@nivaro/react 0.3.30 → 0.3.31

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.
@@ -1,30 +1,30 @@
1
- import { jsx as i, Fragment as w, jsxs as f } from "react/jsx-runtime";
2
- import { useQuery as v, useQueryClient as q, useMutation as R } from "@tanstack/react-query";
1
+ import { jsx as i, Fragment as x, jsxs as f } from "react/jsx-runtime";
2
+ import { useQuery as w, useQueryClient as q, useMutation as R } from "@tanstack/react-query";
3
3
  import { Play as C, Pause as N, Zap as $ } from "lucide-react";
4
- import { useMemo as b, useState as F } from "react";
4
+ import { useMemo as y, useState as F } from "react";
5
5
  import { toast as p } from "sonner";
6
- import { useNivaroClient as x } from "../../context.js";
7
- import { get as j, post as y } from "../../lib/commands.js";
6
+ import { useNivaroClient as v } from "../../context.js";
7
+ import { get as j, post as k } from "../../lib/commands.js";
8
8
  import { userErrorMessage as A } from "../../lib/safe-error.js";
9
9
  import { cn as S } from "../../lib/utils.js";
10
10
  import { useAvailableBulkActions as B, guardMatches as P } from "../bulk/BulkActionButtons.js";
11
- import { Button as k } from "../ui/button.js";
11
+ import { Button as b } from "../ui/button.js";
12
12
  import { Dialog as T, DialogContent as D, DialogHeader as H, DialogTitle as M, DialogDescription as Q, DialogBody as _, DialogFooter as E } from "../ui/dialog.js";
13
13
  import { Textarea as J } from "../ui/textarea.js";
14
14
  import { invalidateRecordQueries as K } from "./RecordLiveSync.js";
15
15
  function ie(e, n, t) {
16
- const h = x(), m = !!n && n !== "new", { data: u } = B(m ? [e] : []), d = b(
16
+ const h = v(), m = !!n && n !== "new", { data: u } = B(m ? [e] : []), d = y(
17
17
  () => ((u == null ? void 0 : u[e]) ?? []).filter(
18
18
  (o) => o.header === !0 && (o.kind === "update_fields" || o.kind === "transition")
19
19
  ),
20
20
  [u, e]
21
- ), s = b(() => {
21
+ ), s = y(() => {
22
22
  const o = /* @__PURE__ */ new Set();
23
23
  for (const a of d)
24
24
  for (const r of a.guard ?? [])
25
25
  r && typeof r.field == "string" && !(t && r.field in t) && o.add(r.field);
26
26
  return [...o].sort();
27
- }, [d, t]), { data: l } = v({
27
+ }, [d, t]), { data: l } = w({
28
28
  queryKey: ["record-header-action-guard", e, String(n), s.join(",")],
29
29
  queryFn: () => h.request(
30
30
  j(`/items/${encodeURIComponent(e)}/${encodeURIComponent(String(n))}`, {
@@ -34,7 +34,7 @@ function ie(e, n, t) {
34
34
  enabled: m && s.length > 0,
35
35
  staleTime: 0
36
36
  });
37
- return b(() => {
37
+ return y(() => {
38
38
  if (s.length > 0 && !l) return d.filter((a) => {
39
39
  var r;
40
40
  return !((r = a.guard) != null && r.length);
@@ -54,23 +54,28 @@ function ae({
54
54
  actions: e,
55
55
  onPick: n
56
56
  }) {
57
- return e.length === 0 ? null : /* @__PURE__ */ i(w, { children: e.map((t) => /* @__PURE__ */ f(
58
- "button",
59
- {
60
- type: "button",
61
- "data-record-header-action": t.key,
62
- "data-tip": W(t),
63
- onClick: () => n(t),
64
- className: S(
65
- "inline-flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md border px-3 text-[13px] font-medium shadow-sm transition-colors",
66
- t.variant === "danger" ? "border-red-300 text-red-600 hover:bg-red-50 dark:border-red-500/40 dark:text-red-400 dark:hover:bg-red-500/10" : "border-slate-300 bg-background text-slate-700 hover:bg-accent dark:border-border dark:text-slate-200"
67
- ),
68
- children: [
69
- U(t),
70
- t.label
71
- ]
72
- },
73
- `${t.source}:${t.key}`
57
+ return e.length === 0 ? null : /* @__PURE__ */ i(x, { children: e.map((t) => (
58
+ // Same Button, size and type as the pipeline's transition buttons beside them.
59
+ /* @__PURE__ */ f(
60
+ b,
61
+ {
62
+ type: "button",
63
+ size: "sm",
64
+ variant: "outline",
65
+ "data-record-header-action": t.key,
66
+ "data-tip": W(t),
67
+ onClick: () => n(t),
68
+ className: S(
69
+ "shrink-0 gap-1.5 text-[12px]",
70
+ t.variant === "danger" && "border-red-300 text-red-600 hover:bg-red-50 hover:text-red-700 dark:border-red-500/40 dark:text-red-400 dark:hover:bg-red-500/10"
71
+ ),
72
+ children: [
73
+ U(t),
74
+ t.label
75
+ ]
76
+ },
77
+ `${t.source}:${t.key}`
78
+ )
74
79
  )) });
75
80
  }
76
81
  function se({
@@ -80,9 +85,9 @@ function se({
80
85
  onClose: h,
81
86
  onDone: m
82
87
  }) {
83
- const u = x(), d = q(), [s, l] = F(""), o = !!(e != null && e.require_reason), a = R({
88
+ const u = v(), d = q(), [s, l] = F(""), o = !!(e != null && e.require_reason), a = R({
84
89
  mutationFn: async (r) => {
85
- const c = { collection: n, ids: [t], reason: s.trim() || null }, g = r.source === "db" ? await u.request(y("/bulk-actions/run", { ...c, key: r.key })) : await u.request(y(`/bulk-actions/${r.key}/execute`, c));
90
+ const c = { collection: n, ids: [t], reason: s.trim() || null }, g = r.source === "db" ? await u.request(k("/bulk-actions/run", { ...c, key: r.key })) : await u.request(k(`/bulk-actions/${r.key}/execute`, c));
86
91
  return { a: r, result: g.data ?? {} };
87
92
  },
88
93
  onSuccess: ({ a: r, result: c }) => {
@@ -118,9 +123,9 @@ function se({
118
123
  )
119
124
  ] }),
120
125
  /* @__PURE__ */ f(E, { children: [
121
- /* @__PURE__ */ i(k, { variant: "outline", onClick: h, disabled: a.isPending, children: "Cancel" }),
126
+ /* @__PURE__ */ i(b, { variant: "outline", onClick: h, disabled: a.isPending, children: "Cancel" }),
122
127
  /* @__PURE__ */ i(
123
- k,
128
+ b,
124
129
  {
125
130
  onClick: () => e && a.mutate(e),
126
131
  disabled: !e || a.isPending || o && !s.trim(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.30",
3
+ "version": "0.3.31",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",