@zag-js/number-input 0.0.0-dev-20220605192656 → 0.0.0-dev-20220612194202
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 +2 -54
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +2 -54
- package/dist/index.mjs.map +2 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -162,30 +162,6 @@ function getEventStep(event) {
|
|
|
162
162
|
return isSkipKey ? 10 : 1;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
function itemById(v, id) {
|
|
166
|
-
return v.find((node) => node.id === id);
|
|
167
|
-
}
|
|
168
|
-
function indexOfId(v, id) {
|
|
169
|
-
const item = itemById(v, id);
|
|
170
|
-
return item ? v.indexOf(item) : -1;
|
|
171
|
-
}
|
|
172
|
-
var getValueText = (item) => {
|
|
173
|
-
var _a, _b;
|
|
174
|
-
return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
|
|
175
|
-
};
|
|
176
|
-
var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
|
|
177
|
-
var wrap = (v, idx) => {
|
|
178
|
-
return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
|
|
179
|
-
};
|
|
180
|
-
function findByText(v, text, currentId) {
|
|
181
|
-
const index = currentId ? indexOfId(v, currentId) : -1;
|
|
182
|
-
let items = currentId ? wrap(v, index) : v;
|
|
183
|
-
const isSingleKey = text.length === 1;
|
|
184
|
-
if (isSingleKey) {
|
|
185
|
-
items = items.filter((item) => item.id !== currentId);
|
|
186
|
-
}
|
|
187
|
-
return items.find((item) => match(getValueText(item), text));
|
|
188
|
-
}
|
|
189
165
|
function addPointerlockChangeListener(doc, fn) {
|
|
190
166
|
return addDomEvent(doc, "pointerlockchange", fn, false);
|
|
191
167
|
}
|
|
@@ -226,38 +202,10 @@ function requestPointerLock(doc, handlers = {}) {
|
|
|
226
202
|
exit();
|
|
227
203
|
};
|
|
228
204
|
}
|
|
229
|
-
function findByTypeahead(_items, options) {
|
|
230
|
-
const { state: state2, activeId, key, timeout = 350 } = options;
|
|
231
|
-
const search = state2.keysSoFar + key;
|
|
232
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
233
|
-
const query2 = isRepeated ? search[0] : search;
|
|
234
|
-
let items = _items.slice();
|
|
235
|
-
const next = findByText(items, query2, activeId);
|
|
236
|
-
function cleanup() {
|
|
237
|
-
clearTimeout(state2.timer);
|
|
238
|
-
state2.timer = -1;
|
|
239
|
-
}
|
|
240
|
-
function update(value) {
|
|
241
|
-
state2.keysSoFar = value;
|
|
242
|
-
cleanup();
|
|
243
|
-
if (value !== "") {
|
|
244
|
-
state2.timer = +setTimeout(() => {
|
|
245
|
-
update("");
|
|
246
|
-
cleanup();
|
|
247
|
-
}, timeout);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
update(search);
|
|
251
|
-
return next;
|
|
252
|
-
}
|
|
253
|
-
findByTypeahead.defaultOptions = {
|
|
254
|
-
keysSoFar: "",
|
|
255
|
-
timer: -1
|
|
256
|
-
};
|
|
257
205
|
|
|
258
206
|
// ../../utilities/number/dist/index.mjs
|
|
259
207
|
var __pow = Math.pow;
|
|
260
|
-
function
|
|
208
|
+
function wrap(num, max) {
|
|
261
209
|
return (num % max + max) % max;
|
|
262
210
|
}
|
|
263
211
|
function roundToDevicePixel(num) {
|
|
@@ -421,7 +369,7 @@ var dom = {
|
|
|
421
369
|
const win = dom.getWin(ctx);
|
|
422
370
|
const width = win.innerWidth;
|
|
423
371
|
const half = roundToDevicePixel(7.5);
|
|
424
|
-
point.x =
|
|
372
|
+
point.x = wrap(point.x + half, width) - half;
|
|
425
373
|
return { hint, point };
|
|
426
374
|
},
|
|
427
375
|
createVirtualCursor(ctx) {
|