@astryxdesign/core 0.5.0-canary.c47e754 → 0.5.0-canary.e6dc4bd

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.
@@ -31,6 +31,16 @@ export type DateInputSize = keyof typeof sizeStyles;
31
31
  * types stay in compile-time lockstep: renaming or removing one of these
32
32
  * members from `TimestampFormat` breaks this type at build time.
33
33
  */
34
+ /**
35
+ * When DateInput hands date picking to the browser/OS instead of its own
36
+ * surfaces.
37
+ *
38
+ * - `'touch'`: native on touch devices (coarse pointer), Astryx's calendar
39
+ * popover on mouse-driven ones
40
+ * - `'always'`: native wherever the browser supports `<input type="date">`
41
+ * - `'never'`: Astryx's own pickers everywhere
42
+ */
43
+ export type DateInputNativePicker = 'touch' | 'always' | 'never';
34
44
  export type DateInputFormat = Extract<TimestampFormat, 'date' | 'date_long' | 'date_weekday' | 'system_date'>;
35
45
  export type { InputStatus as DateInputStatus, InputStatusType as DateInputStatusType, } from '../Field';
36
46
  import type { BaseProps } from '../BaseProps';
@@ -202,6 +212,39 @@ export interface DateInputProps extends Omit<BaseProps, 'onChange' | 'defaultVal
202
212
  * ```
203
213
  */
204
214
  format?: DateInputFormat | ((value: ISODateString) => string);
215
+ /**
216
+ * When date picking is handed to the browser/OS instead of Astryx's own
217
+ * surfaces: the field becomes an `<input type="date">` and the platform
218
+ * draws the picker — the iOS wheel, the Android calendar dialog — with the
219
+ * OS's own hit areas, momentum scrolling, locale and accessibility
220
+ * settings.
221
+ *
222
+ * - `'touch'` (default): native on touch devices (coarse pointer), the text
223
+ * field and calendar popover on mouse-driven ones
224
+ * - `'always'`: native wherever the browser supports `<input type="date">`
225
+ * - `'never'`: Astryx's own pickers everywhere — the touch picker on a
226
+ * finger, the calendar popover on a mouse
227
+ *
228
+ * `format` and `placeholder` still apply in native mode: DateInput paints
229
+ * the closed field's text itself, over the control. `numberOfMonths` and
230
+ * `weekStartsOn` do not — they describe a calendar grid the native picker
231
+ * does not have — so a field that needs either should pass `'never'`.
232
+ *
233
+ * `min` and `max` are forwarded, but note that a native picker may not
234
+ * *show* them: on iOS they are constraint-validation flags rather than
235
+ * clamps, so an out-of-range date can be selected and is refused on commit
236
+ * (announced to assistive technology) rather than being greyed out in the
237
+ * picker. `dateConstraints` is enforced the same way, on commit, and is
238
+ * reason enough to prefer `'never'` on a field that uses it.
239
+ *
240
+ * @default 'touch'
241
+ * @example
242
+ * ```
243
+ * // Astryx's own touch picker instead of the platform's
244
+ * <DateInput label="Event date" value={date} onChange={setDate} nativePicker="never" />
245
+ * ```
246
+ */
247
+ nativePicker?: DateInputNativePicker;
205
248
  }
206
249
  /**
207
250
  * A date picker that fits the pointer it is being used with.
@@ -1 +1 @@
1
- {"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/DateInput/DateInput.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAS3C,OAAO,EAGL,KAAK,WAAW,EAKhB,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAcrB,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAiDlD,QAAA,MAAM,UAAU;;;;;;;;;;;;;EAad,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,UAAU,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CACnC,eAAe,EACf,MAAM,GAAG,WAAW,GAAG,cAAc,GAAG,aAAa,CACtD,CAAC;AAIF,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,eAAe,IAAI,mBAAmB,GACvC,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,C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CAAC,CAAC;IAEzD;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAEnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,CAAC,CAAC;IAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC;AAmeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,+BAc9C;yBAde,SAAS"}
@@ -32,6 +32,7 @@ import { useInputStatusIcon } from "../hooks/useInputStatusIcon.js";
32
32
  import { useMediaQuery } from "../hooks/useMediaQuery.js";
33
33
  import { useResolvedRequired } from "../hooks/useResolvedRequired.js";
34
34
  import { usePopover } from "../Popover/index.js";
35
+ import { NativeDateField } from "./NativeDateField.js";
35
36
  import { TouchDateField } from "./TouchDateField.js";
36
37
  import { useTooltip } from "../Tooltip/index.js";
37
38
  import { getInputARIA, isImeKeyEvent, parseDateInput } from "../utils/index.js";
@@ -87,6 +88,15 @@ const sizeStyles = {
87
88
  * types stay in compile-time lockstep: renaming or removing one of these
88
89
  * members from `TimestampFormat` breaks this type at build time.
89
90
  */
91
+ /**
92
+ * When DateInput hands date picking to the browser/OS instead of its own
93
+ * surfaces.
94
+ *
95
+ * - `'touch'`: native on touch devices (coarse pointer), Astryx's calendar
96
+ * popover on mouse-driven ones
97
+ * - `'always'`: native wherever the browser supports `<input type="date">`
98
+ * - `'never'`: Astryx's own pickers everywhere
99
+ */
90
100
 
91
101
  // Re-export shared types for convenience
92
102
 
@@ -560,6 +570,15 @@ PointerDateField.displayName = 'PointerDateField';
560
570
  */
561
571
  export function DateInput(props) {
562
572
  const isTouch = useMediaQuery(TOUCH_POINTER_QUERY);
573
+ const nativePicker = props.nativePicker ?? 'touch';
574
+
575
+ // The platform's picker, where the consumer asked for it — see the
576
+ // `nativePicker` prop for what that trades away.
577
+ if (nativePicker === 'always' || nativePicker === 'touch' && isTouch) {
578
+ return /*#__PURE__*/_jsx(NativeDateField, {
579
+ ...props
580
+ });
581
+ }
563
582
  return isTouch ? /*#__PURE__*/_jsx(TouchDateField, {
564
583
  ...props
565
584
  }) : /*#__PURE__*/_jsx(PointerDateField, {
@@ -0,0 +1,10 @@
1
+ import type { DateInputProps } from './DateInput';
2
+ /**
3
+ * The OS-picker surface. Takes `DateInput`'s props verbatim; see
4
+ * {@link DateInput} for when it is chosen over the other two.
5
+ */
6
+ export declare function NativeDateField({ label, isLabelHidden, description, isOptional, isRequired, isDisabled, disabledMessage, value, onChange, isLoading, min, max, dateConstraints, placeholder: placeholderFromProps, size: sizeProp, status, statusVariant, labelTooltip, hasClear, numberOfMonths: _numberOfMonths, weekStartsOn: _weekStartsOn, format, width, xstyle, className, style, ref, ...rest }: DateInputProps): import("react").JSX.Element;
7
+ export declare namespace NativeDateField {
8
+ var displayName: string;
9
+ }
10
+ //# sourceMappingURL=NativeDateField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeDateField.d.ts","sourceRoot":"","sources":["../../src/DateInput/NativeDateField.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAwLhD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,SAAiB,EACjB,GAAG,EACH,GAAG,EACH,eAAe,EACf,WAAW,EAAE,oBAAoB,EACjC,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,aAA0B,EAC1B,YAAY,EACZ,QAAgB,EAGhB,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,aAAa,EAC3B,MAAoB,EACpB,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,cAAc,+BAmXhB;yBAlZe,eAAe"}
@@ -0,0 +1,477 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file NativeDateField.tsx
7
+ * @input Uses React, Field, Icon, InputClearButton, Spinner, useCalendarConstraints
8
+ * @output Exports NativeDateField — the OS-picker touch surface
9
+ * @position One of DateInput's three surfaces. `DateInput` picks the pointer
10
+ * field on a mouse and, on touch, either `TouchDateField` (the default) or
11
+ * this one when the consumer opts in with `nativePicker`.
12
+ *
13
+ * Hands date picking to the platform: a real `<input type="date">`, whose
14
+ * picker the OS draws — the iOS wheel, the Android calendar dialog. The field
15
+ * itself still looks like every other Astryx input, and DateInput paints its
16
+ * text so `format` and `placeholder` keep applying.
17
+ *
18
+ * Everything unusual in here was measured on a real iOS device; the comments
19
+ * say which behaviour forced which decision, because none of them are
20
+ * reproducible in a desktop browser.
21
+ *
22
+ * SYNC: When modified, update these files to stay in sync:
23
+ * - /packages/core/src/DateInput/DateInput.tsx (the `nativePicker` prop)
24
+ * - /packages/core/src/DateInput/DateInput.doc.mjs (prop table)
25
+ * - /packages/core/src/DateInput/DateInputNative.test.tsx (tests)
26
+ */
27
+ import { useCallback, useEffect, useId, useRef, useState } from 'react';
28
+ import * as stylex from '@stylexjs/stylex';
29
+ import { useCalendarConstraints } from "../Calendar/index.js";
30
+ import { Field, InputClearButton, inputStatusBorderStyles, inputStatusFocusWithinStyles, inputStatusHoverShadowStyles, inputWrapperStyles } from "../Field/index.js";
31
+ import { useInputStatusIcon, useMergedRefs } from "../hooks/index.js";
32
+ import { useResolvedRequired } from "../hooks/useResolvedRequired.js";
33
+ import { Icon } from "../Icon/index.js";
34
+ import { useLocale, useTranslator } from "../i18n/index.js";
35
+ import { useInputGroup } from "../InputGroup/index.js";
36
+ import { groupStyles } from "../InputGroup/groupStyles.js";
37
+ import { stableClassName } from "../naming.js";
38
+ import { useSize } from "../SizeContext/index.js";
39
+ import { Spinner } from "../Spinner/index.js";
40
+ import "../theme/tokens.stylex.js";
41
+ import { colorVars, radiusVars, sizeVars, typeScaleVars, typographyVars } from "../theme/tokens.stylex.js";
42
+ import { useTooltip } from "../Tooltip/index.js";
43
+ import { VisuallyHidden } from "../VisuallyHidden/index.js";
44
+ import { focusOutlineStyles, formatSharedDate, getInputARIA, mergeProps, parseDateInput, plainDateFromISO, plainDateToISO, themeProps } from "../utils/index.js";
45
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
46
+ const styles = {
47
+ wrapper: {
48
+ kOIVth: "x167g77z",
49
+ $$css: true
50
+ },
51
+ iconButton: {
52
+ k1xSpc: "x78zum5",
53
+ kGNEyG: "x6s0dn4",
54
+ kjj79g: "xl56j7k",
55
+ kmVPX3: "x1717udv",
56
+ kogj98: "x1ghz6dp",
57
+ kMzoRj: "xc342km",
58
+ ksu8eU: "xng3xce",
59
+ kWkggS: "xjbqb8w",
60
+ kkrTdU: "x1ypdohk x16khyan",
61
+ kaIpWk: "xh6dtrn",
62
+ $$css: true
63
+ },
64
+ iconButtonDisabled: {
65
+ kkrTdU: "xt0e3qv",
66
+ $$css: true
67
+ }
68
+ };
69
+ const sizeStyles = {
70
+ sm: {
71
+ kZKoxP: "x6k0iem",
72
+ k7Eaqz: "xfb3i0g",
73
+ $$css: true
74
+ },
75
+ md: {
76
+ kZKoxP: "x1ueg155",
77
+ k7Eaqz: "xfb3i0g",
78
+ $$css: true
79
+ },
80
+ lg: {
81
+ kZKoxP: "xssyfek",
82
+ k7Eaqz: "xfb3i0g",
83
+ $$css: true
84
+ }
85
+ };
86
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
87
+
88
+ /**
89
+ * The OS-picker surface. Takes `DateInput`'s props verbatim; see
90
+ * {@link DateInput} for when it is chosen over the other two.
91
+ */
92
+ export function NativeDateField({
93
+ label,
94
+ isLabelHidden = false,
95
+ description,
96
+ isOptional = false,
97
+ isRequired = false,
98
+ isDisabled = false,
99
+ disabledMessage,
100
+ value,
101
+ onChange,
102
+ isLoading = false,
103
+ min,
104
+ max,
105
+ dateConstraints,
106
+ placeholder: placeholderFromProps,
107
+ size: sizeProp,
108
+ status,
109
+ statusVariant = 'attached',
110
+ labelTooltip,
111
+ hasClear = false,
112
+ // The OS draws the picker, so neither reaches it: both describe a calendar
113
+ // grid it does not have. Accepted (the prop types are shared) and ignored.
114
+ numberOfMonths: _numberOfMonths,
115
+ weekStartsOn: _weekStartsOn,
116
+ format = 'date_long',
117
+ width,
118
+ xstyle,
119
+ className,
120
+ style,
121
+ ref,
122
+ ...rest
123
+ }) {
124
+ const t = useTranslator();
125
+ const locale = useLocale();
126
+ const isEffectivelyRequired = useResolvedRequired({
127
+ isRequired,
128
+ isOptional
129
+ });
130
+ const placeholder = placeholderFromProps ?? t('@astryx.dateInput.placeholder');
131
+ const size = useSize(sizeProp, 'md');
132
+ const id = useId();
133
+ const inputLabelID = useId();
134
+ const descriptionID = useId();
135
+ const statusMessageID = useId();
136
+ const inputRef = useRef(null);
137
+ const mergedInputRef = useMergedRefs(ref, inputRef);
138
+ const inputGroup = useInputGroup();
139
+ const isEffectivelyDisabled = isDisabled || isLoading;
140
+
141
+ // Disabled-reason tooltip, same contract as the other two surfaces: a
142
+ // disabled control swallows pointer events, so the listeners attach to the
143
+ // wrapper and the input stays focusable via aria-disabled.
144
+ const showsDisabledMessage = isDisabled && !!disabledMessage;
145
+ const disabledMessageTooltip = useTooltip({
146
+ placement: 'above',
147
+ focusTrigger: 'always',
148
+ isEnabled: showsDisabledMessage
149
+ });
150
+ const {
151
+ isDateDisabled
152
+ } = useCalendarConstraints({
153
+ min,
154
+ max,
155
+ dateConstraints
156
+ });
157
+ const {
158
+ statusIcon,
159
+ describedBy: statusTooltipDescribedBy
160
+ } = useInputStatusIcon({
161
+ status,
162
+ statusVariant,
163
+ isInGroup: !!inputGroup
164
+ });
165
+ const {
166
+ ariaLabelledBy,
167
+ ariaDescribedBy
168
+ } = getInputARIA(inputLabelID, [description ? descriptionID : null, statusVariant !== 'tooltip' && status?.message ? statusMessageID : null, statusTooltipDescribedBy, showsDisabledMessage ? disabledMessageTooltip.describedBy : null], inputGroup);
169
+
170
+ // A date the picker produced that `dateConstraints` refuses, held so the
171
+ // refusal can be announced instead of looking like a dead tap.
172
+ const [rejectedValue, setRejectedValue] = useState(null);
173
+ // Whether the control has focus — which, on a touch device, means its
174
+ // picker is open.
175
+ const [isFocused, setIsFocused] = useState(false);
176
+ // The raw value the control last reported and we acted on, so the same edit
177
+ // arriving through both commit paths only fires one change.
178
+ const lastCommitRef = useRef(null);
179
+ const prevValueRef = useRef(value);
180
+ if (value !== prevValueRef.current) {
181
+ prevValueRef.current = value;
182
+ lastCommitRef.current = null;
183
+ if (rejectedValue !== null) {
184
+ setRejectedValue(null);
185
+ }
186
+ }
187
+
188
+ // The control's own value is always ISO — the only form it accepts, and
189
+ // what the picker reads and writes. `format` rides on the overlay instead.
190
+ const nativeValue = value && ISO_DATE.test(value) ? value : '';
191
+ const isInputValid = rejectedValue === null;
192
+ const formatValue = useCallback(iso => typeof format === 'function' ? format(iso) : formatSharedDate(plainDateFromISO(iso), format, locale), [format, locale]);
193
+
194
+ // This field paints the closed control's text itself, which is what keeps
195
+ // `format` and `placeholder` applying: the OS picker has no segments to
196
+ // edit, so our text holds even while the picker is open, and tracks it live.
197
+ const overlayText = nativeValue ? formatValue(nativeValue) : placeholder;
198
+ const showsOverlay = !!overlayText;
199
+ const commitValue = useCallback(newValue => {
200
+ if (isEffectivelyDisabled) {
201
+ return;
202
+ }
203
+ // The same edit can arrive twice — React's synthetic change and the
204
+ // native listener below both report it — so act on a raw value once.
205
+ if (lastCommitRef.current === newValue) {
206
+ return;
207
+ }
208
+ lastCommitRef.current = newValue;
209
+ if (!newValue) {
210
+ setRejectedValue(null);
211
+ if (value !== undefined) {
212
+ onChange?.(undefined);
213
+ }
214
+ return;
215
+ }
216
+ const parsed = parseDateInput(newValue, locale);
217
+ if (!parsed) {
218
+ return;
219
+ }
220
+ if (isDateDisabled(parsed)) {
221
+ // iOS does not enforce min/max in its picker — those attributes are
222
+ // constraint-validation flags, not clamps, and the sheet lets the
223
+ // user land on any date. Refuse it here and let the sync effect snap
224
+ // the control back; the live region below announces the refusal.
225
+ setRejectedValue(newValue);
226
+ return;
227
+ }
228
+ setRejectedValue(null);
229
+ const parsedISO = plainDateToISO(parsed);
230
+ if (parsedISO !== value) {
231
+ onChange?.(parsedISO);
232
+ }
233
+ }, [value, onChange, isDateDisabled, isEffectivelyDisabled, locale]);
234
+ const handleChange = useCallback(e => {
235
+ commitValue(e.target.value);
236
+ }, [commitValue]);
237
+
238
+ // React's synthetic change system does not reliably observe the iOS
239
+ // picker's edits. Measured on an iPhone: picking a date fired a native
240
+ // `input` event carrying the new date while React's `onChange` never ran —
241
+ // so React re-rendered and wrote its own stale value straight back over the
242
+ // picker's, and the user's pick (and their Reset) silently reverted. A
243
+ // native listener reads what the control actually holds, whatever React's
244
+ // synthetic layer made of it.
245
+ const commitRef = useRef(commitValue);
246
+ useEffect(() => {
247
+ commitRef.current = commitValue;
248
+ });
249
+ useEffect(() => {
250
+ const input = inputRef.current;
251
+ if (!input) {
252
+ return;
253
+ }
254
+ const handleNative = () => commitRef.current(input.value);
255
+ input.addEventListener('input', handleNative);
256
+ input.addEventListener('change', handleNative);
257
+ return () => {
258
+ input.removeEventListener('input', handleNative);
259
+ input.removeEventListener('change', handleNative);
260
+ };
261
+ }, []);
262
+
263
+ // The value the control mounts with. Deliberately captured once: React
264
+ // writes to the element whenever a `value` OR `defaultValue` prop changes,
265
+ // and on iOS ANY write while the picker sheet is open detaches the sheet
266
+ // from the field — the wheel and Reset keep moving the sheet's own
267
+ // highlight, but nothing they do reaches the input and no event fires, so
268
+ // the user's pick appears to do nothing. Holding this constant means React
269
+ // touches the element exactly once, at mount; the effect below owns every
270
+ // later update and only writes while the field is unfocused.
271
+ const initialValueRef = useRef(null);
272
+ if (initialValueRef.current === null) {
273
+ initialValueRef.current = nativeValue;
274
+ }
275
+
276
+ // Push an externally-changed value in — but never while the control has
277
+ // focus, for the reason above. Blur flips `isFocused`, so this doubles as
278
+ // the reconcile once the picker closes. (Self-heals a stale
279
+ // `initialValueRef` too, on the commit right after a remount.)
280
+ useEffect(() => {
281
+ if (isFocused) {
282
+ return;
283
+ }
284
+ const input = inputRef.current;
285
+ if (input && input.value !== nativeValue) {
286
+ input.value = nativeValue;
287
+ }
288
+ }, [isFocused, nativeValue]);
289
+ const handleBlur = useCallback(() => {
290
+ const domValue = inputRef.current?.value;
291
+ setIsFocused(false);
292
+ // A refused date is reverted by the sync effect the moment focus leaves,
293
+ // so the field is once again showing a date that IS valid. Keeping the
294
+ // rejection past that point would mark good data invalid, with no way
295
+ // back except changing the field again. The live region announced the
296
+ // refusal while it happened; that is the feedback.
297
+ setRejectedValue(null);
298
+ if (domValue !== undefined && domValue !== nativeValue) {
299
+ commitValue(domValue);
300
+ }
301
+ }, [commitValue, nativeValue]);
302
+
303
+ // Focusing a date control is what raises the OS picker, so the usual
304
+ // focus-restore after a clear would pop the picker the tap just dismissed —
305
+ // and on iOS that reads as the clear having done nothing.
306
+ const handleClear = useCallback(() => {
307
+ onChange?.(undefined);
308
+ }, [onChange]);
309
+ const openPicker = useCallback(() => {
310
+ if (isEffectivelyDisabled) {
311
+ return;
312
+ }
313
+ const input = inputRef.current;
314
+ if (!input) {
315
+ return;
316
+ }
317
+ // Focus first: on touch browsers focusing the control is itself what
318
+ // raises the picker, and iOS implements no `showPicker()` for type=date
319
+ // (WebKit bug 261703), so focus is the whole mechanism there.
320
+ input.focus();
321
+ if (typeof input.showPicker === 'function') {
322
+ try {
323
+ input.showPicker();
324
+ } catch {
325
+ // showPicker throws without transient user activation and inside a
326
+ // cross-origin iframe. The focus above is the fallback.
327
+ }
328
+ }
329
+ }, [isEffectivelyDisabled]);
330
+ const inputWrapper = /*#__PURE__*/_jsxs("div", {
331
+ ref: el => {
332
+ disabledMessageTooltip.ref(el);
333
+ },
334
+ ...rest,
335
+ ...mergeProps(themeProps('date-input', {
336
+ size,
337
+ status: status?.type ?? null,
338
+ disabled: isDisabled ? 'disabled' : null
339
+ }), stylex.props(inputWrapperStyles.base, sizeStyles[size], styles.wrapper, isEffectivelyDisabled && inputWrapperStyles.disabled, status && inputStatusBorderStyles[status.type], status && !isEffectivelyDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], inputGroup && groupStyles.inGroup, xstyle), className, style),
340
+ children: [inputGroup && /*#__PURE__*/_jsx(VisuallyHidden, {
341
+ id: inputLabelID,
342
+ children: label
343
+ }), /*#__PURE__*/_jsx("button", {
344
+ type: "button",
345
+ onClick: openPicker,
346
+ disabled: isEffectivelyDisabled,
347
+ "aria-label": t('@astryx.dateInput.openCalendar'),
348
+ tabIndex: -1,
349
+ ...stylex.props(focusOutlineStyles.focusVisible, styles.iconButton, isEffectivelyDisabled && styles.iconButtonDisabled),
350
+ children: /*#__PURE__*/_jsx(Icon, {
351
+ icon: "calendar",
352
+ size: "sm",
353
+ color: "secondary",
354
+ ...themeProps('date-input-toggle-icon', {
355
+ state: 'collapsed'
356
+ })
357
+ })
358
+ }), /*#__PURE__*/_jsxs("span", {
359
+ ...{
360
+ className: "x1n2onr6 x78zum5 x6s0dn4 x98rzlu xeuugli"
361
+ },
362
+ children: [/*#__PURE__*/_jsx("input", {
363
+ ref: mergedInputRef,
364
+ id: id,
365
+ type: "date"
366
+ // UNCONTROLLED on purpose, with a value React never rewrites after
367
+ // mount — see `initialValueRef` and the sync effect above.
368
+ ,
369
+ defaultValue: initialValueRef.current ?? '',
370
+ onChange: handleChange,
371
+ onFocus: () => setIsFocused(true),
372
+ onBlur: handleBlur,
373
+ min: min,
374
+ max: max,
375
+ disabled: isEffectivelyDisabled && !showsDisabledMessage,
376
+ "aria-disabled": showsDisabledMessage ? 'true' : undefined,
377
+ readOnly: showsDisabledMessage || undefined,
378
+ "aria-labelledby": ariaLabelledBy,
379
+ "aria-describedby": ariaDescribedBy,
380
+ "aria-required": isEffectivelyRequired ? 'true' : undefined,
381
+ "aria-invalid": status?.type === 'error' || !isInputValid ? 'true' : undefined,
382
+ "aria-busy": isLoading || undefined,
383
+ ...{
384
+ 0: {
385
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx x1tgivj0 xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3"
386
+ },
387
+ 4: {
388
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 x19co3pv xg7jpbn"
389
+ },
390
+ 2: {
391
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx x1tgivj0 xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 xt0e3qv"
392
+ },
393
+ 6: {
394
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 x19co3pv xg7jpbn xt0e3qv"
395
+ },
396
+ 1: {
397
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 xv1l7n4"
398
+ },
399
+ 5: {
400
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 xg7jpbn xv1l7n4"
401
+ },
402
+ 3: {
403
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 xt0e3qv xv1l7n4"
404
+ },
405
+ 7: {
406
+ className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 x6pjikd xw6l6zx xjbqb8w x1a2a7pz x1oglpa6 x1lugfcp xjyslct xolhmmf x9rmy9g xpsyfx0 x1qqcexc x1x4c3m6 xkqr7wz x1f74mqm xec4aax xtbxizx xslb4at x15bqym3 xg7jpbn xt0e3qv xv1l7n4"
407
+ }
408
+ }[!!showsOverlay << 2 | !!isEffectivelyDisabled << 1 | !!!isInputValid << 0]
409
+ }), showsOverlay && /*#__PURE__*/_jsx("span", {
410
+ "aria-hidden": "true",
411
+ ...{
412
+ 0: {
413
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv xv1l7n4"
414
+ },
415
+ 4: {
416
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv x1tgivj0"
417
+ },
418
+ 2: {
419
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv xv1l7n4 xt0e3qv"
420
+ },
421
+ 6: {
422
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv x1tgivj0 xt0e3qv"
423
+ },
424
+ 1: {
425
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv xv1l7n4"
426
+ },
427
+ 5: {
428
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv xv1l7n4"
429
+ },
430
+ 3: {
431
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv xt0e3qv xv1l7n4"
432
+ },
433
+ 7: {
434
+ className: "x10l6tqk x1o0tod xtijo5x x10no89f x1lliihq xjm74w1 x6pjikd xw6l6zx x47corl xb3r6kr xuxw1ft xlyipyv xt0e3qv xv1l7n4"
435
+ }
436
+ }[!!nativeValue << 2 | !!isEffectivelyDisabled << 1 | !!(!isInputValid && !!nativeValue) << 0],
437
+ children: overlayText
438
+ })]
439
+ }), /*#__PURE__*/_jsx(VisuallyHidden, {
440
+ as: "div",
441
+ role: "alert",
442
+ "aria-live": "assertive",
443
+ children: !isInputValid ? t('@astryx.dateInput.invalidDate') : ''
444
+ }), hasClear && value !== undefined && !isEffectivelyDisabled && /*#__PURE__*/_jsx(InputClearButton, {
445
+ label: t('@astryx.dateInput.clear', {
446
+ label
447
+ }),
448
+ onClick: handleClear,
449
+ iconClassName: stableClassName('date-input-clear-icon')
450
+ }), isLoading && /*#__PURE__*/_jsx(Spinner, {
451
+ size: "sm"
452
+ }), statusIcon, showsDisabledMessage && disabledMessageTooltip.renderTooltip(disabledMessage)]
453
+ });
454
+ if (inputGroup) {
455
+ return inputWrapper;
456
+ }
457
+ return /*#__PURE__*/_jsx(Field, {
458
+ label: label,
459
+ isLabelHidden: isLabelHidden,
460
+ description: description,
461
+ inputID: id,
462
+ descriptionID: description ? descriptionID : undefined,
463
+ isOptional: isOptional,
464
+ isRequired: isRequired,
465
+ isDisabled: isDisabled,
466
+ status: status ? {
467
+ type: status.type,
468
+ message: status.message,
469
+ messageID: status.message ? statusMessageID : undefined
470
+ } : undefined,
471
+ statusVariant: statusVariant,
472
+ labelTooltip: labelTooltip,
473
+ width: width,
474
+ children: inputWrapper
475
+ });
476
+ }
477
+ NativeDateField.displayName = 'NativeDateField';
@@ -5,5 +5,5 @@
5
5
  * @position Package entry point for DateInput
6
6
  */
7
7
  export { DateInput } from './DateInput';
8
- export type { DateInputProps, DateInputSize, DateInputFormat, DateInputStatus, DateInputStatusType, } from './DateInput';
8
+ export type { DateInputProps, DateInputSize, DateInputFormat, DateInputNativePicker, DateInputStatus, DateInputStatusType, } from './DateInput';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DateInput/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,YAAY,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DateInput/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,YAAY,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxIndicator.d.ts","sourceRoot":"","sources":["../../src/Indicator/CheckboxIndicator.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAwI5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,IAAW,EACX,UAAkB,EAClB,QAAQ,EACR,GAAG,EACH,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,gBAAgB,CAAC,+BAwElC;yBAlFe,iBAAiB"}
1
+ {"version":3,"file":"CheckboxIndicator.d.ts","sourceRoot":"","sources":["../../src/Indicator/CheckboxIndicator.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAwI5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,IAAW,EACX,UAAkB,EAClB,QAAQ,EACR,GAAG,EACH,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,gBAAgB,CAAC,+BA8ElC;yBAxFe,iBAAiB"}
@@ -155,7 +155,9 @@ export function CheckboxIndicator({
155
155
  children: isRenderable(children) ? children : /*#__PURE__*/_jsxs(_Fragment, {
156
156
  children: [/*#__PURE__*/_jsx("svg", {
157
157
  viewBox: "0 0 10 10",
158
- ...stylex.props(styles.checkmark, checkmarkSizeStyles[size], isChecked && styles.checkmarkVisible),
158
+ ...mergeProps(themeProps('checkbox-indicator-check', {
159
+ size
160
+ }), stylex.props(styles.checkmark, checkmarkSizeStyles[size], isChecked && styles.checkmarkVisible)),
159
161
  children: /*#__PURE__*/_jsx("path", {
160
162
  d: "M8.5 2.5L4 7.5L1.5 5",
161
163
  stroke: "currentColor",
@@ -165,7 +167,9 @@ export function CheckboxIndicator({
165
167
  strokeLinejoin: "round"
166
168
  })
167
169
  }), /*#__PURE__*/_jsx("span", {
168
- ...stylex.props(styles.indeterminateMark, indeterminateSizeStyles[size], isIndeterminate && styles.indeterminateMarkVisible)
170
+ ...mergeProps(themeProps('checkbox-indicator-dash', {
171
+ size
172
+ }), stylex.props(styles.indeterminateMark, indeterminateSizeStyles[size], isIndeterminate && styles.indeterminateMarkVisible))
169
173
  })]
170
174
  })
171
175
  });