@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.
Files changed (253) hide show
  1. package/cjs/alert/Alert.d.ts +5 -0
  2. package/cjs/alert/Alert.js +5 -3
  3. package/cjs/alert/Alert.js.map +1 -1
  4. package/cjs/collapsible/parts/Collapsible.Content.js +1 -1
  5. package/cjs/collapsible/parts/Collapsible.Trigger.js +1 -1
  6. package/cjs/date/datepicker/types.d.ts +1 -1
  7. package/cjs/date/monthpicker/types.d.ts +1 -1
  8. package/cjs/form/file-upload/parts/Trigger.js +1 -1
  9. package/cjs/form/file-upload/parts/item/Item.d.ts +5 -0
  10. package/cjs/form/file-upload/parts/item/Item.js +2 -2
  11. package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
  12. package/cjs/layout/base/BasePrimitive.d.ts +167 -0
  13. package/cjs/layout/base/BasePrimitive.js +70 -0
  14. package/cjs/layout/base/BasePrimitive.js.map +1 -0
  15. package/cjs/layout/base/PrimitiveAsChildProps.d.ts +41 -0
  16. package/cjs/layout/base/PrimitiveAsChildProps.js +3 -0
  17. package/cjs/layout/base/PrimitiveAsChildProps.js.map +1 -0
  18. package/cjs/layout/bleed/Bleed.js +1 -1
  19. package/cjs/layout/box/Box.d.ts +14 -35
  20. package/cjs/layout/box/Box.js +15 -4
  21. package/cjs/layout/box/Box.js.map +1 -1
  22. package/cjs/layout/grid/HGrid.d.ts +7 -5
  23. package/cjs/layout/grid/HGrid.js +7 -2
  24. package/cjs/layout/grid/HGrid.js.map +1 -1
  25. package/cjs/layout/page/Page.d.ts +4 -3
  26. package/cjs/layout/page/Page.js.map +1 -1
  27. package/cjs/layout/responsive/Responsive.js +1 -1
  28. package/cjs/layout/stack/HStack.d.ts +2 -1
  29. package/cjs/layout/stack/HStack.js.map +1 -1
  30. package/cjs/layout/stack/Stack.d.ts +8 -5
  31. package/cjs/layout/stack/Stack.js +10 -5
  32. package/cjs/layout/stack/Stack.js.map +1 -1
  33. package/cjs/layout/stack/VStack.d.ts +2 -1
  34. package/cjs/layout/stack/VStack.js.map +1 -1
  35. package/cjs/layout/utilities/css.js +3 -0
  36. package/cjs/layout/utilities/css.js.map +1 -1
  37. package/cjs/layout/utilities/types.d.ts +2 -1
  38. package/cjs/list/ListItem.js +2 -2
  39. package/cjs/list/ListItem.js.map +1 -1
  40. package/cjs/modal/dialog-polyfill.js +0 -3
  41. package/cjs/modal/dialog-polyfill.js.map +1 -1
  42. package/cjs/overlays/dismissablelayer/DismissableLayer.js +1 -1
  43. package/cjs/overlays/dismissablelayer/util/useFocusOutside.d.ts +2 -2
  44. package/cjs/overlays/dismissablelayer/util/useFocusOutside.js +6 -2
  45. package/cjs/overlays/dismissablelayer/util/useFocusOutside.js.map +1 -1
  46. package/cjs/overlays/dismissablelayer/util/usePointerDownOutside.d.ts +1 -1
  47. package/cjs/overlays/dismissablelayer/util/usePointerDownOutside.js +3 -1
  48. package/cjs/overlays/dismissablelayer/util/usePointerDownOutside.js.map +1 -1
  49. package/cjs/overlays/floating/Floating.js +1 -1
  50. package/cjs/pagination/Pagination.d.ts +7 -0
  51. package/cjs/pagination/Pagination.js +5 -2
  52. package/cjs/pagination/Pagination.js.map +1 -1
  53. package/cjs/pagination/PaginationItem.js +4 -2
  54. package/cjs/pagination/PaginationItem.js.map +1 -1
  55. package/cjs/portal/Portal.js +1 -1
  56. package/cjs/slot/Slot.d.ts +6 -0
  57. package/cjs/{util → slot}/Slot.js +6 -37
  58. package/cjs/slot/Slot.js.map +1 -0
  59. package/cjs/slot/merge-props.d.ts +4 -0
  60. package/cjs/slot/merge-props.js +37 -0
  61. package/cjs/slot/merge-props.js.map +1 -0
  62. package/cjs/toggle-group/ToggleGroup.d.ts +3 -3
  63. package/cjs/toggle-group/ToggleGroup.js +3 -3
  64. package/cjs/toggle-group/parts/ToggleItem.d.ts +32 -5
  65. package/cjs/toggle-group/parts/ToggleItem.js +4 -2
  66. package/cjs/toggle-group/parts/ToggleItem.js.map +1 -1
  67. package/cjs/toggle-group/parts/useToggleItem.js +1 -1
  68. package/cjs/toggle-group/parts/useToggleItem.js.map +1 -1
  69. package/cjs/util/hooks/descendants/useDescendant.js +1 -1
  70. package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
  71. package/cjs/util/hooks/descendants/utils.js +1 -1
  72. package/cjs/util/hooks/descendants/utils.js.map +1 -1
  73. package/cjs/util/i18n/get.js +3 -2
  74. package/cjs/util/i18n/get.js.map +1 -1
  75. package/cjs/util/types/AsChildProps.d.ts +1 -0
  76. package/esm/alert/Alert.d.ts +5 -0
  77. package/esm/alert/Alert.js +5 -3
  78. package/esm/alert/Alert.js.map +1 -1
  79. package/esm/collapsible/parts/Collapsible.Content.js +1 -1
  80. package/esm/collapsible/parts/Collapsible.Trigger.js +1 -1
  81. package/esm/date/datepicker/types.d.ts +1 -1
  82. package/esm/date/monthpicker/types.d.ts +1 -1
  83. package/esm/form/file-upload/parts/Trigger.js +1 -1
  84. package/esm/form/file-upload/parts/item/Item.d.ts +5 -0
  85. package/esm/form/file-upload/parts/item/Item.js +2 -2
  86. package/esm/form/file-upload/parts/item/Item.js.map +1 -1
  87. package/esm/layout/base/BasePrimitive.d.ts +167 -0
  88. package/esm/layout/base/BasePrimitive.js +63 -0
  89. package/esm/layout/base/BasePrimitive.js.map +1 -0
  90. package/esm/layout/base/PrimitiveAsChildProps.d.ts +41 -0
  91. package/esm/layout/base/PrimitiveAsChildProps.js +2 -0
  92. package/esm/layout/base/PrimitiveAsChildProps.js.map +1 -0
  93. package/esm/layout/bleed/Bleed.js +1 -1
  94. package/esm/layout/box/Box.d.ts +14 -35
  95. package/esm/layout/box/Box.js +15 -4
  96. package/esm/layout/box/Box.js.map +1 -1
  97. package/esm/layout/grid/HGrid.d.ts +7 -5
  98. package/esm/layout/grid/HGrid.js +7 -2
  99. package/esm/layout/grid/HGrid.js.map +1 -1
  100. package/esm/layout/page/Page.d.ts +4 -3
  101. package/esm/layout/page/Page.js.map +1 -1
  102. package/esm/layout/responsive/Responsive.js +1 -1
  103. package/esm/layout/stack/HStack.d.ts +2 -1
  104. package/esm/layout/stack/HStack.js.map +1 -1
  105. package/esm/layout/stack/Stack.d.ts +8 -5
  106. package/esm/layout/stack/Stack.js +10 -5
  107. package/esm/layout/stack/Stack.js.map +1 -1
  108. package/esm/layout/stack/VStack.d.ts +2 -1
  109. package/esm/layout/stack/VStack.js.map +1 -1
  110. package/esm/layout/utilities/css.js +3 -0
  111. package/esm/layout/utilities/css.js.map +1 -1
  112. package/esm/layout/utilities/types.d.ts +2 -1
  113. package/esm/list/ListItem.js +3 -3
  114. package/esm/list/ListItem.js.map +1 -1
  115. package/esm/modal/dialog-polyfill.js +0 -3
  116. package/esm/modal/dialog-polyfill.js.map +1 -1
  117. package/esm/overlays/dismissablelayer/DismissableLayer.js +1 -1
  118. package/esm/overlays/dismissablelayer/util/useFocusOutside.d.ts +2 -2
  119. package/esm/overlays/dismissablelayer/util/useFocusOutside.js +6 -2
  120. package/esm/overlays/dismissablelayer/util/useFocusOutside.js.map +1 -1
  121. package/esm/overlays/dismissablelayer/util/usePointerDownOutside.d.ts +1 -1
  122. package/esm/overlays/dismissablelayer/util/usePointerDownOutside.js +3 -1
  123. package/esm/overlays/dismissablelayer/util/usePointerDownOutside.js.map +1 -1
  124. package/esm/overlays/floating/Floating.js +1 -1
  125. package/esm/pagination/Pagination.d.ts +7 -0
  126. package/esm/pagination/Pagination.js +6 -3
  127. package/esm/pagination/Pagination.js.map +1 -1
  128. package/esm/pagination/PaginationItem.js +4 -2
  129. package/esm/pagination/PaginationItem.js.map +1 -1
  130. package/esm/portal/Portal.js +1 -1
  131. package/esm/slot/Slot.d.ts +6 -0
  132. package/esm/slot/Slot.js +32 -0
  133. package/esm/slot/Slot.js.map +1 -0
  134. package/esm/slot/merge-props.d.ts +4 -0
  135. package/esm/slot/merge-props.js +34 -0
  136. package/esm/slot/merge-props.js.map +1 -0
  137. package/esm/toggle-group/ToggleGroup.d.ts +3 -3
  138. package/esm/toggle-group/ToggleGroup.js +3 -3
  139. package/esm/toggle-group/parts/ToggleItem.d.ts +32 -5
  140. package/esm/toggle-group/parts/ToggleItem.js +4 -2
  141. package/esm/toggle-group/parts/ToggleItem.js.map +1 -1
  142. package/esm/toggle-group/parts/useToggleItem.js +1 -1
  143. package/esm/toggle-group/parts/useToggleItem.js.map +1 -1
  144. package/esm/util/hooks/descendants/useDescendant.js +1 -1
  145. package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
  146. package/esm/util/hooks/descendants/utils.js +1 -1
  147. package/esm/util/hooks/descendants/utils.js.map +1 -1
  148. package/esm/util/i18n/get.js +3 -2
  149. package/esm/util/i18n/get.js.map +1 -1
  150. package/esm/util/types/AsChildProps.d.ts +1 -0
  151. package/package.json +3 -3
  152. package/src/alert/Alert.tsx +23 -2
  153. package/src/collapsible/parts/Collapsible.Content.tsx +1 -1
  154. package/src/collapsible/parts/Collapsible.Trigger.tsx +1 -1
  155. package/src/date/datepicker/types.ts +1 -1
  156. package/src/date/monthpicker/types.ts +1 -1
  157. package/src/form/file-upload/parts/Trigger.tsx +1 -1
  158. package/src/form/file-upload/parts/item/Item.tsx +7 -1
  159. package/src/layout/base/BasePrimitive.tsx +314 -0
  160. package/src/layout/base/PrimitiveAsChildProps.ts +42 -0
  161. package/src/layout/bleed/Bleed.tsx +1 -1
  162. package/src/layout/box/Box.tsx +66 -76
  163. package/src/layout/grid/HGrid.tsx +73 -45
  164. package/src/layout/page/Page.tsx +4 -3
  165. package/src/layout/responsive/Responsive.tsx +1 -1
  166. package/src/layout/stack/HStack.tsx +2 -1
  167. package/src/layout/stack/Stack.tsx +80 -62
  168. package/src/layout/stack/VStack.tsx +3 -1
  169. package/src/layout/utilities/css.ts +3 -0
  170. package/src/layout/utilities/types.ts +2 -3
  171. package/src/list/ListItem.tsx +5 -5
  172. package/src/modal/dialog-polyfill.ts +0 -3
  173. package/src/overlays/dismissablelayer/DismissableLayer.tsx +1 -1
  174. package/src/overlays/dismissablelayer/util/useFocusOutside.ts +6 -2
  175. package/src/overlays/dismissablelayer/util/usePointerDownOutside.ts +3 -1
  176. package/src/overlays/floating/Floating.tsx +1 -1
  177. package/src/pagination/Pagination.tsx +26 -1
  178. package/src/pagination/PaginationItem.tsx +4 -0
  179. package/src/portal/Portal.tsx +1 -1
  180. package/src/slot/Slot.tsx +33 -0
  181. package/src/{util/Slot.tsx → slot/merge-props.ts} +2 -34
  182. package/src/slot/tests/merge-props.test.ts +49 -0
  183. package/src/toggle-group/ToggleGroup.test.tsx +3 -9
  184. package/src/toggle-group/ToggleGroup.tsx +3 -3
  185. package/src/toggle-group/parts/ToggleItem.tsx +54 -8
  186. package/src/toggle-group/parts/useToggleItem.ts +4 -1
  187. package/src/util/hooks/descendants/useDescendant.tsx +1 -1
  188. package/src/util/hooks/descendants/utils.ts +1 -1
  189. package/src/util/i18n/get.ts +4 -2
  190. package/src/util/types/AsChildProps.ts +1 -0
  191. package/cjs/layout/sidemal-test/AvatarPanel.d.ts +0 -4
  192. package/cjs/layout/sidemal-test/AvatarPanel.js +0 -19
  193. package/cjs/layout/sidemal-test/AvatarPanel.js.map +0 -1
  194. package/cjs/layout/sidemal-test/Content.d.ts +0 -2
  195. package/cjs/layout/sidemal-test/Content.js +0 -67
  196. package/cjs/layout/sidemal-test/Content.js.map +0 -1
  197. package/cjs/layout/sidemal-test/Filter.d.ts +0 -2
  198. package/cjs/layout/sidemal-test/Filter.js +0 -49
  199. package/cjs/layout/sidemal-test/Filter.js.map +0 -1
  200. package/cjs/layout/sidemal-test/Header.d.ts +0 -2
  201. package/cjs/layout/sidemal-test/Header.js +0 -49
  202. package/cjs/layout/sidemal-test/Header.js.map +0 -1
  203. package/cjs/layout/sidemal-test/Intro.d.ts +0 -2
  204. package/cjs/layout/sidemal-test/Intro.js +0 -37
  205. package/cjs/layout/sidemal-test/Intro.js.map +0 -1
  206. package/cjs/layout/sidemal-test/Sidebar.d.ts +0 -4
  207. package/cjs/layout/sidemal-test/Sidebar.js +0 -50
  208. package/cjs/layout/sidemal-test/Sidebar.js.map +0 -1
  209. package/cjs/layout/sidemal-test/content-box/ContentBox.d.ts +0 -8
  210. package/cjs/layout/sidemal-test/content-box/ContentBox.js +0 -66
  211. package/cjs/layout/sidemal-test/content-box/ContentBox.js.map +0 -1
  212. package/cjs/layout/sidemal-test/content-box/index.d.ts +0 -1
  213. package/cjs/layout/sidemal-test/content-box/index.js +0 -9
  214. package/cjs/layout/sidemal-test/content-box/index.js.map +0 -1
  215. package/cjs/util/Slot.d.ts +0 -6
  216. package/cjs/util/Slot.js.map +0 -1
  217. package/esm/layout/sidemal-test/AvatarPanel.d.ts +0 -4
  218. package/esm/layout/sidemal-test/AvatarPanel.js +0 -12
  219. package/esm/layout/sidemal-test/AvatarPanel.js.map +0 -1
  220. package/esm/layout/sidemal-test/Content.d.ts +0 -2
  221. package/esm/layout/sidemal-test/Content.js +0 -60
  222. package/esm/layout/sidemal-test/Content.js.map +0 -1
  223. package/esm/layout/sidemal-test/Filter.d.ts +0 -2
  224. package/esm/layout/sidemal-test/Filter.js +0 -22
  225. package/esm/layout/sidemal-test/Filter.js.map +0 -1
  226. package/esm/layout/sidemal-test/Header.d.ts +0 -2
  227. package/esm/layout/sidemal-test/Header.js +0 -42
  228. package/esm/layout/sidemal-test/Header.js.map +0 -1
  229. package/esm/layout/sidemal-test/Intro.d.ts +0 -2
  230. package/esm/layout/sidemal-test/Intro.js +0 -30
  231. package/esm/layout/sidemal-test/Intro.js.map +0 -1
  232. package/esm/layout/sidemal-test/Sidebar.d.ts +0 -4
  233. package/esm/layout/sidemal-test/Sidebar.js +0 -41
  234. package/esm/layout/sidemal-test/Sidebar.js.map +0 -1
  235. package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +0 -8
  236. package/esm/layout/sidemal-test/content-box/ContentBox.js +0 -37
  237. package/esm/layout/sidemal-test/content-box/ContentBox.js.map +0 -1
  238. package/esm/layout/sidemal-test/content-box/index.d.ts +0 -1
  239. package/esm/layout/sidemal-test/content-box/index.js +0 -2
  240. package/esm/layout/sidemal-test/content-box/index.js.map +0 -1
  241. package/esm/util/Slot.d.ts +0 -6
  242. package/esm/util/Slot.js +0 -63
  243. package/esm/util/Slot.js.map +0 -1
  244. package/src/layout/sidemal-test/AvatarPanel.tsx +0 -27
  245. package/src/layout/sidemal-test/Content.tsx +0 -129
  246. package/src/layout/sidemal-test/Filter.tsx +0 -46
  247. package/src/layout/sidemal-test/Header.tsx +0 -96
  248. package/src/layout/sidemal-test/Intro.tsx +0 -91
  249. package/src/layout/sidemal-test/Sidebar.tsx +0 -77
  250. package/src/layout/sidemal-test/content-box/ContentBox.tsx +0 -46
  251. package/src/layout/sidemal-test/content-box/index.ts +0 -1
  252. package/src/layout/sidemal-test/styling.css +0 -43
  253. /package/src/{util/__tests__ → slot/tests}/Slot.test.tsx +0 -0
