@doist/reactist 25.2.0 → 26.1.0

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 (67) hide show
  1. package/dist/reactist.cjs.development.js +225 -121
  2. package/dist/reactist.cjs.development.js.map +1 -1
  3. package/dist/reactist.cjs.production.min.js +1 -1
  4. package/dist/reactist.cjs.production.min.js.map +1 -1
  5. package/es/alert/alert.js +6 -3
  6. package/es/alert/alert.js.map +1 -1
  7. package/es/alert/alert.module.css.js +1 -1
  8. package/es/base-field/base-field.js +98 -46
  9. package/es/base-field/base-field.js.map +1 -1
  10. package/es/base-field/base-field.module.css.js +1 -1
  11. package/es/menu/menu.js +17 -4
  12. package/es/menu/menu.js.map +1 -1
  13. package/es/password-field/password-field.js +5 -4
  14. package/es/password-field/password-field.js.map +1 -1
  15. package/es/select-field/select-field.js +9 -7
  16. package/es/select-field/select-field.js.map +1 -1
  17. package/es/switch-field/switch-field.js +10 -8
  18. package/es/switch-field/switch-field.js.map +1 -1
  19. package/es/text-area/text-area.js +34 -17
  20. package/es/text-area/text-area.js.map +1 -1
  21. package/es/text-area/text-area.module.css.js +1 -1
  22. package/es/text-field/text-field.js +39 -25
  23. package/es/text-field/text-field.js.map +1 -1
  24. package/es/text-field/text-field.module.css.js +1 -1
  25. package/es/tooltip/tooltip.js +4 -2
  26. package/es/tooltip/tooltip.js.map +1 -1
  27. package/lib/alert/alert.js +1 -1
  28. package/lib/alert/alert.js.map +1 -1
  29. package/lib/alert/alert.module.css.js +1 -1
  30. package/lib/base-field/base-field.d.ts +17 -34
  31. package/lib/base-field/base-field.js +1 -1
  32. package/lib/base-field/base-field.js.map +1 -1
  33. package/lib/base-field/base-field.module.css.js +1 -1
  34. package/lib/menu/menu.js +1 -1
  35. package/lib/menu/menu.js.map +1 -1
  36. package/lib/password-field/password-field.d.ts +1 -0
  37. package/lib/password-field/password-field.js +1 -1
  38. package/lib/password-field/password-field.js.map +1 -1
  39. package/lib/select-field/select-field.js +1 -1
  40. package/lib/select-field/select-field.js.map +1 -1
  41. package/lib/switch-field/switch-field.d.ts +1 -1
  42. package/lib/switch-field/switch-field.js +1 -1
  43. package/lib/switch-field/switch-field.js.map +1 -1
  44. package/lib/text-area/text-area.d.ts +9 -1
  45. package/lib/text-area/text-area.js +1 -1
  46. package/lib/text-area/text-area.js.map +1 -1
  47. package/lib/text-area/text-area.module.css.js +1 -1
  48. package/lib/text-field/text-field.js +1 -1
  49. package/lib/text-field/text-field.js.map +1 -1
  50. package/lib/text-field/text-field.module.css.js +1 -1
  51. package/lib/tooltip/tooltip.d.ts +11 -1
  52. package/lib/tooltip/tooltip.js +1 -1
  53. package/lib/tooltip/tooltip.js.map +1 -1
  54. package/package.json +1 -1
  55. package/styles/alert.css +1 -1
  56. package/styles/alert.module.css.css +1 -1
  57. package/styles/base-field.css +3 -2
  58. package/styles/base-field.module.css.css +1 -1
  59. package/styles/index.css +1 -2
  60. package/styles/password-field.css +3 -2
  61. package/styles/reactist.css +5 -5
  62. package/styles/select-field.css +2 -1
  63. package/styles/switch-field.css +2 -1
  64. package/styles/text-area.css +3 -2
  65. package/styles/text-area.module.css.css +1 -1
  66. package/styles/text-field.css +3 -2
  67. package/styles/text-field.module.css.css +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"select-field.js","sources":["../../src/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ninterface SelectFieldProps extends FieldComponentProps<HTMLSelectElement>, BaseFieldVariantProps {}\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n data-testid=\"select-wrapper\"\n className={[\n styles.selectWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n >\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","forwardRef","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","children","hidden","ariaDescribedBy","props","createElement","BaseField","extraProps","Box","className","styles","selectWrapper","error","bordered","_objectSpread","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;AAOMA,MAAAA,WAAW,gBAAGC,KAAK,CAACC,UAAN,CAAsD,SAASF,WAAT,CAgBtEG,IAAAA,EAAAA,GAhBsE,EAgBnE;EAAA,IAfH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;IASIC,QATJ;IAUIC,QAVJ;IAWIC,MAXJ;IAYI,kBAAoBC,EAAAA,eAAAA;GAGrB,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA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AAA4BC,IAAAA,IAAI,EAAC,MAAjC;AAAwCC,IAAAA,KAAK,EAAC,4BAAA;AAA9C,GAAA,EAA+Ef,KAA/E,CACIf,eAAAA,KACI,CAAAgB,aADJ,CACI,MADJ,EACI;AAAAe,IAAAA,CAAC,EAAC,yGAAF;AACAF,IAAAA,IAAI,EAAC,cAAA;AADL,GADJ,CADJ,CADJ,CAAA;AAQH;;;;"}
