le-kit 0.1.4 → 0.1.6
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/cjs/{index-CO4npcak.js → index-WzJ78D5H.js} +9 -2
- package/dist/cjs/{index-CO4npcak.js.map → index-WzJ78D5H.js.map} +1 -1
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/le-box.cjs.entry.js +2 -2
- package/dist/cjs/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.cjs.js.map +1 -1
- package/dist/cjs/le-button_6.cjs.entry.js +25 -22
- package/dist/cjs/le-card.cjs.entry.js +2 -2
- package/dist/cjs/le-kit.cjs.js +1 -1
- package/dist/cjs/le-number-input.cjs.entry.js +2 -2
- package/dist/cjs/le-popup.cjs.entry.js +1 -1
- package/dist/cjs/le-round-progress.cjs.entry.js +1 -1
- package/dist/cjs/le-stack.cjs.entry.js +2 -2
- package/dist/cjs/le-text.cjs.entry.js +2 -2
- package/dist/cjs/le-turntable.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{utils-BeT0iyCQ.js → utils-CBjH2E8A.js} +3 -3
- package/dist/cjs/{utils-BeT0iyCQ.js.map → utils-CBjH2E8A.js.map} +1 -1
- package/dist/collection/assets/.gitkeep +1 -0
- package/dist/collection/assets/custom-elements.json +4305 -0
- package/dist/collection/components/le-component/le-component.js +10 -8
- package/dist/collection/components/le-component/le-component.js.map +1 -1
- package/dist/collection/components/le-slot/le-slot.js +15 -14
- package/dist/collection/components/le-slot/le-slot.js.map +1 -1
- package/dist/components/le-button2.js +24 -21
- package/dist/components/le-button2.js.map +1 -1
- package/dist/docs.json +2 -2
- package/dist/esm/{index-D71TXvJa.js → index-CdjJ98OT.js} +9 -3
- package/dist/esm/{index-D71TXvJa.js.map → index-CdjJ98OT.js.map} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/le-box.entry.js +2 -2
- package/dist/esm/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.js.map +1 -1
- package/dist/esm/le-button_6.entry.js +25 -22
- package/dist/esm/le-card.entry.js +2 -2
- package/dist/esm/le-kit.js +2 -2
- package/dist/esm/le-number-input.entry.js +2 -2
- package/dist/esm/le-popup.entry.js +1 -1
- package/dist/esm/le-round-progress.entry.js +1 -1
- package/dist/esm/le-stack.entry.js +2 -2
- package/dist/esm/le-text.entry.js +2 -2
- package/dist/esm/le-turntable.entry.js +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{utils-CJLZrrdC.js → utils-CzfSUhYB.js} +3 -3
- package/dist/esm/{utils-CJLZrrdC.js.map → utils-CzfSUhYB.js.map} +1 -1
- package/dist/le-kit/assets/custom-elements.json +4305 -0
- package/dist/le-kit/index.esm.js +1 -1
- package/dist/le-kit/le-button.le-checkbox.le-component.le-popover.le-slot.le-string-input.entry.esm.js.map +1 -1
- package/dist/le-kit/le-kit.esm.js +1 -1
- package/dist/le-kit/{p-cfc35bd3.entry.js → p-0633b3ab.entry.js} +2 -2
- package/dist/le-kit/{p-0955b105.entry.js → p-1452a995.entry.js} +2 -2
- package/dist/le-kit/{p-18d79ee2.entry.js → p-220528ee.entry.js} +2 -2
- package/dist/le-kit/p-32ff3dbe.entry.js +2 -0
- package/dist/le-kit/p-32ff3dbe.entry.js.map +1 -0
- package/dist/le-kit/{p-d04da1f5.entry.js → p-3551598e.entry.js} +2 -2
- package/dist/le-kit/{p-79d179bd.entry.js → p-722899f0.entry.js} +2 -2
- package/dist/le-kit/{p-c8a9288e.entry.js → p-95764888.entry.js} +2 -2
- package/dist/le-kit/{p-D71TXvJa.js → p-CdjJ98OT.js} +2 -2
- package/dist/le-kit/{p-D71TXvJa.js.map → p-CdjJ98OT.js.map} +1 -1
- package/dist/le-kit/{p-qIai5-eB.js → p-CvDc0yWN.js} +2 -2
- package/dist/le-kit/{p-qIai5-eB.js.map → p-CvDc0yWN.js.map} +1 -1
- package/dist/le-kit/{p-024a764e.entry.js → p-bc20e30d.entry.js} +2 -2
- package/dist/le-kit/{p-4b1d3b6d.entry.js → p-d32eddad.entry.js} +2 -2
- package/dist/types/components.d.ts +4 -4
- package/package.json +1 -1
- package/dist/le-kit/index-D21JjI31.js.map +0 -1
- package/dist/le-kit/p-073cf0b9.entry.js +0 -2
- package/dist/le-kit/p-073cf0b9.entry.js.map +0 -1
- package/dist/le-kit/utils-apol-Xc_.js.map +0 -1
- /package/dist/le-kit/{p-cfc35bd3.entry.js.map → p-0633b3ab.entry.js.map} +0 -0
- /package/dist/le-kit/{p-0955b105.entry.js.map → p-1452a995.entry.js.map} +0 -0
- /package/dist/le-kit/{p-18d79ee2.entry.js.map → p-220528ee.entry.js.map} +0 -0
- /package/dist/le-kit/{p-d04da1f5.entry.js.map → p-3551598e.entry.js.map} +0 -0
- /package/dist/le-kit/{p-79d179bd.entry.js.map → p-722899f0.entry.js.map} +0 -0
- /package/dist/le-kit/{p-c8a9288e.entry.js.map → p-95764888.entry.js.map} +0 -0
- /package/dist/le-kit/{p-024a764e.entry.js.map → p-bc20e30d.entry.js.map} +0 -0
- /package/dist/le-kit/{p-4b1d3b6d.entry.js.map → p-d32eddad.entry.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
|
1
|
+
import { h, Host, getAssetPath } from "@stencil/core";
|
|
2
2
|
import { classnames, observeModeChanges } from "../../utils/utils";
|
|
3
3
|
/**
|
|
4
4
|
* Component wrapper for admin mode editing.
|
|
@@ -71,7 +71,7 @@ export class LeComponent {
|
|
|
71
71
|
// Find the host element - le-component is rendered inside the component's shadow DOM,
|
|
72
72
|
// so we need to find the shadow root's host element
|
|
73
73
|
this.findHostElement();
|
|
74
|
-
this.disconnectModeObserver = observeModeChanges(this.el,
|
|
74
|
+
this.disconnectModeObserver = observeModeChanges(this.el, mode => {
|
|
75
75
|
this.adminMode = mode === 'admin';
|
|
76
76
|
// Load metadata and refresh property values only when entering admin mode
|
|
77
77
|
if (this.adminMode) {
|
|
@@ -118,8 +118,9 @@ export class LeComponent {
|
|
|
118
118
|
*/
|
|
119
119
|
async loadComponentMetadata() {
|
|
120
120
|
try {
|
|
121
|
-
// Fetch the manifest
|
|
122
|
-
const
|
|
121
|
+
// Fetch the manifest using getAssetPath for correct bundle path
|
|
122
|
+
const manifestPath = getAssetPath('assets/custom-elements.json');
|
|
123
|
+
const response = await fetch(manifestPath);
|
|
123
124
|
const manifest = await response.json();
|
|
124
125
|
// Find the component definition
|
|
125
126
|
for (const module of manifest.modules) {
|
|
@@ -223,7 +224,7 @@ export class LeComponent {
|
|
|
223
224
|
*/
|
|
224
225
|
renderPropertyEditor() {
|
|
225
226
|
const hasProperties = this.componentMeta && this.componentMeta.attributes.length > 0;
|
|
226
|
-
return (h("div", { class: "property-editor-container" }, hasProperties ? (h("form", { class: "property-editor", onSubmit:
|
|
227
|
+
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")))));
|
|
227
228
|
}
|
|
228
229
|
/**
|
|
229
230
|
* Render a single property field based on its type
|
|
@@ -235,15 +236,15 @@ export class LeComponent {
|
|
|
235
236
|
const enumMatch = type.match(/^'[^']+'/);
|
|
236
237
|
if (enumMatch) {
|
|
237
238
|
const options = type.split('|').map(opt => opt.trim().replace(/'/g, ''));
|
|
238
|
-
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:
|
|
239
|
+
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))))));
|
|
239
240
|
}
|
|
240
241
|
// Boolean type
|
|
241
242
|
if (type === 'boolean') {
|
|
242
|
-
return (h("div", { class: "property-field property-field--checkbox" }, h("le-checkbox", { name: `prop-${attr.name}`, checked: value === true || value === '', onChange:
|
|
243
|
+
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))));
|
|
243
244
|
}
|
|
244
245
|
// Number type
|
|
245
246
|
if (type === 'number') {
|
|
246
|
-
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:
|
|
247
|
+
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) })));
|
|
247
248
|
}
|
|
248
249
|
// Default: string/text input
|
|
249
250
|
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))));
|
|
@@ -269,6 +270,7 @@ export class LeComponent {
|
|
|
269
270
|
"$": ["le-component.css"]
|
|
270
271
|
};
|
|
271
272
|
}
|
|
273
|
+
static get assetsDirs() { return ["../../assets"]; }
|
|
272
274
|
static get properties() {
|
|
273
275
|
return {
|
|
274
276
|
"component": {
|
|
@@ -1 +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;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,MAAM,OAAO,WAAW;IACX,EAAE,CAAc;IAE3B;;;OAGG;IACK,SAAS,CAAU;IAE3B;;;OAGG;IACK,WAAW,CAAU;IAE7B;;;OAGG;IACK,SAAS,CAAU;IAE3B;;;OAGG;IACK,SAAS,CAA6B;IAE9C;;OAEG;IACK,WAAW,CAAe;IAElC;;OAEG;IACc,SAAS,GAAY,KAAK,CAAC;IAE5C;;OAEG;IACc,aAAa,GAA6B,IAAI,CAAC;IAEhE;;OAEG;IACc,cAAc,GAAwB,EAAE,CAAC;IAElD,sBAAsB,CAAc;IAE5C,iBAAiB;QACf,sFAAsF;QACtF,oDAAoD;QACpD,IAAI,CAAC,eAAe,EAAE,CAAC;QAEvB,IAAI,CAAC,sBAAsB,GAAG,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;YACjE,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,OAAO,CAAC;YAClC,0EAA0E;YAC1E,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;oBACxB,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC5B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;I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,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h, Host, Element } from '@stencil/core';\nimport { classnames, observeModeChanges } from '../../utils/utils';\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 - in production this would be bundled or cached\n const response = await fetch('/custom-elements.json');\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(\n (attr: AttributeMetadata) => !this.isInternalAttribute(attr.name)\n );\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\n type=\"button\"\n variant=\"outlined\"\n color=\"danger\"\n full-width\n onClick={() => this.deleteComponent()}\n >\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\n id={`prop-${attr.name}`}\n onChange={(e) => this.handlePropertyChange(attr.name, (e.target as HTMLSelectElement).value, type)}\n >\n {options.map(opt => (\n <option value={opt} selected={value === opt || (!value && attr.default?.replace(/'/g, '') === opt)}>{opt}</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 \n popoverTitle={`${name} Settings`}\n position=\"right\"\n align=\"start\"\n min-width=\"300px\"\n mode=\"default\"\n >\n <le-button\n type=\"button\"\n class=\"le-component-button\"\n slot=\"trigger\"\n variant=\"clear\"\n size=\"small\"\n aria-label=\"Edit component properties\"\n icon-only\n >\n <span class=\"le-component-trigger\" slot=\"icon-only\">⚙</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"]}
|
|
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,YAAY,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAOH,MAAM,OAAO,WAAW;IACX,EAAE,CAAc;IAE3B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,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,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, getAssetPath } from '@stencil/core';\nimport { classnames, observeModeChanges } from '../../utils/utils';\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 assetsDirs: ['../../assets'],\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 using getAssetPath for correct bundle path\n const manifestPath = getAssetPath('assets/custom-elements.json');\n const response = await fetch(manifestPath);\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
|
1
|
+
import { h, Host, getAssetPath } from "@stencil/core";
|
|
2
2
|
import { classnames, observeModeChanges } from "../../utils/utils";
|
|
3
3
|
/**
|
|
4
4
|
* Slot placeholder component for admin/CMS mode.
|
|
@@ -105,7 +105,7 @@ export class LeSlot {
|
|
|
105
105
|
leSlotChange;
|
|
106
106
|
disconnectModeObserver;
|
|
107
107
|
connectedCallback() {
|
|
108
|
-
this.disconnectModeObserver = observeModeChanges(this.el,
|
|
108
|
+
this.disconnectModeObserver = observeModeChanges(this.el, mode => {
|
|
109
109
|
const wasAdmin = this.adminMode;
|
|
110
110
|
this.adminMode = mode === 'admin';
|
|
111
111
|
// When entering admin mode, read content from slotted elements
|
|
@@ -209,8 +209,7 @@ export class LeSlot {
|
|
|
209
209
|
if (!this.name && rootNode instanceof ShadowRoot) {
|
|
210
210
|
const hostComponent = rootNode.host;
|
|
211
211
|
Array.from(hostComponent.childNodes).forEach(node => {
|
|
212
|
-
if (node.nodeType === Node.TEXT_NODE ||
|
|
213
|
-
(node.nodeType === Node.ELEMENT_NODE && !node.hasAttribute('slot'))) {
|
|
212
|
+
if (node.nodeType === Node.TEXT_NODE || (node.nodeType === Node.ELEMENT_NODE && !node.hasAttribute('slot'))) {
|
|
214
213
|
node.remove();
|
|
215
214
|
}
|
|
216
215
|
});
|
|
@@ -230,7 +229,7 @@ export class LeSlot {
|
|
|
230
229
|
this.leSlotChange.emit({
|
|
231
230
|
name: this.name,
|
|
232
231
|
value: this.textValue,
|
|
233
|
-
isValid: this.isValidHtml
|
|
232
|
+
isValid: this.isValidHtml,
|
|
234
233
|
});
|
|
235
234
|
};
|
|
236
235
|
/**
|
|
@@ -266,7 +265,8 @@ export class LeSlot {
|
|
|
266
265
|
*/
|
|
267
266
|
async loadAvailableComponents() {
|
|
268
267
|
try {
|
|
269
|
-
const
|
|
268
|
+
const manifestPath = getAssetPath('assets/custom-elements.json');
|
|
269
|
+
const response = await fetch(manifestPath);
|
|
270
270
|
const manifest = await response.json();
|
|
271
271
|
const components = [];
|
|
272
272
|
const allowedList = this.allowedComponents?.split(',').map(s => s.trim()) || [];
|
|
@@ -289,7 +289,7 @@ export class LeSlot {
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
this.availableComponents = components;
|
|
292
|
+
this.availableComponents = components || [];
|
|
293
293
|
}
|
|
294
294
|
catch (error) {
|
|
295
295
|
console.warn('[le-slot] Failed to load component manifest:', error);
|
|
@@ -341,17 +341,17 @@ export class LeSlot {
|
|
|
341
341
|
render() {
|
|
342
342
|
const displayLabel = this.label || this.name;
|
|
343
343
|
// Always render the same structure, CSS handles visibility via .admin-mode class
|
|
344
|
-
return (h(Host, { key: '
|
|
344
|
+
return (h(Host, { key: 'af150a31db62d9c3df9a8c10be34b9bb6756d07f', class: {
|
|
345
345
|
'admin-mode': this.adminMode,
|
|
346
|
-
'invalid-html': !this.isValidHtml
|
|
346
|
+
'invalid-html': !this.isValidHtml,
|
|
347
347
|
}, 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', {
|
|
348
348
|
'le-slot-header-no-label': !displayLabel,
|
|
349
349
|
'le-slot-header-text': this.type === 'text',
|
|
350
|
-
'le-slot-header-error': !this.isValidHtml
|
|
351
|
-
}) }, 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: () => {
|
|
350
|
+
'le-slot-header-error': !this.isValidHtml,
|
|
351
|
+
}) }, 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: () => {
|
|
352
352
|
this.addComponent(component.tagName);
|
|
353
353
|
this.pickerOpen = false;
|
|
354
|
-
} }, h("span", { class: "le-slot-picker-name" }, component.name), component.description &&
|
|
354
|
+
} }, 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())) : (
|
|
355
355
|
// In default mode, just pass through the slot - slotted content renders naturally
|
|
356
356
|
// Note: We use unnamed slot here because named slots from parent component
|
|
357
357
|
// are passed as le-slot's light DOM children
|
|
@@ -362,7 +362,7 @@ export class LeSlot {
|
|
|
362
362
|
// Wrap in a hidden div since slot elements can't have style prop in Stencil
|
|
363
363
|
// Note: We use unnamed slot here because named slots from parent component
|
|
364
364
|
// are passed as le-slot's light DOM children
|
|
365
|
-
const slotElement = (h("div", { class: "hidden-slot" }, h("slot", { ref:
|
|
365
|
+
const slotElement = (h("div", { class: "hidden-slot" }, h("slot", { ref: el => (this.slotRef = el), onSlotchange: this.handleSlotChange })));
|
|
366
366
|
switch (this.type) {
|
|
367
367
|
case 'text':
|
|
368
368
|
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));
|
|
@@ -382,7 +382,7 @@ export class LeSlot {
|
|
|
382
382
|
}
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
|
-
return (h("div", { class: "le-slot-dropzone", style: dropzoneStyle }, h("slot", { ref:
|
|
385
|
+
return (h("div", { class: "le-slot-dropzone", style: dropzoneStyle }, h("slot", { ref: el => (this.slotRef = el), onSlotchange: this.handleSlotChange })));
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
static get is() { return "le-slot"; }
|
|
@@ -397,6 +397,7 @@ export class LeSlot {
|
|
|
397
397
|
"$": ["le-slot.default.css"]
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
|
+
static get assetsDirs() { return ["../../assets"]; }
|
|
400
401
|
static get properties() {
|
|
401
402
|
return {
|
|
402
403
|
"type": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"le-slot.js","sourceRoot":"","sources":["../../../src/components/le-slot/le-slot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;;;;;;GAYG;AAMH,MAAM,OAAO,MAAM;IACN,EAAE,CAAc;IAE3B;;;;;OAKG;IACK,IAAI,GAAiC,MAAM,CAAC;IAEpD;;;OAGG;IACK,IAAI,GAAW,EAAE,CAAC;IAE1B;;;OAGG;IACK,KAAK,CAAU;IAEvB;;;OAGG;IACK,WAAW,CAAU;IAE7B;;;;;OAKG;IACK,iBAAiB,CAAU;IAEnC;;OAEG;IACK,QAAQ,GAAY,IAAI,CAAC;IAEjC;;OAEG;IACK,QAAQ,GAAY,KAAK,CAAC;IAElC;;OAEG;IACK,WAAW,CAAU;IAE7B;;;;;;OAMG;IACK,GAAG,CAAU;IAErB;;;;OAIG;IACK,SAAS,CAAU;IAE3B;;OAEG;IACc,SAAS,GAAY,KAAK,CAAC;IAE5C;;OAEG;IACc,SAAS,GAAW,EAAE,CAAC;IAExC;;OAEG;IACc,WAAW,GAAY,IAAI,CAAC;IAE7C;;OAEG;IACc,mBAAmB,GAAoB,EAAE,CAAC;IAE3D;;OAEG;IACc,UAAU,GAAY,KAAK,CAAC;IAE7C;;OAEG;IACK,OAAO,CAAmB;IAElC;;OAEG;IACK,cAAc,CAAW;IAEjC;;;O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AAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,EAAqB,EACjD,YAAY,EAAE,IAAI,CAAC,gBAAgB,GAC7B,CACJ,CACP,CAAC;QACN,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h, Host, Element, Event, EventEmitter } from '@stencil/core';\nimport { classnames, observeModeChanges } from '../../utils/utils';\n\n/**\n * Slot placeholder component for admin/CMS mode.\n *\n * This component renders a visual placeholder for slots when in admin mode,\n * allowing CMS systems to show available drop zones for content or inline editing.\n *\n * In non-admin mode, this component renders nothing and acts as a passthrough.\n *\n * @slot - Default slot for placeholder content or drop zone UI\n *\n * @cmsInternal true\n * @cmsCategory System\n */\n@Component({\n tag: 'le-slot',\n styleUrl: 'le-slot.default.css',\n shadow: true,\n})\nexport class LeSlot {\n @Element() el: HTMLElement;\n\n /**\n * The type of slot content.\n * - `slot`: Default, shows a dropzone for components (default)\n * - `text`: Shows a single-line text input\n * - `textarea`: Shows a multi-line text area\n */\n @Prop() type: 'slot' | 'text' | 'textarea' = 'slot';\n\n /**\n * The name of the slot this placeholder represents.\n * Should match the slot name in the parent component.\n */\n @Prop() name: string = '';\n\n /**\n * Label to display in admin mode.\n * If not provided, the slot name will be used.\n */\n @Prop() label?: string;\n\n /**\n * Description of what content this slot accepts.\n * Shown in admin mode to guide content editors.\n */\n @Prop() description?: string;\n\n /**\n * Comma-separated list of allowed component tags for this slot.\n * Used by CMS to filter available components.\n *\n * @example \"le-card,le-button,le-text\"\n */\n @Prop() allowedComponents?: string;\n\n /**\n * Whether multiple components can be dropped in this slot.\n */\n @Prop() multiple: boolean = true;\n\n /**\n * Whether this slot is required to have content.\n */\n @Prop() required: boolean = false;\n\n /**\n * Placeholder text for text/textarea inputs in admin mode.\n */\n @Prop() placeholder?: string;\n\n /**\n * The HTML tag to create when there's no slotted element.\n * Used with type=\"text\" or type=\"textarea\" to auto-create elements.\n * \n * @example \"h3\" - creates <h3 slot=\"header\">content</h3>\n * @example \"p\" - creates <p slot=\"content\">content</p>\n */\n @Prop() tag?: string;\n\n /**\n * CSS styles for the slot dropzone container.\n * Useful for layouts - e.g., \"flex-direction: row\" for horizontal stacks.\n * Only applies in admin mode for type=\"slot\".\n */\n @Prop() slotStyle?: string;\n\n /**\n * Internal state to track admin mode\n */\n @State() private adminMode: boolean = false;\n\n /**\n * Internal state for text input value (synced from slot content)\n */\n @State() private textValue: string = '';\n\n /**\n * Whether the current textValue contains valid HTML\n */\n @State() private isValidHtml: boolean = true;\n\n /**\n * Available components loaded from Custom Elements Manifest\n */\n @State() private availableComponents: ComponentInfo[] = [];\n\n /**\n * Whether the component picker popover is open\n */\n @State() private pickerOpen: boolean = false;\n\n /**\n * Reference to the slot element to access assignedNodes\n */\n private slotRef?: HTMLSlotElement;\n\n /**\n * The original slotted element (e.g., <h3 slot=\"header\">)\n */\n private slottedElement?: Element;\n\n /**\n * Emitted when text content changes in admin mode.\n * The event detail contains the new text value and validity.\n */\n @Event() leSlotChange: EventEmitter<{ name: string; value: string; isValid: boolean }>;\n\n private disconnectModeObserver?: () => void;\n\n connectedCallback() {\n this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {\n const wasAdmin = this.adminMode;\n this.adminMode = mode === 'admin';\n \n // When entering admin mode, read content from slotted elements\n if (this.adminMode && !wasAdmin) {\n // Need to wait for render to access slot ref\n requestAnimationFrame(() => this.readSlottedContent());\n \n // Load available components for the component picker\n if (this.type === 'slot') {\n this.loadAvailableComponents();\n }\n }\n });\n }\n\n disconnectedCallback() {\n this.disconnectModeObserver?.();\n }\n\n /**\n * Flag to prevent re-reading content right after we updated it\n */\n private isUpdating: boolean = false;\n\n /**\n * Read content from slotted elements via assignedNodes()\n */\n private readSlottedContent() {\n if (!this.slotRef) return;\n \n // Skip if we just updated the content ourselves\n if (this.isUpdating) {\n this.isUpdating = false;\n return;\n }\n\n const assignedNodes = this.slotRef.assignedNodes({ flatten: true });\n \n // For text/textarea types, we want to edit the innerHTML of slotted elements\n if (this.type === 'text' || this.type === 'textarea') {\n // Find the first element node (skip text nodes that are just whitespace)\n const elementNode = assignedNodes.find(\n node => node.nodeType === Node.ELEMENT_NODE\n ) as Element | undefined;\n\n if (elementNode) {\n // Only update textValue if slotted element changed or we don't have one yet\n if (this.slottedElement !== elementNode) {\n this.slottedElement = elementNode;\n this.textValue = elementNode.innerHTML?.trim() || '';\n // console.log(`[le-slot \"${this.name}\"] Read slotted content:`, this.textValue);\n }\n } else {\n // No element, check for direct text content\n const textContent = assignedNodes\n .filter(node => node.nodeType === Node.TEXT_NODE)\n .map(node => node.textContent)\n .join('')\n .trim();\n \n if (textContent && !this.textValue) {\n this.textValue = textContent;\n // console.log(`[le-slot \"${this.name}\"] Read text content:`, this.textValue);\n }\n }\n }\n }\n\n /**\n * Validates if a string contains valid HTML\n */\n private validateHtml(html: string): boolean {\n // Empty string is valid\n if (!html.trim()) return true;\n \n // Create a template element to parse the HTML\n const template = document.createElement('template');\n template.innerHTML = html;\n \n // Check that we don't have obviously broken HTML\n // Count opening and closing tags for common elements\n const openTags = (html.match(/<[a-z][^>]*(?<!\\/)>/gi) || []).length;\n const closeTags = (html.match(/<\\/[a-z][^>]*>/gi) || []).length;\n const selfClosing = (html.match(/<[a-z][^>]*\\/>/gi) || []).length;\n \n // Simple validation: opening tags (minus self-closing) should roughly match closing tags\n // Allow some tolerance for void elements like <br>, <img>, etc.\n const voidElements = (html.match(/<(br|hr|img|input|meta|link|area|base|col|embed|param|source|track|wbr)[^>]*>/gi) || []).length;\n \n const effectiveOpenTags = openTags - selfClosing - voidElements;\n \n // If difference is too large, HTML is likely broken\n if (Math.abs(effectiveOpenTags - closeTags) > 1) {\n return false;\n }\n \n return true;\n }\n\n private handleTextInput = (event: Event) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n this.textValue = target.value;\n this.isValidHtml = this.validateHtml(this.textValue);\n\n if (this.isValidHtml) {\n // Set flag to prevent slotchange from re-reading what we just wrote\n this.isUpdating = true;\n\n console.log('Updating text value:', this.textValue, 'slottedElement:', this.slottedElement);\n\n if (this.slottedElement) {\n // Update existing slotted element's innerHTML\n this.slottedElement.innerHTML = this.textValue;\n } else if (this.tag && this.textValue) {\n // No slotted element exists\n // If the slot doesn't have a name, then it's the default slot\n // remove the existing non-slotted content (text nodes and elements without slot attribute)\n const rootNode = this.el.getRootNode();\n if (!this.name && rootNode instanceof ShadowRoot) {\n const hostComponent = rootNode.host;\n Array.from(hostComponent.childNodes).forEach(node => {\n if (node.nodeType === Node.TEXT_NODE || \n (node.nodeType === Node.ELEMENT_NODE && !(node as Element).hasAttribute('slot'))) {\n node.remove();\n }\n });\n }\n // create one using the specified tag\n this.createSlottedElement();\n } else if (this.textValue) {\n // no tag specified - just replace everything in the host component\n const rootNode = this.el.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n const hostComponent = rootNode.host;\n hostComponent.innerHTML = this.textValue;\n }\n }\n }\n \n this.leSlotChange.emit({ \n name: this.name, \n value: this.textValue,\n isValid: this.isValidHtml \n });\n };\n\n /**\n * Create a new slotted element when none exists.\n * The element is appended to the host component's light DOM.\n */\n private createSlottedElement() {\n if (!this.tag) return;\n \n // Find the host component (le-card, etc.) by traversing up through shadow DOM\n // le-slot is inside le-card's shadow DOM, so we need to find le-card's host\n const rootNode = this.el.getRootNode();\n if (!(rootNode instanceof ShadowRoot)) return;\n \n const hostComponent = rootNode.host;\n if (!hostComponent) return;\n \n // Create the new element\n const newElement = document.createElement(this.tag);\n newElement.innerHTML = this.textValue;\n \n // Set the slot attribute if this is a named slot\n if (this.name) {\n newElement.setAttribute('slot', this.name);\n }\n \n // Append to the host component's light DOM\n hostComponent.appendChild(newElement);\n \n // Store reference to the new element\n this.slottedElement = newElement;\n \n // console.log(`[le-slot \"${this.name}\"] Created new <${this.tag}> element`);\n }\n\n /**\n * Load available components from Custom Elements Manifest\n */\n private async loadAvailableComponents() {\n try {\n const response = await fetch('/custom-elements.json');\n const manifest = await response.json();\n \n const components: ComponentInfo[] = [];\n const allowedList = this.allowedComponents?.split(',').map(s => s.trim()) || [];\n \n for (const module of manifest.modules) {\n for (const declaration of module.declarations || []) {\n if (declaration.tagName && declaration.customElement) {\n // Skip internal components (le-slot, le-component, le-popover)\n const isInternal = ['le-slot', 'le-component', 'le-popover'].includes(declaration.tagName);\n if (isInternal) continue;\n \n // If allowedComponents is specified, filter by it\n if (allowedList.length > 0 && !allowedList.includes(declaration.tagName)) {\n continue;\n }\n \n components.push({\n tagName: declaration.tagName,\n name: this.formatComponentName(declaration.tagName),\n description: declaration.description || '',\n });\n }\n }\n }\n \n this.availableComponents = components;\n } catch (error) {\n console.warn('[le-slot] Failed to load component manifest:', error);\n }\n }\n\n /**\n * Format a tag name into a display name\n * e.g., 'le-card' -> 'Card'\n */\n private formatComponentName(tagName: string): string {\n return tagName\n .replace(/^le-/, '')\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n }\n\n /**\n * Add a new component to the slot\n */\n private addComponent(tagName: string) {\n // Find the host component by traversing up through shadow DOM\n const rootNode = this.el.getRootNode();\n if (!(rootNode instanceof ShadowRoot)) return;\n \n const hostComponent = rootNode.host;\n if (!hostComponent) return;\n \n // Create the new component element\n const newElement = document.createElement(tagName);\n \n // Set the slot attribute if this is a named slot\n if (this.name) {\n newElement.setAttribute('slot', this.name);\n }\n \n // Append to the host component's light DOM\n hostComponent.appendChild(newElement);\n \n // Emit change event so the page can save\n this.leSlotChange.emit({\n name: this.name,\n value: hostComponent.innerHTML,\n isValid: true,\n });\n }\n\n /**\n * Handle slot change event to re-read content when nodes are assigned\n */\n private handleSlotChange = () => {\n this.readSlottedContent();\n };\n\n render() {\n const displayLabel = this.label || this.name;\n\n // Always render the same structure, CSS handles visibility via .admin-mode class\n return (\n <Host\n class={{ \n 'admin-mode': this.adminMode,\n 'invalid-html': !this.isValidHtml \n }}\n role={this.adminMode ? 'region' : undefined}\n aria-label={this.adminMode ? `Slot: ${displayLabel}` : undefined}\n data-slot-name={this.name}\n data-slot-type={this.type}\n data-allowed={this.allowedComponents}\n data-multiple={this.multiple}\n data-required={this.required}\n >\n {this.adminMode ? (\n <div class=\"le-slot-container\">\n <div class={classnames('le-slot-header', {\n 'le-slot-header-no-label': !displayLabel,\n 'le-slot-header-text': this.type === 'text',\n 'le-slot-header-error': !this.isValidHtml\n })}>\n {displayLabel && (\n <span class=\"le-slot-label\">\n {displayLabel}\n {this.required && <span class=\"le-slot-required\">*</span>}\n </span>\n )}\n {/* {this.description && <le-popover mode=\"default\" showClose={false} align=\"end\" position=\"bottom\">\n <span slot=\"trigger\" class=\"le-slot-description-icon\">ℹ️</span>\n {this.description}\n </le-popover>} */}\n {!this.isValidHtml && <span class=\"le-slot-invalid\">⚠ Invalid HTML</span>}\n {this.type === 'slot' && this.adminMode && (\n <le-popover \n mode=\"default\"\n showClose={true}\n align=\"start\"\n position=\"right\"\n popoverTitle=\"Add Component\"\n open={this.pickerOpen}\n onLePopoverOpen={() => this.pickerOpen = true}\n onLePopoverClose={() => this.pickerOpen = false}\n >\n <le-button\n type=\"button\"\n class=\"le-slot-button\"\n slot=\"trigger\"\n variant=\"clear\"\n size=\"small\"\n aria-label=\"Add component\"\n icon-only\n >\n <span class=\"le-slot-add-btn\" slot=\"icon-only\">+</span>\n </le-button>\n <div class=\"le-slot-picker\">\n {this.availableComponents.length > 0 ? (\n <ul class=\"le-slot-picker-list\">\n {this.availableComponents.map(component => (\n <li key={component.tagName}>\n <button\n class=\"le-slot-picker-item\"\n onClick={() => {\n this.addComponent(component.tagName);\n this.pickerOpen = false;\n }}\n >\n <span class=\"le-slot-picker-name\">{component.name}</span>\n {component.description && (\n <span class=\"le-slot-picker-desc\">{component.description}</span>\n )}\n </button>\n </li>\n ))}\n </ul>\n ) : (\n <div class=\"le-slot-picker-empty\">No components available</div>\n )}\n </div>\n </le-popover>\n )}\n </div>\n {this.renderContent()}\n </div>\n ) : (\n // In default mode, just pass through the slot - slotted content renders naturally\n // Note: We use unnamed slot here because named slots from parent component\n // are passed as le-slot's light DOM children\n <slot \n // ref={(el) => this.slotRef = el as HTMLSlotElement}\n // onSlotchange={this.handleSlotChange}\n ></slot>\n )}\n </Host>\n );\n }\n\n private renderContent() {\n // Create the slot element with ref for reading assignedNodes\n // Wrap in a hidden div since slot elements can't have style prop in Stencil\n // Note: We use unnamed slot here because named slots from parent component\n // are passed as le-slot's light DOM children\n const slotElement = (\n <div class=\"hidden-slot\">\n <slot \n ref={(el) => this.slotRef = el as HTMLSlotElement}\n onSlotchange={this.handleSlotChange}\n ></slot>\n </div>\n );\n\n switch (this.type) {\n case 'text':\n return (\n <div class={{ 'le-slot-input': true, 'has-error': !this.isValidHtml }}>\n <le-string-input\n mode=\"default\"\n value={this.textValue}\n placeholder={this.placeholder || `Enter ${this.label || this.name || 'text'}...`}\n onChange={this.handleTextInput}\n // required={this.required}\n ></le-string-input>\n {slotElement}\n </div>\n );\n\n case 'textarea':\n return (\n <div class={{ 'le-slot-input': true, 'has-error': !this.isValidHtml }}>\n <textarea\n value={this.textValue}\n placeholder={this.placeholder || `Enter ${this.label || this.name || 'text'}...`}\n onInput={this.handleTextInput}\n required={this.required}\n rows={3}\n ></textarea>\n {slotElement}\n </div>\n );\n\n case 'slot':\n default:\n // Parse slotStyle string into style object if provided\n const dropzoneStyle: { [key: string]: string } = {};\n if (this.slotStyle) {\n this.slotStyle.split(';').forEach(rule => {\n const [prop, value] = rule.split(':').map(s => s.trim());\n if (prop && value) {\n // Convert kebab-case to camelCase for style object\n const camelProp = prop.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n dropzoneStyle[camelProp] = value;\n }\n });\n }\n return (\n <div class=\"le-slot-dropzone\" style={dropzoneStyle}>\n <slot \n ref={(el) => this.slotRef = el as HTMLSlotElement}\n onSlotchange={this.handleSlotChange}\n ></slot>\n </div>\n );\n }\n }\n}\n\n/**\n * Component info from the manifest\n */\ninterface ComponentInfo {\n tagName: string;\n name: string;\n description: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"le-slot.js","sourceRoot":"","sources":["../../../src/components/le-slot/le-slot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;;;;;;GAYG;AAOH,MAAM,OAAO,MAAM;IACN,EAAE,CAAc;IAE3B;;;;;OAKG;IACK,IAAI,GAAiC,MAAM,CAAC;IAEpD;;;OAGG;IACK,IAAI,GAAW,EAAE,CAAC;IAE1B;;;OAGG;IACK,KAAK,CAAU;IAEvB;;;OAGG;IACK,WAAW,CAAU;IAE7B;;;;;OAKG;IACK,iBAAiB,CAAU;IAEnC;;OAEG;IACK,QAAQ,GAAY,IAAI,CAAC;IAEjC;;OAEG;IACK,QAAQ,GAAY,KAAK,CAAC;IAElC;;OAEG;IACK,WAAW,CAAU;IAE7B;;;;;;OAMG;IACK,GAAG,CAAU;IAErB;;;;OAIG;IACK,SAAS,CAAU;IAE3B;;OAEG;IACc,SAAS,GAAY,KAAK,CAAC;IAE5C;;OAEG;IACc,SAAS,GAAW,EAAE,CAAC;IAExC;;OAEG;IACc,WAAW,GAAY,IAAI,CAAC;IAE7C;;OAEG;IACc,mBAAmB,GAAoB,EAAE,CAAC;IAE3D;;OAEG;IACc,UAAU,GAAY,KAAK,CAAC;IAE7C;;OAEG;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C;wBACnC,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,CACL,WAAK,KAAK,EAAC,kBAAkB,EAAC,KAAK,EAAE,aAAa;oBAChD,YAAM,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,EAAqB,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,gBAAgB,GAAS,CACjG,CACP,CAAC;QACN,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h, Host, Element, Event, EventEmitter, getAssetPath } from '@stencil/core';\nimport { classnames, observeModeChanges } from '../../utils/utils';\n\n/**\n * Slot placeholder component for admin/CMS mode.\n *\n * This component renders a visual placeholder for slots when in admin mode,\n * allowing CMS systems to show available drop zones for content or inline editing.\n *\n * In non-admin mode, this component renders nothing and acts as a passthrough.\n *\n * @slot - Default slot for placeholder content or drop zone UI\n *\n * @cmsInternal true\n * @cmsCategory System\n */\n@Component({\n tag: 'le-slot',\n styleUrl: 'le-slot.default.css',\n shadow: true,\n assetsDirs: ['../../assets'],\n})\nexport class LeSlot {\n @Element() el: HTMLElement;\n\n /**\n * The type of slot content.\n * - `slot`: Default, shows a dropzone for components (default)\n * - `text`: Shows a single-line text input\n * - `textarea`: Shows a multi-line text area\n */\n @Prop() type: 'slot' | 'text' | 'textarea' = 'slot';\n\n /**\n * The name of the slot this placeholder represents.\n * Should match the slot name in the parent component.\n */\n @Prop() name: string = '';\n\n /**\n * Label to display in admin mode.\n * If not provided, the slot name will be used.\n */\n @Prop() label?: string;\n\n /**\n * Description of what content this slot accepts.\n * Shown in admin mode to guide content editors.\n */\n @Prop() description?: string;\n\n /**\n * Comma-separated list of allowed component tags for this slot.\n * Used by CMS to filter available components.\n *\n * @example \"le-card,le-button,le-text\"\n */\n @Prop() allowedComponents?: string;\n\n /**\n * Whether multiple components can be dropped in this slot.\n */\n @Prop() multiple: boolean = true;\n\n /**\n * Whether this slot is required to have content.\n */\n @Prop() required: boolean = false;\n\n /**\n * Placeholder text for text/textarea inputs in admin mode.\n */\n @Prop() placeholder?: string;\n\n /**\n * The HTML tag to create when there's no slotted element.\n * Used with type=\"text\" or type=\"textarea\" to auto-create elements.\n *\n * @example \"h3\" - creates <h3 slot=\"header\">content</h3>\n * @example \"p\" - creates <p slot=\"content\">content</p>\n */\n @Prop() tag?: string;\n\n /**\n * CSS styles for the slot dropzone container.\n * Useful for layouts - e.g., \"flex-direction: row\" for horizontal stacks.\n * Only applies in admin mode for type=\"slot\".\n */\n @Prop() slotStyle?: string;\n\n /**\n * Internal state to track admin mode\n */\n @State() private adminMode: boolean = false;\n\n /**\n * Internal state for text input value (synced from slot content)\n */\n @State() private textValue: string = '';\n\n /**\n * Whether the current textValue contains valid HTML\n */\n @State() private isValidHtml: boolean = true;\n\n /**\n * Available components loaded from Custom Elements Manifest\n */\n @State() private availableComponents: ComponentInfo[] = [];\n\n /**\n * Whether the component picker popover is open\n */\n @State() private pickerOpen: boolean = false;\n\n /**\n * Reference to the slot element to access assignedNodes\n */\n private slotRef?: HTMLSlotElement;\n\n /**\n * The original slotted element (e.g., <h3 slot=\"header\">)\n */\n private slottedElement?: Element;\n\n /**\n * Emitted when text content changes in admin mode.\n * The event detail contains the new text value and validity.\n */\n @Event() leSlotChange: EventEmitter<{ name: string; value: string; isValid: boolean }>;\n\n private disconnectModeObserver?: () => void;\n\n connectedCallback() {\n this.disconnectModeObserver = observeModeChanges(this.el, mode => {\n const wasAdmin = this.adminMode;\n this.adminMode = mode === 'admin';\n\n // When entering admin mode, read content from slotted elements\n if (this.adminMode && !wasAdmin) {\n // Need to wait for render to access slot ref\n requestAnimationFrame(() => this.readSlottedContent());\n\n // Load available components for the component picker\n if (this.type === 'slot') {\n this.loadAvailableComponents();\n }\n }\n });\n }\n\n disconnectedCallback() {\n this.disconnectModeObserver?.();\n }\n\n /**\n * Flag to prevent re-reading content right after we updated it\n */\n private isUpdating: boolean = false;\n\n /**\n * Read content from slotted elements via assignedNodes()\n */\n private readSlottedContent() {\n if (!this.slotRef) return;\n\n // Skip if we just updated the content ourselves\n if (this.isUpdating) {\n this.isUpdating = false;\n return;\n }\n\n const assignedNodes = this.slotRef.assignedNodes({ flatten: true });\n\n // For text/textarea types, we want to edit the innerHTML of slotted elements\n if (this.type === 'text' || this.type === 'textarea') {\n // Find the first element node (skip text nodes that are just whitespace)\n const elementNode = assignedNodes.find(node => node.nodeType === Node.ELEMENT_NODE) as Element | undefined;\n\n if (elementNode) {\n // Only update textValue if slotted element changed or we don't have one yet\n if (this.slottedElement !== elementNode) {\n this.slottedElement = elementNode;\n this.textValue = elementNode.innerHTML?.trim() || '';\n // console.log(`[le-slot \"${this.name}\"] Read slotted content:`, this.textValue);\n }\n } else {\n // No element, check for direct text content\n const textContent = assignedNodes\n .filter(node => node.nodeType === Node.TEXT_NODE)\n .map(node => node.textContent)\n .join('')\n .trim();\n\n if (textContent && !this.textValue) {\n this.textValue = textContent;\n // console.log(`[le-slot \"${this.name}\"] Read text content:`, this.textValue);\n }\n }\n }\n }\n\n /**\n * Validates if a string contains valid HTML\n */\n private validateHtml(html: string): boolean {\n // Empty string is valid\n if (!html.trim()) return true;\n\n // Create a template element to parse the HTML\n const template = document.createElement('template');\n template.innerHTML = html;\n\n // Check that we don't have obviously broken HTML\n // Count opening and closing tags for common elements\n const openTags = (html.match(/<[a-z][^>]*(?<!\\/)>/gi) || []).length;\n const closeTags = (html.match(/<\\/[a-z][^>]*>/gi) || []).length;\n const selfClosing = (html.match(/<[a-z][^>]*\\/>/gi) || []).length;\n\n // Simple validation: opening tags (minus self-closing) should roughly match closing tags\n // Allow some tolerance for void elements like <br>, <img>, etc.\n const voidElements = (html.match(/<(br|hr|img|input|meta|link|area|base|col|embed|param|source|track|wbr)[^>]*>/gi) || []).length;\n\n const effectiveOpenTags = openTags - selfClosing - voidElements;\n\n // If difference is too large, HTML is likely broken\n if (Math.abs(effectiveOpenTags - closeTags) > 1) {\n return false;\n }\n\n return true;\n }\n\n private handleTextInput = (event: Event) => {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n this.textValue = target.value;\n this.isValidHtml = this.validateHtml(this.textValue);\n\n if (this.isValidHtml) {\n // Set flag to prevent slotchange from re-reading what we just wrote\n this.isUpdating = true;\n\n console.log('Updating text value:', this.textValue, 'slottedElement:', this.slottedElement);\n\n if (this.slottedElement) {\n // Update existing slotted element's innerHTML\n this.slottedElement.innerHTML = this.textValue;\n } else if (this.tag && this.textValue) {\n // No slotted element exists\n // If the slot doesn't have a name, then it's the default slot\n // remove the existing non-slotted content (text nodes and elements without slot attribute)\n const rootNode = this.el.getRootNode();\n if (!this.name && rootNode instanceof ShadowRoot) {\n const hostComponent = rootNode.host;\n Array.from(hostComponent.childNodes).forEach(node => {\n if (node.nodeType === Node.TEXT_NODE || (node.nodeType === Node.ELEMENT_NODE && !(node as Element).hasAttribute('slot'))) {\n node.remove();\n }\n });\n }\n // create one using the specified tag\n this.createSlottedElement();\n } else if (this.textValue) {\n // no tag specified - just replace everything in the host component\n const rootNode = this.el.getRootNode();\n if (rootNode instanceof ShadowRoot) {\n const hostComponent = rootNode.host;\n hostComponent.innerHTML = this.textValue;\n }\n }\n }\n\n this.leSlotChange.emit({\n name: this.name,\n value: this.textValue,\n isValid: this.isValidHtml,\n });\n };\n\n /**\n * Create a new slotted element when none exists.\n * The element is appended to the host component's light DOM.\n */\n private createSlottedElement() {\n if (!this.tag) return;\n\n // Find the host component (le-card, etc.) by traversing up through shadow DOM\n // le-slot is inside le-card's shadow DOM, so we need to find le-card's host\n const rootNode = this.el.getRootNode();\n if (!(rootNode instanceof ShadowRoot)) return;\n\n const hostComponent = rootNode.host;\n if (!hostComponent) return;\n\n // Create the new element\n const newElement = document.createElement(this.tag);\n newElement.innerHTML = this.textValue;\n\n // Set the slot attribute if this is a named slot\n if (this.name) {\n newElement.setAttribute('slot', this.name);\n }\n\n // Append to the host component's light DOM\n hostComponent.appendChild(newElement);\n\n // Store reference to the new element\n this.slottedElement = newElement;\n\n // console.log(`[le-slot \"${this.name}\"] Created new <${this.tag}> element`);\n }\n\n /**\n * Load available components from Custom Elements Manifest\n */\n private async loadAvailableComponents() {\n try {\n const manifestPath = getAssetPath('assets/custom-elements.json');\n const response = await fetch(manifestPath);\n const manifest = await response.json();\n\n const components: ComponentInfo[] = [];\n const allowedList = this.allowedComponents?.split(',').map(s => s.trim()) || [];\n\n for (const module of manifest.modules) {\n for (const declaration of module.declarations || []) {\n if (declaration.tagName && declaration.customElement) {\n // Skip internal components (le-slot, le-component, le-popover)\n const isInternal = ['le-slot', 'le-component', 'le-popover'].includes(declaration.tagName);\n if (isInternal) continue;\n\n // If allowedComponents is specified, filter by it\n if (allowedList.length > 0 && !allowedList.includes(declaration.tagName)) {\n continue;\n }\n\n components.push({\n tagName: declaration.tagName,\n name: this.formatComponentName(declaration.tagName),\n description: declaration.description || '',\n });\n }\n }\n }\n\n this.availableComponents = components || [];\n } catch (error) {\n console.warn('[le-slot] Failed to load component manifest:', error);\n }\n }\n\n /**\n * Format a tag name into a display name\n * e.g., 'le-card' -> 'Card'\n */\n private formatComponentName(tagName: string): string {\n return tagName\n .replace(/^le-/, '')\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n }\n\n /**\n * Add a new component to the slot\n */\n private addComponent(tagName: string) {\n // Find the host component by traversing up through shadow DOM\n const rootNode = this.el.getRootNode();\n if (!(rootNode instanceof ShadowRoot)) return;\n\n const hostComponent = rootNode.host;\n if (!hostComponent) return;\n\n // Create the new component element\n const newElement = document.createElement(tagName);\n\n // Set the slot attribute if this is a named slot\n if (this.name) {\n newElement.setAttribute('slot', this.name);\n }\n\n // Append to the host component's light DOM\n hostComponent.appendChild(newElement);\n\n // Emit change event so the page can save\n this.leSlotChange.emit({\n name: this.name,\n value: hostComponent.innerHTML,\n isValid: true,\n });\n }\n\n /**\n * Handle slot change event to re-read content when nodes are assigned\n */\n private handleSlotChange = () => {\n this.readSlottedContent();\n };\n\n render() {\n const displayLabel = this.label || this.name;\n\n // Always render the same structure, CSS handles visibility via .admin-mode class\n return (\n <Host\n class={{\n 'admin-mode': this.adminMode,\n 'invalid-html': !this.isValidHtml,\n }}\n role={this.adminMode ? 'region' : undefined}\n aria-label={this.adminMode ? `Slot: ${displayLabel}` : undefined}\n data-slot-name={this.name}\n data-slot-type={this.type}\n data-allowed={this.allowedComponents}\n data-multiple={this.multiple}\n data-required={this.required}\n >\n {this.adminMode ? (\n <div class=\"le-slot-container\">\n <div\n class={classnames('le-slot-header', {\n 'le-slot-header-no-label': !displayLabel,\n 'le-slot-header-text': this.type === 'text',\n 'le-slot-header-error': !this.isValidHtml,\n })}\n >\n {displayLabel && (\n <span class=\"le-slot-label\">\n {displayLabel}\n {this.required && <span class=\"le-slot-required\">*</span>}\n </span>\n )}\n {/* {this.description && <le-popover mode=\"default\" showClose={false} align=\"end\" position=\"bottom\">\n <span slot=\"trigger\" class=\"le-slot-description-icon\">ℹ️</span>\n {this.description}\n </le-popover>} */}\n {!this.isValidHtml && <span class=\"le-slot-invalid\">⚠ Invalid HTML</span>}\n {this.type === 'slot' && this.adminMode && (\n <le-popover\n mode=\"default\"\n showClose={true}\n align=\"start\"\n position=\"right\"\n popoverTitle=\"Add Component\"\n open={this.pickerOpen}\n onLePopoverOpen={() => (this.pickerOpen = true)}\n onLePopoverClose={() => (this.pickerOpen = false)}\n >\n <le-button type=\"button\" class=\"le-slot-button\" slot=\"trigger\" variant=\"clear\" size=\"small\" aria-label=\"Add component\" icon-only>\n <span class=\"le-slot-add-btn\" slot=\"icon-only\">\n +\n </span>\n </le-button>\n <div class=\"le-slot-picker\">\n {this.availableComponents.length > 0 ? (\n <ul class=\"le-slot-picker-list\">\n {this.availableComponents.map(component => (\n <li key={component.tagName}>\n <button\n class=\"le-slot-picker-item\"\n onClick={() => {\n this.addComponent(component.tagName);\n this.pickerOpen = false;\n }}\n >\n <span class=\"le-slot-picker-name\">{component.name}</span>\n {component.description && <span class=\"le-slot-picker-desc\">{component.description}</span>}\n </button>\n </li>\n ))}\n </ul>\n ) : (\n <div class=\"le-slot-picker-empty\">No components available</div>\n )}\n </div>\n </le-popover>\n )}\n </div>\n {this.renderContent()}\n </div>\n ) : (\n // In default mode, just pass through the slot - slotted content renders naturally\n // Note: We use unnamed slot here because named slots from parent component\n // are passed as le-slot's light DOM children\n <slot\n // ref={(el) => this.slotRef = el as HTMLSlotElement}\n // onSlotchange={this.handleSlotChange}\n ></slot>\n )}\n </Host>\n );\n }\n\n private renderContent() {\n // Create the slot element with ref for reading assignedNodes\n // Wrap in a hidden div since slot elements can't have style prop in Stencil\n // Note: We use unnamed slot here because named slots from parent component\n // are passed as le-slot's light DOM children\n const slotElement = (\n <div class=\"hidden-slot\">\n <slot ref={el => (this.slotRef = el as HTMLSlotElement)} onSlotchange={this.handleSlotChange}></slot>\n </div>\n );\n\n switch (this.type) {\n case 'text':\n return (\n <div class={{ 'le-slot-input': true, 'has-error': !this.isValidHtml }}>\n <le-string-input\n mode=\"default\"\n value={this.textValue}\n placeholder={this.placeholder || `Enter ${this.label || this.name || 'text'}...`}\n onChange={this.handleTextInput}\n // required={this.required}\n ></le-string-input>\n {slotElement}\n </div>\n );\n\n case 'textarea':\n return (\n <div class={{ 'le-slot-input': true, 'has-error': !this.isValidHtml }}>\n <textarea\n value={this.textValue}\n placeholder={this.placeholder || `Enter ${this.label || this.name || 'text'}...`}\n onInput={this.handleTextInput}\n required={this.required}\n rows={3}\n ></textarea>\n {slotElement}\n </div>\n );\n\n case 'slot':\n default:\n // Parse slotStyle string into style object if provided\n const dropzoneStyle: { [key: string]: string } = {};\n if (this.slotStyle) {\n this.slotStyle.split(';').forEach(rule => {\n const [prop, value] = rule.split(':').map(s => s.trim());\n if (prop && value) {\n // Convert kebab-case to camelCase for style object\n const camelProp = prop.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n dropzoneStyle[camelProp] = value;\n }\n });\n }\n return (\n <div class=\"le-slot-dropzone\" style={dropzoneStyle}>\n <slot ref={el => (this.slotRef = el as HTMLSlotElement)} onSlotchange={this.handleSlotChange}></slot>\n </div>\n );\n }\n }\n}\n\n/**\n * Component info from the manifest\n */\ninterface ComponentInfo {\n tagName: string;\n name: string;\n description: string;\n}\n"]}
|