@nysds/nys-datepicker 1.21.1 → 1.22.1
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/nys-datepicker.d.ts +44 -2
- package/dist/nys-datepicker.js +490 -419
- package/dist/nys-datepicker.js.map +1 -1
- package/package.json +8 -8
package/dist/nys-datepicker.d.ts
CHANGED
|
@@ -3,6 +3,24 @@ import "@nysds/nys-label";
|
|
|
3
3
|
import "@nysds/nys-errormessage";
|
|
4
4
|
import "@nysds/nys-icon";
|
|
5
5
|
import "@nysds/nys-button";
|
|
6
|
+
/** Detail payload for the `nys-input` event. */
|
|
7
|
+
export interface NysDatepickerInputDetail {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
/** The current `value` property: a `Date`, a `YYYY-MM-DD` string, or `undefined`. */
|
|
11
|
+
value: string | Date | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** The `nys-input` event, fired as the date value updates. */
|
|
14
|
+
export type NysDatepickerInputEvent = CustomEvent<NysDatepickerInputDetail>;
|
|
15
|
+
/** Detail payload for the `nys-change` event. */
|
|
16
|
+
export interface NysDatepickerChangeDetail {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
/** The committed date, always a `YYYY-MM-DD` string. Empty string when cleared. */
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
/** The `nys-change` event, fired on a committed selection. */
|
|
23
|
+
export type NysDatepickerChangeEvent = CustomEvent<NysDatepickerChangeDetail>;
|
|
6
24
|
/**
|
|
7
25
|
* Date picker with calendar popup and form validation. Falls back to native date input
|
|
8
26
|
* on Safari and mobile.
|
|
@@ -10,8 +28,26 @@ import "@nysds/nys-button";
|
|
|
10
28
|
* @summary Date picker with calendar popup and native fallback.
|
|
11
29
|
* @element nys-datepicker
|
|
12
30
|
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
31
|
+
* @formControl value nys-change nys-input
|
|
32
|
+
*
|
|
33
|
+
* @fires {NysDatepickerInputEvent} nys-input - Fired as the date value updates (valid typed date, calendar pick, Today, Clear). Detail: `{id, name, value}` where `value` is the current `value` property.
|
|
34
|
+
* @fires {NysDatepickerChangeEvent} nys-change - Fired on committed selection: calendar pick, valid typed date on blur, Today, Clear. Detail: `{id, name, value}` where `value` is always the `YYYY-MM-DD` string, empty string when cleared.
|
|
35
|
+
* @fires {Event} nys-focus - Fired when focus enters the component from outside.
|
|
36
|
+
* @fires {Event} nys-blur - Fired when input or calendar loses focus. Triggers validation.
|
|
37
|
+
*
|
|
38
|
+
* @usagedos
|
|
39
|
+
* - Use when users need to select a single calendar date, such as scheduling an appointment or choosing a filing deadline, especially when the day of the week matters.
|
|
40
|
+
* - Set the `label` property to clearly describe what date is being collected. Every datepicker needs one for accessibility.
|
|
41
|
+
* - Add `description` text to specify the expected format or provide context.
|
|
42
|
+
* - Set `required` when the date is mandatory for form submission; don't set both `required` and `optional` on the same component.
|
|
43
|
+
* - Use `startDate` to open the calendar to a relevant month when the expected date is far from today.
|
|
44
|
+
* - Pass date values as ISO strings (`"YYYY-MM-DD"`) rather than `Date` objects to avoid timezone issues.
|
|
45
|
+
*
|
|
46
|
+
* @usagedonts
|
|
47
|
+
* - Use for dates users know from memory, such as date of birth or document issue dates. A text input with separate month/day/year fields is more efficient.
|
|
48
|
+
* - Use when users need to select multiple dates or a date range, or when time selection is required alongside the date.
|
|
49
|
+
* - Rely on the calendar popup alone. Safari and mobile browsers use the native date picker instead.
|
|
50
|
+
* - Use `hideTodayButton` and `hideClearButton` together unless users must select a specific date and cannot be allowed to clear it.
|
|
15
51
|
*
|
|
16
52
|
* @example Basic
|
|
17
53
|
* ```html
|
|
@@ -158,6 +194,7 @@ export declare class NysDatepicker extends NysFormControlElement {
|
|
|
158
194
|
private datepickerIsOpen;
|
|
159
195
|
private readonly DATEPICKER_GAP;
|
|
160
196
|
private _hasUserInteracted;
|
|
197
|
+
private _dirtySinceCommit;
|
|
161
198
|
/**
|
|
162
199
|
* Lifecycle methods
|
|
163
200
|
* --------------------------------------------------------------------------
|
|
@@ -214,12 +251,17 @@ export declare class NysDatepicker extends NysFormControlElement {
|
|
|
214
251
|
private _setTodayDate;
|
|
215
252
|
private _setFocusOnTodayDate;
|
|
216
253
|
private _isOutOfRange;
|
|
254
|
+
private _valueAsString;
|
|
217
255
|
private _dispatchInputEvent;
|
|
256
|
+
private _dispatchChangeEvent;
|
|
257
|
+
private _closeCalendar;
|
|
258
|
+
private _focusInput;
|
|
218
259
|
/**
|
|
219
260
|
* Event Handlers
|
|
220
261
|
* --------------------------------------------------------------------------
|
|
221
262
|
*/
|
|
222
263
|
private _handleInputKeydown;
|
|
264
|
+
private _handleFocus;
|
|
223
265
|
private _handleBlur;
|
|
224
266
|
private _onDocumentClick;
|
|
225
267
|
private _onKeydownEsc;
|