@opengovsg/oui 0.0.7 → 0.0.8

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 (73) 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/combo-box/combo-box-fuzzy.cjs +52 -30
  5. package/dist/cjs/combo-box/combo-box-item.cjs +70 -0
  6. package/dist/cjs/combo-box/combo-box-variant-context.cjs +13 -0
  7. package/dist/cjs/combo-box/combo-box.cjs +46 -100
  8. package/dist/cjs/combo-box/index.cjs +5 -1
  9. package/dist/cjs/index.cjs +14 -3
  10. package/dist/cjs/select/index.cjs +5 -0
  11. package/dist/cjs/select/select-item.cjs +1 -0
  12. package/dist/cjs/select/select-variant-context.cjs +1 -0
  13. package/dist/cjs/system/react-utils/index.cjs +2 -0
  14. package/dist/cjs/system/react-utils/refs.cjs +12 -0
  15. package/dist/cjs/tag-field/tag-field-list.cjs +3 -2
  16. package/dist/cjs/tag-field/tag-field-trigger.cjs +1 -0
  17. package/dist/cjs/tag-field/tag-field.cjs +1 -1
  18. package/dist/esm/badge/badge.js +40 -0
  19. package/dist/esm/badge/index.js +2 -0
  20. package/dist/esm/badge/use-badge.js +109 -0
  21. package/dist/esm/combo-box/combo-box-fuzzy.js +55 -33
  22. package/dist/esm/combo-box/combo-box-item.js +68 -0
  23. package/dist/esm/combo-box/combo-box-variant-context.js +10 -0
  24. package/dist/esm/combo-box/combo-box.js +48 -101
  25. package/dist/esm/combo-box/index.js +3 -1
  26. package/dist/esm/index.js +7 -2
  27. package/dist/esm/select/index.js +2 -0
  28. package/dist/esm/select/select-item.js +1 -0
  29. package/dist/esm/select/select-variant-context.js +1 -0
  30. package/dist/esm/system/react-utils/index.js +1 -0
  31. package/dist/esm/system/react-utils/refs.js +10 -0
  32. package/dist/esm/tag-field/tag-field-list.js +3 -2
  33. package/dist/esm/tag-field/tag-field-trigger.js +1 -0
  34. package/dist/esm/tag-field/tag-field.js +1 -1
  35. package/dist/types/badge/badge.d.ts +3 -0
  36. package/dist/types/badge/badge.d.ts.map +1 -0
  37. package/dist/types/badge/index.d.ts +2 -0
  38. package/dist/types/badge/index.d.ts.map +1 -0
  39. package/dist/types/badge/use-badge.d.ts +166 -0
  40. package/dist/types/badge/use-badge.d.ts.map +1 -0
  41. package/dist/types/combo-box/combo-box-fuzzy.d.ts +12 -4
  42. package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -1
  43. package/dist/types/combo-box/combo-box-item.d.ts +11 -0
  44. package/dist/types/combo-box/combo-box-item.d.ts.map +1 -0
  45. package/dist/types/combo-box/combo-box-variant-context.d.ts +4 -0
  46. package/dist/types/combo-box/combo-box-variant-context.d.ts.map +1 -0
  47. package/dist/types/combo-box/combo-box.d.ts +5 -21
  48. package/dist/types/combo-box/combo-box.d.ts.map +1 -1
  49. package/dist/types/combo-box/index.d.ts +2 -0
  50. package/dist/types/combo-box/index.d.ts.map +1 -1
  51. package/dist/types/index.d.mts +1 -0
  52. package/dist/types/index.d.ts +1 -0
  53. package/dist/types/index.d.ts.map +1 -1
  54. package/dist/types/select/index.d.ts +2 -0
  55. package/dist/types/select/index.d.ts.map +1 -1
  56. package/dist/types/select/select-item.d.ts.map +1 -1
  57. package/dist/types/select/select-variant-context.d.ts.map +1 -1
  58. package/dist/types/system/react-utils/index.d.ts +1 -0
  59. package/dist/types/system/react-utils/index.d.ts.map +1 -1
  60. package/dist/types/system/react-utils/refs.d.ts +4 -0
  61. package/dist/types/system/react-utils/refs.d.ts.map +1 -0
  62. package/dist/types/tag-field/tag-field-list.d.ts +5 -5
  63. package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
  64. package/dist/types/tag-field/tag-field-root.d.ts +4 -4
  65. package/dist/types/tag-field/tag-field-root.d.ts.map +1 -1
  66. package/dist/types/tag-field/tag-field-tag-list.d.ts +2 -3
  67. package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
  68. package/dist/types/tag-field/tag-field-trigger.d.ts.map +1 -1
  69. package/dist/types/tag-field/tag-field.d.ts +2 -2
  70. package/dist/types/tag-field/tag-field.d.ts.map +1 -1
  71. package/dist/types/tag-field/types.d.ts +0 -5
  72. package/dist/types/tag-field/types.d.ts.map +1 -1
  73. package/package.json +6 -5
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+ var useBadge = require('./use-badge.cjs');
8
+ var x = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.cjs');
9
+
10
+ const Badge = react.forwardRef((props, ref) => {
11
+ const {
12
+ Component,
13
+ children,
14
+ slots,
15
+ classNames,
16
+ getChipProps,
17
+ getCloseButtonProps,
18
+ startContent,
19
+ endContent,
20
+ isCloseable
21
+ } = useBadge.useBadge({ ...props, ref });
22
+ const start = react.useMemo(() => {
23
+ if (props.variant === "dot" && !startContent) {
24
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: slots.dot({ className: classNames?.dot }) });
25
+ }
26
+ return startContent;
27
+ }, [props.variant, startContent, slots, classNames?.dot]);
28
+ const end = react.useMemo(() => {
29
+ if (isCloseable) {
30
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...getCloseButtonProps(), children: endContent ?? /* @__PURE__ */ jsxRuntime.jsx(x.default, { className: "size-full" }) });
31
+ }
32
+ return endContent;
33
+ }, [endContent, getCloseButtonProps, isCloseable]);
34
+ return /* @__PURE__ */ jsxRuntime.jsxs(Component, { ...getChipProps(), children: [
35
+ start,
36
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: slots.content({ className: classNames?.content }), children }),
37
+ end
38
+ ] });
39
+ });
40
+ Badge.displayName = "Badge";
41
+
42
+ exports.Badge = Badge;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ 'use strict';
3
+
4
+ var badge = require('./badge.cjs');
5
+
6
+
7
+
8
+ exports.Badge = badge.Badge;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ 'use strict';
3
+
4
+ var react = require('react');
5
+ var utils$1 = require('@react-aria/utils');
6
+ var reactAria = require('react-aria');
7
+ var useDeepCompare = require('use-deep-compare');
8
+ var ouiTheme = require('@opengovsg/oui-theme');
9
+ var utils = require('../system/utils.cjs');
10
+ var refs = require('../system/react-utils/refs.cjs');
11
+
12
+ const i18nStrings = {
13
+ "en-SG": {
14
+ close: "Close badge"
15
+ },
16
+ "zh-SG": {
17
+ close: "\u5173\u95ED\u5FBD\u7AE0"
18
+ },
19
+ "ms-SG": {
20
+ close: "Tutup lencana"
21
+ },
22
+ "ta-SG": {
23
+ close: "\u0BAA\u0BC7\u0B9F\u0BCD\u0B9C\u0BC8 \u0BAE\u0BC2\u0B9F\u0BC1"
24
+ }
25
+ };
26
+ function useBadge(originalProps) {
27
+ const [_props, variantProps] = utils.mapPropsVariants(
28
+ originalProps,
29
+ ouiTheme.badgeStyles.variantKeys
30
+ );
31
+ const {
32
+ ref,
33
+ as,
34
+ children,
35
+ startContent,
36
+ endContent,
37
+ onClose,
38
+ classNames,
39
+ className,
40
+ ...props
41
+ } = _props;
42
+ const domRef = refs.useDomRef(ref);
43
+ const Component = react.useMemo(() => as || "div", [as]);
44
+ const baseClassName = ouiTheme.cn(classNames?.base, className);
45
+ const formatMessage = reactAria.useMessageFormatter(i18nStrings);
46
+ const isCloseable = variantProps.isCloseable || !!onClose;
47
+ const {
48
+ focusProps: closeFocusProps,
49
+ isFocusVisible: isCloseButtonFocusVisible
50
+ } = reactAria.useFocusRing();
51
+ const slots = useDeepCompare.useDeepCompareMemo(
52
+ () => ({
53
+ ...ouiTheme.badgeStyles({ isCloseable, ...variantProps }),
54
+ closeButton: ouiTheme.badgeCloseButtonStyles
55
+ }),
56
+ [variantProps, isCloseable, ouiTheme.badgeStyles, ouiTheme.badgeCloseButtonStyles]
57
+ );
58
+ const { pressProps: closePressProps } = reactAria.usePress({
59
+ isDisabled: !!variantProps?.isDisabled,
60
+ onPress: onClose
61
+ });
62
+ const getContentClone = react.useCallback(
63
+ (content) => react.isValidElement(content) ? react.cloneElement(content, {
64
+ // @ts-expect-error types are not full
65
+ className: content.props?.className
66
+ }) : null,
67
+ []
68
+ );
69
+ const getChipProps = react.useCallback(() => {
70
+ return {
71
+ ref: domRef,
72
+ className: slots.base({ className: baseClassName }),
73
+ "aria-disabled": variantProps?.isDisabled,
74
+ ...props
75
+ };
76
+ }, [baseClassName, domRef, props, slots, variantProps?.isDisabled]);
77
+ const getCloseButtonProps = react.useCallback(() => {
78
+ return {
79
+ role: "button",
80
+ tabIndex: 0,
81
+ className: slots.closeButton({
82
+ size: variantProps?.size,
83
+ className: classNames?.closeButton,
84
+ isFocusVisible: isCloseButtonFocusVisible
85
+ }),
86
+ "aria-label": formatMessage("close"),
87
+ ...utils$1.mergeProps(closePressProps, closeFocusProps)
88
+ };
89
+ }, [
90
+ classNames?.closeButton,
91
+ closeFocusProps,
92
+ closePressProps,
93
+ formatMessage,
94
+ isCloseButtonFocusVisible,
95
+ slots,
96
+ variantProps?.size
97
+ ]);
98
+ return {
99
+ Component,
100
+ children,
101
+ slots,
102
+ classNames,
103
+ isCloseable,
104
+ startContent: getContentClone(startContent),
105
+ endContent: getContentClone(endContent),
106
+ getCloseButtonProps,
107
+ getChipProps
108
+ };
109
+ }
110
+
111
+ exports.useBadge = useBadge;
@@ -5,8 +5,11 @@
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var react = require('react');
7
7
  var fuzzysort = require('fuzzysort');
