@nysds/nys-datepicker 1.19.0 → 1.19.2

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.
@@ -0,0 +1,189 @@
1
+ import { LitElement } from "lit";
2
+ /**
3
+ * Date picker with calendar popup and form validation. Falls back to native date input
4
+ * on Safari and mobile.
5
+ *
6
+ * @summary Date picker with calendar popup and native fallback.
7
+ * @element nys-datepicker
8
+ *
9
+ * @fires nys-blur - Fired when input or calendar loses focus. Triggers validation.
10
+ * @fires nys-input - Fired on date selection. Detail: `{id, value}`.
11
+ *
12
+ * @example Basic date picker
13
+ * ```html
14
+ * <nys-datepicker label="Birth Date" required></nys-datepicker>
15
+ * ```
16
+ *
17
+ * @example With width and description
18
+ * ```html
19
+ * <nys-datepicker
20
+ * label="Event Date"
21
+ * description="Select the date of your event"
22
+ * width="lg">
23
+ * </nys-datepicker>
24
+ * ```
25
+ *
26
+ * @example Hide buttons, set start date
27
+ * ```html
28
+ * <nys-datepicker
29
+ * label="Appointment"
30
+ * hideTodayButton
31
+ * hideClearButton
32
+ * startDate="2024-01-01">
33
+ * </nys-datepicker>
34
+ * ```
35
+ *
36
+ * @example With validation error message
37
+ * ```html
38
+ * <nys-datepicker
39
+ * label="Start Date"
40
+ * required
41
+ * errorMessage="Please select a valid start date">
42
+ * </nys-datepicker>
43
+ * ```
44
+ */
45
+ export declare class NysDatepicker extends LitElement {
46
+ static styles: import("lit").CSSResult;
47
+ static shadowRootOptions: {
48
+ delegatesFocus: boolean;
49
+ clonable?: boolean;
50
+ customElementRegistry?: CustomElementRegistry;
51
+ mode: ShadowRootMode;
52
+ serializable?: boolean;
53
+ slotAssignment?: SlotAssignmentMode;
54
+ };
55
+ /** Unique identifier. Auto-generated if not provided. */
56
+ id: string;
57
+ /** Name for form submission. */
58
+ name: string;
59
+ /**
60
+ * Input width: `md` (200px), `lg` (384px), `full` (100%).
61
+ * @default "full"
62
+ */
63
+ width: "md" | "lg" | "full";
64
+ /** Hide the "Today" button in calendar popup. */
65
+ hideTodayButton: boolean;
66
+ /** Hide the "Clear" button in calendar popup. */
67
+ hideClearButton: boolean;
68
+ /** Disable interaction. */
69
+ disabled: boolean;
70
+ /** Mark as required. Shows "Required" flag and validates on blur. */
71
+ required: boolean;
72
+ /** Show "Optional" flag. Use when most fields are required. */
73
+ optional: boolean;
74
+ /** Show error state. */
75
+ showError: boolean;
76
+ /** Error message text. */
77
+ errorMessage: string;
78
+ /** Form `id` to associate with when input is outside form. */
79
+ form: string | null;
80
+ /** Tooltip text on info icon hover. */
81
+ tooltip: string;
82
+ /** Input type. Currently only supports `date`. */
83
+ type: string;
84
+ /** Label text. Required for accessibility. */
85
+ label: string;
86
+ /** Helper text below label. */
87
+ description: string;
88
+ /** Initial date when calendar opens (YYYY-MM-DD). */
89
+ startDate: string;
90
+ /** The earliest selectable date (YYYY-MM-DD). */
91
+ minDate: string;
92
+ /** The latest selectable date (YYYY-MM-DD). */
93
+ maxDate: string;
94
+ /** Dark background mode. */
95
+ inverted: boolean;
96
+ /** Selected date. Accepts Date object or ISO string (YYYY-MM-DD). */
97
+ value: string | Date | undefined;
98
+ private datepickerIsOpen;
99
+ private _hasUserInteracted;
100
+ private _internals;
101
+ /**
102
+ * Lifecycle methods
103
+ * --------------------------------------------------------------------------
104
+ */
105
+ static formAssociated: boolean;
106
+ constructor();
107
+ connectedCallback(): void;
108
+ disconnectedCallback(): void;
109
+ firstUpdated(): Promise<void>;
110
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
111
+ private _whenWcDatepickerReady;
112
+ /**
113
+ * Form Integration
114
+ * --------------------------------------------------------------------------
115
+ */
116
+ /**
117
+ * Form helper methods:
118
+ * - _setValue: set internal value and trigger validation
119
+ * - _manageRequire: handle required state
120
+ * - _validate: actively validate and show errors
121
+ * - checkValidity: passive boolean check without UI
122
+ * - _setValidityMessage: sync validation message with UI and internals
123
+ * - _handleInvalid: handle form invalid event and focus first invalid field
124
+ */
125
+ private _setValue;
126
+ private _manageRequire;
127
+ /**
128
+ * Actively validates the component:
129
+ * - Updates internal validity state
130
+ * - Updates UI (e.g. showError)
131
+ * - Called on blur/change or form submission
132
+ */
133
+ private _validate;
134
+ /**
135
+ * Passive check of validity:
136
+ * - Returns true/false
137
+ * - Does NOT update UI or show errors
138
+ * - Used in form submission checks
139
+ */
140
+ checkValidity(): boolean;
141
+ private _setValidityMessage;
142
+ private _handleInvalid;
143
+ /**
144
+ * Functions
145
+ * --------------------------------------------------------------------------
146
+ */
147
+ /**
148
+ * Replaces the default wc-datepicker month navigation buttons
149
+ * with NYS icon components for previous and next month.
150
+ */
151
+ private _replaceButtonSVG;
152
+ private _addMonthDropdownIcon;
153
+ private _parseLocalDate;
154
+ private _setTodayDate;
155
+ private _setFocusOnTodayDate;
156
+ private _isOutOfRange;
157
+ private _dispatchInputEvent;
158
+ /**
159
+ * Event Handlers
160
+ * --------------------------------------------------------------------------
161
+ */
162
+ private _handleInputKeydown;
163
+ private _handleBlur;
164
+ private _onDocumentClick;
165
+ private _onKeydownEsc;
166
+ private _toggleDatepicker;
167
+ private _openDatepicker;
168
+ private _handleDateChange;
169
+ private _handleTodayClick;
170
+ private _handleClearClick;
171
+ private _handleInputChange;
172
+ private _getValidDateFromInput;
173
+ private _handleFocusTrap;
174
+ private _isSafari;
175
+ /**
176
+ * Determines whether the current device uses a coarse pointer.
177
+ * A coarse pointer usually means touch-based input where precise pointing
178
+ * is not expected, such as fingers on phones and most tablets.
179
+ *
180
+ * Note: This is not a guarantee of a mobile device.
181
+ * Some non-mobile devices may also report a coarse pointer,
182
+ * and some mobile devices may not.
183
+ *
184
+ * @returns `true` if the device reports a coarse pointer, otherwise `false`.
185
+ */
186
+ private _isMobile;
187
+ private _shouldUseNativeDatepicker;
188
+ render(): import("lit-html").TemplateResult<1>;
189
+ }