@elliemae/ds-form-toggle 3.80.0-next.72 → 3.80.0-next.75

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.
Files changed (44) hide show
  1. package/dist/cjs/config/useDSControlledToggle.js +3 -2
  2. package/dist/cjs/config/useDSControlledToggle.js.map +2 -2
  3. package/dist/cjs/config/useGetButtonProps.js +49 -11
  4. package/dist/cjs/config/useGetButtonProps.js.map +2 -2
  5. package/dist/cjs/constants/index.js +1 -0
  6. package/dist/cjs/constants/index.js.map +2 -2
  7. package/dist/cjs/parts/Button.js +3 -2
  8. package/dist/cjs/parts/Button.js.map +2 -2
  9. package/dist/cjs/parts/Container.js +32 -4
  10. package/dist/cjs/parts/Container.js.map +2 -2
  11. package/dist/cjs/parts/styles/styles.js +21 -21
  12. package/dist/cjs/parts/styles/styles.js.map +2 -2
  13. package/dist/cjs/parts/wcagViolation/Button.wcagViolationLabels.js +12 -2
  14. package/dist/cjs/parts/wcagViolation/Button.wcagViolationLabels.js.map +2 -2
  15. package/dist/cjs/react-desc-prop-types.js +15 -3
  16. package/dist/cjs/react-desc-prop-types.js.map +2 -2
  17. package/dist/cjs/typescript-testing/form-toggle-typescript-valid.js +24 -1
  18. package/dist/cjs/typescript-testing/form-toggle-typescript-valid.js.map +3 -3
  19. package/dist/cjs/typescript-testing/slot-props.js +2 -0
  20. package/dist/cjs/typescript-testing/slot-props.js.map +2 -2
  21. package/dist/esm/config/useDSControlledToggle.js +3 -2
  22. package/dist/esm/config/useDSControlledToggle.js.map +2 -2
  23. package/dist/esm/config/useGetButtonProps.js +49 -11
  24. package/dist/esm/config/useGetButtonProps.js.map +2 -2
  25. package/dist/esm/constants/index.js +1 -0
  26. package/dist/esm/constants/index.js.map +2 -2
  27. package/dist/esm/parts/Button.js +3 -2
  28. package/dist/esm/parts/Button.js.map +2 -2
  29. package/dist/esm/parts/Container.js +34 -6
  30. package/dist/esm/parts/Container.js.map +2 -2
  31. package/dist/esm/parts/styles/styles.js +22 -22
  32. package/dist/esm/parts/styles/styles.js.map +2 -2
  33. package/dist/esm/parts/wcagViolation/Button.wcagViolationLabels.js +12 -2
  34. package/dist/esm/parts/wcagViolation/Button.wcagViolationLabels.js.map +2 -2
  35. package/dist/esm/react-desc-prop-types.js +15 -3
  36. package/dist/esm/react-desc-prop-types.js.map +2 -2
  37. package/dist/esm/typescript-testing/form-toggle-typescript-valid.js +24 -1
  38. package/dist/esm/typescript-testing/form-toggle-typescript-valid.js.map +3 -3
  39. package/dist/esm/typescript-testing/slot-props.js +2 -0
  40. package/dist/esm/typescript-testing/slot-props.js.map +2 -2
  41. package/dist/types/constants/index.d.ts +2 -0
  42. package/dist/types/parts/styles/styles.d.ts +4 -0
  43. package/dist/types/react-desc-prop-types.d.ts +4 -0
  44. package/package.json +8 -8
@@ -39,10 +39,13 @@ var import_constants = require("./constants/index.js");
39
39
  const defaultProps = {
40
40
  checked: false,
41
41
  onChange: () => null,
42
+ onValueChange: () => null,
42
43
  size: import_constants.TOGGLE_SIZES.MEDIUM,
43
44
  readOnly: false,
44
45
  disabled: false,
45
- applyAriaDisabled: false
46
+ applyAriaDisabled: false,
47
+ hasError: false,
48
+ makeSubmittable: false
46
49
  };
