@navikt/ds-react 7.9.0 → 7.9.2

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 (263) hide show
  1. package/README.md +2 -2
  2. package/cjs/alert/Alert.js +2 -2
  3. package/cjs/alert/Alert.js.map +1 -1
  4. package/cjs/chips/Removable.js +2 -2
  5. package/cjs/chips/Removable.js.map +1 -1
  6. package/cjs/copybutton/CopyButton.js +2 -2
  7. package/cjs/copybutton/CopyButton.js.map +1 -1
  8. package/cjs/date/context/useDateTranslationContext.d.ts +1 -1
  9. package/cjs/date/datepicker/DatePicker.js +3 -3
  10. package/cjs/date/datepicker/DatePicker.js.map +1 -1
  11. package/cjs/date/datepicker/DatePickerStandalone.js +3 -3
  12. package/cjs/date/datepicker/DatePickerStandalone.js.map +1 -1
  13. package/cjs/date/hooks/useDatepicker.js +2 -2
  14. package/cjs/date/hooks/useDatepicker.js.map +1 -1
  15. package/cjs/date/hooks/useMonthPicker.js +2 -2
  16. package/cjs/date/hooks/useMonthPicker.js.map +1 -1
  17. package/cjs/date/hooks/useRangeDatepicker.js +2 -2
  18. package/cjs/date/hooks/useRangeDatepicker.js.map +1 -1
  19. package/cjs/date/monthpicker/MonthPicker.js +3 -3
  20. package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
  21. package/cjs/date/monthpicker/MonthPickerStandalone.js +3 -3
  22. package/cjs/date/monthpicker/MonthPickerStandalone.js.map +1 -1
  23. package/cjs/date/parts/DateWrapper.d.ts +1 -1
  24. package/cjs/date/parts/DateWrapper.js +2 -2
  25. package/cjs/date/parts/DateWrapper.js.map +1 -1
  26. package/cjs/expansion-card/ExpansionCardHeader.js +2 -2
  27. package/cjs/expansion-card/ExpansionCardHeader.js.map +1 -1
  28. package/cjs/form/ReadOnlyIcon.js +2 -2
  29. package/cjs/form/ReadOnlyIcon.js.map +1 -1
  30. package/cjs/form/combobox/FilteredOptions/AddNewOption.js +2 -2
  31. package/cjs/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
  32. package/cjs/form/combobox/FilteredOptions/LoadingMessage.js +2 -2
  33. package/cjs/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
  34. package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js +2 -2
  35. package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
  36. package/cjs/form/error-summary/ErrorSummary.js +2 -2
  37. package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
  38. package/cjs/form/file-upload/parts/dropzone/Dropzone.js +2 -2
  39. package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
  40. package/cjs/form/file-upload/parts/item/Item.js +2 -2
  41. package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
  42. package/cjs/form/form-progress/FormProgress.js +2 -2
  43. package/cjs/form/form-progress/FormProgress.js.map +1 -1
  44. package/cjs/form/form-summary/FormSummaryEditLink.js +2 -2
  45. package/cjs/form/form-summary/FormSummaryEditLink.js.map +1 -1
  46. package/cjs/form/search/Search.js +2 -2
  47. package/cjs/form/search/Search.js.map +1 -1
  48. package/cjs/form/search/SearchButton.js +2 -2
  49. package/cjs/form/search/SearchButton.js.map +1 -1
  50. package/cjs/form/textarea/TextareaCounter.js +2 -2
  51. package/cjs/form/textarea/TextareaCounter.js.map +1 -1
  52. package/cjs/guide-panel/Illustration.darkside.js +2 -2
  53. package/cjs/guide-panel/Illustration.darkside.js.map +1 -1
  54. package/cjs/guide-panel/Illustration.js +2 -2
  55. package/cjs/guide-panel/Illustration.js.map +1 -1
  56. package/cjs/help-text/HelpText.js +2 -2
  57. package/cjs/help-text/HelpText.js.map +1 -1
  58. package/cjs/layout/base/BasePrimitive.d.ts +27 -27
  59. package/cjs/layout/bleed/Bleed.d.ts +6 -6
  60. package/cjs/layout/box/Box.darkside.d.ts +3 -3
  61. package/cjs/layout/grid/HGrid.d.ts +3 -3
  62. package/cjs/layout/stack/Stack.d.ts +3 -3
  63. package/cjs/layout/utilities/css.d.ts +1 -1
  64. package/cjs/layout/utilities/css.js +49 -20
  65. package/cjs/layout/utilities/css.js.map +1 -1
  66. package/cjs/layout/utilities/types.d.ts +2 -2
  67. package/cjs/link/stories/RandomIcon.d.ts +2 -0
  68. package/cjs/link/stories/RandomIcon.js +39 -0
  69. package/cjs/link/stories/RandomIcon.js.map +1 -0
  70. package/cjs/loader/Loader.js +2 -2
  71. package/cjs/loader/Loader.js.map +1 -1
  72. package/cjs/modal/ModalHeader.js +2 -2
  73. package/cjs/modal/ModalHeader.js.map +1 -1
  74. package/cjs/pagination/Pagination.js +2 -2
  75. package/cjs/pagination/Pagination.js.map +1 -1
  76. package/cjs/progress-bar/ProgressBar.js +2 -2
  77. package/cjs/progress-bar/ProgressBar.js.map +1 -1
  78. package/cjs/table/ExpandableRow.js +2 -2
  79. package/cjs/table/ExpandableRow.js.map +1 -1
  80. package/cjs/tag/Tag.d.ts +1 -1
  81. package/cjs/timeline/AxisLabels.js +3 -3
  82. package/cjs/timeline/AxisLabels.js.map +1 -1
  83. package/cjs/timeline/Pin.js +2 -2
  84. package/cjs/timeline/Pin.js.map +1 -1
  85. package/cjs/timeline/TimelineRow.js +2 -2
  86. package/cjs/timeline/TimelineRow.js.map +1 -1
  87. package/cjs/timeline/period/ClickablePeriod.js +2 -2
  88. package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
  89. package/cjs/timeline/period/NonClickablePeriod.js +2 -2
  90. package/cjs/timeline/period/NonClickablePeriod.js.map +1 -1
  91. package/cjs/timeline/utils/period.d.ts +1 -1
  92. package/cjs/timeline/zoom/ZoomButton.js +2 -2
  93. package/cjs/timeline/zoom/ZoomButton.js.map +1 -1
  94. package/cjs/util/i18n/i18n.hooks.d.ts +4 -0
  95. package/cjs/util/i18n/{i18n.context.js → i18n.hooks.js} +3 -7
  96. package/cjs/util/i18n/i18n.hooks.js.map +1 -0
  97. package/cjs/util/i18n/i18n.types.d.ts +4 -0
  98. package/cjs/util/i18n/locales/nb.d.ts +81 -4
  99. package/cjs/util/i18n/locales/nb.js +81 -4
  100. package/cjs/util/i18n/locales/nb.js.map +1 -1
  101. package/esm/alert/Alert.js +1 -1
  102. package/esm/alert/Alert.js.map +1 -1
  103. package/esm/chips/Removable.js +1 -1
  104. package/esm/chips/Removable.js.map +1 -1
  105. package/esm/copybutton/CopyButton.js +1 -1
  106. package/esm/copybutton/CopyButton.js.map +1 -1
  107. package/esm/date/context/useDateTranslationContext.d.ts +1 -1
  108. package/esm/date/datepicker/DatePicker.js +1 -1
  109. package/esm/date/datepicker/DatePicker.js.map +1 -1
  110. package/esm/date/datepicker/DatePickerStandalone.js +1 -1
  111. package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
  112. package/esm/date/hooks/useDatepicker.js +1 -1
  113. package/esm/date/hooks/useDatepicker.js.map +1 -1
  114. package/esm/date/hooks/useMonthPicker.js +1 -1
  115. package/esm/date/hooks/useMonthPicker.js.map +1 -1
  116. package/esm/date/hooks/useRangeDatepicker.js +1 -1
  117. package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
  118. package/esm/date/monthpicker/MonthPicker.js +1 -1
  119. package/esm/date/monthpicker/MonthPicker.js.map +1 -1
  120. package/esm/date/monthpicker/MonthPickerStandalone.js +1 -1
  121. package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
  122. package/esm/date/parts/DateWrapper.d.ts +1 -1
  123. package/esm/date/parts/DateWrapper.js +1 -1
  124. package/esm/date/parts/DateWrapper.js.map +1 -1
  125. package/esm/expansion-card/ExpansionCardHeader.js +1 -1
  126. package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
  127. package/esm/form/ReadOnlyIcon.js +1 -1
  128. package/esm/form/ReadOnlyIcon.js.map +1 -1
  129. package/esm/form/combobox/FilteredOptions/AddNewOption.js +1 -1
  130. package/esm/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
  131. package/esm/form/combobox/FilteredOptions/LoadingMessage.js +1 -1
  132. package/esm/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
  133. package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js +1 -1
  134. package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
  135. package/esm/form/error-summary/ErrorSummary.js +1 -1
  136. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  137. package/esm/form/file-upload/parts/dropzone/Dropzone.js +1 -1
  138. package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
  139. package/esm/form/file-upload/parts/item/Item.js +1 -1
  140. package/esm/form/file-upload/parts/item/Item.js.map +1 -1
  141. package/esm/form/form-progress/FormProgress.js +1 -1
  142. package/esm/form/form-progress/FormProgress.js.map +1 -1
  143. package/esm/form/form-summary/FormSummaryEditLink.js +1 -1
  144. package/esm/form/form-summary/FormSummaryEditLink.js.map +1 -1
  145. package/esm/form/search/Search.js +1 -1
  146. package/esm/form/search/Search.js.map +1 -1
  147. package/esm/form/search/SearchButton.js +1 -1
  148. package/esm/form/search/SearchButton.js.map +1 -1
  149. package/esm/form/textarea/TextareaCounter.js +1 -1
  150. package/esm/form/textarea/TextareaCounter.js.map +1 -1
  151. package/esm/guide-panel/Illustration.darkside.js +1 -1
  152. package/esm/guide-panel/Illustration.darkside.js.map +1 -1
  153. package/esm/guide-panel/Illustration.js +1 -1
  154. package/esm/guide-panel/Illustration.js.map +1 -1
  155. package/esm/help-text/HelpText.js +1 -1
  156. package/esm/help-text/HelpText.js.map +1 -1
  157. package/esm/layout/base/BasePrimitive.d.ts +27 -27
  158. package/esm/layout/bleed/Bleed.d.ts +6 -6
  159. package/esm/layout/box/Box.darkside.d.ts +3 -3
  160. package/esm/layout/grid/HGrid.d.ts +3 -3
  161. package/esm/layout/stack/Stack.d.ts +3 -3
  162. package/esm/layout/utilities/css.d.ts +1 -1
  163. package/esm/layout/utilities/css.js +49 -20
  164. package/esm/layout/utilities/css.js.map +1 -1
  165. package/esm/layout/utilities/types.d.ts +2 -2
  166. package/esm/link/stories/RandomIcon.d.ts +2 -0
  167. package/esm/link/stories/RandomIcon.js +9 -0
  168. package/esm/link/stories/RandomIcon.js.map +1 -0
  169. package/esm/loader/Loader.js +1 -1
  170. package/esm/loader/Loader.js.map +1 -1
  171. package/esm/modal/ModalHeader.js +1 -1
  172. package/esm/modal/ModalHeader.js.map +1 -1
  173. package/esm/pagination/Pagination.js +1 -1
  174. package/esm/pagination/Pagination.js.map +1 -1
  175. package/esm/progress-bar/ProgressBar.js +1 -1
  176. package/esm/progress-bar/ProgressBar.js.map +1 -1
  177. package/esm/table/ExpandableRow.js +1 -1
  178. package/esm/table/ExpandableRow.js.map +1 -1
  179. package/esm/tag/Tag.d.ts +1 -1
  180. package/esm/timeline/AxisLabels.js +1 -1
  181. package/esm/timeline/AxisLabels.js.map +1 -1
  182. package/esm/timeline/Pin.js +1 -1
  183. package/esm/timeline/Pin.js.map +1 -1
  184. package/esm/timeline/TimelineRow.js +1 -1
  185. package/esm/timeline/TimelineRow.js.map +1 -1
  186. package/esm/timeline/period/ClickablePeriod.js +1 -1
  187. package/esm/timeline/period/ClickablePeriod.js.map +1 -1
  188. package/esm/timeline/period/NonClickablePeriod.js +1 -1
  189. package/esm/timeline/period/NonClickablePeriod.js.map +1 -1
  190. package/esm/timeline/utils/period.d.ts +1 -1
  191. package/esm/timeline/zoom/ZoomButton.js +1 -1
  192. package/esm/timeline/zoom/ZoomButton.js.map +1 -1
  193. package/esm/util/i18n/i18n.hooks.d.ts +4 -0
  194. package/esm/util/i18n/{i18n.context.js → i18n.hooks.js} +3 -7
  195. package/esm/util/i18n/{i18n.context.js.map → i18n.hooks.js.map} +1 -1
  196. package/esm/util/i18n/i18n.types.d.ts +4 -0
  197. package/esm/util/i18n/locales/nb.d.ts +81 -4
  198. package/esm/util/i18n/locales/nb.js +81 -4
  199. package/esm/util/i18n/locales/nb.js.map +1 -1
  200. package/package.json +17 -12
  201. package/src/alert/Alert.tsx +1 -1
  202. package/src/chips/Removable.tsx +1 -1
  203. package/src/copybutton/CopyButton.tsx +1 -1
  204. package/src/date/context/useDateTranslationContext.ts +1 -1
  205. package/src/date/datepicker/DatePicker.tsx +1 -1
  206. package/src/date/datepicker/DatePickerStandalone.tsx +1 -1
  207. package/src/date/datepicker/datepicker.test.tsx +2 -5
  208. package/src/date/hooks/useDatepicker.tsx +1 -1
  209. package/src/date/hooks/useMonthPicker.tsx +1 -1
  210. package/src/date/hooks/useRangeDatepicker.test.tsx +5 -10
  211. package/src/date/hooks/useRangeDatepicker.tsx +1 -1
  212. package/src/date/monthpicker/MonthPicker.tsx +1 -1
  213. package/src/date/monthpicker/MonthPickerStandalone.tsx +1 -1
  214. package/src/date/parts/DateWrapper.tsx +2 -1
  215. package/src/expansion-card/ExpansionCardHeader.tsx +1 -1
  216. package/src/form/ReadOnlyIcon.tsx +1 -1
  217. package/src/form/combobox/FilteredOptions/AddNewOption.tsx +1 -1
  218. package/src/form/combobox/FilteredOptions/LoadingMessage.tsx +1 -1
  219. package/src/form/combobox/FilteredOptions/MaxSelectedMessage.tsx +1 -1
  220. package/src/form/error-summary/ErrorSummary.tsx +1 -1
  221. package/src/form/file-upload/parts/dropzone/Dropzone.tsx +1 -1
  222. package/src/form/file-upload/parts/item/Item.tsx +1 -1
  223. package/src/form/form-progress/FormProgress.tsx +1 -1
  224. package/src/form/form-summary/FormSummaryEditLink.tsx +1 -1
  225. package/src/form/search/Search.tsx +1 -1
  226. package/src/form/search/SearchButton.tsx +1 -1
  227. package/src/form/textarea/TextareaCounter.tsx +1 -1
  228. package/src/guide-panel/Illustration.darkside.tsx +1 -1
  229. package/src/guide-panel/Illustration.tsx +1 -1
  230. package/src/help-text/HelpText.tsx +1 -1
  231. package/src/layout/base/BasePrimitive.tsx +27 -27
  232. package/src/layout/bleed/Bleed.tsx +6 -6
  233. package/src/layout/box/Box.darkside.tsx +3 -3
  234. package/src/layout/grid/HGrid.tsx +3 -3
  235. package/src/layout/stack/Stack.tsx +3 -3
  236. package/src/layout/utilities/css.ts +56 -24
  237. package/src/layout/utilities/types.ts +3 -2
  238. package/src/loader/Loader.tsx +1 -1
  239. package/src/modal/ModalHeader.tsx +1 -1
  240. package/src/pagination/Pagination.tsx +1 -1
  241. package/src/progress-bar/ProgressBar.tsx +1 -1
  242. package/src/table/ExpandableRow.tsx +1 -1
  243. package/src/tabs/Tabs.test.tsx +4 -12
  244. package/src/tag/Tag.tsx +6 -6
  245. package/src/timeline/AxisLabels.tsx +2 -1
  246. package/src/timeline/Pin.tsx +1 -1
  247. package/src/timeline/TimelineRow.tsx +1 -1
  248. package/src/timeline/period/ClickablePeriod.tsx +1 -1
  249. package/src/timeline/period/NonClickablePeriod.tsx +1 -1
  250. package/src/timeline/utils/period.ts +1 -1
  251. package/src/timeline/zoom/ZoomButton.tsx +1 -1
  252. package/src/util/i18n/{i18n.context.test.tsx → i18n.hooks.test.tsx} +62 -3
  253. package/src/util/i18n/{i18n.context.ts → i18n.hooks.ts} +3 -19
  254. package/src/util/i18n/i18n.types.ts +12 -0
  255. package/cjs/modal/types.test-d.d.ts +0 -1
  256. package/cjs/modal/types.test-d.js +0 -67
  257. package/cjs/modal/types.test-d.js.map +0 -1
  258. package/cjs/util/i18n/i18n.context.d.ts +0 -9
  259. package/cjs/util/i18n/i18n.context.js.map +0 -1
  260. package/esm/modal/types.test-d.d.ts +0 -1
  261. package/esm/modal/types.test-d.js +0 -65
  262. package/esm/modal/types.test-d.js.map +0 -1
  263. package/esm/util/i18n/i18n.context.d.ts +0 -9
