@ynput/ayon-frontend-shared 0.6.9 → 0.7.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 (65) hide show
  1. package/dist/ContextMenu.es.js +44 -27
  2. package/dist/DetailsPanel.es.js +225 -224
  3. package/dist/ListTable.es.js +420 -420
  4. package/dist/NewEntity.es.js +42 -41
  5. package/dist/ProjectTreeTable.es.js +3517 -3378
  6. package/dist/Slicer.es.js +301 -276
  7. package/dist/Views.es.js +366 -352
  8. package/dist/api.es.js +428 -413
  9. package/dist/chunks/Actions.es.js +18 -17
  10. package/dist/chunks/ColumnDropIndicator.es.js +19 -18
  11. package/dist/chunks/ColumnHeaderMenuUI.es.js +2 -2
  12. package/dist/chunks/ContextMenuContextInstance.es.js +4 -3
  13. package/dist/chunks/DeleteEntitiesConfirmDialog.es.js +53 -41
  14. package/dist/chunks/DetailsDialog.es.js +26 -24
  15. package/dist/chunks/EmptyPlaceholder.es.js +3 -3
  16. package/dist/chunks/EmptyPlaceholderFlex.styled.es.js +40 -0
  17. package/dist/chunks/EntityPath.es.js +60 -59
  18. package/dist/chunks/EntityPickerDialog.es.js +88 -83
  19. package/dist/chunks/EntityTooltip.es.js +15 -14
  20. package/dist/chunks/EntityUpdatesContext.es.js +11 -11
  21. package/dist/chunks/Feed.es.js +864 -859
  22. package/dist/chunks/FilterErrorActions.es.js +4 -3
  23. package/dist/chunks/Menu.es.js +633 -289
  24. package/dist/chunks/MenuContext.es.js +1 -1
  25. package/dist/chunks/MetaWidget.es.js +2457 -2196
  26. package/dist/chunks/PlayableIcon.es.js +77 -76
  27. package/dist/chunks/ProjectContext.es.js +6 -6
  28. package/dist/chunks/RepresentationsList.es.js +1 -1
  29. package/dist/chunks/ReviewablesSelector.es.js +625 -609
  30. package/dist/chunks/SimpleForm.es.js +1 -1
  31. package/dist/chunks/SimpleTable.es.js +386 -363
  32. package/dist/chunks/Slicer.es.js +954 -821
  33. package/dist/chunks/{DeleteEntitiesContextInstance.es.js → TableExportContextInstance.es.js} +190 -186
  34. package/dist/chunks/TableSettingsFallback.es.js +4 -3
  35. package/dist/chunks/ThumbnailSimple.es.js +100 -99
  36. package/dist/chunks/VideoPlayer.es.js +1 -1
  37. package/dist/chunks/Watchers.es.js +222 -221
  38. package/dist/chunks/getBundleMode.es.js +1 -1
  39. package/dist/chunks/getEntityTypeIcon.es.js +5 -4
  40. package/dist/chunks/getUris.es.js +3873 -3736
  41. package/dist/chunks/realtimeUpdatesUtils.es.js +91 -82
  42. package/dist/chunks/searchTerms.es.js +621 -499
  43. package/dist/chunks/sortLists.es.js +22 -0
  44. package/dist/chunks/useAttributeEnums.es.js +43 -43
  45. package/dist/chunks/useHierarchySelection.es.js +6 -5
  46. package/dist/chunks/useLoadModule.es.js +24 -23
  47. package/dist/chunks/viewUpdateHelper.es.js +16 -15
  48. package/dist/components.es.js +565 -531
  49. package/dist/context.es.js +529 -503
  50. package/dist/hooks.es.js +13 -13
  51. package/dist/index.es.js +4 -4
  52. package/dist/types/ContextMenu.d.ts +4 -1
  53. package/dist/types/Feed.d.ts +1 -1
  54. package/dist/types/ListTable.d.ts +1 -1
  55. package/dist/types/ProjectTreeTable.d.ts +123 -13
  56. package/dist/types/SimpleTable.d.ts +2 -1
  57. package/dist/types/Slicer.d.ts +26 -1
  58. package/dist/types/Views.d.ts +2 -0
  59. package/dist/types/api.d.ts +2359 -590
  60. package/dist/types/components.d.ts +30 -4
  61. package/dist/types/context.d.ts +94 -2
  62. package/dist/types/util.d.ts +54 -0
  63. package/dist/util.es.js +129 -119
  64. package/package.json +2 -2
  65. package/dist/chunks/MenuItem.es.js +0 -420
@@ -1,308 +1,654 @@
1
- import rt from "styled-components";
2
- import { E as Mt } from "./EmptyPlaceholder.es.js";
3
- import { jsx as L, jsxs as Q, Fragment as yt } from "react/jsx-runtime";
4
- import X, { useRef as Z, useEffect as U, useLayoutEffect as st, useState as lt, useCallback as xt } from "react";
5
- import { M as Et, a as bt, b as Pt, c as K, D as $, d as Lt, e as Rt, S as Ct, F as St } from "./MenuItem.es.js";
6
- import { Icon as Tt, Button as Ot } from "@ynput/ayon-react-components";
1
+ import { jsxs as Q, jsx as p, Fragment as ke } from "react/jsx-runtime";
2
+ import te, { forwardRef as Ee, useRef as oe, useEffect as Y, useLayoutEffect as ce, useState as de, useCallback as Le } from "react";
3
+ import { Button as fe, Icon as K, ShortcutTag as Pe } from "@ynput/ayon-react-components";
4
+ import A, { keyframes as Re } from "styled-components";
5
+ import { isArray as Ce } from "lodash";
6
+ import { Link as Se } from "react-router-dom";
7
+ import pe from "clsx";
7
8
  import "@module-federation/enhanced/runtime";
8
9
  import "react-toastify";
9
10
  import "./searchTerms.es.js";
10
11
  import "./getUris.es.js";
11
12
  import "primereact/confirmdialog";
12
- import { a as ct, u as at } from "./DeleteEntitiesContextInstance.es.js";
13
- import "lodash";
13
+ import { a as ne, u as ue } from "./TableExportContextInstance.es.js";
14
14
  import "uuid";
