@doist/reactist 25.2.0 → 26.0.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 (50) hide show
  1. package/dist/reactist.cjs.development.js +198 -112
  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/base-field/base-field.js +98 -46
  6. package/es/base-field/base-field.js.map +1 -1
  7. package/es/base-field/base-field.module.css.js +1 -1
  8. package/es/password-field/password-field.js +5 -4
  9. package/es/password-field/password-field.js.map +1 -1
  10. package/es/select-field/select-field.js +9 -7
  11. package/es/select-field/select-field.js.map +1 -1
  12. package/es/switch-field/switch-field.js +10 -8
  13. package/es/switch-field/switch-field.js.map +1 -1
  14. package/es/text-area/text-area.js +34 -17
  15. package/es/text-area/text-area.js.map +1 -1
  16. package/es/text-area/text-area.module.css.js +1 -1
  17. package/es/text-field/text-field.js +39 -25
  18. package/es/text-field/text-field.js.map +1 -1
  19. package/es/text-field/text-field.module.css.js +1 -1
  20. package/lib/base-field/base-field.d.ts +17 -34
  21. package/lib/base-field/base-field.js +1 -1
  22. package/lib/base-field/base-field.js.map +1 -1
  23. package/lib/base-field/base-field.module.css.js +1 -1
  24. package/lib/password-field/password-field.d.ts +1 -0
  25. package/lib/password-field/password-field.js +1 -1
  26. package/lib/password-field/password-field.js.map +1 -1
  27. package/lib/select-field/select-field.js +1 -1
  28. package/lib/select-field/select-field.js.map +1 -1
  29. package/lib/switch-field/switch-field.d.ts +1 -1
  30. package/lib/switch-field/switch-field.js +1 -1
  31. package/lib/switch-field/switch-field.js.map +1 -1
  32. package/lib/text-area/text-area.d.ts +9 -1
  33. package/lib/text-area/text-area.js +1 -1
  34. package/lib/text-area/text-area.js.map +1 -1
  35. package/lib/text-area/text-area.module.css.js +1 -1
  36. package/lib/text-field/text-field.js +1 -1
  37. package/lib/text-field/text-field.js.map +1 -1
  38. package/lib/text-field/text-field.module.css.js +1 -1
  39. package/package.json +1 -1
  40. package/styles/base-field.css +3 -2
  41. package/styles/base-field.module.css.css +1 -1
  42. package/styles/index.css +3 -2
  43. package/styles/password-field.css +3 -2
  44. package/styles/reactist.css +4 -4
  45. package/styles/select-field.css +2 -1
  46. package/styles/switch-field.css +2 -1
  47. package/styles/text-area.css +3 -2
  48. package/styles/text-area.module.css.css +1 -1
  49. package/styles/text-field.css +3 -2
  50. package/styles/text-field.module.css.css +1 -1
@@ -6,28 +6,12 @@ import { Text } from '../text/text.js';
6
6
  import modules_540a88ff from './base-field.module.css.js';
7
7
  import { Stack } from '../stack/stack.js';
8
8
  import { Spinner } from '../spinner/spinner.js';
9
+ import { Columns, Column } from '../columns/columns.js';
9
10
 
10
- function FieldHint(props) {
11
- return /*#__PURE__*/React.createElement(Text, _objectSpread2({
12
- as: "p",
13
- tone: "secondary",
14
- size: "copy"
15
- }, props));
16
- }
11
+ const MAX_LENGTH_THRESHOLD = 10;
17
12
 
