{"code":"import { html } from '@polymer/lit-element';\r\nimport { unsafeHTML } from 'lit-html/lib/unsafe-html';\r\nexport const view = (view, css) => {\r\n    return function classDecorator(constructor) {\r\n        return class WithView extends constructor {\r\n            static get template() {\r\n                const t = document.createElement('template');\r\n                t.innerHTML = `<style>${css}</style>${view}`;\r\n                return t;\r\n            }\r\n        };\r\n    };\r\n};\r\nexport const bindAttributes = function classDecorator(constructor) {\r\n    return class BoundAttributes extends constructor {\r\n        _propertiesChanged(props, changedProps, prevProps) {\r\n            // @ts-ignore\r\n            super._propertiesChanged(props, changedProps, prevProps);\r\n            // @ts-ignore\r\n            const attrs = this.constructor._boundAttributes;\r\n            if (attrs && changedProps) {\r\n                Object.keys(changedProps).forEach(k => {\r\n                    if (attrs.includes(k)) {\r\n                        // @ts-ignore\r\n                        const v = props[k];\r\n                        // @ts-ignore\r\n                        if (v || v === 0)\r\n                            this.setAttribute(k, props[k]);\r\n                        // @ts-ignore\r\n                        else\r\n                            this.removeAttribute(k);\r\n                    }\r\n                });\r\n            }\r\n        }\r\n    };\r\n};\r\nexport const component = (name) => {\r\n    return function (klass) {\r\n        window.customElements.define(name, klass);\r\n    };\r\n};\r\n// export const bindAttributes = function classDecorator<T extends { new(...args: any[]): {} }>(constructor: T) {\r\n//     return class BoundAttributes extends constructor {\r\n//         _propertiesChanged(props: object, changedProps: object, prevProps: object) {\r\n//             // @ts-ignore\r\n//             super._propertiesChanged(props, changedProps, prevProps);\r\n//             // @ts-ignore\r\n//             const attrs = (this.constructor as constructor)._boundAttributes;\r\n//             if (attrs && changedProps) {\r\n//                 Object.keys(changedProps).forEach(k => {\r\n//                     if (attrs.includes(k)) {\r\n//                         // @ts-ignore\r\n//                         const v = props[k];\r\n//                         // @ts-ignore\r\n//                         if (v || v === 0) this.setAttribute(k, props[k]);\r\n//                         // @ts-ignore\r\n//                         else this.removeAttribute(k);\r\n//                     }\r\n//                 });\r\n//             }\r\n//         }\r\n//     };\r\n// };\r\nexport const style = (css) => {\r\n    return function classDecorator(constructor) {\r\n        return class WithStyle extends constructor {\r\n            get _style() {\r\n                return html `${unsafeHTML(`<style> ${css} </style>`)}`;\r\n            }\r\n        };\r\n    };\r\n};\r\nexport const dispatchChange = (prop = 'value', event = 'change') => function classDecorator(constructor) {\r\n    return class DispatchChange extends constructor {\r\n        _propertiesChanged(props, changedProps, prevProps) {\r\n            // @ts-ignore\r\n            super._propertiesChanged(props, changedProps, prevProps);\r\n            // @ts-ignore\r\n            if (changedProps && changedProps[prop] !== undefined)\r\n                this.dispatchEvent(new CustomEvent(event));\r\n        }\r\n    };\r\n};\r\n","dts":{"name":"/Users/tristanmatthias/projects/origami/zen/util/decorators.d.ts","text":"import { TemplateResult } from 'lit-html';\r\nexport declare const view: (view: string, css?: string | undefined) => <T extends new (...args: any[]) => {}>(constructor: T) => {\r\n    new (...args: any[]): {};\r\n    readonly template: HTMLTemplateElement;\r\n} & T;\r\nexport declare const bindAttributes: <T extends new (...args: any[]) => {}>(constructor: T) => {\r\n    new (...args: any[]): {\r\n        _propertiesChanged(props: object, changedProps: object, prevProps: object): void;\r\n    };\r\n} & T;\r\nexport declare const component: (name: string) => ClassDecorator;\r\nexport declare const style: (css: string) => <T extends new (...args: any[]) => {}>(constructor: T) => {\r\n    new (...args: any[]): {\r\n        readonly _style: TemplateResult;\r\n    };\r\n} & T;\r\nexport declare const dispatchChange: (prop?: string, event?: string) => <T extends new (...args: any[]) => {}>(constructor: T) => {\r\n    new (...args: any[]): {\r\n        _propertiesChanged(props: object, changedProps: object, prevProps: object): void;\r\n    };\r\n} & T;\r\n"}}
