le-kit 0.3.2 → 0.3.3
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-BDXkMiZB.js} +27 -2
- package/dist/cjs/index-BDXkMiZB.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-Co3xnkR-.js} +3 -3
- package/dist/cjs/{utils-CZG22_vQ.js.map → utils-Co3xnkR-.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 +601 -601
- package/dist/collection/global/app.js +24 -0
- 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 +194 -0
- package/dist/components/app.js.map +1 -0
- package/dist/components/assets/custom-elements.json +601 -601
- 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-Bb6rgQY0.js} +27 -3
- package/dist/esm/index-Bb6rgQY0.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-CDrgAR8V.js} +3 -3
- package/dist/esm/{utils-CdBk0DdF.js.map → utils-CDrgAR8V.js.map} +1 -1
- package/dist/le-kit/dist/components/assets/custom-elements.json +601 -601
- package/dist/le-kit/index.esm.js +1 -1
- package/dist/le-kit/le-kit.esm.js +1 -1
- package/dist/le-kit/{p-ebd86d4f.entry.js → p-166d31fd.entry.js} +2 -2
- package/dist/le-kit/{p-73f7de28.entry.js → p-1d4f84f6.entry.js} +2 -2
- package/dist/le-kit/{p-4b88b0da.entry.js → p-43a17d84.entry.js} +2 -2
- package/dist/le-kit/{p-b21277e8.entry.js → p-52cc2518.entry.js} +2 -2
- package/dist/le-kit/p-5a0efabf.entry.js +2 -0
- package/dist/le-kit/p-5a0efabf.entry.js.map +1 -0
- package/dist/le-kit/{p-b6997587.entry.js → p-5ad31bd2.entry.js} +2 -2
- package/dist/le-kit/{p-ac822433.entry.js → p-5e7e2d06.entry.js} +2 -2
- package/dist/le-kit/{p-07705c61.entry.js → p-68d94a06.entry.js} +2 -2
- package/dist/le-kit/{p-43f87acb.entry.js → p-84a778b1.entry.js} +2 -2
- package/dist/le-kit/{p-c0ccc9aa.entry.js → p-957f50aa.entry.js} +2 -2
- package/dist/le-kit/p-Bb6rgQY0.js +3 -0
- package/dist/le-kit/p-Bb6rgQY0.js.map +1 -0
- package/dist/le-kit/{p-VG5nXRzT.js → p-DG6SMiyr.js} +2 -2
- package/dist/le-kit/{p-VG5nXRzT.js.map → p-DG6SMiyr.js.map} +1 -1
- package/dist/le-kit/{p-249db213.entry.js → p-a44540d7.entry.js} +2 -2
- package/dist/le-kit/{p-0a270831.entry.js → p-bb7a199f.entry.js} +2 -2
- package/dist/le-kit/{p-3a0a57e9.entry.js → p-c8a9e104.entry.js} +2 -2
- package/dist/le-kit/{p-244ff3d7.entry.js → p-ca766522.entry.js} +2 -2
- package/dist/le-kit/{p-764005e3.entry.js → p-cb392b4b.entry.js} +2 -2
- package/dist/le-kit/{p-61edb398.entry.js → p-eb4b678f.entry.js} +2 -2
- package/dist/le-kit/{p-6d0090c1.entry.js → p-f45d86de.entry.js} +2 -2
- package/dist/types/global/app.d.ts +22 -0
- 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-ebd86d4f.entry.js.map → p-166d31fd.entry.js.map} +0 -0
- /package/dist/le-kit/{p-73f7de28.entry.js.map → p-1d4f84f6.entry.js.map} +0 -0
- /package/dist/le-kit/{p-4b88b0da.entry.js.map → p-43a17d84.entry.js.map} +0 -0
- /package/dist/le-kit/{p-b21277e8.entry.js.map → p-52cc2518.entry.js.map} +0 -0
- /package/dist/le-kit/{p-b6997587.entry.js.map → p-5ad31bd2.entry.js.map} +0 -0
- /package/dist/le-kit/{p-ac822433.entry.js.map → p-5e7e2d06.entry.js.map} +0 -0
- /package/dist/le-kit/{p-07705c61.entry.js.map → p-68d94a06.entry.js.map} +0 -0
- /package/dist/le-kit/{p-43f87acb.entry.js.map → p-84a778b1.entry.js.map} +0 -0
- /package/dist/le-kit/{p-c0ccc9aa.entry.js.map → p-957f50aa.entry.js.map} +0 -0
- /package/dist/le-kit/{p-249db213.entry.js.map → p-a44540d7.entry.js.map} +0 -0
- /package/dist/le-kit/{p-0a270831.entry.js.map → p-bb7a199f.entry.js.map} +0 -0
- /package/dist/le-kit/{p-3a0a57e9.entry.js.map → p-c8a9e104.entry.js.map} +0 -0
- /package/dist/le-kit/{p-244ff3d7.entry.js.map → p-ca766522.entry.js.map} +0 -0
- /package/dist/le-kit/{p-764005e3.entry.js.map → p-cb392b4b.entry.js.map} +0 -0
- /package/dist/le-kit/{p-61edb398.entry.js.map → p-eb4b678f.entry.js.map} +0 -0
- /package/dist/le-kit/{p-6d0090c1.entry.js.map → p-f45d86de.entry.js.map} +0 -0
|
@@ -142,6 +142,23 @@ let leKitConfig = {
|
|
|
142
142
|
* 2. Or set this to point to where the manifest is served
|
|
143
143
|
*/
|
|
144
144
|
manifestFile: '/custom-elements.json',
|
|
145
|
+
/**
|
|
146
|
+
* Base path for loading assets (icons, etc.).
|
|
147
|
+
*
|
|
148
|
+
* Default: '' (empty - uses Stencil's getAssetPath)
|
|
149
|
+
*
|
|
150
|
+
* When set, assets will be loaded from: `${assetBasePath}/icons/${name}.json`
|
|
151
|
+
*
|
|
152
|
+
* For apps using le-kit, you should:
|
|
153
|
+
* 1. Copy the assets from node_modules/le-kit/dist/assets to your public folder
|
|
154
|
+
* 2. Set this to point to where the assets are served (e.g., '/le-kit-assets')
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* configureLeKit({ assetBasePath: '/le-kit-assets' });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
assetBasePath: '',
|
|
145
162
|
};
|
|
146
163
|
/**
|
|
147
164
|
* Configure le-kit global settings.
|
|
@@ -164,4 +181,11 @@ export function configureLeKit(config) {
|
|
|
164
181
|
export function getLeKitConfig() {
|
|
165
182
|
return leKitConfig;
|
|
166
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Get the configured asset base path.
|
|
186
|
+
* Used internally by components that load assets.
|
|
187
|
+
*/
|
|
188
|
+
export function getAssetBasePath() {
|
|
189
|
+
return leKitConfig.assetBasePath;
|
|
190
|
+
}
|
|
167
191
|
//# sourceMappingURL=app.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/global/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKxC;;;;;;;;;;;;GAYG;AACH,SAAS,cAAc;IACrB,OAAO,CAAC,CAAC,E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G,EAAE,GAAG,WAAW,EAAE,GAAG,MAAM,EAAE,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,WAAW,CAAC,aAAa,CAAC;AACnC,CAAC","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 * Base path for loading assets (icons, etc.).\n *\n * Default: '' (empty - uses Stencil's getAssetPath)\n *\n * When set, assets will be loaded from: `${assetBasePath}/icons/${name}.json`\n *\n * For apps using le-kit, you should:\n * 1. Copy the assets from node_modules/le-kit/dist/assets to your public folder\n * 2. Set this to point to where the assets are served (e.g., '/le-kit-assets')\n *\n * @example\n * ```ts\n * configureLeKit({ assetBasePath: '/le-kit-assets' });\n * ```\n */\n assetBasePath: '',\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/**\n * Get the configured asset base path.\n * Used internally by components that load assets.\n */\nexport function getAssetBasePath(): string {\n return leKitConfig.assetBasePath;\n}\n"]}
|
package/dist/collection/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export { generateId, parseCommaSeparated, slotHasContent } from './utils/utils';
|
|
11
11
|
// Global mode and theme helpers
|
|
12
12
|
export { setAssetPath } from '@stencil/core';
|
|
13
|
-
export { getMode, setGlobalMode, getTheme, setGlobalTheme, configureLeKit, getLeKitConfig, } from './global/app';
|
|
13
|
+
export { getMode, setGlobalMode, getTheme, setGlobalTheme, configureLeKit, getLeKitConfig, getAssetBasePath, } from './global/app';
|
|
14
14
|
// Popup/dialog programmatic API
|
|
15
15
|
export { leAlert, leConfirm, lePrompt } from './components/le-popup/le-popup.api';
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhF,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhF,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,gCAAgC;AAChC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["/**\n * @fileoverview Entry point for le-kit component library\n *\n * This file exports utilities, types, and helper functions.\n * Components are auto-registered and available as custom elements.\n *\n * @see README.md for usage instructions\n */\n\n// Utility exports\nexport { generateId, parseCommaSeparated, slotHasContent } from './utils/utils';\n\n// Global mode and theme helpers\nexport { setAssetPath } from '@stencil/core';\nexport {\n getMode,\n setGlobalMode,\n getTheme,\n setGlobalTheme,\n configureLeKit,\n getLeKitConfig,\n getAssetBasePath,\n} from './global/app';\nexport type { LeKitMode, LeKitTheme } from './global/app';\n\n// Popup/dialog programmatic API\nexport { leAlert, leConfirm, lePrompt } from './components/le-popup/le-popup.api';\nexport type { PopupOptions } from './components/le-popup/le-popup.api';\nexport type { PopupResult, PopupType, PopupPosition } from './components/le-popup/le-popup';\n\n// Type exports\nexport type * from './components.d.ts';\n"]}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { setMode } from '@stencil/core/internal/client';
|
|
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
|
+
* Base path for loading assets (icons, etc.).
|
|
146
|
+
*
|
|
147
|
+
* Default: '' (empty - uses Stencil's getAssetPath)
|
|
148
|
+
*
|
|
149
|
+
* When set, assets will be loaded from: `${assetBasePath}/icons/${name}.json`
|
|
150
|
+
*
|
|
151
|
+
* For apps using le-kit, you should:
|
|
152
|
+
* 1. Copy the assets from node_modules/le-kit/dist/assets to your public folder
|
|
153
|
+
* 2. Set this to point to where the assets are served (e.g., '/le-kit-assets')
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* configureLeKit({ assetBasePath: '/le-kit-assets' });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
assetBasePath: '',
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Configure le-kit global settings.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { configureLeKit } from 'le-kit';
|
|
168
|
+
*
|
|
169
|
+
* configureLeKit({
|
|
170
|
+
* manifestFile: 'custom-elements.json'
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
function configureLeKit(config) {
|
|
175
|
+
leKitConfig = { ...leKitConfig, ...config };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get the current le-kit configuration.
|
|
179
|
+
*/
|
|
180
|
+
function getLeKitConfig() {
|
|
181
|
+
return leKitConfig;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get the configured asset base path.
|
|
185
|
+
* Used internally by components that load assets.
|
|
186
|
+
*/
|
|
187
|
+
function getAssetBasePath() {
|
|
188
|
+
return leKitConfig.assetBasePath;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { getTheme as a, setGlobalTheme as b, configureLeKit as c, getLeKitConfig as d, getAssetBasePath as e, getMode as g, initializeMode as i, setGlobalMode as s };
|
|
192
|
+
//# sourceMappingURL=app.js.map
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"app.js","mappings":";;AAKA;;;;;;;;;;;;AAYG;AACH,SAAS,cAAc,GAAA;AACrB,IAAA,OAAO,CAAC,CAAC,EAAe,KAAe;;QAErC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;QACvC,IAAI,OAAO,EAAE;AACX,YAAA,OAAO,OAAoB;;;AAI7B,QAAA,IAAI,MAAM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CAAC,aAAa;AAClC;;;;","names":[],"sources":["src/global/app.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 * Base path for loading assets (icons, etc.).\n *\n * Default: '' (empty - uses Stencil's getAssetPath)\n *\n * When set, assets will be loaded from: `${assetBasePath}/icons/${name}.json`\n *\n * For apps using le-kit, you should:\n * 1. Copy the assets from node_modules/le-kit/dist/assets to your public folder\n * 2. Set this to point to where the assets are served (e.g., '/le-kit-assets')\n *\n * @example\n * ```ts\n * configureLeKit({ assetBasePath: '/le-kit-assets' });\n * ```\n */\n assetBasePath: '',\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/**\n * Get the configured asset base path.\n * Used internally by components that load assets.\n */\nexport function getAssetBasePath(): string {\n return leKitConfig.assetBasePath;\n}\n"],"version":3}
|