@opengovsg/oui 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/cjs/date-picker/date-picker.cjs +3 -2
  2. package/dist/cjs/date-range-picker/date-range-picker.cjs +1 -1
  3. package/dist/cjs/hooks/index.cjs +2 -0
  4. package/dist/cjs/hooks/use-draggable.cjs +88 -0
  5. package/dist/cjs/index.cjs +54 -39
  6. package/dist/cjs/modal/i18n.cjs +19 -0
  7. package/dist/cjs/modal/index.cjs +19 -0
  8. package/dist/cjs/modal/modal-body.cjs +26 -0
  9. package/dist/cjs/modal/modal-content.cjs +54 -0
  10. package/dist/cjs/modal/modal-footer.cjs +27 -0
  11. package/dist/cjs/modal/modal-header.cjs +25 -0
  12. package/dist/cjs/modal/modal-variant-context.cjs +13 -0
  13. package/dist/cjs/modal/modal.cjs +66 -0
  14. package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
  15. package/dist/esm/date-picker/date-picker.js +3 -2
  16. package/dist/esm/date-range-picker/date-range-picker.js +1 -1
  17. package/dist/esm/hooks/index.js +1 -0
  18. package/dist/esm/hooks/use-draggable.js +86 -0
  19. package/dist/esm/index.js +20 -13
  20. package/dist/esm/modal/i18n.js +17 -0
  21. package/dist/esm/modal/index.js +7 -0
  22. package/dist/esm/modal/modal-body.js +24 -0
  23. package/dist/esm/modal/modal-content.js +52 -0
  24. package/dist/esm/modal/modal-footer.js +25 -0
  25. package/dist/esm/modal/modal-header.js +23 -0
  26. package/dist/esm/modal/modal-variant-context.js +10 -0
  27. package/dist/esm/modal/modal.js +64 -0
  28. package/dist/esm/range-calendar/range-calendar.js +1 -1
  29. package/dist/types/badge/use-badge.d.ts +12 -12
  30. package/dist/types/hooks/index.d.ts +4 -1
  31. package/dist/types/hooks/index.d.ts.map +1 -1
  32. package/dist/types/hooks/use-draggable.d.ts +24 -0
  33. package/dist/types/hooks/use-draggable.d.ts.map +1 -0
  34. package/dist/types/index.d.mts +1 -0
  35. package/dist/types/index.d.ts +1 -0
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/dist/types/modal/i18n.d.ts +3 -0
  38. package/dist/types/modal/i18n.d.ts.map +1 -0
  39. package/dist/types/modal/index.d.ts +12 -0
  40. package/dist/types/modal/index.d.ts.map +1 -0
  41. package/dist/types/modal/modal-body.d.ts +5 -0
  42. package/dist/types/modal/modal-body.d.ts.map +1 -0
  43. package/dist/types/modal/modal-content.d.ts +10 -0
  44. package/dist/types/modal/modal-content.d.ts.map +1 -0
  45. package/dist/types/modal/modal-footer.d.ts +5 -0
  46. package/dist/types/modal/modal-footer.d.ts.map +1 -0
  47. package/dist/types/modal/modal-header.d.ts +5 -0
  48. package/dist/types/modal/modal-header.d.ts.map +1 -0
  49. package/dist/types/modal/modal-variant-context.d.ts +8 -0
  50. package/dist/types/modal/modal-variant-context.d.ts.map +1 -0
  51. package/dist/types/modal/modal.d.ts +8 -0
  52. package/dist/types/modal/modal.d.ts.map +1 -0
  53. package/dist/types/pagination/use-pagination.d.ts +36 -36
  54. package/package.json +5 -5
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ "use client";
3
+ import { useRef, useCallback, useEffect } from 'react';
4
+ import { useMove } from '@react-aria/interactions';
5
+
6
+ function useDraggable(props) {
7
+ const { targetRef, isDisabled = false, canOverflow = false } = props;
8
+ const boundary = useRef({ minLeft: 0, minTop: 0, maxLeft: 0, maxTop: 0 });
9
+ const isDragging = useRef(false);
10
+ let transform = { offsetX: 0, offsetY: 0 };
11
+ const onMoveStart = useCallback(() => {
12
+ isDragging.current = true;
13
+ const { offsetX, offsetY } = transform;
14
+ const targetRect = targetRef?.current?.getBoundingClientRect();
15
+ const targetLeft = targetRect?.left ?? 0;
16
+ const targetTop = targetRect?.top ?? 0;
17
+ const targetWidth = targetRect?.width ?? 0;
18
+ const targetHeight = targetRect?.height ?? 0;
19
+ const clientWidth = document.documentElement.clientWidth;
20
+ const clientHeight = document.documentElement.clientHeight;
21
+ const minLeft = -targetLeft + offsetX;
22
+ const minTop = -targetTop + offsetY;
23
+ const maxLeft = clientWidth - targetLeft - targetWidth + offsetX;
24
+ const maxTop = clientHeight - targetTop - targetHeight + offsetY;
25
+ boundary.current = {
26
+ minLeft,
27
+ minTop,
28
+ maxLeft,
29
+ maxTop
30
+ };
31
+ }, [transform, targetRef?.current]);
32
+ const onMove = useCallback(
33
+ (e) => {
34
+ if (isDisabled) {
35
+ return;
36
+ }
37
+ const { offsetX, offsetY } = transform;
38
+ const { minLeft, minTop, maxLeft, maxTop } = boundary.current;
39
+ let moveX = offsetX + e.deltaX;
40
+ let moveY = offsetY + e.deltaY;
41
+ if (!canOverflow) {
42
+ moveX = Math.min(Math.max(moveX, minLeft), maxLeft);
43
+ moveY = Math.min(Math.max(moveY, minTop), maxTop);
44
+ }
45
+ transform = {
46
+ offsetX: moveX,
47
+ offsetY: moveY
48
+ };
49
+ if (targetRef?.current) {
50
+ targetRef.current.style.transform = `translate(${moveX}px, ${moveY}px)`;
51
+ }
52
+ },
53
+ [isDisabled, transform, boundary.current, canOverflow, targetRef?.current]
54
+ );
55
+ const onMoveEnd = useCallback(() => {
56
+ isDragging.current = false;
57
+ }, []);
58
+ const { moveProps } = useMove({
59
+ onMoveStart,
60
+ onMove,
61
+ onMoveEnd
62
+ });
63
+ const preventDefault = useCallback((e) => {
64
+ if (isDragging.current) {
65
+ e.preventDefault();
66
+ }
67
+ }, []);
68
+ useEffect(() => {
69
+ if (!isDisabled) {
70
+ document.body.addEventListener("touchmove", preventDefault, {
71
+ passive: false
72
+ });
73
+ }
74
+ return () => {
75
+ document.body.removeEventListener("touchmove", preventDefault);
76
+ };
77
+ }, [isDisabled, preventDefault]);
78
+ return {
79
+ moveProps: {
80
+ ...moveProps,
81
+ style: { cursor: !isDisabled ? "move" : void 0 }
82
+ }
83
+ };
84
+ }
85
+
86
+ export { useDraggable };
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  export { useControllableState } from './hooks/use-controllable-state.js';
3
+ export { useDraggable } from './hooks/use-draggable.js';
3
4
  export { GovtBanner } from './govt-banner/govt-banner.js';
