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