@digigov/ui 0.30.3 → 0.32.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 (352) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/admin/AccessibilityMenu/index.d.ts +13 -0
  3. package/admin/AccessibilityMenu/index.js +170 -0
  4. package/admin/AutoComplete/index.d.ts +2 -2
  5. package/admin/Chip/index.d.ts +1 -0
  6. package/admin/Chip/index.js +14 -0
  7. package/admin/CopyToClipboard/CopyToClipboard.stories.playwright.json +2 -2
  8. package/admin/Drawer/__stories__/Default.js +19 -12
  9. package/admin/Dropdown/__stories__/AlignRight.js +0 -2
  10. package/admin/Dropdown/__stories__/Default.js +0 -2
  11. package/admin/Dropdown/__stories__/PlacementTop.js +0 -2
  12. package/admin/FilterSection/index.d.ts +1 -2
  13. package/admin/FilterSection/index.js +4 -18
  14. package/admin/Modal/index.d.ts +2 -2
  15. package/admin/Modal/index.js +17 -12
  16. package/admin/Pagination/__stories__/Default.js +4 -7
  17. package/admin/Pagination/__stories__/PaginationSmall.js +2 -3
  18. package/app/Footer/__stories__/FooterAllInclusive.js +1 -0
  19. package/app/Footer/__stories__/FooterWithSecondaryNavigation.js +1 -0
  20. package/app/Header/__stories__/WithNavigation.js +10 -8
  21. package/app/QrCodeScanner/__stories__/Default.js +3 -3
  22. package/app/QrCodeViewer/QRCode.stories.d.ts +0 -1
  23. package/app/QrCodeViewer/index.d.ts +1 -2
  24. package/app/QrCodeViewer/index.js +10 -10
  25. package/app/ThemeOptionsForm/index.d.ts +2 -0
  26. package/app/ThemeOptionsForm/index.js +243 -0
  27. package/app/ThemePaletteForm/index.d.ts +2 -0
  28. package/app/{ThemeSelectorOptions → ThemePaletteForm}/index.js +9 -8
  29. package/app/index.d.ts +2 -1
  30. package/app/index.js +17 -4
  31. package/core/Accordion/Accordion.stories.playwright.json +2 -2
  32. package/core/Accordion/index.d.ts +2 -2
  33. package/core/Accordion/index.js +7 -7
  34. package/core/Divider/__stories__/Default.js +5 -10
  35. package/core/ErrorSummary/ErrorSummary.stories.playwright.json +1 -1
  36. package/core/ErrorSummary/__stories__/Default.js +3 -3
  37. package/core/ErrorSummary/__stories__/LinkedToCheckbox.js +3 -3
  38. package/core/ErrorSummary/__stories__/LinkedToField.js +3 -3
  39. package/core/ErrorSummary/__stories__/LinkedToInput.js +3 -3
  40. package/core/Link/__stories__/DarkBackground.js +6 -2
  41. package/core/Link/__stories__/DarkBackgroundNoUnderline.js +6 -2
  42. package/core/NavList/NavList.stories.d.ts +1 -3
  43. package/core/NavList/NavList.stories.js +4 -32
  44. package/core/NavList/NavList.stories.playwright.json +6 -6
  45. package/core/NavList/{NavListAuto.js → NavListAuto/NavListAuto.js} +11 -5
  46. package/core/NavList/{NavListBase.d.ts → NavListAuto/NavListBaseAuto.d.ts} +1 -1
  47. package/core/NavList/{NavListBase.js → NavListAuto/NavListBaseAuto.js} +6 -6
  48. package/core/NavList/{NavListContext.d.ts → NavListAuto/NavListContextAuto.d.ts} +7 -4
  49. package/core/NavList/{NavListContext.js → NavListAuto/NavListContextAuto.js} +23 -11
  50. package/core/NavList/NavListAuto/NavListItemAnchorAuto.d.ts +9 -0
  51. package/core/NavList/{NavListSubMenu.js → NavListAuto/NavListItemAnchorAuto.js} +22 -21
  52. package/core/NavList/{NavListItemAuto.js → NavListAuto/NavListItemAuto.js} +20 -22
  53. package/core/NavList/NavListAuto/NavListItemButtonAuto.d.ts +12 -0
  54. package/core/NavList/NavListAuto/NavListItemButtonAuto.js +48 -0
  55. package/core/NavList/NavListAuto/NavListMenuAuto.d.ts +11 -0
  56. package/core/NavList/NavListAuto/NavListMenuAuto.js +56 -0
  57. package/core/NavList/NavListAuto/NavListSubMenuAuto.d.ts +9 -0
  58. package/core/NavList/NavListAuto/NavListSubMenuAuto.js +44 -0
  59. package/core/NavList/NavListItem.js +6 -8
  60. package/core/NavList/NavListItemBase.d.ts +1 -1
  61. package/core/NavList/NavListItemBase.js +4 -9
  62. package/core/NavList/NavMenuContainerContentList.d.ts +3 -1
  63. package/core/NavList/NavMenuContainerContentList.js +73 -3
  64. package/core/NavList/__stories__/Default.js +22 -15
  65. package/core/NavList/__stories__/NavVerticalLayout.d.ts +2 -0
  66. package/core/NavList/__stories__/{NavHorizontalLayout.js → NavVerticalLayout.js} +24 -18
  67. package/core/NavList/index.d.ts +3 -5
  68. package/core/NavList/index.js +9 -23
  69. package/core/NavList/types.d.ts +20 -11
  70. package/core/SingleCharacterInputContainer/SingleCharacterInputContainer.stories.d.ts +13 -0
  71. package/core/SingleCharacterInputContainer/SingleCharacterInputContainer.stories.js +75 -0
  72. package/core/SingleCharacterInputContainer/__stories__/Default.d.ts +2 -0
  73. package/core/SingleCharacterInputContainer/__stories__/Default.js +46 -0
  74. package/core/SingleCharacterInputContainer/__stories__/WithDefaultError.d.ts +2 -0
  75. package/core/SingleCharacterInputContainer/__stories__/WithDefaultError.js +52 -0
  76. package/core/SingleCharacterInputContainer/__stories__/WithErrorMessageInvalidCode.d.ts +2 -0
  77. package/core/SingleCharacterInputContainer/__stories__/WithErrorMessageInvalidCode.js +58 -0
  78. package/core/SingleCharacterInputContainer/__stories__/WithErrorMessageLessDigit.d.ts +2 -0
  79. package/core/SingleCharacterInputContainer/__stories__/WithErrorMessageLessDigit.js +52 -0
  80. package/core/SingleCharacterInputContainer/index.d.ts +4 -0
  81. package/core/SingleCharacterInputContainer/index.js +44 -0
  82. package/core/SingleCharacterInputContainer/index.mdx +29 -0
  83. package/core/Tabs/__stories__/Default.js +5 -5
  84. package/core/Tabs/index.d.ts +2 -2
  85. package/core/Tabs/index.js +5 -7
  86. package/es/admin/AccessibilityMenu/index.js +13 -0
  87. package/es/admin/Chip/index.js +1 -0
  88. package/es/admin/CopyToClipboard/CopyToClipboard.stories.playwright.json +2 -2
  89. package/es/admin/Drawer/__stories__/Default.js +20 -13
  90. package/es/admin/Dropdown/__stories__/AlignRight.js +0 -2
  91. package/es/admin/Dropdown/__stories__/Default.js +0 -2
  92. package/es/admin/Dropdown/__stories__/PlacementTop.js +0 -2
  93. package/es/admin/FilterSection/index.js +1 -2
  94. package/es/admin/Modal/index.js +16 -11
  95. package/es/admin/Pagination/__stories__/Default.js +4 -7
  96. package/es/admin/Pagination/__stories__/PaginationSmall.js +2 -3
  97. package/es/app/Footer/__stories__/FooterAllInclusive.js +1 -0
  98. package/es/app/Footer/__stories__/FooterWithSecondaryNavigation.js +1 -0
  99. package/es/app/Header/__stories__/WithNavigation.js +10 -8
  100. package/es/app/QrCodeScanner/__stories__/Default.js +3 -3
  101. package/es/app/QrCodeViewer/index.js +8 -9
  102. package/es/app/ThemeOptionsForm/index.js +215 -0
  103. package/es/app/{ThemeSelectorOptions → ThemePaletteForm}/index.js +5 -4
  104. package/es/app/index.js +2 -1
  105. package/es/core/Accordion/Accordion.stories.playwright.json +2 -2
  106. package/es/core/Accordion/index.js +7 -7
  107. package/es/core/Divider/__stories__/Default.js +5 -10
  108. package/es/core/ErrorSummary/ErrorSummary.stories.playwright.json +1 -1
  109. package/es/core/ErrorSummary/__stories__/Default.js +3 -3
  110. package/es/core/ErrorSummary/__stories__/LinkedToCheckbox.js +3 -3
  111. package/es/core/ErrorSummary/__stories__/LinkedToField.js +3 -3
  112. package/es/core/ErrorSummary/__stories__/LinkedToInput.js +3 -3
  113. package/es/core/Link/__stories__/DarkBackground.js +6 -2
  114. package/es/core/Link/__stories__/DarkBackgroundNoUnderline.js +6 -2
  115. package/es/core/NavList/NavList.stories.js +1 -3
  116. package/es/core/NavList/NavList.stories.playwright.json +6 -6
  117. package/{esm/core/NavList → es/core/NavList/NavListAuto}/NavListAuto.js +11 -5
  118. package/{esm/core/NavList/NavListBase.js → es/core/NavList/NavListAuto/NavListBaseAuto.js} +4 -4
  119. package/es/core/NavList/{NavListContext.js → NavListAuto/NavListContextAuto.js} +20 -8
  120. package/es/core/NavList/NavListAuto/NavListItemAnchorAuto.js +26 -0
  121. package/es/core/NavList/NavListAuto/NavListItemAuto.js +38 -0
  122. package/es/core/NavList/NavListAuto/NavListItemButtonAuto.js +30 -0
  123. package/es/core/NavList/NavListAuto/NavListMenuAuto.js +36 -0
  124. package/es/core/NavList/NavListAuto/NavListSubMenuAuto.js +26 -0
  125. package/es/core/NavList/NavListItem.js +7 -9
  126. package/es/core/NavList/NavListItemBase.js +4 -9
  127. package/es/core/NavList/NavMenuContainerContentList.js +64 -1
  128. package/es/core/NavList/__stories__/Default.js +22 -15
  129. package/{esm/core/NavList/__stories__/NavHorizontalLayout.js → es/core/NavList/__stories__/NavVerticalLayout.js} +22 -16
  130. package/es/core/NavList/index.js +3 -5
  131. package/es/core/SingleCharacterInputContainer/SingleCharacterInputContainer.stories.js +12 -0
  132. package/es/core/SingleCharacterInputContainer/__stories__/Default.js +31 -0
  133. package/es/core/SingleCharacterInputContainer/__stories__/WithDefaultError.js +35 -0
  134. package/es/core/SingleCharacterInputContainer/__stories__/WithErrorMessageInvalidCode.js +41 -0
  135. package/es/core/SingleCharacterInputContainer/__stories__/WithErrorMessageLessDigit.js +35 -0
  136. package/es/core/SingleCharacterInputContainer/index.js +4 -0
  137. package/es/core/SingleCharacterInputContainer/index.mdx +29 -0
  138. package/es/core/Tabs/__stories__/Default.js +5 -5
  139. package/es/core/Tabs/index.js +5 -7
  140. package/es/hooks/useFontSize.js +10 -0
  141. package/es/hooks/useHighlightLinks.js +38 -0
  142. package/es/hooks/useLetterSpacing.js +10 -0
  143. package/es/hooks/useLineHeight.js +10 -0
  144. package/es/hooks/useNavList.js +10 -7
  145. package/es/hooks/useTheme.js +19 -11
  146. package/es/hooks/useTogglableNav.js +292 -0
  147. package/es/hooks/{useTogglableSections.js → useTogglableTab.js} +2 -8
  148. package/es/hooks/useVariantVars.js +30 -0
  149. package/es/layouts/Basic/__stories__/Default.js +2 -2
  150. package/es/layouts/Basic/__stories__/MultipleRowsLayout.js +3 -3
  151. package/es/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.js +3 -3
  152. package/es/locales/el.js +4 -0
  153. package/es/registry.js +40 -14
  154. package/es/typography/NormalText/__stories__/FontSizes.js +18 -6
  155. package/es/typography/NormalText/__stories__/FontWeight.js +3 -1
  156. package/es/typography/NormalText/__stories__/Variants.js +3 -1
  157. package/esm/admin/AccessibilityMenu/index.js +13 -0
  158. package/esm/admin/Chip/index.js +1 -0
  159. package/esm/admin/CopyToClipboard/CopyToClipboard.stories.playwright.json +2 -2
  160. package/esm/admin/Drawer/__stories__/Default.js +20 -13
  161. package/esm/admin/Dropdown/__stories__/AlignRight.js +0 -2
  162. package/esm/admin/Dropdown/__stories__/Default.js +0 -2
  163. package/esm/admin/Dropdown/__stories__/PlacementTop.js +0 -2
  164. package/esm/admin/FilterSection/index.js +1 -2
  165. package/esm/admin/Modal/index.js +16 -11
  166. package/esm/admin/Pagination/__stories__/Default.js +4 -7
  167. package/esm/admin/Pagination/__stories__/PaginationSmall.js +2 -3
  168. package/esm/app/Footer/__stories__/FooterAllInclusive.js +1 -0
  169. package/esm/app/Footer/__stories__/FooterWithSecondaryNavigation.js +1 -0
  170. package/esm/app/Header/__stories__/WithNavigation.js +10 -8
  171. package/esm/app/QrCodeScanner/__stories__/Default.js +3 -3
  172. package/esm/app/QrCodeViewer/index.js +8 -9
  173. package/esm/app/ThemeOptionsForm/index.js +215 -0
  174. package/esm/app/{ThemeSelectorOptions → ThemePaletteForm}/index.js +5 -4
  175. package/esm/app/index.js +2 -1
  176. package/esm/core/Accordion/Accordion.stories.playwright.json +2 -2
  177. package/esm/core/Accordion/index.js +7 -7
  178. package/esm/core/Divider/__stories__/Default.js +5 -10
  179. package/esm/core/ErrorSummary/ErrorSummary.stories.playwright.json +1 -1
  180. package/esm/core/ErrorSummary/__stories__/Default.js +3 -3
  181. package/esm/core/ErrorSummary/__stories__/LinkedToCheckbox.js +3 -3
  182. package/esm/core/ErrorSummary/__stories__/LinkedToField.js +3 -3
  183. package/esm/core/ErrorSummary/__stories__/LinkedToInput.js +3 -3
  184. package/esm/core/Link/__stories__/DarkBackground.js +6 -2
  185. package/esm/core/Link/__stories__/DarkBackgroundNoUnderline.js +6 -2
  186. package/esm/core/NavList/NavList.stories.js +1 -3
  187. package/esm/core/NavList/NavList.stories.playwright.json +6 -6
  188. package/{es/core/NavList → esm/core/NavList/NavListAuto}/NavListAuto.js +11 -5
  189. package/{es/core/NavList/NavListBase.js → esm/core/NavList/NavListAuto/NavListBaseAuto.js} +4 -4
  190. package/esm/core/NavList/{NavListContext.js → NavListAuto/NavListContextAuto.js} +20 -8
  191. package/esm/core/NavList/NavListAuto/NavListItemAnchorAuto.js +26 -0
  192. package/esm/core/NavList/NavListAuto/NavListItemAuto.js +38 -0
  193. package/esm/core/NavList/NavListAuto/NavListItemButtonAuto.js +30 -0
  194. package/esm/core/NavList/NavListAuto/NavListMenuAuto.js +36 -0
  195. package/esm/core/NavList/NavListAuto/NavListSubMenuAuto.js +26 -0
  196. package/esm/core/NavList/NavListItem.js +7 -9
  197. package/esm/core/NavList/NavListItemBase.js +4 -9
  198. package/esm/core/NavList/NavMenuContainerContentList.js +64 -1
  199. package/esm/core/NavList/__stories__/Default.js +22 -15
  200. package/{es/core/NavList/__stories__/NavHorizontalLayout.js → esm/core/NavList/__stories__/NavVerticalLayout.js} +22 -16
  201. package/esm/core/NavList/index.js +3 -5
  202. package/esm/core/SingleCharacterInputContainer/SingleCharacterInputContainer.stories.js +12 -0
  203. package/esm/core/SingleCharacterInputContainer/__stories__/Default.js +31 -0
  204. package/esm/core/SingleCharacterInputContainer/__stories__/WithDefaultError.js +35 -0
  205. package/esm/core/SingleCharacterInputContainer/__stories__/WithErrorMessageInvalidCode.js +41 -0
  206. package/esm/core/SingleCharacterInputContainer/__stories__/WithErrorMessageLessDigit.js +35 -0
  207. package/esm/core/SingleCharacterInputContainer/index.js +4 -0
  208. package/esm/core/SingleCharacterInputContainer/index.mdx +29 -0
  209. package/esm/core/Tabs/__stories__/Default.js +5 -5
  210. package/esm/core/Tabs/index.js +5 -7
  211. package/esm/hooks/useFontSize.js +10 -0
  212. package/esm/hooks/useHighlightLinks.js +38 -0
  213. package/esm/hooks/useLetterSpacing.js +10 -0
  214. package/esm/hooks/useLineHeight.js +10 -0
  215. package/esm/hooks/useNavList.js +10 -7
  216. package/esm/hooks/useTheme.js +19 -11
  217. package/esm/hooks/useTogglableNav.js +292 -0
  218. package/esm/hooks/{useTogglableSections.js → useTogglableTab.js} +2 -8
  219. package/esm/hooks/useVariantVars.js +30 -0
  220. package/esm/index.js +1 -1
  221. package/esm/layouts/Basic/__stories__/Default.js +2 -2
  222. package/esm/layouts/Basic/__stories__/MultipleRowsLayout.js +3 -3
  223. package/esm/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.js +3 -3
  224. package/esm/locales/el.js +4 -0
  225. package/esm/registry.js +40 -14
  226. package/esm/typography/NormalText/__stories__/FontSizes.js +18 -6
  227. package/esm/typography/NormalText/__stories__/FontWeight.js +3 -1
  228. package/esm/typography/NormalText/__stories__/Variants.js +3 -1
  229. package/hooks/useFontSize.d.ts +6 -0
  230. package/hooks/useFontSize.js +23 -0
  231. package/hooks/useHighlightLinks.d.ts +8 -0
  232. package/hooks/useHighlightLinks.js +52 -0
  233. package/hooks/useLetterSpacing.d.ts +6 -0
  234. package/hooks/useLetterSpacing.js +23 -0
  235. package/hooks/useLineHeight.d.ts +6 -0
  236. package/hooks/useLineHeight.js +23 -0
  237. package/hooks/useNavList.d.ts +2 -2
  238. package/hooks/useNavList.js +11 -8
  239. package/hooks/useTheme.d.ts +4 -4
  240. package/hooks/useTheme.js +19 -12
  241. package/hooks/useTogglableNav.d.ts +25 -0
  242. package/hooks/useTogglableNav.js +305 -0
  243. package/hooks/{useTogglableSections.d.ts → useTogglableTab.d.ts} +4 -3
  244. package/hooks/{useTogglableSections.js → useTogglableTab.js} +3 -9
  245. package/hooks/useVariantVars.d.ts +11 -0
  246. package/hooks/useVariantVars.js +41 -0
  247. package/layouts/Basic/__stories__/Default.js +2 -2
  248. package/layouts/Basic/__stories__/MultipleRowsLayout.js +3 -3
  249. package/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.js +3 -3
  250. package/locales/el.d.ts +4 -0
  251. package/locales/el.js +4 -0
  252. package/package.json +3 -3
  253. package/registry.d.ts +21 -7
  254. package/registry.js +55 -16
  255. package/src/admin/AccessibilityMenu/index.tsx +14 -0
  256. package/src/admin/AutoComplete/index.tsx +2 -2
  257. package/src/admin/Chip/index.tsx +1 -0
  258. package/src/admin/CopyToClipboard/CopyToClipboard.stories.playwright.json +2 -2
  259. package/src/admin/Drawer/__stories__/Default.tsx +24 -13
  260. package/src/admin/Dropdown/__stories__/AlignRight.tsx +2 -2
  261. package/src/admin/Dropdown/__stories__/Default.tsx +2 -2
  262. package/src/admin/Dropdown/__stories__/PlacementTop.tsx +2 -2
  263. package/src/admin/FilterSection/index.tsx +1 -2
  264. package/src/admin/Modal/index.tsx +43 -39
  265. package/src/admin/Pagination/__stories__/Default.tsx +4 -4
  266. package/src/admin/Pagination/__stories__/PaginationSmall.tsx +2 -2
  267. package/src/app/Footer/__stories__/FooterAllInclusive.tsx +1 -1
  268. package/src/app/Footer/__stories__/FooterWithSecondaryNavigation.tsx +1 -1
  269. package/src/app/Header/__stories__/WithNavigation.tsx +8 -8
  270. package/src/app/QrCodeScanner/__stories__/Default.tsx +2 -2
  271. package/src/app/QrCodeViewer/index.tsx +16 -14
  272. package/src/app/ThemeOptionsForm/index.tsx +220 -0
  273. package/src/app/{ThemeSelectorOptions → ThemePaletteForm}/index.tsx +3 -3
  274. package/src/app/index.ts +2 -1
  275. package/src/core/Accordion/Accordion.stories.playwright.json +2 -2
  276. package/src/core/Accordion/index.tsx +5 -11
  277. package/src/core/Divider/__stories__/Default.tsx +5 -5
  278. package/src/core/ErrorSummary/ErrorSummary.stories.playwright.json +1 -1
  279. package/src/core/ErrorSummary/__stories__/Default.tsx +2 -2
  280. package/src/core/ErrorSummary/__stories__/LinkedToCheckbox.tsx +2 -2
  281. package/src/core/ErrorSummary/__stories__/LinkedToField.tsx +2 -2
  282. package/src/core/ErrorSummary/__stories__/LinkedToInput.tsx +2 -2
  283. package/src/core/Link/__stories__/DarkBackground.tsx +2 -3
  284. package/src/core/Link/__stories__/DarkBackgroundNoUnderline.tsx +2 -3
  285. package/src/core/NavList/NavList.stories.js +1 -3
  286. package/src/core/NavList/NavList.stories.playwright.json +6 -6
  287. package/src/core/NavList/NavListAuto/NavListAuto.tsx +34 -0
  288. package/src/core/NavList/{NavListBase.tsx → NavListAuto/NavListBaseAuto.tsx} +3 -3
  289. package/src/core/NavList/{NavListContext.tsx → NavListAuto/NavListContextAuto.tsx} +26 -11
  290. package/src/core/NavList/NavListAuto/NavListItemAnchorAuto.tsx +38 -0
  291. package/src/core/NavList/NavListAuto/NavListItemAuto.tsx +49 -0
  292. package/src/core/NavList/NavListAuto/NavListItemButtonAuto.tsx +53 -0
  293. package/src/core/NavList/NavListAuto/NavListMenuAuto.tsx +51 -0
  294. package/src/core/NavList/NavListAuto/NavListSubMenuAuto.tsx +32 -0
  295. package/src/core/NavList/NavListItem.tsx +15 -10
  296. package/src/core/NavList/NavListItemBase.tsx +5 -8
  297. package/src/core/NavList/NavMenuContainerContentList.tsx +61 -1
  298. package/src/core/NavList/__stories__/Default.tsx +26 -14
  299. package/src/core/NavList/__stories__/{NavHorizontalLayout.tsx → NavVerticalLayout.tsx} +29 -16
  300. package/src/core/NavList/index.tsx +3 -5
  301. package/src/core/NavList/types.tsx +23 -10
  302. package/src/core/SingleCharacterInputContainer/SingleCharacterInputContainer.stories.js +13 -0
  303. package/src/core/SingleCharacterInputContainer/__stories__/Default.tsx +35 -0
  304. package/src/core/SingleCharacterInputContainer/__stories__/WithDefaultError.tsx +38 -0
  305. package/src/core/SingleCharacterInputContainer/__stories__/WithErrorMessageInvalidCode.tsx +38 -0
  306. package/src/core/SingleCharacterInputContainer/__stories__/WithErrorMessageLessDigit.tsx +38 -0
  307. package/src/core/SingleCharacterInputContainer/index.mdx +29 -0
  308. package/src/core/SingleCharacterInputContainer/index.tsx +4 -0
  309. package/src/core/Tabs/__stories__/Default.tsx +5 -5
  310. package/src/core/Tabs/index.tsx +5 -9
  311. package/src/hooks/useFontSize.ts +32 -0
  312. package/src/hooks/useHighlightLinks.ts +45 -0
  313. package/src/hooks/useLetterSpacing.ts +27 -0
  314. package/src/hooks/useLineHeight.ts +31 -0
  315. package/src/hooks/useNavList.ts +5 -7
  316. package/src/hooks/useTheme.ts +28 -20
  317. package/src/hooks/useTogglableNav.tsx +294 -0
  318. package/src/hooks/{useTogglableSections.tsx → useTogglableTab.tsx} +12 -13
  319. package/src/hooks/useVariantVars.ts +35 -0
  320. package/src/layouts/Basic/__stories__/Default.tsx +3 -3
  321. package/src/layouts/Basic/__stories__/MultipleRowsLayout.tsx +8 -8
  322. package/src/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.tsx +6 -6
  323. package/src/locales/el.ts +4 -0
  324. package/src/registry.js +40 -14
  325. package/src/typography/NormalText/__stories__/FontSizes.tsx +6 -6
  326. package/src/typography/NormalText/__stories__/FontWeight.tsx +1 -1
  327. package/src/typography/NormalText/__stories__/Variants.tsx +1 -1
  328. package/typography/NormalText/__stories__/FontSizes.js +18 -6
  329. package/typography/NormalText/__stories__/FontWeight.js +3 -1
  330. package/typography/NormalText/__stories__/Variants.js +3 -1
  331. package/app/ThemeSelectorOptions/index.d.ts +0 -2
  332. package/core/NavList/NavListSubMenu.d.ts +0 -8
  333. package/core/NavList/__stories__/NavHorizontalLayout.d.ts +0 -2
  334. package/core/NavList/__stories__/NavListAutoExample.d.ts +0 -2
  335. package/core/NavList/__stories__/NavListAutoExample.js +0 -63
  336. package/core/NavList/__stories__/NavListEpathlaExample.d.ts +0 -2
  337. package/core/NavList/__stories__/NavListEpathlaExample.js +0 -141
  338. package/es/core/NavList/NavListItemAuto.js +0 -40
  339. package/es/core/NavList/NavListSubMenu.js +0 -25
  340. package/es/core/NavList/__stories__/NavListAutoExample.js +0 -48
  341. package/es/core/NavList/__stories__/NavListEpathlaExample.js +0 -123
  342. package/esm/core/NavList/NavListItemAuto.js +0 -40
  343. package/esm/core/NavList/NavListSubMenu.js +0 -25
  344. package/esm/core/NavList/__stories__/NavListAutoExample.js +0 -48
  345. package/esm/core/NavList/__stories__/NavListEpathlaExample.js +0 -123
  346. package/src/core/NavList/NavListAuto.tsx +0 -20
  347. package/src/core/NavList/NavListItemAuto.tsx +0 -41
  348. package/src/core/NavList/NavListSubMenu.tsx +0 -28
  349. package/src/core/NavList/__stories__/NavListAutoExample.tsx +0 -53
  350. package/src/core/NavList/__stories__/NavListEpathlaExample.tsx +0 -174
  351. /package/core/NavList/{NavListAuto.d.ts → NavListAuto/NavListAuto.d.ts} +0 -0
  352. /package/core/NavList/{NavListItemAuto.d.ts → NavListAuto/NavListItemAuto.d.ts} +0 -0