8
+ var reactAriaComponents = require('react-aria-components');
8
9
  var ouiTheme = require('@opengovsg/oui-theme');
10
+ var utils = require('../system/utils.cjs');
9
11
  var comboBox = require('./combo-box.cjs');
12
+ var comboBoxItem = require('./combo-box-item.cjs');
10
13
 
11
14
  function HighlightedText({
12
15
  result,
@@ -29,18 +32,24 @@ function HighlightedText({
29
32
  i
30
33
  ));
31
34
  }
32
- function ComboBoxFuzzy({
33
- items,
34
- itemClassNames,
35
- onSelectionChange: onSelectionChangeProp,
36
- onInputChange: onInputChangeProp,
37
- ...props
38
- }) {
39
- const deferredInputValue = react.useDeferredValue(props.inputValue);
35
+ function ComboBoxFuzzy(originalProps) {
36
+ const [_props, variantProps] = utils.mapPropsVariants(
37
+ originalProps,
38
+ ouiTheme.comboBoxStyles.variantKeys
39
+ );
40
+ const {
41
+ items,
42
+ itemClassNames,
43
+ onSelectionChange: onSelectionChangeProp,
44
+ onInputChange: onInputChangeProp,
45
+ inputValue,
46
+ ...props
47
+ } = _props;
48
+ const deferredInputValue = react.useDeferredValue(inputValue);
40
49
  const preparedItems = react.useMemo(() => {
41
50
  return items?.map((item) => ({
42
51
  ...item,
43
- prepared: fuzzysort.prepare(item.name)
52
+ prepared: fuzzysort.prepare(item.textValue)
44
53
  })) ?? [];
45
54
  }, [items]);
46
55
  const [filteredResults, setFilteredResults] = react.useState({ items, result: {} });
@@ -63,7 +72,7 @@ function ComboBoxFuzzy({
63
72
  }).reduce(
64
73
  (acc, result) => {
65
74
  acc.items.push(result.obj);
66
- acc.result[result.obj.name] = result;
75
+ acc.result[result.obj.textValue] = result;
67
76
  return acc;
68
77
  },
69
78
  { items: [], result: {} }
@@ -72,34 +81,47 @@ function ComboBoxFuzzy({
72
81
  },
73
82
  [onInputChangeProp, preparedItems]
74
83
  );
84
+ const comboboxItemStyles = ouiTheme.comboBoxItemStyles(variantProps);
75
85
  return /* @__PURE__ */ jsxRuntime.jsx(
76
86
  comboBox.ComboBox,
77
87
  {
78
88
  ...props,
89
+ inputValue,
79
90
  items: filteredResults.items,
80
91
  dependencies: [deferredInputValue],
81
92
  onSelectionChange,
82
93
  onInputChange,
83
- children: (item) => /* @__PURE__ */ jsxRuntime.jsx(
84
- comboBox.ComboBoxItem,
85
- {
86
- classNames: itemClassNames,
87
- label: ({ isSelected, isFocused }) => /* @__PURE__ */ jsxRuntime.jsx(
88
- HighlightedText,
89
- {
90
- className: itemClassNames?.highlight,
91
- result: filteredResults.result?.[item.name],
92
- originalText: item.name,
93
- isSelected,
94
- isFocused
95
- }
96
- ),
97
- description: item.description,
98
- textValue: item.name,
99
- id: item.value
100
- },
101
- item.name
102
- )
94
+ children: (item) => /* @__PURE__ */ jsxRuntime.jsx(comboBoxItem.ComboBoxItem, { textValue: item.textValue, id: item.id, children: ({ isSelected, isFocused }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
95
+ /* @__PURE__ */ jsxRuntime.jsx(
96
+ reactAriaComponents.Text,
97
+ {
98
+ className: comboboxItemStyles.label({
99
+ className: itemClassNames?.label
100
+ }),
101
+ slot: "label",
102
+ children: /* @__PURE__ */ jsxRuntime.jsx(
103
+ HighlightedText,
104
+ {
105
+ className: itemClassNames?.highlight,
106
+ result: filteredResults.result?.[item.textValue],
107
+ originalText: item.textValue,
108
+ isSelected,
109
+ isFocused
110
+ }
111
+ )
112
+ }
113
+ ),
114
+ item.description && /* @__PURE__ */ jsxRuntime.jsx(
115
+ reactAriaComponents.Text,
116
+ {
117
+ className: comboboxItemStyles.description({
118
+ className: itemClassNames?.description
119
+ }),
120
+ slot: "description",
121
+ children: item.description
122
+ }
123
+ )
124
+ ] }) }, item.id)
103
125
  }
104
126
  );
105
127
  }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+ var reactAriaComponents = require('react-aria-components');
8
+ var ouiTheme = require('@opengovsg/oui-theme');
9
+ var utils = require('../system/utils.cjs');
10
+ var comboBoxVariantContext = require('./combo-box-variant-context.cjs');
11
+
12
+ const ComboBoxItem = utils.forwardRef(function ComboBoxItem2(originalProps, ref) {
13
+ [originalProps, ref] = reactAriaComponents.useContextProps(
14
+ originalProps,
15
+ ref,
16
+ comboBoxVariantContext.ComboBoxVariantContext
17
+ );
18
+ const [
19
+ { className, description, children, classNames, ...props },
20
+ variantProps
21
+ ] = utils.mapPropsVariants(originalProps, ouiTheme.comboBoxItemStyles.variantKeys);
22
+ const styles = ouiTheme.comboBoxItemStyles(variantProps);
23
+ const defaultTextValue = react.useMemo(() => {
24
+ if (props.textValue) {
25
+ return props.textValue;
26
+ }
27
+ if (typeof children === "string") {
28
+ return children;
29
+ }
30
+ return void 0;
31
+ }, [children, props.textValue]);
32
+ return /* @__PURE__ */ jsxRuntime.jsx(
33
+ reactAriaComponents.ListBoxItem,
34
+ {
35
+ textValue: defaultTextValue,
36
+ ...props,
37
+ className: reactAriaComponents.composeRenderProps(
38
+ className ?? classNames?.container,
39
+ (className2, renderProps) => styles.container({ ...renderProps, className: className2 })
40
+ ),
41
+ children: (renderProps) => {
42
+ if (typeof children === "function") {
43
+ return children(renderProps);
44
+ }
45
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
46
+ /* @__PURE__ */ jsxRuntime.jsx(
47
+ reactAriaComponents.Text,
48
+ {
49
+ className: styles.label({ className: classNames?.label }),
50
+ slot: "label",
51
+ children
52
+ }
53
+ ),
54
+ description && /* @__PURE__ */ jsxRuntime.jsx(
55
+ reactAriaComponents.Text,
56
+ {
57
+ className: styles.description({
58
+ className: classNames?.description
59
+ }),
60
+ slot: "description",
61
+ children: description
62
+ }
63
+ )
64
+ ] });
65
+ }
66
+ }
67
+ );
68
+ });
69
+
70
+ exports.ComboBoxItem = ComboBoxItem;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ "use client";
3
+ 'use strict';
4
+
5
+ var context = require('../system/react-utils/context.cjs');
6
+
7
+ const [ComboBoxVariantContext, useComboBoxVariantContext] = context.createContext({
8
+ name: "ComboBoxVariantContext",
9
+ strict: true
10
+ });
11
+
12
+ exports.ComboBoxVariantContext = ComboBoxVariantContext;
13
+ exports.useComboBoxVariantContext = useComboBoxVariantContext;
@@ -7,6 +7,8 @@ var react = require('react');
7
7
  var reactAria = require('react-aria');
