@declarion/react 0.24.0 → 0.26.1
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/{ActionRunner-eixtbT5K.js → ActionRunner-B2e3Igpd.js} +1706 -3753
- package/dist-lib/{DraggableChildrenTable-ByuH27zv.js → DraggableChildrenTable-BUUUPzI3.js} +25 -25
- package/dist-lib/{Grid-hWuSXZWA.js → Grid-Bjq2IPUx.js} +76 -75
- package/dist-lib/{MarkdownRenderer-x-5sbiRs.js → MarkdownRenderer-Be0nUKB1.js} +1 -1
- package/dist-lib/index.js +5370 -3362
- package/dist-lib/lib/actions.d.ts +7 -0
- package/dist-lib/testing.js +27 -27
- package/dist-lib/value-D7fe0TEL.js +210 -0
- package/package.json +4 -1
|
@@ -37,6 +37,13 @@ export declare function getScreenActions(entityActions: Record<string, Action> |
|
|
|
37
37
|
code: string;
|
|
38
38
|
action: Action;
|
|
39
39
|
}>;
|
|
40
|
+
export declare function filterUnavailableMutationActions(actions: Array<{
|
|
41
|
+
code: string;
|
|
42
|
+
action: Action;
|
|
43
|
+
}>, entity: Pick<Entity, "readonly" | "mutations"> | undefined): Array<{
|
|
44
|
+
code: string;
|
|
45
|
+
action: Action;
|
|
46
|
+
}>;
|
|
40
47
|
/**
|
|
41
48
|
* Checks if an action has parameters that need user input.
|
|
42
49
|
*/
|
package/dist-lib/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as e, V as t, X as n, Y as r, ft as i, t as a } from "./ActionRunner-B2e3Igpd.js";
|
|
2
2
|
import { useState as o } from "react";
|
|
3
3
|
import { MemoryRouter as s } from "react-router-dom";
|
|
4
4
|
import { QueryClient as c, QueryClientProvider as l } from "@tanstack/react-query";
|
|
@@ -54,23 +54,23 @@ function y(e) {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
function b() {
|
|
57
|
-
let
|
|
57
|
+
let e = {
|
|
58
58
|
id: "test-tenant",
|
|
59
59
|
code: "test",
|
|
60
60
|
name: "Test",
|
|
61
61
|
role: "admin"
|
|
62
|
-
},
|
|
62
|
+
}, t = {
|
|
63
63
|
id: "test-user",
|
|
64
64
|
email: "test@example.com",
|
|
65
65
|
display_name: "Test User",
|
|
66
66
|
is_active: !0,
|
|
67
67
|
roles: ["admin"],
|
|
68
68
|
permissions: ["*"],
|
|
69
|
-
tenant:
|
|
69
|
+
tenant: e,
|
|
70
70
|
created_at: "2026-01-01T00:00:00Z",
|
|
71
71
|
updated_at: "2026-01-01T00:00:00Z"
|
|
72
72
|
};
|
|
73
|
-
|
|
73
|
+
i.getState().setUser(t, e);
|
|
74
74
|
}
|
|
75
75
|
function x(e) {
|
|
76
76
|
if (e === void 0) return { rows: [] };
|
|
@@ -85,43 +85,43 @@ function x(e) {
|
|
|
85
85
|
}
|
|
86
86
|
return e;
|
|
87
87
|
}
|
|
88
|
-
function S(
|
|
89
|
-
let
|
|
88
|
+
function S(i) {
|
|
89
|
+
let a = i.entityData ?? {};
|
|
90
90
|
n((e, t) => {
|
|
91
|
-
let n =
|
|
91
|
+
let n = a[e], r = x(n), i = r.meta?.per_page ?? 50, o = r.meta?.total ?? r.rows.length;
|
|
92
92
|
return t.count === "only" ? {
|
|
93
93
|
data: [],
|
|
94
94
|
meta: {
|
|
95
95
|
page: 1,
|
|
96
|
-
per_page:
|
|
96
|
+
per_page: i,
|
|
97
97
|
total: o,
|
|
98
|
-
total_pages: r.meta?.total_pages ?? Math.max(1, Math.ceil(o /
|
|
98
|
+
total_pages: r.meta?.total_pages ?? Math.max(1, Math.ceil(o / i)),
|
|
99
99
|
count_mode: r.meta?.count_mode ?? "exact"
|
|
100
100
|
}
|
|
101
101
|
} : {
|
|
102
102
|
data: r.rows,
|
|
103
103
|
meta: {
|
|
104
104
|
page: r.meta?.page ?? 1,
|
|
105
|
-
per_page:
|
|
105
|
+
per_page: i,
|
|
106
106
|
has_more: r.meta?.has_more ?? !1
|
|
107
107
|
},
|
|
108
108
|
...r.refs === void 0 ? {} : { $refs: r.refs }
|
|
109
109
|
};
|
|
110
110
|
});
|
|
111
|
-
let o =
|
|
112
|
-
|
|
113
|
-
let
|
|
114
|
-
return { data: o[e]?.[
|
|
111
|
+
let o = i.entityItems ?? {};
|
|
112
|
+
r((e, n) => {
|
|
113
|
+
let r = typeof n == "string" ? n : t(n);
|
|
114
|
+
return { data: o[e]?.[r] };
|
|
115
115
|
});
|
|
116
|
-
let s =
|
|
117
|
-
|
|
116
|
+
let s = i.actionResults ?? {};
|
|
117
|
+
e(async (e, t) => {
|
|
118
118
|
if (!(e in s)) throw Error(`renderWithDeclarion: no action result registered for "${e}" (seed it via actionResults)`);
|
|
119
119
|
let n = s[e];
|
|
120
120
|
return y(typeof n == "function" ? await n(t) : n);
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
function C() {
|
|
124
|
-
n(null),
|
|
124
|
+
n(null), r(null), e(null), i.setState({
|
|
125
125
|
user: null,
|
|
126
126
|
isAuthenticated: !1,
|
|
127
127
|
activeTenant: null,
|
|
@@ -138,29 +138,29 @@ function w(e, t = {}) {
|
|
|
138
138
|
client: n,
|
|
139
139
|
children: [/* @__PURE__ */ d(s, {
|
|
140
140
|
initialEntries: [t.route ?? "/"],
|
|
141
|
-
children: /* @__PURE__ */ d(
|
|
141
|
+
children: /* @__PURE__ */ d(a, { children: e })
|
|
142
142
|
}), /* @__PURE__ */ d(u, {})]
|
|
143
143
|
}));
|
|
144
144
|
return Object.assign(r, { queryClient: n });
|
|
145
145
|
}
|
|
146
|
-
function T({ children:
|
|
147
|
-
let [
|
|
148
|
-
let
|
|
146
|
+
function T({ children: e, authenticated: t = !0, ...n }) {
|
|
147
|
+
let [r] = o(() => {
|
|
148
|
+
let e = new c({ defaultOptions: { queries: {
|
|
149
149
|
retry: !1,
|
|
150
150
|
gcTime: Infinity
|
|
151
151
|
} } });
|
|
152
|
-
return
|
|
152
|
+
return t ? (b(), e.setQueryData(["schema", !0], n.schema ?? m())) : i.setState({
|
|
153
153
|
user: null,
|
|
154
154
|
isAuthenticated: !1,
|
|
155
155
|
activeTenant: null,
|
|
156
156
|
tenants: []
|
|
157
|
-
}), S(
|
|
157
|
+
}), S(n), e;
|
|
158
158
|
});
|
|
159
159
|
return /* @__PURE__ */ f(l, {
|
|
160
|
-
client:
|
|
160
|
+
client: r,
|
|
161
161
|
children: [/* @__PURE__ */ d(s, {
|
|
162
|
-
initialEntries: [
|
|
163
|
-
children: /* @__PURE__ */ d(
|
|
162
|
+
initialEntries: [n.route ?? "/"],
|
|
163
|
+
children: /* @__PURE__ */ d(a, { children: e })
|
|
164
164
|
}), /* @__PURE__ */ d(u, {})]
|
|
165
165
|
});
|
|
166
166
|
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Lt as e, Nt as t, Pt as n } from "./ActionRunner-B2e3Igpd.js";
|
|
2
|
+
import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
|
|
3
|
+
//#region src/embed/file-src.ts
|
|
4
|
+
var s = "/api/files";
|
|
5
|
+
function c(e) {
|
|
6
|
+
if (typeof e != "object" || !e) return !1;
|
|
7
|
+
let t = e;
|
|
8
|
+
return typeof t.url == "string" && typeof t.proxy == "boolean";
|
|
9
|
+
}
|
|
10
|
+
function l(e, t) {
|
|
11
|
+
let n = encodeURIComponent(e);
|
|
12
|
+
return typeof t == "object" ? `${s}/${n}/derived/${encodeURIComponent(t.derivation)}/url` : `${s}/${n}/url`;
|
|
13
|
+
}
|
|
14
|
+
var u = class extends Error {
|
|
15
|
+
fileId;
|
|
16
|
+
key;
|
|
17
|
+
constructor(e, t) {
|
|
18
|
+
super(`derivation "${t}" of file ${e} is still generating`), this.fileId = e, this.key = t, this.name = "DerivationPendingError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function d(e, t) {
|
|
22
|
+
return {
|
|
23
|
+
method: "GET",
|
|
24
|
+
credentials: "omit",
|
|
25
|
+
headers: { Authorization: `Bearer ${e}` },
|
|
26
|
+
signal: t
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function f(e) {
|
|
30
|
+
return `${e}${e.includes("?") ? "&" : "?"}disposition=attachment`;
|
|
31
|
+
}
|
|
32
|
+
async function p(e, r) {
|
|
33
|
+
let i = await t(), a = await fetch(e, d(i, r));
|
|
34
|
+
if (a.status !== 401) return a;
|
|
35
|
+
n();
|
|
36
|
+
let o = await t();
|
|
37
|
+
return fetch(e, d(o, r));
|
|
38
|
+
}
|
|
39
|
+
async function m(t, n, r) {
|
|
40
|
+
if (!e()) throw Error("resolveEmbedFileSrc called outside embed token mode");
|
|
41
|
+
let i = await p(l(t, n), r);
|
|
42
|
+
if (i.status === 202 && typeof n == "object") throw new u(t, n.derivation);
|
|
43
|
+
if (!i.ok) throw Error(`embed file url request failed: ${i.status} ${i.statusText}`);
|
|
44
|
+
let a = await i.json();
|
|
45
|
+
if (!c(a)) throw Error("embed file url response is malformed");
|
|
46
|
+
if (!a.proxy) return {
|
|
47
|
+
url: a.url,
|
|
48
|
+
kind: "direct"
|
|
49
|
+
};
|
|
50
|
+
if (!a.url.startsWith("/api/files/")) throw Error(`embed file proxy: refusing non-files-route URL ${JSON.stringify(a.url)}`);
|
|
51
|
+
let o = await p(n === "download" ? f(a.url) : a.url, r);
|
|
52
|
+
if (!o.ok) throw Error(`embed file proxy fetch failed: ${o.status} ${o.statusText}`);
|
|
53
|
+
let s = await o.blob();
|
|
54
|
+
return {
|
|
55
|
+
url: URL.createObjectURL(s),
|
|
56
|
+
kind: "blob"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/components/file-widgets/helpers.ts
|
|
61
|
+
var h = ["thumb_200", "thumb_300"];
|
|
62
|
+
function g() {
|
|
63
|
+
return typeof navigator > "u" ? ["en"] : (navigator.languages?.length ? navigator.languages : [navigator.language]).filter((e) => typeof e == "string" && e.length > 0);
|
|
64
|
+
}
|
|
65
|
+
function _(e, t) {
|
|
66
|
+
for (let n of t) {
|
|
67
|
+
if (e[n]) return e[n];
|
|
68
|
+
let t = n.split("-")[0];
|
|
69
|
+
if (t && e[t]) return e[t];
|
|
70
|
+
}
|
|
71
|
+
for (let t of Object.values(e)) if (typeof t == "string" && t.length > 0) return t;
|
|
72
|
+
}
|
|
73
|
+
function v(e, t, n) {
|
|
74
|
+
if (t) return t;
|
|
75
|
+
let r = e?.metadata?.alt_text;
|
|
76
|
+
if (typeof r == "string" && r.length > 0) return r;
|
|
77
|
+
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
78
|
+
let e = _(Object.fromEntries(Object.entries(r).filter((e) => e[0].length > 0 && typeof e[1] == "string")), g());
|
|
79
|
+
if (e) return e;
|
|
80
|
+
}
|
|
81
|
+
return n;
|
|
82
|
+
}
|
|
83
|
+
var y = new Set([
|
|
84
|
+
"image/png",
|
|
85
|
+
"image/jpeg",
|
|
86
|
+
"image/webp",
|
|
87
|
+
"image/gif",
|
|
88
|
+
"image/avif",
|
|
89
|
+
"application/pdf"
|
|
90
|
+
]);
|
|
91
|
+
function b(e) {
|
|
92
|
+
let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
93
|
+
return y.has(t);
|
|
94
|
+
}
|
|
95
|
+
function x(e) {
|
|
96
|
+
return e.url ?? e.presigned_url;
|
|
97
|
+
}
|
|
98
|
+
function S(e) {
|
|
99
|
+
return e.url ? T(e.url, "attachment") : e.presigned_url;
|
|
100
|
+
}
|
|
101
|
+
function C(e, t) {
|
|
102
|
+
if (!e) return;
|
|
103
|
+
let n = e.derivations ?? {};
|
|
104
|
+
if (t && n[t]) return n[t];
|
|
105
|
+
for (let e of h) if (n[e]) return n[e];
|
|
106
|
+
return e.url ?? e.presigned_url;
|
|
107
|
+
}
|
|
108
|
+
function w(e, t) {
|
|
109
|
+
let n = e?.derivations ?? {};
|
|
110
|
+
if (t && n[t]) return { derivation: t };
|
|
111
|
+
for (let e of h) if (n[e]) return { derivation: e };
|
|
112
|
+
return "preview";
|
|
113
|
+
}
|
|
114
|
+
function T(e, t) {
|
|
115
|
+
try {
|
|
116
|
+
let n = new URL(e, typeof window < "u" ? window.location.origin : "http://localhost");
|
|
117
|
+
return n.searchParams.set("disposition", t), /^https?:\/\//i.test(e) ? n.toString() : `${n.pathname}${n.search}${n.hash}`;
|
|
118
|
+
} catch {
|
|
119
|
+
return `${e}${e.includes("?") ? "&" : "?"}disposition=${t}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function E(e) {
|
|
123
|
+
let t = e?.metadata?.focal_point;
|
|
124
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
125
|
+
let n = t, r = typeof n.x == "number" ? n.x : NaN, i = typeof n.y == "number" ? n.y : NaN;
|
|
126
|
+
return !Number.isFinite(r) || !Number.isFinite(i) || r < 0 || r > 1 || i < 0 || i > 1 ? null : {
|
|
127
|
+
x: r,
|
|
128
|
+
y: i
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function D(e) {
|
|
132
|
+
if (e) return `${e.x * 100}% ${e.y * 100}%`;
|
|
133
|
+
}
|
|
134
|
+
function O(e, t) {
|
|
135
|
+
return {
|
|
136
|
+
...e,
|
|
137
|
+
metadata: {
|
|
138
|
+
...e.metadata ?? {},
|
|
139
|
+
focal_point: t
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/components/file-widgets/useEmbedFileSrc.ts
|
|
145
|
+
function k(e) {
|
|
146
|
+
return typeof e == "object" ? `derivation:${e.derivation}` : e;
|
|
147
|
+
}
|
|
148
|
+
function A(e) {
|
|
149
|
+
return e.startsWith("derivation:") ? { derivation: e.slice(11) } : e === "download" ? "download" : "preview";
|
|
150
|
+
}
|
|
151
|
+
function j(t, n, r) {
|
|
152
|
+
let a = k(n), [s, c] = o(() => e() ? void 0 : r);
|
|
153
|
+
return i(() => {
|
|
154
|
+
e() || c(r);
|
|
155
|
+
}, [r]), i(() => {
|
|
156
|
+
if (!e()) return;
|
|
157
|
+
if (!t) {
|
|
158
|
+
c(void 0);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
let n = null, r = !1, i = new AbortController();
|
|
162
|
+
return c(void 0), m(t, A(a), i.signal).then((e) => {
|
|
163
|
+
if (r) {
|
|
164
|
+
e.kind === "blob" && URL.revokeObjectURL(e.url);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
e.kind === "blob" && (n = e.url), c(e.url);
|
|
168
|
+
}).catch((e) => {
|
|
169
|
+
if (!r) {
|
|
170
|
+
if (e instanceof u) {
|
|
171
|
+
c(void 0);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
e instanceof DOMException && e.name === "AbortError" || (console.error("[declarion-embed] file src resolution failed:", e), c(void 0));
|
|
175
|
+
}
|
|
176
|
+
}), () => {
|
|
177
|
+
r = !0, i.abort(), n && URL.revokeObjectURL(n);
|
|
178
|
+
};
|
|
179
|
+
}, [t, a]), s;
|
|
180
|
+
}
|
|
181
|
+
function M() {
|
|
182
|
+
let t = a([]);
|
|
183
|
+
return i(() => () => {
|
|
184
|
+
for (let e of t.current) URL.revokeObjectURL(e);
|
|
185
|
+
t.current = [];
|
|
186
|
+
}, []), { open: r((n, r, i) => {
|
|
187
|
+
if (!e()) {
|
|
188
|
+
i && window.open(i, "_blank", "noopener");
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
n && m(n, r).then((e) => {
|
|
192
|
+
e.kind === "blob" && t.current.push(e.url), window.open(e.url, "_blank", "noopener");
|
|
193
|
+
}).catch((e) => {
|
|
194
|
+
e instanceof u || console.error("[declarion-embed] file open failed:", e);
|
|
195
|
+
});
|
|
196
|
+
}, []) };
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/components/file-widgets/value.ts
|
|
200
|
+
function N(e) {
|
|
201
|
+
return typeof e == "object" && !!e && typeof e.id == "string";
|
|
202
|
+
}
|
|
203
|
+
function P(e) {
|
|
204
|
+
return e ? Array.isArray(e) ? e.find(N) ?? null : N(e) ? e : null : null;
|
|
205
|
+
}
|
|
206
|
+
function F(e) {
|
|
207
|
+
return e ? Array.isArray(e) ? e.filter(N) : N(e) ? [e] : [] : [];
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
export { b as a, C as c, E as d, v as f, j as i, w as l, P as n, S as o, O as p, M as r, D as s, F as t, x as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@declarion/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React SDK for Declarion, the schema-driven business apps platform.",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"LICENSE",
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
|
+
"sideEffects": [
|
|
41
|
+
"**/*.css"
|
|
42
|
+
],
|
|
40
43
|
"publishConfig": {
|
|
41
44
|
"access": "public"
|
|
42
45
|
},
|