1
+ {"version":3,"file":"select-field.js","sources":["../../src/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ninterface SelectFieldProps extends FieldComponentProps<HTMLSelectElement>, BaseFieldVariantProps {}\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n variant = 'default',\n id,\n label,\n value,\n auxiliaryLabel,\n message,\n tone,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n onChange: originalOnChange,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n value={value}\n auxiliaryLabel={auxiliaryLabel}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n data-testid=\"select-wrapper\"\n className={[\n styles.selectWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n >\n <select\n {...props}\n {...extraProps}\n ref={ref}\n onChange={(event) => {\n originalOnChange?.(event)\n }}\n >\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","forwardRef","ref","variant","id","label","value","auxiliaryLabel","message","tone","maxWidth","children","hidden","ariaDescribedBy","onChange","originalOnChange","props","createElement","BaseField","extraProps","Box","className","styles","selectWrapper","error","bordered","_objectSpread","event","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;AAOMA,MAAAA,WAAW,gBAAGC,KAAK,CAACC,UAAN,CAAsD,SAASF,WAAT,CAgBtEG,IAAAA,EAAAA,GAhBsE,EAgBnE;EAAA,IAfH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,KAJJ;IAKIC,cALJ;IAMIC,OANJ;IAOIC,IAPJ;IAQIC,QARJ;IASIC,QATJ;IAUIC,MAVJ;AAWI,IAAA,kBAAA,EAAoBC,eAXxB;AAYIC,IAAAA,QAAQ,EAAEC,gBAAAA;GAGX,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,oBACIhB,KAAC,CAAAiB,aAAD,CAACC,SAAD,EACI;AAAAf,IAAAA,OAAO,EAAEA,OAAT;AACAC,IAAAA,EAAE,EAAEA,EADJ;AAEAC,IAAAA,KAAK,EAAEA,KAFP;AAGAC,IAAAA,KAAK,EAAEA,KAHP;AAIAC,IAAAA,cAAc,EAAEA,cAJhB;AAKAC,IAAAA,OAAO,EAAEA,OALT;AAMAC,IAAAA,IAAI,EAAEA,IANN;AAOAC,IAAAA,QAAQ,EAAEA,QAPV;AAQAE,IAAAA,MAAM,EAAEA,MARR;IASkB,kBAAAC,EAAAA,eAAAA;GAVtB,EAYMM,UAAD,iBACGnB,KAAC,CAAAiB,aAAD,CAACG,GAAD,EACgB;AAAA,IAAA,aAAA,EAAA,gBAAA;IACZC,SAAS,EAAE,CACPC,gBAAM,CAACC,aADA,EAEPd,IAAI,KAAK,OAAT,GAAmBa,gBAAM,CAACE,KAA1B,GAAkC,IAF3B,EAGPrB,OAAO,KAAK,UAAZ,GAAyBmB,gBAAM,CAACG,QAAhC,GAA2C,IAHpC,CAAA;GAFf,eAQIzB,KAAA,CAAAiB,aAAA,CAAA,QAAA,EAAAS,cAAA,CAAAA,cAAA,CAAAA,cAAA,CAAA,EAAA,EACQV,KADR,CAAA,EAEQG,UAFR,CAAA,EAAA,EAAA,EAAA;AAGIjB,IAAAA,GAAG,EAAEA,GAHT;IAIIY,QAAQ,EAAGa,KAAD,IAAU;AAChBZ,MAAAA,gBAAgB,IAAhB,IAAA,GAAA,KAAA,CAAA,GAAAA,gBAAgB,CAAGY,KAAH,CAAhB,CAAA;AACH,KAAA;GAEAhB,CAAAA,EAAAA,QARL,CARJ,eAkBIX,KAAA,CAAAiB,aAAA,CAACW,aAAD,EAA6B;IAAA,aAAA,EAAA,IAAA;GAA7B,CAlBJ,CAbR,CADJ,CAAA;AAqCH,CAvDmB,EAApB;;AAyDA,SAASA,aAAT,CAAuBZ,KAAvB,EAA0D;AACtD,EAAA,oBACIhB,KAAK,CAAAiB,aAAL,CAAK,KAAL,EAAAS,cAAA,CAAA;AAAKG,IAAAA,KAAK,EAAC,IAAX;AAAgBC,IAAAA,MAAM,EAAC,IAAvB;AAA4BC,IAAAA,IAAI,EAAC,MAAjC;AAAwCC,IAAAA,KAAK,EAAC,4BAAA;AAA9C,GAAA,EAA+EhB,KAA/E,CACIhB,eAAAA,KACI,CAAAiB,aADJ,CACI,MADJ,EACI;AAAAgB,IAAAA,CAAC,EAAC,yGAAF;AACAF,IAAAA,IAAI,EAAC,cAAA;AADL,GADJ,CADJ,CADJ,CAAA;AAQH;;;;"}
@@ -4,17 +4,18 @@ import { Box } from '../box/box.js';
4
4
  import { Stack } from '../stack/stack.js';
5
5
  import { Text } from '../text/text.js';
6
6
  import { HiddenVisually } from '../hidden-visually/hidden-visually.js';
7
- import { FieldHint } from '../base-field/base-field.js';
7
+ import { FieldMessage } from '../base-field/base-field.js';
8
8
  import { useId } from '../utils/common-helpers.js';
9
9
  import modules_8e05f7c9 from './switch-field.module.css.js';
10
10
 
11
- const _excluded = ["label", "hint", "disabled", "hidden", "defaultChecked", "id", "aria-describedby", "aria-label", "aria-labelledby", "onChange"];
11
+ const _excluded = ["label", "message", "tone", "disabled", "hidden", "defaultChecked", "id", "aria-describedby", "aria-label", "aria-labelledby", "onChange"];
12
12
  const SwitchField = /*#__PURE__*/React.forwardRef(function SwitchField(_ref, ref) {
13
13
  var _ref2, _props$checked, _props$checked2;
14
14
 
15
15
  let {
16
16
  label,
17
- hint,
17
+ message,
18
+ tone = 'neutral',
18
19
  disabled = false,
19
20
  hidden,
20
21
  defaultChecked,
@@ -27,8 +28,8 @@ const SwitchField = /*#__PURE__*/React.forwardRef(function SwitchField(_ref, ref
27
28
  props = _objectWithoutProperties(_ref, _excluded);
28
29
 
29
30
  const id = useId(originalId);
30
- const hintId = useId();
31
- const ariaDescribedBy = originalAriaDescribedBy != null ? originalAriaDescribedBy : hint ? hintId : undefined;
31
+ const messageId = useId();
32
+ const ariaDescribedBy = originalAriaDescribedBy != null ? originalAriaDescribedBy : message ? messageId : undefined;
32
33
  const ariaLabel = originalAriaLabel != null ? originalAriaLabel : undefined;
33
34
  const ariaLabelledBy = originalAriaLabelledby != null ? originalAriaLabelledby : undefined;
34
35
  const [keyFocused, setKeyFocused] = React.useState(false);
@@ -77,9 +78,10 @@ const SwitchField = /*#__PURE__*/React.forwardRef(function SwitchField(_ref, ref
77
78
  className: modules_8e05f7c9.handle
78
79
  })), /*#__PURE__*/React.createElement(Text, {
79
80
  exceptionallySetClassName: modules_8e05f7c9.label
80
- }, label)), hint ? /*#__PURE__*/React.createElement(FieldHint, {
81
- id: hintId
82
- }, hint) : null);
81
+ }, label)), message ? /*#__PURE__*/React.createElement(FieldMessage, {
82
+ id: messageId,
83
+ tone: tone
84
+ }, message) : null);
83
85
  });
84
86
 
85
87
  export { SwitchField };
