@nivaro/react 0.3.12 → 0.3.13

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,37 +1,37 @@
1
1
  import { jsxs as b, jsx as f } from "react/jsx-runtime";
2
2
  import { QueryClientContext as v, QueryClient as w, QueryClientProvider as g, useQueryClient as C } from "@tanstack/react-query";
3
3
  import { createContext as i, useContext as l, useState as m, useMemo as x, useCallback as h, useEffect as y } from "react";
4
- import { restoreMetadata as I, startMetadataPersistence as N } from "./lib/metadata-persist.js";
5
- import { isCoalesced as O, withGetCoalescing as P, releaseGatedReadsOnSharedFetch as S } from "./lib/request-gate.js";
6
- const F = i(null);
7
- function z() {
8
- return l(F);
4
+ import { restoreMetadata as S, startMetadataPersistence as I } from "./lib/metadata-persist.js";
5
+ import { isCoalesced as N, withGetCoalescing as O, releaseGatedReadsOnSharedFetch as P } from "./lib/request-gate.js";
6
+ const R = i(null);
7
+ function L() {
8
+ return l(R);
9
9
  }
10
10
  const p = i(null);
11
- function $({ identity: e }) {
11
+ function F({ identity: e }) {
12
12
  const t = C(), { userId: n, epoch: o, version: r } = e;
13
13
  return y(() => {
14
14
  let u = () => {
15
15
  }, c = !1;
16
- return I(t, { userId: n, epoch: o, version: r }).then(() => {
17
- c || (u = N(t, { userId: n, epoch: o, version: r }));
16
+ return S(t, { userId: n, epoch: o, version: r }).then(() => {
17
+ c || (u = I(t, { userId: n, epoch: o, version: r }));
18
18
  }), () => {
19
19
  c = !0, u();
20
20
  };
21
21
  }, [t, n, o, r]), null;
22
22
  }
23
23
  const d = /* @__PURE__ */ new WeakMap();
24
- function j() {
24
+ function $() {
25
25
  const e = C();
26
26
  return y(() => {
27
27
  const t = e.getQueryCache(), n = d.get(t);
28
- return n ? n.count++ : d.set(t, { count: 1, stop: S(t) }), () => {
28
+ return n ? n.count++ : d.set(t, { count: 1, stop: P(t) }), () => {
29
29
  const o = d.get(t);
30
30
  o && (o.count--, o.count <= 0 && (o.stop(), d.delete(t)));
31
31
  };
32
32
  }, [e]), null;
33
33
  }
34
- function L({
34
+ function K({
35
35
  client: e,
36
36
  children: t,
37
37
  batchReads: n = !1,
@@ -42,38 +42,38 @@ function L({
42
42
  defaultOptions: { queries: { retry: 1, refetchOnWindowFocus: !1 } }
43
43
  })
44
44
  ), c = x(
45
- () => O(e) ? e : P(e, { batchReads: n }),
45
+ () => N(e) ? e : O(e, { batchReads: n }),
46
46
  [e, n]
47
47
  ), s = /* @__PURE__ */ b(p.Provider, { value: { client: c }, children: [
48
- o ? /* @__PURE__ */ f($, { identity: o }) : null,
49
- typeof e.setOpen == "function" ? /* @__PURE__ */ f(j, {}) : null,
48
+ o ? /* @__PURE__ */ f(F, { identity: o }) : null,
49
+ typeof e.setOpen == "function" ? /* @__PURE__ */ f($, {}) : null,
50
50
  t
51
51
  ] });
52
52
  return r ? s : /* @__PURE__ */ f(g, { client: u, children: s });
53
53
  }
54
- function K() {
54
+ function X() {
55
55
  const e = l(p);
56
56
  if (!e) throw new Error("useNivaroClient must be used within <NivaroProvider>");
57
57
  return e.client;
58
58
  }
59
- function D() {
59
+ function j() {
60
60
  const e = l(p);
61
61
  return (e == null ? void 0 : e.client) ?? null;
62
62
  }
63
- function X() {
64
- const e = D(), t = e == null ? void 0 : e.getToken();
63
+ function Y() {
64
+ const e = j(), t = e == null ? void 0 : e.getToken();
65
65
  return {
66
66
  apiBase: e ? `${e.url}/api` : "/api",
67
67
  authHeaders: t ? { Authorization: `Bearer ${t}` } : {},
68
68
  credentials: t ? "omit" : "include"
69
69
  };
70
70
  }
71
- const R = i({
71
+ const D = i({
72
72
  isAdmin: !1,
73
73
  userId: ""
74
74
  });
75
- function Y() {
76
- return l(R);
75
+ function Z() {
76
+ return l(D);
77
77
  }
78
78
  function A(e) {
79
79
  const t = JSON.stringify(e), n = new TextEncoder().encode(t);
@@ -81,7 +81,7 @@ function A(e) {
81
81
  for (const r of n) o += String.fromCharCode(r);
82
82
  return encodeURIComponent(btoa(o));
83
83
  }
84
- function Z(e) {
84
+ function ee(e) {
85
85
  if (!e) return null;
86
86
  try {
87
87
  const t = atob(e.replace(/ /g, "+")), n = Uint8Array.from(t, (r) => r.charCodeAt(0)), o = JSON.parse(new TextDecoder().decode(n));
@@ -99,43 +99,46 @@ const Q = i({
99
99
  navigate: (e) => {
100
100
  window.location.href = e;
101
101
  }
102
- });
103
- function U() {
102
+ }), U = i({ active: !0 });
103
+ function te() {
104
+ return l(U);
105
+ }
106
+ function k() {
104
107
  return l(Q);
105
108
  }
106
- function k(e) {
109
+ function E(e) {
107
110
  const t = `/collections/${e.collection}/${e.itemId}`, n = [];
108
111
  e.layoutSlug && n.push(`layout=${encodeURIComponent(e.layoutSlug)}`), e.prefill && Object.keys(e.prefill).length && n.push(`prefill=${A(e.prefill)}`);
109
112
  for (const [o, r] of Object.entries(e.query ?? {}))
110
113
  n.push(`${encodeURIComponent(o)}=${encodeURIComponent(r)}`);
111
114
  return n.length ? `${t}?${n.join("&")}` : t;
112
115
  }
113
- function ee() {
114
- const e = U(), t = (o) => (e.itemUrl ?? k)(o);
116
+ function ne() {
117
+ const e = k(), t = (o) => (e.itemUrl ?? E)(o);
115
118
  return { urlFor: t, open: (o) => {
116
119
  var r;
117
120
  ((r = e.openItem) == null ? void 0 : r.call(e, o)) !== !0 && e.navigate(t(o));
118
121
  } };
119
122
  }
120
- const E = i(null);
121
- function te() {
122
- return l(E);
123
- }
124
123
  const G = i(null);
125
- function ne() {
124
+ function oe() {
126
125
  return l(G);
127
126
  }
128
- const M = i({});
129
- function oe() {
127
+ const M = i(null);
128
+ function re() {
130
129
  return l(M);
131
130
  }
132
- const q = i(null);
133
- function re() {
131
+ const q = i({});
132
+ function le() {
134
133
  return l(q);
135
134
  }
136
135
  const H = i(null);
137
- function le(e) {
138
- const t = l(H), [n, o] = m([]), r = t ? t.get(e) ?? null : n[n.length - 1] ?? null, u = h(
136
+ function ie() {
137
+ return l(H);
138
+ }
139
+ const W = i(null);
140
+ function ue(e) {
141
+ const t = l(W), [n, o] = m([]), r = t ? t.get(e) ?? null : n[n.length - 1] ?? null, u = h(
139
142
  (s) => {
140
143
  t ? t.push(e, s) : o((a) => [...a, s]);
141
144
  },
@@ -148,39 +151,41 @@ function le(e) {
148
151
  );
149
152
  return { value: r, push: u, back: c };
150
153
  }
151
- function ie(e) {
154
+ function se(e) {
152
155
  var u;
153
156
  const t = (u = e._overrides) == null ? void 0 : u.drilldown, n = t && typeof t == "object" ? t : null, o = e.interface === "relation-path";
154
157
  return (n == null ? void 0 : n.enabled) ?? o ? { enabled: !0, layout_id: (n == null ? void 0 : n.layout_id) ?? null, width: (n == null ? void 0 : n.width) ?? null } : null;
155
158
  }
156
- const ue = i(null), W = i(null), se = () => l(W);
159
+ const ce = i(null), J = i(null), ae = () => l(J);
157
160
  export {
158
- q as DrilldownContext,
159
- M as DrilldownViewsContext,
160
- F as GridFlushContext,
161
- R as ItemEditAuthContext,
161
+ H as DrilldownContext,
162
+ q as DrilldownViewsContext,
163
+ R as GridFlushContext,
164
+ D as ItemEditAuthContext,
162
165
  Q as NavigationContext,
163
- L as NivaroProvider,
164
- H as OverlayHistoryContext,
165
- E as ParentDraftContext,
166
- G as ReimportHandlerContext,
167
- ue as RelationPathDataContext,
168
- W as StaleFieldReportContext,
169
- Z as decodePrefill,
170
- k as defaultItemUrl,
166
+ K as NivaroProvider,
167
+ W as OverlayHistoryContext,
168
+ G as ParentDraftContext,
169
+ U as RecordSurfaceContext,
170
+ M as ReimportHandlerContext,
171
+ ce as RelationPathDataContext,
172
+ J as StaleFieldReportContext,
173
+ ee as decodePrefill,
174
+ E as defaultItemUrl,
171
175
  A as encodePrefill,
172
- ie as fieldDrilldownConfig,
173
- X as useApiFetchConfig,
174
- re as useDrilldown,
175
- oe as useDrilldownViews,
176
- z as useGridFlush,
177
- Y as useItemEditAuth,
178
- ee as useItemNavigation,
179
- U as useNavigation,
180
- K as useNivaroClient,
181
- D as useOptionalNivaroClient,
182
- le as useOverlayState,
183
- te as useParentDraft,
184
- ne as useReimportHandler,
185
- se as useStaleFieldReporter
176
+ se as fieldDrilldownConfig,
177
+ Y as useApiFetchConfig,
178
+ ie as useDrilldown,
179
+ le as useDrilldownViews,
180
+ L as useGridFlush,
181
+ Z as useItemEditAuth,
182
+ ne as useItemNavigation,
183
+ k as useNavigation,
184
+ X as useNivaroClient,
185
+ j as useOptionalNivaroClient,
186
+ ue as useOverlayState,
187
+ oe as useParentDraft,
188
+ te as useRecordSurface,
189
+ re as useReimportHandler,
190
+ ae as useStaleFieldReporter
186
191
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",