@navikt/ds-react 5.6.4 → 5.7.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 (473) hide show
  1. package/_docs.json +297 -257
  2. package/cjs/accordion/AccordionContent.js +2 -2
  3. package/cjs/accordion/AccordionHeader.js +2 -2
  4. package/cjs/alert/Alert.js +2 -2
  5. package/cjs/button/Button.js +6 -5
  6. package/cjs/copybutton/CopyButton.js +8 -7
  7. package/cjs/date/DateInput.js +6 -5
  8. package/cjs/date/datepicker/DatePicker.js +6 -5
  9. package/cjs/date/datepicker/DatePickerStandalone.js +6 -6
  10. package/cjs/date/datepicker/parts/Caption.js +5 -4
  11. package/cjs/date/datepicker/parts/DropdownCaption.js +7 -6
  12. package/cjs/date/datepicker/parts/WeekRow.js +1 -1
  13. package/cjs/date/datepicker/types.js +2 -0
  14. package/cjs/date/monthpicker/MonthCaption.js +5 -4
  15. package/cjs/date/monthpicker/MonthPicker.js +4 -3
  16. package/cjs/date/monthpicker/MonthSelector.js +2 -2
  17. package/cjs/date/monthpicker/types.js +2 -0
  18. package/cjs/date/utils/parse-date.js +7 -7
  19. package/cjs/dropdown/Dropdown.js +4 -4
  20. package/cjs/dropdown/Menu/GroupedList/GroupedItem.js +2 -2
  21. package/cjs/dropdown/Menu/List/Item.js +3 -3
  22. package/cjs/dropdown/Menu/index.js +2 -2
  23. package/cjs/dropdown/Toggle.js +3 -3
  24. package/cjs/dropdown/context.js +5 -0
  25. package/cjs/expansion-card/ExpansionCard.js +3 -7
  26. package/cjs/expansion-card/ExpansionCardContent.js +4 -4
  27. package/cjs/expansion-card/ExpansionCardDescription.js +5 -5
  28. package/cjs/expansion-card/ExpansionCardHeader.js +3 -3
  29. package/cjs/expansion-card/ExpansionCardTitle.js +1 -1
  30. package/cjs/expansion-card/context.js +9 -0
  31. package/cjs/form/ConfirmationPanel.js +8 -6
  32. package/cjs/form/Fieldset/Fieldset.js +11 -10
  33. package/cjs/form/Fieldset/context.js +5 -0
  34. package/cjs/form/Fieldset/index.js +2 -1
  35. package/cjs/form/Select.js +8 -7
  36. package/cjs/form/Switch.js +7 -5
  37. package/cjs/form/TextField.js +6 -5
  38. package/cjs/form/Textarea.js +8 -7
  39. package/cjs/form/checkbox/Checkbox.js +1 -1
  40. package/cjs/form/checkbox/CheckboxGroup.js +4 -4
  41. package/cjs/form/checkbox/types.js +2 -0
  42. package/cjs/form/checkbox/useCheckbox.js +2 -2
  43. package/cjs/form/combobox/Combobox.js +6 -5
  44. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +6 -5
  45. package/cjs/form/combobox/Input/Input.js +2 -2
  46. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
  47. package/cjs/form/error-summary/ErrorSummary.js +3 -3
  48. package/cjs/form/radio/RadioGroup.js +6 -6
  49. package/cjs/form/radio/types.js +2 -0
  50. package/cjs/form/radio/useRadio.js +2 -2
  51. package/cjs/form/search/Search.js +10 -9
  52. package/cjs/form/search/SearchButton.js +5 -5
  53. package/cjs/form/search/context.js +5 -0
  54. package/cjs/form/useFormField.js +5 -5
  55. package/cjs/guide-panel/Illustration.js +2 -2
  56. package/cjs/help-text/HelpText.js +5 -4
  57. package/cjs/link-panel/LinkPanel.js +2 -2
  58. package/cjs/link-panel/LinkPanelDescription.js +2 -2
  59. package/cjs/list/List.js +4 -8
  60. package/cjs/list/ListItem.js +2 -2
  61. package/cjs/list/context.js +9 -0
  62. package/cjs/list/types.js +2 -0
  63. package/cjs/loader/Loader.js +4 -4
  64. package/cjs/modal/Modal.js +24 -22
  65. package/cjs/modal/types.js +2 -0
  66. package/cjs/pagination/Pagination.js +5 -5
  67. package/cjs/pagination/PaginationItem.js +2 -2
  68. package/cjs/popover/Popover.js +4 -5
  69. package/cjs/stepper/Step.js +5 -5
  70. package/cjs/stepper/Stepper.js +4 -4
  71. package/cjs/stepper/context.js +5 -0
  72. package/cjs/table/ColumnHeader.js +3 -3
  73. package/cjs/table/DataCell.js +2 -2
  74. package/cjs/table/ExpandableRow.js +2 -2
  75. package/cjs/table/Table.js +7 -7
  76. package/cjs/table/context.js +5 -0
  77. package/cjs/table/types.js +2 -0
  78. package/cjs/tabs/Tab.js +4 -4
  79. package/cjs/tabs/TabList.js +5 -5
  80. package/cjs/tabs/Tabs.js +3 -3
  81. package/cjs/tabs/context.js +5 -0
  82. package/cjs/tag/Tag.js +2 -2
  83. package/cjs/timeline/period/NonClickablePeriod.js +1 -1
  84. package/cjs/timeline/period/types.js +2 -0
  85. package/cjs/toggle-group/ToggleGroup.js +7 -6
  86. package/cjs/toggle-group/ToggleItem.js +4 -4
  87. package/cjs/toggle-group/context.js +5 -0
  88. package/cjs/tooltip/Tooltip.js +4 -3
  89. package/cjs/util/TextareaAutoSize.js +4 -4
  90. package/cjs/util/index.js +7 -38
  91. package/cjs/util/omit.js +7 -0
  92. package/cjs/util/useClientLayoutEffect.js +10 -0
  93. package/cjs/util/useEventListener.js +17 -0
  94. package/esm/accordion/AccordionContent.js +1 -1
  95. package/esm/accordion/AccordionContent.js.map +1 -1
  96. package/esm/accordion/AccordionHeader.js +1 -1
  97. package/esm/accordion/AccordionHeader.js.map +1 -1
  98. package/esm/alert/Alert.js +1 -1
  99. package/esm/alert/Alert.js.map +1 -1
  100. package/esm/button/Button.d.ts +1 -1
  101. package/esm/button/Button.js +4 -3
  102. package/esm/button/Button.js.map +1 -1
  103. package/esm/chips/Chips.d.ts +1 -1
  104. package/esm/chips/Toggle.d.ts +1 -1
  105. package/esm/copybutton/CopyButton.d.ts +7 -7
  106. package/esm/copybutton/CopyButton.js +7 -6
  107. package/esm/copybutton/CopyButton.js.map +1 -1
  108. package/esm/date/DateInput.js +2 -1
  109. package/esm/date/DateInput.js.map +1 -1
  110. package/esm/date/datepicker/DatePicker.d.ts +5 -105
  111. package/esm/date/datepicker/DatePicker.js +4 -3
  112. package/esm/date/datepicker/DatePicker.js.map +1 -1
  113. package/esm/date/datepicker/DatePickerStandalone.d.ts +1 -1
  114. package/esm/date/datepicker/DatePickerStandalone.js +5 -5
  115. package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
  116. package/esm/date/datepicker/parts/Caption.js +2 -1
  117. package/esm/date/datepicker/parts/Caption.js.map +1 -1
  118. package/esm/date/datepicker/parts/DropdownCaption.js +3 -2
  119. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
  120. package/esm/date/datepicker/parts/WeekRow.js +1 -1
  121. package/esm/date/datepicker/parts/WeekRow.js.map +1 -1
  122. package/esm/date/datepicker/types.d.ts +102 -0
  123. package/esm/date/datepicker/types.js +2 -0
  124. package/esm/date/datepicker/types.js.map +1 -0
  125. package/esm/date/hooks/useMonthPicker.d.ts +1 -1
  126. package/esm/date/index.d.ts +4 -3
  127. package/esm/date/index.js +1 -1
  128. package/esm/date/index.js.map +1 -1
  129. package/esm/date/monthpicker/MonthCaption.js +2 -1
  130. package/esm/date/monthpicker/MonthCaption.js.map +1 -1
  131. package/esm/date/monthpicker/MonthPicker.d.ts +5 -86
  132. package/esm/date/monthpicker/MonthPicker.js +3 -2
  133. package/esm/date/monthpicker/MonthPicker.js.map +1 -1
  134. package/esm/date/monthpicker/MonthPickerStandalone.d.ts +1 -1
  135. package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
  136. package/esm/date/monthpicker/MonthSelector.js +1 -1
  137. package/esm/date/monthpicker/MonthSelector.js.map +1 -1
  138. package/esm/date/monthpicker/types.d.ts +83 -0
  139. package/esm/date/monthpicker/types.js +2 -0
  140. package/esm/date/monthpicker/types.js.map +1 -0
  141. package/esm/date/utils/parse-date.js +1 -1
  142. package/esm/date/utils/parse-date.js.map +1 -1
  143. package/esm/dropdown/Dropdown.d.ts +1 -9
  144. package/esm/dropdown/Dropdown.js +3 -3
  145. package/esm/dropdown/Dropdown.js.map +1 -1
  146. package/esm/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
  147. package/esm/dropdown/Menu/GroupedList/GroupedItem.js +1 -1
  148. package/esm/dropdown/Menu/GroupedList/GroupedItem.js.map +1 -1
  149. package/esm/dropdown/Menu/GroupedList/index.d.ts +1 -1
  150. package/esm/dropdown/Menu/List/Item.d.ts +1 -1
  151. package/esm/dropdown/Menu/List/Item.js +2 -2
  152. package/esm/dropdown/Menu/List/Item.js.map +1 -1
  153. package/esm/dropdown/Menu/List/index.d.ts +1 -1
  154. package/esm/dropdown/Menu/index.js +1 -1
  155. package/esm/dropdown/Menu/index.js.map +1 -1
  156. package/esm/dropdown/Toggle.js +2 -2
  157. package/esm/dropdown/Toggle.js.map +1 -1
  158. package/esm/dropdown/context.d.ts +9 -0
  159. package/esm/dropdown/context.js +3 -0
  160. package/esm/dropdown/context.js.map +1 -0
  161. package/esm/expansion-card/ExpansionCard.d.ts +1 -7
  162. package/esm/expansion-card/ExpansionCard.js +2 -6
  163. package/esm/expansion-card/ExpansionCard.js.map +1 -1
  164. package/esm/expansion-card/ExpansionCardContent.js +2 -2
  165. package/esm/expansion-card/ExpansionCardContent.js.map +1 -1
  166. package/esm/expansion-card/ExpansionCardDescription.js +3 -3
  167. package/esm/expansion-card/ExpansionCardDescription.js.map +1 -1
  168. package/esm/expansion-card/ExpansionCardHeader.js +2 -2
  169. package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
  170. package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
  171. package/esm/expansion-card/ExpansionCardTitle.js +1 -1
  172. package/esm/expansion-card/ExpansionCardTitle.js.map +1 -1
  173. package/esm/expansion-card/context.d.ts +7 -0
  174. package/esm/expansion-card/context.js +7 -0
  175. package/esm/expansion-card/context.js.map +1 -0
  176. package/esm/form/ConfirmationPanel.d.ts +1 -1
  177. package/esm/form/ConfirmationPanel.js +4 -2
  178. package/esm/form/ConfirmationPanel.js.map +1 -1
  179. package/esm/form/Fieldset/Fieldset.d.ts +0 -23
  180. package/esm/form/Fieldset/Fieldset.js +4 -3
  181. package/esm/form/Fieldset/Fieldset.js.map +1 -1
  182. package/esm/form/Fieldset/context.d.ts +24 -0
  183. package/esm/form/Fieldset/context.js +3 -0
  184. package/esm/form/Fieldset/context.js.map +1 -0
  185. package/esm/form/Fieldset/index.d.ts +2 -1
  186. package/esm/form/Fieldset/index.js +2 -1
  187. package/esm/form/Fieldset/index.js.map +1 -1
  188. package/esm/form/Select.js +4 -3
  189. package/esm/form/Select.js.map +1 -1
  190. package/esm/form/Switch.js +3 -1
  191. package/esm/form/Switch.js.map +1 -1
  192. package/esm/form/TextField.js +2 -1
  193. package/esm/form/TextField.js.map +1 -1
  194. package/esm/form/Textarea.js +2 -1
  195. package/esm/form/Textarea.js.map +1 -1
  196. package/esm/form/checkbox/Checkbox.d.ts +2 -34
  197. package/esm/form/checkbox/Checkbox.js +1 -1
  198. package/esm/form/checkbox/Checkbox.js.map +1 -1
  199. package/esm/form/checkbox/CheckboxGroup.d.ts +1 -1
  200. package/esm/form/checkbox/CheckboxGroup.js +2 -2
  201. package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
  202. package/esm/form/checkbox/index.d.ts +2 -1
  203. package/esm/form/checkbox/index.js.map +1 -1
  204. package/esm/form/checkbox/types.d.ts +34 -0
  205. package/esm/form/checkbox/types.js +2 -0
  206. package/esm/form/checkbox/types.js.map +1 -0
  207. package/esm/form/checkbox/useCheckbox.d.ts +1 -1
  208. package/esm/form/checkbox/useCheckbox.js +1 -1
  209. package/esm/form/checkbox/useCheckbox.js.map +1 -1
  210. package/esm/form/combobox/Combobox.d.ts +1 -1
  211. package/esm/form/combobox/Combobox.js +2 -1
  212. package/esm/form/combobox/Combobox.js.map +1 -1
  213. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +2 -1
  214. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  215. package/esm/form/combobox/Input/Input.js +1 -1
  216. package/esm/form/combobox/Input/Input.js.map +1 -1
  217. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
  218. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  219. package/esm/form/error-summary/ErrorSummary.js +1 -1
  220. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  221. package/esm/form/error-summary/ErrorSummaryItem.d.ts +1 -1
  222. package/esm/form/radio/Radio.d.ts +2 -16
  223. package/esm/form/radio/Radio.js.map +1 -1
  224. package/esm/form/radio/RadioGroup.d.ts +1 -1
  225. package/esm/form/radio/RadioGroup.js +3 -3
  226. package/esm/form/radio/RadioGroup.js.map +1 -1
  227. package/esm/form/radio/index.d.ts +2 -1
  228. package/esm/form/radio/index.js.map +1 -1
  229. package/esm/form/radio/types.d.ts +16 -0
  230. package/esm/form/radio/types.js +2 -0
  231. package/esm/form/radio/types.js.map +1 -0
  232. package/esm/form/radio/useRadio.d.ts +1 -1
  233. package/esm/form/radio/useRadio.js +1 -1
  234. package/esm/form/radio/useRadio.js.map +1 -1
  235. package/esm/form/search/Search.d.ts +0 -7
  236. package/esm/form/search/Search.js +4 -3
  237. package/esm/form/search/Search.js.map +1 -1
  238. package/esm/form/search/SearchButton.d.ts +1 -1
  239. package/esm/form/search/SearchButton.js +3 -3
  240. package/esm/form/search/SearchButton.js.map +1 -1
  241. package/esm/form/search/context.d.ts +8 -0
  242. package/esm/form/search/context.js +3 -0
  243. package/esm/form/search/context.js.map +1 -0
  244. package/esm/form/useFormField.js +3 -3
  245. package/esm/form/useFormField.js.map +1 -1
  246. package/esm/guide-panel/Illustration.js +1 -1
  247. package/esm/guide-panel/Illustration.js.map +1 -1
  248. package/esm/help-text/HelpText.d.ts +1 -1
  249. package/esm/help-text/HelpText.js +2 -1
  250. package/esm/help-text/HelpText.js.map +1 -1
  251. package/esm/link-panel/LinkPanel.d.ts +1 -1
  252. package/esm/link-panel/LinkPanel.js +1 -1
  253. package/esm/link-panel/LinkPanel.js.map +1 -1
  254. package/esm/link-panel/LinkPanelDescription.js +1 -1
  255. package/esm/link-panel/LinkPanelDescription.js.map +1 -1
  256. package/esm/list/List.d.ts +4 -35
  257. package/esm/list/List.js +2 -6
  258. package/esm/list/List.js.map +1 -1
  259. package/esm/list/ListItem.js +1 -1
  260. package/esm/list/ListItem.js.map +1 -1
  261. package/esm/list/context.d.ts +9 -0
  262. package/esm/list/context.js +7 -0
  263. package/esm/list/context.js.map +1 -0
  264. package/esm/list/index.d.ts +1 -1
  265. package/esm/list/types.d.ts +27 -0
  266. package/esm/list/types.js +2 -0
  267. package/esm/list/types.js.map +1 -0
  268. package/esm/loader/Loader.js +2 -2
  269. package/esm/loader/Loader.js.map +1 -1
  270. package/esm/modal/Modal.d.ts +2 -64
  271. package/esm/modal/Modal.js +8 -6
  272. package/esm/modal/Modal.js.map +1 -1
  273. package/esm/modal/ModalUtils.d.ts +1 -1
  274. package/esm/modal/index.d.ts +3 -2
  275. package/esm/modal/index.js.map +1 -1
  276. package/esm/modal/types.d.ts +64 -0
  277. package/esm/modal/types.js +2 -0
  278. package/esm/modal/types.js.map +1 -0
  279. package/esm/pagination/Pagination.js +1 -1
  280. package/esm/pagination/Pagination.js.map +1 -1
  281. package/esm/pagination/PaginationItem.d.ts +2 -1
  282. package/esm/pagination/PaginationItem.js +1 -1
  283. package/esm/pagination/PaginationItem.js.map +1 -1
  284. package/esm/popover/Popover.d.ts +5 -0
  285. package/esm/popover/Popover.js +5 -6
  286. package/esm/popover/Popover.js.map +1 -1
  287. package/esm/stepper/Step.d.ts +1 -1
  288. package/esm/stepper/Step.js +2 -2
  289. package/esm/stepper/Step.js.map +1 -1
  290. package/esm/stepper/Stepper.d.ts +2 -11
  291. package/esm/stepper/Stepper.js +2 -2
  292. package/esm/stepper/Stepper.js.map +1 -1
  293. package/esm/stepper/context.d.ts +10 -0
  294. package/esm/stepper/context.js +3 -0
  295. package/esm/stepper/context.js.map +1 -0
  296. package/esm/table/ColumnHeader.js +2 -2
  297. package/esm/table/ColumnHeader.js.map +1 -1
  298. package/esm/table/DataCell.js +1 -1
  299. package/esm/table/DataCell.js.map +1 -1
  300. package/esm/table/ExpandableRow.js +1 -1
  301. package/esm/table/ExpandableRow.js.map +1 -1
  302. package/esm/table/Table.d.ts +15 -23
  303. package/esm/table/Table.js +5 -5
  304. package/esm/table/Table.js.map +1 -1
  305. package/esm/table/context.d.ts +7 -0
  306. package/esm/table/context.js +3 -0
  307. package/esm/table/context.js.map +1 -0
  308. package/esm/table/index.d.ts +2 -1
  309. package/esm/table/index.js.map +1 -1
  310. package/esm/table/types.d.ts +4 -0
  311. package/esm/table/types.js +2 -0
  312. package/esm/table/types.js.map +1 -0
  313. package/esm/tabs/Tab.d.ts +1 -1
  314. package/esm/tabs/Tab.js +2 -2
  315. package/esm/tabs/Tab.js.map +1 -1
  316. package/esm/tabs/TabList.js +2 -2
  317. package/esm/tabs/TabList.js.map +1 -1
  318. package/esm/tabs/Tabs.d.ts +0 -6
  319. package/esm/tabs/Tabs.js +2 -2
  320. package/esm/tabs/Tabs.js.map +1 -1
  321. package/esm/tabs/context.d.ts +8 -0
  322. package/esm/tabs/context.js +3 -0
  323. package/esm/tabs/context.js.map +1 -0
  324. package/esm/tabs/index.d.ts +1 -1
  325. package/esm/tabs/index.js.map +1 -1
  326. package/esm/tag/Tag.js +1 -1
  327. package/esm/tag/Tag.js.map +1 -1
  328. package/esm/timeline/period/ClickablePeriod.d.ts +1 -1
  329. package/esm/timeline/period/NonClickablePeriod.d.ts +1 -1
  330. package/esm/timeline/period/NonClickablePeriod.js +1 -1
  331. package/esm/timeline/period/NonClickablePeriod.js.map +1 -1
  332. package/esm/timeline/period/index.d.ts +0 -13
  333. package/esm/timeline/period/index.js.map +1 -1
  334. package/esm/timeline/period/types.d.ts +14 -0
  335. package/esm/timeline/period/types.js +2 -0
  336. package/esm/timeline/period/types.js.map +1 -0
  337. package/esm/toggle-group/ToggleGroup.d.ts +0 -4
  338. package/esm/toggle-group/ToggleGroup.js +4 -3
  339. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  340. package/esm/toggle-group/ToggleItem.js +3 -3
  341. package/esm/toggle-group/ToggleItem.js.map +1 -1
  342. package/esm/toggle-group/context.d.ts +6 -0
  343. package/esm/toggle-group/context.js +3 -0
  344. package/esm/toggle-group/context.js.map +1 -0
  345. package/esm/tooltip/Tooltip.js +2 -1
  346. package/esm/tooltip/Tooltip.js.map +1 -1
  347. package/esm/util/TextareaAutoSize.js +1 -1
  348. package/esm/util/TextareaAutoSize.js.map +1 -1
  349. package/esm/util/index.d.ts +5 -11
  350. package/esm/util/index.js +5 -33
  351. package/esm/util/index.js.map +1 -1
  352. package/esm/util/omit.d.ts +1 -0
  353. package/esm/util/omit.js +4 -0
  354. package/esm/util/omit.js.map +1 -0
  355. package/esm/util/useClientLayoutEffect.d.ts +2 -0
  356. package/esm/util/useClientLayoutEffect.js +8 -0
  357. package/esm/util/useClientLayoutEffect.js.map +1 -0
  358. package/esm/util/useEventListener.d.ts +5 -0
  359. package/esm/util/useEventListener.js +14 -0
  360. package/esm/util/useEventListener.js.map +1 -0
  361. package/package.json +3 -3
  362. package/src/accordion/AccordionContent.tsx +1 -1
  363. package/src/accordion/AccordionHeader.tsx +1 -1
  364. package/src/alert/Alert.tsx +1 -1
  365. package/src/button/Button.tsx +9 -3
  366. package/src/chips/Chips.tsx +1 -1
  367. package/src/chips/Toggle.tsx +1 -1
  368. package/src/copybutton/CopyButton.tsx +28 -29
  369. package/src/copybutton/copy-button.stories.tsx +24 -22
  370. package/src/date/DateInput.tsx +2 -1
  371. package/src/date/datepicker/DatePicker.tsx +9 -124
  372. package/src/date/datepicker/DatePickerStandalone.tsx +9 -9
  373. package/src/date/datepicker/parts/Caption.tsx +3 -1
  374. package/src/date/datepicker/parts/DropdownCaption.tsx +3 -2
  375. package/src/date/datepicker/parts/WeekRow.tsx +1 -1
  376. package/src/date/datepicker/types.ts +109 -0
  377. package/src/date/hooks/useMonthPicker.tsx +1 -1
  378. package/src/date/index.ts +5 -7
  379. package/src/date/monthpicker/MonthCaption.tsx +2 -1
  380. package/src/date/monthpicker/MonthPicker.tsx +9 -92
  381. package/src/date/monthpicker/MonthPickerStandalone.tsx +1 -1
  382. package/src/date/monthpicker/MonthSelector.tsx +1 -1
  383. package/src/date/monthpicker/types.ts +83 -0
  384. package/src/date/utils/parse-date.ts +1 -1
  385. package/src/dropdown/Dropdown.tsx +3 -12
  386. package/src/dropdown/Menu/GroupedList/GroupedItem.tsx +2 -2
  387. package/src/dropdown/Menu/GroupedList/index.tsx +1 -1
  388. package/src/dropdown/Menu/List/Item.tsx +3 -3
  389. package/src/dropdown/Menu/List/index.tsx +1 -1
  390. package/src/dropdown/Menu/index.tsx +1 -1
  391. package/src/dropdown/Toggle.tsx +2 -2
  392. package/src/dropdown/context.ts +11 -0
  393. package/src/expansion-card/ExpansionCard.tsx +3 -14
  394. package/src/expansion-card/ExpansionCardContent.tsx +2 -2
  395. package/src/expansion-card/ExpansionCardDescription.tsx +3 -3
  396. package/src/expansion-card/ExpansionCardHeader.tsx +2 -2
  397. package/src/expansion-card/ExpansionCardTitle.tsx +2 -2
  398. package/src/expansion-card/context.ts +13 -0
  399. package/src/form/ConfirmationPanel.tsx +4 -2
  400. package/src/form/Fieldset/Fieldset.tsx +4 -29
  401. package/src/form/Fieldset/context.ts +26 -0
  402. package/src/form/Fieldset/index.ts +2 -5
  403. package/src/form/Select.tsx +4 -4
  404. package/src/form/Switch.tsx +3 -1
  405. package/src/form/TextField.tsx +2 -1
  406. package/src/form/Textarea.tsx +2 -1
  407. package/src/form/checkbox/Checkbox.tsx +3 -38
  408. package/src/form/checkbox/CheckboxGroup.tsx +2 -2
  409. package/src/form/checkbox/index.ts +2 -1
  410. package/src/form/checkbox/types.ts +37 -0
  411. package/src/form/checkbox/useCheckbox.ts +2 -1
  412. package/src/form/combobox/Combobox.tsx +2 -1
  413. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +2 -1
  414. package/src/form/combobox/Input/Input.tsx +1 -1
  415. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
  416. package/src/form/error-summary/ErrorSummary.tsx +1 -1
  417. package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
  418. package/src/form/radio/Radio.tsx +2 -19
  419. package/src/form/radio/RadioGroup.tsx +3 -3
  420. package/src/form/radio/index.ts +2 -1
  421. package/src/form/radio/types.ts +19 -0
  422. package/src/form/radio/useRadio.ts +2 -2
  423. package/src/form/search/Search.tsx +5 -14
  424. package/src/form/search/SearchButton.tsx +3 -3
  425. package/src/form/search/context.ts +10 -0
  426. package/src/form/useFormField.ts +3 -3
  427. package/src/guide-panel/Illustration.tsx +1 -1
  428. package/src/help-text/HelpText.tsx +2 -1
  429. package/src/link-panel/LinkPanel.tsx +2 -1
  430. package/src/link-panel/LinkPanelDescription.tsx +1 -1
  431. package/src/list/List.tsx +8 -45
  432. package/src/list/ListItem.tsx +1 -1
  433. package/src/list/context.ts +14 -0
  434. package/src/list/index.ts +1 -1
  435. package/src/list/types.ts +26 -0
  436. package/src/loader/Loader.tsx +2 -2
  437. package/src/modal/Modal.tsx +9 -71
  438. package/src/modal/ModalUtils.ts +1 -1
  439. package/src/modal/index.ts +3 -2
  440. package/src/modal/types.ts +64 -0
  441. package/src/pagination/Pagination.tsx +1 -1
  442. package/src/pagination/PaginationItem.tsx +2 -1
  443. package/src/popover/Popover.tsx +10 -5
  444. package/src/stepper/Step.tsx +3 -2
  445. package/src/stepper/Stepper.tsx +3 -13
  446. package/src/stepper/context.ts +11 -0
  447. package/src/table/ColumnHeader.tsx +3 -3
  448. package/src/table/DataCell.tsx +1 -1
  449. package/src/table/ExpandableRow.tsx +1 -1
  450. package/src/table/Table.tsx +17 -27
  451. package/src/table/context.ts +9 -0
  452. package/src/table/index.ts +2 -1
  453. package/src/table/types.ts +4 -0
  454. package/src/tabs/Tab.tsx +3 -2
  455. package/src/tabs/TabList.tsx +2 -2
  456. package/src/tabs/Tabs.tsx +2 -9
  457. package/src/tabs/context.ts +9 -0
  458. package/src/tabs/index.ts +1 -1
  459. package/src/tag/Tag.tsx +1 -1
  460. package/src/timeline/period/ClickablePeriod.tsx +1 -1
  461. package/src/timeline/period/NonClickablePeriod.tsx +2 -2
  462. package/src/timeline/period/index.tsx +0 -14
  463. package/src/timeline/period/types.ts +13 -0
  464. package/src/timeline/utils/filter.ts +1 -1
  465. package/src/toggle-group/ToggleGroup.tsx +4 -15
  466. package/src/toggle-group/ToggleItem.tsx +3 -3
  467. package/src/toggle-group/context.ts +9 -0
  468. package/src/tooltip/Tooltip.tsx +2 -1
  469. package/src/util/TextareaAutoSize.tsx +1 -1
  470. package/src/util/index.ts +5 -70
  471. package/src/util/omit.ts +10 -0
  472. package/src/util/useClientLayoutEffect.ts +11 -0
  473. package/src/util/useEventListener.ts +32 -0
