Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,335 @@
'use client';
import { jsxs, jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { useImperativeHandle, useRef, useEffect } from 'react';
import { factory, useProps, useResolvedStylesApi, Box } from '@mantine/core';
import { useUncontrolled } from '@mantine/hooks';
import { useUncontrolledDates } from '../../hooks/use-uncontrolled-dates/use-uncontrolled-dates.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { toDateString } from '../../utils/to-date-string/to-date-string.mjs';
import { DecadeLevelGroup } from '../DecadeLevelGroup/DecadeLevelGroup.mjs';
import { MonthLevelGroup } from '../MonthLevelGroup/MonthLevelGroup.mjs';
import { YearLevelGroup } from '../YearLevelGroup/YearLevelGroup.mjs';
import { clampLevel } from './clamp-level/clamp-level.mjs';
const defaultProps = {
maxLevel: "decade",
minLevel: "month",
__updateDateOnYearSelect: true,
__updateDateOnMonthSelect: true,
enableKeyboardNavigation: true
};
const Calendar = factory((_props, ref) => {
const props = useProps("Calendar", defaultProps, _props);
const {
// CalendarLevel props
vars,
maxLevel,
minLevel,
defaultLevel,
level,
onLevelChange,
date,
defaultDate,
onDateChange,
numberOfColumns,
columnsToScroll,
ariaLabels,
nextLabel,
previousLabel,
onYearSelect,
onMonthSelect,
onYearMouseEnter,
onMonthMouseEnter,
headerControlsOrder,
__updateDateOnYearSelect,
__updateDateOnMonthSelect,
__setDateRef,
__setLevelRef,
// MonthLevelGroup props
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
monthLabelFormat,
nextIcon,
previousIcon,
__onDayClick,
__onDayMouseEnter,
withCellSpacing,
highlightToday,
withWeekNumbers,
// YearLevelGroup props
monthsListFormat,
getMonthControlProps,
yearLabelFormat,
// DecadeLevelGroup props
yearsListFormat,
getYearControlProps,
decadeLabelFormat,
// Other props
classNames,
styles,
unstyled,
minDate,
maxDate,
locale,
__staticSelector,
size,
__preventFocus,
__stopPropagation,
onNextDecade,
onPreviousDecade,
onNextYear,
onPreviousYear,
onNextMonth,
onPreviousMonth,
static: isStatic,
enableKeyboardNavigation,
attributes,
...others
} = props;
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
const [_level, setLevel] = useUncontrolled({
value: level ? clampLevel(level, minLevel, maxLevel) : void 0,
defaultValue: defaultLevel ? clampLevel(defaultLevel, minLevel, maxLevel) : void 0,
finalValue: clampLevel(void 0, minLevel, maxLevel),
onChange: onLevelChange
});
const [_date, setDate] = useUncontrolledDates({
type: "default",
value: toDateString(date),
defaultValue: toDateString(defaultDate),
onChange: onDateChange
});
useImperativeHandle(__setDateRef, () => (date2) => {
setDate(date2);
});
useImperativeHandle(__setLevelRef, () => (level2) => {
setLevel(level2);
});
const stylesApiProps = {
__staticSelector: __staticSelector || "Calendar",
styles: resolvedStyles,
classNames: resolvedClassNames,
unstyled,
size,
attributes
};
const _columnsToScroll = columnsToScroll || numberOfColumns || 1;
const now = /* @__PURE__ */ new Date();
const fallbackDate = minDate && dayjs(now).isAfter(minDate) ? minDate : dayjs(now).format("YYYY-MM-DD");
const currentDate = _date || fallbackDate;
const handleNextMonth = () => {
const nextDate = dayjs(currentDate).add(_columnsToScroll, "month").format("YYYY-MM-DD");
onNextMonth?.(nextDate);
setDate(nextDate);
};
const handlePreviousMonth = () => {
const nextDate = dayjs(currentDate).subtract(_columnsToScroll, "month").format("YYYY-MM-DD");
onPreviousMonth?.(nextDate);
setDate(nextDate);
};
const handleNextYear = () => {
const nextDate = dayjs(currentDate).add(_columnsToScroll, "year").format("YYYY-MM-DD");
onNextYear?.(nextDate);
setDate(nextDate);
};
const handlePreviousYear = () => {
const nextDate = dayjs(currentDate).subtract(_columnsToScroll, "year").format("YYYY-MM-DD");
onPreviousYear?.(nextDate);
setDate(nextDate);
};
const handleNextDecade = () => {
const nextDate = dayjs(currentDate).add(10 * _columnsToScroll, "year").format("YYYY-MM-DD");
onNextDecade?.(nextDate);
setDate(nextDate);
};
const handlePreviousDecade = () => {
const nextDate = dayjs(currentDate).subtract(10 * _columnsToScroll, "year").format("YYYY-MM-DD");
onPreviousDecade?.(nextDate);
setDate(nextDate);
};
const calendarRef = useRef(null);
useEffect(() => {
if (!enableKeyboardNavigation || isStatic) {
return;
}
const handleKeyDown = (event) => {
if (!calendarRef.current?.contains(document.activeElement)) {
return;
}
const isCtrlOrCmd = event.ctrlKey || event.metaKey;
const isShift = event.shiftKey;
switch (event.key) {
case "ArrowUp":
if (isCtrlOrCmd && isShift) {
event.preventDefault();
handlePreviousDecade();
} else if (isCtrlOrCmd) {
event.preventDefault();
handlePreviousYear();
}
break;
case "ArrowDown":
if (isCtrlOrCmd && isShift) {
event.preventDefault();
handleNextDecade();
} else if (isCtrlOrCmd) {
event.preventDefault();
handleNextYear();
}
break;
case "y":
case "Y":
if (_level === "month") {
event.preventDefault();
setLevel("year");
}
break;
}
};
document.addEventListener("keydown", handleKeyDown);
return () => {
document.removeEventListener("keydown", handleKeyDown);
};
}, [
enableKeyboardNavigation,
isStatic,
_level,
handleNextYear,
handlePreviousYear,
handleNextDecade,
handlePreviousDecade
]);
const mergedRef = (node) => {
calendarRef.current = node;
if (typeof ref === "function") {
ref(node);
} else if (ref) {
ref.current = node;
}
};
return /* @__PURE__ */ jsxs(Box, { ref: mergedRef, size, "data-calendar": true, ...others, children: [
_level === "month" && /* @__PURE__ */ jsx(
MonthLevelGroup,
{
month: currentDate,
minDate,
maxDate,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
onNext: handleNextMonth,
onPrevious: handlePreviousMonth,
hasNextLevel: maxLevel !== "month",
onLevelClick: () => setLevel("year"),
numberOfColumns,
locale,
levelControlAriaLabel: ariaLabels?.monthLevelControl,
nextLabel: ariaLabels?.nextMonth ?? nextLabel,
nextIcon,
previousLabel: ariaLabels?.previousMonth ?? previousLabel,
previousIcon,
monthLabelFormat,
__onDayClick,
__onDayMouseEnter,
__preventFocus,
__stopPropagation,
static: isStatic,
withCellSpacing,
highlightToday,
withWeekNumbers,
headerControlsOrder,
...stylesApiProps
}
),
_level === "year" && /* @__PURE__ */ jsx(
YearLevelGroup,
{
year: currentDate,
numberOfColumns,
minDate,
maxDate,
monthsListFormat,
getMonthControlProps,
locale,
onNext: handleNextYear,
onPrevious: handlePreviousYear,
hasNextLevel: maxLevel !== "month" && maxLevel !== "year",
onLevelClick: () => setLevel("decade"),
levelControlAriaLabel: ariaLabels?.yearLevelControl,
nextLabel: ariaLabels?.nextYear ?? nextLabel,
nextIcon,
previousLabel: ariaLabels?.previousYear ?? previousLabel,
previousIcon,
yearLabelFormat,
__onControlMouseEnter: onMonthMouseEnter,
__onControlClick: (_event, payload) => {
__updateDateOnMonthSelect && setDate(payload);
setLevel(clampLevel("month", minLevel, maxLevel));
onMonthSelect?.(payload);
},
__preventFocus,
__stopPropagation,
withCellSpacing,
headerControlsOrder,
...stylesApiProps
}
),
_level === "decade" && /* @__PURE__ */ jsx(
DecadeLevelGroup,
{
decade: currentDate,
minDate,
maxDate,
yearsListFormat,
getYearControlProps,
locale,
onNext: handleNextDecade,
onPrevious: handlePreviousDecade,
numberOfColumns,
nextLabel: ariaLabels?.nextDecade ?? nextLabel,
nextIcon,
previousLabel: ariaLabels?.previousDecade ?? previousLabel,
previousIcon,
decadeLabelFormat,
__onControlMouseEnter: onYearMouseEnter,
__onControlClick: (_event, payload) => {
__updateDateOnYearSelect && setDate(payload);
setLevel(clampLevel("year", minLevel, maxLevel));
onYearSelect?.(payload);
},
__preventFocus,
__stopPropagation,
withCellSpacing,
headerControlsOrder,
...stylesApiProps
}
)
] });
});
Calendar.classes = {
...DecadeLevelGroup.classes,
...YearLevelGroup.classes,
...MonthLevelGroup.classes
};
Calendar.displayName = "@mantine/dates/Calendar";
export { Calendar };
//# sourceMappingURL=Calendar.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,24 @@
'use client';
import { clamp } from '@mantine/hooks';
function levelToNumber(level, fallback) {
if (!level) {
return fallback || 0;
}
return level === "month" ? 0 : level === "year" ? 1 : 2;
}
function levelNumberToLevel(levelNumber) {
return levelNumber === 0 ? "month" : levelNumber === 1 ? "year" : "decade";
}
function clampLevel(level, minLevel, maxLevel) {
return levelNumberToLevel(
clamp(
levelToNumber(level, 0),
levelToNumber(minLevel, 0),
levelToNumber(maxLevel, 2)
)
);
}
export { clampLevel };
//# sourceMappingURL=clamp-level.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"clamp-level.mjs","sources":["../../../../src/components/Calendar/clamp-level/clamp-level.ts"],"sourcesContent":["import { clamp } from '@mantine/hooks';\nimport type { CalendarLevel } from '../../../types';\n\n// 0 month, 1 year, 2 decade;\ntype LevelNumber = 0 | 1 | 2;\n\nfunction levelToNumber(\n level: CalendarLevel | undefined,\n fallback: LevelNumber | undefined\n): LevelNumber {\n if (!level) {\n return fallback || 0;\n }\n\n return level === 'month' ? 0 : level === 'year' ? 1 : 2;\n}\n\nfunction levelNumberToLevel(levelNumber: LevelNumber | undefined): CalendarLevel {\n return levelNumber === 0 ? 'month' : levelNumber === 1 ? 'year' : 'decade';\n}\n\nexport function clampLevel(\n level: CalendarLevel | undefined,\n minLevel: CalendarLevel | undefined,\n maxLevel: CalendarLevel | undefined\n): CalendarLevel {\n return levelNumberToLevel(\n clamp(\n levelToNumber(level, 0),\n levelToNumber(minLevel, 0),\n levelToNumber(maxLevel, 2)\n ) as LevelNumber\n );\n}\n"],"names":[],"mappings":";;;AAMA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACP,CAAA,CAAA,CAAA,CAAA,GACA,QAAA,CAAA,CACa,CAAA;AACb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,CAAA,CAAA,GAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACpE,CAAA;AAEO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,UAAA,CACd,CAAA,CAAA,CAAA,CAAA,CAAA,EACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,QAAA,CAAA,CACe,CAAA;AACf,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACL,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,GAAO,CAAC,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACtB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAU,CAAC,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACzB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAU,CAAC,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAC3B,CAAA,CAAA,CACF,CAAA;AACF,CAAA;;"}

View File

@@ -0,0 +1,131 @@
'use client';
function pickCalendarProps(props) {
const {
maxLevel,
minLevel,
defaultLevel,
level,
onLevelChange,
nextIcon,
previousIcon,
date,
defaultDate,
onDateChange,
numberOfColumns,
columnsToScroll,
ariaLabels,
nextLabel,
previousLabel,
onYearSelect,
onMonthSelect,
onYearMouseEnter,
onMonthMouseEnter,
onNextMonth,
onPreviousMonth,
onNextYear,
onPreviousYear,
onNextDecade,
onPreviousDecade,
withCellSpacing,
highlightToday,
__updateDateOnYearSelect,
__updateDateOnMonthSelect,
__setDateRef,
__setLevelRef,
withWeekNumbers,
headerControlsOrder,
// MonthLevelGroup props
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
monthLabelFormat,
// YearLevelGroup props
monthsListFormat,
getMonthControlProps,
yearLabelFormat,
// DecadeLevelGroup props
yearsListFormat,
getYearControlProps,
decadeLabelFormat,
// External picker props
allowSingleDateInRange,
allowDeselect,
// Other props
minDate,
maxDate,
locale,
...others
} = props;
return {
calendarProps: {
maxLevel,
minLevel,
defaultLevel,
level,
onLevelChange,
nextIcon,
previousIcon,
date,
defaultDate,
onDateChange,
numberOfColumns,
columnsToScroll,
ariaLabels,
nextLabel,
previousLabel,
onYearSelect,
onMonthSelect,
onYearMouseEnter,
onMonthMouseEnter,
onNextMonth,
onPreviousMonth,
onNextYear,
onPreviousYear,
onNextDecade,
onPreviousDecade,
withCellSpacing,
highlightToday,
__updateDateOnYearSelect,
__updateDateOnMonthSelect,
__setDateRef,
withWeekNumbers,
headerControlsOrder,
// MonthLevelGroup props
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
monthLabelFormat,
// YearLevelGroup props
monthsListFormat,
getMonthControlProps,
yearLabelFormat,
// DecadeLevelGroup props
yearsListFormat,
getYearControlProps,
decadeLabelFormat,
// External picker props
allowSingleDateInRange,
allowDeselect,
// Other props
minDate,
maxDate,
locale
},
others
};
}
export { pickCalendarProps };
//# sourceMappingURL=pick-calendar-levels-props.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,147 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { createElement } from 'react';
import { createVarsResolver, getFontSize, getSize, factory, useProps, useStyles, UnstyledButton, AccordionChevron, Box } from '@mantine/core';
import classes from './CalendarHeader.module.css.mjs';
const defaultProps = {
hasNextLevel: true,
withNext: true,
withPrevious: true,
headerControlsOrder: ["previous", "level", "next"]
};
const varsResolver = createVarsResolver((_, { size }) => ({
calendarHeader: {
"--dch-control-size": getSize(size, "dch-control-size"),
"--dch-fz": getFontSize(size)
}
}));
const CalendarHeader = factory((_props, ref) => {
const props = useProps("CalendarHeader", defaultProps, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
label,
nextDisabled,
previousDisabled,
hasNextLevel,
levelControlAriaLabel,
withNext,
withPrevious,
headerControlsOrder,
__staticSelector,
__preventFocus,
__stopPropagation,
attributes,
...others
} = props;
const getStyles = useStyles({
name: __staticSelector || "CalendarHeader",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars,
varsResolver,
rootSelector: "calendarHeader"
});
const preventFocus = __preventFocus ? (event) => event.preventDefault() : void 0;
const previousControl = withPrevious && /* @__PURE__ */ createElement(
UnstyledButton,
{
...getStyles("calendarHeaderControl"),
key: "previous",
"data-direction": "previous",
"aria-label": previousLabel,
onClick: onPrevious,
unstyled,
onMouseDown: preventFocus,
disabled: previousDisabled,
"data-disabled": previousDisabled || void 0,
tabIndex: __preventFocus || previousDisabled ? -1 : 0,
"data-mantine-stop-propagation": __stopPropagation || void 0
},
previousIcon || /* @__PURE__ */ jsx(
AccordionChevron,
{
...getStyles("calendarHeaderControlIcon"),
"data-direction": "previous",
size: "45%"
}
)
);
const levelControl = /* @__PURE__ */ createElement(
UnstyledButton,
{
component: hasNextLevel ? "button" : "div",
...getStyles("calendarHeaderLevel"),
key: "level",
onClick: hasNextLevel ? onLevelClick : void 0,
unstyled,
onMouseDown: hasNextLevel ? preventFocus : void 0,
disabled: !hasNextLevel,
"data-static": !hasNextLevel || void 0,
"aria-label": levelControlAriaLabel,
tabIndex: __preventFocus || !hasNextLevel ? -1 : 0,
"data-mantine-stop-propagation": __stopPropagation || void 0
},
label
);
const nextControl = withNext && /* @__PURE__ */ createElement(
UnstyledButton,
{
...getStyles("calendarHeaderControl"),
key: "next",
"data-direction": "next",
"aria-label": nextLabel,
onClick: onNext,
unstyled,
onMouseDown: preventFocus,
disabled: nextDisabled,
"data-disabled": nextDisabled || void 0,
tabIndex: __preventFocus || nextDisabled ? -1 : 0,
"data-mantine-stop-propagation": __stopPropagation || void 0
},
nextIcon || /* @__PURE__ */ jsx(
AccordionChevron,
{
...getStyles("calendarHeaderControlIcon"),
"data-direction": "next",
size: "45%"
}
)
);
const controls = headerControlsOrder.map((control) => {
if (control === "previous") {
return previousControl;
}
if (control === "level") {
return levelControl;
}
if (control === "next") {
return nextControl;
}
return null;
});
return /* @__PURE__ */ jsx(Box, { ...getStyles("calendarHeader"), ref, ...others, children: controls });
});
CalendarHeader.classes = classes;
CalendarHeader.displayName = "@mantine/dates/CalendarHeader";
export { CalendarHeader };
//# sourceMappingURL=CalendarHeader.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"calendarHeader":"m_730a79ed","calendarHeaderLevel":"m_f6645d97","calendarHeaderControl":"m_2351eeb0","calendarHeaderControlIcon":"m_367dc749"};
export { classes as default };
//# sourceMappingURL=CalendarHeader.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CalendarHeader.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,238 @@
'use client';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { useRef, useState, useEffect } from 'react';
import { factory, useInputProps, Input, Popover } from '@mantine/core';
import { useDidUpdate, useClickOutside } from '@mantine/hooks';
import { useUncontrolledDates } from '../../hooks/use-uncontrolled-dates/use-uncontrolled-dates.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import { Calendar } from '../Calendar/Calendar.mjs';
import { pickCalendarProps } from '../Calendar/pick-calendar-levels-props/pick-calendar-levels-props.mjs';
import { HiddenDatesInput } from '../HiddenDatesInput/HiddenDatesInput.mjs';
import { isSameMonth } from '../Month/is-same-month/is-same-month.mjs';
import '../Month/Month.mjs';
import { dateStringParser } from './date-string-parser/date-string-parser.mjs';
import { isDateValid } from './is-date-valid/is-date-valid.mjs';
const defaultProps = {
valueFormat: "MMMM D, YYYY",
fixOnBlur: true,
size: "sm"
};
const DateInput = factory((_props, ref) => {
const props = useInputProps("DateInput", defaultProps, _props);
const {
inputProps,
wrapperProps,
value,
defaultValue,
onChange,
clearable,
clearButtonProps,
popoverProps,
getDayProps,
locale,
valueFormat,
dateParser,
minDate,
maxDate,
fixOnBlur,
onFocus,
onBlur,
onClick,
onKeyDown,
readOnly,
name,
form,
rightSection,
unstyled,
classNames,
styles,
allowDeselect,
date,
defaultDate,
onDateChange,
getMonthControlProps,
getYearControlProps,
disabled,
...rest
} = props;
const _wrapperRef = useRef(null);
const _dropdownRef = useRef(null);
const [dropdownOpened, setDropdownOpened] = useState(false);
const { calendarProps, others } = pickCalendarProps(rest);
const ctx = useDatesContext();
const defaultDateParser = (val) => {
const parsedDate = dayjs(val, valueFormat, ctx.getLocale(locale)).toDate();
return Number.isNaN(parsedDate.getTime()) ? dateStringParser(val) : dayjs(parsedDate).format("YYYY-MM-DD");
};
const _dateParser = dateParser || defaultDateParser;
const _allowDeselect = allowDeselect !== void 0 ? allowDeselect : clearable;
const formatValue = (val) => val ? dayjs(val).locale(ctx.getLocale(locale)).format(valueFormat) : "";
const [_value, setValue, controlled] = useUncontrolledDates({
type: "default",
value,
defaultValue,
onChange
});
const [_date, setDate] = useUncontrolledDates({
type: "default",
value: date,
defaultValue: defaultValue || defaultDate,
onChange: onDateChange
});
useEffect(() => {
if (controlled && value !== null) {
setDate(value);
}
}, [controlled, value]);
const [inputValue, setInputValue] = useState(formatValue(_value));
useEffect(() => {
setInputValue(formatValue(_value));
}, [ctx.getLocale(locale)]);
const handleInputChange = (event) => {
const val = event.currentTarget.value;
setInputValue(val);
setDropdownOpened(true);
if (val.trim() === "" && (allowDeselect || clearable)) {
setValue(null);
} else {
const dateValue = _dateParser(val);
if (dateValue && isDateValid({ date: dateValue, minDate, maxDate })) {
setValue(dateValue);
setDate(dateValue);
}
}
};
const handleInputBlur = (event) => {
onBlur?.(event);
setDropdownOpened(false);
fixOnBlur && setInputValue(formatValue(_value));
};
const handleInputFocus = (event) => {
onFocus?.(event);
setDropdownOpened(true);
};
const handleInputClick = (event) => {
onClick?.(event);
setDropdownOpened(true);
};
const handleInputKeyDown = (event) => {
if (event.key === "Escape") {
setDropdownOpened(false);
}
onKeyDown?.(event);
};
const _getDayProps = (day) => ({
...getDayProps?.(day),
selected: dayjs(_value).isSame(day, "day"),
onClick: (event) => {
getDayProps?.(day).onClick?.(event);
const val = _allowDeselect ? dayjs(_value).isSame(day, "day") ? null : day : day;
setValue(val);
!controlled && val && setInputValue(formatValue(val));
setDropdownOpened(false);
}
});
const clearButton = /* @__PURE__ */ jsx(
Input.ClearButton,
{
onClick: () => {
setValue(null);
!controlled && setInputValue("");
setDropdownOpened(false);
},
unstyled,
...clearButtonProps
}
);
const _clearable = clearable && !!_value && !readOnly && !disabled;
useDidUpdate(() => {
_value !== void 0 && !dropdownOpened && setInputValue(formatValue(_value));
}, [_value]);
useClickOutside(() => setDropdownOpened(false), void 0, [
_wrapperRef.current,
_dropdownRef.current
]);
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(Input.Wrapper, { ...wrapperProps, __staticSelector: "DateInput", ref: _wrapperRef, children: /* @__PURE__ */ jsxs(
Popover,
{
opened: dropdownOpened,
trapFocus: false,
position: "bottom-start",
disabled: readOnly || disabled,
withRoles: false,
unstyled,
...popoverProps,
children: [
/* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(
Input,
{
"data-dates-input": true,
"data-read-only": readOnly || void 0,
autoComplete: "off",
ref,
value: inputValue,
onChange: handleInputChange,
onBlur: handleInputBlur,
onFocus: handleInputFocus,
onClick: handleInputClick,
onKeyDown: handleInputKeyDown,
readOnly,
rightSection,
__clearSection: clearButton,
__clearable: _clearable,
...inputProps,
...others,
disabled,
__staticSelector: "DateInput"
}
) }),
/* @__PURE__ */ jsx(
Popover.Dropdown,
{
onMouseDown: (event) => event.preventDefault(),
"data-dates-dropdown": true,
ref: _dropdownRef,
children: /* @__PURE__ */ jsx(
Calendar,
{
__staticSelector: "DateInput",
...calendarProps,
classNames,
styles,
unstyled,
__preventFocus: true,
minDate,
maxDate,
locale,
getDayProps: _getDayProps,
size: inputProps.size,
date: _date,
onDateChange: setDate,
getMonthControlProps: (date2) => ({
selected: typeof _value === "string" ? isSameMonth(date2, _value) : false,
...getMonthControlProps?.(date2)
}),
getYearControlProps: (date2) => ({
selected: typeof _value === "string" ? dayjs(date2).isSame(_value, "year") : false,
...getYearControlProps?.(date2)
}),
attributes: wrapperProps.attributes
}
)
}
)
]
}
) }),
/* @__PURE__ */ jsx(HiddenDatesInput, { name, form, value: _value, type: "default" })
] });
});
DateInput.classes = { ...Input.classes, ...Calendar.classes };
DateInput.displayName = "@mantine/dates/DateInput";
export { DateInput };
//# sourceMappingURL=DateInput.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
'use client';
import dayjs from 'dayjs';
function dateStringParser(dateString) {
if (dateString === null) {
return null;
}
const date = new Date(dateString);
if (Number.isNaN(date.getTime()) || !dateString) {
return null;
}
return dayjs(date).format("YYYY-MM-DD");
}
export { dateStringParser };
//# sourceMappingURL=date-string-parser.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"date-string-parser.mjs","sources":["../../../../src/components/DateInput/date-string-parser/date-string-parser.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\nexport function dateStringParser(dateString: string | null): DateStringValue | null {\n if (dateString === null) {\n return null;\n }\n\n const date = new Date(dateString);\n\n if (Number.isNaN(date.getTime()) || !dateString) {\n return null;\n }\n\n return dayjs(date).format('YYYY-MM-DD');\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAiB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmD,CAAA;AAClF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,MAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA;AACvB,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACT,CAAA;AAEA,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,IAAI,CAAA,CAAA,CAAA,CAAA,CAAK,UAAU,CAAA,CAAA;AAEhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAS,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,UAAA,CAAA,CAAY,CAAA;AAC/C,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACT,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,KAAA,CAAM,CAAA,CAAA,CAAA,CAAI,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA;AACxC,CAAA;;"}

