@geajs/ui 0.2.4 → 0.2.10
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.
- package/dist/accordion.d.mts +2 -2
- package/dist/accordion.mjs +92 -122
- package/dist/accordion.mjs.map +1 -1
- package/dist/alert.d.mts +3 -3
- package/dist/alert.mjs +45 -107
- package/dist/alert.mjs.map +1 -1
- package/dist/avatar.d.mts +2 -2
- package/dist/avatar.mjs +38 -62
- package/dist/avatar.mjs.map +1 -1
- package/dist/badge.d.mts +1 -1
- package/dist/badge.mjs +18 -43
- package/dist/badge.mjs.map +1 -1
- package/dist/bind.mjs +169 -0
- package/dist/bind.mjs.map +1 -0
- package/dist/button.d.mts +3 -2
- package/dist/button.mjs +30 -85
- package/dist/button.mjs.map +1 -1
- package/dist/card.d.mts +6 -6
- package/dist/card.mjs +82 -194
- package/dist/card.mjs.map +1 -1
- package/dist/checkbox.d.mts +2 -2
- package/dist/checkbox.mjs +30 -31
- package/dist/checkbox.mjs.map +1 -1
- package/dist/clipboard.d.mts +2 -2
- package/dist/clipboard.mjs +49 -55
- package/dist/clipboard.mjs.map +1 -1
- package/dist/collapsible.d.mts +2 -2
- package/dist/collapsible.mjs +18 -45
- package/dist/collapsible.mjs.map +1 -1
- package/dist/combobox.d.mts +2 -2
- package/dist/combobox.mjs +390 -261
- package/dist/combobox.mjs.map +1 -1
- package/dist/compiled-component.mjs +121 -0
- package/dist/compiled-component.mjs.map +1 -0
- package/dist/compiled-reactive-component.mjs +435 -0
- package/dist/compiled-reactive-component.mjs.map +1 -0
- package/dist/component-id.mjs +21 -0
- package/dist/component-id.mjs.map +1 -0
- package/dist/conditional-truthy.mjs +48 -0
- package/dist/conditional-truthy.mjs.map +1 -0
- package/dist/conditional.mjs +54 -0
- package/dist/conditional.mjs.map +1 -0
- package/dist/delegate-event.mjs +53 -0
- package/dist/delegate-event.mjs.map +1 -0
- package/dist/dialog.d.mts +4 -3
- package/dist/dialog.mjs +57 -70
- package/dist/dialog.mjs.map +1 -1
- package/dist/dirty-symbols.mjs +7 -0
- package/dist/dirty-symbols.mjs.map +1 -0
- package/dist/disposer.mjs +65 -0
- package/dist/disposer.mjs.map +1 -0
- package/dist/dnd-manager.d.mts +9 -1
- package/dist/dnd-manager.mjs +67 -29
- package/dist/dnd-manager.mjs.map +1 -1
- package/dist/drag-drop-context.d.mts +1 -1
- package/dist/drag-drop-context.mjs +17 -33
- package/dist/drag-drop-context.mjs.map +1 -1
- package/dist/draggable.d.mts +1 -1
- package/dist/draggable.mjs +2 -91
- package/dist/draggable2.mjs +424 -0
- package/dist/draggable2.mjs.map +1 -0
- package/dist/droppable.d.mts +1 -1
- package/dist/droppable.mjs +20 -44
- package/dist/droppable.mjs.map +1 -1
- package/dist/file-upload.d.mts +2 -2
- package/dist/file-upload.mjs +405 -122
- package/dist/file-upload.mjs.map +1 -1
- package/dist/hover-card.d.mts +2 -2
- package/dist/hover-card.mjs +24 -59
- package/dist/hover-card.mjs.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/input.d.mts +1 -1
- package/dist/input.mjs +1 -93
- package/dist/input2.mjs +56 -0
- package/dist/input2.mjs.map +1 -0
- package/dist/internal-symbols.mjs +9 -0
- package/dist/internal-symbols.mjs.map +1 -0
- package/dist/item-obs.mjs +31 -0
- package/dist/item-obs.mjs.map +1 -0
- package/dist/keyed-list-symbols.mjs +6 -0
- package/dist/keyed-list-symbols.mjs.map +1 -0
- package/dist/keyed-list.mjs +538 -0
- package/dist/keyed-list.mjs.map +1 -0
- package/dist/label.d.mts +1 -1
- package/dist/label.mjs +20 -45
- package/dist/label.mjs.map +1 -1
- package/dist/menu.d.mts +2 -2
- package/dist/menu.mjs +87 -41
- package/dist/menu.mjs.map +1 -1
- package/dist/number-input.d.mts +2 -2
- package/dist/number-input.mjs +28 -32
- package/dist/number-input.mjs.map +1 -1
- package/dist/pagination.d.mts +2 -2
- package/dist/pagination.mjs +12 -35
- package/dist/pagination.mjs.map +1 -1
- package/dist/patch.mjs +21 -0
- package/dist/patch.mjs.map +1 -0
- package/dist/pin-input.d.mts +2 -2
- package/dist/pin-input.mjs +88 -87
- package/dist/pin-input.mjs.map +1 -1
- package/dist/popover.d.mts +2 -2
- package/dist/popover.mjs +45 -67
- package/dist/popover.mjs.map +1 -1
- package/dist/progress.d.mts +2 -2
- package/dist/progress.mjs +37 -43
- package/dist/progress.mjs.map +1 -1
- package/dist/radio-group.d.mts +2 -2
- package/dist/radio-group.mjs +99 -140
- package/dist/radio-group.mjs.map +1 -1
- package/dist/rating-group.d.mts +2 -2
- package/dist/rating-group.mjs +91 -99
- package/dist/rating-group.mjs.map +1 -1
- package/dist/reactive-attr.mjs +13 -0
- package/dist/reactive-attr.mjs.map +1 -0
- package/dist/reactive-bool.mjs +13 -0
- package/dist/reactive-bool.mjs.map +1 -0
- package/dist/reactive-class-name.mjs +15 -0
- package/dist/reactive-class-name.mjs.map +1 -0
- package/dist/reactive-class.mjs +54 -0
- package/dist/reactive-class.mjs.map +1 -0
- package/dist/reactive-style.mjs +24 -0
- package/dist/reactive-style.mjs.map +1 -0
- package/dist/reactive-text.mjs +62 -0
- package/dist/reactive-text.mjs.map +1 -0
- package/dist/select.d.mts +2 -2
- package/dist/select.mjs +106 -186
- package/dist/select.mjs.map +1 -1
- package/dist/separator.d.mts +1 -1
- package/dist/separator.mjs +19 -45
- package/dist/separator.mjs.map +1 -1
- package/dist/skeleton.d.mts +1 -1
- package/dist/skeleton.mjs +11 -35
- package/dist/skeleton.mjs.map +1 -1
- package/dist/slider.d.mts +2 -2
- package/dist/slider.mjs +31 -32
- package/dist/slider.mjs.map +1 -1
- package/dist/switch.d.mts +2 -2
- package/dist/switch.mjs +30 -31
- package/dist/switch.mjs.map +1 -1
- package/dist/tabs.d.mts +7 -2
- package/dist/tabs.mjs +180 -147
- package/dist/tabs.mjs.map +1 -1
- package/dist/tags-input.d.mts +2 -2
- package/dist/tags-input.mjs +102 -188
- package/dist/tags-input.mjs.map +1 -1
- package/dist/textarea.d.mts +1 -1
- package/dist/textarea.mjs +32 -75
- package/dist/textarea.mjs.map +1 -1
- package/dist/theme.css +4 -5
- package/dist/toast.d.mts +1 -1
- package/dist/toast.mjs +14 -34
- package/dist/toast.mjs.map +1 -1
- package/dist/toggle-group.d.mts +2 -2
- package/dist/toggle-group.mjs +78 -85
- package/dist/toggle-group.mjs.map +1 -1
- package/dist/tooltip.d.mts +2 -2
- package/dist/tooltip.mjs +23 -43
- package/dist/tooltip.mjs.map +1 -1
- package/dist/tree-view.d.mts +2 -2
- package/dist/tree-view.mjs +32 -50
- package/dist/tree-view.mjs.map +1 -1
- package/dist/types.d.mts +9 -0
- package/dist/zag-component.d.mts +26 -3
- package/dist/zag-component.mjs +73 -17
- package/dist/zag-component.mjs.map +1 -1
- package/package.json +4 -3
- package/dist/cn.mjs +0 -10
- package/dist/cn.mjs.map +0 -1
- package/dist/draggable.mjs.map +0 -1
- package/dist/input.mjs.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region ../gea/src/runtime/delegate-event.ts
|
|
2
|
+
const _NON_BUBBLING = new Set([
|
|
3
|
+
"blur",
|
|
4
|
+
"focus",
|
|
5
|
+
"mouseenter",
|
|
6
|
+
"mouseleave",
|
|
7
|
+
"scroll"
|
|
8
|
+
]);
|
|
9
|
+
function dispatchWithCurrentTarget(handler, event, currentTarget) {
|
|
10
|
+
const previous = Object.getOwnPropertyDescriptor(event, "currentTarget");
|
|
11
|
+
Object.defineProperty(event, "currentTarget", {
|
|
12
|
+
configurable: true,
|
|
13
|
+
value: currentTarget
|
|
14
|
+
});
|
|
15
|
+
try {
|
|
16
|
+
handler(event);
|
|
17
|
+
} finally {
|
|
18
|
+
if (previous) Object.defineProperty(event, "currentTarget", previous);
|
|
19
|
+
else delete event.currentTarget;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function delegateEvent(root, type, pairs, _disposer) {
|
|
23
|
+
const rt = typeof document !== "undefined" ? document : root.ownerDocument;
|
|
24
|
+
const k = "__on_" + type;
|
|
25
|
+
const currentTargetKey = "__onct_" + type;
|
|
26
|
+
const flag = "__d_" + type;
|
|
27
|
+
if (!rt[flag]) {
|
|
28
|
+
rt[flag] = 1;
|
|
29
|
+
rt.addEventListener(type, (e) => {
|
|
30
|
+
for (let n = e.target; n && n !== rt; n = n.parentNode) {
|
|
31
|
+
const h = n[k];
|
|
32
|
+
if (h !== void 0) {
|
|
33
|
+
h(e);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const hct = n[currentTargetKey];
|
|
37
|
+
if (hct !== void 0) {
|
|
38
|
+
dispatchWithCurrentTarget(hct, e, n);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, _NON_BUBBLING.has(type));
|
|
43
|
+
}
|
|
44
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
45
|
+
const el = pairs[i][0];
|
|
46
|
+
if (el) if (pairs[i].length > 2) el[k] = pairs[i][1];
|
|
47
|
+
else el[currentTargetKey] = pairs[i][1];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { delegateEvent as t };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=delegate-event.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegate-event.mjs","names":[],"sources":["../../gea/src/runtime/delegate-event.ts"],"sourcesContent":["/**\n * Per-document event delegation via element expando properties.\n *\n * Fast JSX-declared handlers are stored as own properties on their host\n * element (`el.__on_click = handler`). Handlers that need element-local\n * `currentTarget` semantics use the slower `__onct_click` slot.\n * A single document-level listener per eventType walks from `e.target` up,\n * checks the expando on each node, and dispatches.\n *\n * Why this beats a Map<Element, Handler> dispatcher:\n * - Expando lookup is an inline-cached own-property read.\n * - No per-list Map allocation; DOM nodes are the storage.\n * - Detached elements take their handler expando with them, so bulk row\n * teardown avoids removeEventListener / Map.delete work.\n *\n * Although the real DOM listener is installed on the document, Gea exposes\n * element-local handler semantics: while a matched handler runs,\n * `e.currentTarget` is the element that owned that handler.\n */\n\nimport type { Disposer } from './disposer'\n\n// A Set keeps the membership test native under geatsc; a Record<string, true>\n// computed access has no native plan and trips the boxed-equality guard.\n// Mirrors `delegate-event-fast.ts`, which took the same treatment.\nconst _NON_BUBBLING = new Set<string>(['blur', 'focus', 'mouseenter', 'mouseleave', 'scroll'])\n\ntype Handler = (e: Event) => void\ntype HandlerPair = [Element, Handler] | [Element, Handler, false]\n\nfunction dispatchWithCurrentTarget(handler: Handler, event: Event, currentTarget: Element): void {\n const previous = Object.getOwnPropertyDescriptor(event, 'currentTarget')\n Object.defineProperty(event, 'currentTarget', { configurable: true, value: currentTarget })\n try {\n handler(event)\n } finally {\n if (previous) Object.defineProperty(event, 'currentTarget', previous)\n else delete (event as any).currentTarget\n }\n}\n\nexport function delegateEvent(root: Element, type: string, pairs: HandlerPair[], _disposer: Disposer): void {\n // Prefer the live global `document` — template clones' ownerDocument may\n // differ from the adopted document (jsdom installs fresh docs per test).\n const rt: any = typeof document !== 'undefined' ? document : root.ownerDocument\n const k = '__on_' + type\n const currentTargetKey = '__onct_' + type\n const flag = '__d_' + type\n if (!rt[flag]) {\n rt[flag] = 1\n rt.addEventListener(\n type,\n (e: Event) => {\n for (let n: Node | null = e.target as Node | null; n && n !== rt; n = n.parentNode) {\n const h = (n as any)[k] as Handler | undefined\n if (h !== undefined) {\n h(e)\n return\n }\n const hct = (n as any)[currentTargetKey] as Handler | undefined\n if (hct !== undefined) {\n dispatchWithCurrentTarget(hct, e, n as Element)\n return\n }\n }\n },\n _NON_BUBBLING.has(type),\n )\n }\n for (let i = 0; i < pairs.length; i++) {\n const el = pairs[i][0]\n if (el) {\n // A 3-element pair (`[el, handler, false]`) is the compiler's\n // fast, no-shadow marker; a plain 2-element pair defaults to the\n // slower `currentTarget`-shadowing slot. Test the pair length (a\n // native numeric compare) rather than `pairs[i][2] === false`, whose\n // boxed `false | undefined` equality has no native plan under geatsc.\n if (pairs[i].length > 2) {\n ;(el as any)[k] = pairs[i][1]\n } else {\n ;(el as any)[currentTargetKey] = pairs[i][1]\n }\n }\n }\n // No disposer cleanup: when the element is removed from the DOM and GC'd,\n // the expando dies with it. Skipping a symmetric removeDelegate avoids\n // N `delete el[k]` per row on large replace/clear workloads. A dead expando\n // on a detached element is harmless: events no longer bubble through it, so\n // the document listener never walks into it.\n}\n"],"mappings":";AAyBA,MAAM,gBAAgB,IAAI,IAAY;CAAC;CAAQ;CAAS;CAAc;CAAc;CAAS,CAAC;AAK9F,SAAS,0BAA0B,SAAkB,OAAc,eAA8B;CAC/F,MAAM,WAAW,OAAO,yBAAyB,OAAO,gBAAgB;AACxE,QAAO,eAAe,OAAO,iBAAiB;EAAE,cAAc;EAAM,OAAO;EAAe,CAAC;AAC3F,KAAI;AACF,UAAQ,MAAM;WACN;AACR,MAAI,SAAU,QAAO,eAAe,OAAO,iBAAiB,SAAS;MAChE,QAAQ,MAAc;;;AAI/B,SAAgB,cAAc,MAAe,MAAc,OAAsB,WAA2B;CAG1G,MAAM,KAAU,OAAO,aAAa,cAAc,WAAW,KAAK;CAClE,MAAM,IAAI,UAAU;CACpB,MAAM,mBAAmB,YAAY;CACrC,MAAM,OAAO,SAAS;AACtB,KAAI,CAAC,GAAG,OAAO;AACb,KAAG,QAAQ;AACX,KAAG,iBACD,OACC,MAAa;AACZ,QAAK,IAAI,IAAiB,EAAE,QAAuB,KAAK,MAAM,IAAI,IAAI,EAAE,YAAY;IAClF,MAAM,IAAK,EAAU;AACrB,QAAI,MAAM,KAAA,GAAW;AACnB,OAAE,EAAE;AACJ;;IAEF,MAAM,MAAO,EAAU;AACvB,QAAI,QAAQ,KAAA,GAAW;AACrB,+BAA0B,KAAK,GAAG,EAAa;AAC/C;;;KAIN,cAAc,IAAI,KAAK,CACxB;;AAEH,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,KAAK,MAAM,GAAG;AACpB,MAAI,GAMF,KAAI,MAAM,GAAG,SAAS,EAClB,IAAW,KAAK,MAAM,GAAG;MAEzB,IAAW,oBAAoB,MAAM,GAAG"}
|
package/dist/dialog.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as ZagComponent } from "./zag-component.mjs";
|
|
2
|
+
import { t as JSXNode } from "./types.mjs";
|
|
2
3
|
import * as dialog from "@zag-js/dialog";
|
|
3
4
|
import { OpenChangeDetails } from "@zag-js/dialog";
|
|
4
5
|
import * as _$_zag_js_types0 from "@zag-js/types";
|
|
@@ -6,7 +7,7 @@ import * as _$_zag_js_types0 from "@zag-js/types";
|
|
|
6
7
|
//#region src/components/dialog.d.ts
|
|
7
8
|
interface DialogProps {
|
|
8
9
|
class?: string;
|
|
9
|
-
children?:
|
|
10
|
+
children?: JSXNode;
|
|
10
11
|
triggerLabel?: string;
|
|
11
12
|
title?: string;
|
|
12
13
|
description?: string;
|
|
@@ -25,7 +26,7 @@ declare class Dialog extends ZagComponent<DialogProps> {
|
|
|
25
26
|
open: boolean;
|
|
26
27
|
createMachine(_props: DialogProps): any;
|
|
27
28
|
getMachineProps(props: DialogProps): {
|
|
28
|
-
id:
|
|
29
|
+
id: string;
|
|
29
30
|
open: boolean;
|
|
30
31
|
defaultOpen: boolean;
|
|
31
32
|
modal: boolean;
|
|
@@ -50,7 +51,7 @@ declare class Dialog extends ZagComponent<DialogProps> {
|
|
|
50
51
|
'[data-part="trigger"]': (api: any) => any;
|
|
51
52
|
};
|
|
52
53
|
syncState(api: any): void;
|
|
53
|
-
template(props: DialogProps):
|
|
54
|
+
template(props: DialogProps): any;
|
|
54
55
|
}
|
|
55
56
|
//#endregion
|
|
56
57
|
export { DialogProps, Dialog as default };
|
package/dist/dialog.mjs
CHANGED
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
import { t as ZagComponent } from "./zag-component.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { o as GEA_CREATE_TEMPLATE } from "./bind.mjs";
|
|
3
|
+
import { n as reactiveTextValue, t as reactiveText } from "./reactive-text.mjs";
|
|
4
|
+
import { t as reactiveClass } from "./reactive-class.mjs";
|
|
5
|
+
import { t as conditionalTruthy } from "./conditional-truthy.mjs";
|
|
3
6
|
import { normalizeProps } from "@zag-js/vanilla";
|
|
4
7
|
import * as dialog from "@zag-js/dialog";
|
|
5
8
|
//#region src/components/dialog.tsx
|
|
9
|
+
let _tpl0_root = null;
|
|
10
|
+
function _tpl0_create() {
|
|
11
|
+
const t = document.createElement("template");
|
|
12
|
+
t.innerHTML = "<div><!--1--><div data-part=backdrop class=\"dialog-backdrop fixed inset-0 bg-black/50 z-50\" hidden></div><div data-part=positioner class=\"dialog-positioner fixed inset-0 flex items-center justify-center z-50\" hidden><div data-part=content class=\"dialog-content text-foreground rounded-lg shadow-xl p-6 w-full max-w-md mx-4\"><!--2--><!--3--><div class=dialog-body>0</div><button data-part=close-trigger class=\"dialog-close-trigger absolute top-3 right-3 text-muted-foreground hover:text-foreground\">✕";
|
|
13
|
+
return t.content.firstChild;
|
|
14
|
+
}
|
|
15
|
+
let _tpl1_root = null;
|
|
16
|
+
function _tpl1_create() {
|
|
17
|
+
const t = document.createElement("template");
|
|
18
|
+
t.innerHTML = "<button data-part=trigger class=dialog-trigger>0";
|
|
19
|
+
return t.content.firstChild;
|
|
20
|
+
}
|
|
21
|
+
let _tpl2_root = null;
|
|
22
|
+
function _tpl2_create() {
|
|
23
|
+
const t = document.createElement("template");
|
|
24
|
+
t.innerHTML = "<h2 data-part=title class=\"dialog-title text-lg font-semibold mb-2\">0";
|
|
25
|
+
return t.content.firstChild;
|
|
26
|
+
}
|
|
27
|
+
let _tpl3_root = null;
|
|
28
|
+
function _tpl3_create() {
|
|
29
|
+
const t = document.createElement("template");
|
|
30
|
+
t.innerHTML = "<p data-part=description class=\"dialog-description text-sm text-muted-foreground mb-4\">0";
|
|
31
|
+
return t.content.firstChild;
|
|
32
|
+
}
|
|
6
33
|
var Dialog = class extends ZagComponent {
|
|
7
|
-
static {
|
|
8
|
-
this.__geaTagName = "gea-dialog";
|
|
9
|
-
}
|
|
10
|
-
constructor(...args) {
|
|
11
|
-
super(...args);
|
|
12
|
-
this.props;
|
|
13
|
-
this[geaCondValueSymbol(0)] = !!this.props.title;
|
|
14
|
-
this[geaCondValueSymbol(1)] = !!this.props.description;
|
|
15
|
-
this[geaCondValueSymbol(2)] = !!this.props.triggerLabel;
|
|
16
|
-
this[GEA_REGISTER_COND](0, "c0", () => {
|
|
17
|
-
this.props;
|
|
18
|
-
return this.props.title;
|
|
19
|
-
}, () => {
|
|
20
|
-
this.props;
|
|
21
|
-
return `<h2 data-part="title" class="dialog-title text-lg font-semibold mb-2">${geaEscapeHtml(String(this.props.title))}</h2>`;
|
|
22
|
-
}, null);
|
|
23
|
-
this[GEA_REGISTER_COND](1, "c1", () => {
|
|
24
|
-
this.props;
|
|
25
|
-
return this.props.description;
|
|
26
|
-
}, () => {
|
|
27
|
-
this.props;
|
|
28
|
-
return `<p data-part="description" class="dialog-description text-sm text-muted-foreground mb-4">${geaEscapeHtml(String(this.props.description))}</p>`;
|
|
29
|
-
}, null);
|
|
30
|
-
this[GEA_REGISTER_COND](2, "c2", () => {
|
|
31
|
-
this.props;
|
|
32
|
-
return this.props.triggerLabel;
|
|
33
|
-
}, () => {
|
|
34
|
-
this.props;
|
|
35
|
-
return `<button data-part="trigger" class="dialog-trigger">${geaEscapeHtml(String(this.props.triggerLabel))}</button>`;
|
|
36
|
-
}, null);
|
|
37
|
-
}
|
|
38
34
|
createMachine(_props) {
|
|
39
35
|
return dialog.machine;
|
|
40
36
|
}
|
|
@@ -91,7 +87,7 @@ var Dialog = class extends ZagComponent {
|
|
|
91
87
|
onpointerdown: preventTriggerFocus,
|
|
92
88
|
onmousedown: preventTriggerFocus,
|
|
93
89
|
onclick: (e) => {
|
|
94
|
-
e.
|
|
90
|
+
(e.target?.closest("button, [role=\"button\"]"))?.blur();
|
|
95
91
|
origOnClick?.(e);
|
|
96
92
|
}
|
|
97
93
|
};
|
|
@@ -101,43 +97,34 @@ var Dialog = class extends ZagComponent {
|
|
|
101
97
|
syncState(api) {
|
|
102
98
|
this.open = api.open;
|
|
103
99
|
}
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (key === "title") this[GEA_PATCH_COND](0);
|
|
136
|
-
if (key === "description") this[GEA_PATCH_COND](1);
|
|
137
|
-
if (key === "triggerLabel") this[GEA_PATCH_COND](2);
|
|
138
|
-
}
|
|
139
|
-
__resetEls() {
|
|
140
|
-
this.__e0 = null;
|
|
100
|
+
[GEA_CREATE_TEMPLATE](d) {
|
|
101
|
+
const root = (_tpl0_root || (_tpl0_root = _tpl0_create())).cloneNode(true);
|
|
102
|
+
const el0 = root;
|
|
103
|
+
const anchor1 = root.firstChild;
|
|
104
|
+
const anchor2 = root.childNodes[2].firstChild.firstChild;
|
|
105
|
+
const anchor3 = root.childNodes[2].firstChild.childNodes[1];
|
|
106
|
+
const marker4 = root.childNodes[2].firstChild.childNodes[2].firstChild;
|
|
107
|
+
reactiveClass(el0, d, this, () => this.props.class || "");
|
|
108
|
+
conditionalTruthy(anchor1.parentNode, anchor1, d, this, () => this.props.triggerLabel, (d) => {
|
|
109
|
+
const root = (_tpl1_root || (_tpl1_root = _tpl1_create())).cloneNode(true);
|
|
110
|
+
const t0 = root.firstChild;
|
|
111
|
+
reactiveTextValue(t0, d, this, () => this.props.triggerLabel);
|
|
112
|
+
return root;
|
|
113
|
+
});
|
|
114
|
+
conditionalTruthy(anchor2.parentNode, anchor2, d, this, () => this.props.title, (d) => {
|
|
115
|
+
const root = (_tpl2_root || (_tpl2_root = _tpl2_create())).cloneNode(true);
|
|
116
|
+
const t0 = root.firstChild;
|
|
117
|
+
reactiveTextValue(t0, d, this, () => this.props.title);
|
|
118
|
+
return root;
|
|
119
|
+
});
|
|
120
|
+
conditionalTruthy(anchor3.parentNode, anchor3, d, this, () => this.props.description, (d) => {
|
|
121
|
+
const root = (_tpl3_root || (_tpl3_root = _tpl3_create())).cloneNode(true);
|
|
122
|
+
const t0 = root.firstChild;
|
|
123
|
+
reactiveTextValue(t0, d, this, () => this.props.description);
|
|
124
|
+
return root;
|
|
125
|
+
});
|
|
126
|
+
reactiveText(marker4, d, this, () => this.props.children);
|
|
127
|
+
return root;
|
|
141
128
|
}
|
|
142
129
|
};
|
|
143
130
|
//#endregion
|
package/dist/dialog.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.mjs","names":["
|
|
1
|
+
{"version":3,"file":"dialog.mjs","names":["GEA_CREATE_TEMPLATE","reactiveClass","reactiveTextValue","conditionalTruthy","reactiveText","dialog","OpenChangeDetails","normalizeProps","JSXNode","ZagComponent","DialogProps","class","children","triggerLabel","title","description","open","defaultOpen","modal","closeOnInteractOutside","closeOnEscape","trapFocus","preventScroll","role","onOpenChange","details","_tpl0_root","_tpl0_create","t","document","createElement","innerHTML","content","firstChild","_tpl1_root","_tpl1_create","_tpl2_root","_tpl2_create","_tpl3_root","_tpl3_create","Dialog","createMachine","_props","machine","getMachineProps","props","id","connectApi","service","connect","getSpreadMap","[data-part=\"positioner\"]","api","getPositionerProps","hidden","[data-part=\"close-trigger\"]","_","getCloseTriggerProps","onclick","e","MouseEvent","defaultPrevented","setOpen","[data-part=\"trigger\"]","getTriggerProps","origOnClick","preventTriggerFocus","PointerEvent","button","preventDefault","onpointerdown","onmousedown","btn","target","HTMLElement","closest","blur","syncState","d","root","cloneNode","el0","anchor1","anchor2","childNodes","anchor3","marker4","parentNode","marker0","t0","t4"],"sources":["../src/components/dialog.tsx"],"sourcesContent":["import * as dialog from '@zag-js/dialog'\nimport type { OpenChangeDetails } from '@zag-js/dialog'\nimport { normalizeProps } from '@zag-js/vanilla'\nimport type { JSXNode } from '../types'\nimport ZagComponent from '../primitives/zag-component'\n\nexport interface DialogProps {\n class?: string\n children?: JSXNode\n triggerLabel?: string\n title?: string\n description?: string\n open?: boolean\n defaultOpen?: boolean\n modal?: boolean\n closeOnInteractOutside?: boolean\n closeOnEscape?: boolean\n trapFocus?: boolean\n preventScroll?: boolean\n role?: string\n 'aria-label'?: string\n onOpenChange?: (details: OpenChangeDetails) => void\n}\n\nexport default class Dialog extends ZagComponent<DialogProps> {\n declare open: boolean\n\n createMachine(_props: DialogProps): any {\n return dialog.machine\n }\n\n getMachineProps(props: DialogProps) {\n return {\n id: this.id,\n open: props.open,\n defaultOpen: props.defaultOpen,\n modal: props.modal ?? true,\n closeOnInteractOutside: props.closeOnInteractOutside ?? true,\n closeOnEscape: props.closeOnEscape ?? true,\n trapFocus: props.trapFocus ?? true,\n preventScroll: props.preventScroll ?? true,\n role: props.role ?? 'dialog',\n 'aria-label': props['aria-label'],\n onOpenChange: (details: OpenChangeDetails) => {\n this.open = details.open\n props.onOpenChange?.(details)\n },\n }\n }\n\n connectApi(service: any) {\n return dialog.connect(service, normalizeProps)\n }\n\n getSpreadMap() {\n return {\n '[data-part=\"backdrop\"]': 'getBackdropProps',\n '[data-part=\"positioner\"]': (api: any) => ({\n ...api.getPositionerProps(),\n hidden: !api.open,\n }),\n '[data-part=\"content\"]': 'getContentProps',\n '[data-part=\"title\"]': 'getTitleProps',\n '[data-part=\"description\"]': 'getDescriptionProps',\n '[data-part=\"close-trigger\"]': (api: any) => {\n const { id: _, ...props } = api.getCloseTriggerProps()\n return {\n ...props,\n // normalizeProps lowercases onClick → onclick; must match to override\n // Zag's default handler which calls stopPropagation()\n onclick: (e: MouseEvent) => {\n if (e.defaultPrevented) return\n api.setOpen(false)\n },\n }\n },\n '[data-part=\"trigger\"]': (api: any) => {\n const props = api.getTriggerProps()\n const origOnClick = props.onclick\n const preventTriggerFocus = (e: MouseEvent | PointerEvent) => {\n if ('button' in e && e.button !== 0) return\n e.preventDefault()\n }\n return {\n ...props,\n onpointerdown: preventTriggerFocus,\n onmousedown: preventTriggerFocus,\n onclick: (e: MouseEvent) => {\n const btn = (e.target as HTMLElement)?.closest('button, [role=\"button\"]') as HTMLElement | null\n btn?.blur()\n origOnClick?.(e)\n },\n }\n },\n }\n }\n\n syncState(api: any) {\n this.open = api.open\n }\n\n template(props: DialogProps) {\n return (\n <div class={props.class || ''}>\n {props.triggerLabel && (\n <button data-part=\"trigger\" class=\"dialog-trigger\">\n {props.triggerLabel}\n </button>\n )}\n <div data-part=\"backdrop\" class=\"dialog-backdrop fixed inset-0 bg-black/50 z-50\" hidden></div>\n <div\n data-part=\"positioner\"\n class=\"dialog-positioner fixed inset-0 flex items-center justify-center z-50\"\n hidden\n >\n <div data-part=\"content\" class=\"dialog-content text-foreground rounded-lg shadow-xl p-6 w-full max-w-md mx-4\">\n {props.title && (\n <h2 data-part=\"title\" class=\"dialog-title text-lg font-semibold mb-2\">\n {props.title}\n </h2>\n )}\n {props.description && (\n <p data-part=\"description\" class=\"dialog-description text-sm text-muted-foreground mb-4\">\n {props.description}\n </p>\n )}\n <div class=\"dialog-body\">{props.children}</div>\n <button\n data-part=\"close-trigger\"\n class=\"dialog-close-trigger absolute top-3 right-3 text-muted-foreground hover:text-foreground\"\n >\n ✕\n </button>\n </div>\n </div>\n </div>\n )\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dirty-symbols.mjs","names":[],"sources":["../../gea/src/runtime/dirty-symbols.ts"],"sourcesContent":["// Dirty markers shared by the store and compiler-emitted keyed-list kernels.\n// These stay on Symbol.for because store modules and compiled component modules\n// can be evaluated through different Vite module instances during tests/dev.\nconst _DIRTY: unique symbol = Symbol.for('gea.d.dirty') as any\nconst _DIRTY_PROPS: unique symbol = Symbol.for('gea.d.dirtyProps') as any\n\nexport { _DIRTY as GEA_DIRTY, _DIRTY_PROPS as GEA_DIRTY_PROPS }\n"],"mappings":";AAGA,MAAM,SAAwB,OAAO,IAAI,cAAc;AACvD,MAAM,eAA8B,OAAO,IAAI,mBAAmB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region ../gea/src/runtime/disposer.ts
|
|
2
|
+
/**
|
|
3
|
+
* Disposer — LIFO teardown registry.
|
|
4
|
+
*
|
|
5
|
+
* Class-based so the `add` / `dispose` / `child` methods live on the prototype
|
|
6
|
+
* once, instead of being closures created per instance. Each `createDisposer()`
|
|
7
|
+
* call was allocating 3 closures; on a 1000-row keyed list with per-row
|
|
8
|
+
* children that's ~3000 closure allocations that GC had to chase. The class
|
|
9
|
+
* form drops that to one shared prototype plus the per-instance `f[]` array
|
|
10
|
+
* and (for children) a single dispose-bridge closure.
|
|
11
|
+
*
|
|
12
|
+
* `Disposer` is the CLASS, not an interface over it. The interface had exactly
|
|
13
|
+
* two implementors — this class and the `NOOP_DISPOSER` object literal — which
|
|
14
|
+
* made every `Disposer`-typed slot polymorphic between a class instance and a
|
|
15
|
+
* record, and geatsc has no native carrier for that: the type derives lattice
|
|
16
|
+
* bottom, so `CompiledComponent`'s `[GEA_DISPOSER] = createDisposer() as
|
|
17
|
+
* Disposer` field raised `representation-plan coverage gap for
|
|
18
|
+
* PropertyDeclaration`, and `conditional()`'s `currentChild: Disposer | null`
|
|
19
|
+
* capture blocked its whole nested-function cluster. One class with a `noop`
|
|
20
|
+
* flag has a single concrete carrier and behaves identically: a no-op disposer
|
|
21
|
+
* registers nothing, disposes an empty stack, and hands back itself as its own
|
|
22
|
+
* child.
|
|
23
|
+
*/
|
|
24
|
+
var Disposer = class Disposer {
|
|
25
|
+
constructor(noop = false) {
|
|
26
|
+
this.f = [];
|
|
27
|
+
this.noop = noop;
|
|
28
|
+
}
|
|
29
|
+
add(fn) {
|
|
30
|
+
if (this.noop) return;
|
|
31
|
+
this.f.push(fn);
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
const f = this.f;
|
|
35
|
+
try {
|
|
36
|
+
for (let i = f.length - 1; i >= 0; i--) f[i]();
|
|
37
|
+
} catch {}
|
|
38
|
+
f.length = 0;
|
|
39
|
+
}
|
|
40
|
+
child() {
|
|
41
|
+
if (this.noop) return this;
|
|
42
|
+
const c = new Disposer();
|
|
43
|
+
this.f.push(_dispatchChild(c));
|
|
44
|
+
return c;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function _dispatchChild(c) {
|
|
48
|
+
return () => c.dispose();
|
|
49
|
+
}
|
|
50
|
+
function createDisposer() {
|
|
51
|
+
return new Disposer();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Shared no-op disposer for rows that register no cleanup work.
|
|
55
|
+
*
|
|
56
|
+
* The compiler references this (via `@geajs/core`'s export surface) whenever
|
|
57
|
+
* a keyed-list site proves `noRowDisposer: true` — cheaper than emitting a
|
|
58
|
+
* fresh `{ add() {}, dispose() {}, child() { return this } }` literal per
|
|
59
|
+
* row. 09 clear1k ×8 was paying ~8k object-literal allocations before.
|
|
60
|
+
*/
|
|
61
|
+
const NOOP_DISPOSER = new Disposer(true);
|
|
62
|
+
//#endregion
|
|
63
|
+
export { createDisposer as n, NOOP_DISPOSER as t };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=disposer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposer.mjs","names":[],"sources":["../../gea/src/runtime/disposer.ts"],"sourcesContent":["/**\n * Disposer — LIFO teardown registry.\n *\n * Class-based so the `add` / `dispose` / `child` methods live on the prototype\n * once, instead of being closures created per instance. Each `createDisposer()`\n * call was allocating 3 closures; on a 1000-row keyed list with per-row\n * children that's ~3000 closure allocations that GC had to chase. The class\n * form drops that to one shared prototype plus the per-instance `f[]` array\n * and (for children) a single dispose-bridge closure.\n *\n * `Disposer` is the CLASS, not an interface over it. The interface had exactly\n * two implementors — this class and the `NOOP_DISPOSER` object literal — which\n * made every `Disposer`-typed slot polymorphic between a class instance and a\n * record, and geatsc has no native carrier for that: the type derives lattice\n * bottom, so `CompiledComponent`'s `[GEA_DISPOSER] = createDisposer() as\n * Disposer` field raised `representation-plan coverage gap for\n * PropertyDeclaration`, and `conditional()`'s `currentChild: Disposer | null`\n * capture blocked its whole nested-function cluster. One class with a `noop`\n * flag has a single concrete carrier and behaves identically: a no-op disposer\n * registers nothing, disposes an empty stack, and hands back itself as its own\n * child.\n */\n\nexport class Disposer {\n f: Array<() => void> = []\n /** A shared no-op disposer ignores registrations and owns no children. */\n noop: boolean\n\n constructor(noop = false) {\n this.noop = noop\n }\n\n add(fn: () => void): void {\n if (this.noop) return\n this.f.push(fn)\n }\n\n dispose(): void {\n const f = this.f\n // Hoisted try/catch (one per dispose call, not per iteration) — measurable\n // on 09_clear1k's ~5000-cleanup teardown. Framework-owned cleanups don't\n // throw under normal operation; if one does, the remainder of THIS\n // disposer's stack is skipped (best-effort teardown: one failure does not\n // run the rest of this disposer's callbacks).\n try {\n for (let i = f.length - 1; i >= 0; i--) f[i]()\n } catch {\n /* one handler threw */\n }\n f.length = 0\n }\n\n child(): Disposer {\n if (this.noop) return this\n const c = new Disposer()\n this.f.push(_dispatchChild(c))\n return c\n }\n}\n\nfunction _dispatchChild(c: Disposer): () => void {\n return () => c.dispose()\n}\n\nexport function createDisposer(): Disposer {\n return new Disposer()\n}\n\n/**\n * Shared no-op disposer for rows that register no cleanup work.\n *\n * The compiler references this (via `@geajs/core`'s export surface) whenever\n * a keyed-list site proves `noRowDisposer: true` — cheaper than emitting a\n * fresh `{ add() {}, dispose() {}, child() { return this } }` literal per\n * row. 09 clear1k ×8 was paying ~8k object-literal allocations before.\n */\nexport const NOOP_DISPOSER: Disposer = new Disposer(true)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,WAAb,MAAa,SAAS;CAKpB,YAAY,OAAO,OAAO;WAJH,EAAE;AAKvB,OAAK,OAAO;;CAGd,IAAI,IAAsB;AACxB,MAAI,KAAK,KAAM;AACf,OAAK,EAAE,KAAK,GAAG;;CAGjB,UAAgB;EACd,MAAM,IAAI,KAAK;AAMf,MAAI;AACF,QAAK,IAAI,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,IAAK,GAAE,IAAI;UACxC;AAGR,IAAE,SAAS;;CAGb,QAAkB;AAChB,MAAI,KAAK,KAAM,QAAO;EACtB,MAAM,IAAI,IAAI,UAAU;AACxB,OAAK,EAAE,KAAK,eAAe,EAAE,CAAC;AAC9B,SAAO;;;AAIX,SAAS,eAAe,GAAyB;AAC/C,cAAa,EAAE,SAAS;;AAG1B,SAAgB,iBAA2B;AACzC,QAAO,IAAI,UAAU;;;;;;;;;;AAWvB,MAAa,gBAA0B,IAAI,SAAS,KAAK"}
|
package/dist/dnd-manager.d.mts
CHANGED
|
@@ -5,10 +5,11 @@ interface DragResult {
|
|
|
5
5
|
droppableId: string;
|
|
6
6
|
index: number;
|
|
7
7
|
};
|
|
8
|
+
/** `null` when dropped outside any droppable or returned to same position. */
|
|
8
9
|
destination: {
|
|
9
10
|
droppableId: string;
|
|
10
11
|
index: number;
|
|
11
|
-
};
|
|
12
|
+
} | null;
|
|
12
13
|
}
|
|
13
14
|
declare class DndManager {
|
|
14
15
|
droppables: Map<string, HTMLElement>;
|
|
@@ -21,6 +22,13 @@ declare class DndManager {
|
|
|
21
22
|
private _sourceDroppableId;
|
|
22
23
|
private _sourceIndex;
|
|
23
24
|
private _sourceEl;
|
|
25
|
+
/**
|
|
26
|
+
* If the source draggable is nested inside a component-boundary wrapper
|
|
27
|
+
* (e.g. a `<span style="display:contents">` inside the droppable), this
|
|
28
|
+
* holds that wrapper — the actual direct child of the droppable that we
|
|
29
|
+
* move/return. When there is no wrapper, this equals `_sourceEl`.
|
|
30
|
+
*/
|
|
31
|
+
private _sourceWrapper;
|
|
24
32
|
private _sourceHeight;
|
|
25
33
|
private _sourceRect;
|
|
26
34
|
private _savedCssText;
|
package/dist/dnd-manager.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GEA_DOM_COMPONENT, GEA_PARENT_COMPONENT, GEA_PROXY_GET_RAW_TARGET
|
|
1
|
+
import { GEA_DOM_COMPONENT, GEA_PARENT_COMPONENT, GEA_PROXY_GET_RAW_TARGET } from "@geajs/core";
|
|
2
2
|
//#region src/components/dnd-manager.ts
|
|
3
3
|
const DRAG_THRESHOLD_SQ = 25;
|
|
4
4
|
const DRAGGABLE_SEL = "[data-draggable-id]";
|
|
@@ -6,6 +6,25 @@ const DROPPABLE_SEL = "[data-droppable-id]";
|
|
|
6
6
|
function _rawComp(comp) {
|
|
7
7
|
return comp?.[GEA_PROXY_GET_RAW_TARGET] ?? comp;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Walk up from `el` until its parent is `container`. Used to find the
|
|
11
|
+
* right position within a droppable's direct children when draggable
|
|
12
|
+
* elements are wrapped in one or more intermediate elements (e.g. the
|
|
13
|
+
* `<span style="display:contents">` component-boundary wrapper that Gea
|
|
14
|
+
* emits around child-Component roots inside a keyed-list).
|
|
15
|
+
*
|
|
16
|
+
* Returns the direct-child-of-`container` ancestor of `el`, or `el`
|
|
17
|
+
* itself if `el` is already a direct child. Returns `null` if `el`
|
|
18
|
+
* isn't inside `container` at all.
|
|
19
|
+
*/
|
|
20
|
+
function _directChildOf(container, el) {
|
|
21
|
+
let n = el;
|
|
22
|
+
while (n && n.parentElement !== container) {
|
|
23
|
+
n = n.parentElement;
|
|
24
|
+
if (!n) return null;
|
|
25
|
+
}
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
9
28
|
var DndManager = class {
|
|
10
29
|
constructor() {
|
|
11
30
|
this.droppables = /* @__PURE__ */ new Map();
|
|
@@ -16,6 +35,7 @@ var DndManager = class {
|
|
|
16
35
|
this._sourceDroppableId = "";
|
|
17
36
|
this._sourceIndex = 0;
|
|
18
37
|
this._sourceEl = null;
|
|
38
|
+
this._sourceWrapper = null;
|
|
19
39
|
this._sourceHeight = 0;
|
|
20
40
|
this._sourceRect = null;
|
|
21
41
|
this._savedCssText = "";
|
|
@@ -67,7 +87,7 @@ var DndManager = class {
|
|
|
67
87
|
const droppableEl = el.closest(DROPPABLE_SEL);
|
|
68
88
|
if (!droppableEl) return;
|
|
69
89
|
const droppableId = droppableEl.dataset.droppableId;
|
|
70
|
-
const sourceIndex = Array.from(droppableEl.querySelectorAll(
|
|
90
|
+
const sourceIndex = Array.from(droppableEl.querySelectorAll(DRAGGABLE_SEL)).indexOf(el);
|
|
71
91
|
if (sourceIndex === -1) return;
|
|
72
92
|
this._dragging = true;
|
|
73
93
|
this._started = false;
|
|
@@ -118,8 +138,12 @@ var DndManager = class {
|
|
|
118
138
|
placeholder.style.height = rect.height + "px";
|
|
119
139
|
placeholder.style.marginBottom = elMargin;
|
|
120
140
|
placeholder.style.transition = "none";
|
|
121
|
-
|
|
141
|
+
const sourceContainer = this.droppables.get(this._sourceDroppableId) || el.closest(DROPPABLE_SEL);
|
|
142
|
+
this._sourceWrapper = sourceContainer ? _directChildOf(sourceContainer, el) : el;
|
|
143
|
+
const wrapper = this._sourceWrapper || el;
|
|
144
|
+
wrapper.parentElement.insertBefore(placeholder, wrapper);
|
|
122
145
|
document.body.appendChild(el);
|
|
146
|
+
el.classList.add("gea-dnd-clone", "gea-dragging");
|
|
123
147
|
Object.assign(el.style, {
|
|
124
148
|
position: "fixed",
|
|
125
149
|
top: "0px",
|
|
@@ -154,7 +178,7 @@ var DndManager = class {
|
|
|
154
178
|
this._currentDroppableId = null;
|
|
155
179
|
return;
|
|
156
180
|
}
|
|
157
|
-
const items = Array.from(foundEl.querySelectorAll(
|
|
181
|
+
const items = Array.from(foundEl.querySelectorAll(DRAGGABLE_SEL));
|
|
158
182
|
const threshold = clientY >= this._lastClientY ? 0 : 1;
|
|
159
183
|
let insertIndex = items.length;
|
|
160
184
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -167,7 +191,8 @@ var DndManager = class {
|
|
|
167
191
|
this._currentDroppableId = foundId;
|
|
168
192
|
this._currentIndex = insertIndex;
|
|
169
193
|
if (!this._placeholder) return;
|
|
170
|
-
const
|
|
194
|
+
const refItem = items[insertIndex] || null;
|
|
195
|
+
const refNode = refItem ? _directChildOf(foundEl, refItem) : null;
|
|
171
196
|
if (this._placeholder.parentElement !== foundEl || this._placeholder.nextElementSibling !== refNode) {
|
|
172
197
|
if (this._placeholder.parentElement) {
|
|
173
198
|
const ghost = document.createElement("div");
|
|
@@ -199,8 +224,17 @@ var DndManager = class {
|
|
|
199
224
|
this._dragging = false;
|
|
200
225
|
return;
|
|
201
226
|
}
|
|
227
|
+
const result = {
|
|
228
|
+
draggableId: this._draggedId,
|
|
229
|
+
source: {
|
|
230
|
+
droppableId: this._sourceDroppableId,
|
|
231
|
+
index: this._sourceIndex
|
|
232
|
+
},
|
|
233
|
+
destination: null
|
|
234
|
+
};
|
|
202
235
|
this._animateReturn().then(() => {
|
|
203
236
|
this._returnToSource();
|
|
237
|
+
this._onDragEnd?.(result);
|
|
204
238
|
this._cleanup();
|
|
205
239
|
});
|
|
206
240
|
}
|
|
@@ -215,27 +249,27 @@ var DndManager = class {
|
|
|
215
249
|
index: this._currentIndex
|
|
216
250
|
} : null;
|
|
217
251
|
const samePosition = destination && destination.droppableId === this._sourceDroppableId && destination.index === this._sourceIndex;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} else this._animateReturn().then(() => {
|
|
252
|
+
const result = {
|
|
253
|
+
draggableId: this._draggedId,
|
|
254
|
+
source: {
|
|
255
|
+
droppableId: this._sourceDroppableId,
|
|
256
|
+
index: this._sourceIndex
|
|
257
|
+
},
|
|
258
|
+
destination: destination && !samePosition ? destination : null
|
|
259
|
+
};
|
|
260
|
+
if (destination && this._placeholder && !samePosition) this._animateDrop().then(() => {
|
|
261
|
+
this._restoreElStyles();
|
|
262
|
+
const wrapper = this._sourceWrapper;
|
|
263
|
+
if (this._sourceEl?.parentElement === document.body) this._sourceEl.remove();
|
|
264
|
+
if (wrapper && wrapper !== this._sourceEl && this._sourceEl && !wrapper.contains(this._sourceEl)) wrapper.appendChild(this._sourceEl);
|
|
265
|
+
if (this._placeholder?.parentElement) this._placeholder.remove();
|
|
266
|
+
this._placeholder = null;
|
|
267
|
+
this._onDragEnd?.(result);
|
|
268
|
+
this._cleanup();
|
|
269
|
+
});
|
|
270
|
+
else this._animateReturn().then(() => {
|
|
238
271
|
this._returnToSource();
|
|
272
|
+
this._onDragEnd?.(result);
|
|
239
273
|
this._cleanup();
|
|
240
274
|
});
|
|
241
275
|
}
|
|
@@ -251,16 +285,20 @@ var DndManager = class {
|
|
|
251
285
|
_restoreElStyles() {
|
|
252
286
|
if (!this._sourceEl) return;
|
|
253
287
|
this._sourceEl.style.cssText = this._savedCssText;
|
|
288
|
+
this._sourceEl.classList.remove("gea-dnd-clone", "gea-dragging");
|
|
254
289
|
}
|
|
255
290
|
_returnToSource() {
|
|
256
291
|
if (!this._sourceEl) return;
|
|
257
292
|
this._restoreElStyles();
|
|
258
|
-
|
|
293
|
+
const wrapper = this._sourceWrapper || this._sourceEl;
|
|
294
|
+
if (wrapper !== this._sourceEl && !wrapper.contains(this._sourceEl)) wrapper.appendChild(this._sourceEl);
|
|
295
|
+
if (this._placeholder?.parentElement) this._placeholder.parentElement.insertBefore(wrapper, this._placeholder);
|
|
259
296
|
else {
|
|
260
297
|
const container = this.droppables.get(this._sourceDroppableId);
|
|
261
298
|
if (container) {
|
|
262
|
-
const items = Array.from(container.querySelectorAll(
|
|
263
|
-
|
|
299
|
+
const items = Array.from(container.querySelectorAll(DRAGGABLE_SEL));
|
|
300
|
+
const ref = items[this._sourceIndex] ? _directChildOf(container, items[this._sourceIndex]) : null;
|
|
301
|
+
container.insertBefore(wrapper, ref);
|
|
264
302
|
}
|
|
265
303
|
}
|
|
266
304
|
}
|
|
@@ -269,7 +307,7 @@ var DndManager = class {
|
|
|
269
307
|
if (!sourceEl) return;
|
|
270
308
|
const destContainer = this.droppables.get(destination.droppableId);
|
|
271
309
|
if (!destContainer) return;
|
|
272
|
-
const refNode = Array.from(destContainer.querySelectorAll(
|
|
310
|
+
const refNode = Array.from(destContainer.querySelectorAll(DRAGGABLE_SEL))[destination.index] || null;
|
|
273
311
|
destContainer.insertBefore(sourceEl, refNode);
|
|
274
312
|
const draggedComp = this._getComponentFromElement(sourceEl);
|
|
275
313
|
if (!draggedComp) return;
|