@bizapps/design-system-testing 1.12.0 → 1.12.1
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/dist/main.cjs +33 -3
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +4 -1
- package/dist/main.d.ts +4 -1
- package/dist/main.js +33 -3
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.d.cts
CHANGED
|
@@ -2455,7 +2455,10 @@ interface FloatingSidebarProps extends Omit<ComponentProps<'nav'>, 'children'> {
|
|
|
2455
2455
|
type?: 'single' | 'multiple';
|
|
2456
2456
|
/** Open module cards (controlled). In `single` mode only the first id is used. */
|
|
2457
2457
|
openModuleIds?: string[];
|
|
2458
|
-
/**
|
|
2458
|
+
/**
|
|
2459
|
+
* Initially open module cards when uncontrolled. Read once on mount. Defaults to the module
|
|
2460
|
+
* of the current page (`activeItemId` or `defaultActiveItemId`), or none without one.
|
|
2461
|
+
*/
|
|
2459
2462
|
defaultOpenModuleIds?: string[];
|
|
2460
2463
|
/** Fires with the new list of open module cards. */
|
|
2461
2464
|
onOpenModulesChange?: (moduleIds: string[]) => void;
|
package/dist/main.d.ts
CHANGED
|
@@ -2455,7 +2455,10 @@ interface FloatingSidebarProps extends Omit<ComponentProps<'nav'>, 'children'> {
|
|
|
2455
2455
|
type?: 'single' | 'multiple';
|
|
2456
2456
|
/** Open module cards (controlled). In `single` mode only the first id is used. */
|
|
2457
2457
|
openModuleIds?: string[];
|
|
2458
|
-
/**
|
|
2458
|
+
/**
|
|
2459
|
+
* Initially open module cards when uncontrolled. Read once on mount. Defaults to the module
|
|
2460
|
+
* of the current page (`activeItemId` or `defaultActiveItemId`), or none without one.
|
|
2461
|
+
*/
|
|
2459
2462
|
defaultOpenModuleIds?: string[];
|
|
2460
2463
|
/** Fires with the new list of open module cards. */
|
|
2461
2464
|
onOpenModulesChange?: (moduleIds: string[]) => void;
|
package/dist/main.js
CHANGED
|
@@ -9404,7 +9404,7 @@ function FloatingSidebar({
|
|
|
9404
9404
|
collapsedWidth = DEFAULT_COLLAPSED_WIDTH,
|
|
9405
9405
|
type = "single",
|
|
9406
9406
|
openModuleIds: openModulesProp,
|
|
9407
|
-
defaultOpenModuleIds
|
|
9407
|
+
defaultOpenModuleIds,
|
|
9408
9408
|
onOpenModulesChange,
|
|
9409
9409
|
hideEmptyModules = true,
|
|
9410
9410
|
activeItemId: activeItemProp,
|
|
@@ -9433,9 +9433,16 @@ function FloatingSidebar({
|
|
|
9433
9433
|
const isMobile = useIsMobile();
|
|
9434
9434
|
const baseId = useId();
|
|
9435
9435
|
const [open, setOpen] = useControllableState2(openProp, defaultOpen, onOpenChange);
|
|
9436
|
+
const moduleIdByItemId = useMemo(
|
|
9437
|
+
() => new Map(modules.flatMap((module) => module.items.map((item) => [item.id, module.id]))),
|
|
9438
|
+
[modules]
|
|
9439
|
+
);
|
|
9440
|
+
const moduleIdOf = (itemId) => itemId ? moduleIdByItemId.get(itemId) : void 0;
|
|
9441
|
+
const initialActiveModuleId = moduleIdOf(activeItemProp ?? defaultActiveItemId);
|
|
9436
9442
|
const [rawOpenModuleIds, setOpenModuleIds] = useControllableState2(
|
|
9437
9443
|
openModulesProp,
|
|
9438
|
-
|
|
9444
|
+
// Without an explicit default, the module of the current page starts open.
|
|
9445
|
+
defaultOpenModuleIds ?? (initialActiveModuleId ? [initialActiveModuleId] : []),
|
|
9439
9446
|
onOpenModulesChange
|
|
9440
9447
|
);
|
|
9441
9448
|
const railWidth = Math.max(MIN_COLLAPSED_WIDTH, collapsedWidth);
|
|
@@ -9537,8 +9544,31 @@ function FloatingSidebar({
|
|
|
9537
9544
|
document.addEventListener("keydown", onKeyDown);
|
|
9538
9545
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
9539
9546
|
}, [shortcut, toggle, isMobile, mobileOpen, setMobileOpen]);
|
|
9547
|
+
const openModule = (moduleId) => {
|
|
9548
|
+
const opened = rawOpenModuleIds.includes(moduleId);
|
|
9549
|
+
if (type === "multiple") {
|
|
9550
|
+
if (!opened) setOpenModuleIds([...rawOpenModuleIds, moduleId]);
|
|
9551
|
+
} else if (!opened || rawOpenModuleIds.length > 1) {
|
|
9552
|
+
setOpenModuleIds([moduleId]);
|
|
9553
|
+
}
|
|
9554
|
+
};
|
|
9555
|
+
const activeModuleId = moduleIdOf(activeItemId);
|
|
9556
|
+
const syncedActive = useRef(`${activeItemId}|${activeModuleId}`);
|
|
9557
|
+
useEffect(() => {
|
|
9558
|
+
const key = `${activeItemId}|${activeModuleId}`;
|
|
9559
|
+
if (syncedActive.current === key) return;
|
|
9560
|
+
syncedActive.current = key;
|
|
9561
|
+
if (activeModuleId) openModule(activeModuleId);
|
|
9562
|
+
});
|
|
9540
9563
|
const selectItem = (item, module, navigates) => {
|
|
9541
|
-
if (navigates)
|
|
9564
|
+
if (navigates) {
|
|
9565
|
+
setActiveItemId(item.id);
|
|
9566
|
+
openModule(module.id);
|
|
9567
|
+
if (activeItemProp === void 0) {
|
|
9568
|
+
syncedActive.current = `${item.id}|${moduleIdOf(item.id)}`;
|
|
9569
|
+
}
|
|
9570
|
+
if (queries[module.id]) setQueries((current) => ({ ...current, [module.id]: "" }));
|
|
9571
|
+
}
|
|
9542
9572
|
setFlyoutId(null);
|
|
9543
9573
|
if (isMobile) setMobileOpen(false);
|
|
9544
9574
|
onItemSelect?.(item, module);
|