@navikt/ds-react 7.30.0 → 7.31.0
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/cjs/accordion/AccordionContent.js +1 -1
- package/cjs/accordion/AccordionContent.js.map +1 -1
- package/cjs/accordion/AccordionHeader.js +1 -1
- package/cjs/accordion/AccordionHeader.js.map +1 -1
- package/cjs/chips/Removable.js +1 -1
- package/cjs/chips/Removable.js.map +1 -1
- package/cjs/chips/Toggle.js +1 -1
- package/cjs/chips/Toggle.js.map +1 -1
- package/cjs/copybutton/CopyButton.js +8 -4
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/expansion-card/ExpansionCardContent.js +2 -1
- package/cjs/expansion-card/ExpansionCardContent.js.map +1 -1
- package/cjs/form/checkbox/Checkbox.js +42 -0
- package/cjs/form/checkbox/Checkbox.js.map +1 -1
- package/cjs/form/checkbox/useCheckbox.d.ts +2 -2
- package/cjs/form/checkbox/useCheckbox.js +5 -5
- package/cjs/form/checkbox/useCheckbox.js.map +1 -1
- package/cjs/form/combobox/Combobox.js +15 -13
- package/cjs/form/combobox/Combobox.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +53 -3
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.js +15 -14
- package/cjs/form/combobox/Input/InputController.js.map +1 -1
- package/cjs/form/radio/Radio.js +18 -0
- package/cjs/form/radio/Radio.js.map +1 -1
- package/cjs/form/radio/useRadio.d.ts +2 -2
- package/cjs/form/radio/useRadio.js +5 -5
- package/cjs/form/radio/useRadio.js.map +1 -1
- package/cjs/form/search/Search.js +1 -1
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/guide-panel/GuidePanel.js +3 -3
- package/cjs/guide-panel/GuidePanel.js.map +1 -1
- package/cjs/help-text/HelpText.js +1 -1
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/internal-header/InternalHeader.js +1 -1
- package/cjs/internal-header/InternalHeader.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.js +1 -1
- package/cjs/layout/base/BasePrimitive.js.map +1 -1
- package/cjs/layout/bleed/Bleed.js +1 -1
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.js +4 -4
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/grid/HGrid.js +1 -1
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.js +3 -1
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/stack/Stack.js +1 -1
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/link/Link.js +1 -1
- package/cjs/link/Link.js.map +1 -1
- package/cjs/list/List.js +1 -1
- package/cjs/list/List.js.map +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
- package/cjs/overlays/floating/Floating.d.ts +11 -0
- package/cjs/overlays/floating/Floating.js +32 -8
- package/cjs/overlays/floating/Floating.js.map +1 -1
- package/cjs/overlays/overlay/hooks/useAnimationsFinished.d.ts +27 -0
- package/cjs/overlays/overlay/hooks/useAnimationsFinished.js +138 -0
- package/cjs/overlays/overlay/hooks/useAnimationsFinished.js.map +1 -0
- package/cjs/overlays/overlay/hooks/useEventCallback.d.ts +6 -0
- package/cjs/overlays/overlay/hooks/useEventCallback.js +89 -0
- package/cjs/overlays/overlay/hooks/useEventCallback.js.map +1 -0
- package/cjs/overlays/overlay/hooks/useLatestRef.d.ts +5 -0
- package/cjs/overlays/overlay/hooks/useLatestRef.js +23 -0
- package/cjs/overlays/overlay/hooks/useLatestRef.js.map +1 -0
- package/cjs/overlays/overlay/hooks/useOpenChangeComplete.d.ts +31 -0
- package/cjs/overlays/overlay/hooks/useOpenChangeComplete.js +35 -0
- package/cjs/overlays/overlay/hooks/useOpenChangeComplete.js.map +1 -0
- package/cjs/overlays/overlay/hooks/useRefWithInit.d.ts +7 -0
- package/cjs/overlays/overlay/hooks/useRefWithInit.js +14 -0
- package/cjs/overlays/overlay/hooks/useRefWithInit.js.map +1 -0
- package/cjs/pagination/PaginationItem.js +1 -1
- package/cjs/pagination/PaginationItem.js.map +1 -1
- package/cjs/popover/Popover.js +2 -2
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/portal/Portal.js +1 -1
- package/cjs/portal/Portal.js.map +1 -1
- package/cjs/table/ExpandableRow.d.ts +1 -1
- package/cjs/table/ExpandableRow.js +2 -10
- package/cjs/table/ExpandableRow.js.map +1 -1
- package/cjs/table/Row.d.ts +7 -0
- package/cjs/table/Row.js +13 -2
- package/cjs/table/Row.js.map +1 -1
- package/cjs/table/Table.utils.d.ts +9 -0
- package/cjs/table/Table.utils.js +57 -0
- package/cjs/table/Table.utils.js.map +1 -0
- package/cjs/theme/Theme.d.ts +6 -1
- package/cjs/theme/Theme.js +10 -2
- package/cjs/theme/Theme.js.map +1 -1
- package/cjs/timeline/Pin.js +1 -1
- package/cjs/timeline/Pin.js.map +1 -1
- package/cjs/timeline/period/ClickablePeriod.js +1 -1
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/toggle-group/ToggleGroup.js +1 -1
- package/cjs/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/accordion/AccordionContent.js +1 -1
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +1 -1
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/chips/Removable.js +1 -1
- package/esm/chips/Removable.js.map +1 -1
- package/esm/chips/Toggle.js +1 -1
- package/esm/chips/Toggle.js.map +1 -1
- package/esm/copybutton/CopyButton.js +8 -4
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/expansion-card/ExpansionCardContent.js +3 -2
- package/esm/expansion-card/ExpansionCardContent.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +44 -2
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +2 -2
- package/esm/form/checkbox/useCheckbox.js +5 -5
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/combobox/Combobox.js +15 -13
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +21 -4
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
- package/esm/form/combobox/Input/InputController.js +15 -14
- package/esm/form/combobox/Input/InputController.js.map +1 -1
- package/esm/form/radio/Radio.js +17 -2
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/useRadio.d.ts +2 -2
- package/esm/form/radio/useRadio.js +5 -5
- package/esm/form/radio/useRadio.js.map +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +3 -3
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/help-text/HelpText.js +1 -1
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/internal-header/InternalHeader.js +1 -1
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/layout/base/BasePrimitive.js +1 -1
- package/esm/layout/base/BasePrimitive.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +1 -1
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.js +4 -4
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.js +1 -1
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.js +3 -1
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/stack/Stack.js +1 -1
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/link/Link.js +1 -1
- package/esm/link/Link.js.map +1 -1
- package/esm/list/List.js +1 -1
- package/esm/list/List.js.map +1 -1
- package/esm/overlays/action-menu/ActionMenu.js +1 -1
- package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
- package/esm/overlays/floating/Floating.d.ts +11 -0
- package/esm/overlays/floating/Floating.js +32 -8
- package/esm/overlays/floating/Floating.js.map +1 -1
- package/esm/overlays/overlay/hooks/useAnimationsFinished.d.ts +27 -0
- package/esm/overlays/overlay/hooks/useAnimationsFinished.js +99 -0
- package/esm/overlays/overlay/hooks/useAnimationsFinished.js.map +1 -0
- package/esm/overlays/overlay/hooks/useEventCallback.d.ts +6 -0
- package/esm/overlays/overlay/hooks/useEventCallback.js +53 -0
- package/esm/overlays/overlay/hooks/useEventCallback.js.map +1 -0
- package/esm/overlays/overlay/hooks/useLatestRef.d.ts +5 -0
- package/esm/overlays/overlay/hooks/useLatestRef.js +20 -0
- package/esm/overlays/overlay/hooks/useLatestRef.js.map +1 -0
- package/esm/overlays/overlay/hooks/useOpenChangeComplete.d.ts +31 -0
- package/esm/overlays/overlay/hooks/useOpenChangeComplete.js +32 -0
- package/esm/overlays/overlay/hooks/useOpenChangeComplete.js.map +1 -0
- package/esm/overlays/overlay/hooks/useRefWithInit.d.ts +7 -0
- package/esm/overlays/overlay/hooks/useRefWithInit.js +12 -0
- package/esm/overlays/overlay/hooks/useRefWithInit.js.map +1 -0
- package/esm/pagination/PaginationItem.js +1 -1
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/portal/Portal.js +1 -1
- package/esm/portal/Portal.js.map +1 -1
- package/esm/table/ExpandableRow.d.ts +1 -1
- package/esm/table/ExpandableRow.js +2 -10
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/Row.d.ts +7 -0
- package/esm/table/Row.js +13 -2
- package/esm/table/Row.js.map +1 -1
- package/esm/table/Table.utils.d.ts +9 -0
- package/esm/table/Table.utils.js +55 -0
- package/esm/table/Table.utils.js.map +1 -0
- package/esm/theme/Theme.d.ts +6 -1
- package/esm/theme/Theme.js +10 -2
- package/esm/theme/Theme.js.map +1 -1
- package/esm/timeline/Pin.js +1 -1
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +1 -1
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +1 -1
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/AccordionContent.tsx +1 -1
- package/src/accordion/AccordionHeader.tsx +1 -1
- package/src/chips/Removable.tsx +1 -1
- package/src/chips/Toggle.tsx +1 -1
- package/src/copybutton/CopyButton.tsx +8 -4
- package/src/expansion-card/ExpansionCardContent.tsx +3 -1
- package/src/form/checkbox/Checkbox.tsx +93 -2
- package/src/form/checkbox/useCheckbox.ts +5 -5
- package/src/form/combobox/Combobox.tsx +44 -41
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +29 -4
- package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +1 -0
- package/src/form/combobox/Input/InputController.tsx +33 -29
- package/src/form/radio/Radio.tsx +49 -2
- package/src/form/radio/useRadio.ts +5 -5
- package/src/form/search/Search.tsx +1 -1
- package/src/guide-panel/GuidePanel.tsx +3 -3
- package/src/help-text/HelpText.tsx +2 -2
- package/src/internal-header/InternalHeader.tsx +1 -1
- package/src/layout/base/BasePrimitive.tsx +1 -1
- package/src/layout/bleed/Bleed.tsx +1 -1
- package/src/layout/box/Box.tsx +5 -4
- package/src/layout/grid/HGrid.tsx +1 -1
- package/src/layout/page/Page.tsx +5 -1
- package/src/layout/stack/Stack.tsx +1 -1
- package/src/link/Link.tsx +1 -1
- package/src/list/List.tsx +1 -1
- package/src/overlays/action-menu/ActionMenu.tsx +1 -1
- package/src/overlays/floating/Floating.tsx +110 -59
- package/src/overlays/overlay/hooks/useAnimationsFinished.ts +117 -0
- package/src/overlays/overlay/hooks/useEventCallback.ts +73 -0
- package/src/overlays/overlay/hooks/useLatestRef.ts +25 -0
- package/src/overlays/overlay/hooks/useOpenChangeComplete.ts +66 -0
- package/src/overlays/overlay/hooks/useRefWithInit.ts +25 -0
- package/src/pagination/PaginationItem.tsx +1 -1
- package/src/popover/Popover.tsx +2 -2
- package/src/portal/Portal.tsx +1 -1
- package/src/table/ExpandableRow.tsx +4 -17
- package/src/table/Row.tsx +33 -1
- package/src/table/Table.utils.ts +65 -0
- package/src/theme/Theme.tsx +14 -3
- package/src/timeline/Pin.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +1 -1
- package/src/toggle-group/ToggleGroup.tsx +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
|
+
import { Floating } from "../../overlays/floating/Floating";
|
|
2
3
|
import { useRenameCSS } from "../../theme/Theme";
|
|
3
4
|
import { BodyShort, ErrorMessage, Label } from "../../typography";
|
|
4
5
|
import { ReadOnlyIconWithTitle } from "../ReadOnlyIcon";
|
|
@@ -34,52 +35,54 @@ export const Combobox = forwardRef<
|
|
|
34
35
|
} = useInputContext();
|
|
35
36
|
|
|
36
37
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<Label
|
|
45
|
-
htmlFor={inputProps.id}
|
|
46
|
-
size={size}
|
|
47
|
-
className={cn("navds-form-field__label", {
|
|
48
|
-
"navds-sr-only": hideLabel,
|
|
49
|
-
})}
|
|
38
|
+
<Floating>
|
|
39
|
+
<ComboboxWrapper
|
|
40
|
+
className={className}
|
|
41
|
+
hasError={hasError}
|
|
42
|
+
inputProps={inputProps}
|
|
43
|
+
inputSize={size}
|
|
44
|
+
toggleIsListOpen={toggleIsListOpen}
|
|
50
45
|
>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<BodyShort
|
|
56
|
-
as="div"
|
|
57
|
-
className={cn("navds-form-field__description", {
|
|
46
|
+
<Label
|
|
47
|
+
htmlFor={inputProps.id}
|
|
48
|
+
size={size}
|
|
49
|
+
className={cn("navds-form-field__label", {
|
|
58
50
|
"navds-sr-only": hideLabel,
|
|
59
51
|
})}
|
|
60
|
-
id={inputDescriptionId}
|
|
61
|
-
size={size}
|
|
62
52
|
>
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<ErrorMessage size={size} showIcon>
|
|
78
|
-
{error}
|
|
79
|
-
</ErrorMessage>
|
|
53
|
+
{readOnly && <ReadOnlyIconWithTitle />}
|
|
54
|
+
{label}
|
|
55
|
+
</Label>
|
|
56
|
+
{!!description && (
|
|
57
|
+
<BodyShort
|
|
58
|
+
as="div"
|
|
59
|
+
className={cn("navds-form-field__description", {
|
|
60
|
+
"navds-sr-only": hideLabel,
|
|
61
|
+
})}
|
|
62
|
+
id={inputDescriptionId}
|
|
63
|
+
size={size}
|
|
64
|
+
>
|
|
65
|
+
{description}
|
|
66
|
+
</BodyShort>
|
|
80
67
|
)}
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
<div className={cn("navds-combobox__wrapper")}>
|
|
69
|
+
<InputController ref={ref} {...rest} />
|
|
70
|
+
<FilteredOptions />
|
|
71
|
+
</div>
|
|
72
|
+
<div
|
|
73
|
+
className={cn("navds-form-field__error")}
|
|
74
|
+
id={errorId}
|
|
75
|
+
aria-relevant="additions removals"
|
|
76
|
+
aria-live="polite"
|
|
77
|
+
>
|
|
78
|
+
{showErrorMsg && (
|
|
79
|
+
<ErrorMessage size={size} showIcon>
|
|
80
|
+
{error}
|
|
81
|
+
</ErrorMessage>
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
</ComboboxWrapper>
|
|
85
|
+
</Floating>
|
|
83
86
|
);
|
|
84
87
|
});
|
|
85
88
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Floating } from "../../../overlays/floating/Floating";
|
|
3
|
+
import { useRenameCSS, useThemeInternal } from "../../../theme/Theme";
|
|
4
|
+
import { useClientLayoutEffect } from "../../../util";
|
|
3
5
|
import { useInputContext } from "../Input/Input.context";
|
|
4
6
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
5
7
|
import AddNewOption from "./AddNewOption";
|
|
@@ -12,6 +14,7 @@ import { useFilteredOptionsContext } from "./filteredOptionsContext";
|
|
|
12
14
|
|
|
13
15
|
const FilteredOptions = () => {
|
|
14
16
|
const { cn } = useRenameCSS();
|
|
17
|
+
const themeContext = useThemeInternal(false);
|
|
15
18
|
const {
|
|
16
19
|
inputProps: { id },
|
|
17
20
|
} = useInputContext();
|
|
@@ -25,6 +28,16 @@ const FilteredOptions = () => {
|
|
|
25
28
|
isMouseLastUsedInputDevice,
|
|
26
29
|
isValueNew,
|
|
27
30
|
} = useFilteredOptionsContext();
|
|
31
|
+
const [localOpen, setLocalOpen] = useState(isListOpen);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This is a dirty hack to make the positioning-logic in Floating base the "flip" on the static 290px max-height,
|
|
35
|
+
* instead of the dynamic one based on available space. Without this, the list won't flip to top when there's
|
|
36
|
+
* not enough space below the input.
|
|
37
|
+
*/
|
|
38
|
+
useClientLayoutEffect(() => {
|
|
39
|
+
queueMicrotask(() => setLocalOpen(isListOpen));
|
|
40
|
+
}, [isListOpen]);
|
|
28
41
|
|
|
29
42
|
const { maxSelected, isMultiSelect } = useSelectedOptionsContext();
|
|
30
43
|
|
|
@@ -37,14 +50,26 @@ const FilteredOptions = () => {
|
|
|
37
50
|
(allowNewValues && isValueNew && !maxSelected.isLimitReached) || // Render add new option
|
|
38
51
|
filteredOptions.length > 0; // Render filtered options
|
|
39
52
|
|
|
53
|
+
const height = themeContext?.isDarkside ? "316px" : "290px";
|
|
54
|
+
|
|
40
55
|
return (
|
|
41
|
-
<
|
|
56
|
+
<Floating.Content
|
|
42
57
|
className={cn("navds-combobox__list", {
|
|
43
58
|
"navds-combobox__list--closed": !isListOpen,
|
|
44
59
|
"navds-combobox__list--with-hover": isMouseLastUsedInputDevice,
|
|
45
60
|
})}
|
|
46
61
|
id={filteredOptionsUtil.getFilteredOptionsId(id)}
|
|
47
62
|
tabIndex={-1}
|
|
63
|
+
sideOffset={8}
|
|
64
|
+
side="bottom"
|
|
65
|
+
fallbackPlacements={["top"]}
|
|
66
|
+
enabled={isListOpen}
|
|
67
|
+
style={{
|
|
68
|
+
maxHeight: localOpen
|
|
69
|
+
? `min(${height}, var(--ac-floating-available-height))`
|
|
70
|
+
: `${height}`,
|
|
71
|
+
}}
|
|
72
|
+
autoUpdateWhileMounted={false}
|
|
48
73
|
>
|
|
49
74
|
{shouldRenderNonSelectables && (
|
|
50
75
|
<div
|
|
@@ -74,7 +99,7 @@ const FilteredOptions = () => {
|
|
|
74
99
|
))}
|
|
75
100
|
</ul>
|
|
76
101
|
)}
|
|
77
|
-
</
|
|
102
|
+
</Floating.Content>
|
|
78
103
|
);
|
|
79
104
|
};
|
|
80
105
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2
|
+
|
|
1
3
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
4
|
import React, { forwardRef } from "react";
|
|
5
|
+
import { Floating } from "../../../overlays/floating/Floating";
|
|
3
6
|
import { useRenameCSS } from "../../../theme/Theme";
|
|
4
7
|
import { useMergeRefs } from "../../../util/hooks";
|
|
5
8
|
import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
|
|
@@ -54,42 +57,43 @@ export const InputController = forwardRef<
|
|
|
54
57
|
const mergedInputRef = useMergeRefs(inputRef, ref);
|
|
55
58
|
|
|
56
59
|
return (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
<Floating.Anchor asChild>
|
|
61
|
+
<div
|
|
62
|
+
className={cn("navds-combobox__wrapper-inner navds-text-field__input", {
|
|
63
|
+
"navds-combobox__wrapper-inner--virtually-unfocused":
|
|
64
|
+
activeDecendantId !== undefined,
|
|
65
|
+
})}
|
|
66
|
+
onClick={() => {
|
|
67
|
+
if (inputProps.disabled || readOnly) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<Input
|
|
74
|
-
id={inputProps.id}
|
|
75
|
-
ref={mergedInputRef}
|
|
76
|
-
inputClassName={inputClassName}
|
|
77
|
-
readOnly={readOnly}
|
|
78
|
-
{...rest}
|
|
79
|
-
/>
|
|
80
|
-
) : (
|
|
81
|
-
<SelectedOptions selectedOptions={selectedOptions} size={size}>
|
|
71
|
+
toggleIsListOpen(true);
|
|
72
|
+
focusInput();
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{!shouldShowSelectedOptions ? (
|
|
82
76
|
<Input
|
|
83
77
|
id={inputProps.id}
|
|
84
78
|
ref={mergedInputRef}
|
|
85
79
|
inputClassName={inputClassName}
|
|
86
|
-
shouldShowSelectedOptions={shouldShowSelectedOptions}
|
|
87
80
|
readOnly={readOnly}
|
|
88
81
|
{...rest}
|
|
89
82
|
/>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
) : (
|
|
84
|
+
<SelectedOptions selectedOptions={selectedOptions} size={size}>
|
|
85
|
+
<Input
|
|
86
|
+
id={inputProps.id}
|
|
87
|
+
ref={mergedInputRef}
|
|
88
|
+
inputClassName={inputClassName}
|
|
89
|
+
shouldShowSelectedOptions={shouldShowSelectedOptions}
|
|
90
|
+
readOnly={readOnly}
|
|
91
|
+
{...rest}
|
|
92
|
+
/>
|
|
93
|
+
</SelectedOptions>
|
|
94
|
+
)}
|
|
95
|
+
{toggleListButton && <ToggleListButton ref={toggleOpenButtonRef} />}
|
|
96
|
+
</div>
|
|
97
|
+
</Floating.Anchor>
|
|
94
98
|
);
|
|
95
99
|
});
|
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -1,13 +1,60 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
1
2
|
import React, { forwardRef } from "react";
|
|
2
|
-
import { useRenameCSS } from "../../theme/Theme";
|
|
3
|
+
import { useRenameCSS, useThemeInternal } from "../../theme/Theme";
|
|
3
4
|
import { BodyShort } from "../../typography";
|
|
4
|
-
import { omit } from "../../util";
|
|
5
|
+
import { omit, useId } from "../../util";
|
|
5
6
|
import { RadioProps } from "./types";
|
|
6
7
|
import { useRadio } from "./useRadio";
|
|
7
8
|
|
|
8
9
|
export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
9
10
|
const { cn } = useRenameCSS();
|
|
10
11
|
const { inputProps, size, hasError, readOnly } = useRadio(props);
|
|
12
|
+
const descriptionId = useId();
|
|
13
|
+
const themeContext = useThemeInternal(false);
|
|
14
|
+
|
|
15
|
+
if (themeContext?.isDarkside) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
className={cn(props.className, "navds-radio", `navds-radio--${size}`, {
|
|
19
|
+
"navds-radio--error": hasError,
|
|
20
|
+
"navds-radio--disabled": inputProps.disabled,
|
|
21
|
+
"navds-radio--readonly": readOnly,
|
|
22
|
+
})}
|
|
23
|
+
data-color={hasError ? "danger" : props["data-color"]}
|
|
24
|
+
>
|
|
25
|
+
<input
|
|
26
|
+
{...omit(props, ["children", "size", "description", "readOnly"])}
|
|
27
|
+
{...omit(inputProps, ["aria-invalid", "aria-describedby"])}
|
|
28
|
+
aria-describedby={
|
|
29
|
+
cl(inputProps["aria-describedby"], {
|
|
30
|
+
[descriptionId]: props.description,
|
|
31
|
+
}) || undefined
|
|
32
|
+
}
|
|
33
|
+
className={cn("navds-radio__input")}
|
|
34
|
+
ref={ref}
|
|
35
|
+
/>
|
|
36
|
+
<BodyShort
|
|
37
|
+
as="label"
|
|
38
|
+
htmlFor={inputProps.id}
|
|
39
|
+
className={cn("navds-radio__label")}
|
|
40
|
+
size={size}
|
|
41
|
+
>
|
|
42
|
+
{props.children}
|
|
43
|
+
</BodyShort>
|
|
44
|
+
{props.description && (
|
|
45
|
+
<BodyShort
|
|
46
|
+
id={descriptionId}
|
|
47
|
+
size={size}
|
|
48
|
+
className={cn(
|
|
49
|
+
"navds-form-field__subdescription navds-radio__description",
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
{props.description}
|
|
53
|
+
</BodyShort>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
11
58
|
|
|
12
59
|
return (
|
|
13
60
|
<div
|
|
@@ -37,19 +37,19 @@ export const useRadio = (props: RadioProps) => {
|
|
|
37
37
|
radioGroup?.value === undefined
|
|
38
38
|
? undefined
|
|
39
39
|
: radioGroup?.value === props.value,
|
|
40
|
-
onChange: (
|
|
40
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
41
41
|
if (readOnly) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
props.onChange?.(
|
|
44
|
+
props.onChange?.(event);
|
|
45
45
|
radioGroup?.onChange?.(props.value);
|
|
46
46
|
},
|
|
47
|
-
onClick: (
|
|
47
|
+
onClick: (event: React.MouseEvent<HTMLInputElement>) => {
|
|
48
48
|
if (readOnly) {
|
|
49
|
-
|
|
49
|
+
event.preventDefault();
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
props?.onClick?.(
|
|
52
|
+
props?.onClick?.(event);
|
|
53
53
|
},
|
|
54
54
|
required: radioGroup?.required,
|
|
55
55
|
type: "radio",
|
|
@@ -271,7 +271,7 @@ function ClearButton({
|
|
|
271
271
|
const themeContext = useThemeInternal(false);
|
|
272
272
|
const translate = useI18n("Search");
|
|
273
273
|
|
|
274
|
-
return themeContext ? (
|
|
274
|
+
return themeContext?.isDarkside ? (
|
|
275
275
|
<Button
|
|
276
276
|
className={cn("navds-search__button-clear")}
|
|
277
277
|
variant="tertiary"
|
|
@@ -64,14 +64,14 @@ export const GuidePanel = forwardRef<HTMLDivElement, GuidePanelProps>(
|
|
|
64
64
|
>
|
|
65
65
|
<div className={cn("navds-guide")}>
|
|
66
66
|
{illustration ??
|
|
67
|
-
(themeContext ? (
|
|
67
|
+
(themeContext?.isDarkside ? (
|
|
68
68
|
<DarksideGudiepanelIllustration />
|
|
69
69
|
) : (
|
|
70
70
|
<DefaultIllustration />
|
|
71
71
|
))}
|
|
72
72
|
</div>
|
|
73
73
|
<div className={cn("navds-guide-panel__content")}>
|
|
74
|
-
{themeContext && (
|
|
74
|
+
{themeContext?.isDarkside && (
|
|
75
75
|
<svg
|
|
76
76
|
viewBox="0 0 33 22"
|
|
77
77
|
width="33"
|
|
@@ -96,7 +96,7 @@ export const GuidePanel = forwardRef<HTMLDivElement, GuidePanelProps>(
|
|
|
96
96
|
/>
|
|
97
97
|
</svg>
|
|
98
98
|
)}
|
|
99
|
-
{themeContext ? (
|
|
99
|
+
{themeContext?.isDarkside ? (
|
|
100
100
|
<div className={cn("navds-guide-panel__content-inner")}>
|
|
101
101
|
{children}
|
|
102
102
|
</div>
|
|
@@ -81,8 +81,8 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
81
81
|
anchorEl={buttonRef.current}
|
|
82
82
|
placement={placement}
|
|
83
83
|
strategy={strategy}
|
|
84
|
-
offset={themeContext ? 8 : 12}
|
|
85
|
-
arrow={!themeContext}
|
|
84
|
+
offset={themeContext?.isDarkside ? 8 : 12}
|
|
85
|
+
arrow={!themeContext?.isDarkside}
|
|
86
86
|
>
|
|
87
87
|
<Popover.Content className={cn("navds-body-short")}>
|
|
88
88
|
{children}
|
|
@@ -84,7 +84,7 @@ export const InternalHeader = forwardRef(({ className, ...rest }, ref) => {
|
|
|
84
84
|
/*
|
|
85
85
|
* Component is always in "dark" mode, so we manually override global theme.
|
|
86
86
|
*/
|
|
87
|
-
if (themeContext) {
|
|
87
|
+
if (themeContext?.isDarkside) {
|
|
88
88
|
return (
|
|
89
89
|
<Theme theme="dark" asChild hasBackground={false}>
|
|
90
90
|
<header
|
|
@@ -253,7 +253,7 @@ export const BasePrimitive = ({
|
|
|
253
253
|
}: BasePrimitiveProps) => {
|
|
254
254
|
const themeContext = useThemeInternal(false);
|
|
255
255
|
const { cn } = useRenameCSS();
|
|
256
|
-
const prefix = themeContext ? "ax" : "a";
|
|
256
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
257
257
|
|
|
258
258
|
const style: React.CSSProperties = {
|
|
259
259
|
/* Padding */
|
|
@@ -82,7 +82,7 @@ export const Bleed = forwardRef<HTMLDivElement, BleedProps>(
|
|
|
82
82
|
) => {
|
|
83
83
|
const themeContext = useThemeInternal(false);
|
|
84
84
|
const { cn } = useRenameCSS();
|
|
85
|
-
const prefix = themeContext ? "ax" : "a";
|
|
85
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
86
86
|
|
|
87
87
|
let style: React.CSSProperties = {
|
|
88
88
|
..._style,
|
package/src/layout/box/Box.tsx
CHANGED
|
@@ -113,7 +113,7 @@ export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
|
113
113
|
|
|
114
114
|
if (
|
|
115
115
|
process.env.NODE_ENV !== "production" &&
|
|
116
|
-
themeContext &&
|
|
116
|
+
themeContext?.isDarkside &&
|
|
117
117
|
(background || borderColor || shadow)
|
|
118
118
|
) {
|
|
119
119
|
let errorText = ``;
|
|
@@ -131,7 +131,7 @@ export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const prefix = themeContext ? "ax" : "a";
|
|
134
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
135
135
|
|
|
136
136
|
const style: React.CSSProperties = {
|
|
137
137
|
..._style,
|
|
@@ -173,8 +173,9 @@ export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
|
173
173
|
"navds-box-bg": background,
|
|
174
174
|
"navds-box-border-color": borderColor,
|
|
175
175
|
"navds-box-border-width": borderWidth,
|
|
176
|
-
"navds-box-border-radius":
|
|
177
|
-
|
|
176
|
+
"navds-box-border-radius":
|
|
177
|
+
borderRadius && !themeContext?.isDarkside,
|
|
178
|
+
"navds-box-radius": borderRadius && themeContext?.isDarkside,
|
|
178
179
|
"navds-box-shadow": shadow,
|
|
179
180
|
})}
|
|
180
181
|
>
|
|
@@ -78,7 +78,7 @@ export const HGrid: OverridableComponent<HGridProps, HTMLDivElement> =
|
|
|
78
78
|
ref,
|
|
79
79
|
) => {
|
|
80
80
|
const themeContext = useThemeInternal(false);
|
|
81
|
-
const prefix = themeContext ? "ax" : "a";
|
|
81
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
82
82
|
const { cn } = useRenameCSS();
|
|
83
83
|
|
|
84
84
|
const styles: React.CSSProperties = {
|
package/src/layout/page/Page.tsx
CHANGED
|
@@ -56,7 +56,11 @@ export const PageComponent: OverridableComponent<PageProps, HTMLElement> =
|
|
|
56
56
|
const themeContext = useThemeInternal(false);
|
|
57
57
|
const { cn } = useRenameCSS();
|
|
58
58
|
|
|
59
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
process.env.NODE_ENV !== "production" &&
|
|
61
|
+
themeContext?.isDarkside &&
|
|
62
|
+
background
|
|
63
|
+
) {
|
|
60
64
|
console.warn(
|
|
61
65
|
`Prop \`background\` is deprecated and cannot be used with theme-support. Instead wrap component with \`<Box asChild background>\``,
|
|
62
66
|
);
|
|
@@ -84,7 +84,7 @@ export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
|
|
|
84
84
|
ref,
|
|
85
85
|
) => {
|
|
86
86
|
const themeContext = useThemeInternal(false);
|
|
87
|
-
const prefix = themeContext ? "ax" : "a";
|
|
87
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
88
88
|
const { cn } = useRenameCSS();
|
|
89
89
|
|
|
90
90
|
const style: React.CSSProperties = {
|
package/src/link/Link.tsx
CHANGED
package/src/list/List.tsx
CHANGED
|
@@ -802,7 +802,7 @@ export const ActionMenuRadioItem = forwardRef<
|
|
|
802
802
|
fill="var(--ax-bg-default, var(--a-surface-default))"
|
|
803
803
|
/>
|
|
804
804
|
</g>
|
|
805
|
-
{themeContext ? (
|
|
805
|
+
{themeContext?.isDarkside ? (
|
|
806
806
|
<g className={cn("navds-action-menu__indicator-icon--checked")}>
|
|
807
807
|
<rect
|
|
808
808
|
width="24"
|