@navikt/ds-react 5.5.0 → 5.6.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 (342) hide show
  1. package/_docs.json +507 -106
  2. package/cjs/accordion/Accordion.js +1 -0
  3. package/cjs/accordion/AccordionContext.js +1 -1
  4. package/cjs/accordion/AccordionHeader.js +2 -2
  5. package/cjs/accordion/AccordionItem.js +6 -2
  6. package/cjs/date/datepicker/DatePicker.js +30 -34
  7. package/cjs/date/datepicker/DatePickerStandalone.js +23 -26
  8. package/cjs/date/datepicker/parts/Caption.js +28 -0
  9. package/cjs/date/datepicker/{DayButton.js → parts/DayButton.js} +1 -2
  10. package/cjs/date/datepicker/{caption → parts}/DropdownCaption.js +13 -7
  11. package/cjs/date/datepicker/parts/HeadRow.js +36 -0
  12. package/cjs/date/datepicker/parts/Row.js +23 -0
  13. package/cjs/date/datepicker/{TableHead.js → parts/TableHead.js} +4 -3
  14. package/cjs/date/datepicker/parts/WeekNumber.js +35 -0
  15. package/cjs/date/datepicker/parts/WeekRow.js +34 -0
  16. package/cjs/date/hooks/useDatepicker.js +2 -2
  17. package/cjs/date/hooks/useMonthPicker.js +2 -2
  18. package/cjs/date/hooks/useRangeDatepicker.js +3 -3
  19. package/cjs/date/monthpicker/MonthSelector.js +1 -1
  20. package/cjs/date/utils/get-month-weeks.js +46 -0
  21. package/cjs/date/utils/labels.js +40 -1
  22. package/cjs/dropdown/Toggle.js +2 -2
  23. package/cjs/dropdown/index.js +0 -15
  24. package/cjs/form/Select.js +1 -1
  25. package/cjs/form/checkbox/useCheckbox.js +3 -4
  26. package/cjs/form/combobox/Combobox.js +1 -1
  27. package/cjs/form/combobox/Input/Input.js +1 -1
  28. package/cjs/form/search/Search.js +3 -1
  29. package/cjs/index.js +1 -0
  30. package/cjs/layout/bleed/Bleed.js +69 -0
  31. package/cjs/layout/bleed/index.js +5 -0
  32. package/cjs/layout/bleed/package.json +6 -0
  33. package/cjs/layout/box/Box.js +1 -1
  34. package/cjs/layout/responsive/Responsive.js +8 -6
  35. package/cjs/layout/sidemal-test/AvatarPanel.js +18 -0
  36. package/cjs/layout/sidemal-test/Content.js +66 -0
  37. package/cjs/layout/sidemal-test/Filter.js +48 -0
  38. package/cjs/layout/sidemal-test/Header.js +48 -0
  39. package/cjs/layout/sidemal-test/Intro.js +36 -0
  40. package/cjs/layout/sidemal-test/Sidebar.js +49 -0
  41. package/cjs/layout/sidemal-test/content-box/ContentBox.js +65 -0
  42. package/cjs/layout/sidemal-test/content-box/index.js +8 -0
  43. package/cjs/layout/sidemal-test/content-box/package.json +6 -0
  44. package/cjs/layout/stack/Stack.js +2 -2
  45. package/cjs/layout/stack/index.js +3 -1
  46. package/cjs/layout/utilities/css.js +37 -14
  47. package/cjs/loader/Loader.js +2 -2
  48. package/cjs/modal/dialog-polyfill.js +2 -0
  49. package/cjs/popover/Popover.js +3 -2
  50. package/cjs/tabs/TabList.js +6 -7
  51. package/cjs/timeline/Pin.js +20 -20
  52. package/cjs/timeline/Timeline.js +4 -4
  53. package/cjs/timeline/period/ClickablePeriod.js +19 -19
  54. package/cjs/timeline/period/index.js +1 -1
  55. package/cjs/timeline/utils/timeline.js +3 -3
  56. package/cjs/toggle-group/ToggleGroup.js +1 -1
  57. package/cjs/tooltip/Tooltip.js +1 -1
  58. package/cjs/typography/Heading.js +1 -1
  59. package/cjs/util/RandomIcon.js +1 -0
  60. package/cjs/util/Slot.js +88 -0
  61. package/cjs/util/useId.js +2 -4
  62. package/esm/accordion/Accordion.js +1 -0
  63. package/esm/accordion/Accordion.js.map +1 -1
  64. package/esm/accordion/AccordionContext.d.ts +1 -0
  65. package/esm/accordion/AccordionContext.js +1 -1
  66. package/esm/accordion/AccordionContext.js.map +1 -1
  67. package/esm/accordion/AccordionHeader.js +2 -2
  68. package/esm/accordion/AccordionHeader.js.map +1 -1
  69. package/esm/accordion/AccordionItem.js +6 -2
  70. package/esm/accordion/AccordionItem.js.map +1 -1
  71. package/esm/date/datepicker/DatePicker.d.ts +14 -5
  72. package/esm/date/datepicker/DatePicker.js +29 -33
  73. package/esm/date/datepicker/DatePicker.js.map +1 -1
  74. package/esm/date/datepicker/DatePickerStandalone.d.ts +3 -2
  75. package/esm/date/datepicker/DatePickerStandalone.js +22 -25
  76. package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
  77. package/esm/date/datepicker/{caption → parts}/Caption.d.ts +3 -0
  78. package/esm/date/datepicker/parts/Caption.js +22 -0
  79. package/esm/date/datepicker/parts/Caption.js.map +1 -0
  80. package/esm/date/datepicker/parts/DayButton.d.ts +4 -0
  81. package/esm/date/datepicker/{DayButton.js → parts/DayButton.js} +2 -1
  82. package/esm/date/datepicker/parts/DayButton.js.map +1 -0
  83. package/esm/date/datepicker/{caption → parts}/DropdownCaption.d.ts +3 -0
  84. package/esm/date/datepicker/parts/DropdownCaption.js +44 -0
  85. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -0
  86. package/esm/date/datepicker/parts/HeadRow.d.ts +11 -0
  87. package/esm/date/datepicker/parts/HeadRow.js +29 -0
  88. package/esm/date/datepicker/parts/HeadRow.js.map +1 -0
  89. package/esm/date/datepicker/parts/Row.d.ts +17 -0
  90. package/esm/date/datepicker/parts/Row.js +19 -0
  91. package/esm/date/datepicker/parts/Row.js.map +1 -0
  92. package/esm/date/datepicker/parts/TableHead.d.ts +6 -0
  93. package/esm/date/datepicker/{TableHead.js → parts/TableHead.js} +5 -2
  94. package/esm/date/datepicker/parts/TableHead.js.map +1 -0
  95. package/esm/date/datepicker/parts/WeekNumber.d.ts +13 -0
  96. package/esm/date/datepicker/parts/WeekNumber.js +31 -0
  97. package/esm/date/datepicker/parts/WeekNumber.js.map +1 -0
  98. package/esm/date/datepicker/parts/WeekRow.d.ts +5 -0
  99. package/esm/date/datepicker/parts/WeekRow.js +30 -0
  100. package/esm/date/datepicker/parts/WeekRow.js.map +1 -0
  101. package/esm/date/hooks/useDatepicker.js +2 -2
  102. package/esm/date/hooks/useDatepicker.js.map +1 -1
  103. package/esm/date/hooks/useMonthPicker.js +2 -2
  104. package/esm/date/hooks/useMonthPicker.js.map +1 -1
  105. package/esm/date/hooks/useRangeDatepicker.js +3 -3
  106. package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
  107. package/esm/date/monthpicker/MonthButton.d.ts +2 -2
  108. package/esm/date/monthpicker/MonthPicker.d.ts +1 -1
  109. package/esm/date/monthpicker/MonthSelector.js +1 -1
  110. package/esm/date/monthpicker/MonthSelector.js.map +1 -1
  111. package/esm/date/utils/get-month-weeks.d.ts +16 -0
  112. package/esm/date/utils/get-month-weeks.js +42 -0
  113. package/esm/date/utils/get-month-weeks.js.map +1 -0
  114. package/esm/date/utils/labels.d.ts +9 -0
  115. package/esm/date/utils/labels.js +36 -0
  116. package/esm/date/utils/labels.js.map +1 -1
  117. package/esm/date/utils/navigation.d.ts +1 -1
  118. package/esm/date/utils/navigation.js.map +1 -1
  119. package/esm/dropdown/Toggle.js +1 -1
  120. package/esm/dropdown/Toggle.js.map +1 -1
  121. package/esm/dropdown/index.d.ts +1 -2
  122. package/esm/dropdown/index.js +0 -1
  123. package/esm/dropdown/index.js.map +1 -1
  124. package/esm/form/Select.js +1 -1
  125. package/esm/form/Select.js.map +1 -1
  126. package/esm/form/checkbox/useCheckbox.d.ts +1 -1
  127. package/esm/form/checkbox/useCheckbox.js +3 -4
  128. package/esm/form/checkbox/useCheckbox.js.map +1 -1
  129. package/esm/form/combobox/Combobox.d.ts +1 -1
  130. package/esm/form/combobox/Combobox.js +1 -1
  131. package/esm/form/combobox/Combobox.js.map +1 -1
  132. package/esm/form/combobox/Input/Input.d.ts +0 -2
  133. package/esm/form/combobox/Input/Input.js +1 -1
  134. package/esm/form/combobox/Input/Input.js.map +1 -1
  135. package/esm/form/search/Search.js +3 -1
  136. package/esm/form/search/Search.js.map +1 -1
  137. package/esm/index.d.ts +1 -0
  138. package/esm/index.js +1 -0
  139. package/esm/index.js.map +1 -1
  140. package/esm/layout/bleed/Bleed.d.ts +47 -0
  141. package/esm/layout/bleed/Bleed.js +41 -0
  142. package/esm/layout/bleed/Bleed.js.map +1 -0
  143. package/esm/layout/bleed/index.d.ts +1 -0
  144. package/esm/layout/bleed/index.js +2 -0
  145. package/esm/layout/bleed/index.js.map +1 -0
  146. package/esm/layout/box/Box.d.ts +1 -2
  147. package/esm/layout/box/Box.js +1 -1
  148. package/esm/layout/box/Box.js.map +1 -1
  149. package/esm/layout/responsive/Responsive.d.ts +8 -4
  150. package/esm/layout/responsive/Responsive.js +8 -6
  151. package/esm/layout/responsive/Responsive.js.map +1 -1
  152. package/esm/layout/sidemal-test/AvatarPanel.d.ts +4 -0
  153. package/esm/layout/sidemal-test/AvatarPanel.js +12 -0
  154. package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -0
  155. package/esm/layout/sidemal-test/Content.d.ts +2 -0
  156. package/esm/layout/sidemal-test/Content.js +60 -0
  157. package/esm/layout/sidemal-test/Content.js.map +1 -0
  158. package/esm/layout/sidemal-test/Filter.d.ts +2 -0
  159. package/esm/layout/sidemal-test/Filter.js +22 -0
  160. package/esm/layout/sidemal-test/Filter.js.map +1 -0
  161. package/esm/layout/sidemal-test/Header.d.ts +2 -0
  162. package/esm/layout/sidemal-test/Header.js +42 -0
  163. package/esm/layout/sidemal-test/Header.js.map +1 -0
  164. package/esm/layout/sidemal-test/Intro.d.ts +2 -0
  165. package/esm/layout/sidemal-test/Intro.js +30 -0
  166. package/esm/layout/sidemal-test/Intro.js.map +1 -0
  167. package/esm/layout/sidemal-test/Sidebar.d.ts +4 -0
  168. package/esm/layout/sidemal-test/Sidebar.js +41 -0
  169. package/esm/layout/sidemal-test/Sidebar.js.map +1 -0
  170. package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +8 -0
  171. package/esm/layout/sidemal-test/content-box/ContentBox.js +37 -0
  172. package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -0
  173. package/esm/layout/sidemal-test/content-box/index.d.ts +1 -0
  174. package/esm/layout/sidemal-test/content-box/index.js +2 -0
  175. package/esm/layout/sidemal-test/content-box/index.js.map +1 -0
  176. package/esm/layout/stack/Stack.d.ts +7 -3
  177. package/esm/layout/stack/Stack.js +3 -3
  178. package/esm/layout/stack/Stack.js.map +1 -1
  179. package/esm/layout/stack/index.d.ts +1 -0
  180. package/esm/layout/stack/index.js +1 -0
  181. package/esm/layout/stack/index.js.map +1 -1
  182. package/esm/layout/utilities/css.d.ts +1 -1
  183. package/esm/layout/utilities/css.js +37 -14
  184. package/esm/layout/utilities/css.js.map +1 -1
  185. package/esm/loader/Loader.js +3 -3
  186. package/esm/loader/Loader.js.map +1 -1
  187. package/esm/modal/dialog-polyfill.js +2 -0
  188. package/esm/modal/dialog-polyfill.js.map +1 -1
  189. package/esm/popover/Popover.js +3 -2
  190. package/esm/popover/Popover.js.map +1 -1
  191. package/esm/tabs/TabList.js +6 -7
  192. package/esm/tabs/TabList.js.map +1 -1
  193. package/esm/timeline/Pin.js +21 -21
  194. package/esm/timeline/Pin.js.map +1 -1
  195. package/esm/timeline/Timeline.js +4 -4
  196. package/esm/timeline/Timeline.js.map +1 -1
  197. package/esm/timeline/TimelineRow.js.map +1 -1
  198. package/esm/timeline/hooks/usePeriodContext.d.ts +1 -1
  199. package/esm/timeline/period/ClickablePeriod.js +20 -20
  200. package/esm/timeline/period/ClickablePeriod.js.map +1 -1
  201. package/esm/timeline/period/index.d.ts +2 -2
  202. package/esm/timeline/period/index.js +1 -1
  203. package/esm/timeline/period/index.js.map +1 -1
  204. package/esm/timeline/utils/timeline.js +3 -3
  205. package/esm/timeline/utils/timeline.js.map +1 -1
  206. package/esm/toggle-group/ToggleGroup.js +1 -1
  207. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  208. package/esm/tooltip/Tooltip.js +1 -1
  209. package/esm/tooltip/Tooltip.js.map +1 -1
  210. package/esm/typography/Heading.js +1 -1
  211. package/esm/typography/Heading.js.map +1 -1
  212. package/esm/util/RandomIcon.js +1 -0
  213. package/esm/util/RandomIcon.js.map +1 -1
  214. package/esm/util/Slot.d.ts +6 -0
  215. package/esm/util/Slot.js +60 -0
  216. package/esm/util/Slot.js.map +1 -0
  217. package/esm/util/mergeRefs.d.ts +1 -1
  218. package/esm/util/useId.js +2 -4
  219. package/esm/util/useId.js.map +1 -1
  220. package/package.json +4 -4
  221. package/src/accordion/Accordion.tsx +1 -0
  222. package/src/accordion/AccordionContext.tsx +2 -1
  223. package/src/accordion/AccordionHeader.tsx +2 -2
  224. package/src/accordion/AccordionItem.tsx +7 -5
  225. package/src/accordion/accordion.stories.tsx +21 -34
  226. package/src/alert/alert.stories.tsx +2 -2
  227. package/src/chips/chips.stories.tsx +29 -32
  228. package/src/date/datepicker/DatePicker.tsx +63 -58
  229. package/src/date/datepicker/DatePickerStandalone.tsx +36 -39
  230. package/src/date/datepicker/datepicker.stories.tsx +67 -2
  231. package/src/date/datepicker/datepicker.test.tsx +5 -4
  232. package/src/date/datepicker/{caption → parts}/Caption.tsx +19 -17
  233. package/src/date/datepicker/{DayButton.tsx → parts/DayButton.tsx} +3 -1
  234. package/src/date/datepicker/parts/DropdownCaption.tsx +113 -0
  235. package/src/date/datepicker/parts/HeadRow.tsx +56 -0
  236. package/src/date/datepicker/parts/Row.tsx +47 -0
  237. package/src/date/datepicker/{TableHead.tsx → parts/TableHead.tsx} +6 -2
  238. package/src/date/datepicker/parts/WeekNumber.tsx +79 -0
  239. package/src/date/datepicker/parts/WeekRow.tsx +60 -0
  240. package/src/date/hooks/useDatepicker.tsx +2 -2
  241. package/src/date/hooks/useMonthPicker.tsx +2 -2
  242. package/src/date/hooks/useRangeDatepicker.test.tsx +11 -11
  243. package/src/date/hooks/useRangeDatepicker.tsx +3 -3
  244. package/src/date/monthpicker/MonthButton.tsx +2 -2
  245. package/src/date/monthpicker/MonthPicker.tsx +1 -1
  246. package/src/date/monthpicker/MonthSelector.tsx +3 -3
  247. package/src/date/monthpicker/monthpicker.stories.tsx +1 -1
  248. package/src/date/utils/__tests__/get-initial-year.test.ts +0 -12
  249. package/src/date/utils/__tests__/get-month-weeks.test.ts +113 -0
  250. package/src/date/utils/__tests__/is-match.test.ts +3 -3
  251. package/src/date/utils/__tests__/parse-dates.test.ts +4 -2
  252. package/src/date/utils/get-month-weeks.ts +93 -0
  253. package/src/date/utils/labels.ts +51 -0
  254. package/src/date/utils/navigation.ts +3 -3
  255. package/src/dropdown/Toggle.tsx +1 -1
  256. package/src/dropdown/dropdown.stories.tsx +25 -28
  257. package/src/dropdown/index.ts +1 -2
  258. package/src/expansion-card/expansion-card.stories.tsx +143 -161
  259. package/src/form/ConfirmationPanel.test.tsx +5 -5
  260. package/src/form/Select.tsx +1 -1
  261. package/src/form/checkbox/Checkbox.test.tsx +14 -26
  262. package/src/form/checkbox/checkbox.stories.tsx +66 -71
  263. package/src/form/checkbox/useCheckbox.ts +3 -4
  264. package/src/form/combobox/Combobox.tsx +2 -3
  265. package/src/form/combobox/Input/Input.tsx +1 -3
  266. package/src/form/combobox/combobox.stories.tsx +20 -23
  267. package/src/form/combobox/combobox.test.tsx +22 -20
  268. package/src/form/radio/radio.stories.tsx +39 -44
  269. package/src/form/search/Search.tsx +1 -0
  270. package/src/form/search/search.stories.tsx +22 -26
  271. package/src/form/stories/fieldset.stories.tsx +1 -1
  272. package/src/index.ts +1 -0
  273. package/src/layout/bleed/Bleed.stories.tsx +381 -0
  274. package/src/layout/bleed/Bleed.tsx +130 -0
  275. package/src/layout/bleed/index.ts +1 -0
  276. package/src/layout/box/Box.stories.tsx +251 -256
  277. package/src/layout/box/Box.tsx +2 -1
  278. package/src/layout/responsive/Responsive.tsx +21 -6
  279. package/src/layout/responsive/hide.stories.tsx +35 -0
  280. package/src/layout/responsive/show.stories.tsx +35 -0
  281. package/src/layout/sidemal-test/AvatarPanel.tsx +27 -0
  282. package/src/layout/sidemal-test/Content.tsx +129 -0
  283. package/src/layout/sidemal-test/Filter.tsx +46 -0
  284. package/src/layout/sidemal-test/Header.tsx +96 -0
  285. package/src/layout/sidemal-test/Intro.tsx +91 -0
  286. package/src/layout/sidemal-test/Sidebar.tsx +77 -0
  287. package/src/layout/sidemal-test/content-box/ContentBox.tsx +46 -0
  288. package/src/layout/sidemal-test/content-box/index.ts +1 -0
  289. package/src/layout/sidemal-test/navno-sidemal.stories.mdx +29 -0
  290. package/src/layout/sidemal-test/navno-sidemal.stories.tsx +65 -0
  291. package/src/layout/sidemal-test/styling.css +43 -0
  292. package/src/layout/stack/Stack.tsx +14 -8
  293. package/src/layout/stack/index.ts +1 -0
  294. package/src/layout/stack/stack.stories.tsx +23 -1
  295. package/src/layout/utilities/css.ts +59 -20
  296. package/src/loader/Loader.tsx +2 -3
  297. package/src/modal/dialog-polyfill.ts +2 -0
  298. package/src/pagination/pagination.stories.tsx +35 -42
  299. package/src/popover/Popover.test.tsx +21 -35
  300. package/src/popover/Popover.tsx +2 -2
  301. package/src/popover/popover.stories.tsx +25 -41
  302. package/src/react-css.d.ts +0 -1
  303. package/src/read-more/readmore.stories.tsx +35 -36
  304. package/src/stepper/stepper.stories.tsx +45 -52
  305. package/src/table/stories/table-expandable.stories.tsx +59 -63
  306. package/src/tabs/TabList.tsx +4 -6
  307. package/src/tabs/Tabs.stories.tsx +3 -3
  308. package/src/tag/tag.stories.tsx +4 -4
  309. package/src/timeline/Pin.tsx +44 -39
  310. package/src/timeline/Timeline.tsx +6 -6
  311. package/src/timeline/TimelineRow.tsx +1 -0
  312. package/src/timeline/hooks/usePeriodContext.tsx +1 -1
  313. package/src/timeline/period/ClickablePeriod.tsx +42 -38
  314. package/src/timeline/period/index.tsx +5 -4
  315. package/src/timeline/timeline.stories.tsx +11 -10
  316. package/src/timeline/utils/timeline.ts +3 -3
  317. package/src/toggle-group/ToggleGroup.stories.tsx +25 -29
  318. package/src/toggle-group/ToggleGroup.tsx +0 -1
  319. package/src/tooltip/Tooltip.test.tsx +40 -54
  320. package/src/tooltip/Tooltip.tsx +1 -1
  321. package/src/typography/Heading.tsx +1 -1
  322. package/src/util/RandomIcon.tsx +1 -0
  323. package/src/util/Slot.tsx +69 -0
  324. package/src/util/__tests__/Slot.test.tsx +98 -0
  325. package/src/util/mergeRefs.tsx +1 -1
  326. package/src/util/useId.ts +1 -3
  327. package/cjs/date/datepicker/caption/Caption.js +0 -23
  328. package/cjs/date/datepicker/caption/index.js +0 -10
  329. package/cjs/date/datepicker/caption/package.json +0 -6
  330. package/esm/date/datepicker/DayButton.d.ts +0 -3
  331. package/esm/date/datepicker/DayButton.js.map +0 -1
  332. package/esm/date/datepicker/TableHead.d.ts +0 -3
  333. package/esm/date/datepicker/TableHead.js.map +0 -1
  334. package/esm/date/datepicker/caption/Caption.js +0 -17
  335. package/esm/date/datepicker/caption/Caption.js.map +0 -1
  336. package/esm/date/datepicker/caption/DropdownCaption.js +0 -38
  337. package/esm/date/datepicker/caption/DropdownCaption.js.map +0 -1
  338. package/esm/date/datepicker/caption/index.d.ts +0 -2
  339. package/esm/date/datepicker/caption/index.js +0 -3
  340. package/esm/date/datepicker/caption/index.js.map +0 -1
  341. package/src/date/datepicker/caption/DropdownCaption.tsx +0 -108
  342. package/src/date/datepicker/caption/index.ts +0 -2
