@opengovsg/oui 0.0.7 → 0.0.9

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 (122) hide show
  1. package/dist/cjs/badge/badge.cjs +42 -0
  2. package/dist/cjs/badge/index.cjs +8 -0
  3. package/dist/cjs/badge/use-badge.cjs +111 -0
  4. package/dist/cjs/calendar/calendar-base.cjs +347 -0
  5. package/dist/cjs/calendar/calendar-style-context.cjs +38 -0
  6. package/dist/cjs/calendar/calendar.cjs +16 -0
  7. package/dist/cjs/calendar/index.cjs +22 -0
  8. package/dist/cjs/calendar/types.cjs +3 -0
  9. package/dist/cjs/calendar/utils.cjs +62 -0
  10. package/dist/cjs/combo-box/combo-box-fuzzy.cjs +52 -30
  11. package/dist/cjs/combo-box/combo-box-item.cjs +70 -0
  12. package/dist/cjs/combo-box/combo-box-variant-context.cjs +13 -0
  13. package/dist/cjs/combo-box/combo-box.cjs +46 -100
  14. package/dist/cjs/combo-box/index.cjs +5 -1
  15. package/dist/cjs/index.cjs +30 -1
  16. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/{check.cjs → chevron-left.cjs} +3 -3
  17. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/{chevrons-up-down.cjs → chevron-right.cjs} +3 -6
  18. package/dist/cjs/select/index.cjs +5 -0
  19. package/dist/cjs/select/select-item.cjs +12 -24
  20. package/dist/cjs/select/select-variant-context.cjs +1 -0
  21. package/dist/cjs/select/select.cjs +14 -6
  22. package/dist/cjs/system/react-utils/index.cjs +2 -0
  23. package/dist/cjs/system/react-utils/refs.cjs +12 -0
  24. package/dist/cjs/system/utils.cjs +9 -6
  25. package/dist/cjs/tag-field/index.cjs +2 -0
  26. package/dist/cjs/tag-field/tag-field-item.cjs +28 -0
  27. package/dist/cjs/tag-field/tag-field-list.cjs +11 -21
  28. package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -2
  29. package/dist/cjs/tag-field/tag-field-trigger.cjs +1 -0
  30. package/dist/cjs/tag-field/tag-field.cjs +2 -1
  31. package/dist/esm/badge/badge.js +40 -0
  32. package/dist/esm/badge/index.js +2 -0
  33. package/dist/esm/badge/use-badge.js +109 -0
  34. package/dist/esm/calendar/calendar-base.js +343 -0
  35. package/dist/esm/calendar/calendar-style-context.js +34 -0
  36. package/dist/esm/calendar/calendar.js +14 -0
  37. package/dist/esm/calendar/index.js +5 -0
  38. package/dist/esm/calendar/types.js +1 -0
  39. package/dist/esm/calendar/utils.js +57 -0
  40. package/dist/esm/combo-box/combo-box-fuzzy.js +55 -33
  41. package/dist/esm/combo-box/combo-box-item.js +68 -0
  42. package/dist/esm/combo-box/combo-box-variant-context.js +10 -0
  43. package/dist/esm/combo-box/combo-box.js +48 -101
  44. package/dist/esm/combo-box/index.js +3 -1
  45. package/dist/esm/index.js +11 -1
  46. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/{check.js → chevron-left.js} +3 -3
  47. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.js +14 -0
  48. package/dist/esm/select/index.js +2 -0
  49. package/dist/esm/select/select-item.js +13 -25
  50. package/dist/esm/select/select-variant-context.js +1 -0
  51. package/dist/esm/select/select.js +15 -7
  52. package/dist/esm/system/react-utils/index.js +1 -0
  53. package/dist/esm/system/react-utils/refs.js +10 -0
  54. package/dist/esm/system/utils.js +9 -6
  55. package/dist/esm/tag-field/index.js +1 -0
  56. package/dist/esm/tag-field/tag-field-item.js +26 -0
  57. package/dist/esm/tag-field/tag-field-list.js +12 -21
  58. package/dist/esm/tag-field/tag-field-tag-list.js +3 -2
  59. package/dist/esm/tag-field/tag-field-trigger.js +1 -0
  60. package/dist/esm/tag-field/tag-field.js +3 -2
  61. package/dist/types/badge/badge.d.ts +3 -0
  62. package/dist/types/badge/badge.d.ts.map +1 -0
  63. package/dist/types/badge/index.d.ts +2 -0
  64. package/dist/types/badge/index.d.ts.map +1 -0
  65. package/dist/types/badge/use-badge.d.ts +166 -0
  66. package/dist/types/badge/use-badge.d.ts.map +1 -0
  67. package/dist/types/button/button.d.ts +5 -0
  68. package/dist/types/button/button.d.ts.map +1 -1
  69. package/dist/types/calendar/calendar-base.d.ts +14 -0
  70. package/dist/types/calendar/calendar-base.d.ts.map +1 -0
  71. package/dist/types/calendar/calendar-style-context.d.ts +1032 -0
  72. package/dist/types/calendar/calendar-style-context.d.ts.map +1 -0
  73. package/dist/types/calendar/calendar.d.ts +5 -0
  74. package/dist/types/calendar/calendar.d.ts.map +1 -0
  75. package/dist/types/calendar/index.d.ts +6 -0
  76. package/dist/types/calendar/index.d.ts.map +1 -0
  77. package/dist/types/calendar/types.d.ts +58 -0
  78. package/dist/types/calendar/types.d.ts.map +1 -0
  79. package/dist/types/calendar/utils.d.ts +13 -0
  80. package/dist/types/calendar/utils.d.ts.map +1 -0
  81. package/dist/types/combo-box/combo-box-fuzzy.d.ts +12 -4
  82. package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -1
  83. package/dist/types/combo-box/combo-box-item.d.ts +11 -0
  84. package/dist/types/combo-box/combo-box-item.d.ts.map +1 -0
  85. package/dist/types/combo-box/combo-box-variant-context.d.ts +4 -0
  86. package/dist/types/combo-box/combo-box-variant-context.d.ts.map +1 -0
  87. package/dist/types/combo-box/combo-box.d.ts +5 -21
  88. package/dist/types/combo-box/combo-box.d.ts.map +1 -1
  89. package/dist/types/combo-box/index.d.ts +2 -0
  90. package/dist/types/combo-box/index.d.ts.map +1 -1
  91. package/dist/types/index.d.mts +2 -0
  92. package/dist/types/index.d.ts +2 -0
  93. package/dist/types/index.d.ts.map +1 -1
  94. package/dist/types/select/index.d.ts +2 -0
  95. package/dist/types/select/index.d.ts.map +1 -1
  96. package/dist/types/select/select-item.d.ts.map +1 -1
  97. package/dist/types/select/select-variant-context.d.ts.map +1 -1
  98. package/dist/types/select/select.d.ts.map +1 -1
  99. package/dist/types/system/react-utils/index.d.ts +1 -0
  100. package/dist/types/system/react-utils/index.d.ts.map +1 -1
  101. package/dist/types/system/react-utils/refs.d.ts +4 -0
  102. package/dist/types/system/react-utils/refs.d.ts.map +1 -0
  103. package/dist/types/system/utils.d.ts.map +1 -1
  104. package/dist/types/tag-field/index.d.ts +1 -0
  105. package/dist/types/tag-field/index.d.ts.map +1 -1
  106. package/dist/types/tag-field/tag-field-item.d.ts +7 -0
  107. package/dist/types/tag-field/tag-field-item.d.ts.map +1 -0
  108. package/dist/types/tag-field/tag-field-list.d.ts +5 -9
  109. package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
  110. package/dist/types/tag-field/tag-field-root.d.ts +4 -4
  111. package/dist/types/tag-field/tag-field-root.d.ts.map +1 -1
  112. package/dist/types/tag-field/tag-field-state-context.d.ts +1 -2
  113. package/dist/types/tag-field/tag-field-state-context.d.ts.map +1 -1
  114. package/dist/types/tag-field/tag-field-tag-list.d.ts +2 -3
  115. package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
  116. package/dist/types/tag-field/tag-field-trigger.d.ts.map +1 -1
  117. package/dist/types/tag-field/tag-field.d.ts +2 -2
  118. package/dist/types/tag-field/tag-field.d.ts.map +1 -1
  119. package/dist/types/tag-field/types.d.ts +6 -9
  120. package/dist/types/tag-field/types.d.ts.map +1 -1
  121. package/package.json +8 -6
  122. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js +0 -17
