texditor 2.0.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.
- package/LICENSE.md +9 -0
- package/README.md +232 -0
- package/dist/core/base/base-model.d.ts +160 -0
- package/dist/core/base/base-model.d.ts.map +1 -0
- package/dist/core/base/event-manager.d.ts +20 -0
- package/dist/core/base/event-manager.d.ts.map +1 -0
- package/dist/core/base/index.d.ts +3 -0
- package/dist/core/base/index.d.ts.map +1 -0
- package/dist/core/base.d.ts +2 -0
- package/dist/core/base.mjs +1 -0
- package/dist/core/block-manager.d.ts +91 -0
- package/dist/core/block-manager.d.ts.map +1 -0
- package/dist/core/commands.d.ts +73 -0
- package/dist/core/commands.d.ts.map +1 -0
- package/dist/core/config.d.ts +11 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/events.d.ts +121 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/extensions.d.ts +23 -0
- package/dist/core/extensions.d.ts.map +1 -0
- package/dist/core/history-manager.d.ts +76 -0
- package/dist/core/history-manager.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +29 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/models/action-model.d.ts +54 -0
- package/dist/core/models/action-model.d.ts.map +1 -0
- package/dist/core/models/block-model.d.ts +396 -0
- package/dist/core/models/block-model.d.ts.map +1 -0
- package/dist/core/models/extension-model.d.ts +25 -0
- package/dist/core/models/extension-model.d.ts.map +1 -0
- package/dist/core/models/file-action-model.d.ts +20 -0
- package/dist/core/models/file-action-model.d.ts.map +1 -0
- package/dist/core/models/index.d.ts +7 -0
- package/dist/core/models/index.d.ts.map +1 -0
- package/dist/core/models/tool-model.d.ts +69 -0
- package/dist/core/models/tool-model.d.ts.map +1 -0
- package/dist/core/models.d.ts +2 -0
- package/dist/core/models.mjs +6 -0
- package/dist/core/security/sanitizer.d.ts +65 -0
- package/dist/core/security/sanitizer.d.ts.map +1 -0
- package/dist/core/selection-api.d.ts +52 -0
- package/dist/core/selection-api.d.ts.map +1 -0
- package/dist/core/tools.d.ts +27 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/ui/slider.d.ts +50 -0
- package/dist/core/ui/slider.d.ts.map +1 -0
- package/dist/core/ui/toasts.d.ts +23 -0
- package/dist/core/ui/toasts.d.ts.map +1 -0
- package/dist/core/ui/virtual-selection.d.ts +171 -0
- package/dist/core/ui/virtual-selection.d.ts.map +1 -0
- package/dist/entities/actions/convert-action.d.ts +9 -0
- package/dist/entities/actions/convert-action.d.ts.map +1 -0
- package/dist/entities/actions/create-action.d.ts +8 -0
- package/dist/entities/actions/create-action.d.ts.map +1 -0
- package/dist/entities/actions/delete-action.d.ts +8 -0
- package/dist/entities/actions/delete-action.d.ts.map +1 -0
- package/dist/entities/actions/index.d.ts +7 -0
- package/dist/entities/actions/index.d.ts.map +1 -0
- package/dist/entities/actions/move-down-action.d.ts +9 -0
- package/dist/entities/actions/move-down-action.d.ts.map +1 -0
- package/dist/entities/actions/move-up-action.d.ts +9 -0
- package/dist/entities/actions/move-up-action.d.ts.map +1 -0
- package/dist/entities/actions.d.ts +2 -0
- package/dist/entities/actions.mjs +6 -0
- package/dist/entities/blocks/code/index.d.ts +48 -0
- package/dist/entities/blocks/code/index.d.ts.map +1 -0
- package/dist/entities/blocks/code/languages.d.ts +4 -0
- package/dist/entities/blocks/code/languages.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/DeleteFileAction.d.ts +7 -0
- package/dist/entities/blocks/files/actions/DeleteFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/DownloadFileAction.d.ts +12 -0
- package/dist/entities/blocks/files/actions/DownloadFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/EditFileAction.d.ts +32 -0
- package/dist/entities/blocks/files/actions/EditFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/MoveLeftFileAction.d.ts +8 -0
- package/dist/entities/blocks/files/actions/MoveLeftFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/MoveRightFileAction.d.ts +8 -0
- package/dist/entities/blocks/files/actions/MoveRightFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/index.d.ts +185 -0
- package/dist/entities/blocks/files/index.d.ts.map +1 -0
- package/dist/entities/blocks/gallery/index.d.ts +60 -0
- package/dist/entities/blocks/gallery/index.d.ts.map +1 -0
- package/dist/entities/blocks/header/H1.d.ts +4 -0
- package/dist/entities/blocks/header/H1.d.ts.map +1 -0
- package/dist/entities/blocks/header/H2.d.ts +6 -0
- package/dist/entities/blocks/header/H2.d.ts.map +1 -0
- package/dist/entities/blocks/header/H3.d.ts +6 -0
- package/dist/entities/blocks/header/H3.d.ts.map +1 -0
- package/dist/entities/blocks/header/H4.d.ts +6 -0
- package/dist/entities/blocks/header/H4.d.ts.map +1 -0
- package/dist/entities/blocks/header/H5.d.ts +6 -0
- package/dist/entities/blocks/header/H5.d.ts.map +1 -0
- package/dist/entities/blocks/header/H6.d.ts +6 -0
- package/dist/entities/blocks/header/H6.d.ts.map +1 -0
- package/dist/entities/blocks/header/index.d.ts +6 -0
- package/dist/entities/blocks/header/index.d.ts.map +1 -0
- package/dist/entities/blocks/index.d.ts +14 -0
- package/dist/entities/blocks/index.d.ts.map +1 -0
- package/dist/entities/blocks/list/index.d.ts +6 -0
- package/dist/entities/blocks/list/index.d.ts.map +1 -0
- package/dist/entities/blocks/list/ol.d.ts +6 -0
- package/dist/entities/blocks/list/ol.d.ts.map +1 -0
- package/dist/entities/blocks/paragraph/index.d.ts +6 -0
- package/dist/entities/blocks/paragraph/index.d.ts.map +1 -0
- package/dist/entities/blocks.d.ts +2 -0
- package/dist/entities/blocks.mjs +13 -0
- package/dist/entities/extensions/delete-selected.d.ts +9 -0
- package/dist/entities/extensions/delete-selected.d.ts.map +1 -0
- package/dist/entities/extensions/index.d.ts +5 -0
- package/dist/entities/extensions/index.d.ts.map +1 -0
- package/dist/entities/extensions/redo.d.ts +8 -0
- package/dist/entities/extensions/redo.d.ts.map +1 -0
- package/dist/entities/extensions/undo.d.ts +8 -0
- package/dist/entities/extensions/undo.d.ts.map +1 -0
- package/dist/entities/extensions.d.ts +2 -0
- package/dist/entities/extensions.mjs +4 -0
- package/dist/entities/tools/bold.d.ts +6 -0
- package/dist/entities/tools/bold.d.ts.map +1 -0
- package/dist/entities/tools/clear-formatting.d.ts +7 -0
- package/dist/entities/tools/clear-formatting.d.ts.map +1 -0
- package/dist/entities/tools/index.d.ts +10 -0
- package/dist/entities/tools/index.d.ts.map +1 -0
- package/dist/entities/tools/inline-code.d.ts +6 -0
- package/dist/entities/tools/inline-code.d.ts.map +1 -0
- package/dist/entities/tools/italic.d.ts +6 -0
- package/dist/entities/tools/italic.d.ts.map +1 -0
- package/dist/entities/tools/link.d.ts +35 -0
- package/dist/entities/tools/link.d.ts.map +1 -0
- package/dist/entities/tools/marker.d.ts +6 -0
- package/dist/entities/tools/marker.d.ts.map +1 -0
- package/dist/entities/tools/subscript.d.ts +6 -0
- package/dist/entities/tools/subscript.d.ts.map +1 -0
- package/dist/entities/tools/superscript.d.ts +6 -0
- package/dist/entities/tools/superscript.d.ts.map +1 -0
- package/dist/entities/tools.d.ts +2 -0
- package/dist/entities/tools.mjs +9 -0
- package/dist/icons/index.d.ts +42 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/locales/en.d.ts +66 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/index.d.ts +4 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/ru.d.ts +66 -0
- package/dist/locales/ru.d.ts.map +1 -0
- package/dist/locales.d.ts +2 -0
- package/dist/locales.mjs +3 -0
- package/dist/main.d.ts +6 -0
- package/dist/node_modules/snappykit/dist/snappykit.mjs +440 -0
- package/dist/node_modules/sortum/dist/sortum.mjs +588 -0
- package/dist/src/core/base/base-model.mjs +184 -0
- package/dist/src/core/base/event-manager.mjs +31 -0
- package/dist/src/core/block-manager.mjs +499 -0
- package/dist/src/core/commands.mjs +311 -0
- package/dist/src/core/config.mjs +12 -0
- package/dist/src/core/events.mjs +369 -0
- package/dist/src/core/extensions.mjs +48 -0
- package/dist/src/core/history-manager.mjs +107 -0
- package/dist/src/core/i18n.mjs +25 -0
- package/dist/src/core/models/action-model.mjs +72 -0
- package/dist/src/core/models/block-model.mjs +619 -0
- package/dist/src/core/models/extension-model.mjs +28 -0
- package/dist/src/core/models/file-action-model.mjs +24 -0
- package/dist/src/core/models/tool-model.mjs +80 -0
- package/dist/src/core/security/sanitizer.mjs +130 -0
- package/dist/src/core/selection-api.mjs +202 -0
- package/dist/src/core/tools.mjs +88 -0
- package/dist/src/core/ui/slider.mjs +81 -0
- package/dist/src/core/ui/toasts.mjs +55 -0
- package/dist/src/core/ui/virtual-selection.mjs +205 -0
- package/dist/src/entities/actions/convert-action.mjs +43 -0
- package/dist/src/entities/actions/create-action.mjs +39 -0
- package/dist/src/entities/actions/delete-action.mjs +19 -0
- package/dist/src/entities/actions/move-down-action.mjs +22 -0
- package/dist/src/entities/actions/move-up-action.mjs +22 -0
- package/dist/src/entities/blocks/code/index.mjs +144 -0
- package/dist/src/entities/blocks/code/languages.mjs +54 -0
- package/dist/src/entities/blocks/files/actions/DeleteFileAction.mjs +21 -0
- package/dist/src/entities/blocks/files/actions/DownloadFileAction.mjs +44 -0
- package/dist/src/entities/blocks/files/actions/EditFileAction.mjs +111 -0
- package/dist/src/entities/blocks/files/actions/MoveLeftFileAction.mjs +24 -0
- package/dist/src/entities/blocks/files/actions/MoveRightFileAction.mjs +24 -0
- package/dist/src/entities/blocks/files/index.mjs +424 -0
- package/dist/src/entities/blocks/gallery/index.mjs +141 -0
- package/dist/src/entities/blocks/header/H1.mjs +5 -0
- package/dist/src/entities/blocks/header/H2.mjs +16 -0
- package/dist/src/entities/blocks/header/H3.mjs +16 -0
- package/dist/src/entities/blocks/header/H4.mjs +16 -0
- package/dist/src/entities/blocks/header/H5.mjs +16 -0
- package/dist/src/entities/blocks/header/H6.mjs +16 -0
- package/dist/src/entities/blocks/header/index.mjs +46 -0
- package/dist/src/entities/blocks/list/index.mjs +51 -0
- package/dist/src/entities/blocks/list/ol.mjs +16 -0
- package/dist/src/entities/blocks/paragraph/index.mjs +46 -0
- package/dist/src/entities/extensions/delete-selected.mjs +27 -0
- package/dist/src/entities/extensions/redo.mjs +22 -0
- package/dist/src/entities/extensions/undo.mjs +22 -0
- package/dist/src/entities/tools/bold.mjs +16 -0
- package/dist/src/entities/tools/clear-formatting.mjs +20 -0
- package/dist/src/entities/tools/inline-code.mjs +19 -0
- package/dist/src/entities/tools/italic.mjs +16 -0
- package/dist/src/entities/tools/link.mjs +89 -0
- package/dist/src/entities/tools/marker.mjs +17 -0
- package/dist/src/entities/tools/subscript.mjs +17 -0
- package/dist/src/entities/tools/superscript.mjs +18 -0
- package/dist/src/icons/index.mjs +4 -0
- package/dist/src/locales/en.mjs +68 -0
- package/dist/src/locales/ru.mjs +68 -0
- package/dist/src/store/currentStore.mjs +8 -0
- package/dist/src/store/mainStore.mjs +4 -0
- package/dist/src/utils/ajax.mjs +35 -0
- package/dist/src/utils/common.mjs +26 -0
- package/dist/src/utils/icon.mjs +12 -0
- package/dist/src/utils/sanitizer.mjs +20 -0
- package/dist/src/views/extensions.mjs +18 -0
- package/dist/src/views/main.mjs +19 -0
- package/dist/src/views/tools.mjs +9 -0
- package/dist/store/currentStore.d.ts +15 -0
- package/dist/store/currentStore.d.ts.map +1 -0
- package/dist/store/mainStore.d.ts +14 -0
- package/dist/store/mainStore.d.ts.map +1 -0
- package/dist/styles/animations.css +1 -0
- package/dist/styles/core/ui/selection.css +1 -0
- package/dist/styles/core/ui/slider.css +1 -0
- package/dist/styles/entities/blocks/code.css +1 -0
- package/dist/styles/entities/blocks/files.css +1 -0
- package/dist/styles/entities/blocks/gallery.css +1 -0
- package/dist/styles/entities/blocks/list.css +1 -0
- package/dist/styles/entities/blocks/paragraph.css +1 -0
- package/dist/styles/entities/tools/inline-code.css +1 -0
- package/dist/styles/entities/tools/link.css +1 -0
- package/dist/styles/texditor.css +1 -0
- package/dist/styles/theme.css +42 -0
- package/dist/texditor.d.ts +68 -0
- package/dist/texditor.d.ts.map +1 -0
- package/dist/texditor.mjs +138 -0
- package/dist/types/core/base/base-model.d.ts +212 -0
- package/dist/types/core/base/base-model.d.ts.map +1 -0
- package/dist/types/core/base/event-manager.d.ts +42 -0
- package/dist/types/core/base/event-manager.d.ts.map +1 -0
- package/dist/types/core/base/index.d.ts +3 -0
- package/dist/types/core/base/index.d.ts.map +1 -0
- package/dist/types/core/block-manager.d.ts +223 -0
- package/dist/types/core/block-manager.d.ts.map +1 -0
- package/dist/types/core/commands.d.ts +93 -0
- package/dist/types/core/commands.d.ts.map +1 -0
- package/dist/types/core/config.d.ts +86 -0
- package/dist/types/core/config.d.ts.map +1 -0
- package/dist/types/core/events.d.ts +58 -0
- package/dist/types/core/events.d.ts.map +1 -0
- package/dist/types/core/extensions.d.ts +19 -0
- package/dist/types/core/extensions.d.ts.map +1 -0
- package/dist/types/core/history-manager.d.ts +72 -0
- package/dist/types/core/history-manager.d.ts.map +1 -0
- package/dist/types/core/http/index.d.ts +2 -0
- package/dist/types/core/http/index.d.ts.map +1 -0
- package/dist/types/core/http/response.d.ts +6 -0
- package/dist/types/core/http/response.d.ts.map +1 -0
- package/dist/types/core/i18n.d.ts +40 -0
- package/dist/types/core/i18n.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +15 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/models/action-model.d.ts +46 -0
- package/dist/types/core/models/action-model.d.ts.map +1 -0
- package/dist/types/core/models/block-model.d.ts +404 -0
- package/dist/types/core/models/block-model.d.ts.map +1 -0
- package/dist/types/core/models/extension-model.d.ts +41 -0
- package/dist/types/core/models/extension-model.d.ts.map +1 -0
- package/dist/types/core/models/file-action-model.d.ts +36 -0
- package/dist/types/core/models/file-action-model.d.ts.map +1 -0
- package/dist/types/core/models/index.d.ts +7 -0
- package/dist/types/core/models/index.d.ts.map +1 -0
- package/dist/types/core/models/tool-model.d.ts +54 -0
- package/dist/types/core/models/tool-model.d.ts.map +1 -0
- package/dist/types/core/sanitizer.d.ts +27 -0
- package/dist/types/core/sanitizer.d.ts.map +1 -0
- package/dist/types/core/selection-api.d.ts +116 -0
- package/dist/types/core/selection-api.d.ts.map +1 -0
- package/dist/types/core/tools.d.ts +35 -0
- package/dist/types/core/tools.d.ts.map +1 -0
- package/dist/types/core/ui/index.d.ts +4 -0
- package/dist/types/core/ui/index.d.ts.map +1 -0
- package/dist/types/core/ui/slider.d.ts +45 -0
- package/dist/types/core/ui/slider.d.ts.map +1 -0
- package/dist/types/core/ui/toasts.d.ts +58 -0
- package/dist/types/core/ui/toasts.d.ts.map +1 -0
- package/dist/types/core/ui/virtual-selection.d.ts +83 -0
- package/dist/types/core/ui/virtual-selection.d.ts.map +1 -0
- package/dist/types/entities/blocks/code.d.ts +4 -0
- package/dist/types/entities/blocks/code.d.ts.map +1 -0
- package/dist/types/entities/blocks/files.d.ts +170 -0
- package/dist/types/entities/blocks/files.d.ts.map +1 -0
- package/dist/types/entities/blocks/gallery.d.ts +40 -0
- package/dist/types/entities/blocks/gallery.d.ts.map +1 -0
- package/dist/types/entities/blocks/header.d.ts +4 -0
- package/dist/types/entities/blocks/header.d.ts.map +1 -0
- package/dist/types/entities/blocks/index.d.ts +7 -0
- package/dist/types/entities/blocks/index.d.ts.map +1 -0
- package/dist/types/entities/blocks/list.d.ts +4 -0
- package/dist/types/entities/blocks/list.d.ts.map +1 -0
- package/dist/types/entities/blocks/paragraph.d.ts +4 -0
- package/dist/types/entities/blocks/paragraph.d.ts.map +1 -0
- package/dist/types/entities/index.d.ts +2 -0
- package/dist/types/entities/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/texditor.d.ts +66 -0
- package/dist/types/texditor.d.ts.map +1 -0
- package/dist/types/utils/ajax.d.ts +31 -0
- package/dist/types/utils/ajax.d.ts.map +1 -0
- package/dist/types/utils/icon.d.ts +10 -0
- package/dist/types/utils/icon.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/utils/ajax.d.ts +9 -0
- package/dist/utils/ajax.d.ts.map +1 -0
- package/dist/utils/common.d.ts +28 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/icon.d.ts +12 -0
- package/dist/utils/icon.d.ts.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/sanitizer.d.ts +8 -0
- package/dist/utils/sanitizer.d.ts.map +1 -0
- package/dist/views/extensions.d.ts +3 -0
- package/dist/views/extensions.d.ts.map +1 -0
- package/dist/views/main.d.ts +3 -0
- package/dist/views/main.d.ts.map +1 -0
- package/dist/views/tools.d.ts +2 -0
- package/dist/views/tools.d.ts.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
//#region node_modules/sortum/dist/sortum.mjs
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function t(e) {
|
|
4
|
+
return e ? n(e.charAt(0)) + e.slice(1) : "";
|
|
5
|
+
}
|
|
6
|
+
function n(e) {
|
|
7
|
+
return e.toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
function r(e) {
|
|
10
|
+
return t(e.replace(/[-_\s]+(.)?/g, (e, t) => t ? t.toUpperCase() : ""));
|
|
11
|
+
}
|
|
12
|
+
function i(e) {
|
|
13
|
+
return e.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
function a(e, t, n) {
|
|
16
|
+
let o = "", s = (e) => typeof e == "number" ? `${e}px` : String(e);
|
|
17
|
+
if (typeof t == "object") for (let [n, r] of Object.entries(t)) a(e, n, r);
|
|
18
|
+
else {
|
|
19
|
+
let a = i(t), c = r(t);
|
|
20
|
+
n === "" || n === null ? (e.style.removeProperty(a), e.style.setProperty(a, "")) : n === void 0 ? o = e.style.getPropertyValue(a) || g(e, "").getPropertyValue(a) || "" : c in e.style && e.style.setProperty(a, s(n));
|
|
21
|
+
}
|
|
22
|
+
return o;
|
|
23
|
+
}
|
|
24
|
+
function o(e) {
|
|
25
|
+
return typeof e == "string" ? e.split(" ").map((e) => e.trim()).filter((e) => e !== "") : e.join(" ").split(" ").map((e) => e.trim()).filter((e) => e !== "");
|
|
26
|
+
}
|
|
27
|
+
function s(e, t) {
|
|
28
|
+
if (!e) return;
|
|
29
|
+
let n = o(t);
|
|
30
|
+
n.length !== 0 && e.classList.add(...n);
|
|
31
|
+
}
|
|
32
|
+
function c(e, t) {
|
|
33
|
+
if (!e) return;
|
|
34
|
+
let n = o(t);
|
|
35
|
+
n.length !== 0 && e.classList.remove(...n);
|
|
36
|
+
}
|
|
37
|
+
function l(e) {
|
|
38
|
+
e && (e instanceof NodeList ? Array.from(e).forEach((e) => l(e)) : Array.isArray(e) ? e.slice().forEach((e) => l(e)) : e?.parentNode && e.parentNode.removeChild(e));
|
|
39
|
+
}
|
|
40
|
+
function u(e, t) {
|
|
41
|
+
return t instanceof NodeList ? t.forEach((t) => u(e, t)) : Array.isArray(t) ? Array.from(t).forEach((t) => u(e, t)) : e.appendChild(t), e;
|
|
42
|
+
}
|
|
43
|
+
function d(e, t, n) {
|
|
44
|
+
if (typeof t == "object" && t) return Object.entries(t).forEach(([t, n]) => {
|
|
45
|
+
d(e, t, n);
|
|
46
|
+
}), e;
|
|
47
|
+
if (n === null) return f(e, t), e;
|
|
48
|
+
if (n !== void 0) return e.setAttribute(t, n), e;
|
|
49
|
+
let r = e.getAttribute(t);
|
|
50
|
+
return r === null ? void 0 : r;
|
|
51
|
+
}
|
|
52
|
+
function f(e, t) {
|
|
53
|
+
Array.isArray(t) ? t.forEach((t) => f(e, t)) : e.removeAttribute(t);
|
|
54
|
+
}
|
|
55
|
+
function p(e, t) {
|
|
56
|
+
if (!e || !t || !(e instanceof Node) || !(t instanceof Node)) return !1;
|
|
57
|
+
let n = e;
|
|
58
|
+
for (; n;) {
|
|
59
|
+
if (n === t) return n;
|
|
60
|
+
n = n.parentElement || n.parentNode;
|
|
61
|
+
}
|
|
62
|
+
return !1;
|
|
63
|
+
}
|
|
64
|
+
function m(e, t, n) {
|
|
65
|
+
return typeof t == "object" && t ? (Object.entries(t).forEach(([t, n]) => {
|
|
66
|
+
m(e, t, n);
|
|
67
|
+
}), e) : n === null ? (delete e.dataset[t], e) : n === void 0 ? e.dataset[t] : (e.dataset[t] = n, e);
|
|
68
|
+
}
|
|
69
|
+
function h(e) {
|
|
70
|
+
return e.getBoundingClientRect();
|
|
71
|
+
}
|
|
72
|
+
function g(e, t) {
|
|
73
|
+
return window.getComputedStyle(e, t);
|
|
74
|
+
}
|
|
75
|
+
function _(t, n, r, i) {
|
|
76
|
+
let a = (e) => {
|
|
77
|
+
e.delegateTarget = t, r(e);
|
|
78
|
+
}, [o, s] = n.split("."), c = s ? `${o}.${s}` : `${o}.${Math.random().toString(36).slice(2)}`, l = e.get(t);
|
|
79
|
+
if (l || (l = /* @__PURE__ */ new Map(), e.set(t, l)), l.has(c)) {
|
|
80
|
+
let e = l.get(c);
|
|
81
|
+
t.removeEventListener(o, e, i);
|
|
82
|
+
}
|
|
83
|
+
l.set(c, a), t.addEventListener(o, a, i);
|
|
84
|
+
}
|
|
85
|
+
function v(t, n, r) {
|
|
86
|
+
let [i, a] = n.split("."), o = e.get(t);
|
|
87
|
+
if (o) {
|
|
88
|
+
if (a) {
|
|
89
|
+
let e = `${i}.${a}`, n = o.get(e);
|
|
90
|
+
if (!n) return;
|
|
91
|
+
t.removeEventListener(i, n, r), o.delete(e);
|
|
92
|
+
} else for (let [e, n] of o) e.startsWith(`${i}.`) && (t.removeEventListener(i, n, r), o.delete(e));
|
|
93
|
+
o.size === 0 && e.delete(t);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
var y = class e {
|
|
97
|
+
static {
|
|
98
|
+
this.instances = /* @__PURE__ */ new WeakMap();
|
|
99
|
+
}
|
|
100
|
+
constructor(e, t = {}) {
|
|
101
|
+
this.fullItemsSelector = "", this.ghost = null, this.grabbed = null, this.target = null, this.dropped = null, this.destination = null, this.fromIndex = -1, this.toIndex = -1, this.affected = [], this.scrollContainer = null, this.scrollDirection = null, this.scrollAnimation = null, this.edgePressure = 0, this.isScrolling = !1, this.hasMoved = !1, this.hasTouchMoved = !1, this.shouldRemoveContainerClass = !1, this.startPosition = null, this.touchStart = null, this.currentEvent = null, this.pointerOffsetRatio = {
|
|
102
|
+
x: 0,
|
|
103
|
+
y: 0
|
|
104
|
+
}, this.currentPointer = {
|
|
105
|
+
clientX: 0,
|
|
106
|
+
clientY: 0
|
|
107
|
+
}, this.originalSize = {
|
|
108
|
+
width: 0,
|
|
109
|
+
height: 0
|
|
110
|
+
}, this.currentContainer = null, this.container = e, this.refresh(t);
|
|
111
|
+
}
|
|
112
|
+
getChildren(e) {
|
|
113
|
+
return e ? [...e.children].filter((e) => !e.matches(`.${this.ghostClass}`)) : [];
|
|
114
|
+
}
|
|
115
|
+
hasSignificantMove(e, t, n) {
|
|
116
|
+
return Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY) >= n;
|
|
117
|
+
}
|
|
118
|
+
createGhost() {
|
|
119
|
+
if (!this.grabbed || !this.startPosition) return;
|
|
120
|
+
let { width: e, height: t } = h(this.grabbed);
|
|
121
|
+
this.originalSize = {
|
|
122
|
+
width: e,
|
|
123
|
+
height: t
|
|
124
|
+
}, this.ghost = this.grabbed.cloneNode(!0), a(this.ghost, {
|
|
125
|
+
position: "fixed",
|
|
126
|
+
left: 0,
|
|
127
|
+
top: 0,
|
|
128
|
+
width: e,
|
|
129
|
+
height: t,
|
|
130
|
+
pointerEvents: "none",
|
|
131
|
+
zIndex: this.zIndex,
|
|
132
|
+
opacity: this.opacity,
|
|
133
|
+
transition: "width 0.2s ease-out, height 0.2s ease-out"
|
|
134
|
+
}), c(this.ghost, [this.activeClass, this.targetClass]), s(this.ghost, this.ghostClass), this.ghost.animate([{ scale: `${this.scale}` }], {
|
|
135
|
+
duration: 250,
|
|
136
|
+
easing: this.easing,
|
|
137
|
+
fill: "forwards"
|
|
138
|
+
}), u(this.ghostAppendTo || document.body, this.ghost), this.updateGhostPosition(this.startPosition.clientX, this.startPosition.clientY);
|
|
139
|
+
}
|
|
140
|
+
removeGhost() {
|
|
141
|
+
this.ghost &&= (l(this.ghost), null);
|
|
142
|
+
}
|
|
143
|
+
updateGhostPosition(e, t) {
|
|
144
|
+
if (!this.ghost) return;
|
|
145
|
+
let n = h(this.ghost), r = n.width * this.pointerOffsetRatio.x, i = n.height * this.pointerOffsetRatio.y, o = e - r, s = t - i;
|
|
146
|
+
a(this.ghost, {
|
|
147
|
+
left: o,
|
|
148
|
+
top: s,
|
|
149
|
+
translate: "0 0"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
animateItem({ el: e, x: t, y: n }) {
|
|
153
|
+
let { left: r, top: i } = h(e);
|
|
154
|
+
if (t === r && n === i) return;
|
|
155
|
+
s(e, this.animatedClass);
|
|
156
|
+
let a = e === this.grabbed ? [{
|
|
157
|
+
position: "relative",
|
|
158
|
+
zIndex: 1,
|
|
159
|
+
translate: `${t - r}px ${n - i}px`,
|
|
160
|
+
opacity: .9,
|
|
161
|
+
scale: `${this.scale}`
|
|
162
|
+
}, {
|
|
163
|
+
position: "relative",
|
|
164
|
+
zIndex: 1,
|
|
165
|
+
translate: "0",
|
|
166
|
+
opacity: 1,
|
|
167
|
+
scale: "1"
|
|
168
|
+
}] : [
|
|
169
|
+
{
|
|
170
|
+
position: "relative",
|
|
171
|
+
zIndex: 0,
|
|
172
|
+
scale: "1.0",
|
|
173
|
+
translate: `${t - r}px ${n - i}px`
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
position: "relative",
|
|
177
|
+
zIndex: 0,
|
|
178
|
+
scale: `${2 - this.scale}`
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
position: "relative",
|
|
182
|
+
zIndex: 0,
|
|
183
|
+
scale: "1.0",
|
|
184
|
+
translate: "0"
|
|
185
|
+
}
|
|
186
|
+
], o = e.animate(a, {
|
|
187
|
+
duration: this.duration,
|
|
188
|
+
easing: this.easing,
|
|
189
|
+
fill: "forwards"
|
|
190
|
+
});
|
|
191
|
+
return o.addEventListener("finish", () => {
|
|
192
|
+
c(e, this.animatedClass), o.cancel();
|
|
193
|
+
}), o;
|
|
194
|
+
}
|
|
195
|
+
findDropTarget(e, t) {
|
|
196
|
+
let n = document.elementFromPoint(e, t)?.closest(this.containerSelector);
|
|
197
|
+
if (!n) return {
|
|
198
|
+
target: null,
|
|
199
|
+
dropContainer: null
|
|
200
|
+
};
|
|
201
|
+
let r = this.getChildren(n).filter((e) => e !== this.grabbed);
|
|
202
|
+
if (!r.length) return {
|
|
203
|
+
target: n,
|
|
204
|
+
dropContainer: n
|
|
205
|
+
};
|
|
206
|
+
for (let e of r) {
|
|
207
|
+
let r = h(e);
|
|
208
|
+
if (t < r.top + r.height / 2) return {
|
|
209
|
+
target: e,
|
|
210
|
+
dropContainer: n
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
target: n,
|
|
215
|
+
dropContainer: n
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
isValidPosition({ clientX: t = 0, clientY: n = 0, el: r } = {}) {
|
|
219
|
+
let i = (t, n) => {
|
|
220
|
+
if (n) return !0;
|
|
221
|
+
let r = e.instances.get(t);
|
|
222
|
+
return !r || r.maxItems <= 0 ? !0 : r.getChildren(t).length < r.maxItems;
|
|
223
|
+
};
|
|
224
|
+
if (r) {
|
|
225
|
+
if (r.closest(`${this.ignoredSelector}`)) return !1;
|
|
226
|
+
let e = r.closest(`${this.fullItemsSelector}, ${this.containerSelector}`), t = r.closest(this.containerSelector);
|
|
227
|
+
if (!e || !t) return !1;
|
|
228
|
+
let n = p(e, this.grabbed) === this.grabbed, a = t === this.container, o = e === t;
|
|
229
|
+
if (!this.dropOnContainer && o || !i(t, a)) return !1;
|
|
230
|
+
let s = t.dataset.sortumGroup, c = !a && !!(s && this.group === s);
|
|
231
|
+
return !n && (c || a);
|
|
232
|
+
}
|
|
233
|
+
let { target: a, dropContainer: o } = this.findDropTarget(t, n);
|
|
234
|
+
if (!a || !o || a.closest(`${this.ignoredSelector}`)) return !1;
|
|
235
|
+
let s = p(a, this.grabbed) === this.grabbed, c = o === this.container, l = a === o;
|
|
236
|
+
if (!this.dropOnContainer && l || !i(o, c)) return !1;
|
|
237
|
+
let u = o.dataset.sortumGroup, d = !c && !!(u && this.group === u);
|
|
238
|
+
return !s && (d || c);
|
|
239
|
+
}
|
|
240
|
+
animationEngine(e, t = 60) {
|
|
241
|
+
let n = 1e3 / t, r = 0, i = null, a = () => {
|
|
242
|
+
i = requestAnimationFrame(a);
|
|
243
|
+
let t = window.performance.now(), o = t - r;
|
|
244
|
+
o < n || (r = t - o % n, e());
|
|
245
|
+
}, o = () => {
|
|
246
|
+
s(), r = performance.now(), i = requestAnimationFrame(a);
|
|
247
|
+
}, s = () => {
|
|
248
|
+
i !== null && cancelAnimationFrame(i), i = null, r = 0;
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
start: o,
|
|
252
|
+
stop: s,
|
|
253
|
+
tick: a
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
findScrollParent(e) {
|
|
257
|
+
for (; e && e !== document.documentElement;) {
|
|
258
|
+
let t = getComputedStyle(e);
|
|
259
|
+
if ((e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth) && /^(auto|scroll)$/.test(t.overflowY)) return e;
|
|
260
|
+
e = e.parentElement;
|
|
261
|
+
}
|
|
262
|
+
return document.documentElement;
|
|
263
|
+
}
|
|
264
|
+
scrollTick() {
|
|
265
|
+
if (!this.scrollDirection || !this.scrollContainer) return;
|
|
266
|
+
let e = this.scrollSpeed * (this.edgePressure / Math.max(this.edgeThreshold, 1));
|
|
267
|
+
this.scrollDirection === "up" ? this.scrollContainer.scrollTop -= e : this.scrollDirection === "down" ? this.scrollContainer.scrollTop += e : this.scrollDirection === "left" ? this.scrollContainer.scrollLeft -= e : this.scrollDirection === "right" && (this.scrollContainer.scrollLeft += e);
|
|
268
|
+
}
|
|
269
|
+
startAutoScroll(e) {
|
|
270
|
+
this.scrollDirection !== e && (this.scrollDirection = e, this.scrollAnimation || (this.scrollAnimation = this.animationEngine(() => this.scrollTick()), this.scrollAnimation?.start()));
|
|
271
|
+
}
|
|
272
|
+
stopAutoScroll() {
|
|
273
|
+
this.scrollDirection = null, this.scrollAnimation &&= (this.scrollAnimation.stop(), null);
|
|
274
|
+
}
|
|
275
|
+
handleEdgeScroll(e) {
|
|
276
|
+
this.scrollContainer ||= this.findScrollParent(this.grabbed);
|
|
277
|
+
let t = h(this.scrollContainer), n = document.documentElement, r = this.scrollContainer === n, i = r ? 0 : t.top, a = r ? window.innerHeight : t.bottom, o = r ? 0 : t.left, s = r ? window.innerWidth : t.right;
|
|
278
|
+
e.clientY < i + this.edgeThreshold ? (this.edgePressure = Math.min(this.edgeThreshold, this.edgeThreshold - (e.clientY - i)), this.startAutoScroll("up")) : e.clientY > a - this.edgeThreshold ? (this.edgePressure = Math.min(this.edgeThreshold, this.edgeThreshold - (a - e.clientY)), this.startAutoScroll("down")) : e.clientX < o + this.edgeThreshold ? (this.edgePressure = Math.min(this.edgeThreshold, this.edgeThreshold - (e.clientX - o)), this.startAutoScroll("left")) : e.clientX > s - this.edgeThreshold ? (this.edgePressure = Math.min(this.edgeThreshold, this.edgeThreshold - (s - e.clientX)), this.startAutoScroll("right")) : this.stopAutoScroll();
|
|
279
|
+
}
|
|
280
|
+
performDrop(e, t, n, r) {
|
|
281
|
+
let i = e.closest(this.containerSelector), a = this.getChildren(i);
|
|
282
|
+
this.fromIndex = a.indexOf(e);
|
|
283
|
+
let o = a.filter((t) => t !== e);
|
|
284
|
+
this.dropped = t?.closest(`${this.fullItemsSelector}, ${this.containerSelector}`);
|
|
285
|
+
let l = this.dropped?.matches(this.containerSelector);
|
|
286
|
+
this.destination = this.dropped?.closest(this.containerSelector);
|
|
287
|
+
let d = this.getChildren(this.destination), f = i === this.destination;
|
|
288
|
+
if (this.toIndex = l ? Math.max(0, f ? o.length : d.length) : d.indexOf(this.dropped), !f && !l && this.dropped) {
|
|
289
|
+
let t = h(this.dropped), i = getComputedStyle(this.destination), a = (i.gridTemplateColumns || "").split(" ").filter(Boolean).length, o = i.display.includes("grid") && a > 1, s = i.display.includes("flex") && (i.flexDirection === "row" || i.flexDirection === "row-reverse") && i.flexWrap !== "nowrap";
|
|
290
|
+
if (o || s) {
|
|
291
|
+
let t = d.filter((t) => t !== e), i = /* @__PURE__ */ new Map();
|
|
292
|
+
for (let e of t) {
|
|
293
|
+
let t = h(e), n = null;
|
|
294
|
+
for (let e of i.keys()) if (Math.abs(e - t.top) < 10) {
|
|
295
|
+
n = e;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
let r = n ?? Math.round(t.top);
|
|
299
|
+
i.has(r) || i.set(r, []), i.get(r).push(e);
|
|
300
|
+
}
|
|
301
|
+
let a = [...i.entries()].sort((e, t) => e[0] - t[0]), o = null, s = Infinity;
|
|
302
|
+
for (let [, e] of a) {
|
|
303
|
+
let t = e.map((e) => h(e)), n = Math.min(...t.map((e) => e.top)), i = n + (Math.max(...t.map((e) => e.bottom)) - n) / 2, a = Math.abs(r - i);
|
|
304
|
+
a < s && (s = a, o = e);
|
|
305
|
+
}
|
|
306
|
+
if (!o) {
|
|
307
|
+
let e = a[0]?.[1];
|
|
308
|
+
e && r < h(e[0]).top && (o = e);
|
|
309
|
+
}
|
|
310
|
+
if (o) {
|
|
311
|
+
o.sort((e, t) => h(e).left - h(t).left);
|
|
312
|
+
let e = o.length;
|
|
313
|
+
for (let t = 0; t < o.length; t++) {
|
|
314
|
+
let r = h(o[t]);
|
|
315
|
+
if (n < r.left + r.width / 2) {
|
|
316
|
+
e = t;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
let t = o[0], r = d.indexOf(t);
|
|
321
|
+
this.toIndex = r + e;
|
|
322
|
+
} else this.toIndex = d.length;
|
|
323
|
+
} else r - t.top > t.height / 2 && this.toIndex++;
|
|
324
|
+
}
|
|
325
|
+
if (!this.ghost) return !1;
|
|
326
|
+
this.ghost.animate([{ scale: 1 }], {
|
|
327
|
+
duration: 0,
|
|
328
|
+
fill: "forwards"
|
|
329
|
+
});
|
|
330
|
+
let p = h(this.ghost);
|
|
331
|
+
if (this.affected = [], this.swap) this.affected = this.dropped ? [this.dropped] : [];
|
|
332
|
+
else if (f) {
|
|
333
|
+
let e = l ? this.fromIndex : Math.min(this.toIndex, this.fromIndex), t = l ? o.length : Math.max(this.toIndex, this.fromIndex);
|
|
334
|
+
this.affected = o.slice(e, t);
|
|
335
|
+
} else this.affected = [...o.slice(this.fromIndex), ...d.slice(this.toIndex)];
|
|
336
|
+
let m = this.isValidPosition({ el: t }), g = this.onDrop?.({
|
|
337
|
+
item: this.grabbed,
|
|
338
|
+
source: i,
|
|
339
|
+
target: this.dropped,
|
|
340
|
+
destination: this.destination,
|
|
341
|
+
fromIndex: this.fromIndex,
|
|
342
|
+
toIndex: this.toIndex,
|
|
343
|
+
isValid: m,
|
|
344
|
+
isSameContainer: f,
|
|
345
|
+
event: this.currentEvent
|
|
346
|
+
}) ?? !0, _ = f && this.fromIndex === this.toIndex, v = this.dropped && m && g && !_;
|
|
347
|
+
if (v) {
|
|
348
|
+
let t = this.affected.map((e) => {
|
|
349
|
+
let { x: t, y: n } = h(e);
|
|
350
|
+
return {
|
|
351
|
+
el: e,
|
|
352
|
+
x: t,
|
|
353
|
+
y: n
|
|
354
|
+
};
|
|
355
|
+
});
|
|
356
|
+
if (this.swap && !l) {
|
|
357
|
+
let t = e.nextSibling;
|
|
358
|
+
this.destination?.insertBefore(e, this.dropped.nextSibling), i?.insertBefore(this.dropped, t);
|
|
359
|
+
} else l ? u(this.destination, e) : f ? this.destination?.insertBefore(e, this.toIndex < this.fromIndex ? this.dropped : this.dropped.nextSibling) : this.toIndex > d.indexOf(this.dropped) ? this.destination?.insertBefore(e, this.dropped.nextSibling) : this.destination?.insertBefore(e, this.dropped);
|
|
360
|
+
t.forEach(({ el: t, x: n, y: r }) => {
|
|
361
|
+
t !== e && this.animateItem({
|
|
362
|
+
el: t,
|
|
363
|
+
x: n,
|
|
364
|
+
y: r
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (p) {
|
|
369
|
+
s(e, this.dropAnimationClass);
|
|
370
|
+
let t = this.animateItem({
|
|
371
|
+
el: e,
|
|
372
|
+
x: p.left,
|
|
373
|
+
y: p.top
|
|
374
|
+
});
|
|
375
|
+
t ? t.addEventListener("finish", () => {
|
|
376
|
+
c(e, this.dropAnimationClass), this.onAnimationEnd?.();
|
|
377
|
+
}) : c(e, this.dropAnimationClass);
|
|
378
|
+
}
|
|
379
|
+
return this.removeGhost(), v;
|
|
380
|
+
}
|
|
381
|
+
onPointerDown(e) {
|
|
382
|
+
if (this.grabbed) return;
|
|
383
|
+
let t = e.target, n = t.closest(`${this.fullItemsSelector}`);
|
|
384
|
+
if (!n || n.parentElement !== this.container || t !== n && (this.noDropSelector && t.closest(this.noDropSelector) || this.noDragSelector && t.closest(this.noDragSelector))) return;
|
|
385
|
+
if (this.handleSelector) {
|
|
386
|
+
let e = t.closest(this.handleSelector);
|
|
387
|
+
if (!e || !n.contains(e)) return;
|
|
388
|
+
}
|
|
389
|
+
this.startPosition = {
|
|
390
|
+
clientX: e.clientX,
|
|
391
|
+
clientY: e.clientY
|
|
392
|
+
}, this.grabbed = n, this.fromIndex = this.getChildren(this.container).indexOf(this.grabbed);
|
|
393
|
+
let r = h(n);
|
|
394
|
+
if (this.pointerOffsetRatio = {
|
|
395
|
+
x: (e.clientX - r.left) / r.width,
|
|
396
|
+
y: (e.clientY - r.top) / r.height
|
|
397
|
+
}, this.onStart?.({
|
|
398
|
+
item: this.grabbed,
|
|
399
|
+
container: this.container,
|
|
400
|
+
index: this.fromIndex,
|
|
401
|
+
event: e
|
|
402
|
+
}) === !1) {
|
|
403
|
+
this.reset();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
e.preventDefault(), s(this.grabbed, this.activeClass), a(this.grabbed, {
|
|
407
|
+
cursor: "move",
|
|
408
|
+
userSelect: "none"
|
|
409
|
+
}), e.pointerType === "mouse" && (this.isScrolling = !0), this.onDrag?.({
|
|
410
|
+
item: this.grabbed,
|
|
411
|
+
container: this.container,
|
|
412
|
+
index: this.fromIndex,
|
|
413
|
+
event: e
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
onPointerMove(e) {
|
|
417
|
+
if (!this.grabbed || !this.isScrolling || (this.currentPointer = {
|
|
418
|
+
clientX: e.clientX,
|
|
419
|
+
clientY: e.clientY
|
|
420
|
+
}, this.hasMoved && !this.grabbed.hasPointerCapture(e.pointerId))) return;
|
|
421
|
+
!this.hasMoved && this.hasSignificantMove(this.startPosition, e, this.dragThreshold) && (this.hasMoved = !0, this.grabbed.setPointerCapture(e.pointerId), s(this.grabbed, this.draggingClass), this.createGhost());
|
|
422
|
+
let { clientX: t, clientY: n } = e, r = document.elementFromPoint(t, n), i = r?.closest(this.fullItemsSelector), o = r?.closest(this.containerSelector), l = this.isValidPosition({
|
|
423
|
+
clientX: t,
|
|
424
|
+
clientY: n
|
|
425
|
+
});
|
|
426
|
+
this.ghost && (this.updateGhostPosition(t, n), l ? c(this.ghost, this.invalidClass) : s(this.ghost, this.invalidClass)), a(this.grabbed, { cursor: l ? "grab" : "not-allowed" });
|
|
427
|
+
let u = o !== this.currentContainer;
|
|
428
|
+
u && (this.currentContainer = o), u && !o && this.syncGhostSize(null), i !== this.target && (this.target && c(this.target, this.targetClass), this.target = i, l && i && !i.matches(this.containerSelector) && (s(i, this.targetClass), this.syncGhostSize(i))), this.handleEdgeScroll(e), this.onMove?.({
|
|
429
|
+
item: this.grabbed,
|
|
430
|
+
container: this.container,
|
|
431
|
+
ghost: this.ghost,
|
|
432
|
+
target: this.target,
|
|
433
|
+
isValid: l,
|
|
434
|
+
event: e
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
onPointerUp(e) {
|
|
438
|
+
if (!this.grabbed) return;
|
|
439
|
+
this.stopAutoScroll(), this.isScrolling = !1, a(this.grabbed, {
|
|
440
|
+
userSelect: "",
|
|
441
|
+
cursor: ""
|
|
442
|
+
}), c(this.grabbed, [
|
|
443
|
+
this.activeClass,
|
|
444
|
+
this.draggingClass,
|
|
445
|
+
this.touchClass
|
|
446
|
+
]), this.target && c(this.target, this.targetClass);
|
|
447
|
+
let t = document.elementFromPoint(e.clientX, e.clientY);
|
|
448
|
+
this.currentEvent = e, this.performDrop(this.grabbed, t, e.clientX, e.clientY) && this.onEnd?.({
|
|
449
|
+
item: this.grabbed,
|
|
450
|
+
source: this.container,
|
|
451
|
+
target: this.dropped,
|
|
452
|
+
destination: this.destination,
|
|
453
|
+
fromIndex: this.fromIndex,
|
|
454
|
+
toIndex: this.toIndex,
|
|
455
|
+
isValid: !0,
|
|
456
|
+
isSameContainer: this.container === this.destination,
|
|
457
|
+
event: e
|
|
458
|
+
}), this.reset(), this.removeGhost();
|
|
459
|
+
}
|
|
460
|
+
onTouchStart(e) {
|
|
461
|
+
!this.grabbed || this.touchStart || (this.touchStart = {
|
|
462
|
+
clientX: e.touches[0].clientX,
|
|
463
|
+
clientY: e.touches[0].clientY
|
|
464
|
+
}, this.pressTimer && clearTimeout(this.pressTimer), this.pressTimer = window.setTimeout(() => {
|
|
465
|
+
this.hasTouchMoved || (s(this.grabbed, this.touchClass), this.isScrolling = !0);
|
|
466
|
+
}, this.pressDuration));
|
|
467
|
+
}
|
|
468
|
+
onTouchMove(e) {
|
|
469
|
+
if (!this.grabbed || !this.touchStart) return;
|
|
470
|
+
let t = e.touches[0];
|
|
471
|
+
if (this.isScrolling) {
|
|
472
|
+
if (e.cancelable && e.preventDefault(), this.hasMoved && this.ghost) {
|
|
473
|
+
let { clientX: e, clientY: n } = t, r = document.elementFromPoint(e, n)?.closest(this.fullItemsSelector), i = this.isValidPosition({
|
|
474
|
+
clientX: e,
|
|
475
|
+
clientY: n
|
|
476
|
+
});
|
|
477
|
+
if (this.updateGhostPosition(e, n), this.ghost && (i ? c(this.ghost, this.invalidClass) : s(this.ghost, this.invalidClass)), r !== this.target) {
|
|
478
|
+
if (this.target && (c(this.target, this.targetClass), this.syncSizeOnOverlap && this.ghost && this.grabbed)) {
|
|
479
|
+
let { width: e, height: t } = h(this.grabbed);
|
|
480
|
+
a(this.ghost, {
|
|
481
|
+
width: `${e}px`,
|
|
482
|
+
height: `${t}px`
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
i && r && !r.matches(this.containerSelector) ? (this.target = r, s(this.target, this.targetClass), this.syncGhostSize(r)) : this.target = null;
|
|
486
|
+
}
|
|
487
|
+
this.handleEdgeScroll(t);
|
|
488
|
+
}
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
!this.hasTouchMoved && this.hasSignificantMove(this.touchStart, t, this.scrollThreshold) && (this.hasTouchMoved = !0, clearTimeout(this.pressTimer), this.pressTimer = void 0);
|
|
492
|
+
}
|
|
493
|
+
syncGhostSize(e) {
|
|
494
|
+
if (!this.ghost || !this.syncSizeOnOverlap || !this.grabbed) return;
|
|
495
|
+
clearTimeout(this.ghostResizeTimer);
|
|
496
|
+
let t = () => {
|
|
497
|
+
this.ghost && (a(this.ghost, {
|
|
498
|
+
width: `${this.originalSize.width}px`,
|
|
499
|
+
height: `${this.originalSize.height}px`
|
|
500
|
+
}), requestAnimationFrame(() => {
|
|
501
|
+
this.updateGhostPosition(this.currentPointer.clientX, this.currentPointer.clientY);
|
|
502
|
+
}));
|
|
503
|
+
};
|
|
504
|
+
if (e) {
|
|
505
|
+
let t = e.closest(this.containerSelector);
|
|
506
|
+
if (!t) return;
|
|
507
|
+
let n = m(t, "sortumGroup");
|
|
508
|
+
if (this.group !== "" && n !== this.group) return;
|
|
509
|
+
} else {
|
|
510
|
+
this.ghostResizeTimer = window.setTimeout(t, 80);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
this.ghostResizeTimer = window.setTimeout(() => {
|
|
514
|
+
if (!this.ghost) return;
|
|
515
|
+
if (e.matches(this.containerSelector)) {
|
|
516
|
+
t();
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
let n = h(e);
|
|
520
|
+
a(this.ghost, {
|
|
521
|
+
width: n.width,
|
|
522
|
+
height: n.height
|
|
523
|
+
});
|
|
524
|
+
let r = performance.now(), i = () => {
|
|
525
|
+
this.ghost && (this.updateGhostPosition(this.currentPointer.clientX, this.currentPointer.clientY), performance.now() - r < 180 && requestAnimationFrame(i));
|
|
526
|
+
};
|
|
527
|
+
requestAnimationFrame(i);
|
|
528
|
+
}, 120);
|
|
529
|
+
}
|
|
530
|
+
sort(e) {
|
|
531
|
+
let t = this.getChildren(this.container), n = t.map((e) => {
|
|
532
|
+
let { x: t, y: n } = h(e);
|
|
533
|
+
return {
|
|
534
|
+
el: e,
|
|
535
|
+
x: t,
|
|
536
|
+
y: n
|
|
537
|
+
};
|
|
538
|
+
}), r = [...t].sort(e);
|
|
539
|
+
return r.forEach((e) => u(this.container, e)), n.forEach((e) => this.animateItem(e)), r;
|
|
540
|
+
}
|
|
541
|
+
reset() {
|
|
542
|
+
clearTimeout(this.ghostResizeTimer), this.ghostResizeTimer = void 0, this.currentPointer = {
|
|
543
|
+
clientX: 0,
|
|
544
|
+
clientY: 0
|
|
545
|
+
}, this.ghost = null, this.grabbed = null, this.target = null, this.dropped = null, this.destination = null, this.fromIndex = -1, this.toIndex = -1, this.affected = [], this.scrollContainer = null, this.scrollDirection = null, this.scrollAnimation = null, this.edgePressure = 0, this.pressTimer = void 0, this.isScrolling = !1, this.startPosition = null, this.touchStart = null, this.hasMoved = !1, this.hasTouchMoved = !1;
|
|
546
|
+
}
|
|
547
|
+
refresh(t = {}) {
|
|
548
|
+
this.destroy(), Object.assign(this, {
|
|
549
|
+
group: "",
|
|
550
|
+
swap: !1,
|
|
551
|
+
syncSizeOnOverlap: !0,
|
|
552
|
+
duration: 420,
|
|
553
|
+
easing: "cubic-bezier(0.6, 0, 0.6, 1)",
|
|
554
|
+
scale: 1,
|
|
555
|
+
opacity: .8,
|
|
556
|
+
pressDuration: 240,
|
|
557
|
+
dropOnContainer: !0,
|
|
558
|
+
dragThreshold: 0,
|
|
559
|
+
scrollThreshold: 8,
|
|
560
|
+
edgeThreshold: 50,
|
|
561
|
+
scrollSpeed: 10,
|
|
562
|
+
zIndex: 2147483647,
|
|
563
|
+
maxItems: 0,
|
|
564
|
+
ghostAppendTo: document.body,
|
|
565
|
+
containerSelector: ".sortum",
|
|
566
|
+
itemsSelector: "*",
|
|
567
|
+
ignoredSelector: ".sortum-ignore",
|
|
568
|
+
handleSelector: "",
|
|
569
|
+
noDropSelector: "",
|
|
570
|
+
noDragSelector: ":is(input, select, textarea, button, label, [contenteditable=\"\"], [contenteditable=\"true\"], [tabindex]:not([tabindex^=\"-\"]), a[href]:not(a[href]=\"\"), area[href]):not(:disabled)",
|
|
571
|
+
ghostClass: "is-sortum-ghost",
|
|
572
|
+
activeClass: "is-sortum-active",
|
|
573
|
+
touchClass: "is-sortum-touch",
|
|
574
|
+
draggingClass: "is-sortum-grab",
|
|
575
|
+
targetClass: "is-sortum-target",
|
|
576
|
+
animatedClass: "is-sortum-animated",
|
|
577
|
+
dropAnimationClass: "is-sortum-animated-drop",
|
|
578
|
+
invalidClass: "is-sortum-invalid"
|
|
579
|
+
}, t), this.reset(), e.instances.set(this.container, this);
|
|
580
|
+
let n = this.containerSelector.replace(/^\./, "");
|
|
581
|
+
this.containerSelector.startsWith(".") && !this.container.matches(this.containerSelector) && (s(this.container, n), this.shouldRemoveContainerClass = !0), this.itemsSelector = (this.itemsSelector ?? "*").replace(/^(?! *>)/, "> $&"), this.fullItemsSelector = `${this.containerSelector}${this.itemsSelector}${this.ignoredSelector ? `:not(${this.ignoredSelector})` : ""}`, _(this.container, "touchstart.sortum", (e) => this.onTouchStart(e)), _(this.container, "touchmove.sortum", (e) => this.onTouchMove(e)), _(this.container, "pointerdown.sortum", (e) => this.onPointerDown(e)), _(this.container, "pointermove.sortum", (e) => this.onPointerMove(e)), _(this.container, "pointerup.sortum", (e) => this.onPointerUp(e)), _(this.container, "pointercancel.sortum", (e) => this.onPointerUp(e)), this.group && d(this.container, "data-sortum-group", this.group);
|
|
582
|
+
}
|
|
583
|
+
destroy() {
|
|
584
|
+
this.removeGhost(), e.instances.delete(this.container), v(this.container, "touchstart.sortum"), v(this.container, "touchmove.sortum"), v(this.container, "pointerdown.sortum"), v(this.container, "pointermove.sortum"), v(this.container, "pointerup.sortum"), v(this.container, "pointercancel.sortum"), this.group && f(this.container, "data-sortum-group"), this.shouldRemoveContainerClass && c(this.container, this.containerSelector.replace(/^\./, ""));
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
//#endregion
|
|
588
|
+
export { y };
|