Rocky_Mountain_Vending/.pnpm-store/v10/files/4c/4b7f6e05ded22f62b6a6b76fa6d09e66678f07d48e5c88ce9f2ae5188d38ef03c84f5940a2689a1c320c78f4034ee682ba2b7a17a70063eb0cc855aab213c4
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

58 lines
No EOL
2.1 KiB
Text

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMulti = useMulti;
const useControlledValue_js_1 = require("../helpers/useControlledValue.js");
/**
* Hook to manage multiple-date selection in the DayPicker component.
*
* @template T - The type of DayPicker props.
* @param props - The DayPicker props.
* @param dateLib - The date utility library instance.
* @returns An object containing the selected dates, a function to select dates,
* and a function to check if a date is selected.
*/
function useMulti(props, dateLib) {
const { selected: initiallySelected, required, onSelect } = props;
const [internallySelected, setSelected] = (0, useControlledValue_js_1.useControlledValue)(initiallySelected, onSelect ? initiallySelected : undefined);
const selected = !onSelect ? internallySelected : initiallySelected;
const { isSameDay } = dateLib;
const isSelected = (date) => {
return selected?.some((d) => isSameDay(d, date)) ?? false;
};
const { min, max } = props;
const select = (triggerDate, modifiers, e) => {
let newDates = [...(selected ?? [])];
if (isSelected(triggerDate)) {
if (selected?.length === min) {
// Min value reached, do nothing
return;
}
if (required && selected?.length === 1) {
// Required value already selected do nothing
return;
}
newDates = selected?.filter((d) => !isSameDay(d, triggerDate));
}
else {
if (selected?.length === max) {
// Max value reached, reset the selection to date
newDates = [triggerDate];
}
else {
// Add the date to the selection
newDates = [...newDates, triggerDate];
}
}
if (!onSelect) {
setSelected(newDates);
}
onSelect?.(newDates, triggerDate, modifiers, e);
return newDates;
};
return {
selected,
select,
isSelected
};
}
//# sourceMappingURL=useMulti.js.map