@ynput/ayon-frontend-shared 0.4.7 → 0.5.0

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.
Files changed (48) hide show
  1. package/dist/DetailsPanel.es.js +684 -651
  2. package/dist/ListTable.es.js +8 -7
  3. package/dist/ProjectTreeTable.es.js +2223 -2184
  4. package/dist/Slicer.es.js +152 -120
  5. package/dist/api.es.js +202 -201
  6. package/dist/chunks/Actions.es.js +20 -20
  7. package/dist/chunks/ColumnDropIndicator.es.js +127 -241
  8. package/dist/chunks/DeleteEntitiesContext.es.js +36 -36
  9. package/dist/chunks/DetailsDialog.es.js +3 -3
  10. package/dist/chunks/EntityPath.es.js +22 -22
  11. package/dist/chunks/EntityPickerDialog.es.js +1 -1
  12. package/dist/chunks/EntityTooltip.es.js +12 -12
  13. package/dist/chunks/Feed.es.js +2 -2
  14. package/dist/chunks/FilterErrorActions.es.js +5 -5
  15. package/dist/chunks/GlobalContext.es.js +14 -14
  16. package/dist/chunks/InfoMessage.es.js +146 -0
  17. package/dist/chunks/Menu.es.js +5 -5
  18. package/dist/chunks/MenuContext.es.js +75 -73
  19. package/dist/chunks/MetaWidget.es.js +1968 -1960
  20. package/dist/chunks/NewEntityContext.es.js +538 -543
  21. package/dist/chunks/PlayableIcon.es.js +54 -54
  22. package/dist/chunks/ProjectContext.es.js +12 -12
  23. package/dist/chunks/ProjectFoldersContext.es.js +84 -76
  24. package/dist/chunks/RepresentationsList.es.js +1 -1
  25. package/dist/chunks/ReviewablesSelector.es.js +387 -384
  26. package/dist/chunks/SimpleTable.es.js +286 -283
  27. package/dist/chunks/Slicer.es.js +1121 -683
  28. package/dist/chunks/VersionUploadContext.es.js +26 -26
  29. package/dist/chunks/ViewsContext.es.js +31 -31
  30. package/dist/chunks/Watchers.es.js +1 -1
  31. package/dist/chunks/entityDefinitions.es.js +275 -133
  32. package/dist/chunks/getUris.es.js +236 -231
  33. package/dist/chunks/searchTerms.es.js +9 -0
  34. package/dist/chunks/useAttributeEnums.es.js +69 -61
  35. package/dist/chunks/useLocalStorage.es.js +10 -10
  36. package/dist/chunks/viewUpdateHelper.es.js +23 -23
  37. package/dist/components.es.js +166 -166
  38. package/dist/hooks.es.js +44 -43
  39. package/dist/index.es.js +11 -10
  40. package/dist/types/DetailsPanel.d.ts +6 -0
  41. package/dist/types/ProjectTreeTable.d.ts +28 -6
  42. package/dist/types/RepresentationsList.d.ts +3 -0
  43. package/dist/types/SimpleTable.d.ts +1 -0
  44. package/dist/types/Slicer.d.ts +103 -18
  45. package/dist/types/api.d.ts +13 -0
  46. package/dist/types/components.d.ts +7 -5
  47. package/package.json +11 -10
  48. package/dist/chunks/useSlicerSplitter.es.js +0 -18
@@ -1,214 +1,447 @@
1
- import { jsxs as Q, jsx as R, Fragment as ve } from "react/jsx-runtime";
2
- import { useContext as xe, useMemo as _, useCallback as M, useState as j, useEffect as ae, forwardRef as we, useRef as le, useId as Le, useImperativeHandle as Ce } from "react";
3
- import { b as De, a as Ee, H as ke, d as Re, S as Me } from "./SimpleTable.es.js";
4
- import { u as Ae, E as Oe } from "./EntityPickerDialog.es.js";
5
- import { bp as Fe, bf as ye, bn as _e, be as de } from "./searchTerms.es.js";
6
- import { cD as Ne, bQ as Pe, bw as je, dj as ge } from "./getUris.es.js";
1
+ import { jsx as E, jsxs as G, Fragment as $e } from "react/jsx-runtime";
2
+ import { useState as U, useCallback as A, useMemo as O, useContext as Ye, useEffect as se, forwardRef as Je, useRef as ye, useId as Xe, useImperativeHandle as Ze, useLayoutEffect as Te } from "react";
3
+ import { Splitter as et, SplitterPanel as tt } from "primereact/splitter";
4
+ import V from "styled-components";
5
+ import { u as Ie, n as me } from "./entityDefinitions.es.js";
6
+ import { f as ze, c as nt, u as st } from "./MenuContext.es.js";
7
+ import { u as Ce } from "./useLocalStorage.es.js";
8
+ import { u as we } from "./ProjectFoldersContext.es.js";
9
+ import { E as ot, u as at } from "./EntityPickerDialog.es.js";
10
+ import { toast as Re } from "react-toastify";
11
+ import { be as De, bp as it, bf as Ue, bn as rt } from "./searchTerms.es.js";
12
+ import { dk as Ve, cE as lt, bR as ct, bx as dt } from "./getUris.es.js";
7
13
  import "primereact/confirmdialog";
8
- import { a as H } from "./ProjectContext.es.js";
9
- import { b as se, n as W } from "./entityDefinitions.es.js";
10
- import { u as Ue } from "./GlobalContext.es.js";
11
- import { P as Ve, U as he, h as $e } from "./MetaWidget.es.js";
14
+ import { h as ut, P as pt, U as He } from "./MetaWidget.es.js";
12
15
  import "lodash";
13
- import { toast as ce } from "react-toastify";
14
16
  import "uuid";
15
- import { u as Be, a as He } from "./useAttributeEnums.es.js";
16
- import { u as Ke } from "./useLocalStorage.es.js";
17
- import { g as z } from "./getEntityTypeIcon.es.js";
18
- import { b as qe, s as Ge } from "./buildHierarchicalTableRows.es.js";
19
- import { g as We } from "./parseHtmlToPlainTextWithLinks.es.js";
20
- import { InputText as ze, Button as Qe } from "@ynput/ayon-react-components";
21
- import ie from "clsx";
22
- import K from "styled-components";
23
- import { u as Ye } from "./NewEntityContext.es.js";
24
- import { a as Xe, K as Je } from "./platform.es.js";
25
- import { c as Ze, u as et } from "./MenuContext.es.js";
26
- import { g as tt } from "./DeleteEntitiesContext.es.js";
27
- import { u as nt } from "./VersionUploadContext.es.js";
28
- import { u as at, b as ot, F as ue } from "./EntityUpdatesContext.es.js";
17
+ import { b as he, H as ft, a as mt, d as ht, S as gt } from "./SimpleTable.es.js";
18
+ import { a as ue } from "./ProjectContext.es.js";
19
+ import { u as yt } from "./GlobalContext.es.js";
20
+ import { u as bt, a as St } from "./useAttributeEnums.es.js";
21
+ import { g as ge } from "./getEntityTypeIcon.es.js";
22
+ import { b as Tt, s as vt } from "./buildHierarchicalTableRows.es.js";
23
+ import { g as xt } from "./parseHtmlToPlainTextWithLinks.es.js";
24
+ import { InputText as It, Button as Ct, Icon as wt } from "@ynput/ayon-react-components";
25
+ import W from "clsx";
26
+ import { u as Lt } from "./NewEntityContext.es.js";
27
+ import { a as Et, K as kt } from "./platform.es.js";
28
+ import { g as Rt } from "./DeleteEntitiesContext.es.js";
29
+ import { u as Dt } from "./VersionUploadContext.es.js";
30
+ import { u as Pt, b as Mt, F as Pe } from "./EntityUpdatesContext.es.js";
29
31
  import "./MenuItem.es.js";
30
32
  import "@module-federation/enhanced/runtime";
31
33
  import "semver";
32
34
  import "react-dom";
