@opengovsg/oui 0.0.54 → 0.0.56
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/AGENTS.md +63 -0
- package/dist/cjs/avatar/avatar.cjs +1 -1
- package/dist/cjs/button/button.cjs +8 -3
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +1 -1
- package/dist/cjs/calendar/index.cjs +9 -0
- package/dist/cjs/calendar/{hooks/use-calendar-selectors.cjs → use-calendar-selectors.cjs} +1 -1
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -52
- package/dist/cjs/file-dropzone/file-dropzone.cjs +14 -3
- package/dist/cjs/govt-banner/govt-banner.cjs +63 -143
- package/dist/cjs/hooks/use-scroll-position.cjs +6 -6
- package/dist/cjs/index.cjs +21 -10
- package/dist/cjs/list-box/index.cjs +8 -0
- package/dist/cjs/list-box/list-box.cjs +65 -0
- package/dist/cjs/navbar/index.cjs +6 -6
- package/dist/cjs/navbar/{navbar-menu/item.cjs → navbar-menu-item.cjs} +3 -3
- package/dist/cjs/navbar/{navbar-menu/toggle.cjs → navbar-menu-toggle.cjs} +3 -3
- package/dist/cjs/navbar/{navbar-menu/menu.cjs → navbar-menu.cjs} +4 -4
- package/dist/cjs/navbar/navbar.cjs +3 -3
- package/dist/cjs/navbar/use-navbar.cjs +5 -1
- package/dist/cjs/pagination/index.cjs +2 -2
- package/dist/cjs/pagination/pagination.cjs +18 -18
- package/dist/cjs/pagination/use-pagination.cjs +5 -5
- package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
- package/dist/cjs/tag-field/tag-field-list.cjs +1 -8
- package/dist/esm/avatar/avatar.js +1 -1
- package/dist/esm/button/button.js +8 -3
- package/dist/esm/calendar/calendar-month-day-selector.js +1 -1
- package/dist/esm/calendar/index.js +4 -0
- package/dist/esm/calendar/{hooks/use-calendar-selectors.js → use-calendar-selectors.js} +1 -1
- package/dist/esm/combo-box/combo-box-item.js +5 -55
- package/dist/esm/file-dropzone/file-dropzone.js +14 -3
- package/dist/esm/govt-banner/govt-banner.js +64 -144
- package/dist/esm/hooks/use-scroll-position.js +6 -6
- package/dist/esm/index.js +9 -4
- package/dist/esm/list-box/index.js +2 -0
- package/dist/esm/list-box/list-box.js +63 -0
- package/dist/esm/navbar/index.js +3 -3
- package/dist/esm/navbar/{navbar-menu/item.js → navbar-menu-item.js} +3 -3
- package/dist/esm/navbar/{navbar-menu/toggle.js → navbar-menu-toggle.js} +2 -2
- package/dist/esm/navbar/{navbar-menu/menu.js → navbar-menu.js} +4 -4
- package/dist/esm/navbar/navbar.js +1 -1
- package/dist/esm/navbar/use-navbar.js +6 -2
- package/dist/esm/pagination/index.js +1 -1
- package/dist/esm/pagination/pagination.js +1 -1
- package/dist/esm/pagination/use-pagination.js +1 -1
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/tag-field/tag-field-list.js +1 -8
- package/dist/types/avatar/avatar-context.d.ts +1 -1
- package/dist/types/avatar/avatar-context.d.ts.map +1 -1
- package/dist/types/avatar/use-img-loading-status.d.ts.map +1 -0
- package/dist/types/button/button.d.ts +10 -0
- package/dist/types/button/button.d.ts.map +1 -1
- package/dist/types/calendar/index.d.ts +4 -0
- package/dist/types/calendar/index.d.ts.map +1 -1
- package/dist/types/calendar/use-calendar-selectors.d.ts.map +1 -0
- package/dist/types/combo-box/combo-box-item.d.ts +3 -10
- package/dist/types/combo-box/combo-box-item.d.ts.map +1 -1
- package/dist/types/file-dropzone/file-dropzone.d.ts.map +1 -1
- package/dist/types/file-dropzone/utils.d.ts.map +1 -1
- package/dist/types/govt-banner/govt-banner.d.ts +5 -14
- package/dist/types/govt-banner/govt-banner.d.ts.map +1 -1
- package/dist/types/hooks/use-scroll-position.d.ts +4 -2
- package/dist/types/hooks/use-scroll-position.d.ts.map +1 -1
- 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/list-box/index.d.ts +3 -0
- package/dist/types/list-box/index.d.ts.map +1 -0
- package/dist/types/list-box/list-box.d.ts +11 -0
- package/dist/types/list-box/list-box.d.ts.map +1 -0
- package/dist/types/navbar/index.d.ts +6 -6
- package/dist/types/navbar/index.d.ts.map +1 -1
- package/dist/types/navbar/{navbar-menu/i18n.d.ts → navbar-menu-i18n.d.ts} +1 -1
- package/dist/types/navbar/navbar-menu-i18n.d.ts.map +1 -0
- package/dist/types/navbar/{navbar-menu/item.d.ts → navbar-menu-item.d.ts} +3 -3
- package/dist/types/navbar/navbar-menu-item.d.ts.map +1 -0
- package/dist/types/navbar/{navbar-menu/toggle.d.ts → navbar-menu-toggle.d.ts} +1 -1
- package/dist/types/navbar/navbar-menu-toggle.d.ts.map +1 -0
- package/dist/types/navbar/{navbar-menu/menu.d.ts → navbar-menu.d.ts} +3 -3
- package/dist/types/navbar/navbar-menu.d.ts.map +1 -0
- package/dist/types/navbar/use-navbar.d.ts.map +1 -1
- package/dist/types/pagination/index.d.ts +2 -2
- package/dist/types/pagination/index.d.ts.map +1 -1
- package/dist/types/pagination/pagination.d.ts.map +1 -1
- package/dist/types/pagination/{hooks/use-pagination.d.ts → use-pagination-base.d.ts} +1 -1
- package/dist/types/pagination/use-pagination-base.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination-item.d.ts +1 -1
- package/dist/types/pagination/use-pagination-item.d.ts.map +1 -1
- package/dist/types/pagination/use-pagination.d.ts +1 -1
- package/dist/types/pagination/use-pagination.d.ts.map +1 -1
- package/dist/types/tag-field/tag-field-list.d.ts.map +1 -1
- package/package.json +8 -7
- package/dist/cjs/calendar/hooks/index.cjs +0 -8
- package/dist/esm/calendar/hooks/index.js +0 -2
- package/dist/types/avatar/hooks/use-img-loading-status.d.ts.map +0 -1
- package/dist/types/calendar/hooks/index.d.ts +0 -2
- package/dist/types/calendar/hooks/index.d.ts.map +0 -1
- package/dist/types/calendar/hooks/use-calendar-selectors.d.ts.map +0 -1
- package/dist/types/navbar/navbar-menu/i18n.d.ts.map +0 -1
- package/dist/types/navbar/navbar-menu/item.d.ts.map +0 -1
- package/dist/types/navbar/navbar-menu/menu.d.ts.map +0 -1
- package/dist/types/navbar/navbar-menu/toggle.d.ts.map +0 -1
- package/dist/types/pagination/hooks/use-pagination.d.ts.map +0 -1
- /package/dist/cjs/avatar/{hooks/use-img-loading-status.cjs → use-img-loading-status.cjs} +0 -0
- /package/dist/cjs/navbar/{navbar-menu/i18n.cjs → navbar-menu-i18n.cjs} +0 -0
- /package/dist/cjs/pagination/{hooks/use-pagination.cjs → use-pagination-base.cjs} +0 -0
- /package/dist/esm/avatar/{hooks/use-img-loading-status.js → use-img-loading-status.js} +0 -0
- /package/dist/esm/navbar/{navbar-menu/i18n.js → navbar-menu-i18n.js} +0 -0
- /package/dist/esm/pagination/{hooks/use-pagination.js → use-pagination-base.js} +0 -0
- /package/dist/types/avatar/{hooks/use-img-loading-status.d.ts → use-img-loading-status.d.ts} +0 -0
- /package/dist/types/calendar/{hooks/use-calendar-selectors.d.ts → use-calendar-selectors.d.ts} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var $670gB$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
|
+
|
|
11
|
+
const ListBoxItem = utils.forwardRef(function ListBoxItem2(originalProps, ref) {
|
|
12
|
+
const [
|
|
13
|
+
{ className, description, children, classNames, ...props },
|
|
14
|
+
variantProps
|
|
15
|
+
] = utils.mapPropsVariants(originalProps, ouiTheme.listBoxItemStyles.variantKeys);
|
|
16
|
+
const styles = ouiTheme.listBoxItemStyles(variantProps);
|
|
17
|
+
const defaultTextValue = $670gB$react.useMemo(() => {
|
|
18
|
+
if (props.textValue) {
|
|
19
|
+
return props.textValue;
|
|
20
|
+
}
|
|
21
|
+
if (typeof children === "string") {
|
|
22
|
+
return children;
|
|
23
|
+
}
|
|
24
|
+
return void 0;
|
|
25
|
+
}, [children, props.textValue]);
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
reactAriaComponents.ListBoxItem,
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
textValue: defaultTextValue,
|
|
31
|
+
...props,
|
|
32
|
+
className: reactAriaComponents.composeRenderProps(
|
|
33
|
+
className ?? classNames?.container,
|
|
34
|
+
(className2, renderProps) => styles.container({ ...renderProps, className: className2 })
|
|
35
|
+
),
|
|
36
|
+
children: (renderProps) => {
|
|
37
|
+
if (typeof children === "function") {
|
|
38
|
+
return children(renderProps);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
41
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
reactAriaComponents.Text,
|
|
43
|
+
{
|
|
44
|
+
className: styles.label({ className: classNames?.label }),
|
|
45
|
+
slot: "label",
|
|
46
|
+
children
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
|
+
reactAriaComponents.Text,
|
|
51
|
+
{
|
|
52
|
+
className: styles.description({
|
|
53
|
+
className: classNames?.description
|
|
54
|
+
}),
|
|
55
|
+
slot: "description",
|
|
56
|
+
children: description
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
exports.ListBoxItem = ListBoxItem;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
var navbar = require('./navbar.cjs');
|
|
5
5
|
var navbarBrand = require('./navbar-brand.cjs');
|
|
6
6
|
var navbarContent = require('./navbar-content.cjs');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
var navbarMenu = require('./navbar-menu.cjs');
|
|
8
|
+
var navbarMenuItem = require('./navbar-menu-item.cjs');
|
|
9
|
+
var navbarMenuToggle = require('./navbar-menu-toggle.cjs');
|
|
10
10
|
var navbarItem = require('./navbar-item.cjs');
|
|
11
11
|
var useNavbar = require('./use-navbar.cjs');
|
|
12
12
|
var navbarContext = require('./navbar-context.cjs');
|
|
@@ -16,9 +16,9 @@ var navbarContext = require('./navbar-context.cjs');
|
|
|
16
16
|
exports.Navbar = navbar.Navbar;
|
|
17
17
|
exports.NavbarBrand = navbarBrand.NavbarBrand;
|
|
18
18
|
exports.NavbarContent = navbarContent.NavbarContent;
|
|
19
|
-
exports.NavbarMenu =
|
|
20
|
-
exports.NavbarMenuItem =
|
|
21
|
-
exports.NavbarMenuToggle =
|
|
19
|
+
exports.NavbarMenu = navbarMenu.NavbarMenu;
|
|
20
|
+
exports.NavbarMenuItem = navbarMenuItem.NavbarMenuItem;
|
|
21
|
+
exports.NavbarMenuToggle = navbarMenuToggle.NavbarMenuToggle;
|
|
22
22
|
exports.NavbarItem = navbarItem.NavbarItem;
|
|
23
23
|
exports.useNavbar = useNavbar.useNavbar;
|
|
24
24
|
exports.NavbarProvider = navbarContext.NavbarProvider;
|
|
@@ -5,9 +5,9 @@
|
|
|
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 utils = require('
|
|
9
|
-
var navbarContext = require('
|
|
10
|
-
var refs = require('
|
|
8
|
+
var utils = require('../system/utils.cjs');
|
|
9
|
+
var navbarContext = require('./navbar-context.cjs');
|
|
10
|
+
var refs = require('../system/react-utils/refs.cjs');
|
|
11
11
|
|
|
12
12
|
const NavbarMenuItem = utils.forwardRef(
|
|
13
13
|
(props, ref) => {
|
|
@@ -7,8 +7,8 @@ var $670gB$react = require('react');
|
|
|
7
7
|
var reactAria = require('react-aria');
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
|
-
var navbarContext = require('
|
|
11
|
-
var
|
|
10
|
+
var navbarContext = require('./navbar-context.cjs');
|
|
11
|
+
var navbarMenuI18n = require('./navbar-menu-i18n.cjs');
|
|
12
12
|
|
|
13
13
|
const NavbarMenuToggle = ({
|
|
14
14
|
icon,
|
|
@@ -35,7 +35,7 @@ const NavbarMenuToggle = ({
|
|
|
35
35
|
}
|
|
36
36
|
window.scrollTo({ top: menuTopOffset, behavior: "instant" });
|
|
37
37
|
};
|
|
38
|
-
const stringFormatter = reactAria.useLocalizedStringFormatter(
|
|
38
|
+
const stringFormatter = reactAria.useLocalizedStringFormatter(navbarMenuI18n.i18nStrings);
|
|
39
39
|
const toggleStyles = $670gB$react.useMemo(() => {
|
|
40
40
|
return ouiTheme.buttonStyles({
|
|
41
41
|
variant: "unstyled",
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var Overlay = require('
|
|
6
|
+
var Overlay = require('../node_modules/.pnpm/@react-aria_overlays@3.31.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/Overlay.cjs');
|
|
7
7
|
var reactAria = require('react-aria');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
-
var utils = require('
|
|
10
|
-
var navbarContext = require('
|
|
11
|
-
var refs = require('
|
|
9
|
+
var utils = require('../system/utils.cjs');
|
|
10
|
+
var navbarContext = require('./navbar-context.cjs');
|
|
11
|
+
var refs = require('../system/react-utils/refs.cjs');
|
|
12
12
|
|
|
13
13
|
const NavbarMenu = utils.forwardRef(
|
|
14
14
|
({ className, children, portalContainer, style, onKeyDown, ...props }, ref) => {
|
|
@@ -8,7 +8,7 @@ var reactAria = require('react-aria');
|
|
|
8
8
|
var children = require('../system/react-utils/children.cjs');
|
|
9
9
|
var utils = require('../system/utils.cjs');
|
|
10
10
|
var navbarContext = require('./navbar-context.cjs');
|
|
11
|
-
var
|
|
11
|
+
var navbarMenu = require('./navbar-menu.cjs');
|
|
12
12
|
var useNavbar = require('./use-navbar.cjs');
|
|
13
13
|
|
|
14
14
|
const showOnScrollUpVariants = {
|
|
@@ -29,10 +29,10 @@ const Navbar = utils.forwardRef((props, ref) => {
|
|
|
29
29
|
const { children: children$1, ...otherProps } = props;
|
|
30
30
|
const context = useNavbar.useNavbar({ ...otherProps, ref });
|
|
31
31
|
const Component = context.Component;
|
|
32
|
-
const [childrenWithoutMenu, menu
|
|
32
|
+
const [childrenWithoutMenu, menu] = children.pickChildren(children$1, navbarMenu.NavbarMenu);
|
|
33
33
|
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
34
34
|
/* @__PURE__ */ jsxRuntime.jsx("header", { ...context.getWrapperProps(), children: childrenWithoutMenu }),
|
|
35
|
-
menu
|
|
35
|
+
menu
|
|
36
36
|
] });
|
|
37
37
|
return /* @__PURE__ */ jsxRuntime.jsx(navbarContext.NavbarProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(reactAria.FocusScope, { contain: context.isMenuOpen, children: context.shouldShowOnScrollUp ? /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domAnimation, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
38
|
react.m.nav,
|
|
@@ -70,8 +70,12 @@ function useNavbar(originalProps) {
|
|
|
70
70
|
$670gB$react.useEffect(() => {
|
|
71
71
|
navHeight.current = domRef.current?.offsetHeight || 0;
|
|
72
72
|
}, [domRef]);
|
|
73
|
+
const [scrollElement, setScrollElement] = $670gB$react.useState(null);
|
|
74
|
+
$670gB$react.useLayoutEffect(() => {
|
|
75
|
+
setScrollElement(parentRef?.current ?? null);
|
|
76
|
+
}, [parentRef]);
|
|
73
77
|
useScrollPosition.useScrollPosition({
|
|
74
|
-
|
|
78
|
+
element: scrollElement,
|
|
75
79
|
isEnabled: shouldShowOnScrollUp || !disableScrollHandler,
|
|
76
80
|
callback: ({ prevPos, currPos }) => {
|
|
77
81
|
onScrollPositionChange?.(currPos.y);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var pagination = require('./pagination.cjs');
|
|
5
5
|
var paginationCursor = require('./pagination-cursor.cjs');
|
|
6
6
|
var paginationItem = require('./pagination-item.cjs');
|
|
7
|
-
var
|
|
7
|
+
var usePaginationBase = require('./use-pagination-base.cjs');
|
|
8
8
|
var usePagination = require('./use-pagination.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
@@ -12,6 +12,6 @@ var usePagination = require('./use-pagination.cjs');
|
|
|
12
12
|
exports.Pagination = pagination.Pagination;
|
|
13
13
|
exports.PaginationCursor = paginationCursor.PaginationCursor;
|
|
14
14
|
exports.PaginationItem = paginationItem.PaginationItem;
|
|
15
|
-
exports.PaginationItemType =
|
|
15
|
+
exports.PaginationItemType = usePaginationBase.PaginationItemType;
|
|
16
16
|
exports.CURSOR_TRANSITION_TIMEOUT = usePagination.CURSOR_TRANSITION_TIMEOUT;
|
|
17
17
|
exports.usePagination = usePagination.usePagination;
|
|
@@ -7,10 +7,10 @@ var $670gB$react = require('react');
|
|
|
7
7
|
var i18n = require('@react-aria/i18n');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
9
|
var utils = require('../system/utils.cjs');
|
|
10
|
-
var usePagination$1 = require('./hooks/use-pagination.cjs');
|
|
11
10
|
var paginationCursor = require('./pagination-cursor.cjs');
|
|
12
11
|
var paginationItem = require('./pagination-item.cjs');
|
|
13
12
|
var usePagination = require('./use-pagination.cjs');
|
|
13
|
+
var usePaginationBase = require('./use-pagination-base.cjs');
|
|
14
14
|
var chevronLeft = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs');
|
|
15
15
|
var ellipsis = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/ellipsis.cjs');
|
|
16
16
|
var chevronsRight = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevrons-right.cjs');
|
|
@@ -42,7 +42,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
42
42
|
const isRTL = direction === "rtl";
|
|
43
43
|
const renderChevronIcon = $670gB$react.useCallback(
|
|
44
44
|
(key) => {
|
|
45
|
-
if (key ===
|
|
45
|
+
if (key === usePaginationBase.PaginationItemType.PREV && !isRTL || key === usePaginationBase.PaginationItemType.NEXT && isRTL) {
|
|
46
46
|
return /* @__PURE__ */ jsxRuntime.jsx(chevronLeft.default, {});
|
|
47
47
|
}
|
|
48
48
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -66,11 +66,11 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
66
66
|
"data-slot": "prev",
|
|
67
67
|
getAriaLabel: getItemAriaLabel,
|
|
68
68
|
isDisabled: props.isDisabled || !loop && activePage === 1,
|
|
69
|
-
value:
|
|
69
|
+
value: usePaginationBase.PaginationItemType.PREV,
|
|
70
70
|
onPress: onPrevious,
|
|
71
|
-
children: renderChevronIcon(
|
|
71
|
+
children: renderChevronIcon(usePaginationBase.PaginationItemType.PREV)
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
usePaginationBase.PaginationItemType.PREV
|
|
74
74
|
);
|
|
75
75
|
}, [
|
|
76
76
|
slots,
|
|
@@ -92,11 +92,11 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
92
92
|
"data-slot": "next",
|
|
93
93
|
getAriaLabel: getItemAriaLabel,
|
|
94
94
|
isDisabled: props.isDisabled || !loop && activePage === total,
|
|
95
|
-
value:
|
|
95
|
+
value: usePaginationBase.PaginationItemType.NEXT,
|
|
96
96
|
onPress: onNext,
|
|
97
|
-
children: renderChevronIcon(
|
|
97
|
+
children: renderChevronIcon(usePaginationBase.PaginationItemType.NEXT)
|
|
98
98
|
},
|
|
99
|
-
|
|
99
|
+
usePaginationBase.PaginationItemType.NEXT
|
|
100
100
|
);
|
|
101
101
|
}, [
|
|
102
102
|
slots,
|
|
@@ -114,19 +114,19 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
114
114
|
const isBefore = index < range.indexOf(activePage);
|
|
115
115
|
if (renderItemProp && typeof renderItemProp === "function") {
|
|
116
116
|
let page = typeof value == "number" ? value : index;
|
|
117
|
-
if (value ===
|
|
117
|
+
if (value === usePaginationBase.PaginationItemType.NEXT) {
|
|
118
118
|
page = activePage + 1;
|
|
119
119
|
}
|
|
120
|
-
if (value ===
|
|
120
|
+
if (value === usePaginationBase.PaginationItemType.PREV) {
|
|
121
121
|
page = activePage - 1;
|
|
122
122
|
}
|
|
123
|
-
if (value ===
|
|
123
|
+
if (value === usePaginationBase.PaginationItemType.DOTS) {
|
|
124
124
|
page = isBefore ? activePage - dotsJump >= 1 ? activePage - dotsJump : 1 : activePage + dotsJump <= total ? activePage + dotsJump : total;
|
|
125
125
|
}
|
|
126
126
|
const itemChildren = {
|
|
127
|
-
[
|
|
128
|
-
[
|
|
129
|
-
[
|
|
127
|
+
[usePaginationBase.PaginationItemType.PREV]: renderChevronIcon(usePaginationBase.PaginationItemType.PREV),
|
|
128
|
+
[usePaginationBase.PaginationItemType.NEXT]: renderChevronIcon(usePaginationBase.PaginationItemType.NEXT),
|
|
129
|
+
[usePaginationBase.PaginationItemType.DOTS]: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
130
130
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
131
131
|
ellipsis.default,
|
|
132
132
|
{
|
|
@@ -168,13 +168,13 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
168
168
|
getAriaLabel: getItemAriaLabel
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
if (value ===
|
|
171
|
+
if (value === usePaginationBase.PaginationItemType.PREV) {
|
|
172
172
|
return renderPrevItem();
|
|
173
173
|
}
|
|
174
|
-
if (value ===
|
|
174
|
+
if (value === usePaginationBase.PaginationItemType.NEXT) {
|
|
175
175
|
return renderNextItem();
|
|
176
176
|
}
|
|
177
|
-
if (value ===
|
|
177
|
+
if (value === usePaginationBase.PaginationItemType.DOTS) {
|
|
178
178
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
179
179
|
paginationItem.PaginationItem,
|
|
180
180
|
{
|
|
@@ -206,7 +206,7 @@ const Pagination = utils.forwardRef((props, ref) => {
|
|
|
206
206
|
)
|
|
207
207
|
]
|
|
208
208
|
},
|
|
209
|
-
|
|
209
|
+
usePaginationBase.PaginationItemType.DOTS + isBefore
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
212
|
return /* @__PURE__ */ $670gB$react.createElement(
|
|
@@ -8,7 +8,7 @@ var useDeepCompare = require('use-deep-compare');
|
|
|
8
8
|
var usehooksTs = require('usehooks-ts');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
10
|
var utils = require('../system/utils.cjs');
|
|
11
|
-
var
|
|
11
|
+
var usePaginationBase = require('./use-pagination-base.cjs');
|
|
12
12
|
var refs = require('../system/react-utils/refs.cjs');
|
|
13
13
|
|
|
14
14
|
const CURSOR_TRANSITION_TIMEOUT = 300;
|
|
@@ -93,7 +93,7 @@ function usePagination(originalProps) {
|
|
|
93
93
|
},
|
|
94
94
|
[domRef]
|
|
95
95
|
);
|
|
96
|
-
const { range, activePage, setPage, previous, next, first, last } =
|
|
96
|
+
const { range, activePage, setPage, previous, next, first, last } = usePaginationBase.usePagination({
|
|
97
97
|
page,
|
|
98
98
|
total,
|
|
99
99
|
initialPage,
|
|
@@ -179,11 +179,11 @@ function usePagination(originalProps) {
|
|
|
179
179
|
return getItemAriaLabelProp(page2);
|
|
180
180
|
}
|
|
181
181
|
switch (page2) {
|
|
182
|
-
case
|
|
182
|
+
case usePaginationBase.PaginationItemType.DOTS:
|
|
183
183
|
return "dots element";
|
|
184
|
-
case
|
|
184
|
+
case usePaginationBase.PaginationItemType.PREV:
|
|
185
185
|
return "previous page button";
|
|
186
|
-
case
|
|
186
|
+
case usePaginationBase.PaginationItemType.NEXT:
|
|
187
187
|
return "next page button";
|
|
188
188
|
case "first":
|
|
189
189
|
return "first page button";
|
|
@@ -8,11 +8,11 @@ var date = require('@internationalized/date');
|
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var useDeepCompare = require('use-deep-compare');
|
|
10
10
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
11
|
-
var calendarStyleContext = require('../calendar/calendar-style-context.cjs');
|
|
12
11
|
var agnosticCalendarStateContext = require('../calendar/agnostic-calendar-state-context.cjs');
|
|
13
12
|
var calendarBottomContent = require('../calendar/calendar-bottom-content.cjs');
|
|
14
13
|
var calendarGridHeader = require('../calendar/calendar-grid-header.cjs');
|
|
15
14
|
var calendarHeader = require('../calendar/calendar-header.cjs');
|
|
15
|
+
var calendarStyleContext = require('../calendar/calendar-style-context.cjs');
|
|
16
16
|
var utils = require('../system/utils.cjs');
|
|
17
17
|
|
|
18
18
|
const RangeCalendar = utils.forwardRefGeneric(function RangeCalendar2(originalProps, ref) {
|
|
@@ -67,14 +67,7 @@ const TagFieldListInner = (props, ref) => {
|
|
|
67
67
|
if (typeof props.children === "function") {
|
|
68
68
|
return props.children({ ...childProps, itemProps });
|
|
69
69
|
}
|
|
70
|
-
return /* @__PURE__ */ $670gB$react.createElement(
|
|
71
|
-
tagFieldItem.TagFieldItem,
|
|
72
|
-
{
|
|
73
|
-
...childProps,
|
|
74
|
-
...itemProps,
|
|
75
|
-
key
|
|
76
|
-
}
|
|
77
|
-
);
|
|
70
|
+
return /* @__PURE__ */ $670gB$react.createElement(tagFieldItem.TagFieldItem, { ...childProps, ...itemProps, key });
|
|
78
71
|
}) });
|
|
79
72
|
};
|
|
80
73
|
const TagFieldList = utils.forwardRefGeneric(TagFieldListInner);
|
|
@@ -7,7 +7,7 @@ import { avatarStyles, dataAttr } from '@opengovsg/oui-theme';
|
|
|
7
7
|
import { forwardRef, mapPropsVariants } from '../system/utils.js';
|
|
8
8
|
import { AvatarContext, useAvatarContext } from './avatar-context.js';
|
|
9
9
|
import { useAvatarGroupContext } from './avatar-group-context.js';
|
|
10
|
-
import { useImageLoadingStatus } from './
|
|
10
|
+
import { useImageLoadingStatus } from './use-img-loading-status.js';
|
|
11
11
|
import { getInitialsFromText } from './utils.js';
|
|
12
12
|
import { useDomRef } from '../system/react-utils/refs.js';
|
|
13
13
|
import User from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.js';
|
|
@@ -30,6 +30,7 @@ const Button = forwardRef(
|
|
|
30
30
|
spinner: spinnerProp,
|
|
31
31
|
isIconOnly,
|
|
32
32
|
isAttached,
|
|
33
|
+
preserveWidth,
|
|
33
34
|
...props
|
|
34
35
|
}, ref) => {
|
|
35
36
|
const {
|
|
@@ -50,6 +51,7 @@ const Button = forwardRef(
|
|
|
50
51
|
const spinnerSize = buttonSpinnerSizeMap[size];
|
|
51
52
|
return /* @__PURE__ */ jsx(Spinner, { size: spinnerSize });
|
|
52
53
|
}, [size, spinnerProp]);
|
|
54
|
+
const shouldPreserveWidth = isPending && preserveWidth && !loadingText && !pendingElement;
|
|
53
55
|
return /* @__PURE__ */ jsx(
|
|
54
56
|
Button$1,
|
|
55
57
|
{
|
|
@@ -73,11 +75,14 @@ const Button = forwardRef(
|
|
|
73
75
|
ref,
|
|
74
76
|
children: (renderProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
75
77
|
renderChildren(renderProps, startContent),
|
|
76
|
-
isPending && spinnerPlacement === "start" ? renderChildren(renderProps, spinner) : null,
|
|
77
|
-
isPending ?
|
|
78
|
+
isPending && !shouldPreserveWidth && spinnerPlacement === "start" ? renderChildren(renderProps, spinner) : null,
|
|
79
|
+
!isPending ? renderChildren(renderProps, children) : shouldPreserveWidth ? /* @__PURE__ */ jsxs("span", { className: "relative inline-flex items-center justify-center", children: [
|
|
80
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "opacity-0", children: renderChildren(renderProps, children) }),
|
|
81
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 flex items-center justify-center", children: renderChildren(renderProps, spinner) })
|
|
82
|
+
] }) : null,
|
|
78
83
|
isPending && loadingText ? loadingText : null,
|
|
79
84
|
isPending && pendingElement ? renderChildren(renderProps, pendingElement) : null,
|
|
80
|
-
isPending && spinnerPlacement === "end" ? renderChildren(renderProps, spinner) : null,
|
|
85
|
+
isPending && !shouldPreserveWidth && spinnerPlacement === "end" ? renderChildren(renderProps, spinner) : null,
|
|
81
86
|
renderChildren(renderProps, endContent),
|
|
82
87
|
!disableRipple && /* @__PURE__ */ jsx(Ripple, { onClear: onClearRipple, ripples })
|
|
83
88
|
] })
|
|
@@ -10,7 +10,7 @@ import { SelectItem } from '../select/select-item.js';
|
|
|
10
10
|
import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
11
11
|
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
12
12
|
import { i18nStrings } from './i18n.js';
|
|
13
|
-
import { useCalendarSelectors } from './
|
|
13
|
+
import { useCalendarSelectors } from './use-calendar-selectors.js';
|
|
14
14
|
|
|
15
15
|
const CalendarMonthDaySelector = () => {
|
|
16
16
|
const { slots, size, classNames } = useCalendarStyleContext();
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
export { AgnosticCalendarStateContext, useAgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
2
3
|
export { Calendar, CalendarStateWrapper } from './calendar.js';
|
|
4
|
+
export { CalendarBottomContent } from './calendar-bottom-content.js';
|
|
5
|
+
export { CalendarGridHeader } from './calendar-grid-header.js';
|
|
6
|
+
export { CalendarHeader } from './calendar-header.js';
|
|
3
7
|
export { CalendarStyleContext, useCalendarStyleContext } from './calendar-style-context.js';
|
|
4
8
|
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './utils.js';
|
|
5
9
|
export { CalendarDate } from '@internationalized/date';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useDateFormatter } from 'react-aria';
|
|
5
|
-
import { useGenerateLocalizedMonths, useGenerateLocalizedYears } from '
|
|
5
|
+
import { useGenerateLocalizedMonths, useGenerateLocalizedYears } from './utils.js';
|
|
6
6
|
|
|
7
7
|
const useCalendarSelectors = (state) => {
|
|
8
8
|
const yearRange = useMemo(() => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
import { jsx
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { forwardRef, mapPropsVariants } from '../system/utils.js';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContextProps } from 'react-aria-components';
|
|
5
|
+
import { ListBoxItem } from '../list-box/list-box.js';
|
|
6
|
+
import { forwardRef } from '../system/utils.js';
|
|
8
7
|
import { ComboBoxVariantContext } from './combo-box-variant-context.js';
|
|
9
8
|
|
|
10
9
|
const ComboBoxItem = forwardRef(function ComboBoxItem2(originalProps, ref) {
|
|
@@ -13,56 +12,7 @@ const ComboBoxItem = forwardRef(function ComboBoxItem2(originalProps, ref) {
|
|
|
13
12
|
ref,
|
|
14
13
|
ComboBoxVariantContext
|
|
15
14
|
);
|
|
16
|
-
|
|
17
|
-
{ className, description, children, classNames, ...props },
|
|
18
|
-
variantProps
|
|
19
|
-
] = mapPropsVariants(originalProps, listBoxItemStyles.variantKeys);
|
|
20
|
-
const styles = listBoxItemStyles(variantProps);
|
|
21
|
-
const defaultTextValue = useMemo(() => {
|
|
22
|
-
if (props.textValue) {
|
|
23
|
-
return props.textValue;
|
|
24
|
-
}
|
|
25
|
-
if (typeof children === "string") {
|
|
26
|
-
return children;
|
|
27
|
-
}
|
|
28
|
-
return void 0;
|
|
29
|
-
}, [children, props.textValue]);
|
|
30
|
-
return /* @__PURE__ */ jsx(
|
|
31
|
-
ListBoxItem,
|
|
32
|
-
{
|
|
33
|
-
textValue: defaultTextValue,
|
|
34
|
-
...props,
|
|
35
|
-
className: composeRenderProps(
|
|
36
|
-
className ?? classNames?.container,
|
|
37
|
-
(className2, renderProps) => styles.container({ ...renderProps, className: className2 })
|
|
38
|
-
),
|
|
39
|
-
children: (renderProps) => {
|
|
40
|
-
if (typeof children === "function") {
|
|
41
|
-
return children(renderProps);
|
|
42
|
-
}
|
|
43
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
-
/* @__PURE__ */ jsx(
|
|
45
|
-
Text,
|
|
46
|
-
{
|
|
47
|
-
className: styles.label({ className: classNames?.label }),
|
|
48
|
-
slot: "label",
|
|
49
|
-
children
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
description && /* @__PURE__ */ jsx(
|
|
53
|
-
Text,
|
|
54
|
-
{
|
|
55
|
-
className: styles.description({
|
|
56
|
-
className: classNames?.description
|
|
57
|
-
}),
|
|
58
|
-
slot: "description",
|
|
59
|
-
children: description
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
] });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
);
|
|
15
|
+
return /* @__PURE__ */ jsx(ListBoxItem, { ref, ...originalProps });
|
|
66
16
|
});
|
|
67
17
|
|
|
68
18
|
export { ComboBoxItem };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import { ErrorCode, useDropzone } from 'react-dropzone';
|
|
5
4
|
import { useCallback, useMemo, useEffect } from 'react';
|
|
6
5
|
import { useFormValidationState } from '@react-stately/form';
|
|
7
6
|
import { useField, useId } from 'react-aria';
|
|
8
7
|
import { Provider, LabelContext, GroupContext, TextContext, FieldErrorContext, Group } from 'react-aria-components';
|
|
8
|
+
import { ErrorCode, useDropzone } from 'react-dropzone';
|
|
9
9
|
import { fileDropzoneStyles, dataAttr } from '@opengovsg/oui-theme';
|
|
10
10
|
import { Label, Description, FieldError } from '../field/field.js';
|
|
11
11
|
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
@@ -88,7 +88,11 @@ const FileDropzone = (originalProps) => {
|
|
|
88
88
|
(file) => {
|
|
89
89
|
const errors = [];
|
|
90
90
|
if (maxFileSizeByType.length > 0) {
|
|
91
|
-
const limit = resolveMaxFileSize(
|
|
91
|
+
const limit = resolveMaxFileSize(
|
|
92
|
+
file.type,
|
|
93
|
+
maxFileSizeByType,
|
|
94
|
+
maxFileSize
|
|
95
|
+
);
|
|
92
96
|
if (limit !== Number.POSITIVE_INFINITY && file.size > limit) {
|
|
93
97
|
errors.push({
|
|
94
98
|
code: ErrorCode.FileTooLarge,
|
|
@@ -196,7 +200,14 @@ const FileDropzone = (originalProps) => {
|
|
|
196
200
|
return `Minimum file size: ${formatBytes(minFileSize, 2, fileSizeBase)}`;
|
|
197
201
|
}
|
|
198
202
|
return null;
|
|
199
|
-
}, [
|
|
203
|
+
}, [
|
|
204
|
+
maxFileSize,
|
|
205
|
+
maxFileSizeByType,
|
|
206
|
+
minFileSize,
|
|
207
|
+
showFileSizeText,
|
|
208
|
+
fileSizeBase,
|
|
209
|
+
fileSizeTextOverride
|
|
210
|
+
]);
|
|
200
211
|
const triggerFileSelector = useCallback(() => {
|
|
201
212
|
if (isDisabled || isReadOnly) return;
|
|
202
213
|
dropzoneState.inputRef.current?.click();
|