le-kit 0.1.5 → 0.1.7
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/{dist/le-kit/assets/custom-elements.json → custom-elements.json} +833 -833
- package/dist/cjs/index-D7B9TPh8.js +1835 -0
- package/dist/cjs/index-D7B9TPh8.js.map +1 -0
- package/dist/cjs/index.cjs.js +119 -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 +1200 -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-DrsoID-a.js +152 -0
- package/dist/cjs/utils-DrsoID-a.js.map +1 -0
- package/dist/collection/collection-manifest.json +26 -0
- 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/{le-kit/le-component.entry.js → collection/components/le-component/le-component.js} +141 -24
- 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.css +34 -0
- package/dist/collection/components/le-round-progress/le-round-progress.js +184 -0
- 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/{le-kit/le-slot.entry.js → collection/components/le-slot/le-slot.js} +270 -20
- 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.css +10 -0
- package/dist/collection/components/le-turntable/le-turntable.js +210 -0
- package/dist/collection/components/le-turntable/le-turntable.js.map +1 -0
- package/dist/collection/global/app.js +167 -0
- package/dist/collection/global/app.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 -0
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/components/index.js +127 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/le-box.js +256 -0
- package/dist/components/le-box.js.map +1 -0
- package/dist/components/le-button.js +9 -0
- package/dist/components/le-button.js.map +1 -0
- package/dist/components/le-button2.js +1446 -0
- package/dist/components/le-button2.js.map +1 -0
- package/dist/components/le-card.js +83 -0
- package/dist/components/le-card.js.map +1 -0
- package/dist/components/le-checkbox.js +9 -0
- package/dist/components/le-checkbox.js.map +1 -0
- package/dist/components/le-component.js +9 -0
- package/dist/components/le-component.js.map +1 -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.js +9 -0
- package/dist/components/le-popover.js.map +1 -0
- package/dist/{le-kit/le-popover.entry.js → components/le-popover2.js} +45 -9
- package/dist/components/le-popover2.js.map +1 -0
- package/dist/components/le-popup.js +279 -0
- package/dist/components/le-popup.js.map +1 -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.js +9 -0
- package/dist/components/le-slot.js.map +1 -0
- package/dist/components/le-stack.js +198 -0
- package/dist/components/le-stack.js.map +1 -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.js +398 -0
- package/dist/components/le-text.js.map +1 -0
- package/dist/components/le-turntable.js +164 -0
- package/dist/components/le-turntable.js.map +1 -0
- package/dist/docs.d.ts +443 -0
- package/dist/docs.json +5185 -0
- package/dist/esm/index-PS-3Rz-c.js +1818 -0
- package/dist/esm/index-PS-3Rz-c.js.map +1 -0
- package/dist/esm/index.js +106 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/{le-kit → esm}/le-box.entry.js +3 -3
- 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 +1193 -0
- package/dist/{le-kit → esm}/le-card.entry.js +3 -3
- 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/{le-kit → esm}/le-number-input.entry.js +5 -5
- package/dist/esm/le-number-input.entry.js.map +1 -0
- package/dist/{le-kit → esm}/le-popup.entry.js +6 -6
- package/dist/esm/le-popup.entry.js.map +1 -0
- package/dist/{le-kit → esm}/le-round-progress.entry.js +2 -2
- package/dist/esm/le-round-progress.entry.js.map +1 -0
- package/dist/{le-kit → esm}/le-stack.entry.js +3 -3
- package/dist/esm/le-stack.entry.js.map +1 -0
- package/dist/{le-kit → esm}/le-text.entry.js +3 -3
- package/dist/esm/le-text.entry.js.map +1 -0
- package/dist/{le-kit → esm}/le-turntable.entry.js +2 -2
- 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/{le-kit/utils-FDOApZ53.js → esm/utils-lgjSfQP0.js} +3 -3
- package/dist/{le-kit/utils-FDOApZ53.js.map → esm/utils-lgjSfQP0.js.map} +1 -1
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/le-kit/index.esm.js +2 -116
- package/dist/le-kit/index.esm.js.map +1 -1
- 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-kit.css +1 -1010
- package/dist/le-kit/le-kit.esm.js +2 -48
- package/dist/le-kit/le-kit.esm.js.map +1 -1
- package/dist/le-kit/p-27710b5b.entry.js +2 -0
- package/dist/le-kit/p-27710b5b.entry.js.map +1 -0
- package/dist/le-kit/p-34102cef.entry.js +2 -0
- package/dist/le-kit/p-34102cef.entry.js.map +1 -0
- package/dist/le-kit/p-56a80e6d.entry.js +2 -0
- package/dist/le-kit/p-56a80e6d.entry.js.map +1 -0
- package/dist/le-kit/p-615ea10f.entry.js +2 -0
- package/dist/le-kit/p-615ea10f.entry.js.map +1 -0
- package/dist/le-kit/p-935bb2d4.entry.js +2 -0
- package/dist/le-kit/p-935bb2d4.entry.js.map +1 -0
- package/dist/le-kit/p-9d3dc4e5.entry.js +2 -0
- package/dist/le-kit/p-9d3dc4e5.entry.js.map +1 -0
- package/dist/le-kit/p-DN2JVY-7.js +2 -0
- package/dist/le-kit/p-DN2JVY-7.js.map +1 -0
- package/dist/le-kit/p-PS-3Rz-c.js +3 -0
- package/dist/le-kit/p-PS-3Rz-c.js.map +1 -0
- package/dist/le-kit/p-ccabc638.entry.js +2 -0
- package/dist/le-kit/p-ccabc638.entry.js.map +1 -0
- package/dist/le-kit/p-d8157b06.entry.js +2 -0
- package/dist/le-kit/p-d8157b06.entry.js.map +1 -0
- package/dist/le-kit/p-e8c2ca0e.entry.js +2 -0
- package/dist/le-kit/p-e8c2ca0e.entry.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.d.ts +4 -4
- package/dist/types/global/app.d.ts +33 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -2
- package/readme.md +22 -0
- package/dist/le-kit/index-Da-89pOc.js +0 -4522
- package/dist/le-kit/index-Da-89pOc.js.map +0 -1
- package/dist/le-kit/le-button.entry.esm.js.map +0 -1
- package/dist/le-kit/le-button.entry.js +0 -90
- package/dist/le-kit/le-checkbox.entry.esm.js.map +0 -1
- package/dist/le-kit/le-checkbox.entry.js +0 -59
- package/dist/le-kit/le-component.entry.esm.js.map +0 -1
- package/dist/le-kit/le-popover.entry.esm.js.map +0 -1
- package/dist/le-kit/le-slot.entry.esm.js.map +0 -1
- package/dist/le-kit/le-string-input.entry.esm.js.map +0 -1
- package/dist/le-kit/le-string-input.entry.js +0 -93
package/dist/{le-kit/le-component.entry.js → collection/components/le-component/le-component.js}
RENAMED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { classnames, observeModeChanges } from "../../utils/utils";
|
|
3
|
+
import { getLeKitConfig } from "../../global/app";
|
|
4
|
+
/**
|
|
5
|
+
* Component wrapper for admin mode editing.
|
|
6
|
+
*
|
|
7
|
+
* This component is used internally by other components to provide admin-mode
|
|
8
|
+
* editing capabilities. It wraps the component's rendered output and shows
|
|
9
|
+
* a settings popover for editing properties.
|
|
10
|
+
*
|
|
11
|
+
* In default mode, it acts as a simple passthrough (display: contents).
|
|
12
|
+
* In admin mode, it shows a border, component name header, and settings popover.
|
|
13
|
+
*
|
|
14
|
+
* The host element is found automatically by traversing up through the shadow DOM.
|
|
15
|
+
*
|
|
16
|
+
* Usage inside a component's render method:
|
|
17
|
+
* ```tsx
|
|
18
|
+
* render() {
|
|
19
|
+
* return (
|
|
20
|
+
* <le-component component="le-card">
|
|
21
|
+
* <Host>...</Host>
|
|
22
|
+
* </le-component>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @slot - The component's rendered content
|
|
28
|
+
*
|
|
29
|
+
* @cmsInternal true
|
|
30
|
+
* @cmsCategory System
|
|
31
|
+
*/
|
|
32
|
+
export class LeComponent {
|
|
33
|
+
el;
|
|
11
34
|
/**
|
|
12
35
|
* The tag name of the component (e.g., 'le-card').
|
|
13
36
|
* Used to look up property metadata and display the component name.
|
|
@@ -49,7 +72,7 @@ const LeComponent = class {
|
|
|
49
72
|
// Find the host element - le-component is rendered inside the component's shadow DOM,
|
|
50
73
|
// so we need to find the shadow root's host element
|
|
51
74
|
this.findHostElement();
|
|
52
|
-
this.disconnectModeObserver = observeModeChanges(this.el,
|
|
75
|
+
this.disconnectModeObserver = observeModeChanges(this.el, mode => {
|
|
53
76
|
this.adminMode = mode === 'admin';
|
|
54
77
|
// Load metadata and refresh property values only when entering admin mode
|
|
55
78
|
if (this.adminMode) {
|
|
@@ -96,9 +119,9 @@ const LeComponent = class {
|
|
|
96
119
|
*/
|
|
97
120
|
async loadComponentMetadata() {
|
|
98
121
|
try {
|
|
99
|
-
// Fetch the manifest
|
|
100
|
-
const
|
|
101
|
-
const response = await fetch(
|
|
122
|
+
// Fetch the manifest from configured URL
|
|
123
|
+
const { manifestUrl } = getLeKitConfig();
|
|
124
|
+
const response = await fetch(manifestUrl);
|
|
102
125
|
const manifest = await response.json();
|
|
103
126
|
// Find the component definition
|
|
104
127
|
for (const module of manifest.modules) {
|
|
@@ -202,7 +225,7 @@ const LeComponent = class {
|
|
|
202
225
|
*/
|
|
203
226
|
renderPropertyEditor() {
|
|
204
227
|
const hasProperties = this.componentMeta && this.componentMeta.attributes.length > 0;
|
|
205
|
-
return (h("div", { class: "property-editor-container" }, hasProperties ? (h("form", { class: "property-editor", onSubmit:
|
|
228
|
+
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")))));
|
|
206
229
|
}
|
|
207
230
|
/**
|
|
208
231
|
* Render a single property field based on its type
|
|
@@ -214,15 +237,15 @@ const LeComponent = class {
|
|
|
214
237
|
const enumMatch = type.match(/^'[^']+'/);
|
|
215
238
|
if (enumMatch) {
|
|
216
239
|
const options = type.split('|').map(opt => opt.trim().replace(/'/g, ''));
|
|
217
|
-
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:
|
|
240
|
+
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))))));
|
|
218
241
|
}
|
|
219
242
|
// Boolean type
|
|
220
243
|
if (type === 'boolean') {
|
|
221
|
-
return (h("div", { class: "property-field property-field--checkbox" }, h("le-checkbox", { name: `prop-${attr.name}`, checked: value === true || value === '', onChange:
|
|
244
|
+
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))));
|
|
222
245
|
}
|
|
223
246
|
// Number type
|
|
224
247
|
if (type === 'number') {
|
|
225
|
-
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:
|
|
248
|
+
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) })));
|
|
226
249
|
}
|
|
227
250
|
// Default: string/text input
|
|
228
251
|
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))));
|
|
@@ -236,9 +259,103 @@ const LeComponent = class {
|
|
|
236
259
|
// In admin mode, show wrapper with header and settings
|
|
237
260
|
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)))));
|
|
238
261
|
}
|
|
239
|
-
static get
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
262
|
+
static get is() { return "le-component"; }
|
|
263
|
+
static get encapsulation() { return "shadow"; }
|
|
264
|
+
static get originalStyleUrls() {
|
|
265
|
+
return {
|
|
266
|
+
"$": ["le-component.css"]
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
static get styleUrls() {
|
|
270
|
+
return {
|
|
271
|
+
"$": ["le-component.css"]
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
static get properties() {
|
|
275
|
+
return {
|
|
276
|
+
"component": {
|
|
277
|
+
"type": "string",
|
|
278
|
+
"mutable": false,
|
|
279
|
+
"complexType": {
|
|
280
|
+
"original": "string",
|
|
281
|
+
"resolved": "string",
|
|
282
|
+
"references": {}
|
|
283
|
+
},
|
|
284
|
+
"required": true,
|
|
285
|
+
"optional": false,
|
|
286
|
+
"docs": {
|
|
287
|
+
"tags": [],
|
|
288
|
+
"text": "The tag name of the component (e.g., 'le-card').\nUsed to look up property metadata and display the component name."
|
|
289
|
+
},
|
|
290
|
+
"getter": false,
|
|
291
|
+
"setter": false,
|
|
292
|
+
"reflect": false,
|
|
293
|
+
"attribute": "component"
|
|
294
|
+
},
|
|
295
|
+
"displayName": {
|
|
296
|
+
"type": "string",
|
|
297
|
+
"mutable": false,
|
|
298
|
+
"complexType": {
|
|
299
|
+
"original": "string",
|
|
300
|
+
"resolved": "string",
|
|
301
|
+
"references": {}
|
|
302
|
+
},
|
|
303
|
+
"required": false,
|
|
304
|
+
"optional": true,
|
|
305
|
+
"docs": {
|
|
306
|
+
"tags": [],
|
|
307
|
+
"text": "Optional display name for the component.\nIf not provided, the tag name will be formatted as the display name."
|
|
308
|
+
},
|
|
309
|
+
"getter": false,
|
|
310
|
+
"setter": false,
|
|
311
|
+
"reflect": false,
|
|
312
|
+
"attribute": "display-name"
|
|
313
|
+
},
|
|
314
|
+
"hostClass": {
|
|
315
|
+
"type": "string",
|
|
316
|
+
"mutable": false,
|
|
317
|
+
"complexType": {
|
|
318
|
+
"original": "string",
|
|
319
|
+
"resolved": "string",
|
|
320
|
+
"references": {}
|
|
321
|
+
},
|
|
322
|
+
"required": false,
|
|
323
|
+
"optional": true,
|
|
324
|
+
"docs": {
|
|
325
|
+
"tags": [],
|
|
326
|
+
"text": "Classes to apply to the host element.\nAllows parent components to pass their styling classes."
|
|
327
|
+
},
|
|
328
|
+
"getter": false,
|
|
329
|
+
"setter": false,
|
|
330
|
+
"reflect": false,
|
|
331
|
+
"attribute": "host-class"
|
|
332
|
+
},
|
|
333
|
+
"hostStyle": {
|
|
334
|
+
"type": "unknown",
|
|
335
|
+
"mutable": false,
|
|
336
|
+
"complexType": {
|
|
337
|
+
"original": "{ [key: string]: string }",
|
|
338
|
+
"resolved": "{ [key: string]: string; }",
|
|
339
|
+
"references": {}
|
|
340
|
+
},
|
|
341
|
+
"required": false,
|
|
342
|
+
"optional": true,
|
|
343
|
+
"docs": {
|
|
344
|
+
"tags": [],
|
|
345
|
+
"text": "Inline styles to apply to the host element.\nAllows parent components to pass dynamic styles (e.g., flex properties)."
|
|
346
|
+
},
|
|
347
|
+
"getter": false,
|
|
348
|
+
"setter": false
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
static get states() {
|
|
353
|
+
return {
|
|
354
|
+
"adminMode": {},
|
|
355
|
+
"componentMeta": {},
|
|
356
|
+
"propertyValues": {}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
static get elementRef() { return "el"; }
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=le-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"le-component.js","sourceRoot":"","sources":["../../../src/components/le-component/le-component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,MAAM,OAAO,WAAW;IACX,EAAE,CAAc;IAE3B;;;OAGG;IACK,SAAS,CAAU;IAE3B;;;OAGG;IACK,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EAAE,IAAI,CAAC,SAAS;gBAC5E,eAAa,CACR,CACR,CAAC;QACJ,CAAC;QAED,uDAAuD;QACvD,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS;YAC1F,WAAK,KAAK,EAAC,sBAAsB;gBAC/B,WAAK,KAAK,EAAC,qBAAqB;oBAC9B,YAAM,KAAK,EAAC,mBAAmB,IAAE,IAAI,CAAQ;oBAC7C,kBAAY,YAAY,EAAE,GAAG,IAAI,WAAW,EAAE,QAAQ,EAAC,OAAO,EAAC,KAAK,EAAC,OAAO,eAAW,OAAO,EAAC,IAAI,EAAC,SAAS;wBAC3G,iBAAW,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAC,qBAAqB,EAAC,IAAI,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,gBAAY,2BAA2B;4BACrI,YAAM,KAAK,EAAC,sBAAsB,EAAC,IAAI,EAAC,WAAW,aAE5C,CACG;wBACX,IAAI,CAAC,oBAAoB,EAAE,CACjB,CACT;gBACN,WAAK,KAAK,EAAC,sBAAsB;oBAC/B,eAAa,CACT,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h, Host, Element } from '@stencil/core';\nimport { classnames, observeModeChanges } from '../../utils/utils';\nimport { getLeKitConfig } from '../../global/app';\n\n/**\n * Component wrapper for admin mode editing.\n *\n * This component is used internally by other components to provide admin-mode\n * editing capabilities. It wraps the component's rendered output and shows\n * a settings popover for editing properties.\n *\n * In default mode, it acts as a simple passthrough (display: contents).\n * In admin mode, it shows a border, component name header, and settings popover.\n *\n * The host element is found automatically by traversing up through the shadow DOM.\n *\n * Usage inside a component's render method:\n * ```tsx\n * render() {\n * return (\n * <le-component component=\"le-card\">\n * <Host>...</Host>\n * </le-component>\n * );\n * }\n * ```\n *\n * @slot - The component's rendered content\n *\n * @cmsInternal true\n * @cmsCategory System\n */\n@Component({\n tag: 'le-component',\n styleUrl: 'le-component.css',\n shadow: true,\n})\nexport class LeComponent {\n @Element() el: HTMLElement;\n\n /**\n * The tag name of the component (e.g., 'le-card').\n * Used to look up property metadata and display the component name.\n */\n @Prop() component!: string;\n\n /**\n * Optional display name for the component.\n * If not provided, the tag name will be formatted as the display name.\n */\n @Prop() displayName?: string;\n\n /**\n * Classes to apply to the host element.\n * Allows parent components to pass their styling classes.\n */\n @Prop() hostClass?: string;\n\n /**\n * Inline styles to apply to the host element.\n * Allows parent components to pass dynamic styles (e.g., flex properties).\n */\n @Prop() hostStyle?: { [key: string]: string };\n\n /**\n * Reference to the host element (found automatically from parent)\n */\n private hostElement?: HTMLElement;\n\n /**\n * Internal state to track admin mode\n */\n @State() private adminMode: boolean = false;\n\n /**\n * Component metadata loaded from Custom Elements Manifest\n */\n @State() private componentMeta: ComponentMetadata | null = null;\n\n /**\n * Current property values of the host component\n */\n @State() private propertyValues: Record<string, any> = {};\n\n private disconnectModeObserver?: () => void;\n\n connectedCallback() {\n // Find the host element - le-component is rendered inside the component's shadow DOM,\n // so we need to find the shadow root's host element\n this.findHostElement();\n\n this.disconnectModeObserver = observeModeChanges(this.el, mode => {\n this.adminMode = mode === 'admin';\n // Load metadata and refresh property values only when entering admin mode\n if (this.adminMode) {\n if (!this.componentMeta) {\n this.loadComponentMetadata();\n } else {\n this.readPropertyValues();\n }\n }\n });\n }\n\n /**\n * Find the host element by traversing up through shadow DOM\n */\n private findHostElement() {\n // Get the shadow root that contains this le-component\n const rootNode = this.el.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n // The host of this shadow root is our target component (e.g., le-card)\n this.hostElement = rootNode.host as HTMLElement;\n }\n }\n\n componentDidLoad() {\n // Read initial property values from the host element\n this.readPropertyValues();\n }\n\n disconnectedCallback() {\n this.disconnectModeObserver?.();\n }\n\n /**\n * Formats a tag name into a display name\n * e.g., 'le-card' -> 'Card'\n */\n private formatDisplayName(tagName: string): string {\n return tagName\n .replace(/^le-/, '') // Remove 'le-' prefix\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n }\n\n /**\n * Load component metadata from the Custom Elements Manifest\n */\n private async loadComponentMetadata() {\n try {\n // Fetch the manifest from configured URL\n const { manifestUrl } = getLeKitConfig();\n const response = await fetch(manifestUrl);\n const manifest = await response.json();\n\n // Find the component definition\n for (const module of manifest.modules) {\n for (const declaration of module.declarations || []) {\n if (declaration.tagName === this.component) {\n const attributes = (declaration.attributes || []).filter((attr: AttributeMetadata) => !this.isInternalAttribute(attr.name));\n this.componentMeta = {\n tagName: declaration.tagName,\n description: declaration.description,\n attributes,\n };\n // console.log(`[le-component] Loaded metadata for ${this.component}:`, this.componentMeta);\n // Read property values after metadata is loaded\n this.readPropertyValues();\n return;\n }\n }\n }\n // console.warn(`[le-component] No metadata found for component: ${this.component}`);\n } catch (error) {\n // console.warn(`[le-component] Failed to load metadata for component: ${this.component}`, error);\n }\n }\n\n /**\n * Check if an attribute is internal (should not be shown in editor)\n */\n private isInternalAttribute(name: string): boolean {\n const internalAttrs = ['mode', 'theme', 'class', 'style', 'id', 'slot'];\n return internalAttrs.includes(name);\n }\n\n /**\n * Read current property values from the host element\n */\n private readPropertyValues() {\n if (!this.hostElement || !this.componentMeta) return;\n\n const values: Record<string, any> = {};\n for (const attr of this.componentMeta.attributes) {\n const value = this.hostElement.getAttribute(attr.name);\n values[attr.name] = this.parseAttributeValue(value, attr.type?.text);\n }\n this.propertyValues = values;\n }\n\n /**\n * Parse an attribute value based on its type\n */\n private parseAttributeValue(value: string | null, type?: string): any {\n if (value === null) return undefined;\n\n if (type === 'boolean') {\n return value !== null && value !== 'false';\n }\n if (type === 'number') {\n return parseFloat(value);\n }\n return value;\n }\n\n /**\n * Handle property value changes from the editor\n */\n private handlePropertyChange(attrName: string, value: any, type?: string) {\n if (!this.hostElement) return;\n\n // Update the host element's attribute\n if (type === 'boolean') {\n if (value) {\n this.hostElement.setAttribute(attrName, '');\n } else {\n this.hostElement.removeAttribute(attrName);\n }\n } else if (value === undefined || value === '') {\n this.hostElement.removeAttribute(attrName);\n } else {\n this.hostElement.setAttribute(attrName, String(value));\n }\n\n // Update local state\n this.propertyValues = { ...this.propertyValues, [attrName]: value };\n }\n\n /**\n * Delete this component from the DOM\n */\n private deleteComponent() {\n if (!this.hostElement) return;\n\n // Confirm deletion\n const name = this.displayName || this.formatDisplayName(this.component);\n if (!confirm(`Delete this ${name}?`)) return;\n\n // Remove the host element from its parent\n const parent = this.hostElement.parentElement;\n if (parent) {\n this.hostElement.remove();\n }\n }\n\n /**\n * Render the property editor form\n */\n private renderPropertyEditor() {\n const hasProperties = this.componentMeta && this.componentMeta.attributes.length > 0;\n\n return (\n <div class=\"property-editor-container\">\n {hasProperties ? (\n <form class=\"property-editor\" onSubmit={e => e.preventDefault()}>\n {this.componentMeta!.attributes.map(attr => this.renderPropertyField(attr))}\n </form>\n ) : (\n <p class=\"no-properties\">No editable properties</p>\n )}\n <div class=\"property-editor-actions\">\n <le-button type=\"button\" variant=\"outlined\" color=\"danger\" full-width onClick={() => this.deleteComponent()}>\n <span slot=\"icon-start\">🗑️</span>\n <span>Delete Component</span>\n </le-button>\n </div>\n </div>\n );\n }\n\n /**\n * Render a single property field based on its type\n */\n private renderPropertyField(attr: AttributeMetadata) {\n const value = this.propertyValues[attr.name];\n const type = attr.type?.text || 'string';\n\n // Check if type is a union of string literals (e.g., \"'default' | 'outlined' | 'elevated'\")\n const enumMatch = type.match(/^'[^']+'/);\n if (enumMatch) {\n const options = type.split('|').map(opt => opt.trim().replace(/'/g, ''));\n return (\n <div class=\"property-field\">\n <label htmlFor={`prop-${attr.name}`}>\n {attr.name}\n {attr.description && <span class=\"property-hint\">{attr.description}</span>}\n </label>\n <select id={`prop-${attr.name}`} onChange={e => this.handlePropertyChange(attr.name, (e.target as HTMLSelectElement).value, type)}>\n {options.map(opt => (\n <option value={opt} selected={value === opt || (!value && attr.default?.replace(/'/g, '') === opt)}>\n {opt}\n </option>\n ))}\n </select>\n </div>\n );\n }\n\n // Boolean type\n if (type === 'boolean') {\n return (\n <div class=\"property-field property-field--checkbox\">\n <le-checkbox\n name={`prop-${attr.name}`}\n checked={value === true || value === ''}\n onChange={e => this.handlePropertyChange(attr.name, (e.target as HTMLInputElement).checked, type)}\n >\n {attr.name}\n {attr.description && <div slot=\"description\">{attr.description}</div>}\n </le-checkbox>\n </div>\n );\n }\n\n // Number type\n if (type === 'number') {\n return (\n <div class=\"property-field\">\n <label htmlFor={`prop-${attr.name}`}>\n {attr.name}\n {attr.description && <span class=\"property-hint\">{attr.description}</span>}\n </label>\n <input\n type=\"number\"\n id={`prop-${attr.name}`}\n value={value ?? ''}\n placeholder={attr.default}\n onChange={e => this.handlePropertyChange(attr.name, (e.target as HTMLInputElement).value, type)}\n />\n </div>\n );\n }\n\n // Default: string/text input\n return (\n <div class=\"property-field\">\n <le-string-input\n name={`prop-${attr.name}`}\n label={attr.name}\n value={value ?? ''}\n placeholder={attr.default?.replace(/'/g, '')}\n onChange={(e: any) => this.handlePropertyChange(attr.name, e.detail.value, type)}\n >\n <span slot=\"description\">{attr.description}</span>\n </le-string-input>\n </div>\n );\n }\n\n render() {\n const name = this.displayName || this.formatDisplayName(this.component);\n\n // In default mode, just pass through content with host classes\n if (!this.adminMode) {\n return (\n <Host class={classnames(this.component, this.hostClass)} style={this.hostStyle}>\n <slot></slot>\n </Host>\n );\n }\n\n // In admin mode, show wrapper with header and settings\n return (\n <Host class={classnames(this.component, this.hostClass, 'admin-mode')} style={this.hostStyle}>\n <div class=\"le-component-wrapper\">\n <div class=\"le-component-header\">\n <span class=\"le-component-name\">{name}</span>\n <le-popover popoverTitle={`${name} Settings`} position=\"right\" align=\"start\" min-width=\"300px\" mode=\"default\">\n <le-button type=\"button\" class=\"le-component-button\" slot=\"trigger\" variant=\"clear\" size=\"small\" aria-label=\"Edit component properties\" icon-only>\n <span class=\"le-component-trigger\" slot=\"icon-only\">\n ⚙\n </span>\n </le-button>\n {this.renderPropertyEditor()}\n </le-popover>\n </div>\n <div class=\"le-component-content\">\n <slot></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n\n/**\n * Type definitions for component metadata\n */\ninterface ComponentMetadata {\n tagName: string;\n description?: string;\n attributes: AttributeMetadata[];\n}\n\ninterface AttributeMetadata {\n name: string;\n fieldName?: string;\n description?: string;\n default?: string;\n type?: {\n text: string;\n };\n}\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
--le-input-bg: var(--le-color-surface, #ffffff);
|
|
4
|
+
--le-input-color: var(--le-color-text-primary, #333333);
|
|
5
|
+
--le-input-border: var(--le-border-width, 2px) solid var(--le-color-border-input, #007bff);
|
|
6
|
+
--le-input-radius: var(--le-radius-sm, 4px);
|
|
7
|
+
--le-input-padding: 2px 6px;
|
|
8
|
+
--le-input-height: 1.5rem;
|
|
9
|
+
--le-input-label-color: var(--le-color-text-primary, #333333);
|
|
10
|
+
--le-input-desc-color: var(--le-color-text-secondary, #666666);
|
|
11
|
+
--le-input-placeholder-color: #999999;
|
|
12
|
+
--le-input-border-error: 2px solid var(--le-color-danger, #dc3545);
|
|
13
|
+
--le-input-error-color: var(--le-color-danger, #dc3545);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.le-input-wrapper {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 2px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.le-input-label {
|
|
23
|
+
display: block;
|
|
24
|
+
font-size: 0.9em;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
color: var(--le-input-label-color);
|
|
27
|
+
margin-bottom: 2px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.le-input-container {
|
|
31
|
+
position: relative;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
background: var(--le-input-bg);
|
|
35
|
+
border: var(--le-input-border);
|
|
36
|
+
border-radius: var(--le-input-radius);
|
|
37
|
+
transition: border-color 0.2s;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.le-input-container:focus-within {
|
|
41
|
+
outline: 2px solid var(--le-color-focus);
|
|
42
|
+
outline-offset: 2px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.le-input-container.has-error {
|
|
46
|
+
border: var(--le-input-border-error);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([disabled]) .le-input-container {
|
|
50
|
+
opacity: 0.6;
|
|
51
|
+
background-color: rgba(0,0,0,0.05);
|
|
52
|
+
cursor: not-allowed;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
input {
|
|
56
|
+
flex: 1;
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: calc(var(--le-input-height) - 2px);
|
|
59
|
+
padding: var(--le-input-padding);
|
|
60
|
+
border: none;
|
|
61
|
+
background: transparent;
|
|
62
|
+
color: var(--le-input-color);
|
|
63
|
+
font-family: inherit;
|
|
64
|
+
font-size: inherit;
|
|
65
|
+
outline: none;
|
|
66
|
+
text-align: right; /* Aligned to end */
|
|
67
|
+
-moz-appearance: textfield; /* Remove default spinners in Firefox */
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Remove default spinners in Chrome/Safari/Edge */
|
|
71
|
+
input::-webkit-outer-spin-button,
|
|
72
|
+
input::-webkit-inner-spin-button {
|
|
73
|
+
-webkit-appearance: none;
|
|
74
|
+
margin: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
input::placeholder {
|
|
78
|
+
color: var(--le-input-placeholder-color);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.icon-start, .icon-end {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
padding: 0 8px;
|
|
86
|
+
color: var(--le-input-desc-color);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.le-input-controls {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
border-left: 1px solid var(--le-color-border, #cccccc);
|
|
93
|
+
height: 100%;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.le-input-control-btn {
|
|
97
|
+
--le-button-border-radius: 0;
|
|
98
|
+
--le-button-padding-x: 0;
|
|
99
|
+
--le-button-padding-y: 0;
|
|
100
|
+
--le-button-small-font-size: 9.5px;
|
|
101
|
+
--le-button-small-padding: 0 0.2rem;
|
|
102
|
+
--le-button-icon-aspect-ratio: 2;
|
|
103
|
+
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
height: 50%;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
background: none;
|
|
110
|
+
border: none;
|
|
111
|
+
color: var(--le-input-desc-color);
|
|
112
|
+
font-size: 10px;
|
|
113
|
+
line-height: 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.le-input-control-btn:hover {
|
|
117
|
+
background-color: rgba(0,0,0,0.05);
|
|
118
|
+
color: var(--le-color-primary, #007bff);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.le-input-control-btn:active {
|
|
122
|
+
background-color: rgba(0,0,0,0.1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.le-input-description {
|
|
126
|
+
font-size: 0.85em;
|
|
127
|
+
color: var(--le-input-desc-color);
|
|
128
|
+
margin-top: 2px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.le-input-error {
|
|
132
|
+
font-size: 0.85em;
|
|
133
|
+
color: var(--le-input-error-color);
|
|
134
|
+
margin-top: 2px;
|
|
135
|
+
}
|