wulf.js 2.1.0 → 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 +60 -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 -536
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +260 -87
- 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 -10069
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +4192 -355
- 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 -1067
- package/dist/masonry.esm.js.map +4 -4
- package/dist/masonry.global.js +229 -148
- 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 -1175
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +171 -88
- 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 -741
- package/dist/shortcut.esm.js.map +4 -4
- package/dist/shortcut.global.js +225 -58
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +8 -2
- 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 -1129
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +386 -104
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +4 -4
- 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/dom.d.ts +5 -0
- package/dist/types/common/registry.d.ts +40 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +8 -3
- package/dist/types/index.d.ts +13 -1
- package/dist/types/mask/paste.d.ts +2 -5
- package/dist/types/masonry/Masonry.d.ts +2 -0
- package/dist/types/scroll/ScrollBlock.d.ts +2 -0
- package/dist/types/scroll/types.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +16 -3
- 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 +4 -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,766 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LocalizedComponent,
|
|
3
|
+
createI18nManager
|
|
4
|
+
} from "./chunk-QV46A7FV.js";
|
|
5
|
+
import {
|
|
6
|
+
isImeComposing,
|
|
7
|
+
stripBidiAndInvisibles
|
|
8
|
+
} from "./chunk-22AIMRD5.js";
|
|
9
|
+
import {
|
|
10
|
+
__export
|
|
11
|
+
} from "./chunk-VJO22BAT.js";
|
|
12
|
+
|
|
13
|
+
// src/undo/index.ts
|
|
14
|
+
var undo_exports = {};
|
|
15
|
+
__export(undo_exports, {
|
|
16
|
+
LocalizedComponent: () => LocalizedComponent,
|
|
17
|
+
Undo: () => UndoManager,
|
|
18
|
+
UndoManager: () => UndoManager,
|
|
19
|
+
createI18nManager: () => createI18nManager,
|
|
20
|
+
default: () => UndoManager,
|
|
21
|
+
undoEn: () => undoEn,
|
|
22
|
+
undoFr: () => undoFr,
|
|
23
|
+
undoI18n: () => undoI18n
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// src/undo/i18n/fr.ts
|
|
27
|
+
var undoFr = {
|
|
28
|
+
undone: (label) => label ? `Action annul\xE9e : ${label}` : "Action annul\xE9e.",
|
|
29
|
+
redone: (label) => label ? `Action r\xE9tablie : ${label}` : "Action r\xE9tablie.",
|
|
30
|
+
nothingToUndo: "Aucune action \xE0 annuler.",
|
|
31
|
+
nothingToRedo: "Aucune action \xE0 r\xE9tablir."
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/undo/i18n/en.ts
|
|
35
|
+
var undoEn = {
|
|
36
|
+
undone: (label) => label ? `Undone: ${label}` : "Action undone.",
|
|
37
|
+
redone: (label) => label ? `Redone: ${label}` : "Action redone.",
|
|
38
|
+
nothingToUndo: "Nothing to undo.",
|
|
39
|
+
nothingToRedo: "Nothing to redo."
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/undo/i18n/index.ts
|
|
43
|
+
var undoI18n = createI18nManager("fr", {
|
|
44
|
+
fr: undoFr,
|
|
45
|
+
en: undoEn
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// src/undo/UndoManager.ts
|
|
49
|
+
var SENSITIVE_AUTOCOMPLETE_TOKENS = /* @__PURE__ */ new Set([
|
|
50
|
+
"current-password",
|
|
51
|
+
"new-password",
|
|
52
|
+
"one-time-code",
|
|
53
|
+
"cc-number",
|
|
54
|
+
"cc-csc"
|
|
55
|
+
]);
|
|
56
|
+
function clampInt(val, fallback, min, max) {
|
|
57
|
+
if (typeof val !== "number" || !Number.isFinite(val)) return fallback;
|
|
58
|
+
return Math.min(max, Math.max(min, Math.floor(val)));
|
|
59
|
+
}
|
|
60
|
+
function nowMs() {
|
|
61
|
+
return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
62
|
+
}
|
|
63
|
+
function isApplePlatform() {
|
|
64
|
+
if (typeof navigator === "undefined") return false;
|
|
65
|
+
const nav = navigator;
|
|
66
|
+
const plat = nav.userAgentData?.platform || navigator.platform || navigator.userAgent || "";
|
|
67
|
+
return /mac|iphone|ipad|ipod/i.test(plat);
|
|
68
|
+
}
|
|
69
|
+
function isEditableElement(target) {
|
|
70
|
+
if (!target || typeof target.tagName !== "string") return false;
|
|
71
|
+
const el = target;
|
|
72
|
+
const tag = el.tagName.toUpperCase();
|
|
73
|
+
if (tag === "INPUT") {
|
|
74
|
+
const type = el.type?.toLowerCase() || "text";
|
|
75
|
+
return !["button", "checkbox", "radio", "submit", "reset", "range", "color", "file", "image"].includes(type);
|
|
76
|
+
}
|
|
77
|
+
if (tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
78
|
+
const ce = el.getAttribute?.("contenteditable")?.toLowerCase();
|
|
79
|
+
if (el.isContentEditable || ce === "true" || ce === "plaintext-only" || ce === "") {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const role = el.getAttribute?.("role");
|
|
83
|
+
if (role === "textbox" || role === "searchbox" || role === "combobox" || role === "spinbutton") {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return Boolean(
|
|
87
|
+
typeof el.closest === "function" && el.closest(
|
|
88
|
+
'[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
function isSensitiveElement(target) {
|
|
93
|
+
if (!target || typeof target.tagName !== "string") return false;
|
|
94
|
+
const el = target;
|
|
95
|
+
if (el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password") {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
const sensitiveAttr = el.getAttribute?.("data-mask-sensitive");
|
|
99
|
+
if (sensitiveAttr !== null && sensitiveAttr !== void 0 && sensitiveAttr !== "false") {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
const ac = el.getAttribute?.("autocomplete");
|
|
103
|
+
if (ac) {
|
|
104
|
+
const tokens = ac.trim().toLowerCase().split(/\s+/);
|
|
105
|
+
if (tokens.some((tok) => SENSITIVE_AUTOCOMPLETE_TOKENS.has(tok))) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
function sanitizeLabel(label) {
|
|
112
|
+
if (typeof label !== "string") return void 0;
|
|
113
|
+
const clean = stripBidiAndInvisibles(label, 256).trim();
|
|
114
|
+
return clean || void 0;
|
|
115
|
+
}
|
|
116
|
+
var UndoManager = class extends LocalizedComponent {
|
|
117
|
+
static _i18n = undoI18n;
|
|
118
|
+
maxDepth;
|
|
119
|
+
coalesceMs;
|
|
120
|
+
cloneStrategy;
|
|
121
|
+
equalsFn;
|
|
122
|
+
keyboardOptions;
|
|
123
|
+
announceEnabled;
|
|
124
|
+
announceRoot;
|
|
125
|
+
langOverride;
|
|
126
|
+
onChange;
|
|
127
|
+
onUndo;
|
|
128
|
+
onRedo;
|
|
129
|
+
onError;
|
|
130
|
+
stack = [];
|
|
131
|
+
index = 0;
|
|
132
|
+
lastPushTime = -Infinity;
|
|
133
|
+
batchDepth = 0;
|
|
134
|
+
batchHasChange = false;
|
|
135
|
+
batchPendingState;
|
|
136
|
+
batchPendingLabel;
|
|
137
|
+
isApplying = false;
|
|
138
|
+
paused = false;
|
|
139
|
+
isDestroyed = false;
|
|
140
|
+
abortController = null;
|
|
141
|
+
bindings = /* @__PURE__ */ new Set();
|
|
142
|
+
srStatusEl = null;
|
|
143
|
+
announceTimerId = null;
|
|
144
|
+
constructor(initialState, options = {}) {
|
|
145
|
+
super(options.i18n);
|
|
146
|
+
this.maxDepth = clampInt(options.maxDepth, 100, 1, 1e4);
|
|
147
|
+
this.coalesceMs = clampInt(options.coalesceMs, 500, 0, 6e4);
|
|
148
|
+
this.cloneStrategy = options.clone ?? "structured";
|
|
149
|
+
this.equalsFn = options.equals;
|
|
150
|
+
this.announceEnabled = options.announce ?? true;
|
|
151
|
+
this.announceRoot = options.announceRoot ?? null;
|
|
152
|
+
this.langOverride = options.lang;
|
|
153
|
+
this.onChange = options.onChange;
|
|
154
|
+
this.onUndo = options.onUndo;
|
|
155
|
+
this.onRedo = options.onRedo;
|
|
156
|
+
this.onError = options.onError;
|
|
157
|
+
if (options.keyboard === false) {
|
|
158
|
+
this.keyboardOptions = null;
|
|
159
|
+
} else if (typeof options.keyboard === "object" && options.keyboard !== null) {
|
|
160
|
+
this.keyboardOptions = { ...options.keyboard };
|
|
161
|
+
} else {
|
|
162
|
+
this.keyboardOptions = {};
|
|
163
|
+
}
|
|
164
|
+
this.stack = [{ state: this.cloneState(initialState), timestamp: nowMs() }];
|
|
165
|
+
this.index = 0;
|
|
166
|
+
this.bindKeyboard();
|
|
167
|
+
this.runAuditWarning(options.audit ?? true);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Empile un nouvel état (ou le fusionne avec le sommet selon `coalesceMs` et `mergeKey`).
|
|
171
|
+
*/
|
|
172
|
+
push(nextState, options) {
|
|
173
|
+
if (this.isDestroyed || this.isApplying) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const cleanLabel = sanitizeLabel(options?.label);
|
|
177
|
+
const cloned = this.cloneState(nextState);
|
|
178
|
+
if (this.batchDepth > 0) {
|
|
179
|
+
this.batchPendingState = cloned;
|
|
180
|
+
this.batchHasChange = true;
|
|
181
|
+
if (cleanLabel && !this.batchPendingLabel) {
|
|
182
|
+
this.batchPendingLabel = cleanLabel;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
const currentEntry = this.stack[this.index];
|
|
187
|
+
if (this.equalsFn && currentEntry && this.equalsFn(currentEntry.state, cloned)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
const previousState = currentEntry.state;
|
|
191
|
+
this.stack.length = this.index + 1;
|
|
192
|
+
const t = nowMs();
|
|
193
|
+
const canCoalesce = options?.coalesce !== false && this.index > 0 && this.coalesceMs > 0 && t - this.lastPushTime <= this.coalesceMs && (options?.mergeKey !== void 0 && currentEntry.mergeKey === options.mergeKey || options?.mergeKey === void 0 && currentEntry.mergeKey === void 0);
|
|
194
|
+
if (canCoalesce) {
|
|
195
|
+
this.stack[this.index] = {
|
|
196
|
+
state: cloned,
|
|
197
|
+
label: cleanLabel ?? currentEntry.label,
|
|
198
|
+
mergeKey: options?.mergeKey,
|
|
199
|
+
timestamp: t
|
|
200
|
+
};
|
|
201
|
+
} else {
|
|
202
|
+
this.stack.push({
|
|
203
|
+
state: cloned,
|
|
204
|
+
label: cleanLabel,
|
|
205
|
+
mergeKey: options?.mergeKey,
|
|
206
|
+
timestamp: t
|
|
207
|
+
});
|
|
208
|
+
this.trimToMaxDepth();
|
|
209
|
+
this.index = this.stack.length - 1;
|
|
210
|
+
}
|
|
211
|
+
this.lastPushTime = t;
|
|
212
|
+
this.syncControls();
|
|
213
|
+
this.notifyCallback(this.onChange, "push", this.stack[this.index].state, previousState, this.stack[this.index].label);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Annule la dernière action et restaure l'état précédent.
|
|
218
|
+
*/
|
|
219
|
+
undo() {
|
|
220
|
+
if (this.isDestroyed || this.isApplying || !this.canUndo()) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
return this.stepTo(this.index - 1, "undo");
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Rétablit l'action suivante dans l'historique.
|
|
227
|
+
*/
|
|
228
|
+
redo() {
|
|
229
|
+
if (this.isDestroyed || this.isApplying || !this.canRedo()) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
return this.stepTo(this.index + 1, "redo");
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Saute directement à un index précis de la pile d'historique.
|
|
236
|
+
*/
|
|
237
|
+
go(targetIndex) {
|
|
238
|
+
if (this.isDestroyed || this.isApplying || !Number.isInteger(targetIndex)) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (targetIndex < 0 || targetIndex >= this.stack.length || targetIndex === this.index) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return this.stepTo(targetIndex, "go");
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Regroupe plusieurs `push()` successifs dans une transaction atomique unique.
|
|
248
|
+
* Garantit un rollback complet et la libération du verrou en cas d'exception.
|
|
249
|
+
*/
|
|
250
|
+
batch(fn, label) {
|
|
251
|
+
if (this.isDestroyed) {
|
|
252
|
+
return fn();
|
|
253
|
+
}
|
|
254
|
+
const isRoot = this.batchDepth === 0;
|
|
255
|
+
if (isRoot) {
|
|
256
|
+
this.batchHasChange = false;
|
|
257
|
+
this.batchPendingState = void 0;
|
|
258
|
+
this.batchPendingLabel = sanitizeLabel(label);
|
|
259
|
+
} else if (label && !this.batchPendingLabel) {
|
|
260
|
+
this.batchPendingLabel = sanitizeLabel(label);
|
|
261
|
+
}
|
|
262
|
+
this.batchDepth++;
|
|
263
|
+
try {
|
|
264
|
+
const result = fn();
|
|
265
|
+
if (isRoot && this.batchHasChange && this.batchPendingState !== void 0) {
|
|
266
|
+
const pending = this.batchPendingState;
|
|
267
|
+
const pendingLabel = this.batchPendingLabel;
|
|
268
|
+
const currentEntry = this.stack[this.index];
|
|
269
|
+
if (!this.equalsFn || !this.equalsFn(currentEntry.state, pending)) {
|
|
270
|
+
const previousState = currentEntry.state;
|
|
271
|
+
this.stack.length = this.index + 1;
|
|
272
|
+
this.stack.push({
|
|
273
|
+
state: pending,
|
|
274
|
+
label: pendingLabel,
|
|
275
|
+
timestamp: nowMs()
|
|
276
|
+
});
|
|
277
|
+
this.trimToMaxDepth();
|
|
278
|
+
this.index = this.stack.length - 1;
|
|
279
|
+
this.lastPushTime = -Infinity;
|
|
280
|
+
this.syncControls();
|
|
281
|
+
this.notifyCallback(this.onChange, "batch", pending, previousState, pendingLabel);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
} catch (err) {
|
|
286
|
+
if (isRoot) {
|
|
287
|
+
this.batchHasChange = false;
|
|
288
|
+
this.batchPendingState = void 0;
|
|
289
|
+
this.batchPendingLabel = void 0;
|
|
290
|
+
}
|
|
291
|
+
throw err;
|
|
292
|
+
} finally {
|
|
293
|
+
this.batchDepth--;
|
|
294
|
+
if (isRoot) {
|
|
295
|
+
this.batchHasChange = false;
|
|
296
|
+
this.batchPendingState = void 0;
|
|
297
|
+
this.batchPendingLabel = void 0;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Interrompt la fenêtre de coalescing en cours : le prochain `push()` créera une nouvelle entrée.
|
|
303
|
+
*/
|
|
304
|
+
checkpoint() {
|
|
305
|
+
this.lastPushTime = -Infinity;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Remplace toute la pile par un nouvel état initial.
|
|
309
|
+
*/
|
|
310
|
+
reset(newInitialState, label) {
|
|
311
|
+
if (this.isDestroyed || this.isApplying) return;
|
|
312
|
+
const prev = this.stack[this.index]?.state;
|
|
313
|
+
const cleanLabel = sanitizeLabel(label);
|
|
314
|
+
const cloned = this.cloneState(newInitialState);
|
|
315
|
+
this.stack = [{ state: cloned, label: cleanLabel, timestamp: nowMs() }];
|
|
316
|
+
this.index = 0;
|
|
317
|
+
this.lastPushTime = -Infinity;
|
|
318
|
+
this.syncControls();
|
|
319
|
+
this.notifyCallback(this.onChange, "reset", cloned, prev, cleanLabel);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Vide l'historique passé et futur tout en conservant l'état courant comme nouvelle racine.
|
|
323
|
+
*/
|
|
324
|
+
clear() {
|
|
325
|
+
if (this.isDestroyed || this.isApplying || this.stack.length === 0) return;
|
|
326
|
+
const curr = this.stack[this.index];
|
|
327
|
+
this.stack = [{ state: curr.state, label: curr.label, timestamp: curr.timestamp }];
|
|
328
|
+
this.index = 0;
|
|
329
|
+
this.lastPushTime = -Infinity;
|
|
330
|
+
this.syncControls();
|
|
331
|
+
this.notifyCallback(this.onChange, "clear", curr.state, curr.state, curr.label);
|
|
332
|
+
}
|
|
333
|
+
canUndo() {
|
|
334
|
+
return !this.isDestroyed && this.index > 0;
|
|
335
|
+
}
|
|
336
|
+
canRedo() {
|
|
337
|
+
return !this.isDestroyed && this.index < this.stack.length - 1;
|
|
338
|
+
}
|
|
339
|
+
getState() {
|
|
340
|
+
if (this.batchDepth > 0 && this.batchHasChange && this.batchPendingState !== void 0) {
|
|
341
|
+
return this.cloneState(this.batchPendingState);
|
|
342
|
+
}
|
|
343
|
+
if (this.stack.length === 0) {
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
return this.cloneState(this.stack[this.index].state);
|
|
347
|
+
}
|
|
348
|
+
getIndex() {
|
|
349
|
+
return this.index;
|
|
350
|
+
}
|
|
351
|
+
getLength() {
|
|
352
|
+
return this.stack.length;
|
|
353
|
+
}
|
|
354
|
+
getUndoLabel() {
|
|
355
|
+
return this.canUndo() ? this.stack[this.index].label : void 0;
|
|
356
|
+
}
|
|
357
|
+
getRedoLabel() {
|
|
358
|
+
return this.canRedo() ? this.stack[this.index + 1].label : void 0;
|
|
359
|
+
}
|
|
360
|
+
getHistory() {
|
|
361
|
+
return this.stack.map((entry) => ({
|
|
362
|
+
state: this.cloneState(entry.state),
|
|
363
|
+
label: entry.label,
|
|
364
|
+
mergeKey: entry.mergeKey,
|
|
365
|
+
timestamp: entry.timestamp
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Relie des boutons DOM Undo/Redo de façon non-destructive :
|
|
370
|
+
* gère `aria-disabled` (avec blocage `click` en phase capture), `aria-keyshortcuts`
|
|
371
|
+
* et `data-wulf-undo-label` sans jamais altérer les icônes ou libellés enfants.
|
|
372
|
+
*/
|
|
373
|
+
bindControls(controls) {
|
|
374
|
+
if (this.isDestroyed || typeof HTMLElement === "undefined") {
|
|
375
|
+
return () => {
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
const undoEl = controls.undo instanceof HTMLElement ? controls.undo : null;
|
|
379
|
+
const redoEl = controls.redo instanceof HTMLElement ? controls.redo : null;
|
|
380
|
+
const opts = {
|
|
381
|
+
useNativeDisabled: Boolean(controls.useNativeDisabled),
|
|
382
|
+
updateAriaKeyShortcuts: controls.updateAriaKeyShortcuts !== false,
|
|
383
|
+
updateLabelAttribute: controls.updateLabelAttribute !== false
|
|
384
|
+
};
|
|
385
|
+
const ctrl = new AbortController();
|
|
386
|
+
const savedUndo = undoEl ? this.captureControlAttrs(undoEl, "data-wulf-undo-label") : null;
|
|
387
|
+
const savedRedo = redoEl ? this.captureControlAttrs(redoEl, "data-wulf-redo-label") : null;
|
|
388
|
+
const attachClick = (el, role) => {
|
|
389
|
+
el.addEventListener(
|
|
390
|
+
"click",
|
|
391
|
+
(event) => {
|
|
392
|
+
const enabled = role === "undo" ? this.canUndo() : this.canRedo();
|
|
393
|
+
if (!enabled || this.paused || this.isDestroyed) {
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
event.stopImmediatePropagation();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (role === "undo") this.undo();
|
|
399
|
+
else this.redo();
|
|
400
|
+
},
|
|
401
|
+
{ capture: true, signal: ctrl.signal }
|
|
402
|
+
);
|
|
403
|
+
};
|
|
404
|
+
if (undoEl) attachClick(undoEl, "undo");
|
|
405
|
+
if (redoEl) attachClick(redoEl, "redo");
|
|
406
|
+
const isApple = isApplePlatform();
|
|
407
|
+
const sync = () => {
|
|
408
|
+
if (undoEl) {
|
|
409
|
+
this.applyControlState(
|
|
410
|
+
undoEl,
|
|
411
|
+
this.canUndo(),
|
|
412
|
+
opts,
|
|
413
|
+
isApple ? "Meta+Z" : "Control+Z",
|
|
414
|
+
"data-wulf-undo-label",
|
|
415
|
+
this.getUndoLabel()
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
if (redoEl) {
|
|
419
|
+
this.applyControlState(
|
|
420
|
+
redoEl,
|
|
421
|
+
this.canRedo(),
|
|
422
|
+
opts,
|
|
423
|
+
isApple ? "Meta+Shift+Z" : "Control+Y Control+Shift+Z",
|
|
424
|
+
"data-wulf-redo-label",
|
|
425
|
+
this.getRedoLabel()
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
let unbound = false;
|
|
430
|
+
const unbind = () => {
|
|
431
|
+
if (unbound) return;
|
|
432
|
+
unbound = true;
|
|
433
|
+
ctrl.abort();
|
|
434
|
+
if (undoEl && savedUndo) this.restoreControlAttrs(undoEl, "data-wulf-undo-label", savedUndo);
|
|
435
|
+
if (redoEl && savedRedo) this.restoreControlAttrs(redoEl, "data-wulf-redo-label", savedRedo);
|
|
436
|
+
this.bindings.delete(binding);
|
|
437
|
+
};
|
|
438
|
+
const binding = { undoEl, redoEl, options: opts, sync, unbind };
|
|
439
|
+
this.bindings.add(binding);
|
|
440
|
+
sync();
|
|
441
|
+
return unbind;
|
|
442
|
+
}
|
|
443
|
+
pause() {
|
|
444
|
+
this.paused = true;
|
|
445
|
+
}
|
|
446
|
+
resume() {
|
|
447
|
+
if (!this.isDestroyed) {
|
|
448
|
+
this.paused = false;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
isPaused() {
|
|
452
|
+
return this.paused;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Audite le respect de l'Axiome Primordial et l'accessibilité des contrôles liés.
|
|
456
|
+
*/
|
|
457
|
+
audit() {
|
|
458
|
+
const warnings = [];
|
|
459
|
+
if (this.keyboardOptions?.allowInEditable) {
|
|
460
|
+
warnings.push(
|
|
461
|
+
"Option keyboard.allowInEditable: true d\xE9tect\xE9e \u2014 risque de d\xE9tourner Ctrl/Cmd+Z natif dans les zones de saisie (Axiome Primordial)."
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
for (const binding of this.bindings) {
|
|
465
|
+
for (const el of [binding.undoEl, binding.redoEl]) {
|
|
466
|
+
if (!el) continue;
|
|
467
|
+
const hasLabel = Boolean(el.getAttribute("aria-label")?.trim()) || this.checkAriaIdReferences(el, "aria-labelledby", warnings, true) || Boolean(el.textContent?.trim());
|
|
468
|
+
if (!hasLabel) {
|
|
469
|
+
warnings.push(
|
|
470
|
+
`Contr\xF4le Undo/Redo li\xE9 (${el.tagName.toLowerCase()}) sans nom accessible (ajoutez du texte visible, aria-label ou aria-labelledby).`
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
const tabIndexAttr = el.getAttribute("tabindex");
|
|
474
|
+
if (tabIndexAttr !== null) {
|
|
475
|
+
const parsed = Number.parseInt(tabIndexAttr, 10);
|
|
476
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
477
|
+
warnings.push(`\xC9vitez tabindex="${parsed}" (> 0) sur un contr\xF4le Undo/Redo.`);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return warnings;
|
|
483
|
+
}
|
|
484
|
+
getAuditPrefix() {
|
|
485
|
+
return "Wulf.Undo";
|
|
486
|
+
}
|
|
487
|
+
getAuditTargetLabel() {
|
|
488
|
+
return `UndoManager (${this.stack.length} \xE9tat(s))`;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Détruit l'instance : purge les listeners clavier, délie tous les contrôles,
|
|
492
|
+
* supprime la live-region et libère la pile mémoire.
|
|
493
|
+
*/
|
|
494
|
+
destroy() {
|
|
495
|
+
if (this.isDestroyed) return;
|
|
496
|
+
this.isDestroyed = true;
|
|
497
|
+
if (this.abortController) {
|
|
498
|
+
this.abortController.abort();
|
|
499
|
+
this.abortController = null;
|
|
500
|
+
}
|
|
501
|
+
for (const binding of Array.from(this.bindings)) {
|
|
502
|
+
binding.unbind();
|
|
503
|
+
}
|
|
504
|
+
this.bindings.clear();
|
|
505
|
+
if (this.announceTimerId !== null) {
|
|
506
|
+
clearTimeout(this.announceTimerId);
|
|
507
|
+
this.announceTimerId = null;
|
|
508
|
+
}
|
|
509
|
+
if (this.srStatusEl) {
|
|
510
|
+
this.srStatusEl.remove();
|
|
511
|
+
this.srStatusEl = null;
|
|
512
|
+
}
|
|
513
|
+
this.stack = [];
|
|
514
|
+
this.index = -1;
|
|
515
|
+
this.batchPendingState = void 0;
|
|
516
|
+
}
|
|
517
|
+
// --- Implémentation interne ---
|
|
518
|
+
cloneState(value) {
|
|
519
|
+
if (this.cloneStrategy === "none") {
|
|
520
|
+
return value;
|
|
521
|
+
}
|
|
522
|
+
if (typeof this.cloneStrategy === "function") {
|
|
523
|
+
return this.cloneStrategy(value);
|
|
524
|
+
}
|
|
525
|
+
try {
|
|
526
|
+
return structuredClone(value);
|
|
527
|
+
} catch (err) {
|
|
528
|
+
throw new TypeError(
|
|
529
|
+
`[Wulf.Undo] Impossible de cloner l'\xE9tat via structuredClone() (fonction, n\u0153ud DOM ou Proxy non clonable). Utilisez { clone: "none" } ou fournissez une fonction clone personnalis\xE9e.`,
|
|
530
|
+
{ cause: err }
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
trimToMaxDepth() {
|
|
535
|
+
const maxLen = this.maxDepth + 1;
|
|
536
|
+
if (this.stack.length > maxLen) {
|
|
537
|
+
this.stack.splice(0, this.stack.length - maxLen);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
stepTo(targetIndex, action) {
|
|
541
|
+
const prevEntry = this.stack[this.index];
|
|
542
|
+
const nextEntry = this.stack[targetIndex];
|
|
543
|
+
const labelForAction = action === "undo" ? prevEntry?.label : nextEntry?.label;
|
|
544
|
+
this.isApplying = true;
|
|
545
|
+
try {
|
|
546
|
+
this.index = targetIndex;
|
|
547
|
+
this.lastPushTime = -Infinity;
|
|
548
|
+
this.syncControls();
|
|
549
|
+
const nextClone = this.cloneState(nextEntry.state);
|
|
550
|
+
const prevClone = this.cloneState(prevEntry.state);
|
|
551
|
+
if (action === "undo") {
|
|
552
|
+
this.notifyCallback(this.onUndo, "undo", nextClone, prevClone, labelForAction);
|
|
553
|
+
} else if (action === "redo") {
|
|
554
|
+
this.notifyCallback(this.onRedo, "redo", nextClone, prevClone, labelForAction);
|
|
555
|
+
}
|
|
556
|
+
this.notifyCallback(this.onChange, action, nextClone, prevClone, labelForAction);
|
|
557
|
+
if (this.announceEnabled && (action === "undo" || action === "redo")) {
|
|
558
|
+
const dict = this.resolveI18n();
|
|
559
|
+
this.announce(action === "undo" ? dict.undone(labelForAction) : dict.redone(labelForAction));
|
|
560
|
+
}
|
|
561
|
+
return this.cloneState(nextEntry.state);
|
|
562
|
+
} finally {
|
|
563
|
+
this.isApplying = false;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
notifyCallback(cb, action, state, previousState, label) {
|
|
567
|
+
if (typeof cb !== "function") return;
|
|
568
|
+
const detail = {
|
|
569
|
+
state: this.cloneState(state),
|
|
570
|
+
previousState: this.cloneState(previousState),
|
|
571
|
+
action,
|
|
572
|
+
label,
|
|
573
|
+
index: this.index,
|
|
574
|
+
length: this.stack.length,
|
|
575
|
+
canUndo: this.canUndo(),
|
|
576
|
+
canRedo: this.canRedo()
|
|
577
|
+
};
|
|
578
|
+
try {
|
|
579
|
+
cb(detail);
|
|
580
|
+
} catch (err) {
|
|
581
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
582
|
+
if (typeof this.onError === "function") {
|
|
583
|
+
try {
|
|
584
|
+
this.onError(error, action);
|
|
585
|
+
} catch (onErrEx) {
|
|
586
|
+
console.error("[Wulf.Undo] Erreur dans onError :", onErrEx);
|
|
587
|
+
}
|
|
588
|
+
} else {
|
|
589
|
+
console.error(`[Wulf.Undo] Erreur dans callback (${action}) :`, error);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
bindKeyboard() {
|
|
594
|
+
if (!this.keyboardOptions || typeof window === "undefined") return;
|
|
595
|
+
const target = this.keyboardOptions.target ?? window;
|
|
596
|
+
if (!target || typeof target.addEventListener !== "function") return;
|
|
597
|
+
this.abortController = new AbortController();
|
|
598
|
+
target.addEventListener(
|
|
599
|
+
"keydown",
|
|
600
|
+
(ev) => this.handleKeyDown(ev),
|
|
601
|
+
{ capture: false, signal: this.abortController.signal }
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
handleKeyDown(event) {
|
|
605
|
+
if (this.isDestroyed || this.paused || !this.keyboardOptions || event.defaultPrevented || isImeComposing(event)) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
const composed = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
609
|
+
const nodes = composed.length > 0 ? composed : event.target ? [event.target] : [];
|
|
610
|
+
let isEditable = false;
|
|
611
|
+
let isSensitive = false;
|
|
612
|
+
for (const node of nodes) {
|
|
613
|
+
if (!isSensitive && isSensitiveElement(node)) isSensitive = true;
|
|
614
|
+
if (!isEditable && isEditableElement(node)) isEditable = true;
|
|
615
|
+
}
|
|
616
|
+
if (isSensitive) return;
|
|
617
|
+
if (isEditable && !this.keyboardOptions.allowInEditable) return;
|
|
618
|
+
const key = (event.key || "").toLowerCase();
|
|
619
|
+
if (key !== "z" && key !== "y") return;
|
|
620
|
+
const isApple = isApplePlatform();
|
|
621
|
+
const primaryMod = isApple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
|
|
622
|
+
const isUndo = primaryMod && !event.altKey && !event.shiftKey && key === "z";
|
|
623
|
+
const isRedo = primaryMod && !event.altKey && event.shiftKey && key === "z" || !isApple && event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey && key === "y";
|
|
624
|
+
if (isUndo && this.canUndo()) {
|
|
625
|
+
if (this.keyboardOptions.preventDefault !== false) event.preventDefault();
|
|
626
|
+
this.undo();
|
|
627
|
+
} else if (isRedo && this.canRedo()) {
|
|
628
|
+
if (this.keyboardOptions.preventDefault !== false) event.preventDefault();
|
|
629
|
+
this.redo();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
captureControlAttrs(el, labelAttr) {
|
|
633
|
+
return {
|
|
634
|
+
hadDisabled: el.hasAttribute("disabled"),
|
|
635
|
+
prevDisabled: el.disabled ?? false,
|
|
636
|
+
hadAriaDisabled: el.hasAttribute("aria-disabled"),
|
|
637
|
+
prevAriaDisabled: el.getAttribute("aria-disabled"),
|
|
638
|
+
hadAriaKeyShortcuts: el.hasAttribute("aria-keyshortcuts"),
|
|
639
|
+
prevAriaKeyShortcuts: el.getAttribute("aria-keyshortcuts"),
|
|
640
|
+
hadLabelAttr: el.hasAttribute(labelAttr),
|
|
641
|
+
prevLabelAttr: el.getAttribute(labelAttr)
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
restoreControlAttrs(el, labelAttr, saved) {
|
|
645
|
+
if ("disabled" in el) {
|
|
646
|
+
if (saved.hadDisabled) {
|
|
647
|
+
el.disabled = saved.prevDisabled;
|
|
648
|
+
} else {
|
|
649
|
+
el.removeAttribute("disabled");
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
if (saved.hadAriaDisabled && saved.prevAriaDisabled !== null) {
|
|
653
|
+
el.setAttribute("aria-disabled", saved.prevAriaDisabled);
|
|
654
|
+
} else {
|
|
655
|
+
el.removeAttribute("aria-disabled");
|
|
656
|
+
}
|
|
657
|
+
if (saved.hadAriaKeyShortcuts && saved.prevAriaKeyShortcuts !== null) {
|
|
658
|
+
el.setAttribute("aria-keyshortcuts", saved.prevAriaKeyShortcuts);
|
|
659
|
+
} else {
|
|
660
|
+
el.removeAttribute("aria-keyshortcuts");
|
|
661
|
+
}
|
|
662
|
+
if (saved.hadLabelAttr && saved.prevLabelAttr !== null) {
|
|
663
|
+
el.setAttribute(labelAttr, saved.prevLabelAttr);
|
|
664
|
+
} else {
|
|
665
|
+
el.removeAttribute(labelAttr);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
applyControlState(el, enabled, opts, keyShortcut, labelAttr, actionLabel) {
|
|
669
|
+
if (opts.useNativeDisabled && "disabled" in el) {
|
|
670
|
+
el.disabled = !enabled;
|
|
671
|
+
el.removeAttribute("aria-disabled");
|
|
672
|
+
} else {
|
|
673
|
+
el.setAttribute("aria-disabled", enabled ? "false" : "true");
|
|
674
|
+
}
|
|
675
|
+
if (opts.updateAriaKeyShortcuts) {
|
|
676
|
+
el.setAttribute("aria-keyshortcuts", keyShortcut);
|
|
677
|
+
}
|
|
678
|
+
if (opts.updateLabelAttribute) {
|
|
679
|
+
if (actionLabel) el.setAttribute(labelAttr, actionLabel);
|
|
680
|
+
else el.removeAttribute(labelAttr);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
syncControls() {
|
|
684
|
+
for (const binding of this.bindings) {
|
|
685
|
+
binding.sync();
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
resolveI18n() {
|
|
689
|
+
if (this.langOverride) {
|
|
690
|
+
const prev = undoI18n.getLocale();
|
|
691
|
+
undoI18n.setLocale(this.langOverride);
|
|
692
|
+
const dict = undoI18n.getAll(this.i18nOverrides);
|
|
693
|
+
undoI18n.setLocale(prev);
|
|
694
|
+
return dict;
|
|
695
|
+
}
|
|
696
|
+
return undoI18n.getAll(this.i18nOverrides);
|
|
697
|
+
}
|
|
698
|
+
mountStatusRegion() {
|
|
699
|
+
if (typeof document === "undefined" || this.srStatusEl) return;
|
|
700
|
+
const status = document.createElement("div");
|
|
701
|
+
status.setAttribute("role", "status");
|
|
702
|
+
status.setAttribute("aria-live", "polite");
|
|
703
|
+
status.setAttribute("aria-atomic", "true");
|
|
704
|
+
status.setAttribute("data-wulf-undo-status", "true");
|
|
705
|
+
status.style.position = "absolute";
|
|
706
|
+
status.style.width = "1px";
|
|
707
|
+
status.style.height = "1px";
|
|
708
|
+
status.style.overflow = "hidden";
|
|
709
|
+
status.style.clipPath = "inset(50%)";
|
|
710
|
+
status.style.whiteSpace = "nowrap";
|
|
711
|
+
status.style.pointerEvents = "none";
|
|
712
|
+
let target = null;
|
|
713
|
+
if (this.announceRoot) {
|
|
714
|
+
if (typeof ShadowRoot !== "undefined" && this.announceRoot instanceof ShadowRoot) {
|
|
715
|
+
target = this.announceRoot;
|
|
716
|
+
} else if (typeof HTMLElement !== "undefined" && this.announceRoot instanceof HTMLElement) {
|
|
717
|
+
target = this.announceRoot;
|
|
718
|
+
} else if (typeof Document !== "undefined" && this.announceRoot instanceof Document) {
|
|
719
|
+
target = this.announceRoot.body || this.announceRoot.documentElement;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if (!target) {
|
|
723
|
+
target = document.body || document.documentElement;
|
|
724
|
+
}
|
|
725
|
+
if (!target) return;
|
|
726
|
+
target.appendChild(status);
|
|
727
|
+
this.srStatusEl = status;
|
|
728
|
+
}
|
|
729
|
+
announce(message) {
|
|
730
|
+
if (this.isDestroyed || typeof document === "undefined") return;
|
|
731
|
+
const clean = stripBidiAndInvisibles(message, 400).trim();
|
|
732
|
+
if (!clean) return;
|
|
733
|
+
const docWithNotify = document;
|
|
734
|
+
if (typeof docWithNotify.ariaNotify === "function") {
|
|
735
|
+
try {
|
|
736
|
+
docWithNotify.ariaNotify(clean, { priority: "normal" });
|
|
737
|
+
return;
|
|
738
|
+
} catch {
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if (!this.srStatusEl) {
|
|
742
|
+
this.mountStatusRegion();
|
|
743
|
+
}
|
|
744
|
+
if (!this.srStatusEl) return;
|
|
745
|
+
if (this.announceTimerId !== null) {
|
|
746
|
+
clearTimeout(this.announceTimerId);
|
|
747
|
+
this.announceTimerId = null;
|
|
748
|
+
}
|
|
749
|
+
this.srStatusEl.textContent = "";
|
|
750
|
+
this.announceTimerId = setTimeout(() => {
|
|
751
|
+
this.announceTimerId = null;
|
|
752
|
+
if (!this.isDestroyed && this.srStatusEl) {
|
|
753
|
+
this.srStatusEl.textContent = clean;
|
|
754
|
+
}
|
|
755
|
+
}, 40);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
export {
|
|
760
|
+
undoFr,
|
|
761
|
+
undoEn,
|
|
762
|
+
undoI18n,
|
|
763
|
+
UndoManager,
|
|
764
|
+
undo_exports
|
|
765
|
+
};
|
|
766
|
+
//# sourceMappingURL=chunk-5N2IRGDM.js.map
|