@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,147 @@
|
|
|
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
|
+
import { LitElement } from 'lit';
|
|
8
|
+
/**
|
|
9
|
+
* Calendar renderer for date picker.
|
|
10
|
+
* Replaces Flatpickr's calendar UI with a lightweight, framework-agnostic implementation.
|
|
11
|
+
*
|
|
12
|
+
* @element cds-date-picker-calendar
|
|
13
|
+
* @fires cds-date-picker-calendar-date-select - Fired when a date is selected
|
|
14
|
+
* @fires cds-date-picker-calendar-month-change - Fired when the month changes
|
|
15
|
+
*/
|
|
16
|
+
declare class CDSDatePickerCalendar extends LitElement {
|
|
17
|
+
/**
|
|
18
|
+
* The currently displayed month (Temporal.PlainYearMonth)
|
|
19
|
+
*/
|
|
20
|
+
private _currentMonth;
|
|
21
|
+
/**
|
|
22
|
+
* The selected date(s)
|
|
23
|
+
*/
|
|
24
|
+
selectedDates: Temporal.PlainDate[];
|
|
25
|
+
/**
|
|
26
|
+
* The view date from the state machine (used to sync calendar month)
|
|
27
|
+
*/
|
|
28
|
+
viewDate?: Temporal.PlainDate;
|
|
29
|
+
/**
|
|
30
|
+
* The focused date for keyboard navigation
|
|
31
|
+
*/
|
|
32
|
+
focusedDate?: Temporal.PlainDate | null;
|
|
33
|
+
/**
|
|
34
|
+
* The currently hovered date (for range preview)
|
|
35
|
+
*/
|
|
36
|
+
private _hoveredDate?;
|
|
37
|
+
/**
|
|
38
|
+
* The minimum selectable date
|
|
39
|
+
*/
|
|
40
|
+
minDate?: Temporal.PlainDate;
|
|
41
|
+
/**
|
|
42
|
+
* The maximum selectable date
|
|
43
|
+
*/
|
|
44
|
+
maxDate?: Temporal.PlainDate;
|
|
45
|
+
/**
|
|
46
|
+
* Whether range selection is enabled
|
|
47
|
+
*/
|
|
48
|
+
rangeMode: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The date format for display
|
|
51
|
+
*/
|
|
52
|
+
dateFormat: string;
|
|
53
|
+
/**
|
|
54
|
+
* Locale for date formatting
|
|
55
|
+
*/
|
|
56
|
+
locale: string;
|
|
57
|
+
/**
|
|
58
|
+
* Navigate to previous month
|
|
59
|
+
*/
|
|
60
|
+
private _handlePrevMonth;
|
|
61
|
+
/**
|
|
62
|
+
* Navigate to next month
|
|
63
|
+
*/
|
|
64
|
+
private _handleNextMonth;
|
|
65
|
+
/**
|
|
66
|
+
* Handle date selection
|
|
67
|
+
* @param {Temporal.PlainDate} date - The date to select
|
|
68
|
+
*/
|
|
69
|
+
private _handleDateSelect;
|
|
70
|
+
/**
|
|
71
|
+
* Dispatch month change event
|
|
72
|
+
*/
|
|
73
|
+
private _dispatchMonthChange;
|
|
74
|
+
/**
|
|
75
|
+
* Check if a date is disabled
|
|
76
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
77
|
+
*/
|
|
78
|
+
private _isDateDisabled;
|
|
79
|
+
/**
|
|
80
|
+
* Check if previous month navigation should be disabled
|
|
81
|
+
*/
|
|
82
|
+
private _isPrevMonthDisabled;
|
|
83
|
+
/**
|
|
84
|
+
* Check if next month navigation should be disabled
|
|
85
|
+
*/
|
|
86
|
+
private _isNextMonthDisabled;
|
|
87
|
+
/**
|
|
88
|
+
* Check if a date is selected
|
|
89
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
90
|
+
*/
|
|
91
|
+
private _isDateSelected;
|
|
92
|
+
/**
|
|
93
|
+
* Check if a date is in range (for range mode)
|
|
94
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
95
|
+
*/
|
|
96
|
+
private _isDateInRange;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a date is today
|
|
99
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
100
|
+
*/
|
|
101
|
+
private _isToday;
|
|
102
|
+
/**
|
|
103
|
+
* Check if a date is focused (for keyboard navigation)
|
|
104
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
105
|
+
*/
|
|
106
|
+
private _isDateFocused;
|
|
107
|
+
/**
|
|
108
|
+
* Handle mouse enter on a date
|
|
109
|
+
* @param {Temporal.PlainDate} date - The date being hovered
|
|
110
|
+
*/
|
|
111
|
+
private _handleDateMouseEnter;
|
|
112
|
+
/**
|
|
113
|
+
* Handle mouse leave on a date
|
|
114
|
+
*/
|
|
115
|
+
private _handleDateMouseLeave;
|
|
116
|
+
/**
|
|
117
|
+
* Get the days to display in the calendar grid
|
|
118
|
+
*/
|
|
119
|
+
private _getCalendarDays;
|
|
120
|
+
/**
|
|
121
|
+
* Get weekday names
|
|
122
|
+
*/
|
|
123
|
+
private _getWeekdayNames;
|
|
124
|
+
/**
|
|
125
|
+
* Render the calendar header with month/year and navigation
|
|
126
|
+
*/
|
|
127
|
+
private _renderHeader;
|
|
128
|
+
/**
|
|
129
|
+
* Render the weekday headers
|
|
130
|
+
*/
|
|
131
|
+
private _renderWeekdays;
|
|
132
|
+
/**
|
|
133
|
+
* Render the calendar days grid
|
|
134
|
+
*/
|
|
135
|
+
private _renderDays;
|
|
136
|
+
/**
|
|
137
|
+
* Lifecycle method called when properties change
|
|
138
|
+
* @param {Map<string, any>} changedProperties - Changed properties
|
|
139
|
+
*/
|
|
140
|
+
updated(changedProperties: Map<string, any>): void;
|
|
141
|
+
/**
|
|
142
|
+
* Renders the calendar component
|
|
143
|
+
*/
|
|
144
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
145
|
+
static styles: any;
|
|
146
|
+
}
|
|
147
|
+
export default CDSDatePickerCalendar;
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var lit = require('lit');
|
|
5
|
+
var decorators_js = require('lit/decorators.js');
|
|
6
|
+
var classMap_js = require('lit/directives/class-map.js');
|
|
7
|
+
var settings = require('../../temp-imports/globals/settings.js');
|
|
8
|
+
var carbonElement = require('../../temp-imports/globals/decorators/carbon-element.js');
|
|
9
|
+
var ChevronLeft16 = require('@carbon/icons/es/chevron--left/16.js');
|
|
10
|
+
var ChevronRight16 = require('@carbon/icons/es/chevron--right/16.js');
|
|
11
|
+
var iconLoader = require('../../temp-imports/globals/internal/icon-loader.js');
|
|
12
|
+
var temporalUtils = require('../../state-machine/temporal-utils.js');
|
|
13
|
+
var datePicker = require('./date-picker.scss.js');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Copyright IBM Corp. 2026
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Calendar renderer for date picker.
|
|
23
|
+
* Replaces Flatpickr's calendar UI with a lightweight, framework-agnostic implementation.
|
|
24
|
+
*
|
|
25
|
+
* @element cds-date-picker-calendar
|
|
26
|
+
* @fires cds-date-picker-calendar-date-select - Fired when a date is selected
|
|
27
|
+
* @fires cds-date-picker-calendar-month-change - Fired when the month changes
|
|
28
|
+
*/
|
|
29
|
+
let CDSDatePickerCalendar = class CDSDatePickerCalendar extends lit.LitElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
/**
|
|
33
|
+
* The currently displayed month (Temporal.PlainYearMonth)
|
|
34
|
+
*/
|
|
35
|
+
this._currentMonth = Temporal.Now.plainDateISO().toPlainYearMonth();
|
|
36
|
+
/**
|
|
37
|
+
* The selected date(s)
|
|
38
|
+
*/
|
|
39
|
+
this.selectedDates = [];
|
|
40
|
+
/**
|
|
41
|
+
* Whether range selection is enabled
|
|
42
|
+
*/
|
|
43
|
+
this.rangeMode = false;
|
|
44
|
+
/**
|
|
45
|
+
* The date format for display
|
|
46
|
+
*/
|
|
47
|
+
this.dateFormat = 'm/d/Y';
|
|
48
|
+
/**
|
|
49
|
+
* Locale for date formatting
|
|
50
|
+
*/
|
|
51
|
+
this.locale = 'en-US';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Navigate to previous month
|
|
55
|
+
*/
|
|
56
|
+
_handlePrevMonth() {
|
|
57
|
+
this._currentMonth = this._currentMonth.subtract({ months: 1 });
|
|
58
|
+
this._dispatchMonthChange();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Navigate to next month
|
|
62
|
+
*/
|
|
63
|
+
_handleNextMonth() {
|
|
64
|
+
this._currentMonth = this._currentMonth.add({ months: 1 });
|
|
65
|
+
this._dispatchMonthChange();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handle date selection
|
|
69
|
+
* @param {Temporal.PlainDate} date - The date to select
|
|
70
|
+
*/
|
|
71
|
+
_handleDateSelect(date) {
|
|
72
|
+
if (this._isDateDisabled(date)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.dispatchEvent(new CustomEvent(`${settings.prefix}-date-picker-calendar-date-select`, {
|
|
76
|
+
bubbles: true,
|
|
77
|
+
composed: true,
|
|
78
|
+
detail: { date },
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Dispatch month change event
|
|
83
|
+
*/
|
|
84
|
+
_dispatchMonthChange() {
|
|
85
|
+
this.dispatchEvent(new CustomEvent(`${settings.prefix}-date-picker-calendar-month-change`, {
|
|
86
|
+
bubbles: true,
|
|
87
|
+
composed: true,
|
|
88
|
+
detail: { month: this._currentMonth },
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if a date is disabled
|
|
93
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
94
|
+
*/
|
|
95
|
+
_isDateDisabled(date) {
|
|
96
|
+
if (this.minDate && Temporal.PlainDate.compare(date, this.minDate) < 0) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (this.maxDate && Temporal.PlainDate.compare(date, this.maxDate) > 0) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if previous month navigation should be disabled
|
|
106
|
+
*/
|
|
107
|
+
_isPrevMonthDisabled() {
|
|
108
|
+
if (!this.minDate) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
// Disable if going to previous month would be before minDate's month
|
|
112
|
+
const prevMonth = this._currentMonth.subtract({ months: 1 });
|
|
113
|
+
const prevMonthLastDay = prevMonth.toPlainDate({
|
|
114
|
+
day: prevMonth.daysInMonth,
|
|
115
|
+
});
|
|
116
|
+
return Temporal.PlainDate.compare(prevMonthLastDay, this.minDate) < 0;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if next month navigation should be disabled
|
|
120
|
+
*/
|
|
121
|
+
_isNextMonthDisabled() {
|
|
122
|
+
if (!this.maxDate) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
// Disable if going to next month would be after maxDate's month
|
|
126
|
+
const nextMonth = this._currentMonth.add({ months: 1 });
|
|
127
|
+
const nextMonthFirstDay = nextMonth.toPlainDate({ day: 1 });
|
|
128
|
+
return Temporal.PlainDate.compare(nextMonthFirstDay, this.maxDate) > 0;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if a date is selected
|
|
132
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
133
|
+
*/
|
|
134
|
+
_isDateSelected(date) {
|
|
135
|
+
return this.selectedDates.some((selected) => {
|
|
136
|
+
if (!selected || typeof selected !== 'object' || !('year' in selected)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return Temporal.PlainDate.compare(selected, date) === 0;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Check if a date is in range (for range mode)
|
|
144
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
145
|
+
*/
|
|
146
|
+
_isDateInRange(date) {
|
|
147
|
+
if (!this.rangeMode) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
// Case 1: Both dates are selected (final range)
|
|
151
|
+
if (this.selectedDates.length === 2) {
|
|
152
|
+
const [start, end] = this.selectedDates.sort((a, b) => Temporal.PlainDate.compare(a, b));
|
|
153
|
+
return (Temporal.PlainDate.compare(date, start) >= 0 &&
|
|
154
|
+
Temporal.PlainDate.compare(date, end) <= 0);
|
|
155
|
+
}
|
|
156
|
+
// Case 2: One date selected, show preview range with hovered or focused date
|
|
157
|
+
const previewDate = this._hoveredDate || this.focusedDate;
|
|
158
|
+
if (this.selectedDates.length === 1 && previewDate) {
|
|
159
|
+
const start = this.selectedDates[0];
|
|
160
|
+
const end = previewDate;
|
|
161
|
+
// Sort to handle both forward and backward selection
|
|
162
|
+
const [rangeStart, rangeEnd] = [start, end].sort((a, b) => Temporal.PlainDate.compare(a, b));
|
|
163
|
+
return (Temporal.PlainDate.compare(date, rangeStart) >= 0 &&
|
|
164
|
+
Temporal.PlainDate.compare(date, rangeEnd) <= 0);
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Check if a date is today
|
|
170
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
171
|
+
*/
|
|
172
|
+
_isToday(date) {
|
|
173
|
+
const today = Temporal.Now.plainDateISO();
|
|
174
|
+
return Temporal.PlainDate.compare(date, today) === 0;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Check if a date is focused (for keyboard navigation)
|
|
178
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
179
|
+
*/
|
|
180
|
+
_isDateFocused(date) {
|
|
181
|
+
if (!this.focusedDate) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return Temporal.PlainDate.compare(date, this.focusedDate) === 0;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Handle mouse enter on a date
|
|
188
|
+
* @param {Temporal.PlainDate} date - The date being hovered
|
|
189
|
+
*/
|
|
190
|
+
_handleDateMouseEnter(date) {
|
|
191
|
+
// Only track hover in range mode when selecting end date
|
|
192
|
+
if (this.rangeMode && this.selectedDates.length === 1) {
|
|
193
|
+
this._hoveredDate = date;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Handle mouse leave on a date
|
|
198
|
+
*/
|
|
199
|
+
_handleDateMouseLeave() {
|
|
200
|
+
// Clear hovered date
|
|
201
|
+
this._hoveredDate = undefined;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get the days to display in the calendar grid
|
|
205
|
+
*/
|
|
206
|
+
_getCalendarDays() {
|
|
207
|
+
const firstDayOfMonth = this._currentMonth.toPlainDate({ day: 1 });
|
|
208
|
+
// Get the day of week for the first day (0 = Sunday, 6 = Saturday)
|
|
209
|
+
const firstDayOfWeek = firstDayOfMonth.dayOfWeek % 7;
|
|
210
|
+
// Calculate the start date (may be in previous month)
|
|
211
|
+
const startDate = firstDayOfMonth.subtract({ days: firstDayOfWeek });
|
|
212
|
+
// Generate 42 days (6 weeks) for consistent grid
|
|
213
|
+
const days = [];
|
|
214
|
+
for (let i = 0; i < 42; i++) {
|
|
215
|
+
days.push(startDate.add({ days: i }));
|
|
216
|
+
}
|
|
217
|
+
return days;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get weekday names
|
|
221
|
+
*/
|
|
222
|
+
_getWeekdayNames() {
|
|
223
|
+
// Start from Sunday
|
|
224
|
+
const baseDate = Temporal.PlainDate.from('2024-01-07'); // A Sunday
|
|
225
|
+
const weekdays = [];
|
|
226
|
+
for (let i = 0; i < 7; i++) {
|
|
227
|
+
const date = baseDate.add({ days: i });
|
|
228
|
+
const formatter = new Intl.DateTimeFormat(this.locale, {
|
|
229
|
+
weekday: 'short',
|
|
230
|
+
});
|
|
231
|
+
// Use plainDateToDate to properly convert Temporal.PlainDate to Date
|
|
232
|
+
let name = formatter.format(temporalUtils.plainDateToDate(date));
|
|
233
|
+
// Special handling for Thursday to match Carbon's "Th" format
|
|
234
|
+
if (name === 'Thu') {
|
|
235
|
+
name = 'Th';
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
name = name.charAt(0);
|
|
239
|
+
}
|
|
240
|
+
weekdays.push(name);
|
|
241
|
+
}
|
|
242
|
+
return weekdays;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Render the calendar header with month/year and navigation
|
|
246
|
+
*/
|
|
247
|
+
_renderHeader() {
|
|
248
|
+
// Convert Temporal.PlainYearMonth to Date properly to avoid month offset issues
|
|
249
|
+
const firstDayOfMonth = this._currentMonth.toPlainDate({ day: 1 });
|
|
250
|
+
const monthName = new Intl.DateTimeFormat(this.locale, {
|
|
251
|
+
month: 'long',
|
|
252
|
+
year: 'numeric',
|
|
253
|
+
}).format(temporalUtils.plainDateToDate(firstDayOfMonth));
|
|
254
|
+
const isPrevDisabled = this._isPrevMonthDisabled();
|
|
255
|
+
const isNextDisabled = this._isNextMonthDisabled();
|
|
256
|
+
return lit.html `
|
|
257
|
+
<div class="${settings.prefix}--date-picker__month">
|
|
258
|
+
<button
|
|
259
|
+
type="button"
|
|
260
|
+
class="${settings.prefix}--date-picker__month-nav ${settings.prefix}--date-picker__month-nav--prev"
|
|
261
|
+
tabindex="-1"
|
|
262
|
+
?disabled="${isPrevDisabled}"
|
|
263
|
+
@click="${this._handlePrevMonth}"
|
|
264
|
+
aria-label="Previous month">
|
|
265
|
+
${iconLoader.iconLoader(ChevronLeft16)}
|
|
266
|
+
</button>
|
|
267
|
+
<div class="${settings.prefix}--date-picker__current-month">
|
|
268
|
+
<span class="cur-month">${monthName}</span>
|
|
269
|
+
</div>
|
|
270
|
+
<button
|
|
271
|
+
type="button"
|
|
272
|
+
class="${settings.prefix}--date-picker__month-nav ${settings.prefix}--date-picker__month-nav--next"
|
|
273
|
+
tabindex="-1"
|
|
274
|
+
?disabled="${isNextDisabled}"
|
|
275
|
+
@click="${this._handleNextMonth}"
|
|
276
|
+
aria-label="Next month">
|
|
277
|
+
${iconLoader.iconLoader(ChevronRight16)}
|
|
278
|
+
</button>
|
|
279
|
+
</div>
|
|
280
|
+
`;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Render the weekday headers
|
|
284
|
+
*/
|
|
285
|
+
_renderWeekdays() {
|
|
286
|
+
const weekdays = this._getWeekdayNames();
|
|
287
|
+
return lit.html `
|
|
288
|
+
<div class="${settings.prefix}--date-picker__weekdays">
|
|
289
|
+
${weekdays.map((day) => lit.html `
|
|
290
|
+
<span class="${settings.prefix}--date-picker__weekday">${day}</span>
|
|
291
|
+
`)}
|
|
292
|
+
</div>
|
|
293
|
+
`;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Render the calendar days grid
|
|
297
|
+
*/
|
|
298
|
+
_renderDays() {
|
|
299
|
+
const days = this._getCalendarDays();
|
|
300
|
+
const currentMonthValue = this._currentMonth.month;
|
|
301
|
+
return lit.html `
|
|
302
|
+
<div class="${settings.prefix}--date-picker__days" role="grid">
|
|
303
|
+
${days.map((date) => {
|
|
304
|
+
const isCurrentMonth = date.month === currentMonthValue;
|
|
305
|
+
const isDisabled = this._isDateDisabled(date);
|
|
306
|
+
const isSelected = this._isDateSelected(date);
|
|
307
|
+
const isInRange = this._isDateInRange(date);
|
|
308
|
+
const isToday = this._isToday(date);
|
|
309
|
+
const isFocused = this._isDateFocused(date);
|
|
310
|
+
const dayClasses = classMap_js.classMap({
|
|
311
|
+
[`${settings.prefix}--date-picker__day`]: true,
|
|
312
|
+
prevMonthDay: !isCurrentMonth && date.month < currentMonthValue,
|
|
313
|
+
nextMonthDay: !isCurrentMonth && date.month > currentMonthValue,
|
|
314
|
+
disabled: isDisabled,
|
|
315
|
+
selected: isSelected,
|
|
316
|
+
inRange: isInRange,
|
|
317
|
+
today: isToday && !isSelected,
|
|
318
|
+
'no-border': isToday && isSelected,
|
|
319
|
+
focused: isFocused,
|
|
320
|
+
});
|
|
321
|
+
return lit.html `
|
|
322
|
+
<button
|
|
323
|
+
type="button"
|
|
324
|
+
class="${dayClasses}"
|
|
325
|
+
tabindex="-1"
|
|
326
|
+
?disabled="${isDisabled}"
|
|
327
|
+
@click="${() => this._handleDateSelect(date)}"
|
|
328
|
+
@mouseenter="${() => this._handleDateMouseEnter(date)}"
|
|
329
|
+
@mouseleave="${() => this._handleDateMouseLeave()}"
|
|
330
|
+
aria-label="${date.toString()}">
|
|
331
|
+
${date.day}
|
|
332
|
+
</button>
|
|
333
|
+
`;
|
|
334
|
+
})}
|
|
335
|
+
</div>
|
|
336
|
+
`;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Lifecycle method called when properties change
|
|
340
|
+
* @param {Map<string, any>} changedProperties - Changed properties
|
|
341
|
+
*/
|
|
342
|
+
updated(changedProperties) {
|
|
343
|
+
// Sync calendar month with viewDate from state machine
|
|
344
|
+
if (changedProperties.has('viewDate') && this.viewDate) {
|
|
345
|
+
// Create PlainYearMonth from PlainDate
|
|
346
|
+
this._currentMonth = Temporal.PlainYearMonth.from({
|
|
347
|
+
year: this.viewDate.year,
|
|
348
|
+
month: this.viewDate.month,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Renders the calendar component
|
|
354
|
+
*/
|
|
355
|
+
render() {
|
|
356
|
+
return lit.html `
|
|
357
|
+
<div class="${settings.prefix}--date-picker__calendar" tabindex="0">
|
|
358
|
+
${this._renderHeader()} ${this._renderWeekdays()} ${this._renderDays()}
|
|
359
|
+
</div>
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
CDSDatePickerCalendar.styles = datePicker.default;
|
|
364
|
+
tslib.__decorate([
|
|
365
|
+
decorators_js.state(),
|
|
366
|
+
tslib.__metadata("design:type", Object)
|
|
367
|
+
], CDSDatePickerCalendar.prototype, "_currentMonth", void 0);
|
|
368
|
+
tslib.__decorate([
|
|
369
|
+
decorators_js.property({ type: Array }),
|
|
370
|
+
tslib.__metadata("design:type", Array)
|
|
371
|
+
], CDSDatePickerCalendar.prototype, "selectedDates", void 0);
|
|
372
|
+
tslib.__decorate([
|
|
373
|
+
decorators_js.property({ type: Object }),
|
|
374
|
+
tslib.__metadata("design:type", Object)
|
|
375
|
+
], CDSDatePickerCalendar.prototype, "viewDate", void 0);
|
|
376
|
+
tslib.__decorate([
|
|
377
|
+
decorators_js.property({ type: Object }),
|
|
378
|
+
tslib.__metadata("design:type", Object)
|
|
379
|
+
], CDSDatePickerCalendar.prototype, "focusedDate", void 0);
|
|
380
|
+
tslib.__decorate([
|
|
381
|
+
decorators_js.state(),
|
|
382
|
+
tslib.__metadata("design:type", Object)
|
|
383
|
+
], CDSDatePickerCalendar.prototype, "_hoveredDate", void 0);
|
|
384
|
+
tslib.__decorate([
|
|
385
|
+
decorators_js.property({ type: Object }),
|
|
386
|
+
tslib.__metadata("design:type", Object)
|
|
387
|
+
], CDSDatePickerCalendar.prototype, "minDate", void 0);
|
|
388
|
+
tslib.__decorate([
|
|
389
|
+
decorators_js.property({ type: Object }),
|
|
390
|
+
tslib.__metadata("design:type", Object)
|
|
391
|
+
], CDSDatePickerCalendar.prototype, "maxDate", void 0);
|
|
392
|
+
tslib.__decorate([
|
|
393
|
+
decorators_js.property({ type: Boolean }),
|
|
394
|
+
tslib.__metadata("design:type", Object)
|
|
395
|
+
], CDSDatePickerCalendar.prototype, "rangeMode", void 0);
|
|
396
|
+
tslib.__decorate([
|
|
397
|
+
decorators_js.property({ type: String }),
|
|
398
|
+
tslib.__metadata("design:type", Object)
|
|
399
|
+
], CDSDatePickerCalendar.prototype, "dateFormat", void 0);
|
|
400
|
+
tslib.__decorate([
|
|
401
|
+
decorators_js.property({ type: String }),
|
|
402
|
+
tslib.__metadata("design:type", Object)
|
|
403
|
+
], CDSDatePickerCalendar.prototype, "locale", void 0);
|
|
404
|
+
CDSDatePickerCalendar = tslib.__decorate([
|
|
405
|
+
carbonElement.carbonElement(`${settings.prefix}-date-picker-calendar`)
|
|
406
|
+
], CDSDatePickerCalendar);
|
|
407
|
+
// Made with Bob
|
|
408
|
+
//# sourceMappingURL=calendar-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-renderer.js","sources":["../../../../components/date-picker/calendar-renderer.ts"],"sourcesContent":[null],"names":["LitElement","prefix","plainDateToDate","html","iconLoader","classMap","styles","__decorate","state","property","customElement"],"mappings":";;;;;;;;;;;;;;AAAA;;;;;AAKG;AAiBH;;;;;;;AAOG;AAEH,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQA,cAAU,CAAA;AAA9C,IAAA,WAAA,GAAA;;AACE;;AAEG;QAEK,IAAA,CAAA,aAAa,GAAQ,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,gBAAgB,EAAE;AAE3E;;AAEG;QAEH,IAAA,CAAA,aAAa,GAAyB,EAAE;AAgCxC;;AAEG;QAEH,IAAA,CAAA,SAAS,GAAG,KAAK;AAEjB;;AAEG;QAEH,IAAA,CAAA,UAAU,GAAG,OAAO;AAEpB;;AAEG;QAEH,IAAA,CAAA,MAAM,GAAG,OAAO;IA6WlB;AA3WE;;AAEG;IACK,gBAAgB,GAAA;AACtB,QAAA,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;Q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AAA,CAAA;AADC,IAAAE,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACE,CAAA,EAAA,qBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAM7BF,gBAAA,CAAA;AADC,IAAAE,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;AACV,CAAA,EAAA,qBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAMlBF,gBAAA,CAAA;AADC,IAAAE,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACN,CAAA,EAAA,qBAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAMrBF,gBAAA,CAAA;AADC,IAAAE,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;AACV,CAAA,EAAA,qBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AA3Db,qBAAqB,GAAAF,gBAAA,CAAA;AAD1B,IAAAG,2BAAa,CAAC,CAAA,EAAGT,eAAM,CAAA,qBAAA,CAAuB;AACzC,CAAA,EAAA,qBAAqB,CAwa1B;AAID;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { DATE_PICKER_INPUT_KIND } from './defs';
|
|
9
|
+
/**
|
|
10
|
+
* Skeleton version of the input box for date picker.
|
|
11
|
+
*/
|
|
12
|
+
declare class CDSDatePickerInputSkeleton extends LitElement {
|
|
13
|
+
/**
|
|
14
|
+
* Specify whether the label should be hidden, or not
|
|
15
|
+
*/
|
|
16
|
+
hideLabel: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* * @deprecated use `range` instead
|
|
19
|
+
* Date picker input kind. Corresponds to the attribute with the same name.
|
|
20
|
+
*/
|
|
21
|
+
kind: DATE_PICKER_INPUT_KIND;
|
|
22
|
+
/**
|
|
23
|
+
* Specify whether the skeleton should be of range date picker.
|
|
24
|
+
*/
|
|
25
|
+
range: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Renders the component template.
|
|
28
|
+
*
|
|
29
|
+
* @returns {TemplateResult} The template result
|
|
30
|
+
*/
|
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
static styles: any;
|
|
33
|
+
}
|
|
34
|
+
export default CDSDatePickerInputSkeleton;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var lit = require('lit');
|
|
5
|
+
var decorators_js = require('lit/decorators.js');
|
|
6
|
+
var settings = require('../../temp-imports/globals/settings.js');
|
|
7
|
+
var defs = require('./defs.js');
|
|
8
|
+
var datePicker = require('./date-picker.scss.js');
|
|
9
|
+
var carbonElement = require('../../temp-imports/globals/decorators/carbon-element.js');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copyright IBM Corp. 2019, 2025
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Skeleton version of the input box for date picker.
|
|
19
|
+
*/
|
|
20
|
+
let CDSDatePickerInputSkeleton = class CDSDatePickerInputSkeleton extends lit.LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
/**
|
|
24
|
+
* Specify whether the label should be hidden, or not
|
|
25
|
+
*/
|
|
26
|
+
this.hideLabel = false;
|
|
27
|
+
/**
|
|
28
|
+
* * @deprecated use `range` instead
|
|
29
|
+
* Date picker input kind. Corresponds to the attribute with the same name.
|
|
30
|
+
*/
|
|
31
|
+
this.kind = defs.DATE_PICKER_INPUT_KIND.SIMPLE;
|
|
32
|
+
/**
|
|
33
|
+
* Specify whether the skeleton should be of range date picker.
|
|
34
|
+
*/
|
|
35
|
+
this.range = false;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Renders the component template.
|
|
39
|
+
*
|
|
40
|
+
* @returns {TemplateResult} The template result
|
|
41
|
+
*/
|
|
42
|
+
render() {
|
|
43
|
+
const { hideLabel, range } = this;
|
|
44
|
+
return lit.html `
|
|
45
|
+
<div class="${settings.prefix}--date-picker-input-skeleton-container">
|
|
46
|
+
${!hideLabel ? lit.html `<span class="${settings.prefix}--label"></span>` : null}
|
|
47
|
+
<div class="${settings.prefix}--date-picker__input ${settings.prefix}--skeleton"></div>
|
|
48
|
+
</div>
|
|
49
|
+
${range
|
|
50
|
+
? lit.html `
|
|
51
|
+
<div class="${settings.prefix}--date-picker-input-skeleton-container">
|
|
52
|
+
${!hideLabel
|
|
53
|
+
? lit.html `<span class="${settings.prefix}--label"></span>`
|
|
54
|
+
: null}
|
|
55
|
+
<div
|
|
56
|
+
class="${settings.prefix}--date-picker__input ${settings.prefix}--skeleton"></div>
|
|
57
|
+
</div>
|
|
58
|
+
`
|
|
59
|
+
: null}
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
CDSDatePickerInputSkeleton.styles = datePicker.default;
|
|
64
|
+
tslib.__decorate([
|
|
65
|
+
decorators_js.property({ type: Boolean, reflect: true, attribute: 'hide-label' }),
|
|
66
|
+
tslib.__metadata("design:type", Object)
|
|
67
|
+
], CDSDatePickerInputSkeleton.prototype, "hideLabel", void 0);
|
|
68
|
+
tslib.__decorate([
|
|
69
|
+
decorators_js.property({ reflect: true }),
|
|
70
|
+
tslib.__metadata("design:type", Object)
|
|
71
|
+
], CDSDatePickerInputSkeleton.prototype, "kind", void 0);
|
|
72
|
+
tslib.__decorate([
|
|
73
|
+
decorators_js.property({ type: Boolean, reflect: true, attribute: 'range' }),
|
|
74
|
+
tslib.__metadata("design:type", Object)
|
|
75
|
+
], CDSDatePickerInputSkeleton.prototype, "range", void 0);
|
|
76
|
+
CDSDatePickerInputSkeleton = tslib.__decorate([
|
|
77
|
+
carbonElement.carbonElement(`${settings.prefix}-date-picker-input-skeleton`)
|
|
78
|
+
], CDSDatePickerInputSkeleton);
|
|
79
|
+
//# sourceMappingURL=date-picker-input-skeleton.js.map
|