@astryxdesign/core 0.7.2-canary.b06a093 → 0.7.2-canary.c5f72ea

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.
@@ -159,7 +159,7 @@ export interface SwitchProps extends Omit<BaseProps, 'onChange'> {
159
159
  * />
160
160
  * ```
161
161
  */
162
- export declare function Switch({ label, isLabelHidden, description, onChange, changeAction, isLoading, value, isDisabled, htmlName, disabledMessage, isOptional, isRequired, onFocus, onBlur, labelIcon, labelTooltip, labelPosition, labelSpacing, status, size, width, xstyle, className, style, ref, 'aria-describedby': ariaDescribedByProp, ...rest }: SwitchProps): import("react").JSX.Element;
162
+ export declare function Switch({ label, isLabelHidden, description, onChange, changeAction, isLoading, value, isDisabled, htmlName, disabledMessage, isOptional, isRequired, onFocus, onBlur, labelIcon, labelTooltip, labelPosition, labelSpacing, status, size, width, xstyle, className, style, ref, 'aria-describedby': ariaDescribedByProp, 'aria-labelledby': ariaLabelledByProp, ...rest }: SwitchProps): import("react").JSX.Element;
163
163
  export declare namespace Switch {
164
164
  var displayName: string;
165
165
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/Switch/Switch.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAcf,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAMhD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAkV9C,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,KAAK,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,CAA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,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB;AAOD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,SAAiB,EACjB,KAAK,EACL,UAAkB,EAClB,QAAQ,EACR,eAAe,EACf,UAAkB,EAClB,UAAkB,EAClB,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,aAAqB,EACrB,YAAoB,EACpB,MAAM,EACN,IAAW,EACX,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,kBAAkB,EAAE,mBAAmB,EACvC,iBAAiB,EAAE,kBAAkB,EACrC,GAAG,IAAI,EACR,EAAE,WAAW,+BAiOb;yBA9Pe,MAAM"}
@@ -292,6 +292,7 @@ export function Switch({
292
292
  style,
293
293
  ref,
294
294
  'aria-describedby': ariaDescribedByProp,
295
+ 'aria-labelledby': ariaLabelledByProp,
295
296
  ...rest
296
297
  }) {
297
298
  const t = useTranslator();
@@ -388,7 +389,12 @@ export function Switch({
388
389
  }
389
390
  },
390
391
  onFocus: onFocus,
391
- onBlur: onBlur,
392
+ onBlur: onBlur
393
+ // A caller's `aria-labelledby` names the control (a visible title
394
+ // elsewhere in the row, for example), so it reaches the input rather
395
+ // than the field wrapper via `...rest`.
396
+ ,
397
+ "aria-labelledby": ariaLabelledByProp,
392
398
  "aria-describedby": ariaDescribedBy,
393
399
  "aria-invalid": status?.type === 'error' ? true : undefined,
394
400
  "aria-busy": isBusy || undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/core",
3
- "version": "0.7.2-canary.b06a093",
3
+ "version": "0.7.2-canary.c5f72ea",
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",
@@ -787,8 +787,8 @@
787
787
  "react-dom": ">=19.0.0"
788
788
  },
789
789
  "devDependencies": {
790
- "@astryxdesign/a11y-spec": "0.7.2-canary.b06a093",
791
- "@astryxdesign/cli": "0.7.2-canary.b06a093",
790
+ "@astryxdesign/a11y-spec": "0.7.2-canary.c5f72ea",
791
+ "@astryxdesign/cli": "0.7.2-canary.c5f72ea",
792
792
  "@babel/cli": "^7.29.7",
793
793
  "@babel/core": "^7.29.7",
794
794
  "@babel/preset-react": "^7.29.7",
@@ -12,8 +12,9 @@ export const docs = {
12
12
  props: [
13
13
  {
14
14
  name: 'label',
15
- type: 'string',
16
- description: 'Primary text.',
15
+ type: 'ReactNode',
16
+ description:
17
+ 'Primary content. A plain string gets single-line truncation automatically; a ReactNode renders as given, so child components control their own text behavior.',
17
18
  required: true,
18
19
  },
19
20
  {
@@ -123,8 +124,9 @@ export const docsZh = {
123
124
  props: [
124
125
  {
125
126
  name: 'label',
126
- type: 'string',
127
- description: '主要文本。',
127
+ type: 'ReactNode',
128
+ description:
129
+ '主要内容。纯字符串会自动应用单行截断;ReactNode 按原样渲染,由子组件自行控制文本行为。',
128
130
  required: true,
129
131
  },
130
132
  {
@@ -205,7 +207,8 @@ export const docsDense = {
205
207
  description:
206
208
  'List item w/ label, description, start/end content slots, interactive patterns.',
207
209
  propDescriptions: {
208
- label: 'Primary text.',
210
+ label:
211
+ 'Primary content. String auto-truncates; ReactNode renders as given.',
209
212
  description: 'Secondary text below label.',
210
213
  startContent: 'Content before label area (e.g. icon, avatar).',
211
214
  endContent: 'Content after label area (e.g. badge, chevron).',
@@ -862,6 +862,27 @@ describe('Switch', () => {
862
862
  const root = container.querySelector('[data-testid="my-switch"]');
863
863
  expect(root).not.toHaveAttribute('aria-describedby');
864
864
  });
865
+
866
+ it('names the switch control from a caller aria-labelledby', () => {
867
+ const {container} = render(
868
+ <>
869
+ <span id="row-title">Release notes</span>
870
+ <Switch
871
+ label="Pin Release notes"
872
+ isLabelHidden
873
+ value={false}
874
+ onChange={() => {}}
875
+ data-testid="my-switch"
876
+ aria-labelledby="row-title"
877
+ />
878
+ </>,
879
+ );
880
+ const control = screen.getByRole('switch', {name: 'Release notes'});
881
+ expect(control).toHaveAttribute('aria-labelledby', 'row-title');
882
+ // The id reference lives on the control only, not on the field wrapper.
883
+ const root = container.querySelector('[data-testid="my-switch"]');
884
+ expect(root).not.toHaveAttribute('aria-labelledby');
885
+ });
865
886
  });
866
887
 
867
888
  describe('pressed state', () => {
@@ -567,6 +567,7 @@ export function Switch({
567
567
  style,
568
568
  ref,
569
569
  'aria-describedby': ariaDescribedByProp,
570
+ 'aria-labelledby': ariaLabelledByProp,
570
571
  ...rest
571
572
  }: SwitchProps) {
572
573
  const t = useTranslator();
@@ -664,6 +665,10 @@ export function Switch({
664
665
  }}
665
666
  onFocus={onFocus}
666
667
  onBlur={onBlur}
668
+ // A caller's `aria-labelledby` names the control (a visible title
669
+ // elsewhere in the row, for example), so it reaches the input rather
670
+ // than the field wrapper via `...rest`.
671
+ aria-labelledby={ariaLabelledByProp}
667
672
  aria-describedby={ariaDescribedBy}
668
673
  aria-invalid={status?.type === 'error' ? true : undefined}
669
674
  aria-busy={isBusy || undefined}