15
15
  import "semver";
16
16
  import "./ContextMenuContextInstance.es.js";
17
- import kt from "clsx";
18
- import { createPortal as Dt } from "react-dom";
17
+ import { createPortal as Te } from "react-dom";
19
18
  import "react-redux";
20
- import { c as Ht } from "./copyToClipboard.es.js";
21
- const re = rt(Mt)`
19
+ import { c as Ne } from "./copyToClipboard.es.js";
20
+ const z = 42, Ae = 8, U = z + Ae, De = A.dialog`
21
+ position: fixed;
22
+ margin: 0;
23
+ inset: 0;
24
+ top: ${z}px;
25
+ width: auto;
26
+ height: auto;
27
+ z-index: 1000;
28
+ border: none;
29
+ background-color: unset;
30
+ padding: 0;
31
+
32
+ user-select: none;
33
+
34
+ overflow: auto;
35
+ /* remove scroll bar */
36
+ scrollbar-width: none;
37
+ -ms-overflow-style: none;
38
+ &::-webkit-scrollbar {
39
+ display: none;
40
+ }
41
+ padding-bottom: 60px;
42
+ `, Ie = Re`
43
+ from {
44
+ scale: 0.95;
45
+ opacity: 0.6;
46
+ }
47
+ to {
48
+ scale: 1;
49
+ opacity: 1;
50
+ }
51
+ `, Oe = A.div`
22
52
  display: flex;
23
53
  flex-direction: column;
24
- justify-content: center;
25
- flex-grow: 1;
26
- position: relative;
27
- max-width: 100%;
28
- overflow: hidden;
54
+ gap: var(--base-gap-large);
55
+ min-height: 0;
56
+
57
+ /* position */
58
+ position: absolute;
59
+ right: 0;
29
60
  top: 0;