18
- function MessageIcon(props) {
19
- return /*#__PURE__*/React.createElement("svg", _objectSpread2({
20
- width: "16",
21
- height: "16",
22
- viewBox: "0 0 16 16",
23
- fill: "none",
24
- xmlns: "http://www.w3.org/2000/svg"
25
- }, props), /*#__PURE__*/React.createElement("path", {
26
- fillRule: "evenodd",
27
- clipRule: "evenodd",
28
- d: "M8 2.5C4.96243 2.5 2.5 4.96243 2.5 8C2.5 11.0376 4.96243 13.5 8 13.5C11.0376 13.5 13.5 11.0376 13.5 8C13.5 4.96243 11.0376 2.5 8 2.5ZM1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8ZM8.66667 10.3333C8.66667 10.7015 8.36819 11 8 11C7.63181 11 7.33333 10.7015 7.33333 10.3333C7.33333 9.96514 7.63181 9.66667 8 9.66667C8.36819 9.66667 8.66667 9.96514 8.66667 10.3333ZM8.65766 5.65766C8.65766 5.29445 8.36322 5 8 5C7.99087 5.00008 7.98631 5.00013 7.98175 5.00025C7.97719 5.00038 7.97263 5.00059 7.96352 5.00101C7.60086 5.02116 7.3232 5.33149 7.34335 5.69415L7.50077 8.52774C7.53575 9.15742 8.46425 9.15742 8.49923 8.52774L8.65665 5.69415C8.65707 5.68503 8.65728 5.68047 8.65741 5.67591C8.65754 5.67135 8.65758 5.66679 8.65766 5.65766Z",
29
- fill: "currentColor"
30
- }));
13
+ function fieldToneToTextTone(tone) {
14
+ return tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'secondary';
31
15
  }
32
16
 
33
17
  function FieldMessage({
@@ -35,55 +19,117 @@ function FieldMessage({
35
19
  children,
36
20
  tone
37
21
  }) {
38
- const textTone = tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'normal';
39
22
  return /*#__PURE__*/React.createElement(Text, {
40
23
  as: "p",
41
- tone: textTone,
24
+ tone: fieldToneToTextTone(tone),
42
25
  size: "copy",
43
26
  id: id
44
- }, /*#__PURE__*/React.createElement(Box, {
27
+ }, tone === 'loading' ? /*#__PURE__*/React.createElement(Box, {
45
28
  as: "span",
46
29
  marginRight: "xsmall",
47
30
  display: "inlineFlex",
48
- className: modules_540a88ff.messageIcon
49
- }, tone === 'loading' ? /*#__PURE__*/React.createElement(Spinner, {
31
+ className: modules_540a88ff.loadingIcon
32
+ }, /*#__PURE__*/React.createElement(Spinner, {
50
33
  size: 16
51
- }) : /*#__PURE__*/React.createElement(MessageIcon, {
52
- "aria-hidden": true
53
- })), children);
34
+ })) : null, children);
35
+ }
36
+
37
+ function FieldCharacterCount({
38
+ children,
39
+ tone
40
+ }) {
41
+ return /*#__PURE__*/React.createElement(Text, {
42
+ tone: fieldToneToTextTone(tone),
43
+ size: "copy"
44
+ }, children);
45
+ }
46
+
47
+ function validateInputLength({
48
+ value,
49
+ maxLength
50
+ }) {
51
+ if (!maxLength) {
52
+ return {
53
+ count: null,
54
+ tone: 'neutral'
55
+ };
56
+ }
57
+
58
+ const currentLength = String(value || '').length;
59
+ const isNearMaxLength = maxLength - currentLength <= MAX_LENGTH_THRESHOLD;
60
+ return {
61
+ count: currentLength + "/" + maxLength,
62
+ tone: isNearMaxLength ? 'error' : 'neutral'
63
+ };
54
64
  }
55
65
 
56
66
  function BaseField({
57
67
  variant = 'default',
58
68
  label,
59
- secondaryLabel,
69
+ value,
60
70
  auxiliaryLabel,
61
- hint,
62
71
  message,
63
72
  tone = 'neutral',
64
73
  className,
65
74
  children,
66
75
  maxWidth,
76
+ maxLength,
67
77
  hidden,
68
78
  'aria-describedby': originalAriaDescribedBy,
69
79
  id: originalId
70
80
  }) {
71
81
  const id = useId(originalId);
72
- const hintId = useId();
73
82
  const messageId = useId();
74
- const ariaDescribedBy = originalAriaDescribedBy != null ? originalAriaDescribedBy : [message ? messageId : null, hintId].filter(Boolean).join(' ');
75
- const childrenProps = {
83
+ const inputLength = validateInputLength({
84
+ value,
85
+ maxLength
86
+ });
87
+ const [characterCount, setCharacterCount] = React.useState(inputLength.count);
88
+ const [characterCountTone, setCharacterCountTone] = React.useState(inputLength.tone);
89
+ const ariaDescribedBy = originalAriaDescribedBy != null ? originalAriaDescribedBy : message ? messageId : null;
90
+
91
+ const childrenProps = _objectSpread2(_objectSpread2({
76
92
  id,
77
- 'aria-describedby': ariaDescribedBy,
78
- 'aria-invalid': tone === 'error' ? true : undefined
79
- };
93
+ value
94
+ }, ariaDescribedBy ? {
95
+ 'aria-describedby': ariaDescribedBy
96
+ } : {}), {}, {
97
+ 'aria-invalid': tone === 'error' ? true : undefined,
98
+
99
+ onChange(event) {
100
+ if (!maxLength) {
101
+ return;
102
+ }
103
+
104
+ const inputLength = validateInputLength({
105
+ value: event.currentTarget.value,
106
+ maxLength
107
+ });
108
+ setCharacterCount(inputLength.count);
109
+ setCharacterCountTone(inputLength.tone);
110
+ }
111
+
112
+ });
113
+
114
+ React.useEffect(function updateCharacterCountOnPropChange() {
115
+ if (!maxLength) {
116
+ return;
117
+ }
118
+
119
+ const inputLength = validateInputLength({
120
+ value,
121
+ maxLength
122
+ });
123
+ setCharacterCount(inputLength.count);
124
+ setCharacterCountTone(inputLength.tone);
125
+ }, [maxLength, value]);
80
126
  return /*#__PURE__*/React.createElement(Stack, {
81
- space: "small",
127
+ space: "xsmall",
82
128
  hidden: hidden
83
129
  }, /*#__PURE__*/React.createElement(Box, {
84
130
  className: [className, modules_540a88ff.container, tone === 'error' ? modules_540a88ff.error : null, variant === 'bordered' ? modules_540a88ff.bordered : null],
85
131
  maxWidth: maxWidth
86
- }, label || secondaryLabel || auxiliaryLabel ? /*#__PURE__*/React.createElement(Box, {
132
+ }, label || auxiliaryLabel ? /*#__PURE__*/React.createElement(Box, {
87
133
  as: "span",
88
134
  display: "flex",
89
135
  justifyContent: "spaceBetween",
@@ -94,18 +140,24 @@ function BaseField({
94
140
  htmlFor: id
95
141
  }, label ? /*#__PURE__*/React.createElement("span", {
96
142
  className: modules_540a88ff.primaryLabel
97
- }, label) : null, secondaryLabel ? /*#__PURE__*/React.createElement("span", {
98
- className: modules_540a88ff.secondaryLabel
99
- }, "\u00A0(", secondaryLabel, ")") : null), auxiliaryLabel ? /*#__PURE__*/React.createElement(Box, {
143
+ }, label) : null), auxiliaryLabel ? /*#__PURE__*/React.createElement(Box, {
100
144
  className: modules_540a88ff.auxiliaryLabel,
101
145
  paddingLeft: "small"
102
- }, auxiliaryLabel) : null) : null, children(childrenProps)), message ? /*#__PURE__*/React.createElement(FieldMessage, {
146
+ }, auxiliaryLabel) : null) : null, children(childrenProps)), message || characterCount ? /*#__PURE__*/React.createElement(Columns, {
147
+ align: "right",
148
+ space: "small",
149
+ maxWidth: maxWidth
150
+ }, message ? /*#__PURE__*/React.createElement(Column, {
151
+ width: "auto"
152
+ }, /*#__PURE__*/React.createElement(FieldMessage, {
103
153
  id: messageId,
104
154
  tone: tone
105
- }, message) : null, hint ? /*#__PURE__*/React.createElement(FieldHint, {
106
- id: hintId
107
- }, hint) : null);
155
+ }, message)) : null, characterCount ? /*#__PURE__*/React.createElement(Column, {
156
+ width: "content"
157
+ }, /*#__PURE__*/React.createElement(FieldCharacterCount, {
158
+ tone: characterCountTone
159
+ }, characterCount)) : null) : null);
108
160
  }
