@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const INTERACTIVE_TAGS = new Set([
|
|
2
|
+
"BUTTON",
|
|
3
|
+
"A",
|
|
4
|
+
"INPUT",
|
|
5
|
+
"SELECT",
|
|
6
|
+
"TEXTAREA",
|
|
7
|
+
"DETAILS",
|
|
8
|
+
"SUMMARY",
|
|
9
|
+
"LABEL",
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const INTERACTIVE_ROLES = new Set([
|
|
13
|
+
"button",
|
|
14
|
+
"link",
|
|
15
|
+
"checkbox",
|
|
16
|
+
"radio",
|
|
17
|
+
"switch",
|
|
18
|
+
"menuitem",
|
|
19
|
+
"option",
|
|
20
|
+
"tab",
|
|
21
|
+
"textbox",
|
|
22
|
+
"combobox",
|
|
23
|
+
"spinbutton",
|
|
24
|
+
"slider",
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Walks up from the event target until TR/TH (row / header) or root.
|
|
29
|
+
* Returns true if any ancestor is inherently interactive, explicitly focusable,
|
|
30
|
+
* or has an interactive ARIA role.
|
|
31
|
+
* Used to decide whether a row click should be treated as a row selection
|
|
32
|
+
* or ignored because the user interacted with an embedded control.
|
|
33
|
+
*/
|
|
34
|
+
function isElementInteractiveTarget(element: HTMLElement | null) {
|
|
35
|
+
for (
|
|
36
|
+
let node: HTMLElement | null = element;
|
|
37
|
+
node && node.nodeName !== "TR" && node.nodeName !== "TH";
|
|
38
|
+
node = node.parentElement
|
|
39
|
+
) {
|
|
40
|
+
const tag = node.nodeName;
|
|
41
|
+
|
|
42
|
+
/* Native interactive tag */
|
|
43
|
+
if (INTERACTIVE_TAGS.has(tag)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Explicit interactive role */
|
|
48
|
+
const role = node.getAttribute("role");
|
|
49
|
+
if (role && INTERACTIVE_ROLES.has(role)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Focusable via tabindex (exclude -1) */
|
|
54
|
+
if (node.hasAttribute("tabindex")) {
|
|
55
|
+
const ti = node.getAttribute("tabindex");
|
|
56
|
+
if (ti !== "-1") {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { isElementInteractiveTarget };
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -45,6 +45,8 @@ const RenameCSS = ({ children }: { children: React.ReactNode }) => {
|
|
|
45
45
|
/* -------------------------------------------------------------------------- */
|
|
46
46
|
/* Theme provider */
|
|
47
47
|
/* -------------------------------------------------------------------------- */
|
|
48
|
+
const DEFAULT_COLOR: AkselColor = "accent";
|
|
49
|
+
|
|
48
50
|
type ThemeContext = {
|
|
49
51
|
/**
|
|
50
52
|
* Color theme
|
|
@@ -52,12 +54,21 @@ type ThemeContext = {
|
|
|
52
54
|
*/
|
|
53
55
|
theme?: "light" | "dark";
|
|
54
56
|
color?: AkselColor;
|
|
57
|
+
/**
|
|
58
|
+
* Indicates if Theme-component is used or not.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
isDarkside: boolean;
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
const [ThemeProvider, useThemeInternal] = createContext<ThemeContext>({
|
|
58
65
|
hookName: "useTheme",
|
|
59
66
|
name: "ThemeProvider",
|
|
60
67
|
providerName: "ThemeProvider",
|
|
68
|
+
defaultValue: {
|
|
69
|
+
color: DEFAULT_COLOR,
|
|
70
|
+
isDarkside: false,
|
|
71
|
+
},
|
|
61
72
|
});
|
|
62
73
|
|
|
63
74
|
export type ThemeProps = {
|
|
@@ -70,7 +81,7 @@ export type ThemeProps = {
|
|
|
70
81
|
* Sets default 'base'-color for application
|
|
71
82
|
*/
|
|
72
83
|
"data-color"?: AkselColor;
|
|
73
|
-
} & Omit<ThemeContext, "color"> &
|
|
84
|
+
} & Omit<ThemeContext, "color" | "isDarkside"> &
|
|
74
85
|
AsChildProps;
|
|
75
86
|
|
|
76
87
|
const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
@@ -86,7 +97,7 @@ const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
|
86
97
|
"data-color": color = context?.color,
|
|
87
98
|
} = props;
|
|
88
99
|
|
|
89
|
-
const isRoot = context
|
|
100
|
+
const isRoot = !context?.isDarkside;
|
|
90
101
|
|
|
91
102
|
const hasBackground =
|
|
92
103
|
hasBackgroundProp ?? (isRoot && props.theme !== undefined);
|
|
@@ -94,7 +105,7 @@ const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
|
94
105
|
const SlotElement = asChild ? Slot : "div";
|
|
95
106
|
|
|
96
107
|
return (
|
|
97
|
-
<ThemeProvider theme={theme} color={color}>
|
|
108
|
+
<ThemeProvider theme={theme} color={color} isDarkside={true}>
|
|
98
109
|
<RenameCSS>
|
|
99
110
|
<SlotElement
|
|
100
111
|
ref={ref}
|
package/src/timeline/Pin.tsx
CHANGED
|
@@ -49,7 +49,7 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
|
|
|
49
49
|
const translate = useI18n("Timeline");
|
|
50
50
|
|
|
51
51
|
const themeContext = useThemeInternal(false);
|
|
52
|
-
const showArrow = !themeContext;
|
|
52
|
+
const showArrow = !themeContext?.isDarkside;
|
|
53
53
|
|
|
54
54
|
const {
|
|
55
55
|
context,
|
|
@@ -84,7 +84,7 @@ export const ToggleGroup = forwardRef<HTMLDivElement, ToggleGroupProps>(
|
|
|
84
84
|
|
|
85
85
|
let localVariant: ToggleGroupProps["variant"] | undefined;
|
|
86
86
|
|
|
87
|
-
if (themeContext) {
|
|
87
|
+
if (themeContext?.isDarkside) {
|
|
88
88
|
localVariant = variant;
|
|
89
89
|
} else {
|
|
90
90
|
localVariant = variant ?? "action";
|