@opengovsg/oui 0.0.8 → 0.0.10
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/button/button.cjs +1 -1
- package/dist/cjs/calendar/agnostic-calendar-state-context.cjs +13 -0
- package/dist/cjs/calendar/calendar-bottom-content.cjs +51 -0
- package/dist/cjs/calendar/calendar-grid-header.cjs +28 -0
- package/dist/cjs/calendar/calendar-header.cjs +74 -0
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +86 -0
- package/dist/cjs/calendar/calendar-style-context.cjs +13 -0
- package/dist/cjs/calendar/calendar.cjs +155 -0
- package/dist/cjs/calendar/hooks/index.cjs +11 -0
- package/dist/cjs/calendar/hooks/use-calendar-i18n.cjs +33 -0
- package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +41 -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 +3 -3
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
- package/dist/cjs/combo-box/combo-box.cjs +3 -2
- package/dist/cjs/index.cjs +53 -20
- package/dist/cjs/menu/index.cjs +15 -0
- package/dist/cjs/menu/menu.cjs +229 -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 → chevron-left.cjs} +3 -6
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.cjs +19 -0
- package/dist/cjs/popover/index.cjs +8 -0
- package/dist/cjs/popover/popover.cjs +46 -0
- package/dist/cjs/range-calendar/index.cjs +10 -0
- package/dist/cjs/range-calendar/range-calendar.cjs +188 -0
- package/dist/cjs/select/select-item.cjs +11 -24
- package/dist/cjs/select/select.cjs +17 -6
- package/dist/cjs/system/react-utils/context.cjs +3 -2
- 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 +33 -0
- package/dist/cjs/tag-field/tag-field-list.cjs +11 -22
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -2
- package/dist/cjs/tag-field/tag-field.cjs +5 -3
- package/dist/esm/button/button.js +1 -1
- package/dist/esm/calendar/agnostic-calendar-state-context.js +10 -0
- package/dist/esm/calendar/calendar-bottom-content.js +49 -0
- package/dist/esm/calendar/calendar-grid-header.js +26 -0
- package/dist/esm/calendar/calendar-header.js +72 -0
- package/dist/esm/calendar/calendar-month-day-selector.js +84 -0
- package/dist/esm/calendar/calendar-style-context.js +10 -0
- package/dist/esm/calendar/calendar.js +152 -0
- package/dist/esm/calendar/hooks/index.js +3 -0
- package/dist/esm/calendar/hooks/use-calendar-i18n.js +30 -0
- package/dist/esm/calendar/hooks/use-calendar-selectors.js +39 -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 +4 -4
- package/dist/esm/combo-box/combo-box-item.js +3 -3
- package/dist/esm/combo-box/combo-box.js +4 -3
- package/dist/esm/index.js +17 -9
- package/dist/esm/menu/index.js +2 -0
- package/dist/esm/menu/menu.js +220 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-left.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/chevron-right.js +14 -0
- package/dist/esm/popover/index.js +2 -0
- package/dist/esm/popover/popover.js +44 -0
- package/dist/esm/range-calendar/index.js +2 -0
- package/dist/esm/range-calendar/range-calendar.js +184 -0
- package/dist/esm/select/select-item.js +12 -25
- package/dist/esm/select/select.js +19 -8
- package/dist/esm/system/react-utils/context.js +3 -2
- 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 +31 -0
- package/dist/esm/tag-field/tag-field-list.js +12 -22
- package/dist/esm/tag-field/tag-field-tag-list.js +3 -2
- package/dist/esm/tag-field/tag-field.js +7 -5
- package/dist/types/button/button.d.ts +5 -0
- package/dist/types/button/button.d.ts.map +1 -1
- package/dist/types/calendar/agnostic-calendar-state-context.d.ts +3 -0
- package/dist/types/calendar/agnostic-calendar-state-context.d.ts.map +1 -0
- package/dist/types/calendar/calendar-bottom-content.d.ts +4 -0
- package/dist/types/calendar/calendar-bottom-content.d.ts.map +1 -0
- package/dist/types/calendar/calendar-grid-header.d.ts +2 -0
- package/dist/types/calendar/calendar-grid-header.d.ts.map +1 -0
- package/dist/types/calendar/calendar-header.d.ts +6 -0
- package/dist/types/calendar/calendar-header.d.ts.map +1 -0
- package/dist/types/calendar/calendar-month-day-selector.d.ts +2 -0
- package/dist/types/calendar/calendar-month-day-selector.d.ts.map +1 -0
- package/dist/types/calendar/calendar-style-context.d.ts +12 -0
- package/dist/types/calendar/calendar-style-context.d.ts.map +1 -0
- package/dist/types/calendar/calendar.d.ts +8 -0
- package/dist/types/calendar/calendar.d.ts.map +1 -0
- package/dist/types/calendar/hooks/index.d.ts +3 -0
- package/dist/types/calendar/hooks/index.d.ts.map +1 -0
- package/dist/types/calendar/hooks/use-calendar-i18n.d.ts +4 -0
- package/dist/types/calendar/hooks/use-calendar-i18n.d.ts.map +1 -0
- package/dist/types/calendar/hooks/use-calendar-selectors.d.ts +13 -0
- package/dist/types/calendar/hooks/use-calendar-selectors.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 +59 -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 +2 -2
- package/dist/types/combo-box/combo-box-fuzzy.d.ts.map +1 -1
- package/dist/types/combo-box/combo-box-item.d.ts +3 -3
- package/dist/types/combo-box/combo-box-item.d.ts.map +1 -1
- package/dist/types/combo-box/combo-box.d.ts.map +1 -1
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/menu/index.d.ts +2 -0
- package/dist/types/menu/index.d.ts.map +1 -0
- package/dist/types/menu/menu.d.ts +38 -0
- package/dist/types/menu/menu.d.ts.map +1 -0
- package/dist/types/popover/index.d.ts +2 -0
- package/dist/types/popover/index.d.ts.map +1 -0
- package/dist/types/popover/popover.d.ts +21 -0
- package/dist/types/popover/popover.d.ts.map +1 -0
- package/dist/types/range-calendar/index.d.ts +2 -0
- package/dist/types/range-calendar/index.d.ts.map +1 -0
- package/dist/types/range-calendar/range-calendar.d.ts +69 -0
- package/dist/types/range-calendar/range-calendar.d.ts.map +1 -0
- package/dist/types/select/select-item.d.ts.map +1 -1
- package/dist/types/select/select.d.ts +4 -3
- package/dist/types/select/select.d.ts.map +1 -1
- package/dist/types/system/react-utils/context.d.ts +3 -2
- package/dist/types/system/react-utils/context.d.ts.map +1 -1
- 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 +2 -6
- package/dist/types/tag-field/tag-field-list.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.map +1 -1
- package/dist/types/tag-field/tag-field.d.ts.map +1 -1
- package/dist/types/tag-field/types.d.ts +8 -6
- package/dist/types/tag-field/types.d.ts.map +1 -1
- package/package.json +8 -7
- 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
|
@@ -7,7 +7,6 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
8
|
var utils = require('../system/utils.cjs');
|
|
9
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
10
|
|
|
12
11
|
const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...originalProps }, ref) {
|
|
13
12
|
[originalProps, ref] = reactAriaComponents.useContextProps(
|
|
@@ -23,6 +22,7 @@ const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...origin
|
|
|
23
22
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
24
23
|
reactAriaComponents.ListBoxItem,
|
|
25
24
|
{
|
|
25
|
+
textValue: typeof props.children === "string" ? props.children : void 0,
|
|
26
26
|
...props,
|
|
27
27
|
ref,
|
|
28
28
|
className: ouiTheme.composeRenderProps(
|
|
@@ -33,29 +33,16 @@ const SelectItem = utils.forwardRef(function SelectItem2({ classNames, ...origin
|
|
|
33
33
|
if (typeof props.children === "function") {
|
|
34
34
|
return props.children(renderProps);
|
|
35
35
|
}
|
|
36
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
className:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
] });
|
|
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
|
+
);
|
|
59
46
|
}
|
|
60
47
|
}
|
|
61
48
|
);
|
|
@@ -8,8 +8,9 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
9
|
var utils = require('../system/utils.cjs');
|
|
10
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
11
|
var field = require('../field/field.cjs');
|
|
12
|
+
var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs');
|
|
13
|
+
var popover = require('../popover/popover.cjs');
|
|
13
14
|
var button = require('../button/button.cjs');
|
|
14
15
|
|
|
15
16
|
const calculateEstimatedRowHeight = (size) => {
|
|
@@ -26,6 +27,7 @@ function Select({
|
|
|
26
27
|
label,
|
|
27
28
|
description,
|
|
28
29
|
classNames,
|
|
30
|
+
errorMessage,
|
|
29
31
|
...originalProps
|
|
30
32
|
}) {
|
|
31
33
|
const [_props, variantProps] = utils.mapPropsVariants(
|
|
@@ -34,13 +36,13 @@ function Select({
|
|
|
34
36
|
);
|
|
35
37
|
const { items, children, listLayoutOptions, ...props } = _props;
|
|
36
38
|
const styles = ouiTheme.selectStyles(variantProps);
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
+
const layoutOptions = react.useMemo(() => {
|
|
40
|
+
return {
|
|
39
41
|
estimatedRowHeight: calculateEstimatedRowHeight(
|
|
40
42
|
variantProps.size ?? "md"
|
|
41
43
|
),
|
|
42
44
|
...listLayoutOptions
|
|
43
|
-
}
|
|
45
|
+
};
|
|
44
46
|
}, [listLayoutOptions, variantProps.size]);
|
|
45
47
|
return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Provider, { values: [[selectVariantContext.SelectVariantContext, variantProps]], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
46
48
|
reactAriaComponents.Select,
|
|
@@ -71,7 +73,14 @@ function Select({
|
|
|
71
73
|
})
|
|
72
74
|
}
|
|
73
75
|
),
|
|
74
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
77
|
+
chevronDown.default,
|
|
78
|
+
{
|
|
79
|
+
className: styles.icon({
|
|
80
|
+
className: classNames?.icon
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
)
|
|
75
84
|
]
|
|
76
85
|
}
|
|
77
86
|
),
|
|
@@ -83,9 +92,11 @@ function Select({
|
|
|
83
92
|
children: description
|
|
84
93
|
}
|
|
85
94
|
),
|
|
86
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
95
|
+
/* @__PURE__ */ jsxRuntime.jsx(field.FieldError, { size: variantProps.size, className: classNames?.error, children: errorMessage }),
|
|
96
|
+
/* @__PURE__ */ jsxRuntime.jsx(popover.Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Virtualizer, { layout: reactAriaComponents.ListLayout, layoutOptions, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
97
|
reactAriaComponents.ListBox,
|
|
88
98
|
{
|
|
99
|
+
autoFocus: true,
|
|
89
100
|
items,
|
|
90
101
|
shouldFocusWrap: true,
|
|
91
102
|
className: ouiTheme.composeRenderProps(
|
|
@@ -7,9 +7,10 @@ function createContext(options = {}) {
|
|
|
7
7
|
const {
|
|
8
8
|
strict = true,
|
|
9
9
|
errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider",
|
|
10
|
-
name
|
|
10
|
+
name,
|
|
11
|
+
defaultValue
|
|
11
12
|
} = options;
|
|
12
|
-
const Context = react.createContext(
|
|
13
|
+
const Context = react.createContext(defaultValue);
|
|
13
14
|
Context.displayName = name;
|
|
14
15
|
function useContext() {
|
|
15
16
|
const context = react.useContext(Context);
|
|
@@ -13,12 +13,15 @@ const mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
|
|
|
13
13
|
if (!variantKeys) {
|
|
14
14
|
return [props, {}];
|
|
15
15
|
}
|
|
16
|
-
const picked = variantKeys.reduce(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const picked = variantKeys.reduce(
|
|
17
|
+
(acc, key) => {
|
|
18
|
+
if (key in props) {
|
|
19
|
+
return { ...acc, [key]: props[key] };
|
|
20
|
+
}
|
|
21
|
+
return acc;
|
|
22
|
+
},
|
|
23
|
+
{}
|
|
24
|
+
);
|
|
22
25
|
if (removeVariantProps) {
|
|
23
26
|
const omitted = Object.keys(props).filter((key) => !variantKeys.includes(key)).reduce((acc, key) => ({ ...acc, [key]: props[key] }), {});
|
|
24
27
|
return [omitted, picked];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
+
var utils = require('../system/utils.cjs');
|
|
9
|
+
var tagFieldStateContext = require('./tag-field-state-context.cjs');
|
|
10
|
+
|
|
11
|
+
const TagFieldItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
|
|
12
|
+
const { itemToText, size } = react.useContext(tagFieldStateContext.TagFieldStateContext);
|
|
13
|
+
const styles = ouiTheme.listBoxItemStyles({ size });
|
|
14
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
+
"li",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
...itemProps,
|
|
19
|
+
className: styles.container({
|
|
20
|
+
className: classNames?.container,
|
|
21
|
+
isFocused: isHighlighted,
|
|
22
|
+
isDisabled: itemProps["aria-disabled"]
|
|
23
|
+
}),
|
|
24
|
+
"data-rac": true,
|
|
25
|
+
"data-focused": ouiTheme.dataAttr(isHighlighted),
|
|
26
|
+
"data-disabled": ouiTheme.dataAttr(itemProps["aria-disabled"]),
|
|
27
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
const TagFieldItem = utils.forwardRefGeneric(TagFieldItemInner);
|
|
32
|
+
|
|
33
|
+
exports.TagFieldItem = TagFieldItem;
|
|
@@ -5,27 +5,11 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
|
-
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
8
|
var utils = require('../system/utils.cjs');
|
|
9
|
+
var tagFieldItem = require('./tag-field-item.cjs');
|
|
10
10
|
var tagFieldStateContext = require('./tag-field-state-context.cjs');
|
|
11
11
|
|
|
12
12
|
const TagFieldListContext = react.createContext(null);
|
|
13
|
-
const TagFieldListItemInner = ({ item, isHighlighted, classNames, ...itemProps }, ref) => {
|
|
14
|
-
const { itemToText, size } = react.useContext(tagFieldStateContext.TagFieldStateContext);
|
|
15
|
-
const styles = ouiTheme.tagFieldItemStyles({ size });
|
|
16
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17
|
-
"li",
|
|
18
|
-
{
|
|
19
|
-
ref,
|
|
20
|
-
...itemProps,
|
|
21
|
-
className: styles.container({ className: classNames?.container }),
|
|
22
|
-
"data-rac": true,
|
|
23
|
-
"data-hovered": ouiTheme.dataAttr(isHighlighted),
|
|
24
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.label({ className: classNames?.label }), children: itemToText(item) })
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
const TagFieldListItem = utils.forwardRefGeneric(TagFieldListItemInner);
|
|
29
13
|
const TagFieldListInner = (props, ref) => {
|
|
30
14
|
[props, ref] = reactAriaComponents.useContextProps(props, ref, TagFieldListContext);
|
|
31
15
|
const { items, getItemProps, highlightedIndex } = react.useContext(tagFieldStateContext.TagFieldStateContext);
|
|
@@ -57,13 +41,19 @@ const TagFieldListInner = (props, ref) => {
|
|
|
57
41
|
item,
|
|
58
42
|
isHighlighted: highlightedIndex === virtualRow.index,
|
|
59
43
|
key: virtualRow.key,
|
|
60
|
-
itemClassNames
|
|
61
|
-
...itemProps
|
|
44
|
+
classNames: itemClassNames
|
|
62
45
|
};
|
|
63
46
|
if (typeof props.children === "function") {
|
|
64
|
-
return props.children(childProps);
|
|
47
|
+
return props.children({ ...childProps, itemProps });
|
|
65
48
|
}
|
|
66
|
-
return /* @__PURE__ */ react.createElement(
|
|
49
|
+
return /* @__PURE__ */ react.createElement(
|
|
50
|
+
tagFieldItem.TagFieldItem,
|
|
51
|
+
{
|
|
52
|
+
...childProps,
|
|
53
|
+
...itemProps,
|
|
54
|
+
key: childProps.key
|
|
55
|
+
}
|
|
56
|
+
);
|
|
67
57
|
})
|
|
68
58
|
] }) });
|
|
69
59
|
};
|
|
@@ -71,4 +61,3 @@ const TagFieldList = utils.forwardRefGeneric(TagFieldListInner);
|
|
|
71
61
|
|
|
72
62
|
exports.TagFieldList = TagFieldList;
|
|
73
63
|
exports.TagFieldListContext = TagFieldListContext;
|
|
74
|
-
exports.TagFieldListItem = TagFieldListItem;
|
|
@@ -15,7 +15,8 @@ const TagFieldTagList = ({
|
|
|
15
15
|
getSelectedItemProps,
|
|
16
16
|
removeSelectedItem,
|
|
17
17
|
isDisabled,
|
|
18
|
-
isReadOnly
|
|
18
|
+
isReadOnly,
|
|
19
|
+
itemToText
|
|
19
20
|
} = react.useContext(tagFieldStateContext.TagFieldStateContext);
|
|
20
21
|
const handleRemoveSelectedItem = react.useCallback(
|
|
21
22
|
(item) => () => {
|
|
@@ -49,7 +50,7 @@ const TagFieldTagList = ({
|
|
|
49
50
|
className: classNames?.tag,
|
|
50
51
|
...itemProps,
|
|
51
52
|
children: [
|
|
52
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: classNames?.tagText, children: selectedItem
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: classNames?.tagText, children: itemToText(selectedItem) }),
|
|
53
54
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
54
55
|
x.default,
|
|
55
56
|
{
|
|
@@ -6,13 +6,15 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
-
var
|
|
9
|
+
var tagFieldItem = require('./tag-field-item.cjs');
|
|
10
10
|
var tagFieldList = require('./tag-field-list.cjs');
|
|
11
11
|
var tagFieldRoot = require('./tag-field-root.cjs');
|
|
12
12
|
var tagFieldTagList = require('./tag-field-tag-list.cjs');
|
|
13
13
|
var tagFieldTrigger = require('./tag-field-trigger.cjs');
|
|
14
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');
|
|
15
15
|
var field = require('../field/field.cjs');
|
|
16
|
+
var input = require('../input/input.cjs');
|
|
17
|
+
var popover = require('../popover/popover.cjs');
|
|
16
18
|
|
|
17
19
|
function TagField({
|
|
18
20
|
classNames,
|
|
@@ -92,12 +94,12 @@ function TagField({
|
|
|
92
94
|
}
|
|
93
95
|
)
|
|
94
96
|
] }),
|
|
95
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsx(popover.Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
96
98
|
tagFieldList.TagFieldList,
|
|
97
99
|
{
|
|
98
100
|
className: styles.list({ className: classNames?.list }),
|
|
99
101
|
itemClassNames: props.itemClassNames,
|
|
100
|
-
children: ({ key, ...props2 }) => children ? children({ key, ...props2 }) : /* @__PURE__ */ react.createElement(
|
|
102
|
+
children: ({ key, itemProps, ...props2 }) => children ? children({ key, itemProps, ...props2 }) : /* @__PURE__ */ react.createElement(tagFieldItem.TagFieldItem, { ...props2, ...itemProps, key })
|
|
101
103
|
}
|
|
102
104
|
) })
|
|
103
105
|
] });
|
|
@@ -5,9 +5,9 @@ import { forwardRef, useMemo } from 'react';
|
|
|
5
5
|
import { chain } from '@react-aria/utils';
|
|
6
6
|
import { Button as Button$1, composeRenderProps } from 'react-aria-components';
|
|
7
7
|
import { buttonStyles } from '@opengovsg/oui-theme';
|
|
8
|
+
import { Ripple } from '../ripple/ripple.js';
|
|
8
9
|
import { useRipple } from '../ripple/use-ripple.js';
|
|
9
10
|
import { Spinner } from '../spinner/spinner.js';
|
|
10
|
-
import { Ripple } from '../ripple/ripple.js';
|
|
11
11
|
|
|
12
12
|
const Button = forwardRef(
|
|
13
13
|
({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [AgnosticCalendarStateContext, useAgnosticCalendarStateContext] = createContext({
|
|
6
|
+
name: "AgnosticCalendarStateContext",
|
|
7
|
+
strict: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { AgnosticCalendarStateContext, useAgnosticCalendarStateContext };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { today, getLocalTimeZone } from '@internationalized/date';
|
|
6
|
+
import { Button } from '../button/button.js';
|
|
7
|
+
import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
8
|
+
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
9
|
+
import { useCalendarI18n } from './hooks/use-calendar-i18n.js';
|
|
10
|
+
|
|
11
|
+
const CalendarBottomContent = ({
|
|
12
|
+
bottomContent,
|
|
13
|
+
showTodayButton
|
|
14
|
+
}) => {
|
|
15
|
+
const state = useContext(AgnosticCalendarStateContext);
|
|
16
|
+
const { slots, classNames, size } = useCalendarStyleContext();
|
|
17
|
+
const formatMessage = useCalendarI18n();
|
|
18
|
+
if (bottomContent) {
|
|
19
|
+
return bottomContent;
|
|
20
|
+
}
|
|
21
|
+
if (!showTodayButton) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
className: slots.bottomContentWrapper({
|
|
28
|
+
className: classNames?.bottomContentWrapper
|
|
29
|
+
}),
|
|
30
|
+
children: /* @__PURE__ */ jsx(
|
|
31
|
+
Button,
|
|
32
|
+
{
|
|
33
|
+
isDisabled: state.isDisabled,
|
|
34
|
+
variant: "clear",
|
|
35
|
+
color: "sub",
|
|
36
|
+
size,
|
|
37
|
+
slot: null,
|
|
38
|
+
className: slots.todayButton({ className: classNames?.todayButton }),
|
|
39
|
+
onPress: () => {
|
|
40
|
+
state.setFocusedDate(today(getLocalTimeZone()));
|
|
41
|
+
},
|
|
42
|
+
children: formatMessage("today")
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { CalendarBottomContent };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { CalendarGridHeader as CalendarGridHeader$1, CalendarHeaderCell } from 'react-aria-components';
|
|
5
|
+
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
6
|
+
|
|
7
|
+
function CalendarGridHeader() {
|
|
8
|
+
const { slots, classNames } = useCalendarStyleContext();
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
CalendarGridHeader$1,
|
|
11
|
+
{
|
|
12
|
+
className: slots.gridHeader({ className: classNames?.gridHeader }),
|
|
13
|
+
children: (day) => /* @__PURE__ */ jsx(
|
|
14
|
+
CalendarHeaderCell,
|
|
15
|
+
{
|
|
16
|
+
className: slots.gridHeaderCell({
|
|
17
|
+
className: classNames?.gridHeaderCell
|
|
18
|
+
}),
|
|
19
|
+
children: day
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { CalendarGridHeader };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { useLocale, Group, Heading } from 'react-aria-components';
|
|
6
|
+
import { Button } from '../button/button.js';
|
|
7
|
+
import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
8
|
+
import { CalendarMonthDaySelector } from './calendar-month-day-selector.js';
|
|
9
|
+
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
10
|
+
import { useLocalizedMonthYear } from './utils.js';
|
|
11
|
+
import ChevronRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.js';
|
|
12
|
+
import ChevronLeft from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-left.js';
|
|
13
|
+
|
|
14
|
+
function CalendarHeader({ offsetMonths = 0 }) {
|
|
15
|
+
const { direction } = useLocale();
|
|
16
|
+
const { slots, classNames, size } = useCalendarStyleContext();
|
|
17
|
+
const state = useContext(AgnosticCalendarStateContext);
|
|
18
|
+
const monthYearTitle = useLocalizedMonthYear(
|
|
19
|
+
state.visibleRange.start.add({ months: offsetMonths }),
|
|
20
|
+
state.timeZone
|
|
21
|
+
);
|
|
22
|
+
if (offsetMonths === 0) {
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", { className: slots.header({ className: classNames?.header }), children: [
|
|
24
|
+
/* @__PURE__ */ jsx(CalendarMonthDaySelector, {}),
|
|
25
|
+
/* @__PURE__ */ jsxs(
|
|
26
|
+
Group,
|
|
27
|
+
{
|
|
28
|
+
className: slots.buttonGroup({ className: classNames?.buttonGroup }),
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
Button,
|
|
32
|
+
{
|
|
33
|
+
size,
|
|
34
|
+
isIconOnly: true,
|
|
35
|
+
variant: "clear",
|
|
36
|
+
color: "sub",
|
|
37
|
+
slot: "previous",
|
|
38
|
+
className: slots.prevButton({ className: classNames?.prevButton }),
|
|
39
|
+
children: direction === "rtl" ? /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true }) : /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": true })
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Button,
|
|
44
|
+
{
|
|
45
|
+
size,
|
|
46
|
+
variant: "clear",
|
|
47
|
+
color: "sub",
|
|
48
|
+
isIconOnly: true,
|
|
49
|
+
slot: "next",
|
|
50
|
+
className: slots.nextButton({
|
|
51
|
+
className: classNames?.nextButton
|
|
52
|
+
}),
|
|
53
|
+
children: direction === "rtl" ? /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": true }) : /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true })
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
Heading,
|
|
63
|
+
{
|
|
64
|
+
className: slots.header({ className: classNames?.header }),
|
|
65
|
+
"aria-hidden": true,
|
|
66
|
+
level: 2,
|
|
67
|
+
children: monthYearTitle
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { CalendarHeader };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { CalendarDate } from '@internationalized/date';
|
|
6
|
+
import { Group } from 'react-aria-components';
|
|
7
|
+
import { Select } from '../select/select.js';
|
|
8
|
+
import { SelectItem } from '../select/select-item.js';
|
|
9
|
+
import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
10
|
+
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
11
|
+
import { useCalendarSelectors } from './hooks/use-calendar-selectors.js';
|
|
12
|
+
import { useCalendarI18n } from './hooks/use-calendar-i18n.js';
|
|
13
|
+
|
|
14
|
+
const CalendarMonthDaySelector = () => {
|
|
15
|
+
const { slots, size, classNames } = useCalendarStyleContext();
|
|
16
|
+
const state = useContext(AgnosticCalendarStateContext);
|
|
17
|
+
const { months, years, datePartOrder } = useCalendarSelectors(state);
|
|
18
|
+
const formatMessage = useCalendarI18n();
|
|
19
|
+
return /* @__PURE__ */ jsx(Group, { className: slots.selectors({ className: classNames?.selectors }), children: datePartOrder.map((part) => {
|
|
20
|
+
if (part === "month") {
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
Select,
|
|
23
|
+
{
|
|
24
|
+
isDisabled: state.isDisabled,
|
|
25
|
+
size,
|
|
26
|
+
items: months,
|
|
27
|
+
variant: "clear",
|
|
28
|
+
classNames: {
|
|
29
|
+
trigger: slots.monthSelector({
|
|
30
|
+
className: classNames?.monthSelector
|
|
31
|
+
}),
|
|
32
|
+
list: slots.monthList({ className: classNames?.monthList }),
|
|
33
|
+
selectedText: slots.selectorText({
|
|
34
|
+
className: classNames?.selectorText
|
|
35
|
+
}),
|
|
36
|
+
popover: "min-w-[12ch]"
|
|
37
|
+
},
|
|
38
|
+
selectedKey: state.visibleRange.start.month,
|
|
39
|
+
"aria-label": formatMessage("selectMonth"),
|
|
40
|
+
onSelectionChange: (month) => {
|
|
41
|
+
state.setFocusedDate(
|
|
42
|
+
new CalendarDate(state.focusedDate.year, Number(month), 1)
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
children: (month) => /* @__PURE__ */ jsx(SelectItem, { children: month.textValue })
|
|
46
|
+
},
|
|
47
|
+
part
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
Select,
|
|
52
|
+
{
|
|
53
|
+
isDisabled: state.isDisabled,
|
|
54
|
+
size,
|
|
55
|
+
variant: "clear",
|
|
56
|
+
items: years,
|
|
57
|
+
classNames: {
|
|
58
|
+
trigger: slots.yearSelector({
|
|
59
|
+
className: classNames?.yearSelector
|
|
60
|
+
}),
|
|
61
|
+
list: slots.yearList({ className: classNames?.yearList }),
|
|
62
|
+
selectedText: slots.selectorText({
|
|
63
|
+
className: classNames?.selectorText
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
selectedKey: state.visibleRange.start.year,
|
|
67
|
+
"aria-label": formatMessage("selectYear"),
|
|
68
|
+
onSelectionChange: (year) => {
|
|
69
|
+
state.setFocusedDate(
|
|
70
|
+
new CalendarDate(
|
|
71
|
+
Number(year),
|
|
72
|
+
state.focusedDate.month,
|
|
73
|
+
state.focusedDate.day
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
children: (year) => /* @__PURE__ */ jsx(SelectItem, { children: year.textValue })
|
|
78
|
+
},
|
|
79
|
+
part
|
|
80
|
+
);
|
|
81
|
+
}) });
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { CalendarMonthDaySelector };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [CalendarStyleContext, useCalendarStyleContext] = createContext({
|
|
6
|
+
name: "CalendarStyleContext",
|
|
7
|
+
strict: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { CalendarStyleContext, useCalendarStyleContext };
|