@wistia/ui 0.25.10 → 0.26.0-beta.11ebca9f.285b827

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 CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v0.25.10
3
+ * @license @wistia/ui v0.26.0-beta.11ebca9f.285b827
4
4
  *
5
5
  * Copyright (c) 2024-2026, Wistia, Inc. and its affiliates.
6
6
  *
@@ -5036,9 +5036,6 @@ const ZoomOutIcon = (props) => /* @__PURE__ */ jsx("svg", {
5036
5036
  });
5037
5037
  //#endregion
5038
5038
  //#region src/components/Icon/iconMap.ts
5039
- /**
5040
- * This file is auto-generated by the generateIconMap script on 4/22/2026.
5041
- */
5042
5039
  const iconMap = {
5043
5040
  "ab-test": AbTestIcon,
5044
5041
  accessibility: AccessibilityIcon,
@@ -5338,7 +5335,7 @@ const StyledIcon = styled.svg`
5338
5335
  * Note that icons should not be used directly for interactivity.
5339
5336
  * If you need an interactive element, use IconButton.
5340
5337
  */
5341
- const Icon = ({ useInlineStyles = true, invertColor, colorScheme = "inherit", size = "lg", style, type, ...props }) => {
5338
+ const IconComponent = ({ useInlineStyles = true, invertColor, colorScheme = "inherit", size = "lg", style, type, ...props }) => {
5342
5339
  const responsiveSize = useResponsiveProp(size);
5343
5340
  if (isNil(type)) throw new Error("An Icon component requires a `type` prop to be provided");
5344
5341
  if (isNil(iconMap[type])) throw new Error(`Type "${type}" does not exist, please update type prop in Icon component.`);
@@ -5364,7 +5361,8 @@ const Icon = ({ useInlineStyles = true, invertColor, colorScheme = "inherit", si
5364
5361
  color: iconColor
5365
5362
  });
5366
5363
  };
5367
- Icon.displayName = "Icon_UI";
5364
+ IconComponent.displayName = "Icon_UI";
5365
+ const Icon = IconComponent;
5368
5366
  //#endregion
5369
5367
  //#region src/components/Link/Link.tsx
5370
5368
  const generateHref = (href, type, disabled) => {
@@ -5977,7 +5975,7 @@ Badge.displayName = "Badge_UI";
5977
5975
  //#region src/private/helpers/makePolymorphic/makePolymorphic.tsx
5978
5976
  /**
5979
5977
  * makePolymorphic takes a component (typically a forwardRef component) and returns a new version
5980
- * that supports polymorphism via a `renderAs` prop. The returned components types automatically
5978
+ * that supports polymorphism via a `renderAs` prop. The returned component's types automatically
5981
5979
  * merge the intrinsic props of the rendered element with the custom props of the original
5982
5980
  * component, while including support for children and refs.
5983
5981
  *
@@ -9799,11 +9797,11 @@ const Menu = forwardRef(({ align = "start", children, disabled = false, compact
9799
9797
  modal: false,
9800
9798
  ...controlProps,
9801
9799
  children: [/* @__PURE__ */ jsx(Menu$1.Trigger, { render: isNotUndefined(trigger) ? trigger : /* @__PURE__ */ jsx(Button, {
9800
+ ...triggerProps,
9802
9801
  ref,
9803
9802
  disabled,
9804
9803
  forceState: isOpen ? "active" : void 0,
9805
9804
  rightIcon: /* @__PURE__ */ jsx(Icon, { type: "caret-down" }),
9806
- ...triggerProps,
9807
9805
  children: label
9808
9806
  }) }), /* @__PURE__ */ jsx(Menu$1.Portal, { children: /* @__PURE__ */ jsx(Menu$1.Positioner, {
9809
9807
  align,
@@ -10286,6 +10284,680 @@ const Divider = ({ orientation = "horizontal", inset = "space-00", ...props }) =
10286
10284
  });
10287
10285
  };
10288
10286
  Divider.displayName = "Divider_UI";
10287
+ const SECONDS_PER_HOUR = 3600;
10288
+ const TEN_HOURS = 36e3;
10289
+ const ONE_HUNDREDTH_OF_A_SECOND = .01;
10290
+ const MAX_TIME = TEN_HOURS - ONE_HUNDREDTH_OF_A_SECOND;
10291
+ const NUMBER_STRINGS = [
10292
+ "0",
10293
+ "1",
10294
+ "2",
10295
+ "3",
10296
+ "4",
10297
+ "5",
10298
+ "6",
10299
+ "7",
10300
+ "8",
10301
+ "9"
10302
+ ];
10303
+ //#endregion
10304
+ //#region src/components/DurationInput/durationFormatting.ts
10305
+ const hoursFormatter = new Intl.NumberFormat("en-US", {
10306
+ maximumFractionDigits: 0,
10307
+ useGrouping: false
10308
+ });
10309
+ const minutesFormatter = new Intl.NumberFormat("en-US", {
10310
+ maximumFractionDigits: 0,
10311
+ minimumIntegerDigits: 1
10312
+ });
10313
+ const tensOfMinutesFormatter = new Intl.NumberFormat("en-US", {
10314
+ maximumFractionDigits: 0,
10315
+ minimumIntegerDigits: 2
10316
+ });
10317
+ const getSecondsFormatter = (decimalUnitLength) => {
10318
+ return new Intl.NumberFormat("en-US", {
10319
+ maximumFractionDigits: decimalUnitLength,
10320
+ minimumFractionDigits: decimalUnitLength,
10321
+ minimumIntegerDigits: 2
10322
+ });
10323
+ };
10324
+ const isValidHour = (number) => Number.isInteger(number) && number >= 0;
10325
+ const isValidMinute = (number) => Number.isInteger(number) && number >= 0 && number <= 59;
10326
+ const isValidSecond = (number) => Number.isFinite(number) && number >= 0 && number < 60;
10327
+ const durationInputValueToSeconds = (formattedTimeString) => {
10328
+ const segments = formattedTimeString.split(":");
10329
+ if (segments.length <= 3) {
10330
+ const [seconds = 0, minutes = 0, hours = 0] = segments.reverse().map(Number);
10331
+ if (isValidSecond(seconds) && isValidMinute(minutes) && isValidHour(hours)) return hours * SECONDS_PER_HOUR + minutes * 60 + seconds;
10332
+ }
10333
+ throw new SyntaxError(`Invalid time (${formattedTimeString})`);
10334
+ };
10335
+ const getFormattedHours = ({ hours, maxUnit }) => {
10336
+ if (maxUnit !== "hours") return null;
10337
+ return hoursFormatter.format(hours);
10338
+ };
10339
+ const getFormattedMinutes = ({ minutes, maxUnit }) => {
10340
+ if (maxUnit === "seconds") return null;
10341
+ if (maxUnit === "minutes") return minutesFormatter.format(minutes);
10342
+ return tensOfMinutesFormatter.format(minutes);
10343
+ };
10344
+ const getFormattedSeconds = ({ seconds, decimalUnitLength }) => {
10345
+ return getSecondsFormatter(decimalUnitLength).format(seconds);
10346
+ };
10347
+ const convertSecondsToHMSUnits = (durationInSeconds) => {
10348
+ const seconds = durationInSeconds % 60;
10349
+ const remainingDurationInMinutes = (durationInSeconds - seconds) / 60;
10350
+ const minutes = remainingDurationInMinutes % 60;
10351
+ return {
10352
+ hours: (remainingDurationInMinutes - minutes) / 60,
10353
+ minutes,
10354
+ seconds
10355
+ };
10356
+ };
10357
+ const secondsToDurationInputValue = ({ seconds: durationInSeconds, maxUnit, decimalUnitLength }) => {
10358
+ const { hours, minutes, seconds } = convertSecondsToHMSUnits(durationInSeconds);
10359
+ return [
10360
+ getFormattedHours({
10361
+ hours,
10362
+ maxUnit
10363
+ }),
10364
+ getFormattedMinutes({
10365
+ minutes,
10366
+ maxUnit
10367
+ }),
10368
+ getFormattedSeconds({
10369
+ seconds,
10370
+ decimalUnitLength
10371
+ })
10372
+ ].filter(Boolean).join(":");
10373
+ };
10374
+ const getMaxUnit = (seconds) => {
10375
+ if (seconds >= 3600) return "hours";
10376
+ if (seconds >= 600) return "tens-of-minutes";
10377
+ if (seconds >= 60) return "minutes";
10378
+ return "seconds";
10379
+ };
10380
+ const clampSeconds = ({ maxSeconds, minSeconds, seconds }) => {
10381
+ return Math.min(Math.max(seconds, minSeconds), maxSeconds);
10382
+ };
10383
+ const roundSeconds = (seconds, decimalUnitLength) => {
10384
+ const multiplier = decimalUnitLength === 0 ? 1 : 100;
10385
+ return Math.round(seconds * multiplier) / multiplier;
10386
+ };
10387
+ const getDurationBounds = ({ decimalUnitLength, maxSeconds, minSeconds }) => {
10388
+ const roundedMaxSeconds = roundSeconds(maxSeconds, decimalUnitLength);
10389
+ const roundedMinSeconds = roundSeconds(minSeconds, decimalUnitLength);
10390
+ if (roundedMaxSeconds < roundedMinSeconds) return {
10391
+ maxSeconds: roundedMaxSeconds,
10392
+ minSeconds: roundedMaxSeconds
10393
+ };
10394
+ return {
10395
+ maxSeconds: roundedMaxSeconds,
10396
+ minSeconds: roundedMinSeconds
10397
+ };
10398
+ };
10399
+ //#endregion
10400
+ //#region src/components/DurationInput/durationSelection.ts
10401
+ const getEmptySelectionRanges = () => ({
10402
+ hours: {
10403
+ start: null,
10404
+ end: null
10405
+ },
10406
+ "tens-of-minutes": {
10407
+ start: null,
10408
+ end: null
10409
+ },
10410
+ minutes: {
10411
+ start: null,
10412
+ end: null
10413
+ },
10414
+ seconds: {
10415
+ start: null,
10416
+ end: null
10417
+ },
10418
+ "hundredths-of-seconds": {
10419
+ start: null,
10420
+ end: null
10421
+ }
10422
+ });
10423
+ const getSegmentRange = ({ segment, offset }) => {
10424
+ return {
10425
+ nextOffset: offset + segment.length + 1,
10426
+ range: {
10427
+ start: offset,
10428
+ end: offset + segment.length
10429
+ }
10430
+ };
10431
+ };
10432
+ const getSecondsRanges = ({ segment, offset }) => {
10433
+ const decimalSeparatorIndex = segment.indexOf(".");
10434
+ const ranges = {
10435
+ seconds: {
10436
+ start: offset,
10437
+ end: offset + (decimalSeparatorIndex === -1 ? segment.length : decimalSeparatorIndex)
10438
+ },
10439
+ "hundredths-of-seconds": {
10440
+ start: null,
10441
+ end: null
10442
+ }
10443
+ };
10444
+ if (decimalSeparatorIndex !== -1 && decimalSeparatorIndex < segment.length - 1) ranges["hundredths-of-seconds"] = {
10445
+ start: offset + decimalSeparatorIndex + 1,
10446
+ end: offset + segment.length
10447
+ };
10448
+ return ranges;
10449
+ };
10450
+ const getSelectionRanges = ({ inputValue, maxUnit }) => {
10451
+ const ranges = getEmptySelectionRanges();
10452
+ const segments = inputValue.split(":");
10453
+ let offset = 0;
10454
+ if (maxUnit === "hours") {
10455
+ const [hours = "", minutes = "", seconds = ""] = segments;
10456
+ const hoursResult = getSegmentRange({
10457
+ segment: hours,
10458
+ offset
10459
+ });
10460
+ ranges.hours = hoursResult.range;
10461
+ offset = hoursResult.nextOffset;
10462
+ const minutesResult = getSegmentRange({
10463
+ segment: minutes,
10464
+ offset
10465
+ });
10466
+ ranges["tens-of-minutes"] = minutesResult.range;
10467
+ offset = minutesResult.nextOffset;
10468
+ Object.assign(ranges, getSecondsRanges({
10469
+ segment: seconds,
10470
+ offset
10471
+ }));
10472
+ return ranges;
10473
+ }
10474
+ if (maxUnit === "tens-of-minutes") {
10475
+ const [minutes = "", seconds = ""] = segments;
10476
+ const minutesResult = getSegmentRange({
10477
+ segment: minutes,
10478
+ offset
10479
+ });
10480
+ ranges["tens-of-minutes"] = minutesResult.range;
10481
+ offset = minutesResult.nextOffset;
10482
+ Object.assign(ranges, getSecondsRanges({
10483
+ segment: seconds,
10484
+ offset
10485
+ }));
10486
+ return ranges;
10487
+ }
10488
+ if (maxUnit === "minutes") {
10489
+ const [minutes = "", seconds = ""] = segments;
10490
+ const minutesResult = getSegmentRange({
10491
+ segment: minutes,
10492
+ offset
10493
+ });
10494
+ ranges.minutes = minutesResult.range;
10495
+ offset = minutesResult.nextOffset;
10496
+ Object.assign(ranges, getSecondsRanges({
10497
+ segment: seconds,
10498
+ offset
10499
+ }));
10500
+ return ranges;
10501
+ }
10502
+ const [seconds = ""] = segments;
10503
+ Object.assign(ranges, getSecondsRanges({
10504
+ segment: seconds,
10505
+ offset
10506
+ }));
10507
+ return ranges;
10508
+ };
10509
+ //#endregion
10510
+ //#region src/components/DurationInput/types.ts
10511
+ const DURATION_UNITS = [
10512
+ "hours",
10513
+ "hundredths-of-seconds",
10514
+ "minutes",
10515
+ "seconds",
10516
+ "tens-of-minutes"
10517
+ ];
10518
+ const isDurationUnit = (unit) => {
10519
+ return isNotNil(unit) && DURATION_UNITS.some((durationUnit) => durationUnit === unit);
10520
+ };
10521
+ //#endregion
10522
+ //#region src/components/DurationInput/useDurationInput.ts
10523
+ const useDurationInput = ({ decimalUnitLength, maxSeconds, minSeconds, onChangeValueInSeconds, valueInSeconds }) => {
10524
+ const [inputSelection, setInputSelection] = useState(null);
10525
+ const [anyKeyIsDown, setAnyKeyIsDown] = useState(false);
10526
+ const inputRef = useRef(null);
10527
+ const secondDigitMightBeTypedNext = useRef(false);
10528
+ const { maxSeconds: roundedMaxSeconds, minSeconds: roundedMinSeconds } = useMemo(() => getDurationBounds({
10529
+ decimalUnitLength,
10530
+ maxSeconds,
10531
+ minSeconds
10532
+ }), [
10533
+ decimalUnitLength,
10534
+ maxSeconds,
10535
+ minSeconds
10536
+ ]);
10537
+ const maxUnit = useMemo(() => getMaxUnit(roundedMaxSeconds), [roundedMaxSeconds]);
10538
+ const boundedValueInSeconds = useMemo(() => clampSeconds({
10539
+ maxSeconds: roundedMaxSeconds,
10540
+ minSeconds: roundedMinSeconds,
10541
+ seconds: valueInSeconds
10542
+ }), [
10543
+ roundedMaxSeconds,
10544
+ roundedMinSeconds,
10545
+ valueInSeconds
10546
+ ]);
10547
+ const [inputValue, setInputValue] = useState(() => secondsToDurationInputValue({
10548
+ decimalUnitLength,
10549
+ maxUnit,
10550
+ seconds: boundedValueInSeconds
10551
+ }));
10552
+ const selectionRanges = useMemo(() => getSelectionRanges({
10553
+ inputValue,
10554
+ maxUnit
10555
+ }), [inputValue, maxUnit]);
10556
+ const decimalStep = decimalUnitLength === 0 ? 0 : ONE_HUNDREDTH_OF_A_SECOND;
10557
+ const maybeSetInputValueAndTriggerOnChange = useCallback((candidateInputValue) => {
10558
+ const seconds = durationInputValueToSeconds(candidateInputValue);
10559
+ if (seconds < roundedMinSeconds || seconds > roundedMaxSeconds) return;
10560
+ setInputValue(candidateInputValue);
10561
+ onChangeValueInSeconds(seconds);
10562
+ }, [
10563
+ onChangeValueInSeconds,
10564
+ roundedMaxSeconds,
10565
+ roundedMinSeconds
10566
+ ]);
10567
+ const selectUnit = useCallback((unit) => {
10568
+ if (unit == null) {
10569
+ setInputSelection(null);
10570
+ return;
10571
+ }
10572
+ const { start, end } = selectionRanges[unit];
10573
+ if (start == null || end == null) {
10574
+ setInputSelection(null);
10575
+ return;
10576
+ }
10577
+ inputRef.current?.setSelectionRange(start, end);
10578
+ setInputSelection({
10579
+ start,
10580
+ end
10581
+ });
10582
+ }, [selectionRanges]);
10583
+ const getUnitForSelectionIndices = useCallback(({ selectionStart, selectionEnd }) => {
10584
+ const result = Object.entries(selectionRanges).find(([, { start, end }]) => {
10585
+ if (start === null || end === null) return false;
10586
+ return selectionStart >= start && selectionEnd <= end;
10587
+ })?.[0] ?? null;
10588
+ if (!isDurationUnit(result)) return null;
10589
+ return result;
10590
+ }, [selectionRanges]);
10591
+ const selectedUnit = useMemo(() => {
10592
+ if (inputSelection == null) return null;
10593
+ const { start: selectionStart, end: selectionEnd } = inputSelection;
10594
+ const foundUnit = getUnitForSelectionIndices({
10595
+ selectionStart,
10596
+ selectionEnd
10597
+ });
10598
+ if (!isDurationUnit(foundUnit)) return null;
10599
+ return foundUnit;
10600
+ }, [getUnitForSelectionIndices, inputSelection]);
10601
+ const selectUnitToRight = useCallback(() => {
10602
+ requestAnimationFrame(() => {
10603
+ if (inputSelection == null) return;
10604
+ const unitToSelect = getUnitForSelectionIndices({
10605
+ selectionEnd: inputSelection.end + 1,
10606
+ selectionStart: inputSelection.end + 1
10607
+ });
10608
+ if (unitToSelect == null) return;
10609
+ selectUnit(unitToSelect);
10610
+ });
10611
+ }, [
10612
+ getUnitForSelectionIndices,
10613
+ inputSelection,
10614
+ selectUnit
10615
+ ]);
10616
+ const selectUnitToLeft = useCallback(() => {
10617
+ if (inputSelection == null) return;
10618
+ const unitToSelect = getUnitForSelectionIndices({
10619
+ selectionEnd: inputSelection.start - 1,
10620
+ selectionStart: inputSelection.start - 1
10621
+ });
10622
+ if (unitToSelect == null) return;
10623
+ selectUnit(unitToSelect);
10624
+ }, [
10625
+ getUnitForSelectionIndices,
10626
+ inputSelection,
10627
+ selectUnit
10628
+ ]);
10629
+ const incrementBySeconds = useCallback((secondsToIncrementBy) => {
10630
+ const newValue = durationInputValueToSeconds(inputValue) + secondsToIncrementBy;
10631
+ if (newValue > roundedMaxSeconds) return;
10632
+ maybeSetInputValueAndTriggerOnChange(secondsToDurationInputValue({
10633
+ decimalUnitLength,
10634
+ maxUnit,
10635
+ seconds: newValue
10636
+ }));
10637
+ }, [
10638
+ decimalUnitLength,
10639
+ inputValue,
10640
+ maxUnit,
10641
+ maybeSetInputValueAndTriggerOnChange,
10642
+ roundedMaxSeconds
10643
+ ]);
10644
+ const decrementBySeconds = useCallback((secondsToDecrementBy) => {
10645
+ const newValue = durationInputValueToSeconds(inputValue) - secondsToDecrementBy;
10646
+ if (newValue < roundedMinSeconds) return;
10647
+ maybeSetInputValueAndTriggerOnChange(secondsToDurationInputValue({
10648
+ decimalUnitLength,
10649
+ maxUnit,
10650
+ seconds: newValue
10651
+ }));
10652
+ }, [
10653
+ decimalUnitLength,
10654
+ inputValue,
10655
+ maxUnit,
10656
+ maybeSetInputValueAndTriggerOnChange,
10657
+ roundedMinSeconds
10658
+ ]);
10659
+ const incrementSelectedUnit = useCallback(() => {
10660
+ if (selectedUnit == null) return;
10661
+ if (selectedUnit === "hours") {
10662
+ incrementBySeconds(SECONDS_PER_HOUR);
10663
+ return;
10664
+ }
10665
+ if (selectedUnit === "minutes" || selectedUnit === "tens-of-minutes") {
10666
+ incrementBySeconds(60);
10667
+ return;
10668
+ }
10669
+ if (selectedUnit === "seconds") {
10670
+ incrementBySeconds(1);
10671
+ return;
10672
+ }
10673
+ incrementBySeconds(decimalStep);
10674
+ }, [
10675
+ decimalStep,
10676
+ incrementBySeconds,
10677
+ selectedUnit
10678
+ ]);
10679
+ const decrementSelectedUnit = useCallback(() => {
10680
+ if (selectedUnit == null) return;
10681
+ if (selectedUnit === "hours") {
10682
+ decrementBySeconds(SECONDS_PER_HOUR);
10683
+ return;
10684
+ }
10685
+ if (selectedUnit === "minutes" || selectedUnit === "tens-of-minutes") {
10686
+ decrementBySeconds(60);
10687
+ return;
10688
+ }
10689
+ if (selectedUnit === "seconds") {
10690
+ decrementBySeconds(1);
10691
+ return;
10692
+ }
10693
+ decrementBySeconds(decimalStep);
10694
+ }, [
10695
+ decimalStep,
10696
+ decrementBySeconds,
10697
+ selectedUnit
10698
+ ]);
10699
+ const setSelectedUnitToZero = useCallback(() => {
10700
+ if (selectedUnit == null || inputSelection == null) return;
10701
+ const textToLeftOfSelection = inputValue.slice(0, inputSelection.start);
10702
+ const textToRightOfSelection = inputValue.slice(inputSelection.end);
10703
+ if (selectedUnit === "hours") {
10704
+ maybeSetInputValueAndTriggerOnChange(`0${textToRightOfSelection}`);
10705
+ selectUnitToRight();
10706
+ return;
10707
+ }
10708
+ if (selectedUnit === "tens-of-minutes") {
10709
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}00${textToRightOfSelection}`);
10710
+ selectUnitToRight();
10711
+ return;
10712
+ }
10713
+ if (selectedUnit === "minutes") {
10714
+ maybeSetInputValueAndTriggerOnChange(`0${textToRightOfSelection}`);
10715
+ selectUnitToRight();
10716
+ return;
10717
+ }
10718
+ if (selectedUnit === "seconds") {
10719
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}00${textToRightOfSelection}`);
10720
+ selectUnitToRight();
10721
+ return;
10722
+ }
10723
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${"0".repeat(decimalUnitLength)}`);
10724
+ selectUnitToRight();
10725
+ }, [
10726
+ decimalUnitLength,
10727
+ inputSelection,
10728
+ inputValue,
10729
+ maybeSetInputValueAndTriggerOnChange,
10730
+ selectUnitToRight,
10731
+ selectedUnit
10732
+ ]);
10733
+ const onInputSelect = useCallback((event) => {
10734
+ if (anyKeyIsDown) return;
10735
+ const { selectionStart, selectionEnd } = event.currentTarget;
10736
+ if (selectionStart === null || selectionEnd === null) return;
10737
+ selectUnit(getUnitForSelectionIndices({
10738
+ selectionStart,
10739
+ selectionEnd
10740
+ }));
10741
+ }, [
10742
+ anyKeyIsDown,
10743
+ getUnitForSelectionIndices,
10744
+ selectUnit
10745
+ ]);
10746
+ const restoreSelectionToSelectedUnit = useCallback(() => {
10747
+ requestAnimationFrame(() => {
10748
+ selectUnit(selectedUnit);
10749
+ });
10750
+ }, [selectUnit, selectedUnit]);
10751
+ const prepareForPossibleSecondDigit = useCallback(() => {
10752
+ secondDigitMightBeTypedNext.current = true;
10753
+ restoreSelectionToSelectedUnit();
10754
+ }, [restoreSelectionToSelectedUnit]);
10755
+ const onTypeNumber = useCallback((number) => {
10756
+ if (inputSelection == null) return;
10757
+ const selectedText = inputValue.slice(inputSelection.start, inputSelection.end);
10758
+ const textToLeftOfSelection = inputValue.slice(0, inputSelection.start);
10759
+ const textToRightOfSelection = inputValue.slice(inputSelection.end);
10760
+ if (selectedUnit === "hours") {
10761
+ maybeSetInputValueAndTriggerOnChange(`${number.toString()}${textToRightOfSelection}`);
10762
+ selectUnitToRight();
10763
+ return;
10764
+ }
10765
+ if (selectedUnit === "tens-of-minutes" && number >= 60 / 10 && !secondDigitMightBeTypedNext.current) {
10766
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}0${number.toString()}${textToRightOfSelection}`);
10767
+ secondDigitMightBeTypedNext.current = false;
10768
+ selectUnitToRight();
10769
+ return;
10770
+ }
10771
+ if (selectedUnit === "tens-of-minutes" && !secondDigitMightBeTypedNext.current) {
10772
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${number.toString()}0${textToRightOfSelection}`);
10773
+ prepareForPossibleSecondDigit();
10774
+ return;
10775
+ }
10776
+ if (selectedUnit === "tens-of-minutes" && secondDigitMightBeTypedNext.current) {
10777
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${selectedText[0]}${number.toString()}${textToRightOfSelection}`);
10778
+ secondDigitMightBeTypedNext.current = false;
10779
+ selectUnitToRight();
10780
+ return;
10781
+ }
10782
+ if (selectedUnit === "minutes") {
10783
+ maybeSetInputValueAndTriggerOnChange(`${number.toString()}${textToRightOfSelection}`);
10784
+ selectUnitToRight();
10785
+ return;
10786
+ }
10787
+ if (selectedUnit === "seconds" && number >= 60 / 10 && !secondDigitMightBeTypedNext.current) {
10788
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}0${number.toString()}${textToRightOfSelection}`);
10789
+ secondDigitMightBeTypedNext.current = false;
10790
+ selectUnitToRight();
10791
+ return;
10792
+ }
10793
+ if (selectedUnit === "seconds" && !secondDigitMightBeTypedNext.current) {
10794
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${number.toString()}0${textToRightOfSelection}`);
10795
+ prepareForPossibleSecondDigit();
10796
+ return;
10797
+ }
10798
+ if (selectedUnit === "seconds" && secondDigitMightBeTypedNext.current) {
10799
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${selectedText[0]}${number.toString()}${textToRightOfSelection}`);
10800
+ secondDigitMightBeTypedNext.current = false;
10801
+ selectUnitToRight();
10802
+ return;
10803
+ }
10804
+ if (selectedUnit === "hundredths-of-seconds" && !secondDigitMightBeTypedNext.current) {
10805
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${number.toString()}0`);
10806
+ prepareForPossibleSecondDigit();
10807
+ return;
10808
+ }
10809
+ if (selectedUnit === "hundredths-of-seconds" && secondDigitMightBeTypedNext.current) {
10810
+ maybeSetInputValueAndTriggerOnChange(`${textToLeftOfSelection}${selectedText[0]}${number.toString()}`);
10811
+ secondDigitMightBeTypedNext.current = false;
10812
+ restoreSelectionToSelectedUnit();
10813
+ }
10814
+ }, [
10815
+ inputSelection,
10816
+ inputValue,
10817
+ maybeSetInputValueAndTriggerOnChange,
10818
+ prepareForPossibleSecondDigit,
10819
+ restoreSelectionToSelectedUnit,
10820
+ selectUnitToRight,
10821
+ selectedUnit
10822
+ ]);
10823
+ const onKeyDown = useCallback((event) => {
10824
+ setAnyKeyIsDown(true);
10825
+ if (inputRef.current == null || inputSelection == null) return;
10826
+ const { start: selectionStart, end: selectionEnd } = inputSelection;
10827
+ const { key } = event;
10828
+ if (key === "ArrowRight") {
10829
+ event.preventDefault();
10830
+ secondDigitMightBeTypedNext.current = false;
10831
+ selectUnitToRight();
10832
+ return;
10833
+ }
10834
+ if (key === "ArrowLeft") {
10835
+ event.preventDefault();
10836
+ secondDigitMightBeTypedNext.current = false;
10837
+ selectUnitToLeft();
10838
+ return;
10839
+ }
10840
+ if (key === "ArrowUp") {
10841
+ event.preventDefault();
10842
+ secondDigitMightBeTypedNext.current = false;
10843
+ incrementSelectedUnit();
10844
+ restoreSelectionToSelectedUnit();
10845
+ return;
10846
+ }
10847
+ if (key === "ArrowDown") {
10848
+ event.preventDefault();
10849
+ secondDigitMightBeTypedNext.current = false;
10850
+ decrementSelectedUnit();
10851
+ restoreSelectionToSelectedUnit();
10852
+ return;
10853
+ }
10854
+ if (key === "Tab" && !event.shiftKey && selectionEnd < inputRef.current.value.length) {
10855
+ event.preventDefault();
10856
+ secondDigitMightBeTypedNext.current = false;
10857
+ selectUnitToRight();
10858
+ return;
10859
+ }
10860
+ if (key === "Tab" && event.shiftKey && selectionStart > 0) {
10861
+ event.preventDefault();
10862
+ secondDigitMightBeTypedNext.current = false;
10863
+ selectUnitToLeft();
10864
+ return;
10865
+ }
10866
+ if (key === ":") {
10867
+ event.preventDefault();
10868
+ secondDigitMightBeTypedNext.current = false;
10869
+ selectUnitToRight();
10870
+ return;
10871
+ }
10872
+ if (key === "." && decimalUnitLength > 0) {
10873
+ event.preventDefault();
10874
+ secondDigitMightBeTypedNext.current = false;
10875
+ selectUnit("hundredths-of-seconds");
10876
+ return;
10877
+ }
10878
+ if (NUMBER_STRINGS.includes(key)) {
10879
+ event.preventDefault();
10880
+ onTypeNumber(Number(key));
10881
+ return;
10882
+ }
10883
+ if (key === "Backspace") {
10884
+ event.preventDefault();
10885
+ setSelectedUnitToZero();
10886
+ restoreSelectionToSelectedUnit();
10887
+ }
10888
+ }, [
10889
+ decimalUnitLength,
10890
+ decrementSelectedUnit,
10891
+ incrementSelectedUnit,
10892
+ inputSelection,
10893
+ onTypeNumber,
10894
+ restoreSelectionToSelectedUnit,
10895
+ selectUnit,
10896
+ selectUnitToLeft,
10897
+ selectUnitToRight,
10898
+ setSelectedUnitToZero
10899
+ ]);
10900
+ const onKeyUp = useCallback(() => {
10901
+ setAnyKeyIsDown(false);
10902
+ }, []);
10903
+ useEffect(() => {
10904
+ setInputValue(secondsToDurationInputValue({
10905
+ decimalUnitLength,
10906
+ maxUnit,
10907
+ seconds: boundedValueInSeconds
10908
+ }));
10909
+ }, [
10910
+ boundedValueInSeconds,
10911
+ decimalUnitLength,
10912
+ inputValue,
10913
+ maxUnit
10914
+ ]);
10915
+ return {
10916
+ inputRef,
10917
+ inputValue,
10918
+ onInputSelect,
10919
+ onKeyDown,
10920
+ onKeyUp
10921
+ };
10922
+ };
10923
+ //#endregion
10924
+ //#region src/components/DurationInput/DurationInput.tsx
10925
+ const EXTRA_INPUT_WIDTH_CH = 2;
10926
+ const getInputWidth = (inputValue) => {
10927
+ return `calc(${inputValue.length + EXTRA_INPUT_WIDTH_CH}ch + var(--wui-input-horizontal-padding) + var(--wui-input-horizontal-padding))`;
10928
+ };
10929
+ /**
10930
+ * DurationInput lets users edit a duration value using a keyboard-friendly time input.
10931
+ */
10932
+ const DurationInput = ({ decimalUnitLength = 2, disabled = false, fullWidth = false, maxSeconds = MAX_TIME, minSeconds = 0, onChangeValueInSeconds, valueInSeconds, onFocus, style, ...props }) => {
10933
+ const { inputRef, inputValue, onInputSelect, onKeyDown, onKeyUp } = useDurationInput({
10934
+ decimalUnitLength,
10935
+ maxSeconds,
10936
+ minSeconds,
10937
+ onChangeValueInSeconds,
10938
+ valueInSeconds
10939
+ });
10940
+ const inputWidth = fullWidth ? void 0 : getInputWidth(inputValue);
10941
+ return /* @__PURE__ */ jsx(Input, {
10942
+ ...props,
10943
+ ref: inputRef,
10944
+ disabled,
10945
+ fullWidth,
10946
+ monospace: true,
10947
+ onChange: () => {},
10948
+ onFocus,
10949
+ onKeyDown,
10950
+ onKeyUp,
10951
+ onSelect: onInputSelect,
10952
+ style: {
10953
+ width: inputWidth,
10954
+ textAlign: "right",
10955
+ ...style
10956
+ },
10957
+ type: "text",
10958
+ value: inputValue
10959
+ });
10960
+ };
10289
10961
  //#endregion
10290
10962
  //#region src/components/EditableHeading/EditableHeading.tsx
10291
10963
  const StyledInput$1 = styled(Input)`
@@ -12910,7 +13582,7 @@ PopoverClose.displayName = "PopoverClose_UI";
12910
13582
  * A pre-styled close button intended to be placed inside a `PopoverContent`.
12911
13583
  * For a custom close control, use `PopoverClose` directly.
12912
13584
  */
12913
- const PopoverCloseButton = ({ label = "Close" } = {}) => /* @__PURE__ */ jsx(PopoverClose, { render: /* @__PURE__ */ jsx(IconButton, {
13585
+ const PopoverCloseButton = ({ label = "Close" }) => /* @__PURE__ */ jsx(PopoverClose, { render: /* @__PURE__ */ jsx(IconButton, {
12914
13586
  "data-wui-popover-close": true,
12915
13587
  label,
12916
13588
  variant: "ghost",
@@ -13245,59 +13917,59 @@ const imageCoverStyles = css`
13245
13917
  }
13246
13918
  `;
13247
13919
  const StyledCard = styled.label`
13248
- --wui-radio-card-border-color: var(--wui-color-border-secondary);
13249
- --wui-radio-card-background-color: var(--wui-color-bg-surface);
13250
- --wui-radio-card-cursor: pointer;
13251
- --wui-radio-card-border-width: 1px;
13252
- --wui-radio-card-border-radius: var(--wui-border-radius-02);
13253
-
13254
- position: relative;
13255
- display: inline-flex;
13256
- padding: ${({ $padding }) => `var(--wui-${$padding})`};
13257
- aspect-ratio: ${({ $aspectRatio }) => $aspectRatio};
13258
- border: var(--wui-radio-card-border-width) solid var(--wui-radio-card-border-color);
13259
- border-radius: var(--wui-radio-card-border-radius);
13260
- background-color: var(--wui-radio-card-background-color);
13261
- cursor: var(--wui-radio-card-cursor);
13262
- overflow: hidden;
13263
- transition: all var(--wui-motion-duration-03) var(--wui-motion-ease);
13920
+ --wui-radio-card-border-color: var(--wui-color-border-secondary);
13921
+ --wui-radio-card-background-color: var(--wui-color-bg-surface);
13922
+ --wui-radio-card-cursor: pointer;
13923
+ --wui-radio-card-border-width: 1px;
13924
+ --wui-radio-card-border-radius: var(--wui-border-radius-02);
13264
13925
 
13265
- svg {
13926
+ position: relative;
13927
+ display: inline-flex;
13928
+ padding: ${({ $padding }) => `var(--wui-${$padding})`};
13929
+ aspect-ratio: ${({ $aspectRatio }) => $aspectRatio};
13930
+ border: var(--wui-radio-card-border-width) solid var(--wui-radio-card-border-color);
13931
+ border-radius: var(--wui-radio-card-border-radius);
13932
+ background-color: var(--wui-radio-card-background-color);
13933
+ cursor: var(--wui-radio-card-cursor);
13934
+ overflow: hidden;
13266
13935
  transition: all var(--wui-motion-duration-03) var(--wui-motion-ease);
13267
- }
13268
13936
 
13269
- &:hover {
13270
- --wui-radio-card-border-color: var(--wui-color-border-secondary-hover);
13271
- }
13272
-
13273
- &:active {
13274
- --wui-radio-card-border-color: var(--wui-color-border-secondary-active);
13275
- }
13937
+ svg {
13938
+ transition: all var(--wui-motion-duration-03) var(--wui-motion-ease);
13939
+ }
13276
13940
 
13277
- &:has(input:checked) {
13278
- ${({ $isGated }) => $isGated ? getColorScheme("purple") : checkedStyles}
13279
- }
13941
+ &:hover {
13942
+ --wui-radio-card-border-color: var(--wui-color-border-secondary-hover);
13943
+ }
13280
13944
 
13281
- &:has(input:disabled) {
13282
- ${disabledStyles}
13283
- }
13945
+ &:active {
13946
+ --wui-radio-card-border-color: var(--wui-color-border-secondary-active);
13947
+ }
13284
13948
 
13285
- &:has(input:focus-visible) {
13286
- ${focusStyles}
13287
- }
13949
+ &:has(input:checked) {
13950
+ ${({ $isGated }) => $isGated ? getColorScheme("purple") : checkedStyles}
13951
+ }
13288
13952
 
13289
- &:has([data-wui-radio-card-image]) {
13290
13953
  &:has(input:disabled) {
13291
- [data-wui-radio-card-image] {
13292
- filter: grayscale(100%);
13293
- }
13954
+ ${disabledStyles}
13294
13955
  }
13295
13956
 
13296
- &:has([data-wui-radio-card-image='cover']) {
13297
- ${imageCoverStyles}
13957
+ &:has(input:focus-visible) {
13958
+ ${focusStyles}
13298
13959
  }
13299
- }
13300
- `;
13960
+
13961
+ &:has([data-wui-radio-card-image]) {
13962
+ &:has(input:disabled) {
13963
+ [data-wui-radio-card-image] {
13964
+ filter: grayscale(100%);
13965
+ }
13966
+ }
13967
+
13968
+ &:has([data-wui-radio-card-image='cover']) {
13969
+ ${imageCoverStyles}
13970
+ }
13971
+ }
13972
+ `;
13301
13973
  const StyledHiddenInput = styled.input`
13302
13974
  ${visuallyHiddenStyle}
13303
13975
  `;
@@ -15031,6 +15703,6 @@ const WistiaLogo = ({ description, height = 100, hoverColor, href, iconOnly = fa
15031
15703
  };
15032
15704
  WistiaLogo.displayName = "WistiaLogo_UI";
15033
15705
  //#endregion
15034
- export { ActionButton, Avatar, Badge, Banner, Box, Breadcrumb, Breadcrumbs, Button, ButtonGroup, Card, Center, Checkbox, CheckboxGroup, CheckboxMenuItem, ClickRegion, Collapsible, CollapsibleContent, CollapsibleTrigger, CollapsibleTriggerIcon, ColorGrid, ColorGridOption, ColorList, ColorListGroup, ColorListOption, ColorPicker, ColorPickerPopoverContent, ColorPickerSection, ColorPickerTrigger, ColorSchemeWrapper, Combobox, ComboboxOption, ContextMenu, ContrastControls, CustomizableThemeWrapper, DataCard, DataCardHoverArrow, DataCardTrend, DataCards, DataList, DataListItem, DataListItemLabel, DataListItemValue, Divider, EditableHeading, EditableText, EditableTextCancelButton, EditableTextContext, EditableTextDisplay, EditableTextInput, EditableTextLabel, EditableTextRoot, EditableTextSubmitButton, EditableTextTrigger, Ellipsis, FeatureCard, FeatureCardImage, FileAmountLimitValidator, FileSizeValidator, FileTypeValidator, FilterMenu, FilterMenuItem, Form, FormErrorSummary, FormField, FormGroup, Grid, Heading, HexColorInput, HueSlider, Icon, IconButton, Image, ImageDimensionsValidator, Input, InputClickToCopy, InputPassword, KeyboardShortcut, Label, Link, List, ListItem, Mark, Markdown, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Meter, Modal, ModalCallout, ModalCallouts, PersistentFileAmountLimitValidator, Popover, PopoverAnchor, PopoverArrow, PopoverClose, PopoverCloseButton, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, PreviewCard, ProgressBar, Radio, RadioCard, RadioCardImage, RadioGroup, RadioMenuItem, SaturationAndValuePicker, ScreenReaderOnly, ScrollArea, SegmentedControl, SegmentedControlItem, Select, SelectOption, SelectOptionGroup, Slider, SplitButton, Stack, SubMenu, Switch, Table, TableBody, TableCell, TableFoot, TableHead, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Text, Thumbnail, ThumbnailBadge, ThumbnailCollage, Tooltip, UIProvider, ValueNameOrHexCode, ValueSwatch, WistiaLogo, calculateContrast, coerceToBoolean, colorSchemeOptions, copyToClipboard, dateTime, iconSizeMap, isKeyboardKey, mergeRefs, mq, useActiveMq, useAriaLive, useBoolean, useClipboard, useElementObserver, useFilePicker, useFocusTrap, useForceUpdate, useFormState, useImperativeFilePicker, useIsHovered, useKey, useKeyPress, useLocalStorage, useLockBodyScroll, useMq, useOnClickOutside, usePreviousValue, useToast, useWindowSize, validateWithYup };
15706
+ export { ActionButton, Avatar, Badge, Banner, Box, Breadcrumb, Breadcrumbs, Button, ButtonGroup, Card, Center, Checkbox, CheckboxGroup, CheckboxMenuItem, ClickRegion, Collapsible, CollapsibleContent, CollapsibleTrigger, CollapsibleTriggerIcon, ColorGrid, ColorGridOption, ColorList, ColorListGroup, ColorListOption, ColorPicker, ColorPickerPopoverContent, ColorPickerSection, ColorPickerTrigger, ColorSchemeWrapper, Combobox, ComboboxOption, ContextMenu, ContrastControls, CustomizableThemeWrapper, DataCard, DataCardHoverArrow, DataCardTrend, DataCards, DataList, DataListItem, DataListItemLabel, DataListItemValue, Divider, DurationInput, EditableHeading, EditableText, EditableTextCancelButton, EditableTextContext, EditableTextDisplay, EditableTextInput, EditableTextLabel, EditableTextRoot, EditableTextSubmitButton, EditableTextTrigger, Ellipsis, FeatureCard, FeatureCardImage, FileAmountLimitValidator, FileSizeValidator, FileTypeValidator, FilterMenu, FilterMenuItem, Form, FormErrorSummary, FormField, FormGroup, Grid, Heading, HexColorInput, HueSlider, Icon, IconButton, Image, ImageDimensionsValidator, Input, InputClickToCopy, InputPassword, KeyboardShortcut, Label, Link, List, ListItem, Mark, Markdown, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Meter, Modal, ModalCallout, ModalCallouts, PersistentFileAmountLimitValidator, Popover, PopoverAnchor, PopoverArrow, PopoverClose, PopoverCloseButton, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger, PreviewCard, ProgressBar, Radio, RadioCard, RadioCardImage, RadioGroup, RadioMenuItem, SaturationAndValuePicker, ScreenReaderOnly, ScrollArea, SegmentedControl, SegmentedControlItem, Select, SelectOption, SelectOptionGroup, Slider, SplitButton, Stack, SubMenu, Switch, Table, TableBody, TableCell, TableFoot, TableHead, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Text, Thumbnail, ThumbnailBadge, ThumbnailCollage, Tooltip, UIProvider, ValueNameOrHexCode, ValueSwatch, WistiaLogo, buildTimeDuration, calculateContrast, coerceToBoolean, colorSchemeOptions, copyToClipboard, dateOnlyISOString, dateOnlyString, dateOnlyStringForSentence, dateOnlyStringNumeric, dateTime, dateTimeRounded, dateTimeString, dateTimeStringForSentence, dateTimeToDate, dateTimeToISO, dateToDateTime, dateUTCOffset, dayOfWeekString, iconSizeMap, isKeyboardKey, mediaDurationString, mergeRefs, millisecondsToDurationISOString, monthDayStringNumeric, mq, parseDateString, sessionDurationString, timeAgoString, timeOnlyString, useActiveMq, useAriaLive, useBoolean, useClipboard, useElementObserver, useFilePicker, useFocusTrap, useForceUpdate, useFormState, useImperativeFilePicker, useIsHovered, useKey, useKeyPress, useLocalStorage, useLockBodyScroll, useMq, useOnClickOutside, usePreviousValue, useToast, useWindowSize, validateWithYup };
15035
15707
 
15036
15708
  //# sourceMappingURL=index.js.map