@nivaro/react 0.3.80 → 0.3.81

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.
@@ -0,0 +1,120 @@
1
+ import { jsxs as o, jsx as s } from "react/jsx-runtime";
2
+ import { PenLine as h } from "lucide-react";
3
+ import { useState as p } from "react";
4
+ import { cn as g } from "../../lib/utils.js";
5
+ import { Popover as v, PopoverTrigger as $, PopoverContent as k } from "../ui/popover.js";
6
+ function S(r) {
7
+ if (!Array.isArray(r)) return [];
8
+ const t = [];
9
+ for (const n of r) {
10
+ const e = typeof n == "string" ? { field: n } : n;
11
+ !e || typeof e.field != "string" || !e.field || e.field.includes(".") || t.push({
12
+ field: e.field,
13
+ ...typeof e.label == "string" && e.label.trim() ? { label: e.label.trim() } : {},
14
+ admin_only: e.admin_only !== !1
15
+ });
16
+ }
17
+ return t;
18
+ }
19
+ function j({
20
+ label: r,
21
+ count: t,
22
+ scope: n,
23
+ commonValue: e,
24
+ disabled: b,
25
+ onApply: y
26
+ }) {
27
+ const [u, i] = p(!1), [a, f] = p(""), [m, x] = p(!1), d = n === "selected" ? `${t} selected` : `all ${t}`, c = t === 1 ? "line" : "lines";
28
+ return /* @__PURE__ */ o(
29
+ v,
30
+ {
31
+ open: u,
32
+ onOpenChange: (l) => {
33
+ i(l), l && f(e ?? "");
34
+ },
35
+ children: [
36
+ /* @__PURE__ */ s($, { asChild: !0, children: /* @__PURE__ */ o(
37
+ "button",
38
+ {
39
+ type: "button",
40
+ disabled: b || t === 0,
41
+ "data-grid-set-all": !0,
42
+ "data-tip": `Put one ${r} on ${d} ${c}, or clear it`,
43
+ className: g(
44
+ "inline-flex h-6 items-center gap-1 rounded border px-2 transition-colors disabled:opacity-50",
45
+ u ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-slate-300"
46
+ ),
47
+ children: [
48
+ /* @__PURE__ */ s(h, { className: "h-3 w-3", "aria-hidden": "true" }),
49
+ "Set ",
50
+ r,
51
+ "…"
52
+ ]
53
+ }
54
+ ) }),
55
+ /* @__PURE__ */ s(k, { align: "start", className: "w-[300px] space-y-2 p-3", children: /* @__PURE__ */ o(
56
+ "form",
57
+ {
58
+ className: "space-y-2",
59
+ onSubmit: async (l) => {
60
+ l.preventDefault(), x(!0);
61
+ try {
62
+ await y(a.trim() === "" ? null : a.trim()), i(!1);
63
+ } finally {
64
+ x(!1);
65
+ }
66
+ },
67
+ children: [
68
+ /* @__PURE__ */ o("label", { className: "block text-[12px] font-medium text-slate-700 dark:text-foreground", children: [
69
+ r,
70
+ " for ",
71
+ d,
72
+ " ",
73
+ c,
74
+ /* @__PURE__ */ s(
75
+ "input",
76
+ {
77
+ autoFocus: !0,
78
+ value: a,
79
+ onChange: (l) => f(l.target.value),
80
+ placeholder: `New ${r} — blank clears it`,
81
+ className: "mt-1 h-8 w-full rounded-md border border-slate-200 bg-background px-2 text-[12.5px] font-normal outline-none focus:border-nvr-cyan dark:border-border"
82
+ }
83
+ )
84
+ ] }),
85
+ /* @__PURE__ */ o("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
86
+ a.trim() === "" ? `Leaving it blank clears ${r} on ${d} ${c}.` : `Every ${n === "selected" ? "selected " : ""}line gets “${a.trim()}”.`,
87
+ " ",
88
+ "The grid’s rules and save mode apply as if typed on each line."
89
+ ] }),
90
+ /* @__PURE__ */ o("div", { className: "flex justify-end gap-2", children: [
91
+ /* @__PURE__ */ s(
92
+ "button",
93
+ {
94
+ type: "button",
95
+ onClick: () => i(!1),
96
+ className: "h-7 px-2 text-[12px] text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
97
+ children: "Cancel"
98
+ }
99
+ ),
100
+ /* @__PURE__ */ s(
101
+ "button",
102
+ {
103
+ type: "submit",
104
+ disabled: m,
105
+ className: "h-7 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white disabled:opacity-50",
106
+ children: m ? "Applying…" : a.trim() === "" ? `Clear on ${t}` : `Apply to ${t}`
107
+ }
108
+ )
109
+ ] })
110
+ ]
111
+ }
112
+ ) })
113
+ ]
114
+ }
115
+ );
116
+ }
117
+ export {
118
+ j as SetAllRowsButton,
119
+ S as normalizeSetAllRows
120
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.80",
3
+ "version": "0.3.81",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",