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,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
3
|
import { getMonthName, parseISODate } 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'/>
|
|
@@ -74,56 +37,31 @@ const CHEVRONS_RIGHT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
|
|
|
74
37
|
</g>
|
|
75
38
|
</g>
|
|
76
39
|
</svg>`;
|
|
77
|
-
// ============================================================================
|
|
78
|
-
// Component Implementation
|
|
79
|
-
// ============================================================================
|
|
80
|
-
/**
|
|
81
|
-
* TyCalendarNavigation Web Component
|
|
82
|
-
*/
|
|
83
40
|
export class TyCalendarNavigation extends TyComponent {
|
|
84
41
|
constructor() {
|
|
85
|
-
super();
|
|
86
|
-
// Initialize state with current date
|
|
42
|
+
super();
|
|
87
43
|
const today = new Date();
|
|
88
44
|
this._state = {
|
|
89
45
|
displayMonth: today.getMonth() + 1,
|
|
90
46
|
displayYear: today.getFullYear()
|
|
91
47
|
};
|
|
92
|
-
// Initialize styles in shadow root
|
|
93
48
|
const shadow = this.shadowRoot;
|
|
94
49
|
ensureStyles(shadow, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
|
|
95
50
|
}
|
|
96
|
-
// ==========================================================================
|
|
97
|
-
// Lifecycle Hooks (TyComponent)
|
|
98
|
-
// ==========================================================================
|
|
99
|
-
/**
|
|
100
|
-
* Called when component connects to DOM
|
|
101
|
-
*/
|
|
102
51
|
onConnect() {
|
|
103
|
-
// Sync state from properties
|
|
104
52
|
this._state.displayMonth = this.displayMonth;
|
|
105
53
|
this._state.displayYear = this.displayYear;
|
|
106
|
-
// Setup locale observer to watch for ancestor lang changes
|
|
107
54
|
this._localeObserver = observeLocaleChanges(this, () => {
|
|
108
55
|
this.render();
|
|
109
56
|
});
|
|
110
|
-
// Initial render
|
|
111
57
|
this.render();
|
|
112
58
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Called when component disconnects from DOM
|
|
115
|
-
*/
|
|
116
59
|
onDisconnect() {
|
|
117
|
-
// Cleanup locale observer
|
|
118
60
|
if (this._localeObserver) {
|
|
119
61
|
this._localeObserver();
|
|
120
62
|
this._localeObserver = undefined;
|
|
121
63
|
}
|
|
122
64
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Called when properties change
|
|
125
|
-
* Update internal state BEFORE render
|
|
126
|
-
*/
|
|
127
65
|
onPropertiesChanged(changes) {
|
|
128
66
|
for (const { name, newValue } of changes) {
|
|
129
67
|
switch (name) {
|
|
@@ -136,15 +74,10 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
136
74
|
case 'locale':
|
|
137
75
|
case 'size':
|
|
138
76
|
case 'width':
|
|
139
|
-
// These properties just affect rendering
|
|
140
|
-
// TyComponent will call render() automatically for visual properties
|
|
141
77
|
break;
|
|
142
78
|
}
|
|
143
79
|
}
|
|
144
80
|
}
|
|
145
|
-
// ==========================================================================
|
|
146
|
-
// Property Accessors - Simple wrappers using TyComponent
|
|
147
|
-
// ==========================================================================
|
|
148
81
|
get displayMonth() {
|
|
149
82
|
return this.getProperty('display-month');
|
|
150
83
|
}
|
|
@@ -158,7 +91,6 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
158
91
|
this.setProperty('display-year', value);
|
|
159
92
|
}
|
|
160
93
|
get locale() {
|
|
161
|
-
// Use getEffectiveLocale to check ancestor lang attributes
|
|
162
94
|
return getEffectiveLocale(this, this.getProperty('locale'));
|
|
163
95
|
}
|
|
164
96
|
set locale(value) {
|
|
@@ -188,12 +120,6 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
188
120
|
set max(value) {
|
|
189
121
|
this.setProperty('max', value ?? '');
|
|
190
122
|
}
|
|
191
|
-
// ==========================================================================
|
|
192
|
-
// Event Dispatching
|
|
193
|
-
// ==========================================================================
|
|
194
|
-
/**
|
|
195
|
-
* Emit change event with new month/year
|
|
196
|
-
*/
|
|
197
123
|
emitChangeEvent(month, year) {
|
|
198
124
|
const detail = {
|
|
199
125
|
month,
|
|
@@ -206,18 +132,9 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
206
132
|
});
|
|
207
133
|
this.dispatchEvent(event);
|
|
208
134
|
}
|
|
209
|
-
// ==========================================================================
|
|
210
|
-
// Navigation Logic
|
|
211
|
-
// ==========================================================================
|
|
212
|
-
/**
|
|
213
|
-
* Month index (year * 12 + month - 1) — flat, comparable month math.
|
|
214
|
-
*/
|
|
215
135
|
static monthIndex(year, month) {
|
|
216
136
|
return year * 12 + (month - 1);
|
|
217
137
|
}
|
|
218
|
-
/**
|
|
219
|
-
* min/max as month indices (null when unset/invalid)
|
|
220
|
-
*/
|
|
221
138
|
boundIndices() {
|
|
222
139
|
const min = parseISODate(this.min);
|
|
223
140
|
const max = parseISODate(this.max);
|
|
@@ -226,9 +143,6 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
226
143
|
maxIdx: max ? TyCalendarNavigation.monthIndex(max.year, max.month) : null,
|
|
227
144
|
};
|
|
228
145
|
}
|
|
229
|
-
/**
|
|
230
|
-
* Clamp a target month index to [min, max]
|
|
231
|
-
*/
|
|
232
146
|
clampIndex(idx) {
|
|
233
147
|
const { minIdx, maxIdx } = this.boundIndices();
|
|
234
148
|
if (minIdx !== null && idx < minIdx)
|
|
@@ -237,30 +151,17 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
237
151
|
return maxIdx;
|
|
238
152
|
return idx;
|
|
239
153
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Navigate by month/year delta, clamped to bounds.
|
|
242
|
-
* Year jumps near a bound land ON the bound month instead of overshooting.
|
|
243
|
-
*/
|
|
244
154
|
navigateBy(deltaMonths) {
|
|
245
155
|
const current = TyCalendarNavigation.monthIndex(this._state.displayYear, this._state.displayMonth);
|
|
246
156
|
const target = this.clampIndex(current + deltaMonths);
|
|
247
157
|
if (target === current)
|
|
248
|
-
return;
|
|
158
|
+
return;
|
|
249
159
|
this.emitChangeEvent((target % 12) + 1, Math.floor(target / 12));
|
|
250
160
|
}
|
|
251
|
-
/**
|
|
252
|
-
* True when navigating by deltaMonths can't move the display (bound reached)
|
|
253
|
-
*/
|
|
254
161
|
isNavDisabled(deltaMonths) {
|
|
255
162
|
const current = TyCalendarNavigation.monthIndex(this._state.displayYear, this._state.displayMonth);
|
|
256
163
|
return this.clampIndex(current + deltaMonths) === current;
|
|
257
164
|
}
|
|
258
|
-
// ==========================================================================
|
|
259
|
-
// Rendering
|
|
260
|
-
// ==========================================================================
|
|
261
|
-
/**
|
|
262
|
-
* Create navigation button
|
|
263
|
-
*/
|
|
264
165
|
createButton(className, title, svg, onClick, disabled = false) {
|
|
265
166
|
const button = document.createElement('button');
|
|
266
167
|
button.className = className;
|
|
@@ -270,19 +171,13 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
270
171
|
button.addEventListener('click', onClick);
|
|
271
172
|
return button;
|
|
272
173
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Main render function
|
|
275
|
-
*/
|
|
276
174
|
render() {
|
|
277
175
|
const root = this.shadowRoot;
|
|
278
176
|
if (!root)
|
|
279
177
|
return;
|
|
280
|
-
// Ensure styles are loaded
|
|
281
178
|
ensureStyles(root, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
|
|
282
|
-
// Apply size as data attribute for CSS targeting
|
|
283
179
|
const size = this.size;
|
|
284
180
|
this.setAttribute('data-size', size);
|
|
285
|
-
// Apply width property as CSS custom property
|
|
286
181
|
const width = this.width;
|
|
287
182
|
if (width) {
|
|
288
183
|
this.style.setProperty('--nav-width', width);
|
|
@@ -290,46 +185,35 @@ export class TyCalendarNavigation extends TyComponent {
|
|
|
290
185
|
else {
|
|
291
186
|
this.style.removeProperty('--nav-width');
|
|
292
187
|
}
|
|
293
|
-
// Get localized month name using current state
|
|
294
188
|
const monthName = getMonthName(this._state.displayMonth, this.locale, 'long');
|
|
295
|
-
// Clear and rebuild
|
|
296
189
|
root.innerHTML = '';
|
|
297
|
-
// Create main header container
|
|
298
190
|
const header = document.createElement('div');
|
|
299
191
|
header.className = 'calendar-navigation-header';
|
|
300
|
-
// Left group: [⟪ ‹]
|
|
301
192
|
const leftGroup = document.createElement('div');
|
|
302
193
|
leftGroup.className = 'nav-group nav-group-left';
|
|
303
194
|
leftGroup.appendChild(this.createButton('nav-btn nav-year-prev', 'Previous year', CHEVRONS_LEFT_SVG, () => this.navigateBy(-12), this.isNavDisabled(-12)));
|
|
304
195
|
leftGroup.appendChild(this.createButton('nav-btn nav-month-prev', 'Previous month', CHEVRON_LEFT_SVG, () => this.navigateBy(-1), this.isNavDisabled(-1)));
|
|
305
|
-
// Center group: [Month Year]
|
|
306
196
|
const centerGroup = document.createElement('div');
|
|
307
197
|
centerGroup.className = 'nav-group nav-group-center';
|
|
308
198
|
const monthYearDisplay = document.createElement('div');
|
|
309
199
|
monthYearDisplay.className = 'month-year-display';
|
|
310
200
|
monthYearDisplay.textContent = `${monthName} ${this._state.displayYear}`;
|
|
311
201
|
centerGroup.appendChild(monthYearDisplay);
|
|
312
|
-
// Right group: [› ⟫]
|
|
313
202
|
const rightGroup = document.createElement('div');
|
|
314
203
|
rightGroup.className = 'nav-group nav-group-right';
|
|
315
204
|
rightGroup.appendChild(this.createButton('nav-btn nav-month-next', 'Next month', CHEVRON_RIGHT_SVG, () => this.navigateBy(1), this.isNavDisabled(1)));
|
|
316
205
|
rightGroup.appendChild(this.createButton('nav-btn nav-year-next', 'Next year', CHEVRONS_RIGHT_SVG, () => this.navigateBy(12), this.isNavDisabled(12)));
|
|
317
|
-
// Assemble header
|
|
318
206
|
header.appendChild(leftGroup);
|
|
319
207
|
header.appendChild(centerGroup);
|
|
320
208
|
header.appendChild(rightGroup);
|
|
321
209
|
root.appendChild(header);
|
|
322
210
|
}
|
|
323
211
|
}
|
|
324
|
-
// ============================================================================
|
|
325
|
-
// PROPERTY CONFIGURATION - Single source of truth
|
|
326
|
-
// ============================================================================
|
|
327
212
|
TyCalendarNavigation.properties = {
|
|
328
|
-
// Display properties
|
|
329
213
|
'display-month': {
|
|
330
214
|
type: 'number',
|
|
331
215
|
visual: true,
|
|
332
|
-
default: () => new Date().getMonth() + 1,
|
|
216
|
+
default: () => new Date().getMonth() + 1,
|
|
333
217
|
validate: (v) => {
|
|
334
218
|
const num = Number(v);
|
|
335
219
|
return Number.isInteger(num) && num >= 1 && num <= 12;
|
|
@@ -360,13 +244,11 @@ TyCalendarNavigation.properties = {
|
|
|
360
244
|
return num;
|
|
361
245
|
}
|
|
362
246
|
},
|
|
363
|
-
// Locale property
|
|
364
247
|
locale: {
|
|
365
248
|
type: 'string',
|
|
366
249
|
visual: true,
|
|
367
250
|
default: 'en-US'
|
|
368
251
|
},
|
|
369
|
-
// Size property
|
|
370
252
|
size: {
|
|
371
253
|
type: 'string',
|
|
372
254
|
visual: true,
|
|
@@ -380,14 +262,11 @@ TyCalendarNavigation.properties = {
|
|
|
380
262
|
return v;
|
|
381
263
|
}
|
|
382
264
|
},
|
|
383
|
-
// Width property
|
|
384
265
|
width: {
|
|
385
266
|
type: 'string',
|
|
386
267
|
visual: true,
|
|
387
268
|
default: ''
|
|
388
269
|
},
|
|
389
|
-
// Navigation bounds — ISO dates. Buttons that would move the display
|
|
390
|
-
// entirely outside [min, max] months are disabled; year jumps clamp.
|
|
391
270
|
min: {
|
|
392
271
|
type: 'string',
|
|
393
272
|
visual: true,
|
|
@@ -399,8 +278,6 @@ TyCalendarNavigation.properties = {
|
|
|
399
278
|
default: ''
|
|
400
279
|
}
|
|
401
280
|
};
|
|
402
|
-
// Register the custom element
|
|
403
281
|
if (!customElements.get('ty-calendar-navigation')) {
|
|
404
282
|
customElements.define('ty-calendar-navigation', TyCalendarNavigation);
|
|
405
283
|
}
|
|
406
|
-
//# sourceMappingURL=calendar-navigation.js.map
|
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TyCalendar Web Component
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* A complete calendar orchestration component that combines navigation and month display.
|
|
6
|
-
* Manages selection state, form participation, and event coordination.
|
|
7
|
-
*
|
|
8
|
-
* Architecture:
|
|
9
|
-
* - year/month/day HTML attributes for intuitive API
|
|
10
|
-
* - Internal state management (private properties)
|
|
11
|
-
* - Distributes properties to child components (navigation + month)
|
|
12
|
-
* - Single 'change' event with complete day context
|
|
13
|
-
* - Form participation via ElementInternals
|
|
14
|
-
*
|
|
15
|
-
* Features:
|
|
16
|
-
* - Combines ty-calendar-navigation + ty-calendar-month
|
|
17
|
-
* - Date selection with visual feedback
|
|
18
|
-
* - Form integration (works with FormData)
|
|
19
|
-
* - Custom render functions (dayContentFn)
|
|
20
|
-
* - Custom CSS injection
|
|
21
|
-
* - Automatic date validation
|
|
22
|
-
* - Event coordination between components
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```html
|
|
26
|
-
* <!-- Basic usage -->
|
|
27
|
-
* <ty-calendar
|
|
28
|
-
* year="2025"
|
|
29
|
-
* month="10"
|
|
30
|
-
* day="15">
|
|
31
|
-
* </ty-calendar>
|
|
32
|
-
*
|
|
33
|
-
* <!-- Form integration -->
|
|
34
|
-
* <form>
|
|
35
|
-
* <ty-calendar name="booking-date"></ty-calendar>
|
|
36
|
-
* <button type="submit">Submit</button>
|
|
37
|
-
* </form>
|
|
38
|
-
*
|
|
39
|
-
* <!-- With custom rendering -->
|
|
40
|
-
* <ty-calendar id="custom"></ty-calendar>
|
|
41
|
-
* <script type="module">
|
|
42
|
-
* const cal = document.getElementById('custom');
|
|
43
|
-
* cal.dayContentFn = (ctx) => {
|
|
44
|
-
* const el = document.createElement('div');
|
|
45
|
-
* el.textContent = ctx.dayInMonth;
|
|
46
|
-
* if (ctx.today) el.style.fontWeight = 'bold';
|
|
47
|
-
* return el;
|
|
48
|
-
* };
|
|
49
|
-
* </script>
|
|
50
|
-
* ```
|
|
2
|
+
* TyCalendar Web Component — orchestrates ty-calendar-navigation +
|
|
3
|
+
* ty-calendar-month: owns selection state, distributes properties to the
|
|
4
|
+
* children, and participates in forms via ElementInternals.
|
|
51
5
|
*/
|
|
52
6
|
import './calendar-month.js';
|
|
53
7
|
import './calendar-navigation.js';
|
|
@@ -91,13 +45,7 @@ export declare class TyCalendar extends HTMLElement {
|
|
|
91
45
|
private _monthDisplay?;
|
|
92
46
|
private _internals?;
|
|
93
47
|
private _localeObserver?;
|
|
94
|
-
/**
|
|
95
|
-
* Form-associated custom element
|
|
96
|
-
*/
|
|
97
48
|
static formAssociated: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Observed attributes
|
|
100
|
-
*/
|
|
101
49
|
static get observedAttributes(): string[];
|
|
102
50
|
constructor();
|
|
103
51
|
connectedCallback(): void;
|
|
@@ -135,47 +83,22 @@ export declare class TyCalendar extends HTMLElement {
|
|
|
135
83
|
* Initialize state from HTML attributes on first load
|
|
136
84
|
*/
|
|
137
85
|
private initializeFromAttributes;
|
|
138
|
-
/**
|
|
139
|
-
* Sync state from changed attributes
|
|
140
|
-
*/
|
|
141
86
|
private syncStateFromAttributes;
|
|
142
|
-
/**
|
|
143
|
-
* Update child components with current state
|
|
144
|
-
*/
|
|
145
87
|
private syncChildComponents;
|
|
146
|
-
/**
|
|
147
|
-
* Update form value using ElementInternals
|
|
148
|
-
*/
|
|
149
88
|
private updateFormValue;
|
|
150
89
|
/**
|
|
151
90
|
* Selection outside [min, max] => rangeUnderflow/rangeOverflow.
|
|
152
91
|
* UI can't produce this (days are disabled), but programmatic values can.
|
|
153
92
|
*/
|
|
154
93
|
private updateValidity;
|
|
155
|
-
/**
|
|
156
|
-
* Handle navigation change (month/year navigation)
|
|
157
|
-
*/
|
|
158
94
|
private handleNavigationChange;
|
|
159
|
-
/**
|
|
160
|
-
* Handle day click (day selection)
|
|
161
|
-
*/
|
|
162
95
|
private handleDayClick;
|
|
163
96
|
/**
|
|
164
97
|
* Force re-render of the calendar
|
|
165
98
|
* Useful after updating dayContentFn or other dynamic properties
|
|
166
99
|
*/
|
|
167
100
|
refresh(): void;
|
|
168
|
-
/**
|
|
169
|
-
* Create navigation element
|
|
170
|
-
*/
|
|
171
101
|
private createNavigation;
|
|
172
|
-
/**
|
|
173
|
-
* Create month display element
|
|
174
|
-
*/
|
|
175
102
|
private createMonthDisplay;
|
|
176
|
-
/**
|
|
177
|
-
* Main render function
|
|
178
|
-
*/
|
|
179
103
|
private render;
|
|
180
104
|
}
|
|
181
|
-
//# sourceMappingURL=calendar.d.ts.map
|