@digdir/designsystemet-react 1.0.0-next.44 → 1.0.0-next.45-test-react19
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/components/Combobox/Combobox.js +2 -2
- package/dist/cjs/components/Combobox/internal/ComboboxChips.js +1 -1
- package/dist/cjs/{utilities/hooks → components/Combobox}/useFormField/useFormField.js +1 -1
- package/dist/cjs/components/Field/Field.js +2 -2
- package/dist/cjs/components/Pagination/usePagination.js +8 -8
- package/dist/cjs/components/Popover/PopoverTrigger.js +7 -3
- package/dist/cjs/components/Table/TableHeaderCell.js +1 -1
- package/dist/cjs/components/Tag/Tag.js +3 -3
- package/dist/cjs/components/Tooltip/Tooltip.js +65 -50
- package/dist/cjs/index.js +22 -16
- package/dist/cjs/utilities/RovingFocus/RovingFocusRoot.js +1 -1
- package/dist/cjs/utilities/hooks/useCheckboxGroup/useCheckboxGroup.js +121 -0
- package/dist/cjs/utilities/hooks/useMediaQuery/useMediaQuery.js +49 -0
- package/dist/cjs/utilities/hooks/useRadioGroup/useRadioGroup.js +99 -0
- package/dist/esm/components/Combobox/Combobox.js +2 -2
- package/dist/esm/components/Combobox/internal/ComboboxChips.js +1 -1
- package/dist/esm/{utilities/hooks → components/Combobox}/useFormField/useFormField.js +1 -1
- package/dist/esm/components/Field/Field.js +2 -2
- package/dist/esm/components/Pagination/usePagination.js +8 -8
- package/dist/esm/components/Popover/PopoverTrigger.js +7 -3
- package/dist/esm/components/Table/TableHeaderCell.js +1 -1
- package/dist/esm/components/Tag/Tag.js +3 -3
- package/dist/esm/components/Tooltip/Tooltip.js +66 -51
- package/dist/esm/index.js +10 -7
- package/dist/esm/utilities/RovingFocus/RovingFocusRoot.js +1 -1
- package/dist/esm/utilities/hooks/useCheckboxGroup/useCheckboxGroup.js +119 -0
- package/dist/esm/utilities/hooks/useMediaQuery/useMediaQuery.js +47 -0
- package/dist/esm/utilities/hooks/useRadioGroup/useRadioGroup.js +97 -0
- package/dist/types/components/Avatar/Avatar.d.ts +1 -12
- package/dist/types/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Badge/Badge.d.ts +1 -10
- package/dist/types/components/Badge/Badge.d.ts.map +1 -1
- package/dist/types/components/Badge/index.d.ts +1 -2
- package/dist/types/components/Badge/index.d.ts.map +1 -1
- package/dist/types/components/Breadcrumbs/BreadcrumbsLink.d.ts +1 -2
- package/dist/types/components/Breadcrumbs/BreadcrumbsLink.d.ts.map +1 -1
- package/dist/types/components/Breadcrumbs/index.d.ts +1 -2
- package/dist/types/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts +1 -10
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/Card/Card.d.ts +2 -3
- package/dist/types/components/Card/Card.d.ts.map +1 -1
- package/dist/types/components/Card/index.d.ts +1 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +0 -5
- package/dist/types/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Chip/Chips.d.ts +4 -8
- package/dist/types/components/Chip/Chips.d.ts.map +1 -1
- package/dist/types/components/Chip/index.d.ts +4 -20
- package/dist/types/components/Chip/index.d.ts.map +1 -1
- package/dist/types/components/Combobox/Combobox.d.ts +24 -7
- package/dist/types/components/Combobox/Combobox.d.ts.map +1 -1
- package/dist/types/components/Combobox/ComboboxContext.d.ts +2 -2
- package/dist/types/components/Combobox/ComboboxContext.d.ts.map +1 -1
- package/dist/types/components/Combobox/Option/Option.d.ts +2 -2
- package/dist/types/components/Combobox/Option/Option.d.ts.map +1 -1
- package/dist/types/components/Combobox/Option/useComboboxOption.d.ts +6 -4
- package/dist/types/components/Combobox/Option/useComboboxOption.d.ts.map +1 -1
- package/dist/types/components/Combobox/internal/ComboboxError.d.ts +1 -1
- package/dist/types/components/Combobox/internal/ComboboxError.d.ts.map +1 -1
- package/dist/types/components/Combobox/internal/ComboboxLabel.d.ts +1 -1
- package/dist/types/components/Combobox/internal/ComboboxLabel.d.ts.map +1 -1
- package/dist/types/components/Combobox/useFloatingCombobox.d.ts +2 -2
- package/dist/types/components/Combobox/useFloatingCombobox.d.ts.map +1 -1
- package/dist/types/components/{Fieldset → Combobox/useFormField}/FieldsetContext.d.ts +1 -1
- package/dist/types/components/Combobox/useFormField/FieldsetContext.d.ts.map +1 -0
- package/dist/types/components/Combobox/useFormField/useFormField.d.ts.map +1 -0
- package/dist/types/components/Details/Details.d.ts +10 -2
- package/dist/types/components/Details/Details.d.ts.map +1 -1
- package/dist/types/components/Dropdown/Dropdown.d.ts +1 -8
- package/dist/types/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/types/components/Dropdown/DropdownHeading.d.ts +1 -1
- package/dist/types/components/Dropdown/DropdownTrigger.d.ts +1 -8
- package/dist/types/components/Dropdown/DropdownTrigger.d.ts.map +1 -1
- package/dist/types/components/Dropdown/index.d.ts +3 -11
- package/dist/types/components/Dropdown/index.d.ts.map +1 -1
- package/dist/types/components/ErrorSummary/ErrorSummaryHeading.d.ts +1 -1
- package/dist/types/components/ErrorSummary/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts.map +1 -1
- package/dist/types/components/Fieldset/FieldsetDescription.d.ts +1 -1
- package/dist/types/components/Fieldset/index.d.ts +1 -1
- package/dist/types/components/Heading/Heading.d.ts +2 -2
- package/dist/types/components/Heading/Heading.d.ts.map +1 -1
- package/dist/types/components/Input/Input.d.ts +1 -12
- package/dist/types/components/Input/Input.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +1 -12
- package/dist/types/components/Link/Link.d.ts.map +1 -1
- package/dist/types/components/Modal/ModalTrigger.d.ts +2 -5
- package/dist/types/components/Modal/ModalTrigger.d.ts.map +1 -1
- package/dist/types/components/Modal/ModalTriggerContext.d.ts +1 -1
- package/dist/types/components/Modal/ModalTriggerContext.d.ts.map +1 -1
- package/dist/types/components/Modal/index.d.ts +2 -5
- package/dist/types/components/Modal/index.d.ts.map +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +1 -10
- package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/types/components/Pagination/index.d.ts +1 -2
- package/dist/types/components/Pagination/index.d.ts.map +1 -1
- package/dist/types/components/Pagination/usePagination.d.ts +1 -1
- package/dist/types/components/Pagination/usePagination.d.ts.map +1 -1
- package/dist/types/components/Paragraph/Paragraph.d.ts +2 -2
- package/dist/types/components/Paragraph/Paragraph.d.ts.map +1 -1
- package/dist/types/components/Popover/Popover.d.ts +1 -10
- package/dist/types/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/components/Popover/PopoverTrigger.d.ts +8 -8
- package/dist/types/components/Popover/PopoverTrigger.d.ts.map +1 -1
- package/dist/types/components/Radio/Radio.d.ts +0 -5
- package/dist/types/components/Radio/Radio.d.ts.map +1 -1
- package/dist/types/components/Search/SearchButton.d.ts +1 -2
- package/dist/types/components/Search/SearchButton.d.ts.map +1 -1
- package/dist/types/components/Search/index.d.ts +1 -2
- package/dist/types/components/Search/index.d.ts.map +1 -1
- package/dist/types/components/Spinner/Spinner.d.ts +1 -6
- package/dist/types/components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/types/components/Switch/Switch.d.ts +0 -10
- package/dist/types/components/Switch/Switch.d.ts.map +1 -1
- package/dist/types/components/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/types/components/Tabs/Tabs.d.ts +1 -8
- package/dist/types/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/types/components/Tabs/index.d.ts +1 -2
- package/dist/types/components/Tabs/index.d.ts.map +1 -1
- package/dist/types/components/Tag/Tag.d.ts +3 -17
- package/dist/types/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/components/ToggleGroup/ToggleGroup.d.ts +1 -8
- package/dist/types/components/ToggleGroup/ToggleGroup.d.ts.map +1 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +3 -23
- package/dist/types/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +0 -1
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +6 -11
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utilities/RovingFocus/useRovingFocus.d.ts +14 -1
- package/dist/types/utilities/RovingFocus/useRovingFocus.d.ts.map +1 -1
- package/dist/types/utilities/hooks/index.d.ts +2 -3
- package/dist/types/utilities/hooks/index.d.ts.map +1 -1
- package/dist/types/utilities/hooks/useCheckboxGroup/useCheckboxGroup.d.ts +6 -325
- package/dist/types/utilities/hooks/useCheckboxGroup/useCheckboxGroup.d.ts.map +1 -1
- package/dist/types/utilities/hooks/useRadioGroup/useRadioGroup.d.ts +13 -327
- package/dist/types/utilities/hooks/useRadioGroup/useRadioGroup.d.ts.map +1 -1
- package/dist/types/utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.d.ts +1 -1
- package/dist/types/utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cjs/components/HelpText/HelpText.js +0 -13
- package/dist/esm/components/HelpText/HelpText.js +0 -11
- package/dist/types/components/Fieldset/FieldsetContext.d.ts.map +0 -1
- package/dist/types/components/HelpText/HelpText.d.ts +0 -27
- package/dist/types/components/HelpText/HelpText.d.ts.map +0 -1
- package/dist/types/components/HelpText/index.d.ts +0 -3
- package/dist/types/components/HelpText/index.d.ts.map +0 -1
- package/dist/types/components/Textarea/useTextarea.d.ts +0 -10
- package/dist/types/components/Textarea/useTextarea.d.ts.map +0 -1
- package/dist/types/utilities/hooks/useFormField/useFormField.d.ts.map +0 -1
- package/dist/types/utilities/hooks/usePrevious/usePrevious.d.ts +0 -2
- package/dist/types/utilities/hooks/usePrevious/usePrevious.d.ts.map +0 -1
- /package/dist/cjs/components/{Fieldset → Combobox/useFormField}/FieldsetContext.js +0 -0
- /package/dist/esm/components/{Fieldset → Combobox/useFormField}/FieldsetContext.js +0 -0
- /package/dist/types/{utilities/hooks → components/Combobox}/useFormField/useFormField.d.ts +0 -0
|
@@ -6,7 +6,7 @@ var react$1 = require('@floating-ui/react');
|
|
|
6
6
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
7
7
|
var cl = require('clsx/lite');
|
|
8
8
|
var react = require('react');
|
|
9
|
-
var useFormField = require('
|
|
9
|
+
var useFormField = require('./useFormField/useFormField.js');
|
|
10
10
|
var ComboboxContext = require('./ComboboxContext.js');
|
|
11
11
|
var ComboboxIdContext = require('./ComboboxIdContext.js');
|
|
12
12
|
var Custom = require('./Custom.js');
|
|
@@ -178,7 +178,7 @@ const ComboboxComponent = react.forwardRef(({ value, initialValue = [], onValueC
|
|
|
178
178
|
setListRef: (index, node) => {
|
|
179
179
|
listRef.current[index] = node;
|
|
180
180
|
},
|
|
181
|
-
}, children: [jsxRuntime.jsxs("div", { className: cl('ds-combobox', `ds-combobox--${size}`, disabled && 'ds-combobox__disabled', className), style: style, ref: portalRef, children: [name && (jsxRuntime.jsx(ComboboxNative, { name: name, selectedOptions: selectedOptions, multiple: multiple })), jsxRuntime.jsx(ComboboxLabel, { label: label, description: description, size: size, readOnly: readOnly, hideLabel: hideLabel, formFieldProps: formFieldProps }), jsxRuntime.jsx(ComboboxInput, { ...omit.omit(['inputValue'], rest), hideClearButton: hideClearButton, listId: context.floatingId, error: error, hideChips: hideChips, handleKeyDown: handleKeyDown, "aria-busy": loading }), jsxRuntime.jsx(ComboboxError, { size: size, error: error, formFieldProps: formFieldProps })] }), open && (jsxRuntime.jsx(react$1.FloatingPortal, { root: portal ? null : portalRef, children: jsxRuntime.jsx(react$1.FloatingFocusManager, { context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: jsxRuntime.jsxs("div", { "aria-labelledby": formFieldProps.inputProps.id, "aria-autocomplete": 'list', tabIndex: -1, ...getFloatingProps({
|
|
181
|
+
}, children: [jsxRuntime.jsxs("div", { className: cl('ds-combobox', `ds-combobox--${size}`, disabled && 'ds-combobox__disabled', className), style: style, ref: portalRef, children: [name && (jsxRuntime.jsx(ComboboxNative, { name: name, selectedOptions: selectedOptions, multiple: multiple })), jsxRuntime.jsx(ComboboxLabel, { label: label, description: description, size: size, readOnly: readOnly, hideLabel: hideLabel, formFieldProps: formFieldProps }), jsxRuntime.jsx(ComboboxInput, { ...omit.omit(['inputValue'], rest), hideClearButton: hideClearButton, listId: context.floatingId || '', error: error, hideChips: hideChips, handleKeyDown: handleKeyDown, "aria-busy": loading }), jsxRuntime.jsx(ComboboxError, { size: size, error: error, formFieldProps: formFieldProps })] }), open && (jsxRuntime.jsx(react$1.FloatingPortal, { root: portal ? null : portalRef, children: jsxRuntime.jsx(react$1.FloatingFocusManager, { context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: jsxRuntime.jsxs("div", { "aria-labelledby": formFieldProps.inputProps.id, "aria-autocomplete": 'list', tabIndex: -1, ...getFloatingProps({
|
|
182
182
|
ref: refs.setFloating,
|
|
183
183
|
style: {
|
|
184
184
|
...floatingStyles,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var cl = require('clsx/lite');
|
|
5
5
|
var react = require('react');
|
|
6
|
-
var FieldsetContext = require('
|
|
6
|
+
var FieldsetContext = require('./FieldsetContext.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Handles props and their state for various form-fields in context with Fieldset
|
|
@@ -7,11 +7,11 @@ var cl = require('clsx/lite');
|
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var fieldObserver = require('./fieldObserver.js');
|
|
9
9
|
|
|
10
|
-
const Field = react.forwardRef(function Field({ className, ...rest }, ref) {
|
|
10
|
+
const Field = react.forwardRef(function Field({ className, position, ...rest }, ref) {
|
|
11
11
|
const fieldRef = react.useRef(null);
|
|
12
12
|
const mergedRefs = react$1.useMergeRefs([fieldRef, ref]);
|
|
13
13
|
react.useEffect(() => fieldObserver.fieldObserver(fieldRef.current), []);
|
|
14
|
-
return (jsxRuntime.jsx("div", { className: cl('ds-field', className), ref: mergedRefs, ...rest }));
|
|
14
|
+
return (jsxRuntime.jsx("div", { className: cl('ds-field', className), "data-position": position, ref: mergedRefs, ...rest }));
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
exports.Field = Field;
|
|
@@ -28,15 +28,15 @@ const usePagination = ({ currentPage = 1, setCurrentPage, onChange, totalPages,
|
|
|
28
28
|
return {
|
|
29
29
|
/** Number of steps */
|
|
30
30
|
pages: getSteps(currentPage, totalPages, showPages).map((page, index) => ({
|
|
31
|
-
page: page || '',
|
|
31
|
+
page: page || 'ellipsis',
|
|
32
32
|
itemKey: page ? `page-${page}` : `ellipsis-${index}`, // React key utility
|
|
33
|
-
buttonProps:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
buttonProps: (page
|
|
34
|
+
? {
|
|
35
|
+
'aria-current': page === currentPage ? 'page' : undefined,
|
|
36
|
+
onClick: handleClick(page),
|
|
37
|
+
variant: page === currentPage ? 'primary' : 'tertiary',
|
|
38
|
+
}
|
|
39
|
+
: null),
|
|
40
40
|
})),
|
|
41
41
|
/** Properties to spread on Pagination.Button used for previous naviagation */
|
|
42
42
|
prevButtonProps: {
|
|
@@ -7,10 +7,14 @@ var react = require('react');
|
|
|
7
7
|
var Button = require('../Button/Button.js');
|
|
8
8
|
var PopoverTriggerContext = require('./PopoverTriggerContext.js');
|
|
9
9
|
|
|
10
|
-
const PopoverTrigger = react.forwardRef(function PopoverTrigger({ id, asChild, ...rest }, ref) {
|
|
10
|
+
const PopoverTrigger = react.forwardRef(function PopoverTrigger({ id, inline, asChild, ...rest }, ref) {
|
|
11
11
|
const { popoverId } = react.useContext(PopoverTriggerContext.Context);
|
|
12
|
-
const Component = asChild ? reactSlot.Slot : Button.Button;
|
|
13
|
-
return jsxRuntime.jsx(Component, { ref: ref, popovertarget: popoverId, ...
|
|
12
|
+
const Component = asChild ? reactSlot.Slot : inline ? 'button' : Button.Button;
|
|
13
|
+
return (jsxRuntime.jsx(Component, { ref: ref, popovertarget: popoverId, ...(inline
|
|
14
|
+
? {
|
|
15
|
+
'data-popover': 'inline',
|
|
16
|
+
}
|
|
17
|
+
: {}), ...rest }));
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
exports.PopoverTrigger = PopoverTrigger;
|
|
@@ -5,7 +5,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
|
|
7
7
|
const TableHeaderCell = react.forwardRef(function TableHeaderCell({ sort, children, ...rest }, ref) {
|
|
8
|
-
return (jsxRuntime.jsx("th", { "aria-sort": sort, ref: ref, ...rest, children: sort ?
|
|
8
|
+
return (jsxRuntime.jsx("th", { "aria-sort": sort, ref: ref, ...rest, children: sort ? jsxRuntime.jsx("button", { type: 'button', children: children }) : children }));
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
exports.TableHeaderCell = TableHeaderCell;
|
|
@@ -8,10 +8,10 @@ var react = require('react');
|
|
|
8
8
|
/**
|
|
9
9
|
* Use `Tag` to display a small piece of information.
|
|
10
10
|
* @example
|
|
11
|
-
* <Tag
|
|
11
|
+
* <Tag>Success</Tag>
|
|
12
12
|
*/
|
|
13
|
-
const Tag = react.forwardRef(function Tag({
|
|
14
|
-
return
|
|
13
|
+
const Tag = react.forwardRef(function Tag({ className, ...rest }, ref) {
|
|
14
|
+
return jsxRuntime.jsx("span", { className: cl('ds-tag', className), ref: ref, ...rest });
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
exports.Tag = Tag;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var
|
|
5
|
+
var dom = require('@floating-ui/dom');
|
|
6
6
|
var reactSlot = require('@radix-ui/react-slot');
|
|
7
7
|
var cl = require('clsx/lite');
|
|
8
8
|
var react = require('react');
|
|
9
|
+
var react$1 = require('@floating-ui/react');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Tooltip component that displays a small piece of information when hovering or focusing on an element.
|
|
@@ -19,46 +20,61 @@ var react = require('react');
|
|
|
19
20
|
* Hover me
|
|
20
21
|
* </Tooltip>
|
|
21
22
|
*/
|
|
22
|
-
const Tooltip = react.forwardRef(function Tooltip({ children, content, placement = 'top',
|
|
23
|
-
const
|
|
24
|
-
const internalOpen =
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
23
|
+
const Tooltip = react.forwardRef(function Tooltip({ id, children, content, placement = 'top', open, className, ...rest }, ref) {
|
|
24
|
+
const randomTooltipId = react.useId();
|
|
25
|
+
const [internalOpen, setInternalOpen] = react.useState(false);
|
|
26
|
+
const triggerRef = react.useRef(null);
|
|
27
|
+
const tooltipRef = react.useRef(null);
|
|
28
|
+
const mergedRefs = react$1.useMergeRefs([tooltipRef, ref]);
|
|
29
|
+
const controlledOpen = open ?? internalOpen;
|
|
30
|
+
const setOpen = () => {
|
|
31
|
+
setInternalOpen(true);
|
|
32
|
+
};
|
|
33
|
+
const setClose = () => {
|
|
34
|
+
setInternalOpen(false);
|
|
35
|
+
};
|
|
36
|
+
// Position with floating-ui
|
|
37
|
+
react.useEffect(() => {
|
|
38
|
+
const tooltip = tooltipRef.current;
|
|
39
|
+
const trigger = triggerRef.current;
|
|
40
|
+
tooltip?.togglePopover?.(controlledOpen);
|
|
41
|
+
if (tooltip)
|
|
42
|
+
tooltip.style.opacity = controlledOpen ? '1' : '0';
|
|
43
|
+
if (tooltip && trigger && controlledOpen) {
|
|
44
|
+
return dom.autoUpdate(trigger, tooltip, () => {
|
|
45
|
+
dom.computePosition(trigger, tooltip, {
|
|
46
|
+
placement,
|
|
47
|
+
strategy: 'fixed',
|
|
48
|
+
middleware: [
|
|
49
|
+
dom.offset((data) => {
|
|
50
|
+
// get pseudo element arrow size
|
|
51
|
+
const styles = getComputedStyle(data.elements.floating, '::before');
|
|
52
|
+
return parseFloat(styles.height);
|
|
53
|
+
}),
|
|
54
|
+
dom.flip({
|
|
55
|
+
fallbackAxisSideDirection: 'start',
|
|
56
|
+
}),
|
|
57
|
+
dom.shift(),
|
|
58
|
+
arrowPseudoElement,
|
|
59
|
+
],
|
|
60
|
+
}).then(({ x, y }) => {
|
|
61
|
+
tooltip.style.translate = `${x}px ${y}px`;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, [controlledOpen, placement]);
|
|
66
|
+
/* Add listener for ESC to dismiss */
|
|
67
|
+
react.useEffect(() => {
|
|
68
|
+
const handleKeyDown = (event) => {
|
|
69
|
+
if (event.key === 'Escape') {
|
|
70
|
+
setInternalOpen(false);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
74
|
+
return () => {
|
|
75
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
62
78
|
/* If children is only a string, make a span */
|
|
63
79
|
const ChildContainer = typeof children === 'string' ? 'span' : reactSlot.Slot;
|
|
64
80
|
/* Make sure it is valid */
|
|
@@ -66,13 +82,12 @@ const Tooltip = react.forwardRef(function Tooltip({ children, content, placement
|
|
|
66
82
|
console.error('<Tooltip> children needs to be a single ReactElement that can receive a ref and not: <Fragment/> | <></>');
|
|
67
83
|
return null;
|
|
68
84
|
}
|
|
69
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ChildContainer, {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}), children: content }) }))] }));
|
|
85
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ChildContainer, { ref: triggerRef, popovertarget: id ?? randomTooltipId,
|
|
86
|
+
// We set this to not close on click, since it should always show on hover
|
|
87
|
+
// @ts-ignore @types/react-dom does not understand popovertargetaction yet
|
|
88
|
+
popovertargetaction: 'show', onMouseEnter: setOpen, onMouseLeave: setClose, onFocus: setOpen, onBlur: setClose, children: children }), jsxRuntime.jsx("div", { ref: mergedRefs, role: 'tooltip', className: cl('ds-tooltip', className), id: id ?? randomTooltipId,
|
|
89
|
+
// @ts-ignore @types/react-dom does not understand popover yet
|
|
90
|
+
popover: 'manual', ...rest, children: content })] }));
|
|
76
91
|
});
|
|
77
92
|
const arrowPseudoElement = {
|
|
78
93
|
name: 'ArrowPseudoElement',
|
|
@@ -94,8 +109,8 @@ const arrowPseudoElement = {
|
|
|
94
109
|
arrowX = '100%';
|
|
95
110
|
break;
|
|
96
111
|
}
|
|
97
|
-
elements.floating.style.setProperty('--
|
|
98
|
-
elements.floating.style.setProperty('--
|
|
112
|
+
elements.floating.style.setProperty('--dsc-tooltip-arrow-x', arrowX);
|
|
113
|
+
elements.floating.style.setProperty('--dsc-tooltip-arrow-y', arrowY);
|
|
99
114
|
return data;
|
|
100
115
|
},
|
|
101
116
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var useSynchronizedAnimation = require('./utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.js');
|
|
5
|
-
var useIsomorphicLayoutEffect = require('./utilities/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js');
|
|
6
|
-
var RovingFocusRoot = require('./utilities/RovingFocus/RovingFocusRoot.js');
|
|
7
|
-
var useRovingFocus = require('./utilities/RovingFocus/useRovingFocus.js');
|
|
8
|
-
var RovingFocusItem = require('./utilities/RovingFocus/RovingFocusItem.js');
|
|
9
|
-
var omit = require('./utilities/omit/omit.js');
|
|
10
4
|
var Avatar = require('./components/Avatar/Avatar.js');
|
|
11
5
|
var Button = require('./components/Button/Button.js');
|
|
12
6
|
var index = require('./components/Badge/index.js');
|
|
@@ -15,7 +9,6 @@ var index$1 = require('./components/Breadcrumbs/index.js');
|
|
|
15
9
|
var BreadcrumbsList = require('./components/Breadcrumbs/BreadcrumbsList.js');
|
|
16
10
|
var BreadcrumbsItem = require('./components/Breadcrumbs/BreadcrumbsItem.js');
|
|
17
11
|
var BreadcrumbsLink = require('./components/Breadcrumbs/BreadcrumbsLink.js');
|
|
18
|
-
var HelpText = require('./components/HelpText/HelpText.js');
|
|
19
12
|
var Spinner = require('./components/Spinner/Spinner.js');
|
|
20
13
|
var Skeleton = require('./components/Skeleton/Skeleton.js');
|
|
21
14
|
var Link = require('./components/Link/Link.js');
|
|
@@ -97,17 +90,19 @@ var index$i = require('./components/ErrorSummary/index.js');
|
|
|
97
90
|
var ErrorSummaryItem = require('./components/ErrorSummary/ErrorSummaryItem.js');
|
|
98
91
|
var ErrorSummaryHeading = require('./components/ErrorSummary/ErrorSummaryHeading.js');
|
|
99
92
|
var ErrorSummaryList = require('./components/ErrorSummary/ErrorSummaryList.js');
|
|
93
|
+
var omit = require('./utilities/omit/omit.js');
|
|
94
|
+
var useCheckboxGroup = require('./utilities/hooks/useCheckboxGroup/useCheckboxGroup.js');
|
|
95
|
+
var useDebounceCallback = require('./utilities/hooks/useDebounceCallback/useDebounceCallback.js');
|
|
96
|
+
var useIsomorphicLayoutEffect = require('./utilities/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js');
|
|
97
|
+
var useMediaQuery = require('./utilities/hooks/useMediaQuery/useMediaQuery.js');
|
|
98
|
+
var useRadioGroup = require('./utilities/hooks/useRadioGroup/useRadioGroup.js');
|
|
99
|
+
var useSynchronizedAnimation = require('./utilities/hooks/useSynchronizedAnimation/useSynchronizedAnimation.js');
|
|
100
|
+
var RovingFocusRoot = require('./utilities/RovingFocus/RovingFocusRoot.js');
|
|
101
|
+
var useRovingFocus = require('./utilities/RovingFocus/useRovingFocus.js');
|
|
102
|
+
var RovingFocusItem = require('./utilities/RovingFocus/RovingFocusItem.js');
|
|
100
103
|
|
|
101
104
|
|
|
102
105
|
|
|
103
|
-
exports.useSynchronizedAnimation = useSynchronizedAnimation.useSynchronizedAnimation;
|
|
104
|
-
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect.useIsomorphicLayoutEffect;
|
|
105
|
-
exports.RovingFocusRoot = RovingFocusRoot.RovingFocusRoot;
|
|
106
|
-
exports.useRovingFocus = useRovingFocus.useRovingFocus;
|
|
107
|
-
exports.RovingFocusItem = RovingFocusItem.RovingFocusItem;
|
|
108
|
-
exports.getNextFocusableValue = RovingFocusItem.getNextFocusableValue;
|
|
109
|
-
exports.getPrevFocusableValue = RovingFocusItem.getPrevFocusableValue;
|
|
110
|
-
exports.omit = omit.omit;
|
|
111
106
|
exports.Avatar = Avatar.Avatar;
|
|
112
107
|
exports.Button = Button.Button;
|
|
113
108
|
exports.Badge = index.Badge;
|
|
@@ -116,7 +111,6 @@ exports.Breadcrumbs = index$1.Breadcrumbs;
|
|
|
116
111
|
exports.BreadcrumbsList = BreadcrumbsList.BreadcrumbsList;
|
|
117
112
|
exports.BreadcrumbsItem = BreadcrumbsItem.BreadcrumbsItem;
|
|
118
113
|
exports.BreadcrumbsLink = BreadcrumbsLink.BreadcrumbsLink;
|
|
119
|
-
exports.HelpText = HelpText.HelpText;
|
|
120
114
|
exports.Spinner = Spinner.Spinner;
|
|
121
115
|
exports.Skeleton = Skeleton.Skeleton;
|
|
122
116
|
exports.Link = Link.Link;
|
|
@@ -203,3 +197,15 @@ exports.ErrorSummary = index$i.ErrorSummary;
|
|
|
203
197
|
exports.ErrorSummaryItem = ErrorSummaryItem.ErrorSummaryItem;
|
|
204
198
|
exports.ErrorSummaryHeading = ErrorSummaryHeading.ErrorSummaryHeading;
|
|
205
199
|
exports.ErrorSummaryList = ErrorSummaryList.ErrorSummaryList;
|
|
200
|
+
exports.omit = omit.omit;
|
|
201
|
+
exports.useCheckboxGroup = useCheckboxGroup.useCheckboxGroup;
|
|
202
|
+
exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
|
|
203
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect.useIsomorphicLayoutEffect;
|
|
204
|
+
exports.useMediaQuery = useMediaQuery.useMediaQuery;
|
|
205
|
+
exports.useRadioGroup = useRadioGroup.useRadioGroup;
|
|
206
|
+
exports.useSynchronizedAnimation = useSynchronizedAnimation.useSynchronizedAnimation;
|
|
207
|
+
exports.RovingFocusRoot = RovingFocusRoot.RovingFocusRoot;
|
|
208
|
+
exports.useRovingFocus = useRovingFocus.useRovingFocus;
|
|
209
|
+
exports.RovingFocusItem = RovingFocusItem.RovingFocusItem;
|
|
210
|
+
exports.getNextFocusableValue = RovingFocusItem.getNextFocusableValue;
|
|
211
|
+
exports.getPrevFocusableValue = RovingFocusItem.getPrevFocusableValue;
|
|
@@ -23,7 +23,7 @@ const RovingFocusRoot = react.forwardRef(({ activeValue, asChild, orientation =
|
|
|
23
23
|
const [focusableValue, setFocusableValue] = react.useState(null);
|
|
24
24
|
const [isShiftTabbing, setIsShiftTabbing] = react.useState(false);
|
|
25
25
|
const elements = react.useRef(new Map());
|
|
26
|
-
const myRef = react.useRef();
|
|
26
|
+
const myRef = react.useRef(null);
|
|
27
27
|
const refs = react$1.useMergeRefs([ref, myRef]);
|
|
28
28
|
const getOrderedItems = () => {
|
|
29
29
|
if (!myRef.current)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react$1 = require('@floating-ui/react');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const toggleIndeterminate = (getIndeterminateInputs, getInputs) => {
|
|
8
|
+
const inputs = getIndeterminateInputs();
|
|
9
|
+
const checked = !!getInputs(true).length;
|
|
10
|
+
const unchecked = !!getInputs(false).length;
|
|
11
|
+
for (const input of inputs) {
|
|
12
|
+
input.indeterminate = unchecked && checked;
|
|
13
|
+
input.checked = !unchecked && checked;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function useCheckboxGroup(props) {
|
|
17
|
+
const { error, name: groupName, onChange, value = [], disabled, readOnly, required, } = props || {};
|
|
18
|
+
const [groupValue, setGroupValue] = react.useState(value);
|
|
19
|
+
const namedId = react.useId();
|
|
20
|
+
const errorId = react.useId();
|
|
21
|
+
const checkboxRefs = react.useRef(new Set());
|
|
22
|
+
const indeterminateRefs = react.useRef(new Set());
|
|
23
|
+
const getInputs = (checked) => Array.from(checkboxRefs.current.values()).filter((input) => input.checked === checked);
|
|
24
|
+
const getIndeterminateInputs = () => Array.from(indeterminateRefs.current.values());
|
|
25
|
+
return {
|
|
26
|
+
/**
|
|
27
|
+
* Current value of the group.
|
|
28
|
+
*/
|
|
29
|
+
value: groupValue,
|
|
30
|
+
/**
|
|
31
|
+
* Set the value of the group.
|
|
32
|
+
*
|
|
33
|
+
* @param value string[]
|
|
34
|
+
* @returns void
|
|
35
|
+
*/
|
|
36
|
+
setValue: setGroupValue,
|
|
37
|
+
/**
|
|
38
|
+
* Props to send to the `Checkbox` component.
|
|
39
|
+
* Accepts value or object
|
|
40
|
+
* @example
|
|
41
|
+
* <Checkbox {...getCheckboxProps('value')} />
|
|
42
|
+
*
|
|
43
|
+
* @example allow indeterminate
|
|
44
|
+
* <Checkbox {...getCheckboxProps({ value: 'all', allowIndeterminate: true })} />
|
|
45
|
+
*/
|
|
46
|
+
getCheckboxProps: (propsOrValue) => {
|
|
47
|
+
const props = typeof propsOrValue === 'string'
|
|
48
|
+
? { value: propsOrValue }
|
|
49
|
+
: propsOrValue || {};
|
|
50
|
+
const { allowIndeterminate = false, ref = undefined, value = '', ...rest } = props;
|
|
51
|
+
const inputRef = react.useRef(null);
|
|
52
|
+
const mergedRefs = react$1.useMergeRefs([ref, inputRef]);
|
|
53
|
+
const handleChange = () => {
|
|
54
|
+
const nextGroupValue = Array.from(getInputs(true), ({ value }) => value);
|
|
55
|
+
setGroupValue(nextGroupValue);
|
|
56
|
+
onChange?.(nextGroupValue, groupValue);
|
|
57
|
+
};
|
|
58
|
+
const indeterminateChange = () => {
|
|
59
|
+
if (!inputRef.current)
|
|
60
|
+
return;
|
|
61
|
+
const checked = !!inputRef.current.checked;
|
|
62
|
+
for (const input of getInputs(!checked)) {
|
|
63
|
+
/* We use click to send both event and change checked state */
|
|
64
|
+
input.click();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
react.useEffect(() => {
|
|
68
|
+
if (!allowIndeterminate)
|
|
69
|
+
return;
|
|
70
|
+
toggleIndeterminate(getIndeterminateInputs, getInputs);
|
|
71
|
+
}, [groupValue]);
|
|
72
|
+
react.useEffect(() => {
|
|
73
|
+
if (!inputRef.current)
|
|
74
|
+
return;
|
|
75
|
+
const input = inputRef.current;
|
|
76
|
+
const refs = allowIndeterminate ? indeterminateRefs : checkboxRefs;
|
|
77
|
+
refs.current.add(input);
|
|
78
|
+
if (getIndeterminateInputs().length)
|
|
79
|
+
toggleIndeterminate(getIndeterminateInputs, getInputs);
|
|
80
|
+
return () => {
|
|
81
|
+
refs.current.delete(input);
|
|
82
|
+
};
|
|
83
|
+
}, [value]);
|
|
84
|
+
return {
|
|
85
|
+
/* Spread anything the user has set first */
|
|
86
|
+
...rest,
|
|
87
|
+
/* Concat ours with the user prop */
|
|
88
|
+
'aria-describedby': `${error ? errorId : ''} ${rest['aria-describedby'] || ''}`.trim() ||
|
|
89
|
+
undefined,
|
|
90
|
+
'aria-invalid': !!error || rest['aria-invalid'],
|
|
91
|
+
checked: allowIndeterminate ? undefined : groupValue.includes(value),
|
|
92
|
+
name: rest.name || groupName || namedId,
|
|
93
|
+
onChange: (e) => {
|
|
94
|
+
rest.onChange?.(e);
|
|
95
|
+
if (e.defaultPrevented)
|
|
96
|
+
return;
|
|
97
|
+
allowIndeterminate && indeterminateChange();
|
|
98
|
+
handleChange();
|
|
99
|
+
},
|
|
100
|
+
ref: mergedRefs,
|
|
101
|
+
value,
|
|
102
|
+
disabled: disabled || rest.disabled,
|
|
103
|
+
readOnly: readOnly || rest.readOnly,
|
|
104
|
+
required: required || rest.required,
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Props to send to the `ValidationMessage` component.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* <ValidationMessage {...validationMessageProps} />
|
|
112
|
+
*/
|
|
113
|
+
validationMessageProps: {
|
|
114
|
+
children: error,
|
|
115
|
+
hidden: !error,
|
|
116
|
+
id: errorId,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.useCheckboxGroup = useCheckboxGroup;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js');
|
|
6
|
+
|
|
7
|
+
// from https://usehooks-ts.com/react-hook/use-media-query
|
|
8
|
+
const IS_SERVER = typeof window === 'undefined';
|
|
9
|
+
function useMediaQuery(query, { defaultValue = false, initializeWithValue = true, } = {}) {
|
|
10
|
+
const getMatches = (query) => {
|
|
11
|
+
if (IS_SERVER) {
|
|
12
|
+
return defaultValue;
|
|
13
|
+
}
|
|
14
|
+
return window.matchMedia(query).matches;
|
|
15
|
+
};
|
|
16
|
+
const [matches, setMatches] = react.useState(() => {
|
|
17
|
+
if (initializeWithValue) {
|
|
18
|
+
return getMatches(query);
|
|
19
|
+
}
|
|
20
|
+
return defaultValue;
|
|
21
|
+
});
|
|
22
|
+
// Handles the change event of the media query.
|
|
23
|
+
function handleChange() {
|
|
24
|
+
setMatches(getMatches(query));
|
|
25
|
+
}
|
|
26
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
27
|
+
const matchMedia = window.matchMedia(query);
|
|
28
|
+
// Triggered at the first client-side load and if query changes
|
|
29
|
+
handleChange();
|
|
30
|
+
// Use deprecated `addListener` and `removeListener` to support Safari < 14 (#135)
|
|
31
|
+
if (matchMedia.addListener) {
|
|
32
|
+
matchMedia.addListener(handleChange);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
matchMedia.addEventListener('change', handleChange);
|
|
36
|
+
}
|
|
37
|
+
return () => {
|
|
38
|
+
if (matchMedia.removeListener) {
|
|
39
|
+
matchMedia.removeListener(handleChange);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
matchMedia.removeEventListener('change', handleChange);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, [query]);
|
|
46
|
+
return matches;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
exports.useMediaQuery = useMediaQuery;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react$1 = require('@floating-ui/react');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* useRadioGroup is used to group multiple <Radio> components
|
|
9
|
+
* @example
|
|
10
|
+
* const { getRadioProps, validationMessageProps, value, setValue } = useRadioGroup({
|
|
11
|
+
* disabled: false,
|
|
12
|
+
* error: 'Validation message text',
|
|
13
|
+
* name: 'group-name',
|
|
14
|
+
* onChange: (nextValue, prevValue) => {},
|
|
15
|
+
* readOnly: false,
|
|
16
|
+
* required: true,
|
|
17
|
+
* value: '',
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
function useRadioGroup({ error, readOnly, required, disabled, name, onChange, value: initalValue = '', } = {}) {
|
|
21
|
+
const [groupValue, setGroupValue] = react.useState(initalValue);
|
|
22
|
+
const errorId = react.useId();
|
|
23
|
+
const namedId = react.useId();
|
|
24
|
+
const radioGroupName = name || namedId;
|
|
25
|
+
return {
|
|
26
|
+
/**
|
|
27
|
+
* Current value of the group.
|
|
28
|
+
*/
|
|
29
|
+
value: groupValue,
|
|
30
|
+
/**
|
|
31
|
+
* Set the value of the group.
|
|
32
|
+
*
|
|
33
|
+
* @param value string[]
|
|
34
|
+
* @returns void
|
|
35
|
+
*/
|
|
36
|
+
setValue: setGroupValue,
|
|
37
|
+
/**
|
|
38
|
+
* Props to send to the `Radio` component.
|
|
39
|
+
* @example
|
|
40
|
+
* <Radio label="Option 1" {...getRadioProps('option-1')} />
|
|
41
|
+
*/
|
|
42
|
+
getRadioProps: (propsOrValue) => {
|
|
43
|
+
const props = typeof propsOrValue === 'string'
|
|
44
|
+
? { value: propsOrValue }
|
|
45
|
+
: propsOrValue;
|
|
46
|
+
const { ref = undefined, value = '', ...rest } = props;
|
|
47
|
+
const localRef = react.useRef(null);
|
|
48
|
+
const mergedRefs = react$1.useMergeRefs([ref, localRef]);
|
|
49
|
+
const handleChange = () => {
|
|
50
|
+
const input = localRef.current;
|
|
51
|
+
const isInput = input instanceof HTMLInputElement;
|
|
52
|
+
if (isInput && input.name === radioGroupName) {
|
|
53
|
+
setGroupValue((prevValue) => {
|
|
54
|
+
onChange?.(input.value, prevValue);
|
|
55
|
+
return input.value;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
react.useEffect(() => {
|
|
60
|
+
if (!localRef.current)
|
|
61
|
+
return;
|
|
62
|
+
localRef.current.checked = value === groupValue;
|
|
63
|
+
}, [groupValue, value]);
|
|
64
|
+
return {
|
|
65
|
+
/* Spread anything the user has set first */
|
|
66
|
+
...rest,
|
|
67
|
+
/* Concat ours with the user prop */
|
|
68
|
+
name: radioGroupName,
|
|
69
|
+
'aria-describedby': `${error ? errorId : ''} ${rest['aria-describedby'] || ''}`.trim() ||
|
|
70
|
+
undefined,
|
|
71
|
+
'aria-invalid': !!error || rest['aria-invalid'],
|
|
72
|
+
value,
|
|
73
|
+
ref: mergedRefs,
|
|
74
|
+
required: required || rest.required,
|
|
75
|
+
readOnly: readOnly || rest.readOnly,
|
|
76
|
+
disabled: disabled || rest.disabled,
|
|
77
|
+
onChange: (e) => {
|
|
78
|
+
rest.onChange?.(e);
|
|
79
|
+
if (e.defaultPrevented)
|
|
80
|
+
return;
|
|
81
|
+
handleChange();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* Props to send to the `ValidationMessage` component.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* <ValidationMessage {...validationMessageProps} />
|
|
90
|
+
*/
|
|
91
|
+
validationMessageProps: {
|
|
92
|
+
children: error,
|
|
93
|
+
hidden: !error,
|
|
94
|
+
id: errorId,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.useRadioGroup = useRadioGroup;
|
|
@@ -4,7 +4,7 @@ import { FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
|
4
4
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
5
5
|
import cl from 'clsx/lite';
|
|
6
6
|
import { forwardRef, useRef, useState, useEffect } from 'react';
|
|
7
|
-
import { useFormField } from '
|
|
7
|
+
import { useFormField } from './useFormField/useFormField.js';
|
|
8
8
|
import { ComboboxContext } from './ComboboxContext.js';
|
|
9
9
|
import { ComboboxIdProvider } from './ComboboxIdContext.js';
|
|
10
10
|
import { ComboboxCustom } from './Custom.js';
|
|
@@ -176,7 +176,7 @@ const ComboboxComponent = forwardRef(({ value, initialValue = [], onValueChange,
|
|
|
176
176
|
setListRef: (index, node) => {
|
|
177
177
|
listRef.current[index] = node;
|
|
178
178
|
},
|
|
179
|
-
}, children: [jsxs("div", { className: cl('ds-combobox', `ds-combobox--${size}`, disabled && 'ds-combobox__disabled', className), style: style, ref: portalRef, children: [name && (jsx(ComboboxNative, { name: name, selectedOptions: selectedOptions, multiple: multiple })), jsx(ComboboxLabel, { label: label, description: description, size: size, readOnly: readOnly, hideLabel: hideLabel, formFieldProps: formFieldProps }), jsx(ComboboxInput, { ...omit(['inputValue'], rest), hideClearButton: hideClearButton, listId: context.floatingId, error: error, hideChips: hideChips, handleKeyDown: handleKeyDown, "aria-busy": loading }), jsx(ComboboxError, { size: size, error: error, formFieldProps: formFieldProps })] }), open && (jsx(FloatingPortal, { root: portal ? null : portalRef, children: jsx(FloatingFocusManager, { context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: jsxs("div", { "aria-labelledby": formFieldProps.inputProps.id, "aria-autocomplete": 'list', tabIndex: -1, ...getFloatingProps({
|
|
179
|
+
}, children: [jsxs("div", { className: cl('ds-combobox', `ds-combobox--${size}`, disabled && 'ds-combobox__disabled', className), style: style, ref: portalRef, children: [name && (jsx(ComboboxNative, { name: name, selectedOptions: selectedOptions, multiple: multiple })), jsx(ComboboxLabel, { label: label, description: description, size: size, readOnly: readOnly, hideLabel: hideLabel, formFieldProps: formFieldProps }), jsx(ComboboxInput, { ...omit(['inputValue'], rest), hideClearButton: hideClearButton, listId: context.floatingId || '', error: error, hideChips: hideChips, handleKeyDown: handleKeyDown, "aria-busy": loading }), jsx(ComboboxError, { size: size, error: error, formFieldProps: formFieldProps })] }), open && (jsx(FloatingPortal, { root: portal ? null : portalRef, children: jsx(FloatingFocusManager, { context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: jsxs("div", { "aria-labelledby": formFieldProps.inputProps.id, "aria-autocomplete": 'list', tabIndex: -1, ...getFloatingProps({
|
|
180
180
|
ref: refs.setFloating,
|
|
181
181
|
style: {
|
|
182
182
|
...floatingStyles,
|