View File

@@ -0,0 +1,21 @@
'use client';
import dayjs from 'dayjs';
function isDateValid({ date, maxDate, minDate }) {
if (date == null) {
return false;
}
if (Number.isNaN(new Date(date).getTime())) {
return false;
}
if (maxDate && dayjs(date).isAfter(maxDate, "date")) {
return false;
}
if (minDate && dayjs(date).isBefore(minDate, "date")) {
return false;
}
return true;
}
export { isDateValid };
//# sourceMappingURL=is-date-valid.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-date-valid.mjs","sources":["../../../../src/components/DateInput/is-date-valid/is-date-valid.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\ninterface IsDateValid {\n date: DateStringValue | Date;\n maxDate: DateStringValue | Date | null | undefined;\n minDate: DateStringValue | Date | null | undefined;\n}\n\nexport function isDateValid({ date, maxDate, minDate }: IsDateValid) {\n if (date == null) {\n return false;\n }\n\n if (Number.isNaN(new Date(date).getTime())) {\n return false;\n }\n\n if (maxDate && dayjs(date).isAfter(maxDate, 'date')) {\n return false;\n }\n\n if (minDate && dayjs(date).isBefore(minDate, 'date')) {\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":";;;AASO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,EAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAQ,CAAA,CAAgB,CAAA;AACnE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,KAAQ,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CAAG,CAAA;AACpD,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACT,CAAA;AAEA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA;AACT,CAAA;;"}

View File