@@ -1 +1 @@
1
- {"version":3,"file":"switch-field.js","sources":["../../src/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../utils/common-helpers'\nimport styles from './switch-field.module.css'\n\ninterface SwitchFieldProps\n extends Omit<\n FieldComponentProps<HTMLInputElement>,\n | 'type'\n | 'secondaryLabel'\n | 'auxiliaryLabel'\n | 'maxWidth'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n > {\n /**\n * Identifies the element (or elements) that describes the switch for assistive technologies.\n */\n 'aria-describedby'?: string\n\n /**\n * Defines a string value that labels the current switch for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current switch for assistive technologies.\n */\n 'aria-labelledby'?: string\n}\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n hint,\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n 'aria-label': originalAriaLabel,\n 'aria-labelledby': originalAriaLabelledby,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const hintId = useId()\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n const ariaLabel = originalAriaLabel ?? undefined\n const ariaLabelledBy = originalAriaLabelledby ?? undefined\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <Text exceptionallySetClassName={styles.label}>{label}</Text>\n </Box>\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n})\n\nexport { SwitchField }\nexport type { SwitchFieldProps }\n"],"names":["SwitchField","React","forwardRef","ref","label","hint","disabled","hidden","defaultChecked","id","originalId","originalAriaDescribedBy","originalAriaLabel","originalAriaLabelledby","onChange","props","useId","hintId","ariaDescribedBy","undefined","ariaLabel","ariaLabelledBy","keyFocused","setKeyFocused","useState","checkedState","setChecked","checked","isChecked","createElement","Stack","space","Box","className","styles","container","as","display","alignItems","position","overflow","marginRight","flexShrink","toggle","HiddenVisually","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","handle","Text","exceptionallySetClassName","FieldHint"],"mappings":";;;;;;;;;;;AAoCMA,MAAAA,WAAW,gBAAGC,KAAK,CAACC,UAAN,CAAqD,SAASF,WAAT,CAcrEG,IAAAA,EAAAA,GAdqE,EAclE;AAAA,EAAA,IAAA,KAAA,EAAA,cAAA,EAAA,eAAA,CAAA;;EAAA,IAbH;IACIC,KADJ;IAEIC,IAFJ;AAGIC,IAAAA,QAAQ,GAAG,KAHf;IAIIC,MAJJ;IAKIC,cALJ;AAMIC,IAAAA,EAAE,EAAE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AA;KAdT;IAgBIsB,MAAM,EAAGH,KAAD,IAAU;MACdvB,aAAa,CAAC,KAAD,CAAb,CAAA;MACAR,KAAK,IAAA,IAAL,GAAAA,KAAAA,CAAAA,GAAAA,KAAK,CAAEkC,MAAP,oBAAAlC,KAAK,CAAEkC,MAAP,CAAgBH,KAAhB,CAAA,CAAA;KAlBR;IAoBII,OAAO,EAAGJ,KAAD,IAAU;MACfvB,aAAa,CAAC,IAAD,CAAb,CAAA;MACAR,KAAK,IAAA,IAAL,GAAAA,KAAAA,CAAAA,GAAAA,KAAK,CAAEmC,OAAP,oBAAAnC,KAAK,CAAEmC,OAAP,CAAiBJ,KAAjB,CAAA,CAAA;AACH,KAAA;AAvBL,GAAA,CAAA,CADJ,CARJ,eAmCI7C,KAAA,CAAA4B,aAAA,CAAA,MAAA,EAAA;IAAMI,SAAS,EAAEC,gBAAM,CAACiB,MAAAA;GAAxB,CAnCJ,CAXJ,eAgDIlD,KAAC,CAAA4B,aAAD,CAACuB,IAAD,EAAM;IAAAC,yBAAyB,EAAEnB,gBAAM,CAAC9B,KAAAA;AAAlC,GAAN,EAAgDA,KAAhD,CAhDJ,CADJ,EAmDKC,IAAI,gBAAGJ,mBAAA,CAACqD,SAAD,EAAU;AAAC7C,IAAAA,EAAE,EAAEQ,MAAAA;AAAL,GAAV,EAAwBZ,IAAxB,CAAH,GAA+C,IAnDxD,CADJ,CAAA;AAuDH,CAlFmB;;;;"}
1
+ {"version":3,"file":"switch-field.js","sources":["../../src/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldMessage } from '../base-field'\nimport { useId } from '../utils/common-helpers'\nimport styles from './switch-field.module.css'\n\ninterface SwitchFieldProps\n extends Omit<\n FieldComponentProps<HTMLInputElement>,\n | 'type'\n | 'auxiliaryLabel'\n | 'maxWidth'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n > {\n /**\n * Identifies the element (or elements) that describes the switch for assistive technologies.\n */\n 'aria-describedby'?: string\n\n /**\n * Defines a string value that labels the current switch for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current switch for assistive technologies.\n */\n 'aria-labelledby'?: string\n}\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n message,\n tone = 'neutral',\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n 'aria-label': originalAriaLabel,\n 'aria-labelledby': originalAriaLabelledby,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const messageId = useId()\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (message ? messageId : undefined)\n const ariaLabel = originalAriaLabel ?? undefined\n const ariaLabelledBy = originalAriaLabelledby ?? undefined\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <Text exceptionallySetClassName={styles.label}>{label}</Text>\n </Box>\n {message ? (\n <FieldMessage id={messageId} tone={tone}>\n {message}\n </FieldMessage>\n ) : null}\n </Stack>\n )\n})\n\nexport { SwitchField }\nexport type { SwitchFieldProps }\n"],"names":["SwitchField","React","forwardRef","ref","label","message","tone","disabled","hidden","defaultChecked","id","originalId","originalAriaDescribedBy","originalAriaLabel","originalAriaLabelledby","onChange","props","useId","messageId","ariaDescribedBy","undefined","ariaLabel","ariaLabelledBy","keyFocused","setKeyFocused","useState","checkedState","setChecked","checked","isChecked","createElement","Stack","space","Box","className","styles","container","as","display","alignItems","position","overflow","marginRight","flexShrink","toggle","HiddenVisually","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","handle","Text","exceptionallySetClassName","FieldMessage"],"mappings":";;;;;;;;;;;AAmCMA,MAAAA,WAAW,gBAAGC,KAAK,CAACC,UAAN,CAAqD,SAASF,WAAT,CAerEG,IAAAA,EAAAA,GAfqE,EAelE;AAAA,EAAA,IAAA,KAAA,EAAA,cAAA,EAAA,eAAA,CAAA;;EAAA,IAdH;IACIC,KADJ;IAEIC,OAFJ;AAGIC,IAAAA,IAAI,GAAG,SAHX;AAIIC,IAAAA,QAAQ,GAAG,KAJf;IAKIC,MALJ;IAMIC,cANJ;AAOIC,IAAAA,EAAE,EAAEC,UAPR;AAQI,IAAA,kBAAA,EAAoBC,uBARxB;AASI,IAAA,YAAA,EAAcC,iBATlB;AAUI,IAAA,iBAAA,EAAmBC,sBAVvB;AAWIC,IAAAA,QAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMN,EAAE,GAAGO,KAAK,CAACN,UAAD,CAAhB,CAAA;EACA,MAAMO,SAAS,GAAGD,KAAK,EAAvB,CAAA;EAEA,MAAME,eAA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KAAK,CAAEmC,OAAP,oBAAAnC,KAAK,CAAEmC,OAAP,CAAiBJ,KAAjB,CAAA,CAAA;AACH,KAAA;AAvBL,GAAA,CAAA,CADJ,CARJ,eAmCI9C,KAAA,CAAA6B,aAAA,CAAA,MAAA,EAAA;IAAMI,SAAS,EAAEC,gBAAM,CAACiB,MAAAA;GAAxB,CAnCJ,CAXJ,eAgDInD,KAAC,CAAA6B,aAAD,CAACuB,IAAD,EAAM;IAAAC,yBAAyB,EAAEnB,gBAAM,CAAC/B,KAAAA;AAAlC,GAAN,EAAgDA,KAAhD,CAhDJ,CADJ,EAmDKC,OAAO,gBACJJ,KAAA,CAAA6B,aAAA,CAACyB,YAAD,EAAc;AAAA7C,IAAAA,EAAE,EAAEQ,SAAJ;AAAeZ,IAAAA,IAAI,EAAEA,IAAAA;AAArB,GAAd,EACKD,OADL,CADI,GAIJ,IAvDR,CADJ,CAAA;AA2DH,CAvFmB;;;;"}
@@ -1,32 +1,37 @@
1
1
  import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import * as React from 'react';
3
+ import classNames from 'classnames';
3
4
  import { useMergeRefs } from 'use-callback-ref';
4
5
  import { BaseField } from '../base-field/base-field.js';
5
6
  import { Box } from '../box/box.js';
6
7
  import modules_2728c236 from './text-area.module.css.js';
7
8
 
8
- const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "hidden", "aria-describedby", "rows", "autoExpand"];
9
+ const _excluded = ["variant", "id", "label", "value", "auxiliaryLabel", "message", "tone", "maxWidth", "maxLength", "hidden", "aria-describedby", "rows", "autoExpand", "disableResize", "onChange"],
10
+ _excluded2 = ["onChange"];
9
11
  const TextArea = /*#__PURE__*/React.forwardRef(function TextArea(_ref, ref) {
10
12
  let {
11
13
  variant = 'default',
12
14
  id,
13
15
  label,
14
- secondaryLabel,
16
+ value,
15
17
  auxiliaryLabel,
16
- hint,
17
18
  message,
18
19
  tone,
19
20
  maxWidth,
21
+ maxLength,
20
22
  hidden,
21
23
  'aria-describedby': ariaDescribedBy,
22
24
  rows,
23
- autoExpand = false
25
+ autoExpand = false,
26
+ disableResize = false,
27
+ onChange: originalOnChange
24
28
  } = _ref,
25
29
  props = _objectWithoutProperties(_ref, _excluded);
26
30
 
27
31
  const containerRef = React.useRef(null);
28
32
  const internalRef = React.useRef(null);
29
33
  const combinedRef = useMergeRefs([ref, internalRef]);
34
+ const textAreaClassName = classNames([autoExpand ? modules_2728c236.disableResize : null, disableResize ? modules_2728c236.disableResize : null]);
30
35
  React.useEffect(function setupAutoExpand() {
31
36
  const containerElement = containerRef.current;
32
37
 
@@ -55,25 +60,37 @@ const TextArea = /*#__PURE__*/React.forwardRef(function TextArea(_ref, ref) {
55
60
  variant: variant,
56
61
  id: id,
57
62
  label: label,
58
- secondaryLabel: secondaryLabel,
63
+ value: value,
59
64
  auxiliaryLabel: auxiliaryLabel,
60
- hint: hint,
61
65
  message: message,
62
66
  tone: tone,
63
67
  hidden: hidden,
64
68
  "aria-describedby": ariaDescribedBy,
65
69
  className: [modules_2728c236.textAreaContainer, tone === 'error' ? modules_2728c236.error : null, variant === 'bordered' ? modules_2728c236.bordered : null],
66
- maxWidth: maxWidth
67
- }, extraProps => /*#__PURE__*/React.createElement(Box, {
68
- width: "full",
69
- display: "flex",
70
- className: modules_2728c236.innerContainer,
71
- ref: containerRef
72
- }, /*#__PURE__*/React.createElement("textarea", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
73
- ref: combinedRef,
74
- rows: rows,
75
- className: autoExpand ? modules_2728c236.autoExpand : undefined
76
- }))));
70
+ maxWidth: maxWidth,
71
+ maxLength: maxLength
72
+ }, _ref2 => {
73
+ let {
74
+ onChange
75
+ } = _ref2,
76
+ extraProps = _objectWithoutProperties(_ref2, _excluded2);
77
+
78
+ return /*#__PURE__*/React.createElement(Box, {
79
+ width: "full",
80
+ display: "flex",
81
+ className: modules_2728c236.innerContainer,
82
+ ref: containerRef
83
+ }, /*#__PURE__*/React.createElement("textarea", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
84
+ ref: combinedRef,
85
+ rows: rows,
86
+ className: textAreaClassName,
87
+ maxLength: maxLength,
88
+ onChange: event => {
89
+ originalOnChange == null ? void 0 : originalOnChange(event);
90
+ onChange == null ? void 0 : onChange(event);
91
+ }
92
+ })));
93
+ });
77
94
  });