8
8
  var reactAriaComponents = require('react-aria-components');
9
9
  var ouiTheme = require('@opengovsg/oui-theme');
10
+ var utils = require('../system/utils.cjs');
11
+ var comboBoxVariantContext = require('./combo-box-variant-context.cjs');
10
12
  var field = require('../field/field.cjs');
11
13
  var chevronUp = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs');
12
14
  var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs');
@@ -56,38 +58,43 @@ function ComboBoxEmptyState({
56
58
  }
57
59
  );
58
60
  }
59
- function ComboBox({
60
- label,
61
- description,
62
- errorMessage,
63
- classNames,
64
- itemClassNames,
65
- size,
66
- listLayoutOptions,
67
- children,
68
- dependencies,
69
- onClear,
70
- renderEmptyState: renderEmptyStateProp,
71
- ...props
72
- }) {
61
+ function ComboBox(originalProps) {
73
62
  const formatMessage = reactAria.useMessageFormatter(i18nStrings);
74
- const styles = ouiTheme.comboBoxStyles({ size });
63
+ const [_props, variantProps] = utils.mapPropsVariants(
64
+ originalProps,
65
+ ouiTheme.comboBoxStyles.variantKeys
66
+ );
67
+ const {
68
+ label,
69
+ description,
70
+ errorMessage,
71
+ classNames,
72
+ listLayoutOptions,
73
+ children,
74
+ dependencies,
75
+ onClear,
76
+ renderEmptyState: renderEmptyStateProp,
77
+ ...props
78
+ } = _props;
79
+ const styles = ouiTheme.comboBoxStyles(variantProps);
75
80
  const layout = react.useMemo(() => {
76
81
  return new reactAriaComponents.ListLayout({
77
- estimatedRowHeight: calculateEstimatedRowHeight(size ?? "md"),
82
+ estimatedRowHeight: calculateEstimatedRowHeight(
83
+ variantProps.size ?? "md"
84
+ ),
78
85
  ...listLayoutOptions
79
86
  });
80
- }, [listLayoutOptions, size]);
87
+ }, [listLayoutOptions, variantProps.size]);
81
88
  const renderEmptyState = react.useCallback(
82
89
  (props2) => {
83
90
  if (renderEmptyStateProp) {
84
91
  return renderEmptyStateProp(props2);
85
92
  }
86
- return /* @__PURE__ */ jsxRuntime.jsx(ComboBoxEmptyState, { size, className: classNames?.emptyState });
93
+ return /* @__PURE__ */ jsxRuntime.jsx(ComboBoxEmptyState, { className: classNames?.emptyState });
87
94
  },
88
- [classNames?.emptyState, renderEmptyStateProp, size]
95
+ [classNames?.emptyState, renderEmptyStateProp]
89
96
  );
