@nextlyhq/ui 0.0.2-alpha.75 → 0.0.2-alpha.76

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.cjs CHANGED
@@ -552,21 +552,39 @@ const Grid = (0, react.forwardRef)(({ cols = 2, gap = 4, responsive = false, cla
552
552
  });
553
553
  });
554
554
  Grid.displayName = "Grid";
555
+ /** Each tone's dot, in the status's solid colour (the same as `Badge`'s). */
556
+ const STAT_TONE_DOT = {
557
+ success: "bg-success-solid",
558
+ warning: "bg-warning-solid",
559
+ destructive: "bg-danger-solid",
560
+ info: "bg-info-solid"
561
+ };
555
562
  /** Labelled metric block for dashboard-style plugin widgets.
556
563
  * @experimental
557
564
  */
558
- const Stat = (0, react.forwardRef)(({ label, value, className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
559
- ref,
560
- className: cn("flex flex-col gap-1", className),
561
- ...props,
562
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
563
- className: "text-sm text-muted-foreground",
564
- children: label
565
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
566
- className: "text-2xl font-semibold text-foreground",
565
+ const Stat = (0, react.forwardRef)(({ label, value, tone, size = "default", className, ...props }, ref) => {
566
+ const compact = size === "compact";
567
+ const figure = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
568
+ className: cn("font-semibold text-foreground", compact ? "text-xl" : "text-2xl"),
567
569
  children: value
568
- })]
569
- }));
570
+ });
571
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
572
+ ref,
573
+ className: cn("flex flex-col", compact ? "gap-3" : "gap-1", className),
574
+ ...props,
575
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
576
+ className: cn("text-sm text-muted-foreground", compact && "font-semibold"),
577
+ children: label
578
+ }), tone === void 0 ? figure : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
579
+ className: "flex items-center gap-2.5",
580
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
581
+ "aria-hidden": "true",
582
+ "data-stat-tone": tone,
583
+ className: cn("size-2.5 shrink-0 rounded-full", STAT_TONE_DOT[tone])
584
+ }), figure]
585
+ })]
586
+ });
587
+ });
570
588
  Stat.displayName = "Stat";
571
589
  /**
572
590
  * Alert Component - Design System Specification
@@ -6582,6 +6600,34 @@ function useActiveShortcuts() {
6582
6600
  const manager = useShortcutManager();
6583
6601
  return react.useSyncExternalStore(manager.subscribe, manager.activeBindings, manager.activeBindings);
6584
6602
  }
6603
+ // src/components/field-row.tsx
6604
+ /**
6605
+ * The two-column settings row: label and help on the left, the control on the
6606
+ * right, stacking into one column on a narrow screen.
6607
+ *
6608
+ * Geometry only. It owns the grid and nothing about naming, so the rows that
6609
+ * differ in how they label their control — `FieldShell`'s row layout, and the
6610
+ * admin's form-bound and grouped settings rows — all draw this one grid rather
6611
+ * than three copies of it that could drift apart.
6612
+ *
6613
+ * It applies no vertical padding: `FormSection` sets the rhythm between its
6614
+ * rows, and a row that padded itself as well would double it.
6615
+ * @experimental
6616
+ */
6617
+ function FieldRow({ aside, children, className, ...props }) {
6618
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6619
+ "data-slot": "field-row",
6620
+ className: cn("grid grid-cols-1 md:grid-cols-[2fr_3fr] gap-4 md:gap-8 items-start", className),
6621
+ ...props,
6622
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6623
+ className: "flex flex-col",
6624
+ children: aside
6625
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6626
+ className: "w-full",
6627
+ children
6628
+ })]
6629
+ });
6630
+ }
6585
6631
  // src/components/field-shell.tsx
6586
6632
  /**
6587
6633
  * The width cap applies to a wrapper around the control, not to the field row.
@@ -6647,7 +6693,7 @@ function computeControlWiring(ownProps, requestedId, renderedMessageIds, hasErro
6647
6693
  };
6648
6694
  }
6649
6695
  /** @experimental */
6650
- function FieldShell({ label, description, error, width = "half", htmlFor, className, children }) {
6696
+ function FieldShell({ label, description, error, width, layout = "stacked", htmlFor, className, children }) {
6651
6697
  const generatedControlId = (0, react.useId)();
6652
6698
  const messageBaseId = (0, react.useId)();
6653
6699
  const descriptionId = `${messageBaseId}-description`;
@@ -6676,27 +6722,69 @@ function FieldShell({ label, description, error, width = "half", htmlFor, classN
6676
6722
  };
6677
6723
  control = isFragmentChild ? children : (0, react.cloneElement)(children, controlOverrides);
6678
6724
  }
6725
+ const parts = {
6726
+ label,
6727
+ description,
6728
+ error,
6729
+ controlId: wiring.id,
6730
+ descriptionId,
6731
+ errorId,
6732
+ width: width ?? (layout === "row" ? "fill" : "half"),
6733
+ className,
6734
+ control
6735
+ };
6736
+ return layout === "row" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowField, { ...parts }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StackedField, { ...parts });
6737
+ }
6738
+ /**
6739
+ * The settings row: the label and its help on the left, the control and any
6740
+ * error under it on the right. The grid itself is `FieldRow`'s, so this row and
6741
+ * the admin's own settings rows cannot disagree about it.
6742
+ */
6743
+ function RowField(parts) {
6744
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(FieldRow, {
6745
+ className: parts.className,
6746
+ aside: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [parts.label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
6747
+ htmlFor: parts.controlId,
6748
+ className: "cursor-pointer text-sm font-semibold text-foreground",
6749
+ children: parts.label
6750
+ }) : null, parts.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6751
+ id: parts.descriptionId,
6752
+ className: "mt-0.5 text-xs leading-relaxed text-muted-foreground",
6753
+ children: parts.description
6754
+ }) : null] }),
6755
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6756
+ className: controlWidth({ width: parts.width }),
6757
+ children: parts.control
6758
+ }), parts.error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6759
+ id: parts.errorId,
6760
+ className: "mt-1.5 text-sm font-medium text-destructive",
6761
+ children: parts.error
6762
+ }) : null]
6763
+ });
6764
+ }
6765
+ /** The stacked field: the label, then the control, its help and any error. */
6766
+ function StackedField(parts) {
6679
6767
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6680
- className: cn("flex flex-col gap-1.5", className),
6768
+ className: cn("flex flex-col gap-1.5", parts.className),
6681
6769
  children: [
6682
- label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
6683
- htmlFor: wiring.id,
6770
+ parts.label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
6771
+ htmlFor: parts.controlId,
6684
6772
  className: "text-sm font-medium text-foreground",
6685
- children: label
6773
+ children: parts.label
6686
6774
  }) : null,