109
161
 
110
- export { BaseField, FieldHint, FieldMessage };
162
+ export { BaseField, FieldMessage };
111
163
  //# sourceMappingURL=base-field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-field.js","sources":["../../src/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../utils/common-helpers'\nimport { Text } from '../text'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\nimport type { WithEnhancedClassName } from '../utils/common-types'\nimport { Spinner } from '../spinner'\n\ntype FieldHintProps = {\n id: string\n children: React.ReactNode\n}\n\nfunction FieldHint(props: FieldHintProps) {\n return <Text as=\"p\" tone=\"secondary\" size=\"copy\" {...props} />\n}\n\nfunction MessageIcon(props: React.SVGProps<SVGSVGElement>) {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M8 2.5C4.96243 2.5 2.5 4.96243 2.5 8C2.5 11.0376 4.96243 13.5 8 13.5C11.0376 13.5 13.5 11.0376 13.5 8C13.5 4.96243 11.0376 2.5 8 2.5ZM1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8ZM8.66667 10.3333C8.66667 10.7015 8.36819 11 8 11C7.63181 11 7.33333 10.7015 7.33333 10.3333C7.33333 9.96514 7.63181 9.66667 8 9.66667C8.36819 9.66667 8.66667 9.96514 8.66667 10.3333ZM8.65766 5.65766C8.65766 5.29445 8.36322 5 8 5C7.99087 5.00008 7.98631 5.00013 7.98175 5.00025C7.97719 5.00038 7.97263 5.00059 7.96352 5.00101C7.60086 5.02116 7.3232 5.33149 7.34335 5.69415L7.50077 8.52774C7.53575 9.15742 8.46425 9.15742 8.49923 8.52774L8.65665 5.69415C8.65707 5.68503 8.65728 5.68047 8.65741 5.67591C8.65754 5.67135 8.65758 5.66679 8.65766 5.65766Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\ntype FieldTone = 'neutral' | 'success' | 'error' | 'loading'\n\ntype FieldMessageProps = FieldHintProps & {\n tone: FieldTone\n}\n\nfunction FieldMessage({ id, children, tone }: FieldMessageProps) {\n const textTone = tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'normal'\n return (\n <Text as=\"p\" tone={textTone} size=\"copy\" id={id}>\n <Box as=\"span\" marginRight=\"xsmall\" display=\"inlineFlex\" className={styles.messageIcon}>\n {tone === 'loading' ? <Spinner size={16} /> : <MessageIcon aria-hidden />}\n </Box>\n {children}\n </Text>\n )\n}\n\n//\n// BaseField\n//\n\ntype ChildrenRenderProps = {\n id: string\n 'aria-describedby'?: string\n 'aria-invalid'?: true\n}\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldVariant = 'default' | 'bordered'\ntype BaseFieldVariantProps = {\n /**\n * Provides alternative visual layouts or modes that the field can be rendered in.\n *\n * Namely, there are two variants supported:\n *\n * - the default one\n * - a \"bordered\" variant, where the border of the field surrounds also the labels, instead\n * of just surrounding the actual field element\n *\n * In both cases, the message and description texts for the field lie outside the bordered\n * area.\n */\n variant?: BaseFieldVariant\n}\n\ntype BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * This prop is not optional. Consumers of field components must be explicit about not\n * wanting a label by passing `label=\"\"` or `label={null}`. In those situations, consumers\n * should make sure that fields are properly labelled semantically by other means (e.g using\n * `aria-labelledby`, or rendering a `<label />` element referencing the field by id).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see BaseFieldProps['secondaryLabel']\n * @see BaseFieldProps['auxiliaryLabel']\n */\n label: React.ReactNode\n\n /**\n * An optional secondary label for this field element. It is combined with the `label` to\n * form the field's entire accessible name (unless the field label is overriden by using\n * `aria-label` or `aria-labelledby`).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see BaseFieldProps['label']\n * @see BaseFieldProps['auxiliaryLabel']\n */\n secondaryLabel?: React.ReactNode\n\n /**\n * An optional extra element to be placed to the right of the main and secondary labels.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see BaseFieldProps['label']\n * @see BaseFieldProps['secondaryLabel']\n */\n auxiliaryLabel?: React.ReactNode\n\n /**\n * A message associated with the field. It is rendered below the field, and with an\n * appearance that conveys the tone of the field (e.g. coloured red for errors, green for\n * success, etc).\n *\n * The message element is associated to the field via the `aria-describedby` attribute. If a\n * `hint` is provided, both the hint and the message are associated as the field accessible\n * description.\n *\n * In the future, when `aria-errormessage` gets better user agent support, we should use it\n * to associate the filed with a message when tone is `\"error\"`.\n *\n * @see BaseFieldProps['tone']\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid\n */\n message?: React.ReactNode\n\n /**\n * The tone with which the message, if any, is presented.\n *\n * If the tone is `\"error\"`, the field border turns red, and the message, if any, is also\n * red.\n *\n * When the tone is `\"loading\"`, it is recommended that you also disable the field. However,\n * this is not enforced by the component. It is only a recommendation.\n *\n * @see BaseFieldProps['message']\n * @see BaseFieldProps['hint']\n */\n tone?: FieldTone\n\n /**\n * A hint or help-like content associated as the accessible description of the field. It is\n * generally rendered below it, and with a visual style that reduces its prominence (i.e.\n * as secondary text).\n *\n * It sets the `aria-describedby` attribute pointing to the element that holds the hint\n * content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby\n */\n hint?: React.ReactNode\n\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: ChildrenRenderProps) => React.ReactNode\n }\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<\n BaseFieldProps,\n 'children' | 'className' | 'variant'\n> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\nfunction BaseField({\n variant = 'default',\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone = 'neutral',\n className,\n children,\n maxWidth,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n}: BaseFieldProps & BaseFieldVariantProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const hintId = useId()\n const messageId = useId()\n\n const ariaDescribedBy =\n originalAriaDescribedBy ?? [message ? messageId : null, hintId].filter(Boolean).join(' ')\n\n const childrenProps: ChildrenRenderProps = {\n id,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': tone === 'error' ? true : undefined,\n }\n\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n className,\n styles.container,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {label || secondaryLabel || auxiliaryLabel ? (\n <Box\n as=\"span\"\n display=\"flex\"\n justifyContent=\"spaceBetween\"\n alignItems=\"flexEnd\"\n >\n <Text\n size={variant === 'bordered' ? 'caption' : 'body'}\n as=\"label\"\n htmlFor={id}\n >\n {label ? <span className={styles.primaryLabel}>{label}</span> : null}\n {secondaryLabel ? (\n <span className={styles.secondaryLabel}>\n &nbsp;({secondaryLabel})\n </span>\n ) : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n ) : null}\n {children(childrenProps)}\n </Box>\n {message ? (\n <FieldMessage id={messageId} tone={tone}>\n {message}\n </FieldMessage>\n ) : null}\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldHint, FieldMessage }\nexport type { BaseFieldVariant, BaseFieldVariantProps, FieldComponentProps }\n"],"names":["FieldHint","props","React","Text","_objectSpread","as","tone","size","MessageIcon","width","height","viewBox","fill","xmlns","createElement","fillRule","clipRule","d","FieldMessage","id","children","textTone","Box","marginRight","display","className","styles","messageIcon","Spinner","BaseField","variant","label","secondaryLabel","auxiliaryLabel","hint","message","maxWidth","hidden","originalAriaDescribedBy","originalId","useId","hintId","messageId","ariaDescribedBy","filter","Boolean","join","childrenProps","undefined","Stack","space","container","error","bordered","justifyContent","alignItems","htmlFor","primaryLabel","paddingLeft"],"mappings":";;;;;;;;;AAeA,SAASA,SAAT,CAAmBC,KAAnB,EAAwC;AACpC,EAAA,oBAAOC,mBAAA,CAACC,IAAD,EAAAC,cAAA,CAAA;AAAMC,IAAAA,EAAE,EAAC,GAAT;AAAaC,IAAAA,IAAI,EAAC,WAAlB;AAA8BC,IAAAA,IAAI,EAAC,MAAA;AAAnC,GAAA,EAA8CN,KAA9C,CAAP,CAAA,CAAA;AACH,CAAA;;AAED,SAASO,WAAT,CAAqBP,KAArB,EAAyD;AACrD,EAAA,oBACIC,mBAAA,MAAA,EAAAE,cAAA,CAAA;AACIK,IAAAA,KAAK,EAAC,IADV;AAEIC,IAAAA,MAAM,EAAC,IAFX;AAGIC,IAAAA,OAAO,EAAC,WAHZ;AAIIC,IAAAA,IAAI,EAAC,MAJT;AAKIC,IAAAA,KAAK,EAAC,4BAAA;AALV,GAAA,EAMQZ,KANR,CAQIC,eAAAA,KAAA,CAAAY,aAAA,CAAA,MAAA,EAAA;AACIC,IAAAA,QAAQ,EAAC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eAMIrD,KAAC,CAAAY,aAAD,CAACX,IAAD;AACII,IAAAA,IAAI,EAAEuB,OAAO,KAAK,UAAZ,GAAyB,SAAzB,GAAqC;AAC3CzB,IAAAA,EAAE,EAAC;AACHmD,IAAAA,OAAO,EAAErC,EAAAA;GAHb,EAKKY,KAAK,gBAAG7B,KAAA,CAAAY,aAAA,CAAA,MAAA,EAAA;IAAMW,SAAS,EAAEC,gBAAM,CAAC+B,YAAAA;AAAxB,GAAA,EAAuC1B,KAAvC,CAAH,GAA0D,IALpE,EAMKC,cAAc,gBACX9B,mBAAA,OAAA;IAAMuB,SAAS,EAAEC,gBAAM,CAACM,cAAAA;GAAxB,WAAA,EACYA,cADZ,EAEO,GAFP,CADW,GAIX,IAVR,CANJ,EAkBKC,cAAc,gBACX/B,KAAC,CAAAY,aAAD,CAACQ,GAAD,EAAK;IAAAG,SAAS,EAAEC,gBAAM,CAACO,cAAlB;AAAkCyB,IAAAA,WAAW,EAAC,OAAA;GAAnD,EACKzB,cADL,CADW,GAIX,IAtBR,CADH,GAyBG,IAlCR,EAmCKb,QAAQ,CAAC2B,aAAD,CAnCb,CADJ,EAsCKZ,OAAO,gBACJjC,mBAAA,CAACgB,YAAD,EAAa;AAACC,IAAAA,EAAE,EAAEuB,SAAL;AAAgBpC,IAAAA,IAAI,EAAEA,IAAAA;AAAtB,GAAb,EACK6B,OADL,CADI,GAIJ,IA1CR,EA2CKD,IAAI,gBAAGhC,mBAAA,CAACF,SAAD,EAAU;AAACmB,IAAAA,EAAE,EAAEsB,MAAAA;AAAL,GAAV,EAAwBP,IAAxB,CAAH,GAA+C,IA3CxD,CADJ,CAAA;AA+CH;;;;"}
