@opengovsg/oui 0.0.30 → 0.0.32
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/avatar/avatar-context.cjs +12 -0
- package/dist/cjs/avatar/avatar-group-context.cjs +88 -0
- package/dist/cjs/avatar/avatar-group.cjs +60 -0
- package/dist/cjs/avatar/avatar.cjs +132 -0
- package/dist/cjs/avatar/hooks/use-img-loading-status.cjs +68 -0
- package/dist/cjs/avatar/index.cjs +23 -0
- package/dist/cjs/avatar/utils.cjs +9 -0
- package/dist/cjs/banner/banner.cjs +1 -1
- package/dist/cjs/button/button.cjs +1 -1
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +2 -2
- package/dist/cjs/checkbox/checkbox.cjs +3 -3
- package/dist/cjs/combo-box/combo-box.cjs +2 -2
- 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 +5 -5
- 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 +26 -12
- package/dist/cjs/menu/menu.cjs +1 -1
- package/dist/cjs/modal/modal-content.cjs +1 -1
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.cjs +22 -0
- package/dist/cjs/number-field/number-field.cjs +3 -3
- package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
- package/dist/cjs/select/select.cjs +89 -17
- package/dist/cjs/tag-field/tag-field.cjs +3 -3
- 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/toast/toast.cjs +1 -1
- package/dist/esm/avatar/avatar-context.js +9 -0
- package/dist/esm/avatar/avatar-group-context.js +84 -0
- package/dist/esm/avatar/avatar-group.js +58 -0
- package/dist/esm/avatar/avatar.js +128 -0
- package/dist/esm/avatar/hooks/use-img-loading-status.js +66 -0
- package/dist/esm/avatar/index.js +13 -0
- package/dist/esm/avatar/utils.js +7 -0
- package/dist/esm/banner/banner.js +1 -1
- package/dist/esm/button/button.js +1 -1
- package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
- package/dist/esm/checkbox/checkbox.js +3 -3
- 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 +4 -5
- package/dist/esm/date-range-picker/date-range-picker.js +5 -5
- 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 +8 -3
- package/dist/esm/menu/menu.js +1 -1
- package/dist/esm/modal/modal-content.js +1 -1
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.js +17 -0
- package/dist/esm/number-field/number-field.js +3 -3
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/select/select.js +92 -20
- 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/esm/toast/toast.js +1 -1
- package/dist/types/avatar/avatar-context.d.ts +12 -0
- package/dist/types/avatar/avatar-context.d.ts.map +1 -0
- package/dist/types/avatar/avatar-group-context.d.ts +70 -0
- package/dist/types/avatar/avatar-group-context.d.ts.map +1 -0
- package/dist/types/avatar/avatar-group.d.ts +5 -0
- package/dist/types/avatar/avatar-group.d.ts.map +1 -0
- package/dist/types/avatar/avatar.d.ts +18 -0
- package/dist/types/avatar/avatar.d.ts.map +1 -0
- package/dist/types/avatar/hooks/use-img-loading-status.d.ts +4 -0
- package/dist/types/avatar/hooks/use-img-loading-status.d.ts.map +1 -0
- package/dist/types/avatar/index.d.ts +15 -0
- package/dist/types/avatar/index.d.ts.map +1 -0
- package/dist/types/avatar/utils.d.ts +2 -0
- package/dist/types/avatar/utils.d.ts.map +1 -0
- package/dist/types/checkbox/checkbox-group-style-context.d.ts +1 -1
- package/dist/types/checkbox/checkbox-group-style-context.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/menu/menu.d.ts.map +1 -1
- package/dist/types/select/select.d.ts +14 -0
- package/dist/types/select/select.d.ts.map +1 -1
- package/dist/types/system/react-utils/context.d.ts +4 -4
- package/dist/types/system/react-utils/context.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { useRef, useState, useLayoutEffect, useSyncExternalStore } from 'react';
|
|
3
|
+
|
|
4
|
+
function useIsHydrated() {
|
|
5
|
+
return useSyncExternalStore(
|
|
6
|
+
subscribe,
|
|
7
|
+
() => true,
|
|
8
|
+
() => false
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function subscribe() {
|
|
12
|
+
return () => {
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function resolveLoadingStatus(image, src) {
|
|
16
|
+
if (!image) {
|
|
17
|
+
return "idle";
|
|
18
|
+
}
|
|
19
|
+
if (!src) {
|
|
20
|
+
return "error";
|
|
21
|
+
}
|
|
22
|
+
if (image.src !== src) {
|
|
23
|
+
image.src = src;
|
|
24
|
+
}
|
|
25
|
+
return image.complete && image.naturalWidth > 0 ? "loaded" : "loading";
|
|
26
|
+
}
|
|
27
|
+
function useImageLoadingStatus(src, { referrerPolicy, crossOrigin }) {
|
|
28
|
+
const isHydrated = useIsHydrated();
|
|
29
|
+
const imageRef = useRef(null);
|
|
30
|
+
const image = (() => {
|
|
31
|
+
if (!isHydrated) return null;
|
|
32
|
+
if (!imageRef.current) {
|
|
33
|
+
imageRef.current = new window.Image();
|
|
34
|
+
}
|
|
35
|
+
return imageRef.current;
|
|
36
|
+
})();
|
|
37
|
+
const [loadingStatus, setLoadingStatus] = useState(
|
|
38
|
+
() => resolveLoadingStatus(image, src)
|
|
39
|
+
);
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
setLoadingStatus(resolveLoadingStatus(image, src));
|
|
42
|
+
}, [image, src]);
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
const updateStatus = (status) => () => {
|
|
45
|
+
setLoadingStatus(status);
|
|
46
|
+
};
|
|
47
|
+
if (!image) return;
|
|
48
|
+
const handleLoad = updateStatus("loaded");
|
|
49
|
+
const handleError = updateStatus("error");
|
|
50
|
+
image.addEventListener("load", handleLoad);
|
|
51
|
+
image.addEventListener("error", handleError);
|
|
52
|
+
if (referrerPolicy) {
|
|
53
|
+
image.referrerPolicy = referrerPolicy;
|
|
54
|
+
}
|
|
55
|
+
if (typeof crossOrigin === "string") {
|
|
56
|
+
image.crossOrigin = crossOrigin;
|
|
57
|
+
}
|
|
58
|
+
return () => {
|
|
59
|
+
image.removeEventListener("load", handleLoad);
|
|
60
|
+
image.removeEventListener("error", handleError);
|
|
61
|
+
};
|
|
62
|
+
}, [image, crossOrigin, referrerPolicy]);
|
|
63
|
+
return loadingStatus;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { useImageLoadingStatus };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { AvatarRoot, AvatarFallback, AvatarImage } from './avatar.js';
|
|
3
|
+
export { AvatarContext, useAvatarContext } from './avatar-context.js';
|
|
4
|
+
export { AvatarGroup } from './avatar-group.js';
|
|
5
|
+
export { AvatarGroupProvider, useAvatarGroup } from './avatar-group-context.js';
|
|
6
|
+
|
|
7
|
+
const Avatar = Object.assign(AvatarRoot, {
|
|
8
|
+
Root: AvatarRoot,
|
|
9
|
+
Image: AvatarImage,
|
|
10
|
+
Fallback: AvatarFallback
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { Avatar, AvatarFallback, AvatarImage, AvatarRoot };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const getInitialsFromText = (text, limit = 2) => {
|
|
3
|
+
const initials = text?.trim().split(/[\s\-_.]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase()).join("") || "";
|
|
4
|
+
return initials.slice(0, limit);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { getInitialsFromText };
|
|
@@ -5,9 +5,9 @@ import { useMemo, useRef } from 'react';
|
|
|
5
5
|
import { useMessageFormatter, useDisclosure } from 'react-aria';
|
|
6
6
|
import { useDisclosureState } from 'react-stately';
|
|
7
7
|
import { bannerStyles } from '@opengovsg/oui-theme';
|
|
8
|
-
import { Button } from '../button/button.js';
|
|
9
8
|
import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
|
|
10
9
|
import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/info.js';
|
|
10
|
+
import { Button } from '../button/button.js';
|
|
11
11
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
12
12
|
|
|
13
13
|
const i18nStrings = {
|
|
@@ -5,9 +5,9 @@ import { forwardRef, useMemo } from 'react';
|
|
|
5
5
|
import { chain } from '@react-aria/utils';
|
|
6
6
|
import { Button as Button$1, composeRenderProps } from 'react-aria-components';
|
|
7
7
|
import { buttonStyles } from '@opengovsg/oui-theme';
|
|
8
|
-
import { Ripple } from '../ripple/ripple.js';
|
|
9
8
|
import { useRipple } from '../ripple/use-ripple.js';
|
|
10
9
|
import { Spinner } from '../spinner/spinner.js';
|
|
10
|
+
import { Ripple } from '../ripple/ripple.js';
|
|
11
11
|
|
|
12
12
|
const Button = forwardRef(
|
|
13
13
|
({
|
|
@@ -4,11 +4,11 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { CalendarDate } from '@internationalized/date';
|
|
6
6
|
import { Group } from 'react-aria-components';
|
|
7
|
-
import { Select } from '../select/select.js';
|
|
8
|
-
import { SelectItem } from '../select/select-item.js';
|
|
9
7
|
import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
10
8
|
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
11
9
|
import { useCalendarSelectors } from './hooks/use-calendar-selectors.js';
|
|
10
|
+
import { Select } from '../select/select.js';
|
|
11
|
+
import { SelectItem } from '../select/select-item.js';
|
|
12
12
|
import { useCalendarI18n } from './hooks/use-calendar-i18n.js';
|
|
13
13
|
|
|
14
14
|
const CalendarMonthDaySelector = () => {
|
|
@@ -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';
|
|
7
6
|
import { mapPropsVariants } from '../system/utils.js';
|
|
8
7
|
import { useCheckboxGroupStyleContext, CheckboxGroupStyleContext } from './checkbox-group-style-context.js';
|
|
9
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';
|
|
10
9
|
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/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,
|
|
@@ -18,8 +18,8 @@ const Checkbox = ({
|
|
|
18
18
|
originalProps,
|
|
19
19
|
checkboxStyles.variantKeys
|
|
20
20
|
);
|
|
21
|
-
const
|
|
22
|
-
const styles = checkboxStyles({ size, ...variants });
|
|
21
|
+
const context = useCheckboxGroupStyleContext();
|
|
22
|
+
const styles = checkboxStyles({ size: context?.size, ...variants });
|
|
23
23
|
return /* @__PURE__ */ jsx(
|
|
24
24
|
Checkbox$1,
|
|
25
25
|
{
|
|
@@ -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';
|
|
10
8
|
import { mapPropsVariants } from '../system/utils.js';
|
|
11
9
|
import { ComboBoxVariantContext } from './combo-box-variant-context.js';
|
|
10
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
12
11
|
import ChevronUp from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-up.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';
|
|
14
13
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/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 { Label, Description, FieldError } from '../field/field.js';
|
|
8
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
8
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
9
9
|
|
|
10
10
|
function DateField(originalProps) {
|
|
11
11
|
const [
|
|
@@ -4,14 +4,13 @@ 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 {
|
|
8
|
-
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
9
|
-
import '@internationalized/date';
|
|
7
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
10
8
|
import { DateInput } from '../date-field/date-field.js';
|
|
9
|
+
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
10
|
+
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
11
11
|
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
12
|
+
import { Button } from '../button/button.js';
|
|
12
13
|
import { Popover } from '../popover/popover.js';
|
|
13
|
-
import { mapPropsVariants } from '../system/utils.js';
|
|
14
|
-
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
15
14
|
|
|
16
15
|
function DatePicker(originalProps) {
|
|
17
16
|
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 { Button } from '../button/button.js';
|
|
9
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
10
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
11
|
-
import { Popover } from '../popover/popover.js';
|
|
12
|
-
import { RangeCalendar } from '../range-calendar/range-calendar.js';
|
|
13
8
|
import { mapPropsVariants } from '../system/utils.js';
|
|
14
9
|
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/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
|
+
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';
|
|
12
10
|
import { mapPropsVariants } from '../system/utils.js';
|
|
13
11
|
import { FileDropzoneStyleContext, FileDropzoneStateContext, useFileDropzoneStateContext, useFileDropzoneStyleContext } from './contexts.js';
|
|
14
12
|
import { FileInfo } from './file-info.js';
|
|
15
13
|
import { formatErrorMessage, formatBytes } from './utils.js';
|
|
14
|
+
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
16
15
|
import Upload from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/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(
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
5
|
import { fileInfoDropzoneStyles, cn } from '@opengovsg/oui-theme';
|
|
6
|
-
import { Button } from '../button/button.js';
|
|
7
6
|
import { useFileDropzoneStateContext, useFileDropzoneStyleContext } from './contexts.js';
|
|
8
7
|
import { formatBytes } from './utils.js';
|
|
9
8
|
import Trash2 from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/trash-2.js';
|
|
9
|
+
import { Button } from '../button/button.js';
|
|
10
10
|
|
|
11
11
|
const FileInfo = ({ file, imagePreview, classNames }) => {
|
|
12
12
|
const {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
export { Avatar } from './avatar/index.js';
|
|
2
3
|
export { useControllableState } from './hooks/use-controllable-state.js';
|
|
3
4
|
export { useDraggable } from './hooks/use-draggable.js';
|
|
4
5
|
export { Button } from './button/button.js';
|
|
@@ -25,10 +26,10 @@ export { Select } from './select/select.js';
|
|
|
25
26
|
export { SelectItem } from './select/select-item.js';
|
|
26
27
|
export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
|
|
27
28
|
export { Badge } from './badge/badge.js';
|
|
29
|
+
export { CalendarDate } from '@internationalized/date';
|
|
28
30
|
export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
|
|
29
31
|
export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
|
|
30
32
|
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
|
|
31
|
-
export { CalendarDate } from '@internationalized/date';
|
|
32
33
|
export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
|
|
33
34
|
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
34
35
|
export { Popover } from './popover/popover.js';
|
|
@@ -38,10 +39,10 @@ export { DatePicker } from './date-picker/date-picker.js';
|
|
|
38
39
|
export { DateRangePicker } from './date-range-picker/date-range-picker.js';
|
|
39
40
|
export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
|
|
40
41
|
export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
|
|
42
|
+
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
41
43
|
export { Pagination } from './pagination/pagination.js';
|
|
42
44
|
export { PaginationCursor } from './pagination/pagination-cursor.js';
|
|
43
45
|
export { PaginationItem } from './pagination/pagination-item.js';
|
|
44
|
-
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
45
46
|
export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './pagination/use-pagination.js';
|
|
46
47
|
export { FileDropzone } from './file-dropzone/file-dropzone.js';
|
|
47
48
|
export { FileInfo } from './file-dropzone/file-info.js';
|
|
@@ -54,6 +55,7 @@ export { ModalBody } from './modal/modal-body.js';
|
|
|
54
55
|
export { ModalHeader } from './modal/modal-header.js';
|
|
55
56
|
export { ModalVariantContext, useModalVariantContext } from './modal/modal-variant-context.js';
|
|
56
57
|
export { Toaster } from './toast/toast.js';
|
|
58
|
+
export { toast } from 'sonner';
|
|
57
59
|
export { Navbar } from './navbar/navbar.js';
|
|
58
60
|
export { NavbarBrand } from './navbar/navbar-brand.js';
|
|
59
61
|
export { NavbarContent } from './navbar/navbar-content.js';
|
|
@@ -63,4 +65,7 @@ export { NavbarMenuToggle } from './navbar/navbar-menu/toggle.js';
|
|
|
63
65
|
export { NavbarItem } from './navbar/navbar-item.js';
|
|
64
66
|
export { useNavbar } from './navbar/use-navbar.js';
|
|
65
67
|
export { NavbarProvider, useNavbarContext } from './navbar/navbar-context.js';
|
|
66
|
-
export {
|
|
68
|
+
export { AvatarContext, useAvatarContext } from './avatar/avatar-context.js';
|
|
69
|
+
export { AvatarGroup } from './avatar/avatar-group.js';
|
|
70
|
+
export { AvatarGroupProvider, useAvatarGroup } from './avatar/avatar-group-context.js';
|
|
71
|
+
export { AvatarFallback, AvatarImage, AvatarRoot } from './avatar/avatar.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';
|
|
8
7
|
import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
|
|
9
8
|
import { createContext } from '../system/react-utils/context.js';
|
|
10
9
|
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/check.js';
|
|
11
10
|
import ChevronRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/chevron-right.js';
|
|
11
|
+
import { Popover } from '../popover/popover.js';
|
|
12
12
|
|
|
13
13
|
const [MenuVariantContext, useMenuVariantContext] = createContext({
|
|
14
14
|
name: "MenuVariantContext",
|
|
@@ -5,10 +5,10 @@ import { useContext, isValidElement } from 'react';
|
|
|
5
5
|
import { useMessageFormatter } 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,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import createLucideIcon from '../createLucideIcon.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @license lucide-react v0.475.0 - ISC
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the ISC license.
|
|
7
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const __iconNode = [
|
|
12
|
+
["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
|
|
13
|
+
["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
|
|
14
|
+
];
|
|
15
|
+
const User = createLucideIcon("User", __iconNode);
|
|
16
|
+
|
|
17
|
+
export { __iconNode, User as default };
|
|
@@ -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
|
-
import { Input } from '../input/input.js';
|
|
9
6
|
import { mapPropsVariants } from '../system/utils.js';
|
|
10
7
|
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
8
|
import Plus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/plus.js';
|
|
9
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
10
|
+
import { Input } from '../input/input.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(
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
9
|
-
import { Popover } from '../popover/popover.js';
|
|
4
|
+
import { useMemo, isValidElement, cloneElement } from 'react';
|
|
5
|
+
import { useLocalizedStringFormatter } from 'react-aria';
|
|
6
|
+
import { useFilter, Virtualizer, ListLayout, ListBox, Provider, Select as Select$1, SelectValue, Autocomplete, SearchField, Input } from 'react-aria-components';
|
|
7
|
+
import { selectStyles, cn, composeRenderProps } from '@opengovsg/oui-theme';
|
|
10
8
|
import { mapPropsVariants } from '../system/utils.js';
|
|
11
9
|
import { SelectVariantContext } from './select-variant-context.js';
|
|
10
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
12
11
|
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';
|
|
12
|
+
import { Popover } from '../popover/popover.js';
|
|
13
|
+
import { Button } from '../button/button.js';
|
|
13
14
|
|
|
15
|
+
const i18nStrings = {
|
|
16
|
+
"en-SG": {
|
|
17
|
+
searchPlaceholder: "Search...",
|
|
18
|
+
searchAriaLabel: "Search options"
|
|
19
|
+
},
|
|
20
|
+
"zh-SG": {
|
|
21
|
+
searchPlaceholder: "\u641C\u7D22...",
|
|
22
|
+
searchAriaLabel: "\u641C\u7D22\u9009\u9879"
|
|
23
|
+
},
|
|
24
|
+
"ms-SG": {
|
|
25
|
+
searchPlaceholder: "Cari...",
|
|
26
|
+
searchAriaLabel: "Cari pilihan"
|
|
27
|
+
},
|
|
28
|
+
"ta-SG": {
|
|
29
|
+
searchPlaceholder: "\u0BA4\u0BC7\u0B9F\u0BC1...",
|
|
30
|
+
searchAriaLabel: "\u0BA4\u0BC7\u0B9F\u0BB2\u0BCD \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0B99\u0BCD\u0B95\u0BB3\u0BCD"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
14
33
|
const calculateEstimatedRowHeight = (size) => {
|
|
15
34
|
switch (size) {
|
|
16
35
|
case "xs":
|
|
@@ -28,12 +47,22 @@ function Select({
|
|
|
28
47
|
errorMessage,
|
|
29
48
|
...originalProps
|
|
30
49
|
}) {
|
|
50
|
+
const formatter = useLocalizedStringFormatter(i18nStrings);
|
|
31
51
|
const [_props, variantProps] = mapPropsVariants(
|
|
32
52
|
originalProps,
|
|
33
53
|
selectStyles.variantKeys
|
|
34
54
|
);
|
|
35
|
-
const {
|
|
55
|
+
const {
|
|
56
|
+
items,
|
|
57
|
+
children,
|
|
58
|
+
listLayoutOptions,
|
|
59
|
+
enableSearch = false,
|
|
60
|
+
searchPlaceholder,
|
|
61
|
+
searchIcon,
|
|
62
|
+
...props
|
|
63
|
+
} = _props;
|
|
36
64
|
const styles = selectStyles(variantProps);
|
|
65
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
37
66
|
const layoutOptions = useMemo(() => {
|
|
38
67
|
return {
|
|
39
68
|
estimatedRowHeight: calculateEstimatedRowHeight(
|
|
@@ -42,6 +71,37 @@ function Select({
|
|
|
42
71
|
...listLayoutOptions
|
|
43
72
|
};
|
|
44
73
|
}, [listLayoutOptions, variantProps.size]);
|
|
74
|
+
const renderedSearchIcon = useMemo(() => {
|
|
75
|
+
if (!enableSearch || !searchIcon) return null;
|
|
76
|
+
if (isValidElement(searchIcon)) {
|
|
77
|
+
const iconElement = searchIcon;
|
|
78
|
+
return cloneElement(iconElement, {
|
|
79
|
+
className: styles.searchIcon({
|
|
80
|
+
className: cn(classNames?.searchIcon, iconElement.props.className)
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
"span",
|
|
86
|
+
{
|
|
87
|
+
className: styles.searchIcon({ className: classNames?.searchIcon }),
|
|
88
|
+
children: searchIcon
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}, [classNames?.searchIcon, enableSearch, searchIcon, styles]);
|
|
92
|
+
const listContent = /* @__PURE__ */ jsx(Virtualizer, { layout: ListLayout, layoutOptions, children: /* @__PURE__ */ jsx(
|
|
93
|
+
ListBox,
|
|
94
|
+
{
|
|
95
|
+
autoFocus: !enableSearch,
|
|
96
|
+
items,
|
|
97
|
+
shouldFocusWrap: true,
|
|
98
|
+
className: composeRenderProps(
|
|
99
|
+
classNames?.list,
|
|
100
|
+
(className, renderProps) => styles.list({ className, ...renderProps })
|
|
101
|
+
),
|
|
102
|
+
children
|
|
103
|
+
}
|
|
104
|
+
) });
|
|
45
105
|
return /* @__PURE__ */ jsx(Provider, { values: [[SelectVariantContext, variantProps]], children: /* @__PURE__ */ jsxs(
|
|
46
106
|
Select$1,
|
|
47
107
|
{
|
|
@@ -91,19 +151,31 @@ function Select({
|
|
|
91
151
|
}
|
|
92
152
|
),
|
|
93
153
|
/* @__PURE__ */ jsx(FieldError, { size: variantProps.size, className: classNames?.error, children: errorMessage }),
|
|
94
|
-
/* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: /* @__PURE__ */
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
154
|
+
/* @__PURE__ */ jsx(Popover, { className: styles.popover({ className: classNames?.popover }), children: enableSearch ? /* @__PURE__ */ jsxs(Autocomplete, { filter: contains, children: [
|
|
155
|
+
/* @__PURE__ */ jsxs(
|
|
156
|
+
SearchField,
|
|
157
|
+
{
|
|
158
|
+
autoFocus: true,
|
|
159
|
+
"aria-label": formatter.format("searchAriaLabel"),
|
|
160
|
+
className: styles.searchField({
|
|
161
|
+
className: classNames?.searchField
|
|
162
|
+
}),
|
|
163
|
+
children: [
|
|
164
|
+
renderedSearchIcon,
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
Input,
|
|
167
|
+
{
|
|
168
|
+
placeholder: searchPlaceholder ?? formatter.format("searchPlaceholder"),
|
|
169
|
+
className: styles.searchInput({
|
|
170
|
+
className: classNames?.searchInput
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
listContent
|
|
178
|
+
] }) : listContent })
|
|
107
179
|
]
|
|
108
180
|
}
|
|
109
181
|
) });
|
|
@@ -4,15 +4,15 @@ 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
|
-
import { Input } from '../input/input.js';
|
|
9
|
-
import { Popover } from '../popover/popover.js';
|
|
10
7
|
import { TagFieldItem } from './tag-field-item.js';
|
|
11
8
|
import { TagFieldList } from './tag-field-list.js';
|
|
12
9
|
import { TagFieldRoot } from './tag-field-root.js';
|
|
13
10
|
import { TagFieldTagList } from './tag-field-tag-list.js';
|
|
14
11
|
import { TagFieldTrigger } from './tag-field-trigger.js';
|
|
15
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 { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
14
|
+
import { Input } from '../input/input.js';
|
|
15
|
+
import { Popover } from '../popover/popover.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,
|
package/dist/esm/toast/toast.js
CHANGED
|
@@ -4,9 +4,9 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { Toaster as Toaster$1 } from 'sonner';
|
|
5
5
|
export { toast } from 'sonner';
|
|
6
6
|
import { toastStyles } from '@opengovsg/oui-theme';
|
|
7
|
-
import { Spinner } from '../spinner/spinner.js';
|
|
8
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
9
8
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
9
|
+
import { Spinner } from '../spinner/spinner.js';
|
|
10
10
|
|
|
11
11
|
function Toaster(originalProps) {
|
|
12
12
|
const [{ toastOptions, closeButton = true, ...props }, variantProps] = mapPropsVariants(originalProps, toastStyles.variantKeys);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AvatarSlots, avatarStyles, SlotsToClasses } from "@opengovsg/oui-theme";
|
|
2
|
+
import type { ImageLoadingStatus } from "./hooks/use-img-loading-status";
|
|
3
|
+
export interface UseAvatarContextReturn {
|
|
4
|
+
imageLoadingStatus: ImageLoadingStatus;
|
|
5
|
+
setImageLoadingStatus: React.Dispatch<React.SetStateAction<ImageLoadingStatus>>;
|
|
6
|
+
slots: ReturnType<typeof avatarStyles>;
|
|
7
|
+
classNames?: SlotsToClasses<AvatarSlots>;
|
|
8
|
+
name?: string;
|
|
9
|
+
getInitials: (name: string) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare const AvatarContext: import("react").Context<UseAvatarContextReturn>, useAvatarContext: () => UseAvatarContextReturn;
|
|
12
|
+
//# sourceMappingURL=avatar-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-context.d.ts","sourceRoot":"","sources":["../../../src/avatar/avatar-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACf,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGxE,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,EAAE,kBAAkB,CAAA;IACtC,qBAAqB,EAAE,KAAK,CAAC,QAAQ,CACnC,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,CACzC,CAAA;IACD,KAAK,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA;IACtC,UAAU,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAA;IACxC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACtC;AACD,eAAO,MAAO,aAAa,mDAAE,gBAAgB,8BAIzC,CAAA"}
|