@digigov/ui 0.29.0 → 0.30.0-navlist.alpha
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 +8 -1
- package/core/NavList/NavHorizontalListItem.d.ts +3 -2
- package/core/NavList/NavHorizontalListItem.js +19 -8
- package/core/NavList/NavListBase.d.ts +0 -1
- package/core/NavList/NavListBase.js +7 -50
- package/core/NavList/NavListItem.d.ts +0 -1
- package/core/NavList/NavListItem.js +2 -27
- package/core/NavList/NavListItemBase.d.ts +1 -1
- package/core/NavList/__stories__/NavHorizontalLayout.js +35 -24
- package/core/NavList/index.d.ts +9 -1
- package/core/NavList/index.js +48 -2
- package/core/NavList/types.d.ts +27 -0
- package/core/NavList/types.js +14 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +13 -0
- package/es/core/NavList/NavHorizontalListItem.js +12 -2
- package/es/core/NavList/NavListBase.js +5 -47
- package/es/core/NavList/NavListItem.js +1 -23
- package/es/core/NavList/__stories__/NavHorizontalLayout.js +34 -24
- package/es/core/NavList/index.js +37 -1
- package/es/core/NavList/types.js +6 -1
- package/es/core/index.js +1 -0
- package/es/hooks/useTogglableSections.js +7 -1
- package/esm/core/NavList/NavHorizontalListItem.js +12 -2
- package/esm/core/NavList/NavListBase.js +5 -47
- package/esm/core/NavList/NavListItem.js +1 -23
- package/esm/core/NavList/__stories__/NavHorizontalLayout.js +34 -24
- package/esm/core/NavList/index.js +37 -1
- package/esm/core/NavList/types.js +6 -1
- package/esm/core/index.js +1 -0
- package/esm/hooks/useTogglableSections.js +7 -1
- package/esm/index.js +1 -1
- package/hooks/useTogglableSections.d.ts +2 -1
- package/hooks/useTogglableSections.js +7 -1
- package/package.json +4 -3
- package/src/core/NavList/NavHorizontalListItem.tsx +30 -2
- package/src/core/NavList/NavListBase.tsx +4 -56
- package/src/core/NavList/NavListItem.tsx +1 -22
- package/src/core/NavList/__stories__/NavHorizontalLayout.tsx +61 -29
- package/src/core/NavList/index.tsx +42 -1
- package/src/core/NavList/types.tsx +44 -0
- package/src/core/index.ts +1 -0
- package/src/hooks/useTogglableSections.tsx +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @digigov/ui
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 18 Jan 2023 13:07:00 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.29.1
|
|
6
|
+
Wed, 18 Jan 2023 13:07:00 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Rexport FieldContainer from `@digigov/ui/core` path
|
|
4
11
|
|
|
5
12
|
## 0.29.0
|
|
6
13
|
Mon, 16 Jan 2023 13:05:21 GMT
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NavHorizontalListItemProps } from '@digigov/ui/core/NavList/types';
|
|
3
|
+
export declare const NavHorizontalListItem: React.FC<NavHorizontalListItemProps>;
|
|
3
4
|
export default NavHorizontalListItem;
|
|
@@ -5,15 +5,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return _NavHorizontalListItem["default"];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
exports["default"] = void 0;
|
|
8
|
+
exports["default"] = exports.NavHorizontalListItem = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
11
|
|
|
16
12
|
var _NavHorizontalListItem = _interopRequireDefault(require("@digigov/react-core/NavHorizontalListItem"));
|
|
17
13
|
|
|
18
|
-
var
|
|
14
|
+
var _NavHorizontalListItemButton = _interopRequireDefault(require("@digigov/ui/core/NavList/NavHorizontalListItemButton"));
|
|
15
|
+
|
|
16
|
+
var _NavHorizontalListItemLink = require("@digigov/ui/core/NavList/NavHorizontalListItemLink");
|
|
17
|
+
|
|
18
|
+
var _types = require("@digigov/ui/core/NavList/types");
|
|
19
|
+
|
|
20
|
+
var NavHorizontalListItem = function NavHorizontalListItem(_ref) {
|
|
21
|
+
var link = _ref.link,
|
|
22
|
+
setRegister = _ref.setRegister;
|
|
23
|
+
return /*#__PURE__*/_react["default"].createElement(_NavHorizontalListItem["default"], null, (0, _types.isNavListItemSubMenuInterface)(link) && link !== null && link !== void 0 && link.subMenu && setRegister ? /*#__PURE__*/_react["default"].createElement(_NavHorizontalListItemButton["default"], setRegister(link.name), link === null || link === void 0 ? void 0 : link.label) : (0, _types.isNavListItemLinkInterface)(link) && /*#__PURE__*/_react["default"].createElement(_NavHorizontalListItemLink.NavHorizontalListItemLink, {
|
|
24
|
+
href: link === null || link === void 0 ? void 0 : link.href
|
|
25
|
+
}, link === null || link === void 0 ? void 0 : link.label));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.NavHorizontalListItem = NavHorizontalListItem;
|
|
29
|
+
var _default = NavHorizontalListItem;
|
|
19
30
|
exports["default"] = _default;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NavListProps } from '@digigov/ui/core/NavList/types';
|
|
3
|
-
export declare const useNavListStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"vertical" | "root" | "subMenu" | "floating" | "floatClear">;
|
|
4
3
|
export declare const NavListBase: React.FC<NavListProps>;
|
|
@@ -5,55 +5,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.NavListBase = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
11
|
|
|
10
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
13
|
|
|
12
14
|
var _react = _interopRequireDefault(require("react"));
|
|
13
15
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _styles = require("@material-ui/core/styles");
|
|
16
|
+
var _reactCore = require("@digigov/react-core");
|
|
17
17
|
|
|
18
18
|
var _excluded = ["className", "children", "floating", "horizontal", "subMenu", "role"];
|
|
19
|
-
var useNavListStyles = (0, _styles.makeStyles)(function (theme) {
|
|
20
|
-
return {
|
|
21
|
-
root: {
|
|
22
|
-
padding: theme.spacing(0),
|
|
23
|
-
margin: theme.spacing(0),
|
|
24
|
-
display: 'flex',
|
|
25
|
-
'&$vertical': {
|
|
26
|
-
flexDirection: 'column'
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
subMenu: {
|
|
30
|
-
marginLeft: theme.spacing(3)
|
|
31
|
-
},
|
|
32
|
-
floating: {
|
|
33
|
-
left: 0,
|
|
34
|
-
zIndex: 99,
|
|
35
|
-
position: 'absolute',
|
|
36
|
-
background: theme.palette.grey['100'],
|
|
37
|
-
borderTop: "1px solid ".concat(theme.palette.grey['500']),
|
|
38
|
-
borderRight: "1px solid ".concat(theme.palette.grey['500']),
|
|
39
|
-
borderLeft: "1px solid ".concat(theme.palette.grey['500']),
|
|
40
|
-
margin: theme.spacing(1.5, 0, 0, 0),
|
|
41
|
-
boxShadow: theme.shadows[3],
|
|
42
|
-
'& > li': {
|
|
43
|
-
width: '100%',
|
|
44
|
-
borderBottom: "1px solid ".concat(theme.palette.grey['500']),
|
|
45
|
-
margin: 0
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
vertical: {},
|
|
49
|
-
floatClear: {
|
|
50
|
-
clear: 'both'
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}, {
|
|
54
|
-
name: 'MuiNavList'
|
|
55
|
-
});
|
|
56
|
-
exports.useNavListStyles = useNavListStyles;
|
|
57
19
|
|
|
58
20
|
var NavListBase = function NavListBase(_ref) {
|
|
59
21
|
var className = _ref.className,
|
|
@@ -63,14 +25,9 @@ var NavListBase = function NavListBase(_ref) {
|
|
|
63
25
|
subMenu = _ref.subMenu,
|
|
64
26
|
role = _ref.role,
|
|
65
27
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
role: role,
|
|
70
|
-
className: (0, _clsx["default"])(className, classes.root, !horizontal && classes.vertical, floating && classes.floating, subMenu && classes.subMenu)
|
|
71
|
-
}, children), /*#__PURE__*/_react["default"].createElement("div", {
|
|
72
|
-
className: classes.floatClear
|
|
73
|
-
}));
|
|
28
|
+
return /*#__PURE__*/_react["default"].createElement(_reactCore.NavHorizontal, (0, _extends2["default"])({
|
|
29
|
+
open: true
|
|
30
|
+
}, props), /*#__PURE__*/_react["default"].createElement(_reactCore.NavHorizontalList, null, children));
|
|
74
31
|
};
|
|
75
32
|
|
|
76
33
|
exports.NavListBase = NavListBase;
|
|
@@ -9,6 +9,5 @@ export interface NavListItemProps {
|
|
|
9
9
|
expandOn?: 'hover' | 'click';
|
|
10
10
|
role?: string;
|
|
11
11
|
}
|
|
12
|
-
export declare const useNavListItemStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"link" | "selected" | "root">;
|
|
13
12
|
export declare const NavListItem: React.FC<NavListItemProps>;
|
|
14
13
|
export default NavListItem;
|
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports
|
|
10
|
+
exports["default"] = exports.NavListItem = void 0;
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
@@ -21,8 +21,6 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
21
21
|
|
|
22
22
|
var _SectionBreak = _interopRequireDefault(require("@digigov/react-core/SectionBreak"));
|
|
23
23
|
|
|
24
|
-
var _styles = require("@material-ui/core/styles");
|
|
25
|
-
|
|
26
24
|
var _NavListItemBase = _interopRequireDefault(require("@digigov/ui/core/NavList/NavListItemBase"));
|
|
27
25
|
|
|
28
26
|
var _NavListSubMenu = _interopRequireDefault(require("@digigov/ui/core/NavList/NavListSubMenu"));
|
|
@@ -35,27 +33,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
35
33
|
|
|
36
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
35
|
|
|
38
|
-
var useNavListItemStyles = (0, _styles.makeStyles)(function (theme) {
|
|
39
|
-
return {
|
|
40
|
-
root: {},
|
|
41
|
-
link: {
|
|
42
|
-
padding: theme.spacing(0.5, 2),
|
|
43
|
-
textDecoration: 'none',
|
|
44
|
-
'&:hover': {
|
|
45
|
-
textDecoration: 'underline'
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
selected: {
|
|
49
|
-
borderStyle: 'solid',
|
|
50
|
-
borderColor: theme.palette.secondary.main,
|
|
51
|
-
fontWeight: 'bolder'
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}, {
|
|
55
|
-
name: 'MuiNavListItem'
|
|
56
|
-
});
|
|
57
|
-
exports.useNavListItemStyles = useNavListItemStyles;
|
|
58
|
-
|
|
59
36
|
var _ref3 = /*#__PURE__*/_react["default"].createElement(_SectionBreak["default"], null);
|
|
60
37
|
|
|
61
38
|
var NavListItem = function NavListItem(_ref) {
|
|
@@ -93,8 +70,6 @@ var NavListItem = function NavListItem(_ref) {
|
|
|
93
70
|
selected = _useState8[0],
|
|
94
71
|
setSelected = _useState8[1];
|
|
95
72
|
|
|
96
|
-
var classes = useNavListItemStyles();
|
|
97
|
-
|
|
98
73
|
var _useContext = (0, _react.useContext)(_NavListContext["default"]),
|
|
99
74
|
openSubMenus = _useContext.openSubMenus,
|
|
100
75
|
horizontal = _useContext.horizontal,
|
|
@@ -161,7 +136,7 @@ var NavListItem = function NavListItem(_ref) {
|
|
|
161
136
|
isNested: subMenu && subMenu.length > 0,
|
|
162
137
|
horizontal: horizontal,
|
|
163
138
|
role: role,
|
|
164
|
-
className: (0, _clsx["default"])(className
|
|
139
|
+
className: (0, _clsx["default"])(className)
|
|
165
140
|
}, handlerProps, props), (open || openSubMenus) && subMenu && subMenu.length && /*#__PURE__*/_react["default"].createElement(_NavListSubMenu["default"], {
|
|
166
141
|
style: style,
|
|
167
142
|
links: subMenu
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const useNavListItemBaseStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "link" | "open" | "selected" | "horizontal" | "vertical" | "
|
|
2
|
+
export declare const useNavListItemBaseStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "link" | "open" | "selected" | "horizontal" | "vertical" | "icon" | "root" | "submenu">;
|
|
3
3
|
export interface NavListItemBaseProps {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
href?: string;
|
|
@@ -7,20 +7,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = exports.NavHorizontalLayout = void 0;
|
|
9
9
|
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireDefault(require("react"));
|
|
11
13
|
|
|
12
|
-
var _NavList = require("@digigov/ui/core/NavList
|
|
14
|
+
var _NavList = require("@digigov/ui/core/NavList");
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _core = require("@digigov/ui/core");
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var navItemArray = [{
|
|
17
19
|
name: 'Nav1',
|
|
18
|
-
|
|
19
|
-
label: 'Nav list item 1'
|
|
20
|
-
}, {
|
|
21
|
-
name: 'Nav2',
|
|
22
|
-
href: '#',
|
|
23
|
-
label: 'Nav list item 2',
|
|
20
|
+
label: 'Item list 1',
|
|
24
21
|
subMenu: [{
|
|
25
22
|
name: 'Nav2.1',
|
|
26
23
|
href: '#',
|
|
@@ -37,24 +34,38 @@ var links = [{
|
|
|
37
34
|
}, {
|
|
38
35
|
name: 'Nav3',
|
|
39
36
|
href: '#',
|
|
40
|
-
label: '
|
|
37
|
+
label: 'Item list 3'
|
|
41
38
|
}];
|
|
42
39
|
|
|
43
40
|
var NavHorizontalLayout = function NavHorizontalLayout() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
var _useNavList = (0, _NavList.useNavList)(),
|
|
42
|
+
container = _useNavList.container,
|
|
43
|
+
register = _useNavList.register;
|
|
44
|
+
|
|
45
|
+
var setRegister = function setRegister(name) {
|
|
46
|
+
return (0, _extends2["default"])({}, register(name));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/_react["default"].createElement(_NavList.NavHorizontal, {
|
|
50
|
+
open: true
|
|
51
|
+
}, /*#__PURE__*/_react["default"].createElement(_NavList.NavHorizontalList, null, navItemArray.map(function (item, index) {
|
|
52
|
+
var _item$subMenu;
|
|
53
|
+
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
|
|
55
|
+
key: index
|
|
56
|
+
}, /*#__PURE__*/_react["default"].createElement(_NavList.NavHorizontalListItem, {
|
|
57
|
+
link: item,
|
|
58
|
+
setRegister: setRegister
|
|
59
|
+
}), /*#__PURE__*/_react["default"].createElement(_NavList.NavMenu, container(item.name), /*#__PURE__*/_react["default"].createElement(_NavList.NavMenuContainer, {
|
|
60
|
+
paddingLeft: 5,
|
|
61
|
+
paddingRight: 5
|
|
62
|
+
}, /*#__PURE__*/_react["default"].createElement(_NavList.NavMenuContainerTitle, null, item.name), /*#__PURE__*/_react["default"].createElement(_NavList.NavMenuContainerContent, null, /*#__PURE__*/_react["default"].createElement(_NavList.NavMenuContainerContentList, null, (0, _NavList.isNavListItemSubMenuInterface)(item) && (item === null || item === void 0 ? void 0 : (_item$subMenu = item.subMenu) === null || _item$subMenu === void 0 ? void 0 : _item$subMenu.map(function (subMenu, menuIndex) {
|
|
63
|
+
return /*#__PURE__*/_react["default"].createElement(_NavList.NavMenuContainerContentListItem, {
|
|
64
|
+
key: menuIndex
|
|
65
|
+
}, (0, _NavList.isNavListItemLinkInterface)(subMenu) && /*#__PURE__*/_react["default"].createElement(_core.Link, {
|
|
66
|
+
href: subMenu.href
|
|
67
|
+
}, subMenu.label));
|
|
68
|
+
})))))));
|
|
58
69
|
})));
|
|
59
70
|
};
|
|
60
71
|
|
package/core/NavList/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import NavList from '@digigov/ui/core/NavList/NavList';
|
|
2
|
+
import { UseTogglableSectionsReturn } from '@digigov/ui/hooks/useTogglableSections';
|
|
3
|
+
export interface UseNavListReturn extends UseTogglableSectionsReturn {
|
|
4
|
+
container: (key: string) => {
|
|
5
|
+
active: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const useNavList: () => UseNavListReturn;
|
|
1
10
|
export * from '@digigov/ui/core/NavList/NavList';
|
|
2
11
|
export * from '@digigov/ui/core/NavList/NavListItem';
|
|
3
12
|
export * from '@digigov/ui/core/NavList/NavListSubMenu';
|
|
@@ -16,5 +25,4 @@ export * from '@digigov/ui/core/NavList/NavMenuContainerContentListItem';
|
|
|
16
25
|
export * from '@digigov/ui/core/NavList/NavVertical';
|
|
17
26
|
export * from '@digigov/ui/core/NavList/NavVerticalItem';
|
|
18
27
|
export * from '@digigov/ui/core/NavList/types';
|
|
19
|
-
import NavList from '@digigov/ui/core/NavList/NavList';
|
|
20
28
|
export default NavList;
|
package/core/NavList/index.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
|
-
var _exportNames = {
|
|
9
|
-
|
|
10
|
+
var _exportNames = {
|
|
11
|
+
useNavList: true
|
|
12
|
+
};
|
|
13
|
+
exports.useNavList = exports["default"] = void 0;
|
|
14
|
+
|
|
15
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
|
+
|
|
17
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
18
|
+
|
|
19
|
+
var _react = require("react");
|
|
10
20
|
|
|
11
21
|
var _NavList = _interopRequireWildcard(require("@digigov/ui/core/NavList/NavList"));
|
|
12
22
|
|
|
@@ -22,6 +32,8 @@ Object.keys(_NavList).forEach(function (key) {
|
|
|
22
32
|
});
|
|
23
33
|
});
|
|
24
34
|
|
|
35
|
+
var _useTogglableSections2 = require("@digigov/ui/hooks/useTogglableSections");
|
|
36
|
+
|
|
25
37
|
var _NavListItem = require("@digigov/ui/core/NavList/NavListItem");
|
|
26
38
|
|
|
27
39
|
Object.keys(_NavListItem).forEach(function (key) {
|
|
@@ -259,10 +271,44 @@ Object.keys(_types).forEach(function (key) {
|
|
|
259
271
|
}
|
|
260
272
|
});
|
|
261
273
|
});
|
|
274
|
+
var _excluded = ["register", "opened"];
|
|
262
275
|
|
|
263
276
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
264
277
|
|
|
265
278
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
266
279
|
|
|
280
|
+
var useNavList = function useNavList() {
|
|
281
|
+
var registeredContainers = (0, _react.useRef)({});
|
|
282
|
+
|
|
283
|
+
var _useTogglableSections = (0, _useTogglableSections2.useTogglableSections)({
|
|
284
|
+
singleOpen: true,
|
|
285
|
+
reOpen: true,
|
|
286
|
+
toggleProperty: 'active',
|
|
287
|
+
onToggleProperty: 'onClick',
|
|
288
|
+
ariaNavigation: true
|
|
289
|
+
}),
|
|
290
|
+
registerListItem = _useTogglableSections.register,
|
|
291
|
+
opened = _useTogglableSections.opened,
|
|
292
|
+
rest = (0, _objectWithoutProperties2["default"])(_useTogglableSections, _excluded);
|
|
293
|
+
|
|
294
|
+
var registerNavMenu = (0, _react.useCallback)(function (key) {
|
|
295
|
+
return {
|
|
296
|
+
ref: function ref(el) {
|
|
297
|
+
if (el && !registeredContainers.current[el.id]) {
|
|
298
|
+
registeredContainers.current[el.id] = el;
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
active: opened[key],
|
|
302
|
+
id: key
|
|
303
|
+
};
|
|
304
|
+
}, [opened]);
|
|
305
|
+
return (0, _extends2["default"])({
|
|
306
|
+
register: registerListItem,
|
|
307
|
+
opened: opened,
|
|
308
|
+
container: registerNavMenu
|
|
309
|
+
}, rest);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
exports.useNavList = useNavList;
|
|
267
313
|
var _default = _NavList["default"];
|
|
268
314
|
exports["default"] = _default;
|
package/core/NavList/types.d.ts
CHANGED
|
@@ -12,3 +12,30 @@ export interface NavListProps {
|
|
|
12
12
|
links?: NavLinkInterface[];
|
|
13
13
|
style?: BaseCSSProperties;
|
|
14
14
|
}
|
|
15
|
+
interface NavListItemInterface {
|
|
16
|
+
name: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
interface NavListItemLinkInterface extends NavListItemInterface {
|
|
21
|
+
href: string;
|
|
22
|
+
}
|
|
23
|
+
export interface NavListHeaderItemType {
|
|
24
|
+
name: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
subMenu: NavListItemLinkInterface[];
|
|
29
|
+
}
|
|
30
|
+
export declare type NavListItemType = NavListItemLinkInterface | NavListItemSubMenuInterface;
|
|
31
|
+
export interface NavListItemSubMenuInterface extends NavListItemInterface {
|
|
32
|
+
subMenu: NavListItemType[];
|
|
33
|
+
}
|
|
34
|
+
export declare const isNavListItemLinkInterface: (item: any) => item is NavListItemLinkInterface;
|
|
35
|
+
export declare const isNavListItemSubMenuInterface: (item: any) => item is NavListItemSubMenuInterface;
|
|
36
|
+
export interface NavHorizontalListItemProps {
|
|
37
|
+
children?: React.ReactNode;
|
|
38
|
+
link?: NavListItemType;
|
|
39
|
+
setRegister?: (name: string) => any;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
package/core/NavList/types.js
CHANGED
|
@@ -2,4 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
exports.isNavListItemSubMenuInterface = exports.isNavListItemLinkInterface = void 0;
|
|
7
|
+
|
|
8
|
+
var isNavListItemLinkInterface = function isNavListItemLinkInterface(item) {
|
|
9
|
+
return 'href' in item;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.isNavListItemLinkInterface = isNavListItemLinkInterface;
|
|
13
|
+
|
|
14
|
+
var isNavListItemSubMenuInterface = function isNavListItemSubMenuInterface(item) {
|
|
15
|
+
return 'subMenu' in item;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.isNavListItemSubMenuInterface = isNavListItemSubMenuInterface;
|
package/core/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from '@digigov/ui/core/Details';
|
|
|
12
12
|
export * from '@digigov/ui/core/Divider';
|
|
13
13
|
export * from '@digigov/ui/core/ErrorMessage';
|
|
14
14
|
export * from '@digigov/ui/core/ErrorSummary';
|
|
15
|
+
export * from '@digigov/ui/core/FieldContainer';
|
|
15
16
|
export * from '@digigov/ui/core/FileUpload';
|
|
16
17
|
export * from '@digigov/ui/core/Form';
|
|
17
18
|
export * from '@digigov/ui/core/Hidden';
|
package/core/index.js
CHANGED
|
@@ -173,6 +173,19 @@ Object.keys(_ErrorSummary).forEach(function (key) {
|
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
+
var _FieldContainer = require("@digigov/ui/core/FieldContainer");
|
|
177
|
+
|
|
178
|
+
Object.keys(_FieldContainer).forEach(function (key) {
|
|
179
|
+
if (key === "default" || key === "__esModule") return;
|
|
180
|
+
if (key in exports && exports[key] === _FieldContainer[key]) return;
|
|
181
|
+
Object.defineProperty(exports, key, {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function get() {
|
|
184
|
+
return _FieldContainer[key];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
176
189
|
var _FileUpload = require("@digigov/ui/core/FileUpload");
|
|
177
190
|
|
|
178
191
|
Object.keys(_FileUpload).forEach(function (key) {
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CoreNavHorizontalListItem from '@digigov/react-core/NavHorizontalListItem';
|
|
3
|
+
import NavHorizontalListItemButton from '@digigov/ui/core/NavList/NavHorizontalListItemButton';
|
|
4
|
+
import { NavHorizontalListItemLink } from '@digigov/ui/core/NavList/NavHorizontalListItemLink';
|
|
5
|
+
import { isNavListItemLinkInterface, isNavListItemSubMenuInterface } from '@digigov/ui/core/NavList/types';
|
|
6
|
+
export var NavHorizontalListItem = function NavHorizontalListItem(_ref) {
|
|
7
|
+
var link = _ref.link,
|
|
8
|
+
setRegister = _ref.setRegister;
|
|
9
|
+
return /*#__PURE__*/React.createElement(CoreNavHorizontalListItem, null, isNavListItemSubMenuInterface(link) && link !== null && link !== void 0 && link.subMenu && setRegister ? /*#__PURE__*/React.createElement(NavHorizontalListItemButton, setRegister(link.name), link === null || link === void 0 ? void 0 : link.label) : isNavListItemLinkInterface(link) && /*#__PURE__*/React.createElement(NavHorizontalListItemLink, {
|
|
10
|
+
href: link === null || link === void 0 ? void 0 : link.href
|
|
11
|
+
}, link === null || link === void 0 ? void 0 : link.label));
|
|
12
|
+
};
|
|
3
13
|
export default NavHorizontalListItem;
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
var _excluded = ["className", "children", "floating", "horizontal", "subMenu", "role"];
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import
|
|
5
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
6
|
-
export var useNavListStyles = makeStyles(function (theme) {
|
|
7
|
-
return {
|
|
8
|
-
root: {
|
|
9
|
-
padding: theme.spacing(0),
|
|
10
|
-
margin: theme.spacing(0),
|
|
11
|
-
display: 'flex',
|
|
12
|
-
'&$vertical': {
|
|
13
|
-
flexDirection: 'column'
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
subMenu: {
|
|
17
|
-
marginLeft: theme.spacing(3)
|
|
18
|
-
},
|
|
19
|
-
floating: {
|
|
20
|
-
left: 0,
|
|
21
|
-
zIndex: 99,
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
background: theme.palette.grey['100'],
|
|
24
|
-
borderTop: "1px solid ".concat(theme.palette.grey['500']),
|
|
25
|
-
borderRight: "1px solid ".concat(theme.palette.grey['500']),
|
|
26
|
-
borderLeft: "1px solid ".concat(theme.palette.grey['500']),
|
|
27
|
-
margin: theme.spacing(1.5, 0, 0, 0),
|
|
28
|
-
boxShadow: theme.shadows[3],
|
|
29
|
-
'& > li': {
|
|
30
|
-
width: '100%',
|
|
31
|
-
borderBottom: "1px solid ".concat(theme.palette.grey['500']),
|
|
32
|
-
margin: 0
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
vertical: {},
|
|
36
|
-
floatClear: {
|
|
37
|
-
clear: 'both'
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}, {
|
|
41
|
-
name: 'MuiNavList'
|
|
42
|
-
});
|
|
5
|
+
import { NavHorizontal, NavHorizontalList } from '@digigov/react-core';
|
|
43
6
|
export var NavListBase = function NavListBase(_ref) {
|
|
44
7
|
var className = _ref.className,
|
|
45
8
|
children = _ref.children,
|
|
@@ -49,12 +12,7 @@ export var NavListBase = function NavListBase(_ref) {
|
|
|
49
12
|
role = _ref.role,
|
|
50
13
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
51
14
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
role: role,
|
|
56
|
-
className: clsx(className, classes.root, !horizontal && classes.vertical, floating && classes.floating, subMenu && classes.subMenu)
|
|
57
|
-
}, children), /*#__PURE__*/React.createElement("div", {
|
|
58
|
-
className: classes.floatClear
|
|
59
|
-
}));
|
|
15
|
+
return /*#__PURE__*/React.createElement(NavHorizontal, _extends({
|
|
16
|
+
open: true
|
|
17
|
+
}, props), /*#__PURE__*/React.createElement(NavHorizontalList, null, children));
|
|
60
18
|
};
|
|
@@ -5,29 +5,9 @@ var _excluded = ["name", "expandOn", "children", "href", "className", "selected"
|
|
|
5
5
|
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import Divider from '@digigov/react-core/SectionBreak';
|
|
8
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
9
8
|
import NavListItemBase from '@digigov/ui/core/NavList/NavListItemBase';
|
|
10
9
|
import NavListSubMenu from '@digigov/ui/core/NavList/NavListSubMenu';
|
|
11
10
|
import NavListContext from '@digigov/ui/core/NavList/NavListContext';
|
|
12
|
-
export var useNavListItemStyles = makeStyles(function (theme) {
|
|
13
|
-
return {
|
|
14
|
-
root: {},
|
|
15
|
-
link: {
|
|
16
|
-
padding: theme.spacing(0.5, 2),
|
|
17
|
-
textDecoration: 'none',
|
|
18
|
-
'&:hover': {
|
|
19
|
-
textDecoration: 'underline'
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
selected: {
|
|
23
|
-
borderStyle: 'solid',
|
|
24
|
-
borderColor: theme.palette.secondary.main,
|
|
25
|
-
fontWeight: 'bolder'
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}, {
|
|
29
|
-
name: 'MuiNavListItem'
|
|
30
|
-
});
|
|
31
11
|
|
|
32
12
|
var _ref3 = /*#__PURE__*/React.createElement(Divider, null);
|
|
33
13
|
|
|
@@ -66,8 +46,6 @@ export var NavListItem = function NavListItem(_ref) {
|
|
|
66
46
|
selected = _useState8[0],
|
|
67
47
|
setSelected = _useState8[1];
|
|
68
48
|
|
|
69
|
-
var classes = useNavListItemStyles();
|
|
70
|
-
|
|
71
49
|
var _useContext = useContext(NavListContext),
|
|
72
50
|
openSubMenus = _useContext.openSubMenus,
|
|
73
51
|
horizontal = _useContext.horizontal,
|
|
@@ -134,7 +112,7 @@ export var NavListItem = function NavListItem(_ref) {
|
|
|
134
112
|
isNested: subMenu && subMenu.length > 0,
|
|
135
113
|
horizontal: horizontal,
|
|
136
114
|
role: role,
|
|
137
|
-
className: clsx(className
|
|
115
|
+
className: clsx(className)
|
|
138
116
|
}, handlerProps, props), (open || openSubMenus) && subMenu && subMenu.length && /*#__PURE__*/React.createElement(NavListSubMenu, {
|
|
139
117
|
style: style,
|
|
140
118
|
links: subMenu
|