@nysds/nys-datepicker 1.13.1 → 1.14.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.
@@ -0,0 +1 @@
1
+ export * from "./nys-datepicker";
@@ -0,0 +1,174 @@
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
+ /** Unique identifier. Auto-generated if not provided. */
48
+ id: string;
49
+ /** Name for form submission. */
50
+ name: string;
51
+ /**
52
+ * Input width: `md` (200px), `lg` (384px), `full` (100%).
53
+ * @default "md"
54
+ */
55
+ width: "md" | "lg" | "full";
56
+ /** Hide the "Today" button in calendar popup. */
57
+ hideTodayButton: boolean;
58
+ /** Hide the "Clear" button in calendar popup. */
59
+ hideClearButton: boolean;
60
+ /** Disable interaction. */
61
+ disabled: boolean;
62
+ /** Mark as required. Shows "Required" flag and validates on blur. */
63
+ required: boolean;
64
+ /** Show "Optional" flag. Use when most fields are required. */
65
+ optional: boolean;
66
+ /** Show error state. */
67
+ showError: boolean;
68
+ /** Error message text. */
69
+ errorMessage: string;
70
+ /** Form `id` to associate with when input is outside form. */
71
+ form: string | null;
72
+ /** Tooltip text on info icon hover. */
73
+ tooltip: string;
74
+ /** Input type. Currently only supports `date`. */
75
+ type: string;
76
+ /** Label text. Required for accessibility. */
77
+ label: string;
78
+ /** Helper text below label. */
79
+ description: string;
80
+ /** Initial date when calendar opens (YYYY-MM-DD). */
81
+ startDate: string;
82
+ /** Dark background mode. */
83
+ inverted: boolean;
84
+ /** Selected date. Accepts Date object or ISO string (YYYY-MM-DD). */
85
+ value: string | Date | undefined;
86
+ private datepickerIsOpen;
87
+ private _hasUserInteracted;
88
+ private _internals;
89
+ /**
90
+ * Lifecycle methods
91
+ * --------------------------------------------------------------------------
92
+ */
93
+ static formAssociated: boolean;
94
+ constructor();
95
+ connectedCallback(): void;
96
+ disconnectedCallback(): void;
97
+ firstUpdated(): Promise<void>;
98
+ private _whenWcDatepickerReady;
99
+ /**
100
+ * Form Integration
101
+ * --------------------------------------------------------------------------
102
+ */
103
+ /**
104
+ * Form helper methods:
105
+ * - _setValue: set internal value and trigger validation
106
+ * - _manageRequire: handle required state
107
+ * - _validate: actively validate and show errors
108
+ * - checkValidity: passive boolean check without UI
109
+ * - _setValidityMessage: sync validation message with UI and internals
110
+ * - _handleInvalid: handle form invalid event and focus first invalid field
111
+ */
112
+ private _setValue;
113
+ private _manageRequire;
114
+ /**
115
+ * Actively validates the component:
116
+ * - Updates internal validity state
117
+ * - Updates UI (e.g. showError)
118
+ * - Called on blur/change or form submission
119
+ */
120
+ private _validate;
121
+ /**
122
+ * Passive check of validity:
123
+ * - Returns true/false
124
+ * - Does NOT update UI or show errors
125
+ * - Used in form submission checks
126
+ */
127
+ checkValidity(): boolean;
128
+ private _setValidityMessage;
129
+ private _handleInvalid;
130
+ /**
131
+ * Functions
132
+ * --------------------------------------------------------------------------
133
+ */
134
+ /**
135
+ * Replaces the default wc-datepicker month navigation buttons
136
+ * with NYS icon components for previous and next month.
137
+ */
138
+ private _replaceButtonSVG;
139
+ private _addMonthDropdownIcon;
140
+ private _parseLocalDate;
141
+ private _setTodayDate;
142
+ private _setFocusOnTodayDate;
143
+ /**
144
+ * Event Handlers
145
+ * --------------------------------------------------------------------------
146
+ */
147
+ private _handleInputKeydown;
148
+ private _handleBlur;
149
+ private _onDocumentClick;
150
+ private _onKeydownEsc;
151
+ private _toggleDatepicker;
152
+ private _openDatepicker;
153
+ private _handleDateChange;
154
+ private _handleTodayClick;
155
+ private _handleClearClick;
156
+ private _handleInputChange;
157
+ private _getValidDateFromInput;
158
+ private _handleFocusTrap;
159
+ private _isSafari;
160
+ /**
161
+ * Determines whether the current device uses a coarse pointer.
162
+ * A coarse pointer usually means touch-based input where precise pointing
163
+ * is not expected, such as fingers on phones and most tablets.
164
+ *
165
+ * Note: This is not a guarantee of a mobile device.
166
+ * Some non-mobile devices may also report a coarse pointer,
167
+ * and some mobile devices may not.
168
+ *
169
+ * @returns `true` if the device reports a coarse pointer, otherwise `false`.
170
+ */
171
+ private _isMobile;
172
+ private _shouldUseNativeDatepicker;
173
+ render(): import("lit-html").TemplateResult<1>;
174
+ }
@@ -0,0 +1 @@
1
+ export {};