tyrell-components 1.0.0-RC12 → 1.0.0-RC14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/css/tyrell-colors-static.css +316 -0
- package/css/tyrell-theme.css +1443 -0
- package/css/tyrell.css +127 -423
- package/dist/tyrell-colors-static.css +316 -0
- package/dist/tyrell-theme.css +1443 -0
- package/dist/tyrell.css +127 -423
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +20 -10
- package/lib/base/ty-component.js +21 -144
- package/lib/components/button.d.ts +9 -16
- package/lib/components/button.js +12 -37
- package/lib/components/calendar-month.d.ts +17 -46
- package/lib/components/calendar-month.js +97 -145
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +3 -126
- package/lib/components/calendar.d.ts +6 -81
- package/lib/components/calendar.js +24 -236
- package/lib/components/checkbox.d.ts +8 -74
- package/lib/components/checkbox.js +21 -177
- package/lib/components/copy.d.ts +7 -59
- package/lib/components/copy.js +19 -137
- package/lib/components/date-picker.d.ts +23 -161
- package/lib/components/date-picker.js +127 -588
- package/lib/components/file-upload.d.ts +9 -15
- package/lib/components/file-upload.js +19 -41
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +1 -90
- package/lib/components/input.d.ts +10 -109
- package/lib/components/input.js +24 -209
- package/lib/components/modal.d.ts +17 -26
- package/lib/components/modal.js +67 -192
- package/lib/components/option.d.ts +2 -20
- package/lib/components/option.js +1 -148
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +35 -132
- package/lib/components/radio.d.ts +7 -24
- package/lib/components/radio.js +24 -68
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +12 -46
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +3 -46
- package/lib/components/select.d.ts +130 -151
- package/lib/components/select.js +327 -516
- package/lib/components/selected-tags.d.ts +8 -38
- package/lib/components/selected-tags.js +20 -78
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +0 -6
- package/lib/components/switch.d.ts +4 -14
- package/lib/components/switch.js +15 -61
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +0 -7
- package/lib/components/tabs.d.ts +5 -63
- package/lib/components/tabs.js +159 -267
- 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 +7 -13
- package/lib/components/tooltip.js +83 -180
- package/lib/components/wizard.d.ts +6 -54
- package/lib/components/wizard.js +27 -221
- 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 +2 -2
- package/lib/index.js +2 -21
- package/lib/styles/button.d.ts +19 -7
- package/lib/styles/button.js +180 -77
- package/lib/styles/calendar-month.d.ts +4 -6
- package/lib/styles/calendar-month.js +57 -59
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +3 -28
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +1 -14
- package/lib/styles/checkbox.d.ts +3 -2
- package/lib/styles/checkbox.js +24 -68
- package/lib/styles/copy.d.ts +3 -2
- package/lib/styles/copy.js +25 -17
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +5 -20
- package/lib/styles/date-picker.d.ts +4 -6
- package/lib/styles/date-picker.js +80 -130
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +4 -19
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +7 -21
- package/lib/styles/input.d.ts +4 -7
- package/lib/styles/input.js +55 -160
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +21 -23
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +17 -63
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +26 -30
- package/lib/styles/radio.d.ts +3 -2
- package/lib/styles/radio.js +21 -32
- 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 +8 -0
- package/lib/styles/{multiselect.js → select-base.js} +264 -127
- package/lib/styles/select.d.ts +3 -4
- package/lib/styles/select.js +103 -43
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +0 -4
- package/lib/styles/switch.d.ts +3 -2
- package/lib/styles/switch.js +20 -23
- 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 +77 -45
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +6 -32
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +7 -50
- package/lib/styles/tooltip.d.ts +4 -3
- package/lib/styles/tooltip.js +0 -125
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +23 -91
- package/lib/types/common.d.ts +1 -3
- package/lib/types/common.js +0 -10
- 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 +9 -0
- package/lib/utils/icons.js +1 -0
- package/lib/utils/loader-registry.d.ts +2 -3
- package/lib/utils/loader-registry.js +0 -32
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +0 -86
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +0 -17
- package/lib/utils/number-format.d.ts +6 -3
- package/lib/utils/number-format.js +11 -67
- package/lib/utils/positioning.d.ts +77 -3
- package/lib/utils/positioning.js +67 -58
- 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 +8 -5
- package/css/tyrell-brand.css +0 -1015
- package/dist/tyrell-brand.css +0 -1015
- 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 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- 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.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/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,56 +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
|
-
import {
|
|
2
|
+
import { syncCustomFlavorSheet } from '../utils/flavor-sheet.js';
|
|
3
|
+
import { calendarMonthStyles, calendarMonthCustomFlavorCss } from '../styles/calendar-month.js';
|
|
40
4
|
import { getCalendarMonthDays, getLocalizedWeekdays, parseISODate } from '../utils/calendar-utils.js';
|
|
41
5
|
import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
|
|
42
|
-
// ============================================================================
|
|
43
|
-
// Default Render Functions
|
|
44
|
-
// ============================================================================
|
|
45
|
-
/**
|
|
46
|
-
* Default day content renderer - just the day number
|
|
47
|
-
*/
|
|
48
6
|
function defaultDayContent(dayContext) {
|
|
49
7
|
return dayContext.dayInMonth.toString();
|
|
50
8
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Default day classes based on day context
|
|
53
|
-
*/
|
|
54
9
|
function getDefaultDayClasses(dayContext) {
|
|
55
10
|
const classes = ['calendar-day'];
|
|
56
11
|
if (dayContext.today)
|
|
@@ -63,19 +18,9 @@ function getDefaultDayClasses(dayContext) {
|
|
|
63
18
|
classes.push('selected');
|
|
64
19
|
return classes;
|
|
65
20
|
}
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// Helper Functions
|
|
68
|
-
// ============================================================================
|
|
69
|
-
/**
|
|
70
|
-
* Check if value is a DOM element
|
|
71
|
-
*/
|
|
72
21
|
function isDOMElement(value) {
|
|
73
22
|
return value instanceof HTMLElement;
|
|
74
23
|
}
|
|
75
|
-
/**
|
|
76
|
-
* ISO date string ("YYYY-MM-DD") → UTC-midnight timestamp, matching
|
|
77
|
-
* DayContext.value semantics. null when unset/invalid.
|
|
78
|
-
*/
|
|
79
24
|
function isoToUTCTimestamp(iso) {
|
|
80
25
|
if (!iso)
|
|
81
26
|
return null;
|
|
@@ -84,49 +29,32 @@ function isoToUTCTimestamp(iso) {
|
|
|
84
29
|
return null;
|
|
85
30
|
return Date.UTC(parsed.year, parsed.month - 1, parsed.day);
|
|
86
31
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Normalize size value - add 'px' if just a number
|
|
89
|
-
*/
|
|
90
32
|
function normalizeSizeValue(value) {
|
|
91
33
|
if (!value || value === '')
|
|
92
34
|
return null;
|
|
93
35
|
const strValue = String(value);
|
|
94
|
-
// If it's just a number, add 'px'
|
|
95
36
|
if (/^\d+(\.\d+)?$/.test(strValue)) {
|
|
96
37
|
return `${strValue}px`;
|
|
97
38
|
}
|
|
98
|
-
// Otherwise use as-is (supports %, rem, vw, etc.)
|
|
99
39
|
return strValue;
|
|
100
40
|
}
|
|
101
|
-
// ============================================================================
|
|
102
|
-
// Component Implementation
|
|
103
|
-
// ============================================================================
|
|
104
|
-
/**
|
|
105
|
-
* TyCalendarMonth Web Component
|
|
106
|
-
*/
|
|
107
41
|
export class TyCalendarMonth extends HTMLElement {
|
|
108
|
-
/**
|
|
109
|
-
* Observed attributes (minimal - mainly for debugging)
|
|
110
|
-
* Properties are the primary API
|
|
111
|
-
*/
|
|
112
42
|
static get observedAttributes() {
|
|
113
|
-
return ['locale', 'size', 'min', 'max'];
|
|
43
|
+
return ['locale', 'size', 'min', 'max', 'flavor'];
|
|
114
44
|
}
|
|
115
45
|
constructor() {
|
|
116
46
|
super();
|
|
117
47
|
this._locale = 'en-US';
|
|
118
48
|
this._size = 'md';
|
|
119
|
-
|
|
49
|
+
this._customFlavorSheet = null;
|
|
50
|
+
this._focusedIndex = null;
|
|
51
|
+
this._cellElements = [];
|
|
120
52
|
const today = new Date();
|
|
121
53
|
this._displayYear = today.getFullYear();
|
|
122
|
-
this._displayMonth = today.getMonth() + 1;
|
|
54
|
+
this._displayMonth = today.getMonth() + 1;
|
|
123
55
|
this.attachShadow({ mode: 'open' });
|
|
124
56
|
}
|
|
125
|
-
// ==========================================================================
|
|
126
|
-
// Lifecycle Methods
|
|
127
|
-
// ==========================================================================
|
|
128
57
|
connectedCallback() {
|
|
129
|
-
// Set defaults if not already set
|
|
130
58
|
if (!this._displayMonth) {
|
|
131
59
|
this._displayMonth = new Date().getMonth() + 1;
|
|
132
60
|
}
|
|
@@ -136,31 +64,27 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
136
64
|
if (!this._locale) {
|
|
137
65
|
this._locale = this.getAttribute('locale') || 'en-US';
|
|
138
66
|
}
|
|
139
|
-
// Read size attribute if present
|
|
140
67
|
const sizeAttr = this.getAttribute('size');
|
|
141
68
|
if (sizeAttr && (sizeAttr === 'sm' || sizeAttr === 'md' || sizeAttr === 'lg')) {
|
|
142
69
|
this._size = sizeAttr;
|
|
143
70
|
}
|
|
144
|
-
// Check for dayContentFn set before upgrade
|
|
145
71
|
const plainDayContentFn = this.dayContentFn;
|
|
146
72
|
if (plainDayContentFn && !this._dayContentFn) {
|
|
147
73
|
this._dayContentFn = plainDayContentFn;
|
|
148
|
-
delete this.dayContentFn;
|
|
74
|
+
delete this.dayContentFn;
|
|
149
75
|
}
|
|
150
|
-
// Check for customCSS set before upgrade
|
|
151
76
|
const plainCustomCSS = this.customCSS;
|
|
152
77
|
if (plainCustomCSS && !this._customCSS) {
|
|
153
78
|
this._customCSS = plainCustomCSS;
|
|
154
|
-
delete this.customCSS;
|
|
79
|
+
delete this.customCSS;
|
|
155
80
|
}
|
|
156
|
-
// Setup locale observer to watch for ancestor lang changes
|
|
157
81
|
this._localeObserver = observeLocaleChanges(this, () => {
|
|
158
82
|
this.render();
|
|
159
83
|
});
|
|
84
|
+
this._syncCustomFlavor();
|
|
160
85
|
this.render();
|
|
161
86
|
}
|
|
162
87
|
disconnectedCallback() {
|
|
163
|
-
// Cleanup locale observer
|
|
164
88
|
if (this._localeObserver) {
|
|
165
89
|
this._localeObserver();
|
|
166
90
|
this._localeObserver = undefined;
|
|
@@ -181,16 +105,20 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
181
105
|
this[name === 'min' ? '_min' : '_max'] = newValue ?? undefined;
|
|
182
106
|
this.render();
|
|
183
107
|
}
|
|
108
|
+
else if (name === 'flavor') {
|
|
109
|
+
this._syncCustomFlavor();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
_syncCustomFlavor() {
|
|
113
|
+
this._customFlavorSheet = syncCustomFlavorSheet(this.shadowRoot, this._customFlavorSheet, this.getAttribute('flavor'), ({ base }) => calendarMonthCustomFlavorCss(base));
|
|
184
114
|
}
|
|
185
|
-
// ==========================================================================
|
|
186
|
-
// Property Getters/Setters
|
|
187
|
-
// ==========================================================================
|
|
188
115
|
get displayYear() {
|
|
189
116
|
return this._displayYear;
|
|
190
117
|
}
|
|
191
118
|
set displayYear(value) {
|
|
192
119
|
if (this._displayYear !== value) {
|
|
193
120
|
this._displayYear = value;
|
|
121
|
+
this._focusedIndex = null;
|
|
194
122
|
this.render();
|
|
195
123
|
}
|
|
196
124
|
}
|
|
@@ -200,6 +128,7 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
200
128
|
set displayMonth(value) {
|
|
201
129
|
if (this._displayMonth !== value) {
|
|
202
130
|
this._displayMonth = value;
|
|
131
|
+
this._focusedIndex = null;
|
|
203
132
|
this.render();
|
|
204
133
|
}
|
|
205
134
|
}
|
|
@@ -221,6 +150,15 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
221
150
|
this.render();
|
|
222
151
|
}
|
|
223
152
|
}
|
|
153
|
+
get flavor() {
|
|
154
|
+
return this.getAttribute('flavor') || 'primary';
|
|
155
|
+
}
|
|
156
|
+
set flavor(value) {
|
|
157
|
+
if (value)
|
|
158
|
+
this.setAttribute('flavor', value);
|
|
159
|
+
else
|
|
160
|
+
this.removeAttribute('flavor');
|
|
161
|
+
}
|
|
224
162
|
get width() {
|
|
225
163
|
return this._width;
|
|
226
164
|
}
|
|
@@ -294,12 +232,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
294
232
|
this.render();
|
|
295
233
|
}
|
|
296
234
|
}
|
|
297
|
-
// ==========================================================================
|
|
298
|
-
// Width Property System
|
|
299
|
-
// ==========================================================================
|
|
300
|
-
/**
|
|
301
|
-
* Apply width-related properties as CSS custom properties
|
|
302
|
-
*/
|
|
303
235
|
applyWidthProperties() {
|
|
304
236
|
const normalizedWidth = normalizeSizeValue(this._width);
|
|
305
237
|
const normalizedMinWidth = normalizeSizeValue(this._minWidth);
|
|
@@ -323,9 +255,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
323
255
|
this.style.removeProperty('--calendar-max-width');
|
|
324
256
|
}
|
|
325
257
|
}
|
|
326
|
-
/**
|
|
327
|
-
* Apply custom CSS to shadow root
|
|
328
|
-
*/
|
|
329
258
|
applyCustomCSS() {
|
|
330
259
|
if (!this._customCSS || !this.shadowRoot)
|
|
331
260
|
return;
|
|
@@ -334,23 +263,10 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
334
263
|
this.shadowRoot.adoptedStyleSheets = [...existing, this._customCSS];
|
|
335
264
|
}
|
|
336
265
|
}
|
|
337
|
-
// ==========================================================================
|
|
338
|
-
// Public Methods
|
|
339
|
-
// ==========================================================================
|
|
340
|
-
/**
|
|
341
|
-
* Force re-render of the calendar month
|
|
342
|
-
* Useful when external data changes (e.g., async event loading)
|
|
343
|
-
*/
|
|
344
266
|
refresh() {
|
|
345
267
|
this.render();
|
|
346
268
|
}
|
|
347
|
-
|
|
348
|
-
// Event Dispatching
|
|
349
|
-
// ==========================================================================
|
|
350
|
-
/**
|
|
351
|
-
* Dispatch day-click custom event with day context
|
|
352
|
-
*/
|
|
353
|
-
dispatchDayClick(dayContext, domEvent) {
|
|
269
|
+
dispatchDayClick(dayContext, _domEvent) {
|
|
354
270
|
const detail = {
|
|
355
271
|
dayContext,
|
|
356
272
|
value: dayContext.value,
|
|
@@ -362,7 +278,6 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
362
278
|
isWeekend: dayContext.weekend,
|
|
363
279
|
isOtherMonth: dayContext.otherMonth,
|
|
364
280
|
};
|
|
365
|
-
// Dispatch both 'day-click' and 'day-select' (alias)
|
|
366
281
|
for (const eventType of ['day-click', 'day-select']) {
|
|
367
282
|
const event = new CustomEvent(eventType, {
|
|
368
283
|
detail,
|
|
@@ -372,112 +287,149 @@ export class TyCalendarMonth extends HTMLElement {
|
|
|
372
287
|
this.dispatchEvent(event);
|
|
373
288
|
}
|
|
374
289
|
}
|
|
375
|
-
|
|
376
|
-
// Rendering
|
|
377
|
-
// ==========================================================================
|
|
378
|
-
/**
|
|
379
|
-
* Render a single day cell
|
|
380
|
-
*/
|
|
381
|
-
renderDayCell(dayContext, disabled) {
|
|
290
|
+
renderDayCell(dayContext, disabled, isRoving) {
|
|
382
291
|
const dayElement = document.createElement('div');
|
|
383
|
-
// Get content using custom or default function
|
|
384
292
|
const content = this._dayContentFn
|
|
385
293
|
? this._dayContentFn(dayContext)
|
|
386
294
|
: defaultDayContent(dayContext);
|
|
387
|
-
// STRICT DOM-ONLY CHECK for custom functions
|
|
388
295
|
if (this._dayContentFn && content && !isDOMElement(content) && typeof content !== 'string') {
|
|
389
296
|
throw new Error(`Custom dayContentFn must return a DOM element or string, got: ${typeof content}. ` +
|
|
390
297
|
`Use document.createElement() to create DOM elements.`);
|
|
391
298
|
}
|
|
392
|
-
// Apply default classes
|
|
393
299
|
const classes = getDefaultDayClasses(dayContext);
|
|
394
300
|
if (disabled)
|
|
395
301
|
classes.push('disabled');
|
|
396
302
|
dayElement.className = classes.join(' ');
|
|
397
|
-
// Set content
|
|
398
303
|
if (typeof content === 'string') {
|
|
399
304
|
dayElement.textContent = content;
|
|
400
305
|
}
|
|
401
306
|
else if (isDOMElement(content)) {
|
|
402
307
|
dayElement.appendChild(content);
|
|
403
308
|
}
|
|
404
|
-
|
|
405
|
-
|
|
309
|
+
dayElement.setAttribute('role', 'gridcell');
|
|
310
|
+
dayElement.setAttribute('aria-label', new Intl.DateTimeFormat(this._locale, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
|
311
|
+
.format(new Date(dayContext.localValue)));
|
|
312
|
+
dayElement.setAttribute('aria-selected', String(!!dayContext.isSelected));
|
|
313
|
+
if (dayContext.today)
|
|
314
|
+
dayElement.setAttribute('aria-current', 'date');
|
|
315
|
+
if (disabled) {
|
|
316
|
+
dayElement.setAttribute('aria-disabled', 'true');
|
|
317
|
+
dayElement.setAttribute('tabindex', '-1');
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
dayElement.setAttribute('tabindex', isRoving ? '0' : '-1');
|
|
406
321
|
dayElement.addEventListener('pointerdown', (event) => {
|
|
407
322
|
event.preventDefault();
|
|
408
323
|
this.dispatchDayClick(dayContext, event);
|
|
409
324
|
});
|
|
325
|
+
dayElement.addEventListener('keydown', (event) => {
|
|
326
|
+
const ke = event;
|
|
327
|
+
if (ke.key === 'Enter' || ke.key === ' ') {
|
|
328
|
+
ke.preventDefault();
|
|
329
|
+
this.dispatchDayClick(dayContext, event);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
410
332
|
}
|
|
411
333
|
return dayElement;
|
|
412
334
|
}
|
|
413
|
-
/**
|
|
414
|
-
* Main render function - property-based approach
|
|
415
|
-
*/
|
|
416
335
|
render() {
|
|
417
336
|
const root = this.shadowRoot;
|
|
418
337
|
if (!root)
|
|
419
338
|
return;
|
|
420
|
-
// Ensure styles are loaded
|
|
421
339
|
ensureStyles(root, { css: calendarMonthStyles, id: 'ty-calendar-month' });
|
|
422
|
-
// Apply custom CSS if provided
|
|
423
340
|
this.applyCustomCSS();
|
|
424
|
-
// Apply width properties
|
|
425
341
|
this.applyWidthProperties();
|
|
426
|
-
// Convert timestamp to selection info
|
|
427
342
|
let selection;
|
|
428
343
|
if (this._value) {
|
|
429
344
|
const date = new Date(this._value);
|
|
430
345
|
selection = {
|
|
431
346
|
year: date.getFullYear(),
|
|
432
|
-
month: date.getMonth() + 1,
|
|
347
|
+
month: date.getMonth() + 1,
|
|
433
348
|
day: date.getDate()
|
|
434
349
|
};
|
|
435
350
|
}
|
|
436
|
-
// Generate calendar days with selection info
|
|
437
351
|
const days = getCalendarMonthDays(this._displayYear, this._displayMonth, selection);
|
|
438
|
-
// Get localized weekday names
|
|
439
352
|
const weekdays = getLocalizedWeekdays(this._locale, 'short');
|
|
440
|
-
// Clear and rebuild
|
|
441
353
|
root.innerHTML = '';
|
|
442
|
-
// Create unified flex container
|
|
443
354
|
const calendarContainer = document.createElement('div');
|
|
444
355
|
calendarContainer.className = `calendar-flex-container calendar-size-${this._size}`;
|
|
445
|
-
|
|
356
|
+
calendarContainer.setAttribute('role', 'grid');
|
|
357
|
+
calendarContainer.setAttribute('aria-label', new Intl.DateTimeFormat(this._locale, { month: 'long', year: 'numeric' })
|
|
358
|
+
.format(new Date(this._displayYear, this._displayMonth - 1, 1)));
|
|
446
359
|
const headerRow = document.createElement('div');
|
|
447
360
|
headerRow.className = 'calendar-row calendar-header-row';
|
|
361
|
+
headerRow.setAttribute('role', 'row');
|
|
448
362
|
weekdays.forEach(weekday => {
|
|
449
363
|
const headerCell = document.createElement('div');
|
|
450
364
|
headerCell.className = 'calendar-cell calendar-header-cell';
|
|
365
|
+
headerCell.setAttribute('role', 'columnheader');
|
|
451
366
|
headerCell.textContent = weekday;
|
|
452
367
|
headerRow.appendChild(headerCell);
|
|
453
368
|
});
|
|
454
369
|
calendarContainer.appendChild(headerRow);
|
|
455
|
-
// Create day rows (6 weeks of 7 days each)
|
|
456
370
|
const dayWeeks = [];
|
|
457
371
|
for (let i = 0; i < 42; i += 7) {
|
|
458
372
|
dayWeeks.push(days.slice(i, i + 7));
|
|
459
373
|
}
|
|
460
|
-
// Bounds for disabling days (UTC-midnight, same space as DayContext.value)
|
|
461
374
|
const minTs = isoToUTCTimestamp(this._min);
|
|
462
375
|
const maxTs = isoToUTCTimestamp(this._max);
|
|
376
|
+
const disabledAt = (i) => {
|
|
377
|
+
const v = days[i].value;
|
|
378
|
+
return (minTs !== null && v < minTs) || (maxTs !== null && v > maxTs);
|
|
379
|
+
};
|
|
380
|
+
let defaultIndex = days.findIndex(d => d.isSelected);
|
|
381
|
+
if (defaultIndex === -1)
|
|
382
|
+
defaultIndex = days.findIndex(d => d.today);
|
|
383
|
+
if (defaultIndex === -1)
|
|
384
|
+
defaultIndex = 0;
|
|
385
|
+
if (this._focusedIndex === null ||
|
|
386
|
+
this._focusedIndex < 0 ||
|
|
387
|
+
this._focusedIndex > 41 ||
|
|
388
|
+
disabledAt(this._focusedIndex)) {
|
|
389
|
+
this._focusedIndex = defaultIndex;
|
|
390
|
+
}
|
|
391
|
+
this._cellElements = [];
|
|
392
|
+
let flatIndex = 0;
|
|
463
393
|
dayWeeks.forEach(week => {
|
|
464
394
|
const dayRow = document.createElement('div');
|
|
465
395
|
dayRow.className = 'calendar-row calendar-day-row';
|
|
396
|
+
dayRow.setAttribute('role', 'row');
|
|
466
397
|
week.forEach(dayContext => {
|
|
467
398
|
const disabled = (minTs !== null && dayContext.value < minTs) ||
|
|
468
399
|
(maxTs !== null && dayContext.value > maxTs);
|
|
469
|
-
const dayCell = this.renderDayCell(dayContext, disabled);
|
|
470
|
-
// Add unified cell classes for flex layout
|
|
400
|
+
const dayCell = this.renderDayCell(dayContext, disabled, flatIndex === this._focusedIndex);
|
|
471
401
|
dayCell.className = `${dayCell.className} calendar-cell calendar-day-cell`;
|
|
472
402
|
dayRow.appendChild(dayCell);
|
|
403
|
+
this._cellElements[flatIndex] = dayCell;
|
|
404
|
+
flatIndex++;
|
|
473
405
|
});
|
|
474
406
|
calendarContainer.appendChild(dayRow);
|
|
475
407
|
});
|
|
408
|
+
calendarContainer.addEventListener('keydown', (event) => {
|
|
409
|
+
const ke = event;
|
|
410
|
+
const delta = ke.key === 'ArrowLeft' ? -1 :
|
|
411
|
+
ke.key === 'ArrowRight' ? 1 :
|
|
412
|
+
ke.key === 'ArrowUp' ? -7 :
|
|
413
|
+
ke.key === 'ArrowDown' ? 7 :
|
|
414
|
+
0;
|
|
415
|
+
if (delta === 0)
|
|
416
|
+
return;
|
|
417
|
+
const currentIndex = this._focusedIndex ?? defaultIndex;
|
|
418
|
+
const nextIndex = currentIndex + delta;
|
|
419
|
+
if (nextIndex < 0 || nextIndex > 41 || disabledAt(nextIndex))
|
|
420
|
+
return;
|
|
421
|
+
ke.preventDefault();
|
|
422
|
+
this._cellElements[currentIndex]?.setAttribute('tabindex', '-1');
|
|
423
|
+
this._focusedIndex = nextIndex;
|
|
424
|
+
const nextCell = this._cellElements[nextIndex];
|
|
425
|
+
if (nextCell) {
|
|
426
|
+
nextCell.setAttribute('tabindex', '0');
|
|
427
|
+
nextCell.focus();
|
|
428
|
+
}
|
|
429
|
+
});
|
|
476
430
|
root.appendChild(calendarContainer);
|
|
477
431
|
}
|
|
478
432
|
}
|
|
479
|
-
// Register the custom element
|
|
480
433
|
if (!customElements.get('ty-calendar-month')) {
|
|
481
434
|
customElements.define('ty-calendar-month', TyCalendarMonth);
|
|
482
435
|
}
|
|
483
|
-
//# 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
|