@elliemae/ds-form-checkbox 3.10.0-next.9 → 3.10.2

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 (45) hide show
  1. package/dist/cjs/ControlledCheckbox.js +7 -106
  2. package/dist/cjs/ControlledCheckbox.js.map +2 -2
  3. package/dist/cjs/ControlledCheckboxCTX.js +36 -0
  4. package/dist/cjs/ControlledCheckboxCTX.js.map +7 -0
  5. package/dist/cjs/config/useCheckBox.js +56 -0
  6. package/dist/cjs/config/useCheckBox.js.map +7 -0
  7. package/dist/cjs/config/useEventHandlers.js +67 -0
  8. package/dist/cjs/config/useEventHandlers.js.map +7 -0
  9. package/dist/cjs/config/useValidateProps.js +0 -15
  10. package/dist/cjs/config/useValidateProps.js.map +2 -2
  11. package/dist/cjs/constants/device.js +35 -0
  12. package/dist/cjs/constants/device.js.map +7 -0
  13. package/dist/cjs/exported-related/data-test-ids.js.map +1 -1
  14. package/dist/cjs/exported-related/theming.js.map +1 -1
  15. package/dist/cjs/parts/ControlledCheckBoxContent.js +74 -0
  16. package/dist/cjs/parts/ControlledCheckBoxContent.js.map +7 -0
  17. package/dist/cjs/parts/MainInput.js +76 -0
  18. package/dist/cjs/parts/MainInput.js.map +7 -0
  19. package/dist/cjs/react-desc-prop-types.js +22 -9
  20. package/dist/cjs/react-desc-prop-types.js.map +2 -2
  21. package/dist/cjs/utils/styleHelpers.js +0 -1
  22. package/dist/cjs/utils/styleHelpers.js.map +2 -2
  23. package/dist/esm/ControlledCheckbox.js +10 -114
  24. package/dist/esm/ControlledCheckbox.js.map +2 -2
  25. package/dist/esm/ControlledCheckboxCTX.js +10 -0
  26. package/dist/esm/ControlledCheckboxCTX.js.map +7 -0
  27. package/dist/esm/config/useCheckBox.js +30 -0
  28. package/dist/esm/config/useCheckBox.js.map +7 -0
  29. package/dist/esm/config/useEventHandlers.js +41 -0
  30. package/dist/esm/config/useEventHandlers.js.map +7 -0
  31. package/dist/esm/config/useValidateProps.js +0 -15
  32. package/dist/esm/config/useValidateProps.js.map +2 -2
  33. package/dist/esm/constants/device.js +9 -0
  34. package/dist/esm/constants/device.js.map +7 -0
  35. package/dist/esm/exported-related/data-test-ids.js.map +1 -1
  36. package/dist/esm/exported-related/theming.js.map +1 -1
  37. package/dist/esm/parts/ControlledCheckBoxContent.js +48 -0
  38. package/dist/esm/parts/ControlledCheckBoxContent.js.map +7 -0
  39. package/dist/esm/parts/MainInput.js +50 -0
  40. package/dist/esm/parts/MainInput.js.map +7 -0
  41. package/dist/esm/react-desc-prop-types.js +23 -10
  42. package/dist/esm/react-desc-prop-types.js.map +2 -2
  43. package/dist/esm/utils/styleHelpers.js +0 -1
  44. package/dist/esm/utils/styleHelpers.js.map +2 -2
  45. package/package.json +7 -4
@@ -30,25 +30,38 @@ __export(react_desc_prop_types_exports, {
30
30
  module.exports = __toCommonJS(react_desc_prop_types_exports);
31
31
  var React = __toESM(require("react"));
32
32
  var import_ds_utilities = require("@elliemae/ds-utilities");
33
+ var import_device = require("./constants/device");
33
34
  const defaultProps = {
34
35
  wrapLabel: false,
35
36
  hasError: false,
36
- tabIndex: void 0,
37
37
  checked: false,
38
- onKeyDown: () => null
38
+ disabled: false,
39
+ readOnly: false,
40
+ tabIndex: 0,
41
+ onChange: () => {
42
+ }
39
43
  };
40
44
  const propTypes = {
41
45
  ...import_ds_utilities.globalAttributesPropTypes,
46
+ ...import_ds_utilities.xstyledPropTypes,
47
+ checked: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.bool, import_ds_utilities.PropTypes.string]).description("Wheter the checkbox is set as bool or mixed").defaultValue(false).isRequired,
48
+ onChange: import_ds_utilities.PropTypes.func.description("function executed when the checkbox changes state").signature("(( newIsChecked: boolean, e: React.SyntheticEvent ) => void )").isRequiredIf((props) => !props.disabled && !props.readOnly),
49
+ "aria-controls": import_ds_utilities.PropTypes.string.description('a11y required attribute when "mixed" state is to be supported').isRequiredIf(
50
+ (props) => props.checked === "mixed" && typeof props.ariaControls !== "string"
51
+ ),
52
+ ariaControls: import_ds_utilities.PropTypes.string.description('deprecated equivalent of "aria-controls", please use "aria-controls" instead').deprecated({ version: "3.x", message: 'use "aria-controls" instead' }).isRequiredIf(
53
+ (props) => props.checked === "mixed" && typeof props["aria-controls"] !== "string"
54
+ ),
42
55
  label: import_ds_utilities.PropTypes.string.description(
43
56
  "Checkbox Label property. This label is also going to be used as an aria-label for screen readers."
44
57
  ),
45
- checked: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.bool, import_ds_utilities.PropTypes.string]).description(
46
- "Wheter the checkbox is set as bool or mixed"
58
+ hasError: import_ds_utilities.PropTypes.bool.description("Whether the checkbox has error or not.").defaultValue(false),
59
+ disabled: import_ds_utilities.PropTypes.bool.description("Whether the checkbox is disabled or not.").defaultValue(false),
60
+ readOnly: import_ds_utilities.PropTypes.bool.description("Whether the checkbox is disabled or not.").defaultValue(false),
61
+ wrapLabel: import_ds_utilities.PropTypes.bool.description("Whether to wrap or truncate the label").defaultValue(false),
62
+ device: import_ds_utilities.PropTypes.oneOf(Object.values(import_device.DEVICE)).description(
63
+ "When not provide will scale via css breakpoint media queries, if provided, breakpoint will be ignored in favor of explicit devide declaration"
47
64
  ),
48
- hasError: import_ds_utilities.PropTypes.bool.description("Whether the checkbox has error or not."),
49
- innerRef: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.func, import_ds_utilities.PropTypes.object]).description("Checkbox input ref."),
50
- onChange: import_ds_utilities.PropTypes.func.description("function executed when the checkbox changes"),
51
- wrapLabel: import_ds_utilities.PropTypes.bool.description("Whether to wrap or truncate the label"),
52
- device: import_ds_utilities.PropTypes.string.description("Whether to use mobile styling")
65
+ innerRef: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.func, import_ds_utilities.PropTypes.object]).description("Checkbox input ref.")
53
66
  };
54
67
  //# sourceMappingURL=react-desc-prop-types.js.map
