@carbon/utilities 0.23.0 → 0.24.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,993 @@
1
+ //#region src/date-picker/primitives/states.d.ts
2
+ /**
3
+ * Copyright IBM Corp. 2026
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * Date picker state machine states
10
+ */
11
+ declare enum DatePickerState {
12
+ /**
13
+ * Initial state - calendar closed, no focus
14
+ */
15
+ IDLE = "idle",
16
+ /**
17
+ * Input has focus, calendar closed
18
+ */
19
+ FOCUSED = "focused",
20
+ /**
21
+ * Calendar dropdown is open
22
+ */
23
+ CALENDAR_OPEN = "calendar_open",
24
+ /**
25
+ * User is selecting the start date (range mode)
26
+ */
27
+ SELECTING_START = "selecting_start",
28
+ /**
29
+ * User is selecting the end date (range mode)
30
+ */
31
+ SELECTING_END = "selecting_end",
32
+ /**
33
+ * Date(s) have been selected
34
+ */
35
+ DATE_SELECTED = "date_selected",
36
+ /**
37
+ * Component is disabled
38
+ */
39
+ DISABLED = "disabled",
40
+ /**
41
+ * Component is read-only
42
+ */
43
+ READONLY = "readonly",
44
+ /**
45
+ * Component is in an error state
46
+ */
47
+ ERROR = "error"
48
+ }
49
+ /**
50
+ * Date picker events
51
+ */
52
+ declare enum DatePickerEvent {
53
+ INPUT_FOCUS = "INPUT_FOCUS",
54
+ INPUT_BLUR = "INPUT_BLUR",
55
+ INPUT_CHANGE = "INPUT_CHANGE",
56
+ CALENDAR_ICON_CLICK = "CALENDAR_ICON_CLICK",
57
+ CALENDAR_OPEN = "CALENDAR_OPEN",
58
+ CALENDAR_CLOSE = "CALENDAR_CLOSE",
59
+ PREV_MONTH = "PREV_MONTH",
60
+ NEXT_MONTH = "NEXT_MONTH",
61
+ PREV_YEAR = "PREV_YEAR",
62
+ NEXT_YEAR = "NEXT_YEAR",
63
+ GO_TO_TODAY = "GO_TO_TODAY",
64
+ DATE_SELECT = "DATE_SELECT",
65
+ RANGE_START_SELECT = "RANGE_START_SELECT",
66
+ RANGE_END_SELECT = "RANGE_END_SELECT",
67
+ OUTSIDE_CLICK = "OUTSIDE_CLICK",
68
+ ESCAPE_KEY = "ESCAPE_KEY",
69
+ TAB_KEY = "TAB_KEY",
70
+ SHIFT_TAB_KEY = "SHIFT_TAB_KEY",
71
+ ENTER_KEY = "ENTER_KEY",
72
+ ARROW_UP = "ARROW_UP",
73
+ ARROW_DOWN = "ARROW_DOWN",
74
+ ARROW_LEFT = "ARROW_LEFT",
75
+ ARROW_RIGHT = "ARROW_RIGHT",
76
+ PAGE_UP = "PAGE_UP",
77
+ PAGE_DOWN = "PAGE_DOWN",
78
+ HOME_KEY = "HOME_KEY",
79
+ END_KEY = "END_KEY",
80
+ DISABLE = "DISABLE",
81
+ ENABLE = "ENABLE",
82
+ SET_READONLY = "SET_READONLY",
83
+ UNSET_READONLY = "UNSET_READONLY",
84
+ VALUE_CHANGE = "VALUE_CHANGE",
85
+ VALIDATION_ERROR = "VALIDATION_ERROR",
86
+ CLEAR_ERROR = "CLEAR_ERROR",
87
+ SET_MIN_DATE = "SET_MIN_DATE",
88
+ SET_MAX_DATE = "SET_MAX_DATE",
89
+ SET_DATE_FORMAT = "SET_DATE_FORMAT"
90
+ }
91
+ //#endregion
92
+ //#region src/date-picker/primitives/types.d.ts
93
+ /**
94
+ * Copyright IBM Corp. 2026
95
+ *
96
+ * This source code is licensed under the Apache-2.0 license found in the
97
+ * LICENSE file in the root directory of this source tree.
98
+ */
99
+ /**
100
+ * Temporal API type declarations
101
+ * Using Temporal for modern date handling
102
+ */
103
+ declare global {
104
+ namespace Temporal {
105
+ interface PlainDate {
106
+ readonly year: number;
107
+ readonly month: number;
108
+ readonly day: number;
109
+ readonly daysInMonth: number;
110
+ toString(): string;
111
+ with(dateLike: {
112
+ year?: number;
113
+ month?: number;
114
+ day?: number;
115
+ }): PlainDate;
116
+ add(duration: {
117
+ days?: number;
118
+ months?: number;
119
+ years?: number;
120
+ }): PlainDate;
121
+ until(other: PlainDate): {
122
+ days: number;
123
+ };
124
+ toPlainYearMonth(): PlainYearMonth;
125
+ }
126
+ interface PlainYearMonth {
127
+ readonly year: number;
128
+ readonly month: number;
129
+ readonly daysInMonth: number;
130
+ toString(): string;
131
+ toPlainDate(dayLike: {
132
+ day: number;
133
+ }): PlainDate;
134
+ add(duration: {
135
+ months?: number;
136
+ years?: number;
137
+ }): PlainYearMonth;
138
+ subtract(duration: {
139
+ months?: number;
140
+ years?: number;
141
+ }): PlainYearMonth;
142
+ }
143
+ interface PlainYearMonthConstructor {
144
+ from(item: string | {
145
+ year: number;
146
+ month: number;
147
+ }): PlainYearMonth;
148
+ compare(one: PlainYearMonth, two: PlainYearMonth): number;
149
+ }
150
+ const PlainYearMonth: PlainYearMonthConstructor;
151
+ interface PlainDateConstructor {
152
+ from(item: string | {
153
+ year: number;
154
+ month: number;
155
+ day: number;
156
+ }): PlainDate;
157
+ compare(one: PlainDate, two: PlainDate): number;
158
+ }
159
+ const PlainDate: PlainDateConstructor;
160
+ interface Now {
161
+ plainDateISO(): PlainDate;
162
+ }
163
+ const Now: Now;
164
+ }
165
+ }
166
+ /**
167
+ * Date picker modes
168
+ */
169
+ type DatePickerMode = 'simple' | 'single' | 'range';
170
+ /**
171
+ * Input type for range mode
172
+ */
173
+ type InputType = 'from' | 'to';
174
+ /**
175
+ * Input target for focus restoration
176
+ */
177
+ type FocusRestoreTarget = InputType | null;
178
+ /**
179
+ * Date picker state machine context
180
+ * Contains all the state needed to manage the datepicker
181
+ * Uses Temporal.PlainDate for robust date handling
182
+ */
183
+ interface DatePickerContext {
184
+ /** The mode of the date picker */
185
+ mode: DatePickerMode;
186
+ /** The current value as ISO date string(s) */
187
+ value: string;
188
+ /** The selected start date (using Temporal API) */
189
+ startDate: Temporal.PlainDate | null;
190
+ /** The selected end date (range mode only, using Temporal API) */
191
+ endDate: Temporal.PlainDate | null;
192
+ /** Whether the calendar dropdown is open */
193
+ isOpen: boolean;
194
+ /** Whether an input has focus */
195
+ isFocused: boolean;
196
+ /** Whether the component is disabled */
197
+ isDisabled: boolean;
198
+ /** Whether the component is readonly */
199
+ isReadonly: boolean;
200
+ /** Whether the component is in an invalid state */
201
+ isInvalid: boolean;
202
+ /** The last focused input (for range mode) */
203
+ lastFocusedInput: InputType | null;
204
+ /** The input that should receive focus after a selection-driven close */
205
+ restoreFocusTo: FocusRestoreTarget;
206
+ /** Whether focus should be restored after the next close/render cycle */
207
+ shouldRestoreFocus: boolean;
208
+ /** Minimum selectable date (using Temporal API) */
209
+ minDate: Temporal.PlainDate | null;
210
+ /** Maximum selectable date (using Temporal API) */
211
+ maxDate: Temporal.PlainDate | null;
212
+ /** Date format string */
213
+ dateFormat: string;
214
+ /** Whether to allow manual input */
215
+ allowInput: boolean;
216
+ /** Whether to close calendar on date selection */
217
+ closeOnSelect: boolean;
218
+ /** Error message if any */
219
+ errorMessage?: string;
220
+ /** The currently viewed month in the calendar (using Temporal API) */
221
+ viewDate: Temporal.PlainDate | null;
222
+ /** The date that currently has keyboard focus in the calendar */
223
+ focusedDate: Temporal.PlainDate | null;
224
+ }
225
+ /**
226
+ * Event payload types
227
+ */
228
+ interface DateSelectPayload {
229
+ date: Temporal.PlainDate;
230
+ inputType?: InputType;
231
+ }
232
+ interface InputFocusPayload {
233
+ inputType: InputType;
234
+ }
235
+ interface KeyboardPayload {
236
+ key: string;
237
+ shiftKey?: boolean;
238
+ }
239
+ interface ValueChangePayload {
240
+ value: string;
241
+ }
242
+ interface ValidationErrorPayload {
243
+ message: string;
244
+ }
245
+ /**
246
+ * Date picker event
247
+ */
248
+ interface DatePickerEvent$1<T = unknown> {
249
+ type: string;
250
+ payload?: T;
251
+ timestamp: number;
252
+ }
253
+ /**
254
+ * State transition information
255
+ */
256
+ interface StateTransition {
257
+ from: string;
258
+ to: string;
259
+ event: DatePickerEvent$1;
260
+ context: DatePickerContext;
261
+ }
262
+ /**
263
+ * Guard function type - determines if a transition is allowed
264
+ */
265
+ type StateGuard = (context: DatePickerContext, event: DatePickerEvent$1) => boolean;
266
+ /**
267
+ * Action function type - updates context during transition
268
+ */
269
+ type StateAction = (context: DatePickerContext, event: DatePickerEvent$1) => Partial<DatePickerContext>;
270
+ /**
271
+ * Side effect function type - performs side effects after transition
272
+ */
273
+ type SideEffect = (context: DatePickerContext, event: DatePickerEvent$1) => void;
274
+ /**
275
+ * Transition listener function type
276
+ */
277
+ type TransitionListener = (transition: StateTransition) => void;
278
+ /**
279
+ * State configuration
280
+ */
281
+ interface StateConfig {
282
+ guards?: Record<string, StateGuard>;
283
+ actions?: Record<string, StateAction>;
284
+ effects?: Record<string, SideEffect>;
285
+ }
286
+ /**
287
+ * Transition map type
288
+ */
289
+ type TransitionMap = Record<string, Partial<Record<string, string>>>;
290
+ //#endregion
291
+ //#region src/date-picker/primitives/machine.d.ts
292
+ /**
293
+ * Date picker state machine
294
+ * Manages state transitions and context updates for the date picker
295
+ */
296
+ declare class DatePickerStateMachine {
297
+ private currentState;
298
+ private context;
299
+ private listeners;
300
+ /**
301
+ * Create a new date picker state machine
302
+ *
303
+ * @param {Partial<DatePickerContext>} initialContext - Initial context values
304
+ */
305
+ constructor(initialContext?: Partial<DatePickerContext>);
306
+ /**
307
+ * Create initial context with defaults
308
+ *
309
+ * @param {Partial<DatePickerContext>} partial - Partial context to merge with defaults
310
+ * @returns Complete context object
311
+ */
312
+ private createInitialContext;
313
+ /**
314
+ * Send an event to the state machine
315
+ * This is the primary method for triggering state transitions
316
+ *
317
+ * @param {string} eventType - The type of event to send
318
+ * @param {unknown} payload - Optional event payload
319
+ * @returns The updated context
320
+ */
321
+ send(eventType: string, payload?: unknown): DatePickerContext;
322
+ /**
323
+ * Get the current state
324
+ *
325
+ * @returns The current state
326
+ */
327
+ getState(): DatePickerState;
328
+ /**
329
+ * Get the current context
330
+ *
331
+ * @returns A copy of the current context
332
+ */
333
+ getContext(): DatePickerContext;
334
+ /**
335
+ * Update context directly (use sparingly)
336
+ *
337
+ * @param {Partial<DatePickerContext>} updates - Partial context updates
338
+ * @returns The updated context
339
+ */
340
+ updateContext(updates: Partial<DatePickerContext>): DatePickerContext;
341
+ /**
342
+ * Subscribe to state transitions
343
+ *
344
+ * @param {TransitionListener} listener - Function to call on each transition
345
+ * @returns Unsubscribe function
346
+ */
347
+ subscribe(listener: TransitionListener): () => void;
348
+ /**
349
+ * Check if a transition is valid from the current state
350
+ *
351
+ * @param {string} eventType - The event type to check
352
+ * @returns True if the transition is valid
353
+ */
354
+ canTransition(eventType: string): boolean;
355
+ /**
356
+ * Get the next state for a given event
357
+ *
358
+ * @param {DatePickerState} from - Current state
359
+ * @param {DatePickerEvent} event - The event
360
+ * @returns Next state or null if no transition exists
361
+ */
362
+ private getNextState;
363
+ /**
364
+ * Notify all listeners of a state transition
365
+ *
366
+ * @param {StateTransition} transition - The state transition
367
+ */
368
+ private notifyListeners;
369
+ /**
370
+ * Reset the state machine to initial state
371
+ *
372
+ * @param {Partial<DatePickerContext>} initialContext - Optional new initial context
373
+ */
374
+ reset(initialContext?: Partial<DatePickerContext>): void;
375
+ }
376
+ //#endregion
377
+ //#region src/date-picker/primitives/guards.d.ts
378
+ /**
379
+ * Guard map - determines if transitions are allowed
380
+ */
381
+ type GuardMap = Record<DatePickerState, Partial<Record<string, StateGuard>>>;
382
+ /**
383
+ * Check if component is in single mode
384
+ * @param {DatePickerContext} context - Current context
385
+ * @returns {boolean} True if in single mode
386
+ */
387
+ declare const isSingleMode: (context: DatePickerContext) => boolean;
388
+ /**
389
+ * Guards for state transitions
390
+ */
391
+ declare const guards: GuardMap;
392
+ /**
393
+ * Get guard for a specific state and event
394
+ *
395
+ * @param {DatePickerState} state - The current state
396
+ * @param {string} eventType - The event type
397
+ * @returns {StateGuard | undefined} The guard function or undefined
398
+ */
399
+ declare function getGuard(state: DatePickerState, eventType: string): StateGuard | undefined;
400
+ /**
401
+ * Check if a transition is guarded and allowed
402
+ *
403
+ * @param {DatePickerState} state - The current state
404
+ * @param {string} eventType - The event type
405
+ * @param {DatePickerContext} context - The current context
406
+ * @param {DatePickerEvent} event - The event
407
+ * @returns {boolean} True if guard passes
408
+ */
409
+ declare function checkGuard(state: DatePickerState, eventType: string, context: DatePickerContext, event: DatePickerEvent$1): boolean;
410
+ //#endregion
411
+ //#region src/date-picker/primitives/actions.d.ts
412
+ /**
413
+ * Action map - updates context during transitions
414
+ */
415
+ type ActionMap = Record<DatePickerState, Partial<Record<string, StateAction>>>;
416
+ /**
417
+ * Actions for state transitions
418
+ */
419
+ declare const actions: ActionMap;
420
+ /**
421
+ * Get action for a specific state and event
422
+ *
423
+ * @param {DatePickerState} state - The current state
424
+ * @param {string} eventType - The event type
425
+ * @returns {StateAction | undefined} The action function or undefined
426
+ */
427
+ declare function getAction(state: DatePickerState, eventType: string): StateAction | undefined;
428
+ /**
429
+ * Execute an action and return context updates
430
+ *
431
+ * @param {DatePickerState} state - The current state
432
+ * @param {string} eventType - The event type
433
+ * @param {DatePickerContext} context - The current context
434
+ * @param {DatePickerEvent} event - The event
435
+ * @returns {Partial<DatePickerContext>} Partial context updates
436
+ */
437
+ declare function executeAction(state: DatePickerState, eventType: string, context: DatePickerContext, event: DatePickerEvent$1): Partial<DatePickerContext>;
438
+ //#endregion
439
+ //#region src/date-picker/primitives/effects.d.ts
440
+ /**
441
+ * Effect map - performs side effects after transitions
442
+ */
443
+ type EffectMap = Record<DatePickerState, Partial<Record<string, SideEffect>>>;
444
+ /**
445
+ * Side effects for state transitions
446
+ * These are executed after the state transition is complete
447
+ */
448
+ declare const effects: EffectMap;
449
+ /**
450
+ * Get effect for a specific state and event
451
+ *
452
+ * @param {DatePickerState} state - The current state
453
+ * @param {string} eventType - The event type
454
+ * @returns The effect function or undefined
455
+ */
456
+ declare function getEffect(state: DatePickerState, eventType: string): SideEffect | undefined;
457
+ /**
458
+ * Execute an effect
459
+ *
460
+ * @param {DatePickerState} state - The current state
461
+ * @param {string} eventType - The event type
462
+ * @param {DatePickerContext} context - The current context
463
+ * @param {DatePickerEvent} event - The event
464
+ */
465
+ declare function executeEffect(state: DatePickerState, eventType: string, context: DatePickerContext, event: DatePickerEvent$1): void;
466
+ //#endregion
467
+ //#region src/date-picker/primitives/click-outside-handler.d.ts
468
+ /**
469
+ * Copyright IBM Corp. 2026
470
+ *
471
+ * This source code is licensed under the Apache-2.0 license found in the
472
+ * LICENSE file in the root directory of this source tree.
473
+ */
474
+ /**
475
+ * Configuration for click outside detection
476
+ */
477
+ interface ClickOutsideConfig {
478
+ /**
479
+ * Whether the component is currently open/active
480
+ */
481
+ isOpen: boolean;
482
+ /**
483
+ * Function to check if a node is within the component
484
+ *
485
+ * React example:
486
+ * ```typescript
487
+ * containsNode: (node) => {
488
+ * return (
489
+ * (calendarRef.current?.contains(node) ?? false) ||
490
+ * (startInputRef.current?.contains(node) ?? false) ||
491
+ * (endInputRef.current?.contains(node) ?? false)
492
+ * );
493
+ * }
494
+ * ```
495
+ *
496
+ * Web Components example:
497
+ * ```typescript
498
+ * containsNode: (node) => {
499
+ * return this.contains(node) || (this.shadowRoot?.contains(node) ?? false);
500
+ * }
501
+ * ```
502
+ */
503
+ containsNode: (node: Node) => boolean;
504
+ /**
505
+ * Callback when click outside is detected
506
+ */
507
+ onOutsideClick: () => void;
508
+ /**
509
+ * Whether to use capture phase (default: true)
510
+ * Using capture phase ensures the handler runs before other click handlers
511
+ */
512
+ useCapture?: boolean;
513
+ /**
514
+ * Delay in milliseconds before attaching listener (default: 0)
515
+ *
516
+ * Setting this to 0 uses a defensive approach where the listener is attached
517
+ * on the next event loop tick, preventing the click that opened the component
518
+ * from immediately triggering a close.
519
+ *
520
+ * This is particularly important when the same click that opens the calendar
521
+ * might otherwise be caught by the outside click handler.
522
+ */
523
+ attachDelay?: number;
524
+ }
525
+ /**
526
+ * Creates a click outside handler with proper lifecycle management
527
+ *
528
+ * This utility provides a framework-agnostic way to detect clicks outside
529
+ * a component and trigger a callback. It combines best practices from both
530
+ * React and Web Components implementations:
531
+ *
532
+ * - Uses defensive timing (from React) to prevent the opening click from closing
533
+ * - Supports flexible element detection (from Web Components)
534
+ * - Provides clean lifecycle management
535
+ * - Fully testable and reusable
536
+ *
537
+ * @example React usage
538
+ * ```typescript
539
+ * useEffect(() => {
540
+ * if (!context.isOpen) {
541
+ * return;
542
+ * }
543
+ *
544
+ * const handler = new ClickOutsideHandler({
545
+ * isOpen: context.isOpen,
546
+ * containsNode: (node: Node) => {
547
+ * const calendarEl = calendarRef.current;
548
+ * const startInputEl = startInputRef.current;
549
+ * const endInputEl = endInputRef.current;
550
+ *
551
+ * return (
552
+ * (calendarEl?.contains(node) ?? false) ||
553
+ * (startInputEl?.contains(node) ?? false) ||
554
+ * (endInputEl?.contains(node) ?? false)
555
+ * );
556
+ * },
557
+ * onOutsideClick: () => send(DatePickerEvent.OUTSIDE_CLICK),
558
+ * useCapture: true,
559
+ * attachDelay: 0,
560
+ * });
561
+ *
562
+ * handler.attach();
563
+ *
564
+ * return () => {
565
+ * handler.detach();
566
+ * };
567
+ * }, [context.isOpen, send]);
568
+ * ```
569
+ *
570
+ * @example Web Components usage
571
+ * ```typescript
572
+ * connectedCallback() {
573
+ * super.connectedCallback();
574
+ *
575
+ * this._clickOutsideHandler = new ClickOutsideHandler({
576
+ * isOpen: this.open,
577
+ * containsNode: (node: Node) => {
578
+ * return this.contains(node) || (this.shadowRoot?.contains(node) ?? false);
579
+ * },
580
+ * onOutsideClick: () => {
581
+ * if (this._adapter) {
582
+ * this._adapter.send(DatePickerEvent.OUTSIDE_CLICK);
583
+ * }
584
+ * },
585
+ * useCapture: true,
586
+ * attachDelay: 0,
587
+ * });
588
+ *
589
+ * this._clickOutsideHandler.attach();
590
+ * }
591
+ *
592
+ * disconnectedCallback() {
593
+ * super.disconnectedCallback();
594
+ * this._clickOutsideHandler?.detach();
595
+ * this._clickOutsideHandler = null;
596
+ * }
597
+ *
598
+ * updated(changedProperties: PropertyValues) {
599
+ * super.updated(changedProperties);
600
+ *
601
+ * if (changedProperties.has('open')) {
602
+ * this._clickOutsideHandler?.updateConfig({ isOpen: this.open });
603
+ * }
604
+ * }
605
+ * ```
606
+ */
607
+ declare class ClickOutsideHandler {
608
+ private handler;
609
+ private timeoutId;
610
+ private config;
611
+ /**
612
+ * Creates a new ClickOutsideHandler instance
613
+ *
614
+ * @param {ClickOutsideConfig} config - Configuration for the click outside handler
615
+ */
616
+ constructor(config: ClickOutsideConfig);
617
+ /**
618
+ * The actual click handler that checks if click is outside
619
+ *
620
+ * @param {MouseEvent} event - The mouse event
621
+ */
622
+ private handleClick;
623
+ /**
624
+ * Attach the click outside listener
625
+ *
626
+ * This method adds the click event listener to the document.
627
+ * If attachDelay is configured, it will delay the attachment to prevent
628
+ * the opening click from immediately triggering a close.
629
+ *
630
+ * Calling attach() multiple times is safe - it will only attach once.
631
+ */
632
+ attach(): void;
633
+ /**
634
+ * Detach the click outside listener
635
+ *
636
+ * This method removes the click event listener and cleans up any pending timeouts.
637
+ * It's safe to call detach() multiple times or even if attach() was never called.
638
+ *
639
+ * Always call detach() when the component unmounts or when you no longer need
640
+ * click outside detection to prevent memory leaks.
641
+ */
642
+ detach(): void;
643
+ /**
644
+ * Update configuration
645
+ *
646
+ * This is useful in React when dependencies change, or in Web Components
647
+ * when properties update. You can update any part of the configuration
648
+ * without needing to detach and reattach the handler.
649
+ *
650
+ * @param {Partial<ClickOutsideConfig>} config - Partial configuration to update
651
+ *
652
+ * @example
653
+ * ```typescript
654
+ * // Update just the isOpen state
655
+ * handler.updateConfig({ isOpen: true });
656
+ *
657
+ * // Update multiple properties
658
+ * handler.updateConfig({
659
+ * isOpen: true,
660
+ * onOutsideClick: newCallback
661
+ * });
662
+ * ```
663
+ */
664
+ updateConfig(config: Partial<ClickOutsideConfig>): void;
665
+ /**
666
+ * Check if the handler is currently attached
667
+ *
668
+ * @returns true if the handler is attached, false otherwise
669
+ */
670
+ isAttached(): boolean;
671
+ /**
672
+ * Check if there's a pending attachment
673
+ *
674
+ * @returns true if attachment is pending (waiting for delay), false otherwise
675
+ */
676
+ isPending(): boolean;
677
+ }
678
+ //#endregion
679
+ //#region src/date-picker/primitives/keyboard-utils.d.ts
680
+ /**
681
+ * Information needed to map a keyboard event to a state machine event
682
+ */
683
+ interface KeyboardEventInfo {
684
+ /** The keyboard key that was pressed */
685
+ key: string;
686
+ /** Whether the shift key was held */
687
+ shiftKey: boolean;
688
+ /** The current date picker mode */
689
+ mode: DatePickerMode;
690
+ /** The current state machine state */
691
+ state: DatePickerState;
692
+ /** The currently focused date in the calendar */
693
+ focusedDate: Temporal.PlainDate | null;
694
+ }
695
+ /**
696
+ * Result of mapping a keyboard event to a state machine event
697
+ */
698
+ interface KeyboardEventResult {
699
+ /** The state machine event type to dispatch, or null if key not handled */
700
+ eventType: string | null;
701
+ /** Optional payload for the event */
702
+ payload?: {
703
+ date: Temporal.PlainDate;
704
+ };
705
+ /** Whether to call preventDefault on the keyboard event */
706
+ preventDefault: boolean;
707
+ }
708
+ /**
709
+ * Map a keyboard event to a state machine event
710
+ * This provides a single source of truth for keyboard shortcuts across React and Web Components
711
+ *
712
+ * @param {KeyboardEventInfo} info - Information about the keyboard event and current state
713
+ * @returns {KeyboardEventResult | null} The state machine event to dispatch, or null if key not handled
714
+ */
715
+ declare function mapKeyboardToStateMachineEvent(info: KeyboardEventInfo): KeyboardEventResult | null;
716
+ //#endregion
717
+ //#region src/date-picker/primitives/calendar-grid.d.ts
718
+ /**
719
+ * Copyright IBM Corp. 2026
720
+ *
721
+ * This source code is licensed under the Apache-2.0 license found in the
722
+ * LICENSE file in the root directory of this source tree.
723
+ */
724
+ /**
725
+ * A single day cell in the calendar grid.
726
+ */
727
+ interface CalendarDay {
728
+ date: Temporal.PlainDate;
729
+ isCurrentMonth: boolean;
730
+ isDisabled: boolean;
731
+ isToday: boolean;
732
+ }
733
+ /**
734
+ * Generate the calendar grid for the month containing `viewDate`.
735
+ *
736
+ *
737
+ * @param {Temporal.PlainDate} viewDate - The date to generate calendar for
738
+ * @param {Temporal.PlainDate | null} minDate - Minimum selectable date (inclusive), or `null` for no lower bound.
739
+ * @param {Temporal.PlainDate | null} maxDate - Maximum selectable date (inclusive), or `null` for no upper bound.
740
+ * @param {number} weekStartsOn - First day of the week: 0 = Sunday (default) through 6 = Saturday.
741
+ * @returns {CalendarDay[][]} 6×7 grid of day cells (weeks × days).
742
+ */
743
+ declare function generateCalendarGrid(viewDate: Temporal.PlainDate, minDate?: Temporal.PlainDate | null, maxDate?: Temporal.PlainDate | null, weekStartsOn?: number): CalendarDay[][];
744
+ //#endregion
745
+ //#region src/date-picker/primitives/calendar-labels.d.ts
746
+ /**
747
+ * Copyright IBM Corp. 2026
748
+ *
749
+ * This source code is licensed under the Apache-2.0 license found in the
750
+ * LICENSE file in the root directory of this source tree.
751
+ */
752
+ /**
753
+ * Get the month-and-year heading for the calendar (e.g. "January 2026").
754
+ *
755
+ * @param {Temporal.PlainDate} viewDate - Any date within the displayed month.
756
+ * @param {string} locale - BCP 47 locale tag (default 'en').
757
+ * @returns {string} Localized "month year" label.
758
+ */
759
+ declare function getMonthYearLabel(viewDate: Temporal.PlainDate, locale?: string): string;
760
+ /**
761
+ * Get a full, localized label for a single date (e.g. "January 1, 2026"),
762
+ * suitable for a day cell's `aria-label`.
763
+ *
764
+ * @param {Temporal.PlainDate} date - The date to label.
765
+ * @param {string} locale - BCP 47 locale tag (default 'en').
766
+ * @returns {string} Localized full-date label.
767
+ */
768
+ declare function getFullDateLabel(date: Temporal.PlainDate, locale?: string): string;
769
+ /**
770
+ * Get the ordered weekday header labels.
771
+ *
772
+ * For English locales this returns `S M T W Th F S`,
773
+ * with `Th` disambiguating Thursday from Tuesday). Other
774
+ * locales get their `Intl` short weekday names unchanged.
775
+ *
776
+ * @param {string} locale - BCP 47 locale tag (default 'en').
777
+ * @param {number} weekStartsOn - First day of the week: 0 = Sunday (default) through 6 = Saturday.
778
+ * @returns {string[]} Seven weekday labels, ordered from `weekStartsOn`.
779
+ */
780
+ declare function getWeekdayLabels(locale?: string, weekStartsOn?: number): string[];
781
+ //#endregion
782
+ //#region src/date-picker/primitives/temporal-utils.d.ts
783
+ /**
784
+ * Copyright IBM Corp. 2026
785
+ *
786
+ * This source code is licensed under the Apache-2.0 license found in the
787
+ * LICENSE file in the root directory of this source tree.
788
+ */
789
+ /**
790
+ * Temporal API utilities for date picker
791
+ * Uses the modern Temporal API for robust date handling
792
+ */
793
+ /**
794
+ * Convert a Date object to Temporal.PlainDate
795
+ *
796
+ * @param {Date} date - JavaScript Date object
797
+ * @returns Temporal.PlainDate
798
+ */
799
+ declare function dateToPlainDate(date: Date): Temporal.PlainDate;
800
+ /**
801
+ * Convert Temporal.PlainDate to Date object
802
+ *
803
+ * @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
804
+ * @returns JavaScript Date object
805
+ */
806
+ declare function plainDateToDate(plainDate: Temporal.PlainDate): Date;
807
+ /**
808
+ * Convert Temporal.PlainDate to ISO date string (YYYY-MM-DD)
809
+ *
810
+ * @param {Temporal.PlainDate} plainDate - Temporal.PlainDate
811
+ * @returns ISO date string
812
+ */
813
+ declare function plainDateToISOString(plainDate: Temporal.PlainDate): string;
814
+ /**
815
+ * Parse ISO date string to Temporal.PlainDate
816
+ *
817
+ * @param {string} isoString - ISO date string (YYYY-MM-DD)
818
+ * @returns Temporal.PlainDate or null if invalid
819
+ */
820
+ declare function parseISOToPlainDate(isoString: string): Temporal.PlainDate | null;
821
+ /**
822
+ * Parse a date string in various formats to Temporal.PlainDate
823
+ * Supports: ISO (YYYY-MM-DD), US (MM/DD/YYYY), and JavaScript Date objects
824
+ *
825
+ * @param {string | Date} dateInput - Date string or Date object
826
+ * @returns Temporal.PlainDate or null if invalid
827
+ */
828
+ declare function parseDateToPlainDate(dateInput: string | Date | null | undefined): Temporal.PlainDate | null;
829
+ /**
830
+ * Compare two Temporal.PlainDate objects
831
+ *
832
+ * @param {Temporal.PlainDate} date1 - First date
833
+ * @param {Temporal.PlainDate} date2 - Second date
834
+ * @returns -1 if date1 < date2, 0 if equal, 1 if date1 > date2
835
+ */
836
+ declare function comparePlainDates(date1: Temporal.PlainDate, date2: Temporal.PlainDate): number;
837
+ /**
838
+ * Check if a date is within a range
839
+ *
840
+ * @param {Temporal.PlainDate} date - Date to check
841
+ * @param {Temporal.PlainDate | null} minDate - Minimum date (inclusive)
842
+ * @param {Temporal.PlainDate | null} maxDate - Maximum date (inclusive)
843
+ * @returns True if date is within range
844
+ */
845
+ declare function isDateInRange(date: Temporal.PlainDate, minDate: Temporal.PlainDate | null, maxDate: Temporal.PlainDate | null): boolean;
846
+ /**
847
+ * Format a Temporal.PlainDate according to a format string
848
+ * Supports Flatpickr-compatible format tokens:
849
+ * - Y: 4-digit year (e.g., 2026)
850
+ * - y: 2-digit year (e.g., 26)
851
+ * - m: 2-digit month with leading zero (01-12)
852
+ * - n: month without leading zero (1-12)
853
+ * - d: 2-digit day with leading zero (01-31)
854
+ * - j: day without leading zero (1-31)
855
+ *
856
+ * @param {Temporal.PlainDate} date - Date to format
857
+ * @param {string} format - Format string (e.g., 'd/m/Y', 'm/d/Y', 'Y-m-d')
858
+ * @returns Formatted date string
859
+ */
860
+ declare function formatPlainDate(date: Temporal.PlainDate, format: string): string;
861
+ /**
862
+ * Get today's date as Temporal.PlainDate
863
+ *
864
+ * @returns Today's date
865
+ */
866
+ declare function getToday(): Temporal.PlainDate;
867
+ /**
868
+ * Add days to a date
869
+ *
870
+ * @param {Temporal.PlainDate} date - Starting date
871
+ * @param {number} days - Number of days to add (can be negative)
872
+ * @returns New date
873
+ */
874
+ declare function addDays(date: Temporal.PlainDate, days: number): Temporal.PlainDate;
875
+ /**
876
+ * Add months to a date
877
+ *
878
+ * @param {Temporal.PlainDate} date - Starting date
879
+ * @param {number} months - Number of months to add (can be negative)
880
+ * @returns New date
881
+ */
882
+ declare function addMonths(date: Temporal.PlainDate, months: number): Temporal.PlainDate;
883
+ /**
884
+ * Get the number of days between two dates
885
+ *
886
+ * @param {Temporal.PlainDate} date1 - First date
887
+ * @param {Temporal.PlainDate} date2 - Second date
888
+ * @returns Number of days (positive if date2 is after date1)
889
+ */
890
+ declare function daysBetween(date1: Temporal.PlainDate, date2: Temporal.PlainDate): number;
891
+ /**
892
+ * Check if two dates are equal
893
+ *
894
+ * @param {Temporal.PlainDate} date1 - First date
895
+ * @param {Temporal.PlainDate} date2 - Second date
896
+ * @returns True if dates are equal
897
+ */
898
+ declare function areDatesEqual(date1: Temporal.PlainDate | null, date2: Temporal.PlainDate | null): boolean;
899
+ /**
900
+ * Get the start of the month for a given date
901
+ *
902
+ * @param {Temporal.PlainDate} date - Input date
903
+ * @returns First day of the month
904
+ */
905
+ declare function getMonthStart(date: Temporal.PlainDate): Temporal.PlainDate;
906
+ /**
907
+ * Get the end of the month for a given date
908
+ *
909
+ * @param {Temporal.PlainDate} date - Input date
910
+ * @returns Last day of the month
911
+ */
912
+ declare function getMonthEnd(date: Temporal.PlainDate): Temporal.PlainDate;
913
+ /**
914
+ * Check if a date is today
915
+ *
916
+ * @param {Temporal.PlainDate} date - Date to check
917
+ * @returns True if date is today
918
+ */
919
+ declare function isToday(date: Temporal.PlainDate): boolean;
920
+ /**
921
+ * Check if a date is in the past
922
+ *
923
+ * @param {Temporal.PlainDate} date - Date to check
924
+ * @returns True if date is before today
925
+ */
926
+ declare function isPast(date: Temporal.PlainDate): boolean;
927
+ /**
928
+ * Check if a date is in the future
929
+ *
930
+ * @param {Temporal.PlainDate} date - Date to check
931
+ * @returns True if date is after today
932
+ */
933
+ declare function isFuture(date: Temporal.PlainDate): boolean;
934
+ /**
935
+ * Parse a date string with a specific format
936
+ * Supports common format tokens: Y, m, d
937
+ *
938
+ * @param {string} dateString - Date string to parse
939
+ * @param {string} format - Format string (e.g., 'm/d/Y', 'Y-m-d')
940
+ * @returns Temporal.PlainDate or null if invalid
941
+ */
942
+ declare function parseDateString(dateString: string, format: string): Temporal.PlainDate | null;
943
+ /**
944
+ * Polyfill check for Temporal API
945
+ *
946
+ * @returns True if Temporal API is available
947
+ */
948
+ declare function isTemporalAvailable(): boolean;
949
+ /**
950
+ * Get a fallback date handler if Temporal is not available
951
+ * This provides a migration path for browsers without Temporal support
952
+ */
953
+ declare function getDateHandler(): {
954
+ type: "temporal";
955
+ toISOString: typeof plainDateToISOString;
956
+ fromISOString: typeof parseISOToPlainDate;
957
+ compare: typeof comparePlainDates;
958
+ format: typeof formatPlainDate;
959
+ isInRange: typeof isDateInRange;
960
+ } | {
961
+ type: "date";
962
+ /**
963
+ *
964
+ * @param {Temporal.PlainDate} date - The date to convert
965
+ */
966
+ toISOString: (date: Date) => string;
967
+ /**
968
+ *
969
+ * @param {string} str - The ISO string to parse
970
+ */
971
+ fromISOString: (str: string) => Date | null;
972
+ /**
973
+ *
974
+ * @param {Temporal.PlainDate} d1 - First date
975
+ * @param {Temporal.PlainDate} d2 - Second date
976
+ */
977
+ compare: (d1: Date, d2: Date) => number;
978
+ /**
979
+ *
980
+ * @param {Temporal.PlainDate} date - The date to format
981
+ * @param {string} format - The format string
982
+ */
983
+ format: (date: Date, format: string) => string;
984
+ /**
985
+ *
986
+ * @param {Temporal.PlainDate} date - The date to check
987
+ * @param {Temporal.PlainDate | null} min - Minimum date
988
+ * @param {Temporal.PlainDate | null} max - Maximum date
989
+ */
990
+ isInRange: (date: Date, min: Date | null, max: Date | null) => boolean;
991
+ };
992
+ //#endregion
993
+ export { type CalendarDay, type ClickOutsideConfig, ClickOutsideHandler, type DatePickerContext, DatePickerEvent, type DatePickerEvent$1 as DatePickerEventType, type DatePickerMode, DatePickerState, DatePickerStateMachine, type DateSelectPayload, type FocusRestoreTarget, type InputFocusPayload, type InputType, type KeyboardEventInfo, type KeyboardEventResult, type KeyboardPayload, type SideEffect, type StateAction, type StateConfig, type StateGuard, type StateTransition, type TransitionListener, type TransitionMap, type ValidationErrorPayload, type ValueChangePayload, actions, addDays, addMonths, areDatesEqual, checkGuard, comparePlainDates, dateToPlainDate, daysBetween, effects, executeAction, executeEffect, formatPlainDate, generateCalendarGrid, getAction, getDateHandler, getEffect, getFullDateLabel, getGuard, getMonthEnd, getMonthStart, getMonthYearLabel, getToday, getWeekdayLabels, guards, isDateInRange, isFuture, isPast, isSingleMode, isTemporalAvailable, isToday, mapKeyboardToStateMachineEvent, parseDateString, parseDateToPlainDate, parseISOToPlainDate, plainDateToDate, plainDateToISOString };