@navikt/ds-react 4.0.0 β†’ 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/_docs.json +171 -5
  2. package/cjs/accordion/Accordion.js +22 -2
  3. package/cjs/alert/Alert.js +9 -0
  4. package/cjs/button/Button.js +10 -0
  5. package/cjs/chat/Chat.js +16 -0
  6. package/cjs/chips/Chips.js +27 -0
  7. package/cjs/chips/Toggle.js +4 -6
  8. package/cjs/copybutton/CopyButton.js +11 -0
  9. package/cjs/date/DateInput.js +1 -1
  10. package/cjs/date/datepicker/DatePicker.js +22 -0
  11. package/cjs/date/hooks/useDatepicker.js +13 -0
  12. package/cjs/date/hooks/useMonthPicker.js +13 -0
  13. package/cjs/date/hooks/useRangeDatepicker.js +12 -0
  14. package/cjs/date/monthpicker/MonthPicker.js +22 -0
  15. package/cjs/dropdown/Dropdown.js +31 -0
  16. package/cjs/dropdown/Menu/GroupedList/index.js +1 -1
  17. package/cjs/dropdown/Menu/List/index.js +1 -1
  18. package/cjs/dropdown/Menu/index.js +1 -1
  19. package/cjs/expansion-card/ExpansionCard.js +18 -0
  20. package/cjs/form/ConfirmationPanel.js +18 -0
  21. package/cjs/form/Select.js +16 -0
  22. package/cjs/form/Switch.js +11 -0
  23. package/cjs/form/TextField.js +11 -0
  24. package/cjs/form/Textarea.js +11 -0
  25. package/cjs/form/checkbox/CheckboxGroup.js +15 -0
  26. package/cjs/form/error-summary/ErrorSummary.js +18 -0
  27. package/cjs/form/radio/RadioGroup.js +2 -2
  28. package/cjs/form/search/Search.js +13 -0
  29. package/cjs/guide-panel/GuidePanel.js +15 -0
  30. package/cjs/help-text/HelpText.js +13 -0
  31. package/cjs/index.js +1 -0
  32. package/cjs/internal-header/InternalHeader.js +30 -2
  33. package/cjs/link/Link.js +13 -0
  34. package/cjs/link-panel/LinkPanel.js +17 -0
  35. package/cjs/loader/Loader.js +11 -0
  36. package/cjs/modal/Modal.js +27 -0
  37. package/cjs/pagination/Pagination.js +17 -0
  38. package/cjs/panel/Panel.js +19 -0
  39. package/cjs/popover/Popover.js +20 -0
  40. package/cjs/provider/Provider.js +13 -0
  41. package/cjs/read-more/ReadMore.js +2 -2
  42. package/cjs/skeleton/Skeleton.js +51 -0
  43. package/cjs/skeleton/index.js +8 -0
  44. package/cjs/skeleton/package.json +6 -0
  45. package/cjs/stepper/Step.js +3 -4
  46. package/cjs/stepper/Stepper.js +24 -0
  47. package/cjs/table/Table.js +32 -0
  48. package/cjs/tabs/Tabs.js +27 -1
  49. package/cjs/tag/Tag.js +11 -0
  50. package/cjs/timeline/Timeline.js +18 -0
  51. package/cjs/toggle-group/ToggleGroup.js +17 -2
  52. package/cjs/tooltip/Tooltip.js +13 -0
  53. package/cjs/typography/BodyLong.js +14 -0
  54. package/cjs/typography/BodyShort.js +14 -0
  55. package/cjs/typography/Detail.js +14 -0
  56. package/cjs/typography/ErrorMessage.js +14 -0
  57. package/cjs/typography/Heading.js +14 -0
  58. package/cjs/typography/Ingress.js +14 -0
  59. package/cjs/typography/Label.js +14 -0
  60. package/esm/accordion/Accordion.d.ts +40 -6
  61. package/esm/accordion/Accordion.js +22 -2
  62. package/esm/accordion/Accordion.js.map +1 -1
  63. package/esm/accordion/AccordionContent.d.ts +1 -2
  64. package/esm/accordion/AccordionContent.js.map +1 -1
  65. package/esm/accordion/AccordionHeader.d.ts +1 -2
  66. package/esm/accordion/AccordionHeader.js.map +1 -1
  67. package/esm/accordion/AccordionItem.d.ts +1 -2
  68. package/esm/accordion/AccordionItem.js.map +1 -1
  69. package/esm/alert/Alert.d.ts +9 -0
  70. package/esm/alert/Alert.js +9 -0
  71. package/esm/alert/Alert.js.map +1 -1
  72. package/esm/button/Button.d.ts +10 -0
  73. package/esm/button/Button.js +10 -0
  74. package/esm/button/Button.js.map +1 -1
  75. package/esm/chat/Bubble.d.ts +1 -2
  76. package/esm/chat/Bubble.js.map +1 -1
  77. package/esm/chat/Chat.d.ts +21 -2
  78. package/esm/chat/Chat.js +16 -0
  79. package/esm/chat/Chat.js.map +1 -1
  80. package/esm/chips/Chips.d.ts +42 -4
  81. package/esm/chips/Chips.js +27 -0
  82. package/esm/chips/Chips.js.map +1 -1
  83. package/esm/chips/Removable.d.ts +0 -2
  84. package/esm/chips/Removable.js.map +1 -1
  85. package/esm/chips/Toggle.d.ts +11 -3
  86. package/esm/chips/Toggle.js +4 -6
  87. package/esm/chips/Toggle.js.map +1 -1
  88. package/esm/copybutton/CopyButton.d.ts +11 -0
  89. package/esm/copybutton/CopyButton.js +11 -0
  90. package/esm/copybutton/CopyButton.js.map +1 -1
  91. package/esm/date/DateInput.d.ts +2 -3
  92. package/esm/date/DateInput.js +1 -1
  93. package/esm/date/DateInput.js.map +1 -1
  94. package/esm/date/datepicker/DatePicker.d.ts +38 -2
  95. package/esm/date/datepicker/DatePicker.js +22 -0
  96. package/esm/date/datepicker/DatePicker.js.map +1 -1
  97. package/esm/date/hooks/useDatepicker.d.ts +13 -0
  98. package/esm/date/hooks/useDatepicker.js +13 -0
  99. package/esm/date/hooks/useDatepicker.js.map +1 -1
  100. package/esm/date/hooks/useMonthPicker.d.ts +13 -0
  101. package/esm/date/hooks/useMonthPicker.js +13 -0
  102. package/esm/date/hooks/useMonthPicker.js.map +1 -1
  103. package/esm/date/hooks/useRangeDatepicker.d.ts +12 -0
  104. package/esm/date/hooks/useRangeDatepicker.js +12 -0
  105. package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
  106. package/esm/date/monthpicker/MonthPicker.d.ts +34 -4
  107. package/esm/date/monthpicker/MonthPicker.js +22 -0
  108. package/esm/date/monthpicker/MonthPicker.js.map +1 -1
  109. package/esm/dropdown/Dropdown.d.ts +39 -2
  110. package/esm/dropdown/Dropdown.js +31 -0
  111. package/esm/dropdown/Dropdown.js.map +1 -1
  112. package/esm/dropdown/Menu/Divider.d.ts +1 -2
  113. package/esm/dropdown/Menu/Divider.js.map +1 -1
  114. package/esm/dropdown/Menu/GroupedList/Heading.d.ts +1 -2
  115. package/esm/dropdown/Menu/GroupedList/Heading.js.map +1 -1
  116. package/esm/dropdown/Menu/GroupedList/Item.d.ts +1 -2
  117. package/esm/dropdown/Menu/GroupedList/Item.js.map +1 -1
  118. package/esm/dropdown/Menu/GroupedList/index.d.ts +12 -4
  119. package/esm/dropdown/Menu/GroupedList/index.js +1 -1
  120. package/esm/dropdown/Menu/GroupedList/index.js.map +1 -1
  121. package/esm/dropdown/Menu/List/Item.d.ts +1 -2
  122. package/esm/dropdown/Menu/List/Item.js.map +1 -1
  123. package/esm/dropdown/Menu/List/index.d.ts +7 -2
  124. package/esm/dropdown/Menu/List/index.js +1 -1
  125. package/esm/dropdown/Menu/List/index.js.map +1 -1
  126. package/esm/dropdown/Menu/index.d.ts +10 -2
  127. package/esm/dropdown/Menu/index.js +1 -1
  128. package/esm/dropdown/Menu/index.js.map +1 -1
  129. package/esm/dropdown/Toggle.d.ts +1 -2
  130. package/esm/dropdown/Toggle.js.map +1 -1
  131. package/esm/expansion-card/ExpansionCard.d.ts +40 -8
  132. package/esm/expansion-card/ExpansionCard.js +18 -0
  133. package/esm/expansion-card/ExpansionCard.js.map +1 -1
  134. package/esm/expansion-card/ExpansionCardContent.d.ts +1 -2
  135. package/esm/expansion-card/ExpansionCardContent.js.map +1 -1
  136. package/esm/expansion-card/ExpansionCardDescription.d.ts +2 -4
  137. package/esm/expansion-card/ExpansionCardDescription.js.map +1 -1
  138. package/esm/expansion-card/ExpansionCardHeader.d.ts +1 -2
  139. package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
  140. package/esm/expansion-card/ExpansionCardTitle.d.ts +2 -4
  141. package/esm/expansion-card/ExpansionCardTitle.js.map +1 -1
  142. package/esm/form/ConfirmationPanel.d.ts +18 -0
  143. package/esm/form/ConfirmationPanel.js +18 -0
  144. package/esm/form/ConfirmationPanel.js.map +1 -1
  145. package/esm/form/Select.d.ts +16 -0
  146. package/esm/form/Select.js +16 -0
  147. package/esm/form/Select.js.map +1 -1
  148. package/esm/form/Switch.d.ts +11 -0
  149. package/esm/form/Switch.js +11 -0
  150. package/esm/form/Switch.js.map +1 -1
  151. package/esm/form/TextField.d.ts +11 -0
  152. package/esm/form/TextField.js +11 -0
  153. package/esm/form/TextField.js.map +1 -1
  154. package/esm/form/Textarea.d.ts +11 -0
  155. package/esm/form/Textarea.js +11 -0
  156. package/esm/form/Textarea.js.map +1 -1
  157. package/esm/form/checkbox/CheckboxGroup.d.ts +15 -0
  158. package/esm/form/checkbox/CheckboxGroup.js +15 -0
  159. package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
  160. package/esm/form/error-summary/ErrorSummary.d.ts +18 -0
  161. package/esm/form/error-summary/ErrorSummary.js +18 -0
  162. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  163. package/esm/form/radio/RadioGroup.d.ts +2 -2
  164. package/esm/form/radio/RadioGroup.js +2 -2
  165. package/esm/form/search/Search.d.ts +13 -0
  166. package/esm/form/search/Search.js +13 -0
  167. package/esm/form/search/Search.js.map +1 -1
  168. package/esm/guide-panel/GuidePanel.d.ts +15 -0
  169. package/esm/guide-panel/GuidePanel.js +15 -0
  170. package/esm/guide-panel/GuidePanel.js.map +1 -1
  171. package/esm/help-text/HelpText.d.ts +13 -0
  172. package/esm/help-text/HelpText.js +13 -0
  173. package/esm/help-text/HelpText.js.map +1 -1
  174. package/esm/index.d.ts +1 -0
  175. package/esm/index.js +1 -0
  176. package/esm/index.js.map +1 -1
  177. package/esm/internal-header/InternalHeader.d.ts +52 -8
  178. package/esm/internal-header/InternalHeader.js +30 -2
  179. package/esm/internal-header/InternalHeader.js.map +1 -1
  180. package/esm/internal-header/InternalHeaderButton.d.ts +1 -2
  181. package/esm/internal-header/InternalHeaderButton.js.map +1 -1
  182. package/esm/internal-header/InternalHeaderTitle.d.ts +1 -2
  183. package/esm/internal-header/InternalHeaderTitle.js.map +1 -1
  184. package/esm/internal-header/InternalHeaderUser.d.ts +0 -1
  185. package/esm/internal-header/InternalHeaderUser.js.map +1 -1
  186. package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -2
  187. package/esm/internal-header/InternalHeaderUserButton.js.map +1 -1
  188. package/esm/link/Link.d.ts +13 -0
  189. package/esm/link/Link.js +13 -0
  190. package/esm/link/Link.js.map +1 -1
  191. package/esm/link-panel/LinkPanel.d.ts +28 -4
  192. package/esm/link-panel/LinkPanel.js +17 -0
  193. package/esm/link-panel/LinkPanel.js.map +1 -1
  194. package/esm/link-panel/LinkPanelDescription.d.ts +2 -4
  195. package/esm/link-panel/LinkPanelDescription.js.map +1 -1
  196. package/esm/link-panel/LinkPanelTitle.d.ts +2 -4
  197. package/esm/link-panel/LinkPanelTitle.js.map +1 -1
  198. package/esm/list/List.d.ts +5 -2
  199. package/esm/list/List.js.map +1 -1
  200. package/esm/list/ListItem.d.ts +1 -3
  201. package/esm/list/ListItem.js.map +1 -1
  202. package/esm/loader/Loader.d.ts +11 -0
  203. package/esm/loader/Loader.js +11 -0
  204. package/esm/loader/Loader.js.map +1 -1
  205. package/esm/modal/Modal.d.ts +27 -0
  206. package/esm/modal/Modal.js +27 -0
  207. package/esm/modal/Modal.js.map +1 -1
  208. package/esm/pagination/Pagination.d.ts +17 -0
  209. package/esm/pagination/Pagination.js +17 -0
  210. package/esm/pagination/Pagination.js.map +1 -1
  211. package/esm/panel/Panel.d.ts +19 -0
  212. package/esm/panel/Panel.js +19 -0
  213. package/esm/panel/Panel.js.map +1 -1
  214. package/esm/popover/Popover.d.ts +20 -0
  215. package/esm/popover/Popover.js +20 -0
  216. package/esm/popover/Popover.js.map +1 -1
  217. package/esm/provider/Provider.d.ts +13 -0
  218. package/esm/provider/Provider.js +13 -0
  219. package/esm/provider/Provider.js.map +1 -1
  220. package/esm/read-more/ReadMore.d.ts +2 -2
  221. package/esm/read-more/ReadMore.js +2 -2
  222. package/esm/skeleton/Skeleton.d.ts +18 -0
  223. package/esm/skeleton/Skeleton.js +23 -0
  224. package/esm/skeleton/Skeleton.js.map +1 -0
  225. package/esm/skeleton/index.d.ts +2 -0
  226. package/esm/skeleton/index.js +2 -0
  227. package/esm/skeleton/index.js.map +1 -0
  228. package/esm/stepper/Step.d.ts +1 -4
  229. package/esm/stepper/Step.js +1 -2
  230. package/esm/stepper/Step.js.map +1 -1
  231. package/esm/stepper/Stepper.d.ts +31 -2
  232. package/esm/stepper/Stepper.js +24 -0
  233. package/esm/stepper/Stepper.js.map +1 -1
  234. package/esm/table/Table.d.ts +32 -0
  235. package/esm/table/Table.js +32 -0
  236. package/esm/table/Table.js.map +1 -1
  237. package/esm/tabs/Tab.d.ts +1 -2
  238. package/esm/tabs/Tab.js.map +1 -1
  239. package/esm/tabs/TabList.d.ts +1 -2
  240. package/esm/tabs/TabList.js.map +1 -1
  241. package/esm/tabs/TabPanel.d.ts +1 -2
  242. package/esm/tabs/TabPanel.js.map +1 -1
  243. package/esm/tabs/Tabs.d.ts +43 -6
  244. package/esm/tabs/Tabs.js +27 -1
  245. package/esm/tabs/Tabs.js.map +1 -1
  246. package/esm/tag/Tag.d.ts +11 -0
  247. package/esm/tag/Tag.js +11 -0
  248. package/esm/tag/Tag.js.map +1 -1
  249. package/esm/timeline/Timeline.d.ts +22 -4
  250. package/esm/timeline/Timeline.js +18 -0
  251. package/esm/timeline/Timeline.js.map +1 -1
  252. package/esm/toggle-group/ToggleGroup.d.ts +20 -2
  253. package/esm/toggle-group/ToggleGroup.js +17 -2
  254. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  255. package/esm/toggle-group/ToggleItem.d.ts +1 -2
  256. package/esm/toggle-group/ToggleItem.js.map +1 -1
  257. package/esm/tooltip/Tooltip.d.ts +13 -0
  258. package/esm/tooltip/Tooltip.js +13 -0
  259. package/esm/tooltip/Tooltip.js.map +1 -1
  260. package/esm/typography/BodyLong.d.ts +14 -0
  261. package/esm/typography/BodyLong.js +14 -0
  262. package/esm/typography/BodyLong.js.map +1 -1
  263. package/esm/typography/BodyShort.d.ts +14 -0
  264. package/esm/typography/BodyShort.js +14 -0
  265. package/esm/typography/BodyShort.js.map +1 -1
  266. package/esm/typography/Detail.d.ts +14 -0
  267. package/esm/typography/Detail.js +14 -0
  268. package/esm/typography/Detail.js.map +1 -1
  269. package/esm/typography/ErrorMessage.d.ts +14 -0
  270. package/esm/typography/ErrorMessage.js +14 -0
  271. package/esm/typography/ErrorMessage.js.map +1 -1
  272. package/esm/typography/Heading.d.ts +14 -0
  273. package/esm/typography/Heading.js +14 -0
  274. package/esm/typography/Heading.js.map +1 -1
  275. package/esm/typography/Ingress.d.ts +14 -0
  276. package/esm/typography/Ingress.js +14 -0
  277. package/esm/typography/Ingress.js.map +1 -1
  278. package/esm/typography/Label.d.ts +14 -0
  279. package/esm/typography/Label.js +14 -0
  280. package/esm/typography/Label.js.map +1 -1
  281. package/package.json +2 -2
  282. package/src/accordion/Accordion.tsx +49 -7
  283. package/src/accordion/AccordionContent.tsx +1 -5
  284. package/src/accordion/AccordionHeader.tsx +1 -5
  285. package/src/accordion/AccordionItem.tsx +1 -5
  286. package/src/accordion/accordion.stories.tsx +4 -2
  287. package/src/alert/Alert.tsx +9 -0
  288. package/src/button/Button.tsx +10 -0
  289. package/src/chat/Bubble.tsx +1 -5
  290. package/src/chat/Chat.tsx +23 -2
  291. package/src/chips/Chips.tsx +42 -4
  292. package/src/chips/Removable.tsx +1 -4
  293. package/src/chips/Toggle.tsx +47 -11
  294. package/src/chips/chips.stories.tsx +73 -20
  295. package/src/copybutton/CopyButton.tsx +11 -0
  296. package/src/date/DateInput.tsx +105 -115
  297. package/src/date/datepicker/DatePicker.tsx +40 -2
  298. package/src/date/hooks/useDatepicker.tsx +13 -0
  299. package/src/date/hooks/useMonthPicker.tsx +13 -0
  300. package/src/date/hooks/useRangeDatepicker.tsx +13 -1
  301. package/src/date/monthpicker/MonthPicker.tsx +36 -4
  302. package/src/dropdown/Dropdown.tsx +41 -2
  303. package/src/dropdown/Menu/Divider.tsx +10 -13
  304. package/src/dropdown/Menu/GroupedList/Heading.tsx +15 -18
  305. package/src/dropdown/Menu/GroupedList/Item.tsx +23 -27
  306. package/src/dropdown/Menu/GroupedList/index.tsx +15 -5
  307. package/src/dropdown/Menu/List/Item.tsx +3 -9
  308. package/src/dropdown/Menu/List/index.tsx +8 -3
  309. package/src/dropdown/Menu/index.tsx +14 -3
  310. package/src/dropdown/Toggle.tsx +1 -5
  311. package/src/expansion-card/ExpansionCard.tsx +46 -8
  312. package/src/expansion-card/ExpansionCardContent.tsx +25 -28
  313. package/src/expansion-card/ExpansionCardDescription.tsx +22 -24
  314. package/src/expansion-card/ExpansionCardHeader.tsx +31 -34
  315. package/src/expansion-card/ExpansionCardTitle.tsx +3 -5
  316. package/src/form/ConfirmationPanel.tsx +18 -0
  317. package/src/form/Select.tsx +16 -0
  318. package/src/form/Switch.tsx +11 -0
  319. package/src/form/TextField.tsx +11 -0
  320. package/src/form/Textarea.tsx +11 -0
  321. package/src/form/checkbox/CheckboxGroup.tsx +15 -0
  322. package/src/form/error-summary/ErrorSummary.tsx +18 -0
  323. package/src/form/radio/RadioGroup.tsx +2 -2
  324. package/src/form/search/Search.tsx +13 -0
  325. package/src/guide-panel/GuidePanel.tsx +15 -0
  326. package/src/help-text/HelpText.tsx +13 -0
  327. package/src/index.ts +1 -0
  328. package/src/internal-header/InternalHeader.tsx +60 -11
  329. package/src/internal-header/InternalHeaderButton.tsx +8 -13
  330. package/src/internal-header/InternalHeaderTitle.tsx +11 -19
  331. package/src/internal-header/InternalHeaderUser.tsx +0 -4
  332. package/src/internal-header/InternalHeaderUserButton.tsx +17 -20
  333. package/src/link/Link.tsx +13 -0
  334. package/src/link-panel/LinkPanel.tsx +30 -4
  335. package/src/link-panel/LinkPanelDescription.tsx +12 -15
  336. package/src/link-panel/LinkPanelTitle.tsx +15 -18
  337. package/src/list/List.tsx +7 -2
  338. package/src/list/ListItem.tsx +1 -6
  339. package/src/loader/Loader.tsx +11 -0
  340. package/src/modal/Modal.tsx +27 -0
  341. package/src/pagination/Pagination.tsx +17 -0
  342. package/src/panel/Panel.tsx +19 -0
  343. package/src/popover/Popover.tsx +20 -0
  344. package/src/provider/Provider.tsx +13 -0
  345. package/src/read-more/ReadMore.tsx +2 -2
  346. package/src/skeleton/Skeleton.tsx +48 -0
  347. package/src/skeleton/index.ts +2 -0
  348. package/src/skeleton/skeleton.stories.tsx +118 -0
  349. package/src/stepper/Step.tsx +57 -60
  350. package/src/stepper/Stepper.tsx +31 -2
  351. package/src/table/Table.tsx +32 -0
  352. package/src/tabs/Tab.tsx +38 -39
  353. package/src/tabs/TabList.tsx +1 -5
  354. package/src/tabs/TabPanel.tsx +1 -5
  355. package/src/tabs/Tabs.tsx +48 -7
  356. package/src/tag/Tag.tsx +11 -0
  357. package/src/timeline/Timeline.tsx +22 -4
  358. package/src/toggle-group/ToggleGroup.tsx +23 -3
  359. package/src/toggle-group/ToggleItem.tsx +1 -5
  360. package/src/tooltip/Tooltip.tsx +13 -0
  361. package/src/typography/BodyLong.tsx +14 -0
  362. package/src/typography/BodyShort.tsx +14 -0
  363. package/src/typography/Detail.tsx +14 -0
  364. package/src/typography/ErrorMessage.tsx +14 -0
  365. package/src/typography/Heading.tsx +14 -0
  366. package/src/typography/Ingress.tsx +14 -0
  367. package/src/typography/Label.tsx +14 -0