@@ -1,13 +1,16 @@
1
1
  import React from 'react';
2
- import { NavLinkInterface } from '@digigov/ui/core/NavList/NavListContext';
2
+ import { NavLinkInterface } from '@digigov/ui/core/NavList/NavListAuto/NavListContextAuto';
3
3
  import { BaseCSSProperties } from '@material-ui/core/styles/withStyles';
4
+ import { NavProps } from '@digigov/ui/core/NavList';
4
5
 
5
6
  export type NavListLayout = 'horizontal' | 'vertical';
6
7
 
7
- export interface NavListAutoProps {
8
+ export interface NavListAutoProps extends NavProps {
8
9
  children?: React.ReactNode;
9
10
  className?: string;
10
11
  layout?: NavListLayout;
12
+ border?: boolean;
13
+ fixed?: boolean;
11
14
  role?: string;
12
15
  openSubMenus?: boolean;
13
16
  floating?: boolean;
@@ -16,6 +19,14 @@ export interface NavListAutoProps {
16
19
  style?: BaseCSSProperties;
17
20
  }
18
21
 
22
+ export interface NavListHeaderItemType {
23
+ name: string;
24
+ label?: string;
25
+ title?: string;
26
+ children?: React.ReactNode;
27
+ subMenu: NavListItemLinkInterface[];
28
+ }
29
+
19
30
  interface NavListItemInterface {
20
31
  name: string;
21
32
  label?: string;
@@ -27,18 +38,20 @@ interface NavListItemLinkInterface extends NavListItemInterface {
27
38
  href: string;
28
39
  }
29
40
 
30
- export interface NavListHeaderItemType {
31
- name: string;
32
- label?: string;
33
- title?: string;
34
- children?: React.ReactNode;
35
- subMenu: NavListItemLinkInterface[];
41
+ interface NavListItemMenuInterface extends NavListItemInterface {
42
+ links: NavListItemLinkInterface[];
36
43
  }
37
44
 
38
45
  export type NavListItemType =
39
46
  | NavListItemLinkInterface
47
+ | NavListItemMenuContainerInterface
40
48
  | NavListItemSubMenuInterface;
41
49
 
50
+ export interface NavListItemMenuContainerInterface
51
+ extends NavListItemInterface {
52
+ menu: NavListItemMenuInterface[];
53
+ }
54
+
42
55
  export interface NavListItemSubMenuInterface extends NavListItemInterface {
43
56
  subMenu: NavListItemType[];
44
57
  }
@@ -59,7 +72,7 @@ export interface NavListItemProps {
59
72
  children?: React.ReactNode;
60
73
  role?: string;
61
74
  link?: NavListItemType;
62
- layout?: NavListLayout;
63
75
  active?: boolean;
64
- setRegister?: (name: string) => any;
76
+ setRegisterButton?: (name: string) => any;
77
+ setRegisterLink?: (name: string) => any;
65
78
  }
@@ -0,0 +1,13 @@
1
+ import SingleCharacterInputContainer from '@digigov/ui/core/SingleCharacterInputContainer';
2
+ export default {
3
+ title: 'Digigov UI/core/SingleCharacterInputContainer',
4
+ description:
5
+ 'Use the One-time password input component to help users enter a memorable digital character for One-time password.',
6
+ link: 'https://guide.services.gov.gr/docs/patterns/one-time-password',
7
+ component: SingleCharacterInputContainer,
8
+ displayName: 'SingleCharacterInputContainer',
9
+ };
10
+ export * from '@digigov/ui/core/SingleCharacterInputContainer/__stories__/Default';
11
+ export * from '@digigov/ui/core/SingleCharacterInputContainer/__stories__/WithDefaultError';
12
+ export * from '@digigov/ui/core/SingleCharacterInputContainer/__stories__/WithErrorMessageInvalidCode';
13
+ export * from '@digigov/ui/core/SingleCharacterInputContainer/__stories__/WithErrorMessageLessDigit';
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ SingleCharacterInputContainer,
5
+ SingleCharacterInputItem,
6
+ } from '@digigov/ui/core/SingleCharacterInputContainer';
7
+
8
+ import {
9
+ FieldContainer,
10
+ Fieldset,
11
+ FieldsetLegend,
12
+ } from '@digigov/ui/core/FieldContainer';
13
+
14
+ import { Paragraph } from '@digigov/ui/typography/Paragraph';
15
+
16
+ export const Default = () => (
17
+ <FieldContainer>
18
+ <Fieldset>
19
+ <FieldsetLegend heading>Κωδικός Επιβεβαίωσης</FieldsetLegend>
20
+ <Paragraph>
21
+ Εισάγετε τον μοναδικό κωδικό που λάβατε στο ηλεκτρονικό σας ταχυδρομείο
22
+ </Paragraph>
23
+ <SingleCharacterInputContainer>
24
+ <SingleCharacterInputItem name="first-digit" value={4} />
25
+ <SingleCharacterInputItem name="second-digit" value={4} />
26
+ <SingleCharacterInputItem name="third-digit" value={5} />
27
+ <SingleCharacterInputItem name="forth-digit" value={1} />
28
+ <SingleCharacterInputItem name="fifth-digit" value={2} />
29
+ <SingleCharacterInputItem name="sixth-digit" value={3} />
30
+ </SingleCharacterInputContainer>
31
+ </Fieldset>
32
+ </FieldContainer>
33
+ );
34
+
35
+ export default Default;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import {
3
+ SingleCharacterInputContainer,
4
+ SingleCharacterInputItem,
5
+ } from '@digigov/ui/core/SingleCharacterInputContainer';
6
+ import {
7
+ FieldContainer,
8
+ Fieldset,
9
+ FieldsetLegend,
10
+ } from '@digigov/ui/core/FieldContainer';
11
+ import { Paragraph } from '@digigov/ui/typography/Paragraph';
12
+ import { ErrorMessage } from '@digigov/ui/core/ErrorMessage';
13
+ import { VisuallyHidden } from '@digigov/ui/core/VisuallyHidden';
14
+
15
+ export const WithDefaultError = () => (
16
+ <FieldContainer error>
17
+ <Fieldset>
18
+ <FieldsetLegend heading>Κωδικός Επιβεβαίωσης</FieldsetLegend>
19
+ <Paragraph>
20
+ Εισάγετε τον μοναδικό κωδικό που λάβατε στο ηλεκτρονικό σας ταχυδρομείο
21
+ </Paragraph>
22
+ <ErrorMessage>
23
+ <VisuallyHidden>Λάθος:</VisuallyHidden>
24
+ Το πεδίο είναι υποχρεωτικό.
25
+ </ErrorMessage>
26
+ <SingleCharacterInputContainer>
27
+ <SingleCharacterInputItem name="first-digit" error />
28
+ <SingleCharacterInputItem name="second-digit" error />
29
+ <SingleCharacterInputItem name="third-digit" error />
30
+ <SingleCharacterInputItem name="forth-digit" error />
31
+ <SingleCharacterInputItem name="fifth-digit" error />
32
+ <SingleCharacterInputItem name="sixth-digit" error />
33
+ </SingleCharacterInputContainer>
34
+ </Fieldset>
35
+ </FieldContainer>
36
+ );
37
+
38
+ export default WithDefaultError;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import {
3
+ SingleCharacterInputContainer,
4
+ SingleCharacterInputItem,
5
+ } from '@digigov/ui/core/SingleCharacterInputContainer';
6
+ import {
7
+ FieldContainer,
8
+ Fieldset,
9
+ FieldsetLegend,
10
+ } from '@digigov/ui/core/FieldContainer';
11
+ import { Paragraph } from '@digigov/ui/typography/Paragraph';
12
+ import { ErrorMessage } from '@digigov/ui/core/ErrorMessage';
13
+ import { VisuallyHidden } from '@digigov/ui/core/VisuallyHidden';
14
+
15
+ export const WithErrorMessageInvalidCode = () => (
16
+ <FieldContainer error>
17
+ <Fieldset>
18
+ <FieldsetLegend heading>Κωδικός Επιβεβαίωσης</FieldsetLegend>
19
+ <Paragraph>
20
+ Εισάγετε τον μοναδικό κωδικό που λάβατε στο ηλεκτρονικό σας ταχυδρομείο
21
+ </Paragraph>
22
+ <ErrorMessage>
23
+ <VisuallyHidden>Λάθος:</VisuallyHidden>
24
+ Έχετε εισάγει λάθος κωδικό.
25
+ </ErrorMessage>
26
+ <SingleCharacterInputContainer>
27
+ <SingleCharacterInputItem name="first-digit" value={4} error />
28
+ <SingleCharacterInputItem name="second-digit" value={4} error />
29
+ <SingleCharacterInputItem name="third-digit" value={5} error />
30
+ <SingleCharacterInputItem name="forth-digit" value={1} error />
31
+ <SingleCharacterInputItem name="fifth-digit" value={2} error />
32
+ <SingleCharacterInputItem name="sixth-digit" value={3} error />
33
+ </SingleCharacterInputContainer>
34
+ </Fieldset>
35
+ </FieldContainer>
36
+ );
37
+
38
+ export default WithErrorMessageInvalidCode;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import {
3
+ SingleCharacterInputContainer,
4
+ SingleCharacterInputItem,
5
+ } from '@digigov/ui/core/SingleCharacterInputContainer';
6
+ import {
7
+ FieldContainer,
8
+ Fieldset,
9
+ FieldsetLegend,
10
+ } from '@digigov/ui/core/FieldContainer';
11
+ import { Paragraph } from '@digigov/ui/typography/Paragraph';
12
+ import { ErrorMessage } from '@digigov/ui/core/ErrorMessage';
13
+ import { VisuallyHidden } from '@digigov/ui/core/VisuallyHidden';
14
+
15
+ export const WithErrorMessageLessDigit = () => (
16
+ <FieldContainer error>
17
+ <Fieldset>
18
+ <FieldsetLegend heading>Κωδικός Επιβεβαίωσης</FieldsetLegend>
19
+ <Paragraph>
20
+ Εισάγετε τον μοναδικό κωδικό που λάβατε στο ηλεκτρονικό σας ταχυδρομείο
21
+ </Paragraph>
22
+ <ErrorMessage>
23
+ <VisuallyHidden>Λάθος:</VisuallyHidden>
24
+ Έχετε συμπληρώσει λιγότερα από 6 ψηφία..
25
+ </ErrorMessage>
26
+ <SingleCharacterInputContainer>
27
+ <SingleCharacterInputItem name="first-digit" value="6" />
28
+ <SingleCharacterInputItem name="second-digit" value="4" />
29
+ <SingleCharacterInputItem name="third-digit" value="5" />
30
+ <SingleCharacterInputItem name="forth-digit" error />
31
+ <SingleCharacterInputItem name="fifth-digit" error />
32
+ <SingleCharacterInputItem name="sixth-digit" error />
33
+ </SingleCharacterInputContainer>
34
+ </Fieldset>
35
+ </FieldContainer>
36
+ );
37
+
38
+ export default WithErrorMessageLessDigit;
@@ -0,0 +1,29 @@
1
+ ---
2
+ id: otp-input
3
+ title: SingleCharacterInputContainer
4
+ ---
5
+
6
+ # SingleCharacterInputItem
7
+
8
+ ```bash
9
+ import SingleCharacterInputContainer from '@digigov/ui/core/SingleCharacterInputContainer';
10
+ ```
11
+
12
+ ## How to use
13
+
14
+ <Story
15
+ packageName="@digigov/ui"
16
+ component="core/SingleCharacterInputContainer"
17
+ story="Default.tsx"
18
+ />
19
+
20
+
21
+ ### Error message
22
+
23
+ If you’re highlighting the whole date, style all the fields like this:
24
+
25
+ <Story
26
+ packageName="@digigov/ui"
27
+ component="core/SingleCharacterInputContainer"
28
+ story="WithDefaultError.tsx"
29
+ />
@@ -0,0 +1,4 @@
1
+ export * from '@digigov/react-core/SingleCharacterInputContainer';
2
+ export * from '@digigov/react-core/SingleCharacterInputItem';
3
+ import SingleCharacterInputContainer from '@digigov/react-core/SingleCharacterInputContainer';
4
+ export default SingleCharacterInputContainer;
@@ -8,7 +8,7 @@ import {
8
8
  useTabs,
9
9
  } from '@digigov/ui/core/Tabs';
10
10
 
11
- import { Title } from '@digigov/ui/typography/Title';
11
+ import { Heading } from '@digigov/ui/typography/Heading';
12
12
  import { VisuallyHidden } from '@digigov/ui/core/VisuallyHidden';
13
13
 
14
14
  import {
@@ -30,9 +30,9 @@ export function Default() {
30
30
  <TabsListItem {...register('b')}>Yποθέσεις</TabsListItem>
31
31
  </TabsList>
32
32
  <TabsPanel {...panel('a')}>
33
- <Title size="md" element="h3">
33
+ <Heading size="m" element="h3">
34
34
  Στοιχεία πολίτη
35
- </Title>
35
+ </Heading>
36
36
  <SummaryList>
37
37
  <SummaryListItem>
38
38
  <SummaryListItemKey>Όνομα</SummaryListItemKey>
@@ -62,9 +62,9 @@ export function Default() {
62
62
  </SummaryList>
63
63
  </TabsPanel>
64
64
  <TabsPanel {...panel('b')}>
65
- <Title size="md" element="h3">
65
+ <Heading size="m" element="h3">
66
66
  Yποθέσεις
67
- </Title>
67
+ </Heading>
68
68
  Περιεχόμενα υποθέσεων
69
69
  </TabsPanel>
70
70
  </Tabs>
@@ -1,20 +1,16 @@
1
1
  import { useCallback, useRef } from 'react';
2
2
  import Tabs from '@digigov/react-core/Tabs';
3
3
  import {
4
- useTogglableSections,
5
- UseTogglableSectionsReturn,
6
- } from '@digigov/ui/hooks/useTogglableSections';
4
+ useTogglableTab,
5
+ UseTogglableTabReturn,
6
+ } from '@digigov/ui/hooks/useTogglableTab';
7
7
 
8
- export interface UseTabsReturn extends UseTogglableSectionsReturn {
8
+ export interface UseTabsReturn extends UseTogglableTabReturn {
9
9
  panel: (key: string) => { active: boolean; tabIndex: number; id: string };
10
10
  }
11
11
  export const useTabs = (): UseTabsReturn => {
12
12
  const registeredPanels = useRef({});
13
13
  const goTo = useCallback((key: string) => {
14
- console.log(
15
- registeredPanels.current[key].offsetTop -
16
- rest.registered.current[key].offsetTop
17
- );
18
14
  if (
19
15
  registeredPanels.current[key].offsetTop -
20
16
  rest.registered.current[key].offsetTop >=
@@ -26,7 +22,7 @@ export const useTabs = (): UseTabsReturn => {
26
22
  });
27
23
  }
28
24
  }, []);
29
- const { register, opened, ...rest } = useTogglableSections({
25
+ const { register, opened, ...rest } = useTogglableTab({
30
26
  singleOpen: true,
31
27
  toggleProperty: 'selected',
32
28
  onToggleProperty: 'onClick',
@@ -0,0 +1,32 @@
1
+ import useVariantVars, { UseVariantVarsResult } from "@digigov/ui/hooks/useVariantVars";
2
+
3
+ export type FontSizeOptions = 'default' | 'large';
4
+ export type StoredFontSizeOptions = FontSizeOptions | null;
5
+
6
+ export type UseFontSizeResult = UseVariantVarsResult<FontSizeOptions>
7
+
8
+ export const useFontSize = (): UseFontSizeResult => {
9
+
10
+ const config = {
11
+ 'name': 'font-size',
12
+ 'variables': [
13
+ 'text-sm',
14
+ 'text-base',
15
+ 'text-lg',
16
+ 'text-xl',
17
+ 'text-2xl',
18
+ 'text-3xl',
19
+ 'text-4xl',
20
+ 'text-5xl',
21
+ ],
22
+ 'variants': [
23
+ 'default',
24
+ 'large'
25
+ ]
26
+ }
27
+ return useVariantVars(config);
28
+ };
29
+
30
+
31
+
32
+ export default useFontSize;
@@ -0,0 +1,45 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ export type HighlightLinksOptions = 'default' | 'highlight';
4
+ export type StoredHighlightLinksOptions = HighlightLinksOptions | null;
5
+
6
+ export type UseHighlightLinksResult = [
7
+ highlightLinks: HighlightLinksOptions,
8
+ changeHighlightLinks: (selectedHighlightLinks: HighlightLinksOptions) => void,
9
+ ]
10
+
11
+ export const useHighlightLinks = (): UseHighlightLinksResult => {
12
+ const storedHighlightLinks = localStorage.getItem('--theme-highlight-links') as StoredHighlightLinksOptions;
13
+
14
+ const [highlightLinks, changeHighlightLinks] = useState<HighlightLinksOptions>(
15
+ storedHighlightLinks || 'default'
16
+ );
17
+
18
+ useEffect(() => {
19
+ if (highlightLinks === 'highlight') {
20
+ document.documentElement.classList.add(`govgr-highlight-links`);
21
+ } else {
22
+ document.documentElement.classList.remove(`govgr-highlight-links`);
23
+ }
24
+ localStorage.setItem('--theme-highlight-links', highlightLinks);
25
+ }, [highlightLinks]);
26
+
27
+ useEffect(() => {
28
+ const beforePrintListener = () => {
29
+ document.documentElement.classList.remove(`govgr-highlight-links`);
30
+ };
31
+ const afterPrintListener = () => {
32
+ document.documentElement.classList.add(localStorage.getItem('--theme-highlight-links')=== 'highlight' ? `govgr-highlight-links`: '');
33
+ };
34
+ window.addEventListener('beforeprint', beforePrintListener);
35
+ window.addEventListener('afterprint', afterPrintListener);
36
+ return () => {
37
+ window.removeEventListener('beforeprint', beforePrintListener);
38
+ window.removeEventListener('afterprint', afterPrintListener);
39
+ };
40
+ }, []);
41
+
42
+ return [highlightLinks, changeHighlightLinks ];
43
+ };
44
+
45
+ export default useHighlightLinks;
@@ -0,0 +1,27 @@
1
+ import useVariantVars, { UseVariantVarsResult } from '@digigov/ui/hooks/useVariantVars';
2
+
3
+ export type LetterSpacingOptions = 'default' | 'extra';
4
+ export type StoredLetterSpacingOptions = LetterSpacingOptions | null;
5
+
6
+ export type UseLetterSpacingResult = UseVariantVarsResult<LetterSpacingOptions>
7
+
8
+ export const useLetterSpacing = (): UseLetterSpacingResult => {
9
+
10
+ const config = {
11
+ name: 'letter-spacing',
12
+ variables: [
13
+ "letter-spacing-normal",
14
+ "letter-spacing-wide",
15
+ "letter-spacing-wider",
16
+ "letter-spacing-widest"
17
+ ],
18
+ variants: [
19
+ 'default',
20
+ 'extra'
21
+ ]
22
+ }
23
+
24
+ return useVariantVars(config);
25
+ };
26
+
27
+ export default useLetterSpacing;
@@ -0,0 +1,31 @@
1
+ import useVariantVars, { UseVariantVarsResult } from '@digigov/ui/hooks/useVariantVars';
2
+
3
+ export type LineHeightOptions = 'default' | 'large';
4
+ export type StoredLineHeightOptions = LineHeightOptions | null;
5
+
6
+ export type UseLineHeightResult = UseVariantVarsResult<LineHeightOptions>
7
+
8
+ export const useLineHeight = (): UseLineHeightResult => {
9
+
10
+ const config = {
11
+ name: 'line-height',
12
+ variables: [
13
+ "line-h-sm",
14
+ "line-h-base",
15
+ "line-h-lg",
16
+ "line-h-xl",
17
+ "line-h-2xl",
18
+ "line-h-3xl",
19
+ "line-h-4xl",
20
+ "line-h-5xl"
21
+ ],
22
+ variants: [
23
+ 'default',
24
+ 'large'
25
+ ]
26
+ }
27
+ return useVariantVars(config);
28
+
29
+ };
30
+
31
+ export default useLineHeight;
@@ -1,18 +1,16 @@
1
+ import { useTogglableNav, UseTogglableNavReturn } from '@digigov/ui/hooks/useTogglableNav';
1
2
  import { useCallback, useRef } from 'react';
2
- import {
3
- useTogglableSections,
4
- UseTogglableSectionsReturn,
5
- } from '@digigov/ui/hooks/useTogglableSections';
6
3
 
7
- export interface UseNavListReturn extends UseTogglableSectionsReturn {
4
+ export interface UseNavListReturn extends UseTogglableNavReturn {
8
5
  container: (key: string) => { active: boolean; id: string };
9
6
  }
10
7
  export const useNavList = (): UseNavListReturn => {
11
8
  const registeredContainers = useRef({});
12
9
 
13
- const { register, opened, ...rest } = useTogglableSections({
10
+ const { registerButton, registerLink, opened, ...rest } = useTogglableNav({
14
11
  singleOpen: true,
15
12
  toggleOpenClose: true,
13
+ toggleParentOpen: true,
16
14
  toggleProperty: 'active',
17
15
  onToggleProperty: 'onClick',
18
16
  ariaNavigation: true,
@@ -31,6 +29,6 @@ export const useNavList = (): UseNavListReturn => {
31
29
  },
32
30
  [opened]
33
31
  );
34
- return { register, opened, container, ...rest };
32
+ return { registerButton, registerLink, opened, container, ...rest };
35
33
  };
36
34
 
@@ -3,37 +3,45 @@ import { useState, useEffect } from 'react';
3
3
  export type ThemeSelectOptions = 'light' | 'dark' | 'auto';
4
4
  export type StoredThemeOptions = ThemeSelectOptions | null;
5
5
 
6
- export interface UseThemeResult {
7
- theme: ThemeSelectOptions;
8
- changeTheme: (
9
- selectedTheme:ThemeSelectOptions,
10
- ) => void;
11
- };
6
+ export type UseThemeResult = [
7
+ theme: ThemeSelectOptions,
8
+ changeTheme: (selectedTheme: ThemeSelectOptions) => void,
9
+ ]
12
10
 
13
- export const useTheme = () : UseThemeResult => {
11
+ export const useTheme = (): UseThemeResult => {
14
12
  const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)')
15
13
  .matches;
16
- const storedTheme = localStorage.getItem('theme') as StoredThemeOptions;
17
-
18
- const [theme, changeTheme] = useState<ThemeSelectOptions>(storedTheme || 'auto');
14
+ const storedTheme = localStorage.getItem('--theme-palette') as StoredThemeOptions;
19
15
 
16
+ const [theme, changeTheme] = useState<ThemeSelectOptions>(
17
+ storedTheme || 'auto'
18
+ );
20
19
 
21
- useEffect(() => {
20
+ useEffect(() => {
21
+ document.documentElement.classList.remove('dark', 'light', 'auto');
22
22
  if (theme === 'auto') {
23
- document.documentElement.className = prefersDarkScheme ? 'dark' : 'light';
23
+ document.documentElement.classList.add(prefersDarkScheme ? 'dark' : 'light');
24
24
  } else {
25
- document.documentElement.className = theme;
25
+ document.documentElement.classList.add(theme);
26
26
  }
27
- localStorage.setItem('theme', theme);
27
+ localStorage.setItem('--theme-palette', theme);
28
28
  }, [theme]);
29
29
 
30
30
  useEffect(() => {
31
31
  const beforePrintListener = () => {
32
- document.documentElement.className = 'light';
32
+ document.documentElement.classList.remove('dark');
33
+ document.documentElement.classList.add('light');
34
+
33
35
  };
34
36
  const afterPrintListener = () => {
35
- document.documentElement.className =
36
- localStorage.getItem('theme') || theme;
37
+ document.documentElement.classList.remove('light');
38
+ let localtheme;
39
+ if (localStorage.getItem('--theme-palette') === 'auto') {
40
+ localtheme = prefersDarkScheme ? 'dark' : 'light';
41
+ } else {
42
+ localtheme = localStorage.getItem('--theme-palette');
43
+ }
44
+ document.documentElement.classList.add(localtheme || theme);
37
45
  };
38
46
  window.addEventListener('beforeprint', beforePrintListener);
39
47
  window.addEventListener('afterprint', afterPrintListener);
@@ -43,7 +51,7 @@ useEffect(() => {
43
51
  };
44
52
  }, []);
45
53
 
46
- return {theme, changeTheme};
47
- }
54
+ return [ theme, changeTheme ];
55
+ };
48
56
 
49
- export default useTheme;
57
+ export default useTheme;