@iris-ui-kit/vue 0.1.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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/dist/admin.cjs +1869 -0
  3. package/dist/admin.cjs.map +1 -0
  4. package/dist/admin.d.cts +376 -0
  5. package/dist/admin.d.ts +376 -0
  6. package/dist/admin.js +10 -0
  7. package/dist/admin.js.map +1 -0
  8. package/dist/async.cjs +76 -0
  9. package/dist/async.cjs.map +1 -0
  10. package/dist/async.d.cts +59 -0
  11. package/dist/async.d.ts +59 -0
  12. package/dist/async.js +3 -0
  13. package/dist/async.js.map +1 -0
  14. package/dist/behaviors.cjs +659 -0
  15. package/dist/behaviors.cjs.map +1 -0
  16. package/dist/behaviors.d.cts +441 -0
  17. package/dist/behaviors.d.ts +441 -0
  18. package/dist/behaviors.js +3 -0
  19. package/dist/behaviors.js.map +1 -0
  20. package/dist/chunk-3FJUCHCC.js +146 -0
  21. package/dist/chunk-3FJUCHCC.js.map +1 -0
  22. package/dist/chunk-3R3QDLJC.js +172 -0
  23. package/dist/chunk-3R3QDLJC.js.map +1 -0
  24. package/dist/chunk-4FLIW67H.js +137 -0
  25. package/dist/chunk-4FLIW67H.js.map +1 -0
  26. package/dist/chunk-4FQ7XF52.js +3 -0
  27. package/dist/chunk-4FQ7XF52.js.map +1 -0
  28. package/dist/chunk-72PZMU6R.js +99 -0
  29. package/dist/chunk-72PZMU6R.js.map +1 -0
  30. package/dist/chunk-75GSYEJS.js +17 -0
  31. package/dist/chunk-75GSYEJS.js.map +1 -0
  32. package/dist/chunk-7IOJADZC.js +38 -0
  33. package/dist/chunk-7IOJADZC.js.map +1 -0
  34. package/dist/chunk-CIZGSGXN.js +651 -0
  35. package/dist/chunk-CIZGSGXN.js.map +1 -0
  36. package/dist/chunk-F77KIPOH.js +103 -0
  37. package/dist/chunk-F77KIPOH.js.map +1 -0
  38. package/dist/chunk-FJBYAIL4.js +1318 -0
  39. package/dist/chunk-FJBYAIL4.js.map +1 -0
  40. package/dist/chunk-H7HVVPYR.js +66 -0
  41. package/dist/chunk-H7HVVPYR.js.map +1 -0
  42. package/dist/chunk-I6D5VXQK.js +167 -0
  43. package/dist/chunk-I6D5VXQK.js.map +1 -0
  44. package/dist/chunk-PPYNXNGZ.js +73 -0
  45. package/dist/chunk-PPYNXNGZ.js.map +1 -0
  46. package/dist/chunk-QLUIKEMJ.js +1197 -0
  47. package/dist/chunk-QLUIKEMJ.js.map +1 -0
  48. package/dist/chunk-ROJV6RON.js +3 -0
  49. package/dist/chunk-ROJV6RON.js.map +1 -0
  50. package/dist/chunk-S43IHHBU.js +82 -0
  51. package/dist/chunk-S43IHHBU.js.map +1 -0
  52. package/dist/chunk-TCAXRWT6.js +108 -0
  53. package/dist/chunk-TCAXRWT6.js.map +1 -0
  54. package/dist/chunk-TQB5LVOH.js +17 -0
  55. package/dist/chunk-TQB5LVOH.js.map +1 -0
  56. package/dist/chunk-VM2CXEUA.js +46 -0
  57. package/dist/chunk-VM2CXEUA.js.map +1 -0
  58. package/dist/chunk-W2JVHGFR.js +103 -0
  59. package/dist/chunk-W2JVHGFR.js.map +1 -0
  60. package/dist/chunk-WL67XCH5.js +59 -0
  61. package/dist/chunk-WL67XCH5.js.map +1 -0
  62. package/dist/chunk-XCNCIG2I.js +165 -0
  63. package/dist/chunk-XCNCIG2I.js.map +1 -0
  64. package/dist/chunk-XSLBANUV.js +16 -0
  65. package/dist/chunk-XSLBANUV.js.map +1 -0
  66. package/dist/chunk-ZY4NLITM.js +73 -0
  67. package/dist/chunk-ZY4NLITM.js.map +1 -0
  68. package/dist/data.cjs +59 -0
  69. package/dist/data.cjs.map +1 -0
  70. package/dist/data.d.cts +46 -0
  71. package/dist/data.d.ts +46 -0
  72. package/dist/data.js +4 -0
  73. package/dist/data.js.map +1 -0
  74. package/dist/error-boundary.cjs +115 -0
  75. package/dist/error-boundary.cjs.map +1 -0
  76. package/dist/error-boundary.d.cts +60 -0
  77. package/dist/error-boundary.d.ts +60 -0
  78. package/dist/error-boundary.js +4 -0
  79. package/dist/error-boundary.js.map +1 -0
  80. package/dist/floating.cjs +149 -0
  81. package/dist/floating.cjs.map +1 -0
  82. package/dist/floating.d.cts +106 -0
  83. package/dist/floating.d.ts +106 -0
  84. package/dist/floating.js +4 -0
  85. package/dist/floating.js.map +1 -0
  86. package/dist/form.cjs +144 -0
  87. package/dist/form.cjs.map +1 -0
  88. package/dist/form.d.cts +128 -0
  89. package/dist/form.d.ts +128 -0
  90. package/dist/form.js +3 -0
  91. package/dist/form.js.map +1 -0
  92. package/dist/i18n.cjs +112 -0
  93. package/dist/i18n.cjs.map +1 -0
  94. package/dist/i18n.d.cts +99 -0
  95. package/dist/i18n.d.ts +99 -0
  96. package/dist/i18n.js +3 -0
  97. package/dist/i18n.js.map +1 -0
  98. package/dist/index.cjs +18673 -0
  99. package/dist/index.cjs.map +1 -0
  100. package/dist/index.d.cts +8087 -0
  101. package/dist/index.d.ts +8087 -0
  102. package/dist/index.js +13525 -0
  103. package/dist/index.js.map +1 -0
  104. package/dist/layouts.cjs +392 -0
  105. package/dist/layouts.cjs.map +1 -0
  106. package/dist/layouts.d.cts +406 -0
  107. package/dist/layouts.d.ts +406 -0
  108. package/dist/layouts.js +5 -0
  109. package/dist/layouts.js.map +1 -0
  110. package/dist/machine.cjs +19 -0
  111. package/dist/machine.cjs.map +1 -0
  112. package/dist/machine.d.cts +18 -0
  113. package/dist/machine.d.ts +18 -0
  114. package/dist/machine.js +4 -0
  115. package/dist/machine.js.map +1 -0
  116. package/dist/modal-utils.cjs +170 -0
  117. package/dist/modal-utils.cjs.map +1 -0
  118. package/dist/modal-utils.d.cts +43 -0
  119. package/dist/modal-utils.d.ts +43 -0
  120. package/dist/modal-utils.js +3 -0
  121. package/dist/modal-utils.js.map +1 -0
  122. package/dist/motion.cjs +88 -0
  123. package/dist/motion.cjs.map +1 -0
  124. package/dist/motion.d.cts +43 -0
  125. package/dist/motion.d.ts +43 -0
  126. package/dist/motion.js +3 -0
  127. package/dist/motion.js.map +1 -0
  128. package/dist/provider.cjs +272 -0
  129. package/dist/provider.cjs.map +1 -0
  130. package/dist/provider.d.cts +130 -0
  131. package/dist/provider.d.ts +130 -0
  132. package/dist/provider.js +6 -0
  133. package/dist/provider.js.map +1 -0
  134. package/dist/resource.cjs +25 -0
  135. package/dist/resource.cjs.map +1 -0
  136. package/dist/resource.d.cts +17 -0
  137. package/dist/resource.d.ts +17 -0
  138. package/dist/resource.js +3 -0
  139. package/dist/resource.js.map +1 -0
  140. package/dist/skeletons.cjs +1659 -0
  141. package/dist/skeletons.cjs.map +1 -0
  142. package/dist/skeletons.d.cts +179 -0
  143. package/dist/skeletons.d.ts +179 -0
  144. package/dist/skeletons.js +7 -0
  145. package/dist/skeletons.js.map +1 -0
  146. package/dist/skins.cjs +138 -0
  147. package/dist/skins.cjs.map +1 -0
  148. package/dist/skins.d.cts +67 -0
  149. package/dist/skins.d.ts +67 -0
  150. package/dist/skins.js +3 -0
  151. package/dist/skins.js.map +1 -0
  152. package/dist/theme.cjs +106 -0
  153. package/dist/theme.cjs.map +1 -0
  154. package/dist/theme.d.cts +103 -0
  155. package/dist/theme.d.ts +103 -0
  156. package/dist/theme.js +3 -0
  157. package/dist/theme.js.map +1 -0
  158. package/dist/undo.cjs +51 -0
  159. package/dist/undo.cjs.map +1 -0
  160. package/dist/undo.d.cts +48 -0
  161. package/dist/undo.d.ts +48 -0
  162. package/dist/undo.js +3 -0
  163. package/dist/undo.js.map +1 -0
  164. package/package.json +59 -0
