@navikt/ds-react 6.10.1 → 6.12.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/alert/Alert.d.ts +5 -0
- package/cjs/alert/Alert.js +5 -3
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/collapsible/parts/Collapsible.Content.js +1 -1
- package/cjs/collapsible/parts/Collapsible.Trigger.js +1 -1
- package/cjs/date/datepicker/types.d.ts +1 -1
- package/cjs/date/monthpicker/types.d.ts +1 -1
- package/cjs/form/file-upload/parts/Trigger.js +1 -1
- package/cjs/form/file-upload/parts/item/Item.d.ts +5 -0
- package/cjs/form/file-upload/parts/item/Item.js +2 -2
- package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.d.ts +167 -0
- package/cjs/layout/base/BasePrimitive.js +70 -0
- package/cjs/layout/base/BasePrimitive.js.map +1 -0
- package/cjs/layout/base/PrimitiveAsChildProps.d.ts +41 -0
- package/cjs/layout/base/PrimitiveAsChildProps.js +3 -0
- package/cjs/layout/base/PrimitiveAsChildProps.js.map +1 -0
- package/cjs/layout/bleed/Bleed.js +1 -1
- package/cjs/layout/box/Box.d.ts +14 -35
- package/cjs/layout/box/Box.js +15 -4
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/grid/HGrid.d.ts +7 -5
- package/cjs/layout/grid/HGrid.js +7 -2
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.d.ts +4 -3
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/responsive/Responsive.js +1 -1
- package/cjs/layout/stack/HStack.d.ts +2 -1
- package/cjs/layout/stack/HStack.js.map +1 -1
- package/cjs/layout/stack/Stack.d.ts +8 -5
- package/cjs/layout/stack/Stack.js +10 -5
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/layout/stack/VStack.d.ts +2 -1
- package/cjs/layout/stack/VStack.js.map +1 -1
- package/cjs/layout/utilities/css.js +3 -0
- package/cjs/layout/utilities/css.js.map +1 -1
- package/cjs/layout/utilities/types.d.ts +2 -1
- package/cjs/list/ListItem.js +2 -2
- package/cjs/list/ListItem.js.map +1 -1
- package/cjs/modal/dialog-polyfill.js +0 -3
- package/cjs/modal/dialog-polyfill.js.map +1 -1
- package/cjs/overlays/dismissablelayer/DismissableLayer.js +1 -1
- package/cjs/overlays/dismissablelayer/util/useFocusOutside.d.ts +2 -2
- package/cjs/overlays/dismissablelayer/util/useFocusOutside.js +6 -2
- package/cjs/overlays/dismissablelayer/util/useFocusOutside.js.map +1 -1
- package/cjs/overlays/dismissablelayer/util/usePointerDownOutside.d.ts +1 -1
- package/cjs/overlays/dismissablelayer/util/usePointerDownOutside.js +3 -1
- package/cjs/overlays/dismissablelayer/util/usePointerDownOutside.js.map +1 -1
- package/cjs/overlays/floating/Floating.js +1 -1
- package/cjs/pagination/Pagination.d.ts +7 -0
- package/cjs/pagination/Pagination.js +5 -2
- package/cjs/pagination/Pagination.js.map +1 -1
- package/cjs/pagination/PaginationItem.js +4 -2
- package/cjs/pagination/PaginationItem.js.map +1 -1
- package/cjs/portal/Portal.js +1 -1
- package/cjs/slot/Slot.d.ts +6 -0
- package/cjs/{util → slot}/Slot.js +6 -37
- package/cjs/slot/Slot.js.map +1 -0
- package/cjs/slot/merge-props.d.ts +4 -0
- package/cjs/slot/merge-props.js +37 -0
- package/cjs/slot/merge-props.js.map +1 -0
- package/cjs/toggle-group/ToggleGroup.d.ts +3 -3
- package/cjs/toggle-group/ToggleGroup.js +3 -3
- package/cjs/toggle-group/parts/ToggleItem.d.ts +32 -5
- package/cjs/toggle-group/parts/ToggleItem.js +4 -2
- package/cjs/toggle-group/parts/ToggleItem.js.map +1 -1
- package/cjs/toggle-group/parts/useToggleItem.js +1 -1
- package/cjs/toggle-group/parts/useToggleItem.js.map +1 -1
- package/cjs/util/hooks/descendants/useDescendant.js +1 -1
- package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
- package/cjs/util/hooks/descendants/utils.js +1 -1
- package/cjs/util/hooks/descendants/utils.js.map +1 -1
- package/cjs/util/i18n/get.js +3 -2
- package/cjs/util/i18n/get.js.map +1 -1
- package/cjs/util/types/AsChildProps.d.ts +1 -0
- package/esm/alert/Alert.d.ts +5 -0
- package/esm/alert/Alert.js +5 -3
- package/esm/alert/Alert.js.map +1 -1
- package/esm/collapsible/parts/Collapsible.Content.js +1 -1
- package/esm/collapsible/parts/Collapsible.Trigger.js +1 -1
- package/esm/date/datepicker/types.d.ts +1 -1
- package/esm/date/monthpicker/types.d.ts +1 -1
- package/esm/form/file-upload/parts/Trigger.js +1 -1
- package/esm/form/file-upload/parts/item/Item.d.ts +5 -0
- package/esm/form/file-upload/parts/item/Item.js +2 -2
- package/esm/form/file-upload/parts/item/Item.js.map +1 -1
- package/esm/layout/base/BasePrimitive.d.ts +167 -0
- package/esm/layout/base/BasePrimitive.js +63 -0
- package/esm/layout/base/BasePrimitive.js.map +1 -0
- package/esm/layout/base/PrimitiveAsChildProps.d.ts +41 -0
- package/esm/layout/base/PrimitiveAsChildProps.js +2 -0
- package/esm/layout/base/PrimitiveAsChildProps.js.map +1 -0
- package/esm/layout/bleed/Bleed.js +1 -1
- package/esm/layout/box/Box.d.ts +14 -35
- package/esm/layout/box/Box.js +15 -4
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.d.ts +7 -5
- package/esm/layout/grid/HGrid.js +7 -2
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.d.ts +4 -3
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/responsive/Responsive.js +1 -1
- package/esm/layout/stack/HStack.d.ts +2 -1
- package/esm/layout/stack/HStack.js.map +1 -1
- package/esm/layout/stack/Stack.d.ts +8 -5
- package/esm/layout/stack/Stack.js +10 -5
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/stack/VStack.d.ts +2 -1
- package/esm/layout/stack/VStack.js.map +1 -1
- package/esm/layout/utilities/css.js +3 -0
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +2 -1
- package/esm/list/ListItem.js +3 -3
- package/esm/list/ListItem.js.map +1 -1
- package/esm/modal/dialog-polyfill.js +0 -3
- package/esm/modal/dialog-polyfill.js.map +1 -1
- package/esm/overlays/dismissablelayer/DismissableLayer.js +1 -1
- package/esm/overlays/dismissablelayer/util/useFocusOutside.d.ts +2 -2
- package/esm/overlays/dismissablelayer/util/useFocusOutside.js +6 -2
- package/esm/overlays/dismissablelayer/util/useFocusOutside.js.map +1 -1
- package/esm/overlays/dismissablelayer/util/usePointerDownOutside.d.ts +1 -1
- package/esm/overlays/dismissablelayer/util/usePointerDownOutside.js +3 -1
- package/esm/overlays/dismissablelayer/util/usePointerDownOutside.js.map +1 -1
- package/esm/overlays/floating/Floating.js +1 -1
- package/esm/pagination/Pagination.d.ts +7 -0
- package/esm/pagination/Pagination.js +6 -3
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.js +4 -2
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/portal/Portal.js +1 -1
- package/esm/slot/Slot.d.ts +6 -0
- package/esm/slot/Slot.js +32 -0
- package/esm/slot/Slot.js.map +1 -0
- package/esm/slot/merge-props.d.ts +4 -0
- package/esm/slot/merge-props.js +34 -0
- package/esm/slot/merge-props.js.map +1 -0
- package/esm/toggle-group/ToggleGroup.d.ts +3 -3
- package/esm/toggle-group/ToggleGroup.js +3 -3
- package/esm/toggle-group/parts/ToggleItem.d.ts +32 -5
- package/esm/toggle-group/parts/ToggleItem.js +4 -2
- package/esm/toggle-group/parts/ToggleItem.js.map +1 -1
- package/esm/toggle-group/parts/useToggleItem.js +1 -1
- package/esm/toggle-group/parts/useToggleItem.js.map +1 -1
- package/esm/util/hooks/descendants/useDescendant.js +1 -1
- package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
- package/esm/util/hooks/descendants/utils.js +1 -1
- package/esm/util/hooks/descendants/utils.js.map +1 -1
- package/esm/util/i18n/get.js +3 -2
- package/esm/util/i18n/get.js.map +1 -1
- package/esm/util/types/AsChildProps.d.ts +1 -0
- package/package.json +3 -3
- package/src/alert/Alert.tsx +23 -2
- package/src/collapsible/parts/Collapsible.Content.tsx +1 -1
- package/src/collapsible/parts/Collapsible.Trigger.tsx +1 -1
- package/src/date/datepicker/types.ts +1 -1
- package/src/date/monthpicker/types.ts +1 -1
- package/src/form/file-upload/parts/Trigger.tsx +1 -1
- package/src/form/file-upload/parts/item/Item.tsx +7 -1
- package/src/layout/base/BasePrimitive.tsx +314 -0
- package/src/layout/base/PrimitiveAsChildProps.ts +42 -0
- package/src/layout/bleed/Bleed.tsx +1 -1
- package/src/layout/box/Box.tsx +66 -76
- package/src/layout/grid/HGrid.tsx +73 -45
- package/src/layout/page/Page.tsx +4 -3
- package/src/layout/responsive/Responsive.tsx +1 -1
- package/src/layout/stack/HStack.tsx +2 -1
- package/src/layout/stack/Stack.tsx +80 -62
- package/src/layout/stack/VStack.tsx +3 -1
- package/src/layout/utilities/css.ts +3 -0
- package/src/layout/utilities/types.ts +2 -3
- package/src/list/ListItem.tsx +5 -5
- package/src/modal/dialog-polyfill.ts +0 -3
- package/src/overlays/dismissablelayer/DismissableLayer.tsx +1 -1
- package/src/overlays/dismissablelayer/util/useFocusOutside.ts +6 -2
- package/src/overlays/dismissablelayer/util/usePointerDownOutside.ts +3 -1
- package/src/overlays/floating/Floating.tsx +1 -1
- package/src/pagination/Pagination.tsx +26 -1
- package/src/pagination/PaginationItem.tsx +4 -0
- package/src/portal/Portal.tsx +1 -1
- package/src/slot/Slot.tsx +33 -0
- package/src/{util/Slot.tsx → slot/merge-props.ts} +2 -34
- package/src/slot/tests/merge-props.test.ts +49 -0
- package/src/toggle-group/ToggleGroup.test.tsx +3 -9
- package/src/toggle-group/ToggleGroup.tsx +3 -3
- package/src/toggle-group/parts/ToggleItem.tsx +54 -8
- package/src/toggle-group/parts/useToggleItem.ts +4 -1
- package/src/util/hooks/descendants/useDescendant.tsx +1 -1
- package/src/util/hooks/descendants/utils.ts +1 -1
- package/src/util/i18n/get.ts +4 -2
- package/src/util/types/AsChildProps.ts +1 -0
- package/cjs/layout/sidemal-test/AvatarPanel.d.ts +0 -4
- package/cjs/layout/sidemal-test/AvatarPanel.js +0 -19
- package/cjs/layout/sidemal-test/AvatarPanel.js.map +0 -1
- package/cjs/layout/sidemal-test/Content.d.ts +0 -2
- package/cjs/layout/sidemal-test/Content.js +0 -67
- package/cjs/layout/sidemal-test/Content.js.map +0 -1
- package/cjs/layout/sidemal-test/Filter.d.ts +0 -2
- package/cjs/layout/sidemal-test/Filter.js +0 -49
- package/cjs/layout/sidemal-test/Filter.js.map +0 -1
- package/cjs/layout/sidemal-test/Header.d.ts +0 -2
- package/cjs/layout/sidemal-test/Header.js +0 -49
- package/cjs/layout/sidemal-test/Header.js.map +0 -1
- package/cjs/layout/sidemal-test/Intro.d.ts +0 -2
- package/cjs/layout/sidemal-test/Intro.js +0 -37
- package/cjs/layout/sidemal-test/Intro.js.map +0 -1
- package/cjs/layout/sidemal-test/Sidebar.d.ts +0 -4
- package/cjs/layout/sidemal-test/Sidebar.js +0 -50
- package/cjs/layout/sidemal-test/Sidebar.js.map +0 -1
- package/cjs/layout/sidemal-test/content-box/ContentBox.d.ts +0 -8
- package/cjs/layout/sidemal-test/content-box/ContentBox.js +0 -66
- package/cjs/layout/sidemal-test/content-box/ContentBox.js.map +0 -1
- package/cjs/layout/sidemal-test/content-box/index.d.ts +0 -1
- package/cjs/layout/sidemal-test/content-box/index.js +0 -9
- package/cjs/layout/sidemal-test/content-box/index.js.map +0 -1
- package/cjs/util/Slot.d.ts +0 -6
- package/cjs/util/Slot.js.map +0 -1
- package/esm/layout/sidemal-test/AvatarPanel.d.ts +0 -4
- package/esm/layout/sidemal-test/AvatarPanel.js +0 -12
- package/esm/layout/sidemal-test/AvatarPanel.js.map +0 -1
- package/esm/layout/sidemal-test/Content.d.ts +0 -2
- package/esm/layout/sidemal-test/Content.js +0 -60
- package/esm/layout/sidemal-test/Content.js.map +0 -1
- package/esm/layout/sidemal-test/Filter.d.ts +0 -2
- package/esm/layout/sidemal-test/Filter.js +0 -22
- package/esm/layout/sidemal-test/Filter.js.map +0 -1
- package/esm/layout/sidemal-test/Header.d.ts +0 -2
- package/esm/layout/sidemal-test/Header.js +0 -42
- package/esm/layout/sidemal-test/Header.js.map +0 -1
- package/esm/layout/sidemal-test/Intro.d.ts +0 -2
- package/esm/layout/sidemal-test/Intro.js +0 -30
- package/esm/layout/sidemal-test/Intro.js.map +0 -1
- package/esm/layout/sidemal-test/Sidebar.d.ts +0 -4
- package/esm/layout/sidemal-test/Sidebar.js +0 -41
- package/esm/layout/sidemal-test/Sidebar.js.map +0 -1
- package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +0 -8
- package/esm/layout/sidemal-test/content-box/ContentBox.js +0 -37
- package/esm/layout/sidemal-test/content-box/ContentBox.js.map +0 -1
- package/esm/layout/sidemal-test/content-box/index.d.ts +0 -1
- package/esm/layout/sidemal-test/content-box/index.js +0 -2
- package/esm/layout/sidemal-test/content-box/index.js.map +0 -1
- package/esm/util/Slot.d.ts +0 -6
- package/esm/util/Slot.js +0 -63
- package/esm/util/Slot.js.map +0 -1
- package/src/layout/sidemal-test/AvatarPanel.tsx +0 -27
- package/src/layout/sidemal-test/Content.tsx +0 -129
- package/src/layout/sidemal-test/Filter.tsx +0 -46
- package/src/layout/sidemal-test/Header.tsx +0 -96
- package/src/layout/sidemal-test/Intro.tsx +0 -91
- package/src/layout/sidemal-test/Sidebar.tsx +0 -77
- package/src/layout/sidemal-test/content-box/ContentBox.tsx +0 -46
- package/src/layout/sidemal-test/content-box/index.ts +0 -1
- package/src/layout/sidemal-test/styling.css +0 -43
- /package/src/{util/__tests__ → slot/tests}/Slot.test.tsx +0 -0
package/src/layout/box/Box.tsx
CHANGED
|
@@ -1,78 +1,60 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { Slot } from "../../slot/Slot";
|
|
4
|
+
import { omit } from "../../util";
|
|
3
5
|
import { OverridableComponent } from "../../util/types";
|
|
6
|
+
import BasePrimitive, {
|
|
7
|
+
PRIMITIVE_PROPS,
|
|
8
|
+
PrimitiveProps,
|
|
9
|
+
} from "../base/BasePrimitive";
|
|
10
|
+
import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
|
|
4
11
|
import { getResponsiveProps } from "../utilities/css";
|
|
5
12
|
import {
|
|
6
|
-
|
|
13
|
+
BackgroundColorToken,
|
|
7
14
|
BorderColorToken,
|
|
8
15
|
BorderRadiiToken,
|
|
9
16
|
ResponsiveProp,
|
|
10
17
|
ShadowToken,
|
|
11
18
|
SpaceDelimitedAttribute,
|
|
12
|
-
|
|
19
|
+
SurfaceColorToken,
|
|
13
20
|
} from "../utilities/types";
|
|
14
21
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
* paddingInline='4'
|
|
52
|
-
* paddingInline='4 5'
|
|
53
|
-
* paddingInline={{xs: '0 32', sm: '3', md: '4 5', lg: '5', xl: '6'}}
|
|
54
|
-
*/
|
|
55
|
-
paddingInline?: ResponsiveProp<
|
|
56
|
-
SpacingScale | `${SpacingScale} ${SpacingScale}`
|
|
57
|
-
>;
|
|
58
|
-
/**
|
|
59
|
-
* Vertical padding around children.
|
|
60
|
-
* Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
|
|
61
|
-
* or an object of spacing tokens for different breakpoints.
|
|
62
|
-
* @example
|
|
63
|
-
* paddingBlock='4'
|
|
64
|
-
* paddingBlock='4 5'
|
|
65
|
-
* paddingBlock={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
|
|
66
|
-
*/
|
|
67
|
-
paddingBlock?: ResponsiveProp<
|
|
68
|
-
SpacingScale | `${SpacingScale} ${SpacingScale}`
|
|
69
|
-
>;
|
|
70
|
-
/** Shadow on box. Accepts a shadow token.
|
|
71
|
-
* @example
|
|
72
|
-
* shadow='small'
|
|
73
|
-
*/
|
|
74
|
-
shadow?: ShadowToken;
|
|
75
|
-
}
|
|
22
|
+
export type BoxProps = PrimitiveProps &
|
|
23
|
+
PrimitiveAsChildProps &
|
|
24
|
+
React.HTMLAttributes<HTMLDivElement> & {
|
|
25
|
+
/**
|
|
26
|
+
* CSS `background-color` property.
|
|
27
|
+
* Accepts a [background/surface color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#afff774dad80).
|
|
28
|
+
*/
|
|
29
|
+
background?: BackgroundColorToken | SurfaceColorToken;
|
|
30
|
+
/**
|
|
31
|
+
* CSS `border-color` property.
|
|
32
|
+
* Accepts a [border color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#adb1767e2f87).
|
|
33
|
+
*/
|
|
34
|
+
borderColor?: BorderColorToken;
|
|
35
|
+
/**
|
|
36
|
+
* CSS `border-radius` property.
|
|
37
|
+
* Accepts a [radius token](https://aksel.nav.no/grunnleggende/styling/design-tokens#6d79c5605d31)
|
|
38
|
+
* or an object of radius tokens for different breakpoints.
|
|
39
|
+
* @example
|
|
40
|
+
* borderRadius='full'
|
|
41
|
+
* borderRadius='0 full large small'
|
|
42
|
+
* borderRadius={{xs: 'small large', sm: '0', md: 'large', lg: 'full'}}
|
|
43
|
+
*/
|
|
44
|
+
borderRadius?: ResponsiveProp<SpaceDelimitedAttribute<BorderRadiiToken>>;
|
|
45
|
+
/**
|
|
46
|
+
* CSS `border-width` property. If this is not set there will be no border.
|
|
47
|
+
* @example
|
|
48
|
+
* borderWidth='2'
|
|
49
|
+
* borderWidth='1 2 3 4'
|
|
50
|
+
*/
|
|
51
|
+
borderWidth?: SpaceDelimitedAttribute<"0" | "1" | "2" | "3" | "4" | "5">;
|
|
52
|
+
/** Shadow on box. Accepts a shadow token.
|
|
53
|
+
* @example
|
|
54
|
+
* shadow='small'
|
|
55
|
+
*/
|
|
56
|
+
shadow?: ShadowToken;
|
|
57
|
+
};
|
|
76
58
|
|
|
77
59
|
/**
|
|
78
60
|
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
@@ -104,17 +86,16 @@ export interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
104
86
|
export const Box: OverridableComponent<BoxProps, HTMLDivElement> = forwardRef(
|
|
105
87
|
(
|
|
106
88
|
{
|
|
89
|
+
children,
|
|
90
|
+
className,
|
|
107
91
|
as: Component = "div",
|
|
108
92
|
background,
|
|
109
93
|
borderColor,
|
|
110
94
|
borderWidth,
|
|
111
95
|
borderRadius,
|
|
112
|
-
className,
|
|
113
|
-
padding,
|
|
114
|
-
paddingInline,
|
|
115
|
-
paddingBlock,
|
|
116
96
|
shadow,
|
|
117
97
|
style: _style,
|
|
98
|
+
asChild,
|
|
118
99
|
...rest
|
|
119
100
|
},
|
|
120
101
|
ref,
|
|
@@ -142,18 +123,27 @@ export const Box: OverridableComponent<BoxProps, HTMLDivElement> = forwardRef(
|
|
|
142
123
|
false,
|
|
143
124
|
["0"],
|
|
144
125
|
),
|
|
145
|
-
...getResponsiveProps("box", "padding", "spacing", padding),
|
|
146
|
-
...getResponsiveProps("box", "padding-inline", "spacing", paddingInline),
|
|
147
|
-
...getResponsiveProps("box", "padding-block", "spacing", paddingBlock),
|
|
148
126
|
};
|
|
149
127
|
|
|
128
|
+
const Comp = asChild ? Slot : Component;
|
|
129
|
+
|
|
150
130
|
return (
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
131
|
+
<BasePrimitive {...rest}>
|
|
132
|
+
<Comp
|
|
133
|
+
{...omit(rest, PRIMITIVE_PROPS)}
|
|
134
|
+
ref={ref}
|
|
135
|
+
style={style}
|
|
136
|
+
className={cl("navds-box", className, {
|
|
137
|
+
"navds-box-bg": background,
|
|
138
|
+
"navds-box-border-color": borderColor,
|
|
139
|
+
"navds-box-border-width": borderWidth,
|
|
140
|
+
"navds-box-border-radius": borderRadius,
|
|
141
|
+
"navds-box-shadow": shadow,
|
|
142
|
+
})}
|
|
143
|
+
>
|
|
144
|
+
{children}
|
|
145
|
+
</Comp>
|
|
146
|
+
</BasePrimitive>
|
|
157
147
|
);
|
|
158
148
|
},
|
|
159
149
|
);
|
|
@@ -1,34 +1,42 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { Slot } from "../../slot/Slot";
|
|
4
|
+
import { OverridableComponent, omit } from "../../util";
|
|
5
|
+
import BasePrimitive, {
|
|
6
|
+
PRIMITIVE_PROPS,
|
|
7
|
+
PrimitiveProps,
|
|
8
|
+
} from "../base/BasePrimitive";
|
|
9
|
+
import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
|
|
3
10
|
import { getResponsiveProps, getResponsiveValue } from "../utilities/css";
|
|
4
11
|
import { ResponsiveProp, SpacingScale } from "../utilities/types";
|
|
5
12
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
export type HGridProps = PrimitiveProps &
|
|
14
|
+
PrimitiveAsChildProps &
|
|
15
|
+
React.HTMLAttributes<HTMLDivElement> & {
|
|
16
|
+
/**
|
|
17
|
+
* Number of columns to display. Can be a number, a string, or an object with values for specific breakpoints.
|
|
18
|
+
* Sets `grid-template-columns`, so `fr`, `minmax` etc. works.
|
|
19
|
+
* @example
|
|
20
|
+
* columns={{ sm: 1, md: 1, lg: "1fr auto", xl: "1fr auto"}}
|
|
21
|
+
* columns={3}
|
|
22
|
+
* columns="repeat(3, minmax(0, 1fr))"
|
|
23
|
+
*/
|
|
24
|
+
columns?: ResponsiveProp<number | string>;
|
|
25
|
+
/**
|
|
26
|
+
* Spacing between columns.
|
|
27
|
+
* Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
|
|
28
|
+
* or an object of spacing tokens for different breakpoints.
|
|
29
|
+
* @example
|
|
30
|
+
* gap="6"
|
|
31
|
+
* gap="8 4"
|
|
32
|
+
* gap={{ sm: "2", md: "2", lg: "6", xl: "6"}}
|
|
33
|
+
*/
|
|
34
|
+
gap?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
|
|
35
|
+
/**
|
|
36
|
+
* Vertical alignment of children. Elements will by default stretch to the height of parent-element.
|
|
37
|
+
*/
|
|
38
|
+
align?: "start" | "center" | "end";
|
|
39
|
+
};
|
|
32
40
|
/**
|
|
33
41
|
* Horizontal Grid Primitive with dynamic columns and gap based on breakpoints.
|
|
34
42
|
*
|
|
@@ -54,25 +62,45 @@ export interface HGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
54
62
|
* <div />
|
|
55
63
|
* </HGrid>
|
|
56
64
|
*/
|
|
57
|
-
export const HGrid
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
export const HGrid: OverridableComponent<HGridProps, HTMLDivElement> =
|
|
66
|
+
forwardRef(
|
|
67
|
+
(
|
|
68
|
+
{
|
|
69
|
+
children,
|
|
70
|
+
className,
|
|
71
|
+
as: Component = "div",
|
|
72
|
+
columns,
|
|
73
|
+
gap,
|
|
74
|
+
style,
|
|
75
|
+
align,
|
|
76
|
+
asChild,
|
|
77
|
+
...rest
|
|
78
|
+
},
|
|
79
|
+
ref,
|
|
80
|
+
) => {
|
|
81
|
+
const styles: React.CSSProperties = {
|
|
82
|
+
...style,
|
|
83
|
+
"--__ac-hgrid-align": align,
|
|
84
|
+
...getResponsiveProps(`hgrid`, "gap", "spacing", gap),
|
|
85
|
+
...getResponsiveValue(`hgrid`, "columns", formatGrid(columns)),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const Comp = asChild ? Slot : Component;
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
90
|
+
return (
|
|
91
|
+
<BasePrimitive {...rest}>
|
|
92
|
+
<Comp
|
|
93
|
+
{...omit(rest, PRIMITIVE_PROPS)}
|
|
94
|
+
ref={ref}
|
|
95
|
+
className={cl("navds-hgrid", className)}
|
|
96
|
+
style={styles}
|
|
97
|
+
>
|
|
98
|
+
{children}
|
|
99
|
+
</Comp>
|
|
100
|
+
</BasePrimitive>
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
);
|
|
76
104
|
|
|
77
105
|
function formatGrid(
|
|
78
106
|
props?: ResponsiveProp<number | string>,
|
package/src/layout/page/Page.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
-
import bgColors from "@navikt/ds-tokens/src/colors-bg.json";
|
|
4
3
|
import { OverridableComponent } from "../../util";
|
|
4
|
+
import { BackgroundColorToken } from "../utilities/types";
|
|
5
5
|
import { PageBlock } from "./parts/PageBlock";
|
|
6
6
|
|
|
7
7
|
export interface PageProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -11,10 +11,11 @@ export interface PageProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
11
11
|
*/
|
|
12
12
|
as?: "div" | "body";
|
|
13
13
|
/**
|
|
14
|
-
* Background color.
|
|
14
|
+
* Background color.
|
|
15
|
+
* Accepts a [background color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#753d1cf4d1d6).
|
|
15
16
|
* @default "bg-default"
|
|
16
17
|
*/
|
|
17
|
-
background?:
|
|
18
|
+
background?: BackgroundColorToken;
|
|
18
19
|
/**
|
|
19
20
|
* Allows better positioning of footer
|
|
20
21
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { HTMLAttributes, forwardRef } from "react";
|
|
3
|
-
import { Slot } from "../../
|
|
3
|
+
import { Slot } from "../../slot/Slot";
|
|
4
4
|
import { BreakpointsAlias } from "../utilities/types";
|
|
5
5
|
|
|
6
6
|
export interface ResponsiveProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { OverridableComponent } from "../../util/types";
|
|
3
|
+
import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
|
|
3
4
|
import { Stack, StackProps } from "./Stack";
|
|
4
5
|
|
|
5
|
-
export type HStackProps = Omit<StackProps, "direction">;
|
|
6
|
+
export type HStackProps = PrimitiveAsChildProps & Omit<StackProps, "direction">;
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Layout-primitive for horizontal flexbox
|
|
@@ -1,73 +1,85 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { HTMLAttributes, forwardRef } from "react";
|
|
3
|
+
import { Slot } from "../../slot/Slot";
|
|
4
|
+
import { omit } from "../../util";
|
|
3
5
|
import { OverridableComponent } from "../../util/types";
|
|
6
|
+
import BasePrimitive, {
|
|
7
|
+
PRIMITIVE_PROPS,
|
|
8
|
+
PrimitiveProps,
|
|
9
|
+
} from "../base/BasePrimitive";
|
|
10
|
+
import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
|
|
4
11
|
import { getResponsiveProps, getResponsiveValue } from "../utilities/css";
|
|
5
12
|
import { ResponsiveProp, SpacingScale } from "../utilities/types";
|
|
6
13
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
14
|
+
export type StackProps = PrimitiveProps &
|
|
15
|
+
PrimitiveAsChildProps &
|
|
16
|
+
HTMLAttributes<HTMLDivElement> & {
|
|
17
|
+
/**
|
|
18
|
+
* CSS `justify-content` property.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* justify='center'
|
|
22
|
+
* justify={{xs: 'start', sm: 'center', md: 'end', lg: 'space-around', xl: 'space-between'}}
|
|
23
|
+
*/
|
|
24
|
+
justify?: ResponsiveProp<
|
|
25
|
+
| "start"
|
|
26
|
+
| "center"
|
|
27
|
+
| "end"
|
|
28
|
+
| "space-around"
|
|
29
|
+
| "space-between"
|
|
30
|
+
| "space-evenly"
|
|
31
|
+
>;
|
|
32
|
+
/**
|
|
33
|
+
* CSS `align-items` property.
|
|
34
|
+
* @default "stretch"
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* align='center'
|
|
38
|
+
* align={{xs: 'start', sm: 'center', md: 'end', lg: 'baseline', xl: 'stretch'}}
|
|
39
|
+
*/
|
|
40
|
+
align?: ResponsiveProp<"start" | "center" | "end" | "baseline" | "stretch">;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the CSS `flex-wrap` property.
|
|
43
|
+
*/
|
|
44
|
+
wrap?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* CSS `gap` property.
|
|
47
|
+
* Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
|
|
48
|
+
* or an object of spacing tokens for different breakpoints.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* gap='4'
|
|
52
|
+
* gap='8 4'
|
|
53
|
+
* gap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
|
|
54
|
+
*/
|
|
55
|
+
gap?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
|
|
56
|
+
/**
|
|
57
|
+
* CSS `flex-direction` property.
|
|
58
|
+
* @default "row"
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* direction='row'
|
|
62
|
+
* direction={{xs: 'row', sm: 'column'}}
|
|
63
|
+
*/
|
|
64
|
+
direction?: ResponsiveProp<
|
|
65
|
+
"row" | "column" | "row-reverse" | "column-reverse"
|
|
66
|
+
>;
|
|
67
|
+
};
|
|
58
68
|
|
|
59
69
|
export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
|
|
60
70
|
forwardRef(
|
|
61
71
|
(
|
|
62
72
|
{
|
|
63
|
-
|
|
73
|
+
children,
|
|
64
74
|
className,
|
|
65
|
-
|
|
75
|
+
as: Component = "div",
|
|
76
|
+
align = "stretch",
|
|
66
77
|
justify,
|
|
67
78
|
wrap = true,
|
|
68
79
|
gap,
|
|
69
80
|
style: _style,
|
|
70
81
|
direction = "row",
|
|
82
|
+
asChild,
|
|
71
83
|
...rest
|
|
72
84
|
},
|
|
73
85
|
ref,
|
|
@@ -81,16 +93,22 @@ export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
|
|
|
81
93
|
...getResponsiveValue(`stack`, "justify", justify),
|
|
82
94
|
};
|
|
83
95
|
|
|
96
|
+
const Comp = asChild ? Slot : Component;
|
|
97
|
+
|
|
84
98
|
return (
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"navds-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
<BasePrimitive {...rest}>
|
|
100
|
+
<Comp
|
|
101
|
+
{...omit(rest, PRIMITIVE_PROPS)}
|
|
102
|
+
ref={ref}
|
|
103
|
+
style={style}
|
|
104
|
+
className={cl("navds-stack", className, {
|
|
105
|
+
"navds-vstack": direction === "column",
|
|
106
|
+
"navds-hstack": direction === "row",
|
|
107
|
+
})}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</Comp>
|
|
111
|
+
</BasePrimitive>
|
|
94
112
|
);
|
|
95
113
|
},
|
|
96
114
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { OverridableComponent } from "../../util/types";
|
|
3
|
+
import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
|
|
3
4
|
import { Stack, StackProps } from "./Stack";
|
|
4
5
|
|
|
5
|
-
export type VStackProps =
|
|
6
|
+
export type VStackProps = PrimitiveAsChildProps &
|
|
7
|
+
Omit<StackProps, "direction" | "wrap">;
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Layout-primitive for vetical flexbox
|
|
@@ -50,6 +50,9 @@ const translateTokenStringToCSS = (
|
|
|
50
50
|
const width = 100 / arr.length;
|
|
51
51
|
return `calc((100vw - ${width}%)/2)`;
|
|
52
52
|
}
|
|
53
|
+
if (["mi", "mb"].includes(componentProp) && x === "auto") {
|
|
54
|
+
return "auto";
|
|
55
|
+
}
|
|
53
56
|
|
|
54
57
|
let output = `var(--a-${tokenSubgroup}-${x})`;
|
|
55
58
|
if (tokenExceptions.includes(x)) {
|
|
@@ -5,9 +5,8 @@ import surfaceColors from "@navikt/ds-tokens/src/colors-surface.json";
|
|
|
5
5
|
import shadows from "@navikt/ds-tokens/src/shadow.json";
|
|
6
6
|
import Spacing from "@navikt/ds-tokens/src/spacing.json";
|
|
7
7
|
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
| keyof typeof surfaceColors.a;
|
|
8
|
+
export type BackgroundColorToken = keyof typeof bgColors.a;
|
|
9
|
+
export type SurfaceColorToken = keyof typeof surfaceColors.a;
|
|
11
10
|
export type BorderColorToken = keyof typeof borderColors.a;
|
|
12
11
|
export type BorderRadiiToken =
|
|
13
12
|
| keyof (typeof borderRadii.a)["border-radius"]
|
package/src/list/ListItem.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { BodyLong } from "../typography";
|
|
4
4
|
import { ListContext } from "./context";
|
|
5
5
|
import { ListItemProps } from "./types";
|
|
6
6
|
|
|
@@ -45,14 +45,14 @@ export const ListItem = forwardRef<HTMLLIElement, ListItemProps>(
|
|
|
45
45
|
</div>
|
|
46
46
|
)}
|
|
47
47
|
|
|
48
|
-
<
|
|
48
|
+
<BodyLong as="div" size={size} className="navds-list__item-content">
|
|
49
49
|
{title && (
|
|
50
|
-
<
|
|
50
|
+
<BodyLong as="p" size={size} weight="semibold">
|
|
51
51
|
{title}
|
|
52
|
-
</
|
|
52
|
+
</BodyLong>
|
|
53
53
|
)}
|
|
54
54
|
{children}
|
|
55
|
-
</
|
|
55
|
+
</BodyLong>
|
|
56
56
|
</li>
|
|
57
57
|
);
|
|
58
58
|
},
|
|
@@ -631,7 +631,6 @@ dialogPolyfill.DialogManager = function () {
|
|
|
631
631
|
this.mo_ = new MutationObserver(function (records) {
|
|
632
632
|
var removed = [];
|
|
633
633
|
records.forEach(function (rec) {
|
|
634
|
-
// biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type c in this scenario
|
|
635
634
|
for (var i = 0, c; (c = rec.removedNodes[i]); ++i) {
|
|
636
635
|
if (!(c instanceof Element)) {
|
|
637
636
|
continue;
|
|
@@ -679,7 +678,6 @@ dialogPolyfill.DialogManager.prototype.unblockDocument = function () {
|
|
|
679
678
|
dialogPolyfill.DialogManager.prototype.updateStacking = function () {
|
|
680
679
|
var zIndex = this.zIndexHigh_;
|
|
681
680
|
|
|
682
|
-
// biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type dpi in this scenario
|
|
683
681
|
for (var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i) {
|
|
684
682
|
dpi.updateZIndex(--zIndex, --zIndex);
|
|
685
683
|
if (i === 0) {
|
|
@@ -705,7 +703,6 @@ dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function (
|
|
|
705
703
|
candidate,
|
|
706
704
|
) {
|
|
707
705
|
while ((candidate = findNearestDialog(candidate))) {
|
|
708
|
-
// biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type dpi in this scenario
|
|
709
706
|
for (var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i) {
|
|
710
707
|
if (dpi.dialog === candidate) {
|
|
711
708
|
return i === 0; // only valid if top-most
|
|
@@ -5,7 +5,7 @@ import React, {
|
|
|
5
5
|
useRef,
|
|
6
6
|
useState,
|
|
7
7
|
} from "react";
|
|
8
|
-
import { Slot } from "../../
|
|
8
|
+
import { Slot } from "../../slot/Slot";
|
|
9
9
|
import { useMergeRefs } from "../../util/hooks";
|
|
10
10
|
import { createDescendantContext } from "../../util/hooks/descendants/useDescendant";
|
|
11
11
|
import { AsChild } from "../../util/types/AsChild";
|
|
@@ -46,7 +46,11 @@ export function useFocusOutside(
|
|
|
46
46
|
* we can eliminate the need for DOM traversal to verify if the focused element is within the react tree.
|
|
47
47
|
*/
|
|
48
48
|
return {
|
|
49
|
-
onFocusCapture: () =>
|
|
50
|
-
|
|
49
|
+
onFocusCapture: () => {
|
|
50
|
+
isFocusInsideReactTreeRef.current = true;
|
|
51
|
+
},
|
|
52
|
+
onBlurCapture: () => {
|
|
53
|
+
isFocusInsideReactTreeRef.current = false;
|
|
54
|
+
},
|
|
51
55
|
};
|
|
52
56
|
}
|