@@ -66,25 +66,78 @@ export const Default = {
66
66
  };
67
67
 
68
68
  export const Toggle = () => {
69
- const [selected, setSelected] = useState<number[]>([]);
69
+ const [selected, setSelected] = useState<number[]>([2, 4]);
70
70
  return (
71
- <Chips>
72
- {options.map((c, y) => (
73
- <Chips.Toggle
74
- selected={selected.includes(y)}
75
- onClick={() =>
76
- setSelected(
77
- selected.includes(y)
78
- ? selected.filter((x) => x !== y)
79
- : [...selected, y]
80
- )
81
- }
82
- key={y}
83
- >
84
- {c}
85
- </Chips.Toggle>
86
- ))}
87
- </Chips>
71
+ <div className="colgap">
72
+ <Chips>
73
+ {options.map((c, y) => (
74
+ <Chips.Toggle
75
+ selected={selected.includes(y)}
76
+ onClick={() =>
77
+ setSelected(
78
+ selected.includes(y)
79
+ ? selected.filter((x) => x !== y)
80
+ : [...selected, y]
81
+ )
82
+ }
83
+ key={y}
84
+ >
85
+ {c}
86
+ </Chips.Toggle>
87
+ ))}
88
+ </Chips>
89
+ <Chips>
90
+ {options.map((c, y) => (
91
+ <Chips.Toggle
92
+ variant="neutral"
93
+ selected={selected.includes(y)}
94
+ onClick={() =>
95
+ setSelected(
96
+ selected.includes(y)
97
+ ? selected.filter((x) => x !== y)
98
+ : [...selected, y]
99
+ )
100
+ }
101
+ key={y}
102
+ >
103
+ {c}
104
+ </Chips.Toggle>
105
+ ))}
106
+ </Chips>
107
+ </div>
108
+ );
109
+ };
110
+
111
+ export const ToggleNoCheckmark = () => {
112
+ const [selected, setSelected] = useState<number>(2);
113
+ return (
114
+ <div className="colgap">
115
+ <Chips>
116
+ {options.map((c, y) => (
117
+ <Chips.Toggle
118
+ selected={selected === y}
119
+ checkmark={false}
120
+ onClick={() => setSelected(y)}
121
+ key={y}
122
+ >
123
+ {c}
124
+ </Chips.Toggle>
125
+ ))}
126
+ </Chips>
127
+ <Chips>
128
+ {options.map((c, y) => (
129
+ <Chips.Toggle
130
+ variant="neutral"
131
+ selected={selected === y}
132
+ checkmark={false}
133
+ onClick={() => setSelected(y)}
134
+ key={y}
135
+ >
136
+ {c}
137
+ </Chips.Toggle>
138
+ ))}
139
+ </Chips>
140
+ </div>
88
141
  );
89
142
  };
