@capra/core 1.11.1 → 1.12.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/dist/index.mjs CHANGED
@@ -4097,20 +4097,21 @@ const Toast = {
4097
4097
  //#endregion
4098
4098
  //#region src/components/Menu/Menu.module.css
4099
4099
  var Menu_module_default = {
4100
- "divider": "capra-Menu-module-3G4VeG-divider",
4101
- "header": "capra-Menu-module-3G4VeG-header",
4102
- "list": "capra-Menu-module-3G4VeG-list",
4103
- "menu": "capra-Menu-module-3G4VeG-menu",
4104
- "menuItem": "capra-Menu-module-3G4VeG-menuItem",
4105
- "menuItemDescription": "capra-Menu-module-3G4VeG-menuItemDescription",
4106
- "menuItemLabel": "capra-Menu-module-3G4VeG-menuItemLabel",
4107
- "menuItemLeadingGutter": "capra-Menu-module-3G4VeG-menuItemLeadingGutter",
4108
- "menuItemListItemShell": "capra-Menu-module-3G4VeG-menuItemListItemShell",
4109
- "menuItemShortcut": "capra-Menu-module-3G4VeG-menuItemShortcut",
4110
- "menuItemTrailingGroup": "capra-Menu-module-3G4VeG-menuItemTrailingGroup",
4111
- "menuItemTrailingGutter": "capra-Menu-module-3G4VeG-menuItemTrailingGutter",
4112
- "menuTriggerSlot": "capra-Menu-module-3G4VeG-menuTriggerSlot",
4113
- "section": "capra-Menu-module-3G4VeG-section"
4100
+ "divider": "capra-Menu-module-HIhAFW-divider",
4101
+ "header": "capra-Menu-module-HIhAFW-header",
4102
+ "list": "capra-Menu-module-HIhAFW-list",
4103
+ "menu": "capra-Menu-module-HIhAFW-menu",
4104
+ "menuItem": "capra-Menu-module-HIhAFW-menuItem",
4105
+ "menuItemDescription": "capra-Menu-module-HIhAFW-menuItemDescription",
4106
+ "menuItemLabel": "capra-Menu-module-HIhAFW-menuItemLabel",
4107
+ "menuItemLeadingGutter": "capra-Menu-module-HIhAFW-menuItemLeadingGutter",
4108
+ "menuItemListItemShell": "capra-Menu-module-HIhAFW-menuItemListItemShell",
4109
+ "menuItemShortcut": "capra-Menu-module-HIhAFW-menuItemShortcut",
4110
+ "menuItemTrailingGroup": "capra-Menu-module-HIhAFW-menuItemTrailingGroup",
4111
+ "menuItemTrailingGutter": "capra-Menu-module-HIhAFW-menuItemTrailingGutter",
4112
+ "menuTriggerSlot": "capra-Menu-module-HIhAFW-menuTriggerSlot",
4113
+ "section": "capra-Menu-module-HIhAFW-section",
4114
+ "slot": "capra-Menu-module-HIhAFW-slot"
4114
4115
  };
4115
4116
  //#endregion
4116
4117
  //#region src/components/Menu/Menu.tsx
@@ -4200,7 +4201,7 @@ const MenuItem$1 = ({ as: Component, label, description, ariaLabel, href, disabl
4200
4201
  const labelContent = children ?? label;
4201
4202
  const showDescription = description != null && description !== "";
4202
4203
  const textValue = ariaLabel || (typeof label === "string" ? label : void 0) || (typeof children === "string" ? children : void 0) || "";
4203
- const listItemContent = /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, (indent || icon) && /* @__PURE__ */ React$1.createElement(ListItem.Leading, { FORCE__className: icon ? Menu_module_default.menuItemLeadingGutter : void 0 }, icon && /* @__PURE__ */ React$1.createElement("span", { "aria-hidden": "true" }, icon)), /* @__PURE__ */ React$1.createElement(ListItem.Content, null, /* @__PURE__ */ React$1.createElement(ListItem.Label, null, /* @__PURE__ */ React$1.createElement("span", { className: Menu_module_default.menuItemLabel }, labelContent)), showDescription ? /* @__PURE__ */ React$1.createElement(ListItem.Description, null, /* @__PURE__ */ React$1.createElement("span", { className: Menu_module_default.menuItemDescription }, description)) : null), (shortcut || parent) && /* @__PURE__ */ React$1.createElement(ListItem.Trailing, { FORCE__className: Menu_module_default.menuItemTrailingGutter }, /* @__PURE__ */ React$1.createElement("span", { className: Menu_module_default.menuItemTrailingGroup }, [shortcut ? /* @__PURE__ */ React$1.createElement("span", {
4204
+ const listItemContent = /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, (indent || icon) && /* @__PURE__ */ React$1.createElement(ListItem.Leading, { FORCE__className: icon ? Menu_module_default.menuItemLeadingGutter : void 0 }, icon), /* @__PURE__ */ React$1.createElement(ListItem.Content, null, /* @__PURE__ */ React$1.createElement(ListItem.Label, null, /* @__PURE__ */ React$1.createElement("span", { className: Menu_module_default.menuItemLabel }, labelContent)), showDescription ? /* @__PURE__ */ React$1.createElement(ListItem.Description, null, /* @__PURE__ */ React$1.createElement("span", { className: Menu_module_default.menuItemDescription }, description)) : null), (shortcut || parent) && /* @__PURE__ */ React$1.createElement(ListItem.Trailing, { FORCE__className: Menu_module_default.menuItemTrailingGutter }, /* @__PURE__ */ React$1.createElement("span", { className: Menu_module_default.menuItemTrailingGroup }, [shortcut ? /* @__PURE__ */ React$1.createElement("span", {
4204
4205
  key: "shortcut",
4205
4206
  className: Menu_module_default.menuItemShortcut
4206
4207
  }, shortcut) : null, parent ? /* @__PURE__ */ React$1.createElement(ChevronRight, {
@@ -4228,7 +4229,8 @@ const MenuItem$1 = ({ as: Component, label, description, ariaLabel, href, disabl
4228
4229
  "data-has-description": showDescription || void 0,
4229
4230
  render,
4230
4231
  onClick,
4231
- onPress
4232
+ onPress,
4233
+ ...rest
4232
4234
  }, /* @__PURE__ */ React$1.createElement(ListItem, {
4233
4235
  as: "div",
4234
4236
  role: "presentation",
@@ -4270,7 +4272,6 @@ const MenuSubmenu = ({ label, children, itemHoverAppearance = "default", itemAct
4270
4272
  }, listItemContent)), /* @__PURE__ */ React$1.createElement(PopoverSurface, {
4271
4273
  placement: "rightTop",
4272
4274
  isNonModal: true,
4273
- shouldFlip: false,
4274
4275
  offsets: [0, 0],
4275
4276
  removeContentPadding: true
4276
4277
  }, /* @__PURE__ */ React$1.createElement("div", menuSessionId != null ? { [MENU_SESSION_DATA_ATTR]: menuSessionId } : {}, /* @__PURE__ */ React$1.createElement(Menu$1, {
@@ -4338,7 +4339,7 @@ function MenuPanelFocusScope({ controlledOpen, children }) {
4338
4339
  restoreFocus: true
4339
4340
  }, children));
4340
4341
  }
4341
- const Menu = ({ trigger, children, contentProps, open, onOpenChange, itemHoverAppearance = "default", itemActiveAccentBar = true, itemActiveLabelSemibold = true, panelPadding = "default", popoverOffset = 0, trapFocus = false, FORCE__className: classNameOverride }) => {
4342
+ const Menu = ({ trigger, children, contentProps, open, onOpenChange, itemHoverAppearance = "default", itemActiveAccentBar = true, itemActiveLabelSemibold = true, panelPadding = "default", popoverOffset = 2, trapFocus = false, FORCE__className: classNameOverride }) => {
4342
4343
  const sessionId = React$1.useId();
4343
4344
  const menuPanel = /* @__PURE__ */ React$1.createElement(Menu$1, {
4344
4345
  className: clsx(Menu_module_default.menu, classNameOverride),
@@ -4405,6 +4406,17 @@ var TabNav_module_default = {
4405
4406
  const SUB_KEY_SEP = "::";
4406
4407
  /** Delay before closing a subnav on pointer leave (hover), so users can move into the menu. */
4407
4408
  const HOVER_CLOSE_DELAY_MS = 150;
4409
+ function getRoutedLinkProps(source) {
4410
+ return {
4411
+ href: source.href,
4412
+ hrefLang: source.hrefLang,
4413
+ target: source.target,
4414
+ rel: source.rel,
4415
+ download: source.download,
4416
+ referrerPolicy: source.referrerPolicy,
4417
+ routerOptions: source.routerOptions
4418
+ };
4419
+ }
4408
4420
  function optionalAriaLabelProps(source) {
4409
4421
  const v = source["aria-label"];
4410
4422
  return v != null && v !== "" ? { "aria-label": v } : {};
@@ -4414,7 +4426,7 @@ function optionalAriaLabelProps(source) {
4414
4426
  * Tab items are links that redirect to URLs. With `subItems`, horizontal tabs open a dropdown menu; vertical tabs
4415
4427
  * use an inline indented list (Tab Nav | Vertical in Figma).
4416
4428
  */
4417
- const TabNav = ({ activeKey, onTabClick, items, tabPlacement = "horizontal", centered = false, tabBarExtraSlot, wrap = true, FORCE__className: classNameOverride, "aria-label": ariaLabel = "Navigation", ...props }) => {
4429
+ const TabNav = ({ activeKey, onTabPress, onTabClick, items, tabPlacement = "horizontal", centered = false, tabBarExtraSlot, wrap = true, FORCE__className: classNameOverride, "aria-label": ariaLabel = "Navigation", ...props }) => {
4418
4430
  const [subMenuOpen, setSubMenuOpen] = React$1.useState({});
4419
4431
  const hoverCloseTimeoutRef = React$1.useRef(null);
4420
4432
  const pendingKeyboardFocusKeyRef = React$1.useRef(null);
@@ -4575,15 +4587,6 @@ const TabNav = ({ activeKey, onTabClick, items, tabPlacement = "horizontal", cen
4575
4587
  getEnabledMenuItems,
4576
4588
  getTriggerElement
4577
4589
  ]);
4578
- const handleTabClick = (key, event) => {
4579
- const item = items.find((i) => i.key === key);
4580
- if (item?.disabled) {
4581
- event.preventDefault();
4582
- return;
4583
- }
4584
- if (item?.subItems?.length) return;
4585
- onTabClick?.(key, event);
4586
- };
4587
4590
  const handleKeyDown = (event, key) => {
4588
4591
  const itemIndex = items.findIndex((i) => i.key === key);
4589
4592
  if (itemIndex === -1) return;
@@ -4720,37 +4723,24 @@ const TabNav = ({ activeKey, onTabClick, items, tabPlacement = "horizontal", cen
4720
4723
  }, item.subItems.map((sub) => {
4721
4724
  const subActive = activeMainKey === item.key && activeSubKey === sub.key;
4722
4725
  const compoundKey = `${item.key}${SUB_KEY_SEP}${sub.key}`;
4723
- const subCommon = {
4726
+ return /* @__PURE__ */ React$1.createElement("li", {
4727
+ key: sub.key,
4728
+ className: TabNav_module_default.subTabListItem
4729
+ }, /* @__PURE__ */ React$1.createElement(Link$1, {
4724
4730
  "data-tab-key": compoundKey,
4725
4731
  "data-indent": true,
4726
4732
  "data-variant": "default",
4727
4733
  "data-active": subActive || void 0,
4728
- "data-disabled": sub.disabled || void 0,
4729
4734
  id: `tabnav-${item.key}-${sub.key}`,
4730
4735
  className: clsx(TabNav_module_default.tab, TabNav_module_default.subTab),
4731
- "aria-current": subActive ? "page" : void 0
4732
- };
4733
- if (sub.href && sub.disabled) return /* @__PURE__ */ React$1.createElement("li", {
4734
- key: sub.key,
4735
- className: TabNav_module_default.subTabListItem
4736
- }, /* @__PURE__ */ React$1.createElement("a", {
4737
- ...subCommon,
4738
- ...optionalAriaLabelProps(sub),
4739
- href: sub.href,
4740
- "aria-disabled": true,
4741
- tabIndex: -1,
4742
- onClick: (e) => e.preventDefault()
4743
- }, /* @__PURE__ */ React$1.createElement("span", {
4744
- className: TabNav_module_default.indentSpacer,
4745
- "aria-hidden": "true"
4746
- }), /* @__PURE__ */ React$1.createElement("span", { className: TabNav_module_default.tabLabel }, sub.name)));
4747
- if (sub.href) return /* @__PURE__ */ React$1.createElement("li", {
4748
- key: sub.key,
4749
- className: TabNav_module_default.subTabListItem
4750
- }, /* @__PURE__ */ React$1.createElement("a", {
4751
- ...subCommon,
4736
+ "aria-current": subActive ? "page" : void 0,
4752
4737
  ...optionalAriaLabelProps(sub),
4753
- href: sub.href,
4738
+ ...getRoutedLinkProps(sub),
4739
+ isDisabled: sub.disabled,
4740
+ onPress: () => {
4741
+ sub.onPress?.();
4742
+ onTabPress?.(compoundKey);
4743
+ },
4754
4744
  onClick: (e) => {
4755
4745
  sub.onClick?.(e);
4756
4746
  onTabClick?.(compoundKey, e);
@@ -4760,26 +4750,6 @@ const TabNav = ({ activeKey, onTabClick, items, tabPlacement = "horizontal", cen
4760
4750
  className: TabNav_module_default.indentSpacer,
4761
4751
  "aria-hidden": "true"
4762
4752
  }), /* @__PURE__ */ React$1.createElement("span", { className: TabNav_module_default.tabLabel }, sub.name)));
4763
- return /* @__PURE__ */ React$1.createElement("li", {
4764
- key: sub.key,
4765
- className: TabNav_module_default.subTabListItem
4766
- }, /* @__PURE__ */ React$1.createElement("span", {
4767
- ...subCommon,
4768
- ...optionalAriaLabelProps(sub),
4769
- role: "link",
4770
- "aria-disabled": sub.disabled,
4771
- tabIndex: sub.disabled ? -1 : 0,
4772
- onKeyDown: (e) => {
4773
- if (e.key === "Enter" || e.key === " ") {
4774
- e.preventDefault();
4775
- sub.onClick?.(e);
4776
- onTabClick?.(compoundKey, e);
4777
- } else handleKeyDown(e, item.key);
4778
- }
4779
- }, /* @__PURE__ */ React$1.createElement("span", {
4780
- className: TabNav_module_default.indentSpacer,
4781
- "aria-hidden": "true"
4782
- }), /* @__PURE__ */ React$1.createElement("span", { className: TabNav_module_default.tabLabel }, sub.name)));
4783
4753
  })));
4784
4754
  }
4785
4755
  if (hasSubItems) {
@@ -4803,7 +4773,7 @@ const TabNav = ({ activeKey, onTabClick, items, tabPlacement = "horizontal", cen
4803
4773
  itemActiveLabelSemibold: false,
4804
4774
  panelPadding: "none",
4805
4775
  popoverOffset: 1,
4806
- open: subMenuOpen[item.key],
4776
+ open: Boolean(subMenuOpen[item.key]),
4807
4777
  onOpenChange: (open) => {
4808
4778
  if (open) {
4809
4779
  openSubMenu(item.key);
@@ -4839,36 +4809,30 @@ const TabNav = ({ activeKey, onTabClick, items, tabPlacement = "horizontal", cen
4839
4809
  ariaLabel: sub["aria-label"],
4840
4810
  href: sub.href,
4841
4811
  disabled: sub.disabled,
4812
+ routerOptions: sub.routerOptions,
4842
4813
  active: activeSubKey === sub.key,
4814
+ onPress: () => {
4815
+ sub.onPress?.();
4816
+ onTabPress?.(`${item.key}${SUB_KEY_SEP}${sub.key}`);
4817
+ closeMenu();
4818
+ },
4843
4819
  onClick: (e) => {
4844
4820
  sub.onClick?.(e);
4845
- closeMenu();
4821
+ onTabClick?.(`${item.key}${SUB_KEY_SEP}${sub.key}`, e);
4846
4822
  }
4847
4823
  });
4848
4824
  }));
4849
4825
  }
4850
- if (item.href && !item.disabled) return /* @__PURE__ */ React$1.createElement(Link$1, {
4826
+ return /* @__PURE__ */ React$1.createElement(Link$1, {
4851
4827
  key: item.key,
4852
4828
  ...commonTabProps,
4853
- href: item.href,
4829
+ ...getRoutedLinkProps(item),
4830
+ isDisabled: item.disabled,
4854
4831
  "aria-current": ariaCurrentPage ? "page" : void 0,
4855
- onClick: (e) => handleTabClick(item.key, e),
4832
+ onPress: () => onTabPress?.(item.key),
4833
+ onClick: (e) => onTabClick?.(item.key, e),
4856
4834
  onKeyDown: (e) => handleKeyDown(e, item.key)
4857
4835
  }, renderTabContent(item));
4858
- return /* @__PURE__ */ React$1.createElement("span", {
4859
- key: item.key,
4860
- ...commonTabProps,
4861
- role: "link",
4862
- "aria-disabled": item.disabled,
4863
- "aria-current": ariaCurrentPage ? "page" : void 0,
4864
- tabIndex: item.disabled ? -1 : computedTabIndex ?? 0,
4865
- onKeyDown: (e) => {
4866
- if (e.key === "Enter" || e.key === " ") {
4867
- e.preventDefault();
4868
- handleTabClick(item.key, e);
4869
- } else handleKeyDown(e, item.key);
4870
- }
4871
- }, renderTabContent(item));
4872
4836
  })), tabBarExtraSlot && /* @__PURE__ */ React$1.createElement("div", { className: TabNav_module_default.extraContent }, tabBarExtraSlot)));
4873
4837
  };
4874
4838
  TabNav.displayName = "TabNav";