@lime-bundles/react 7.3.0 → 7.3.1

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.cjs CHANGED
@@ -3066,6 +3066,8 @@ function normalizeText2(str) {
3066
3066
  return str.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
3067
3067
  }
3068
3068
  var FILTERS_ALL2 = "__all__";
3069
+ var STEP_CASCADE_MS = 500;
3070
+ var AUTO_ADVANCE_HOLD_MS = 160;
3069
3071
  function MultiStepPicker({
3070
3072
  bundle,
3071
3073
  currency,
@@ -3089,6 +3091,8 @@ function MultiStepPicker({
3089
3091
  const closeBtnRef = (0, import_react15.useRef)(null);
3090
3092
  const listRef = (0, import_react15.useRef)(null);
3091
3093
  const mouseDownTarget = (0, import_react15.useRef)(null);
3094
+ const cascadeTimer = (0, import_react15.useRef)(null);
3095
+ const autoAdvanceTimer = (0, import_react15.useRef)(null);
3092
3096
  const [open, setOpen] = (0, import_react15.useState)(false);
3093
3097
  const [stepIndex, setStepIndex] = (0, import_react15.useState)(
3094
3098
  () => Math.max(0, Math.min(steps.length - 1, initialStep))
@@ -3124,6 +3128,14 @@ function MultiStepPicker({
3124
3128
  const id = requestAnimationFrame(() => setOpen(true));
3125
3129
  return () => cancelAnimationFrame(id);
3126
3130
  }, []);
3131
+ (0, import_react15.useEffect)(() => {
3132
+ return () => {
3133
+ if (cascadeTimer.current !== null) clearTimeout(cascadeTimer.current);
3134
+ if (autoAdvanceTimer.current !== null) {
3135
+ clearTimeout(autoAdvanceTimer.current);
3136
+ }
3137
+ };
3138
+ }, []);
3127
3139
  useScrollLock(true);
3128
3140
  useFocusTrap({
3129
3141
  active: true,
@@ -3152,12 +3164,36 @@ function MultiStepPicker({
3152
3164
  lastSeen.current = { step: stepIndex, units: unitsInStep };
3153
3165
  if (!autoAdvance || isLastStep || prev.step !== stepIndex) return;
3154
3166
  if (unitsInStep <= prev.units) return;
3155
- if ((0, import_core13.stepHeadroom)(step?.maxQuantity ?? null, unitsInStep) === 0) {
3156
- goToStep(stepIndex + 1);
3167
+ if ((0, import_core13.stepHeadroom)(step?.maxQuantity ?? null, unitsInStep) !== 0) return;
3168
+ const from = stepIndex;
3169
+ if (autoAdvanceTimer.current !== null) {
3170
+ clearTimeout(autoAdvanceTimer.current);
3157
3171
  }
3172
+ autoAdvanceTimer.current = setTimeout(() => {
3173
+ autoAdvanceTimer.current = null;
3174
+ goToStep(from + 1);
3175
+ }, AUTO_ADVANCE_HOLD_MS);
3158
3176
  });
3159
3177
  function goToStep(i) {
3160
3178
  const clamped = Math.max(0, Math.min(steps.length - 1, i));
3179
+ if (autoAdvanceTimer.current !== null) {
3180
+ clearTimeout(autoAdvanceTimer.current);
3181
+ autoAdvanceTimer.current = null;
3182
+ }
3183
+ const dialog = dialogRef.current;
3184
+ if (dialog && clamped !== stepIndex) {
3185
+ if (cascadeTimer.current !== null) clearTimeout(cascadeTimer.current);
3186
+ dialog.removeAttribute("data-step-transition");
3187
+ void dialog.offsetHeight;
3188
+ dialog.setAttribute(
3189
+ "data-step-transition",
3190
+ clamped > stepIndex ? "forward" : "back"
3191
+ );
3192
+ cascadeTimer.current = setTimeout(() => {
3193
+ cascadeTimer.current = null;
3194
+ dialog.removeAttribute("data-step-transition");
3195
+ }, STEP_CASCADE_MS);
3196
+ }
3161
3197
  setStepIndex(clamped);
3162
3198
  setQuery("");
3163
3199
  setActiveType(FILTERS_ALL2);