47
50
  const DSControlledTogglePropTypes = {
48
51
  ...import_ds_props_helpers.globalAttributesPropTypes,
@@ -50,12 +53,21 @@ const DSControlledTogglePropTypes = {
50
53
  ...(0, import_ds_props_helpers.getPropsPerSlotPropTypes)(import_constants.DSControlledToggleName, import_constants.CONTROLLED_TOGGLE_SLOTS),
51
54
  checked: import_ds_props_helpers.PropTypes.bool.description("Whether the toggle is checked or not").defaultValue("false"),
52
55
  onChange: import_ds_props_helpers.PropTypes.func.description("OnClick callback").defaultValue("() => null"),
56
+ onValueChange: import_ds_props_helpers.PropTypes.func.description(
57
+ "Callback triggered when the user toggles it, it receives the new checked state. It is not triggered when disabled, readOnly or applyAriaDisabled."
58
+ ).defaultValue("() => null").signature("((newChecked: boolean, e: React.MouseEvent | React.KeyboardEvent) => void)"),
53
59
  size: import_ds_props_helpers.PropTypes.oneOf(["s", "m", "l"]).description("Size of toggle").defaultValue(import_constants.TOGGLE_SIZES.MEDIUM),
54
60
  disabled: import_ds_props_helpers.PropTypes.bool.description("Whether the toggle is disabled or not").defaultValue("false"),
55
61
  applyAriaDisabled: import_ds_props_helpers.PropTypes.bool.description(
56
- "Whether to apply disabled styling and announce as disabled in SR. CAN STILL RECEIVE FOCUS. PREVENTS ONLY MAIN ACTION."
62
+ "Whether to apply disabled styling and announce as disabled in SR. CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE CONSUMER HANDLERS FOR THEM."
63
+ ).defaultValue("false"),
64
+ readOnly: import_ds_props_helpers.PropTypes.bool.description(
65
+ 'Soft lock, same as applyAriaDisabled: aria-disabled="true", CAN STILL RECEIVE FOCUS, IGNORES EVERY ACTION (click, Enter, Space) AND THE CONSUMER HANDLERS FOR THEM. Also announces "Read only" through a hidden description. Dimsum never writes aria-readonly.'
66
+ ).defaultValue("false"),
67
+ hasError: import_ds_props_helpers.PropTypes.bool.description("Whether the toggle has error or not. When true the borders use the error color.").defaultValue("false"),
68
+ makeSubmittable: import_ds_props_helpers.PropTypes.bool.description(
69
+ "Renders a hidden checkbox input so the toggle can be submitted by a native form. When true, name and value are applied to the hidden input instead of the button."
57
70
  ).defaultValue("false"),
58
- readOnly: import_ds_props_helpers.PropTypes.bool.description("Whether the toggle is readOnly or not").defaultValue("false"),
59
71
  containerProps: import_ds_props_helpers.PropTypes.object.description("Set of properties attached to the main container"),
60
72
  id: import_ds_props_helpers.PropTypes.string.description("Unique id."),
61
73
  innerRef: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.func, import_ds_props_helpers.PropTypes.object]).description("Toggle button ref."),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/react-desc-prop-types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type React from 'react';\nimport type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport type { DSPropTypesSchema, GlobalAttributesT, ValidationMap, XstyledProps } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n getPropsPerSlotPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { TOGGLE_SIZES, DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from './constants/index.js';\n\nexport declare namespace DSControlledToggleT {\n export type ToggleSize = ObjectValues<typeof TOGGLE_SIZES>;\n\n // One entry per slot in CONTROLLED_TOGGLE_SLOTS \u2014 the function (dynamic) form of slot props.\n // Exhaustiveness against the slots is enforced in typescript-testing/slot-props.ts.\n export type SlotFunctionArguments = {\n dsFormtoggleButtonContentWrapper: () => object;\n dsFormtoggleCircle: () => object;\n dsFormtoggleTextWrapper: () => object;\n // legacy slot aliases \u2014 still injection points, see KNOWN_INTENTIONAL_DEVIATIONS.md\n dsFormtoggleControlledContainer: () => object;\n dsFormtoggleToggleCheckbox: () => object;\n };\n\n export interface DefaultProps {\n checked: boolean;\n onChange: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;\n size: ToggleSize;\n readOnly: boolean;\n disabled: boolean;\n applyAriaDisabled: boolean;\n }\n\n export interface RequiredProps {}\n\n export interface OptionalProps extends TypescriptHelpersT.PropsForGlobalOnSlots<\n typeof DSControlledToggleName,\n typeof CONTROLLED_TOGGLE_SLOTS\n > {\n containerProps?: Record<string, unknown>;\n id?: string;\n /**\n * Ref forwarded to the focusable toggle button (role=\"switch\"). Mirrors the innerRef\n * contract of DSControlledRadio / DSControlledCheckbox so consumers (e.g. ds-data-table\n * custom cells) can reach the real focusable node for keyboard focus management.\n */\n innerRef?: React.MutableRefObject<HTMLButtonElement | null> | React.RefCallback<HTMLButtonElement>;\n }\n\n // this interface is the \"last chance\" for apps to keep using the deprecated props before the major release that will remove them\n // this is meant to \"break\" those using the old prop, but still allow a last chance to gradually update (requiring them to change the prop name)\n export interface PostDeprecationETAPropsFallback {\n /**\n * @deprecated a custom wcagViolationLabelOn violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n wcagViolationLabelOn?: string; // used to be \"labelOn\"\n /**\n * @deprecated a custom wcagViolationLabelOff violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n wcagViolationLabelOff?: string; // used to be \"labelOff\"\n }\n export interface PreDeprecationETAProps {\n /**\n * @deprecated a custom wcagViolationLabelOn violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n labelOn?: string; // used to be \"labelOn\"\n /**\n * @deprecated a custom wcagViolationLabelOff violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n labelOff?: string; // used to be \"labelOff\"\n }\n\n export interface ButtonV3InherithedProps extends Omit<DSButtonV3T.Props, 'size' | 'children'> {}\n\n export interface Props\n extends\n Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps,\n PreDeprecationETAProps,\n PostDeprecationETAPropsFallback {}\n\n export interface InternalProps\n extends\n DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps,\n PreDeprecationETAProps,\n PostDeprecationETAPropsFallback {}\n}\n\nexport const defaultProps: DSControlledToggleT.DefaultProps = {\n checked: false,\n onChange: () => null,\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n};\n\nexport const DSControlledTogglePropTypes: DSPropTypesSchema<\n Omit<DSControlledToggleT.Props, keyof DSControlledToggleT.PostDeprecationETAPropsFallback> &\n DSControlledToggleT.PreDeprecationETAProps\n> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n ...getPropsPerSlotPropTypes(DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS),\n checked: PropTypes.bool.description('Whether the toggle is checked or not').defaultValue('false'),\n onChange: PropTypes.func.description('OnClick callback').defaultValue('() => null'),\n size: PropTypes.oneOf(['s', 'm', 'l']).description('Size of toggle').defaultValue(TOGGLE_SIZES.MEDIUM),\n disabled: PropTypes.bool.description('Whether the toggle is disabled or not').defaultValue('false'),\n applyAriaDisabled: PropTypes.bool\n .description(\n 'Whether to apply disabled styling and announce as disabled in SR. CAN STILL RECEIVE FOCUS. PREVENTS ONLY MAIN ACTION.',\n )\n .defaultValue('false'),\n readOnly: PropTypes.bool.description('Whether the toggle is readOnly or not').defaultValue('false'),\n containerProps: PropTypes.object.description('Set of properties attached to the main container'),\n id: PropTypes.string.description('Unique id.'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Toggle button ref.'),\n labelOn: PropTypes.string\n .description('Past deprecation ETA, this fails WCAG, switch to appropiate designs')\n .deprecated({ version: '25.3' }),\n labelOff: PropTypes.string\n .description('Past deprecation ETA, this fails WCAG, switch to appropiate designs')\n .deprecated({ version: '25.3' }),\n};\n\nexport const DSControlledTogglePropTypesSchema =\n DSControlledTogglePropTypes as unknown as ValidationMap<DSControlledToggleT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAKO;AAEP,uBAA8E;AA2FvE,MAAM,eAAiD;AAAA,EAC5D,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAChB,MAAM,8BAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AACrB;AAEO,MAAM,8BAGT;AAAA,EACF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAG,kDAAyB,yCAAwB,wCAAuB;AAAA,EAC3E,SAAS,kCAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,OAAO;AAAA,EAChG,UAAU,kCAAU,KAAK,YAAY,kBAAkB,EAAE,aAAa,YAAY;AAAA,EAClF,MAAM,kCAAU,MAAM,CAAC,KAAK,KAAK,GAAG,CAAC,EAAE,YAAY,gBAAgB,EAAE,aAAa,8BAAa,MAAM;AAAA,EACrG,UAAU,kCAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,OAAO;AAAA,EAClG,mBAAmB,kCAAU,KAC1B;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AAAA,EACvB,UAAU,kCAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,OAAO;AAAA,EAClG,gBAAgB,kCAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,IAAI,kCAAU,OAAO,YAAY,YAAY;AAAA,EAC7C,UAAU,kCAAU,UAAU,CAAC,kCAAU,MAAM,kCAAU,MAAM,CAAC,EAAE,YAAY,oBAAoB;AAAA,EAClG,SAAS,kCAAU,OAChB,YAAY,qEAAqE,EACjF,WAAW,EAAE,SAAS,OAAO,CAAC;AAAA,EACjC,UAAU,kCAAU,OACjB,YAAY,qEAAqE,EACjF,WAAW,EAAE,SAAS,OAAO,CAAC;AACnC;AAEO,MAAM,oCACX;",
4
+ "sourcesContent": ["import type React from 'react';\nimport type { DSButtonV3T } from '@elliemae/ds-button-v2';\nimport type { DSPropTypesSchema, GlobalAttributesT, ValidationMap, XstyledProps } from '@elliemae/ds-props-helpers';\nimport {\n PropTypes,\n globalAttributesPropTypes,\n xstyledPropTypes,\n getPropsPerSlotPropTypes,\n} from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { TOGGLE_SIZES, DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from './constants/index.js';\n\nexport declare namespace DSControlledToggleT {\n export type ToggleSize = ObjectValues<typeof TOGGLE_SIZES>;\n\n // One entry per slot in CONTROLLED_TOGGLE_SLOTS \u2014 the function (dynamic) form of slot props.\n // Exhaustiveness against the slots is enforced in typescript-testing/slot-props.ts.\n export type SlotFunctionArguments = {\n dsFormtoggleButtonContentWrapper: () => object;\n dsFormtoggleCircle: () => object;\n dsFormtoggleTextWrapper: () => object;\n dsFormtoggleHiddenInput: () => object;\n // legacy slot aliases \u2014 still injection points, see KNOWN_INTENTIONAL_DEVIATIONS.md\n dsFormtoggleControlledContainer: () => object;\n dsFormtoggleToggleCheckbox: () => object;\n };\n\n export interface DefaultProps {\n checked: boolean;\n onChange: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;\n onValueChange: (\n newChecked: boolean,\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>,\n ) => void;\n size: ToggleSize;\n readOnly: boolean;\n disabled: boolean;\n applyAriaDisabled: boolean;\n hasError: boolean;\n makeSubmittable: boolean;\n }\n\n export interface RequiredProps {}\n\n export interface OptionalProps extends TypescriptHelpersT.PropsForGlobalOnSlots<\n typeof DSControlledToggleName,\n typeof CONTROLLED_TOGGLE_SLOTS\n > {\n containerProps?: Record<string, unknown>;\n id?: string;\n /**\n * Ref forwarded to the focusable toggle button (role=\"switch\"). Mirrors the innerRef\n * contract of DSControlledRadio / DSControlledCheckbox so consumers (e.g. ds-data-table\n * custom cells) can reach the real focusable node for keyboard focus management.\n */\n innerRef?: React.MutableRefObject<HTMLButtonElement | null> | React.RefCallback<HTMLButtonElement>;\n }\n\n // this interface is the \"last chance\" for apps to keep using the deprecated props before the major release that will remove them\n // this is meant to \"break\" those using the old prop, but still allow a last chance to gradually update (requiring them to change the prop name)\n export interface PostDeprecationETAPropsFallback {\n /**\n * @deprecated a custom wcagViolationLabelOn violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n wcagViolationLabelOn?: string; // used to be \"labelOn\"\n /**\n * @deprecated a custom wcagViolationLabelOff violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n wcagViolationLabelOff?: string; // used to be \"labelOff\"\n }\n export interface PreDeprecationETAProps {\n /**\n * @deprecated a custom wcagViolationLabelOn violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n labelOn?: string; // used to be \"labelOn\"\n /**\n * @deprecated a custom wcagViolationLabelOff violates the role='switch' by design and it's impossible to make it WCAG compliant.\n * Do not use it, if you need a custom label, you don't need a toggle, use a checkbox instead.\n */\n labelOff?: string; // used to be \"labelOff\"\n }\n\n export interface ButtonV3InherithedProps extends Omit<DSButtonV3T.Props, 'size' | 'children'> {}\n\n export interface Props\n extends\n Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps,\n PreDeprecationETAProps,\n PostDeprecationETAPropsFallback {}\n\n export interface InternalProps\n extends\n DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps,\n RequiredProps,\n PreDeprecationETAProps,\n PostDeprecationETAPropsFallback {}\n}\n\nexport const defaultProps: DSControlledToggleT.DefaultProps = {\n checked: false,\n onChange: () => null,\n onValueChange: () => null,\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n hasError: false,\n makeSubmittable: false,\n};\n\nexport const DSControlledTogglePropTypes: DSPropTypesSchema<\n Omit<DSControlledToggleT.Props, keyof DSControlledToggleT.PostDeprecationETAPropsFallback> &\n DSControlledToggleT.PreDeprecationETAProps\n> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n ...getPropsPerSlotPropTypes(DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS),\n checked: PropTypes.bool.description('Whether the toggle is checked or not').defaultValue('false'),\n onChange: PropTypes.func.description('OnClick callback').defaultValue('() => null'),\n onValueChange: PropTypes.func\n .description(\n 'Callback triggered when the user toggles it, it receives the new checked state. It is not triggered when disabled, readOnly or applyAriaDisabled.',\n )\n .defaultValue('() => null')\n .signature('((newChecked: boolean, e: React.MouseEvent | React.KeyboardEvent) => void)'),\n size: PropTypes.oneOf(['s', 'm', 'l']).description('Size of toggle').defaultValue(TOGGLE_SIZES.MEDIUM),\n disabled: PropTypes.bool.description('Whether the toggle is disabled or not').defaultValue('false'),\n applyAriaDisabled: PropTypes.bool\n .description(\n 'Whether to apply disabled styling and announce as disabled in SR. CAN STILL RECEIVE FOCUS. IGNORES EVERY ACTION (click, Enter, Space) AND THE CONSUMER HANDLERS FOR THEM.',\n )\n .defaultValue('false'),\n readOnly: PropTypes.bool\n .description(\n 'Soft lock, same as applyAriaDisabled: aria-disabled=\"true\", CAN STILL RECEIVE FOCUS, IGNORES EVERY ACTION (click, Enter, Space) AND THE CONSUMER HANDLERS FOR THEM. Also announces \"Read only\" through a hidden description. Dimsum never writes aria-readonly.',\n )\n .defaultValue('false'),\n hasError: PropTypes.bool\n .description('Whether the toggle has error or not. When true the borders use the error color.')\n .defaultValue('false'),\n makeSubmittable: PropTypes.bool\n .description(\n 'Renders a hidden checkbox input so the toggle can be submitted by a native form. When true, name and value are applied to the hidden input instead of the button.',\n )\n .defaultValue('false'),\n containerProps: PropTypes.object.description('Set of properties attached to the main container'),\n id: PropTypes.string.description('Unique id.'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Toggle button ref.'),\n labelOn: PropTypes.string\n .description('Past deprecation ETA, this fails WCAG, switch to appropiate designs')\n .deprecated({ version: '25.3' }),\n labelOff: PropTypes.string\n .description('Past deprecation ETA, this fails WCAG, switch to appropiate designs')\n .deprecated({ version: '25.3' }),\n};\n\nexport const DSControlledTogglePropTypesSchema =\n DSControlledTogglePropTypes as unknown as ValidationMap<DSControlledToggleT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAKO;AAEP,uBAA8E;AAkGvE,MAAM,eAAiD;AAAA,EAC5D,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAChB,eAAe,MAAM;AAAA,EACrB,MAAM,8BAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,iBAAiB;AACnB;AAEO,MAAM,8BAGT;AAAA,EACF,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAG,kDAAyB,yCAAwB,wCAAuB;AAAA,EAC3E,SAAS,kCAAU,KAAK,YAAY,sCAAsC,EAAE,aAAa,OAAO;AAAA,EAChG,UAAU,kCAAU,KAAK,YAAY,kBAAkB,EAAE,aAAa,YAAY;AAAA,EAClF,eAAe,kCAAU,KACtB;AAAA,IACC;AAAA,EACF,EACC,aAAa,YAAY,EACzB,UAAU,4EAA4E;AAAA,EACzF,MAAM,kCAAU,MAAM,CAAC,KAAK,KAAK,GAAG,CAAC,EAAE,YAAY,gBAAgB,EAAE,aAAa,8BAAa,MAAM;AAAA,EACrG,UAAU,kCAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,OAAO;AAAA,EAClG,mBAAmB,kCAAU,KAC1B;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AAAA,EACvB,UAAU,kCAAU,KACjB;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AAAA,EACvB,UAAU,kCAAU,KACjB,YAAY,iFAAiF,EAC7F,aAAa,OAAO;AAAA,EACvB,iBAAiB,kCAAU,KACxB;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AAAA,EACvB,gBAAgB,kCAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,IAAI,kCAAU,OAAO,YAAY,YAAY;AAAA,EAC7C,UAAU,kCAAU,UAAU,CAAC,kCAAU,MAAM,kCAAU,MAAM,CAAC,EAAE,YAAY,oBAAoB;AAAA,EAClG,SAAS,kCAAU,OAChB,YAAY,qEAAqE,EACjF,WAAW,EAAE,SAAS,OAAO,CAAC;AAAA,EACjC,UAAU,kCAAU,OACjB,YAAY,qEAAqE,EACjF,WAAW,EAAE,SAAS,OAAO,CAAC;AACnC;AAEO,MAAM,oCACX;",
6
6
  "names": []
7
7
  }
@@ -23,6 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  ));
24
24
  var React = __toESM(require("react"));
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react = __toESM(require("react"));
26
27
  var import__ = require("../index.js");
27
28
  const testRequiredProps = {};