@@ -0,0 +1,64 @@
1
+ export interface ModalProps
2
+ extends React.DialogHTMLAttributes<HTMLDialogElement> {
3
+ /**
4
+ * Content for the header. Alteratively you can use <Modal.Header> instead for more control,
5
+ * but then you have to set `aria-label` or `aria-labelledby` on the modal manually.
6
+ */
7
+ header?: {
8
+ label?: string;
9
+ icon?: React.ReactNode;
10
+ heading: string;
11
+ /**
12
+ * Heading size
13
+ * @default "medium"
14
+ * */
15
+ size?: "medium" | "small";
16
+ /**
17
+ * Removes close-button (X) when false
18
+ * @default true
19
+ */
20
+ closeButton?: boolean;
21
+ };
22
+ /**
23
+ * Modal content
24
+ */
25
+ children: React.ReactNode;
26
+ /**
27
+ * Whether the modal should be visible or not.
28
+ * Remember to use the `onClose` callback to keep your local state in sync.
29
+ * You can also use `ref.current.openModal()` and `ref.current.close()`.
30
+ */
31
+ open?: boolean;
32
+ /**
33
+ * Called when the modal has been closed
34
+ */
35
+ onClose?: React.ReactEventHandler<HTMLDialogElement>;
36
+ /**
37
+ * Called when the user wants to close the modal (clicked the close button or pressed Esc).
38
+ * @returns Whether to close the modal
39
+ */
40
+ onBeforeClose?: () => boolean | void;
41
+ /**
42
+ * Called when the user presses the Esc key, unless `onBeforeClose()` returns `false`.
43
+ */
44
+ onCancel?: React.ReactEventHandler<HTMLDialogElement>;
45
+ /**
46
+ * @default fit-content (up to 700px)
47
+ * */
48
+ width?: "medium" | "small" | number | `${number}${string}`;
49
+ /**
50
+ * Lets you render the modal into a different part of the DOM.
51
+ * Will use `rootElement` from `Provider` if defined, otherwise `document.body`.
52
+ */
53
+ portal?: boolean;
54
+ /**
55
+ * User defined classname for modal
56
+ */
57
+ className?: string;
58
+ /**
59
+ * Sets aria-labelledby on modal.
60
+ * No need to set this manually if the `header` prop is used. A reference to `header.heading` will be created automatically.
61
+ * @warning If not using `header`, you should set either `aria-labelledby` or `aria-label`.
62
+ */
63
+ "aria-labelledby"?: string;
64
+ }
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
 
