@opengovsg/oui 0.0.12 → 0.0.14
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 +4 -4
- package/dist/cjs/badge/use-badge.cjs +6 -6
- package/dist/cjs/banner/banner.cjs +4 -4
- package/dist/cjs/button/button.cjs +3 -3
- package/dist/cjs/calendar/calendar-bottom-content.cjs +2 -2
- package/dist/cjs/calendar/calendar-header.cjs +2 -2
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +2 -2
- package/dist/cjs/calendar/calendar.cjs +4 -4
- package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
- package/dist/cjs/calendar/utils.cjs +3 -3
- package/dist/cjs/checkbox/checkbox-group-style-context.cjs +16 -0
- package/dist/cjs/checkbox/checkbox.cjs +94 -0
- package/dist/cjs/checkbox/index.cjs +12 -0
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
- package/dist/cjs/combo-box/combo-box.cjs +3 -3
- package/dist/cjs/date-field/date-field.cjs +3 -3
- package/dist/cjs/date-picker/date-picker.cjs +6 -5
- package/dist/cjs/date-range-picker/date-range-picker.cjs +5 -5
- package/dist/cjs/govt-banner/govt-banner.cjs +27 -62
- package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
- package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
- package/dist/cjs/index.cjs +52 -35
- package/dist/cjs/input/input.cjs +2 -2
- package/dist/cjs/menu/menu.cjs +6 -6
- package/dist/cjs/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.cjs +45 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.cjs +21 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.cjs +72 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.cjs +60 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.cjs +210 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.cjs +100 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.cjs +152 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.cjs +676 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.cjs +160 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs +9 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs +9 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs +16 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs +9 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.cjs +11 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.cjs +10 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.cjs +12 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/Icon.cjs +4 -4
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +3 -3
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.cjs +22 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.cjs +23 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.cjs +19 -0
- package/dist/cjs/pagination/hooks/use-pagination.cjs +117 -0
- package/dist/cjs/pagination/index.cjs +17 -0
- package/dist/cjs/pagination/pagination-cursor.cjs +18 -0
- package/dist/cjs/pagination/pagination-item.cjs +18 -0
- package/dist/cjs/pagination/pagination.cjs +263 -0
- package/dist/cjs/pagination/use-pagination-item.cjs +87 -0
- package/dist/cjs/pagination/use-pagination.cjs +251 -0
- package/dist/cjs/range-calendar/range-calendar.cjs +7 -7
- package/dist/cjs/ripple/use-ripple.cjs +4 -4
- package/dist/cjs/select/select.cjs +3 -3
- package/dist/cjs/spinner/use-spinner.cjs +3 -3
- package/dist/cjs/system/react-utils/context.cjs +3 -3
- package/dist/cjs/system/react-utils/dom-props.cjs +186 -0
- package/dist/cjs/system/react-utils/filter-dom-props.cjs +46 -0
- package/dist/cjs/system/react-utils/index.cjs +2 -0
- package/dist/cjs/system/react-utils/refs.cjs +3 -3
- package/dist/cjs/system/utils.cjs +3 -3
- package/dist/cjs/tabs/tabs.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
- package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
- package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
- package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
- package/dist/cjs/tag-field/tag-field.cjs +2 -2
- package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
- package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
- package/dist/cjs/text-area/text-area.cjs +2 -2
- package/dist/cjs/toggle/toggle.cjs +3 -3
- package/dist/esm/banner/banner.js +1 -1
- package/dist/esm/checkbox/checkbox-group-style-context.js +13 -0
- package/dist/esm/checkbox/checkbox.js +91 -0
- package/dist/esm/checkbox/index.js +3 -0
- package/dist/esm/date-picker/date-picker.js +4 -3
- package/dist/esm/date-range-picker/date-range-picker.js +2 -2
- package/dist/esm/govt-banner/govt-banner.js +25 -60
- package/dist/esm/index.js +19 -12
- package/dist/esm/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.js +43 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.js +19 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.js +69 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.js +58 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.js +205 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.js +98 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.js +150 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.js +674 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.js +155 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +7 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js +7 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js +14 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js +7 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.js +9 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.js +8 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.js +10 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.js +17 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.js +18 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.js +14 -0
- package/dist/esm/pagination/hooks/use-pagination.js +114 -0
- package/dist/esm/pagination/index.js +6 -0
- package/dist/esm/pagination/pagination-cursor.js +16 -0
- package/dist/esm/pagination/pagination-item.js +16 -0
- package/dist/esm/pagination/pagination.js +261 -0
- package/dist/esm/pagination/use-pagination-item.js +85 -0
- package/dist/esm/pagination/use-pagination.js +248 -0
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/select/select.js +1 -1
- package/dist/esm/system/react-utils/dom-props.js +183 -0
- package/dist/esm/system/react-utils/filter-dom-props.js +44 -0
- package/dist/esm/system/react-utils/index.js +1 -0
- package/dist/types/badge/badge.d.ts +3 -1
- package/dist/types/badge/badge.d.ts.map +1 -1
- package/dist/types/badge/use-badge.d.ts +7 -48
- package/dist/types/badge/use-badge.d.ts.map +1 -1
- package/dist/types/checkbox/checkbox-group-style-context.d.ts +6 -0
- package/dist/types/checkbox/checkbox-group-style-context.d.ts.map +1 -0
- package/dist/types/checkbox/checkbox.d.ts +19 -0
- package/dist/types/checkbox/checkbox.d.ts.map +1 -0
- package/dist/types/checkbox/index.d.ts +3 -0
- package/dist/types/checkbox/index.d.ts.map +1 -0
- package/dist/types/govt-banner/govt-banner.d.ts.map +1 -1
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pagination/hooks/use-pagination.d.ts +51 -0
- package/dist/types/pagination/hooks/use-pagination.d.ts.map +1 -0
- package/dist/types/pagination/index.d.ts +7 -0
- package/dist/types/pagination/index.d.ts.map +1 -0
- package/dist/types/pagination/pagination-cursor.d.ts +9 -0
- package/dist/types/pagination/pagination-cursor.d.ts.map +1 -0
- package/dist/types/pagination/pagination-item.d.ts +5 -0
- package/dist/types/pagination/pagination-item.d.ts.map +1 -0
- package/dist/types/pagination/pagination.d.ts +5 -0
- package/dist/types/pagination/pagination.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination-item.d.ts +51 -0
- package/dist/types/pagination/use-pagination-item.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination.d.ts +353 -0
- package/dist/types/pagination/use-pagination.d.ts.map +1 -0
- package/dist/types/spinner/use-spinner.d.ts +8 -8
- package/dist/types/system/react-utils/context.d.ts.map +1 -1
- package/dist/types/system/react-utils/dom-props.d.ts +3 -0
- package/dist/types/system/react-utils/dom-props.d.ts.map +1 -0
- package/dist/types/system/react-utils/filter-dom-props.d.ts +39 -0
- package/dist/types/system/react-utils/filter-dom-props.d.ts.map +1 -0
- package/dist/types/system/react-utils/index.d.ts +1 -0
- package/dist/types/system/react-utils/index.d.ts.map +1 -1
- package/package.json +8 -6
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var react = require('react');
|
|
6
|
+
var $670gB$react = require('react');
|
|
7
7
|
var reactAria = require('react-aria');
|
|
8
8
|
var reactAriaComponents = require('react-aria-components');
|
|
9
9
|
var ouiTheme = require('@opengovsg/oui-theme');
|
|
@@ -20,12 +20,12 @@ const Toggle = ({
|
|
|
20
20
|
ouiTheme.toggleStyles.variantKeys
|
|
21
21
|
);
|
|
22
22
|
const slots = ouiTheme.toggleStyles(variantProps);
|
|
23
|
-
const clonedThumbIcon = react.useCallback(
|
|
23
|
+
const clonedThumbIcon = $670gB$react.useCallback(
|
|
24
24
|
(renderProps) => {
|
|
25
25
|
const baseProps = {
|
|
26
26
|
className: slots.thumbIcon({ className: classNames?.thumbIcon })
|
|
27
27
|
};
|
|
28
|
-
return typeof thumbIcon === "function" ? thumbIcon(reactAria.mergeProps(baseProps, renderProps)) : thumbIcon && react.cloneElement(thumbIcon, baseProps);
|
|
28
|
+
return typeof thumbIcon === "function" ? thumbIcon(reactAria.mergeProps(baseProps, renderProps)) : thumbIcon && $670gB$react.cloneElement(thumbIcon, baseProps);
|
|
29
29
|
},
|
|
30
30
|
[classNames?.thumbIcon, slots, thumbIcon]
|
|
31
31
|
);
|
|
@@ -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 = {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { createContext } from '../system/react-utils/context.js';
|
|
4
|
+
|
|
5
|
+
const [CheckboxGroupStyleContext, useCheckboxGroupStyleContext] = createContext({
|
|
6
|
+
name: "CheckboxGroupStyleContext",
|
|
7
|
+
strict: false,
|
|
8
|
+
defaultValue: {
|
|
9
|
+
size: "md"
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { Checkbox as Checkbox$1, composeRenderProps, Provider, CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
|
|
5
|
+
import { checkboxStyles, checkboxGroupStyles } from '@opengovsg/oui-theme';
|
|
6
|
+
import { Label, Description, FieldError } from '../field/field.js';
|
|
7
|
+
import { mapPropsVariants } from '../system/utils.js';
|
|
8
|
+
import { useCheckboxGroupStyleContext, CheckboxGroupStyleContext } from './checkbox-group-style-context.js';
|
|
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';
|
|
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';
|
|
11
|
+
|
|
12
|
+
const Checkbox = ({
|
|
13
|
+
classNames,
|
|
14
|
+
className,
|
|
15
|
+
...originalProps
|
|
16
|
+
}) => {
|
|
17
|
+
const [props, variants] = mapPropsVariants(
|
|
18
|
+
originalProps,
|
|
19
|
+
checkboxStyles.variantKeys
|
|
20
|
+
);
|
|
21
|
+
const { size } = useCheckboxGroupStyleContext();
|
|
22
|
+
const styles = checkboxStyles({ size, ...variants });
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Checkbox$1,
|
|
25
|
+
{
|
|
26
|
+
...props,
|
|
27
|
+
isDisabled: variants.isDisabled,
|
|
28
|
+
isInvalid: variants.isInvalid,
|
|
29
|
+
isSelected: variants.isSelected,
|
|
30
|
+
className: composeRenderProps(
|
|
31
|
+
className ?? classNames?.base,
|
|
32
|
+
(className2, renderProps) => styles.base({ ...renderProps, className: className2 })
|
|
33
|
+
),
|
|
34
|
+
children: ({ isSelected, isIndeterminate, ...renderProps }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
className: styles.box({
|
|
39
|
+
isSelected: isSelected || isIndeterminate,
|
|
40
|
+
...renderProps,
|
|
41
|
+
className: classNames?.box
|
|
42
|
+
}),
|
|
43
|
+
children: isIndeterminate ? /* @__PURE__ */ jsx(
|
|
44
|
+
Minus,
|
|
45
|
+
{
|
|
46
|
+
"aria-hidden": true,
|
|
47
|
+
className: styles.icon({ className: classNames?.icon })
|
|
48
|
+
}
|
|
49
|
+
) : isSelected ? /* @__PURE__ */ jsx(
|
|
50
|
+
Check,
|
|
51
|
+
{
|
|
52
|
+
"aria-hidden": true,
|
|
53
|
+
className: styles.icon({ className: classNames?.icon })
|
|
54
|
+
}
|
|
55
|
+
) : null
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
props.children
|
|
59
|
+
] })
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
function CheckboxGroup({
|
|
64
|
+
description,
|
|
65
|
+
errorMessage,
|
|
66
|
+
classNames,
|
|
67
|
+
size,
|
|
68
|
+
...props
|
|
69
|
+
}) {
|
|
70
|
+
const context = {
|
|
71
|
+
size
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ jsx(Provider, { values: [[CheckboxGroupStyleContext, context]], children: /* @__PURE__ */ jsxs(
|
|
74
|
+
CheckboxGroup$1,
|
|
75
|
+
{
|
|
76
|
+
...props,
|
|
77
|
+
className: composeRenderProps(
|
|
78
|
+
props.className ?? classNames?.base,
|
|
79
|
+
(className, renderProps) => checkboxGroupStyles({ ...renderProps, size, className })
|
|
80
|
+
),
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ jsx(Label, { size, className: classNames?.label, children: props.label }),
|
|
83
|
+
props.children,
|
|
84
|
+
description && /* @__PURE__ */ jsx(Description, { size, className: classNames?.description, children: description }),
|
|
85
|
+
/* @__PURE__ */ jsx(FieldError, { size, classNames: classNames?.error, children: errorMessage })
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
) });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { Checkbox, CheckboxGroup };
|
|
@@ -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 { Button } from '../button/button.js';
|
|
8
|
+
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
9
|
+
import '@internationalized/date';
|
|
10
|
+
import { DateInput } from '../date-field/date-field.js';
|
|
7
11
|
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
8
12
|
import { Popover } from '../popover/popover.js';
|
|
9
13
|
import { mapPropsVariants } from '../system/utils.js';
|
|
10
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
11
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';
|
|
12
|
-
import { Calendar as Calendar$1 } from '../calendar/calendar.js';
|
|
13
|
-
import { Button } from '../button/button.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 { Button } from '../button/button.js';
|
|
9
|
+
import { DateInput } from '../date-field/date-field.js';
|
|
8
10
|
import { Label, FieldGroup, Description, FieldError } from '../field/field.js';
|
|
9
11
|
import { Popover } from '../popover/popover.js';
|
|
10
12
|
import { RangeCalendar } from '../range-calendar/range-calendar.js';
|
|
11
13
|
import { mapPropsVariants } from '../system/utils.js';
|
|
12
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';
|
|
13
|
-
import { DateInput } from '../date-field/date-field.js';
|
|
14
|
-
import { Button } from '../button/button.js';
|
|
15
15
|
|
|
16
16
|
function DateRangePicker(originalProps) {
|
|
17
17
|
const [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useRef } from 'react';
|
|
5
|
-
import {
|
|
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
8
|
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';
|
|
@@ -10,54 +10,11 @@ import Landmark from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/no
|
|
|
10
10
|
import ExternalLink from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/external-link.js';
|
|
11
11
|
import Lock from '../node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/lock.js';
|
|
12
12
|
|
|
13
|
-
const i18nStrings = {
|
|
14
|
-
"en-SG": {
|
|
15
|
-
mainLabel: "A Singapore Government Agency Website",
|
|
16
|
-
identifyLabel: "How to identify",
|
|
17
|
-
environmentLabel: "[NOTE: THIS IS A {environment} WEBSITE]",
|
|
18
|
-
officialLinkHeader: "Official website links end with .gov.sg",
|
|
19
|
-
officialLinkContent: "Government agencies communicate via <boldThis>.gov.sg</boldThis> websites (e.g. go.gov.sg/open).",
|
|
20
|
-
officialLinkTrusted: "Trusted websites",
|
|
21
|
-
secureHeader: "Secure websites use HTTPS",
|
|
22
|
-
secureContent: "Look for a <boldThis>lock</boldThis> {icon} or https:// as an added precaution. Share sensitive information only on official, secure websites."
|
|
23
|
-
},
|
|
24
|
-
"zh-SG": {
|
|
25
|
-
mainLabel: "A Singapore Government Agency Website",
|
|
26
|
-
identifyLabel: "How to identify",
|
|
27
|
-
environmentLabel: "[NOTE: THIS IS A {environment} WEBSITE]",
|
|
28
|
-
officialLinkHeader: "Official website links end with .gov.sg",
|
|
29
|
-
officialLinkContent: "Government agencies communicate via <boldThis>.gov.sg</boldThis> websites (e.g. go.gov.sg/open).",
|
|
30
|
-
officialLinkTrusted: "Trusted websites",
|
|
31
|
-
secureHeader: "Secure websites use HTTPS",
|
|
32
|
-
secureContent: "Look for a <boldThis>lock</boldThis> {icon} or https:// as an added precaution. Share sensitive information only on official, secure websites."
|
|
33
|
-
},
|
|
34
|
-
"ms-SG": {
|
|
35
|
-
mainLabel: "A Singapore Government Agency Website",
|
|
36
|
-
identifyLabel: "How to identify",
|
|
37
|
-
environmentLabel: "[NOTE: THIS IS A {environment} WEBSITE]",
|
|
38
|
-
officialLinkHeader: "Official website links end with .gov.sg",
|
|
39
|
-
officialLinkContent: "Government agencies communicate via <boldThis>.gov.sg</boldThis> websites (e.g. go.gov.sg/open).",
|
|
40
|
-
officialLinkTrusted: "Trusted websites",
|
|
41
|
-
secureHeader: "Secure websites use HTTPS",
|
|
42
|
-
secureContent: "Look for a <boldThis>lock</boldThis> {icon} or https:// as an added precaution. Share sensitive information only on official, secure websites."
|
|
43
|
-
},
|
|
44
|
-
"ta-SG": {
|
|
45
|
-
mainLabel: "A Singapore Government Agency Website",
|
|
46
|
-
identifyLabel: "How to identify",
|
|
47
|
-
environmentLabel: "[NOTE: THIS IS A {environment} WEBSITE]",
|
|
48
|
-
officialLinkHeader: "Official website links end with .gov.sg",
|
|
49
|
-
officialLinkContent: "Government agencies communicate via <boldThis>.gov.sg</boldThis> websites (e.g. go.gov.sg/open).",
|
|
50
|
-
officialLinkTrusted: "Trusted websites",
|
|
51
|
-
secureHeader: "Secure websites use HTTPS",
|
|
52
|
-
secureContent: "Look for a <boldThis>lock</boldThis> {icon} or https:// as an added precaution. Share sensitive information only on official, secure websites."
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
13
|
function GovtBanner({
|
|
56
14
|
environment,
|
|
57
15
|
classNames,
|
|
58
16
|
...props
|
|
59
17
|
}) {
|
|
60
|
-
const formatMessage = useMessageFormatter(i18nStrings);
|
|
61
18
|
const state = useDisclosureState(props);
|
|
62
19
|
const panelRef = useRef(null);
|
|
63
20
|
const triggerRef = useRef(null);
|
|
@@ -104,10 +61,12 @@ function GovtBanner({
|
|
|
104
61
|
{
|
|
105
62
|
className: slots.mainContent({ className: classNames?.mainContent }),
|
|
106
63
|
children: [
|
|
107
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
108
|
-
environment ? /* @__PURE__ */
|
|
109
|
-
|
|
110
|
-
|
|
64
|
+
/* @__PURE__ */ jsx("span", { children: "A Singapore Government Agency Website" }),
|
|
65
|
+
environment ? /* @__PURE__ */ jsxs("b", { children: [
|
|
66
|
+
"[NOTE: THIS IS A ",
|
|
67
|
+
environment.toUpperCase(),
|
|
68
|
+
" WEBSITE]"
|
|
69
|
+
] }) : null,
|
|
111
70
|
/* @__PURE__ */ jsxs(
|
|
112
71
|
"button",
|
|
113
72
|
{
|
|
@@ -119,7 +78,7 @@ function GovtBanner({
|
|
|
119
78
|
type: "button",
|
|
120
79
|
...mergeProps(buttonProps, focusProps),
|
|
121
80
|
children: [
|
|
122
|
-
/* @__PURE__ */ jsx("span", { className: slots.link({ className: classNames?.link }), children:
|
|
81
|
+
/* @__PURE__ */ jsx("span", { className: slots.link({ className: classNames?.link }), children: "How to identify" }),
|
|
123
82
|
/* @__PURE__ */ jsx(
|
|
124
83
|
ChevronDown,
|
|
125
84
|
{
|
|
@@ -162,13 +121,13 @@ function GovtBanner({
|
|
|
162
121
|
className: slots.panelHeader({
|
|
163
122
|
className: classNames?.panelHeader
|
|
164
123
|
}),
|
|
165
|
-
children:
|
|
124
|
+
children: "Official website links end with .gov.sg"
|
|
166
125
|
}
|
|
167
126
|
),
|
|
168
127
|
/* @__PURE__ */ jsxs("article", { children: [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
128
|
+
"Government agencies communicate via ",
|
|
129
|
+
/* @__PURE__ */ jsx("b", { children: ".gov.sg" }),
|
|
130
|
+
" websites (e.g. go.gov.sg/open).",
|
|
172
131
|
" ",
|
|
173
132
|
/* @__PURE__ */ jsxs(
|
|
174
133
|
"a",
|
|
@@ -178,7 +137,7 @@ function GovtBanner({
|
|
|
178
137
|
rel: "noreferrer",
|
|
179
138
|
target: "_blank",
|
|
180
139
|
children: [
|
|
181
|
-
|
|
140
|
+
"Trusted websites",
|
|
182
141
|
/* @__PURE__ */ jsx(
|
|
183
142
|
ExternalLink,
|
|
184
143
|
{
|
|
@@ -224,12 +183,14 @@ function GovtBanner({
|
|
|
224
183
|
className: slots.panelHeader({
|
|
225
184
|
className: classNames?.panelHeader
|
|
226
185
|
}),
|
|
227
|
-
children:
|
|
186
|
+
children: "Secure websites use HTTPS"
|
|
228
187
|
}
|
|
229
188
|
),
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
|
|
232
|
-
|
|
189
|
+
/* @__PURE__ */ jsxs("article", { children: [
|
|
190
|
+
"Look for a ",
|
|
191
|
+
/* @__PURE__ */ jsx("b", { children: "lock" }),
|
|
192
|
+
" ",
|
|
193
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": true, children: [
|
|
233
194
|
"(",
|
|
234
195
|
/* @__PURE__ */ jsx(
|
|
235
196
|
Lock,
|
|
@@ -240,8 +201,12 @@ function GovtBanner({
|
|
|
240
201
|
}
|
|
241
202
|
),
|
|
242
203
|
")"
|
|
243
|
-
] })
|
|
244
|
-
|
|
204
|
+
] }),
|
|
205
|
+
" ",
|
|
206
|
+
"or ",
|
|
207
|
+
/* @__PURE__ */ jsx("b", { children: "https://" }),
|
|
208
|
+
" as an added precaution. Share sensitive information only on official, secure websites."
|
|
209
|
+
] })
|
|
245
210
|
]
|
|
246
211
|
}
|
|
247
212
|
)
|
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 { Button } from './button/button.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,26 +13,32 @@ export { TextField } from './text-field/text-field.js';
|
|
|
12
13
|
export { Description, FieldError, 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';
|
|
20
|
+
export { Banner } from './banner/banner.js';
|
|
15
21
|
export { TagField } from './tag-field/tag-field.js';
|
|
16
22
|
export { TagFieldItem } from './tag-field/tag-field-item.js';
|
|
17
23
|
export { Select } from './select/select.js';
|
|
18
24
|
export { SelectItem } from './select/select-item.js';
|
|
19
25
|
export { SelectVariantContext, useSelectVariantContext } from './select/select-variant-context.js';
|
|
26
|
+
export { Badge } from './badge/badge.js';
|
|
27
|
+
export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
|
|
28
|
+
export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
|
|
29
|
+
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
|
|
30
|
+
export { CalendarDate } from '@internationalized/date';
|
|
20
31
|
export { RangeCalendar, RangeCalendarCell, RangeCalendarStateWrapper } from './range-calendar/range-calendar.js';
|
|
21
32
|
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, MenuVariantContext, SubmenuTrigger, useMenuVariantContext } from './menu/menu.js';
|
|
22
33
|
export { Popover } from './popover/popover.js';
|
|
23
34
|
export { Tab, TabList, TabPanel, Tabs, TabsVariantContext, useTabsVariantContext } from './tabs/tabs.js';
|
|
35
|
+
export { DateField, DateInput } from './date-field/date-field.js';
|
|
24
36
|
export { DatePicker } from './date-picker/date-picker.js';
|
|
25
37
|
export { DateRangePicker } from './date-range-picker/date-range-picker.js';
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export { CalendarDate } from '@internationalized/date';
|
|
34
|
-
export { Calendar, CalendarStateWrapper } from './calendar/calendar.js';
|
|
35
|
-
export { CalendarStyleContext, useCalendarStyleContext } from './calendar/calendar-style-context.js';
|
|
36
|
-
export { getEraFormat, useGenerateLocalizedMonths, useGenerateLocalizedYears, useLocalizedMonthYear } from './calendar/utils.js';
|
|
37
|
-
export { DateField, DateInput } from './date-field/date-field.js';
|
|
38
|
+
export { Checkbox, CheckboxGroup } from './checkbox/checkbox.js';
|
|
39
|
+
export { CheckboxGroupStyleContext, useCheckboxGroupStyleContext } from './checkbox/checkbox-group-style-context.js';
|
|
40
|
+
export { Pagination } from './pagination/pagination.js';
|
|
41
|
+
export { PaginationCursor } from './pagination/pagination-cursor.js';
|
|
42
|
+
export { PaginationItem } from './pagination/pagination-item.js';
|
|
43
|
+
export { PaginationItemType } from './pagination/hooks/use-pagination.js';
|
|
44
|
+
export { CURSOR_TRANSITION_TIMEOUT, usePagination } from './pagination/use-pagination.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useFocus as $a1ea59d68270f0dd$export$f8168d8dd8fd66e6 } from '../../../../../@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.js';
|
|
2
|
+
import { isFocusVisible as $507fabe10e71c6fb$export$b9b3dfddab17db27, useFocusVisibleListener as $507fabe10e71c6fb$export$ec71b4b83ac08ec3 } from '../../../../../@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.js';
|
|
3
|
+
import { useFocusWithin as $9ab94262bd0047c7$export$420e68273165f4ec } from '../../../../../@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.js';
|
|
4
|
+
import { useRef, useState, useCallback } from 'react';
|
|
5
|
+
|
|
6
|
+
function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
7
|
+
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
|
|
8
|
+
let state = (useRef)({
|
|
9
|
+
isFocused: false,
|
|
10
|
+
isFocusVisible: autoFocus || ($507fabe10e71c6fb$export$b9b3dfddab17db27)()
|
|
11
|
+
});
|
|
12
|
+
let [isFocused, setFocused] = (useState)(false);
|
|
13
|
+
let [isFocusVisibleState, setFocusVisible] = (useState)(()=>state.current.isFocused && state.current.isFocusVisible);
|
|
14
|
+
let updateState = (useCallback)(()=>setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
|
|
15
|
+
let onFocusChange = (useCallback)((isFocused)=>{
|
|
16
|
+
state.current.isFocused = isFocused;
|
|
17
|
+
setFocused(isFocused);
|
|
18
|
+
updateState();
|
|
19
|
+
}, [
|
|
20
|
+
updateState
|
|
21
|
+
]);
|
|
22
|
+
($507fabe10e71c6fb$export$ec71b4b83ac08ec3)((isFocusVisible)=>{
|
|
23
|
+
state.current.isFocusVisible = isFocusVisible;
|
|
24
|
+
updateState();
|
|
25
|
+
}, [], {
|
|
26
|
+
isTextInput: isTextInput
|
|
27
|
+
});
|
|
28
|
+
let { focusProps: focusProps } = ($a1ea59d68270f0dd$export$f8168d8dd8fd66e6)({
|
|
29
|
+
isDisabled: within,
|
|
30
|
+
onFocusChange: onFocusChange
|
|
31
|
+
});
|
|
32
|
+
let { focusWithinProps: focusWithinProps } = ($9ab94262bd0047c7$export$420e68273165f4ec)({
|
|
33
|
+
isDisabled: !within,
|
|
34
|
+
onFocusWithinChange: onFocusChange
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
isFocused: isFocused,
|
|
38
|
+
isFocusVisible: isFocusVisibleState,
|
|
39
|
+
focusProps: within ? focusWithinProps : focusProps
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { $f7dceffc5ad7768b$export$4e328f61c538687f as useFocusRing };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import $670gB$react from 'react';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
const $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = ($670gB$react).createContext({
|
|
15
|
+
register: ()=>{}
|
|
16
|
+
});
|
|
17
|
+
$ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = 'PressResponderContext';
|
|
18
|
+
|
|
19
|
+
export { $ae1eeba8b9eafd08$export$5165eccb35aaadb5 as PressResponderContext };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { isIOS, getOwnerDocument, runAfterTransition } from '@react-aria/utils';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
// Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
|
|
15
|
+
// rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
|
|
16
|
+
let $14c0b72509d70225$var$state = 'default';
|
|
17
|
+
let $14c0b72509d70225$var$savedUserSelect = '';
|
|
18
|
+
let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
|
|
19
|
+
function $14c0b72509d70225$export$16a4697467175487(target) {
|
|
20
|
+
if ((isIOS)()) {
|
|
21
|
+
if ($14c0b72509d70225$var$state === 'default') {
|
|
22
|
+
const documentObject = (getOwnerDocument)(target);
|
|
23
|
+
$14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
|
|
24
|
+
documentObject.documentElement.style.webkitUserSelect = 'none';
|
|
25
|
+
}
|
|
26
|
+
$14c0b72509d70225$var$state = 'disabled';
|
|
27
|
+
} else if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
28
|
+
// If not iOS, store the target's original user-select and change to user-select: none
|
|
29
|
+
// Ignore state since it doesn't apply for non iOS
|
|
30
|
+
let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
|
|
31
|
+
$14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]);
|
|
32
|
+
target.style[property] = 'none';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
|
|
36
|
+
if ((isIOS)()) {
|
|
37
|
+
// If the state is already default, there's nothing to do.
|
|
38
|
+
// If it is restoring, then there's no need to queue a second restore.
|
|
39
|
+
if ($14c0b72509d70225$var$state !== 'disabled') return;
|
|
40
|
+
$14c0b72509d70225$var$state = 'restoring';
|
|
41
|
+
// There appears to be a delay on iOS where selection still might occur
|
|
42
|
+
// after pointer up, so wait a bit before removing user-select.
|
|
43
|
+
setTimeout(()=>{
|
|
44
|
+
// Wait for any CSS transitions to complete so we don't recompute style
|
|
45
|
+
// for the whole page in the middle of the animation and cause jank.
|
|
46
|
+
(runAfterTransition)(()=>{
|
|
47
|
+
// Avoid race conditions
|
|
48
|
+
if ($14c0b72509d70225$var$state === 'restoring') {
|
|
49
|
+
const documentObject = (getOwnerDocument)(target);
|
|
50
|
+
if (documentObject.documentElement.style.webkitUserSelect === 'none') documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || '';
|
|
51
|
+
$14c0b72509d70225$var$savedUserSelect = '';
|
|
52
|
+
$14c0b72509d70225$var$state = 'default';
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}, 300);
|
|
56
|
+
} else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
|
|
57
|
+
// Ignore state since it doesn't apply for non iOS
|
|
58
|
+
{
|
|
59
|
+
if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
|
|
60
|
+
let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
|
|
61
|
+
let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
|
|
62
|
+
if (target.style[property] === 'none') target.style[property] = targetOldUserSelect;
|
|
63
|
+
if (target.getAttribute('style') === '') target.removeAttribute('style');
|
|
64
|
+
$14c0b72509d70225$var$modifiedElementMap.delete(target);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { $14c0b72509d70225$export$16a4697467175487 as disableTextSelection, $14c0b72509d70225$export$b0d6fa1ab32e3295 as restoreTextSelection };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useSyntheticBlurEvent as $8a9cb279dc87e130$export$715c682d09d639cc } from './utils.js';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { getOwnerDocument, getActiveElement, getEventTarget } from '@react-aria/utils';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
16
|
+
// Original licensing for the following can be found in the
|
|
17
|
+
// NOTICE file in the root directory of this source tree.
|
|
18
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
23
|
+
let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
|
|
24
|
+
const onBlur = (useCallback)((e)=>{
|
|
25
|
+
if (e.target === e.currentTarget) {
|
|
26
|
+
if (onBlurProp) onBlurProp(e);
|
|
27
|
+
if (onFocusChange) onFocusChange(false);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
onBlurProp,
|
|
32
|
+
onFocusChange
|
|
33
|
+
]);
|
|
34
|
+
const onSyntheticFocus = ($8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
35
|
+
const onFocus = (useCallback)((e)=>{
|
|
36
|
+
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
37
|
+
// focus handler already moved focus somewhere else.
|
|
38
|
+
const ownerDocument = (getOwnerDocument)(e.target);
|
|
39
|
+
const activeElement = ownerDocument ? (getActiveElement)(ownerDocument) : (getActiveElement)();
|
|
40
|
+
if (e.target === e.currentTarget && activeElement === (getEventTarget)(e.nativeEvent)) {
|
|
41
|
+
if (onFocusProp) onFocusProp(e);
|
|
42
|
+
if (onFocusChange) onFocusChange(true);
|
|
43
|
+
onSyntheticFocus(e);
|
|
44
|
+
}
|
|
45
|
+
}, [
|
|
46
|
+
onFocusChange,
|
|
47
|
+
onFocusProp,
|
|
48
|
+
onSyntheticFocus
|
|
49
|
+
]);
|
|
50
|
+
return {
|
|
51
|
+
focusProps: {
|
|
52
|
+
onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
|
|
53
|
+
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { $a1ea59d68270f0dd$export$f8168d8dd8fd66e6 as useFocus };
|