4
5
  export { Ripple } from './ripple/ripple.js';
5
6
  export { useRipple } from './ripple/use-ripple.js';
@@ -12,15 +13,28 @@ export { TextField } from './text-field/text-field.js';
12
13
  export { Description, FieldError, FieldErrorIcon, FieldGroup, Label } from './field/field.js';
13
14
  export { TextArea } from './text-area/text-area.js';
14
15
  export { TextAreaField } from './text-area-field/text-area-field.js';
16
+ export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
17
+ export { ComboBoxFuzzy } from './combo-box/combo-box-fuzzy.js';
18
+ export { ComboBoxItem } from './combo-box/combo-box-item.js';
19
+ export { ComboBoxVariantContext, useComboBoxVariantContext } from './combo-box/combo-box-variant-context.js';
15
20
  export { TagField } from './tag-field/tag-field.js';
16
21
  export { TagFieldItem } from './tag-field/tag-field-item.js';
17
22
  export { Select } from './select/select.js';
18
23
  export { SelectItem } from './select/select-item.js';
19
24
  export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
25
+ export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
26
+ export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
27
+ export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
28
+ export { CalendarDate } from '@internationalized/date';
20
29
  export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
21
30
  export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
22
31
  export { Popover } from './popover/popover.js';
23
32
  export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs/tabs.js';
