tyrell-components 1.0.0-TC8 → 1.0.0-rc.21
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/AGENTS.md +122 -0
- package/CHANGELOG.md +1531 -0
- package/README.md +71 -53
- package/css/tyrell-colors-static.css +1 -0
- package/css/tyrell-theme.css +1 -0
- package/css/tyrell.css +1 -1783
- package/dist/tyrell-colors-static.css +1 -0
- package/dist/tyrell-theme.css +1 -0
- package/dist/tyrell.css +1 -1783
- package/dist/tyrell.js +1 -1
- package/guides/AGENT_INSTRUCTIONS.md +124 -0
- package/guides/AI_GUIDE.md +53 -0
- package/guides/CSS_GUIDE.md +1016 -0
- package/guides/DATASTAR_TY_GUIDE.md +657 -0
- package/guides/ICONS_GUIDE.md +212 -0
- package/guides/TY_GUIDE.md +935 -0
- package/guides/clj/CLOJURESCRIPT_GUIDE.md +300 -0
- package/guides/clj/CODE_SPLITTING.md +279 -0
- package/guides/clj/COMPONENT_GUIDE.md +391 -0
- package/guides/clj/HELIX_TY_GUIDE.md +428 -0
- package/guides/clj/I18N_GUIDE.md +478 -0
- package/guides/clj/LAYOUT_GUIDE.md +273 -0
- package/guides/clj/QUICKSTART.md +266 -0
- package/guides/clj/REAGENT_TY_GUIDE.md +408 -0
- package/guides/clj/REPLICANT_TY_GUIDE.md +623 -0
- package/guides/clj/ROUTING_GUIDE.md +346 -0
- package/guides/clj/UIX_TY_GUIDE.md +319 -0
- package/guides/js/HTMX_TY_GUIDE.md +252 -0
- package/guides/js/JAVASCRIPT_GUIDE.md +388 -0
- package/guides/js/REACT_TY_GUIDE.md +983 -0
- package/guides/js/SVELTE_TY_GUIDE.md +682 -0
- package/guides/js/TYCOMPONENT_GUIDE.md +962 -0
- package/guides/js/VUE_TY_GUIDE.md +738 -0
- package/lib/base/ty-component.d.ts +57 -13
- package/lib/base/ty-component.js +266 -292
- package/lib/components/button.d.ts +42 -18
- package/lib/components/button.js +318 -235
- package/lib/components/calendar-month.d.ts +30 -47
- package/lib/components/calendar-month.js +455 -429
- package/lib/components/calendar-navigation.d.ts +41 -49
- package/lib/components/calendar-navigation.js +287 -346
- package/lib/components/calendar.d.ts +73 -83
- package/lib/components/calendar.js +837 -762
- package/lib/components/checkbox.d.ts +26 -75
- package/lib/components/checkbox.js +298 -391
- package/lib/components/copy.d.ts +20 -60
- package/lib/components/copy.js +276 -380
- package/lib/components/date-picker.d.ts +100 -183
- package/lib/components/date-picker.js +1155 -1570
- package/lib/components/file-upload.d.ts +122 -0
- package/lib/components/file-upload.js +451 -0
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +141 -230
- package/lib/components/input.d.ts +93 -108
- package/lib/components/input.js +734 -710
- package/lib/components/modal.d.ts +39 -29
- package/lib/components/modal.js +419 -438
- package/lib/components/option.d.ts +20 -35
- package/lib/components/option.js +184 -309
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +353 -347
- package/lib/components/radio.d.ts +33 -25
- package/lib/components/radio.js +433 -422
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +71 -103
- package/lib/components/scroll-container.d.ts +21 -14
- package/lib/components/scroll-container.js +292 -234
- package/lib/components/select.d.ts +446 -0
- package/lib/components/select.js +1381 -0
- package/lib/components/selected-tags.d.ts +60 -0
- package/lib/components/selected-tags.js +225 -0
- package/lib/components/sortable.d.ts +175 -0
- package/lib/components/sortable.js +1844 -0
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +62 -68
- package/lib/components/switch.d.ts +15 -15
- package/lib/components/switch.js +237 -231
- package/lib/components/tab.d.ts +50 -7
- package/lib/components/tab.js +203 -69
- package/lib/components/tabs.d.ts +19 -64
- package/lib/components/tabs.js +600 -618
- package/lib/components/tag.d.ts +17 -55
- package/lib/components/tag.js +235 -308
- package/lib/components/textarea.d.ts +58 -89
- package/lib/components/textarea.js +523 -573
- package/lib/components/tooltip.d.ts +8 -13
- package/lib/components/tooltip.js +322 -409
- package/lib/components/wizard.d.ts +7 -54
- package/lib/components/wizard.js +376 -606
- package/lib/icons/fontawesome/brands.d.ts +0 -1
- package/lib/icons/fontawesome/brands.js +0 -8
- package/lib/icons/fontawesome/regular.d.ts +0 -1
- package/lib/icons/fontawesome/regular.js +0 -8
- package/lib/icons/fontawesome/solid.d.ts +0 -1
- package/lib/icons/fontawesome/solid.js +0 -8
- package/lib/icons/heroicons/micro.d.ts +0 -1
- package/lib/icons/heroicons/micro.js +392 -400
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +382 -390
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +337 -345
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +407 -415
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +24479 -26351
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +9653 -9663
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +10271 -10281
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +10495 -10505
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +9905 -9915
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +12792 -12802
- package/lib/index.d.ts +15 -4
- package/lib/index.js +28 -38
- package/lib/styles/button.d.ts +24 -7
- package/lib/styles/button.js +298 -417
- package/lib/styles/calendar-month.d.ts +7 -6
- package/lib/styles/calendar-month.js +157 -179
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +108 -109
- package/lib/styles/calendar.d.ts +3 -3
- package/lib/styles/calendar.js +87 -23
- package/lib/styles/checkbox.d.ts +7 -6
- package/lib/styles/checkbox.js +101 -15
- package/lib/styles/copy.d.ts +3 -2
- package/lib/styles/copy.js +91 -71
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +80 -115
- package/lib/styles/date-picker.d.ts +4 -6
- package/lib/styles/date-picker.js +320 -352
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.d.ts +1 -0
- package/lib/styles/file-upload.js +196 -0
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +92 -170
- package/lib/styles/input.d.ts +4 -7
- package/lib/styles/input.js +148 -643
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +127 -108
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +53 -96
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +47 -77
- package/lib/styles/radio.d.ts +3 -2
- package/lib/styles/radio.js +90 -116
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +2 -12
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +103 -146
- package/lib/styles/select-base.d.ts +8 -0
- package/lib/styles/select-base.js +747 -0
- package/lib/styles/select.d.ts +11 -0
- package/lib/styles/select.js +229 -0
- package/lib/styles/sortable.d.ts +16 -0
- package/lib/styles/sortable.js +85 -0
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +15 -34
- package/lib/styles/switch.d.ts +3 -2
- package/lib/styles/switch.js +52 -68
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +86 -34
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +204 -162
- package/lib/styles/tag.d.ts +2 -6
- package/lib/styles/tag.js +170 -359
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +238 -306
- package/lib/styles/tooltip.d.ts +4 -3
- package/lib/styles/tooltip.js +3 -131
- package/lib/styles/wizard.d.ts +8 -20
- package/lib/styles/wizard.js +306 -295
- package/lib/types/common.d.ts +9 -8
- package/lib/types/common.js +8 -5
- package/lib/utils/calendar-utils.d.ts +49 -65
- package/lib/utils/calendar-utils.js +158 -343
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +273 -317
- package/lib/utils/flavor-sheet.d.ts +31 -0
- package/lib/utils/flavor-sheet.js +17 -0
- package/lib/utils/icon-registry.d.ts +0 -15
- package/lib/utils/icon-registry.js +138 -279
- package/lib/utils/icons.d.ts +9 -0
- package/lib/utils/icons.js +1 -0
- package/lib/utils/loader-registry.d.ts +34 -0
- package/lib/utils/loader-registry.js +11 -0
- package/lib/utils/locale.d.ts +2 -80
- package/lib/utils/locale.js +30 -205
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +1 -18
- package/lib/utils/number-format.d.ts +6 -24
- package/lib/utils/number-format.js +53 -136
- package/lib/utils/positioning.d.ts +72 -22
- package/lib/utils/positioning.js +224 -298
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +36 -144
- package/lib/utils/property-manager.d.ts +6 -6
- package/lib/utils/property-manager.js +127 -196
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +23 -59
- package/lib/utils/scroll-lock.d.ts +10 -11
- package/lib/utils/scroll-lock.js +165 -173
- package/lib/utils/styles.d.ts +0 -6
- package/lib/utils/styles.js +17 -48
- package/lib/utils/upgrade-properties.d.ts +21 -0
- package/lib/utils/upgrade-properties.js +47 -0
- package/lib/utils/validity.d.ts +122 -0
- package/lib/utils/validity.js +289 -0
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +66 -18
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/dropdown.d.ts +0 -402
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -1564
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/multiselect.d.ts +0 -397
- package/lib/components/multiselect.d.ts.map +0 -1
- package/lib/components/multiselect.js +0 -1580
- package/lib/components/multiselect.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/checkbox.d.ts.map +0 -1
- package/lib/styles/checkbox.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/custom-scrollbar.d.ts.map +0 -1
- package/lib/styles/custom-scrollbar.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/dropdown.d.ts +0 -12
- package/lib/styles/dropdown.d.ts.map +0 -1
- package/lib/styles/dropdown.js +0 -983
- package/lib/styles/dropdown.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -774
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/radio.d.ts.map +0 -1
- package/lib/styles/radio.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/switch.d.ts.map +0 -1
- package/lib/styles/switch.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/custom-scrollbar.d.ts.map +0 -1
- package/lib/utils/custom-scrollbar.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/mobile.d.ts.map +0 -1
- package/lib/utils/mobile.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -58
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FLAVORS } from '../types/common.js';
|
|
2
|
+
export function syncCustomFlavorSheet(shadow, sheet, flavor, css) {
|
|
3
|
+
const full = String(flavor || '');
|
|
4
|
+
const base = full.replace(/[+-]$/, '');
|
|
5
|
+
if (FLAVORS.includes(base) || !/^[A-Za-z][A-Za-z0-9_-]*$/.test(base)) {
|
|
6
|
+
if (sheet) {
|
|
7
|
+
shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter((s) => s !== sheet);
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (!sheet) {
|
|
12
|
+
sheet = new CSSStyleSheet();
|
|
13
|
+
shadow.adoptedStyleSheets = [...shadow.adoptedStyleSheets, sheet];
|
|
14
|
+
}
|
|
15
|
+
sheet.replaceSync(css({ flavor: full, base, shade: full.slice(base.length) }));
|
|
16
|
+
return sheet;
|
|
17
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Icon Registry System
|
|
3
3
|
* Simple icon storage and retrieval with Cache API persistence
|
|
4
|
-
* PORTED FROM: clj/ty/icons.cljs
|
|
5
4
|
*/
|
|
6
5
|
/**
|
|
7
6
|
* Read icon directly from cache (for immediate rendering)
|
|
@@ -17,14 +16,6 @@ export declare function getCachedIcon(name: string): Promise<string | null>;
|
|
|
17
16
|
* @param icons Object mapping icon names to SVG strings
|
|
18
17
|
*/
|
|
19
18
|
export declare function registerIcons(icons: Record<string, string>): void;
|
|
20
|
-
/**
|
|
21
|
-
* Register a single icon
|
|
22
|
-
* Always updates memory and notifies watchers immediately
|
|
23
|
-
* Cache update happens in background (only if different from cached version)
|
|
24
|
-
* @param name Icon name
|
|
25
|
-
* @param svg SVG string
|
|
26
|
-
*/
|
|
27
|
-
export declare function registerIcon(name: string, svg: string): void;
|
|
28
19
|
/**
|
|
29
20
|
* Lookup an icon by name from memory
|
|
30
21
|
* NOTE: This does NOT check cache - use getCachedIcon() for that
|
|
@@ -60,11 +51,6 @@ export declare function removeWatcher(id: string): void;
|
|
|
60
51
|
* @returns Array of icon names
|
|
61
52
|
*/
|
|
62
53
|
export declare function getIconNames(): string[];
|
|
63
|
-
/**
|
|
64
|
-
* Get registry size (memory only)
|
|
65
|
-
* @returns Number of registered icons in memory
|
|
66
|
-
*/
|
|
67
|
-
export declare function getIconCount(): number;
|
|
68
54
|
/**
|
|
69
55
|
* Get cache statistics
|
|
70
56
|
* @returns Promise with cache info
|
|
@@ -75,4 +61,3 @@ export declare function getCacheInfo(): Promise<{
|
|
|
75
61
|
available: boolean;
|
|
76
62
|
iconCount?: number;
|
|
77
63
|
}>;
|
|
78
|
-
//# sourceMappingURL=icon-registry.d.ts.map
|
|
@@ -1,304 +1,163 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Icon Registry System
|
|
3
|
-
* Simple icon storage and retrieval with Cache API persistence
|
|
4
|
-
* PORTED FROM: clj/ty/icons.cljs
|
|
5
|
-
*/
|
|
6
1
|
import { VERSION } from '../version.js';
|
|
7
|
-
/** Icon registry - maps icon names to SVG strings */
|
|
8
2
|
const iconRegistry = new Map();
|
|
9
|
-
/** Watchers for registry changes - now receives Set of changed icon names */
|
|
10
3
|
const watchers = new Map();
|
|
11
|
-
/** Track which icons each watcher cares about (for selective notification) */
|
|
12
4
|
const watcherIconNames = new Map();
|
|
13
|
-
/** Pending notifications - batched for performance */
|
|
14
5
|
let pendingNotifications = null;
|
|
15
6
|
let notificationTimer = null;
|
|
16
|
-
/** Cache API configuration */
|
|
17
7
|
const CACHE_NAME = `ty-icons-v${VERSION}`;
|
|
18
|
-
// Use a fake URL base for Cache API (requires valid URL format)
|
|
19
8
|
const CACHE_URL_BASE = 'https://ty-icons.local/';
|
|
20
|
-
/** Track in-flight cache reads to avoid duplicate work */
|
|
21
9
|
const cacheReadPromises = new Map();
|
|
22
|
-
/** Flag to track if old caches have been cleared */
|
|
23
10
|
let oldCachesCleared = false;
|
|
24
|
-
/**
|
|
25
|
-
* Clear old cache versions on first use
|
|
26
|
-
* This runs lazily the first time any icon is requested
|
|
27
|
-
*/
|
|
28
11
|
async function clearOldCaches() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Cache an icon in Cache API (non-blocking background operation)
|
|
46
|
-
* @param name Icon name
|
|
47
|
-
* @param svg SVG string
|
|
48
|
-
*/
|
|
12
|
+
if (oldCachesCleared || !('caches' in window))
|
|
13
|
+
return;
|
|
14
|
+
oldCachesCleared = true;
|
|
15
|
+
try {
|
|
16
|
+
const cacheNames = await caches.keys();
|
|
17
|
+
const oldCaches = cacheNames.filter(name => name.startsWith('ty-icons-v') && name !== CACHE_NAME);
|
|
18
|
+
await Promise.all(oldCaches.map(name => caches.delete(name)));
|
|
19
|
+
if (oldCaches.length > 0) {
|
|
20
|
+
console.log(`🗑️ Cleared ${oldCaches.length} old icon cache(s)`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.warn('[ty-icons] Failed to clear old caches:', err);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
49
27
|
async function cacheIcon(name, svg) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Read icon directly from cache (for immediate rendering)
|
|
67
|
-
* This is the key function that prevents icon twitching!
|
|
68
|
-
* @param name Icon name
|
|
69
|
-
* @returns Promise<string | null> - SVG string from cache or null
|
|
70
|
-
*/
|
|
28
|
+
if (!('caches' in window))
|
|
29
|
+
return;
|
|
30
|
+
try {
|
|
31
|
+
const cache = await caches.open(CACHE_NAME);
|
|
32
|
+
const response = new Response(svg, {
|
|
33
|
+
headers: { 'Content-Type': 'image/svg+xml' }
|
|
34
|
+
});
|
|
35
|
+
await cache.put(`${CACHE_URL_BASE}${name}`, response);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.warn(`[ty-icons] Failed to cache icon "${name}":`, err);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
71
41
|
export async function getCachedIcon(name) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
readPromise.finally(() => {
|
|
97
|
-
cacheReadPromises.delete(name);
|
|
98
|
-
});
|
|
99
|
-
return readPromise;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Register multiple icons at once
|
|
103
|
-
* Always updates memory and notifies watchers immediately
|
|
104
|
-
* Cache update happens in background (only if different from cached version)
|
|
105
|
-
* @param icons Object mapping icon names to SVG strings
|
|
106
|
-
*/
|
|
42
|
+
const existingPromise = cacheReadPromises.get(name);
|
|
43
|
+
if (existingPromise) {
|
|
44
|
+
return existingPromise;
|
|
45
|
+
}
|
|
46
|
+
const readPromise = (async () => {
|
|
47
|
+
try {
|
|
48
|
+
await clearOldCaches();
|
|
49
|
+
const cache = await caches.open(CACHE_NAME);
|
|
50
|
+
const response = await cache.match(`${CACHE_URL_BASE}${name}`);
|
|
51
|
+
if (response) {
|
|
52
|
+
return await response.text();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.warn(`[ty-icons] Failed to read icon "${name}" from cache:`, err);
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
})();
|
|
60
|
+
cacheReadPromises.set(name, readPromise);
|
|
61
|
+
readPromise.finally(() => {
|
|
62
|
+
cacheReadPromises.delete(name);
|
|
63
|
+
});
|
|
64
|
+
return readPromise;
|
|
65
|
+
}
|
|
107
66
|
export function registerIcons(icons) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
cacheIcon(name, svg).catch(() => {
|
|
118
|
-
// Error already logged in cacheIcon
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
// If cachedSvg === svg, skip cache write (already up to date)
|
|
122
|
-
}).catch(() => {
|
|
123
|
-
// No cached version or error reading cache - write new icon
|
|
124
|
-
cacheIcon(name, svg).catch(() => {
|
|
125
|
-
// Error already logged in cacheIcon
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
*/
|
|
129
|
-
});
|
|
130
|
-
// Notify watchers immediately (synchronous)
|
|
131
|
-
if (changedIcons.size > 0) {
|
|
132
|
-
scheduleNotification(changedIcons);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Register a single icon
|
|
137
|
-
* Always updates memory and notifies watchers immediately
|
|
138
|
-
* Cache update happens in background (only if different from cached version)
|
|
139
|
-
* @param name Icon name
|
|
140
|
-
* @param svg SVG string
|
|
141
|
-
*/
|
|
142
|
-
export function registerIcon(name, svg) {
|
|
143
|
-
// Always set in memory registry (fast, synchronous)
|
|
144
|
-
iconRegistry.set(name, svg);
|
|
145
|
-
// Notify watchers immediately (synchronous)
|
|
146
|
-
scheduleNotification(new Set([name]));
|
|
147
|
-
// Compare with cache in background to avoid unnecessary cache writes
|
|
148
|
-
getCachedIcon(name).then(cachedSvg => {
|
|
149
|
-
// Only write to cache if content actually changed
|
|
150
|
-
if (cachedSvg !== svg) {
|
|
151
|
-
cacheIcon(name, svg).catch(() => {
|
|
152
|
-
// Error already logged in cacheIcon
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
// If cachedSvg === svg, skip cache write (already up to date)
|
|
156
|
-
}).catch(() => {
|
|
157
|
-
// No cached version or error reading cache - write new icon
|
|
158
|
-
cacheIcon(name, svg).catch(() => {
|
|
159
|
-
// Error already logged in cacheIcon
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Lookup an icon by name from memory
|
|
165
|
-
* NOTE: This does NOT check cache - use getCachedIcon() for that
|
|
166
|
-
* @param name Icon name
|
|
167
|
-
* @returns SVG string or undefined
|
|
168
|
-
*/
|
|
67
|
+
const changedIcons = new Set();
|
|
68
|
+
Object.entries(icons).forEach(([name, svg]) => {
|
|
69
|
+
iconRegistry.set(name, svg);
|
|
70
|
+
changedIcons.add(name);
|
|
71
|
+
});
|
|
72
|
+
if (changedIcons.size > 0) {
|
|
73
|
+
scheduleNotification(changedIcons);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
169
76
|
export function getIcon(name) {
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Check if an icon exists in memory
|
|
174
|
-
* NOTE: This does NOT check cache
|
|
175
|
-
* @param name Icon name
|
|
176
|
-
* @returns true if icon is registered in memory
|
|
177
|
-
*/
|
|
77
|
+
return iconRegistry.get(name);
|
|
78
|
+
}
|
|
178
79
|
export function hasIcon(name) {
|
|
179
|
-
|
|
80
|
+
return iconRegistry.has(name);
|
|
180
81
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Clear all registered icons from memory and cache
|
|
183
|
-
*/
|
|
184
82
|
export async function clearIcons() {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Add a watcher for registry changes
|
|
201
|
-
* @param id Unique watcher ID
|
|
202
|
-
* @param iconName Optional icon name to watch (for selective notification)
|
|
203
|
-
* @param callback Function to call when watched icons change
|
|
204
|
-
*/
|
|
83
|
+
const allIcons = new Set(iconRegistry.keys());
|
|
84
|
+
iconRegistry.clear();
|
|
85
|
+
if ('caches' in window) {
|
|
86
|
+
try {
|
|
87
|
+
await caches.delete(CACHE_NAME);
|
|
88
|
+
oldCachesCleared = false;
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
console.warn('[ty-icons] Failed to clear icon cache:', err);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
scheduleNotification(allIcons);
|
|
95
|
+
}
|
|
205
96
|
export function addWatcher(id, iconName, callback) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Remove a watcher
|
|
213
|
-
* @param id Watcher ID to remove
|
|
214
|
-
*/
|
|
97
|
+
watchers.set(id, callback);
|
|
98
|
+
if (iconName) {
|
|
99
|
+
watcherIconNames.set(id, iconName);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
215
102
|
export function removeWatcher(id) {
|
|
216
|
-
|
|
217
|
-
|
|
103
|
+
watchers.delete(id);
|
|
104
|
+
watcherIconNames.delete(id);
|
|
218
105
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Schedule notification for changed icons (batched and deferred)
|
|
221
|
-
*/
|
|
222
106
|
function scheduleNotification(changedIcons) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
notifyWatchers(toNotify);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Notify watchers of changed icons (selective notification)
|
|
248
|
-
*/
|
|
107
|
+
if (!pendingNotifications) {
|
|
108
|
+
pendingNotifications = new Set();
|
|
109
|
+
}
|
|
110
|
+
changedIcons.forEach(name => pendingNotifications.add(name));
|
|
111
|
+
if (notificationTimer !== null) {
|
|
112
|
+
clearTimeout(notificationTimer);
|
|
113
|
+
}
|
|
114
|
+
const scheduleCallback = typeof requestIdleCallback !== 'undefined'
|
|
115
|
+
? requestIdleCallback
|
|
116
|
+
: (cb) => setTimeout(cb, 0);
|
|
117
|
+
notificationTimer = scheduleCallback(() => {
|
|
118
|
+
const toNotify = pendingNotifications;
|
|
119
|
+
pendingNotifications = null;
|
|
120
|
+
notificationTimer = null;
|
|
121
|
+
if (toNotify && toNotify.size > 0) {
|
|
122
|
+
notifyWatchers(toNotify);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
249
126
|
function notifyWatchers(changedIcons) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Get all registered icon names (memory only, not cache)
|
|
266
|
-
* @returns Array of icon names
|
|
267
|
-
*/
|
|
127
|
+
watchers.forEach((callback, watcherId) => {
|
|
128
|
+
const watchedIcon = watcherIconNames.get(watcherId);
|
|
129
|
+
if (watchedIcon) {
|
|
130
|
+
if (changedIcons.has(watchedIcon)) {
|
|
131
|
+
callback(new Set([watchedIcon]));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
callback(changedIcons);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
268
139
|
export function getIconNames() {
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Get registry size (memory only)
|
|
273
|
-
* @returns Number of registered icons in memory
|
|
274
|
-
*/
|
|
275
|
-
export function getIconCount() {
|
|
276
|
-
return iconRegistry.size;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Get cache statistics
|
|
280
|
-
* @returns Promise with cache info
|
|
281
|
-
*/
|
|
140
|
+
return Array.from(iconRegistry.keys());
|
|
141
|
+
}
|
|
282
142
|
export async function getCacheInfo() {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
//# sourceMappingURL=icon-registry.js.map
|
|
143
|
+
const info = {
|
|
144
|
+
version: VERSION,
|
|
145
|
+
cacheName: CACHE_NAME,
|
|
146
|
+
available: 'caches' in window
|
|
147
|
+
};
|
|
148
|
+
if (!info.available)
|
|
149
|
+
return info;
|
|
150
|
+
try {
|
|
151
|
+
const cache = await caches.open(CACHE_NAME);
|
|
152
|
+
const keys = await cache.keys();
|
|
153
|
+
const iconKeys = keys.filter(req => req.url.startsWith(CACHE_URL_BASE));
|
|
154
|
+
return {
|
|
155
|
+
...info,
|
|
156
|
+
iconCount: iconKeys.length
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
console.warn('[ty-icons] Failed to get cache info:', err);
|
|
161
|
+
return info;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared inline SVG icons for shadow-DOM components.
|
|
3
|
+
*
|
|
4
|
+
* Kept inline (not the icon registry) because shadow roots must render
|
|
5
|
+
* without registry setup. Styling hooks target the wrapper element
|
|
6
|
+
* (e.g. `.required-icon svg`), never the svg's own classes.
|
|
7
|
+
*/
|
|
8
|
+
/** Lucide `asterisk` — required-field indicator. */
|
|
9
|
+
export declare const REQUIRED_ICON_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 6v12\"/><path d=\"M17.196 9 6.804 15\"/><path d=\"m6.804 9 10.392 6\"/></svg>";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const REQUIRED_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 6v12"/><path d="M17.196 9 6.804 15"/><path d="m6.804 9 10.392 6"/></svg>`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global loader-icon registry.
|
|
3
|
+
*
|
|
4
|
+
* Set once at app bootstrap to override the default spinner SVG used by
|
|
5
|
+
* every loading-aware component (`ty-button`, `ty-select`, etc.). Components
|
|
6
|
+
* call `getLoaderSvg()` on every render, so changing the
|
|
7
|
+
* registered SVG affects future renders.
|
|
8
|
+
*
|
|
9
|
+
* The wrapper element rotates the SVG with `transform: rotate()`, so prefer
|
|
10
|
+
* a *static* SVG. If you must use a self-animating SVG, disable the wrapper
|
|
11
|
+
* spin with the `--ty-loader-animation: none` CSS custom property.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { setLoaderSvg } from 'tyrell-components'
|
|
15
|
+
* setLoaderSvg('<svg viewBox="0 0 24 24">...</svg>')
|
|
16
|
+
*
|
|
17
|
+
* // CDN / vanilla
|
|
18
|
+
* window.tyLoader.set('<svg ...>...</svg>')
|
|
19
|
+
*
|
|
20
|
+
* // Reset to default
|
|
21
|
+
* setLoaderSvg(null)
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Register a custom spinner SVG (markup string). Pass `null` to reset to
|
|
25
|
+
* the built-in default.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setLoaderSvg(svg: string | null): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get the currently registered spinner SVG, or the built-in default if
|
|
30
|
+
* none has been set. Components call this on every render.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLoaderSvg(): string;
|
|
33
|
+
/** Reset the registered loader back to the built-in default. */
|
|
34
|
+
export declare function resetLoaderSvg(): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const DEFAULT_LOADER_SVG = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3" stroke-opacity="0.25"/><path d="M22 12a10 10 0 0 1-10 10" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>`;
|
|
2
|
+
let customLoaderSvg = null;
|
|
3
|
+
export function setLoaderSvg(svg) {
|
|
4
|
+
customLoaderSvg = svg && svg.trim() ? svg : null;
|
|
5
|
+
}
|
|
6
|
+
export function getLoaderSvg() {
|
|
7
|
+
return customLoaderSvg ?? DEFAULT_LOADER_SVG;
|
|
8
|
+
}
|
|
9
|
+
export function resetLoaderSvg() {
|
|
10
|
+
customLoaderSvg = null;
|
|
11
|
+
}
|
package/lib/utils/locale.d.ts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Locale Resolution Utilities
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 2. Closest ancestor's `lang` attribute
|
|
7
|
-
* 3. Document root's `lang` attribute
|
|
8
|
-
* 4. Browser's language preference
|
|
9
|
-
* 5. 'en-US' fallback (lowest priority)
|
|
10
|
-
*
|
|
11
|
-
* This allows developers to set locale at any level:
|
|
12
|
-
* - Per-component: <ty-input locale="fr-FR">
|
|
13
|
-
* - Per-section: <div lang="de-DE"><ty-input></ty-input></div>
|
|
14
|
-
* - Per-page: <html lang="es-ES">
|
|
15
|
-
* - Browser default: Uses navigator.language
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // In a component
|
|
20
|
-
* class TyInput extends HTMLElement {
|
|
21
|
-
* get locale(): string {
|
|
22
|
-
* return getEffectiveLocale(this, this.getAttribute('locale'));
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
4
|
+
* Cascade for resolving locale/language preferences, so developers can set it
|
|
5
|
+
* per-component, per-section, per-page, or fall back to the browser default.
|
|
26
6
|
*/
|
|
27
7
|
/**
|
|
28
8
|
* Get the effective locale for an element using the resolution cascade.
|
|
@@ -50,63 +30,6 @@
|
|
|
50
30
|
* ```
|
|
51
31
|
*/
|
|
52
32
|
export declare function getEffectiveLocale(element: HTMLElement, explicitLocale?: string | null): string;
|
|
53
|
-
/**
|
|
54
|
-
* Normalize a locale string to BCP 47 format.
|
|
55
|
-
* Handles common variations and ensures consistency.
|
|
56
|
-
*
|
|
57
|
-
* @param locale - The locale string to normalize
|
|
58
|
-
* @returns Normalized locale string
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* normalizeLocale('en') // 'en'
|
|
63
|
-
* normalizeLocale('en_US') // 'en-US'
|
|
64
|
-
* normalizeLocale('EN-us') // 'en-US'
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function normalizeLocale(locale: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* Check if a locale string is valid BCP 47 format.
|
|
70
|
-
*
|
|
71
|
-
* @param locale - The locale string to validate
|
|
72
|
-
* @returns true if valid, false otherwise
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* isValidLocale('en-US') // true
|
|
77
|
-
* isValidLocale('fr') // true
|
|
78
|
-
* isValidLocale('invalid!') // false
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export declare function isValidLocale(locale: string): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Get the language code from a locale (e.g., 'en' from 'en-US').
|
|
84
|
-
*
|
|
85
|
-
* @param locale - The locale string
|
|
86
|
-
* @returns The language code
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```typescript
|
|
90
|
-
* getLanguageCode('en-US') // 'en'
|
|
91
|
-
* getLanguageCode('fr-FR') // 'fr'
|
|
92
|
-
* getLanguageCode('de') // 'de'
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export declare function getLanguageCode(locale: string): string;
|
|
96
|
-
/**
|
|
97
|
-
* Get the region/country code from a locale (e.g., 'US' from 'en-US').
|
|
98
|
-
*
|
|
99
|
-
* @param locale - The locale string
|
|
100
|
-
* @returns The region code, or undefined if not present
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* getRegionCode('en-US') // 'US'
|
|
105
|
-
* getRegionCode('fr-FR') // 'FR'
|
|
106
|
-
* getRegionCode('de') // undefined
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
export declare function getRegionCode(locale: string): string | undefined;
|
|
110
33
|
/**
|
|
111
34
|
* Create a MutationObserver to watch for lang attribute changes.
|
|
112
35
|
* Useful for components that need to react to dynamic locale changes.
|
|
@@ -133,4 +56,3 @@ export declare function getRegionCode(locale: string): string | undefined;
|
|
|
133
56
|
* ```
|
|
134
57
|
*/
|
|
135
58
|
export declare function observeLocaleChanges(element: HTMLElement, callback: (newLocale: string) => void): () => void;
|
|
136
|
-
//# sourceMappingURL=locale.d.ts.map
|