wulf.js 2.1.1 → 2.2.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/README.md +217 -11
- package/changelog.md +50 -0
- package/dist/anchor.esm.js +9 -0
- package/dist/anchor.esm.js.map +7 -0
- package/dist/anchor.global.js +695 -0
- package/dist/anchor.global.js.map +7 -0
- package/dist/anchor.global.min.js +6 -0
- package/dist/anchor.global.min.js.map +7 -0
- package/dist/autosize.css +1 -0
- package/dist/autosize.css.map +7 -0
- package/dist/autosize.esm.js +10 -0
- package/dist/autosize.esm.js.map +7 -0
- package/dist/autosize.global.js +657 -0
- package/dist/autosize.global.js.map +7 -0
- package/dist/autosize.global.min.js +6 -0
- package/dist/autosize.global.min.js.map +7 -0
- package/dist/autosize.layered.css +1 -0
- package/dist/autosize.layered.css.map +7 -0
- package/dist/chunks/chunk-22AIMRD5.js +119 -0
- package/dist/chunks/chunk-22AIMRD5.js.map +7 -0
- package/dist/chunks/chunk-5N2IRGDM.js +766 -0
- package/dist/chunks/chunk-5N2IRGDM.js.map +7 -0
- package/dist/chunks/chunk-72FVCNNZ.js +863 -0
- package/dist/chunks/chunk-72FVCNNZ.js.map +7 -0
- package/dist/chunks/chunk-AXZYYW7H.js +865 -0
- package/dist/chunks/chunk-AXZYYW7H.js.map +7 -0
- package/dist/chunks/chunk-CM3SBIVQ.js +1116 -0
- package/dist/chunks/chunk-CM3SBIVQ.js.map +7 -0
- package/dist/chunks/chunk-H4GRLGQ3.js +578 -0
- package/dist/chunks/chunk-H4GRLGQ3.js.map +7 -0
- package/dist/chunks/chunk-ITRU2RFV.js +1195 -0
- package/dist/chunks/chunk-ITRU2RFV.js.map +7 -0
- package/dist/chunks/chunk-NLUQZEL4.js +1029 -0
- package/dist/chunks/chunk-NLUQZEL4.js.map +7 -0
- package/dist/chunks/chunk-QV46A7FV.js +197 -0
- package/dist/chunks/chunk-QV46A7FV.js.map +7 -0
- package/dist/chunks/chunk-SXLUXN6W.js +612 -0
- package/dist/chunks/chunk-SXLUXN6W.js.map +7 -0
- package/dist/chunks/chunk-T2H4EJCW.js +621 -0
- package/dist/chunks/chunk-T2H4EJCW.js.map +7 -0
- package/dist/chunks/chunk-TILLYEF2.js +6044 -0
- package/dist/chunks/chunk-TILLYEF2.js.map +7 -0
- package/dist/chunks/chunk-VJO22BAT.js +72 -0
- package/dist/chunks/chunk-VJO22BAT.js.map +7 -0
- package/dist/chunks/chunk-ZGUU6DMM.js +77 -0
- package/dist/chunks/chunk-ZGUU6DMM.js.map +7 -0
- package/dist/focus-trap.esm.js +6 -594
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +176 -61
- package/dist/focus-trap.global.js.map +3 -3
- package/dist/focus-trap.global.min.js +4 -4
- package/dist/focus-trap.global.min.js.map +4 -4
- package/dist/index.esm.js +79 -10448
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +3660 -202
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +6 -3
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.esm.js +16 -6094
- package/dist/mask.esm.js.map +4 -4
- package/dist/mask.global.js +44 -55
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +3 -3
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.esm.js +15 -1158
- package/dist/masonry.esm.js.map +4 -4
- package/dist/masonry.global.js +84 -94
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -4
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +14 -1252
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +64 -58
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +3 -3
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/scroll.layered.css +1 -1
- package/dist/scroll.layered.css.map +2 -2
- package/dist/shortcut.esm.js +6 -901
- package/dist/shortcut.esm.js.map +4 -4
- package/dist/shortcut.global.js +43 -36
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +6 -3
- package/dist/shortcut.global.min.js.map +4 -4
- package/dist/size-report.json +319 -0
- package/dist/sortable.css +1 -0
- package/dist/sortable.css.map +7 -0
- package/dist/sortable.esm.js +22 -0
- package/dist/sortable.esm.js.map +7 -0
- package/dist/sortable.global.js +1477 -0
- package/dist/sortable.global.js.map +7 -0
- package/dist/sortable.global.min.js +6 -0
- package/dist/sortable.global.min.js.map +7 -0
- package/dist/sortable.layered.css +1 -0
- package/dist/sortable.layered.css.map +7 -0
- package/dist/sri-manifest.json +64 -0
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +19 -1208
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +314 -111
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +3 -3
- package/dist/toast.global.min.js.map +4 -4
- package/dist/toast.layered.css +1 -1
- package/dist/toast.layered.css.map +2 -2
- package/dist/types/anchor/Anchor.d.ts +41 -0
- package/dist/types/anchor/index.d.ts +3 -0
- package/dist/types/anchor/types.d.ts +115 -0
- package/dist/types/autosize/Autosize.d.ts +71 -0
- package/dist/types/autosize/index.d.ts +3 -0
- package/dist/types/autosize/types.d.ts +66 -0
- package/dist/types/common/AuditableComponent.d.ts +1 -1
- package/dist/types/common/registry.d.ts +40 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +3 -1
- package/dist/types/index.d.ts +13 -1
- package/dist/types/scroll/types.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +2 -0
- package/dist/types/shortcut/types.d.ts +5 -0
- package/dist/types/sortable/Sortable.d.ts +75 -0
- package/dist/types/sortable/i18n/en.d.ts +2 -0
- package/dist/types/sortable/i18n/fr.d.ts +2 -0
- package/dist/types/sortable/i18n/index.d.ts +9 -0
- package/dist/types/sortable/i18n/types.d.ts +15 -0
- package/dist/types/sortable/index.d.ts +4 -0
- package/dist/types/sortable/types.d.ts +112 -0
- package/dist/types/toast/Toast.d.ts +6 -1
- package/dist/types/toast/ToastInstance.d.ts +7 -0
- package/dist/types/toast/ToastManager.d.ts +2 -2
- package/dist/types/toast/types.d.ts +27 -1
- package/dist/types/undo/UndoManager.d.ts +112 -0
- package/dist/types/undo/i18n/en.d.ts +2 -0
- package/dist/types/undo/i18n/fr.d.ts +2 -0
- package/dist/types/undo/i18n/index.d.ts +9 -0
- package/dist/types/undo/i18n/types.d.ts +6 -0
- package/dist/types/undo/index.d.ts +5 -0
- package/dist/types/undo/types.d.ts +106 -0
- package/dist/undo.esm.js +23 -0
- package/dist/undo.esm.js.map +7 -0
- package/dist/undo.global.js +1029 -0
- package/dist/undo.global.js.map +7 -0
- package/dist/undo.global.min.js +6 -0
- package/dist/undo.global.min.js.map +7 -0
- package/package.json +54 -5
|
@@ -0,0 +1,1477 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __WulfIIFE = (() => {
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/sortable/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
LocalizedComponent: () => LocalizedComponent,
|
|
25
|
+
Sortable: () => Sortable,
|
|
26
|
+
createI18nManager: () => createI18nManager,
|
|
27
|
+
default: () => Sortable,
|
|
28
|
+
sortableEn: () => sortableEn,
|
|
29
|
+
sortableFr: () => sortableFr,
|
|
30
|
+
sortableI18n: () => sortableI18n
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// src/common/i18n.ts
|
|
34
|
+
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
35
|
+
function isSafeKey(key) {
|
|
36
|
+
return Boolean(key) && !FORBIDDEN_KEYS.has(key);
|
|
37
|
+
}
|
|
38
|
+
function normalizeLocaleCode(locale) {
|
|
39
|
+
const norm = String(locale ?? "").trim().toLowerCase().replace(/_/g, "-");
|
|
40
|
+
return isSafeKey(norm) ? norm : "";
|
|
41
|
+
}
|
|
42
|
+
function getPrimaryLanguage(normalizedLocale) {
|
|
43
|
+
const dashIndex = normalizedLocale.indexOf("-");
|
|
44
|
+
const primary = dashIndex > 0 ? normalizedLocale.slice(0, dashIndex) : null;
|
|
45
|
+
return primary && isSafeKey(primary) ? primary : null;
|
|
46
|
+
}
|
|
47
|
+
function assignDefined(target, source) {
|
|
48
|
+
if (!source || typeof source !== "object") return target;
|
|
49
|
+
for (const key of Object.keys(source)) {
|
|
50
|
+
if (isSafeKey(String(key)) && Object.hasOwn(source, key) && source[key] !== void 0) {
|
|
51
|
+
target[key] = source[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return target;
|
|
55
|
+
}
|
|
56
|
+
function createI18nManager(defaultLocale, locales) {
|
|
57
|
+
const fallbackLocale = normalizeLocaleCode(defaultLocale) || "fr";
|
|
58
|
+
const initialLocales = /* @__PURE__ */ Object.create(null);
|
|
59
|
+
for (const [loc, dict] of Object.entries(locales)) {
|
|
60
|
+
const norm = normalizeLocaleCode(loc);
|
|
61
|
+
if (norm) {
|
|
62
|
+
initialLocales[norm] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let currentLocale = fallbackLocale;
|
|
66
|
+
let activeLocales = /* @__PURE__ */ Object.create(null);
|
|
67
|
+
for (const [loc, dict] of Object.entries(initialLocales)) {
|
|
68
|
+
activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
|
|
69
|
+
}
|
|
70
|
+
let globalOverrides = /* @__PURE__ */ Object.create(null);
|
|
71
|
+
function resolveActiveDictionaries() {
|
|
72
|
+
const dicts = [];
|
|
73
|
+
if (isSafeKey(currentLocale)) {
|
|
74
|
+
const exact = activeLocales[currentLocale];
|
|
75
|
+
if (exact) dicts.push(exact);
|
|
76
|
+
}
|
|
77
|
+
const primary = getPrimaryLanguage(currentLocale);
|
|
78
|
+
if (primary && activeLocales[primary]) {
|
|
79
|
+
dicts.push(activeLocales[primary]);
|
|
80
|
+
}
|
|
81
|
+
return dicts;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
setLocale(locale) {
|
|
85
|
+
if (locale && typeof locale === "string" && locale.trim()) {
|
|
86
|
+
const norm = normalizeLocaleCode(locale);
|
|
87
|
+
if (norm) {
|
|
88
|
+
currentLocale = norm;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
getLocale() {
|
|
93
|
+
return currentLocale;
|
|
94
|
+
},
|
|
95
|
+
registerLocale(locale, translations) {
|
|
96
|
+
if (!locale || typeof locale !== "string" || !locale.trim() || !translations) return;
|
|
97
|
+
const norm = normalizeLocaleCode(locale);
|
|
98
|
+
if (!norm) return;
|
|
99
|
+
const base = assignDefined(/* @__PURE__ */ Object.create(null), activeLocales[norm]);
|
|
100
|
+
activeLocales[norm] = assignDefined(base, translations);
|
|
101
|
+
},
|
|
102
|
+
setI18n(overrides) {
|
|
103
|
+
if (!overrides || typeof overrides !== "object") return;
|
|
104
|
+
const base = assignDefined(/* @__PURE__ */ Object.create(null), globalOverrides);
|
|
105
|
+
globalOverrides = assignDefined(base, overrides);
|
|
106
|
+
},
|
|
107
|
+
t(key, instanceOverride) {
|
|
108
|
+
if (!isSafeKey(String(key))) {
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
111
|
+
if (instanceOverride && typeof instanceOverride === "object" && Object.hasOwn(instanceOverride, key) && instanceOverride[key] !== void 0) {
|
|
112
|
+
return String(instanceOverride[key]);
|
|
113
|
+
}
|
|
114
|
+
if (globalOverrides[key] !== void 0) {
|
|
115
|
+
return String(globalOverrides[key]);
|
|
116
|
+
}
|
|
117
|
+
for (const dict of resolveActiveDictionaries()) {
|
|
118
|
+
if (dict[key] !== void 0) {
|
|
119
|
+
return String(dict[key]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const fallbackDict = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
|
|
123
|
+
if (fallbackDict && fallbackDict[key] !== void 0) {
|
|
124
|
+
return String(fallbackDict[key]);
|
|
125
|
+
}
|
|
126
|
+
return String(key);
|
|
127
|
+
},
|
|
128
|
+
getAll(instanceOverride) {
|
|
129
|
+
const result = {};
|
|
130
|
+
const fallback = activeLocales[fallbackLocale] || initialLocales[fallbackLocale];
|
|
131
|
+
assignDefined(result, fallback);
|
|
132
|
+
const activeDicts = resolveActiveDictionaries().reverse();
|
|
133
|
+
for (const dict of activeDicts) {
|
|
134
|
+
assignDefined(result, dict);
|
|
135
|
+
}
|
|
136
|
+
assignDefined(result, globalOverrides);
|
|
137
|
+
assignDefined(result, instanceOverride);
|
|
138
|
+
return result;
|
|
139
|
+
},
|
|
140
|
+
reset() {
|
|
141
|
+
currentLocale = fallbackLocale;
|
|
142
|
+
globalOverrides = /* @__PURE__ */ Object.create(null);
|
|
143
|
+
activeLocales = /* @__PURE__ */ Object.create(null);
|
|
144
|
+
for (const [loc, dict] of Object.entries(initialLocales)) {
|
|
145
|
+
activeLocales[loc] = assignDefined(/* @__PURE__ */ Object.create(null), dict);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/common/AuditableComponent.ts
|
|
152
|
+
var AuditableComponent = class {
|
|
153
|
+
/**
|
|
154
|
+
* Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
|
|
155
|
+
*/
|
|
156
|
+
getAuditDisableHint() {
|
|
157
|
+
return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
|
|
161
|
+
* si l'audit est activé et que des contraintes manquent.
|
|
162
|
+
*/
|
|
163
|
+
runAuditWarning(enabled = true) {
|
|
164
|
+
if (!enabled) return [];
|
|
165
|
+
const warnings = this.audit();
|
|
166
|
+
if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
|
|
167
|
+
console.warn(
|
|
168
|
+
`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
169
|
+
` + warnings.map((w) => ` - ${w}`).join("\n") + `
|
|
170
|
+
(${this.getAuditDisableHint()})`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return warnings;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
|
|
177
|
+
* pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
|
|
178
|
+
*/
|
|
179
|
+
checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
|
|
180
|
+
const rawValue = element.getAttribute(attrName)?.trim();
|
|
181
|
+
if (!rawValue) return false;
|
|
182
|
+
const doc = element.ownerDocument || document;
|
|
183
|
+
const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
|
|
184
|
+
const ids = rawValue.split(/\s+/).filter(Boolean);
|
|
185
|
+
const targets = ids.map(
|
|
186
|
+
(id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
|
|
187
|
+
);
|
|
188
|
+
const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
|
|
189
|
+
if (!allFound) {
|
|
190
|
+
warnings.push(
|
|
191
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
|
|
192
|
+
);
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
if (requireNonEmptyText) {
|
|
196
|
+
const hasNonEmptyText = targets.some((el) => {
|
|
197
|
+
if (!el) return false;
|
|
198
|
+
const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
|
|
199
|
+
return text.length > 0;
|
|
200
|
+
});
|
|
201
|
+
if (!hasNonEmptyText) {
|
|
202
|
+
warnings.push(
|
|
203
|
+
`Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
|
|
204
|
+
);
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/common/LocalizedComponent.ts
|
|
213
|
+
var LocalizedComponent = class extends AuditableComponent {
|
|
214
|
+
static _i18n;
|
|
215
|
+
/**
|
|
216
|
+
* Définit la langue globale du composant (ex: 'fr', 'en', 'es').
|
|
217
|
+
*/
|
|
218
|
+
static setLocale(locale) {
|
|
219
|
+
if (this._i18n) {
|
|
220
|
+
this._i18n.setLocale(locale);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Retourne la langue globale active du composant.
|
|
225
|
+
*/
|
|
226
|
+
static getLocale() {
|
|
227
|
+
return this._i18n ? this._i18n.getLocale() : "";
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Enregistre un dictionnaire de traduction pour une langue donnée.
|
|
231
|
+
*/
|
|
232
|
+
static registerLocale(locale, translations) {
|
|
233
|
+
if (this._i18n) {
|
|
234
|
+
this._i18n.registerLocale(locale, translations);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Surcharge les libellés globalement pour ce composant.
|
|
239
|
+
*/
|
|
240
|
+
static setI18n(overrides) {
|
|
241
|
+
if (this._i18n) {
|
|
242
|
+
this._i18n.setI18n(overrides);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Retourne l'ensemble des libellés actifs résolus du composant.
|
|
247
|
+
*/
|
|
248
|
+
static getI18n() {
|
|
249
|
+
return this._i18n ? this._i18n.getAll() : {};
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Réinitialise les réglages de langue et surcharges globales.
|
|
253
|
+
*/
|
|
254
|
+
static resetI18n() {
|
|
255
|
+
if (this._i18n) {
|
|
256
|
+
this._i18n.reset();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Résout une clé au niveau statique de la classe.
|
|
261
|
+
*/
|
|
262
|
+
static t(key, instanceOverride) {
|
|
263
|
+
return this._i18n ? this._i18n.t(key, instanceOverride) : String(key);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Surcharges de localisation spécifiques à cette instance.
|
|
267
|
+
*/
|
|
268
|
+
i18nOverrides;
|
|
269
|
+
constructor(i18nOverrides) {
|
|
270
|
+
super();
|
|
271
|
+
this.i18nOverrides = i18nOverrides;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Traduit une clé en tenant compte automatiquement des surcharges de l'instance courante.
|
|
275
|
+
*/
|
|
276
|
+
t(key) {
|
|
277
|
+
const ctor = this.constructor;
|
|
278
|
+
return ctor._i18n ? ctor._i18n.t(key, this.i18nOverrides) : String(key);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// src/sortable/i18n/fr.ts
|
|
283
|
+
var sortableFr = {
|
|
284
|
+
grabbed: (label, position, total) => `${label} saisi en position ${position} sur ${total}. Utilisez les fl\xE8ches pour d\xE9placer, Entr\xE9e ou Espace pour d\xE9poser, \xC9chap pour annuler.`,
|
|
285
|
+
moved: (label, position, total) => `${label} d\xE9plac\xE9 en position ${position} sur ${total}.`,
|
|
286
|
+
dropped: (label, position, total) => `${label} d\xE9pos\xE9 en position ${position} sur ${total}.`,
|
|
287
|
+
cancelled: (label, position, total) => `D\xE9placement annul\xE9. ${label} replac\xE9 en position ${position} sur ${total}.`,
|
|
288
|
+
defaultItemLabel: (position) => `\xC9l\xE9ment ${position}`
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// src/sortable/i18n/en.ts
|
|
292
|
+
var sortableEn = {
|
|
293
|
+
grabbed: (label, position, total) => `${label} grabbed at position ${position} of ${total}. Use arrow keys to move, Enter or Space to drop, Escape to cancel.`,
|
|
294
|
+
moved: (label, position, total) => `${label} moved to position ${position} of ${total}.`,
|
|
295
|
+
dropped: (label, position, total) => `${label} dropped at position ${position} of ${total}.`,
|
|
296
|
+
cancelled: (label, position, total) => `Reordering cancelled. ${label} returned to position ${position} of ${total}.`,
|
|
297
|
+
defaultItemLabel: (position) => `Item ${position}`
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/sortable/i18n/index.ts
|
|
301
|
+
var sortableI18n = createI18nManager("fr", {
|
|
302
|
+
fr: sortableFr,
|
|
303
|
+
en: sortableEn
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// src/common/dom.ts
|
|
307
|
+
function stripBidiAndInvisibles(raw, maxLength = 4096) {
|
|
308
|
+
const safeLimit = Math.max(0, maxLength);
|
|
309
|
+
return String(raw ?? "").slice(0, safeLimit).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
|
|
310
|
+
}
|
|
311
|
+
function getDeepActiveElement(root) {
|
|
312
|
+
if (typeof document === "undefined") return null;
|
|
313
|
+
let active = (root ?? document).activeElement;
|
|
314
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
315
|
+
active = active.shadowRoot.activeElement;
|
|
316
|
+
}
|
|
317
|
+
return active && typeof active.focus === "function" ? active : null;
|
|
318
|
+
}
|
|
319
|
+
function safeMove(parent, node, referenceNode = null) {
|
|
320
|
+
const moveBefore = parent.moveBefore;
|
|
321
|
+
if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
|
|
322
|
+
try {
|
|
323
|
+
moveBefore.call(parent, node, referenceNode);
|
|
324
|
+
return;
|
|
325
|
+
} catch {
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
parent.insertBefore(node, referenceNode);
|
|
329
|
+
}
|
|
330
|
+
function isImeComposing(event) {
|
|
331
|
+
return Boolean(
|
|
332
|
+
event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
function prefersReducedMotion() {
|
|
336
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/sortable/Sortable.ts
|
|
340
|
+
var INTERACTIVE_DESCENDANT_SELECTOR = 'input, textarea, select, button, a[href], label, [contenteditable], [role="button"], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"], [role="slider"]';
|
|
341
|
+
var NATIVELY_FOCUSABLE_SELECTOR = "button, a[href], input, select, textarea, summary, [tabindex]";
|
|
342
|
+
function clampNumber(value, fallback, min, max) {
|
|
343
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
|
344
|
+
return Math.min(max, Math.max(min, value));
|
|
345
|
+
}
|
|
346
|
+
function resolveContainer(target) {
|
|
347
|
+
if (typeof target === "string") {
|
|
348
|
+
if (!target) return null;
|
|
349
|
+
try {
|
|
350
|
+
return document.querySelector(target);
|
|
351
|
+
} catch {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (typeof HTMLElement !== "undefined" && target instanceof HTMLElement) {
|
|
356
|
+
return target;
|
|
357
|
+
}
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
function isEditableTarget(target) {
|
|
361
|
+
if (!target || typeof target.tagName !== "string") return false;
|
|
362
|
+
const el = target;
|
|
363
|
+
const tag = el.tagName.toUpperCase();
|
|
364
|
+
if (tag === "INPUT") {
|
|
365
|
+
const type = el.type?.toLowerCase() || "text";
|
|
366
|
+
return !["button", "checkbox", "radio", "submit", "reset", "range", "color", "file", "image"].includes(type);
|
|
367
|
+
}
|
|
368
|
+
if (tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
369
|
+
const ce = el.getAttribute?.("contenteditable")?.toLowerCase();
|
|
370
|
+
if (el.isContentEditable || ce === "true" || ce === "plaintext-only" || ce === "") {
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
const role = el.getAttribute?.("role");
|
|
374
|
+
if (role === "textbox" || role === "searchbox" || role === "combobox" || role === "spinbutton") {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
return Boolean(
|
|
378
|
+
el.closest?.(
|
|
379
|
+
'[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'
|
|
380
|
+
)
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
function moveItemInDom(container, item, siblings, targetIndex) {
|
|
384
|
+
if (siblings.length === 0) return;
|
|
385
|
+
const clamped = Math.max(0, Math.min(targetIndex, siblings.length));
|
|
386
|
+
const referenceNode = clamped < siblings.length ? siblings[clamped] : siblings[siblings.length - 1].nextSibling;
|
|
387
|
+
if (item.nextSibling !== referenceNode) {
|
|
388
|
+
safeMove(container, item, referenceNode);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function computeReorderedArray(items, fromIndex, toIndex) {
|
|
392
|
+
const next = items.slice();
|
|
393
|
+
if (fromIndex < 0 || fromIndex >= next.length) return next;
|
|
394
|
+
const clampedTo = Math.max(0, Math.min(toIndex, next.length - 1));
|
|
395
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
396
|
+
next.splice(clampedTo, 0, moved);
|
|
397
|
+
return next;
|
|
398
|
+
}
|
|
399
|
+
var Sortable = class extends LocalizedComponent {
|
|
400
|
+
static _i18n = sortableI18n;
|
|
401
|
+
static i18n = sortableI18n;
|
|
402
|
+
container;
|
|
403
|
+
options;
|
|
404
|
+
isDestroyed = false;
|
|
405
|
+
isMovingFocus = false;
|
|
406
|
+
dragSessionSeq = 0;
|
|
407
|
+
rootAbort = new AbortController();
|
|
408
|
+
pointerDrag = null;
|
|
409
|
+
keyboardGrab = null;
|
|
410
|
+
hadRootClass = false;
|
|
411
|
+
savedAttributes = /* @__PURE__ */ new Map();
|
|
412
|
+
addedHandles = /* @__PURE__ */ new Set();
|
|
413
|
+
activeAnimations = /* @__PURE__ */ new WeakMap();
|
|
414
|
+
srStatusEl = null;
|
|
415
|
+
announceTimerId = null;
|
|
416
|
+
mutationObserver = null;
|
|
417
|
+
constructor(target, options = {}) {
|
|
418
|
+
super(options.i18n);
|
|
419
|
+
this.options = {
|
|
420
|
+
itemSelector: options.itemSelector,
|
|
421
|
+
handleSelector: options.handleSelector,
|
|
422
|
+
axis: options.axis ?? "y",
|
|
423
|
+
autoMove: options.autoMove ?? true,
|
|
424
|
+
threshold: clampNumber(options.threshold, 5, 0, 100),
|
|
425
|
+
animationDuration: clampNumber(options.animationDuration, 180, 0, 2e3),
|
|
426
|
+
autoScroll: options.autoScroll ?? true,
|
|
427
|
+
autoScrollSpeed: clampNumber(options.autoScrollSpeed, 12, 1, 30),
|
|
428
|
+
disabled: Boolean(options.disabled),
|
|
429
|
+
lang: options.lang,
|
|
430
|
+
getItemLabel: options.getItemLabel,
|
|
431
|
+
onStart: options.onStart,
|
|
432
|
+
onMove: options.onMove,
|
|
433
|
+
onReorder: options.onReorder,
|
|
434
|
+
onCancel: options.onCancel,
|
|
435
|
+
audit: options.audit ?? true
|
|
436
|
+
};
|
|
437
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
438
|
+
this.container = null;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const resolved = resolveContainer(target);
|
|
442
|
+
if (!resolved) {
|
|
443
|
+
throw new Error("[Wulf.Sortable] Conteneur HTMLElement ou s\xE9lecteur CSS valide requis.");
|
|
444
|
+
}
|
|
445
|
+
this.container = resolved;
|
|
446
|
+
this.hadRootClass = resolved.classList.contains("wulf-sortable");
|
|
447
|
+
resolved.classList.add("wulf-sortable");
|
|
448
|
+
this.mountStatusRegion();
|
|
449
|
+
this.refresh();
|
|
450
|
+
this.bindContainerEvents();
|
|
451
|
+
this.observeDomChanges();
|
|
452
|
+
this.runAuditWarning(this.options.audit);
|
|
453
|
+
}
|
|
454
|
+
getAuditPrefix() {
|
|
455
|
+
return "Wulf.Sortable";
|
|
456
|
+
}
|
|
457
|
+
getAuditTargetLabel() {
|
|
458
|
+
if (!this.container) return "<ssr>";
|
|
459
|
+
if (this.container.id) return `#${this.container.id}`;
|
|
460
|
+
return `<${this.container.tagName.toLowerCase()}>`;
|
|
461
|
+
}
|
|
462
|
+
getItems() {
|
|
463
|
+
if (!this.container || this.isDestroyed) return [];
|
|
464
|
+
if (this.options.itemSelector) {
|
|
465
|
+
try {
|
|
466
|
+
return Array.from(this.container.querySelectorAll(this.options.itemSelector)).filter(
|
|
467
|
+
(el) => !el.hasAttribute("data-wulf-sortable-ignore") && !el.classList.contains("wulf-sortable-sr-status")
|
|
468
|
+
);
|
|
469
|
+
} catch {
|
|
470
|
+
return [];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const result = [];
|
|
474
|
+
for (const child of Array.from(this.container.children)) {
|
|
475
|
+
if (typeof HTMLElement !== "undefined" && child instanceof HTMLElement && !child.hasAttribute("data-wulf-sortable-ignore") && !child.classList.contains("wulf-sortable-sr-status")) {
|
|
476
|
+
result.push(child);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return result;
|
|
480
|
+
}
|
|
481
|
+
isDisabled() {
|
|
482
|
+
return this.options.disabled;
|
|
483
|
+
}
|
|
484
|
+
isDragging() {
|
|
485
|
+
return Boolean(this.pointerDrag?.started || this.keyboardGrab);
|
|
486
|
+
}
|
|
487
|
+
setDisabled(disabled) {
|
|
488
|
+
const next = Boolean(disabled);
|
|
489
|
+
if (this.options.disabled === next) return;
|
|
490
|
+
this.options.disabled = next;
|
|
491
|
+
if (next) {
|
|
492
|
+
this.cancel();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
updateOptions(options) {
|
|
496
|
+
if (this.isDestroyed || !options) return;
|
|
497
|
+
if (options.i18n !== void 0) this.i18nOverrides = options.i18n;
|
|
498
|
+
if (options.itemSelector !== void 0) this.options.itemSelector = options.itemSelector;
|
|
499
|
+
if (options.handleSelector !== void 0) this.options.handleSelector = options.handleSelector;
|
|
500
|
+
if (options.axis !== void 0) this.options.axis = options.axis;
|
|
501
|
+
if (options.autoMove !== void 0) this.options.autoMove = Boolean(options.autoMove);
|
|
502
|
+
if (options.threshold !== void 0) {
|
|
503
|
+
this.options.threshold = clampNumber(options.threshold, 5, 0, 100);
|
|
504
|
+
}
|
|
505
|
+
if (options.animationDuration !== void 0) {
|
|
506
|
+
this.options.animationDuration = clampNumber(options.animationDuration, 180, 0, 2e3);
|
|
507
|
+
}
|
|
508
|
+
if (options.autoScroll !== void 0) this.options.autoScroll = Boolean(options.autoScroll);
|
|
509
|
+
if (options.autoScrollSpeed !== void 0) {
|
|
510
|
+
this.options.autoScrollSpeed = clampNumber(options.autoScrollSpeed, 12, 1, 30);
|
|
511
|
+
}
|
|
512
|
+
if (options.lang !== void 0) this.options.lang = options.lang;
|
|
513
|
+
if (options.getItemLabel !== void 0) this.options.getItemLabel = options.getItemLabel;
|
|
514
|
+
if (options.onStart !== void 0) this.options.onStart = options.onStart;
|
|
515
|
+
if (options.onMove !== void 0) this.options.onMove = options.onMove;
|
|
516
|
+
if (options.onReorder !== void 0) this.options.onReorder = options.onReorder;
|
|
517
|
+
if (options.onCancel !== void 0) this.options.onCancel = options.onCancel;
|
|
518
|
+
if (options.disabled !== void 0) this.setDisabled(options.disabled);
|
|
519
|
+
this.refresh();
|
|
520
|
+
}
|
|
521
|
+
refresh() {
|
|
522
|
+
if (!this.container || this.isDestroyed) return;
|
|
523
|
+
const items = this.getItems();
|
|
524
|
+
for (const item of items) {
|
|
525
|
+
const target = this.resolveTriggerForItem(item);
|
|
526
|
+
if (target) {
|
|
527
|
+
if (this.options.handleSelector && target !== item) {
|
|
528
|
+
target.classList.add("wulf-sortable-handle");
|
|
529
|
+
this.addedHandles.add(target);
|
|
530
|
+
}
|
|
531
|
+
if (!this.savedAttributes.has(target)) {
|
|
532
|
+
this.savedAttributes.set(target, {
|
|
533
|
+
hadTabIndex: target.hasAttribute("tabindex"),
|
|
534
|
+
prevTabIndex: target.getAttribute("tabindex"),
|
|
535
|
+
hadAriaPressed: target.hasAttribute("aria-pressed"),
|
|
536
|
+
prevAriaPressed: target.getAttribute("aria-pressed")
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
if (!target.matches(NATIVELY_FOCUSABLE_SELECTOR) && !target.hasAttribute("tabindex")) {
|
|
540
|
+
target.setAttribute("tabindex", "0");
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
move(fromIndex, toIndex) {
|
|
546
|
+
if (!this.container || this.isDestroyed) return false;
|
|
547
|
+
const items = this.getItems();
|
|
548
|
+
if (!Number.isInteger(fromIndex) || !Number.isInteger(toIndex) || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length || fromIndex === toIndex) {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
const item = items[fromIndex];
|
|
552
|
+
const siblings = items.filter((el) => el !== item);
|
|
553
|
+
const ordered = computeReorderedArray(items, fromIndex, toIndex);
|
|
554
|
+
if (this.options.autoMove) {
|
|
555
|
+
const beforeRects = this.snapshotRects(items);
|
|
556
|
+
moveItemInDom(this.container, item, siblings, toIndex);
|
|
557
|
+
this.animateFlip(items, beforeRects);
|
|
558
|
+
}
|
|
559
|
+
this.emitReorder({
|
|
560
|
+
item,
|
|
561
|
+
oldIndex: fromIndex,
|
|
562
|
+
newIndex: toIndex,
|
|
563
|
+
items: ordered,
|
|
564
|
+
trigger: "programmatic"
|
|
565
|
+
});
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
cancel() {
|
|
569
|
+
if (this.isDestroyed) return;
|
|
570
|
+
if (this.pointerDrag) {
|
|
571
|
+
this.endPointerDrag(true);
|
|
572
|
+
}
|
|
573
|
+
if (this.keyboardGrab) {
|
|
574
|
+
this.cancelKeyboardGrab();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
audit() {
|
|
578
|
+
if (!this.container || this.isDestroyed) return [];
|
|
579
|
+
const warnings = [];
|
|
580
|
+
const hasAriaLabel = Boolean(this.container.getAttribute("aria-label")?.trim());
|
|
581
|
+
const hasLabelledBy = this.checkAriaIdReferences(this.container, "aria-labelledby", warnings, true);
|
|
582
|
+
this.checkAriaIdReferences(this.container, "aria-describedby", warnings, true);
|
|
583
|
+
if (!hasAriaLabel && !hasLabelledBy) {
|
|
584
|
+
warnings.push(
|
|
585
|
+
"Aucun nom accessible d\xE9tect\xE9 sur le conteneur triable (ajoutez aria-label ou aria-labelledby)."
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
if (this.container.hasAttribute("aria-live")) {
|
|
589
|
+
warnings.push(
|
|
590
|
+
"\xC9vitez aria-live directement sur le conteneur triable (annoncez via une r\xE9gion status d\xE9di\xE9e ou ariaNotify)."
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
const items = this.getItems();
|
|
594
|
+
items.forEach((item, index) => {
|
|
595
|
+
const rawTab = item.getAttribute("tabindex");
|
|
596
|
+
if (rawTab !== null && Number.parseInt(rawTab, 10) > 0) {
|
|
597
|
+
warnings.push(
|
|
598
|
+
`\xC9vitez tabindex="${rawTab}" (> 0) sur l'\xE9l\xE9ment #${index + 1} pour pr\xE9server l'ordre de tabulation naturel.`
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
if (this.options.handleSelector) {
|
|
602
|
+
const handle = this.resolveTriggerForItem(item);
|
|
603
|
+
if (!handle || handle === item) {
|
|
604
|
+
warnings.push(`Poign\xE9e introuvable ("${this.options.handleSelector}") dans l'\xE9l\xE9ment #${index + 1}.`);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const hTab = handle.getAttribute("tabindex");
|
|
608
|
+
if (hTab !== null && Number.parseInt(hTab, 10) > 0) {
|
|
609
|
+
warnings.push(`\xC9vitez tabindex="${hTab}" (> 0) sur la poign\xE9e de l'\xE9l\xE9ment #${index + 1}.`);
|
|
610
|
+
}
|
|
611
|
+
const isFocusable = handle.matches("button:not([disabled]), a[href], input:not([disabled]), [tabindex]") && handle.getAttribute("tabindex") !== "-1";
|
|
612
|
+
if (!isFocusable) {
|
|
613
|
+
warnings.push(`La poign\xE9e de l'\xE9l\xE9ment #${index + 1} doit \xEAtre focusable au clavier.`);
|
|
614
|
+
}
|
|
615
|
+
const hLabel = handle.getAttribute("aria-label")?.trim() || handle.textContent?.trim() || "";
|
|
616
|
+
const hLabelledBy = this.checkAriaIdReferences(handle, "aria-labelledby", warnings, true);
|
|
617
|
+
if (!hLabel && !hLabelledBy) {
|
|
618
|
+
warnings.push(`La poign\xE9e de l'\xE9l\xE9ment #${index + 1} ne poss\xE8de aucun nom accessible.`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
return warnings;
|
|
623
|
+
}
|
|
624
|
+
destroy() {
|
|
625
|
+
if (this.isDestroyed) return;
|
|
626
|
+
this.isDestroyed = true;
|
|
627
|
+
this.cancel();
|
|
628
|
+
this.rootAbort.abort();
|
|
629
|
+
if (this.mutationObserver) {
|
|
630
|
+
this.mutationObserver.disconnect();
|
|
631
|
+
this.mutationObserver = null;
|
|
632
|
+
}
|
|
633
|
+
if (this.announceTimerId !== null) {
|
|
634
|
+
clearTimeout(this.announceTimerId);
|
|
635
|
+
this.announceTimerId = null;
|
|
636
|
+
}
|
|
637
|
+
if (this.srStatusEl) {
|
|
638
|
+
this.srStatusEl.remove();
|
|
639
|
+
this.srStatusEl = null;
|
|
640
|
+
}
|
|
641
|
+
if (this.container) {
|
|
642
|
+
this.clearDropMarker();
|
|
643
|
+
this.container.classList.remove("wulf-sortable--dragging");
|
|
644
|
+
if (!this.hadRootClass) {
|
|
645
|
+
this.container.classList.remove("wulf-sortable");
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
for (const handle of this.addedHandles) {
|
|
649
|
+
handle.classList.remove("wulf-sortable-handle");
|
|
650
|
+
}
|
|
651
|
+
this.addedHandles.clear();
|
|
652
|
+
for (const [el, saved] of this.savedAttributes.entries()) {
|
|
653
|
+
el.classList.remove("wulf-sortable-item--dragging", "wulf-sortable-item--grabbed");
|
|
654
|
+
el.removeAttribute("data-wulf-dragging");
|
|
655
|
+
el.removeAttribute("data-wulf-grabbed");
|
|
656
|
+
if (saved.hadTabIndex && saved.prevTabIndex !== null) {
|
|
657
|
+
el.setAttribute("tabindex", saved.prevTabIndex);
|
|
658
|
+
} else if (!saved.hadTabIndex) {
|
|
659
|
+
el.removeAttribute("tabindex");
|
|
660
|
+
}
|
|
661
|
+
if (saved.hadAriaPressed && saved.prevAriaPressed !== null) {
|
|
662
|
+
el.setAttribute("aria-pressed", saved.prevAriaPressed);
|
|
663
|
+
} else if (!saved.hadAriaPressed) {
|
|
664
|
+
el.removeAttribute("aria-pressed");
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
this.savedAttributes.clear();
|
|
668
|
+
}
|
|
669
|
+
resolveI18n() {
|
|
670
|
+
if (this.options.lang) {
|
|
671
|
+
const prev = sortableI18n.getLocale();
|
|
672
|
+
sortableI18n.setLocale(this.options.lang);
|
|
673
|
+
const dict = sortableI18n.getAll(this.i18nOverrides);
|
|
674
|
+
sortableI18n.setLocale(prev);
|
|
675
|
+
return dict;
|
|
676
|
+
}
|
|
677
|
+
return sortableI18n.getAll(this.i18nOverrides);
|
|
678
|
+
}
|
|
679
|
+
getItemLabelText(item, index) {
|
|
680
|
+
if (typeof this.options.getItemLabel === "function") {
|
|
681
|
+
try {
|
|
682
|
+
const custom = stripBidiAndInvisibles(this.options.getItemLabel(item, index), 200).trim();
|
|
683
|
+
if (custom) return custom;
|
|
684
|
+
} catch {
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
const raw = item.getAttribute("aria-label") || item.getAttribute("data-label") || item.textContent || "";
|
|
688
|
+
const clean = stripBidiAndInvisibles(raw, 200).replace(/\s+/g, " ").trim();
|
|
689
|
+
if (clean) return clean.slice(0, 80);
|
|
690
|
+
return this.resolveI18n().defaultItemLabel(index + 1);
|
|
691
|
+
}
|
|
692
|
+
mountStatusRegion() {
|
|
693
|
+
if (!this.container || typeof document === "undefined") return;
|
|
694
|
+
if (typeof document.ariaNotify === "function") {
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
const status = document.createElement("div");
|
|
698
|
+
status.className = "wulf-sortable-sr-status";
|
|
699
|
+
status.setAttribute("role", "status");
|
|
700
|
+
status.setAttribute("aria-live", "polite");
|
|
701
|
+
status.setAttribute("aria-atomic", "true");
|
|
702
|
+
status.setAttribute("data-wulf-sortable-ignore", "true");
|
|
703
|
+
const root = typeof this.container.getRootNode === "function" ? this.container.getRootNode() : document;
|
|
704
|
+
const mountTarget = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : document.body || this.container;
|
|
705
|
+
mountTarget.appendChild(status);
|
|
706
|
+
this.srStatusEl = status;
|
|
707
|
+
}
|
|
708
|
+
announce(message) {
|
|
709
|
+
if (this.isDestroyed || typeof document === "undefined") return;
|
|
710
|
+
const clean = stripBidiAndInvisibles(message, 400).trim();
|
|
711
|
+
if (!clean) return;
|
|
712
|
+
const docWithNotify = document;
|
|
713
|
+
if (typeof docWithNotify.ariaNotify === "function") {
|
|
714
|
+
try {
|
|
715
|
+
docWithNotify.ariaNotify(clean, { priority: "normal" });
|
|
716
|
+
return;
|
|
717
|
+
} catch {
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (!this.srStatusEl) {
|
|
721
|
+
this.mountStatusRegion();
|
|
722
|
+
}
|
|
723
|
+
if (!this.srStatusEl) return;
|
|
724
|
+
if (this.announceTimerId !== null) {
|
|
725
|
+
clearTimeout(this.announceTimerId);
|
|
726
|
+
this.announceTimerId = null;
|
|
727
|
+
}
|
|
728
|
+
this.srStatusEl.textContent = "";
|
|
729
|
+
this.announceTimerId = setTimeout(() => {
|
|
730
|
+
this.announceTimerId = null;
|
|
731
|
+
if (!this.isDestroyed && this.srStatusEl) {
|
|
732
|
+
this.srStatusEl.textContent = clean;
|
|
733
|
+
}
|
|
734
|
+
}, 40);
|
|
735
|
+
}
|
|
736
|
+
resolveTriggerForItem(item) {
|
|
737
|
+
if (!this.options.handleSelector) return item;
|
|
738
|
+
try {
|
|
739
|
+
const handle = item.querySelector(this.options.handleSelector);
|
|
740
|
+
return handle ?? null;
|
|
741
|
+
} catch {
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
findItemForEvent(event) {
|
|
746
|
+
if (!this.container) return null;
|
|
747
|
+
const items = this.getItems();
|
|
748
|
+
if (items.length === 0) return null;
|
|
749
|
+
const itemSet = new Set(items);
|
|
750
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [event.target];
|
|
751
|
+
for (const node of path) {
|
|
752
|
+
if (node && itemSet.has(node)) {
|
|
753
|
+
return node;
|
|
754
|
+
}
|
|
755
|
+
if (node === this.container) break;
|
|
756
|
+
}
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
hasInteractiveDescendantBeforeItem(event, item) {
|
|
760
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [event.target];
|
|
761
|
+
for (const node of path) {
|
|
762
|
+
if (!node || node === item) break;
|
|
763
|
+
if (typeof Element !== "undefined" && node instanceof Element) {
|
|
764
|
+
if (isEditableTarget(node) || node.matches(INTERACTIVE_DESCENDANT_SELECTOR)) {
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
findHandleInPath(event, item) {
|
|
772
|
+
if (!this.options.handleSelector) return item;
|
|
773
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [event.target];
|
|
774
|
+
for (const node of path) {
|
|
775
|
+
if (!node) continue;
|
|
776
|
+
if (typeof HTMLElement !== "undefined" && node instanceof HTMLElement) {
|
|
777
|
+
try {
|
|
778
|
+
if (node.matches(this.options.handleSelector) && item.contains(node)) {
|
|
779
|
+
if (node.hasAttribute("disabled") || node.getAttribute("aria-disabled") === "true") {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
return node;
|
|
783
|
+
}
|
|
784
|
+
} catch {
|
|
785
|
+
return null;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (node === item) break;
|
|
789
|
+
}
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
bindContainerEvents() {
|
|
793
|
+
if (!this.container) return;
|
|
794
|
+
const signal = this.rootAbort.signal;
|
|
795
|
+
this.container.addEventListener("pointerdown", (e) => this.handlePointerDown(e), { signal });
|
|
796
|
+
this.container.addEventListener("keydown", (e) => this.handleKeyDown(e), { signal });
|
|
797
|
+
this.container.addEventListener("focusout", (e) => this.handleFocusOut(e), { signal });
|
|
798
|
+
this.container.addEventListener("focusin", (e) => this.handleFocusIn(e), { signal });
|
|
799
|
+
}
|
|
800
|
+
observeDomChanges() {
|
|
801
|
+
if (!this.container || typeof MutationObserver === "undefined") return;
|
|
802
|
+
this.mutationObserver = new MutationObserver(() => {
|
|
803
|
+
if (!this.isDestroyed && !this.pointerDrag?.started) {
|
|
804
|
+
this.refresh();
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
this.mutationObserver.observe(this.container, { childList: true });
|
|
808
|
+
}
|
|
809
|
+
handleFocusIn(event) {
|
|
810
|
+
if (!this.container || this.isDestroyed) return;
|
|
811
|
+
const target = event.target;
|
|
812
|
+
if (!target || typeof target.matches !== "function") return;
|
|
813
|
+
let isFocusVisible = false;
|
|
814
|
+
try {
|
|
815
|
+
isFocusVisible = target.matches(":focus-visible");
|
|
816
|
+
} catch {
|
|
817
|
+
isFocusVisible = false;
|
|
818
|
+
}
|
|
819
|
+
if (!isFocusVisible) return;
|
|
820
|
+
const item = this.findItemForEvent(event);
|
|
821
|
+
if (!item || typeof item.scrollIntoView !== "function") return;
|
|
822
|
+
const running = typeof item.getAnimations === "function" && item.getAnimations().some((a) => a.playState === "running");
|
|
823
|
+
if (!running) {
|
|
824
|
+
item.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
handlePointerDown(event) {
|
|
828
|
+
if (!this.container || this.isDestroyed || this.options.disabled) return;
|
|
829
|
+
if (this.pointerDrag || event.button !== 0 || event.isPrimary === false) return;
|
|
830
|
+
if (isEditableTarget(event.target)) return;
|
|
831
|
+
const item = this.findItemForEvent(event);
|
|
832
|
+
if (!item) return;
|
|
833
|
+
let handle = item;
|
|
834
|
+
if (this.options.handleSelector) {
|
|
835
|
+
handle = this.findHandleInPath(event, item);
|
|
836
|
+
if (!handle) return;
|
|
837
|
+
} else if (this.hasInteractiveDescendantBeforeItem(event, item)) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (this.keyboardGrab) {
|
|
841
|
+
this.commitKeyboardGrab();
|
|
842
|
+
}
|
|
843
|
+
const items = this.getItems();
|
|
844
|
+
const oldIndex = items.indexOf(item);
|
|
845
|
+
if (oldIndex === -1 || items.length < 2) return;
|
|
846
|
+
const siblings = items.filter((el) => el !== item);
|
|
847
|
+
const dragAbort = new AbortController();
|
|
848
|
+
this.pointerDrag = {
|
|
849
|
+
sessionId: ++this.dragSessionSeq,
|
|
850
|
+
pointerId: event.pointerId,
|
|
851
|
+
item,
|
|
852
|
+
handle,
|
|
853
|
+
oldIndex,
|
|
854
|
+
targetIndex: oldIndex,
|
|
855
|
+
startX: event.clientX,
|
|
856
|
+
startY: event.clientY,
|
|
857
|
+
lastClientX: event.clientX,
|
|
858
|
+
lastClientY: event.clientY,
|
|
859
|
+
startScrollLeft: this.container.scrollLeft,
|
|
860
|
+
startScrollTop: this.container.scrollTop,
|
|
861
|
+
started: false,
|
|
862
|
+
prevTranslate: item.style.translate,
|
|
863
|
+
slotRect: item.getBoundingClientRect(),
|
|
864
|
+
siblings,
|
|
865
|
+
items,
|
|
866
|
+
abortController: dragAbort,
|
|
867
|
+
rafId: null,
|
|
868
|
+
lastFrameTime: typeof performance !== "undefined" ? performance.now() : Date.now()
|
|
869
|
+
};
|
|
870
|
+
const sig = dragAbort.signal;
|
|
871
|
+
document.addEventListener("pointermove", (e) => this.handlePointerMove(e), { signal: sig });
|
|
872
|
+
document.addEventListener("pointerup", (e) => this.handlePointerUp(e), { signal: sig });
|
|
873
|
+
document.addEventListener("pointercancel", (e) => this.handlePointerCancel(e), { signal: sig });
|
|
874
|
+
document.addEventListener("keydown", (e) => this.handlePointerEscape(e), { signal: sig });
|
|
875
|
+
if (this.options.threshold === 0) {
|
|
876
|
+
this.activatePointerDrag(this.pointerDrag);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
activatePointerDrag(drag) {
|
|
880
|
+
if (!this.container || drag.started) return;
|
|
881
|
+
drag.started = true;
|
|
882
|
+
const activeAnim = this.activeAnimations.get(drag.item);
|
|
883
|
+
if (activeAnim) {
|
|
884
|
+
try {
|
|
885
|
+
activeAnim.cancel();
|
|
886
|
+
} catch {
|
|
887
|
+
}
|
|
888
|
+
this.activeAnimations.delete(drag.item);
|
|
889
|
+
}
|
|
890
|
+
try {
|
|
891
|
+
drag.handle.setPointerCapture?.(drag.pointerId);
|
|
892
|
+
} catch {
|
|
893
|
+
}
|
|
894
|
+
drag.handle.addEventListener(
|
|
895
|
+
"lostpointercapture",
|
|
896
|
+
() => {
|
|
897
|
+
if (this.pointerDrag === drag && drag.started) {
|
|
898
|
+
this.endPointerDrag(true);
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
{ signal: drag.abortController.signal }
|
|
902
|
+
);
|
|
903
|
+
this.container.classList.add("wulf-sortable--dragging");
|
|
904
|
+
drag.item.classList.add("wulf-sortable-item--dragging");
|
|
905
|
+
drag.item.setAttribute("data-wulf-dragging", "true");
|
|
906
|
+
this.safeInvoke(this.options.onStart, {
|
|
907
|
+
item: drag.item,
|
|
908
|
+
index: drag.oldIndex,
|
|
909
|
+
trigger: "pointer"
|
|
910
|
+
});
|
|
911
|
+
if (this.options.autoScroll) {
|
|
912
|
+
this.startAutoScrollLoop(drag);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
handlePointerMove(event) {
|
|
916
|
+
const drag = this.pointerDrag;
|
|
917
|
+
if (!drag || event.pointerId !== drag.pointerId || !this.container) return;
|
|
918
|
+
drag.lastClientX = event.clientX;
|
|
919
|
+
drag.lastClientY = event.clientY;
|
|
920
|
+
if (!drag.started) {
|
|
921
|
+
const dist = Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY);
|
|
922
|
+
if (dist < this.options.threshold) return;
|
|
923
|
+
this.activatePointerDrag(drag);
|
|
924
|
+
}
|
|
925
|
+
this.updatePointerPosition(drag);
|
|
926
|
+
}
|
|
927
|
+
updatePointerPosition(drag) {
|
|
928
|
+
if (!this.container) return;
|
|
929
|
+
const axis = this.options.axis;
|
|
930
|
+
const scrollDx = this.container.scrollLeft - drag.startScrollLeft;
|
|
931
|
+
const scrollDy = this.container.scrollTop - drag.startScrollTop;
|
|
932
|
+
const tx = axis === "y" ? 0 : drag.lastClientX - drag.startX + scrollDx;
|
|
933
|
+
const ty = axis === "x" ? 0 : drag.lastClientY - drag.startY + scrollDy;
|
|
934
|
+
drag.item.style.translate = `${tx}px ${ty}px`;
|
|
935
|
+
const nextTarget = this.computePointerTargetIndex(drag, tx, ty);
|
|
936
|
+
this.updateDropMarker(drag, nextTarget);
|
|
937
|
+
if (nextTarget !== drag.targetIndex) {
|
|
938
|
+
const fromIndex = drag.targetIndex;
|
|
939
|
+
drag.targetIndex = nextTarget;
|
|
940
|
+
this.safeInvoke(this.options.onMove, {
|
|
941
|
+
item: drag.item,
|
|
942
|
+
oldIndex: drag.oldIndex,
|
|
943
|
+
fromIndex,
|
|
944
|
+
toIndex: nextTarget,
|
|
945
|
+
items: computeReorderedArray(drag.items, drag.oldIndex, nextTarget),
|
|
946
|
+
trigger: "pointer"
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
computePointerTargetIndex(drag, tx, ty) {
|
|
951
|
+
if (!this.container) return drag.oldIndex;
|
|
952
|
+
const axis = this.options.axis;
|
|
953
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
954
|
+
const isRtl = this.isRtl();
|
|
955
|
+
if (axis === "y") {
|
|
956
|
+
const py2 = Math.max(containerRect.top, Math.min(containerRect.bottom, drag.lastClientY));
|
|
957
|
+
let idx = 0;
|
|
958
|
+
for (const sibling of drag.siblings) {
|
|
959
|
+
const r = sibling.getBoundingClientRect();
|
|
960
|
+
if (r.top + r.height / 2 < py2) {
|
|
961
|
+
idx++;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return idx;
|
|
965
|
+
}
|
|
966
|
+
if (axis === "x") {
|
|
967
|
+
const px2 = Math.max(containerRect.left, Math.min(containerRect.right, drag.lastClientX));
|
|
968
|
+
let idx = 0;
|
|
969
|
+
for (const sibling of drag.siblings) {
|
|
970
|
+
const r = sibling.getBoundingClientRect();
|
|
971
|
+
const midX = r.left + r.width / 2;
|
|
972
|
+
if (isRtl ? midX > px2 : midX < px2) {
|
|
973
|
+
idx++;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
return idx;
|
|
977
|
+
}
|
|
978
|
+
const px = drag.lastClientX;
|
|
979
|
+
const py = drag.lastClientY;
|
|
980
|
+
let bestIdx = drag.oldIndex;
|
|
981
|
+
let bestDistSq = Number.POSITIVE_INFINITY;
|
|
982
|
+
for (let i = 0; i < drag.items.length; i++) {
|
|
983
|
+
const el = drag.items[i];
|
|
984
|
+
let r = el.getBoundingClientRect();
|
|
985
|
+
if (el === drag.item) {
|
|
986
|
+
r = new DOMRect(r.left - tx, r.top - ty, r.width, r.height);
|
|
987
|
+
}
|
|
988
|
+
if (px >= r.left && px <= r.right && py >= r.top && py <= r.bottom) {
|
|
989
|
+
return i;
|
|
990
|
+
}
|
|
991
|
+
const cx = r.left + r.width / 2;
|
|
992
|
+
const cy = r.top + r.height / 2;
|
|
993
|
+
const dSq = (px - cx) * (px - cx) + (py - cy) * (py - cy);
|
|
994
|
+
if (dSq < bestDistSq) {
|
|
995
|
+
bestDistSq = dSq;
|
|
996
|
+
bestIdx = i;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return bestIdx;
|
|
1000
|
+
}
|
|
1001
|
+
updateDropMarker(drag, targetIndex) {
|
|
1002
|
+
if (!this.container) return;
|
|
1003
|
+
if (targetIndex === drag.oldIndex || drag.siblings.length === 0) {
|
|
1004
|
+
this.clearDropMarker();
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
const axis = this.options.axis;
|
|
1008
|
+
this.container.setAttribute("data-wulf-drop", axis);
|
|
1009
|
+
const size = 3;
|
|
1010
|
+
if (axis === "both") {
|
|
1011
|
+
const targetSlotEl = drag.items[targetIndex];
|
|
1012
|
+
if (targetSlotEl) {
|
|
1013
|
+
const r = targetSlotEl.getBoundingClientRect();
|
|
1014
|
+
this.setDropMarkerVars(r.left, r.top, r.width, r.height);
|
|
1015
|
+
}
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
const sibs = drag.siblings;
|
|
1019
|
+
const refRect = sibs[Math.min(targetIndex, sibs.length - 1)].getBoundingClientRect();
|
|
1020
|
+
if (axis === "y") {
|
|
1021
|
+
let y;
|
|
1022
|
+
if (targetIndex === 0) {
|
|
1023
|
+
y = sibs[0].getBoundingClientRect().top - size;
|
|
1024
|
+
} else if (targetIndex >= sibs.length) {
|
|
1025
|
+
y = sibs[sibs.length - 1].getBoundingClientRect().bottom;
|
|
1026
|
+
} else {
|
|
1027
|
+
const prevR = sibs[targetIndex - 1].getBoundingClientRect();
|
|
1028
|
+
const nextR = sibs[targetIndex].getBoundingClientRect();
|
|
1029
|
+
y = (prevR.bottom + nextR.top - size) / 2;
|
|
1030
|
+
}
|
|
1031
|
+
this.setDropMarkerVars(refRect.left, y, refRect.width, size);
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
const isRtl = this.isRtl();
|
|
1035
|
+
let x;
|
|
1036
|
+
if (targetIndex === 0) {
|
|
1037
|
+
const firstR = sibs[0].getBoundingClientRect();
|
|
1038
|
+
x = isRtl ? firstR.right : firstR.left - size;
|
|
1039
|
+
} else if (targetIndex >= sibs.length) {
|
|
1040
|
+
const lastR = sibs[sibs.length - 1].getBoundingClientRect();
|
|
1041
|
+
x = isRtl ? lastR.left - size : lastR.right;
|
|
1042
|
+
} else {
|
|
1043
|
+
const prevR = sibs[targetIndex - 1].getBoundingClientRect();
|
|
1044
|
+
const nextR = sibs[targetIndex].getBoundingClientRect();
|
|
1045
|
+
x = isRtl ? (nextR.right + prevR.left - size) / 2 : (prevR.right + nextR.left - size) / 2;
|
|
1046
|
+
}
|
|
1047
|
+
this.setDropMarkerVars(x, refRect.top, size, refRect.height);
|
|
1048
|
+
}
|
|
1049
|
+
setDropMarkerVars(x, y, w, h) {
|
|
1050
|
+
if (!this.container) return;
|
|
1051
|
+
this.container.style.setProperty("--wulf-drop-x", `${Math.round(x)}px`);
|
|
1052
|
+
this.container.style.setProperty("--wulf-drop-y", `${Math.round(y)}px`);
|
|
1053
|
+
this.container.style.setProperty("--wulf-drop-w", `${Math.max(1, Math.round(w))}px`);
|
|
1054
|
+
this.container.style.setProperty("--wulf-drop-h", `${Math.max(1, Math.round(h))}px`);
|
|
1055
|
+
}
|
|
1056
|
+
clearDropMarker() {
|
|
1057
|
+
if (!this.container) return;
|
|
1058
|
+
this.container.removeAttribute("data-wulf-drop");
|
|
1059
|
+
this.container.style.removeProperty("--wulf-drop-x");
|
|
1060
|
+
this.container.style.removeProperty("--wulf-drop-y");
|
|
1061
|
+
this.container.style.removeProperty("--wulf-drop-w");
|
|
1062
|
+
this.container.style.removeProperty("--wulf-drop-h");
|
|
1063
|
+
}
|
|
1064
|
+
startAutoScrollLoop(drag) {
|
|
1065
|
+
const tick = (now) => {
|
|
1066
|
+
if (this.pointerDrag !== drag || !drag.started || !this.container || this.isDestroyed) return;
|
|
1067
|
+
const dt = Math.min(64, Math.max(0, now - drag.lastFrameTime)) / 16.6667;
|
|
1068
|
+
drag.lastFrameTime = now;
|
|
1069
|
+
const cRect = this.container.getBoundingClientRect();
|
|
1070
|
+
const axis = this.options.axis;
|
|
1071
|
+
const maxSpeed = this.options.autoScrollSpeed * dt;
|
|
1072
|
+
let scrolled = false;
|
|
1073
|
+
if (axis === "y" || axis === "both") {
|
|
1074
|
+
const edge = Math.min(drag.slotRect.height || 40, cRect.height / 3);
|
|
1075
|
+
if (edge > 0) {
|
|
1076
|
+
if (drag.lastClientY < cRect.top + edge && this.container.scrollTop > 0) {
|
|
1077
|
+
const ratio = Math.min(2, (cRect.top + edge - drag.lastClientY) / edge);
|
|
1078
|
+
this.container.scrollTop -= maxSpeed * ratio;
|
|
1079
|
+
scrolled = true;
|
|
1080
|
+
} else if (drag.lastClientY > cRect.bottom - edge && this.container.scrollTop < this.container.scrollHeight - this.container.clientHeight) {
|
|
1081
|
+
const ratio = Math.min(2, (drag.lastClientY - (cRect.bottom - edge)) / edge);
|
|
1082
|
+
this.container.scrollTop += maxSpeed * ratio;
|
|
1083
|
+
scrolled = true;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
if (axis === "x" || axis === "both") {
|
|
1088
|
+
const edge = Math.min(drag.slotRect.width || 40, cRect.width / 3);
|
|
1089
|
+
if (edge > 0) {
|
|
1090
|
+
if (drag.lastClientX < cRect.left + edge) {
|
|
1091
|
+
const ratio = Math.min(2, (cRect.left + edge - drag.lastClientX) / edge);
|
|
1092
|
+
this.container.scrollLeft -= maxSpeed * ratio;
|
|
1093
|
+
scrolled = true;
|
|
1094
|
+
} else if (drag.lastClientX > cRect.right - edge) {
|
|
1095
|
+
const ratio = Math.min(2, (drag.lastClientX - (cRect.right - edge)) / edge);
|
|
1096
|
+
this.container.scrollLeft += maxSpeed * ratio;
|
|
1097
|
+
scrolled = true;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
if (scrolled) {
|
|
1102
|
+
this.updatePointerPosition(drag);
|
|
1103
|
+
}
|
|
1104
|
+
drag.rafId = requestAnimationFrame(tick);
|
|
1105
|
+
};
|
|
1106
|
+
drag.rafId = requestAnimationFrame(tick);
|
|
1107
|
+
}
|
|
1108
|
+
handlePointerUp(event) {
|
|
1109
|
+
const drag = this.pointerDrag;
|
|
1110
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
1111
|
+
this.endPointerDrag(false);
|
|
1112
|
+
}
|
|
1113
|
+
handlePointerCancel(event) {
|
|
1114
|
+
const drag = this.pointerDrag;
|
|
1115
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
1116
|
+
this.endPointerDrag(true);
|
|
1117
|
+
}
|
|
1118
|
+
handlePointerEscape(event) {
|
|
1119
|
+
if (event.key !== "Escape" || isImeComposing(event)) return;
|
|
1120
|
+
const drag = this.pointerDrag;
|
|
1121
|
+
if (!drag) return;
|
|
1122
|
+
event.preventDefault();
|
|
1123
|
+
this.endPointerDrag(true);
|
|
1124
|
+
}
|
|
1125
|
+
endPointerDrag(cancelled) {
|
|
1126
|
+
const drag = this.pointerDrag;
|
|
1127
|
+
if (!drag || !this.container) return;
|
|
1128
|
+
this.pointerDrag = null;
|
|
1129
|
+
drag.abortController.abort();
|
|
1130
|
+
if (drag.rafId !== null) {
|
|
1131
|
+
cancelAnimationFrame(drag.rafId);
|
|
1132
|
+
drag.rafId = null;
|
|
1133
|
+
}
|
|
1134
|
+
try {
|
|
1135
|
+
if (drag.handle.hasPointerCapture?.(drag.pointerId)) {
|
|
1136
|
+
drag.handle.releasePointerCapture(drag.pointerId);
|
|
1137
|
+
}
|
|
1138
|
+
} catch {
|
|
1139
|
+
}
|
|
1140
|
+
if (!drag.started) return;
|
|
1141
|
+
const releasedRect = drag.item.getBoundingClientRect();
|
|
1142
|
+
this.clearDropMarker();
|
|
1143
|
+
this.container.classList.remove("wulf-sortable--dragging");
|
|
1144
|
+
drag.item.classList.remove("wulf-sortable-item--dragging");
|
|
1145
|
+
drag.item.removeAttribute("data-wulf-dragging");
|
|
1146
|
+
drag.item.style.translate = drag.prevTranslate;
|
|
1147
|
+
const changed = !cancelled && drag.targetIndex !== drag.oldIndex;
|
|
1148
|
+
if (cancelled) {
|
|
1149
|
+
const snap = /* @__PURE__ */ new Map([[drag.item, releasedRect]]);
|
|
1150
|
+
this.animateFlip([drag.item], snap);
|
|
1151
|
+
this.safeInvoke(this.options.onCancel, {
|
|
1152
|
+
item: drag.item,
|
|
1153
|
+
index: drag.oldIndex,
|
|
1154
|
+
trigger: "pointer"
|
|
1155
|
+
});
|
|
1156
|
+
const label2 = this.getItemLabelText(drag.item, drag.oldIndex);
|
|
1157
|
+
this.announce(this.resolveI18n().cancelled(label2, drag.oldIndex + 1, drag.items.length));
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
if (!changed) {
|
|
1161
|
+
const snap = /* @__PURE__ */ new Map([[drag.item, releasedRect]]);
|
|
1162
|
+
this.animateFlip([drag.item], snap);
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
const ordered = computeReorderedArray(drag.items, drag.oldIndex, drag.targetIndex);
|
|
1166
|
+
if (this.options.autoMove) {
|
|
1167
|
+
const beforeRects = this.snapshotRects(drag.siblings);
|
|
1168
|
+
beforeRects.set(drag.item, releasedRect);
|
|
1169
|
+
moveItemInDom(this.container, drag.item, drag.siblings, drag.targetIndex);
|
|
1170
|
+
drag.item.scrollIntoView?.({ block: "nearest", inline: "nearest" });
|
|
1171
|
+
this.animateFlip(ordered, beforeRects);
|
|
1172
|
+
}
|
|
1173
|
+
this.emitReorder({
|
|
1174
|
+
item: drag.item,
|
|
1175
|
+
oldIndex: drag.oldIndex,
|
|
1176
|
+
newIndex: drag.targetIndex,
|
|
1177
|
+
items: ordered,
|
|
1178
|
+
trigger: "pointer"
|
|
1179
|
+
});
|
|
1180
|
+
const label = this.getItemLabelText(drag.item, drag.targetIndex);
|
|
1181
|
+
this.announce(this.resolveI18n().dropped(label, drag.targetIndex + 1, drag.items.length));
|
|
1182
|
+
}
|
|
1183
|
+
handleKeyDown(event) {
|
|
1184
|
+
if (!this.container || this.isDestroyed || this.options.disabled) return;
|
|
1185
|
+
if (isImeComposing(event)) return;
|
|
1186
|
+
if (event.ctrlKey || event.altKey || event.metaKey) return;
|
|
1187
|
+
if (isEditableTarget(event.target)) return;
|
|
1188
|
+
const item = this.findItemForEvent(event);
|
|
1189
|
+
if (!item) return;
|
|
1190
|
+
const activeTrigger = this.resolveTriggerForItem(item);
|
|
1191
|
+
const eventTarget = event.target;
|
|
1192
|
+
if (!this.options.handleSelector) {
|
|
1193
|
+
if (eventTarget !== item && this.hasInteractiveDescendantBeforeItem(event, item)) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
} else if (!activeTrigger || eventTarget !== activeTrigger && !activeTrigger.contains(eventTarget)) {
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
const triggerEl = activeTrigger ?? item;
|
|
1200
|
+
if (event.key === " " || event.key === "Enter") {
|
|
1201
|
+
event.preventDefault();
|
|
1202
|
+
if (this.keyboardGrab && this.keyboardGrab.item === item) {
|
|
1203
|
+
this.commitKeyboardGrab();
|
|
1204
|
+
} else {
|
|
1205
|
+
this.startKeyboardGrab(item, triggerEl);
|
|
1206
|
+
}
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (!this.keyboardGrab || this.keyboardGrab.item !== item) return;
|
|
1210
|
+
if (event.key === "Escape") {
|
|
1211
|
+
event.preventDefault();
|
|
1212
|
+
this.cancelKeyboardGrab();
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const nextIndex = this.computeKeyboardNextIndex(event.key, this.keyboardGrab);
|
|
1216
|
+
if (nextIndex === null) return;
|
|
1217
|
+
event.preventDefault();
|
|
1218
|
+
this.stepKeyboardGrab(nextIndex);
|
|
1219
|
+
}
|
|
1220
|
+
startKeyboardGrab(item, trigger) {
|
|
1221
|
+
if (!this.container) return;
|
|
1222
|
+
if (this.keyboardGrab) {
|
|
1223
|
+
this.commitKeyboardGrab();
|
|
1224
|
+
}
|
|
1225
|
+
const items = this.getItems();
|
|
1226
|
+
const index = items.indexOf(item);
|
|
1227
|
+
if (index === -1 || items.length < 2) return;
|
|
1228
|
+
this.keyboardGrab = {
|
|
1229
|
+
item,
|
|
1230
|
+
trigger,
|
|
1231
|
+
originIndex: index,
|
|
1232
|
+
currentIndex: index,
|
|
1233
|
+
initialOrder: items.slice(),
|
|
1234
|
+
tailRef: items[items.length - 1]?.nextSibling ?? null
|
|
1235
|
+
};
|
|
1236
|
+
this.container.classList.add("wulf-sortable--dragging");
|
|
1237
|
+
item.classList.add("wulf-sortable-item--grabbed");
|
|
1238
|
+
item.setAttribute("data-wulf-grabbed", "true");
|
|
1239
|
+
trigger.setAttribute("aria-pressed", "true");
|
|
1240
|
+
this.safeInvoke(this.options.onStart, {
|
|
1241
|
+
item,
|
|
1242
|
+
index,
|
|
1243
|
+
trigger: "keyboard"
|
|
1244
|
+
});
|
|
1245
|
+
const label = this.getItemLabelText(item, index);
|
|
1246
|
+
this.announce(this.resolveI18n().grabbed(label, index + 1, items.length));
|
|
1247
|
+
}
|
|
1248
|
+
computeKeyboardNextIndex(key, grab) {
|
|
1249
|
+
const axis = this.options.axis;
|
|
1250
|
+
const isRtl = this.isRtl();
|
|
1251
|
+
const items = this.options.autoMove ? this.getItems() : computeReorderedArray(grab.initialOrder, grab.originIndex, grab.currentIndex);
|
|
1252
|
+
const total = items.length;
|
|
1253
|
+
const idx = grab.currentIndex;
|
|
1254
|
+
if (key === "Home") return 0;
|
|
1255
|
+
if (key === "End") return total - 1;
|
|
1256
|
+
if (axis === "y") {
|
|
1257
|
+
if (key === "ArrowUp") return Math.max(0, idx - 1);
|
|
1258
|
+
if (key === "ArrowDown") return Math.min(total - 1, idx + 1);
|
|
1259
|
+
return null;
|
|
1260
|
+
}
|
|
1261
|
+
if (axis === "x") {
|
|
1262
|
+
if (key === "ArrowLeft") return isRtl ? Math.min(total - 1, idx + 1) : Math.max(0, idx - 1);
|
|
1263
|
+
if (key === "ArrowRight") return isRtl ? Math.max(0, idx - 1) : Math.min(total - 1, idx + 1);
|
|
1264
|
+
return null;
|
|
1265
|
+
}
|
|
1266
|
+
if (key === "ArrowLeft") return isRtl ? Math.min(total - 1, idx + 1) : Math.max(0, idx - 1);
|
|
1267
|
+
if (key === "ArrowRight") return isRtl ? Math.max(0, idx - 1) : Math.min(total - 1, idx + 1);
|
|
1268
|
+
if (key !== "ArrowUp" && key !== "ArrowDown") return null;
|
|
1269
|
+
const currentRect = grab.item.getBoundingClientRect();
|
|
1270
|
+
const cx0 = currentRect.left + currentRect.width / 2;
|
|
1271
|
+
const cy0 = currentRect.top + currentRect.height / 2;
|
|
1272
|
+
const minRowDelta = Math.max(4, currentRect.height * 0.35);
|
|
1273
|
+
const candidates = [];
|
|
1274
|
+
for (let i = 0; i < total; i++) {
|
|
1275
|
+
if (i === idx) continue;
|
|
1276
|
+
const r = items[i].getBoundingClientRect();
|
|
1277
|
+
const cy = r.top + r.height / 2;
|
|
1278
|
+
if (key === "ArrowDown" && cy - cy0 > minRowDelta) {
|
|
1279
|
+
candidates.push({ index: i, cx: r.left + r.width / 2, cy });
|
|
1280
|
+
} else if (key === "ArrowUp" && cy0 - cy > minRowDelta) {
|
|
1281
|
+
candidates.push({ index: i, cx: r.left + r.width / 2, cy });
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (candidates.length === 0) return idx;
|
|
1285
|
+
const targetRowCy = key === "ArrowDown" ? Math.min(...candidates.map((c) => c.cy)) : Math.max(...candidates.map((c) => c.cy));
|
|
1286
|
+
const rowTolerance = Math.max(8, currentRect.height * 0.5);
|
|
1287
|
+
const sameRow = candidates.filter((c) => Math.abs(c.cy - targetRowCy) <= rowTolerance);
|
|
1288
|
+
let best = sameRow[0];
|
|
1289
|
+
let bestDx = Math.abs(best.cx - cx0);
|
|
1290
|
+
for (let i = 1; i < sameRow.length; i++) {
|
|
1291
|
+
const dx = Math.abs(sameRow[i].cx - cx0);
|
|
1292
|
+
if (dx < bestDx) {
|
|
1293
|
+
bestDx = dx;
|
|
1294
|
+
best = sameRow[i];
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
return best.index;
|
|
1298
|
+
}
|
|
1299
|
+
stepKeyboardGrab(nextIndex) {
|
|
1300
|
+
const grab = this.keyboardGrab;
|
|
1301
|
+
if (!grab || !this.container || nextIndex === grab.currentIndex) return;
|
|
1302
|
+
const fromIndex = grab.currentIndex;
|
|
1303
|
+
const currentItems = this.getItems();
|
|
1304
|
+
const total = currentItems.length;
|
|
1305
|
+
if (this.options.autoMove) {
|
|
1306
|
+
const beforeRects = this.snapshotRects(currentItems);
|
|
1307
|
+
const siblings = currentItems.filter((el) => el !== grab.item);
|
|
1308
|
+
this.isMovingFocus = true;
|
|
1309
|
+
try {
|
|
1310
|
+
moveItemInDom(this.container, grab.item, siblings, nextIndex);
|
|
1311
|
+
grab.item.scrollIntoView?.({ block: "nearest", inline: "nearest" });
|
|
1312
|
+
if (getDeepActiveElement() !== grab.trigger) {
|
|
1313
|
+
grab.trigger.focus({ preventScroll: true });
|
|
1314
|
+
}
|
|
1315
|
+
} finally {
|
|
1316
|
+
this.isMovingFocus = false;
|
|
1317
|
+
}
|
|
1318
|
+
this.animateFlip(currentItems, beforeRects);
|
|
1319
|
+
}
|
|
1320
|
+
grab.currentIndex = nextIndex;
|
|
1321
|
+
const ordered = this.options.autoMove ? this.getItems() : computeReorderedArray(grab.initialOrder, grab.originIndex, nextIndex);
|
|
1322
|
+
this.safeInvoke(this.options.onMove, {
|
|
1323
|
+
item: grab.item,
|
|
1324
|
+
oldIndex: grab.originIndex,
|
|
1325
|
+
fromIndex,
|
|
1326
|
+
toIndex: nextIndex,
|
|
1327
|
+
items: ordered,
|
|
1328
|
+
trigger: "keyboard"
|
|
1329
|
+
});
|
|
1330
|
+
const label = this.getItemLabelText(grab.item, nextIndex);
|
|
1331
|
+
this.announce(this.resolveI18n().moved(label, nextIndex + 1, total));
|
|
1332
|
+
}
|
|
1333
|
+
clearKeyboardGrabVisuals(grab) {
|
|
1334
|
+
this.container?.classList.remove("wulf-sortable--dragging");
|
|
1335
|
+
grab.item.classList.remove("wulf-sortable-item--grabbed");
|
|
1336
|
+
grab.item.removeAttribute("data-wulf-grabbed");
|
|
1337
|
+
const saved = this.savedAttributes.get(grab.trigger);
|
|
1338
|
+
if (saved?.hadAriaPressed && saved.prevAriaPressed !== null) {
|
|
1339
|
+
grab.trigger.setAttribute("aria-pressed", saved.prevAriaPressed);
|
|
1340
|
+
} else {
|
|
1341
|
+
grab.trigger.removeAttribute("aria-pressed");
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
commitKeyboardGrab() {
|
|
1345
|
+
const grab = this.keyboardGrab;
|
|
1346
|
+
if (!grab) return;
|
|
1347
|
+
this.keyboardGrab = null;
|
|
1348
|
+
this.clearKeyboardGrabVisuals(grab);
|
|
1349
|
+
if (grab.currentIndex !== grab.originIndex) {
|
|
1350
|
+
const ordered = this.options.autoMove ? this.getItems() : computeReorderedArray(grab.initialOrder, grab.originIndex, grab.currentIndex);
|
|
1351
|
+
this.emitReorder({
|
|
1352
|
+
item: grab.item,
|
|
1353
|
+
oldIndex: grab.originIndex,
|
|
1354
|
+
newIndex: grab.currentIndex,
|
|
1355
|
+
items: ordered,
|
|
1356
|
+
trigger: "keyboard"
|
|
1357
|
+
});
|
|
1358
|
+
const label = this.getItemLabelText(grab.item, grab.currentIndex);
|
|
1359
|
+
this.announce(this.resolveI18n().dropped(label, grab.currentIndex + 1, ordered.length));
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
cancelKeyboardGrab() {
|
|
1363
|
+
const grab = this.keyboardGrab;
|
|
1364
|
+
if (!grab || !this.container) return;
|
|
1365
|
+
this.keyboardGrab = null;
|
|
1366
|
+
if (this.options.autoMove && grab.currentIndex !== grab.originIndex) {
|
|
1367
|
+
const currentItems = this.getItems();
|
|
1368
|
+
const beforeRects = this.snapshotRects(currentItems);
|
|
1369
|
+
this.isMovingFocus = true;
|
|
1370
|
+
try {
|
|
1371
|
+
const ref = grab.tailRef && grab.tailRef.parentNode === this.container ? grab.tailRef : null;
|
|
1372
|
+
for (const node of grab.initialOrder) {
|
|
1373
|
+
if (node.parentNode === this.container && node !== ref) {
|
|
1374
|
+
safeMove(this.container, node, ref);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
grab.item.scrollIntoView?.({ block: "nearest", inline: "nearest" });
|
|
1378
|
+
if (getDeepActiveElement() !== grab.trigger) {
|
|
1379
|
+
grab.trigger.focus({ preventScroll: true });
|
|
1380
|
+
}
|
|
1381
|
+
} finally {
|
|
1382
|
+
this.isMovingFocus = false;
|
|
1383
|
+
}
|
|
1384
|
+
this.animateFlip(grab.initialOrder, beforeRects);
|
|
1385
|
+
}
|
|
1386
|
+
this.clearKeyboardGrabVisuals(grab);
|
|
1387
|
+
this.safeInvoke(this.options.onCancel, {
|
|
1388
|
+
item: grab.item,
|
|
1389
|
+
index: grab.originIndex,
|
|
1390
|
+
trigger: "keyboard"
|
|
1391
|
+
});
|
|
1392
|
+
const total = this.getItems().length || grab.initialOrder.length;
|
|
1393
|
+
const label = this.getItemLabelText(grab.item, grab.originIndex);
|
|
1394
|
+
this.announce(this.resolveI18n().cancelled(label, grab.originIndex + 1, total));
|
|
1395
|
+
}
|
|
1396
|
+
handleFocusOut(event) {
|
|
1397
|
+
if (this.isMovingFocus || !this.keyboardGrab) return;
|
|
1398
|
+
const grab = this.keyboardGrab;
|
|
1399
|
+
const nextFocus = event.relatedTarget;
|
|
1400
|
+
if (!nextFocus || nextFocus !== grab.trigger && !grab.trigger.contains(nextFocus)) {
|
|
1401
|
+
this.commitKeyboardGrab();
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
snapshotRects(elements) {
|
|
1405
|
+
const map = /* @__PURE__ */ new Map();
|
|
1406
|
+
for (const el of elements) {
|
|
1407
|
+
const prev = this.activeAnimations.get(el);
|
|
1408
|
+
if (prev) {
|
|
1409
|
+
try {
|
|
1410
|
+
prev.finish();
|
|
1411
|
+
} catch {
|
|
1412
|
+
}
|
|
1413
|
+
this.activeAnimations.delete(el);
|
|
1414
|
+
}
|
|
1415
|
+
map.set(el, el.getBoundingClientRect());
|
|
1416
|
+
}
|
|
1417
|
+
return map;
|
|
1418
|
+
}
|
|
1419
|
+
animateFlip(elements, beforeRects) {
|
|
1420
|
+
const duration = this.options.animationDuration;
|
|
1421
|
+
if (duration <= 0 || prefersReducedMotion()) return;
|
|
1422
|
+
for (const el of elements) {
|
|
1423
|
+
if (typeof el.animate !== "function") continue;
|
|
1424
|
+
const oldRect = beforeRects.get(el);
|
|
1425
|
+
if (!oldRect) continue;
|
|
1426
|
+
const newRect = el.getBoundingClientRect();
|
|
1427
|
+
const dx = oldRect.left - newRect.left;
|
|
1428
|
+
const dy = oldRect.top - newRect.top;
|
|
1429
|
+
if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5) continue;
|
|
1430
|
+
try {
|
|
1431
|
+
const anim = el.animate(
|
|
1432
|
+
[{ translate: `${dx}px ${dy}px` }, { translate: "0px 0px" }],
|
|
1433
|
+
{ duration, easing: "cubic-bezier(0.2, 0.8, 0.2, 1)" }
|
|
1434
|
+
);
|
|
1435
|
+
this.activeAnimations.set(el, anim);
|
|
1436
|
+
anim.addEventListener(
|
|
1437
|
+
"finish",
|
|
1438
|
+
() => {
|
|
1439
|
+
if (this.activeAnimations.get(el) === anim) {
|
|
1440
|
+
this.activeAnimations.delete(el);
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
{ once: true }
|
|
1444
|
+
);
|
|
1445
|
+
} catch {
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
isRtl() {
|
|
1450
|
+
if (!this.container || typeof window === "undefined" || typeof window.getComputedStyle !== "function") {
|
|
1451
|
+
return false;
|
|
1452
|
+
}
|
|
1453
|
+
return window.getComputedStyle(this.container).direction === "rtl";
|
|
1454
|
+
}
|
|
1455
|
+
emitReorder(detail) {
|
|
1456
|
+
this.safeInvoke(this.options.onReorder, detail);
|
|
1457
|
+
if (this.container && typeof CustomEvent === "function") {
|
|
1458
|
+
this.container.dispatchEvent(
|
|
1459
|
+
new CustomEvent("wulf:sortable:reorder", {
|
|
1460
|
+
bubbles: true,
|
|
1461
|
+
detail
|
|
1462
|
+
})
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
safeInvoke(fn, detail) {
|
|
1467
|
+
if (typeof fn !== "function") return;
|
|
1468
|
+
try {
|
|
1469
|
+
fn(detail);
|
|
1470
|
+
} catch {
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
return __toCommonJS(index_exports);
|
|
1475
|
+
})();
|
|
1476
|
+
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } var __set = function(obj, key, val) { try { Object.defineProperty(obj, key, { value: val, writable: true, configurable: true, enumerable: true }); } catch (_) { try { obj[key] = val; } catch (__) {} } }; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { var __e = __WulfIIFE; var __skip = ["__proto__","constructor","prototype"]; for (var k in __e) { if (Object.hasOwn(__e, k) && __skip.indexOf(k) === -1 && __w[k] === undefined) { __set(__w, k, __e[k]); } } if (__e.Sortable) __set(__w, "Sortable", Object.assign(__e.Sortable, { Sortable: __e.Sortable, i18n: __e.sortableI18n, default: __e.Sortable })); }}
|
|
1477
|
+
//# sourceMappingURL=sortable.global.js.map
|