@navikt/ds-react 5.5.0 → 5.6.0-beta.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 (267) hide show
  1. package/_docs.json +446 -888
  2. package/cjs/accordion/AccordionItem.js +3 -2
  3. package/cjs/date/datepicker/DatePickerStandalone.js +2 -2
  4. package/cjs/date/hooks/useDatepicker.js +2 -2
  5. package/cjs/date/hooks/useMonthPicker.js +2 -2
  6. package/cjs/date/hooks/useRangeDatepicker.js +3 -3
  7. package/cjs/date/monthpicker/MonthSelector.js +1 -1
  8. package/cjs/dropdown/Toggle.js +2 -2
  9. package/cjs/dropdown/index.js +0 -15
  10. package/cjs/form/Select.js +1 -1
  11. package/cjs/form/checkbox/useCheckbox.js +3 -4
  12. package/cjs/form/combobox/Combobox.js +1 -1
  13. package/cjs/form/combobox/Input/Input.js +1 -1
  14. package/cjs/form/search/Search.js +3 -1
  15. package/cjs/layout/bleed/Bleed.js +49 -0
  16. package/cjs/layout/bleed/index.js +8 -0
  17. package/cjs/layout/bleed/package.json +6 -0
  18. package/cjs/layout/content-box/ContentBox.js +56 -0
  19. package/cjs/layout/content-box/index.js +8 -0
  20. package/cjs/layout/content-box/package.json +6 -0
  21. package/cjs/layout/page-demo/AvatarPanel.js +18 -0
  22. package/cjs/layout/page-demo/Filter.js +21 -0
  23. package/cjs/layout/page-demo/Header.js +48 -0
  24. package/cjs/layout/page-demo/Intro.js +36 -0
  25. package/cjs/layout/page-demo/Sidebar.js +49 -0
  26. package/cjs/layout/sidemal-test/AvatarPanel.js +18 -0
  27. package/cjs/layout/sidemal-test/Content.js +66 -0
  28. package/cjs/layout/sidemal-test/Filter.js +48 -0
  29. package/cjs/layout/sidemal-test/Header.js +48 -0
  30. package/cjs/layout/sidemal-test/Intro.js +36 -0
  31. package/cjs/layout/sidemal-test/Sidebar.js +49 -0
  32. package/cjs/layout/sidemal-test/content-box/ContentBox.js +65 -0
  33. package/cjs/layout/sidemal-test/content-box/index.js +8 -0
  34. package/cjs/layout/sidemal-test/content-box/package.json +6 -0
  35. package/cjs/layout/stack/Stack.js +2 -2
  36. package/cjs/layout/stack/index.js +3 -1
  37. package/cjs/loader/Loader.js +2 -2
  38. package/cjs/modal/dialog-polyfill.js +2 -0
  39. package/cjs/popover/Popover.js +3 -2
  40. package/cjs/tabs/TabList.js +6 -7
  41. package/cjs/timeline/Pin.js +20 -20
  42. package/cjs/timeline/Timeline.js +4 -4
  43. package/cjs/timeline/period/ClickablePeriod.js +19 -19
  44. package/cjs/timeline/period/index.js +1 -1
  45. package/cjs/timeline/utils/timeline.js +3 -3
  46. package/cjs/toggle-group/ToggleGroup.js +1 -1
  47. package/cjs/tooltip/Tooltip.js +1 -1
  48. package/cjs/typography/Heading.js +1 -1
  49. package/cjs/util/RandomIcon.js +1 -0
  50. package/cjs/util/Slot.js +88 -0
  51. package/cjs/util/useId.js +2 -4
  52. package/esm/accordion/AccordionItem.js +3 -2
  53. package/esm/accordion/AccordionItem.js.map +1 -1
  54. package/esm/date/datepicker/DatePickerStandalone.js +2 -2
  55. package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
  56. package/esm/date/hooks/useDatepicker.js +2 -2
  57. package/esm/date/hooks/useDatepicker.js.map +1 -1
  58. package/esm/date/hooks/useMonthPicker.js +2 -2
  59. package/esm/date/hooks/useMonthPicker.js.map +1 -1
  60. package/esm/date/hooks/useRangeDatepicker.js +3 -3
  61. package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
  62. package/esm/date/monthpicker/MonthButton.d.ts +2 -2
  63. package/esm/date/monthpicker/MonthPicker.d.ts +1 -1
  64. package/esm/date/monthpicker/MonthSelector.js +1 -1
  65. package/esm/date/monthpicker/MonthSelector.js.map +1 -1
  66. package/esm/date/utils/navigation.d.ts +1 -1
  67. package/esm/date/utils/navigation.js.map +1 -1
  68. package/esm/dropdown/Toggle.js +1 -1
  69. package/esm/dropdown/Toggle.js.map +1 -1
  70. package/esm/dropdown/index.d.ts +1 -2
  71. package/esm/dropdown/index.js +0 -1
  72. package/esm/dropdown/index.js.map +1 -1
  73. package/esm/form/Fieldset/useFieldset.d.ts +1 -1
  74. package/esm/form/Select.js +1 -1
  75. package/esm/form/Select.js.map +1 -1
  76. package/esm/form/checkbox/useCheckbox.d.ts +2 -2
  77. package/esm/form/checkbox/useCheckbox.js +3 -4
  78. package/esm/form/checkbox/useCheckbox.js.map +1 -1
  79. package/esm/form/combobox/Combobox.d.ts +1 -1
  80. package/esm/form/combobox/Combobox.js +1 -1
  81. package/esm/form/combobox/Combobox.js.map +1 -1
  82. package/esm/form/combobox/Input/Input.d.ts +0 -2
  83. package/esm/form/combobox/Input/Input.js +1 -1
  84. package/esm/form/combobox/Input/Input.js.map +1 -1
  85. package/esm/form/radio/useRadio.d.ts +1 -1
  86. package/esm/form/search/Search.js +3 -1
  87. package/esm/form/search/Search.js.map +1 -1
  88. package/esm/layout/bleed/Bleed.d.ts +8 -0
  89. package/esm/layout/bleed/Bleed.js +21 -0
  90. package/esm/layout/bleed/Bleed.js.map +1 -0
  91. package/esm/layout/bleed/index.d.ts +1 -0
  92. package/esm/layout/bleed/index.js +2 -0
  93. package/esm/layout/bleed/index.js.map +1 -0
  94. package/esm/layout/box/Box.d.ts +1 -2
  95. package/esm/layout/box/Box.js.map +1 -1
  96. package/esm/layout/content-box/ContentBox.d.ts +8 -0
  97. package/esm/layout/content-box/ContentBox.js +28 -0
  98. package/esm/layout/content-box/ContentBox.js.map +1 -0
  99. package/esm/layout/content-box/index.d.ts +1 -0
  100. package/esm/layout/content-box/index.js +2 -0
  101. package/esm/layout/content-box/index.js.map +1 -0
  102. package/esm/layout/page-demo/AvatarPanel.d.ts +4 -0
  103. package/esm/layout/page-demo/AvatarPanel.js +12 -0
  104. package/esm/layout/page-demo/AvatarPanel.js.map +1 -0
  105. package/esm/layout/page-demo/Filter.d.ts +2 -0
  106. package/esm/layout/page-demo/Filter.js +15 -0
  107. package/esm/layout/page-demo/Filter.js.map +1 -0
  108. package/esm/layout/page-demo/Header.d.ts +2 -0
  109. package/esm/layout/page-demo/Header.js +42 -0
  110. package/esm/layout/page-demo/Header.js.map +1 -0
  111. package/esm/layout/page-demo/Intro.d.ts +2 -0
  112. package/esm/layout/page-demo/Intro.js +30 -0
  113. package/esm/layout/page-demo/Intro.js.map +1 -0
  114. package/esm/layout/page-demo/Sidebar.d.ts +4 -0
  115. package/esm/layout/page-demo/Sidebar.js +41 -0
  116. package/esm/layout/page-demo/Sidebar.js.map +1 -0
  117. package/esm/layout/sidemal-test/AvatarPanel.d.ts +4 -0
  118. package/esm/layout/sidemal-test/AvatarPanel.js +12 -0
  119. package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -0
  120. package/esm/layout/sidemal-test/Content.d.ts +2 -0
  121. package/esm/layout/sidemal-test/Content.js +60 -0
  122. package/esm/layout/sidemal-test/Content.js.map +1 -0
  123. package/esm/layout/sidemal-test/Filter.d.ts +2 -0
  124. package/esm/layout/sidemal-test/Filter.js +22 -0
  125. package/esm/layout/sidemal-test/Filter.js.map +1 -0
  126. package/esm/layout/sidemal-test/Header.d.ts +2 -0
  127. package/esm/layout/sidemal-test/Header.js +42 -0
  128. package/esm/layout/sidemal-test/Header.js.map +1 -0
  129. package/esm/layout/sidemal-test/Intro.d.ts +2 -0
  130. package/esm/layout/sidemal-test/Intro.js +30 -0
  131. package/esm/layout/sidemal-test/Intro.js.map +1 -0
  132. package/esm/layout/sidemal-test/Sidebar.d.ts +4 -0
  133. package/esm/layout/sidemal-test/Sidebar.js +41 -0
  134. package/esm/layout/sidemal-test/Sidebar.js.map +1 -0
  135. package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +8 -0
  136. package/esm/layout/sidemal-test/content-box/ContentBox.js +37 -0
  137. package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -0
  138. package/esm/layout/sidemal-test/content-box/index.d.ts +1 -0
  139. package/esm/layout/sidemal-test/content-box/index.js +2 -0
  140. package/esm/layout/sidemal-test/content-box/index.js.map +1 -0
  141. package/esm/layout/stack/Stack.d.ts +7 -3
  142. package/esm/layout/stack/Stack.js +3 -3
  143. package/esm/layout/stack/Stack.js.map +1 -1
  144. package/esm/layout/stack/index.d.ts +1 -0
  145. package/esm/layout/stack/index.js +1 -0
  146. package/esm/layout/stack/index.js.map +1 -1
  147. package/esm/layout/utilities/css.js.map +1 -1
  148. package/esm/loader/Loader.js +3 -3
  149. package/esm/loader/Loader.js.map +1 -1
  150. package/esm/modal/dialog-polyfill.js +2 -0
  151. package/esm/modal/dialog-polyfill.js.map +1 -1
  152. package/esm/popover/Popover.js +3 -2
  153. package/esm/popover/Popover.js.map +1 -1
  154. package/esm/tabs/TabList.js +6 -7
  155. package/esm/tabs/TabList.js.map +1 -1
  156. package/esm/timeline/Pin.js +21 -21
  157. package/esm/timeline/Pin.js.map +1 -1
  158. package/esm/timeline/Timeline.js +4 -4
  159. package/esm/timeline/Timeline.js.map +1 -1
  160. package/esm/timeline/TimelineRow.js.map +1 -1
  161. package/esm/timeline/hooks/usePeriodContext.d.ts +1 -1
  162. package/esm/timeline/period/ClickablePeriod.js +20 -20
  163. package/esm/timeline/period/ClickablePeriod.js.map +1 -1
  164. package/esm/timeline/period/index.d.ts +2 -2
  165. package/esm/timeline/period/index.js +1 -1
  166. package/esm/timeline/period/index.js.map +1 -1
  167. package/esm/timeline/utils/timeline.js +3 -3
  168. package/esm/timeline/utils/timeline.js.map +1 -1
  169. package/esm/toggle-group/ToggleGroup.js +1 -1
  170. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  171. package/esm/tooltip/Tooltip.js +1 -1
  172. package/esm/tooltip/Tooltip.js.map +1 -1
  173. package/esm/typography/Heading.js +1 -1
  174. package/esm/typography/Heading.js.map +1 -1
  175. package/esm/util/RandomIcon.js +1 -0
  176. package/esm/util/RandomIcon.js.map +1 -1
  177. package/esm/util/Slot.d.ts +6 -0
  178. package/esm/util/Slot.js +60 -0
  179. package/esm/util/Slot.js.map +1 -0
  180. package/esm/util/mergeRefs.d.ts +1 -1
  181. package/esm/util/useId.js +2 -4
  182. package/esm/util/useId.js.map +1 -1
  183. package/package.json +3 -4
  184. package/src/accordion/AccordionItem.tsx +3 -5
  185. package/src/accordion/accordion.stories.tsx +21 -34
  186. package/src/alert/alert.stories.tsx +2 -2
  187. package/src/chips/chips.stories.tsx +29 -32
  188. package/src/date/datepicker/DatePickerStandalone.tsx +1 -3
  189. package/src/date/datepicker/datepicker.stories.tsx +1 -1
  190. package/src/date/datepicker/datepicker.test.tsx +5 -4
  191. package/src/date/hooks/useDatepicker.tsx +2 -2
  192. package/src/date/hooks/useMonthPicker.tsx +2 -2
  193. package/src/date/hooks/useRangeDatepicker.test.tsx +11 -11
  194. package/src/date/hooks/useRangeDatepicker.tsx +3 -3
  195. package/src/date/monthpicker/MonthButton.tsx +2 -2
  196. package/src/date/monthpicker/MonthPicker.tsx +1 -1
  197. package/src/date/monthpicker/MonthSelector.tsx +3 -3
  198. package/src/date/monthpicker/monthpicker.stories.tsx +1 -1
  199. package/src/date/utils/__tests__/get-initial-year.test.ts +0 -12
  200. package/src/date/utils/__tests__/is-match.test.ts +3 -3
  201. package/src/date/utils/__tests__/parse-dates.test.ts +4 -2
  202. package/src/date/utils/navigation.ts +3 -3
  203. package/src/dropdown/Toggle.tsx +1 -1
  204. package/src/dropdown/dropdown.stories.tsx +25 -28
  205. package/src/dropdown/index.ts +1 -2
  206. package/src/expansion-card/expansion-card.stories.tsx +143 -161
  207. package/src/form/ConfirmationPanel.test.tsx +5 -5
  208. package/src/form/Select.tsx +1 -1
  209. package/src/form/checkbox/Checkbox.test.tsx +14 -26
  210. package/src/form/checkbox/checkbox.stories.tsx +66 -71
  211. package/src/form/checkbox/useCheckbox.ts +3 -4
  212. package/src/form/combobox/Combobox.tsx +2 -3
  213. package/src/form/combobox/Input/Input.tsx +1 -3
  214. package/src/form/combobox/combobox.stories.tsx +20 -23
  215. package/src/form/combobox/combobox.test.tsx +22 -20
  216. package/src/form/radio/radio.stories.tsx +39 -44
  217. package/src/form/search/Search.tsx +1 -0
  218. package/src/form/search/search.stories.tsx +22 -26
  219. package/src/form/stories/fieldset.stories.tsx +1 -1
  220. package/src/layout/box/Box.stories.tsx +251 -256
  221. package/src/layout/box/Box.tsx +1 -1
  222. package/src/layout/sidemal-test/AvatarPanel.tsx +27 -0
  223. package/src/layout/sidemal-test/Content.tsx +129 -0
  224. package/src/layout/sidemal-test/Filter.tsx +46 -0
  225. package/src/layout/sidemal-test/Header.tsx +96 -0
  226. package/src/layout/sidemal-test/Intro.tsx +91 -0
  227. package/src/layout/sidemal-test/Sidebar.tsx +77 -0
  228. package/src/layout/sidemal-test/content-box/ContentBox.tsx +46 -0
  229. package/src/layout/sidemal-test/content-box/index.ts +1 -0
  230. package/src/layout/sidemal-test/navno-sidemal.stories.mdx +29 -0
  231. package/src/layout/sidemal-test/navno-sidemal.stories.tsx +65 -0
  232. package/src/layout/sidemal-test/styling.css +43 -0
  233. package/src/layout/stack/Stack.tsx +14 -8
  234. package/src/layout/stack/index.ts +1 -0
  235. package/src/layout/stack/stack.stories.tsx +23 -1
  236. package/src/layout/utilities/css.ts +0 -1
  237. package/src/loader/Loader.tsx +2 -3
  238. package/src/modal/dialog-polyfill.ts +2 -0
  239. package/src/pagination/pagination.stories.tsx +35 -42
  240. package/src/popover/Popover.test.tsx +21 -35
  241. package/src/popover/Popover.tsx +2 -2
  242. package/src/popover/popover.stories.tsx +25 -41
  243. package/src/react-css.d.ts +0 -1
  244. package/src/read-more/readmore.stories.tsx +35 -36
  245. package/src/stepper/stepper.stories.tsx +45 -52
  246. package/src/table/stories/table-expandable.stories.tsx +59 -63
  247. package/src/tabs/TabList.tsx +4 -6
  248. package/src/tabs/Tabs.stories.tsx +3 -3
  249. package/src/tag/tag.stories.tsx +4 -4
  250. package/src/timeline/Pin.tsx +44 -39
  251. package/src/timeline/Timeline.tsx +6 -6
  252. package/src/timeline/TimelineRow.tsx +1 -0
  253. package/src/timeline/hooks/usePeriodContext.tsx +1 -1
  254. package/src/timeline/period/ClickablePeriod.tsx +42 -38
  255. package/src/timeline/period/index.tsx +5 -4
  256. package/src/timeline/timeline.stories.tsx +11 -10
  257. package/src/timeline/utils/timeline.ts +3 -3
  258. package/src/toggle-group/ToggleGroup.stories.tsx +25 -29
  259. package/src/toggle-group/ToggleGroup.tsx +0 -1
  260. package/src/tooltip/Tooltip.test.tsx +40 -54
  261. package/src/tooltip/Tooltip.tsx +1 -1
  262. package/src/typography/Heading.tsx +1 -1
  263. package/src/util/RandomIcon.tsx +1 -0
  264. package/src/util/Slot.tsx +69 -0
  265. package/src/util/__tests__/Slot.test.tsx +98 -0
  266. package/src/util/mergeRefs.tsx +1 -1
  267. package/src/util/useId.ts +1 -3
