intelliwaketssveltekitv25 1.0.51 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Functions.d.ts +1 -4
- package/dist/Functions.js +37 -33
- package/package.json +1 -1
package/dist/Functions.d.ts
CHANGED
|
@@ -34,10 +34,7 @@ export declare const DoIDsMatch: (a: any, b: any) => boolean;
|
|
|
34
34
|
* - `update(nextEnabled: boolean)`: Updates the enabled state.
|
|
35
35
|
* - `destroy()`: Cancels the auto-focus behavior and cleans up resources.
|
|
36
36
|
*/
|
|
37
|
-
export declare function autoFocus(el: HTMLElement | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
|
|
38
|
-
update(nextEnabled: boolean): void;
|
|
39
|
-
destroy(): void;
|
|
40
|
-
};
|
|
37
|
+
export declare function autoFocus(el: HTMLElement | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | never): void;
|
|
41
38
|
export declare function autoGrow(node: HTMLTextAreaElement, _value?: string | null): {
|
|
42
39
|
update(): void;
|
|
43
40
|
destroy(): void;
|
package/dist/Functions.js
CHANGED
|
@@ -184,42 +184,46 @@ export const DoIDsMatch = (a, b) => IsEqual(a, b) || IsEqual(a?.id, b?.id);
|
|
|
184
184
|
* - `update(nextEnabled: boolean)`: Updates the enabled state.
|
|
185
185
|
* - `destroy()`: Cancels the auto-focus behavior and cleans up resources.
|
|
186
186
|
*/
|
|
187
|
-
export function autoFocus(el, enabled = true) {
|
|
188
|
-
let cancelled = false;
|
|
189
|
-
async function run() {
|
|
190
|
-
if (!enabled)
|
|
191
|
-
return;
|
|
192
|
-
await tick();
|
|
193
|
-
if (cancelled)
|
|
194
|
-
return;
|
|
195
|
-
// Avoid focusing detached nodes
|
|
196
|
-
if (!el.isConnected)
|
|
197
|
-
return;
|
|
198
|
-
// Sometimes modals need the next frame (transitions/portals)
|
|
199
|
-
requestAnimationFrame(() => {
|
|
200
|
-
if (!cancelled)
|
|
201
|
-
el.focus();
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
void run();
|
|
205
|
-
return {
|
|
206
|
-
update(nextEnabled) {
|
|
207
|
-
enabled = nextEnabled;
|
|
208
|
-
void run();
|
|
209
|
-
},
|
|
210
|
-
destroy() {
|
|
211
|
-
cancelled = true;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
187
|
// export function autoFocus(
|
|
216
|
-
// el: HTMLElement | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
|
|
188
|
+
// el: HTMLElement | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement,
|
|
189
|
+
// enabled: boolean = true
|
|
217
190
|
// ) {
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
191
|
+
// let cancelled = false
|
|
192
|
+
//
|
|
193
|
+
// async function run() {
|
|
194
|
+
// if (!enabled) return
|
|
195
|
+
//
|
|
196
|
+
// await tick()
|
|
197
|
+
// if (cancelled) return
|
|
198
|
+
//
|
|
199
|
+
// // Avoid focusing detached nodes
|
|
200
|
+
// if (!el.isConnected) return
|
|
201
|
+
//
|
|
202
|
+
// // Sometimes modals need the next frame (transitions/portals)
|
|
203
|
+
// requestAnimationFrame(() => {
|
|
204
|
+
// if (!cancelled) el.focus()
|
|
205
|
+
// })
|
|
206
|
+
// }
|
|
207
|
+
//
|
|
208
|
+
// void run()
|
|
209
|
+
//
|
|
210
|
+
// return {
|
|
211
|
+
// update(nextEnabled: boolean) {
|
|
212
|
+
// enabled = nextEnabled
|
|
213
|
+
// void run()
|
|
214
|
+
// },
|
|
215
|
+
// destroy() {
|
|
216
|
+
// cancelled = true
|
|
217
|
+
// }
|
|
218
|
+
// }
|
|
222
219
|
// }
|
|
220
|
+
export function autoFocus(el) {
|
|
221
|
+
tick().then(() => {
|
|
222
|
+
if (!el)
|
|
223
|
+
console.error('autoFocus el not available');
|
|
224
|
+
el?.focus();
|
|
225
|
+
});
|
|
226
|
+
}
|
|
223
227
|
export function autoGrow(node, _value) {
|
|
224
228
|
let userResized = false;
|
|
225
229
|
let pointerDown = false;
|