@cypress-design/react-docmenu 0.5.4 → 0.7.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 +87 -74
- package/_DocGroup.tsx +10 -0
- package/_DocLink.tsx +33 -15
- package/dist/_DocGroup.d.ts.map +1 -1
- package/dist/_DocLink.d.ts.map +1 -1
- package/dist/index.es.mjs +32 -6
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +32 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -183,10 +183,11 @@ const classes = {
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
var DocLink = React__namespace.forwardRef(function (_a, ref) {
|
|
186
|
-
var
|
|
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) {
|
|
@@ -200,6 +201,23 @@ var DocLink = React__namespace.forwardRef(function (_a, ref) {
|
|
|
200
201
|
// on mount, if the item is active,
|
|
201
202
|
// send the top position to the parent
|
|
202
203
|
React__namespace.useEffect(setActiveMarkerPosition, [onActive, active]);
|
|
204
|
+
React__namespace.useEffect(function () {
|
|
205
|
+
if (active && activeLIRef.current) {
|
|
206
|
+
// if active check if the item is visible in the
|
|
207
|
+
// viewport and scrollIntoView if not
|
|
208
|
+
var rect = activeLIRef.current.getBoundingClientRect();
|
|
209
|
+
if (rect.top > 0 && rect.bottom < window.innerHeight) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (rect.left > 0 && rect.right < window.innerWidth) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
activeLIRef.current.scrollIntoView({
|
|
216
|
+
block: 'nearest',
|
|
217
|
+
inline: 'nearest',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}, [active]);
|
|
203
221
|
React__namespace.useImperativeHandle(ref, function () { return ({
|
|
204
222
|
setActiveMarkerPosition: setActiveMarkerPosition,
|
|
205
223
|
}); });
|
|
@@ -214,11 +232,12 @@ var DocLink = React__namespace.forwardRef(function (_a, ref) {
|
|
|
214
232
|
} }),
|
|
215
233
|
depth >= 0 ? (React__namespace.createElement("div", { className: clsx('left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full', {
|
|
216
234
|
hidden: !markerIsMoving || !active,
|
|
217
|
-
'group-hover:block bg-gray-300': !active && collapsible,
|
|
235
|
+
'group-hover:block bg-gray-300': !active && context.collapsible,
|
|
218
236
|
'bg-indigo-500 dark:bg-indigo-400': active && markerIsMoving,
|
|
219
237
|
}) })) : null,
|
|
220
|
-
label)));
|
|
238
|
+
item.label)));
|
|
221
239
|
});
|
|
240
|
+
DocLink.displayName = 'DocMenuDocLink';
|
|
222
241
|
|
|
223
242
|
var hasActiveItemRecursively = function (items, localActivePath) {
|
|
224
243
|
return items.some(function (item) {
|
|
@@ -238,6 +257,11 @@ var DocGroup = React__namespace.forwardRef(function (_a, ref) {
|
|
|
238
257
|
var _e = React__namespace.useState(!group.collapsed), open = _e[0], setOpen = _e[1];
|
|
239
258
|
var _f = React__namespace.useState(), markerIsMovingTimeout = _f[0], setMarkerIsMovingTimeout = _f[1];
|
|
240
259
|
var $groupElements = React__namespace.useRef(null);
|
|
260
|
+
React__namespace.useEffect(function () {
|
|
261
|
+
if (hasActiveItemRecursivelyMemo && !open) {
|
|
262
|
+
setOpen(true);
|
|
263
|
+
}
|
|
264
|
+
}, [hasActiveItemRecursivelyMemo, activePath, open]);
|
|
241
265
|
var toggleMenu = function (localOpen) {
|
|
242
266
|
if (!collapsible || markerIsMoving)
|
|
243
267
|
return;
|
|
@@ -327,6 +351,7 @@ var DocGroup = React__namespace.forwardRef(function (_a, ref) {
|
|
|
327
351
|
open && collapsible && depth === 0 ? (React__namespace.createElement("div", { className: classes.openListBorderLeft })) : null,
|
|
328
352
|
React__namespace.createElement(DocGroupElements, { ref: $groupElements, className: "overflow-hidden", items: group.items, depth: depth, context: context, markerIsMoving: markerIsMoving, onActivePosition: setActivePosition, updateMarkerPosition: onUpdateMarkerPosition, LinkComponent: LinkComponent }))));
|
|
329
353
|
});
|
|
354
|
+
DocGroup.displayName = 'DocMenuDocGroup';
|
|
330
355
|
var DocGroupElements = React__namespace.forwardRef(function (_a, ref) {
|
|
331
356
|
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"]);
|
|
332
357
|
var $groups = React__namespace.useRef([]);
|
|
@@ -371,6 +396,7 @@ var DocGroupElements = React__namespace.forwardRef(function (_a, ref) {
|
|
|
371
396
|
}, LinkComponent: LinkComponent }));
|
|
372
397
|
})));
|
|
373
398
|
});
|
|
399
|
+
DocGroupElements.displayName = 'DocMenuDocGroupElements';
|
|
374
400
|
|
|
375
401
|
var DocMenu = function (_a) {
|
|
376
402
|
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"]);
|
|
@@ -418,4 +444,4 @@ var DocMenu = function (_a) {
|
|
|
418
444
|
module.exports = DocMenu;
|
|
419
445
|
//# sourceMappingURL=index.umd.js.map
|
|
420
446
|
|
|
421
|
-
/* <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"> */
|
|
447
|
+
/* <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 visible block inline 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"> */
|