@@ -1,3 +1,4 @@
1
+ import type { LegacySpacingKeys, SpaceKeys } from "@navikt/ds-tokens/types";
1
2
  import { ResponsiveProp } from "./types";
2
3
 
3
4
  export function getResponsiveValue<T = string>(
@@ -24,46 +25,77 @@ export function getResponsiveValue<T = string>(
24
25
  );
25
26
  }
26
27
 
27
- const translateExceptionToCSS = (exception: string) => {
28
- switch (exception) {
29
- case "px":
30
- return "1px";
31
- }
32
- return exception;
28
+ /**
29
+ * Temporary lookup for mapping legacy spacing tokens to new space tokens.
30
+ */
31
+ const legacySpacingTokenLookup: Record<
32
+ `--ax-spacing-${LegacySpacingKeys}`,
33
+ `--ax-${SpaceKeys}`
34
+ > = {
35
+ "--ax-spacing-32": "--ax-space-128",
36
+ "--ax-spacing-24": "--ax-space-96",
37
+ "--ax-spacing-20": "--ax-space-80",
38
+ "--ax-spacing-18": "--ax-space-72",
39
+ "--ax-spacing-16": "--ax-space-64",
40
+ "--ax-spacing-14": "--ax-space-56",
41
+ "--ax-spacing-12": "--ax-space-48",
42
+ "--ax-spacing-11": "--ax-space-44",
43
+ "--ax-spacing-10": "--ax-space-40",
44
+ "--ax-spacing-9": "--ax-space-36",
45
+ "--ax-spacing-8": "--ax-space-32",
46
+ "--ax-spacing-7": "--ax-space-28",
47
+ "--ax-spacing-6": "--ax-space-24",
48
+ "--ax-spacing-5": "--ax-space-20",
49
+ "--ax-spacing-4": "--ax-space-16",
50
+ "--ax-spacing-3": "--ax-space-12",
51
+ "--ax-spacing-2": "--ax-space-8",
52
+ "--ax-spacing-1-alt": "--ax-space-6",
53
+ "--ax-spacing-1": "--ax-space-4",
54
+ "--ax-spacing-05": "--ax-space-2",
55
+ "--ax-spacing-0": "--ax-space-0",
33
56
  };
34
57
 
35
58
  const translateTokenStringToCSS = (
36
- componentProp: string,
59
+ specialLayout: string,
37
60
  tokenString: string,
38
- tokenSubgroup: string,
61
+ tokenSubgroup: "spacing" | "border-radius",
39
62
  tokenExceptions: string[],
40
63
  invert: boolean,
41
64
  prefix: string,
42
65
  ) => {
43
66
  return tokenString
44
67
  .split(" ")
45
- .map((x, _, arr) => {
46
- if (componentProp === "margin-inline" && x === "full") {
47
- const width = 100 / arr.length;
48
- return `calc((100vw - ${width}%)/-2)`;
68
+ .map((propValue, _, arr) => {
69
+ // Handle special layout cases
70
+ if (specialLayout === "margin-inline" && propValue === "full") {
71
+ return `calc((100vw - ${100 / arr.length}%)/-2)`;
49
72
  }
50
-
51
- if (componentProp === "padding-inline" && x === "full") {
52
- const width = 100 / arr.length;
53
- return `calc((100vw - ${width}%)/2)`;
73
+ if (specialLayout === "padding-inline" && propValue === "full") {
74
+ return `calc((100vw - ${100 / arr.length}%)/2)`;
54
75
  }
55
- if (["mi", "mb"].includes(componentProp) && x === "auto") {
76
+ if (["mi", "mb"].includes(specialLayout) && propValue === "auto") {
56
77
  return "auto";
57
78
  }
58
79
 
59
- let output = `var(--${prefix}-${tokenSubgroup}-${x})`;
60
- if (tokenExceptions.includes(x)) {
61
- output = translateExceptionToCSS(x);
80
+ // Handle exceptions and space tokens
81
+ let output = `var(--${prefix}-${tokenSubgroup}-${propValue})`;
82
+
83
+ if (tokenExceptions.includes(propValue)) {
84
+ output = propValue === "px" ? "1px" : propValue;
85
+ } else if (tokenSubgroup === "spacing" && propValue.startsWith("space")) {
86
+ /* Use new "space-x" tokens */
87
+ output = `var(--${prefix}-${propValue})`;
88
+ } else if (tokenSubgroup === "spacing") {
89
+ /* Translate old "spacing" tokens to new "space" tokens */
90
+ const spacingTokenName = `--${prefix}-spacing-${propValue}`;
91
+ output = `var(${
92
+ legacySpacingTokenLookup[spacingTokenName] ?? spacingTokenName
93
+ })`;
62
94
  }
95
+
96
+ // Handle inversion for negative values
63
97
  if (invert) {
64
- if (x === "0") {
65
- return `0`;
66
- }
98
+ if (propValue === "0") return `0`;
67
99
  return `calc(-1 * ${output})`;
68
100
  }
69
101
  return output;
@@ -75,7 +107,7 @@ export function getResponsiveProps<T extends string>(
75
107
  prefix: string,
76
108
  componentName: string,
77
109
  componentProp: string,
78
- tokenSubgroup: string,
110
+ tokenSubgroup: "spacing" | "border-radius",
79
111
  responsiveProp?: ResponsiveProp<T>,
80
112
  invert = false,
81
113
  tokenExceptions: string[] = [],
@@ -3,8 +3,9 @@ import type {
3
3
  LegacyBgColorKeys,
4
4
  LegacyBorderColorKeys,
5
5
  LegacyShadowKeys,
6
+ LegacySpacingKeys,
6
7
  LegacySurfaceColorKeys,
7
- SpacingKeys,
8
+ SpaceKeys,
8
9
  } from "@navikt/ds-tokens/types";
9
10
 
10
11
  export type BackgroundColorToken = LegacyBgColorKeys;
@@ -17,7 +18,7 @@ export type BreakpointsAlias = Extract<
17
18
  "xs" | "sm" | "md" | "lg" | "xl" | "2xl"
18
19
  >;
19
20
 
20
- export type SpacingScale = SpacingKeys;
21
+ export type SpacingScale = LegacySpacingKeys | SpaceKeys;
21
22
 
22
23
  export type SpaceDelimitedAttribute<T extends string> =
23
24
  | T
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import React, { SVGProps, forwardRef } from "react";
3
3
  import { omit } from "../util";
4
4
  import { useId } from "../util/hooks";
5
- import { useI18n } from "../util/i18n/i18n.context";
5
+ import { useI18n } from "../util/i18n/i18n.hooks";
6
6
 
7
7
  export interface LoaderProps extends Omit<SVGProps<SVGSVGElement>, "ref"> {
8
8
  /**
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { XMarkIcon } from "@navikt/aksel-icons";
4
4
  import { Button } from "../button";
5
- import { useI18n } from "../util/i18n/i18n.context";
5
+ import { useI18n } from "../util/i18n/i18n.hooks";
6
6
  import { useModalContext } from "./Modal.context";
7
7
 
8
8
  export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -3,7 +3,7 @@ import React, { forwardRef } from "react";
3
3
  import { ChevronLeftIcon, ChevronRightIcon } from "@navikt/aksel-icons";
4
4
  import { BodyShort, Heading } from "../typography";
5
5
  import { useId } from "../util";
6
- import { useI18n } from "../util/i18n/i18n.context";
6
+ import { useI18n } from "../util/i18n/i18n.hooks";
7
7
  import PaginationItem, {
8
8
  PaginationItemProps,
9
9
  PaginationItemType,
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { HTMLAttributes, forwardRef, useEffect, useRef } from "react";
3
- import { useI18n } from "../util/i18n/i18n.context";
3
+ import { useI18n } from "../util/i18n/i18n.hooks";
4
4
 
5
5
  interface ProgressBarPropsBase
6
6
  extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
@@ -4,7 +4,7 @@ import { ChevronDownIcon } from "@navikt/aksel-icons";
4
4
  import { composeEventHandlers } from "../util/composeEventHandlers";
5
5
  import { useId } from "../util/hooks";
6
6
  import { useControllableState } from "../util/hooks/useControllableState";
7
- import { useI18n } from "../util/i18n/i18n.context";
7
+ import { useI18n } from "../util/i18n/i18n.hooks";
8
8
  import AnimateHeight from "./AnimateHeight";
9
9
  import DataCell from "./DataCell";
10
10
  import Row, { RowProps } from "./Row";
@@ -1,4 +1,4 @@
1
- import { act, fireEvent, render, screen } from "@testing-library/react";
1
+ import { fireEvent, render, screen } from "@testing-library/react";
2
2
  import userEvent from "@testing-library/user-event";
3
3
  import React from "react";
4
4
  import { describe, expect, test } from "vitest";
@@ -154,19 +154,11 @@ describe("Tabs", () => {
154
154
  expect(screen.getByTestId("tab2")).toHaveFocus();
155
155
 
156
156
  /* Move focus to tabPanel */
157
- // eslint-disable-next-line testing-library/no-unnecessary-act
158
- await act(async () => {
159
- /* Tablist handles tabbing with setTimeout, so we need to use act */
160
- await userEvent.tab();
161
- });
162
-
157
+ await userEvent.tab();
163
158
  expect(screen.getByTestId("tabpanel1")).toHaveFocus();
164
- /* Move focus back to tablist, now tab1 should have focus */
165
159
 
166
- // eslint-disable-next-line testing-library/no-unnecessary-act
167
- await act(async () => {
168
- await userEvent.tab({ shift: true });
169
- });
160
+ /* Move focus back to tablist, now tab1 should have focus */
161
+ await userEvent.tab({ shift: true });
170
162
  expect(screen.getByTestId("tab1")).toHaveFocus();
171
163
  });
172
164
  });
package/src/tag/Tag.tsx CHANGED
@@ -32,12 +32,12 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
32
32
  | "alt3"
33
33
  | "alt3-filled"
34
34
  | "alt3-moderate"
35
- | "meta-purple"
36
- | "meta-purple-filled"
37
- | "meta-purple-moderate"
38
- | "meta-lime"
39
- | "meta-lime-filled"
40
- | "meta-lime-moderate";
35
+ | "meta-1"
36
+ | "meta-1-filled"
37
+ | "meta-1-moderate"
38
+ | "meta-2"
39
+ | "meta-2-filled"
40
+ | "meta-2-moderate";
41
41
  /**
42
42
  * @default "medium"
43
43
  */
@@ -16,7 +16,8 @@ import {
16
16
  } from "date-fns";
17
17
  import React from "react";
18
18
  import { Detail } from "../typography/Detail";
19
- import { TFunction, useDateLocale, useI18n } from "../util/i18n/i18n.context";
19
+ import { useDateLocale, useI18n } from "../util/i18n/i18n.hooks";
20
+ import { TFunction } from "../util/i18n/i18n.types";
20
21
  import { useTimelineContext } from "./hooks/useTimelineContext";
21
22
  import { isVisible } from "./utils";
22
23
  import { horizontalPositionAndWidth } from "./utils/calc";
@@ -17,7 +17,7 @@ import { format } from "date-fns";
17
17
  import React, { forwardRef, useRef, useState } from "react";
18
18
  import { useThemeInternal } from "../theme/Theme";
19
19
  import { useMergeRefs } from "../util/hooks/useMergeRefs";
20
- import { useI18n } from "../util/i18n/i18n.context";
20
+ import { useI18n } from "../util/i18n/i18n.hooks";
21
21
  import { useTimelineContext } from "./hooks/useTimelineContext";
22
22
  import { position } from "./utils/calc";
23
23
  import { TimelineComponentTypes } from "./utils/types.internal";
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import { format } from "date-fns";
3
3
  import React, { forwardRef } from "react";
4
4
  import { BodyShort } from "../typography/BodyShort";
5
- import { useI18n } from "../util/i18n/i18n.context";
5
+ import { useI18n } from "../util/i18n/i18n.hooks";
6
6
  import { PeriodContext } from "./hooks/usePeriodContext";
7
7
  import { useRowContext } from "./hooks/useRowContext";
8
8
  import { useTimelineContext } from "./hooks/useTimelineContext";
@@ -17,7 +17,7 @@ import cl from "clsx";
17
17
  import React, { useRef, useState } from "react";
18
18
  import { useThemeInternal } from "../../theme/Theme";
19
19
  import { useMergeRefs } from "../../util/hooks/useMergeRefs";
20
- import { useI18n } from "../../util/i18n/i18n.context";
20
+ import { useI18n } from "../../util/i18n/i18n.hooks";
21
21
  import { usePeriodContext } from "../hooks/usePeriodContext";
22
22
  import { useRowContext } from "../hooks/useRowContext";
23
23
  import { useTimelineContext } from "../hooks/useTimelineContext";
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React from "react";
3
- import { useI18n } from "../../util/i18n/i18n.context";
3
+ import { useI18n } from "../../util/i18n/i18n.hooks";
4
4
  import { ariaLabel, getConditionalClasses } from "../utils/period";
5
5
  import type { PeriodProps } from "./types";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import { format } from "date-fns";
3
- import type { TFunction } from "../../util/i18n/i18n.context";
3
+ import type { TFunction } from "../../util/i18n/i18n.types";
4
4
  import type { PeriodProps } from "../period/types";
5
5
 
6
6
  export const getConditionalClasses = (
@@ -8,7 +8,7 @@ import {
8
8
  } from "date-fns";
9
9
  import React, { forwardRef } from "react";
10
10
  import { Detail } from "../../typography/Detail";
11
- import { useI18n } from "../../util/i18n/i18n.context";
11
+ import { useI18n } from "../../util/i18n/i18n.hooks";
12
12
  import { useTimelineContext } from "../hooks/useTimelineContext";
13
13
 
14
14
  export interface TimelineZoomButtonProps {
@@ -2,9 +2,8 @@ import { renderHook } from "@testing-library/react";
2
2
  import React from "react";
3
3
  import { describe, expect, test } from "vitest";
4
4
  import { Provider } from "../../provider";
5
- import { useI18n } from "./i18n.context";
6
- import en from "./locales/en";
7
- import nb from "./locales/nb";
5
+ import { useDateLocale, useI18n } from "./i18n.hooks";
6
+ import { en, nb, nn } from "./locales";
8
7
 
9
8
  describe("useI18n", () => {
10
9
  test("should throw error if key is not found", () => {
@@ -112,3 +111,63 @@ describe("useI18n", () => {
112
111
  expect(() => translate("item.uploading", { other: "John" })).toThrowError();
113
112
  });
114
113
  });
114
+
115
+ describe("useDateLocale", () => {
116
+ test("should return the default NB date locale when Provider is not used", () => {
117
+ const { result } = renderHook(() => useDateLocale());
118
+ const dateLocale = result.current;
119
+ expect(dateLocale).toBe(nb.global.dateLocale);
120
+ });
121
+
122
+ test("should return the default NB date locale when Provider is used without the locale prop", () => {
123
+ const { result } = renderHook(() => useDateLocale(), {
124
+ wrapper: ({ children }) => <Provider>{children}</Provider>,
125
+ });
126
+ const dateLocale = result.current;
127
+ expect(dateLocale).toBe(nb.global.dateLocale);
128
+ });
129
+
130
+ test("should return date locale from context.locale when using Provider with just locale prop", () => {
131
+ const { result } = renderHook(() => useDateLocale(), {
132
+ wrapper: ({ children }) => <Provider locale={en}>{children}</Provider>,
133
+ });
134
+ const dateLocale = result.current;
135
+ expect(dateLocale).toBe(en.global.dateLocale);
136
+ });
137
+
138
+ test("should return date locale from context.locale when it does not exist in translations", () => {
139
+ const { result } = renderHook(() => useDateLocale(), {
140
+ wrapper: ({ children }) => (
141
+ <Provider locale={en} translations={{ global: {} }}>
142
+ {children}
143
+ </Provider>
144
+ ),
145
+ });
146
+ const dateLocale = result.current;
147
+ expect(dateLocale).toBe(en.global.dateLocale);
148
+ });
149
+
150
+ test("should return date locale from context.translations", () => {
151
+ const { result } = renderHook(() => useDateLocale(), {
152
+ wrapper: ({ children }) => (
153
+ <Provider locale={en} translations={nn}>
154
+ {children}
155
+ </Provider>
156
+ ),
157
+ });
158
+ const dateLocale = result.current;
159
+ expect(dateLocale).toBe(nn.global.dateLocale);
160
+ });
161
+
162
+ test("should return date locale from second object in context.translations", () => {
163
+ const { result } = renderHook(() => useDateLocale(), {
164
+ wrapper: ({ children }) => (
165
+ <Provider locale={nb} translations={[{}, nn, en]}>
166
+ {children}
167
+ </Provider>
168
+ ),
169
+ });
170
+ const dateLocale = result.current;
171
+ expect(dateLocale).toBe(nn.global.dateLocale);
172
+ });
173
+ });
@@ -5,26 +5,12 @@ import {
5
5
  Component,
6
6
  ComponentTranslation,
7
7
  PartialTranslations,
8
- Translations,
8
+ TFunction,
9
9
  } from "./i18n.types";
10
10
 
11
- /**
12
- * https://regex101.com/r/LYKWi3/1
13
- */
11
+ /* https://regex101.com/r/LYKWi3/1 */
14
12
  const REPLACE_REGEX = /{[^}]*}/g;
15
13
 
16
- /* https://dev.to/pffigueiredo/typescript-utility-keyof-nested-object-2pa3 */
17
- type NestedKeyOf<ObjectType extends object> = {
18
- [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
19
- ? `${Key}.${NestedKeyOf<ObjectType[Key]>}`
20
- : `${Key}`;
21
- }[keyof ObjectType & (string | number)];
22
-
23
- export type TFunction<T extends Component> = (
24
- keypath: NestedKeyOf<Translations[T]>,
25
- replacements?: Record<string, string | number>,
26
- ) => string;
27
-
28
14
  export function useI18n<T extends Component>(
29
15
  componentName: T,
30
16
  ...localTranslations: (ComponentTranslation<T> | undefined)[]
@@ -39,9 +25,7 @@ export function useI18n<T extends Component>(
39
25
  context.locale[componentName],
40
26
  ];
41
27
 
42
- /**
43
- * https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
44
- */
28
+ /* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24 */
45
29
  const translate: TFunction<T> = (keypath, replacements) => {
46
30
  const text = get(keypath, i18nObjects);
47
31
 
@@ -1,5 +1,17 @@
1
1
  import type nb from "./locales/nb";
2
2
 
3
+ /* https://dev.to/pffigueiredo/typescript-utility-keyof-nested-object-2pa3 */
4
+ type NestedKeyOf<ObjectType extends object> = {
5
+ [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
6
+ ? `${Key}.${NestedKeyOf<ObjectType[Key]>}`
7
+ : `${Key}`;
8
+ }[keyof ObjectType & (string | number)];
9
+
10
+ export type TFunction<T extends Component> = (
11
+ keypath: NestedKeyOf<Translations[T]>,
12
+ replacements?: Record<string, string | number>,
13
+ ) => string;
14
+
3
15
  /* https://stackoverflow.com/questions/47914536/use-partial-in-nested-property-with-typescripts */
4
16
  type RecursivePartial<T> = {
5
17
  [P in keyof T]?: RecursivePartial<T[P]>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- test("ModalProps works as intended", () => {
5
- (0, vitest_1.expectTypeOf)({
6
- header: { heading: "Label" },
7
- children: "OK",
8
- }).toMatchTypeOf();
9
- (0, vitest_1.expectTypeOf)({
10
- header: { heading: "Label" },
11
- "aria-label": "Label",
12
- children: "OK",
13
- }).toMatchTypeOf();
14
- (0, vitest_1.expectTypeOf)({
15
- header: { heading: "Label" },
16
- "aria-labelledby": "Label",
17
- children: "OK",
18
- }).toMatchTypeOf();
19
- (0, vitest_1.expectTypeOf)({
20
- "aria-label": "Label",
21
- children: "OK",
22
- }).toMatchTypeOf();
23
- (0, vitest_1.expectTypeOf)({
24
- "aria-labelledby": "Label",
25
- children: "OK",
26
- }).toMatchTypeOf();
27
- (0, vitest_1.expectTypeOf)({
28
- "aria-label": "Label",
29
- open: true,
30
- onClose: () => null,
31
- children: "OK",
32
- }).toMatchTypeOf();
33
- (0, vitest_1.expectTypeOf)({
34
- children: "Mangler label",
35
- }).not.toMatchTypeOf();
36
- (0, vitest_1.expectTypeOf)({
37
- open: true,
38
- children: "Mangler onClose eller label",
39
- }).not.toMatchTypeOf();
40
- (0, vitest_1.expectTypeOf)({
41
- open: true,
42
- "aria-label": "Label",
43
- children: "Mangler onClose",
44
- }).not.toMatchTypeOf();
45
- (0, vitest_1.expectTypeOf)({
46
- open: true,
47
- onClose: () => null,
48
- children: "Mangler label",
49
- }).not.toMatchTypeOf();
50
- (0, vitest_1.expectTypeOf)({
51
- header: { heading: "Label" },
52
- open: true,
53
- children: "Mangler onClose",
54
- }).not.toMatchTypeOf();
55
- (0, vitest_1.expectTypeOf)({
56
- header: { heading: "Label" },
57
- "aria-label": "Label",
58
- "aria-labelledby": "Label",
59
- children: "For mange labels",
60
- }).not.toMatchTypeOf();
61
- (0, vitest_1.expectTypeOf)({
62
- "aria-label": "Label",
63
- "aria-labelledby": "Label",
64
- children: "For mange labels",
65
- }).not.toMatchTypeOf();
66
- });
67
- //# sourceMappingURL=types.test-d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.test-d.js","sourceRoot":"","sources":["../../src/modal/types.test-d.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AAGtC,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACxC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,6BAA6B;KACxC,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { Locale } from "date-fns";
2
- import { Component, ComponentTranslation, Translations } from "./i18n.types";
3
- type NestedKeyOf<ObjectType extends object> = {
4
- [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
5
- }[keyof ObjectType & (string | number)];
6
- export type TFunction<T extends Component> = (keypath: NestedKeyOf<Translations[T]>, replacements?: Record<string, string | number>) => string;
7
- export declare function useI18n<T extends Component>(componentName: T, ...localTranslations: (ComponentTranslation<T> | undefined)[]): TFunction<T>;
8
- export declare function useDateLocale(): Locale;
9
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":";;AA2BA,0BAuCC;AAED,sCAcC;AAjFD,sDAAsD;AACtD,+BAA4B;AAQ5B;;GAEG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;AAcjC,SAAgB,OAAO,CACrB,aAAgB,EAChB,GAAG,iBAA0D;IAE7D,MAAM,OAAO,GAAG,IAAA,sBAAW,GAAE,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IACvD,MAAM,WAAW,GAAwC;QACvD,GAAG,iBAAiB;QACpB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACpC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;KAC9B,CAAC;IAEF;;OAEG;IACH,MAAM,SAAS,GAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;QACxD,MAAM,IAAI,GAAG,IAAA,SAAG,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAEvC,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzD,IAAI,YAAY,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;oBAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;oBACrD,MAAM,IAAI,KAAK,CACb,0BAA0B,OAAO,gDAAgD,WAAW,+CAA+C,eAAe,GAAG,CAC9J,CAAC;gBACJ,CAAC;gBAED,OAAO,YAAY,CAAC,WAAW,CAAW,CAAC,CAAC,+CAA+C;YAC7F,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAA,sBAAW,GAAE,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACpD,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAExC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC,UAAoB,CAAC;QAClC,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC3C,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- import { expectTypeOf } from "vitest";
2
- test("ModalProps works as intended", () => {
3
- expectTypeOf({
4
- header: { heading: "Label" },
5
- children: "OK",
6
- }).toMatchTypeOf();
7
- expectTypeOf({
8
- header: { heading: "Label" },
9
- "aria-label": "Label",
10
- children: "OK",
11
- }).toMatchTypeOf();
12
- expectTypeOf({
13
- header: { heading: "Label" },
14
- "aria-labelledby": "Label",
15
- children: "OK",
16
- }).toMatchTypeOf();
17
- expectTypeOf({
18
- "aria-label": "Label",
19
- children: "OK",
20
- }).toMatchTypeOf();
21
- expectTypeOf({
22
- "aria-labelledby": "Label",
23
- children: "OK",
24
- }).toMatchTypeOf();
25
- expectTypeOf({
26
- "aria-label": "Label",
27
- open: true,
28
- onClose: () => null,
29
- children: "OK",
30
- }).toMatchTypeOf();
31
- expectTypeOf({
32
- children: "Mangler label",
33
- }).not.toMatchTypeOf();
34
- expectTypeOf({
35
- open: true,
36
- children: "Mangler onClose eller label",
37
- }).not.toMatchTypeOf();
38
- expectTypeOf({
39
- open: true,
40
- "aria-label": "Label",
41
- children: "Mangler onClose",
42
- }).not.toMatchTypeOf();
43
- expectTypeOf({
44
- open: true,
45
- onClose: () => null,
46
- children: "Mangler label",
47
- }).not.toMatchTypeOf();
48
- expectTypeOf({
49
- header: { heading: "Label" },
50
- open: true,
51
- children: "Mangler onClose",
52
- }).not.toMatchTypeOf();
53
- expectTypeOf({
54
- header: { heading: "Label" },
55
- "aria-label": "Label",
56
- "aria-labelledby": "Label",
57
- children: "For mange labels",
58
- }).not.toMatchTypeOf();
59
- expectTypeOf({
60
- "aria-label": "Label",
61
- "aria-labelledby": "Label",
62
- children: "For mange labels",
63
- }).not.toMatchTypeOf();
64
- });
65
- //# sourceMappingURL=types.test-d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.test-d.js","sourceRoot":"","sources":["../../src/modal/types.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACxC,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,YAAY,EAAE,OAAO;QACrB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,YAAY,CAAC;QACX,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,YAAY,CAAC;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,6BAA6B;KACxC,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,YAAY,CAAC;QACX,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,YAAY,CAAC;QACX,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,YAAY,CAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,YAAY,CAAC;QACX,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { Locale } from "date-fns";
2
- import { Component, ComponentTranslation, Translations } from "./i18n.types.js";
3
- type NestedKeyOf<ObjectType extends object> = {
4
- [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
5
- }[keyof ObjectType & (string | number)];
6
- export type TFunction<T extends Component> = (keypath: NestedKeyOf<Translations[T]>, replacements?: Record<string, string | number>) => string;
7
- export declare function useI18n<T extends Component>(componentName: T, ...localTranslations: (ComponentTranslation<T> | undefined)[]): TFunction<T>;
8
- export declare function useDateLocale(): Locale;
9
- export {};