90
- return /* @__PURE__ */ jsxRuntime.jsx(
97
+ return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Provider, { values: [[comboBoxVariantContext.ComboBoxVariantContext, variantProps]], children: /* @__PURE__ */ jsxRuntime.jsx(
91
98
  reactAriaComponents.ComboBox,
92
99
  {
93
100
  className: ouiTheme.composeTailwindRenderProps(
@@ -96,13 +103,14 @@ function ComboBox({
96
103
  ),
97
104
  shouldFocusWrap: true,
98
105
  allowsEmptyCollection: true,
106
+ isDisabled: variantProps.isDisabled,
99
107
  ...props,
100
108
  children: ({ isOpen, isDisabled: isComboBoxDisabled }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
101
109
  /* @__PURE__ */ jsxRuntime.jsx(
102
110
  field.Label,
103
111
  {
104
- size,
105
- className: styles.label({ className: classNames?.label, size }),
112
+ size: variantProps.size,
113
+ className: styles.label({ className: classNames?.label }),
106
114
  children: label
107
115
  }
108
116
  ),
@@ -110,12 +118,12 @@ function ComboBox({
110
118
  /* @__PURE__ */ jsxRuntime.jsxs(
111
119
  field.FieldGroup,
112
120
  {
121
+ isDisabled: isComboBoxDisabled,
113
122
  className: ouiTheme.composeRenderProps(
114
123
  classNames?.group,
115
124
  (className, renderProps) => styles.group({
116
125
  ...renderProps,
117
126
  className,
118
- size,
119
127
  isClearable: !!onClear
120
128
  })
121
129
  ),
@@ -125,7 +133,7 @@ function ComboBox({
125
133
  {
126
134
  className: ouiTheme.composeRenderProps(
127
135
  classNames?.field,
128
- (className, renderProps) => styles.field({ ...renderProps, className, size })
136
+ (className, renderProps) => styles.field({ ...renderProps, className })
129
137
  )
130
138
  }
131
139
  ),
@@ -134,22 +142,20 @@ function ComboBox({
134
142
  {
135
143
  className: ouiTheme.composeRenderProps(
136
144
  classNames?.expandButton,
137
- (className, renderProps) => styles.expandButton({ ...renderProps, className, size })
145
+ (className, renderProps) => styles.expandButton({ ...renderProps, className })
138
146
  ),
139
147
  children: isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
140
148
  chevronUp.default,
141
149
  {
142
150
  className: styles.icon({
143
- className: classNames?.icon,
144
- size
151
+ className: classNames?.icon
145
152
  })
146
153
  }
147
154
  ) : /* @__PURE__ */ jsxRuntime.jsx(
148
155
  chevronDown.default,
149
156
  {
150
157
  className: styles.icon({
151
- className: classNames?.icon,
152
- size
158
+ className: classNames?.icon
153
159
  })
154
160
  }
155
161
  )
@@ -168,35 +174,33 @@ function ComboBox({
168
174
  className: ouiTheme.composeRenderProps(
169
175
  classNames?.clearButton,
170
176
  (className, renderProps) => ouiTheme.comboBoxClearButtonStyles({
177
+ ...variantProps,
171
178
  ...renderProps,
172
179
  className,
173
- size,
174
- isInactive: !props.inputValue,
175
- isDisabled: renderProps.isDisabled
180
+ isInactive: !props.inputValue
176
181
  })
177
182
  ),
178
183
  children: /* @__PURE__ */ jsxRuntime.jsx(
179
184
  x.default,
180
185
  {
181
186
  className: styles.icon({
182
- className: classNames?.icon,
183
- size
187
+ className: classNames?.icon
184
188
  })
185
189
  }
186
190
  )
187
191
  }
188
192
  )
189
193
  ] }),
190
- description && /* @__PURE__ */ jsxRuntime.jsx(field.Description, { size, children: description }),
191
- /* @__PURE__ */ jsxRuntime.jsx(field.FieldError, { size, children: errorMessage }),
192
- /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Virtualizer, { layout, children: /* @__PURE__ */ jsxRuntime.jsx(
194
+ description && /* @__PURE__ */ jsxRuntime.jsx(field.Description, { size: variantProps.size, children: description }),
195
+ /* @__PURE__ */ jsxRuntime.jsx(field.FieldError, { size: variantProps.size, children: errorMessage }),
196
+ /* @__PURE__ */ jsxRuntime.jsx(
193
197
  reactAriaComponents.Popover,
194
198
  {
195
199
  className: ouiTheme.composeRenderProps(
196
200
  classNames?.popover,
197
201
  (className, renderProps) => styles.popover({ ...renderProps, className })
198
202
  ),
199
- children: /* @__PURE__ */ jsxRuntime.jsx(
203
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Virtualizer, { layout, children: /* @__PURE__ */ jsxRuntime.jsx(
200
204
  reactAriaComponents.ListBox,
201
205
  {
202
206
  className: ouiTheme.composeRenderProps(
@@ -205,73 +209,15 @@ function ComboBox({
205
209
  ),
206
210
  dependencies,
207
211
  renderEmptyState,
208
- children: (item) => {
209
- if (children) {
210
- return children(item);
211
- }
212
- return /* @__PURE__ */ jsxRuntime.jsx(
213
- ComboBoxItem,
214
- {
215
- size,
216
- id: item.value,
217
- label: item.name,
218
- textValue: item.name,
219
- description: item.description,
220
- classNames: itemClassNames
221
- }
222
- );
223
- }
212
+ children
224
213
  }
225
- )
214
+ ) })
226
215
  }
227
- ) })
216
+ )
228
217
  ] })
229
218
  }
230
- );
231
- }
232
- function ComboBoxItem({
233
- className,
234
- size,
235
- description,
236
- label,
237
- classNames,
238
- ...props
239
- }) {
240
- const styles = ouiTheme.comboBoxItemStyles({ size });
241
- return /* @__PURE__ */ jsxRuntime.jsx(
242
- reactAriaComponents.ListBoxItem,
243
- {
244
- ...props,
245
- className: ouiTheme.composeRenderProps(
246
- className ?? classNames?.container,
247
- (className2, renderProps) => styles.container({ ...renderProps, className: className2 })
248
- ),
249
- children: (renderProps) => {
250
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
251
- /* @__PURE__ */ jsxRuntime.jsx(
252
- reactAriaComponents.Text,
253
- {
254
- className: styles.label({ className: classNames?.label }),
255
- slot: "label",
256
- children: typeof label === "function" ? label(renderProps) : label
257
- }
258
- ),
259
- description && /* @__PURE__ */ jsxRuntime.jsx(
260
- reactAriaComponents.Text,
261
- {
262
- className: styles.description({
263
- className: classNames?.description
264
- }),
265
- slot: "description",
266
- children: typeof description === "function" ? description(renderProps) : description
267
- }
268
- )
269
- ] });
270
- }
271
- }
272
- );
219
+ ) });
273
220
  }
274
221
 
275
222
  exports.ComboBox = ComboBox;
276
223
  exports.ComboBoxEmptyState = ComboBoxEmptyState;
277
- exports.ComboBoxItem = ComboBoxItem;
@@ -3,10 +3,14 @@
3
3
 
4
4
  var comboBox = require('./combo-box.cjs');
5
5
  var comboBoxFuzzy = require('./combo-box-fuzzy.cjs');
6
+ var comboBoxItem = require('./combo-box-item.cjs');
7
+ var comboBoxVariantContext = require('./combo-box-variant-context.cjs');
6
8
 
7
9
 
8
10
 
9
11
  exports.ComboBox = comboBox.ComboBox;
10
12
  exports.ComboBoxEmptyState = comboBox.ComboBoxEmptyState;
11
- exports.ComboBoxItem = comboBox.ComboBoxItem;
12
13
  exports.ComboBoxFuzzy = comboBoxFuzzy.ComboBoxFuzzy;
14
+ exports.ComboBoxItem = comboBoxItem.ComboBoxItem;
15
+ exports.ComboBoxVariantContext = comboBoxVariantContext.ComboBoxVariantContext;
16
+ exports.useComboBoxVariantContext = comboBoxVariantContext.useComboBoxVariantContext;