@lime-bundles/react 7.2.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 +47 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.css +137 -19
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3076,6 +3076,8 @@ function normalizeText2(str) {
|
|
|
3076
3076
|
return str.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
3077
3077
|
}
|
|
3078
3078
|
var FILTERS_ALL2 = "__all__";
|
|
3079
|
+
var STEP_CASCADE_MS = 500;
|
|
3080
|
+
var AUTO_ADVANCE_HOLD_MS = 160;
|
|
3079
3081
|
function MultiStepPicker({
|
|
3080
3082
|
bundle,
|
|
3081
3083
|
currency,
|
|
@@ -3099,6 +3101,8 @@ function MultiStepPicker({
|
|
|
3099
3101
|
const closeBtnRef = useRef7(null);
|
|
3100
3102
|
const listRef = useRef7(null);
|
|
3101
3103
|
const mouseDownTarget = useRef7(null);
|
|
3104
|
+
const cascadeTimer = useRef7(null);
|
|
3105
|
+
const autoAdvanceTimer = useRef7(null);
|
|
3102
3106
|
const [open, setOpen] = useState11(false);
|
|
3103
3107
|
const [stepIndex, setStepIndex] = useState11(
|
|
3104
3108
|
() => Math.max(0, Math.min(steps.length - 1, initialStep))
|
|
@@ -3134,6 +3138,14 @@ function MultiStepPicker({
|
|
|
3134
3138
|
const id = requestAnimationFrame(() => setOpen(true));
|
|
3135
3139
|
return () => cancelAnimationFrame(id);
|
|
3136
3140
|
}, []);
|
|
3141
|
+
useEffect14(() => {
|
|
3142
|
+
return () => {
|
|
3143
|
+
if (cascadeTimer.current !== null) clearTimeout(cascadeTimer.current);
|
|
3144
|
+
if (autoAdvanceTimer.current !== null) {
|
|
3145
|
+
clearTimeout(autoAdvanceTimer.current);
|
|
3146
|
+
}
|
|
3147
|
+
};
|
|
3148
|
+
}, []);
|
|
3137
3149
|
useScrollLock(true);
|
|
3138
3150
|
useFocusTrap({
|
|
3139
3151
|
active: true,
|
|
@@ -3155,8 +3167,43 @@ function MultiStepPicker({
|
|
|
3155
3167
|
}
|
|
3156
3168
|
return front.concat(back);
|
|
3157
3169
|
}, [eligible, selectedAtLoad]);
|
|
3170
|
+
const autoAdvance = wc.multiStepAutoAdvance === true;
|
|
3171
|
+
const lastSeen = useRef7({ step: stepIndex, units: unitsInStep });
|
|
3172
|
+
useEffect14(() => {
|
|
3173
|
+
const prev = lastSeen.current;
|
|
3174
|
+
lastSeen.current = { step: stepIndex, units: unitsInStep };
|
|
3175
|
+
if (!autoAdvance || isLastStep || prev.step !== stepIndex) return;
|
|
3176
|
+
if (unitsInStep <= prev.units) return;
|
|
3177
|
+
if (stepHeadroom(step?.maxQuantity ?? null, unitsInStep) !== 0) return;
|
|
3178
|
+
const from = stepIndex;
|
|
3179
|
+
if (autoAdvanceTimer.current !== null) {
|
|
3180
|
+
clearTimeout(autoAdvanceTimer.current);
|
|
3181
|
+
}
|
|
3182
|
+
autoAdvanceTimer.current = setTimeout(() => {
|
|
3183
|
+
autoAdvanceTimer.current = null;
|
|
3184
|
+
goToStep(from + 1);
|
|
3185
|
+
}, AUTO_ADVANCE_HOLD_MS);
|
|
3186
|
+
});
|
|
3158
3187
|
function goToStep(i) {
|
|
3159
3188
|
const clamped = Math.max(0, Math.min(steps.length - 1, i));
|
|
3189
|
+
if (autoAdvanceTimer.current !== null) {
|
|
3190
|
+
clearTimeout(autoAdvanceTimer.current);
|
|
3191
|
+
autoAdvanceTimer.current = null;
|
|
3192
|
+
}
|
|
3193
|
+
const dialog = dialogRef.current;
|
|
3194
|
+
if (dialog && clamped !== stepIndex) {
|
|
3195
|
+
if (cascadeTimer.current !== null) clearTimeout(cascadeTimer.current);
|
|
3196
|
+
dialog.removeAttribute("data-step-transition");
|
|
3197
|
+
void dialog.offsetHeight;
|
|
3198
|
+
dialog.setAttribute(
|
|
3199
|
+
"data-step-transition",
|
|
3200
|
+
clamped > stepIndex ? "forward" : "back"
|
|
3201
|
+
);
|
|
3202
|
+
cascadeTimer.current = setTimeout(() => {
|
|
3203
|
+
cascadeTimer.current = null;
|
|
3204
|
+
dialog.removeAttribute("data-step-transition");
|
|
3205
|
+
}, STEP_CASCADE_MS);
|
|
3206
|
+
}
|
|
3160
3207
|
setStepIndex(clamped);
|
|
3161
3208
|
setQuery("");
|
|
3162
3209
|
setActiveType(FILTERS_ALL2);
|