28
29
  const testOptionalProps = {
@@ -51,10 +52,14 @@ const testCompleteDefaults = {
51
52
  checked: false,
52
53
  onChange: () => {
53
54
  },
55
+ onValueChange: () => {
56
+ },
54
57
  size: import__.TOGGLE_SIZES.MEDIUM,
55
58
  readOnly: false,
56
59
  disabled: false,
57
- applyAriaDisabled: false
60
+ applyAriaDisabled: false,
61
+ hasError: false,
62
+ makeSubmittable: false
58
63
  };
59
64
  const testInternalProps = {
60
65
  ...testRequiredProps,
@@ -74,10 +79,16 @@ const testExplicitDefinition = {
74
79
  checked: true,
75
80
  onChange: () => {
76
81
  },
82
+ onValueChange: (newChecked, e) => {
83
+ },
77
84
  size: import__.TOGGLE_SIZES.LARGE,
78
85
  readOnly: false,
79
86
  disabled: false,
80
87
  applyAriaDisabled: false,
88
+ hasError: false,
89
+ makeSubmittable: true,
90
+ name: "toggle-name",
91
+ value: "toggle-value",
81
92
  labelOn: "Enabled",
82
93
  labelOff: "Disabled",
83
94
  wcagViolationLabelOn: "Legacy On",
@@ -88,6 +99,8 @@ const testInferedTypeCompatibility = {
88
99
  checked: false,
89
100
  onChange: () => {
90
101
  },
102
+ onValueChange: (newChecked) => {
103
+ },
91
104
  size: import__.TOGGLE_SIZES.SMALL,
92
105
  readOnly: false,
93
106
  disabled: true,
@@ -105,6 +118,10 @@ const testDefinitionAsConst = {
105
118
  disabled: false,
106
119
  applyAriaDisabled: false
107
120
  };
121
+ const ExampleUsageWithStateSetter = () => {
122
+ const [checked, setChecked] = import_react.default.useState(false);
123
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSControlledToggle, { "aria-label": "state setter", checked, onValueChange: setChecked });
124
+ };
108
125
  const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
109
126
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSControlledToggle, { ...testExplicitDefinition }),
110
127
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSControlledToggle, { ...testInferedTypeCompatibility }),
@@ -119,10 +136,16 @@ const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)
119
136
  checked: true,
120
137
  onChange: () => {
121
138
  },
139
+ onValueChange: (newChecked, e) => {
140
+ },
122
141
  size: import__.TOGGLE_SIZES.MEDIUM,
123
142
  readOnly: false,
124
143
  disabled: false,
125
144
  applyAriaDisabled: false,
145
+ hasError: true,
146
+ makeSubmittable: true,
147
+ name: "toggle-inline-name",
148
+ value: "toggle-inline-value",
126
149
  labelOn: "Enabled",
127
150
  labelOff: "Disabled",
128
151
  wcagViolationLabelOn: "Legacy On",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/form-toggle-typescript-valid.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSControlledToggle, TOGGLE_SIZES, type DSControlledToggleT } from '../index.js';\n\n/**\n * Namespace type aliases exposed by the package public API.\n */\ntype ComponentPropsForApp = DSControlledToggleT.Props;\ntype ComponentPropsInternals = DSControlledToggleT.InternalProps;\ntype ComponentPropsDefaultProps = DSControlledToggleT.DefaultProps;\ntype ComponentPropsOptionalProps = DSControlledToggleT.OptionalProps;\ntype ComponentPropsRequiredProps = DSControlledToggleT.RequiredProps;\n\n/**\n * Required props contract (empty for this component).\n */\nconst testRequiredProps: ComponentPropsRequiredProps = {};\n\n/**\n * Optional props contract.\n */\nconst testOptionalProps: ComponentPropsOptionalProps = {\n id: 'toggle-id',\n containerProps: {\n 'data-testid': 'toggle-container',\n 'aria-label': 'toggle container',\n },\n innerRef: { current: null },\n};\n\n/**\n * Partial defaults are valid for app-facing props.\n */\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n checked: true,\n size: TOGGLE_SIZES.MEDIUM,\n};\n\n/**\n * Public props composition using explicit type annotation.\n */\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\n\n/**\n * Public props composition using \"as\" syntax.\n */\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n\n/**\n * Internal props require all default values.\n */\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n checked: false,\n onChange: () => {},\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n};\n\n/**\n * Internal props composition using explicit type annotation.\n */\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\n\n/**\n * Internal props composition using \"as\" syntax.\n */\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n/**\n * Explicit app-facing definition validates individual keys.\n */\nconst testExplicitDefinition: ComponentPropsForApp = {\n id: 'toggle-explicit',\n containerProps: {\n 'data-testid': 'toggle-explicit-container',\n },\n checked: true,\n onChange: () => {},\n size: TOGGLE_SIZES.LARGE,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n labelOn: 'Enabled',\n labelOff: 'Disabled',\n wcagViolationLabelOn: 'Legacy On',\n wcagViolationLabelOff: 'Legacy Off',\n};\n\n/**\n * Inferred compatibility validates the complete object against public props.\n */\nconst testInferedTypeCompatibility = {\n id: 'toggle-inferred',\n checked: false,\n onChange: () => {},\n size: TOGGLE_SIZES.SMALL,\n readOnly: false,\n disabled: true,\n applyAriaDisabled: true,\n labelOn: 'Enabled',\n labelOff: 'Disabled',\n} as ComponentPropsForApp;\n\n/**\n * As-const object should remain spread-compatible with component props.\n */\nconst testDefinitionAsConst = {\n id: 'toggle-const',\n checked: true,\n onChange: () => {},\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: true,\n disabled: false,\n applyAriaDisabled: false,\n} as const;\n\n/**\n * TS validation usage component covering spread and inline syntaxes.\n */\nconst ExampleUsageComponent = () => (\n <>\n <DSControlledToggle {...testExplicitDefinition} />\n <DSControlledToggle {...testInferedTypeCompatibility} />\n <DSControlledToggle {...testDefinitionAsConst} />\n <DSControlledToggle\n id=\"toggle-inline\"\n containerProps={{\n 'data-testid': 'toggle-inline-container',\n }}\n checked\n onChange={() => {}}\n size={TOGGLE_SIZES.MEDIUM}\n readOnly={false}\n disabled={false}\n applyAriaDisabled={false}\n labelOn=\"Enabled\"\n labelOff=\"Disabled\"\n wcagViolationLabelOn=\"Legacy On\"\n wcagViolationLabelOff=\"Legacy Off\"\n />\n </>\n);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACyIrB;AAxIF,eAA2E;AAc3E,MAAM,oBAAiD,CAAC;AAKxD,MAAM,oBAAiD;AAAA,EACrD,IAAI;AAAA,EACJ,gBAAgB;AAAA,IACd,eAAe;AAAA,IACf,cAAc;AAAA,EAChB;AAAA,EACA,UAAU,EAAE,SAAS,KAAK;AAC5B;AAKA,MAAM,sBAA2D;AAAA,EAC/D,SAAS;AAAA,EACT,MAAM,sBAAa;AACrB;AAKA,MAAM,YAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,uBAA6D;AAAA,EACjE,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AACrB;AAKA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,yBAA+C;AAAA,EACnD,IAAI;AAAA,EACJ,gBAAgB;AAAA,IACd,eAAe;AAAA,EACjB;AAAA,EACA,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,uBAAuB;AACzB;AAKA,MAAM,+BAA+B;AAAA,EACnC,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,UAAU;AACZ;AAKA,MAAM,wBAAwB;AAAA,EAC5B,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AACrB;AAKA,MAAM,wBAAwB,MAC5B,4EACE;AAAA,8CAAC,+BAAoB,GAAG,wBAAwB;AAAA,EAChD,4CAAC,+BAAoB,GAAG,8BAA8B;AAAA,EACtD,4CAAC,+BAAoB,GAAG,uBAAuB;AAAA,EAC/C;AAAA,IAAC;AAAA;AAAA,MACC,IAAG;AAAA,MACH,gBAAgB;AAAA,QACd,eAAe;AAAA,MACjB;AAAA,MACA,SAAO;AAAA,MACP,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,MAAM,sBAAa;AAAA,MACnB,UAAU;AAAA,MACV,UAAU;AAAA,MACV,mBAAmB;AAAA,MACnB,SAAQ;AAAA,MACR,UAAS;AAAA,MACT,sBAAqB;AAAA,MACrB,uBAAsB;AAAA;AAAA,EACxB;AAAA,GACF;",
6
- "names": []
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport React from 'react';\nimport { DSControlledToggle, TOGGLE_SIZES, type DSControlledToggleT } from '../index.js';\n\n/**\n * Namespace type aliases exposed by the package public API.\n */\ntype ComponentPropsForApp = DSControlledToggleT.Props;\ntype ComponentPropsInternals = DSControlledToggleT.InternalProps;\ntype ComponentPropsDefaultProps = DSControlledToggleT.DefaultProps;\ntype ComponentPropsOptionalProps = DSControlledToggleT.OptionalProps;\ntype ComponentPropsRequiredProps = DSControlledToggleT.RequiredProps;\n\n/**\n * Required props contract (empty for this component).\n */\nconst testRequiredProps: ComponentPropsRequiredProps = {};\n\n/**\n * Optional props contract.\n */\nconst testOptionalProps: ComponentPropsOptionalProps = {\n id: 'toggle-id',\n containerProps: {\n 'data-testid': 'toggle-container',\n 'aria-label': 'toggle container',\n },\n innerRef: { current: null },\n};\n\n/**\n * Partial defaults are valid for app-facing props.\n */\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n checked: true,\n size: TOGGLE_SIZES.MEDIUM,\n};\n\n/**\n * Public props composition using explicit type annotation.\n */\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\n\n/**\n * Public props composition using \"as\" syntax.\n */\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n\n/**\n * Internal props require all default values.\n */\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n checked: false,\n onChange: () => {},\n onValueChange: () => {},\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n hasError: false,\n makeSubmittable: false,\n};\n\n/**\n * Internal props composition using explicit type annotation.\n */\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\n\n/**\n * Internal props composition using \"as\" syntax.\n */\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n/**\n * Explicit app-facing definition validates individual keys.\n */\nconst testExplicitDefinition: ComponentPropsForApp = {\n id: 'toggle-explicit',\n containerProps: {\n 'data-testid': 'toggle-explicit-container',\n },\n checked: true,\n onChange: () => {},\n onValueChange: (newChecked, e) => {},\n size: TOGGLE_SIZES.LARGE,\n readOnly: false,\n disabled: false,\n applyAriaDisabled: false,\n hasError: false,\n makeSubmittable: true,\n name: 'toggle-name',\n value: 'toggle-value',\n labelOn: 'Enabled',\n labelOff: 'Disabled',\n wcagViolationLabelOn: 'Legacy On',\n wcagViolationLabelOff: 'Legacy Off',\n};\n\n/**\n * Inferred compatibility validates the complete object against public props.\n */\nconst testInferedTypeCompatibility = {\n id: 'toggle-inferred',\n checked: false,\n onChange: () => {},\n onValueChange: (newChecked: boolean) => {},\n size: TOGGLE_SIZES.SMALL,\n readOnly: false,\n disabled: true,\n applyAriaDisabled: true,\n labelOn: 'Enabled',\n labelOff: 'Disabled',\n} as ComponentPropsForApp;\n\n/**\n * As-const object should remain spread-compatible with component props.\n */\nconst testDefinitionAsConst = {\n id: 'toggle-const',\n checked: true,\n onChange: () => {},\n size: TOGGLE_SIZES.MEDIUM,\n readOnly: true,\n disabled: false,\n applyAriaDisabled: false,\n} as const;\n\n/**\n * The state setter handed over directly as onValueChange must stay type-compatible.\n */\nconst ExampleUsageWithStateSetter = () => {\n const [checked, setChecked] = React.useState(false);\n return <DSControlledToggle aria-label=\"state setter\" checked={checked} onValueChange={setChecked} />;\n};\n\n/**\n * TS validation usage component covering spread and inline syntaxes.\n */\nconst ExampleUsageComponent = () => (\n <>\n <DSControlledToggle {...testExplicitDefinition} />\n <DSControlledToggle {...testInferedTypeCompatibility} />\n <DSControlledToggle {...testDefinitionAsConst} />\n <DSControlledToggle\n id=\"toggle-inline\"\n containerProps={{\n 'data-testid': 'toggle-inline-container',\n }}\n checked\n onChange={() => {}}\n onValueChange={(newChecked, e) => {}}\n size={TOGGLE_SIZES.MEDIUM}\n readOnly={false}\n disabled={false}\n applyAriaDisabled={false}\n hasError\n makeSubmittable\n name=\"toggle-inline-name\"\n value=\"toggle-inline-value\"\n labelOn=\"Enabled\"\n labelOff=\"Disabled\"\n wcagViolationLabelOn=\"Legacy On\"\n wcagViolationLabelOff=\"Legacy Off\"\n />\n </>\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACoJd;AAnJT,mBAAkB;AAClB,eAA2E;AAc3E,MAAM,oBAAiD,CAAC;AAKxD,MAAM,oBAAiD;AAAA,EACrD,IAAI;AAAA,EACJ,gBAAgB;AAAA,IACd,eAAe;AAAA,IACf,cAAc;AAAA,EAChB;AAAA,EACA,UAAU,EAAE,SAAS,KAAK;AAC5B;AAKA,MAAM,sBAA2D;AAAA,EAC/D,SAAS;AAAA,EACT,MAAM,sBAAa;AACrB;AAKA,MAAM,YAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,uBAA6D;AAAA,EACjE,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,iBAAiB;AACnB;AAKA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAKA,MAAM,yBAA+C;AAAA,EACnD,IAAI;AAAA,EACJ,gBAAgB;AAAA,IACd,eAAe;AAAA,EACjB;AAAA,EACA,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,eAAe,CAAC,YAAY,MAAM;AAAA,EAAC;AAAA,EACnC,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,uBAAuB;AACzB;AAKA,MAAM,+BAA+B;AAAA,EACnC,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,eAAe,CAAC,eAAwB;AAAA,EAAC;AAAA,EACzC,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,UAAU;AACZ;AAKA,MAAM,wBAAwB;AAAA,EAC5B,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,MAAM,sBAAa;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,mBAAmB;AACrB;AAKA,MAAM,8BAA8B,MAAM;AACxC,QAAM,CAAC,SAAS,UAAU,IAAI,aAAAA,QAAM,SAAS,KAAK;AAClD,SAAO,4CAAC,+BAAmB,cAAW,gBAAe,SAAkB,eAAe,YAAY;AACpG;AAKA,MAAM,wBAAwB,MAC5B,4EACE;AAAA,8CAAC,+BAAoB,GAAG,wBAAwB;AAAA,EAChD,4CAAC,+BAAoB,GAAG,8BAA8B;AAAA,EACtD,4CAAC,+BAAoB,GAAG,uBAAuB;AAAA,EAC/C;AAAA,IAAC;AAAA;AAAA,MACC,IAAG;AAAA,MACH,gBAAgB;AAAA,QACd,eAAe;AAAA,MACjB;AAAA,MACA,SAAO;AAAA,MACP,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,eAAe,CAAC,YAAY,MAAM;AAAA,MAAC;AAAA,MACnC,MAAM,sBAAa;AAAA,MACnB,UAAU;AAAA,MACV,UAAU;AAAA,MACV,mBAAmB;AAAA,MACnB,UAAQ;AAAA,MACR,iBAAe;AAAA,MACf,MAAK;AAAA,MACL,OAAM;AAAA,MACN,SAAQ;AAAA,MACR,UAAS;AAAA,MACT,sBAAqB;AAAA,MACrB,uBAAsB;AAAA;AAAA,EACxB;AAAA,GACF;",
6
+ "names": ["React"]
7
7
  }
