@opengovsg/oui 0.0.6 → 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.
- 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/banner/banner.cjs +1 -1
- package/dist/cjs/button/button.cjs +1 -1
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +53 -31
- 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 +47 -101
- package/dist/cjs/combo-box/index.cjs +5 -1
- package/dist/cjs/field/field.cjs +1 -1
- package/dist/cjs/govt-banner/govt-banner.cjs +1 -1
- package/dist/cjs/index.cjs +16 -3
- package/dist/cjs/input/input.cjs +1 -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 +19 -0
- 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 +22 -0
- package/dist/cjs/select/index.cjs +13 -0
- package/dist/cjs/select/select-item.cjs +64 -0
- package/dist/cjs/select/select-variant-context.cjs +13 -0
- package/dist/cjs/select/select.cjs +103 -0
- package/dist/cjs/spinner/use-spinner.cjs +1 -1
- package/dist/cjs/system/react-utils/context.cjs +1 -5
- package/dist/cjs/system/react-utils/index.cjs +2 -0
- package/dist/cjs/system/react-utils/refs.cjs +12 -0
- package/dist/cjs/tag-field/tag-field-list.cjs +4 -3
- package/dist/cjs/tag-field/tag-field-trigger.cjs +1 -0
- package/dist/cjs/tag-field/tag-field.cjs +2 -2
- package/dist/cjs/tag-field/use-tag-field.cjs +1 -0
- package/dist/cjs/text-area/text-area.cjs +1 -1
- package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
- package/dist/cjs/text-field/text-field.cjs +1 -1
- package/dist/cjs/toggle/toggle.cjs +1 -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/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 +49 -102
- package/dist/esm/combo-box/index.js +3 -1
- package/dist/esm/field/field.js +1 -1
- package/dist/esm/govt-banner/govt-banner.js +1 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/input/input.js +1 -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 +14 -0
- 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 +17 -0
- package/dist/esm/select/index.js +4 -0
- package/dist/esm/select/select-item.js +62 -0
- package/dist/esm/select/select-variant-context.js +10 -0
- package/dist/esm/select/select.js +101 -0
- package/dist/esm/spinner/use-spinner.js +1 -1
- package/dist/esm/system/react-utils/context.js +1 -5
- package/dist/esm/system/react-utils/index.js +1 -0
- package/dist/esm/system/react-utils/refs.js +10 -0
- package/dist/esm/tag-field/tag-field-list.js +4 -3
- package/dist/esm/tag-field/tag-field-trigger.js +1 -0
- package/dist/esm/tag-field/tag-field.js +2 -2
- package/dist/esm/tag-field/use-tag-field.js +1 -0
- package/dist/esm/text-area/text-area.js +1 -1
- package/dist/esm/text-area-field/text-area-field.js +1 -1
- package/dist/esm/text-field/text-field.js +1 -1
- package/dist/esm/toggle/toggle.js +1 -1
- 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/banner/banner.d.ts +4 -3
- package/dist/types/banner/banner.d.ts.map +1 -1
- package/dist/types/button/button.d.ts +2 -11
- package/dist/types/button/button.d.ts.map +1 -1
- package/dist/types/combo-box/combo-box-fuzzy.d.ts +14 -5
- 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/field/field.d.ts +2 -2
- package/dist/types/field/field.d.ts.map +1 -1
- package/dist/types/govt-banner/govt-banner.d.ts +1 -1
- package/dist/types/govt-banner/govt-banner.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/input/input.d.ts +3 -2
- package/dist/types/input/input.d.ts.map +1 -1
- package/dist/types/select/index.d.ts +4 -0
- package/dist/types/select/index.d.ts.map +1 -0
- package/dist/types/select/select-item.d.ts +9 -0
- package/dist/types/select/select-item.d.ts.map +1 -0
- 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 +17 -0
- package/dist/types/select/select.d.ts.map +1 -0
- package/dist/types/skip-nav-link/skip-nav-link.d.ts +3 -2
- package/dist/types/skip-nav-link/skip-nav-link.d.ts.map +1 -1
- package/dist/types/spinner/use-spinner.d.ts +1 -1
- package/dist/types/spinner/use-spinner.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/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/types.d.ts +1 -1
- package/dist/types/system/types.d.ts.map +1 -1
- package/dist/types/system/utils.d.ts +2 -2
- package/dist/types/system/utils.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-list.d.ts +10 -10
- package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-root.d.ts +6 -6
- package/dist/types/tag-field/tag-field-root.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-state-context.d.ts +2 -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 +4 -5
- package/dist/types/tag-field/tag-field-tag-list.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-trigger.d.ts +2 -2
- 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 +2 -7
- package/dist/types/tag-field/types.d.ts.map +1 -1
- package/dist/types/tag-field/use-tag-field-state.d.ts +4 -4
- package/dist/types/tag-field/use-tag-field-state.d.ts.map +1 -1
- package/dist/types/tag-field/use-tag-field.d.ts +7 -7
- package/dist/types/tag-field/use-tag-field.d.ts.map +1 -1
- package/dist/types/text-area/text-area.d.ts +3 -2
- package/dist/types/text-area/text-area.d.ts.map +1 -1
- package/dist/types/text-area-field/text-area-field.d.ts +3 -3
- package/dist/types/text-area-field/text-area-field.d.ts.map +1 -1
- package/dist/types/text-field/text-field.d.ts +3 -3
- package/dist/types/text-field/text-field.d.ts.map +1 -1
- package/dist/types/toggle/toggle.d.ts +3 -2
- package/dist/types/toggle/toggle.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useDeferredValue, useMemo, useState, useCallback } from 'react';
|
|
5
|
-
import { comboBoxFuzzyHighlightedTextStyles } from '@opengovsg/oui-theme';
|
|
6
5
|
import fuzzysort from 'fuzzysort';
|
|
7
|
-
import {
|
|
6
|
+
import { Text } from 'react-aria-components';
|
|
7
|
+
import { comboBoxStyles, comboBoxItemStyles, comboBoxFuzzyHighlightedTextStyles } from '@opengovsg/oui-theme';
|
|
8
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
9
|
+
import { ComboBox } from './combo-box.js';
|
|
10
|
+
import { ComboBoxItem } from './combo-box-item.js';
|
|
8
11
|
|
|
9
12
|
function HighlightedText({
|
|
10
13
|
result,
|
|
@@ -27,18 +30,24 @@ function HighlightedText({
|
|
|
27
30
|
i
|
|
28
31
|
));
|
|
29
32
|
}
|
|
30
|
-
function ComboBoxFuzzy({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
function ComboBoxFuzzy(originalProps) {
|
|
34
|
+
const [_props, variantProps] = mapPropsVariants(
|
|
35
|
+
originalProps,
|
|
36
|
+
comboBoxStyles.variantKeys
|
|
37
|
+
);
|
|
38
|
+
const {
|
|
39
|
+
items,
|
|
40
|
+
itemClassNames,
|
|
41
|
+
onSelectionChange: onSelectionChangeProp,
|
|
42
|
+
onInputChange: onInputChangeProp,
|
|
43
|
+
inputValue,
|
|
44
|
+
...props
|
|
45
|
+
} = _props;
|
|
46
|
+
const deferredInputValue = useDeferredValue(inputValue);
|
|
38
47
|
const preparedItems = useMemo(() => {
|
|
39
48
|
return items?.map((item) => ({
|
|
40
49
|
...item,
|
|
41
|
-
prepared: fuzzysort.prepare(item.
|
|
50
|
+
prepared: fuzzysort.prepare(item.textValue)
|
|
42
51
|
})) ?? [];
|
|
43
52
|
}, [items]);
|
|
44
53
|
const [filteredResults, setFilteredResults] = useState({ items, result: {} });
|
|
@@ -61,7 +70,7 @@ function ComboBoxFuzzy({
|
|
|
61
70
|
}).reduce(
|
|
62
71
|
(acc, result) => {
|
|
63
72
|
acc.items.push(result.obj);
|
|
64
|
-
acc.result[result.obj.
|
|
73
|
+
acc.result[result.obj.textValue] = result;
|
|
65
74
|
return acc;
|
|
66
75
|
},
|
|
67
76
|
{ items: [], result: {} }
|
|
@@ -70,34 +79,47 @@ function ComboBoxFuzzy({
|
|
|
70
79
|
},
|
|
71
80
|
[onInputChangeProp, preparedItems]
|
|
72
81
|
);
|
|
82
|
+
const comboboxItemStyles = comboBoxItemStyles(variantProps);
|
|
73
83
|
return /* @__PURE__ */ jsx(
|
|
74
84
|
ComboBox,
|
|
75
85
|
{
|
|
76
86
|
...props,
|
|
87
|
+
inputValue,
|
|
77
88
|
items: filteredResults.items,
|
|
78
89
|
dependencies: [deferredInputValue],
|
|
79
90
|
onSelectionChange,
|
|
80
91
|
onInputChange,
|
|
81
|
-
children: (item) => /* @__PURE__ */ jsx(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
children: (item) => /* @__PURE__ */ jsx(ComboBoxItem, { textValue: item.textValue, id: item.id, children: ({ isSelected, isFocused }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
93
|
+
/* @__PURE__ */ jsx(
|
|
94
|
+
Text,
|
|
95
|
+
{
|
|
96
|
+
className: comboboxItemStyles.label({
|
|
97
|
+
className: itemClassNames?.label
|
|
98
|
+
}),
|
|
99
|
+
slot: "label",
|
|
100
|
+
children: /* @__PURE__ */ jsx(
|
|
101
|
+
HighlightedText,
|
|
102
|
+
{
|
|
103
|
+
className: itemClassNames?.highlight,
|
|
104
|
+
result: filteredResults.result?.[item.textValue],
|
|
105
|
+
originalText: item.textValue,
|
|
106
|
+
isSelected,
|
|
107
|
+
isFocused
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
item.description && /* @__PURE__ */ jsx(
|
|
113
|
+
Text,
|
|
114
|
+
{
|
|
115
|
+
className: comboboxItemStyles.description({
|
|
116
|
+
className: itemClassNames?.description
|
|
117
|
+
}),
|
|
118
|
+
slot: "description",
|
|
119
|
+
children: item.description
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] }) }, item.id)
|
|
101
123
|
}
|
|
102
124
|
);
|
|
103
125
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { useContextProps, ListBoxItem, composeRenderProps, Text } from 'react-aria-components';
|
|
6
|
+
import { comboBoxItemStyles } from '@opengovsg/oui-theme';
|
|
7
|
+
import { forwardRef, mapPropsVariants } from '../system/utils.js';
|
|
8
|
+
import { ComboBoxVariantContext } from './combo-box-variant-context.js';
|
|
9
|
+
|
|
10
|
+
const ComboBoxItem = forwardRef(function ComboBoxItem2(originalProps, ref) {
|
|
11
|
+
[originalProps, ref] = useContextProps(
|
|
12
|
+
originalProps,
|
|
13
|
+
ref,
|
|
14
|
+
ComboBoxVariantContext
|
|
15
|
+
);
|
|
16
|
+
const [
|
|
17
|
+
{ className, description, children, classNames, ...props },
|
|
18
|
+
variantProps
|
|
19
|
+
] = mapPropsVariants(originalProps, comboBoxItemStyles.variantKeys);
|
|
20
|
+
const styles = comboBoxItemStyles(variantProps);
|
|
21
|
+
const defaultTextValue = useMemo(() => {
|
|
22
|
+
if (props.textValue) {
|
|
23
|
+
return props.textValue;
|
|
24
|
+
}
|
|
25
|
+
if (typeof children === "string") {
|
|
26
|
+
return children;
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}, [children, props.textValue]);
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
ListBoxItem,
|
|
32
|
+
{
|
|
33
|
+
textValue: defaultTextValue,
|
|
34
|
+
...props,
|
|
35
|
+
className: composeRenderProps(
|
|
36
|
+
className ?? classNames?.container,
|
|
37
|
+
(className2, renderProps) => styles.container({ ...renderProps, className: className2 })
|
|
38
|
+
),
|
|
39
|
+
children: (renderProps) => {
|
|
40
|
+
if (typeof children === "function") {
|
|
41
|
+
return children(renderProps);
|
|
42
|
+
}
|
|
43
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
Text,
|
|
46
|
+
{
|
|
47
|
+
className: styles.label({ className: classNames?.label }),
|
|
48
|
+
slot: "label",
|
|
49
|
+
children
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
description && /* @__PURE__ */ jsx(
|
|
53
|
+
Text,
|
|
54
|
+
{
|
|
55
|
+
className: styles.description({
|
|
56
|
+
className: classNames?.description
|
|
57
|
+
}),
|
|
58
|
+
slot: "description",
|
|
59
|
+
children: description
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export { ComboBoxItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [ComboBoxVariantContext, useComboBoxVariantContext] = createContext({
|
|
6
|
+
name: "ComboBoxVariantContext",
|
|
7
|
+
strict: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { ComboBoxVariantContext, useComboBoxVariantContext };
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useMemo, useCallback } from 'react';
|
|
5
|
-
import { comboBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
|
|
6
5
|
import { useMessageFormatter } from 'react-aria';
|
|
7
|
-
import { ListLayout, ComboBox as ComboBox$1, Input, Button,
|
|
6
|
+
import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Popover, Virtualizer, ListBox } from 'react-aria-components';
|
|
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
|
|
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(
|
|
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, {
|
|
91
|
+
return /* @__PURE__ */ jsx(ComboBoxEmptyState, { className: classNames?.emptyState });
|
|
85
92
|
},
|
|
86
|
-
[classNames?.emptyState, renderEmptyStateProp
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
|
220
|
+
export { ComboBox, ComboBoxEmptyState };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export { ComboBox, ComboBoxEmptyState
|
|
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/field/field.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { labelStyles, descriptionStyles, fieldErrorStyles, composeRenderProps, fieldGroupStyles } from '@opengovsg/oui-theme';
|
|
5
4
|
import { Label as Label$1, Text, FieldError as FieldError$1, Group } from 'react-aria-components';
|
|
5
|
+
import { labelStyles, descriptionStyles, fieldErrorStyles, composeRenderProps, fieldGroupStyles } from '@opengovsg/oui-theme';
|
|
6
6
|
import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
|
|
7
7
|
|
|
8
8
|
function Label({ size, className, ...props }) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useRef } from 'react';
|
|
5
|
-
import { govtBannerStyles, dataAttr, twMerge } from '@opengovsg/oui-theme';
|
|
6
5
|
import { useMessageFormatter, useDisclosure, useButton, useFocusRing, mergeProps } from 'react-aria';
|
|
7
6
|
import { useDisclosureState } from 'react-stately';
|
|
7
|
+
import { govtBannerStyles, dataAttr, twMerge } from '@opengovsg/oui-theme';
|
|
8
8
|
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';
|
|
9
9
|
import Landmark from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/landmark.js';
|
|
10
10
|
import ExternalLink from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/external-link.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
export { Input } from './input/input.js';
|
|
2
3
|
export { useControllableState } from './hooks/use-controllable-state.js';
|
|
3
4
|
export { Button } from './button/button.js';
|
|
4
5
|
export { GovtBanner } from './govt-banner/govt-banner.js';
|
|
@@ -8,12 +9,17 @@ export { Spinner } from './spinner/spinner.js';
|
|
|
8
9
|
export { useSpinner } from './spinner/use-spinner.js';
|
|
9
10
|
export { Toggle } from './toggle/toggle.js';
|
|
10
11
|
export { SkipNavLink } from './skip-nav-link/skip-nav-link.js';
|
|
11
|
-
export { Input } from './input/input.js';
|
|
12
12
|
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
|
|
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 { Select } from './select/select.js';
|
|
23
|
+
export { SelectItem } from './select/select-item.js';
|
|
24
|
+
export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
|
|
25
|
+
export { Badge } from './badge/badge.js';
|
package/dist/esm/input/input.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
|
-
import { composeRenderProps, inputStyles } from '@opengovsg/oui-theme';
|
|
6
5
|
import { Input as Input$1 } from 'react-aria-components';
|
|
6
|
+
import { composeRenderProps, inputStyles } from '@opengovsg/oui-theme';
|
|
7
7
|
|
|
8
8
|
const Input = forwardRef(
|
|
9
9
|
({ size, variant, isDisabled, ...props }, ref) => {
|
|
@@ -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: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
12
|
+
const Check = createLucideIcon("Check", __iconNode);
|
|
13
|
+
|
|
14
|
+
export { __iconNode, Check as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
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 = [
|
|
12
|
+
["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
|
|
13
|
+
["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
|
|
14
|
+
];
|
|
15
|
+
const ChevronsUpDown = createLucideIcon("ChevronsUpDown", __iconNode);
|
|
16
|
+
|
|
17
|
+
export { __iconNode, ChevronsUpDown as default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useContextProps, ListBoxItem } from 'react-aria-components';
|
|
5
|
+
import { selectItemStyles, composeRenderProps } from '@opengovsg/oui-theme';
|
|
6
|
+
import { forwardRef, mapPropsVariants } from '../system/utils.js';
|
|
7
|
+
import { SelectVariantContext } from './select-variant-context.js';
|
|
8
|
+
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js';
|
|
9
|
+
|
|
10
|
+
const SelectItem = forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
|
|
11
|
+
[originalProps, ref] = useContextProps(
|
|
12
|
+
originalProps,
|
|
13
|
+
ref,
|
|
14
|
+
SelectVariantContext
|
|
15
|
+
);
|
|
16
|
+
const [props, variantProps] = mapPropsVariants(
|
|
17
|
+
originalProps,
|
|
18
|
+
selectItemStyles.variantKeys
|
|
19
|
+
);
|
|
20
|
+
const styles = selectItemStyles(variantProps);
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
ListBoxItem,
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
ref,
|
|
26
|
+
className: composeRenderProps(
|
|
27
|
+
props.className ?? classNames?.base,
|
|
28
|
+
(className, renderProps) => styles.base({ className, ...renderProps })
|
|
29
|
+
),
|
|
30
|
+
children: (renderProps) => {
|
|
31
|
+
if (typeof props.children === "function") {
|
|
32
|
+
return props.children(renderProps);
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
"span",
|
|
37
|
+
{
|
|
38
|
+
className: styles.text({
|
|
39
|
+
className: classNames?.text,
|
|
40
|
+
...renderProps
|
|
41
|
+
}),
|
|
42
|
+
children: props.children
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
renderProps.isSelected && /* @__PURE__ */ jsx(
|
|
46
|
+
"span",
|
|
47
|
+
{
|
|
48
|
+
"aria-hidden": true,
|
|
49
|
+
className: styles.icon({
|
|
50
|
+
className: classNames?.icon,
|
|
51
|
+
...renderProps
|
|
52
|
+
}),
|
|
53
|
+
children: /* @__PURE__ */ jsx(Check, {})
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export { SelectItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [SelectVariantContext, useSelectVariantContext] = createContext({
|
|
6
|
+
name: "SelectVariantContext",
|
|
7
|
+
strict: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { SelectVariantContext, useSelectVariantContext };
|