@@ -0,0 +1,659 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+ var core = require('@iris-ui-kit/core');
5
+
6
+ // src/behaviors/Resizable.ts
7
+ function useDrag(options) {
8
+ const buttons = options.buttons ?? [0];
9
+ let startX = 0;
10
+ let startY = 0;
11
+ let active = null;
12
+ const onPointerDown = (event) => {
13
+ if (options.disabled?.value) return;
14
+ if (!buttons.includes(event.button)) return;
15
+ const handle = options.handle.value;
16
+ if (!handle) return;
17
+ startX = event.clientX;
18
+ startY = event.clientY;
19
+ const state = {
20
+ x: event.clientX,
21
+ y: event.clientY,
22
+ dx: 0,
23
+ dy: 0,
24
+ event
25
+ };
26
+ const result = options.onStart?.(state);
27
+ if (result === false) return;
28
+ active = event;
29
+ handle.setPointerCapture?.(event.pointerId);
30
+ handle.style.touchAction = "none";
31
+ event.preventDefault();
32
+ };
33
+ const onPointerMove = (event) => {
34
+ if (!active || active.pointerId !== event.pointerId) return;
35
+ options.onDrag?.({
36
+ x: event.clientX,
37
+ y: event.clientY,
38
+ dx: event.clientX - startX,
39
+ dy: event.clientY - startY,
40
+ event
41
+ });
42
+ };
43
+ const onPointerEnd = (event) => {
44
+ if (!active || active.pointerId !== event.pointerId) return;
45
+ const handle = options.handle.value;
46
+ handle?.releasePointerCapture?.(event.pointerId);
47
+ if (handle) handle.style.touchAction = "";
48
+ options.onEnd?.({
49
+ x: event.clientX,
50
+ y: event.clientY,
51
+ dx: event.clientX - startX,
52
+ dy: event.clientY - startY,
53
+ event
54
+ });
55
+ active = null;
56
+ };
57
+ const attach = (el) => {
58
+ el.addEventListener("pointerdown", onPointerDown);
59
+ el.addEventListener("pointermove", onPointerMove);
60
+ el.addEventListener("pointerup", onPointerEnd);
61
+ el.addEventListener("pointercancel", onPointerEnd);
62
+ };
63
+ const detach = (el) => {
64
+ el.removeEventListener("pointerdown", onPointerDown);
65
+ el.removeEventListener("pointermove", onPointerMove);
66
+ el.removeEventListener("pointerup", onPointerEnd);
67
+ el.removeEventListener("pointercancel", onPointerEnd);
68
+ };
69
+ vue.watch(
70
+ options.handle,
71
+ (el, prev) => {
72
+ if (prev) detach(prev);
73
+ if (el) attach(el);
74
+ },
75
+ { immediate: true, flush: "post" }
76
+ );
77
+ vue.onScopeDispose(() => {
78
+ const el = options.handle.value;
79
+ if (el) detach(el);
80
+ });
81
+ }
82
+
83
+ // src/behaviors/Resizable.ts
84
+ var ALL_HANDLES = [
85
+ "top",
86
+ "right",
87
+ "bottom",
88
+ "left",
89
+ "top-left",
90
+ "top-right",
91
+ "bottom-left",
92
+ "bottom-right"
93
+ ];
94
+ var HANDLE_CURSORS = {
95
+ top: "ns-resize",
96
+ right: "ew-resize",
97
+ bottom: "ns-resize",
98
+ left: "ew-resize",
99
+ "top-left": "nwse-resize",
100
+ "top-right": "nesw-resize",
101
+ "bottom-left": "nesw-resize",
102
+ "bottom-right": "nwse-resize"
103
+ };
104
+ function handlePosition(handle) {
105
+ const s = { position: "absolute" };
106
+ const t = handle.includes("top");
107
+ const b = handle.includes("bottom");
108
+ const l = handle.includes("left");
109
+ const r = handle.includes("right");
110
+ if (t) s.top = "-4px";
111
+ if (b) s.bottom = "-4px";
112
+ if (l) s.left = "-4px";
113
+ if (r) s.right = "-4px";
114
+ const isCorner = (t || b) && (l || r);
115
+ if (isCorner) {
116
+ s.width = "12px";
117
+ s.height = "12px";
118
+ } else if (t || b) {
119
+ s.left = "0";
120
+ s.right = "0";
121
+ s.height = "8px";
122
+ } else {
123
+ s.top = "0";
124
+ s.bottom = "0";
125
+ s.width = "8px";
126
+ }
127
+ s.cursor = HANDLE_CURSORS[handle];
128
+ return s;
129
+ }
130
+ var IrisResizable = vue.defineComponent({
131
+ name: "IrisResizable",
132
+ inheritAttrs: false,
133
+ props: {
134
+ size: { type: Object, default: void 0 },
135
+ defaultSize: {
136
+ type: Object,
137
+ default: () => ({ width: 200, height: 200 })
138
+ },
139
+ handles: { type: Array, default: () => ALL_HANDLES },
140
+ minWidth: { type: Number, default: 40 },
141
+ minHeight: { type: Number, default: 40 },
142
+ maxWidth: { type: Number, default: Infinity },
143
+ maxHeight: { type: Number, default: Infinity },
144
+ keepAspect: { type: Boolean, default: false },
145
+ disabled: { type: Boolean, default: false }
146
+ },
147
+ emits: {
148
+ "update:size": (_v) => true,
149
+ resizeStart: (_v) => true,
150
+ resizeEnd: (_v) => true
151
+ },
152
+ setup(props, { slots, attrs, emit }) {
153
+ const isControlled = vue.computed(() => props.size !== void 0);
154
+ const internal = vue.ref({ ...props.defaultSize });
155
+ const size = vue.computed(
156
+ () => isControlled.value ? props.size : internal.value
157
+ );
158
+ const setSize = (next) => {
159
+ if (!isControlled.value) internal.value = next;
160
+ emit("update:size", next);
161
+ };
162
+ const renderHandle = (handle) => {
163
+ const handleRef = vue.ref(null);
164
+ let startSize = { width: 0, height: 0 };
165
+ let aspect = 1;
166
+ useDrag({
167
+ handle: handleRef,
168
+ disabled: vue.computed(() => props.disabled),
169
+ onStart: () => {
170
+ startSize = { ...size.value };
171
+ aspect = startSize.width / Math.max(1, startSize.height);
172
+ emit("resizeStart", startSize);
173
+ },
174
+ onDrag: ({ dx, dy }) => {
175
+ const t = handle.includes("top");
176
+ const b = handle.includes("bottom");
177
+ const l = handle.includes("left");
178
+ const r = handle.includes("right");
179
+ let nextW = startSize.width;
180
+ let nextH = startSize.height;
181
+ if (r) nextW = startSize.width + dx;
182
+ if (l) nextW = startSize.width - dx;
183
+ if (b) nextH = startSize.height + dy;
184
+ if (t) nextH = startSize.height - dy;
185
+ if (props.keepAspect && (t || b) && (l || r)) {
186
+ nextH = nextW / aspect;
187
+ }
188
+ nextW = Math.max(props.minWidth, Math.min(props.maxWidth, nextW));
189
+ nextH = Math.max(props.minHeight, Math.min(props.maxHeight, nextH));
190
+ setSize({ width: nextW, height: nextH });
191
+ },
192
+ onEnd: () => {
193
+ emit("resizeEnd", size.value);
194
+ }
195
+ });
196
+ return vue.h("div", {
197
+ ref: (el) => {
198
+ handleRef.value = el ?? null;
199
+ },
200
+ "data-iris-resizable-handle": handle,
201
+ style: {
202
+ ...handlePosition(handle),
203
+ touchAction: "none",
204
+ background: "transparent",
205
+ zIndex: "1"
206
+ }
207
+ });
208
+ };
209
+ return () => vue.h(
210
+ "div",
211
+ {
212
+ ...attrs,
213
+ "data-iris-resizable": "",
214
+ "data-state": props.disabled ? "disabled" : "idle",
215
+ style: {
216
+ position: "relative",
217
+ display: "inline-block",
218
+ width: `${size.value.width}px`,
219
+ height: `${size.value.height}px`,
220
+ ...attrs.style ?? {}
221
+ }
222
+ },
223
+ [slots.default?.(), ...props.handles.map(renderHandle)]
224
+ );
225
+ }
226
+ });
227
+ var IrisMovable = vue.defineComponent({
228
+ name: "IrisMovable",
229
+ inheritAttrs: false,
230
+ props: {
231
+ position: { type: Object, default: void 0 },
232
+ defaultPosition: {
233
+ type: Object,
234
+ default: () => ({ x: 0, y: 0 })
235
+ },
236
+ bounds: { type: Object, default: () => ({}) },
237
+ byHandle: { type: Boolean, default: false },
238
+ disabled: { type: Boolean, default: false }
239
+ },
240
+ emits: {
241
+ "update:position": (_v) => true,
242
+ dragStart: (_v) => true,
243
+ dragEnd: (_v) => true
244
+ },
245
+ setup(props, { slots, attrs, emit }) {
246
+ const isControlled = vue.computed(() => props.position !== void 0);
247
+ const internal = vue.ref({ ...props.defaultPosition });
248
+ const position = vue.computed(
249
+ () => isControlled.value ? props.position : internal.value
250
+ );
251
+ const rootRef = vue.ref(null);
252
+ const handleRef = vue.ref(null);
253
+ const dragging = vue.ref(false);
254
+ let startPos = { x: 0, y: 0 };
255
+ const refreshHandle = () => {
256
+ if (!props.byHandle) return;
257
+ handleRef.value = rootRef.value?.querySelector("[data-iris-movable-handle]") ?? null;
258
+ };
259
+ vue.onMounted(refreshHandle);
260
+ vue.onUpdated(refreshHandle);
261
+ const dragTarget = vue.computed(() => props.byHandle ? handleRef : rootRef);
262
+ const clamp = (p) => ({
263
+ x: Math.max(props.bounds.minX ?? -Infinity, Math.min(props.bounds.maxX ?? Infinity, p.x)),
264
+ y: Math.max(props.bounds.minY ?? -Infinity, Math.min(props.bounds.maxY ?? Infinity, p.y))
265
+ });
266
+ const setPosition = (next) => {
267
+ if (!isControlled.value) internal.value = next;
268
+ emit("update:position", next);
269
+ };
270
+ useDrag({
271
+ handle: vue.computed(() => dragTarget.value.value),
272
+ disabled: vue.computed(() => props.disabled),
273
+ onStart: () => {
274
+ startPos = position.value;
275
+ dragging.value = true;
276
+ emit("dragStart", position.value);
277
+ },
278
+ onDrag: ({ dx, dy }) => {
279
+ setPosition(clamp({ x: startPos.x + dx, y: startPos.y + dy }));
280
+ },
281
+ onEnd: () => {
282
+ dragging.value = false;
283
+ emit("dragEnd", position.value);
284
+ }
285
+ });
286
+ return () => vue.h(
287
+ "div",
288
+ {
289
+ ...attrs,
290
+ ref: (el) => {
291
+ rootRef.value = el ?? null;
292
+ },
293
+ "data-iris-movable": "",
294
+ "data-state": dragging.value ? "dragging" : "idle",
295
+ style: {
296
+ position: "absolute",
297
+ left: "0",
298
+ top: "0",
299
+ transform: `translate3d(${position.value.x}px, ${position.value.y}px, 0)`,
300
+ cursor: props.byHandle ? "default" : props.disabled ? "not-allowed" : "grab",
301
+ touchAction: "none",
302
+ ...attrs.style ?? {}
303
+ }
304
+ },
305
+ slots.default?.()
306
+ );
307
+ }
308
+ });
309
+ function parseShortcut(spec) {
310
+ const parts = spec.split("+").map((p) => p.trim());
311
+ const key = parts[parts.length - 1].toLowerCase();
312
+ const mods = new Set(parts.slice(0, -1).map((p) => p.toLowerCase()));
313
+ return {
314
+ key,
315
+ shift: mods.has("shift"),
316
+ alt: mods.has("alt") || mods.has("option"),
317
+ ctrl: mods.has("ctrl") || mods.has("control"),
318
+ meta: mods.has("meta") || mods.has("cmd") || mods.has("command"),
319
+ ctrlOrMeta: mods.has("mod")
320
+ };
321
+ }
322
+ function isInputTarget(target) {
323
+ const el = target;
324
+ if (!el) return false;
325
+ const tag = el.tagName;
326
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
327
+ if (el.isContentEditable) return true;
328
+ return false;
329
+ }
330
+ function matches(event, parsed) {
331
+ if (event.key.toLowerCase() !== parsed.key) return false;
332
+ if (parsed.shift !== event.shiftKey) return false;
333
+ if (parsed.alt !== event.altKey) return false;
334
+ if (parsed.ctrlOrMeta) {
335
+ if (!event.ctrlKey && !event.metaKey) return false;
336
+ } else {
337
+ if (parsed.ctrl !== event.ctrlKey) return false;
338
+ if (parsed.meta !== event.metaKey) return false;
339
+ }
340
+ return true;
341
+ }
342
+ var IrisHotkey = vue.defineComponent({
343
+ name: "IrisHotkey",
344
+ inheritAttrs: false,
345
+ props: {
346
+ shortcut: { type: [String, Array], required: true },
347
+ disabled: { type: Boolean, default: false },
348
+ allowInInputs: { type: Boolean, default: false },
349
+ scope: { type: String, default: "document" }
350
+ },
351
+ emits: {
352
+ trigger: (_event) => true
353
+ },
354
+ setup(props, { slots, emit }) {
355
+ let detach = null;
356
+ vue.watchEffect((onCleanup) => {
357
+ detach?.();
358
+ detach = null;
359
+ if (props.disabled) return;
360
+ const specs = Array.isArray(props.shortcut) ? props.shortcut : [props.shortcut];
361
+ const parsed = specs.map(parseShortcut);
362
+ const target = props.scope === "window" ? window : document;
363
+ const onKey = (event) => {
364
+ const e = event;
365
+ if (!props.allowInInputs && isInputTarget(e.target)) return;
366
+ for (const p of parsed) {
367
+ if (matches(e, p)) {
368
+ emit("trigger", e);
369
+ return;
370
+ }
371
+ }
372
+ };
373
+ target.addEventListener("keydown", onKey);
374
+ detach = () => target.removeEventListener("keydown", onKey);
375
+ onCleanup(() => detach?.());
376
+ });
377
+ vue.onBeforeUnmount(() => detach?.());
378
+ return () => slots.default?.();
379
+ }
380
+ });
381
+ var IrisClickOutside = vue.defineComponent({
382
+ name: "IrisClickOutside",
383
+ inheritAttrs: false,
384
+ props: {
385
+ disabled: { type: Boolean, default: false },
386
+ ignore: {
387
+ type: Array,
388
+ default: () => []
389
+ }
390
+ },
391
+ emits: {
392
+ outside: (_event) => true
393
+ },
394
+ setup(props, { slots, emit }) {
395
+ const wrapperRef = vue.ref(null);
396
+ let detach = null;
397
+ vue.watchEffect((onCleanup) => {
398
+ detach?.();
399
+ detach = null;
400
+ if (props.disabled) return;
401
+ if (typeof document === "undefined") return;
402
+ const handler = (event) => {
403
+ const target = event.target;
404
+ if (!target) return;
405
+ const wrapper = wrapperRef.value;
406
+ if (wrapper) {
407
+ let node = target;
408
+ while (node) {
409
+ if (node === wrapper) return;
410
+ if (node.parentNode === wrapper) return;
411
+ node = node.parentNode;
412
+ }
413
+ }
414
+ for (const r of props.ignore) {
415
+ const el = r.value;
416
+ if (el && el.contains(target)) return;
417
+ }
418
+ emit("outside", event);
419
+ };
420
+ document.addEventListener("pointerdown", handler);
421
+ detach = () => document.removeEventListener("pointerdown", handler);
422
+ onCleanup(() => detach?.());
423
+ });
424
+ vue.onBeforeUnmount(() => detach?.());
425
+ return () => vue.h(
426
+ "span",
427
+ {
428
+ ref: (el) => {
429
+ wrapperRef.value = el ?? null;
430
+ },
431
+ "data-iris-click-outside": "",
432
+ style: { display: "contents" }
433
+ },
434
+ slots.default?.()
435
+ );
436
+ }
437
+ });
438
+ var SORTABLE_ITEM_ATTR = "data-iris-sortable-item";
439
+ var IrisSortable = vue.defineComponent({
440
+ name: "IrisSortable",
441
+ inheritAttrs: false,
442
+ props: {
443
+ /** The ordered items. Used to detect which item is at which position. */
444
+ items: {
445
+ type: Array,
446
+ required: true
447
+ },
448
+ /** Called when the user drops an item in a new position. */
449
+ onReorder: {
450
+ type: Function,
451
+ default: void 0
452
+ },
453
+ /** Optional item key getter. Defaults to `String(index)`. */
454
+ getKey: {
455
+ type: Function,
456
+ default: void 0
457
+ },
458
+ disabled: {
459
+ type: Boolean,
460
+ default: false
461
+ },
462
+ class: {
463
+ type: String,
464
+ default: void 0
465
+ },
466
+ style: {
467
+ type: Object,
468
+ default: void 0
469
+ }
470
+ },
471
+ emits: {
472
+ reorder: (_next) => true
473
+ },
474
+ setup(props, { slots, attrs, emit }) {
475
+ const containerRef = vue.ref(null);
476
+ const sortable = core.createSortable();
477
+ const activeKey = vue.ref(null);
478
+ const unsub = sortable.subscribe((state) => {
479
+ activeKey.value = state.activeId;
480
+ });
481
+ vue.onBeforeUnmount(unsub);
482
+ const indexOf = (key) => {
483
+ const container = containerRef.value;
484
+ if (!container) return -1;
485
+ return Array.from(
486
+ container.querySelectorAll(`[${SORTABLE_ITEM_ATTR}]`)
487
+ ).findIndex((el) => el.getAttribute(SORTABLE_ITEM_ATTR) === key);
488
+ };
489
+ const onPointerDown = (e) => {
490
+ if (props.disabled) return;
491
+ const target = e.target.closest(`[${SORTABLE_ITEM_ATTR}]`);
492
+ if (!target) return;
493
+ const container = containerRef.value;
494
+ if (!container) return;
495
+ const key = target.getAttribute(SORTABLE_ITEM_ATTR) ?? "";
496
+ const index = indexOf(key);
497
+ if (index < 0) return;
498
+ sortable.press(key, e.clientX, e.clientY);
499
+ };
500
+ const onPointerMove = (e) => {
501
+ if (!sortable.isPending() && sortable.getState().activeId === null) return;
502
+ const items = containerRef.value?.querySelectorAll(`[${SORTABLE_ITEM_ATTR}]`);
503
+ const rects = Array.from(items ?? []).map((el) => {
504
+ const rect = el.getBoundingClientRect();
505
+ return {
506
+ id: el.getAttribute(SORTABLE_ITEM_ATTR) ?? "",
507
+ left: rect.left,
508
+ top: rect.top,
509
+ width: rect.width,
510
+ height: rect.height
511
+ };
512
+ });
513
+ sortable.tryStart(e.clientX, e.clientY);
514
+ if (sortable.getState().activeId !== null) {
515
+ sortable.moveOver({ x: e.clientX, y: e.clientY }, rects);
516
+ }
517
+ };
518
+ const onPointerUp = () => {
519
+ const state = sortable.getState();
520
+ if (state.activeId === null) {
521
+ sortable.cancel();
522
+ return;
523
+ }
524
+ const result = sortable.end();
525
+ if (result.activeId && result.overId && result.activeId !== result.overId) {
526
+ const from = indexOf(result.activeId);
527
+ const to = indexOf(result.overId);
528
+ if (from >= 0 && to >= 0) {
529
+ const next = [...props.items];
530
+ const [moved] = next.splice(from, 1);
531
+ next.splice(to, 0, moved);
532
+ if (props.onReorder) {
533
+ props.onReorder(next);
534
+ }
535
+ emit("reorder", next);
536
+ }
537
+ }
538
+ };
539
+ const resolveKey = (item, index) => props.getKey ? props.getKey(item, index) : String(index);
540
+ return () => {
541
+ const children = [];
542
+ const defaultSlots = slots.default?.();
543
+ if (defaultSlots) {
544
+ const itemsArray = props.items;
545
+ defaultSlots.forEach((child, index) => {
546
+ const item = itemsArray[index];
547
+ const key = resolveKey(item, index);
548
+ const isDragging = key === activeKey.value;
549
+ children.push(
550
+ vue.h(
551
+ "div",
552
+ {
553
+ key,
554
+ [SORTABLE_ITEM_ATTR]: key,
555
+ "data-iris-sortable-dragging": isDragging ? "" : void 0,
556
+ style: {
557
+ transition: isDragging ? "none" : "transform 150ms ease",
558
+ opacity: isDragging ? 0.4 : 1,
559
+ position: "relative",
560
+ zIndex: isDragging ? 100 : void 0
561
+ }
562
+ },
563
+ [child]
564
+ )
565
+ );
566
+ });
567
+ }
568
+ return vue.h(
569
+ "div",
570
+ {
571
+ ...attrs,
572
+ ref: (el) => {
573
+ containerRef.value = el ?? null;
574
+ },
575
+ "data-iris-sortable": "",
576
+ "data-state": activeKey.value ? "dragging" : "idle",
577
+ class: props.class,
578
+ style: {
579
+ display: "flex",
580
+ flexDirection: "column",
581
+ gap: "var(--iris-gap-sm, 4px)",
582
+ opacity: props.disabled ? 0.6 : 1,
583
+ userSelect: activeKey.value ? "none" : void 0,
584
+ ...props.style ?? {}
585
+ },
586
+ onPointerdown: onPointerDown,
587
+ onPointermove: onPointerMove,
588
+ onPointerup: onPointerUp,
589
+ onPointerleave: onPointerUp
590
+ },
591
+ children
592
+ );
593
+ };
594
+ }
595
+ });
596
+ var IrisLongPress = vue.defineComponent({
597
+ name: "IrisLongPress",
598
+ inheritAttrs: false,
599
+ props: {
600
+ /** Time the pointer must be held before `onLongPress` fires, in ms. */
601
+ holdDelay: {
602
+ type: Number,
603
+ default: 500
604
+ },
605
+ /** Called once when the hold reaches `holdDelay` without an intervening release. */
606
+ onLongPress: {
607
+ type: Function,
608
+ default: void 0
609
+ },
610
+ disabled: {
611
+ type: Boolean,
612
+ default: false
613
+ }
614
+ },
615
+ emits: {
616
+ longpress: () => true
617
+ },
618
+ setup(props, { slots, emit }) {
619
+ const ctrl = core.createLongPress({
620
+ holdDelay: props.holdDelay,
621
+ onLongPress: () => {
622
+ props.onLongPress?.();
623
+ emit("longpress");
624
+ }
625
+ });
626
+ const onPointerDown = () => {
627
+ if (props.disabled) return;
628
+ ctrl.press();
629
+ };
630
+ const onPointerUp = () => {
631
+ ctrl.release();
632
+ };
633
+ const onPointerLeave = () => {
634
+ ctrl.cancel();
635
+ };
636
+ vue.onBeforeUnmount(() => ctrl.cancel());
637
+ return () => vue.h(
638
+ "span",
639
+ {
640
+ "data-iris-long-press": "",
641
+ style: { display: "contents" },
642
+ onPointerdown: onPointerDown,
643
+ onPointerup: onPointerUp,
644
+ onPointerleave: onPointerLeave
645
+ },
646
+ slots.default?.()
647
+ );
648
+ }
649
+ });
650
+
651
+ exports.IrisClickOutside = IrisClickOutside;
652
+ exports.IrisHotkey = IrisHotkey;
653
+ exports.IrisLongPress = IrisLongPress;
654
+ exports.IrisMovable = IrisMovable;
655
+ exports.IrisResizable = IrisResizable;
656
+ exports.IrisSortable = IrisSortable;
657
+ exports.SORTABLE_ITEM_ATTR = SORTABLE_ITEM_ATTR;
658
+ //# sourceMappingURL=behaviors.cjs.map
659
+ //# sourceMappingURL=behaviors.cjs.map