@@ -0,0 +1,153 @@
'use client';
import { jsx, jsxs } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { useRef } from 'react';
import { createVarsResolver, getFontSize, factory, useProps, useStyles, useResolvedStylesApi, UnstyledButton, Box } from '@mantine/core';
import { useDatesState } from '../../hooks/use-dates-state/use-dates-state.mjs';
import '@mantine/hooks';
import '../DatesProvider/DatesProvider.mjs';
import { Calendar } from '../Calendar/Calendar.mjs';
import { pickCalendarProps } from '../Calendar/pick-calendar-levels-props/pick-calendar-levels-props.mjs';
import { isSameMonth } from '../Month/is-same-month/is-same-month.mjs';
import '../Month/Month.mjs';
import classes from './DatePicker.module.css.mjs';
const varsResolver = createVarsResolver((_, { size }) => ({
datePickerRoot: {
"--preset-font-size": getFontSize(size)
}
}));
const defaultProps = {
type: "default",
defaultLevel: "month",
numberOfColumns: 1,
size: "sm"
};
const DatePicker = factory((_props, ref) => {
const props = useProps("DatePicker", defaultProps, _props);
const {
allowDeselect,
allowSingleDateInRange,
value,
defaultValue,
onChange,
onMouseLeave,
classNames,
styles,
__staticSelector,
__onDayClick,
__onDayMouseEnter,
__onPresetSelect,
__stopPropagation,
presets,
className,
style,
unstyled,
size,
vars,
attributes,
...rest
} = props;
const { calendarProps, others } = pickCalendarProps(rest);
const setDateRef = useRef(null);
const setLevelRef = useRef(null);
const getStyles = useStyles({
name: __staticSelector || "DatePicker",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
rootSelector: presets ? "datePickerRoot" : void 0,
varsResolver,
vars
});
const { onDateChange, onRootMouseLeave, onHoveredDateChange, getControlProps, _value, setValue } = useDatesState({
type: others.type,
level: "day",
allowDeselect,
allowSingleDateInRange,
value,
defaultValue,
onChange,
onMouseLeave
});
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
const calendar = /* @__PURE__ */ jsx(
Calendar,
{
ref,
classNames: resolvedClassNames,
styles: resolvedStyles,
__staticSelector: __staticSelector || "DatePicker",
onMouseLeave: onRootMouseLeave,
size,
...calendarProps,
...!presets ? others : {},
__stopPropagation,
__setDateRef: setDateRef,
__setLevelRef: setLevelRef,
minLevel: calendarProps.minLevel || "month",
__onDayMouseEnter: (_event, date) => {
onHoveredDateChange(date);
__onDayMouseEnter?.(_event, date);
},
__onDayClick: (_event, date) => {
onDateChange(date);
__onDayClick?.(_event, date);
},
getDayProps: (date) => ({
...getControlProps(date),
...calendarProps.getDayProps?.(date)
}),
getMonthControlProps: (date) => ({
selected: typeof _value === "string" ? isSameMonth(date, _value) : false,
...calendarProps.getMonthControlProps?.(date)
}),
getYearControlProps: (date) => ({
selected: typeof _value === "string" ? dayjs(date).isSame(_value, "year") : false,
...calendarProps.getYearControlProps?.(date)
}),
hideOutsideDates: calendarProps.hideOutsideDates ?? calendarProps.numberOfColumns !== 1,
...!presets ? { className, style, attributes } : {}
}
);
if (!presets) {
return calendar;
}
const handlePresetSelect = (val) => {
const _val = Array.isArray(val) ? val[0] : val;
if (_val !== void 0) {
setDateRef.current?.(_val);
setLevelRef.current?.("month");
__onPresetSelect ? __onPresetSelect(_val) : setValue(val);
}
};
const presetButtons = presets.map((preset, index) => /* @__PURE__ */ jsx(
UnstyledButton,
{
...getStyles("presetButton"),
onClick: () => handlePresetSelect(preset.value),
onMouseDown: (event) => event.preventDefault(),
"data-mantine-stop-propagation": __stopPropagation || void 0,
children: preset.label
},
index
));
return /* @__PURE__ */ jsxs(Box, { ...getStyles("datePickerRoot"), size, ...others, children: [
/* @__PURE__ */ jsx("div", { ...getStyles("presetsList"), children: presetButtons }),
calendar
] });
});
DatePicker.classes = Calendar.classes;
DatePicker.displayName = "@mantine/dates/DatePicker";
export { DatePicker };
//# sourceMappingURL=DatePicker.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"datePickerRoot":"m_765a40cf","presetsList":"m_d6a681e1","presetButton":"m_acd30b22"};
export { classes as default };
//# sourceMappingURL=DatePicker.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DatePicker.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,126 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { factory, useProps, useResolvedStylesApi } from '@mantine/core';
import 'dayjs';
import 'react';
import '@mantine/hooks';
import { getDefaultClampedDate } from '../../utils/get-default-clamped-date/get-default-clamped-date.mjs';
import { useDatesInput } from '../../hooks/use-dates-input/use-dates-input.mjs';
import '../Calendar/Calendar.mjs';
import { pickCalendarProps } from '../Calendar/pick-calendar-levels-props/pick-calendar-levels-props.mjs';
import { DatePicker } from '../DatePicker/DatePicker.mjs';
import { PickerInputBase } from '../PickerInputBase/PickerInputBase.mjs';
const defaultProps = {
type: "default",
valueFormat: "MMMM D, YYYY",
closeOnChange: true,
sortDates: true,
dropdownType: "popover"
};
const DatePickerInput = factory(
(_props, ref) => {
const props = useProps("DatePickerInput", defaultProps, _props);
const {
type,
value,
defaultValue,
onChange,
valueFormat,
labelSeparator,
locale,
classNames,
styles,
unstyled,
closeOnChange,
size,
variant,
dropdownType,
sortDates,
minDate,
maxDate,
vars,
defaultDate,
valueFormatter,
presets,
attributes,
...rest
} = props;
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
const { calendarProps, others } = pickCalendarProps(rest);
const {
_value,
setValue,
formattedValue,
dropdownHandlers,
dropdownOpened,
onClear,
shouldClear
} = useDatesInput({
type,
value,
defaultValue,
onChange,
locale,
format: valueFormat,
labelSeparator,
closeOnChange,
sortDates,
valueFormatter
});
const _defaultDate = Array.isArray(_value) ? _value[0] || defaultDate : _value || defaultDate;
return /* @__PURE__ */ jsx(
PickerInputBase,
{
formattedValue,
dropdownOpened,
dropdownHandlers,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
ref,
onClear,
shouldClear,
value: _value,
size,
variant,
dropdownType,
...others,
type,
__staticSelector: "DatePickerInput",
attributes,
children: /* @__PURE__ */ jsx(
DatePicker,
{
...calendarProps,
size,
variant,
type,
value: _value,
defaultDate: _defaultDate || getDefaultClampedDate({ maxDate, minDate }),
onChange: setValue,
locale,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
__staticSelector: "DatePickerInput",
__stopPropagation: dropdownType === "popover",
minDate,
maxDate,
presets,
attributes
}
)
}
);
}
);
DatePickerInput.classes = { ...PickerInputBase.classes, ...DatePicker.classes };
DatePickerInput.displayName = "@mantine/dates/DatePickerInput";
export { DatePickerInput };
//# sourceMappingURL=DatePickerInput.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,233 @@
'use client';
import { jsxs, jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { useRef, useState } from 'react';
import { factory, useProps, useStyles, useResolvedStylesApi, ActionIcon, CheckIcon } from '@mantine/core';
import { useMergedRef, useDisclosure, useDidUpdate } from '@mantine/hooks';
import { useUncontrolledDates } from '../../hooks/use-uncontrolled-dates/use-uncontrolled-dates.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import { assignTime } from '../../utils/assign-time/assign-time.mjs';
import { getDefaultClampedDate } from '../../utils/get-default-clamped-date/get-default-clamped-date.mjs';
import { clampDate } from '../../utils/clamp-date/clamp-date.mjs';
import '../Calendar/Calendar.mjs';
import { pickCalendarProps } from '../Calendar/pick-calendar-levels-props/pick-calendar-levels-props.mjs';
import { DatePicker } from '../DatePicker/DatePicker.mjs';
import { PickerInputBase } from '../PickerInputBase/PickerInputBase.mjs';
import { TimePicker } from '../TimePicker/TimePicker.mjs';
import classes from './DateTimePicker.module.css.mjs';
import { getMaxTime, getMinTime } from './get-min-max-time/get-min-max-time.mjs';
const defaultProps = {
dropdownType: "popover",
size: "sm"
};
const DateTimePicker = factory((_props, ref) => {
const props = useProps("DateTimePicker", defaultProps, _props);
const {
value,
defaultValue,
onChange,
valueFormat,
locale,
classNames,
styles,
unstyled,
timePickerProps,
submitButtonProps,
withSeconds,
level,
defaultLevel,
size,
variant,
dropdownType,
vars,
minDate,
maxDate,
defaultDate,
defaultTimeValue,
presets,
attributes,
onDropdownClose,
...rest
} = props;
const getStyles = useStyles({
name: "DateTimePicker",
classes,
props,
classNames,
styles,
unstyled,
attributes,
vars
});
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
const _valueFormat = valueFormat || (withSeconds ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY HH:mm");
const timePickerRef = useRef(null);
const timePickerRefMerged = useMergedRef(timePickerRef, timePickerProps?.hoursRef);
const {
calendarProps: { allowSingleDateInRange, ...calendarProps },
others
} = pickCalendarProps(rest);
const ctx = useDatesContext();
const [_value, setValue] = useUncontrolledDates({
type: "default",
value,
defaultValue,
onChange,
withTime: true
});
const _defaultDate = defaultDate || _value;
const formatTime = (dateValue) => dateValue ? dayjs(dateValue).format(withSeconds ? "HH:mm:ss" : "HH:mm") : "";
const [timeValue, setTimeValue] = useState(defaultTimeValue || formatTime(_value));
const [currentLevel, setCurrentLevel] = useState(level || defaultLevel || "month");
const [dropdownOpened, dropdownHandlers] = useDisclosure(false);
const formattedValue = _value ? dayjs(_value).locale(ctx.getLocale(locale)).format(_valueFormat) : "";
const handleTimeChange = (timeString) => {
timePickerProps?.onChange?.(timeString);
setTimeValue(timeString);
if (timeString) {
setValue(assignTime(_value, timeString));
}
};
const handleDateChange = (date) => {
if (date) {
setValue(assignTime(clampDate(minDate, maxDate, date), timeValue || defaultTimeValue || ""));
}
timePickerRef.current?.focus();
};
const handleTimeInputKeyDown = (event) => {
if (event.key === "Enter") {
event.preventDefault();
dropdownHandlers.close();
}
};
useDidUpdate(() => {
if (!dropdownOpened) {
setTimeValue(formatTime(_value));
}
}, [_value, dropdownOpened]);
useDidUpdate(() => {
if (dropdownOpened) {
setCurrentLevel("month");
}
}, [dropdownOpened]);
const __stopPropagation = dropdownType === "popover";
const handleDropdownClose = () => {
const clamped = clampDate(minDate, maxDate, _value);
if (_value && _value !== clamped) {
setValue(clampDate(minDate, maxDate, _value));
}
onDropdownClose?.();
};
return /* @__PURE__ */ jsxs(
PickerInputBase,
{
formattedValue,
dropdownOpened: !rest.disabled ? dropdownOpened : false,
dropdownHandlers,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
ref,
onClear: () => setValue(null),
shouldClear: !!_value,
value: _value,
size,
variant,
dropdownType,
...others,
type: "default",
__staticSelector: "DateTimePicker",
onDropdownClose: handleDropdownClose,
withTime: true,
attributes,
children: [
/* @__PURE__ */ jsx(
DatePicker,
{
...calendarProps,
maxDate,
minDate,
size,
variant,
type: "default",
value: _value,
defaultDate: _defaultDate || getDefaultClampedDate({ maxDate, minDate }),
onChange: handleDateChange,
locale,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
__staticSelector: "DateTimePicker",
__stopPropagation,
level,
defaultLevel,
onLevelChange: (_level) => {
setCurrentLevel(_level);
calendarProps.onLevelChange?.(_level);
},
presets,
__onPresetSelect: (val) => {
setValue(val);
val && setTimeValue(formatTime(val));
},
attributes
}
),
currentLevel === "month" && /* @__PURE__ */ jsxs("div", { ...getStyles("timeWrapper"), children: [
/* @__PURE__ */ jsx(
TimePicker,
{
value: timeValue,
withSeconds,
unstyled,
min: getMinTime({ minDate, value: _value }),
max: getMaxTime({ maxDate, value: _value }),
...timePickerProps,
...getStyles("timeInput", {
className: timePickerProps?.className,
style: timePickerProps?.style
}),
onChange: handleTimeChange,
onKeyDown: handleTimeInputKeyDown,
size,
"data-mantine-stop-propagation": __stopPropagation || void 0,
hoursRef: timePickerRefMerged,
attributes
}
),
/* @__PURE__ */ jsx(
ActionIcon,
{
variant: "default",
size: `input-${size || "sm"}`,
...getStyles("submitButton", {
className: submitButtonProps?.className,
style: submitButtonProps?.style
}),
unstyled,
"data-mantine-stop-propagation": __stopPropagation || void 0,
children: /* @__PURE__ */ jsx(CheckIcon, { size: "30%" }),
...submitButtonProps,
onClick: (event) => {
submitButtonProps?.onClick?.(event);
dropdownHandlers.close();
handleDropdownClose();
}
}
)
] })
]
}
);
});
DateTimePicker.classes = { ...classes, ...PickerInputBase.classes, ...DatePicker.classes };
DateTimePicker.displayName = "@mantine/dates/DateTimePicker";
export { DateTimePicker };
//# sourceMappingURL=DateTimePicker.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"timeWrapper":"m_208d2562","timeInput":"m_62ee059"};
export { classes as default };
//# sourceMappingURL=DateTimePicker.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DateTimePicker.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,14 @@
'use client';
import dayjs from 'dayjs';
function getMinTime({ minDate, value }) {
const minTime = minDate ? dayjs(minDate).format("HH:mm:ss") : null;
return value && minDate && value === minDate ? minTime != null ? minTime : void 0 : void 0;
}
function getMaxTime({ maxDate, value }) {
const maxTime = maxDate ? dayjs(maxDate).format("HH:mm:ss") : null;
return value && maxDate && value === maxDate ? maxTime != null ? maxTime : void 0 : void 0;
}
export { getMaxTime, getMinTime };
//# sourceMappingURL=get-min-max-time.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-min-max-time.mjs","sources":["../../../../src/components/DateTimePicker/get-min-max-time/get-min-max-time.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\ninterface GetMinTimeInput {\n minDate: DateStringValue | Date | undefined;\n value: DateStringValue | null;\n}\n\nexport function getMinTime({ minDate, value }: GetMinTimeInput): string | undefined {\n const minTime = minDate ? dayjs(minDate).format('HH:mm:ss') : null;\n return value && minDate && value === minDate\n ? minTime != null\n ? minTime\n : undefined\n : undefined;\n}\n\ninterface GetMaxTimeInput {\n maxDate: DateStringValue | Date | undefined;\n value: DateStringValue | null;\n}\n\nexport function getMaxTime({ maxDate, value }: GetMaxTimeInput): string | undefined {\n const maxTime = maxDate ? dayjs(maxDate).format('HH:mm:ss') : null;\n return value && maxDate && value === maxDate\n ? maxTime != null\n ? maxTime\n : undefined\n : undefined;\n}\n"],"names":[],"mappings":";;;AAQO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,UAAA,CAAW,CAAA,CAAE,OAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,EAAM,CAAA,CAAwC,CAAA;AAClF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,GAAI,CAAA,CAAA,CAAA,CAAA,CAAA;AAC9D,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,KAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,KAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IACjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACT,UACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GACF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACN,CAAA;AAOO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,UAAA,CAAW,CAAA,CAAE,OAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,EAAM,CAAA,CAAwC,CAAA;AAClF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,GAAI,CAAA,CAAA,CAAA,CAAA,CAAA;AAC9D,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,KAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,KAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IACjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACT,UACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GACF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACN,CAAA;;"}

View File

@@ -0,0 +1,18 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { createContext } from 'react';
const DATES_PROVIDER_DEFAULT_SETTINGS = {
locale: "en",
firstDayOfWeek: 1,
weekendDays: [0, 6],
labelSeparator: "\u2013",
consistentWeeks: false
};
const DatesProviderContext = createContext(DATES_PROVIDER_DEFAULT_SETTINGS);
function DatesProvider({ settings, children }) {
return /* @__PURE__ */ jsx(DatesProviderContext.Provider, { value: { ...DATES_PROVIDER_DEFAULT_SETTINGS, ...settings }, children });
}
export { DATES_PROVIDER_DEFAULT_SETTINGS, DatesProvider, DatesProviderContext };
//# sourceMappingURL=DatesProvider.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DatesProvider.mjs","sources":["../../../src/components/DatesProvider/DatesProvider.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport { DayOfWeek } from '../../types';\n\nexport interface DatesProviderValue {\n locale: string;\n firstDayOfWeek: DayOfWeek;\n weekendDays: DayOfWeek[];\n labelSeparator: string;\n consistentWeeks: boolean;\n}\n\nexport type DatesProviderSettings = Partial<DatesProviderValue>;\n\nexport const DATES_PROVIDER_DEFAULT_SETTINGS: DatesProviderValue = {\n locale: 'en',\n firstDayOfWeek: 1,\n weekendDays: [0, 6],\n labelSeparator: '',\n consistentWeeks: false,\n};\n\nexport const DatesProviderContext = createContext(DATES_PROVIDER_DEFAULT_SETTINGS);\n\nexport interface DatesProviderProps {\n settings: DatesProviderSettings;\n children?: React.ReactNode;\n}\n\nexport function DatesProvider({ settings, children }: DatesProviderProps) {\n return (\n <DatesProviderContext.Provider value={{ ...DATES_PROVIDER_DEFAULT_SETTINGS, ...settings }}>\n {children}\n </DatesProviderContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;AAaO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,+BAAA,CAAA,CAAA,CAAsD,CAAA;AAAA,CAAA,CACjE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAQ,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACR,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAgB,CAAA,CAAA;AAAA,CAAA,CAChB,WAAA,CAAA,CAAa,CAAC,CAAA,CAAA,CAAG,CAAC,CAAA,CAAA;AAAA,CAAA,CAClB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAgB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAiC,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAS,CAAA,CACrF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EACH,CAAA,CAAA;AAEJ,CAAA;;"}

View File

@@ -0,0 +1,30 @@
'use client';
import { useContext, useCallback } from 'react';
import { DatesProviderContext } from './DatesProvider.mjs';
function useDatesContext() {
const ctx = useContext(DatesProviderContext);
const getLocale = useCallback((input) => input || ctx.locale, [ctx.locale]);
const getFirstDayOfWeek = useCallback(
(input) => typeof input === "number" ? input : ctx.firstDayOfWeek,
[ctx.firstDayOfWeek]
);
const getWeekendDays = useCallback(
(input) => Array.isArray(input) ? input : ctx.weekendDays,
[ctx.weekendDays]
);
const getLabelSeparator = useCallback(
(input) => typeof input === "string" ? input : ctx.labelSeparator,
[ctx.labelSeparator]
);
return {
...ctx,
getLocale,
getFirstDayOfWeek,
getWeekendDays,
getLabelSeparator
};
}
export { useDatesContext };
//# sourceMappingURL=use-dates-context.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-dates-context.mjs","sources":["../../../src/components/DatesProvider/use-dates-context.ts"],"sourcesContent":["import { useCallback, useContext } from 'react';\nimport { DayOfWeek } from '../../types';\nimport { DatesProviderContext } from './DatesProvider';\n\nexport function useDatesContext() {\n const ctx = useContext(DatesProviderContext);\n const getLocale = useCallback((input?: string) => input || ctx.locale, [ctx.locale]);\n\n const getFirstDayOfWeek = useCallback(\n (input?: DayOfWeek) => (typeof input === 'number' ? input : ctx.firstDayOfWeek),\n [ctx.firstDayOfWeek]\n );\n\n const getWeekendDays = useCallback(\n (input?: DayOfWeek[]) => (Array.isArray(input) ? input : ctx.weekendDays),\n [ctx.weekendDays]\n );\n\n const getLabelSeparator = useCallback(\n (input?: string) => (typeof input === 'string' ? input : ctx.labelSeparator),\n [ctx.labelSeparator]\n );\n\n return {\n ...ctx,\n getLocale,\n getFirstDayOfWeek,\n getWeekendDays,\n getLabelSeparator,\n };\n}\n"],"names":[],"mappings":";;;;AAIO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,eAAA,CAAA,CAAA,CAAkB,CAAA;AAChC,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAW,oBAAoB,CAAA,CAAA;AAC3C,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,WAAA,CAAY,CAAC,KAAA,CAAA,CAAA,CAAA,CAAA,CAAmB,CAAA,CAAA,CAAA,CAAA,CAAA,IAAS,CAAA,CAAA,EAAI,MAAA,CAAA,CAAQ,CAAC,GAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA;AAEnF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACxB,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAA,CAAA,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A,CAAA,CAAA;AAAA,CAAA,CAAA,CACF,CAAA;AACF,CAAA;;"}

79
node_modules/@mantine/dates/esm/components/Day/Day.mjs generated vendored Normal file
View File

@@ -0,0 +1,79 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { createVarsResolver, getSize, factory, useProps, useStyles, UnstyledButton } from '@mantine/core';
import classes from './Day.module.css.mjs';
const varsResolver = createVarsResolver((_, { size }) => ({
day: {
"--day-size": getSize(size, "day-size")
}
}));
const Day = factory((_props, ref) => {
const props = useProps("Day", null, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
date,
disabled,
__staticSelector,
weekend,
outside,
selected,
renderDay,
inRange,
firstInRange,
lastInRange,
hidden,
static: isStatic,
highlightToday,
attributes,
...others
} = props;
const getStyles = useStyles({
name: __staticSelector || "Day",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars,
varsResolver,
rootSelector: "day"
});
return /* @__PURE__ */ jsx(
UnstyledButton,
{
...getStyles("day", { style: hidden ? { display: "none" } : void 0 }),
component: isStatic ? "div" : "button",
ref,
disabled,
"data-today": dayjs(date).isSame(/* @__PURE__ */ new Date(), "day") || void 0,
"data-hidden": hidden || void 0,
"data-highlight-today": highlightToday || void 0,
"data-disabled": disabled || void 0,
"data-weekend": !disabled && !outside && weekend || void 0,
"data-outside": !disabled && outside || void 0,
"data-selected": !disabled && selected || void 0,
"data-in-range": inRange && !disabled || void 0,
"data-first-in-range": firstInRange && !disabled || void 0,
"data-last-in-range": lastInRange && !disabled || void 0,
"data-static": isStatic || void 0,
unstyled,
...others,
children: renderDay?.(date) || dayjs(date).date()
}
);
});
Day.classes = classes;
Day.displayName = "@mantine/dates/Day";
export { Day };
//# sourceMappingURL=Day.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"day":"m_396ce5cb"};
export { classes as default };
//# sourceMappingURL=Day.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Day.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,118 @@
'use client';
import { jsxs, jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { factory, useProps, Box } from '@mantine/core';
import { CalendarHeader } from '../CalendarHeader/CalendarHeader.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import { YearsList } from '../YearsList/YearsList.mjs';
import { getDecadeRange } from './get-decade-range/get-decade-range.mjs';
const defaultProps = {
decadeLabelFormat: "YYYY"
};
const DecadeLevel = factory((_props, ref) => {
const props = useProps("DecadeLevel", defaultProps, _props);
const {
// YearsList settings
decade,
locale,
minDate,
maxDate,
yearsListFormat,
getYearControlProps,
__getControlRef,
__onControlKeyDown,
__onControlClick,
__onControlMouseEnter,
withCellSpacing,
// CalendarHeader settings
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
nextDisabled,
previousDisabled,
levelControlAriaLabel,
withNext,
withPrevious,
headerControlsOrder,
// Other props
decadeLabelFormat,
classNames,
styles,
unstyled,
__staticSelector,
__stopPropagation,
size,
attributes,
...others
} = props;
const ctx = useDatesContext();
const [startOfDecade, endOfDecade] = getDecadeRange(decade);
const stylesApiProps = {
__staticSelector: __staticSelector || "DecadeLevel",
classNames,
styles,
unstyled,
size,
attributes
};
const _nextDisabled = typeof nextDisabled === "boolean" ? nextDisabled : maxDate ? !dayjs(endOfDecade).endOf("year").isBefore(maxDate) : false;
const _previousDisabled = typeof previousDisabled === "boolean" ? previousDisabled : minDate ? !dayjs(startOfDecade).startOf("year").isAfter(minDate) : false;
const formatDecade = (date, format) => dayjs(date).locale(locale || ctx.locale).format(format);
return /* @__PURE__ */ jsxs(Box, { "data-decade-level": true, size, ref, ...others, children: [
/* @__PURE__ */ jsx(
CalendarHeader,
{
label: typeof decadeLabelFormat === "function" ? decadeLabelFormat(startOfDecade, endOfDecade) : `${formatDecade(startOfDecade, decadeLabelFormat)} \u2013 ${formatDecade(
endOfDecade,
decadeLabelFormat
)}`,
__preventFocus,
__stopPropagation,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
nextDisabled: _nextDisabled,
previousDisabled: _previousDisabled,
hasNextLevel: false,
levelControlAriaLabel,
withNext,
withPrevious,
headerControlsOrder,
...stylesApiProps
}
),
/* @__PURE__ */ jsx(
YearsList,
{
decade,
locale,
minDate,
maxDate,
yearsListFormat,
getYearControlProps,
__getControlRef,
__onControlKeyDown,
__onControlClick,
__onControlMouseEnter,
__preventFocus,
__stopPropagation,
withCellSpacing,
...stylesApiProps
}
)
] });
});
DecadeLevel.classes = { ...YearsList.classes, ...CalendarHeader.classes };
DecadeLevel.displayName = "@mantine/dates/DecadeLevel";
export { DecadeLevel };
//# sourceMappingURL=DecadeLevel.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
'use client';
import { getYearsData } from '../../YearsList/get-years-data/get-years-data.mjs';
function getDecadeRange(decade) {
const years = getYearsData(decade);
return [years[0][0], years[3][0]];
}
export { getDecadeRange };
//# sourceMappingURL=get-decade-range.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-decade-range.mjs","sources":["../../../../src/components/DecadeLevel/get-decade-range/get-decade-range.ts"],"sourcesContent":["import { DateStringValue } from '../../../types';\nimport { getYearsData } from '../../YearsList/get-years-data/get-years-data';\n\nexport function getDecadeRange(decade: DateStringValue) {\n const years = getYearsData(decade);\n return [years[0][0], years[3][0]] as const;\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB,CAAA;AACtD,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAa,MAAM,CAAA,CAAA;AACjC,CAAA,CAAA,OAAO,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAE,CAAC,GAAG,KAAA,CAAM,CAAC,CAAA,CAAE,CAAC,CAAC,CAAA,CAAA;AAClC,CAAA;;"}

View File

@@ -0,0 +1,126 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { useRef } from 'react';
import { factory, useProps } from '@mantine/core';
import { handleControlKeyDown } from '../../utils/handle-control-key-down/handle-control-key-down.mjs';
import { DecadeLevel } from '../DecadeLevel/DecadeLevel.mjs';
import { LevelsGroup } from '../LevelsGroup/LevelsGroup.mjs';
const defaultProps = {
numberOfColumns: 1
};
const DecadeLevelGroup = factory((_props, ref) => {
const props = useProps("DecadeLevelGroup", defaultProps, _props);
const {
// DecadeLevel settings
decade,
locale,
minDate,
maxDate,
yearsListFormat,
getYearControlProps,
__onControlClick,
__onControlMouseEnter,
withCellSpacing,
// CalendarHeader settings
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
nextDisabled,
previousDisabled,
headerControlsOrder,
// Other settings
classNames,
styles,
unstyled,
__staticSelector,
__stopPropagation,
numberOfColumns,
levelControlAriaLabel,
decadeLabelFormat,
size,
vars,
attributes,
...others
} = props;
const controlsRef = useRef([]);
const decades = Array(numberOfColumns).fill(0).map((_, decadeIndex) => {
const currentDecade = dayjs(decade).add(decadeIndex * 10, "years").format("YYYY-MM-DD");
return /* @__PURE__ */ jsx(
DecadeLevel,
{
size,
yearsListFormat,
decade: currentDecade,
withNext: decadeIndex === numberOfColumns - 1,
withPrevious: decadeIndex === 0,
decadeLabelFormat,
__onControlClick,
__onControlMouseEnter,
__onControlKeyDown: (event, payload) => handleControlKeyDown({
levelIndex: decadeIndex,
rowIndex: payload.rowIndex,
cellIndex: payload.cellIndex,
event,
controlsRef
}),
__getControlRef: (rowIndex, cellIndex, node) => {
if (!Array.isArray(controlsRef.current[decadeIndex])) {
controlsRef.current[decadeIndex] = [];
}
if (!Array.isArray(controlsRef.current[decadeIndex][rowIndex])) {
controlsRef.current[decadeIndex][rowIndex] = [];
}
controlsRef.current[decadeIndex][rowIndex][cellIndex] = node;
},
levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentDecade) : levelControlAriaLabel,
locale,
minDate,
maxDate,
__preventFocus,
__stopPropagation,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
nextDisabled,
previousDisabled,
getYearControlProps,
__staticSelector: __staticSelector || "DecadeLevelGroup",
classNames,
styles,
unstyled,
withCellSpacing,
headerControlsOrder,
attributes
},
decadeIndex
);
});
return /* @__PURE__ */ jsx(
LevelsGroup,
{
classNames,
styles,
__staticSelector: __staticSelector || "DecadeLevelGroup",
ref,
size,
unstyled,
attributes,
...others,
children: decades
}
);
});
DecadeLevelGroup.classes = { ...LevelsGroup.classes, ...DecadeLevel.classes };
DecadeLevelGroup.displayName = "@mantine/dates/DecadeLevelGroup";
export { DecadeLevelGroup };
//# sourceMappingURL=DecadeLevelGroup.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,39 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import 'dayjs';
import { toDateTimeString, toDateString } from '../../utils/to-date-string/to-date-string.mjs';
function formatValue({ value, type, withTime }) {
const formatter = withTime ? toDateTimeString : toDateString;
if (type === "range" && Array.isArray(value)) {
const startDate = formatter(value[0]);
const endDate = formatter(value[1]);
if (!startDate) {
return "";
}
if (!endDate) {
return `${startDate} \u2013`;
}
return `${startDate} \u2013 ${endDate}`;
}
if (type === "multiple" && Array.isArray(value)) {
return value.filter(Boolean).join(", ");
}
if (!Array.isArray(value) && value) {
return formatter(value);
}
return "";
}
function HiddenDatesInput({
value,
type,
name,
form,
withTime = false
}) {
return /* @__PURE__ */ jsx("input", { type: "hidden", value: formatValue({ value, type, withTime }), name, form });
}
HiddenDatesInput.displayName = "@mantine/dates/HiddenDatesInput";
export { HiddenDatesInput };
//# sourceMappingURL=HiddenDatesInput.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,38 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { factory, useProps, useStyles, Box } from '@mantine/core';
import classes from './LevelsGroup.module.css.mjs';
const LevelsGroup = factory((_props, ref) => {
const props = useProps("LevelsGroup", null, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
__staticSelector,
attributes,
...others
} = props;
const getStyles = useStyles({
name: __staticSelector || "LevelsGroup",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars,
rootSelector: "levelsGroup"
});
return /* @__PURE__ */ jsx(Box, { ref, ...getStyles("levelsGroup"), ...others });
});
LevelsGroup.classes = classes;
LevelsGroup.displayName = "@mantine/dates/LevelsGroup";
export { LevelsGroup };
//# sourceMappingURL=LevelsGroup.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LevelsGroup.mjs","sources":["../../../src/components/LevelsGroup/LevelsGroup.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n ElementProps,\n factory,\n Factory,\n MantineSize,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport classes from './LevelsGroup.module.css';\n\nexport type LevelsGroupStylesNames = 'levelsGroup';\n\nexport interface LevelsGroupProps\n extends BoxProps,\n StylesApiProps<LevelsGroupFactory>,\n ElementProps<'div'> {\n __staticSelector?: string;\n size?: MantineSize;\n}\n\nexport type LevelsGroupFactory = Factory<{\n props: LevelsGroupProps;\n ref: HTMLDivElement;\n stylesNames: LevelsGroupStylesNames;\n}>;\n\nexport const LevelsGroup = factory<LevelsGroupFactory>((_props, ref) => {\n const props = useProps('LevelsGroup', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n __staticSelector,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<LevelsGroupFactory>({\n name: __staticSelector || 'LevelsGroup',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n rootSelector: 'levelsGroup',\n });\n\n return <Box ref={ref} {...getStyles('levelsGroup')} {...others} />;\n});\n\nLevelsGroup.classes = classes;\nLevelsGroup.displayName = '@mantine/dates/LevelsGroup';\n"],"names":[],"mappings":";;;;;AA6BO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4B,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,GAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA;AACtE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,aAAA,CAAA,CAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA;AAClD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA;AAAA,CAAA,CAAA,CAAA,CACJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CA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CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"levelsGroup":"m_30b26e33"};
export { classes as default };
//# sourceMappingURL=LevelsGroup.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LevelsGroup.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,150 @@
'use client';
import { jsxs, jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { createVarsResolver, getSize, factory, useProps, useStyles, UnstyledButton, Box, AccordionChevron } from '@mantine/core';
import { useUncontrolled } from '@mantine/hooks';
import { toDateString } from '../../utils/to-date-string/to-date-string.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import classes from './MiniCalendar.module.css.mjs';
const defaultProps = {
size: "sm",
numberOfDays: 7,
monthLabelFormat: "MMM"
};
const varsResolver = createVarsResolver((_theme, { size }) => ({
root: {
"--mini-calendar-font-size": getSize(size, "mantine-font-size")
}
}));
const MiniCalendar = factory((_props, ref) => {
const props = useProps("MiniCalendar", defaultProps, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
date,
defaultDate,
onDateChange,
value,
onChange,
onNext,
onPrevious,
getDayProps,
numberOfDays,
size,
minDate,
maxDate,
monthLabelFormat,
nextControlProps,
previousControlProps,
locale,
...others
} = props;
const getStyles = useStyles({
name: "MiniCalendar",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
vars,
varsResolver
});
const ctx = useDatesContext();
const _locale = ctx.getLocale(locale);
const [_date, setDate] = useUncontrolled({
value: toDateString(date),
defaultValue: toDateString(defaultDate),
finalValue: toDateString(value) || dayjs().format("YYYY-MM-DD"),
onChange: onDateChange
});
const handleNext = () => {
onNext?.();
const nextDate = dayjs(_date).add(numberOfDays, "days");
setDate(toDateString(nextDate));
};
const handlePrevious = () => {
onPrevious?.();
const previousDate = dayjs(_date).subtract(numberOfDays, "days");
setDate(toDateString(previousDate));
};
const previousDisabled = minDate ? dayjs(_date).subtract(1, "days").isBefore(dayjs(minDate)) : false;
const nextDisabled = maxDate ? dayjs(_date).add(numberOfDays, "days").isAfter(dayjs(maxDate)) : false;
const range = Array(numberOfDays).fill(0).map((_, index) => dayjs(_date).add(index, "days")).map((date2) => {
const disabled = minDate && date2.isBefore(dayjs(minDate), "day") || maxDate && date2.isAfter(dayjs(maxDate), "day") || false;
const dayProps = getDayProps?.(toDateString(date2));
return /* @__PURE__ */ jsxs(
UnstyledButton,
{
disabled,
"aria-label": date2.format("YYYY-MM-DD"),
"data-disabled": disabled || void 0,
"data-selected": value && dayjs(date2).isSame(value, "day") ? true : void 0,
...dayProps,
onClick: (event) => {
dayProps?.onClick?.(event);
onChange?.(toDateString(date2));
},
...getStyles("day", {
active: !disabled,
className: dayProps?.className,
style: dayProps?.style
}),
children: [
/* @__PURE__ */ jsx("span", { ...getStyles("dayMonth"), children: date2.locale(_locale).format(monthLabelFormat) }),
/* @__PURE__ */ jsx("span", { ...getStyles("dayNumber"), children: date2.date() })
]
},
date2.toString()
);
});
return /* @__PURE__ */ jsxs(Box, { ref, size, ...getStyles("root"), ...others, children: [
/* @__PURE__ */ jsx(
UnstyledButton,
{
size,
onClick: handlePrevious,
disabled: previousDisabled,
"data-disabled": previousDisabled || void 0,
"data-direction": "previous",
...previousControlProps,
...getStyles("control", {
active: !previousDisabled,
className: previousControlProps?.className,
style: previousControlProps?.style
}),
children: previousControlProps?.children || /* @__PURE__ */ jsx(AccordionChevron, { "data-chevron": true, size })
}
),
/* @__PURE__ */ jsx("div", { ...getStyles("days"), children: range }),
/* @__PURE__ */ jsx(
UnstyledButton,
{
size,
onClick: handleNext,
disabled: nextDisabled,
"data-disabled": nextDisabled || void 0,
"data-direction": "next",
...nextControlProps,
...getStyles("control", {
active: !nextDisabled,
className: nextControlProps?.className,
style: nextControlProps?.style
}),
children: nextControlProps?.children || /* @__PURE__ */ jsx(AccordionChevron, { "data-chevron": true, size })
}
)
] });
});
MiniCalendar.displayName = "@mantine/dates/MiniCalendar";
MiniCalendar.classes = classes;
export { MiniCalendar };
//# sourceMappingURL=MiniCalendar.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"root":"m_2a0c4eda","days":"m_2a05be4f","day":"m_99d16a4","dayMonth":"m_176ca23c","dayNumber":"m_d830530d","control":"m_14c23465"};
export { classes as default };
//# sourceMappingURL=MiniCalendar.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MiniCalendar.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,183 @@
'use client';
import { jsx, jsxs } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { createVarsResolver, getSize, getFontSize, factory, useProps, useStyles, useResolvedStylesApi, Box } from '@mantine/core';
import { toDateString } from '../../utils/to-date-string/to-date-string.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import { Day } from '../Day/Day.mjs';
import { WeekdaysRow } from '../WeekdaysRow/WeekdaysRow.mjs';
import { getDateInTabOrder } from './get-date-in-tab-order/get-date-in-tab-order.mjs';
import { getMonthDays } from './get-month-days/get-month-days.mjs';
import { getWeekNumber } from './get-week-number/get-week-number.mjs';
import { isAfterMinDate } from './is-after-min-date/is-after-min-date.mjs';
import { isBeforeMaxDate } from './is-before-max-date/is-before-max-date.mjs';
import { isSameMonth } from './is-same-month/is-same-month.mjs';
import classes from './Month.module.css.mjs';
const defaultProps = {
withCellSpacing: true
};
const varsResolver = createVarsResolver((_, { size }) => ({
weekNumber: {
"--wn-fz": getFontSize(size),
"--wn-size": getSize(size, "wn-size")
}
}));
const Month = factory((_props, ref) => {
const props = useProps("Month", defaultProps, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
__staticSelector,
locale,
firstDayOfWeek,
weekdayFormat,
month,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
static: isStatic,
__getDayRef,
__onDayKeyDown,
__onDayClick,
__onDayMouseEnter,
__preventFocus,
__stopPropagation,
withCellSpacing,
size,
highlightToday,
withWeekNumbers,
attributes,
...others
} = props;
const getStyles = useStyles({
name: __staticSelector || "Month",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars,
varsResolver,
rootSelector: "month"
});
const ctx = useDatesContext();
const dates = getMonthDays({
month,
firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek),
consistentWeeks: ctx.consistentWeeks
});
const dateInTabOrder = getDateInTabOrder({
dates,
minDate: toDateString(minDate),
maxDate: toDateString(maxDate),
getDayProps,
excludeDate,
hideOutsideDates,
month
});
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
const rows = dates.map((row, rowIndex) => {
const cells = row.map((date, cellIndex) => {
const outside = !isSameMonth(date, month);
const ariaLabel = getDayAriaLabel?.(date) || dayjs(date).locale(locale || ctx.locale).format("D MMMM YYYY");
const dayProps = getDayProps?.(date);
const isDateInTabOrder = dayjs(date).isSame(dateInTabOrder, "date");
return /* @__PURE__ */ jsx(
"td",
{
...getStyles("monthCell"),
"data-with-spacing": withCellSpacing || void 0,
children: /* @__PURE__ */ jsx(
Day,
{
__staticSelector: __staticSelector || "Month",
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
"data-mantine-stop-propagation": __stopPropagation || void 0,
highlightToday,
renderDay,
date,
size,
weekend: ctx.getWeekendDays(weekendDays).includes(dayjs(date).get("day")),
outside,
hidden: hideOutsideDates ? outside : false,
"aria-label": ariaLabel,
static: isStatic,
disabled: excludeDate?.(date) || !isBeforeMaxDate(date, toDateString(maxDate)) || !isAfterMinDate(date, toDateString(minDate)),
ref: (node) => {
if (node) {
__getDayRef?.(rowIndex, cellIndex, node);
}
},
...dayProps,
onKeyDown: (event) => {
dayProps?.onKeyDown?.(event);
__onDayKeyDown?.(event, { rowIndex, cellIndex, date });
},
onMouseEnter: (event) => {
dayProps?.onMouseEnter?.(event);
__onDayMouseEnter?.(event, date);
},
onClick: (event) => {
dayProps?.onClick?.(event);
__onDayClick?.(event, date);
},
onMouseDown: (event) => {
dayProps?.onMouseDown?.(event);
__preventFocus && event.preventDefault();
},
tabIndex: __preventFocus || !isDateInTabOrder ? -1 : 0
}
)
},
date.toString()
);
});
return /* @__PURE__ */ jsxs("tr", { ...getStyles("monthRow"), children: [
withWeekNumbers && /* @__PURE__ */ jsx("td", { ...getStyles("weekNumber"), children: getWeekNumber(row) }),
cells
] }, rowIndex);
});
return /* @__PURE__ */ jsxs(Box, { component: "table", ...getStyles("month"), size, ref, ...others, children: [
!hideWeekdays && /* @__PURE__ */ jsx("thead", { ...getStyles("monthThead"), children: /* @__PURE__ */ jsx(
WeekdaysRow,
{
__staticSelector: __staticSelector || "Month",
locale,
firstDayOfWeek,
weekdayFormat,
size,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
withWeekNumbers
}
) }),
/* @__PURE__ */ jsx("tbody", { ...getStyles("monthTbody"), children: rows })
] });
});
Month.classes = classes;
Month.displayName = "@mantine/dates/Month";
export { Month };
//# sourceMappingURL=Month.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"month":"m_cc9820d3","monthCell":"m_8f457cd5","weekNumber":"m_6cff9dea"};
export { classes as default };
//# sourceMappingURL=Month.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Month.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,31 @@
'use client';
import dayjs from 'dayjs';
import { isAfterMinDate } from '../is-after-min-date/is-after-min-date.mjs';
import { isBeforeMaxDate } from '../is-before-max-date/is-before-max-date.mjs';
import { isSameMonth } from '../is-same-month/is-same-month.mjs';
function getDateInTabOrder({
dates,
minDate,
maxDate,
getDayProps,
excludeDate,
hideOutsideDates,
month
}) {
const enabledDates = dates.flat().filter(
(date) => isBeforeMaxDate(date, maxDate) && isAfterMinDate(date, minDate) && !excludeDate?.(date) && !getDayProps?.(date)?.disabled && (!hideOutsideDates || isSameMonth(date, month))
);
const selectedDate = enabledDates.find((date) => getDayProps?.(date)?.selected);
if (selectedDate) {
return selectedDate;
}
const currentDate = enabledDates.find((date) => dayjs().isSame(date, "date"));
if (currentDate) {
return currentDate;
}
return enabledDates[0];
}
export { getDateInTabOrder };
//# sourceMappingURL=get-date-in-tab-order.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-date-in-tab-order.mjs","sources":["../../../../src/components/Month/get-date-in-tab-order/get-date-in-tab-order.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\nimport { DayProps } from '../../Day/Day';\nimport { isAfterMinDate } from '../is-after-min-date/is-after-min-date';\nimport { isBeforeMaxDate } from '../is-before-max-date/is-before-max-date';\nimport { isSameMonth } from '../is-same-month/is-same-month';\n\ninterface GetDateInTabOrderInput {\n dates: DateStringValue[][];\n minDate: DateStringValue | undefined;\n maxDate: DateStringValue | undefined;\n getDayProps: ((date: DateStringValue) => Partial<DayProps>) | undefined;\n excludeDate: ((date: DateStringValue) => boolean) | undefined;\n hideOutsideDates: boolean | undefined;\n month: DateStringValue;\n}\n\nexport function getDateInTabOrder({\n dates,\n minDate,\n maxDate,\n getDayProps,\n excludeDate,\n hideOutsideDates,\n month,\n}: GetDateInTabOrderInput) {\n const enabledDates = dates\n .flat()\n .filter(\n (date) =>\n isBeforeMaxDate(date, maxDate) &&\n isAfterMinDate(date, minDate) &&\n !excludeDate?.(date) &&\n !getDayProps?.(date)?.disabled &&\n (!hideOutsideDates || isSameMonth(date, month))\n );\n\n const selectedDate = enabledDates.find((date) => getDayProps?.(date)?.selected);\n\n if (selectedDate) {\n return selectedDate;\n }\n\n const currentDate = enabledDates.find((date) => dayjs().isSame(date, 'date'));\n\n if (currentDate) {\n return currentDate;\n }\n\n return enabledDates[0];\n}\n"],"names":[],"mappings":";;;;;;AAiBO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,iBAAA,CAAkB,CAAA;AAAA,CAAA,CAChC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA;AACF,CAAA,CAAA,CAA2B,CAAA;AACzB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,YAAA,CAAA,CAAA,CAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAClB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CACL,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACC,CAAC,CAAA,CAAA,CAAA,MACC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgB,IAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAA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AA,CAAA,CAAA,KAAS,CAAA,CAAA,CAAA,CAAA,GAAM,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,IAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA;AAE5E,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,WAAA,CAAA,CAAa,CAAA;AACf,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACT,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAa,CAAC,CAAA,CAAA;AACvB,CAAA;;"}

View File

@@ -0,0 +1,17 @@
'use client';
import dayjs from 'dayjs';
function getEndOfWeek(date, firstDayOfWeek = 1) {
let value = dayjs(date);
if (!value.isValid()) {
return value;
}
const lastDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1;
while (value.day() !== lastDayOfWeek) {
value = value.add(1, "day");
}
return value.format("YYYY-MM-DD");
}
export { getEndOfWeek };
//# sourceMappingURL=get-end-of-week.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-end-of-week.mjs","sources":["../../../../src/components/Month/get-end-of-week/get-end-of-week.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { DateStringValue, DayOfWeek } from '../../../types';\n\nexport function getEndOfWeek(date: DateStringValue, firstDayOfWeek: DayOfWeek = 1) {\n let value = dayjs(date);\n\n if (!value.isValid()) {\n return value;\n }\n\n const lastDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1;\n while (value.day() !== lastDayOfWeek) {\n value = value.add(1, 'day');\n }\n\n return value.format('YYYY-MM-DD');\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA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CAAI,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA;AAAA,CAAA,CAC5B,CAAA;AAEA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,YAAY,CAAA,CAAA;AAClC,CAAA;;"}

View File

@@ -0,0 +1,43 @@
'use client';
import dayjs from 'dayjs';
import { getEndOfWeek } from '../get-end-of-week/get-end-of-week.mjs';
import { getStartOfWeek } from '../get-start-of-week/get-start-of-week.mjs';
function getMonthDays({
month,
firstDayOfWeek = 1,
consistentWeeks
}) {
const day = dayjs(month).subtract(dayjs(month).date() - 1, "day");
const start = dayjs(day.format("YYYY-M-D"));
const startOfMonth = start.format("YYYY-MM-DD");
const endOfMonth = start.add(+start.daysInMonth() - 1, "day").format("YYYY-MM-DD");
const endDate = getEndOfWeek(endOfMonth, firstDayOfWeek);
const weeks = [];
let date = dayjs(getStartOfWeek(startOfMonth, firstDayOfWeek));
while (dayjs(date).isBefore(endDate, "day")) {
const days = [];
for (let i = 0; i < 7; i += 1) {
days.push(date.format("YYYY-MM-DD"));
date = date.add(1, "day");
}
weeks.push(days);
}
if (consistentWeeks && weeks.length < 6) {
const lastWeek = weeks[weeks.length - 1];
const lastDay = lastWeek[lastWeek.length - 1];
let nextDay = dayjs(lastDay).add(1, "day");
while (weeks.length < 6) {
const days = [];
for (let i = 0; i < 7; i += 1) {
days.push(nextDay.format("YYYY-MM-DD"));
nextDay = nextDay.add(1, "day");
}
weeks.push(days);
}
}
return weeks;
}
export { getMonthDays };
//# sourceMappingURL=get-month-days.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
'use client';
import dayjs from 'dayjs';
function getStartOfWeek(date, firstDayOfWeek = 1) {
let value = dayjs(date);
while (value.day() !== firstDayOfWeek) {
value = value.subtract(1, "day");
}
return value.format("YYYY-MM-DD");
}
export { getStartOfWeek };
//# sourceMappingURL=get-start-of-week.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-start-of-week.mjs","sources":["../../../../src/components/Month/get-start-of-week/get-start-of-week.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { DateStringValue, DayOfWeek } from '../../../types';\n\nexport function getStartOfWeek(date: DateStringValue, firstDayOfWeek: DayOfWeek = 1) {\n let value = dayjs(date);\n while (value.day() !== firstDayOfWeek) {\n value = value.subtract(1, 'day');\n }\n\n return value.format('YYYY-MM-DD');\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,cAAA,CAAe,CAAA,CAAA,CAAA,CAAA,EAAuB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4B,CAAA,CAAA,CAAG,CAAA;AACnF,CAAA,CAAA,IAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAA,CAAA,EAAM,IAAI,CAAA,CAAA;AACtB,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,GAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAM,cAAA,CAAA,CAAgB,CAAA;AACrC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,QAAA,CAAS,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA;AAAA,CAAA,CACjC,CAAA;AAEA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,YAAY,CAAA,CAAA;AAClC,CAAA;;"}

View File

@@ -0,0 +1,12 @@
'use client';
import dayjs from 'dayjs';
import isoWeek from 'dayjs/plugin/isoWeek.js';
dayjs.extend(isoWeek);
function getWeekNumber(week) {
const monday = week.find((date) => dayjs(date).day() === 1);
return dayjs(monday).isoWeek();
}
export { getWeekNumber };
//# sourceMappingURL=get-week-number.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-week-number.mjs","sources":["../../../../src/components/Month/get-week-number/get-week-number.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport isoWeek from 'dayjs/plugin/isoWeek.js';\nimport { DateStringValue } from '../../../types';\n\ndayjs.extend(isoWeek);\n\nexport function getWeekNumber(week: DateStringValue[]): number {\n const monday = week.find((date) => dayjs(date).day() === 1);\n return dayjs(monday).isoWeek();\n}\n"],"names":[],"mappings":";;;;AAIA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA;AAEb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiC,CAAA;AAC7D,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,IAAA,CAAK,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA,CAAA,CAAA,CAAA,KAAS,CAAA,CAAA,CAAA,CAAA,EAAM,IAAI,CAAA,CAAE,GAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA;AAC1D,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,MAAM,CAAA,CAAE,OAAA,CAAA,CAAQ,CAAA;AAC/B,CAAA;;"}

View File

@@ -0,0 +1,9 @@
'use client';
import dayjs from 'dayjs';
function isAfterMinDate(date, minDate) {
return minDate ? dayjs(date).isAfter(dayjs(minDate).subtract(1, "day"), "day") : true;
}
export { isAfterMinDate };
//# sourceMappingURL=is-after-min-date.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-after-min-date.mjs","sources":["../../../../src/components/Month/is-after-min-date/is-after-min-date.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\nexport function isAfterMinDate(date: DateStringValue, minDate: DateStringValue | undefined) {\n return minDate ? dayjs(date).isAfter(dayjs(minDate).subtract(1, 'day'), 'day') : true;\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAA,CAAA,CAAA,GAAuB,OAAA,CAAA,CAAsC,CAAA;AAC1F,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,IAAI,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,OAAO,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA;AACnF,CAAA;;"}

View File

@@ -0,0 +1,9 @@
'use client';
import dayjs from 'dayjs';
function isBeforeMaxDate(date, maxDate) {
return maxDate ? dayjs(date).isBefore(dayjs(maxDate).add(1, "day"), "day") : true;
}
export { isBeforeMaxDate };
//# sourceMappingURL=is-before-max-date.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-before-max-date.mjs","sources":["../../../../src/components/Month/is-before-max-date/is-before-max-date.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\nexport function isBeforeMaxDate(date: DateStringValue, maxDate: DateStringValue | undefined) {\n return maxDate ? dayjs(date).isBefore(dayjs(maxDate).add(1, 'day'), 'day') : true;\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgB,CAAA,CAAA,CAAA,GAAuB,OAAA,CAAA,CAAsC,CAAA;AAC3F,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,IAAI,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,OAAO,CAAA,CAAE,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA;AAC/E,CAAA;;"}

View File

@@ -0,0 +1,9 @@
'use client';
import dayjs from 'dayjs';
function isSameMonth(date, comparison) {
return dayjs(date).format("YYYY-MM") === dayjs(comparison).format("YYYY-MM");
}
export { isSameMonth };
//# sourceMappingURL=is-same-month.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-same-month.mjs","sources":["../../../../src/components/Month/is-same-month/is-same-month.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\nexport function isSameMonth(date: Date | string, comparison: Date | string) {\n return dayjs(date).format('YYYY-MM') === dayjs(comparison).format('YYYY-MM');\n}\n"],"names":[],"mappings":";;;AAEO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,GAAqB,UAAA,CAAA,CAA2B,CAAA;AAC1E,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,IAAI,CAAA,CAAE,MAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,SAAS,CAAA,CAAA;AAC7E,CAAA;;"}

View File

@@ -0,0 +1,135 @@
'use client';
import { jsxs, jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { factory, useProps, Box } from '@mantine/core';
import { CalendarHeader } from '../CalendarHeader/CalendarHeader.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import { Month } from '../Month/Month.mjs';
const defaultProps = {
monthLabelFormat: "MMMM YYYY"
};
const MonthLevel = factory((_props, ref) => {
const props = useProps("MonthLevel", defaultProps, _props);
const {
// Month settings
month,
locale,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
__getDayRef,
__onDayKeyDown,
__onDayClick,
__onDayMouseEnter,
withCellSpacing,
highlightToday,
withWeekNumbers,
// CalendarHeader settings
__preventFocus,
__stopPropagation,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled,
previousDisabled,
hasNextLevel,
levelControlAriaLabel,
withNext,
withPrevious,
headerControlsOrder,
// Other props
monthLabelFormat,
classNames,
styles,
unstyled,
__staticSelector,
size,
static: isStatic,
attributes,
...others
} = props;
const ctx = useDatesContext();
const stylesApiProps = {
__staticSelector: __staticSelector || "MonthLevel",
classNames,
styles,
unstyled,
size,
attributes
};
const _nextDisabled = typeof nextDisabled === "boolean" ? nextDisabled : maxDate ? !dayjs(month).endOf("month").isBefore(maxDate) : false;
const _previousDisabled = typeof previousDisabled === "boolean" ? previousDisabled : minDate ? !dayjs(month).startOf("month").isAfter(minDate) : false;
return /* @__PURE__ */ jsxs(Box, { "data-month-level": true, size, ref, ...others, children: [
/* @__PURE__ */ jsx(
CalendarHeader,
{
label: typeof monthLabelFormat === "function" ? monthLabelFormat(month) : dayjs(month).locale(locale || ctx.locale).format(monthLabelFormat),
__preventFocus,
__stopPropagation,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled: _nextDisabled,
previousDisabled: _previousDisabled,
hasNextLevel,
levelControlAriaLabel,
withNext,
withPrevious,
headerControlsOrder,
...stylesApiProps
}
),
/* @__PURE__ */ jsx(
Month,
{
month,
locale,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
__getDayRef,
__onDayKeyDown,
__onDayClick,
__onDayMouseEnter,
__preventFocus,
__stopPropagation,
static: isStatic,
withCellSpacing,
highlightToday,
withWeekNumbers,
...stylesApiProps
}
)
] });
});
MonthLevel.classes = { ...Month.classes, ...CalendarHeader.classes };
MonthLevel.displayName = "@mantine/dates/MonthLevel";
export { MonthLevel };
//# sourceMappingURL=MonthLevel.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,149 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { useRef } from 'react';
import { factory, useProps } from '@mantine/core';
import { handleControlKeyDown } from '../../utils/handle-control-key-down/handle-control-key-down.mjs';
import { LevelsGroup } from '../LevelsGroup/LevelsGroup.mjs';
import { MonthLevel } from '../MonthLevel/MonthLevel.mjs';
const defaultProps = {
numberOfColumns: 1
};
const MonthLevelGroup = factory((_props, ref) => {
const props = useProps("MonthLevelGroup", defaultProps, _props);
const {
// Month settings
month,
locale,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
__onDayClick,
__onDayMouseEnter,
withCellSpacing,
highlightToday,
withWeekNumbers,
// CalendarHeader settings
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled,
previousDisabled,
hasNextLevel,
headerControlsOrder,
// Other settings
classNames,
styles,
unstyled,
numberOfColumns,
levelControlAriaLabel,
monthLabelFormat,
__staticSelector,
__stopPropagation,
size,
static: isStatic,
vars,
attributes,
...others
} = props;
const daysRefs = useRef([]);
const months = Array(numberOfColumns).fill(0).map((_, monthIndex) => {
const currentMonth = dayjs(month).add(monthIndex, "months").format("YYYY-MM-DD");
return /* @__PURE__ */ jsx(
MonthLevel,
{
month: currentMonth,
withNext: monthIndex === numberOfColumns - 1,
withPrevious: monthIndex === 0,
monthLabelFormat,
__stopPropagation,
__onDayClick,
__onDayMouseEnter,
__onDayKeyDown: (event, payload) => handleControlKeyDown({
levelIndex: monthIndex,
rowIndex: payload.rowIndex,
cellIndex: payload.cellIndex,
event,
controlsRef: daysRefs
}),
__getDayRef: (rowIndex, cellIndex, node) => {
if (!Array.isArray(daysRefs.current[monthIndex])) {
daysRefs.current[monthIndex] = [];
}
if (!Array.isArray(daysRefs.current[monthIndex][rowIndex])) {
daysRefs.current[monthIndex][rowIndex] = [];
}
daysRefs.current[monthIndex][rowIndex][cellIndex] = node;
},
levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentMonth) : levelControlAriaLabel,
locale,
firstDayOfWeek,
weekdayFormat,
weekendDays,
getDayProps,
excludeDate,
minDate,
maxDate,
renderDay,
hideOutsideDates,
hideWeekdays,
getDayAriaLabel,
__preventFocus,
nextIcon,
previousIcon,
nextLabel,
previousLabel,
onNext,
onPrevious,
onLevelClick,
nextDisabled,
previousDisabled,
hasNextLevel,
classNames,
styles,
unstyled,
__staticSelector: __staticSelector || "MonthLevelGroup",
size,
static: isStatic,
withCellSpacing,
highlightToday,
withWeekNumbers,
headerControlsOrder,
attributes
},
monthIndex
);
});
return /* @__PURE__ */ jsx(
LevelsGroup,
{
classNames,
styles,
__staticSelector: __staticSelector || "MonthLevelGroup",
ref,
size,
attributes,
...others,
children: months
}
);
});
MonthLevelGroup.classes = { ...LevelsGroup.classes, ...MonthLevel.classes };
MonthLevelGroup.displayName = "@mantine/dates/MonthLevelGroup";
export { MonthLevelGroup };
//# sourceMappingURL=MonthLevelGroup.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,77 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { factory, useProps, useResolvedStylesApi } from '@mantine/core';
import { useDatesState } from '../../hooks/use-dates-state/use-dates-state.mjs';
import 'dayjs';
import '@mantine/hooks';
import '../DatesProvider/DatesProvider.mjs';
import 'react';
import { Calendar } from '../Calendar/Calendar.mjs';
const defaultProps = {
type: "default"
};
const MonthPicker = factory((_props, ref) => {
const props = useProps("MonthPicker", defaultProps, _props);
const {
classNames,
styles,
vars,
type,
defaultValue,
value,
onChange,
__staticSelector,
getMonthControlProps,
allowSingleDateInRange,
allowDeselect,
onMouseLeave,
onMonthSelect,
__updateDateOnMonthSelect,
onLevelChange,
...others
} = props;
const { onDateChange, onRootMouseLeave, onHoveredDateChange, getControlProps } = useDatesState({
type,
level: "month",
allowDeselect,
allowSingleDateInRange,
value,
defaultValue,
onChange,
onMouseLeave
});
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
return /* @__PURE__ */ jsx(
Calendar,
{
ref,
minLevel: "year",
__updateDateOnMonthSelect: __updateDateOnMonthSelect ?? false,
__staticSelector: __staticSelector || "MonthPicker",
onMouseLeave: onRootMouseLeave,
onMonthMouseEnter: (_event, date) => onHoveredDateChange(date),
onMonthSelect: (date) => {
onDateChange(date);
onMonthSelect?.(date);
},
getMonthControlProps: (date) => ({
...getControlProps(date),
...getMonthControlProps?.(date)
}),
classNames: resolvedClassNames,
styles: resolvedStyles,
onLevelChange,
...others
}
);
});
MonthPicker.classes = Calendar.classes;
MonthPicker.displayName = "@mantine/dates/MonthPicker";
export { MonthPicker };
//# sourceMappingURL=MonthPicker.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,122 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { factory, useProps, useResolvedStylesApi } from '@mantine/core';
import 'dayjs';
import 'react';
import '@mantine/hooks';
import { getDefaultClampedDate } from '../../utils/get-default-clamped-date/get-default-clamped-date.mjs';
import { useDatesInput } from '../../hooks/use-dates-input/use-dates-input.mjs';
import '../Calendar/Calendar.mjs';
import { pickCalendarProps } from '../Calendar/pick-calendar-levels-props/pick-calendar-levels-props.mjs';
import { MonthPicker } from '../MonthPicker/MonthPicker.mjs';
import { PickerInputBase } from '../PickerInputBase/PickerInputBase.mjs';
const defaultProps = {
type: "default",
valueFormat: "MMMM YYYY",
closeOnChange: true,
sortDates: true,
dropdownType: "popover"
};
const MonthPickerInput = factory(
(_props, ref) => {
const props = useProps("MonthPickerInput", defaultProps, _props);
const {
type,
value,
defaultValue,
onChange,
valueFormat,
labelSeparator,
locale,
classNames,
styles,
unstyled,
closeOnChange,
size,
variant,
dropdownType,
sortDates,
minDate,
maxDate,
vars,
valueFormatter,
attributes,
...rest
} = props;
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
classNames,
styles,
props
});
const { calendarProps, others } = pickCalendarProps(rest);
const {
_value,
setValue,
formattedValue,
dropdownHandlers,
dropdownOpened,
onClear,
shouldClear
} = useDatesInput({
type,
value,
defaultValue,
onChange,
locale,
format: valueFormat,
labelSeparator,
closeOnChange,
sortDates,
valueFormatter
});
return /* @__PURE__ */ jsx(
PickerInputBase,
{
formattedValue,
dropdownOpened,
dropdownHandlers,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
ref,
onClear,
shouldClear,
value: _value,
size,
variant,
dropdownType,
...others,
attributes,
type,
__staticSelector: "MonthPickerInput",
children: /* @__PURE__ */ jsx(
MonthPicker,
{
...calendarProps,
size,
variant,
type,
value: _value,
defaultDate: calendarProps.defaultDate || (Array.isArray(_value) ? _value[0] || getDefaultClampedDate({ maxDate, minDate }) : _value || getDefaultClampedDate({ maxDate, minDate })),
onChange: setValue,
locale,
classNames: resolvedClassNames,
styles: resolvedStyles,
unstyled,
__staticSelector: "MonthPickerInput",
__stopPropagation: dropdownType === "popover",
minDate,
maxDate,
attributes
}
)
}
);
}
);
MonthPickerInput.classes = { ...PickerInputBase.classes, ...MonthPicker.classes };
MonthPickerInput.displayName = "@mantine/dates/MonthPickerInput";
export { MonthPickerInput };
//# sourceMappingURL=MonthPickerInput.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,126 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import dayjs from 'dayjs';
import { factory, useProps, useStyles, Box } from '@mantine/core';
import { toDateString } from '../../utils/to-date-string/to-date-string.mjs';
import '../DatesProvider/DatesProvider.mjs';
import { useDatesContext } from '../DatesProvider/use-dates-context.mjs';
import { PickerControl } from '../PickerControl/PickerControl.mjs';
import { getMonthInTabOrder } from './get-month-in-tab-order/get-month-in-tab-order.mjs';
import { getMonthsData } from './get-months-data/get-months-data.mjs';
import { isMonthDisabled } from './is-month-disabled/is-month-disabled.mjs';
import classes from './MonthsList.module.css.mjs';
const defaultProps = {
monthsListFormat: "MMM",
withCellSpacing: true
};
const MonthsList = factory((_props, ref) => {
const props = useProps("MonthsList", defaultProps, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
__staticSelector,
year,
monthsListFormat,
locale,
minDate,
maxDate,
getMonthControlProps,
__getControlRef,
__onControlKeyDown,
__onControlClick,
__onControlMouseEnter,
__preventFocus,
__stopPropagation,
withCellSpacing,
size,
attributes,
...others
} = props;
const getStyles = useStyles({
name: __staticSelector || "MonthsList",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars,
rootSelector: "monthsList"
});
const ctx = useDatesContext();
const months = getMonthsData(year);
const monthInTabOrder = getMonthInTabOrder({
months,
minDate: toDateString(minDate),
maxDate: toDateString(maxDate),
getMonthControlProps
});
const rows = months.map((monthsRow, rowIndex) => {
const cells = monthsRow.map((month, cellIndex) => {
const controlProps = getMonthControlProps?.(month);
const isMonthInTabOrder = dayjs(month).isSame(monthInTabOrder, "month");
return /* @__PURE__ */ jsx(
"td",
{
...getStyles("monthsListCell"),
"data-with-spacing": withCellSpacing || void 0,
children: /* @__PURE__ */ jsx(
PickerControl,
{
...getStyles("monthsListControl"),
size,
unstyled,
__staticSelector: __staticSelector || "MonthsList",
"data-mantine-stop-propagation": __stopPropagation || void 0,
disabled: isMonthDisabled({
month,
minDate: toDateString(minDate),
maxDate: toDateString(maxDate)
}),
ref: (node) => {
if (node) {
__getControlRef?.(rowIndex, cellIndex, node);
}
},
...controlProps,
onKeyDown: (event) => {
controlProps?.onKeyDown?.(event);
__onControlKeyDown?.(event, { rowIndex, cellIndex, date: month });
},
onClick: (event) => {
controlProps?.onClick?.(event);
__onControlClick?.(event, month);
},
onMouseEnter: (event) => {
controlProps?.onMouseEnter?.(event);
__onControlMouseEnter?.(event, month);
},
onMouseDown: (event) => {
controlProps?.onMouseDown?.(event);
__preventFocus && event.preventDefault();
},
tabIndex: __preventFocus || !isMonthInTabOrder ? -1 : 0,
children: controlProps?.children ?? dayjs(month).locale(ctx.getLocale(locale)).format(monthsListFormat)
}
)
},
cellIndex
);
});
return /* @__PURE__ */ jsx("tr", { ...getStyles("monthsListRow"), children: cells }, rowIndex);
});
return /* @__PURE__ */ jsx(Box, { component: "table", ref, size, ...getStyles("monthsList"), ...others, children: /* @__PURE__ */ jsx("tbody", { children: rows }) });
});
MonthsList.classes = classes;
MonthsList.displayName = "@mantine/dates/MonthsList";
export { MonthsList };
//# sourceMappingURL=MonthsList.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"monthsList":"m_2a6c32d","monthsListCell":"m_fe27622f"};
export { classes as default };
//# sourceMappingURL=MonthsList.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MonthsList.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,26 @@
'use client';
import dayjs from 'dayjs';
import { isMonthDisabled } from '../is-month-disabled/is-month-disabled.mjs';
function getMonthInTabOrder({
months,
minDate,
maxDate,
getMonthControlProps
}) {
const enabledMonths = months.flat().filter(
(month) => !isMonthDisabled({ month, minDate, maxDate }) && !getMonthControlProps?.(month)?.disabled
);
const selectedMonth = enabledMonths.find((month) => getMonthControlProps?.(month)?.selected);
if (selectedMonth) {
return selectedMonth;
}
const currentMonth = enabledMonths.find((month) => dayjs().isSame(month, "month"));
if (currentMonth) {
return currentMonth;
}
return enabledMonths[0];
}
export { getMonthInTabOrder };
//# sourceMappingURL=get-month-in-tab-order.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-month-in-tab-order.mjs","sources":["../../../../src/components/MonthsList/get-month-in-tab-order/get-month-in-tab-order.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\nimport { PickerControlProps } from '../../PickerControl';\nimport { isMonthDisabled } from '../is-month-disabled/is-month-disabled';\n\ninterface GetMonthInTabOrderInput {\n months: DateStringValue[][];\n minDate: DateStringValue | undefined;\n maxDate: DateStringValue | undefined;\n getMonthControlProps: ((month: DateStringValue) => Partial<PickerControlProps>) | undefined;\n}\n\nexport function getMonthInTabOrder({\n months,\n minDate,\n maxDate,\n getMonthControlProps,\n}: GetMonthInTabOrderInput) {\n const enabledMonths = months\n .flat()\n .filter(\n (month) =>\n !isMonthDisabled({ month, minDate, maxDate }) && !getMonthControlProps?.(month)?.disabled\n );\n\n const selectedMonth = enabledMonths.find((month) => getMonthControlProps?.(month)?.selected);\n\n if (selectedMonth) {\n return selectedMonth;\n }\n\n const currentMonth = enabledMonths.find((month) => dayjs().isSame(month, 'month'));\n\n if (currentMonth) {\n return currentMonth;\n }\n\n return enabledMonths[0];\n}\n"],"names":[],"mappings":";;;;AAYO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,kBAAA,CAAmB,CAAA;AAAA,CAAA,CACjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACF,CAAA,CAAA,CAA4B,CAAA;AAC1B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,aAAA,CAAA,CAAA,CAAgB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACnB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CACL,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACC,CAAC,KAAA,CAAA,CAAA,CAAA,CAAA,CACC,CAAC,eAAA,CAAgB,CAAA,CAAE,KAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,oBAAA,CAAA,CAAA,CAAuB,C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AAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAc,CAAC,CAAA,CAAA;AACxB,CAAA;;"}

