@astryxdesign/core 0.7.3-canary.316e5ab → 0.7.3-canary.31e06f4
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/DateInput/DateInput.d.ts +4 -4
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +20 -27
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +8 -14
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +10 -14
- package/dist/astryx.css +0 -2
- package/package.json +3 -3
- package/src/DateInput/DateInput.doc.mjs +8 -9
- package/src/DateInput/DateInput.test.tsx +13 -88
- package/src/DateInput/DateInput.tsx +21 -49
- package/src/DateInput/DateInputTouch.test.tsx +1 -22
- package/src/DateInput/NativeDateField.test.tsx +3 -29
- package/src/DateInput/NativeDateField.tsx +7 -20
- package/src/DateInput/TouchDateField.tsx +9 -24
|
@@ -82,13 +82,13 @@ export interface DateInputProps extends Omit<FieldInputBaseProps<HTMLInputElemen
|
|
|
82
82
|
isDisabled?: boolean;
|
|
83
83
|
/**
|
|
84
84
|
* Explains why the input is disabled. When set together with
|
|
85
|
-
* `isDisabled`, the
|
|
86
|
-
* keyboard focus, and the field
|
|
85
|
+
* `isDisabled`, the input shows a tooltip with this text on hover and
|
|
86
|
+
* keyboard focus, and the field stays focusable (via `aria-disabled`)
|
|
87
87
|
* so the reason is discoverable by keyboard and assistive technology.
|
|
88
88
|
* Typing and calendar activation stay blocked.
|
|
89
89
|
*
|
|
90
|
-
* Use this instead of wrapping a disabled input in `Tooltip
|
|
91
|
-
*
|
|
90
|
+
* Use this instead of wrapping a disabled input in `Tooltip` — disabled
|
|
91
|
+
* controls don't emit the pointer events an external tooltip needs.
|
|
92
92
|
*
|
|
93
93
|
* @example
|
|
94
94
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/DateInput/DateInput.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAQ3C,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;AAgBrB,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/DateInput/DateInput.tsx"],"names":[],"mappings":"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"}
|
|
@@ -41,11 +41,6 @@ import { plainDateFromISO, plainDateToISO, formatSharedDate } from "../utils/pla
|
|
|
41
41
|
import { effectivePickerPresentation, resolvePickerPresentation } from "../utils/inputPresentation.js";
|
|
42
42
|
import { useDevWarning } from "../hooks/useDevWarning.js";
|
|
43
43
|
const styles = {
|
|
44
|
-
disabledFocusRing: {
|
|
45
|
-
kVAM5u: "xvy26l8 x2uiyk",
|
|
46
|
-
kGVxlE: "x1gnnqk1 xxsos93",
|
|
47
|
-
$$css: true
|
|
48
|
-
},
|
|
49
44
|
iconButton: {
|
|
50
45
|
k1xSpc: "x78zum5",
|
|
51
46
|
kGNEyG: "x6s0dn4",
|
|
@@ -217,11 +212,11 @@ function PointerDateField({
|
|
|
217
212
|
const isBusy = isLoading || optimisticValue !== value;
|
|
218
213
|
const isEffectivelyDisabled = isDisabled || isBusy;
|
|
219
214
|
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
//
|
|
215
|
+
// Disabled-reason tooltip. Disabled controls swallow pointer events, so the
|
|
216
|
+
// tooltip listeners attach to the input container (which already exists) and
|
|
217
|
+
// the text input stays perceivable via aria-disabled instead of the disabled
|
|
218
|
+
// attribute. Typing is blocked with readOnly and value mutation guards;
|
|
219
|
+
// calendar activation is blocked by the isEffectivelyDisabled guards. Only
|
|
225
220
|
// the persistent isDisabled state (not the transient busy state) surfaces a
|
|
226
221
|
// reason.
|
|
227
222
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
@@ -362,8 +357,8 @@ function PointerDateField({
|
|
|
362
357
|
|
|
363
358
|
// Handle input text change - update immediately if valid and allowed
|
|
364
359
|
const handleInputChange = useCallback(e => {
|
|
365
|
-
//
|
|
366
|
-
// value mutation explicitly (readOnly also blocks typing).
|
|
360
|
+
// With a disabledMessage the input drops `disabled` for focusability, so
|
|
361
|
+
// guard value mutation explicitly (readOnly also blocks typing).
|
|
367
362
|
if (isEffectivelyDisabled) {
|
|
368
363
|
return;
|
|
369
364
|
}
|
|
@@ -386,11 +381,6 @@ function PointerDateField({
|
|
|
386
381
|
if (pendingInput === null) {
|
|
387
382
|
return;
|
|
388
383
|
}
|
|
389
|
-
// Disabled or busy: keep the value, drop the draft (spec:AST-085 FR2).
|
|
390
|
-
if (isEffectivelyDisabled) {
|
|
391
|
-
setPendingInput(null);
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
384
|
if (!pendingInput.trim()) {
|
|
395
385
|
if (value !== undefined) {
|
|
396
386
|
fireChange(undefined);
|
|
@@ -406,7 +396,7 @@ function PointerDateField({
|
|
|
406
396
|
}
|
|
407
397
|
}
|
|
408
398
|
setPendingInput(null);
|
|
409
|
-
}, [pendingInput,
|
|
399
|
+
}, [pendingInput, value, fireChange, isDateDisabled, locale]);
|
|
410
400
|
|
|
411
401
|
// Handle blur - validate, check constraints, and clear pending input
|
|
412
402
|
const handleBlur = useCallback(() => {
|
|
@@ -452,17 +442,14 @@ function PointerDateField({
|
|
|
452
442
|
size,
|
|
453
443
|
status: status?.type ?? null,
|
|
454
444
|
disabled: isDisabled ? 'disabled' : null
|
|
455
|
-
}), stylex.props(inputWrapperStyles.base, sizeStyles[size], isEffectivelyDisabled && inputWrapperStyles.disabled,
|
|
445
|
+
}), stylex.props(inputWrapperStyles.base, sizeStyles[size], isEffectivelyDisabled && inputWrapperStyles.disabled, status && inputStatusBorderStyles[status.type], status && !isEffectivelyDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], inputGroup && groupStyles.inGroup, controlXstyle), controlClassName, controlStyle),
|
|
456
446
|
children: [inputGroup && /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
457
447
|
id: inputLabelID,
|
|
458
448
|
children: label
|
|
459
449
|
}), /*#__PURE__*/_jsx("button", {
|
|
460
450
|
type: "button",
|
|
461
451
|
onClick: handleToggle,
|
|
462
|
-
|
|
463
|
-
// A tab stop while disabled too, so it carries the reason (FR5).
|
|
464
|
-
,
|
|
465
|
-
"aria-describedby": showsDisabledMessage ? disabledMessageTooltip.describedBy : undefined,
|
|
452
|
+
disabled: isEffectivelyDisabled,
|
|
466
453
|
"aria-label": popover.isOpen ? t('@astryx.dateInput.toggleCalendarClose') : t('@astryx.dateInput.openCalendar'),
|
|
467
454
|
...stylex.props(focusOutlineStyles.focusVisible, styles.iconButton, isEffectivelyDisabled && styles.iconButtonDisabled),
|
|
468
455
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
@@ -489,11 +476,17 @@ function PointerDateField({
|
|
|
489
476
|
value: displayValue,
|
|
490
477
|
onChange: handleInputChange,
|
|
491
478
|
onBlur: chainEventHandlers(handleBlur, onBlurProp),
|
|
492
|
-
onClick:
|
|
479
|
+
onClick: chainEventHandlers(handleInputClick, onClickProp),
|
|
493
480
|
onKeyDown: chainEventHandlers(handleInputKeyDown, onKeyDownProp),
|
|
494
|
-
placeholder: placeholder
|
|
495
|
-
|
|
496
|
-
|
|
481
|
+
placeholder: placeholder
|
|
482
|
+
// With a disabledMessage the input keeps focusability via
|
|
483
|
+
// aria-disabled so the reason is focus-discoverable; typing is
|
|
484
|
+
// blocked with readOnly and the mutation guards, and calendar
|
|
485
|
+
// activation is blocked by the isEffectivelyDisabled guards.
|
|
486
|
+
,
|
|
487
|
+
disabled: isEffectivelyDisabled && !showsDisabledMessage,
|
|
488
|
+
"aria-disabled": showsDisabledMessage ? 'true' : undefined,
|
|
489
|
+
readOnly: showsDisabledMessage || undefined,
|
|
497
490
|
"aria-labelledby": ariaLabelledByProp != null ? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp) : ariaLabelledBy,
|
|
498
491
|
"aria-describedby": ariaDescribedBy,
|
|
499
492
|
"aria-required": isEffectivelyRequired ? 'true' : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeDateField.d.ts","sourceRoot":"","sources":["../../src/DateInput/NativeDateField.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeDateField.d.ts","sourceRoot":"","sources":["../../src/DateInput/NativeDateField.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AA6MhD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,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,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,GAAG,EACH,GAAG,SAAS,EACb,EAAE,cAAc,+BA+ahB;yBAlde,eAAe"}
|
|
@@ -49,11 +49,6 @@ import { focusOutlineStyles, formatSharedDate, getInputARIA, mergeProps, parseDa
|
|
|
49
49
|
import { chainEventHandlers } from "../utils/chainEventHandlers.js";
|
|
50
50
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
51
51
|
const styles = {
|
|
52
|
-
disabledFocusRing: {
|
|
53
|
-
kVAM5u: "xvy26l8 x2uiyk",
|
|
54
|
-
kGVxlE: "x1gnnqk1 xxsos93",
|
|
55
|
-
$$css: true
|
|
56
|
-
},
|
|
57
52
|
wrapper: {
|
|
58
53
|
kOIVth: "x1txdalj",
|
|
59
54
|
$$css: true
|
|
@@ -179,10 +174,9 @@ export function NativeDateField({
|
|
|
179
174
|
// platform picker from its input.
|
|
180
175
|
const isEffectivelyDisabled = isDisabled || isLoading;
|
|
181
176
|
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
// attach to the wrapper.
|
|
177
|
+
// Disabled-reason tooltip, same contract as the other two surfaces: a
|
|
178
|
+
// disabled control swallows pointer events, so the listeners attach to the
|
|
179
|
+
// wrapper and the input stays focusable via aria-disabled.
|
|
186
180
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
187
181
|
const disabledMessageTooltip = useTooltip({
|
|
188
182
|
placement: 'above',
|
|
@@ -401,14 +395,14 @@ export function NativeDateField({
|
|
|
401
395
|
size,
|
|
402
396
|
status: status?.type ?? null,
|
|
403
397
|
disabled: isDisabled ? 'disabled' : null
|
|
404
|
-
}), stylex.props(inputWrapperStyles.base, sizeStyles[size], styles.wrapper, isEffectivelyDisabled && inputWrapperStyles.disabled,
|
|
398
|
+
}), 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, controlXstyle), controlClassName, controlStyle),
|
|
405
399
|
children: [inputGroup && /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
406
400
|
id: inputLabelID,
|
|
407
401
|
children: label
|
|
408
402
|
}), /*#__PURE__*/_jsx("button", {
|
|
409
403
|
type: "button",
|
|
410
404
|
onClick: openPicker,
|
|
411
|
-
|
|
405
|
+
disabled: isEffectivelyDisabled,
|
|
412
406
|
"aria-label": t('@astryx.dateInput.openCalendar'),
|
|
413
407
|
tabIndex: -1,
|
|
414
408
|
...stylex.props(focusOutlineStyles.focusVisible, styles.iconButton, isEffectivelyDisabled && styles.iconButtonDisabled),
|
|
@@ -426,7 +420,6 @@ export function NativeDateField({
|
|
|
426
420
|
},
|
|
427
421
|
children: [/*#__PURE__*/_jsx("input", {
|
|
428
422
|
...controlProps,
|
|
429
|
-
onClick: isEffectivelyDisabled ? undefined : controlProps.onClick,
|
|
430
423
|
ref: mergedInputRef,
|
|
431
424
|
id: id,
|
|
432
425
|
type: "date"
|
|
@@ -439,8 +432,9 @@ export function NativeDateField({
|
|
|
439
432
|
onBlur: chainEventHandlers(handleBlur, onBlurProp),
|
|
440
433
|
min: min,
|
|
441
434
|
max: max,
|
|
442
|
-
|
|
443
|
-
|
|
435
|
+
disabled: isEffectivelyDisabled && !showsDisabledMessage,
|
|
436
|
+
"aria-disabled": showsDisabledMessage ? 'true' : undefined,
|
|
437
|
+
readOnly: showsDisabledMessage || undefined,
|
|
444
438
|
"aria-labelledby": ariaLabelledByProp != null ? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp) : ariaLabelledBy,
|
|
445
439
|
"aria-describedby": ariaDescribedBy,
|
|
446
440
|
"aria-required": isEffectivelyRequired ? 'true' : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchDateField.d.ts","sourceRoot":"","sources":["../../src/DateInput/TouchDateField.tsx"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"TouchDateField.d.ts","sourceRoot":"","sources":["../../src/DateInput/TouchDateField.tsx"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAgehD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,SAAiB,EACjB,GAAG,EACH,GAAG,EACH,eAAe,EACf,WAAW,EAAE,oBAAoB,EACjC,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,aAA0B,EAC1B,YAAY,EACZ,QAAgB,EAIhB,cAAc,EAAE,eAAe,EAC/B,YAAY,EAAE,gBAAoB,EAClC,MAAoB,EACpB,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,GAAG,EACH,GAAG,SAAS,EACb,EAAE,cAAc,+BAmvBhB;yBAvxBe,cAAc"}
|
|
@@ -122,11 +122,6 @@ const sizeStyles = {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
const styles = {
|
|
125
|
-
disabledFocusRing: {
|
|
126
|
-
kVAM5u: "xvy26l8 x2uiyk",
|
|
127
|
-
kGVxlE: "x1gnnqk1 xxsos93",
|
|
128
|
-
$$css: true
|
|
129
|
-
},
|
|
130
125
|
wrapper: {
|
|
131
126
|
kOIVth: "x1txdalj",
|
|
132
127
|
$$css: true
|
|
@@ -281,11 +276,11 @@ export function TouchDateField({
|
|
|
281
276
|
const isBusy = isLoading || optimisticValue !== value;
|
|
282
277
|
const isEffectivelyDisabled = isDisabled || isBusy;
|
|
283
278
|
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
//
|
|
288
|
-
// transient busy one.
|
|
279
|
+
// Disabled-reason tooltip, same contract as DateInput: a disabled control
|
|
280
|
+
// swallows pointer events, so the listeners attach to the wrapper and the
|
|
281
|
+
// input stays focusable via aria-disabled rather than the disabled
|
|
282
|
+
// attribute. Only the persistent disabled state surfaces a reason, never
|
|
283
|
+
// the transient busy one.
|
|
289
284
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
290
285
|
const disabledMessageTooltip = useTooltip({
|
|
291
286
|
placement: 'above',
|
|
@@ -796,14 +791,14 @@ export function TouchDateField({
|
|
|
796
791
|
size,
|
|
797
792
|
status: status?.type ?? null,
|
|
798
793
|
disabled: isDisabled ? 'disabled' : null
|
|
799
|
-
}), stylex.props(inputWrapperStyles.base, sizeStyles[size], styles.wrapper, isEffectivelyDisabled && inputWrapperStyles.disabled,
|
|
794
|
+
}), 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, controlXstyle), controlClassName, controlStyle),
|
|
800
795
|
children: [inputGroup && /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
801
796
|
id: inputLabelID,
|
|
802
797
|
children: label
|
|
803
798
|
}), /*#__PURE__*/_jsx("button", {
|
|
804
799
|
type: "button",
|
|
805
800
|
onClick: openSheet,
|
|
806
|
-
|
|
801
|
+
disabled: isEffectivelyDisabled,
|
|
807
802
|
"aria-label": t('@astryx.dateInput.openCalendar'),
|
|
808
803
|
tabIndex: -1,
|
|
809
804
|
...stylex.props(focusOutlineStyles.focusVisible, styles.iconButton, isEffectivelyDisabled && styles.iconButtonDisabled),
|
|
@@ -830,10 +825,11 @@ export function TouchDateField({
|
|
|
830
825
|
readOnly: true,
|
|
831
826
|
inputMode: "none",
|
|
832
827
|
onChange: () => {},
|
|
833
|
-
onClick:
|
|
828
|
+
onClick: chainEventHandlers(openSheet, onClickProp),
|
|
834
829
|
onKeyDown: chainEventHandlers(handleInputKeyDown, onKeyDownProp),
|
|
835
830
|
placeholder: placeholder,
|
|
836
|
-
|
|
831
|
+
disabled: isEffectivelyDisabled && !showsDisabledMessage,
|
|
832
|
+
"aria-disabled": showsDisabledMessage ? 'true' : undefined,
|
|
837
833
|
"aria-labelledby": ariaLabelledByProp != null ? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp) : ariaLabelledBy,
|
|
838
834
|
"aria-describedby": ariaDescribedBy,
|
|
839
835
|
"aria-required": isEffectivelyRequired ? 'true' : undefined,
|
package/dist/astryx.css
CHANGED
|
@@ -646,7 +646,6 @@
|
|
|
646
646
|
.xa1yw2k:focus-within:not(#\#):not(#\#){border-color:var(--color-warning)}
|
|
647
647
|
.x1bax923.x1bax923:where(.xgy66g5:has(:focus-visible) *):not(#\#):not(#\#){outline:var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color)}
|
|
648
648
|
.x1dordxg:focus-within:not(#\#):not(#\#){overflow:visible}
|
|
649
|
-
.x2uiyk:has(input:focus):not(#\#):not(#\#){border-color:var(--color-accent)}
|
|
650
649
|
.xb0m1lw:has(> div > .astryx-layout-content):not(#\#):not(#\#){margin-inline:0}
|
|
651
650
|
.x16s19ga:has(:focus-visible):not(#\#):not(#\#){outline:var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color)}
|
|
652
651
|
.xf0xpto:placeholder-shown:not(#\#):not(#\#){flex:0 0 auto}
|
|
@@ -1536,7 +1535,6 @@
|
|
|
1536
1535
|
.x1qf1n5z.x1qf1n5z:where(.astryx-input-group > *):focus-visible:not(#\#):not(#\#):not(#\#){z-index:2}
|
|
1537
1536
|
.x1s2lk0z.x1s2lk0z:where(:not(:disabled,[aria-disabled="true"]))[data-astryx-press="fading"]:not(#\#):not(#\#):not(#\#){--_press-overlay:var(--_press-paint)}
|
|
1538
1537
|
.x1sad4of.x1sad4of:where(:not(:disabled,[aria-disabled="true"]))[data-astryx-press="on"]:not(#\#):not(#\#):not(#\#){--_press-overlay:var(--_press-paint)}
|
|
1539
|
-
.xxsos93:has(input:focus):not(#\#):not(#\#):not(#\#){box-shadow:inset 0 0 0 2px var(--color-accent-muted)}
|
|
1540
1538
|
.x1btxeh5:has(input:focus-visible):not(#\#):not(#\#):not(#\#){box-shadow:inset 0 0 0 2px var(--color-accent)}
|
|
1541
1539
|
.xsw3flo:has(> div > .astryx-layout-content):not(#\#):not(#\#):not(#\#){container-type:inline-size}
|
|
1542
1540
|
.x1ab7gxt:has(~ * > [data-astryx-submenu-regions="view"]:not([hidden])):not(#\#):not(#\#):not(#\#){display:none}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.7.3-canary.
|
|
3
|
+
"version": "0.7.3-canary.31e06f4",
|
|
4
4
|
"displayName": "Astryx Core",
|
|
5
5
|
"description": "The component library. Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -792,8 +792,8 @@
|
|
|
792
792
|
"react-dom": ">=19.0.0"
|
|
793
793
|
},
|
|
794
794
|
"devDependencies": {
|
|
795
|
-
"@astryxdesign/a11y-spec": "0.7.3-canary.
|
|
796
|
-
"@astryxdesign/cli": "0.7.3-canary.
|
|
795
|
+
"@astryxdesign/a11y-spec": "0.7.3-canary.31e06f4",
|
|
796
|
+
"@astryxdesign/cli": "0.7.3-canary.31e06f4",
|
|
797
797
|
"@babel/cli": "^7.29.7",
|
|
798
798
|
"@babel/core": "^7.29.7",
|
|
799
799
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -49,15 +49,14 @@ export const docs = {
|
|
|
49
49
|
{
|
|
50
50
|
name: 'isDisabled',
|
|
51
51
|
type: 'boolean',
|
|
52
|
-
description:
|
|
53
|
-
'Disable the input and calendar. The field stays focusable and exposes `aria-disabled`; typing and opening are blocked.',
|
|
52
|
+
description: 'Disable the input and calendar.',
|
|
54
53
|
default: 'false',
|
|
55
54
|
},
|
|
56
55
|
{
|
|
57
56
|
name: 'disabledMessage',
|
|
58
57
|
type: 'string',
|
|
59
58
|
description:
|
|
60
|
-
'Explains why the input is disabled. With isDisabled, shows a tooltip on hover/keyboard focus (activation stays blocked). Use this instead of wrapping a disabled DateInput in Tooltip.',
|
|
59
|
+
'Explains why the input is disabled. With isDisabled, shows a tooltip on hover/keyboard focus and keeps the field focusable via aria-disabled (activation stays blocked). Use this instead of wrapping a disabled DateInput in Tooltip. Disabled controls swallow the hover events an external Tooltip needs.',
|
|
61
60
|
},
|
|
62
61
|
{
|
|
63
62
|
name: 'value',
|
|
@@ -276,7 +275,7 @@ export const docs = {
|
|
|
276
275
|
{
|
|
277
276
|
guidance: false,
|
|
278
277
|
description:
|
|
279
|
-
'Wrap a disabled DateInput in Tooltip to explain why it is disabled
|
|
278
|
+
'Wrap a disabled DateInput in Tooltip to explain why it is disabled; disabled triggers swallow the hover events the wrapper needs. Use the disabledMessage prop instead.',
|
|
280
279
|
},
|
|
281
280
|
],
|
|
282
281
|
anatomy: [
|
|
@@ -369,7 +368,7 @@ export const docsZh = {
|
|
|
369
368
|
{
|
|
370
369
|
guidance: false,
|
|
371
370
|
description:
|
|
372
|
-
'Wrap a disabled DateInput in Tooltip to explain why it is disabled
|
|
371
|
+
'Wrap a disabled DateInput in Tooltip to explain why it is disabled; disabled triggers swallow the hover events the wrapper needs. Use the disabledMessage prop instead.',
|
|
373
372
|
},
|
|
374
373
|
],
|
|
375
374
|
},
|
|
@@ -401,14 +400,14 @@ export const docsZh = {
|
|
|
401
400
|
{
|
|
402
401
|
name: 'isDisabled',
|
|
403
402
|
type: 'boolean',
|
|
404
|
-
description: '
|
|
403
|
+
description: '禁用输入框和日历。',
|
|
405
404
|
default: 'false',
|
|
406
405
|
},
|
|
407
406
|
{
|
|
408
407
|
name: 'disabledMessage',
|
|
409
408
|
type: 'string',
|
|
410
409
|
description:
|
|
411
|
-
'说明输入框为何被禁用。与 isDisabled
|
|
410
|
+
'说明输入框为何被禁用。与 isDisabled 一起使用时,在悬停/键盘聚焦时显示提示,并通过 aria-disabled 保持输入框可聚焦(仍阻止输入和激活)。请使用此属性,而不是用 Tooltip 包裹已禁用的 DateInput。',
|
|
412
411
|
},
|
|
413
412
|
{
|
|
414
413
|
name: 'value',
|
|
@@ -622,7 +621,7 @@ export const docsDense = {
|
|
|
622
621
|
{
|
|
623
622
|
guidance: false,
|
|
624
623
|
description:
|
|
625
|
-
'Wrap a disabled DateInput in Tooltip to explain why it is disabled
|
|
624
|
+
'Wrap a disabled DateInput in Tooltip to explain why it is disabled; disabled triggers swallow the hover events the wrapper needs. Use the disabledMessage prop instead.',
|
|
626
625
|
},
|
|
627
626
|
],
|
|
628
627
|
},
|
|
@@ -634,7 +633,7 @@ export const docsDense = {
|
|
|
634
633
|
isRequired: 'mark field required',
|
|
635
634
|
isDisabled: 'disable input+calendar',
|
|
636
635
|
disabledMessage:
|
|
637
|
-
|
|
636
|
+
'reason shown in a tooltip on hover/focus when disabled; keeps field focusable via aria-disabled',
|
|
638
637
|
value: 'selected date YYYY-MM-DD',
|
|
639
638
|
onChange: 'callback on date change',
|
|
640
639
|
changeAction: 'async action after onChange; drives optimistic UI',
|
|
@@ -84,14 +84,9 @@ describe('DateInput', () => {
|
|
|
84
84
|
expect(screen.getByRole('combobox')).not.toHaveAttribute('aria-required');
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
it('
|
|
87
|
+
it('sets disabled attribute when isDisabled is true', () => {
|
|
88
88
|
render(<DateInput label="Date" isDisabled onChange={() => {}} />);
|
|
89
|
-
|
|
90
|
-
expect(input).not.toHaveAttribute('disabled');
|
|
91
|
-
expect(input).toHaveAttribute('aria-disabled', 'true');
|
|
92
|
-
expect(input).toHaveAttribute('readonly');
|
|
93
|
-
input.focus();
|
|
94
|
-
expect(input).toHaveFocus();
|
|
89
|
+
expect(screen.getByRole('combobox')).toBeDisabled();
|
|
95
90
|
});
|
|
96
91
|
|
|
97
92
|
it('is not disabled by default', () => {
|
|
@@ -120,16 +115,10 @@ describe('DateInput', () => {
|
|
|
120
115
|
expect(button).not.toBeDisabled();
|
|
121
116
|
});
|
|
122
117
|
|
|
123
|
-
it('calendar button is
|
|
118
|
+
it('calendar button is disabled when isDisabled is true', () => {
|
|
124
119
|
render(<DateInput label="Date" isDisabled onChange={() => {}} />);
|
|
125
120
|
const button = getButton('Open calendar');
|
|
126
|
-
expect(button).
|
|
127
|
-
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
128
|
-
fireEvent.click(button);
|
|
129
|
-
expect(screen.getByRole('combobox')).toHaveAttribute(
|
|
130
|
-
'aria-expanded',
|
|
131
|
-
'false',
|
|
132
|
-
);
|
|
121
|
+
expect(button).toBeDisabled();
|
|
133
122
|
});
|
|
134
123
|
|
|
135
124
|
it('does not call onChange while typing invalid input', async () => {
|
|
@@ -360,15 +349,10 @@ describe('DateInput', () => {
|
|
|
360
349
|
|
|
361
350
|
// --- P1: Input disabled during isBusy (isLoading) ---
|
|
362
351
|
|
|
363
|
-
it('
|
|
352
|
+
it('disables input and button when isLoading is true', () => {
|
|
364
353
|
render(<DateInput label="Date" isLoading onChange={() => {}} />);
|
|
365
|
-
expect(screen.getByRole('combobox')).
|
|
366
|
-
expect(
|
|
367
|
-
'aria-disabled',
|
|
368
|
-
'true',
|
|
369
|
-
);
|
|
370
|
-
expect(getButton('Open calendar')).not.toHaveAttribute('disabled');
|
|
371
|
-
expect(getButton('Open calendar')).toHaveAttribute('aria-disabled', 'true');
|
|
354
|
+
expect(screen.getByRole('combobox')).toBeDisabled();
|
|
355
|
+
expect(getButton('Open calendar')).toBeDisabled();
|
|
372
356
|
});
|
|
373
357
|
|
|
374
358
|
it('shows spinner when isLoading is true', () => {
|
|
@@ -542,8 +526,7 @@ describe('DateInput', () => {
|
|
|
542
526
|
render(<DateInput label="Date" isDisabled onChange={() => {}} />);
|
|
543
527
|
|
|
544
528
|
const input = screen.getByRole('combobox');
|
|
545
|
-
expect(input).
|
|
546
|
-
expect(input).not.toHaveAttribute('disabled');
|
|
529
|
+
expect(input).toBeDisabled();
|
|
547
530
|
});
|
|
548
531
|
|
|
549
532
|
// --- P1: aria-busy on input ---
|
|
@@ -835,10 +818,7 @@ describe('DateInput', () => {
|
|
|
835
818
|
expect(input).toHaveAttribute('aria-disabled', 'true');
|
|
836
819
|
expect(input.getAttribute('aria-describedby')).toContain(tooltip.id);
|
|
837
820
|
expect(tooltip).toHaveTextContent('Scheduling is locked');
|
|
838
|
-
expect(getButton('Open calendar')).
|
|
839
|
-
'aria-disabled',
|
|
840
|
-
'true',
|
|
841
|
-
);
|
|
821
|
+
expect(getButton('Open calendar')).toBeDisabled();
|
|
842
822
|
});
|
|
843
823
|
});
|
|
844
824
|
|
|
@@ -895,10 +875,6 @@ describe('DateInput', () => {
|
|
|
895
875
|
);
|
|
896
876
|
|
|
897
877
|
const tooltip = screen.getByRole('tooltip', h);
|
|
898
|
-
// The calendar button keeps its enabled tab stop (spec:AST-085 FR1),
|
|
899
|
-
// so the input is the second stop.
|
|
900
|
-
await user.tab();
|
|
901
|
-
expect(getButton('Open calendar')).toHaveFocus();
|
|
902
878
|
await user.tab();
|
|
903
879
|
expect(screen.getByRole('combobox')).toHaveFocus();
|
|
904
880
|
await waitFor(() => {
|
|
@@ -932,50 +908,6 @@ describe('DateInput', () => {
|
|
|
932
908
|
expect(input).toHaveAttribute('readonly');
|
|
933
909
|
});
|
|
934
910
|
|
|
935
|
-
it('does not call a caller onClick while disabled (AST-085 FR2)', () => {
|
|
936
|
-
const onClick = vi.fn();
|
|
937
|
-
render(<DateInput label="Date" isDisabled onClick={onClick} />);
|
|
938
|
-
fireEvent.click(screen.getByRole('combobox'));
|
|
939
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
it('links the reason tooltip from the calendar button too (AST-085 FR5)', () => {
|
|
943
|
-
render(
|
|
944
|
-
<DateInput
|
|
945
|
-
label="Date"
|
|
946
|
-
isDisabled
|
|
947
|
-
disabledMessage="You need the Editor role"
|
|
948
|
-
/>,
|
|
949
|
-
);
|
|
950
|
-
const tooltip = screen.getByRole('tooltip', h);
|
|
951
|
-
expect(
|
|
952
|
-
getButton('Open calendar').getAttribute('aria-describedby'),
|
|
953
|
-
).toContain(tooltip.id);
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
it('drops a draft instead of committing it when the field becomes disabled (AST-085 FR2)', async () => {
|
|
957
|
-
const user = userEvent.setup();
|
|
958
|
-
const onChange = vi.fn();
|
|
959
|
-
const {rerender} = render(
|
|
960
|
-
<DateInput label="Date" value="2026-03-10" onChange={onChange} />,
|
|
961
|
-
);
|
|
962
|
-
const input = screen.getByRole('combobox');
|
|
963
|
-
await user.click(input);
|
|
964
|
-
await user.clear(input);
|
|
965
|
-
rerender(
|
|
966
|
-
<DateInput
|
|
967
|
-
label="Date"
|
|
968
|
-
value="2026-03-10"
|
|
969
|
-
onChange={onChange}
|
|
970
|
-
isDisabled
|
|
971
|
-
/>,
|
|
972
|
-
);
|
|
973
|
-
expect(input).toHaveFocus();
|
|
974
|
-
await user.keyboard('{Enter}');
|
|
975
|
-
await user.tab();
|
|
976
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
977
|
-
});
|
|
978
|
-
|
|
979
911
|
it('links the reason tooltip from the input via aria-describedby', () => {
|
|
980
912
|
render(
|
|
981
913
|
<DateInput
|
|
@@ -1009,18 +941,11 @@ describe('DateInput', () => {
|
|
|
1009
941
|
expect(onChange).not.toHaveBeenCalled();
|
|
1010
942
|
});
|
|
1011
943
|
|
|
1012
|
-
it('
|
|
1013
|
-
|
|
1014
|
-
const onChange = vi.fn();
|
|
1015
|
-
render(<DateInput label="Date" onChange={onChange} isDisabled />);
|
|
944
|
+
it('remains natively disabled when disabled without a reason', () => {
|
|
945
|
+
render(<DateInput label="Date" isDisabled />);
|
|
1016
946
|
const input = screen.getByRole('combobox');
|
|
1017
|
-
expect(input).
|
|
1018
|
-
|
|
1019
|
-
await user.type(input, '2026-03-15');
|
|
1020
|
-
await user.keyboard('{ArrowDown}');
|
|
1021
|
-
expect(input).toHaveValue('');
|
|
1022
|
-
expect(input).toHaveAttribute('aria-expanded', 'false');
|
|
1023
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
947
|
+
expect(input).toBeDisabled();
|
|
948
|
+
expect(input).not.toHaveAttribute('aria-disabled');
|
|
1024
949
|
});
|
|
1025
950
|
});
|
|
1026
951
|
|
|
@@ -79,18 +79,6 @@ import {
|
|
|
79
79
|
import {useDevWarning} from '../hooks/useDevWarning';
|
|
80
80
|
|
|
81
81
|
const styles = stylex.create({
|
|
82
|
-
// The shared disabled style drops the focus ring; restore it while this
|
|
83
|
-
// field's own input holds focus (spec:AST-085 FR6). Defaults repeat it.
|
|
84
|
-
disabledFocusRing: {
|
|
85
|
-
borderColor: {
|
|
86
|
-
default: colorVars['--color-border-emphasized'],
|
|
87
|
-
':has(input:focus)': colorVars['--color-accent'],
|
|
88
|
-
},
|
|
89
|
-
boxShadow: {
|
|
90
|
-
default: 'none',
|
|
91
|
-
':has(input:focus)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
82
|
iconButton: {
|
|
95
83
|
display: 'flex',
|
|
96
84
|
alignItems: 'center',
|
|
@@ -253,13 +241,13 @@ export interface DateInputProps extends Omit<
|
|
|
253
241
|
|
|
254
242
|
/**
|
|
255
243
|
* Explains why the input is disabled. When set together with
|
|
256
|
-
* `isDisabled`, the
|
|
257
|
-
* keyboard focus, and the field
|
|
244
|
+
* `isDisabled`, the input shows a tooltip with this text on hover and
|
|
245
|
+
* keyboard focus, and the field stays focusable (via `aria-disabled`)
|
|
258
246
|
* so the reason is discoverable by keyboard and assistive technology.
|
|
259
247
|
* Typing and calendar activation stay blocked.
|
|
260
248
|
*
|
|
261
|
-
* Use this instead of wrapping a disabled input in `Tooltip
|
|
262
|
-
*
|
|
249
|
+
* Use this instead of wrapping a disabled input in `Tooltip` — disabled
|
|
250
|
+
* controls don't emit the pointer events an external tooltip needs.
|
|
263
251
|
*
|
|
264
252
|
* @example
|
|
265
253
|
* ```
|
|
@@ -549,11 +537,11 @@ function PointerDateField({
|
|
|
549
537
|
const isBusy = isLoading || optimisticValue !== value;
|
|
550
538
|
const isEffectivelyDisabled = isDisabled || isBusy;
|
|
551
539
|
|
|
552
|
-
//
|
|
553
|
-
//
|
|
554
|
-
//
|
|
555
|
-
//
|
|
556
|
-
//
|
|
540
|
+
// Disabled-reason tooltip. Disabled controls swallow pointer events, so the
|
|
541
|
+
// tooltip listeners attach to the input container (which already exists) and
|
|
542
|
+
// the text input stays perceivable via aria-disabled instead of the disabled
|
|
543
|
+
// attribute. Typing is blocked with readOnly and value mutation guards;
|
|
544
|
+
// calendar activation is blocked by the isEffectivelyDisabled guards. Only
|
|
557
545
|
// the persistent isDisabled state (not the transient busy state) surfaces a
|
|
558
546
|
// reason.
|
|
559
547
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
@@ -715,8 +703,8 @@ function PointerDateField({
|
|
|
715
703
|
// Handle input text change - update immediately if valid and allowed
|
|
716
704
|
const handleInputChange = useCallback(
|
|
717
705
|
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
718
|
-
//
|
|
719
|
-
// value mutation explicitly (readOnly also blocks typing).
|
|
706
|
+
// With a disabledMessage the input drops `disabled` for focusability, so
|
|
707
|
+
// guard value mutation explicitly (readOnly also blocks typing).
|
|
720
708
|
if (isEffectivelyDisabled) {
|
|
721
709
|
return;
|
|
722
710
|
}
|
|
@@ -745,11 +733,6 @@ function PointerDateField({
|
|
|
745
733
|
if (pendingInput === null) {
|
|
746
734
|
return;
|
|
747
735
|
}
|
|
748
|
-
// Disabled or busy: keep the value, drop the draft (spec:AST-085 FR2).
|
|
749
|
-
if (isEffectivelyDisabled) {
|
|
750
|
-
setPendingInput(null);
|
|
751
|
-
return;
|
|
752
|
-
}
|
|
753
736
|
|
|
754
737
|
if (!pendingInput.trim()) {
|
|
755
738
|
if (value !== undefined) {
|
|
@@ -767,14 +750,7 @@ function PointerDateField({
|
|
|
767
750
|
}
|
|
768
751
|
}
|
|
769
752
|
setPendingInput(null);
|
|
770
|
-
}, [
|
|
771
|
-
pendingInput,
|
|
772
|
-
isEffectivelyDisabled,
|
|
773
|
-
value,
|
|
774
|
-
fireChange,
|
|
775
|
-
isDateDisabled,
|
|
776
|
-
locale,
|
|
777
|
-
]);
|
|
753
|
+
}, [pendingInput, value, fireChange, isDateDisabled, locale]);
|
|
778
754
|
|
|
779
755
|
// Handle blur - validate, check constraints, and clear pending input
|
|
780
756
|
const handleBlur = useCallback(() => {
|
|
@@ -832,7 +808,6 @@ function PointerDateField({
|
|
|
832
808
|
inputWrapperStyles.base,
|
|
833
809
|
sizeStyles[size],
|
|
834
810
|
isEffectivelyDisabled && inputWrapperStyles.disabled,
|
|
835
|
-
isEffectivelyDisabled && styles.disabledFocusRing,
|
|
836
811
|
status && inputStatusBorderStyles[status.type],
|
|
837
812
|
status &&
|
|
838
813
|
!isEffectivelyDisabled &&
|
|
@@ -848,11 +823,7 @@ function PointerDateField({
|
|
|
848
823
|
<button
|
|
849
824
|
type="button"
|
|
850
825
|
onClick={handleToggle}
|
|
851
|
-
|
|
852
|
-
// A tab stop while disabled too, so it carries the reason (FR5).
|
|
853
|
-
aria-describedby={
|
|
854
|
-
showsDisabledMessage ? disabledMessageTooltip.describedBy : undefined
|
|
855
|
-
}
|
|
826
|
+
disabled={isEffectivelyDisabled}
|
|
856
827
|
aria-label={
|
|
857
828
|
popover.isOpen
|
|
858
829
|
? t('@astryx.dateInput.toggleCalendarClose')
|
|
@@ -887,15 +858,16 @@ function PointerDateField({
|
|
|
887
858
|
value={displayValue}
|
|
888
859
|
onChange={handleInputChange}
|
|
889
860
|
onBlur={chainEventHandlers(handleBlur, onBlurProp)}
|
|
890
|
-
onClick={
|
|
891
|
-
isEffectivelyDisabled
|
|
892
|
-
? undefined
|
|
893
|
-
: chainEventHandlers(handleInputClick, onClickProp)
|
|
894
|
-
}
|
|
861
|
+
onClick={chainEventHandlers(handleInputClick, onClickProp)}
|
|
895
862
|
onKeyDown={chainEventHandlers(handleInputKeyDown, onKeyDownProp)}
|
|
896
863
|
placeholder={placeholder}
|
|
897
|
-
|
|
898
|
-
|
|
864
|
+
// With a disabledMessage the input keeps focusability via
|
|
865
|
+
// aria-disabled so the reason is focus-discoverable; typing is
|
|
866
|
+
// blocked with readOnly and the mutation guards, and calendar
|
|
867
|
+
// activation is blocked by the isEffectivelyDisabled guards.
|
|
868
|
+
disabled={isEffectivelyDisabled && !showsDisabledMessage}
|
|
869
|
+
aria-disabled={showsDisabledMessage ? 'true' : undefined}
|
|
870
|
+
readOnly={showsDisabledMessage || undefined}
|
|
899
871
|
aria-labelledby={
|
|
900
872
|
ariaLabelledByProp != null
|
|
901
873
|
? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp)
|
|
@@ -554,32 +554,11 @@ describe('DateInput — field parity', () => {
|
|
|
554
554
|
onChange={() => {}}
|
|
555
555
|
/>,
|
|
556
556
|
);
|
|
557
|
-
|
|
558
|
-
expect(field()).not.toHaveAttribute('disabled');
|
|
559
|
-
expect(field()).toHaveAttribute('aria-disabled', 'true');
|
|
560
|
-
field().focus();
|
|
561
|
-
expect(field()).toHaveFocus();
|
|
557
|
+
expect(field()).toBeDisabled();
|
|
562
558
|
fireEvent.click(field());
|
|
563
|
-
fireEvent.keyDown(field(), {key: 'Enter'});
|
|
564
|
-
expect(field()).toHaveAttribute('aria-expanded', 'false');
|
|
565
559
|
expect(screen.queryByRole('grid')).not.toBeInTheDocument();
|
|
566
560
|
});
|
|
567
561
|
|
|
568
|
-
it('does not call a caller onClick while disabled (AST-085 FR2)', () => {
|
|
569
|
-
const onClick = vi.fn();
|
|
570
|
-
render(
|
|
571
|
-
<DateInput
|
|
572
|
-
nativePicker="never"
|
|
573
|
-
label="Ship date"
|
|
574
|
-
isDisabled
|
|
575
|
-
onClick={onClick}
|
|
576
|
-
onChange={() => {}}
|
|
577
|
-
/>,
|
|
578
|
-
);
|
|
579
|
-
fireEvent.click(field());
|
|
580
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
581
|
-
});
|
|
582
|
-
|
|
583
562
|
it('stays focusable and explains itself when disabled with a reason', () => {
|
|
584
563
|
render(
|
|
585
564
|
<DateInput
|
|
@@ -601,38 +601,12 @@ describe('DateInput nativePicker', () => {
|
|
|
601
601
|
await act(async () => resolveAction());
|
|
602
602
|
});
|
|
603
603
|
|
|
604
|
-
it('
|
|
604
|
+
it('disables the control and its toggle when isDisabled', () => {
|
|
605
605
|
stubPointer(true);
|
|
606
606
|
render(<DateInput label="Date" isDisabled onChange={() => {}} />);
|
|
607
607
|
|
|
608
|
-
|
|
609
|
-
expect(
|
|
610
|
-
expect(input).toHaveAttribute('aria-disabled', 'true');
|
|
611
|
-
expect(input).toHaveAttribute('readonly');
|
|
612
|
-
input.focus();
|
|
613
|
-
expect(input).toHaveFocus();
|
|
614
|
-
const toggle = screen.getByLabelText('Open calendar');
|
|
615
|
-
expect(toggle).not.toHaveAttribute('disabled');
|
|
616
|
-
expect(toggle).toHaveAttribute('aria-disabled', 'true');
|
|
617
|
-
const showPicker = vi.fn();
|
|
618
|
-
Object.defineProperty(input, 'showPicker', {value: showPicker});
|
|
619
|
-
fireEvent.click(toggle);
|
|
620
|
-
expect(showPicker).not.toHaveBeenCalled();
|
|
621
|
-
});
|
|
622
|
-
|
|
623
|
-
it('does not call a caller onClick while disabled (AST-085 FR2)', () => {
|
|
624
|
-
stubPointer(true);
|
|
625
|
-
const onClick = vi.fn();
|
|
626
|
-
render(
|
|
627
|
-
<DateInput
|
|
628
|
-
label="Date"
|
|
629
|
-
isDisabled
|
|
630
|
-
onClick={onClick}
|
|
631
|
-
onChange={() => {}}
|
|
632
|
-
/>,
|
|
633
|
-
);
|
|
634
|
-
fireEvent.click(getInput());
|
|
635
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
608
|
+
expect(getInput()).toBeDisabled();
|
|
609
|
+
expect(screen.getByLabelText('Open calendar')).toBeDisabled();
|
|
636
610
|
});
|
|
637
611
|
|
|
638
612
|
it('ignores a change while disabled', () => {
|
|
@@ -82,17 +82,6 @@ import {
|
|
|
82
82
|
import {chainEventHandlers} from '../utils/chainEventHandlers';
|
|
83
83
|
|
|
84
84
|
const styles = stylex.create({
|
|
85
|
-
// Same as DateInput's: the focus ring for a focused disabled field.
|
|
86
|
-
disabledFocusRing: {
|
|
87
|
-
borderColor: {
|
|
88
|
-
default: colorVars['--color-border-emphasized'],
|
|
89
|
-
':has(input:focus)': colorVars['--color-accent'],
|
|
90
|
-
},
|
|
91
|
-
boxShadow: {
|
|
92
|
-
default: 'none',
|
|
93
|
-
':has(input:focus)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
85
|
wrapper: {
|
|
97
86
|
gap: spacingVars['--spacing-2'],
|
|
98
87
|
},
|
|
@@ -334,10 +323,9 @@ export function NativeDateField({
|
|
|
334
323
|
// platform picker from its input.
|
|
335
324
|
const isEffectivelyDisabled = isDisabled || isLoading;
|
|
336
325
|
|
|
337
|
-
//
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
// attach to the wrapper.
|
|
326
|
+
// Disabled-reason tooltip, same contract as the other two surfaces: a
|
|
327
|
+
// disabled control swallows pointer events, so the listeners attach to the
|
|
328
|
+
// wrapper and the input stays focusable via aria-disabled.
|
|
341
329
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
342
330
|
const disabledMessageTooltip = useTooltip({
|
|
343
331
|
placement: 'above',
|
|
@@ -594,7 +582,6 @@ export function NativeDateField({
|
|
|
594
582
|
sizeStyles[size],
|
|
595
583
|
styles.wrapper,
|
|
596
584
|
isEffectivelyDisabled && inputWrapperStyles.disabled,
|
|
597
|
-
isEffectivelyDisabled && styles.disabledFocusRing,
|
|
598
585
|
status && inputStatusBorderStyles[status.type],
|
|
599
586
|
status &&
|
|
600
587
|
!isEffectivelyDisabled &&
|
|
@@ -610,7 +597,7 @@ export function NativeDateField({
|
|
|
610
597
|
<button
|
|
611
598
|
type="button"
|
|
612
599
|
onClick={openPicker}
|
|
613
|
-
|
|
600
|
+
disabled={isEffectivelyDisabled}
|
|
614
601
|
aria-label={t('@astryx.dateInput.openCalendar')}
|
|
615
602
|
tabIndex={-1}
|
|
616
603
|
{...stylex.props(
|
|
@@ -628,7 +615,6 @@ export function NativeDateField({
|
|
|
628
615
|
<span {...stylex.props(styles.slot)}>
|
|
629
616
|
<input
|
|
630
617
|
{...controlProps}
|
|
631
|
-
onClick={isEffectivelyDisabled ? undefined : controlProps.onClick}
|
|
632
618
|
ref={mergedInputRef}
|
|
633
619
|
id={id}
|
|
634
620
|
type="date"
|
|
@@ -640,8 +626,9 @@ export function NativeDateField({
|
|
|
640
626
|
onBlur={chainEventHandlers(handleBlur, onBlurProp)}
|
|
641
627
|
min={min}
|
|
642
628
|
max={max}
|
|
643
|
-
|
|
644
|
-
|
|
629
|
+
disabled={isEffectivelyDisabled && !showsDisabledMessage}
|
|
630
|
+
aria-disabled={showsDisabledMessage ? 'true' : undefined}
|
|
631
|
+
readOnly={showsDisabledMessage || undefined}
|
|
645
632
|
aria-labelledby={
|
|
646
633
|
ariaLabelledByProp != null
|
|
647
634
|
? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp)
|
|
@@ -166,17 +166,6 @@ const sizeStyles = stylex.create({
|
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
const styles = stylex.create({
|
|
169
|
-
// Same as DateInput's: the focus ring for a focused disabled field.
|
|
170
|
-
disabledFocusRing: {
|
|
171
|
-
borderColor: {
|
|
172
|
-
default: colorVars['--color-border-emphasized'],
|
|
173
|
-
':has(input:focus)': colorVars['--color-accent'],
|
|
174
|
-
},
|
|
175
|
-
boxShadow: {
|
|
176
|
-
default: 'none',
|
|
177
|
-
':has(input:focus)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
169
|
// ---- the closed field ----
|
|
181
170
|
wrapper: {
|
|
182
171
|
gap: spacingVars['--spacing-2'],
|
|
@@ -631,11 +620,11 @@ export function TouchDateField({
|
|
|
631
620
|
const isBusy = isLoading || optimisticValue !== value;
|
|
632
621
|
const isEffectivelyDisabled = isDisabled || isBusy;
|
|
633
622
|
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
//
|
|
637
|
-
//
|
|
638
|
-
// transient busy one.
|
|
623
|
+
// Disabled-reason tooltip, same contract as DateInput: a disabled control
|
|
624
|
+
// swallows pointer events, so the listeners attach to the wrapper and the
|
|
625
|
+
// input stays focusable via aria-disabled rather than the disabled
|
|
626
|
+
// attribute. Only the persistent disabled state surfaces a reason, never
|
|
627
|
+
// the transient busy one.
|
|
639
628
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
640
629
|
const disabledMessageTooltip = useTooltip({
|
|
641
630
|
placement: 'above',
|
|
@@ -1224,7 +1213,6 @@ export function TouchDateField({
|
|
|
1224
1213
|
sizeStyles[size],
|
|
1225
1214
|
styles.wrapper,
|
|
1226
1215
|
isEffectivelyDisabled && inputWrapperStyles.disabled,
|
|
1227
|
-
isEffectivelyDisabled && styles.disabledFocusRing,
|
|
1228
1216
|
status && inputStatusBorderStyles[status.type],
|
|
1229
1217
|
status &&
|
|
1230
1218
|
!isEffectivelyDisabled &&
|
|
@@ -1240,7 +1228,7 @@ export function TouchDateField({
|
|
|
1240
1228
|
<button
|
|
1241
1229
|
type="button"
|
|
1242
1230
|
onClick={openSheet}
|
|
1243
|
-
|
|
1231
|
+
disabled={isEffectivelyDisabled}
|
|
1244
1232
|
aria-label={t('@astryx.dateInput.openCalendar')}
|
|
1245
1233
|
tabIndex={-1}
|
|
1246
1234
|
{...stylex.props(
|
|
@@ -1271,14 +1259,11 @@ export function TouchDateField({
|
|
|
1271
1259
|
readOnly
|
|
1272
1260
|
inputMode="none"
|
|
1273
1261
|
onChange={() => {}}
|
|
1274
|
-
onClick={
|
|
1275
|
-
isEffectivelyDisabled
|
|
1276
|
-
? undefined
|
|
1277
|
-
: chainEventHandlers(openSheet, onClickProp)
|
|
1278
|
-
}
|
|
1262
|
+
onClick={chainEventHandlers(openSheet, onClickProp)}
|
|
1279
1263
|
onKeyDown={chainEventHandlers(handleInputKeyDown, onKeyDownProp)}
|
|
1280
1264
|
placeholder={placeholder}
|
|
1281
|
-
|
|
1265
|
+
disabled={isEffectivelyDisabled && !showsDisabledMessage}
|
|
1266
|
+
aria-disabled={showsDisabledMessage ? 'true' : undefined}
|
|
1282
1267
|
aria-labelledby={
|
|
1283
1268
|
ariaLabelledByProp != null
|
|
1284
1269
|
? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp)
|