78
95
 
79
96
  export { TextArea };
@@ -1 +1 @@
1
- {"version":3,"file":"text-area.js","sources":["../../src/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMergeRefs } from 'use-callback-ref'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ninterface TextAreaProps extends FieldComponentProps<HTMLTextAreaElement>, BaseFieldVariantProps {\n /**\n * The number of visible text lines for the text area.\n *\n * If it is specified, it must be a positive integer. If it is not specified, the default\n * value is 2 (set by the browser).\n *\n * When `autoExpand` is true, this value serves the purpose of specifying the minimum number\n * of rows that the textarea will shrink to when the content is not large enough to make it\n * expand.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n */\n rows?: number\n\n /**\n * If `true`, the textarea will auto-expand or shrink vertically to fit the content.\n */\n autoExpand?: boolean\n}\n\nconst TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n rows,\n autoExpand = false,\n ...props\n },\n ref,\n) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n React.useEffect(\n function setupAutoExpand() {\n const containerElement = containerRef.current\n\n function handleAutoExpand(value: string) {\n if (containerElement) {\n containerElement.dataset.replicatedValue = value\n }\n }\n\n function handleInput(event: Event) {\n handleAutoExpand((event.currentTarget as HTMLTextAreaElement).value)\n }\n\n const textAreaElement = internalRef.current\n if (!textAreaElement || !autoExpand) {\n return undefined\n }\n\n // Apply change initially, in case the text area has a non-empty initial value\n handleAutoExpand(textAreaElement.value)\n\n textAreaElement.addEventListener('input', handleInput)\n return () => textAreaElement.removeEventListener('input', handleInput)\n },\n [autoExpand],\n )\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n className={[\n styles.textAreaContainer,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box\n width=\"full\"\n display=\"flex\"\n className={styles.innerContainer}\n ref={containerRef}\n >\n <textarea\n {...props}\n {...extraProps}\n ref={combinedRef}\n rows={rows}\n className={autoExpand ? styles.autoExpand : undefined}\n />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","React","forwardRef","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","hidden","ariaDescribedBy","rows","autoExpand","props","containerRef","useRef","internalRef","combinedRef","useMergeRefs","useEffect","setupAutoExpand","containerElement","current","handleAutoExpand","value","dataset","replicatedValue","handleInput","event","currentTarget","textAreaElement","undefined","addEventListener","removeEventListener","createElement","BaseField","className","styles","textAreaContainer","error","bordered","extraProps","Box","width","display","innerContainer","_objectSpread"],"mappings":";;;;;;;;AA2BMA,MAAAA,QAAQ,gBAAGC,KAAK,CAACC,UAAN,CAAqD,SAASF,QAAT,CAiBlEG,IAAAA,EAAAA,GAjBkE,EAiB/D;EAAA,IAhBH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;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AAqCH,CAxFgB;;;;"}
1
+ {"version":3,"file":"text-area.js","sources":["../../src/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { useMergeRefs } from 'use-callback-ref'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ninterface TextAreaProps extends FieldComponentProps<HTMLTextAreaElement>, BaseFieldVariantProps {\n /**\n * The number of visible text lines for the text area.\n *\n * If it is specified, it must be a positive integer. If it is not specified, the default\n * value is 2 (set by the browser).\n *\n * When `autoExpand` is true, this value serves the purpose of specifying the minimum number\n * of rows that the textarea will shrink to when the content is not large enough to make it\n * expand.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n */\n rows?: number\n\n /**\n * If `true`, the textarea will be automatically resized to fit the content, and the ability to\n * manually resize the textarea will be disabled.\n */\n autoExpand?: boolean\n\n /**\n * If `true`, the ability to manually resize the textarea will be disabled.\n *\n * When `autoExpand` is true, this property serves no purpose, because the ability to manually\n * resize the textarea is always disabled when `autoExpand` is true.\n */\n disableResize?: boolean\n}\n\nconst TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n {\n variant = 'default',\n id,\n label,\n value,\n auxiliaryLabel,\n message,\n tone,\n maxWidth,\n maxLength,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n rows,\n autoExpand = false,\n disableResize = false,\n onChange: originalOnChange,\n ...props\n },\n ref,\n) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n const textAreaClassName = classNames([\n autoExpand ? styles.disableResize : null,\n disableResize ? styles.disableResize : null,\n ])\n\n React.useEffect(\n function setupAutoExpand() {\n const containerElement = containerRef.current\n\n function handleAutoExpand(value: string) {\n if (containerElement) {\n containerElement.dataset.replicatedValue = value\n }\n }\n\n function handleInput(event: Event) {\n handleAutoExpand((event.currentTarget as HTMLTextAreaElement).value)\n }\n\n const textAreaElement = internalRef.current\n if (!textAreaElement || !autoExpand) {\n return undefined\n }\n\n // Apply change initially, in case the text area has a non-empty initial value\n handleAutoExpand(textAreaElement.value)\n\n textAreaElement.addEventListener('input', handleInput)\n return () => textAreaElement.removeEventListener('input', handleInput)\n },\n [autoExpand],\n )\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n value={value}\n auxiliaryLabel={auxiliaryLabel}\n message={message}\n tone={tone}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n className={[\n styles.textAreaContainer,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n maxLength={maxLength}\n >\n {({ onChange, ...extraProps }) => (\n <Box\n width=\"full\"\n display=\"flex\"\n className={styles.innerContainer}\n ref={containerRef}\n >\n <textarea\n {...props}\n {...extraProps}\n ref={combinedRef}\n rows={rows}\n className={textAreaClassName}\n maxLength={maxLength}\n onChange={(event) => {\n originalOnChange?.(event)\n onChange?.(event)\n }}\n />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","React","forwardRef","ref","variant","id","label","value","auxiliaryLabel","message","tone","maxWidth","maxLength","hidden","ariaDescribedBy","rows","autoExpand","disableResize","onChange","originalOnChange","props","containerRef","useRef","internalRef","combinedRef","useMergeRefs","textAreaClassName","classNames","styles","useEffect","setupAutoExpand","containerElement","current","handleAutoExpand","dataset","replicatedValue","handleInput","event","currentTarget","textAreaElement","undefined","addEventListener","removeEventListener","createElement","BaseField","className","textAreaContainer","error","bordered","extraProps","Box","width","display","innerContainer","_objectSpread"],"mappings":";;;;;;;;;;AAqCMA,MAAAA,QAAQ,gBAAGC,KAAK,CAACC,UAAN,CAAqD,SAASF,QAAT,CAmBlEG,IAAAA,EAAAA,GAnBkE,EAmB/D;EAAA,IAlBH;AACIC,IAAAA,OAAO,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GAAD;AACIC,MAAAA,KAAK,EAAC;AACNC,MAAAA,OAAO,EAAC;MACRP,SAAS,EAAEjB,gBAAM,CAACyB;AAClBlD,MAAAA,GAAG,EAAEkB,YAAAA;KAJT,eAMIpB,KACQ,CAAA0C,aADR,CACQ,UADR,EAAAW,cAAA,CAAAA,cAAA,CAAAA,cAAA,CAAA,EAAA,EACQlC,KADR,CAAA,EAEQ6B,UAFR,CAAA,EAAA,EAAA,EAAA;AAGI9C,MAAAA,GAAG,EAAEqB,WAHT;AAIIT,MAAAA,IAAI,EAAEA,IAJV;AAKI8B,MAAAA,SAAS,EAAEnB,iBALf;AAMId,MAAAA,SAAS,EAAEA,SANf;MAOIM,QAAQ,EAAGmB,KAAD,IAAU;AAChBlB,QAAAA,gBAAgB,IAAhB,IAAA,GAAA,KAAA,CAAA,GAAAA,gBAAgB,CAAGkB,KAAH,CAAhB,CAAA;AACAnB,QAAAA,QAAQ,IAAR,IAAA,GAAA,KAAA,CAAA,GAAAA,QAAQ,CAAGmB,KAAH,CAAR,CAAA;AACH,OAAA;AAVL,KAAA,CAAA,CANJ,CADH,CAAA;AAAA,GAlBL,CADJ,CAAA;AA0CH,CApGgB;;;;"}
@@ -1,4 +1,4 @@
1
- var modules_2728c236 = {"textAreaContainer":"_55ccf266","innerContainer":"_89bb7098","bordered":"_02a47358","error":"_704ff540","autoExpand":"_145ca8f0"};
1
+ var modules_2728c236 = {"textAreaContainer":"a95cb864","innerContainer":"ab9873f7","bordered":"de380efd","error":"_29a9d12f","disableResize":"_44f7147e"};
2
2
 
