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
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TyCalendarNavigation Web Component
|
|
3
|
-
* PORTED FROM: cljs/ty/components/calendar_navigation.cljs
|
|
4
|
-
*
|
|
5
|
-
* A pure presentation component for calendar month/year navigation.
|
|
6
|
-
* Stateless - all state comes from properties, changes emitted via events.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - Year/Month navigation (prev/next month, prev/next year)
|
|
10
|
-
* - Localized month name display
|
|
11
|
-
* - Custom event emission on navigation
|
|
12
|
-
* - Property-driven API (no internal state)
|
|
13
|
-
* - Inline SVG icons
|
|
14
|
-
* - Shadow DOM encapsulation
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```html
|
|
18
|
-
* <!-- Basic usage -->
|
|
19
|
-
* <ty-calendar-navigation
|
|
20
|
-
* display-month="10"
|
|
21
|
-
* display-year="2025"
|
|
22
|
-
* locale="en-US">
|
|
23
|
-
* </ty-calendar-navigation>
|
|
24
|
-
*
|
|
25
|
-
* <!-- Listen for changes -->
|
|
26
|
-
* <script type="module">
|
|
27
|
-
* const nav = document.querySelector('ty-calendar-navigation');
|
|
28
|
-
* nav.addEventListener('change', (e) => {
|
|
29
|
-
* console.log('New month:', e.detail.month);
|
|
30
|
-
* console.log('New year:', e.detail.year);
|
|
31
|
-
* });
|
|
32
|
-
* </script>
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
36
2
|
import { calendarNavigationStyles } from '../styles/calendar-navigation.js';
|
|
37
|
-
import { getMonthName } from '../utils/calendar-utils.js';
|
|
3
|
+
import { getMonthName, parseDateDay } from '../utils/calendar-utils.js';
|
|
38
4
|
import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
|
|
39
5
|
import { TyComponent } from '../base/ty-component.js';
|
|
40
|
-
// ============================================================================
|
|
41
|
-
// SVG Icons (Material Design)
|
|
42
|
-
// ============================================================================
|
|
43
6
|
const CHEVRON_LEFT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
|
|
44
7
|
<svg width='24' viewBox='0 0 24 24' height='24' xmlns='http://www.w3.org/2000/svg' stroke-width='0' stroke='currentColor' fill='currentColor'>
|
|
45
8
|
<path fill='none' d='M0 0h24v24H0V0z'/>
|
|
@@ -50,317 +13,295 @@ const CHEVRON_RIGHT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
|
|
|
50
13
|
<path fill='none' d='M0 0h24v24H0V0z'/>
|
|
51
14
|
<path d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z'/>
|
|
52
15
|
</svg>`;
|
|
53
|
-
const
|
|
54
|
-
<
|
|
55
|
-
<g>
|
|
56
|
-
<rect width='24' height='24' fill='none'/>
|
|
57
|
-
</g>
|
|
58
|
-
<g>
|
|
59
|
-
<g>
|
|
60
|
-
<polygon points='17.59,18 19,16.59 14.42,12 19,7.41 17.59,6 11.59,12'/>
|
|
61
|
-
<polygon points='11,18 12.41,16.59 7.83,12 12.41,7.41 11,6 5,12'/>
|
|
62
|
-
</g>
|
|
63
|
-
</g>
|
|
16
|
+
const CARET_DOWN_SVG = `<svg width='24' viewBox='0 0 24 24' height='24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>
|
|
17
|
+
<path d='m6 9 6 6 6-6'/>
|
|
64
18
|
</svg>`;
|
|
65
|
-
const CHEVRONS_RIGHT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
|
|
66
|
-
<svg width='24' viewBox='0 0 24 24' height='24' enable-background='new 0 0 24 24' xmlns='http://www.w3.org/2000/svg' stroke-width='0' stroke='currentColor' fill='currentColor'>
|
|
67
|
-
<g>
|
|
68
|
-
<rect width='24' height='24' fill='none'/>
|
|
69
|
-
</g>
|
|
70
|
-
<g>
|
|
71
|
-
<g>
|
|
72
|
-
<polygon points='6.41,6 5,7.41 9.58,12 5,16.59 6.41,18 12.41,12'/>
|
|
73
|
-
<polygon points='13,6 11.59,7.41 16.17,12 11.59,16.59 13,18 19,12'/>
|
|
74
|
-
</g>
|
|
75
|
-
</g>
|
|
76
|
-
</svg>`;
|
|
77
|
-
// ============================================================================
|
|
78
|
-
// Component Implementation
|
|
79
|
-
// ============================================================================
|
|
80
|
-
/**
|
|
81
|
-
* TyCalendarNavigation Web Component
|
|
82
|
-
*/
|
|
83
19
|
export class TyCalendarNavigation extends TyComponent {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
root.appendChild(header);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
// ============================================================================
|
|
297
|
-
// PROPERTY CONFIGURATION - Single source of truth
|
|
298
|
-
// ============================================================================
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
const today = new Date();
|
|
23
|
+
this._state = {
|
|
24
|
+
displayMonth: today.getMonth() + 1,
|
|
25
|
+
displayYear: today.getFullYear()
|
|
26
|
+
};
|
|
27
|
+
const shadow = this.shadowRoot;
|
|
28
|
+
ensureStyles(shadow, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
|
|
29
|
+
}
|
|
30
|
+
onConnect() {
|
|
31
|
+
this._state.displayMonth = this.displayMonth;
|
|
32
|
+
this._state.displayYear = this.displayYear;
|
|
33
|
+
this._localeObserver = observeLocaleChanges(this, () => {
|
|
34
|
+
if (!this.getProperty('locale'))
|
|
35
|
+
this.render();
|
|
36
|
+
});
|
|
37
|
+
this.render();
|
|
38
|
+
}
|
|
39
|
+
onDisconnect() {
|
|
40
|
+
if (this._localeObserver) {
|
|
41
|
+
this._localeObserver();
|
|
42
|
+
this._localeObserver = undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
onPropertiesChanged(changes) {
|
|
46
|
+
for (const { name, newValue } of changes) {
|
|
47
|
+
switch (name) {
|
|
48
|
+
case 'display-month':
|
|
49
|
+
this._state.displayMonth = newValue;
|
|
50
|
+
break;
|
|
51
|
+
case 'display-year':
|
|
52
|
+
this._state.displayYear = newValue;
|
|
53
|
+
break;
|
|
54
|
+
case 'locale':
|
|
55
|
+
case 'size':
|
|
56
|
+
case 'width':
|
|
57
|
+
case 'view':
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
get displayMonth() {
|
|
63
|
+
return this.getProperty('display-month');
|
|
64
|
+
}
|
|
65
|
+
set displayMonth(value) {
|
|
66
|
+
this.setProperty('display-month', value);
|
|
67
|
+
}
|
|
68
|
+
get displayYear() {
|
|
69
|
+
return this.getProperty('display-year');
|
|
70
|
+
}
|
|
71
|
+
set displayYear(value) {
|
|
72
|
+
this.setProperty('display-year', value);
|
|
73
|
+
}
|
|
74
|
+
get locale() {
|
|
75
|
+
return getEffectiveLocale(this, this.getProperty('locale'));
|
|
76
|
+
}
|
|
77
|
+
set locale(value) {
|
|
78
|
+
this.setProperty('locale', value);
|
|
79
|
+
}
|
|
80
|
+
get size() {
|
|
81
|
+
return this.getProperty('size');
|
|
82
|
+
}
|
|
83
|
+
set size(value) {
|
|
84
|
+
this.setProperty('size', value);
|
|
85
|
+
}
|
|
86
|
+
get width() {
|
|
87
|
+
return this.getProperty('width');
|
|
88
|
+
}
|
|
89
|
+
set width(value) {
|
|
90
|
+
this.setProperty('width', value);
|
|
91
|
+
}
|
|
92
|
+
get view() {
|
|
93
|
+
return this.getProperty('view');
|
|
94
|
+
}
|
|
95
|
+
set view(value) {
|
|
96
|
+
this.setProperty('view', value);
|
|
97
|
+
}
|
|
98
|
+
get min() {
|
|
99
|
+
return this.getProperty('min');
|
|
100
|
+
}
|
|
101
|
+
set min(value) {
|
|
102
|
+
this.setProperty('min', value ?? '');
|
|
103
|
+
}
|
|
104
|
+
get max() {
|
|
105
|
+
return this.getProperty('max');
|
|
106
|
+
}
|
|
107
|
+
set max(value) {
|
|
108
|
+
this.setProperty('max', value ?? '');
|
|
109
|
+
}
|
|
110
|
+
emitChangeEvent(month, year) {
|
|
111
|
+
const detail = {
|
|
112
|
+
month,
|
|
113
|
+
year,
|
|
114
|
+
};
|
|
115
|
+
const event = new CustomEvent('change', {
|
|
116
|
+
detail,
|
|
117
|
+
bubbles: true,
|
|
118
|
+
cancelable: true,
|
|
119
|
+
});
|
|
120
|
+
this.dispatchEvent(event);
|
|
121
|
+
}
|
|
122
|
+
static monthIndex(year, month) {
|
|
123
|
+
return year * 12 + (month - 1);
|
|
124
|
+
}
|
|
125
|
+
boundIndices() {
|
|
126
|
+
const min = parseDateDay(this.min);
|
|
127
|
+
const max = parseDateDay(this.max);
|
|
128
|
+
return {
|
|
129
|
+
minIdx: min ? TyCalendarNavigation.monthIndex(min.year, min.month) : null,
|
|
130
|
+
maxIdx: max ? TyCalendarNavigation.monthIndex(max.year, max.month) : null,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
clampIndex(idx) {
|
|
134
|
+
const { minIdx, maxIdx } = this.boundIndices();
|
|
135
|
+
if (minIdx !== null && idx < minIdx)
|
|
136
|
+
return minIdx;
|
|
137
|
+
if (maxIdx !== null && idx > maxIdx)
|
|
138
|
+
return maxIdx;
|
|
139
|
+
return idx;
|
|
140
|
+
}
|
|
141
|
+
navigateBy(deltaMonths) {
|
|
142
|
+
const current = TyCalendarNavigation.monthIndex(this._state.displayYear, this._state.displayMonth);
|
|
143
|
+
const target = this.clampIndex(current + deltaMonths);
|
|
144
|
+
if (target === current)
|
|
145
|
+
return;
|
|
146
|
+
this.emitChangeEvent((target % 12) + 1, Math.floor(target / 12));
|
|
147
|
+
}
|
|
148
|
+
isNavDisabled(deltaMonths) {
|
|
149
|
+
const current = TyCalendarNavigation.monthIndex(this._state.displayYear, this._state.displayMonth);
|
|
150
|
+
return this.clampIndex(current + deltaMonths) === current;
|
|
151
|
+
}
|
|
152
|
+
createButton(className, title, svg, onClick, disabled = false) {
|
|
153
|
+
const button = document.createElement('button');
|
|
154
|
+
button.type = 'button';
|
|
155
|
+
button.className = className;
|
|
156
|
+
button.title = title;
|
|
157
|
+
button.setAttribute('aria-label', title);
|
|
158
|
+
button.innerHTML = svg;
|
|
159
|
+
button.disabled = disabled;
|
|
160
|
+
button.addEventListener('click', onClick);
|
|
161
|
+
return button;
|
|
162
|
+
}
|
|
163
|
+
render() {
|
|
164
|
+
const root = this.shadowRoot;
|
|
165
|
+
if (!root)
|
|
166
|
+
return;
|
|
167
|
+
ensureStyles(root, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
|
|
168
|
+
const size = this.size;
|
|
169
|
+
this.setAttribute('data-size', size);
|
|
170
|
+
const width = this.width;
|
|
171
|
+
if (width) {
|
|
172
|
+
this.style.setProperty('--nav-width', width);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.style.removeProperty('--nav-width');
|
|
176
|
+
}
|
|
177
|
+
const months = this.view === 'months';
|
|
178
|
+
const monthName = getMonthName(this._state.displayMonth, this.locale, 'long');
|
|
179
|
+
const had = root.activeElement;
|
|
180
|
+
const place = !had ? null
|
|
181
|
+
: had.classList.contains('nav-title') ? 'title'
|
|
182
|
+
: had.className.includes('-prev') ? 'prev'
|
|
183
|
+
: had.className.includes('-next') ? 'next'
|
|
184
|
+
: null;
|
|
185
|
+
root.innerHTML = '';
|
|
186
|
+
const header = document.createElement('div');
|
|
187
|
+
header.className = 'calendar-navigation-header';
|
|
188
|
+
const title = document.createElement('button');
|
|
189
|
+
title.type = 'button';
|
|
190
|
+
title.className = 'nav-title';
|
|
191
|
+
title.setAttribute('aria-expanded', String(months));
|
|
192
|
+
title.setAttribute('aria-label', months ? 'Back to days' : 'Choose month and year');
|
|
193
|
+
if (!months) {
|
|
194
|
+
const month = document.createElement('span');
|
|
195
|
+
month.className = 'nav-title-month';
|
|
196
|
+
month.textContent = monthName;
|
|
197
|
+
title.appendChild(month);
|
|
198
|
+
}
|
|
199
|
+
const year = document.createElement('span');
|
|
200
|
+
year.className = months ? 'nav-title-month' : 'nav-title-year';
|
|
201
|
+
year.textContent = String(this._state.displayYear);
|
|
202
|
+
title.appendChild(year);
|
|
203
|
+
const caret = document.createElement('span');
|
|
204
|
+
caret.className = 'nav-caret';
|
|
205
|
+
caret.innerHTML = CARET_DOWN_SVG;
|
|
206
|
+
title.appendChild(caret);
|
|
207
|
+
title.addEventListener('click', () => {
|
|
208
|
+
this.dispatchEvent(new CustomEvent('view-toggle', {
|
|
209
|
+
detail: { view: months ? 'days' : 'months' },
|
|
210
|
+
}));
|
|
211
|
+
});
|
|
212
|
+
const step = months ? 12 : 1;
|
|
213
|
+
const unit = months ? 'year' : 'month';
|
|
214
|
+
const arrows = document.createElement('div');
|
|
215
|
+
arrows.className = 'nav-group nav-arrows';
|
|
216
|
+
const prev = this.createButton(`nav-btn nav-${unit}-prev`, `Previous ${unit}`, CHEVRON_LEFT_SVG, () => this.navigateBy(-step), this.isNavDisabled(-step));
|
|
217
|
+
const next = this.createButton(`nav-btn nav-${unit}-next`, `Next ${unit}`, CHEVRON_RIGHT_SVG, () => this.navigateBy(step), this.isNavDisabled(step));
|
|
218
|
+
arrows.appendChild(prev);
|
|
219
|
+
arrows.appendChild(next);
|
|
220
|
+
header.appendChild(title);
|
|
221
|
+
header.appendChild(arrows);
|
|
222
|
+
root.appendChild(header);
|
|
223
|
+
if (place) {
|
|
224
|
+
const successor = place === 'prev' ? prev : place === 'next' ? next : title;
|
|
225
|
+
(successor.disabled ? title : successor).focus({ preventScroll: true });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
299
229
|
TyCalendarNavigation.properties = {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
230
|
+
'display-month': {
|
|
231
|
+
type: 'number',
|
|
232
|
+
visual: true,
|
|
233
|
+
default: () => new Date().getMonth() + 1,
|
|
234
|
+
validate: (v) => {
|
|
235
|
+
const num = Number(v);
|
|
236
|
+
return Number.isInteger(num) && num >= 1 && num <= 12;
|
|
237
|
+
},
|
|
238
|
+
coerce: (v) => {
|
|
239
|
+
const num = Number(v);
|
|
240
|
+
if (isNaN(num) || num < 1 || num > 12) {
|
|
241
|
+
console.warn(`[ty-calendar-navigation] Invalid month '${v}'. Using current month.`);
|
|
242
|
+
return new Date().getMonth() + 1;
|
|
243
|
+
}
|
|
244
|
+
return num;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
'display-year': {
|
|
248
|
+
type: 'number',
|
|
249
|
+
visual: true,
|
|
250
|
+
default: () => new Date().getFullYear(),
|
|
251
|
+
validate: (v) => {
|
|
252
|
+
const num = Number(v);
|
|
253
|
+
return Number.isInteger(num) && num >= 1 && num <= 9999;
|
|
254
|
+
},
|
|
255
|
+
coerce: (v) => {
|
|
256
|
+
const num = Number(v);
|
|
257
|
+
if (isNaN(num) || num < 1 || num > 9999) {
|
|
258
|
+
console.warn(`[ty-calendar-navigation] Invalid year '${v}'. Using current year.`);
|
|
259
|
+
return new Date().getFullYear();
|
|
260
|
+
}
|
|
261
|
+
return num;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
locale: {
|
|
265
|
+
type: 'string',
|
|
266
|
+
visual: true,
|
|
267
|
+
default: ''
|
|
268
|
+
},
|
|
269
|
+
size: {
|
|
270
|
+
type: 'string',
|
|
271
|
+
visual: true,
|
|
272
|
+
default: 'md',
|
|
273
|
+
validate: (v) => ['sm', 'md', 'lg'].includes(v),
|
|
274
|
+
coerce: (v) => {
|
|
275
|
+
if (!['sm', 'md', 'lg'].includes(v)) {
|
|
276
|
+
console.warn(`[ty-calendar-navigation] Invalid size '${v}'. Using 'md'.`);
|
|
277
|
+
return 'md';
|
|
278
|
+
}
|
|
279
|
+
return v;
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
width: {
|
|
283
|
+
type: 'string',
|
|
284
|
+
visual: true,
|
|
285
|
+
default: ''
|
|
286
|
+
},
|
|
287
|
+
view: {
|
|
288
|
+
type: 'string',
|
|
289
|
+
visual: true,
|
|
290
|
+
default: 'days',
|
|
291
|
+
validate: (v) => v === 'days' || v === 'months',
|
|
292
|
+
coerce: (v) => (v === 'months' ? 'months' : 'days')
|
|
293
|
+
},
|
|
294
|
+
min: {
|
|
295
|
+
type: 'string',
|
|
296
|
+
visual: true,
|
|
297
|
+
default: ''
|
|
298
|
+
},
|
|
299
|
+
max: {
|
|
300
|
+
type: 'string',
|
|
301
|
+
visual: true,
|
|
302
|
+
default: ''
|
|
303
|
+
}
|
|
361
304
|
};
|
|
362
|
-
// Register the custom element
|
|
363
305
|
if (!customElements.get('ty-calendar-navigation')) {
|
|
364
|
-
|
|
306
|
+
customElements.define('ty-calendar-navigation', TyCalendarNavigation);
|
|
365
307
|
}
|
|
366
|
-
//# sourceMappingURL=calendar-navigation.js.map
|