View File

@@ -0,0 +1,18 @@
'use client';
import dayjs from 'dayjs';
function getMonthsData(year) {
const startOfYear = dayjs(year).startOf("year").toDate();
const results = [[], [], [], []];
let currentMonthIndex = 0;
for (let i = 0; i < 4; i += 1) {
for (let j = 0; j < 3; j += 1) {
results[i].push(dayjs(startOfYear).add(currentMonthIndex, "months").format("YYYY-MM-DD"));
currentMonthIndex += 1;
}
}
return results;
}
export { getMonthsData };
//# sourceMappingURL=get-months-data.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-months-data.mjs","sources":["../../../../src/components/MonthsList/get-months-data/get-months-data.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\nexport function getMonthsData(year: DateStringValue) {\n const startOfYear = dayjs(year).startOf('year').toDate();\n\n const results: DateStringValue[][] = [[], [], [], []];\n let currentMonthIndex = 0;\n\n for (let i = 0; i < 4; i += 1) {\n for (let j = 0; j < 3; j += 1) {\n results[i].push(dayjs(startOfYear).add(currentMonthIndex, 'months').format('YYYY-MM-DD'));\n currentMonthIndex += 1;\n }\n }\n\n return results;\n}\n"],"names":[],"mappings":";;;AAGO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuB,CAAA;AACnD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAI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AAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAC,CAAA,CAAA;AACxF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAqB,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CACvB,CAAA;AAAA,CAAA,CACF,CAAA;AAEA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACT,CAAA;;"}

