tyrell-components 1.0.0-RC13 → 1.0.0-RC15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/css/tyrell-theme.css +192 -180
- package/css/tyrell.css +23 -0
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1454
- package/dist/tyrell.css +1 -1371
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +20 -10
- package/lib/base/ty-component.js +196 -319
- package/lib/components/button.d.ts +3 -17
- package/lib/components/button.js +261 -295
- package/lib/components/calendar-month.d.ts +4 -50
- package/lib/components/calendar-month.js +443 -582
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +239 -362
- package/lib/components/calendar.d.ts +8 -83
- package/lib/components/calendar.js +616 -829
- package/lib/components/checkbox.d.ts +5 -72
- package/lib/components/checkbox.js +273 -416
- package/lib/components/copy.d.ts +4 -57
- package/lib/components/copy.js +280 -397
- package/lib/components/date-picker.d.ts +21 -163
- package/lib/components/date-picker.js +1143 -1674
- package/lib/components/file-upload.d.ts +9 -15
- package/lib/components/file-upload.js +404 -426
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +141 -230
- package/lib/components/input.d.ts +8 -108
- package/lib/components/input.js +593 -784
- package/lib/components/modal.d.ts +17 -26
- package/lib/components/modal.js +340 -484
- package/lib/components/option.d.ts +2 -9
- package/lib/components/option.js +168 -216
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +249 -380
- package/lib/components/radio.d.ts +5 -25
- package/lib/components/radio.js +407 -461
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +69 -103
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +293 -338
- package/lib/components/select.d.ts +87 -159
- package/lib/components/select.js +1609 -2090
- package/lib/components/selected-tags.d.ts +5 -48
- package/lib/components/selected-tags.js +188 -276
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +62 -68
- package/lib/components/switch.d.ts +1 -12
- package/lib/components/switch.js +214 -247
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +62 -69
- package/lib/components/tabs.d.ts +6 -63
- package/lib/components/tabs.js +545 -777
- package/lib/components/tag.d.ts +3 -37
- package/lib/components/tag.js +236 -335
- package/lib/components/textarea.d.ts +7 -87
- package/lib/components/textarea.js +457 -627
- package/lib/components/tooltip.d.ts +3 -11
- package/lib/components/tooltip.js +307 -443
- package/lib/components/wizard.d.ts +6 -54
- package/lib/components/wizard.js +405 -618
- package/lib/icons/fontawesome/brands.d.ts +0 -1
- package/lib/icons/fontawesome/brands.js +0 -8
- package/lib/icons/fontawesome/regular.d.ts +0 -1
- package/lib/icons/fontawesome/regular.js +0 -8
- package/lib/icons/fontawesome/solid.d.ts +0 -1
- package/lib/icons/fontawesome/solid.js +0 -8
- package/lib/icons/heroicons/micro.d.ts +0 -1
- package/lib/icons/heroicons/micro.js +392 -400
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +382 -390
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +337 -345
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +407 -415
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +24479 -26351
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +9653 -9663
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +10271 -10281
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +10495 -10505
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +9905 -9915
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +12792 -12802
- package/lib/index.d.ts +0 -1
- package/lib/index.js +21 -41
- package/lib/styles/button.d.ts +2 -20
- package/lib/styles/button.js +202 -404
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +127 -244
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +64 -104
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +9 -22
- package/lib/styles/checkbox.d.ts +0 -1
- package/lib/styles/checkbox.js +45 -94
- package/lib/styles/copy.d.ts +0 -1
- package/lib/styles/copy.js +67 -106
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +80 -115
- package/lib/styles/date-picker.d.ts +1 -5
- package/lib/styles/date-picker.js +261 -335
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +143 -188
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +92 -170
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +125 -290
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +71 -108
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +49 -64
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +42 -77
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +69 -110
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +2 -12
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +100 -149
- package/lib/styles/select-base.d.ts +0 -1
- package/lib/styles/select-base.js +597 -785
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +140 -236
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +22 -33
- package/lib/styles/switch.d.ts +0 -1
- package/lib/styles/switch.js +34 -73
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +22 -34
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +190 -222
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +136 -218
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +210 -319
- package/lib/styles/tooltip.d.ts +0 -1
- package/lib/styles/tooltip.js +3 -13
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +170 -306
- package/lib/types/common.d.ts +2 -2
- package/lib/types/common.js +6 -17
- package/lib/utils/calendar-utils.d.ts +4 -21
- package/lib/utils/calendar-utils.js +100 -273
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +273 -317
- package/lib/utils/flavor-sheet.d.ts +0 -1
- package/lib/utils/flavor-sheet.js +14 -37
- package/lib/utils/icon-registry.d.ts +0 -2
- package/lib/utils/icon-registry.js +137 -243
- package/lib/utils/icons.d.ts +0 -1
- package/lib/utils/icons.js +0 -9
- package/lib/utils/loader-registry.d.ts +0 -1
- package/lib/utils/loader-registry.js +3 -35
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +34 -120
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +1 -18
- package/lib/utils/number-format.d.ts +6 -3
- package/lib/utils/number-format.js +54 -110
- package/lib/utils/positioning.d.ts +50 -7
- package/lib/utils/positioning.js +224 -234
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +36 -144
- package/lib/utils/property-manager.d.ts +0 -1
- package/lib/utils/property-manager.js +126 -196
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +23 -59
- package/lib/utils/scroll-lock.d.ts +4 -11
- package/lib/utils/scroll-lock.js +65 -172
- package/lib/utils/styles.d.ts +0 -1
- package/lib/utils/styles.js +17 -41
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +4 -4
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/file-upload.d.ts.map +0 -1
- package/lib/components/file-upload.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js.map +0 -1
- package/lib/components/selected-tags.d.ts.map +0 -1
- package/lib/components/selected-tags.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/checkbox.d.ts.map +0 -1
- package/lib/styles/checkbox.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/custom-scrollbar.d.ts.map +0 -1
- package/lib/styles/custom-scrollbar.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/file-upload.d.ts.map +0 -1
- package/lib/styles/file-upload.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -8
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -849
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/radio.d.ts.map +0 -1
- package/lib/styles/radio.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/select-base.d.ts.map +0 -1
- package/lib/styles/select-base.js.map +0 -1
- package/lib/styles/select.d.ts.map +0 -1
- package/lib/styles/select.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/switch.d.ts.map +0 -1
- package/lib/styles/switch.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/custom-scrollbar.d.ts.map +0 -1
- package/lib/utils/custom-scrollbar.js.map +0 -1
- package/lib/utils/flavor-sheet.d.ts.map +0 -1
- package/lib/utils/flavor-sheet.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/icons.d.ts.map +0 -1
- package/lib/utils/icons.js.map +0 -1
- package/lib/utils/loader-registry.d.ts.map +0 -1
- package/lib/utils/loader-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/mobile.d.ts.map +0 -1
- package/lib/utils/mobile.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -58
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
|
@@ -1,845 +1,632 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TyCalendar Web Component
|
|
3
|
-
* PORTED FROM: cljs/ty/components/calendar.cljs
|
|
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
|
-
* ```
|
|
51
|
-
*/
|
|
52
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
53
2
|
import { calendarStyles } from '../styles/calendar.js';
|
|
54
|
-
// Side-effect imports: register the child elements this component createElements
|
|
55
3
|
import './calendar-month.js';
|
|
56
4
|
import './calendar-navigation.js';
|
|
57
5
|
import { parseISODate } from '../utils/calendar-utils.js';
|
|
58
6
|
import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
|
|
59
|
-
// ============================================================================
|
|
60
|
-
// Helper Functions
|
|
61
|
-
// ============================================================================
|
|
62
|
-
/**
|
|
63
|
-
* Get current date for defaults
|
|
64
|
-
*/
|
|
65
7
|
function getCurrentDate() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Validate and parse year from string
|
|
75
|
-
*/
|
|
8
|
+
const now = new Date();
|
|
9
|
+
return {
|
|
10
|
+
year: now.getFullYear(),
|
|
11
|
+
month: now.getMonth() + 1,
|
|
12
|
+
day: now.getDate(),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
76
15
|
function parseYear(yearStr) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
16
|
+
if (!yearStr || !/^\d{4}$/.test(yearStr))
|
|
17
|
+
return null;
|
|
18
|
+
return parseInt(yearStr, 10);
|
|
80
19
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Validate and parse month from string (1-12)
|
|
83
|
-
*/
|
|
84
20
|
function parseMonth(monthStr) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Validate and parse day from string (1-31, validated against month)
|
|
92
|
-
*/
|
|
21
|
+
if (!monthStr || !/^\d{1,2}$/.test(monthStr))
|
|
22
|
+
return null;
|
|
23
|
+
const month = parseInt(monthStr, 10);
|
|
24
|
+
return month >= 1 && month <= 12 ? month : null;
|
|
25
|
+
}
|
|
93
26
|
function parseDay(dayStr, year, month) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Format date as ISO string (YYYY-MM-DD) for form submission
|
|
103
|
-
*/
|
|
27
|
+
if (!dayStr || !/^\d{1,2}$/.test(dayStr))
|
|
28
|
+
return null;
|
|
29
|
+
const day = parseInt(dayStr, 10);
|
|
30
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
31
|
+
return day >= 1 && day <= daysInMonth ? day : null;
|
|
32
|
+
}
|
|
104
33
|
function formatDateISO(year, month, day) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
// ============================================================================
|
|
110
|
-
// Component Implementation
|
|
111
|
-
// ============================================================================
|
|
112
|
-
/**
|
|
113
|
-
* TyCalendar Web Component
|
|
114
|
-
*/
|
|
34
|
+
const monthStr = month.toString().padStart(2, '0');
|
|
35
|
+
const dayStr = day.toString().padStart(2, '0');
|
|
36
|
+
return `${year}-${monthStr}-${dayStr}`;
|
|
37
|
+
}
|
|
115
38
|
export class TyCalendar extends HTMLElement {
|
|
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
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
// Normal mode: update selection state
|
|
707
|
-
this._state.selectedYear = year;
|
|
708
|
-
this._state.selectedMonth = month;
|
|
709
|
-
this._state.selectedDay = day;
|
|
710
|
-
this._state.displayYear = year;
|
|
711
|
-
this._state.displayMonth = month;
|
|
712
|
-
// Update HTML attributes
|
|
713
|
-
this.setAttribute('year', year.toString());
|
|
714
|
-
this.setAttribute('month', month.toString());
|
|
715
|
-
this.setAttribute('day', day.toString());
|
|
716
|
-
// Update form value
|
|
717
|
-
this.updateFormValue();
|
|
718
|
-
// Sync child components
|
|
719
|
-
this.syncChildComponents();
|
|
720
|
-
// Emit change event
|
|
721
|
-
const changeDetail = {
|
|
722
|
-
year,
|
|
723
|
-
month,
|
|
724
|
-
day,
|
|
725
|
-
action: 'select',
|
|
726
|
-
source: 'day-click',
|
|
727
|
-
dayContext,
|
|
728
|
-
};
|
|
729
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
730
|
-
detail: changeDetail,
|
|
731
|
-
bubbles: true,
|
|
732
|
-
composed: true,
|
|
733
|
-
cancelable: false,
|
|
734
|
-
}));
|
|
735
|
-
}
|
|
736
|
-
// ==========================================================================
|
|
737
|
-
// Public Methods
|
|
738
|
-
// ==========================================================================
|
|
739
|
-
/**
|
|
740
|
-
* Force re-render of the calendar
|
|
741
|
-
* Useful after updating dayContentFn or other dynamic properties
|
|
742
|
-
*/
|
|
743
|
-
refresh() {
|
|
744
|
-
this.syncChildComponents();
|
|
745
|
-
// Force month display to re-render (for async data updates)
|
|
746
|
-
if (this._monthDisplay && typeof this._monthDisplay.refresh === 'function') {
|
|
747
|
-
this._monthDisplay.refresh();
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
// ==========================================================================
|
|
751
|
-
// Rendering
|
|
752
|
-
// ==========================================================================
|
|
753
|
-
/**
|
|
754
|
-
* Create navigation element
|
|
755
|
-
*/
|
|
756
|
-
createNavigation() {
|
|
757
|
-
const nav = document.createElement('ty-calendar-navigation');
|
|
758
|
-
// Set properties
|
|
759
|
-
nav.displayMonth = this._state.displayMonth;
|
|
760
|
-
nav.displayYear = this._state.displayYear;
|
|
761
|
-
nav.locale = this.locale;
|
|
762
|
-
nav.size = this._size;
|
|
763
|
-
nav.min = this._min ?? '';
|
|
764
|
-
nav.max = this._max ?? '';
|
|
765
|
-
// Only set width if explicitly provided
|
|
766
|
-
if (this._width) {
|
|
767
|
-
nav.width = this._width;
|
|
768
|
-
}
|
|
769
|
-
// Listen for change events
|
|
770
|
-
nav.addEventListener('change', (e) => this.handleNavigationChange(e));
|
|
771
|
-
// Store reference
|
|
772
|
-
this._navigation = nav;
|
|
773
|
-
return nav;
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Create month display element
|
|
777
|
-
*/
|
|
778
|
-
createMonthDisplay() {
|
|
779
|
-
const month = document.createElement('ty-calendar-month');
|
|
780
|
-
// Set properties
|
|
781
|
-
month.displayMonth = this._state.displayMonth;
|
|
782
|
-
month.displayYear = this._state.displayYear;
|
|
783
|
-
month.locale = this.locale;
|
|
784
|
-
month.size = this._size;
|
|
785
|
-
month.min = this._min;
|
|
786
|
-
month.max = this._max;
|
|
787
|
-
month.flavor = this._flavor;
|
|
788
|
-
// Only set width if explicitly provided
|
|
789
|
-
if (this._width) {
|
|
790
|
-
month.width = this._width;
|
|
791
|
-
}
|
|
792
|
-
// Set selection value if exists
|
|
793
|
-
const { selectedYear, selectedMonth, selectedDay } = this._state;
|
|
794
|
-
if (selectedYear && selectedMonth && selectedDay) {
|
|
795
|
-
const date = new Date(selectedYear, selectedMonth - 1, selectedDay);
|
|
796
|
-
month.value = date.getTime();
|
|
797
|
-
}
|
|
798
|
-
// Pass render functions
|
|
799
|
-
if (this._dayContentFn) {
|
|
800
|
-
month.dayContentFn = this._dayContentFn;
|
|
801
|
-
}
|
|
802
|
-
// Pass custom CSS
|
|
803
|
-
if (this._customCSS) {
|
|
804
|
-
month.customCSS = this._customCSS;
|
|
805
|
-
}
|
|
806
|
-
// Listen for day-click events
|
|
807
|
-
month.addEventListener('day-click', (e) => this.handleDayClick(e));
|
|
808
|
-
// Store reference
|
|
809
|
-
this._monthDisplay = month;
|
|
810
|
-
return month;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Main render function
|
|
814
|
-
*/
|
|
815
|
-
render() {
|
|
816
|
-
const root = this.shadowRoot;
|
|
817
|
-
if (!root)
|
|
818
|
-
return;
|
|
819
|
-
// Ensure styles are loaded
|
|
820
|
-
ensureStyles(root, { css: calendarStyles, id: 'ty-calendar' });
|
|
821
|
-
// Clear and rebuild
|
|
822
|
-
root.innerHTML = '';
|
|
823
|
-
// Create main container
|
|
824
|
-
const container = document.createElement('div');
|
|
825
|
-
container.className = 'calendar-container';
|
|
826
|
-
// Add navigation if requested
|
|
827
|
-
if (this._showNavigation) {
|
|
828
|
-
const nav = this.createNavigation();
|
|
829
|
-
container.appendChild(nav);
|
|
830
|
-
}
|
|
831
|
-
// Add month display
|
|
832
|
-
const month = this.createMonthDisplay();
|
|
833
|
-
container.appendChild(month);
|
|
834
|
-
root.appendChild(container);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Form-associated custom element
|
|
839
|
-
*/
|
|
39
|
+
static get observedAttributes() {
|
|
40
|
+
return ['value', 'year', 'month', 'day', 'hide-navigation', 'stateless', 'locale', 'name', 'size', 'width', 'min', 'max', 'flavor'];
|
|
41
|
+
}
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
this._hideNavigation = false;
|
|
45
|
+
this._stateless = false;
|
|
46
|
+
this._size = 'md';
|
|
47
|
+
this._flavor = 'primary';
|
|
48
|
+
this._initialValue = '';
|
|
49
|
+
const current = getCurrentDate();
|
|
50
|
+
this._state = {
|
|
51
|
+
displayYear: current.year,
|
|
52
|
+
displayMonth: current.month,
|
|
53
|
+
};
|
|
54
|
+
this.attachShadow({ mode: 'open' });
|
|
55
|
+
if ('attachInternals' in this) {
|
|
56
|
+
this._internals = this.attachInternals();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
connectedCallback() {
|
|
60
|
+
this.initializeFromAttributes();
|
|
61
|
+
const plainDayContentFn = this.dayContentFn;
|
|
62
|
+
if (plainDayContentFn && !this._dayContentFn) {
|
|
63
|
+
this._dayContentFn = plainDayContentFn;
|
|
64
|
+
delete this.dayContentFn;
|
|
65
|
+
}
|
|
66
|
+
const plainCustomCSS = this.customCSS;
|
|
67
|
+
if (plainCustomCSS && !this._customCSS) {
|
|
68
|
+
this._customCSS = plainCustomCSS;
|
|
69
|
+
delete this.customCSS;
|
|
70
|
+
}
|
|
71
|
+
const plainValue = this.value;
|
|
72
|
+
if (plainValue && typeof plainValue === 'string' && plainValue !== this.value) {
|
|
73
|
+
const match = plainValue.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
74
|
+
if (match) {
|
|
75
|
+
const year = parseInt(match[1], 10);
|
|
76
|
+
const month = parseInt(match[2], 10);
|
|
77
|
+
const day = parseInt(match[3], 10);
|
|
78
|
+
this._state.selectedYear = year;
|
|
79
|
+
this._state.selectedMonth = month;
|
|
80
|
+
this._state.selectedDay = day;
|
|
81
|
+
this._state.displayYear = year;
|
|
82
|
+
this._state.displayMonth = month;
|
|
83
|
+
if (!this._stateless) {
|
|
84
|
+
this.setAttribute('year', year.toString());
|
|
85
|
+
this.setAttribute('month', month.toString());
|
|
86
|
+
this.setAttribute('day', day.toString());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
delete this.value;
|
|
90
|
+
}
|
|
91
|
+
this.render();
|
|
92
|
+
this.updateFormValue();
|
|
93
|
+
this._localeObserver = observeLocaleChanges(this, () => {
|
|
94
|
+
this.render();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
if (this._localeObserver) {
|
|
99
|
+
this._localeObserver();
|
|
100
|
+
this._localeObserver = undefined;
|
|
101
|
+
}
|
|
102
|
+
this._navigation = undefined;
|
|
103
|
+
this._monthDisplay = undefined;
|
|
104
|
+
}
|
|
105
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
106
|
+
if (oldValue === newValue)
|
|
107
|
+
return;
|
|
108
|
+
switch (name) {
|
|
109
|
+
case 'value':
|
|
110
|
+
this.value = newValue || '';
|
|
111
|
+
break;
|
|
112
|
+
case 'year':
|
|
113
|
+
case 'month':
|
|
114
|
+
case 'day':
|
|
115
|
+
this.syncStateFromAttributes();
|
|
116
|
+
this.syncChildComponents();
|
|
117
|
+
this.updateFormValue();
|
|
118
|
+
break;
|
|
119
|
+
case 'hide-navigation':
|
|
120
|
+
this._hideNavigation = newValue !== null;
|
|
121
|
+
this.render();
|
|
122
|
+
break;
|
|
123
|
+
case 'stateless':
|
|
124
|
+
this._stateless = newValue !== null && newValue !== 'false';
|
|
125
|
+
break;
|
|
126
|
+
case 'locale':
|
|
127
|
+
this.syncChildComponents();
|
|
128
|
+
break;
|
|
129
|
+
case 'size':
|
|
130
|
+
if (newValue === 'sm' || newValue === 'md' || newValue === 'lg') {
|
|
131
|
+
this._size = newValue;
|
|
132
|
+
this._width = undefined;
|
|
133
|
+
this.removeAttribute('width');
|
|
134
|
+
this.syncChildComponents();
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case 'width':
|
|
138
|
+
this._width = newValue || undefined;
|
|
139
|
+
if (newValue) {
|
|
140
|
+
this._size = 'md';
|
|
141
|
+
this.removeAttribute('size');
|
|
142
|
+
}
|
|
143
|
+
this.syncChildComponents();
|
|
144
|
+
break;
|
|
145
|
+
case 'name':
|
|
146
|
+
this.updateFormValue();
|
|
147
|
+
break;
|
|
148
|
+
case 'min':
|
|
149
|
+
case 'max':
|
|
150
|
+
this[name === 'min' ? '_min' : '_max'] = newValue || undefined;
|
|
151
|
+
this.syncChildComponents();
|
|
152
|
+
this.updateValidity();
|
|
153
|
+
break;
|
|
154
|
+
case 'flavor':
|
|
155
|
+
this._flavor = newValue || 'primary';
|
|
156
|
+
this.syncChildComponents();
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
get min() {
|
|
161
|
+
return this._min;
|
|
162
|
+
}
|
|
163
|
+
set min(value) {
|
|
164
|
+
if (value)
|
|
165
|
+
this.setAttribute('min', value);
|
|
166
|
+
else
|
|
167
|
+
this.removeAttribute('min');
|
|
168
|
+
}
|
|
169
|
+
get max() {
|
|
170
|
+
return this._max;
|
|
171
|
+
}
|
|
172
|
+
set max(value) {
|
|
173
|
+
if (value)
|
|
174
|
+
this.setAttribute('max', value);
|
|
175
|
+
else
|
|
176
|
+
this.removeAttribute('max');
|
|
177
|
+
}
|
|
178
|
+
get flavor() {
|
|
179
|
+
return this._flavor;
|
|
180
|
+
}
|
|
181
|
+
set flavor(value) {
|
|
182
|
+
if (value)
|
|
183
|
+
this.setAttribute('flavor', value);
|
|
184
|
+
else
|
|
185
|
+
this.removeAttribute('flavor');
|
|
186
|
+
}
|
|
187
|
+
get year() {
|
|
188
|
+
return this._state.selectedYear;
|
|
189
|
+
}
|
|
190
|
+
set year(value) {
|
|
191
|
+
if (value !== undefined) {
|
|
192
|
+
if (this._stateless) {
|
|
193
|
+
this._state.displayYear = value;
|
|
194
|
+
this.setAttribute('year', value.toString());
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this._state.selectedYear = value;
|
|
198
|
+
this._state.displayYear = value;
|
|
199
|
+
this.setAttribute('year', value.toString());
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
if (!this._stateless) {
|
|
204
|
+
delete this._state.selectedYear;
|
|
205
|
+
}
|
|
206
|
+
this.removeAttribute('year');
|
|
207
|
+
}
|
|
208
|
+
this.syncChildComponents();
|
|
209
|
+
if (!this._stateless) {
|
|
210
|
+
this.updateFormValue();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
get month() {
|
|
214
|
+
return this._state.selectedMonth;
|
|
215
|
+
}
|
|
216
|
+
set month(value) {
|
|
217
|
+
if (value !== undefined) {
|
|
218
|
+
if (this._stateless) {
|
|
219
|
+
this._state.displayMonth = value;
|
|
220
|
+
this.setAttribute('month', value.toString());
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this._state.selectedMonth = value;
|
|
224
|
+
this._state.displayMonth = value;
|
|
225
|
+
this.setAttribute('month', value.toString());
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
if (!this._stateless) {
|
|
230
|
+
delete this._state.selectedMonth;
|
|
231
|
+
}
|
|
232
|
+
this.removeAttribute('month');
|
|
233
|
+
}
|
|
234
|
+
this.syncChildComponents();
|
|
235
|
+
if (!this._stateless) {
|
|
236
|
+
this.updateFormValue();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
get day() {
|
|
240
|
+
return this._state.selectedDay;
|
|
241
|
+
}
|
|
242
|
+
set day(value) {
|
|
243
|
+
if (value !== undefined) {
|
|
244
|
+
this._state.selectedDay = value;
|
|
245
|
+
this.setAttribute('day', value.toString());
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
delete this._state.selectedDay;
|
|
249
|
+
this.removeAttribute('day');
|
|
250
|
+
}
|
|
251
|
+
this.syncChildComponents();
|
|
252
|
+
this.updateFormValue();
|
|
253
|
+
}
|
|
254
|
+
get locale() {
|
|
255
|
+
return getEffectiveLocale(this, this.getAttribute('locale'));
|
|
256
|
+
}
|
|
257
|
+
set locale(value) {
|
|
258
|
+
this.setAttribute('locale', value);
|
|
259
|
+
}
|
|
260
|
+
get hideNavigation() {
|
|
261
|
+
return this._hideNavigation;
|
|
262
|
+
}
|
|
263
|
+
set hideNavigation(value) {
|
|
264
|
+
this._hideNavigation = value;
|
|
265
|
+
if (value)
|
|
266
|
+
this.setAttribute('hide-navigation', '');
|
|
267
|
+
else
|
|
268
|
+
this.removeAttribute('hide-navigation');
|
|
269
|
+
}
|
|
270
|
+
get stateless() {
|
|
271
|
+
return this._stateless;
|
|
272
|
+
}
|
|
273
|
+
set stateless(value) {
|
|
274
|
+
this._stateless = value;
|
|
275
|
+
if (value) {
|
|
276
|
+
this.setAttribute('stateless', '');
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
this.removeAttribute('stateless');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
get size() {
|
|
283
|
+
return this._size;
|
|
284
|
+
}
|
|
285
|
+
set size(value) {
|
|
286
|
+
if (this._size !== value) {
|
|
287
|
+
this._size = value;
|
|
288
|
+
this._width = undefined;
|
|
289
|
+
this.removeAttribute('width');
|
|
290
|
+
this.setAttribute('size', value);
|
|
291
|
+
this.syncChildComponents();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
get width() {
|
|
295
|
+
return this._width;
|
|
296
|
+
}
|
|
297
|
+
set width(value) {
|
|
298
|
+
if (this._width !== value) {
|
|
299
|
+
this._width = value;
|
|
300
|
+
if (value) {
|
|
301
|
+
this._size = 'md';
|
|
302
|
+
this.removeAttribute('size');
|
|
303
|
+
this.setAttribute('width', value);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.removeAttribute('width');
|
|
307
|
+
}
|
|
308
|
+
this.syncChildComponents();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
get dayContentFn() {
|
|
312
|
+
return this._dayContentFn;
|
|
313
|
+
}
|
|
314
|
+
set dayContentFn(fn) {
|
|
315
|
+
this._dayContentFn = fn;
|
|
316
|
+
this.syncChildComponents();
|
|
317
|
+
}
|
|
318
|
+
get customCSS() {
|
|
319
|
+
return this._customCSS;
|
|
320
|
+
}
|
|
321
|
+
set customCSS(sheet) {
|
|
322
|
+
this._customCSS = sheet;
|
|
323
|
+
this.syncChildComponents();
|
|
324
|
+
}
|
|
325
|
+
get value() {
|
|
326
|
+
const { selectedYear, selectedMonth, selectedDay } = this._state;
|
|
327
|
+
if (selectedYear && selectedMonth && selectedDay) {
|
|
328
|
+
return formatDateISO(selectedYear, selectedMonth, selectedDay);
|
|
329
|
+
}
|
|
330
|
+
return '';
|
|
331
|
+
}
|
|
332
|
+
set value(isoDate) {
|
|
333
|
+
if (!isoDate) {
|
|
334
|
+
delete this._state.selectedYear;
|
|
335
|
+
delete this._state.selectedMonth;
|
|
336
|
+
delete this._state.selectedDay;
|
|
337
|
+
if (!this._stateless) {
|
|
338
|
+
this.removeAttribute('year');
|
|
339
|
+
this.removeAttribute('month');
|
|
340
|
+
this.removeAttribute('day');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
const match = isoDate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
345
|
+
if (match) {
|
|
346
|
+
const year = parseInt(match[1], 10);
|
|
347
|
+
const month = parseInt(match[2], 10);
|
|
348
|
+
const day = parseInt(match[3], 10);
|
|
349
|
+
this._state.selectedYear = year;
|
|
350
|
+
this._state.selectedMonth = month;
|
|
351
|
+
this._state.selectedDay = day;
|
|
352
|
+
this._state.displayYear = year;
|
|
353
|
+
this._state.displayMonth = month;
|
|
354
|
+
if (!this._stateless) {
|
|
355
|
+
this.setAttribute('year', year.toString());
|
|
356
|
+
this.setAttribute('month', month.toString());
|
|
357
|
+
this.setAttribute('day', day.toString());
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
this.syncChildComponents();
|
|
362
|
+
if (!this._stateless) {
|
|
363
|
+
this.updateFormValue();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
initializeFromAttributes() {
|
|
367
|
+
const yearStr = this.getAttribute('year');
|
|
368
|
+
const monthStr = this.getAttribute('month');
|
|
369
|
+
const dayStr = this.getAttribute('day');
|
|
370
|
+
const hideNav = this.hasAttribute('hide-navigation');
|
|
371
|
+
const statelessStr = this.getAttribute('stateless');
|
|
372
|
+
const sizeStr = this.getAttribute('size');
|
|
373
|
+
const widthStr = this.getAttribute('width');
|
|
374
|
+
this._min = this.getAttribute('min') || undefined;
|
|
375
|
+
this._max = this.getAttribute('max') || undefined;
|
|
376
|
+
const year = parseYear(yearStr);
|
|
377
|
+
if (year) {
|
|
378
|
+
this._state.displayYear = year;
|
|
379
|
+
}
|
|
380
|
+
const month = parseMonth(monthStr);
|
|
381
|
+
if (month) {
|
|
382
|
+
this._state.displayMonth = month;
|
|
383
|
+
}
|
|
384
|
+
if (year && month) {
|
|
385
|
+
const day = parseDay(dayStr, year, month);
|
|
386
|
+
if (day) {
|
|
387
|
+
this._state.selectedYear = year;
|
|
388
|
+
this._state.selectedMonth = month;
|
|
389
|
+
this._state.selectedDay = day;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
this._hideNavigation = hideNav;
|
|
393
|
+
if (statelessStr !== null) {
|
|
394
|
+
this._stateless = statelessStr !== 'false';
|
|
395
|
+
}
|
|
396
|
+
if (sizeStr && (sizeStr === 'sm' || sizeStr === 'md' || sizeStr === 'lg')) {
|
|
397
|
+
this._size = sizeStr;
|
|
398
|
+
}
|
|
399
|
+
if (widthStr) {
|
|
400
|
+
this._width = widthStr;
|
|
401
|
+
}
|
|
402
|
+
this._initialValue = this.value;
|
|
403
|
+
}
|
|
404
|
+
formResetCallback() {
|
|
405
|
+
this.value = this._initialValue;
|
|
406
|
+
}
|
|
407
|
+
syncStateFromAttributes() {
|
|
408
|
+
const yearStr = this.getAttribute('year');
|
|
409
|
+
const monthStr = this.getAttribute('month');
|
|
410
|
+
const dayStr = this.getAttribute('day');
|
|
411
|
+
const year = parseYear(yearStr);
|
|
412
|
+
const month = parseMonth(monthStr);
|
|
413
|
+
if (year)
|
|
414
|
+
this._state.displayYear = year;
|
|
415
|
+
if (month)
|
|
416
|
+
this._state.displayMonth = month;
|
|
417
|
+
if (year && month) {
|
|
418
|
+
const day = parseDay(dayStr, year, month);
|
|
419
|
+
if (day) {
|
|
420
|
+
this._state.selectedYear = year;
|
|
421
|
+
this._state.selectedMonth = month;
|
|
422
|
+
this._state.selectedDay = day;
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
delete this._state.selectedYear;
|
|
426
|
+
delete this._state.selectedMonth;
|
|
427
|
+
delete this._state.selectedDay;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
delete this._state.selectedYear;
|
|
432
|
+
delete this._state.selectedMonth;
|
|
433
|
+
delete this._state.selectedDay;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
syncChildComponents() {
|
|
437
|
+
if (this._navigation) {
|
|
438
|
+
this._navigation.displayMonth = this._state.displayMonth;
|
|
439
|
+
this._navigation.displayYear = this._state.displayYear;
|
|
440
|
+
this._navigation.locale = this.locale;
|
|
441
|
+
this._navigation.size = this._size;
|
|
442
|
+
this._navigation.min = this._min ?? '';
|
|
443
|
+
this._navigation.max = this._max ?? '';
|
|
444
|
+
this._navigation.width = this._width;
|
|
445
|
+
}
|
|
446
|
+
if (this._monthDisplay) {
|
|
447
|
+
this._monthDisplay.displayMonth = this._state.displayMonth;
|
|
448
|
+
this._monthDisplay.displayYear = this._state.displayYear;
|
|
449
|
+
this._monthDisplay.locale = this.locale;
|
|
450
|
+
this._monthDisplay.size = this._size;
|
|
451
|
+
this._monthDisplay.min = this._min;
|
|
452
|
+
this._monthDisplay.max = this._max;
|
|
453
|
+
this._monthDisplay.flavor = this._flavor;
|
|
454
|
+
this._monthDisplay.width = this._width;
|
|
455
|
+
if (this._dayContentFn) {
|
|
456
|
+
this._monthDisplay.dayContentFn = this._dayContentFn;
|
|
457
|
+
}
|
|
458
|
+
if (this._customCSS) {
|
|
459
|
+
this._monthDisplay.customCSS = this._customCSS;
|
|
460
|
+
}
|
|
461
|
+
const { selectedYear, selectedMonth, selectedDay } = this._state;
|
|
462
|
+
if (selectedYear && selectedMonth && selectedDay) {
|
|
463
|
+
const date = new Date(selectedYear, selectedMonth - 1, selectedDay);
|
|
464
|
+
this._monthDisplay.value = date.getTime();
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
this._monthDisplay.value = null;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
updateFormValue() {
|
|
472
|
+
if (this._stateless)
|
|
473
|
+
return;
|
|
474
|
+
if (!this._internals)
|
|
475
|
+
return;
|
|
476
|
+
const elementName = this.getAttribute('name');
|
|
477
|
+
const { selectedYear, selectedMonth, selectedDay } = this._state;
|
|
478
|
+
if (elementName && selectedYear && selectedMonth && selectedDay) {
|
|
479
|
+
const isoDate = formatDateISO(selectedYear, selectedMonth, selectedDay);
|
|
480
|
+
this._internals.setFormValue(isoDate);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
this._internals.setFormValue('');
|
|
484
|
+
}
|
|
485
|
+
this.updateValidity();
|
|
486
|
+
}
|
|
487
|
+
updateValidity() {
|
|
488
|
+
if (!this._internals)
|
|
489
|
+
return;
|
|
490
|
+
const { selectedYear, selectedMonth, selectedDay } = this._state;
|
|
491
|
+
if (selectedYear && selectedMonth && selectedDay) {
|
|
492
|
+
const sel = Date.UTC(selectedYear, selectedMonth - 1, selectedDay);
|
|
493
|
+
const min = this._min ? parseISODate(this._min) : null;
|
|
494
|
+
const max = this._max ? parseISODate(this._max) : null;
|
|
495
|
+
if (min && sel < Date.UTC(min.year, min.month - 1, min.day)) {
|
|
496
|
+
this._internals.setValidity({ rangeUnderflow: true }, `Date must be ${this._min} or later`);
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (max && sel > Date.UTC(max.year, max.month - 1, max.day)) {
|
|
500
|
+
this._internals.setValidity({ rangeOverflow: true }, `Date must be ${this._max} or earlier`);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
this._internals.setValidity({});
|
|
505
|
+
}
|
|
506
|
+
handleNavigationChange(event) {
|
|
507
|
+
event.preventDefault();
|
|
508
|
+
event.stopPropagation();
|
|
509
|
+
const { month, year } = event.detail;
|
|
510
|
+
this._state.displayMonth = month;
|
|
511
|
+
this._state.displayYear = year;
|
|
512
|
+
this.syncChildComponents();
|
|
513
|
+
const navigateDetail = {
|
|
514
|
+
month,
|
|
515
|
+
year,
|
|
516
|
+
action: 'navigate',
|
|
517
|
+
source: 'navigation',
|
|
518
|
+
};
|
|
519
|
+
this.dispatchEvent(new CustomEvent('navigate', {
|
|
520
|
+
detail: navigateDetail,
|
|
521
|
+
bubbles: true,
|
|
522
|
+
composed: true,
|
|
523
|
+
cancelable: false,
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
handleDayClick(event) {
|
|
527
|
+
event.preventDefault();
|
|
528
|
+
event.stopPropagation();
|
|
529
|
+
const { dayContext, year, month, day } = event.detail;
|
|
530
|
+
if (this._stateless) {
|
|
531
|
+
this.dispatchEvent(new CustomEvent('day-click', {
|
|
532
|
+
detail: event.detail,
|
|
533
|
+
bubbles: true,
|
|
534
|
+
composed: true,
|
|
535
|
+
cancelable: true,
|
|
536
|
+
}));
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
this._state.selectedYear = year;
|
|
540
|
+
this._state.selectedMonth = month;
|
|
541
|
+
this._state.selectedDay = day;
|
|
542
|
+
this._state.displayYear = year;
|
|
543
|
+
this._state.displayMonth = month;
|
|
544
|
+
this.setAttribute('year', year.toString());
|
|
545
|
+
this.setAttribute('month', month.toString());
|
|
546
|
+
this.setAttribute('day', day.toString());
|
|
547
|
+
this.updateFormValue();
|
|
548
|
+
this.syncChildComponents();
|
|
549
|
+
const changeDetail = {
|
|
550
|
+
year,
|
|
551
|
+
month,
|
|
552
|
+
day,
|
|
553
|
+
action: 'select',
|
|
554
|
+
source: 'day-click',
|
|
555
|
+
dayContext,
|
|
556
|
+
};
|
|
557
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
558
|
+
detail: changeDetail,
|
|
559
|
+
bubbles: true,
|
|
560
|
+
composed: true,
|
|
561
|
+
cancelable: false,
|
|
562
|
+
}));
|
|
563
|
+
}
|
|
564
|
+
refresh() {
|
|
565
|
+
this.syncChildComponents();
|
|
566
|
+
if (this._monthDisplay && typeof this._monthDisplay.refresh === 'function') {
|
|
567
|
+
this._monthDisplay.refresh();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
createNavigation() {
|
|
571
|
+
const nav = document.createElement('ty-calendar-navigation');
|
|
572
|
+
nav.displayMonth = this._state.displayMonth;
|
|
573
|
+
nav.displayYear = this._state.displayYear;
|
|
574
|
+
nav.locale = this.locale;
|
|
575
|
+
nav.size = this._size;
|
|
576
|
+
nav.min = this._min ?? '';
|
|
577
|
+
nav.max = this._max ?? '';
|
|
578
|
+
if (this._width) {
|
|
579
|
+
nav.width = this._width;
|
|
580
|
+
}
|
|
581
|
+
nav.addEventListener('change', (e) => this.handleNavigationChange(e));
|
|
582
|
+
this._navigation = nav;
|
|
583
|
+
return nav;
|
|
584
|
+
}
|
|
585
|
+
createMonthDisplay() {
|
|
586
|
+
const month = document.createElement('ty-calendar-month');
|
|
587
|
+
month.displayMonth = this._state.displayMonth;
|
|
588
|
+
month.displayYear = this._state.displayYear;
|
|
589
|
+
month.locale = this.locale;
|
|
590
|
+
month.size = this._size;
|
|
591
|
+
month.min = this._min;
|
|
592
|
+
month.max = this._max;
|
|
593
|
+
month.flavor = this._flavor;
|
|
594
|
+
if (this._width) {
|
|
595
|
+
month.width = this._width;
|
|
596
|
+
}
|
|
597
|
+
const { selectedYear, selectedMonth, selectedDay } = this._state;
|
|
598
|
+
if (selectedYear && selectedMonth && selectedDay) {
|
|
599
|
+
const date = new Date(selectedYear, selectedMonth - 1, selectedDay);
|
|
600
|
+
month.value = date.getTime();
|
|
601
|
+
}
|
|
602
|
+
if (this._dayContentFn) {
|
|
603
|
+
month.dayContentFn = this._dayContentFn;
|
|
604
|
+
}
|
|
605
|
+
if (this._customCSS) {
|
|
606
|
+
month.customCSS = this._customCSS;
|
|
607
|
+
}
|
|
608
|
+
month.addEventListener('day-click', (e) => this.handleDayClick(e));
|
|
609
|
+
this._monthDisplay = month;
|
|
610
|
+
return month;
|
|
611
|
+
}
|
|
612
|
+
render() {
|
|
613
|
+
const root = this.shadowRoot;
|
|
614
|
+
if (!root)
|
|
615
|
+
return;
|
|
616
|
+
ensureStyles(root, { css: calendarStyles, id: 'ty-calendar' });
|
|
617
|
+
root.innerHTML = '';
|
|
618
|
+
const container = document.createElement('div');
|
|
619
|
+
container.className = 'calendar-container';
|
|
620
|
+
if (!this._hideNavigation) {
|
|
621
|
+
const nav = this.createNavigation();
|
|
622
|
+
container.appendChild(nav);
|
|
623
|
+
}
|
|
624
|
+
const month = this.createMonthDisplay();
|
|
625
|
+
container.appendChild(month);
|
|
626
|
+
root.appendChild(container);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
840
629
|
TyCalendar.formAssociated = true;
|
|
841
|
-
// Register the custom element
|
|
842
630
|
if (!customElements.get('ty-calendar')) {
|
|
843
|
-
|
|
631
|
+
customElements.define('ty-calendar', TyCalendar);
|
|
844
632
|
}
|
|
845
|
-
//# sourceMappingURL=calendar.js.map
|