@@ -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
- BackgroundToken,
13
+ BackgroundColorToken,
7
14
  BorderColorToken,
8
15
  BorderRadiiToken,
9
16
  ResponsiveProp,
10
17
  ShadowToken,
11
18
  SpaceDelimitedAttribute,
12
- SpacingScale,
19
+ SurfaceColorToken,
13
20
  } from "../utilities/types";
14
21
 
15
- export interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {
16
- /** CSS `background-color` property. Accepts a color token. */
17
- background?: BackgroundToken;
18
- /** CSS `border-color` property. Accepts a color token. */
19
- borderColor?: BorderColorToken;
20
- /**
21
- * CSS `border-radius` property.
22
- * Accepts a [radius token](https://aksel.nav.no/grunnleggende/styling/design-tokens#6d79c5605d31)
23
- * or an object of radius tokens for different breakpoints.
24
- * @example
25
- * borderRadius='full'
26
- * borderRadius='0 full large small'
27
- * borderRadius={{xs: 'small large', sm: '0', md: 'large', lg: 'full'}}
28
- */
29
- borderRadius?: ResponsiveProp<SpaceDelimitedAttribute<BorderRadiiToken>>;
30
- /**
31
- * CSS `border-width` property. If this is not set there will be no border.
32
- * @example
33
- * borderWidth='2'
34
- * borderWidth='1 2 3 4'
35
- */
36
- borderWidth?: SpaceDelimitedAttribute<"0" | "1" | "2" | "3" | "4" | "5">;
37
- /**
38
- * Padding around children.
39
- * Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
40
- * or an object of spacing tokens for different breakpoints.
41
- * @example
42
- * padding='4'
43
- * padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
44
- */
45
- padding?: ResponsiveProp<SpacingScale>;
46
- /**
47
- * Horizontal padding around children.
48
- * Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
49
- * or an object of spacing tokens for different breakpoints.
50
- * @example
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
- <Component
152
- {...rest}
153
- className={cl("navds-box", className)}
154
- ref={ref}
155
- style={style}
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, { HTMLAttributes, forwardRef } from "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 interface HGridProps extends HTMLAttributes<HTMLDivElement> {
7
- children: React.ReactNode;
8
- /**
9
- * Number of columns to display. Can be a number, a string, or an object with values for specific breakpoints.
10
- * Sets `grid-template-columns`, so `fr`, `minmax` etc. works.
11
- * @example
12
- * columns={{ sm: 1, md: 1, lg: "1fr auto", xl: "1fr auto"}}
13
- * columns={3}
14
- * columns="repeat(3, minmax(0, 1fr))"
15
- */
16
- columns?: ResponsiveProp<number | string>;
17
- /**
18
- * Spacing between columns.
19
- * Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
20
- * or an object of spacing tokens for different breakpoints.
21
- * @example
22
- * gap="6"
23
- * gap="8 4"
24
- * gap={{ sm: "2", md: "2", lg: "6", xl: "6"}}
25
- */
26
- gap?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
27
- /**
28
- * Vertical alignment of children. Elements will by default stretch to the height of parent-element.
29
- */
30
- align?: "start" | "center" | "end";
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 = forwardRef<HTMLDivElement, HGridProps>(
58
- ({ className, columns, gap, style, align, ...rest }, ref) => {
59
- const styles: React.CSSProperties = {
60
- ...style,
61
- "--__ac-hgrid-align": align,
62
- ...getResponsiveProps(`hgrid`, "gap", "spacing", gap),
63
- ...getResponsiveValue(`hgrid`, "columns", formatGrid(columns)),
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
- return (
67
- <div
68
- {...rest}
69
- ref={ref}
70
- className={cl("navds-hgrid", className)}
71
- style={styles}
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>,
@@ -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. Accepts a color token.
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?: keyof typeof bgColors.a | "surface-subtle";
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 "../../util/Slot";
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 interface StackProps extends HTMLAttributes<HTMLDivElement> {
8
- children: React.ReactNode;
9
- /**
10
- * CSS `justify-content` property.
11
- *
12
- * @example
13
- * justify='center'
14
- * justify={{xs: 'start', sm: 'center', md: 'end', lg: 'space-around', xl: 'space-between'}}
15
- */
16
- justify?: ResponsiveProp<
17
- | "start"
18
- | "center"
19
- | "end"
20
- | "space-around"
21
- | "space-between"
22
- | "space-evenly"
23
- >;
24
- /**
25
- * CSS `align-items` property.
26
- *
27
- * @example
28
- * align='center'
29
- * align={{xs: 'start', sm: 'center', md: 'end', lg: 'baseline', xl: 'stretch'}}
30
- */
31
- align?: ResponsiveProp<"start" | "center" | "end" | "baseline" | "stretch">;
32
- /**
33
- * Sets the CSS `flex-wrap` property.
34
- */
35
- wrap?: boolean;
36
- /**
37
- * CSS `gap` property.
38
- * Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
39
- * or an object of spacing tokens for different breakpoints.
40
- *
41
- * @example
42
- * gap='4'
43
- * gap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
44
- */
45
- gap?: ResponsiveProp<SpacingScale>;
46
- /**
47
- * CSS `flex-direction` property.
48
- * @default "row"
49
- *
50
- * @example
51
- * direction='row'
52
- * direction={{xs: 'row', sm: 'column'}}
53
- */
54
- direction?: ResponsiveProp<
55
- "row" | "column" | "row-reverse" | "column-reverse"
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
- as: Component = "div",
73
+ children,
64
74
  className,
65
- align,
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
- <Component
86
- {...rest}
87
- ref={ref}
88
- style={style}
89
- className={cl("navds-stack", className, {
90
- "navds-vstack": direction === "column",
91
- "navds-hstack": direction === "row",
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 = Omit<StackProps, "direction" | "wrap">;
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 BackgroundToken =
9
- | keyof typeof bgColors.a
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"]
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef, useContext } from "react";
3
- import { BodyShort, Label } from "../typography";
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
- <BodyShort as="div" size={size} className="navds-list__item-content">
48
+ <BodyLong as="div" size={size} className="navds-list__item-content">
49
49
  {title && (
50
- <Label as="p" size={size}>
50
+ <BodyLong as="p" size={size} weight="semibold">
51
51
  {title}
52
- </Label>
52
+ </BodyLong>
53
53
  )}
54
54
  {children}
55
- </BodyShort>
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 "../../util/Slot";
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: () => (isFocusInsideReactTreeRef.current = true),
50
- onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),
49
+ onFocusCapture: () => {
50
+ isFocusInsideReactTreeRef.current = true;
51
+ },
52
+ onBlurCapture: () => {
53
+ isFocusInsideReactTreeRef.current = false;
54
+ },
51
55
  };
52
56
  }