@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.
- package/dist/cjs/badge/badge.cjs +42 -0
- package/dist/cjs/badge/index.cjs +8 -0
- package/dist/cjs/badge/use-badge.cjs +111 -0
- package/dist/cjs/calendar/calendar-base.cjs +347 -0
- package/dist/cjs/calendar/calendar-style-context.cjs +38 -0
- package/dist/cjs/calendar/calendar.cjs +16 -0
- package/dist/cjs/calendar/index.cjs +22 -0
- package/dist/cjs/calendar/types.cjs +3 -0
- package/dist/cjs/calendar/utils.cjs +62 -0
- 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 +30 -1
- 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
- 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
- package/dist/cjs/select/index.cjs +5 -0
- package/dist/cjs/select/select-item.cjs +12 -24
- package/dist/cjs/select/select-variant-context.cjs +1 -0
- package/dist/cjs/select/select.cjs +14 -6
- package/dist/cjs/system/react-utils/index.cjs +2 -0
- package/dist/cjs/system/react-utils/refs.cjs +12 -0
- package/dist/cjs/system/utils.cjs +9 -6
- package/dist/cjs/tag-field/index.cjs +2 -0
- package/dist/cjs/tag-field/tag-field-item.cjs +28 -0
- package/dist/cjs/tag-field/tag-field-list.cjs +11 -21
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -2
- package/dist/cjs/tag-field/tag-field-trigger.cjs +1 -0
- package/dist/cjs/tag-field/tag-field.cjs +2 -1
- package/dist/esm/badge/badge.js +40 -0
- package/dist/esm/badge/index.js +2 -0
- package/dist/esm/badge/use-badge.js +109 -0
- package/dist/esm/calendar/calendar-base.js +343 -0
- package/dist/esm/calendar/calendar-style-context.js +34 -0
- package/dist/esm/calendar/calendar.js +14 -0
- package/dist/esm/calendar/index.js +5 -0
- package/dist/esm/calendar/types.js +1 -0
- package/dist/esm/calendar/utils.js +57 -0
- 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 +11 -1
- 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
- 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
- package/dist/esm/select/index.js +2 -0
- package/dist/esm/select/select-item.js +13 -25
- package/dist/esm/select/select-variant-context.js +1 -0
- package/dist/esm/select/select.js +15 -7
- package/dist/esm/system/react-utils/index.js +1 -0
- package/dist/esm/system/react-utils/refs.js +10 -0
- package/dist/esm/system/utils.js +9 -6
- package/dist/esm/tag-field/index.js +1 -0
- package/dist/esm/tag-field/tag-field-item.js +26 -0
- package/dist/esm/tag-field/tag-field-list.js +12 -21
- package/dist/esm/tag-field/tag-field-tag-list.js +3 -2
- package/dist/esm/tag-field/tag-field-trigger.js +1 -0
- package/dist/esm/tag-field/tag-field.js +3 -2
- package/dist/types/badge/badge.d.ts +3 -0
- package/dist/types/badge/badge.d.ts.map +1 -0
- package/dist/types/badge/index.d.ts +2 -0
- package/dist/types/badge/index.d.ts.map +1 -0
- package/dist/types/badge/use-badge.d.ts +166 -0
- package/dist/types/badge/use-badge.d.ts.map +1 -0
- package/dist/types/button/button.d.ts +5 -0
- package/dist/types/button/button.d.ts.map +1 -1
- package/dist/types/calendar/calendar-base.d.ts +14 -0
- package/dist/types/calendar/calendar-base.d.ts.map +1 -0
- package/dist/types/calendar/calendar-style-context.d.ts +1032 -0
- package/dist/types/calendar/calendar-style-context.d.ts.map +1 -0
- package/dist/types/calendar/calendar.d.ts +5 -0
- package/dist/types/calendar/calendar.d.ts.map +1 -0
- package/dist/types/calendar/index.d.ts +6 -0
- package/dist/types/calendar/index.d.ts.map +1 -0
- package/dist/types/calendar/types.d.ts +58 -0
- package/dist/types/calendar/types.d.ts.map +1 -0
- package/dist/types/calendar/utils.d.ts +13 -0
- package/dist/types/calendar/utils.d.ts.map +1 -0
- 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/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/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.map +1 -1
- package/dist/types/select/select-variant-context.d.ts.map +1 -1
- package/dist/types/select/select.d.ts.map +1 -1
- package/dist/types/system/react-utils/index.d.ts +1 -0
- package/dist/types/system/react-utils/index.d.ts.map +1 -1
- package/dist/types/system/react-utils/refs.d.ts +4 -0
- package/dist/types/system/react-utils/refs.d.ts.map +1 -0
- package/dist/types/system/utils.d.ts.map +1 -1
- package/dist/types/tag-field/index.d.ts +1 -0
- package/dist/types/tag-field/index.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-item.d.ts +7 -0
- package/dist/types/tag-field/tag-field-item.d.ts.map +1 -0
- package/dist/types/tag-field/tag-field-list.d.ts +5 -9
- package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-root.d.ts +4 -4
- package/dist/types/tag-field/tag-field-root.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-state-context.d.ts +1 -2
- package/dist/types/tag-field/tag-field-state-context.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-tag-list.d.ts +2 -3
- package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-trigger.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field.d.ts +2 -2
- package/dist/types/tag-field/tag-field.d.ts.map +1 -1
- package/dist/types/tag-field/types.d.ts +6 -9
- package/dist/types/tag-field/types.d.ts.map +1 -1
- package/package.json +8 -6
- 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
|
@@ -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;
|
|
@@ -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
|
|
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,19 @@ 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');
|
|
24
|
+
var tagFieldItem = require('./tag-field/tag-field-item.cjs');
|
|
22
25
|
var select = require('./select/select.cjs');
|
|
26
|
+
var selectItem = require('./select/select-item.cjs');
|
|
27
|
+
var selectVariantContext = require('./select/select-variant-context.cjs');
|
|
28
|
+
var badge = require('./badge/badge.cjs');
|
|
29
|
+
var date = require('@internationalized/date');
|
|
30
|
+
var calendar = require('./calendar/calendar.cjs');
|
|
31
|
+
var calendarStyleContext = require('./calendar/calendar-style-context.cjs');
|
|
32
|
+
var utils = require('./calendar/utils.cjs');
|
|
23
33
|
|
|
24
34
|
|
|
25
35
|
|
|
@@ -42,8 +52,27 @@ exports.TextArea = textArea.TextArea;
|
|
|
42
52
|
exports.TextAreaField = textAreaField.TextAreaField;
|
|
43
53
|
exports.ComboBox = comboBox.ComboBox;
|
|
44
54
|
exports.ComboBoxEmptyState = comboBox.ComboBoxEmptyState;
|
|
45
|
-
exports.ComboBoxItem = comboBox.ComboBoxItem;
|
|
46
55
|
exports.ComboBoxFuzzy = comboBoxFuzzy.ComboBoxFuzzy;
|
|
56
|
+
exports.ComboBoxItem = comboBoxItem.ComboBoxItem;
|
|
57
|
+
exports.ComboBoxVariantContext = comboBoxVariantContext.ComboBoxVariantContext;
|
|
58
|
+
exports.useComboBoxVariantContext = comboBoxVariantContext.useComboBoxVariantContext;
|
|
47
59
|
exports.Banner = banner.Banner;
|
|
48
60
|
exports.TagField = tagField.TagField;
|
|
61
|
+
exports.TagFieldItem = tagFieldItem.TagFieldItem;
|
|
49
62
|
exports.Select = select.Select;
|
|
63
|
+
exports.SelectItem = selectItem.SelectItem;
|
|
64
|
+
exports.SelectVariantContext = selectVariantContext.SelectVariantContext;
|
|
65
|
+
exports.useSelectVariantContext = selectVariantContext.useSelectVariantContext;
|
|
66
|
+
exports.Badge = badge.Badge;
|
|
67
|
+
Object.defineProperty(exports, "CalendarDate", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () { return date.CalendarDate; }
|
|
70
|
+
});
|
|
71
|
+
exports.Calendar = calendar.Calendar;
|
|
72
|
+
exports.CalendarStyleContext = calendarStyleContext.CalendarStyleContext;
|
|
73
|
+
exports.useCalendarStyleContext = calendarStyleContext.useCalendarStyleContext;
|
|
74
|
+
exports.useProvideCalendarStyles = calendarStyleContext.useProvideCalendarStyles;
|
|
75
|
+
exports.getEraFormat = utils.getEraFormat;
|
|
76
|
+
exports.useGenerateLocalizedMonths = utils.useGenerateLocalizedMonths;
|
|
77
|
+
exports.useGenerateLocalizedYears = utils.useGenerateLocalizedYears;
|
|
78
|
+
exports.useLocalizedMonthYear = utils.useLocalizedMonthYear;
|
|
@@ -12,8 +12,8 @@ var createLucideIcon = require('../createLucideIcon.cjs');
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
const __iconNode = [["path", { d: "
|
|
16
|
-
const
|
|
15
|
+
const __iconNode = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
|
|
16
|
+
const ChevronLeft = createLucideIcon.default("ChevronLeft", __iconNode);
|
|
17
17
|
|
|
18
18
|
exports.__iconNode = __iconNode;
|
|
19
|
-
exports.default =
|
|
19
|
+
exports.default = ChevronLeft;
|
|
@@ -12,11 +12,8 @@ var createLucideIcon = require('../createLucideIcon.cjs');
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
const __iconNode = [
|
|
16
|
-
|
|
17
|
-
["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
|
|
18
|
-
];
|
|
19
|
-
const ChevronsUpDown = createLucideIcon.default("ChevronsUpDown", __iconNode);
|
|
15
|
+
const __iconNode = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
|
|
16
|
+
const ChevronRight = createLucideIcon.default("ChevronRight", __iconNode);
|
|
20
17
|
|
|
21
18
|
exports.__iconNode = __iconNode;
|
|
22
|
-
exports.default =
|
|
19
|
+
exports.default = ChevronRight;
|
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
4
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -6,7 +7,6 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
6
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
7
8
|
var utils = require('../system/utils.cjs');
|
|
8
9
|
var selectVariantContext = require('./select-variant-context.cjs');
|
|
9
|
-
var check = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.cjs');
|
|
10
10
|
|
|
11
11
|
const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
|
|
12
12
|
[originalProps, ref] = reactAriaComponents.useContextProps(
|
|
@@ -22,6 +22,7 @@ const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...origin
|
|
|
22
22
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
23
23
|
reactAriaComponents.ListBoxItem,
|
|
24
24
|
{
|
|
25
|
+
textValue: typeof props.children === "string" ? props.children : void 0,
|
|
25
26
|
...props,
|
|
26
27
|
ref,
|
|
27
28
|
className: ouiTheme.composeRenderProps(
|
|
@@ -32,29 +33,16 @@ const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...origin
|
|
|
32
33
|
if (typeof props.children === "function") {
|
|
33
34
|
return props.children(renderProps);
|
|
34
35
|
}
|
|
35
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
className:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
),
|
|
46
|
-
renderProps.isSelected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
-
"span",
|
|
48
|
-
{
|
|
49
|
-
"aria-hidden": true,
|
|
50
|
-
className: styles.icon({
|
|
51
|
-
className: classNames?.icon,
|
|
52
|
-
...renderProps
|
|
53
|
-
}),
|
|
54
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(check.default, {})
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
] });
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37
|
+
"span",
|
|
38
|
+
{
|
|
39
|
+
className: styles.text({
|
|
40
|
+
className: classNames?.text,
|
|
41
|
+
...renderProps
|
|
42
|
+
}),
|
|
43
|
+
children: props.children
|
|
44
|
+
}
|
|
45
|
+
);
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
48
|
);
|