30
- left: 0;
31
- transform: none;
32
- gap: 8px;
33
- .icon {
34
- font-size: 34px;
61
+ width: fit-content;
62
+ z-index: 30;
63
+
64
+ /* animate */
65
+ animation: ${Ie} 0.03s ease-in forwards;
66
+
67
+ /* transform origin based on alignment */
68
+ &.right {
69
+ transform-origin: top right;
35
70
  }
36
- h3 {
37
- font-size: 18px;
71
+ &.left {
72
+ transform-origin: top left;
38
73
  }
39
- `, se = rt.div`
74
+
75
+ /* add shadow to each item */
76
+ & > *:not(.sub-menu),
77
+ .sub-menu menu {
78
+ box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.15);
79
+ }
80
+
81
+ /* theme support */
82
+ &.dark {
83
+ color: var(--md-sys-color-on-surface, #fff);
84
+ /* override children backgrounds if needed */
85
+ & > * {
86
+ color: var(--md-sys-color-on-surface, #fff) !important;
87
+ }
88
+ }
89
+ `, He = A.section`
90
+ position: relative;
40
91
  display: flex;
41
92
  flex-direction: column;
42
- flex-grow: 1;
93
+ min-height: 0;
43
94
 
95
+ padding: 0px;
96
+ border-radius: 8px;
97
+ /* colors */
98
+ background-color: var(--md-sys-color-surface-container-high);
99
+ color: var(--md-sys-color-on-surface);
100
+ z-index: 10;
101
+ overflow: hidden;
102
+ `, _e = A.div`
44
103
  position: relative;
45
- height: 100%;
46
- border-radius: var(--border-radius-m);
104
+ border-radius: 8px;
105
+ display: flex;
106
+ flex-direction: column;
107
+ min-height: 0;
108
+
109
+ & > * {
110
+ min-height: 0;
111
+ }
112
+
113
+ /* sub menu */
114
+ &.sub-menu {
115
+ position: absolute;
47
116
 
48
- background: var(--md-sys-color-surface-container-low);
49
- .header {
117
+ border-radius: 8px;
118
+ width: max-content;
119
+ z-index: 30;
120
+
121
+ & > * {
122
+ border-radius: 8px;
123
+ overflow-x: hidden;
124
+ }
125
+ }
126
+ `, Be = A.menu`
127
+ /* reset defaults */
128
+ display: flex;
129
+ list-style-type: none;
130
+ margin-block-start: 0;
131
+ margin-block-end: 0;
132
+ margin-inline-start: 0px;
133
+ margin-inline-end: 0px;
134
+ padding-inline-start: 0;
135
+
136
+ /* custom */
137
+ flex-direction: column;
138
+ gap: var(--base-gap-large);
139
+ padding: 8px;
140
+ flex: 1 1 auto;
141
+ min-height: 0;
142
+ overflow-y: auto;
143
+
144
+ /* shrink the padding when compact */
145
+ &.compact {
146
+ padding: 4px;
147
+ gap: var(--base-gap-small);
148
+ }
149
+
150
+ /* colors */
151
+ background-color: var(--md-sys-color-surface-container-high);
152
+
153
+ /* divider */
154
+ hr {
50
155
  margin: 0;
51
- padding: 9.4px 8px;
52
- text-transform: capitalize;
156
+ width: 100%;
157
+ border-style: solid;
158
+ opacity: 0.5;
159
+ border-color: var(--md-sys-color-surface-container-highest);
160
+ }
161
+ `, Fe = A.li`
162
+ display: flex;
163
+ padding: 6px 16px 6px 12px;
164
+ justify-content: flex-start;
165
+ align-items: center;
166
+ gap: var(--base-gap-large);
167
+ align-self: stretch;
168
+ border-radius: 4px;
169
+ cursor: pointer;
170
+ position: relative;
171
+ user-select: none;
172
+
173
+ span {
174
+ display: inline-block;
175
+ }
176
+
177
+ &:hover {
178
+ background-color: var(--md-sys-color-surface-container-highest);
179
+ }
180
+
181
+ .hover-swap {
182
+ display: none;
183
+ cursor: grab;
184
+ }
185
+ &:hover {
186
+ .hover-swap-default {
187
+ display: none;
188
+ }
189
+ .hover-swap {
190
+ display: inline-block;
191
+ }
192
+ }
193
+
194
+ .more {
195
+ margin-left: auto;
196
+ }
197
+
198
+ /* highlighted item */
199
+ &.highlighted {
200
+ background-color: var(--md-sys-color-secondary-container);
201
+ &:hover {
202
+ background-color: var(--md-sys-color-secondary-container-hover);
203
+ }
204
+ }
205
+
206
+ /* selected item */
207
+ &.selected {
208
+ background-color: var(--md-sys-color-primary-container);
209
+ color: var(--md-sys-color-on-primary-container);
210
+ &:hover {
211
+ background-color: var(--md-sys-color-primary-container-hover);
212
+ }
213
+ }
214
+
215
+ &.notification::after {
216
+ content: '';
217
+ position: absolute;
218
+ right: 0;
219
+ top: 0;
220
+ transform: translate(25%, -25%);
221
+ width: 8px;
222
+ height: 8px;
223
+ border-radius: 50%;
224
+ background-color: var(--md-sys-color-error);
225
+ }
226
+
227
+ &.danger {
228
+ &,
229
+ .icon {
230
+ color: var(--md-sys-color-error);
231
+ }
232
+
233
+ &:hover {
234
+ background-color: var(--md-sys-color-error-container);
235
+
236
+ &,
237
+ .icon {
238
+ color: var(--md-sys-color-on-error-container);
239
+ }
240
+ }
241
+ }
242
+
243
+ &.dev {
244
+ &,
245
+ .icon {
246
+ color: var(--color-hl-developer);
247
+ }
248
+
249
+ &:hover {
250
+ background-color: var(--color-hl-developer-container-hover);
251
+ }
252
+ }
253
+
254
+ /* needs a Power Pack license: a bolt at the end of the row */
255
+ .power-bolt {
256
+ margin-left: auto;
257
+ color: var(--md-sys-color-tertiary);
258
+ font-variation-settings: 'FILL' 1;
259
+ }
260
+
261
+ &.disabled {
262
+ user-select: none;
263
+ pointer-events: none;
264
+ &,
265
+ .icon {
266
+ color: var(--md-sys-color-outline);
267
+ }
268
+ background-color: unset;
269
+ }
270
+ `, We = A.div`
271
+ display: flex;
272
+ align-items: center;
273
+ gap: var(--base-gap-small);
274
+ margin-left: auto;
275
+ padding-left: 24px;
276
+ `, $e = A(fe)`
277
+ margin-left: auto;
278
+ &.hasIcon {
279
+ padding: 4px;
280
+ }
281
+ .icon {
282
+ font-size: 16px;
283
+ }
284
+
285
+ .selected & {
286
+ background-color: var(--md-sys-color-on-primary);
287
+ color: var(--md-sys-color-primary);
288
+ }
289
+ `, ze = A.img`
290
+ width: 18px;
291
+ height: 18px;
292
+ object-fit: contain;
293
+ `, qe = A.footer`
294
+ position: relative;
295
+ display: flex;
296
+ padding: 8px;
297
+ flex-direction: column;
298
+ justify-content: center;
299
+ align-items: center;
300
+ align-self: stretch;
301
+ background-color: var(--md-sys-color-surface-container-lowest);
302
+
303
+ user-select: text;
304
+
305
+ button {
306
+ display: none;
307
+
308
+ position: absolute;
309
+ right: 2px;
310
+ border-radius: 8px;
311
+ top: 50%;
312
+ transform: translateY(-50%);
313
+ cursor: pointer;
314
+ }
315
+
316
+ /* hover show button */
317
+ &:hover {
318
+ button {
319
+ display: flex;
320
+ }
321
+ }
322
+ `, ge = Ee(
323
+ ({
324
+ label: s,
325
+ icon: n,
326
+ hoverIcon: r,
327
+ img: i,
328
+ highlighted: d,
329
+ notification: u,
330
+ selected: c,
331
+ danger: t,
332
+ items: g = [],
333
+ className: a,
334
+ isLink: h,
335
+ isDev: m,
336
+ shortcut: L,
337
+ disabled: e,
338
+ powerFeature: l,
339
+ active: f,
340
+ reserveActiveSlot: w,
341
+ endActions: y = [],
342
+ ...N
343
+ }, q) => {
344
+ const J = Ce(s) ? s : [s], { powerLicense: v } = ne(), C = !v && l, S = /* @__PURE__ */ Q(
345
+ Fe,
346
+ {
347
+ ref: q,
348
+ className: pe(
349
+ "menu-item",
350
+ {
351
+ highlighted: d,
352
+ selected: c,
353
+ notification: u,
354
+ danger: t,
355
+ dev: m,
356
+ disabled: e,
357
+ power: C
358
+ },
359
+ a
360
+ ),
361
+ ...N,
362
+ "aria-label": J.join(", "),
363
+ children: [
364
+ n && /* @__PURE__ */ p(K, { icon: n, className: r ? "hover-swap-default" : void 0 }),
365
+ r && /* @__PURE__ */ p(K, { icon: r, className: "hover-swap" }),
366
+ i && /* @__PURE__ */ p(ze, { src: i, alt: `${s} icon` }),
367
+ J.map((b, x) => /* @__PURE__ */ p("span", { children: b }, x)),
368
+ L && /* @__PURE__ */ p(Pe, { style: { minWidth: 22, textAlign: "center" }, align: "right", children: L }),
369
+ (f || w) && /* @__PURE__ */ p(
370
+ K,
371
+ {
372
+ icon: "check",
373
+ style: { marginLeft: "auto", visibility: f ? "visible" : "hidden" }
374
+ }
375
+ ),
376
+ !!y.length && /* @__PURE__ */ p(We, { children: y.map((b) => /* @__PURE__ */ p(
377
+ $e,
378
+ {
379
+ variant: "text",
380
+ icon: b.icon,
381
+ className: "menu-item-end-action",
382
+ "data-tooltip": b.tooltip,
383
+ "aria-label": b.tooltip,
384
+ onClick: (x) => {
385
+ x.stopPropagation(), b.onClick(x);
386
+ },
387
+ onKeyDown: (x) => x.stopPropagation()
388
+ },
389
+ b.icon
390
+ )) }),
391
+ C && /* @__PURE__ */ p(K, { icon: "bolt", className: "power-bolt" }),
392
+ !!g.length && /* @__PURE__ */ p(K, { icon: "arrow_right", className: "more" })
393
+ ]
394
+ }
395
+ );
396
+ return h ? /* @__PURE__ */ p(Se, { to: h, target: N.target, children: S }) : S;
53
397
  }
54
- `, ot = ({
55
- items: c,
56
- handleClick: o,
398
+ );
399
+ ge.displayName = "MenuItem";
400
+ const ae = ({
401
+ items: s,
402
+ handleClick: n,
57
403
  onSubMenu: r,
58
404
  onSubMenuLayout: i,
59
- subMenu: f,
60
- level: d,
61
- id: a = "root-menu",
62
- parentRef: e,
63
- parentEl: p,
64
- style: s,
405
+ subMenu: d,
406
+ level: u,
407
+ id: c = "root-menu",
408
+ parentRef: t,
409
+ parentEl: g,
410
+ style: a,
65
411
  placement: h,
66
412
  onClose: m,
67
- onMenuClose: R,
68
- itemClassName: t,
413
+ onMenuClose: L,
414
+ itemClassName: e,
69
415
  itemStyle: l,
70
- setPowerpackDialog: u,
71
- ...x
416
+ setPowerpackDialog: f,
417
+ ...w
72
418
  }) => {
73
- const v = Z({}), _ = Z(null), j = (g, D, H) => {
74
- const C = v.current[D], A = _.current;
75
- if (!C || !A) return;
76
- const F = (A.offsetParent ?? document.body).getBoundingClientRect(), S = C.getBoundingClientRect(), M = (A.querySelector("menu") ?? A).getBoundingClientRect(), q = window.innerWidth, I = window.innerHeight, w = 8, P = Math.max(240, M.width), T = Math.min(
77
- H.length * 36 + 16,
78
- I - K - w
79
- ), y = 4, B = () => Math.max(w, M.left - P - y), O = () => M.right + y, V = O() + P <= q - w, W = B() >= w;
80
- let b, n;
81
- h === "left" && W ? (b = "left", n = B()) : V ? (b = "right", n = O()) : W ? (b = "left", n = B()) : (b = "left", n = Math.max(w, q - P - w));
82
- let N = S.top - 8;
83
- N + T > I - w && (N = I - T - w), N = Math.max(K, N);
84
- const J = b === "left" ? n - 16 : n;
85
- r?.(g, {
86
- id: D,
419
+ const y = oe({}), N = oe(null), q = (v, C, S) => {
420
+ const b = y.current[C], x = N.current;
421
+ if (!b || !x) return;
422
+ const _ = (x.offsetParent ?? document.body).getBoundingClientRect(), D = b.getBoundingClientRect(), k = (x.querySelector("menu") ?? x).getBoundingClientRect(), V = window.innerWidth, B = window.innerHeight, M = 8, T = Math.max(240, k.width), I = Math.min(
423
+ S.length * 36 + 16,
424
+ B - U - M
425
+ ), E = 4, F = () => Math.max(M, k.left - T - E), O = () => k.right + E, j = O() + T <= V - M, $ = F() >= M;
426
+ let R, o;
427
+ h === "left" && $ ? (R = "left", o = F()) : j ? (R = "right", o = O()) : $ ? (R = "left", o = F()) : (R = "left", o = Math.max(M, V - T - M));
428
+ let W = D.top - 8;
429
+ W + I > B - M && (W = B - I - M), W = Math.max(U, W);
430
+ const ee = R === "left" ? o - 16 : o;
431
+ r?.(v, {
432
+ id: C,
87
433
  style: {
88
- top: N - F.top,
89
- left: J - F.left,
90
- maxHeight: I - N - w
434
+ top: W - _.top,
435
+ left: ee - _.left,
436
+ maxHeight: B - W - M
91
437
  },
92
- items: H,
93
- level: d,
94
- placement: b,
438
+ items: S,
439
+ level: u,
440
+ placement: R,
95
441
  // Pass the actual menu-item element so sub-menu measurement uses the <li>
96
442
  // instead of whatever inner span the mouse event bubbled from.
97
- parentEl: C
443
+ parentEl: b
98
444
  });
99
- }, dt = (g) => {
100
- f && r?.(g, { id: "parent", items: [] });
445
+ }, J = (v) => {
446
+ d && r?.(v, { id: "parent", items: [] });
101
447
  };
102
- return U(() => {
103
- f && _.current && _.current.querySelectorAll("li, button")[0]?.focus();
104
- }, [f]), st(() => {
105
- if (!f || !_.current || !e || !i || !a) return;
106
- const g = _.current, D = e, H = D.closest(".menu-list, .sub-menu");
107
- if (!H) return;
108
- const C = g.querySelector("menu") ?? g, A = H.querySelector("menu") ?? H, F = (g.offsetParent ?? document.body).getBoundingClientRect(), S = g.getBoundingClientRect(), E = C.getBoundingClientRect(), M = A.getBoundingClientRect(), q = D.getBoundingClientRect(), I = E.left - S.left, w = E.width, P = window.innerWidth, T = window.innerHeight, y = 8, B = 4, O = () => Math.max(y, M.left - w - B), V = () => M.right + B, W = V() + w <= P - y, b = O() >= y;
109
- let n, k;
110
- h === "left" && b ? (n = "left", k = O()) : W ? (n = "right", k = V()) : b ? (n = "left", k = O()) : (n = "left", k = Math.max(y, P - w - y));
111
- const Y = C.querySelector(":scope > li")?.getBoundingClientRect(), J = q.top, pt = Y ? Y.top : S.top + 8, mt = J - pt, tt = C.scrollHeight;
112
- let z = S.top + mt;
113
- if (z + tt > T - y) {
114
- const wt = Math.min(tt, T - K - y);
115
- z = T - wt - y;
448
+ return Y(() => {
449
+ d && N.current && N.current.querySelectorAll("li, button")[0]?.focus();
450
+ }, [d]), ce(() => {
451
+ if (!d || !N.current || !t || !i || !c) return;
452
+ const v = N.current, C = t, S = C.closest(".menu-list, .sub-menu");
453
+ if (!S) return;
454
+ const b = v.querySelector("menu") ?? v, x = S.querySelector("menu") ?? S, _ = (v.offsetParent ?? document.body).getBoundingClientRect(), D = v.getBoundingClientRect(), P = b.getBoundingClientRect(), k = x.getBoundingClientRect(), V = C.getBoundingClientRect(), B = P.left - D.left, M = P.width, T = window.innerWidth, I = window.innerHeight, E = 8, F = 4, O = () => Math.max(E, k.left - M - F), j = () => k.right + F, $ = j() + M <= T - E, R = O() >= E;
455
+ let o, H;
456
+ h === "left" && R ? (o = "left", H = O()) : $ ? (o = "right", H = j()) : R ? (o = "left", H = O()) : (o = "left", H = Math.max(E, T - M - E));
457
+ const Z = b.querySelector(":scope > li")?.getBoundingClientRect(), ee = V.top, ve = Z ? Z.top : D.top + 8, ye = ee - ve, ie = b.scrollHeight;
458
+ let G = D.top + ye;
459
+ if (G + ie > I - E) {
460
+ const Me = Math.min(ie, I - U - E);
461
+ G = I - Me - E;
116
462
  }
117
- z = Math.max(K, z);
118
- const gt = n === "left" ? k - I : k, et = z - F.top, nt = gt - F.left, ht = typeof s?.top == "number" ? s.top : parseFloat(String(s?.top)), vt = typeof s?.left == "number" ? s.left : parseFloat(String(s?.left));
119
- (Math.abs(et - ht) > 1 || Math.abs(nt - vt) > 1) && i(
120
- a,
121
- { top: et, left: nt, maxHeight: T - z - y },
122
- n
463
+ G = Math.max(U, G);
464
+ const be = o === "left" ? H - B : H, re = G - _.top, se = be - _.left, we = typeof a?.top == "number" ? a.top : parseFloat(String(a?.top)), xe = typeof a?.left == "number" ? a.left : parseFloat(String(a?.left));
465
+ (Math.abs(re - we) > 1 || Math.abs(se - xe) > 1) && i(
466
+ c,
467
+ { top: re, left: se, maxHeight: I - G - E },
468
+ o
123
469
  );
124
- }, [f, c, e, a, h, s?.top, s?.left, i]), /* @__PURE__ */ L(
125
- Et,
470
+ }, [d, s, t, c, h, a?.top, a?.left, i]), /* @__PURE__ */ p(
471
+ _e,
126
472
  {
127
- style: { paddingLeft: f ? 16 : 0, ...s },
128
- className: f ? "sub-menu" : "menu-list",
129
- id: a,
130
- onMouseLeave: dt,
131
- ...x,
132
- ref: _,
133
- children: /* @__PURE__ */ L(bt, { children: c.filter((g) => !g.hidden).map((g, D) => {
134
- if (g.node)
135
- return g.node;
136
- if (g?.id === "divider" || g?.separator) return /* @__PURE__ */ L("hr", {}, D);
473
+ style: { paddingLeft: d ? 16 : 0, ...a },
474
+ className: d ? "sub-menu" : "menu-list",
475
+ id: c,
476
+ onMouseLeave: J,
477
+ ...w,
478
+ ref: N,
479
+ children: /* @__PURE__ */ p(Be, { children: s.filter((v) => !v.hidden).map((v, C) => {
480
+ if (v.node)
481
+ return v.node;
482
+ if (v?.id === "divider" || v?.separator) return /* @__PURE__ */ p("hr", {}, C);
137
483
  const {
138
- label: H,
139
- icon: C,
140
- img: A,
141
- highlighted: G,
142
- onClick: F,
143
- link: S,
144
- items: E = [],
145
- id: M,
146
- disableClose: q,
147
- selected: I,
148
- disabled: w,
149
- powerFeature: P,
150
- active: T,
151
- reserveActiveSlot: y,
152
- endActions: B,
484
+ label: S,
485
+ icon: b,
486
+ img: x,
487
+ highlighted: X,
488
+ onClick: _,
489
+ link: D,
490
+ items: P = [],
491
+ id: k,
492
+ disableClose: V,
493
+ selected: B,
494
+ disabled: M,
495
+ powerFeature: T,
496
+ active: I,
497
+ reserveActiveSlot: E,
498
+ endActions: F,
153
499
  ...O
154
- } = g, { powerLicense: V } = ct(), W = !V && P, b = (n) => {
155
- n.preventDefault(), n.stopPropagation(), P && u?.(P), R?.();
500
+ } = v, { powerLicense: j } = ne(), $ = !j && T, R = (o) => {
501
+ o.preventDefault(), o.stopPropagation(), T && f?.(T), L?.();
156
502
  };
157
- return /* @__PURE__ */ L(
158
- Pt,
503
+ return /* @__PURE__ */ p(
504
+ ge,
159
505
  {
160
506
  tabIndex: 0,
161
- label: H,
162
- icon: C,
163
- img: A,
164
- highlighted: G,
165
- items: E,
166
- selected: I,
167
- disabled: w,
168
- powerFeature: P,
169
- active: T,
170
- reserveActiveSlot: y,
171
- endActions: B,
172
- isLink: S,
173
- onClick: (n) => W ? b(n) : E.length ? j(n, M, E) : o(n, F, S, q),
174
- onKeyDown: (n) => {
175
- n.key === "Enter" && (W ? b(n) : E.length ? j(n, M, E) : o(n, F, S));
176
- const k = !n.target.nextSibling;
177
- n.key === "Tab" && k && !n.shiftKey && (n.preventDefault(), n.stopPropagation(), _.current?.querySelectorAll("li, button")[0]?.focus()), n.key === "Escape" && f && e && (n.preventDefault(), n.stopPropagation(), e.focus(), m?.(M));
507
+ label: S,
508
+ icon: b,
509
+ img: x,
510
+ highlighted: X,
511
+ items: P,
512
+ selected: B,
513
+ disabled: M,
514
+ powerFeature: T,
515
+ active: I,
516
+ reserveActiveSlot: E,
517
+ endActions: F,
518
+ isLink: D,
519
+ onClick: (o) => $ ? R(o) : P.length ? q(o, k, P) : n(o, _, D, V),
520
+ onKeyDown: (o) => {
521
+ o.key === "Enter" && ($ ? R(o) : P.length ? q(o, k, P) : n(o, _, D));
522
+ const H = !o.target.nextSibling;
523
+ o.key === "Tab" && H && !o.shiftKey && (o.preventDefault(), o.stopPropagation(), N.current?.querySelectorAll("li, button")[0]?.focus()), o.key === "Escape" && d && t && (o.preventDefault(), o.stopPropagation(), t.focus(), m?.(k));
178
524
  },
179
- style: { paddingRight: E.length ? "0" : "16px", ...l },
180
- ref: (n) => v.current[M] = n,
181
- onMouseEnter: (n) => j(n, M, E),
182
- onMouseLeave: (n) => j(n, M, []),
183
- className: `${t} ${O.className || ""}`,
525
+ style: { paddingRight: P.length ? "0" : "16px", ...l },
526
+ ref: (o) => y.current[k] = o,
527
+ onMouseEnter: (o) => q(o, k, P),
528
+ onMouseLeave: (o) => q(o, k, []),
529
+ className: `${e} ${O.className || ""}`,
184
530
  ...O,
185
- children: !!E.length && /* @__PURE__ */ L(Tt, { icon: "arrow_right", style: { marginLeft: "auto" } })
531
+ children: !!P.length && /* @__PURE__ */ p(K, { icon: "arrow_right", style: { marginLeft: "auto" } })
186
532
  },
187
- `${M}-${D}`
533
+ `${k}-${C}`
188
534
  );
189
535
  }) })
190
536
  }
191
537
  );
192
538
  };
193
- function At(c, o, r = "right") {
194
- if (!c) return null;
195
- const i = c.getBoundingClientRect(), f = o?.getBoundingClientRect(), d = f?.width || 200, a = f?.height || 300, e = 8, p = window.innerWidth, s = window.innerHeight;
196
- let h = i.bottom + 8 - $, m;
197
- const R = K - $;
198
- if (h + $ + a > s - e) {
199
- const t = i.top - 8 - a - $;
200
- t >= R && (h = t);
539
+ function Ve(s, n, r = "right") {
540
+ if (!s) return null;
541
+ const i = s.getBoundingClientRect(), d = n?.getBoundingClientRect(), u = d?.width || 200, c = d?.height || 300, t = 8, g = window.innerWidth, a = window.innerHeight;
542
+ let h = i.bottom + 8 - z, m;
543
+ const L = U - z;
544
+ if (h + z + c > a - t) {
545
+ const e = i.top - 8 - c - z;
546
+ e >= L && (h = e);
201
547
  }
202
- if (h = Math.max(R, h), r === "right") {
203
- const t = i.right - d;
204
- t >= e ? m = t : m = i.left;
548
+ if (h = Math.max(L, h), r === "right") {
549
+ const e = i.right - u;
550
+ e >= t ? m = e : m = i.left;
205
551
  } else {
206
- const t = i.left;
207
- t + d <= p - e ? m = t : m = i.right - d;
552
+ const e = i.left;
553
+ e + u <= g - t ? m = e : m = i.right - u;
208
554
  }
209
- return m !== void 0 && (m = Math.max(e, Math.min(m, p - d - e))), { top: h, left: m, maxHeight: s - (h + $) - e };
555
+ return m !== void 0 && (m = Math.max(t, Math.min(m, g - u - t))), { top: h, left: m, maxHeight: a - (h + z) - t };
210
556
  }
211
- function Ft(c, o, r = "right") {
212
- const [i, f] = lt(null), d = Z(null), a = xt(() => {
213
- let e = c;
214
- if (!e && o && (e = document.getElementById(o)), !e) {
215
- o && console.warn(`Target element with id '${o}' not found`);
557
+ function je(s, n, r = "right") {
558
+ const [i, d] = de(null), u = oe(null), c = Le(() => {
559
+ let t = s;
560
+ if (!t && n && (t = document.getElementById(n)), !t) {
561
+ n && console.warn(`Target element with id '${n}' not found`);
216
562
  return;
217
563
  }
218
- if (!d.current) return;
219
- const p = At(e, d.current, r);
220
- p && f(
221
- (s) => s && Math.abs(s.top - p.top) < 1 && Math.abs((s.left ?? 0) - (p.left ?? 0)) < 1 && Math.abs((s.maxHeight ?? 0) - (p.maxHeight ?? 0)) < 1 ? s : p
564
+ if (!u.current) return;
565
+ const g = Ve(t, u.current, r);
566
+ g && d(
567
+ (a) => a && Math.abs(a.top - g.top) < 1 && Math.abs((a.left ?? 0) - (g.left ?? 0)) < 1 && Math.abs((a.maxHeight ?? 0) - (g.maxHeight ?? 0)) < 1 ? a : g
222
568
  );
223
- }, [c, o, r]);
224
- return st(() => {
225
- a();
226
- }, [a]), U(() => {
227
- const e = () => requestAnimationFrame(a);
228
- return window.addEventListener("resize", e, { passive: !0 }), window.addEventListener("scroll", e, { passive: !0 }), () => {
229
- window.removeEventListener("resize", e), window.removeEventListener("scroll", e);
569
+ }, [s, n, r]);
570
+ return ce(() => {
571
+ c();
572
+ }, [c]), Y(() => {
573
+ const t = () => requestAnimationFrame(c);
574
+ return window.addEventListener("resize", t, { passive: !0 }), window.addEventListener("scroll", t, { passive: !0 }), () => {
575
+ window.removeEventListener("resize", t), window.removeEventListener("scroll", t);
230
576
  };
231
- }, [a]), U(() => {
232
- if (!d.current) return;
233
- const e = new ResizeObserver(() => {
234
- a();
577
+ }, [c]), Y(() => {
578
+ if (!u.current) return;
579
+ const t = new ResizeObserver(() => {
580
+ c();
235
581
  });
236
- return e.observe(d.current), () => {
237
- e.disconnect();
582
+ return t.observe(u.current), () => {
583
+ t.disconnect();
238
584
  };
239
- }, [a]), { position: i, menuRef: d };
585
+ }, [c]), { position: i, menuRef: u };
240
586
  }
241
- const it = "ayon-menu-dialog", ft = "ayon-menu-content", le = ({
242
- id: c,
243
- target: o,
587
+ const le = "ayon-menu-dialog", me = "ayon-menu-content", gt = ({
588
+ id: s,
589
+ target: n,
244
590
  targetId: r = "",
245
591
  align: i = "right",
246
- theme: f = "light",
247
- children: d,
248
- ...a
592
+ theme: d = "light",
593
+ children: u,
594
+ ...c
249
595
  }) => {
250
- const { menuOpen: e, setMenuOpen: p, navigate: s } = at(), h = e === c, m = () => {
251
- p(!1);
252
- }, R = (t) => {
253
- console.log("navigate and close"), m(), !s && t ? console.log("navigate not found") : s && t && s(t);
596
+ const { menuOpen: t, setMenuOpen: g, navigate: a } = ue(), h = t === s, m = () => {
597
+ g(!1);
598
+ }, L = (e) => {
599
+ console.log("navigate and close"), m(), !a && e ? console.log("navigate not found") : a && e && a(e);
254
600
  };
255
- return h ? /* @__PURE__ */ L(
256
- It,
601
+ return h ? /* @__PURE__ */ p(
602
+ Ge,
257
603
  {
258
604
  handleClose: m,
259
- handleNavigate: R,
260
- target: o,
605
+ handleNavigate: L,
606
+ target: n,
261
607
  targetId: r,
262
608
  align: i,
263
- theme: f,
264
- children: d,
265
- ...a
609
+ theme: d,
610
+ children: u,
611
+ ...c
266
612
  }
267
613
  ) : null;
268
- }, It = ({
269
- handleClose: c,
270
- handleNavigate: o,
614
+ }, Ge = ({
615
+ handleClose: s,
616
+ handleNavigate: n,
271
617
  target: r,
272
618
  targetId: i,
273
- align: f = "right",
274
- children: d,
275
- ...a
619
+ align: d = "right",
620
+ children: u,
621
+ ...c
276
622
  }) => {
277
- const { position: e, menuRef: p } = Ft(r ?? null, i ?? "", f);
278
- U(() => {
279
- e && p.current && p.current.querySelectorAll("li, button")[0]?.focus();
280
- }, [e]);
281
- const s = (t) => {
282
- t.key === "Escape" && c();
283
- }, h = (t) => {
284
- t.target.id === it && c();
285
- }, m = X.Children.map(d, (t, l) => X.isValidElement(t) ? X.cloneElement(t, {
286
- onClose: c,
623
+ const { position: t, menuRef: g } = je(r ?? null, i ?? "", d);
624
+ Y(() => {
625
+ t && g.current && g.current.querySelectorAll("li, button")[0]?.focus();
626
+ }, [t]);
627
+ const a = (e) => {
628
+ e.key === "Escape" && s();
629
+ }, h = (e) => {
630
+ e.target.id === le && s();
631
+ }, m = te.Children.map(u, (e, l) => te.isValidElement(e) ? te.cloneElement(e, {
632
+ onClose: s,
287
633
  index: l,
288
- navigate: o
289
- }) : t);
290
- return Dt(
291
- /* @__PURE__ */ L(
292
- Lt,
634
+ navigate: n
635
+ }) : e);
636
+ return Te(
637
+ /* @__PURE__ */ p(
638
+ De,
293
639
  {
294
640
  open: !0,
295
641
  onClick: h,
296
- onKeyDown: s,
297
- ...a,
298
- id: it,
299
- children: /* @__PURE__ */ L(
300
- Rt,
642
+ onKeyDown: a,
643
+ ...c,
644
+ id: le,
645
+ children: /* @__PURE__ */ p(
646
+ Oe,
301
647
  {
302
- id: ft,
303
- style: e || { top: 0, left: 0, opacity: 0, visibility: "hidden" },
304
- className: kt(f),
305
- ref: p,
648
+ id: me,
649
+ style: t || { top: 0, left: 0, opacity: 0, visibility: "hidden" },
650
+ className: pe(d),
651
+ ref: g,
306
652
  children: m
307
653
  }
308
654
  )
@@ -310,88 +656,88 @@ const it = "ayon-menu-dialog", ft = "ayon-menu-content", le = ({
310
656
  ),
311
657
  document.body
312
658
  );
313
- }, ut = (c, o) => {
314
- for (const r of c) {
315
- if (r.id === o) return r.items?.length ? r.items : void 0;
316
- const i = r.items?.length ? ut(r.items, o) : void 0;
659
+ }, he = (s, n) => {
660
+ for (const r of s) {
661
+ if (r.id === n) return r.items?.length ? r.items : void 0;
662
+ const i = r.items?.length ? he(r.items, n) : void 0;
317
663
  if (i) return i;
318
664
  }
319
- }, Bt = (c = [], o = []) => c.length === o.length && c.every((r, i) => r.icon === o[i].icon && r.tooltip === o[i].tooltip), Nt = (c, o) => c.length === o.length && c.every(
320
- (r, i) => r.id === o[i].id && r.icon === o[i].icon && r.selected === o[i].selected && r.active === o[i].active && Bt(r.endActions, o[i].endActions)
321
- ), ce = ({ menu: c = [], onClose: o, header: r, footer: i = "" }) => {
322
- const { setPowerpackDialog: f } = ct(), { setMenuOpen: d } = at(), [a, e] = lt([]), p = (t, l, u, x) => {
323
- if (u) return o?.();
324
- l?.(t), !x && o && o();
325
- }, s = (t, l) => {
665
+ }, Ke = (s = [], n = []) => s.length === n.length && s.every((r, i) => r.icon === n[i].icon && r.tooltip === n[i].tooltip), Ue = (s, n) => s.length === n.length && s.every(
666
+ (r, i) => r.id === n[i].id && r.icon === n[i].icon && r.selected === n[i].selected && r.active === n[i].active && Ke(r.endActions, n[i].endActions)
667
+ ), mt = ({ menu: s = [], onClose: n, header: r, footer: i = "" }) => {
668
+ const { setPowerpackDialog: d } = ne(), { setMenuOpen: u } = ue(), [c, t] = de([]), g = (e, l, f, w) => {
669
+ if (f) return n?.();
670
+ l?.(e), !w && n && n();
671
+ }, a = (e, l) => {
326
672
  if (l.items.length) {
327
- if (!a.find((u) => u.id === l.id)) {
328
- const u = l.parentEl ?? t.currentTarget ?? t.target;
329
- e([
330
- ...a.filter((x) => x.level < (l.level || 0) + 1),
673
+ if (!c.find((f) => f.id === l.id)) {
674
+ const f = l.parentEl ?? e.currentTarget ?? e.target;
675
+ t([
676
+ ...c.filter((w) => w.level < (l.level || 0) + 1),
331
677
  {
332
678
  ...l,
333
679
  id: l.id,
334
680
  level: (l.level || 0) + 1,
335
- parentRef: u
681
+ parentRef: f
336
682
  }
337
683
  ]);
338
684
  }
339
685
  } else
340
- e(a.filter((u) => u.level <= (l.level || 0)));
341
- }, h = (t, l = {}) => {
342
- const u = t.relatedTarget;
343
- if (!u) return;
344
- if (u.tagName === "DIALOG") return e([]);
345
- typeof u.closest == "function" && u.closest(`#${ft}`) || a.find((v) => v.id === u.id) || e(a.filter((v) => v.level <= (l.level || 0) + 1));
346
- }, m = (t, l) => {
347
- t.type === "mouseenter" || t.type === "keydown" ? s(t, l) : t.type === "mouseleave" && h(t, l);
686
+ t(c.filter((f) => f.level <= (l.level || 0)));
687
+ }, h = (e, l = {}) => {
688
+ const f = e.relatedTarget;
689
+ if (!f) return;
690
+ if (f.tagName === "DIALOG") return t([]);
691
+ typeof f.closest == "function" && f.closest(`#${me}`) || c.find((y) => y.id === f.id) || t(c.filter((y) => y.level <= (l.level || 0) + 1));
692
+ }, m = (e, l) => {
693
+ e.type === "mouseenter" || e.type === "keydown" ? a(e, l) : e.type === "mouseleave" && h(e, l);
348
694
  };
349
- U(() => {
350
- e((t) => {
351
- if (!t.length) return t;
352
- const l = t.flatMap((x) => {
353
- const v = ut(c, x.id);
354
- return v ? [{ ...x, items: v }] : [];
695
+ Y(() => {
696
+ t((e) => {
697
+ if (!e.length) return e;
698
+ const l = e.flatMap((w) => {
699
+ const y = he(s, w.id);
700
+ return y ? [{ ...w, items: y }] : [];
355
701
  });
356
- return l.length === t.length && l.every((x, v) => Nt(x.items, t[v].items)) ? t : l;
702
+ return l.length === e.length && l.every((w, y) => Ue(w.items, e[y].items)) ? e : l;
357
703
  });
358
- }, [c]);
359
- const R = (t, l, u) => {
360
- e((x) => x.map((v) => v.id === t ? { ...v, style: l, placement: u } : v));
704
+ }, [s]);
705
+ const L = (e, l, f) => {
706
+ t((w) => w.map((y) => y.id === e ? { ...y, style: l, placement: f } : y));
361
707
  };
362
- return /* @__PURE__ */ Q(yt, { children: [
363
- /* @__PURE__ */ Q(Ct, { children: [
708
+ return /* @__PURE__ */ Q(ke, { children: [
709
+ /* @__PURE__ */ Q(He, { children: [
364
710
  r && r,
365
- /* @__PURE__ */ L(
366
- ot,
711
+ /* @__PURE__ */ p(
712
+ ae,
367
713
  {
368
- items: c,
369
- handleClick: p,
714
+ items: s,
715
+ handleClick: g,
370
716
  onSubMenu: m,
371
717
  level: 0,
372
- setPowerpackDialog: f,
373
- onMenuClose: () => d(!1)
718
+ setPowerpackDialog: d,
719
+ onMenuClose: () => u(!1)
374
720
  }
375
721
  ),
376
- i && /* @__PURE__ */ Q(St, { children: [
722
+ i && /* @__PURE__ */ Q(qe, { children: [
377
723
  i,
378
- /* @__PURE__ */ L(Ot, { icon: "content_copy", variant: "text", onClick: () => Ht(i) })
724
+ /* @__PURE__ */ p(fe, { icon: "content_copy", variant: "text", onClick: () => Ne(i) })
379
725
  ] })
380
726
  ] }),
381
- a.map((t, l) => /* @__PURE__ */ L(
382
- ot,
727
+ c.map((e, l) => /* @__PURE__ */ p(
728
+ ae,
383
729
  {
384
- ...t,
385
- parentRef: t.parentRef || null,
386
- style: t.style || {},
387
- handleClick: p,
730
+ ...e,
731
+ parentRef: e.parentRef || null,
732
+ style: e.style || {},
733
+ handleClick: g,
388
734
  subMenu: !0,
389
735
  onSubMenu: m,
390
- onSubMenuLayout: R,
391
- onClose: () => e(a.filter((u) => u.id !== t.id)),
392
- onMenuClose: () => d(!1),
393
- onChange: s,
394
- setPowerpackDialog: f,
736
+ onSubMenuLayout: L,
737
+ onClose: () => t(c.filter((f) => f.id !== e.id)),
738
+ onMenuClose: () => u(!1),
739
+ onChange: a,
740
+ setPowerpackDialog: d,
395
741
  itemClassName: void 0,
396
742
  itemStyle: void 0
397
743
  },
@@ -400,11 +746,9 @@ const it = "ayon-menu-dialog", ft = "ayon-menu-content", le = ({
400
746
  ] });
401
747
  };
402
748
  export {
403
- re as E,
404
- le as M,
405
- ce as a,
406
- se as b,
407
- ft as c,
408
- it as d,
409
- ot as e
749
+ gt as M,
750
+ mt as a,
751
+ me as b,
752
+ le as c,
753
+ ae as d
410
754
  };