@opengovsg/oui 0.0.23 → 0.0.25
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 +4 -4
- package/dist/cjs/badge/use-badge.cjs +6 -6
- package/dist/cjs/banner/banner.cjs +3 -3
- package/dist/cjs/button/button.cjs +3 -3
- package/dist/cjs/calendar/calendar-bottom-content.cjs +3 -3
- package/dist/cjs/calendar/calendar-header.cjs +2 -2
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +2 -2
- package/dist/cjs/calendar/calendar.cjs +4 -4
- package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
- package/dist/cjs/calendar/utils.cjs +3 -3
- package/dist/cjs/checkbox/checkbox.cjs +1 -1
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
- package/dist/cjs/combo-box/combo-box.cjs +5 -5
- package/dist/cjs/date-field/date-field.cjs +4 -4
- package/dist/cjs/date-picker/date-picker.cjs +7 -6
- package/dist/cjs/date-range-picker/date-range-picker.cjs +7 -7
- package/dist/cjs/field/field.cjs +2 -2
- package/dist/cjs/file-dropzone/file-dropzone.cjs +12 -12
- package/dist/cjs/file-dropzone/file-info.cjs +3 -3
- package/dist/cjs/govt-banner/govt-banner.cjs +3 -3
- package/dist/cjs/hooks/index.cjs +2 -0
- package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
- package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
- package/dist/cjs/hooks/use-draggable.cjs +88 -0
- package/dist/cjs/index.cjs +54 -39
- package/dist/cjs/input/input.cjs +2 -2
- package/dist/cjs/menu/menu.cjs +7 -7
- package/dist/cjs/modal/i18n.cjs +19 -0
- package/dist/cjs/modal/index.cjs +19 -0
- package/dist/cjs/modal/modal-body.cjs +26 -0
- package/dist/cjs/modal/modal-content.cjs +54 -0
- package/dist/cjs/modal/modal-footer.cjs +27 -0
- package/dist/cjs/modal/modal-header.cjs +25 -0
- package/dist/cjs/modal/modal-variant-context.cjs +13 -0
- package/dist/cjs/modal/modal.cjs +66 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/Icon.cjs +4 -4
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +3 -3
- package/dist/cjs/number-field/number-field.cjs +2 -2
- package/dist/cjs/pagination/hooks/use-pagination.cjs +7 -7
- package/dist/cjs/pagination/pagination.cjs +6 -6
- package/dist/cjs/pagination/use-pagination-item.cjs +7 -8
- package/dist/cjs/pagination/use-pagination.cjs +8 -8
- package/dist/cjs/range-calendar/range-calendar.cjs +7 -7
- package/dist/cjs/ripple/use-ripple.cjs +4 -4
- package/dist/cjs/select/select.cjs +4 -4
- package/dist/cjs/spinner/use-spinner.cjs +3 -3
- package/dist/cjs/system/react-utils/context.cjs +3 -3
- package/dist/cjs/system/react-utils/refs.cjs +3 -3
- package/dist/cjs/system/utils.cjs +3 -3
- package/dist/cjs/tabs/tabs.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
- package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
- package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
- package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
- package/dist/cjs/tag-field/tag-field.cjs +5 -5
- package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
- package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
- package/dist/cjs/text-area/text-area.cjs +2 -2
- package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
- package/dist/cjs/text-field/text-field.cjs +1 -1
- package/dist/cjs/toggle/toggle.cjs +3 -3
- package/dist/esm/checkbox/checkbox.js +1 -1
- package/dist/esm/combo-box/combo-box.js +2 -2
- package/dist/esm/date-field/date-field.js +1 -1
- package/dist/esm/date-picker/date-picker.js +5 -4
- package/dist/esm/date-range-picker/date-range-picker.js +4 -4
- package/dist/esm/file-dropzone/file-dropzone.js +2 -2
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/use-draggable.js +86 -0
- package/dist/esm/index.js +18 -11
- package/dist/esm/menu/menu.js +1 -1
- package/dist/esm/modal/i18n.js +17 -0
- package/dist/esm/modal/index.js +7 -0
- package/dist/esm/modal/modal-body.js +24 -0
- package/dist/esm/modal/modal-content.js +52 -0
- package/dist/esm/modal/modal-footer.js +25 -0
- package/dist/esm/modal/modal-header.js +23 -0
- package/dist/esm/modal/modal-variant-context.js +10 -0
- package/dist/esm/modal/modal.js +64 -0
- package/dist/esm/number-field/number-field.js +2 -2
- package/dist/esm/pagination/use-pagination-item.js +5 -6
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/select/select.js +2 -2
- package/dist/esm/tag-field/tag-field.js +3 -3
- package/dist/esm/text-area-field/text-area-field.js +1 -1
- package/dist/esm/text-field/text-field.js +1 -1
- package/dist/types/badge/use-badge.d.ts +12 -12
- package/dist/types/hooks/index.d.ts +4 -1
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/use-draggable.d.ts +24 -0
- package/dist/types/hooks/use-draggable.d.ts.map +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/menu/menu.d.ts.map +1 -1
- package/dist/types/modal/i18n.d.ts +3 -0
- package/dist/types/modal/i18n.d.ts.map +1 -0
- package/dist/types/modal/index.d.ts +12 -0
- package/dist/types/modal/index.d.ts.map +1 -0
- package/dist/types/modal/modal-body.d.ts +5 -0
- package/dist/types/modal/modal-body.d.ts.map +1 -0
- package/dist/types/modal/modal-content.d.ts +10 -0
- package/dist/types/modal/modal-content.d.ts.map +1 -0
- package/dist/types/modal/modal-footer.d.ts +5 -0
- package/dist/types/modal/modal-footer.d.ts.map +1 -0
- package/dist/types/modal/modal-header.d.ts +5 -0
- package/dist/types/modal/modal-header.d.ts.map +1 -0
- package/dist/types/modal/modal-variant-context.d.ts +8 -0
- package/dist/types/modal/modal-variant-context.d.ts.map +1 -0
- package/dist/types/modal/modal.d.ts +8 -0
- package/dist/types/modal/modal.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination.d.ts +36 -36
- package/package.json +13 -10
- package/dist/cjs/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.cjs +0 -45
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.cjs +0 -21
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.cjs +0 -72
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.cjs +0 -60
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.cjs +0 -210
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.cjs +0 -100
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.cjs +0 -152
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.cjs +0 -676
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.cjs +0 -160
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs +0 -9
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs +0 -9
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs +0 -16
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs +0 -9
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.cjs +0 -11
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.cjs +0 -10
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.cjs +0 -12
- package/dist/esm/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.js +0 -43
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.js +0 -19
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.js +0 -69
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.js +0 -58
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.js +0 -205
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.js +0 -98
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.js +0 -150
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.js +0 -674
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.js +0 -155
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +0 -7
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js +0 -7
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js +0 -14
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js +0 -7
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.js +0 -9
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.js +0 -8
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.js +0 -10
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var
|
|
6
|
+
var react = require('react');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var field = require('../field/field.cjs');
|
|
10
|
+
var input = require('../input/input.cjs');
|
|
11
|
+
var popover = require('../popover/popover.cjs');
|
|
9
12
|
var tagFieldItem = require('./tag-field-item.cjs');
|
|
10
13
|
var tagFieldList = require('./tag-field-list.cjs');
|
|
11
14
|
var tagFieldRoot = require('./tag-field-root.cjs');
|
|
12
15
|
var tagFieldTagList = require('./tag-field-tag-list.cjs');
|
|
13
16
|
var tagFieldTrigger = require('./tag-field-trigger.cjs');
|
|
14
17
|
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
|
-
var field = require('../field/field.cjs');
|
|
16
|
-
var input = require('../input/input.cjs');
|
|
17
|
-
var popover = require('../popover/popover.cjs');
|
|
18
18
|
|
|
19
19
|
function TagField({
|
|
20
20
|
classNames,
|
|
@@ -99,7 +99,7 @@ function TagField({
|
|
|
99
99
|
{
|
|
100
100
|
className: styles.list({ className: classNames?.list }),
|
|
101
101
|
itemClassNames: props.itemClassNames,
|
|
102
|
-
children: ({ key, itemProps, ...props2 }) => children ? children({ key, itemProps, ...props2 }) : /* @__PURE__ */
|
|
102
|
+
children: ({ key, itemProps, ...props2 }) => children ? children({ key, itemProps, ...props2 }) : /* @__PURE__ */ react.createElement(tagFieldItem.TagFieldItem, { ...props2, ...itemProps, key })
|
|
103
103
|
}
|
|
104
104
|
) })
|
|
105
105
|
] });
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var form = require('@react-stately/form');
|
|
6
6
|
var utils = require('@react-stately/utils');
|
|
7
7
|
var useControllableState = require('../hooks/use-controllable-state.cjs');
|
|
8
8
|
|
|
9
9
|
function useTagFieldState(props) {
|
|
10
10
|
const { itemToText, itemToKey, defaultFilter } = props;
|
|
11
|
-
const itemsByKey =
|
|
11
|
+
const itemsByKey = react.useMemo(() => {
|
|
12
12
|
const items = props.items ?? props.defaultItems ?? [];
|
|
13
13
|
return items.reduce(
|
|
14
14
|
(acc, item) => {
|
|
@@ -18,7 +18,7 @@ function useTagFieldState(props) {
|
|
|
18
18
|
{}
|
|
19
19
|
) ?? {};
|
|
20
20
|
}, [itemToKey, props.defaultItems, props.items]);
|
|
21
|
-
const getSelectedItemsByKey =
|
|
21
|
+
const getSelectedItemsByKey = react.useCallback(
|
|
22
22
|
(keys) => {
|
|
23
23
|
if (!keys) return;
|
|
24
24
|
return [...keys].map((key) => itemsByKey[key]);
|
|
@@ -36,13 +36,13 @@ function useTagFieldState(props) {
|
|
|
36
36
|
defaultInputValue,
|
|
37
37
|
props.onInputChange
|
|
38
38
|
);
|
|
39
|
-
const controlledSelectedKeys =
|
|
39
|
+
const controlledSelectedKeys = react.useMemo(
|
|
40
40
|
() => new Set(selectedItems.map(itemToKey)),
|
|
41
41
|
[itemToKey, selectedItems]
|
|
42
42
|
);
|
|
43
43
|
const validation = form.useFormValidationState({
|
|
44
44
|
...props,
|
|
45
|
-
value:
|
|
45
|
+
value: react.useMemo(
|
|
46
46
|
() => ({
|
|
47
47
|
inputValue,
|
|
48
48
|
selectedKeys: controlledSelectedKeys
|
|
@@ -50,7 +50,7 @@ function useTagFieldState(props) {
|
|
|
50
50
|
[controlledSelectedKeys, inputValue]
|
|
51
51
|
)
|
|
52
52
|
});
|
|
53
|
-
const filteredItems =
|
|
53
|
+
const filteredItems = react.useMemo(
|
|
54
54
|
() => (
|
|
55
55
|
// No default filter if items are controlled.
|
|
56
56
|
!!props.items || !defaultFilter ? props.items ?? [] : filterItems({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var utils = require('@react-aria/utils');
|
|
6
6
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
7
7
|
var downshift = require('downshift');
|
|
@@ -23,7 +23,7 @@ function useTagField(props, state) {
|
|
|
23
23
|
label,
|
|
24
24
|
virtualRowHeight = 40
|
|
25
25
|
} = props;
|
|
26
|
-
const backupBtnRef =
|
|
26
|
+
const backupBtnRef = react.useRef(null);
|
|
27
27
|
buttonRef = buttonRef ?? backupBtnRef;
|
|
28
28
|
const {
|
|
29
29
|
selectedItems,
|
|
@@ -48,14 +48,14 @@ function useTagField(props, state) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
const disabledKeysSet =
|
|
51
|
+
const disabledKeysSet = react.useMemo(() => {
|
|
52
52
|
return new Set(disabledKeys);
|
|
53
53
|
}, [disabledKeys]);
|
|
54
54
|
const rowVirtualizer = reactVirtual.useVirtualizer({
|
|
55
55
|
count: items.length,
|
|
56
56
|
getScrollElement: () => listBoxRef.current,
|
|
57
57
|
estimateSize: () => virtualRowHeight,
|
|
58
|
-
getItemKey:
|
|
58
|
+
getItemKey: react.useCallback(
|
|
59
59
|
(index) => itemToKey(items[index]),
|
|
60
60
|
[itemToKey, items]
|
|
61
61
|
),
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var
|
|
6
|
+
var react = require('react');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
9
|
|
|
10
|
-
const TextArea =
|
|
10
|
+
const TextArea = react.forwardRef(
|
|
11
11
|
({ size, variant, isDisabled, ...props }, ref) => {
|
|
12
12
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13
13
|
reactAriaComponents.TextArea,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
-
var textArea = require('../text-area/text-area.cjs');
|
|
9
8
|
var field = require('../field/field.cjs');
|
|
9
|
+
var textArea = require('../text-area/text-area.cjs');
|
|
10
10
|
|
|
11
11
|
function TextAreaField({
|
|
12
12
|
label,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
-
var input = require('../input/input.cjs');
|
|
9
8
|
var field = require('../field/field.cjs');
|
|
9
|
+
var input = require('../input/input.cjs');
|
|
10
10
|
|
|
11
11
|
function TextField({
|
|
12
12
|
label,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var
|
|
6
|
+
var react = require('react');
|
|
7
7
|
var reactAria = require('react-aria');
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
@@ -21,12 +21,12 @@ const Toggle = ({
|
|
|
21
21
|
ouiTheme.toggleStyles.variantKeys
|
|
22
22
|
);
|
|
23
23
|
const slots = ouiTheme.toggleStyles(variantProps);
|
|
24
|
-
const clonedThumbIcon =
|
|
24
|
+
const clonedThumbIcon = react.useCallback(
|
|
25
25
|
(renderProps) => {
|
|
26
26
|
const baseProps = {
|
|
27
27
|
className: slots.thumbIcon({ className: classNames?.thumbIcon })
|
|
28
28
|
};
|
|
29
|
-
return typeof thumbIcon === "function" ? thumbIcon(reactAria.mergeProps(baseProps, renderProps)) : thumbIcon &&
|
|
29
|
+
return typeof thumbIcon === "function" ? thumbIcon(reactAria.mergeProps(baseProps, renderProps)) : thumbIcon && react.cloneElement(thumbIcon, baseProps);
|
|
30
30
|
},
|
|
31
31
|
[classNames?.thumbIcon, slots, thumbIcon]
|
|
32
32
|
);
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { Checkbox as Checkbox$1, composeRenderProps, Provider, CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
|
|
5
5
|
import { checkboxStyles, checkboxGroupStyles } from '@opengovsg/oui-theme';
|
|
6
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
6
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
7
8
|
import { useCheckboxGroupStyleContext, CheckboxGroupStyleContext } from './checkbox-group-style-context.js';
|
|
8
9
|
import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.js';
|
|
9
10
|
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js';
|
|
10
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
11
11
|
|
|
12
12
|
const Checkbox = ({
|
|
13
13
|
classNames,
|
|
@@ -5,13 +5,13 @@ import { useMemo, useCallback } from 'react';
|
|
|
5
5
|
import { useMessageFormatter } from 'react-aria';
|
|
6
6
|
import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Virtualizer, ListBox } from 'react-aria-components';
|
|
7
7
|
import { listBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
|
|
8
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
9
|
+
import { Popover } from '../popover/popover.js';
|
|
8
10
|
import { mapPropsVariants } from '../system/utils.js';
|
|
9
11
|
import { ComboBoxVariantContext } from './combo-box-variant-context.js';
|
|
10
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
11
12
|
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';
|
|
12
13
|
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';
|
|
13
14
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
14
|
-
import { Popover } from '../popover/popover.js';
|
|
15
15
|
|
|
16
16
|
const calculateEstimatedRowHeight = (size) => {
|
|
17
17
|
switch (size) {
|
|
@@ -4,8 +4,8 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { DateField as DateField$1, DateInput as DateInput$1, DateSegment } from 'react-aria-components';
|
|
6
6
|
import { dateFieldStyles, composeTailwindRenderProps, dateInputStyles, composeRenderProps } from '@opengovsg/oui-theme';
|
|
7
|
-
import { mapPropsVariants } from '../system/utils.js';
|
|
8
7
|
import { Label, Description, FieldError } from '../field/field.js';
|
|
8
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
9
9
|
|
|
10
10
|
function DateField(originalProps) {
|
|
11
11
|
const [
|
|
@@ -4,13 +4,14 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { DatePicker as DatePicker$1, Dialog } from 'react-aria-components';
|
|
6
6
|
import { datePickerStyles, composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
7
|
-
import { mapPropsVariants } from '../system/utils.js';
|
|
8
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
9
|
-
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
10
7
|
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
8
|
+
import '@internationalized/date';
|
|
9
|
+
import { DateInput } from '../date-field/date-field.js';
|
|
11
10
|
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
12
|
-
import { Button } from '../button/button.js';
|
|
13
11
|
import { Popover } from '../popover/popover.js';
|
|
12
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
13
|
+
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
14
|
+
import { Button } from '../button/button.js';
|
|
14
15
|
|
|
15
16
|
function DatePicker(originalProps) {
|
|
16
17
|
const [
|
|
@@ -5,13 +5,13 @@ import { useMemo } from 'react';
|
|
|
5
5
|
import { CalendarDate } from '@internationalized/date';
|
|
6
6
|
import { DateRangePicker as DateRangePicker$1, Dialog } from 'react-aria-components';
|
|
7
7
|
import { dateRangePickerStyles, composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
8
|
+
import { DateInput } from '../date-field/date-field.js';
|
|
9
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
10
|
+
import { Popover } from '../popover/popover.js';
|
|
11
|
+
import { RangeCalendar } from '../range-calendar/range-calendar.js';
|
|
8
12
|
import { mapPropsVariants } from '../system/utils.js';
|
|
9
13
|
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
10
|
-
import { RangeCalendar } from '../range-calendar/range-calendar.js';
|
|
11
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
12
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
13
14
|
import { Button } from '../button/button.js';
|
|
14
|
-
import { Popover } from '../popover/popover.js';
|
|
15
15
|
|
|
16
16
|
function DateRangePicker(originalProps) {
|
|
17
17
|
const [
|
|
@@ -7,13 +7,13 @@ import { useField, useId } from 'react-aria';
|
|
|
7
7
|
import { Provider, LabelContext, GroupContext, TextContext, FieldErrorContext, Group } from 'react-aria-components';
|
|
8
8
|
import { useDropzone } from 'react-dropzone';
|
|
9
9
|
import { fileDropzoneStyles, dataAttr } from '@opengovsg/oui-theme';
|
|
10
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
11
|
+
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
10
12
|
import { mapPropsVariants } from '../system/utils.js';
|
|
11
13
|
import { FileDropzoneStyleContext, FileDropzoneStateContext, useFileDropzoneStateContext, useFileDropzoneStyleContext } from './contexts.js';
|
|
12
14
|
import { FileInfo } from './file-info.js';
|
|
13
15
|
import { formatErrorMessage, formatBytes } from './utils.js';
|
|
14
|
-
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
15
16
|
import Upload from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/upload.js';
|
|
16
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
17
17
|
|
|
18
18
|
const FileDropzone = (originalProps) => {
|
|
19
19
|
const [props, variantProps] = mapPropsVariants(
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
4
|
+
import { useMove } from '@react-aria/interactions';
|
|
5
|
+
|
|
6
|
+
function useDraggable(props) {
|
|
7
|
+
const { targetRef, isDisabled = false, canOverflow = false } = props;
|
|
8
|
+
const boundary = useRef({ minLeft: 0, minTop: 0, maxLeft: 0, maxTop: 0 });
|
|
9
|
+
const isDragging = useRef(false);
|
|
10
|
+
let transform = { offsetX: 0, offsetY: 0 };
|
|
11
|
+
const onMoveStart = useCallback(() => {
|
|
12
|
+
isDragging.current = true;
|
|
13
|
+
const { offsetX, offsetY } = transform;
|
|
14
|
+
const targetRect = targetRef?.current?.getBoundingClientRect();
|
|
15
|
+
const targetLeft = targetRect?.left ?? 0;
|
|
16
|
+
const targetTop = targetRect?.top ?? 0;
|
|
17
|
+
const targetWidth = targetRect?.width ?? 0;
|
|
18
|
+
const targetHeight = targetRect?.height ?? 0;
|
|
19
|
+
const clientWidth = document.documentElement.clientWidth;
|
|
20
|
+
const clientHeight = document.documentElement.clientHeight;
|
|
21
|
+
const minLeft = -targetLeft + offsetX;
|
|
22
|
+
const minTop = -targetTop + offsetY;
|
|
23
|
+
const maxLeft = clientWidth - targetLeft - targetWidth + offsetX;
|
|
24
|
+
const maxTop = clientHeight - targetTop - targetHeight + offsetY;
|
|
25
|
+
boundary.current = {
|
|
26
|
+
minLeft,
|
|
27
|
+
minTop,
|
|
28
|
+
maxLeft,
|
|
29
|
+
maxTop
|
|
30
|
+
};
|
|
31
|
+
}, [transform, targetRef?.current]);
|
|
32
|
+
const onMove = useCallback(
|
|
33
|
+
(e) => {
|
|
34
|
+
if (isDisabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const { offsetX, offsetY } = transform;
|
|
38
|
+
const { minLeft, minTop, maxLeft, maxTop } = boundary.current;
|
|
39
|
+
let moveX = offsetX + e.deltaX;
|
|
40
|
+
let moveY = offsetY + e.deltaY;
|
|
41
|
+
if (!canOverflow) {
|
|
42
|
+
moveX = Math.min(Math.max(moveX, minLeft), maxLeft);
|
|
43
|
+
moveY = Math.min(Math.max(moveY, minTop), maxTop);
|
|
44
|
+
}
|
|
45
|
+
transform = {
|
|
46
|
+
offsetX: moveX,
|
|
47
|
+
offsetY: moveY
|
|
48
|
+
};
|
|
49
|
+
if (targetRef?.current) {
|
|
50
|
+
targetRef.current.style.transform = `translate(${moveX}px, ${moveY}px)`;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[isDisabled, transform, boundary.current, canOverflow, targetRef?.current]
|
|
54
|
+
);
|
|
55
|
+
const onMoveEnd = useCallback(() => {
|
|
56
|
+
isDragging.current = false;
|
|
57
|
+
}, []);
|
|
58
|
+
const { moveProps } = useMove({
|
|
59
|
+
onMoveStart,
|
|
60
|
+
onMove,
|
|
61
|
+
onMoveEnd
|
|
62
|
+
});
|
|
63
|
+
const preventDefault = useCallback((e) => {
|
|
64
|
+
if (isDragging.current) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!isDisabled) {
|
|
70
|
+
document.body.addEventListener("touchmove", preventDefault, {
|
|
71
|
+
passive: false
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return () => {
|
|
75
|
+
document.body.removeEventListener("touchmove", preventDefault);
|
|
76
|
+
};
|
|
77
|
+
}, [isDisabled, preventDefault]);
|
|
78
|
+
return {
|
|
79
|
+
moveProps: {
|
|
80
|
+
...moveProps,
|
|
81
|
+
style: { cursor: !isDisabled ? "move" : void 0 }
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { useDraggable };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
export { useControllableState } from './hooks/use-controllable-state.js';
|
|
3
|
+
export { useDraggable } from './hooks/use-draggable.js';
|
|
4
|
+
export { GovtBanner } from './govt-banner/govt-banner.js';
|
|
2
5
|
export { Ripple } from './ripple/ripple.js';
|
|
3
6
|
export { useRipple } from './ripple/use-ripple.js';
|
|
4
7
|
export { Spinner } from './spinner/spinner.js';
|
|
5
8
|
export { useSpinner } from './spinner/use-spinner.js';
|
|
6
9
|
export { Toggle } from './toggle/toggle.js';
|
|
7
10
|
export { SkipNavLink } from './skip-nav-link/skip-nav-link.js';
|
|
11
|
+
export { Input } from './input/input.js';
|
|
8
12
|
export { TextField } from './text-field/text-field.js';
|
|
13
|
+
export { Description, FieldError, FieldErrorIcon, FieldGroup, Label } from './field/field.js';
|
|
9
14
|
export { TextArea } from './text-area/text-area.js';
|
|
10
15
|
export { TextAreaField } from './text-area-field/text-area-field.js';
|
|
11
16
|
export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
|
|
@@ -17,32 +22,34 @@ export { TagFieldItem } from './tag-field/tag-field-item.js';
|
|
|
17
22
|
export { Select } from './select/select.js';
|
|
18
23
|
export { SelectItem } from './select/select-item.js';
|
|
19
24
|
export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
|
|
20
|
-
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
21
|
-
export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs/tabs.js';
|
|
22
|
-
export { useControllableState } from './hooks/use-controllable-state.js';
|
|
23
|
-
export { Button } from './button/button.js';
|
|
24
|
-
export { GovtBanner } from './govt-banner/govt-banner.js';
|
|
25
|
-
export { Input } from './input/input.js';
|
|
26
|
-
export { Description, FieldError, FieldErrorIcon, FieldGroup, Label } from './field/field.js';
|
|
27
|
-
export { Banner } from './banner/banner.js';
|
|
28
|
-
export { Badge } from './badge/badge.js';
|
|
29
|
-
export { CalendarDate } from '@internationalized/date';
|
|
30
25
|
export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
|
|
31
26
|
export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
|
|
32
27
|
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
|
|
28
|
+
export { CalendarDate } from '@internationalized/date';
|
|
33
29
|
export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
|
|
30
|
+
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
34
31
|
export { Popover } from './popover/popover.js';
|
|
32
|
+
export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs/tabs.js';
|
|
35
33
|
export { DateField, DateInput } from './date-field/date-field.js';
|
|
36
34
|
export { DatePicker } from './date-picker/date-picker.js';
|
|
37
35
|
export { DateRangePicker } from './date-range-picker/date-range-picker.js';
|
|
38
36
|
export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
|
|
39
37
|
export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
|
|
40
|
-
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
41
38
|
export { Pagination } from './pagination/pagination.js';
|
|
42
39
|
export { PaginationCursor } from './pagination/pagination-cursor.js';
|
|
43
40
|
export { PaginationItem } from './pagination/pagination-item.js';
|
|
41
|
+
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
44
42
|
export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './pagination/use-pagination.js';
|
|
45
43
|
export { FileDropzone } from './file-dropzone/file-dropzone.js';
|
|
46
44
|
export { FileInfo } from './file-dropzone/file-info.js';
|
|
47
45
|
export { formatBytes, formatErrorMessage } from './file-dropzone/utils.js';
|
|
48
46
|
export { NumberField } from './number-field/number-field.js';
|
|
47
|
+
export { Modal } from './modal/modal.js';
|
|
48
|
+
export { ModalContent } from './modal/modal-content.js';
|
|
49
|
+
export { ModalFooter } from './modal/modal-footer.js';
|
|
50
|
+
export { ModalBody } from './modal/modal-body.js';
|
|
51
|
+
export { ModalHeader } from './modal/modal-header.js';
|
|
52
|
+
export { ModalVariantContext, useModalVariantContext } from './modal/modal-variant-context.js';
|
|
53
|
+
export { Button } from './button/button.js';
|
|
54
|
+
export { Banner } from './banner/banner.js';
|
|
55
|
+
export { Badge } from './badge/badge.js';
|
package/dist/esm/menu/menu.js
CHANGED
|
@@ -4,11 +4,11 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
import { forwardRef, useMemo, useCallback } from 'react';
|
|
5
5
|
import { useContextProps, MenuItem as MenuItem$1, composeRenderProps, Provider, Menu as Menu$1, MenuSection as MenuSection$1, Header, Collection, MenuTrigger as MenuTrigger$1, SubmenuTrigger as SubmenuTrigger$1, Separator } from 'react-aria-components';
|
|
6
6
|
import { listBoxItemStyles, menuItemStyles, menuStyles, menuSectionStyles, menuDividerStyles } from '@opengovsg/oui-theme';
|
|
7
|
+
import { Popover } from '../popover/popover.js';
|
|
7
8
|
import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
|
|
8
9
|
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
|
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';
|
|
10
11
|
import { createContext } from '../system/react-utils/context.js';
|
|
11
|
-
import { Popover } from '../popover/popover.js';
|
|
12
12
|
|
|
13
13
|
const [MenuVariantContext, useMenuVariantContext] = createContext({
|
|
14
14
|
name: "MenuVariantContext",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const i18nStrings = {
|
|
3
|
+
"en-SG": {
|
|
4
|
+
dismiss: "Dismiss"
|
|
5
|
+
},
|
|
6
|
+
"zh-SG": {
|
|
7
|
+
dismiss: "\u53D6\u6D88"
|
|
8
|
+
},
|
|
9
|
+
"ms-SG": {
|
|
10
|
+
dismiss: "Tutup"
|
|
11
|
+
},
|
|
12
|
+
"ta-SG": {
|
|
13
|
+
dismiss: "\u0BAE\u0BC2\u0B9F\u0BC1"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { i18nStrings };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export { Modal } from './modal.js';
|
|
3
|
+
export { ModalContent } from './modal-content.js';
|
|
4
|
+
export { ModalFooter } from './modal-footer.js';
|
|
5
|
+
export { ModalBody } from './modal-body.js';
|
|
6
|
+
export { ModalHeader } from './modal-header.js';
|
|
7
|
+
export { ModalVariantContext, useModalVariantContext } from './modal-variant-context.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { cn } from '@opengovsg/oui-theme';
|
|
6
|
+
import { forwardRef } from '../system/utils.js';
|
|
7
|
+
import { ModalVariantContext } from './modal-variant-context.js';
|
|
8
|
+
|
|
9
|
+
const ModalBody = forwardRef(function ModalBody2({ as, ...props }, ref) {
|
|
10
|
+
const { slots, classNames } = useContext(ModalVariantContext);
|
|
11
|
+
const Component = as || "div";
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Component,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
className: slots.body({
|
|
17
|
+
className: cn(classNames?.body, props.className)
|
|
18
|
+
}),
|
|
19
|
+
...props
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { ModalBody };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext, isValidElement } from 'react';
|
|
5
|
+
import { useMessageFormatter } from 'react-aria';
|
|
6
|
+
import { Dialog } from 'react-aria-components';
|
|
7
|
+
import { cn } from '@opengovsg/oui-theme';
|
|
8
|
+
import { i18nStrings } from './i18n.js';
|
|
9
|
+
import { ModalVariantContext } from './modal-variant-context.js';
|
|
10
|
+
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
11
|
+
import { Button } from '../button/button.js';
|
|
12
|
+
|
|
13
|
+
function ModalContent({
|
|
14
|
+
closeButtonContent: closeButtonContentProp,
|
|
15
|
+
hideCloseButton,
|
|
16
|
+
closeButtonProps,
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
const { slots, classNames, buttonSize } = useContext(ModalVariantContext);
|
|
20
|
+
const formatMessage = useMessageFormatter(i18nStrings);
|
|
21
|
+
const closeButtonContent = isValidElement(closeButtonContentProp) ? closeButtonContentProp : /* @__PURE__ */ jsx(X, {});
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
Dialog,
|
|
24
|
+
{
|
|
25
|
+
...props,
|
|
26
|
+
className: slots.dialog({
|
|
27
|
+
className: props.className ?? classNames?.dialog
|
|
28
|
+
}),
|
|
29
|
+
children: ({ close }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
!hideCloseButton && /* @__PURE__ */ jsx(
|
|
31
|
+
Button,
|
|
32
|
+
{
|
|
33
|
+
slot: "close",
|
|
34
|
+
isIconOnly: true,
|
|
35
|
+
"aria-label": formatMessage("dismiss"),
|
|
36
|
+
size: buttonSize,
|
|
37
|
+
variant: "clear",
|
|
38
|
+
color: "neutral",
|
|
39
|
+
...closeButtonProps,
|
|
40
|
+
className: slots.closeButton({
|
|
41
|
+
className: cn(classNames?.closeButton, props.className)
|
|
42
|
+
}),
|
|
43
|
+
children: closeButtonContent
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
typeof props.children === "function" ? props.children(close) : props.children
|
|
47
|
+
] })
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { ModalContent };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { cn } from '@opengovsg/oui-theme';
|
|
6
|
+
import { forwardRef } from '../system/utils.js';
|
|
7
|
+
import { ModalVariantContext } from './modal-variant-context.js';
|
|
8
|
+
|
|
9
|
+
const ModalFooter = forwardRef(function ModalFooter2({ as, ...props }, ref) {
|
|
10
|
+
const { slots, classNames } = useContext(ModalVariantContext);
|
|
11
|
+
const Component = as || "footer";
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Component,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
className: slots.footer({
|
|
17
|
+
className: cn(classNames?.footer, props.className)
|
|
18
|
+
}),
|
|
19
|
+
...props
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
ModalFooter.displayName = "ModalFooter";
|
|
24
|
+
|
|
25
|
+
export { ModalFooter };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { Heading } from 'react-aria-components';
|
|
6
|
+
import { cn } from '@opengovsg/oui-theme';
|
|
7
|
+
import { ModalVariantContext } from './modal-variant-context.js';
|
|
8
|
+
|
|
9
|
+
function ModalHeader(props) {
|
|
10
|
+
const { slots, classNames } = useContext(ModalVariantContext);
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Heading,
|
|
13
|
+
{
|
|
14
|
+
slot: "title",
|
|
15
|
+
...props,
|
|
16
|
+
className: slots.header({
|
|
17
|
+
className: cn(classNames?.header, props.className)
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { ModalHeader };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [ModalVariantContext, useModalVariantContext] = createContext({
|
|
6
|
+
name: "ModalVariantContext",
|
|
7
|
+
strict: true
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { ModalVariantContext, useModalVariantContext };
|