@ynput/ayon-frontend-shared 0.6.5 → 0.6.6
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/ProjectTreeTable.es.js +645 -653
- package/dist/chunks/Feed.es.js +1742 -1733
- package/dist/chunks/Menu.es.js +168 -166
- package/dist/chunks/MenuItem.es.js +112 -77
- package/dist/chunks/SimpleForm.es.js +78 -75
- package/dist/chunks/getUris.es.js +171 -172
- package/dist/chunks/queryFilterToClientFilter.es.js +90 -81
- package/dist/chunks/searchTerms.es.js +3 -0
- package/dist/types/Feed.d.ts +1 -1
- package/dist/types/ProjectTreeTable.d.ts +3 -5
- package/dist/types/Slicer.d.ts +1 -1
- package/dist/types/Views.d.ts +2 -2
- package/dist/types/api.d.ts +9 -5
- package/dist/types/components.d.ts +9 -2
- package/dist/types/context.d.ts +2 -2
- package/dist/types/util.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { jsx as c, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { getTextColor as
|
|
4
|
-
import { a$ as
|
|
1
|
+
import { jsx as c, jsxs as V, Fragment as B } from "react/jsx-runtime";
|
|
2
|
+
import { useState as _, useEffect as v, useMemo as D, useRef as R, useCallback as K } from "react";
|
|
3
|
+
import { getTextColor as P, InputTextarea as W, InputText as z, InputSwitch as M, InputNumber as C, Dropdown as F, DefaultItemTemplate as U, FormLayout as q, FormRow as G } from "@ynput/ayon-react-components";
|
|
4
|
+
import { a$ as J } from "./searchTerms.es.js";
|
|
5
5
|
import "./getUris.es.js";
|
|
6
6
|
import "primereact/confirmdialog";
|
|
7
7
|
import b from "styled-components";
|
|
8
|
-
import
|
|
8
|
+
import Q from "react-markdown";
|
|
9
9
|
import { toast as A } from "react-toastify";
|
|
10
|
-
import { p as
|
|
11
|
-
const
|
|
10
|
+
import { p as H } from "./parseFilename.es.js";
|
|
11
|
+
const X = (e, r) => {
|
|
12
12
|
const t = {};
|
|
13
13
|
return e.forEach((n) => {
|
|
14
14
|
n.name in r ? t[n.name] = r[n.name] : n.value ? t[n.name] = n.value : n.type === "boolean" ? t[n.name] = !1 : n.type === "integer" || n.type === "float" ? t[n.name] = 0 : n.type === "text" ? t[n.name] = "" : n.type === "multiselect" ? t[n.name] = [] : n.type === "file" && (t[n.name] = void 0);
|
|
15
15
|
}), t;
|
|
16
|
-
}, w = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, g = (e) => Array.isArray(e) ? e : w(e) ? [] : [e],
|
|
16
|
+
}, w = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, g = (e) => Array.isArray(e) ? e : w(e) ? [] : [e], Y = (e) => "conditions" in e, E = (e, r) => {
|
|
17
|
+
if (typeof e != "string" || typeof r != "string") return !1;
|
|
18
|
+
const t = r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/%/g, ".*").replace(/_/g, ".");
|
|
19
|
+
try {
|
|
20
|
+
return new RegExp(`^${t}$`, "i").test(e);
|
|
21
|
+
} catch {
|
|
22
|
+
return !1;
|
|
23
|
+
}
|
|
24
|
+
}, Z = (e, r) => {
|
|
17
25
|
const t = r[e.key], n = e.value;
|
|
18
26
|
switch (e.operator || "eq") {
|
|
19
27
|
case "isnull":
|
|
@@ -32,15 +40,10 @@ const H = (e, r) => {
|
|
|
32
40
|
return typeof t == "number" && typeof n == "number" && t <= n;
|
|
33
41
|
case "gte":
|
|
34
42
|
return typeof t == "number" && typeof n == "number" && t >= n;
|
|
35
|
-
case "like":
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return new RegExp(`^${o}$`, "i").test(t);
|
|
40
|
-
} catch {
|
|
41
|
-
return !1;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
43
|
+
case "like":
|
|
44
|
+
return E(t, n);
|
|
45
|
+
case "notlike":
|
|
46
|
+
return typeof n == "string" && !E(t, n);
|
|
44
47
|
case "in":
|
|
45
48
|
return Array.isArray(n) && n.includes(t);
|
|
46
49
|
case "notin":
|
|
@@ -60,34 +63,34 @@ const H = (e, r) => {
|
|
|
60
63
|
default:
|
|
61
64
|
return !1;
|
|
62
65
|
}
|
|
63
|
-
},
|
|
66
|
+
}, j = (e, r) => {
|
|
64
67
|
const t = e.conditions || [];
|
|
65
68
|
if (t.length === 0) return !0;
|
|
66
69
|
const n = t.map(
|
|
67
|
-
(s) =>
|
|
70
|
+
(s) => Y(s) ? j(s, r) : Z(s, r)
|
|
68
71
|
);
|
|
69
72
|
return (e.operator || "and") === "and" ? n.every(Boolean) : n.some(Boolean);
|
|
70
|
-
},
|
|
73
|
+
}, ee = (e, r) => {
|
|
71
74
|
const t = {};
|
|
72
75
|
for (const n of e) {
|
|
73
76
|
if (!n.rules?.length) continue;
|
|
74
77
|
let s;
|
|
75
78
|
for (const o of n.rules)
|
|
76
|
-
|
|
79
|
+
j(o.when, r) && (s = { ...s, ...o.set });
|
|
77
80
|
s && (t[n.name] = s);
|
|
78
81
|
}
|
|
79
82
|
return t;
|
|
80
|
-
},
|
|
83
|
+
}, T = /\{\{\s*([^{}\s]+)\s*\}\}/g, te = (e) => {
|
|
81
84
|
const r = /* @__PURE__ */ new Set(), t = (n) => {
|
|
82
85
|
if (typeof n == "string")
|
|
83
|
-
for (const s of n.matchAll(
|
|
86
|
+
for (const s of n.matchAll(T)) r.add(s[1]);
|
|
84
87
|
else Array.isArray(n) ? n.forEach(t) : n && typeof n == "object" && Object.values(n).forEach(t);
|
|
85
88
|
};
|
|
86
89
|
return t(e), [...r];
|
|
87
90
|
}, x = (e, r) => {
|
|
88
91
|
if (typeof e == "string") {
|
|
89
92
|
const t = e.match(/^\{\{\s*([^{}\s]+)\s*\}\}$/);
|
|
90
|
-
return t ? r[t[1]] : e.replace(
|
|
93
|
+
return t ? r[t[1]] : e.replace(T, (n, s) => {
|
|
91
94
|
const o = r[s];
|
|
92
95
|
return w(o) ? "" : String(o);
|
|
93
96
|
});
|
|
@@ -95,8 +98,8 @@ const H = (e, r) => {
|
|
|
95
98
|
return Array.isArray(e) ? e.map((t) => x(t, r)) : e && typeof e == "object" ? Object.fromEntries(
|
|
96
99
|
Object.entries(e).map(([t, n]) => [t, x(n, r)])
|
|
97
100
|
) : e;
|
|
98
|
-
},
|
|
99
|
-
const [t, n] =
|
|
101
|
+
}, ne = (e) => e == null || e === "", re = (e, r) => {
|
|
102
|
+
const [t, n] = _({}), [s] = J(), o = e.filter((u) => !!u.enum_resolver), m = JSON.stringify(
|
|
100
103
|
o.map((u) => [
|
|
101
104
|
u.name,
|
|
102
105
|
u.enum_resolver,
|
|
@@ -108,7 +111,7 @@ const H = (e, r) => {
|
|
|
108
111
|
let u = !1;
|
|
109
112
|
return o.forEach(async (a) => {
|
|
110
113
|
const l = a.enum_resolver_params || {};
|
|
111
|
-
if (
|
|
114
|
+
if (te(l).some((p) => ne(r[p]))) {
|
|
112
115
|
n((p) => ({ ...p, [a.name]: { options: [], loading: !1 } }));
|
|
113
116
|
return;
|
|
114
117
|
}
|
|
@@ -132,12 +135,12 @@ const H = (e, r) => {
|
|
|
132
135
|
u = !0;
|
|
133
136
|
};
|
|
134
137
|
}, [m]), t;
|
|
135
|
-
},
|
|
136
|
-
const [t, n] =
|
|
138
|
+
}, oe = (e, r) => {
|
|
139
|
+
const [t, n] = _(null), s = D(() => JSON.stringify(e), [e]);
|
|
137
140
|
v(() => {
|
|
138
|
-
n((a) =>
|
|
141
|
+
n((a) => X(e, { ...r, ...a }));
|
|
139
142
|
}, [s]);
|
|
140
|
-
const o = D(() =>
|
|
143
|
+
const o = D(() => ee(e, t || {}), [e, t]), m = re(e, t || {});
|
|
141
144
|
return v(() => {
|
|
142
145
|
if (!t) return;
|
|
143
146
|
const a = {};
|
|
@@ -163,18 +166,18 @@ const H = (e, r) => {
|
|
|
163
166
|
d = i.options ?? [];
|
|
164
167
|
const f = new Set(d.map((h) => `${h.value}`)), p = t[i.name];
|
|
165
168
|
if (i.type === "multiselect") {
|
|
166
|
-
const h = Array.isArray(p) ? p : [],
|
|
167
|
-
|
|
169
|
+
const h = Array.isArray(p) ? p : [], k = h.filter((I) => f.has(`${I}`));
|
|
170
|
+
k.length !== h.length && (a[i.name] = k, l = !0);
|
|
168
171
|
} else p != null && p !== "" && !f.has(`${p}`) && (a[i.name] = void 0, l = !0);
|
|
169
172
|
}
|
|
170
173
|
l && n((i) => i && { ...i, ...a });
|
|
171
174
|
}, [e, o, m, t]), { formData: t, patches: o, resolvedOptions: m, setFieldValue: (a, l) => {
|
|
172
175
|
n((i) => ({ ...i, [a]: l }));
|
|
173
176
|
} };
|
|
174
|
-
},
|
|
177
|
+
}, ae = (e, r, t) => {
|
|
175
178
|
if (!(e.type !== "select" && e.type !== "multiselect"))
|
|
176
179
|
return r?.options ? r.options : e.enum_resolver ? t[e.name]?.options ?? [] : e.options ?? [];
|
|
177
|
-
},
|
|
180
|
+
}, se = b.div`
|
|
178
181
|
&.normal {
|
|
179
182
|
// maybe something here
|
|
180
183
|
}
|
|
@@ -197,10 +200,10 @@ const H = (e, r) => {
|
|
|
197
200
|
&.error {
|
|
198
201
|
background-color: var(--md-sys-color-on-error-dark);
|
|
199
202
|
}
|
|
200
|
-
`,
|
|
203
|
+
`, le = ({ field: e }) => {
|
|
201
204
|
const r = typeof e.value == "string" ? e.value : "Invalid label value";
|
|
202
|
-
return /* @__PURE__ */ c(
|
|
203
|
-
},
|
|
205
|
+
return /* @__PURE__ */ c(se, { className: e.highlight || "normal", children: /* @__PURE__ */ c(Q, { children: r }) });
|
|
206
|
+
}, ie = b.span`
|
|
204
207
|
overflow: hidden;
|
|
205
208
|
white-space: nowrap;
|
|
206
209
|
text-overflow: ellipsis;
|
|
@@ -213,13 +216,13 @@ const H = (e, r) => {
|
|
|
213
216
|
&.placeholder {
|
|
214
217
|
color: var(--md-sys-color-outline);
|
|
215
218
|
}
|
|
216
|
-
`,
|
|
219
|
+
`, L = ["studio", "project", "production", "staging", "developer"], ce = (e) => {
|
|
217
220
|
const { label: r, color: t, style: n, className: s, ...o } = e, m = { ...n };
|
|
218
221
|
let u;
|
|
219
|
-
t ? t.startsWith("#") || t.startsWith("rgb") ? u = t :
|
|
220
|
-
const a = u ?
|
|
222
|
+
t ? t.startsWith("#") || t.startsWith("rgb") ? u = t : L.includes(t.toLowerCase()) && (u = `var(--color-hl-${t})`) : r && L.includes(r.toLowerCase()) && (u = `var(--color-hl-${r.toLowerCase()})`);
|
|
223
|
+
const a = u ? P(u) : "#e0e0e0";
|
|
221
224
|
return m.backgroundColor = u, m.color = a, u && (m.fontSize = "0.9rem"), /* @__PURE__ */ c(
|
|
222
|
-
|
|
225
|
+
ie,
|
|
223
226
|
{
|
|
224
227
|
style: m,
|
|
225
228
|
className: s,
|
|
@@ -235,7 +238,7 @@ const H = (e, r) => {
|
|
|
235
238
|
gap: var(--base-gap-small);
|
|
236
239
|
padding: 0 4px;
|
|
237
240
|
margin-left: 12px;
|
|
238
|
-
`,
|
|
241
|
+
`, N = b.button`
|
|
239
242
|
width: auto;
|
|
240
243
|
background: none;
|
|
241
244
|
border: none;
|
|
@@ -244,7 +247,7 @@ const H = (e, r) => {
|
|
|
244
247
|
cursor: pointer;
|
|
245
248
|
padding: 2px;
|
|
246
249
|
font: inherit;
|
|
247
|
-
`,
|
|
250
|
+
`, ue = b.div`
|
|
248
251
|
border: 2px dashed var(--md-sys-color-outline);
|
|
249
252
|
border-radius: 8px;
|
|
250
253
|
display: flex;
|
|
@@ -257,13 +260,13 @@ const H = (e, r) => {
|
|
|
257
260
|
input {
|
|
258
261
|
display: none;
|
|
259
262
|
}
|
|
260
|
-
`,
|
|
261
|
-
const r =
|
|
263
|
+
`, pe = (e) => {
|
|
264
|
+
const r = R(null), t = D(
|
|
262
265
|
() => e.validExtensions?.map(
|
|
263
266
|
(a) => a.startsWith(".") ? a.toLowerCase() : `.${a.toLowerCase()}`
|
|
264
267
|
),
|
|
265
268
|
[e.validExtensions]
|
|
266
|
-
), n =
|
|
269
|
+
), n = K(
|
|
267
270
|
(a) => {
|
|
268
271
|
if (a) {
|
|
269
272
|
if (a.size === 0) {
|
|
@@ -282,7 +285,7 @@ const H = (e, r) => {
|
|
|
282
285
|
}
|
|
283
286
|
}
|
|
284
287
|
if (a) {
|
|
285
|
-
const l =
|
|
288
|
+
const l = H(a.name), i = new FileReader();
|
|
286
289
|
i.onload = () => {
|
|
287
290
|
const y = i.result.split(",")[1];
|
|
288
291
|
e.onChange({ payload: y, filename: l });
|
|
@@ -292,7 +295,7 @@ const H = (e, r) => {
|
|
|
292
295
|
},
|
|
293
296
|
[e, t]
|
|
294
297
|
);
|
|
295
|
-
return /* @__PURE__ */
|
|
298
|
+
return /* @__PURE__ */ V(ue, { onDragOver: (a) => {
|
|
296
299
|
a.preventDefault();
|
|
297
300
|
}, onDragLeave: (a) => {
|
|
298
301
|
a.preventDefault();
|
|
@@ -315,25 +318,25 @@ const H = (e, r) => {
|
|
|
315
318
|
style: { display: "none" }
|
|
316
319
|
}
|
|
317
320
|
),
|
|
318
|
-
/* @__PURE__ */ c(
|
|
321
|
+
/* @__PURE__ */ c(N, { type: "button", onClick: () => r.current?.click(), children: e.value ? `Change file (${e.value.filename})` : "Upload file" })
|
|
319
322
|
] });
|
|
320
|
-
},
|
|
323
|
+
}, me = b.div`
|
|
321
324
|
display: flex;
|
|
322
325
|
flex-direction: row;
|
|
323
326
|
align-items: center;
|
|
324
327
|
justify-content: flex-start;
|
|
325
328
|
background: none;
|
|
326
329
|
border: none;
|
|
327
|
-
`,
|
|
330
|
+
`, de = (e) => /* @__PURE__ */ c(me, { children: /* @__PURE__ */ c(N, { onClick: () => {
|
|
328
331
|
const t = document.createElement("a");
|
|
329
332
|
t.href = `data:application/octet-stream;base64,${e.value.payload}`, t.download = e.value.filename, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
330
333
|
}, children: e.value.filename }) }), $ = (e) => {
|
|
331
|
-
const r = /* @__PURE__ */
|
|
334
|
+
const r = /* @__PURE__ */ V(B, { children: [
|
|
332
335
|
/* @__PURE__ */ c("div", { style: { flex: 1 } }),
|
|
333
|
-
e.badges && e.badges.map((t, n) => /* @__PURE__ */ c(
|
|
336
|
+
e.badges && e.badges.map((t, n) => /* @__PURE__ */ c(ce, { label: t }, n))
|
|
334
337
|
] });
|
|
335
338
|
return /* @__PURE__ */ c(
|
|
336
|
-
|
|
339
|
+
U,
|
|
337
340
|
{
|
|
338
341
|
option: e,
|
|
339
342
|
dataKey: "value",
|
|
@@ -342,12 +345,12 @@ const H = (e, r) => {
|
|
|
342
345
|
endContent: r
|
|
343
346
|
}
|
|
344
347
|
);
|
|
345
|
-
},
|
|
348
|
+
}, S = (e = []) => e.map((r) => ({ ...r, value: `${r.value}` })), O = (e = [], r) => e.find((t) => `${t.value}` === r)?.value ?? r, ye = ({ field: e, value: r, onChange: t }) => {
|
|
346
349
|
const n = !!(e.disabled || e.readOnly);
|
|
347
350
|
if (e.type === "text") {
|
|
348
351
|
const s = typeof r == "string" ? r : "";
|
|
349
352
|
return e.multiline ? /* @__PURE__ */ c(
|
|
350
|
-
|
|
353
|
+
W,
|
|
351
354
|
{
|
|
352
355
|
value: s,
|
|
353
356
|
onChange: (o) => t(o.target.value),
|
|
@@ -355,7 +358,7 @@ const H = (e, r) => {
|
|
|
355
358
|
disabled: n
|
|
356
359
|
}
|
|
357
360
|
) : /* @__PURE__ */ c(
|
|
358
|
-
|
|
361
|
+
z,
|
|
359
362
|
{
|
|
360
363
|
value: s,
|
|
361
364
|
onChange: (o) => t(o.target.value),
|
|
@@ -365,12 +368,12 @@ const H = (e, r) => {
|
|
|
365
368
|
);
|
|
366
369
|
}
|
|
367
370
|
if (e.type === "boolean")
|
|
368
|
-
return /* @__PURE__ */ c(
|
|
371
|
+
return /* @__PURE__ */ c(M, { checked: typeof r == "boolean" ? r : !1, onChange: (m) => {
|
|
369
372
|
"target" in m && "checked" in m.target && t(m.target.checked);
|
|
370
373
|
}, disabled: n });
|
|
371
374
|
if (e.type === "integer")
|
|
372
375
|
return /* @__PURE__ */ c(
|
|
373
|
-
|
|
376
|
+
C,
|
|
374
377
|
{
|
|
375
378
|
value: typeof r == "number" ? r : 0,
|
|
376
379
|
onChange: (o) => t(parseInt(o.target.value)),
|
|
@@ -380,7 +383,7 @@ const H = (e, r) => {
|
|
|
380
383
|
);
|
|
381
384
|
if (e.type === "float")
|
|
382
385
|
return /* @__PURE__ */ c(
|
|
383
|
-
|
|
386
|
+
C,
|
|
384
387
|
{
|
|
385
388
|
type: "number",
|
|
386
389
|
value: typeof r == "number" ? r : 0,
|
|
@@ -395,9 +398,9 @@ const H = (e, r) => {
|
|
|
395
398
|
F,
|
|
396
399
|
{
|
|
397
400
|
widthExpand: !0,
|
|
398
|
-
options:
|
|
401
|
+
options: S(e.options),
|
|
399
402
|
value: s ? [s] : [],
|
|
400
|
-
onSelectionChange: (o) => t(
|
|
403
|
+
onSelectionChange: (o) => t(O(e.options, o[0])),
|
|
401
404
|
className: "form-field",
|
|
402
405
|
multiSelect: !1,
|
|
403
406
|
itemTemplate: $,
|
|
@@ -412,9 +415,9 @@ const H = (e, r) => {
|
|
|
412
415
|
F,
|
|
413
416
|
{
|
|
414
417
|
widthExpand: !0,
|
|
415
|
-
options:
|
|
418
|
+
options: S(e.options),
|
|
416
419
|
value: s,
|
|
417
|
-
onSelectionChange: (o) => t(o.map((m) =>
|
|
420
|
+
onSelectionChange: (o) => t(o.map((m) => O(e.options, m))),
|
|
418
421
|
className: "form-field",
|
|
419
422
|
multiSelect: !0,
|
|
420
423
|
itemTemplate: $,
|
|
@@ -424,20 +427,20 @@ const H = (e, r) => {
|
|
|
424
427
|
);
|
|
425
428
|
}
|
|
426
429
|
if (e.type === "file")
|
|
427
|
-
return r && r?.download ? /* @__PURE__ */ c(
|
|
428
|
-
|
|
430
|
+
return r && r?.download ? /* @__PURE__ */ c(de, { value: r }) : /* @__PURE__ */ c(
|
|
431
|
+
pe,
|
|
429
432
|
{
|
|
430
433
|
value: r,
|
|
431
434
|
onChange: t,
|
|
432
435
|
validExtensions: e.valid_extensions
|
|
433
436
|
}
|
|
434
437
|
);
|
|
435
|
-
},
|
|
436
|
-
const { formData: o, patches: m, resolvedOptions: u, setFieldValue: a } =
|
|
438
|
+
}, Fe = ({ fields: e, values: r, onChange: t, className: n, style: s }) => {
|
|
439
|
+
const { formData: o, patches: m, resolvedOptions: u, setFieldValue: a } = oe(e, r);
|
|
437
440
|
return v(() => {
|
|
438
441
|
o && t?.(o);
|
|
439
442
|
}, [o]), o ? /* @__PURE__ */ c(
|
|
440
|
-
|
|
443
|
+
q,
|
|
441
444
|
{
|
|
442
445
|
className: n,
|
|
443
446
|
style: s,
|
|
@@ -445,11 +448,11 @@ const H = (e, r) => {
|
|
|
445
448
|
l.stopPropagation();
|
|
446
449
|
},
|
|
447
450
|
children: e.map((l) => {
|
|
448
|
-
const i = m[l.name], y =
|
|
451
|
+
const i = m[l.name], y = ae(l, i, u), d = { ...l, ...i };
|
|
449
452
|
y !== void 0 && (d.options = y, l.enum_resolver && u[l.name]?.loading && d.placeholder === void 0 && (d.placeholder = "Loading..."));
|
|
450
453
|
const f = {};
|
|
451
|
-
return d.hidden && (f.display = "none"), d.type === "label" ? /* @__PURE__ */ c(
|
|
452
|
-
|
|
454
|
+
return d.hidden && (f.display = "none"), d.type === "label" ? /* @__PURE__ */ c(le, { field: d }, l.name) : /* @__PURE__ */ c(G, { label: d.label || "", style: f, children: /* @__PURE__ */ c(
|
|
455
|
+
ye,
|
|
453
456
|
{
|
|
454
457
|
field: d,
|
|
455
458
|
value: o[l.name],
|
|
@@ -461,7 +464,7 @@ const H = (e, r) => {
|
|
|
461
464
|
) : null;
|
|
462
465
|
};
|
|
463
466
|
export {
|
|
464
|
-
|
|
465
|
-
|
|
467
|
+
ce as B,
|
|
468
|
+
Fe as S,
|
|
466
469
|
Ce as a
|
|
467
470
|
};
|