@nvidia-elements/core 2.22.5 → 2.23.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 (273) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/accordion/accordion2.js +4 -4
  3. package/dist/alert/alert-group2.js +1 -1
  4. package/dist/alert/alert2.js +1 -1
  5. package/dist/avatar/avatar-group2.js +1 -1
  6. package/dist/avatar/avatar2.js +1 -1
  7. package/dist/badge/badge2.js +1 -1
  8. package/dist/breadcrumb/breadcrumb2.js +1 -1
  9. package/dist/bundle.d.ts +4 -0
  10. package/dist/bundles/index.d.ts +336 -0
  11. package/dist/bundles/index.js +14 -14
  12. package/dist/button/button2.js +1 -1
  13. package/dist/button-group/button-group2.js +1 -1
  14. package/dist/card/card2.js +4 -4
  15. package/dist/chat-message/chat-message2.js +1 -1
  16. package/dist/checkbox/checkbox-group2.js +1 -1
  17. package/dist/checkbox/checkbox2.js +1 -1
  18. package/dist/color/color2.js +6 -6
  19. package/dist/combobox/combobox2.js +1 -1
  20. package/dist/copy-button/copy-button2.js +1 -1
  21. package/dist/custom-elements-jsx.d.ts +189 -0
  22. package/dist/custom-elements-vue.d.ts +189 -0
  23. package/dist/custom-elements.json +6555 -0
  24. package/dist/data.html.json +133 -0
  25. package/dist/data.snippets.json +27 -27
  26. package/dist/date/date2.js +6 -6
  27. package/dist/datetime/datetime2.js +6 -6
  28. package/dist/dialog/dialog-footer2.js +1 -1
  29. package/dist/dialog/dialog-header2.js +1 -1
  30. package/dist/dialog/dialog2.js +1 -1
  31. package/dist/divider/divider2.js +1 -1
  32. package/dist/dot/dot2.js +1 -1
  33. package/dist/drag-handle/drag-handle2.js +1 -1
  34. package/dist/drawer/drawer-content2.js +1 -1
  35. package/dist/drawer/drawer-footer2.js +1 -1
  36. package/dist/drawer/drawer-header2.js +1 -1
  37. package/dist/drawer/drawer2.js +1 -1
  38. package/dist/dropdown/dropdown-footer2.js +1 -1
  39. package/dist/dropdown/dropdown-header2.js +1 -1
  40. package/dist/dropdown/dropdown2.js +1 -1
  41. package/dist/dropdown-group/dropdown-group.js +1 -1
  42. package/dist/dropzone/dropzone2.js +1 -1
  43. package/dist/file/file2.js +1 -1
  44. package/dist/format-bytes/format-bytes2.js +1 -1
  45. package/dist/format-datetime/format-datetime2.js +1 -1
  46. package/dist/format-number/format-number2.js +1 -1
  47. package/dist/format-relative-time/format-relative-time2.js +1 -1
  48. package/dist/format-truncate/format-truncate2.js +1 -1
  49. package/dist/forms/control/control2.js +1 -1
  50. package/dist/forms/control-group/control-group2.js +1 -1
  51. package/dist/forms/control-message/control-message2.js +1 -1
  52. package/dist/gauge/gauge2.js +1 -1
  53. package/dist/ghost/define.d.ts +6 -0
  54. package/dist/ghost/define.js +6 -0
  55. package/dist/ghost/define.js.map +1 -0
  56. package/dist/ghost/ghost.d.ts +27 -0
  57. package/dist/ghost/ghost.examples.js +5 -0
  58. package/dist/ghost/ghost.examples.js.map +1 -0
  59. package/dist/ghost/ghost.examples.json +37 -0
  60. package/dist/ghost/ghost.js +5 -0
  61. package/dist/ghost/ghost.js.map +1 -0
  62. package/dist/ghost/ghost2.js +28 -0
  63. package/dist/ghost/ghost2.js.map +1 -0
  64. package/dist/ghost/index.d.ts +1 -0
  65. package/dist/ghost/index.js +1 -0
  66. package/dist/grid/cell/cell2.js +1 -1
  67. package/dist/grid/column/column2.js +1 -1
  68. package/dist/grid/footer/footer2.js +1 -1
  69. package/dist/grid/grid2.js +1 -1
  70. package/dist/grid/header/header2.js +1 -1
  71. package/dist/grid/placeholder/placeholder2.js +1 -1
  72. package/dist/grid/row/row2.js +1 -1
  73. package/dist/icon/icon2.js +2 -2
  74. package/dist/icon-button/icon-button2.js +1 -1
  75. package/dist/iframe/iframe2.js +1 -1
  76. package/dist/index.js +1 -1
  77. package/dist/input/input-group2.js +1 -1
  78. package/dist/input/input2.js +1 -1
  79. package/dist/joystick/joystick2.js +5 -5
  80. package/dist/logo/logo2.js +1 -1
  81. package/dist/menu/menu-group2.js +1 -1
  82. package/dist/menu/menu-item2.js +1 -1
  83. package/dist/menu/menu2.js +1 -1
  84. package/dist/month/month2.js +6 -6
  85. package/dist/notification/notification-group2.js +1 -1
  86. package/dist/notification/notification2.js +1 -1
  87. package/dist/page/page-panel/page-panel-content2.js +1 -1
  88. package/dist/page/page-panel/page-panel-footer2.js +1 -1
  89. package/dist/page/page-panel/page-panel-header2.js +1 -1
  90. package/dist/page/page-panel/page-panel2.js +1 -1
  91. package/dist/page/page2.js +1 -1
  92. package/dist/page-header/page-header2.js +1 -1
  93. package/dist/page-loader/page-loader2.js +1 -1
  94. package/dist/pagination/pagination2.js +1 -1
  95. package/dist/panel/panel2.js +4 -4
  96. package/dist/password/password2.js +6 -6
  97. package/dist/preferences-input/preferences-input2.js +5 -5
  98. package/dist/progress-bar/progress-bar2.js +1 -1
  99. package/dist/progress-dot/progress-dot2.js +1 -1
  100. package/dist/progress-ring/progress-ring2.js +1 -1
  101. package/dist/progressive-filter-chip/progressive-filter-chip2.js +1 -1
  102. package/dist/pulse/pulse2.js +1 -1
  103. package/dist/radio/radio-group2.js +1 -1
  104. package/dist/radio/radio2.js +1 -1
  105. package/dist/range/range2.js +1 -1
  106. package/dist/resize-handle/resize-handle2.js +5 -5
  107. package/dist/search/search2.js +6 -6
  108. package/dist/select/select2.js +1 -1
  109. package/dist/skeleton/skeleton2.js +1 -1
  110. package/dist/sort-button/sort-button2.js +1 -1
  111. package/dist/sparkline/sparkline2.js +1 -1
  112. package/dist/star-rating/star-rating2.js +1 -1
  113. package/dist/steps/steps2.js +6 -6
  114. package/dist/switch/switch-group2.js +1 -1
  115. package/dist/switch/switch2.js +1 -1
  116. package/dist/tabs/tabs-group2.js +1 -1
  117. package/dist/tabs/tabs-item-group2.js +1 -1
  118. package/dist/tabs/tabs2.js +2 -2
  119. package/dist/tag/tag2.js +5 -5
  120. package/dist/textarea/textarea2.js +1 -1
  121. package/dist/time/time2.js +6 -6
  122. package/dist/toast/toast2.js +1 -1
  123. package/dist/toggletip/toggletip-footer2.js +1 -1
  124. package/dist/toggletip/toggletip-header2.js +1 -1
  125. package/dist/toggletip/toggletip2.js +1 -1
  126. package/dist/toolbar/toolbar2.js +1 -1
  127. package/dist/tooltip/tooltip2.js +1 -1
  128. package/dist/tree/tree-node2.js +1 -1
  129. package/dist/tree/tree2.js +1 -1
  130. package/dist/week/week2.js +6 -6
  131. package/dist/workspace/controllers/workspace-command.controller.d.ts +34 -0
  132. package/dist/workspace/controllers/workspace-command.controller.js +87 -0
  133. package/dist/workspace/controllers/workspace-command.controller.js.map +1 -0
  134. package/dist/workspace/controllers/workspace-composition.controller.d.ts +54 -0
  135. package/dist/workspace/controllers/workspace-composition.controller.js +169 -0
  136. package/dist/workspace/controllers/workspace-composition.controller.js.map +1 -0
  137. package/dist/workspace/controllers/workspace-fullscreen.controller.d.ts +25 -0
  138. package/dist/workspace/controllers/workspace-fullscreen.controller.js +84 -0
  139. package/dist/workspace/controllers/workspace-fullscreen.controller.js.map +1 -0
  140. package/dist/workspace/controllers/workspace-measurement.controller.d.ts +19 -0
  141. package/dist/workspace/controllers/workspace-measurement.controller.js +188 -0
  142. package/dist/workspace/controllers/workspace-measurement.controller.js.map +1 -0
  143. package/dist/workspace/controllers/workspace-rearrange.controller.d.ts +40 -0
  144. package/dist/workspace/controllers/workspace-rearrange.controller.js +385 -0
  145. package/dist/workspace/controllers/workspace-rearrange.controller.js.map +1 -0
  146. package/dist/workspace/controllers/workspace-resize.controller.d.ts +43 -0
  147. package/dist/workspace/controllers/workspace-resize.controller.js +168 -0
  148. package/dist/workspace/controllers/workspace-resize.controller.js.map +1 -0
  149. package/dist/workspace/controllers/workspace-restoration.controller.d.ts +24 -0
  150. package/dist/workspace/controllers/workspace-restoration.controller.js +193 -0
  151. package/dist/workspace/controllers/workspace-restoration.controller.js.map +1 -0
  152. package/dist/workspace/define.d.ts +10 -0
  153. package/dist/workspace/define.js +9 -0
  154. package/dist/workspace/define.js.map +1 -0
  155. package/dist/workspace/index.d.ts +8 -0
  156. package/dist/workspace/index.js +6 -0
  157. package/dist/workspace/panel/panel.d.ts +48 -0
  158. package/dist/workspace/panel/panel.js +5 -0
  159. package/dist/workspace/panel/panel.js.map +1 -0
  160. package/dist/workspace/panel/panel2.js +53 -0
  161. package/dist/workspace/panel/panel2.js.map +1 -0
  162. package/dist/workspace/panel-content/panel-content.d.ts +20 -0
  163. package/dist/workspace/panel-content/panel-content.js +5 -0
  164. package/dist/workspace/panel-content/panel-content.js.map +1 -0
  165. package/dist/workspace/panel-content/panel-content2.js +22 -0
  166. package/dist/workspace/panel-content/panel-content2.js.map +1 -0
  167. package/dist/workspace/panel-footer/panel-footer.d.ts +24 -0
  168. package/dist/workspace/panel-footer/panel-footer.js +5 -0
  169. package/dist/workspace/panel-footer/panel-footer.js.map +1 -0
  170. package/dist/workspace/panel-footer/panel-footer2.js +28 -0
  171. package/dist/workspace/panel-footer/panel-footer2.js.map +1 -0
  172. package/dist/workspace/panel-header/panel-header.d.ts +61 -0
  173. package/dist/workspace/panel-header/panel-header.js +5 -0
  174. package/dist/workspace/panel-header/panel-header.js.map +1 -0
  175. package/dist/workspace/panel-header/panel-header2.js +102 -0
  176. package/dist/workspace/panel-header/panel-header2.js.map +1 -0
  177. package/dist/workspace/utils/evaluation.utils.d.ts +83 -0
  178. package/dist/workspace/utils/evaluation.utils.js +294 -0
  179. package/dist/workspace/utils/evaluation.utils.js.map +1 -0
  180. package/dist/workspace/utils/geometry/allocation.utils.d.ts +40 -0
  181. package/dist/workspace/utils/geometry/allocation.utils.js +73 -0
  182. package/dist/workspace/utils/geometry/allocation.utils.js.map +1 -0
  183. package/dist/workspace/utils/geometry/partition.utils.d.ts +10 -0
  184. package/dist/workspace/utils/geometry/partition.utils.js +40 -0
  185. package/dist/workspace/utils/geometry/partition.utils.js.map +1 -0
  186. package/dist/workspace/utils/geometry/sizing.utils.d.ts +35 -0
  187. package/dist/workspace/utils/geometry/sizing.utils.js +42 -0
  188. package/dist/workspace/utils/geometry/sizing.utils.js.map +1 -0
  189. package/dist/workspace/utils/interaction/boundary.utils.d.ts +40 -0
  190. package/dist/workspace/utils/interaction/boundary.utils.js +91 -0
  191. package/dist/workspace/utils/interaction/boundary.utils.js.map +1 -0
  192. package/dist/workspace/utils/interaction/command.utils.d.ts +74 -0
  193. package/dist/workspace/utils/interaction/command.utils.js +189 -0
  194. package/dist/workspace/utils/interaction/command.utils.js.map +1 -0
  195. package/dist/workspace/utils/interaction/drag-preview.utils.d.ts +79 -0
  196. package/dist/workspace/utils/interaction/drag-preview.utils.js +16 -0
  197. package/dist/workspace/utils/interaction/drag-preview.utils.js.map +1 -0
  198. package/dist/workspace/utils/interaction/insertion-offers.utils.d.ts +58 -0
  199. package/dist/workspace/utils/interaction/insertion-offers.utils.js +259 -0
  200. package/dist/workspace/utils/interaction/insertion-offers.utils.js.map +1 -0
  201. package/dist/workspace/utils/interaction/placement-decision.utils.d.ts +55 -0
  202. package/dist/workspace/utils/interaction/placement-decision.utils.js +242 -0
  203. package/dist/workspace/utils/interaction/placement-decision.utils.js.map +1 -0
  204. package/dist/workspace/utils/interaction/resize-input.utils.d.ts +1 -0
  205. package/dist/workspace/utils/interaction/resize-input.utils.js +17 -0
  206. package/dist/workspace/utils/interaction/resize-input.utils.js.map +1 -0
  207. package/dist/workspace/utils/model/layout.utils.d.ts +22 -0
  208. package/dist/workspace/utils/model/layout.utils.js +41 -0
  209. package/dist/workspace/utils/model/layout.utils.js.map +1 -0
  210. package/dist/workspace/utils/model/membership.utils.d.ts +14 -0
  211. package/dist/workspace/utils/model/membership.utils.js +17 -0
  212. package/dist/workspace/utils/model/membership.utils.js.map +1 -0
  213. package/dist/workspace/utils/model/operations.utils.d.ts +31 -0
  214. package/dist/workspace/utils/model/operations.utils.js +178 -0
  215. package/dist/workspace/utils/model/operations.utils.js.map +1 -0
  216. package/dist/workspace/utils/model/projection.utils.d.ts +7 -0
  217. package/dist/workspace/utils/model/projection.utils.js +87 -0
  218. package/dist/workspace/utils/model/projection.utils.js.map +1 -0
  219. package/dist/workspace/utils/model/value.utils.d.ts +5 -0
  220. package/dist/workspace/utils/model/value.utils.js +68 -0
  221. package/dist/workspace/utils/model/value.utils.js.map +1 -0
  222. package/dist/workspace/utils/placement/acquisition-sizing.utils.d.ts +32 -0
  223. package/dist/workspace/utils/placement/acquisition-sizing.utils.js +152 -0
  224. package/dist/workspace/utils/placement/acquisition-sizing.utils.js.map +1 -0
  225. package/dist/workspace/utils/placement/context.utils.d.ts +36 -0
  226. package/dist/workspace/utils/placement/context.utils.js +135 -0
  227. package/dist/workspace/utils/placement/context.utils.js.map +1 -0
  228. package/dist/workspace/utils/placement/group-insertion.utils.d.ts +26 -0
  229. package/dist/workspace/utils/placement/group-insertion.utils.js +171 -0
  230. package/dist/workspace/utils/placement/group-insertion.utils.js.map +1 -0
  231. package/dist/workspace/utils/placement/origin.utils.d.ts +13 -0
  232. package/dist/workspace/utils/placement/origin.utils.js +49 -0
  233. package/dist/workspace/utils/placement/origin.utils.js.map +1 -0
  234. package/dist/workspace/utils/placement/planner.utils.d.ts +22 -0
  235. package/dist/workspace/utils/placement/planner.utils.js +184 -0
  236. package/dist/workspace/utils/placement/planner.utils.js.map +1 -0
  237. package/dist/workspace/utils/placement/preparation.utils.d.ts +28 -0
  238. package/dist/workspace/utils/placement/preparation.utils.js +140 -0
  239. package/dist/workspace/utils/placement/preparation.utils.js.map +1 -0
  240. package/dist/workspace/utils/placement/region.utils.d.ts +15 -0
  241. package/dist/workspace/utils/placement/region.utils.js +111 -0
  242. package/dist/workspace/utils/placement/region.utils.js.map +1 -0
  243. package/dist/workspace/utils/placement/split-sizing.utils.d.ts +18 -0
  244. package/dist/workspace/utils/placement/split-sizing.utils.js +108 -0
  245. package/dist/workspace/utils/placement/split-sizing.utils.js.map +1 -0
  246. package/dist/workspace/utils/presentation/composition.utils.d.ts +17 -0
  247. package/dist/workspace/utils/presentation/composition.utils.js +95 -0
  248. package/dist/workspace/utils/presentation/composition.utils.js.map +1 -0
  249. package/dist/workspace/utils/presentation/groups.utils.d.ts +91 -0
  250. package/dist/workspace/utils/presentation/groups.utils.js +169 -0
  251. package/dist/workspace/utils/presentation/groups.utils.js.map +1 -0
  252. package/dist/workspace/utils/presentation/header-configuration.utils.d.ts +11 -0
  253. package/dist/workspace/utils/presentation/header-configuration.utils.js +7 -0
  254. package/dist/workspace/utils/presentation/header-configuration.utils.js.map +1 -0
  255. package/dist/workspace/utils/presentation/measurements.utils.d.ts +21 -0
  256. package/dist/workspace/utils/presentation/measurements.utils.js +28 -0
  257. package/dist/workspace/utils/presentation/measurements.utils.js.map +1 -0
  258. package/dist/workspace/utils/presentation/offers.utils.d.ts +43 -0
  259. package/dist/workspace/utils/presentation/offers.utils.js +137 -0
  260. package/dist/workspace/utils/presentation/offers.utils.js.map +1 -0
  261. package/dist/workspace/utils/presentation/preview.utils.d.ts +6 -0
  262. package/dist/workspace/utils/presentation/preview.utils.js +36 -0
  263. package/dist/workspace/utils/presentation/preview.utils.js.map +1 -0
  264. package/dist/workspace/workspace.d.ts +103 -0
  265. package/dist/workspace/workspace.examples.js +5 -0
  266. package/dist/workspace/workspace.examples.js.map +1 -0
  267. package/dist/workspace/workspace.examples.json +133 -0
  268. package/dist/workspace/workspace.js +5 -0
  269. package/dist/workspace/workspace.js.map +1 -0
  270. package/dist/workspace/workspace.types.d.ts +3 -0
  271. package/dist/workspace/workspace2.js +518 -0
  272. package/dist/workspace/workspace2.js.map +1 -0
  273. package/package.json +25 -1