33
+ export { DateField, DateInput } from './date-field/date-field.js';
34
+ export { DatePicker } from './date-picker/date-picker.js';
35
+ export { DateRangePicker } from './date-range-picker/date-range-picker.js';
36
+ export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
37
+ export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
24
38
  export { Pagination } from './pagination/pagination.js';
25
39
  export { PaginationCursor } from './pagination/pagination-cursor.js';
26
40
  export { PaginationItem } from './pagination/pagination-item.js';
@@ -30,19 +44,12 @@ export { FileDropzone } from './file-dropzone/file-dropzone.js';
30
44
  export { FileInfo } from './file-dropzone/file-info.js';
31
45
  export { formatBytes, formatErrorMessage } from './file-dropzone/utils.js';
32
46
  export { NumberField } from './number-field/number-field.js';
47
+ export { Modal } from './modal/modal.js';
48
+ export { ModalContent } from './modal/modal-content.js';
49
+ export { ModalFooter } from './modal/modal-footer.js';
50
+ export { ModalBody } from './modal/modal-body.js';
51
+ export { ModalHeader } from './modal/modal-header.js';
52
+ export { ModalVariantContext, useModalVariantContext } from './modal/modal-variant-context.js';
33
53
  export { Button } from './button/button.js';
34
- export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
35
- export { ComboBoxFuzzy } from './combo-box/combo-box-fuzzy.js';
36
- export { ComboBoxItem } from './combo-box/combo-box-item.js';
37
- export { ComboBoxVariantContext, useComboBoxVariantContext } from './combo-box/combo-box-variant-context.js';
38
54
  export { Banner } from './banner/banner.js';
39
55
  export { Badge } from './badge/badge.js';
