tyrell-components 1.0.0-RC13 → 1.0.0-RC14
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 +1 -1
- package/css/tyrell-theme.css +167 -178
- package/css/tyrell.css +19 -0
- package/dist/tyrell-theme.css +167 -178
- package/dist/tyrell.css +19 -0
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +20 -10
- package/lib/base/ty-component.js +21 -144
- package/lib/components/button.d.ts +2 -16
- package/lib/components/button.js +0 -36
- package/lib/components/calendar-month.d.ts +2 -48
- package/lib/components/calendar-month.js +4 -166
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +3 -126
- package/lib/components/calendar.d.ts +3 -80
- package/lib/components/calendar.js +8 -230
- package/lib/components/checkbox.d.ts +4 -71
- package/lib/components/checkbox.js +7 -151
- package/lib/components/copy.d.ts +3 -56
- package/lib/components/copy.js +1 -120
- package/lib/components/date-picker.d.ts +13 -162
- package/lib/components/date-picker.js +41 -592
- package/lib/components/file-upload.d.ts +9 -15
- package/lib/components/file-upload.js +19 -41
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +1 -90
- package/lib/components/input.d.ts +7 -107
- package/lib/components/input.js +5 -193
- package/lib/components/modal.d.ts +17 -26
- package/lib/components/modal.js +57 -201
- package/lib/components/option.d.ts +2 -9
- package/lib/components/option.js +0 -48
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +8 -139
- package/lib/components/radio.d.ts +3 -23
- package/lib/components/radio.js +10 -65
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +12 -46
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +3 -46
- package/lib/components/select.d.ts +22 -153
- package/lib/components/select.js +33 -590
- package/lib/components/selected-tags.d.ts +4 -47
- package/lib/components/selected-tags.js +1 -95
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +0 -6
- package/lib/components/switch.d.ts +0 -11
- package/lib/components/switch.js +2 -36
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +0 -7
- package/lib/components/tabs.d.ts +5 -63
- package/lib/components/tabs.js +20 -283
- package/lib/components/tag.d.ts +2 -36
- package/lib/components/tag.js +5 -105
- package/lib/components/textarea.d.ts +6 -86
- package/lib/components/textarea.js +2 -173
- package/lib/components/tooltip.d.ts +3 -11
- package/lib/components/tooltip.js +24 -160
- package/lib/components/wizard.d.ts +6 -54
- package/lib/components/wizard.js +15 -228
- 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 +0 -8
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +0 -8
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +0 -8
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +0 -8
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +0 -1872
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +0 -10
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +0 -10
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +0 -10
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +0 -10
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +0 -10
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -20
- package/lib/styles/button.d.ts +2 -20
- package/lib/styles/button.js +22 -122
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +4 -61
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +2 -27
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +1 -14
- package/lib/styles/checkbox.d.ts +0 -1
- package/lib/styles/checkbox.js +1 -23
- package/lib/styles/copy.d.ts +0 -1
- package/lib/styles/copy.js +2 -17
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +3 -18
- package/lib/styles/date-picker.d.ts +1 -5
- package/lib/styles/date-picker.js +35 -39
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +1 -16
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +7 -21
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +5 -54
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +21 -23
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +17 -12
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +26 -30
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +2 -16
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +0 -7
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +0 -19
- package/lib/styles/select-base.d.ts +0 -1
- package/lib/styles/select-base.js +68 -79
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +7 -15
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +0 -4
- package/lib/styles/switch.d.ts +0 -1
- package/lib/styles/switch.js +2 -20
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +0 -5
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +10 -48
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +2 -31
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +2 -45
- package/lib/styles/tooltip.d.ts +0 -1
- package/lib/styles/tooltip.js +0 -10
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +8 -88
- package/lib/types/common.d.ts +0 -2
- package/lib/types/common.js +0 -12
- package/lib/utils/calendar-utils.d.ts +4 -21
- package/lib/utils/calendar-utils.js +4 -177
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +1 -45
- package/lib/utils/flavor-sheet.d.ts +0 -1
- package/lib/utils/flavor-sheet.js +0 -23
- package/lib/utils/icon-registry.d.ts +0 -2
- package/lib/utils/icon-registry.js +1 -107
- 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 +0 -32
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +0 -86
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +0 -17
- package/lib/utils/number-format.d.ts +6 -3
- package/lib/utils/number-format.js +11 -67
- package/lib/utils/positioning.d.ts +50 -7
- package/lib/utils/positioning.js +52 -62
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +0 -108
- package/lib/utils/property-manager.d.ts +0 -1
- package/lib/utils/property-manager.js +0 -70
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +0 -36
- package/lib/utils/scroll-lock.d.ts +4 -11
- package/lib/utils/scroll-lock.js +0 -107
- package/lib/utils/styles.d.ts +0 -1
- package/lib/utils/styles.js +0 -24
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +2 -2
- 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,23 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CustomScrollbar -
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* const scrollbar = new CustomScrollbar(scrollEl, { vertical: true })
|
|
11
|
-
* // scrollbar.trackY, scrollbar.thumbY — append these to your DOM
|
|
12
|
-
* // scrollbar.trackX, scrollbar.thumbX — for horizontal
|
|
13
|
-
* scrollbar.destroy() // cleanup
|
|
14
|
-
*
|
|
15
|
-
* CSS classes applied:
|
|
16
|
-
* .ty-scrollbar-track-y / .ty-scrollbar-track-x
|
|
17
|
-
* .ty-scrollbar-thumb-y / .ty-scrollbar-thumb-x
|
|
18
|
-
* .has-overflow — when content overflows
|
|
19
|
-
* .dragging — during thumb drag
|
|
20
|
-
* .scrolling — briefly after scroll (auto-hide)
|
|
2
|
+
* CustomScrollbar - attaches a rendered scrollbar (vertical and/or horizontal)
|
|
3
|
+
* to any scrollable element. Overlay approach: native overflow:auto is kept for
|
|
4
|
+
* scroll physics, the native scrollbar is hidden via CSS, and custom track/thumb
|
|
5
|
+
* elements are synced on top. Append `trackY`/`trackX` to your DOM; `destroy()`
|
|
6
|
+
* cleans up. Classes: `.ty-scrollbar-{track,thumb}-{y,x}` plus state classes
|
|
7
|
+
* `.has-overflow`, `.dragging`, `.scrolling` (brief auto-hide after scroll).
|
|
21
8
|
*/
|
|
22
9
|
export interface CustomScrollbarOptions {
|
|
23
10
|
vertical?: boolean;
|
|
@@ -79,4 +66,3 @@ export declare class CustomScrollbar {
|
|
|
79
66
|
private _handleTrackYDown;
|
|
80
67
|
private _handleTrackXDown;
|
|
81
68
|
}
|
|
82
|
-
//# sourceMappingURL=custom-scrollbar.d.ts.map
|
|
@@ -1,40 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CustomScrollbar - Reusable scrollbar utility
|
|
3
|
-
*
|
|
4
|
-
* Attaches a custom rendered scrollbar (vertical and/or horizontal) to any
|
|
5
|
-
* scrollable element. Uses the overlay approach: native overflow:auto is
|
|
6
|
-
* preserved for scroll physics, native scrollbar is hidden via CSS,
|
|
7
|
-
* and custom track/thumb elements are synced on top.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* const scrollbar = new CustomScrollbar(scrollEl, { vertical: true })
|
|
11
|
-
* // scrollbar.trackY, scrollbar.thumbY — append these to your DOM
|
|
12
|
-
* // scrollbar.trackX, scrollbar.thumbX — for horizontal
|
|
13
|
-
* scrollbar.destroy() // cleanup
|
|
14
|
-
*
|
|
15
|
-
* CSS classes applied:
|
|
16
|
-
* .ty-scrollbar-track-y / .ty-scrollbar-track-x
|
|
17
|
-
* .ty-scrollbar-thumb-y / .ty-scrollbar-thumb-x
|
|
18
|
-
* .has-overflow — when content overflows
|
|
19
|
-
* .dragging — during thumb drag
|
|
20
|
-
* .scrolling — briefly after scroll (auto-hide)
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Check if custom scrollbar is enabled globally.
|
|
24
|
-
* Default: true (custom scrollbar on).
|
|
25
|
-
* Set data-ty-scrollbar="native" on <html> to opt out.
|
|
26
|
-
*/
|
|
27
1
|
export function isCustomScrollbarEnabled() {
|
|
28
2
|
return document.documentElement.getAttribute('data-ty-scrollbar') !== 'native';
|
|
29
3
|
}
|
|
30
4
|
export class CustomScrollbar {
|
|
31
5
|
constructor(scrollEl, options = {}) {
|
|
32
|
-
// Elements
|
|
33
6
|
this.trackY = null;
|
|
34
7
|
this.thumbY = null;
|
|
35
8
|
this.trackX = null;
|
|
36
9
|
this.thumbX = null;
|
|
37
|
-
// State
|
|
38
10
|
this._isDragging = false;
|
|
39
11
|
this._dragAxis = 'y';
|
|
40
12
|
this._dragStartPos = 0;
|
|
@@ -43,10 +15,9 @@ export class CustomScrollbar {
|
|
|
43
15
|
this._hideTimeout = null;
|
|
44
16
|
this._resizeObserver = null;
|
|
45
17
|
this._scrollEl = scrollEl;
|
|
46
|
-
this._vertical = options.vertical !== false;
|
|
18
|
+
this._vertical = options.vertical !== false;
|
|
47
19
|
this._horizontal = options.horizontal ?? false;
|
|
48
20
|
this._autoHideDelay = options.autoHideDelay ?? 1000;
|
|
49
|
-
// Bind handlers
|
|
50
21
|
this._onScroll = this._handleScroll.bind(this);
|
|
51
22
|
this._onThumbYDown = this._handleThumbYDown.bind(this);
|
|
52
23
|
this._onThumbXDown = this._handleThumbXDown.bind(this);
|
|
@@ -54,7 +25,6 @@ export class CustomScrollbar {
|
|
|
54
25
|
this._onTrackXDown = this._handleTrackXDown.bind(this);
|
|
55
26
|
this._onDragMove = this._handleDragMove.bind(this);
|
|
56
27
|
this._onDragEnd = this._handleDragEnd.bind(this);
|
|
57
|
-
// Create elements
|
|
58
28
|
if (this._vertical) {
|
|
59
29
|
this.trackY = this._createTrack('y');
|
|
60
30
|
this.thumbY = this._createThumb('y');
|
|
@@ -65,7 +35,6 @@ export class CustomScrollbar {
|
|
|
65
35
|
this.thumbX = this._createThumb('x');
|
|
66
36
|
this.trackX.appendChild(this.thumbX);
|
|
67
37
|
}
|
|
68
|
-
// Attach listeners
|
|
69
38
|
this._scrollEl.addEventListener('scroll', this._onScroll, { passive: true });
|
|
70
39
|
if (this.thumbY) {
|
|
71
40
|
this.thumbY.addEventListener('pointerdown', this._onThumbYDown);
|
|
@@ -79,13 +48,10 @@ export class CustomScrollbar {
|
|
|
79
48
|
if (this.trackX) {
|
|
80
49
|
this.trackX.addEventListener('pointerdown', this._onTrackXDown);
|
|
81
50
|
}
|
|
82
|
-
// ResizeObserver
|
|
83
51
|
this._resizeObserver = new ResizeObserver(() => this.update());
|
|
84
52
|
this._resizeObserver.observe(this._scrollEl);
|
|
85
|
-
// Initial update
|
|
86
53
|
this.update();
|
|
87
54
|
}
|
|
88
|
-
// ============ Element Creation ============
|
|
89
55
|
_createTrack(axis) {
|
|
90
56
|
const el = document.createElement('div');
|
|
91
57
|
el.className = `ty-scrollbar-track-${axis}`;
|
|
@@ -96,13 +62,10 @@ export class CustomScrollbar {
|
|
|
96
62
|
el.className = `ty-scrollbar-thumb-${axis}`;
|
|
97
63
|
return el;
|
|
98
64
|
}
|
|
99
|
-
// ============ Public API ============
|
|
100
|
-
/** Force update thumb size and position */
|
|
101
65
|
update() {
|
|
102
66
|
this._updateVertical();
|
|
103
67
|
this._updateHorizontal();
|
|
104
68
|
}
|
|
105
|
-
/** Reset scroll position */
|
|
106
69
|
scrollToTop(smooth = false) {
|
|
107
70
|
this._scrollEl.scrollTo({ top: 0, behavior: smooth ? 'smooth' : 'auto' });
|
|
108
71
|
}
|
|
@@ -115,7 +78,6 @@ export class CustomScrollbar {
|
|
|
115
78
|
scrollToRight(smooth = false) {
|
|
116
79
|
this._scrollEl.scrollTo({ left: this._scrollEl.scrollWidth, behavior: smooth ? 'smooth' : 'auto' });
|
|
117
80
|
}
|
|
118
|
-
/** Cleanup all listeners and observers */
|
|
119
81
|
destroy() {
|
|
120
82
|
this._scrollEl.removeEventListener('scroll', this._onScroll);
|
|
121
83
|
if (this.thumbY) {
|
|
@@ -143,7 +105,6 @@ export class CustomScrollbar {
|
|
|
143
105
|
this._hideTimeout = null;
|
|
144
106
|
}
|
|
145
107
|
}
|
|
146
|
-
// ============ Scroll Handler ============
|
|
147
108
|
_handleScroll() {
|
|
148
109
|
if (this._rafId !== null)
|
|
149
110
|
return;
|
|
@@ -153,7 +114,6 @@ export class CustomScrollbar {
|
|
|
153
114
|
this._showScrollbars();
|
|
154
115
|
});
|
|
155
116
|
}
|
|
156
|
-
// ============ Update Logic ============
|
|
157
117
|
_updateVertical() {
|
|
158
118
|
if (!this.trackY || !this.thumbY)
|
|
159
119
|
return;
|
|
@@ -208,7 +168,6 @@ export class CustomScrollbar {
|
|
|
208
168
|
const maxThumbLeft = trackWidth - thumbWidth;
|
|
209
169
|
this.thumbX.style.left = `${scrollRatio * maxThumbLeft}px`;
|
|
210
170
|
}
|
|
211
|
-
// ============ Auto-hide ============
|
|
212
171
|
_showScrollbars() {
|
|
213
172
|
if (this._isDragging)
|
|
214
173
|
return;
|
|
@@ -223,7 +182,6 @@ export class CustomScrollbar {
|
|
|
223
182
|
this._hideTimeout = null;
|
|
224
183
|
}, this._autoHideDelay);
|
|
225
184
|
}
|
|
226
|
-
// ============ Thumb Drag ============
|
|
227
185
|
_handleThumbYDown(e) {
|
|
228
186
|
if (e.button !== 0)
|
|
229
187
|
return;
|
|
@@ -291,7 +249,6 @@ export class CustomScrollbar {
|
|
|
291
249
|
thumb.removeEventListener('pointercancel', this._onDragEnd);
|
|
292
250
|
this._showScrollbars();
|
|
293
251
|
}
|
|
294
|
-
// ============ Track Click ============
|
|
295
252
|
_handleTrackYDown(e) {
|
|
296
253
|
if (e.target === this.thumbY || e.button !== 0)
|
|
297
254
|
return;
|
|
@@ -317,4 +274,3 @@ export class CustomScrollbar {
|
|
|
317
274
|
});
|
|
318
275
|
}
|
|
319
276
|
}
|
|
320
|
-
//# sourceMappingURL=custom-scrollbar.js.map
|
|
@@ -29,4 +29,3 @@ export interface CustomFlavorParts {
|
|
|
29
29
|
* adopted into the shadow root. Returns the sheet to store for the next call.
|
|
30
30
|
*/
|
|
31
31
|
export declare function syncCustomFlavorSheet(shadow: ShadowRoot, sheet: CSSStyleSheet | null, flavor: unknown, css: (parts: CustomFlavorParts) => string): CSSStyleSheet | null;
|
|
32
|
-
//# sourceMappingURL=flavor-sheet.d.ts.map
|
|
@@ -1,26 +1,4 @@
|
|
|
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
3
|
const full = String(flavor || '');
|
|
26
4
|
const base = full.replace(/[+-]$/, '');
|
|
@@ -37,4 +15,3 @@ export function syncCustomFlavorSheet(shadow, sheet, flavor, css) {
|
|
|
37
15
|
sheet.replaceSync(css({ flavor: full, base, shade: full.slice(base.length) }));
|
|
38
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,30 +1,13 @@
|
|
|
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
12
|
if (oldCachesCleared || !('caches' in window))
|
|
30
13
|
return;
|
|
@@ -41,11 +24,6 @@ async function clearOldCaches() {
|
|
|
41
24
|
console.warn('[ty-icons] Failed to clear old caches:', err);
|
|
42
25
|
}
|
|
43
26
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Cache an icon in Cache API (non-blocking background operation)
|
|
46
|
-
* @param name Icon name
|
|
47
|
-
* @param svg SVG string
|
|
48
|
-
*/
|
|
49
27
|
async function cacheIcon(name, svg) {
|
|
50
28
|
if (!('caches' in window))
|
|
51
29
|
return;
|
|
@@ -54,30 +32,19 @@ async function cacheIcon(name, svg) {
|
|
|
54
32
|
const response = new Response(svg, {
|
|
55
33
|
headers: { 'Content-Type': 'image/svg+xml' }
|
|
56
34
|
});
|
|
57
|
-
// Cache API requires valid URLs
|
|
58
35
|
await cache.put(`${CACHE_URL_BASE}${name}`, response);
|
|
59
36
|
}
|
|
60
37
|
catch (err) {
|
|
61
|
-
// Silent fail - caching is an optimization, not critical
|
|
62
38
|
console.warn(`[ty-icons] Failed to cache icon "${name}":`, err);
|
|
63
39
|
}
|
|
64
40
|
}
|
|
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
|
-
*/
|
|
71
41
|
export async function getCachedIcon(name) {
|
|
72
|
-
// Check if we already have a read in progress for this icon
|
|
73
42
|
const existingPromise = cacheReadPromises.get(name);
|
|
74
43
|
if (existingPromise) {
|
|
75
44
|
return existingPromise;
|
|
76
45
|
}
|
|
77
|
-
// Create new read promise
|
|
78
46
|
const readPromise = (async () => {
|
|
79
47
|
try {
|
|
80
|
-
// Clear old caches on first cache access
|
|
81
48
|
await clearOldCaches();
|
|
82
49
|
const cache = await caches.open(CACHE_NAME);
|
|
83
50
|
const response = await cache.match(`${CACHE_URL_BASE}${name}`);
|
|
@@ -90,77 +57,35 @@ export async function getCachedIcon(name) {
|
|
|
90
57
|
}
|
|
91
58
|
return null;
|
|
92
59
|
})();
|
|
93
|
-
// Store promise to avoid duplicate work
|
|
94
60
|
cacheReadPromises.set(name, readPromise);
|
|
95
|
-
// Clean up promise after completion
|
|
96
61
|
readPromise.finally(() => {
|
|
97
62
|
cacheReadPromises.delete(name);
|
|
98
63
|
});
|
|
99
64
|
return readPromise;
|
|
100
65
|
}
|
|
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
|
-
*/
|
|
107
66
|
export function registerIcons(icons) {
|
|
108
67
|
const changedIcons = new Set();
|
|
109
68
|
Object.entries(icons).forEach(([name, svg]) => {
|
|
110
|
-
// Always set in memory registry (fast, synchronous)
|
|
111
69
|
iconRegistry.set(name, svg);
|
|
112
70
|
changedIcons.add(name);
|
|
113
|
-
// Compare with cache in background to avoid unnecessary cache writes
|
|
114
|
-
/*getCachedIcon(name).then(cachedSvg => {
|
|
115
|
-
// Only write to cache if content actually changed
|
|
116
|
-
if (cachedSvg !== svg) {
|
|
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
71
|
});
|
|
130
|
-
// Notify watchers immediately (synchronous)
|
|
131
72
|
if (changedIcons.size > 0) {
|
|
132
73
|
scheduleNotification(changedIcons);
|
|
133
74
|
}
|
|
134
75
|
}
|
|
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
|
-
*/
|
|
141
76
|
export function getIcon(name) {
|
|
142
77
|
return iconRegistry.get(name);
|
|
143
78
|
}
|
|
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
|
-
*/
|
|
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
83
|
const allIcons = new Set(iconRegistry.keys());
|
|
158
84
|
iconRegistry.clear();
|
|
159
|
-
// Clear cache
|
|
160
85
|
if ('caches' in window) {
|
|
161
86
|
try {
|
|
162
87
|
await caches.delete(CACHE_NAME);
|
|
163
|
-
oldCachesCleared = false;
|
|
88
|
+
oldCachesCleared = false;
|
|
164
89
|
}
|
|
165
90
|
catch (err) {
|
|
166
91
|
console.warn('[ty-icons] Failed to clear icon cache:', err);
|
|
@@ -168,40 +93,24 @@ export async function clearIcons() {
|
|
|
168
93
|
}
|
|
169
94
|
scheduleNotification(allIcons);
|
|
170
95
|
}
|
|
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
|
-
*/
|
|
177
96
|
export function addWatcher(id, iconName, callback) {
|
|
178
97
|
watchers.set(id, callback);
|
|
179
98
|
if (iconName) {
|
|
180
99
|
watcherIconNames.set(id, iconName);
|
|
181
100
|
}
|
|
182
101
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Remove a watcher
|
|
185
|
-
* @param id Watcher ID to remove
|
|
186
|
-
*/
|
|
187
102
|
export function removeWatcher(id) {
|
|
188
103
|
watchers.delete(id);
|
|
189
104
|
watcherIconNames.delete(id);
|
|
190
105
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Schedule notification for changed icons (batched and deferred)
|
|
193
|
-
*/
|
|
194
106
|
function scheduleNotification(changedIcons) {
|
|
195
|
-
// Accumulate changed icons
|
|
196
107
|
if (!pendingNotifications) {
|
|
197
108
|
pendingNotifications = new Set();
|
|
198
109
|
}
|
|
199
110
|
changedIcons.forEach(name => pendingNotifications.add(name));
|
|
200
|
-
// Cancel existing timer
|
|
201
111
|
if (notificationTimer !== null) {
|
|
202
112
|
clearTimeout(notificationTimer);
|
|
203
113
|
}
|
|
204
|
-
// Schedule notification using requestIdleCallback or setTimeout
|
|
205
114
|
const scheduleCallback = typeof requestIdleCallback !== 'undefined'
|
|
206
115
|
? requestIdleCallback
|
|
207
116
|
: (cb) => setTimeout(cb, 0);
|
|
@@ -209,41 +118,27 @@ function scheduleNotification(changedIcons) {
|
|
|
209
118
|
const toNotify = pendingNotifications;
|
|
210
119
|
pendingNotifications = null;
|
|
211
120
|
notificationTimer = null;
|
|
212
|
-
// Only notify if we have icons to notify about
|
|
213
121
|
if (toNotify && toNotify.size > 0) {
|
|
214
122
|
notifyWatchers(toNotify);
|
|
215
123
|
}
|
|
216
124
|
});
|
|
217
125
|
}
|
|
218
|
-
/**
|
|
219
|
-
* Notify watchers of changed icons (selective notification)
|
|
220
|
-
*/
|
|
221
126
|
function notifyWatchers(changedIcons) {
|
|
222
127
|
watchers.forEach((callback, watcherId) => {
|
|
223
128
|
const watchedIcon = watcherIconNames.get(watcherId);
|
|
224
|
-
// If watcher is watching a specific icon, only notify if that icon changed
|
|
225
129
|
if (watchedIcon) {
|
|
226
130
|
if (changedIcons.has(watchedIcon)) {
|
|
227
131
|
callback(new Set([watchedIcon]));
|
|
228
132
|
}
|
|
229
133
|
}
|
|
230
134
|
else {
|
|
231
|
-
// Watcher wants all changes
|
|
232
135
|
callback(changedIcons);
|
|
233
136
|
}
|
|
234
137
|
});
|
|
235
138
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Get all registered icon names (memory only, not cache)
|
|
238
|
-
* @returns Array of icon names
|
|
239
|
-
*/
|
|
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
143
|
const info = {
|
|
249
144
|
version: VERSION,
|
|
@@ -266,4 +161,3 @@ export async function getCacheInfo() {
|
|
|
266
161
|
return info;
|
|
267
162
|
}
|
|
268
163
|
}
|
|
269
|
-
//# sourceMappingURL=icon-registry.js.map
|
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
|