@opengovsg/oui 0.0.44 → 0.0.45
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/banner/banner.cjs +1 -1
- package/dist/cjs/checkbox/checkbox.cjs +1 -1
- package/dist/cjs/combo-box/combo-box.cjs +1 -1
- package/dist/cjs/date-field/date-field.cjs +1 -1
- package/dist/cjs/date-picker/date-picker.cjs +4 -5
- package/dist/cjs/date-range-picker/date-range-picker.cjs +3 -3
- package/dist/cjs/file-dropzone/file-dropzone.cjs +2 -2
- package/dist/cjs/file-dropzone/file-info.cjs +1 -1
- package/dist/cjs/index.cjs +88 -74
- package/dist/cjs/modal/modal-content.cjs +1 -1
- package/dist/cjs/number-field/number-field.cjs +2 -2
- package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
- package/dist/cjs/search-field/search-field.cjs +2 -2
- package/dist/cjs/select/select.cjs +2 -2
- package/dist/cjs/sidebar/context.cjs +24 -0
- package/dist/cjs/sidebar/i18n.cjs +23 -0
- package/dist/cjs/sidebar/index.cjs +17 -0
- package/dist/cjs/sidebar/sidebar-header.cjs +40 -0
- package/dist/cjs/sidebar/sidebar-item.cjs +61 -0
- package/dist/cjs/sidebar/sidebar-list.cjs +213 -0
- package/dist/cjs/sidebar/sidebar-root.cjs +63 -0
- package/dist/cjs/sidebar/sidebar.cjs +31 -0
- package/dist/cjs/sidebar/types.cjs +3 -0
- package/dist/cjs/sidebar/utils.cjs +12 -0
- package/dist/cjs/tag-field/tag-field.cjs +1 -1
- package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
- package/dist/cjs/text-field/text-field.cjs +1 -1
- package/dist/cjs/time-field/time-field.cjs +2 -2
- package/dist/cjs/tooltip/index.cjs +9 -0
- package/dist/cjs/tooltip/tooltip.cjs +54 -0
- package/dist/esm/banner/banner.js +1 -1
- package/dist/esm/checkbox/checkbox.js +1 -1
- package/dist/esm/combo-box/combo-box.js +1 -1
- package/dist/esm/date-field/date-field.js +1 -1
- package/dist/esm/date-picker/date-picker.js +4 -5
- package/dist/esm/date-range-picker/date-range-picker.js +3 -3
- package/dist/esm/file-dropzone/file-dropzone.js +2 -2
- package/dist/esm/file-dropzone/file-info.js +1 -1
- package/dist/esm/index.js +31 -25
- package/dist/esm/modal/modal-content.js +1 -1
- package/dist/esm/number-field/number-field.js +2 -2
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/search-field/search-field.js +2 -2
- package/dist/esm/select/select.js +2 -2
- package/dist/esm/sidebar/context.js +17 -0
- package/dist/esm/sidebar/i18n.js +21 -0
- package/dist/esm/sidebar/index.js +6 -0
- package/dist/esm/sidebar/sidebar-header.js +38 -0
- package/dist/esm/sidebar/sidebar-item.js +59 -0
- package/dist/esm/sidebar/sidebar-list.js +211 -0
- package/dist/esm/sidebar/sidebar-root.js +61 -0
- package/dist/esm/sidebar/sidebar.js +28 -0
- package/dist/esm/sidebar/types.js +1 -0
- package/dist/esm/sidebar/utils.js +9 -0
- package/dist/esm/tag-field/tag-field.js +1 -1
- package/dist/esm/text-area-field/text-area-field.js +1 -1
- package/dist/esm/text-field/text-field.js +1 -1
- package/dist/esm/time-field/time-field.js +2 -2
- package/dist/esm/tooltip/index.js +2 -0
- package/dist/esm/tooltip/tooltip.js +51 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/sidebar/context.d.ts +22 -0
- package/dist/types/sidebar/context.d.ts.map +1 -0
- package/dist/types/sidebar/i18n.d.ts +19 -0
- package/dist/types/sidebar/i18n.d.ts.map +1 -0
- package/dist/types/sidebar/index.d.ts +7 -0
- package/dist/types/sidebar/index.d.ts.map +1 -0
- package/dist/types/sidebar/sidebar-header.d.ts +6 -0
- package/dist/types/sidebar/sidebar-header.d.ts.map +1 -0
- package/dist/types/sidebar/sidebar-item.d.ts +3 -0
- package/dist/types/sidebar/sidebar-item.d.ts.map +1 -0
- package/dist/types/sidebar/sidebar-list.d.ts +3 -0
- package/dist/types/sidebar/sidebar-list.d.ts.map +1 -0
- package/dist/types/sidebar/sidebar-root.d.ts +17 -0
- package/dist/types/sidebar/sidebar-root.d.ts.map +1 -0
- package/dist/types/sidebar/sidebar.d.ts +8 -0
- package/dist/types/sidebar/sidebar.d.ts.map +1 -0
- package/dist/types/sidebar/types.d.ts +48 -0
- package/dist/types/sidebar/types.d.ts.map +1 -0
- package/dist/types/sidebar/utils.d.ts +4 -0
- package/dist/types/sidebar/utils.d.ts.map +1 -0
- package/dist/types/system/react-utils/children.d.ts +1 -2
- package/dist/types/system/react-utils/children.d.ts.map +1 -1
- package/dist/types/tooltip/index.d.ts +2 -0
- package/dist/types/tooltip/index.d.ts.map +1 -0
- package/dist/types/tooltip/tooltip.d.ts +16 -0
- package/dist/types/tooltip/tooltip.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -5,10 +5,10 @@ import { useContext, isValidElement } from 'react';
|
|
|
5
5
|
import { useLocalizedStringFormatter } from 'react-aria';
|
|
6
6
|
import { Dialog } from 'react-aria-components';
|
|
7
7
|
import { cn } from '@opengovsg/oui-theme';
|
|
8
|
-
import { Button } from '../button/button.js';
|
|
9
8
|
import { i18nStrings } from './i18n.js';
|
|
10
9
|
import { ModalVariantContext } from './modal-variant-context.js';
|
|
11
10
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
11
|
+
import { Button } from '../button/button.js';
|
|
12
12
|
|
|
13
13
|
function ModalContent({
|
|
14
14
|
closeButtonContent: closeButtonContentProp,
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { NumberField as NumberField$1 } from 'react-aria-components';
|
|
5
5
|
import { numberFieldStyles, composeTailwindRenderProps, dataAttr, fieldBorderStyles, cn } from '@opengovsg/oui-theme';
|
|
6
|
-
import { Button } from '../button/button.js';
|
|
7
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
8
6
|
import { Input } from '../input/input.js';
|
|
9
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
10
8
|
import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/minus.js';
|
|
11
9
|
import Plus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/plus.js';
|
|
10
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
11
|
+
import { Button } from '../button/button.js';
|
|
12
12
|
|
|
13
13
|
function NumberField(originalProps) {
|
|
14
14
|
const [
|
|
@@ -6,12 +6,12 @@ import { CalendarDate, today, getLocalTimeZone, getDayOfWeek } from '@internatio
|
|
|
6
6
|
import { RangeCalendar as RangeCalendar$1, Provider, CalendarGrid, CalendarGridBody, Text, RangeCalendarStateContext, useLocale, CalendarCell } from 'react-aria-components';
|
|
7
7
|
import { useDeepCompareMemo } from 'use-deep-compare';
|
|
8
8
|
import { calendarStyles, composeRenderProps, cn, dataAttr } from '@opengovsg/oui-theme';
|
|
9
|
-
import { CalendarStyleContext, useCalendarStyleContext } from '../calendar/calendar-style-context.js';
|
|
10
9
|
import { AgnosticCalendarStateContext } from '../calendar/agnostic-calendar-state-context.js';
|
|
11
10
|
import { CalendarBottomContent } from '../calendar/calendar-bottom-content.js';
|
|
12
11
|
import { CalendarGridHeader } from '../calendar/calendar-grid-header.js';
|
|
13
12
|
import { CalendarHeader } from '../calendar/calendar-header.js';
|
|
14
13
|
import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
|
|
14
|
+
import { CalendarStyleContext, useCalendarStyleContext } from '../calendar/calendar-style-context.js';
|
|
15
15
|
|
|
16
16
|
const RangeCalendar = forwardRefGeneric(function RangeCalendar2(originalProps, ref) {
|
|
17
17
|
const [props, variantProps] = mapPropsVariants(
|
|
@@ -3,13 +3,13 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useLocalizedStringFormatter } from 'react-aria';
|
|
4
4
|
import { SearchField as SearchField$1 } from 'react-aria-components';
|
|
5
5
|
import { searchFieldStyles, composeRenderProps } from '@opengovsg/oui-theme';
|
|
6
|
-
import { Button } from '../button/button.js';
|
|
7
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
8
6
|
import { Input } from '../input/input.js';
|
|
9
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
10
8
|
import { i18nStrings } from './i18n.js';
|
|
11
9
|
import Search from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/search.js';
|
|
12
10
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
11
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
12
|
+
import { Button } from '../button/button.js';
|
|
13
13
|
|
|
14
14
|
function SearchField(originalProps) {
|
|
15
15
|
const [
|
|
@@ -5,12 +5,12 @@ import { useMemo, isValidElement, cloneElement } from 'react';
|
|
|
5
5
|
import { useLocalizedStringFormatter } from 'react-aria';
|
|
6
6
|
import { useFilter, Virtualizer, ListLayout, ListBox, Provider, Select as Select$1, SelectValue, Autocomplete, SearchField, Input } from 'react-aria-components';
|
|
7
7
|
import { selectStyles, cn, composeRenderProps } from '@opengovsg/oui-theme';
|
|
8
|
-
import { Button } from '../button/button.js';
|
|
9
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
10
8
|
import { Popover } from '../popover/popover.js';
|
|
11
9
|
import { mapPropsVariants } from '../system/utils.js';
|
|
12
10
|
import { SelectVariantContext } from './select-variant-context.js';
|
|
11
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
13
12
|
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
13
|
+
import { Button } from '../button/button.js';
|
|
14
14
|
|
|
15
15
|
const i18nStrings = {
|
|
16
16
|
"en-SG": {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [SidebarStyleContext, useSidebarStyleContext] = createContext({
|
|
6
|
+
name: "SidebarStyleContext"
|
|
7
|
+
});
|
|
8
|
+
const [SidebarCollapseContext, useSidebarCollapseContext] = createContext({
|
|
9
|
+
name: "SidebarCollapseContext"
|
|
10
|
+
});
|
|
11
|
+
const [SidebarNestContext, useSidebarNestContext] = createContext({
|
|
12
|
+
name: "SidebarNestContext",
|
|
13
|
+
strict: false,
|
|
14
|
+
defaultValue: { isNested: false, isExpanded: false }
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { SidebarCollapseContext, SidebarNestContext, SidebarStyleContext, useSidebarCollapseContext, useSidebarNestContext, useSidebarStyleContext };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const i18nStrings = {
|
|
3
|
+
"en-SG": {
|
|
4
|
+
"Expand sidebar section": "Expand sidebar section",
|
|
5
|
+
"Collapse sidebar section": "Collapse sidebar section"
|
|
6
|
+
},
|
|
7
|
+
"zh-SG": {
|
|
8
|
+
"Expand sidebar section": "\u5C55\u5F00\u4FA7\u8FB9\u680F\u90E8\u5206",
|
|
9
|
+
"Collapse sidebar section": "\u6298\u53E0\u4FA7\u8FB9\u680F\u90E8\u5206"
|
|
10
|
+
},
|
|
11
|
+
"ms-SG": {
|
|
12
|
+
"Expand sidebar section": "Perluas bahagian bar sisi",
|
|
13
|
+
"Collapse sidebar section": "Kuncupkan bahagian bar sisi"
|
|
14
|
+
},
|
|
15
|
+
"ta-SG": {
|
|
16
|
+
"Expand sidebar section": "\u0BAA\u0B95\u0BCD\u0B95\u0BB5\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0BAA\u0BCD \u0BAA\u0B95\u0BC1\u0BA4\u0BBF\u0BAF\u0BC8 \u0BB5\u0BBF\u0BB0\u0BBF\u0BB5\u0BBE\u0B95\u0BCD\u0B95\u0BC1",
|
|
17
|
+
"Collapse sidebar section": "\u0BAA\u0B95\u0BCD\u0B95\u0BB5\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0BAA\u0BCD \u0BAA\u0B95\u0BC1\u0BA4\u0BBF\u0BAF\u0BC8 \u0B9A\u0BC1\u0BB0\u0BC1\u0B95\u0BCD\u0B95\u0BC1"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { i18nStrings };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export { Sidebar, generateSidebarItems } from './sidebar.js';
|
|
3
|
+
export { SidebarRoot } from './sidebar-root.js';
|
|
4
|
+
export { SidebarItem } from './sidebar-item.js';
|
|
5
|
+
export { SidebarList } from './sidebar-list.js';
|
|
6
|
+
export { SidebarHeader } from './sidebar-header.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { renderChildren } from '../system/react-utils/children.js';
|
|
5
|
+
import { forwardRef } from '../system/utils.js';
|
|
6
|
+
import { useSidebarStyleContext } from './context.js';
|
|
7
|
+
|
|
8
|
+
const SidebarHeader = forwardRef(
|
|
9
|
+
({ children, startContent, endContent, ...props }, ref) => {
|
|
10
|
+
const { slots, classNames } = useSidebarStyleContext();
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"li",
|
|
13
|
+
{
|
|
14
|
+
className: slots.headerLi({
|
|
15
|
+
className: classNames?.headerLi
|
|
16
|
+
}),
|
|
17
|
+
children: /* @__PURE__ */ jsxs(
|
|
18
|
+
"h2",
|
|
19
|
+
{
|
|
20
|
+
className: slots.header({
|
|
21
|
+
className: classNames?.header
|
|
22
|
+
}),
|
|
23
|
+
ref,
|
|
24
|
+
...props,
|
|
25
|
+
children: [
|
|
26
|
+
startContent,
|
|
27
|
+
renderChildren({}, children),
|
|
28
|
+
endContent
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
SidebarHeader.displayName = "SidebarHeader";
|
|
37
|
+
|
|
38
|
+
export { SidebarHeader };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { Link } from 'react-aria-components';
|
|
6
|
+
import { dataAttr } from '@opengovsg/oui-theme';
|
|
7
|
+
import { renderChildren } from '../system/react-utils/children.js';
|
|
8
|
+
import { forwardRef } from '../system/utils.js';
|
|
9
|
+
import { TooltipTrigger, Tooltip } from '../tooltip/tooltip.js';
|
|
10
|
+
import { useSidebarStyleContext, useSidebarNestContext, useSidebarCollapseContext } from './context.js';
|
|
11
|
+
|
|
12
|
+
const SidebarItem = forwardRef(
|
|
13
|
+
({ children, startContent, endContent, tooltip, isSelected, ...props }, ref) => {
|
|
14
|
+
const { slots, classNames } = useSidebarStyleContext();
|
|
15
|
+
const { isNested, isExpanded } = useSidebarNestContext() ?? {};
|
|
16
|
+
const { isCollapsed, tooltipProps, tooltipTriggerProps } = useSidebarCollapseContext() ?? {};
|
|
17
|
+
const dataSelected = useMemo(() => {
|
|
18
|
+
if (typeof isSelected === "function") {
|
|
19
|
+
return isSelected();
|
|
20
|
+
}
|
|
21
|
+
return isSelected;
|
|
22
|
+
}, [isSelected]);
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
"li",
|
|
25
|
+
{
|
|
26
|
+
"data-selected": dataAttr(dataSelected),
|
|
27
|
+
"data-nested": dataAttr(isNested),
|
|
28
|
+
className: slots.item({
|
|
29
|
+
isNested,
|
|
30
|
+
className: classNames?.item
|
|
31
|
+
}),
|
|
32
|
+
ref,
|
|
33
|
+
children: /* @__PURE__ */ jsxs(TooltipTrigger, { delay: 0, ...tooltipTriggerProps, children: [
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
Link,
|
|
36
|
+
{
|
|
37
|
+
"aria-label": isCollapsed ? tooltip : void 0,
|
|
38
|
+
...props,
|
|
39
|
+
className: slots.label({
|
|
40
|
+
isNested,
|
|
41
|
+
isExpanded,
|
|
42
|
+
className: classNames?.label
|
|
43
|
+
}),
|
|
44
|
+
children: (renderProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
+
startContent,
|
|
46
|
+
!isCollapsed && renderChildren(renderProps, children),
|
|
47
|
+
!isCollapsed && endContent
|
|
48
|
+
] })
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
isCollapsed && /* @__PURE__ */ jsx(Tooltip, { placement: "end", ...tooltipProps, children: tooltip })
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
SidebarItem.displayName = "SidebarItem";
|
|
58
|
+
|
|
59
|
+
export { SidebarItem };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { useLocalizedStringFormatter } from 'react-aria';
|
|
6
|
+
import { Disclosure, DisclosurePanel, Provider, Link, Button as Button$1 } from 'react-aria-components';
|
|
7
|
+
import { useDisclosureState } from 'react-stately';
|
|
8
|
+
import { dataAttr } from '@opengovsg/oui-theme';
|
|
9
|
+
import { forwardRef } from '../system/utils.js';
|
|
10
|
+
import { useSidebarStyleContext, useSidebarCollapseContext, SidebarNestContext, useSidebarNestContext } from './context.js';
|
|
11
|
+
import { i18nStrings } from './i18n.js';
|
|
12
|
+
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
13
|
+
import { Button } from '../button/button.js';
|
|
14
|
+
|
|
15
|
+
const SidebarListSection = ({
|
|
16
|
+
onlyCaretToggle,
|
|
17
|
+
isExpanded,
|
|
18
|
+
isSelected,
|
|
19
|
+
children,
|
|
20
|
+
linkProps
|
|
21
|
+
}) => {
|
|
22
|
+
const { slots, classNames } = useSidebarStyleContext();
|
|
23
|
+
const { isNested } = useSidebarNestContext() ?? {};
|
|
24
|
+
const stringFormatter = useLocalizedStringFormatter(i18nStrings);
|
|
25
|
+
if (onlyCaretToggle) {
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
"data-expanded": dataAttr(isExpanded),
|
|
30
|
+
"data-selected": dataAttr(isSelected),
|
|
31
|
+
className: slots.item({
|
|
32
|
+
className: classNames?.item,
|
|
33
|
+
isExpanded,
|
|
34
|
+
isNested
|
|
35
|
+
}),
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
Link,
|
|
39
|
+
{
|
|
40
|
+
className: slots.label({
|
|
41
|
+
className: classNames?.label,
|
|
42
|
+
isNested,
|
|
43
|
+
isExpanded
|
|
44
|
+
}),
|
|
45
|
+
...linkProps,
|
|
46
|
+
children
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
Button,
|
|
51
|
+
{
|
|
52
|
+
variant: "clear",
|
|
53
|
+
color: "none",
|
|
54
|
+
slot: "trigger",
|
|
55
|
+
"aria-label": stringFormatter.format(
|
|
56
|
+
isExpanded ? "Collapse sidebar section" : "Expand sidebar section"
|
|
57
|
+
),
|
|
58
|
+
className: slots.chevronContainer({
|
|
59
|
+
className: classNames?.chevronContainer
|
|
60
|
+
}),
|
|
61
|
+
children: ({ isDisabled }) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
62
|
+
ChevronDown,
|
|
63
|
+
{
|
|
64
|
+
"aria-hidden": true,
|
|
65
|
+
className: slots.chevron({ isExpanded, isDisabled })
|
|
66
|
+
}
|
|
67
|
+
) })
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
Button$1,
|
|
76
|
+
{
|
|
77
|
+
"data-expanded": dataAttr(isExpanded),
|
|
78
|
+
"data-selected": dataAttr(isSelected),
|
|
79
|
+
slot: "trigger",
|
|
80
|
+
className: slots.item({
|
|
81
|
+
className: classNames?.item,
|
|
82
|
+
isExpanded,
|
|
83
|
+
isNested
|
|
84
|
+
}),
|
|
85
|
+
children: ({ isDisabled }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"span",
|
|
88
|
+
{
|
|
89
|
+
className: slots.label({
|
|
90
|
+
className: classNames?.label,
|
|
91
|
+
isNested,
|
|
92
|
+
isExpanded
|
|
93
|
+
}),
|
|
94
|
+
children
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
"span",
|
|
99
|
+
{
|
|
100
|
+
className: slots.chevronContainer({
|
|
101
|
+
className: classNames?.chevronContainer
|
|
102
|
+
}),
|
|
103
|
+
children: /* @__PURE__ */ jsx(
|
|
104
|
+
ChevronDown,
|
|
105
|
+
{
|
|
106
|
+
"aria-hidden": true,
|
|
107
|
+
className: slots.chevron({ isExpanded, isDisabled })
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] })
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
const SidebarList = forwardRef(
|
|
117
|
+
({
|
|
118
|
+
label,
|
|
119
|
+
children,
|
|
120
|
+
startContent,
|
|
121
|
+
endContent,
|
|
122
|
+
isSelected,
|
|
123
|
+
defaultIsExpanded,
|
|
124
|
+
isExpanded: isExpandedProp,
|
|
125
|
+
onExpand: onExpandProp,
|
|
126
|
+
onlyCaretToggle = false,
|
|
127
|
+
...props
|
|
128
|
+
}, ref) => {
|
|
129
|
+
const { slots, classNames } = useSidebarStyleContext();
|
|
130
|
+
const { isCollapsed } = useSidebarCollapseContext() ?? {};
|
|
131
|
+
const { isExpanded, setExpanded } = useDisclosureState({
|
|
132
|
+
defaultExpanded: defaultIsExpanded,
|
|
133
|
+
isExpanded: isExpandedProp,
|
|
134
|
+
onExpandedChange: onExpandProp
|
|
135
|
+
});
|
|
136
|
+
const dataSelected = useMemo(() => {
|
|
137
|
+
if (typeof isSelected === "function") {
|
|
138
|
+
return isSelected();
|
|
139
|
+
}
|
|
140
|
+
return isSelected;
|
|
141
|
+
}, [isSelected]);
|
|
142
|
+
if (isCollapsed) {
|
|
143
|
+
return children;
|
|
144
|
+
}
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
"li",
|
|
147
|
+
{
|
|
148
|
+
"data-selected": dataAttr(dataSelected),
|
|
149
|
+
className: slots.list({
|
|
150
|
+
className: classNames?.list
|
|
151
|
+
}),
|
|
152
|
+
ref,
|
|
153
|
+
children: /* @__PURE__ */ jsxs(
|
|
154
|
+
Disclosure,
|
|
155
|
+
{
|
|
156
|
+
className: slots.section({
|
|
157
|
+
className: classNames?.section,
|
|
158
|
+
isExpanded
|
|
159
|
+
}),
|
|
160
|
+
isExpanded,
|
|
161
|
+
onExpandedChange: setExpanded,
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsxs(
|
|
164
|
+
SidebarListSection,
|
|
165
|
+
{
|
|
166
|
+
onlyCaretToggle,
|
|
167
|
+
isSelected,
|
|
168
|
+
isExpanded,
|
|
169
|
+
linkProps: props,
|
|
170
|
+
children: [
|
|
171
|
+
startContent,
|
|
172
|
+
label,
|
|
173
|
+
endContent
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
DisclosurePanel,
|
|
179
|
+
{
|
|
180
|
+
className: slots.nestedPanel({
|
|
181
|
+
className: classNames?.nestedPanel
|
|
182
|
+
}),
|
|
183
|
+
children: /* @__PURE__ */ jsx(
|
|
184
|
+
Provider,
|
|
185
|
+
{
|
|
186
|
+
values: [[SidebarNestContext, { isNested: true, isExpanded }]],
|
|
187
|
+
children: /* @__PURE__ */ jsx(
|
|
188
|
+
"ul",
|
|
189
|
+
{
|
|
190
|
+
className: slots.ul({
|
|
191
|
+
className: classNames?.ul,
|
|
192
|
+
isNested: true,
|
|
193
|
+
isExpanded
|
|
194
|
+
}),
|
|
195
|
+
children
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
SidebarList.displayName = "SidebarList";
|
|
210
|
+
|
|
211
|
+
export { SidebarList };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useControlledState } from '@react-stately/utils';
|
|
5
|
+
import { Provider } from 'react-aria-components';
|
|
6
|
+
import { sidebarStyles, dataAttr } from '@opengovsg/oui-theme';
|
|
7
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
8
|
+
import { SidebarStyleContext, SidebarCollapseContext } from './context.js';
|
|
9
|
+
|
|
10
|
+
const SidebarRoot = ({
|
|
11
|
+
className,
|
|
12
|
+
classNames,
|
|
13
|
+
defaultCollapsed,
|
|
14
|
+
onCollapsedChange,
|
|
15
|
+
tooltipProps,
|
|
16
|
+
tooltipTriggerProps,
|
|
17
|
+
...originalProps
|
|
18
|
+
}) => {
|
|
19
|
+
const [props, variantProps] = mapPropsVariants(
|
|
20
|
+
originalProps,
|
|
21
|
+
sidebarStyles.variantKeys
|
|
22
|
+
);
|
|
23
|
+
const [isCollapsed, setCollapsed] = useControlledState(
|
|
24
|
+
variantProps.isCollapsed,
|
|
25
|
+
defaultCollapsed ?? false,
|
|
26
|
+
onCollapsedChange
|
|
27
|
+
);
|
|
28
|
+
const slots = sidebarStyles({ ...variantProps, isCollapsed });
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
Provider,
|
|
31
|
+
{
|
|
32
|
+
values: [
|
|
33
|
+
[SidebarStyleContext, { slots, classNames }],
|
|
34
|
+
[
|
|
35
|
+
SidebarCollapseContext,
|
|
36
|
+
{ isCollapsed, setCollapsed, tooltipProps, tooltipTriggerProps }
|
|
37
|
+
]
|
|
38
|
+
],
|
|
39
|
+
children: /* @__PURE__ */ jsx(
|
|
40
|
+
"nav",
|
|
41
|
+
{
|
|
42
|
+
"data-collapsed": dataAttr(isCollapsed),
|
|
43
|
+
className: slots.base({
|
|
44
|
+
className: className ?? classNames?.base
|
|
45
|
+
}),
|
|
46
|
+
children: /* @__PURE__ */ jsx(
|
|
47
|
+
"ul",
|
|
48
|
+
{
|
|
49
|
+
className: slots.ul({
|
|
50
|
+
className: classNames?.ul
|
|
51
|
+
}),
|
|
52
|
+
...props
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { SidebarRoot };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { SidebarHeader } from './sidebar-header.js';
|
|
6
|
+
import { SidebarItem } from './sidebar-item.js';
|
|
7
|
+
import { SidebarList } from './sidebar-list.js';
|
|
8
|
+
import { SidebarRoot } from './sidebar-root.js';
|
|
9
|
+
import { isNestableItem, isHeaderItem } from './utils.js';
|
|
10
|
+
|
|
11
|
+
const generateSidebarItems = (items) => {
|
|
12
|
+
return items.map((item, index) => {
|
|
13
|
+
if (isNestableItem(item)) {
|
|
14
|
+
const { label, subItems, ...rest } = item;
|
|
15
|
+
return /* @__PURE__ */ jsx(SidebarList, { label, ...rest, children: generateSidebarItems(subItems) }, index);
|
|
16
|
+
}
|
|
17
|
+
if (isHeaderItem(item)) {
|
|
18
|
+
return /* @__PURE__ */ jsx(SidebarHeader, { ...item }, index);
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ jsx(SidebarItem, { ...item }, index);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const Sidebar = ({ items, ...props }) => {
|
|
24
|
+
const sidebarItems = useMemo(() => generateSidebarItems(items), [items]);
|
|
25
|
+
return /* @__PURE__ */ jsx(SidebarRoot, { ...props, children: sidebarItems });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { Sidebar, generateSidebarItems };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -4,7 +4,6 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { createElement } from 'react';
|
|
5
5
|
import { composeRenderProps } from 'react-aria-components';
|
|
6
6
|
import { tagFieldStyles } from '@opengovsg/oui-theme';
|
|
7
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
8
7
|
import { Input } from '../input/input.js';
|
|
9
8
|
import { Popover } from '../popover/popover.js';
|
|
10
9
|
import { TagFieldItem } from './tag-field-item.js';
|
|
@@ -13,6 +12,7 @@ import { TagFieldRoot } from './tag-field-root.js';
|
|
|
13
12
|
import { TagFieldTagList } from './tag-field-tag-list.js';
|
|
14
13
|
import { TagFieldTrigger } from './tag-field-trigger.js';
|
|
15
14
|
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
15
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
16
16
|
|
|
17
17
|
function TagField({
|
|
18
18
|
classNames,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { TextField } from 'react-aria-components';
|
|
5
5
|
import { composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
6
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
7
6
|
import { TextArea } from '../text-area/text-area.js';
|
|
7
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
8
8
|
|
|
9
9
|
function TextAreaField({
|
|
10
10
|
label,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { TextField as TextField$1 } from 'react-aria-components';
|
|
5
5
|
import { composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
6
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
7
6
|
import { Input } from '../input/input.js';
|
|
7
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
8
8
|
|
|
9
9
|
function TextField({
|
|
10
10
|
label,
|
|
@@ -3,9 +3,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { TimeField as TimeField$1 } from 'react-aria-components';
|
|
5
5
|
import { dateInputStyles, composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
6
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
7
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
8
6
|
import { mapPropsVariants } from '../system/utils.js';
|
|
7
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
8
|
+
import { DateInput } from '../date-field/date-field.js';
|
|
9
9
|
|
|
10
10
|
function TimeField(originalProps) {
|
|
11
11
|
const [
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { TooltipTrigger as TooltipTrigger$1, Tooltip as Tooltip$1, OverlayArrow } from 'react-aria-components';
|
|
5
|
+
import { tooltipStyles, composeRenderProps } from '@opengovsg/oui-theme';
|
|
6
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
7
|
+
|
|
8
|
+
function Tooltip(originalProps) {
|
|
9
|
+
const [{ children, showArrow = true, classNames, ...props }, variantProps] = mapPropsVariants(originalProps, tooltipStyles.variantKeys);
|
|
10
|
+
const styles = tooltipStyles(variantProps);
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
Tooltip$1,
|
|
13
|
+
{
|
|
14
|
+
isEntering: variantProps.isEntering,
|
|
15
|
+
isExiting: variantProps.isExiting,
|
|
16
|
+
offset: 10,
|
|
17
|
+
...props,
|
|
18
|
+
className: composeRenderProps(
|
|
19
|
+
props.className ?? classNames?.base,
|
|
20
|
+
(className, renderProps) => styles.base({
|
|
21
|
+
...renderProps,
|
|
22
|
+
className
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
children: (renderProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
+
showArrow && /* @__PURE__ */ jsx(OverlayArrow, { children: /* @__PURE__ */ jsx(
|
|
27
|
+
"svg",
|
|
28
|
+
{
|
|
29
|
+
width: 8,
|
|
30
|
+
height: 8,
|
|
31
|
+
viewBox: "0 0 8 8",
|
|
32
|
+
className: composeRenderProps(
|
|
33
|
+
classNames?.arrow,
|
|
34
|
+
(className, renderProps2) => styles.arrow({
|
|
35
|
+
className,
|
|
36
|
+
...renderProps2
|
|
37
|
+
})
|
|
38
|
+
)(renderProps),
|
|
39
|
+
children: /* @__PURE__ */ jsx("path", { d: "M0 0 L4 4 L8 0" })
|
|
40
|
+
}
|
|
41
|
+
) }),
|
|
42
|
+
children
|
|
43
|
+
] })
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function TooltipTrigger(props) {
|
|
48
|
+
return /* @__PURE__ */ jsx(TooltipTrigger$1, { delay: 300, ...props });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { Tooltip, TooltipTrigger };
|
package/dist/types/index.d.mts
CHANGED