6687
6775
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6688
- className: controlWidth({ width }),
6689
- children: control
6776
+ className: controlWidth({ width: parts.width }),
6777
+ children: parts.control
6690
6778
  }),
6691
- description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6692
- id: descriptionId,
6779
+ parts.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6780
+ id: parts.descriptionId,
6693
6781
  className: "text-sm text-muted-foreground",
6694
- children: description
6782
+ children: parts.description
6695
6783
  }) : null,
6696
- error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6697
- id: errorId,
6784
+ parts.error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6785
+ id: parts.errorId,
6698
6786
  className: "text-sm font-medium text-destructive",
6699
- children: error
6787
+ children: parts.error
6700
6788
  }) : null
6701
6789
  ]
6702
6790
  });
@@ -6746,13 +6834,13 @@ function FormSection({ label, description, className, children }) {
6746
6834
  * first as soon as either changed.
6747
6835
  * @experimental
6748
6836
  */
6749
- function FormActions({ dirty, className, children }) {
6837
+ function FormActions({ dirty, message = "You have unsaved changes", className, children }) {
6750
6838
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6751
6839
  className: cn("sticky bottom-0 mt-8 flex items-center justify-end gap-3", "border-t border-border bg-background/95 py-4 backdrop-blur", className),
6752
6840
  children: [dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6753
6841
  role: "status",
6754
6842
  className: "mr-auto text-sm text-muted-foreground",
6755
- children: "You have unsaved changes"
6843
+ children: message
6756
6844
  }) : null, children]
6757
6845
  });
6758
6846
  }
@@ -7008,14 +7096,33 @@ PageHeader.displayName = "PageHeader";
7008
7096
  * `PageTab`.
7009
7097
  * @experimental
7010
7098
  */
7011
- const PageTabs = (0, react.forwardRef)(({ label, className, children, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
7012
- ref,
7013
- "aria-label": label,
7014
- "data-slot": "page-tabs",
7015
- className: cn("flex gap-1 overflow-x-auto border-b border-border", className),
7016
- ...props,
7017
- children
7018
- }));
7099
+ const PageTabs = (0, react.forwardRef)(({ label, className, children, ...props }, ref) => {
7100
+ const row = (0, react.useRef)(null);
7101
+ const shown = (0, react.useRef)(null);
7102
+ const setRow = (0, react.useCallback)((node) => {
7103
+ row.current = node;
7104
+ if (typeof ref === "function") return ref(node);
7105
+ if (ref) ref.current = node;
7106
+ }, [ref]);
7107
+ (0, react.useEffect)(() => {
7108
+ const nav = row.current;
7109
+ const current = nav?.querySelector("[aria-current=\"page\"]") ?? null;
7110
+ if (nav === null || current === null || current === shown.current) return;
7111
+ shown.current = current;
7112
+ const bounds = nav.getBoundingClientRect();
7113
+ const tab = current.getBoundingClientRect();
7114
+ if (tab.left < bounds.left) nav.scrollLeft -= bounds.left - tab.left;
7115
+ else if (tab.right > bounds.right) nav.scrollLeft += tab.right - bounds.right;
7116
+ });
7117
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
7118
+ ref: setRow,
7119
+ "aria-label": label,
7120
+ "data-slot": "page-tabs",
7121
+ className: cn("flex gap-1 overflow-x-auto border-b border-border", className),
7122
+ ...props,
7123
+ children
7124
+ });
7125
+ });
7019
7126
  PageTabs.displayName = "PageTabs";
7020
7127
  /**
7021
7128
  * One section of a `PageTabs` row: a link, underlined when current.
@@ -7190,6 +7297,7 @@ exports.DropdownMenuSub = DropdownMenuSub;
7190
7297
  exports.DropdownMenuSubContent = DropdownMenuSubContent;
7191
7298
  exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
7192
7299
  exports.DropdownMenuTrigger = DropdownMenuTrigger;
7300
+ exports.FieldRow = FieldRow;
7193
7301
  exports.FieldShell = FieldShell;
7194
7302
  exports.FormActions = FormActions;
7195
7303
  exports.FormLabelWithTooltip = FormLabelWithTooltip;