@astryxdesign/core 0.1.8-canary.3290b8a → 0.1.8-canary.351a2f5
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/CheckboxList/CheckboxListItem.d.ts +20 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +18 -2
- package/dist/astryx.umd.js +24 -24
- package/dist/astryx.umd.js.map +3 -3
- package/package.json +1 -1
- package/src/CheckboxList/CheckboxList.test.tsx +72 -2
- package/src/CheckboxList/CheckboxListItem.doc.mjs +33 -5
- package/src/CheckboxList/CheckboxListItem.tsx +50 -6
|
@@ -22,6 +22,25 @@ export interface CheckboxListItemProps extends BaseProps<HTMLLIElement> {
|
|
|
22
22
|
* child components control their own text behavior).
|
|
23
23
|
*/
|
|
24
24
|
label: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Plain-text accessible name for the checkbox when `label` is a ReactNode.
|
|
27
|
+
*
|
|
28
|
+
* A string `label` names the checkbox automatically. A rich (ReactNode)
|
|
29
|
+
* `label` cannot, so pass a concise string equivalent via the standard
|
|
30
|
+
* `aria-label` — otherwise the checkbox falls back to the generic name
|
|
31
|
+
* "Checkbox" and every rich-label item in a list announces identically to
|
|
32
|
+
* screen readers. Applied to the checkbox control, not the row.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```
|
|
36
|
+
* <CheckboxListItem
|
|
37
|
+
* label={<span>Pro plan <Badge label="Recommended" /></span>}
|
|
38
|
+
* aria-label="Pro plan"
|
|
39
|
+
* value="pro"
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
'aria-label'?: string;
|
|
25
44
|
/**
|
|
26
45
|
* Identity key for collection mode (REQUIRED inside CheckboxList).
|
|
27
46
|
* Throws a runtime error if missing when used inside CheckboxList.
|
|
@@ -83,7 +102,7 @@ export interface CheckboxListItemProps extends BaseProps<HTMLLIElement> {
|
|
|
83
102
|
* />
|
|
84
103
|
* ```
|
|
85
104
|
*/
|
|
86
|
-
export declare function CheckboxListItem({ label, value, description, endContent, isDisabled: isItemDisabled, isLoading: isItemLoading, isChecked, onCheck, ref, xstyle, className, style, onClick: onClickProp, ...restProps }: CheckboxListItemProps): import("react").JSX.Element;
|
|
105
|
+
export declare function CheckboxListItem({ label, 'aria-label': ariaLabel, value, description, endContent, isDisabled: isItemDisabled, isLoading: isItemLoading, isChecked, onCheck, ref, xstyle, className, style, onClick: onClickProp, ...restProps }: CheckboxListItemProps): import("react").JSX.Element;
|
|
87
106
|
export declare namespace CheckboxListItem {
|
|
88
107
|
var displayName: string;
|
|
89
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxListItem.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckboxListItem.d.ts","sourceRoot":"","sources":["../../src/CheckboxList/CheckboxListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAA0C,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAI9E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAsB5C,MAAM,WAAW,qBAAsB,SAAQ,SAAS,CAAC,aAAa,CAAC;IACrE;;;;;;OAMG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;CAChC;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,KAAK,EACL,WAAW,EACX,UAAU,EACV,UAAU,EAAE,cAAsB,EAClC,SAAS,EAAE,aAAqB,EAChC,SAAS,EACT,OAAO,EACP,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EAAE,WAAW,EACpB,GAAG,SAAS,EACb,EAAE,qBAAqB,+BAsIvB;yBAtJe,gBAAgB"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - /apps/storybook/stories/CheckboxList.stories.tsx
|
|
16
16
|
* - /packages/cli/templates/blocks/components/CheckboxList/ (showcase blocks)
|
|
17
17
|
*/
|
|
18
|
-
import { use } from 'react';
|
|
18
|
+
import { use, useEffect, useRef } from 'react';
|
|
19
19
|
import * as stylex from '@stylexjs/stylex';
|
|
20
20
|
import "../theme/tokens.stylex.js";
|
|
21
21
|
import { colorVars } from "../theme/tokens.stylex.js";
|
|
@@ -67,6 +67,7 @@ const styles = {
|
|
|
67
67
|
*/
|
|
68
68
|
export function CheckboxListItem({
|
|
69
69
|
label,
|
|
70
|
+
'aria-label': ariaLabel,
|
|
70
71
|
value,
|
|
71
72
|
description,
|
|
72
73
|
endContent,
|
|
@@ -87,6 +88,21 @@ export function CheckboxListItem({
|
|
|
87
88
|
throw new Error('CheckboxListItem requires a `value` prop when used inside CheckboxList with a value array.');
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
// Accessible name for the (visually hidden) checkbox label. A string
|
|
92
|
+
// `label` names it directly; a rich label needs `aria-label`.
|
|
93
|
+
const checkboxLabel = ariaLabel ?? (typeof label === 'string' ? label : t('@astryx.checkboxList.item.checkbox'));
|
|
94
|
+
|
|
95
|
+
// Dev-time guardrail: a rich label without `aria-label` leaves the
|
|
96
|
+
// checkbox with the generic name "Checkbox". Warn once per item instance
|
|
97
|
+
// (in an effect) rather than on every render.
|
|
98
|
+
const warnedUnnamedCheckboxRef = useRef(false);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (typeof label !== 'string' && ariaLabel == null && !warnedUnnamedCheckboxRef.current) {
|
|
101
|
+
warnedUnnamedCheckboxRef.current = true;
|
|
102
|
+
console.warn('CheckboxListItem: `label` is a ReactNode, so the checkbox falls ' + 'back to the generic accessible name "Checkbox". Pass ' + '`aria-label` with a concise string equivalent of the visible ' + 'label so screen readers can tell items apart.');
|
|
103
|
+
}
|
|
104
|
+
}, [label, ariaLabel]);
|
|
105
|
+
|
|
90
106
|
// Density from list context for checkbox sizing
|
|
91
107
|
const listCtx = use(ListContext);
|
|
92
108
|
const density = listCtx?.density ?? 'balanced';
|
|
@@ -144,7 +160,7 @@ export function CheckboxListItem({
|
|
|
144
160
|
className: className,
|
|
145
161
|
style: style,
|
|
146
162
|
startContent: /*#__PURE__*/_jsx(CheckboxInput, {
|
|
147
|
-
label:
|
|
163
|
+
label: checkboxLabel,
|
|
148
164
|
isLabelHidden: true,
|
|
149
165
|
value: resolvedChecked,
|
|
150
166
|
onChange: () => handleToggle(),
|