tyrell-components 1.0.0-RC13 → 1.0.0-RC15
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/README.md +10 -2
- package/css/tyrell-theme.css +192 -180
- package/css/tyrell.css +23 -0
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1454
- package/dist/tyrell.css +1 -1371
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +20 -10
- package/lib/base/ty-component.js +196 -319
- package/lib/components/button.d.ts +3 -17
- package/lib/components/button.js +261 -295
- package/lib/components/calendar-month.d.ts +4 -50
- package/lib/components/calendar-month.js +443 -582
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +239 -362
- package/lib/components/calendar.d.ts +8 -83
- package/lib/components/calendar.js +616 -829
- package/lib/components/checkbox.d.ts +5 -72
- package/lib/components/checkbox.js +273 -416
- package/lib/components/copy.d.ts +4 -57
- package/lib/components/copy.js +280 -397
- package/lib/components/date-picker.d.ts +21 -163
- package/lib/components/date-picker.js +1143 -1674
- package/lib/components/file-upload.d.ts +9 -15
- package/lib/components/file-upload.js +404 -426
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +141 -230
- package/lib/components/input.d.ts +8 -108
- package/lib/components/input.js +593 -784
- package/lib/components/modal.d.ts +17 -26
- package/lib/components/modal.js +340 -484
- package/lib/components/option.d.ts +2 -9
- package/lib/components/option.js +168 -216
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +249 -380
- package/lib/components/radio.d.ts +5 -25
- package/lib/components/radio.js +407 -461
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +69 -103
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +293 -338
- package/lib/components/select.d.ts +87 -159
- package/lib/components/select.js +1609 -2090
- package/lib/components/selected-tags.d.ts +5 -48
- package/lib/components/selected-tags.js +188 -276
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +62 -68
- package/lib/components/switch.d.ts +1 -12
- package/lib/components/switch.js +214 -247
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +62 -69
- package/lib/components/tabs.d.ts +6 -63
- package/lib/components/tabs.js +545 -777
- package/lib/components/tag.d.ts +3 -37
- package/lib/components/tag.js +236 -335
- package/lib/components/textarea.d.ts +7 -87
- package/lib/components/textarea.js +457 -627
- package/lib/components/tooltip.d.ts +3 -11
- package/lib/components/tooltip.js +307 -443
- package/lib/components/wizard.d.ts +6 -54
- package/lib/components/wizard.js +405 -618
- 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 +0 -1
- package/lib/index.js +21 -41
- package/lib/styles/button.d.ts +2 -20
- package/lib/styles/button.js +202 -404
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +127 -244
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +64 -104
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +9 -22
- package/lib/styles/checkbox.d.ts +0 -1
- package/lib/styles/checkbox.js +45 -94
- package/lib/styles/copy.d.ts +0 -1
- package/lib/styles/copy.js +67 -106
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +80 -115
- package/lib/styles/date-picker.d.ts +1 -5
- package/lib/styles/date-picker.js +261 -335
- 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 -2
- package/lib/styles/file-upload.js +143 -188
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +92 -170
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +125 -290
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +71 -108
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +49 -64
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +42 -77
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +69 -110
- 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 +100 -149
- package/lib/styles/select-base.d.ts +0 -1
- package/lib/styles/select-base.js +597 -785
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +140 -236
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +22 -33
- package/lib/styles/switch.d.ts +0 -1
- package/lib/styles/switch.js +34 -73
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +22 -34
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +190 -222
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +136 -218
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +210 -319
- package/lib/styles/tooltip.d.ts +0 -1
- package/lib/styles/tooltip.js +3 -13
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +170 -306
- package/lib/types/common.d.ts +2 -2
- package/lib/types/common.js +6 -17
- package/lib/utils/calendar-utils.d.ts +4 -21
- package/lib/utils/calendar-utils.js +100 -273
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +273 -317
- package/lib/utils/flavor-sheet.d.ts +0 -1
- package/lib/utils/flavor-sheet.js +14 -37
- package/lib/utils/icon-registry.d.ts +0 -2
- package/lib/utils/icon-registry.js +137 -243
- package/lib/utils/icons.d.ts +0 -1
- package/lib/utils/icons.js +0 -9
- package/lib/utils/loader-registry.d.ts +0 -1
- package/lib/utils/loader-registry.js +3 -35
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +34 -120
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +1 -18
- package/lib/utils/number-format.d.ts +6 -3
- package/lib/utils/number-format.js +54 -110
- package/lib/utils/positioning.d.ts +50 -7
- package/lib/utils/positioning.js +224 -234
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +36 -144
- package/lib/utils/property-manager.d.ts +0 -1
- package/lib/utils/property-manager.js +126 -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 +4 -11
- package/lib/utils/scroll-lock.js +65 -172
- package/lib/utils/styles.d.ts +0 -1
- package/lib/utils/styles.js +17 -41
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +4 -4
- 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/file-upload.d.ts.map +0 -1
- package/lib/components/file-upload.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/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/select.d.ts.map +0 -1
- package/lib/components/select.js.map +0 -1
- package/lib/components/selected-tags.d.ts.map +0 -1
- package/lib/components/selected-tags.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/file-upload.d.ts.map +0 -1
- package/lib/styles/file-upload.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 -8
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -849
- 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/select-base.d.ts.map +0 -1
- package/lib/styles/select-base.js.map +0 -1
- package/lib/styles/select.d.ts.map +0 -1
- package/lib/styles/select.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/flavor-sheet.d.ts.map +0 -1
- package/lib/utils/flavor-sheet.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/icons.d.ts.map +0 -1
- package/lib/utils/icons.js.map +0 -1
- package/lib/utils/loader-registry.d.ts.map +0 -1
- package/lib/utils/loader-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
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom (non-built-in) flavor support.
|
|
3
|
-
*
|
|
4
|
-
* Built-in flavors get static per-flavor CSS in each component's stylesheet.
|
|
5
|
-
* Any other flavor string is a custom flavor: the component generates the
|
|
6
|
-
* same wiring at runtime, pointed at the user's design tokens
|
|
7
|
-
* (--ty-color-X / --ty-bg-X / --ty-solid-X / ...), and adopts it as a
|
|
8
|
-
* constructed stylesheet.
|
|
9
|
-
*
|
|
10
|
-
* Why an adopted sheet: render() implementations replace shadowRoot.innerHTML
|
|
11
|
-
* (which would destroy an injected <style> element), and inline style on the
|
|
12
|
-
* host would defeat page-level overrides. Adopted sheets survive renders, and
|
|
13
|
-
* outer-document rules on the host still take precedence over :host rules —
|
|
14
|
-
* so `ty-tag[flavor="X"] { --tag-bg: ... }` escape hatches keep working.
|
|
15
|
-
*/
|
|
16
1
|
import { FLAVORS } from '../types/common.js';
|
|
17
|
-
/**
|
|
18
|
-
* Keep a shadow root's custom-flavor sheet in sync with the current flavor.
|
|
19
|
-
*
|
|
20
|
-
* Built-in flavors (and anything that isn't a plain identifier, so attribute
|
|
21
|
-
* values can't inject CSS) remove the sheet. Custom flavors get `css(parts)`
|
|
22
|
-
* adopted into the shadow root. Returns the sheet to store for the next call.
|
|
23
|
-
*/
|
|
24
2
|
export function syncCustomFlavorSheet(shadow, sheet, flavor, css) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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;
|
|
39
17
|
}
|
|
40
|
-
//# sourceMappingURL=flavor-sheet.js.map
|
|
@@ -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)
|
|
@@ -62,4 +61,3 @@ export declare function getCacheInfo(): Promise<{
|
|
|
62
61
|
available: boolean;
|
|
63
62
|
iconCount?: number;
|
|
64
63
|
}>;
|
|
65
|
-
//# sourceMappingURL=icon-registry.d.ts.map
|
|
@@ -1,269 +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
|
-
* Lookup an icon by name from memory
|
|
137
|
-
* NOTE: This does NOT check cache - use getCachedIcon() for that
|
|
138
|
-
* @param name Icon name
|
|
139
|
-
* @returns SVG string or undefined
|
|
140
|
-
*/
|
|
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
|
+
}
|
|
141
76
|
export function getIcon(name) {
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Check if an icon exists in memory
|
|
146
|
-
* NOTE: This does NOT check cache
|
|
147
|
-
* @param name Icon name
|
|
148
|
-
* @returns true if icon is registered in memory
|
|
149
|
-
*/
|
|
77
|
+
return iconRegistry.get(name);
|
|
78
|
+
}
|
|
150
79
|
export function hasIcon(name) {
|
|
151
|
-
|
|
80
|
+
return iconRegistry.has(name);
|
|
152
81
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Clear all registered icons from memory and cache
|
|
155
|
-
*/
|
|
156
82
|
export async function clearIcons() {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Add a watcher for registry changes
|
|
173
|
-
* @param id Unique watcher ID
|
|
174
|
-
* @param iconName Optional icon name to watch (for selective notification)
|
|
175
|
-
* @param callback Function to call when watched icons change
|
|
176
|
-
*/
|
|
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
|
+
}
|
|
177
96
|
export function addWatcher(id, iconName, callback) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Remove a watcher
|
|
185
|
-
* @param id Watcher ID to remove
|
|
186
|
-
*/
|
|
97
|
+
watchers.set(id, callback);
|
|
98
|
+
if (iconName) {
|
|
99
|
+
watcherIconNames.set(id, iconName);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
187
102
|
export function removeWatcher(id) {
|
|
188
|
-
|
|
189
|
-
|
|
103
|
+
watchers.delete(id);
|
|
104
|
+
watcherIconNames.delete(id);
|
|
190
105
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Schedule notification for changed icons (batched and deferred)
|
|
193
|
-
*/
|
|
194
106
|
function scheduleNotification(changedIcons) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
notifyWatchers(toNotify);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Notify watchers of changed icons (selective notification)
|
|
220
|
-
*/
|
|
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
|
+
}
|
|
221
126
|
function notifyWatchers(changedIcons) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Get all registered icon names (memory only, not cache)
|
|
238
|
-
* @returns Array of icon names
|
|
239
|
-
*/
|
|
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
|
+
}
|
|
240
139
|
export function getIconNames() {
|
|
241
|
-
|
|
140
|
+
return Array.from(iconRegistry.keys());
|
|
242
141
|
}
|
|
243
|
-
/**
|
|
244
|
-
* Get cache statistics
|
|
245
|
-
* @returns Promise with cache info
|
|
246
|
-
*/
|
|
247
142
|
export async function getCacheInfo() {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
//# 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
|
+
}
|
package/lib/utils/icons.d.ts
CHANGED
|
@@ -7,4 +7,3 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** Lucide `asterisk` — required-field indicator. */
|
|
9
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>";
|
|
10
|
-
//# sourceMappingURL=icons.d.ts.map
|
package/lib/utils/icons.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
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
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>`;
|
|
10
|
-
//# sourceMappingURL=icons.js.map
|
|
@@ -32,4 +32,3 @@ export declare function setLoaderSvg(svg: string | null): void;
|
|
|
32
32
|
export declare function getLoaderSvg(): string;
|
|
33
33
|
/** Reset the registered loader back to the built-in default. */
|
|
34
34
|
export declare function resetLoaderSvg(): void;
|
|
35
|
-
//# sourceMappingURL=loader-registry.d.ts.map
|
|
@@ -1,43 +1,11 @@
|
|
|
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
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>`;
|
|
24
2
|
let customLoaderSvg = null;
|
|
25
|
-
/**
|
|
26
|
-
* Register a custom spinner SVG (markup string). Pass `null` to reset to
|
|
27
|
-
* the built-in default.
|
|
28
|
-
*/
|
|
29
3
|
export function setLoaderSvg(svg) {
|
|
30
|
-
|
|
4
|
+
customLoaderSvg = svg && svg.trim() ? svg : null;
|
|
31
5
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Get the currently registered spinner SVG, or the built-in default if
|
|
34
|
-
* none has been set. Components call this on every render.
|
|
35
|
-
*/
|
|
36
6
|
export function getLoaderSvg() {
|
|
37
|
-
|
|
7
|
+
return customLoaderSvg ?? DEFAULT_LOADER_SVG;
|
|
38
8
|
}
|
|
39
|
-
/** Reset the registered loader back to the built-in default. */
|
|
40
9
|
export function resetLoaderSvg() {
|
|
41
|
-
|
|
10
|
+
customLoaderSvg = null;
|
|
42
11
|
}
|
|
43
|
-
//# sourceMappingURL=loader-registry.js.map
|
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.
|
|
@@ -76,4 +56,3 @@ export declare function getEffectiveLocale(element: HTMLElement, explicitLocale?
|
|
|
76
56
|
* ```
|
|
77
57
|
*/
|
|
78
58
|
export declare function observeLocaleChanges(element: HTMLElement, callback: (newLocale: string) => void): () => void;
|
|
79
|
-
//# sourceMappingURL=locale.d.ts.map
|