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