@opengovsg/oui 0.0.0-snapshot-20250314033410 → 0.0.0-snapshot-20250318052429
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.
- package/dist/cjs/banner/banner.cjs +1 -1
- package/dist/cjs/button/button.cjs +1 -1
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +52 -30
- package/dist/cjs/combo-box/combo-box-item.cjs +70 -0
- package/dist/cjs/combo-box/combo-box-variant-context.cjs +13 -0
- package/dist/cjs/combo-box/combo-box.cjs +46 -100
- package/dist/cjs/combo-box/index.cjs +5 -1
- package/dist/cjs/index.cjs +10 -1
- package/dist/cjs/select/index.cjs +5 -0
- package/dist/cjs/select/select-item.cjs +38 -26
- package/dist/cjs/select/select-variant-context.cjs +13 -0
- package/dist/cjs/select/select.cjs +6 -19
- package/dist/cjs/system/react-utils/context.cjs +1 -5
- package/dist/cjs/tag-field/tag-field-list.cjs +1 -0
- package/dist/cjs/tag-field/tag-field-trigger.cjs +1 -0
- package/dist/cjs/tag-field/tag-field.cjs +2 -2
- package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
- package/dist/cjs/text-field/text-field.cjs +1 -1
- package/dist/esm/banner/banner.js +1 -1
- package/dist/esm/button/button.js +1 -1
- package/dist/esm/combo-box/combo-box-fuzzy.js +55 -33
- package/dist/esm/combo-box/combo-box-item.js +68 -0
- package/dist/esm/combo-box/combo-box-variant-context.js +10 -0
- package/dist/esm/combo-box/combo-box.js +48 -101
- package/dist/esm/combo-box/index.js +3 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/select/index.js +2 -0
- package/dist/esm/select/select-item.js +40 -28
- package/dist/esm/select/select-variant-context.js +10 -0
- package/dist/esm/select/select.js +8 -21
- package/dist/esm/system/react-utils/context.js +1 -5
- package/dist/esm/tag-field/tag-field-list.js +1 -0
- package/dist/esm/tag-field/tag-field-trigger.js +1 -0
- package/dist/esm/tag-field/tag-field.js +2 -2
- package/dist/esm/text-area-field/text-area-field.js +1 -1
- package/dist/esm/text-field/text-field.js +1 -1
- package/dist/types/combo-box/combo-box-fuzzy.d.ts +12 -4
- package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -1
- package/dist/types/combo-box/combo-box-item.d.ts +11 -0
- package/dist/types/combo-box/combo-box-item.d.ts.map +1 -0
- package/dist/types/combo-box/combo-box-variant-context.d.ts +4 -0
- package/dist/types/combo-box/combo-box-variant-context.d.ts.map +1 -0
- package/dist/types/combo-box/combo-box.d.ts +5 -21
- package/dist/types/combo-box/combo-box.d.ts.map +1 -1
- package/dist/types/combo-box/index.d.ts +2 -0
- package/dist/types/combo-box/index.d.ts.map +1 -1
- package/dist/types/select/index.d.ts +2 -0
- package/dist/types/select/index.d.ts.map +1 -1
- package/dist/types/select/select-item.d.ts +3 -3
- package/dist/types/select/select-item.d.ts.map +1 -1
- package/dist/types/select/select-variant-context.d.ts +4 -0
- package/dist/types/select/select-variant-context.d.ts.map +1 -0
- package/dist/types/select/select.d.ts +3 -10
- package/dist/types/select/select.d.ts.map +1 -1
- package/dist/types/system/react-utils/context.d.ts +1 -5
- package/dist/types/system/react-utils/context.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-trigger.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -7,9 +7,9 @@ var react = require('react');
|
|
|
7
7
|
var reactAria = require('react-aria');
|
|
8
8
|
var reactStately = require('react-stately');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
|
+
var button = require('../button/button.cjs');
|
|
10
11
|
var circleAlert = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/circle-alert.cjs');
|
|
11
12
|
var info = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/info.cjs');
|
|
12
|
-
var button = require('../button/button.cjs');
|
|
13
13
|
var x = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.cjs');
|
|
14
14
|
|
|
15
15
|
const i18nStrings = {
|
|
@@ -7,9 +7,9 @@ var react = require('react');
|
|
|
7
7
|
var utils = require('@react-aria/utils');
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
|
+
var ripple = require('../ripple/ripple.cjs');
|
|
10
11
|
var useRipple = require('../ripple/use-ripple.cjs');
|
|
11
12
|
var spinner = require('../spinner/spinner.cjs');
|
|
12
|
-
var ripple = require('../ripple/ripple.cjs');
|
|
13
13
|
|
|
14
14
|
const Button = react.forwardRef(
|
|
15
15
|
({
|
|
@@ -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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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;
|
|
@@ -8,6 +8,8 @@ var reactAria = require('react-aria');
|
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
10
|
var field = require('../field/field.cjs');
|
|
11
|
+
var utils = require('../system/utils.cjs');
|
|
12
|
+
var comboBoxVariantContext = require('./combo-box-variant-context.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');
|
|
13
15
|
var x = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.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
|
|
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(
|
|
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, {
|
|
93
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ComboBoxEmptyState, { className: classNames?.emptyState });
|
|
87
94
|
},
|
|
88
|
-
[classNames?.emptyState, renderEmptyStateProp
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
|
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;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -17,9 +17,13 @@ var textArea = require('./text-area/text-area.cjs');
|
|
|
17
17
|
var textAreaField = require('./text-area-field/text-area-field.cjs');
|
|
18
18
|
var comboBox = require('./combo-box/combo-box.cjs');
|
|
19
19
|
var comboBoxFuzzy = require('./combo-box/combo-box-fuzzy.cjs');
|
|
20
|
+
var comboBoxItem = require('./combo-box/combo-box-item.cjs');
|
|
21
|
+
var comboBoxVariantContext = require('./combo-box/combo-box-variant-context.cjs');
|
|
20
22
|
var banner = require('./banner/banner.cjs');
|
|
21
23
|
var tagField = require('./tag-field/tag-field.cjs');
|
|
22
24
|
var select = require('./select/select.cjs');
|
|
25
|
+
var selectItem = require('./select/select-item.cjs');
|
|
26
|
+
var selectVariantContext = require('./select/select-variant-context.cjs');
|
|
23
27
|
|
|
24
28
|
|
|
25
29
|
|
|
@@ -42,8 +46,13 @@ exports.TextArea = textArea.TextArea;
|
|
|
42
46
|
exports.TextAreaField = textAreaField.TextAreaField;
|
|
43
47
|
exports.ComboBox = comboBox.ComboBox;
|
|
44
48
|
exports.ComboBoxEmptyState = comboBox.ComboBoxEmptyState;
|
|
45
|
-
exports.ComboBoxItem = comboBox.ComboBoxItem;
|
|
46
49
|
exports.ComboBoxFuzzy = comboBoxFuzzy.ComboBoxFuzzy;
|
|
50
|
+
exports.ComboBoxItem = comboBoxItem.ComboBoxItem;
|
|
51
|
+
exports.ComboBoxVariantContext = comboBoxVariantContext.ComboBoxVariantContext;
|
|
52
|
+
exports.useComboBoxVariantContext = comboBoxVariantContext.useComboBoxVariantContext;
|
|
47
53
|
exports.Banner = banner.Banner;
|
|
48
54
|
exports.TagField = tagField.TagField;
|
|
49
55
|
exports.Select = select.Select;
|
|
56
|
+
exports.SelectItem = selectItem.SelectItem;
|
|
57
|
+
exports.SelectVariantContext = selectVariantContext.SelectVariantContext;
|
|
58
|
+
exports.useSelectVariantContext = selectVariantContext.useSelectVariantContext;
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var select = require('./select.cjs');
|
|
5
|
+
var selectItem = require('./select-item.cjs');
|
|
6
|
+
var selectVariantContext = require('./select-variant-context.cjs');
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
exports.Select = select.Select;
|
|
11
|
+
exports.SelectItem = selectItem.SelectItem;
|
|
12
|
+
exports.SelectVariantContext = selectVariantContext.SelectVariantContext;
|
|
13
|
+
exports.useSelectVariantContext = selectVariantContext.useSelectVariantContext;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
4
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
6
|
var reactAriaComponents = require('react-aria-components');
|
|
6
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
7
8
|
var utils = require('../system/utils.cjs');
|
|
9
|
+
var selectVariantContext = require('./select-variant-context.cjs');
|
|
8
10
|
var check = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.cjs');
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
|
|
13
|
+
[originalProps, ref] = reactAriaComponents.useContextProps(
|
|
14
|
+
originalProps,
|
|
15
|
+
ref,
|
|
16
|
+
selectVariantContext.SelectVariantContext
|
|
17
|
+
);
|
|
11
18
|
const [props, variantProps] = utils.mapPropsVariants(
|
|
12
19
|
originalProps,
|
|
13
20
|
ouiTheme.selectItemStyles.variantKeys
|
|
@@ -17,36 +24,41 @@ function SelectItem({ classNames, ...originalProps }) {
|
|
|
17
24
|
reactAriaComponents.ListBoxItem,
|
|
18
25
|
{
|
|
19
26
|
...props,
|
|
20
|
-
|
|
27
|
+
ref,
|
|
21
28
|
className: ouiTheme.composeRenderProps(
|
|
22
29
|
props.className ?? classNames?.base,
|
|
23
30
|
(className, renderProps) => styles.base({ className, ...renderProps })
|
|
24
31
|
),
|
|
25
|
-
children: (renderProps) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
children: (renderProps) => {
|
|
33
|
+
if (typeof props.children === "function") {
|
|
34
|
+
return props.children(renderProps);
|
|
35
|
+
}
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
37
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
"span",
|
|
39
|
+
{
|
|
40
|
+
className: styles.text({
|
|
41
|
+
className: classNames?.text,
|
|
42
|
+
...renderProps
|
|
43
|
+
}),
|
|
44
|
+
children: props.children
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
renderProps.isSelected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
"span",
|
|
49
|
+
{
|
|
50
|
+
"aria-hidden": true,
|
|
51
|
+
className: styles.icon({
|
|
52
|
+
className: classNames?.icon,
|
|
53
|
+
...renderProps
|
|
54
|
+
}),
|
|
55
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(check.default, {})
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
61
|
);
|
|
50
|
-
}
|
|
62
|
+
});
|
|
51
63
|
|
|
52
64
|
exports.SelectItem = SelectItem;
|
|
@@ -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 [SelectVariantContext, useSelectVariantContext] = context.createContext({
|
|
8
|
+
name: "SelectVariantContext",
|
|
9
|
+
strict: true
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
exports.SelectVariantContext = SelectVariantContext;
|
|
13
|
+
exports.useSelectVariantContext = useSelectVariantContext;
|