3
3
  export { modules_2728c236 as default };
4
4
  //# sourceMappingURL=text-area.module.css.js.map
@@ -5,23 +5,25 @@ import { Box } from '../box/box.js';
5
5
  import modules_aaf25250 from './text-field.module.css.js';
6
6
  import { useMergeRefs } from 'use-callback-ref';
7
7
 
8
- const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "type", "maxWidth", "hidden", "aria-describedby", "startSlot", "endSlot"];
8
+ const _excluded = ["variant", "id", "label", "value", "auxiliaryLabel", "message", "tone", "type", "maxWidth", "maxLength", "hidden", "aria-describedby", "startSlot", "endSlot", "onChange"],
9
+ _excluded2 = ["onChange"];
9
10
  const TextField = /*#__PURE__*/React.forwardRef(function TextField(_ref, ref) {
10
11
  let {
11
12
  variant = 'default',
12
13
  id,
13
14
  label,
14
- secondaryLabel,
15
+ value,
15
16
  auxiliaryLabel,
16
- hint,
17
17
  message,
18
18
  tone,
19
19
  type = 'text',
20
20
  maxWidth,
21
+ maxLength,
21
22
  hidden,
22
23
  'aria-describedby': ariaDescribedBy,
23
24
  startSlot,
24
- endSlot
25
+ endSlot,
26
+ onChange: originalOnChange
25
27
  } = _ref,
26
28
  props = _objectWithoutProperties(_ref, _excluded);
27
29
 
@@ -39,33 +41,45 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(_ref, ref) {
39
41
  variant: variant,
40
42
  id: id,
41
43
  label: label,
42
- secondaryLabel: secondaryLabel,
44
+ value: value,
43
45
  auxiliaryLabel: auxiliaryLabel,
44
- hint: hint,
45
46
  message: message,
46
47
  tone: tone,
47
48
  maxWidth: maxWidth,
49
+ maxLength: maxLength,
48
50
  hidden: hidden,
49
51
  "aria-describedby": ariaDescribedBy
50
- }, extraProps => /*#__PURE__*/React.createElement(Box, {
51
- display: "flex",
52
- alignItems: "center",
53
- className: [modules_aaf25250.inputWrapper, tone === 'error' ? modules_aaf25250.error : null, variant === 'bordered' ? modules_aaf25250.bordered : null],
54
- onClick: handleClick
55
- }, startSlot ? /*#__PURE__*/React.createElement(Box, {
56
- className: modules_aaf25250.slot,
57
- display: "flex",
58
- marginRight: variant === 'bordered' ? 'xsmall' : '-xsmall',
59
- marginLeft: variant === 'bordered' ? '-xsmall' : 'xsmall'
60
- }, startSlot) : null, /*#__PURE__*/React.createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
61
- type: type,
62
- ref: combinedRef
63
- })), endSlot ? /*#__PURE__*/React.createElement(Box, {
64
- className: modules_aaf25250.slot,
65
- display: "flex",
66
- marginRight: variant === 'bordered' ? '-xsmall' : 'xsmall',
67
- marginLeft: variant === 'bordered' ? 'xsmall' : '-xsmall'
68
- }, endSlot) : null));
52
+ }, _ref2 => {
53
+ let {
54
+ onChange
55
+ } = _ref2,
56
+ extraProps = _objectWithoutProperties(_ref2, _excluded2);
57
+
58
+ return /*#__PURE__*/React.createElement(Box, {
59
+ display: "flex",
60
+ alignItems: "center",
61
+ className: [modules_aaf25250.inputWrapper, tone === 'error' ? modules_aaf25250.error : null, variant === 'bordered' ? modules_aaf25250.bordered : null, props.readOnly ? modules_aaf25250.readOnly : null],
62
+ onClick: handleClick
63
+ }, startSlot ? /*#__PURE__*/React.createElement(Box, {
64
+ className: modules_aaf25250.slot,
65
+ display: "flex",
66
+ marginRight: variant === 'bordered' ? 'xsmall' : '-xsmall',
67
+ marginLeft: variant === 'bordered' ? '-xsmall' : 'xsmall'
68
+ }, startSlot) : null, /*#__PURE__*/React.createElement("input", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
69
+ type: type,
70
+ ref: combinedRef,
71
+ maxLength: maxLength,
72
+ onChange: event => {
73
+ originalOnChange == null ? void 0 : originalOnChange(event);
74
+ onChange == null ? void 0 : onChange(event);
75
+ }
76
+ })), endSlot ? /*#__PURE__*/React.createElement(Box, {
77
+ className: modules_aaf25250.slot,
78
+ display: "flex",
79
+ marginRight: variant === 'bordered' ? '-xsmall' : 'xsmall',
80
+ marginLeft: variant === 'bordered' ? 'xsmall' : '-xsmall'
81
+ }, endSlot) : null);
82
+ });
69
83
  });
70
84
 