@@ -1 +1 @@
1
- {"version":3,"file":"useId.js","sourceRoot":"","sources":["../../src/util/useId.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAS,WAAW,CAAC,UAAmB;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,UAAU,IAAI,SAAS,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,6CAA6C;YAC7C,6DAA6D;YAC7D,+BAA+B;YAC/B,wHAAwH;YACxH,QAAQ,IAAI,CAAC,CAAC;YACd,YAAY,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;SACtC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAChB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,+GAA+G;AAC/G,MAAM,eAAe,GAAgC,KAAa;AAChE,6CAA6C;AAC7C,OAAO,GAAG,EAAE,CACb,CAAC;AACF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,UAAmB;;IACvC,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,OAAO,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KAClD;IACD,0FAA0F;IAC1F,OAAO,MAAA,WAAW,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;AACvC,CAAC"}
1
+ {"version":3,"file":"useId.js","sourceRoot":"","sources":["../../src/util/useId.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAS,WAAW,CAAC,UAAmB;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,UAAU,IAAI,SAAS,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,6CAA6C;YAC7C,6DAA6D;YAC7D,+BAA+B;YAC/B,wHAAwH;YACxH,QAAQ,IAAI,CAAC,CAAC;YACd,YAAY,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;SACtC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAChB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,eAAe,GAAgC,KAAa,CAChE,OAAO,GAAG,EAAE,CAAC,iEAAiE;CAC/E,CAAC;AACF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,UAAmB;;IACvC,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,OAAO,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KAClD;IACD,0FAA0F;IAC1F,OAAO,MAAA,WAAW,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;AACvC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "5.5.0",
3
+ "version": "5.6.0-beta.0",
4
4
  "description": "Aksel react-components for NAV designsystem",
5
5
  "author": "Aksel | NAV designsystem team",
6
6
  "license": "MIT",
@@ -18,8 +18,7 @@
18
18
  "module": "./esm/index.js",
19
19
  "typings": "./esm/index.d.ts",
20
20
  "publishConfig": {
21
- "access": "public",
22
- "provenance": true
21
+ "access": "public"
23
22
  },
24
23
  "files": [
25
24
  "/cjs",
@@ -37,7 +36,7 @@
37
36
  "test": "TZ=UTC jest"
38
37
  },
39
38
  "dependencies": {
40
- "@floating-ui/react": "0.24.1",
39
+ "@floating-ui/react": "0.25.4",
41
40
  "@navikt/aksel-icons": "^5.5.0",
42
41
  "@navikt/ds-tokens": "^5.5.0",
43
42
  "@radix-ui/react-tabs": "1.0.0",
@@ -7,6 +7,7 @@ import React, {
7
7
  useState,
8
8
  } from "react";
9
9
  import { AccordionContext } from "./AccordionContext";
10
+ import { omit } from "../util";
10
11
 
11
12
  export interface AccordionItemProps
12
13
  extends React.HTMLAttributes<HTMLDivElement> {
@@ -36,10 +37,7 @@ export const AccordionItemContext =
36
37
  createContext<AccordionItemContextProps | null>(null);
37
38
 
38
39
  const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
39
- (
40
- { children, className, open, defaultOpen = false, onClick, id, ...rest },
41
- ref
42
- ) => {
40
+ ({ children, className, open, defaultOpen = false, ...rest }, ref) => {
43
41
  const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);
44
42
  const context = useContext(AccordionContext);
45
43
 
@@ -64,7 +62,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
64
62
  "navds-accordion__item--no-animation": !shouldAnimate.current,
65
63
  })}
66
64
  ref={ref}
67
- {...rest}
65
+ {...omit(rest, ["onClick"])}
68
66
  >
69
67
  <AccordionItemContext.Provider
70
68
  value={{
@@ -274,39 +274,26 @@ const SingleHeaderAccordion = ({
274
274
  );
275
275
  };
276
276
 
277
- type sizesType = "large" | "medium" | "small";
278
- type headingSizesType = "large" | "medium" | "small" | "xsmall";
279
- const sizes: sizesType[] = ["large", "medium", "small"];
280
- const headingSizes: headingSizesType[] = ["large", "medium", "small", "xsmall"]; // enum this?!
277
+ const sizes: AccordionProps["size"][] = ["large", "medium", "small"];
278
+ const headingSizes: AccordionProps["headingSize"][] = [
279
+ "large",
280
+ "medium",
281
+ "small",
282
+ "xsmall",
283
+ ];
281
284
 
282
- export const Size = {
283
- render: ({ ...props }) => {
284
- return (
285
- <div style={{ width: 500 }} className="colgap">
286
- {sizes.map((element) => (
287
- <SingleHeaderAccordion size={element} {...props} />
288
- ))}
289
- </div>
290
- );
291
- },
292
-
293
- args: {
294
- variant: "neutral",
295
- },
296
- };
297
-
298
- export const HeadingSize = {
299
- render: ({ ...props }) => {
300
- return (
301
- <div style={{ width: 500 }} className="colgap">
302
- {headingSizes.map((element) => (
303
- <SingleHeaderAccordion headingSize={element} {...props} />
304
- ))}
305
- </div>
306
- );
307
- },
285
+ export const Size = (props) => (
286
+ <div style={{ width: 500 }} className="colgap">
287
+ {sizes.map((size) => (
288
+ <SingleHeaderAccordion key={size} size={size} {...props} />
289
+ ))}
290
+ </div>
291
+ );
308
292
 
309
- args: {
310
- variant: "neutral",
311
- },
312
- };
293
+ export const HeadingSize = (props) => (
294
+ <div style={{ width: 500 }} className="colgap">
295
+ {headingSizes.map((size) => (
296
+ <SingleHeaderAccordion key={size} headingSize={size} {...props} />
297
+ ))}
298
+ </div>
299
+ );
@@ -140,7 +140,7 @@ export const Heading = () => {
140
140
  export const Links = () => {
141
141
  return (
142
142
  <div className="colgap">
143
- {variants.map((variant, i) => (
143
+ {variants.map((variant) => (
144
144
  <Alert key={variant} variant={variant}>
145
145
  <Link href="#">Id elit esse enim reprehenderit</Link>
146
146
  </Alert>
@@ -156,7 +156,7 @@ const AlertWithCloseButton = ({
156
156
  size?: "medium" | "small";
157
157
  children?: React.ReactNode;
158
158
  }) => {
159
- let [show, setShow] = React.useState(true);
159
+ const [show, setShow] = React.useState(true);
160
160
 
161
161
  return show ? (
162
162
  <Alert
@@ -1,4 +1,3 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
1
  import React, { useState } from "react";
3
2
  import { Chips } from ".";
4
3
 
@@ -23,46 +22,44 @@ export default {
23
22
 
24
23
  const options = ["Norsk", "Dansk", "Svensk", "Tysk", "Spansk"];
25
24
 
26
- export const Default = {
27
- render: (props) => {
28
- const [selected, setSelected] = useState(["Dansk", "Svensk"]);
29
- const [filter, setFilter] = useState(options);
30
-
31
- if (props.type === "toggle") {
32
- return (
33
- <Chips size={props.size ?? "medium"}>
34
- {options.map((c) => (
35
- <Chips.Toggle
36
- selected={selected.includes(c)}
37
- key={c}
38
- onClick={() =>
39
- setSelected(
40
- selected.includes(c)
41
- ? selected.filter((x) => x !== c)
42
- : [...selected, c]
43
- )
44
- }
45
- >
46
- {c}
47
- </Chips.Toggle>
48
- ))}
49
- </Chips>
50
- );
51
- }
25
+ export const Default = (props) => {
26
+ const [selected, setSelected] = useState(["Dansk", "Svensk"]);
27
+ const [filter, setFilter] = useState(options);
52
28
 
29
+ if (props.type === "toggle") {
53
30
  return (
54
31
  <Chips size={props.size ?? "medium"}>
55
- {filter.map((c) => (
56
- <Chips.Removable
32
+ {options.map((c) => (
33
+ <Chips.Toggle
34
+ selected={selected.includes(c)}
57
35
  key={c}
58
- onClick={() => setFilter((x) => x.filter((y) => y !== c))}
36
+ onClick={() =>
37
+ setSelected(
38
+ selected.includes(c)
39
+ ? selected.filter((x) => x !== c)
40
+ : [...selected, c]
41
+ )
42
+ }
59
43
  >
60
44
  {c}
61
- </Chips.Removable>
45
+ </Chips.Toggle>
62
46
  ))}
63
47
  </Chips>
64
48
  );
65
- },
49
+ }
50
+
51
+ return (
52
+ <Chips size={props.size ?? "medium"}>
53
+ {filter.map((c) => (
54
+ <Chips.Removable
55
+ key={c}
56
+ onClick={() => setFilter((x) => x.filter((y) => y !== c))}
57
+ >
58
+ {c}
59
+ </Chips.Removable>
60
+ ))}
61
+ </Chips>
62
+ );
66
63
  };
67
64
 
68
65
  export const Toggle = () => {
@@ -44,7 +44,6 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
44
44
  >(
45
45
  (
46
46
  {
47
- children,
48
47
  className,
49
48
  locale = "nb",
50
49
  dropdownCaption,
@@ -52,7 +51,6 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
52
51
  disableWeekends = false,
53
52
  showWeekNumber = false,
54
53
  selected,
55
- id,
56
54
  defaultSelected,
57
55
  onSelect,
58
56
  fixedWeeks = true,
@@ -121,7 +119,7 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
121
119
  showWeekNumber={showWeekNumber}
122
120
  fixedWeeks={fixedWeeks}
123
121
  showOutsideDays
124
- {...omit(rest, ["onSelect"])}
122
+ {...omit(rest, ["onSelect", "children", "id"])}
125
123
  />
126
124
  </div>
127
125
  );
@@ -311,7 +311,7 @@ export const UseRangedDatepickerValidation = () => {
311
311
  );
312
312
  };
313
313
 
314
- export const defaultShownMonth = () => {
314
+ export const DefaultShownMonth = () => {
315
315
  const { datepickerProps, inputProps } = useDatepicker({
316
316
  fromDate: new Date("Aug 23 2019"),
317
317
  onDateChange: console.log,
@@ -1,5 +1,4 @@
1
- /* eslint-disable react/jsx-pascal-case */
2
- import { act, render } from "@testing-library/react";
1
+ import { act, render, screen } from "@testing-library/react";
3
2
  import userEvent from "@testing-library/user-event";
4
3
  import React from "react";
5
4
  import { DatePicker, useDatepicker } from "..";
@@ -18,11 +17,13 @@ const App = () => {
18
17
  };
19
18
 
20
19
  describe("Render datepicker", () => {
20
+ // eslint-disable-next-line jest/expect-expect
21
21
  it("Should not crash when e.target is window", async () => {
22
- const utils = render(<App />);
22
+ render(<App />);
23
23
 
24
+ // eslint-disable-next-line testing-library/no-unnecessary-act -- https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning
24
25
  await act(async () => {
25
- await userEvent.click(utils.getByText("Velg dato"));
26
+ await userEvent.click(screen.getByText("Velg dato"));
26
27
  });
27
28
  });
28
29
  });
@@ -207,7 +207,7 @@ export const useDatepicker = (
207
207
  return;
208
208
  }
209
209
  !open && openOnFocus && handleOpen(true);
210
- let day = parseDate(
210
+ const day = parseDate(
211
211
  e.target.value,
212
212
  today,
213
213
  locale,
@@ -227,7 +227,7 @@ export const useDatepicker = (
227
227
  };
228
228
 
229
229
  const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
230
- let day = parseDate(
230
+ const day = parseDate(
231
231
  e.target.value,
232
232
  today,
233
233
  locale,
@@ -204,7 +204,7 @@ export const useMonthpicker = (
204
204
  return;
205
205
  }
206
206
  !open && openOnFocus && handleOpen(true);
207
- let day = parseDate(
207
+ const day = parseDate(
208
208
  e.target.value,
209
209
  today,
210
210
  locale,
@@ -223,7 +223,7 @@ export const useMonthpicker = (
223
223
  };
224
224
 
225
225
  const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
226
- let day = parseDate(
226
+ const day = parseDate(
227
227
  e.target.value,
228
228
  today,
229
229
  locale,
@@ -1,5 +1,5 @@
1
- /* eslint-disable react/jsx-pascal-case */
2
- import { act, render } from "@testing-library/react";
1
+ /* eslint-disable testing-library/no-unnecessary-act -- https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning */
2
+ import { act, render, screen } from "@testing-library/react";
3
3
  import userEvent from "@testing-library/user-event";
4
4
  import React from "react";
5
5
  import { DatePicker, useRangeDatepicker } from "..";
@@ -23,15 +23,15 @@ const RangeDemo = () => {
23
23
 
24
24
  describe("Writing in input sets correct values", () => {
25
25
  it("useRangeDatepicker same date", async () => {
26
- const utils = render(<RangeDemo />);
26
+ render(<RangeDemo />);
27
27
 
28
- const fraInput = utils.getByRole("textbox", { name: "Fra" });
29
- const tilInput = utils.getByRole("textbox", { name: "Til" });
28
+ const fraInput = screen.getByRole("textbox", { name: "Fra" });
29
+ const tilInput = screen.getByRole("textbox", { name: "Til" });
30
30
  await act(async () => {
31
31
  await userEvent.type(fraInput, "03.08.2022");
32
32
  await userEvent.type(tilInput, "03.08.2022");
33
33
  });
34
- const res = utils.getByTitle("res");
34
+ const res = screen.getByTitle("res");
35
35
  expect(res.innerHTML).toEqual(
36
36
  JSON.stringify({
37
37
  from: "2022-08-03T00:00:00.000Z",
@@ -40,16 +40,16 @@ describe("Writing in input sets correct values", () => {
40
40
  );
41
41
  });
42
42
 
43
- it("useRangeDatepicker before after to ", async () => {
44
- const utils = render(<RangeDemo />);
43
+ it("useRangeDatepicker before after to", async () => {
44
+ render(<RangeDemo />);
45
45
 
46
- const fraInput = utils.getByRole("textbox", { name: "Fra" });
47
- const tilInput = utils.getByRole("textbox", { name: "Til" });
46
+ const fraInput = screen.getByRole("textbox", { name: "Fra" });
47
+ const tilInput = screen.getByRole("textbox", { name: "Til" });
48
48
  await act(async () => {
49
49
  await userEvent.type(fraInput, "03.08.2022");
50
50
  await userEvent.type(tilInput, "02.08.2022");
51
51
  });
52
- const res = utils.getByTitle("res");
52
+ const res = screen.getByTitle("res");
53
53
  expect(res.innerHTML).toEqual(
54
54
  JSON.stringify({
55
55
  from: "2022-08-03T00:00:00.000Z",
@@ -325,7 +325,7 @@ export const useRangeDatepicker = (
325
325
  return;
326
326
  }
327
327
  !open && openOnFocus && setOpen(true);
328
- let day = parseDate(
328
+ const day = parseDate(
329
329
  e.target.value,
330
330
  today,
331
331
  locale,
@@ -349,7 +349,7 @@ export const useRangeDatepicker = (
349
349
  };
350
350
 
351
351
  const handleBlur = (e, src: RangeT) => {
352
- let day = parseDate(
352
+ const day = parseDate(
353
353
  e.target.value,
354
354
  today,
355
355
  locale,
@@ -379,7 +379,7 @@ export const useRangeDatepicker = (
379
379
  if (range?.from && range?.to) {
380
380
  setOpen(false);
381
381
  }
382
- let prevToRange =
382
+ const prevToRange =
383
383
  !selectedRange?.from && selectedRange?.to ? selectedRange?.to : range?.to;
384
384
 
385
385
  const resetTo = isBefore(prevToRange, range?.from);
@@ -13,9 +13,9 @@ interface MonthType {
13
13
  month: Date;
14
14
  months: Date[];
15
15
  focus: Date | undefined;
16
- setFocus: Function;
16
+ setFocus: (date?: Date) => void;
17
17
  tabRoot?: Date;
18
- setTabRoot: Function;
18
+ setTabRoot: (date?: Date) => void;
19
19
  }
20
20
 
21
21
  const disableMonth = (month: Date, fromDate?: Date, toDate?: Date) => {
@@ -70,7 +70,7 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
70
70
  /**
71
71
  * Callback for user-controlled state
72
72
  */
73
- onMonthSelect?: Function;
73
+ onMonthSelect?: (month?: Date) => void;
74
74
  /**
75
75
  * Used to set visible year programmatically. Component controlled by default
76
76
  */
@@ -62,9 +62,9 @@ export const MonthSelector = () => {
62
62
  return (
63
63
  <BodyShort as="table" className="rdp-table">
64
64
  <tbody className="rdp-tbody">
65
- {tableMonths.map((x, y) => (
66
- <tr className="rdp-row" key={y}>
67
- {x.map((month: Date, y) => {
65
+ {tableMonths.map((months, i) => (
66
+ <tr className="rdp-row" key={i}>
67
+ {months.map((month: Date) => {
68
68
  return (
69
69
  <td key={month.toDateString()} className="rdp-cell">
70
70
  <MonthButton
@@ -42,7 +42,7 @@ Default.argTypes = {
42
42
  },
43
43
  };
44
44
 
45
- export const dropdownCaption = () => {
45
+ export const DropdownCaption = () => {
46
46
  return (
47
47
  <MonthPicker.Standalone
48
48
  dropdownCaption
@@ -22,18 +22,6 @@ describe("Returns initial year for monthpicker", () => {
22
22
  )
23
23
  ).toBeFalsy();
24
24
  });
25
- test("Default selected should not be valid (false)", () => {
26
- expect(
27
- isSameYear(
28
- new Date("Oct 4 2021"),
29
- getInitialYear({
30
- defaultMonth: new Date("Aug 4 2020"),
31
- /* toDate: new Date("Oct 4 2021"), */
32
- /* fromDate: new Date("Oct 4 2021"), */
33
- })
34
- )
35
- ).toBeFalsy();
36
- });
37
25
  test("Default selected should be valid with fromDate", () => {
38
26
  expect(
39
27
  isSameYear(
@@ -13,13 +13,13 @@ describe("Returns if date is disabled", () => {
13
13
  test("Date should be disabled type Date[] (true)", () => {
14
14
  expect(isMatch(new Date("Dec 4 2011"), disabled)).toBeTruthy();
15
15
  });
16
- test("Date should be disabled type Range (true)", () => {
16
+ test("Date should be disabled type Range (false)", () => {
17
17
  expect(isMatch(new Date("Sep 5 2023"), disabled)).toBeTruthy();
18
18
  });
19
19
  test("Date should be disabled type Range (true)", () => {
20
20
  expect(isMatch(new Date("Sep 3 2023"), disabled)).toBeTruthy();
21
21
  });
22
- test("Date should be disabled type After (true)", () => {
22
+ test("Date should be disabled type After (same month)(true)", () => {
23
23
  expect(
24
24
  isMatch(new Date("Aug 5 2018"), [{ after: new Date("Aug 2 2018") }])
25
25
  ).toBeTruthy();
@@ -34,7 +34,7 @@ describe("Returns if date is disabled", () => {
34
34
  isMatch(new Date("Aug 1 2018"), [{ before: new Date("Aug 2 2018") }])
35
35
  ).toBeTruthy();
36
36
  });
37
- test("Date should be disabled type Before (true)", () => {
37
+ test("Date should be disabled type Before (false)", () => {
38
38
  expect(
39
39
  isMatch(new Date("Jul 1 2018"), [{ before: new Date("Aug 2 2018") }])
40
40
  ).toBeTruthy();
@@ -1,12 +1,14 @@
1
- import { parseDate } from "..";
2
- import { isValidDate } from "..";
1
+ /* eslint-disable jest/expect-expect */
2
+ import { parseDate, isValidDate } from "..";
3
3
  import nb from "date-fns/locale/nb";
4
4
  import getMonth from "date-fns/getMonth";
5
5
 
6
6
  const check = (inp: string) =>
7
+ // eslint-disable-next-line jest/valid-expect
7
8
  expect(isValidDate(parseDate(inp, new Date(), nb, "date", false)));
8
9
 
9
10
  const checkTwoDigit = (inp: string) =>
11
+ // eslint-disable-next-line jest/valid-expect
10
12
  expect(isValidDate(parseDate(inp, new Date(), nb, "date", true)));
11
13
 
12
14
  const parse = (inp: string) => parseDate(inp, new Date(), nb, "date", false);
@@ -6,7 +6,7 @@ export const nextEnabled = (
6
6
  key: string,
7
7
  disabled: Matcher[],
8
8
  currentMonth: Date,
9
- setYearState: Function,
9
+ setYearState: (date: Date) => void,
10
10
  yearState: Date,
11
11
  dropdownCaption: boolean,
12
12
  fromDate?: Date,
@@ -148,7 +148,7 @@ const loopBack = (
148
148
  months: Date[],
149
149
  disabled: Matcher[],
150
150
  yearState: Date,
151
- setYearState: Function,
151
+ setYearState: (date: Date) => void,
152
152
  rowCheck: boolean,
153
153
  dropdownCaption: boolean,
154
154
  fromDate?: Date,
@@ -191,7 +191,7 @@ const loopForward = (
191
191
  currentIndex: number,
192
192
  months: Date[],
193
193
  yearState: Date,
194
- setYearState: Function,
194
+ setYearState: (date: Date) => void,
195
195
  disabled: Matcher[],
196
196
  rowCheck: boolean,
197
197
  dropdownCaption: boolean,
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, useContext } from "react";
2
2
  import cl from "clsx";
3
- import { DropdownContext } from ".";
3
+ import { DropdownContext } from "./Dropdown";
4
4
 
5
5
  export interface ToggleProps
6
6
  extends React.ButtonHTMLAttributes<HTMLButtonElement> {
@@ -60,32 +60,29 @@ export const DefaultOpen = {
60
60
  args: { chromatic: { delay: 300 } },
61
61
  };
62
62
 
63
- export const ControlledOpen = {
64
- render: () => {
65
- // eslint-disable-next-line react-hooks/rules-of-hooks
66
- const [openState, setOpenState] = useState(true);
67
- return (
68
- <Dropdown onSelect={(event) => console.log(event)} open={openState}>
69
- <Button as={Dropdown.Toggle} onClick={() => setOpenState(!openState)}>
70
- Toggle
71
- </Button>
72
- <Dropdown.Menu
73
- strategy="fixed"
74
- onClose={() => console.log("ONCLOSE CONTROLLED")}
75
- >
76
- <Dropdown.Menu.GroupedList>
77
- <Dropdown.Menu.GroupedList.Heading>
78
- Systemer og oppslagsverk
79
- </Dropdown.Menu.GroupedList.Heading>
80
- <Dropdown.Menu.GroupedList.Item
81
- onClick={() => console.log("GroupedList.Item-click")}
82
- >
83
- Gosys
84
- </Dropdown.Menu.GroupedList.Item>
85
- </Dropdown.Menu.GroupedList>
86
- </Dropdown.Menu>
87
- </Dropdown>
88
- );
89
- },
90
- args: { chromatic: { delay: 300 } },
63
+ export const ControlledOpen = () => {
64
+ const [openState, setOpenState] = useState(true);
65
+ return (
66
+ <Dropdown onSelect={(event) => console.log(event)} open={openState}>
67
+ <Button as={Dropdown.Toggle} onClick={() => setOpenState(!openState)}>
68
+ Toggle
69
+ </Button>
70
+ <Dropdown.Menu
71
+ strategy="fixed"
72
+ onClose={() => console.log("ONCLOSE CONTROLLED")}
73
+ >
74
+ <Dropdown.Menu.GroupedList>
75
+ <Dropdown.Menu.GroupedList.Heading>
76
+ Systemer og oppslagsverk
77
+ </Dropdown.Menu.GroupedList.Heading>
78
+ <Dropdown.Menu.GroupedList.Item
79
+ onClick={() => console.log("GroupedList.Item-click")}
80
+ >
81
+ Gosys
82
+ </Dropdown.Menu.GroupedList.Item>
83
+ </Dropdown.Menu.GroupedList>
84
+ </Dropdown.Menu>
85
+ </Dropdown>
86
+ );
91
87
  };
88
+ ControlledOpen.args = { chromatic: { delay: 300 } };
@@ -1,2 +1 @@
1
- export { default as Dropdown } from "./Dropdown";
2
- export * from "./Dropdown";
1
+ export { default as Dropdown, type DropdownProps } from "./Dropdown";