1
+ {"version":3,"file":"base-field.js","sources":["../../src/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../utils/common-helpers'\nimport { Text } from '../text'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\nimport type { WithEnhancedClassName } from '../utils/common-types'\nimport { Spinner } from '../spinner'\nimport { Column, Columns } from '../columns'\n\nconst MAX_LENGTH_THRESHOLD = 10\n\ntype FieldTone = 'neutral' | 'success' | 'error' | 'loading'\n\ntype FieldMessageProps = {\n id: string\n children: React.ReactNode\n tone: FieldTone\n}\n\nfunction fieldToneToTextTone(tone: FieldTone) {\n return tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'secondary'\n}\n\nfunction FieldMessage({ id, children, tone }: FieldMessageProps) {\n return (\n <Text as=\"p\" tone={fieldToneToTextTone(tone)} size=\"copy\" id={id}>\n {tone === 'loading' ? (\n <Box\n as=\"span\"\n marginRight=\"xsmall\"\n display=\"inlineFlex\"\n className={styles.loadingIcon}\n >\n <Spinner size={16} />\n </Box>\n ) : null}\n {children}\n </Text>\n )\n}\n\ntype FieldCharacterCountProps = {\n children: React.ReactNode\n tone: FieldTone\n}\n\nfunction FieldCharacterCount({ children, tone }: FieldCharacterCountProps) {\n return (\n <Text tone={fieldToneToTextTone(tone)} size=\"copy\">\n {children}\n </Text>\n )\n}\n\ntype ValidateInputLengthProps = {\n value?: React.InputHTMLAttributes<unknown>['value']\n maxLength?: number\n}\n\ntype ValidateInputLengthResult = {\n count: string | null\n tone: FieldTone\n}\n\nfunction validateInputLength({\n value,\n maxLength,\n}: ValidateInputLengthProps): ValidateInputLengthResult {\n if (!maxLength) {\n return {\n count: null,\n tone: 'neutral',\n }\n }\n\n const currentLength = String(value || '').length\n const isNearMaxLength = maxLength - currentLength <= MAX_LENGTH_THRESHOLD\n\n return {\n count: `${currentLength}/${maxLength}`,\n tone: isNearMaxLength ? 'error' : 'neutral',\n }\n}\n\n//\n// BaseField\n//\n\ntype ChildrenRenderProps = {\n id: string\n value?: React.InputHTMLAttributes<unknown>['value']\n 'aria-describedby'?: string\n 'aria-invalid'?: true\n onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>\n}\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldVariant = 'default' | 'bordered'\ntype BaseFieldVariantProps = {\n /**\n * Provides alternative visual layouts or modes that the field can be rendered in.\n *\n * Namely, there are two variants supported:\n *\n * - the default one\n * - a \"bordered\" variant, where the border of the field surrounds also the labels, instead\n * of just surrounding the actual field element\n *\n * In both cases, the message and description texts for the field lie outside the bordered\n * area.\n */\n variant?: BaseFieldVariant\n}\n\ntype BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'maxLength' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * This prop is not optional. Consumers of field components must be explicit about not\n * wanting a label by passing `label=\"\"` or `label={null}`. In those situations, consumers\n * should make sure that fields are properly labelled semantically by other means (e.g using\n * `aria-labelledby`, or rendering a `<label />` element referencing the field by id).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see BaseFieldProps['auxiliaryLabel']\n */\n label: React.ReactNode\n\n /**\n * The initial value for this field element.\n *\n * This prop is used to calculate the character count for the initial value, and is then\n * passed to the underlying child element.\n */\n value?: React.InputHTMLAttributes<unknown>['value']\n\n /**\n * An optional extra element to be placed to the right of the main label.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see BaseFieldProps['label']\n *\n * @deprecated The usage of this element is discouraged given that it was removed from the\n * latest form field spec revision.\n */\n auxiliaryLabel?: React.ReactNode\n\n /**\n * A message associated with the field. It is rendered below the field, and with an\n * appearance that conveys the tone of the field (e.g. coloured red for errors, green for\n * success, etc).\n *\n * The message element is associated to the field via the `aria-describedby` attribute.\n *\n * In the future, when `aria-errormessage` gets better user agent support, we should use it\n * to associate the filed with a message when tone is `\"error\"`.\n *\n * @see BaseFieldProps['tone']\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid\n */\n message?: React.ReactNode\n\n /**\n * The tone with which the message, if any, is presented.\n *\n * If the tone is `\"error\"`, the field border turns red, and the message, if any, is also\n * red.\n *\n * When the tone is `\"loading\"`, it is recommended that you also disable the field. However,\n * this is not enforced by the component. It is only a recommendation.\n *\n * @see BaseFieldProps['message']\n * @see BaseFieldProps['hint']\n */\n tone?: FieldTone\n\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: ChildrenRenderProps) => React.ReactNode\n }\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<\n BaseFieldProps,\n 'children' | 'className' | 'fieldRef' | 'variant'\n> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\nfunction BaseField({\n variant = 'default',\n label,\n value,\n auxiliaryLabel,\n message,\n tone = 'neutral',\n className,\n children,\n maxWidth,\n maxLength,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n}: BaseFieldProps & BaseFieldVariantProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const messageId = useId()\n\n const inputLength = validateInputLength({ value, maxLength })\n\n const [characterCount, setCharacterCount] = React.useState<string | null>(inputLength.count)\n const [characterCountTone, setCharacterCountTone] = React.useState<FieldTone>(inputLength.tone)\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (message ? messageId : null)\n\n const childrenProps: ChildrenRenderProps = {\n id,\n value,\n ...(ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}),\n 'aria-invalid': tone === 'error' ? true : undefined,\n onChange(event) {\n if (!maxLength) {\n return\n }\n\n const inputLength = validateInputLength({\n value: event.currentTarget.value,\n maxLength,\n })\n\n setCharacterCount(inputLength.count)\n setCharacterCountTone(inputLength.tone)\n },\n }\n\n React.useEffect(\n function updateCharacterCountOnPropChange() {\n if (!maxLength) {\n return\n }\n\n const inputLength = validateInputLength({\n value,\n maxLength,\n })\n\n setCharacterCount(inputLength.count)\n setCharacterCountTone(inputLength.tone)\n },\n [maxLength, value],\n )\n\n return (\n <Stack space=\"xsmall\" hidden={hidden}>\n <Box\n className={[\n className,\n styles.container,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {label || auxiliaryLabel ? (\n <Box\n as=\"span\"\n display=\"flex\"\n justifyContent=\"spaceBetween\"\n alignItems=\"flexEnd\"\n >\n <Text\n size={variant === 'bordered' ? 'caption' : 'body'}\n as=\"label\"\n htmlFor={id}\n >\n {label ? <span className={styles.primaryLabel}>{label}</span> : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n ) : null}\n {children(childrenProps)}\n </Box>\n {message || characterCount ? (\n <Columns align=\"right\" space=\"small\" maxWidth={maxWidth}>\n {message ? (\n <Column width=\"auto\">\n <FieldMessage id={messageId} tone={tone}>\n {message}\n </FieldMessage>\n </Column>\n ) : null}\n {characterCount ? (\n <Column width=\"content\">\n <FieldCharacterCount tone={characterCountTone}>\n {characterCount}\n </FieldCharacterCount>\n </Column>\n ) : null}\n </Columns>\n ) : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldMessage }\nexport type { BaseFieldVariant, BaseFieldVariantProps, FieldComponentProps }\n"],"names":["MAX_LENGTH_THRESHOLD","fieldToneToTextTone","tone","FieldMessage","id","children","React","Text","as","size","createElement","Box","marginRight","display","className","styles","loadingIcon","Spinner","FieldCharacterCount","validateInputLength","value","maxLength","count","currentLength","String","length","isNearMaxLength","BaseField","variant","label","auxiliaryLabel","message","maxWidth","hidden","originalAriaDescribedBy","originalId","useId","messageId","inputLength","characterCount","setCharacterCount","useState","characterCountTone","setCharacterCountTone","ariaDescribedBy","childrenProps","_objectSpread","undefined","onChange","event","currentTarget","useEffect","updateCharacterCountOnPropChange","Stack","space","container","error","bordered","justifyContent","alignItems","htmlFor","primaryLabel","paddingLeft","Columns","align","Column","width"],"mappings":";;;;;;;;;;AAWA,MAAMA,oBAAoB,GAAG,EAA7B,CAAA;;AAUA,SAASC,mBAAT,CAA6BC,IAA7B,EAA4C;AACxC,EAAA,OAAOA,IAAI,KAAK,OAAT,GAAmB,QAAnB,GAA8BA,IAAI,KAAK,SAAT,GAAqB,UAArB,GAAkC,WAAvE,CAAA;AACH,CAAA;;AAED,SAASC,YAAT,CAAsB;EAAEC,EAAF;EAAMC,QAAN;AAAgBH,EAAAA,IAAAA;AAAhB,CAAtB,EAA+D;AAC3D,EAAA,oBACII,mBAAA,CAACC,IAAD,EAAK;AAACC,IAAAA,EAAE,EAAC,GAAJ;AAAQN,IAAAA,IAAI,EAAED,mBAAmB,CAACC,IAAD,CAAjC;AAAyCO,IAAAA,IAAI,EAAC,MAA9C;AAAqDL,IAAAA,EAAE,EAAEA,EAAAA;GAA9D,EACKF,IAAI,KAAK,SAAT,gBACGI,KAAC,CAAAI,aAAD,CAACC,GAAD,EACI;AAAAH,IAAAA,EAAE,EAAC,MAAH;AACAI,IAAAA,WAAW,EAAC,QADZ;AAEAC,IAAAA,OAAO,EAAC,YAFR;IAGAC,SAAS,EAAEC,gBAAM,CAACC,WAAAA;AAHlB,GADJ,eAMIV,KAAC,CAAAI,aAAD,CAACO,OAAD,EAAS;AAAAR,IAAAA,IAAI,EAAE,EAAA;AAAN,GAAT,CANJ,CADH,GASG,IAVR,EAWKJ,QAXL,CADJ,CAAA;AAeH,CAAA;;AAOD,SAASa,mBAAT,CAA6B;EAAEb,QAAF;AAAYH,EAAAA,IAAAA;AAAZ,CAA7B,EAAyE;AACrE,EAAA,oBACII,KAAC,CAAAI,aAAD,CAACH,IAAD;AAAML,IAAAA,IAAI,EAAED,mBAAmB,CAACC,IAAD;AAAQO,IAAAA,IAAI,EAAC,MAAA;GAA5C,EACKJ,QADL,CADJ,CAAA;AAKH,CAAA;;AAYD,SAASc,mB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,EAiCKd,OAAO,IAAIQ,cAAX,gBACGjC,mBAAA,CAACyD,OAAD,EAAQ;AAACC,IAAAA,KAAK,EAAC,OAAP;AAAeV,IAAAA,KAAK,EAAC,OAArB;AAA6BtB,IAAAA,QAAQ,EAAEA,QAAAA;GAA/C,EACKD,OAAO,gBACJzB,mBAAA,CAAC2D,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,MAAA;AAAP,GAAP,eACI5D,KAAA,CAAAI,aAAA,CAACP,YAAD,EAAc;AAAAC,IAAAA,EAAE,EAAEiC,SAAJ;AAAenC,IAAAA,IAAI,EAAEA,IAAAA;AAArB,GAAd,EACK6B,OADL,CADJ,CADI,GAMJ,IAPR,EAQKQ,cAAc,gBACXjC,mBAAA,CAAC2D,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,SAAA;AAAP,GAAP,eACI5D,KAAC,CAAAI,aAAD,CAACQ,mBAAD;AAAqBhB,IAAAA,IAAI,EAAEwC,kBAAAA;GAA3B,EACKH,cADL,CADJ,CADW,GAMX,IAdR,CADH,GAiBG,IAlDR,CADJ,CAAA;AAsDH;;;;"}
@@ -1,4 +1,4 @@
1
- var modules_540a88ff = {"container":"_7acdc928","auxiliaryLabel":"_815bad88","bordered":"e35886fe","error":"_6c7b5dc8","primaryLabel":"ec74af87","secondaryLabel":"_6db0ec44","messageIcon":"_05c35af8"};
1
+ var modules_540a88ff = {"container":"d5ff04da","auxiliaryLabel":"_8d2b52f1","bordered":"_49c37b27","error":"_922ff337","primaryLabel":"af23c791","loadingIcon":"_75edcef6"};
2
2
 