33
- import { u as be } from "./ProjectFoldersContext.es.js";
34
- const st = ({ projectName: a, useExtraSlices: n }) => {
35
- const [i, { isLoading: l, isFetching: d }] = Ne(), { formatAssignees: r } = n();
35
+ const _t = 180, Be = 100, Ge = 34, At = (e, t = [], a = Be) => e.map((r) => t.includes(r) ? Ge : a), Ot = (e, t, a, r) => {
36
+ const d = e.reduce((p, g) => p + g, 0), l = r.filter(Boolean).length;
37
+ if (!l || d === a) return e;
38
+ if (d < a) {
39
+ const p = (a - d) / l;
40
+ return e.map((g, L) => r[L] ? g + p : g);
41
+ }
42
+ const f = e.map((p, g) => r[g] ? p - t[g] : 0), S = f.reduce((p, g) => p + g, 0);
43
+ if (!S) return e;
44
+ const m = d - a;
45
+ return e.map((p, g) => p - m * (f[g] / S));
46
+ }, Nt = (e, t, a = [], r = 0, d = _t) => {
47
+ if (!t.length)
48
+ return { heights: [], mins: [], sizes: [], minSize: 2, height: r };
49
+ const l = t.filter((h) => !a.includes(h)).length, f = (t.length - l) * Ge, S = r && l ? Math.min(
50
+ d,
51
+ Math.max(
52
+ Be,
53
+ Math.floor((r - f) / l)
54
+ )
55
+ ) : d, m = At(t, a), p = t.map(
56
+ (h, i) => a.includes(h) ? m[i] : Math.max(e[h] ?? S, m[i])
57
+ ), g = t.map((h) => !a.includes(h)), L = m.reduce((h, i) => h + i, 0), u = g.some(Boolean) ? Math.max(r, L) : L, b = Ot(p, m, u, g);
58
+ return {
59
+ heights: b,
60
+ mins: m,
61
+ sizes: b.map((h) => h / u * 100),
62
+ // primereact must allow the drag past the min; clampDraggedHeights puts it back
63
+ minSize: 2,
64
+ height: u
65
+ };
66
+ }, jt = (e, t, a) => {
67
+ const r = e.map((m, p) => Math.max(m / 100 * t, a[p])), d = Math.max(
68
+ t,
69
+ a.reduce((m, p) => m + p, 0)
70
+ ), l = r.reduce((m, p) => m + p, 0) - d;
71
+ if (l <= 0) return r;
72
+ const f = r.map((m, p) => m - a[p]), S = f.reduce((m, p) => m + p, 0);
73
+ return S ? r.map((m, p) => m - l * (f[p] / S)) : r;
74
+ }, Ft = "slicer-splitter", Me = {
75
+ minSize: 2,
76
+ size: 12
77
+ }, Yn = () => {
78
+ const [e, t] = ze(Ft, [
79
+ Me.size,
80
+ 100 - Me.size
81
+ ]);
82
+ return [e, (r) => {
83
+ t(r.sizes);
84
+ }];
85
+ }, $t = (e, t, a = [], r = 0) => {
86
+ const [d, l] = ze(
87
+ `slicer-panel-heights-${e}`,
88
+ {}
89
+ ), [f, S] = U(0), m = Array.isArray(d) ? {} : d, {
90
+ sizes: p,
91
+ mins: g,
92
+ minSize: L,
93
+ height: u,
94
+ heights: b
95
+ } = Nt(m, t, a, r), h = (i) => {
96
+ const c = jt(i.sizes, u, g);
97
+ l({
98
+ ...m,
99
+ ...Object.fromEntries(
100
+ t.map((o, y) => [o, c[y]]).filter(([o]) => !a.includes(o))
101
+ )
102
+ }), c.some(
103
+ (o, y) => Math.abs(o - i.sizes[y] / 100 * u) > 1
104
+ ) && S((o) => o + 1);
105
+ };
106
+ return {
107
+ sizes: p,
108
+ minSize: L,
109
+ height: u,
110
+ panelHeights: b,
111
+ layoutKey: `${t.join("|")}#${a.join("|")}#${f}`,
112
+ handleResizeEnd: h
113
+ };
114
+ }, zt = ({
115
+ projectName: e,
116
+ movingEntities: t,
117
+ onClose: a,
118
+ onMoveComplete: r
119
+ }) => {
120
+ const [d] = Ve(), l = ut(), { folders: f } = we(), S = l?.tableData || [], m = A(
121
+ (h) => l?.getEntityById(h) || f.find((i) => i.id === h),
122
+ [f, l]
123
+ ), p = A(
124
+ async (h) => {
125
+ if (!t || h.length === 0) return;
126
+ const i = h[0];
127
+ try {
128
+ const c = t.entities.map(
129
+ (y, n) => ({
130
+ id: `move-${y.entityId}-${Date.now()}-${n}`,
131
+ type: "update",
132
+ entityType: y.entityType,
133
+ entityId: y.entityId,
134
+ data: y.entityType === "folder" ? { parentId: i } : { folderId: i }
135
+ })
136
+ ), o = (await d({
137
+ projectName: e,
138
+ operationsRequestModel: {
139
+ operations: c
140
+ }
141
+ }).unwrap())?.operations?.filter((y) => y.success === !1) || [];
142
+ if (o.length > 0) {
143
+ const y = o.map((n) => n.detail).join(", ");
144
+ throw new Error(y || "Some move operations failed");
145
+ }
146
+ r?.(i);
147
+ } catch (c) {
148
+ let s = De(c) || "Failed to move entities";
149
+ if (s.includes("already exists"))
150
+ if (t.entities.length > 1)
151
+ s = "Cannot move some entities - one or more entities with the same name already exist in the target location";
152
+ else if (t.entities[0].entityType === "task") {
153
+ const y = s.match(/name '.*?, (.+?)' already exists/);
154
+ s = `Cannot move "${y ? y[1] : "this task"}" - a task with this name already exists in the target folder`;
155
+ } else {
156
+ const y = s.match(/name '.*?, (.+?)' already exists/);
157
+ s = `Cannot move "${y ? y[1] : "this folder"}" - a folder with this name already exists in the target location`;
158
+ }
159
+ Re.error(s);
160
+ } finally {
161
+ a();
162
+ }
163
+ },
164
+ [t, e, d, a, r]
165
+ ), g = A(async () => {
166
+ if (t)
167
+ try {
168
+ const h = t.entities.map(
169
+ (s, o) => ({
170
+ id: `move-to-root-${s.entityId}-${Date.now()}-${o}`,
171
+ type: "update",
172
+ entityType: s.entityType,
173
+ entityId: s.entityId,
174
+ data: s.entityType === "folder" ? { parentId: null } : { folderId: null }
175
+ })
176
+ ), c = (await d({
177
+ projectName: e,
178
+ operationsRequestModel: {
179
+ operations: h
180
+ }
181
+ }).unwrap())?.operations?.filter((s) => s.success === !1) || [];
182
+ if (c.length > 0) {
183
+ const s = c.map((o) => o.detail).join(", ");
184
+ throw new Error(s || "Some move operations failed");
185
+ }
186
+ } catch (h) {
187
+ let i = De(h) || "Failed to move entities to root";
188
+ Re.error(i);
189
+ } finally {
190
+ a();
191
+ }
192
+ }, [t, e, d, a]), L = A(() => {
193
+ if (!t) return [];
194
+ const h = [];
195
+ return t.entities.forEach((i) => {
196
+ h.push(i.entityId);
197
+ }), f.forEach((i) => {
198
+ t.entities.some((s) => {
199
+ const o = m(s.entityId);
200
+ return o?.name ? S.filter((n) => s.entityType === "folder" ? n.entityType === "folder" && n.parentId === i.id : s.entityType === "task" ? n.entityType === "task" && n.folderId === i.id : !1).some(
201
+ (n) => n.name === o.name && n.entityId !== s.entityId
202
+ ) : !1;
203
+ }) && h.push(i.id);
204
+ }), [...new Set(h)];
205
+ }, [t, f, S, m]), u = A(
206
+ (h) => {
207
+ if (!t) return;
208
+ if (t.entities.some(
209
+ (y) => y.entityType === "folder" && y.entityId === h
210
+ ))
211
+ return "Cannot move folder to itself";
212
+ if (t.entities.some(
213
+ (y) => y.currentParentId === h
214
+ ))
215
+ return "Cannot move to the same location";
216
+ const s = f.find((y) => y.id === h);
217
+ if (s) {
218
+ const y = t.entities.find((n) => {
219
+ const x = m(n.entityId);
220
+ return x?.name ? S.filter((v) => n.entityType === "folder" ? v.entityType === "folder" && v.parentId === s.id : n.entityType === "task" ? v.entityType === "task" && v.folderId === s.id : !1).some(
221
+ (v) => v.name === x.name && v.entityId !== n.entityId
222
+ ) : !1;
223
+ });
224
+ if (y)
225
+ return `Cannot move "${m(y.entityId)?.name || "Entity"}" - an entity with the same name already exists in this folder`;
226
+ }
227
+ return t.entities.some(
228
+ (y) => y.entityType === "folder"
229
+ ) ? "Cannot move folder to its child" : "Cannot move to this location";
230
+ },
231
+ [t, f, S, m]
232
+ ), b = O(() => t?.entities.every((h) => h.entityType === "folder") || !1, [t]);
233
+ return {
234
+ handleMoveSubmit: p,
235
+ handleMoveToRoot: g,
236
+ getDisabledFolderIds: L,
237
+ getDisabledMessage: u,
238
+ canMoveToRoot: b
239
+ };
240
+ }, Ut = ({
241
+ projectName: e,
242
+ movingEntities: t,
243
+ onClose: a,
244
+ onMoveComplete: r
245
+ }) => {
246
+ const { handleMoveSubmit: d, handleMoveToRoot: l, getDisabledFolderIds: f, getDisabledMessage: S } = zt({
247
+ projectName: e,
248
+ movingEntities: t ?? null,
249
+ onClose: a,
250
+ onMoveComplete: r
251
+ });
252
+ return t?.entities.length ? /* @__PURE__ */ E(
253
+ ot,
254
+ {
255
+ projectName: e,
256
+ entityType: "folder",
257
+ onSubmit: d,
258
+ onClose: a,
259
+ showMoveToRoot: t.entities.every(
260
+ (m) => m.entityType === "folder"
261
+ ),
262
+ onMoveToRoot: l,
263
+ disabledIds: f(),
264
+ getDisabledMessage: S
265
+ }
266
+ ) : null;
267
+ }, Vt = ({ projectName: e, useExtraSlices: t }) => {
268
+ const [a, { isLoading: r, isFetching: d }] = lt(), { formatAssignees: l } = t();
36
269
  return {
37
270
  getData: async () => {
38
- const y = await i({ projectName: a || "" }, !0).unwrap();
39
- return r(y);
271
+ const S = await a({ projectName: e || "" }, !0).unwrap();
272
+ return l(S);
40
273
  },
41
- isLoading: l || d
274
+ isLoading: r || d
42
275
  };
43
- }, it = ({ scopes: a, useExtraSlices: n }) => {
44
- const { isLoading: i, productTypes: l, ...d } = H(), { formatStatuses: r, formatTaskTypes: u, formatProductTypes: y, formatTypes: v, formatAttribute: b } = n();
45
- return { project: d, getStatuses: async () => r(d, a), getTypes: async () => v(d), getTaskTypes: async () => u(d), getProductTypes: async () => y(l), getAttribute: async (h) => b ? b(h).map(
46
- (s) => Fe(s.icon ?? void 0) ? { ...s, icon: void 0, img: s.icon, imgShape: "circle" } : s
47
- ) : void 0, isLoading: i };
48
- }, rt = ({ entityTypes: a, request: n }) => {
276
+ }, Ht = ({ scopes: e, useExtraSlices: t }) => {
277
+ const { isLoading: a, productTypes: r, ...d } = ue(), { formatStatuses: l, formatTaskTypes: f, formatProductTypes: S, formatTypes: m, formatAttribute: p } = t();
278
+ return { project: d, getStatuses: async () => l(d, e), getTypes: async () => m(d), getTaskTypes: async () => f(d), getProductTypes: async () => S(r), getAttribute: async (i) => p ? p(i).map(
279
+ (c) => it(c.icon ?? void 0) ? { ...c, icon: void 0, img: c.icon, imgShape: "circle" } : c
280
+ ) : void 0, isLoading: a };
281
+ }, Bt = ({ entityTypes: e, request: t }) => {
49
282
  const {
50
- attributes: i,
51
- isLoading: { siteInfo: l }
52
- } = Ue(), d = xe(Ve), r = d?.attribFields?.length ? d.attribFields : i, { projectName: u } = H();
53
- return { attributes: Be(r, { projectName: u, request: n ?? [] }).filter((b) => ye(b.data)).filter((b) => a.some((S) => b.scope?.includes(S))).map(
54
- (b) => b.data.enum?.some((S) => S.hidden) ? { ...b, data: { ...b.data, enum: _e(b.data.enum) } } : b
55
- ), isLoading: l };
56
- }, lt = "snippet_folder", B = "folder", dt = (a) => `${B}-${a}`, pe = (a) => a.entityListType === "review-session" ? "subscriptions" : z(a.entityType), ne = (a) => [...a].sort((n, i) => {
57
- if (n.active && !i.active) return -1;
58
- if (!n.active && i.active) return 1;
59
- const l = new Date(n.createdAt || 0);
60
- return new Date(i.createdAt || 0).getTime() - l.getTime();
61
- }), ct = (a = !0) => {
62
- const { projectName: n } = H(), { powerLicense: i } = Ke(), {
63
- data: l,
283
+ attributes: a,
284
+ isLoading: { siteInfo: r }
285
+ } = yt(), d = Ye(pt), l = d?.attribFields?.length ? d.attribFields : a, { projectName: f } = ue();
286
+ return { attributes: bt(l, { projectName: f, request: t ?? [] }).filter((p) => Ue(p.data)).filter((p) => e.some((g) => p.scope?.includes(g))).map(
287
+ (p) => p.data.enum?.some((g) => g.hidden) ? { ...p, data: { ...p.data, enum: rt(p.data.enum) } } : p
288
+ ), isLoading: r };
289
+ }, Gt = "snippet_folder", de = "folder", Kt = (e) => `${de}-${e}`, _e = (e) => e.entityListType === "review-session" ? "subscriptions" : ge(e.entityType), ve = (e) => [...e].sort((t, a) => {
290
+ if (t.active && !a.active) return -1;
291
+ if (!t.active && a.active) return 1;
292
+ const r = new Date(t.createdAt || 0);
293
+ return new Date(a.createdAt || 0).getTime() - r.getTime();
294
+ }), Wt = (e = !0) => {
295
+ const { projectName: t } = ue(), { powerLicense: a } = Ce(), {
296
+ data: r,
64
297
  isLoading: d,
65
- isFetching: r
66
- } = Pe(
67
- { projectName: n || "" },
298
+ isFetching: l
299
+ } = ct(
300
+ { projectName: t || "" },
68
301
  {
69
302
  initialPageParam: { cursor: "" },
70
- skip: !n || !a
303
+ skip: !t || !e
71
304
  }
72
- ), { data: u = [], isLoading: y } = je(
73
- { projectName: n || "" },
74
- { skip: !n || !i || !a }
75
- ), v = _(() => {
76
- if (!l?.pages) return [];
77
- const w = l.pages.flatMap((p) => p.lists);
78
- if (i && u.length > 0) {
79
- const p = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Set();
80
- for (const e of u)
81
- p.set(e.id, {
82
- id: e.id,
83
- folder: e,
305
+ ), { data: f = [], isLoading: S } = dt(
306
+ { projectName: t || "" },
307
+ { skip: !t || !a || !e }
308
+ ), m = O(() => {
309
+ if (!r?.pages) return [];
310
+ const L = r.pages.flatMap((u) => u.lists);
311
+ if (a && f.length > 0) {
312
+ const u = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
313
+ for (const n of f)
314
+ u.set(n.id, {
315
+ id: n.id,
316
+ folder: n,
84
317
  children: /* @__PURE__ */ new Map(),
85
318
  items: [],
86
319
  hasAnyItems: !1
87
- }), e.parentId || I.add(e.id);
88
- for (const e of u)
89
- if (e.parentId && p.has(e.parentId)) {
90
- const m = p.get(e.parentId), f = p.get(e.id);
91
- m.children.set(e.id, f);
320
+ }), n.parentId || b.add(n.id);
321
+ for (const n of f)
322
+ if (n.parentId && u.has(n.parentId)) {
323
+ const x = u.get(n.parentId), T = u.get(n.id);
324
+ x.children.set(n.id, T);
92
325
  }
93
- const g = [];
94
- for (const e of w) {
95
- const m = e.entityListFolderId;
96
- if (m && p.has(m)) {
97
- const f = p.get(m);
98
- f.items.push(e), f.hasAnyItems = !0;
326
+ const h = [];
327
+ for (const n of L) {
328
+ const x = n.entityListFolderId;
329
+ if (x && u.has(x)) {
330
+ const T = u.get(x);
331
+ T.items.push(n), T.hasAnyItems = !0;
99
332
  } else
100
- g.push(e);
333
+ h.push(n);
101
334
  }
102
- for (const e of p.values())
103
- if (e.hasAnyItems) {
104
- let m = e.folder;
105
- for (; m.parentId; ) {
106
- const f = p.get(m.parentId);
107
- if (f)
108
- f.hasAnyItems = !0, m = f.folder;
335
+ for (const n of u.values())
336
+ if (n.hasAnyItems) {
337
+ let x = n.folder;
338
+ for (; x.parentId; ) {
339
+ const T = u.get(x.parentId);
340
+ if (T)
341
+ T.hasAnyItems = !0, x = T.folder;
109
342
  else
110
343
  break;
111
344
  }
112
345
  }
113
- const h = (e, m, f = []) => ({
114
- id: e.id,
115
- name: e.label,
116
- label: e.label,
117
- ...f.length > 0 && { parents: f },
118
- icon: pe(e),
346
+ const i = (n, x, T = []) => ({
347
+ id: n.id,
348
+ name: n.label,
349
+ label: n.label,
350
+ ...T.length > 0 && { parents: T },
351
+ icon: _e(n),
119
352
  subRows: [],
120
353
  data: {
121
- id: e.id,
122
- name: e.label,
123
- label: e.label,
124
- entityType: e.entityType,
125
- listId: e.id
354
+ id: n.id,
355
+ name: n.label,
356
+ label: n.label,
357
+ entityType: n.entityType,
358
+ listId: n.id
126
359
  }
127
- }), s = (e) => e.sort((m, f) => {
128
- const x = u.findIndex((N) => N.id === m.id), C = u.findIndex((N) => N.id === f.id);
129
- return x === -1 && C === -1 ? m.folder.label.localeCompare(f.folder.label) : x === -1 ? 1 : C === -1 ? -1 : x - C;
130
- }), t = (e) => {
131
- const m = e.items.map((f) => f.id);
132
- for (const f of e.children.values())
133
- m.push(...t(f));
134
- return m;
135
- }, o = qe({
136
- folderNodes: p,
137
- rootFolderIds: I,
360
+ }), c = (n) => n.sort((x, T) => {
361
+ const v = f.findIndex((H) => H.id === x.id), k = f.findIndex((H) => H.id === T.id);
362
+ return v === -1 && k === -1 ? x.folder.label.localeCompare(T.folder.label) : v === -1 ? 1 : k === -1 ? -1 : v - k;
363
+ }), s = (n) => {
364
+ const x = n.items.map((T) => T.id);
365
+ for (const T of n.children.values())
366
+ x.push(...s(T));
367
+ return x;
368
+ }, o = Tt({
369
+ folderNodes: u,
370
+ rootFolderIds: b,
138
371
  showEmptyFolders: !1,
139
- buildFolderRowId: dt,
140
- createItemRow: h,
141
- sortFolderNodes: s,
142
- sortItems: ne,
143
- getFolderLabel: (e) => e.label,
144
- getFolderIcon: (e) => e.data?.icon || lt,
145
- getFolderColor: (e) => e.data?.color,
146
- getItemCount: (e) => e.items.length + Array.from(e.children.values()).reduce((m, f) => m + f.items.length, 0)
372
+ buildFolderRowId: Kt,
373
+ createItemRow: i,
374
+ sortFolderNodes: c,
375
+ sortItems: ve,
376
+ getFolderLabel: (n) => n.label,
377
+ getFolderIcon: (n) => n.data?.icon || Gt,
378
+ getFolderColor: (n) => n.data?.color,
379
+ getItemCount: (n) => n.items.length + Array.from(n.children.values()).reduce((x, T) => x + T.items.length, 0)
147
380
  });
148
- for (const e of o) {
149
- if (e.id.startsWith(B + "-")) {
150
- const f = e.id.substring((B + "-").length), x = p.get(f);
151
- x && (e.data = { ...e.data, childListIds: t(x) });
381
+ for (const n of o) {
382
+ if (n.id.startsWith(de + "-")) {
383
+ const T = n.id.substring((de + "-").length), v = u.get(T);
384
+ v && (n.data = { ...n.data, childListIds: s(v) });
152
385
  }
153
- const m = [...e.subRows || []];
154
- for (; m.length > 0; ) {
155
- const f = m.shift();
156
- if (f.id.startsWith(B + "-")) {
157
- const x = f.id.substring((B + "-").length), C = p.get(x);
158
- C && (f.data = { ...f.data, childListIds: t(C) });
386
+ const x = [...n.subRows || []];
387
+ for (; x.length > 0; ) {
388
+ const T = x.shift();
389
+ if (T.id.startsWith(de + "-")) {
390
+ const v = T.id.substring((de + "-").length), k = u.get(v);
391
+ k && (T.data = { ...T.data, childListIds: s(k) });
159
392
  }
160
- f.subRows && m.push(...f.subRows);
393
+ T.subRows && x.push(...T.subRows);
161
394
  }
162
395
  }
163
- const c = ne(g).map((e) => h(e));
164
- return [...o, ...c];
396
+ const y = ve(h).map((n) => i(n));
397
+ return [...o, ...y];
165
398
  }
166
- return ne(w).map((p) => ({
167
- id: p.id,
168
- name: p.label,
169
- label: p.label,
170
- icon: pe(p),
399
+ return ve(L).map((u) => ({
400
+ id: u.id,
401
+ name: u.label,
402
+ label: u.label,
403
+ icon: _e(u),
171
404
  subRows: [],
172
405
  data: {
173
- id: p.id,
174
- name: p.label,
175
- label: p.label,
176
- entityType: p.entityType,
177
- listId: p.id
406
+ id: u.id,
407
+ name: u.label,
408
+ label: u.label,
409
+ entityType: u.entityType,
410
+ listId: u.id
178
411
  }
179
412
  }));
180
- }, [l, i, u]), b = i && u.length > 0;
413
+ }, [r, a, f]), p = a && f.length > 0;
181
414
  return {
182
- getData: M(async () => v, [v]),
183
- isLoading: d || r || y,
184
- isExpandable: b
415
+ getData: A(async () => m, [m]),
416
+ isLoading: d || l || S,
417
+ isExpandable: p
185
418
  };
186
- }, ut = (a, n, i, l) => a.id === "noValue" ? n.get(he)?.count ?? (l ? 0 : void 0) : a.id === "hasValue" ? l ? i : void 0 : n.get(a.id)?.count ?? (a.name ? n.get(a.name)?.count : void 0) ?? (l ? 0 : void 0), Ie = (a, n, i, l) => n ? a.map((d) => {
187
- const r = ut(d, n, i, l);
419
+ }, qt = (e, t, a, r) => e.id === "noValue" ? t.get(He)?.count ?? (r ? 0 : void 0) : e.id === "hasValue" ? r ? a : void 0 : t.get(e.id)?.count ?? (e.name ? t.get(e.name)?.count : void 0) ?? (r ? 0 : void 0), Ke = (e, t, a, r) => t ? e.map((d) => {
420
+ const l = qt(d, t, a, r);
188
421
  return {
189
422
  ...d,
190
- badge: r != null ? String(r) : d.badge,
191
- subRows: d.subRows?.length ? Ie(d.subRows, n, i, l) : d.subRows
423
+ badge: l != null ? String(l) : d.badge,
424
+ subRows: d.subRows?.length ? Ke(d.subRows, t, a, r) : d.subRows
192
425
  };
193
- }) : a, pt = (a) => ({
426
+ }) : e, Qt = (e) => ({
194
427
  id: "noValue",
195
428
  name: "noValue",
196
- label: `No ${a}`,
429
+ label: `No ${e}`,
197
430
  icon: "unpublished",
198
431
  subRows: [],
199
432
  data: {
200
433
  id: "noValue"
201
434
  }
202
- }), ft = (a) => ({
435
+ }), Yt = (e) => ({
203
436
  id: "hasValue",
204
437
  name: "hasValue",
205
- label: `Some ${a}`,
438
+ label: `Some ${e}`,
206
439
  icon: "check",
207
440
  subRows: [],
208
441
  data: {
209
442
  id: "hasValue"
210
443
  }
211
- }), fe = [
444
+ }), Ae = [
212
445
  {
213
446
  label: "Hierarchy",
214
447
  value: "hierarchy",
@@ -227,17 +460,17 @@ const st = ({ projectName: a, useExtraSlices: n }) => {
227
460
  {
228
461
  label: "Task Type",
229
462
  value: "taskType",
230
- icon: z("task")
463
+ icon: ge("task")
231
464
  },
232
465
  {
233
466
  label: "Folder Type",
234
467
  value: "folderType",
235
- icon: z("folder")
468
+ icon: ge("folder")
236
469
  },
237
470
  {
238
471
  label: "Product Type",
239
472
  value: "productType",
240
- icon: z("product")
473
+ icon: ge("product")
241
474
  },
242
475
  {
243
476
  label: "Author",
@@ -249,366 +482,387 @@ const st = ({ projectName: a, useExtraSlices: n }) => {
249
482
  value: "entityList",
250
483
  icon: "list_alt"
251
484
  }
252
- ], mt = ({
253
- sliceFields: a,
254
- entityTypes: n = [],
255
- counts: i,
256
- filled: l = 0,
257
- countsComplete: d = !1
485
+ ], Jt = ({
486
+ sliceFields: e,
487
+ usedSliceTypes: t = [],
488
+ entityTypes: a = [],
489
+ counts: r,
490
+ filled: d = 0,
491
+ countsComplete: l = !1,
492
+ sliceType: f,
493
+ onSliceTypeChange: S
258
494
  }) => {
259
- const { sliceType: r, onSliceTypeChange: u, useExtraSlices: y, isLoadingExtraSlices: v } = se(), { projectName: b } = H(), { formatAttribute: S } = y(), w = a.filter((T) => fe.some((D) => D.value === T.value)).map((T) => ({
260
- ...fe.find((k) => k.value === T.value),
261
- ...T
262
- })), p = a.some((T) => T.value === "attributes"), I = r?.startsWith("attrib.") ? r.slice(7) : void 0, g = _(
263
- () => I ? [I] : [],
264
- [I]
265
- ), { attributes: h, isLoading: s } = rt({
266
- entityTypes: n,
267
- request: g
495
+ const {
496
+ sliceType: m,
497
+ onSliceTypeChange: p,
498
+ useExtraSlices: g,
499
+ isLoadingExtraSlices: L
500
+ } = Ie(), u = f ?? m, b = S ?? p, { projectName: h } = ue(), { formatAttribute: i } = g(), c = e.filter((C) => Ae.some((D) => D.value === C.value)).map((C) => ({
501
+ ...Ae.find((_) => _.value === C.value),
502
+ ...C
503
+ })), s = e.some((C) => C.value === "attributes"), o = u?.startsWith("attrib.") ? u.slice(7) : void 0, y = O(
504
+ () => o ? [o] : [],
505
+ [o]
506
+ ), { attributes: n, isLoading: x } = Bt({
507
+ entityTypes: a,
508
+ request: y
268
509
  });
269
- p && typeof S == "function" && h.forEach(
270
- (T) => w.push({
271
- label: T.data.title || T.name,
272
- value: "attrib." + T.name,
273
- icon: We(T.name, T.data.type, ye(T.data))
510
+ s && typeof i == "function" && n.forEach(
511
+ (C) => c.push({
512
+ label: C.data.title || C.name,
513
+ value: "attrib." + C.name,
514
+ icon: xt(C.name, C.data.type, Ue(C.data))
274
515
  })
275
516
  );
276
- const [t, o] = j(!1), e = !!h.find((T) => T.name === I)?.enumIsLoading, {
277
- project: m,
278
- getStatuses: f,
279
- getTypes: x,
280
- getTaskTypes: C,
281
- getProductTypes: N,
282
- getAttribute: Y,
283
- isLoading: F
284
- } = it({ scopes: n, useExtraSlices: y }), {
285
- data: E,
286
- getData: X,
287
- isFetching: q
288
- } = Ae({
289
- projectName: b || "",
290
- folderTypes: m?.folderTypes || [],
517
+ const [T, v] = U(!1), H = !!n.find((C) => C.name === o)?.enumIsLoading, {
518
+ project: oe,
519
+ getStatuses: ae,
520
+ getTypes: q,
521
+ getTaskTypes: ie,
522
+ getProductTypes: Z,
523
+ getAttribute: ee,
524
+ isLoading: B
525
+ } = Ht({ scopes: a, useExtraSlices: g }), {
526
+ data: te,
527
+ getData: Q,
528
+ isFetching: Y
529
+ } = at({
530
+ projectName: h || "",
531
+ folderTypes: oe?.folderTypes || [],
291
532
  includeColors: !0
292
- }), { getData: G, isLoading: U } = st({
293
- projectName: b,
294
- useExtraSlices: y
533
+ }), { getData: I, isLoading: R } = Vt({
534
+ projectName: h,
535
+ useExtraSlices: g
295
536
  }), {
296
- getData: J,
297
- isLoading: A,
298
- isExpandable: Z
299
- } = ct(r === "entityList"), V = q || F || U || v && r !== "hierarchy" || A && r === "entityList" || s || e, L = {
537
+ getData: P,
538
+ isLoading: K,
539
+ isExpandable: re
540
+ } = Wt(u === "entityList"), F = Y || B || R || L && u !== "hierarchy" || K && u === "entityList" || x || H, N = {
300
541
  hierarchy: {
301
- getData: X,
302
- isLoading: q,
542
+ getData: Q,
543
+ isLoading: Y,
303
544
  isExpandable: !0
304
545
  },
305
546
  assignees: {
306
- getData: G,
307
- isLoading: U,
547
+ getData: I,
548
+ isLoading: R,
308
549
  isExpandable: !1,
309
550
  noValue: !0,
310
551
  hasValue: !0
311
552
  },
312
553
  author: {
313
- getData: G,
314
- isLoading: U,
554
+ getData: I,
555
+ isLoading: R,
315
556
  isExpandable: !1
316
557
  },
317
558
  status: {
318
- getData: f,
319
- isLoading: F,
559
+ getData: ae,
560
+ isLoading: B,
320
561
  isExpandable: !1
321
562
  },
322
563
  type: {
323
- getData: x,
324
- isLoading: F,
564
+ getData: q,
565
+ isLoading: B,
325
566
  isExpandable: !0
326
567
  },
327
568
  taskType: {
328
- getData: C,
329
- isLoading: F,
569
+ getData: ie,
570
+ isLoading: B,
330
571
  isExpandable: !1
331
572
  },
332
573
  productType: {
333
- getData: N,
574
+ getData: Z,
334
575
  isLoading: !1,
335
576
  isExpandable: !1
336
577
  },
337
578
  entityList: {
338
- getData: J,
339
- isLoading: A,
340
- isExpandable: Z
579
+ getData: P,
580
+ isLoading: K,
581
+ isExpandable: re
341
582
  }
342
583
  };
343
- for (const T of h)
344
- L["attrib." + T.name] = {
345
- getData: () => Y(T),
346
- isLoading: s || !!T.enumIsLoading,
584
+ for (const C of n)
585
+ N["attrib." + C.name] = {
586
+ getData: () => ee(C),
587
+ isLoading: x || !!C.enumIsLoading,
347
588
  isExpandable: !1,
348
589
  isAttribute: !0
349
590
  };
350
- const O = { data: [], isExpandable: !1 }, [P, re] = j(O), $ = L[r], Te = (T, D) => {
351
- const k = L[T];
352
- if (!k) {
353
- console.warn(`Slice type ${T} not found`);
591
+ const pe = { data: [], isExpandable: !1 }, [le, fe] = U(pe), $ = N[u], ne = c.find(
592
+ (C) => N[C.value] && !t.includes(C.value)
593
+ )?.value;
594
+ se(() => {
595
+ F || $ || !ne || b(ne, !1);
596
+ }, [F, $, ne]);
597
+ const z = (C, D) => {
598
+ const _ = N[C];
599
+ if (!_) {
600
+ console.warn(`Slice type ${C} not found`);
354
601
  return;
355
602
  }
356
- (k.isAttribute && p || a.some((te) => te.value === T)) && u(T, D);
603
+ (_.isAttribute && s || e.some((ce) => ce.value === C)) && b(C, D);
357
604
  };
358
- ae(() => {
359
- if (V) return;
605
+ se(() => {
606
+ if (F) return;
360
607
  (async () => {
361
608
  try {
362
609
  if (!$) return;
363
- o(!0);
610
+ v(!0);
364
611
  const D = await $.getData();
365
612
  if (D === void 0)
366
613
  throw window.alert(
367
614
  "Slice options failed to load. This likely means the PowerFeatures addon is out of date. Please update to the latest version."
368
- ), u("hierarchy", !1), new Error("Slice data is undefined");
369
- $.hasValue && D.unshift(ft(r)), $.noValue && D.unshift(pt(r)), re({
615
+ ), b(ne ?? "hierarchy", !1), new Error("Slice data is undefined");
616
+ $.hasValue && D.unshift(Yt(u)), $.noValue && D.unshift(Qt(u)), fe({
370
617
  data: D,
371
618
  isExpandable: $.isExpandable
372
619
  });
373
620
  } catch (D) {
374
- console.error("Error fetching slice data:", D), re(O);
621
+ console.error("Error fetching slice data:", D), fe(pe);
375
622
  } finally {
376
- o(!1);
623
+ v(!1);
377
624
  }
378
625
  })();
379
- }, [r, b, V, r === "hierarchy" ? E : null]);
380
- const ee = _(
381
- () => Ie(P.data, i, l, d),
382
- [P.data, i, l, d]
383
- ), Se = _(() => {
384
- const T = /* @__PURE__ */ new Map(), D = [...ee];
626
+ }, [u, h, F, u === "hierarchy" ? te : null]);
627
+ const j = O(
628
+ () => Ke(le.data, r, d, l),
629
+ [le.data, r, d, l]
630
+ ), Le = O(() => {
631
+ const C = /* @__PURE__ */ new Map(), D = [...j];
385
632
  for (; D.length > 0; ) {
386
- const k = D.shift();
387
- if (k && (T.set(k.id, k), k.subRows && k.subRows.length > 0))
388
- for (const te of k.subRows)
389
- D.push(te);
633
+ const _ = D.shift();
634
+ if (_ && (C.set(_.id, _), _.subRows && _.subRows.length > 0))
635
+ for (const ce of _.subRows)
636
+ D.push(ce);
390
637
  }
391
- return T;
392
- }, [ee]);
638
+ return C;
639
+ }, [j]);
393
640
  return {
394
- sliceOptions: w,
395
- table: { ...P, data: ee },
396
- sliceMap: Se,
397
- isLoading: L[r] && L[r].isLoading || t || V,
398
- sliceType: r,
399
- handleSliceTypeChange: Te
641
+ sliceOptions: c,
642
+ table: { ...le, data: j },
643
+ sliceMap: Le,
644
+ isLoading: N[u] && N[u].isLoading || T || F,
645
+ sliceType: u,
646
+ handleSliceTypeChange: z
400
647
  };
401
- }, yt = /* @__PURE__ */ new Map(), gt = (a, n) => {
402
- const { sliceType: i } = se(), l = _(() => ({ id: i, desc: !1 }), [i]), d = !!n || !a, r = a?.entity === "version" ? { entity: "version", groupBy: l, args: a.args, skip: d } : {
648
+ }, Xt = /* @__PURE__ */ new Map(), Zt = (e, t, a, r) => {
649
+ const d = O(() => ({ id: t, desc: !1 }), [t]), l = O(
650
+ () => (a ?? []).filter((h) => h !== t).map((h) => ({ id: h, desc: !1 })),
651
+ [a, t]
652
+ ), f = !!r || !e, S = e?.entity === "version" ? { entity: "version", groupBy: d, extraGroupBys: l, args: e.args, skip: f } : {
403
653
  entity: "task",
404
- groupBy: l,
405
- args: a?.args ?? { projectName: "" },
406
- skip: d
407
- }, { counts: u, total: y, complete: v } = He(r), b = u?.get(he)?.count ?? 0, S = Math.max(y - b, 0);
654
+ groupBy: d,
655
+ extraGroupBys: l,
656
+ args: e?.args ?? { projectName: "" },
657
+ skip: f
658
+ }, { counts: m, total: p, complete: g } = St(S), L = m?.get(He)?.count ?? 0, u = Math.max(p - L, 0);
408
659
  return {
409
- counts: d ? void 0 : u ?? (v ? yt : void 0),
410
- total: y,
411
- filled: S,
412
- complete: !d && v
660
+ counts: f ? void 0 : m ?? (g ? Xt : void 0),
661
+ total: p,
662
+ filled: u,
663
+ complete: !f && g
413
664
  };
414
- }, ht = K.div``, bt = K(ze)`
415
- position: absolute;
416
- inset: 4px;
417
- top: 50%;
418
- transform: translateY(-50%);
419
- z-index: 100;
665
+ }, en = V.div`
666
+ display: flex;
667
+ align-items: center;
668
+
669
+ &.open {
670
+ flex: 1;
671
+ min-width: 0;
672
+ }
673
+ `, tn = V(It)`
674
+ flex: 1;
675
+ min-width: 0;
420
676
  height: 28px;
421
677
  min-height: 28px;
422
- `, It = ({ value: a, onChange: n }) => {
423
- const [i, l] = j(!1);
424
- return /* @__PURE__ */ Q(ht, { children: [
425
- i && /* @__PURE__ */ R(
426
- bt,
678
+ `, nn = ({ open: e, value: t, subject: a, onChange: r }) => {
679
+ const d = () => r(e ? void 0 : ""), l = (f) => {
680
+ f.key === "Escape" && r(void 0);
681
+ };
682
+ return /* @__PURE__ */ G(en, { className: W({ open: e }), children: [
683
+ e && /* @__PURE__ */ E(
684
+ tn,
427
685
  {
428
- value: a,
429
- onChange: (u) => n(u.target.value),
686
+ value: t,
687
+ onChange: (f) => r(f.target.value),
430
688
  placeholder: "Search",
431
689
  autoFocus: !0,
432
- onKeyDown: (u) => {
433
- u.key === "Escape" && (l(!1), n(""));
434
- }
690
+ onKeyDown: l
435
691
  }
436
692
  ),
437
- /* @__PURE__ */ R(
438
- De,
693
+ /* @__PURE__ */ E(
694
+ he,
439
695
  {
440
- icon: i ? "close" : "search",
441
- onClick: () => {
442
- l(!i), i && n("");
443
- },
444
- className: ie({ open: i }),
445
- "data-tooltip": i ? "Close search" : "Search folders"
696
+ icon: e ? "close" : "search",
697
+ onClick: d,
698
+ className: W({ open: e }),
699
+ "data-tooltip": e ? "Close search" : `Search ${a}`
446
700
  }
447
701
  )
448
702
  ] });
449
- }, oe = (a, n) => {
450
- a.toggleExpanded(n), a.subRows?.forEach((i) => oe(i, n));
451
- }, me = (a) => a.map((n) => n.id).filter(Boolean), Tt = (a, n, i, l) => {
452
- const { onOpenNew: d } = Ye(), { projectName: r } = H(), { setEntities: u } = Ze(), y = nt(), [v] = ge(), { deleteEntities: b } = tt(), [S, w] = j(null), p = M(
453
- (s, t) => t.map((o) => n?.get(o) || (o === s.id ? s : void 0)).filter((o) => !!o),
454
- [n]
455
- ), I = _(
703
+ }, xe = (e, t) => {
704
+ e.toggleExpanded(t), e.subRows?.forEach((a) => xe(a, t));
705
+ }, Oe = (e) => e.map((t) => t.id).filter(Boolean), sn = (e, t, a, r) => {
706
+ const { onOpenNew: d } = Lt(), { projectName: l } = ue(), { setEntities: f } = nt(), S = Dt(), [m] = Ve(), { deleteEntities: p } = Rt(), [g, L] = U(null), u = A(
707
+ (c, s) => s.map((o) => t?.get(o) || (o === c.id ? c : void 0)).filter((o) => !!o),
708
+ [t]
709
+ ), b = O(
456
710
  () => ({
457
- onShowDetails: (s, t = [s.id]) => {
458
- u({
711
+ onShowDetails: (c, s = [c.id]) => {
712
+ f({
459
713
  entityType: "folder",
460
- entities: t.map((o) => ({ id: o, projectName: r }))
714
+ entities: s.map((o) => ({ id: o, projectName: l }))
461
715
  });
462
716
  },
463
- onAddToList: a,
464
- onMove: (s) => {
465
- l?.({
466
- entities: s.map((t) => ({
467
- entityId: t.id,
468
- entityType: t.data?.entityType === "task" ? "task" : "folder",
469
- currentParentId: t.parentId || t.data?.parentId
717
+ onAddToList: e,
718
+ onMove: (c) => {
719
+ r?.({
720
+ entities: c.map((s) => ({
721
+ entityId: s.id,
722
+ entityType: s.data?.entityType === "task" ? "task" : "folder",
723
+ currentParentId: s.parentId || s.data?.parentId
470
724
  }))
471
725
  });
472
726
  },
473
- onRename: (s) => w(s),
474
- onOpenViewer: (s) => i?.(s, r),
475
- onUploadVersion: (s) => {
476
- const t = s.data?.entityType === "task", o = t ? s.parentId || s.data?.parentId : s.id;
477
- o && y?.onOpenVersionUpload({
727
+ onRename: (c) => L(c),
728
+ onOpenViewer: (c) => a?.(c, l),
729
+ onUploadVersion: (c) => {
730
+ const s = c.data?.entityType === "task", o = s ? c.parentId || c.data?.parentId : c.id;
731
+ o && S?.onOpenVersionUpload({
478
732
  folderId: o,
479
- taskId: t ? s.id : void 0
733
+ taskId: s ? c.id : void 0
480
734
  });
481
735
  },
482
- onDelete: (s) => {
483
- const t = s.map((o) => {
484
- const c = o.data?.entityType === "task" ? "task" : "folder", e = o.parentId || o.data?.parentId;
736
+ onDelete: (c) => {
737
+ const s = c.map((o) => {
738
+ const y = o.data?.entityType === "task" ? "task" : "folder", n = o.parentId || o.data?.parentId;
485
739
  return {
486
740
  id: o.id,
487
- entityType: c,
741
+ entityType: y,
488
742
  name: o.name,
489
743
  label: o.label,
490
- projectName: r,
491
- folderId: c === "task" ? e : void 0,
492
- parentId: c === "folder" ? e : void 0
744
+ projectName: l,
745
+ folderId: y === "task" ? n : void 0,
746
+ parentId: y === "folder" ? n : void 0
493
747
  };
494
748
  });
495
- b(t);
749
+ p(s);
496
750
  }
497
751
  }),
498
752
  [
753
+ e,
499
754
  a,
500
- i,
501
- l,
502
755
  r,
503
- u,
504
- b,
505
- y
756
+ l,
757
+ f,
758
+ p,
759
+ S
506
760
  ]
507
- ), g = M(
508
- (s) => {
509
- S && (v({
510
- projectName: r,
761
+ ), h = A(
762
+ (c) => {
763
+ g && (m({
764
+ projectName: l,
511
765
  operationsRequestModel: {
512
766
  operations: [
513
767
  {
514
768
  type: "update",
515
- entityType: S.data?.entityType === "task" ? "task" : "folder",
516
- entityId: S.id,
517
- data: { label: s }
769
+ entityType: g.data?.entityType === "task" ? "task" : "folder",
770
+ entityId: g.id,
771
+ data: { label: c }
518
772
  }
519
773
  ]
520
774
  }
521
- }), w(null));
775
+ }), L(null));
522
776
  },
523
- [r, S, v]
777
+ [l, g, m]
524
778
  );
525
779
  return {
526
- rowContextMenuBuilders: _(
780
+ rowContextMenuBuilders: O(
527
781
  () => [
528
- (s, { row: t, selectedRows: o }) => ({
782
+ (c, { row: s, selectedRows: o }) => ({
529
783
  label: "Show details",
530
784
  icon: "dock_to_left",
531
- shortcut: Xe("click", [Je.Alt]),
532
- command: () => I.onShowDetails(t.original, o)
785
+ shortcut: Et("click", [kt.Alt]),
786
+ command: () => b.onShowDetails(s.original, o)
533
787
  }),
534
- (s, { row: t }) => ({
788
+ (c, { row: s }) => ({
535
789
  label: "Rename label",
536
790
  icon: "titlecase",
537
791
  shortcut: "R",
538
- command: () => I.onRename(t.original)
792
+ command: () => b.onRename(s.original)
539
793
  }),
540
- (s, { row: t }) => ({
794
+ (c, { row: s }) => ({
541
795
  label: "Open in viewer",
542
796
  icon: "play_circle",
543
- command: () => I.onOpenViewer(t.original),
544
- hidden: !i
797
+ command: () => b.onOpenViewer(s.original),
798
+ hidden: !a
545
799
  }),
546
- (s, { selectedTableRows: t }) => ({
800
+ (c, { selectedTableRows: s }) => ({
547
801
  label: "Expand all children",
548
802
  icon: "expand_all",
549
- command: () => t.filter((o) => o.getCanExpand() && !o.getIsExpanded()).forEach((o) => oe(o, !0)),
550
- hidden: !t.some(
803
+ command: () => s.filter((o) => o.getCanExpand() && !o.getIsExpanded()).forEach((o) => xe(o, !0)),
804
+ hidden: !s.some(
551
805
  (o) => o.getCanExpand() && !o.getIsExpanded()
552
806
  )
553
807
  }),
554
- (s, { selectedTableRows: t }) => ({
808
+ (c, { selectedTableRows: s }) => ({
555
809
  label: "Collapse all children",
556
810
  icon: "collapse_all",
557
- command: () => t.filter((o) => o.getCanExpand() && o.getIsExpanded()).forEach((o) => oe(o, !1)),
558
- hidden: !t.some(
811
+ command: () => s.filter((o) => o.getCanExpand() && o.getIsExpanded()).forEach((o) => xe(o, !1)),
812
+ hidden: !s.some(
559
813
  (o) => o.getCanExpand() && o.getIsExpanded()
560
814
  )
561
815
  }),
562
- (s, { row: t, selectedRows: o }) => {
563
- const c = I.onAddToList?.(t.original, o);
564
- return c ? Array.isArray(c) ? c : [c] : void 0;
816
+ (c, { row: s, selectedRows: o }) => {
817
+ const y = b.onAddToList?.(s.original, o);
818
+ return y ? Array.isArray(y) ? y : [y] : void 0;
565
819
  },
566
- (s, { row: t }) => ({
820
+ (c, { row: s }) => ({
567
821
  label: "Upload version",
568
822
  icon: "upload",
569
- command: () => I.onUploadVersion(t.original)
823
+ command: () => b.onUploadVersion(s.original)
570
824
  }),
571
- (s, { row: t, selectedRows: o }) => ({
825
+ (c, { row: s, selectedRows: o }) => ({
572
826
  label: "Move",
573
827
  icon: "drive_file_move",
574
- command: () => I.onMove(p(t.original, o)),
575
- hidden: !l
828
+ command: () => b.onMove(u(s.original, o)),
829
+ hidden: !r
576
830
  }),
577
- (s, { row: t, selectedRows: o }) => ({
578
- label: W.folder.createLabel,
579
- icon: W.folder.icon,
831
+ (c, { row: s, selectedRows: o }) => ({
832
+ label: me.folder.createLabel,
833
+ icon: me.folder.icon,
580
834
  command: () => d?.("folder", {
581
- parentFolderIds: me(
582
- p(t.original, o)
835
+ parentFolderIds: Oe(
836
+ u(s.original, o)
583
837
  )
584
838
  })
585
839
  }),
586
- (s, { row: t, selectedRows: o }) => ({
587
- label: W.task.createLabel,
588
- icon: W.task.icon,
840
+ (c, { row: s, selectedRows: o }) => ({
841
+ label: me.task.createLabel,
842
+ icon: me.task.icon,
589
843
  command: () => d?.("task", {
590
- parentFolderIds: me(
591
- p(t.original, o)
844
+ parentFolderIds: Oe(
845
+ u(s.original, o)
592
846
  )
593
847
  })
594
848
  }),
595
- (s, { row: t, selectedRows: o }) => ({
849
+ (c, { row: s, selectedRows: o }) => ({
596
850
  label: "Delete",
597
851
  icon: "delete",
598
852
  danger: !0,
599
- command: () => I.onDelete(p(t.original, o))
853
+ command: () => b.onDelete(u(s.original, o))
600
854
  })
601
855
  ],
602
- [I, p, d]
856
+ [b, u, d]
603
857
  ),
604
- onOptionClick: I.onShowDetails,
605
- onRename: I.onRename,
606
- renamingRow: S,
607
- renameInitialValue: S?.label || S?.name || "",
608
- onSubmitRename: g,
609
- onCancelRename: () => w(null)
858
+ onOptionClick: b.onShowDetails,
859
+ onRename: b.onRename,
860
+ renamingRow: g,
861
+ renameInitialValue: g?.label || g?.name || "",
862
+ onSubmitRename: h,
863
+ onCancelRename: () => L(null)
610
864
  };
611
- }, St = K(Qe)`
865
+ }, on = V(Ct)`
612
866
  /* put above the menu so it's still clickable */
613
867
  /* NOTE: this will need fixing as this also puts it above dialogs */
614
868
  /* z-index: 1001; */
@@ -639,7 +893,7 @@ const st = ({ projectName: a, useExtraSlices: n }) => {
639
893
  }
640
894
  }
641
895
  `;
642
- K.div`
896
+ V.div`
643
897
  display: flex;
644
898
  flex-direction: column;
645
899
  gap: var(--base-gap-large);
@@ -661,361 +915,545 @@ K.div`
661
915
  font-weight: 600;
662
916
  }
663
917
  `;
664
- const vt = (a, n, i) => {
665
- const l = `${n}${i === 1 ? "" : "s"}`;
666
- return a === "created" ? `new ${l}` : a === "deleted" ? `${l} deleted` : `${i} ${l} ${a.replaceAll("_", " ")}`;
667
- }, xt = (a) => {
668
- const n = /* @__PURE__ */ new Map();
669
- return a.forEach((l) => {
670
- const [, d, r] = l.topic.split(".");
671
- if (!d || !r) return;
672
- const u = `${d}.${r}`, y = n.get(u) || {
918
+ const an = (e, t, a) => {
919
+ const r = `${t}${a === 1 ? "" : "s"}`;
920
+ return e === "created" ? `new ${r}` : e === "deleted" ? `${r} deleted` : `${a} ${r} ${e.replaceAll("_", " ")}`;
921
+ }, rn = (e) => {
922
+ const t = /* @__PURE__ */ new Map();
923
+ return e.forEach((r) => {
924
+ const [, d, l] = r.topic.split(".");
925
+ if (!d || !l) return;
926
+ const f = `${d}.${l}`, S = t.get(f) || {
673
927
  entityType: d,
674
- updateType: r,
928
+ updateType: l,
675
929
  ids: /* @__PURE__ */ new Set()
676
930
  };
677
- y.ids.add(l.entityId || String(l.id)), n.set(u, y);
678
- }), `${Array.from(n.values()).map(
679
- ({ entityType: l, updateType: d, ids: r }) => vt(d, l, r.size)
931
+ S.ids.add(r.entityId || String(r.id)), t.set(f, S);
932
+ }), `${Array.from(t.values()).map(
933
+ ({ entityType: r, updateType: d, ids: l }) => an(d, r, l.size)
680
934
  ).join(", ")} since last sync`;
681
- }, wt = we(
682
- ({ projectNames: a, topics: n, onSync: i, shouldSyncOnUpdate: l, hideWhenNoUpdates: d = !1, ...r }, u) => {
683
- const [y, v] = j(!1), [b, S] = at(), { setMenuOpen: w } = et(), p = le(null), I = le(), g = Le();
684
- ae(() => () => {
685
- const x = I.current;
686
- I.current = void 0, x !== void 0 && clearTimeout(x);
687
- }, []), Ce(u, () => p.current, []);
688
- const h = async () => {
689
- v(!0);
935
+ }, ln = Je(
936
+ ({ projectNames: e, topics: t, onSync: a, shouldSyncOnUpdate: r, hideWhenNoUpdates: d = !1, ...l }, f) => {
937
+ const [S, m] = U(!1), [p, g] = Pt(), { setMenuOpen: L } = st(), u = ye(null), b = ye(), h = Xe();
938
+ se(() => () => {
939
+ const v = b.current;
940
+ b.current = void 0, v !== void 0 && clearTimeout(v);
941
+ }, []), Ze(f, () => u.current, []);
942
+ const i = async () => {
943
+ m(!0);
690
944
  try {
691
- await i?.(s);
945
+ await a?.(c);
692
946
  } finally {
693
- v(!1);
947
+ m(!1);
694
948
  }
695
- }, { updates: s, hasUpdates: t } = ot({
696
- projectNames: a,
697
- topics: n,
698
- isSyncing: y,
699
- shouldSyncOnUpdate: l
949
+ }, { updates: c, hasUpdates: s } = Mt({
950
+ projectNames: e,
951
+ topics: t,
952
+ isSyncing: S,
953
+ shouldSyncOnUpdate: r
700
954
  });
701
- if (ae(() => {
702
- const x = (C) => {
703
- C.repeat || !C.shiftKey || C.ctrlKey || C.metaKey || C.key.toLowerCase() !== "r" || Ge(C) || (C.preventDefault(), C.stopPropagation(), h());
955
+ if (se(() => {
956
+ const v = (k) => {
957
+ k.repeat || !k.shiftKey || k.ctrlKey || k.metaKey || k.key.toLowerCase() !== "r" || vt(k) || (k.preventDefault(), k.stopPropagation(), i());
704
958
  };
705
- return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
706
- }, [h]), d && !t) return null;
707
- const o = xt(s), c = Object.values(b).some(Boolean);
708
- Object.values(b).every(Boolean);
709
- const e = () => {
710
- I.current && clearTimeout(I.current);
959
+ return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
960
+ }, [i]), d && !s) return null;
961
+ const o = rn(c), y = Object.values(p).some(Boolean);
962
+ Object.values(p).every(Boolean);
963
+ const n = () => {
964
+ b.current && clearTimeout(b.current);
711
965
  };
712
- return /* @__PURE__ */ Q(ve, { children: [
713
- /* @__PURE__ */ R(
714
- St,
966
+ return /* @__PURE__ */ G($e, { children: [
967
+ /* @__PURE__ */ E(
968
+ on,
715
969
  {
716
- ...r,
970
+ ...l,
717
971
  icon: "sync",
718
- ref: p,
719
- onClick: h,
972
+ ref: u,
973
+ onClick: i,
720
974
  onMouseEnter: () => {
721
- e(), w(g);
975
+ n(), L(h);
722
976
  },
723
977
  onMouseLeave: () => {
724
- e(), I.current = setTimeout(() => w(!1), 100);
978
+ n(), b.current = setTimeout(() => L(!1), 100);
725
979
  },
726
- className: ie(r.className, {
727
- syncing: y,
728
- "has-updates": t,
729
- "auto-sync": c && !ue
980
+ className: W(l.className, {
981
+ syncing: S,
982
+ "has-updates": s,
983
+ "auto-sync": y && !Pe
730
984
  }),
731
985
  "data-shortcut": "Shift+R",
732
- "data-tooltip": t ? o : "Refresh data",
733
- variant: t ? "filled" : "surface"
986
+ "data-tooltip": s ? o : "Refresh data",
987
+ variant: s ? "filled" : "surface"
734
988
  }
735
989
  ),
736
- !ue
990
+ !Pe
737
991
  ] });
738
992
  }
739
- ), Lt = ({
740
- projectName: a,
741
- movingEntities: n,
742
- onClose: i,
743
- onMoveComplete: l
744
- }) => {
745
- const [d] = ge(), r = $e(), { folders: u } = be(), y = r?.tableData || [], v = M(
746
- (g) => r?.getEntityById(g) || u.find((h) => h.id === g),
747
- [u, r]
748
- ), b = M(
749
- async (g) => {
750
- if (!n || g.length === 0) return;
751
- const h = g[0];
752
- try {
753
- const s = n.entities.map(
754
- (c, e) => ({
755
- id: `move-${c.entityId}-${Date.now()}-${e}`,
756
- type: "update",
757
- entityType: c.entityType,
758
- entityId: c.entityId,
759
- data: c.entityType === "folder" ? { parentId: h } : { folderId: h }
760
- })
761
- ), o = (await d({
762
- projectName: a,
763
- operationsRequestModel: {
764
- operations: s
765
- }
766
- }).unwrap())?.operations?.filter((c) => c.success === !1) || [];
767
- if (o.length > 0) {
768
- const c = o.map((e) => e.detail).join(", ");
769
- throw new Error(c || "Some move operations failed");
770
- }
771
- l?.(h);
772
- } catch (s) {
773
- let t = de(s) || "Failed to move entities";
774
- if (t.includes("already exists"))
775
- if (n.entities.length > 1)
776
- t = "Cannot move some entities - one or more entities with the same name already exist in the target location";
777
- else if (n.entities[0].entityType === "task") {
778
- const c = t.match(/name '.*?, (.+?)' already exists/);
779
- t = `Cannot move "${c ? c[1] : "this task"}" - a task with this name already exists in the target folder`;
780
- } else {
781
- const c = t.match(/name '.*?, (.+?)' already exists/);
782
- t = `Cannot move "${c ? c[1] : "this folder"}" - a folder with this name already exists in the target location`;
783
- }
784
- ce.error(t);
785
- } finally {
786
- i();
787
- }
788
- },
789
- [n, a, d, i, l]
790
- ), S = M(async () => {
791
- if (n)
792
- try {
793
- const g = n.entities.map(
794
- (t, o) => ({
795
- id: `move-to-root-${t.entityId}-${Date.now()}-${o}`,
796
- type: "update",
797
- entityType: t.entityType,
798
- entityId: t.entityId,
799
- data: t.entityType === "folder" ? { parentId: null } : { folderId: null }
800
- })
801
- ), s = (await d({
802
- projectName: a,
803
- operationsRequestModel: {
804
- operations: g
805
- }
806
- }).unwrap())?.operations?.filter((t) => t.success === !1) || [];
807
- if (s.length > 0) {
808
- const t = s.map((o) => o.detail).join(", ");
809
- throw new Error(t || "Some move operations failed");
810
- }
811
- } catch (g) {
812
- let h = de(g) || "Failed to move entities to root";
813
- ce.error(h);
814
- } finally {
815
- i();
816
- }
817
- }, [n, a, d, i]), w = M(() => {
818
- if (!n) return [];
819
- const g = [];
820
- return n.entities.forEach((h) => {
821
- g.push(h.entityId);
822
- }), u.forEach((h) => {
823
- n.entities.some((t) => {
824
- const o = v(t.entityId);
825
- return o?.name ? y.filter((e) => t.entityType === "folder" ? e.entityType === "folder" && e.parentId === h.id : t.entityType === "task" ? e.entityType === "task" && e.folderId === h.id : !1).some(
826
- (e) => e.name === o.name && e.entityId !== t.entityId
827
- ) : !1;
828
- }) && g.push(h.id);
829
- }), [...new Set(g)];
830
- }, [n, u, y, v]), p = M(
831
- (g) => {
832
- if (!n) return;
833
- if (n.entities.some(
834
- (c) => c.entityType === "folder" && c.entityId === g
835
- ))
836
- return "Cannot move folder to itself";
837
- if (n.entities.some(
838
- (c) => c.currentParentId === g
839
- ))
840
- return "Cannot move to the same location";
841
- const t = u.find((c) => c.id === g);
842
- if (t) {
843
- const c = n.entities.find((e) => {
844
- const m = v(e.entityId);
845
- return m?.name ? y.filter((x) => e.entityType === "folder" ? x.entityType === "folder" && x.parentId === t.id : e.entityType === "task" ? x.entityType === "task" && x.folderId === t.id : !1).some(
846
- (x) => x.name === m.name && x.entityId !== e.entityId
847
- ) : !1;
848
- });
849
- if (c)
850
- return `Cannot move "${v(c.entityId)?.name || "Entity"}" - an entity with the same name already exists in this folder`;
851
- }
852
- return n.entities.some(
853
- (c) => c.entityType === "folder"
854
- ) ? "Cannot move folder to its child" : "Cannot move to this location";
855
- },
856
- [n, u, y, v]
857
- ), I = _(() => n?.entities.every((g) => g.entityType === "folder") || !1, [n]);
858
- return {
859
- handleMoveSubmit: b,
860
- handleMoveToRoot: S,
861
- getDisabledFolderIds: w,
862
- getDisabledMessage: p,
863
- canMoveToRoot: I
864
- };
865
- }, Ct = ({
866
- projectName: a,
867
- movingEntities: n,
868
- onClose: i,
869
- onMoveComplete: l
870
- }) => {
871
- const { handleMoveSubmit: d, handleMoveToRoot: r, getDisabledFolderIds: u, getDisabledMessage: y } = Lt({
872
- projectName: a,
873
- movingEntities: n ?? null,
874
- onClose: i,
875
- onMoveComplete: l
876
- });
877
- return n?.entities.length ? /* @__PURE__ */ R(
878
- Oe,
879
- {
880
- projectName: a,
881
- entityType: "folder",
882
- onSubmit: d,
883
- onClose: i,
884
- showMoveToRoot: n.entities.every(
885
- (v) => v.entityType === "folder"
886
- ),
887
- onMoveToRoot: r,
888
- disabledIds: u(),
889
- getDisabledMessage: y
993
+ ), Ne = V.div`
994
+ display: flex;
995
+ align-items: center;
996
+ gap: var(--base-gap-small);
997
+ overflow: hidden;
998
+ flex: 1;
999
+ min-width: 0;
1000
+ color: var(--md-sys-color-outline);
1001
+ `, cn = V.span`
1002
+ display: flex;
1003
+ align-items: center;
1004
+ gap: 2px;
1005
+ white-space: nowrap;
1006
+ flex-shrink: 0;
1007
+
1008
+ img {
1009
+ width: 18px;
1010
+ height: 18px;
1011
+ border-radius: 50%;
1012
+ object-fit: cover;
1013
+ }
1014
+ `, dn = ({ rowSelection: e, sliceMap: t }) => {
1015
+ const a = ye(null), [r, d] = U(0);
1016
+ Te(() => {
1017
+ const i = a.current;
1018
+ if (!i) return;
1019
+ const c = new ResizeObserver(([s]) => d(s.contentRect.width));
1020
+ return c.observe(i), () => c.disconnect();
1021
+ }, []);
1022
+ const l = Object.keys(e).filter((i) => e[i]).map((i) => t.get(i)).filter((i) => !!i), f = (i) => !!i.icon || !!i.img || !!i.startContent, [S, m] = U(!0), p = l.length > 1 || !S, [g, L] = U(l.length), u = l.map((i) => i.id).join("|");
1023
+ if (Te(() => {
1024
+ m(!0), L(l.length);
1025
+ }, [r, u]), Te(() => {
1026
+ const i = a.current;
1027
+ if (!i || !l.length) return;
1028
+ const c = Array.from(i.querySelectorAll("[data-chip]")), s = i.querySelector("[data-overflow]")?.offsetWidth ?? 22, o = (v, k) => v.offsetLeft - i.offsetLeft + v.offsetWidth <= k;
1029
+ if (l.length === 1) {
1030
+ S && c[0] && !o(c[0], i.clientWidth) && f(l[0]) && m(!1);
1031
+ return;
890
1032
  }
891
- ) : null;
892
- }, Dt = K.div`
1033
+ const y = c[c.length - 1];
1034
+ if (y && o(y, i.clientWidth)) return;
1035
+ const n = i.clientWidth - s, x = c.filter((v) => o(v, n)).length, T = Math.max(1, x);
1036
+ T !== g && L(T);
1037
+ }), !l.length) return /* @__PURE__ */ E(Ne, { ref: a });
1038
+ const b = l.slice(0, g), h = l.length - b.length;
1039
+ return /* @__PURE__ */ G(Ne, { ref: a, children: [
1040
+ b.map((i) => /* @__PURE__ */ G(
1041
+ cn,
1042
+ {
1043
+ "data-chip": !0,
1044
+ title: i.label || i.name,
1045
+ "aria-label": i.label || i.name,
1046
+ children: [
1047
+ i.startContent ?? (i.img ? /* @__PURE__ */ E("img", { src: i.img, alt: "" }) : i.icon && /* @__PURE__ */ E(wt, { icon: i.icon, style: { color: i.iconColor } })),
1048
+ !(p && f(i)) && /* @__PURE__ */ E("span", { children: i.label || i.name })
1049
+ ]
1050
+ },
1051
+ i.id
1052
+ )),
1053
+ h > 0 && /* @__PURE__ */ G("span", { "data-overflow": !0, children: [
1054
+ "+",
1055
+ h
1056
+ ] })
1057
+ ] });
1058
+ }, un = V.div`
893
1059
  height: 28px;
894
1060
  border-radius: 4px;
895
1061
  background: var(--md-sys-color-surface-container);
896
1062
  width: 100px;
897
- `, ln = ({
898
- sliceFields: a = [],
899
- entityTypes: n = ["task"],
900
- pinnedSliceType: i,
1063
+ `, pn = V.div`
1064
+ display: flex;
1065
+ align-items: center;
1066
+ gap: var(--base-gap-small);
1067
+ margin-left: auto;
1068
+ flex-shrink: 0;
1069
+
1070
+ // the open search box takes the whole header rather than sitting on top of the buttons
1071
+ &.searching {
1072
+ flex: 1;
1073
+ min-width: 0;
1074
+ }
1075
+ `, fn = V(ft)`
1076
+ .slicer-dropdown {
1077
+ flex: 0 1 auto;
1078
+ min-width: 48px;
1079
+ }
1080
+
1081
+ &.collapsed {
1082
+ cursor: pointer;
1083
+ }
1084
+
1085
+ .collapse-toggle .icon {
1086
+ transition: transform 0.15s;
1087
+ }
1088
+
1089
+ .collapse-toggle.collapsed .icon {
1090
+ transform: rotate(-90deg);
1091
+ }
1092
+
1093
+ .power-feature .icon {
1094
+ color: var(--md-sys-color-tertiary);
1095
+ }
1096
+ `, mn = V.div`
1097
+ display: flex;
1098
+ align-items: center;
1099
+ gap: var(--base-gap-small);
1100
+ min-width: 0;
1101
+ flex: 0 1 auto;
1102
+ padding: 0 4px;
1103
+
1104
+ span {
1105
+ overflow: hidden;
1106
+ text-overflow: ellipsis;
1107
+ white-space: nowrap;
1108
+ }
1109
+ `, je = "__splitSlicer__", Fe = ({
1110
+ panel: e,
1111
+ visibleSlices: t,
1112
+ sliceFields: a,
1113
+ entityTypes: r = ["task"],
1114
+ pinnedSliceType: d,
901
1115
  countsSource: l,
902
- onAddToList: d
1116
+ onAddToList: f,
1117
+ openMoveDialog: S,
1118
+ splitEnabled: m,
1119
+ canCollapse: p,
1120
+ isPrimary: g,
1121
+ search: L,
1122
+ onSearchChange: u
903
1123
  }) => {
904
- const [r, u] = j(""), {
905
- SlicerDropdown: y,
906
- rowSelection: v,
907
- onRowSelectionChange: b,
908
- expanded: S,
909
- onExpandedChange: w,
910
- isViewSyncPending: p,
911
- onOpenViewer: I,
912
- onAddToList: g,
913
- projectName: h
914
- } = se(), [s, t] = j(null), o = M((L) => {
915
- t("entities" in L ? L : { entities: [L] });
916
- }, []), c = M(() => {
917
- t(null);
918
- }, []), { refetch: e, getParentFolderIds: m } = be(), f = M(
919
- (L) => {
920
- const O = [L, ...m(L)];
921
- w(
922
- typeof S == "boolean" ? S || Object.fromEntries(O.map((P) => [P, !0])) : {
923
- ...S,
924
- ...Object.fromEntries(O.map((P) => [P, !0]))
925
- }
926
- );
1124
+ const {
1125
+ SlicerDropdown: b,
1126
+ addSlicePanel: h,
1127
+ removeSlicePanel: i,
1128
+ collapsedPanels: c,
1129
+ togglePanelCollapsed: s,
1130
+ setPanelSliceType: o,
1131
+ getPanelSelection: y,
1132
+ setPanelSelection: n,
1133
+ getPanelExpanded: x,
1134
+ setPanelExpanded: T,
1135
+ onSliceTypeChange: v,
1136
+ isViewSyncPending: k,
1137
+ onOpenViewer: H,
1138
+ onAddToList: oe
1139
+ } = Ie(), { refetch: ae } = we(), { powerLicense: q, setPowerpackDialog: ie } = Ce(), Z = y(e.id), ee = x(e.id), B = (w) => {
1140
+ n(e.id, w);
1141
+ }, te = A(
1142
+ (w) => T(e.id, w),
1143
+ [T, e.id]
1144
+ ), Q = O(
1145
+ () => typeof l == "function" ? l(e.sliceType) : l,
1146
+ [l, e.sliceType]
1147
+ ), Y = O(() => {
1148
+ const w = t.map((X) => X.sliceType);
1149
+ if (typeof l != "function") return w;
1150
+ const M = (X) => JSON.stringify([X?.entity, X?.args]), Qe = M(Q);
1151
+ return w.filter((X) => X === e.sliceType || M(l(X)) === Qe);
1152
+ }, [l, Q, t, e.sliceType]), { counts: I, filled: R, complete: P } = Zt(
1153
+ Q,
1154
+ e.sliceType,
1155
+ Y
1156
+ ), K = A(
1157
+ (w, M) => {
1158
+ g ? v(w, M) : o(e.id, w);
927
1159
  },
928
- [S, m, w]
929
- ), x = async () => e(), { counts: C, filled: N, complete: Y } = gt(l), {
1160
+ [g, v, o, e.id]
1161
+ ), re = O(
1162
+ () => t.filter((w) => w.id !== e.id).map((w) => w.sliceType),
1163
+ [t, e.id]
1164
+ ), {
930
1165
  sliceOptions: F,
931
- sliceType: E,
932
- handleSliceTypeChange: X,
933
- table: { data: q, isExpandable: G },
934
- sliceMap: U,
935
- isLoading: J
936
- } = mt({
1166
+ sliceType: N,
1167
+ handleSliceTypeChange: pe,
1168
+ table: { data: le, isExpandable: fe },
1169
+ sliceMap: $,
1170
+ isLoading: ne
1171
+ } = Jt({
937
1172
  sliceFields: a,
938
- entityTypes: n,
939
- counts: C,
940
- filled: N,
941
- countsComplete: Y
942
- }), A = Tt(
943
- d || g,
944
- U,
945
- I,
946
- o
947
- ), Z = E === "hierarchy" ? A.rowContextMenuBuilders : [], V = (L) => {
948
- b?.(L);
1173
+ usedSliceTypes: re,
1174
+ entityTypes: r,
1175
+ counts: I,
1176
+ filled: R,
1177
+ countsComplete: P,
1178
+ sliceType: e.sliceType,
1179
+ onSliceTypeChange: K
1180
+ }), z = N === "hierarchy", j = !!p && c.includes(e.id), C = F.find((w) => w.value === N)?.label || N, D = L !== void 0, _ = L ?? "", ce = z ? "Folders" : C, J = sn(
1181
+ f || oe,
1182
+ $,
1183
+ H,
1184
+ S
1185
+ ), We = z ? J.rowContextMenuBuilders : [], Ee = O(
1186
+ () => F.map((w) => w.value).filter((w) => !t.some((M) => M.sliceType === w)),
1187
+ [F, t]
1188
+ ), be = !!m && Ee.length > 0, Se = O(() => {
1189
+ const w = F.map(
1190
+ (M) => re.includes(M.value) ? { ...M, disabled: !0, disabledMessage: "Already used by another panel" } : M
1191
+ );
1192
+ return be && w.push({ label: "Split slicer", value: je, icon: "splitscreen_add" }), w;
1193
+ }, [F, re, be]), ke = () => {
1194
+ if (!q) return ie("slicer");
1195
+ h(Ee[0]);
1196
+ }, qe = (w) => {
1197
+ const M = String(w[0]);
1198
+ if (M === je) {
1199
+ ke();
1200
+ return;
1201
+ }
1202
+ pe(M, !!g && d === N);
949
1203
  };
950
- return /* @__PURE__ */ Q(Ee, { children: [
951
- /* @__PURE__ */ Q(ke, { children: [
952
- p ? /* @__PURE__ */ R(Dt, {}) : /* @__PURE__ */ R(
953
- y,
954
- {
955
- options: F || [],
956
- value: [E],
957
- sliceTypes: a.map((L) => L.value),
958
- onChange: (L) => X(L[0], i === E),
959
- className: ie("slicer-dropdown", { "single-option": F.length === 1 }),
960
- disableOpen: F.length === 1
961
- }
962
- ),
963
- /* @__PURE__ */ R(It, { value: r, onChange: u }),
964
- /* @__PURE__ */ R(
965
- wt,
966
- {
967
- topics: ["entity.folder.created"],
968
- onSync: async () => {
969
- await x();
970
- },
971
- hideWhenNoUpdates: !0
972
- }
973
- )
974
- ] }),
975
- /* @__PURE__ */ R(
976
- Re,
1204
+ return /* @__PURE__ */ G(mt, { children: [
1205
+ /* @__PURE__ */ G(
1206
+ fn,
1207
+ {
1208
+ className: W({ collapsed: j }),
1209
+ onClick: j ? () => s(e.id) : void 0,
1210
+ children: [
1211
+ p && /* @__PURE__ */ E(
1212
+ he,
1213
+ {
1214
+ icon: "expand_more",
1215
+ className: W("collapse-toggle", { collapsed: j }),
1216
+ "data-tooltip": j ? "Expand panel" : "Collapse panel",
1217
+ "data-tooltip-delay": 0,
1218
+ onClick: () => s(e.id)
1219
+ }
1220
+ ),
1221
+ j ? (
1222
+ // the dropdown cannot be used from a collapsed panel, but the dimension it
1223
+ // shows has to read the same as the dropdown does when open
1224
+ /* @__PURE__ */ E(mn, { children: /* @__PURE__ */ E("span", { children: C }) })
1225
+ ) : k ? /* @__PURE__ */ E(un, {}) : !D && /* @__PURE__ */ E(
1226
+ b,
1227
+ {
1228
+ options: Se,
1229
+ value: [N],
1230
+ sliceTypes: a.map((w) => w.value),
1231
+ onChange: (w) => qe(w),
1232
+ className: W("slicer-dropdown", { "single-option": Se.length === 1 }),
1233
+ disableOpen: Se.length === 1
1234
+ }
1235
+ ),
1236
+ j && /* @__PURE__ */ E(dn, { rowSelection: Z, sliceMap: $ }),
1237
+ /* @__PURE__ */ G(
1238
+ pn,
1239
+ {
1240
+ className: W({ searching: D }),
1241
+ onClick: (w) => w.stopPropagation(),
1242
+ children: [
1243
+ !j && /* @__PURE__ */ E(
1244
+ nn,
1245
+ {
1246
+ open: D,
1247
+ value: _,
1248
+ subject: ce,
1249
+ onChange: u
1250
+ }
1251
+ ),
1252
+ z && /* @__PURE__ */ E(
1253
+ ln,
1254
+ {
1255
+ topics: ["entity.folder.created"],
1256
+ onSync: async () => {
1257
+ await ae();
1258
+ },
1259
+ hideWhenNoUpdates: !0
1260
+ }
1261
+ ),
1262
+ be && g && !D && /* @__PURE__ */ E(
1263
+ he,
1264
+ {
1265
+ icon: "splitscreen_add",
1266
+ className: W({ "power-feature": !q }),
1267
+ "data-tooltip": q ? "Split slicer" : "Power feature - Slicer",
1268
+ "data-tooltip-delay": 0,
1269
+ onClick: ke
1270
+ }
1271
+ ),
1272
+ !g && !D && /* @__PURE__ */ E(
1273
+ he,
1274
+ {
1275
+ icon: "close",
1276
+ "data-tooltip": "Remove panel",
1277
+ "data-tooltip-delay": 0,
1278
+ onClick: () => i(e.id)
1279
+ }
1280
+ )
1281
+ ]
1282
+ }
1283
+ )
1284
+ ]
1285
+ }
1286
+ ),
1287
+ !j && /* @__PURE__ */ E(
1288
+ ht,
977
1289
  {
978
- rowSelection: v,
979
- onRowSelectionChange: V,
980
- expanded: S,
981
- setExpanded: w,
982
- data: U,
983
- children: /* @__PURE__ */ R(
984
- Me,
1290
+ rowSelection: Z,
1291
+ onRowSelectionChange: B,
1292
+ expanded: ee,
1293
+ setExpanded: te,
1294
+ data: $,
1295
+ children: /* @__PURE__ */ E(
1296
+ gt,
985
1297
  {
986
- data: q,
987
- isExpandable: G,
988
- isLoading: J || p,
989
- forceUpdateTable: E,
990
- globalFilter: r,
991
- onRename: E === "hierarchy" ? (L, O) => A.onRename(O.original) : void 0,
992
- renamingId: E === "hierarchy" ? A.renamingRow?.id : null,
993
- renameInitialValue: E === "hierarchy" ? A.renameInitialValue : void 0,
994
- onSubmitRename: E === "hierarchy" ? (L, O) => A.onSubmitRename(O) : void 0,
995
- onCancelRename: E === "hierarchy" ? A.onCancelRename : void 0,
996
- onRowOptionClick: E === "hierarchy" ? A.onOptionClick : void 0,
997
- rowContextMenuBuilders: Z
1298
+ data: le,
1299
+ isExpandable: fe,
1300
+ isLoading: ne || k,
1301
+ forceUpdateTable: N,
1302
+ globalFilter: _,
1303
+ rowIdPrefix: `slicer-${e.id}`,
1304
+ onRename: z ? (w, M) => J.onRename(M.original) : void 0,
1305
+ renamingId: z ? J.renamingRow?.id : null,
1306
+ renameInitialValue: z ? J.renameInitialValue : void 0,
1307
+ onSubmitRename: z ? (w, M) => J.onSubmitRename(M) : void 0,
1308
+ onCancelRename: z ? J.onCancelRename : void 0,
1309
+ onRowOptionClick: z ? J.onOptionClick : void 0,
1310
+ rowContextMenuBuilders: We
998
1311
  }
999
1312
  )
1000
1313
  }
1001
- ),
1002
- /* @__PURE__ */ R(
1003
- Ct,
1314
+ )
1315
+ ] });
1316
+ }, hn = V.div`
1317
+ height: 100%;
1318
+ width: 100%;
1319
+ overflow-y: auto;
1320
+ overflow-x: hidden;
1321
+
1322
+ ${({ $deadGutters: e }) => e.map(
1323
+ (t) => `
1324
+ & > .p-splitter > :nth-child(${t * 2 + 2}) {
1325
+ pointer-events: none;
1326
+ cursor: default;
1327
+ }
1328
+ `
1329
+ ).join("")}
1330
+ `, Jn = ({
1331
+ sliceFields: e = [],
1332
+ entityTypes: t = ["task"],
1333
+ pinnedSliceType: a,
1334
+ countsSource: r,
1335
+ onAddToList: d,
1336
+ enableSplit: l
1337
+ }) => {
1338
+ const { slices: f, page: S, setPanelExpanded: m, projectName: p, collapsedPanels: g } = Ie(), { powerLicense: L } = Ce(), u = !!l, b = u && L ? f : f.slice(0, 1), [h, i] = U(null), c = A((I) => {
1339
+ i("entities" in I ? I : { entities: [I] });
1340
+ }, []), s = A(() => {
1341
+ i(null);
1342
+ }, []), { getParentFolderIds: o } = we(), y = A(
1343
+ (I) => {
1344
+ const R = [I, ...o(I)];
1345
+ m(
1346
+ "hierarchy",
1347
+ (P) => typeof P == "boolean" ? P || Object.fromEntries(R.map((K) => [K, !0])) : {
1348
+ ...P,
1349
+ ...Object.fromEntries(R.map((K) => [K, !0]))
1350
+ }
1351
+ );
1352
+ },
1353
+ [o, m]
1354
+ ), n = ye(null), [x, T] = U(0);
1355
+ se(() => {
1356
+ const I = n.current;
1357
+ if (!I) return;
1358
+ const R = new ResizeObserver(([P]) => T(P.contentRect.height));
1359
+ return R.observe(I), () => R.disconnect();
1360
+ }, [b.length]);
1361
+ const v = b.map((I) => I.id), k = b.length > 1, {
1362
+ sizes: H,
1363
+ minSize: oe,
1364
+ height: ae,
1365
+ layoutKey: q,
1366
+ handleResizeEnd: ie
1367
+ } = $t(S, v, k ? g : [], x), Z = v.slice(0, -1).map(
1368
+ (I, R) => k && (g.includes(I) || g.includes(v[R + 1])) ? R : -1
1369
+ ).filter((I) => I >= 0), [ee, B] = U({}), te = A(
1370
+ (I, R) => B((P) => ({ ...P, [I]: R })),
1371
+ []
1372
+ ), Q = v.join("|");
1373
+ se(() => {
1374
+ B((I) => {
1375
+ const R = Object.keys(I).filter((P) => v.includes(P));
1376
+ return R.length === Object.keys(I).length ? I : Object.fromEntries(R.map((P) => [P, I[P]]));
1377
+ });
1378
+ }, [Q]);
1379
+ const Y = {
1380
+ visibleSlices: b,
1381
+ canCollapse: k,
1382
+ sliceFields: e,
1383
+ entityTypes: t,
1384
+ pinnedSliceType: a,
1385
+ countsSource: r,
1386
+ onAddToList: d,
1387
+ openMoveDialog: c,
1388
+ splitEnabled: u
1389
+ };
1390
+ return /* @__PURE__ */ G($e, { children: [
1391
+ b.length === 1 ? /* @__PURE__ */ E(
1392
+ Fe,
1393
+ {
1394
+ panel: b[0],
1395
+ isPrimary: !0,
1396
+ search: ee[b[0].id],
1397
+ onSearchChange: (I) => te(b[0].id, I),
1398
+ ...Y
1399
+ }
1400
+ ) : /* @__PURE__ */ E(hn, { ref: n, $deadGutters: Z, children: /* @__PURE__ */ E(
1401
+ et,
1402
+ {
1403
+ layout: "vertical",
1404
+ onResizeEnd: ie,
1405
+ style: {
1406
+ width: "100%",
1407
+ height: ae,
1408
+ overflow: "hidden"
1409
+ },
1410
+ children: b.map((I, R) => /* @__PURE__ */ E(
1411
+ tt,
1412
+ {
1413
+ size: H[R],
1414
+ minSize: oe,
1415
+ style: { overflow: "hidden" },
1416
+ children: /* @__PURE__ */ E(
1417
+ Fe,
1418
+ {
1419
+ panel: I,
1420
+ isPrimary: R === 0,
1421
+ search: ee[I.id],
1422
+ onSearchChange: (P) => te(I.id, P),
1423
+ ...Y
1424
+ }
1425
+ )
1426
+ },
1427
+ I.id
1428
+ ))
1429
+ },
1430
+ q
1431
+ ) }),
1432
+ /* @__PURE__ */ E(
1433
+ Ut,
1004
1434
  {
1005
- projectName: h,
1006
- movingEntities: s,
1007
- onClose: c,
1008
- onMoveComplete: f
1435
+ projectName: p,
1436
+ movingEntities: h,
1437
+ onClose: s,
1438
+ onMoveComplete: y
1009
1439
  }
1010
1440
  )
1011
1441
  ] });
1012
1442
  };
1013
1443
  export {
1014
- ln as S,
1015
- Tt as a,
1016
- dt as b,
1017
- gt as c,
1018
- fe as d,
1019
- wt as e,
1020
- ct as u
1444
+ _t as S,
1445
+ Be as a,
1446
+ Me as b,
1447
+ Ft as c,
1448
+ Jn as d,
1449
+ Kt as e,
1450
+ jt as f,
1451
+ Ae as g,
1452
+ sn as h,
1453
+ Zt as i,
1454
+ $t as j,
1455
+ Yn as k,
1456
+ ln as l,
1457
+ Nt as r,
1458
+ Wt as u
1021
1459
  };