@carbon-labs/wc-date-picker 0.2.0
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/LICENSE +201 -0
- package/es/__stories__/date-picker.stories.d.ts +949 -0
- package/es/components/date-picker/calendar-renderer.d.ts +147 -0
- package/es/components/date-picker/calendar-renderer.js +406 -0
- package/es/components/date-picker/calendar-renderer.js.map +1 -0
- package/es/components/date-picker/date-picker-input-skeleton.d.ts +34 -0
- package/es/components/date-picker/date-picker-input-skeleton.js +77 -0
- package/es/components/date-picker/date-picker-input-skeleton.js.map +1 -0
- package/es/components/date-picker/date-picker-input.d.ts +539 -0
- package/es/components/date-picker/date-picker-input.js +413 -0
- package/es/components/date-picker/date-picker-input.js.map +1 -0
- package/es/components/date-picker/date-picker.d.ts +977 -0
- package/es/components/date-picker/date-picker.js +1047 -0
- package/es/components/date-picker/date-picker.js.map +1 -0
- package/es/components/date-picker/date-picker.scss.js +6 -0
- package/es/components/date-picker/date-picker.scss.js.map +1 -0
- package/es/components/date-picker/defs.d.ts +45 -0
- package/es/components/date-picker/defs.js +51 -0
- package/es/components/date-picker/defs.js.map +1 -0
- package/es/index.d.ts +10 -0
- package/es/index.js +5 -0
- package/es/index.js.map +1 -0
- package/es/state-machine/actions.d.ts +35 -0
- package/es/state-machine/actions.js +860 -0
- package/es/state-machine/actions.js.map +1 -0
- package/es/state-machine/adapters/web-component-adapter.d.ts +142 -0
- package/es/state-machine/adapters/web-component-adapter.js +269 -0
- package/es/state-machine/adapters/web-component-adapter.js.map +1 -0
- package/es/state-machine/effects.d.ts +35 -0
- package/es/state-machine/effects.js +92 -0
- package/es/state-machine/effects.js.map +1 -0
- package/es/state-machine/guards.d.ts +41 -0
- package/es/state-machine/guards.js +143 -0
- package/es/state-machine/guards.js.map +1 -0
- package/es/state-machine/index.d.ts +12 -0
- package/es/state-machine/machine.d.ts +92 -0
- package/es/state-machine/machine.js +272 -0
- package/es/state-machine/machine.js.map +1 -0
- package/es/state-machine/states.d.ts +89 -0
- package/es/state-machine/states.js +105 -0
- package/es/state-machine/states.js.map +1 -0
- package/es/state-machine/temporal-utils.d.ts +203 -0
- package/es/state-machine/temporal-utils.js +128 -0
- package/es/state-machine/temporal-utils.js.map +1 -0
- package/es/state-machine/types.d.ts +163 -0
- package/es/temp-imports/.storybook/templates/with-layer.d.ts +26 -0
- package/es/temp-imports/globals/decorators/carbon-element.d.ts +45 -0
- package/es/temp-imports/globals/decorators/carbon-element.js +63 -0
- package/es/temp-imports/globals/decorators/carbon-element.js.map +1 -0
- package/es/temp-imports/globals/decorators/host-listener.d.ts +17 -0
- package/es/temp-imports/globals/decorators/host-listener.js +62 -0
- package/es/temp-imports/globals/decorators/host-listener.js.map +1 -0
- package/es/temp-imports/globals/internal/collection-helpers.d.ts +41 -0
- package/es/temp-imports/globals/internal/handle.d.ts +16 -0
- package/es/temp-imports/globals/internal/icon-loader-utils.d.ts +31 -0
- package/es/temp-imports/globals/internal/icon-loader-utils.js +69 -0
- package/es/temp-imports/globals/internal/icon-loader-utils.js.map +1 -0
- package/es/temp-imports/globals/internal/icon-loader.d.ts +28 -0
- package/es/temp-imports/globals/internal/icon-loader.js +43 -0
- package/es/temp-imports/globals/internal/icon-loader.js.map +1 -0
- package/es/temp-imports/globals/mixins/focus.d.ts +369 -0
- package/es/temp-imports/globals/mixins/focus.js +38 -0
- package/es/temp-imports/globals/mixins/focus.js.map +1 -0
- package/es/temp-imports/globals/mixins/form.d.ts +379 -0
- package/es/temp-imports/globals/mixins/form.js +49 -0
- package/es/temp-imports/globals/mixins/form.js.map +1 -0
- package/es/temp-imports/globals/mixins/host-listener.d.ts +387 -0
- package/es/temp-imports/globals/mixins/host-listener.js +76 -0
- package/es/temp-imports/globals/mixins/host-listener.js.map +1 -0
- package/es/temp-imports/globals/mixins/on.d.ts +9 -0
- package/es/temp-imports/globals/mixins/on.js +19 -0
- package/es/temp-imports/globals/mixins/on.js.map +1 -0
- package/es/temp-imports/globals/settings.d.ts +13 -0
- package/es/temp-imports/globals/settings.js +76 -0
- package/es/temp-imports/globals/settings.js.map +1 -0
- package/es/temp-imports/globals/shared-enums.d.ts +19 -0
- package/es/temp-imports/globals/shared-enums.js +23 -0
- package/es/temp-imports/globals/shared-enums.js.map +1 -0
- package/lib/__stories__/date-picker.stories.d.ts +949 -0
- package/lib/components/date-picker/calendar-renderer.d.ts +147 -0
- package/lib/components/date-picker/calendar-renderer.js +408 -0
- package/lib/components/date-picker/calendar-renderer.js.map +1 -0
- package/lib/components/date-picker/date-picker-input-skeleton.d.ts +34 -0
- package/lib/components/date-picker/date-picker-input-skeleton.js +79 -0
- package/lib/components/date-picker/date-picker-input-skeleton.js.map +1 -0
- package/lib/components/date-picker/date-picker-input.d.ts +539 -0
- package/lib/components/date-picker/date-picker-input.js +422 -0
- package/lib/components/date-picker/date-picker-input.js.map +1 -0
- package/lib/components/date-picker/date-picker.d.ts +977 -0
- package/lib/components/date-picker/date-picker.js +1049 -0
- package/lib/components/date-picker/date-picker.js.map +1 -0
- package/lib/components/date-picker/date-picker.scss.js +10 -0
- package/lib/components/date-picker/date-picker.scss.js.map +1 -0
- package/lib/components/date-picker/defs.d.ts +45 -0
- package/lib/components/date-picker/defs.js +56 -0
- package/lib/components/date-picker/defs.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/state-machine/actions.d.ts +35 -0
- package/lib/state-machine/actions.js +864 -0
- package/lib/state-machine/actions.js.map +1 -0
- package/lib/state-machine/adapters/web-component-adapter.d.ts +142 -0
- package/lib/state-machine/adapters/web-component-adapter.js +271 -0
- package/lib/state-machine/adapters/web-component-adapter.js.map +1 -0
- package/lib/state-machine/effects.d.ts +35 -0
- package/lib/state-machine/effects.js +96 -0
- package/lib/state-machine/effects.js.map +1 -0
- package/lib/state-machine/guards.d.ts +41 -0
- package/lib/state-machine/guards.js +147 -0
- package/lib/state-machine/guards.js.map +1 -0
- package/lib/state-machine/index.d.ts +12 -0
- package/lib/state-machine/machine.d.ts +92 -0
- package/lib/state-machine/machine.js +274 -0
- package/lib/state-machine/machine.js.map +1 -0
- package/lib/state-machine/states.d.ts +89 -0
- package/lib/state-machine/states.js +105 -0
- package/lib/state-machine/states.js.map +1 -0
- package/lib/state-machine/temporal-utils.d.ts +203 -0
- package/lib/state-machine/temporal-utils.js +136 -0
- package/lib/state-machine/temporal-utils.js.map +1 -0
- package/lib/state-machine/types.d.ts +163 -0
- package/lib/temp-imports/.storybook/templates/with-layer.d.ts +26 -0
- package/lib/temp-imports/globals/decorators/carbon-element.d.ts +45 -0
- package/lib/temp-imports/globals/decorators/carbon-element.js +65 -0
- package/lib/temp-imports/globals/decorators/carbon-element.js.map +1 -0
- package/lib/temp-imports/globals/decorators/host-listener.d.ts +17 -0
- package/lib/temp-imports/globals/decorators/host-listener.js +66 -0
- package/lib/temp-imports/globals/decorators/host-listener.js.map +1 -0
- package/lib/temp-imports/globals/internal/collection-helpers.d.ts +41 -0
- package/lib/temp-imports/globals/internal/handle.d.ts +16 -0
- package/lib/temp-imports/globals/internal/icon-loader-utils.d.ts +31 -0
- package/lib/temp-imports/globals/internal/icon-loader-utils.js +72 -0
- package/lib/temp-imports/globals/internal/icon-loader-utils.js.map +1 -0
- package/lib/temp-imports/globals/internal/icon-loader.d.ts +28 -0
- package/lib/temp-imports/globals/internal/icon-loader.js +45 -0
- package/lib/temp-imports/globals/internal/icon-loader.js.map +1 -0
- package/lib/temp-imports/globals/mixins/focus.d.ts +369 -0
- package/lib/temp-imports/globals/mixins/focus.js +42 -0
- package/lib/temp-imports/globals/mixins/focus.js.map +1 -0
- package/lib/temp-imports/globals/mixins/form.d.ts +379 -0
- package/lib/temp-imports/globals/mixins/form.js +53 -0
- package/lib/temp-imports/globals/mixins/form.js.map +1 -0
- package/lib/temp-imports/globals/mixins/host-listener.d.ts +387 -0
- package/lib/temp-imports/globals/mixins/host-listener.js +80 -0
- package/lib/temp-imports/globals/mixins/host-listener.js.map +1 -0
- package/lib/temp-imports/globals/mixins/on.d.ts +9 -0
- package/lib/temp-imports/globals/mixins/on.js +23 -0
- package/lib/temp-imports/globals/mixins/on.js.map +1 -0
- package/lib/temp-imports/globals/settings.d.ts +13 -0
- package/lib/temp-imports/globals/settings.js +79 -0
- package/lib/temp-imports/globals/settings.js.map +1 -0
- package/lib/temp-imports/globals/shared-enums.d.ts +19 -0
- package/lib/temp-imports/globals/shared-enums.js +23 -0
- package/lib/temp-imports/globals/shared-enums.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright IBM Corp. 2026
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Date picker state machine states
|
|
11
|
+
*/
|
|
12
|
+
exports.DatePickerState = void 0;
|
|
13
|
+
(function (DatePickerState) {
|
|
14
|
+
/**
|
|
15
|
+
* Initial state - calendar closed, no focus
|
|
16
|
+
*/
|
|
17
|
+
DatePickerState["IDLE"] = "idle";
|
|
18
|
+
/**
|
|
19
|
+
* Input has focus, calendar closed
|
|
20
|
+
*/
|
|
21
|
+
DatePickerState["FOCUSED"] = "focused";
|
|
22
|
+
/**
|
|
23
|
+
* Calendar dropdown is open
|
|
24
|
+
*/
|
|
25
|
+
DatePickerState["CALENDAR_OPEN"] = "calendar_open";
|
|
26
|
+
/**
|
|
27
|
+
* User is selecting the start date (range mode)
|
|
28
|
+
*/
|
|
29
|
+
DatePickerState["SELECTING_START"] = "selecting_start";
|
|
30
|
+
/**
|
|
31
|
+
* User is selecting the end date (range mode)
|
|
32
|
+
*/
|
|
33
|
+
DatePickerState["SELECTING_END"] = "selecting_end";
|
|
34
|
+
/**
|
|
35
|
+
* Date(s) have been selected
|
|
36
|
+
*/
|
|
37
|
+
DatePickerState["DATE_SELECTED"] = "date_selected";
|
|
38
|
+
/**
|
|
39
|
+
* Component is disabled
|
|
40
|
+
*/
|
|
41
|
+
DatePickerState["DISABLED"] = "disabled";
|
|
42
|
+
/**
|
|
43
|
+
* Component is read-only
|
|
44
|
+
*/
|
|
45
|
+
DatePickerState["READONLY"] = "readonly";
|
|
46
|
+
/**
|
|
47
|
+
* Component is in an error state
|
|
48
|
+
*/
|
|
49
|
+
DatePickerState["ERROR"] = "error";
|
|
50
|
+
})(exports.DatePickerState || (exports.DatePickerState = {}));
|
|
51
|
+
/**
|
|
52
|
+
* Date picker events
|
|
53
|
+
*/
|
|
54
|
+
exports.DatePickerEvent = void 0;
|
|
55
|
+
(function (DatePickerEvent) {
|
|
56
|
+
// Input events
|
|
57
|
+
DatePickerEvent["INPUT_FOCUS"] = "INPUT_FOCUS";
|
|
58
|
+
DatePickerEvent["INPUT_BLUR"] = "INPUT_BLUR";
|
|
59
|
+
DatePickerEvent["INPUT_CHANGE"] = "INPUT_CHANGE";
|
|
60
|
+
// Calendar events
|
|
61
|
+
DatePickerEvent["CALENDAR_ICON_CLICK"] = "CALENDAR_ICON_CLICK";
|
|
62
|
+
DatePickerEvent["CALENDAR_OPEN"] = "CALENDAR_OPEN";
|
|
63
|
+
DatePickerEvent["CALENDAR_CLOSE"] = "CALENDAR_CLOSE";
|
|
64
|
+
// Calendar navigation events
|
|
65
|
+
DatePickerEvent["PREV_MONTH"] = "PREV_MONTH";
|
|
66
|
+
DatePickerEvent["NEXT_MONTH"] = "NEXT_MONTH";
|
|
67
|
+
DatePickerEvent["PREV_YEAR"] = "PREV_YEAR";
|
|
68
|
+
DatePickerEvent["NEXT_YEAR"] = "NEXT_YEAR";
|
|
69
|
+
DatePickerEvent["GO_TO_TODAY"] = "GO_TO_TODAY";
|
|
70
|
+
// Date selection events
|
|
71
|
+
DatePickerEvent["DATE_SELECT"] = "DATE_SELECT";
|
|
72
|
+
DatePickerEvent["RANGE_START_SELECT"] = "RANGE_START_SELECT";
|
|
73
|
+
DatePickerEvent["RANGE_END_SELECT"] = "RANGE_END_SELECT";
|
|
74
|
+
// User interaction events
|
|
75
|
+
DatePickerEvent["OUTSIDE_CLICK"] = "OUTSIDE_CLICK";
|
|
76
|
+
DatePickerEvent["ESCAPE_KEY"] = "ESCAPE_KEY";
|
|
77
|
+
DatePickerEvent["TAB_KEY"] = "TAB_KEY";
|
|
78
|
+
DatePickerEvent["SHIFT_TAB_KEY"] = "SHIFT_TAB_KEY";
|
|
79
|
+
DatePickerEvent["ENTER_KEY"] = "ENTER_KEY";
|
|
80
|
+
// Arrow key navigation
|
|
81
|
+
DatePickerEvent["ARROW_UP"] = "ARROW_UP";
|
|
82
|
+
DatePickerEvent["ARROW_DOWN"] = "ARROW_DOWN";
|
|
83
|
+
DatePickerEvent["ARROW_LEFT"] = "ARROW_LEFT";
|
|
84
|
+
DatePickerEvent["ARROW_RIGHT"] = "ARROW_RIGHT";
|
|
85
|
+
// Page navigation
|
|
86
|
+
DatePickerEvent["PAGE_UP"] = "PAGE_UP";
|
|
87
|
+
DatePickerEvent["PAGE_DOWN"] = "PAGE_DOWN";
|
|
88
|
+
// Week navigation
|
|
89
|
+
DatePickerEvent["HOME_KEY"] = "HOME_KEY";
|
|
90
|
+
DatePickerEvent["END_KEY"] = "END_KEY";
|
|
91
|
+
// State change events
|
|
92
|
+
DatePickerEvent["DISABLE"] = "DISABLE";
|
|
93
|
+
DatePickerEvent["ENABLE"] = "ENABLE";
|
|
94
|
+
DatePickerEvent["SET_READONLY"] = "SET_READONLY";
|
|
95
|
+
DatePickerEvent["UNSET_READONLY"] = "UNSET_READONLY";
|
|
96
|
+
DatePickerEvent["VALUE_CHANGE"] = "VALUE_CHANGE";
|
|
97
|
+
DatePickerEvent["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
98
|
+
DatePickerEvent["CLEAR_ERROR"] = "CLEAR_ERROR";
|
|
99
|
+
// Configuration events
|
|
100
|
+
DatePickerEvent["SET_MIN_DATE"] = "SET_MIN_DATE";
|
|
101
|
+
DatePickerEvent["SET_MAX_DATE"] = "SET_MAX_DATE";
|
|
102
|
+
DatePickerEvent["SET_DATE_FORMAT"] = "SET_DATE_FORMAT";
|
|
103
|
+
})(exports.DatePickerEvent || (exports.DatePickerEvent = {}));
|
|
104
|
+
// Made with Bob
|
|
105
|
+
//# sourceMappingURL=states.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states.js","sources":["../../../state-machine/states.ts"],"sourcesContent":[null],"names":["DatePickerState","DatePickerEvent"],"mappings":"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"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Temporal API utilities for date picker
|
|
9
|
+
* Uses the modern Temporal API for robust date handling
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Convert a Date object to Temporal.PlainDate
|
|
13
|
+
*
|
|
14
|
+
* @param {Date} date - JavaScript Date object
|
|
15
|
+
* @returns Temporal.PlainDate
|
|
16
|
+
*/
|
|
17
|
+
export declare function dateToPlainDate(date: Date): Temporal.PlainDate;
|
|
18
|
+
/**
|
|
19
|
+
* Convert Temporal.PlainDate to Date object
|
|
20
|
+
*
|
|
21
|
+
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
22
|
+
* @returns JavaScript Date object
|
|
23
|
+
*/
|
|
24
|
+
export declare function plainDateToDate(plainDate: Temporal.PlainDate): Date;
|
|
25
|
+
/**
|
|
26
|
+
* Convert Temporal.PlainDate to ISO date string (YYYY-MM-DD)
|
|
27
|
+
*
|
|
28
|
+
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
29
|
+
* @returns ISO date string
|
|
30
|
+
*/
|
|
31
|
+
export declare function plainDateToISOString(plainDate: Temporal.PlainDate): string;
|
|
32
|
+
/**
|
|
33
|
+
* Parse ISO date string to Temporal.PlainDate
|
|
34
|
+
*
|
|
35
|
+
* @param {string} isoString - ISO date string (YYYY-MM-DD)
|
|
36
|
+
* @returns Temporal.PlainDate or null if invalid
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseISOToPlainDate(isoString: string): Temporal.PlainDate | null;
|
|
39
|
+
/**
|
|
40
|
+
* Parse a date string in various formats to Temporal.PlainDate
|
|
41
|
+
* Supports: ISO (YYYY-MM-DD), US (MM/DD/YYYY), and JavaScript Date objects
|
|
42
|
+
*
|
|
43
|
+
* @param {string | Date} dateInput - Date string or Date object
|
|
44
|
+
* @returns Temporal.PlainDate or null if invalid
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseDateToPlainDate(dateInput: string | Date | null | undefined): Temporal.PlainDate | null;
|
|
47
|
+
/**
|
|
48
|
+
* Compare two Temporal.PlainDate objects
|
|
49
|
+
*
|
|
50
|
+
* @param {Temporal.PlainDate} date1 - First date
|
|
51
|
+
* @param {Temporal.PlainDate} date2 - Second date
|
|
52
|
+
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
53
|
+
*/
|
|
54
|
+
export declare function comparePlainDates(date1: Temporal.PlainDate, date2: Temporal.PlainDate): number;
|
|
55
|
+
/**
|
|
56
|
+
* Check if a date is within a range
|
|
57
|
+
*
|
|
58
|
+
* @param {Temporal.PlainDate} date - Date to check
|
|
59
|
+
* @param {Temporal.PlainDate | null} minDate - Minimum date (inclusive)
|
|
60
|
+
* @param {Temporal.PlainDate | null} maxDate - Maximum date (inclusive)
|
|
61
|
+
* @returns True if date is within range
|
|
62
|
+
*/
|
|
63
|
+
export declare function isDateInRange(date: Temporal.PlainDate, minDate: Temporal.PlainDate | null, maxDate: Temporal.PlainDate | null): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Format a Temporal.PlainDate according to a format string
|
|
66
|
+
* Supports common format tokens: Y, m, d
|
|
67
|
+
*
|
|
68
|
+
* @param {Temporal.PlainDate} date - Date to format
|
|
69
|
+
* @param {string} format - Format string (e.g., 'm/d/Y', 'Y-m-d')
|
|
70
|
+
* @returns Formatted date string
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatPlainDate(date: Temporal.PlainDate, format: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get today's date as Temporal.PlainDate
|
|
75
|
+
*
|
|
76
|
+
* @returns Today's date
|
|
77
|
+
*/
|
|
78
|
+
export declare function getToday(): Temporal.PlainDate;
|
|
79
|
+
/**
|
|
80
|
+
* Add days to a date
|
|
81
|
+
*
|
|
82
|
+
* @param {Temporal.PlainDate} date - Starting date
|
|
83
|
+
* @param {number} days - Number of days to add (can be negative)
|
|
84
|
+
* @returns New date
|
|
85
|
+
*/
|
|
86
|
+
export declare function addDays(date: Temporal.PlainDate, days: number): Temporal.PlainDate;
|
|
87
|
+
/**
|
|
88
|
+
* Add months to a date
|
|
89
|
+
*
|
|
90
|
+
* @param {Temporal.PlainDate} date - Starting date
|
|
91
|
+
* @param {number} months - Number of months to add (can be negative)
|
|
92
|
+
* @returns New date
|
|
93
|
+
*/
|
|
94
|
+
export declare function addMonths(date: Temporal.PlainDate, months: number): Temporal.PlainDate;
|
|
95
|
+
/**
|
|
96
|
+
* Get the number of days between two dates
|
|
97
|
+
*
|
|
98
|
+
* @param {Temporal.PlainDate} date1 - First date
|
|
99
|
+
* @param {Temporal.PlainDate} date2 - Second date
|
|
100
|
+
* @returns Number of days (positive if date2 is after date1)
|
|
101
|
+
*/
|
|
102
|
+
export declare function daysBetween(date1: Temporal.PlainDate, date2: Temporal.PlainDate): number;
|
|
103
|
+
/**
|
|
104
|
+
* Check if two dates are equal
|
|
105
|
+
*
|
|
106
|
+
* @param {Temporal.PlainDate} date1 - First date
|
|
107
|
+
* @param {Temporal.PlainDate} date2 - Second date
|
|
108
|
+
* @returns True if dates are equal
|
|
109
|
+
*/
|
|
110
|
+
export declare function areDatesEqual(date1: Temporal.PlainDate | null, date2: Temporal.PlainDate | null): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Get the start of the month for a given date
|
|
113
|
+
*
|
|
114
|
+
* @param {Temporal.PlainDate} date - Input date
|
|
115
|
+
* @returns First day of the month
|
|
116
|
+
*/
|
|
117
|
+
export declare function getMonthStart(date: Temporal.PlainDate): Temporal.PlainDate;
|
|
118
|
+
/**
|
|
119
|
+
* Get the end of the month for a given date
|
|
120
|
+
*
|
|
121
|
+
* @param {Temporal.PlainDate} date - Input date
|
|
122
|
+
* @returns Last day of the month
|
|
123
|
+
*/
|
|
124
|
+
export declare function getMonthEnd(date: Temporal.PlainDate): Temporal.PlainDate;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a date is today
|
|
127
|
+
*
|
|
128
|
+
* @param {Temporal.PlainDate} date - Date to check
|
|
129
|
+
* @returns True if date is today
|
|
130
|
+
*/
|
|
131
|
+
export declare function isToday(date: Temporal.PlainDate): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Check if a date is in the past
|
|
134
|
+
*
|
|
135
|
+
* @param {Temporal.PlainDate} date - Date to check
|
|
136
|
+
* @returns True if date is before today
|
|
137
|
+
*/
|
|
138
|
+
export declare function isPast(date: Temporal.PlainDate): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Check if a date is in the future
|
|
141
|
+
*
|
|
142
|
+
* @param {Temporal.PlainDate} date - Date to check
|
|
143
|
+
* @returns True if date is after today
|
|
144
|
+
*/
|
|
145
|
+
export declare function isFuture(date: Temporal.PlainDate): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Parse a date string with a specific format
|
|
148
|
+
* Supports common format tokens: Y, m, d
|
|
149
|
+
*
|
|
150
|
+
* @param {string} dateString - Date string to parse
|
|
151
|
+
* @param {string} format - Format string (e.g., 'm/d/Y', 'Y-m-d')
|
|
152
|
+
* @returns Temporal.PlainDate or null if invalid
|
|
153
|
+
*/
|
|
154
|
+
export declare function parseDateString(dateString: string, format: string): Temporal.PlainDate | null;
|
|
155
|
+
/**
|
|
156
|
+
* Polyfill check for Temporal API
|
|
157
|
+
*
|
|
158
|
+
* @returns True if Temporal API is available
|
|
159
|
+
*/
|
|
160
|
+
export declare function isTemporalAvailable(): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Get a fallback date handler if Temporal is not available
|
|
163
|
+
* This provides a migration path for browsers without Temporal support
|
|
164
|
+
*/
|
|
165
|
+
export declare function getDateHandler(): {
|
|
166
|
+
type: "temporal";
|
|
167
|
+
toISOString: typeof plainDateToISOString;
|
|
168
|
+
fromISOString: typeof parseISOToPlainDate;
|
|
169
|
+
compare: typeof comparePlainDates;
|
|
170
|
+
format: typeof formatPlainDate;
|
|
171
|
+
isInRange: typeof isDateInRange;
|
|
172
|
+
} | {
|
|
173
|
+
type: "date";
|
|
174
|
+
/**
|
|
175
|
+
*
|
|
176
|
+
* @param {Temporal.PlainDate} date - The date to convert
|
|
177
|
+
*/
|
|
178
|
+
toISOString: (date: Date) => string;
|
|
179
|
+
/**
|
|
180
|
+
*
|
|
181
|
+
* @param {string} str - The ISO string to parse
|
|
182
|
+
*/
|
|
183
|
+
fromISOString: (str: string) => Date | null;
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
* @param {Temporal.PlainDate} d1 - First date
|
|
187
|
+
* @param {Temporal.PlainDate} d2 - Second date
|
|
188
|
+
*/
|
|
189
|
+
compare: (d1: Date, d2: Date) => number;
|
|
190
|
+
/**
|
|
191
|
+
*
|
|
192
|
+
* @param {Temporal.PlainDate} date - The date to format
|
|
193
|
+
* @param {string} format - The format string
|
|
194
|
+
*/
|
|
195
|
+
format: (date: Date, format: string) => string;
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
199
|
+
* @param {Temporal.PlainDate | null} min - Minimum date
|
|
200
|
+
* @param {Temporal.PlainDate | null} max - Maximum date
|
|
201
|
+
*/
|
|
202
|
+
isInRange: (date: Date, min: Date | null, max: Date | null) => boolean;
|
|
203
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright IBM Corp. 2026
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Temporal API utilities for date picker
|
|
11
|
+
* Uses the modern Temporal API for robust date handling
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Convert a Date object to Temporal.PlainDate
|
|
15
|
+
*
|
|
16
|
+
* @param {Date} date - JavaScript Date object
|
|
17
|
+
* @returns Temporal.PlainDate
|
|
18
|
+
*/
|
|
19
|
+
function dateToPlainDate(date) {
|
|
20
|
+
return Temporal.PlainDate.from({
|
|
21
|
+
year: date.getFullYear(),
|
|
22
|
+
month: date.getMonth() + 1,
|
|
23
|
+
day: date.getDate(),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert Temporal.PlainDate to Date object
|
|
28
|
+
*
|
|
29
|
+
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
30
|
+
* @returns JavaScript Date object
|
|
31
|
+
*/
|
|
32
|
+
function plainDateToDate(plainDate) {
|
|
33
|
+
return new Date(plainDate.year, plainDate.month - 1, plainDate.day);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Convert Temporal.PlainDate to ISO date string (YYYY-MM-DD)
|
|
37
|
+
*
|
|
38
|
+
* @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
|
|
39
|
+
* @returns ISO date string
|
|
40
|
+
*/
|
|
41
|
+
function plainDateToISOString(plainDate) {
|
|
42
|
+
return plainDate.toString();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse ISO date string to Temporal.PlainDate
|
|
46
|
+
*
|
|
47
|
+
* @param {string} isoString - ISO date string (YYYY-MM-DD)
|
|
48
|
+
* @returns Temporal.PlainDate or null if invalid
|
|
49
|
+
*/
|
|
50
|
+
function parseISOToPlainDate(isoString) {
|
|
51
|
+
try {
|
|
52
|
+
return Temporal.PlainDate.from(isoString);
|
|
53
|
+
}
|
|
54
|
+
catch (_a) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse a date string in various formats to Temporal.PlainDate
|
|
60
|
+
* Supports: ISO (YYYY-MM-DD), US (MM/DD/YYYY), and JavaScript Date objects
|
|
61
|
+
*
|
|
62
|
+
* @param {string | Date} dateInput - Date string or Date object
|
|
63
|
+
* @returns Temporal.PlainDate or null if invalid
|
|
64
|
+
*/
|
|
65
|
+
function parseDateToPlainDate(dateInput) {
|
|
66
|
+
if (!dateInput) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
// Handle Date objects
|
|
70
|
+
if (dateInput instanceof Date) {
|
|
71
|
+
return dateToPlainDate(dateInput);
|
|
72
|
+
}
|
|
73
|
+
// Try ISO format first (YYYY-MM-DD)
|
|
74
|
+
try {
|
|
75
|
+
return Temporal.PlainDate.from(dateInput);
|
|
76
|
+
}
|
|
77
|
+
catch (_a) {
|
|
78
|
+
// Not ISO format, try parsing MM/DD/YYYY or M/D/YYYY
|
|
79
|
+
const parts = dateInput.split('/');
|
|
80
|
+
if (parts.length === 3) {
|
|
81
|
+
const month = parseInt(parts[0], 10);
|
|
82
|
+
const day = parseInt(parts[1], 10);
|
|
83
|
+
const year = parseInt(parts[2], 10);
|
|
84
|
+
if (!isNaN(month) && !isNaN(day) && !isNaN(year)) {
|
|
85
|
+
try {
|
|
86
|
+
return Temporal.PlainDate.from({
|
|
87
|
+
year,
|
|
88
|
+
month,
|
|
89
|
+
day,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (_b) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compare two Temporal.PlainDate objects
|
|
102
|
+
*
|
|
103
|
+
* @param {Temporal.PlainDate} date1 - First date
|
|
104
|
+
* @param {Temporal.PlainDate} date2 - Second date
|
|
105
|
+
* @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
|
|
106
|
+
*/
|
|
107
|
+
function comparePlainDates(date1, date2) {
|
|
108
|
+
return Temporal.PlainDate.compare(date1, date2);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Check if a date is within a range
|
|
112
|
+
*
|
|
113
|
+
* @param {Temporal.PlainDate} date - Date to check
|
|
114
|
+
* @param {Temporal.PlainDate | null} minDate - Minimum date (inclusive)
|
|
115
|
+
* @param {Temporal.PlainDate | null} maxDate - Maximum date (inclusive)
|
|
116
|
+
* @returns True if date is within range
|
|
117
|
+
*/
|
|
118
|
+
function isDateInRange(date, minDate, maxDate) {
|
|
119
|
+
if (minDate && comparePlainDates(date, minDate) < 0) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (maxDate && comparePlainDates(date, maxDate) > 0) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
// Made with Bob
|
|
128
|
+
|
|
129
|
+
exports.comparePlainDates = comparePlainDates;
|
|
130
|
+
exports.dateToPlainDate = dateToPlainDate;
|
|
131
|
+
exports.isDateInRange = isDateInRange;
|
|
132
|
+
exports.parseDateToPlainDate = parseDateToPlainDate;
|
|
133
|
+
exports.parseISOToPlainDate = parseISOToPlainDate;
|
|
134
|
+
exports.plainDateToDate = plainDateToDate;
|
|
135
|
+
exports.plainDateToISOString = plainDateToISOString;
|
|
136
|
+
//# sourceMappingURL=temporal-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal-utils.js","sources":["../../../state-machine/temporal-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AAEH;;;AAGG;AAEH;;;;;AAKG;AACG,SAAU,eAAe,CAAC,IAAU,EAAA;AACxC,IAAA,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;AAC7B,QAAA,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE;AACxB,QAAA,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;AAC1B,QAAA,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE;AACpB,KAAA,CAAC;AACJ;AAEA;;;;;AAKG;AACG,SAAU,eAAe,CAAC,SAA6B,EAAA;AAC3D,IAAA,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC;AACrE;AAEA;;;;;AAKG;AACG,SAAU,oBAAoB,CAAC,SAA6B,EAAA;AAChE,IAAA,OAAO,SAAS,CAAC,QAAQ,EAAE;AAC7B;AAEA;;;;;AAKG;AACG,SAAU,mBAAmB,CACjC,SAAiB,EAAA;AAEjB,IAAA,IAAI;QACF,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3C;AAAE,IAAA,OAAA,EAAA,EAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;;AAMG;AACG,SAAU,oBAAoB,CAClC,SAA2C,EAAA;IAE3C,IAAI,CAAC,SAAS,EAAE;AACd,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,IAAI,SAAS,YAAY,IAAI,EAAE;AAC7B,QAAA,OAAO,eAAe,CAAC,SAAS,CAAC;IACnC;;AAGA,IAAA,IAAI;QACF,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3C;AAAE,IAAA,OAAA,EAAA,EAAM;;QAEN,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;AAClC,QAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAEnC,YAAA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AAChD,gBAAA,IAAI;AACF,oBAAA,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC7B,IAAI;wBACJ,KAAK;wBACL,GAAG;AACJ,qBAAA,CAAC;gBACJ;AAAE,gBAAA,OAAA,EAAA,EAAM;AACN,oBAAA,OAAO,IAAI;gBACb;YACF;QACF;AACA,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;;AAMG;AACG,SAAU,iBAAiB,CAC/B,KAAyB,EACzB,KAAyB,EAAA;IAEzB,OAAO,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;AACjD;AAEA;;;;;;;AAOG;SACa,aAAa,CAC3B,IAAwB,EACxB,OAAkC,EAClC,OAAkC,EAAA;IAElC,IAAI,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;AACnD,QAAA,OAAO,KAAK;IACd;IACA,IAAI,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;AACnD,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,IAAI;AACb;AAuQA;;;;;;;;;;"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Temporal API type declarations
|
|
9
|
+
* Using Temporal for modern date handling
|
|
10
|
+
*/
|
|
11
|
+
declare global {
|
|
12
|
+
namespace Temporal {
|
|
13
|
+
interface PlainDate {
|
|
14
|
+
readonly year: number;
|
|
15
|
+
readonly month: number;
|
|
16
|
+
readonly day: number;
|
|
17
|
+
readonly daysInMonth: number;
|
|
18
|
+
toString(): string;
|
|
19
|
+
with(dateLike: {
|
|
20
|
+
year?: number;
|
|
21
|
+
month?: number;
|
|
22
|
+
day?: number;
|
|
23
|
+
}): PlainDate;
|
|
24
|
+
add(duration: {
|
|
25
|
+
days?: number;
|
|
26
|
+
months?: number;
|
|
27
|
+
years?: number;
|
|
28
|
+
}): PlainDate;
|
|
29
|
+
until(other: PlainDate): {
|
|
30
|
+
days: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface PlainDateConstructor {
|
|
34
|
+
from(item: string | {
|
|
35
|
+
year: number;
|
|
36
|
+
month: number;
|
|
37
|
+
day: number;
|
|
38
|
+
}): PlainDate;
|
|
39
|
+
compare(one: PlainDate, two: PlainDate): number;
|
|
40
|
+
}
|
|
41
|
+
const PlainDate: PlainDateConstructor;
|
|
42
|
+
interface Now {
|
|
43
|
+
plainDateISO(): PlainDate;
|
|
44
|
+
}
|
|
45
|
+
const Now: Now;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Date picker modes
|
|
50
|
+
*/
|
|
51
|
+
export type DatePickerMode = 'simple' | 'single' | 'range';
|
|
52
|
+
/**
|
|
53
|
+
* Input type for range mode
|
|
54
|
+
*/
|
|
55
|
+
export type InputType = 'from' | 'to';
|
|
56
|
+
/**
|
|
57
|
+
* Date picker state machine context
|
|
58
|
+
* Contains all the state needed to manage the datepicker
|
|
59
|
+
* Uses Temporal.PlainDate for robust date handling
|
|
60
|
+
*/
|
|
61
|
+
export interface DatePickerContext {
|
|
62
|
+
/** The mode of the date picker */
|
|
63
|
+
mode: DatePickerMode;
|
|
64
|
+
/** The current value as ISO date string(s) */
|
|
65
|
+
value: string;
|
|
66
|
+
/** The selected start date (using Temporal API) */
|
|
67
|
+
startDate: Temporal.PlainDate | null;
|
|
68
|
+
/** The selected end date (range mode only, using Temporal API) */
|
|
69
|
+
endDate: Temporal.PlainDate | null;
|
|
70
|
+
/** Whether the calendar dropdown is open */
|
|
71
|
+
isOpen: boolean;
|
|
72
|
+
/** Whether an input has focus */
|
|
73
|
+
isFocused: boolean;
|
|
74
|
+
/** Whether the component is disabled */
|
|
75
|
+
isDisabled: boolean;
|
|
76
|
+
/** Whether the component is readonly */
|
|
77
|
+
isReadonly: boolean;
|
|
78
|
+
/** Whether the component is in an invalid state */
|
|
79
|
+
isInvalid: boolean;
|
|
80
|
+
/** The last focused input (for range mode) */
|
|
81
|
+
lastFocusedInput: InputType | null;
|
|
82
|
+
/** Minimum selectable date (using Temporal API) */
|
|
83
|
+
minDate: Temporal.PlainDate | null;
|
|
84
|
+
/** Maximum selectable date (using Temporal API) */
|
|
85
|
+
maxDate: Temporal.PlainDate | null;
|
|
86
|
+
/** Date format string */
|
|
87
|
+
dateFormat: string;
|
|
88
|
+
/** Whether to allow manual input */
|
|
89
|
+
allowInput: boolean;
|
|
90
|
+
/** Whether to close calendar on date selection */
|
|
91
|
+
closeOnSelect: boolean;
|
|
92
|
+
/** Error message if any */
|
|
93
|
+
errorMessage?: string;
|
|
94
|
+
/** The currently viewed month in the calendar (using Temporal API) */
|
|
95
|
+
viewDate: Temporal.PlainDate | null;
|
|
96
|
+
/** The date that currently has keyboard focus in the calendar */
|
|
97
|
+
focusedDate: Temporal.PlainDate | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Event payload types
|
|
101
|
+
*/
|
|
102
|
+
export interface DateSelectPayload {
|
|
103
|
+
date: Temporal.PlainDate;
|
|
104
|
+
inputType?: InputType;
|
|
105
|
+
}
|
|
106
|
+
export interface InputFocusPayload {
|
|
107
|
+
inputType: InputType;
|
|
108
|
+
}
|
|
109
|
+
export interface KeyboardPayload {
|
|
110
|
+
key: string;
|
|
111
|
+
shiftKey?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface ValueChangePayload {
|
|
114
|
+
value: string;
|
|
115
|
+
}
|
|
116
|
+
export interface ValidationErrorPayload {
|
|
117
|
+
message: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Date picker event
|
|
121
|
+
*/
|
|
122
|
+
export interface DatePickerEvent<T = any> {
|
|
123
|
+
type: string;
|
|
124
|
+
payload?: T;
|
|
125
|
+
timestamp: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* State transition information
|
|
129
|
+
*/
|
|
130
|
+
export interface StateTransition {
|
|
131
|
+
from: string;
|
|
132
|
+
to: string;
|
|
133
|
+
event: DatePickerEvent;
|
|
134
|
+
context: DatePickerContext;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Guard function type - determines if a transition is allowed
|
|
138
|
+
*/
|
|
139
|
+
export type StateGuard = (context: DatePickerContext, event: DatePickerEvent) => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Action function type - updates context during transition
|
|
142
|
+
*/
|
|
143
|
+
export type StateAction = (context: DatePickerContext, event: DatePickerEvent) => Partial<DatePickerContext>;
|
|
144
|
+
/**
|
|
145
|
+
* Side effect function type - performs side effects after transition
|
|
146
|
+
*/
|
|
147
|
+
export type SideEffect = (context: DatePickerContext, event: DatePickerEvent) => void;
|
|
148
|
+
/**
|
|
149
|
+
* Transition listener function type
|
|
150
|
+
*/
|
|
151
|
+
export type TransitionListener = (transition: StateTransition) => void;
|
|
152
|
+
/**
|
|
153
|
+
* State configuration
|
|
154
|
+
*/
|
|
155
|
+
export interface StateConfig {
|
|
156
|
+
guards?: Record<string, StateGuard>;
|
|
157
|
+
actions?: Record<string, StateAction>;
|
|
158
|
+
effects?: Record<string, SideEffect>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Transition map type
|
|
162
|
+
*/
|
|
163
|
+
export type TransitionMap = Record<string, Partial<Record<string, string>>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2019, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { LitElement } from 'lit';
|
|
8
|
+
import '@carbon/web-components/es/components/layer/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Storybook template layer component, strictly for presentation purposes
|
|
11
|
+
*
|
|
12
|
+
* @element sb-template-layers
|
|
13
|
+
* @slot The elements contained within the component.
|
|
14
|
+
*/
|
|
15
|
+
declare class CDSLayer extends LitElement {
|
|
16
|
+
content: any;
|
|
17
|
+
private _observer;
|
|
18
|
+
private _layer1;
|
|
19
|
+
private _layer2;
|
|
20
|
+
private _handleSlotChange;
|
|
21
|
+
updated(): void;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
24
|
+
static styles: any;
|
|
25
|
+
}
|
|
26
|
+
export default CDSLayer;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2019, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export declare type Constructor<T> = {
|
|
8
|
+
new (...args: any[]): T;
|
|
9
|
+
};
|
|
10
|
+
type Finisher = (<T>(clazz: Constructor<T>) => Constructor<T>) | (<T>(clazz: Constructor<T>) => void);
|
|
11
|
+
export interface ClassDescriptor {
|
|
12
|
+
kind: 'class';
|
|
13
|
+
elements: ClassElement[];
|
|
14
|
+
finisher?: Finisher;
|
|
15
|
+
}
|
|
16
|
+
export interface ClassElement {
|
|
17
|
+
kind: 'field' | 'method';
|
|
18
|
+
key: PropertyKey;
|
|
19
|
+
placement: 'static' | 'prototype' | 'own';
|
|
20
|
+
initializer?: () => unknown;
|
|
21
|
+
extras?: ClassElement[];
|
|
22
|
+
finisher?: Finisher;
|
|
23
|
+
descriptor?: PropertyDescriptor;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Allow for custom element classes with private constructors
|
|
27
|
+
*/
|
|
28
|
+
type CustomElementClass = Omit<typeof HTMLElement, 'new'>;
|
|
29
|
+
/**
|
|
30
|
+
* Class decorator factory that defines the decorated class as a custom element.
|
|
31
|
+
*
|
|
32
|
+
* ```js
|
|
33
|
+
* @customElement('my-element')
|
|
34
|
+
* class MyElement extends LitElement {
|
|
35
|
+
* render() {
|
|
36
|
+
* return html``;
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category Decorator
|
|
42
|
+
* @param tagName The tag name of the custom element to define.
|
|
43
|
+
*/
|
|
44
|
+
export declare const carbonElement: (tagName: string) => (classOrDescriptor: CustomElementClass | ClassDescriptor) => any;
|
|
45
|
+
export {};
|