3
3
  export { modules_540a88ff as default };
4
4
  //# sourceMappingURL=base-field.module.css.js.map
@@ -5,10 +5,11 @@ import { PasswordHiddenIcon } from '../icons/password-hidden-icon.js';
5
5
  import { TextField } from '../text-field/text-field.js';
6
6
  import { IconButton } from '../button/button.js';
7
7
 
8
- const _excluded = ["togglePasswordLabel"];
8
+ const _excluded = ["togglePasswordLabel", "endSlot"];
9
9
  const PasswordField = /*#__PURE__*/React.forwardRef(function PasswordField(_ref, ref) {
10
10
  let {
11
- togglePasswordLabel = 'Toggle password visibility'
11
+ togglePasswordLabel = 'Toggle password visibility',
12
+ endSlot
12
13
  } = _ref,
13
14
  props = _objectWithoutProperties(_ref, _excluded);
14
15
 
@@ -18,14 +19,14 @@ const PasswordField = /*#__PURE__*/React.forwardRef(function PasswordField(_ref,
18
19
  ref: ref,
19
20
  // @ts-expect-error TextField does not support type="password", so we override the type check here
20
21
  type: isPasswordVisible ? 'text' : 'password',
21
- endSlot: /*#__PURE__*/React.createElement(IconButton, {
22
+ endSlot: /*#__PURE__*/React.createElement(React.Fragment, null, endSlot, /*#__PURE__*/React.createElement(IconButton, {
22
23
  variant: "quaternary",
23
24
  icon: /*#__PURE__*/React.createElement(Icon, {
24
25
  "aria-hidden": true
25
26
  }),
26
27
  "aria-label": togglePasswordLabel,
27
28
  onClick: () => setPasswordVisible(v => !v)
28
- })
29
+ }))
29
30
  }));
30
31
  });