@@ -3,8 +3,10 @@
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useMemo, useCallback } from 'react';
5
5
  import { useMessageFormatter } from 'react-aria';
6
- import { ListLayout, ComboBox as ComboBox$1, Input, Button, Virtualizer, Popover, ListBox, ListBoxItem, Text } from 'react-aria-components';
6
+ import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Popover, Virtualizer, ListBox } from 'react-aria-components';
7
7
  import { comboBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
8
+ import { mapPropsVariants } from '../system/utils.js';
9
+ import { ComboBoxVariantContext } from './combo-box-variant-context.js';
8
10
  import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
9
11
  import ChevronUp from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
10
12
  import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
@@ -54,38 +56,43 @@ function ComboBoxEmptyState({
54
56
  }
55
57
  );
56
58
  }
57
- function ComboBox({
58
- label,
59
- description,
60
- errorMessage,
61
- classNames,
62
- itemClassNames,
63
- size,
64
- listLayoutOptions,
65
- children,
66
- dependencies,
67
- onClear,
68
- renderEmptyState: renderEmptyStateProp,
69
- ...props
70
- }) {
59
+ function ComboBox(originalProps) {
71
60
  const formatMessage = useMessageFormatter(i18nStrings);
72
- const styles = comboBoxStyles({ size });
61
+ const [_props, variantProps] = mapPropsVariants(
62
+ originalProps,
63
+ comboBoxStyles.variantKeys
64
+ );
65
+ const {
66
+ label,
67
+ description,
68
+ errorMessage,
69
+ classNames,
70
+ listLayoutOptions,
71
+ children,
72
+ dependencies,
73
+ onClear,
74
+ renderEmptyState: renderEmptyStateProp,
75
+ ...props
76
+ } = _props;
77
+ const styles = comboBoxStyles(variantProps);
73
78
  const layout = useMemo(() => {
74
79
  return new ListLayout({
75
- estimatedRowHeight: calculateEstimatedRowHeight(size ?? "md"),
80
+ estimatedRowHeight: calculateEstimatedRowHeight(
81
+ variantProps.size ?? "md"
82
+ ),
76
83
  ...listLayoutOptions
77
84
  });
78
- }, [listLayoutOptions, size]);
85
+ }, [listLayoutOptions, variantProps.size]);
79
86
  const renderEmptyState = useCallback(
80
87
  (props2) => {
81
88
  if (renderEmptyStateProp) {
82
89
  return renderEmptyStateProp(props2);
83
90
  }
84
- return /* @__PURE__ */ jsx(ComboBoxEmptyState, { size, className: classNames?.emptyState });
91
+ return /* @__PURE__ */ jsx(ComboBoxEmptyState, { className: classNames?.emptyState });
85
92
  },
86
- [classNames?.emptyState, renderEmptyStateProp, size]
93
+ [classNames?.emptyState, renderEmptyStateProp]
87
94
  );
