@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
package/es/alert/alert.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { getClassNames } from '../utils/responsive-props.js';
3
3
  import { Box } from '../box/box.js';
4
- import { Button } from '../button/button.js';
4
+ import { IconButton } from '../button/button.js';
5
5
  import { Columns, Column } from '../columns/columns.js';
6
6
  import { AlertIcon } from '../icons/alert-icon.js';
7
7
  import { CloseIcon } from '../icons/close-icon.js';
@@ -30,10 +30,13 @@ function Alert({
30
30
  className: modules_6205a58e.icon
31
31
  })), /*#__PURE__*/React.createElement(Column, null, /*#__PURE__*/React.createElement(Box, {
32
32
  paddingY: "xsmall",
33
- paddingRight: onClose != null && closeLabel != null ? undefined : 'small'
33
+ paddingRight: onClose != null && closeLabel != null ? undefined : 'small',
34
+ display: "flex",
35
+ alignItems: "center",
36
+ className: modules_6205a58e.content
34
37
  }, children)), onClose != null && closeLabel != null ? /*#__PURE__*/React.createElement(Column, {
35
38
  width: "content"
36
- }, /*#__PURE__*/React.createElement(Button, {
39
+ }, /*#__PURE__*/React.createElement(IconButton, {
37
40
  variant: "quaternary",
38
41
  size: "small",
39
42
  onClick: onClose,
@@ -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":["Alert","id","children","tone","closeLabel","onClose","React","createElement","Box","role","borderRadius","className","styles","container","getClassNames","Columns","space","alignY","Column","width","AlertIcon","icon","paddingY","paddingRight","undefined","Button","variant","size","onClick","CloseIcon","style"],"mappings":";;;;;;;;;AA0BA,SAASA,KAAT,CAAe;EAAEC,EAAF;EAAMC,QAAN;EAAgBC,IAAhB;EAAsBC,UAAtB;AAAkCC,EAAAA,OAAAA;AAAlC,CAAf,EAAsE;AAClE,EAAA,oBACIC,KAAA,CAAAC,aAAA,CAACC,GAAD,EAAI;AACAP,IAAAA,EAAE,EAAEA,EADJ;AAEAQ,IAAAA,IAAI,EAAC,OAFL;AAGU,IAAA,WAAA,EAAA,QAHV;AAIAC,IAAAA,YAAY,EAAC,MAJb;AAKAC,IAAAA,SAAS,EAAE,CAACC,gBAAM,CAACC,SAAR,EAAmBC,aAAa,CAACF,gBAAD,EAAS,MAAT,EAAiBT,IAAjB,CAAhC,CAAA;AALX,GAAJ,eAOIG,KAAC,CAAAC,aAAD,CAACQ,OAAD;AAASC,IAAAA,KAAK,EAAC;AAAQC,IAAAA,MAAM,EAAC,QAAA;GAA9B,eACIX,KAAA,CAAAC,aAAA,CAACW,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,SAAA;AAAP,GAAP,eACIb,KAAA,CAAAC,aAAA,CAACa,SAAD,EAAU;AAACjB,IAAAA,IAAI,EAAEA,IAAP;IAAaQ,SAAS,EAAEC,gBAAM,CAACS,IAAAA;AAA/B,GAAV,CADJ,CADJ,eAIIf,KAAA,CAAAC,aAAA,CAACW,MAAD,EAAO,IAAP,eACIZ,KAAC,CAAAC,aAAD,CAACC,GAAD,EACI;AAAAc,IAAAA,QAAQ,EAAC,QAAT;IACAC,YAAY,EAAElB,OAAO,IAAI,IAAX,IAAmBD,UAAU,IAAI,IAAjC,GAAwCoB,SAAxC,GAAoD,OAAA;AADlE,GADJ,EAIKtB,QAJL,CADJ,CAJJ,EAYKG,OAAO,IAAI,IAAX,IAAmBD,UAAU,IAAI,IAAjC,gBACGE,KAAC,CAAAC,aAAD,CAACW,MAAD,EAAQ;AAAAC,IAAAA,KAAK,EAAC,SAAA;AAAN,GAAR,eACIb,KAAC,CAAAC,aAAD,CAACkB,MAAD;AACIC,IAAAA,OAAO,EAAC;AACRC,IAAAA,IAAI,EAAC;AACLC,IAAAA,OAAO,EAAEvB;AAAO,IAAA,YAAA,EACJD;IACZiB,IAAI,eAAEf,mBAAA,CAACuB,SAAD,EAAU,IAAV;AACNC,IAAAA,KAAK,EAAE;AACH;MACA,2BAA6B,EAAA,aAAA;AAF1B,KAAA;GANX,CADJ,CADH,GAcG,IA1BR,CAPJ,CADJ,CAAA;AAsCH;;;;"}
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":["Alert","id","children","tone","closeLabel","onClose","React","createElement","Box","role","borderRadius","className","styles","container","getClassNames","Columns","space","alignY","Column","width","AlertIcon","icon","paddingY","paddingRight","undefined","display","alignItems","content","IconButton","variant","size","onClick","CloseIcon","style"],"mappings":";;;;;;;;;AA0BA,SAASA,KAAT,CAAe;EAAEC,EAAF;EAAMC,QAAN;EAAgBC,IAAhB;EAAsBC,UAAtB;AAAkCC,EAAAA,OAAAA;AAAlC,CAAf,EAAsE;AAClE,EAAA,oBACIC,KAAA,CAAAC,aAAA,CAACC,GAAD,EAAI;AACAP,IAAAA,EAAE,EAAEA,EADJ;AAEAQ,IAAAA,IAAI,EAAC,OAFL;AAGU,IAAA,WAAA,EAAA,QAHV;AAIAC,IAAAA,YAAY,EAAC,MAJb;AAKAC,IAAAA,SAAS,EAAE,CAACC,gBAAM,CAACC,SAAR,EAAmBC,aAAa,CAACF,gBAAD,EAAS,MAAT,EAAiBT,IAAjB,CAAhC,CAAA;AALX,GAAJ,eAOIG,KAAC,CAAAC,aAAD,CAACQ,OAAD;AAASC,IAAAA,KAAK,EAAC;AAAQC,IAAAA,MAAM,EAAC,QAAA;GAA9B,eACIX,KAAA,CAAAC,aAAA,CAACW,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,SAAA;AAAP,GAAP,eACIb,KAAA,CAAAC,aAAA,CAACa,SAAD,EAAU;AAACjB,IAAAA,IAAI,EAAEA,IAAP;IAAaQ,SAAS,EAAEC,gBAAM,CAACS,IAAAA;AAA/B,GAAV,CADJ,CADJ,eAIIf,KAAA,CAAAC,aAAA,CAACW,MAAD,EAAO,IAAP,eACIZ,KAAA,CAAAC,aAAA,CAACC,GAAD,EACI;AAAAc,IAAAA,QAAQ,EAAC,QAAT;IACAC,YAAY,EAAElB,OAAO,IAAI,IAAX,IAAmBD,UAAU,IAAI,IAAjC,GAAwCoB,SAAxC,GAAoD,OADlE;AAEAC,IAAAA,OAAO,EAAC,MAFR;AAGAC,IAAAA,UAAU,EAAC,QAHX;IAIAf,SAAS,EAAEC,gBAAM,CAACe,OAAAA;AAJlB,GADJ,EAOKzB,QAPL,CADJ,CAJJ,EAeKG,OAAO,IAAI,IAAX,IAAmBD,UAAU,IAAI,IAAjC,gBACGE,KAAC,CAAAC,aAAD,CAACW,MAAD,EAAQ;AAAAC,IAAAA,KAAK,EAAC,SAAA;AAAN,GAAR,eACIb,KAAC,CAAAC,aAAD,CAACqB,UAAD;AACIC,IAAAA,OAAO,EAAC;AACRC,IAAAA,IAAI,EAAC;AACLC,IAAAA,OAAO,EAAE1B;AAAO,IAAA,YAAA,EACJD;IACZiB,IAAI,eAAEf,mBAAA,CAAC0B,SAAD,EAAU,IAAV;AACNC,IAAAA,KAAK,EAAE;AACH;MACA,2BAA6B,EAAA,aAAA;AAF1B,KAAA;GANX,CADJ,CADH,GAcG,IA7BR,CAPJ,CADJ,CAAA;AAyCH;;;;"}
@@ -1,4 +1,4 @@
1
- var modules_6205a58e = {"container":"_51a84fb3","tone-info":"_5649104a","icon":"_79fa06e2","tone-positive":"c67632e4","tone-caution":"_654ff216","tone-critical":"b1ee4ff1"};
1
+ var modules_6205a58e = {"container":"d6be7fe9","content":"ad8ace2f","icon":"ab71a9dc","tone-info":"_043941a6","tone-positive":"f34b89d4","tone-caution":"a069ea07","tone-critical":"e505aabb"};
2
2
 
3
3
  export { modules_6205a58e as default };
4
4
  //# sourceMappingURL=alert.module.css.js.map
@@ -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,SADb;AAEIC,IAAAA,QAAQ,EAAC,SAFb;AAGIC,IAAAA,CAAC,EAAC,gzBAHN;AAIIL,IAAAA,IAAI,EAAC,cAAA;AAJT,GAAA,CARJ,CADJ,CAAA;AAiBH,CAAA;;AAQD,SAASM,YAAT,CAAsB;EAAEC,EAAF;EAAMC,QAAN;AAAgBd,EAAAA,IAAAA;AAAhB,CAAtB,EAA+D;AAC3D,EAAA,MAAMe,QAAQ,GAAGf,IAAI,KAAK,OAAT,GAAmB,QAAnB,GAA8BA,IAAI,KAAK,SAAT,GAAqB,UAArB,GAAkC,QAAjF,CAAA;AACA,EAAA,oBACIJ,KAAC,CAAA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;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,m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,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
package/es/menu/menu.js CHANGED
@@ -6,7 +6,7 @@ import { useMenuStore, MenuButton as MenuButton$1, Role, Portal, Menu as Menu$1,
6
6
  const _excluded = ["children", "onItemSelect"],
7
7
  _excluded2 = ["exceptionallySetClassName"],
8
8
  _excluded3 = ["render"],
9
- _excluded4 = ["exceptionallySetClassName", "modal"],
9
+ _excluded4 = ["exceptionallySetClassName", "modal", "flip"],
10
10
  _excluded5 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName"],
11
11
  _excluded6 = ["label", "children", "exceptionallySetClassName"];
12
12
  const MenuContext = /*#__PURE__*/React.createContext({
@@ -15,6 +15,9 @@ const MenuContext = /*#__PURE__*/React.createContext({
15
15
  getAnchorRect: null,
16
16
  setAnchorRect: () => undefined
17
17
  });
18
+ const SubMenuContext = /*#__PURE__*/React.createContext({
19
+ isSubMenu: false
20
+ });
18
21
  /**
19
22
  * Wrapper component to control a menu. It does not render anything, only providing the state
20
23
  * management for the menu components inside it.
@@ -107,7 +110,8 @@ const ContextMenuTrigger = /*#__PURE__*/React.forwardRef(function ContextMenuTri
107
110
  const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(_ref4, ref) {
108
111
  let {
109
112
  exceptionallySetClassName,
110
- modal = true
113
+ modal = true,
114
+ flip
111
115
  } = _ref4,
112
116
  props = _objectWithoutProperties(_ref4, _excluded4);
113
117
 
@@ -120,6 +124,9 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(_ref4, ref) {
120
124
  throw new Error('MenuList must be wrapped in <Menu/>');
121
125
  }
122
126
 
127
+ const {
128
+ isSubMenu
129
+ } = React.useContext(SubMenuContext);
123
130
  const isOpen = menuStore.useState('open');
124
131
  return isOpen ? /*#__PURE__*/React.createElement(Portal, {
125
132
  preserveTabOrder: true
@@ -130,7 +137,8 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(_ref4, ref) {
130
137
  ref: ref,
131
138
  className: classNames('reactist_menulist', exceptionallySetClassName),
132
139
  getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
133
- modal: modal
140
+ modal: modal,
141
+ flip: flip != null ? flip : isSubMenu ? 'bottom' : undefined
134
142
  }))) : null;
135
143
  });
136
144
  /**
@@ -221,6 +229,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
221
229
  }, [parentMenuHide, parentMenuItemSelect, onItemSelect]);
222
230
  const [button, list] = React.Children.toArray(children);
223
231
  const buttonElement = button;
232
+ const subMenuContextValue = React.useMemo(() => ({
233
+ isSubMenu: true
234
+ }), []);
224
235
  return /*#__PURE__*/React.createElement(Menu, {
225
236
  onItemSelect: handleSubItemSelect
226
237
  }, /*#__PURE__*/React.createElement(MenuItem$1, {
@@ -228,7 +239,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
228
239
  ref: ref,
229
240
  hideOnClick: false,
230
241
  render: buttonElement
231
- }, buttonElement.props.children), list);
242
+ }, buttonElement.props.children), /*#__PURE__*/React.createElement(SubMenuContext.Provider, {
243
+ value: subMenuContextValue
244
+ }, list));
232
245
  });
233
246
  /**
234
247
  * A way to semantically group some menu items.
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","sources":["../../src/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport {\n Portal,\n MenuStore,\n MenuStoreProps,\n useMenuStore,\n MenuProps as AriakitMenuProps,\n Menu as AriakitMenu,\n MenuGroup as AriakitMenuGroup,\n MenuItem as AriakitMenuItem,\n MenuItemProps as AriakitMenuItemProps,\n MenuButton as AriakitMenuButton,\n MenuButtonProps as AriakitMenuButtonProps,\n Role,\n RoleProps,\n} from '@ariakit/react'\n\nimport './menu.less'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ntype MenuContextState = {\n menuStore: MenuStore | null\n handleItemSelect?: (value: string | null | undefined) => void\n getAnchorRect: (() => { x: number; y: number }) | null\n setAnchorRect: (rect: { x: number; y: number } | null) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>({\n menuStore: null,\n handleItemSelect: () => undefined,\n getAnchorRect: null,\n setAnchorRect: () => undefined,\n})\n\n//\n// Menu\n//\n\ninterface MenuProps extends Omit<MenuStoreProps, 'visible'> {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const [anchorRect, setAnchorRect] = React.useState<{ x: number; y: number } | null>(null)\n const getAnchorRect = React.useMemo(() => (anchorRect ? () => anchorRect : null), [anchorRect])\n const menuStore = useMenuStore({ focusLoop: true, ...props })\n\n const value: MenuContextState = React.useMemo(\n () => ({ menuStore, handleItemSelect: onItemSelect, getAnchorRect, setAnchorRect }),\n [menuStore, onItemSelect, getAnchorRect, setAnchorRect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\ninterface MenuButtonProps\n extends Omit<AriakitMenuButtonProps, 'store' | 'className' | 'as'>,\n ObfuscatedClassName {}\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = React.forwardRef<HTMLButtonElement, MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuButton must be wrapped in <Menu/>')\n }\n return (\n <AriakitMenuButton\n {...props}\n store={menuStore}\n ref={ref}\n className={classNames('reactist_menubutton', exceptionallySetClassName)}\n />\n )\n})\n\n//\n// ContextMenuTrigger\n//\n\ninterface ContextMenuTriggerProps\n extends ObfuscatedClassName,\n React.HTMLAttributes<HTMLDivElement>,\n Pick<RoleProps, 'render'> {}\n\nconst ContextMenuTrigger = React.forwardRef<HTMLDivElement, ContextMenuTriggerProps>(\n function ContextMenuTrigger({ render, ...props }, ref) {\n const { setAnchorRect, menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('ContextMenuTrigger must be wrapped in <Menu/>')\n }\n\n const handleContextMenu = React.useCallback(\n function handleContextMenu(event: React.MouseEvent) {\n event.preventDefault()\n setAnchorRect({ x: event.clientX, y: event.clientY })\n menuStore.show()\n },\n [setAnchorRect, menuStore],\n )\n\n const isOpen = menuStore.useState('open')\n React.useEffect(() => {\n if (!isOpen) setAnchorRect(null)\n }, [isOpen, setAnchorRect])\n\n return <Role.div {...props} onContextMenu={handleContextMenu} ref={ref} render={render} />\n },\n)\n\n//\n// MenuList\n//\n\ninterface MenuListProps\n extends Omit<AriakitMenuProps, 'store' | 'className'>,\n ObfuscatedClassName {}\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = React.forwardRef<HTMLDivElement, MenuListProps>(function MenuList(\n { exceptionallySetClassName, modal = true, ...props },\n ref,\n) {\n const { menuStore, getAnchorRect } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuList must be wrapped in <Menu/>')\n }\n\n const isOpen = menuStore.useState('open')\n\n return isOpen ? (\n <Portal preserveTabOrder>\n <AriakitMenu\n {...props}\n store={menuStore}\n gutter={8}\n shift={4}\n ref={ref}\n className={classNames('reactist_menulist', exceptionallySetClassName)}\n getAnchorRect={getAnchorRect ?? undefined}\n modal={modal}\n />\n </Portal>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ninterface MenuItemProps extends AriakitMenuItemProps, ObfuscatedClassName {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(function MenuItem(\n {\n value,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const { handleItemSelect, menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuItem must be wrapped in <Menu/>')\n }\n\n const { hide } = menuStore\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect?.(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <AriakitMenuItem\n {...props}\n store={menuStore}\n ref={ref}\n onClick={handleClick}\n className={exceptionallySetClassName}\n hideOnClick={false}\n >\n {children}\n </AriakitMenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLDivElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('SubMenu must be wrapped in <Menu/>')\n }\n\n const { hide: parentMenuHide } = menuStore\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value: string | null | undefined) {\n onItemSelect?.(value)\n parentMenuItemSelect?.(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n const buttonElement = button as React.ReactElement<MenuButtonProps>\n\n return (\n <Menu onItemSelect={handleSubItemSelect}>\n <AriakitMenuItem store={menuStore} ref={ref} hideOnClick={false} render={buttonElement}>\n {buttonElement.props.children}\n </AriakitMenuItem>\n {list}\n </Menu>\n )\n})\n\n//\n// MenuGroup\n//\n\ninterface MenuGroupProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'className'>,\n ObfuscatedClassName {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = React.forwardRef<HTMLDivElement, MenuGroupProps>(function MenuGroup(\n { label, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const { menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuGroup must be wrapped in <Menu/>')\n }\n\n return (\n <AriakitMenuGroup\n {...props}\n ref={ref}\n store={menuStore}\n className={exceptionallySetClassName}\n >\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </AriakitMenuGroup>\n )\n})\n\nexport { ContextMenuTrigger, Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuButtonProps, MenuListProps, MenuItemProps, MenuGroupProps }\n"],"names":["MenuContext","React","createContext","menuStore","handleItemSelect","undefined","getAnchorRect","setAnchorRect","Menu","children","onItemSelect","props","anchorRect","useState","useMemo","useMenuStore","_objectSpread","focusLoop","value","createElement","Provider","MenuButton","forwardRef","ref","exceptionallySetClassName","useContext","Error","AriakitMenuButton","store","className","classNames","ContextMenuTrigger","render","handleContextMenu","useCallback","event","preventDefault","x","clientX","y","clientY","show","isOpen","useEffect","Role","div","onContextMenu","MenuList","modal","Portal","preserveTabOrder","AriakitMenu","gutter","shift","MenuItem","onSelect","hideOnSelect","onClick","hide","handleClick","onSelectResult","defaultPrevented","shouldClose","AriakitMenuItem","hideOnClick","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","button","list","Children","toArray","buttonElement","MenuGroup","label","AriakitMenuGroup","role"],"mappings":";;;;;;;;;;;AA6BA,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAN,CAAsC;AACtDC,EAAAA,SAAS,EAAE,IAD2C;EAEtDC,gBAAgB,EAAE,MAAMC,SAF8B;AAGtDC,EAAAA,aAAa,EAAE,IAHuC;AAItDC,EAAAA,aAAa,EAAE,MAAMF,SAAAA;AAJiC,CAAtC,CAApB,CAAA;AA4BA;;;AAGG;;AACH,SAASG,IAAT,CAA6D,IAAA,EAAA;EAAA,IAA/C;IAAEC,QAAF;AAAYC,IAAAA,YAAAA;GAAmC,GAAA,IAAA;AAAA,MAAlBC,KAAkB,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EACzD,MAAM,CAACC,UAAD,EAAaL,aAAb,CAAA,GAA8BN,KAAK,CAACY,QAAN,CAAgD,IAAhD,CAApC,CAAA;AACA,EAAA,MAAMP,aAAa,GAAGL,KAAK,CAACa,OAAN,CAAc,MAAOF,UAAU,GAAG,MAAMA,UAAT,GAAsB,IAArD,EAA4D,CAACA,UAAD,CAA5D,CAAtB,CAAA;EACA,MAAMT,SAAS,GAAGY,YAAY,CAAAC,cAAA,CAAA;AAAGC,IAAAA,SAAS,EAAE,IAAA;AAAd,GAAA,EAAuBN,KAAvB,CAA9B,CAAA,CAAA;AAEA,EAAA,MAAMO,KAAK,GAAqBjB,KAAK,CAACa,OAAN,CAC5B,OAAO;IAAEX,SAAF;AAAaC,IAAAA,gBAAgB,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EACK8C,KADL,CADE,GAIF,IAVR,EAWKlE,QAXL,CADJ,CAAA;AAeH,CAxBiB;;;;"}
1
+ {"version":3,"file":"menu.js","sources":["../../src/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport {\n Portal,\n MenuStore,\n MenuStoreProps,\n useMenuStore,\n MenuProps as AriakitMenuProps,\n Menu as AriakitMenu,\n MenuGroup as AriakitMenuGroup,\n MenuItem as AriakitMenuItem,\n MenuItemProps as AriakitMenuItemProps,\n MenuButton as AriakitMenuButton,\n MenuButtonProps as AriakitMenuButtonProps,\n Role,\n RoleProps,\n} from '@ariakit/react'\n\nimport './menu.less'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ntype MenuContextState = {\n menuStore: MenuStore | null\n handleItemSelect?: (value: string | null | undefined) => void\n getAnchorRect: (() => { x: number; y: number }) | null\n setAnchorRect: (rect: { x: number; y: number } | null) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>({\n menuStore: null,\n handleItemSelect: () => undefined,\n getAnchorRect: null,\n setAnchorRect: () => undefined,\n})\n\nconst SubMenuContext = React.createContext<{ isSubMenu: boolean }>({ isSubMenu: false })\n\n//\n// Menu\n//\n\ninterface MenuProps extends Omit<MenuStoreProps, 'visible'> {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const [anchorRect, setAnchorRect] = React.useState<{ x: number; y: number } | null>(null)\n const getAnchorRect = React.useMemo(() => (anchorRect ? () => anchorRect : null), [anchorRect])\n const menuStore = useMenuStore({ focusLoop: true, ...props })\n\n const value: MenuContextState = React.useMemo(\n () => ({ menuStore, handleItemSelect: onItemSelect, getAnchorRect, setAnchorRect }),\n [menuStore, onItemSelect, getAnchorRect, setAnchorRect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\ninterface MenuButtonProps\n extends Omit<AriakitMenuButtonProps, 'store' | 'className' | 'as'>,\n ObfuscatedClassName {}\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = React.forwardRef<HTMLButtonElement, MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuButton must be wrapped in <Menu/>')\n }\n return (\n <AriakitMenuButton\n {...props}\n store={menuStore}\n ref={ref}\n className={classNames('reactist_menubutton', exceptionallySetClassName)}\n />\n )\n})\n\n//\n// ContextMenuTrigger\n//\n\ninterface ContextMenuTriggerProps\n extends ObfuscatedClassName,\n React.HTMLAttributes<HTMLDivElement>,\n Pick<RoleProps, 'render'> {}\n\nconst ContextMenuTrigger = React.forwardRef<HTMLDivElement, ContextMenuTriggerProps>(\n function ContextMenuTrigger({ render, ...props }, ref) {\n const { setAnchorRect, menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('ContextMenuTrigger must be wrapped in <Menu/>')\n }\n\n const handleContextMenu = React.useCallback(\n function handleContextMenu(event: React.MouseEvent) {\n event.preventDefault()\n setAnchorRect({ x: event.clientX, y: event.clientY })\n menuStore.show()\n },\n [setAnchorRect, menuStore],\n )\n\n const isOpen = menuStore.useState('open')\n React.useEffect(() => {\n if (!isOpen) setAnchorRect(null)\n }, [isOpen, setAnchorRect])\n\n return <Role.div {...props} onContextMenu={handleContextMenu} ref={ref} render={render} />\n },\n)\n\n//\n// MenuList\n//\n\ninterface MenuListProps\n extends Omit<AriakitMenuProps, 'store' | 'className'>,\n ObfuscatedClassName {}\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = React.forwardRef<HTMLDivElement, MenuListProps>(function MenuList(\n { exceptionallySetClassName, modal = true, flip, ...props },\n ref,\n) {\n const { menuStore, getAnchorRect } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuList must be wrapped in <Menu/>')\n }\n\n const { isSubMenu } = React.useContext(SubMenuContext)\n\n const isOpen = menuStore.useState('open')\n\n return isOpen ? (\n <Portal preserveTabOrder>\n <AriakitMenu\n {...props}\n store={menuStore}\n gutter={8}\n shift={4}\n ref={ref}\n className={classNames('reactist_menulist', exceptionallySetClassName)}\n getAnchorRect={getAnchorRect ?? undefined}\n modal={modal}\n flip={flip ?? (isSubMenu ? 'bottom' : undefined)}\n />\n </Portal>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ninterface MenuItemProps extends AriakitMenuItemProps, ObfuscatedClassName {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(function MenuItem(\n {\n value,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const { handleItemSelect, menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuItem must be wrapped in <Menu/>')\n }\n\n const { hide } = menuStore\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect?.(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <AriakitMenuItem\n {...props}\n store={menuStore}\n ref={ref}\n onClick={handleClick}\n className={exceptionallySetClassName}\n hideOnClick={false}\n >\n {children}\n </AriakitMenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLDivElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('SubMenu must be wrapped in <Menu/>')\n }\n\n const { hide: parentMenuHide } = menuStore\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value: string | null | undefined) {\n onItemSelect?.(value)\n parentMenuItemSelect?.(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n const buttonElement = button as React.ReactElement<MenuButtonProps>\n const subMenuContextValue = React.useMemo(() => ({ isSubMenu: true }), [])\n\n return (\n <Menu onItemSelect={handleSubItemSelect}>\n <AriakitMenuItem store={menuStore} ref={ref} hideOnClick={false} render={buttonElement}>\n {buttonElement.props.children}\n </AriakitMenuItem>\n <SubMenuContext.Provider value={subMenuContextValue}>{list}</SubMenuContext.Provider>\n </Menu>\n )\n})\n\n//\n// MenuGroup\n//\n\ninterface MenuGroupProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'className'>,\n ObfuscatedClassName {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = React.forwardRef<HTMLDivElement, MenuGroupProps>(function MenuGroup(\n { label, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const { menuStore } = React.useContext(MenuContext)\n if (!menuStore) {\n throw new Error('MenuGroup must be wrapped in <Menu/>')\n }\n\n return (\n <AriakitMenuGroup\n {...props}\n ref={ref}\n store={menuStore}\n className={exceptionallySetClassName}\n >\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </AriakitMenuGroup>\n )\n})\n\nexport { ContextMenuTrigger, Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuButtonProps, MenuListProps, MenuItemProps, MenuGroupProps }\n"],"names":["MenuContext","React","createContext","menuStore","handleItemSelect","undefined","getAnchorRect","setAnchorRect","SubMenuContext","isSubMenu","Menu","children","onItemSelect","props","anchorRect","useState","useMemo","useMenuStore","_objectSpread","focusLoop","value","createElement","Provider","MenuButton","forwardRef","ref","exceptionallySetClassName","useContext","Error","AriakitMenuButton","store","className","classNames","ContextMenuTrigger","render","handleContextMenu","useCallback","event","preventDefault","x","clientX","y","clientY","show","isOpen","useEffect","Role","div","onContextMenu","MenuList","modal","flip","Portal","preserveTabOrder","AriakitMenu","gutter","shift","MenuItem","onSelect","hideOnSelect","onClick","hide","handleClick","onSelectResult","defaultPrevented","shouldClose","AriakitMenuItem","hideOnClick","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","button","list","Children","toArray","buttonElement","subMenuContextValue","MenuGroup","label","AriakitMenuGroup","role"],"mappings":";;;;;;;;;;;AA6BA,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAN,CAAsC;AACtDC,EAAAA,SAAS,EAAE,IAD2C;EAEtDC,gBAAgB,EAAE,MAAMC,SAF8B;AAGtDC,EAAAA,aAAa,EAAE,IAHuC;AAItDC,EAAAA,aAAa,EAAE,MAAMF,SAAAA;AAJiC,CAAtC,CAApB,CAAA;AAOA,MAAMG,cAAc,gBAAGP,KAAK,CAACC,aAAN,CAA4C;AAAEO,EAAAA,SAAS,EAAE,KAAA;AAAb,CAA5C,CAAvB,CAAA;AAuBA;;;AAGG;;AACH,SAASC,IAAT,CAA6D,IAAA,EAAA;EAAA,IAA/C;IAAEC,QAAF;AAAYC,IAAAA,YAAAA;GAAmC,GAAA,IAAA;AAAA,MAAlBC,KAAkB,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EACzD,MAAM,CAACC,UAAD,EAAaP,aAAb,CAAA,GAA8BN,KAAK,CAACc,QAAN,CAAgD,IAAhD,CAApC,CAAA;AACA,EAAA,MAAMT,aAAa,GAAGL,KAA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AAAA,SAAS,gBAAG7E,KAAK,CAACuB,UAAN,CAAiD,SAASsD,SAAT,CAE/DrD,KAAAA,EAAAA,GAF+D,EAE5D;EAAA,IADH;IAAEsD,KAAF;IAASpE,QAAT;AAAmBe,IAAAA,yBAAAA;GAChB,GAAA,KAAA;AAAA,MAD8Cb,KAC9C,GAAA,wBAAA,CAAA,KAAA,EAAA,UAAA,CAAA,CAAA;;EAEH,MAAM;AAAEV,IAAAA,SAAAA;AAAF,GAAA,GAAgBF,KAAK,CAAC0B,UAAN,CAAiB3B,WAAjB,CAAtB,CAAA;;EACA,IAAI,CAACG,SAAL,EAAgB;AACZ,IAAA,MAAM,IAAIyB,KAAJ,CAAU,sCAAV,CAAN,CAAA;AACH,GAAA;;AAED,EAAA,oBACI3B,KAAC,CAAAoB,aAAD,CAAC2D,WAAD,oCACQnE,KADR,CAAA,EAAA,EAAA,EAAA;AAEIY,IAAAA,GAAG,EAAEA,GAFT;AAGIK,IAAAA,KAAK,EAAE3B,SAHX;AAII4B,IAAAA,SAAS,EAAEL,yBAAAA;AAJf,GAAA,CAAA,EAMKqD,KAAK,gBACF9E,KAAK,CAAAoB,aAAL,CAAK,KAAL,EAAK;AAAA4D,IAAAA,IAAI,EAAC,cAAL;AAAoBlD,IAAAA,SAAS,EAAC,2BAAA;AAA9B,GAAL,EACKgD,KADL,CADE,GAIF,IAVR,EAWKpE,QAXL,CADJ,CAAA;AAeH,CAxBiB;;;;"}
@@ -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
  })));