tyrell-components 1.0.0-TC45 → 1.0.0-TC46
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/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +12 -7
- package/lib/base/ty-component.js +8 -139
- 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 +5 -162
- package/lib/components/date-picker.js +28 -583
- package/lib/components/file-upload.d.ts +3 -15
- package/lib/components/file-upload.js +0 -37
- 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 +4 -193
- package/lib/components/modal.d.ts +3 -26
- package/lib/components/modal.js +1 -188
- 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 +3 -130
- package/lib/components/radio.d.ts +3 -23
- package/lib/components/radio.js +0 -63
- package/lib/components/resize-observer.d.ts +2 -30
- package/lib/components/resize-observer.js +0 -45
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +3 -46
- package/lib/components/select.d.ts +11 -150
- package/lib/components/select.js +7 -581
- package/lib/components/selected-tags.d.ts +4 -47
- package/lib/components/selected-tags.js +0 -94
- 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 +3 -63
- package/lib/components/tabs.js +2 -282
- 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 +0 -154
- package/lib/components/wizard.d.ts +4 -54
- package/lib/components/wizard.js +0 -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 +13 -120
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +3 -60
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +1 -26
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +0 -13
- 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 +5 -35
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +0 -15
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +1 -26
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +3 -53
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +3 -23
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +1 -11
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +4 -25
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +1 -15
- 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 +9 -70
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +2 -14
- 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 +4 -47
- 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 +0 -44
- 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 +5 -85
- 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 +0 -2
- package/lib/utils/number-format.js +2 -65
- package/lib/utils/positioning.d.ts +0 -2
- package/lib/utils/positioning.js +0 -54
- 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,57 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TyCalendarMonth Web Component
|
|
3
|
-
* PORTED FROM: cljs/ty/components/calendar_month.cljs
|
|
4
|
-
*
|
|
5
|
-
* A stateless, property-driven calendar month renderer with customizable
|
|
6
|
-
* day content and styling.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - 42-day grid (6 weeks × 7 days) with Monday-first ordering
|
|
10
|
-
* - Localized weekday headers
|
|
11
|
-
* - Custom day content rendering via dayContentFn
|
|
12
|
-
* - Custom day classes via dayClassesFn
|
|
13
|
-
* - Custom CSS injection via customCSS
|
|
14
|
-
* - Responsive width system (width, minWidth, maxWidth)
|
|
15
|
-
* - Rich day-click events with full context
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```html
|
|
19
|
-
* <!-- Basic usage -->
|
|
20
|
-
* <ty-calendar-month
|
|
21
|
-
* display-year="2025"
|
|
22
|
-
* display-month="10"
|
|
23
|
-
* locale="en-US">
|
|
24
|
-
* </ty-calendar-month>
|
|
25
|
-
*
|
|
26
|
-
* <!-- With custom rendering -->
|
|
27
|
-
* <ty-calendar-month id="custom"></ty-calendar-month>
|
|
28
|
-
* <script type="module">
|
|
29
|
-
* const cal = document.getElementById('custom');
|
|
30
|
-
* cal.dayContentFn = (ctx) => {
|
|
31
|
-
* const el = document.createElement('div');
|
|
32
|
-
* el.textContent = ctx.dayInMonth;
|
|
33
|
-
* return el;
|
|
34
|
-
* };
|
|
35
|
-
* </script>
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
39
2
|
import { syncCustomFlavorSheet } from '../utils/flavor-sheet.js';
|
|
40
3
|
import { calendarMonthStyles, calendarMonthCustomFlavorCss } from '../styles/calendar-month.js';
|
|
41
4
|
import { getCalendarMonthDays, getLocalizedWeekdays, parseISODate } from '../utils/calendar-utils.js';
|
|
42
5
|
import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
|
|
43
|
-
// ============================================================================
|
|
44
|
-
// Default Render Functions
|
|
45
|
-
// ============================================================================
|
|
46
|
-
/**
|
|
47
|
-
* Default day content renderer - just the day number
|
|
48
|
-
*/
|
|
49
6
|
function defaultDayContent(dayContext) {
|
|
50
7
|
return dayContext.dayInMonth.toString();
|
|
51
8
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Default day classes based on day context
|
|
54
|
-
*/
|
|
55
9
|
function getDefaultDayClasses(dayContext) {
|
|
56
10
|
const classes = ['calendar-day'];
|
|
57
11
|
if (dayContext.today)
|
|
@@ -64,19 +18,9 @@ function getDefaultDayClasses(dayContext) {
|
|
|
64
18
|
classes.push('selected');
|
|
65
19
|
return classes;
|
|
66
20
|
}
|
|
67
|
-
// ============================================================================
|
|
68
|
-
// Helper Functions
|
|
69
|
-
// ============================================================================
|
|
70
|
-
/**
|
|
71
|
-
* Check if value is a DOM element
|
|
72
|
-
*/
|
|
73
21
|
function isDOMElement(value) {
|
|
74
22
|
return value instanceof HTMLElement;
|
|
75
23
|
}
|
|
76
|
-
/**
|
|
77
|
-
* ISO date string ("YYYY-MM-DD") → UTC-midnight timestamp, matching
|
|
78
|
-
* DayContext.value semantics. null when unset/invalid.
|
|
79
|
-
*/
|
|
80
24
|
function isoToUTCTimestamp(iso) {
|
|
81
25
|
if (!iso)
|
|
82
26
|
return null;
|
|
@@ -85,31 +29,16 @@ function isoToUTCTimestamp(iso) {
|
|
|
85
29
|
return null;
|
|
86
30
|
return Date.UTC(parsed.year, parsed.month - 1, parsed.day);
|
|
87
31
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Normalize size value - add 'px' if just a number
|
|
90
|
-
*/
|
|
91
32
|
function normalizeSizeValue(value) {
|
|
92
33
|
if (!value || value === '')
|
|
93
34
|
return null;
|
|
94
35
|
const strValue = String(value);
|
|
95
|
-
// If it's just a number, add 'px'
|
|
96
36
|
if (/^\d+(\.\d+)?$/.test(strValue)) {
|
|
97
37
|
return `${strValue}px`;
|
|
98
38
|
}
|
|
99
|
-
// Otherwise use as-is (supports %, rem, vw, etc.)
|
|
100
39
|
return strValue;
|
|
101
40
|
}
|
|
102
|
-
// ============================================================================
|
|
103
|
-
// Component Implementation
|
|
104
|
-
// ============================================================================
|
|
105
|
-
/**
|
|
106
|
-
* TyCalendarMonth Web Component
|
|
107
|
-
*/
|
|
108
41
|
export class TyCalendarMonth extends HTMLElement {
|
|
109
|
-
/**
|
|
110
|
-
* Observed attributes (minimal - mainly for debugging)
|
|
111
|
-
* Properties are the primary API
|
|
112
|
-
*/
|
|
113
42
|
static get observedAttributes() {
|
|
114
43
|
return ['locale', 'size', 'min', 'max', 'flavor'];
|
|
115
44
|
}
|
|
@@ -118,25 +47,14 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
118
47
|
this._locale = 'en-US';
|
|
119
48
|
this._size = 'md';
|
|
120
49
|
this._customFlavorSheet = null;
|
|
121
|
-
// ARIA grid roving-tabindex state — index into the flat 42-day array.
|
|
122
|
-
// null means "not yet resolved"; render() picks a sensible default
|
|
123
|
-
// (selected day, else today, else the 1st rendered day) and persists it
|
|
124
|
-
// across re-renders so keyboard focus survives unrelated prop changes.
|
|
125
|
-
// Reset to null on month/year navigation (see the property setters below)
|
|
126
|
-
// so the new month gets a fresh default instead of a stale index.
|
|
127
50
|
this._focusedIndex = null;
|
|
128
51
|
this._cellElements = [];
|
|
129
|
-
// Initialize with current date
|
|
130
52
|
const today = new Date();
|
|
131
53
|
this._displayYear = today.getFullYear();
|
|
132
|
-
this._displayMonth = today.getMonth() + 1;
|
|
54
|
+
this._displayMonth = today.getMonth() + 1;
|
|
133
55
|
this.attachShadow({ mode: 'open' });
|
|
134
56
|
}
|
|
135
|
-
// ==========================================================================
|
|
136
|
-
// Lifecycle Methods
|
|
137
|
-
// ==========================================================================
|
|
138
57
|
connectedCallback() {
|
|
139
|
-
// Set defaults if not already set
|
|
140
58
|
if (!this._displayMonth) {
|
|
141
59
|
this._displayMonth = new Date().getMonth() + 1;
|
|
142
60
|
}
|
|
@@ -146,24 +64,20 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
146
64
|
if (!this._locale) {
|
|
147
65
|
this._locale = this.getAttribute('locale') || 'en-US';
|
|
148
66
|
}
|
|
149
|
-
// Read size attribute if present
|
|
150
67
|
const sizeAttr = this.getAttribute('size');
|
|
151
68
|
if (sizeAttr && (sizeAttr === 'sm' || sizeAttr === 'md' || sizeAttr === 'lg')) {
|
|
152
69
|
this._size = sizeAttr;
|
|
153
70
|
}
|
|
154
|
-
// Check for dayContentFn set before upgrade
|
|
155
71
|
const plainDayContentFn = this.dayContentFn;
|
|
156
72
|
if (plainDayContentFn && !this._dayContentFn) {
|
|
157
73
|
this._dayContentFn = plainDayContentFn;
|
|
158
|
-
delete this.dayContentFn;
|
|
74
|
+
delete this.dayContentFn;
|
|
159
75
|
}
|
|
160
|
-
// Check for customCSS set before upgrade
|
|
161
76
|
const plainCustomCSS = this.customCSS;
|
|
162
77
|
if (plainCustomCSS && !this._customCSS) {
|
|
163
78
|
this._customCSS = plainCustomCSS;
|
|
164
|
-
delete this.customCSS;
|
|
79
|
+
delete this.customCSS;
|
|
165
80
|
}
|
|
166
|
-
// Setup locale observer to watch for ancestor lang changes
|
|
167
81
|
this._localeObserver = observeLocaleChanges(this, () => {
|
|
168
82
|
this.render();
|
|
169
83
|
});
|
|
@@ -171,7 +85,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
171
85
|
this.render();
|
|
172
86
|
}
|
|
173
87
|
disconnectedCallback() {
|
|
174
|
-
// Cleanup locale observer
|
|
175
88
|
if (this._localeObserver) {
|
|
176
89
|
this._localeObserver();
|
|
177
90
|
this._localeObserver = undefined;
|
|
@@ -196,17 +109,9 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
196
109
|
this._syncCustomFlavor();
|
|
197
110
|
}
|
|
198
111
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Custom (non-built-in) flavors — the `flavor` attribute itself drives
|
|
201
|
-
* built-in flavors directly via `:host([flavor="X"])` CSS, no JS needed.
|
|
202
|
-
* See utils/flavor-sheet.ts.
|
|
203
|
-
*/
|
|
204
112
|
_syncCustomFlavor() {
|
|
205
113
|
this._customFlavorSheet = syncCustomFlavorSheet(this.shadowRoot, this._customFlavorSheet, this.getAttribute('flavor'), ({ base }) => calendarMonthCustomFlavorCss(base));
|
|
206
114
|
}
|
|
207
|
-
// ==========================================================================
|
|
208
|
-
// Property Getters/Setters
|
|
209
|
-
// ==========================================================================
|
|
210
115
|
get displayYear() {
|
|
211
116
|
return this._displayYear;
|
|
212
117
|
}
|
|
@@ -327,12 +232,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
327
232
|
this.render();
|
|
328
233
|
}
|
|
329
234
|
}
|
|
330
|
-
// ==========================================================================
|
|
331
|
-
// Width Property System
|
|
332
|
-
// ==========================================================================
|
|
333
|
-
/**
|
|
334
|
-
* Apply width-related properties as CSS custom properties
|
|
335
|
-
*/
|
|
336
235
|
applyWidthProperties() {
|
|
337
236
|
const normalizedWidth = normalizeSizeValue(this._width);
|
|
338
237
|
const normalizedMinWidth = normalizeSizeValue(this._minWidth);
|
|
@@ -356,9 +255,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
356
255
|
this.style.removeProperty('--calendar-max-width');
|
|
357
256
|
}
|
|
358
257
|
}
|
|
359
|
-
/**
|
|
360
|
-
* Apply custom CSS to shadow root
|
|
361
|
-
*/
|
|
362
258
|
applyCustomCSS() {
|
|
363
259
|
if (!this._customCSS || !this.shadowRoot)
|
|
364
260
|
return;
|
|
@@ -367,22 +263,9 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
367
263
|
this.shadowRoot.adoptedStyleSheets = [...existing, this._customCSS];
|
|
368
264
|
}
|
|
369
265
|
}
|
|
370
|
-
// ==========================================================================
|
|
371
|
-
// Public Methods
|
|
372
|
-
// ==========================================================================
|
|
373
|
-
/**
|
|
374
|
-
* Force re-render of the calendar month
|
|
375
|
-
* Useful when external data changes (e.g., async event loading)
|
|
376
|
-
*/
|
|
377
266
|
refresh() {
|
|
378
267
|
this.render();
|
|
379
268
|
}
|
|
380
|
-
// ==========================================================================
|
|
381
|
-
// Event Dispatching
|
|
382
|
-
// ==========================================================================
|
|
383
|
-
/**
|
|
384
|
-
* Dispatch day-click custom event with day context
|
|
385
|
-
*/
|
|
386
269
|
dispatchDayClick(dayContext, _domEvent) {
|
|
387
270
|
const detail = {
|
|
388
271
|
dayContext,
|
|
@@ -395,7 +278,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
395
278
|
isWeekend: dayContext.weekend,
|
|
396
279
|
isOtherMonth: dayContext.otherMonth,
|
|
397
280
|
};
|
|
398
|
-
// Dispatch both 'day-click' and 'day-select' (alias)
|
|
399
281
|
for (const eventType of ['day-click', 'day-select']) {
|
|
400
282
|
const event = new CustomEvent(eventType, {
|
|
401
283
|
detail,
|
|
@@ -405,35 +287,19 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
405
287
|
this.dispatchEvent(event);
|
|
406
288
|
}
|
|
407
289
|
}
|
|
408
|
-
// ==========================================================================
|
|
409
|
-
// Rendering
|
|
410
|
-
// ==========================================================================
|
|
411
|
-
/**
|
|
412
|
-
* Render a single day cell
|
|
413
|
-
*/
|
|
414
|
-
/**
|
|
415
|
-
* WAI-ARIA grid pattern: gridcell + roving tabindex (exactly one cell in
|
|
416
|
-
* the whole grid is tabindex="0" at a time — the rest are -1, so Tab
|
|
417
|
-
* enters/exits the grid in one hop and arrow keys move focus inside it).
|
|
418
|
-
* Disabled days are excluded from the roving set entirely.
|
|
419
|
-
*/
|
|
420
290
|
renderDayCell(dayContext, disabled, isRoving) {
|
|
421
291
|
const dayElement = document.createElement('div');
|
|
422
|
-
// Get content using custom or default function
|
|
423
292
|
const content = this._dayContentFn
|
|
424
293
|
? this._dayContentFn(dayContext)
|
|
425
294
|
: defaultDayContent(dayContext);
|
|
426
|
-
// STRICT DOM-ONLY CHECK for custom functions
|
|
427
295
|
if (this._dayContentFn && content && !isDOMElement(content) && typeof content !== 'string') {
|
|
428
296
|
throw new Error(`Custom dayContentFn must return a DOM element or string, got: ${typeof content}. ` +
|
|
429
297
|
`Use document.createElement() to create DOM elements.`);
|
|
430
298
|
}
|
|
431
|
-
// Apply default classes
|
|
432
299
|
const classes = getDefaultDayClasses(dayContext);
|
|
433
300
|
if (disabled)
|
|
434
301
|
classes.push('disabled');
|
|
435
302
|
dayElement.className = classes.join(' ');
|
|
436
|
-
// Set content
|
|
437
303
|
if (typeof content === 'string') {
|
|
438
304
|
dayElement.textContent = content;
|
|
439
305
|
}
|
|
@@ -452,7 +318,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
452
318
|
}
|
|
453
319
|
else {
|
|
454
320
|
dayElement.setAttribute('tabindex', isRoving ? '0' : '-1');
|
|
455
|
-
// Add click handler (disabled days don't emit)
|
|
456
321
|
dayElement.addEventListener('pointerdown', (event) => {
|
|
457
322
|
event.preventDefault();
|
|
458
323
|
this.dispatchDayClick(dayContext, event);
|
|
@@ -467,42 +332,30 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
467
332
|
}
|
|
468
333
|
return dayElement;
|
|
469
334
|
}
|
|
470
|
-
/**
|
|
471
|
-
* Main render function - property-based approach
|
|
472
|
-
*/
|
|
473
335
|
render() {
|
|
474
336
|
const root = this.shadowRoot;
|
|
475
337
|
if (!root)
|
|
476
338
|
return;
|
|
477
|
-
// Ensure styles are loaded
|
|
478
339
|
ensureStyles(root, { css: calendarMonthStyles, id: 'ty-calendar-month' });
|
|
479
|
-
// Apply custom CSS if provided
|
|
480
340
|
this.applyCustomCSS();
|
|
481
|
-
// Apply width properties
|
|
482
341
|
this.applyWidthProperties();
|
|
483
|
-
// Convert timestamp to selection info
|
|
484
342
|
let selection;
|
|
485
343
|
if (this._value) {
|
|
486
344
|
const date = new Date(this._value);
|
|
487
345
|
selection = {
|
|
488
346
|
year: date.getFullYear(),
|
|
489
|
-
month: date.getMonth() + 1,
|
|
347
|
+
month: date.getMonth() + 1,
|
|
490
348
|
day: date.getDate()
|
|
491
349
|
};
|
|
492
350
|
}
|
|
493
|
-
// Generate calendar days with selection info
|
|
494
351
|
const days = getCalendarMonthDays(this._displayYear, this._displayMonth, selection);
|
|
495
|
-
// Get localized weekday names
|
|
496
352
|
const weekdays = getLocalizedWeekdays(this._locale, 'short');
|
|
497
|
-
// Clear and rebuild
|
|
498
353
|
root.innerHTML = '';
|
|
499
|
-
// Create unified flex container
|
|
500
354
|
const calendarContainer = document.createElement('div');
|
|
501
355
|
calendarContainer.className = `calendar-flex-container calendar-size-${this._size}`;
|
|
502
356
|
calendarContainer.setAttribute('role', 'grid');
|
|
503
357
|
calendarContainer.setAttribute('aria-label', new Intl.DateTimeFormat(this._locale, { month: 'long', year: 'numeric' })
|
|
504
358
|
.format(new Date(this._displayYear, this._displayMonth - 1, 1)));
|
|
505
|
-
// Create header row with weekday names
|
|
506
359
|
const headerRow = document.createElement('div');
|
|
507
360
|
headerRow.className = 'calendar-row calendar-header-row';
|
|
508
361
|
headerRow.setAttribute('role', 'row');
|
|
@@ -514,17 +367,12 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
514
367
|
headerRow.appendChild(headerCell);
|
|
515
368
|
});
|
|
516
369
|
calendarContainer.appendChild(headerRow);
|
|
517
|
-
// Create day rows (6 weeks of 7 days each)
|
|
518
370
|
const dayWeeks = [];
|
|
519
371
|
for (let i = 0; i < 42; i += 7) {
|
|
520
372
|
dayWeeks.push(days.slice(i, i + 7));
|
|
521
373
|
}
|
|
522
|
-
// Bounds for disabling days (UTC-midnight, same space as DayContext.value)
|
|
523
374
|
const minTs = isoToUTCTimestamp(this._min);
|
|
524
375
|
const maxTs = isoToUTCTimestamp(this._max);
|
|
525
|
-
// Roving-tabindex target: keep the persisted index if still valid and
|
|
526
|
-
// not disabled, else fall back to selected day, else today, else the
|
|
527
|
-
// first rendered day — always something focusable exists in the grid.
|
|
528
376
|
const disabledAt = (i) => {
|
|
529
377
|
const v = days[i].value;
|
|
530
378
|
return (minTs !== null && v < minTs) || (maxTs !== null && v > maxTs);
|
|
@@ -550,7 +398,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
550
398
|
const disabled = (minTs !== null && dayContext.value < minTs) ||
|
|
551
399
|
(maxTs !== null && dayContext.value > maxTs);
|
|
552
400
|
const dayCell = this.renderDayCell(dayContext, disabled, flatIndex === this._focusedIndex);
|
|
553
|
-
// Add unified cell classes for flex layout
|
|
554
401
|
dayCell.className = `${dayCell.className} calendar-cell calendar-day-cell`;
|
|
555
402
|
dayRow.appendChild(dayCell);
|
|
556
403
|
this._cellElements[flatIndex] = dayCell;
|
|
@@ -558,13 +405,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
558
405
|
});
|
|
559
406
|
calendarContainer.appendChild(dayRow);
|
|
560
407
|
});
|
|
561
|
-
// Arrow-key roving-tabindex navigation: Left/Right move a day,
|
|
562
|
-
// Up/Down move a week — pure index arithmetic works because `days` is a
|
|
563
|
-
// flat, chronologically-ordered 42-cell array (Monday-first weeks), so
|
|
564
|
-
// index+1 is always the next calendar day and index+7 the next week.
|
|
565
|
-
// Delegated on the grid (one listener, not 42) — this component is
|
|
566
|
-
// stateless about which month is shown, so moving past the rendered
|
|
567
|
-
// 42-day range just clamps at the edge rather than crossing months.
|
|
568
408
|
calendarContainer.addEventListener('keydown', (event) => {
|
|
569
409
|
const ke = event;
|
|
570
410
|
const delta = ke.key === 'ArrowLeft' ? -1 :
|
|
@@ -590,8 +430,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
590
430
|
root.appendChild(calendarContainer);
|
|
591
431
|
}
|
|
592
432
|
}
|
|
593
|
-
// Register the custom element
|
|
594
433
|
if (!customElements.get('ty-calendar-month')) {
|
|
595
434
|
customElements.define('ty-calendar-month', TyCalendarMonth);
|
|
596
435
|
}
|
|
597
|
-
//# sourceMappingURL=calendar-month.js.map
|
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TyCalendarNavigation Web Component
|
|
3
|
-
*
|
|
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
|
-
* ```
|
|
2
|
+
* TyCalendarNavigation Web Component — pure presentation for calendar
|
|
3
|
+
* month/year navigation. Stateless: all state comes from properties,
|
|
4
|
+
* changes are emitted via events.
|
|
34
5
|
*/
|
|
35
6
|
import { TyComponent } from '../base/ty-component.js';
|
|
36
7
|
import type { PropertyChange } from '../utils/property-manager.js';
|
|
@@ -98,13 +69,7 @@ export declare class TyCalendarNavigation extends TyComponent<NavigationState> {
|
|
|
98
69
|
private _state;
|
|
99
70
|
private _localeObserver?;
|
|
100
71
|
constructor();
|
|
101
|
-
/**
|
|
102
|
-
* Called when component connects to DOM
|
|
103
|
-
*/
|
|
104
72
|
protected onConnect(): void;
|
|
105
|
-
/**
|
|
106
|
-
* Called when component disconnects from DOM
|
|
107
|
-
*/
|
|
108
73
|
protected onDisconnect(): void;
|
|
109
74
|
/**
|
|
110
75
|
* Called when properties change
|
|
@@ -125,9 +90,6 @@ export declare class TyCalendarNavigation extends TyComponent<NavigationState> {
|
|
|
125
90
|
set min(value: string);
|
|
126
91
|
get max(): string;
|
|
127
92
|
set max(value: string);
|
|
128
|
-
/**
|
|
129
|
-
* Emit change event with new month/year
|
|
130
|
-
*/
|
|
131
93
|
private emitChangeEvent;
|
|
132
94
|
/**
|
|
133
95
|
* Month index (year * 12 + month - 1) — flat, comparable month math.
|
|
@@ -150,14 +112,7 @@ export declare class TyCalendarNavigation extends TyComponent<NavigationState> {
|
|
|
150
112
|
* True when navigating by deltaMonths can't move the display (bound reached)
|
|
151
113
|
*/
|
|
152
114
|
private isNavDisabled;
|
|
153
|
-
/**
|
|
154
|
-
* Create navigation button
|
|
155
|
-
*/
|
|
156
115
|
private createButton;
|
|
157
|
-
/**
|
|
158
|
-
* Main render function
|
|
159
|
-
*/
|
|
160
116
|
protected render(): void;
|
|
161
117
|
}
|
|
162
118
|
export {};
|
|
163
|
-
//# sourceMappingURL=calendar-navigation.d.ts.map
|