4
4
  import { ChevronLeftIcon, ChevronRightIcon } from "@navikt/aksel-icons";
5
- import { BodyShort } from "..";
5
+ import { BodyShort } from "../typography";
6
6
  import PaginationItem, {
7
7
  PaginationItemProps,
8
8
  PaginationItemType,
@@ -1,6 +1,7 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import cl from "clsx";
3
- import { Button, ButtonProps, OverridableComponent } from "..";
3
+ import { Button, ButtonProps } from "../button";
4
+ import { OverridableComponent } from "../util";
4
5
 
5
6
  export interface PaginationItemProps extends ButtonProps {
6
7
  children: React.ReactNode;
@@ -14,14 +14,13 @@ import React, {
14
14
  HTMLAttributes,
15
15
  forwardRef,
16
16
  useCallback,
17
+ useContext,
17
18
  useMemo,
18
19
  useRef,
19
- useContext,
20
20
  } from "react";
21
- import { mergeRefs } from "..";
22
- import { useClientLayoutEffect, useEventListener } from "../util";
23
- import PopoverContent, { PopoverContentType } from "./PopoverContent";
24
21
  import { ModalContext } from "../modal/ModalContext";
22
+ import { mergeRefs, useClientLayoutEffect, useEventListener } from "../util";
23
+ import PopoverContent, { PopoverContentType } from "./PopoverContent";
25
24
 
26
25
  export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
27
26
  /**
@@ -79,6 +78,11 @@ export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
79
78
  * @default false
80
79
  */
81
80
  bubbleEscape?: boolean;
81
+ /**
82
+ * Changes placement of the floating element in order to keep it in view.
83
+ * @default true
84
+ */
85
+ flip?: boolean;
82
86
  }
83
87
 
84
88
  interface PopoverComponent
@@ -121,6 +125,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
121
125
  offset,
122
126
  strategy: userStrategy,
123
127
  bubbleEscape = false,
128
+ flip: _flip = true,
124
129
  ...rest
125
130
  },