31
32
 
@@ -1 +1 @@
1
- {"version":3,"file":"password-field.js","sources":["../../src/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport { TextField, TextFieldProps } from '../text-field'\nimport { IconButton } from '../button'\n\nimport type { BaseFieldVariantProps } from '../base-field'\n\ninterface PasswordFieldProps\n extends Omit<TextFieldProps, 'type' | 'startSlot' | 'endSlot'>,\n BaseFieldVariantProps {\n togglePasswordLabel?: string\n}\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n { togglePasswordLabel = 'Toggle password visibility', ...props },\n ref,\n) {\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n const Icon = isPasswordVisible ? PasswordVisibleIcon : PasswordHiddenIcon\n return (\n <TextField\n {...props}\n ref={ref}\n // @ts-expect-error TextField does not support type=\"password\", so we override the type check here\n type={isPasswordVisible ? 'text' : 'password'}\n endSlot={\n <IconButton\n variant=\"quaternary\"\n icon={<Icon aria-hidden />}\n aria-label={togglePasswordLabel}\n onClick={() => setPasswordVisible((v) => !v)}\n />\n }\n />\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","forwardRef","ref","togglePasswordLabel","props","isPasswordVisible","setPasswordVisible","useState","Icon","PasswordVisibleIcon","PasswordHiddenIcon","TextField","type","endSlot","IconButton","variant","icon","createElement","onClick","v"],"mappings":";;;;;;;;AAgBMA,MAAAA,aAAa,gBAAGC,KAAK,CAACC,UAAN,CAAuD,SAASF,aAAT,CAEzEG,IAAAA,EAAAA,GAFyE,EAEtE;EAAA,IADH;AAAEC,IAAAA,mBAAmB,GAAG,4BAAA;GACrB,GAAA,IAAA;AAAA,MADsDC,KACtD,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EAEH,MAAM,CAACC,iBAAD,EAAoBC,kBAApB,CAAA,GAA0CN,KAAK,CAACO,QAAN,CAAe,KAAf,CAAhD,CAAA;AACA,EAAA,MAAMC,IAAI,GAAGH,iBAAiB,GAAGI,mBAAH,GAAyBC,kBAAvD,CAAA;AACA,EAAA,oBACIV,mBAAA,CAACW,SAAD,oCACQP,KADR,CAAA,EAAA,EAAA,EAAA;AAEIF,IAAAA,GAAG,EAAEA,GAFT;AAGI;AACAU,IAAAA,IAAI,EAAEP,iBAAiB,GAAG,MAAH,GAAY,UAJvC;AAKIQ,IAAAA,OAAO,eACHb,mBAAA,CAACc,UAAD,EAAW;AACPC,MAAAA,OAAO,EAAC,YADD;AAEPC,MAAAA,IAAI,eAAEhB,KAAA,CAAAiB,aAAA,CAACT,IAAD,EAAoB;QAAA,aAAA,EAAA,IAAA;AAAA,OAApB,CAFC;AAEmB,MAAA,YAAA,EACdL,mBAHL;AAIPe,MAAAA,OAAO,EAAE,MAAMZ,kBAAkB,CAAEa,CAAD,IAAO,CAACA,CAAT,CAAA;KAJrC,CAAA;GAPZ,CAAA,CAAA,CAAA;AAgBH,CAtBqB;;;;"}
1
+ {"version":3,"file":"password-field.js","sources":["../../src/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport { TextField, TextFieldProps } from '../text-field'\nimport { IconButton } from '../button'\n\nimport type { BaseFieldVariantProps } from '../base-field'\n\ninterface PasswordFieldProps\n extends Omit<TextFieldProps, 'type' | 'startSlot' | 'endSlot'>,\n BaseFieldVariantProps {\n togglePasswordLabel?: string\n endSlot?: React.ReactElement | string | number\n}\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n { togglePasswordLabel = 'Toggle password visibility', endSlot, ...props },\n ref,\n) {\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n const Icon = isPasswordVisible ? PasswordVisibleIcon : PasswordHiddenIcon\n return (\n <TextField\n {...props}\n ref={ref}\n // @ts-expect-error TextField does not support type=\"password\", so we override the type check here\n type={isPasswordVisible ? 'text' : 'password'}\n endSlot={\n <>\n {endSlot}\n <IconButton\n variant=\"quaternary\"\n icon={<Icon aria-hidden />}\n aria-label={togglePasswordLabel}\n onClick={() => setPasswordVisible((v) => !v)}\n />\n </>\n }\n />\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","forwardRef","ref","togglePasswordLabel","endSlot","props","isPasswordVisible","setPasswordVisible","useState","Icon","PasswordVisibleIcon","PasswordHiddenIcon","TextField","type","createElement","Fragment","IconButton","variant","icon","onClick","v"],"mappings":";;;;;;;;AAiBMA,MAAAA,aAAa,gBAAGC,KAAK,CAACC,UAAN,CAAuD,SAASF,aAAT,CAEzEG,IAAAA,EAAAA,GAFyE,EAEtE;EAAA,IADH;AAAEC,IAAAA,mBAAmB,GAAG,4BAAxB;AAAsDC,IAAAA,OAAAA;GACnD,GAAA,IAAA;AAAA,MAD+DC,KAC/D,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EAEH,MAAM,CAACC,iBAAD,EAAoBC,kBAApB,CAAA,GAA0CP,KAAK,CAACQ,QAAN,CAAe,KAAf,CAAhD,CAAA;AACA,EAAA,MAAMC,IAAI,GAAGH,iBAAiB,GAAGI,mBAAH,GAAyBC,kBAAvD,CAAA;AACA,EAAA,oBACIX,mBAAA,CAACY,SAAD,oCACQP,KADR,CAAA,EAAA,EAAA,EAAA;AAEIH,IAAAA,GAAG,EAAEA,GAFT;AAGI;AACAW,IAAAA,IAAI,EAAEP,iBAAiB,GAAG,MAAH,GAAY,UAJvC;AAKIF,IAAAA,OAAO,eACHJ,KAAA,CAAAc,aAAA,CAAAd,KAAA,CAAAe,QAAA,EAAA,IAAA,EACKX,OADL,eAEIJ,KAAA,CAAAc,aAAA,CAACE,UAAD,EAAW;AACPC,MAAAA,OAAO,EAAC,YADD;AAEPC,MAAAA,IAAI,eAAElB,KAAA,CAAAc,aAAA,CAACL,IAAD,EAAK;QAAA,aAAA,EAAA,IAAA;AAAA,OAAL,CAFC;AAGK,MAAA,YAAA,EAAAN,mBAHL;AAIPgB,MAAAA,OAAO,EAAE,MAAMZ,kBAAkB,CAAEa,CAAD,IAAO,CAACA,CAAT,CAAA;AAJ1B,KAAX,CAFJ,CAAA;GAPZ,CAAA,CAAA,CAAA;AAmBH,CAzBqB;;;;"}
@@ -4,21 +4,21 @@ import { BaseField } from '../base-field/base-field.js';
4
4
  import { Box } from '../box/box.js';
