le-kit 0.0.3 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/admin/index.d.ts +25 -0
- package/dist/admin/index.js +80 -0
- package/dist/cjs/index-CO4npcak.js +1796 -0
- package/dist/cjs/index-CO4npcak.js.map +1 -0
- package/dist/cjs/index.cjs.js +117 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/le-box.cjs.entry.js +184 -0
- package/dist/cjs/le-box.entry.cjs.js.map +1 -0
- package/dist/cjs/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.cjs.js.map +1 -0
- package/dist/cjs/le-button_6.cjs.entry.js +1199 -0
- package/dist/cjs/le-card.cjs.entry.js +29 -0
- package/dist/cjs/le-card.entry.cjs.js.map +1 -0
- package/dist/cjs/le-kit.cjs.js +25 -0
- package/dist/cjs/le-kit.cjs.js.map +1 -0
- package/dist/cjs/le-number-input.cjs.entry.js +202 -0
- package/dist/cjs/le-number-input.entry.cjs.js.map +1 -0
- package/dist/cjs/le-popup.cjs.entry.js +212 -0
- package/dist/cjs/le-popup.entry.cjs.js.map +1 -0
- package/dist/cjs/le-round-progress.cjs.entry.js +106 -0
- package/dist/cjs/le-round-progress.entry.cjs.js.map +1 -0
- package/dist/cjs/le-stack.cjs.entry.js +135 -0
- package/dist/cjs/le-stack.entry.cjs.js.map +1 -0
- package/dist/cjs/le-text.cjs.entry.js +335 -0
- package/dist/cjs/le-text.entry.cjs.js.map +1 -0
- package/dist/cjs/le-turntable.cjs.entry.js +139 -0
- package/dist/cjs/le-turntable.entry.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/utils-BeT0iyCQ.js +152 -0
- package/dist/cjs/utils-BeT0iyCQ.js.map +1 -0
- package/dist/collection/collection-manifest.json +20 -102
- package/dist/collection/components/le-box/le-box.default.css +37 -0
- package/dist/collection/components/le-box/le-box.js +614 -0
- package/dist/collection/components/le-box/le-box.js.map +1 -0
- package/dist/collection/components/le-button/le-button.default.css +263 -0
- package/dist/collection/components/le-button/le-button.js +368 -0
- package/dist/collection/components/le-button/le-button.js.map +1 -0
- package/dist/collection/components/le-card/le-card.default.css +74 -0
- package/dist/collection/components/le-card/le-card.js +102 -0
- package/dist/collection/components/le-card/le-card.js.map +1 -0
- package/dist/collection/components/le-checkbox/le-checkbox.css +93 -0
- package/dist/collection/components/le-checkbox/le-checkbox.js +192 -0
- package/dist/collection/components/le-checkbox/le-checkbox.js.map +1 -0
- package/dist/collection/components/le-component/le-component.css +189 -0
- package/dist/collection/components/le-component/le-component.js +359 -0
- package/dist/collection/components/le-component/le-component.js.map +1 -0
- package/dist/collection/components/le-number-input/le-number-input.css +135 -0
- package/dist/collection/components/le-number-input/le-number-input.js +515 -0
- package/dist/collection/components/le-number-input/le-number-input.js.map +1 -0
- package/dist/collection/components/le-popover/le-popover.css +143 -0
- package/dist/collection/components/le-popover/le-popover.js +693 -0
- package/dist/collection/components/le-popover/le-popover.js.map +1 -0
- package/dist/collection/components/le-popup/le-popup.api.js +101 -0
- package/dist/collection/components/le-popup/le-popup.api.js.map +1 -0
- package/dist/collection/components/le-popup/le-popup.css +222 -0
- package/dist/collection/components/le-popup/le-popup.js +596 -0
- package/dist/collection/components/le-popup/le-popup.js.map +1 -0
- package/dist/collection/components/le-round-progress/le-round-progress.js +184 -84
- package/dist/collection/components/le-round-progress/le-round-progress.js.map +1 -0
- package/dist/collection/components/le-slot/le-slot.default.css +222 -0
- package/dist/collection/components/le-slot/le-slot.js +636 -0
- package/dist/collection/components/le-slot/le-slot.js.map +1 -0
- package/dist/collection/components/le-stack/le-stack.default.css +37 -0
- package/dist/collection/components/le-stack/le-stack.js +389 -0
- package/dist/collection/components/le-stack/le-stack.js.map +1 -0
- package/dist/collection/components/le-string-input/le-string-input.css +83 -0
- package/dist/collection/components/le-string-input/le-string-input.js +359 -0
- package/dist/collection/components/le-string-input/le-string-input.js.map +1 -0
- package/dist/collection/components/le-text/le-text.default.css +169 -0
- package/dist/collection/components/le-text/le-text.js +475 -0
- package/dist/collection/components/le-text/le-text.js.map +1 -0
- package/dist/collection/components/le-turntable/le-turntable.js +210 -102
- package/dist/collection/components/le-turntable/le-turntable.js.map +1 -0
- package/dist/collection/global/app.js +130 -0
- package/dist/collection/global/app.js.map +1 -0
- package/dist/collection/index-admin.js +27 -0
- package/dist/collection/index-admin.js.map +1 -0
- package/dist/collection/index-core.js +25 -0
- package/dist/collection/index-core.js.map +1 -0
- package/dist/collection/index.js +15 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/types/blocks.js +115 -0
- package/dist/collection/types/blocks.js.map +1 -0
- package/dist/collection/types/options.js +2 -0
- package/dist/collection/types/options.js.map +1 -0
- package/dist/collection/utils/utils.js +141 -5
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/components/index.d.ts +64 -0
- package/dist/components/index.js +127 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/le-box.d.ts +11 -0
- package/dist/components/le-box.js +256 -0
- package/dist/components/le-box.js.map +1 -0
- package/dist/components/le-button.d.ts +11 -0
- package/dist/components/le-button.js +9 -0
- package/dist/components/le-button.js.map +1 -0
- package/dist/components/le-button2.js +1408 -0
- package/dist/components/le-button2.js.map +1 -0
- package/dist/components/le-card.d.ts +11 -0
- package/dist/components/le-card.js +83 -0
- package/dist/components/le-card.js.map +1 -0
- package/dist/components/le-checkbox.d.ts +11 -0
- package/dist/components/le-checkbox.js +9 -0
- package/dist/components/le-checkbox.js.map +1 -0
- package/dist/components/le-component.d.ts +11 -0
- package/dist/components/le-component.js +9 -0
- package/dist/components/le-component.js.map +1 -0
- package/dist/components/le-number-input.d.ts +11 -0
- package/dist/components/le-number-input.js +271 -0
- package/dist/components/le-number-input.js.map +1 -0
- package/dist/components/le-popover.d.ts +11 -0
- package/dist/components/le-popover.js +9 -0
- package/dist/components/le-popover.js.map +1 -0
- package/dist/components/le-popover2.js +382 -0
- package/dist/components/le-popover2.js.map +1 -0
- package/dist/components/le-popup.d.ts +11 -0
- package/dist/components/le-popup.js +279 -0
- package/dist/components/le-popup.js.map +1 -0
- package/dist/components/le-round-progress.d.ts +11 -0
- package/dist/components/le-round-progress.js +135 -0
- package/dist/components/le-round-progress.js.map +1 -0
- package/dist/components/le-slot.d.ts +11 -0
- package/dist/components/le-slot.js +9 -0
- package/dist/components/le-slot.js.map +1 -0
- package/dist/components/le-stack.d.ts +11 -0
- package/dist/components/le-stack.js +198 -0
- package/dist/components/le-stack.js.map +1 -0
- package/dist/components/le-string-input.d.ts +11 -0
- package/dist/components/le-string-input.js +9 -0
- package/dist/components/le-string-input.js.map +1 -0
- package/dist/components/le-text.d.ts +11 -0
- package/dist/components/le-text.js +398 -0
- package/dist/components/le-text.js.map +1 -0
- package/dist/components/le-turntable.d.ts +11 -0
- package/dist/components/le-turntable.js +164 -0
- package/dist/components/le-turntable.js.map +1 -0
- package/dist/core/components/index.d.ts +64 -0
- package/dist/core/components/index.js +127 -0
- package/dist/core/components/index.js.map +1 -0
- package/dist/core/components/le-box.d.ts +11 -0
- package/dist/core/components/le-box.js +246 -0
- package/dist/core/components/le-box.js.map +1 -0
- package/dist/core/components/le-button.d.ts +11 -0
- package/dist/core/components/le-button.js +9 -0
- package/dist/core/components/le-button.js.map +1 -0
- package/dist/core/components/le-button2.js +1358 -0
- package/dist/core/components/le-button2.js.map +1 -0
- package/dist/core/components/le-card.d.ts +11 -0
- package/dist/core/components/le-card.js +73 -0
- package/dist/core/components/le-card.js.map +1 -0
- package/dist/core/components/le-checkbox.d.ts +11 -0
- package/dist/core/components/le-checkbox.js +9 -0
- package/dist/core/components/le-checkbox.js.map +1 -0
- package/dist/core/components/le-component.js.map +1 -0
- package/dist/core/components/le-number-input.d.ts +11 -0
- package/dist/core/components/le-number-input.js +261 -0
- package/dist/core/components/le-number-input.js.map +1 -0
- package/dist/core/components/le-popover.d.ts +11 -0
- package/dist/core/components/le-popover.js +9 -0
- package/dist/core/components/le-popover.js.map +1 -0
- package/dist/core/components/le-popover2.js +382 -0
- package/dist/core/components/le-popover2.js.map +1 -0
- package/dist/core/components/le-popup.d.ts +11 -0
- package/dist/core/components/le-popup.js +269 -0
- package/dist/core/components/le-popup.js.map +1 -0
- package/dist/core/components/le-round-progress.d.ts +11 -0
- package/dist/core/components/le-round-progress.js +135 -0
- package/dist/core/components/le-round-progress.js.map +1 -0
- package/dist/core/components/le-slot.js.map +1 -0
- package/dist/core/components/le-stack.d.ts +11 -0
- package/dist/core/components/le-stack.js +188 -0
- package/dist/core/components/le-stack.js.map +1 -0
- package/dist/core/components/le-string-input.d.ts +11 -0
- package/dist/core/components/le-string-input.js +9 -0
- package/dist/core/components/le-string-input.js.map +1 -0
- package/dist/core/components/le-text.d.ts +11 -0
- package/dist/core/components/le-text.js +388 -0
- package/dist/core/components/le-text.js.map +1 -0
- package/dist/core/components/le-turntable.d.ts +11 -0
- package/dist/core/components/le-turntable.js +164 -0
- package/dist/core/components/le-turntable.js.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.js +74 -0
- package/dist/core/stencil-runtime.js +1 -0
- package/dist/docs.d.ts +443 -0
- package/dist/docs.json +5185 -0
- package/dist/esm/index-D71TXvJa.js +1781 -0
- package/dist/esm/index-D71TXvJa.js.map +1 -0
- package/dist/esm/index.js +105 -5
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/le-box.entry.js +182 -0
- package/dist/esm/le-box.entry.js.map +1 -0
- package/dist/esm/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.js.map +1 -0
- package/dist/esm/le-button_6.entry.js +1192 -0
- package/dist/esm/le-card.entry.js +27 -0
- package/dist/esm/le-card.entry.js.map +1 -0
- package/dist/esm/le-kit.js +21 -0
- package/dist/esm/le-kit.js.map +1 -0
- package/dist/esm/le-number-input.entry.js +200 -0
- package/dist/esm/le-number-input.entry.js.map +1 -0
- package/dist/esm/le-popup.entry.js +210 -0
- package/dist/esm/le-popup.entry.js.map +1 -0
- package/dist/esm/le-round-progress.entry.js +104 -0
- package/dist/esm/le-round-progress.entry.js.map +1 -0
- package/dist/esm/le-stack.entry.js +133 -0
- package/dist/esm/le-stack.entry.js.map +1 -0
- package/dist/esm/le-text.entry.js +333 -0
- package/dist/esm/le-text.entry.js.map +1 -0
- package/dist/esm/le-turntable.entry.js +137 -0
- package/dist/esm/le-turntable.entry.js.map +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/utils-CJLZrrdC.js +146 -0
- package/dist/esm/utils-CJLZrrdC.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -2
- package/dist/le-kit/index-D21JjI31.js.map +1 -0
- package/dist/le-kit/index.esm.js +2 -0
- package/dist/le-kit/index.esm.js.map +1 -0
- package/dist/le-kit/le-box.entry.esm.js.map +1 -0
- package/dist/le-kit/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.esm.js.map +1 -0
- package/dist/le-kit/le-card.entry.esm.js.map +1 -0
- package/dist/le-kit/le-kit.css +1 -0
- package/dist/le-kit/le-kit.esm.js +2 -0
- package/dist/le-kit/le-kit.esm.js.map +1 -0
- package/dist/le-kit/le-number-input.entry.esm.js.map +1 -0
- package/dist/le-kit/le-popup.entry.esm.js.map +1 -0
- package/dist/le-kit/le-round-progress.entry.esm.js.map +1 -0
- package/dist/le-kit/le-stack.entry.esm.js.map +1 -0
- package/dist/le-kit/le-text.entry.esm.js.map +1 -0
- package/dist/le-kit/le-turntable.entry.esm.js.map +1 -0
- package/dist/le-kit/loader.esm.js.map +1 -0
- package/dist/le-kit/p-024a764e.entry.js +2 -0
- package/dist/le-kit/p-024a764e.entry.js.map +1 -0
- package/dist/le-kit/p-073cf0b9.entry.js +2 -0
- package/dist/le-kit/p-073cf0b9.entry.js.map +1 -0
- package/dist/le-kit/p-0955b105.entry.js +2 -0
- package/dist/le-kit/p-0955b105.entry.js.map +1 -0
- package/dist/le-kit/p-18d79ee2.entry.js +2 -0
- package/dist/le-kit/p-18d79ee2.entry.js.map +1 -0
- package/dist/le-kit/p-4b1d3b6d.entry.js +2 -0
- package/dist/le-kit/p-4b1d3b6d.entry.js.map +1 -0
- package/dist/le-kit/p-79d179bd.entry.js +2 -0
- package/dist/le-kit/p-79d179bd.entry.js.map +1 -0
- package/dist/le-kit/p-D71TXvJa.js +3 -0
- package/dist/le-kit/p-D71TXvJa.js.map +1 -0
- package/dist/le-kit/p-c8a9288e.entry.js +2 -0
- package/dist/le-kit/p-c8a9288e.entry.js.map +1 -0
- package/dist/le-kit/p-cfc35bd3.entry.js +2 -0
- package/dist/le-kit/p-cfc35bd3.entry.js.map +1 -0
- package/dist/le-kit/p-d04da1f5.entry.js +2 -0
- package/dist/le-kit/p-d04da1f5.entry.js.map +1 -0
- package/dist/le-kit/p-qIai5-eB.js +2 -0
- package/dist/le-kit/p-qIai5-eB.js.map +1 -0
- package/dist/le-kit/utils-apol-Xc_.js.map +1 -0
- package/dist/themes/base.css +89 -0
- package/dist/themes/dark.css +100 -0
- package/dist/themes/default.css +108 -0
- package/dist/themes/gradient.css +100 -0
- package/dist/themes/index.css +413 -0
- package/dist/themes/minimal.css +100 -0
- package/dist/themes/warm.css +100 -0
- package/dist/types/components/le-box/le-box.d.ts +111 -0
- package/dist/types/components/le-button/le-button.d.ts +78 -0
- package/dist/types/components/le-card/le-card.d.ts +37 -0
- package/dist/types/components/le-checkbox/le-checkbox.d.ts +46 -0
- package/dist/types/components/le-component/le-component.d.ts +115 -0
- package/dist/types/components/le-number-input/le-number-input.d.ts +106 -0
- package/dist/types/components/le-popover/le-popover.d.ts +109 -0
- package/dist/types/components/le-popup/le-popup.api.d.ts +73 -0
- package/dist/types/components/le-popup/le-popup.d.ts +122 -0
- package/dist/types/components/le-round-progress/le-round-progress.d.ts +2 -3
- package/dist/types/components/le-slot/le-slot.d.ts +149 -0
- package/dist/types/components/le-stack/le-stack.d.ts +73 -0
- package/dist/types/components/le-string-input/le-string-input.d.ts +83 -0
- package/dist/types/components/le-text/le-text.d.ts +141 -0
- package/dist/types/components/le-turntable/le-turntable.d.ts +1 -2
- package/dist/types/components.d.ts +2030 -62
- package/dist/types/global/app.d.ts +40 -0
- package/dist/types/index-admin.d.ts +29 -0
- package/dist/types/index-core.d.ts +27 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/stencil-public-runtime.d.ts +1756 -0
- package/dist/types/types/blocks.d.ts +136 -0
- package/dist/types/types/options.d.ts +124 -0
- package/dist/types/utils/utils.d.ts +54 -1
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +64 -13
- package/readme.md +180 -46
- package/dist/cjs/es5/build/jqoqzji9.entry.js +0 -6
- package/dist/cjs/es5/build/jqoqzji9.sc.entry.js +0 -6
- package/dist/cjs/es5/build/novg0vs0.entry.js +0 -9
- package/dist/cjs/es5/build/novg0vs0.sc.entry.js +0 -9
- package/dist/cjs/es5/index.js +0 -1
- package/dist/cjs/es5/le-kit.components.js +0 -4
- package/dist/cjs/es5/le-kit.core.js +0 -459
- package/dist/cjs/es5/le-kit.define.js +0 -9
- package/dist/cjs/es5/polyfills/array.js +0 -63
- package/dist/cjs/es5/polyfills/css-shim.js +0 -178
- package/dist/cjs/es5/polyfills/dom.js +0 -125
- package/dist/cjs/es5/polyfills/fetch.js +0 -186
- package/dist/cjs/es5/polyfills/map.js +0 -54
- package/dist/cjs/es5/polyfills/object.js +0 -27
- package/dist/cjs/es5/polyfills/promise.js +0 -80
- package/dist/cjs/es5/polyfills/string.js +0 -15
- package/dist/cjs/es5/polyfills/tslib.js +0 -244
- package/dist/cjs/es5/polyfills/url.js +0 -68
- package/dist/collection/interface.js +0 -0
- package/dist/esm/es2017/build/jqoqzji9.entry.js +0 -88
- package/dist/esm/es2017/build/jqoqzji9.sc.entry.js +0 -88
- package/dist/esm/es2017/build/novg0vs0.entry.js +0 -106
- package/dist/esm/es2017/build/novg0vs0.sc.entry.js +0 -106
- package/dist/esm/es2017/index.js +0 -1
- package/dist/esm/es2017/le-kit.components.js +0 -2
- package/dist/esm/es2017/le-kit.core.js +0 -5
- package/dist/esm/es2017/le-kit.define.js +0 -9
- package/dist/esm/es5/build/jqoqzji9.entry.js +0 -1
- package/dist/esm/es5/build/jqoqzji9.sc.entry.js +0 -1
- package/dist/esm/es5/build/novg0vs0.entry.js +0 -1
- package/dist/esm/es5/build/novg0vs0.sc.entry.js +0 -1
- package/dist/esm/es5/index.js +0 -1
- package/dist/esm/es5/le-kit.components.js +0 -2
- package/dist/esm/es5/le-kit.core.js +0 -5
- package/dist/esm/es5/le-kit.define.js +0 -9
- package/dist/esm/es5/polyfills/array.js +0 -23
- package/dist/esm/es5/polyfills/css-shim.js +0 -8
- package/dist/esm/es5/polyfills/dom.js +0 -22
- package/dist/esm/es5/polyfills/fetch.js +0 -20
- package/dist/esm/es5/polyfills/map.js +0 -7
- package/dist/esm/es5/polyfills/object.js +0 -20
- package/dist/esm/es5/polyfills/promise.js +0 -8
- package/dist/esm/es5/polyfills/string.js +0 -12
- package/dist/esm/es5/polyfills/tslib.js +0 -160
- package/dist/esm/es5/polyfills/url.js +0 -7
- package/dist/le-kit/jqoqzji9.entry.js +0 -1
- package/dist/le-kit/jqoqzji9.es5.entry.js +0 -1
- package/dist/le-kit/jqoqzji9.sc.entry.js +0 -1
- package/dist/le-kit/jqoqzji9.sc.es5.entry.js +0 -1
- package/dist/le-kit/le-kit.lfyfa4jd.js +0 -123
- package/dist/le-kit/le-kit.rzqb8hph.js +0 -4
- package/dist/le-kit/novg0vs0.entry.js +0 -1
- package/dist/le-kit/novg0vs0.es5.entry.js +0 -1
- package/dist/le-kit/novg0vs0.sc.entry.js +0 -1
- package/dist/le-kit/novg0vs0.sc.es5.entry.js +0 -1
- package/dist/le-kit.js +0 -1
- package/dist/loader/index.cjs.js +0 -1
- package/dist/loader/index.d.ts +0 -1
- package/dist/loader/index.es2017.js +0 -1
- package/dist/loader/index.js +0 -1
- package/dist/loader/package.json +0 -9
- package/dist/types/stencil.core.d.ts +0 -1203
- package/dist/web-components.json +0 -41
|
@@ -0,0 +1,1358 @@
|
|
|
1
|
+
import { setMode, proxyCustomElement, HTMLElement, createEvent, h, Host, Fragment } from '@stencil/core/internal/client';
|
|
2
|
+
import { d as defineCustomElement$5 } from './le-popover2.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Global mode initialization for le-kit components.
|
|
6
|
+
*
|
|
7
|
+
* Mode inheritance works as follows:
|
|
8
|
+
* 1. Check the element's own `mode` attribute
|
|
9
|
+
* 2. Traverse up the DOM to find a parent with `mode` attribute
|
|
10
|
+
* 3. Check the document root element (html) for `mode` attribute
|
|
11
|
+
* 4. Fall back to 'default'
|
|
12
|
+
*
|
|
13
|
+
* This allows setting mode at any level:
|
|
14
|
+
* - `<html mode="admin">` - all components in admin mode
|
|
15
|
+
* - `<le-card mode="admin">` - this card and its children in admin mode
|
|
16
|
+
*/
|
|
17
|
+
function initializeMode() {
|
|
18
|
+
setMode((el) => {
|
|
19
|
+
// 1. Check element's own mode attribute
|
|
20
|
+
const ownMode = el.getAttribute('mode');
|
|
21
|
+
if (ownMode) {
|
|
22
|
+
return ownMode;
|
|
23
|
+
}
|
|
24
|
+
// 2. Traverse up the DOM tree to find inherited mode
|
|
25
|
+
let parent = el.parentElement;
|
|
26
|
+
while (parent) {
|
|
27
|
+
const parentMode = parent.getAttribute('mode');
|
|
28
|
+
if (parentMode) {
|
|
29
|
+
return parentMode;
|
|
30
|
+
}
|
|
31
|
+
parent = parent.parentElement;
|
|
32
|
+
}
|
|
33
|
+
// 3. Check document root element
|
|
34
|
+
const rootMode = document.documentElement.getAttribute('mode');
|
|
35
|
+
if (rootMode) {
|
|
36
|
+
return rootMode;
|
|
37
|
+
}
|
|
38
|
+
// 4. Default mode
|
|
39
|
+
return 'default';
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to get the current mode for an element.
|
|
44
|
+
* Can be used programmatically in components.
|
|
45
|
+
*
|
|
46
|
+
* This function traverses both regular DOM and shadow DOM boundaries
|
|
47
|
+
* to find the nearest mode attribute.
|
|
48
|
+
*/
|
|
49
|
+
function getMode(el) {
|
|
50
|
+
// Check element's own mode
|
|
51
|
+
const ownMode = el.getAttribute('mode');
|
|
52
|
+
if (ownMode) {
|
|
53
|
+
return ownMode;
|
|
54
|
+
}
|
|
55
|
+
// Traverse up DOM, crossing shadow boundaries
|
|
56
|
+
let current = el;
|
|
57
|
+
while (current) {
|
|
58
|
+
// Try parent element first
|
|
59
|
+
if (current instanceof Element && current.parentElement) {
|
|
60
|
+
current = current.parentElement;
|
|
61
|
+
const mode = current.getAttribute?.('mode');
|
|
62
|
+
if (mode) {
|
|
63
|
+
return mode;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// No parent element - check if we're in a shadow root
|
|
68
|
+
const root = current.getRootNode();
|
|
69
|
+
if (root instanceof ShadowRoot) {
|
|
70
|
+
// Cross the shadow boundary to the host element
|
|
71
|
+
current = root.host;
|
|
72
|
+
const mode = current.getAttribute?.('mode');
|
|
73
|
+
if (mode) {
|
|
74
|
+
return mode;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// We've reached the document root
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Check document root
|
|
84
|
+
const rootMode = document.documentElement.getAttribute('mode');
|
|
85
|
+
if (rootMode) {
|
|
86
|
+
return rootMode;
|
|
87
|
+
}
|
|
88
|
+
return 'default';
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Helper function to get the current theme for an element.
|
|
92
|
+
* Theme inheritance works the same as mode - cascades through DOM.
|
|
93
|
+
*/
|
|
94
|
+
function getTheme(el) {
|
|
95
|
+
// Check element's own theme
|
|
96
|
+
const ownTheme = el.getAttribute('theme');
|
|
97
|
+
if (ownTheme) {
|
|
98
|
+
return ownTheme;
|
|
99
|
+
}
|
|
100
|
+
// Traverse up DOM
|
|
101
|
+
let parent = el.parentElement;
|
|
102
|
+
while (parent) {
|
|
103
|
+
const parentTheme = parent.getAttribute('theme');
|
|
104
|
+
if (parentTheme) {
|
|
105
|
+
return parentTheme;
|
|
106
|
+
}
|
|
107
|
+
parent = parent.parentElement;
|
|
108
|
+
}
|
|
109
|
+
// Check root
|
|
110
|
+
const rootTheme = document.documentElement.getAttribute('theme');
|
|
111
|
+
if (rootTheme) {
|
|
112
|
+
return rootTheme;
|
|
113
|
+
}
|
|
114
|
+
return 'default';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Helper function to set mode on the document root.
|
|
118
|
+
* Useful for switching all components to admin mode.
|
|
119
|
+
*/
|
|
120
|
+
function setGlobalMode(mode) {
|
|
121
|
+
document.documentElement.setAttribute('mode', mode);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Helper function to set theme on the document root.
|
|
125
|
+
* Useful for switching all components to a different theme.
|
|
126
|
+
*/
|
|
127
|
+
function setGlobalTheme(theme) {
|
|
128
|
+
document.documentElement.setAttribute('theme', theme);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Utility functions for le-kit components
|
|
133
|
+
*/
|
|
134
|
+
/**
|
|
135
|
+
* Generates a unique ID for component instances
|
|
136
|
+
*/
|
|
137
|
+
function generateId(prefix = 'le') {
|
|
138
|
+
return `${prefix}-${Math.random().toString(36).substring(2, 9)}`;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Parses a comma-separated string into an array
|
|
142
|
+
*/
|
|
143
|
+
function parseCommaSeparated(value) {
|
|
144
|
+
if (!value)
|
|
145
|
+
return [];
|
|
146
|
+
return value
|
|
147
|
+
.split(',')
|
|
148
|
+
.map(s => s.trim())
|
|
149
|
+
.filter(Boolean);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Checks if a slot has content
|
|
153
|
+
*/
|
|
154
|
+
function slotHasContent(el, slotName = '') {
|
|
155
|
+
const selector = slotName ? `[slot="${slotName}"]` : ':not([slot])';
|
|
156
|
+
return el.querySelector(selector) !== null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Sets up a MutationObserver to track mode changes on ancestor elements.
|
|
160
|
+
* Returns a cleanup function to disconnect the observer.
|
|
161
|
+
*
|
|
162
|
+
* If the element or any ancestor has an explicit `mode` attribute, that creates
|
|
163
|
+
* a "mode boundary" - the mode is determined from that point, not from further up.
|
|
164
|
+
* This allows components like le-popover to force default mode for their children.
|
|
165
|
+
*
|
|
166
|
+
* @param el - The component's host element
|
|
167
|
+
* @param callback - Function to call when mode changes, receives the new mode
|
|
168
|
+
* @returns Cleanup function to disconnect the observer
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```tsx
|
|
172
|
+
* export class MyComponent {
|
|
173
|
+
* @Element() el: HTMLElement;
|
|
174
|
+
* @State() adminMode: boolean = false;
|
|
175
|
+
* private disconnectModeObserver?: () => void;
|
|
176
|
+
*
|
|
177
|
+
* connectedCallback() {
|
|
178
|
+
* this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {
|
|
179
|
+
* this.adminMode = mode === 'admin';
|
|
180
|
+
* });
|
|
181
|
+
* }
|
|
182
|
+
*
|
|
183
|
+
* disconnectedCallback() {
|
|
184
|
+
* this.disconnectModeObserver?.();
|
|
185
|
+
* }
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
function observeModeChanges(el, callback) {
|
|
190
|
+
// Call immediately with current mode
|
|
191
|
+
callback(getMode(el));
|
|
192
|
+
// Set up observer for mode attribute changes
|
|
193
|
+
const observer = new MutationObserver(() => {
|
|
194
|
+
callback(getMode(el));
|
|
195
|
+
});
|
|
196
|
+
// Observe the element itself (for mode boundary changes)
|
|
197
|
+
observer.observe(el, {
|
|
198
|
+
attributes: true,
|
|
199
|
+
attributeFilter: ['mode'],
|
|
200
|
+
});
|
|
201
|
+
// Observe document root
|
|
202
|
+
observer.observe(document.documentElement, {
|
|
203
|
+
attributes: true,
|
|
204
|
+
attributeFilter: ['mode'],
|
|
205
|
+
});
|
|
206
|
+
// Traverse up, crossing shadow boundaries, and observe each element
|
|
207
|
+
let current = el;
|
|
208
|
+
while (current) {
|
|
209
|
+
if (current instanceof Element && current.parentElement) {
|
|
210
|
+
current = current.parentElement;
|
|
211
|
+
observer.observe(current, {
|
|
212
|
+
attributes: true,
|
|
213
|
+
attributeFilter: ['mode'],
|
|
214
|
+
});
|
|
215
|
+
// If this element has an explicit mode, it's a boundary
|
|
216
|
+
if (current.hasAttribute('mode')) {
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// Check if we're in a shadow root
|
|
222
|
+
const root = current.getRootNode();
|
|
223
|
+
if (root instanceof ShadowRoot) {
|
|
224
|
+
// Cross the shadow boundary and observe the host
|
|
225
|
+
current = root.host;
|
|
226
|
+
observer.observe(current, {
|
|
227
|
+
attributes: true,
|
|
228
|
+
attributeFilter: ['mode'],
|
|
229
|
+
});
|
|
230
|
+
// If the host has an explicit mode, it's a boundary
|
|
231
|
+
if (current.hasAttribute('mode')) {
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Return cleanup function
|
|
241
|
+
return () => observer.disconnect();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Combines multiple class names into a single string, filtering out falsy values.
|
|
245
|
+
*
|
|
246
|
+
* @param classes - arguments of class names, undefined, arrays, objects with boolean values and nested combinations of these
|
|
247
|
+
* @returns Combined class names string
|
|
248
|
+
*/
|
|
249
|
+
function classnames(...classes) {
|
|
250
|
+
const result = [];
|
|
251
|
+
classes.forEach(cls => {
|
|
252
|
+
if (!cls)
|
|
253
|
+
return;
|
|
254
|
+
if (typeof cls === 'string') {
|
|
255
|
+
result.push(cls);
|
|
256
|
+
}
|
|
257
|
+
else if (Array.isArray(cls)) {
|
|
258
|
+
result.push(classnames(...cls));
|
|
259
|
+
}
|
|
260
|
+
else if (typeof cls === 'object') {
|
|
261
|
+
Object.entries(cls).forEach(([key, value]) => {
|
|
262
|
+
if (value) {
|
|
263
|
+
result.push(key);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return result.join(' ');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const leStringInputCss = ":host{display:block;--le-input-bg:var(--le-color-surface, #ffffff);--le-input-color:var(--le-color-text-primary, #333333);--le-input-border:var(--le-border-width, 2px) solid var(--le-color-border-input, #007bff);--le-input-radius:var(--le-radius-sm, 4px);--le-input-padding:2px 6px;--le-input-height:1.5rem;--le-input-label-color:var(--le-color-text-primary, #333333);--le-input-desc-color:var(--le-color-text-secondary, #666666);--le-input-placeholder-color:#999999}.le-input-wrapper{display:flex;flex-direction:column;gap:2px}.le-input-label{display:block;font-size:0.9em;font-weight:500;color:var(--le-input-label-color);margin-bottom:2px}.le-input-container{position:relative;display:flex;align-items:center;background:var(--le-input-bg);border:var(--le-input-border);border-radius:var(--le-input-radius);transition:border-color 0.2s}.le-input-container:focus-within{outline:2px solid var(--le-color-focus);outline-offset:2px}:host([disabled]) .le-input-container{opacity:0.6;background-color:rgba(0,0,0,0.05);cursor:not-allowed}input{flex:1;min-height:var(--le-input-height);padding:var(--le-input-padding);border:none;background:transparent;color:var(--le-input-color);font-family:inherit;font-size:inherit;outline:none;width:100%}input::placeholder{color:var(--le-input-placeholder-color)}.icon-start,.icon-end{display:flex;align-items:center;justify-content:center;padding:0 8px;color:var(--le-input-desc-color)}.le-input-description{font-size:0.85em;color:var(--le-input-desc-color);margin-top:2px}.le-input-description::has(le-slot>slot[name=description]:empty){display:none}";
|
|
272
|
+
|
|
273
|
+
const LeStringInput = /*@__PURE__*/ proxyCustomElement(class LeStringInput extends HTMLElement {
|
|
274
|
+
constructor(registerHost) {
|
|
275
|
+
super();
|
|
276
|
+
if (registerHost !== false) {
|
|
277
|
+
this.__registerHost();
|
|
278
|
+
}
|
|
279
|
+
this.__attachShadow();
|
|
280
|
+
this.leChange = createEvent(this, "change", 7);
|
|
281
|
+
this.leInput = createEvent(this, "input", 7);
|
|
282
|
+
}
|
|
283
|
+
get el() { return this; }
|
|
284
|
+
/**
|
|
285
|
+
* Mode of the popover should be 'default' for internal use
|
|
286
|
+
*/
|
|
287
|
+
mode;
|
|
288
|
+
/**
|
|
289
|
+
* The value of the input
|
|
290
|
+
*/
|
|
291
|
+
value;
|
|
292
|
+
/**
|
|
293
|
+
* The name of the input
|
|
294
|
+
*/
|
|
295
|
+
name;
|
|
296
|
+
/**
|
|
297
|
+
* The type of the input (text, email, password, etc.)
|
|
298
|
+
*/
|
|
299
|
+
type = 'text';
|
|
300
|
+
/**
|
|
301
|
+
* Label for the input
|
|
302
|
+
*/
|
|
303
|
+
label;
|
|
304
|
+
/**
|
|
305
|
+
* Icon for the start icon
|
|
306
|
+
*/
|
|
307
|
+
iconStart;
|
|
308
|
+
/**
|
|
309
|
+
* Icon for the end icon
|
|
310
|
+
*/
|
|
311
|
+
iconEnd;
|
|
312
|
+
/**
|
|
313
|
+
* Placeholder text
|
|
314
|
+
*/
|
|
315
|
+
placeholder;
|
|
316
|
+
/**
|
|
317
|
+
* Whether the input is disabled
|
|
318
|
+
*/
|
|
319
|
+
disabled = false;
|
|
320
|
+
/**
|
|
321
|
+
* Whether the input is read-only
|
|
322
|
+
*/
|
|
323
|
+
readonly = false;
|
|
324
|
+
/**
|
|
325
|
+
* External ID for linking with external systems
|
|
326
|
+
*/
|
|
327
|
+
externalId;
|
|
328
|
+
/**
|
|
329
|
+
* Emitted when the value changes (on blur or Enter)
|
|
330
|
+
*/
|
|
331
|
+
leChange;
|
|
332
|
+
/**
|
|
333
|
+
* Emitted when the input value changes (on keystroke)
|
|
334
|
+
*/
|
|
335
|
+
leInput;
|
|
336
|
+
handleInput = (ev) => {
|
|
337
|
+
const input = ev.target;
|
|
338
|
+
this.value = input.value;
|
|
339
|
+
this.leInput.emit({
|
|
340
|
+
value: this.value,
|
|
341
|
+
name: this.name,
|
|
342
|
+
externalId: this.externalId
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
handleChange = (ev) => {
|
|
346
|
+
const input = ev.target;
|
|
347
|
+
this.value = input.value;
|
|
348
|
+
this.leChange.emit({
|
|
349
|
+
value: this.value,
|
|
350
|
+
name: this.name,
|
|
351
|
+
externalId: this.externalId
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
handleClick = (ev) => {
|
|
355
|
+
ev.stopPropagation();
|
|
356
|
+
};
|
|
357
|
+
render() {
|
|
358
|
+
return (h(Host, { class: classnames({ 'disabled': this.disabled }) }, h("div", { key: '4acae8d3c34da2a86970a616c493ff210d561f5f', class: "le-input-wrapper" }, this.label && (h("label", { key: '609191b45187b6b1a65d05cd594b149760ac6882', class: "le-input-label", htmlFor: this.name }, this.label)), h("div", { key: '36b4caff4468ac7421db03f811cb3ef4a622b001', class: "le-input-container" }, this.iconStart && (h("span", { key: '344f88887fe8270bbef7e26ec1ad5da9fae1f8e4', class: "icon-start" }, this.iconStart)), h("input", { key: '4ba7beeddd7fb3cf23d03e029d11a804764cdd6e', id: this.name, type: this.type, name: this.name, value: this.value, placeholder: this.placeholder, disabled: this.disabled, readOnly: this.readonly, onInput: this.handleInput, onChange: this.handleChange, onClick: this.handleClick }), this.iconEnd && (h("span", { key: '7cdd4b52c3e1a1b18b19e697bdb42431941bba01', class: "icon-end" }, this.iconEnd))), h("div", { key: '113a75aa413e4d95300aeaa97d1ce7a75cf68c7a', class: "le-input-description" }, h("slot", { key: '2674056dc915fabdb4fcbcaa13294a116b9509a6', name: "description" })))));
|
|
359
|
+
}
|
|
360
|
+
static get style() { return leStringInputCss; }
|
|
361
|
+
}, [769, "le-string-input", {
|
|
362
|
+
"mode": [1537],
|
|
363
|
+
"value": [1537],
|
|
364
|
+
"name": [1],
|
|
365
|
+
"type": [1],
|
|
366
|
+
"label": [1],
|
|
367
|
+
"iconStart": [1, "icon-start"],
|
|
368
|
+
"iconEnd": [1, "icon-end"],
|
|
369
|
+
"placeholder": [1],
|
|
370
|
+
"disabled": [4],
|
|
371
|
+
"readonly": [4],
|
|
372
|
+
"externalId": [1, "external-id"]
|
|
373
|
+
}]);
|
|
374
|
+
function defineCustomElement$4() {
|
|
375
|
+
if (typeof customElements === "undefined") {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const components = ["le-string-input", "le-button", "le-checkbox", "le-popover", "le-string-input"];
|
|
379
|
+
components.forEach(tagName => { switch (tagName) {
|
|
380
|
+
case "le-string-input":
|
|
381
|
+
if (!customElements.get(tagName)) {
|
|
382
|
+
customElements.define(tagName, LeStringInput);
|
|
383
|
+
}
|
|
384
|
+
break;
|
|
385
|
+
case "le-button":
|
|
386
|
+
if (!customElements.get(tagName)) {
|
|
387
|
+
defineCustomElement();
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
case "le-checkbox":
|
|
391
|
+
if (!customElements.get(tagName)) {
|
|
392
|
+
defineCustomElement$1();
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
case "le-popover":
|
|
396
|
+
if (!customElements.get(tagName)) {
|
|
397
|
+
defineCustomElement$5();
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
case "le-string-input":
|
|
401
|
+
if (!customElements.get(tagName)) {
|
|
402
|
+
defineCustomElement$4();
|
|
403
|
+
}
|
|
404
|
+
break;
|
|
405
|
+
} });
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const leSlotDefaultCss = ":host{display:contents;--le-slot-border-color:#0088ff;--le-slot-bg-color:rgba(0, 136, 255, 0.05);--le-slot-header-bg:rgb(218, 238, 255);--le-slot-label-color:#0066cc;--le-slot-description-color:#666;--le-slot-required-color:#e53935;--le-slot-dropzone-min-height:20px;--le-slot-dropzone-border-color:#ccc}.le-slot-container,.le-slot-header,.le-slot-description,.le-slot-dropzone,.le-slot-input{display:none}.hidden-slot{display:none}:host(.admin-mode){display:block;flex:1}:host(.admin-mode) .le-slot-container{position:relative;display:flex;flex-direction:column;border:2px dashed var(--le-slot-border-color);border-radius:4px;background:var(--le-slot-bg-color);margin:4px 0}:host(.admin-mode) .le-slot-header{display:flex;align-items:center;gap:4px;padding:0 0 0 var(--le-spacing-1, 4px);background:var(--le-slot-header-bg);border-bottom:1px solid var(--le-slot-border-color);font-size:var(--le-font-size-xs, 11px);font-weight:400;text-transform:capitalize}:host(.admin-mode) .le-slot-header-no-label{justify-content:flex-end;height:16px;border:none;background-color:transparent}.le-slot-label{color:var(--le-slot-label-color);text-align:start;overflow:hidden;width:0;flex:1 1 0%}.le-slot-required{color:var(--le-slot-required-color);font-weight:bold}:host(.admin-mode) .le-slot-description{display:block;padding:4px 8px;font-size:12px;color:var(--le-slot-description-color);font-style:italic}:host(.admin-mode) .le-slot-description-icon{display:inline-block;font-size:9px;line-height:1;cursor:pointer;color:var(--le-slot-description-color)}:host(.admin-mode) .le-slot-dropzone{display:block;min-height:var(--le-slot-dropzone-min-height);padding:var(--le-spacing-1, 4px);position:relative}:host(.admin-mode) .le-slot-dropzone:empty::before{content:'Drop content here';display:flex;align-items:center;justify-content:center;position:absolute;inset:8px;border:2px dashed var(--le-slot-dropzone-border-color);border-radius:4px;color:#999;font-size:12px;pointer-events:none}:host(.admin-mode.drag-over) .le-slot-container{border-color:#00cc66;background:rgba(0, 204, 102, 0.1)}:host(.admin-mode.drag-over) .le-slot-dropzone:empty::before{border-color:#00cc66;color:#00cc66;content:'Release to drop'}:host(.admin-mode) .le-slot-input{display:block;padding:var(--le-spacing-1, 4px)}:host(.admin-mode) .le-slot-input input,:host(.admin-mode) .le-slot-input textarea{display:block;width:100%;padding:8px 10px;border:1px solid var(--le-slot-dropzone-border-color);border-radius:4px;font-family:inherit;font-size:14px;line-height:1.4;background:#fff;color:#333;box-sizing:border-box;transition:border-color 0.2s, box-shadow 0.2s}:host(.admin-mode) .le-slot-input input:focus,:host(.admin-mode) .le-slot-input textarea:focus{outline:none;border-color:var(--le-slot-border-color);box-shadow:0 0 0 3px rgba(0, 136, 255, 0.15)}:host(.admin-mode) .le-slot-input input::placeholder,:host(.admin-mode) .le-slot-input textarea::placeholder{color:#999}:host(.admin-mode) .le-slot-input textarea{resize:vertical;min-height:60px}:host(.admin-mode) .le-slot-input slot{display:none}.le-slot-invalid{color:var(--le-slot-required-color);font-size:10px;margin-left:auto;font-weight:normal;text-transform:none}:host(.admin-mode) .le-slot-input.has-error input,:host(.admin-mode) .le-slot-input.has-error textarea{border-color:var(--le-slot-required-color);background:rgba(229, 57, 53, 0.05)}:host(.admin-mode) .le-slot-input.has-error input:focus,:host(.admin-mode) .le-slot-input.has-error textarea:focus{border-color:var(--le-slot-required-color);box-shadow:0 0 0 3px rgba(229, 57, 53, 0.15)}.le-slot-add-btn{font-size:24px;line-height:0px;width:12px;height:12px}.le-slot-header-no-label .le-slot-add-btn{font-size:16px}.le-slot-button{width:20px;height:20px}:host(.admin-mode) .le-slot-header-no-label.le-slot-header-text{height:0}";
|
|
409
|
+
|
|
410
|
+
const LeSlot = /*@__PURE__*/ proxyCustomElement(class LeSlot extends HTMLElement {
|
|
411
|
+
constructor(registerHost) {
|
|
412
|
+
super();
|
|
413
|
+
if (registerHost !== false) {
|
|
414
|
+
this.__registerHost();
|
|
415
|
+
}
|
|
416
|
+
this.__attachShadow();
|
|
417
|
+
this.leSlotChange = createEvent(this, "leSlotChange", 7);
|
|
418
|
+
}
|
|
419
|
+
get el() { return this; }
|
|
420
|
+
/**
|
|
421
|
+
* The type of slot content.
|
|
422
|
+
* - `slot`: Default, shows a dropzone for components (default)
|
|
423
|
+
* - `text`: Shows a single-line text input
|
|
424
|
+
* - `textarea`: Shows a multi-line text area
|
|
425
|
+
*/
|
|
426
|
+
type = 'slot';
|
|
427
|
+
/**
|
|
428
|
+
* The name of the slot this placeholder represents.
|
|
429
|
+
* Should match the slot name in the parent component.
|
|
430
|
+
*/
|
|
431
|
+
name = '';
|
|
432
|
+
/**
|
|
433
|
+
* Label to display in admin mode.
|
|
434
|
+
* If not provided, the slot name will be used.
|
|
435
|
+
*/
|
|
436
|
+
label;
|
|
437
|
+
/**
|
|
438
|
+
* Description of what content this slot accepts.
|
|
439
|
+
* Shown in admin mode to guide content editors.
|
|
440
|
+
*/
|
|
441
|
+
description;
|
|
442
|
+
/**
|
|
443
|
+
* Comma-separated list of allowed component tags for this slot.
|
|
444
|
+
* Used by CMS to filter available components.
|
|
445
|
+
*
|
|
446
|
+
* @example "le-card,le-button,le-text"
|
|
447
|
+
*/
|
|
448
|
+
allowedComponents;
|
|
449
|
+
/**
|
|
450
|
+
* Whether multiple components can be dropped in this slot.
|
|
451
|
+
*/
|
|
452
|
+
multiple = true;
|
|
453
|
+
/**
|
|
454
|
+
* Whether this slot is required to have content.
|
|
455
|
+
*/
|
|
456
|
+
required = false;
|
|
457
|
+
/**
|
|
458
|
+
* Placeholder text for text/textarea inputs in admin mode.
|
|
459
|
+
*/
|
|
460
|
+
placeholder;
|
|
461
|
+
/**
|
|
462
|
+
* The HTML tag to create when there's no slotted element.
|
|
463
|
+
* Used with type="text" or type="textarea" to auto-create elements.
|
|
464
|
+
*
|
|
465
|
+
* @example "h3" - creates <h3 slot="header">content</h3>
|
|
466
|
+
* @example "p" - creates <p slot="content">content</p>
|
|
467
|
+
*/
|
|
468
|
+
tag;
|
|
469
|
+
/**
|
|
470
|
+
* CSS styles for the slot dropzone container.
|
|
471
|
+
* Useful for layouts - e.g., "flex-direction: row" for horizontal stacks.
|
|
472
|
+
* Only applies in admin mode for type="slot".
|
|
473
|
+
*/
|
|
474
|
+
slotStyle;
|
|
475
|
+
/**
|
|
476
|
+
* Internal state to track admin mode
|
|
477
|
+
*/
|
|
478
|
+
adminMode = false;
|
|
479
|
+
/**
|
|
480
|
+
* Internal state for text input value (synced from slot content)
|
|
481
|
+
*/
|
|
482
|
+
textValue = '';
|
|
483
|
+
/**
|
|
484
|
+
* Whether the current textValue contains valid HTML
|
|
485
|
+
*/
|
|
486
|
+
isValidHtml = true;
|
|
487
|
+
/**
|
|
488
|
+
* Available components loaded from Custom Elements Manifest
|
|
489
|
+
*/
|
|
490
|
+
availableComponents = [];
|
|
491
|
+
/**
|
|
492
|
+
* Whether the component picker popover is open
|
|
493
|
+
*/
|
|
494
|
+
pickerOpen = false;
|
|
495
|
+
/**
|
|
496
|
+
* Reference to the slot element to access assignedNodes
|
|
497
|
+
*/
|
|
498
|
+
slotRef;
|
|
499
|
+
/**
|
|
500
|
+
* The original slotted element (e.g., <h3 slot="header">)
|
|
501
|
+
*/
|
|
502
|
+
slottedElement;
|
|
503
|
+
/**
|
|
504
|
+
* Emitted when text content changes in admin mode.
|
|
505
|
+
* The event detail contains the new text value and validity.
|
|
506
|
+
*/
|
|
507
|
+
leSlotChange;
|
|
508
|
+
disconnectModeObserver;
|
|
509
|
+
connectedCallback() {
|
|
510
|
+
this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {
|
|
511
|
+
const wasAdmin = this.adminMode;
|
|
512
|
+
this.adminMode = mode === 'admin';
|
|
513
|
+
// When entering admin mode, read content from slotted elements
|
|
514
|
+
if (this.adminMode && !wasAdmin) {
|
|
515
|
+
// Need to wait for render to access slot ref
|
|
516
|
+
requestAnimationFrame(() => this.readSlottedContent());
|
|
517
|
+
// Load available components for the component picker
|
|
518
|
+
if (this.type === 'slot') {
|
|
519
|
+
this.loadAvailableComponents();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
disconnectedCallback() {
|
|
525
|
+
this.disconnectModeObserver?.();
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Flag to prevent re-reading content right after we updated it
|
|
529
|
+
*/
|
|
530
|
+
isUpdating = false;
|
|
531
|
+
/**
|
|
532
|
+
* Read content from slotted elements via assignedNodes()
|
|
533
|
+
*/
|
|
534
|
+
readSlottedContent() {
|
|
535
|
+
if (!this.slotRef)
|
|
536
|
+
return;
|
|
537
|
+
// Skip if we just updated the content ourselves
|
|
538
|
+
if (this.isUpdating) {
|
|
539
|
+
this.isUpdating = false;
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const assignedNodes = this.slotRef.assignedNodes({ flatten: true });
|
|
543
|
+
// For text/textarea types, we want to edit the innerHTML of slotted elements
|
|
544
|
+
if (this.type === 'text' || this.type === 'textarea') {
|
|
545
|
+
// Find the first element node (skip text nodes that are just whitespace)
|
|
546
|
+
const elementNode = assignedNodes.find(node => node.nodeType === Node.ELEMENT_NODE);
|
|
547
|
+
if (elementNode) {
|
|
548
|
+
// Only update textValue if slotted element changed or we don't have one yet
|
|
549
|
+
if (this.slottedElement !== elementNode) {
|
|
550
|
+
this.slottedElement = elementNode;
|
|
551
|
+
this.textValue = elementNode.innerHTML?.trim() || '';
|
|
552
|
+
// console.log(`[le-slot "${this.name}"] Read slotted content:`, this.textValue);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
// No element, check for direct text content
|
|
557
|
+
const textContent = assignedNodes
|
|
558
|
+
.filter(node => node.nodeType === Node.TEXT_NODE)
|
|
559
|
+
.map(node => node.textContent)
|
|
560
|
+
.join('')
|
|
561
|
+
.trim();
|
|
562
|
+
if (textContent && !this.textValue) {
|
|
563
|
+
this.textValue = textContent;
|
|
564
|
+
// console.log(`[le-slot "${this.name}"] Read text content:`, this.textValue);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Validates if a string contains valid HTML
|
|
571
|
+
*/
|
|
572
|
+
validateHtml(html) {
|
|
573
|
+
// Empty string is valid
|
|
574
|
+
if (!html.trim())
|
|
575
|
+
return true;
|
|
576
|
+
// Create a template element to parse the HTML
|
|
577
|
+
const template = document.createElement('template');
|
|
578
|
+
template.innerHTML = html;
|
|
579
|
+
// Check that we don't have obviously broken HTML
|
|
580
|
+
// Count opening and closing tags for common elements
|
|
581
|
+
const openTags = (html.match(/<[a-z][^>]*(?<!\/)>/gi) || []).length;
|
|
582
|
+
const closeTags = (html.match(/<\/[a-z][^>]*>/gi) || []).length;
|
|
583
|
+
const selfClosing = (html.match(/<[a-z][^>]*\/>/gi) || []).length;
|
|
584
|
+
// Simple validation: opening tags (minus self-closing) should roughly match closing tags
|
|
585
|
+
// Allow some tolerance for void elements like <br>, <img>, etc.
|
|
586
|
+
const voidElements = (html.match(/<(br|hr|img|input|meta|link|area|base|col|embed|param|source|track|wbr)[^>]*>/gi) || []).length;
|
|
587
|
+
const effectiveOpenTags = openTags - selfClosing - voidElements;
|
|
588
|
+
// If difference is too large, HTML is likely broken
|
|
589
|
+
if (Math.abs(effectiveOpenTags - closeTags) > 1) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
handleTextInput = (event) => {
|
|
595
|
+
const target = event.target;
|
|
596
|
+
this.textValue = target.value;
|
|
597
|
+
this.isValidHtml = this.validateHtml(this.textValue);
|
|
598
|
+
if (this.isValidHtml) {
|
|
599
|
+
// Set flag to prevent slotchange from re-reading what we just wrote
|
|
600
|
+
this.isUpdating = true;
|
|
601
|
+
console.log('Updating text value:', this.textValue, 'slottedElement:', this.slottedElement);
|
|
602
|
+
if (this.slottedElement) {
|
|
603
|
+
// Update existing slotted element's innerHTML
|
|
604
|
+
this.slottedElement.innerHTML = this.textValue;
|
|
605
|
+
}
|
|
606
|
+
else if (this.tag && this.textValue) {
|
|
607
|
+
// No slotted element exists
|
|
608
|
+
// If the slot doesn't have a name, then it's the default slot
|
|
609
|
+
// remove the existing non-slotted content (text nodes and elements without slot attribute)
|
|
610
|
+
const rootNode = this.el.getRootNode();
|
|
611
|
+
if (!this.name && rootNode instanceof ShadowRoot) {
|
|
612
|
+
const hostComponent = rootNode.host;
|
|
613
|
+
Array.from(hostComponent.childNodes).forEach(node => {
|
|
614
|
+
if (node.nodeType === Node.TEXT_NODE ||
|
|
615
|
+
(node.nodeType === Node.ELEMENT_NODE && !node.hasAttribute('slot'))) {
|
|
616
|
+
node.remove();
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
// create one using the specified tag
|
|
621
|
+
this.createSlottedElement();
|
|
622
|
+
}
|
|
623
|
+
else if (this.textValue) {
|
|
624
|
+
// no tag specified - just replace everything in the host component
|
|
625
|
+
const rootNode = this.el.getRootNode();
|
|
626
|
+
if (rootNode instanceof ShadowRoot) {
|
|
627
|
+
const hostComponent = rootNode.host;
|
|
628
|
+
hostComponent.innerHTML = this.textValue;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
this.leSlotChange.emit({
|
|
633
|
+
name: this.name,
|
|
634
|
+
value: this.textValue,
|
|
635
|
+
isValid: this.isValidHtml
|
|
636
|
+
});
|
|
637
|
+
};
|
|
638
|
+
/**
|
|
639
|
+
* Create a new slotted element when none exists.
|
|
640
|
+
* The element is appended to the host component's light DOM.
|
|
641
|
+
*/
|
|
642
|
+
createSlottedElement() {
|
|
643
|
+
if (!this.tag)
|
|
644
|
+
return;
|
|
645
|
+
// Find the host component (le-card, etc.) by traversing up through shadow DOM
|
|
646
|
+
// le-slot is inside le-card's shadow DOM, so we need to find le-card's host
|
|
647
|
+
const rootNode = this.el.getRootNode();
|
|
648
|
+
if (!(rootNode instanceof ShadowRoot))
|
|
649
|
+
return;
|
|
650
|
+
const hostComponent = rootNode.host;
|
|
651
|
+
if (!hostComponent)
|
|
652
|
+
return;
|
|
653
|
+
// Create the new element
|
|
654
|
+
const newElement = document.createElement(this.tag);
|
|
655
|
+
newElement.innerHTML = this.textValue;
|
|
656
|
+
// Set the slot attribute if this is a named slot
|
|
657
|
+
if (this.name) {
|
|
658
|
+
newElement.setAttribute('slot', this.name);
|
|
659
|
+
}
|
|
660
|
+
// Append to the host component's light DOM
|
|
661
|
+
hostComponent.appendChild(newElement);
|
|
662
|
+
// Store reference to the new element
|
|
663
|
+
this.slottedElement = newElement;
|
|
664
|
+
// console.log(`[le-slot "${this.name}"] Created new <${this.tag}> element`);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Load available components from Custom Elements Manifest
|
|
668
|
+
*/
|
|
669
|
+
async loadAvailableComponents() {
|
|
670
|
+
try {
|
|
671
|
+
const response = await fetch('/custom-elements.json');
|
|
672
|
+
const manifest = await response.json();
|
|
673
|
+
const components = [];
|
|
674
|
+
const allowedList = this.allowedComponents?.split(',').map(s => s.trim()) || [];
|
|
675
|
+
for (const module of manifest.modules) {
|
|
676
|
+
for (const declaration of module.declarations || []) {
|
|
677
|
+
if (declaration.tagName && declaration.customElement) {
|
|
678
|
+
// Skip internal components (le-slot, le-component, le-popover)
|
|
679
|
+
const isInternal = ['le-slot', 'le-component', 'le-popover'].includes(declaration.tagName);
|
|
680
|
+
if (isInternal)
|
|
681
|
+
continue;
|
|
682
|
+
// If allowedComponents is specified, filter by it
|
|
683
|
+
if (allowedList.length > 0 && !allowedList.includes(declaration.tagName)) {
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
components.push({
|
|
687
|
+
tagName: declaration.tagName,
|
|
688
|
+
name: this.formatComponentName(declaration.tagName),
|
|
689
|
+
description: declaration.description || '',
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
this.availableComponents = components;
|
|
695
|
+
}
|
|
696
|
+
catch (error) {
|
|
697
|
+
console.warn('[le-slot] Failed to load component manifest:', error);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Format a tag name into a display name
|
|
702
|
+
* e.g., 'le-card' -> 'Card'
|
|
703
|
+
*/
|
|
704
|
+
formatComponentName(tagName) {
|
|
705
|
+
return tagName
|
|
706
|
+
.replace(/^le-/, '')
|
|
707
|
+
.split('-')
|
|
708
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
709
|
+
.join(' ');
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Add a new component to the slot
|
|
713
|
+
*/
|
|
714
|
+
addComponent(tagName) {
|
|
715
|
+
// Find the host component by traversing up through shadow DOM
|
|
716
|
+
const rootNode = this.el.getRootNode();
|
|
717
|
+
if (!(rootNode instanceof ShadowRoot))
|
|
718
|
+
return;
|
|
719
|
+
const hostComponent = rootNode.host;
|
|
720
|
+
if (!hostComponent)
|
|
721
|
+
return;
|
|
722
|
+
// Create the new component element
|
|
723
|
+
const newElement = document.createElement(tagName);
|
|
724
|
+
// Set the slot attribute if this is a named slot
|
|
725
|
+
if (this.name) {
|
|
726
|
+
newElement.setAttribute('slot', this.name);
|
|
727
|
+
}
|
|
728
|
+
// Append to the host component's light DOM
|
|
729
|
+
hostComponent.appendChild(newElement);
|
|
730
|
+
// Emit change event so the page can save
|
|
731
|
+
this.leSlotChange.emit({
|
|
732
|
+
name: this.name,
|
|
733
|
+
value: hostComponent.innerHTML,
|
|
734
|
+
isValid: true,
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Handle slot change event to re-read content when nodes are assigned
|
|
739
|
+
*/
|
|
740
|
+
handleSlotChange = () => {
|
|
741
|
+
this.readSlottedContent();
|
|
742
|
+
};
|
|
743
|
+
render() {
|
|
744
|
+
const displayLabel = this.label || this.name;
|
|
745
|
+
// Always render the same structure, CSS handles visibility via .admin-mode class
|
|
746
|
+
return (h(Host, { key: 'bae03733e0443c10f1abe8b4c846d3eae0723d3d', class: {
|
|
747
|
+
'admin-mode': this.adminMode,
|
|
748
|
+
'invalid-html': !this.isValidHtml
|
|
749
|
+
}, role: this.adminMode ? 'region' : undefined, "aria-label": this.adminMode ? `Slot: ${displayLabel}` : undefined, "data-slot-name": this.name, "data-slot-type": this.type, "data-allowed": this.allowedComponents, "data-multiple": this.multiple, "data-required": this.required }, this.adminMode ? (h("div", { class: "le-slot-container" }, h("div", { class: classnames('le-slot-header', {
|
|
750
|
+
'le-slot-header-no-label': !displayLabel,
|
|
751
|
+
'le-slot-header-text': this.type === 'text',
|
|
752
|
+
'le-slot-header-error': !this.isValidHtml
|
|
753
|
+
}) }, displayLabel && (h("span", { class: "le-slot-label" }, displayLabel, this.required && h("span", { class: "le-slot-required" }, "*"))), !this.isValidHtml && h("span", { class: "le-slot-invalid" }, "\u26A0 Invalid HTML"), this.type === 'slot' && this.adminMode && (h("le-popover", { mode: "default", showClose: true, align: "start", position: "right", popoverTitle: "Add Component", open: this.pickerOpen, onLePopoverOpen: () => this.pickerOpen = true, onLePopoverClose: () => this.pickerOpen = false }, h("le-button", { type: "button", class: "le-slot-button", slot: "trigger", variant: "clear", size: "small", "aria-label": "Add component", "icon-only": true }, h("span", { class: "le-slot-add-btn", slot: "icon-only" }, "+")), h("div", { class: "le-slot-picker" }, this.availableComponents.length > 0 ? (h("ul", { class: "le-slot-picker-list" }, this.availableComponents.map(component => (h("li", { key: component.tagName }, h("button", { class: "le-slot-picker-item", onClick: () => {
|
|
754
|
+
this.addComponent(component.tagName);
|
|
755
|
+
this.pickerOpen = false;
|
|
756
|
+
} }, h("span", { class: "le-slot-picker-name" }, component.name), component.description && (h("span", { class: "le-slot-picker-desc" }, component.description)))))))) : (h("div", { class: "le-slot-picker-empty" }, "No components available")))))), this.renderContent())) : (
|
|
757
|
+
// In default mode, just pass through the slot - slotted content renders naturally
|
|
758
|
+
// Note: We use unnamed slot here because named slots from parent component
|
|
759
|
+
// are passed as le-slot's light DOM children
|
|
760
|
+
h("slot", null))));
|
|
761
|
+
}
|
|
762
|
+
renderContent() {
|
|
763
|
+
// Create the slot element with ref for reading assignedNodes
|
|
764
|
+
// Wrap in a hidden div since slot elements can't have style prop in Stencil
|
|
765
|
+
// Note: We use unnamed slot here because named slots from parent component
|
|
766
|
+
// are passed as le-slot's light DOM children
|
|
767
|
+
const slotElement = (h("div", { class: "hidden-slot" }, h("slot", { ref: (el) => this.slotRef = el, onSlotchange: this.handleSlotChange })));
|
|
768
|
+
switch (this.type) {
|
|
769
|
+
case 'text':
|
|
770
|
+
return (h("div", { class: { 'le-slot-input': true, 'has-error': !this.isValidHtml } }, h("le-string-input", { mode: "default", value: this.textValue, placeholder: this.placeholder || `Enter ${this.label || this.name || 'text'}...`, onChange: this.handleTextInput }), slotElement));
|
|
771
|
+
case 'textarea':
|
|
772
|
+
return (h("div", { class: { 'le-slot-input': true, 'has-error': !this.isValidHtml } }, h("textarea", { value: this.textValue, placeholder: this.placeholder || `Enter ${this.label || this.name || 'text'}...`, onInput: this.handleTextInput, required: this.required, rows: 3 }), slotElement));
|
|
773
|
+
case 'slot':
|
|
774
|
+
default:
|
|
775
|
+
// Parse slotStyle string into style object if provided
|
|
776
|
+
const dropzoneStyle = {};
|
|
777
|
+
if (this.slotStyle) {
|
|
778
|
+
this.slotStyle.split(';').forEach(rule => {
|
|
779
|
+
const [prop, value] = rule.split(':').map(s => s.trim());
|
|
780
|
+
if (prop && value) {
|
|
781
|
+
// Convert kebab-case to camelCase for style object
|
|
782
|
+
const camelProp = prop.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
783
|
+
dropzoneStyle[camelProp] = value;
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
return (h("div", { class: "le-slot-dropzone", style: dropzoneStyle }, h("slot", { ref: (el) => this.slotRef = el, onSlotchange: this.handleSlotChange })));
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
static get style() { return leSlotDefaultCss; }
|
|
791
|
+
}, [769, "le-slot", {
|
|
792
|
+
"type": [1],
|
|
793
|
+
"name": [1],
|
|
794
|
+
"label": [1],
|
|
795
|
+
"description": [1],
|
|
796
|
+
"allowedComponents": [1, "allowed-components"],
|
|
797
|
+
"multiple": [4],
|
|
798
|
+
"required": [4],
|
|
799
|
+
"placeholder": [1],
|
|
800
|
+
"tag": [1],
|
|
801
|
+
"slotStyle": [1, "slot-style"],
|
|
802
|
+
"adminMode": [32],
|
|
803
|
+
"textValue": [32],
|
|
804
|
+
"isValidHtml": [32],
|
|
805
|
+
"availableComponents": [32],
|
|
806
|
+
"pickerOpen": [32]
|
|
807
|
+
}]);
|
|
808
|
+
function defineCustomElement$3() {
|
|
809
|
+
if (typeof customElements === "undefined") {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
const components = ["le-button", "le-checkbox", "le-popover", "le-string-input"];
|
|
813
|
+
components.forEach(tagName => { switch (tagName) {
|
|
814
|
+
case "le-slot":
|
|
815
|
+
if (!customElements.get(tagName)) {
|
|
816
|
+
customElements.define(tagName, LeSlot);
|
|
817
|
+
}
|
|
818
|
+
break;
|
|
819
|
+
case "le-button":
|
|
820
|
+
if (!customElements.get(tagName)) {
|
|
821
|
+
defineCustomElement();
|
|
822
|
+
}
|
|
823
|
+
break;
|
|
824
|
+
case "le-checkbox":
|
|
825
|
+
if (!customElements.get(tagName)) {
|
|
826
|
+
defineCustomElement$1();
|
|
827
|
+
}
|
|
828
|
+
break;
|
|
829
|
+
case "le-popover":
|
|
830
|
+
if (!customElements.get(tagName)) {
|
|
831
|
+
defineCustomElement$5();
|
|
832
|
+
}
|
|
833
|
+
break;
|
|
834
|
+
case "le-string-input":
|
|
835
|
+
if (!customElements.get(tagName)) {
|
|
836
|
+
defineCustomElement$4();
|
|
837
|
+
}
|
|
838
|
+
break;
|
|
839
|
+
} });
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
const leComponentCss = ":host{display:contents}:host(.admin-mode){display:block}.le-component-wrapper{position:relative;border:2px dashed var(--le-admin-border-color, #90caf9);border-radius:var(--le-radius-md, 8px);background:var(--le-admin-bg, rgba(144, 202, 249, 0.05));transition:border-color 0.2s ease, box-shadow 0.2s ease}.le-component-wrapper:hover{border-color:var(--le-admin-border-hover, #42a5f5);box-shadow:0 0 0 2px var(--le-admin-glow, rgba(66, 165, 245, 0.2))}.le-component-header{display:flex;align-items:center;justify-content:space-between;gap:var(--le-spacing-1, 4px);padding:0 0 0 var(--le-spacing-1, 4px);background:var(--le-admin-header-bg, rgba(144, 202, 249, 0.15));border-bottom:1px solid var(--le-admin-border-color, #90caf9);border-radius:var(--le-radius-md, 8px) var(--le-radius-md, 8px) 0 0;font-size:var(--le-font-size-xs, 11px)}.le-component-name{font-weight:var(--le-font-weight-medium, 500);color:var(--le-admin-text, #1976d2);text-transform:capitalize;text-align:start;overflow:hidden;width:0;flex:1 1 0%}.le-component-content{padding:var(--le-space-xs, 4px)}.le-component-trigger{font-size:24px;line-height:0px;width:12px;height:12px}.le-component-button{width:20px}.property-editor{display:flex;flex-direction:column;gap:var(--le-space-sm, 8px);max-width:380px}.property-field{display:flex;flex-direction:column;gap:var(--le-space-xs, 4px)}.property-field label{display:flex;flex-direction:column;gap:2px;font-size:var(--le-font-size-sm, 13px);font-weight:var(--le-font-weight-medium, 500);color:var(--le-color-text, #333)}.property-hint{font-size:var(--le-font-size-xs, 11px);font-weight:normal;color:var(--le-color-text-secondary, #666);line-height:1.3}.property-field input[type=\"text\"],.property-field input[type=\"number\"],.property-field select{padding:var(--le-space-xs, 4px) var(--le-space-sm, 8px);border:1px solid var(--le-color-border, #ddd);border-radius:var(--le-radius-md, 7px);font-size:var(--le-font-size-sm, 13px);font-family:inherit;background:var(--le-color-surface, #fff);color:var(--le-color-text, #333);transition:border-color 0.15s ease, box-shadow 0.15s ease}.property-field input:focus,.property-field select:focus{outline:none;border-color:var(--le-color-primary, #1976d2);box-shadow:0 0 0 2px var(--le-color-primary-light, rgba(25, 118, 210, 0.2))}.property-field--checkbox{flex-direction:column}.property-field--checkbox label{flex-direction:row;align-items:center;gap:var(--le-space-sm, 8px);cursor:pointer}.property-field--checkbox input[type=\"checkbox\"]{width:16px;height:16px;margin:0;cursor:pointer;accent-color:var(--le-color-primary, #1976d2)}.property-field--checkbox .property-hint{margin-left:24px}.no-properties{margin:0;padding:var(--le-space-sm, 8px);font-size:var(--le-font-size-sm, 13px);color:var(--le-color-text-secondary, #666);text-align:center}.property-editor-container{display:flex;flex-direction:column;gap:var(--le-space-md, 12px)}.property-editor-actions{padding-top:var(--le-space-sm, 8px);border-top:1px solid var(--le-color-border, #e5e5e5)}.delete-component-btn{display:flex;align-items:center;justify-content:center;gap:var(--le-space-xs, 4px);width:100%;padding:var(--le-space-sm, 8px) var(--le-space-md, 12px);border:1px solid var(--le-color-danger, #e53935);border-radius:var(--le-radius-md, 6px);background:transparent;color:var(--le-color-danger, #e53935);font-size:var(--le-font-size-sm, 13px);font-weight:500;cursor:pointer;transition:background-color 0.15s, color 0.15s}.delete-component-btn:hover{background:var(--le-color-danger, #e53935);color:white}.delete-component-btn:active{opacity:0.9}";
|
|
843
|
+
|
|
844
|
+
const LeComponent = /*@__PURE__*/ proxyCustomElement(class LeComponent extends HTMLElement {
|
|
845
|
+
constructor(registerHost) {
|
|
846
|
+
super();
|
|
847
|
+
if (registerHost !== false) {
|
|
848
|
+
this.__registerHost();
|
|
849
|
+
}
|
|
850
|
+
this.__attachShadow();
|
|
851
|
+
}
|
|
852
|
+
get el() { return this; }
|
|
853
|
+
/**
|
|
854
|
+
* The tag name of the component (e.g., 'le-card').
|
|
855
|
+
* Used to look up property metadata and display the component name.
|
|
856
|
+
*/
|
|
857
|
+
component;
|
|
858
|
+
/**
|
|
859
|
+
* Optional display name for the component.
|
|
860
|
+
* If not provided, the tag name will be formatted as the display name.
|
|
861
|
+
*/
|
|
862
|
+
displayName;
|
|
863
|
+
/**
|
|
864
|
+
* Classes to apply to the host element.
|
|
865
|
+
* Allows parent components to pass their styling classes.
|
|
866
|
+
*/
|
|
867
|
+
hostClass;
|
|
868
|
+
/**
|
|
869
|
+
* Inline styles to apply to the host element.
|
|
870
|
+
* Allows parent components to pass dynamic styles (e.g., flex properties).
|
|
871
|
+
*/
|
|
872
|
+
hostStyle;
|
|
873
|
+
/**
|
|
874
|
+
* Reference to the host element (found automatically from parent)
|
|
875
|
+
*/
|
|
876
|
+
hostElement;
|
|
877
|
+
/**
|
|
878
|
+
* Internal state to track admin mode
|
|
879
|
+
*/
|
|
880
|
+
adminMode = false;
|
|
881
|
+
/**
|
|
882
|
+
* Component metadata loaded from Custom Elements Manifest
|
|
883
|
+
*/
|
|
884
|
+
componentMeta = null;
|
|
885
|
+
/**
|
|
886
|
+
* Current property values of the host component
|
|
887
|
+
*/
|
|
888
|
+
propertyValues = {};
|
|
889
|
+
disconnectModeObserver;
|
|
890
|
+
connectedCallback() {
|
|
891
|
+
// Find the host element - le-component is rendered inside the component's shadow DOM,
|
|
892
|
+
// so we need to find the shadow root's host element
|
|
893
|
+
this.findHostElement();
|
|
894
|
+
this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {
|
|
895
|
+
this.adminMode = mode === 'admin';
|
|
896
|
+
// Load metadata and refresh property values only when entering admin mode
|
|
897
|
+
if (this.adminMode) {
|
|
898
|
+
if (!this.componentMeta) {
|
|
899
|
+
this.loadComponentMetadata();
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
this.readPropertyValues();
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Find the host element by traversing up through shadow DOM
|
|
909
|
+
*/
|
|
910
|
+
findHostElement() {
|
|
911
|
+
// Get the shadow root that contains this le-component
|
|
912
|
+
const rootNode = this.el.getRootNode();
|
|
913
|
+
if (rootNode instanceof ShadowRoot) {
|
|
914
|
+
// The host of this shadow root is our target component (e.g., le-card)
|
|
915
|
+
this.hostElement = rootNode.host;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
componentDidLoad() {
|
|
919
|
+
// Read initial property values from the host element
|
|
920
|
+
this.readPropertyValues();
|
|
921
|
+
}
|
|
922
|
+
disconnectedCallback() {
|
|
923
|
+
this.disconnectModeObserver?.();
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Formats a tag name into a display name
|
|
927
|
+
* e.g., 'le-card' -> 'Card'
|
|
928
|
+
*/
|
|
929
|
+
formatDisplayName(tagName) {
|
|
930
|
+
return tagName
|
|
931
|
+
.replace(/^le-/, '') // Remove 'le-' prefix
|
|
932
|
+
.split('-')
|
|
933
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
934
|
+
.join(' ');
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Load component metadata from the Custom Elements Manifest
|
|
938
|
+
*/
|
|
939
|
+
async loadComponentMetadata() {
|
|
940
|
+
try {
|
|
941
|
+
// Fetch the manifest - in production this would be bundled or cached
|
|
942
|
+
const response = await fetch('/custom-elements.json');
|
|
943
|
+
const manifest = await response.json();
|
|
944
|
+
// Find the component definition
|
|
945
|
+
for (const module of manifest.modules) {
|
|
946
|
+
for (const declaration of module.declarations || []) {
|
|
947
|
+
if (declaration.tagName === this.component) {
|
|
948
|
+
const attributes = (declaration.attributes || []).filter((attr) => !this.isInternalAttribute(attr.name));
|
|
949
|
+
this.componentMeta = {
|
|
950
|
+
tagName: declaration.tagName,
|
|
951
|
+
description: declaration.description,
|
|
952
|
+
attributes,
|
|
953
|
+
};
|
|
954
|
+
// console.log(`[le-component] Loaded metadata for ${this.component}:`, this.componentMeta);
|
|
955
|
+
// Read property values after metadata is loaded
|
|
956
|
+
this.readPropertyValues();
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
// console.warn(`[le-component] No metadata found for component: ${this.component}`);
|
|
962
|
+
}
|
|
963
|
+
catch (error) {
|
|
964
|
+
// console.warn(`[le-component] Failed to load metadata for component: ${this.component}`, error);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Check if an attribute is internal (should not be shown in editor)
|
|
969
|
+
*/
|
|
970
|
+
isInternalAttribute(name) {
|
|
971
|
+
const internalAttrs = ['mode', 'theme', 'class', 'style', 'id', 'slot'];
|
|
972
|
+
return internalAttrs.includes(name);
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Read current property values from the host element
|
|
976
|
+
*/
|
|
977
|
+
readPropertyValues() {
|
|
978
|
+
if (!this.hostElement || !this.componentMeta)
|
|
979
|
+
return;
|
|
980
|
+
const values = {};
|
|
981
|
+
for (const attr of this.componentMeta.attributes) {
|
|
982
|
+
const value = this.hostElement.getAttribute(attr.name);
|
|
983
|
+
values[attr.name] = this.parseAttributeValue(value, attr.type?.text);
|
|
984
|
+
}
|
|
985
|
+
this.propertyValues = values;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Parse an attribute value based on its type
|
|
989
|
+
*/
|
|
990
|
+
parseAttributeValue(value, type) {
|
|
991
|
+
if (value === null)
|
|
992
|
+
return undefined;
|
|
993
|
+
if (type === 'boolean') {
|
|
994
|
+
return value !== null && value !== 'false';
|
|
995
|
+
}
|
|
996
|
+
if (type === 'number') {
|
|
997
|
+
return parseFloat(value);
|
|
998
|
+
}
|
|
999
|
+
return value;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Handle property value changes from the editor
|
|
1003
|
+
*/
|
|
1004
|
+
handlePropertyChange(attrName, value, type) {
|
|
1005
|
+
if (!this.hostElement)
|
|
1006
|
+
return;
|
|
1007
|
+
// Update the host element's attribute
|
|
1008
|
+
if (type === 'boolean') {
|
|
1009
|
+
if (value) {
|
|
1010
|
+
this.hostElement.setAttribute(attrName, '');
|
|
1011
|
+
}
|
|
1012
|
+
else {
|
|
1013
|
+
this.hostElement.removeAttribute(attrName);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
else if (value === undefined || value === '') {
|
|
1017
|
+
this.hostElement.removeAttribute(attrName);
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
this.hostElement.setAttribute(attrName, String(value));
|
|
1021
|
+
}
|
|
1022
|
+
// Update local state
|
|
1023
|
+
this.propertyValues = { ...this.propertyValues, [attrName]: value };
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Delete this component from the DOM
|
|
1027
|
+
*/
|
|
1028
|
+
deleteComponent() {
|
|
1029
|
+
if (!this.hostElement)
|
|
1030
|
+
return;
|
|
1031
|
+
// Confirm deletion
|
|
1032
|
+
const name = this.displayName || this.formatDisplayName(this.component);
|
|
1033
|
+
if (!confirm(`Delete this ${name}?`))
|
|
1034
|
+
return;
|
|
1035
|
+
// Remove the host element from its parent
|
|
1036
|
+
const parent = this.hostElement.parentElement;
|
|
1037
|
+
if (parent) {
|
|
1038
|
+
this.hostElement.remove();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Render the property editor form
|
|
1043
|
+
*/
|
|
1044
|
+
renderPropertyEditor() {
|
|
1045
|
+
const hasProperties = this.componentMeta && this.componentMeta.attributes.length > 0;
|
|
1046
|
+
return (h("div", { class: "property-editor-container" }, hasProperties ? (h("form", { class: "property-editor", onSubmit: (e) => e.preventDefault() }, this.componentMeta.attributes.map(attr => this.renderPropertyField(attr)))) : (h("p", { class: "no-properties" }, "No editable properties")), h("div", { class: "property-editor-actions" }, h("le-button", { type: "button", variant: "outlined", color: "danger", "full-width": true, onClick: () => this.deleteComponent() }, h("span", { slot: "icon-start" }, "\uD83D\uDDD1\uFE0F"), h("span", null, "Delete Component")))));
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Render a single property field based on its type
|
|
1050
|
+
*/
|
|
1051
|
+
renderPropertyField(attr) {
|
|
1052
|
+
const value = this.propertyValues[attr.name];
|
|
1053
|
+
const type = attr.type?.text || 'string';
|
|
1054
|
+
// Check if type is a union of string literals (e.g., "'default' | 'outlined' | 'elevated'")
|
|
1055
|
+
const enumMatch = type.match(/^'[^']+'/);
|
|
1056
|
+
if (enumMatch) {
|
|
1057
|
+
const options = type.split('|').map(opt => opt.trim().replace(/'/g, ''));
|
|
1058
|
+
return (h("div", { class: "property-field" }, h("label", { htmlFor: `prop-${attr.name}` }, attr.name, attr.description && h("span", { class: "property-hint" }, attr.description)), h("select", { id: `prop-${attr.name}`, onChange: (e) => this.handlePropertyChange(attr.name, e.target.value, type) }, options.map(opt => (h("option", { value: opt, selected: value === opt || (!value && attr.default?.replace(/'/g, '') === opt) }, opt))))));
|
|
1059
|
+
}
|
|
1060
|
+
// Boolean type
|
|
1061
|
+
if (type === 'boolean') {
|
|
1062
|
+
return (h("div", { class: "property-field property-field--checkbox" }, h("le-checkbox", { name: `prop-${attr.name}`, checked: value === true || value === '', onChange: (e) => this.handlePropertyChange(attr.name, e.target.checked, type) }, attr.name, attr.description && h("div", { slot: "description" }, attr.description))));
|
|
1063
|
+
}
|
|
1064
|
+
// Number type
|
|
1065
|
+
if (type === 'number') {
|
|
1066
|
+
return (h("div", { class: "property-field" }, h("label", { htmlFor: `prop-${attr.name}` }, attr.name, attr.description && h("span", { class: "property-hint" }, attr.description)), h("input", { type: "number", id: `prop-${attr.name}`, value: value ?? '', placeholder: attr.default, onChange: (e) => this.handlePropertyChange(attr.name, e.target.value, type) })));
|
|
1067
|
+
}
|
|
1068
|
+
// Default: string/text input
|
|
1069
|
+
return (h("div", { class: "property-field" }, h("le-string-input", { name: `prop-${attr.name}`, label: attr.name, value: value ?? '', placeholder: attr.default?.replace(/'/g, ''), onChange: (e) => this.handlePropertyChange(attr.name, e.detail.value, type) }, h("span", { slot: "description" }, attr.description))));
|
|
1070
|
+
}
|
|
1071
|
+
render() {
|
|
1072
|
+
const name = this.displayName || this.formatDisplayName(this.component);
|
|
1073
|
+
// In default mode, just pass through content with host classes
|
|
1074
|
+
if (!this.adminMode) {
|
|
1075
|
+
return (h(Host, { class: classnames(this.component, this.hostClass), style: this.hostStyle }, h("slot", null)));
|
|
1076
|
+
}
|
|
1077
|
+
// In admin mode, show wrapper with header and settings
|
|
1078
|
+
return (h(Host, { class: classnames(this.component, this.hostClass, 'admin-mode'), style: this.hostStyle }, h("div", { class: "le-component-wrapper" }, h("div", { class: "le-component-header" }, h("span", { class: "le-component-name" }, name), h("le-popover", { popoverTitle: `${name} Settings`, position: "right", align: "start", "min-width": "300px", mode: "default" }, h("le-button", { type: "button", class: "le-component-button", slot: "trigger", variant: "clear", size: "small", "aria-label": "Edit component properties", "icon-only": true }, h("span", { class: "le-component-trigger", slot: "icon-only" }, "\u2699")), this.renderPropertyEditor())), h("div", { class: "le-component-content" }, h("slot", null)))));
|
|
1079
|
+
}
|
|
1080
|
+
static get style() { return leComponentCss; }
|
|
1081
|
+
}, [769, "le-component", {
|
|
1082
|
+
"component": [1],
|
|
1083
|
+
"displayName": [1, "display-name"],
|
|
1084
|
+
"hostClass": [1, "host-class"],
|
|
1085
|
+
"hostStyle": [16],
|
|
1086
|
+
"adminMode": [32],
|
|
1087
|
+
"componentMeta": [32],
|
|
1088
|
+
"propertyValues": [32]
|
|
1089
|
+
}]);
|
|
1090
|
+
function defineCustomElement$2() {
|
|
1091
|
+
if (typeof customElements === "undefined") {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
const components = ["le-button", "le-checkbox", "le-popover", "le-string-input"];
|
|
1095
|
+
components.forEach(tagName => { switch (tagName) {
|
|
1096
|
+
case "le-component":
|
|
1097
|
+
if (!customElements.get(tagName)) {
|
|
1098
|
+
customElements.define(tagName, LeComponent);
|
|
1099
|
+
}
|
|
1100
|
+
break;
|
|
1101
|
+
case "le-button":
|
|
1102
|
+
if (!customElements.get(tagName)) {
|
|
1103
|
+
defineCustomElement();
|
|
1104
|
+
}
|
|
1105
|
+
break;
|
|
1106
|
+
case "le-checkbox":
|
|
1107
|
+
if (!customElements.get(tagName)) {
|
|
1108
|
+
defineCustomElement$1();
|
|
1109
|
+
}
|
|
1110
|
+
break;
|
|
1111
|
+
case "le-popover":
|
|
1112
|
+
if (!customElements.get(tagName)) {
|
|
1113
|
+
defineCustomElement$5();
|
|
1114
|
+
}
|
|
1115
|
+
break;
|
|
1116
|
+
case "le-string-input":
|
|
1117
|
+
if (!customElements.get(tagName)) {
|
|
1118
|
+
defineCustomElement$4();
|
|
1119
|
+
}
|
|
1120
|
+
break;
|
|
1121
|
+
} });
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
const leCheckboxCss = ":host{display:block;--le-checkbox-size:18px;--le-checkbox-color:var(--le-color-primary, #007bff);--le-checkbox-label-color:var(--le-color-text-primary, #333);--le-checkbox-desc-color:var(--le-color-text-secondary, #666);--le-checkbox-border-radius:var(--le-radius-sm, 2px);--le-checkbox-marker-color:var(--le-color-surface, #fff)}.le-checkbox-wrapper{display:flex;flex-direction:column;gap:4px}.le-checkbox-label{display:inline-flex;align-items:flex-start;gap:8px;cursor:pointer;user-select:none}:host([disabled]) .le-checkbox-label{cursor:not-allowed;opacity:0.6}.le-checkbox-input{display:flex;align-items:center;justify-content:center;min-height:1.4em}input[type=\"checkbox\"]{appearance:none;-webkit-appearance:none;width:var(--le-checkbox-size);height:var(--le-checkbox-size);border:var(--le-border-width, 2px) solid var(--le-checkbox-color);border-radius:var(--le-checkbox-border-radius);margin:0;margin-top:2px;position:relative;cursor:inherit;background-color:transparent;transition:background-color 0.2s, border-color 0.2s}input[type=\"checkbox\"]:checked{background-color:var(--le-checkbox-color)}input[type=\"checkbox\"]:checked::after{content:'';position:absolute;left:0;top:0;bottom:calc(var(--le-checkbox-size) / 5);right:0;margin:auto;width:calc(var(--le-checkbox-size) / 4);height:calc(var(--le-checkbox-size) / 2);border:solid var(--le-checkbox-marker-color, #fff);border-width:0 calc(var(--le-checkbox-size) / 10) calc(var(--le-checkbox-size) / 10) 0;transform:rotate(45deg)}input[type=\"checkbox\"]:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.le-checkbox-text{flex:1;flex-wrap:wrap;color:var(--le-checkbox-label-color);line-height:1.5;text-align:start}.le-checkbox-description{margin-left:calc(var(--le-checkbox-size) + 8px);font-size:0.875em;color:var(--le-checkbox-desc-color);line-height:1.4}:host [slot=\"description\"]{margin:0}";
|
|
1125
|
+
|
|
1126
|
+
const LeCheckbox = /*@__PURE__*/ proxyCustomElement(class LeCheckbox extends HTMLElement {
|
|
1127
|
+
constructor(registerHost) {
|
|
1128
|
+
super();
|
|
1129
|
+
if (registerHost !== false) {
|
|
1130
|
+
this.__registerHost();
|
|
1131
|
+
}
|
|
1132
|
+
this.__attachShadow();
|
|
1133
|
+
this.leChange = createEvent(this, "change", 7);
|
|
1134
|
+
}
|
|
1135
|
+
get el() { return this; }
|
|
1136
|
+
/**
|
|
1137
|
+
* Whether the checkbox is checked
|
|
1138
|
+
*/
|
|
1139
|
+
checked = false;
|
|
1140
|
+
/**
|
|
1141
|
+
* Whether the checkbox is disabled
|
|
1142
|
+
*/
|
|
1143
|
+
disabled = false;
|
|
1144
|
+
/**
|
|
1145
|
+
* The name of the checkbox input
|
|
1146
|
+
*/
|
|
1147
|
+
name;
|
|
1148
|
+
/**
|
|
1149
|
+
* The value of the checkbox input
|
|
1150
|
+
*/
|
|
1151
|
+
value;
|
|
1152
|
+
/**
|
|
1153
|
+
* External ID for linking with external systems (e.g. database ID, PDF form field ID)
|
|
1154
|
+
*/
|
|
1155
|
+
externalId;
|
|
1156
|
+
/**
|
|
1157
|
+
* Emitted when the checked state changes
|
|
1158
|
+
*/
|
|
1159
|
+
leChange;
|
|
1160
|
+
handleChange = (event) => {
|
|
1161
|
+
// We stop the internal button click from bubbling up
|
|
1162
|
+
event.stopPropagation();
|
|
1163
|
+
if (this.disabled) {
|
|
1164
|
+
event.preventDefault();
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
const input = event.target;
|
|
1168
|
+
this.checked = input.checked;
|
|
1169
|
+
this.leChange.emit({
|
|
1170
|
+
checked: this.checked,
|
|
1171
|
+
value: this.value,
|
|
1172
|
+
name: this.name,
|
|
1173
|
+
externalId: this.externalId
|
|
1174
|
+
});
|
|
1175
|
+
};
|
|
1176
|
+
render() {
|
|
1177
|
+
return (h(Host, { class: classnames({ 'disabled': this.disabled }) }, h("div", { key: '7ddbf2ac1690bb09082adfea70b9767c972d007a', class: "le-checkbox-wrapper" }, h("label", { key: '8eec4055c713e8b3b155695751b10bff64c9f903', class: "le-checkbox-label" }, h("span", { key: '2118b1cbe7911ff1674e522d723949d81cade185', class: "le-checkbox-input" }, h("input", { key: 'd0a30af5c14497fa6fa294c07ba74ae2e032481f', type: "checkbox", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, onChange: this.handleChange })), h("span", { key: '02cf9588431240039a53ee50e02b08ba5d63b974', class: "le-checkbox-text" }, h("slot", { key: '1d8c443073e48848513a8a6d04cd7805a394e54e' }))), h("div", { key: '16c2c927dc0c0f7844a203a0628bf0e561009bd0', class: "le-checkbox-description" }, h("slot", { key: '3342add8ed1400ab74681e445163eeb3dd415941', name: "description" })))));
|
|
1178
|
+
}
|
|
1179
|
+
static get style() { return leCheckboxCss; }
|
|
1180
|
+
}, [769, "le-checkbox", {
|
|
1181
|
+
"checked": [1540],
|
|
1182
|
+
"disabled": [4],
|
|
1183
|
+
"name": [1],
|
|
1184
|
+
"value": [1],
|
|
1185
|
+
"externalId": [1, "external-id"]
|
|
1186
|
+
}]);
|
|
1187
|
+
function defineCustomElement$1() {
|
|
1188
|
+
if (typeof customElements === "undefined") {
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
const components = ["le-checkbox", "le-button", "le-checkbox", "le-popover", "le-string-input"];
|
|
1192
|
+
components.forEach(tagName => { switch (tagName) {
|
|
1193
|
+
case "le-checkbox":
|
|
1194
|
+
if (!customElements.get(tagName)) {
|
|
1195
|
+
customElements.define(tagName, LeCheckbox);
|
|
1196
|
+
}
|
|
1197
|
+
break;
|
|
1198
|
+
case "le-button":
|
|
1199
|
+
if (!customElements.get(tagName)) {
|
|
1200
|
+
defineCustomElement();
|
|
1201
|
+
}
|
|
1202
|
+
break;
|
|
1203
|
+
case "le-checkbox":
|
|
1204
|
+
if (!customElements.get(tagName)) {
|
|
1205
|
+
defineCustomElement$1();
|
|
1206
|
+
}
|
|
1207
|
+
break;
|
|
1208
|
+
case "le-popover":
|
|
1209
|
+
if (!customElements.get(tagName)) {
|
|
1210
|
+
defineCustomElement$5();
|
|
1211
|
+
}
|
|
1212
|
+
break;
|
|
1213
|
+
case "le-string-input":
|
|
1214
|
+
if (!customElements.get(tagName)) {
|
|
1215
|
+
defineCustomElement$4();
|
|
1216
|
+
}
|
|
1217
|
+
break;
|
|
1218
|
+
} });
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
const leButtonDefaultCss = ":host{display:inline-block;--le-button-border-radius:var(--le-radius-md);--le-button-padding-x:0.4rem;--le-button-padding-y:0.4rem;--le-button-small-padding:0.25rem;--le-button-font-size:var(--le-font-size-md);--le-button-font-weight:var(--le-font-weight-medium);--le-button-transition:var(--le-transition-fast);--le-button-icon-aspect-ratio:1;--_btn-bg:var(--le-color-primary);--_btn-bg-hover:var(--le-color-primary-dark);--_btn-bg-system:var(--le-color-black);--_btn-color:var(--le-color-primary-contrast);--_btn-border-color:var(--le-color-primary)}:host([full-width]){display:block;width:100%}.button{display:inline-flex;align-items:center;justify-content:center;gap:var(--le-spacing-3);width:100%;padding:var(--le-button-padding-y) var(--le-button-padding-x);border:1px solid var(--_btn-border-color);border-radius:var(--le-button-border-radius);background:var(--_btn-bg);color:var(--_btn-color);font-family:var(--le-font-family-base);font-size:var(--le-button-font-size);font-weight:var(--le-button-font-weight);line-height:var(--le-line-height-tight);text-decoration:none;cursor:pointer;transition:background-color var(--le-button-transition) var(--le-transition-easing),\n border-color var(--le-button-transition) var(--le-transition-easing),\n box-shadow var(--le-button-transition) var(--le-transition-easing),\n transform var(--le-button-transition) var(--le-transition-easing)}.button:hover:not(:disabled){background:var(--_btn-bg-hover);border-color:var(--_btn-bg-hover)}.button:active:not(:disabled){transform:translateY(1px)}.button:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.button:disabled{opacity:0.5;cursor:not-allowed}:host.color-primary{--_btn-bg:var(--le-color-primary);--_btn-bg-hover:var(--le-color-primary-dark);--_btn-color:var(--le-color-primary-contrast);--_btn-border-color:var(--le-color-primary)}:host.color-secondary{--_btn-bg:var(--le-color-secondary);--_btn-bg-hover:var(--le-color-secondary-dark);--_btn-color:var(--le-color-secondary-contrast);--_btn-border-color:var(--le-color-secondary)}:host.color-success{--_btn-bg:var(--le-color-success);--_btn-bg-hover:var(--le-color-success-dark);--_btn-color:var(--le-color-success-contrast);--_btn-border-color:var(--le-color-success)}:host.color-warning{--_btn-bg:var(--le-color-warning);--_btn-bg-hover:var(--le-color-warning-dark);--_btn-color:var(--le-color-warning-contrast);--_btn-border-color:var(--le-color-warning)}:host.color-danger{--_btn-bg:var(--le-color-danger);--_btn-bg-hover:var(--le-color-danger-dark);--_btn-color:var(--le-color-danger-contrast);--_btn-border-color:var(--le-color-danger)}:host.color-info{--_btn-bg:var(--le-color-info);--_btn-bg-hover:var(--le-color-info-dark);--_btn-color:var(--le-color-info-contrast);--_btn-border-color:var(--le-color-info)}:host.variant-solid .button{box-shadow:var(--le-shadow-sm)}:host.variant-solid .button:hover:not(:disabled){box-shadow:var(--le-shadow-md)}:host.variant-outlined .button{background:transparent;color:var(--_btn-bg);border-color:var(--_btn-border-color)}:host.variant-outlined .button:hover:not(:disabled){background:var(--_btn-bg);color:var(--_btn-color)}:host.variant-clear .button{background:transparent;color:var(--_btn-bg);border-color:transparent}:host.variant-clear .button:hover:not(:disabled){background:var(--le-color-gray-100);border-color:transparent}:host.variant-system .button{background:transparent;color:var(--_btn-bg-system);border-color:transparent}:host.size-small .button{--le-button-padding-x:0.4rem;--le-button-padding-y:0.3rem;--le-button-padding-top:0.35rem;--le-button-font-size:var(--le-button-small-font-size, var(--le-font-size-xs))}:host.size-large .button{--le-button-padding-x:0.9rem;--le-button-padding-y:0.6rem;--le-button-font-size:var(--le-font-size-xl)}:host.full-width{display:block;width:100%}:host.selected .button{box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.2)}:host.variant-outlined.selected .button,:host.variant-clear.selected .button{background:var(--_btn-bg);color:var(--_btn-color)}:host.icon-only .button{padding:0.5rem;padding-bottom:0.6rem;aspect-ratio:var(--le-button-icon-aspect-ratio, 1)}:host.icon-only.size-small .button{padding:var(--le-button-small-padding, 0.25rem)}:host.icon-only.size-large .button{padding:0.75rem}:host.icon-only .content{display:none}.content{display:inline}.content:empty{display:none}.icon-start,.icon-only,.icon-end{display:flex;align-items:center;justify-content:center}.icon-start:empty,.icon-only:empty,.icon-end:empty{display:none}::slotted([slot=\"icon-start\"]),::slotted([slot=\"icon-only\"]),::slotted([slot=\"icon-end\"]){display:flex;align-items:center;justify-content:center;width:1.125em;height:1.125em}";
|
|
1222
|
+
|
|
1223
|
+
const LeButton = /*@__PURE__*/ proxyCustomElement(class LeButton extends HTMLElement {
|
|
1224
|
+
constructor(registerHost) {
|
|
1225
|
+
super();
|
|
1226
|
+
if (registerHost !== false) {
|
|
1227
|
+
this.__registerHost();
|
|
1228
|
+
}
|
|
1229
|
+
this.__attachShadow();
|
|
1230
|
+
this.leClick = createEvent(this, "click", 7);
|
|
1231
|
+
}
|
|
1232
|
+
get el() { return this; }
|
|
1233
|
+
/**
|
|
1234
|
+
* Mode of the popover should be 'default' for internal use
|
|
1235
|
+
*/
|
|
1236
|
+
mode;
|
|
1237
|
+
/**
|
|
1238
|
+
* Button variant style
|
|
1239
|
+
* @allowedValues solid | outlined | clear
|
|
1240
|
+
*/
|
|
1241
|
+
variant = 'solid';
|
|
1242
|
+
/**
|
|
1243
|
+
* Button color theme (uses theme semantic colors)
|
|
1244
|
+
* @allowedValues primary | secondary | success | warning | danger | info
|
|
1245
|
+
*/
|
|
1246
|
+
color = 'primary';
|
|
1247
|
+
/**
|
|
1248
|
+
* Button size
|
|
1249
|
+
* @allowedValues small | medium | large
|
|
1250
|
+
*/
|
|
1251
|
+
size = 'medium';
|
|
1252
|
+
/**
|
|
1253
|
+
* Whether the button is in a selected/active state
|
|
1254
|
+
*/
|
|
1255
|
+
selected = false;
|
|
1256
|
+
/**
|
|
1257
|
+
* Whether the button takes full width of its container
|
|
1258
|
+
*/
|
|
1259
|
+
fullWidth = false;
|
|
1260
|
+
/**
|
|
1261
|
+
* Whether the button displays only an icon (square aspect ratio)
|
|
1262
|
+
*/
|
|
1263
|
+
iconOnly = false;
|
|
1264
|
+
/**
|
|
1265
|
+
* Whether the button is disabled
|
|
1266
|
+
*/
|
|
1267
|
+
disabled = false;
|
|
1268
|
+
/**
|
|
1269
|
+
* The button type attribute
|
|
1270
|
+
* @allowedValues button | submit | reset
|
|
1271
|
+
*/
|
|
1272
|
+
type = 'button';
|
|
1273
|
+
/**
|
|
1274
|
+
* Optional href to make the button act as a link
|
|
1275
|
+
*/
|
|
1276
|
+
href;
|
|
1277
|
+
/**
|
|
1278
|
+
* Link target when href is set
|
|
1279
|
+
*/
|
|
1280
|
+
target;
|
|
1281
|
+
/**
|
|
1282
|
+
* Emitted when the button is clicked.
|
|
1283
|
+
* This is a custom event that wraps the native click but ensures the target is the le-button.
|
|
1284
|
+
*/
|
|
1285
|
+
leClick;
|
|
1286
|
+
handleClick = (event) => {
|
|
1287
|
+
// We stop the internal button click from bubbling up
|
|
1288
|
+
event.stopPropagation();
|
|
1289
|
+
if (this.disabled) {
|
|
1290
|
+
event.preventDefault();
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
// And emit our own click event from the host element
|
|
1294
|
+
this.leClick.emit(event);
|
|
1295
|
+
};
|
|
1296
|
+
render() {
|
|
1297
|
+
const classes = classnames(`variant-${this.variant}`, `color-${this.color}`, `size-${this.size}`, {
|
|
1298
|
+
'selected': this.selected,
|
|
1299
|
+
'full-width': this.fullWidth,
|
|
1300
|
+
'icon-only': this.iconOnly,
|
|
1301
|
+
'disabled': this.disabled,
|
|
1302
|
+
});
|
|
1303
|
+
const TagType = this.href ? 'a' : 'button';
|
|
1304
|
+
const attrs = this.href ? { href: this.href, target: this.target, role: 'button' } : { type: this.type, disabled: this.disabled };
|
|
1305
|
+
return (h(Host, { class: classes }, h(TagType, { key: 'e112acdff4278e976ad767bd1ea7c9ced5e85f43', class: "button", part: "button", ...attrs, onClick: this.handleClick }, this.iconOnly ? (h("span", { class: "icon-start" }, h("slot", { name: "icon-only" }))) : (h(Fragment, null, h("span", { class: "icon-start" }, h("slot", { name: "icon-start" })), h("slot", null), h("span", { class: "icon-end" }, h("slot", { name: "icon-end" })))))));
|
|
1306
|
+
}
|
|
1307
|
+
static get style() { return leButtonDefaultCss; }
|
|
1308
|
+
}, [769, "le-button", {
|
|
1309
|
+
"mode": [1537],
|
|
1310
|
+
"variant": [1],
|
|
1311
|
+
"color": [1],
|
|
1312
|
+
"size": [1],
|
|
1313
|
+
"selected": [4],
|
|
1314
|
+
"fullWidth": [516, "full-width"],
|
|
1315
|
+
"iconOnly": [4, "icon-only"],
|
|
1316
|
+
"disabled": [4],
|
|
1317
|
+
"type": [1],
|
|
1318
|
+
"href": [1],
|
|
1319
|
+
"target": [1]
|
|
1320
|
+
}]);
|
|
1321
|
+
function defineCustomElement() {
|
|
1322
|
+
if (typeof customElements === "undefined") {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
const components = ["le-button", "le-button", "le-checkbox", "le-popover", "le-string-input"];
|
|
1326
|
+
components.forEach(tagName => { switch (tagName) {
|
|
1327
|
+
case "le-button":
|
|
1328
|
+
if (!customElements.get(tagName)) {
|
|
1329
|
+
customElements.define(tagName, LeButton);
|
|
1330
|
+
}
|
|
1331
|
+
break;
|
|
1332
|
+
case "le-button":
|
|
1333
|
+
if (!customElements.get(tagName)) {
|
|
1334
|
+
defineCustomElement();
|
|
1335
|
+
}
|
|
1336
|
+
break;
|
|
1337
|
+
case "le-checkbox":
|
|
1338
|
+
if (!customElements.get(tagName)) {
|
|
1339
|
+
defineCustomElement$1();
|
|
1340
|
+
}
|
|
1341
|
+
break;
|
|
1342
|
+
case "le-popover":
|
|
1343
|
+
if (!customElements.get(tagName)) {
|
|
1344
|
+
defineCustomElement$5();
|
|
1345
|
+
}
|
|
1346
|
+
break;
|
|
1347
|
+
case "le-string-input":
|
|
1348
|
+
if (!customElements.get(tagName)) {
|
|
1349
|
+
defineCustomElement$4();
|
|
1350
|
+
}
|
|
1351
|
+
break;
|
|
1352
|
+
} });
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
export { LeButton as L, getMode as a, setGlobalMode as b, getTheme as c, setGlobalTheme as d, classnames as e, defineCustomElement$4 as f, generateId as g, defineCustomElement$3 as h, initializeMode as i, defineCustomElement$2 as j, defineCustomElement$1 as k, defineCustomElement as l, LeCheckbox as m, LeComponent as n, LeSlot as o, parseCommaSeparated as p, LeStringInput as q, observeModeChanges as r, slotHasContent as s };
|
|
1356
|
+
//# sourceMappingURL=le-button2.js.map
|
|
1357
|
+
|
|
1358
|
+
//# sourceMappingURL=le-button2.js.map
|