126
131
  ref
@@ -145,7 +150,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
145
150
  onOpenChange: () => onClose(),
146
151
  middleware: [
147
152
  flOffset(offset ?? (arrow ? 16 : 4)),
148
- flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
153
+ _flip && flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
149
154
  shift({ padding: 12 }),
150
155
  flArrow({ element: arrowRef, padding: 8 }),
151
156
  ],
@@ -1,7 +1,8 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef, useContext } from "react";
3
- import { Label, OverridableComponent } from "..";
4
- import { StepperContext } from "./Stepper";
3
+ import { Label } from "../typography";
4
+ import { OverridableComponent } from "../util";
5
+ import { StepperContext } from "./context";
5
6
 
6
7
  export interface StepperStepProps
7
8
  extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
@@ -1,7 +1,7 @@
1
- import React, { createContext, forwardRef } from "react";
2
1
  import cl from "clsx";
2
+ import React, { forwardRef } from "react";
3
3
  import Step, { StepperStepProps } from "./Step";
4
- import { OverridableComponent } from "../util/OverridableComponent";
4
+ import { StepperContext } from "./context";
5
5
 
6
6
  export interface StepperProps extends React.HTMLAttributes<HTMLOListElement> {
7
7
  /**
@@ -38,19 +38,9 @@ interface StepperComponent
38
38
  * @see 🏷️ {@link StepperStepProps}
39
39
  * @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
40
40
  */
41
- Step: OverridableComponent<StepperStepProps, HTMLAnchorElement>;
41
+ Step: typeof Step;
42
42
  }