90
143
 
@@ -108,7 +161,7 @@ export const Removable = () => {
108
161
  };
109
162
 
110
163
  export const Regular = () => {
111
- const [selected, setSelected] = useState<number[]>([]);
164
+ const [selected, setSelected] = useState<number[]>([2]);
112
165
  return (
113
166
  <div className="colgap">
114
167
  <Chips>
@@ -138,7 +191,7 @@ export const Regular = () => {
138
191
  };
139
192
 
140
193
  export const Small = () => {
141
- const [selected, setSelected] = useState<number[]>([]);
194
+ const [selected, setSelected] = useState<number[]>([2, 4]);
142
195
  return (
143
196
  <div className="colgap">
144
197
  <Chips size="small">
@@ -65,6 +65,17 @@ export interface CopyButtonProps
65
65
  activeTitle?: string;
66
66
  }
67
67
 
68
+ /**
69
+ * A button component that copies text to the clipboard when clicked.
70
+ *
71
+ * @see [πŸ“ Documentation](https://aksel.nav.no/komponenter/core/copybutton)
72
+ * @see 🏷️ {@link CopyButtonProps}
73
+ *
74
+ * @example
75
+ * ```jsx
76
+ <CopyButton copyText="3.14" />
77
+ * ```
78
+ */
68
79
  export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
69
80
  (
70
81
  {
@@ -28,131 +28,121 @@ export interface DateInputProps
28
28
  variant?: "datepicker" | "monthpicker";
29
29
  }
30
30
 
31
- export type DateInputType = React.ForwardRefExoticComponent<
32
- DateInputProps & React.RefAttributes<HTMLInputElement>
33
- >;
31
+ const DateInput = forwardRef<HTMLInputElement, DateInputProps>((props, ref) => {
32
+ const {
33
+ className,
34
+ hideLabel = false,
35
+ label,
36
+ description,
37
+ variant = "datepicker",
38
+ ...rest
39
+ } = props;
34
40
 
35
- const DateInput: DateInputType = forwardRef<HTMLInputElement, DateInputProps>(
36
- (props, ref) => {
37
- const {
38
- className,
39
- hideLabel = false,
40
- label,
41
- description,
42
- variant = "datepicker",
43
- ...rest
44
- } = props;
41
+ const isDatepickerVariant = variant === "datepicker";
45
42
 
46
- const isDatepickerVariant = variant === "datepicker";
43
+ const conditionalVariables = {
44
+ prefix: isDatepickerVariant ? "datepicker-input" : "monthpicker-input",
45
+ iconTitle: {
46
+ open: isDatepickerVariant ? "Γ…pne datovelger" : "Γ…pne mΓ₯nedsvelger",
47
+ close: isDatepickerVariant ? "Lukk datovelger" : "Lukk mΓ₯nedsvelger",
48
+ },
49
+ };
47
50
 
48
- const conditionalVariables = {
49
- prefix: isDatepickerVariant ? "datepicker-input" : "monthpicker-input",
50
- iconTitle: {
51
- open: isDatepickerVariant ? "Γ…pne datovelger" : "Γ…pne mΓ₯nedsvelger",
52
- close: isDatepickerVariant ? "Lukk datovelger" : "Lukk mΓ₯nedsvelger",
53
- },
54
- };
51
+ const { onOpen, ariaId, open } = useDateInputContext();
55
52
 
56
- const { onOpen, ariaId, open } = useDateInputContext();
53
+ const {
54
+ inputProps,
55
+ size = "medium",
56
+ inputDescriptionId,
57
+ errorId,
58
+ showErrorMsg,
59
+ hasError,
60
+ } = useFormField(props, conditionalVariables.prefix);
57
61
 
58
- const {
59
- inputProps,
60
- size = "medium",
61
- inputDescriptionId,
62
- errorId,
63
- showErrorMsg,
64
- hasError,
65
- } = useFormField(props, conditionalVariables.prefix);
66
-
67
- return (
68
- <div
69
- className={cl(
70
- className,
71
- "navds-form-field",
72
- `navds-form-field--${size}`,
73
- "navds-date__field",
74
- {
75
- "navds-text-field--error": hasError,
76
- "navds-date__field--error": hasError,
77
- "navds-form-field--disabled": !!inputProps.disabled,
78
- "navds-text-field--disabled": !!inputProps.disabled,
79
- }
80
- )}
62
+ return (
63
+ <div
64
+ className={cl(
65
+ className,
66
+ "navds-form-field",
67
+ `navds-form-field--${size}`,
68
+ "navds-date__field",
69
+ {
70
+ "navds-text-field--error": hasError,
71
+ "navds-date__field--error": hasError,
72
+ "navds-form-field--disabled": !!inputProps.disabled,
73
+ "navds-text-field--disabled": !!inputProps.disabled,
74
+ }
75
+ )}
76
+ >
77
+ <Label
78
+ htmlFor={inputProps.id}
79
+ size={size}
80
+ className={cl("navds-form-field__label", {
81
+ "navds-sr-only": hideLabel,
82
+ })}
81
83
  >
82
- <Label
83
- htmlFor={inputProps.id}
84
- size={size}
85
- className={cl("navds-form-field__label", {
84
+ {label}
85
+ </Label>
86
+ {!!description && (
87
+ <BodyShort
88
+ as="div"
89
+ className={cl("navds-form-field__description", {
86
90
  "navds-sr-only": hideLabel,
87
91
  })}
92
+ id={inputDescriptionId}
93
+ size={size}
88
94
  >
89
- {label}
90
- </Label>
91
- {!!description && (
92
- <BodyShort
93
- as="div"
94
- className={cl("navds-form-field__description", {
95
- "navds-sr-only": hideLabel,
96
- })}
97
- id={inputDescriptionId}
98
- size={size}
99
- >
100
- {description}
101
- </BodyShort>
102
- )}
103
- <div className="navds-date__field-wrapper">
104
- <input
105
- ref={ref}
106
- {...omit(rest, ["error", "errorId", "size"])}
107
- {...inputProps}
108
- autoComplete="off"
109
- aria-controls={ariaId}
110
- className={cl(
111
- "navds-date__field-input",
112
- "navds-text-field__input",
113
- "navds-body-short",
114
- `navds-body-${size}`
115
- )}
116
- size={14}
117
- />
118
- <button
119
- disabled={inputProps.disabled}
120
- tabIndex={open ? -1 : 0}
121
- onClick={() => onOpen()}
122
- type="button"
123
- className="navds-date__field-button"
124
- >
125
- <CalendarIcon
126
- pointerEvents="none"
127
- title={
128
- open
129
- ? conditionalVariables.iconTitle.close
130
- : conditionalVariables.iconTitle.open
131
- }
132
- />
133
- </button>
134
- </div>
135
- <div
136
- className="navds-form-field__error"
137
- id={errorId}
138
- aria-relevant="additions removals"
139
- aria-live="polite"
140
- >
141
- {showErrorMsg && (
142
- <ErrorMessage size={size}>{props.error}</ErrorMessage>
95
+ {description}
96
+ </BodyShort>
97
+ )}
98
+ <div className="navds-date__field-wrapper">
99
+ <input
100
+ ref={ref}
101
+ {...omit(rest, ["error", "errorId", "size"])}
102
+ {...inputProps}
103
+ autoComplete="off"
104
+ aria-controls={ariaId}
105
+ className={cl(
106
+ "navds-date__field-input",
107
+ "navds-text-field__input",
108
+ "navds-body-short",
109
+ `navds-body-${size}`
143
110
  )}
144
- </div>
111
+ size={14}
112
+ />
113
+ <button
114
+ disabled={inputProps.disabled}
115
+ tabIndex={open ? -1 : 0}
116
+ onClick={() => onOpen()}
117
+ type="button"
118
+ className="navds-date__field-button"
119
+ >
120
+ <CalendarIcon
121
+ pointerEvents="none"
122
+ title={
123
+ open
124
+ ? conditionalVariables.iconTitle.close
125
+ : conditionalVariables.iconTitle.open
126
+ }
127
+ />
128
+ </button>
145
129
  </div>
146
- );
147
- }
148
- );
130
+ <div
131
+ className="navds-form-field__error"
132
+ id={errorId}
133
+ aria-relevant="additions removals"
134
+ aria-live="polite"
135
+ >
136
+ {showErrorMsg && <ErrorMessage size={size}>{props.error}</ErrorMessage>}
137
+ </div>
138
+ </div>
139
+ );
140
+ });
149
141
 
150
- export const DatePickerInput: DateInputType = forwardRef<
151
- HTMLInputElement,
152
- DateInputProps
153
- >((props, ref) => <DateInput {...props} ref={ref} />);
142
+ export const DatePickerInput = forwardRef<HTMLInputElement, DateInputProps>(
143
+ (props, ref) => <DateInput {...props} ref={ref} />
144
+ );
154
145
 
155
- export const MonthPickerInput: DateInputType = forwardRef<
156
- HTMLInputElement,
157
- DateInputProps
158
- >((props, ref) => <DateInput {...props} variant="monthpicker" ref={ref} />);
146
+ export const MonthPickerInput = forwardRef<HTMLInputElement, DateInputProps>(
147
+ (props, ref) => <DateInput {...props} variant="monthpicker" ref={ref} />
148
+ );
@@ -12,7 +12,7 @@ import {
12
12
  SelectSingleEventHandler,
13
13
  } from "react-day-picker";
14
14
  import { omit, Popover, useId } from "../..";
15
- import { DateInputType, DatePickerInput } from "../DateInput";
15
+ import { DateInputProps, DatePickerInput } from "../DateInput";
16
16
  import { DateContext } from "../context";
17
17
  import { getLocaleFromString, labels } from "../utils";
18
18
  import { Caption, DropdownCaption } from "./caption";
@@ -120,10 +120,48 @@ export type DatePickerProps = DatePickerDefaultProps & ConditionalModeProps;
120
120
 
121
121
  interface DatePickerComponent
122
122
  extends React.ForwardRefExoticComponent<DatePickerProps> {
123
+ /**
124
+ * @example
125
+ * ```jsx
126
+ * <DatePicker.Standalone
127
+ * dropdownCaption
128
+ * fromDate={new Date("2020-10-01")}
129
+ * toDate={new Date("2024-10-01")}
130
+ * />
131
+ * ```
132
+ */
123
133
  Standalone: DatePickerStandaloneType;
124
- Input: DateInputType;
134
+ /**
135
+ * Custom TextField for DatePicker
136
+ * @see 🏷️ {@link DateInputProps}
137
+ */
138
+ Input: React.ForwardRefExoticComponent<
139
+ DateInputProps & React.RefAttributes<HTMLInputElement>
140
+ >;
125
141
  }
126
142
 
143
+ /**
144
+ * A component that allows users to select a date from a calendar.
145
+ *
146
+ * @see [πŸ“ Documentation](https://aksel.nav.no/komponenter/core/datepicker)
147
+ * @see 🏷️ {@link DatePickerProps}
148
+ *
149
+ * @example
150
+ * ```jsx
151
+ * const { inputProps, datepickerProps } = useMonthpicker({
152
+ * onMonthChange: console.log,
153
+ * });
154
+ *
155
+ * return (
156
+ * <DatePicker {...datepickerProps} dropdownCaption>
157
+ * <DatePicker.Input
158
+ * {...inputProps}
159
+ * label="Velg dato"
160
+ * />
161
+ * </DatePicker>
162
+ * );
163
+ * ```
164
+ */
127
165
  export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
128
166
  (
129
167
  {
@@ -113,6 +113,19 @@ const getValidationMessage = (val = {}): DateValidationT => ({
113
113
  ...val,
114
114
  });
115
115
 
116
+ /**
117
+ *
118
+ * @see 🏷️ {@link UseDatepickerOptions}
119
+ * @see 🏷️ {@link UseDatepickerValue}
120
+ * @see 🏷️ {@link DateValidationT}
121
+ * @example
122
+ * const { datepickerProps, inputProps } = useDatepicker({
123
+ * fromDate: new Date("Aug 23 2019"),
124
+ * toDate: new Date("Feb 23 2024"),
125
+ * onDateChange: console.log,
126
+ * onValidate: console.log,
127
+ * });
128
+ */
116
129
  export const useDatepicker = (
117
130
  opt: UseDatepickerOptions = {}
118
131
  ): UseDatepickerValue => {
@@ -110,6 +110,19 @@ const getIsAfter = (opt: { toDate?: Date; date?: Date }) =>
110
110
  (opt.toDate.getFullYear() === opt.date.getFullYear() &&
111
111
  opt.toDate.getMonth() < opt.date.getMonth()));
112
112
 
113
+ /**
114
+ *
115
+ * @see 🏷️ {@link UseMonthPickerOptions}
116
+ * @see 🏷️ {@link UseMonthPickerValue}
117
+ * @see 🏷️ {@link MonthValidationT}
118
+ * @example
119
+ * const { monthpickerProps, inputProps } = useMonthpicker({
120
+ * fromDate: new Date("Aug 23 2019"),
121
+ * toDate: new Date("Feb 23 2024"),
122
+ * onMonthChange: console.log,
123
+ * onValidate: console.log,
124
+ * });
125
+ */
113
126
  export const useMonthpicker = (
114
127
  opt: UseMonthPickerOptions = {}
115
128
  ): UseMonthPickerValue => {
@@ -102,7 +102,7 @@ const RANGE = {
102
102
  TO: "TO",
103
103
  } as const;
104
104
 
105
- type RangeT = typeof RANGE[keyof typeof RANGE];
105
+ type RangeT = (typeof RANGE)[keyof typeof RANGE];
106
106
 
107
107
  const fromValidation = (day: Date, opt?: UseRangeDatepickerOptions) => {
108
108
  const isBefore =
@@ -190,6 +190,18 @@ const initialValidation = (
190
190
  return getValidationMessage({ ...fromVal }, { ...toVal });
191
191
  };
192
192
 
193
+ /**
194
+ *
195
+ * @see 🏷️ {@link UseRangeDatepickerOptions}
196
+ * @see 🏷️ {@link UseRangeDatepickerValue}
197
+ * @see 🏷️ {@link RangeValidationT}
198
+ * @example
199
+ * const { datepickerProps, fromInputProps, toInputProps } = useRangeDatepicker({
200
+ * fromDate: new Date("Aug 23 2019"),
201
+ * onRangeChange: console.log,
202
+ * onValidate: console.log,
203
+ * });
204
+ */
193
205
  export const useRangeDatepicker = (
194
206
  opt: UseRangeDatepickerOptions = {}
195
207
  ): UseRangeDatepickerValue => {
@@ -2,7 +2,7 @@ import cl from "clsx";
2
2
  import React, { forwardRef, useRef, useState } from "react";
3
3
  import { RootProvider } from "react-day-picker";
4
4
  import { Popover, useId } from "../..";
5
- import { DateInputType, MonthPickerInput } from "../DateInput";
5
+ import { DateInputProps, MonthPickerInput } from "../DateInput";
6
6
  import { DateContext, SharedMonthProvider } from "../context";
7
7
  import { getLocaleFromString, Matcher } from "../utils";
8
8
  import MonthCaption from "./MonthCaption";
@@ -91,15 +91,47 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
91
91
  interface MonthPickerComponent
92
92
  extends React.ForwardRefExoticComponent<MonthPickerProps> {
93
93
  /**
94
- * Variant without popover
94
+ * @example
95
+ * ```jsx
96
+ * <MonthPicker.Standalone
97
+ * dropdownCaption
98
+ * fromDate={new Date("1 Oct 2020")}
99
+ * toDate={new Date("1 Oct 2024")}
100
+ * />
101
+ * ```
95
102
  */
96
103
  Standalone: MonthPickerStandaloneType;
97
104
  /**
98
- * Built-in Inputfield
105
+ * Custom TextField for MonthPicker
106
+ * @see 🏷️ {@link DateInputProps}
99
107
  */
100
- Input: DateInputType;
108
+ Input: React.ForwardRefExoticComponent<
109
+ DateInputProps & React.RefAttributes<HTMLInputElement>
110
+ >;
101
111
  }
102
112
 
113
+ /**
114
+ * A component that displays a month picker.
115
+ *
116
+ * @see [πŸ“ Documentation](https://aksel.nav.no/komponenter/core/monthpicker)
117
+ * @see 🏷️ {@link MonthPickerProps}
118
+ *
119
+ * @example
120
+ * ```jsx
121
+ * const { inputProps, monthpickerProps } = useMonthpicker({
122
+ * onMonthChange: console.log,
123
+ * });
124
+ *
125
+ * return (
126
+ * <MonthPicker {...monthpickerProps} dropdownCaption>
127
+ * <MonthPicker.Input
128
+ * {...inputProps}
129
+ * label="Velg mΓ₯ned"
130
+ * />
131
+ * </MonthPicker>
132
+ * );
133
+ * ```
134
+ */
103
135
  export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
104
136
  (
105
137
  {
@@ -1,5 +1,5 @@
1
1
  import React, { createContext, useState } from "react";
2
- import Toggle, { ToggleType } from "./Toggle";
2
+ import Toggle, { ToggleProps } from "./Toggle";
3
3
  import Menu, { MenuType } from "./Menu";
4
4
 
5
5
  export interface DropdownProps {
@@ -24,7 +24,15 @@ export interface DropdownProps {
24
24
  }
25
25
 
26
26
  export interface DropdownType extends React.FC<DropdownProps> {
27
- Toggle: ToggleType;
27
+ /**
28
+ * @see 🏷️ {@link ToggleProps}
29
+ */
30
+ Toggle: React.ForwardRefExoticComponent<
31
+ ToggleProps & React.RefAttributes<HTMLButtonElement>
32
+ >;
33
+ /**
34
+ * @see 🏷️ {@link MenuType}
35
+ */
28
36
  Menu: MenuType;
29
37
  }
30
38
 
@@ -38,6 +46,37 @@ export interface DropdownContextType {
38
46
 
39
47
  export const DropdownContext = createContext<DropdownContextType | null>(null);
40
48
 
49
+ /**
50
+ * A component that displays a dropdown menu when the user clicks on its toggle button.
51
+ *
52
+ * @see [πŸ“ Documentation](https://aksel.nav.no/komponenter/core/dropdown)
53
+ * @see 🏷️ {@link DropdownProps}
54
+ *
55
+ * @example
56
+ * ```jsx
57
+ * <Dropdown>
58
+ * <Button as={Dropdown.Toggle}>Toggle</Button>
59
+ * <Dropdown.Menu>
60
+ * <Dropdown.Menu.GroupedList>
61
+ * <Dropdown.Menu.GroupedList.Heading>
62
+ * Systemer og oppslagsverk
63
+ * </Dropdown.Menu.GroupedList.Heading>
64
+ * <Dropdown.Menu.GroupedList.Item>
65
+ * Gosys
66
+ * </Dropdown.Menu.GroupedList.Item>
67
+ * <Dropdown.Menu.GroupedList.Item>
68
+ * Infotrygd
69
+ * </Dropdown.Menu.GroupedList.Item>
70
+ * </Dropdown.Menu.GroupedList>
71
+ * <Dropdown.Menu.Divider />
72
+ * <Dropdown.Menu.List>
73
+ * <Dropdown.Menu.List.Item>Gosys</Dropdown.Menu.List.Item>
74
+ * <Dropdown.Menu.List.Item>Infotrygd</Dropdown.Menu.List.Item>
75
+ * </Dropdown.Menu.List>
76
+ * </Dropdown.Menu>
77
+ * </Dropdown>
78
+ * ```
79
+ */
41
80
  export const Dropdown = (({
42
81
  children,
43
82
  onSelect,
@@ -1,18 +1,15 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import cl from "clsx";
3
3
 
4
- export type DividerType = React.ForwardRefExoticComponent<
5
- React.HTMLAttributes<HTMLHRElement> & React.RefAttributes<HTMLHRElement>
6
- >;
7
-
8
- export const Divider: DividerType = forwardRef(
9
- ({ className, ...rest }, ref) => (
10
- <hr
11
- {...rest}
12
- ref={ref}
13
- className={cl("navds-dropdown__divider", className)}
14
- />
15
- )
16
- );
4
+ export const Divider = forwardRef<
5
+ HTMLHRElement,
6
+ React.HTMLAttributes<HTMLHRElement>
7
+ >(({ className, ...rest }, ref) => (
8
+ <hr
9
+ {...rest}
10
+ ref={ref}
11
+ className={cl("navds-dropdown__divider", className)}
12
+ />
13
+ ));
17
14
 
18
15
  export default Divider;