View File

@@ -0,0 +1,18 @@
'use client';
import dayjs from 'dayjs';
function isMonthDisabled({ month, minDate, maxDate }) {
if (!minDate && !maxDate) {
return false;
}
if (minDate && dayjs(month).isBefore(minDate, "month")) {
return true;
}
if (maxDate && dayjs(month).isAfter(maxDate, "month")) {
return true;
}
return false;
}
export { isMonthDisabled };
//# sourceMappingURL=is-month-disabled.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-month-disabled.mjs","sources":["../../../../src/components/MonthsList/is-month-disabled/is-month-disabled.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { DateStringValue } from '../../../types';\n\ninterface IsMonthDisabledInput {\n month: DateStringValue;\n minDate: DateStringValue | undefined;\n maxDate: DateStringValue | undefined;\n}\n\nexport function isMonthDisabled({ month, minDate, maxDate }: IsMonthDisabledInput): boolean {\n if (!minDate && !maxDate) {\n return false;\n }\n\n if (minDate && dayjs(month).isBefore(minDate, 'month')) {\n return true;\n }\n\n if (maxDate && dayjs(month).isAfter(maxDate, 'month')) {\n return true;\n }\n\n return false;\n}\n"],"names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AAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAG,CAAA;AACrD,CAAA,CAAA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CACT,CAAA;AAEA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACT,CAAA;;"}