@@ -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 React from 'react';\nimport { GlobalAttributesT, PropTypes, globalAttributesPropTypes } from '@elliemae/ds-utilities';\nexport declare namespace DSControlledCheckboxT {\n export interface DefaultProps {\n checked: boolean | 'mixed';\n tabIndex: number;\n hasError: boolean;\n wrapLabel: boolean;\n disabled: boolean;\n }\n\n export interface OptionalProps {\n innerRef?: React.RefObject<HTMLInputElement>;\n 'data-testid'?: string;\n device?: 'mobile' | 'desktop';\n }\n\n export interface LegacyAriaProps {\n ariaControls?: string;\n ariaLabel?: string;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps>,\n LegacyAriaProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps>,\n LegacyAriaProps {}\n\n export interface StyledCheckBoxT {\n checked: boolean | 'mixed';\n readOnly?: boolean;\n hasError?: boolean;\n disabled?: boolean;\n device?: 'mobile' | 'desktop';\n }\n\n export interface StyledLabelT {\n disabled?: boolean;\n readOnly?: boolean;\n checked: boolean | 'mixed';\n wrapLabel: boolean;\n device?: 'mobile' | 'desktop';\n }\n}\n\nexport const defaultProps: Partial<DSControlledCheckboxT.Props> = {\n wrapLabel: false,\n hasError: false,\n tabIndex: undefined,\n checked: false,\n onKeyDown: () => null,\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n label: PropTypes.string.description(\n 'Checkbox Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]).description(\n 'Wheter the checkbox is set as bool or mixed',\n ),\n hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.'),\n onChange: PropTypes.func.description('function executed when the checkbox changes'),\n wrapLabel: PropTypes.bool.description('Whether to wrap or truncate the label'),\n device: PropTypes.string.description('Whether to use mobile styling'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAAwE;AAkDjE,MAAM,eAAqD;AAAA,EAChE,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW,MAAM;AACnB;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,OAAO,8BAAU,OAAO;AAAA,IACtB;AAAA,EACF;AAAA,EACA,SAAS,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,MAAM,CAAC,EAAE;AAAA,IAC/D;AAAA,EACF;AAAA,EACA,UAAU,8BAAU,KAAK,YAAY,wCAAwC;AAAA,EAC7E,UAAU,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,MAAM,CAAC,EAAE,YAAY,qBAAqB;AAAA,EACnG,UAAU,8BAAU,KAAK,YAAY,6CAA6C;AAAA,EAClF,WAAW,8BAAU,KAAK,YAAY,uCAAuC;AAAA,EAC7E,QAAQ,8BAAU,OAAO,YAAY,+BAA+B;AACtE;",
4
+ "sourcesContent": ["import React from 'react';\nimport { GlobalAttributesT, PropTypes, globalAttributesPropTypes, xstyledPropTypes } from '@elliemae/ds-utilities';\nimport { DEVICE } from './constants/device';\nexport declare namespace DSControlledCheckboxT {\n type DevicesKeys = keyof typeof DEVICE;\n type Devices = typeof DEVICE[DevicesKeys];\n\n export interface DefaultProps {\n checked: boolean | 'mixed';\n tabIndex: WCAGTabIndex;\n hasError: boolean;\n wrapLabel: boolean;\n disabled: boolean;\n readOnly: boolean;\n onChange: (\n newVal: boolean,\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLabelElement>\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n ) => void;\n }\n\n export interface OptionalProps {\n onKeyDown: React.KeyboardEventHandler;\n innerRef?: React.RefObject<HTMLInputElement>;\n 'data-testid'?: string;\n device?: Devices;\n }\n\n export interface LegacyAriaProps {\n ariaControls?: string;\n ariaLabel?: string;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof OptionalProps>,\n LegacyAriaProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof OptionalProps>,\n LegacyAriaProps {}\n\n export interface StyledCheckBoxT {\n checked: boolean | 'mixed';\n readOnly?: boolean;\n hasError?: boolean;\n disabled?: boolean;\n device?: Devices;\n }\n\n export interface StyledLabelT {\n disabled?: boolean;\n readOnly?: boolean;\n checked: boolean | 'mixed';\n wrapLabel: boolean;\n device?: Devices;\n }\n}\n\nexport const defaultProps: DSControlledCheckboxT.DefaultProps = {\n wrapLabel: false,\n hasError: false,\n checked: false,\n disabled: false,\n readOnly: false,\n tabIndex: 0,\n onChange: () => {},\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.string])\n .description('Wheter the checkbox is set as bool or mixed')\n .defaultValue(false).isRequired,\n onChange: PropTypes.func\n .description('function executed when the checkbox changes state')\n .signature('(( newIsChecked: boolean, e: React.SyntheticEvent ) => void )')\n .isRequiredIf((props: DSControlledCheckboxT.Props) => !props.disabled && !props.readOnly),\n 'aria-controls': PropTypes.string\n .description('a11y required attribute when \"mixed\" state is to be supported')\n .isRequiredIf(\n (props: DSControlledCheckboxT.Props) => props.checked === 'mixed' && typeof props.ariaControls !== 'string',\n ),\n ariaControls: PropTypes.string\n .description('deprecated equivalent of \"aria-controls\", please use \"aria-controls\" instead')\n .deprecated({ version: '3.x', message: 'use \"aria-controls\" instead' })\n .isRequiredIf(\n (props: DSControlledCheckboxT.Props) => props.checked === 'mixed' && typeof props['aria-controls'] !== 'string',\n ),\n label: PropTypes.string.description(\n 'Checkbox Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n hasError: PropTypes.bool.description('Whether the checkbox has error or not.').defaultValue(false),\n disabled: PropTypes.bool.description('Whether the checkbox is disabled or not.').defaultValue(false),\n readOnly: PropTypes.bool.description('Whether the checkbox is disabled or not.').defaultValue(false),\n wrapLabel: PropTypes.bool.description('Whether to wrap or truncate the label').defaultValue(false),\n device: PropTypes.oneOf(Object.values(DEVICE)).description(\n 'When not provide will scale via css breakpoint media queries, if provided, breakpoint will be ignored in favor of explicit devide declaration',\n ),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAA0F;AAC1F,oBAAuB;AA+DhB,MAAM,eAAmD;AAAA,EAC9D,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU,MAAM;AAAA,EAAC;AACnB;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,SAAS,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,MAAM,CAAC,EAC5D,YAAY,6CAA6C,EACzD,aAAa,KAAK,EAAE;AAAA,EACvB,UAAU,8BAAU,KACjB,YAAY,mDAAmD,EAC/D,UAAU,+DAA+D,EACzE,aAAa,CAAC,UAAuC,CAAC,MAAM,YAAY,CAAC,MAAM,QAAQ;AAAA,EAC1F,iBAAiB,8BAAU,OACxB,YAAY,+DAA+D,EAC3E;AAAA,IACC,CAAC,UAAuC,MAAM,YAAY,WAAW,OAAO,MAAM,iBAAiB;AAAA,EACrG;AAAA,EACF,cAAc,8BAAU,OACrB,YAAY,8EAA8E,EAC1F,WAAW,EAAE,SAAS,OAAO,SAAS,8BAA8B,CAAC,EACrE;AAAA,IACC,CAAC,UAAuC,MAAM,YAAY,WAAW,OAAO,MAAM,qBAAqB;AAAA,EACzG;AAAA,EACF,OAAO,8BAAU,OAAO;AAAA,IACtB;AAAA,EACF;AAAA,EACA,UAAU,8BAAU,KAAK,YAAY,wCAAwC,EAAE,aAAa,KAAK;AAAA,EACjG,UAAU,8BAAU,KAAK,YAAY,0CAA0C,EAAE,aAAa,KAAK;AAAA,EACnG,UAAU,8BAAU,KAAK,YAAY,0CAA0C,EAAE,aAAa,KAAK;AAAA,EACnG,WAAW,8BAAU,KAAK,YAAY,uCAAuC,EAAE,aAAa,KAAK;AAAA,EACjG,QAAQ,8BAAU,MAAM,OAAO,OAAO,oBAAM,CAAC,EAAE;AAAA,IAC7C;AAAA,EACF;AAAA,EACA,UAAU,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,MAAM,CAAC,EAAE,YAAY,qBAAqB;AACrG;",
6
6
  "names": []
7
7
  }
@@ -98,7 +98,6 @@ const handleCheckmark = (theme, checked, disabled, readOnly, hasError, isHoverin
98
98
  if (checked === "mixed") {
99
99
  return `&:before {
100
100
  ${device === void 0 ? normalMixedCheckmark : device === "mobile" ? mobileMixedCheckmark : desktopMixedCheckmark}
101
-
102
101
  }`;
103
102
  }
104
103
  if (checked) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/styleHelpers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable no-nested-ternary */\n/* eslint-disable max-params */\n\nimport type { Theme } from '@elliemae/pui-theme';\nexport const handleCheckMarkColor = (\n { colors }: Theme,\n checked: boolean | 'mixed',\n isHovering: boolean,\n disabled?: boolean,\n readOnly?: boolean,\n hasError?: boolean,\n): string => {\n if (hasError) {\n return colors.danger[900];\n }\n if (disabled || readOnly) {\n return colors.neutral[500];\n }\n if (isHovering && checked !== false) {\n return colors.brand[800];\n }\n return colors.brand[500];\n};\n\nexport const handleCheckmark = (\n theme: Theme,\n checked: boolean | 'mixed',\n disabled?: boolean,\n readOnly?: boolean,\n hasError?: boolean,\n isHovering = false,\n device: string | undefined = undefined,\n): string => {\n const desktopMixedCheckmark = `\n position: absolute;\n content: '';\n top: 6px;\n left: 3px;\n background: ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};\n width: ${theme.space.xxs};\n height: 2px;\n`;\n\n const normalMixedCheckmark = `\n @media (max-width: ${theme.breakpoints.small}) {\n top:10px;\n left:5px;\n height:2px;\n width:12px;\n }\n ${desktopMixedCheckmark}\n`;\n const mobileMixedCheckmark = `\n ${desktopMixedCheckmark}\n top:10px;\n left:5px;\n height:2px;\n width:12px;\n `;\n const desktopCheckmark = `\n position: absolute;\n content: '';\n top: 3px;\n left: 2px;\n border-left: 2px solid ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};\n border-bottom: 2px solid ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};\n height: 5px;\n width: 10px;\n transform: rotate(-45deg);\n`;\n\n const normalCheckmark = `\n @media (max-width: ${theme.breakpoints.small}) {\n top: 5px;\n left: 3px;\n height: 8px;\n width: 17px;\n }\n ${desktopCheckmark}\n`;\n const mobileCheckmark = `\n ${desktopCheckmark}\n top: 5px;\n left: 3px;\n height: 8px;\n width: 17px;\n `;\n\n if (checked === 'mixed') {\n return `&:before {\n ${\n device === undefined ? normalMixedCheckmark : device === 'mobile' ? mobileMixedCheckmark : desktopMixedCheckmark\n }\n\n }`;\n }\n if (checked) {\n return `&:before {\n ${device === undefined ? normalCheckmark : device === 'mobile' ? mobileCheckmark : desktopCheckmark}\n }`;\n }\n return '';\n};\n\nexport const handleBackgroundColor = ({ colors }: Theme, disabled?: boolean): string => {\n if (disabled) {\n return colors.neutral['080'];\n }\n\n return colors.neutral['000'];\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIhB,MAAM,uBAAuB,CAClC,EAAE,OAAO,GACT,SACA,YACA,UACA,UACA,aACW;AACX,MAAI,UAAU;AACZ,WAAO,OAAO,OAAO;AAAA,EACvB;AACA,MAAI,YAAY,UAAU;AACxB,WAAO,OAAO,QAAQ;AAAA,EACxB;AACA,MAAI,cAAc,YAAY,OAAO;AACnC,WAAO,OAAO,MAAM;AAAA,EACtB;AACA,SAAO,OAAO,MAAM;AACtB;AAEO,MAAM,kBAAkB,CAC7B,OACA,SACA,UACA,UACA,UACA,aAAa,OACb,SAA6B,WAClB;AACX,QAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,gBAKhB,qBAAqB,OAAO,SAAS,YAAY,UAAU,UAAU,QAAQ;AAAA,WAClF,MAAM,MAAM;AAAA;AAAA;AAIrB,QAAM,uBAAuB;AAAA,yBACN,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMrC;AAAA;AAEJ,QAAM,uBAAuB;AAAA,MACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAMJ,QAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA,2BAKA,qBAAqB,OAAO,SAAS,YAAY,UAAU,UAAU,QAAQ;AAAA,6BAC3E,qBAAqB,OAAO,SAAS,YAAY,UAAU,UAAU,QAAQ;AAAA;AAAA;AAAA;AAAA;AAMxG,QAAM,kBAAkB;AAAA,yBACD,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMrC;AAAA;AAEJ,QAAM,kBAAkB;AAAA,MACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAOJ,MAAI,YAAY,SAAS;AACvB,WAAO;AAAA,QAEH,WAAW,SAAY,uBAAuB,WAAW,WAAW,uBAAuB;AAAA;AAAA;AAAA,EAIjG;AACA,MAAI,SAAS;AACX,WAAO;AAAA,UACD,WAAW,SAAY,kBAAkB,WAAW,WAAW,kBAAkB;AAAA;AAAA,EAEzF;AACA,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,EAAE,OAAO,GAAU,aAA+B;AACtF,MAAI,UAAU;AACZ,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO,OAAO,QAAQ;AACxB;",
4
+ "sourcesContent": ["/* eslint-disable indent */\n/* eslint-disable no-nested-ternary */\n/* eslint-disable max-params */\n\nimport type { Theme } from '@elliemae/pui-theme';\nexport const handleCheckMarkColor = (\n { colors }: Theme,\n checked: boolean | 'mixed',\n isHovering: boolean,\n disabled?: boolean,\n readOnly?: boolean,\n hasError?: boolean,\n): string => {\n if (hasError) {\n return colors.danger[900];\n }\n if (disabled || readOnly) {\n return colors.neutral[500];\n }\n if (isHovering && checked !== false) {\n return colors.brand[800];\n }\n return colors.brand[500];\n};\n\nexport const handleCheckmark = (\n theme: Theme,\n checked: boolean | 'mixed',\n disabled?: boolean,\n readOnly?: boolean,\n hasError?: boolean,\n isHovering = false,\n device: string | undefined = undefined,\n): string => {\n const desktopMixedCheckmark = `\n position: absolute;\n content: '';\n top: 6px;\n left: 3px;\n background: ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};\n width: ${theme.space.xxs};\n height: 2px;\n`;\n\n const normalMixedCheckmark = `\n @media (max-width: ${theme.breakpoints.small}) {\n top:10px;\n left:5px;\n height:2px;\n width:12px;\n }\n ${desktopMixedCheckmark}\n`;\n const mobileMixedCheckmark = `\n ${desktopMixedCheckmark}\n top:10px;\n left:5px;\n height:2px;\n width:12px;\n `;\n const desktopCheckmark = `\n position: absolute;\n content: '';\n top: 3px;\n left: 2px;\n border-left: 2px solid ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};\n border-bottom: 2px solid ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};\n height: 5px;\n width: 10px;\n transform: rotate(-45deg);\n`;\n\n const normalCheckmark = `\n @media (max-width: ${theme.breakpoints.small}) {\n top: 5px;\n left: 3px;\n height: 8px;\n width: 17px;\n }\n ${desktopCheckmark}\n`;\n const mobileCheckmark = `\n ${desktopCheckmark}\n top: 5px;\n left: 3px;\n height: 8px;\n width: 17px;\n `;\n\n if (checked === 'mixed') {\n return `&:before {\n ${\n device === undefined ? normalMixedCheckmark : device === 'mobile' ? mobileMixedCheckmark : desktopMixedCheckmark\n }\n }`;\n }\n if (checked) {\n return `&:before {\n ${device === undefined ? normalCheckmark : device === 'mobile' ? mobileCheckmark : desktopCheckmark}\n }`;\n }\n return '';\n};\n\nexport const handleBackgroundColor = ({ colors }: Theme, disabled?: boolean): string => {\n if (disabled) {\n return colors.neutral['080'];\n }\n\n return colors.neutral['000'];\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKhB,MAAM,uBAAuB,CAClC,EAAE,OAAO,GACT,SACA,YACA,UACA,UACA,aACW;AACX,MAAI,UAAU;AACZ,WAAO,OAAO,OAAO;AAAA,EACvB;AACA,MAAI,YAAY,UAAU;AACxB,WAAO,OAAO,QAAQ;AAAA,EACxB;AACA,MAAI,cAAc,YAAY,OAAO;AACnC,WAAO,OAAO,MAAM;AAAA,EACtB;AACA,SAAO,OAAO,MAAM;AACtB;AAEO,MAAM,kBAAkB,CAC7B,OACA,SACA,UACA,UACA,UACA,aAAa,OACb,SAA6B,WAClB;AACX,QAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,gBAKhB,qBAAqB,OAAO,SAAS,YAAY,UAAU,UAAU,QAAQ;AAAA,WAClF,MAAM,MAAM;AAAA;AAAA;AAIrB,QAAM,uBAAuB;AAAA,yBACN,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMrC;AAAA;AAEJ,QAAM,uBAAuB;AAAA,MACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAMJ,QAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA,2BAKA,qBAAqB,OAAO,SAAS,YAAY,UAAU,UAAU,QAAQ;AAAA,6BAC3E,qBAAqB,OAAO,SAAS,YAAY,UAAU,UAAU,QAAQ;AAAA;AAAA;AAAA;AAAA;AAMxG,QAAM,kBAAkB;AAAA,yBACD,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMrC;AAAA;AAEJ,QAAM,kBAAkB;AAAA,MACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAOJ,MAAI,YAAY,SAAS;AACvB,WAAO;AAAA,QAEH,WAAW,SAAY,uBAAuB,WAAW,WAAW,uBAAuB;AAAA;AAAA,EAGjG;AACA,MAAI,SAAS;AACX,WAAO;AAAA,UACD,WAAW,SAAY,kBAAkB,WAAW,WAAW,kBAAkB;AAAA;AAAA,EAEzF;AACA,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,EAAE,OAAO,GAAU,aAA+B;AACtF,MAAI,UAAU;AACZ,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO,OAAO,QAAQ;AACxB;",
6
6
  "names": []
7
7
  }
@@ -1,119 +1,15 @@
1
1
  import * as React from "react";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useMemo, useCallback } from "react";
4
- import { uid } from "uid";
5
- import {
6
- describe,
7
- useGetGlobalAttributes,
8
- useGetXstyledProps,
9
- useMemoMergePropsWithDefault
10
- } from "@elliemae/ds-utilities";
11
- import { SimpleTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
12
- import { StyledContainer, StyledWrapLabel, StyledInput, StyledLabel, StyledCheckBox, StyledInputMixed } from "./styles";
13
- import { propTypes, defaultProps } from "./react-desc-prop-types";
14
- import { useValidateProps } from "./config/useValidateProps";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { describe } from "@elliemae/ds-utilities";
4
+ import { propTypes } from "./react-desc-prop-types";
5
+ import { useCheckBox } from "./config/useCheckBox";
6
+ import { ControlledCheckBoxContext } from "./ControlledCheckboxCTX";
7
+ import { ControlledCheckBoxContent } from "./parts/ControlledCheckBoxContent";
15
8
  const DSControlledCheckbox = (props) => {
16
- const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
17
- useValidateProps(props, propTypes);
18
- const {
19
- checked,
20
- device,
21
- label,
22
- hasError,
23
- innerRef,
24
- wrapLabel,
25
- ariaLabel: legacyAriaLabel,
26
- ariaControls: legacyAriaControls
27
- } = propsWithDefault;
28
- const handleMixedCheckboxOnKeyDown = useCallback((e) => {
29
- if (e.code === "Space") {
30
- const { currentTarget } = e;
31
- currentTarget.click();
32
- e.preventDefault();
33
- }
34
- }, []);
35
- const {
36
- id,
37
- disabled,
38
- readOnly,
39
- label: globalLabel,
40
- "aria-label": ariaLabel,
41
- "aria-controls": ariaControls,
42
- className,
43
- onChange,
44
- tabIndex,
45
- onKeyDown: userOnKeyDown,
46
- ...restGlobals
47
- } = useGetGlobalAttributes(propsWithDefault, {
48
- onKeyDown: handleMixedCheckboxOnKeyDown
49
- });
50
- const instanceUid = useMemo(() => id || uid(5), [id]);
51
- const onChangeValue = useCallback(
52
- (e) => {
53
- if (checked === "mixed")
54
- onChange(true, e);
55
- if (checked === true)
56
- onChange(false, e);
57
- if (checked === false)
58
- onChange(true, e);
59
- },
60
- [checked, onChange]
61
- );
62
- const xstyledProps = useGetXstyledProps(propsWithDefault);
63
- const commonProps = {
64
- "data-testid": "ds-checkbox",
65
- ...restGlobals,
66
- id: instanceUid,
67
- "aria-label": ariaLabel || legacyAriaLabel || label,
68
- "aria-checked": checked
69
- };
70
- return /* @__PURE__ */ jsxs(StyledContainer, {
71
- device,
72
- "data-testid": "ds-checkbox-container",
73
- className,
74
- ...xstyledProps,
75
- children: [
76
- /* @__PURE__ */ jsx(StyledCheckBox, {
77
- device,
78
- checked,
79
- hasError,
80
- disabled,
81
- readOnly,
82
- children: ariaControls || legacyAriaControls ? /* @__PURE__ */ jsx(StyledInputMixed, {
83
- ...commonProps,
84
- role: "checkbox",
85
- "aria-controls": ariaControls || legacyAriaControls,
86
- "aria-disabled": disabled,
87
- onClick: !disabled && !readOnly ? onChangeValue : void 0,
88
- onKeyDown: userOnKeyDown,
89
- tabIndex: tabIndex ?? (disabled ? -1 : 0),
90
- ref: innerRef
91
- }) : /* @__PURE__ */ jsx(StyledInput, {
92
- ...commonProps,
93
- type: "checkbox",
94
- checked,
95
- onChange: onChangeValue,
96
- disabled,
97
- tabIndex,
98
- ref: innerRef
99
- })
100
- }),
101
- label && /* @__PURE__ */ jsx(StyledLabel, {
102
- htmlFor: instanceUid,
103
- disabled,
104
- readOnly,
105
- checked,
106
- "data-testid": "ds-checkbox-label",
107
- wrapLabel,
108
- device,
109
- ...!disabled && (ariaControls || legacyAriaControls) ? { onClick: onChangeValue } : {},
110
- children: wrapLabel ? /* @__PURE__ */ jsx(StyledWrapLabel, {
111
- children: label
112
- }) : /* @__PURE__ */ jsx(SimpleTruncatedTooltipText, {
113
- value: label
114
- })
115
- })
116
- ]
9
+ const ctx = useCheckBox(props);
10
+ return /* @__PURE__ */ jsx(ControlledCheckBoxContext.Provider, {
11
+ value: ctx,
12
+ children: /* @__PURE__ */ jsx(ControlledCheckBoxContent, {})
117
13
  });
118
14
  };
119
15
  DSControlledCheckbox.propTypes = propTypes;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/ControlledCheckbox.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useMemo, useCallback, WeakValidationMap } from 'react';\nimport { uid } from 'uid';\n\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n} from '@elliemae/ds-utilities';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { StyledContainer, StyledWrapLabel, StyledInput, StyledLabel, StyledCheckBox, StyledInputMixed } from './styles';\nimport { DSControlledCheckboxT, propTypes, defaultProps } from './react-desc-prop-types';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst DSControlledCheckbox: React.ComponentType<DSControlledCheckboxT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);\n useValidateProps(props, propTypes);\n\n const {\n checked,\n device,\n label,\n hasError,\n innerRef,\n wrapLabel,\n ariaLabel: legacyAriaLabel,\n ariaControls: legacyAriaControls,\n } = propsWithDefault;\n\n const handleMixedCheckboxOnKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.code === 'Space') {\n const { currentTarget }: { currentTarget: HTMLDivElement } = e;\n currentTarget.click();\n e.preventDefault(); // when selecting a checkbox we don't want to scroll for example\n }\n }, []);\n\n const {\n id,\n disabled,\n readOnly,\n label: globalLabel,\n 'aria-label': ariaLabel,\n 'aria-controls': ariaControls,\n className,\n onChange,\n tabIndex,\n onKeyDown: userOnKeyDown,\n ...restGlobals\n } = useGetGlobalAttributes<DSControlledCheckboxT.Props>(propsWithDefault, {\n onKeyDown: handleMixedCheckboxOnKeyDown,\n });\n\n const instanceUid = useMemo(() => id || uid(5), [id]);\n\n const onChangeValue = useCallback(\n (e: Event) => {\n if (checked === 'mixed') onChange(true, e);\n if (checked === true) onChange(false, e);\n if (checked === false) onChange(true, e);\n },\n [checked, onChange],\n );\n\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const commonProps: Partial<DSControlledCheckboxT.Props> = {\n 'data-testid': 'ds-checkbox',\n ...restGlobals,\n id: instanceUid,\n 'aria-label': ariaLabel || legacyAriaLabel || label,\n 'aria-checked': checked,\n };\n\n return (\n <StyledContainer device={device} data-testid=\"ds-checkbox-container\" className={className} {...xstyledProps}>\n <StyledCheckBox device={device} checked={checked} hasError={hasError} disabled={disabled} readOnly={readOnly}>\n {ariaControls || legacyAriaControls ? (\n <StyledInputMixed\n {...commonProps}\n role=\"checkbox\"\n aria-controls={ariaControls || legacyAriaControls}\n aria-disabled={disabled}\n onClick={!disabled && !readOnly ? onChangeValue : undefined}\n onKeyDown={userOnKeyDown}\n tabIndex={tabIndex ?? (disabled ? -1 : 0)}\n ref={innerRef}\n />\n ) : (\n <StyledInput\n {...commonProps}\n type=\"checkbox\"\n checked={checked as boolean | undefined}\n onChange={onChangeValue}\n disabled={disabled}\n tabIndex={tabIndex}\n ref={innerRef}\n />\n )}\n </StyledCheckBox>\n {label && (\n <StyledLabel\n htmlFor={instanceUid}\n disabled={disabled}\n readOnly={readOnly}\n checked={checked}\n data-testid=\"ds-checkbox-label\"\n wrapLabel={wrapLabel}\n device={device}\n {...(!disabled && (ariaControls || legacyAriaControls) ? { onClick: onChangeValue } : {})}\n >\n {wrapLabel ? <StyledWrapLabel>{label}</StyledWrapLabel> : <SimpleTruncatedTooltipText value={label} />}\n </StyledLabel>\n )}\n </StyledContainer>\n );\n};\n\nDSControlledCheckbox.propTypes = propTypes as WeakValidationMap<unknown>;\nDSControlledCheckbox.displayName = 'DSControlledCheckbox';\nconst DSControlledCheckboxWithSchema = describe(DSControlledCheckbox);\nDSControlledCheckboxWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSControlledCheckbox, DSControlledCheckboxWithSchema };\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,SAAS,mBAAsC;AAC/D,SAAS,WAAW;AAEpB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kCAAkC;AAC3C,SAAS,iBAAiB,iBAAiB,aAAa,aAAa,gBAAgB,wBAAwB;AAC7G,SAAgC,WAAW,oBAAoB;AAC/D,SAAS,wBAAwB;AAEjC,MAAM,uBAAyE,CAAC,UAAU;AACxF,QAAM,mBAAmB,6BAA6B,OAAO,YAAY;AACzE,mBAAiB,OAAO,SAAS;AAEjC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,cAAc;AAAA,EAChB,IAAI;AAEJ,QAAM,+BAA+B,YAAY,CAAC,MAA2C;AAC3F,QAAI,EAAE,SAAS,SAAS;AACtB,YAAM,EAAE,cAAc,IAAuC;AAC7D,oBAAc,MAAM;AACpB,QAAE,eAAe;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,OACR;AAAA,EACL,IAAI,uBAAoD,kBAAkB;AAAA,IACxE,WAAW;AAAA,EACb,CAAC;AAED,QAAM,cAAc,QAAQ,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEpD,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAAa;AACZ,UAAI,YAAY;AAAS,iBAAS,MAAM,CAAC;AACzC,UAAI,YAAY;AAAM,iBAAS,OAAO,CAAC;AACvC,UAAI,YAAY;AAAO,iBAAS,MAAM,CAAC;AAAA,IACzC;AAAA,IACA,CAAC,SAAS,QAAQ;AAAA,EACpB;AAEA,QAAM,eAAe,mBAAmB,gBAAgB;AAExD,QAAM,cAAoD;AAAA,IACxD,eAAe;AAAA,IACf,GAAG;AAAA,IACH,IAAI;AAAA,IACJ,cAAc,aAAa,mBAAmB;AAAA,IAC9C,gBAAgB;AAAA,EAClB;AAEA,SACE,qBAAC;AAAA,IAAgB;AAAA,IAAgB,eAAY;AAAA,IAAwB;AAAA,IAAuB,GAAG;AAAA,IAC7F;AAAA,0BAAC;AAAA,QAAe;AAAA,QAAgB;AAAA,QAAkB;AAAA,QAAoB;AAAA,QAAoB;AAAA,QACvF,0BAAgB,qBACf,oBAAC;AAAA,UACE,GAAG;AAAA,UACJ,MAAK;AAAA,UACL,iBAAe,gBAAgB;AAAA,UAC/B,iBAAe;AAAA,UACf,SAAS,CAAC,YAAY,CAAC,WAAW,gBAAgB;AAAA,UAClD,WAAW;AAAA,UACX,UAAU,aAAa,WAAW,KAAK;AAAA,UACvC,KAAK;AAAA,SACP,IAEA,oBAAC;AAAA,UACE,GAAG;AAAA,UACJ,MAAK;AAAA,UACL;AAAA,UACA,UAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,KAAK;AAAA,SACP;AAAA,OAEJ;AAAA,MACC,SACC,oBAAC;AAAA,QACC,SAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACC,GAAI,CAAC,aAAa,gBAAgB,sBAAsB,EAAE,SAAS,cAAc,IAAI,CAAC;AAAA,QAEtF,sBAAY,oBAAC;AAAA,UAAiB;AAAA,SAAM,IAAqB,oBAAC;AAAA,UAA2B,OAAO;AAAA,SAAO;AAAA,OACtG;AAAA;AAAA,GAEJ;AAEJ;AAEA,qBAAqB,YAAY;AACjC,qBAAqB,cAAc;AACnC,MAAM,iCAAiC,SAAS,oBAAoB;AACpE,+BAA+B,YAAY;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { WeakValidationMap } from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { DSControlledCheckboxT, propTypes } from './react-desc-prop-types';\nimport { useCheckBox } from './config/useCheckBox';\nimport { ControlledCheckBoxContext } from './ControlledCheckboxCTX';\nimport { ControlledCheckBoxContent } from './parts/ControlledCheckBoxContent';\n\nconst DSControlledCheckbox: React.ComponentType<DSControlledCheckboxT.Props> = (props) => {\n const ctx = useCheckBox(props);\n return (\n <ControlledCheckBoxContext.Provider value={ctx}>\n <ControlledCheckBoxContent />\n </ControlledCheckBoxContext.Provider>\n );\n};\n\nDSControlledCheckbox.propTypes = propTypes as WeakValidationMap<unknown>;\nDSControlledCheckbox.displayName = 'DSControlledCheckbox';\nconst DSControlledCheckboxWithSchema = describe(DSControlledCheckbox);\nDSControlledCheckboxWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSControlledCheckbox, DSControlledCheckboxWithSchema };\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AAEA,SAAS,gBAAgB;AACzB,SAAgC,iBAAiB;AACjD,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAE1C,MAAM,uBAAyE,CAAC,UAAU;AACxF,QAAM,MAAM,YAAY,KAAK;AAC7B,SACE,oBAAC,0BAA0B,UAA1B;AAAA,IAAmC,OAAO;AAAA,IACzC,8BAAC,6BAA0B;AAAA,GAC7B;AAEJ;AAEA,qBAAqB,YAAY;AACjC,qBAAqB,cAAc;AACnC,MAAM,iCAAiC,SAAS,oBAAoB;AACpE,+BAA+B,YAAY;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { createContext } from "react";
3
+ const defaultContext = {};
4
+ const ControlledCheckBoxContext = createContext(defaultContext);
5
+ var ControlledCheckboxCTX_default = ControlledCheckBoxContext;
6
+ export {
7
+ ControlledCheckBoxContext,
8
+ ControlledCheckboxCTX_default as default
9
+ };
10
+ //# sourceMappingURL=ControlledCheckboxCTX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/ControlledCheckboxCTX.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport type { ControlledCheckboxCTX } from './config/useCheckBox';\n\nconst defaultContext = {} as ControlledCheckboxCTX;\n\n/** Context for cross component communication */\nexport const ControlledCheckBoxContext = createContext<ControlledCheckboxCTX>(defaultContext);\n\nexport default ControlledCheckBoxContext;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB;AAG9B,MAAM,iBAAiB,CAAC;AAGjB,MAAM,4BAA4B,cAAqC,cAAc;AAE5F,IAAO,gCAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from "@elliemae/ds-utilities";
4
+ import { uid } from "uid";
5
+ import { propTypes, defaultProps } from "../react-desc-prop-types";
6
+ import { useValidateProps } from "./useValidateProps";
7
+ import { useEventHandlers } from "./useEventHandlers";
8
+ const useCheckBox = (props) => {
9
+ const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
10
+ useValidateProps(props, propTypes);
11
+ const globalProps = useGetGlobalAttributes(propsWithDefault);
12
+ const xstyledProps = useGetXstyledProps(propsWithDefault);
13
+ const { id } = globalProps;
14
+ const instanceUid = React2.useMemo(() => id || uid(5), [id]);
15
+ const eventHandlers = useEventHandlers(propsWithDefault);
16
+ return React2.useMemo(
17
+ () => ({
18
+ propsWithDefault,
19
+ globalProps,
20
+ xstyledProps,
21
+ instanceUid,
22
+ ...eventHandlers
23
+ }),
24
+ [eventHandlers, globalProps, instanceUid, propsWithDefault, xstyledProps]
25
+ );
26
+ };
27
+ export {
28
+ useCheckBox
29
+ };
30
+ //# sourceMappingURL=useCheckBox.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useCheckBox.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-utilities';\nimport { uid } from 'uid';\nimport { DSControlledCheckboxT, propTypes, defaultProps } from '../react-desc-prop-types';\nimport { useValidateProps } from './useValidateProps';\nimport { useEventHandlers } from './useEventHandlers';\n\nexport interface ControlledCheckboxCTX extends ReturnType<typeof useEventHandlers> {\n propsWithDefault: DSControlledCheckboxT.InternalProps;\n globalProps: ReturnType<typeof useGetGlobalAttributes>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n instanceUid: string;\n}\n\nexport const useCheckBox = (props: DSControlledCheckboxT.Props): ControlledCheckboxCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSControlledCheckboxT.InternalProps>(props, defaultProps);\n useValidateProps(props, propTypes);\n // =============================================================================\n // GLOBAL ATTRIBUTES & XSTYLED PROPS\n // =============================================================================\n const globalProps = useGetGlobalAttributes<DSControlledCheckboxT.InternalProps>(propsWithDefault);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { id } = globalProps;\n const instanceUid = React.useMemo(() => id || uid(5), [id]);\n\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n const eventHandlers = useEventHandlers(propsWithDefault);\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalProps,\n xstyledProps,\n instanceUid,\n ...eventHandlers,\n }),\n [eventHandlers, globalProps, instanceUid, propsWithDefault, xstyledProps],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,SAAS,WAAW;AACpB,SAAgC,WAAW,oBAAoB;AAC/D,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAS1B,MAAM,cAAc,CAAC,UAA8D;AAIxF,QAAM,mBAAmB,6BAAkE,OAAO,YAAY;AAC9G,mBAAiB,OAAO,SAAS;AAIjC,QAAM,cAAc,uBAA4D,gBAAgB;AAChG,QAAM,eAAe,mBAAmB,gBAAgB;AAIxD,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,cAAcA,OAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAK1D,QAAM,gBAAgB,iBAAiB,gBAAgB;AAEvD,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,IACA,CAAC,eAAe,aAAa,aAAa,kBAAkB,YAAY;AAAA,EAC1E;AACF;",
6
+ "names": ["React"]
7
+ }
@@ -0,0 +1,41 @@
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ const useEventHandlers = (props) => {
4
+ const { checked, onChange, onKeyDown } = props;
5
+ const handleOnChange = React2.useCallback(
6
+ (e) => {
7
+ if (onChange) {
8
+ if (checked === "mixed")
9
+ onChange(true, e);
10
+ if (checked === true)
11
+ onChange(false, e);
12
+ if (checked === false)
13
+ onChange(true, e);
14
+ }
15
+ },
16
+ [checked, onChange]
17
+ );
18
+ const handleMixedCheckboxOnKeyDown = React2.useCallback(
19
+ (e) => {
20
+ if (onKeyDown) {
21
+ onKeyDown(e);
22
+ }
23
+ if (e.code === "Space" || e.code === "Enter") {
24
+ handleOnChange(e);
25
+ e.preventDefault();
26
+ }
27
+ },
28
+ [handleOnChange, onKeyDown]
29
+ );
30
+ return React2.useMemo(
31
+ () => ({
32
+ handleOnChange,
33
+ handleMixedCheckboxOnKeyDown
34
+ }),
35
+ [handleMixedCheckboxOnKeyDown, handleOnChange]
36
+ );
37
+ };
38
+ export {
39
+ useEventHandlers
40
+ };
41
+ //# sourceMappingURL=useEventHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useEventHandlers.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { DSControlledCheckboxT } from '../react-desc-prop-types';\n\nexport const useEventHandlers = (props: DSControlledCheckboxT.InternalProps) => {\n const { checked, onChange, onKeyDown } = props;\n const handleOnChange = React.useCallback(\n (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.MouseEvent<HTMLLabelElement>\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n ) => {\n if (onChange) {\n if (checked === 'mixed') onChange(true, e);\n if (checked === true) onChange(false, e);\n if (checked === false) onChange(true, e);\n }\n },\n [checked, onChange],\n );\n const handleMixedCheckboxOnKeyDown = React.useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (onKeyDown) {\n // if user provides 'onKeyDown' event, he is in charge of what happens\n onKeyDown(e);\n }\n if (e.code === 'Space' || e.code === 'Enter') {\n handleOnChange(e);\n e.preventDefault(); // when selecting a checkbox we don't want to scroll for example\n }\n },\n [handleOnChange, onKeyDown],\n );\n\n return React.useMemo(\n () => ({\n handleOnChange,\n handleMixedCheckboxOnKeyDown,\n }),\n [handleMixedCheckboxOnKeyDown, handleOnChange],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAGX,MAAM,mBAAmB,CAAC,UAA+C;AAC9E,QAAM,EAAE,SAAS,UAAU,UAAU,IAAI;AACzC,QAAM,iBAAiBA,OAAM;AAAA,IAC3B,CACE,MAKG;AACH,UAAI,UAAU;AACZ,YAAI,YAAY;AAAS,mBAAS,MAAM,CAAC;AACzC,YAAI,YAAY;AAAM,mBAAS,OAAO,CAAC;AACvC,YAAI,YAAY;AAAO,mBAAS,MAAM,CAAC;AAAA,MACzC;AAAA,IACF;AAAA,IACA,CAAC,SAAS,QAAQ;AAAA,EACpB;AACA,QAAM,+BAA+BA,OAAM;AAAA,IACzC,CAAC,MAA2C;AAC1C,UAAI,WAAW;AAEb,kBAAU,CAAC;AAAA,MACb;AACA,UAAI,EAAE,SAAS,WAAW,EAAE,SAAS,SAAS;AAC5C,uBAAe,CAAC;AAChB,UAAE,eAAe;AAAA,MACnB;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB,SAAS;AAAA,EAC5B;AAEA,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,8BAA8B,cAAc;AAAA,EAC/C;AACF;",
6
+ "names": ["React"]
7
+ }
@@ -1,22 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { useValidateTypescriptPropTypes } from "@elliemae/ds-utilities";
3
- const throwError = (message) => {
4
- throw new Error(
5
- `DSControlledCheckbox:: ${message}
6
- `
7
- );
8
- };
9
3
  const useValidateProps = (props, propTypes) => {
10
4
  useValidateTypescriptPropTypes(props, propTypes);
11
- if (typeof props.label === "undefined" && typeof props["aria-label"] === "undefined") {
12
- throwError(`Please provide a label or "aria-label" property to use this component.`);
13
- }
14
- if (props.checked === "mixed" && typeof props["aria-controls"] === "undefined") {
15
- throwError(
16
- `Please provide an ariaControls property to use a checkbox mixed state.
17
- This property must be a string containing all the ids that this mixed checkbox is controlling.`
18
- );
19
- }
20
5
  };
21
6
  export {
22
7
  useValidateProps
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useValidateProps.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useValidateTypescriptPropTypes } from '@elliemae/ds-utilities';\nimport { WeakValidationMap } from 'react';\nimport { DSControlledCheckboxT } from '../react-desc-prop-types';\n\nconst throwError = (message: string): void => {\n throw new Error(\n `DSControlledCheckbox:: ${message}\n `,\n );\n};\n\nexport const useValidateProps = (props: DSControlledCheckboxT.Props, propTypes: WeakValidationMap<unknown>): void => {\n useValidateTypescriptPropTypes(props, propTypes);\n if (typeof props.label === 'undefined' && typeof props['aria-label'] === 'undefined') {\n throwError(`Please provide a label or \"aria-label\" property to use this component.`);\n }\n if (props.checked === 'mixed' && typeof props['aria-controls'] === 'undefined') {\n throwError(\n `Please provide an ariaControls property to use a checkbox mixed state. \n This property must be a string containing all the ids that this mixed checkbox is controlling.`,\n );\n }\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,sCAAsC;AAI/C,MAAM,aAAa,CAAC,YAA0B;AAC5C,QAAM,IAAI;AAAA,IACR,0BAA0B;AAAA;AAAA,EAE5B;AACF;AAEO,MAAM,mBAAmB,CAAC,OAAoC,cAAgD;AACnH,iCAA+B,OAAO,SAAS;AAC/C,MAAI,OAAO,MAAM,UAAU,eAAe,OAAO,MAAM,kBAAkB,aAAa;AACpF,eAAW,wEAAwE;AAAA,EACrF;AACA,MAAI,MAAM,YAAY,WAAW,OAAO,MAAM,qBAAqB,aAAa;AAC9E;AAAA,MACE;AAAA;AAAA,IAEF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useValidateTypescriptPropTypes } from '@elliemae/ds-utilities';\nimport { WeakValidationMap } from 'react';\nimport { DSControlledCheckboxT } from '../react-desc-prop-types';\n\nexport const useValidateProps = (props: DSControlledCheckboxT.Props, propTypes: WeakValidationMap<unknown>): void => {\n // we validate the \"required if\" via 'isRequiredIf from our custom PropTypes\n useValidateTypescriptPropTypes(props, propTypes);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,sCAAsC;AAIxC,MAAM,mBAAmB,CAAC,OAAoC,cAAgD;AAEnH,iCAA+B,OAAO,SAAS;AACjD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ const DEVICE = {
3
+ MOBILE: "mobile",
4
+ DESKTOP: "desktop"
5
+ };
6
+ export {
7
+ DEVICE
8
+ };
9
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/constants/device.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DEVICE = {\n MOBILE: 'mobile',\n DESKTOP: 'desktop',\n} as const;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,SAAS;AAAA,EACpB,QAAQ;AAAA,EACR,SAAS;AACX;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/exported-related/data-test-ids.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSCheckboxDataTestIds = {\n CONTAINER: 'ds-checkbox-container',\n INPUT: 'ds-checkbox',\n};\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSCheckboxDataTestIds = {\n CONTAINER: 'ds-checkbox-container',\n INPUT: 'ds-checkbox',\n} as const;\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,wBAAwB;AAAA,EACnC,WAAW;AAAA,EACX,OAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/exported-related/theming.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSCheckboxName = 'DS-Checkbox';\n\nexport const DSCheckboxSlots = {\n CONTAINER: 'root',\n INPUT: 'input',\n LABEL: 'label',\n};\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSCheckboxName = 'DS-Checkbox' as const;\n\nexport const DSCheckboxSlots = {\n CONTAINER: 'root',\n INPUT: 'input',\n LABEL: 'label',\n} as const;\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AAAA,EAC7B,WAAW;AAAA,EACX,OAAO;AAAA,EACP,OAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,48 @@
1
+ import * as React from "react";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import React2 from "react";
4
+ import { SimpleTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
5
+ import { StyledContainer, StyledWrapLabel, StyledLabel, StyledCheckBox } from "../styles";
6
+ import { MainInput } from "./MainInput";
7
+ import { ControlledCheckBoxContext } from "../ControlledCheckboxCTX";
8
+ const ControlledCheckBoxContent = () => {
9
+ const { propsWithDefault, globalProps, instanceUid, xstyledProps, handleOnChange } = React2.useContext(ControlledCheckBoxContext);
10
+ const { checked, device, label, hasError, wrapLabel, ariaControls: legacyAriaControls } = propsWithDefault;
11
+ const { disabled, readOnly, "aria-controls": ariaControls, className } = globalProps;
12
+ return /* @__PURE__ */ jsxs(StyledContainer, {
13
+ device,
14
+ "data-testid": "ds-checkbox-container",
15
+ className,
16
+ ...xstyledProps,
17
+ children: [
18
+ /* @__PURE__ */ jsx(StyledCheckBox, {
19
+ device,
20
+ checked,
21
+ hasError,
22
+ disabled,
23
+ readOnly,
24
+ children: /* @__PURE__ */ jsx(MainInput, {})
25
+ }),
26
+ label && /* @__PURE__ */ jsx(StyledLabel, {
27
+ id: `${instanceUid}_label`,
28
+ htmlFor: instanceUid,
29
+ disabled,
30
+ readOnly,
31
+ checked,
32
+ "data-testid": "ds-checkbox-label",
33
+ wrapLabel,
34
+ device,
35
+ ...!disabled && (ariaControls || legacyAriaControls) ? { onClick: handleOnChange } : {},
36
+ children: wrapLabel ? /* @__PURE__ */ jsx(StyledWrapLabel, {
37
+ children: label
38
+ }) : /* @__PURE__ */ jsx(SimpleTruncatedTooltipText, {
39
+ value: label
40
+ })
41
+ })
42
+ ]
43
+ });
44
+ };
45
+ export {
46
+ ControlledCheckBoxContent
47
+ };
48
+ //# sourceMappingURL=ControlledCheckBoxContent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/ControlledCheckBoxContent.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { StyledContainer, StyledWrapLabel, StyledLabel, StyledCheckBox } from '../styles';\nimport { MainInput } from './MainInput';\nimport { ControlledCheckBoxContext } from '../ControlledCheckboxCTX';\n\nexport const ControlledCheckBoxContent = () => {\n const { propsWithDefault, globalProps, instanceUid, xstyledProps, handleOnChange } =\n React.useContext(ControlledCheckBoxContext);\n const { checked, device, label, hasError, wrapLabel, ariaControls: legacyAriaControls } = propsWithDefault;\n const { disabled, readOnly, 'aria-controls': ariaControls, className } = globalProps;\n\n return (\n <StyledContainer device={device} data-testid=\"ds-checkbox-container\" className={className} {...xstyledProps}>\n <StyledCheckBox device={device} checked={checked} hasError={hasError} disabled={disabled} readOnly={readOnly}>\n <MainInput />\n </StyledCheckBox>\n {label && (\n <StyledLabel\n id={`${instanceUid}_label`}\n htmlFor={instanceUid}\n disabled={disabled}\n readOnly={readOnly}\n checked={checked}\n data-testid=\"ds-checkbox-label\"\n wrapLabel={wrapLabel}\n device={device}\n {...(!disabled && (ariaControls || legacyAriaControls) ? { onClick: handleOnChange } : {})}\n >\n {wrapLabel ? <StyledWrapLabel>{label}</StyledWrapLabel> : <SimpleTruncatedTooltipText value={label} />}\n </StyledLabel>\n )}\n </StyledContainer>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAOA,YAAW;AAClB,SAAS,kCAAkC;AAC3C,SAAS,iBAAiB,iBAAiB,aAAa,sBAAsB;AAC9E,SAAS,iBAAiB;AAC1B,SAAS,iCAAiC;AAEnC,MAAM,4BAA4B,MAAM;AAC7C,QAAM,EAAE,kBAAkB,aAAa,aAAa,cAAc,eAAe,IAC/EA,OAAM,WAAW,yBAAyB;AAC5C,QAAM,EAAE,SAAS,QAAQ,OAAO,UAAU,WAAW,cAAc,mBAAmB,IAAI;AAC1F,QAAM,EAAE,UAAU,UAAU,iBAAiB,cAAc,UAAU,IAAI;AAEzE,SACE,qBAAC;AAAA,IAAgB;AAAA,IAAgB,eAAY;AAAA,IAAwB;AAAA,IAAuB,GAAG;AAAA,IAC7F;AAAA,0BAAC;AAAA,QAAe;AAAA,QAAgB;AAAA,QAAkB;AAAA,QAAoB;AAAA,QAAoB;AAAA,QACxF,8BAAC,aAAU;AAAA,OACb;AAAA,MACC,SACC,oBAAC;AAAA,QACC,IAAI,GAAG;AAAA,QACP,SAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACC,GAAI,CAAC,aAAa,gBAAgB,sBAAsB,EAAE,SAAS,eAAe,IAAI,CAAC;AAAA,QAEvF,sBAAY,oBAAC;AAAA,UAAiB;AAAA,SAAM,IAAqB,oBAAC;AAAA,UAA2B,OAAO;AAAA,SAAO;AAAA,OACtG;AAAA;AAAA,GAEJ;AAEJ;",
6
+ "names": ["React"]
7
+ }
@@ -0,0 +1,50 @@
1
+ import * as React from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import React2 from "react";
4
+ import { StyledInput, StyledInputMixed } from "../styles";
5
+ import { ControlledCheckBoxContext } from "../ControlledCheckboxCTX";
6
+ const MainInput = () => {
7
+ const { propsWithDefault, globalProps, instanceUid, handleOnChange, handleMixedCheckboxOnKeyDown } = React2.useContext(ControlledCheckBoxContext);
8
+ const {
9
+ disabled,
10
+ readOnly,
11
+ tabIndex,
12
+ innerRef,
13
+ checked,
14
+ ariaControls: camelCaseAriaControls
15
+ } = propsWithDefault;
16
+ const { "aria-controls": ariaControls } = globalProps;
17
+ const canShowMixedState = ariaControls || camelCaseAriaControls;
18
+ const mainInputProps = {
19
+ id: instanceUid,
20
+ "data-testid": "ds-checkbox",
21
+ "aria-labelledby": `${instanceUid}_label ${instanceUid}_block_label`,
22
+ "aria-checked": checked,
23
+ ...globalProps
24
+ };
25
+ if (canShowMixedState)
26
+ return /* @__PURE__ */ jsx(StyledInputMixed, {
27
+ ...mainInputProps,
28
+ role: "checkbox",
29
+ "aria-controls": ariaControls || camelCaseAriaControls,
30
+ "aria-disabled": disabled,
31
+ onClick: !disabled && !readOnly ? handleOnChange : void 0,
32
+ onKeyDown: handleMixedCheckboxOnKeyDown,
33
+ tabIndex: tabIndex ?? (disabled ? -1 : 0),
34
+ ref: innerRef
35
+ });
36
+ return /* @__PURE__ */ jsx(StyledInput, {
37
+ ...mainInputProps,
38
+ type: "checkbox",
39
+ checked,
40
+ onChange: handleOnChange,
41
+ onKeyDown: handleMixedCheckboxOnKeyDown,
42
+ disabled,
43
+ tabIndex,
44
+ ref: innerRef
45
+ });
46
+ };
47
+ export {
48
+ MainInput
49
+ };
50
+ //# sourceMappingURL=MainInput.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/MainInput.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { StyledInput, StyledInputMixed } from '../styles';\nimport { ControlledCheckBoxContext } from '../ControlledCheckboxCTX';\n\nexport const MainInput = () => {\n const { propsWithDefault, globalProps, instanceUid, handleOnChange, handleMixedCheckboxOnKeyDown } =\n React.useContext(ControlledCheckBoxContext);\n const {\n disabled,\n readOnly,\n // label,\n tabIndex,\n innerRef,\n checked,\n ariaControls: camelCaseAriaControls,\n // ariaLabel: camelCaseAriaLabel,\n // externalLabel,\n } = propsWithDefault;\n const { 'aria-controls': ariaControls } = globalProps;\n\n // if components doesn't define 'aria-controls' it would be \"a11y invalid\" to allow 'mixed' state\n // so\n // if they are NOT provided we use <input type='checkbox' /> that has no 'mixed' state support in html5\n // if they ARE provided we use <input /> (no type checkbox) in which we super-charge the 'mixed' state via css\n // props slightly differ because of this\n // also, because of this, \"onChange\" may be an onClick (or keyboard activation) or the native \"onChange\"\n const canShowMixedState = ariaControls || camelCaseAriaControls;\n\n const mainInputProps = {\n id: instanceUid,\n 'data-testid': 'ds-checkbox',\n 'aria-labelledby': `${instanceUid}_label ${instanceUid}_block_label`,\n 'aria-checked': checked, // if user doesn't provide aria-checked, we make this the same as the actual value\n ...globalProps, // any props provided by the user will over-ride ours\n };\n\n if (canShowMixedState)\n return (\n <StyledInputMixed\n {...mainInputProps}\n role=\"checkbox\"\n aria-controls={ariaControls || camelCaseAriaControls}\n aria-disabled={disabled}\n onClick={!disabled && !readOnly ? handleOnChange : undefined}\n onKeyDown={handleMixedCheckboxOnKeyDown}\n tabIndex={tabIndex ?? (disabled ? -1 : 0)}\n ref={innerRef}\n />\n );\n return (\n <StyledInput\n {...mainInputProps}\n type=\"checkbox\"\n checked={checked as boolean | undefined}\n onChange={handleOnChange}\n onKeyDown={handleMixedCheckboxOnKeyDown}\n disabled={disabled}\n tabIndex={tabIndex}\n ref={innerRef}\n />\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAOA,YAAW;AAClB,SAAS,aAAa,wBAAwB;AAC9C,SAAS,iCAAiC;AAEnC,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,kBAAkB,aAAa,aAAa,gBAAgB,6BAA6B,IAC/FA,OAAM,WAAW,yBAAyB;AAC5C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,EAGhB,IAAI;AACJ,QAAM,EAAE,iBAAiB,aAAa,IAAI;AAQ1C,QAAM,oBAAoB,gBAAgB;AAE1C,QAAM,iBAAiB;AAAA,IACrB,IAAI;AAAA,IACJ,eAAe;AAAA,IACf,mBAAmB,GAAG,qBAAqB;AAAA,IAC3C,gBAAgB;AAAA,IAChB,GAAG;AAAA,EACL;AAEA,MAAI;AACF,WACE,oBAAC;AAAA,MACE,GAAG;AAAA,MACJ,MAAK;AAAA,MACL,iBAAe,gBAAgB;AAAA,MAC/B,iBAAe;AAAA,MACf,SAAS,CAAC,YAAY,CAAC,WAAW,iBAAiB;AAAA,MACnD,WAAW;AAAA,MACX,UAAU,aAAa,WAAW,KAAK;AAAA,MACvC,KAAK;AAAA,KACP;AAEJ,SACE,oBAAC;AAAA,IACE,GAAG;AAAA,IACJ,MAAK;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,KAAK;AAAA,GACP;AAEJ;",
6
+ "names": ["React"]
7
+ }