@cypress-design/react-docmenu 0.5.3 → 0.6.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +16 -0
- package/DocMenuReact.cy.tsx +49 -2
- package/_DocGroup.tsx +17 -1
- package/_DocLink.tsx +11 -4
- package/dist/_DocGroup.d.ts.map +1 -1
- package/dist/_DocLink.d.ts.map +1 -1
- package/dist/index.es.mjs +22 -10
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +22 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -185,8 +185,9 @@ const classes = {
|
|
|
185
185
|
var DocLink = React__namespace.forwardRef(function (_a, ref) {
|
|
186
186
|
var item = _a.item, depth = _a.depth, markerIsMoving = _a.markerIsMoving, context = _a.context, onActive = _a.onActive, LinkComponent = _a.LinkComponent;
|
|
187
187
|
var activeLIRef = React__namespace.useRef(null);
|
|
188
|
-
var
|
|
189
|
-
|
|
188
|
+
var active = React__namespace.useMemo(function () { return item.href === context.activePath; }, [item.href, context.activePath]);
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
190
|
+
item.label; var itemRest = __rest$1(item, ["label"]);
|
|
190
191
|
var setActiveMarkerPosition = function () {
|
|
191
192
|
var _a;
|
|
192
193
|
if (active) {
|
|
@@ -204,21 +205,22 @@ var DocLink = React__namespace.forwardRef(function (_a, ref) {
|
|
|
204
205
|
setActiveMarkerPosition: setActiveMarkerPosition,
|
|
205
206
|
}); });
|
|
206
207
|
return (React__namespace.createElement("li", { ref: activeLIRef, className: "list-none p-0" },
|
|
207
|
-
React__namespace.createElement(LinkComponent, { className: clsx('group relative block w-full pl-[24px]', {
|
|
208
|
+
React__namespace.createElement(LinkComponent, __assign$1({}, itemRest, { className: clsx('group relative block w-full pl-[24px]', {
|
|
208
209
|
'text-indigo-500 dark:text-indigo-400': active,
|
|
209
210
|
'text-gray-700 dark:text-gray-500': !active,
|
|
210
211
|
'py-[8px] text-[16px] leading-[24px]': depth < 0,
|
|
211
212
|
'leading-[20px] text-[14px] py-[12px]': depth >= 0,
|
|
212
|
-
}),
|
|
213
|
+
}), style: {
|
|
213
214
|
paddingLeft: depth >= 0 ? "".concat(depth * 12 + 48, "px") : undefined,
|
|
214
|
-
} },
|
|
215
|
+
} }),
|
|
215
216
|
depth >= 0 ? (React__namespace.createElement("div", { className: clsx('left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full', {
|
|
216
217
|
hidden: !markerIsMoving || !active,
|
|
217
|
-
'group-hover:block bg-gray-300': !active && collapsible,
|
|
218
|
+
'group-hover:block bg-gray-300': !active && context.collapsible,
|
|
218
219
|
'bg-indigo-500 dark:bg-indigo-400': active && markerIsMoving,
|
|
219
220
|
}) })) : null,
|
|
220
221
|
item.label)));
|
|
221
222
|
});
|
|
223
|
+
DocLink.displayName = 'DocMenuDocLink';
|
|
222
224
|
|
|
223
225
|
var hasActiveItemRecursively = function (items, localActivePath) {
|
|
224
226
|
return items.some(function (item) {
|
|
@@ -238,6 +240,11 @@ var DocGroup = React__namespace.forwardRef(function (_a, ref) {
|
|
|
238
240
|
var _e = React__namespace.useState(!group.collapsed), open = _e[0], setOpen = _e[1];
|
|
239
241
|
var _f = React__namespace.useState(), markerIsMovingTimeout = _f[0], setMarkerIsMovingTimeout = _f[1];
|
|
240
242
|
var $groupElements = React__namespace.useRef(null);
|
|
243
|
+
React__namespace.useEffect(function () {
|
|
244
|
+
if (hasActiveItemRecursivelyMemo && !open) {
|
|
245
|
+
setOpen(true);
|
|
246
|
+
}
|
|
247
|
+
}, [hasActiveItemRecursivelyMemo, activePath, open]);
|
|
241
248
|
var toggleMenu = function (localOpen) {
|
|
242
249
|
if (!collapsible || markerIsMoving)
|
|
243
250
|
return;
|
|
@@ -307,12 +314,15 @@ var DocGroup = React__namespace.forwardRef(function (_a, ref) {
|
|
|
307
314
|
_b['text-indigo-500 dark:text-indigo-400'] = activePath === group.href,
|
|
308
315
|
_b['text-gray-900 dark:text-gray-100'] = hasActiveItemRecursivelyMemo && activePath !== group.href,
|
|
309
316
|
_b['text-gray-800 dark:text-gray-200'] = !hasActiveItemRecursivelyMemo && activePath !== group.href,
|
|
310
|
-
_b))
|
|
317
|
+
_b)), style: {
|
|
318
|
+
paddingLeft: depth >= 1 ? "".concat((depth - 1) * 12 + 48, "px") : undefined,
|
|
319
|
+
} },
|
|
311
320
|
collapsible ? (React__namespace.createElement(IconChevronDownSmall, { "stroke-color": "gray-400", size: depth ? '8' : '16', className: clsx(classes.expandedIcon, {
|
|
312
321
|
'rotate-0': open,
|
|
313
322
|
'-rotate-90': !open,
|
|
314
|
-
|
|
315
|
-
|
|
323
|
+
}), style: {
|
|
324
|
+
marginLeft: depth >= 1 ? "".concat((depth - 1) * 12 + 28, "px") : undefined,
|
|
325
|
+
} })) : null,
|
|
316
326
|
group.label),
|
|
317
327
|
React__namespace.createElement("div", { className: clsx('relative', collapsible
|
|
318
328
|
? {
|
|
@@ -324,6 +334,7 @@ var DocGroup = React__namespace.forwardRef(function (_a, ref) {
|
|
|
324
334
|
open && collapsible && depth === 0 ? (React__namespace.createElement("div", { className: classes.openListBorderLeft })) : null,
|
|
325
335
|
React__namespace.createElement(DocGroupElements, { ref: $groupElements, className: "overflow-hidden", items: group.items, depth: depth, context: context, markerIsMoving: markerIsMoving, onActivePosition: setActivePosition, updateMarkerPosition: onUpdateMarkerPosition, LinkComponent: LinkComponent }))));
|
|
326
336
|
});
|
|
337
|
+
DocGroup.displayName = 'DocMenuDocGroup';
|
|
327
338
|
var DocGroupElements = React__namespace.forwardRef(function (_a, ref) {
|
|
328
339
|
var items = _a.items, _b = _a.depth, depth = _b === void 0 ? 0 : _b, onActivePosition = _a.onActivePosition, updateMarkerPosition = _a.updateMarkerPosition, markerIsMoving = _a.markerIsMoving, LinkComponent = _a.LinkComponent, className = _a.className, context = _a.context, rest = __rest$1(_a, ["items", "depth", "onActivePosition", "updateMarkerPosition", "markerIsMoving", "LinkComponent", "className", "context"]);
|
|
329
340
|
var $groups = React__namespace.useRef([]);
|
|
@@ -368,6 +379,7 @@ var DocGroupElements = React__namespace.forwardRef(function (_a, ref) {
|
|
|
368
379
|
}, LinkComponent: LinkComponent }));
|
|
369
380
|
})));
|
|
370
381
|
});
|
|
382
|
+
DocGroupElements.displayName = 'DocMenuDocGroupElements';
|
|
371
383
|
|
|
372
384
|
var DocMenu = function (_a) {
|
|
373
385
|
var items = _a.items, _b = _a.activePath, activePath = _b === void 0 ? '<unknown>' : _b, _c = _a.collapsible, collapsible = _c === void 0 ? true : _c, _d = _a.LinkComponent, LinkComponent = _d === void 0 ? 'a' : _d, rest = __rest$1(_a, ["items", "activePath", "collapsible", "LinkComponent"]);
|
|
@@ -415,4 +427,4 @@ var DocMenu = function (_a) {
|
|
|
415
427
|
module.exports = DocMenu;
|
|
416
428
|
//# sourceMappingURL=index.umd.js.map
|
|
417
429
|
|
|
418
|
-
/* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 dark:bg-indigo-400 ml-[6.5px] mt-[4px] transition ease-in-out text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90
|
|
430
|
+
/* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 dark:bg-indigo-400 ml-[6.5px] mt-[4px] transition ease-in-out text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 transition-all grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden filter list-none p-0 block w-full pl-[24px] text-gray-700 dark:text-gray-500 py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] left-[6.5px] top-[4px] bottom-[4px] z-10 hidden group-hover:block bg-gray-300 text-indigo-400 text-gray-500 bg-indigo-400 left-0 transform transition-transform text-gray-400 dark:text-gray-700 flex py-[10px] items-center text-start font-medium pl-[48px] left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"> */
|