@helsenorge/designsystem-react 14.0.0-beta.9 → 14.1.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 (229) hide show
  1. package/lib/AnchorLink.js +2 -2
  2. package/lib/AnchorLink.js.map +1 -1
  3. package/lib/Avatar.js +2 -2
  4. package/lib/Avatar.js.map +1 -1
  5. package/lib/Badge.js +2 -2
  6. package/lib/Badge.js.map +1 -1
  7. package/lib/Button.js +6 -6
  8. package/lib/Button.js.map +1 -1
  9. package/lib/CHANGELOG.md +341 -11
  10. package/lib/Checkbox.js +6 -6
  11. package/lib/Checkbox.js.map +1 -1
  12. package/lib/Close.js +3 -3
  13. package/lib/Close.js.map +1 -1
  14. package/lib/DictionaryTrigger.js +2 -2
  15. package/lib/DictionaryTrigger.js.map +1 -1
  16. package/lib/DoctorSmall.js +22 -34
  17. package/lib/DoctorSmall.js.map +1 -1
  18. package/lib/Drawer.js +6 -5
  19. package/lib/Drawer.js.map +1 -1
  20. package/lib/Duolist.js +5 -5
  21. package/lib/Duolist.js.map +1 -1
  22. package/lib/ElementHeader.js +9 -9
  23. package/lib/ElementHeader.js.map +1 -1
  24. package/lib/ElementHeaderText.js +4 -4
  25. package/lib/ElementHeaderText.js.map +1 -1
  26. package/lib/ErrorWrapper.js +2 -2
  27. package/lib/ErrorWrapper.js.map +1 -1
  28. package/lib/Expander.js +8 -8
  29. package/lib/Expander.js.map +1 -1
  30. package/lib/FormFieldTag.js +2 -2
  31. package/lib/FormFieldTag.js.map +1 -1
  32. package/lib/FormGroup.js +5 -5
  33. package/lib/FormGroup.js.map +1 -1
  34. package/lib/FormLayout.js +3 -3
  35. package/lib/FormLayout.js.map +1 -1
  36. package/lib/HelpDetails.js +3 -3
  37. package/lib/HelpDetails.js.map +1 -1
  38. package/lib/HelpTriggerIcon.js +12 -8
  39. package/lib/HelpTriggerIcon.js.map +1 -1
  40. package/lib/HelpTriggerStandalone.js +2 -2
  41. package/lib/HelpTriggerStandalone.js.map +1 -1
  42. package/lib/HighlightPanel.js +3 -3
  43. package/lib/HighlightPanel.js.map +1 -1
  44. package/lib/HorizontalScroll.js +4 -4
  45. package/lib/HorizontalScroll.js.map +1 -1
  46. package/lib/Icon.js +2 -2
  47. package/lib/Icon.js.map +1 -1
  48. package/lib/IllustrationNames.js +6 -2
  49. package/lib/IllustrationNames.js.map +1 -1
  50. package/lib/InfoTeaser.js +3 -3
  51. package/lib/InfoTeaser.js.map +1 -1
  52. package/lib/Input.js +9 -7
  53. package/lib/Input.js.map +1 -1
  54. package/lib/LazyIcon.js +3 -0
  55. package/lib/LazyIcon.js.map +1 -1
  56. package/lib/LazyIllustration.js +5 -1
  57. package/lib/LazyIllustration.js.map +1 -1
  58. package/lib/LinkList.js +5 -5
  59. package/lib/LinkList.js.map +1 -1
  60. package/lib/List.js +2 -2
  61. package/lib/List.js.map +1 -1
  62. package/lib/ListEditMode.js +4 -4
  63. package/lib/ListEditMode.js.map +1 -1
  64. package/lib/MaxCharacters.js +2 -2
  65. package/lib/MaxCharacters.js.map +1 -1
  66. package/lib/PanelTitle.js +2 -2
  67. package/lib/PanelTitle.js.map +1 -1
  68. package/lib/PopOver.js +2 -2
  69. package/lib/PopOver.js.map +1 -1
  70. package/lib/Select.js +4 -4
  71. package/lib/Select.js.map +1 -1
  72. package/lib/SingleSelectItem.js +3 -3
  73. package/lib/SingleSelectItem.js.map +1 -1
  74. package/lib/Slider.js +18 -10
  75. package/lib/Slider.js.map +1 -1
  76. package/lib/Spacer.js +2 -2
  77. package/lib/Spacer.js.map +1 -1
  78. package/lib/StatusDot.js +4 -4
  79. package/lib/StatusDot.js.map +1 -1
  80. package/lib/StatusDotList.js +2 -2
  81. package/lib/StatusDotList.js.map +1 -1
  82. package/lib/StepButtons.js +5 -5
  83. package/lib/StepButtons.js.map +1 -1
  84. package/lib/StorkMedium.js +96 -0
  85. package/lib/StorkMedium.js.map +1 -0
  86. package/lib/TabList.js +8 -8
  87. package/lib/TabList.js.map +1 -1
  88. package/lib/TabPanel.js +2 -2
  89. package/lib/TabPanel.js.map +1 -1
  90. package/lib/TableBody.js +3 -3
  91. package/lib/TableBody.js.map +1 -1
  92. package/lib/TableCell.js +3 -3
  93. package/lib/TableCell.js.map +1 -1
  94. package/lib/TableExpandedRow.js +5 -5
  95. package/lib/TableExpandedRow.js.map +1 -1
  96. package/lib/TableExpanderCell.js +3 -3
  97. package/lib/TableExpanderCell.js.map +1 -1
  98. package/lib/TableHead.js +7 -7
  99. package/lib/TableHead.js.map +1 -1
  100. package/lib/TableHeadCell.js +6 -6
  101. package/lib/TableHeadCell.js.map +1 -1
  102. package/lib/TableRow.js +6 -6
  103. package/lib/TableRow.js.map +1 -1
  104. package/lib/Textarea.js +17 -16
  105. package/lib/Textarea.js.map +1 -1
  106. package/lib/ThinkingMedium.js +98 -0
  107. package/lib/ThinkingMedium.js.map +1 -0
  108. package/lib/Title.js +2 -2
  109. package/lib/Title.js.map +1 -1
  110. package/lib/Toast.js +3 -3
  111. package/lib/Toast.js.map +1 -1
  112. package/lib/components/ArticleTeaser/index.js +4 -4
  113. package/lib/components/ArticleTeaser/index.js.map +1 -1
  114. package/lib/components/Button/styles.module.scss +1 -3
  115. package/lib/components/Chip/index.js +2 -2
  116. package/lib/components/Chip/index.js.map +1 -1
  117. package/lib/components/Drawer/styles.module.scss +4 -21
  118. package/lib/components/Drawer/styles.module.scss.d.ts +1 -1
  119. package/lib/components/Dropdown/index.js +5 -5
  120. package/lib/components/Dropdown/index.js.map +1 -1
  121. package/lib/components/DropdownOld/index.js +3 -3
  122. package/lib/components/DropdownOld/index.js.map +1 -1
  123. package/lib/components/EmptyState/index.js +2 -2
  124. package/lib/components/EmptyState/index.js.map +1 -1
  125. package/lib/components/ExpanderHierarchy/Expander.d.ts +1 -1
  126. package/lib/components/ExpanderHierarchy/index.js +7 -7
  127. package/lib/components/ExpanderHierarchy/index.js.map +1 -1
  128. package/lib/components/ExpanderList/index.js +19 -10
  129. package/lib/components/ExpanderList/index.js.map +1 -1
  130. package/lib/components/FavoriteButton/index.js +2 -2
  131. package/lib/components/FavoriteButton/index.js.map +1 -1
  132. package/lib/components/HelpBubble/index.js +3 -3
  133. package/lib/components/HelpBubble/index.js.map +1 -1
  134. package/lib/components/HelpPanel/index.js +2 -2
  135. package/lib/components/HelpPanel/index.js.map +1 -1
  136. package/lib/components/HelpTriggerIcon/HelpSign.d.ts +0 -1
  137. package/lib/components/HelpTriggerInline/index.js +2 -2
  138. package/lib/components/HelpTriggerInline/index.js.map +1 -1
  139. package/lib/components/HelpTriggerInline/styles.module.scss +1 -0
  140. package/lib/components/Icons/AdditionalIconInformation.d.ts +12 -0
  141. package/lib/components/Icons/AdditionalIconInformation.js +12 -0
  142. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  143. package/lib/components/Icons/IconNames.d.ts +1 -1
  144. package/lib/components/Icons/IconNames.js +3 -0
  145. package/lib/components/Icons/IconNames.js.map +1 -1
  146. package/lib/components/Icons/MeasuringTape.d.ts +3 -0
  147. package/lib/components/Icons/MeasuringTape.js +8 -0
  148. package/lib/components/Icons/MeasuringTape.js.map +1 -0
  149. package/lib/components/Icons/StarFill.d.ts +4 -0
  150. package/lib/components/Icons/StarFill.js +16 -0
  151. package/lib/components/Icons/StarFill.js.map +1 -0
  152. package/lib/components/Icons/StarStroke.d.ts +4 -0
  153. package/lib/components/Icons/StarStroke.js +16 -0
  154. package/lib/components/Icons/StarStroke.js.map +1 -0
  155. package/lib/components/Illustrations/IllustrationNames.d.ts +1 -1
  156. package/lib/components/Illustrations/Stork.d.ts +11 -0
  157. package/lib/components/Illustrations/Stork.js +16 -0
  158. package/lib/components/Illustrations/Stork.js.map +1 -0
  159. package/lib/components/Illustrations/StorkMedium.d.ts +4 -0
  160. package/lib/components/Illustrations/StorkMedium.js +2 -0
  161. package/lib/components/Illustrations/Thinking.d.ts +9 -0
  162. package/lib/components/Illustrations/Thinking.js +16 -0
  163. package/lib/components/Illustrations/Thinking.js.map +1 -0
  164. package/lib/components/Illustrations/ThinkingMedium.d.ts +4 -0
  165. package/lib/components/Illustrations/ThinkingMedium.js +2 -0
  166. package/lib/components/Loader/index.js +19 -17
  167. package/lib/components/Loader/index.js.map +1 -1
  168. package/lib/components/Modal/index.js +9 -9
  169. package/lib/components/Modal/index.js.map +1 -1
  170. package/lib/components/NotificationPanel/index.js +6 -6
  171. package/lib/components/NotificationPanel/index.js.map +1 -1
  172. package/lib/components/Panel/index.js +12 -12
  173. package/lib/components/Panel/index.js.map +1 -1
  174. package/lib/components/PanelList/index.js +3 -3
  175. package/lib/components/PanelList/index.js.map +1 -1
  176. package/lib/components/PopMenu/index.js +3 -3
  177. package/lib/components/PopMenu/index.js.map +1 -1
  178. package/lib/components/Progressbar/index.js +2 -2
  179. package/lib/components/Progressbar/index.js.map +1 -1
  180. package/lib/components/PromoPanel/index.js +2 -2
  181. package/lib/components/PromoPanel/index.js.map +1 -1
  182. package/lib/components/ServiceMessage/ServiceMessage.d.ts +3 -0
  183. package/lib/components/ServiceMessage/index.js +7 -7
  184. package/lib/components/ServiceMessage/index.js.map +1 -1
  185. package/lib/components/SharingStatus/index.js +4 -4
  186. package/lib/components/SharingStatus/index.js.map +1 -1
  187. package/lib/components/Step/index.js +2 -2
  188. package/lib/components/Step/index.js.map +1 -1
  189. package/lib/components/Stepper/index.js +2 -2
  190. package/lib/components/Stepper/index.js.map +1 -1
  191. package/lib/components/StickyNote/index.js +16 -13
  192. package/lib/components/StickyNote/index.js.map +1 -1
  193. package/lib/components/Table/index.js +3 -3
  194. package/lib/components/Table/index.js.map +1 -1
  195. package/lib/components/Tabs/index.js +4 -4
  196. package/lib/components/Tabs/index.js.map +1 -1
  197. package/lib/components/Tag/index.js +2 -2
  198. package/lib/components/Tag/index.js.map +1 -1
  199. package/lib/components/Tile/index.js +6 -5
  200. package/lib/components/Tile/index.js.map +1 -1
  201. package/lib/components/Toggle/index.js +16 -16
  202. package/lib/components/Toggle/index.js.map +1 -1
  203. package/lib/components/Toggle/styles.module.scss +4 -4
  204. package/lib/components/Validation/index.js +2 -2
  205. package/lib/components/Validation/index.js.map +1 -1
  206. package/lib/declaration.d.ts +9 -0
  207. package/lib/floating-ui.react.js +126 -129
  208. package/lib/floating-ui.react.js.map +1 -1
  209. package/lib/global.d.ts +3 -0
  210. package/lib/hooks/useIsServerSide.d.ts +1 -1
  211. package/lib/resources/Resources.d.ts +145 -0
  212. package/lib/scss/bootstrap/scss/mixins/_grid.scss +2 -1
  213. package/lib/types.d.ts +1 -0
  214. package/lib/useBreakpoint.js +15 -24
  215. package/lib/useBreakpoint.js.map +1 -1
  216. package/lib/useExpand.js +5 -3
  217. package/lib/useExpand.js.map +1 -1
  218. package/lib/useIsServerSide.js +5 -6
  219. package/lib/useIsServerSide.js.map +1 -1
  220. package/lib/useToggle.js +5 -3
  221. package/lib/useToggle.js.map +1 -1
  222. package/lib/utils2.js +7 -7
  223. package/lib/utils2.js.map +1 -1
  224. package/lib/utils3.js +5 -5
  225. package/lib/utils3.js.map +1 -1
  226. package/lib/utils6.js +2 -2
  227. package/lib/utils6.js.map +1 -1
  228. package/package.json +1 -1
  229. package/scss/bootstrap/scss/mixins/_grid.scss +2 -1