View File

@@ -0,0 +1,65 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { createVarsResolver, getSize, getFontSize, factory, useProps, useStyles, UnstyledButton } from '@mantine/core';
import classes from './PickerControl.module.css.mjs';
const varsResolver = createVarsResolver((_, { size }) => ({
pickerControl: {
"--dpc-fz": getFontSize(size),
"--dpc-size": getSize(size, "dpc-size")
}
}));
const PickerControl = factory((_props, ref) => {
const props = useProps("PickerControl", null, _props);
const {
classNames,
className,
style,
styles,
unstyled,
vars,
firstInRange,
lastInRange,
inRange,
__staticSelector,
selected,
disabled,
attributes,
...others
} = props;
const getStyles = useStyles({
name: __staticSelector || "PickerControl",
classes,
props,
className,
style,
classNames,
styles,
unstyled,
attributes,
vars,
varsResolver,
rootSelector: "pickerControl"
});
return /* @__PURE__ */ jsx(
UnstyledButton,
{
...getStyles("pickerControl"),
ref,
unstyled,
"data-picker-control": true,
"data-selected": selected && !disabled || void 0,
"data-disabled": disabled || void 0,
"data-in-range": inRange && !disabled && !selected || void 0,
"data-first-in-range": firstInRange && !disabled || void 0,
"data-last-in-range": lastInRange && !disabled || void 0,
disabled,
...others
}
);
});
PickerControl.classes = classes;
PickerControl.displayName = "@mantine/dates/PickerControl";
export { PickerControl };
//# sourceMappingURL=PickerControl.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"pickerControl":"m_dc6a3c71"};
export { classes as default };
//# sourceMappingURL=PickerControl.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PickerControl.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,123 @@
'use client';
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import cx from 'clsx';
import { factory, useInputProps, Input, Modal, Popover } from '@mantine/core';
import { HiddenDatesInput } from '../HiddenDatesInput/HiddenDatesInput.mjs';
import classes from './PickerInputBase.module.css.mjs';
const PickerInputBase = factory((_props, ref) => {
const {
inputProps,
wrapperProps,
placeholder,
classNames,
styles,
unstyled,
popoverProps,
modalProps,
dropdownType,
children,
formattedValue,
dropdownHandlers,
dropdownOpened,
onClick,
clearable,
onClear,
clearButtonProps,
rightSection,
shouldClear,
readOnly,
disabled,
value,
name,
form,
type,
onDropdownClose,
withTime,
...others
} = useInputProps("PickerInputBase", { size: "sm" }, _props);
const clearButton = /* @__PURE__ */ jsx(Input.ClearButton, { onClick: onClear, unstyled, ...clearButtonProps });
const handleClose = () => {
const isInvalidRangeValue = type === "range" && Array.isArray(value) && value[0] && !value[1];
if (isInvalidRangeValue) {
onClear();
}
dropdownHandlers.close();
};
return /* @__PURE__ */ jsxs(Fragment, { children: [
dropdownType === "modal" && !readOnly && /* @__PURE__ */ jsx(
Modal,
{
opened: dropdownOpened,
onClose: handleClose,
withCloseButton: false,
size: "auto",
"data-dates-modal": true,
unstyled,
...modalProps,
children
}
),
/* @__PURE__ */ jsx(Input.Wrapper, { ...wrapperProps, children: /* @__PURE__ */ jsxs(
Popover,
{
position: "bottom-start",
opened: dropdownOpened,
trapFocus: true,
returnFocus: false,
unstyled,
onClose: onDropdownClose,
...popoverProps,
disabled: popoverProps?.disabled || dropdownType === "modal" || readOnly,
onChange: (_opened) => {
if (!_opened) {
popoverProps?.onClose?.();
handleClose();
}
},
children: [
/* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(
Input,
{
"data-dates-input": true,
"data-read-only": readOnly || void 0,
disabled,
component: "button",
type: "button",
multiline: true,
onClick: (event) => {
onClick?.(event);
dropdownHandlers.toggle();
},
__clearSection: clearButton,
__clearable: clearable && shouldClear && !readOnly && !disabled,
rightSection,
...inputProps,
ref,
classNames: { ...classNames, input: cx(classes.input, classNames?.input) },
...others,
children: formattedValue || /* @__PURE__ */ jsx(
Input.Placeholder,
{
error: inputProps.error,
unstyled,
classNames,
styles,
__staticSelector: inputProps.__staticSelector,
children: placeholder
}
)
}
) }),
/* @__PURE__ */ jsx(Popover.Dropdown, { "data-dates-dropdown": true, children })
]
}
) }),
/* @__PURE__ */ jsx(HiddenDatesInput, { value, name, form, type, withTime })
] });
});
PickerInputBase.classes = classes;
PickerInputBase.displayName = "@mantine/dates/PickerInputBase";
export { PickerInputBase };
//# sourceMappingURL=PickerInputBase.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
'use client';
var classes = {"input":"m_6fa5e2aa"};
export { classes as default };
//# sourceMappingURL=PickerInputBase.module.css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PickerInputBase.module.css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}