71
85
  export { TextField };
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.js","sources":["../../src/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\nimport { useMergeRefs } from 'use-callback-ref'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ninterface TextFieldProps\n extends Omit<FieldComponentProps<HTMLInputElement>, 'type'>,\n BaseFieldVariantProps {\n type?: TextFieldType\n startSlot?: React.ReactElement | string | number\n endSlot?: React.ReactElement | string | number\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n startSlot,\n endSlot,\n ...props\n },\n ref,\n) {\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n function handleClick(event: React.MouseEvent) {\n if (event.currentTarget === combinedRef.current) return\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.inputWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n onClick={handleClick}\n >\n {startSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n marginLeft={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n >\n {startSlot}\n </Box>\n ) : null}\n <input {...props} {...extraProps} type={type} ref={combinedRef} />\n {endSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n marginLeft={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n >\n {endSlot}\n </Box>\n ) : null}\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","forwardRef","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","type","maxWidth","hidden","ariaDescribedBy","startSlot","endSlot","props","internalRef","useRef","combinedRef","useMergeRefs","handleClick","event","currentTarget","current","focus","createElement","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","error","bordered","onClick","slot","marginRight","marginLeft"],"mappings":";;;;;;;;AAiBMA,MAAAA,SAAS,gBAAGC,KAAK,CAACC,UAAN,CAAmD,SAASF,SAAT,CAkBjEG,IAAAA,EAAAA,GAlBiE,EAkB9D;EAAA,IAjBH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;AASIC,IAAAA,IAAI,GAAG,MATX;IAUIC,QAVJ;IAWIC,MAXJ;AAYI,IAAA,kBAAA,EAAoBC,eAZxB;IAaIC,SAbJ;AAcIC,IAAAA,OAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,WAAW,GAAGlB,KAAK,CAACmB,MAAN,CAA+B,IAA/B,CAApB,CAAA;EACA,MAAMC,WAAW,GAAGC,YAAY,CAAC,CAACnB,GAAD,EAAMgB,WAAN,CAAD,CAAhC,CAAA;;EAEA,SAASI,WAAT,CAAqBC,KAArB,EAA4C;AAAA,IAAA,IAAA,oBAAA,CAAA;;AACxC,IAAA,IAAIA,KAAK,CAACC,aAAN,KAAwBJ,WAAW,CAACK,OAAxC,EAAiD,OAAA;AACjD,IAAA,CAAA,oBAAA,GAAAP,WAAW,CAACO,OAAZ,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,oBAAA,CAAqBC,KAArB,EAAA,CAAA;AACH,GAAA;;AAED,EAAA,oBACI1B,KAAA,CAAA2B,aAAA,CAACC,SAAD,E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8CT,IAAAA,GAAG,EAAEkB,WAAAA;GApBvD,CAAA,CAAA,EAqBKJ,OAAO,gBACJhB,KAAA,CAAA2B,aAAA,CAACG,GAAD,EAAI;IACAG,SAAS,EAAEC,gBAAM,CAACK,IADlB;AAEAR,IAAAA,OAAO,EAAC,MAFR;AAGAS,IAAAA,WAAW,EAAErC,OAAO,KAAK,UAAZ,GAAyB,SAAzB,GAAqC,QAHlD;AAIAsC,IAAAA,UAAU,EAAEtC,OAAO,KAAK,UAAZ,GAAyB,QAAzB,GAAoC,SAAA;AAJhD,GAAJ,EAMKa,OANL,CADI,GASJ,IA9BR,CAdR,CADJ,CAAA;AAkDH,CA9EiB;;;;"}
1
+ {"version":3,"file":"text-field.js","sources":["../../src/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\nimport { useMergeRefs } from 'use-callback-ref'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ninterface TextFieldProps\n extends Omit<FieldComponentProps<HTMLInputElement>, 'type'>,\n BaseFieldVariantProps {\n type?: TextFieldType\n startSlot?: React.ReactElement | string | number\n endSlot?: React.ReactElement | string | number\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n variant = 'default',\n id,\n label,\n value,\n auxiliaryLabel,\n message,\n tone,\n type = 'text',\n maxWidth,\n maxLength,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n startSlot,\n endSlot,\n onChange: originalOnChange,\n ...props\n },\n ref,\n) {\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n function handleClick(event: React.MouseEvent) {\n if (event.currentTarget === combinedRef.current) return\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n value={value}\n auxiliaryLabel={auxiliaryLabel}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n maxLength={maxLength}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {({ onChange, ...extraProps }) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.inputWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n props.readOnly ? styles.readOnly : null,\n ]}\n onClick={handleClick}\n >\n {startSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n marginLeft={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n >\n {startSlot}\n </Box>\n ) : null}\n <input\n {...props}\n {...extraProps}\n type={type}\n ref={combinedRef}\n maxLength={maxLength}\n onChange={(event) => {\n originalOnChange?.(event)\n onChange?.(event)\n }}\n />\n {endSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n marginLeft={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n >\n {endSlot}\n </Box>\n ) : null}\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","forwardRef","ref","variant","id","label","value","auxiliaryLabel","message","tone","type","maxWidth","maxLength","hidden","ariaDescribedBy","startSlot","endSlot","onChange","originalOnChange","props","internalRef","useRef","combinedRef","useMergeRefs","handleClick","event","currentTarget","current","focus","createElement","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","error","bordered","readOnly","onClick","slot","marginRight","marginLeft"],"mappings":";;;;;;;;;AAiBMA,MAAAA,SAAS,gBAAGC,KAAK,CAACC,UAAN,CAAmD,SAASF,SAAT,CAmBjEG,IAAAA,EAAAA,GAnBiE,EAmB9D;EAAA,IAlBH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,KAJJ;IAKIC,cALJ;IAMIC,OANJ;IAOIC,IAPJ;A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QAAQ,CAAGQ,KAAH,CAAR,CAAA;AACH,OAAA;KA9BT,CAAA,CAAA,EAgCKT,OAAO,gBACJhB,KAAA,CAAA6B,aAAA,CAACG,GAAD,EAAI;MACAG,SAAS,EAAEC,gBAAM,CAACM,IADlB;AAEAT,MAAAA,OAAO,EAAC,MAFR;AAGAU,MAAAA,WAAW,EAAExC,OAAO,KAAK,UAAZ,GAAyB,SAAzB,GAAqC,QAHlD;AAIAyC,MAAAA,UAAU,EAAEzC,OAAO,KAAK,UAAZ,GAAyB,QAAzB,GAAoC,SAAA;AAJhD,KAAJ,EAMKa,OANL,CADI,GASJ,IAzCR,CADH,CAAA;AAAA,GAbL,CADJ,CAAA;AA6DH,CA1FiB;;;;"}
@@ -1,4 +1,4 @@
1
- var modules_aaf25250 = {"inputWrapper":"dea25485","bordered":"_80b6b376","error":"_1a32867a","slot":"dbbd207e"};
1
+ var modules_aaf25250 = {"inputWrapper":"f2de4e8d","readOnly":"ee26e40c","bordered":"_3afb1a56","error":"f3ff9f57","slot":"_3eb7b0ef"};
2
2
 
3
3
  export { modules_aaf25250 as default };
4
4
  //# sourceMappingURL=text-field.module.css.js.map
@@ -9,12 +9,14 @@ function Tooltip({
9
9
  position = 'top',
10
10
  gapSize = 3,
11
11
  withArrow = false,
12
+ showTimeout = 500,
13
+ hideTimeout = 100,
12
14
  exceptionallySetClassName
13
15
  }) {
14
16
  const tooltip = useTooltipStore({
15
17
  placement: position,
16
- showTimeout: 500,
17
- hideTimeout: 100
18
+ showTimeout,
19
+ hideTimeout
18
20
  });
19
21
  const isOpen = tooltip.useState('open');
20
22
  const child = React.Children.only(children);
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n useTooltipStore,\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n} from '@ariakit/react'\nimport { Box } from '../box'\n\nimport type { TooltipStoreState } from '@ariakit/react'\n\nimport styles from './tooltip.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface TooltipProps extends ObfuscatedClassName {\n /**\n * The element that triggers the tooltip. Generally a button or link.\n *\n * It should be an interactive element accessible both via mouse and keyboard interactions.\n */\n children: React.ReactNode\n\n /**\n * The content to show in the tooltip.\n *\n * It can be rich content provided via React elements, or string content. It should not include\n * interactive elements inside it. This includes links or buttons.\n *\n * You can provide a function instead of the content itself. In this case, the function should\n * return the desired content. This is useful if the content is expensive to generate. It can\n * also be useful if the content dynamically changes often, so every time you trigger the\n * tooltip the content may have changed (e.g. if you show a ticking time clock in the tooltip).\n *\n * The trigger element will be associated to this content via `aria-describedby`. This means\n * that the tooltip content will be read by assistive technologies such as screen readers. It\n * will likely read this content right after reading the trigger element label.\n */\n content: React.ReactNode | (() => React.ReactNode)\n\n /**\n * How to place the tooltip relative to its trigger element.\n *\n * The possible values are \"top\", \"bottom\", \"left\", \"right\". Additionally, any of these values\n * can be combined with `-start` or `-end` for even more control. For instance `top-start` will\n * place the tooltip at the top, but with the start (e.g. left) side of the toolip and the\n * trigger aligned. If neither `-start` or `-end` are provided, the tooltip is centered along\n * the vertical or horizontal axis with the trigger.\n *\n * The position is enforced whenever possible, but tooltips can appear in different positions\n * if the specified one would make the tooltip intersect with the viewport edges.\n *\n * @default 'top'\n */\n position?: TooltipStoreState['placement']\n\n /**\n * The separation (in pixels) between the trigger element and the tooltip.\n * @default 3\n */\n gapSize?: number\n\n /**\n * Whether to show an arrow-like element attached to the tooltip, and pointing towards the\n * trigger element.\n * @default false\n */\n withArrow?: boolean\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n withArrow = false,\n exceptionallySetClassName,\n}: TooltipProps) {\n const tooltip = useTooltipStore({ placement: position, showTimeout: 500, hideTimeout: 100 })\n const isOpen = tooltip.useState('open')\n\n const child = React.Children.only(\n children as React.FunctionComponentElement<JSX.IntrinsicElements['div']> | null,\n )\n\n if (!child) {\n return child\n }\n\n if (typeof child.ref === 'string') {\n throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded')\n }\n\n return (\n <>\n <TooltipAnchor render={child} store={tooltip} ref={child.ref} />\n {isOpen && content ? (\n <AriakitTooltip\n store={tooltip}\n gutter={gapSize}\n render={\n <Box\n className={[styles.tooltip, exceptionallySetClassName]}\n background=\"toast\"\n borderRadius=\"standard\"\n paddingX=\"small\"\n paddingY=\"xsmall\"\n maxWidth=\"medium\"\n width=\"fitContent\"\n overflow=\"hidden\"\n textAlign=\"center\"\n />\n }\n >\n {withArrow ? <TooltipArrow /> : null}\n {typeof content === 'function' ? content() : content}\n </AriakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n"],"names":["Tooltip","children","content","position","gapSize","withArrow","exceptionallySetClassName","tooltip","useTooltipStore","placement","showTimeout","hideTimeout","isOpen","useState","child","React","Children","only","ref","Error","createElement","Fragment","TooltipAnchor","render","store","AriakitTooltip","gutter","Box","className","styles","background","borderRadius","paddingX","paddingY","maxWidth","width","overflow","textAlign","TooltipArrow"],"mappings":";;;;;AAsEA,SAASA,OAAT,CAAiB;EACbC,QADa;EAEbC,OAFa;AAGbC,EAAAA,QAAQ,GAAG,KAHE;AAIbC,EAAAA,OAAO,GAAG,CAJG;AAKbC,EAAAA,SAAS,GAAG,KALC;AAMbC,EAAAA,yBAAAA;AANa,CAAjB,EAOe;EACX,MAAMC,OAAO,GAAGC,eAAe,CAAC;AAAEC,IAAAA,SAAS,EAAEN,QAAb;AAAuBO,IAAAA,WAAW,EAAE,GAApC;AAAyCC,IAAAA,WAAW,EAAE,GAAA;AAAtD,GAAD,CAA/B,CAAA;AACA,EAAA,MAAMC,MAAM,GAAGL,OAAO,CAACM,QAAR,CAAiB,MAAjB,CAAf,CAAA;EAEA,MAAMC,KAAK,GAAGC,KAAK,CAACC,QAAN,CAAeC,IAAf,CACVhB,QADU,CAAd,CAAA;;EAIA,IAAI,CAACa,KAAL,EAAY;AACR,IAAA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sourcesContent":["import * as React from 'react'\n\nimport {\n useTooltipStore,\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n} from '@ariakit/react'\nimport { Box } from '../box'\n\nimport type { TooltipStoreState } from '@ariakit/react'\n\nimport styles from './tooltip.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface TooltipProps extends ObfuscatedClassName {\n /**\n * The element that triggers the tooltip. Generally a button or link.\n *\n * It should be an interactive element accessible both via mouse and keyboard interactions.\n */\n children: React.ReactNode\n\n /**\n * The content to show in the tooltip.\n *\n * It can be rich content provided via React elements, or string content. It should not include\n * interactive elements inside it. This includes links or buttons.\n *\n * You can provide a function instead of the content itself. In this case, the function should\n * return the desired content. This is useful if the content is expensive to generate. It can\n * also be useful if the content dynamically changes often, so every time you trigger the\n * tooltip the content may have changed (e.g. if you show a ticking time clock in the tooltip).\n *\n * The trigger element will be associated to this content via `aria-describedby`. This means\n * that the tooltip content will be read by assistive technologies such as screen readers. It\n * will likely read this content right after reading the trigger element label.\n */\n content: React.ReactNode | (() => React.ReactNode)\n\n /**\n * How to place the tooltip relative to its trigger element.\n *\n * The possible values are \"top\", \"bottom\", \"left\", \"right\". Additionally, any of these values\n * can be combined with `-start` or `-end` for even more control. For instance `top-start` will\n * place the tooltip at the top, but with the start (e.g. left) side of the toolip and the\n * trigger aligned. If neither `-start` or `-end` are provided, the tooltip is centered along\n * the vertical or horizontal axis with the trigger.\n *\n * The position is enforced whenever possible, but tooltips can appear in different positions\n * if the specified one would make the tooltip intersect with the viewport edges.\n *\n * @default 'top'\n */\n position?: TooltipStoreState['placement']\n\n /**\n * The separation (in pixels) between the trigger element and the tooltip.\n * @default 3\n */\n gapSize?: number\n\n /**\n * Whether to show an arrow-like element attached to the tooltip, and pointing towards the\n * trigger element.\n * @default false\n */\n withArrow?: boolean\n\n /**\n * The amount of time in milliseconds to wait before showing the tooltip\n * @default 500\n */\n showTimeout?: number\n\n /**\n * The amount of time in milliseconds to wait before hiding the tooltip\n * @default 100\n */\n hideTimeout?: number\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n withArrow = false,\n showTimeout = 500,\n hideTimeout = 100,\n exceptionallySetClassName,\n}: TooltipProps) {\n const tooltip = useTooltipStore({ placement: position, showTimeout, hideTimeout })\n const isOpen = tooltip.useState('open')\n\n const child = React.Children.only(\n children as React.FunctionComponentElement<JSX.IntrinsicElements['div']> | null,\n )\n\n if (!child) {\n return child\n }\n\n if (typeof child.ref === 'string') {\n throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded')\n }\n\n return (\n <>\n <TooltipAnchor render={child} store={tooltip} ref={child.ref} />\n {isOpen && content ? (\n <AriakitTooltip\n store={tooltip}\n gutter={gapSize}\n render={\n <Box\n className={[styles.tooltip, exceptionallySetClassName]}\n background=\"toast\"\n borderRadius=\"standard\"\n paddingX=\"small\"\n paddingY=\"xsmall\"\n maxWidth=\"medium\"\n width=\"fitContent\"\n overflow=\"hidden\"\n textAlign=\"center\"\n />\n }\n >\n {withArrow ? <TooltipArrow /> : null}\n {typeof content === 'function' ? content() : content}\n </AriakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n"],"names":["Tooltip","children","content","position","gapSize","withArrow","showTimeout","hideTimeout","exceptionallySetClassName","tooltip","useTooltipStore","placement","isOpen","useState","child","React","Children","only","ref","Error","createElement","Fragment","TooltipAnchor","render","store","AriakitTooltip","gutter","Box","className","styles","background","borderRadius","paddingX","paddingY","maxWidth","width","overflow","textAlign","TooltipArrow"],"mappings":";;;;;AAkFA,SAASA,OAAT,CAAiB;EACbC,QADa;EAEbC,OAFa;AAGbC,EAAAA,QAAQ,GAAG,KAHE;AAIbC,EAAAA,OAAO,GAAG,CAJG;AAKbC,EAAAA,SAAS,GAAG,KALC;AAMbC,EAAAA,WAAW,GAAG,GAND;AAObC,EAAAA,WAAW,GAAG,GAPD;AAQbC,EAAAA,yBAAAA;AARa,CAAjB,EASe;E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Q,EAAC,QART;AASAC,MAAAA,SAAS,EAAC,QAAA;KATd,CAAA;GAJR,EAiBKhC,SAAS,gBAAGU,KAAA,CAAAK,aAAA,CAACkB,YAAD,EAAgB,IAAhB,CAAH,GAAsB,IAjBpC,EAkBK,OAAOpC,OAAP,KAAmB,UAAnB,GAAgCA,OAAO,EAAvC,GAA4CA,OAlBjD,CADH,GAqBG,IAvBR,CADJ,CAAA;AA2BH;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../utils/responsive-props.js"),l=require("../box/box.js"),r=require("../button/button.js"),n=require("../columns/columns.js"),a=require("../icons/alert-icon.js"),o=require("../icons/close-icon.js"),u=require("./alert.module.css.js");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(l){if("default"!==l){var r=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,r.get?r:{enumerable:!0,get:function(){return e[l]}})}})),t.default=e,t}var s=i(e);exports.Alert=function({id:e,children:i,tone:c,closeLabel:m,onClose:d}){return s.createElement(l.Box,{id:e,role:"alert","aria-live":"polite",borderRadius:"full",className:[u.default.container,t.getClassNames(u.default,"tone",c)]},s.createElement(n.Columns,{space:"small",alignY:"center"},s.createElement(n.Column,{width:"content"},s.createElement(a.AlertIcon,{tone:c,className:u.default.icon})),s.createElement(n.Column,null,s.createElement(l.Box,{paddingY:"xsmall",paddingRight:null!=d&&null!=m?void 0:"small"},i)),null!=d&&null!=m?s.createElement(n.Column,{width:"content"},s.createElement(r.Button,{variant:"quaternary",size:"small",onClick:d,"aria-label":m,icon:s.createElement(o.CloseIcon,null),style:{"--reactist-btn-hover-fill":"transparent"}})):null))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../utils/responsive-props.js"),l=require("../box/box.js"),n=require("../button/button.js"),r=require("../columns/columns.js"),a=require("../icons/alert-icon.js"),o=require("../icons/close-icon.js"),s=require("./alert.module.css.js");function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(l){if("default"!==l){var n=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,n.get?n:{enumerable:!0,get:function(){return e[l]}})}})),t.default=e,t}var i=c(e);exports.Alert=function({id:e,children:c,tone:u,closeLabel:m,onClose:d}){return i.createElement(l.Box,{id:e,role:"alert","aria-live":"polite",borderRadius:"full",className:[s.default.container,t.getClassNames(s.default,"tone",u)]},i.createElement(r.Columns,{space:"small",alignY:"center"},i.createElement(r.Column,{width:"content"},i.createElement(a.AlertIcon,{tone:u,className:s.default.icon})),i.createElement(r.Column,null,i.createElement(l.Box,{paddingY:"xsmall",paddingRight:null!=d&&null!=m?void 0:"small",display:"flex",alignItems:"center",className:s.default.content},c)),null!=d&&null!=m?i.createElement(r.Column,{width:"content"},i.createElement(n.IconButton,{variant:"quaternary",size:"small",onClick:d,"aria-label":m,icon:i.createElement(o.CloseIcon,null),style:{"--reactist-btn-hover-fill":"transparent"}})):null))};
2
2
  //# sourceMappingURL=alert.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.js","sources":["../../src/alert/alert.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport { Button } from '../button'\nimport { Columns, Column } from '../columns'\n\nimport { AlertIcon } from '../icons/alert-icon'\nimport { CloseIcon } from '../icons/close-icon'\n\nimport styles from './alert.module.css'\n\nimport type { AlertTone } from '../utils/common-types'\n\ntype AllOrNone<T> = T | { [K in keyof T]?: never }\n\ntype AlertCloseProps = AllOrNone<{\n closeLabel: string\n onClose: () => void\n}>\n\ntype AlertProps = {\n id?: string\n children: React.ReactNode\n tone: AlertTone\n} & AlertCloseProps\n\nfunction Alert({ id, children, tone, closeLabel, onClose }: AlertProps) {\n return (\n <Box\n id={id}\n role=\"alert\"\n aria-live=\"polite\"\n borderRadius=\"full\"\n className={[styles.container, getClassNames(styles, 'tone', tone)]}\n >\n <Columns space=\"small\" alignY=\"center\">\n <Column width=\"content\">\n <AlertIcon tone={tone} className={styles.icon} />\n </Column>\n <Column>\n <Box\n paddingY=\"xsmall\"\n paddingRight={onClose != null && closeLabel != null ? undefined : 'small'}\n >\n {children}\n </Box>\n </Column>\n {onClose != null && closeLabel != null ? (\n <Column width=\"content\">\n <Button\n variant=\"quaternary\"\n size=\"small\"\n onClick={onClose}\n aria-label={closeLabel}\n icon={<CloseIcon />}\n style={{\n // @ts-expect-error not sure how to make TypeScript understand custom CSS properties\n '--reactist-btn-hover-fill': 'transparent',\n }}\n />\n </Column>\n ) : null}\n </Columns>\n </Box>\n )\n}\n\nexport { Alert }\nexport type { AlertProps }\n"],"names":["id","children","tone","closeLabel","onClose","React","createElement","Box","role","aria-live","borderRadius","className","styles","container","getClassNames","Columns","space","alignY","Column","width","AlertIcon","icon","paddingY","paddingRight","undefined","Button","variant","size","onClick","aria-label","CloseIcon","style","--reactist-btn-hover-fill"],"mappings":"wnBA0BA,UAAeA,GAAEA,EAAFC,SAAMA,EAANC,KAAgBA,EAAhBC,WAAsBA,EAAtBC,QAAkCA,IAC7C,OACIC,EAAAC,cAACC,MAAG,CACAP,GAAIA,EACJQ,KAAK,QACKC,YAAA,SACVC,aAAa,OACbC,UAAW,CAACC,EAAAA,QAAOC,UAAWC,EAAaA,cAACF,UAAQ,OAAQV,KAE5DG,EAACC,cAAAS,WAAQC,MAAM,QAAQC,OAAO,UAC1BZ,EAAAC,cAACY,SAAM,CAACC,MAAM,WACVd,EAAAC,cAACc,YAAS,CAAClB,KAAMA,EAAMS,UAAWC,EAAM,QAACS,QAE7ChB,EAAAC,cAACY,EAAAA,OAAM,KACHb,EAACC,cAAAC,MACG,CAAAe,SAAS,SACTC,aAAyB,MAAXnB,GAAiC,MAAdD,OAAqBqB,EAAY,SAEjEvB,IAGG,MAAXG,GAAiC,MAAdD,EAChBE,EAACC,cAAAY,SAAO,CAAAC,MAAM,WACVd,EAACC,cAAAmB,UACGC,QAAQ,aACRC,KAAK,QACLC,QAASxB,EAAOyB,aACJ1B,EACZkB,KAAMhB,gBAACyB,EAAAA,UAAS,MAChBC,MAAO,CAEHC,4BAA6B,kBAIzC"}
1
+ {"version":3,"file":"alert.js","sources":["../../src/alert/alert.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport { IconButton } from '../button'\nimport { Columns, Column } from '../columns'\n\nimport { AlertIcon } from '../icons/alert-icon'\nimport { CloseIcon } from '../icons/close-icon'\n\nimport styles from './alert.module.css'\n\nimport type { AlertTone } from '../utils/common-types'\n\ntype AllOrNone<T> = T | { [K in keyof T]?: never }\n\ntype AlertCloseProps = AllOrNone<{\n closeLabel: string\n onClose: () => void\n}>\n\ntype AlertProps = {\n id?: string\n children: React.ReactNode\n tone: AlertTone\n} & AlertCloseProps\n\nfunction Alert({ id, children, tone, closeLabel, onClose }: AlertProps) {\n return (\n <Box\n id={id}\n role=\"alert\"\n aria-live=\"polite\"\n borderRadius=\"full\"\n className={[styles.container, getClassNames(styles, 'tone', tone)]}\n >\n <Columns space=\"small\" alignY=\"center\">\n <Column width=\"content\">\n <AlertIcon tone={tone} className={styles.icon} />\n </Column>\n <Column>\n <Box\n paddingY=\"xsmall\"\n paddingRight={onClose != null && closeLabel != null ? undefined : 'small'}\n display=\"flex\"\n alignItems=\"center\"\n className={styles.content}\n >\n {children}\n </Box>\n </Column>\n {onClose != null && closeLabel != null ? (\n <Column width=\"content\">\n <IconButton\n variant=\"quaternary\"\n size=\"small\"\n onClick={onClose}\n aria-label={closeLabel}\n icon={<CloseIcon />}\n style={{\n // @ts-expect-error not sure how to make TypeScript understand custom CSS properties\n '--reactist-btn-hover-fill': 'transparent',\n }}\n />\n </Column>\n ) : null}\n </Columns>\n </Box>\n )\n}\n\nexport { Alert }\nexport type { AlertProps }\n"],"names":["id","children","tone","closeLabel","onClose","React","createElement","Box","role","aria-live","borderRadius","className","styles","container","getClassNames","Columns","space","alignY","Column","width","AlertIcon","icon","paddingY","paddingRight","undefined","display","alignItems","content","IconButton","variant","size","onClick","aria-label","CloseIcon","style","--reactist-btn-hover-fill"],"mappings":"wnBA0BA,UAAeA,GAAEA,EAAFC,SAAMA,EAANC,KAAgBA,EAAhBC,WAAsBA,EAAtBC,QAAkCA,IAC7C,OACIC,EAAAC,cAACC,MAAG,CACAP,GAAIA,EACJQ,KAAK,QACKC,YAAA,SACVC,aAAa,OACbC,UAAW,CAACC,EAAAA,QAAOC,UAAWC,EAAaA,cAACF,UAAQ,OAAQV,KAE5DG,EAACC,cAAAS,WAAQC,MAAM,QAAQC,OAAO,UAC1BZ,EAAAC,cAACY,SAAM,CAACC,MAAM,WACVd,EAAAC,cAACc,YAAS,CAAClB,KAAMA,EAAMS,UAAWC,EAAM,QAACS,QAE7ChB,EAAAC,cAACY,EAAAA,OAAM,KACHb,EAAAC,cAACC,MACG,CAAAe,SAAS,SACTC,aAAyB,MAAXnB,GAAiC,MAAdD,OAAqBqB,EAAY,QAClEC,QAAQ,OACRC,WAAW,SACXf,UAAWC,EAAM,QAACe,SAEjB1B,IAGG,MAAXG,GAAiC,MAAdD,EAChBE,EAACC,cAAAY,SAAO,CAAAC,MAAM,WACVd,EAACC,cAAAsB,cACGC,QAAQ,aACRC,KAAK,QACLC,QAAS3B,EAAO4B,aACJ7B,EACZkB,KAAMhB,gBAAC4B,EAAAA,UAAS,MAChBC,MAAO,CAEHC,4BAA6B,kBAIzC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default={container:"_51a84fb3","tone-info":"_5649104a",icon:"_79fa06e2","tone-positive":"c67632e4","tone-caution":"_654ff216","tone-critical":"b1ee4ff1"};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default={container:"d6be7fe9",content:"ad8ace2f",icon:"ab71a9dc","tone-info":"_043941a6","tone-positive":"f34b89d4","tone-caution":"a069ea07","tone-critical":"e505aabb"};
2
2
  //# sourceMappingURL=alert.module.css.js.map