@@ -0,0 +1,3 @@
1
+ // This file is for typescript global SCRIPTS. This shall not contain any import/export
2
+
3
+ declare module '*.scss';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Sjekk om React kjører på server, eller ikke. (useEffect kjører ikke på server)
2
+ * Sjekk om React kjører på server, eller ikke.
3
3
  *
4
4
  * @returns true dersom koden kjører på server
5
5
  */
@@ -0,0 +1,145 @@
1
+ /* eslint:disable */
2
+ /*
3
+ * This file is automatically generated by SOT
4
+ *
5
+ * This file is for typings support only, it will not supply the actual text, you will still need to download the correct culture spesific .resx file.
6
+ */
7
+ export type HNDesignsystemDropdown = {
8
+ /**
9
+ * Lukk
10
+ */
11
+ closeText: string;
12
+ };
13
+
14
+ export type HNDesignsystemPanel = {
15
+ /**
16
+ * Se detaljer
17
+ */
18
+ expandButtonOpen: string;
19
+ /**
20
+ * Skjul detaljer
21
+ */
22
+ expandButtonClose: string;
23
+ };
24
+
25
+ export type HNDesignsystemClose = {
26
+ /**
27
+ * Lukk
28
+ */
29
+ ariaLabel: string;
30
+ };
31
+
32
+ export type HNDesignsystemInfoTeaser = {
33
+ /**
34
+ * Vis mindre
35
+ */
36
+ expandButtonOpen: string;
37
+ /**
38
+ * Vis mer
39
+ */
40
+ expandButtonClose: string;
41
+ };
42
+
43
+ export type HNDesignsystemArticleTeaser = {
44
+ /**
45
+ * Vis mer
46
+ */
47
+ expandButtonClose: string;
48
+ /**
49
+ * Vis mindre
50
+ */
51
+ expandButtonOpen: string;
52
+ };
53
+
54
+ export type HNDesignsystemHelpBubble = {
55
+ /**
56
+ * Hjelpetekst
57
+ */
58
+ ariaLabel: string;
59
+ };
60
+
61
+ export type HNDesignsystemHelpDrawer = {
62
+ /**
63
+ * Hjelpetekst
64
+ */
65
+ ariaLabel: string;
66
+ };
67
+
68
+ export type HNDesignsystemFavoriteButton = {
69
+ /**
70
+ * Favorittmarkering
71
+ */
72
+ ariaLabel: string;
73
+ };
74
+
75
+ export type HNDesignsystemTabs = {
76
+ /**
77
+ * Scroll til høyre
78
+ */
79
+ ariaLabelRightButton: string;
80
+ /**
81
+ * Scroll til venstre
82
+ */
83
+ ariaLabelLeftButton: string;
84
+ };
85
+
86
+ export type HNDesignsystemDrawer = {
87
+ /**
88
+ * Lukk
89
+ */
90
+ ariaLabelCloseBtn: string;
91
+ };
92
+
93
+ export type HNDesignsystemFormFieldTag = {
94
+ /**
95
+ * Alle felt må fylles ut
96
+ */
97
+ allRequired: string;
98
+ /**
99
+ * Må fylles ut
100
+ */
101
+ requiredField: string;
102
+ /**
103
+ * Valgfritt
104
+ */
105
+ optional: string;
106
+ /**
107
+ * Alle felt er valgfrie
108
+ */
109
+ allOptional: string;
110
+ /**
111
+ * Velg én
112
+ */
113
+ requiredRadiobuttonList: string;
114
+ /**
115
+ * Velg én eller flere
116
+ */
117
+ requiredCheckboxList: string;
118
+ /**
119
+ * Må velges
120
+ */
121
+ requiredSingleCheckbox: string;
122
+ };
123
+
124
+ export type HNDesignsystemTextArea = {
125
+ /**
126
+ * tegn
127
+ */
128
+ characters: string;
129
+ };
130
+
131
+ export type HNDesignsystemLinkList = {
132
+ /**
133
+ * Slett
134
+ */
135
+ editMode_deleteButtonAriaLabel: string;
136
+ };
137
+
138
+ export type HNDesignsystemInput = {
139
+ /**
140
+ * tegn
141
+ */
142
+ characters: string;
143
+ };
144
+
145
+ /* eslint:enable */
@@ -28,7 +28,8 @@
28
28
  }
29
29
  }
30
30
 
31
- @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
31
+ // fjerner denne i vår kopi
32
+ // @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
32
33
  }
33
34
 
34
35
  @mixin make-col-ready($gutter: $grid-gutter-width) {
package/lib/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ type PickByValue<T, V> = Pick<T, { [K in keyof T]: T[K] extends V ? K : never }[keyof T]>;
@@ -1,5 +1,5 @@
1
1
  import { r as screen, t as breakpoints } from "./grid.js";
2
- import { useEffect, useState } from "react";
2
+ import { useSyncExternalStore } from "react";
3
3
  let Breakpoint = /* @__PURE__ */ function(Breakpoint$1) {
4
4
  Breakpoint$1[Breakpoint$1["xxs"] = breakpoints.xxs] = "xxs";
5
5
  Breakpoint$1[Breakpoint$1["xs"] = breakpoints.xs] = "xs";
@@ -17,30 +17,21 @@ function getCurrentBreakpoint() {
17
17
  };
18
18
  }).find((entry) => entry.mq.matches)?.breakpoint ?? Breakpoint.xxs;
19
19
  }