5
5
  import modules_1fa9b208 from './select-field.module.css.js';
6
6
 
7
- const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "children", "hidden", "aria-describedby"];
7
+ const _excluded = ["variant", "id", "label", "value", "auxiliaryLabel", "message", "tone", "maxWidth", "children", "hidden", "aria-describedby", "onChange"];
8
8
  const SelectField = /*#__PURE__*/React.forwardRef(function SelectField(_ref, ref) {
9
9
  let {
10
10
  variant = 'default',
11
11
  id,
12
12
  label,
13
- secondaryLabel,
13
+ value,
14
14
  auxiliaryLabel,
15
- hint,
16
15
  message,
17
16
  tone,
18
17
  maxWidth,
19
18
  children,
20
19
  hidden,
21
- 'aria-describedby': ariaDescribedBy
20
+ 'aria-describedby': ariaDescribedBy,
21
+ onChange: originalOnChange
22
22
  } = _ref,
23
23
  props = _objectWithoutProperties(_ref, _excluded);
24
24
 
@@ -26,9 +26,8 @@ const SelectField = /*#__PURE__*/React.forwardRef(function SelectField(_ref, ref
26
26
  variant: variant,
27
27
  id: id,
28
28
  label: label,
29
- secondaryLabel: secondaryLabel,
29
+ value: value,
30
30
  auxiliaryLabel: auxiliaryLabel,
31
- hint: hint,
32
31
  message: message,
33
32
  tone: tone,
34
33
  maxWidth: maxWidth,
@@ -38,7 +37,10 @@ const SelectField = /*#__PURE__*/React.forwardRef(function SelectField(_ref, ref
38
37
  "data-testid": "select-wrapper",
39
38
  className: [modules_1fa9b208.selectWrapper, tone === 'error' ? modules_1fa9b208.error : null, variant === 'bordered' ? modules_1fa9b208.bordered : null]
40
39
  }, /*#__PURE__*/React.createElement("select", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
41
- ref: ref
40
+ ref: ref,
41
+ onChange: event => {
42
+ originalOnChange == null ? void 0 : originalOnChange(event);
43
+ }
42
44
  }), children), /*#__PURE__*/React.createElement(SelectChevron, {
43
45
  "aria-hidden": true
44
46
  })));
@@ -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,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BACIf,KAAK,CAAAgB,aAAL,CAAK,KAAL,EAAAS,cAAA,CAAA;AAAKE,IAAAA,KAAK,EAAC,IAAX;AAAgBC,IAAAA,MAAM,EAAC,IAAvB;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,kBAAA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;"}
@@ -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;;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AAA,IAAI,CAACA,KAAK,CAACC,gBAAX,EAA6B;AACzBrB,QAAAA,UAAU,CAACoB,KAAK,CAACE,aAAN,CAAoBrB,OAArB,CAAV,CAAA;AACH,OAAA;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;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;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,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 };