@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
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
7
|
var reactAria = require('react-aria');
|
|
9
8
|
var reactStately = require('react-stately');
|
|
9
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
10
|
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');
|
|
11
11
|
var landmark = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/landmark.cjs');
|
|
12
12
|
var externalLink = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/external-link.cjs');
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var input = require('./input/input.cjs');
|
|
4
5
|
var useControllableState = require('./hooks/use-controllable-state.cjs');
|
|
5
6
|
var button = require('./button/button.cjs');
|
|
6
7
|
var govtBanner = require('./govt-banner/govt-banner.cjs');
|
|
@@ -10,18 +11,24 @@ var spinner = require('./spinner/spinner.cjs');
|
|
|
10
11
|
var useSpinner = require('./spinner/use-spinner.cjs');
|
|
11
12
|
var toggle = require('./toggle/toggle.cjs');
|
|
12
13
|
var skipNavLink = require('./skip-nav-link/skip-nav-link.cjs');
|
|
13
|
-
var input = require('./input/input.cjs');
|
|
14
14
|
var textField = require('./text-field/text-field.cjs');
|
|
15
15
|
var field = require('./field/field.cjs');
|
|
16
16
|
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 select = require('./select/select.cjs');
|
|
25
|
+
var selectItem = require('./select/select-item.cjs');
|
|
26
|
+
var selectVariantContext = require('./select/select-variant-context.cjs');
|
|
27
|
+
var badge = require('./badge/badge.cjs');
|
|
22
28
|
|
|
23
29
|
|
|
24
30
|
|
|
31
|
+
exports.Input = input.Input;
|
|
25
32
|
exports.useControllableState = useControllableState.useControllableState;
|
|
26
33
|
exports.Button = button.Button;
|
|
27
34
|
exports.GovtBanner = govtBanner.GovtBanner;
|
|
@@ -31,7 +38,6 @@ exports.Spinner = spinner.Spinner;
|
|
|
31
38
|
exports.useSpinner = useSpinner.useSpinner;
|
|
32
39
|
exports.Toggle = toggle.Toggle;
|
|
33
40
|
exports.SkipNavLink = skipNavLink.SkipNavLink;
|
|
34
|
-
exports.Input = input.Input;
|
|
35
41
|
exports.TextField = textField.TextField;
|
|
36
42
|
exports.Description = field.Description;
|
|
37
43
|
exports.FieldError = field.FieldError;
|
|
@@ -41,7 +47,14 @@ exports.TextArea = textArea.TextArea;
|
|
|
41
47
|
exports.TextAreaField = textAreaField.TextAreaField;
|
|
42
48
|
exports.ComboBox = comboBox.ComboBox;
|
|
43
49
|
exports.ComboBoxEmptyState = comboBox.ComboBoxEmptyState;
|
|
44
|
-
exports.ComboBoxItem = comboBox.ComboBoxItem;
|
|
45
50
|
exports.ComboBoxFuzzy = comboBoxFuzzy.ComboBoxFuzzy;
|
|
51
|
+
exports.ComboBoxItem = comboBoxItem.ComboBoxItem;
|
|
52
|
+
exports.ComboBoxVariantContext = comboBoxVariantContext.ComboBoxVariantContext;
|
|
53
|
+
exports.useComboBoxVariantContext = comboBoxVariantContext.useComboBoxVariantContext;
|
|
46
54
|
exports.Banner = banner.Banner;
|
|
47
55
|
exports.TagField = tagField.TagField;
|
|
56
|
+
exports.Select = select.Select;
|
|
57
|
+
exports.SelectItem = selectItem.SelectItem;
|
|
58
|
+
exports.SelectVariantContext = selectVariantContext.SelectVariantContext;
|
|
59
|
+
exports.useSelectVariantContext = selectVariantContext.useSelectVariantContext;
|
|
60
|
+
exports.Badge = badge.Badge;
|
package/dist/cjs/input/input.cjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
9
|
|
|
10
10
|
const Input = react.forwardRef(
|
|
11
11
|
({ size, variant, isDisabled, ...props }, ref) => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var createLucideIcon = require('../createLucideIcon.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @license lucide-react v0.475.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
16
|
+
const Check = createLucideIcon.default("Check", __iconNode);
|
|
17
|
+
|
|
18
|
+
exports.__iconNode = __iconNode;
|
|
19
|
+
exports.default = Check;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var createLucideIcon = require('../createLucideIcon.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @license lucide-react v0.475.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const __iconNode = [
|
|
16
|
+
["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
|
|
17
|
+
["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
|
|
18
|
+
];
|
|
19
|
+
const ChevronsUpDown = createLucideIcon.default("ChevronsUpDown", __iconNode);
|
|
20
|
+
|
|
21
|
+
exports.__iconNode = __iconNode;
|
|
22
|
+
exports.default = ChevronsUpDown;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var select = require('./select.cjs');
|
|
5
|
+
var selectItem = require('./select-item.cjs');
|
|
6
|
+
var selectVariantContext = require('./select-variant-context.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.Select = select.Select;
|
|
11
|
+
exports.SelectItem = selectItem.SelectItem;
|
|
12
|
+
exports.SelectVariantContext = selectVariantContext.SelectVariantContext;
|
|
13
|
+
exports.useSelectVariantContext = selectVariantContext.useSelectVariantContext;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
+
var utils = require('../system/utils.cjs');
|
|
9
|
+
var selectVariantContext = require('./select-variant-context.cjs');
|
|
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');
|
|
11
|
+
|
|
12
|
+
const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
|
|
13
|
+
[originalProps, ref] = reactAriaComponents.useContextProps(
|
|
14
|
+
originalProps,
|
|
15
|
+
ref,
|
|
16
|
+
selectVariantContext.SelectVariantContext
|
|
17
|
+
);
|
|
18
|
+
const [props, variantProps] = utils.mapPropsVariants(
|
|
19
|
+
originalProps,
|
|
20
|
+
ouiTheme.selectItemStyles.variantKeys
|
|
21
|
+
);
|
|
22
|
+
const styles = ouiTheme.selectItemStyles(variantProps);
|
|
23
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
24
|
+
reactAriaComponents.ListBoxItem,
|
|
25
|
+
{
|
|
26
|
+
...props,
|
|
27
|
+
ref,
|
|
28
|
+
className: ouiTheme.composeRenderProps(
|
|
29
|
+
props.className ?? classNames?.base,
|
|
30
|
+
(className, renderProps) => styles.base({ className, ...renderProps })
|
|
31
|
+
),
|
|
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
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
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;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 selectVariantContext = require('./select-variant-context.cjs');
|
|
11
|
+
var chevronsUpDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.cjs');
|
|
12
|
+
var field = require('../field/field.cjs');
|
|
13
|
+
var button = require('../button/button.cjs');
|
|
14
|
+
|
|
15
|
+
const calculateEstimatedRowHeight = (size) => {
|
|
16
|
+
switch (size) {
|
|
17
|
+
case "xs":
|
|
18
|
+
return 44;
|
|
19
|
+
case "sm":
|
|
20
|
+
return 44;
|
|
21
|
+
case "md":
|
|
22
|
+
return 48;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function Select({
|
|
26
|
+
label,
|
|
27
|
+
description,
|
|
28
|
+
classNames,
|
|
29
|
+
...originalProps
|
|
30
|
+
}) {
|
|
31
|
+
const [_props, variantProps] = utils.mapPropsVariants(
|
|
32
|
+
originalProps,
|
|
33
|
+
ouiTheme.selectStyles.variantKeys
|
|
34
|
+
);
|
|
35
|
+
const { items, children, listLayoutOptions, ...props } = _props;
|
|
36
|
+
const styles = ouiTheme.selectStyles(variantProps);
|
|
37
|
+
const layout = react.useMemo(() => {
|
|
38
|
+
return new reactAriaComponents.ListLayout({
|
|
39
|
+
estimatedRowHeight: calculateEstimatedRowHeight(
|
|
40
|
+
variantProps.size ?? "md"
|
|
41
|
+
),
|
|
42
|
+
...listLayoutOptions
|
|
43
|
+
});
|
|
44
|
+
}, [listLayoutOptions, variantProps.size]);
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Provider, { values: [[selectVariantContext.SelectVariantContext, variantProps]], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
46
|
+
reactAriaComponents.Select,
|
|
47
|
+
{
|
|
48
|
+
className: ouiTheme.composeRenderProps(
|
|
49
|
+
props.className,
|
|
50
|
+
(className, renderProps) => styles.base({ className, ...renderProps })
|
|
51
|
+
),
|
|
52
|
+
...props,
|
|
53
|
+
children: [
|
|
54
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(field.Label, { size: variantProps.size, className: classNames?.label, children: label }),
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
56
|
+
button.Button,
|
|
57
|
+
{
|
|
58
|
+
size: variantProps.size,
|
|
59
|
+
variant: variantProps.variant ?? ouiTheme.selectStyles.defaultVariants.variant,
|
|
60
|
+
color: variantProps.color ?? ouiTheme.selectStyles.defaultVariants.color,
|
|
61
|
+
className: ouiTheme.composeRenderProps(
|
|
62
|
+
classNames?.trigger,
|
|
63
|
+
(className, renderProps) => styles.trigger({ className, ...renderProps })
|
|
64
|
+
),
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
67
|
+
reactAriaComponents.SelectValue,
|
|
68
|
+
{
|
|
69
|
+
className: styles.selectedText({
|
|
70
|
+
className: classNames?.selectedText
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsx(chevronsUpDown.default, { className: "h-4 w-4" })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
+
field.Description,
|
|
80
|
+
{
|
|
81
|
+
size: variantProps.size,
|
|
82
|
+
className: classNames?.description,
|
|
83
|
+
children: description
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Virtualizer, { layout, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
reactAriaComponents.ListBox,
|
|
88
|
+
{
|
|
89
|
+
items,
|
|
90
|
+
shouldFocusWrap: true,
|
|
91
|
+
className: ouiTheme.composeRenderProps(
|
|
92
|
+
classNames?.list,
|
|
93
|
+
(className, renderProps) => styles.list({ className, ...renderProps })
|
|
94
|
+
),
|
|
95
|
+
children
|
|
96
|
+
}
|
|
97
|
+
) }) })
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
) });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.Select = Select;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
7
6
|
var useDeepCompare = require('use-deep-compare');
|
|
7
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
8
|
var utils = require('../system/utils.cjs');
|
|
9
9
|
|
|
10
10
|
const useSpinner = (originalProps) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
'use strict';
|
|
3
4
|
|
|
4
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
6
|
var react = require('react');
|
|
6
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
9
|
var utils = require('../system/utils.cjs');
|
|
9
10
|
var tagFieldStateContext = require('./tag-field-state-context.cjs');
|
|
10
11
|
|
|
@@ -56,8 +57,8 @@ const TagFieldListInner = (props, ref) => {
|
|
|
56
57
|
item,
|
|
57
58
|
isHighlighted: highlightedIndex === virtualRow.index,
|
|
58
59
|
key: virtualRow.key,
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
itemClassNames,
|
|
61
|
+
...itemProps
|
|
61
62
|
};
|
|
62
63
|
if (typeof props.children === "function") {
|
|
63
64
|
return props.children(childProps);
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var input = require('../input/input.cjs');
|
|
9
10
|
var tagFieldList = require('./tag-field-list.cjs');
|
|
10
11
|
var tagFieldRoot = require('./tag-field-root.cjs');
|
|
11
12
|
var tagFieldTagList = require('./tag-field-tag-list.cjs');
|
|
12
13
|
var tagFieldTrigger = require('./tag-field-trigger.cjs');
|
|
13
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');
|
|
14
15
|
var field = require('../field/field.cjs');
|
|
15
|
-
var input = require('../input/input.cjs');
|
|
16
16
|
|
|
17
17
|
function TagField({
|
|
18
18
|
classNames,
|
|
@@ -127,6 +127,7 @@ function useTagField(props, state) {
|
|
|
127
127
|
});
|
|
128
128
|
const { isInvalid, validationErrors, validationDetails } = state.displayValidation;
|
|
129
129
|
const inputProps = getInputProps({
|
|
130
|
+
placeholder: props.placeholder,
|
|
130
131
|
ref: inputRef,
|
|
131
132
|
"aria-label": props["aria-label"],
|
|
132
133
|
"aria-labelledby": props["aria-labelledby"],
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
9
|
|
|
10
10
|
const TextArea = react.forwardRef(
|
|
11
11
|
({ size, variant, isDisabled, ...props }, ref) => {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
7
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
8
|
var textArea = require('../text-area/text-area.cjs');
|
|
9
9
|
var field = require('../field/field.cjs');
|
|
10
10
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
7
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
8
|
var input = require('../input/input.cjs');
|
|
9
9
|
var field = require('../field/field.cjs');
|
|
10
10
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
7
|
var reactAria = require('react-aria');
|
|
9
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
10
|
var utils = require('../system/utils.cjs');
|
|
11
11
|
|
|
12
12
|
const Toggle = ({
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { forwardRef, useMemo } from 'react';
|
|
5
|
+
import { useBadge } from './use-badge.js';
|
|
6
|
+
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
7
|
+
|
|
8
|
+
const Badge = forwardRef((props, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
Component,
|
|
11
|
+
children,
|
|
12
|
+
slots,
|
|
13
|
+
classNames,
|
|
14
|
+
getChipProps,
|
|
15
|
+
getCloseButtonProps,
|
|
16
|
+
startContent,
|
|
17
|
+
endContent,
|
|
18
|
+
isCloseable
|
|
19
|
+
} = useBadge({ ...props, ref });
|
|
20
|
+
const start = useMemo(() => {
|
|
21
|
+
if (props.variant === "dot" && !startContent) {
|
|
22
|
+
return /* @__PURE__ */ jsx("span", { className: slots.dot({ className: classNames?.dot }) });
|
|
23
|
+
}
|
|
24
|
+
return startContent;
|
|
25
|
+
}, [props.variant, startContent, slots, classNames?.dot]);
|
|
26
|
+
const end = useMemo(() => {
|
|
27
|
+
if (isCloseable) {
|
|
28
|
+
return /* @__PURE__ */ jsx("span", { ...getCloseButtonProps(), children: endContent ?? /* @__PURE__ */ jsx(X, { className: "size-full" }) });
|
|
29
|
+
}
|
|
30
|
+
return endContent;
|
|
31
|
+
}, [endContent, getCloseButtonProps, isCloseable]);
|
|
32
|
+
return /* @__PURE__ */ jsxs(Component, { ...getChipProps(), children: [
|
|
33
|
+
start,
|
|
34
|
+
/* @__PURE__ */ jsx("span", { className: slots.content({ className: classNames?.content }), children }),
|
|
35
|
+
end
|
|
36
|
+
] });
|
|
37
|
+
});
|
|
38
|
+
Badge.displayName = "Badge";
|
|
39
|
+
|
|
40
|
+
export { Badge };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { useMemo, useCallback, cloneElement, isValidElement } from 'react';
|
|
3
|
+
import { mergeProps } from '@react-aria/utils';
|
|
4
|
+
import { useMessageFormatter, useFocusRing, usePress } from 'react-aria';
|
|
5
|
+
import { useDeepCompareMemo } from 'use-deep-compare';
|
|
6
|
+
import { badgeStyles, cn, badgeCloseButtonStyles } from '@opengovsg/oui-theme';
|
|
7
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
8
|
+
import { useDomRef } from '../system/react-utils/refs.js';
|
|
9
|
+
|
|
10
|
+
const i18nStrings = {
|
|
11
|
+
"en-SG": {
|
|
12
|
+
close: "Close badge"
|
|
13
|
+
},
|
|
14
|
+
"zh-SG": {
|
|
15
|
+
close: "\u5173\u95ED\u5FBD\u7AE0"
|
|
16
|
+
},
|
|
17
|
+
"ms-SG": {
|
|
18
|
+
close: "Tutup lencana"
|
|
19
|
+
},
|
|
20
|
+
"ta-SG": {
|
|
21
|
+
close: "\u0BAA\u0BC7\u0B9F\u0BCD\u0B9C\u0BC8 \u0BAE\u0BC2\u0B9F\u0BC1"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function useBadge(originalProps) {
|
|
25
|
+
const [_props, variantProps] = mapPropsVariants(
|
|
26
|
+
originalProps,
|
|
27
|
+
badgeStyles.variantKeys
|
|
28
|
+
);
|
|
29
|
+
const {
|
|
30
|
+
ref,
|
|
31
|
+
as,
|
|
32
|
+
children,
|
|
33
|
+
startContent,
|
|
34
|
+
endContent,
|
|
35
|
+
onClose,
|
|
36
|
+
classNames,
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
} = _props;
|
|
40
|
+
const domRef = useDomRef(ref);
|
|
41
|
+
const Component = useMemo(() => as || "div", [as]);
|
|
42
|
+
const baseClassName = cn(classNames?.base, className);
|
|
43
|
+
const formatMessage = useMessageFormatter(i18nStrings);
|
|
44
|
+
const isCloseable = variantProps.isCloseable || !!onClose;
|
|
45
|
+
const {
|
|
46
|
+
focusProps: closeFocusProps,
|
|
47
|
+
isFocusVisible: isCloseButtonFocusVisible
|
|
48
|
+
} = useFocusRing();
|
|
49
|
+
const slots = useDeepCompareMemo(
|
|
50
|
+
() => ({
|
|
51
|
+
...badgeStyles({ isCloseable, ...variantProps }),
|
|
52
|
+
closeButton: badgeCloseButtonStyles
|
|
53
|
+
}),
|
|
54
|
+
[variantProps, isCloseable, badgeStyles, badgeCloseButtonStyles]
|
|
55
|
+
);
|
|
56
|
+
const { pressProps: closePressProps } = usePress({
|
|
57
|
+
isDisabled: !!variantProps?.isDisabled,
|
|
58
|
+
onPress: onClose
|
|
59
|
+
});
|
|
60
|
+
const getContentClone = useCallback(
|
|
61
|
+
(content) => isValidElement(content) ? cloneElement(content, {
|
|
62
|
+
// @ts-expect-error types are not full
|
|
63
|
+
className: content.props?.className
|
|
64
|
+
}) : null,
|
|
65
|
+
[]
|
|
66
|
+
);
|
|
67
|
+
const getChipProps = useCallback(() => {
|
|
68
|
+
return {
|
|
69
|
+
ref: domRef,
|
|
70
|
+
className: slots.base({ className: baseClassName }),
|
|
71
|
+
"aria-disabled": variantProps?.isDisabled,
|
|
72
|
+
...props
|
|
73
|
+
};
|
|
74
|
+
}, [baseClassName, domRef, props, slots, variantProps?.isDisabled]);
|
|
75
|
+
const getCloseButtonProps = useCallback(() => {
|
|
76
|
+
return {
|
|
77
|
+
role: "button",
|
|
78
|
+
tabIndex: 0,
|
|
79
|
+
className: slots.closeButton({
|
|
80
|
+
size: variantProps?.size,
|
|
81
|
+
className: classNames?.closeButton,
|
|
82
|
+
isFocusVisible: isCloseButtonFocusVisible
|
|
83
|
+
}),
|
|
84
|
+
"aria-label": formatMessage("close"),
|
|
85
|
+
...mergeProps(closePressProps, closeFocusProps)
|
|
86
|
+
};
|
|
87
|
+
}, [
|
|
88
|
+
classNames?.closeButton,
|
|
89
|
+
closeFocusProps,
|
|
90
|
+
closePressProps,
|
|
91
|
+
formatMessage,
|
|
92
|
+
isCloseButtonFocusVisible,
|
|
93
|
+
slots,
|
|
94
|
+
variantProps?.size
|
|
95
|
+
]);
|
|
96
|
+
return {
|
|
97
|
+
Component,
|
|
98
|
+
children,
|
|
99
|
+
slots,
|
|
100
|
+
classNames,
|
|
101
|
+
isCloseable,
|
|
102
|
+
startContent: getContentClone(startContent),
|
|
103
|
+
endContent: getContentClone(endContent),
|
|
104
|
+
getCloseButtonProps,
|
|
105
|
+
getChipProps
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { useBadge };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { useMemo, useRef } from 'react';
|
|
5
|
-
import { bannerStyles } from '@opengovsg/oui-theme';
|
|
6
5
|
import { useMessageFormatter, useDisclosure } from 'react-aria';
|
|
7
6
|
import { useDisclosureState } from 'react-stately';
|
|
7
|
+
import { bannerStyles } from '@opengovsg/oui-theme';
|
|
8
8
|
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';
|
|
9
9
|
import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/info.js';
|
|
10
10
|
import { Button } from '../button/button.js';
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { forwardRef, useMemo } from 'react';
|
|
5
|
-
import { buttonStyles } from '@opengovsg/oui-theme';
|
|
6
5
|
import { chain } from '@react-aria/utils';
|
|
7
6
|
import { Button as Button$1, composeRenderProps } from 'react-aria-components';
|
|
7
|
+
import { buttonStyles } from '@opengovsg/oui-theme';
|
|
8
8
|
import { useRipple } from '../ripple/use-ripple.js';
|
|
9
9
|
import { Spinner } from '../spinner/spinner.js';
|
|
10
10
|
import { Ripple } from '../ripple/ripple.js';
|