@opengovsg/oui 0.0.24 → 0.0.26
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/badge/badge.cjs +1 -1
- package/dist/cjs/banner/banner.cjs +3 -3
- package/dist/cjs/button/button.cjs +2 -2
- package/dist/cjs/calendar/calendar-header.cjs +2 -2
- package/dist/cjs/checkbox/checkbox.cjs +3 -3
- package/dist/cjs/combo-box/combo-box.cjs +5 -5
- package/dist/cjs/date-field/date-field.cjs +1 -1
- package/dist/cjs/date-picker/date-picker.cjs +3 -3
- package/dist/cjs/date-range-picker/date-range-picker.cjs +4 -4
- package/dist/cjs/field/field.cjs +1 -1
- package/dist/cjs/file-dropzone/file-dropzone.cjs +3 -3
- package/dist/cjs/file-dropzone/file-info.cjs +1 -1
- package/dist/cjs/govt-banner/govt-banner.cjs +4 -4
- package/dist/cjs/hooks/index.cjs +2 -0
- package/dist/cjs/hooks/use-draggable.cjs +88 -0
- package/dist/cjs/index.cjs +66 -51
- package/dist/cjs/menu/menu.cjs +3 -3
- 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/pagination/pagination.cjs +3 -3
- package/dist/cjs/select/select.cjs +3 -3
- package/dist/cjs/system/utils.cjs +0 -48
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +1 -1
- package/dist/cjs/tag-field/tag-field.cjs +4 -4
- 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/badge/badge.js +1 -1
- package/dist/esm/banner/banner.js +3 -3
- package/dist/esm/button/button.js +2 -2
- package/dist/esm/calendar/calendar-header.js +2 -2
- package/dist/esm/checkbox/checkbox.js +3 -3
- package/dist/esm/combo-box/combo-box.js +5 -5
- package/dist/esm/date-field/date-field.js +1 -1
- package/dist/esm/date-picker/date-picker.js +3 -3
- package/dist/esm/date-range-picker/date-range-picker.js +4 -4
- package/dist/esm/field/field.js +1 -1
- package/dist/esm/file-dropzone/file-dropzone.js +3 -3
- package/dist/esm/file-dropzone/file-info.js +1 -1
- package/dist/esm/govt-banner/govt-banner.js +4 -4
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/use-draggable.js +86 -0
- package/dist/esm/index.js +25 -18
- package/dist/esm/menu/menu.js +3 -3
- 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/pagination/pagination.js +3 -3
- package/dist/esm/select/select.js +3 -3
- package/dist/esm/system/utils.js +2 -49
- package/dist/esm/tag-field/tag-field-tag-list.js +1 -1
- package/dist/esm/tag-field/tag-field.js +4 -4
- 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/dist/types/system/utils.d.ts +1 -833
- package/dist/types/system/utils.d.ts.map +1 -1
- package/package.json +9 -9
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/Icon.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/defaultAttributes.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/calendar.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/check.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-right.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-up.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevrons-right.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/circle-alert.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/ellipsis.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/external-link.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/info.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/landmark.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/lock.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/minus.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/plus.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/trash-2.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/upload.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/x.cjs +0 -0
- /package/dist/cjs/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/shared/src/utils.cjs +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/Icon.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/createLucideIcon.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/defaultAttributes.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/calendar.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/check.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-down.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-left.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-right.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevron-up.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/chevrons-right.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/circle-alert.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/ellipsis.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/external-link.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/info.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/landmark.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/lock.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/minus.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/plus.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/trash-2.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/upload.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/icons/x.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{lucide-react@0.475.0_react@19.0.0 → lucide-react@0.475.0_react@19.2.1}/node_modules/lucide-react/dist/esm/shared/src/utils.js +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var modalVariantContext = require('./modal-variant-context.cjs');
|
|
10
|
+
|
|
11
|
+
function ModalHeader(props) {
|
|
12
|
+
const { slots, classNames } = react.useContext(modalVariantContext.ModalVariantContext);
|
|
13
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
14
|
+
reactAriaComponents.Heading,
|
|
15
|
+
{
|
|
16
|
+
slot: "title",
|
|
17
|
+
...props,
|
|
18
|
+
className: slots.header({
|
|
19
|
+
className: ouiTheme.cn(classNames?.header, props.className)
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.ModalHeader = ModalHeader;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var context = require('../system/react-utils/context.cjs');
|
|
6
|
+
|
|
7
|
+
const [ModalVariantContext, useModalVariantContext] = context.createContext({
|
|
8
|
+
name: "ModalVariantContext",
|
|
9
|
+
strict: true
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
exports.ModalVariantContext = ModalVariantContext;
|
|
13
|
+
exports.useModalVariantContext = useModalVariantContext;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var utils = require('../system/utils.cjs');
|
|
10
|
+
var modalVariantContext = require('./modal-variant-context.cjs');
|
|
11
|
+
|
|
12
|
+
const Modal = react.forwardRef(function Modal2(originalProps, ref) {
|
|
13
|
+
const [{ classNames, ...props }, variantProps] = utils.mapPropsVariants(
|
|
14
|
+
originalProps,
|
|
15
|
+
ouiTheme.modalStyles.variantKeys
|
|
16
|
+
);
|
|
17
|
+
const { isDismissable = true } = props;
|
|
18
|
+
const slots = ouiTheme.modalStyles(variantProps);
|
|
19
|
+
const buttonSize = react.useMemo(() => {
|
|
20
|
+
switch (variantProps.size) {
|
|
21
|
+
case "mobile":
|
|
22
|
+
return "md";
|
|
23
|
+
default: {
|
|
24
|
+
return "lg";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [variantProps.size]);
|
|
28
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
29
|
+
reactAriaComponents.Provider,
|
|
30
|
+
{
|
|
31
|
+
values: [
|
|
32
|
+
[
|
|
33
|
+
modalVariantContext.ModalVariantContext,
|
|
34
|
+
{ ...variantProps, classNames, buttonSize, slots }
|
|
35
|
+
]
|
|
36
|
+
],
|
|
37
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
reactAriaComponents.ModalOverlay,
|
|
39
|
+
{
|
|
40
|
+
...props,
|
|
41
|
+
isDismissable,
|
|
42
|
+
className: ouiTheme.composeRenderProps(
|
|
43
|
+
classNames?.overlay,
|
|
44
|
+
(className, renderProps) => slots.overlay({ className, ...renderProps })
|
|
45
|
+
),
|
|
46
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
reactAriaComponents.Modal,
|
|
48
|
+
{
|
|
49
|
+
...props,
|
|
50
|
+
ref,
|
|
51
|
+
isDismissable,
|
|
52
|
+
"data-placement": variantProps.placement,
|
|
53
|
+
className: ouiTheme.composeRenderProps(
|
|
54
|
+
props.className ?? classNames?.base,
|
|
55
|
+
(className, renderProps) => slots.base({ className, ...renderProps })
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
Modal.displayName = "Modal";
|
|
65
|
+
|
|
66
|
+
exports.Modal = Modal;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
+
var utils = require('../system/utils.cjs');
|
|
9
|
+
var minus = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/minus.cjs');
|
|
10
|
+
var plus = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/plus.cjs');
|
|
8
11
|
var field = require('../field/field.cjs');
|
|
9
12
|
var input = require('../input/input.cjs');
|
|
10
|
-
var utils = require('../system/utils.cjs');
|
|
11
|
-
var minus = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.cjs');
|
|
12
|
-
var plus = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/plus.cjs');
|
|
13
13
|
var button = require('../button/button.cjs');
|
|
14
14
|
|
|
15
15
|
function NumberField(originalProps) {
|
|
@@ -11,9 +11,9 @@ var usePagination$1 = require('./hooks/use-pagination.cjs');
|
|
|
11
11
|
var paginationCursor = require('./pagination-cursor.cjs');
|
|
12
12
|
var paginationItem = require('./pagination-item.cjs');
|
|
13
13
|
var usePagination = require('./use-pagination.cjs');
|
|
14
|
-
var chevronLeft = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
15
|
-
var ellipsis = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
16
|
-
var chevronsRight = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
14
|
+
var chevronLeft = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-left.cjs');
|
|
15
|
+
var ellipsis = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/ellipsis.cjs');
|
|
16
|
+
var chevronsRight = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevrons-right.cjs');
|
|
17
17
|
|
|
18
18
|
const Pagination = utils.forwardRef((props, ref) => {
|
|
19
19
|
const {
|
|
@@ -6,11 +6,11 @@ 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 popover = require('../popover/popover.cjs');
|
|
11
9
|
var utils = require('../system/utils.cjs');
|
|
12
10
|
var selectVariantContext = require('./select-variant-context.cjs');
|
|
13
|
-
var
|
|
11
|
+
var field = require('../field/field.cjs');
|
|
12
|
+
var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs');
|
|
13
|
+
var popover = require('../popover/popover.cjs');
|
|
14
14
|
var button = require('../button/button.cjs');
|
|
15
15
|
|
|
16
16
|
const calculateEstimatedRowHeight = (size) => {
|
|
@@ -28,53 +28,6 @@ const mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
|
|
|
28
28
|
}
|
|
29
29
|
return [props, picked];
|
|
30
30
|
};
|
|
31
|
-
function useRenderProps(props) {
|
|
32
|
-
const {
|
|
33
|
-
className,
|
|
34
|
-
style,
|
|
35
|
-
children,
|
|
36
|
-
defaultClassName = void 0,
|
|
37
|
-
defaultChildren = void 0,
|
|
38
|
-
defaultStyle,
|
|
39
|
-
values
|
|
40
|
-
} = props;
|
|
41
|
-
return react.useMemo(() => {
|
|
42
|
-
let computedClassName;
|
|
43
|
-
let computedStyle;
|
|
44
|
-
let computedChildren;
|
|
45
|
-
if (typeof className === "function") {
|
|
46
|
-
computedClassName = className({ ...values, defaultClassName });
|
|
47
|
-
} else {
|
|
48
|
-
computedClassName = className;
|
|
49
|
-
}
|
|
50
|
-
if (typeof style === "function") {
|
|
51
|
-
computedStyle = style({ ...values, defaultStyle: defaultStyle || {} });
|
|
52
|
-
} else {
|
|
53
|
-
computedStyle = style;
|
|
54
|
-
}
|
|
55
|
-
if (typeof children === "function") {
|
|
56
|
-
computedChildren = children({ ...values, defaultChildren });
|
|
57
|
-
} else if (children == null) {
|
|
58
|
-
computedChildren = defaultChildren;
|
|
59
|
-
} else {
|
|
60
|
-
computedChildren = children;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
className: computedClassName ?? defaultClassName,
|
|
64
|
-
style: computedStyle || defaultStyle ? { ...defaultStyle, ...computedStyle } : void 0,
|
|
65
|
-
children: computedChildren ?? defaultChildren,
|
|
66
|
-
"data-rac": ""
|
|
67
|
-
};
|
|
68
|
-
}, [
|
|
69
|
-
className,
|
|
70
|
-
style,
|
|
71
|
-
children,
|
|
72
|
-
defaultClassName,
|
|
73
|
-
defaultChildren,
|
|
74
|
-
defaultStyle,
|
|
75
|
-
values
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
31
|
function removeDataAttributes(props) {
|
|
79
32
|
const prefix = /^(data-.*)$/;
|
|
80
33
|
const filteredProps = {};
|
|
@@ -101,4 +54,3 @@ exports.forwardRefGeneric = forwardRefGeneric;
|
|
|
101
54
|
exports.mapPropsVariants = mapPropsVariants;
|
|
102
55
|
exports.pickAriaAttributes = pickAriaAttributes;
|
|
103
56
|
exports.removeDataAttributes = removeDataAttributes;
|
|
104
|
-
exports.useRenderProps = useRenderProps;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var tagFieldStateContext = require('./tag-field-state-context.cjs');
|
|
7
|
-
var x = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
7
|
+
var x = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/x.cjs');
|
|
8
8
|
|
|
9
9
|
const TagFieldTagList = ({
|
|
10
10
|
classNames,
|
|
@@ -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');
|
|
12
9
|
var tagFieldItem = require('./tag-field-item.cjs');
|
|
13
10
|
var tagFieldList = require('./tag-field-list.cjs');
|
|
14
11
|
var tagFieldRoot = require('./tag-field-root.cjs');
|
|
15
12
|
var tagFieldTagList = require('./tag-field-tag-list.cjs');
|
|
16
13
|
var tagFieldTrigger = require('./tag-field-trigger.cjs');
|
|
17
|
-
var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
14
|
+
var chevronDown = require('../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/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 field = require('../field/field.cjs');
|
|
9
8
|
var textArea = require('../text-area/text-area.cjs');
|
|
9
|
+
var field = require('../field/field.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 field = require('../field/field.cjs');
|
|
9
8
|
var input = require('../input/input.cjs');
|
|
9
|
+
var field = require('../field/field.cjs');
|
|
10
10
|
|
|
11
11
|
function TextField({
|
|
12
12
|
label,
|
package/dist/esm/badge/badge.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { forwardRef, useMemo } from 'react';
|
|
5
5
|
import { useBadge } from './use-badge.js';
|
|
6
|
-
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
6
|
+
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
7
7
|
|
|
8
8
|
const Badge = forwardRef((props, ref) => {
|
|
9
9
|
const {
|
|
@@ -5,10 +5,10 @@ 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 CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
9
|
-
import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
8
|
+
import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
|
|
9
|
+
import Info from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/info.js';
|
|
10
10
|
import { Button } from '../button/button.js';
|
|
11
|
-
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
11
|
+
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
12
12
|
|
|
13
13
|
const i18nStrings = {
|
|
14
14
|
"en-SG": {
|
|
@@ -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
|
-
import { useRipple } from '../ripple/use-ripple.js';
|
|
10
8
|
import { Spinner } from '../spinner/spinner.js';
|
|
9
|
+
import { useRipple } from '../ripple/use-ripple.js';
|
|
10
|
+
import { Ripple } from '../ripple/ripple.js';
|
|
11
11
|
|
|
12
12
|
const Button = forwardRef(
|
|
13
13
|
({
|
|
@@ -8,8 +8,8 @@ import { AgnosticCalendarStateContext } from './agnostic-calendar-state-context.
|
|
|
8
8
|
import { CalendarMonthDaySelector } from './calendar-month-day-selector.js';
|
|
9
9
|
import { useCalendarStyleContext } from './calendar-style-context.js';
|
|
10
10
|
import { useLocalizedMonthYear } from './utils.js';
|
|
11
|
-
import ChevronRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
12
|
-
import ChevronLeft from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
11
|
+
import ChevronRight from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-right.js';
|
|
12
|
+
import ChevronLeft from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-left.js';
|
|
13
13
|
|
|
14
14
|
function CalendarHeader({ offsetMonths = 0 }) {
|
|
15
15
|
const { direction } = useLocale();
|
|
@@ -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
|
-
import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
10
|
-
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
8
|
+
import Minus from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/minus.js';
|
|
9
|
+
import Check from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/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';
|
|
10
8
|
import { mapPropsVariants } from '../system/utils.js';
|
|
11
9
|
import { ComboBoxVariantContext } from './combo-box-variant-context.js';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
10
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
11
|
+
import ChevronUp from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
|
|
12
|
+
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
13
|
+
import X from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/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,13 +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 { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
8
|
-
import { Popover } from '../popover/popover.js';
|
|
9
7
|
import { mapPropsVariants } from '../system/utils.js';
|
|
10
8
|
import { DateInput } from '../date-field/date-field.js';
|
|
11
|
-
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
9
|
+
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/calendar.js';
|
|
12
10
|
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
11
|
+
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
13
12
|
import { Button } from '../button/button.js';
|
|
13
|
+
import { Popover } from '../popover/popover.js';
|
|
14
14
|
|
|
15
15
|
function DatePicker(originalProps) {
|
|
16
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 { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
9
|
-
import { Popover } from '../popover/popover.js';
|
|
10
|
-
import { RangeCalendar } from '../range-calendar/range-calendar.js';
|
|
11
8
|
import { mapPropsVariants } from '../system/utils.js';
|
|
12
|
-
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
9
|
+
import Calendar from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/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';
|
|
13
12
|
import { DateInput } from '../date-field/date-field.js';
|
|
14
13
|
import { Button } from '../button/button.js';
|
|
14
|
+
import { Popover } from '../popover/popover.js';
|
|
15
15
|
|
|
16
16
|
function DateRangePicker(originalProps) {
|
|
17
17
|
const [
|
package/dist/esm/field/field.js
CHANGED
|
@@ -4,7 +4,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { Label as Label$1, Text, FieldError as FieldError$1, Group } from 'react-aria-components';
|
|
6
6
|
import { labelStyles, descriptionStyles, fieldErrorStyles, composeRenderProps, fieldGroupStyles } from '@opengovsg/oui-theme';
|
|
7
|
-
import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
7
|
+
import CircleAlert from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/circle-alert.js';
|
|
8
8
|
|
|
9
9
|
function Label({ size, className, ...props }) {
|
|
10
10
|
return /* @__PURE__ */ jsx(Label$1, { ...props, className: labelStyles({ className, size }) });
|
|
@@ -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';
|
|
16
|
-
import
|
|
14
|
+
import { useControllableState } from '../hooks/use-controllable-state.js';
|
|
15
|
+
import Upload from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/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(
|
|
@@ -5,7 +5,7 @@ import { useState, useEffect } from 'react';
|
|
|
5
5
|
import { fileInfoDropzoneStyles, cn } from '@opengovsg/oui-theme';
|
|
6
6
|
import { useFileDropzoneStateContext, useFileDropzoneStyleContext } from './contexts.js';
|
|
7
7
|
import { formatBytes } from './utils.js';
|
|
8
|
-
import Trash2 from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
8
|
+
import Trash2 from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/trash-2.js';
|
|
9
9
|
import { Button } from '../button/button.js';
|
|
10
10
|
|
|
11
11
|
const FileInfo = ({ file, imagePreview, classNames }) => {
|
|
@@ -5,10 +5,10 @@ import { useRef } from 'react';
|
|
|
5
5
|
import { useDisclosure, useButton, useFocusRing, mergeProps } from 'react-aria';
|
|
6
6
|
import { useDisclosureState } from 'react-stately';
|
|
7
7
|
import { govtBannerStyles, dataAttr, twMerge } from '@opengovsg/oui-theme';
|
|
8
|
-
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
9
|
-
import Landmark from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
10
|
-
import ExternalLink from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
11
|
-
import Lock from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.
|
|
8
|
+
import ChevronDown from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
9
|
+
import Landmark from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/landmark.js';
|
|
10
|
+
import ExternalLink from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/external-link.js';
|
|
11
|
+
import Lock from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.2.1/node_modules/lucide-react/dist/esm/icons/lock.js';
|
|
12
12
|
|
|
13
13
|
function GovtBanner({
|
|
14
14
|
environment,
|
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,15 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export { useControllableState } from './hooks/use-controllable-state.js';
|
|
3
|
-
export { GovtBanner } from './govt-banner/govt-banner.js';
|
|
4
|
-
export { Ripple } from './ripple/ripple.js';
|
|
5
|
-
export { useRipple } from './ripple/use-ripple.js';
|
|
6
2
|
export { Spinner } from './spinner/spinner.js';
|
|
7
3
|
export { useSpinner } from './spinner/use-spinner.js';
|
|
8
4
|
export { Toggle } from './toggle/toggle.js';
|
|
9
5
|
export { SkipNavLink } from './skip-nav-link/skip-nav-link.js';
|
|
10
|
-
export { Input } from './input/input.js';
|
|
11
6
|
export { TextField } from './text-field/text-field.js';
|
|
12
|
-
export { Description, FieldError, FieldErrorIcon, FieldGroup, Label } from './field/field.js';
|
|
13
7
|
export { TextArea } from './text-area/text-area.js';
|
|
14
8
|
export { TextAreaField } from './text-area-field/text-area-field.js';
|
|
15
9
|
export { TagField } from './tag-field/tag-field.js';
|
|
@@ -17,20 +11,15 @@ export { TagFieldItem } from './tag-field/tag-field-item.js';
|
|
|
17
11
|
export { Select } from './select/select.js';
|
|
18
12
|
export { SelectItem } from './select/select-item.js';
|
|
19
13
|
export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
|
|
20
|
-
export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
|
|
21
|
-
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
22
|
-
export { Popover } from './popover/popover.js';
|
|
23
14
|
export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs/tabs.js';
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export { PaginationItem } from './pagination/pagination-item.js';
|
|
27
|
-
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
28
|
-
export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './pagination/use-pagination.js';
|
|
29
|
-
export { FileDropzone } from './file-dropzone/file-dropzone.js';
|
|
30
|
-
export { FileInfo } from './file-dropzone/file-info.js';
|
|
31
|
-
export { formatBytes, formatErrorMessage } from './file-dropzone/utils.js';
|
|
32
|
-
export { NumberField } from './number-field/number-field.js';
|
|
15
|
+
export { useControllableState } from './hooks/use-controllable-state.js';
|
|
16
|
+
export { useDraggable } from './hooks/use-draggable.js';
|
|
33
17
|
export { Button } from './button/button.js';
|
|
18
|
+
export { GovtBanner } from './govt-banner/govt-banner.js';
|
|
19
|
+
export { Ripple } from './ripple/ripple.js';
|
|
20
|
+
export { useRipple } from './ripple/use-ripple.js';
|
|
21
|
+
export { Input } from './input/input.js';
|
|
22
|
+
export { Description, FieldError, FieldErrorIcon, FieldGroup, Label } from './field/field.js';
|
|
34
23
|
export { ComboBox, ComboBoxEmptyState } from './combo-box/combo-box.js';
|
|
35
24
|
export { ComboBoxFuzzy } from './combo-box/combo-box-fuzzy.js';
|
|
36
25
|
export { ComboBoxItem } from './combo-box/combo-box-item.js';
|
|
@@ -41,8 +30,26 @@ export { CalendarDate } from '@internationalized/date';
|
|
|
41
30
|
export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
|
|
42
31
|
export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
|
|
43
32
|
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
|
|
33
|
+
export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
|
|
34
|
+
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
35
|
+
export { Popover } from './popover/popover.js';
|
|
44
36
|
export { DateField, DateInput } from './date-field/date-field.js';
|
|
45
37
|
export { DatePicker } from './date-picker/date-picker.js';
|
|
46
38
|
export { DateRangePicker } from './date-range-picker/date-range-picker.js';
|
|
47
39
|
export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
|
|
48
40
|
export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
|
|
41
|
+
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
42
|
+
export { Pagination } from './pagination/pagination.js';
|
|
43
|
+
export { PaginationCursor } from './pagination/pagination-cursor.js';
|
|
44
|
+
export { PaginationItem } from './pagination/pagination-item.js';
|
|
45
|
+
export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './pagination/use-pagination.js';
|
|
46
|
+
export { FileDropzone } from './file-dropzone/file-dropzone.js';
|
|
47
|
+
export { FileInfo } from './file-dropzone/file-info.js';
|
|
48
|
+
export { formatBytes, formatErrorMessage } from './file-dropzone/utils.js';
|
|
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';
|