@navikt/ds-react 0.19.25 → 1.0.0-rc.3

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 (430) hide show
  1. package/README.md +43 -0
  2. package/_docs.json +364 -520
  3. package/cjs/accordion/Accordion.js +2 -2
  4. package/cjs/accordion/AccordionContent.js +5 -9
  5. package/cjs/accordion/AccordionHeader.js +5 -10
  6. package/cjs/accordion/AccordionItem.js +3 -7
  7. package/cjs/alert/Alert.js +2 -2
  8. package/cjs/button/Button.js +9 -7
  9. package/cjs/{speech-bubble → chat}/Bubble.js +7 -4
  10. package/cjs/{speech-bubble/SpeechBubble.js → chat/Chat.js} +11 -10
  11. package/cjs/{menu → chat}/index.js +3 -3
  12. package/cjs/chat/package.json +6 -0
  13. package/cjs/form/ConfirmationPanel.js +3 -3
  14. package/cjs/form/Fieldset/Fieldset.js +6 -6
  15. package/cjs/form/Select.js +6 -6
  16. package/cjs/form/Switch.js +4 -4
  17. package/cjs/form/TextField.js +6 -6
  18. package/cjs/form/Textarea.js +14 -14
  19. package/cjs/form/checkbox/Checkbox.js +3 -3
  20. package/cjs/form/checkbox/CheckboxGroup.js +2 -2
  21. package/cjs/form/error-summary/ErrorSummary.js +3 -3
  22. package/cjs/form/error-summary/ErrorSummaryItem.js +2 -2
  23. package/cjs/form/radio/Radio.js +2 -2
  24. package/cjs/form/radio/RadioGroup.js +2 -2
  25. package/cjs/form/search/Search.js +6 -7
  26. package/cjs/form/search/SearchButton.js +2 -4
  27. package/cjs/form/useFormField.js +2 -2
  28. package/cjs/grid/Cell.js +2 -2
  29. package/cjs/grid/ContentContainer.js +2 -2
  30. package/cjs/grid/Grid.js +2 -2
  31. package/cjs/guide-panel/Guide.js +3 -3
  32. package/cjs/guide-panel/GuidePanel.js +2 -2
  33. package/cjs/help-text/HelpText.js +5 -5
  34. package/cjs/index.js +1 -6
  35. package/cjs/link/Link.js +2 -2
  36. package/cjs/link-panel/LinkPanel.js +2 -2
  37. package/cjs/link-panel/LinkPanelDescription.js +2 -2
  38. package/cjs/link-panel/LinkPanelTitle.js +2 -2
  39. package/cjs/loader/Loader.js +2 -2
  40. package/cjs/modal/Modal.js +5 -7
  41. package/cjs/modal/ModalContent.js +2 -2
  42. package/cjs/pagination/Pagination.js +18 -23
  43. package/cjs/{menu/MenuItem.js → pagination/PaginationItem.js} +5 -4
  44. package/cjs/panel/Panel.js +2 -2
  45. package/cjs/popover/Popover.js +55 -45
  46. package/cjs/popover/PopoverContent.js +2 -2
  47. package/cjs/read-more/ReadMore.js +7 -11
  48. package/cjs/stepper/Step.js +2 -2
  49. package/cjs/stepper/Stepper.js +3 -3
  50. package/cjs/table/Body.js +2 -2
  51. package/cjs/table/DataCell.js +2 -2
  52. package/cjs/table/ExpandableRow.js +9 -12
  53. package/cjs/table/Header.js +2 -2
  54. package/cjs/table/HeaderCell.js +2 -2
  55. package/cjs/table/Row.js +2 -2
  56. package/cjs/table/Table.js +2 -2
  57. package/cjs/tabs/Tab.js +4 -4
  58. package/cjs/tabs/TabList.js +8 -7
  59. package/cjs/tabs/TabPanel.js +2 -2
  60. package/cjs/tabs/Tabs.js +5 -3
  61. package/cjs/tag/Tag.js +2 -2
  62. package/cjs/toggle-group/ToggleGroup.js +5 -5
  63. package/cjs/toggle-group/ToggleItem.js +2 -2
  64. package/cjs/tooltip/Tooltip.js +45 -92
  65. package/cjs/typography/BodyLong.js +2 -2
  66. package/cjs/typography/BodyShort.js +2 -2
  67. package/cjs/typography/Detail.js +2 -2
  68. package/cjs/typography/ErrorMessage.js +2 -2
  69. package/cjs/typography/Heading.js +2 -2
  70. package/cjs/typography/Ingress.js +2 -2
  71. package/cjs/typography/Label.js +2 -2
  72. package/cjs/util/AnimateHeight.js +204 -0
  73. package/cjs/util/TextareaAutoSize.js +174 -0
  74. package/cjs/util/debounce.js +18 -0
  75. package/cjs/util/index.js +14 -1
  76. package/cjs/util/mergeRefs.js +16 -0
  77. package/cjs/util/useId.js +60 -17
  78. package/esm/accordion/Accordion.js +1 -1
  79. package/esm/accordion/Accordion.js.map +1 -1
  80. package/esm/accordion/AccordionContent.d.ts +0 -2
  81. package/esm/accordion/AccordionContent.js +5 -9
  82. package/esm/accordion/AccordionContent.js.map +1 -1
  83. package/esm/accordion/AccordionHeader.js +5 -10
  84. package/esm/accordion/AccordionHeader.js.map +1 -1
  85. package/esm/accordion/AccordionItem.d.ts +0 -8
  86. package/esm/accordion/AccordionItem.js +2 -6
  87. package/esm/accordion/AccordionItem.js.map +1 -1
  88. package/esm/alert/Alert.d.ts +1 -1
  89. package/esm/alert/Alert.js +1 -1
  90. package/esm/alert/Alert.js.map +1 -1
  91. package/esm/button/Button.d.ts +10 -1
  92. package/esm/button/Button.js +10 -8
  93. package/esm/button/Button.js.map +1 -1
  94. package/esm/{speech-bubble → chat}/Bubble.d.ts +7 -3
  95. package/esm/{speech-bubble → chat}/Bubble.js +7 -4
  96. package/esm/chat/Bubble.js.map +1 -0
  97. package/esm/chat/Chat.d.ts +38 -0
  98. package/esm/chat/Chat.js +28 -0
  99. package/esm/chat/Chat.js.map +1 -0
  100. package/esm/chat/index.d.ts +1 -0
  101. package/esm/chat/index.js +2 -0
  102. package/esm/chat/index.js.map +1 -0
  103. package/esm/form/ConfirmationPanel.d.ts +1 -1
  104. package/esm/form/ConfirmationPanel.js +3 -3
  105. package/esm/form/ConfirmationPanel.js.map +1 -1
  106. package/esm/form/Fieldset/Fieldset.js +1 -1
  107. package/esm/form/Fieldset/Fieldset.js.map +1 -1
  108. package/esm/form/Select.js +1 -1
  109. package/esm/form/Select.js.map +1 -1
  110. package/esm/form/Switch.js +1 -1
  111. package/esm/form/Switch.js.map +1 -1
  112. package/esm/form/TextField.js +1 -1
  113. package/esm/form/TextField.js.map +1 -1
  114. package/esm/form/Textarea.js +6 -6
  115. package/esm/form/Textarea.js.map +1 -1
  116. package/esm/form/checkbox/Checkbox.js +1 -1
  117. package/esm/form/checkbox/Checkbox.js.map +1 -1
  118. package/esm/form/checkbox/CheckboxGroup.js +1 -1
  119. package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
  120. package/esm/form/error-summary/ErrorSummary.js +3 -3
  121. package/esm/form/error-summary/ErrorSummary.js.map +1 -1
  122. package/esm/form/error-summary/ErrorSummaryItem.js +1 -1
  123. package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
  124. package/esm/form/radio/Radio.js +1 -1
  125. package/esm/form/radio/Radio.js.map +1 -1
  126. package/esm/form/radio/RadioGroup.js +1 -1
  127. package/esm/form/radio/RadioGroup.js.map +1 -1
  128. package/esm/form/search/Search.js +4 -5
  129. package/esm/form/search/Search.js.map +1 -1
  130. package/esm/form/search/SearchButton.d.ts +1 -1
  131. package/esm/form/search/SearchButton.js +2 -4
  132. package/esm/form/search/SearchButton.js.map +1 -1
  133. package/esm/form/useFormField.js +1 -1
  134. package/esm/form/useFormField.js.map +1 -1
  135. package/esm/grid/Cell.js +1 -1
  136. package/esm/grid/Cell.js.map +1 -1
  137. package/esm/grid/ContentContainer.js +1 -1
  138. package/esm/grid/ContentContainer.js.map +1 -1
  139. package/esm/grid/Grid.js +1 -1
  140. package/esm/grid/Grid.js.map +1 -1
  141. package/esm/guide-panel/Guide.js +1 -1
  142. package/esm/guide-panel/Guide.js.map +1 -1
  143. package/esm/guide-panel/GuidePanel.js +1 -1
  144. package/esm/guide-panel/GuidePanel.js.map +1 -1
  145. package/esm/help-text/HelpText.d.ts +1 -2
  146. package/esm/help-text/HelpText.js +7 -7
  147. package/esm/help-text/HelpText.js.map +1 -1
  148. package/esm/index.d.ts +1 -5
  149. package/esm/index.js +1 -6
  150. package/esm/index.js.map +1 -1
  151. package/esm/link/Link.js +1 -1
  152. package/esm/link/Link.js.map +1 -1
  153. package/esm/link-panel/LinkPanel.js +1 -1
  154. package/esm/link-panel/LinkPanel.js.map +1 -1
  155. package/esm/link-panel/LinkPanelDescription.js +1 -1
  156. package/esm/link-panel/LinkPanelDescription.js.map +1 -1
  157. package/esm/link-panel/LinkPanelTitle.js +1 -1
  158. package/esm/link-panel/LinkPanelTitle.js.map +1 -1
  159. package/esm/loader/Loader.js +1 -1
  160. package/esm/loader/Loader.js.map +1 -1
  161. package/esm/modal/Modal.js +5 -7
  162. package/esm/modal/Modal.js.map +1 -1
  163. package/esm/modal/ModalContent.js +1 -1
  164. package/esm/modal/ModalContent.js.map +1 -1
  165. package/esm/pagination/Pagination.d.ts +12 -3
  166. package/esm/pagination/Pagination.js +17 -22
  167. package/esm/pagination/Pagination.js.map +1 -1
  168. package/esm/pagination/PaginationItem.d.ts +22 -0
  169. package/esm/{menu/MenuItem.js → pagination/PaginationItem.js} +6 -5
  170. package/esm/pagination/PaginationItem.js.map +1 -0
  171. package/esm/pagination/index.d.ts +1 -2
  172. package/esm/pagination/index.js.map +1 -1
  173. package/esm/panel/Panel.js +1 -1
  174. package/esm/panel/Panel.js.map +1 -1
  175. package/esm/popover/Popover.d.ts +2 -3
  176. package/esm/popover/Popover.js +56 -46
  177. package/esm/popover/Popover.js.map +1 -1
  178. package/esm/popover/PopoverContent.js +1 -1
  179. package/esm/popover/PopoverContent.js.map +1 -1
  180. package/esm/read-more/ReadMore.d.ts +0 -5
  181. package/esm/read-more/ReadMore.js +7 -11
  182. package/esm/read-more/ReadMore.js.map +1 -1
  183. package/esm/stepper/Step.js +1 -1
  184. package/esm/stepper/Step.js.map +1 -1
  185. package/esm/stepper/Stepper.js +1 -1
  186. package/esm/stepper/Stepper.js.map +1 -1
  187. package/esm/table/Body.js +1 -1
  188. package/esm/table/Body.js.map +1 -1
  189. package/esm/table/DataCell.js +1 -1
  190. package/esm/table/DataCell.js.map +1 -1
  191. package/esm/table/ExpandableRow.js +7 -10
  192. package/esm/table/ExpandableRow.js.map +1 -1
  193. package/esm/table/Header.js +1 -1
  194. package/esm/table/Header.js.map +1 -1
  195. package/esm/table/HeaderCell.js +1 -1
  196. package/esm/table/HeaderCell.js.map +1 -1
  197. package/esm/table/Row.js +1 -1
  198. package/esm/table/Row.js.map +1 -1
  199. package/esm/table/Table.js +1 -1
  200. package/esm/table/Table.js.map +1 -1
  201. package/esm/tabs/Tab.d.ts +0 -5
  202. package/esm/tabs/Tab.js +5 -5
  203. package/esm/tabs/Tab.js.map +1 -1
  204. package/esm/tabs/TabList.d.ts +0 -4
  205. package/esm/tabs/TabList.js +7 -6
  206. package/esm/tabs/TabList.js.map +1 -1
  207. package/esm/tabs/TabPanel.js +1 -1
  208. package/esm/tabs/TabPanel.js.map +1 -1
  209. package/esm/tabs/Tabs.d.ts +12 -0
  210. package/esm/tabs/Tabs.js +4 -2
  211. package/esm/tabs/Tabs.js.map +1 -1
  212. package/esm/tag/Tag.js +1 -1
  213. package/esm/tag/Tag.js.map +1 -1
  214. package/esm/toggle-group/ToggleGroup.js +3 -3
  215. package/esm/toggle-group/ToggleGroup.js.map +1 -1
  216. package/esm/toggle-group/ToggleItem.js +1 -1
  217. package/esm/toggle-group/ToggleItem.js.map +1 -1
  218. package/esm/tooltip/Tooltip.js +44 -91
  219. package/esm/tooltip/Tooltip.js.map +1 -1
  220. package/esm/typography/BodyLong.js +1 -1
  221. package/esm/typography/BodyLong.js.map +1 -1
  222. package/esm/typography/BodyShort.js +1 -1
  223. package/esm/typography/BodyShort.js.map +1 -1
  224. package/esm/typography/Detail.js +1 -1
  225. package/esm/typography/Detail.js.map +1 -1
  226. package/esm/typography/ErrorMessage.js +1 -1
  227. package/esm/typography/ErrorMessage.js.map +1 -1
  228. package/esm/typography/Heading.js +1 -1
  229. package/esm/typography/Heading.js.map +1 -1
  230. package/esm/typography/Ingress.js +1 -1
  231. package/esm/typography/Ingress.js.map +1 -1
  232. package/esm/typography/Label.js +1 -1
  233. package/esm/typography/Label.js.map +1 -1
  234. package/esm/util/AnimateHeight.d.ts +10 -0
  235. package/esm/util/AnimateHeight.js +180 -0
  236. package/esm/util/AnimateHeight.js.map +1 -0
  237. package/esm/util/TextareaAutoSize.d.ts +14 -0
  238. package/esm/util/TextareaAutoSize.js +150 -0
  239. package/esm/util/TextareaAutoSize.js.map +1 -0
  240. package/esm/util/debounce.d.ts +4 -0
  241. package/esm/util/debounce.js +16 -0
  242. package/esm/util/debounce.js.map +1 -0
  243. package/esm/util/index.d.ts +4 -0
  244. package/esm/util/index.js +9 -1
  245. package/esm/util/index.js.map +1 -1
  246. package/esm/util/mergeRefs.d.ts +2 -0
  247. package/esm/util/mergeRefs.js +14 -0
  248. package/esm/util/mergeRefs.js.map +1 -0
  249. package/esm/util/useId.d.ts +7 -3
  250. package/esm/util/useId.js +36 -16
  251. package/esm/util/useId.js.map +1 -1
  252. package/package.json +13 -15
  253. package/src/accordion/Accordion.tsx +1 -1
  254. package/src/accordion/AccordionContent.tsx +13 -19
  255. package/src/accordion/AccordionHeader.tsx +11 -18
  256. package/src/accordion/AccordionItem.tsx +2 -23
  257. package/src/accordion/accordion.stories.tsx +30 -31
  258. package/src/alert/Alert.tsx +2 -2
  259. package/src/alert/alert.stories.tsx +7 -0
  260. package/src/button/Button.tsx +39 -14
  261. package/src/button/button.stories.tsx +55 -28
  262. package/src/chat/Bubble.tsx +52 -0
  263. package/src/chat/Chat.tsx +96 -0
  264. package/src/chat/chat.stories.tsx +202 -0
  265. package/src/chat/index.ts +1 -0
  266. package/src/form/ConfirmationPanel.tsx +9 -4
  267. package/src/form/Fieldset/Fieldset.tsx +1 -1
  268. package/src/form/Select.tsx +1 -1
  269. package/src/form/Switch.tsx +1 -1
  270. package/src/form/TextField.tsx +1 -1
  271. package/src/form/Textarea.tsx +6 -6
  272. package/src/form/checkbox/Checkbox.test.tsx +20 -17
  273. package/src/form/checkbox/Checkbox.tsx +1 -1
  274. package/src/form/checkbox/CheckboxGroup.tsx +1 -1
  275. package/src/form/error-summary/ErrorSummary.tsx +3 -3
  276. package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
  277. package/src/form/radio/Radio.tsx +1 -1
  278. package/src/form/radio/RadioGroup.tsx +1 -1
  279. package/src/form/search/Search.tsx +11 -4
  280. package/src/form/search/SearchButton.tsx +8 -4
  281. package/src/form/useFormField.ts +1 -1
  282. package/src/grid/Cell.tsx +1 -1
  283. package/src/grid/ContentContainer.tsx +1 -1
  284. package/src/grid/Grid.tsx +1 -1
  285. package/src/grid/grid.stories.tsx +68 -0
  286. package/src/guide-panel/Guide.tsx +1 -1
  287. package/src/guide-panel/GuidePanel.tsx +1 -1
  288. package/src/help-text/HelpText.tsx +22 -8
  289. package/src/help-text/help-text.stories.tsx +12 -16
  290. package/src/index.ts +1 -7
  291. package/src/link/Link.tsx +1 -1
  292. package/src/link-panel/LinkPanel.tsx +1 -1
  293. package/src/link-panel/LinkPanelDescription.tsx +1 -1
  294. package/src/link-panel/LinkPanelTitle.tsx +1 -1
  295. package/src/loader/Loader.tsx +1 -1
  296. package/src/modal/Modal.tsx +6 -8
  297. package/src/modal/ModalContent.tsx +1 -1
  298. package/src/pagination/Pagination.tsx +87 -72
  299. package/src/pagination/PaginationItem.tsx +56 -0
  300. package/src/pagination/index.ts +1 -2
  301. package/src/pagination/pagination.stories.tsx +90 -16
  302. package/src/panel/Panel.tsx +1 -1
  303. package/src/popover/Popover.test.tsx +143 -0
  304. package/src/popover/Popover.tsx +107 -73
  305. package/src/popover/PopoverContent.tsx +1 -1
  306. package/src/popover/popover.stories.tsx +22 -27
  307. package/src/read-more/ReadMore.tsx +19 -30
  308. package/src/read-more/readmore.stories.tsx +3 -10
  309. package/src/stepper/Step.tsx +1 -1
  310. package/src/stepper/Stepper.tsx +1 -1
  311. package/src/table/Body.tsx +1 -1
  312. package/src/table/DataCell.tsx +1 -1
  313. package/src/table/ExpandableRow.tsx +12 -13
  314. package/src/table/Header.tsx +1 -1
  315. package/src/table/HeaderCell.tsx +1 -1
  316. package/src/table/Row.tsx +1 -1
  317. package/src/table/Table.tsx +1 -1
  318. package/src/tabs/Tab.tsx +6 -19
  319. package/src/tabs/TabList.tsx +14 -9
  320. package/src/tabs/TabPanel.tsx +1 -1
  321. package/src/tabs/Tabs.stories.tsx +94 -117
  322. package/src/tabs/Tabs.tsx +17 -1
  323. package/src/tag/Tag.tsx +1 -1
  324. package/src/toggle-group/ToggleGroup.tsx +3 -3
  325. package/src/toggle-group/ToggleItem.tsx +1 -1
  326. package/src/tooltip/Tooltip.test.tsx +167 -0
  327. package/src/tooltip/Tooltip.tsx +106 -173
  328. package/src/tooltip/tooltip.stories.tsx +15 -1
  329. package/src/typography/BodyLong.tsx +1 -1
  330. package/src/typography/BodyShort.tsx +1 -1
  331. package/src/typography/Detail.tsx +1 -1
  332. package/src/typography/ErrorMessage.tsx +1 -1
  333. package/src/typography/Heading.tsx +1 -1
  334. package/src/typography/Ingress.tsx +1 -1
  335. package/src/typography/Label.tsx +1 -1
  336. package/src/util/AnimateHeight.tsx +240 -0
  337. package/src/util/TextareaAutoSize.tsx +224 -0
  338. package/src/util/debounce.ts +17 -0
  339. package/src/util/index.ts +14 -2
  340. package/src/util/mergeRefs.tsx +14 -0
  341. package/src/util/useId.ts +37 -20
  342. package/cjs/card/MicroCard.js +0 -47
  343. package/cjs/card/index.js +0 -8
  344. package/cjs/card/package.json +0 -6
  345. package/cjs/menu/Menu.js +0 -53
  346. package/cjs/menu/MenuCollapse.js +0 -65
  347. package/cjs/menu/MenuItems.js +0 -23
  348. package/cjs/menu/package.json +0 -6
  349. package/cjs/page-header/PageHeader.js +0 -51
  350. package/cjs/page-header/index.js +0 -8
  351. package/cjs/page-header/package.json +0 -6
  352. package/cjs/speech-bubble/index.js +0 -8
  353. package/cjs/speech-bubble/package.json +0 -6
  354. package/cjs/step-indicator/Step.js +0 -67
  355. package/cjs/step-indicator/StepIndicator.js +0 -80
  356. package/cjs/step-indicator/index.js +0 -8
  357. package/cjs/step-indicator/package.json +0 -6
  358. package/esm/card/MicroCard.d.ts +0 -10
  359. package/esm/card/MicroCard.js +0 -19
  360. package/esm/card/MicroCard.js.map +0 -1
  361. package/esm/card/index.d.ts +0 -2
  362. package/esm/card/index.js +0 -2
  363. package/esm/card/index.js.map +0 -1
  364. package/esm/menu/Menu.d.ts +0 -12
  365. package/esm/menu/Menu.js +0 -25
  366. package/esm/menu/Menu.js.map +0 -1
  367. package/esm/menu/MenuCollapse.d.ts +0 -12
  368. package/esm/menu/MenuCollapse.js +0 -37
  369. package/esm/menu/MenuCollapse.js.map +0 -1
  370. package/esm/menu/MenuItem.d.ts +0 -13
  371. package/esm/menu/MenuItem.js.map +0 -1
  372. package/esm/menu/MenuItems.d.ts +0 -6
  373. package/esm/menu/MenuItems.js +0 -19
  374. package/esm/menu/MenuItems.js.map +0 -1
  375. package/esm/menu/index.d.ts +0 -3
  376. package/esm/menu/index.js +0 -2
  377. package/esm/menu/index.js.map +0 -1
  378. package/esm/page-header/PageHeader.d.ts +0 -27
  379. package/esm/page-header/PageHeader.js +0 -24
  380. package/esm/page-header/PageHeader.js.map +0 -1
  381. package/esm/page-header/index.d.ts +0 -2
  382. package/esm/page-header/index.js +0 -2
  383. package/esm/page-header/index.js.map +0 -1
  384. package/esm/speech-bubble/Bubble.js.map +0 -1
  385. package/esm/speech-bubble/SpeechBubble.d.ts +0 -34
  386. package/esm/speech-bubble/SpeechBubble.js +0 -27
  387. package/esm/speech-bubble/SpeechBubble.js.map +0 -1
  388. package/esm/speech-bubble/index.d.ts +0 -1
  389. package/esm/speech-bubble/index.js +0 -2
  390. package/esm/speech-bubble/index.js.map +0 -1
  391. package/esm/step-indicator/Step.d.ts +0 -23
  392. package/esm/step-indicator/Step.js +0 -39
  393. package/esm/step-indicator/Step.js.map +0 -1
  394. package/esm/step-indicator/StepIndicator.d.ts +0 -41
  395. package/esm/step-indicator/StepIndicator.js +0 -52
  396. package/esm/step-indicator/StepIndicator.js.map +0 -1
  397. package/esm/step-indicator/index.d.ts +0 -1
  398. package/esm/step-indicator/index.js +0 -2
  399. package/esm/step-indicator/index.js.map +0 -1
  400. package/src/card/MicroCard.tsx +0 -32
  401. package/src/card/index.ts +0 -2
  402. package/src/card/stories/card.stories.mdx +0 -26
  403. package/src/card/stories/card.stories.tsx +0 -16
  404. package/src/grid/stories/grid.stories.mdx +0 -79
  405. package/src/grid/stories/grid.stories.tsx +0 -51
  406. package/src/grid/stories/styles.css +0 -21
  407. package/src/menu/Menu.tsx +0 -36
  408. package/src/menu/MenuCollapse.tsx +0 -80
  409. package/src/menu/MenuItem.tsx +0 -39
  410. package/src/menu/MenuItems.tsx +0 -21
  411. package/src/menu/index.ts +0 -3
  412. package/src/menu/stories/menu.stories.mdx +0 -93
  413. package/src/menu/stories/menu.stories.tsx +0 -139
  414. package/src/page-header/PageHeader.tsx +0 -72
  415. package/src/page-header/index.ts +0 -2
  416. package/src/page-header/stories/header.stories.mdx +0 -81
  417. package/src/page-header/stories/header.stories.tsx +0 -61
  418. package/src/page-header/stories/pictogram.tsx +0 -14
  419. package/src/speech-bubble/Bubble.tsx +0 -48
  420. package/src/speech-bubble/SpeechBubble.tsx +0 -93
  421. package/src/speech-bubble/index.ts +0 -1
  422. package/src/speech-bubble/stories/illustration.tsx +0 -66
  423. package/src/speech-bubble/stories/speechbubble.stories.mdx +0 -184
  424. package/src/speech-bubble/stories/speechbubble.stories.tsx +0 -104
  425. package/src/step-indicator/Step.tsx +0 -81
  426. package/src/step-indicator/StepIndicator.tsx +0 -148
  427. package/src/step-indicator/index.ts +0 -1
  428. package/src/step-indicator/stories/Example.tsx +0 -23
  429. package/src/step-indicator/stories/step-indicator.stories.mdx +0 -122
  430. package/src/step-indicator/stories/step-indicator.stories.tsx +0 -104
