@navikt/ds-react 7.2.1 → 7.3.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 (209) hide show
  1. package/cjs/accordion/AccordionHeader.js +1 -1
  2. package/cjs/accordion/AccordionHeader.js.map +1 -1
  3. package/cjs/alert/Alert.d.ts +0 -3
  4. package/cjs/alert/Alert.js +11 -17
  5. package/cjs/alert/Alert.js.map +1 -1
  6. package/cjs/chips/Removable.d.ts +5 -5
  7. package/cjs/chips/Removable.js +4 -2
  8. package/cjs/chips/Removable.js.map +1 -1
  9. package/cjs/collapsible/Collapsible.context.d.ts +1 -1
  10. package/cjs/date/datepicker/DatePicker.d.ts +2 -2
  11. package/cjs/date/monthpicker/MonthPicker.d.ts +2 -2
  12. package/cjs/form/file-upload/FileUpload.context.d.ts +1 -1
  13. package/cjs/index.d.ts +1 -0
  14. package/cjs/index.js +4 -2
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/layout/base/BasePrimitive.d.ts +3 -0
  17. package/cjs/layout/base/BasePrimitive.js.map +1 -1
  18. package/cjs/layout/box/Box.d.ts +2 -2
  19. package/cjs/layout/box/Box.js.map +1 -1
  20. package/cjs/layout/grid/HGrid.d.ts +2 -2
  21. package/cjs/layout/grid/HGrid.js.map +1 -1
  22. package/cjs/layout/stack/Stack.d.ts +2 -2
  23. package/cjs/layout/stack/Stack.js.map +1 -1
  24. package/cjs/modal/ModalHeader.js +6 -1
  25. package/cjs/modal/ModalHeader.js.map +1 -1
  26. package/cjs/modal/dialog-polyfill.js +2 -2
  27. package/cjs/modal/dialog-polyfill.js.map +1 -1
  28. package/cjs/overlays/action-menu/ActionMenu.d.ts +310 -0
  29. package/cjs/overlays/action-menu/ActionMenu.js +227 -0
  30. package/cjs/overlays/action-menu/ActionMenu.js.map +1 -0
  31. package/cjs/overlays/action-menu/index.d.ts +1 -0
  32. package/cjs/overlays/action-menu/index.js +19 -0
  33. package/cjs/overlays/action-menu/index.js.map +1 -0
  34. package/cjs/overlays/floating/Floating.js +9 -10
  35. package/cjs/overlays/floating/Floating.js.map +1 -1
  36. package/cjs/overlays/floating/Floating.utils.d.ts +3 -5
  37. package/cjs/overlays/floating/Floating.utils.js +0 -2
  38. package/cjs/overlays/floating/Floating.utils.js.map +1 -1
  39. package/cjs/overlays/floating-menu/Menu.d.ts +15 -21
  40. package/cjs/overlays/floating-menu/Menu.js +119 -230
  41. package/cjs/overlays/floating-menu/Menu.js.map +1 -1
  42. package/cjs/overlays/floating-menu/parts/RovingFocus.d.ts +1 -1
  43. package/cjs/overlays/floating-menu/parts/RovingFocus.js.map +1 -1
  44. package/cjs/pagination/Pagination.d.ts +1 -6
  45. package/cjs/pagination/Pagination.js.map +1 -1
  46. package/cjs/provider/i18n/LanguageProvider.d.ts +3 -3
  47. package/cjs/stepper/context.d.ts +1 -1
  48. package/cjs/table/Body.d.ts +2 -4
  49. package/cjs/table/Body.js.map +1 -1
  50. package/cjs/table/ColumnHeader.d.ts +1 -2
  51. package/cjs/table/ColumnHeader.js.map +1 -1
  52. package/cjs/table/ExpandableRow.d.ts +1 -2
  53. package/cjs/table/ExpandableRow.js.map +1 -1
  54. package/cjs/table/Header.d.ts +2 -4
  55. package/cjs/table/Header.js.map +1 -1
  56. package/cjs/table/HeaderCell.d.ts +1 -2
  57. package/cjs/table/HeaderCell.js.map +1 -1
  58. package/cjs/table/Row.d.ts +1 -2
  59. package/cjs/table/Row.js.map +1 -1
  60. package/cjs/tabs/Tabs.context.d.ts +1 -1
  61. package/cjs/toggle-group/ToggleGroup.context.d.ts +1 -1
  62. package/cjs/util/i18n/get.d.ts +2 -2
  63. package/cjs/util/i18n/get.js.map +1 -1
  64. package/cjs/util/i18n/i18n.context.d.ts +2 -3
  65. package/cjs/util/i18n/i18n.context.js.map +1 -1
  66. package/cjs/util/i18n/i18n.types.d.ts +5 -9
  67. package/cjs/util/i18n/locales/en.d.ts +39 -0
  68. package/cjs/util/i18n/locales/en.js +41 -0
  69. package/cjs/util/i18n/locales/en.js.map +1 -0
  70. package/cjs/util/i18n/locales/nb.d.ts +14 -0
  71. package/cjs/util/i18n/locales/nb.js +14 -0
  72. package/cjs/util/i18n/locales/nb.js.map +1 -1
  73. package/cjs/util/i18n/locales/nn.d.ts +39 -0
  74. package/cjs/util/i18n/locales/nn.js +41 -0
  75. package/cjs/util/i18n/locales/nn.js.map +1 -0
  76. package/cjs/util/requireReactElement.d.ts +2 -0
  77. package/cjs/util/requireReactElement.js +22 -0
  78. package/cjs/util/requireReactElement.js.map +1 -0
  79. package/cjs/util/virtualfocus/Context.d.ts +1 -1
  80. package/cjs/util/virtualfocus/parts/VirtualFocusContent.d.ts +1 -2
  81. package/cjs/util/virtualfocus/parts/VirtualFocusContent.js.map +1 -1
  82. package/esm/accordion/AccordionHeader.js +1 -1
  83. package/esm/accordion/AccordionHeader.js.map +1 -1
  84. package/esm/alert/Alert.d.ts +0 -3
  85. package/esm/alert/Alert.js +11 -17
  86. package/esm/alert/Alert.js.map +1 -1
  87. package/esm/chips/Removable.d.ts +5 -5
  88. package/esm/chips/Removable.js +4 -2
  89. package/esm/chips/Removable.js.map +1 -1
  90. package/esm/collapsible/Collapsible.context.d.ts +1 -1
  91. package/esm/date/datepicker/DatePicker.d.ts +2 -2
  92. package/esm/date/monthpicker/MonthPicker.d.ts +2 -2
  93. package/esm/form/file-upload/FileUpload.context.d.ts +1 -1
  94. package/esm/index.d.ts +1 -0
  95. package/esm/index.js +1 -0
  96. package/esm/index.js.map +1 -1
  97. package/esm/layout/base/BasePrimitive.d.ts +3 -0
  98. package/esm/layout/base/BasePrimitive.js.map +1 -1
  99. package/esm/layout/box/Box.d.ts +2 -2
  100. package/esm/layout/box/Box.js.map +1 -1
  101. package/esm/layout/grid/HGrid.d.ts +2 -2
  102. package/esm/layout/grid/HGrid.js.map +1 -1
  103. package/esm/layout/stack/Stack.d.ts +2 -2
  104. package/esm/layout/stack/Stack.js.map +1 -1
  105. package/esm/modal/ModalHeader.js +6 -1
  106. package/esm/modal/ModalHeader.js.map +1 -1
  107. package/esm/modal/dialog-polyfill.js +2 -2
  108. package/esm/modal/dialog-polyfill.js.map +1 -1
  109. package/esm/overlays/action-menu/ActionMenu.d.ts +310 -0
  110. package/esm/overlays/action-menu/ActionMenu.js +197 -0
  111. package/esm/overlays/action-menu/ActionMenu.js.map +1 -0
  112. package/esm/overlays/action-menu/index.d.ts +1 -0
  113. package/esm/overlays/action-menu/index.js +3 -0
  114. package/esm/overlays/action-menu/index.js.map +1 -0
  115. package/esm/overlays/floating/Floating.js +9 -10
  116. package/esm/overlays/floating/Floating.js.map +1 -1
  117. package/esm/overlays/floating/Floating.utils.d.ts +3 -5
  118. package/esm/overlays/floating/Floating.utils.js +0 -2
  119. package/esm/overlays/floating/Floating.utils.js.map +1 -1
  120. package/esm/overlays/floating-menu/Menu.d.ts +15 -21
  121. package/esm/overlays/floating-menu/Menu.js +119 -230
  122. package/esm/overlays/floating-menu/Menu.js.map +1 -1
  123. package/esm/overlays/floating-menu/parts/RovingFocus.d.ts +1 -1
  124. package/esm/overlays/floating-menu/parts/RovingFocus.js.map +1 -1
  125. package/esm/pagination/Pagination.d.ts +1 -6
  126. package/esm/pagination/Pagination.js.map +1 -1
  127. package/esm/provider/i18n/LanguageProvider.d.ts +3 -3
  128. package/esm/stepper/context.d.ts +1 -1
  129. package/esm/table/Body.d.ts +2 -4
  130. package/esm/table/Body.js.map +1 -1
  131. package/esm/table/ColumnHeader.d.ts +1 -2
  132. package/esm/table/ColumnHeader.js.map +1 -1
  133. package/esm/table/ExpandableRow.d.ts +1 -2
  134. package/esm/table/ExpandableRow.js.map +1 -1
  135. package/esm/table/Header.d.ts +2 -4
  136. package/esm/table/Header.js.map +1 -1
  137. package/esm/table/HeaderCell.d.ts +1 -2
  138. package/esm/table/HeaderCell.js.map +1 -1
  139. package/esm/table/Row.d.ts +1 -2
  140. package/esm/table/Row.js.map +1 -1
  141. package/esm/tabs/Tabs.context.d.ts +1 -1
  142. package/esm/toggle-group/ToggleGroup.context.d.ts +1 -1
  143. package/esm/util/i18n/get.d.ts +2 -2
  144. package/esm/util/i18n/get.js.map +1 -1
  145. package/esm/util/i18n/i18n.context.d.ts +2 -3
  146. package/esm/util/i18n/i18n.context.js.map +1 -1
  147. package/esm/util/i18n/i18n.types.d.ts +5 -9
  148. package/esm/util/i18n/locales/en.d.ts +39 -0
  149. package/esm/util/i18n/locales/en.js +39 -0
  150. package/esm/util/i18n/locales/en.js.map +1 -0
  151. package/esm/util/i18n/locales/nb.d.ts +14 -0
  152. package/esm/util/i18n/locales/nb.js +14 -0
  153. package/esm/util/i18n/locales/nb.js.map +1 -1
  154. package/esm/util/i18n/locales/nn.d.ts +39 -0
  155. package/esm/util/i18n/locales/nn.js +39 -0
  156. package/esm/util/i18n/locales/nn.js.map +1 -0
  157. package/esm/util/requireReactElement.d.ts +2 -0
  158. package/esm/util/requireReactElement.js +15 -0
  159. package/esm/util/requireReactElement.js.map +1 -0
  160. package/esm/util/virtualfocus/Context.d.ts +1 -1
  161. package/esm/util/virtualfocus/parts/VirtualFocusContent.d.ts +1 -2
  162. package/esm/util/virtualfocus/parts/VirtualFocusContent.js.map +1 -1
  163. package/package.json +15 -7
  164. package/src/accordion/AccordionHeader.tsx +0 -1
  165. package/src/alert/Alert.tsx +11 -20
  166. package/src/chips/Removable.tsx +13 -9
  167. package/src/date/datepicker/DatePicker.tsx +2 -2
  168. package/src/date/monthpicker/MonthPicker.tsx +2 -2
  169. package/src/form/checkbox/Checkbox.test.tsx +2 -3
  170. package/src/form/confirmation-panel/ConfirmationPanel.test.tsx +1 -2
  171. package/src/form/radio/Radio.test.tsx +4 -5
  172. package/src/index.ts +1 -0
  173. package/src/layout/base/BasePrimitive.tsx +3 -0
  174. package/src/layout/box/Box.tsx +35 -36
  175. package/src/layout/grid/HGrid.tsx +26 -27
  176. package/src/layout/stack/Stack.tsx +53 -54
  177. package/src/modal/ModalHeader.tsx +6 -0
  178. package/src/modal/dialog-polyfill.ts +2 -2
  179. package/src/overlays/action-menu/ActionMenu.tsx +971 -0
  180. package/src/overlays/action-menu/index.ts +29 -0
  181. package/src/overlays/floating/Floating.tsx +6 -12
  182. package/src/overlays/floating/Floating.utils.ts +2 -5
  183. package/src/overlays/floating-menu/Menu.tsx +183 -332
  184. package/src/overlays/floating-menu/parts/RovingFocus.tsx +3 -3
  185. package/src/pagination/Pagination.tsx +4 -1
  186. package/src/pagination/steps.test.ts +15 -16
  187. package/src/provider/i18n/LanguageProvider.tsx +3 -3
  188. package/src/table/Body.tsx +4 -6
  189. package/src/table/ColumnHeader.tsx +3 -4
  190. package/src/table/ExpandableRow.tsx +3 -4
  191. package/src/table/Header.tsx +4 -6
  192. package/src/table/HeaderCell.tsx +3 -4
  193. package/src/table/Row.tsx +3 -4
  194. package/src/util/i18n/get.ts +3 -3
  195. package/src/util/i18n/i18n.context.ts +2 -3
  196. package/src/util/i18n/i18n.types.ts +7 -11
  197. package/src/util/i18n/locales/en.ts +40 -0
  198. package/src/util/i18n/locales/nb.ts +23 -1
  199. package/src/util/i18n/locales/nn.ts +40 -0
  200. package/src/util/i18n/locales.test.tsx +23 -0
  201. package/src/util/requireReactElement.ts +25 -0
  202. package/src/util/virtualfocus/parts/VirtualFocusContent.tsx +4 -2
  203. package/cjs/util/i18n/merge.d.ts +0 -2
  204. package/cjs/util/i18n/merge.js +0 -28
  205. package/cjs/util/i18n/merge.js.map +0 -1
  206. package/esm/util/i18n/merge.d.ts +0 -2
  207. package/esm/util/i18n/merge.js +0 -25
  208. package/esm/util/i18n/merge.js.map +0 -1
  209. package/src/util/i18n/merge.ts +0 -35
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ export const requireReactElement = (children) => {
3
+ const isReactElement = React.isValidElement(children);
4
+ if (!isReactElement) {
5
+ throw Error(`Expected a single React Element child, but got: ${React.Children.toArray(children)
6
+ .map((child) => typeof child === "object" &&
7
+ "type" in child &&
8
+ typeof child.type === "string"
9
+ ? child.type
10
+ : typeof child)
11
+ .join(", ")}`);
12
+ }
13
+ return children;
14
+ };
15
+ //# sourceMappingURL=requireReactElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireReactElement.js","sourceRoot":"","sources":["../../src/util/requireReactElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAW,EACR,EAAE;IACL,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEtD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,KAAK,CACT,mDAAmD,KAAK,CAAC,QAAQ,CAAC,OAAO,CACvE,QAAQ,CACT;aACE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,OAAO,KAAK,KAAK,QAAQ;YACzB,MAAM,IAAI,KAAK;YACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;YAC5B,CAAC,CAAC,KAAK,CAAC,IAAI;YACZ,CAAC,CAAC,OAAO,KAAK,CACjB;aACA,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -29,7 +29,7 @@ export declare const VirtualFocusInternalContextProvider: import("react").Forwar
29
29
  loop: boolean;