@@ -0,0 +1,385 @@
1
+ import { GestureController as e } from "../../internal/controllers/gesture.controller.js";
2
+ import { nonnegativeFiniteOr as t } from "../../internal/utils/numeric.js";
3
+ import { findGroup as n } from "../utils/model/operations.utils.js";
4
+ import { captureTabScroll as r, captureWorkspaceFocus as i } from "../utils/presentation/composition.utils.js";
5
+ import { getAllocatedTabWidth as a, getInitialDragCue as o } from "../utils/presentation/groups.utils.js";
6
+ import { createWorkspacePlacementPlanner as s } from "../utils/placement/planner.utils.js";
7
+ import { getWorkspacePanelSource as c } from "../utils/model/membership.utils.js";
8
+ import { decidePlacement as l, decidePointerPlacement as u } from "../utils/interaction/placement-decision.utils.js";
9
+ import { createInitialReservation as d } from "../utils/placement/origin.utils.js";
10
+ import { evaluatePlacementOffer as f } from "../utils/placement/preparation.utils.js";
11
+ // src/workspace/controllers/workspace-rearrange.controller.ts
12
+ var p = class {
13
+ #e;
14
+ #t;
15
+ #n;
16
+ #r;
17
+ #i;
18
+ #a;
19
+ #o = !1;
20
+ #s;
21
+ #c;
22
+ constructor(t, n) {
23
+ this.#e = t, this.#t = n, this.#n = new e(t, {
24
+ claimPriority: "descendant-first",
25
+ suppressNativeDrag: !0,
26
+ shouldIgnoreEvent: (e) => {
27
+ let t = this.#h(e);
28
+ return !this.#r && !this.#_(t) || this.#c !== void 0 || !t;
29
+ }
30
+ }), this.#n.target = t, t.addController(this);
31
+ }
32
+ get capabilities() {
33
+ return this.#r?.capabilities;
34
+ }
35
+ get suppressSelection() {
36
+ return this.#o || this.#r?.phase === "attached" || this.#r?.phase === "detached";
37
+ }
38
+ hostConnected() {
39
+ this.#a = this.#e.ownerDocument, this.#e.addEventListener("nve-gesture-input", this.#y), this.#e.addEventListener("nve-gesture", this.#N), this.#e.addEventListener("click", this.#f, !0), this.#a.addEventListener("keydown", this.#d), this.#a.addEventListener("pointerdown", this.#u, !0);
40
+ }
41
+ hostDisconnected() {
42
+ this.#e.removeEventListener("nve-gesture-input", this.#y), this.#e.removeEventListener("nve-gesture", this.#N), this.#e.removeEventListener("click", this.#f, !0), this.#a?.removeEventListener("keydown", this.#d), this.#a?.removeEventListener("pointerdown", this.#u, !0), this.#a = void 0, this.cancel();
43
+ }
44
+ getPreviewHint(e, t) {
45
+ if (e.phase === "detached" && e.point) return l({
46
+ ...t.targetCatalog(e.source),
47
+ preview: e,
48
+ source: e.source,
49
+ point: e.point,
50
+ local: e.intent,
51
+ header: !1,
52
+ currentLayout: this.#t.getLayout() ?? {
53
+ version: 1,
54
+ root: null,
55
+ closed: []
56
+ },
57
+ available: t.available,
58
+ projectLayout: t.projectLayout,
59
+ planPlacement: this.#i
60
+ }).hint;
61
+ }
62
+ handleMeasurementsChange(e) {
63
+ e.spaceChanged ? this.cancel() : this.refresh();
64
+ }
65
+ refresh() {
66
+ let e = this.#r;
67
+ e && e.phase !== "pressed" && (e.phase === "attached" ? (e.initialCue = this.#x(e.source, e.group), e.preview = {
68
+ ...e.preview,
69
+ cue: e.initialCue
70
+ }, this.#t.applyPreview(e.preview)) : (e.pendingRefresh = !0, this.#I(e)));
71
+ }
72
+ cancelForUser() {
73
+ if (this.#c) return;
74
+ let e = this.#r;
75
+ if (!e || e.phase === "pressed") {
76
+ this.cancel();
77
+ return;
78
+ }
79
+ e.phase === "detached" && this.#L(e), this.#m(), this.#r = void 0, this.#o = !0;
80
+ let t = e;
81
+ this.#c = t;
82
+ let n = this.#E(e);
83
+ e.restoreScroll?.(), this.#O(n, t);
84
+ }
85
+ cancel() {
86
+ this.#m(), this.#c = void 0, this.#o ||= this.#r !== void 0 && this.#r.phase !== "pressed", this.#r?.phase === "detached" && this.#L(this.#r), this.#r = void 0, this.#i = void 0, this.#t.applyPreview(void 0);
87
+ }
88
+ #l(e) {
89
+ let t = (t) => {
90
+ let n = this.#S(e.source, t.intent, { selected: t });
91
+ if (!n) return t;
92
+ let { feasible: r, context: i, seams: a, ...o } = n;
93
+ return {
94
+ ...t,
95
+ ...o,
96
+ seams: a,
97
+ context: i,
98
+ blocked: !r
99
+ };
100
+ }, n = e.lastFeasible === e.preview;
101
+ e.lastFeasible = t(e.lastFeasible), e.preview = n ? e.lastFeasible : t(e.preview);
102
+ }
103
+ #u = () => {
104
+ this.#c && this.cancel(), this.#o = !1;
105
+ };
106
+ #d = (e) => {
107
+ this.#c && e.key !== "Escape" && !e.repeat && this.cancel(), e.key === "Escape" && !e.defaultPrevented && this.#r && (e.preventDefault(), this.cancelForUser());
108
+ };
109
+ #f = (e) => {
110
+ this.#o &&= (e instanceof MouseEvent && e.detail === 0 || (e.preventDefault(), e.stopImmediatePropagation()), !1);
111
+ };
112
+ #p(e) {
113
+ this.#s ??= {
114
+ value: this.#e.style.getPropertyValue("cursor"),
115
+ priority: this.#e.style.getPropertyPriority("cursor"),
116
+ owned: e
117
+ }, this.#s.owned = e, this.#e.style.setProperty("cursor", e, "important");
118
+ }
119
+ #m() {
120
+ let e = this.#s;
121
+ e && (this.#s = void 0, this.#e.style.getPropertyValue("cursor") === e.owned && this.#e.style.getPropertyPriority("cursor") === "important" && (e.value ? this.#e.style.setProperty("cursor", e.value, e.priority) : this.#e.style.removeProperty("cursor")));
122
+ }
123
+ #h(e) {
124
+ return e.composedPath().find((e) => e instanceof HTMLElement && e.getRootNode() === this.#e.shadowRoot && (e.hasAttribute("data-panel") || e.hasAttribute("data-drag-group")));
125
+ }
126
+ #g() {
127
+ return {
128
+ rearrangeable: this.#e.rearrangeable,
129
+ groupable: this.#e.groupable
130
+ };
131
+ }
132
+ #_(e, t = this.#g()) {
133
+ return !!e && this.#t.isRearrangementAllowed() && t.rearrangeable && (t.groupable || e.localName !== "nve-tabs-item");
134
+ }
135
+ #v(e) {
136
+ let t = this.#t.getLayout();
137
+ return e.dataset.panel ? c({
138
+ layout: t,
139
+ anchor: e.dataset.panel,
140
+ available: this.#t.getAvailablePanels()
141
+ }) : e.dataset.dragGroup ? [...n(t?.root ?? null, e.dataset.dragGroup)?.panels ?? []] : void 0;
142
+ }
143
+ #y = (e) => {
144
+ if (e.target !== this.#e) return;
145
+ let t = e.detail;
146
+ t.kind === "pointerdown" ? this.#b(t) : t.kind === "pointerend" && this.#C(t);
147
+ };
148
+ #b(e) {
149
+ let n = this.#h(e.event);
150
+ if (!n) return;
151
+ let i = this.#g(), a = this.#v(n);
152
+ if (!a || !this.#_(n, i) || e.event.button !== 0 || !e.event.isPrimary || this.#r || !e.claim({ kind: "drag" })) return;
153
+ this.#o = !1;
154
+ let o = this.#e.detachThreshold, c = this.#x(a, n.hasAttribute("data-drag-group")), l = this.#t.getLayout();
155
+ l && (this.#i = s()), this.#r = {
156
+ source: a,
157
+ phase: "pressed",
158
+ capabilities: i,
159
+ initialAllocation: { allocation: "committed" },
160
+ initialPlacement: l ? d({
161
+ layout: l,
162
+ source: a,
163
+ cue: c,
164
+ available: this.#t.getAvailablePanels(),
165
+ evaluate: (e) => this.#S(a, e)
166
+ }) : void 0,
167
+ detachThreshold: t(o, 48),
168
+ group: n.hasAttribute("data-drag-group"),
169
+ controlRect: n.getBoundingClientRect(),
170
+ initialCue: c,
171
+ restoreScroll: r(this.#e)
172
+ };
173
+ }
174
+ #x(e, t) {
175
+ return this.#t.evaluateWithContext((n) => {
176
+ let r = this.#t.getLayout() ?? {
177
+ version: 1,
178
+ root: null,
179
+ closed: []
180
+ }, i = this.#t.getMeasurements();
181
+ return o({
182
+ groups: n.geometry(n.project(r)).groups,
183
+ source: e,
184
+ groupDrag: t,
185
+ bounds: n.bounds(),
186
+ client: (e) => n.client(e),
187
+ measurements: i,
188
+ width: (e) => a(e, i),
189
+ scroll: (e) => n.scroll(e)
190
+ });
191
+ });
192
+ }
193
+ #S(e, t, n) {
194
+ return this.#t.evaluateWithContext((r) => {
195
+ let i = this.#t.getLayout();
196
+ if (i && t.kind !== "invalid") return f({
197
+ evaluation: r,
198
+ layout: i,
199
+ measurements: this.#t.getMeasurements(),
200
+ source: e,
201
+ intent: t,
202
+ context: n,
203
+ planner: this.#i,
204
+ groupable: this.#r?.capabilities.groupable ?? this.#e.groupable,
205
+ currentRegions: () => r.presentationGeometry().regions
206
+ });
207
+ });
208
+ }
209
+ #C(e) {
210
+ let t = this.#r;
211
+ t && (e.interrupted || e.reason !== "up" ? this.cancelForUser() : t.phase === "detached" && !this.#T(t) ? this.#r === t && this.cancelForUser() : this.#w(t, e));
212
+ }
213
+ #w(e, t) {
214
+ let n = e.phase === "detached" && this.#j(e);
215
+ e.phase === "pressed" && this.#M(e, t), this.#o = !0, this.cancel(), e.phase !== "pressed" && this.#k(e, n);
216
+ }
217
+ #T(e) {
218
+ return this.#L(e), e.initialPaint = !1, this.#R(e), this.#r === e && !e.preview.blocked;
219
+ }
220
+ #E(e) {
221
+ let t = {
222
+ source: e.source,
223
+ ...e.initialAllocation,
224
+ phase: e.phase === "attached" ? "returning-attached" : "returning-detached",
225
+ intent: { kind: "invalid" },
226
+ cue: this.#x(e.source, e.group),
227
+ blocked: !1
228
+ };
229
+ return this.#i = void 0, this.#t.applyPreview(t), this.#D(e);
230
+ }
231
+ async #D(e) {
232
+ if (await this.#e.updateComplete, this.#c !== e) return;
233
+ let t = this.#e.shadowRoot?.querySelector("[data-destination-ghost]");
234
+ t && (t.getBoundingClientRect(), await Promise.allSettled(t.getAnimations().map((e) => e.finished)));
235
+ }
236
+ async #O(e, t) {
237
+ await e, this.#c === t && (this.#t.applyPreview(void 0), this.#A(t));
238
+ }
239
+ #k(e, t) {
240
+ this.#c = e, t || e.restoreScroll?.(), this.#A(e);
241
+ }
242
+ async #A(e) {
243
+ await this.#e.updateComplete, this.#c === e && (this.#c = void 0, e.restoreFocus?.());
244
+ }
245
+ #j(e) {
246
+ let t = e.preview.intent;
247
+ return t.kind !== "invalid" && this.#t.commitPlacement(e.source, t, e.preview.allocation === "reserved" ? e.preview.layout : void 0);
248
+ }
249
+ #M(e, t) {
250
+ let n = e.controlRect;
251
+ t.clientX >= n.x && t.clientX <= n.x + n.width && t.clientY >= n.y && t.clientY <= n.y + n.height && this.#t.activateSource(e.source, e.group);
252
+ }
253
+ #N = (e) => {
254
+ let t = e.detail, n = this.#r;
255
+ if (!n || t.kind !== "drag") return;
256
+ let r = Math.hypot(t.totalDisplacementX, t.totalDisplacementY);
257
+ if (n.phase === "pressed" && r < 6) return;
258
+ let a = {
259
+ x: t.clientX,
260
+ y: t.clientY
261
+ };
262
+ if (n.phase === "detached") {
263
+ this.#F(n, a);
264
+ return;
265
+ }
266
+ let o = {
267
+ ...n,
268
+ restoreFocus: n.phase === "pressed" ? i(this.#e) : n.restoreFocus,
269
+ phase: "attached",
270
+ point: a,
271
+ preview: {
272
+ source: n.source,
273
+ phase: "attached",
274
+ point: a,
275
+ intent: { kind: "invalid" },
276
+ cue: n.initialCue,
277
+ blocked: !1
278
+ }
279
+ };
280
+ this.#p("grabbing"), r >= n.detachThreshold ? this.#P(o) : (this.#r = o, this.#t.applyPreview(o.preview));
281
+ };
282
+ #P(e) {
283
+ let { feasible: t, ...n } = e.initialPlacement?.offer ?? {
284
+ ...e.initialAllocation,
285
+ cue: e.initialCue,
286
+ feasible: !0
287
+ }, r = {
288
+ ...e.preview,
289
+ ...n,
290
+ intent: e.initialPlacement?.intent ?? e.preview.intent,
291
+ context: n.context,
292
+ blocked: !t,
293
+ phase: "detached"
294
+ }, i = {
295
+ ...e,
296
+ phase: "detached",
297
+ preview: r,
298
+ lastFeasible: r,
299
+ pendingInput: !0,
300
+ pendingRefresh: !1,
301
+ initialPaint: !0
302
+ };
303
+ this.#r = i, this.#t.applyPreview(r), this.#I(i);
304
+ }
305
+ #F(e, t) {
306
+ e.point = t, e.pendingInput = !0, this.#I(e);
307
+ }
308
+ #I(e) {
309
+ if (e.pendingFrame !== void 0) return;
310
+ let t = requestAnimationFrame(() => {
311
+ this.#r === e && e.pendingFrame === t && (e.pendingFrame = void 0, e.initialPaint && (e.initialPaint = !1, this.#e.shadowRoot?.querySelector("[data-destination-ghost]")?.getBoundingClientRect()), this.#R(e));
312
+ });
313
+ e.pendingFrame = t;
314
+ }
315
+ #L(e) {
316
+ e.pendingFrame !== void 0 && cancelAnimationFrame(e.pendingFrame), e.pendingFrame = void 0;
317
+ }
318
+ #R(e) {
319
+ let t = e.pendingInput, n = e.pendingRefresh;
320
+ e.pendingInput = !1, e.pendingRefresh = !1, n && this.#l(e), this.#r === e && (t ? this.#z(e, e.point) : n && this.#H(e.preview));
321
+ }
322
+ #z(e, t) {
323
+ this.#t.evaluateWithContext((n) => this.#B(e, t, n));
324
+ }
325
+ #B(e, t, n) {
326
+ let r = this.#t.getLayout(), { intent: i, acquisition: a } = u({
327
+ placement: n.getPlacementCatalog(e.source, t),
328
+ canonicalRoot: r?.root ?? null,
329
+ currentLayout: r ?? {
330
+ version: 1,
331
+ root: null,
332
+ closed: []
333
+ },
334
+ source: e.source,
335
+ point: t,
336
+ heldIntent: e.preview.intent,
337
+ groupable: e.capabilities.groupable,
338
+ gap: this.#t.getMeasurements().gap,
339
+ available: n.available,
340
+ projectLayout: n.projectLayout,
341
+ planPlacement: this.#i
342
+ });
343
+ if (!i) {
344
+ this.#V(e, t);
345
+ return;
346
+ }
347
+ let o = this.#S(e.source, i, {
348
+ selected: e.preview,
349
+ acquisition: a ? {
350
+ ...a,
351
+ point: t
352
+ } : void 0
353
+ });
354
+ if (!o) {
355
+ e.preview = {
356
+ ...e.preview,
357
+ point: t
358
+ }, this.#t.applyPreview(e.preview);
359
+ return;
360
+ }
361
+ let { feasible: s, context: c, ...l } = o;
362
+ e.preview = {
363
+ context: c,
364
+ ...l,
365
+ source: e.source,
366
+ phase: "detached",
367
+ point: t,
368
+ intent: i,
369
+ cue: o.cue,
370
+ blocked: !s
371
+ }, s && (e.lastFeasible = e.preview), this.#H(e.preview);
372
+ }
373
+ #V(e, t) {
374
+ this.#p(e.lastFeasible.blocked ? "no-drop" : "grabbing"), e.preview = {
375
+ ...e.lastFeasible,
376
+ point: t
377
+ }, this.#t.applyPreview(e.preview);
378
+ }
379
+ #H(e) {
380
+ this.#p(e.blocked ? "no-drop" : "grabbing"), this.#t.applyPreview(e);
381
+ }
382
+ };
383
+ export { p as WorkspaceRearrangeController };
384
+
385
+ //# sourceMappingURL=workspace-rearrange.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-rearrange.controller.js","names":["WorkspaceRearrangeController","#host","host","#delegate","delegate","#gesture","GestureController","control","#findDragControl","event","#session","#allowsDrag","#pendingRecovery","#suppressClick","#document","#input","#movement","#click","#keydown","#freshPointer","preview","decidePlacement","evaluation","#planner","change","session","#createInitialCue","#requestFrame","#cancelFrame","#restoreCursor","recovery","completion","#returnToOrigin","#completeReturnPreview","refresh","offer","#getPlacementOffer","presentation","feasible","sharesPreview","#cursor","cursor","previous","item","#getCapabilities","capabilities","layout","getWorkspacePanelSource","findGroup","input","#start","#end","source","#getDragSource","threshold","initialCue","createWorkspacePlacementPlanner","createInitialReservation","intent","nonnegativeFiniteOr","captureTabScroll","measurements","getInitialDragCue","rect","getAllocatedTabWidth","group","evaluatePlacementOffer","#prepareDrop","#completeInteraction","committed","#drop","#activate","#recoverAfterDrop","#flushPending","#settlePreviewReturn","ghost","animation","#completeRecovery","distance","point","#queueInput","attached","captureWorkspaceFocus","#setCursor","#detach","initial","frame","pointerPending","refreshPending","#refreshSelected","#offerAt","#publish","#evaluateOffer","decidePointerPlacement","#showLastFeasible","acquisition"],"sources":["../../../src/workspace/controllers/workspace-rearrange.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveControllerHost } from 'lit';\n\nimport {\n type Gesture,\n GestureController,\n type GestureInput,\n nonnegativeFiniteOr,\n type Point,\n type Rect\n} from '@nvidia-elements/core/internal';\n\nimport { decidePlacement, decidePointerPlacement } from '../utils/interaction/placement-decision.utils.js';\nimport { getWorkspacePanelSource } from '../utils/model/membership.utils.js';\nimport { findGroup } from '../utils/model/operations.utils.js';\nimport { createInitialReservation } from '../utils/placement/origin.utils.js';\nimport { createWorkspacePlacementPlanner } from '../utils/placement/planner.utils.js';\nimport { evaluatePlacementOffer } from '../utils/placement/preparation.utils.js';\nimport { captureTabScroll, captureWorkspaceFocus } from '../utils/presentation/composition.utils.js';\nimport { getAllocatedTabWidth, getInitialDragCue } from '../utils/presentation/groups.utils.js';\n\nimport type {\n WorkspaceDragAllocation,\n WorkspaceDragCue,\n WorkspaceDragOffer,\n WorkspaceDragPreview,\n WorkspaceDropIntent,\n WorkspaceOfferContext\n} from '../utils/interaction/drag-preview.utils.js';\nimport type { WorkspaceLayout } from '../utils/model/layout.utils.js';\nimport type { WorkspacePlacementPlanner } from '../utils/placement/planner.utils.js';\nimport type { WorkspaceMeasurementChange, WorkspaceMeasurements } from '../utils/presentation/measurements.utils.js';\nimport type { WorkspaceEvaluation } from '../utils/evaluation.utils.js';\n\nexport interface WorkspaceRearrangeCapabilities {\n rearrangeable: boolean;\n groupable: boolean;\n}\n\ntype WorkspaceRearrangeHost = HTMLElement &\n ReactiveControllerHost & {\n readonly rearrangeable: boolean;\n readonly groupable: boolean;\n readonly detachThreshold: number;\n };\n\ninterface WorkspaceRearrangeDelegate {\n readonly evaluateWithContext: <T>(work: (evaluation: WorkspaceEvaluation) => T) => T;\n readonly isRearrangementAllowed: () => boolean;\n readonly getLayout: () => WorkspaceLayout | undefined;\n readonly getAvailablePanels: () => string[];\n readonly getMeasurements: () => WorkspaceMeasurements;\n readonly activateSource: (source: string[], group: boolean) => void;\n readonly applyPreview: (preview: WorkspaceDragPreview | undefined) => void;\n readonly commitPlacement: (\n source: string[],\n intent: Exclude<WorkspaceDropIntent, { kind: 'invalid' }>,\n layout?: WorkspaceLayout\n ) => boolean;\n}\n\ntype AttachedPreview = Extract<WorkspaceDragPreview, { phase: 'attached' }>;\n\ntype DetachedPreview = Extract<WorkspaceDragPreview, { phase: 'detached' }>;\n\ninterface SessionOrigin {\n capabilities: WorkspaceRearrangeCapabilities;\n source: string[];\n group: boolean;\n controlRect: Rect;\n initialCue: WorkspaceDragCue;\n detachThreshold: number;\n initialAllocation: WorkspaceDragAllocation;\n initialPlacement?: { intent: WorkspaceDropIntent; offer: WorkspaceDragOffer };\n restoreScroll?: () => void;\n restoreFocus?: () => void;\n}\n\ntype AttachedSession = SessionOrigin & {\n phase: 'attached';\n point: Point;\n preview: AttachedPreview;\n};\n\ntype DetachedSession = SessionOrigin & {\n phase: 'detached';\n point: Point;\n preview: DetachedPreview;\n lastFeasible: DetachedPreview;\n pendingFrame?: number;\n pendingInput: boolean;\n pendingRefresh: boolean;\n initialPaint: boolean;\n};\n\ntype WorkspaceRearrangeControllerSession = (SessionOrigin & { phase: 'pressed' }) | AttachedSession | DetachedSession;\n\nexport class WorkspaceRearrangeController {\n readonly #host: WorkspaceRearrangeHost;\n\n readonly #delegate: WorkspaceRearrangeDelegate;\n\n readonly #gesture: GestureController;\n\n #session?: WorkspaceRearrangeControllerSession;\n\n #planner?: WorkspacePlacementPlanner;\n\n #document?: Document;\n\n #suppressClick = false;\n\n #cursor?: { value: string; priority: string; owned: string };\n\n #pendingRecovery?: SessionOrigin;\n\n constructor(host: WorkspaceRearrangeHost, delegate: WorkspaceRearrangeDelegate) {\n this.#host = host;\n this.#delegate = delegate;\n this.#gesture = new GestureController(host, {\n claimPriority: 'descendant-first',\n suppressNativeDrag: true,\n shouldIgnoreEvent: event => {\n const control = this.#findDragControl(event);\n return (!this.#session && !this.#allowsDrag(control)) || this.#pendingRecovery !== undefined || !control;\n }\n });\n this.#gesture.target = host;\n host.addController(this);\n }\n\n get capabilities() {\n return this.#session?.capabilities;\n }\n\n get suppressSelection() {\n return this.#suppressClick || this.#session?.phase === 'attached' || this.#session?.phase === 'detached';\n }\n\n hostConnected() {\n this.#document = this.#host.ownerDocument;\n this.#host.addEventListener('nve-gesture-input', this.#input as EventListener);\n this.#host.addEventListener('nve-gesture', this.#movement as EventListener);\n this.#host.addEventListener('click', this.#click, true);\n this.#document.addEventListener('keydown', this.#keydown);\n this.#document.addEventListener('pointerdown', this.#freshPointer, true);\n }\n\n hostDisconnected() {\n this.#host.removeEventListener('nve-gesture-input', this.#input as EventListener);\n this.#host.removeEventListener('nve-gesture', this.#movement as EventListener);\n this.#host.removeEventListener('click', this.#click, true);\n this.#document?.removeEventListener('keydown', this.#keydown);\n this.#document?.removeEventListener('pointerdown', this.#freshPointer, true);\n this.#document = undefined;\n this.cancel();\n }\n\n getPreviewHint(preview: WorkspaceDragPreview, evaluation: WorkspaceEvaluation) {\n if (preview.phase !== 'detached' || !preview.point) return undefined;\n\n return decidePlacement({\n ...evaluation.targetCatalog(preview.source),\n preview,\n source: preview.source,\n point: preview.point,\n local: preview.intent,\n header: false,\n currentLayout: this.#delegate.getLayout() ?? { version: 1, root: null, closed: [] },\n available: evaluation.available,\n projectLayout: evaluation.projectLayout,\n planPlacement: this.#planner\n }).hint;\n }\n\n handleMeasurementsChange(change: WorkspaceMeasurementChange) {\n if (change.spaceChanged) {\n this.cancel();\n } else {\n this.refresh();\n }\n }\n\n refresh() {\n const session = this.#session;\n if (!session || session.phase === 'pressed') return;\n if (session.phase === 'attached') {\n session.initialCue = this.#createInitialCue(session.source, session.group);\n session.preview = { ...session.preview, cue: session.initialCue };\n this.#delegate.applyPreview(session.preview);\n return;\n }\n session.pendingRefresh = true;\n this.#requestFrame(session);\n }\n\n cancelForUser() {\n if (this.#pendingRecovery) return;\n const session = this.#session;\n if (!session || session.phase === 'pressed') {\n this.cancel();\n return;\n }\n if (session.phase === 'detached') {\n this.#cancelFrame(session);\n }\n this.#restoreCursor();\n this.#session = undefined;\n this.#suppressClick = true;\n const recovery = session;\n this.#pendingRecovery = recovery;\n const completion = this.#returnToOrigin(session);\n session.restoreScroll?.();\n void this.#completeReturnPreview(completion, recovery);\n }\n\n cancel() {\n this.#restoreCursor();\n this.#pendingRecovery = undefined;\n this.#suppressClick ||= this.#session !== undefined && this.#session.phase !== 'pressed';\n if (this.#session?.phase === 'detached') {\n this.#cancelFrame(this.#session);\n }\n this.#session = undefined;\n this.#planner = undefined;\n this.#delegate.applyPreview(undefined);\n }\n\n #refreshSelected(session: DetachedSession) {\n const refresh = (preview: DetachedPreview): DetachedPreview => {\n const offer = this.#getPlacementOffer(session.source, preview.intent, { selected: preview });\n if (!offer) return preview;\n const { feasible, context, seams, ...presentation } = offer;\n return {\n ...preview,\n ...presentation,\n seams,\n context: context,\n blocked: !feasible\n };\n };\n const sharesPreview = session.lastFeasible === session.preview;\n session.lastFeasible = refresh(session.lastFeasible);\n session.preview = sharesPreview ? session.lastFeasible : refresh(session.preview);\n }\n\n #freshPointer = () => {\n if (this.#pendingRecovery) {\n this.cancel();\n }\n this.#suppressClick = false;\n };\n\n #keydown = (event: KeyboardEvent) => {\n if (this.#pendingRecovery && event.key !== 'Escape' && !event.repeat) {\n this.cancel();\n }\n if (event.key === 'Escape' && !event.defaultPrevented && this.#session) {\n event.preventDefault();\n this.cancelForUser();\n }\n };\n\n #click = (event: Event) => {\n if (!this.#suppressClick) return;\n if (event instanceof MouseEvent && event.detail === 0) {\n this.#suppressClick = false;\n return;\n }\n event.preventDefault();\n event.stopImmediatePropagation();\n this.#suppressClick = false;\n };\n\n #setCursor(cursor: 'grabbing' | 'no-drop') {\n this.#cursor ??= {\n value: this.#host.style.getPropertyValue('cursor'),\n priority: this.#host.style.getPropertyPriority('cursor'),\n owned: cursor\n };\n this.#cursor.owned = cursor;\n this.#host.style.setProperty('cursor', cursor, 'important');\n }\n\n #restoreCursor() {\n const previous = this.#cursor;\n if (!previous) return;\n this.#cursor = undefined;\n if (\n this.#host.style.getPropertyValue('cursor') !== previous.owned ||\n this.#host.style.getPropertyPriority('cursor') !== 'important'\n ) {\n return;\n }\n if (previous.value) {\n this.#host.style.setProperty('cursor', previous.value, previous.priority);\n } else {\n this.#host.style.removeProperty('cursor');\n }\n }\n\n #findDragControl(event: Event): HTMLElement | undefined {\n return event\n .composedPath()\n .find(\n (item): item is HTMLElement =>\n item instanceof HTMLElement &&\n item.getRootNode() === this.#host.shadowRoot &&\n (item.hasAttribute('data-panel') || item.hasAttribute('data-drag-group'))\n );\n }\n\n #getCapabilities(): WorkspaceRearrangeCapabilities {\n return { rearrangeable: this.#host.rearrangeable, groupable: this.#host.groupable };\n }\n\n #allowsDrag(control: HTMLElement | undefined, capabilities = this.#getCapabilities()): boolean {\n return (\n !!control &&\n this.#delegate.isRearrangementAllowed() &&\n capabilities.rearrangeable &&\n (capabilities.groupable || control.localName !== 'nve-tabs-item')\n );\n }\n\n #getDragSource(control: HTMLElement): string[] | undefined {\n const layout = this.#delegate.getLayout();\n if (control.dataset.panel) {\n return getWorkspacePanelSource({\n layout,\n anchor: control.dataset.panel,\n available: this.#delegate.getAvailablePanels()\n });\n }\n return control.dataset.dragGroup\n ? [...(findGroup(layout?.root ?? null, control.dataset.dragGroup)?.panels ?? [])]\n : undefined;\n }\n\n #input = (event: CustomEvent<GestureInput>) => {\n if (event.target !== this.#host) return;\n const input = event.detail;\n if (input.kind === 'pointerdown') {\n this.#start(input);\n } else if (input.kind === 'pointerend') {\n this.#end(input);\n }\n };\n\n #start(input: Extract<GestureInput, { kind: 'pointerdown' }>) {\n const control = this.#findDragControl(input.event);\n if (!control) return;\n const capabilities = this.#getCapabilities();\n const source = this.#getDragSource(control);\n if (\n !source ||\n !this.#allowsDrag(control, capabilities) ||\n input.event.button !== 0 ||\n !input.event.isPrimary ||\n this.#session\n ) {\n return;\n }\n if (!input.claim({ kind: 'drag' })) return;\n this.#suppressClick = false;\n const threshold = this.#host.detachThreshold;\n const initialCue = this.#createInitialCue(source, control.hasAttribute('data-drag-group'));\n const layout = this.#delegate.getLayout();\n if (layout) {\n this.#planner = createWorkspacePlacementPlanner();\n }\n this.#session = {\n source,\n phase: 'pressed',\n capabilities,\n initialAllocation: { allocation: 'committed' },\n initialPlacement: layout\n ? createInitialReservation({\n layout,\n source,\n cue: initialCue,\n available: this.#delegate.getAvailablePanels(),\n evaluate: intent => this.#getPlacementOffer(source, intent)\n })\n : undefined,\n detachThreshold: nonnegativeFiniteOr(threshold, 48),\n group: control.hasAttribute('data-drag-group'),\n controlRect: control.getBoundingClientRect(),\n initialCue,\n restoreScroll: captureTabScroll(this.#host)\n };\n }\n\n #createInitialCue(source: string[], groupDrag: boolean): WorkspaceDragCue {\n return this.#delegate.evaluateWithContext(evaluation => {\n const layout = this.#delegate.getLayout() ?? { version: 1, root: null, closed: [] };\n const measurements = this.#delegate.getMeasurements();\n return getInitialDragCue({\n groups: evaluation.geometry(evaluation.project(layout)).groups,\n source,\n groupDrag,\n bounds: evaluation.bounds(),\n client: rect => evaluation.client(rect),\n measurements,\n width: group => getAllocatedTabWidth(group, measurements),\n scroll: group => evaluation.scroll(group)\n });\n });\n }\n\n #getPlacementOffer(\n source: string[],\n intent: WorkspaceDropIntent,\n context?: WorkspaceOfferContext\n ): WorkspaceDragOffer | undefined {\n return this.#delegate.evaluateWithContext(evaluation => {\n const layout = this.#delegate.getLayout();\n if (!layout || intent.kind === 'invalid') return undefined;\n\n return evaluatePlacementOffer({\n evaluation,\n layout,\n measurements: this.#delegate.getMeasurements(),\n source,\n intent,\n context,\n planner: this.#planner,\n groupable: this.#session?.capabilities.groupable ?? this.#host.groupable,\n currentRegions: () => evaluation.presentationGeometry().regions\n });\n });\n }\n\n #end(input: Extract<GestureInput, { kind: 'pointerend' }>) {\n const session = this.#session;\n if (!session) return;\n if (input.interrupted || input.reason !== 'up') {\n this.cancelForUser();\n return;\n }\n if (session.phase === 'detached' && !this.#prepareDrop(session)) {\n if (this.#session === session) {\n this.cancelForUser();\n }\n return;\n }\n this.#completeInteraction(session, input);\n }\n\n #completeInteraction(\n session: WorkspaceRearrangeControllerSession,\n input: Extract<GestureInput, { kind: 'pointerend' }>\n ) {\n const committed = session.phase === 'detached' ? this.#drop(session) : false;\n if (session.phase === 'pressed') {\n this.#activate(session, input);\n }\n this.#suppressClick = true;\n this.cancel();\n if (session.phase !== 'pressed') {\n this.#recoverAfterDrop(session, committed);\n }\n }\n\n #prepareDrop(session: DetachedSession) {\n this.#cancelFrame(session);\n session.initialPaint = false;\n this.#flushPending(session);\n return this.#session === session && !session.preview.blocked;\n }\n\n #returnToOrigin(session: AttachedSession | DetachedSession) {\n const preview: WorkspaceDragPreview = {\n source: session.source,\n ...session.initialAllocation,\n phase: session.phase === 'attached' ? 'returning-attached' : 'returning-detached',\n intent: { kind: 'invalid' },\n cue: this.#createInitialCue(session.source, session.group),\n blocked: false\n };\n this.#planner = undefined;\n this.#delegate.applyPreview(preview);\n return this.#settlePreviewReturn(session);\n }\n\n async #settlePreviewReturn(session: SessionOrigin) {\n await this.#host.updateComplete;\n if (this.#pendingRecovery !== session) return;\n const ghost = this.#host.shadowRoot?.querySelector('[data-destination-ghost]');\n if (!ghost) return;\n ghost.getBoundingClientRect();\n await Promise.allSettled(ghost.getAnimations().map(animation => animation.finished));\n }\n\n async #completeReturnPreview(completion: Promise<void>, session: SessionOrigin) {\n await completion;\n if (this.#pendingRecovery !== session) return;\n\n this.#delegate.applyPreview(undefined);\n void this.#completeRecovery(session);\n }\n\n #recoverAfterDrop(session: SessionOrigin, committed: boolean) {\n this.#pendingRecovery = session;\n if (!committed) {\n session.restoreScroll?.();\n }\n void this.#completeRecovery(session);\n }\n\n async #completeRecovery(session: SessionOrigin) {\n await this.#host.updateComplete;\n if (this.#pendingRecovery !== session) return;\n this.#pendingRecovery = undefined;\n session.restoreFocus?.();\n }\n\n #drop(session: DetachedSession) {\n const intent = session.preview.intent;\n return intent.kind !== 'invalid'\n ? this.#delegate.commitPlacement(\n session.source,\n intent,\n session.preview.allocation === 'reserved' ? session.preview.layout : undefined\n )\n : false;\n }\n\n #activate(\n session: { source: string[]; group: boolean; controlRect: Rect },\n input: Extract<GestureInput, { kind: 'pointerend' }>\n ) {\n const rect = session.controlRect;\n if (\n input.clientX >= rect.x &&\n input.clientX <= rect.x + rect.width &&\n input.clientY >= rect.y &&\n input.clientY <= rect.y + rect.height\n ) {\n this.#delegate.activateSource(session.source, session.group);\n }\n }\n\n #movement = (event: CustomEvent<Gesture<undefined>>) => {\n const input = event.detail;\n const session = this.#session;\n if (!session || input.kind !== 'drag') return;\n const distance = Math.hypot(input.totalDisplacementX, input.totalDisplacementY);\n if (session.phase === 'pressed' && distance < 6) return;\n const point = { x: input.clientX, y: input.clientY };\n if (session.phase === 'detached') {\n this.#queueInput(session, point);\n return;\n }\n const attached: AttachedSession = {\n ...session,\n restoreFocus: session.phase === 'pressed' ? captureWorkspaceFocus(this.#host) : session.restoreFocus,\n phase: 'attached',\n point,\n preview: {\n source: session.source,\n\n phase: 'attached',\n point,\n intent: { kind: 'invalid' },\n cue: session.initialCue,\n blocked: false\n }\n };\n this.#setCursor('grabbing');\n if (distance >= session.detachThreshold) {\n this.#detach(attached);\n } else {\n this.#session = attached;\n this.#delegate.applyPreview(attached.preview);\n }\n };\n\n #detach(attached: AttachedSession) {\n const origin: WorkspaceDragOffer = attached.initialPlacement?.offer ?? {\n ...attached.initialAllocation,\n cue: attached.initialCue,\n feasible: true\n };\n const { feasible, ...initial } = origin;\n const preview: DetachedPreview = {\n ...attached.preview,\n ...initial,\n intent: attached.initialPlacement?.intent ?? attached.preview.intent,\n context: initial.context,\n blocked: !feasible,\n phase: 'detached'\n };\n const session: DetachedSession = {\n ...attached,\n phase: 'detached',\n preview,\n lastFeasible: preview,\n pendingInput: true,\n pendingRefresh: false,\n initialPaint: true\n };\n this.#session = session;\n this.#delegate.applyPreview(preview);\n this.#requestFrame(session);\n }\n\n #queueInput(session: DetachedSession, point: Point) {\n session.point = point;\n session.pendingInput = true;\n this.#requestFrame(session);\n }\n\n #requestFrame(session: DetachedSession) {\n if (session.pendingFrame !== undefined) return;\n const frame = requestAnimationFrame(() => {\n if (this.#session !== session || session.pendingFrame !== frame) return;\n session.pendingFrame = undefined;\n if (session.initialPaint) {\n session.initialPaint = false;\n this.#host.shadowRoot?.querySelector('[data-destination-ghost]')?.getBoundingClientRect();\n }\n this.#flushPending(session);\n });\n session.pendingFrame = frame;\n }\n\n #cancelFrame(session: DetachedSession) {\n if (session.pendingFrame !== undefined) {\n cancelAnimationFrame(session.pendingFrame);\n }\n session.pendingFrame = undefined;\n }\n\n #flushPending(session: DetachedSession) {\n const pointerPending = session.pendingInput;\n const refreshPending = session.pendingRefresh;\n session.pendingInput = false;\n session.pendingRefresh = false;\n if (refreshPending) {\n this.#refreshSelected(session);\n }\n if (this.#session !== session) return;\n if (pointerPending) {\n this.#offerAt(session, session.point);\n } else if (refreshPending) {\n this.#publish(session.preview);\n }\n }\n\n #offerAt(session: DetachedSession, point: Point) {\n this.#delegate.evaluateWithContext(evaluation => this.#evaluateOffer(session, point, evaluation));\n }\n\n #evaluateOffer(session: DetachedSession, point: Point, evaluation: WorkspaceEvaluation) {\n const layout = this.#delegate.getLayout();\n const { intent, acquisition } = decidePointerPlacement({\n placement: evaluation.getPlacementCatalog(session.source, point),\n canonicalRoot: layout?.root ?? null,\n currentLayout: layout ?? { version: 1, root: null, closed: [] },\n source: session.source,\n point,\n heldIntent: session.preview.intent,\n groupable: session.capabilities.groupable,\n gap: this.#delegate.getMeasurements().gap,\n available: evaluation.available,\n projectLayout: evaluation.projectLayout,\n planPlacement: this.#planner\n });\n if (!intent) {\n this.#showLastFeasible(session, point);\n return;\n }\n const offer = this.#getPlacementOffer(session.source, intent, {\n selected: session.preview,\n acquisition: acquisition ? { ...acquisition, point } : undefined\n });\n if (!offer) {\n session.preview = { ...session.preview, point };\n this.#delegate.applyPreview(session.preview);\n return;\n }\n const { feasible, context, ...presentation } = offer;\n session.preview = {\n context: context,\n ...presentation,\n source: session.source,\n\n phase: 'detached',\n point,\n intent,\n cue: offer.cue,\n blocked: !feasible\n };\n if (feasible) {\n session.lastFeasible = session.preview;\n }\n this.#publish(session.preview);\n }\n\n #showLastFeasible(session: DetachedSession, point: Point) {\n this.#setCursor(session.lastFeasible.blocked ? 'no-drop' : 'grabbing');\n session.preview = { ...session.lastFeasible, point };\n this.#delegate.applyPreview(session.preview);\n }\n\n #publish(preview: DetachedPreview) {\n this.#setCursor(preview.blocked ? 'no-drop' : 'grabbing');\n this.#delegate.applyPreview(preview);\n }\n}\n"],"mappings":";;;;;;;;;;;AAmGA,IAAaA,IAAb,MAA0C;CACxC;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,KAAiB;CAEjB;CAEA;CAEA,YAAY,GAA8B,GAAsC;EAY9E,AAXA,KAAKC,KAAQC,GACb,KAAKC,KAAYC,GACjB,KAAKC,KAAW,IAAIC,EAAkBJ,GAAM;GAC1C,eAAe;GACf,oBAAo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D,EAAQ,UAAU,YAAY,UAAU,GACxD,KAAKjB,GAAU,aAAaiB,CAAO;CACrC;AACF"}
@@ -0,0 +1,43 @@
1
+ import type { ReactiveControllerHost } from 'lit';
2
+ import { type GestureInput } from '@nvidia-elements/core/internal';
3
+ import type { WorkspaceBoundary } from '../utils/geometry/allocation.utils.js';
4
+ import type { WorkspaceLayout } from '../utils/model/layout.utils.js';
5
+ import type { WorkspaceMeasurementChange, WorkspaceMeasurements } from '../utils/presentation/measurements.utils.js';
6
+ interface WorkspaceResizeHost extends HTMLElement, ReactiveControllerHost {
7
+ readonly resizePolicy: 'stop' | 'propagate';
8
+ }
9
+ interface ResizePresentation {
10
+ measurements: WorkspaceMeasurements;
11
+ rearrangeable: boolean;
12
+ closable: boolean;
13
+ fullscreenable: boolean;
14
+ }
15
+ interface WorkspaceResizeDelegate {
16
+ readonly isEnabled: () => boolean;
17
+ readonly getLayout: () => WorkspaceLayout | undefined;
18
+ readonly getBoundaries: () => WorkspaceBoundary[];
19
+ readonly getAvailablePanels: () => string[];
20
+ readonly getPresentation: () => ResizePresentation;
21
+ readonly cancelForUser: () => void;
22
+ readonly commitLayout: (layout: WorkspaceLayout) => void;
23
+ }
24
+ export declare class WorkspaceResizeController {
25
+ #private;
26
+ constructor(host: WorkspaceResizeHost, delegate: WorkspaceResizeDelegate);
27
+ get preview(): WorkspaceLayout | undefined;
28
+ get presentation(): ResizePresentation | undefined;
29
+ get retainingHandles(): boolean;
30
+ get resizing(): boolean;
31
+ get policy(): 'stop' | 'propagate';
32
+ hostConnected(): void;
33
+ hostDisconnected(): void;
34
+ hostUpdate(): void;
35
+ hostUpdated(): void;
36
+ handleMeasurementsChange(change: WorkspaceMeasurementChange): void;
37
+ resetForRestore(): void;
38
+ cancel(): void;
39
+ input(event: Event, boundary: WorkspaceBoundary): void;
40
+ change(event: Event, boundary: WorkspaceBoundary): void;
41
+ gesture: (event: CustomEvent<GestureInput>) => void;
42
+ }
43
+ export {};
@@ -0,0 +1,168 @@
1
+ import { matchesElementName as e } from "../../internal/utils/dom.js";
2
+ import { ResizeHandle as t } from "../../resize-handle/resize-handle2.js";
3
+ import { rebaseProjectedSplit as n } from "../utils/model/projection.utils.js";
4
+ import { resizeSizes as r } from "../utils/geometry/partition.utils.js";
5
+ import { isResizeKey as i } from "../utils/interaction/resize-input.utils.js";
6
+ // src/workspace/controllers/workspace-resize.controller.ts
7
+ var a = class {
8
+ #e;
9
+ #t;
10
+ #n;
11
+ #r;
12
+ #i;
13
+ #a;
14
+ constructor(e, t) {
15
+ this.#i = !1, this.gesture = (e) => {
16
+ let t = this.#s(e);
17
+ if (!t) return;
18
+ let n = e.detail;
19
+ if (n.kind === "pointerdown" && n.event.button === 0 && n.event.isPrimary && this.#t.isEnabled()) {
20
+ let e = this.#t.getBoundaries().find((e) => e.key === t.dataset.boundary);
21
+ e && this.#u(t, e, n.event.pointerId);
22
+ }
23
+ n.kind === "pointerend" && this.#o(t, n);
24
+ }, this.#c = (e) => {
25
+ this.#s(e) && (e instanceof KeyboardEvent && !i(e.key) || (this.#t.isEnabled() && !this.#l ? e instanceof KeyboardEvent && this.#n?.status === "cancelled" && (this.#n = void 0) : (e.preventDefault(), e.stopImmediatePropagation())));
26
+ }, this.#m = (e) => {
27
+ e.key !== "Escape" || e.defaultPrevented || this.#n?.status !== "active" || (e.preventDefault(), this.#t.cancelForUser());
28
+ }, this.#e = e, this.#t = t, e.addController(this);
29
+ }
30
+ get preview() {
31
+ return this.#n?.status === "cancelled" ? void 0 : this.#n?.preview?.layout;
32
+ }
33
+ get presentation() {
34
+ let e = this.#n;
35
+ return e?.status === "cancelled" ? void 0 : e?.presentation;
36
+ }
37
+ get retainingHandles() {
38
+ return this.#n?.pointerId !== void 0 && this.#n.status !== "cancelled";
39
+ }
40
+ get resizing() {
41
+ return this.#i;
42
+ }
43
+ get policy() {
44
+ let e = this.#n;
45
+ return e && e.status !== "cancelled" ? e.policy : this.#e.resizePolicy === "propagate" ? "propagate" : "stop";
46
+ }
47
+ hostConnected() {
48
+ this.#r = this.#e.ownerDocument, this.#e.addEventListener("pointerdown", this.#c, !0), this.#e.addEventListener("keydown", this.#c, !0), this.#r.addEventListener("keydown", this.#m);
49
+ }
50
+ hostDisconnected() {
51
+ this.#e.removeEventListener("pointerdown", this.#c, !0), this.#e.removeEventListener("keydown", this.#c, !0), this.#r?.removeEventListener("keydown", this.#m), this.#r = void 0, this.#n = void 0, this.#f();
52
+ }
53
+ hostUpdate() {
54
+ let e = this.#n;
55
+ if (e?.status !== "active" || e.pendingValue === void 0) return;
56
+ let t = e.pendingValue;
57
+ e.pendingValue = void 0, this.#_(t, e);
58
+ }
59
+ hostUpdated() {
60
+ !this.#i || this.preview || this.retainingHandles || this.#a !== void 0 || (this.#a = requestAnimationFrame(() => {
61
+ this.#a = requestAnimationFrame(() => {
62
+ this.#a = void 0, !(this.preview || this.retainingHandles) && (this.#f(), this.#e.requestUpdate());
63
+ });
64
+ }));
65
+ }
66
+ handleMeasurementsChange(e) {
67
+ e.spaceChanged && this.cancel();
68
+ }
69
+ resetForRestore() {
70
+ this.cancel(), this.#f();
71
+ }
72
+ cancel() {
73
+ let e = this.#n;
74
+ e && e.status !== "cancelled" && (this.#n = {
75
+ handle: e.handle,
76
+ pointerId: e.pointerId,
77
+ status: "cancelled"
78
+ }, this.#e.requestUpdate());
79
+ }
80
+ input(e, t) {
81
+ this.#h(e, t, !1);
82
+ }
83
+ change(e, t) {
84
+ this.#h(e, t, !0);
85
+ }
86
+ #o(e, t) {
87
+ let n = this.#n;
88
+ if (n?.handle !== e || n.pointerId !== t.event.pointerId) return;
89
+ t.interrupted && this.cancel();
90
+ let r = this.#n;
91
+ r && (r.status === "cancelled" ? (r.pointerId = void 0, this.#p(e)) : r.status === "committed" ? this.#n = void 0 : r.pointerId = void 0, this.#e.requestUpdate());
92
+ }
93
+ #s(e) {
94
+ return e.composedPath().find((e) => o(e) && e.isConnected && e.getRootNode() === this.#e.shadowRoot);
95
+ }
96
+ #c;
97
+ get #l() {
98
+ let e = this.#n;
99
+ return e?.pointerId !== void 0 && e.handle.isConnected && e.handle.getRootNode() === this.#e.shadowRoot;
100
+ }
101
+ #u(e, t, n) {
102
+ let r = this.#t.getLayout();
103
+ r && (this.#n = {
104
+ handle: e,
105
+ pointerId: n,
106
+ status: "active",
107
+ baseline: structuredClone(r),
108
+ origin: t,
109
+ policy: this.policy,
110
+ available: this.#t.getAvailablePanels(),
111
+ presentation: this.#t.getPresentation()
112
+ });
113
+ }
114
+ #d() {
115
+ this.#a !== void 0 && cancelAnimationFrame(this.#a), this.#a = void 0, this.#i = !0;
116
+ }
117
+ #f() {
118
+ this.#a !== void 0 && cancelAnimationFrame(this.#a), this.#a = void 0, this.#i = !1;
119
+ }
120
+ async #p(e) {
121
+ if (await this.#e.updateComplete, !e.isConnected || e.getRootNode() !== this.#e.shadowRoot) return;
122
+ let t = this.#t.getBoundaries().find((t) => t.key === e.dataset.boundary);
123
+ t && (e.valueAsNumber = t.value);
124
+ }
125
+ #m;
126
+ #h(e, t, n) {
127
+ e.stopPropagation();
128
+ let r = e.currentTarget;
129
+ if (!o(r) || !this.#s(e)) return;
130
+ !this.#n && this.#t.isEnabled() && this.#u(r, t);
131
+ let i = this.#n;
132
+ if (!i || i.handle !== r || i.status !== "active") return;
133
+ let a = r.valueAsNumber;
134
+ if (n) {
135
+ i.pendingValue = void 0;
136
+ let e = this.#_(a, i);
137
+ e && this.#v(e, i);
138
+ } else this.#g(a, i);
139
+ }
140
+ #g(e, t) {
141
+ t.pendingValue === e || t.pendingValue === void 0 && t.preview?.value === e || (t.pendingValue = e, this.#e.requestUpdate());
142
+ }
143
+ #_(e, t) {
144
+ if (t.preview?.value === e) return t.preview.layout;
145
+ let n = this.#y(e, t);
146
+ return n && (this.#d(), t.preview = {
147
+ value: e,
148
+ layout: n
149
+ }), n;
150
+ }
151
+ #v(e, t) {
152
+ t.preview = void 0, t.status = "committed", t.pointerId === void 0 && (this.#n = void 0), this.#t.commitLayout(e);
153
+ }
154
+ #y(e, t) {
155
+ let { origin: i, baseline: a } = t, o = (e - i.value) * (i.branch.axis === "horizontal" ? 1 : -1), s = r(i.sizes, i.minima, {
156
+ boundary: i.index,
157
+ delta: o,
158
+ policy: t.policy
159
+ });
160
+ return s.every((e, t) => e === i.sizes[t]) ? structuredClone(a) : n(a, i.branch, s, t.available);
161
+ }
162
+ };
163
+ function o(n) {
164
+ return n !== null && e(n, t);
165
+ }
166
+ export { a as WorkspaceResizeController };
167
+
168
+ //# sourceMappingURL=workspace-resize.controller.js.map