@zag-js/slider 0.0.0-dev-20220504084708 → 0.0.0-dev-20220508172505
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/index.js +53 -1
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +53 -1
- package/dist/index.mjs.map +3 -3
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -285,6 +285,30 @@ function getEventStep(event) {
|
|
|
285
285
|
return isSkipKey ? 10 : 1;
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
+
function itemById(v, id) {
|
|
289
|
+
return v.find((node) => node.id === id);
|
|
290
|
+
}
|
|
291
|
+
function indexOfId(v, id) {
|
|
292
|
+
const item = itemById(v, id);
|
|
293
|
+
return item ? v.indexOf(item) : -1;
|
|
294
|
+
}
|
|
295
|
+
var getValueText = (item) => {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
|
|
298
|
+
};
|
|
299
|
+
var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
|
|
300
|
+
var wrap = (v, idx) => {
|
|
301
|
+
return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
|
|
302
|
+
};
|
|
303
|
+
function findByText(v, text, currentId) {
|
|
304
|
+
const index = currentId ? indexOfId(v, currentId) : -1;
|
|
305
|
+
let items = currentId ? wrap(v, index) : v;
|
|
306
|
+
const isSingleKey = text.length === 1;
|
|
307
|
+
if (isSingleKey) {
|
|
308
|
+
items = items.filter((item) => item.id !== currentId);
|
|
309
|
+
}
|
|
310
|
+
return items.find((item) => match(getValueText(item), text));
|
|
311
|
+
}
|
|
288
312
|
var state = "default";
|
|
289
313
|
var savedUserSelect = "";
|
|
290
314
|
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -348,6 +372,34 @@ function trackPointerMove(opts) {
|
|
|
348
372
|
};
|
|
349
373
|
return pipe(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
|
|
350
374
|
}
|
|
375
|
+
function findByTypeahead(_items, options) {
|
|
376
|
+
const { state: state2, activeId, key, timeout = 350 } = options;
|
|
377
|
+
const search = state2.keysSoFar + key;
|
|
378
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
379
|
+
const query2 = isRepeated ? search[0] : search;
|
|
380
|
+
let items = _items.slice();
|
|
381
|
+
const next = findByText(items, query2, activeId);
|
|
382
|
+
function cleanup() {
|
|
383
|
+
clearTimeout(state2.timer);
|
|
384
|
+
state2.timer = -1;
|
|
385
|
+
}
|
|
386
|
+
function update(value) {
|
|
387
|
+
state2.keysSoFar = value;
|
|
388
|
+
cleanup();
|
|
389
|
+
if (value !== "") {
|
|
390
|
+
state2.timer = +setTimeout(() => {
|
|
391
|
+
update("");
|
|
392
|
+
cleanup();
|
|
393
|
+
}, timeout);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
update(search);
|
|
397
|
+
return next;
|
|
398
|
+
}
|
|
399
|
+
findByTypeahead.defaultOptions = {
|
|
400
|
+
keysSoFar: "",
|
|
401
|
+
timer: -1
|
|
402
|
+
};
|
|
351
403
|
|
|
352
404
|
// ../../utilities/number/dist/index.mjs
|
|
353
405
|
var __pow2 = Math.pow;
|
|
@@ -583,7 +635,7 @@ var normalizeProp = createNormalizer((v) => v);
|
|
|
583
635
|
|
|
584
636
|
// ../../utilities/core/dist/index.mjs
|
|
585
637
|
var isLeftClick2 = (v) => v.button === 0;
|
|
586
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey
|
|
638
|
+
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
587
639
|
|
|
588
640
|
// src/slider.connect.ts
|
|
589
641
|
function connect(state2, send, normalize = normalizeProp) {
|