20
- const useBreakpoint = () => {
21
- const [breakpoint, setBreakpoint] = useState(Breakpoint.xxs);
22
- useEffect(() => {
23
- setBreakpoint(getCurrentBreakpoint());
24
- }, []);
25
- useEffect(() => {
26
- const mediaQueryList = Object.values(screen).map((mediaQuery) => {
27
- const mq = window.matchMedia(mediaQuery);
28
- const handler = () => {
29
- setBreakpoint(getCurrentBreakpoint());
30
- };
31
- mq.addEventListener("change", handler);
32
- return {
33
- mq,
34
- handler
35
- };
20
+ function subscribeToBreakpointChanges(callback) {
21
+ const mediaQueryList = Object.values(screen).map((mediaQuery) => {
22
+ const mq = window.matchMedia(mediaQuery);
23
+ mq.addEventListener("change", callback);
24
+ return mq;
25
+ });
26
+ return () => {
27
+ mediaQueryList.forEach((mq) => {
28
+ mq.removeEventListener("change", callback);
36
29
  });
37
- return () => {
38
- mediaQueryList.forEach(({ mq, handler }) => {
39
- mq.removeEventListener("change", handler);
40
- });
41
- };
42
- }, []);
43
- return breakpoint;
30
+ };
31
+ }
32
+ var getServerSnapshot = () => Breakpoint.xxs;
33
+ const useBreakpoint = () => {
34
+ return useSyncExternalStore(subscribeToBreakpointChanges, getCurrentBreakpoint, getServerSnapshot);
44
35
  };
45
36
  export { useBreakpoint as n, Breakpoint as t };
46
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"useBreakpoint.js","names":[],"sources":["../src/hooks/useBreakpoint.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { breakpoints, screen } from '../theme/grid';\n\nexport enum Breakpoint {\n xxs = breakpoints.xxs,\n xs = breakpoints.xs,\n sm = breakpoints.sm,\n md = breakpoints.md,\n lg = breakpoints.lg,\n xl = breakpoints.xl,\n}\n\nfunction getCurrentBreakpoint(): Breakpoint {\n // We read from largest -> smallest or vice versa\n // so that the first match is the \"highest\" one that applies\n const mediaQueryList = Object.entries(screen)\n .reverse() // e.g. check xl, lg, md, etc. in descending order\n .map(([size, mediaQuery]) => {\n return {\n breakpoint: Breakpoint[size as keyof typeof Breakpoint],\n mq: window.matchMedia(mediaQuery),\n };\n });\n\n const matched = mediaQueryList.find(entry => entry.mq.matches);\n return matched?.breakpoint ?? Breakpoint.xxs;\n}\n\nexport const useBreakpoint = (): Breakpoint => {\n const [breakpoint, setBreakpoint] = useState<Breakpoint>(Breakpoint.xxs);\n\n useEffect(() => {\n // Oppdater breakpoint i useEffect for å støtte server side rendering\n setBreakpoint(getCurrentBreakpoint());\n }, []);\n\n useEffect(() => {\n const mediaQueryList = Object.values(screen).map(mediaQuery => {\n const mq = window.matchMedia(mediaQuery);\n const handler = (): void => {\n setBreakpoint(getCurrentBreakpoint());\n };\n\n mq.addEventListener('change', handler);\n return { mq, handler };\n });\n\n return (): void => {\n mediaQueryList.forEach(({ mq, handler }) => {\n mq.removeEventListener('change', handler);\n });\n };\n }, []);\n\n return breakpoint;\n};\n"],"mappings":";;AAIA,IAAY,aAAA,yBAAA,cAAL;AACL,cAAA,aAAA,SAAM,YAAY,OAAA;AAClB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;;;AAGnB,SAAS,uBAAmC;AAa1C,QAVuB,OAAO,QAAQ,OAAO,CAC1C,SAAS,CACT,KAAK,CAAC,MAAM,gBAAgB;AAC3B,SAAO;GACL,YAAY,WAAW;GACvB,IAAI,OAAO,WAAW,WAAW;GAClC;GACD,CAE2B,MAAK,UAAS,MAAM,GAAG,QAAQ,EAC9C,cAAc,WAAW;;AAG3C,MAAa,sBAAkC;CAC7C,MAAM,CAAC,YAAY,iBAAiB,SAAqB,WAAW,IAAI;AAExE,iBAAgB;AAEd,gBAAc,sBAAsB,CAAC;IACpC,EAAE,CAAC;AAEN,iBAAgB;EACd,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,KAAI,eAAc;GAC7D,MAAM,KAAK,OAAO,WAAW,WAAW;GACxC,MAAM,gBAAsB;AAC1B,kBAAc,sBAAsB,CAAC;;AAGvC,MAAG,iBAAiB,UAAU,QAAQ;AACtC,UAAO;IAAE;IAAI;IAAS;IACtB;AAEF,eAAmB;AACjB,kBAAe,SAAS,EAAE,IAAI,cAAc;AAC1C,OAAG,oBAAoB,UAAU,QAAQ;KACzC;;IAEH,EAAE,CAAC;AAEN,QAAO"}
1
+ {"version":3,"file":"useBreakpoint.js","names":[],"sources":["../src/hooks/useBreakpoint.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { breakpoints, screen } from '../theme/grid';\n\nexport enum Breakpoint {\n xxs = breakpoints.xxs,\n xs = breakpoints.xs,\n sm = breakpoints.sm,\n md = breakpoints.md,\n lg = breakpoints.lg,\n xl = breakpoints.xl,\n}\n\n/** Sjekker nettleserens media queries fra største til minste; det høyeste treffet gjelder */\nfunction getCurrentBreakpoint(): Breakpoint {\n const mediaQueryList = Object.entries(screen)\n .reverse() // Sjekk xl, lg, md, osv. i synkende rekkefølge\n .map(([size, mediaQuery]) => {\n return {\n breakpoint: Breakpoint[size as keyof typeof Breakpoint],\n mq: window.matchMedia(mediaQuery),\n };\n });\n\n const matched = mediaQueryList.find(entry => entry.mq.matches);\n return matched?.breakpoint ?? Breakpoint.xxs;\n}\n\n/** Event listeners for media queries - dette varslet React ved endringer */\nfunction subscribeToBreakpointChanges(callback: () => void): () => void {\n const mediaQueryList = Object.values(screen).map(mediaQuery => {\n const mq = window.matchMedia(mediaQuery);\n mq.addEventListener('change', callback);\n return mq;\n });\n\n return (): void => {\n mediaQueryList.forEach(mq => {\n mq.removeEventListener('change', callback);\n });\n };\n}\n\n/** Brukes ved server side rendering der window ikke finnes. Returnerer minste breakpoint som default */\nconst getServerSnapshot = (): Breakpoint => Breakpoint.xxs;\n\nexport const useBreakpoint = (): Breakpoint => {\n return useSyncExternalStore(subscribeToBreakpointChanges, getCurrentBreakpoint, getServerSnapshot);\n};\n"],"mappings":";;AAIA,IAAY,aAAA,yBAAA,cAAL;AACL,cAAA,aAAA,SAAM,YAAY,OAAA;AAClB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;AACjB,cAAA,aAAA,QAAK,YAAY,MAAA;;;AAInB,SAAS,uBAAmC;AAW1C,QAVuB,OAAO,QAAQ,OAAO,CAC1C,SAAS,CACT,KAAK,CAAC,MAAM,gBAAgB;AAC3B,SAAO;GACL,YAAY,WAAW;GACvB,IAAI,OAAO,WAAW,WAAW;GAClC;GACD,CAE2B,MAAK,UAAS,MAAM,GAAG,QAAQ,EAC9C,cAAc,WAAW;;AAI3C,SAAS,6BAA6B,UAAkC;CACtE,MAAM,iBAAiB,OAAO,OAAO,OAAO,CAAC,KAAI,eAAc;EAC7D,MAAM,KAAK,OAAO,WAAW,WAAW;AACxC,KAAG,iBAAiB,UAAU,SAAS;AACvC,SAAO;GACP;AAEF,cAAmB;AACjB,iBAAe,SAAQ,OAAM;AAC3B,MAAG,oBAAoB,UAAU,SAAS;IAC1C;;;AAKN,IAAM,0BAAsC,WAAW;AAEvD,MAAa,sBAAkC;AAC7C,QAAO,qBAAqB,8BAA8B,sBAAsB,kBAAkB"}
package/lib/useExpand.js CHANGED
@@ -2,10 +2,12 @@ import { t as usePrevious } from "./usePrevious.js";
2
2
  import { useEffect, useState } from "react";
3
3
  const useExpand = (expanded, onExpand) => {
4
4
  const [isExpanded, setIsExpanded] = useState(expanded);
5
+ const [prevExpanded, setPrevExpanded] = useState(expanded);
5
6
  const previousIsExpanded = usePrevious(isExpanded);
6
- useEffect(() => {
7
- if (expanded !== isExpanded) setIsExpanded(expanded);
8
- }, [expanded]);
7
+ if (expanded !== prevExpanded) {
8
+ setPrevExpanded(expanded);
9
+ setIsExpanded(expanded);
10
+ }
9
11
  useEffect(() => {
10
12
  if (onExpand && isExpanded !== !!previousIsExpanded) onExpand(isExpanded);
11
13
  }, [isExpanded, onExpand]);
@@ -1 +1 @@
1
- {"version":3,"file":"useExpand.js","names":[],"sources":["../src/hooks/useExpand.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\nimport { useEffect, useState } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\nexport const useExpand = (expanded: boolean, onExpand?: (isExpanded: boolean) => void): [boolean, Dispatch<SetStateAction<boolean>>] => {\n const [isExpanded, setIsExpanded] = useState(expanded);\n const previousIsExpanded = usePrevious(isExpanded);\n\n useEffect(() => {\n if (expanded !== isExpanded) {\n setIsExpanded(expanded);\n }\n }, [expanded]);\n\n useEffect(() => {\n if (onExpand && isExpanded !== !!previousIsExpanded) {\n onExpand(isExpanded);\n }\n }, [isExpanded, onExpand]);\n\n return [isExpanded, setIsExpanded];\n};\n"],"mappings":";;AAKA,MAAa,aAAa,UAAmB,aAA2F;CACtI,MAAM,CAAC,YAAY,iBAAiB,SAAS,SAAS;CACtD,MAAM,qBAAqB,YAAY,WAAW;AAElD,iBAAgB;AACd,MAAI,aAAa,WACf,eAAc,SAAS;IAExB,CAAC,SAAS,CAAC;AAEd,iBAAgB;AACd,MAAI,YAAY,eAAe,CAAC,CAAC,mBAC/B,UAAS,WAAW;IAErB,CAAC,YAAY,SAAS,CAAC;AAE1B,QAAO,CAAC,YAAY,cAAc"}
1
+ {"version":3,"file":"useExpand.js","names":[],"sources":["../src/hooks/useExpand.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\nimport { useEffect, useState } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\nexport const useExpand = (expanded: boolean, onExpand?: (isExpanded: boolean) => void): [boolean, Dispatch<SetStateAction<boolean>>] => {\n const [isExpanded, setIsExpanded] = useState(expanded);\n const [prevExpanded, setPrevExpanded] = useState(expanded);\n const previousIsExpanded = usePrevious(isExpanded);\n\n if (expanded !== prevExpanded) {\n setPrevExpanded(expanded);\n setIsExpanded(expanded);\n }\n\n useEffect(() => {\n if (onExpand && isExpanded !== !!previousIsExpanded) {\n onExpand(isExpanded);\n }\n }, [isExpanded, onExpand]);\n\n return [isExpanded, setIsExpanded];\n};\n"],"mappings":";;AAKA,MAAa,aAAa,UAAmB,aAA2F;CACtI,MAAM,CAAC,YAAY,iBAAiB,SAAS,SAAS;CACtD,MAAM,CAAC,cAAc,mBAAmB,SAAS,SAAS;CAC1D,MAAM,qBAAqB,YAAY,WAAW;AAElD,KAAI,aAAa,cAAc;AAC7B,kBAAgB,SAAS;AACzB,gBAAc,SAAS;;AAGzB,iBAAgB;AACd,MAAI,YAAY,eAAe,CAAC,CAAC,mBAC/B,UAAS,WAAW;IAErB,CAAC,YAAY,SAAS,CAAC;AAE1B,QAAO,CAAC,YAAY,cAAc"}
@@ -1,10 +1,9 @@
1
- import { useEffect, useState } from "react";
1
+ import { useSyncExternalStore } from "react";
2
+ var emptySubscribe = () => () => {};
3
+ var getClientSnapshot = () => false;
4
+ var getServerSnapshot = () => true;
2
5
  const useIsServerSide = () => {
3
- const [isServerSide, setIsServerSide] = useState(true);
4
- useEffect(() => {
5
- setIsServerSide(false);
6
- }, []);
7
- return isServerSide;
6
+ return useSyncExternalStore(emptySubscribe, getClientSnapshot, getServerSnapshot);
8
7
  };
9
8
  export { useIsServerSide as t };
10
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"useIsServerSide.js","names":[],"sources":["../src/hooks/useIsServerSide.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\n/**\n * Sjekk om React kjører på server, eller ikke. (useEffect kjører ikke på server)\n *\n * @returns true dersom koden kjører på server\n */\nexport const useIsServerSide = (): boolean => {\n const [isServerSide, setIsServerSide] = useState(true);\n\n useEffect(() => {\n setIsServerSide(false);\n }, []);\n\n return isServerSide;\n};\n"],"mappings":";AAOA,MAAa,wBAAiC;CAC5C,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;AAEtD,iBAAgB;AACd,kBAAgB,MAAM;IACrB,EAAE,CAAC;AAEN,QAAO"}
1
+ {"version":3,"file":"useIsServerSide.js","names":[],"sources":["../src/hooks/useIsServerSide.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nconst emptySubscribe = (): (() => void) => (): void => {};\nconst getClientSnapshot = (): boolean => false;\nconst getServerSnapshot = (): boolean => true;\n\n/**\n * Sjekk om React kjører på server, eller ikke.\n *\n * @returns true dersom koden kjører på server\n */\nexport const useIsServerSide = (): boolean => {\n return useSyncExternalStore(emptySubscribe, getClientSnapshot, getServerSnapshot);\n};\n"],"mappings":";AAEA,IAAM,6BAAiD;AACvD,IAAM,0BAAmC;AACzC,IAAM,0BAAmC;AAOzC,MAAa,wBAAiC;AAC5C,QAAO,qBAAqB,gBAAgB,mBAAmB,kBAAkB"}
package/lib/useToggle.js CHANGED
@@ -2,13 +2,15 @@ import { t as usePrevious } from "./usePrevious.js";
2
2
  import { useEffect, useState } from "react";
3
3
  const useToggle = (initialValue, callback) => {
4
4
  const [value, setValue] = useState(initialValue);
5
+ const [prevInitialValue, setPrevInitialValue] = useState(initialValue);
5
6
  const previousValue = usePrevious(value);
7
+ if (initialValue !== prevInitialValue) {
8
+ setPrevInitialValue(initialValue);
9
+ setValue(initialValue);
10
+ }
6
11
  const toggleValue = () => {
7
12
  setValue(!value);
8
13
  };
9
- useEffect(() => {
10
- if (initialValue !== value) setValue(initialValue);
11
- }, [initialValue]);
12
14
  useEffect(() => {
13
15
  if (callback && value !== !!previousValue) callback(value);
14
16
  }, [value, callback]);
@@ -1 +1 @@
1
- {"version":3,"file":"useToggle.js","names":[],"sources":["../src/hooks/useToggle.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\n/**\n * Hook for å toggle en boolean og kjøre en callback når verdien endres\n *\n * @param initialValue Initiell verdi for boolean\n * @param callback Funksjon som kalles når value endrer verdi (optional)\n * @returns Objekt med nåværende verdi og funksjon som kan kalles for å toggle verdien\n */\nexport const useToggle = (initialValue: boolean, callback?: (value: boolean) => void): { value: boolean; toggleValue: () => void } => {\n const [value, setValue] = useState(initialValue);\n const previousValue = usePrevious(value);\n\n const toggleValue = (): void => {\n setValue(!value);\n };\n\n useEffect(() => {\n if (initialValue !== value) {\n setValue(initialValue);\n }\n }, [initialValue]);\n\n useEffect(() => {\n if (callback && value !== !!previousValue) {\n callback(value);\n }\n }, [value, callback]);\n\n return { value, toggleValue };\n};\n"],"mappings":";;AAWA,MAAa,aAAa,cAAuB,aAAqF;CACpI,MAAM,CAAC,OAAO,YAAY,SAAS,aAAa;CAChD,MAAM,gBAAgB,YAAY,MAAM;CAExC,MAAM,oBAA0B;AAC9B,WAAS,CAAC,MAAM;;AAGlB,iBAAgB;AACd,MAAI,iBAAiB,MACnB,UAAS,aAAa;IAEvB,CAAC,aAAa,CAAC;AAElB,iBAAgB;AACd,MAAI,YAAY,UAAU,CAAC,CAAC,cAC1B,UAAS,MAAM;IAEhB,CAAC,OAAO,SAAS,CAAC;AAErB,QAAO;EAAE;EAAO;EAAa"}
1
+ {"version":3,"file":"useToggle.js","names":[],"sources":["../src/hooks/useToggle.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { usePrevious } from './usePrevious';\n\n/**\n * Hook for å toggle en boolean og kjøre en callback når verdien endres\n *\n * @param initialValue Initiell verdi for boolean\n * @param callback Funksjon som kalles når value endrer verdi (optional)\n * @returns Objekt med nåværende verdi og funksjon som kan kalles for å toggle verdien\n */\nexport const useToggle = (initialValue: boolean, callback?: (value: boolean) => void): { value: boolean; toggleValue: () => void } => {\n const [value, setValue] = useState(initialValue);\n const [prevInitialValue, setPrevInitialValue] = useState(initialValue);\n const previousValue = usePrevious(value);\n\n if (initialValue !== prevInitialValue) {\n setPrevInitialValue(initialValue);\n setValue(initialValue);\n }\n\n const toggleValue = (): void => {\n setValue(!value);\n };\n\n useEffect(() => {\n if (callback && value !== !!previousValue) {\n callback(value);\n }\n }, [value, callback]);\n\n return { value, toggleValue };\n};\n"],"mappings":";;AAWA,MAAa,aAAa,cAAuB,aAAqF;CACpI,MAAM,CAAC,OAAO,YAAY,SAAS,aAAa;CAChD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,aAAa;CACtE,MAAM,gBAAgB,YAAY,MAAM;AAExC,KAAI,iBAAiB,kBAAkB;AACrC,sBAAoB,aAAa;AACjC,WAAS,aAAa;;CAGxB,MAAM,oBAA0B;AAC9B,WAAS,CAAC,MAAM;;AAGlB,iBAAgB;AACd,MAAI,YAAY,UAAU,CAAC,CAAC,cAC1B,UAAS,MAAM;IAEhB,CAAC,OAAO,SAAS,CAAC;AAErB,QAAO;EAAE;EAAO;EAAa"}
package/lib/utils2.js CHANGED
@@ -3,14 +3,14 @@ import { t as isComponent } from "./component.js";
3
3
  import { t as Spacer_default } from "./Spacer.js";
4
4
  import { t as FormFieldTag_default } from "./FormFieldTag.js";
5
5
  import { t as StatusDot_default } from "./StatusDot.js";
6
- import classNames from "classnames";
6
+ import cn from "classnames";
7
7
  import React from "react";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import styles from "./components/Label/styles.module.scss";
10
10
  const Sublabel = ({ children, className, id, onColor, sublabelTexts, testId }) => {
11
11
  const mapSublabels = (hideFromScreenReader) => {
12
12
  return sublabelTexts && sublabelTexts.map((sublabelText, index) => {
13
- const labelClasses = classNames(styles.label, styles["sublabel"], {
13
+ const labelClasses = cn(styles.label, styles["sublabel"], {
14
14
  [styles["sublabel--subdued"]]: sublabelText.type === "subdued",
15
15
  [styles["sublabel--on-dark"]]: onColor === FormOnColor.ondark
16
16
  });
@@ -40,13 +40,13 @@ const Sublabel = ({ children, className, id, onColor, sublabelTexts, testId }) =
40
40
  };
41
41
  var Label = ({ afterLabelChildren, children, className, formFieldTag, htmlFor, htmlMarkup = "label", labelClassName, labelTextClassName, labelId, labelTexts, onColor = FormOnColor.onwhite, statusDot, sublabel, sublabelWrapperClassName, testId, afterLabelChildrenClassName }) => {
42
42
  const hasChildren = children && typeof children !== "undefined";
43
- const labelWrapperClasses = classNames(styles["label-wrapper"], { [styles["label-wrapper--no-bottom-margin"]]: hasChildren }, className);
44
- const mainLabelWrapperClasses = classNames({ [styles["label-wrapper--after-label-children"]]: afterLabelChildren });
45
- const afterLabelChildrenClasses = classNames(styles["after-label-children"], afterLabelChildrenClassName);
43
+ const labelWrapperClasses = cn(styles["label-wrapper"], { [styles["label-wrapper--no-bottom-margin"]]: hasChildren }, className);
44
+ const mainLabelWrapperClasses = cn({ [styles["label-wrapper--after-label-children"]]: afterLabelChildren });
45
+ const afterLabelChildrenClasses = cn(styles["after-label-children"], afterLabelChildrenClassName);
46
46
  const mapLabels = () => {
47
47
  if (typeof labelTexts === "undefined") return null;
48
48
  return labelTexts.map((labelText, index) => {
49
- const labelClasses = classNames(styles.label, {
49
+ const labelClasses = cn(styles.label, {
50
50
  [styles["label--subdued"]]: labelText.type === "subdued",
51
51
  [styles["label--on-dark"]]: onColor === FormOnColor.ondark
52
52
  }, labelTextClassName);
@@ -115,7 +115,7 @@ const renderLabelAsParent = (props) => {
115
115
  htmlFor: props.inputId,
116
116
  onColor: props.onColor,
117
117
  children: props.children,
118
- labelClassName: classNames(props.labelClassName, props.label.props.labelClassName),
118
+ labelClassName: cn(props.labelClassName, props.label.props.labelClassName),
119
119
  labelTextClassName: props.labelTextClassName,
120
120
  htmlMarkup: props.markup || "label",
121
121
  sublabelWrapperClassName: props.sublabelWrapperClassName,
package/lib/utils2.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils2.js","names":["Sublabel: React.FC<SublabelProps>","Label: FunctionComponent<LabelProps>"],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n })\n : typeof props.label === 'string' && (\n <Label labelTexts={[{ text: props.label, type: 'normal' }]} htmlFor={props.inputId} onColor={props.onColor} />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAaA,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;AACxE,SACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,WAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY;IACxD,CAAC;AACF,UACE,yBAAyB,aAAa,wBACpC,oBAAC,QAAA;IAAK,WAAW;cACd,aAAa;MADoB,MAE7B;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,gBAAgB,MAAM,MAAM,MAAM,eAAe;EAC1E,oBAAoB,MAAM;EAC1B,YAAY,MAAM,UAAU;EAC5B,0BAA0B,MAAM;EAChC,UAAU,MAAM,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACtD,WAAW,MAAM,QAAQ,KAAA,IAAY,MAAM,MAAM,MAAM;EACvD,6BAA6B,MAAM;EACpC,CAAC,GACF,OAAO,MAAM,UAAU,YACrB,oBAAC,eAAA;EACC,YAAY,CAAC;GAAE,MAAM,MAAM;GAAO,MAAM;GAAW,CAAC;EACpD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;YAElC,MAAM;GACD,EAAA,CAEb"}
1
+ {"version":3,"file":"utils2.js","names":["Sublabel: React.FC<SublabelProps>","Label: FunctionComponent<LabelProps>"],"sources":["../src/components/Label/SubLabel.tsx","../src/components/Label/Label.tsx","../src/components/Label/utils.tsx"],"sourcesContent":["import cn from 'classnames';\n\nimport type { LabelText } from './Label';\n\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport Spacer from '../Spacer';\n\nimport styles from './styles.module.scss';\n\nexport interface SublabelProps {\n /** Sets the content of the Sublabel */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** id that is placed on the wrapper */\n id: string;\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: FormOnColor;\n /** Array of sublabel strings. Can be of type semibold or normal */\n sublabelTexts?: LabelText[];\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Sublabel: React.FC<SublabelProps> = ({ children, className, id, onColor, sublabelTexts, testId }) => {\n const mapSublabels = (hideFromScreenReader?: boolean): React.ReactNode => {\n return (\n sublabelTexts &&\n sublabelTexts.map((sublabelText, index) => {\n const labelClasses = cn(styles.label, styles['sublabel'], {\n [styles['sublabel--subdued']]: sublabelText.type === 'subdued',\n [styles['sublabel--on-dark']]: onColor === FormOnColor.ondark,\n });\n return (\n hideFromScreenReader === sublabelText.hideFromScreenReader && (\n <span className={labelClasses} key={index}>\n {sublabelText.text}\n </span>\n )\n );\n })\n );\n };\n\n const subLabels = mapSublabels();\n const ariaHiddenSublabels = mapSublabels(true);\n\n return (\n <>\n <Spacer size={'3xs'} />\n {(subLabels || children) && (\n <div className={className} id={id} data-testid={testId} data-analyticsid={AnalyticsId.Sublabel}>\n {subLabels}\n {children}\n </div>\n )}\n {ariaHiddenSublabels && (\n <div className={className} data-testid={testId}>\n {ariaHiddenSublabels}\n </div>\n )}\n </>\n );\n};\n","import type { FunctionComponent } from 'react';\nimport React from 'react';\n\nimport cn from 'classnames';\n\nimport type { SublabelProps } from './SubLabel';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport { Sublabel } from './SubLabel';\nimport { AnalyticsId, FormOnColor } from '../../constants';\nimport { isComponent } from '../../utils/component';\nimport FormFieldTag from '../FormFieldTag';\nimport Spacer from '../Spacer';\nimport StatusDot from '../StatusDot';\n\nimport styles from './styles.module.scss';\n\nexport type LabelText = {\n hideFromScreenReader?: boolean;\n text: string;\n type?: 'normal' | 'subdued';\n};\n\nexport type LabelTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'label' | 'p' | 'legend';\n\nexport interface LabelProps {\n /** Component shown after label - discourage use of this */\n afterLabelChildren?: React.ReactNode;\n /** Sets the content of the Label */\n children?: React.ReactNode;\n /** Sets a tag that describes whether the form field is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the label tag. */\n labelClassName?: string;\n /** Adds custom classes to the label text. */\n labelTextClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Id that is put on the \"for\" attribute of the label */\n htmlFor?: string;\n /** Changes the underlying element of the label */\n htmlMarkup?: LabelTags;\n /** Id som plasseres på <label/> */\n labelId?: string;\n /** Array of main label strings. Can be of type semibold or normal */\n labelTexts?: LabelText[];\n /** Array of sublabel strings. Can be of type semibold or normal */\n onColor?: keyof typeof FormOnColor;\n /** StatusDot placed underneath the last sublabel */\n statusDot?: React.ReactNode;\n /** Sublabel component */\n sublabel?: React.ReactNode;\n /** Adds custom classes to the div wrapping the sublabels. */\n sublabelWrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Gives a custom classname to the afterLabelChildren wrapper. Used in checkbox and radiobutton */\n afterLabelChildrenClassName?: string;\n}\n\nconst Label: FunctionComponent<LabelProps> = ({\n afterLabelChildren,\n children,\n className,\n formFieldTag,\n htmlFor,\n htmlMarkup = 'label',\n labelClassName,\n labelTextClassName,\n labelId,\n labelTexts,\n onColor = FormOnColor.onwhite,\n statusDot,\n sublabel,\n sublabelWrapperClassName,\n testId,\n afterLabelChildrenClassName,\n}) => {\n const hasChildren = children && typeof children !== 'undefined';\n const labelWrapperClasses = cn(styles['label-wrapper'], { [styles['label-wrapper--no-bottom-margin']]: hasChildren }, className);\n const mainLabelWrapperClasses = cn({\n [styles['label-wrapper--after-label-children']]: afterLabelChildren,\n });\n const afterLabelChildrenClasses = cn(styles['after-label-children'], afterLabelChildrenClassName);\n\n const mapLabels = (): React.ReactNode => {\n if (typeof labelTexts === 'undefined') return null;\n\n return labelTexts.map((labelText, index) => {\n const labelClasses = cn(\n styles.label,\n {\n [styles['label--subdued']]: labelText.type === 'subdued',\n [styles['label--on-dark']]: onColor === FormOnColor.ondark,\n },\n labelTextClassName\n );\n return (\n <span aria-hidden={labelText.hideFromScreenReader} className={labelClasses} key={index}>\n {labelText.text}\n </span>\n );\n });\n };\n const CustomTag = htmlMarkup;\n\n return (\n <div className={labelWrapperClasses}>\n <div className={mainLabelWrapperClasses}>\n <CustomTag className={labelClassName} id={labelId} htmlFor={htmlFor} data-testid={testId} data-analyticsid={AnalyticsId.Label}>\n <span className={styles['label-content-wrapper']}>\n {children}\n <span className={styles.label__texts}>{mapLabels()}</span>\n </span>\n </CustomTag>\n {afterLabelChildren && <div className={afterLabelChildrenClasses}>{afterLabelChildren}</div>}\n </div>\n {(sublabel || statusDot || formFieldTag) && (\n <div className={sublabelWrapperClassName}>\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n {sublabel &&\n isComponent<SublabelProps>(sublabel, Sublabel) &&\n React.cloneElement(sublabel, {\n onColor: onColor as FormOnColor,\n })}\n {statusDot && isComponent<StatusDotProps>(statusDot, StatusDot) && (\n <>\n <Spacer size={'3xs'} />\n {React.cloneElement(statusDot, {\n onColor: onColor === FormOnColor.ondark ? 'ondark' : 'onwhite',\n })}\n </>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Label;\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { LabelProps, LabelTags } from './Label';\nimport type { FormOnColor } from '../../constants';\n\nimport Label from './Label';\nimport { isComponent } from '../../utils/component';\n\nexport const getLabelText = (label: React.ReactNode): string => {\n let allLabelText = '';\n\n if (isComponent<LabelProps>(label, Label)) {\n label.props.labelTexts?.forEach(labelText => {\n allLabelText += !labelText.hideFromScreenReader ? labelText.text : '';\n });\n }\n\n return allLabelText;\n};\n\ninterface RenderLabelProps {\n label: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n markup?: LabelTags;\n}\n\nexport const renderLabel = (props: RenderLabelProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n htmlMarkup: props.markup || 'label',\n onColor: props.onColor,\n })\n : typeof props.label === 'string' && (\n <Label labelTexts={[{ text: props.label, type: 'normal' }]} htmlFor={props.inputId} onColor={props.onColor} />\n )}\n </>\n );\n};\n\ninterface RenderLabelAsParentProps {\n label: React.ReactNode;\n children: React.ReactNode;\n inputId: string;\n onColor: FormOnColor;\n labelClassName?: string;\n labelTextClassName?: string;\n sublabelWrapperClassName?: string;\n large?: boolean;\n markup?: LabelTags;\n afterLabelChildrenClassName?: string;\n}\n\nexport const renderLabelAsParent = (props: RenderLabelAsParentProps): React.ReactNode => {\n return (\n <>\n {props.label && isComponent<LabelProps>(props.label, Label)\n ? React.cloneElement(props.label, {\n htmlFor: props.inputId,\n onColor: props.onColor,\n children: props.children,\n labelClassName: cn(props.labelClassName, props.label.props.labelClassName),\n labelTextClassName: props.labelTextClassName,\n htmlMarkup: props.markup || 'label',\n sublabelWrapperClassName: props.sublabelWrapperClassName,\n sublabel: props.large ? undefined : props.label.props.sublabel,\n statusDot: props.large ? undefined : props.label.props.statusDot,\n afterLabelChildrenClassName: props.afterLabelChildrenClassName,\n })\n : typeof props.label === 'string' && (\n <Label\n labelTexts={[{ text: props.label, type: 'subdued' }]}\n htmlFor={props.inputId}\n onColor={props.onColor}\n htmlMarkup={props.markup || 'label'}\n labelClassName={props.labelClassName}\n labelTextClassName={props.labelTextClassName}\n sublabelWrapperClassName={props.sublabelWrapperClassName}\n afterLabelChildrenClassName={props.afterLabelChildrenClassName}\n >\n {props.children}\n </Label>\n )}\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAwBA,MAAaA,YAAqC,EAAE,UAAU,WAAW,IAAI,SAAS,eAAe,aAAa;CAChH,MAAM,gBAAgB,yBAAoD;AACxE,SACE,iBACA,cAAc,KAAK,cAAc,UAAU;GACzC,MAAM,eAAe,GAAG,OAAO,OAAO,OAAO,aAAa;KACvD,OAAO,uBAAuB,aAAa,SAAS;KACpD,OAAO,uBAAuB,YAAY,YAAY;IACxD,CAAC;AACF,UACE,yBAAyB,aAAa,wBACpC,oBAAC,QAAA;IAAK,WAAW;cACd,aAAa;MADoB,MAE7B;IAGX;;CAIN,MAAM,YAAY,cAAc;CAChC,MAAM,sBAAsB,aAAa,KAAK;AAE9C,QACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,gBAAA,EAAO,MAAM,OAAA,CAAS;GACrB,aAAa,aACb,qBAAC,OAAA;GAAe;GAAe;GAAI,eAAa;G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,MAAM,MAAM;EACvD,6BAA6B,MAAM;EACpC,CAAC,GACF,OAAO,MAAM,UAAU,YACrB,oBAAC,eAAA;EACC,YAAY,CAAC;GAAE,MAAM,MAAM;GAAO,MAAM;GAAW,CAAC;EACpD,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM,UAAU;EAC5B,gBAAgB,MAAM;EACtB,oBAAoB,MAAM;EAC1B,0BAA0B,MAAM;EAChC,6BAA6B,MAAM;YAElC,MAAM;GACD,EAAA,CAEb"}
package/lib/utils3.js CHANGED
@@ -6,7 +6,7 @@ import { t as useIdWithFallback } from "./useIdWithFallback.js";
6
6
  import { t as getAriaDescribedBy } from "./accessibility.js";
7
7
  import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
8
8
  import { r as renderLabelAsParent, t as getLabelText } from "./utils2.js";
9
- import classNames from "classnames";
9
+ import cn from "classnames";
10
10
  import { useState } from "react";
11
11
  import { jsx } from "react/jsx-runtime";
12
12
  import radioButtonStyles from "./components/RadioButton/styles.module.scss";
@@ -21,14 +21,14 @@ const RadioButton = (props) => {
21
21
  const { refObject, isFocused } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
22
22
  const mergedRefs = mergeRefs([ref, refObject]);
23
23
  const errorTextId = useIdWithFallback(errorTextIdProp);
24
- const radioButtonWrapperClasses = classNames(radioButtonStyles["radio-button-wrapper"], {
24
+ const radioButtonWrapperClasses = cn(radioButtonStyles["radio-button-wrapper"], {
25
25
  [radioButtonStyles["radio-button-wrapper__large"]]: isLarge,
26
26
  [radioButtonStyles["radio-button-wrapper__large--focused"]]: isLarge && isFocused,
27
27
  [radioButtonStyles["radio-button-wrapper__large--selected"]]: isLarge && checked && isFocused,
28
28
  [radioButtonStyles["radio-button-wrapper__large--invalid"]]: isLarge && onCherry && isFocused,
29
29
  [radioButtonStyles["radio-button-wrapper__large--on-blueberry"]]: isLarge && onBlueberry && isFocused
30
30
  });
31
- const radioButtonLabelClasses = classNames(radioButtonStyles["radio-button-label"], {
31
+ const radioButtonLabelClasses = cn(radioButtonStyles["radio-button-label"], {
32
32
  [radioButtonStyles["radio-button-label--disabled"]]: disabled,
33
33
  [radioButtonStyles["radio-button-label--on-dark"]]: onDark,
34
34
  [radioButtonStyles["radio-button-label--invalid"]]: invalid,
@@ -36,7 +36,7 @@ const RadioButton = (props) => {
36
36
  [radioButtonStyles["radio-button-label__large--focused"]]: isFocused && isLarge,
37
37
  [radioButtonStyles["radio-button-label__large--disabled"]]: isLarge && disabled
38
38
  }, labelClassNames);
39
- const radioButtonClasses = classNames(radioButtonStyles["radio-button"], {
39
+ const radioButtonClasses = cn(radioButtonStyles["radio-button"], {
40
40
  [radioButtonStyles["radio-button--on-dark"]]: onDark,
41
41
  [radioButtonStyles["radio-button--disabled"]]: disabled,
42
42
  [radioButtonStyles["radio-button--on-blueberry"]]: onBlueberry,
@@ -89,7 +89,7 @@ var RadioButton_default = RadioButton;
89
89
  const getRadioLabelClasses = (radioId, onColor, large, checkedRadioId) => {
90
90
  const onCherry = onColor === "oninvalid";
91
91
  const checked = radioId === checkedRadioId;
92
- return classNames({
92
+ return cn({
93
93
  [radioButtonStyles["radio-button-label__large--on-grey"]]: large && onColor === "ongrey" && !checked,
94
94
  [radioButtonStyles["radio-button-label__large--on-blueberry"]]: onColor === "onblueberry" && !checked && large,
95
95
  [radioButtonStyles["radio-button-label__large--selected"]]: large && checked && !onCherry,
package/lib/utils3.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils3.js","names":["RadioButton: React.FC<RadioButtonProps>"],"sources":["../src/components/RadioButton/RadioButton.tsx","../src/components/RadioButton/utils.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the radioButton. Large version only works when used inside a FormGroup wrapper. */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const RadioButton: React.FC<RadioButtonProps> = props => {\n const {\n className,\n defaultChecked,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n errorTextId: errorTextIdProp,\n error = !!errorText,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ref,\n ...rest\n } = props;\n const invalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onCherry = onColor === FormOnColor.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>();\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--focused']]: isFocused && isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n if (onChange) onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n {...rest}\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n required={required}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: radioButtonLabelClasses,\n sublabelWrapperClassName: radioButtonStyles['radiobutton-sublabel-wrapper'],\n large: isLarge,\n afterLabelChildrenClassName: radioButtonStyles['radiobutton-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n","import classNames from 'classnames';\n\nimport type { FormOnColor } from '../../constants';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport const getRadioLabelClasses = (\n radioId: string,\n onColor: FormOnColor,\n large: boolean,\n checkedRadioId?: string\n): string | undefined => {\n const onCherry = onColor === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && onColor === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: onColor === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n"],"mappings":";;;;;;;;;;;;AAgDA,MAAaA,eAA0C,UAAS;CAC9D,MAAM,EACJ,WACA,gBACA,UACA,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,aAAa,iBACb,QAAQ,CAAC,CAAC,WACV,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,iBACA,KACA,GAAG,SACD;CACJ,MAAM,UAAU,SAAS,YAAY,YAAY;CACjD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,WAAW,YAAY,YAAY;CAC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Aa;GAAQ,oBAAkB,YAAY;GAAa,WAAW;aAC7E,oBAAoB;IACZ;IACP,UAAU,iBAAiB;IAClB;IACA;IACT,gBAAgB;IAChB,0BAA0B,kBAAkB;IAC5C,OAAO;IACP,6BAA6B,kBAAkB;IAChD,CAAC;IACE;GACO;;AAInB,YAAY,cAAc;AAE1B,IAAA,sBAAe;ACrJf,MAAa,wBACX,SACA,SACA,OACA,mBACuB;CACvB,MAAM,WAAW,YAAY;CAC7B,MAAM,UAAU,YAAY;AAE5B,QAAO,WAAW;GACf,kBAAkB,wCAAwC,SAAS,YAAY,YAAY,CAAC;GAC5F,kBAAkB,6CAA6C,YAAY,iBAAiB,CAAC,WAAW;GACxG,kBAAkB,yCAAyC,SAAS,WAAW,CAAC;GAChF,kBAAkB,iDAAiD,SAAS,WAAW;EACzF,CAAC"}
1
+ {"version":3,"file":"utils3.js","names":["RadioButton: React.FC<RadioButtonProps>"],"sources":["../src/components/RadioButton/RadioButton.tsx","../src/components/RadioButton/utils.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport interface RadioButtonProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'defaultChecked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the radioButton - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** Adds custom classes to the label element. */\n labelClassNames?: string;\n /** input id of the radioButton */\n inputId?: string;\n /** Changes the visuals of the radioButton */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the radioButton. Large version only works when used inside a FormGroup wrapper. */\n size?: keyof typeof FormSize;\n /** Activates Error style for the radioButton - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const RadioButton: React.FC<RadioButtonProps> = props => {\n const {\n className,\n defaultChecked,\n onChange,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n errorTextId: errorTextIdProp,\n error = !!errorText,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n labelClassNames,\n ref,\n ...rest\n } = props;\n const invalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onCherry = onColor === FormOnColor.oninvalid;\n const isLarge = size === FormSize.large;\n const [checked, changeChecked] = useState<boolean>();\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n\n const radioButtonWrapperClasses = classNames(radioButtonStyles['radio-button-wrapper'], {\n [radioButtonStyles['radio-button-wrapper__large']]: isLarge,\n [radioButtonStyles['radio-button-wrapper__large--focused']]: isLarge && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--selected']]: isLarge && checked && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--invalid']]: isLarge && onCherry && isFocused,\n [radioButtonStyles['radio-button-wrapper__large--on-blueberry']]: isLarge && onBlueberry && isFocused,\n });\n const radioButtonLabelClasses = classNames(\n radioButtonStyles['radio-button-label'],\n {\n [radioButtonStyles['radio-button-label--disabled']]: disabled,\n [radioButtonStyles['radio-button-label--on-dark']]: onDark,\n [radioButtonStyles['radio-button-label--invalid']]: invalid,\n [radioButtonStyles['radio-button-label__large']]: isLarge,\n [radioButtonStyles['radio-button-label__large--focused']]: isFocused && isLarge,\n [radioButtonStyles['radio-button-label__large--disabled']]: isLarge && disabled,\n },\n labelClassNames\n );\n const radioButtonClasses = classNames(\n radioButtonStyles['radio-button'],\n {\n [radioButtonStyles['radio-button--on-dark']]: onDark,\n [radioButtonStyles['radio-button--disabled']]: disabled,\n [radioButtonStyles['radio-button--on-blueberry']]: onBlueberry,\n [radioButtonStyles['radio-button--invalid']]: invalid,\n [radioButtonStyles['radio-button__large']]: isLarge,\n [radioButtonStyles['radio-button__large--disabled']]: isLarge && disabled,\n [radioButtonStyles['radio-button__large--invalid']]: isLarge && invalid,\n },\n className\n );\n\n const change = (e: React.ChangeEvent<HTMLInputElement>): void => {\n changeChecked(e.target.checked);\n if (onChange) onChange(e);\n };\n\n const getLabelContent = (): React.ReactNode => (\n <input\n {...rest}\n id={inputId}\n name={name}\n className={radioButtonClasses}\n type=\"radio\"\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n defaultChecked={defaultChecked}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n required={required}\n onChange={(e): void => change(e)}\n />\n );\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.RadioButton} className={radioButtonWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: radioButtonLabelClasses,\n sublabelWrapperClassName: radioButtonStyles['radiobutton-sublabel-wrapper'],\n large: isLarge,\n afterLabelChildrenClassName: radioButtonStyles['radiobutton-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n","import classNames from 'classnames';\n\nimport type { FormOnColor } from '../../constants';\n\nimport radioButtonStyles from './styles.module.scss';\n\nexport const getRadioLabelClasses = (\n radioId: string,\n onColor: FormOnColor,\n large: boolean,\n checkedRadioId?: string\n): string | undefined => {\n const onCherry = onColor === 'oninvalid';\n const checked = radioId === checkedRadioId;\n\n return classNames({\n [radioButtonStyles['radio-button-label__large--on-grey']]: large && onColor === 'ongrey' && !checked,\n [radioButtonStyles['radio-button-label__large--on-blueberry']]: onColor === 'onblueberry' && !checked && large,\n [radioButtonStyles['radio-button-label__large--selected']]: large && checked && !onCherry,\n [radioButtonStyles['radio-button-label__large--selected-invalid']]: large && checked && onCherry,\n });\n};\n"],"mappings":";;;;;;;;;;;;AAgDA,MAAaA,eAA0C,UAAS;CAC9D,MAAM,EACJ,WACA,gBACA,UACA,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,aAAa,iBACb,QAAQ,CAAC,CAAC,WACV,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,iBACA,KACA,GAAG,SACD;CACJ,MAAM,UAAU,SAAS,YAAY,YAAY;CACjD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,WAAW,YAAY,YAAY;CACzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,CAAC,SAAS,iBAAiB,UAAmB;CACpD,MAAM,EAAE,WAAW,cAAc,iBAAmC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACzG,MAAM,aAAa,UAAU,CAAC,KAAK,UAAU,CAAC;CAC9C,MAAM,cAAc,kBAAkB,gBAAgB;CAEtD,MAAM,4BAA4B,GAAW,kBAAkB,yBAAyB;GACrF,kBAAkB,iCAAiC;GACnD,kBAAkB,0CAA0C,WAAW;GACvE,kBAAkB,2CAA2C,WAAW,WAAW;GACnF,kBAAkB,0CAA0C,WAAW,YA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BAAkB,6CAA6C,YAAY,iBAAiB,CAAC,WAAW;GACxG,kBAAkB,yCAAyC,SAAS,WAAW,CAAC;GAChF,kBAAkB,iDAAiD,SAAS,WAAW;EACzF,CAAC"}
package/lib/utils6.js CHANGED
@@ -2,9 +2,9 @@ import { t as Breakpoint } from "./useBreakpoint.js";
2
2
  import { r as ResponsiveTableVariant } from "./constants3.js";
3
3
  import { t as isTouchDevice } from "./device.js";
4
4
  import React from "react";
5
- import styles from "./components/Table/styles.module.scss";
5
+ import tableStyles from "./components/Table/styles.module.scss";
6
6
  var configUsesCss = (config) => config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;
7
- var mapConfigToClass = (config) => config.variant === "centeredoverflow" || config.variant === "block" ? styles[`table--${config.variant}-${config.breakpoint}`] : "";
7
+ var mapConfigToClass = (config) => config.variant === "centeredoverflow" || config.variant === "block" ? tableStyles[`table--${config.variant}-${config.breakpoint}`] : "";
8
8
  var sortByBreakpointsDescending = (a, b) => Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];
9
9
  var isValidForCurrentBreakpoint = (config, breakpoint) => Breakpoint[config.breakpoint] >= breakpoint;
10
10
  var getConfigForBreakpoint = (config, breakpoint) => {
package/lib/utils6.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils6.js","names":["clone: Partial<T>"],"sources":["../src/components/Table/utils.ts"],"sourcesContent":["import React from 'react';\n\nimport type { ModeType } from './constants';\nimport type { BreakpointConfig } from './Table';\n\nimport { ResponsiveTableVariant } from './constants';\nimport { Breakpoint } from '../../hooks/useBreakpoint';\nimport { isTouchDevice } from '../../utils/device';\n\nimport styles from './styles.module.scss';\n\n/**\n * Sjekk om det skal brukes CSS for å bestemme responsivt utseende på dette breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns true om breakpoint bruker CSS\n */\nconst configUsesCss = (config: BreakpointConfig): boolean =>\n config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;\n\n/**\n * Lag klassenavn for CSS-config\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns CSS-klassenavn\n */\nconst mapConfigToClass = (config: BreakpointConfig): string =>\n config.variant === 'centeredoverflow' || config.variant === 'block' ? styles[`table--${config.variant}-${config.breakpoint}`] : '';\n\n/**\n * Sorter konfigurasjon etter breakpoints, fra største til minste\n * @param a Konfigurasjon for responsiv oppførsel\n * @param b Konfigurasjon for responsiv oppførsel\n * @returns Sortert liste\n */\nconst sortByBreakpointsDescending = (a: BreakpointConfig, b: BreakpointConfig): number =>\n Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];\n\n/**\n * Sjekk om en konfigurasjon skal brukes for nåværende breakpoint\n * @param a Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns true dersom config skal brukes for breakpointet\n */\nconst isValidForCurrentBreakpoint = (config: BreakpointConfig, breakpoint: Breakpoint): boolean =>\n Breakpoint[config.breakpoint] >= breakpoint;\n\n/**\n * Finn konfigurasjon for nåværende breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns Konfigurasjon for responsiv oppførsel\n */\nconst getConfigForBreakpoint = (config: BreakpointConfig | BreakpointConfig[], breakpoint: Breakpoint): BreakpointConfig | undefined => {\n if (Array.isArray(config)) {\n config.sort(sortByBreakpointsDescending);\n\n return config.find(x => isValidForCurrentBreakpoint(x, breakpoint));\n } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) {\n return config;\n }\n};\n\n/**\n * Finn konfigurasjon for nåværende breakpoint og tabellbredde\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @param tableWidth Bredde på tabell i px\n * @returns Konfigurasjon for responsiv oppførsel uten fallbackVariant\n */\nexport const getCurrentConfig = (\n config: BreakpointConfig | BreakpointConfig[],\n breakpoint: Breakpoint,\n tableWidth: number,\n windowWidth: number\n): Omit<BreakpointConfig, 'fallbackVariant'> | undefined => {\n const breakpointConfig = getConfigForBreakpoint(config, breakpoint);\n const canUseHorizontalScroll = isTouchDevice();\n const canUseCenteredOverflow = tableWidth <= windowWidth;\n\n if (!breakpointConfig) {\n return;\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n return breakpointConfig;\n};\n\n/**\n * Finn klassenavn for responsiv oppførsel\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns Klassenavn\n */\nexport const getBreakpointClass = (config?: BreakpointConfig): string | undefined =>\n config && configUsesCss(config) ? mapConfigToClass(config) : undefined;\n\n/**\n * Finn riktig posisjon for horisontal sentrering av tabell som skal vises \"centeredoverflow\"\n * @param parentWidth Bredde på element som tabellen ligger i\n * @param tableWidth Bredde på tabellen\n * @returns Styling som posisjonerer tabellen riktig\n */\nexport const getCenteredOverflowTableStyle = (parentWidth: number, tableWidth: number): React.CSSProperties | undefined => {\n if (parentWidth >= tableWidth) {\n return;\n }\n\n const COLUMN_GUTTER_WIDTH_PX = 8;\n\n return { left: `${(parentWidth - tableWidth) / 2 - COLUMN_GUTTER_WIDTH_PX}px` };\n};\n\n/**\n * Map children and inject the `mode` prop into element children, but never on React.Fragment.\n * If a Fragment is encountered, its children are mapped and updated, while the Fragment wrapper is preserved.\n */\nexport const mapChildrenWithMode = (children: React.ReactNode, mode: ModeType | undefined): React.ReactNode =>\n React.Children.map(children, child => {\n if (!React.isValidElement(child)) return child;\n if (child.type === React.Fragment) {\n const fragmentChildren = (child.props as { children?: React.ReactNode }).children;\n const mapped = React.Children.map(fragmentChildren, gc =>\n React.isValidElement<{ mode?: ModeType }>(gc) ? React.cloneElement(gc, { mode }) : gc\n );\n return React.cloneElement(child, undefined, mapped);\n }\n return React.cloneElement(child as React.ReactElement<{ mode?: ModeType }>, { mode });\n });\n\n/**\n * Create a shallow copy of an object with specific keys omitted.\n */\nexport const omitProps = <T extends Record<PropertyKey, unknown>>(obj: T, keys: Array<keyof T>): Partial<T> => {\n const clone: Partial<T> = { ...obj };\n for (const k of keys) {\n delete clone[k];\n }\n return clone;\n};\n"],"mappings":";;;;;AAgBA,IAAM,iBAAiB,WACrB,OAAO,YAAY,uBAAuB,oBAAoB,OAAO,YAAY,uBAAuB;AAO1G,IAAM,oBAAoB,WACxB,OAAO,YAAY,sBAAsB,OAAO,YAAY,UAAU,OAAO,UAAU,OAAO,QAAQ,GAAG,OAAO,gBAAgB;AAQlI,IAAM,+BAA+B,GAAqB,MACxD,WAAW,EAAE,cAAc,WAAW,EAAE;AAQ1C,IAAM,+BAA+B,QAA0B,eAC7D,WAAW,OAAO,eAAe;AAQnC,IAAM,0BAA0B,QAA+C,eAAyD;AACtI,KAAI,MAAM,QAAQ,OAAO,EAAE;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AAC,MAAM,eAAe,MAAM,CAAE,QAAO;AACzC,KAAI,MAAM,SAAS,MAAM,UAAU;EACjC,MAAM,mBAAoB,MAAM,MAAyC;EACzE,MAAM,SAAS,MAAM,SAAS,IAAI,mBAAkB,OAClD,MAAM,eAAoC,GAAG,GAAG,MAAM,aAAa,IAAI,EAAE,MAAM,CAAC,GAAG,GACpF;AACD,SAAO,MAAM,aAAa,OAAO,KAAA,GAAW,OAAO;;AAErD,QAAO,MAAM,aAAa,OAAkD,EAAE,MAAM,CAAC;EACrF;AAKJ,MAAa,aAAqD,KAAQ,SAAqC;CAC7G,MAAMA,QAAoB,EAAE,GAAG,KAAK;AACpC,MAAK,MAAM,KAAK,KACd,QAAO,MAAM;AAEf,QAAO"}
1
+ {"version":3,"file":"utils6.js","names":["clone: Partial<T>"],"sources":["../src/components/Table/utils.ts"],"sourcesContent":["import React from 'react';\n\nimport type { ModeType } from './constants';\nimport type { BreakpointConfig } from './Table';\n\nimport { ResponsiveTableVariant } from './constants';\nimport { Breakpoint } from '../../hooks/useBreakpoint';\nimport { isTouchDevice } from '../../utils/device';\n\nimport styles from './styles.module.scss';\n\n/**\n * Sjekk om det skal brukes CSS for å bestemme responsivt utseende på dette breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns true om breakpoint bruker CSS\n */\nconst configUsesCss = (config: BreakpointConfig): boolean =>\n config.variant === ResponsiveTableVariant.centeredoverflow || config.variant === ResponsiveTableVariant.block;\n\n/**\n * Lag klassenavn for CSS-config\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns CSS-klassenavn\n */\nconst mapConfigToClass = (config: BreakpointConfig): string =>\n config.variant === 'centeredoverflow' || config.variant === 'block' ? styles[`table--${config.variant}-${config.breakpoint}`] : '';\n\n/**\n * Sorter konfigurasjon etter breakpoints, fra største til minste\n * @param a Konfigurasjon for responsiv oppførsel\n * @param b Konfigurasjon for responsiv oppførsel\n * @returns Sortert liste\n */\nconst sortByBreakpointsDescending = (a: BreakpointConfig, b: BreakpointConfig): number =>\n Breakpoint[a.breakpoint] - Breakpoint[b.breakpoint];\n\n/**\n * Sjekk om en konfigurasjon skal brukes for nåværende breakpoint\n * @param a Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns true dersom config skal brukes for breakpointet\n */\nconst isValidForCurrentBreakpoint = (config: BreakpointConfig, breakpoint: Breakpoint): boolean =>\n Breakpoint[config.breakpoint] >= breakpoint;\n\n/**\n * Finn konfigurasjon for nåværende breakpoint\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @returns Konfigurasjon for responsiv oppførsel\n */\nconst getConfigForBreakpoint = (config: BreakpointConfig | BreakpointConfig[], breakpoint: Breakpoint): BreakpointConfig | undefined => {\n if (Array.isArray(config)) {\n config.sort(sortByBreakpointsDescending);\n\n return config.find(x => isValidForCurrentBreakpoint(x, breakpoint));\n } else if (config && isValidForCurrentBreakpoint(config, breakpoint)) {\n return config;\n }\n};\n\n/**\n * Finn konfigurasjon for nåværende breakpoint og tabellbredde\n * @param config Konfigurasjon for responsiv oppførsel\n * @param breakpoint Nåværende breakpoint\n * @param tableWidth Bredde på tabell i px\n * @returns Konfigurasjon for responsiv oppførsel uten fallbackVariant\n */\nexport const getCurrentConfig = (\n config: BreakpointConfig | BreakpointConfig[],\n breakpoint: Breakpoint,\n tableWidth: number,\n windowWidth: number\n): Omit<BreakpointConfig, 'fallbackVariant'> | undefined => {\n const breakpointConfig = getConfigForBreakpoint(config, breakpoint);\n const canUseHorizontalScroll = isTouchDevice();\n const canUseCenteredOverflow = tableWidth <= windowWidth;\n\n if (!breakpointConfig) {\n return;\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: canUseHorizontalScroll ? ResponsiveTableVariant.horizontalscroll : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.centeredoverflow &&\n !canUseCenteredOverflow &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant === ResponsiveTableVariant.centeredoverflow\n ) {\n return {\n variant: canUseCenteredOverflow ? ResponsiveTableVariant.centeredoverflow : ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n if (\n breakpointConfig.variant === ResponsiveTableVariant.horizontalscroll &&\n !canUseHorizontalScroll &&\n breakpointConfig.fallbackVariant !== ResponsiveTableVariant.horizontalscroll\n ) {\n return {\n variant: breakpointConfig.fallbackVariant ?? ResponsiveTableVariant.none,\n breakpoint: breakpointConfig.breakpoint,\n };\n }\n\n return breakpointConfig;\n};\n\n/**\n * Finn klassenavn for responsiv oppførsel\n * @param config Konfigurasjon for responsiv oppførsel\n * @returns Klassenavn\n */\nexport const getBreakpointClass = (config?: BreakpointConfig): string | undefined =>\n config && configUsesCss(config) ? mapConfigToClass(config) : undefined;\n\n/**\n * Finn riktig posisjon for horisontal sentrering av tabell som skal vises \"centeredoverflow\"\n * @param parentWidth Bredde på element som tabellen ligger i\n * @param tableWidth Bredde på tabellen\n * @returns Styling som posisjonerer tabellen riktig\n */\nexport const getCenteredOverflowTableStyle = (parentWidth: number, tableWidth: number): React.CSSProperties | undefined => {\n if (parentWidth >= tableWidth) {\n return;\n }\n\n const COLUMN_GUTTER_WIDTH_PX = 8;\n\n return { left: `${(parentWidth - tableWidth) / 2 - COLUMN_GUTTER_WIDTH_PX}px` };\n};\n\n/**\n * Map children and inject the `mode` prop into element children, but never on React.Fragment.\n * If a Fragment is encountered, its children are mapped and updated, while the Fragment wrapper is preserved.\n */\nexport const mapChildrenWithMode = (children: React.ReactNode, mode: ModeType | undefined): React.ReactNode =>\n React.Children.map(children, child => {\n if (!React.isValidElement(child)) return child;\n if (child.type === React.Fragment) {\n const fragmentChildren = (child.props as { children?: React.ReactNode }).children;\n const mapped = React.Children.map(fragmentChildren, gc =>\n React.isValidElement<{ mode?: ModeType }>(gc) ? React.cloneElement(gc, { mode }) : gc\n );\n return React.cloneElement(child, undefined, mapped);\n }\n return React.cloneElement(child as React.ReactElement<{ mode?: ModeType }>, { mode });\n });\n\n/**\n * Create a shallow copy of an object with specific keys omitted.\n */\nexport const omitProps = <T extends Record<PropertyKey, unknown>>(obj: T, keys: Array<keyof T>): Partial<T> => {\n const clone: Partial<T> = { ...obj };\n for (const k of keys) {\n delete clone[k];\n }\n return clone;\n};\n"],"mappings":";;;;;AAgBA,IAAM,iBAAiB,WACrB,OAAO,YAAY,uBAAuB,oBAAoB,OAAO,YAAY,uBAAuB;AAO1G,IAAM,oBAAoB,WACxB,OAAO,YAAY,sBAAsB,OAAO,YAAY,UAAU,YAAO,UAAU,OAAO,QAAQ,GAAG,OAAO,gBAAgB;AAQlI,IAAM,+BAA+B,GAAqB,MACxD,WAAW,EAAE,cAAc,WAAW,EAAE;AAQ1C,IAAM,+BAA+B,QAA0B,eAC7D,WAAW,OAAO,eAAe;AAQnC,IAAM,0BAA0B,QAA+C,eAAyD;AACtI,KAAI,MAAM,QAAQ,OAAO,EAAE;AACzB,SAAO,KAAK,4BAA4B;AAExC,SAAO,OAAO,MAAK,MAAK,4BAA4B,GAAG,WAAW,CAAC;YAC1D,UAAU,4BAA4B,QAAQ,WAAW,CAClE,QAAO;;AAWX,MAAa,oBACX,QACA,YACA,YACA,gBAC0D;CAC1D,MAAM,mBAAmB,uBAAuB,QAAQ,WAAW;CACnE,MAAM,yBAAyB,eAAe;CAC9C,MAAM,yBAAyB,cAAc;AAE7C,KAAI,CAAC,iBACH;AAGF,KACE,iBAAiB,YAAY,uBAAuB,oBACpD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KJ,MAAa,aAAqD,KAAQ,SAAqC;CAC7G,MAAMA,QAAoB,EAAE,GAAG,KAAK;AACpC,MAAK,MAAM,KAAK,KACd,QAAO,MAAM;AAEf,QAAO"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@helsenorge/designsystem-react",
3
3
  "sideEffects": false,
4
4
  "private": false,
5
- "version": "14.0.0-beta.9",
5
+ "version": "14.1.0",
6
6
  "description": "The official design system for Helsenorge built with React.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -28,7 +28,8 @@
28
28
  }
29
29
  }
30
30
 
31
- @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
31
+ // fjerner denne i vår kopi
32
+ // @include deprecate('The `make-container-max-widths` mixin', 'v4.5.2', 'v5');
32
33
  }
33
34
 
34
35
  @mixin make-col-ready($gutter: $grid-gutter-width) {