@@ -1,93 +0,0 @@
1
- import React, { forwardRef, HTMLAttributes } from "react";
2
- import cl from "classnames";
3
- import Bubble, { BubbleType } from "./Bubble";
4
-
5
- export interface SpeechBubbleProps extends HTMLAttributes<HTMLDivElement> {
6
- /**
7
- * Children of type <SpeechBubble.Bubble />
8
- */
9
- children: React.ReactNode;
10
- /**
11
- * Top text for personalia and date
12
- */
13
- topText?: React.ReactNode;
14
- /**
15
- * Illustration for messenger. Regular text for initials works to
16
- */
17
- illustration: React.ReactNode;
18
- /**
19
- * Background color on bubbles
20
- */
21
- backgroundColor?: string;
22
- /**
23
- * Background color for illustration
24
- */
25
- illustrationBgColor?: string;
26
- /**
27
- * Positions illustration and Speechbubbles
28
- * @default "left"
29
- */
30
- position?: "left" | "right";
31
- }
32
-
33
- interface SpeechBubbleComponent
34
- extends React.ForwardRefExoticComponent<
35
- SpeechBubbleProps & React.RefAttributes<HTMLDivElement>
36
- > {
37
- Bubble: BubbleType;
38
- }
39
-
40
- export const SpeechBubble = forwardRef<HTMLDivElement, SpeechBubbleProps>(
41
- (
42
- {
43
- children,
44
- className,
45
- topText,
46
- illustration,
47
- position = "left",
48
- illustrationBgColor,
49
- backgroundColor,
50
- ...rest
51
- },
52
- ref
53
- ) => {
54
- return (
55
- <div
56
- ref={ref}
57
- className={cl(
58
- "navds-speechbubble",
59
- className,
60
- `navds-speechbubble--${position}`,
61
- "navds-body-long"
62
- )}
63
- {...rest}
64
- >
65
- <div
66
- className="navds-speechbubble__illustration"
67
- style={{ backgroundColor: illustrationBgColor }}
68
- >
69
- {illustration}
70
- </div>
71
- <ol className="navds-speechbubble__bubble-list">
72
- {React.Children.map(children, (child, i) => {
73
- if (React.isValidElement(child)) {
74
- return (
75
- <li>
76
- {React.cloneElement(child, {
77
- topText: topText && i === 0 ? topText : undefined,
78
- backgroundColor,
79
- ...child.props,
80
- })}
81
- </li>
82
- );
83
- }
84
- })}
85
- </ol>
86
- </div>
87
- );
88
- }
89
- ) as SpeechBubbleComponent;
90
-
91
- SpeechBubble.Bubble = Bubble;
92
-
93
- export default SpeechBubble;
@@ -1 +0,0 @@
1
- export { default as SpeechBubble, SpeechBubbleProps } from "./SpeechBubble";
@@ -1,66 +0,0 @@
1
- import React from "react";
2
- export const Illustration = () => (
3
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 93">
4
- <path
5
- fill="#e7e5e2"
6
- d="M14 50.7C15 52.3 17.9 81 26.5 81S39 51.8 39 50.3c-13.2-7.6-25 .4-25 .4z"
7
- />
8
- <path
9
- fill="#5c4378"
10
- d="M38.7 50.2c6 2.9 15.3 10.9 15.3 18.3V93H0V68.5c0-7.1 8.5-14.8 14.5-18-.3.2-.5.3-.5.3 1 1.7 3.8 9.2 12.4 9.2C35 60 39 51.9 39 50.4c-.1-.1-.2-.2-.3-.2z"
11
- />
12
- <path
13
- fill="#d2242a"
14
- d="M46.7 76H31.2c-.7 0-1.3-.6-1.2-1.3v-8.5c0-.7.6-1.3 1.3-1.3h15.5c.7 0 1.3.6 1.3 1.3v8.5c-.1.7-.7 1.3-1.4 1.3"
15
- />
16
- <path
17
- fill="#fff"
18
- d="M42.9 71c0 2.1-1.7 3.8-3.8 3.8-2.1 0-3.8-1.7-3.8-3.8s1.7-3.8 3.8-3.8c2.1 0 3.8 1.7 3.8 3.8m-8.7 1.7h-.7l.8-1.9h.7l-.8 1.9zm9.3 0H43l.8-1.9h.5l-.8 1.9zm1.2 0h-.2l.8-1.9h.2l-.8 1.9z"
19
- />
20
- <path
21
- fill="#c52d35"
22
- d="M36.2 72.7h.6s.1 0 .1-.1v-1.8s0-.1-.1-.1h-.6s-.1 0-.1.1l-.2.6v.1h.2l.1 1.2c0-.1 0 0 0 0"
23
- />
24
- <path
25
- fill="#c52d35"
26
- d="M37.5 72.7h.6s.1 0 .1-.1v-1.8s0-.1-.1-.1h-.9s-.1 0-.1.1l-.2.6-.1.1h.5c.1 0 .2.1.2.2v1c-.1-.1-.1 0 0 0m2.6-1.9h-.6s-.1 0-.1.1v1.8s0 .1.1.1h.6s.1 0 .1-.1l.2-.6V72h-.2l-.1-1.2"
27
- />
28
- <path
29
- fill="#c52d35"
30
- d="M37.7 72.7h.4s.1 0 .1-.1l.2-.6v-.1h-.2c0 .1-.5.8-.5.8zm3.9-1.9h.7s.1 0 0 .1l-.7 1.8H41l.6-1.9"
31
- />
32
- <path
33
- fill="#c52d35"
34
- d="M40.8 70.8h-1c-.1 0 .3.1.3.1l.7 1.7s0 .1.1.1h.6l-.7-1.9m-1.3.6v.4s-.1-.4-.3-.4c-.3 0-.3.2-.3.3 0 .1.1.3.2.3h.5l-.3.7H39c-.2 0-.9-.3-.9-.9 0-.6.5-1 .9-1 .2-.1.5.2.5.6 0-.1 0-.1 0 0z"
35
- />
36
- <path
37
- fill="#5a1f57"
38
- d="M39.9 66.7h-1.6c-.1 0-.2-.1-.2-.2v-.3c0-.1.1-.2.2-.2h1.6c.1 0 .2.1.2.2v.3c0 .2-.1.2-.2.2"
39
- />
40
- <path fill="#c2b5cf" d="M38.7 66.5h.9V64h-.9v2.5z" />
41
- <path
42
- fill="#e7e5e2"
43
- d="M47.2 35.3C44.7 45.6 36.6 53.1 27 53.1S9.3 45.6 6.8 35.3c-.2.1-.5.1-.8.1-1.1 0-2-.8-2-1.7v-7c0-1 .9-1.7 2-1.7h.2C7.7 13.1 16.4 4 27 4c10.6 0 19.3 9.1 20.8 21h.2c1.1 0 2 .8 2 1.7v7c0 1-.9 1.7-2 1.7-.3 0-.5 0-.8-.1z"
44
- />
45
- <path
46
- fill="#635e59"
47
- d="M19 27.6c-1.4.1-1.9-2-1.4-3.4.1-.3.6-1.5 1.4-1.5.8 0 1.2.7 1.3.8.6 1.4.3 4-1.3 4.1m16.2 0c1.4.1 1.9-2 1.4-3.4-.1-.3-.6-1.5-1.4-1.5-.8 0-1.2.7-1.3.8-.6 1.4-.3 4 1.3 4.1"
48
- />
49
- <path
50
- fill="#d1bfa3"
51
- d="M26.8 34.6c-.4 0-.7-.1-1-.2-.3-.1-.4-.4-.3-.7.1-.3.4-.4.7-.3.5.2 1.5.1 2.2-.4.7-.4 1.1-1 1.2-1.5.1-.4-.1-.9-.4-1.3-.2-.2-.8-.2-1.6-.1-.3 0-.5-.1-.6-.4 0-.3.1-.5.4-.6 1.2-.2 2.1 0 2.6.6.5.7.8 1.4.6 2.1-.1.8-.7 1.6-1.7 2.2-.6.3-1.4.6-2.1.6z"
52
- />
53
- <path
54
- fill="#593a32"
55
- d="M27.1 42.1h-.3c-5.3-.2-7.3-4.1-7.4-4.3-.1-.3 0-.6.2-.7.2-.1.6 0 .7.2.1.1 1.9 3.6 6.6 3.8 4.7.2 6.4-3.7 6.4-3.7.1-.3.4-.4.7-.3.3.1.4.4.3.7-.1 0-2.1 4.3-7.2 4.3z"
56
- />
57
- <path
58
- fill="#f6b873"
59
- d="M6.6 30.7c.1-.1.1-.2.1-.3v-2c-.1-5.6 1.8-8.1 3.4-10.1 0 0-1 4.3-.3 3.4 3.8-5 21.4-1.6 25-8.1.5 3.6-4.1 4.6-4.1 4.6 3.7.7 6.9-.8 7.7-2.5.3 1.4-.6 2.4-1.9 3.4 4.5-.9 4.6-4 4.6-4 .6 4.1 5.3 2.5 5.3 9.3v6c0 .3.2.6.5.6h.5c.3 0 .5-.3.5-.6V26c.3-15.6-8.5-26-20.6-26C15.9 0 5 10.4 5 24.1v6.3c0 .4.2.6.5.6h.6c.2 0 .3-.1.5-.3"
60
- />
61
- <path
62
- fill="#f6b873"
63
- d="M25.9 43.4c-4.4 0-8-1.4-8-3.2s3.6-3.2 8-3.2 8 1.4 8 3.2c0 1.8-3.6 3.2-8 3.2m.8-9.4c-2.9 0-4.7.7-8.8 2.1-12.7 4.6-11.6-14-11.6-14C3.4 46 18.6 52 26.5 52c8.1 0 24.1-8.1 21-30 0 0 .4 17.1-12.9 13.8-3.7-.9-5-1.8-7.9-1.8z"
64
- />
65
- </svg>
66
- );
@@ -1,184 +0,0 @@
1
- import { Meta, Canvas } from "@storybook/addon-docs";
2
- import { SpeechBubble, Bubble } from "../../index";
3
- import { Illustration } from "./illustration";
4
-
5
- <Meta title="ds-react/speechbubble/intro" />
6
-
7
- # Hvordan ta i bruk Speechbubble
8
-
9
- NOTE: Komponenten er i tidlig BETA og ikke testet ordentlig. Derfor kan/vil det komme potensielle
10
- breaking-changes før v1 er klar. Anbefaler da å ikke override styling som er brukt utenom det som er tilbytt som props.
11
-
12
- ```jsx
13
- <SpeechBubble illustration="OLA" topText="Ola Normann 01.01.21 14:00">
14
- <SpeechBubble.Bubble>
15
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
16
- </SpeechBubble.Bubble>
17
- <SpeechBubble.Bubble>
18
- Tempor fugiat amet eu sint in in ullamco.
19
- </SpeechBubble.Bubble>
20
- <SpeechBubble.Bubble>
21
- Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
22
- labore nisi ut.
23
- </SpeechBubble.Bubble>
24
- </SpeechBubble>
25
- ```
26
-
27
- <Canvas>
28
- <SpeechBubble illustration="OLA" topText="Ola Normann 01.01.21 14:00">
29
- <SpeechBubble.Bubble>
30
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
31
- </SpeechBubble.Bubble>
32
- <SpeechBubble.Bubble>
33
- Tempor fugiat amet eu sint in in ullamco.
34
- </SpeechBubble.Bubble>
35
- <SpeechBubble.Bubble>
36
- Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
37
- labore nisi ut.
38
- </SpeechBubble.Bubble>
39
- </SpeechBubble>
40
- </Canvas>
41
-
42
- ## Posisjonering
43
-
44
- Speechbubble kan bli posisjonert "left" og "right" med `position`-proppen
45
-
46
- ```jsx
47
- <SpeechBubble illustration="OLA" position="left">
48
- <SpeechBubble.Bubble>
49
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
50
- </SpeechBubble.Bubble>
51
- </SpeechBubble>
52
- <SpeechBubble illustration="OLA" position="right">
53
- <SpeechBubble.Bubble>
54
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
55
- </SpeechBubble.Bubble>
56
- </SpeechBubble>
57
- ```
58
-
59
- <Canvas>
60
- <div>
61
- <SpeechBubble illustration="OLA" position="left">
62
- <SpeechBubble.Bubble>
63
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
64
- </SpeechBubble.Bubble>
65
- </SpeechBubble>
66
- <br />
67
- <SpeechBubble illustration="PER" position="right">
68
- <SpeechBubble.Bubble>
69
- Ipsum laborum culpa ea ea commodo eiusmod in aute.
70
- </SpeechBubble.Bubble>
71
- </SpeechBubble>
72
- </div>
73
- </Canvas>
74
-
75
- ## Endring av farger
76
-
77
- Man kan endre bakgrunnsfargen selv med `illustrationBgColor` og `backgroundColor` proppene.
78
-
79
- ```jsx
80
- <SpeechBubble
81
- illustration="OLA"
82
- position="left"
83
- illustrationBgColor="var(--navds-global-color-lightblue-100)"
84
- backgroundColor="var(--navds-global-color-lightblue-200)"
85
- >
86
- <SpeechBubble.Bubble>
87
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
88
- </SpeechBubble.Bubble>
89
- </SpeechBubble>
90
- ```
91
-
92
- <Canvas>
93
- <SpeechBubble
94
- illustration="OLA"
95
- position="left"
96
- illustrationBgColor="var(--navds-global-color-lightblue-100)"
97
- backgroundColor="var(--navds-global-color-lightblue-200)"
98
- >
99
- <SpeechBubble.Bubble>
100
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
101
- </SpeechBubble.Bubble>
102
- </SpeechBubble>
103
- </Canvas>
104
-
105
- ## Illustrasjoner
106
-
107
- `illustration`-proppen aksepterer `ReactNode`.
108
- Hvis man bruker en illustrasjon i SVG-fromat vil den fungere likt `nav-frontend-veilederpanel` sin illustrasjon.
109
-
110
- ```jsx
111
- <SpeechBubble illustration={<Illustration />} position="left">
112
- <SpeechBubble.Bubble>
113
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
114
- </SpeechBubble.Bubble>
115
- </SpeechBubble>
116
- ```
117
-
118
- <Canvas>
119
- <SpeechBubble illustration={<Illustration />} position="left">
120
- <SpeechBubble.Bubble>
121
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
122
- </SpeechBubble.Bubble>
123
- </SpeechBubble>
124
- </Canvas>
125
-
126
- ## Styling av topText
127
-
128
- `topText`-proppen aksepterer `ReactNode` og man kan da selv style den
129
-
130
- ```jsx
131
- <SpeechBubble
132
- illustration={<div>OLA</div>}
133
- topText={
134
- <div
135
- style={{
136
- display: "flex",
137
- columnGap: "1rem",
138
- }}
139
- >
140
- <span>Ola Normann</span>
141
- <span className="navds-detail--s">01.01.21 14:00</span>
142
- </div>
143
- }
144
- >
145
- <SpeechBubble.Bubble>
146
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
147
- </SpeechBubble.Bubble>
148
- <SpeechBubble.Bubble>
149
- Tempor fugiat amet eu sint in in ullamco.
150
- </SpeechBubble.Bubble>
151
- <SpeechBubble.Bubble>
152
- Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
153
- labore nisi ut.
154
- </SpeechBubble.Bubble>
155
- </SpeechBubble>
156
- ```
157
-
158
- <Canvas>
159
- <SpeechBubble
160
- illustration={<div>OLA</div>}
161
- topText={
162
- <div
163
- style={{
164
- display: "flex",
165
- columnGap: "1rem",
166
- }}
167
- >
168
- <span>Ola Normann</span>
169
- <span className="navds-detail--s">01.01.21 14:00</span>
170
- </div>
171
- }
172
- >
173
- <SpeechBubble.Bubble>
174
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
175
- </SpeechBubble.Bubble>
176
- <SpeechBubble.Bubble>
177
- Tempor fugiat amet eu sint in in ullamco.
178
- </SpeechBubble.Bubble>
179
- <SpeechBubble.Bubble>
180
- Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
181
- labore nisi ut.
182
- </SpeechBubble.Bubble>
183
- </SpeechBubble>
184
- </Canvas>
@@ -1,104 +0,0 @@
1
- import React from "react";
2
- import { SpeechBubble } from "../index";
3
- import { Meta } from "@storybook/react/types-6-0";
4
- import { Illustration } from "./illustration";
5
-
6
- export default {
7
- title: "ds-react/speechbubble",
8
- component: SpeechBubble,
9
- } as Meta;
10
-
11
- export const All = () => {
12
- return (
13
- <div style={{ rowGap: "2rem", display: "flex", flexDirection: "column" }}>
14
- <SpeechBubble
15
- illustration={<Illustration />}
16
- topText="Ola Normann 01.01.21 14:00"
17
- backgroundColor="var(--navds-global-color-lightblue-200)"
18
- >
19
- <SpeechBubble.Bubble>
20
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
21
- </SpeechBubble.Bubble>
22
- <SpeechBubble.Bubble>
23
- Tempor fugiat amet eu sint in in ullamco.
24
- </SpeechBubble.Bubble>
25
- <SpeechBubble.Bubble>
26
- Adipisicing laborum est eu laborum est sit in commodo enim sint
27
- laboris labore nisi ut.
28
- </SpeechBubble.Bubble>
29
- </SpeechBubble>
30
- <SpeechBubble
31
- illustration={<div>KAJ</div>}
32
- topText={
33
- <div
34
- style={{
35
- columnGap: "1rem",
36
- display: "flex",
37
- justifyContent: "flex-end",
38
- }}
39
- >
40
- <span>Ola Normann</span>
41
- <span className="navds-detail--s">01.01.21 14:00</span>
42
- </div>
43
- }
44
- position="right"
45
- backgroundColor="var(--navds-global-color-gray-100)"
46
- >
47
- <SpeechBubble.Bubble>
48
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
49
- </SpeechBubble.Bubble>
50
- <SpeechBubble.Bubble>
51
- Tempor fugiat amet eu sint in in ullamco.
52
- </SpeechBubble.Bubble>
53
- <SpeechBubble.Bubble>
54
- Adipisicing laborum est eu laborum est sit in commodo enim sint
55
- laboris labore nisi ut.
56
- </SpeechBubble.Bubble>
57
- </SpeechBubble>
58
- <SpeechBubble
59
- illustration={<div>KAJ</div>}
60
- topText="Ola Normann 01.01.21 14:00"
61
- position="left"
62
- >
63
- <SpeechBubble.Bubble>
64
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
65
- </SpeechBubble.Bubble>
66
- <SpeechBubble.Bubble>
67
- Tempor fugiat amet eu sint in in ullamco.
68
- </SpeechBubble.Bubble>
69
- <SpeechBubble.Bubble>
70
- Adipisicing laborum est eu laborum est sit in commodo enim sint
71
- laboris labore nisi ut.
72
- </SpeechBubble.Bubble>
73
- </SpeechBubble>
74
- <SpeechBubble
75
- illustration={<div>KAJ</div>}
76
- topText="Ola Normann 01.01.21 14:00"
77
- position="right"
78
- >
79
- <SpeechBubble.Bubble>
80
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
81
- </SpeechBubble.Bubble>
82
- <SpeechBubble.Bubble>
83
- Tempor fugiat amet eu sint in in ullamco.
84
- </SpeechBubble.Bubble>
85
- </SpeechBubble>
86
- <SpeechBubble
87
- illustration={<div>KAJ</div>}
88
- topText="Ola Normann 01.01.21 14:00"
89
- position="left"
90
- >
91
- <SpeechBubble.Bubble>
92
- Aute minim nisi sunt mollit duis sunt nulla minim non proident.
93
- </SpeechBubble.Bubble>
94
- </SpeechBubble>
95
- <SpeechBubble
96
- illustration={<div>KAJ</div>}
97
- topText="Ola Normann 01.01.21 14:00"
98
- position="right"
99
- >
100
- <SpeechBubble.Bubble>Per skriver....</SpeechBubble.Bubble>
101
- </SpeechBubble>
102
- </div>
103
- );
104
- };
@@ -1,81 +0,0 @@
1
- import React, { forwardRef, useContext } from "react";
2
- import cl from "classnames";
3
- import { StepContext } from "./StepIndicator";
4
- import { BodyShort, Label, OverridableComponent } from "..";
5
-
6
- export interface StepIndicatorStepProps
7
- extends React.HTMLAttributes<HTMLButtonElement> {
8
- /**
9
- * Text content under indicator
10
- */
11
- children: React.ReactNode;
12
- /**
13
- * Disables interaction with element
14
- * @note We recommend not using disabled if possible
15
- */
16
- disabled?: boolean;
17
- /**
18
- * Handled by StepIndicator
19
- * @private
20
- */
21
- index?: number;
22
- }
23
-
24
- export interface StepIndicatorStepType
25
- extends OverridableComponent<StepIndicatorStepProps, HTMLButtonElement> {}
26
-
27
- export const StepIndicatorStepComponent: OverridableComponent<
28
- StepIndicatorStepProps,
29
- HTMLButtonElement
30
- > = forwardRef(
31
- (
32
- { className, children, as: Component = "button", disabled, index, ...rest },
33
- ref
34
- ) => {
35
- const context = useContext(StepContext);
36
-
37
- if (context === null) {
38
- console.error(
39
- "<StepIndicator.Step> has to be used within an <StepIndicator>"
40
- );
41
- return null;
42
- }
43
-
44
- const safeIndex = index ?? 0;
45
-
46
- const Number = context.activeStep === safeIndex ? Label : BodyShort;
47
-
48
- return (
49
- <Component
50
- {...rest}
51
- disabled={disabled}
52
- ref={ref}
53
- className={cl("navds-step-indicator__step", className, {
54
- "navds-step-indicator__step--disabled": disabled,
55
- "navds-step-indicator__step--active":
56
- context.activeStep === safeIndex,
57
- "navds-step-indicator__step--finished":
58
- context.activeStep > safeIndex,
59
- })}
60
- onClick={(e) => {
61
- context.onStepChange(safeIndex);
62
- rest.onClick && rest.onClick(e);
63
- }}
64
- >
65
- <Number className="navds-step-indicator__step-number">
66
- {safeIndex + 1}
67
- </Number>
68
- <div className={cl("navds-step-indicator__step-label")}>
69
- {!context.hideLabels && children}
70
- </div>
71
- {safeIndex !== 0 && (
72
- <span aria-hidden className="navds-step-indicator__step-line" />
73
- )}
74
- </Component>
75
- );
76
- }
77
- );
78
-
79
- const Step = StepIndicatorStepComponent as StepIndicatorStepType;
80
-
81
- export default Step;
@@ -1,148 +0,0 @@
1
- import cl from "classnames";
2
- import React, {
3
- createContext,
4
- forwardRef,
5
- useCallback,
6
- useEffect,
7
- useRef,
8
- useState,
9
- } from "react";
10
- import mergeRefs from "react-merge-refs";
11
- import StepIndicatorStep, {
12
- StepIndicatorStepProps,
13
- StepIndicatorStepType,
14
- } from "./Step";
15
-
16
- export interface StepIndicatorProps
17
- extends React.HTMLAttributes<HTMLOListElement> {
18
- /**
19
- * <StepIndicator.Step /> elements
20
- */
21
- children: React.ReactNode;
22
- /**
23
- * Adds classname to wrapper
24
- */
25
- className?: string;
26
- /**
27
- * Current active step index
28
- */
29
- activeStep: number;
30
- /**
31
- * Callback for clicked step index
32
- */
33
- onStepChange?: (step: number) => void;
34
- /**
35
- * Hides labels for each step if true
36
- * @default false
37
- */
38
- hideLabels?: boolean;
39
- /**
40
- * enables `hideLabels` internally when steps start to overflow.
41
- * @note declaring `hideLabels` overwrites this functionality
42
- */
43
- responsive?: boolean;
44
- }
45
-
46
- interface StepIndicatorComponent
47
- extends React.ForwardRefExoticComponent<
48
- StepIndicatorProps & React.RefAttributes<HTMLOListElement>
49
- > {
50
- Step: StepIndicatorStepType;
51
- }
52
-
53
- interface StepContextProps {
54
- activeStep: number;
55
- onStepChange: (step: number) => void;
56
- hideLabels: boolean;
57
- }
58
-
59
- export const StepContext = createContext<StepContextProps | null>(null);
60
-
61
- export const StepIndicator: StepIndicatorComponent = forwardRef<
62
- HTMLOListElement,
63
- StepIndicatorProps
64
- >(
65
- (
66
- {
67
- children,
68
- className,
69
- activeStep,
70
- hideLabels,
71
- onStepChange = () => {},
72
- responsive,
73
- ...rest
74
- },
75
- ref
76
- ) => {
77
- const wrapperRef = useRef<HTMLOListElement | null>(null);
78
- const mergedRef = mergeRefs([wrapperRef, ref]);
79
-
80
- const [showLabels, setShowLabels] = useState(true);
81
-
82
- const removeLabels = hideLabels ?? (!!responsive && !showLabels);
83
-
84
- const stepsWithIndex = React.Children.map(children, (step, index) => {
85
- return React.isValidElement<StepIndicatorStepProps>(step) ? (
86
- <li
87
- className={cl("navds-step-indicator__step-wrapper", {
88
- "navds-step-indicator__step-wrapper--hidelabel": removeLabels,
89
- })}
90
- key={index}
91
- aria-current={index === activeStep && "step"}
92
- >
93
- {React.cloneElement(step, {
94
- ...step.props,
95
- index,
96
- })}
97
- </li>
98
- ) : (
99
- step
100
- );
101
- });
102
-
103
- const canShowLabels = useCallback(() => {
104
- const remSize = parseFloat(
105
- String(getComputedStyle(document.documentElement).fontSize)
106
- );
107
- const childrenLength = React.Children.toArray(children).filter((child) =>
108
- React.isValidElement(child)
109
- ).length;
110
-
111
- wrapperRef.current &&
112
- setShowLabels(
113
- wrapperRef.current?.getBoundingClientRect().width >=
114
- remSize * 10 * childrenLength
115
- );
116
- }, [children]);
117
-
118
- useEffect(() => {
119
- window.addEventListener("resize", canShowLabels);
120
- canShowLabels();
121
- return () => {
122
- window.removeEventListener("resize", canShowLabels);
123
- };
124
- }, [canShowLabels]);
125
-
126
- return (
127
- <ol
128
- ref={mergedRef}
129
- className={cl(`navds-step-indicator`, className)}
130
- {...rest}
131
- >
132
- <StepContext.Provider
133
- value={{
134
- activeStep,
135
- onStepChange,
136
- hideLabels: removeLabels,
137
- }}
138
- >
139
- {stepsWithIndex}
140
- </StepContext.Provider>
141
- </ol>
142
- );
143
- }
144
- ) as StepIndicatorComponent;
145
-
146
- StepIndicator.Step = StepIndicatorStep;
147
-
148
- export default StepIndicator;
@@ -1 +0,0 @@
1
- export { default as StepIndicator, StepIndicatorProps } from "./StepIndicator";