@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.js
CHANGED
|
@@ -309,6 +309,30 @@ function getEventStep(event) {
|
|
|
309
309
|
return isSkipKey ? 10 : 1;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
+
function itemById(v, id) {
|
|
313
|
+
return v.find((node) => node.id === id);
|
|
314
|
+
}
|
|
315
|
+
function indexOfId(v, id) {
|
|
316
|
+
const item = itemById(v, id);
|
|
317
|
+
return item ? v.indexOf(item) : -1;
|
|
318
|
+
}
|
|
319
|
+
var getValueText = (item) => {
|
|
320
|
+
var _a, _b;
|
|
321
|
+
return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
|
|
322
|
+
};
|
|
323
|
+
var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
|
|
324
|
+
var wrap = (v, idx) => {
|
|
325
|
+
return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
|
|
326
|
+
};
|
|
327
|
+
function findByText(v, text, currentId) {
|
|
328
|
+
const index = currentId ? indexOfId(v, currentId) : -1;
|
|
329
|
+
let items = currentId ? wrap(v, index) : v;
|
|
330
|
+
const isSingleKey = text.length === 1;
|
|
331
|
+
if (isSingleKey) {
|
|
332
|
+
items = items.filter((item) => item.id !== currentId);
|
|
333
|
+
}
|
|
334
|
+
return items.find((item) => match(getValueText(item), text));
|
|
335
|
+
}
|
|
312
336
|
var state = "default";
|
|
313
337
|
var savedUserSelect = "";
|
|
314
338
|
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -372,6 +396,34 @@ function trackPointerMove(opts) {
|
|
|
372
396
|
};
|
|
373
397
|
return pipe(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
|
|
374
398
|
}
|
|
399
|
+
function findByTypeahead(_items, options) {
|
|
400
|
+
const { state: state2, activeId, key, timeout = 350 } = options;
|
|
401
|
+
const search = state2.keysSoFar + key;
|
|
402
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
403
|
+
const query2 = isRepeated ? search[0] : search;
|
|
404
|
+
let items = _items.slice();
|
|
405
|
+
const next = findByText(items, query2, activeId);
|
|
406
|
+
function cleanup() {
|
|
407
|
+
clearTimeout(state2.timer);
|
|
408
|
+
state2.timer = -1;
|
|
409
|
+
}
|
|
410
|
+
function update(value) {
|
|
411
|
+
state2.keysSoFar = value;
|
|
412
|
+
cleanup();
|
|
413
|
+
if (value !== "") {
|
|
414
|
+
state2.timer = +setTimeout(() => {
|
|
415
|
+
update("");
|
|
416
|
+
cleanup();
|
|
417
|
+
}, timeout);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
update(search);
|
|
421
|
+
return next;
|
|
422
|
+
}
|
|
423
|
+
findByTypeahead.defaultOptions = {
|
|
424
|
+
keysSoFar: "",
|
|
425
|
+
timer: -1
|
|
426
|
+
};
|
|
375
427
|
|
|
376
428
|
// ../../utilities/number/dist/index.mjs
|
|
377
429
|
var __pow2 = Math.pow;
|
|
@@ -607,7 +659,7 @@ var normalizeProp = createNormalizer((v) => v);
|
|
|
607
659
|
|
|
608
660
|
// ../../utilities/core/dist/index.mjs
|
|
609
661
|
var isLeftClick2 = (v) => v.button === 0;
|
|
610
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey
|
|
662
|
+
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
611
663
|
|
|
612
664
|
// src/slider.connect.ts
|
|
613
665
|
function connect(state2, send, normalize = normalizeProp) {
|