43
43
 
44
- interface StepperContextProps {
45
- activeStep: number;
46
- onStepChange: (step: number) => void;
47
- lastIndex: number;
48
- orientation: "horizontal" | "vertical";
49
- interactive: boolean;
50
- }
51
-
52
- export const StepperContext = createContext<StepperContextProps | null>(null);
53
-
54
44
  /**
55
45
  * A component that displays a stepper with clickable steps.
56
46
  *
@@ -0,0 +1,11 @@
1
+ import { createContext } from "react";
2
+
3
+ interface StepperContextProps {
4
+ activeStep: number;
5
+ onStepChange: (step: number) => void;
6
+ lastIndex: number;
7
+ orientation: "horizontal" | "vertical";
8
+ interactive: boolean;
9
+ }
10
+
11
+ export const StepperContext = createContext<StepperContextProps | null>(null);
@@ -1,11 +1,11 @@
1
- import React, { forwardRef, useContext } from "react";
2
- import { TableContext } from "./Table";
3
- import HeaderCell, { HeaderCellProps } from "./HeaderCell";
4
1
  import {
5
2
  ArrowDownIcon,
6
3
  ArrowUpIcon,
7
4
  ArrowsUpDownIcon,
8
5
  } from "@navikt/aksel-icons";
6
+ import React, { forwardRef, useContext } from "react";
7
+ import HeaderCell, { HeaderCellProps } from "./HeaderCell";
8
+ import { TableContext } from "./context";
9
9
 
10
10
  export interface ColumnHeaderProps extends HeaderCellProps {
11
11
  /**
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import cl from "clsx";
3
- import { BodyShort } from "..";
3
+ import { BodyShort } from "../typography";
4
4
 
5
5
  export interface DataCellProps
6
6
  extends React.TdHTMLAttributes<HTMLTableCellElement> {
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef, useState } from "react";
3
- import { useId } from "..";
3
+ import { useId } from "../util";
4
4
  import AnimateHeight from "../util/AnimateHeight";
5
5
  import DataCell from "./DataCell";
6
6
  import Row, { RowProps } from "./Row";
@@ -1,17 +1,14 @@
1
- import React, { createContext, forwardRef } from "react";
2
1
  import cl from "clsx";
3
- import Header, { HeaderType } from "./Header";
4
- import Body, { BodyType } from "./Body";
5
- import Row, { RowType } from "./Row";
6
- import ColumnHeader, { ColumnHeaderType } from "./ColumnHeader";
7
- import HeaderCell, { HeaderCellType } from "./HeaderCell";
8
- import DataCell, { DataCellType } from "./DataCell";
9
- import ExpandableRow, { ExpandableRowType } from "./ExpandableRow";
10
-
11
- export interface SortState {
12
- orderBy: string;
13
- direction: "ascending" | "descending";
14
- }
2
+ import React, { forwardRef } from "react";
3
+ import Body from "./Body";
4
+ import ColumnHeader from "./ColumnHeader";
5
+ import DataCell from "./DataCell";
6
+ import ExpandableRow from "./ExpandableRow";
7
+ import Header from "./Header";
8
+ import HeaderCell from "./HeaderCell";
9
+ import Row from "./Row";
10
+ import { TableContext } from "./context";
11
+ import { SortState } from "./types";
15
12
 
16
13
  export interface TableProps
17
14
  extends React.TableHTMLAttributes<HTMLTableElement> {
@@ -39,22 +36,15 @@ export interface TableType
39
36
  extends React.ForwardRefExoticComponent<
40
37
  TableProps & React.RefAttributes<HTMLTableElement>
41
38
  > {
42
- Header: HeaderType;
43
- Body: BodyType;
44
- Row: RowType;
45
- DataCell: DataCellType;
46
- HeaderCell: HeaderCellType;
47
- ColumnHeader: ColumnHeaderType;
48
- ExpandableRow: ExpandableRowType;
49
- }
50
-
51
- export interface TableContextProps {
52
- onSortChange?: (sortKey: string) => void;
53
- sort?: SortState;
39
+ Header: typeof Header;
40
+ Body: typeof Body;
41
+ Row: typeof Row;
42
+ DataCell: typeof DataCell;
43
+ HeaderCell: typeof HeaderCell;
44
+ ColumnHeader: typeof ColumnHeader;
45
+ ExpandableRow: typeof ExpandableRow;
54
46
  }
55
47
 
56
- export const TableContext = createContext<TableContextProps | null>(null);
57
-
58
48
  /**
59
49
  * A component that displays a table with headers and rows.
60
50
  *
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+ import { SortState } from "./types";
3
+
4
+ export interface TableContextProps {
5
+ onSortChange?: (sortKey: string) => void;
6
+ sort?: SortState;
7
+ }
8
+
9
+ export const TableContext = createContext<TableContextProps | null>(null);
@@ -1,4 +1,3 @@
1
- export { default as Table, type TableProps, type SortState } from "./Table";
2
1
  export { type BodyProps } from "./Body";
3
2
  export { type ColumnHeaderProps } from "./ColumnHeader";
4
3
  export { type DataCellProps } from "./DataCell";
@@ -6,3 +5,5 @@ export { type ExpandableRowProps } from "./ExpandableRow";
6
5
  export { type HeaderProps } from "./Header";
7
6
  export { type HeaderCellProps } from "./HeaderCell";
8
7
  export { type RowProps } from "./Row";
8
+ export { default as Table, type TableProps } from "./Table";
9
+ export { type SortState } from "./types";
@@ -0,0 +1,4 @@
1
+ export interface SortState {
2
+ orderBy: string;
3
+ direction: "ascending" | "descending";
4
+ }
package/src/tabs/Tab.tsx CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as RadixTabs from "@radix-ui/react-tabs";
2
2
  import cl from "clsx";
3
3
  import React, { forwardRef, useContext } from "react";
4
- import { BodyShort, OverridableComponent } from "..";
5
- import { TabsContext } from "./Tabs";
4
+ import { BodyShort } from "../typography";
5
+ import { OverridableComponent } from "../util";
6
+ import { TabsContext } from "./context";
6
7
 
7
8
  export interface TabProps
8
9
  extends Omit<React.HTMLAttributes<HTMLButtonElement>, "children"> {
@@ -9,8 +9,8 @@ import React, {
9
9
  useRef,
10
10
  useState,
11
11
  } from "react";
12
- import { debounce, mergeRefs } from "..";
13
- import { TabsContext } from "./Tabs";
12
+ import { debounce, mergeRefs } from "../util";
13
+ import { TabsContext } from "./context";
14
14
 
15
15
  export interface TabListProps extends React.HTMLAttributes<HTMLDivElement> {
16
16
  /**
package/src/tabs/Tabs.tsx CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as RadixTabs from "@radix-ui/react-tabs";
2
2
  import cl from "clsx";
3
- import React, { createContext, forwardRef, HTMLAttributes } from "react";
3
+ import React, { forwardRef, HTMLAttributes } from "react";
4
4
  import { OverridableComponent } from "../util/OverridableComponent";
5
+ import { TabsContext } from "./context";
5
6
  import Tab, { TabProps } from "./Tab";
6
7
  import TabList, { TabListProps } from "./TabList";
7
8
  import TabPanel, { TabPanelProps } from "./TabPanel";
@@ -66,14 +67,6 @@ interface TabsComponent
66
67
  >;
67
68
  }
68
69
 
69
- interface TabsContextProps {
70
- size: "medium" | "small";
71
- loop: boolean;
72
- iconPosition: "left" | "top";
73
- }
74
-
75
- export const TabsContext = createContext<TabsContextProps | null>(null);
76
-
77
70
  /**
78
71
  * A component that displays a set of tabs that can be used to switch between different views.
79
72
  *
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+
3
+ interface TabsContextProps {
4
+ size: "medium" | "small";
5
+ loop: boolean;
6
+ iconPosition: "left" | "top";
7
+ }
8
+
9
+ export const TabsContext = createContext<TabsContextProps | null>(null);
package/src/tabs/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { default as Tabs, type TabsProps } from "./Tabs";
2
1
  export { type TabProps } from "./Tab";
3
2
  export { type TabListProps } from "./TabList";
4
3
  export { type TabPanelProps } from "./TabPanel";
4
+ export { default as Tabs, type TabsProps } from "./Tabs";
package/src/tag/Tag.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, HTMLAttributes } from "react";
2
2
  import cl from "clsx";
3
- import { BodyShort } from "..";
3
+ import { BodyShort } from "../typography";
4
4
 
5
5
  export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
6
6
  children: React.ReactNode;
@@ -20,7 +20,7 @@ import { usePeriodContext } from "../hooks/usePeriodContext";
20
20
  import { useRowContext } from "../hooks/useRowContext";
21
21
  import { useTimelineContext } from "../hooks/useTimelineContext";
22
22
  import { ariaLabel, getConditionalClasses } from "../utils/period";
23
- import { PeriodProps } from "./index";
23
+ import { PeriodProps } from "./types";
24
24
 
25
25
  interface TimelineClickablePeriodProps extends PeriodProps {
26
26
  onSelectPeriod?: (
@@ -1,7 +1,7 @@
1
+ import cl from "clsx";
1
2
  import React from "react";
2
3
  import { ariaLabel, getConditionalClasses } from "../utils/period";
3
- import { PeriodProps } from "./index";
4
- import cl from "clsx";
4
+ import { PeriodProps } from "./types";
5
5
 
6
6
  interface TimelineNonClickablePeriodProps extends PeriodProps {
7
7
  periodRef?: React.ForwardedRef<HTMLDivElement>;
@@ -44,20 +44,6 @@ export interface TimelinePeriodProps
44
44
  isActive?: boolean;
45
45
  }
46
46
 
47
- export interface PeriodProps {
48
- start: Date;
49
- end: Date;
50
- status: string;
51
- cropped: string;
52
- direction: string;
53
- width: number;
54
- left: number;
55
- icon?: React.ReactNode;
56
- children?: React.ReactNode;
57
- statusLabel?: string;
58
- restProps?: any;
59
- }
60
-
61
47
  export interface PeriodType
62
48
  extends React.ForwardRefExoticComponent<
63
49
  TimelinePeriodProps &
@@ -0,0 +1,13 @@
1
+ export interface PeriodProps {
2
+ start: Date;
3
+ end: Date;
4
+ status: string;
5
+ cropped: string;
6
+ direction: string;
7
+ width: number;
8
+ left: number;
9
+ icon?: React.ReactNode;
10
+ children?: React.ReactNode;
11
+ statusLabel?: string;
12
+ restProps?: any;
13
+ }
@@ -1,5 +1,5 @@
1
1
  import { differenceInDays } from "date-fns";
2
- import { PeriodProps } from "../period";
2
+ import { PeriodProps } from "../period/types";
3
3
  import { Spatial } from "./types.internal";
4
4
 
5
5
  export interface Positioned {
@@ -1,12 +1,9 @@
1
1
  import * as RadixToggleGroup from "@radix-ui/react-toggle-group";
2
2
  import cl from "clsx";
3
- import React, {
4
- createContext,
5
- forwardRef,
6
- HTMLAttributes,
7
- useState,
8
- } from "react";
9
- import { Label, useId } from "..";
3
+ import React, { forwardRef, HTMLAttributes, useState } from "react";
4
+ import { Label } from "../typography";
5
+ import { useId } from "../util";
6
+ import { ToggleGroupContext } from "./context";
10
7
  import ToggleItem, { ToggleItemProps } from "./ToggleItem";
11
8
 
12
9
  export interface ToggleGroupProps
@@ -55,14 +52,6 @@ interface ToggleGroupComponent
55
52
  >;
56
53
  }
57
54
 
58
- interface ToggleContextProps {
59
- size: "medium" | "small";
60
- }
61
-
62
- export const ToggleGroupContext = createContext<ToggleContextProps | null>(
63
- null
64
- );
65
-
66
55
  /**
67
56
  * A component that displays a group of toggle buttons.
68
57
  *
@@ -1,8 +1,8 @@
1
- import React, { forwardRef, useContext } from "react";
1
+ import * as RadixToggleGroup from "@radix-ui/react-toggle-group";
2
2
  import cl from "clsx";
3
+ import React, { forwardRef, useContext } from "react";
3
4
  import { BodyShort } from "../typography/BodyShort";
4
- import * as RadixToggleGroup from "@radix-ui/react-toggle-group";
5
- import { ToggleGroupContext } from "./ToggleGroup";
5
+ import { ToggleGroupContext } from "./context";
6
6
 
7
7
  export interface ToggleItemProps
8
8
  extends React.HTMLAttributes<HTMLButtonElement> {
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+
3
+ interface ToggleContextProps {
4
+ size: "medium" | "small";
5
+ }
6
+
7
+ export const ToggleGroupContext = createContext<ToggleContextProps | null>(
8
+ null
9
+ );
@@ -21,8 +21,9 @@ import React, {
21
21
  useRef,
22
22
  useState,
23
23
  } from "react";
24
- import { Detail, useProvider } from "..";
24
+ import { Detail } from "../typography";
25
25
  import { mergeRefs, useId } from "../util";
26
+ import { useProvider } from "../provider";
26
27
 
27
28
  export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
28
29
  /**
@@ -1,7 +1,7 @@
1
1
  /* https://github.com/mui/material-ui/blob/master/packages/mui-base/src/TextareaAutosize/TextareaAutosize.js */
