@astryxdesign/core 0.7.5-canary.0026f37 → 0.7.5-canary.0ade0dd
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/NumberInput/NumberInput.d.ts +3 -3
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +39 -14
- package/package.json +3 -3
- package/src/NumberInput/NumberInput.doc.mjs +6 -6
- package/src/NumberInput/NumberInput.test.tsx +126 -14
- package/src/NumberInput/NumberInput.tsx +62 -16
- package/src/Pagination/Pagination.test.tsx +2 -2
|
@@ -67,7 +67,7 @@ interface NumberInputPropsBase extends Omit<FieldInputBaseProps, 'onChange' | 'd
|
|
|
67
67
|
* Whether the input is read-only.
|
|
68
68
|
* The value is shown at full opacity and still submits with the form, but
|
|
69
69
|
* cannot be edited. Unlike `isDisabled`, a read-only input is not dimmed and
|
|
70
|
-
*
|
|
70
|
+
* keeps its form value — use it for a value the user should see and send
|
|
71
71
|
* but not change. Stepping is off in every form while read-only: arrow keys,
|
|
72
72
|
* the wheel, and the number steppers. `isDisabled` takes precedence when both
|
|
73
73
|
* are set.
|
|
@@ -81,8 +81,8 @@ interface NumberInputPropsBase extends Omit<FieldInputBaseProps, 'onChange' | 'd
|
|
|
81
81
|
* keyboard and assistive technology. The field cannot be edited (it becomes
|
|
82
82
|
* read-only) while disabled.
|
|
83
83
|
*
|
|
84
|
-
* Use this instead of wrapping a disabled input in `Tooltip
|
|
85
|
-
*
|
|
84
|
+
* Use this instead of wrapping a disabled input in `Tooltip`, so the reason
|
|
85
|
+
* is attached to the field itself.
|
|
86
86
|
*
|
|
87
87
|
* @example
|
|
88
88
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../src/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAML,KAAK,UAAU,EACf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ACH,GAAG,EACH,IAAI,EACJ,WAAW,EACX,cAAqB,EACrB,iBAAyB,EACzB,KAAK,EACL,aAAqB,EACrB,OAAO,EACP,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,GAAG,EACH,EAAE,EAAE,MAAM,EACV,kBAAkB,EAAE,mBAAmB,EACvC,GAAG,SAAS,EACb,EAAE,gBAAgB,+BAkiBlB;yBA/kBe,WAAW"}
|
|
@@ -28,6 +28,7 @@ import { useTooltip } from "../Tooltip/index.js";
|
|
|
28
28
|
import { getInputARIA } from "../utils/index.js";
|
|
29
29
|
import { interactionOverlayStyles } from "../utils/interactionOverlay.stylex.js";
|
|
30
30
|
import { usePressFeedback } from "../hooks/usePressFeedback.js";
|
|
31
|
+
import { inputDisabledFocusStyles } from "../Field/inputDisabledFocus.js";
|
|
31
32
|
import { useSize } from "../SizeContext/SizeContext.js";
|
|
32
33
|
import { useInputContainer } from "../hooks/useInputContainer.js";
|
|
33
34
|
import { useInputStatusIcon } from "../hooks/useInputStatusIcon.js";
|
|
@@ -275,12 +276,14 @@ export function NumberInput({
|
|
|
275
276
|
const [pendingInput, setPendingInput] = useState(null);
|
|
276
277
|
const [isFocused, setIsFocused] = useState(false);
|
|
277
278
|
|
|
278
|
-
// Disabled-reason tooltip.
|
|
279
|
-
// tooltip listeners attach to the input container (which already exists) and
|
|
279
|
+
// Disabled-reason tooltip. The tooltip listeners attach to the input container (which already exists) and
|
|
280
280
|
// the input stays perceivable via aria-disabled instead of the native
|
|
281
281
|
// disabled attribute. The field is made read-only so it can't be typed into,
|
|
282
282
|
// and value mutation is blocked by the isDisabled guard in the handlers.
|
|
283
283
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
284
|
+
// A disabled field keeps its tab stop but, like a natively disabled one,
|
|
285
|
+
// runs no caller event handler other than focus and blur (`spec:AST-085` FR2).
|
|
286
|
+
const fieldProps = isDisabled ? Object.fromEntries(Object.entries(rest).filter(([key]) => !/^on[A-Z]/.test(key) || /^on(Focus|Blur)/.test(key))) : rest;
|
|
284
287
|
const disabledMessageTooltip = useTooltip({
|
|
285
288
|
placement: 'above',
|
|
286
289
|
// The container div is not naturally focusable; focusin bubbles up from
|
|
@@ -359,6 +362,12 @@ export function NumberInput({
|
|
|
359
362
|
if (pendingInput === null) {
|
|
360
363
|
return;
|
|
361
364
|
}
|
|
365
|
+
if (isDisabled) {
|
|
366
|
+
// A field disabled mid-entry commits nothing; its draft is dropped, as
|
|
367
|
+
// a natively disabled field's was (spec:AST-085 FR2).
|
|
368
|
+
setPendingInput(null);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
362
371
|
const decision = resolveNumberInputCommit(pendingInput, {
|
|
363
372
|
min,
|
|
364
373
|
max,
|
|
@@ -376,7 +385,7 @@ export function NumberInput({
|
|
|
376
385
|
} else if (decision.type === 'commit' && decision.value !== value) {
|
|
377
386
|
onChange(decision.value);
|
|
378
387
|
}
|
|
379
|
-
}, [hasClear, isIntegerOnly, locale, max, min, onChange, pendingInput, value]);
|
|
388
|
+
}, [hasClear, isDisabled, isIntegerOnly, locale, max, min, onChange, pendingInput, value]);
|
|
380
389
|
|
|
381
390
|
// Blur ends the edit and displays the resulting committed value.
|
|
382
391
|
const handleBlur = useCallback(e => {
|
|
@@ -419,6 +428,13 @@ export function NumberInput({
|
|
|
419
428
|
|
|
420
429
|
// Handle keyboard events
|
|
421
430
|
const handleKeyDown = useCallback(e => {
|
|
431
|
+
if (isDisabled) {
|
|
432
|
+
// A read-only field still submits its form on Enter.
|
|
433
|
+
if (e.key === 'Enter') {
|
|
434
|
+
e.preventDefault();
|
|
435
|
+
}
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
422
438
|
// The field is type="text" for formatted display, so an IME can compose
|
|
423
439
|
// into it: Enter commits the candidate and the arrows walk the candidate
|
|
424
440
|
// window. The composing keydown fires before compositionend, so without
|
|
@@ -442,7 +458,7 @@ export function NumberInput({
|
|
|
442
458
|
onEnter?.();
|
|
443
459
|
}
|
|
444
460
|
onKeyDown?.(e);
|
|
445
|
-
}, [commitPendingInput, onEnter, onKeyDown, stepValue]);
|
|
461
|
+
}, [commitPendingInput, isDisabled, onEnter, onKeyDown, stepValue]);
|
|
446
462
|
|
|
447
463
|
// React's delegated wheel listener can be passive, so use a native,
|
|
448
464
|
// explicitly non-passive listener to prevent page scrolling only when this
|
|
@@ -513,7 +529,7 @@ export function NumberInput({
|
|
|
513
529
|
status: status?.type ?? null,
|
|
514
530
|
disabled: isDisabled ? 'disabled' : null,
|
|
515
531
|
readonly: isReadOnly ? 'readonly' : null
|
|
516
|
-
}), stylex.props(inputWrapperStyles.base, styles.wrapper, hasNumberSteppers && styles.wrapperWithNumberSteppers, sizeStyles[size], isDisabled && inputWrapperStyles.disabled, status && inputStatusBorderStyles[status.type], status && !isDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], inputGroup && groupStyles.inGroup, controlXstyle), controlClassName, controlStyle),
|
|
532
|
+
}), stylex.props(inputWrapperStyles.base, styles.wrapper, hasNumberSteppers && styles.wrapperWithNumberSteppers, sizeStyles[size], isDisabled && inputWrapperStyles.disabled, isDisabled && inputDisabledFocusStyles.ring, status && inputStatusBorderStyles[status.type], status && !isDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type], inputGroup && groupStyles.inGroup, controlXstyle), controlClassName, controlStyle),
|
|
517
533
|
children: [startIcon && renderIconSlot(startIcon, {
|
|
518
534
|
size: 'sm',
|
|
519
535
|
color: 'secondary'
|
|
@@ -521,7 +537,7 @@ export function NumberInput({
|
|
|
521
537
|
id: inputLabelID,
|
|
522
538
|
children: label
|
|
523
539
|
}), /*#__PURE__*/_jsx("input", {
|
|
524
|
-
...
|
|
540
|
+
...fieldProps,
|
|
525
541
|
ref: mergedInputRef,
|
|
526
542
|
id: id,
|
|
527
543
|
name: isDisabled || formatValue ? undefined : htmlName,
|
|
@@ -535,13 +551,12 @@ export function NumberInput({
|
|
|
535
551
|
onBlur: handleBlur,
|
|
536
552
|
onKeyDown: handleKeyDown,
|
|
537
553
|
placeholder: placeholder
|
|
538
|
-
//
|
|
539
|
-
//
|
|
540
|
-
//
|
|
554
|
+
// A disabled input keeps its place in the tab order (spec:AST-085):
|
|
555
|
+
// aria-disabled instead of the native attribute, with readOnly + the
|
|
556
|
+
// handler guards keeping the value from changing.
|
|
541
557
|
,
|
|
542
|
-
disabled: isDisabled
|
|
543
|
-
|
|
544
|
-
readOnly: isReadOnly || showsDisabledMessage || undefined,
|
|
558
|
+
"aria-disabled": isDisabled ? 'true' : undefined,
|
|
559
|
+
readOnly: isReadOnly || isDisabled || undefined,
|
|
545
560
|
autoFocus: hasAutoFocus,
|
|
546
561
|
"data-autofocus": hasAutoFocus || undefined,
|
|
547
562
|
"aria-valuemin": min ?? undefined,
|
|
@@ -597,12 +612,17 @@ export function NumberInput({
|
|
|
597
612
|
type: "button",
|
|
598
613
|
tabIndex: -1,
|
|
599
614
|
...pressable,
|
|
600
|
-
disabled: isDisabled || isReadOnly || !canIncrement,
|
|
615
|
+
"aria-disabled": isDisabled || isReadOnly || !canIncrement || undefined,
|
|
601
616
|
"aria-label": t('@astryx.numberInput.incrementLabel', {
|
|
602
617
|
label
|
|
603
618
|
}),
|
|
604
619
|
onPointerDown: event => event.preventDefault(),
|
|
605
620
|
onClick: () => {
|
|
621
|
+
// An aria-disabled stepper does nothing, as a natively disabled
|
|
622
|
+
// one did (spec:AST-085 FR2).
|
|
623
|
+
if (isDisabled || isReadOnly || !canIncrement) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
606
626
|
inputRef.current?.focus();
|
|
607
627
|
stepValue(1);
|
|
608
628
|
},
|
|
@@ -617,12 +637,17 @@ export function NumberInput({
|
|
|
617
637
|
type: "button",
|
|
618
638
|
tabIndex: -1,
|
|
619
639
|
...pressable,
|
|
620
|
-
disabled: isDisabled || isReadOnly || !canDecrement,
|
|
640
|
+
"aria-disabled": isDisabled || isReadOnly || !canDecrement || undefined,
|
|
621
641
|
"aria-label": t('@astryx.numberInput.decrementLabel', {
|
|
622
642
|
label
|
|
623
643
|
}),
|
|
624
644
|
onPointerDown: event => event.preventDefault(),
|
|
625
645
|
onClick: () => {
|
|
646
|
+
// An aria-disabled stepper does nothing, as a natively disabled
|
|
647
|
+
// one did (spec:AST-085 FR2).
|
|
648
|
+
if (isDisabled || isReadOnly || !canDecrement) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
626
651
|
inputRef.current?.focus();
|
|
627
652
|
stepValue(-1);
|
|
628
653
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.7.5-canary.
|
|
3
|
+
"version": "0.7.5-canary.0ade0dd",
|
|
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.5-canary.
|
|
796
|
-
"@astryxdesign/cli": "0.7.5-canary.
|
|
795
|
+
"@astryxdesign/a11y-spec": "0.7.5-canary.0ade0dd",
|
|
796
|
+
"@astryxdesign/cli": "0.7.5-canary.0ade0dd",
|
|
797
797
|
"@babel/cli": "^7.29.7",
|
|
798
798
|
"@babel/core": "^7.29.7",
|
|
799
799
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -81,7 +81,7 @@ export const docs = {
|
|
|
81
81
|
name: 'isReadOnly',
|
|
82
82
|
type: 'boolean',
|
|
83
83
|
description:
|
|
84
|
-
'Makes the input read-only: the value is shown at full opacity and still submits with the form, but cannot be edited. Unlike isDisabled, a read-only input is not dimmed and
|
|
84
|
+
'Makes the input read-only: the value is shown at full opacity and still submits with the form, but cannot be edited. Unlike isDisabled, a read-only input is not dimmed and keeps its form value. Stepping is off in every form while read-only: arrow keys, the wheel, and the number steppers. isDisabled takes precedence when both are set.',
|
|
85
85
|
default: 'false',
|
|
86
86
|
},
|
|
87
87
|
{
|
|
@@ -308,7 +308,7 @@ export const docs = {
|
|
|
308
308
|
{
|
|
309
309
|
guidance: false,
|
|
310
310
|
description:
|
|
311
|
-
"Wrap a disabled NumberInput in Tooltip to explain why it's disabled
|
|
311
|
+
"Wrap a disabled NumberInput in Tooltip to explain why it's disabled. Use the disabledMessage prop, which attaches the reason to the field itself.",
|
|
312
312
|
},
|
|
313
313
|
],
|
|
314
314
|
anatomy: [
|
|
@@ -401,7 +401,7 @@ export const docsZh = {
|
|
|
401
401
|
name: 'isReadOnly',
|
|
402
402
|
type: 'boolean',
|
|
403
403
|
description:
|
|
404
|
-
'将输入框设为只读:值以完整不透明度显示并仍随表单提交,但无法编辑。与 isDisabled
|
|
404
|
+
'将输入框设为只读:值以完整不透明度显示并仍随表单提交,但无法编辑。与 isDisabled 不同,只读输入框不会变暗,并保留其表单值。只读时所有步进方式均被禁用:方向键、滚轮和步进按钮。同时设置时 isDisabled 优先。',
|
|
405
405
|
default: 'false',
|
|
406
406
|
},
|
|
407
407
|
{
|
|
@@ -613,7 +613,7 @@ export const docsZh = {
|
|
|
613
613
|
{
|
|
614
614
|
guidance: false,
|
|
615
615
|
description:
|
|
616
|
-
"Wrap a disabled NumberInput in Tooltip to explain why it's disabled
|
|
616
|
+
"Wrap a disabled NumberInput in Tooltip to explain why it's disabled. Use the disabledMessage prop, which attaches the reason to the field itself.",
|
|
617
617
|
},
|
|
618
618
|
],
|
|
619
619
|
anatomy: [
|
|
@@ -687,7 +687,7 @@ export const docsDense = {
|
|
|
687
687
|
{
|
|
688
688
|
guidance: false,
|
|
689
689
|
description:
|
|
690
|
-
"Wrap a disabled NumberInput in Tooltip to explain why it's disabled
|
|
690
|
+
"Wrap a disabled NumberInput in Tooltip to explain why it's disabled. Use the disabledMessage prop, which attaches the reason to the field itself.",
|
|
691
691
|
},
|
|
692
692
|
],
|
|
693
693
|
anatomy: [
|
|
@@ -737,7 +737,7 @@ export const docsDense = {
|
|
|
737
737
|
isRequired: 'Field required (mutually exclusive w/ isOptional).',
|
|
738
738
|
isDisabled: 'Input disabled.',
|
|
739
739
|
isReadOnly:
|
|
740
|
-
'Read-only: value visible + still submits, but not editable. Unlike isDisabled: not dimmed
|
|
740
|
+
'Read-only: value visible + still submits, but not editable. Unlike isDisabled: not dimmed.',
|
|
741
741
|
disabledMessage:
|
|
742
742
|
'Explains why input is disabled. With isDisabled, shows tooltip on hover/focus + keeps input focusable via aria-disabled (field becomes read-only). Use instead of wrapping a disabled NumberInput in Tooltip.',
|
|
743
743
|
placeholder: 'Placeholder text.',
|
|
@@ -13,6 +13,8 @@ import {describe, it, expect, vi, beforeEach, afterEach} from 'vitest';
|
|
|
13
13
|
import {act, useState} from 'react';
|
|
14
14
|
import {render, screen, fireEvent, waitFor} from '@testing-library/react';
|
|
15
15
|
import userEvent from '@testing-library/user-event';
|
|
16
|
+
import * as stylex from '@stylexjs/stylex';
|
|
17
|
+
import {colorVars} from '../theme/tokens.stylex';
|
|
16
18
|
import {TestIcon} from '../__tests__/TestIcon';
|
|
17
19
|
import {InternationalizationProvider} from '../i18n';
|
|
18
20
|
import {registerIcons, resetIcons} from '../Icon';
|
|
@@ -22,6 +24,21 @@ import {defineTheme} from '../theme/defineTheme';
|
|
|
22
24
|
import {generateThemeCSS} from '../theme/generateThemeRules';
|
|
23
25
|
import {__resetLiveRegionsForTest} from '../hooks/useAnnounce';
|
|
24
26
|
|
|
27
|
+
// jsdom cannot match `:focus-visible`: compare the ring's StyleX class hash.
|
|
28
|
+
const RING = stylex
|
|
29
|
+
.props(
|
|
30
|
+
stylex.create({
|
|
31
|
+
ring: {
|
|
32
|
+
boxShadow: {
|
|
33
|
+
default: null,
|
|
34
|
+
':has(> [aria-disabled="true"]:focus-visible)': `inset 0px 0px 0px 2px ${colorVars['--color-accent-muted']}`,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}).ring,
|
|
38
|
+
)
|
|
39
|
+
.className!.split(' ')
|
|
40
|
+
.pop()!;
|
|
41
|
+
|
|
25
42
|
// FieldStatus announces status messages through the persistent useAnnounce
|
|
26
43
|
// singletons; remove them between tests so role/aria-live queries in this
|
|
27
44
|
// file never match a leftover region.
|
|
@@ -149,7 +166,7 @@ describe('NumberInput', () => {
|
|
|
149
166
|
expect(screen.getByRole('spinbutton')).not.toHaveAttribute('aria-required');
|
|
150
167
|
});
|
|
151
168
|
|
|
152
|
-
it('
|
|
169
|
+
it('exposes aria-disabled, not native disabled, when isDisabled is true (spec:AST-085)', () => {
|
|
153
170
|
render(
|
|
154
171
|
<NumberInput
|
|
155
172
|
label="Quantity"
|
|
@@ -158,7 +175,76 @@ describe('NumberInput', () => {
|
|
|
158
175
|
onChange={() => {}}
|
|
159
176
|
/>,
|
|
160
177
|
);
|
|
161
|
-
expect(screen.getByRole('spinbutton')).
|
|
178
|
+
expect(screen.getByRole('spinbutton')).toHaveAttribute(
|
|
179
|
+
'aria-disabled',
|
|
180
|
+
'true',
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('keeps a disabled input in the tab order and rings it (spec:AST-085 FR1, FR6)', async () => {
|
|
185
|
+
const user = userEvent.setup();
|
|
186
|
+
render(
|
|
187
|
+
<>
|
|
188
|
+
<NumberInput label="First" value={1} onChange={() => {}} />
|
|
189
|
+
<NumberInput label="Second" value={2} onChange={() => {}} isDisabled />
|
|
190
|
+
</>,
|
|
191
|
+
);
|
|
192
|
+
await user.tab();
|
|
193
|
+
await user.tab();
|
|
194
|
+
const input = screen.getByRole('spinbutton', {name: 'Second'});
|
|
195
|
+
expect(input).toHaveFocus();
|
|
196
|
+
expect(input.parentElement).toHaveClass(RING);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('runs no caller handler, steps nothing and submits no form while disabled (spec:AST-085 FR2)', async () => {
|
|
200
|
+
const user = userEvent.setup();
|
|
201
|
+
const handlers = {
|
|
202
|
+
onChange: vi.fn(),
|
|
203
|
+
onEnter: vi.fn(),
|
|
204
|
+
onKeyDown: vi.fn(),
|
|
205
|
+
onPaste: vi.fn(),
|
|
206
|
+
};
|
|
207
|
+
const onSubmit = vi.fn((e: React.FormEvent) => e.preventDefault());
|
|
208
|
+
render(
|
|
209
|
+
<form onSubmit={onSubmit}>
|
|
210
|
+
<NumberInput
|
|
211
|
+
label="Quantity"
|
|
212
|
+
value={5}
|
|
213
|
+
isDisabled
|
|
214
|
+
hasNumberSteppers
|
|
215
|
+
{...handlers}
|
|
216
|
+
/>
|
|
217
|
+
</form>,
|
|
218
|
+
);
|
|
219
|
+
await user.click(screen.getByRole('spinbutton'));
|
|
220
|
+
await user.keyboard('{ArrowUp}{ArrowDown}{Enter}');
|
|
221
|
+
await user.paste('9');
|
|
222
|
+
await user.click(screen.getByRole('button', {name: 'Increment Quantity'}));
|
|
223
|
+
for (const handler of [...Object.values(handlers), onSubmit]) {
|
|
224
|
+
expect(handler).not.toHaveBeenCalled();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('commits nothing when a field disabled mid-entry loses focus (spec:AST-085 FR2)', async () => {
|
|
229
|
+
const user = userEvent.setup();
|
|
230
|
+
const onChange = vi.fn();
|
|
231
|
+
const field = (isDisabled: boolean) => (
|
|
232
|
+
<NumberInput
|
|
233
|
+
label="Quantity"
|
|
234
|
+
value={5}
|
|
235
|
+
onChange={onChange}
|
|
236
|
+
isDisabled={isDisabled}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
239
|
+
const {rerender} = render(field(false));
|
|
240
|
+
const input = screen.getByRole('spinbutton');
|
|
241
|
+
await user.clear(input);
|
|
242
|
+
await user.type(input, '8');
|
|
243
|
+
onChange.mockClear();
|
|
244
|
+
rerender(field(true));
|
|
245
|
+
await user.tab();
|
|
246
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
247
|
+
expect(input).toHaveValue('5');
|
|
162
248
|
});
|
|
163
249
|
|
|
164
250
|
it('does not fire onChange when disabled', async () => {
|
|
@@ -1424,10 +1510,10 @@ describe('NumberInput', () => {
|
|
|
1424
1510
|
const increment = screen.getByRole('button', {
|
|
1425
1511
|
name: 'Increment Quantity',
|
|
1426
1512
|
});
|
|
1427
|
-
expect(increment).
|
|
1513
|
+
expect(increment).toHaveAttribute('aria-disabled', 'true');
|
|
1428
1514
|
expect(
|
|
1429
1515
|
screen.getByRole('button', {name: 'Decrement Quantity'}),
|
|
1430
|
-
).
|
|
1516
|
+
).toHaveAttribute('aria-disabled', 'true');
|
|
1431
1517
|
|
|
1432
1518
|
fireEvent.click(increment);
|
|
1433
1519
|
expect(handleChange).not.toHaveBeenCalled();
|
|
@@ -1446,7 +1532,10 @@ describe('NumberInput', () => {
|
|
|
1446
1532
|
/>
|
|
1447
1533
|
</form>,
|
|
1448
1534
|
);
|
|
1449
|
-
expect(screen.getByRole('spinbutton')).
|
|
1535
|
+
expect(screen.getByRole('spinbutton')).toHaveAttribute(
|
|
1536
|
+
'aria-disabled',
|
|
1537
|
+
'true',
|
|
1538
|
+
);
|
|
1450
1539
|
expect([
|
|
1451
1540
|
...new FormData(container.querySelector('form')!).keys(),
|
|
1452
1541
|
]).toEqual([]);
|
|
@@ -1693,7 +1782,7 @@ describe('NumberInput', () => {
|
|
|
1693
1782
|
expect(onChange).not.toHaveBeenCalled();
|
|
1694
1783
|
});
|
|
1695
1784
|
|
|
1696
|
-
it('
|
|
1785
|
+
it('stays focusable when disabled without a reason', () => {
|
|
1697
1786
|
render(
|
|
1698
1787
|
<NumberInput
|
|
1699
1788
|
label="Quantity"
|
|
@@ -1703,8 +1792,8 @@ describe('NumberInput', () => {
|
|
|
1703
1792
|
/>,
|
|
1704
1793
|
);
|
|
1705
1794
|
const input = screen.getByRole('spinbutton');
|
|
1706
|
-
expect(input).toBeDisabled();
|
|
1707
|
-
expect(input).
|
|
1795
|
+
expect(input).not.toBeDisabled();
|
|
1796
|
+
expect(input).toHaveAttribute('aria-disabled', 'true');
|
|
1708
1797
|
});
|
|
1709
1798
|
});
|
|
1710
1799
|
});
|
|
@@ -2006,14 +2095,14 @@ describe('NumberInput stepping', () => {
|
|
|
2006
2095
|
|
|
2007
2096
|
const input = screen.getByRole('spinbutton');
|
|
2008
2097
|
const increment = screen.getByRole('button', {name: 'Increment Amount'});
|
|
2009
|
-
expect(increment).
|
|
2098
|
+
expect(increment).not.toHaveAttribute('aria-disabled');
|
|
2010
2099
|
|
|
2011
2100
|
fireEvent.click(increment);
|
|
2012
2101
|
|
|
2013
2102
|
expect(input).toHaveValue('99.99');
|
|
2014
2103
|
expect(input).toHaveAttribute('aria-valuenow', '99.99');
|
|
2015
2104
|
expect(input).not.toHaveAttribute('aria-invalid');
|
|
2016
|
-
expect(increment).
|
|
2105
|
+
expect(increment).toHaveAttribute('aria-disabled', 'true');
|
|
2017
2106
|
});
|
|
2018
2107
|
|
|
2019
2108
|
it('allows wheel stepping by default and consumes the focused gesture', () => {
|
|
@@ -2259,10 +2348,33 @@ describe('NumberInput stepping', () => {
|
|
|
2259
2348
|
);
|
|
2260
2349
|
expect(
|
|
2261
2350
|
screen.getByRole('button', {name: 'Increment Quantity'}),
|
|
2262
|
-
).
|
|
2351
|
+
).toHaveAttribute('aria-disabled', 'true');
|
|
2263
2352
|
expect(
|
|
2264
2353
|
screen.getByRole('button', {name: 'Decrement Quantity'}),
|
|
2265
|
-
).not.
|
|
2354
|
+
).not.toHaveAttribute('aria-disabled');
|
|
2355
|
+
});
|
|
2356
|
+
|
|
2357
|
+
it('commits nothing from a click on the stepper at the reached boundary (spec:AST-085 FR2)', async () => {
|
|
2358
|
+
const user = userEvent.setup();
|
|
2359
|
+
const onChange = vi.fn();
|
|
2360
|
+
render(
|
|
2361
|
+
<NumberInput
|
|
2362
|
+
label="Quantity"
|
|
2363
|
+
value={5}
|
|
2364
|
+
onChange={onChange}
|
|
2365
|
+
min={0}
|
|
2366
|
+
max={10}
|
|
2367
|
+
hasNumberSteppers
|
|
2368
|
+
/>,
|
|
2369
|
+
);
|
|
2370
|
+
const input = screen.getByRole('spinbutton');
|
|
2371
|
+
await user.clear(input);
|
|
2372
|
+
await user.type(input, '10');
|
|
2373
|
+
onChange.mockClear();
|
|
2374
|
+
await user.click(
|
|
2375
|
+
screen.getByRole('button', {name: 'Increment Quantity'}),
|
|
2376
|
+
);
|
|
2377
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
2266
2378
|
});
|
|
2267
2379
|
|
|
2268
2380
|
it('disables both steppers with the input', () => {
|
|
@@ -2277,10 +2389,10 @@ describe('NumberInput stepping', () => {
|
|
|
2277
2389
|
);
|
|
2278
2390
|
expect(
|
|
2279
2391
|
screen.getByRole('button', {name: 'Increment Quantity'}),
|
|
2280
|
-
).
|
|
2392
|
+
).toHaveAttribute('aria-disabled', 'true');
|
|
2281
2393
|
expect(
|
|
2282
2394
|
screen.getByRole('button', {name: 'Decrement Quantity'}),
|
|
2283
|
-
).
|
|
2395
|
+
).toHaveAttribute('aria-disabled', 'true');
|
|
2284
2396
|
});
|
|
2285
2397
|
});
|
|
2286
2398
|
});
|
|
@@ -53,6 +53,7 @@ import {useTooltip} from '../Tooltip';
|
|
|
53
53
|
import {getInputARIA} from '../utils';
|
|
54
54
|
import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
|
|
55
55
|
import {usePressFeedback} from '../hooks/usePressFeedback';
|
|
56
|
+
import {inputDisabledFocusStyles} from '../Field/inputDisabledFocus';
|
|
56
57
|
import {useSize} from '../SizeContext/SizeContext';
|
|
57
58
|
import {useInputContainer} from '../hooks/useInputContainer';
|
|
58
59
|
import {useInputStatusIcon} from '../hooks/useInputStatusIcon';
|
|
@@ -261,7 +262,7 @@ interface NumberInputPropsBase extends Omit<
|
|
|
261
262
|
* Whether the input is read-only.
|
|
262
263
|
* The value is shown at full opacity and still submits with the form, but
|
|
263
264
|
* cannot be edited. Unlike `isDisabled`, a read-only input is not dimmed and
|
|
264
|
-
*
|
|
265
|
+
* keeps its form value — use it for a value the user should see and send
|
|
265
266
|
* but not change. Stepping is off in every form while read-only: arrow keys,
|
|
266
267
|
* the wheel, and the number steppers. `isDisabled` takes precedence when both
|
|
267
268
|
* are set.
|
|
@@ -275,8 +276,8 @@ interface NumberInputPropsBase extends Omit<
|
|
|
275
276
|
* keyboard and assistive technology. The field cannot be edited (it becomes
|
|
276
277
|
* read-only) while disabled.
|
|
277
278
|
*
|
|
278
|
-
* Use this instead of wrapping a disabled input in `Tooltip
|
|
279
|
-
*
|
|
279
|
+
* Use this instead of wrapping a disabled input in `Tooltip`, so the reason
|
|
280
|
+
* is attached to the field itself.
|
|
280
281
|
*
|
|
281
282
|
* @example
|
|
282
283
|
* ```
|
|
@@ -600,12 +601,20 @@ export function NumberInput({
|
|
|
600
601
|
const [pendingInput, setPendingInput] = useState<string | null>(null);
|
|
601
602
|
const [isFocused, setIsFocused] = useState(false);
|
|
602
603
|
|
|
603
|
-
// Disabled-reason tooltip.
|
|
604
|
-
// tooltip listeners attach to the input container (which already exists) and
|
|
604
|
+
// Disabled-reason tooltip. The tooltip listeners attach to the input container (which already exists) and
|
|
605
605
|
// the input stays perceivable via aria-disabled instead of the native
|
|
606
606
|
// disabled attribute. The field is made read-only so it can't be typed into,
|
|
607
607
|
// and value mutation is blocked by the isDisabled guard in the handlers.
|
|
608
608
|
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
609
|
+
// A disabled field keeps its tab stop but, like a natively disabled one,
|
|
610
|
+
// runs no caller event handler other than focus and blur (`spec:AST-085` FR2).
|
|
611
|
+
const fieldProps = isDisabled
|
|
612
|
+
? Object.fromEntries(
|
|
613
|
+
Object.entries(rest).filter(
|
|
614
|
+
([key]) => !/^on[A-Z]/.test(key) || /^on(Focus|Blur)/.test(key),
|
|
615
|
+
),
|
|
616
|
+
)
|
|
617
|
+
: rest;
|
|
609
618
|
const disabledMessageTooltip = useTooltip({
|
|
610
619
|
placement: 'above',
|
|
611
620
|
// The container div is not naturally focusable; focusin bubbles up from
|
|
@@ -699,6 +708,12 @@ export function NumberInput({
|
|
|
699
708
|
if (pendingInput === null) {
|
|
700
709
|
return;
|
|
701
710
|
}
|
|
711
|
+
if (isDisabled) {
|
|
712
|
+
// A field disabled mid-entry commits nothing; its draft is dropped, as
|
|
713
|
+
// a natively disabled field's was (spec:AST-085 FR2).
|
|
714
|
+
setPendingInput(null);
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
702
717
|
|
|
703
718
|
const decision = resolveNumberInputCommit(pendingInput, {
|
|
704
719
|
min,
|
|
@@ -722,7 +737,17 @@ export function NumberInput({
|
|
|
722
737
|
onChange(decision.value);
|
|
723
738
|
}
|
|
724
739
|
},
|
|
725
|
-
[
|
|
740
|
+
[
|
|
741
|
+
hasClear,
|
|
742
|
+
isDisabled,
|
|
743
|
+
isIntegerOnly,
|
|
744
|
+
locale,
|
|
745
|
+
max,
|
|
746
|
+
min,
|
|
747
|
+
onChange,
|
|
748
|
+
pendingInput,
|
|
749
|
+
value,
|
|
750
|
+
],
|
|
726
751
|
);
|
|
727
752
|
|
|
728
753
|
// Blur ends the edit and displays the resulting committed value.
|
|
@@ -780,6 +805,13 @@ export function NumberInput({
|
|
|
780
805
|
// Handle keyboard events
|
|
781
806
|
const handleKeyDown = useCallback(
|
|
782
807
|
(e: KeyboardEvent<HTMLInputElement>) => {
|
|
808
|
+
if (isDisabled) {
|
|
809
|
+
// A read-only field still submits its form on Enter.
|
|
810
|
+
if (e.key === 'Enter') {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
}
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
783
815
|
// The field is type="text" for formatted display, so an IME can compose
|
|
784
816
|
// into it: Enter commits the candidate and the arrows walk the candidate
|
|
785
817
|
// window. The composing keydown fires before compositionend, so without
|
|
@@ -804,7 +836,7 @@ export function NumberInput({
|
|
|
804
836
|
}
|
|
805
837
|
onKeyDown?.(e);
|
|
806
838
|
},
|
|
807
|
-
[commitPendingInput, onEnter, onKeyDown, stepValue],
|
|
839
|
+
[commitPendingInput, isDisabled, onEnter, onKeyDown, stepValue],
|
|
808
840
|
);
|
|
809
841
|
|
|
810
842
|
// React's delegated wheel listener can be passive, so use a native,
|
|
@@ -902,6 +934,7 @@ export function NumberInput({
|
|
|
902
934
|
hasNumberSteppers && styles.wrapperWithNumberSteppers,
|
|
903
935
|
sizeStyles[size],
|
|
904
936
|
isDisabled && inputWrapperStyles.disabled,
|
|
937
|
+
isDisabled && inputDisabledFocusStyles.ring,
|
|
905
938
|
status && inputStatusBorderStyles[status.type],
|
|
906
939
|
status && !isDisabled && inputStatusHoverShadowStyles[status.type],
|
|
907
940
|
status && inputStatusFocusWithinStyles[status.type],
|
|
@@ -914,7 +947,7 @@ export function NumberInput({
|
|
|
914
947
|
{startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'secondary'})}
|
|
915
948
|
{inputGroup && <VisuallyHidden id={inputLabelID}>{label}</VisuallyHidden>}
|
|
916
949
|
<input
|
|
917
|
-
{...
|
|
950
|
+
{...fieldProps}
|
|
918
951
|
ref={mergedInputRef}
|
|
919
952
|
id={id}
|
|
920
953
|
name={isDisabled || formatValue ? undefined : htmlName}
|
|
@@ -928,12 +961,11 @@ export function NumberInput({
|
|
|
928
961
|
onBlur={handleBlur}
|
|
929
962
|
onKeyDown={handleKeyDown}
|
|
930
963
|
placeholder={placeholder}
|
|
931
|
-
//
|
|
932
|
-
//
|
|
933
|
-
//
|
|
934
|
-
disabled={isDisabled
|
|
935
|
-
|
|
936
|
-
readOnly={isReadOnly || showsDisabledMessage || undefined}
|
|
964
|
+
// A disabled input keeps its place in the tab order (spec:AST-085):
|
|
965
|
+
// aria-disabled instead of the native attribute, with readOnly + the
|
|
966
|
+
// handler guards keeping the value from changing.
|
|
967
|
+
aria-disabled={isDisabled ? 'true' : undefined}
|
|
968
|
+
readOnly={isReadOnly || isDisabled || undefined}
|
|
937
969
|
autoFocus={hasAutoFocus}
|
|
938
970
|
data-autofocus={hasAutoFocus || undefined}
|
|
939
971
|
aria-valuemin={min ?? undefined}
|
|
@@ -992,10 +1024,17 @@ export function NumberInput({
|
|
|
992
1024
|
type="button"
|
|
993
1025
|
tabIndex={-1}
|
|
994
1026
|
{...pressable}
|
|
995
|
-
disabled={
|
|
1027
|
+
aria-disabled={
|
|
1028
|
+
isDisabled || isReadOnly || !canIncrement || undefined
|
|
1029
|
+
}
|
|
996
1030
|
aria-label={t('@astryx.numberInput.incrementLabel', {label})}
|
|
997
1031
|
onPointerDown={event => event.preventDefault()}
|
|
998
1032
|
onClick={() => {
|
|
1033
|
+
// An aria-disabled stepper does nothing, as a natively disabled
|
|
1034
|
+
// one did (spec:AST-085 FR2).
|
|
1035
|
+
if (isDisabled || isReadOnly || !canIncrement) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
999
1038
|
inputRef.current?.focus();
|
|
1000
1039
|
stepValue(1);
|
|
1001
1040
|
}}
|
|
@@ -1016,10 +1055,17 @@ export function NumberInput({
|
|
|
1016
1055
|
type="button"
|
|
1017
1056
|
tabIndex={-1}
|
|
1018
1057
|
{...pressable}
|
|
1019
|
-
disabled={
|
|
1058
|
+
aria-disabled={
|
|
1059
|
+
isDisabled || isReadOnly || !canDecrement || undefined
|
|
1060
|
+
}
|
|
1020
1061
|
aria-label={t('@astryx.numberInput.decrementLabel', {label})}
|
|
1021
1062
|
onPointerDown={event => event.preventDefault()}
|
|
1022
1063
|
onClick={() => {
|
|
1064
|
+
// An aria-disabled stepper does nothing, as a natively disabled
|
|
1065
|
+
// one did (spec:AST-085 FR2).
|
|
1066
|
+
if (isDisabled || isReadOnly || !canDecrement) {
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1023
1069
|
inputRef.current?.focus();
|
|
1024
1070
|
stepValue(-1);
|
|
1025
1071
|
}}
|
|
@@ -965,7 +965,7 @@ describe('Pagination', () => {
|
|
|
965
965
|
/>,
|
|
966
966
|
);
|
|
967
967
|
const box = screen.getByRole('spinbutton', {name: 'Go to page'});
|
|
968
|
-
expect(box).
|
|
968
|
+
expect(box).toHaveAttribute('aria-disabled', 'true');
|
|
969
969
|
// Disabled input never fires a change.
|
|
970
970
|
await user.type(box, '5{Enter}');
|
|
971
971
|
expect(onChange).not.toHaveBeenCalled();
|
|
@@ -999,7 +999,7 @@ describe('Pagination', () => {
|
|
|
999
999
|
// editable box is inert rather than accepting entries it can't resolve.
|
|
1000
1000
|
expect(
|
|
1001
1001
|
screen.getByRole('spinbutton', {name: 'Go to page'}),
|
|
1002
|
-
).
|
|
1002
|
+
).toHaveAttribute('aria-disabled', 'true');
|
|
1003
1003
|
});
|
|
1004
1004
|
|
|
1005
1005
|
it('renders the localized "Page" label by default and a custom pageLabel', () => {
|