@nysds/nys-datepicker 1.19.4 → 1.20.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/dist/index.d.ts +1 -0
- package/dist/nys-datepicker.d.ts +259 -0
- package/dist/nys-datepicker.figma.d.ts +1 -0
- package/dist/nys-datepicker.js +378 -247
- package/dist/nys-datepicker.js.map +1 -1
- package/package.json +6 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./nys-datepicker";
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { NysFormControlElement } from "@nysds/internals";
|
|
2
|
+
import "@nysds/nys-label";
|
|
3
|
+
import "@nysds/nys-errormessage";
|
|
4
|
+
import "@nysds/nys-icon";
|
|
5
|
+
import "@nysds/nys-button";
|
|
6
|
+
/**
|
|
7
|
+
* Date picker with calendar popup and form validation. Falls back to native date input
|
|
8
|
+
* on Safari and mobile.
|
|
9
|
+
*
|
|
10
|
+
* @summary Date picker with calendar popup and native fallback.
|
|
11
|
+
* @element nys-datepicker
|
|
12
|
+
*
|
|
13
|
+
* @fires nys-blur - Fired when input or calendar loses focus. Triggers validation.
|
|
14
|
+
* @fires nys-input - Fired on date selection. Detail: `{id, value}`.
|
|
15
|
+
*
|
|
16
|
+
* @example Basic
|
|
17
|
+
* ```html
|
|
18
|
+
* <nys-datepicker
|
|
19
|
+
* id="my-datepicker"
|
|
20
|
+
* name="my-datepicker"
|
|
21
|
+
* label="Schedule an appointment"
|
|
22
|
+
* description="Enter in MM/DD/YYYY format"
|
|
23
|
+
* ></nys-datepicker>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Width Large
|
|
27
|
+
* ```html
|
|
28
|
+
* <nys-datepicker
|
|
29
|
+
* label="Event Date"
|
|
30
|
+
* description="Select the date of your event"
|
|
31
|
+
* width="lg">
|
|
32
|
+
* </nys-datepicker>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Width Full
|
|
36
|
+
* ```html
|
|
37
|
+
* <nys-datepicker
|
|
38
|
+
* label="Event Date"
|
|
39
|
+
* description="Select the date of your event"
|
|
40
|
+
* width="full">
|
|
41
|
+
* </nys-datepicker>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Custom Start Date
|
|
45
|
+
* ```html
|
|
46
|
+
* <nys-datepicker
|
|
47
|
+
* label="Appointment"
|
|
48
|
+
* startDate="2024-01-01">
|
|
49
|
+
* </nys-datepicker>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Without Buttons
|
|
53
|
+
* ```html
|
|
54
|
+
* <nys-datepicker
|
|
55
|
+
* label="Appointment"
|
|
56
|
+
* hideTodayButton
|
|
57
|
+
* hideClearButton>
|
|
58
|
+
* </nys-datepicker>
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example Error Message
|
|
62
|
+
* ```html
|
|
63
|
+
* <nys-datepicker
|
|
64
|
+
* label="Start Date"
|
|
65
|
+
* showError
|
|
66
|
+
* errorMessage="Please select a valid start date">
|
|
67
|
+
* </nys-datepicker>
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Date Range
|
|
71
|
+
* ```html
|
|
72
|
+
* <nys-datepicker
|
|
73
|
+
* label="Select a date"
|
|
74
|
+
* description="Only dates within April 4/5/2026 - 7/15/2026 are selectable"
|
|
75
|
+
* minDate="2026-04-05"
|
|
76
|
+
* maxDate="2026-07-15">
|
|
77
|
+
* </nys-datepicker>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example Disabled
|
|
81
|
+
* ```html
|
|
82
|
+
* <nys-datepicker
|
|
83
|
+
* label="Disabled datepicker"
|
|
84
|
+
* disabled
|
|
85
|
+
* value="2025-01-15">
|
|
86
|
+
* </nys-datepicker>
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @example Required
|
|
90
|
+
* ```html
|
|
91
|
+
* <nys-datepicker
|
|
92
|
+
* label="Start Date"
|
|
93
|
+
* required>
|
|
94
|
+
* </nys-datepicker>
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example Optional
|
|
98
|
+
* ```html
|
|
99
|
+
* <nys-datepicker
|
|
100
|
+
* label="Start Date"
|
|
101
|
+
* optional>
|
|
102
|
+
* </nys-datepicker>
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare class NysDatepicker extends NysFormControlElement {
|
|
106
|
+
static styles: import("lit").CSSResult;
|
|
107
|
+
static shadowRootOptions: {
|
|
108
|
+
delegatesFocus: boolean;
|
|
109
|
+
clonable?: boolean;
|
|
110
|
+
customElementRegistry?: CustomElementRegistry;
|
|
111
|
+
mode: ShadowRootMode;
|
|
112
|
+
serializable?: boolean;
|
|
113
|
+
slotAssignment?: SlotAssignmentMode;
|
|
114
|
+
};
|
|
115
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
116
|
+
id: string;
|
|
117
|
+
/** Name for form submission. */
|
|
118
|
+
name: string;
|
|
119
|
+
/**
|
|
120
|
+
* Input width: `md` (200px), `lg` (384px), `full` (100%).
|
|
121
|
+
* @default "full"
|
|
122
|
+
*/
|
|
123
|
+
width: "md" | "lg" | "full";
|
|
124
|
+
/** Hide the "Today" button in calendar popup. */
|
|
125
|
+
hideTodayButton: boolean;
|
|
126
|
+
/** Hide the "Clear" button in calendar popup. */
|
|
127
|
+
hideClearButton: boolean;
|
|
128
|
+
/** Disable interaction. */
|
|
129
|
+
disabled: boolean;
|
|
130
|
+
/** Mark as required. Shows "Required" flag and validates on blur. */
|
|
131
|
+
required: boolean;
|
|
132
|
+
/** Show "Optional" flag. Use when most fields are required. */
|
|
133
|
+
optional: boolean;
|
|
134
|
+
/** Show error state. */
|
|
135
|
+
showError: boolean;
|
|
136
|
+
/** Error message text. */
|
|
137
|
+
errorMessage: string;
|
|
138
|
+
/** Form `id` to associate with when input is outside form. */
|
|
139
|
+
form: string | null;
|
|
140
|
+
/** Tooltip text on info icon hover. */
|
|
141
|
+
tooltip: string;
|
|
142
|
+
/** Input type. Currently only supports `date`. */
|
|
143
|
+
type: string;
|
|
144
|
+
/** Label text. Required for accessibility. */
|
|
145
|
+
label: string;
|
|
146
|
+
/** Helper text below label. */
|
|
147
|
+
description: string;
|
|
148
|
+
/** Initial date when calendar opens (YYYY-MM-DD). */
|
|
149
|
+
startDate: string;
|
|
150
|
+
/** The earliest selectable date (YYYY-MM-DD). */
|
|
151
|
+
minDate: string;
|
|
152
|
+
/** The latest selectable date (YYYY-MM-DD). */
|
|
153
|
+
maxDate: string;
|
|
154
|
+
/** Dark background mode. */
|
|
155
|
+
inverted: boolean;
|
|
156
|
+
/** Selected date. Accepts Date object or ISO string (YYYY-MM-DD). */
|
|
157
|
+
value: string | Date | undefined;
|
|
158
|
+
private datepickerIsOpen;
|
|
159
|
+
private readonly DATEPICKER_GAP;
|
|
160
|
+
private _hasUserInteracted;
|
|
161
|
+
/**
|
|
162
|
+
* Lifecycle methods
|
|
163
|
+
* --------------------------------------------------------------------------
|
|
164
|
+
* Form association, ElementInternals, and id generation are provided by
|
|
165
|
+
* NysFormControlElement (@nysds/internals).
|
|
166
|
+
*/
|
|
167
|
+
connectedCallback(): void;
|
|
168
|
+
disconnectedCallback(): void;
|
|
169
|
+
firstUpdated(): Promise<void>;
|
|
170
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
171
|
+
private _whenWcDatepickerReady;
|
|
172
|
+
/**
|
|
173
|
+
* Form Integration
|
|
174
|
+
* --------------------------------------------------------------------------
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* Form helper methods:
|
|
178
|
+
* - _setValue: set internal value and trigger validation
|
|
179
|
+
* - _manageRequire: handle required state
|
|
180
|
+
* - _validate: actively validate and show errors
|
|
181
|
+
* - checkValidity: passive boolean check without UI
|
|
182
|
+
* - _setValidityMessage: sync validation message with UI and internals
|
|
183
|
+
* - _handleInvalid: handle form invalid event and focus first invalid field
|
|
184
|
+
*/
|
|
185
|
+
private _setValue;
|
|
186
|
+
private _manageRequire;
|
|
187
|
+
/**
|
|
188
|
+
* Actively validates the component:
|
|
189
|
+
* - Updates internal validity state
|
|
190
|
+
* - Updates UI (e.g. showError)
|
|
191
|
+
* - Called on blur/change or form submission
|
|
192
|
+
*/
|
|
193
|
+
private _validate;
|
|
194
|
+
/**
|
|
195
|
+
* Passive check of validity:
|
|
196
|
+
* - Returns true/false
|
|
197
|
+
* - Does NOT update UI or show errors
|
|
198
|
+
* - Used in form submission checks
|
|
199
|
+
*/
|
|
200
|
+
checkValidity(): boolean;
|
|
201
|
+
private _setValidityMessage;
|
|
202
|
+
private _handleInvalid;
|
|
203
|
+
/**
|
|
204
|
+
* Functions
|
|
205
|
+
* --------------------------------------------------------------------------
|
|
206
|
+
*/
|
|
207
|
+
/**
|
|
208
|
+
* Replaces the default wc-datepicker month navigation buttons
|
|
209
|
+
* with NYS icon components for previous and next month.
|
|
210
|
+
*/
|
|
211
|
+
private _replaceButtonSVG;
|
|
212
|
+
private _addMonthDropdownIcon;
|
|
213
|
+
private _parseLocalDate;
|
|
214
|
+
private _setTodayDate;
|
|
215
|
+
private _setFocusOnTodayDate;
|
|
216
|
+
private _isOutOfRange;
|
|
217
|
+
private _dispatchInputEvent;
|
|
218
|
+
/**
|
|
219
|
+
* Event Handlers
|
|
220
|
+
* --------------------------------------------------------------------------
|
|
221
|
+
*/
|
|
222
|
+
private _handleInputKeydown;
|
|
223
|
+
private _handleBlur;
|
|
224
|
+
private _onDocumentClick;
|
|
225
|
+
private _onKeydownEsc;
|
|
226
|
+
private _toggleDatepicker;
|
|
227
|
+
private _openDatepicker;
|
|
228
|
+
private _handleDateChange;
|
|
229
|
+
private _handleTodayClick;
|
|
230
|
+
private _handleClearClick;
|
|
231
|
+
private _handleInputChange;
|
|
232
|
+
private _getValidDateFromInput;
|
|
233
|
+
private _handleFocusTrap;
|
|
234
|
+
private _isSafari;
|
|
235
|
+
/**
|
|
236
|
+
* Determines whether the current device uses a coarse pointer.
|
|
237
|
+
* A coarse pointer usually means touch-based input where precise pointing
|
|
238
|
+
* is not expected, such as fingers on phones and most tablets.
|
|
239
|
+
*
|
|
240
|
+
* Note: This is not a guarantee of a mobile device.
|
|
241
|
+
* Some non-mobile devices may also report a coarse pointer,
|
|
242
|
+
* and some mobile devices may not.
|
|
243
|
+
*
|
|
244
|
+
* @returns `true` if the device reports a coarse pointer, otherwise `false`.
|
|
245
|
+
*/
|
|
246
|
+
private _isMobile;
|
|
247
|
+
private _shouldUseNativeDatepicker;
|
|
248
|
+
/**
|
|
249
|
+
* Auto-Positioning
|
|
250
|
+
* --------------------------------------------------------------------------
|
|
251
|
+
* Opens the calendar below the input by default. If there isn't enough
|
|
252
|
+
* room below (and there's more room above), it opens above instead.
|
|
253
|
+
*/
|
|
254
|
+
private _positionDatepicker;
|
|
255
|
+
private _handleScrollReposition;
|
|
256
|
+
private _startDatepickerPositioning;
|
|
257
|
+
private _stopDatepickerPositioning;
|
|
258
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
259
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|