40
- export { CalendarDate } from '@internationalized/date';
41
- export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
42
- export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
43
- export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
44
- export { DateField, DateInput } from './date-field/date-field.js';
45
- export { DatePicker } from './date-picker/date-picker.js';
46
- export { DateRangePicker } from './date-range-picker/date-range-picker.js';
47
- export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
48
- export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ const i18nStrings = {
3
+ "en-SG": {
4
+ dismiss: "Dismiss"
5
+ },
6
+ "zh-SG": {
7
+ dismiss: "\u53D6\u6D88"
8
+ },
9
+ "ms-SG": {
10
+ dismiss: "Tutup"
11
+ },
12
+ "ta-SG": {
13
+ dismiss: "\u0BAE\u0BC2\u0B9F\u0BC1"
14
+ }
15
+ };
16
+
17
+ export { i18nStrings };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ export { Modal } from './modal.js';
3
+ export { ModalContent } from './modal-content.js';
4
+ export { ModalFooter } from './modal-footer.js';
5
+ export { ModalBody } from './modal-body.js';
6
+ export { ModalHeader } from './modal-header.js';
7
+ export { ModalVariantContext, useModalVariantContext } from './modal-variant-context.js';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { cn } from '@opengovsg/oui-theme';
6
+ import { forwardRef } from '../system/utils.js';
7
+ import { ModalVariantContext } from './modal-variant-context.js';
8
+
9
+ const ModalBody = forwardRef(function ModalBody2({ as, ...props }, ref) {
10
+ const { slots, classNames } = useContext(ModalVariantContext);
11
+ const Component = as || "div";
12
+ return /* @__PURE__ */ jsx(
13
+ Component,
14
+ {
15
+ ref,
16
+ className: slots.body({
17
+ className: cn(classNames?.body, props.className)
18
+ }),
19
+ ...props
20
+ }
21
+ );
22
+ });
23
+
24
+ export { ModalBody };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { useContext, isValidElement } from 'react';
5
+ import { useMessageFormatter } from 'react-aria';
6
+ import { Dialog } from 'react-aria-components';
7
+ import { cn } from '@opengovsg/oui-theme';
8
+ import { i18nStrings } from './i18n.js';
9
+ import { ModalVariantContext } from './modal-variant-context.js';
10
+ import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
11
+ import { Button } from '../button/button.js';
12
+
13
+ function ModalContent({
14
+ closeButtonContent: closeButtonContentProp,
15
+ hideCloseButton,
16
+ closeButtonProps,
17
+ ...props
18
+ }) {
19
+ const { slots, classNames, buttonSize } = useContext(ModalVariantContext);
20
+ const formatMessage = useMessageFormatter(i18nStrings);
21
+ const closeButtonContent = isValidElement(closeButtonContentProp) ? closeButtonContentProp : /* @__PURE__ */ jsx(X, {});
22
+ return /* @__PURE__ */ jsx(
23
+ Dialog,
24
+ {
25
+ ...props,
26
+ className: slots.dialog({
27
+ className: props.className ?? classNames?.dialog
28
+ }),
29
+ children: ({ close }) => /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ !hideCloseButton && /* @__PURE__ */ jsx(
31
+ Button,
32
+ {
33
+ slot: "close",
34
+ isIconOnly: true,
35
+ "aria-label": formatMessage("dismiss"),
36
+ size: buttonSize,
37
+ variant: "clear",
38
+ color: "neutral",
39
+ ...closeButtonProps,
40
+ className: slots.closeButton({
41
+ className: cn(classNames?.closeButton, props.className)
42
+ }),
43
+ children: closeButtonContent
44
+ }
45
+ ),
46
+ typeof props.children === "function" ? props.children(close) : props.children
47
+ ] })
48
+ }
49
+ );
50
+ }
51
+
52
+ export { ModalContent };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { cn } from '@opengovsg/oui-theme';
6
+ import { forwardRef } from '../system/utils.js';
7
+ import { ModalVariantContext } from './modal-variant-context.js';
8
+
9
+ const ModalFooter = forwardRef(function ModalFooter2({ as, ...props }, ref) {
10
+ const { slots, classNames } = useContext(ModalVariantContext);
11
+ const Component = as || "footer";
12
+ return /* @__PURE__ */ jsx(
13
+ Component,
14
+ {
15
+ ref,
16
+ className: slots.footer({
17
+ className: cn(classNames?.footer, props.className)
18
+ }),
19
+ ...props
20
+ }
21
+ );
22
+ });
23
+ ModalFooter.displayName = "ModalFooter";
24
+
25
+ export { ModalFooter };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useContext } from 'react';
5
+ import { Heading } from 'react-aria-components';
6
+ import { cn } from '@opengovsg/oui-theme';
7
+ import { ModalVariantContext } from './modal-variant-context.js';
8
+
9
+ function ModalHeader(props) {
10
+ const { slots, classNames } = useContext(ModalVariantContext);
11
+ return /* @__PURE__ */ jsx(
12
+ Heading,
13
+ {
14
+ slot: "title",
15
+ ...props,
16
+ className: slots.header({
17
+ className: cn(classNames?.header, props.className)
18
+ })
19
+ }
20
+ );
21
+ }
22
+
23
+ export { ModalHeader };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ "use client";
3
+ import { createContext } from '../system/react-utils/context.js';
4
+
5
+ const [ModalVariantContext, useModalVariantContext] = createContext({
6
+ name: "ModalVariantContext",
7
+ strict: true
8
+ });
9
+
10
+ export { ModalVariantContext, useModalVariantContext };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ "use client";
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { forwardRef, useMemo } from 'react';
5
+ import { Provider, ModalOverlay, Modal as Modal$1 } from 'react-aria-components';
6
+ import { modalStyles, composeRenderProps } from '@opengovsg/oui-theme';
7
+ import { mapPropsVariants } from '../system/utils.js';
8
+ import { ModalVariantContext } from './modal-variant-context.js';
9
+
10
+ const Modal = forwardRef(function Modal2(originalProps, ref) {
11
+ const [{ classNames, ...props }, variantProps] = mapPropsVariants(
12
+ originalProps,
13
+ modalStyles.variantKeys
14
+ );
15
+ const { isDismissable = true } = props;
16
+ const slots = modalStyles(variantProps);
17
+ const buttonSize = useMemo(() => {
18
+ switch (variantProps.size) {
19
+ case "mobile":
20
+ return "md";
21
+ default: {
22
+ return "lg";
23
+ }
24
+ }
25
+ }, [variantProps.size]);
26
+ return /* @__PURE__ */ jsx(
27
+ Provider,
28
+ {
29
+ values: [
30
+ [
31
+ ModalVariantContext,
32
+ { ...variantProps, classNames, buttonSize, slots }
33
+ ]
34
+ ],
35
+ children: /* @__PURE__ */ jsx(
36
+ ModalOverlay,
37
+ {
38
+ ...props,
39
+ isDismissable,
40
+ className: composeRenderProps(
41
+ classNames?.overlay,
42
+ (className, renderProps) => slots.overlay({ className, ...renderProps })
43
+ ),
44
+ children: /* @__PURE__ */ jsx(
45
+ Modal$1,
46
+ {
47
+ ...props,
48
+ ref,
49
+ isDismissable,
50
+ "data-placement": variantProps.placement,
51
+ className: composeRenderProps(
52
+ props.className ?? classNames?.base,
53
+ (className, renderProps) => slots.base({ className, ...renderProps })
54
+ )
55
+ }
56
+ )
57
+ }
58
+ )
59
+ }
60
+ );
61
+ });
62
+ Modal.displayName = "Modal";
63
+
64
+ export { Modal };
@@ -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';
9
10
  import { AgnosticCalendarStateContext } from '../calendar/agnostic-calendar-state-context.js';
