@tensor_1/react 2.26.3 → 2.27.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.
Files changed (55) hide show
  1. package/README.md +51 -0
  2. package/dist/calendar-model.d.ts +4 -2
  3. package/dist/components/AppShell.d.ts +1 -1
  4. package/dist/components/AppShell.js +6 -2
  5. package/dist/components/Button.d.ts +28 -4
  6. package/dist/components/Button.js +19 -9
  7. package/dist/components/Card.d.ts +7 -1
  8. package/dist/components/Card.js +3 -3
  9. package/dist/components/Chip.d.ts +43 -0
  10. package/dist/components/Chip.js +73 -0
  11. package/dist/components/CollapsibleSection.d.ts +19 -1
  12. package/dist/components/CollapsibleSection.js +5 -2
  13. package/dist/components/CollapsibleSectionState.d.ts +11 -0
  14. package/dist/components/CollapsibleSectionState.js +67 -0
  15. package/dist/components/CommandPalette.d.ts +1 -1
  16. package/dist/components/CommandPalette.js +4 -1
  17. package/dist/components/DateRangePicker.js +3 -1
  18. package/dist/components/Dialogs.d.ts +54 -3
  19. package/dist/components/Dialogs.js +167 -6
  20. package/dist/components/Drawer.d.ts +6 -1
  21. package/dist/components/Drawer.js +5 -2
  22. package/dist/components/Kbd.d.ts +27 -0
  23. package/dist/components/Kbd.js +45 -0
  24. package/dist/components/Menu.d.ts +51 -0
  25. package/dist/components/Menu.js +177 -0
  26. package/dist/components/Modal.d.ts +1 -1
  27. package/dist/components/Modal.js +4 -1
  28. package/dist/components/Pagination.d.ts +36 -5
  29. package/dist/components/Pagination.js +59 -37
  30. package/dist/components/Peek.d.ts +1 -1
  31. package/dist/components/Peek.js +6 -1
  32. package/dist/components/SchedulingCalendar.d.ts +47 -2
  33. package/dist/components/SchedulingCalendar.js +69 -22
  34. package/dist/components/SearchSuggest.d.ts +1 -1
  35. package/dist/components/SearchSuggest.js +4 -1
  36. package/dist/components/Sidebar.d.ts +7 -2
  37. package/dist/components/Sidebar.js +15 -4
  38. package/dist/components/Stat.d.ts +16 -0
  39. package/dist/components/Stat.js +12 -5
  40. package/dist/components/Steps.d.ts +48 -0
  41. package/dist/components/Steps.js +42 -0
  42. package/dist/components/Toast.d.ts +2 -2
  43. package/dist/components/Toast.js +7 -2
  44. package/dist/components/Tooltip.d.ts +10 -4
  45. package/dist/components/Tooltip.js +2 -2
  46. package/dist/emoji.cjs +2 -2
  47. package/dist/index.cjs +2061 -1350
  48. package/dist/index.d.cts +596 -165
  49. package/dist/index.d.ts +10 -4
  50. package/dist/index.js +24 -2
  51. package/dist/labels-context.d.ts +72 -0
  52. package/dist/labels-context.js +23 -0
  53. package/dist/link.d.ts +20 -0
  54. package/dist/link.js +9 -0
  55. package/package.json +1 -1
