@hanzo/ui 8.0.21 → 8.0.23
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/ThemeToggleNext-AEDLHX5X.js +5 -0
- package/dist/{ThemeToggleNext-OMBC67MO.js.map → ThemeToggleNext-AEDLHX5X.js.map} +1 -1
- package/dist/ThemeToggleNext-N6ASYJ6J.cjs +20 -0
- package/dist/{ThemeToggleNext-LI3SBFW7.cjs.map → ThemeToggleNext-N6ASYJ6J.cjs.map} +1 -1
- package/dist/chunk-2BM42AZR.cjs +2301 -0
- package/dist/chunk-2BM42AZR.cjs.map +1 -0
- package/dist/{chunk-T3UAC7ZZ.js → chunk-77AMCLN4.js} +4 -4
- package/dist/{chunk-T3UAC7ZZ.js.map → chunk-77AMCLN4.js.map} +1 -1
- package/dist/chunk-7P7R7FC5.js +2231 -0
- package/dist/chunk-7P7R7FC5.js.map +1 -0
- package/dist/{chunk-57YEM34R.cjs → chunk-7XDEUEWI.cjs} +11 -2
- package/dist/chunk-7XDEUEWI.cjs.map +1 -0
- package/dist/{chunk-J3P63OX6.cjs → chunk-ARV3P4CE.cjs} +5 -5
- package/dist/{chunk-J3P63OX6.cjs.map → chunk-ARV3P4CE.cjs.map} +1 -1
- package/dist/{chunk-P6IHE2O3.js → chunk-FVQXROBK.js} +11 -3
- package/dist/chunk-FVQXROBK.js.map +1 -0
- package/dist/{chunk-WN3YJYGQ.cjs → chunk-NBZDIMP3.cjs} +11 -11
- package/dist/chunk-NBZDIMP3.cjs.map +1 -0
- package/dist/{chunk-WW6C6EHS.js → chunk-P2P6ST6J.js} +4 -4
- package/dist/chunk-P2P6ST6J.js.map +1 -0
- package/dist/framework/CollectionsBrowser.d.ts +44 -0
- package/dist/framework/DocTypeDetail.d.ts +13 -0
- package/dist/framework/DocTypeRecords.d.ts +43 -0
- package/dist/framework/Loader.d.ts +4 -0
- package/dist/framework/client.d.ts +87 -0
- package/dist/framework/data.d.ts +18 -0
- package/dist/framework/fields.d.ts +75 -0
- package/dist/framework/index.d.ts +23 -0
- package/dist/framework/types.d.ts +81 -0
- package/dist/framework.cjs +757 -0
- package/dist/framework.cjs.map +1 -0
- package/dist/framework.d.ts +1 -0
- package/dist/framework.js +727 -0
- package/dist/framework.js.map +1 -0
- package/dist/product/index.cjs +323 -2340
- package/dist/product/index.cjs.map +1 -1
- package/dist/product/index.js +4 -2231
- package/dist/product/index.js.map +1 -1
- package/dist/product/instrument.d.ts +6 -0
- package/dist/product/social/index.cjs +16 -16
- package/dist/product/social/index.js +2 -2
- package/package.json +7 -1
- package/dist/ThemeToggleNext-LI3SBFW7.cjs +0 -20
- package/dist/ThemeToggleNext-OMBC67MO.js +0 -5
- package/dist/chunk-57YEM34R.cjs.map +0 -1
- package/dist/chunk-P6IHE2O3.js.map +0 -1
- package/dist/chunk-WN3YJYGQ.cjs.map +0 -1
- package/dist/chunk-WW6C6EHS.js.map +0 -1
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { HanzoMark } from './chunk-7P7R7FC5.js';
|
|
3
|
+
import './chunk-77AMCLN4.js';
|
|
4
|
+
import { classifyBackend, PageHeader, BackendStateCard, PrimaryButton, EmptyState } from './chunk-P2P6ST6J.js';
|
|
5
|
+
import './chunk-FVQXROBK.js';
|
|
6
|
+
import './chunk-ZGTJCJ55.js';
|
|
7
|
+
import { YStack, Text, Card, XStack, Button } from '@hanzo/gui';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
10
|
+
import { Plus, TriangleAlert, Boxes, X, Save, Trash2, Ban, Send, PenOff, Globe, Pencil, ArrowLeft, RefreshCw } from '@hanzogui/lucide-icons-2';
|
|
11
|
+
import { RecordsView, RecordForm, RecordDetail } from '@hanzo/data';
|
|
12
|
+
|
|
13
|
+
// src/framework/types.ts
|
|
14
|
+
var REDACTED_MARKER = "__set__";
|
|
15
|
+
|
|
16
|
+
// src/framework/fields.ts
|
|
17
|
+
var TYPE_MAP = {
|
|
18
|
+
Data: "text",
|
|
19
|
+
SmallText: "text",
|
|
20
|
+
Text: "longText",
|
|
21
|
+
LongText: "longText",
|
|
22
|
+
RichText: "richText",
|
|
23
|
+
Int: "number",
|
|
24
|
+
Float: "number",
|
|
25
|
+
Currency: "currency",
|
|
26
|
+
Check: "boolean",
|
|
27
|
+
Date: "date",
|
|
28
|
+
Datetime: "dateTime",
|
|
29
|
+
Select: "select",
|
|
30
|
+
Link: "relation",
|
|
31
|
+
Table: "json",
|
|
32
|
+
Attach: "url",
|
|
33
|
+
JSON: "json",
|
|
34
|
+
Password: "text"
|
|
35
|
+
};
|
|
36
|
+
var ACRONYMS = /* @__PURE__ */ new Set(["id", "url", "seo", "api", "ip"]);
|
|
37
|
+
function humanize(name) {
|
|
38
|
+
return name.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().split(/\s+/).filter(Boolean).map((w) => ACRONYMS.has(w.toLowerCase()) ? w.toUpperCase() : w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
39
|
+
}
|
|
40
|
+
function selectOptions(options) {
|
|
41
|
+
return (options ?? "").split("\n").map((s) => s.replace(/\r$/, "").trim()).filter(Boolean).map((v) => ({ value: v, label: v }));
|
|
42
|
+
}
|
|
43
|
+
function metadataFor(f) {
|
|
44
|
+
switch (f.fieldtype) {
|
|
45
|
+
case "Select":
|
|
46
|
+
return { options: selectOptions(f.options) };
|
|
47
|
+
case "Currency":
|
|
48
|
+
return { currencyCode: "USD" };
|
|
49
|
+
case "Int":
|
|
50
|
+
return { decimals: 0 };
|
|
51
|
+
case "Link":
|
|
52
|
+
return { objectName: f.options };
|
|
53
|
+
default:
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function autonameSource(dt) {
|
|
58
|
+
const a = (dt.autoname ?? "").trim();
|
|
59
|
+
return a.startsWith("field:") ? a.slice("field:".length).trim() : "";
|
|
60
|
+
}
|
|
61
|
+
function docTypeToFields(dt, opts = {}) {
|
|
62
|
+
const src = autonameSource(dt);
|
|
63
|
+
return (dt.fields ?? []).filter((f) => !f.hidden).map((f) => {
|
|
64
|
+
const readOnly = f.readOnly || opts.editing && f.fieldname === src || void 0;
|
|
65
|
+
const metadata = metadataFor(f);
|
|
66
|
+
return {
|
|
67
|
+
name: f.fieldname,
|
|
68
|
+
label: f.label || humanize(f.fieldname),
|
|
69
|
+
type: TYPE_MAP[f.fieldtype] ?? "text",
|
|
70
|
+
...metadata ? { metadata } : {},
|
|
71
|
+
...readOnly ? { readOnly: true } : {}
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function statusField(dt) {
|
|
76
|
+
const f = (dt.fields ?? []).find(
|
|
77
|
+
(x) => x.fieldtype === "Select" && x.fieldname === "status" && (x.options ?? "").includes("Published")
|
|
78
|
+
);
|
|
79
|
+
return f ? f.fieldname : "";
|
|
80
|
+
}
|
|
81
|
+
function listHiddenFields(dt) {
|
|
82
|
+
const anyListed = (dt.fields ?? []).some((f) => f.inListView);
|
|
83
|
+
if (!anyListed) return [];
|
|
84
|
+
return (dt.fields ?? []).filter((f) => !f.inListView && !f.hidden).map((f) => f.fieldname);
|
|
85
|
+
}
|
|
86
|
+
function isMediaDoctype(dt) {
|
|
87
|
+
return (dt.fields ?? []).some((f) => f.fieldtype === "Attach" && f.reqd);
|
|
88
|
+
}
|
|
89
|
+
function mediaFileField(dt) {
|
|
90
|
+
const f = (dt.fields ?? []).find((x) => x.fieldtype === "Attach" && x.reqd) ?? (dt.fields ?? []).find((x) => x.fieldtype === "Attach");
|
|
91
|
+
return f ? f.fieldname : "";
|
|
92
|
+
}
|
|
93
|
+
function moduleDoctypes(dts, module) {
|
|
94
|
+
return dts.filter((dt) => (dt.module ?? "") === module);
|
|
95
|
+
}
|
|
96
|
+
var PROJECT_FIELD = "project";
|
|
97
|
+
function hasProjectField(dt) {
|
|
98
|
+
return (dt.fields ?? []).some((f) => f.fieldname === PROJECT_FIELD);
|
|
99
|
+
}
|
|
100
|
+
function titleOf(doc, dt) {
|
|
101
|
+
if (dt.titleField && typeof doc[dt.titleField] === "string" && doc[dt.titleField]) return String(doc[dt.titleField]);
|
|
102
|
+
return typeof doc.name === "string" && doc.name ? doc.name : "(untitled)";
|
|
103
|
+
}
|
|
104
|
+
function slugify(s) {
|
|
105
|
+
return String(s ?? "").normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
106
|
+
}
|
|
107
|
+
function isValidDoctypeName(name) {
|
|
108
|
+
return /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(name.trim());
|
|
109
|
+
}
|
|
110
|
+
var secToMs = (v) => {
|
|
111
|
+
const n = Number(v);
|
|
112
|
+
return Number.isFinite(n) && n > 0 ? n * 1e3 : void 0;
|
|
113
|
+
};
|
|
114
|
+
var numOrNull = (v) => {
|
|
115
|
+
const n = Number(v);
|
|
116
|
+
return Number.isFinite(n) ? n : null;
|
|
117
|
+
};
|
|
118
|
+
function coerceForDisplay(f, v) {
|
|
119
|
+
switch (f.fieldtype) {
|
|
120
|
+
case "Currency":
|
|
121
|
+
return { amount: numOrNull(v), currencyCode: "USD" };
|
|
122
|
+
case "Check":
|
|
123
|
+
return v === 1 || v === true || v === "1";
|
|
124
|
+
case "Datetime":
|
|
125
|
+
return typeof v === "string" ? v.replace(" ", "T") : v;
|
|
126
|
+
case "Password":
|
|
127
|
+
return v === REDACTED_MARKER ? "" : v;
|
|
128
|
+
// never surface the marker
|
|
129
|
+
default:
|
|
130
|
+
return v;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function toRecord(doc, dt) {
|
|
134
|
+
const rec = {
|
|
135
|
+
id: doc.name,
|
|
136
|
+
name: doc.name,
|
|
137
|
+
doctype: doc.doctype,
|
|
138
|
+
docstatus: doc.docstatus,
|
|
139
|
+
createdAt: secToMs(doc.createdAt),
|
|
140
|
+
updatedAt: secToMs(doc.updatedAt)
|
|
141
|
+
};
|
|
142
|
+
for (const f of dt.fields ?? []) {
|
|
143
|
+
if (!(f.fieldname in doc)) continue;
|
|
144
|
+
rec[f.fieldname] = coerceForDisplay(f, doc[f.fieldname]);
|
|
145
|
+
}
|
|
146
|
+
return rec;
|
|
147
|
+
}
|
|
148
|
+
function coerceForWrite(f, v) {
|
|
149
|
+
switch (f.fieldtype) {
|
|
150
|
+
case "Currency":
|
|
151
|
+
return v && typeof v === "object" && "amount" in v ? Number(v.amount) : Number(v);
|
|
152
|
+
case "Check":
|
|
153
|
+
return Boolean(v);
|
|
154
|
+
case "Int":
|
|
155
|
+
case "Float":
|
|
156
|
+
return Number(v);
|
|
157
|
+
case "Datetime":
|
|
158
|
+
if (v instanceof Date) return v.toISOString();
|
|
159
|
+
if (typeof v === "number" && Number.isFinite(v)) return new Date(v).toISOString();
|
|
160
|
+
return v;
|
|
161
|
+
case "Link":
|
|
162
|
+
if (v == null || v === "") return "";
|
|
163
|
+
if (typeof v === "object") return String(v.id ?? v.value ?? "");
|
|
164
|
+
return v;
|
|
165
|
+
default:
|
|
166
|
+
return v;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function enrichLinks(record, dt, optionsByField) {
|
|
170
|
+
const out = { ...record };
|
|
171
|
+
for (const f of dt.fields ?? []) {
|
|
172
|
+
if (f.fieldtype !== "Link") continue;
|
|
173
|
+
const raw = out[f.fieldname];
|
|
174
|
+
if (typeof raw === "string" && raw) {
|
|
175
|
+
const opt = (optionsByField[f.fieldname] ?? []).find((o) => o.value === raw);
|
|
176
|
+
out[f.fieldname] = { id: raw, label: opt?.label ?? raw };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
function linkFields(dt) {
|
|
182
|
+
return (dt.fields ?? []).filter((f) => f.fieldtype === "Link");
|
|
183
|
+
}
|
|
184
|
+
function newDraft(dt) {
|
|
185
|
+
const out = {};
|
|
186
|
+
for (const f of dt.fields ?? []) {
|
|
187
|
+
if (f.default === void 0 || f.default === "") continue;
|
|
188
|
+
out[f.fieldname] = f.fieldtype === "Check" ? f.default === "1" || f.default === "true" : f.default;
|
|
189
|
+
}
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
function savePayload(draft, dt) {
|
|
193
|
+
const src = autonameSource(dt);
|
|
194
|
+
const out = {};
|
|
195
|
+
for (const f of dt.fields ?? []) {
|
|
196
|
+
if (f.readOnly) continue;
|
|
197
|
+
let v = draft[f.fieldname];
|
|
198
|
+
if (v === void 0) continue;
|
|
199
|
+
v = coerceForWrite(f, v);
|
|
200
|
+
if (f.fieldname === src && typeof v === "string") v = slugify(v);
|
|
201
|
+
out[f.fieldname] = v;
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/framework/client.ts
|
|
207
|
+
var enc = encodeURIComponent;
|
|
208
|
+
var asRecord = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
209
|
+
function rows(payload) {
|
|
210
|
+
if (Array.isArray(payload)) return payload.filter((x) => x && typeof x === "object");
|
|
211
|
+
const o = asRecord(payload);
|
|
212
|
+
for (const k of ["data", "items", "rows"]) {
|
|
213
|
+
if (Array.isArray(o[k])) return o[k].filter((x) => x && typeof x === "object");
|
|
214
|
+
}
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
var asDoc = (v) => asRecord(v);
|
|
218
|
+
var asDocType = (v) => {
|
|
219
|
+
const r = asRecord(v);
|
|
220
|
+
return { ...r, name: String(r.name ?? ""), fields: Array.isArray(r.fields) ? r.fields : [] };
|
|
221
|
+
};
|
|
222
|
+
function listQuery(q) {
|
|
223
|
+
if (!q) return "";
|
|
224
|
+
const p = new URLSearchParams();
|
|
225
|
+
if (q.filters && Object.keys(q.filters).length) p.set("filters", JSON.stringify(q.filters));
|
|
226
|
+
if (q.fields && q.fields.length) p.set("fields", q.fields.join(","));
|
|
227
|
+
if (q.orderBy) p.set("order_by", q.orderBy);
|
|
228
|
+
if (q.limit) p.set("limit", String(q.limit));
|
|
229
|
+
const s = p.toString();
|
|
230
|
+
return s ? `?${s}` : "";
|
|
231
|
+
}
|
|
232
|
+
function createFrameworkClient(t) {
|
|
233
|
+
return {
|
|
234
|
+
/** The DocType registry (schemas) — the collection definitions of every app lane. */
|
|
235
|
+
doctypes: {
|
|
236
|
+
list: () => t.get("doctypes").then((r) => rows(r).map(asDocType)),
|
|
237
|
+
get: (name) => t.get(`doctypes/${enc(name)}`).then(asDocType),
|
|
238
|
+
create: (dt) => t.post("doctypes", dt).then(asDocType),
|
|
239
|
+
update: (name, dt) => t.put(`doctypes/${enc(name)}`, dt).then(asDocType),
|
|
240
|
+
remove: (name) => t.del(`doctypes/${enc(name)}`)
|
|
241
|
+
},
|
|
242
|
+
/** Generic, metadata-driven document CRUD — the SAME calls for ANY doctype. */
|
|
243
|
+
records: {
|
|
244
|
+
list: (doctype, q) => t.get(`${enc(doctype)}${listQuery(q)}`).then((r) => rows(r).map(asDoc)),
|
|
245
|
+
get: (doctype, name) => t.get(`${enc(doctype)}/${enc(name)}`).then(asDoc),
|
|
246
|
+
create: (doctype, data) => t.post(enc(doctype), data).then(asDoc),
|
|
247
|
+
update: (doctype, name, data) => t.put(`${enc(doctype)}/${enc(name)}`, data).then(asDoc),
|
|
248
|
+
remove: (doctype, name) => t.del(`${enc(doctype)}/${enc(name)}`),
|
|
249
|
+
submit: (doctype, name) => t.post(`${enc(doctype)}/${enc(name)}/submit`).then(asDoc),
|
|
250
|
+
cancel: (doctype, name) => t.post(`${enc(doctype)}/${enc(name)}/cancel`).then(asDoc)
|
|
251
|
+
},
|
|
252
|
+
/** App-lane fixtures: list the registered lanes, inspect one, install into the org. */
|
|
253
|
+
modules: {
|
|
254
|
+
list: () => t.get("modules").then(
|
|
255
|
+
(r) => rows(r).map((m) => ({
|
|
256
|
+
module: String(m.module ?? ""),
|
|
257
|
+
doctypes: Array.isArray(m.doctypes) ? m.doctypes : []
|
|
258
|
+
}))
|
|
259
|
+
),
|
|
260
|
+
get: (module) => t.get(`modules/${enc(module)}`).then((v) => {
|
|
261
|
+
const r = asRecord(v);
|
|
262
|
+
return {
|
|
263
|
+
module: String(r.module ?? module),
|
|
264
|
+
doctypes: Array.isArray(r.doctypes) ? r.doctypes : [],
|
|
265
|
+
installed: Array.isArray(r.installed) ? r.installed : []
|
|
266
|
+
};
|
|
267
|
+
}),
|
|
268
|
+
install: (module) => t.post(`modules/${enc(module)}/install`).then((v) => {
|
|
269
|
+
const r = asRecord(v);
|
|
270
|
+
return {
|
|
271
|
+
module: String(r.module ?? module),
|
|
272
|
+
created: Array.isArray(r.created) ? r.created : [],
|
|
273
|
+
existing: Array.isArray(r.existing) ? r.existing : []
|
|
274
|
+
};
|
|
275
|
+
})
|
|
276
|
+
},
|
|
277
|
+
/** Per-org role assignments (grant editors; the owner is seeded System Manager). */
|
|
278
|
+
roles: {
|
|
279
|
+
list: () => t.get("roles").then((r) => rows(r).map((x) => ({ user: String(x.user ?? ""), role: String(x.role ?? "") }))),
|
|
280
|
+
assign: (user, role) => t.post("roles", { user, role }).then(() => void 0),
|
|
281
|
+
revoke: (user, role) => t.del(`roles/${enc(user)}/${enc(role)}`)
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
var FrameworkHttpError = class extends Error {
|
|
286
|
+
constructor(status, message) {
|
|
287
|
+
super(message);
|
|
288
|
+
this.status = status;
|
|
289
|
+
this.name = "FrameworkHttpError";
|
|
290
|
+
}
|
|
291
|
+
status;
|
|
292
|
+
};
|
|
293
|
+
function fetchTransport(opts) {
|
|
294
|
+
const base = opts.baseUrl.replace(/\/+$/, "");
|
|
295
|
+
const doFetch = opts.fetchImpl ?? ((...a) => fetch(...a));
|
|
296
|
+
async function req(method, path, body) {
|
|
297
|
+
const tok = opts.token?.();
|
|
298
|
+
const res = await doFetch(`${base}/${path}`, {
|
|
299
|
+
method,
|
|
300
|
+
headers: {
|
|
301
|
+
Accept: "application/json",
|
|
302
|
+
...body === void 0 ? null : { "Content-Type": "application/json" },
|
|
303
|
+
...tok ? { Authorization: `Bearer ${tok}` } : null
|
|
304
|
+
},
|
|
305
|
+
...body === void 0 ? null : { body: JSON.stringify(body) }
|
|
306
|
+
});
|
|
307
|
+
const text = await res.text();
|
|
308
|
+
let payload = null;
|
|
309
|
+
try {
|
|
310
|
+
payload = text ? JSON.parse(text) : null;
|
|
311
|
+
} catch {
|
|
312
|
+
payload = null;
|
|
313
|
+
}
|
|
314
|
+
if (!res.ok) {
|
|
315
|
+
const o = asRecord(payload);
|
|
316
|
+
const said = [o.error, o.msg, o.message].find((v) => typeof v === "string" && v.trim() !== "");
|
|
317
|
+
throw new FrameworkHttpError(res.status, typeof said === "string" ? said : `HTTP ${res.status}`);
|
|
318
|
+
}
|
|
319
|
+
return payload;
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
get: (p) => req("GET", p),
|
|
323
|
+
post: (p, b) => req("POST", p, b),
|
|
324
|
+
put: (p, b) => req("PUT", p, b),
|
|
325
|
+
del: (p) => req("DELETE", p).then(() => void 0)
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/framework/data.ts
|
|
330
|
+
async function loadLinkOptions(client, dt) {
|
|
331
|
+
const links = linkFields(dt);
|
|
332
|
+
const out = {};
|
|
333
|
+
await Promise.all(
|
|
334
|
+
links.map(async (f) => {
|
|
335
|
+
const target = f.options;
|
|
336
|
+
if (!target) return;
|
|
337
|
+
const [tdt, docs] = await Promise.all([
|
|
338
|
+
client.doctypes.get(target).catch(() => null),
|
|
339
|
+
client.records.list(target, { limit: 200 }).catch(() => [])
|
|
340
|
+
]);
|
|
341
|
+
out[f.fieldname] = docs.map((d) => ({
|
|
342
|
+
value: String(d.name),
|
|
343
|
+
label: tdt ? titleOf(d, tdt) : String(d.name)
|
|
344
|
+
}));
|
|
345
|
+
})
|
|
346
|
+
);
|
|
347
|
+
return out;
|
|
348
|
+
}
|
|
349
|
+
function makeFieldOptions(linkOptions) {
|
|
350
|
+
return (field) => {
|
|
351
|
+
if (field.type === "relation") return linkOptions[field.name] ?? [];
|
|
352
|
+
if (field.type === "select" || field.type === "multiSelect") {
|
|
353
|
+
return field.metadata?.options;
|
|
354
|
+
}
|
|
355
|
+
return void 0;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function Loader({ label, size = 40 }) {
|
|
359
|
+
return /* @__PURE__ */ jsxs(YStack, { flex: 1, minH: 280, items: "center", justify: "center", gap: "$3", children: [
|
|
360
|
+
/* @__PURE__ */ jsx("style", { children: "@keyframes hz-pulse{0%,100%{opacity:.45}50%{opacity:1}}.hz-pulse{animation:hz-pulse 1.5s ease-in-out infinite;display:inline-flex}@media (prefers-reduced-motion:reduce){.hz-pulse{animation:none}}" }),
|
|
361
|
+
/* @__PURE__ */ jsx("div", { className: "hz-pulse", children: /* @__PURE__ */ jsx(HanzoMark, { size }) }),
|
|
362
|
+
label ? /* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$color11", children: label }) : null
|
|
363
|
+
] });
|
|
364
|
+
}
|
|
365
|
+
function CollectionsBrowser({ client, module, label, subtitle, onOpen, setupDescription, setupBullets, renderBuilder }) {
|
|
366
|
+
const [state, setState] = useState({ phase: "loading" });
|
|
367
|
+
const [busy, setBusy] = useState(false);
|
|
368
|
+
const [creating, setCreating] = useState(false);
|
|
369
|
+
const [actionError, setActionError] = useState(null);
|
|
370
|
+
const load = useCallback(
|
|
371
|
+
async (signal) => {
|
|
372
|
+
setState({ phase: "loading" });
|
|
373
|
+
try {
|
|
374
|
+
const [dts, mod] = await Promise.all([
|
|
375
|
+
client.doctypes.list(),
|
|
376
|
+
client.modules.get(module).catch(() => null)
|
|
377
|
+
// module may not be registered on older cloud
|
|
378
|
+
]);
|
|
379
|
+
if (signal.cancelled) return;
|
|
380
|
+
setState({ phase: "ready", collections: moduleDoctypes(dts, module), registered: Boolean(mod && mod.doctypes.length) });
|
|
381
|
+
} catch (e) {
|
|
382
|
+
if (!signal.cancelled) setState({ phase: "error", error: classifyBackend(e) });
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
[client, module]
|
|
386
|
+
);
|
|
387
|
+
useEffect(() => {
|
|
388
|
+
const signal = { cancelled: false };
|
|
389
|
+
void load(signal);
|
|
390
|
+
return () => {
|
|
391
|
+
signal.cancelled = true;
|
|
392
|
+
};
|
|
393
|
+
}, [load]);
|
|
394
|
+
const reload = useCallback(() => void load({ cancelled: false }), [load]);
|
|
395
|
+
const install = useCallback(async () => {
|
|
396
|
+
setBusy(true);
|
|
397
|
+
setActionError(null);
|
|
398
|
+
try {
|
|
399
|
+
await client.modules.install(module);
|
|
400
|
+
reload();
|
|
401
|
+
} catch (e) {
|
|
402
|
+
setActionError(classifyBackend(e).message);
|
|
403
|
+
} finally {
|
|
404
|
+
setBusy(false);
|
|
405
|
+
}
|
|
406
|
+
}, [client, module, reload]);
|
|
407
|
+
if (state.phase === "loading") return /* @__PURE__ */ jsx(Loader, { label: `Loading ${label}\u2026` });
|
|
408
|
+
if (state.phase === "error") {
|
|
409
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
410
|
+
/* @__PURE__ */ jsx(PageHeader, { title: label, subtitle }),
|
|
411
|
+
/* @__PURE__ */ jsx(BackendStateCard, { state: state.error, onRetry: reload, hint: "framework \xB7 GET /v1/framework/doctypes" })
|
|
412
|
+
] });
|
|
413
|
+
}
|
|
414
|
+
const { collections } = state;
|
|
415
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
416
|
+
/* @__PURE__ */ jsx(
|
|
417
|
+
PageHeader,
|
|
418
|
+
{
|
|
419
|
+
title: label,
|
|
420
|
+
subtitle,
|
|
421
|
+
actions: renderBuilder && collections.length && !creating ? /* @__PURE__ */ jsx(PrimaryButton, { size: "$2", icon: /* @__PURE__ */ jsx(Plus, { size: 15 }), onPress: () => {
|
|
422
|
+
setCreating(true);
|
|
423
|
+
setActionError(null);
|
|
424
|
+
}, children: "New collection" }) : void 0
|
|
425
|
+
}
|
|
426
|
+
),
|
|
427
|
+
actionError ? /* @__PURE__ */ jsx(Card, { borderWidth: 1, borderColor: "$red7", bg: "$red2", p: "$3", mb: "$3", maxWidth: 620, children: /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
|
|
428
|
+
/* @__PURE__ */ jsx(TriangleAlert, { size: 15 }),
|
|
429
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$red11", children: actionError })
|
|
430
|
+
] }) }) : null,
|
|
431
|
+
creating && renderBuilder ? /* @__PURE__ */ jsx(YStack, { mb: "$3", children: renderBuilder({
|
|
432
|
+
onSaved: (name) => {
|
|
433
|
+
setCreating(false);
|
|
434
|
+
onOpen(name);
|
|
435
|
+
},
|
|
436
|
+
onCancel: () => setCreating(false)
|
|
437
|
+
}) }) : null,
|
|
438
|
+
collections.length === 0 && !creating ? /* @__PURE__ */ jsx(
|
|
439
|
+
EmptyState,
|
|
440
|
+
{
|
|
441
|
+
icon: Boxes,
|
|
442
|
+
title: `Set up ${label}`,
|
|
443
|
+
description: setupDescription ?? `${label} is a set of content collections \u2014 Pages, Posts, Articles, Media, and Navigation \u2014 as DocTypes on the Hanzo Framework, per organization.`,
|
|
444
|
+
bullets: setupBullets ?? [
|
|
445
|
+
"Installs the default collections into your organization",
|
|
446
|
+
"Content is documents on the framework \u2014 versioned, permissioned, per-org",
|
|
447
|
+
"Add your own collections and fields any time"
|
|
448
|
+
],
|
|
449
|
+
primary: state.registered ? { label: busy ? "Setting up\u2026" : `Set up ${label}`, onPress: install } : void 0,
|
|
450
|
+
secondary: renderBuilder ? { label: "New collection", onPress: () => setCreating(true) } : void 0
|
|
451
|
+
}
|
|
452
|
+
) : !creating ? /* @__PURE__ */ jsx(XStack, { gap: "$3", flexWrap: "wrap", children: collections.map((dt) => /* @__PURE__ */ jsxs(
|
|
453
|
+
YStack,
|
|
454
|
+
{
|
|
455
|
+
onPress: () => onOpen(dt.name),
|
|
456
|
+
hoverStyle: { borderColor: "$color8" },
|
|
457
|
+
cursor: "pointer",
|
|
458
|
+
borderWidth: 1,
|
|
459
|
+
borderColor: "$borderColor",
|
|
460
|
+
rounded: "$4",
|
|
461
|
+
p: "$4",
|
|
462
|
+
gap: "$2",
|
|
463
|
+
width: 240,
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
|
|
466
|
+
/* @__PURE__ */ jsx(Boxes, { size: 16 }),
|
|
467
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "$4", fontWeight: "700", numberOfLines: 1, children: dt.name })
|
|
468
|
+
] }),
|
|
469
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: "$2", color: "$color10", children: [
|
|
470
|
+
dt.fields?.length ?? 0,
|
|
471
|
+
" field",
|
|
472
|
+
(dt.fields?.length ?? 0) === 1 ? "" : "s",
|
|
473
|
+
dt.isSubmittable ? " \xB7 submittable" : ""
|
|
474
|
+
] })
|
|
475
|
+
]
|
|
476
|
+
},
|
|
477
|
+
dt.name
|
|
478
|
+
)) }) : null
|
|
479
|
+
] });
|
|
480
|
+
}
|
|
481
|
+
function DocTypeRecords({ client, doctype, onOpen, onCreate, project, title, renderMedia }) {
|
|
482
|
+
const [state, setState] = useState({ phase: "loading" });
|
|
483
|
+
const [mutationError, setMutationError] = useState(null);
|
|
484
|
+
const load = useCallback(
|
|
485
|
+
async (signal) => {
|
|
486
|
+
setState({ phase: "loading" });
|
|
487
|
+
try {
|
|
488
|
+
const dt = await client.doctypes.get(doctype);
|
|
489
|
+
const linkOptions = await loadLinkOptions(client, dt);
|
|
490
|
+
const filters = project && hasProjectField(dt) ? { [PROJECT_FIELD]: project } : void 0;
|
|
491
|
+
const docs = await client.records.list(doctype, { limit: 200, ...filters ? { filters } : {} });
|
|
492
|
+
if (signal.cancelled) return;
|
|
493
|
+
const records = docs.map((d) => enrichLinks(toRecord(d, dt), dt, linkOptions));
|
|
494
|
+
setState({ phase: "ready", dt, fields: docTypeToFields(dt), docs, records, linkOptions });
|
|
495
|
+
} catch (e) {
|
|
496
|
+
if (!signal.cancelled) setState({ phase: "error", error: classifyBackend(e) });
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
[client, doctype, project]
|
|
500
|
+
);
|
|
501
|
+
useEffect(() => {
|
|
502
|
+
const signal = { cancelled: false };
|
|
503
|
+
void load(signal);
|
|
504
|
+
return () => {
|
|
505
|
+
signal.cancelled = true;
|
|
506
|
+
};
|
|
507
|
+
}, [load]);
|
|
508
|
+
const reload = useCallback(() => void load({ cancelled: false }), [load]);
|
|
509
|
+
const fieldOptions = useMemo(
|
|
510
|
+
() => state.phase === "ready" ? makeFieldOptions(state.linkOptions) : void 0,
|
|
511
|
+
[state]
|
|
512
|
+
);
|
|
513
|
+
const onEditCommit = useCallback(
|
|
514
|
+
async (record, field, value) => {
|
|
515
|
+
if (state.phase !== "ready") return;
|
|
516
|
+
const name = typeof record.name === "string" ? record.name : "";
|
|
517
|
+
if (!name) return;
|
|
518
|
+
setMutationError(null);
|
|
519
|
+
try {
|
|
520
|
+
const body = savePayload({ ...record, [field.name]: value }, state.dt);
|
|
521
|
+
const saved = await client.records.update(doctype, name, body);
|
|
522
|
+
const next = enrichLinks(toRecord(saved, state.dt), state.dt, state.linkOptions);
|
|
523
|
+
setState((s) => s.phase === "ready" ? { ...s, records: s.records.map((r) => r.name === name ? next : r) } : s);
|
|
524
|
+
} catch (e) {
|
|
525
|
+
setMutationError(classifyBackend(e).message);
|
|
526
|
+
throw e;
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
[client, doctype, state]
|
|
530
|
+
);
|
|
531
|
+
if (state.phase === "error") {
|
|
532
|
+
return /* @__PURE__ */ jsx(BackendStateCard, { state: state.error, onRetry: reload, hint: `framework \xB7 GET /v1/framework/${doctype}` });
|
|
533
|
+
}
|
|
534
|
+
const refresh = /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(RefreshCw, { size: 15 }), onPress: reload, children: "Refresh" });
|
|
535
|
+
if (renderMedia && state.phase === "ready" && isMediaDoctype(state.dt)) {
|
|
536
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderMedia({ dt: state.dt, docs: state.docs, onOpen, onChanged: reload, toolbarExtra: refresh }) });
|
|
537
|
+
}
|
|
538
|
+
const ready = state.phase === "ready" ? state : void 0;
|
|
539
|
+
return /* @__PURE__ */ jsx(
|
|
540
|
+
RecordsView,
|
|
541
|
+
{
|
|
542
|
+
title,
|
|
543
|
+
fields: ready?.fields ?? [],
|
|
544
|
+
records: ready?.records ?? [],
|
|
545
|
+
loading: state.phase === "loading",
|
|
546
|
+
onOpen: (r) => onOpen(String(r.name ?? r.id ?? "")),
|
|
547
|
+
onCreate,
|
|
548
|
+
createLabel: "New record",
|
|
549
|
+
onEditCommit,
|
|
550
|
+
fieldOptions,
|
|
551
|
+
toolbarExtra: refresh,
|
|
552
|
+
empty: mutationError ?? `No records in ${doctype} yet.`
|
|
553
|
+
}
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
function DocTypeDetail({ client, doctype, name, project, onBack, onView }) {
|
|
557
|
+
const isNew = name === "new";
|
|
558
|
+
const [state, setState] = useState({ phase: "loading" });
|
|
559
|
+
const [editing, setEditing] = useState(isNew);
|
|
560
|
+
const [draft, setDraft] = useState({});
|
|
561
|
+
const [busy, setBusy] = useState(false);
|
|
562
|
+
const [saveError, setSaveError] = useState(null);
|
|
563
|
+
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
564
|
+
const load = useCallback(
|
|
565
|
+
async (signal) => {
|
|
566
|
+
setState({ phase: "loading" });
|
|
567
|
+
try {
|
|
568
|
+
const dt2 = await client.doctypes.get(doctype);
|
|
569
|
+
const linkOptions = await loadLinkOptions(client, dt2);
|
|
570
|
+
const doc = isNew ? null : await client.records.get(doctype, name);
|
|
571
|
+
if (signal.cancelled) return;
|
|
572
|
+
const record2 = doc ? enrichLinks(toRecord(doc, dt2), dt2, linkOptions) : null;
|
|
573
|
+
setState({ phase: "ready", dt: dt2, record: record2, linkOptions });
|
|
574
|
+
const seed = newDraft(dt2);
|
|
575
|
+
if (record2 == null && project && hasProjectField(dt2)) seed[PROJECT_FIELD] = project;
|
|
576
|
+
setDraft(record2 ? { ...record2 } : seed);
|
|
577
|
+
setEditing(isNew);
|
|
578
|
+
setSaveError(null);
|
|
579
|
+
setConfirmingDelete(false);
|
|
580
|
+
} catch (e) {
|
|
581
|
+
if (!signal.cancelled) setState({ phase: "error", error: classifyBackend(e) });
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
[client, doctype, name, isNew, project]
|
|
585
|
+
);
|
|
586
|
+
useEffect(() => {
|
|
587
|
+
const signal = { cancelled: false };
|
|
588
|
+
void load(signal);
|
|
589
|
+
return () => {
|
|
590
|
+
signal.cancelled = true;
|
|
591
|
+
};
|
|
592
|
+
}, [load]);
|
|
593
|
+
const reload = useCallback(() => void load({ cancelled: false }), [load]);
|
|
594
|
+
const ready = state.phase === "ready" ? state : void 0;
|
|
595
|
+
const dt = ready?.dt;
|
|
596
|
+
const record = ready?.record ?? null;
|
|
597
|
+
const fields = useMemo(
|
|
598
|
+
() => dt ? docTypeToFields(dt, { editing: !isNew }) : [],
|
|
599
|
+
[dt, isNew]
|
|
600
|
+
);
|
|
601
|
+
const fieldOptions = useMemo(() => ready ? makeFieldOptions(ready.linkOptions) : void 0, [ready]);
|
|
602
|
+
const title = dt ? isNew ? `New ${doctype}` : titleOf(record ?? {}, dt) : doctype;
|
|
603
|
+
const onChange = useCallback((field, value) => {
|
|
604
|
+
setDraft((d) => ({ ...d, [field]: value }));
|
|
605
|
+
}, []);
|
|
606
|
+
const reflect = useCallback(
|
|
607
|
+
(saved) => {
|
|
608
|
+
if (!dt || !ready) return;
|
|
609
|
+
const next = enrichLinks(toRecord(saved, dt), dt, ready.linkOptions);
|
|
610
|
+
setState({ phase: "ready", dt, record: next, linkOptions: ready.linkOptions });
|
|
611
|
+
setDraft({ ...next });
|
|
612
|
+
},
|
|
613
|
+
[dt, ready]
|
|
614
|
+
);
|
|
615
|
+
const save = useCallback(async () => {
|
|
616
|
+
if (!dt) return;
|
|
617
|
+
setBusy(true);
|
|
618
|
+
setSaveError(null);
|
|
619
|
+
try {
|
|
620
|
+
const body = savePayload(draft, dt);
|
|
621
|
+
if (isNew) {
|
|
622
|
+
const created = await client.records.create(doctype, body);
|
|
623
|
+
if (created.name) onView(String(created.name));
|
|
624
|
+
else onBack();
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (!record?.name) throw new Error("This record has no name to update.");
|
|
628
|
+
reflect(await client.records.update(doctype, String(record.name), body));
|
|
629
|
+
setEditing(false);
|
|
630
|
+
} catch (e) {
|
|
631
|
+
setSaveError(classifyBackend(e).message);
|
|
632
|
+
} finally {
|
|
633
|
+
setBusy(false);
|
|
634
|
+
}
|
|
635
|
+
}, [client, doctype, draft, dt, isNew, onBack, onView, record, reflect]);
|
|
636
|
+
const run = useCallback(
|
|
637
|
+
async (op) => {
|
|
638
|
+
setBusy(true);
|
|
639
|
+
setSaveError(null);
|
|
640
|
+
try {
|
|
641
|
+
const saved = await op();
|
|
642
|
+
if (saved) reflect(saved);
|
|
643
|
+
} catch (e) {
|
|
644
|
+
setSaveError(classifyBackend(e).message);
|
|
645
|
+
} finally {
|
|
646
|
+
setBusy(false);
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
[reflect]
|
|
650
|
+
);
|
|
651
|
+
const remove = useCallback(async () => {
|
|
652
|
+
if (!record?.name) return;
|
|
653
|
+
setBusy(true);
|
|
654
|
+
setSaveError(null);
|
|
655
|
+
try {
|
|
656
|
+
await client.records.remove(doctype, String(record.name));
|
|
657
|
+
onBack();
|
|
658
|
+
} catch (e) {
|
|
659
|
+
setSaveError(classifyBackend(e).message);
|
|
660
|
+
setBusy(false);
|
|
661
|
+
setConfirmingDelete(false);
|
|
662
|
+
}
|
|
663
|
+
}, [client, doctype, onBack, record]);
|
|
664
|
+
const backButton = /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(ArrowLeft, { size: 15 }), onPress: onBack, children: "Back" });
|
|
665
|
+
if (state.phase === "error") {
|
|
666
|
+
return /* @__PURE__ */ jsxs(YStack, { gap: "$3", children: [
|
|
667
|
+
backButton,
|
|
668
|
+
/* @__PURE__ */ jsx(BackendStateCard, { state: state.error, onRetry: reload, hint: `framework \xB7 ${doctype}/${name}` })
|
|
669
|
+
] });
|
|
670
|
+
}
|
|
671
|
+
if (!dt) return /* @__PURE__ */ jsx(YStack, { gap: "$3", children: backButton });
|
|
672
|
+
const statusF = statusField(dt);
|
|
673
|
+
const status = record ? String(record[statusF] ?? "") : "";
|
|
674
|
+
const docstatus = record ? Number(record.docstatus ?? 0) : 0;
|
|
675
|
+
const canPublish = !editing && !isNew && statusF && docstatus === 0;
|
|
676
|
+
const canSubmit = !editing && !isNew && dt.isSubmittable && docstatus === 0;
|
|
677
|
+
const canCancel = !editing && !isNew && dt.isSubmittable && docstatus === 1;
|
|
678
|
+
return /* @__PURE__ */ jsxs(YStack, { gap: "$3", children: [
|
|
679
|
+
/* @__PURE__ */ jsxs(XStack, { items: "center", justify: "space-between", gap: "$4", flexWrap: "wrap", children: [
|
|
680
|
+
/* @__PURE__ */ jsxs(XStack, { items: "center", gap: "$3", flex: 1, children: [
|
|
681
|
+
backButton,
|
|
682
|
+
/* @__PURE__ */ jsxs(YStack, { flex: 1, children: [
|
|
683
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "$6", fontWeight: "800", numberOfLines: 1, children: title }),
|
|
684
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: "$2", color: "$color10", children: [
|
|
685
|
+
doctype,
|
|
686
|
+
status ? ` \xB7 ${status}` : "",
|
|
687
|
+
docstatus === 1 ? " \xB7 submitted" : docstatus === 2 ? " \xB7 cancelled" : ""
|
|
688
|
+
] })
|
|
689
|
+
] })
|
|
690
|
+
] }),
|
|
691
|
+
/* @__PURE__ */ jsx(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: editing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
692
|
+
!isNew ? /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(X, { size: 15 }), disabled: busy, onPress: () => {
|
|
693
|
+
setDraft(record ? { ...record } : {});
|
|
694
|
+
setEditing(false);
|
|
695
|
+
setSaveError(null);
|
|
696
|
+
}, children: "Cancel" }) : null,
|
|
697
|
+
/* @__PURE__ */ jsx(PrimaryButton, { size: "$2", icon: /* @__PURE__ */ jsx(Save, { size: 15 }), disabled: busy, onPress: save, children: busy ? "Saving\u2026" : isNew ? "Create" : "Save" })
|
|
698
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
699
|
+
/* @__PURE__ */ jsx(Button, { size: "$2", theme: "red", icon: /* @__PURE__ */ jsx(Trash2, { size: 15 }), disabled: busy, onPress: () => setConfirmingDelete(true), children: "Delete" }),
|
|
700
|
+
canCancel ? /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(Ban, { size: 15 }), disabled: busy, onPress: () => run(() => client.records.cancel(doctype, String(record.name))), children: "Cancel doc" }) : null,
|
|
701
|
+
canSubmit ? /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(Send, { size: 15 }), disabled: busy, onPress: () => run(() => client.records.submit(doctype, String(record.name))), children: "Submit" }) : null,
|
|
702
|
+
canPublish ? status === "Published" ? /* @__PURE__ */ jsx(Button, { size: "$2", icon: /* @__PURE__ */ jsx(PenOff, { size: 15 }), disabled: busy, onPress: () => run(async () => client.records.update(doctype, String(record.name), savePayload({ ...record, [statusF]: "Draft" }, dt))), children: "Unpublish" }) : /* @__PURE__ */ jsx(PrimaryButton, { size: "$2", icon: /* @__PURE__ */ jsx(Globe, { size: 15 }), disabled: busy, onPress: () => run(async () => client.records.update(doctype, String(record.name), savePayload({ ...record, [statusF]: "Published" }, dt))), children: "Publish" }) : null,
|
|
703
|
+
/* @__PURE__ */ jsx(PrimaryButton, { size: "$2", icon: /* @__PURE__ */ jsx(Pencil, { size: 15 }), onPress: () => setEditing(true), children: "Edit" })
|
|
704
|
+
] }) })
|
|
705
|
+
] }),
|
|
706
|
+
confirmingDelete ? /* @__PURE__ */ jsxs(Card, { borderWidth: 1, borderColor: "$red7", bg: "$red2", p: "$3", gap: "$2", maxWidth: 620, children: [
|
|
707
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: "$3", fontWeight: "700", children: [
|
|
708
|
+
"Delete \u201C",
|
|
709
|
+
title,
|
|
710
|
+
"\u201D? This cannot be undone."
|
|
711
|
+
] }),
|
|
712
|
+
/* @__PURE__ */ jsxs(XStack, { gap: "$2", children: [
|
|
713
|
+
/* @__PURE__ */ jsx(Button, { size: "$2", theme: "red", disabled: busy, onPress: remove, children: busy ? "Deleting\u2026" : "Confirm delete" }),
|
|
714
|
+
/* @__PURE__ */ jsx(Button, { size: "$2", disabled: busy, onPress: () => setConfirmingDelete(false), children: "Cancel" })
|
|
715
|
+
] })
|
|
716
|
+
] }) : null,
|
|
717
|
+
saveError ? /* @__PURE__ */ jsx(Card, { borderWidth: 1, borderColor: "$red7", bg: "$red2", p: "$3", maxWidth: 620, children: /* @__PURE__ */ jsxs(XStack, { gap: "$2", items: "center", children: [
|
|
718
|
+
/* @__PURE__ */ jsx(TriangleAlert, { size: 15 }),
|
|
719
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "$3", color: "$red11", children: saveError })
|
|
720
|
+
] }) }) : null,
|
|
721
|
+
/* @__PURE__ */ jsx(Card, { borderWidth: 1, borderColor: "$borderColor", p: "$4", maxWidth: 760, children: editing ? /* @__PURE__ */ jsx(RecordForm, { fields, values: draft, onChange, fieldOptions }) : record ? /* @__PURE__ */ jsx(RecordDetail, { title, fields, record, fieldOptions }) : null })
|
|
722
|
+
] });
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
export { CollectionsBrowser, DocTypeDetail, DocTypeRecords, FrameworkHttpError, Loader, PROJECT_FIELD, REDACTED_MARKER, autonameSource, createFrameworkClient, docTypeToFields, enrichLinks, fetchTransport, hasProjectField, humanize, isMediaDoctype, isValidDoctypeName, linkFields, listHiddenFields, listQuery, loadLinkOptions, makeFieldOptions, mediaFileField, moduleDoctypes, newDraft, savePayload, slugify, statusField, titleOf, toRecord };
|
|
726
|
+
//# sourceMappingURL=framework.js.map
|
|
727
|
+
//# sourceMappingURL=framework.js.map
|