@@ -1,4 +1,5 @@
1
1
  import {
2
+ FloatingFocusManager,
2
3
  autoUpdate,
3
4
  arrow as flArrow,
4
5
  flip,
@@ -10,6 +11,7 @@ import {
10
11
  useFocus,
11
12
  useHover,
12
13
  useInteractions,
14
+ useRole,
13
15
  } from "@floating-ui/react";
14
16
  import { format } from "date-fns";
15
17
  import React, { forwardRef, useMemo, useRef, useState } from "react";
@@ -51,25 +53,32 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
51
53
  floatingStyles,
52
54
  } = useFloating({
53
55
  placement: "top",
54
- open: open,
55
- onOpenChange: setOpen,
56
+ open,
57
+ onOpenChange: (_open) => setOpen(_open),
58
+ whileElementsMounted: autoUpdate,
56
59
  middleware: [
57
60
  offset(16),
58
61
  shift(),
59
62
  flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
60
63
  flArrow({ element: arrowRef, padding: 5 }),
61
64
  ],
62
- whileElementsMounted: autoUpdate,
63
65
  });
64
66
 
67
+ const hover = useHover(context, {
68
+ handleClose: safePolygon(),
69
+ restMs: 25,
70
+ delay: { open: 1000 },
71
+ move: false,
72
+ });
73
+ const focus = useFocus(context);
74
+ const dismiss = useDismiss(context);
75
+ const role = useRole(context, { role: "dialog" });
76
+
65
77
  const { getFloatingProps, getReferenceProps } = useInteractions([
66
- useHover(context, {
67
- handleClose: safePolygon(),
68
- restMs: 25,
69
- delay: { open: 1000 },
70
- }),
71
- useFocus(context),
72
- useDismiss(context),
78
+ hover,
79
+ focus,
80
+ dismiss,
81
+ role,
73
82
  ]);
