@digigov/ui 0.30.2 → 0.31.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.
- package/CHANGELOG.md +16 -1
- package/admin/AccessibilityMenu/index.d.ts +13 -0
- package/admin/AccessibilityMenu/index.js +170 -0
- package/admin/AutoComplete/index.d.ts +2 -2
- package/admin/Chip/index.d.ts +1 -0
- package/admin/Chip/index.js +14 -0
- package/admin/Drawer/__stories__/Default.js +18 -7
- package/admin/Dropdown/__stories__/AlignRight.js +0 -2
- package/admin/Dropdown/__stories__/Default.js +0 -2
- package/admin/Dropdown/__stories__/PlacementTop.js +0 -2
- package/admin/FilterSection/index.d.ts +1 -2
- package/admin/FilterSection/index.js +4 -18
- package/admin/Modal/index.d.ts +2 -2
- package/admin/Modal/index.js +17 -12
- package/admin/Pagination/__stories__/Default.js +4 -7
- package/admin/Pagination/__stories__/PaginationSmall.js +2 -3
- package/app/Footer/__stories__/FooterAllInclusive.js +1 -0
- package/app/Footer/__stories__/FooterWithSecondaryNavigation.js +1 -0
- package/app/Header/__stories__/WithNavigation.js +10 -8
- package/app/QrCodeScanner/__stories__/Default.js +3 -3
- package/app/QrCodeViewer/QRCode.stories.d.ts +0 -1
- package/app/QrCodeViewer/index.d.ts +1 -2
- package/app/QrCodeViewer/index.js +10 -10
- package/app/ThemeOptionsForm/index.d.ts +2 -0
- package/app/ThemeOptionsForm/index.js +243 -0
- package/app/ThemePaletteForm/index.d.ts +2 -0
- package/app/{ThemeSelectorOptions → ThemePaletteForm}/index.js +9 -8
- package/app/index.d.ts +2 -1
- package/app/index.js +17 -4
- package/core/Accordion/index.d.ts +2 -2
- package/core/Accordion/index.js +7 -7
- package/core/Divider/__stories__/Default.js +5 -10
- package/core/ErrorSummary/__stories__/Default.js +3 -3
- package/core/ErrorSummary/__stories__/LinkedToCheckbox.js +3 -3
- package/core/ErrorSummary/__stories__/LinkedToField.js +3 -3
- package/core/ErrorSummary/__stories__/LinkedToInput.js +3 -3
- package/core/Link/__stories__/DarkBackground.js +6 -2
- package/core/Link/__stories__/DarkBackgroundNoUnderline.js +6 -2
- package/core/NavList/NavList.stories.d.ts +3 -1
- package/core/NavList/NavList.stories.js +32 -4
- package/core/NavList/NavList.stories.playwright.json +6 -6
- package/core/NavList/{NavListAuto.js → NavListAuto/NavListAuto.js} +11 -5
- package/core/NavList/{NavListBase.d.ts → NavListAuto/NavListBaseAuto.d.ts} +1 -1
- package/core/NavList/{NavListBase.js → NavListAuto/NavListBaseAuto.js} +6 -4
- package/core/NavList/{NavListContext.d.ts → NavListAuto/NavListContextAuto.d.ts} +7 -4
- package/core/NavList/{NavListContext.js → NavListAuto/NavListContextAuto.js} +23 -11
- package/core/NavList/NavListAuto/NavListItemAnchorAuto.d.ts +11 -0
- package/core/NavList/{NavListSubMenu.js → NavListAuto/NavListItemAnchorAuto.js} +25 -21
- package/core/NavList/{NavListItemAuto.js → NavListAuto/NavListItemAuto.js} +23 -20
- package/core/NavList/NavListAuto/NavListItemButtonAuto.d.ts +12 -0
- package/core/NavList/NavListAuto/NavListItemButtonAuto.js +50 -0
- package/core/NavList/NavListAuto/NavListMenuAuto.d.ts +11 -0
- package/core/NavList/NavListAuto/NavListMenuAuto.js +59 -0
- package/core/NavList/NavListAuto/NavListSubMenuAuto.d.ts +9 -0
- package/core/NavList/NavListAuto/NavListSubMenuAuto.js +46 -0
- package/core/NavList/NavListItem.js +6 -5
- package/core/NavList/NavListItemBase.d.ts +1 -1
- package/core/NavList/NavListItemBase.js +3 -3
- package/core/NavList/NavMenuContainerContentList.d.ts +3 -1
- package/core/NavList/NavMenuContainerContentList.js +76 -3
- package/core/NavList/__stories__/Default.js +19 -6
- package/core/NavList/__stories__/NavHorizontalLayout.js +17 -5
- package/core/NavList/__stories__/NavListEpathlaExample.js +24 -12
- package/core/NavList/__stories__/NavListHorizontalAutoExample.d.ts +2 -0
- package/core/NavList/__stories__/NavListHorizontalAutoExample.js +67 -0
- package/core/NavList/__stories__/NavListSecondaryAutoExample.d.ts +2 -0
- package/core/NavList/__stories__/NavListSecondaryAutoExample.js +281 -0
- package/core/NavList/__stories__/NavListVerticalAutoExample.d.ts +2 -0
- package/core/NavList/__stories__/NavListVerticalAutoExample.js +67 -0
- package/core/NavList/index.d.ts +2 -5
- package/core/NavList/index.js +5 -33
- package/core/NavList/types.d.ts +20 -10
- package/core/Tabs/__stories__/Default.js +5 -5
- package/core/Tabs/index.d.ts +2 -2
- package/core/Tabs/index.js +5 -7
- package/es/admin/AccessibilityMenu/index.js +13 -0
- package/es/admin/Chip/index.js +1 -0
- package/es/admin/Drawer/__stories__/Default.js +19 -8
- package/es/admin/Dropdown/__stories__/AlignRight.js +0 -2
- package/es/admin/Dropdown/__stories__/Default.js +0 -2
- package/es/admin/Dropdown/__stories__/PlacementTop.js +0 -2
- package/es/admin/FilterSection/index.js +1 -2
- package/es/admin/Modal/index.js +16 -11
- package/es/admin/Pagination/__stories__/Default.js +4 -7
- package/es/admin/Pagination/__stories__/PaginationSmall.js +2 -3
- package/es/app/Footer/__stories__/FooterAllInclusive.js +1 -0
- package/es/app/Footer/__stories__/FooterWithSecondaryNavigation.js +1 -0
- package/es/app/Header/__stories__/WithNavigation.js +10 -8
- package/es/app/QrCodeScanner/__stories__/Default.js +3 -3
- package/es/app/QrCodeViewer/index.js +8 -9
- package/es/app/ThemeOptionsForm/index.js +215 -0
- package/es/app/{ThemeSelectorOptions → ThemePaletteForm}/index.js +5 -4
- package/es/app/index.js +2 -1
- package/es/core/Accordion/index.js +7 -7
- package/es/core/Divider/__stories__/Default.js +5 -10
- package/es/core/ErrorSummary/__stories__/Default.js +3 -3
- package/es/core/ErrorSummary/__stories__/LinkedToCheckbox.js +3 -3
- package/es/core/ErrorSummary/__stories__/LinkedToField.js +3 -3
- package/es/core/ErrorSummary/__stories__/LinkedToInput.js +3 -3
- package/es/core/Link/__stories__/DarkBackground.js +6 -2
- package/es/core/Link/__stories__/DarkBackgroundNoUnderline.js +6 -2
- package/es/core/NavList/NavList.stories.js +3 -1
- package/es/core/NavList/NavList.stories.playwright.json +6 -6
- package/{esm/core/NavList → es/core/NavList/NavListAuto}/NavListAuto.js +11 -5
- package/{esm/core/NavList/NavListBase.js → es/core/NavList/NavListAuto/NavListBaseAuto.js} +4 -2
- package/es/core/NavList/{NavListContext.js → NavListAuto/NavListContextAuto.js} +20 -8
- package/es/core/NavList/NavListAuto/NavListItemAnchorAuto.js +29 -0
- package/es/core/NavList/NavListAuto/NavListItemAuto.js +42 -0
- package/es/core/NavList/NavListAuto/NavListItemButtonAuto.js +32 -0
- package/es/core/NavList/NavListAuto/NavListMenuAuto.js +39 -0
- package/es/core/NavList/NavListAuto/NavListSubMenuAuto.js +28 -0
- package/es/core/NavList/NavListItem.js +8 -7
- package/es/core/NavList/NavListItemBase.js +3 -3
- package/es/core/NavList/NavMenuContainerContentList.js +67 -1
- package/es/core/NavList/__stories__/Default.js +19 -6
- package/es/core/NavList/__stories__/NavHorizontalLayout.js +17 -5
- package/es/core/NavList/__stories__/NavListEpathlaExample.js +24 -12
- package/es/core/NavList/__stories__/NavListHorizontalAutoExample.js +51 -0
- package/es/core/NavList/__stories__/NavListSecondaryAutoExample.js +255 -0
- package/es/core/NavList/__stories__/NavListVerticalAutoExample.js +51 -0
- package/es/core/NavList/index.js +2 -5
- package/es/core/Tabs/__stories__/Default.js +5 -5
- package/es/core/Tabs/index.js +5 -7
- package/es/hooks/useFontSize.js +10 -0
- package/es/hooks/useHighlightLinks.js +38 -0
- package/es/hooks/useLetterSpacing.js +10 -0
- package/es/hooks/useLineHeight.js +10 -0
- package/es/hooks/useNavList.js +10 -7
- package/es/hooks/useTheme.js +19 -11
- package/es/hooks/useTogglableNav.js +292 -0
- package/es/hooks/{useTogglableSections.js → useTogglableTab.js} +2 -8
- package/es/hooks/useVariantVars.js +30 -0
- package/es/layouts/Basic/__stories__/Default.js +2 -2
- package/es/layouts/Basic/__stories__/MultipleRowsLayout.js +3 -3
- package/es/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.js +3 -3
- package/es/registry.js +36 -14
- package/es/typography/NormalText/__stories__/FontSizes.js +18 -6
- package/es/typography/NormalText/__stories__/FontWeight.js +3 -1
- package/es/typography/NormalText/__stories__/Variants.js +3 -1
- package/esm/admin/AccessibilityMenu/index.js +13 -0
- package/esm/admin/Chip/index.js +1 -0
- package/esm/admin/Drawer/__stories__/Default.js +19 -8
- package/esm/admin/Dropdown/__stories__/AlignRight.js +0 -2
- package/esm/admin/Dropdown/__stories__/Default.js +0 -2
- package/esm/admin/Dropdown/__stories__/PlacementTop.js +0 -2
- package/esm/admin/FilterSection/index.js +1 -2
- package/esm/admin/Modal/index.js +16 -11
- package/esm/admin/Pagination/__stories__/Default.js +4 -7
- package/esm/admin/Pagination/__stories__/PaginationSmall.js +2 -3
- package/esm/app/Footer/__stories__/FooterAllInclusive.js +1 -0
- package/esm/app/Footer/__stories__/FooterWithSecondaryNavigation.js +1 -0
- package/esm/app/Header/__stories__/WithNavigation.js +10 -8
- package/esm/app/QrCodeScanner/__stories__/Default.js +3 -3
- package/esm/app/QrCodeViewer/index.js +8 -9
- package/esm/app/ThemeOptionsForm/index.js +215 -0
- package/esm/app/{ThemeSelectorOptions → ThemePaletteForm}/index.js +5 -4
- package/esm/app/index.js +2 -1
- package/esm/core/Accordion/index.js +7 -7
- package/esm/core/Divider/__stories__/Default.js +5 -10
- package/esm/core/ErrorSummary/__stories__/Default.js +3 -3
- package/esm/core/ErrorSummary/__stories__/LinkedToCheckbox.js +3 -3
- package/esm/core/ErrorSummary/__stories__/LinkedToField.js +3 -3
- package/esm/core/ErrorSummary/__stories__/LinkedToInput.js +3 -3
- package/esm/core/Link/__stories__/DarkBackground.js +6 -2
- package/esm/core/Link/__stories__/DarkBackgroundNoUnderline.js +6 -2
- package/esm/core/NavList/NavList.stories.js +3 -1
- package/esm/core/NavList/NavList.stories.playwright.json +6 -6
- package/{es/core/NavList → esm/core/NavList/NavListAuto}/NavListAuto.js +11 -5
- package/{es/core/NavList/NavListBase.js → esm/core/NavList/NavListAuto/NavListBaseAuto.js} +4 -2
- package/esm/core/NavList/{NavListContext.js → NavListAuto/NavListContextAuto.js} +20 -8
- package/esm/core/NavList/NavListAuto/NavListItemAnchorAuto.js +29 -0
- package/esm/core/NavList/NavListAuto/NavListItemAuto.js +42 -0
- package/esm/core/NavList/NavListAuto/NavListItemButtonAuto.js +32 -0
- package/esm/core/NavList/NavListAuto/NavListMenuAuto.js +39 -0
- package/esm/core/NavList/NavListAuto/NavListSubMenuAuto.js +28 -0
- package/esm/core/NavList/NavListItem.js +8 -7
- package/esm/core/NavList/NavListItemBase.js +3 -3
- package/esm/core/NavList/NavMenuContainerContentList.js +67 -1
- package/esm/core/NavList/__stories__/Default.js +19 -6
- package/esm/core/NavList/__stories__/NavHorizontalLayout.js +17 -5
- package/esm/core/NavList/__stories__/NavListEpathlaExample.js +24 -12
- package/esm/core/NavList/__stories__/NavListHorizontalAutoExample.js +51 -0
- package/esm/core/NavList/__stories__/NavListSecondaryAutoExample.js +255 -0
- package/esm/core/NavList/__stories__/NavListVerticalAutoExample.js +51 -0
- package/esm/core/NavList/index.js +2 -5
- package/esm/core/Tabs/__stories__/Default.js +5 -5
- package/esm/core/Tabs/index.js +5 -7
- package/esm/hooks/useFontSize.js +10 -0
- package/esm/hooks/useHighlightLinks.js +38 -0
- package/esm/hooks/useLetterSpacing.js +10 -0
- package/esm/hooks/useLineHeight.js +10 -0
- package/esm/hooks/useNavList.js +10 -7
- package/esm/hooks/useTheme.js +19 -11
- package/esm/hooks/useTogglableNav.js +292 -0
- package/esm/hooks/{useTogglableSections.js → useTogglableTab.js} +2 -8
- package/esm/hooks/useVariantVars.js +30 -0
- package/esm/index.js +1 -1
- package/esm/layouts/Basic/__stories__/Default.js +2 -2
- package/esm/layouts/Basic/__stories__/MultipleRowsLayout.js +3 -3
- package/esm/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.js +3 -3
- package/esm/registry.js +36 -14
- package/esm/typography/NormalText/__stories__/FontSizes.js +18 -6
- package/esm/typography/NormalText/__stories__/FontWeight.js +3 -1
- package/esm/typography/NormalText/__stories__/Variants.js +3 -1
- package/hooks/useFontSize.d.ts +6 -0
- package/hooks/useFontSize.js +23 -0
- package/hooks/useHighlightLinks.d.ts +8 -0
- package/hooks/useHighlightLinks.js +52 -0
- package/hooks/useLetterSpacing.d.ts +6 -0
- package/hooks/useLetterSpacing.js +23 -0
- package/hooks/useLineHeight.d.ts +6 -0
- package/hooks/useLineHeight.js +23 -0
- package/hooks/useNavList.d.ts +2 -2
- package/hooks/useNavList.js +11 -8
- package/hooks/useTheme.d.ts +4 -4
- package/hooks/useTheme.js +19 -12
- package/hooks/useTogglableNav.d.ts +25 -0
- package/hooks/useTogglableNav.js +305 -0
- package/hooks/{useTogglableSections.d.ts → useTogglableTab.d.ts} +4 -3
- package/hooks/{useTogglableSections.js → useTogglableTab.js} +3 -9
- package/hooks/useVariantVars.d.ts +11 -0
- package/hooks/useVariantVars.js +41 -0
- package/layouts/Basic/__stories__/Default.js +2 -2
- package/layouts/Basic/__stories__/MultipleRowsLayout.js +3 -3
- package/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.js +3 -3
- package/package.json +3 -3
- package/registry.d.ts +18 -7
- package/registry.js +49 -16
- package/src/admin/AccessibilityMenu/index.tsx +14 -0
- package/src/admin/AutoComplete/index.tsx +2 -2
- package/src/admin/Chip/index.tsx +1 -0
- package/src/admin/Drawer/__stories__/Default.tsx +23 -9
- package/src/admin/Dropdown/__stories__/AlignRight.tsx +2 -2
- package/src/admin/Dropdown/__stories__/Default.tsx +2 -2
- package/src/admin/Dropdown/__stories__/PlacementTop.tsx +2 -2
- package/src/admin/FilterSection/index.tsx +1 -2
- package/src/admin/Modal/index.tsx +43 -39
- package/src/admin/Pagination/__stories__/Default.tsx +4 -4
- package/src/admin/Pagination/__stories__/PaginationSmall.tsx +2 -2
- package/src/app/Footer/__stories__/FooterAllInclusive.tsx +1 -1
- package/src/app/Footer/__stories__/FooterWithSecondaryNavigation.tsx +1 -1
- package/src/app/Header/__stories__/WithNavigation.tsx +8 -8
- package/src/app/QrCodeScanner/__stories__/Default.tsx +2 -2
- package/src/app/QrCodeViewer/index.tsx +16 -14
- package/src/app/ThemeOptionsForm/index.tsx +220 -0
- package/src/app/{ThemeSelectorOptions → ThemePaletteForm}/index.tsx +3 -3
- package/src/app/index.ts +2 -1
- package/src/core/Accordion/index.tsx +5 -11
- package/src/core/Divider/__stories__/Default.tsx +5 -5
- package/src/core/ErrorSummary/__stories__/Default.tsx +2 -2
- package/src/core/ErrorSummary/__stories__/LinkedToCheckbox.tsx +2 -2
- package/src/core/ErrorSummary/__stories__/LinkedToField.tsx +2 -2
- package/src/core/ErrorSummary/__stories__/LinkedToInput.tsx +2 -2
- package/src/core/Link/__stories__/DarkBackground.tsx +2 -3
- package/src/core/Link/__stories__/DarkBackgroundNoUnderline.tsx +2 -3
- package/src/core/NavList/NavList.stories.js +3 -1
- package/src/core/NavList/NavList.stories.playwright.json +6 -6
- package/src/core/NavList/NavListAuto/NavListAuto.tsx +34 -0
- package/src/core/NavList/{NavListBase.tsx → NavListAuto/NavListBaseAuto.tsx} +2 -2
- package/src/core/NavList/{NavListContext.tsx → NavListAuto/NavListContextAuto.tsx} +26 -11
- package/src/core/NavList/NavListAuto/NavListItemAnchorAuto.tsx +41 -0
- package/src/core/NavList/NavListAuto/NavListItemAuto.tsx +51 -0
- package/src/core/NavList/NavListAuto/NavListItemButtonAuto.tsx +53 -0
- package/src/core/NavList/NavListAuto/NavListMenuAuto.tsx +51 -0
- package/src/core/NavList/NavListAuto/NavListSubMenuAuto.tsx +32 -0
- package/src/core/NavList/NavListItem.tsx +15 -9
- package/src/core/NavList/NavListItemBase.tsx +3 -3
- package/src/core/NavList/NavMenuContainerContentList.tsx +63 -1
- package/src/core/NavList/__stories__/Default.tsx +23 -8
- package/src/core/NavList/__stories__/NavHorizontalLayout.tsx +24 -8
- package/src/core/NavList/__stories__/NavListEpathlaExample.tsx +46 -25
- package/src/core/NavList/__stories__/NavListHorizontalAutoExample.tsx +65 -0
- package/src/core/NavList/__stories__/NavListSecondaryAutoExample.tsx +284 -0
- package/src/core/NavList/__stories__/NavListVerticalAutoExample.tsx +65 -0
- package/src/core/NavList/index.tsx +2 -5
- package/src/core/NavList/types.tsx +23 -9
- package/src/core/Tabs/__stories__/Default.tsx +5 -5
- package/src/core/Tabs/index.tsx +5 -9
- package/src/hooks/useFontSize.ts +32 -0
- package/src/hooks/useHighlightLinks.ts +45 -0
- package/src/hooks/useLetterSpacing.ts +27 -0
- package/src/hooks/useLineHeight.ts +31 -0
- package/src/hooks/useNavList.ts +5 -7
- package/src/hooks/useTheme.ts +28 -20
- package/src/hooks/useTogglableNav.tsx +294 -0
- package/src/hooks/{useTogglableSections.tsx → useTogglableTab.tsx} +12 -13
- package/src/hooks/useVariantVars.ts +35 -0
- package/src/layouts/Basic/__stories__/Default.tsx +3 -3
- package/src/layouts/Basic/__stories__/MultipleRowsLayout.tsx +8 -8
- package/src/layouts/Basic/__stories__/TwoThirdsOneThirdColumns.tsx +6 -6
- package/src/registry.js +36 -14
- package/src/typography/NormalText/__stories__/FontSizes.tsx +6 -6
- package/src/typography/NormalText/__stories__/FontWeight.tsx +1 -1
- package/src/typography/NormalText/__stories__/Variants.tsx +1 -1
- package/typography/NormalText/__stories__/FontSizes.js +18 -6
- package/typography/NormalText/__stories__/FontWeight.js +3 -1
- package/typography/NormalText/__stories__/Variants.js +3 -1
- package/app/ThemeSelectorOptions/index.d.ts +0 -2
- package/core/NavList/NavListSubMenu.d.ts +0 -8
- package/core/NavList/__stories__/NavListAutoExample.d.ts +0 -2
- package/core/NavList/__stories__/NavListAutoExample.js +0 -63
- package/es/core/NavList/NavListItemAuto.js +0 -40
- package/es/core/NavList/NavListSubMenu.js +0 -25
- package/es/core/NavList/__stories__/NavListAutoExample.js +0 -48
- package/esm/core/NavList/NavListItemAuto.js +0 -40
- package/esm/core/NavList/NavListSubMenu.js +0 -25
- package/esm/core/NavList/__stories__/NavListAutoExample.js +0 -48
- package/src/core/NavList/NavListAuto.tsx +0 -20
- package/src/core/NavList/NavListItemAuto.tsx +0 -41
- package/src/core/NavList/NavListSubMenu.tsx +0 -28
- package/src/core/NavList/__stories__/NavListAutoExample.tsx +0 -53
- /package/core/NavList/{NavListAuto.d.ts → NavListAuto/NavListAuto.d.ts} +0 -0
- /package/core/NavList/{NavListItemAuto.d.ts → NavListAuto/NavListItemAuto.d.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useHighlightLinks = exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
var useHighlightLinks = function useHighlightLinks() {
|
|
15
|
+
var storedHighlightLinks = localStorage.getItem('--theme-highlight-links');
|
|
16
|
+
|
|
17
|
+
var _useState = (0, _react.useState)(storedHighlightLinks || 'default'),
|
|
18
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
19
|
+
highlightLinks = _useState2[0],
|
|
20
|
+
changeHighlightLinks = _useState2[1];
|
|
21
|
+
|
|
22
|
+
(0, _react.useEffect)(function () {
|
|
23
|
+
if (highlightLinks === 'highlight') {
|
|
24
|
+
document.documentElement.classList.add("govgr-highlight-links");
|
|
25
|
+
} else {
|
|
26
|
+
document.documentElement.classList.remove("govgr-highlight-links");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
localStorage.setItem('--theme-highlight-links', highlightLinks);
|
|
30
|
+
}, [highlightLinks]);
|
|
31
|
+
(0, _react.useEffect)(function () {
|
|
32
|
+
var beforePrintListener = function beforePrintListener() {
|
|
33
|
+
document.documentElement.classList.remove("govgr-highlight-links");
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var afterPrintListener = function afterPrintListener() {
|
|
37
|
+
document.documentElement.classList.add(localStorage.getItem('--theme-highlight-links') === 'highlight' ? "govgr-highlight-links" : '');
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
window.addEventListener('beforeprint', beforePrintListener);
|
|
41
|
+
window.addEventListener('afterprint', afterPrintListener);
|
|
42
|
+
return function () {
|
|
43
|
+
window.removeEventListener('beforeprint', beforePrintListener);
|
|
44
|
+
window.removeEventListener('afterprint', afterPrintListener);
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
return [highlightLinks, changeHighlightLinks];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.useHighlightLinks = useHighlightLinks;
|
|
51
|
+
var _default = useHighlightLinks;
|
|
52
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseVariantVarsResult } from '@digigov/ui/hooks/useVariantVars';
|
|
2
|
+
export declare type LetterSpacingOptions = 'default' | 'extra';
|
|
3
|
+
export declare type StoredLetterSpacingOptions = LetterSpacingOptions | null;
|
|
4
|
+
export declare type UseLetterSpacingResult = UseVariantVarsResult<LetterSpacingOptions>;
|
|
5
|
+
export declare const useLetterSpacing: () => UseLetterSpacingResult;
|
|
6
|
+
export default useLetterSpacing;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useLetterSpacing = exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _useVariantVars = _interopRequireDefault(require("@digigov/ui/hooks/useVariantVars"));
|
|
11
|
+
|
|
12
|
+
var useLetterSpacing = function useLetterSpacing() {
|
|
13
|
+
var config = {
|
|
14
|
+
name: 'letter-spacing',
|
|
15
|
+
variables: ["letter-spacing-normal", "letter-spacing-wide", "letter-spacing-wider", "letter-spacing-widest"],
|
|
16
|
+
variants: ['default', 'extra']
|
|
17
|
+
};
|
|
18
|
+
return (0, _useVariantVars["default"])(config);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.useLetterSpacing = useLetterSpacing;
|
|
22
|
+
var _default = useLetterSpacing;
|
|
23
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseVariantVarsResult } from '@digigov/ui/hooks/useVariantVars';
|
|
2
|
+
export declare type LineHeightOptions = 'default' | 'large';
|
|
3
|
+
export declare type StoredLineHeightOptions = LineHeightOptions | null;
|
|
4
|
+
export declare type UseLineHeightResult = UseVariantVarsResult<LineHeightOptions>;
|
|
5
|
+
export declare const useLineHeight: () => UseLineHeightResult;
|
|
6
|
+
export default useLineHeight;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useLineHeight = exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _useVariantVars = _interopRequireDefault(require("@digigov/ui/hooks/useVariantVars"));
|
|
11
|
+
|
|
12
|
+
var useLineHeight = function useLineHeight() {
|
|
13
|
+
var config = {
|
|
14
|
+
name: 'line-height',
|
|
15
|
+
variables: ["line-h-sm", "line-h-base", "line-h-lg", "line-h-xl", "line-h-2xl", "line-h-3xl", "line-h-4xl", "line-h-5xl"],
|
|
16
|
+
variants: ['default', 'large']
|
|
17
|
+
};
|
|
18
|
+
return (0, _useVariantVars["default"])(config);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.useLineHeight = useLineHeight;
|
|
22
|
+
var _default = useLineHeight;
|
|
23
|
+
exports["default"] = _default;
|
package/hooks/useNavList.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UseNavListReturn extends
|
|
1
|
+
import { UseTogglableNavReturn } from '@digigov/ui/hooks/useTogglableNav';
|
|
2
|
+
export interface UseNavListReturn extends UseTogglableNavReturn {
|
|
3
3
|
container: (key: string) => {
|
|
4
4
|
active: boolean;
|
|
5
5
|
id: string;
|
package/hooks/useNavList.js
CHANGED
|
@@ -11,25 +11,27 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _useTogglableNav2 = require("@digigov/ui/hooks/useTogglableNav");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _react = require("react");
|
|
17
17
|
|
|
18
|
-
var _excluded = ["
|
|
18
|
+
var _excluded = ["registerButton", "registerLink", "opened"];
|
|
19
19
|
|
|
20
20
|
var useNavList = function useNavList() {
|
|
21
21
|
var registeredContainers = (0, _react.useRef)({});
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _useTogglableNav = (0, _useTogglableNav2.useTogglableNav)({
|
|
24
24
|
singleOpen: true,
|
|
25
25
|
toggleOpenClose: true,
|
|
26
|
+
toggleParentOpen: true,
|
|
26
27
|
toggleProperty: 'active',
|
|
27
28
|
onToggleProperty: 'onClick',
|
|
28
29
|
ariaNavigation: true
|
|
29
30
|
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
registerButton = _useTogglableNav.registerButton,
|
|
32
|
+
registerLink = _useTogglableNav.registerLink,
|
|
33
|
+
opened = _useTogglableNav.opened,
|
|
34
|
+
rest = (0, _objectWithoutProperties2["default"])(_useTogglableNav, _excluded);
|
|
33
35
|
|
|
34
36
|
var container = (0, _react.useCallback)(function (key) {
|
|
35
37
|
return {
|
|
@@ -43,7 +45,8 @@ var useNavList = function useNavList() {
|
|
|
43
45
|
};
|
|
44
46
|
}, [opened]);
|
|
45
47
|
return (0, _extends2["default"])({
|
|
46
|
-
|
|
48
|
+
registerButton: registerButton,
|
|
49
|
+
registerLink: registerLink,
|
|
47
50
|
opened: opened,
|
|
48
51
|
container: container
|
|
49
52
|
}, rest);
|
package/hooks/useTheme.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare type ThemeSelectOptions = 'light' | 'dark' | 'auto';
|
|
2
2
|
export declare type StoredThemeOptions = ThemeSelectOptions | null;
|
|
3
|
-
export
|
|
4
|
-
theme: ThemeSelectOptions
|
|
5
|
-
changeTheme: (selectedTheme: ThemeSelectOptions) => void
|
|
6
|
-
|
|
3
|
+
export declare type UseThemeResult = [
|
|
4
|
+
theme: ThemeSelectOptions,
|
|
5
|
+
changeTheme: (selectedTheme: ThemeSelectOptions) => void
|
|
6
|
+
];
|
|
7
7
|
export declare const useTheme: () => UseThemeResult;
|
|
8
8
|
export default useTheme;
|
package/hooks/useTheme.js
CHANGED
|
@@ -11,11 +11,9 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
|
|
14
|
-
;
|
|
15
|
-
|
|
16
14
|
var useTheme = function useTheme() {
|
|
17
15
|
var prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
18
|
-
var storedTheme = localStorage.getItem('theme');
|
|
16
|
+
var storedTheme = localStorage.getItem('--theme-palette');
|
|
19
17
|
|
|
20
18
|
var _useState = (0, _react.useState)(storedTheme || 'auto'),
|
|
21
19
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -23,21 +21,33 @@ var useTheme = function useTheme() {
|
|
|
23
21
|
changeTheme = _useState2[1];
|
|
24
22
|
|
|
25
23
|
(0, _react.useEffect)(function () {
|
|
24
|
+
document.documentElement.classList.remove('dark', 'light', 'auto');
|
|
25
|
+
|
|
26
26
|
if (theme === 'auto') {
|
|
27
|
-
document.documentElement.
|
|
27
|
+
document.documentElement.classList.add(prefersDarkScheme ? 'dark' : 'light');
|
|
28
28
|
} else {
|
|
29
|
-
document.documentElement.
|
|
29
|
+
document.documentElement.classList.add(theme);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
localStorage.setItem('theme', theme);
|
|
32
|
+
localStorage.setItem('--theme-palette', theme);
|
|
33
33
|
}, [theme]);
|
|
34
34
|
(0, _react.useEffect)(function () {
|
|
35
35
|
var beforePrintListener = function beforePrintListener() {
|
|
36
|
-
document.documentElement.
|
|
36
|
+
document.documentElement.classList.remove('dark');
|
|
37
|
+
document.documentElement.classList.add('light');
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
var afterPrintListener = function afterPrintListener() {
|
|
40
|
-
document.documentElement.
|
|
41
|
+
document.documentElement.classList.remove('light');
|
|
42
|
+
var localtheme;
|
|
43
|
+
|
|
44
|
+
if (localStorage.getItem('--theme-palette') === 'auto') {
|
|
45
|
+
localtheme = prefersDarkScheme ? 'dark' : 'light';
|
|
46
|
+
} else {
|
|
47
|
+
localtheme = localStorage.getItem('--theme-palette');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
document.documentElement.classList.add(localtheme || theme);
|
|
41
51
|
};
|
|
42
52
|
|
|
43
53
|
window.addEventListener('beforeprint', beforePrintListener);
|
|
@@ -47,10 +57,7 @@ var useTheme = function useTheme() {
|
|
|
47
57
|
window.removeEventListener('afterprint', afterPrintListener);
|
|
48
58
|
};
|
|
49
59
|
}, []);
|
|
50
|
-
return
|
|
51
|
-
theme: theme,
|
|
52
|
-
changeTheme: changeTheme
|
|
53
|
-
};
|
|
60
|
+
return [theme, changeTheme];
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
exports.useTheme = useTheme;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface UseTogglableNavInterface {
|
|
2
|
+
toggleProperty: string;
|
|
3
|
+
singleOpen?: boolean;
|
|
4
|
+
toggleOpenClose?: boolean;
|
|
5
|
+
toggleParentOpen?: boolean;
|
|
6
|
+
onToggleProperty: string;
|
|
7
|
+
initial?: Record<string, boolean>;
|
|
8
|
+
firstOpen?: boolean;
|
|
9
|
+
ariaNavigation?: boolean;
|
|
10
|
+
toggleHook?: (id: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface UseTogglableNavReturn {
|
|
13
|
+
registerButton: (el: string) => any;
|
|
14
|
+
registerLink: (el: string) => any;
|
|
15
|
+
registered: {
|
|
16
|
+
current: Record<string, {
|
|
17
|
+
el: HTMLElement;
|
|
18
|
+
type: string;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
opened: Record<string, boolean>;
|
|
22
|
+
toggle: (id: string) => void;
|
|
23
|
+
setOpened: (opened: ((curOpened: Record<string, boolean>) => Record<string, boolean>) | Record<string, boolean>) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function useTogglableNav({ toggleProperty, toggleOpenClose, toggleParentOpen, onToggleProperty, initial, ariaNavigation, toggleHook, }: UseTogglableNavInterface): UseTogglableNavReturn;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useTogglableNav = useTogglableNav;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = require("react");
|
|
17
|
+
|
|
18
|
+
function useTogglableNav(_ref) {
|
|
19
|
+
var toggleProperty = _ref.toggleProperty,
|
|
20
|
+
toggleOpenClose = _ref.toggleOpenClose,
|
|
21
|
+
toggleParentOpen = _ref.toggleParentOpen,
|
|
22
|
+
onToggleProperty = _ref.onToggleProperty,
|
|
23
|
+
initial = _ref.initial,
|
|
24
|
+
ariaNavigation = _ref.ariaNavigation,
|
|
25
|
+
toggleHook = _ref.toggleHook;
|
|
26
|
+
|
|
27
|
+
var _useState = (0, _react.useState)(initial || {}),
|
|
28
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
29
|
+
opened = _useState2[0],
|
|
30
|
+
setOpened = _useState2[1];
|
|
31
|
+
|
|
32
|
+
var registered = (0, _react.useRef)({});
|
|
33
|
+
var openedKeys = (0, _react.useRef)([]);
|
|
34
|
+
var registerButtonRef = (0, _react.useCallback)(function (el) {
|
|
35
|
+
if (!el) return;
|
|
36
|
+
var key = el.getAttribute('aria-controls');
|
|
37
|
+
if (registered.current[key]) return;
|
|
38
|
+
registered.current[key] = {
|
|
39
|
+
el: el,
|
|
40
|
+
type: 'button'
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
var registerLinkRef = (0, _react.useCallback)(function (el) {
|
|
44
|
+
if (!el) return;
|
|
45
|
+
var key = el.getAttribute('aria-controls');
|
|
46
|
+
if (registered.current[key]) return;
|
|
47
|
+
registered.current[key] = {
|
|
48
|
+
el: el,
|
|
49
|
+
type: 'link'
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
var toggle = (0, _react.useCallback)(function (e) {
|
|
53
|
+
var key = e.currentTarget.getAttribute('aria-controls');
|
|
54
|
+
var selected = e.currentTarget.getAttribute('aria-selected') === 'true';
|
|
55
|
+
|
|
56
|
+
if (toggleHook) {
|
|
57
|
+
toggleHook(key);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
|
|
62
|
+
if (toggleOpenClose) {
|
|
63
|
+
if (toggleParentOpen) {
|
|
64
|
+
var items = key.split('__');
|
|
65
|
+
var currentKey = items.slice(0, items.length).join('__');
|
|
66
|
+
var totalKeys = items.map(function (_, index) {
|
|
67
|
+
return items.slice(0, index + 1).join('__');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!selected && !openedKeys.current.includes(currentKey)) {
|
|
71
|
+
openedKeys.current.push(currentKey);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (selected && openedKeys.current.includes(currentKey)) {
|
|
75
|
+
openedKeys.current = openedKeys.current.filter(function (k) {
|
|
76
|
+
return k !== currentKey;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setOpened(function (_) {
|
|
81
|
+
return (0, _extends3["default"])({}, totalKeys.reduce(function (acc, cur) {
|
|
82
|
+
acc[cur] = cur === currentKey ? !selected : true;
|
|
83
|
+
return acc;
|
|
84
|
+
}, {}));
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
setOpened((0, _defineProperty2["default"])({}, key, !selected));
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
setOpened((0, _defineProperty2["default"])({}, key, true));
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
var getMenuItems = function getMenuItems(element) {
|
|
95
|
+
if (element) {
|
|
96
|
+
if ((element === null || element === void 0 ? void 0 : element.role) === 'menuitem') {
|
|
97
|
+
return element;
|
|
98
|
+
} else {
|
|
99
|
+
var childrenArray = Array.from(element === null || element === void 0 ? void 0 : element.children);
|
|
100
|
+
var menuItemsArray = [];
|
|
101
|
+
childrenArray.forEach(function (child) {
|
|
102
|
+
var menuItem = getMenuItems(child);
|
|
103
|
+
|
|
104
|
+
if (menuItem && !menuItemsArray.includes(menuItem)) {
|
|
105
|
+
menuItemsArray.push(menuItem);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return menuItemsArray.flatMap(function (x) {
|
|
109
|
+
return x;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return null;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var findChildren = function findChildren(parent, items) {
|
|
118
|
+
return items ? items.filter(function (child) {
|
|
119
|
+
return child.slice(0, child.lastIndexOf('__')) === parent;
|
|
120
|
+
}) : items;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var findParent = function findParent(child, items) {
|
|
124
|
+
var parent = child.slice(0, child.lastIndexOf('__'));
|
|
125
|
+
return items.find(function (item) {
|
|
126
|
+
return item === parent;
|
|
127
|
+
}) ? parent : null;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var findSiblings = function findSiblings(key, items) {
|
|
131
|
+
var parent = key.slice(0, key.lastIndexOf('__'));
|
|
132
|
+
|
|
133
|
+
if (key.lastIndexOf('__') > 0) {
|
|
134
|
+
return items.filter(function (child) {
|
|
135
|
+
return child.slice(0, child.lastIndexOf('__')) === parent;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return items.filter(function (child) {
|
|
140
|
+
return !child.includes('__');
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
var findLeftSibling = function findLeftSibling(key, items) {
|
|
145
|
+
var siblings = findSiblings(key, items);
|
|
146
|
+
|
|
147
|
+
if (siblings.length > 0) {
|
|
148
|
+
var keyIndex = siblings.findIndex(function (item) {
|
|
149
|
+
return item === key;
|
|
150
|
+
});
|
|
151
|
+
return keyIndex > 0 ? siblings[keyIndex - 1] : null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return null;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var findRightSibling = function findRightSibling(key, items) {
|
|
158
|
+
var siblings = findSiblings(key, items);
|
|
159
|
+
|
|
160
|
+
if (siblings.length > 0) {
|
|
161
|
+
var keyIndex = siblings.findIndex(function (item) {
|
|
162
|
+
return item === key;
|
|
163
|
+
});
|
|
164
|
+
return keyIndex < siblings.length - 1 ? siblings[keyIndex + 1] : null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return null;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var getOpenItemChildren = function getOpenItemChildren(currentItem, items) {
|
|
171
|
+
var itemChildrenArray = [];
|
|
172
|
+
var itemChildren = findChildren(currentItem, items);
|
|
173
|
+
itemChildren.forEach(function (item) {
|
|
174
|
+
if (openedKeys.current.includes(item)) {
|
|
175
|
+
itemChildrenArray.push(item);
|
|
176
|
+
var internChildren = getOpenItemChildren(item, items);
|
|
177
|
+
|
|
178
|
+
if (internChildren.length > 0) {
|
|
179
|
+
itemChildrenArray.push(internChildren);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
itemChildrenArray.push(item);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return itemChildrenArray.flatMap(function (x) {
|
|
186
|
+
return x;
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
191
|
+
var _document$querySelect;
|
|
192
|
+
|
|
193
|
+
var orientation = (_document$querySelect = document.querySelector("[aria-orientation]")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute('aria-orientation');
|
|
194
|
+
var key = e.target.getAttribute('aria-controls');
|
|
195
|
+
var keys = Object.entries(registered.current).map(function (_ref2) {
|
|
196
|
+
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
197
|
+
entryKey = _ref3[0],
|
|
198
|
+
_ = _ref3[1];
|
|
199
|
+
|
|
200
|
+
return entryKey;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
var handleArrowRight = function handleArrowRight() {
|
|
204
|
+
var arrowRightItem = findRightSibling(key, keys);
|
|
205
|
+
|
|
206
|
+
if (arrowRightItem) {
|
|
207
|
+
registered.current[arrowRightItem].el.focus();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
var handleArrowLeft = function handleArrowLeft() {
|
|
212
|
+
var arrowLeftItem = findLeftSibling(key, keys);
|
|
213
|
+
|
|
214
|
+
if (arrowLeftItem) {
|
|
215
|
+
registered.current[arrowLeftItem].el.focus();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
switch (e.key) {
|
|
220
|
+
case 'ArrowRight':
|
|
221
|
+
handleArrowRight();
|
|
222
|
+
break;
|
|
223
|
+
|
|
224
|
+
case 'ArrowDown':
|
|
225
|
+
var openItem = getOpenItemChildren(key, keys);
|
|
226
|
+
var arrowDownItems = findChildren(key, openItem);
|
|
227
|
+
var menuItems = getMenuItems(document.getElementById(key));
|
|
228
|
+
|
|
229
|
+
if (arrowDownItems.length > 0) {
|
|
230
|
+
registered.current[arrowDownItems[0]].el.focus();
|
|
231
|
+
} else {
|
|
232
|
+
if (orientation === 'vertical') {
|
|
233
|
+
var _document$activeEleme;
|
|
234
|
+
|
|
235
|
+
if (((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.getAttribute('aria-selected')) === 'true' && menuItems && menuItems.length > 0) {
|
|
236
|
+
menuItems[0].focus();
|
|
237
|
+
} else {
|
|
238
|
+
handleArrowRight();
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
if (menuItems && menuItems.length > 0) {
|
|
242
|
+
menuItems[0].focus();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
break;
|
|
248
|
+
|
|
249
|
+
case 'ArrowLeft':
|
|
250
|
+
handleArrowLeft();
|
|
251
|
+
break;
|
|
252
|
+
|
|
253
|
+
case 'ArrowUp':
|
|
254
|
+
if (orientation === 'vertical') {
|
|
255
|
+
handleArrowLeft();
|
|
256
|
+
} else {
|
|
257
|
+
var arrowUpItem = findParent(key, keys);
|
|
258
|
+
|
|
259
|
+
if (arrowUpItem) {
|
|
260
|
+
registered.current[arrowUpItem].el.focus();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
break;
|
|
265
|
+
|
|
266
|
+
case ' ':
|
|
267
|
+
case 'Enter':
|
|
268
|
+
if (registered.current[key].type === 'link') {
|
|
269
|
+
registered.current[key].el.click();
|
|
270
|
+
} else {
|
|
271
|
+
toggle(e);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}, []);
|
|
277
|
+
var registerButton = (0, _react.useCallback)(function (key) {
|
|
278
|
+
var _extends2;
|
|
279
|
+
|
|
280
|
+
var isOpen = !!opened[key];
|
|
281
|
+
return (0, _extends3["default"])((_extends2 = {
|
|
282
|
+
ref: registerButtonRef
|
|
283
|
+
}, (0, _defineProperty2["default"])(_extends2, toggleProperty, isOpen), (0, _defineProperty2["default"])(_extends2, onToggleProperty, toggle), (0, _defineProperty2["default"])(_extends2, 'aria-controls', "".concat(key)), _extends2), ariaNavigation && {
|
|
284
|
+
onKeyDown: onKeyDown
|
|
285
|
+
});
|
|
286
|
+
}, [opened]);
|
|
287
|
+
var registerLink = (0, _react.useCallback)(function (key) {
|
|
288
|
+
return (0, _extends3["default"])({
|
|
289
|
+
ref: registerLinkRef,
|
|
290
|
+
'aria-controls': "".concat(key)
|
|
291
|
+
}, ariaNavigation && {
|
|
292
|
+
onKeyDown: onKeyDown
|
|
293
|
+
});
|
|
294
|
+
}, [opened]);
|
|
295
|
+
return (0, _react.useMemo)(function () {
|
|
296
|
+
return {
|
|
297
|
+
registerButton: registerButton,
|
|
298
|
+
registerLink: registerLink,
|
|
299
|
+
registered: registered,
|
|
300
|
+
opened: opened,
|
|
301
|
+
toggle: toggle,
|
|
302
|
+
setOpened: setOpened
|
|
303
|
+
};
|
|
304
|
+
}, [opened]);
|
|
305
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface UseTogglableTabInterface {
|
|
2
2
|
toggleProperty: string;
|
|
3
3
|
singleOpen?: boolean;
|
|
4
4
|
toggleOpenClose?: boolean;
|
|
5
|
+
toggleParentOpen?: boolean;
|
|
5
6
|
onToggleProperty: string;
|
|
6
7
|
initial?: Record<string, boolean>;
|
|
7
8
|
firstOpen?: boolean;
|
|
8
9
|
ariaNavigation?: boolean;
|
|
9
10
|
toggleHook?: (id: string) => void;
|
|
10
11
|
}
|
|
11
|
-
export interface
|
|
12
|
+
export interface UseTogglableTabReturn {
|
|
12
13
|
register: (el: string) => any;
|
|
13
14
|
registered: {
|
|
14
15
|
current: Record<string, HTMLElement>;
|
|
@@ -17,4 +18,4 @@ export interface UseTogglableSectionsReturn {
|
|
|
17
18
|
toggle: (id: string) => void;
|
|
18
19
|
setOpened: (opened: ((curOpened: Record<string, boolean>) => Record<string, boolean>) | Record<string, boolean>) => void;
|
|
19
20
|
}
|
|
20
|
-
export declare function
|
|
21
|
+
export declare function useTogglableTab({ toggleProperty, singleOpen, onToggleProperty, initial, firstOpen, ariaNavigation, toggleHook, }: UseTogglableTabInterface): UseTogglableTabReturn;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.useTogglableTab = useTogglableTab;
|
|
9
9
|
|
|
10
10
|
var _extends4 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
@@ -16,10 +16,9 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
16
16
|
var _react = require("react");
|
|
17
17
|
|
|
18
18
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
19
|
-
function
|
|
19
|
+
function useTogglableTab(_ref) {
|
|
20
20
|
var toggleProperty = _ref.toggleProperty,
|
|
21
21
|
singleOpen = _ref.singleOpen,
|
|
22
|
-
toggleOpenClose = _ref.toggleOpenClose,
|
|
23
22
|
onToggleProperty = _ref.onToggleProperty,
|
|
24
23
|
initial = _ref.initial,
|
|
25
24
|
firstOpen = _ref.firstOpen,
|
|
@@ -46,7 +45,6 @@ function useTogglableSections(_ref) {
|
|
|
46
45
|
}, []);
|
|
47
46
|
var toggle = (0, _react.useCallback)(function (e) {
|
|
48
47
|
var key = e.currentTarget.getAttribute('aria-controls');
|
|
49
|
-
var selected = e.currentTarget.getAttribute('aria-selected') === 'true';
|
|
50
48
|
|
|
51
49
|
if (toggleHook) {
|
|
52
50
|
toggleHook(key);
|
|
@@ -55,11 +53,7 @@ function useTogglableSections(_ref) {
|
|
|
55
53
|
e.preventDefault();
|
|
56
54
|
|
|
57
55
|
if (singleOpen) {
|
|
58
|
-
|
|
59
|
-
setOpened((0, _defineProperty2["default"])({}, key, !selected));
|
|
60
|
-
} else {
|
|
61
|
-
setOpened((0, _defineProperty2["default"])({}, key, true));
|
|
62
|
-
}
|
|
56
|
+
setOpened((0, _defineProperty2["default"])({}, key, true));
|
|
63
57
|
} else {
|
|
64
58
|
setOpened(function (prev) {
|
|
65
59
|
return (0, _extends4["default"])({}, prev, (0, _defineProperty2["default"])({}, key, !prev[key]));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface VariantVarsOptions {
|
|
2
|
+
name: string;
|
|
3
|
+
variables: string[];
|
|
4
|
+
variants: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare type UseVariantVarsResult<T> = [
|
|
7
|
+
value: T,
|
|
8
|
+
changeValue: (value: T) => void
|
|
9
|
+
];
|
|
10
|
+
declare function useVariantVars({ name, variables, variants, }: VariantVarsOptions): UseVariantVarsResult<any>;
|
|
11
|
+
export default useVariantVars;
|