@@ -0,0 +1,42 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Children, cloneElement, isValidElement } from "react";
3
+ import { cx } from "../cx.js";
4
+ import { renderUixLink } from "../link.js";
5
+ const DEFAULT_STEP_STATE_LABELS = {
6
+ complete: "Completed",
7
+ current: "Current step",
8
+ upcoming: "Not started",
9
+ waiting: "Waiting",
10
+ error: "Needs attention"
11
+ };
12
+ const CSS_STATE = { complete: "done", current: "active", upcoming: void 0, waiting: "waiting", error: "error" };
13
+ const Check = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "12", height: "12", fill: "none", stroke: "currentColor", strokeWidth: 2.25, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M3.5 8.5l3 3 6-7" }) });
14
+ function Steps({ orientation = "horizontal", label, stateLabels, className, children, ...props }) {
15
+ const labels = { ...DEFAULT_STEP_STATE_LABELS, ...stateLabels };
16
+ const steps = Children.toArray(children).filter(isValidElement);
17
+ return /* @__PURE__ */ jsx("ol", { "aria-label": label, className: cx("uix-steps", "uix-steps--list", `uix-steps--${orientation}`, className), ...props, children: steps.map((step, index) => cloneElement(step, { index, last: index === steps.length - 1, stateLabels: labels })) });
18
+ }
19
+ function Step({ title, description, state = "upcoming", marker, href, renderLink, onSelect, index = 0, last = false, stateLabels = DEFAULT_STEP_STATE_LABELS, className, ...props }) {
20
+ const glyph = marker ?? (state === "complete" ? /* @__PURE__ */ jsx(Check, {}) : state === "error" ? "!" : index + 1);
21
+ const name = /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ /* @__PURE__ */ jsx("span", { className: "uix-step__title", children: title }),
23
+ /* @__PURE__ */ jsxs("span", { className: "uix-visually-hidden", children: [
24
+ ", ",
25
+ stateLabels[state]
26
+ ] })
27
+ ] });
28
+ const titled = href != null ? renderUixLink(renderLink, { href, className: "uix-step__action", children: name }) : onSelect ? /* @__PURE__ */ jsx("button", { type: "button", className: "uix-step__action", onClick: onSelect, children: name }) : /* @__PURE__ */ jsx("span", { className: "uix-step__action", children: name });
29
+ return /* @__PURE__ */ jsxs("li", { className: cx("uix-step", className), "data-state": CSS_STATE[state], "aria-current": state === "current" ? "step" : void 0, ...props, children: [
30
+ /* @__PURE__ */ jsx("span", { className: "uix-step__marker", "aria-hidden": "true", children: glyph }),
31
+ /* @__PURE__ */ jsxs("span", { className: "uix-step__text", children: [
32
+ titled,
33
+ description != null && /* @__PURE__ */ jsx("span", { className: "uix-step__desc", children: description })
34
+ ] }),
35
+ !last && /* @__PURE__ */ jsx("span", { className: "uix-step__connector", "aria-hidden": "true", "data-done": state === "complete" || void 0 })
36
+ ] });
37
+ }
38
+ export {
39
+ DEFAULT_STEP_STATE_LABELS,
40
+ Step,
41
+ Steps
42
+ };
@@ -12,12 +12,12 @@ interface ToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
12
12
  onClose?: () => void;
13
13
  leaving?: boolean;
14
14
  }
15
- declare function Toast({ title, message, tone, icon, onClose, leaving, dismissLabel, className, ...props }: ToastProps): react.JSX.Element;
15
+ declare function Toast({ title, message, tone, icon, onClose, leaving, dismissLabel: dismissLabelProp, className, ...props }: ToastProps): react.JSX.Element;
16
16
  interface ToasterProps extends HTMLAttributes<HTMLDivElement> {
17
17
  /** TENSOR RX-125 (UIX-04): translatable; English default. */
18
18
  regionLabel?: string;
19
19
  children?: ReactNode;
20
20
  }
21
- declare function Toaster({ children, regionLabel, className, ...props }: ToasterProps): react.JSX.Element;
21
+ declare function Toaster({ children, regionLabel: regionLabelProp, className, ...props }: ToasterProps): react.JSX.Element;
22
22
 
23
23
  export { Toast, type ToastProps, type ToastTone, Toaster, type ToasterProps };
@@ -2,8 +2,11 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { cx } from "../cx.js";
5
+ import { useUixLabels } from "../labels-context.js";
5
6
  const ToasterContext = createContext(null);