74
83
 
75
84
  const mergedRef = useMemo(
@@ -109,37 +118,33 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
109
118
  })}
110
119
  />
111
120
  </div>
112
- {children && (
113
- <div
114
- className="navds-timeline__popover"
115
- data-placement={placement}
116
- aria-hidden={!open}
117
- ref={refs.setFloating}
118
- {...getFloatingProps({
119
- tabIndex: -1,
120
- onBlur: (e) =>
121
- e.target.previousSibling !== document.activeElement &&
122
- open &&
123
- setOpen(false),
124
- })}
125
- style={{
126
- ...floatingStyles,
127
- display: open ? undefined : "none",
128
- }}
121
+ {children && open && (
122
+ <FloatingFocusManager
123
+ context={context}
124
+ modal={false}
125
+ initialFocus={-1}
126
+ returnFocus={false}
129
127
  >
130
- <div className="navds-timeline__popover-content">{children}</div>
131
128
  <div
132
- ref={(node) => {
133
- arrowRef.current = node;
134
- }}
135
- style={{
136
- ...(arrowX != null ? { left: arrowX } : {}),
137
- ...(arrowY != null ? { top: arrowY } : {}),
138
- ...(staticSide ? { [staticSide]: "-0.5rem" } : {}),
139
- }}
140
- className="navds-timeline__popover-arrow"
141
- />
142
- </div>
129
+ className="navds-timeline__popover"
130
+ data-placement={placement}
131
+ ref={refs.setFloating}
132
+ {...getFloatingProps()}
133
+ tabIndex={undefined}
134
+ style={floatingStyles}
135
+ >
136
+ {children}
137
+ <div
138
+ ref={arrowRef}
139
+ style={{
140
+ ...(arrowX != null ? { left: arrowX } : {}),
141
+ ...(arrowY != null ? { top: arrowY } : {}),
142
+ ...(staticSide ? { [staticSide]: "-0.5rem" } : {}),
143
+ }}
144
+ className="navds-timeline__popover-arrow"
145
+ />
146
+ </div>
147
+ </FloatingFocusManager>
143
148
  )}
144
149
  </>
145
150
  );
@@ -104,9 +104,9 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
104
104
  (c: any) => c?.type?.componentType === "row"
105
105
  );
