@opengovsg/oui 0.0.0-snapshot-20251201075851 → 0.0.0-snapshot-20251203091804
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/button/button.cjs +1 -1
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +2 -2
- package/dist/cjs/checkbox/checkbox.cjs +1 -1
- 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 +5 -4
- 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/hooks/index.cjs +2 -0
- package/dist/cjs/hooks/use-draggable.cjs +88 -0
- package/dist/cjs/index.cjs +22 -7
- package/dist/cjs/menu/menu.cjs +1 -1
- package/dist/cjs/modal/i18n.cjs +19 -0
- package/dist/cjs/modal/index.cjs +19 -0
- package/dist/cjs/modal/modal-body.cjs +26 -0
- package/dist/cjs/modal/modal-content.cjs +54 -0
- package/dist/cjs/modal/modal-footer.cjs +27 -0
- package/dist/cjs/modal/modal-header.cjs +25 -0
- package/dist/cjs/modal/modal-variant-context.cjs +13 -0
- package/dist/cjs/modal/modal.cjs +66 -0
- package/dist/cjs/number-field/number-field.cjs +3 -3
- package/dist/cjs/range-calendar/range-calendar.cjs +1 -1
- package/dist/cjs/select/select.cjs +3 -3
- 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/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 +1 -1
- package/dist/esm/combo-box/combo-box.js +2 -2
- package/dist/esm/date-field/date-field.js +1 -1
- package/dist/esm/date-picker/date-picker.js +5 -4
- package/dist/esm/date-range-picker/date-range-picker.js +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/hooks/index.js +1 -0
- package/dist/esm/hooks/use-draggable.js +86 -0
- package/dist/esm/index.js +9 -2
- package/dist/esm/menu/menu.js +1 -1
- package/dist/esm/modal/i18n.js +17 -0
- package/dist/esm/modal/index.js +7 -0
- package/dist/esm/modal/modal-body.js +24 -0
- package/dist/esm/modal/modal-content.js +52 -0
- package/dist/esm/modal/modal-footer.js +25 -0
- package/dist/esm/modal/modal-header.js +23 -0
- package/dist/esm/modal/modal-variant-context.js +10 -0
- package/dist/esm/modal/modal.js +64 -0
- package/dist/esm/number-field/number-field.js +3 -3
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/select/select.js +3 -3
- package/dist/esm/tag-field/tag-field.js +3 -3
- package/dist/esm/text-area-field/text-area-field.js +1 -1
- package/dist/esm/text-field/text-field.js +1 -1
- package/dist/types/badge/use-badge.d.ts +12 -12
- package/dist/types/hooks/index.d.ts +4 -1
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/use-draggable.d.ts +24 -0
- package/dist/types/hooks/use-draggable.d.ts.map +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modal/i18n.d.ts +3 -0
- package/dist/types/modal/i18n.d.ts.map +1 -0
- package/dist/types/modal/index.d.ts +12 -0
- package/dist/types/modal/index.d.ts.map +1 -0
- package/dist/types/modal/modal-body.d.ts +5 -0
- package/dist/types/modal/modal-body.d.ts.map +1 -0
- package/dist/types/modal/modal-content.d.ts +10 -0
- package/dist/types/modal/modal-content.d.ts.map +1 -0
- package/dist/types/modal/modal-footer.d.ts +5 -0
- package/dist/types/modal/modal-footer.d.ts.map +1 -0
- package/dist/types/modal/modal-header.d.ts +5 -0
- package/dist/types/modal/modal-header.d.ts.map +1 -0
- package/dist/types/modal/modal-variant-context.d.ts +8 -0
- package/dist/types/modal/modal-variant-context.d.ts.map +1 -0
- package/dist/types/modal/modal.d.ts +8 -0
- package/dist/types/modal/modal.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination.d.ts +36 -36
- package/package.json +5 -5
|
@@ -6,12 +6,12 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var button = require('../button/button.cjs');
|
|
10
|
+
var field = require('../field/field.cjs');
|
|
11
|
+
var popover = require('../popover/popover.cjs');
|
|
9
12
|
var utils = require('../system/utils.cjs');
|
|
10
13
|
var selectVariantContext = require('./select-variant-context.cjs');
|
|
11
|
-
var field = require('../field/field.cjs');
|
|
12
14
|
var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs');
|
|
13
|
-
var popover = require('../popover/popover.cjs');
|
|
14
|
-
var button = require('../button/button.cjs');
|
|
15
15
|
|
|
16
16
|
const calculateEstimatedRowHeight = (size) => {
|
|
17
17
|
switch (size) {
|
|
@@ -6,15 +6,15 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactAriaComponents = require('react-aria-components');
|
|
8
8
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var field = require('../field/field.cjs');
|
|
10
|
+
var input = require('../input/input.cjs');
|
|
11
|
+
var popover = require('../popover/popover.cjs');
|
|
9
12
|
var tagFieldItem = require('./tag-field-item.cjs');
|
|
10
13
|
var tagFieldList = require('./tag-field-list.cjs');
|
|
11
14
|
var tagFieldRoot = require('./tag-field-root.cjs');
|
|
12
15
|
var tagFieldTagList = require('./tag-field-tag-list.cjs');
|
|
13
16
|
var tagFieldTrigger = require('./tag-field-trigger.cjs');
|
|
14
17
|
var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs');
|
|
15
|
-
var field = require('../field/field.cjs');
|
|
16
|
-
var input = require('../input/input.cjs');
|
|
17
|
-
var popover = require('../popover/popover.cjs');
|
|
18
18
|
|
|
19
19
|
function TagField({
|
|
20
20
|
classNames,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
-
var textArea = require('../text-area/text-area.cjs');
|
|
9
8
|
var field = require('../field/field.cjs');
|
|
9
|
+
var textArea = require('../text-area/text-area.cjs');
|
|
10
10
|
|
|
11
11
|
function TextAreaField({
|
|
12
12
|
label,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
-
var input = require('../input/input.cjs');
|
|
9
8
|
var field = require('../field/field.cjs');
|
|
9
|
+
var input = require('../input/input.cjs');
|
|
10
10
|
|
|
11
11
|
function TextField({
|
|
12
12
|
label,
|
|
@@ -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';
|
|
8
9
|
import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
|
|
9
10
|
import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/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.0.0/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';
|
|
8
9
|
import { useRipple } from '../ripple/use-ripple.js';
|
|
9
10
|
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';
|
|
7
9
|
import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.js';
|
|
8
10
|
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
9
11
|
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';
|
|
6
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
7
8
|
import { useCheckboxGroupStyleContext, CheckboxGroupStyleContext } from './checkbox-group-style-context.js';
|
|
8
9
|
import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.js';
|
|
9
10
|
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js';
|
|
10
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
11
11
|
|
|
12
12
|
const Checkbox = ({
|
|
13
13
|
classNames,
|
|
@@ -5,13 +5,13 @@ import { useMemo, useCallback } from 'react';
|
|
|
5
5
|
import { useMessageFormatter } from 'react-aria';
|
|
6
6
|
import { ListLayout, Provider, ComboBox as ComboBox$1, Input, Button, Virtualizer, ListBox } from 'react-aria-components';
|
|
7
7
|
import { listBoxItemStyles, cn, comboBoxStyles, composeTailwindRenderProps, composeRenderProps, comboBoxClearButtonStyles } from '@opengovsg/oui-theme';
|
|
8
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
9
|
+
import { Popover } from '../popover/popover.js';
|
|
8
10
|
import { mapPropsVariants } from '../system/utils.js';
|
|
9
11
|
import { ComboBoxVariantContext } from './combo-box-variant-context.js';
|
|
10
|
-
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
11
12
|
import ChevronUp from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
|
|
12
13
|
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
13
14
|
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
14
|
-
import { Popover } from '../popover/popover.js';
|
|
15
15
|
|
|
16
16
|
const calculateEstimatedRowHeight = (size) => {
|
|
17
17
|
switch (size) {
|
|
@@ -4,8 +4,8 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { DateField as DateField$1, DateInput as DateInput$1, DateSegment } from 'react-aria-components';
|
|
6
6
|
import { dateFieldStyles, composeTailwindRenderProps, dateInputStyles, composeRenderProps } from '@opengovsg/oui-theme';
|
|
7
|
-
import { mapPropsVariants } from '../system/utils.js';
|
|
8
7
|
import { Label, Description, FieldError } from '../field/field.js';
|
|
8
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
9
9
|
|
|
10
10
|
function DateField(originalProps) {
|
|
11
11
|
const [
|
|
@@ -4,13 +4,14 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { DatePicker as DatePicker$1, Dialog } from 'react-aria-components';
|
|
6
6
|
import { datePickerStyles, composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
7
|
-
import {
|
|
8
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
9
|
-
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
7
|
+
import { Button } from '../button/button.js';
|
|
10
8
|
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
9
|
+
import '@internationalized/date';
|
|
10
|
+
import { DateInput } from '../date-field/date-field.js';
|
|
11
11
|
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
12
|
-
import { Button } from '../button/button.js';
|
|
13
12
|
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.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
14
15
|
|
|
15
16
|
function DatePicker(originalProps) {
|
|
16
17
|
const [
|
|
@@ -5,13 +5,13 @@ import { useMemo } from 'react';
|
|
|
5
5
|
import { CalendarDate } from '@internationalized/date';
|
|
6
6
|
import { DateRangePicker as DateRangePicker$1, Dialog } from 'react-aria-components';
|
|
7
7
|
import { dateRangePickerStyles, composeTailwindRenderProps } from '@opengovsg/oui-theme';
|
|
8
|
-
import { mapPropsVariants } from '../system/utils.js';
|
|
9
|
-
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
10
|
-
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
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';
|
|
14
11
|
import { Popover } from '../popover/popover.js';
|
|
12
|
+
import { RangeCalendar } from '../range-calendar/range-calendar.js';
|
|
13
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
14
|
+
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
15
15
|
|
|
16
16
|
function DateRangePicker(originalProps) {
|
|
17
17
|
const [
|
|
@@ -7,13 +7,13 @@ import { useField, useId } from 'react-aria';
|
|
|
7
7
|
import { Provider, LabelContext, GroupContext, TextContext, FieldErrorContext, Group } from 'react-aria-components';
|
|
8
8
|
import { useDropzone } from 'react-dropzone';
|
|
9
9
|
import { fileDropzoneStyles, dataAttr } from '@opengovsg/oui-theme';
|
|
10
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
11
|
+
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
10
12
|
import { mapPropsVariants } from '../system/utils.js';
|
|
11
13
|
import { FileDropzoneStyleContext, FileDropzoneStateContext, useFileDropzoneStateContext, useFileDropzoneStyleContext } from './contexts.js';
|
|
12
14
|
import { FileInfo } from './file-info.js';
|
|
13
15
|
import { formatErrorMessage, formatBytes } from './utils.js';
|
|
14
|
-
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
15
16
|
import Upload from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/upload.js';
|
|
16
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
17
17
|
|
|
18
18
|
const FileDropzone = (originalProps) => {
|
|
19
19
|
const [props, variantProps] = mapPropsVariants(
|
|
@@ -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';
|
|
6
7
|
import { useFileDropzoneStateContext, useFileDropzoneStyleContext } from './contexts.js';
|
|
7
8
|
import { formatBytes } from './utils.js';
|
|
8
9
|
import Trash2 from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/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/hooks/index.js
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
4
|
+
import { useMove } from '@react-aria/interactions';
|
|
5
|
+
|
|
6
|
+
function useDraggable(props) {
|
|
7
|
+
const { targetRef, isDisabled = false, canOverflow = false } = props;
|
|
8
|
+
const boundary = useRef({ minLeft: 0, minTop: 0, maxLeft: 0, maxTop: 0 });
|
|
9
|
+
const isDragging = useRef(false);
|
|
10
|
+
let transform = { offsetX: 0, offsetY: 0 };
|
|
11
|
+
const onMoveStart = useCallback(() => {
|
|
12
|
+
isDragging.current = true;
|
|
13
|
+
const { offsetX, offsetY } = transform;
|
|
14
|
+
const targetRect = targetRef?.current?.getBoundingClientRect();
|
|
15
|
+
const targetLeft = targetRect?.left ?? 0;
|
|
16
|
+
const targetTop = targetRect?.top ?? 0;
|
|
17
|
+
const targetWidth = targetRect?.width ?? 0;
|
|
18
|
+
const targetHeight = targetRect?.height ?? 0;
|
|
19
|
+
const clientWidth = document.documentElement.clientWidth;
|
|
20
|
+
const clientHeight = document.documentElement.clientHeight;
|
|
21
|
+
const minLeft = -targetLeft + offsetX;
|
|
22
|
+
const minTop = -targetTop + offsetY;
|
|
23
|
+
const maxLeft = clientWidth - targetLeft - targetWidth + offsetX;
|
|
24
|
+
const maxTop = clientHeight - targetTop - targetHeight + offsetY;
|
|
25
|
+
boundary.current = {
|
|
26
|
+
minLeft,
|
|
27
|
+
minTop,
|
|
28
|
+
maxLeft,
|
|
29
|
+
maxTop
|
|
30
|
+
};
|
|
31
|
+
}, [transform, targetRef?.current]);
|
|
32
|
+
const onMove = useCallback(
|
|
33
|
+
(e) => {
|
|
34
|
+
if (isDisabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const { offsetX, offsetY } = transform;
|
|
38
|
+
const { minLeft, minTop, maxLeft, maxTop } = boundary.current;
|
|
39
|
+
let moveX = offsetX + e.deltaX;
|
|
40
|
+
let moveY = offsetY + e.deltaY;
|
|
41
|
+
if (!canOverflow) {
|
|
42
|
+
moveX = Math.min(Math.max(moveX, minLeft), maxLeft);
|
|
43
|
+
moveY = Math.min(Math.max(moveY, minTop), maxTop);
|
|
44
|
+
}
|
|
45
|
+
transform = {
|
|
46
|
+
offsetX: moveX,
|
|
47
|
+
offsetY: moveY
|
|
48
|
+
};
|
|
49
|
+
if (targetRef?.current) {
|
|
50
|
+
targetRef.current.style.transform = `translate(${moveX}px, ${moveY}px)`;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[isDisabled, transform, boundary.current, canOverflow, targetRef?.current]
|
|
54
|
+
);
|
|
55
|
+
const onMoveEnd = useCallback(() => {
|
|
56
|
+
isDragging.current = false;
|
|
57
|
+
}, []);
|
|
58
|
+
const { moveProps } = useMove({
|
|
59
|
+
onMoveStart,
|
|
60
|
+
onMove,
|
|
61
|
+
onMoveEnd
|
|
62
|
+
});
|
|
63
|
+
const preventDefault = useCallback((e) => {
|
|
64
|
+
if (isDragging.current) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!isDisabled) {
|
|
70
|
+
document.body.addEventListener("touchmove", preventDefault, {
|
|
71
|
+
passive: false
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return () => {
|
|
75
|
+
document.body.removeEventListener("touchmove", preventDefault);
|
|
76
|
+
};
|
|
77
|
+
}, [isDisabled, preventDefault]);
|
|
78
|
+
return {
|
|
79
|
+
moveProps: {
|
|
80
|
+
...moveProps,
|
|
81
|
+
style: { cursor: !isDisabled ? "move" : void 0 }
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { useDraggable };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,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 { Button } from './button/button.js';
|
|
4
5
|
export { GovtBanner } from './govt-banner/govt-banner.js';
|
|
5
6
|
export { Ripple } from './ripple/ripple.js';
|
|
@@ -24,10 +25,10 @@ export { Select } from './select/select.js';
|
|
|
24
25
|
export { SelectItem } from './select/select-item.js';
|
|
25
26
|
export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
|
|
26
27
|
export { Badge } from './badge/badge.js';
|
|
27
|
-
export { CalendarDate } from '@internationalized/date';
|
|
28
28
|
export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
|
|
29
29
|
export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
|
|
30
30
|
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
|
|
31
|
+
export { CalendarDate } from '@internationalized/date';
|
|
31
32
|
export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
|
|
32
33
|
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
33
34
|
export { Popover } from './popover/popover.js';
|
|
@@ -37,12 +38,18 @@ export { DatePicker } from './date-picker/date-picker.js';
|
|
|
37
38
|
export { DateRangePicker } from './date-range-picker/date-range-picker.js';
|
|
38
39
|
export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
|
|
39
40
|
export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
|
|
40
|
-
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
41
41
|
export { Pagination } from './pagination/pagination.js';
|
|
42
42
|
export { PaginationCursor } from './pagination/pagination-cursor.js';
|
|
43
43
|
export { PaginationItem } from './pagination/pagination-item.js';
|
|
44
|
+
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
44
45
|
export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './pagination/use-pagination.js';
|
|
45
46
|
export { FileDropzone } from './file-dropzone/file-dropzone.js';
|
|
46
47
|
export { FileInfo } from './file-dropzone/file-info.js';
|
|
47
48
|
export { formatBytes, formatErrorMessage } from './file-dropzone/utils.js';
|
|
48
49
|
export { NumberField } from './number-field/number-field.js';
|
|
50
|
+
export { Modal } from './modal/modal.js';
|
|
51
|
+
export { ModalContent } from './modal/modal-content.js';
|
|
52
|
+
export { ModalFooter } from './modal/modal-footer.js';
|
|
53
|
+
export { ModalBody } from './modal/modal-body.js';
|
|
54
|
+
export { ModalHeader } from './modal/modal-header.js';
|
|
55
|
+
export { ModalVariantContext, useModalVariantContext } from './modal/modal-variant-context.js';
|
package/dist/esm/menu/menu.js
CHANGED
|
@@ -4,11 +4,11 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
import { forwardRef, useMemo, useCallback } from 'react';
|
|
5
5
|
import { useContextProps, MenuItem as MenuItem$1, composeRenderProps, Provider, Menu as Menu$1, MenuSection as MenuSection$1, Header, Collection, MenuTrigger as MenuTrigger$1, SubmenuTrigger as SubmenuTrigger$1, Separator } from 'react-aria-components';
|
|
6
6
|
import { listBoxItemStyles, menuItemStyles, menuStyles, menuSectionStyles, menuDividerStyles } from '@opengovsg/oui-theme';
|
|
7
|
+
import { Popover } from '../popover/popover.js';
|
|
7
8
|
import { forwardRefGeneric, mapPropsVariants } from '../system/utils.js';
|
|
8
9
|
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/check.js';
|
|
9
10
|
import ChevronRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-right.js';
|
|
10
11
|
import { createContext } from '../system/react-utils/context.js';
|
|
11
|
-
import { Popover } from '../popover/popover.js';
|
|
12
12
|
|
|
13
13
|
const [MenuVariantContext, useMenuVariantContext] = createContext({
|
|
14
14
|
name: "MenuVariantContext",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const i18nStrings = {
|
|
3
|
+
"en-SG": {
|
|
4
|
+
dismiss: "Dismiss"
|
|
5
|
+
},
|
|
6
|
+
"zh-SG": {
|
|
7
|
+
dismiss: "\u53D6\u6D88"
|
|
8
|
+
},
|
|
9
|
+
"ms-SG": {
|
|
10
|
+
dismiss: "Tutup"
|
|
11
|
+
},
|
|
12
|
+
"ta-SG": {
|
|
13
|
+
dismiss: "\u0BAE\u0BC2\u0B9F\u0BC1"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { i18nStrings };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export { Modal } from './modal.js';
|
|
3
|
+
export { ModalContent } from './modal-content.js';
|
|
4
|
+
export { ModalFooter } from './modal-footer.js';
|
|
5
|
+
export { ModalBody } from './modal-body.js';
|
|
6
|
+
export { ModalHeader } from './modal-header.js';
|
|
7
|
+
export { ModalVariantContext, useModalVariantContext } from './modal-variant-context.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { cn } from '@opengovsg/oui-theme';
|
|
6
|
+
import { forwardRef } from '../system/utils.js';
|
|
7
|
+
import { ModalVariantContext } from './modal-variant-context.js';
|
|
8
|
+
|
|
9
|
+
const ModalBody = forwardRef(function ModalBody2({ as, ...props }, ref) {
|
|
10
|
+
const { slots, classNames } = useContext(ModalVariantContext);
|
|
11
|
+
const Component = as || "div";
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Component,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
className: slots.body({
|
|
17
|
+
className: cn(classNames?.body, props.className)
|
|
18
|
+
}),
|
|
19
|
+
...props
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { ModalBody };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { useContext, isValidElement } from 'react';
|
|
5
|
+
import { useMessageFormatter } from 'react-aria';
|
|
6
|
+
import { Dialog } from 'react-aria-components';
|
|
7
|
+
import { cn } from '@opengovsg/oui-theme';
|
|
8
|
+
import { Button } from '../button/button.js';
|
|
9
|
+
import { i18nStrings } from './i18n.js';
|
|
10
|
+
import { ModalVariantContext } from './modal-variant-context.js';
|
|
11
|
+
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/x.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 };
|
|
@@ -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';
|
|
6
9
|
import { mapPropsVariants } from '../system/utils.js';
|
|
7
10
|
import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.js';
|
|
8
11
|
import Plus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/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';
|
|
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(
|
|
@@ -4,12 +4,12 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { Provider, Select as Select$1, SelectValue, Virtualizer, ListLayout, ListBox } from 'react-aria-components';
|
|
6
6
|
import { selectStyles, composeRenderProps } from '@opengovsg/oui-theme';
|
|
7
|
+
import { Button } from '../button/button.js';
|
|
8
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
9
|
+
import { Popover } from '../popover/popover.js';
|
|
7
10
|
import { mapPropsVariants } from '../system/utils.js';
|
|
8
11
|
import { SelectVariantContext } from './select-variant-context.js';
|
|
9
|
-
import { Label, Description, FieldError } from '../field/field.js';
|
|
10
12
|
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
11
|
-
import { Popover } from '../popover/popover.js';
|
|
12
|
-
import { Button } from '../button/button.js';
|
|
13
13
|
|
|
14
14
|
const calculateEstimatedRowHeight = (size) => {
|
|
15
15
|
switch (size) {
|