6
- function Toast({ title, message, tone, icon, onClose, leaving, dismissLabel = "Dismiss", className, ...props }) {
7
+ function Toast({ title, message, tone, icon, onClose, leaving, dismissLabel: dismissLabelProp, className, ...props }) {
8
+ const uixLabels = useUixLabels();
9
+ const dismissLabel = dismissLabelProp ?? uixLabels.toast?.dismiss ?? "Dismiss";
7
10
  const assertive = tone === "danger";
8
11
  const toaster = useContext(ToasterContext);
9
12
  const bodyRef = useRef(null);
@@ -44,7 +47,9 @@ function Toast({ title, message, tone, icon, onClose, leaving, dismissLabel = "D
44
47
  }
45
48
  );
46
49
  }
47
- function Toaster({ children, regionLabel = "Notifications", className, ...props }) {
50
+ function Toaster({ children, regionLabel: regionLabelProp, className, ...props }) {
51
+ const uixLabels = useUixLabels();
52
+ const regionLabel = regionLabelProp ?? uixLabels.toaster?.region ?? "Notifications";
48
53
  const [announced, setAnnounced] = useState("");
49
54
  const clearTimer = useRef(null);
50
55
  const announce = useCallback((text) => {
@@ -2,9 +2,15 @@ import * as react from 'react';
2
2
  import { HTMLAttributes, ReactNode } from 'react';
3
3
  import { Placement } from '../overlay-position.js';
4
4
 
5
- interface TooltipProps extends HTMLAttributes<HTMLSpanElement> {
6
- /** Tooltip text. */
7
- label: string;
5
+ interface TooltipProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'content'> {
6
+ /** Tooltip text. Pass this or `content`. */
7
+ label?: string;
8
+ /**
9
+ * Rich, non-interactive tooltip content, e.g. a short list (HAR-1349; TENSOR A3). It is
10
+ * still a `role="tooltip"` description: no links or buttons inside — use `InfoTip` or
11
+ * `Popover` for content the user must reach. Wins over `label` when both are set.
12
+ */
13
+ content?: ReactNode;
8
14
  /** Preferred placement. Default `'top'`. */
9
15
  placement?: Placement;
10
16
  children?: ReactNode;
@@ -17,6 +23,6 @@ interface TooltipProps extends HTMLAttributes<HTMLSpanElement> {
17
23
  * (document-level, per WCAG 1.4.13), and hoverable: the bubble stays open while
18
24
  * the pointer is over it (UIX-A11Y-1).
19
25
  */
20
- declare function Tooltip({ label, placement, className, children, ...props }: TooltipProps): react.JSX.Element;
26
+ declare function Tooltip({ label, content, placement, className, children, ...props }: TooltipProps): react.JSX.Element;
21
27
 
22
28
  export { Tooltip, type TooltipProps };
@@ -3,7 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { cloneElement, isValidElement, useEffect, useId, useRef, useState } from "react";
4
4
  import { cx } from "../cx.js";
5
5
  import { useAnchoredPosition } from "../hooks/useAnchoredPosition.js";
6
- function Tooltip({ label, placement = "top", className, children, ...props }) {
6
+ function Tooltip({ label, content, placement = "top", className, children, ...props }) {
7
7
  const triggerRef = useRef(null);
8
8
  const bubbleRef = useRef(null);
9
9
  const closeTimer = useRef(null);
@@ -92,7 +92,7 @@ function Tooltip({ label, placement = "top", className, children, ...props }) {
92
92
  onMouseEnter: cancelClose,
93
93
  onMouseLeave: scheduleHide,
94
94
  ...bubbleAttr,
95
- children: label
95
+ children: content ?? label
96
96
  }
97
97
  )
98
98
  ]
package/dist/emoji.cjs CHANGED
@@ -939,7 +939,7 @@ function EditorIcon({ name, ...props }) {
939
939
  // src/components/Tooltip.tsx
940
940
  var import_react5 = require("react");
941
941
  var import_jsx_runtime5 = require("react/jsx-runtime");
942
- function Tooltip({ label, placement = "top", className, children, ...props }) {
942
+ function Tooltip({ label, content, placement = "top", className, children, ...props }) {
943
943
  const triggerRef = (0, import_react5.useRef)(null);
944
944
  const bubbleRef = (0, import_react5.useRef)(null);
945
945
  const closeTimer = (0, import_react5.useRef)(null);
@@ -1028,7 +1028,7 @@ function Tooltip({ label, placement = "top", className, children, ...props }) {
1028
1028
  onMouseEnter: cancelClose,
1029
1029
  onMouseLeave: scheduleHide,
1030
1030
  ...bubbleAttr,
1031
- children: label
1031
+ children: content ?? label
1032
1032
  }
1033
1033
  )
1034
1034
  ]