30
30
  uniqueId: string;
31
31
  } & {
32
- children: React.ReactNode;
32
+ children: import("react").ReactNode;
33
33
  } & import("react").RefAttributes<unknown>>, useVirtualFocusInternalContext: <S extends boolean = true>(strict?: S) => S extends true ? {
34
34
  virtualFocusIdx: number;
35
35
  setVirtualFocusIdx: Dispatch<SetStateAction<number>>;
@@ -1,4 +1,3 @@
1
1
  import React from "react";
2
- export interface VirtualFocusContentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "id"> {
3
- }
2
+ export type VirtualFocusContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, "id">;
4
3
  export declare const VirtualFocusContent: React.ForwardRefExoticComponent<VirtualFocusContentProps & React.RefAttributes<HTMLDivElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualFocusContent.js","sourceRoot":"","sources":["../../../../src/util/virtualfocus/parts/VirtualFocusContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAK5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAG3C,CAAC,EAAqB,EAAE,GAAG,EAAE,EAAE;QAA9B,EAAE,QAAQ,OAAW,EAAN,IAAI,cAAnB,YAAqB,CAAF;IACpB,MAAM,EAAE,QAAQ,EAAE,GAAG,8BAA8B,EAAE,CAAC;IACtD,OAAO,CACL,2CAAK,GAAG,EAAE,GAAG,IAAM,IAAI,IAAE,EAAE,EAAE,gBAAgB,QAAQ,UAAU,KAC5D,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"VirtualFocusContent.js","sourceRoot":"","sources":["../../../../src/util/virtualfocus/parts/VirtualFocusContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAO5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAG3C,CAAC,EAAqB,EAAE,GAAG,EAAE,EAAE;QAA9B,EAAE,QAAQ,OAAW,EAAN,IAAI,cAAnB,YAAqB,CAAF;IACpB,MAAM,EAAE,QAAQ,EAAE,GAAG,8BAA8B,EAAE,CAAC;IACtD,OAAO,CACL,2CAAK,GAAG,EAAE,GAAG,IAAM,IAAI,IAAE,EAAE,EAAE,gBAAgB,QAAQ,UAAU,KAC5D,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "7.2.1",
3
+ "version": "7.3.0",
4
4
  "description": "React components from the Norwegian Labour and Welfare Administration.",
5
5
  "author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
6
6
  "license": "MIT",
@@ -50,6 +50,16 @@
50
50
  "default": "./cjs/accordion/index.js"
51
51
  }
52
52
  },
