@aviala-design/spiral 2.6.0 → 2.6.2
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/component-changelogs.json +108 -8
- package/dist/index.cjs +370 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +386 -137
- package/dist/index.js.map +1 -1
- package/dist/styles.css +231 -187
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6005,8 +6005,8 @@ function CascaderField({
|
|
|
6005
6005
|
// src/components/date-picker/date-picker.tsx
|
|
6006
6006
|
import * as PopoverPrimitive4 from "@radix-ui/react-popover";
|
|
6007
6007
|
import {
|
|
6008
|
-
|
|
6009
|
-
|
|
6008
|
+
DirectionArrowLeftLight as DirectionArrowLeftLight2,
|
|
6009
|
+
DirectionArrowRightLight as DirectionArrowRightLight2,
|
|
6010
6010
|
TimeAndDateClock,
|
|
6011
6011
|
TimeAndDateDate
|
|
6012
6012
|
} from "@aviala-design/icons";
|
|
@@ -6237,7 +6237,70 @@ import {
|
|
|
6237
6237
|
// src/lib/sticky-wheel.ts
|
|
6238
6238
|
var WHEEL_STICKY_AMOUNT = 0.45;
|
|
6239
6239
|
var WHEEL_SCROLL_END_MS = 100;
|
|
6240
|
-
var WHEEL_STEP_THRESHOLD_FACTOR = 0.
|
|
6240
|
+
var WHEEL_STEP_THRESHOLD_FACTOR = 0.35;
|
|
6241
|
+
var WHEEL_ACCUM_IDLE_MS = 140;
|
|
6242
|
+
var WHEEL_LOOP_SECTIONS = 3;
|
|
6243
|
+
var WHEEL_LOOP_MIDDLE_SECTION = 1;
|
|
6244
|
+
function consumeWheelSteps(accum, deltaY, threshold) {
|
|
6245
|
+
if (!(threshold > 0) || !Number.isFinite(deltaY) || deltaY === 0) {
|
|
6246
|
+
return { nextAccum: accum, steps: 0 };
|
|
6247
|
+
}
|
|
6248
|
+
let nextAccum = accum;
|
|
6249
|
+
if (nextAccum !== 0 && Math.sign(nextAccum) !== Math.sign(deltaY)) {
|
|
6250
|
+
nextAccum = 0;
|
|
6251
|
+
}
|
|
6252
|
+
nextAccum += deltaY;
|
|
6253
|
+
const steps = Math.trunc(nextAccum / threshold);
|
|
6254
|
+
if (steps === 0) {
|
|
6255
|
+
return { nextAccum, steps: 0 };
|
|
6256
|
+
}
|
|
6257
|
+
nextAccum -= steps * threshold;
|
|
6258
|
+
return { nextAccum, steps };
|
|
6259
|
+
}
|
|
6260
|
+
function normalizeWheelIndex(index, length) {
|
|
6261
|
+
if (length <= 0) return 0;
|
|
6262
|
+
return (index % length + length) % length;
|
|
6263
|
+
}
|
|
6264
|
+
function recenterLoopIndex(rawIndex, length, middleSection = WHEEL_LOOP_MIDDLE_SECTION) {
|
|
6265
|
+
if (length <= 0) return 0;
|
|
6266
|
+
return middleSection * length + normalizeWheelIndex(rawIndex, length);
|
|
6267
|
+
}
|
|
6268
|
+
function nearestLoopIndex(currentRawIndex, valueIndex, length, sections = WHEEL_LOOP_SECTIONS, preferDelta = 0) {
|
|
6269
|
+
if (length <= 0 || sections <= 0) return 0;
|
|
6270
|
+
const slot = normalizeWheelIndex(valueIndex, length);
|
|
6271
|
+
let best = slot;
|
|
6272
|
+
let bestScore = Number.POSITIVE_INFINITY;
|
|
6273
|
+
for (let section = 0; section < sections; section += 1) {
|
|
6274
|
+
const candidate = section * length + slot;
|
|
6275
|
+
const distance = Math.abs(candidate - currentRawIndex);
|
|
6276
|
+
const directionBias = preferDelta === 0 ? 0 : Math.sign(candidate - currentRawIndex) === Math.sign(preferDelta) ? -0.25 : 0.25;
|
|
6277
|
+
const score = distance + directionBias;
|
|
6278
|
+
if (score < bestScore) {
|
|
6279
|
+
bestScore = score;
|
|
6280
|
+
best = candidate;
|
|
6281
|
+
}
|
|
6282
|
+
}
|
|
6283
|
+
return best;
|
|
6284
|
+
}
|
|
6285
|
+
function stepLoopRawIndex(currentRawIndex, steps, length, sections = WHEEL_LOOP_SECTIONS, middleSection = WHEEL_LOOP_MIDDLE_SECTION) {
|
|
6286
|
+
if (length <= 0) return { rawIndex: 0, didRecenter: false };
|
|
6287
|
+
const maxIndex = sections * length - 1;
|
|
6288
|
+
let rawIndex = currentRawIndex;
|
|
6289
|
+
let didRecenter = false;
|
|
6290
|
+
const section = Math.floor(rawIndex / length);
|
|
6291
|
+
if (section !== middleSection) {
|
|
6292
|
+
rawIndex = recenterLoopIndex(rawIndex, length, middleSection);
|
|
6293
|
+
didRecenter = true;
|
|
6294
|
+
}
|
|
6295
|
+
const next = rawIndex + steps;
|
|
6296
|
+
if (next < 0 || next > maxIndex) {
|
|
6297
|
+
return {
|
|
6298
|
+
rawIndex: recenterLoopIndex(next, length, middleSection),
|
|
6299
|
+
didRecenter: true
|
|
6300
|
+
};
|
|
6301
|
+
}
|
|
6302
|
+
return { rawIndex: next, didRecenter };
|
|
6303
|
+
}
|
|
6241
6304
|
function stickyRemapProgress(t, amount) {
|
|
6242
6305
|
const clamped = Math.max(0, Math.min(1, t));
|
|
6243
6306
|
if (amount <= 0) return clamped;
|
|
@@ -6256,14 +6319,11 @@ function stickyRoundIndex(fractionalIndex, stickiness = WHEEL_STICKY_AMOUNT) {
|
|
|
6256
6319
|
|
|
6257
6320
|
// src/components/date-picker/date-picker-time-wheel.tsx
|
|
6258
6321
|
import { jsx as jsx40, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6259
|
-
var LOOP_SECTIONS =
|
|
6260
|
-
var MIDDLE_SECTION =
|
|
6322
|
+
var LOOP_SECTIONS = WHEEL_LOOP_SECTIONS;
|
|
6323
|
+
var MIDDLE_SECTION = WHEEL_LOOP_MIDDLE_SECTION;
|
|
6261
6324
|
function formatWheelValue(value) {
|
|
6262
6325
|
return String(value).padStart(2, "0");
|
|
6263
6326
|
}
|
|
6264
|
-
function normalizeIndex(index, length) {
|
|
6265
|
-
return (index % length + length) % length;
|
|
6266
|
-
}
|
|
6267
6327
|
function getValueIndex(values, value) {
|
|
6268
6328
|
const index = values.indexOf(value);
|
|
6269
6329
|
if (index >= 0) return index;
|
|
@@ -6301,17 +6361,28 @@ function DatePickerTimeWheelColumn({
|
|
|
6301
6361
|
layoutKey = 0
|
|
6302
6362
|
}) {
|
|
6303
6363
|
const scrollRef = useRef8(null);
|
|
6364
|
+
const clipTrackRef = useRef8(null);
|
|
6304
6365
|
const isUserScrollingRef = useRef8(false);
|
|
6305
6366
|
const isProgrammaticScrollRef = useRef8(false);
|
|
6306
6367
|
const smoothTargetValueRef = useRef8(null);
|
|
6307
6368
|
const scrollEndTimerRef = useRef8(void 0);
|
|
6308
6369
|
const wheelAccumRef = useRef8(0);
|
|
6370
|
+
const wheelAccumIdleTimerRef = useRef8(void 0);
|
|
6309
6371
|
const selectedValueRef = useRef8(value);
|
|
6310
6372
|
selectedValueRef.current = value;
|
|
6311
6373
|
const repeatedValues = useMemo6(() => {
|
|
6312
6374
|
if (!loop) return [...values];
|
|
6313
6375
|
return Array.from({ length: LOOP_SECTIONS }, () => values).flat();
|
|
6314
6376
|
}, [loop, values]);
|
|
6377
|
+
const readRawIndex2 = useCallback11((container, itemHeight) => {
|
|
6378
|
+
return Math.round(container.scrollTop / itemHeight);
|
|
6379
|
+
}, []);
|
|
6380
|
+
const syncClipTrack = useCallback11(() => {
|
|
6381
|
+
const container = scrollRef.current;
|
|
6382
|
+
const track = clipTrackRef.current;
|
|
6383
|
+
if (!container || !track) return;
|
|
6384
|
+
track.style.transform = `translate3d(0, ${-container.scrollTop}px, 0)`;
|
|
6385
|
+
}, []);
|
|
6315
6386
|
const scrollToIndex = useCallback11(
|
|
6316
6387
|
(index, behavior = "auto") => {
|
|
6317
6388
|
const container = scrollRef.current;
|
|
@@ -6320,21 +6391,13 @@ function DatePickerTimeWheelColumn({
|
|
|
6320
6391
|
if (itemHeight <= 0) return;
|
|
6321
6392
|
isProgrammaticScrollRef.current = true;
|
|
6322
6393
|
container.scrollTo({ top: index * itemHeight, behavior });
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
);
|
|
6326
|
-
const scrollToValue = useCallback11(
|
|
6327
|
-
(nextValue, behavior = "smooth") => {
|
|
6328
|
-
if (behavior === "smooth") {
|
|
6329
|
-
smoothTargetValueRef.current = nextValue;
|
|
6394
|
+
if (behavior === "auto") {
|
|
6395
|
+
syncClipTrack();
|
|
6330
6396
|
} else {
|
|
6331
|
-
|
|
6397
|
+
requestAnimationFrame(syncClipTrack);
|
|
6332
6398
|
}
|
|
6333
|
-
const valueIndex = getValueIndex(values, nextValue);
|
|
6334
|
-
const targetIndex = loop ? values.length * MIDDLE_SECTION + valueIndex : valueIndex;
|
|
6335
|
-
scrollToIndex(targetIndex, behavior);
|
|
6336
6399
|
},
|
|
6337
|
-
[
|
|
6400
|
+
[syncClipTrack]
|
|
6338
6401
|
);
|
|
6339
6402
|
const syncScrollToValue = useCallback11(
|
|
6340
6403
|
(behavior = "auto") => {
|
|
@@ -6347,24 +6410,27 @@ function DatePickerTimeWheelColumn({
|
|
|
6347
6410
|
const itemHeight = readItemHeight(container);
|
|
6348
6411
|
if (itemHeight <= 0) return;
|
|
6349
6412
|
const valueIndex = getValueIndex(values, selectedValueRef.current);
|
|
6350
|
-
const
|
|
6351
|
-
const
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6413
|
+
const currentIndex = readRawIndex2(container, itemHeight);
|
|
6414
|
+
const currentValueIndex = loop ? normalizeWheelIndex(currentIndex, values.length) : Math.min(Math.max(currentIndex, 0), values.length - 1);
|
|
6415
|
+
if (currentValueIndex === valueIndex) {
|
|
6416
|
+
syncClipTrack();
|
|
6417
|
+
return;
|
|
6418
|
+
}
|
|
6419
|
+
const targetIndex = loop ? nearestLoopIndex(currentIndex, valueIndex, values.length, LOOP_SECTIONS) : valueIndex;
|
|
6355
6420
|
scrollToIndex(targetIndex, behavior);
|
|
6356
6421
|
},
|
|
6357
|
-
[loop, scrollToIndex, values]
|
|
6422
|
+
[loop, readRawIndex2, scrollToIndex, syncClipTrack, values]
|
|
6358
6423
|
);
|
|
6359
6424
|
const settleScroll = useCallback11(() => {
|
|
6360
6425
|
const container = scrollRef.current;
|
|
6361
|
-
if (!container
|
|
6362
|
-
|
|
6426
|
+
if (!container) return;
|
|
6427
|
+
const wasProgrammatic = isProgrammaticScrollRef.current;
|
|
6428
|
+
isProgrammaticScrollRef.current = false;
|
|
6429
|
+
const itemHeight = readItemHeight(container);
|
|
6430
|
+
if (itemHeight <= 0 || values.length === 0) {
|
|
6363
6431
|
smoothTargetValueRef.current = null;
|
|
6364
6432
|
return;
|
|
6365
6433
|
}
|
|
6366
|
-
const itemHeight = readItemHeight(container);
|
|
6367
|
-
if (itemHeight <= 0 || values.length === 0) return;
|
|
6368
6434
|
const lastIndex = values.length - 1;
|
|
6369
6435
|
const maxScroll = Math.max(container.scrollHeight - container.clientHeight, 0);
|
|
6370
6436
|
const fractionalIndex = container.scrollTop / itemHeight;
|
|
@@ -6376,12 +6442,21 @@ function DatePickerTimeWheelColumn({
|
|
|
6376
6442
|
rawIndex = 0;
|
|
6377
6443
|
}
|
|
6378
6444
|
}
|
|
6379
|
-
const valueIndex = loop ?
|
|
6445
|
+
const valueIndex = loop ? normalizeWheelIndex(rawIndex, values.length) : Math.min(Math.max(rawIndex, 0), lastIndex);
|
|
6380
6446
|
const nextValue = values[valueIndex];
|
|
6381
|
-
const targetIndex = loop ? values.length
|
|
6447
|
+
const targetIndex = loop ? recenterLoopIndex(rawIndex, values.length, MIDDLE_SECTION) : valueIndex;
|
|
6382
6448
|
const targetTop = targetIndex * itemHeight;
|
|
6383
6449
|
const section = loop ? Math.floor(rawIndex / values.length) : MIDDLE_SECTION;
|
|
6384
6450
|
const needsLoopRecenter = loop && section !== MIDDLE_SECTION;
|
|
6451
|
+
if (wasProgrammatic) {
|
|
6452
|
+
if (needsLoopRecenter) {
|
|
6453
|
+
isProgrammaticScrollRef.current = true;
|
|
6454
|
+
container.scrollTop = targetTop;
|
|
6455
|
+
}
|
|
6456
|
+
smoothTargetValueRef.current = null;
|
|
6457
|
+
syncClipTrack();
|
|
6458
|
+
return;
|
|
6459
|
+
}
|
|
6385
6460
|
const needsSnap = Math.abs(container.scrollTop - targetTop) > 1;
|
|
6386
6461
|
if (needsLoopRecenter) {
|
|
6387
6462
|
isProgrammaticScrollRef.current = true;
|
|
@@ -6399,22 +6474,26 @@ function DatePickerTimeWheelColumn({
|
|
|
6399
6474
|
}
|
|
6400
6475
|
isUserScrollingRef.current = false;
|
|
6401
6476
|
wheelAccumRef.current = 0;
|
|
6402
|
-
|
|
6477
|
+
syncClipTrack();
|
|
6478
|
+
}, [loop, onChange, syncClipTrack, values]);
|
|
6403
6479
|
const handleScroll = useCallback11(() => {
|
|
6480
|
+
syncClipTrack();
|
|
6404
6481
|
if (isProgrammaticScrollRef.current) return;
|
|
6405
6482
|
isUserScrollingRef.current = true;
|
|
6406
6483
|
if (scrollEndTimerRef.current) {
|
|
6407
6484
|
clearTimeout(scrollEndTimerRef.current);
|
|
6408
6485
|
}
|
|
6409
6486
|
scrollEndTimerRef.current = setTimeout(settleScroll, WHEEL_SCROLL_END_MS);
|
|
6410
|
-
}, [settleScroll]);
|
|
6487
|
+
}, [settleScroll, syncClipTrack]);
|
|
6411
6488
|
useLayoutEffect5(() => {
|
|
6412
6489
|
syncScrollToValue("auto");
|
|
6490
|
+
syncClipTrack();
|
|
6413
6491
|
const raf = requestAnimationFrame(() => {
|
|
6414
6492
|
syncScrollToValue("auto");
|
|
6493
|
+
syncClipTrack();
|
|
6415
6494
|
});
|
|
6416
6495
|
return () => cancelAnimationFrame(raf);
|
|
6417
|
-
}, [layoutKey, syncScrollToValue, value]);
|
|
6496
|
+
}, [layoutKey, syncClipTrack, syncScrollToValue, value]);
|
|
6418
6497
|
useEffect8(() => {
|
|
6419
6498
|
const container = scrollRef.current;
|
|
6420
6499
|
if (!container) return;
|
|
@@ -6442,23 +6521,48 @@ function DatePickerTimeWheelColumn({
|
|
|
6442
6521
|
if (!container) return;
|
|
6443
6522
|
const onWheel = (event) => {
|
|
6444
6523
|
event.preventDefault();
|
|
6445
|
-
if (
|
|
6524
|
+
if (values.length === 0) return;
|
|
6446
6525
|
const itemHeight = readItemHeight(container);
|
|
6447
6526
|
if (itemHeight <= 0) return;
|
|
6448
|
-
|
|
6527
|
+
if (wheelAccumIdleTimerRef.current) {
|
|
6528
|
+
clearTimeout(wheelAccumIdleTimerRef.current);
|
|
6529
|
+
}
|
|
6530
|
+
wheelAccumIdleTimerRef.current = setTimeout(() => {
|
|
6531
|
+
wheelAccumRef.current = 0;
|
|
6532
|
+
}, WHEEL_ACCUM_IDLE_MS);
|
|
6449
6533
|
const threshold = itemHeight * WHEEL_STEP_THRESHOLD_FACTOR;
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6534
|
+
const { nextAccum, steps } = consumeWheelSteps(
|
|
6535
|
+
wheelAccumRef.current,
|
|
6536
|
+
event.deltaY,
|
|
6537
|
+
threshold
|
|
6538
|
+
);
|
|
6539
|
+
wheelAccumRef.current = nextAccum;
|
|
6540
|
+
if (steps === 0) return;
|
|
6541
|
+
const currentRaw = readRawIndex2(container, itemHeight);
|
|
6542
|
+
let targetRaw;
|
|
6543
|
+
if (loop) {
|
|
6544
|
+
if (Math.floor(currentRaw / values.length) !== MIDDLE_SECTION) {
|
|
6545
|
+
isProgrammaticScrollRef.current = true;
|
|
6546
|
+
container.scrollTop = recenterLoopIndex(currentRaw, values.length, MIDDLE_SECTION) * itemHeight;
|
|
6547
|
+
}
|
|
6548
|
+
targetRaw = stepLoopRawIndex(
|
|
6549
|
+
readRawIndex2(container, itemHeight),
|
|
6550
|
+
steps,
|
|
6551
|
+
values.length,
|
|
6552
|
+
LOOP_SECTIONS,
|
|
6553
|
+
MIDDLE_SECTION
|
|
6554
|
+
).rawIndex;
|
|
6555
|
+
} else {
|
|
6556
|
+
targetRaw = Math.min(Math.max(currentRaw + steps, 0), values.length - 1);
|
|
6557
|
+
if (targetRaw === currentRaw) return;
|
|
6558
|
+
}
|
|
6456
6559
|
if (scrollEndTimerRef.current) {
|
|
6457
6560
|
clearTimeout(scrollEndTimerRef.current);
|
|
6458
6561
|
}
|
|
6459
|
-
const nextValue = values[
|
|
6562
|
+
const nextValue = values[normalizeWheelIndex(targetRaw, values.length)];
|
|
6460
6563
|
isUserScrollingRef.current = false;
|
|
6461
|
-
|
|
6564
|
+
smoothTargetValueRef.current = nextValue;
|
|
6565
|
+
scrollToIndex(targetRaw, "smooth");
|
|
6462
6566
|
if (nextValue !== selectedValueRef.current) {
|
|
6463
6567
|
onChange(nextValue);
|
|
6464
6568
|
}
|
|
@@ -6466,35 +6570,49 @@ function DatePickerTimeWheelColumn({
|
|
|
6466
6570
|
container.addEventListener("wheel", onWheel, { passive: false });
|
|
6467
6571
|
return () => {
|
|
6468
6572
|
container.removeEventListener("wheel", onWheel);
|
|
6573
|
+
if (wheelAccumIdleTimerRef.current) {
|
|
6574
|
+
clearTimeout(wheelAccumIdleTimerRef.current);
|
|
6575
|
+
}
|
|
6469
6576
|
};
|
|
6470
|
-
}, [loop, onChange,
|
|
6577
|
+
}, [loop, onChange, readRawIndex2, scrollToIndex, values]);
|
|
6471
6578
|
const handleKeyDown = (event) => {
|
|
6472
|
-
const
|
|
6473
|
-
|
|
6579
|
+
const container = scrollRef.current;
|
|
6580
|
+
if (!container || values.length === 0) return;
|
|
6581
|
+
const itemHeight = readItemHeight(container);
|
|
6582
|
+
if (itemHeight <= 0) return;
|
|
6583
|
+
const currentRaw = readRawIndex2(container, itemHeight);
|
|
6584
|
+
let targetRaw = null;
|
|
6585
|
+
let preferDelta = 0;
|
|
6474
6586
|
switch (event.key) {
|
|
6475
6587
|
case "ArrowUp":
|
|
6476
|
-
|
|
6588
|
+
preferDelta = -1;
|
|
6589
|
+
targetRaw = loop ? stepLoopRawIndex(currentRaw, -1, values.length, LOOP_SECTIONS, MIDDLE_SECTION).rawIndex : Math.max(currentRaw - 1, 0);
|
|
6477
6590
|
break;
|
|
6478
6591
|
case "ArrowDown":
|
|
6479
|
-
|
|
6592
|
+
preferDelta = 1;
|
|
6593
|
+
targetRaw = loop ? stepLoopRawIndex(currentRaw, 1, values.length, LOOP_SECTIONS, MIDDLE_SECTION).rawIndex : Math.min(currentRaw + 1, values.length - 1);
|
|
6480
6594
|
break;
|
|
6481
6595
|
case "Home":
|
|
6482
|
-
|
|
6596
|
+
targetRaw = loop ? nearestLoopIndex(currentRaw, 0, values.length, LOOP_SECTIONS, -1) : 0;
|
|
6483
6597
|
break;
|
|
6484
6598
|
case "End":
|
|
6485
|
-
|
|
6599
|
+
targetRaw = loop ? nearestLoopIndex(currentRaw, values.length - 1, values.length, LOOP_SECTIONS, 1) : values.length - 1;
|
|
6486
6600
|
break;
|
|
6487
6601
|
default:
|
|
6488
6602
|
return;
|
|
6489
6603
|
}
|
|
6490
6604
|
event.preventDefault();
|
|
6491
|
-
|
|
6492
|
-
|
|
6605
|
+
if (targetRaw === currentRaw && preferDelta === 0) return;
|
|
6606
|
+
const nextValue = values[normalizeWheelIndex(targetRaw, values.length)];
|
|
6607
|
+
isUserScrollingRef.current = false;
|
|
6608
|
+
smoothTargetValueRef.current = nextValue;
|
|
6609
|
+
scrollToIndex(targetRaw, "smooth");
|
|
6493
6610
|
if (nextValue !== selectedValueRef.current) {
|
|
6494
6611
|
onChange(nextValue);
|
|
6495
6612
|
}
|
|
6496
6613
|
};
|
|
6497
|
-
const
|
|
6614
|
+
const committedIndex = getValueIndex(values, value);
|
|
6615
|
+
const selectedOptionId = loop ? `${ariaLabel}-${value}-${values.length * MIDDLE_SECTION + committedIndex}` : `${ariaLabel}-${value}`;
|
|
6498
6616
|
return /* @__PURE__ */ jsxs26("div", { className: cn("aviala-datepicker-time__wheel", className), children: [
|
|
6499
6617
|
/* @__PURE__ */ jsx40("div", { className: "aviala-datepicker-time__wheel-highlight", "aria-hidden": true }),
|
|
6500
6618
|
/* @__PURE__ */ jsx40(
|
|
@@ -6523,15 +6641,15 @@ function DatePickerTimeWheelColumn({
|
|
|
6523
6641
|
tabIndex: 0,
|
|
6524
6642
|
onKeyDown: handleKeyDown,
|
|
6525
6643
|
children: /* @__PURE__ */ jsx40("ul", { className: "aviala-datepicker-time__wheel-list", children: repeatedValues.map((itemValue, index) => {
|
|
6526
|
-
const
|
|
6644
|
+
const isCommitted = itemValue === value;
|
|
6527
6645
|
const optionId = loop ? `${ariaLabel}-${itemValue}-${index}` : `${ariaLabel}-${itemValue}`;
|
|
6528
6646
|
return /* @__PURE__ */ jsx40(
|
|
6529
6647
|
"li",
|
|
6530
6648
|
{
|
|
6531
|
-
id: optionId,
|
|
6649
|
+
id: loop && isCommitted && Math.floor(index / values.length) === MIDDLE_SECTION ? selectedOptionId : optionId,
|
|
6532
6650
|
className: "aviala-datepicker-time__wheel-item",
|
|
6533
6651
|
role: "option",
|
|
6534
|
-
"aria-selected":
|
|
6652
|
+
"aria-selected": isCommitted,
|
|
6535
6653
|
children: /* @__PURE__ */ jsx40(
|
|
6536
6654
|
"button",
|
|
6537
6655
|
{
|
|
@@ -6540,10 +6658,12 @@ function DatePickerTimeWheelColumn({
|
|
|
6540
6658
|
"aviala-datepicker-time__wheel-option",
|
|
6541
6659
|
typographyVariants({ level: "text" })
|
|
6542
6660
|
),
|
|
6543
|
-
"data-selected":
|
|
6661
|
+
"data-selected": isCommitted ? "true" : void 0,
|
|
6544
6662
|
tabIndex: -1,
|
|
6545
6663
|
onClick: () => {
|
|
6546
|
-
|
|
6664
|
+
isUserScrollingRef.current = false;
|
|
6665
|
+
smoothTargetValueRef.current = itemValue;
|
|
6666
|
+
scrollToIndex(index, "smooth");
|
|
6547
6667
|
if (itemValue !== selectedValueRef.current) {
|
|
6548
6668
|
onChange(itemValue);
|
|
6549
6669
|
}
|
|
@@ -6556,7 +6676,18 @@ function DatePickerTimeWheelColumn({
|
|
|
6556
6676
|
);
|
|
6557
6677
|
}) })
|
|
6558
6678
|
}
|
|
6559
|
-
)
|
|
6679
|
+
),
|
|
6680
|
+
/* @__PURE__ */ jsx40("div", { className: "aviala-datepicker-time__wheel-clip", "aria-hidden": true, children: /* @__PURE__ */ jsx40("div", { ref: clipTrackRef, className: "aviala-datepicker-time__wheel-clip-track", children: repeatedValues.map((itemValue, index) => /* @__PURE__ */ jsx40(
|
|
6681
|
+
"div",
|
|
6682
|
+
{
|
|
6683
|
+
className: cn(
|
|
6684
|
+
"aviala-datepicker-time__wheel-clip-item",
|
|
6685
|
+
typographyVariants({ level: "text" })
|
|
6686
|
+
),
|
|
6687
|
+
children: formatValue(itemValue)
|
|
6688
|
+
},
|
|
6689
|
+
`clip-${loop ? `${itemValue}-${index}` : itemValue}`
|
|
6690
|
+
)) }) })
|
|
6560
6691
|
] });
|
|
6561
6692
|
}
|
|
6562
6693
|
|
|
@@ -7292,8 +7423,8 @@ function DatePickerCalendar({ className }) {
|
|
|
7292
7423
|
const { code } = useLocale();
|
|
7293
7424
|
const locale = useLocaleMessages("DatePicker");
|
|
7294
7425
|
const rtl = useRtl();
|
|
7295
|
-
const PrevIcon = rtl ?
|
|
7296
|
-
const NextIcon = rtl ?
|
|
7426
|
+
const PrevIcon = rtl ? DirectionArrowRightLight2 : DirectionArrowLeftLight2;
|
|
7427
|
+
const NextIcon = rtl ? DirectionArrowLeftLight2 : DirectionArrowRightLight2;
|
|
7297
7428
|
const {
|
|
7298
7429
|
mode,
|
|
7299
7430
|
viewMonth,
|
|
@@ -7315,6 +7446,10 @@ function DatePickerCalendar({ className }) {
|
|
|
7315
7446
|
const dayGridRef = useRef9(null);
|
|
7316
7447
|
const pendingDayFocusRef = useRef9(false);
|
|
7317
7448
|
const [monthSlide, setMonthSlide] = useState13(null);
|
|
7449
|
+
const [prevNavAnimKey, setPrevNavAnimKey] = useState13(0);
|
|
7450
|
+
const [nextNavAnimKey, setNextNavAnimKey] = useState13(0);
|
|
7451
|
+
const [prevNavAnimating, setPrevNavAnimating] = useState13(false);
|
|
7452
|
+
const [nextNavAnimating, setNextNavAnimating] = useState13(false);
|
|
7318
7453
|
const isMonthPanel = activePanel === "month";
|
|
7319
7454
|
const isTimePanel = activePanel === "time" && enableTime;
|
|
7320
7455
|
const targetContentView = isMonthPanel ? "month" : "date";
|
|
@@ -7565,8 +7700,23 @@ function DatePickerCalendar({ className }) {
|
|
|
7565
7700
|
type: "button",
|
|
7566
7701
|
className: "aviala-datepicker-calendar__nav aviala-focus-ring",
|
|
7567
7702
|
"aria-label": isMonthPanel ? locale.previousYear : locale.previousMonth,
|
|
7568
|
-
onClick: () =>
|
|
7569
|
-
|
|
7703
|
+
onClick: () => {
|
|
7704
|
+
if (!prefersReducedMotion2()) {
|
|
7705
|
+
setPrevNavAnimKey((n) => n + 1);
|
|
7706
|
+
setPrevNavAnimating(true);
|
|
7707
|
+
}
|
|
7708
|
+
setViewMonth(addMonths(viewMonth, -stepMonth));
|
|
7709
|
+
},
|
|
7710
|
+
children: /* @__PURE__ */ jsx43("span", { className: "aviala-datepicker-calendar__nav-icon", children: /* @__PURE__ */ jsx43(
|
|
7711
|
+
"span",
|
|
7712
|
+
{
|
|
7713
|
+
className: "aviala-datepicker-calendar__nav-icon-inner",
|
|
7714
|
+
"data-anim": prevNavAnimating ? "prev" : void 0,
|
|
7715
|
+
onAnimationEnd: () => setPrevNavAnimating(false),
|
|
7716
|
+
children: /* @__PURE__ */ jsx43(PrevIcon, { level: "text", biggerSize: true, "aria-hidden": true })
|
|
7717
|
+
},
|
|
7718
|
+
prevNavAnimKey
|
|
7719
|
+
) })
|
|
7570
7720
|
}
|
|
7571
7721
|
),
|
|
7572
7722
|
/* @__PURE__ */ jsx43(
|
|
@@ -7599,8 +7749,23 @@ function DatePickerCalendar({ className }) {
|
|
|
7599
7749
|
type: "button",
|
|
7600
7750
|
className: "aviala-datepicker-calendar__nav aviala-focus-ring",
|
|
7601
7751
|
"aria-label": isMonthPanel ? locale.nextYear : locale.nextMonth,
|
|
7602
|
-
onClick: () =>
|
|
7603
|
-
|
|
7752
|
+
onClick: () => {
|
|
7753
|
+
if (!prefersReducedMotion2()) {
|
|
7754
|
+
setNextNavAnimKey((n) => n + 1);
|
|
7755
|
+
setNextNavAnimating(true);
|
|
7756
|
+
}
|
|
7757
|
+
setViewMonth(addMonths(viewMonth, stepMonth));
|
|
7758
|
+
},
|
|
7759
|
+
children: /* @__PURE__ */ jsx43("span", { className: "aviala-datepicker-calendar__nav-icon", children: /* @__PURE__ */ jsx43(
|
|
7760
|
+
"span",
|
|
7761
|
+
{
|
|
7762
|
+
className: "aviala-datepicker-calendar__nav-icon-inner",
|
|
7763
|
+
"data-anim": nextNavAnimating ? "next" : void 0,
|
|
7764
|
+
onAnimationEnd: () => setNextNavAnimating(false),
|
|
7765
|
+
children: /* @__PURE__ */ jsx43(NextIcon, { level: "text", biggerSize: true, "aria-hidden": true })
|
|
7766
|
+
},
|
|
7767
|
+
nextNavAnimKey
|
|
7768
|
+
) })
|
|
7604
7769
|
}
|
|
7605
7770
|
)
|
|
7606
7771
|
] }),
|
|
@@ -8957,8 +9122,8 @@ Alert.displayName = "Alert";
|
|
|
8957
9122
|
|
|
8958
9123
|
// src/components/list.tsx
|
|
8959
9124
|
import {
|
|
8960
|
-
DirectionArrowLeftLight as
|
|
8961
|
-
DirectionArrowRightLight as
|
|
9125
|
+
DirectionArrowLeftLight as DirectionArrowLeftLight3,
|
|
9126
|
+
DirectionArrowRightLight as DirectionArrowRightLight3,
|
|
8962
9127
|
GeneralSetting
|
|
8963
9128
|
} from "@aviala-design/icons";
|
|
8964
9129
|
import {
|
|
@@ -9054,7 +9219,7 @@ var ListItem = forwardRef35(
|
|
|
9054
9219
|
}, ref) => {
|
|
9055
9220
|
const locale = useLocaleMessages("List");
|
|
9056
9221
|
const rtl = useRtl();
|
|
9057
|
-
const ChevronIcon = rtl ?
|
|
9222
|
+
const ChevronIcon = rtl ? DirectionArrowLeftLight3 : DirectionArrowRightLight3;
|
|
9058
9223
|
const isInteractive = interactive ?? (onClick != null || href != null);
|
|
9059
9224
|
const chevronVisible = showChevron ?? itemType === "action";
|
|
9060
9225
|
const primaryAction = action ?? /* @__PURE__ */ jsx53(Button, { mode: "primary", size: "regular", leftIcon: /* @__PURE__ */ jsx53(GeneralSetting, { "aria-hidden": true }), children: actionLabel });
|
|
@@ -10462,11 +10627,8 @@ import {
|
|
|
10462
10627
|
useRef as useRef16
|
|
10463
10628
|
} from "react";
|
|
10464
10629
|
import { jsx as jsx57, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
10465
|
-
var LOOP_SECTIONS2 =
|
|
10466
|
-
var MIDDLE_SECTION2 =
|
|
10467
|
-
function normalizeIndex2(index, length) {
|
|
10468
|
-
return (index % length + length) % length;
|
|
10469
|
-
}
|
|
10630
|
+
var LOOP_SECTIONS2 = WHEEL_LOOP_SECTIONS;
|
|
10631
|
+
var MIDDLE_SECTION2 = WHEEL_LOOP_MIDDLE_SECTION;
|
|
10470
10632
|
function readMetrics(container) {
|
|
10471
10633
|
const items = container.querySelectorAll(".aviala-scroll-picker-item");
|
|
10472
10634
|
const first = items[0];
|
|
@@ -10488,6 +10650,9 @@ function scrollTopForIndex(container, metrics, index) {
|
|
|
10488
10650
|
function fractionalIndexAtScrollTop(metrics, scrollTop) {
|
|
10489
10651
|
return (scrollTop - metrics.originTop) / metrics.pitch;
|
|
10490
10652
|
}
|
|
10653
|
+
function readRawIndex(container, metrics) {
|
|
10654
|
+
return Math.round(fractionalIndexAtScrollTop(metrics, container.scrollTop));
|
|
10655
|
+
}
|
|
10491
10656
|
function ScrollPicker({ className, children, ...props }) {
|
|
10492
10657
|
return /* @__PURE__ */ jsx57("div", { className: cn("aviala-scroll-picker", className), ...props, children });
|
|
10493
10658
|
}
|
|
@@ -10502,11 +10667,13 @@ function ScrollPickerColumn({
|
|
|
10502
10667
|
getValueKey
|
|
10503
10668
|
}) {
|
|
10504
10669
|
const scrollRef = useRef16(null);
|
|
10670
|
+
const clipTrackRef = useRef16(null);
|
|
10505
10671
|
const isUserScrollingRef = useRef16(false);
|
|
10506
10672
|
const isProgrammaticScrollRef = useRef16(false);
|
|
10507
10673
|
const smoothTargetValueRef = useRef16(null);
|
|
10508
10674
|
const scrollEndTimerRef = useRef16(void 0);
|
|
10509
10675
|
const wheelAccumRef = useRef16(0);
|
|
10676
|
+
const wheelAccumIdleTimerRef = useRef16(void 0);
|
|
10510
10677
|
const selectedValueRef = useRef16(value);
|
|
10511
10678
|
const reactId = useId5();
|
|
10512
10679
|
selectedValueRef.current = value;
|
|
@@ -10521,36 +10688,43 @@ function ScrollPickerColumn({
|
|
|
10521
10688
|
if (!loop) return [...values];
|
|
10522
10689
|
return Array.from({ length: LOOP_SECTIONS2 }, () => values).flat();
|
|
10523
10690
|
}, [loop, values]);
|
|
10524
|
-
const
|
|
10691
|
+
const syncClipTrack = useCallback19(() => {
|
|
10525
10692
|
const container = scrollRef.current;
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10693
|
+
const track = clipTrackRef.current;
|
|
10694
|
+
if (!container || !track) return;
|
|
10695
|
+
const band = container.parentElement?.querySelector(
|
|
10696
|
+
".aviala-scroll-picker-column__highlight"
|
|
10697
|
+
);
|
|
10698
|
+
const bandHeight = band?.offsetHeight || 26;
|
|
10699
|
+
const offset = container.scrollTop + (container.clientHeight - bandHeight) / 2;
|
|
10700
|
+
track.style.transform = `translate3d(0, ${-offset}px, 0)`;
|
|
10531
10701
|
}, []);
|
|
10532
|
-
const
|
|
10533
|
-
(
|
|
10534
|
-
|
|
10535
|
-
|
|
10702
|
+
const scrollToIndex = useCallback19(
|
|
10703
|
+
(index, behavior = "auto") => {
|
|
10704
|
+
const container = scrollRef.current;
|
|
10705
|
+
if (!container) return;
|
|
10706
|
+
const metrics = readMetrics(container);
|
|
10707
|
+
if (!metrics) return;
|
|
10708
|
+
isProgrammaticScrollRef.current = true;
|
|
10709
|
+
container.scrollTo({ top: scrollTopForIndex(container, metrics, index), behavior });
|
|
10710
|
+
if (behavior === "auto") {
|
|
10711
|
+
syncClipTrack();
|
|
10536
10712
|
} else {
|
|
10537
|
-
|
|
10713
|
+
requestAnimationFrame(syncClipTrack);
|
|
10538
10714
|
}
|
|
10539
|
-
const valueIndex = getIndex(nextValue);
|
|
10540
|
-
const targetIndex = loop ? values.length * MIDDLE_SECTION2 + valueIndex : valueIndex;
|
|
10541
|
-
scrollToIndex(targetIndex, behavior);
|
|
10542
10715
|
},
|
|
10543
|
-
[
|
|
10716
|
+
[syncClipTrack]
|
|
10544
10717
|
);
|
|
10545
10718
|
const settleScroll = useCallback19(() => {
|
|
10546
10719
|
const container = scrollRef.current;
|
|
10547
|
-
if (!container
|
|
10548
|
-
|
|
10720
|
+
if (!container) return;
|
|
10721
|
+
const wasProgrammatic = isProgrammaticScrollRef.current;
|
|
10722
|
+
isProgrammaticScrollRef.current = false;
|
|
10723
|
+
const metrics = readMetrics(container);
|
|
10724
|
+
if (!metrics || values.length === 0) {
|
|
10549
10725
|
smoothTargetValueRef.current = null;
|
|
10550
10726
|
return;
|
|
10551
10727
|
}
|
|
10552
|
-
const metrics = readMetrics(container);
|
|
10553
|
-
if (!metrics || values.length === 0) return;
|
|
10554
10728
|
const lastIndex = values.length - 1;
|
|
10555
10729
|
const maxScroll = Math.max(container.scrollHeight - container.clientHeight, 0);
|
|
10556
10730
|
let rawIndex = stickyRoundIndex(
|
|
@@ -10564,12 +10738,21 @@ function ScrollPickerColumn({
|
|
|
10564
10738
|
rawIndex = 0;
|
|
10565
10739
|
}
|
|
10566
10740
|
}
|
|
10567
|
-
const valueIndex = loop ?
|
|
10741
|
+
const valueIndex = loop ? normalizeWheelIndex(rawIndex, values.length) : Math.min(Math.max(rawIndex, 0), lastIndex);
|
|
10568
10742
|
const nextValue = values[valueIndex];
|
|
10569
|
-
const targetIndex = loop ? values.length
|
|
10743
|
+
const targetIndex = loop ? recenterLoopIndex(rawIndex, values.length, MIDDLE_SECTION2) : valueIndex;
|
|
10570
10744
|
const targetTop = scrollTopForIndex(container, metrics, targetIndex);
|
|
10571
10745
|
const section = loop ? Math.floor(rawIndex / values.length) : MIDDLE_SECTION2;
|
|
10572
10746
|
const needsLoopRecenter = loop && section !== MIDDLE_SECTION2;
|
|
10747
|
+
if (wasProgrammatic) {
|
|
10748
|
+
if (needsLoopRecenter) {
|
|
10749
|
+
isProgrammaticScrollRef.current = true;
|
|
10750
|
+
container.scrollTop = targetTop;
|
|
10751
|
+
}
|
|
10752
|
+
smoothTargetValueRef.current = null;
|
|
10753
|
+
syncClipTrack();
|
|
10754
|
+
return;
|
|
10755
|
+
}
|
|
10573
10756
|
const needsSnap = Math.abs(container.scrollTop - targetTop) > 1;
|
|
10574
10757
|
if (needsLoopRecenter) {
|
|
10575
10758
|
isProgrammaticScrollRef.current = true;
|
|
@@ -10587,15 +10770,17 @@ function ScrollPickerColumn({
|
|
|
10587
10770
|
}
|
|
10588
10771
|
isUserScrollingRef.current = false;
|
|
10589
10772
|
wheelAccumRef.current = 0;
|
|
10590
|
-
|
|
10773
|
+
syncClipTrack();
|
|
10774
|
+
}, [loop, onChange, syncClipTrack, values]);
|
|
10591
10775
|
const handleScroll = useCallback19(() => {
|
|
10776
|
+
syncClipTrack();
|
|
10592
10777
|
if (isProgrammaticScrollRef.current) return;
|
|
10593
10778
|
isUserScrollingRef.current = true;
|
|
10594
10779
|
if (scrollEndTimerRef.current) {
|
|
10595
10780
|
clearTimeout(scrollEndTimerRef.current);
|
|
10596
10781
|
}
|
|
10597
10782
|
scrollEndTimerRef.current = setTimeout(settleScroll, WHEEL_SCROLL_END_MS);
|
|
10598
|
-
}, [settleScroll]);
|
|
10783
|
+
}, [settleScroll, syncClipTrack]);
|
|
10599
10784
|
useLayoutEffect9(() => {
|
|
10600
10785
|
if (isUserScrollingRef.current) return;
|
|
10601
10786
|
if (smoothTargetValueRef.current != null && Object.is(smoothTargetValueRef.current, value)) {
|
|
@@ -10606,11 +10791,20 @@ function ScrollPickerColumn({
|
|
|
10606
10791
|
const metrics = readMetrics(container);
|
|
10607
10792
|
if (!metrics) return;
|
|
10608
10793
|
const valueIndex = getIndex(value);
|
|
10609
|
-
const
|
|
10794
|
+
const currentRaw = readRawIndex(container, metrics);
|
|
10795
|
+
const currentValueIndex = loop ? normalizeWheelIndex(currentRaw, values.length) : Math.min(Math.max(currentRaw, 0), values.length - 1);
|
|
10796
|
+
if (currentValueIndex === valueIndex) {
|
|
10797
|
+
syncClipTrack();
|
|
10798
|
+
return;
|
|
10799
|
+
}
|
|
10800
|
+
const targetIndex = loop ? nearestLoopIndex(currentRaw, valueIndex, values.length, LOOP_SECTIONS2) : valueIndex;
|
|
10610
10801
|
const targetTop = scrollTopForIndex(container, metrics, targetIndex);
|
|
10611
|
-
if (Math.abs(container.scrollTop - targetTop) <= 1)
|
|
10802
|
+
if (Math.abs(container.scrollTop - targetTop) <= 1) {
|
|
10803
|
+
syncClipTrack();
|
|
10804
|
+
return;
|
|
10805
|
+
}
|
|
10612
10806
|
scrollToIndex(targetIndex, "auto");
|
|
10613
|
-
}, [getIndex, loop, scrollToIndex, value, values.length]);
|
|
10807
|
+
}, [getIndex, loop, scrollToIndex, syncClipTrack, value, values.length]);
|
|
10614
10808
|
useEffect16(() => {
|
|
10615
10809
|
const container = scrollRef.current;
|
|
10616
10810
|
if (!container) return;
|
|
@@ -10633,23 +10827,52 @@ function ScrollPickerColumn({
|
|
|
10633
10827
|
if (!container) return;
|
|
10634
10828
|
const onWheel = (event) => {
|
|
10635
10829
|
event.preventDefault();
|
|
10636
|
-
if (
|
|
10830
|
+
if (values.length === 0) return;
|
|
10637
10831
|
const metrics = readMetrics(container);
|
|
10638
10832
|
if (!metrics) return;
|
|
10639
|
-
|
|
10833
|
+
if (wheelAccumIdleTimerRef.current) {
|
|
10834
|
+
clearTimeout(wheelAccumIdleTimerRef.current);
|
|
10835
|
+
}
|
|
10836
|
+
wheelAccumIdleTimerRef.current = setTimeout(() => {
|
|
10837
|
+
wheelAccumRef.current = 0;
|
|
10838
|
+
}, WHEEL_ACCUM_IDLE_MS);
|
|
10640
10839
|
const threshold = metrics.pitch * WHEEL_STEP_THRESHOLD_FACTOR;
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10840
|
+
const { nextAccum, steps } = consumeWheelSteps(
|
|
10841
|
+
wheelAccumRef.current,
|
|
10842
|
+
event.deltaY,
|
|
10843
|
+
threshold
|
|
10844
|
+
);
|
|
10845
|
+
wheelAccumRef.current = nextAccum;
|
|
10846
|
+
if (steps === 0) return;
|
|
10847
|
+
const currentRaw = readRawIndex(container, metrics);
|
|
10848
|
+
let targetRaw;
|
|
10849
|
+
if (loop) {
|
|
10850
|
+
if (Math.floor(currentRaw / values.length) !== MIDDLE_SECTION2) {
|
|
10851
|
+
isProgrammaticScrollRef.current = true;
|
|
10852
|
+
container.scrollTop = scrollTopForIndex(
|
|
10853
|
+
container,
|
|
10854
|
+
metrics,
|
|
10855
|
+
recenterLoopIndex(currentRaw, values.length, MIDDLE_SECTION2)
|
|
10856
|
+
);
|
|
10857
|
+
}
|
|
10858
|
+
targetRaw = stepLoopRawIndex(
|
|
10859
|
+
readRawIndex(container, metrics),
|
|
10860
|
+
steps,
|
|
10861
|
+
values.length,
|
|
10862
|
+
LOOP_SECTIONS2,
|
|
10863
|
+
MIDDLE_SECTION2
|
|
10864
|
+
).rawIndex;
|
|
10865
|
+
} else {
|
|
10866
|
+
targetRaw = Math.min(Math.max(currentRaw + steps, 0), values.length - 1);
|
|
10867
|
+
if (targetRaw === currentRaw) return;
|
|
10868
|
+
}
|
|
10647
10869
|
if (scrollEndTimerRef.current) {
|
|
10648
10870
|
clearTimeout(scrollEndTimerRef.current);
|
|
10649
10871
|
}
|
|
10650
|
-
const nextValue = values[
|
|
10872
|
+
const nextValue = values[normalizeWheelIndex(targetRaw, values.length)];
|
|
10651
10873
|
isUserScrollingRef.current = false;
|
|
10652
|
-
|
|
10874
|
+
smoothTargetValueRef.current = nextValue;
|
|
10875
|
+
scrollToIndex(targetRaw, "smooth");
|
|
10653
10876
|
if (!Object.is(nextValue, selectedValueRef.current)) {
|
|
10654
10877
|
onChange(nextValue);
|
|
10655
10878
|
}
|
|
@@ -10657,30 +10880,39 @@ function ScrollPickerColumn({
|
|
|
10657
10880
|
container.addEventListener("wheel", onWheel, { passive: false });
|
|
10658
10881
|
return () => {
|
|
10659
10882
|
container.removeEventListener("wheel", onWheel);
|
|
10883
|
+
if (wheelAccumIdleTimerRef.current) {
|
|
10884
|
+
clearTimeout(wheelAccumIdleTimerRef.current);
|
|
10885
|
+
}
|
|
10660
10886
|
};
|
|
10661
|
-
}, [
|
|
10887
|
+
}, [loop, onChange, scrollToIndex, values]);
|
|
10662
10888
|
const handleKeyDown = (event) => {
|
|
10663
|
-
const
|
|
10664
|
-
|
|
10889
|
+
const container = scrollRef.current;
|
|
10890
|
+
if (!container || values.length === 0) return;
|
|
10891
|
+
const metrics = readMetrics(container);
|
|
10892
|
+
if (!metrics) return;
|
|
10893
|
+
const currentRaw = readRawIndex(container, metrics);
|
|
10894
|
+
let targetRaw = null;
|
|
10665
10895
|
switch (event.key) {
|
|
10666
10896
|
case "ArrowUp":
|
|
10667
|
-
|
|
10897
|
+
targetRaw = loop ? stepLoopRawIndex(currentRaw, -1, values.length, LOOP_SECTIONS2, MIDDLE_SECTION2).rawIndex : Math.max(currentRaw - 1, 0);
|
|
10668
10898
|
break;
|
|
10669
10899
|
case "ArrowDown":
|
|
10670
|
-
|
|
10900
|
+
targetRaw = loop ? stepLoopRawIndex(currentRaw, 1, values.length, LOOP_SECTIONS2, MIDDLE_SECTION2).rawIndex : Math.min(currentRaw + 1, values.length - 1);
|
|
10671
10901
|
break;
|
|
10672
10902
|
case "Home":
|
|
10673
|
-
|
|
10903
|
+
targetRaw = loop ? nearestLoopIndex(currentRaw, 0, values.length, LOOP_SECTIONS2, -1) : 0;
|
|
10674
10904
|
break;
|
|
10675
10905
|
case "End":
|
|
10676
|
-
|
|
10906
|
+
targetRaw = loop ? nearestLoopIndex(currentRaw, values.length - 1, values.length, LOOP_SECTIONS2, 1) : values.length - 1;
|
|
10677
10907
|
break;
|
|
10678
10908
|
default:
|
|
10679
10909
|
return;
|
|
10680
10910
|
}
|
|
10681
10911
|
event.preventDefault();
|
|
10682
|
-
const nextValue = values[
|
|
10683
|
-
|
|
10912
|
+
const nextValue = values[normalizeWheelIndex(targetRaw, values.length)];
|
|
10913
|
+
isUserScrollingRef.current = false;
|
|
10914
|
+
smoothTargetValueRef.current = nextValue;
|
|
10915
|
+
scrollToIndex(targetRaw, "smooth");
|
|
10684
10916
|
if (!Object.is(nextValue, selectedValueRef.current)) {
|
|
10685
10917
|
onChange(nextValue);
|
|
10686
10918
|
}
|
|
@@ -10700,17 +10932,20 @@ function ScrollPickerColumn({
|
|
|
10700
10932
|
tabIndex: 0,
|
|
10701
10933
|
onKeyDown: handleKeyDown,
|
|
10702
10934
|
children: /* @__PURE__ */ jsx57("ul", { className: "aviala-scroll-picker-column__list", children: repeatedValues.map((itemValue, index) => {
|
|
10703
|
-
const
|
|
10704
|
-
const valueIndex = loop ?
|
|
10935
|
+
const isCommitted = Object.is(itemValue, value);
|
|
10936
|
+
const valueIndex = loop ? normalizeWheelIndex(index, values.length) : index;
|
|
10705
10937
|
const optionId = `${reactId}-${loop ? index : valueIndex}`;
|
|
10706
10938
|
const key = getValueKey?.(itemValue, index) ?? `${String(itemValue)}-${index}`;
|
|
10939
|
+
const useSelectedId = isCommitted && (!loop || Math.floor(index / values.length) === MIDDLE_SECTION2);
|
|
10707
10940
|
return /* @__PURE__ */ jsx57("li", { className: "contents", children: /* @__PURE__ */ jsx57(
|
|
10708
10941
|
ScrollPickerItem,
|
|
10709
10942
|
{
|
|
10710
|
-
id:
|
|
10711
|
-
selected:
|
|
10943
|
+
id: useSelectedId ? selectedOptionId : optionId,
|
|
10944
|
+
selected: isCommitted,
|
|
10712
10945
|
onSelect: () => {
|
|
10713
|
-
|
|
10946
|
+
isUserScrollingRef.current = false;
|
|
10947
|
+
smoothTargetValueRef.current = itemValue;
|
|
10948
|
+
scrollToIndex(index, "smooth");
|
|
10714
10949
|
if (!Object.is(itemValue, selectedValueRef.current)) {
|
|
10715
10950
|
onChange(itemValue);
|
|
10716
10951
|
}
|
|
@@ -10720,7 +10955,21 @@ function ScrollPickerColumn({
|
|
|
10720
10955
|
) }, key);
|
|
10721
10956
|
}) })
|
|
10722
10957
|
}
|
|
10723
|
-
)
|
|
10958
|
+
),
|
|
10959
|
+
/* @__PURE__ */ jsx57("div", { className: "aviala-scroll-picker-column__clip", "aria-hidden": true, children: /* @__PURE__ */ jsx57("div", { ref: clipTrackRef, className: "aviala-scroll-picker-column__clip-track", children: /* @__PURE__ */ jsx57("div", { className: "aviala-scroll-picker-column__list", children: repeatedValues.map((itemValue, index) => {
|
|
10960
|
+
const key = getValueKey?.(itemValue, index) ?? `clip-${String(itemValue)}-${index}`;
|
|
10961
|
+
return /* @__PURE__ */ jsx57(
|
|
10962
|
+
"div",
|
|
10963
|
+
{
|
|
10964
|
+
className: cn(
|
|
10965
|
+
"aviala-scroll-picker-column__clip-item",
|
|
10966
|
+
typographyVariants({ level: "text" })
|
|
10967
|
+
),
|
|
10968
|
+
children: formatValue ? formatValue(itemValue) : String(itemValue)
|
|
10969
|
+
},
|
|
10970
|
+
key
|
|
10971
|
+
);
|
|
10972
|
+
}) }) }) })
|
|
10724
10973
|
] }) });
|
|
10725
10974
|
}
|
|
10726
10975
|
function ScrollPickerItem({
|
|
@@ -10752,8 +11001,8 @@ function ScrollPickerItem({
|
|
|
10752
11001
|
|
|
10753
11002
|
// src/components/breadcrumb.tsx
|
|
10754
11003
|
import {
|
|
10755
|
-
DirectionArrowLeftLight as
|
|
10756
|
-
DirectionArrowRightLight as
|
|
11004
|
+
DirectionArrowLeftLight as DirectionArrowLeftLight4,
|
|
11005
|
+
DirectionArrowRightLight as DirectionArrowRightLight4,
|
|
10757
11006
|
SymbolMore
|
|
10758
11007
|
} from "@aviala-design/icons";
|
|
10759
11008
|
import { cva as cva15 } from "class-variance-authority";
|
|
@@ -10879,7 +11128,7 @@ var BreadcrumbEllipsisItem = forwardRef39(
|
|
|
10879
11128
|
...props
|
|
10880
11129
|
}, ref) => {
|
|
10881
11130
|
const rtl = useRtl();
|
|
10882
|
-
const ChevronIcon = rtl ?
|
|
11131
|
+
const ChevronIcon = rtl ? DirectionArrowLeftLight4 : DirectionArrowRightLight4;
|
|
10883
11132
|
const content = /* @__PURE__ */ jsxs43(Fragment9, { children: [
|
|
10884
11133
|
/* @__PURE__ */ jsx58(Typography, { level: "text", as: "span", className: "aviala-breadcrumb-ellipsis-item__label", children }),
|
|
10885
11134
|
showChevron ? /* @__PURE__ */ jsx58("span", { className: "aviala-breadcrumb-ellipsis-item__chevron", "aria-hidden": true, children: /* @__PURE__ */ jsx58(ChevronIcon, { width: 14, height: 14, thickness: "Light" }) }) : null
|
|
@@ -11115,8 +11364,8 @@ StepsItem.displayName = "StepsItem";
|
|
|
11115
11364
|
|
|
11116
11365
|
// src/components/pagination.tsx
|
|
11117
11366
|
import {
|
|
11118
|
-
DirectionArrowLeftLight as
|
|
11119
|
-
DirectionArrowRightLight as
|
|
11367
|
+
DirectionArrowLeftLight as DirectionArrowLeftLight5,
|
|
11368
|
+
DirectionArrowRightLight as DirectionArrowRightLight5
|
|
11120
11369
|
} from "@aviala-design/icons";
|
|
11121
11370
|
import {
|
|
11122
11371
|
forwardRef as forwardRef42,
|
|
@@ -11175,8 +11424,8 @@ var Pagination = forwardRef42(
|
|
|
11175
11424
|
}, ref) => {
|
|
11176
11425
|
const locale = useLocaleMessages("Pagination");
|
|
11177
11426
|
const rtl = useRtl();
|
|
11178
|
-
const PrevIcon = rtl ?
|
|
11179
|
-
const NextIcon = rtl ?
|
|
11427
|
+
const PrevIcon = rtl ? DirectionArrowRightLight5 : DirectionArrowLeftLight5;
|
|
11428
|
+
const NextIcon = rtl ? DirectionArrowLeftLight5 : DirectionArrowRightLight5;
|
|
11180
11429
|
const resolvedJumpLabel = jumpLabel ?? locale.jumpTo;
|
|
11181
11430
|
const resolvedSizeLabel = sizeLabel ?? locale.pageSize;
|
|
11182
11431
|
const resolvedSizeOptionLabel = sizeOptionLabel ?? ((size) => interpolate(locale.items, { size }));
|
|
@@ -11357,8 +11606,8 @@ Pagination.displayName = "Pagination";
|
|
|
11357
11606
|
|
|
11358
11607
|
// src/components/card.tsx
|
|
11359
11608
|
import {
|
|
11360
|
-
DirectionArrowLeftLight as
|
|
11361
|
-
DirectionArrowRightLight as
|
|
11609
|
+
DirectionArrowLeftLight as DirectionArrowLeftLight6,
|
|
11610
|
+
DirectionArrowRightLight as DirectionArrowRightLight6,
|
|
11362
11611
|
GeneralSetting as GeneralSetting2
|
|
11363
11612
|
} from "@aviala-design/icons";
|
|
11364
11613
|
import {
|
|
@@ -11401,7 +11650,7 @@ var CardHead = forwardRef43(
|
|
|
11401
11650
|
}, ref) => {
|
|
11402
11651
|
const locale = useLocaleMessages("Card");
|
|
11403
11652
|
const rtl = useRtl();
|
|
11404
|
-
const ChevronIcon = rtl ?
|
|
11653
|
+
const ChevronIcon = rtl ? DirectionArrowLeftLight6 : DirectionArrowRightLight6;
|
|
11405
11654
|
const primaryAction = action ?? /* @__PURE__ */ jsx62(Button, { mode: "primary", size: "regular", leftIcon: /* @__PURE__ */ jsx62(GeneralSetting2, { "aria-hidden": true }), children: actionLabel });
|
|
11406
11655
|
const renderTrailing = () => {
|
|
11407
11656
|
if (trailing !== void 0) return trailing;
|
|
@@ -11471,7 +11720,7 @@ var CardBottom = forwardRef43(
|
|
|
11471
11720
|
}, ref) => {
|
|
11472
11721
|
const locale = useLocaleMessages("Card");
|
|
11473
11722
|
const rtl = useRtl();
|
|
11474
|
-
const ChevronIcon = rtl ?
|
|
11723
|
+
const ChevronIcon = rtl ? DirectionArrowLeftLight6 : DirectionArrowRightLight6;
|
|
11475
11724
|
const primaryAction = action ?? /* @__PURE__ */ jsx62(Button, { mode: "primary", size: "regular", leftIcon: /* @__PURE__ */ jsx62(GeneralSetting2, { "aria-hidden": true }), children: actionLabel });
|
|
11476
11725
|
const renderTrailing = () => {
|
|
11477
11726
|
if (trailing !== void 0) return trailing;
|