Rocky_Mountain_Vending/.pnpm-store/v10/files/87/b3585b388f1a543673614a738aea36356f691941808dc1e28bb7a4feaa38983e6aebcd018e53edfb0edc8a43b13308550f4704e450932a84b6e96a0043a36a
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

45 lines
No EOL
1.7 KiB
Text

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSingle = useSingle;
const useControlledValue_js_1 = require("../helpers/useControlledValue.js");
/**
* Hook to manage single-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 date, a function to select a date,
* and a function to check if a date is selected.
*/
function useSingle(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 = (compareDate) => {
return selected ? isSameDay(selected, compareDate) : false;
};
const select = (triggerDate, modifiers, e) => {
let newDate = triggerDate;
if (!required && selected && selected && isSameDay(triggerDate, selected)) {
// If the date is the same, clear the selection.
newDate = undefined;
}
if (!onSelect) {
setSelected(newDate);
}
if (required) {
onSelect?.(newDate, triggerDate, modifiers, e);
}
else {
onSelect?.(newDate, triggerDate, modifiers, e);
}
return newDate;
};
return {
selected,
select,
isSelected
};
}
//# sourceMappingURL=useSingle.js.map