10
11
  import { CalendarBottomContent } from '../calendar/calendar-bottom-content.js';
11
12
  import { CalendarGridHeader } from '../calendar/calendar-grid-header.js';
12
13
  import { CalendarHeader } from '../calendar/calendar-header.js';
13
14
  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(
@@ -70,48 +70,48 @@ export declare function useBadge(originalProps: UseBadgeProps): {
70
70
  };
71
71
  }, undefined, "outline-offset-2 outline-none", unknown, unknown, undefined>>>;
72
72
  base: ((slotProps?: ({
73
+ isDisabled?: boolean | undefined;
73
74
  size?: "md" | "sm" | "xs" | undefined;
74
75
  color?: "sub" | "main" | "neutral" | "critical" | "warning" | "success" | undefined;
75
- radius?: "lg" | "md" | "sm" | "none" | "full" | undefined;
76
+ radius?: "none" | "lg" | "md" | "sm" | "full" | undefined;
76
77
  variant?: "solid" | "outline" | "dot" | "subtle" | undefined;
77
- isDisabled?: boolean | undefined;
78
78
  isCloseable?: boolean | undefined;
79
79
  } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string) & ((slotProps?: ({
80
+ isDisabled?: boolean | undefined;
80
81
  size?: "md" | "sm" | "xs" | undefined;
81
82
  color?: "sub" | "main" | "neutral" | "critical" | "warning" | "success" | undefined;
82
- radius?: "lg" | "md" | "sm" | "none" | "full" | undefined;
83
+ radius?: "none" | "lg" | "md" | "sm" | "full" | undefined;
83
84
  variant?: "solid" | "outline" | "dot" | "subtle" | undefined;
84
- isDisabled?: boolean | undefined;
85
85
  isCloseable?: boolean | undefined;
86
86
  } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string);
87
87
  dot: ((slotProps?: ({
88
+ isDisabled?: boolean | undefined;
88
89
  size?: "md" | "sm" | "xs" | undefined;
89
90
  color?: "sub" | "main" | "neutral" | "critical" | "warning" | "success" | undefined;
90
- radius?: "lg" | "md" | "sm" | "none" | "full" | undefined;
91
+ radius?: "none" | "lg" | "md" | "sm" | "full" | undefined;
91
92
  variant?: "solid" | "outline" | "dot" | "subtle" | undefined;
92
- isDisabled?: boolean | undefined;
93
93
  isCloseable?: boolean | undefined;
94
94
  } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string) & ((slotProps?: ({
95
+ isDisabled?: boolean | undefined;
95
96
  size?: "md" | "sm" | "xs" | undefined;
96
97
  color?: "sub" | "main" | "neutral" | "critical" | "warning" | "success" | undefined;
97
- radius?: "lg" | "md" | "sm" | "none" | "full" | undefined;
98
+ radius?: "none" | "lg" | "md" | "sm" | "full" | undefined;
98
99
  variant?: "solid" | "outline" | "dot" | "subtle" | undefined;
99
- isDisabled?: boolean | undefined;
100
100
  isCloseable?: boolean | undefined;
101
101
  } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string);
102
102
  content: ((slotProps?: ({
103
+ isDisabled?: boolean | undefined;
103
104
  size?: "md" | "sm" | "xs" | undefined;
104
105
  color?: "sub" | "main" | "neutral" | "critical" | "warning" | "success" | undefined;
105
- radius?: "lg" | "md" | "sm" | "none" | "full" | undefined;
106
+ radius?: "none" | "lg" | "md" | "sm" | "full" | undefined;
106
107
  variant?: "solid" | "outline" | "dot" | "subtle" | undefined;
107
- isDisabled?: boolean | undefined;
108
108
  isCloseable?: boolean | undefined;
109
109
  } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string) & ((slotProps?: ({
110
+ isDisabled?: boolean | undefined;
110
111
  size?: "md" | "sm" | "xs" | undefined;
111
112
  color?: "sub" | "main" | "neutral" | "critical" | "warning" | "success" | undefined;
112
- radius?: "lg" | "md" | "sm" | "none" | "full" | undefined;
113
+ radius?: "none" | "lg" | "md" | "sm" | "full" | undefined;
113
114
  variant?: "solid" | "outline" | "dot" | "subtle" | undefined;
114
- isDisabled?: boolean | undefined;
115
115
  isCloseable?: boolean | undefined;
116
116
  } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string);
117
117
  };
@@ -1,2 +1,5 @@
1
- export * from "./use-controllable-state";
1
+ export { useControllableState } from "./use-controllable-state";
2
+ export { useDraggable } from "./use-draggable";
3
+ export type { UseControllableStateProps } from "./use-controllable-state";
4
+ export type { UseDraggableProps } from "./use-draggable";
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,YAAY,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,24 @@
1
+ import type { MoveResult } from "@react-aria/interactions";
2
+ export interface UseDraggableProps {
3
+ /**
4
+ * Ref to the moving target DOM node.
5
+ */
6
+ targetRef?: React.RefObject<HTMLElement | null>;
7
+ /**
8
+ * Whether to disable the target is draggable.
9
+ * @default false
10
+ */
11
+ isDisabled?: boolean;
12
+ /**
13
+ * Whether the target can overflow the viewport.
14
+ * @default false
15
+ */
16
+ canOverflow?: boolean;
17
+ }
18
+ /**
19
+ * A hook to make a target draggable.
20
+ * @param props UseDraggableProps
21
+ * @returns MoveResult for the drag DOM node.
22
+ */
23
+ export declare function useDraggable(props: UseDraggableProps): MoveResult;
24
+ //# sourceMappingURL=use-draggable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-draggable.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-draggable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAIzE,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC/C;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAmGjE"}
@@ -27,4 +27,5 @@ export * from "./checkbox";
27
27
  export * from "./pagination";
28
28
  export * from "./file-dropzone";
29
29
  export * from "./number-field";
30
+ export * from "./modal";
30
31
  //# sourceMappingURL=index.d.ts.map
@@ -27,4 +27,5 @@ export * from "./checkbox";
27
27
  export * from "./pagination";
28
28
  export * from "./file-dropzone";
29
29
  export * from "./number-field";
30
+ export * from "./modal";
30
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { LocalizedStrings } from "react-aria";
2
+ export declare const i18nStrings: LocalizedStrings;
3
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/modal/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,eAAO,MAAM,WAAW,EAAE,gBAazB,CAAA"}
@@ -0,0 +1,12 @@
1
+ export { Modal } from "./modal";
2
+ export { ModalContent } from "./modal-content";
3
+ export { ModalFooter } from "./modal-footer";
4
+ export { ModalBody } from "./modal-body";
5
+ export { ModalHeader } from "./modal-header";
6
+ export type { ModalProps } from "./modal";
7
+ export type { ModalContentProps } from "./modal-content";
8
+ export type { ModalFooterProps } from "./modal-footer";
9
+ export type { ModalBodyProps } from "./modal-body";
10
+ export type { ModalHeaderProps } from "./modal-header";
11
+ export { ModalVariantContext, useModalVariantContext, } from "./modal-variant-context";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { HtmlUiProps } from "../system/types";
2
+ export interface ModalBodyProps extends HtmlUiProps<"div"> {
3
+ }
4
+ export declare const ModalBody: import("../system/utils").InternalForwardRefRenderFunction<import("../system/types").As, ModalBodyProps, never>;
5
+ //# sourceMappingURL=modal-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-body.d.ts","sourceRoot":"","sources":["../../../src/modal/modal-body.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAKlD,MAAM,WAAW,cAAe,SAAQ,WAAW,CAAC,KAAK,CAAC;CAAG;AAE7D,eAAO,MAAM,SAAS,iHAiBpB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { DialogProps } from "react-aria-components";
2
+ import type { ButtonProps } from "../button";
3
+ export interface ModalContentProps extends Omit<DialogProps, "children"> {
4
+ children: React.ReactNode | ((onClose: () => void) => React.ReactNode);
5
+ closeButtonContent?: React.ReactNode;
6
+ hideCloseButton?: boolean;
7
+ closeButtonProps?: Omit<ButtonProps, "className" | "slot">;
8
+ }
9
+ export declare function ModalContent({ closeButtonContent: closeButtonContentProp, hideCloseButton, closeButtonProps, ...props }: ModalContentProps): import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=modal-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["../../../src/modal/modal-content.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAQxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAK5C,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IACtE,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC,CAAA;IACtE,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACpC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,gBAAgB,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAAC,CAAA;CAC3D;AAED,wBAAgB,YAAY,CAAC,EAC3B,kBAAkB,EAAE,sBAAsB,EAC1C,eAAe,EACf,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,iBAAiB,2CA2CnB"}
@@ -0,0 +1,5 @@
1
+ import type { HtmlUiProps } from "../system/types";
2
+ export interface ModalFooterProps extends HtmlUiProps<"footer"> {
3
+ }
4
+ export declare const ModalFooter: import("../system/utils").InternalForwardRefRenderFunction<import("../system/types").As, ModalFooterProps, never>;
5
+ //# sourceMappingURL=modal-footer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-footer.d.ts","sourceRoot":"","sources":["../../../src/modal/modal-footer.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAKlD,MAAM,WAAW,gBAAiB,SAAQ,WAAW,CAAC,QAAQ,CAAC;CAAG;AAElE,eAAO,MAAM,WAAW,mHAgBtB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { HeadingProps } from "react-aria-components";
2
+ export interface ModalHeaderProps extends HeadingProps {
3
+ }
4
+ export declare function ModalHeader(props: ModalHeaderProps): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=modal-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-header.d.ts","sourceRoot":"","sources":["../../../src/modal/modal-header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AASzD,MAAM,WAAW,gBAAiB,SAAQ,YAAY;CAAG;AAEzD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAYlD"}
@@ -0,0 +1,8 @@
1
+ import type { ModalSlots, modalStyles, ModalVariantProps, SlotsToClasses } from "@opengovsg/oui-theme";
2
+ export interface ModalVariantContextValue extends ModalVariantProps {
3
+ classNames?: SlotsToClasses<ModalSlots>;
4
+ slots: ReturnType<typeof modalStyles>;
5
+ buttonSize: "md" | "lg";
6
+ }
7
+ export declare const ModalVariantContext: import("react").Context<ModalVariantContextValue>, useModalVariantContext: () => ModalVariantContextValue;
8
+ //# sourceMappingURL=modal-variant-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-variant-context.d.ts","sourceRoot":"","sources":["../../../src/modal/modal-variant-context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACf,MAAM,sBAAsB,CAAA;AAI7B,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IACjE,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACvC,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;IACrC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;CACxB;AAED,eAAO,MAAO,mBAAmB,qDAAE,sBAAsB,gCAIrD,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { ModalOverlayProps } from "react-aria-components";
2
+ import type { ModalSlots, SlotsToClasses, VariantProps } from "@opengovsg/oui-theme";
3
+ import { modalStyles } from "@opengovsg/oui-theme";
4
+ export interface ModalProps extends ModalOverlayProps, VariantProps<typeof modalStyles> {
5
+ classNames?: SlotsToClasses<ModalSlots>;
6
+ }
7
+ export declare const Modal: import("react").ForwardRefExoticComponent<ModalProps & import("react").RefAttributes<HTMLDivElement>>;
8
+ //# sourceMappingURL=modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/modal/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAQ9D,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAsB,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAMtE,MAAM,WAAW,UACf,SAAQ,iBAAiB,EACvB,YAAY,CAAC,OAAO,WAAW,CAAC;IAClC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CACxC;AAED,eAAO,MAAM,KAAK,uGAsDhB,CAAA"}