View File

@@ -0,0 +1,117 @@
'use client';
import { jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { clamp } from '@mantine/hooks';
import { padTime } from '../TimePicker/utils/pad-time/pad-time.mjs';
const getMaxDigit = (max) => Number(max.toFixed(0)[0]);
const SpinInput = forwardRef(
({
value,
min,
max,
onChange,
focusable,
step,
onNextInput,
onPreviousInput,
onFocus,
readOnly,
allowTemporaryZero = false,
placeholder = "--",
...others
}, ref) => {
const maxDigit = getMaxDigit(max);
const arrowsMax = max + 1 - step;
const handleChange = (value2) => {
if (readOnly) {
return;
}
const clearValue = value2.replace(/\D/g, "");
if (clearValue !== "") {
const parsedValue = parseInt(clearValue, 10);
const clampedValue = allowTemporaryZero && parsedValue === 0 && min > 0 ? 0 : clamp(parsedValue, min, max);
onChange(clampedValue);
if (clampedValue > maxDigit || value2.startsWith("00")) {
onNextInput?.();
}
}
};
const handleKeyDown = (event) => {
if (readOnly) {
return;
}
if (event.key === "0" || event.key === "Num0") {
if (value === 0) {
event.preventDefault();
onNextInput?.();
}
}
if (event.key === "Home") {
event.preventDefault();
onChange(min);
}
if (event.key === "End") {
event.preventDefault();
onChange(max);
}
if (event.key === "Backspace" || event.key === "Delete") {
event.preventDefault();
if (value !== null) {
onChange(null);
} else {
onPreviousInput?.();
}
}
if (event.key === "ArrowRight") {
event.preventDefault();
onNextInput?.();
}
if (event.key === "ArrowLeft") {
event.preventDefault();
onPreviousInput?.();
}
if (event.key === "ArrowUp") {
event.preventDefault();
const newValue = value === null ? min : clamp(value + step, min, arrowsMax);
onChange(newValue);
}
if (event.key === "ArrowDown") {
event.preventDefault();
const newValue = value === null ? arrowsMax : clamp(value - step, min, arrowsMax);
onChange(newValue);
}
};
return /* @__PURE__ */ jsx(
"input",
{
ref,
type: "text",
role: "spinbutton",
"aria-valuemin": min,
"aria-valuemax": max,
"aria-valuenow": value === null ? 0 : value,
"data-empty": value === null || void 0,
inputMode: "numeric",
placeholder,
value: value === null ? "" : padTime(value),
onChange: (event) => handleChange(event.currentTarget.value),
onKeyDown: handleKeyDown,
onFocus: (event) => {
event.currentTarget.select();
onFocus?.(event);
},
onClick: (event) => {
event.stopPropagation();
event.currentTarget.select();
},
onMouseDown: (event) => event.stopPropagation(),
...others
}
);
}
);
SpinInput.displayName = "@mantine/dates/SpinInput";
export { SpinInput };
//# sourceMappingURL=SpinInput.mjs.map

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More