@tensor_1/react 2.68.0 → 2.70.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.
@@ -10,6 +10,7 @@ import { useHoverGlide } from "../hooks/useHoverGlide.js";
10
10
  import { useSlidingIndicator } from "../hooks/useSlidingIndicator.js";
11
11
  import { useArrivalBlur } from "../hooks/useArrivalBlur.js";
12
12
  import { watchInputModality } from "../motion.js";
13
+ import { renderUixLink } from "../link.js";
13
14
  const ChevronIcon = () => /* @__PURE__ */ jsx("svg", { className: "uix-navgroup__chevron", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2 4l4 4 4-4" }) });
14
15
  function Sidebar({ collapsed, nav, onToggle, brand, toggleIcon, actions, search, footer, children, expandLabel: expandLabelProp, collapseLabel: collapseLabelProp, className, ...props }) {
15
16
  const uixLabels = useUixLabels();
@@ -71,7 +72,22 @@ function SidebarSection({ label, children }) {
71
72
  children
72
73
  ] });
73
74
  }
74
- const NavItem = forwardRef(function NavItem2({ icon, badge, active, as: Tag = "a", description, children, className, ...props }, ref) {
75
+ function navLink(renderLink, ref, props, children) {
76
+ if (!renderLink || props.href == null) return /* @__PURE__ */ jsx("a", { ref, ...props, children });
77
+ return renderUixLink(renderLink, { ...props, ref, href: String(props.href), children });
78
+ }
79
+ function endSlot(badge, trailing) {
80
+ if (trailing == null) return badge != null ? /* @__PURE__ */ jsx("span", { className: "uix-navitem__badge", children: badge }) : null;
81
+ return /* @__PURE__ */ jsx("span", { className: "uix-navitem__end", children: badge != null && /* @__PURE__ */ jsx("span", { className: "uix-navitem__badge", children: badge }) });
82
+ }
83
+ function withTrailing(link, trailing) {
84
+ if (trailing == null) return link;
85
+ return /* @__PURE__ */ jsxs("div", { className: "uix-navrow", children: [
86
+ link,
87
+ /* @__PURE__ */ jsx("span", { className: "uix-navrow__trailing", children: trailing })
88
+ ] });
89
+ }
90
+ const NavItem = forwardRef(function NavItem2({ icon, badge, active, as: Tag = "a", description, trailing, renderLink, children, className, ...props }, ref) {
75
91
  const text = description == null ? /* @__PURE__ */ jsx("span", { className: "uix-navitem__label", children }) : /* @__PURE__ */ jsxs("span", { className: "uix-navitem__text", children: [
76
92
  /* @__PURE__ */ jsx("span", { className: "uix-navitem__label", children }),
77
93
  /* @__PURE__ */ jsx("span", { className: "uix-navitem__desc", children: description })
@@ -79,37 +95,33 @@ const NavItem = forwardRef(function NavItem2({ icon, badge, active, as: Tag = "a
79
95
  const multiline = description == null ? void 0 : true;
80
96
  if (Tag === "button") {
81
97
  const { href: _href, ...btnProps } = props;
82
- return /* @__PURE__ */ jsxs(
83
- "button",
84
- {
85
- ref,
86
- type: "button",
87
- className: cx("uix-navitem", className),
88
- "aria-current": active ? "page" : void 0,
89
- "data-multiline": multiline,
90
- ...btnProps,
91
- children: [
92
- icon && /* @__PURE__ */ jsx("span", { className: "uix-navitem__icon", "aria-hidden": "true", children: icon }),
93
- text,
94
- badge != null && /* @__PURE__ */ jsx("span", { className: "uix-navitem__badge", children: badge })
95
- ]
96
- }
98
+ return withTrailing(
99
+ /* @__PURE__ */ jsxs(
100
+ "button",
101
+ {
102
+ ref,
103
+ type: "button",
104
+ className: cx("uix-navitem", className),
105
+ "aria-current": active ? "page" : void 0,
106
+ "data-multiline": multiline,
107
+ ...btnProps,
108
+ children: [
109
+ icon && /* @__PURE__ */ jsx("span", { className: "uix-navitem__icon", "aria-hidden": "true", children: icon }),
110
+ text,
111
+ endSlot(badge, trailing)
112
+ ]
113
+ }
114
+ ),
115
+ trailing
97
116
  );
98
117
  }
99
- return /* @__PURE__ */ jsxs(
100
- "a",
101
- {
102
- ref,
103
- className: cx("uix-navitem", className),
104
- "aria-current": active ? "page" : void 0,
105
- "data-multiline": multiline,
106
- ...props,
107
- children: [
108
- icon && /* @__PURE__ */ jsx("span", { className: "uix-navitem__icon", "aria-hidden": "true", children: icon }),
109
- text,
110
- badge != null && /* @__PURE__ */ jsx("span", { className: "uix-navitem__badge", children: badge })
111
- ]
112
- }
118
+ return withTrailing(
119
+ navLink(renderLink, ref, { className: cx("uix-navitem", className), "aria-current": active ? "page" : void 0, "data-multiline": multiline, ...props }, /* @__PURE__ */ jsxs(Fragment, { children: [
120
+ icon && /* @__PURE__ */ jsx("span", { className: "uix-navitem__icon", "aria-hidden": "true", children: icon }),
121
+ text,
122
+ endSlot(badge, trailing)
123
+ ] })),
124
+ trailing
113
125
  );
114
126
  });
115
127
  NavItem.displayName = "NavItem";
@@ -152,13 +164,25 @@ function NavGroup({ icon, label, children, defaultExpanded = true, expanded: con
152
164
  /* @__PURE__ */ jsx("div", { ref: panelRef, id: panelId, className: "uix-navgroup__panel", "aria-hidden": !expanded, children: /* @__PURE__ */ jsx("div", { children }) })
153
165
  ] });
154
166
  }
155
- const SubNavItem = forwardRef(function SubNavItem2({ active, as: Tag = "a", children, className, ...props }, ref) {
167
+ const SubNavItem = forwardRef(function SubNavItem2({ active, as: Tag = "a", badge, trailing, renderLink, children, className, ...props }, ref) {
156
168
  const cls = cx("uix-navitem uix-subitem", className);
157
169
  if (Tag === "button") {
158
170
  const { href: _href, ...btnProps } = props;
159
- return /* @__PURE__ */ jsx("button", { ref, type: "button", className: cls, "aria-current": active ? "page" : void 0, ...btnProps, children: /* @__PURE__ */ jsx("span", { className: "uix-navitem__label", children }) });
171
+ return withTrailing(
172
+ /* @__PURE__ */ jsxs("button", { ref, type: "button", className: cls, "aria-current": active ? "page" : void 0, ...btnProps, children: [
173
+ /* @__PURE__ */ jsx("span", { className: "uix-navitem__label", children }),
174
+ endSlot(badge, trailing)
175
+ ] }),
176
+ trailing
177
+ );
160
178
  }
161
- return /* @__PURE__ */ jsx("a", { ref, className: cls, "aria-current": active ? "page" : void 0, ...props, children: /* @__PURE__ */ jsx("span", { className: "uix-navitem__label", children }) });
179
+ return withTrailing(
180
+ navLink(renderLink, ref, { className: cls, "aria-current": active ? "page" : void 0, ...props }, /* @__PURE__ */ jsxs(Fragment, { children: [
181
+ /* @__PURE__ */ jsx("span", { className: "uix-navitem__label", children }),
182
+ endSlot(badge, trailing)
183
+ ] })),
184
+ trailing
185
+ );
162
186
  });
163
187
  SubNavItem.displayName = "SubNavItem";
164
188
  export {
@@ -0,0 +1,25 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface ToolbarMoreProps {
5
+ /**
6
+ * The trigger's visible word and the menu's name. Default: the `UixLabelsProvider`
7
+ * `toolbar.more`, then "More".
8
+ */
9
+ label?: string;
10
+ /** `MenuItem`, `MenuItemCheckbox`, `MenuRadioGroup`, `MenuGroup` and `MenuSeparator`. */
11
+ children?: ReactNode;
12
+ open?: boolean;
13
+ onOpenChange?: (open: boolean) => void;
14
+ className?: string;
15
+ }
16
+ /**
17
+ * A toolbar's one overflow menu (HAR-3090): a quiet "More" trigger at the end of the row that
18
+ * collects the less frequent actions (group by, export, save as, maximize), so search and the
19
+ * filters lead and nothing else competes with them. It is the kit `Menu`, with its keyboard:
20
+ * ↓/↑, Home/End, type-to-find, Enter/Space, Esc and Tab close, focus back on the trigger. The
21
+ * product decides which actions go in; the kit draws the trigger and names it.
22
+ */
23
+ declare function ToolbarMore({ label, children, open, onOpenChange, className }: ToolbarMoreProps): react.JSX.Element;
24
+
25
+ export { ToolbarMore, type ToolbarMoreProps };
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { cx } from "../cx.js";
4
+ import { useUixLabels } from "../labels-context.js";
5
+ import { MoreHorizontalIcon } from "../icons/components.js";
6
+ import { Button } from "./Button.js";
7
+ import { Menu } from "./Menu.js";
8
+ function ToolbarMore({ label, children, open, onOpenChange, className }) {
9
+ const provided = useUixLabels().toolbar?.more;
10
+ const word = label ?? provided ?? "More";
11
+ return /* @__PURE__ */ jsx(
12
+ Menu,
13
+ {
14
+ trigger: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", className: cx("uix-toolbar__more", className), children: [
15
+ /* @__PURE__ */ jsx(MoreHorizontalIcon, { size: "sm", "aria-hidden": "true" }),
16
+ word
17
+ ] }),
18
+ placement: "bottom-end",
19
+ label: word,
20
+ ...open !== void 0 ? { open } : {},
21
+ ...onOpenChange ? { onOpenChange } : {},
22
+ children
23
+ }
24
+ );
25
+ }
26
+ export {
27
+ ToolbarMore
28
+ };