le-kit 0.3.2 → 0.3.4
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-CNRmviSz.js → index-BPF04Jvb.js} +30 -19
- package/dist/cjs/index-BPF04Jvb.js.map +1 -0
- package/dist/cjs/index.cjs.js +3 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/le-bar_16.cjs.entry.js +20 -6
- package/dist/cjs/le-box.cjs.entry.js +2 -2
- package/dist/cjs/le-card.cjs.entry.js +2 -2
- package/dist/cjs/le-combobox.cjs.entry.js +1 -1
- package/dist/cjs/le-header-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/le-kit.cjs.js +1 -1
- package/dist/cjs/le-multiselect.cjs.entry.js +1 -1
- package/dist/cjs/le-number-input.cjs.entry.js +2 -2
- package/dist/cjs/le-round-progress.cjs.entry.js +1 -1
- package/dist/cjs/le-segmented-control.cjs.entry.js +1 -1
- package/dist/cjs/le-stack.cjs.entry.js +2 -2
- package/dist/cjs/le-tab-bar.cjs.entry.js +1 -1
- package/dist/cjs/le-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/le-tab.cjs.entry.js +2 -2
- package/dist/cjs/le-tabs.cjs.entry.js +2 -2
- package/dist/cjs/le-tag.cjs.entry.js +1 -1
- 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-CZG22_vQ.js → utils-BYsLPHN1.js} +3 -3
- package/dist/cjs/{utils-CZG22_vQ.js.map → utils-BYsLPHN1.js.map} +1 -1
- package/dist/collection/components/le-icon/le-icon.js +19 -4
- package/dist/collection/components/le-icon/le-icon.js.map +1 -1
- package/dist/collection/dist/components/assets/custom-elements.json +825 -825
- package/dist/collection/global/app.js +27 -17
- package/dist/collection/global/app.js.map +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/components/app.js +180 -0
- package/dist/components/app.js.map +1 -0
- package/dist/components/assets/custom-elements.json +825 -825
- package/dist/components/index.js +3 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/le-bar2.js +1 -1
- package/dist/components/le-box.js +1 -1
- package/dist/components/le-button2.js +2 -1
- package/dist/components/le-button2.js.map +1 -1
- package/dist/components/le-card.js +1 -1
- package/dist/components/le-header.js +1 -1
- package/dist/components/le-icon2.js +19 -4
- package/dist/components/le-icon2.js.map +1 -1
- package/dist/components/le-navigation.js +1 -1
- package/dist/components/le-number-input.js +1 -1
- package/dist/components/le-popover2.js +1 -1
- package/dist/components/le-stack.js +1 -1
- package/dist/components/le-tab2.js +1 -1
- package/dist/components/le-tabs.js +1 -1
- package/dist/components/utils.js +2 -166
- package/dist/components/utils.js.map +1 -1
- package/dist/docs.json +1 -1
- package/dist/esm/{index-BqH-zsXr.js → index-C-Chwj1b.js} +30 -20
- package/dist/esm/index-C-Chwj1b.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/le-bar_16.entry.js +20 -6
- package/dist/esm/le-box.entry.js +2 -2
- package/dist/esm/le-card.entry.js +2 -2
- package/dist/esm/le-combobox.entry.js +1 -1
- package/dist/esm/le-header-placeholder.entry.js +1 -1
- package/dist/esm/le-kit.js +2 -2
- package/dist/esm/le-multiselect.entry.js +1 -1
- package/dist/esm/le-number-input.entry.js +2 -2
- package/dist/esm/le-round-progress.entry.js +1 -1
- package/dist/esm/le-segmented-control.entry.js +1 -1
- package/dist/esm/le-stack.entry.js +2 -2
- package/dist/esm/le-tab-bar.entry.js +1 -1
- package/dist/esm/le-tab-panel.entry.js +1 -1
- package/dist/esm/le-tab.entry.js +2 -2
- package/dist/esm/le-tabs.entry.js +2 -2
- package/dist/esm/le-tag.entry.js +1 -1
- 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-CdBk0DdF.js → utils-B3alHV04.js} +3 -3
- package/dist/esm/{utils-CdBk0DdF.js.map → utils-B3alHV04.js.map} +1 -1
- package/dist/le-kit/dist/components/assets/custom-elements.json +825 -825
- package/dist/le-kit/index.esm.js +1 -1
- package/dist/le-kit/le-kit.esm.js +1 -1
- package/dist/le-kit/{p-0a270831.entry.js → p-05ccab91.entry.js} +2 -2
- package/dist/le-kit/{p-ebd86d4f.entry.js → p-06d2d79c.entry.js} +2 -2
- package/dist/le-kit/{p-764005e3.entry.js → p-2230ecd7.entry.js} +2 -2
- package/dist/le-kit/{p-b21277e8.entry.js → p-33c2168a.entry.js} +2 -2
- package/dist/le-kit/{p-249db213.entry.js → p-3d22aeb2.entry.js} +2 -2
- package/dist/le-kit/{p-3a0a57e9.entry.js → p-3d873cdb.entry.js} +2 -2
- package/dist/le-kit/{p-ac822433.entry.js → p-4a45ff67.entry.js} +2 -2
- package/dist/le-kit/{p-43f87acb.entry.js → p-5d72c894.entry.js} +2 -2
- package/dist/le-kit/{p-b6997587.entry.js → p-68d836a3.entry.js} +2 -2
- package/dist/le-kit/{p-6d0090c1.entry.js → p-923828fe.entry.js} +2 -2
- package/dist/le-kit/p-9880466c.entry.js +2 -0
- package/dist/le-kit/p-9880466c.entry.js.map +1 -0
- package/dist/le-kit/p-C-Chwj1b.js +3 -0
- package/dist/le-kit/p-C-Chwj1b.js.map +1 -0
- package/dist/le-kit/{p-VG5nXRzT.js → p-DFr88Szp.js} +2 -2
- package/dist/le-kit/{p-VG5nXRzT.js.map → p-DFr88Szp.js.map} +1 -1
- package/dist/le-kit/{p-244ff3d7.entry.js → p-be2a7276.entry.js} +2 -2
- package/dist/le-kit/{p-61edb398.entry.js → p-d161946c.entry.js} +2 -2
- package/dist/le-kit/{p-c0ccc9aa.entry.js → p-e1846fc2.entry.js} +2 -2
- package/dist/le-kit/{p-07705c61.entry.js → p-e6b2cf9a.entry.js} +2 -2
- package/dist/le-kit/{p-4b88b0da.entry.js → p-ea71f22c.entry.js} +2 -2
- package/dist/le-kit/{p-73f7de28.entry.js → p-f8034500.entry.js} +2 -2
- package/dist/types/global/app.d.ts +29 -6
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-CNRmviSz.js.map +0 -1
- package/dist/esm/index-BqH-zsXr.js.map +0 -1
- package/dist/le-kit/p-BqH-zsXr.js +0 -3
- package/dist/le-kit/p-BqH-zsXr.js.map +0 -1
- package/dist/le-kit/p-dea78542.entry.js +0 -2
- package/dist/le-kit/p-dea78542.entry.js.map +0 -1
- /package/dist/le-kit/{p-0a270831.entry.js.map → p-05ccab91.entry.js.map} +0 -0
- /package/dist/le-kit/{p-ebd86d4f.entry.js.map → p-06d2d79c.entry.js.map} +0 -0
- /package/dist/le-kit/{p-764005e3.entry.js.map → p-2230ecd7.entry.js.map} +0 -0
- /package/dist/le-kit/{p-b21277e8.entry.js.map → p-33c2168a.entry.js.map} +0 -0
- /package/dist/le-kit/{p-249db213.entry.js.map → p-3d22aeb2.entry.js.map} +0 -0
- /package/dist/le-kit/{p-3a0a57e9.entry.js.map → p-3d873cdb.entry.js.map} +0 -0
- /package/dist/le-kit/{p-ac822433.entry.js.map → p-4a45ff67.entry.js.map} +0 -0
- /package/dist/le-kit/{p-43f87acb.entry.js.map → p-5d72c894.entry.js.map} +0 -0
- /package/dist/le-kit/{p-b6997587.entry.js.map → p-68d836a3.entry.js.map} +0 -0
- /package/dist/le-kit/{p-6d0090c1.entry.js.map → p-923828fe.entry.js.map} +0 -0
- /package/dist/le-kit/{p-244ff3d7.entry.js.map → p-be2a7276.entry.js.map} +0 -0
- /package/dist/le-kit/{p-61edb398.entry.js.map → p-d161946c.entry.js.map} +0 -0
- /package/dist/le-kit/{p-c0ccc9aa.entry.js.map → p-e1846fc2.entry.js.map} +0 -0
- /package/dist/le-kit/{p-07705c61.entry.js.map → p-e6b2cf9a.entry.js.map} +0 -0
- /package/dist/le-kit/{p-4b88b0da.entry.js.map → p-ea71f22c.entry.js.map} +0 -0
- /package/dist/le-kit/{p-73f7de28.entry.js.map → p-f8034500.entry.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$2, a as defineCustomElement$3, b as defineCustomElement$4, c as defineCustomElement$5, e as defineCustomElement$8, f as defineCustomElement$9, g as defineCustomElement$a } from './le-button2.js';
|
|
4
4
|
import { d as defineCustomElement$7 } from './le-dropdown-base2.js';
|
|
5
5
|
import { d as defineCustomElement$6 } from './le-popover2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$2, a as defineCustomElement$3, b as defineCustomElement$4, c as defineCustomElement$5, e as defineCustomElement$8, f as defineCustomElement$9, g as defineCustomElement$a } from './le-button2.js';
|
|
4
4
|
import { d as defineCustomElement$7 } from './le-dropdown-base2.js';
|
|
5
5
|
import { d as defineCustomElement$6 } from './le-popover2.js';
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, Build, h, transformTag, getAssetPath } from '@stencil/core/internal/client';
|
|
2
|
+
import { e as getAssetBasePath } from './app.js';
|
|
2
3
|
|
|
3
4
|
const leIconCss = () => `:host{display:inline-block;width:var(--le-icon-size, var(--le-size-4));height:var(--le-icon-size, var(--le-size-4));color:var(--le-icon-color, var(--le-color-text-primary))}:host svg{display:block;fill:currentColor}`;
|
|
4
5
|
|
|
5
6
|
const iconCache = {};
|
|
6
7
|
const requestCache = {};
|
|
8
|
+
/**
|
|
9
|
+
* Get the URL for loading an icon.
|
|
10
|
+
* Uses configurable assetBasePath if set, otherwise falls back to Stencil's getAssetPath.
|
|
11
|
+
*/
|
|
12
|
+
function getIconUrl(name) {
|
|
13
|
+
const basePath = getAssetBasePath();
|
|
14
|
+
if (basePath) {
|
|
15
|
+
// Use configured base path - normalize by removing trailing slash
|
|
16
|
+
const normalizedBase = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
|
17
|
+
return `${normalizedBase}/icons/${name}.json`;
|
|
18
|
+
}
|
|
19
|
+
// Fall back to Stencil's getAssetPath for local development
|
|
20
|
+
return getAssetPath(`./assets/icons/${name}.json`);
|
|
21
|
+
}
|
|
7
22
|
async function fetchIcon({ name }) {
|
|
8
23
|
if (iconCache[name]) {
|
|
9
24
|
return iconCache[name];
|
|
10
25
|
}
|
|
11
26
|
if (!requestCache[name]) {
|
|
12
|
-
|
|
13
|
-
requestCache[name] = fetch(
|
|
27
|
+
const iconUrl = getIconUrl(name);
|
|
28
|
+
requestCache[name] = fetch(iconUrl)
|
|
14
29
|
.then(resp => resp.json())
|
|
15
30
|
.catch(() => {
|
|
16
|
-
console.error(`"${name}"
|
|
31
|
+
console.error(`Icon "${name}" could not be loaded from: ${iconUrl}`);
|
|
17
32
|
return '';
|
|
18
33
|
});
|
|
19
34
|
}
|
|
@@ -100,7 +115,7 @@ const LeIcon = /*@__PURE__*/ proxyCustomElement(class LeIcon extends HTMLElement
|
|
|
100
115
|
return svgElements;
|
|
101
116
|
}
|
|
102
117
|
render() {
|
|
103
|
-
return (h("svg", { key: '
|
|
118
|
+
return (h("svg", { key: '0518b0d454e3f3f171413a8b7f03ea89f6f48c0b', xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", height: this.size || 16, width: this.size || 16, viewBox: this.iconData?.viewBox || `0 0 ${this.size || 16} ${this.size || 16}` }, this.renderSVGContent(this.iconData?.children)));
|
|
104
119
|
}
|
|
105
120
|
static get assetsDirs() { return ["assets/icons"]; }
|
|
106
121
|
static get watchers() { return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"le-icon2.js","mappings":"
|
|
1
|
+
{"file":"le-icon2.js","m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/le-icon.css?tag=le-icon&encapsulation=shadow","src/components/le-icon/le-icon.tsx"],"sourcesContent":[":host {\n display: inline-block;\n\n width: var(--le-icon-size, var(--le-size-4));\n height: var(--le-icon-size, var(--le-size-4));\n\n color: var(--le-icon-color, var(--le-color-text-primary));\n}\n\n:host svg {\n display: block;\n fill: currentColor;\n}\n","/**\n * Based on the script from Paul Andreson's article:\n * https://paulcpederson.com/articles/stencil-icons/\n */\nimport { Build, Component, Element, getAssetPath, h, Prop, State, Watch } from '@stencil/core';\nimport { getAssetBasePath } from '../../global/app';\n\nconst iconCache: Record<string, any> = {};\nconst requestCache: Record<string, Promise<any>> = {};\n\n/**\n * Get the URL for loading an icon.\n * Uses configurable assetBasePath if set, otherwise falls back to Stencil's getAssetPath.\n */\nfunction getIconUrl(name: string): string {\n const basePath = getAssetBasePath();\n if (basePath) {\n // Use configured base path - normalize by removing trailing slash\n const normalizedBase = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n return `${normalizedBase}/icons/${name}.json`;\n }\n // Fall back to Stencil's getAssetPath for local development\n return getAssetPath(`./assets/icons/${name}.json`);\n}\n\nasync function fetchIcon({ name }): Promise<string> {\n if (iconCache[name]) {\n return iconCache[name];\n }\n if (!requestCache[name]) {\n const iconUrl = getIconUrl(name);\n requestCache[name] = fetch(iconUrl)\n .then(resp => resp.json())\n .catch(() => {\n console.error(`Icon \"${name}\" could not be loaded from: ${iconUrl}`);\n return '';\n });\n }\n\n const path = await requestCache[name];\n iconCache[name] = path;\n\n return path;\n}\n\n@Component({\n tag: 'le-icon',\n styleUrl: 'le-icon.css',\n shadow: true,\n assetsDirs: ['assets/icons'],\n})\nexport class LeIcon {\n @Element() el: HTMLElement;\n\n /**\n * Name of the icon to display. Corresponds to a JSON file in the assets folder.\n * For example, \"search\" will load the \"search.json\" file.\n */\n @Prop() name: string = null;\n\n /**\n * Size of the icon in pixels. Default is 16.\n */\n @Prop() size: number = 16;\n\n @State() private iconData: any = null;\n\n @State() private visible = false;\n\n @Watch('name') private async loadIconData(): Promise<void> {\n const { name, visible } = this;\n\n if (!Build.isBrowser || !name || !visible) {\n return;\n }\n\n this.iconData = await fetchIcon({ name });\n }\n\n private intersectionObserver: IntersectionObserver;\n\n connectedCallback(): void {\n this.waitUntilVisible(() => {\n this.visible = true;\n this.loadIconData();\n });\n }\n\n disconnectedCallback(): void {\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n this.intersectionObserver = null;\n }\n }\n\n async componentWillLoad(): Promise<void> {\n this.loadIconData();\n }\n\n private waitUntilVisible(callback: () => void): void {\n if (\n !Build.isBrowser ||\n typeof window === 'undefined' ||\n !(window as any).IntersectionObserver\n ) {\n callback();\n return;\n }\n\n this.intersectionObserver = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n this.intersectionObserver.disconnect();\n this.intersectionObserver = null;\n callback();\n }\n });\n },\n { rootMargin: '50px' },\n );\n\n this.intersectionObserver.observe(this.el);\n }\n\n /**\n * Renders the SVG content out of a JSON data in a format:\n * { \"viewBox\": \"...\", children: [{ \"tag\": \"g\", \"\"children\": [ ... ], ...attrs }, ...] }\n *\n * @returns JSX.Element | null\n */\n private renderSVGContent(children?: any[]) {\n if (!children || children.length === 0) {\n return null;\n }\n\n const createElement = node => {\n const { tag, children, ...attrs } = node;\n return h(tag, attrs, children ? children.map(createElement) : null);\n };\n\n const svgElements = children.map(createElement);\n return svgElements;\n }\n\n render() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\"\n height={this.size || 16}\n width={this.size || 16}\n viewBox={this.iconData?.viewBox || `0 0 ${this.size || 16} ${this.size || 16}`}\n >\n {this.renderSVGContent(this.iconData?.children)}\n </svg>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import { g as generateId,
|
|
2
|
+
import { g as generateId, c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$d } from './le-bar2.js';
|
|
4
4
|
import { d as defineCustomElement$2, a as defineCustomElement$3, b as defineCustomElement$4, c as defineCustomElement$5, e as defineCustomElement$9, f as defineCustomElement$b, g as defineCustomElement$c } from './le-button2.js';
|
|
5
5
|
import { d as defineCustomElement$a } from './le-collapse2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$2, a as defineCustomElement$3, b as defineCustomElement$4, c as defineCustomElement$5, e as defineCustomElement$8, f as defineCustomElement$9, g as defineCustomElement$a } from './le-button2.js';
|
|
4
4
|
import { d as defineCustomElement$7 } from './le-dropdown-base2.js';
|
|
5
5
|
import { d as defineCustomElement$6 } from './le-popover2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
|
|
4
4
|
const lePopoverCss = () => `/* ============================================
|
|
5
5
|
le-popover.css
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$2, a as defineCustomElement$3, b as defineCustomElement$4, c as defineCustomElement$5, e as defineCustomElement$8, f as defineCustomElement$9, g as defineCustomElement$a } from './le-button2.js';
|
|
4
4
|
import { d as defineCustomElement$7 } from './le-dropdown-base2.js';
|
|
5
5
|
import { d as defineCustomElement$6 } from './le-popover2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host, Fragment, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$1, a as defineCustomElement$2, b as defineCustomElement$3, c as defineCustomElement$4, e as defineCustomElement$7, f as defineCustomElement$8, g as defineCustomElement$9 } from './le-button2.js';
|
|
4
4
|
import { d as defineCustomElement$6 } from './le-dropdown-base2.js';
|
|
5
5
|
import { d as defineCustomElement$5 } from './le-popover2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, transformTag } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { c as classnames } from './utils.js';
|
|
3
3
|
import { d as defineCustomElement$3, a as defineCustomElement$4, b as defineCustomElement$5, c as defineCustomElement$6, e as defineCustomElement$9, f as defineCustomElement$a, g as defineCustomElement$b } from './le-button2.js';
|
|
4
4
|
import { d as defineCustomElement$8 } from './le-dropdown-base2.js';
|
|
5
5
|
import { d as defineCustomElement$7 } from './le-popover2.js';
|
package/dist/components/utils.js
CHANGED
|
@@ -1,168 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Global mode initialization for le-kit components.
|
|
5
|
-
*
|
|
6
|
-
* Mode inheritance works as follows:
|
|
7
|
-
* 1. Check the element's own `mode` attribute
|
|
8
|
-
* 2. Traverse up the DOM to find a parent with `mode` attribute
|
|
9
|
-
* 3. Check the document root element (html) for `mode` attribute
|
|
10
|
-
* 4. Fall back to 'default'
|
|
11
|
-
*
|
|
12
|
-
* This allows setting mode at any level:
|
|
13
|
-
* - `<html mode="admin">` - all components in admin mode
|
|
14
|
-
* - `<le-card mode="admin">` - this card and its children in admin mode
|
|
15
|
-
*/
|
|
16
|
-
function initializeMode() {
|
|
17
|
-
setMode((el) => {
|
|
18
|
-
// 1. Check element's own mode attribute
|
|
19
|
-
const ownMode = el.getAttribute('mode');
|
|
20
|
-
if (ownMode) {
|
|
21
|
-
return ownMode;
|
|
22
|
-
}
|
|
23
|
-
// 2. Traverse up the DOM tree to find inherited mode
|
|
24
|
-
let parent = el.parentElement;
|
|
25
|
-
while (parent) {
|
|
26
|
-
const parentMode = parent.getAttribute('mode');
|
|
27
|
-
if (parentMode) {
|
|
28
|
-
return parentMode;
|
|
29
|
-
}
|
|
30
|
-
parent = parent.parentElement;
|
|
31
|
-
}
|
|
32
|
-
// 3. Check document root element
|
|
33
|
-
const rootMode = document.documentElement.getAttribute('mode');
|
|
34
|
-
if (rootMode) {
|
|
35
|
-
return rootMode;
|
|
36
|
-
}
|
|
37
|
-
// 4. Default mode
|
|
38
|
-
return 'default';
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Helper function to get the current mode for an element.
|
|
43
|
-
* Can be used programmatically in components.
|
|
44
|
-
*
|
|
45
|
-
* This function traverses both regular DOM and shadow DOM boundaries
|
|
46
|
-
* to find the nearest mode attribute.
|
|
47
|
-
*/
|
|
48
|
-
function getMode(el) {
|
|
49
|
-
// Check element's own mode
|
|
50
|
-
const ownMode = el.getAttribute('mode');
|
|
51
|
-
if (ownMode) {
|
|
52
|
-
return ownMode;
|
|
53
|
-
}
|
|
54
|
-
// Traverse up DOM, crossing shadow boundaries
|
|
55
|
-
let current = el;
|
|
56
|
-
while (current) {
|
|
57
|
-
// Try parent element first
|
|
58
|
-
if (current instanceof Element && current.parentElement) {
|
|
59
|
-
current = current.parentElement;
|
|
60
|
-
const mode = current.getAttribute?.('mode');
|
|
61
|
-
if (mode) {
|
|
62
|
-
return mode;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// No parent element - check if we're in a shadow root
|
|
67
|
-
const root = current.getRootNode();
|
|
68
|
-
if (root instanceof ShadowRoot) {
|
|
69
|
-
// Cross the shadow boundary to the host element
|
|
70
|
-
current = root.host;
|
|
71
|
-
const mode = current.getAttribute?.('mode');
|
|
72
|
-
if (mode) {
|
|
73
|
-
return mode;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
// We've reached the document root
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Check document root
|
|
83
|
-
const rootMode = document.documentElement.getAttribute('mode');
|
|
84
|
-
if (rootMode) {
|
|
85
|
-
return rootMode;
|
|
86
|
-
}
|
|
87
|
-
return 'default';
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Helper function to get the current theme for an element.
|
|
91
|
-
* Theme inheritance works the same as mode - cascades through DOM.
|
|
92
|
-
*/
|
|
93
|
-
function getTheme(el) {
|
|
94
|
-
// Check element's own theme
|
|
95
|
-
const ownTheme = el.getAttribute('theme');
|
|
96
|
-
if (ownTheme) {
|
|
97
|
-
return ownTheme;
|
|
98
|
-
}
|
|
99
|
-
// Traverse up DOM
|
|
100
|
-
let parent = el.parentElement;
|
|
101
|
-
while (parent) {
|
|
102
|
-
const parentTheme = parent.getAttribute('theme');
|
|
103
|
-
if (parentTheme) {
|
|
104
|
-
return parentTheme;
|
|
105
|
-
}
|
|
106
|
-
parent = parent.parentElement;
|
|
107
|
-
}
|
|
108
|
-
// Check root
|
|
109
|
-
const rootTheme = document.documentElement.getAttribute('theme');
|
|
110
|
-
if (rootTheme) {
|
|
111
|
-
return rootTheme;
|
|
112
|
-
}
|
|
113
|
-
return 'default';
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Helper function to set mode on the document root.
|
|
117
|
-
* Useful for switching all components to admin mode.
|
|
118
|
-
*/
|
|
119
|
-
function setGlobalMode(mode) {
|
|
120
|
-
document.documentElement.setAttribute('mode', mode);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Helper function to set theme on the document root.
|
|
124
|
-
* Useful for switching all components to a different theme.
|
|
125
|
-
*/
|
|
126
|
-
function setGlobalTheme(theme) {
|
|
127
|
-
document.documentElement.setAttribute('theme', theme);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Global configuration for le-kit
|
|
131
|
-
*/
|
|
132
|
-
let leKitConfig = {
|
|
133
|
-
/**
|
|
134
|
-
* URL to the custom-elements.json manifest.
|
|
135
|
-
* Used by admin components (le-component, le-slot) to load component metadata.
|
|
136
|
-
*
|
|
137
|
-
* Default: '/custom-elements.json' (served from app root)
|
|
138
|
-
*
|
|
139
|
-
* For apps using le-kit, you may need to:
|
|
140
|
-
* 1. Copy the manifest from node_modules/le-kit/custom-elements.json to your public folder
|
|
141
|
-
* 2. Or set this to point to where the manifest is served
|
|
142
|
-
*/
|
|
143
|
-
manifestFile: '/custom-elements.json',
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* Configure le-kit global settings.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```ts
|
|
150
|
-
* import { configureLeKit } from 'le-kit';
|
|
151
|
-
*
|
|
152
|
-
* configureLeKit({
|
|
153
|
-
* manifestFile: 'custom-elements.json'
|
|
154
|
-
* });
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
function configureLeKit(config) {
|
|
158
|
-
leKitConfig = { ...leKitConfig, ...config };
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get the current le-kit configuration.
|
|
162
|
-
*/
|
|
163
|
-
function getLeKitConfig() {
|
|
164
|
-
return leKitConfig;
|
|
165
|
-
}
|
|
1
|
+
import { g as getMode } from './app.js';
|
|
166
2
|
|
|
167
3
|
/**
|
|
168
4
|
* Utility functions for le-kit components
|
|
@@ -304,7 +140,7 @@ function classnames(...classes) {
|
|
|
304
140
|
return result.join(' ');
|
|
305
141
|
}
|
|
306
142
|
|
|
307
|
-
export {
|
|
143
|
+
export { classnames as c, generateId as g, observeModeChanges as o, parseCommaSeparated as p, slotHasContent as s };
|
|
308
144
|
//# sourceMappingURL=utils.js.map
|
|
309
145
|
|
|
310
146
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1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E;AAC3B,YAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;;AACX,aAAA,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC;;AAC1B,aAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;AAClC,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;gBAC3C,IAAI,KAAK,EAAE;AACT,oBAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;;AAEpB,aAAC,CAAC;;AAEN,KAAC,CAAC;AAEF,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACzB;;;;","names":[],"sources":["src/global/app.ts","src/utils/utils.ts"],"sourcesContent":["import { setMode } from '@stencil/core';\n\nexport type LeKitMode = 'default' | 'admin' | string;\nexport type LeKitTheme = 'default' | 'dark' | string;\n\n/**\n * Global mode initialization for le-kit components.\n *\n * Mode inheritance works as follows:\n * 1. Check the element's own `mode` attribute\n * 2. Traverse up the DOM to find a parent with `mode` attribute\n * 3. Check the document root element (html) for `mode` attribute\n * 4. Fall back to 'default'\n *\n * This allows setting mode at any level:\n * - `<html mode=\"admin\">` - all components in admin mode\n * - `<le-card mode=\"admin\">` - this card and its children in admin mode\n */\nfunction initializeMode() {\n setMode((el: HTMLElement): LeKitMode => {\n // 1. Check element's own mode attribute\n const ownMode = el.getAttribute('mode');\n if (ownMode) {\n return ownMode as LeKitMode;\n }\n\n // 2. Traverse up the DOM tree to find inherited mode\n let parent = el.parentElement;\n while (parent) {\n const parentMode = parent.getAttribute('mode');\n if (parentMode) {\n return parentMode as LeKitMode;\n }\n parent = parent.parentElement;\n }\n\n // 3. Check document root element\n const rootMode = document.documentElement.getAttribute('mode');\n if (rootMode) {\n return rootMode as LeKitMode;\n }\n\n // 4. Default mode\n return 'default';\n });\n}\n\n// Default export for Stencil global script\nexport default initializeMode;\n\n/**\n * Helper function to get the current mode for an element.\n * Can be used programmatically in components.\n * \n * This function traverses both regular DOM and shadow DOM boundaries\n * to find the nearest mode attribute.\n */\nexport function getMode(el: HTMLElement): LeKitMode {\n // Check element's own mode\n const ownMode = el.getAttribute('mode');\n if (ownMode) {\n return ownMode as LeKitMode;\n }\n\n // Traverse up DOM, crossing shadow boundaries\n let current: Node | null = el;\n while (current) {\n // Try parent element first\n if (current instanceof Element && current.parentElement) {\n current = current.parentElement;\n const mode = (current as HTMLElement).getAttribute?.('mode');\n if (mode) {\n return mode as LeKitMode;\n }\n } else {\n // No parent element - check if we're in a shadow root\n const root = current.getRootNode();\n if (root instanceof ShadowRoot) {\n // Cross the shadow boundary to the host element\n current = root.host;\n const mode = (current as HTMLElement).getAttribute?.('mode');\n if (mode) {\n return mode as LeKitMode;\n }\n } else {\n // We've reached the document root\n break;\n }\n }\n }\n\n // Check document root\n const rootMode = document.documentElement.getAttribute('mode');\n if (rootMode) {\n return rootMode as LeKitMode;\n }\n\n return 'default';\n}\n\n/**\n * Helper function to get the current theme for an element.\n * Theme inheritance works the same as mode - cascades through DOM.\n */\nexport function getTheme(el: HTMLElement): LeKitTheme {\n // Check element's own theme\n const ownTheme = el.getAttribute('theme');\n if (ownTheme) {\n return ownTheme as LeKitTheme;\n }\n\n // Traverse up DOM\n let parent = el.parentElement;\n while (parent) {\n const parentTheme = parent.getAttribute('theme');\n if (parentTheme) {\n return parentTheme as LeKitTheme;\n }\n parent = parent.parentElement;\n }\n\n // Check root\n const rootTheme = document.documentElement.getAttribute('theme');\n if (rootTheme) {\n return rootTheme as LeKitTheme;\n }\n\n return 'default';\n}\n\n/**\n * Helper function to set mode on the document root.\n * Useful for switching all components to admin mode.\n */\nexport function setGlobalMode(mode: LeKitMode): void {\n document.documentElement.setAttribute('mode', mode);\n}\n\n/**\n * Helper function to set theme on the document root.\n * Useful for switching all components to a different theme.\n */\nexport function setGlobalTheme(theme: LeKitTheme): void {\n document.documentElement.setAttribute('theme', theme);\n}\n\n/**\n * Global configuration for le-kit\n */\nlet leKitConfig = {\n /**\n * URL to the custom-elements.json manifest.\n * Used by admin components (le-component, le-slot) to load component metadata.\n * \n * Default: '/custom-elements.json' (served from app root)\n * \n * For apps using le-kit, you may need to:\n * 1. Copy the manifest from node_modules/le-kit/custom-elements.json to your public folder\n * 2. Or set this to point to where the manifest is served\n */\n manifestFile: '/custom-elements.json',\n};\n\n/**\n * Configure le-kit global settings.\n * \n * @example\n * ```ts\n * import { configureLeKit } from 'le-kit';\n * \n * configureLeKit({\n * manifestFile: 'custom-elements.json'\n * });\n * ```\n */\nexport function configureLeKit(config: Partial<typeof leKitConfig>): void {\n leKitConfig = { ...leKitConfig, ...config };\n}\n\n/**\n * Get the current le-kit configuration.\n */\nexport function getLeKitConfig(): typeof leKitConfig {\n return leKitConfig;\n}\n","/**\n * Utility functions for le-kit components\n */\n\nimport { getMode } from '../global/app';\n\n/**\n * Generates a unique ID for component instances\n */\nexport function generateId(prefix: string = 'le'): string {\n return `${prefix}-${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Parses a comma-separated string into an array\n */\nexport function parseCommaSeparated(value: string | undefined): string[] {\n if (!value) return [];\n return value\n .split(',')\n .map(s => s.trim())\n .filter(Boolean);\n}\n\n/**\n * Checks if a slot has content\n */\nexport function slotHasContent(el: HTMLElement, slotName: string = ''): boolean {\n const selector = slotName ? `[slot=\"${slotName}\"]` : ':not([slot])';\n return el.querySelector(selector) !== null;\n}\n\n/**\n * Sets up a MutationObserver to track mode changes on ancestor elements.\n * Returns a cleanup function to disconnect the observer.\n * \n * If the element or any ancestor has an explicit `mode` attribute, that creates\n * a \"mode boundary\" - the mode is determined from that point, not from further up.\n * This allows components like le-popover to force default mode for their children.\n * \n * @param el - The component's host element\n * @param callback - Function to call when mode changes, receives the new mode\n * @returns Cleanup function to disconnect the observer\n * \n * @example\n * ```tsx\n * export class MyComponent {\n * @Element() el: HTMLElement;\n * @State() adminMode: boolean = false;\n * private disconnectModeObserver?: () => void;\n * \n * connectedCallback() {\n * this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {\n * this.adminMode = mode === 'admin';\n * });\n * }\n * \n * disconnectedCallback() {\n * this.disconnectModeObserver?.();\n * }\n * }\n * ```\n */\nexport function observeModeChanges(\n el: HTMLElement,\n callback: (mode: string) => void\n): () => void {\n // Call immediately with current mode\n callback(getMode(el));\n\n // Set up observer for mode attribute changes\n const observer = new MutationObserver(() => {\n callback(getMode(el));\n });\n\n // Observe the element itself (for mode boundary changes)\n observer.observe(el, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n\n // Observe document root\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n\n // Traverse up, crossing shadow boundaries, and observe each element\n let current: Node | null = el;\n while (current) {\n if (current instanceof Element && current.parentElement) {\n current = current.parentElement;\n observer.observe(current, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n // If this element has an explicit mode, it's a boundary\n if ((current as Element).hasAttribute('mode')) {\n break;\n }\n } else {\n // Check if we're in a shadow root\n const root = current.getRootNode();\n if (root instanceof ShadowRoot) {\n // Cross the shadow boundary and observe the host\n current = root.host;\n observer.observe(current, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n // If the host has an explicit mode, it's a boundary\n if ((current as Element).hasAttribute('mode')) {\n break;\n }\n } else {\n break;\n }\n }\n }\n\n // Return cleanup function\n return () => observer.disconnect();\n}\n\n/**\n * Combines multiple class names into a single string, filtering out falsy values.\n * \n * @param classes - arguments of class names, undefined, arrays, objects with boolean values and nested combinations of these\n * @returns Combined class names string\n */\nexport function classnames(...classes: any[]): string {\n const result: string[] = [];\n\n classes.forEach(cls => {\n if (!cls) return;\n\n if (typeof cls === 'string') {\n result.push(cls);\n } else if (Array.isArray(cls)) {\n result.push(classnames(...cls));\n } else if (typeof cls === 'object') {\n Object.entries(cls).forEach(([key, value]) => {\n if (value) {\n result.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C,OAAO,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC;;AAC1B,aAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;AAClC,YAAA,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;gBAC3C,IAAI,KAAK,EAAE;AACT,oBAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;;AAEpB,aAAC,CAAC;;AAEN,KAAC,CAAC;AAEF,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACzB;;;;","names":[],"sources":["src/utils/utils.ts"],"sourcesContent":["/**\n * Utility functions for le-kit components\n */\n\nimport { getMode } from '../global/app';\n\n/**\n * Generates a unique ID for component instances\n */\nexport function generateId(prefix: string = 'le'): string {\n return `${prefix}-${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Parses a comma-separated string into an array\n */\nexport function parseCommaSeparated(value: string | undefined): string[] {\n if (!value) return [];\n return value\n .split(',')\n .map(s => s.trim())\n .filter(Boolean);\n}\n\n/**\n * Checks if a slot has content\n */\nexport function slotHasContent(el: HTMLElement, slotName: string = ''): boolean {\n const selector = slotName ? `[slot=\"${slotName}\"]` : ':not([slot])';\n return el.querySelector(selector) !== null;\n}\n\n/**\n * Sets up a MutationObserver to track mode changes on ancestor elements.\n * Returns a cleanup function to disconnect the observer.\n * \n * If the element or any ancestor has an explicit `mode` attribute, that creates\n * a \"mode boundary\" - the mode is determined from that point, not from further up.\n * This allows components like le-popover to force default mode for their children.\n * \n * @param el - The component's host element\n * @param callback - Function to call when mode changes, receives the new mode\n * @returns Cleanup function to disconnect the observer\n * \n * @example\n * ```tsx\n * export class MyComponent {\n * @Element() el: HTMLElement;\n * @State() adminMode: boolean = false;\n * private disconnectModeObserver?: () => void;\n * \n * connectedCallback() {\n * this.disconnectModeObserver = observeModeChanges(this.el, (mode) => {\n * this.adminMode = mode === 'admin';\n * });\n * }\n * \n * disconnectedCallback() {\n * this.disconnectModeObserver?.();\n * }\n * }\n * ```\n */\nexport function observeModeChanges(\n el: HTMLElement,\n callback: (mode: string) => void\n): () => void {\n // Call immediately with current mode\n callback(getMode(el));\n\n // Set up observer for mode attribute changes\n const observer = new MutationObserver(() => {\n callback(getMode(el));\n });\n\n // Observe the element itself (for mode boundary changes)\n observer.observe(el, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n\n // Observe document root\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n\n // Traverse up, crossing shadow boundaries, and observe each element\n let current: Node | null = el;\n while (current) {\n if (current instanceof Element && current.parentElement) {\n current = current.parentElement;\n observer.observe(current, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n // If this element has an explicit mode, it's a boundary\n if ((current as Element).hasAttribute('mode')) {\n break;\n }\n } else {\n // Check if we're in a shadow root\n const root = current.getRootNode();\n if (root instanceof ShadowRoot) {\n // Cross the shadow boundary and observe the host\n current = root.host;\n observer.observe(current, {\n attributes: true,\n attributeFilter: ['mode'],\n });\n // If the host has an explicit mode, it's a boundary\n if ((current as Element).hasAttribute('mode')) {\n break;\n }\n } else {\n break;\n }\n }\n }\n\n // Return cleanup function\n return () => observer.disconnect();\n}\n\n/**\n * Combines multiple class names into a single string, filtering out falsy values.\n * \n * @param classes - arguments of class names, undefined, arrays, objects with boolean values and nested combinations of these\n * @returns Combined class names string\n */\nexport function classnames(...classes: any[]): string {\n const result: string[] = [];\n\n classes.forEach(cls => {\n if (!cls) return;\n\n if (typeof cls === 'string') {\n result.push(cls);\n } else if (Array.isArray(cls)) {\n result.push(classnames(...cls));\n } else if (typeof cls === 'object') {\n Object.entries(cls).forEach(([key, value]) => {\n if (value) {\n result.push(key);\n }\n });\n }\n });\n\n return result.join(' ');\n}\n"],"version":3}
|
package/dist/docs.json
CHANGED
|
@@ -104,22 +104,23 @@ function setGlobalMode(mode) {
|
|
|
104
104
|
function setGlobalTheme(theme) {
|
|
105
105
|
document.documentElement.setAttribute('theme', theme);
|
|
106
106
|
}
|
|
107
|
+
// Use a Symbol to avoid conflicts with other libraries
|
|
108
|
+
const LE_KIT_CONFIG_KEY = '__leKitConfig__';
|
|
107
109
|
/**
|
|
108
|
-
*
|
|
110
|
+
* Get the global config object, creating it if needed.
|
|
111
|
+
* Uses globalThis (window in browser) to ensure config is shared
|
|
112
|
+
* across all module bundles.
|
|
109
113
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*/
|
|
121
|
-
manifestFile: '/custom-elements.json',
|
|
122
|
-
};
|
|
114
|
+
function getGlobalConfig() {
|
|
115
|
+
const g = globalThis;
|
|
116
|
+
if (!g[LE_KIT_CONFIG_KEY]) {
|
|
117
|
+
g[LE_KIT_CONFIG_KEY] = {
|
|
118
|
+
manifestFile: '/custom-elements.json',
|
|
119
|
+
assetBasePath: '',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return g[LE_KIT_CONFIG_KEY];
|
|
123
|
+
}
|
|
123
124
|
/**
|
|
124
125
|
* Configure le-kit global settings.
|
|
125
126
|
*
|
|
@@ -128,18 +129,27 @@ let leKitConfig = {
|
|
|
128
129
|
* import { configureLeKit } from 'le-kit';
|
|
129
130
|
*
|
|
130
131
|
* configureLeKit({
|
|
131
|
-
* manifestFile: 'custom-elements.json'
|
|
132
|
+
* manifestFile: 'custom-elements.json',
|
|
133
|
+
* assetBasePath: '/le-kit-assets'
|
|
132
134
|
* });
|
|
133
135
|
* ```
|
|
134
136
|
*/
|
|
135
137
|
function configureLeKit(config) {
|
|
136
|
-
|
|
138
|
+
const globalConfig = getGlobalConfig();
|
|
139
|
+
Object.assign(globalConfig, config);
|
|
137
140
|
}
|
|
138
141
|
/**
|
|
139
142
|
* Get the current le-kit configuration.
|
|
140
143
|
*/
|
|
141
144
|
function getLeKitConfig() {
|
|
142
|
-
return
|
|
145
|
+
return getGlobalConfig();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get the configured asset base path.
|
|
149
|
+
* Used internally by components that load assets.
|
|
150
|
+
*/
|
|
151
|
+
function getAssetBasePath() {
|
|
152
|
+
return getGlobalConfig().assetBasePath;
|
|
143
153
|
}
|
|
144
154
|
|
|
145
155
|
const globalScripts = initializeMode;
|
|
@@ -1825,7 +1835,7 @@ function transformTag(tag) {
|
|
|
1825
1835
|
return tag;
|
|
1826
1836
|
}
|
|
1827
1837
|
|
|
1828
|
-
export { Fragment as F, Host as H, getMode as a, bootstrapLazy as b, getElement as c, createEvent as d,
|
|
1829
|
-
//# sourceMappingURL=index-
|
|
1838
|
+
export { Fragment as F, Host as H, getMode as a, bootstrapLazy as b, getElement as c, createEvent as d, getLeKitConfig as e, getAssetPath as f, globalScripts as g, h, getAssetBasePath as i, setAssetPath as j, setGlobalMode as k, getTheme as l, setGlobalTheme as m, configureLeKit as n, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
1839
|
+
//# sourceMappingURL=index-C-Chwj1b.js.map
|
|
1830
1840
|
|
|
1831
|
-
//# sourceMappingURL=index-
|
|
1841
|
+
//# sourceMappingURL=index-C-Chwj1b.js.map
|