@declarion/react 0.1.80 → 0.1.82
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-lib/{DraggableChildrenTable-CcXR8Vm6.js → DraggableChildrenTable-XKJWMb1S.js} +2 -2
- package/dist-lib/{DraggableChildrenTable-CcXR8Vm6.js.map → DraggableChildrenTable-XKJWMb1S.js.map} +1 -1
- package/dist-lib/{Grid-CseTLMLv.js → Grid-By_Ere-W.js} +2 -2
- package/dist-lib/{Grid-CseTLMLv.js.map → Grid-By_Ere-W.js.map} +1 -1
- package/dist-lib/{JsonEditor-Tew1oNqZ.js → JsonEditor-CexL5HXN.js} +17 -15
- package/dist-lib/JsonEditor-CexL5HXN.js.map +1 -0
- package/dist-lib/api/events.d.ts +5 -0
- package/dist-lib/components/fields/BoolField.d.ts +1 -1
- package/dist-lib/components/fields/EmailField.d.ts +1 -1
- package/dist-lib/components/fields/EnumField.d.ts +1 -1
- package/dist-lib/components/fields/IntArrayField.d.ts +1 -1
- package/dist-lib/components/fields/JsonEditor.d.ts +2 -1
- package/dist-lib/components/fields/JsonField.d.ts +1 -1
- package/dist-lib/components/fields/MultilangField.d.ts +1 -1
- package/dist-lib/components/fields/MultilangTextField.d.ts +1 -1
- package/dist-lib/components/fields/NumberField.d.ts +1 -1
- package/dist-lib/components/fields/PasswordField.d.ts +1 -1
- package/dist-lib/components/fields/PhoneField.d.ts +1 -1
- package/dist-lib/components/fields/RefField.d.ts +1 -1
- package/dist-lib/components/fields/SecretField.d.ts +1 -1
- package/dist-lib/components/fields/StringArrayField.d.ts +1 -1
- package/dist-lib/components/fields/StringField.d.ts +1 -1
- package/dist-lib/components/fields/TextField.d.ts +1 -1
- package/dist-lib/components/fields/TimestampField.d.ts +1 -1
- package/dist-lib/components/fields/UrlField.d.ts +1 -1
- package/dist-lib/components/fields/index.d.ts +2 -0
- package/dist-lib/components/file-widgets/host.d.ts +2 -0
- package/dist-lib/components/file-widgets/types.d.ts +1 -0
- package/dist-lib/components/pages/list/DataCell.d.ts +7 -0
- package/dist-lib/components/pages/list/ListBulkBar.d.ts +27 -0
- package/dist-lib/components/pages/list/ListHeader.d.ts +23 -0
- package/dist-lib/components/pages/list/RowActionsCell.d.ts +38 -0
- package/dist-lib/components/pages/list/SaveViewDialog.d.ts +6 -0
- package/dist-lib/components/pages/list/columns.d.ts +42 -0
- package/dist-lib/components/pages/list/filter-meta.d.ts +9 -0
- package/dist-lib/components/primitives/BoolToggle.d.ts +3 -1
- package/dist-lib/components/primitives/Fields.d.ts +12 -3
- package/dist-lib/index.js +4189 -4066
- package/dist-lib/index.js.map +1 -1
- package/dist-lib/lib/action-dispatch.d.ts +7 -0
- package/dist-lib/stores/realtime.d.ts +9 -0
- package/dist-lib/types/schema.d.ts +11 -1
- package/dist-lib/{useUserLocale-D9wc5kzQ.js → useUserLocale-CSS6fwi8.js} +1110 -1003
- package/dist-lib/useUserLocale-CSS6fwi8.js.map +1 -0
- package/dist-lib/{value-FIp50R1-.js → value-DgzPSFZM.js} +149 -196
- package/dist-lib/value-DgzPSFZM.js.map +1 -0
- package/package.json +1 -1
- package/dist-lib/JsonEditor-Tew1oNqZ.js.map +0 -1
- package/dist-lib/components/shared/RowActionItem.d.ts +0 -11
- package/dist-lib/useUserLocale-D9wc5kzQ.js.map +0 -1
- package/dist-lib/value-FIp50R1-.js.map +0 -1
|
@@ -38,53 +38,53 @@ function m() {
|
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/lib/versionTracker.ts
|
|
41
|
-
var h = "X-Declarion-Version",
|
|
42
|
-
function
|
|
41
|
+
var h = "X-Declarion-Version", ee = "declarion-version";
|
|
42
|
+
function g() {
|
|
43
43
|
if (typeof BroadcastChannel > "u") return null;
|
|
44
44
|
try {
|
|
45
|
-
return new BroadcastChannel(
|
|
45
|
+
return new BroadcastChannel(ee);
|
|
46
46
|
} catch {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
var
|
|
50
|
+
var _ = {
|
|
51
51
|
firstSeen: null,
|
|
52
52
|
firstComponents: null,
|
|
53
53
|
hasReportedDrift: !1,
|
|
54
54
|
listeners: /* @__PURE__ */ new Set(),
|
|
55
55
|
channel: null
|
|
56
56
|
};
|
|
57
|
-
function
|
|
58
|
-
|
|
57
|
+
function v() {
|
|
58
|
+
_.channel || typeof BroadcastChannel > "u" || (_.channel = g(), _.channel && _.channel.addEventListener("message", (e) => {
|
|
59
59
|
let t = e.data;
|
|
60
|
-
if (!(!t || t.type !== "drift" || !t.delta) && !
|
|
61
|
-
|
|
62
|
-
for (let e of
|
|
60
|
+
if (!(!t || t.type !== "drift" || !t.delta) && !_.hasReportedDrift) {
|
|
61
|
+
_.hasReportedDrift = !0;
|
|
62
|
+
for (let e of _.listeners) e(t.delta);
|
|
63
63
|
}
|
|
64
64
|
}));
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
if (
|
|
66
|
+
function y(e) {
|
|
67
|
+
if (v(), !e) return;
|
|
68
68
|
let t = e.get(h);
|
|
69
69
|
if (t) {
|
|
70
|
-
if (!
|
|
71
|
-
|
|
70
|
+
if (!_.firstSeen) {
|
|
71
|
+
_.firstSeen = t;
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
t !==
|
|
75
|
-
|
|
74
|
+
t !== _.firstSeen && (_.hasReportedDrift || b().catch(() => {
|
|
75
|
+
x({
|
|
76
76
|
kind: "unknown",
|
|
77
77
|
observed: t
|
|
78
78
|
});
|
|
79
79
|
}));
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
async function
|
|
83
|
-
|
|
82
|
+
async function b() {
|
|
83
|
+
v();
|
|
84
84
|
let e;
|
|
85
85
|
try {
|
|
86
86
|
let t = {};
|
|
87
|
-
|
|
87
|
+
_.firstSeen && (t["If-None-Match"] = `"${_.firstSeen}"`), e = await fetch("/api/version", {
|
|
88
88
|
method: "GET",
|
|
89
89
|
credentials: "include",
|
|
90
90
|
headers: t
|
|
@@ -107,188 +107,141 @@ async function x() {
|
|
|
107
107
|
asset: t.asset_fingerprint,
|
|
108
108
|
binary: t.binary_fingerprint
|
|
109
109
|
} : void 0;
|
|
110
|
-
|
|
111
|
-
kind:
|
|
110
|
+
_.firstSeen ||= n, !_.firstComponents && r && n === _.firstSeen && (_.firstComponents = r), n !== _.firstSeen && x({
|
|
111
|
+
kind: te(_.firstComponents, r),
|
|
112
112
|
observed: n,
|
|
113
113
|
components: r
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function te(e, t) {
|
|
117
117
|
if (!e || !t) return "unknown";
|
|
118
118
|
let n = e.schema !== t.schema, r = e.asset !== t.asset, i = e.binary !== t.binary;
|
|
119
119
|
return n && !r && !i ? "schema-only" : r || i ? "asset-or-binary" : "unknown";
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
if (!
|
|
123
|
-
|
|
124
|
-
for (let t of
|
|
125
|
-
if (
|
|
126
|
-
|
|
121
|
+
function x(e) {
|
|
122
|
+
if (!_.hasReportedDrift) {
|
|
123
|
+
_.hasReportedDrift = !0;
|
|
124
|
+
for (let t of _.listeners) t(e);
|
|
125
|
+
if (_.channel) try {
|
|
126
|
+
_.channel.postMessage({
|
|
127
127
|
type: "drift",
|
|
128
128
|
delta: e
|
|
129
129
|
});
|
|
130
130
|
} catch {}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
return
|
|
135
|
-
|
|
133
|
+
function ne(e) {
|
|
134
|
+
return _.listeners.add(e), () => {
|
|
135
|
+
_.listeners.delete(e);
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/api/client.ts
|
|
140
|
-
var
|
|
140
|
+
var S = (e) => JSON.stringify(e ?? {}), C = null, w = class extends Error {
|
|
141
141
|
constructor(e) {
|
|
142
142
|
super(`refresh failed terminally (${e})`), this.status = e, this.name = "RefreshDeadError";
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
|
-
async function
|
|
145
|
+
async function T() {
|
|
146
146
|
let e = {
|
|
147
147
|
method: "POST",
|
|
148
148
|
credentials: "include",
|
|
149
149
|
headers: { "Content-Type": "application/json" },
|
|
150
|
-
body:
|
|
150
|
+
body: S({})
|
|
151
151
|
}, t = await fetch("/api/actions/auth.refresh", e);
|
|
152
152
|
if (t.status === 429) {
|
|
153
153
|
let n = parseInt(t.headers.get("Retry-After") || "1", 10);
|
|
154
154
|
await new Promise((e) => setTimeout(e, n * 1e3));
|
|
155
155
|
let r = await fetch("/api/actions/auth.refresh", e);
|
|
156
|
-
if (!r.ok) throw new
|
|
156
|
+
if (!r.ok) throw new w(r.status);
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
|
-
if (!t.ok) throw new
|
|
159
|
+
if (!t.ok) throw new w(t.status);
|
|
160
160
|
}
|
|
161
|
-
async function
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
}),
|
|
161
|
+
async function E() {
|
|
162
|
+
return C || (C = T().finally(() => {
|
|
163
|
+
C = null;
|
|
164
|
+
}), C);
|
|
165
165
|
}
|
|
166
|
-
var
|
|
166
|
+
var D = () => {
|
|
167
167
|
if (typeof window > "u") return;
|
|
168
168
|
let { pathname: e } = window.location;
|
|
169
169
|
e.startsWith("/login") || e.startsWith("/signup") || e === "/reset" || e === "/forgot" || (window.location.href = m());
|
|
170
170
|
};
|
|
171
|
-
function
|
|
172
|
-
return
|
|
171
|
+
function O() {
|
|
172
|
+
return D;
|
|
173
173
|
}
|
|
174
|
-
var
|
|
174
|
+
var re = ({ status: e, code: t, message: n }) => {
|
|
175
175
|
console.error(`[API ${e}] ${t}: ${n}`);
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
let
|
|
179
|
-
!
|
|
180
|
-
let r = AbortSignal.timeout(j), i = t.signal ? AbortSignal.any([t.signal, r]) : r, a;
|
|
181
|
-
try {
|
|
182
|
-
a = await fetch(e, {
|
|
183
|
-
...t,
|
|
184
|
-
headers: n,
|
|
185
|
-
credentials: "include",
|
|
186
|
-
signal: i
|
|
187
|
-
});
|
|
188
|
-
} catch (t) {
|
|
189
|
-
throw t instanceof DOMException && t.name === "TimeoutError" ? new o(0, `Request to ${e} timed out after ${j / 1e3}s. If you have many tabs open to the dev server, the HTTP/1.1 6-connection cap may be queueing requests in the browser. See docs/gotchas.md.`, "REQUEST_TIMEOUT") : t;
|
|
190
|
-
}
|
|
191
|
-
if (b(a.headers), a.status !== 204) {
|
|
192
|
-
if (a.status === 207) return a.json();
|
|
193
|
-
if (!a.ok) {
|
|
194
|
-
let n = "Request failed", r = "UNKNOWN", s, c;
|
|
195
|
-
try {
|
|
196
|
-
c = await a.json();
|
|
197
|
-
let e = c;
|
|
198
|
-
e && e.error && (n = e.error.message, r = e.error.code, e.index != null && (s = e.index));
|
|
199
|
-
} catch {}
|
|
200
|
-
if (a.status === 401 && (r === "TOKEN_REFRESH_NEEDED" || r === "UNAUTHORIZED")) try {
|
|
201
|
-
await D();
|
|
202
|
-
let n = new Headers(t.headers);
|
|
203
|
-
!n.has("Content-Type") && t.body && n.set("Content-Type", "application/json");
|
|
204
|
-
let r = await fetch(e, {
|
|
205
|
-
...t,
|
|
206
|
-
headers: n,
|
|
207
|
-
credentials: "include",
|
|
208
|
-
signal: i
|
|
209
|
-
});
|
|
210
|
-
if (r.status === 204) return;
|
|
211
|
-
if (!r.ok) {
|
|
212
|
-
O();
|
|
213
|
-
let e = await r.json().catch(() => ({ error: {
|
|
214
|
-
message: "Request failed",
|
|
215
|
-
code: "UNKNOWN"
|
|
216
|
-
} }));
|
|
217
|
-
throw new o(r.status, e.error.message, e.error.code, e.index);
|
|
218
|
-
}
|
|
219
|
-
return r.json();
|
|
220
|
-
} catch (e) {
|
|
221
|
-
throw e instanceof o ? e : (O(), new o(401, n, r, s));
|
|
222
|
-
}
|
|
223
|
-
throw a.status === 401 && O(), A({
|
|
224
|
-
status: a.status,
|
|
225
|
-
code: r,
|
|
226
|
-
message: n
|
|
227
|
-
}), new o(a.status, n, r, s, c);
|
|
228
|
-
}
|
|
229
|
-
return a.json();
|
|
230
|
-
}
|
|
176
|
+
}, k = 3e4;
|
|
177
|
+
function A(e, t, n) {
|
|
178
|
+
let r = new Headers(e);
|
|
179
|
+
return !r.has("Content-Type") && t && r.set("Content-Type", "application/json"), n.setAccept && !r.has("Accept") && r.set("Accept", "*/*"), r;
|
|
231
180
|
}
|
|
232
|
-
async function
|
|
233
|
-
let n =
|
|
234
|
-
!n.has("Content-Type") && t.body && n.set("Content-Type", "application/json"), n.has("Accept") || n.set("Accept", "*/*");
|
|
235
|
-
let r = AbortSignal.timeout(j), i = t.signal ? AbortSignal.any([t.signal, r]) : r, a;
|
|
181
|
+
async function j(e, t, n, r) {
|
|
182
|
+
let i = A(t.headers, !!t.body, n), a = AbortSignal.timeout(k), s = t.signal ? AbortSignal.any([t.signal, a]) : a, c;
|
|
236
183
|
try {
|
|
237
|
-
|
|
184
|
+
c = await fetch(e, {
|
|
238
185
|
...t,
|
|
239
|
-
headers:
|
|
186
|
+
headers: i,
|
|
240
187
|
credentials: "include",
|
|
241
|
-
signal:
|
|
188
|
+
signal: s
|
|
242
189
|
});
|
|
243
190
|
} catch (t) {
|
|
244
|
-
throw t instanceof DOMException && t.name === "TimeoutError" ? new o(0, `Request to ${e} timed out after ${
|
|
191
|
+
throw t instanceof DOMException && t.name === "TimeoutError" ? new o(0, `Request to ${e} timed out after ${k / 1e3}s. If you have many tabs open to the dev server, the HTTP/1.1 6-connection cap may be queueing requests in the browser. See docs/gotchas.md.`, "REQUEST_TIMEOUT") : t;
|
|
245
192
|
}
|
|
246
|
-
if (
|
|
247
|
-
let
|
|
193
|
+
if (y(c.headers), !c.ok) {
|
|
194
|
+
let i = "Request failed", a = "UNKNOWN", l, u;
|
|
248
195
|
try {
|
|
249
|
-
|
|
250
|
-
let e =
|
|
251
|
-
e && e.error && (
|
|
196
|
+
u = await c.json();
|
|
197
|
+
let e = u;
|
|
198
|
+
e && e.error && (i = e.error.message, a = e.error.code, e.index != null && (l = e.index));
|
|
252
199
|
} catch {}
|
|
253
|
-
if (
|
|
254
|
-
await
|
|
255
|
-
let
|
|
256
|
-
!n.has("Content-Type") && t.body && n.set("Content-Type", "application/json"), n.has("Accept") || n.set("Accept", "*/*");
|
|
257
|
-
let r = await fetch(e, {
|
|
200
|
+
if (c.status === 401 && (a === "TOKEN_REFRESH_NEEDED" || a === "UNAUTHORIZED")) try {
|
|
201
|
+
await E();
|
|
202
|
+
let i = A(t.headers, !!t.body, n), a = await fetch(e, {
|
|
258
203
|
...t,
|
|
259
|
-
headers:
|
|
204
|
+
headers: i,
|
|
260
205
|
credentials: "include",
|
|
261
|
-
signal:
|
|
206
|
+
signal: s
|
|
262
207
|
});
|
|
263
|
-
if (!
|
|
264
|
-
|
|
265
|
-
let e = await
|
|
208
|
+
if (!a.ok) {
|
|
209
|
+
D();
|
|
210
|
+
let e = await a.json().catch(() => ({ error: {
|
|
266
211
|
message: "Request failed",
|
|
267
212
|
code: "UNKNOWN"
|
|
268
213
|
} }));
|
|
269
|
-
throw new o(
|
|
214
|
+
throw new o(a.status, e.error.message, e.error.code, e.index);
|
|
270
215
|
}
|
|
271
|
-
return
|
|
272
|
-
blob: await r.blob(),
|
|
273
|
-
filename: N(r.headers),
|
|
274
|
-
headers: r.headers
|
|
275
|
-
};
|
|
216
|
+
return r(a);
|
|
276
217
|
} catch (e) {
|
|
277
|
-
throw e instanceof o ? e : (
|
|
218
|
+
throw e instanceof o ? e : (D(), new o(401, i, a, l));
|
|
278
219
|
}
|
|
279
|
-
throw
|
|
280
|
-
status:
|
|
281
|
-
code:
|
|
282
|
-
message:
|
|
283
|
-
}), new o(
|
|
220
|
+
throw c.status === 401 && D(), re({
|
|
221
|
+
status: c.status,
|
|
222
|
+
code: a,
|
|
223
|
+
message: i
|
|
224
|
+
}), new o(c.status, i, a, l, u);
|
|
284
225
|
}
|
|
226
|
+
return r(c);
|
|
227
|
+
}
|
|
228
|
+
function M(e) {
|
|
229
|
+
return e.status === 204 ? Promise.resolve(void 0) : e.json();
|
|
230
|
+
}
|
|
231
|
+
async function N(e, t = {}) {
|
|
232
|
+
return j(e, t, { setAccept: !1 }, M);
|
|
233
|
+
}
|
|
234
|
+
async function P(e) {
|
|
285
235
|
return {
|
|
286
|
-
blob: await
|
|
287
|
-
filename:
|
|
288
|
-
headers:
|
|
236
|
+
blob: await e.blob(),
|
|
237
|
+
filename: I(e.headers),
|
|
238
|
+
headers: e.headers
|
|
289
239
|
};
|
|
290
240
|
}
|
|
291
|
-
function
|
|
241
|
+
async function F(e, t = {}) {
|
|
242
|
+
return j(e, t, { setAccept: !0 }, P);
|
|
243
|
+
}
|
|
244
|
+
function I(e) {
|
|
292
245
|
let t = e.get("Content-Disposition");
|
|
293
246
|
if (!t) return "";
|
|
294
247
|
let n = t.match(/filename\*\s*=\s*([^']*)'([^']*)'([^;]+)/i);
|
|
@@ -298,26 +251,26 @@ function N(e) {
|
|
|
298
251
|
let r = t.match(/filename\s*=\s*("([^"]+)"|([^;]+))/i);
|
|
299
252
|
return r ? (r[2] ?? r[3] ?? "").trim() : "";
|
|
300
253
|
}
|
|
301
|
-
async function
|
|
302
|
-
return (await
|
|
254
|
+
async function L(e, t = {}) {
|
|
255
|
+
return (await N(`/api/actions/${encodeURIComponent(e)}`, {
|
|
303
256
|
method: "POST",
|
|
304
|
-
body:
|
|
257
|
+
body: S(t)
|
|
305
258
|
})).result;
|
|
306
259
|
}
|
|
307
260
|
//#endregion
|
|
308
261
|
//#region src/components/file-widgets/upload.ts
|
|
309
|
-
var
|
|
262
|
+
var R = class extends Error {
|
|
310
263
|
code;
|
|
311
264
|
status;
|
|
312
265
|
constructor(e, t, n) {
|
|
313
266
|
super(n), this.code = t, this.status = e;
|
|
314
267
|
}
|
|
315
268
|
};
|
|
316
|
-
function
|
|
269
|
+
function z(e) {
|
|
317
270
|
let { file: t, entityCode: n, fieldCode: r, slotCode: i, onProgress: a, signal: o } = e;
|
|
318
271
|
return new Promise((e, s) => {
|
|
319
272
|
let c = new XMLHttpRequest();
|
|
320
|
-
if (c.open("POST",
|
|
273
|
+
if (c.open("POST", B(n, r, i)), c.withCredentials = !0, c.upload.onprogress = (e) => {
|
|
321
274
|
if (!a) return;
|
|
322
275
|
let n = e.lengthComputable ? e.total : t.size, r = n > 0 ? Math.min(100, Math.round(e.loaded / n * 100)) : 0;
|
|
323
276
|
a({
|
|
@@ -331,23 +284,23 @@ function I(e) {
|
|
|
331
284
|
n = t ? JSON.parse(t) : null;
|
|
332
285
|
} catch {}
|
|
333
286
|
if (c.status >= 200 && c.status < 300) {
|
|
334
|
-
let t =
|
|
287
|
+
let t = V(n);
|
|
335
288
|
if (!t || !t.id) {
|
|
336
|
-
s(new
|
|
289
|
+
s(new R(c.status, "BAD_RESPONSE", "Upload returned no file id"));
|
|
337
290
|
return;
|
|
338
291
|
}
|
|
339
292
|
e(t);
|
|
340
293
|
return;
|
|
341
294
|
}
|
|
342
295
|
let r = n, i = r?.error?.code ?? "UPLOAD_FAILED", a = r?.error?.message ?? `Upload failed (${c.status})`;
|
|
343
|
-
s(new
|
|
296
|
+
s(new R(c.status, i, a));
|
|
344
297
|
}, c.onerror = () => {
|
|
345
|
-
s(new
|
|
298
|
+
s(new R(0, "NETWORK_ERROR", "Network error during upload"));
|
|
346
299
|
}, c.onabort = () => {
|
|
347
|
-
s(new
|
|
300
|
+
s(new R(0, "ABORTED", "Upload aborted"));
|
|
348
301
|
}, o) {
|
|
349
302
|
if (o.aborted) {
|
|
350
|
-
c.abort(), s(new
|
|
303
|
+
c.abort(), s(new R(0, "ABORTED", "Upload aborted"));
|
|
351
304
|
return;
|
|
352
305
|
}
|
|
353
306
|
o.addEventListener("abort", () => c.abort(), { once: !0 });
|
|
@@ -356,56 +309,56 @@ function I(e) {
|
|
|
356
309
|
l.append("file", t, t.name), c.send(l);
|
|
357
310
|
});
|
|
358
311
|
}
|
|
359
|
-
function
|
|
312
|
+
function B(e, t, n) {
|
|
360
313
|
let r = new URLSearchParams();
|
|
361
314
|
e && t && (r.set("entity_code", e), r.set("field_code", t), n && r.set("slot_code", n));
|
|
362
315
|
let i = r.toString();
|
|
363
316
|
return i ? `/api/files/upload?${i}` : "/api/files/upload";
|
|
364
317
|
}
|
|
365
|
-
function
|
|
366
|
-
return
|
|
318
|
+
function V(e) {
|
|
319
|
+
return U(e) ? U(e.result) ? V(e.result) : U(e.file) ? H(e.file) : typeof e.id == "string" ? e : null : null;
|
|
367
320
|
}
|
|
368
|
-
function
|
|
369
|
-
let t =
|
|
321
|
+
function H(e) {
|
|
322
|
+
let t = W(e.file_id);
|
|
370
323
|
return t ? {
|
|
371
324
|
id: t,
|
|
372
|
-
filename:
|
|
373
|
-
content_type:
|
|
374
|
-
size_bytes:
|
|
375
|
-
sha256:
|
|
376
|
-
dedup:
|
|
325
|
+
filename: W(e.filename_original) ?? W(e.filename_normalized) ?? t,
|
|
326
|
+
content_type: W(e.content_type) ?? "application/octet-stream",
|
|
327
|
+
size_bytes: G(e.size_bytes) ?? 0,
|
|
328
|
+
sha256: W(e.sha256) ?? "",
|
|
329
|
+
dedup: K(e.dedup)
|
|
377
330
|
} : null;
|
|
378
331
|
}
|
|
379
|
-
function
|
|
332
|
+
function U(e) {
|
|
380
333
|
return typeof e == "object" && !!e;
|
|
381
334
|
}
|
|
382
|
-
function
|
|
335
|
+
function W(e) {
|
|
383
336
|
return typeof e == "string" ? e : void 0;
|
|
384
337
|
}
|
|
385
|
-
function
|
|
338
|
+
function G(e) {
|
|
386
339
|
return typeof e == "number" ? e : void 0;
|
|
387
340
|
}
|
|
388
|
-
function
|
|
341
|
+
function K(e) {
|
|
389
342
|
return typeof e == "boolean" ? e : void 0;
|
|
390
343
|
}
|
|
391
|
-
async function
|
|
392
|
-
await
|
|
344
|
+
async function q(e) {
|
|
345
|
+
await L("files.discard", { file_id: e });
|
|
393
346
|
}
|
|
394
|
-
function
|
|
347
|
+
function ie(e, t, n) {
|
|
395
348
|
if (n && e.size > n) return {
|
|
396
349
|
code: "FILE_TOO_LARGE",
|
|
397
|
-
message: `File is ${
|
|
350
|
+
message: `File is ${Y(e.size)}, max ${Y(n)}`
|
|
398
351
|
};
|
|
399
352
|
if (t && t.length > 0) {
|
|
400
353
|
let n = e.type || "application/octet-stream";
|
|
401
|
-
if (!t.some((e) =>
|
|
354
|
+
if (!t.some((e) => J(e, n))) return {
|
|
402
355
|
code: "MIME_NOT_ACCEPTED",
|
|
403
356
|
message: `File type ${n} is not accepted`
|
|
404
357
|
};
|
|
405
358
|
}
|
|
406
359
|
return null;
|
|
407
360
|
}
|
|
408
|
-
function
|
|
361
|
+
function J(e, t) {
|
|
409
362
|
if (e === "*/*" || e === "*") return !0;
|
|
410
363
|
if (e.endsWith("/*")) {
|
|
411
364
|
let n = e.slice(0, e.length - 1);
|
|
@@ -413,7 +366,7 @@ function K(e, t) {
|
|
|
413
366
|
}
|
|
414
367
|
return e === t;
|
|
415
368
|
}
|
|
416
|
-
function
|
|
369
|
+
function Y(e) {
|
|
417
370
|
if (e < 1024) return `${e} B`;
|
|
418
371
|
let t = [
|
|
419
372
|
"KB",
|
|
@@ -425,10 +378,10 @@ function q(e) {
|
|
|
425
378
|
}
|
|
426
379
|
//#endregion
|
|
427
380
|
//#region src/components/file-widgets/helpers.ts
|
|
428
|
-
function
|
|
381
|
+
function ae() {
|
|
429
382
|
return typeof navigator > "u" ? ["en"] : (navigator.languages?.length ? navigator.languages : [navigator.language]).filter((e) => typeof e == "string" && e.length > 0);
|
|
430
383
|
}
|
|
431
|
-
function
|
|
384
|
+
function oe(e, t) {
|
|
432
385
|
for (let n of t) {
|
|
433
386
|
if (e[n]) return e[n];
|
|
434
387
|
let t = n.split("-")[0];
|
|
@@ -436,17 +389,17 @@ function Y(e, t) {
|
|
|
436
389
|
}
|
|
437
390
|
for (let t of Object.values(e)) if (typeof t == "string" && t.length > 0) return t;
|
|
438
391
|
}
|
|
439
|
-
function
|
|
392
|
+
function se(e, t, n) {
|
|
440
393
|
if (t) return t;
|
|
441
394
|
let r = e?.metadata?.alt_text;
|
|
442
395
|
if (typeof r == "string" && r.length > 0) return r;
|
|
443
396
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
444
|
-
let e =
|
|
397
|
+
let e = oe(Object.fromEntries(Object.entries(r).filter((e) => e[0].length > 0 && typeof e[1] == "string")), ae());
|
|
445
398
|
if (e) return e;
|
|
446
399
|
}
|
|
447
400
|
return n;
|
|
448
401
|
}
|
|
449
|
-
var
|
|
402
|
+
var ce = new Set([
|
|
450
403
|
"image/png",
|
|
451
404
|
"image/jpeg",
|
|
452
405
|
"image/webp",
|
|
@@ -454,22 +407,22 @@ var X = new Set([
|
|
|
454
407
|
"image/avif",
|
|
455
408
|
"application/pdf"
|
|
456
409
|
]);
|
|
457
|
-
function
|
|
410
|
+
function le(e) {
|
|
458
411
|
let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
459
|
-
return
|
|
412
|
+
return ce.has(t);
|
|
460
413
|
}
|
|
461
|
-
function
|
|
414
|
+
function ue(e) {
|
|
462
415
|
return e.url ?? e.presigned_url;
|
|
463
416
|
}
|
|
464
|
-
function
|
|
465
|
-
return e.url ?
|
|
417
|
+
function de(e) {
|
|
418
|
+
return e.url ? pe(e.url, "attachment") : e.presigned_url;
|
|
466
419
|
}
|
|
467
|
-
function
|
|
420
|
+
function fe(e, t) {
|
|
468
421
|
if (!e) return;
|
|
469
422
|
let n = e.derivations ?? {};
|
|
470
423
|
return t && n[t] ? n[t] : n.thumb_200 ?? n.thumb_300 ?? e.url ?? e.presigned_url;
|
|
471
424
|
}
|
|
472
|
-
function
|
|
425
|
+
function pe(e, t) {
|
|
473
426
|
try {
|
|
474
427
|
let n = new URL(e, typeof window < "u" ? window.location.origin : "http://localhost");
|
|
475
428
|
return n.searchParams.set("disposition", t), /^https?:\/\//i.test(e) ? n.toString() : `${n.pathname}${n.search}${n.hash}`;
|
|
@@ -477,7 +430,7 @@ function ce(e, t) {
|
|
|
477
430
|
return `${e}${e.includes("?") ? "&" : "?"}disposition=${t}`;
|
|
478
431
|
}
|
|
479
432
|
}
|
|
480
|
-
function
|
|
433
|
+
function me(e) {
|
|
481
434
|
let t = e?.metadata?.focal_point;
|
|
482
435
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
483
436
|
let n = t, r = typeof n.x == "number" ? n.x : NaN, i = typeof n.y == "number" ? n.y : NaN;
|
|
@@ -486,10 +439,10 @@ function le(e) {
|
|
|
486
439
|
y: i
|
|
487
440
|
};
|
|
488
441
|
}
|
|
489
|
-
function
|
|
442
|
+
function he(e) {
|
|
490
443
|
if (e) return `${e.x * 100}% ${e.y * 100}%`;
|
|
491
444
|
}
|
|
492
|
-
function
|
|
445
|
+
function ge(e, t) {
|
|
493
446
|
return {
|
|
494
447
|
...e,
|
|
495
448
|
metadata: {
|
|
@@ -500,7 +453,7 @@ function de(e, t) {
|
|
|
500
453
|
}
|
|
501
454
|
//#endregion
|
|
502
455
|
//#region src/components/file-widgets/draft-scope.tsx
|
|
503
|
-
var
|
|
456
|
+
var X = e({
|
|
504
457
|
registerDraft() {},
|
|
505
458
|
unregisterDraft() {},
|
|
506
459
|
hasDraft() {
|
|
@@ -509,7 +462,7 @@ var Z = e({
|
|
|
509
462
|
flushAllDrafts: async () => {},
|
|
510
463
|
markCommitted() {}
|
|
511
464
|
});
|
|
512
|
-
function
|
|
465
|
+
function _e({ children: e }) {
|
|
513
466
|
let t = i(/* @__PURE__ */ new Map()), n = r(() => ({
|
|
514
467
|
registerDraft(e) {
|
|
515
468
|
t.current.set(e.fileId, e);
|
|
@@ -528,16 +481,16 @@ function fe({ children: e }) {
|
|
|
528
481
|
t.current.clear(), await Promise.allSettled(e.map((e) => Promise.resolve(e.discard())));
|
|
529
482
|
}
|
|
530
483
|
}), []);
|
|
531
|
-
return /* @__PURE__ */ a(
|
|
484
|
+
return /* @__PURE__ */ a(X.Provider, {
|
|
532
485
|
value: n,
|
|
533
486
|
children: e
|
|
534
487
|
});
|
|
535
488
|
}
|
|
536
|
-
function
|
|
537
|
-
return n(
|
|
489
|
+
function Z() {
|
|
490
|
+
return n(X);
|
|
538
491
|
}
|
|
539
|
-
function
|
|
540
|
-
let e =
|
|
492
|
+
function Q() {
|
|
493
|
+
let e = Z();
|
|
541
494
|
return {
|
|
542
495
|
register: t((t, n) => {
|
|
543
496
|
e.registerDraft({
|
|
@@ -559,13 +512,13 @@ function pe() {
|
|
|
559
512
|
function $(e) {
|
|
560
513
|
return typeof e == "object" && !!e && typeof e.id == "string";
|
|
561
514
|
}
|
|
562
|
-
function
|
|
515
|
+
function ve(e) {
|
|
563
516
|
return e ? Array.isArray(e) ? e.find($) ?? null : $(e) ? e : null : null;
|
|
564
517
|
}
|
|
565
|
-
function
|
|
518
|
+
function ye(e) {
|
|
566
519
|
return e ? Array.isArray(e) ? e.filter($) : $(e) ? [e] : [] : [];
|
|
567
520
|
}
|
|
568
521
|
//#endregion
|
|
569
|
-
export {
|
|
522
|
+
export { E as C, p as D, ne as E, f as O, L as S, b as T, z as _, Z as a, N as b, he as c, me as d, se as f, Y as g, q as h, Q as i, o as k, fe as l, R as m, ve as n, le as o, ge as p, _e as r, de as s, ye as t, ue as u, ie as v, O as w, F as x, w as y };
|
|
570
523
|
|
|
571
|
-
//# sourceMappingURL=value-
|
|
524
|
+
//# sourceMappingURL=value-DgzPSFZM.js.map
|