@@ -26,6 +26,7 @@ const SlotPropsAsObject = {
26
26
  dsFormtoggleButtonContentWrapper: { "aria-label": "just a typescript test" },
27
27
  dsFormtoggleCircle: { "aria-label": "just a typescript test" },
28
28
  dsFormtoggleTextWrapper: { "aria-label": "just a typescript test" },
29
+ dsFormtoggleHiddenInput: { "aria-label": "just a typescript test" },
29
30
  dsFormtoggleControlledContainer: { "aria-label": "just a typescript test" },
30
31
  dsFormtoggleToggleCheckbox: { "aria-label": "just a typescript test" }
31
32
  };
@@ -33,6 +34,7 @@ const SlotPropsAsFunctions = {
33
34
  dsFormtoggleButtonContentWrapper: () => ({ "aria-label": "just a typescript test" }),
34
35
  dsFormtoggleCircle: () => ({ "aria-label": "just a typescript test" }),
35
36
  dsFormtoggleTextWrapper: () => ({ "aria-label": "just a typescript test" }),
37
+ dsFormtoggleHiddenInput: () => ({ "aria-label": "just a typescript test" }),
36
38
  dsFormtoggleControlledContainer: () => ({ "aria-label": "just a typescript test" }),
37
39
  dsFormtoggleToggleCheckbox: () => ({ "aria-label": "just a typescript test" })
38
40
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/slot-props.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type { DSControlledToggleT } from '../react-desc-prop-types.js';\nimport type { DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from '../constants/index.js';\n\n// Exhaustiveness contract over CONTROLLED_TOGGLE_SLOTS \u2014 every slot must appear in SlotFunctionArguments.\n// The legacy aliases (dsFormtoggleControlledContainer, dsFormtoggleToggleCheckbox) are real injection\n// points kept for QA/consumer compatibility \u2014 see KNOWN_INTENTIONAL_DEVIATIONS.md.\n//\n// Slot props can be passed in two forms \u2014 object (static) and function (dynamic).\nconst SlotPropsAsObject: Partial<DSControlledToggleT.Props> = {\n dsFormtoggleButtonContentWrapper: { 'aria-label': 'just a typescript test' },\n dsFormtoggleCircle: { 'aria-label': 'just a typescript test' },\n dsFormtoggleTextWrapper: { 'aria-label': 'just a typescript test' },\n dsFormtoggleControlledContainer: { 'aria-label': 'just a typescript test' },\n dsFormtoggleToggleCheckbox: { 'aria-label': 'just a typescript test' },\n};\n\nconst SlotPropsAsFunctions: DSControlledToggleT.SlotFunctionArguments = {\n dsFormtoggleButtonContentWrapper: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleCircle: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleTextWrapper: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleControlledContainer: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleToggleCheckbox: () => ({ 'aria-label': 'just a typescript test' }),\n};\n\n// Exhaustiveness check \u2014 fails compilation if a slot is missing from SlotFunctionArguments.\nconst EnsureAllSlotsExistInSlotFunctionArguments: Required<\n TypescriptHelpersT.PropsForSlots<typeof DSControlledToggleName, typeof CONTROLLED_TOGGLE_SLOTS>\n> = SlotPropsAsFunctions;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACUvB,MAAM,oBAAwD;AAAA,EAC5D,kCAAkC,EAAE,cAAc,yBAAyB;AAAA,EAC3E,oBAAoB,EAAE,cAAc,yBAAyB;AAAA,EAC7D,yBAAyB,EAAE,cAAc,yBAAyB;AAAA,EAClE,iCAAiC,EAAE,cAAc,yBAAyB;AAAA,EAC1E,4BAA4B,EAAE,cAAc,yBAAyB;AACvE;AAEA,MAAM,uBAAkE;AAAA,EACtE,kCAAkC,OAAO,EAAE,cAAc,yBAAyB;AAAA,EAClF,oBAAoB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACpE,yBAAyB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACzE,iCAAiC,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACjF,4BAA4B,OAAO,EAAE,cAAc,yBAAyB;AAC9E;AAGA,MAAM,6CAEF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type { DSControlledToggleT } from '../react-desc-prop-types.js';\nimport type { DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS } from '../constants/index.js';\n\n// Exhaustiveness contract over CONTROLLED_TOGGLE_SLOTS \u2014 every slot must appear in SlotFunctionArguments.\n// The legacy aliases (dsFormtoggleControlledContainer, dsFormtoggleToggleCheckbox) are real injection\n// points kept for QA/consumer compatibility \u2014 see KNOWN_INTENTIONAL_DEVIATIONS.md.\n//\n// Slot props can be passed in two forms \u2014 object (static) and function (dynamic).\nconst SlotPropsAsObject: Partial<DSControlledToggleT.Props> = {\n dsFormtoggleButtonContentWrapper: { 'aria-label': 'just a typescript test' },\n dsFormtoggleCircle: { 'aria-label': 'just a typescript test' },\n dsFormtoggleTextWrapper: { 'aria-label': 'just a typescript test' },\n dsFormtoggleHiddenInput: { 'aria-label': 'just a typescript test' },\n dsFormtoggleControlledContainer: { 'aria-label': 'just a typescript test' },\n dsFormtoggleToggleCheckbox: { 'aria-label': 'just a typescript test' },\n};\n\nconst SlotPropsAsFunctions: DSControlledToggleT.SlotFunctionArguments = {\n dsFormtoggleButtonContentWrapper: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleCircle: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleTextWrapper: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleHiddenInput: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleControlledContainer: () => ({ 'aria-label': 'just a typescript test' }),\n dsFormtoggleToggleCheckbox: () => ({ 'aria-label': 'just a typescript test' }),\n};\n\n// Exhaustiveness check \u2014 fails compilation if a slot is missing from SlotFunctionArguments.\nconst EnsureAllSlotsExistInSlotFunctionArguments: Required<\n TypescriptHelpersT.PropsForSlots<typeof DSControlledToggleName, typeof CONTROLLED_TOGGLE_SLOTS>\n> = SlotPropsAsFunctions;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACUvB,MAAM,oBAAwD;AAAA,EAC5D,kCAAkC,EAAE,cAAc,yBAAyB;AAAA,EAC3E,oBAAoB,EAAE,cAAc,yBAAyB;AAAA,EAC7D,yBAAyB,EAAE,cAAc,yBAAyB;AAAA,EAClE,yBAAyB,EAAE,cAAc,yBAAyB;AAAA,EAClE,iCAAiC,EAAE,cAAc,yBAAyB;AAAA,EAC1E,4BAA4B,EAAE,cAAc,yBAAyB;AACvE;AAEA,MAAM,uBAAkE;AAAA,EACtE,kCAAkC,OAAO,EAAE,cAAc,yBAAyB;AAAA,EAClF,oBAAoB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACpE,yBAAyB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACzE,yBAAyB,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACzE,iCAAiC,OAAO,EAAE,cAAc,yBAAyB;AAAA,EACjF,4BAA4B,OAAO,EAAE,cAAc,yBAAyB;AAC9E;AAGA,MAAM,6CAEF;",
6
6
  "names": []
7
7
  }
@@ -8,15 +8,16 @@ import { useValidateProps } from "./useValidateProps.js";
8
8
  const useDSControlledToggle = (propsFromUser) => {
9
9
  const propsWithDefault = useMemoMergePropsWithDefault(propsFromUser, defaultProps);
10
10
  useValidateProps(propsWithDefault, DSControlledTogglePropTypes);
11
- const { disabled, applyAriaDisabled, readOnly, onChange } = propsWithDefault;
11
+ const { disabled, applyAriaDisabled, readOnly, onChange, onValueChange, checked } = propsWithDefault;
12
12
  const handleOnClick = useCallback(
13
13
  (e) => {
14
14
  if (disabled || applyAriaDisabled || readOnly) return;
15
15
  if (onChange) {
16
16
  onChange(e);
17
17
  }
18
+ onValueChange?.(!checked, e);
18
19
  },
19
- [disabled, applyAriaDisabled, readOnly, onChange]
20
+ [disabled, applyAriaDisabled, readOnly, onChange, onValueChange, checked]
20
21
  );
21
22
  const globalProps = useGetGlobalAttributes(propsWithDefault, {
22
23
  onClick: handleOnClick
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useDSControlledToggle.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React, { useCallback } from 'react';\nimport { uid } from 'uid';\nimport { type DSControlledToggleT, DSControlledTogglePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useGetButtonProps } from './useGetButtonProps.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport interface ControlledToggleCTX {\n propsWithDefault: DSControlledToggleT.InternalProps;\n globalProps: ReturnType<typeof useGetGlobalAttributes>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n instanceUid: string;\n buttonProps: ReturnType<typeof useGetButtonProps>;\n handleOnClick: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}\n\nexport const useDSControlledToggle = (propsFromUser: DSControlledToggleT.Props): ControlledToggleCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSControlledToggleT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSControlledTogglePropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { disabled, applyAriaDisabled, readOnly, onChange } = propsWithDefault;\n const handleOnClick = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || applyAriaDisabled || readOnly) return;\n if (onChange) {\n onChange(e);\n }\n },\n [disabled, applyAriaDisabled, readOnly, onChange],\n );\n // =============================================================================\n // GLOBAL ATTRIBUTES & XSTYLED PROPS\n // =============================================================================\n const globalProps = useGetGlobalAttributes<DSControlledToggleT.InternalProps>(propsWithDefault, {\n onClick: handleOnClick,\n });\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n const { id } = propsWithDefault;\n const instanceUid = React.useMemo(() => id || `ds-form-toggle-${uid(5)}`, [id]);\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n const buttonProps = useGetButtonProps({\n handleOnClick,\n globalProps,\n instanceUid,\n propsWithDefault,\n });\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalProps,\n xstyledProps,\n instanceUid,\n buttonProps,\n handleOnClick,\n }),\n [propsWithDefault, globalProps, buttonProps, xstyledProps, instanceUid, handleOnClick],\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,UAAS,mBAAmB;AACnC,SAAS,WAAW;AACpB,SAAmC,6BAA6B,oBAAoB;AACpF,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAW1B,MAAM,wBAAwB,CAAC,kBAAkE;AAItG,QAAM,mBAAmB,6BAAgE,eAAe,YAAY;AACpH,mBAAiB,kBAAkB,2BAA2B;AAI9D,QAAM,EAAE,UAAU,mBAAmB,UAAU,SAAS,IAAI;AAC5D,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAAgG;AAC/F,UAAI,YAAY,qBAAqB,SAAU;AAC/C,UAAI,UAAU;AACZ,iBAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,IACA,CAAC,UAAU,mBAAmB,UAAU,QAAQ;AAAA,EAClD;AAIA,QAAM,cAAc,uBAA0D,kBAAkB;AAAA,IAC9F,SAAS;AAAA,EACX,CAAC;AACD,QAAM,eAAe,mBAAmB,gBAAgB;AACxD,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,cAAcA,OAAM,QAAQ,MAAM,MAAM,kBAAkB,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAI9E,QAAM,cAAc,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB,aAAa,aAAa,cAAc,aAAa,aAAa;AAAA,EACvF;AACF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React, { useCallback } from 'react';\nimport { uid } from 'uid';\nimport { type DSControlledToggleT, DSControlledTogglePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useGetButtonProps } from './useGetButtonProps.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport interface ControlledToggleCTX {\n propsWithDefault: DSControlledToggleT.InternalProps;\n globalProps: ReturnType<typeof useGetGlobalAttributes>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n instanceUid: string;\n buttonProps: ReturnType<typeof useGetButtonProps>;\n handleOnClick: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}\n\nexport const useDSControlledToggle = (propsFromUser: DSControlledToggleT.Props): ControlledToggleCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSControlledToggleT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSControlledTogglePropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { disabled, applyAriaDisabled, readOnly, onChange, onValueChange, checked } = propsWithDefault;\n const handleOnClick = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || applyAriaDisabled || readOnly) return;\n if (onChange) {\n onChange(e);\n }\n // the toggle is controlled: the new state is always the opposite of the current `checked`\n onValueChange?.(!checked, e);\n },\n [disabled, applyAriaDisabled, readOnly, onChange, onValueChange, checked],\n );\n // =============================================================================\n // GLOBAL ATTRIBUTES & XSTYLED PROPS\n // =============================================================================\n const globalProps = useGetGlobalAttributes<DSControlledToggleT.InternalProps>(propsWithDefault, {\n onClick: handleOnClick,\n });\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n const { id } = propsWithDefault;\n const instanceUid = React.useMemo(() => id || `ds-form-toggle-${uid(5)}`, [id]);\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n const buttonProps = useGetButtonProps({\n handleOnClick,\n globalProps,\n instanceUid,\n propsWithDefault,\n });\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalProps,\n xstyledProps,\n instanceUid,\n buttonProps,\n handleOnClick,\n }),\n [propsWithDefault, globalProps, buttonProps, xstyledProps, instanceUid, handleOnClick],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,UAAS,mBAAmB;AACnC,SAAS,WAAW;AACpB,SAAmC,6BAA6B,oBAAoB;AACpF,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAW1B,MAAM,wBAAwB,CAAC,kBAAkE;AAItG,QAAM,mBAAmB,6BAAgE,eAAe,YAAY;AACpH,mBAAiB,kBAAkB,2BAA2B;AAI9D,QAAM,EAAE,UAAU,mBAAmB,UAAU,UAAU,eAAe,QAAQ,IAAI;AACpF,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAAgG;AAC/F,UAAI,YAAY,qBAAqB,SAAU;AAC/C,UAAI,UAAU;AACZ,iBAAS,CAAC;AAAA,MACZ;AAEA,sBAAgB,CAAC,SAAS,CAAC;AAAA,IAC7B;AAAA,IACA,CAAC,UAAU,mBAAmB,UAAU,UAAU,eAAe,OAAO;AAAA,EAC1E;AAIA,QAAM,cAAc,uBAA0D,kBAAkB;AAAA,IAC9F,SAAS;AAAA,EACX,CAAC;AACD,QAAM,eAAe,mBAAmB,gBAAgB;AACxD,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,cAAcA,OAAM,QAAQ,MAAM,MAAM,kBAAkB,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAI9E,QAAM,cAAc,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB,aAAa,aAAa,cAAc,aAAa,aAAa;AAAA,EACvF;AACF;",
6
6
  "names": ["React"]
7
7
  }
@@ -1,28 +1,66 @@
1
1
  import * as React from "react";
2
+ import { resolveAriaDisabled } from "@elliemae/ds-props-helpers";
2
3
  import { useMemo } from "react";
3
4
  import { CONTROLLED_TOGGLE_DATA_TESTID } from "../constants/index.js";
4
5
  const useGetButtonProps = (config) => {
5
6
  const { globalProps, instanceUid, handleOnClick, propsWithDefault } = config;
6
- const { checked, disabled, applyAriaDisabled, readOnly } = propsWithDefault;
7
- const { size: _sizeCleanFromRest, shape: _shapeCleanFromRest, ...restGlobalProps } = globalProps;
8
- const buttonProps = useMemo(
9
- () => ({
7
+ const { checked, disabled, applyAriaDisabled, readOnly, hasError, makeSubmittable } = propsWithDefault;
8
+ const {
9
+ // eslint-disable-next-line @typescript-eslint/naming-convention
10
+ size: _sizeCleanFromRest,
11
+ // eslint-disable-next-line @typescript-eslint/naming-convention
12
+ shape: _shapeCleanFromRest,
13
+ "aria-describedby": consumerAriaDescribedBy,
14
+ ...restGlobalProps
15
+ } = globalProps;
16
+ const baseAriaDescribedBy = consumerAriaDescribedBy ?? `${instanceUid}_feedback_message ${instanceUid}_error_message`;
17
+ const ariaDescribedBy = readOnly ? `${baseAriaDescribedBy} ${instanceUid}-read-only-helper-msg` : baseAriaDescribedBy;
18
+ const buttonProps = useMemo(() => {
19
+ const buttonGlobalProps = { ...restGlobalProps };
20
+ if (makeSubmittable) {
21
+ delete buttonGlobalProps.name;
22
+ delete buttonGlobalProps.value;
23
+ }
24
+ return {
10
25
  role: "switch",
11
26
  "data-testid": CONTROLLED_TOGGLE_DATA_TESTID.TOGGLE_CHECKBOX,
12
27
  id: instanceUid,
13
- "aria-readonly": readOnly,
14
- "aria-disabled": disabled || applyAriaDisabled || readOnly,
28
+ // readOnly and applyAriaDisabled are synonyms here: both emit aria-disabled="true", never aria-readonly.
29
+ // "disabled" stays native only (no aria-disabled).
15
30
  "aria-checked": checked,
16
- "aria-describedby": `${instanceUid}_feedback_message ${instanceUid}_error_message`,
31
+ "aria-describedby": ariaDescribedBy,
32
+ // only present when there is an error, so the markup of toggles without error does not change
33
+ ...hasError ? { "aria-invalid": true } : {},
17
34
  readOnly,
18
35
  disabled,
19
- ...restGlobalProps,
36
+ // passed to DSButton so its own gate covers the consumer pointer/key handlers spread through restGlobalProps
37
+ applyAriaDisabled,
38
+ ...buttonGlobalProps,
39
+ // after the spread: a soft lock prints "true" whatever the consumer passes, a natively disabled toggle prints none of
40
+ // its own, otherwise the consumer's own aria-disabled passes through (inversion of control)
41
+ // The key is always present (even when undefined) so it overrides DSButton's own aria-disabled.
42
+ "aria-disabled": resolveAriaDisabled({
43
+ disabled,
44
+ softLocked: applyAriaDisabled || readOnly,
45
+ consumerValue: restGlobalProps["aria-disabled"]
46
+ }),
20
47
  type: "button",
21
48
  buttonType: "raw",
49
+ // replaces the consumer onClick (pre-existing: it is never called); handleOnClick gates onChange on all three props
22
50
  onClick: handleOnClick
23
- }),
24
- [instanceUid, readOnly, disabled, applyAriaDisabled, checked, restGlobalProps, handleOnClick]
25
- );
51
+ };
52
+ }, [
53
+ instanceUid,
54
+ readOnly,
55
+ disabled,
56
+ applyAriaDisabled,
57
+ checked,
58
+ hasError,
59
+ makeSubmittable,
60
+ restGlobalProps,
61
+ ariaDescribedBy,
62
+ handleOnClick
63
+ ]);
26
64
  return buttonProps;
27
65
  };
28
66
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useGetButtonProps.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { GlobalAttributesT } from '@elliemae/ds-props-helpers';\nimport { useMemo } from 'react';\nimport { CONTROLLED_TOGGLE_DATA_TESTID } from '../constants/index.js';\nimport { type DSControlledToggleT } from '../react-desc-prop-types.js';\n\ninterface UseGetButtonPropsConfigT {\n handleOnClick: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;\n globalProps: GlobalAttributesT<HTMLButtonElement>;\n propsWithDefault: DSControlledToggleT.InternalProps;\n instanceUid: string;\n}\nexport const useGetButtonProps = (config: UseGetButtonPropsConfigT): DSControlledToggleT.ButtonV3InherithedProps => {\n const { globalProps, instanceUid, handleOnClick, propsWithDefault } = config;\n const { checked, disabled, applyAriaDisabled, readOnly } = propsWithDefault;\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { size: _sizeCleanFromRest, shape: _shapeCleanFromRest, ...restGlobalProps } = globalProps;\n const buttonProps: DSControlledToggleT.ButtonV3InherithedProps = useMemo(\n () => ({\n role: 'switch',\n 'data-testid': CONTROLLED_TOGGLE_DATA_TESTID.TOGGLE_CHECKBOX,\n id: instanceUid,\n 'aria-readonly': readOnly,\n 'aria-disabled': disabled || applyAriaDisabled || readOnly,\n 'aria-checked': checked,\n 'aria-describedby': `${instanceUid}_feedback_message ${instanceUid}_error_message`,\n readOnly,\n disabled,\n ...restGlobalProps,\n type: 'button',\n buttonType: 'raw',\n onClick: handleOnClick,\n }),\n [instanceUid, readOnly, disabled, applyAriaDisabled, checked, restGlobalProps, handleOnClick],\n );\n return buttonProps;\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,eAAe;AACxB,SAAS,qCAAqC;AASvC,MAAM,oBAAoB,CAAC,WAAkF;AAClH,QAAM,EAAE,aAAa,aAAa,eAAe,iBAAiB,IAAI;AACtE,QAAM,EAAE,SAAS,UAAU,mBAAmB,SAAS,IAAI;AAG3D,QAAM,EAAE,MAAM,oBAAoB,OAAO,qBAAqB,GAAG,gBAAgB,IAAI;AACrF,QAAM,cAA2D;AAAA,IAC/D,OAAO;AAAA,MACL,MAAM;AAAA,MACN,eAAe,8BAA8B;AAAA,MAC7C,IAAI;AAAA,MACJ,iBAAiB;AAAA,MACjB,iBAAiB,YAAY,qBAAqB;AAAA,MAClD,gBAAgB;AAAA,MAChB,oBAAoB,GAAG,WAAW,qBAAqB,WAAW;AAAA,MAClE;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,SAAS;AAAA,IACX;AAAA,IACA,CAAC,aAAa,UAAU,UAAU,mBAAmB,SAAS,iBAAiB,aAAa;AAAA,EAC9F;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { GlobalAttributesT } from '@elliemae/ds-props-helpers';\nimport { resolveAriaDisabled } from '@elliemae/ds-props-helpers';\nimport { useMemo } from 'react';\nimport { CONTROLLED_TOGGLE_DATA_TESTID } from '../constants/index.js';\nimport { type DSControlledToggleT } from '../react-desc-prop-types.js';\n\ninterface UseGetButtonPropsConfigT {\n handleOnClick: (e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;\n globalProps: GlobalAttributesT<HTMLButtonElement>;\n propsWithDefault: DSControlledToggleT.InternalProps;\n instanceUid: string;\n}\nexport const useGetButtonProps = (config: UseGetButtonPropsConfigT): DSControlledToggleT.ButtonV3InherithedProps => {\n const { globalProps, instanceUid, handleOnClick, propsWithDefault } = config;\n const { checked, disabled, applyAriaDisabled, readOnly, hasError, makeSubmittable } = propsWithDefault;\n\n const {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n size: _sizeCleanFromRest,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n shape: _shapeCleanFromRest,\n 'aria-describedby': consumerAriaDescribedBy,\n ...restGlobalProps\n } = globalProps;\n // CONVENTION (not a bug): `${instanceUid}_feedback_message` and `${instanceUid}_error_message` are NOT rendered by the\n // toggle. They are the ids DSFormLayoutBlockItem always renders from its `inputID` prop (a StyledMessage /\n // StyledErrorMessage when there is a feedback / validation message, an empty ScreenReaderOnly otherwise, see\n // ds-form-layout-blocks DSFormLayoutBlockItem.tsx). When the toggle sits in a block item whose `inputID` equals the\n // toggle `id`, these references resolve to the block item's messages; outside a block item they have no element to\n // point at and are simply skipped when the description is computed. DSInputText follows the same convention.\n // A consumer aria-describedby replaces those ids (unchanged behaviour); readOnly appends the \"Read only\" helper\n // rendered by Container, so both the consumer ids and the helper are announced.\n const baseAriaDescribedBy = consumerAriaDescribedBy ?? `${instanceUid}_feedback_message ${instanceUid}_error_message`;\n const ariaDescribedBy = readOnly ? `${baseAriaDescribedBy} ${instanceUid}-read-only-helper-msg` : baseAriaDescribedBy;\n const buttonProps: DSControlledToggleT.ButtonV3InherithedProps = useMemo(() => {\n // when the toggle is submittable the hidden input is the one that carries name and value, the button must not\n const buttonGlobalProps = { ...restGlobalProps };\n if (makeSubmittable) {\n delete buttonGlobalProps.name;\n delete buttonGlobalProps.value;\n }\n return {\n role: 'switch',\n 'data-testid': CONTROLLED_TOGGLE_DATA_TESTID.TOGGLE_CHECKBOX,\n id: instanceUid,\n // readOnly and applyAriaDisabled are synonyms here: both emit aria-disabled=\"true\", never aria-readonly.\n // \"disabled\" stays native only (no aria-disabled).\n 'aria-checked': checked,\n 'aria-describedby': ariaDescribedBy,\n // only present when there is an error, so the markup of toggles without error does not change\n ...(hasError ? { 'aria-invalid': true } : {}),\n readOnly,\n disabled,\n // passed to DSButton so its own gate covers the consumer pointer/key handlers spread through restGlobalProps\n applyAriaDisabled,\n ...buttonGlobalProps,\n // after the spread: a soft lock prints \"true\" whatever the consumer passes, a natively disabled toggle prints none of\n // its own, otherwise the consumer's own aria-disabled passes through (inversion of control)\n // The key is always present (even when undefined) so it overrides DSButton's own aria-disabled.\n 'aria-disabled': resolveAriaDisabled({\n disabled,\n softLocked: applyAriaDisabled || readOnly,\n consumerValue: restGlobalProps['aria-disabled'],\n }),\n type: 'button',\n buttonType: 'raw',\n // replaces the consumer onClick (pre-existing: it is never called); handleOnClick gates onChange on all three props\n onClick: handleOnClick,\n };\n }, [\n instanceUid,\n readOnly,\n disabled,\n applyAriaDisabled,\n checked,\n hasError,\n makeSubmittable,\n restGlobalProps,\n ariaDescribedBy,\n handleOnClick,\n ]);\n return buttonProps;\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,2BAA2B;AACpC,SAAS,eAAe;AACxB,SAAS,qCAAqC;AASvC,MAAM,oBAAoB,CAAC,WAAkF;AAClH,QAAM,EAAE,aAAa,aAAa,eAAe,iBAAiB,IAAI;AACtE,QAAM,EAAE,SAAS,UAAU,mBAAmB,UAAU,UAAU,gBAAgB,IAAI;AAEtF,QAAM;AAAA;AAAA,IAEJ,MAAM;AAAA;AAAA,IAEN,OAAO;AAAA,IACP,oBAAoB;AAAA,IACpB,GAAG;AAAA,EACL,IAAI;AASJ,QAAM,sBAAsB,2BAA2B,GAAG,WAAW,qBAAqB,WAAW;AACrG,QAAM,kBAAkB,WAAW,GAAG,mBAAmB,IAAI,WAAW,0BAA0B;AAClG,QAAM,cAA2D,QAAQ,MAAM;AAE7E,UAAM,oBAAoB,EAAE,GAAG,gBAAgB;AAC/C,QAAI,iBAAiB;AACnB,aAAO,kBAAkB;AACzB,aAAO,kBAAkB;AAAA,IAC3B;AACA,WAAO;AAAA,MACL,MAAM;AAAA,MACN,eAAe,8BAA8B;AAAA,MAC7C,IAAI;AAAA;AAAA;AAAA,MAGJ,gBAAgB;AAAA,MAChB,oBAAoB;AAAA;AAAA,MAEpB,GAAI,WAAW,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAAA,MAC3C;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAG;AAAA;AAAA;AAAA;AAAA,MAIH,iBAAiB,oBAAoB;AAAA,QACnC;AAAA,QACA,YAAY,qBAAqB;AAAA,QACjC,eAAe,gBAAgB,eAAe;AAAA,MAChD,CAAC;AAAA,MACD,MAAM;AAAA,MACN,YAAY;AAAA;AAAA,MAEZ,SAAS;AAAA,IACX;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -5,6 +5,7 @@ const CONTROLLED_TOGGLE_SLOTS = {
5
5
  BUTTON_CONTENT_WRAPPER: "button-content-wrapper",
6
6
  CIRCLE: "circle",
7
7
  TEXT_WRAPPER: "text-wrapper",
8
+ HIDDEN_INPUT: "hidden-input",
8
9
  // legacy ones...
9
10
  CONTROLLED_CONTAINER: "controlled-container",
10
11
  // in other components this is the ROOT
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/constants/index.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSControlledToggleName = 'DSFormtoggle';\n\n// we are giving \"component_name_slots\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_SLOTS = {\n BUTTON_CONTENT_WRAPPER: 'button-content-wrapper',\n CIRCLE: 'circle',\n TEXT_WRAPPER: 'text-wrapper',\n // legacy ones...\n CONTROLLED_CONTAINER: 'controlled-container', // in other components this is the ROOT\n TOGGLE_CHECKBOX: 'toggle-checkbox',\n} as const;\n\n// we are giving \"component_name_data_testid\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_DATA_TESTID = {\n ...slotObjectToDataTestIds(DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS),\n CONTROLLED_CONTAINER: 'ds-controlled-toggle', // in other components this is the ROOT\n TOGGLE_CHECKBOX: 'ds-controlled-toggle-checkbox',\n};\n\n// Specific of the toggle component\n\nexport const TOGGLE_SIZES = {\n SMALL: 's',\n MEDIUM: 'm',\n LARGE: 'l',\n} as const;\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,yBAAyB;AAG/B,MAAM,0BAA0B;AAAA,EACrC,wBAAwB;AAAA,EACxB,QAAQ;AAAA,EACR,cAAc;AAAA;AAAA,EAEd,sBAAsB;AAAA;AAAA,EACtB,iBAAiB;AACnB;AAGO,MAAM,gCAAgC;AAAA,EAC3C,GAAG,wBAAwB,wBAAwB,uBAAuB;AAAA,EAC1E,sBAAsB;AAAA;AAAA,EACtB,iBAAiB;AACnB;AAIO,MAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACT;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSControlledToggleName = 'DSFormtoggle';\n\n// we are giving \"component_name_slots\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_SLOTS = {\n BUTTON_CONTENT_WRAPPER: 'button-content-wrapper',\n CIRCLE: 'circle',\n TEXT_WRAPPER: 'text-wrapper',\n HIDDEN_INPUT: 'hidden-input',\n // legacy ones...\n CONTROLLED_CONTAINER: 'controlled-container', // in other components this is the ROOT\n TOGGLE_CHECKBOX: 'toggle-checkbox',\n} as const;\n\n// we are giving \"component_name_data_testid\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_DATA_TESTID = {\n ...slotObjectToDataTestIds(DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS),\n CONTROLLED_CONTAINER: 'ds-controlled-toggle', // in other components this is the ROOT\n TOGGLE_CHECKBOX: 'ds-controlled-toggle-checkbox',\n};\n\n// Specific of the toggle component\n\nexport const TOGGLE_SIZES = {\n SMALL: 's',\n MEDIUM: 'm',\n LARGE: 'l',\n} as const;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,yBAAyB;AAG/B,MAAM,0BAA0B;AAAA,EACrC,wBAAwB;AAAA,EACxB,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,cAAc;AAAA;AAAA,EAEd,sBAAsB;AAAA;AAAA,EACtB,iBAAiB;AACnB;AAGO,MAAM,gCAAgC;AAAA,EAC3C,GAAG,wBAAwB,wBAAwB,uBAAuB;AAAA,EAC1E,sBAAsB;AAAA;AAAA,EACtB,iBAAiB;AACnB;AAIO,MAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -12,18 +12,18 @@ const widthSizeMap = {
12
12
  };
13
13
  const Button = () => {
14
14
  const { propsWithDefault, buttonProps } = React2.useContext(ControlledToggleContext);
15
- const { checked, size, disabled, applyAriaDisabled, readOnly, innerRef } = propsWithDefault;
15
+ const { checked, size, disabled, applyAriaDisabled, readOnly, hasError, innerRef } = propsWithDefault;
16
16
  const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);
17
17
  return /* @__PURE__ */ jsx(
18
18
  StyledButton,
19
19
  {
20
- ...readOnly ? { "aria-readonly": "true" } : {},
21
20
  ...buttonProps,
22
21
  innerRef,
23
22
  $checked: checked,
24
23
  $readOnly: readOnly,
25
24
  $disabled: disabled,
26
25
  $applyAriaDisabled: applyAriaDisabled,
26
+ $hasError: hasError,
27
27
  getOwnerProps,
28
28
  getOwnerPropsArguments,
29
29
  children: /* @__PURE__ */ jsxs(
@@ -42,6 +42,7 @@ const Button = () => {
42
42
  $disabled: disabled,
43
43
  $readOnly: readOnly,
44
44
  $applyAriaDisabled: applyAriaDisabled,
45
+ $hasError: hasError,
45
46
  getOwnerProps,
46
47
  getOwnerPropsArguments
47
48
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Button.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport React from 'react';\nimport { ControlledToggleContext } from '../DSControlledToggleCTX.js';\nimport { type DSControlledToggleT } from '../react-desc-prop-types.js';\nimport { StyledButton, StyledButtonContentWrapper, StyledCircle, StyledTextWrapper } from './styles/styles.js';\n\n// What is this about?\n// Currently the way the code is written for this component and the way this component UI/UX specs are handled\n// there is no defiend \"dynamic\" and \"responsive\" sizes also, the font-size are hardcoded and not aligned with typography in the different \"size\" variants.\n// In the past we accepted \"whatever\" labels for the toggle,\n// it was discarded as non compliant for the semantic of the component that only announces and accepts the \"on\" and \"off\" meaning,\n// as of today, wcag compliant way has an hardcoded \"ON\" and \"OFF\"/\n// The previous implementation was relying on a dynamic calculation of the width to keep the size of the toggle button,\n// it had it's own set of issues and was creating extra renders (see PUI-18655).\n\n// This constant is just the pre-calculated values to avoid extra javascript logic and extra renderes.\n\n// What does this means long term?\n// - When the font-size is aligned, the component specs are made responsive and the component will support \"text resize/reflow\",\n// - When the px will change to rem\n// - When the component will be updated to support \"tokens\"\n// - When/if the component will be i18n compliant and support different languages labels that are the other language version of \"on\" and \"off\" (like \"activ\u00E9\" and \"d\u00E9sactiv\u00E9\" in french)\n\n// The whole size calcualtion logic of the component needs to be reviewed and updated to not need a constant \"width\" to guarante the width to be \"the biggest of the two labels\".\n\n// The most reasonable implementation would be to:\n// - simply render both \"on\" and \"off\" in the DOM at the same time\n// - make the not active version influence the size but not visible (e.g. height:0, overflow:hidden)\n// - have the width be automatically calculated by the browser to fit the longest.\n\n// I can't implement this as part of the current ticket(PUI-16323) as that would be a visual breaking change and need coordination with QA and UX.\n\n// So, short term solution:\n// - Not responsive (in the rem, text resize WCAG sense, still is in the \"zoom\" sense as before)\n// - Not i18n compliant\n// - Not theming ready\n// Exactly as we never wrote the component to be, but at least it won't:\n// - flicker\n// - pay the cost of the WCAG non-compliant labels\n// - hide the pending issues with aproximation that \"happens to kinda fix it\"\n// Important note -> I changed the \"width\" to \"min-width\" to keep some amount of resize/reflow WCAG compliant (zoom will keep working, font size changes won't like before),\n// but true wcag compliance requires the component to use typography, be designed accordingly, written accordingly and rely on rem.\nconst widthSizeMap = {\n s: 18,\n m: 26,\n l: 36,\n} as const;\n\nexport const Button: React.ComponentType<DSControlledToggleT.Props> = () => {\n const { propsWithDefault, buttonProps } = React.useContext(ControlledToggleContext);\n const { checked, size, disabled, applyAriaDisabled, readOnly, innerRef } = propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n\n return (\n <StyledButton\n // as per morning meeting, juan said \"readOnly\" in toggle should receive aria-readonly, aria-readonly is valid for switch role, the html readonly attribute is not\n {...(readOnly ? { 'aria-readonly': 'true' } : {})}\n {...buttonProps}\n /**\n * PUI-14730\n * innerRef is not a global attribute, so it is not carried by buttonProps; forward it\n * explicitly to reach the underlying <button> DOM node (parity with radio/checkbox)\n */\n innerRef={innerRef}\n $checked={checked}\n $readOnly={readOnly}\n $disabled={disabled}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledButtonContentWrapper\n $width={widthSizeMap[size]}\n $checked={checked}\n $size={size}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledCircle\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n <StyledTextWrapper\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n variant={TYPOGRAPHY_VARIANTS.B2}\n // this is \"okay\" in this version but not in the WCAGViolation code\n // the reason being that a role switch with proper \"aria-checked\" already announces \"on\" and \"off\" to screen readers\n // so this is just a visual representation of the state, not a semantic one\n // the WCAGViolation code is violating this contract with custom labels and they need to be announced, so they can't be hidden from screen readers\n // and they can't be considered \"presentational\" as they are meaning bearing for scenario with custom texts (which is exactly WHY role switch is wrong in that case)\n // confirmed with Juan, this avoids the \"double announcement\" issue that was happening with the previous implementation of the component\n role=\"presentation\"\n aria-hidden=\"true\"\n >\n {checked ? 'ON' : 'OFF'}\n </StyledTextWrapper>\n </StyledButtonContentWrapper>\n </StyledButton>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACwEjB,SAOE,KAPF;AAxEN,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,OAAOA,YAAW;AAClB,SAAS,+BAA+B;AAExC,SAAS,cAAc,4BAA4B,cAAc,yBAAyB;AAsC1F,MAAM,eAAe;AAAA,EACnB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,MAAM,SAAyD,MAAM;AAC1E,QAAM,EAAE,kBAAkB,YAAY,IAAIA,OAAM,WAAW,uBAAuB;AAClF,QAAM,EAAE,SAAS,MAAM,UAAU,mBAAmB,UAAU,SAAS,IAAI;AAC3E,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAEhF,SACE;AAAA,IAAC;AAAA;AAAA,MAEE,GAAI,WAAW,EAAE,iBAAiB,OAAO,IAAI,CAAC;AAAA,MAC9C,GAAG;AAAA,MAMJ;AAAA,MACA,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,QAAQ,aAAa,IAAI;AAAA,UACzB,UAAU;AAAA,UACV,OAAO;AAAA,UACP;AAAA,UACA;AAAA,UAEA;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,oBAAoB;AAAA,gBACpB;AAAA,gBACA;AAAA;AAAA,YACF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,oBAAoB;AAAA,gBACpB;AAAA,gBACA;AAAA,gBACA,SAAS,oBAAoB;AAAA,gBAO7B,MAAK;AAAA,gBACL,eAAY;AAAA,gBAEX,oBAAU,OAAO;AAAA;AAAA,YACpB;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport React from 'react';\nimport { ControlledToggleContext } from '../DSControlledToggleCTX.js';\nimport { type DSControlledToggleT } from '../react-desc-prop-types.js';\nimport { StyledButton, StyledButtonContentWrapper, StyledCircle, StyledTextWrapper } from './styles/styles.js';\n\n// What is this about?\n// Currently the way the code is written for this component and the way this component UI/UX specs are handled\n// there is no defiend \"dynamic\" and \"responsive\" sizes also, the font-size are hardcoded and not aligned with typography in the different \"size\" variants.\n// In the past we accepted \"whatever\" labels for the toggle,\n// it was discarded as non compliant for the semantic of the component that only announces and accepts the \"on\" and \"off\" meaning,\n// as of today, wcag compliant way has an hardcoded \"ON\" and \"OFF\"/\n// The previous implementation was relying on a dynamic calculation of the width to keep the size of the toggle button,\n// it had it's own set of issues and was creating extra renders (see PUI-18655).\n\n// This constant is just the pre-calculated values to avoid extra javascript logic and extra renderes.\n\n// What does this means long term?\n// - When the font-size is aligned, the component specs are made responsive and the component will support \"text resize/reflow\",\n// - When the px will change to rem\n// - When the component will be updated to support \"tokens\"\n// - When/if the component will be i18n compliant and support different languages labels that are the other language version of \"on\" and \"off\" (like \"activ\u00E9\" and \"d\u00E9sactiv\u00E9\" in french)\n\n// The whole size calcualtion logic of the component needs to be reviewed and updated to not need a constant \"width\" to guarante the width to be \"the biggest of the two labels\".\n\n// The most reasonable implementation would be to:\n// - simply render both \"on\" and \"off\" in the DOM at the same time\n// - make the not active version influence the size but not visible (e.g. height:0, overflow:hidden)\n// - have the width be automatically calculated by the browser to fit the longest.\n\n// I can't implement this as part of the current ticket(PUI-16323) as that would be a visual breaking change and need coordination with QA and UX.\n\n// So, short term solution:\n// - Not responsive (in the rem, text resize WCAG sense, still is in the \"zoom\" sense as before)\n// - Not i18n compliant\n// - Not theming ready\n// Exactly as we never wrote the component to be, but at least it won't:\n// - flicker\n// - pay the cost of the WCAG non-compliant labels\n// - hide the pending issues with aproximation that \"happens to kinda fix it\"\n// Important note -> I changed the \"width\" to \"min-width\" to keep some amount of resize/reflow WCAG compliant (zoom will keep working, font size changes won't like before),\n// but true wcag compliance requires the component to use typography, be designed accordingly, written accordingly and rely on rem.\nconst widthSizeMap = {\n s: 18,\n m: 26,\n l: 36,\n} as const;\n\nexport const Button: React.ComponentType<DSControlledToggleT.Props> = () => {\n const { propsWithDefault, buttonProps } = React.useContext(ControlledToggleContext);\n const { checked, size, disabled, applyAriaDisabled, readOnly, hasError, innerRef } = propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n\n return (\n <StyledButton\n {...buttonProps}\n /**\n * PUI-14730\n * innerRef is not a global attribute, so it is not carried by buttonProps; forward it\n * explicitly to reach the underlying <button> DOM node (parity with radio/checkbox)\n */\n innerRef={innerRef}\n $checked={checked}\n $readOnly={readOnly}\n $disabled={disabled}\n $applyAriaDisabled={applyAriaDisabled}\n $hasError={hasError}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledButtonContentWrapper\n $width={widthSizeMap[size]}\n $checked={checked}\n $size={size}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledCircle\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n $hasError={hasError}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n <StyledTextWrapper\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n variant={TYPOGRAPHY_VARIANTS.B2}\n // this is \"okay\" in this version but not in the WCAGViolation code\n // the reason being that a role switch with proper \"aria-checked\" already announces \"on\" and \"off\" to screen readers\n // so this is just a visual representation of the state, not a semantic one\n // the WCAGViolation code is violating this contract with custom labels and they need to be announced, so they can't be hidden from screen readers\n // and they can't be considered \"presentational\" as they are meaning bearing for scenario with custom texts (which is exactly WHY role switch is wrong in that case)\n // confirmed with Juan, this avoids the \"double announcement\" issue that was happening with the previous implementation of the component\n role=\"presentation\"\n aria-hidden=\"true\"\n >\n {checked ? 'ON' : 'OFF'}\n </StyledTextWrapper>\n </StyledButtonContentWrapper>\n </StyledButton>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACuEjB,SAOE,KAPF;AAvEN,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,OAAOA,YAAW;AAClB,SAAS,+BAA+B;AAExC,SAAS,cAAc,4BAA4B,cAAc,yBAAyB;AAsC1F,MAAM,eAAe;AAAA,EACnB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,MAAM,SAAyD,MAAM;AAC1E,QAAM,EAAE,kBAAkB,YAAY,IAAIA,OAAM,WAAW,uBAAuB;AAClF,QAAM,EAAE,SAAS,MAAM,UAAU,mBAAmB,UAAU,UAAU,SAAS,IAAI;AACrF,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAEhF,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MAMJ;AAAA,MACA,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,QAAQ,aAAa,IAAI;AAAA,UACzB,UAAU;AAAA,UACV,OAAO;AAAA,UACP;AAAA,UACA;AAAA,UAEA;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,oBAAoB;AAAA,gBACpB,WAAW;AAAA,gBACX;AAAA,gBACA;AAAA;AAAA,YACF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,oBAAoB;AAAA,gBACpB;AAAA,gBACA;AAAA,gBACA,SAAS,oBAAoB;AAAA,gBAO7B,MAAK;AAAA,gBACL,eAAY;AAAA,gBAEX,oBAAU,OAAO;AAAA;AAAA,YACpB;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": ["React"]
7
7
  }
@@ -1,27 +1,55 @@
1
1
  import * as React from "react";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useOwnerProps } from "@elliemae/ds-props-helpers";
4
4
  import React2 from "react";
5
5
  import { CONTROLLED_TOGGLE_DATA_TESTID } from "../constants/index.js";
6
6
  import { ControlledToggleContext } from "../DSControlledToggleCTX.js";
7
7
  import { Button } from "./Button.js";
8
8
  import { ButtonWCAGViolation } from "./wcagViolation/Button.wcagViolationLabels.js";
9
- import { StyledContainer } from "./styles/styles.js";
9
+ import { StyledContainer, StyledHiddenInput } from "./styles/styles.js";
10
10
  const Container = () => {
11
- const { propsWithDefault, xstyledProps } = React2.useContext(ControlledToggleContext);
12
- const { wcagViolationLabelOn, wcagViolationLabelOff, size, containerProps } = propsWithDefault;
11
+ const { propsWithDefault, xstyledProps, instanceUid } = React2.useContext(ControlledToggleContext);
12
+ const {
13
+ wcagViolationLabelOn,
14
+ wcagViolationLabelOff,
15
+ size,
16
+ containerProps,
17
+ makeSubmittable,
18
+ checked,
19
+ disabled,
20
+ readOnly,
21
+ name,
22
+ value
23
+ } = propsWithDefault;
13
24
  const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);
14
25
  const isViolationVersion = wcagViolationLabelOn || wcagViolationLabelOff;
15
- return /* @__PURE__ */ jsx(
26
+ return /* @__PURE__ */ jsxs(
16
27
  StyledContainer,
17
28
  {
18
29
  $size: size,
30
+ $disabled: Boolean(disabled),
19
31
  "data-testid": CONTROLLED_TOGGLE_DATA_TESTID.CONTROLLED_CONTAINER,
20
32
  ...containerProps,
21
33
  ...xstyledProps,
22
34
  getOwnerProps,
23
35
  getOwnerPropsArguments,
24
- children: isViolationVersion ? /* @__PURE__ */ jsx(ButtonWCAGViolation, { ...propsWithDefault }) : /* @__PURE__ */ jsx(Button, { ...propsWithDefault })
36
+ children: [
37
+ isViolationVersion ? /* @__PURE__ */ jsx(ButtonWCAGViolation, { ...propsWithDefault }) : /* @__PURE__ */ jsx(Button, { ...propsWithDefault }),
38
+ readOnly ? /* @__PURE__ */ jsx("p", { hidden: true, id: `${instanceUid}-read-only-helper-msg`, children: "Read only" }) : null,
39
+ makeSubmittable ? /* @__PURE__ */ jsx(
40
+ StyledHiddenInput,
41
+ {
42
+ type: "checkbox",
43
+ checked,
44
+ readOnly: true,
45
+ disabled,
46
+ name,
47
+ value,
48
+ getOwnerProps,
49
+ getOwnerPropsArguments
50
+ }
51
+ ) : null
52
+ ]
25
53
  }
26
54
  );
27
55
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Container.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport React from 'react';\nimport { CONTROLLED_TOGGLE_DATA_TESTID } from '../constants/index.js';\nimport { ControlledToggleContext } from '../DSControlledToggleCTX.js';\nimport { Button } from './Button.js';\nimport { ButtonWCAGViolation } from './wcagViolation/Button.wcagViolationLabels.js';\nimport { StyledContainer } from './styles/styles.js';\n\nexport const Container = () => {\n const { propsWithDefault, xstyledProps } = React.useContext(ControlledToggleContext);\n const { wcagViolationLabelOn, wcagViolationLabelOff, size, containerProps } = propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n\n const isViolationVersion = wcagViolationLabelOn || wcagViolationLabelOff;\n\n return (\n <StyledContainer\n $size={size}\n data-testid={CONTROLLED_TOGGLE_DATA_TESTID.CONTROLLED_CONTAINER}\n {...containerProps}\n {...xstyledProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {isViolationVersion ? <ButtonWCAGViolation {...propsWithDefault} /> : <Button {...propsWithDefault} />}\n </StyledContainer>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACwBK;AAxB5B,SAAS,qBAAqB;AAC9B,OAAOA,YAAW;AAClB,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAEzB,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,kBAAkB,aAAa,IAAIA,OAAM,WAAW,uBAAuB;AACnF,QAAM,EAAE,sBAAsB,uBAAuB,MAAM,eAAe,IAAI;AAC9E,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAEhF,QAAM,qBAAqB,wBAAwB;AAEnD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,eAAa,8BAA8B;AAAA,MAC1C,GAAG;AAAA,MACH,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MAEC,+BAAqB,oBAAC,uBAAqB,GAAG,kBAAkB,IAAK,oBAAC,UAAQ,GAAG,kBAAkB;AAAA;AAAA,EACtG;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport React from 'react';\nimport { CONTROLLED_TOGGLE_DATA_TESTID } from '../constants/index.js';\nimport { ControlledToggleContext } from '../DSControlledToggleCTX.js';\nimport { Button } from './Button.js';\nimport { ButtonWCAGViolation } from './wcagViolation/Button.wcagViolationLabels.js';\nimport { StyledContainer, StyledHiddenInput } from './styles/styles.js';\n\nexport const Container = () => {\n const { propsWithDefault, xstyledProps, instanceUid } = React.useContext(ControlledToggleContext);\n const {\n wcagViolationLabelOn,\n wcagViolationLabelOff,\n size,\n containerProps,\n makeSubmittable,\n checked,\n disabled,\n readOnly,\n name,\n value,\n } = propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n\n const isViolationVersion = wcagViolationLabelOn || wcagViolationLabelOff;\n\n return (\n <StyledContainer\n $size={size}\n $disabled={Boolean(disabled)}\n data-testid={CONTROLLED_TOGGLE_DATA_TESTID.CONTROLLED_CONTAINER}\n {...containerProps}\n {...xstyledProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {isViolationVersion ? <ButtonWCAGViolation {...propsWithDefault} /> : <Button {...propsWithDefault} />}\n {/* READ-ONLY helper: hidden, referenced by the button's aria-describedby. Plain element, not a slot. */}\n {readOnly ? (\n <p hidden id={`${instanceUid}-read-only-helper-msg`}>\n Read only\n </p>\n ) : null}\n {makeSubmittable ? (\n <StyledHiddenInput\n type=\"checkbox\"\n // the hidden input mirrors the toggle: the user can't interact with it, the toggle is the source of truth\n checked={checked}\n readOnly\n disabled={disabled}\n name={name}\n value={value}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n ) : null}\n </StyledContainer>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;AC2BnB,SASwB,KATxB;AA3BJ,SAAS,qBAAqB;AAC9B,OAAOA,YAAW;AAClB,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,yBAAyB;AAE5C,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,kBAAkB,cAAc,YAAY,IAAIA,OAAM,WAAW,uBAAuB;AAChG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAEhF,QAAM,qBAAqB,wBAAwB;AAEnD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,WAAW,QAAQ,QAAQ;AAAA,MAC3B,eAAa,8BAA8B;AAAA,MAC1C,GAAG;AAAA,MACH,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MAEC;AAAA,6BAAqB,oBAAC,uBAAqB,GAAG,kBAAkB,IAAK,oBAAC,UAAQ,GAAG,kBAAkB;AAAA,QAEnG,WACC,oBAAC,OAAE,QAAM,MAAC,IAAI,GAAG,WAAW,yBAAyB,uBAErD,IACE;AAAA,QACH,kBACC;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YAEL;AAAA,YACA,UAAQ;AAAA,YACR;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACF,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;",
6
6
  "names": ["React"]
7
7
  }