106
106
 
107
- const pins = React.Children.toArray(children).filter(
108
- (c: any) => c?.type?.componentType === "pin"
109
- );
107
+ const pins = React.Children.toArray(children)
108
+ .filter((c: any) => c?.type?.componentType === "pin")
109
+ .map((x) => () => x);
110
110
 
111
111
  const zoomComponent = React.Children.toArray(children).find(
112
112
  (c: any) => c?.type?.componentType === "zoom"
@@ -212,9 +212,9 @@ export const Timeline = forwardRef<HTMLDivElement, TimelineProps>(
212
212
  <div className="navds-timeline">
213
213
  <AxisLabels templates={axisLabelTemplates} />
214
214
 
215
- {pins.map((pin) => {
216
- return pin;
217
- })}
215
+ {pins.map((Pin, i) => (
216
+ <Pin key={`pin-${i}`} />
217
+ ))}
218
218
 
219
219
  {processedRows.map((row, i) => {
220
220
  return (
@@ -70,6 +70,7 @@ export const TimelineRow = forwardRef<HTMLOListElement, TimelineRowProps>(
70
70
  "navds-timeline__row--active": active,
71
71
  })}
72
72
  >
73
+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}
73
74
  <ol
74
75
  {...rest}
75
76
  tabIndex={-1}
@@ -1,7 +1,7 @@
1
1
  import { createContext, useContext } from "react";
2
2
 
3
3
  interface PeriodContextProps {
4
- periodId: String;
4
+ periodId: string;
5
5
  firstFocus: boolean;
6
6
  restProps?: any;
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ FloatingFocusManager,
2
3
  autoUpdate,
3
4
  arrow as flArrow,
4
5
  flip,
@@ -10,6 +11,7 @@ import {
10
11
  useFocus,
11
12
  useHover,
12
13
  useInteractions,
14
+ useRole,
13
15
  } from "@floating-ui/react";
14
16
  import cl from "clsx";
15
17
  import React, { useMemo, useRef, useState } from "react";
@@ -60,24 +62,31 @@ const ClickablePeriod = React.memo(
60
62
  } = useFloating({
61
63
  placement: "top",
62
64
  open: open,
63
- onOpenChange: setOpen,
65
+ onOpenChange: (_open) => setOpen(_open),
66
+ whileElementsMounted: autoUpdate,
64
67
  middleware: [
65
68
  offset(16),
66
69
  shift(),
67
70
  flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
68
71
  flArrow({ element: arrowRef, padding: 5 }),
69
72
  ],
70
- whileElementsMounted: autoUpdate,
71
73
  });
72
74
 
75
+ const hover = useHover(context, {
76
+ handleClose: safePolygon(),
77
+ restMs: 25,
78
+ delay: { open: 1000 },
79
+ move: false,
80
+ });
81
+ const focus = useFocus(context);
82
+ const dismiss = useDismiss(context);
83
+ const role = useRole(context, { role: "dialog" });
84
+
73
85
  const { getFloatingProps, getReferenceProps } = useInteractions([
74
- useHover(context, {
75
- handleClose: safePolygon(),
76
- restMs: 25,
77
- delay: { open: 1000 },
78
- }),
79
- useFocus(context),
80
- useDismiss(context),
86
+ hover,
87
+ focus,
88
+ dismiss,
89
+ role,
81
90
  ]);
82
91
 
83
92
  const mergedRef = useMemo(
@@ -141,37 +150,32 @@ const ClickablePeriod = React.memo(
141
150
  >
142
151
  <span className="navds-timeline__period--inner">{icon}</span>
143
152
  </button>
144
- {children && (
145
- <div
146
- className="navds-timeline__popover"
147
- data-placement={placement}
148
- aria-hidden={!open}
149
- ref={refs.setFloating}
150
- {...getFloatingProps({
151
- tabIndex: -1,
152
- onBlur: (e) =>
153
- e.target.previousSibling !== document.activeElement &&
154
- open &&
155
- setOpen(false),
156
- })}
157
- style={{
158
- ...floatingStyles,
159
- display: open ? undefined : "none",
160
- }}
153
+ {children && open && (
154
+ <FloatingFocusManager
155
+ context={context}
156
+ modal={false}
157
+ initialFocus={-1}
158
+ returnFocus={false}
161
159
  >
162
- <div className="navds-timeline__popover-content">{children}</div>
163
160
  <div
164
- ref={(node) => {
165
- arrowRef.current = node;
166
- }}
167
- style={{
168
- ...(arrowX != null ? { left: arrowX } : {}),
169
- ...(arrowY != null ? { top: arrowY } : {}),
170
- ...(staticSide ? { [staticSide]: "-0.5rem" } : {}),
171
- }}
172
- className="navds-timeline__popover-arrow"
173
- />
174
- </div>
161
+ className="navds-timeline__popover"
162
+ data-placement={placement}
163
+ ref={refs.setFloating}
164
+ {...getFloatingProps()}
165
+ style={floatingStyles}
166
+ >
167
+ {children}
168
+ <div
169
+ ref={arrowRef}
170
+ style={{
171
+ ...(arrowX != null ? { left: arrowX } : {}),
172
+ ...(arrowY != null ? { top: arrowY } : {}),
173
+ ...(staticSide ? { [staticSide]: "-0.5rem" } : {}),
174
+ }}
175
+ className="navds-timeline__popover-arrow"
176
+ />
177
+ </div>
178
+ </FloatingFocusManager>
175
179
  )}
176
180
  </>
177
181
  );
@@ -50,8 +50,8 @@ export interface PeriodProps {
50
50
  status: string;
51
51
  cropped: string;
52
52
  direction: string;
53
- width: Number;
54
- left: Number;
53
+ width: number;
54
+ left: number;
55
55
  icon?: React.ReactNode;
56
56
  children?: React.ReactNode;
57
57
  statusLabel?: string;
@@ -102,11 +102,12 @@ export const Period = forwardRef<HTMLDivElement, TimelinePeriodProps>(
102
102
  width={width}
103
103
  left={horizontalPosition}
104
104
  icon={icon}
105
- children={children}
106
105
  isActive={isActive}
107
106
  statusLabel={statusLabel}
108
107
  restProps={restProps}
109
- />
108
+ >
109
+ {children}
110
+ </ClickablePeriod>
110
111
  ) : (
111
112
  <NonClickablePeriod
112
113
  periodRef={ref}
@@ -110,7 +110,7 @@ export const Default = () => {
110
110
  label="Row 1"
111
111
  icon={<CheckmarkCircleFillIcon aria-hidden />}
112
112
  >
113
- {row1.map((p: any, i) => {
113
+ {row1.map((p: any) => {
114
114
  return (
115
115
  <Timeline.Period
116
116
  key={p.id}
@@ -126,7 +126,7 @@ export const Default = () => {
126
126
  label="Row 2"
127
127
  icon={<CheckmarkCircleFillIcon aria-hidden />}
128
128
  >
129
- {row2.map((p: any, i) => {
129
+ {row2.map((p: any) => {
130
130
  return (
131
131
  <Timeline.Period
132
132
  key={p.id}
@@ -154,7 +154,7 @@ export const WithPins = () => {
154
154
  label="Row 1"
155
155
  icon={<CheckmarkCircleFillIcon aria-hidden />}
156
156
  >
157
- {row1.map((p: any, i) => {
157
+ {row1.map((p: any) => {
158
158
  return (
159
159
  <Timeline.Period
160
160
  key={p.id}
@@ -170,7 +170,7 @@ export const WithPins = () => {
170
170
  label="Row 2"
171
171
  icon={<CheckmarkCircleFillIcon aria-hidden />}
172
172
  >
173
- {row2.map((p: any, i) => {
173
+ {row2.map((p: any) => {
174
174
  return (
175
175
  <Timeline.Period
176
176
  key={p.id}
@@ -195,7 +195,7 @@ export const WithZoom = () => {
195
195
  label="Row 1"
196
196
  icon={<CheckmarkCircleFillIcon aria-hidden />}
197
197
  >
198
- {row1.map((p: any, i) => {
198
+ {row1.map((p: any) => {
199
199
  return (
200
200
  <Timeline.Period
201
201
  key={p.id}
@@ -211,7 +211,7 @@ export const WithZoom = () => {
211
211
  label="Row 2"
212
212
  icon={<CheckmarkCircleFillIcon aria-hidden />}
213
213
  >
214
- {row2.map((p: any, i) => {
214
+ {row2.map((p: any) => {
215
215
  return (
216
216
  <Timeline.Period
217
217
  key={p.id}
@@ -246,7 +246,7 @@ export const ActivePeriod = () => {
246
246
  label="Rad 1"
247
247
  icon={<CheckmarkCircleFillIcon aria-hidden />}
248
248
  >
249
- {row1.map((p: any, i) => {
249
+ {row1.map((p: any) => {
250
250
  return (
251
251
  <Timeline.Period
252
252
  key={p.id}
@@ -268,7 +268,7 @@ export const ActivePeriod = () => {
268
268
  })}
269
269
  </Timeline.Row>
270
270
  <Timeline.Row label="Rad 2">
271
- {row2.map((p: any, i) => {
271
+ {row2.map((p: any) => {
272
272
  return (
273
273
  <Timeline.Period
274
274
  key={p.id}
@@ -368,13 +368,14 @@ export const ContentDemo = () => {
368
368
  <Timeline.Pin date={new Date("Apr 15 2022")}>Pin 1</Timeline.Pin>
369
369
  <Timeline.Pin date={new Date("Jun 12 2022")}>
370
370
  Pin 2 <button>test</button>
371
+ <a href="/123">test123123</a>
371
372
  </Timeline.Pin>
372
373
  <Timeline.Pin date={new Date("Jul 28 2022")}>Pin 3</Timeline.Pin>
373
374
  <Timeline.Row
374
375
  label="Rad 1"
375
376
  icon={<CheckmarkCircleFillIcon aria-hidden />}
376
377
  >
377
- {row1.map((p: any, i) => {
378
+ {row1.map((p: any) => {
378
379
  return (
379
380
  <Timeline.Period
380
381
  key={p.id}
@@ -400,7 +401,7 @@ export const ContentDemo = () => {
400
401
  })}
401
402
  </Timeline.Row>
402
403
  <Timeline.Row label="Rad 2">
403
- {row2.map((p: any, i) => {
404
+ {row2.map((p: any) => {
404
405
  return (
405
406
  <Timeline.Period
406
407
  key={p.id}
@@ -12,9 +12,9 @@ type ParsedChild = {
12
12
  };
13
13
 
14
14
  export const parseRows = (rowChildren: ReactNode[]) => {
15
- let parsedChildren: ParsedChild[] = [];
15
+ const parsedChildren: ParsedChild[] = [];
16
16
  rowChildren?.forEach((r: React.ReactNode) => {
17
- let periods: ParsedChild["periods"] = [];
17
+ const periods: ParsedChild["periods"] = [];
18
18
  if (React.isValidElement(r) && r?.props?.children) {
19
19
  if (Array.isArray(r.props.children)) {
20
20
  for (let i = 0; i < r.props.children.length; i++) {
@@ -72,7 +72,7 @@ export const parseRows = (rowChildren: ReactNode[]) => {
72
72
  label: r.props.label,
73
73
  icon: r.props.icon,
74
74
  headingTag: r.props.headingTag,
75
- periods: periods,
75
+ periods,
76
76
  restProps: omit(r.props, ["label", "icon", "headingTag"]),
77
77
  ref: (r as any)?.ref,
78
78
  });
@@ -1,5 +1,3 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
-
3
1
  import {
4
2
  EnvelopeClosedIcon,
5
3
  EnvelopeOpenIcon,
@@ -8,24 +6,24 @@ import {
8
6
  import { Meta } from "@storybook/react";
9
7
  import React, { useState } from "react";
10
8
  import { ToggleGroup } from "../index";
11
- export default {
9
+
10
+ const meta: Meta<typeof ToggleGroup> = {
12
11
  title: "ds-react/ToggleGroup",
13
12
  component: ToggleGroup,
14
13
  argTypes: {
15
14
  size: {
15
+ options: ["medium", "small"],
16
16
  control: {
17
17
  type: "radio",
18
- options: ["medium", "small"],
19
18
  },
20
19
  },
21
20
  variant: {
22
- control: {
23
- type: "radio",
24
- options: ["action", "neutral"],
25
- },
21
+ options: ["action", "neutral"],
22
+ control: { type: "radio" },
26
23
  },
27
24
  },
28
- } as Meta;
25
+ };
26
+ export default meta;
29
27
 
30
28
  const Items = (icon?: boolean, both?: boolean) => (
31
29
  <>
@@ -59,26 +57,24 @@ const Items = (icon?: boolean, both?: boolean) => (
59
57
  </>
60
58
  );
61
59
 
62
- export const Default = {
63
- render: (props) => {
64
- const [activeValue, setActiveValue] = useState("ulest");
65
- return (
66
- <ToggleGroup
67
- size={props?.size}
68
- value={activeValue}
69
- onChange={setActiveValue}
70
- label={props.label ? "Proident minim dolor pariatur." : undefined}
71
- >
72
- {Items(!!props?.icon, !!props?.text && props.icon)}
73
- </ToggleGroup>
74
- );
75
- },
76
-
77
- args: {
78
- icon: true,
79
- text: true,
80
- label: false,
81
- },
60
+ export const Default = (props) => {
61
+ const [activeValue, setActiveValue] = useState("ulest");
62
+ return (
63
+ <ToggleGroup
64
+ size={props.size}
65
+ variant={props.variant}
66
+ value={activeValue}
67
+ onChange={setActiveValue}
68
+ label={props.label ? "Proident minim dolor pariatur." : undefined}
69
+ >
70
+ {Items(props.icon, props.text && props.icon)}
71
+ </ToggleGroup>
72
+ );
73
+ };
74
+ Default.args = {
75
+ icon: true,
76
+ text: true,
77
+ label: false,
82
78
  };
83
79
 
84
80
  export const Compositions = () => {
@@ -88,7 +88,6 @@ export const ToggleGroup = forwardRef<HTMLDivElement, ToggleGroupProps>(
88
88
  label,
89
89
  value,
90
90
  defaultValue,
91
- id,
92
91
  "aria-describedby": desc,
93
92
  variant = "action",
94
93
  ...rest