88
- return /* @__PURE__ */ jsx(
95
+ return /* @__PURE__ */ jsx(Provider, { values: [[ComboBoxVariantContext, variantProps]], children: /* @__PURE__ */ jsx(
89
96
  ComboBox$1,
90
97
  {
91
98
  className: composeTailwindRenderProps(
@@ -94,13 +101,14 @@ function ComboBox({
94
101
  ),
95
102
  shouldFocusWrap: true,
96
103
  allowsEmptyCollection: true,
104
+ isDisabled: variantProps.isDisabled,
97
105
  ...props,
98
106
  children: ({ isOpen, isDisabled: isComboBoxDisabled }) => /* @__PURE__ */ jsxs(Fragment, { children: [
99
107
  /* @__PURE__ */ jsx(
100
108
  Label,
101
109
  {
102
- size,
103
- className: styles.label({ className: classNames?.label, size }),
110
+ size: variantProps.size,
111
+ className: styles.label({ className: classNames?.label }),
104
112
  children: label
105
113
  }
106
114
  ),
@@ -108,12 +116,12 @@ function ComboBox({
108
116
  /* @__PURE__ */ jsxs(
109
117
  FieldGroup,
110
118
  {
119
+ isDisabled: isComboBoxDisabled,
111
120
  className: composeRenderProps(
112
121
  classNames?.group,
113
122
  (className, renderProps) => styles.group({
114
123
  ...renderProps,
115
124
  className,
116
- size,
117
125
  isClearable: !!onClear
118
126
  })
119
127
  ),
@@ -123,7 +131,7 @@ function ComboBox({
123
131
  {
124
132
  className: composeRenderProps(
125
133
  classNames?.field,
126
- (className, renderProps) => styles.field({ ...renderProps, className, size })
134
+ (className, renderProps) => styles.field({ ...renderProps, className })
127
135
  )
128
136
  }
129
137
  ),
@@ -132,22 +140,20 @@ function ComboBox({
132
140
  {
133
141
  className: composeRenderProps(
134
142
  classNames?.expandButton,
135
- (className, renderProps) => styles.expandButton({ ...renderProps, className, size })
143
+ (className, renderProps) => styles.expandButton({ ...renderProps, className })
136
144
  ),
137
145
  children: isOpen ? /* @__PURE__ */ jsx(
138
146
  ChevronUp,
139
147
  {
140
148
  className: styles.icon({
141
- className: classNames?.icon,
142
- size
149
+ className: classNames?.icon
143
150
  })
144
151
  }
145
152
  ) : /* @__PURE__ */ jsx(
146
153
  ChevronDown,
147
154
  {
148
155
  className: styles.icon({
149
- className: classNames?.icon,
150
- size
156
+ className: classNames?.icon
151
157
  })
152
158
  }
153
159
  )
@@ -166,35 +172,33 @@ function ComboBox({
166
172
  className: composeRenderProps(
167
173
  classNames?.clearButton,
168
174
  (className, renderProps) => comboBoxClearButtonStyles({
175
+ ...variantProps,
169
176
  ...renderProps,
170
177
  className,
171
- size,
172
- isInactive: !props.inputValue,
173
- isDisabled: renderProps.isDisabled
178
+ isInactive: !props.inputValue
174
179
  })
175
180
  ),
176
181
  children: /* @__PURE__ */ jsx(
177
182
  X,
178
183
  {
179
184
  className: styles.icon({
180
- className: classNames?.icon,
181
- size
185
+ className: classNames?.icon
182
186
  })
183
187
  }
184
188
  )
185
189
  }
186
190
  )
187
191
  ] }),
188
- description && /* @__PURE__ */ jsx(Description, { size, children: description }),
189
- /* @__PURE__ */ jsx(FieldError, { size, children: errorMessage }),
190
- /* @__PURE__ */ jsx(Virtualizer, { layout, children: /* @__PURE__ */ jsx(
192
+ description && /* @__PURE__ */ jsx(Description, { size: variantProps.size, children: description }),
193
+ /* @__PURE__ */ jsx(FieldError, { size: variantProps.size, children: errorMessage }),
194
+ /* @__PURE__ */ jsx(
191
195
  Popover,
192
196
  {
193
197
  className: composeRenderProps(
194
198
  classNames?.popover,
195
199
  (className, renderProps) => styles.popover({ ...renderProps, className })
196
200
  ),
197
- children: /* @__PURE__ */ jsx(
201
+ children: /* @__PURE__ */ jsx(Virtualizer, { layout, children: /* @__PURE__ */ jsx(
198
202
  ListBox,
199
203
  {
200
204
  className: composeRenderProps(
@@ -203,71 +207,14 @@ function ComboBox({
203
207
  ),
204
208
  dependencies,
205
209
  renderEmptyState,
206
- children: (item) => {
207
- if (children) {
208
- return children(item);
209
- }
210
- return /* @__PURE__ */ jsx(
211
- ComboBoxItem,
212
- {
213
- size,
214
- id: item.value,
215
- label: item.name,
216
- textValue: item.name,
217
- description: item.description,
218
- classNames: itemClassNames
219
- }
220
- );
221
- }
210
+ children
222
211
  }
223
- )
212
+ ) })
224
213
  }
225
- ) })
214
+ )
226
215
  ] })
227
216
  }
228
- );
229
- }
230
- function ComboBoxItem({
231
- className,
232
- size,
233
- description,
234
- label,
235
- classNames,
236
- ...props
237
- }) {
238
- const styles = comboBoxItemStyles({ size });
239
- return /* @__PURE__ */ jsx(
240
- ListBoxItem,
241
- {
242
- ...props,
243
- className: composeRenderProps(
244
- className ?? classNames?.container,
245
- (className2, renderProps) => styles.container({ ...renderProps, className: className2 })
246
- ),
247
- children: (renderProps) => {
248
- return /* @__PURE__ */ jsxs(Fragment, { children: [
249
- /* @__PURE__ */ jsx(
250
- Text,
251
- {
252
- className: styles.label({ className: classNames?.label }),
253
- slot: "label",
254
- children: typeof label === "function" ? label(renderProps) : label
255
- }
256
- ),
257
- description && /* @__PURE__ */ jsx(
258
- Text,
259
- {
260
- className: styles.description({
261
- className: classNames?.description
262
- }),
263
- slot: "description",
264
- children: typeof description === "function" ? description(renderProps) : description
265
- }
266
- )
267
- ] });
268
- }
269
- }
270
- );
217
+ ) });
271
218
  }
272
219
 
273
- export { ComboBox, ComboBoxEmptyState, ComboBoxItem };
220
+ export { ComboBox, ComboBoxEmptyState };
@@ -1,3 +1,5 @@
1
1
  "use strict";
2
- export { ComboBox, ComboBoxEmptyState, ComboBoxItem } from './combo-box.js';
2
+ export { ComboBox, ComboBoxEmptyState } from './combo-box.js';
3
3
  export { ComboBoxFuzzy } from './combo-box-fuzzy.js';
4
+ export { ComboBoxItem } from './combo-box-item.js';
5
+ export { ComboBoxVariantContext, useComboBoxVariantContext } from './combo-box-variant-context.js';
package/dist/esm/index.js CHANGED
@@ -13,8 +13,18 @@ export { TextField } from './text-field/text-field.js';
13
13
  export { Description, FieldError, FieldGroup, Label } from './field/field.js';
14
14
  export { TextArea } from './text-area/text-area.js';
15
15
  export { TextAreaField } from './text-area-field/text-area-field.js';
16
- export { ComboBox, ComboBoxEmptyState, ComboBoxItem } from './combo-box/combo-box.js';
16
+ export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
17
17
  export { ComboBoxFuzzy } from './combo-box/combo-box-fuzzy.js';
18
+ export { ComboBoxItem } from './combo-box/combo-box-item.js';
19
+ export { ComboBoxVariantContext, useComboBoxVariantContext } from './combo-box/combo-box-variant-context.js';
18
20
  export { Banner } from './banner/banner.js';
19
21
  export { TagField } from './tag-field/tag-field.js';
22
+ export { TagFieldItem } from './tag-field/tag-field-item.js';
20
23
  export { Select } from './select/select.js';
24
+ export { SelectItem } from './select/select-item.js';
25
+ export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
26
+ export { Badge } from './badge/badge.js';
27
+ export { CalendarDate } from '@internationalized/date';
28
+ export { Calendar } from './calendar/calendar.js';
29
+ export { CalendarStyleContext, useCalendarStyleContext, useProvideCalendarStyles } from './calendar/calendar-style-context.js';
30
+ export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
@@ -8,7 +8,7 @@ import createLucideIcon from '../createLucideIcon.js';
8
8
  */
9
9
 
10
10
 
11
- const __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
12
- const Check = createLucideIcon("Check", __iconNode);
11
+ const __iconNode = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
12
+ const ChevronLeft = createLucideIcon("ChevronLeft", __iconNode);
13
13
 
14
- export { __iconNode, Check as default };
14
+ export { __iconNode, ChevronLeft as default };
@@ -0,0 +1,14 @@
1
+ import createLucideIcon from '../createLucideIcon.js';
2
+
3
+ /**
4
+ * @license lucide-react v0.475.0 - ISC
5
+ *
6
+ * This source code is licensed under the ISC license.
7
+ * See the LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+
11
+ const __iconNode = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
12
+ const ChevronRight = createLucideIcon("ChevronRight", __iconNode);
13
+
14
+ export { __iconNode, ChevronRight as default };
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
2
  export { Select } from './select.js';
3
+ export { SelectItem } from './select-item.js';
4
+ export { SelectVariantContext, useSelectVariantContext } from './select-variant-context.js';
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
3
4
  import { useContextProps, ListBoxItem } from 'react-aria-components';
4
5
  import { selectItemStyles, composeRenderProps } from '@opengovsg/oui-theme';
5
6
  import { forwardRef, mapPropsVariants } from '../system/utils.js';
6
7
  import { SelectVariantContext } from './select-variant-context.js';
7
- import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js';
8
8
 
9
9
  const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
10
10
  [originalProps, ref] = useContextProps(
@@ -20,6 +20,7 @@ const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProp
20
20
  return /* @__PURE__ */ jsx(
21
21
  ListBoxItem,
22
22
  {
23
+ textValue: typeof props.children === "string" ? props.children : void 0,
23
24
  ...props,
24
25
  ref,
25
26
  className: composeRenderProps(
@@ -30,29 +31,16 @@ const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProp
30
31
  if (typeof props.children === "function") {
31
32
  return props.children(renderProps);
32
33
  }
33
- return /* @__PURE__ */ jsxs(Fragment, { children: [
34
- /* @__PURE__ */ jsx(
35
- "span",
36
- {
37
- className: styles.text({
38
- className: classNames?.text,
39
- ...renderProps
40
- }),
41
- children: props.children
42
- }
43
- ),
44
- renderProps.isSelected && /* @__PURE__ */ jsx(
45
- "span",
46
- {
47
- "aria-hidden": true,
48
- className: styles.icon({
49
- className: classNames?.icon,
50
- ...renderProps
51
- }),
52
- children: /* @__PURE__ */ jsx(Check, {})
53
- }
54
- )
55
- ] });
34
+ return /* @__PURE__ */ jsx(
35
+ "span",
36
+ {
37
+ className: styles.text({
38
+ className: classNames?.text,
39
+ ...renderProps
40
+ }),
41
+ children: props.children
42
+ }
43
+ );
56
44
  }
57
45
  }
58
46
  );
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  import { createContext } from '../system/react-utils/context.js';
3
4
 
4
5
  const [SelectVariantContext, useSelectVariantContext] = createContext({
@@ -2,12 +2,12 @@
2
2
  "use client";
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
4
  import { useMemo } from 'react';
5
- import { ListLayout, Provider, Select as Select$1, SelectValue, Popover, Virtualizer, ListBox } from 'react-aria-components';
5
+ import { Provider, Select as Select$1, SelectValue, Popover, Virtualizer, ListLayout, ListBox } from 'react-aria-components';
6
6
  import { selectStyles, composeRenderProps } from '@opengovsg/oui-theme';
7
7
  import { mapPropsVariants } from '../system/utils.js';
8
8
  import { SelectVariantContext } from './select-variant-context.js';
9
- import ChevronsUpDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js';
10
9
  import { Label, Description } from '../field/field.js';
10
+ import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
11
11
  import { Button } from '../button/button.js';
12
12
 
13
13
  const calculateEstimatedRowHeight = (size) => {
@@ -32,13 +32,13 @@ function Select({
32
32
  );
33
33
  const { items, children, listLayoutOptions, ...props } = _props;
34
34
  const styles = selectStyles(variantProps);
35
- const layout = useMemo(() => {
36
- return new ListLayout({
35
+ const layoutOptions = useMemo(() => {
36
+ return {
37
37
  estimatedRowHeight: calculateEstimatedRowHeight(
38
38
  variantProps.size ?? "md"
39
39
  ),
40
40
  ...listLayoutOptions
41
- });
41
+ };
42
42
  }, [listLayoutOptions, variantProps.size]);
43
43
  return /* @__PURE__ */ jsx(Provider, { values: [[SelectVariantContext, variantProps]], children: /* @__PURE__ */ jsxs(
44
44
  Select$1,
@@ -69,7 +69,14 @@ function Select({
69
69
  })
70
70
  }
71
71
  ),
72
- /* @__PURE__ */ jsx(ChevronsUpDown, { className: "h-4 w-4" })
72
+ /* @__PURE__ */ jsx(
73
+ ChevronDown,
74
+ {
75
+ className: styles.icon({
76
+ className: classNames?.icon
77
+ })
78
+ }
79
+ )
73
80
  ]
74
81
  }
75
82
  ),
@@ -81,9 +88,10 @@ function Select({
81
88
  children: description
82
89
  }
83
90
  ),
84
- /* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsx(Virtualizer, { layout, children: /* @__PURE__ */ jsx(
91
+ /* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsx(Virtualizer, { layout: ListLayout, layoutOptions, children: /* @__PURE__ */ jsx(
85
92
  ListBox,
86
93
  {
94
+ autoFocus: true,
87
95
  items,
88
96
  shouldFocusWrap: true,
89
97
  className: composeRenderProps(
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  export { createContext } from './context.js';
3
+ export { useDomRef } from './refs.js';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ import { useRef, useImperativeHandle } from 'react';
3
+
4
+ function useDomRef(ref) {
5
+ const domRef = useRef(null);
6
+ useImperativeHandle(ref, () => domRef.current);
7
+ return domRef;
8
+ }
9
+
10
+ export { useDomRef };
@@ -11,12 +11,15 @@ const mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
11
11
  if (!variantKeys) {
12
12
  return [props, {}];
13
13
  }
14
- const picked = variantKeys.reduce((acc, key) => {
15
- if (key in props) {
16
- return { ...acc, [key]: props[key] };
17
- }
18
- return acc;
19
- }, {});
14
+ const picked = variantKeys.reduce(
15
+ (acc, key) => {
16
+ if (key in props) {
17
+ return { ...acc, [key]: props[key] };
18
+ }
19
+ return acc;
20
+ },
21
+ {}
22
+ );
20
23
  if (removeVariantProps) {
21
24
  const omitted = Object.keys(props).filter((key) => !variantKeys.includes(key)).reduce((acc, key) => ({ ...acc, [key]: props[key] }), {});
22
25
  return [omitted, picked];
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  export { TagField } from './tag-field.js';
3
+ export { TagFieldItem } from './tag-field-item.js';
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { tagFieldItemStyles, dataAttr } from '@opengovsg/oui-theme';
6
+ import { forwardRefGeneric } from '../system/utils.js';
7
+ import { TagFieldStateContext } from './tag-field-state-context.js';
8
+
9
+ const TagFieldItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
10
+ const { itemToText, size } = useContext(TagFieldStateContext);
11
+ const styles = tagFieldItemStyles({ size });
12
+ return /* @__PURE__ */ jsx(
13
+ "li",
14
+ {
15
+ ref,
16
+ ...itemProps,
17
+ className: styles.container({ className: classNames?.container }),
18
+ "data-rac": true,
19
+ "data-hovered": dataAttr(isHighlighted),
20
+ children: /* @__PURE__ */ jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
21
+ }
22
+ );
23
+ };
24
+ const TagFieldItem = forwardRefGeneric(TagFieldItemInner);
25
+
26
+ export { TagFieldItem };
@@ -1,28 +1,13 @@
1
1
  "use strict";
2
+ "use client";
2
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
4
  import { createContext, useContext, createElement } from 'react';
4
5
  import { useContextProps } from 'react-aria-components';
5
- import { tagFieldItemStyles, dataAttr } from '@opengovsg/oui-theme';
6
6
  import { forwardRefGeneric } from '../system/utils.js';
7
+ import { TagFieldItem } from './tag-field-item.js';
7
8
  import { TagFieldStateContext } from './tag-field-state-context.js';
8
9
 
9
10
  const TagFieldListContext = createContext(null);
10
- const TagFieldListItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
11
- const { itemToText, size } = useContext(TagFieldStateContext);
12
- const styles = tagFieldItemStyles({ size });
13
- return /* @__PURE__ */ jsx(
14
- "li",
15
- {
16
- ref,
17
- ...itemProps,
18
- className: styles.container({ className: classNames?.container }),
19
- "data-rac": true,
20
- "data-hovered": dataAttr(isHighlighted),
21
- children: /* @__PURE__ */ jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
22
- }
23
- );
24
- };
25
- const TagFieldListItem = forwardRefGeneric(TagFieldListItemInner);
26
11
  const TagFieldListInner = (props, ref) => {
27
12
  [props, ref] = useContextProps(props, ref, TagFieldListContext);
28
13
  const { items, getItemProps, highlightedIndex } = useContext(TagFieldStateContext);
@@ -54,16 +39,22 @@ const TagFieldListInner = (props, ref) => {
54
39
  item,
55
40
  isHighlighted: highlightedIndex === virtualRow.index,
56
41
  key: virtualRow.key,
57
- ...itemProps,
58
42
  classNames: itemClassNames
59
43
  };
60
44
  if (typeof props.children === "function") {
61
- return props.children(childProps);
45
+ return props.children({ ...childProps, itemProps });
62
46
  }
63
- return /* @__PURE__ */ createElement(TagFieldListItem, { ...childProps, key: childProps.key });
47
+ return /* @__PURE__ */ createElement(
48
+ TagFieldItem,
49
+ {
50
+ ...childProps,
51
+ ...itemProps,
52
+ key: childProps.key
53
+ }
54
+ );
64
55
  })
65
56
  ] }) });
66
57
  };
67
58
  const TagFieldList = forwardRefGeneric(TagFieldListInner);
68
59
 
69
- export { TagFieldList, TagFieldListContext, TagFieldListItem };
60
+ export { TagFieldList, TagFieldListContext };
@@ -13,7 +13,8 @@ const TagFieldTagList = ({
13
13
  getSelectedItemProps,
14
14
  removeSelectedItem,
15
15
  isDisabled,
16
- isReadOnly
16
+ isReadOnly,
17
+ itemToText
17
18
  } = useContext(TagFieldStateContext);
18
19
  const handleRemoveSelectedItem = useCallback(
19
20
  (item) => () => {
@@ -47,7 +48,7 @@ const TagFieldTagList = ({
47
48
  className: classNames?.tag,
48
49
  ...itemProps,
49
50
  children: [
50
- /* @__PURE__ */ jsx("span", { className: classNames?.tagText, children: selectedItem.textValue }),
51
+ /* @__PURE__ */ jsx("span", { className: classNames?.tagText, children: itemToText(selectedItem) }),
51
52
  /* @__PURE__ */ jsx(
52
53
  X,
53
54
  {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  import { jsx } from 'react/jsx-runtime';
3
4
  import { createContext } from 'react';
4
5
  import { useContextProps } from 'react-aria-components';
@@ -4,7 +4,8 @@ import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { createElement } from 'react';
5
5
  import { composeRenderProps, Popover } from 'react-aria-components';
6
6
  import { tagFieldStyles } from '@opengovsg/oui-theme';
7
- import { TagFieldList, TagFieldListItem } from './tag-field-list.js';
7
+ import { TagFieldItem } from './tag-field-item.js';
8
+ import { TagFieldList } from './tag-field-list.js';
8
9
  import { TagFieldRoot } from './tag-field-root.js';
9
10
  import { TagFieldTagList } from './tag-field-tag-list.js';
10
11
  import { TagFieldTrigger } from './tag-field-trigger.js';
@@ -95,7 +96,7 @@ function TagField({
95
96
  {
96
97
  className: styles.list({ className: classNames?.list }),
97
98
  itemClassNames: props.itemClassNames,
98
- children: ({ key, ...props2 }) => children ? children({ key, ...props2 }) : /* @__PURE__ */ createElement(TagFieldListItem, { ...props2, key })
99
+ children: ({ key, itemProps, ...props2 }) => children ? children({ key, itemProps, ...props2 }) : /* @__PURE__ */ createElement(TagFieldItem, { ...props2, ...itemProps, key })
99
100
  }
100
101
  ) })
101
102
  ] });
@@ -0,0 +1,3 @@
1
+ import type { UseBadgeProps } from "./use-badge";
2
+ export declare const Badge: import("react").ForwardRefExoticComponent<Omit<UseBadgeProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
3
+ //# sourceMappingURL=badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/badge/badge.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,eAAO,MAAM,KAAK,uHAwChB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./badge";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/badge/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}