53
+ "./ActionMenu": {
54
+ "import": {
55
+ "types": "./esm/overlays/action-menu/index.d.ts",
56
+ "default": "./esm/overlays/action-menu/index.js"
57
+ },
58
+ "require": {
59
+ "types": "./cjs/overlays/action-menu/index.d.ts",
60
+ "default": "./cjs/overlays/action-menu/index.js"
61
+ }
62
+ },
53
63
  "./Alert": {
54
64
  "import": {
55
65
  "types": "./esm/alert/index.d.ts",
@@ -594,8 +604,8 @@
594
604
  "dependencies": {
595
605
  "@floating-ui/react": "0.25.4",
596
606
  "@floating-ui/react-dom": "^2.0.9",
597
- "@navikt/aksel-icons": "^7.2.1",
598
- "@navikt/ds-tokens": "^7.2.1",
607
+ "@navikt/aksel-icons": "^7.3.0",
608
+ "@navikt/ds-tokens": "^7.3.0",
599
609
  "clsx": "^2.1.0",
600
610
  "date-fns": "^3.0.0",
601
611
  "react-day-picker": "8.10.0"
@@ -605,9 +615,7 @@
605
615
  "@testing-library/jest-dom": "^5.16.0",
606
616
  "@testing-library/react": "^15.0.7",
607
617
  "@testing-library/user-event": "^14.2.0",
608
- "@types/faker": "5.5.8",
609
- "concurrently": "7.2.1",
610
- "faker": "5.5.3",
618
+ "concurrently": "9.0.1",
611
619
  "fast-glob": "3.2.11",
612
620
  "jsdom": "24.0.0",
613
621
  "react-dom": "^18.0.0",
@@ -616,7 +624,7 @@
616
624
  "swr": "^1.1.2",
617
625
  "tsc-alias": "1.8.8",
618
626
  "tsx": "^4.19.1",
619
- "typescript": "^5.1.6",
627
+ "typescript": "5.5.4",
620
628
  "vitest": "^1.2.2"
621
629
  },
622
630
  "peerDependencies": {
@@ -38,7 +38,6 @@ const AccordionHeader = forwardRef<HTMLButtonElement, AccordionHeaderProps>(
38
38
  <span className="navds-accordion__icon-wrapper">
39
39
  <ChevronDownIcon
40
40
  className="navds-accordion__header-chevron"
41
- title="Vis mer"
42
41
  aria-hidden
43
42
  />
44
43
  </span>
@@ -9,6 +9,7 @@ import {
9
9
  } from "@navikt/aksel-icons";
10
10
  import { Button } from "../button";
11
11
  import { BodyLong } from "../typography";
12
+ import { useI18n } from "../util/i18n/i18n.context";
12
13
 
13
14
  export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
14
15
  /**
@@ -54,25 +55,13 @@ export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
54
55
  onClose?: () => void;
55
56
  }
56
57
 
57
- const Icon = ({ variant, ...props }) => {
58
- switch (variant) {
59
- case "error":
60
- return <XMarkOctagonFillIcon title="Feil" {...props} />;
61
- case "warning":
62
- return <ExclamationmarkTriangleFillIcon title="Advarsel" {...props} />;
63
- case "info":
64
- return <InformationSquareFillIcon title="Informasjon" {...props} />;
65
- case "success":
66
- return <CheckmarkCircleFillIcon title="Suksess" {...props} />;
67
- default:
68
- return null;
69
- }
58
+ const IconMap = {
59
+ error: XMarkOctagonFillIcon,
60
+ warning: ExclamationmarkTriangleFillIcon,
61
+ info: InformationSquareFillIcon,
62
+ success: CheckmarkCircleFillIcon,
70
63
  };
71
64
 
72
- export interface AlertContextProps {
73
- size: "medium" | "small";
74
- }
75
-
76
65
  /**
77
66
  * A component for displaying alerts
78
67
  * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/alert)
@@ -98,6 +87,8 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>(
98
87
  },
99
88
  ref,
100
89
  ) => {
90
+ const translate = useI18n("Alert");
91
+ const Icon = IconMap[variant];
101
92
  return (
102
93
  <div
103
94
  {...rest}
@@ -114,7 +105,7 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>(
114
105
  },
115
106
  )}
116
107
  >
117
- <Icon variant={variant} className="navds-alert__icon" />
108
+ <Icon title={translate(variant)} className="navds-alert__icon" />
118
109
  <BodyLong
119
110
  as="div"
120
111
  size={size}
@@ -137,8 +128,8 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>(
137
128
  <XMarkIcon
138
129
  title={
139
130
  ["error", "warning"].includes(variant)
140
- ? "Lukk varsel"
141
- : "Lukk melding"
131
+ ? translate("closeAlert")
132
+ : translate("closeMessage")
142
133
  }
143
134
  />
144
135
  }
@@ -2,6 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { XMarkIcon } from "@navikt/aksel-icons";
4
4
  import { composeEventHandlers } from "../util/composeEventHandlers";
5
+ import { useI18n } from "../util/i18n/i18n.context";
5
6
 
6
7
  export interface ChipsRemovableProps
7
8
  extends React.ButtonHTMLAttributes<HTMLButtonElement> {
@@ -11,15 +12,15 @@ export interface ChipsRemovableProps
11
12
  * @default "action"
12
13
  */
13
14
  variant?: "action" | "neutral";
14
- /**
15
- * Replaces label read for screen-readers
16
- * @default "slett filter"
17
- */
18
- removeLabel?: string;
19
15
  /**
20
16
  * Click callback
21
17
  */
22
18
  onDelete?: () => void;
19
+ /**
20
+ * Replaces label read for screen-readers
21
+ * @default "slett"
22
+ */
23
+ removeLabel?: string;
23
24
  }
24
25
 
25
26
  export const RemovableChips = forwardRef<
@@ -28,17 +29,18 @@ export const RemovableChips = forwardRef<
28
29
  >(
29
30
  (
30
31
  {
31
- className,
32
32
  children,
33
33
  variant = "action",
34
- removeLabel = "slett",
35
34
  onDelete,
36
- type = "button",
35
+ removeLabel,
36
+ className,
37
37
  onClick,
38
+ type = "button",
38
39
  ...rest
39
40
  },
40
41
  ref,
41
42
  ) => {
43
+ const translate = useI18n("Chips");
42
44
  return (
43
45
  <button
44
46
  {...rest}
@@ -49,7 +51,9 @@ export const RemovableChips = forwardRef<
49
51
  className,
50
52
  `navds-chips__removable--${variant}`,
51
53
  )}
52
- aria-label={`${children} ${removeLabel}`}
54
+ aria-label={`${children} ${
55
+ removeLabel ?? translate("Removable.labelSuffix")
56
+ }`}
53
57
  onClick={composeEventHandlers(onClick, onDelete)}
54
58
  >
55
59
  <span className="navds-chips__chip-text">{children}</span>
@@ -27,8 +27,8 @@ interface DatePickerComponent
27
27
  * ```jsx
28
28
  * <DatePicker.Standalone
29
29
  * dropdownCaption
30
- * fromDate={new Date("2020-10-01")}
31
- * toDate={new Date("2024-10-01")}
30
+ * fromDate={new Date("2022-10-01")}
31
+ * toDate={new Date("2026-10-01")}
32
32
  * />
33
33
  * ```
34
34
  */
@@ -19,8 +19,8 @@ interface MonthPickerComponent
19
19
  * ```jsx
20
20
  * <MonthPicker.Standalone
21
21
  * dropdownCaption
22
- * fromDate={new Date("1 Oct 2020")}
23
- * toDate={new Date("1 Oct 2024")}
22
+ * fromDate={new Date("1 Oct 2022")}
23
+ * toDate={new Date("1 Oct 2026")}
24
24
  * />
25
25
  * ```
26
26
  */
@@ -1,5 +1,4 @@
1
1
  import { fireEvent, render, screen } from "@testing-library/react";
2
- import faker from "faker";
3
2
  import React from "react";
4
3
  import { describe, expect, test, vi } from "vitest";
5
4
  import { Checkbox, CheckboxGroup } from ".";
@@ -10,8 +9,8 @@ const firstArgumentOfFirstCall = (fn: ReturnType<typeof vi.fn>) =>
10
9
  test("checkbox group chains onChange calls", async () => {
11
10
  const onGroupChange = vi.fn();
12
11
  const onChange = vi.fn();
13
- const value = faker.datatype.string();
14
- const label = faker.datatype.string();
12
+ const value = "Checkbox value";
13
+ const label = "My pretty label";
15
14
 
16
15
  render(
17
16
  <CheckboxGroup legend="legend" onChange={onGroupChange}>
@@ -1,11 +1,10 @@
1
1
  import { render, screen } from "@testing-library/react";
2
- import faker from "faker";
3
2
  import React from "react";
4
3
  import { expect, test } from "vitest";
5
4
  import { ConfirmationPanel } from ".";
6
5
 
7
6
  test("omits error id from input", async () => {
8
- const label = faker.datatype.string();
7
+ const label = "My label";
9
8
 
10
9
  render(<ConfirmationPanel label={label} errorId="wat"></ConfirmationPanel>);
11
10
 
@@ -1,14 +1,13 @@
1
1
  import { render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
- import faker from "faker";
4
3
  import React from "react";
5
4
  import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
6
5
  import { Radio, RadioGroup } from ".";
7
6
 
8
- const value1 = faker.datatype.string();
9
- const label1 = faker.datatype.string();
10
- const value2 = faker.datatype.string();
11
- const label2 = faker.datatype.string();
7
+ const value1 = "My first value";
8
+ const label1 = "World's best radio label";
9
+ const value2 = "Life changing value";
10
+ const label2 = "Radio label of the year";
12
11
 
13
12
  const Group = (props) => (
14
13
  <RadioGroup {...props} legend="legend">
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  export { Accordion, type AccordionProps } from "./accordion";
3
+ export { ActionMenu, type ActionMenuProps } from "./overlays/action-menu";
3
4
  export { Alert, type AlertProps } from "./alert";
4
5
  export { Button, type ButtonProps } from "./button";
5
6
  export { Chat, type ChatProps } from "./chat";
@@ -5,6 +5,9 @@ import { getResponsiveProps, getResponsiveValue } from "../utilities/css";
5
5
  import { ResponsiveProp, SpacingScale } from "../utilities/types";
6
6
 
7
7
  export type PrimitiveProps = {
8
+ /**
9
+ * @private Hides prop from documentation
10
+ */
8
11
  className?: string;
9
12
  /**
10
13
  * Padding around children.
@@ -19,42 +19,41 @@ import {
19
19
  SurfaceColorToken,
20
20
  } from "../utilities/types";
21
21
 
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
- };
22
+ export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
23
+ /**
24
+ * CSS `background-color` property.
25
+ * Accepts a [background/surface color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#afff774dad80).
26
+ */
27
+ background?: BackgroundColorToken | SurfaceColorToken;
28
+ /**
29
+ * CSS `border-color` property.
30
+ * Accepts a [border color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#adb1767e2f87).
31
+ */
32
+ borderColor?: BorderColorToken;
33
+ /**
34
+ * CSS `border-radius` property.
35
+ * Accepts a [radius token](https://aksel.nav.no/grunnleggende/styling/design-tokens#6d79c5605d31)
36
+ * or an object of radius tokens for different breakpoints.
37
+ * @example
38
+ * borderRadius='full'
39
+ * borderRadius='0 full large small'
40
+ * borderRadius={{xs: 'small large', sm: '0', md: 'large', lg: 'full'}}
41
+ */
42
+ borderRadius?: ResponsiveProp<SpaceDelimitedAttribute<BorderRadiiToken>>;
43
+ /**
44
+ * CSS `border-width` property. If this is not set there will be no border.
45
+ * @example
46
+ * borderWidth='2'
47
+ * borderWidth='1 2 3 4'
48
+ */
49
+ borderWidth?: SpaceDelimitedAttribute<"0" | "1" | "2" | "3" | "4" | "5">;
50
+ /** Shadow on box. Accepts a shadow token.
51
+ * @example
52
+ * shadow='small'
53
+ */
54
+ shadow?: ShadowToken;
55
+ } & PrimitiveProps &
56
+ PrimitiveAsChildProps;
58
57
 
59
58
  /**
60
59
  * Foundational Layout-primitive for generic encapsulation & styling.
@@ -10,33 +10,32 @@ import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
10
10
  import { getResponsiveProps, getResponsiveValue } from "../utilities/css";
11
11
  import { ResponsiveProp, SpacingScale } from "../utilities/types";
12
12
 
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
- };
13
+ export type HGridProps = React.HTMLAttributes<HTMLDivElement> & {
14
+ /**
15
+ * Number of columns to display. Can be a number, a string, or an object with values for specific breakpoints.
16
+ * Sets `grid-template-columns`, so `fr`, `minmax` etc. works.
17
+ * @example
18
+ * columns={{ sm: 1, md: 1, lg: "1fr auto", xl: "1fr auto"}}
19
+ * columns={3}
20
+ * columns="repeat(3, minmax(0, 1fr))"
21
+ */
22
+ columns?: ResponsiveProp<number | string>;
23
+ /**
24
+ * Spacing between columns.
25
+ * Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
26
+ * or an object of spacing tokens for different breakpoints.
27
+ * @example
28
+ * gap="6"
29
+ * gap="8 4"
30
+ * gap={{ sm: "2", md: "2", lg: "6", xl: "6"}}
31
+ */
32
+ gap?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
33
+ /**
34
+ * Vertical alignment of children. Elements will by default stretch to the height of parent-element.
35
+ */
36
+ align?: "start" | "center" | "end";
37
+ } & PrimitiveProps &
38
+ PrimitiveAsChildProps;
40
39
  /**
41
40
  * Horizontal Grid Primitive with dynamic columns and gap based on breakpoints.
42
41
  *
@@ -11,60 +11,59 @@ import { PrimitiveAsChildProps } from "../base/PrimitiveAsChildProps";
11
11
  import { getResponsiveProps, getResponsiveValue } from "../utilities/css";
12
12
  import { ResponsiveProp, SpacingScale } from "../utilities/types";
13
13
 
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
- };
14
+ export type StackProps = HTMLAttributes<HTMLDivElement> & {
15
+ /**
16
+ * CSS `justify-content` property.
17
+ *
18
+ * @example
19
+ * justify='center'
20
+ * justify={{xs: 'start', sm: 'center', md: 'end', lg: 'space-around', xl: 'space-between'}}
21
+ */
22
+ justify?: ResponsiveProp<
23
+ | "start"
24
+ | "center"
25
+ | "end"
26
+ | "space-around"
27
+ | "space-between"
28
+ | "space-evenly"
29
+ >;
30
+ /**
31
+ * CSS `align-items` property.
32
+ * @default "stretch"
33
+ *
34
+ * @example
35
+ * align='center'
36
+ * align={{xs: 'start', sm: 'center', md: 'end', lg: 'baseline', xl: 'stretch'}}
37
+ */
38
+ align?: ResponsiveProp<"start" | "center" | "end" | "baseline" | "stretch">;
39
+ /**
40
+ * Sets the CSS `flex-wrap` property.
41
+ */
42
+ wrap?: boolean;
43
+ /**
44
+ * CSS `gap` property.
45
+ * Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#0cc9fb32f213)
46
+ * or an object of spacing tokens for different breakpoints.
47
+ *
48
+ * @example
49
+ * gap='4'
50
+ * gap='8 4'
51
+ * gap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
52
+ */
53
+ gap?: ResponsiveProp<SpacingScale | `${SpacingScale} ${SpacingScale}`>;
54
+ /**
55
+ * CSS `flex-direction` property.
56
+ * @default "row"
57
+ *
58
+ * @example
59
+ * direction='row'
60
+ * direction={{xs: 'row', sm: 'column'}}
61
+ */
62
+ direction?: ResponsiveProp<
63
+ "row" | "column" | "row-reverse" | "column-reverse"
64
+ >;
65
+ } & PrimitiveProps &
66
+ PrimitiveAsChildProps;
68
67
 
69
68
  export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
70
69
  forwardRef(
@@ -25,6 +25,12 @@ const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
25
25
  className="navds-modal__button"
26
26
  size="small"
27
27
  variant="tertiary-neutral"
28
+ onKeyDown={(event) => {
29
+ /* Prevents autofocus used in combination with holding down keys from closing modal */
30
+ if (["Enter", " "].includes(event.key) && event.repeat) {
31
+ event.preventDefault();
32
+ }
33
+ }}
28
34
  onClick={context.closeHandler}
29
35
  icon={<XMarkIcon title="Lukk" />}
30
36
  />
@@ -518,7 +518,7 @@ dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
518
518
  // Some browsers throw on cssRules.
519
519
  try {
520
520
  cssRules = styleSheet.cssRules;
521
- } catch (e) {
521
+ } catch {
522
522
  /* empty */
523
523
  }
524
524
  if (!cssRules) {
@@ -530,7 +530,7 @@ dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
530
530
  // Ignore errors on invalid selector texts.
531
531
  try {
532
532
  selectedNodes = document.querySelectorAll(rule.selectorText);
533
- } catch (e) {
533
+ } catch {
534
534
  /* empty */
535
535
  }
536
536
  if (!selectedNodes || !inNodeList(selectedNodes, element)) {