2
2
  import React, { forwardRef, useEffect, useMemo, useRef, useState } from "react";
3
3
  import ReactDOM from "react-dom";
4
- import { debounce, mergeRefs, useClientLayoutEffect } from "..";
4
+ import { debounce, mergeRefs, useClientLayoutEffect } from "../util";
5
5
 
6
6
  /**
7
7
  * https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerDocument.ts
package/src/util/index.ts CHANGED
@@ -1,72 +1,7 @@
1
- import { useEffect, useLayoutEffect } from "react";
2
-
3
1
  export * from "./OverridableComponent";
4
- export * from "./useId";
5
- export { default as mergeRefs } from "./mergeRefs";
6
2
  export { default as debounce } from "./debounce";
7
-
8
- const canUseDOM = (): boolean => {
9
- return (
10
- typeof window !== "undefined" &&
11
- typeof window.document !== "undefined" &&
12
- typeof window.document.createElement !== "undefined"
13
- );
14
- };
15
-
16
- export const useClientLayoutEffect = canUseDOM() ? useLayoutEffect : () => {};
17
-
18
- export const omit = (obj: object, props: string[]) =>
19
- Object.entries(obj)
20
- .filter(([key]) => !props.includes(key))
21
- .reduce(
22
- (obj, [key, value]) => ({
23
- ...obj,
24
- [key]: value,
25
- }),
26
- {}
27
- );
28
-
29
- export interface ListenerT {
30
- addEventListener(
31
- name: string,
32
- handler: (event?: any) => void,
33
- ...args: any[]
34
- );
35
-
36
- removeEventListener(
37
- name: string,
38
- handler: (event?: any) => void,
39
- ...args: any[]
40
- );
41
- }
42
-
43
- /* https://github.com/streamich/react-use/blob/master/src/useEvent.ts */
44
- export const useEventListener = <T extends ListenerT>(
45
- name: Parameters<ListenerT["addEventListener"]>[0],
46
- handler: Parameters<ListenerT["addEventListener"]>[1],
47
- target: null | T | Window = typeof window !== "undefined" ? window : null
48
- ): void => {
49
- useEffect(() => {
50
- if (!target) {
51
- return;
52
- }
53
- target?.addEventListener(name, handler);
54
- return () => {
55
- target?.removeEventListener(name, handler);
56
- };
57
- }, [name, handler, target]);
58
- };
59
-
60
- /* https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx */
61
- export const composeEventHandlers = <E>(
62
- originalEventHandler?: (event: E) => void,
63
- ourEventHandler?: (event: E) => void
64
- ) => {
65
- return function handleEvent(event: E) {
66
- originalEventHandler?.(event);
67
-
68
- if (!(event as unknown as Event).defaultPrevented) {
69
- return ourEventHandler?.(event);
70
- }
71
- };
72
- };
3
+ export { default as mergeRefs } from "./mergeRefs";
4
+ export * from "./omit";
5
+ export * from "./useClientLayoutEffect";
6
+ export * from "./useEventListener";
7
+ export * from "./useId";
@@ -0,0 +1,10 @@
1
+ export const omit = (obj: object, props: string[]) =>
2
+ Object.entries(obj)
3
+ .filter(([key]) => !props.includes(key))
4
+ .reduce(
5
+ (obj, [key, value]) => ({
6
+ ...obj,
7
+ [key]: value,
8
+ }),
9
+ {}
10
+ );
@@ -0,0 +1,11 @@
1
+ import { useLayoutEffect } from "react";
2
+
3
+ const canUseDOM = (): boolean => {
4
+ return (
5
+ typeof window !== "undefined" &&
6
+ typeof window.document !== "undefined" &&
7
+ typeof window.document.createElement !== "undefined"
8
+ );
9
+ };
10
+
11
+ export const useClientLayoutEffect = canUseDOM() ? useLayoutEffect : () => {};