@bizapps/design-system-testing 1.12.0 → 1.12.2

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 CHANGED
@@ -9224,6 +9224,13 @@ var DEFAULT_LABELS = {
9224
9224
  var EASE = "cubic-bezier(.2,.8,.2,1)";
9225
9225
  var MOTION_MS = 240;
9226
9226
  var FADE_MS = MOTION_MS / 2;
9227
+ var RAIL_STAGGER_MS = 20;
9228
+ var ACCORDION_EASE = "cubic-bezier(.4,0,.2,1)";
9229
+ var ACCORDION_ITEM_FADE_MS = 260;
9230
+ var ACCORDION_OPEN_DELAY_MS = 120;
9231
+ var ACCORDION_OPEN_STAGGER_MS = 50;
9232
+ var ACCORDION_CLOSE_FADE_MS = 160;
9233
+ var ACCORDION_STAGGER_CAP = 8;
9227
9234
  var MORPH_MS = 360;
9228
9235
  var MORPH_EASE = "cubic-bezier(.65,0,.35,1)";
9229
9236
  var BOUNCE_KEYFRAMES = [
@@ -9361,7 +9368,7 @@ var DEFAULT_WIDTH = 305;
9361
9368
  var DEFAULT_COLLAPSED_WIDTH = 48;
9362
9369
  var TILE_ICON_SIZE = 22;
9363
9370
  var MIN_COLLAPSED_WIDTH = 40;
9364
- var t = (prop, ms = 300, delay = 0) => `${prop} ${ms}ms ${EASE} ${delay}ms`;
9371
+ var t = (prop, ms = 300, delay = 0, ease2 = EASE) => `${prop} ${ms}ms ${ease2} ${delay}ms`;
9365
9372
  function transition2(reduced, ...parts) {
9366
9373
  const kept = reduced ? parts.filter((part) => /^(opacity|visibility|background|color|box-shadow)/.test(part)) : parts;
9367
9374
  return kept.join(", ") || "none";
@@ -9430,7 +9437,7 @@ function FloatingSidebar({
9430
9437
  collapsedWidth = DEFAULT_COLLAPSED_WIDTH,
9431
9438
  type = "single",
9432
9439
  openModuleIds: openModulesProp,
9433
- defaultOpenModuleIds = [],
9440
+ defaultOpenModuleIds,
9434
9441
  onOpenModulesChange,
9435
9442
  hideEmptyModules = true,
9436
9443
  activeItemId: activeItemProp,
@@ -9459,9 +9466,16 @@ function FloatingSidebar({
9459
9466
  const isMobile = useIsMobile();
9460
9467
  const baseId = react.useId();
9461
9468
  const [open, setOpen] = useControllableState2(openProp, defaultOpen, onOpenChange);
9469
+ const moduleIdByItemId = react.useMemo(
9470
+ () => new Map(modules.flatMap((module) => module.items.map((item) => [item.id, module.id]))),
9471
+ [modules]
9472
+ );
9473
+ const moduleIdOf = (itemId) => itemId ? moduleIdByItemId.get(itemId) : void 0;
9474
+ const initialActiveModuleId = moduleIdOf(activeItemProp ?? defaultActiveItemId);
9462
9475
  const [rawOpenModuleIds, setOpenModuleIds] = useControllableState2(
9463
9476
  openModulesProp,
9464
- defaultOpenModuleIds,
9477
+ // Without an explicit default, the module of the current page starts open.
9478
+ defaultOpenModuleIds ?? (initialActiveModuleId ? [initialActiveModuleId] : []),
9465
9479
  onOpenModulesChange
9466
9480
  );
9467
9481
  const railWidth = Math.max(MIN_COLLAPSED_WIDTH, collapsedWidth);
@@ -9563,8 +9577,31 @@ function FloatingSidebar({
9563
9577
  document.addEventListener("keydown", onKeyDown);
9564
9578
  return () => document.removeEventListener("keydown", onKeyDown);
9565
9579
  }, [shortcut, toggle, isMobile, mobileOpen, setMobileOpen]);
9580
+ const openModule = (moduleId) => {
9581
+ const opened = rawOpenModuleIds.includes(moduleId);
9582
+ if (type === "multiple") {
9583
+ if (!opened) setOpenModuleIds([...rawOpenModuleIds, moduleId]);
9584
+ } else if (!opened || rawOpenModuleIds.length > 1) {
9585
+ setOpenModuleIds([moduleId]);
9586
+ }
9587
+ };
9588
+ const activeModuleId = moduleIdOf(activeItemId);
9589
+ const syncedActive = react.useRef(`${activeItemId}|${activeModuleId}`);
9590
+ react.useEffect(() => {
9591
+ const key = `${activeItemId}|${activeModuleId}`;
9592
+ if (syncedActive.current === key) return;
9593
+ syncedActive.current = key;
9594
+ if (activeModuleId) openModule(activeModuleId);
9595
+ });
9566
9596
  const selectItem = (item, module, navigates) => {
9567
- if (navigates) setActiveItemId(item.id);
9597
+ if (navigates) {
9598
+ setActiveItemId(item.id);
9599
+ openModule(module.id);
9600
+ if (activeItemProp === void 0) {
9601
+ syncedActive.current = `${item.id}|${moduleIdOf(item.id)}`;
9602
+ }
9603
+ if (queries[module.id]) setQueries((current) => ({ ...current, [module.id]: "" }));
9604
+ }
9568
9605
  setFlyoutId(null);
9569
9606
  if (isMobile) setMobileOpen(false);
9570
9607
  onItemSelect?.(item, module);
@@ -9979,6 +10016,11 @@ function ModuleCard({
9979
10016
  });
9980
10017
  return () => animation2?.cancel();
9981
10018
  }, [collapsed, hasActive, reduced]);
10019
+ const [toggle, setToggle] = react.useState({ collapsed, open, accordion: false });
10020
+ if (toggle.collapsed !== collapsed || toggle.open !== open) {
10021
+ setToggle({ collapsed, open, accordion: toggle.collapsed === collapsed });
10022
+ }
10023
+ const accordion = toggle.accordion && !reduced;
9982
10024
  const items = filterItems(module.items, query);
9983
10025
  const isEmpty = module.items.length === 0;
9984
10026
  const emptyMessage = /* @__PURE__ */ jsxRuntime.jsx(
@@ -10197,6 +10239,7 @@ function ModuleCard({
10197
10239
  list,
10198
10240
  visible: open,
10199
10241
  staggerIndex: index,
10242
+ accordion,
10200
10243
  onSelect: (navigates) => onSelect(item, navigates)
10201
10244
  },
10202
10245
  item.id
@@ -10321,20 +10364,27 @@ function ModuleCard({
10321
10364
  }
10322
10365
  ) });
10323
10366
  }
10324
- function ItemRow({ item, list, visible, staggerIndex, onSelect }) {
10367
+ function ItemRow({ item, list, visible, staggerIndex, accordion, onSelect }) {
10325
10368
  const { activeItemId, favoriteIds, reduced, labels, resolveIcon, renderLink } = list;
10326
10369
  const active = item.id === activeItemId;
10327
10370
  const favorite = favoriteIds?.includes(item.id) ?? false;
10328
10371
  const tabIndex = visible ? 0 : -1;
10329
10372
  const staggered = staggerIndex !== void 0;
10330
- const delay = staggered && visible ? Math.min(staggerIndex * 20, FADE_MS) : 0;
10373
+ let fade = t("opacity", FADE_MS, 0);
10374
+ if (staggered && accordion) {
10375
+ const step = Math.min(staggerIndex, ACCORDION_STAGGER_CAP);
10376
+ fade = visible ? t(
10377
+ "opacity",
10378
+ ACCORDION_ITEM_FADE_MS,
10379
+ ACCORDION_OPEN_DELAY_MS + step * ACCORDION_OPEN_STAGGER_MS,
10380
+ ACCORDION_EASE
10381
+ ) : t("opacity", ACCORDION_CLOSE_FADE_MS, 0, ACCORDION_EASE);
10382
+ } else if (staggered && visible) {
10383
+ fade = t("opacity", FADE_MS, Math.min(staggerIndex * RAIL_STAGGER_MS, FADE_MS));
10384
+ }
10331
10385
  const rowStyle = staggered ? {
10332
10386
  opacity: visible ? 1 : 0,
10333
- transition: transition2(
10334
- reduced,
10335
- t("opacity", FADE_MS, delay),
10336
- "background-color 180ms ease-out"
10337
- )
10387
+ transition: transition2(reduced, fade, "background-color 180ms ease-out")
10338
10388
  } : { transition: "background-color 180ms ease-out" };
10339
10389
  const className = cn(
10340
10390
  "focus-visible:ring-primary flex min-h-[46px] min-w-0 flex-1 cursor-pointer items-start gap-3 rounded-[10px] border-0 bg-transparent py-[13px] pr-1 pl-3 text-left text-[13px] leading-5 transition-transform duration-180 ease-[cubic-bezier(.2,.8,.2,1)] outline-none hover:text-primary focus-visible:ring-2 focus-visible:ring-inset disabled:cursor-not-allowed disabled:opacity-50",