carbon-react 154.0.0 → 154.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/vertical-menu/index.d.ts +1 -0
- package/esm/components/vertical-menu/index.js +2 -1
- package/esm/components/vertical-menu/responsive-vertical-menu/__internal__/depth.context.d.ts +16 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/__internal__/depth.context.js +47 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/__internal__/focus.context.d.ts +24 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/__internal__/focus.context.js +206 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/index.d.ts +7 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/index.js +4 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/index.d.ts +2 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/index.js +1 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.component.d.ts +6 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.component.js +19 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.style.d.ts +8 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.style.js +13 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/index.d.ts +2 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/index.js +1 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.component.d.ts +23 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.component.js +307 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.style.d.ts +31 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.style.js +217 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.component.d.ts +14 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.component.js +186 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.context.d.ts +28 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.context.js +32 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.style.d.ts +20 -0
- package/esm/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.style.js +95 -0
- package/lib/components/vertical-menu/index.d.ts +1 -0
- package/lib/components/vertical-menu/index.js +19 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/__internal__/depth.context.d.ts +16 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/__internal__/depth.context.js +58 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/__internal__/focus.context.d.ts +24 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/__internal__/focus.context.js +217 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/index.d.ts +7 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/index.js +33 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/package.json +6 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/index.d.ts +2 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/index.js +13 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/package.json +6 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.component.d.ts +6 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.component.js +27 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.style.d.ts +8 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-divider/responsive-vertical-menu-divider.style.js +20 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/index.d.ts +2 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/index.js +13 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/package.json +6 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.component.d.ts +23 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.component.js +316 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.style.d.ts +31 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/responsive-vertical-menu-item.style.js +226 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.component.d.ts +14 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.component.js +196 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.context.d.ts +28 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.context.js +42 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.style.d.ts +20 -0
- package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu.style.js +104 -0
- package/package.json +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMenuFocus = exports.MenuFocusProvider = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
/* eslint-disable no-console */
|
|
11
|
+
/**
|
|
12
|
+
* Provides context for managing focus within a menu component.
|
|
13
|
+
* This context allows for tracking expanded items, focusing on specific items,
|
|
14
|
+
* and moving focus in various directions (next, previous, parent, first child, last child).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Create a context for menu focus
|
|
18
|
+
const MenuFocusContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
19
|
+
|
|
20
|
+
// Custom hook to use the MenuFocusContext
|
|
21
|
+
const useMenuFocus = () => {
|
|
22
|
+
// Get the current context value
|
|
23
|
+
const context = (0, _react.useContext)(MenuFocusContext);
|
|
24
|
+
|
|
25
|
+
// If context is undefined, it means the hook is being used outside of a MenuFocusProvider
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
if (!context) {
|
|
28
|
+
console.error("useMenuFocus must be used within a MenuFocusProvider");
|
|
29
|
+
// Return a default value to avoid breakages
|
|
30
|
+
return {
|
|
31
|
+
expandedItems: [],
|
|
32
|
+
expandItem: () => {},
|
|
33
|
+
focusedItemId: null,
|
|
34
|
+
getRegisteredItems: () => [],
|
|
35
|
+
focusItem: () => {},
|
|
36
|
+
moveFocus: () => {},
|
|
37
|
+
registerMenuItem: () => {}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Return the current context value
|
|
42
|
+
return context;
|
|
43
|
+
};
|
|
44
|
+
exports.useMenuFocus = useMenuFocus;
|
|
45
|
+
const MenuFocusProvider = ({
|
|
46
|
+
children
|
|
47
|
+
}) => {
|
|
48
|
+
// State to track expanded items
|
|
49
|
+
const [expandedItems, setExpandedItems] = (0, _react.useState)([]);
|
|
50
|
+
// State to track the currently focused item
|
|
51
|
+
const [focusedItemId, setFocusedItemId] = (0, _react.useState)(null);
|
|
52
|
+
|
|
53
|
+
// Ref to hold registered menu items
|
|
54
|
+
const menuItemsRef = (0, _react.useRef)(new Map());
|
|
55
|
+
|
|
56
|
+
// Function to register a menu item
|
|
57
|
+
// This function takes an id, a ref to the item, and an optional parentId
|
|
58
|
+
// and stores the item in the menuItemsRef map.
|
|
59
|
+
// If a parentId is provided, it also updates the parent's childIds array
|
|
60
|
+
// to include the new item.
|
|
61
|
+
const registerMenuItem = (0, _react.useCallback)((id, ref, parentId) => {
|
|
62
|
+
menuItemsRef.current.set(id, {
|
|
63
|
+
ref,
|
|
64
|
+
parentId,
|
|
65
|
+
childIds: []
|
|
66
|
+
});
|
|
67
|
+
if (parentId) {
|
|
68
|
+
const parentItem = menuItemsRef.current.get(parentId);
|
|
69
|
+
parentItem?.childIds.push(id);
|
|
70
|
+
}
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
// Function to get all registered menu items
|
|
74
|
+
// This function returns an array of objects, each containing the id,
|
|
75
|
+
// ref, parentId, and childIds of the registered items.
|
|
76
|
+
const getRegisteredItems = (0, _react.useCallback)(() => {
|
|
77
|
+
const items = Array.from(menuItemsRef.current.entries()).map(([id, {
|
|
78
|
+
ref,
|
|
79
|
+
parentId,
|
|
80
|
+
childIds
|
|
81
|
+
}]) => ({
|
|
82
|
+
id,
|
|
83
|
+
ref,
|
|
84
|
+
parentId,
|
|
85
|
+
childIds
|
|
86
|
+
}));
|
|
87
|
+
return items;
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
// Function to focus on a specific menu item
|
|
91
|
+
// This function takes an id and focuses the corresponding item
|
|
92
|
+
// by calling the focus method on its ref.
|
|
93
|
+
// It also updates the focusedItemId state to the new id.
|
|
94
|
+
const focusItem = (0, _react.useCallback)(id => {
|
|
95
|
+
const item = menuItemsRef.current.get(id);
|
|
96
|
+
/* istanbul ignore else */
|
|
97
|
+
if (item?.ref?.current) {
|
|
98
|
+
item.ref.current.focus();
|
|
99
|
+
setFocusedItemId(id);
|
|
100
|
+
}
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
// Function to expand or collapse a menu item
|
|
104
|
+
// This function takes an id and a boolean value (expand)
|
|
105
|
+
// and updates the expandedItems state accordingly.
|
|
106
|
+
// If expand is true, it adds the id to the expandedItems array;
|
|
107
|
+
// otherwise, it removes the id from the array.
|
|
108
|
+
const expandItem = (0, _react.useCallback)((id, expand) => {
|
|
109
|
+
if (expand) {
|
|
110
|
+
setExpandedItems(prev => [...prev, id]);
|
|
111
|
+
} else {
|
|
112
|
+
setExpandedItems(prev => prev.filter(itemId => itemId !== id));
|
|
113
|
+
}
|
|
114
|
+
}, []);
|
|
115
|
+
|
|
116
|
+
// Function to move focus in a specific direction
|
|
117
|
+
// This function takes a direction (next, prev, parent, firstChild, lastChild)
|
|
118
|
+
// and moves the focus accordingly.
|
|
119
|
+
// It uses the current focusedItemId to determine the current item
|
|
120
|
+
// and then finds the next item based on the direction.
|
|
121
|
+
// It also handles expanding/collapsing items as needed.
|
|
122
|
+
const moveFocus = (0, _react.useCallback)(direction => {
|
|
123
|
+
/* istanbul ignore if */
|
|
124
|
+
if (!focusedItemId) return;
|
|
125
|
+
|
|
126
|
+
// Get the current item based on the focusedItemId
|
|
127
|
+
const currentItem = menuItemsRef.current.get(focusedItemId);
|
|
128
|
+
|
|
129
|
+
// If the current item is not found, return early
|
|
130
|
+
/* istanbul ignore if */
|
|
131
|
+
if (!currentItem) return;
|
|
132
|
+
let allItems = [];
|
|
133
|
+
let visibleItems = [];
|
|
134
|
+
let currentIndex = -1;
|
|
135
|
+
switch (direction) {
|
|
136
|
+
// Move focus to the parent item
|
|
137
|
+
case "parent":
|
|
138
|
+
/* istanbul ignore else */
|
|
139
|
+
if (currentItem.parentId) {
|
|
140
|
+
focusItem(currentItem.parentId);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
// Move focus to the first child
|
|
145
|
+
// If the current item has children and is not already expanded,
|
|
146
|
+
// expand it and focus on the first child
|
|
147
|
+
case "firstChild":
|
|
148
|
+
/* istanbul ignore else */
|
|
149
|
+
if (currentItem.childIds.length > 0) {
|
|
150
|
+
if (!expandedItems.includes(focusedItemId)) {
|
|
151
|
+
expandItem(focusedItemId, true);
|
|
152
|
+
}
|
|
153
|
+
focusItem(currentItem.childIds[0]);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
// Move focus to the last child
|
|
158
|
+
// Moving backwards through the menu works slightly differently:
|
|
159
|
+
// If the current item has children, get the last child. Before focusing on it,
|
|
160
|
+
// check if the last child is expanded. If it is, focus on its last child.
|
|
161
|
+
// If the last child is not expanded (i.e. it's just a link), focus on it directly.
|
|
162
|
+
case "lastChild":
|
|
163
|
+
/* istanbul ignore else */
|
|
164
|
+
if (currentItem.childIds.length > 0) {
|
|
165
|
+
const lastChild = currentItem.childIds[currentItem.childIds.length - 1];
|
|
166
|
+
/* istanbul ignore else */
|
|
167
|
+
if (lastChild) {
|
|
168
|
+
/* istanbul ignore if */
|
|
169
|
+
if (expandedItems.includes(lastChild)) {
|
|
170
|
+
const lastChildItem = getRegisteredItems().find(item => item.id === lastChild);
|
|
171
|
+
if (lastChildItem) {
|
|
172
|
+
focusItem(lastChildItem.childIds[lastChildItem.childIds.length - 1]);
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
focusItem(lastChild);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
|
|
181
|
+
// Move focus to the next or previous item
|
|
182
|
+
// This case handles both next and previous focus movement.
|
|
183
|
+
// Whilst this functionality is not currently used in the menu,
|
|
184
|
+
// it is included for completeness/future-proofing.
|
|
185
|
+
/* istanbul ignore next */
|
|
186
|
+
default:
|
|
187
|
+
allItems = Array.from(menuItemsRef.current.keys());
|
|
188
|
+
visibleItems = allItems.filter(id => {
|
|
189
|
+
const item = menuItemsRef.current.get(id);
|
|
190
|
+
if (!item || !item.parentId) return true;
|
|
191
|
+
const parentVisible = expandedItems.includes(item.parentId);
|
|
192
|
+
return parentVisible;
|
|
193
|
+
});
|
|
194
|
+
currentIndex = visibleItems.indexOf(focusedItemId);
|
|
195
|
+
if (currentIndex !== -1) {
|
|
196
|
+
const nextIndex = direction === "next" ? (currentIndex + 1) % visibleItems.length : (currentIndex - 1 + visibleItems.length) % visibleItems.length;
|
|
197
|
+
focusItem(visibleItems[nextIndex]);
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}, [focusedItemId, focusItem, expandedItems, expandItem, getRegisteredItems]);
|
|
202
|
+
const value = {
|
|
203
|
+
expandedItems,
|
|
204
|
+
expandItem,
|
|
205
|
+
focusedItemId,
|
|
206
|
+
focusItem,
|
|
207
|
+
getRegisteredItems,
|
|
208
|
+
registerMenuItem,
|
|
209
|
+
moveFocus
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// Provide the current context value to the MenuFocusContext
|
|
213
|
+
return /*#__PURE__*/_react.default.createElement(MenuFocusContext.Provider, {
|
|
214
|
+
value: value
|
|
215
|
+
}, children);
|
|
216
|
+
};
|
|
217
|
+
exports.MenuFocusProvider = MenuFocusProvider;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ResponsiveVerticalMenuProvider } from "./responsive-vertical-menu.context";
|
|
2
|
+
export { ResponsiveVerticalMenu } from "./responsive-vertical-menu.component";
|
|
3
|
+
export type { ResponsiveVerticalMenuProps } from "./responsive-vertical-menu.component";
|
|
4
|
+
export { ResponsiveVerticalMenuItem } from "./responsive-vertical-menu-item";
|
|
5
|
+
export type { ResponsiveVerticalMenuItemProps } from "./responsive-vertical-menu-item";
|
|
6
|
+
export { ResponsiveVerticalMenuDivider } from "./responsive-vertical-menu-divider";
|
|
7
|
+
export type { ResponsiveVerticalMenuDividerProps } from "./responsive-vertical-menu-divider";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ResponsiveVerticalMenu", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _responsiveVerticalMenu2.ResponsiveVerticalMenu;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ResponsiveVerticalMenuDivider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _responsiveVerticalMenuDivider.ResponsiveVerticalMenuDivider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ResponsiveVerticalMenuItem", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _responsiveVerticalMenuItem.ResponsiveVerticalMenuItem;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ResponsiveVerticalMenuProvider", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _responsiveVerticalMenu.ResponsiveVerticalMenuProvider;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _responsiveVerticalMenu = require("./responsive-vertical-menu.context");
|
|
31
|
+
var _responsiveVerticalMenu2 = require("./responsive-vertical-menu.component");
|
|
32
|
+
var _responsiveVerticalMenuItem = require("./responsive-vertical-menu-item");
|
|
33
|
+
var _responsiveVerticalMenuDivider = require("./responsive-vertical-menu-divider");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ResponsiveVerticalMenuDivider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _responsiveVerticalMenuDivider.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _responsiveVerticalMenuDivider = _interopRequireDefault(require("./responsive-vertical-menu-divider.component"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
export interface ResponsiveVerticalMenuDividerProps extends MarginProps {
|
|
4
|
+
}
|
|
5
|
+
export declare const ResponsiveVerticalMenuDivider: (props: ResponsiveVerticalMenuDividerProps) => React.JSX.Element;
|
|
6
|
+
export default ResponsiveVerticalMenuDivider;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ResponsiveVerticalMenuDivider = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _responsiveVerticalMenuDivider = require("./responsive-vertical-menu-divider.style");
|
|
9
|
+
var _utils = require("../../../../style/utils");
|
|
10
|
+
var _depth = require("../__internal__/depth.context");
|
|
11
|
+
var _responsiveVerticalMenu = require("../responsive-vertical-menu.context");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const ResponsiveVerticalMenuDivider = props => {
|
|
14
|
+
const depth = (0, _depth.useDepth)();
|
|
15
|
+
const {
|
|
16
|
+
responsiveMode
|
|
17
|
+
} = (0, _responsiveVerticalMenu.useResponsiveVerticalMenu)();
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_responsiveVerticalMenuDivider.StyledResponsiveVerticalMenuDivider, {
|
|
19
|
+
"data-component": "responsive-vertical-menu-divider",
|
|
20
|
+
"data-element": "responsive-vertical-menu-divider",
|
|
21
|
+
"data-role": "responsive-vertical-menu-divider",
|
|
22
|
+
depth: depth,
|
|
23
|
+
responsive: responsiveMode
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(_responsiveVerticalMenuDivider.StyledHr, (0, _utils.filterStyledSystemMarginProps)(props)));
|
|
25
|
+
};
|
|
26
|
+
exports.ResponsiveVerticalMenuDivider = ResponsiveVerticalMenuDivider;
|
|
27
|
+
var _default = exports.default = ResponsiveVerticalMenuDivider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MarginProps } from "styled-system";
|
|
2
|
+
interface StyledResponsiveVerticalMenuDividerProps {
|
|
3
|
+
depth: number;
|
|
4
|
+
responsive?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const StyledResponsiveVerticalMenuDivider: import("styled-components").StyledComponent<"div", any, StyledResponsiveVerticalMenuDividerProps, never>;
|
|
7
|
+
export declare const StyledHr: import("styled-components").StyledComponent<"hr", any, MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledResponsiveVerticalMenuDivider = exports.StyledHr = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _styledSystem = require("styled-system");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const StyledResponsiveVerticalMenuDivider = exports.StyledResponsiveVerticalMenuDivider = _styledComponents.default.div`
|
|
11
|
+
width: ${({
|
|
12
|
+
depth,
|
|
13
|
+
responsive
|
|
14
|
+
}) => depth > 0 && responsive ? "88%" : "100%"};
|
|
15
|
+
`;
|
|
16
|
+
const StyledHr = exports.StyledHr = _styledComponents.default.hr`
|
|
17
|
+
border-color: #ffffff33;
|
|
18
|
+
border-bottom: 1px;
|
|
19
|
+
${_styledSystem.margin}
|
|
20
|
+
`;
|
package/lib/components/vertical-menu/responsive-vertical-menu/responsive-vertical-menu-item/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ResponsiveVerticalMenuItem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _responsiveVerticalMenuItem.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _responsiveVerticalMenuItem = _interopRequireDefault(require("./responsive-vertical-menu-item.component"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { MarginProps, PaddingProps } from "styled-system";
|
|
3
|
+
import { IconType } from "../../../icon";
|
|
4
|
+
interface BaseItemProps extends MarginProps, PaddingProps {
|
|
5
|
+
/** The content of the menu item. This will render the menu item as a parent menu. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** Custom icon to be displayed. Takes precedence over `icon` if both are specified. */
|
|
8
|
+
customIcon?: ReactNode;
|
|
9
|
+
/** The destination URL. Providing this will render the menu item as an anchor link. */
|
|
10
|
+
href?: string;
|
|
11
|
+
/** The Carbon icon to be displayed. Defers to `customIcon` if both are defined. */
|
|
12
|
+
icon?: IconType;
|
|
13
|
+
/** The unique identifier for the menu item. */
|
|
14
|
+
id: string;
|
|
15
|
+
/** The label for the menu item. */
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ResponsiveVerticalMenuItemProps extends Omit<BaseItemProps, "id"> {
|
|
19
|
+
/** The unique identifier for the menu item. */
|
|
20
|
+
id?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const ResponsiveVerticalMenuItem: ({ children, id, label, ...props }: ResponsiveVerticalMenuItemProps) => React.JSX.Element;
|
|
23
|
+
export default ResponsiveVerticalMenuItem;
|