PromoCursed/node_modules/.cache/babel-loader/98d7037bff4ceac6ea31c8541096d679f9834faae50c30736ddc6acb8cfe95dc.json

1 line
26 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { PickerPanel as RCPickerPanel } from 'rc-picker';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport { useLocale } from '../locale';\nimport CalendarHeader from './Header';\nimport enUS from './locale/en_US';\nimport useStyle from './style';\nconst isSameYear = (date1, date2, config) => {\n const {\n getYear\n } = config;\n return date1 && date2 && getYear(date1) === getYear(date2);\n};\nconst isSameMonth = (date1, date2, config) => {\n const {\n getMonth\n } = config;\n return isSameYear(date1, date2, config) && getMonth(date1) === getMonth(date2);\n};\nconst isSameDate = (date1, date2, config) => {\n const {\n getDate\n } = config;\n return isSameMonth(date1, date2, config) && getDate(date1) === getDate(date2);\n};\nconst generateCalendar = generateConfig => {\n const Calendar = props => {\n const {\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n style,\n dateFullCellRender,\n dateCellRender,\n monthFullCellRender,\n monthCellRender,\n cellRender,\n fullCellRender,\n headerRender,\n value,\n defaultValue,\n disabledDate,\n mode,\n validRange,\n fullscreen = true,\n onChange,\n onPanelChange,\n onSelect\n } = props;\n const {\n getPrefixCls,\n direction,\n calendar\n } = React.useContext(ConfigContext);\n const prefixCls = getPrefixCls('picker', customizePrefixCls);\n const calendarPrefixCls = `${prefixCls}-calendar`;\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, calendarPrefixCls);\n const today = generateConfig.getNow();\n // ====================== Warning =======================\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Calendar');\n warning.deprecated(!dateFullCellRender, 'dateFullCellRender', 'fullCellRender');\n warning.deprecated(!dateCellRender, 'dateCellRender', 'cellRender');\n warning.deprecated(!monthFullCellRender, 'monthFullCellRender', 'fullCellRender');\n warning.deprecated(!monthCellRender, 'monthCellRender', 'cellRender');\n }\n // ====================== State =======================\n // Value\n const [mergedValue, setMergedValue] = useMergedState(() => value || generateConfig.getNow(), {\n defaultValue,\n value\n });\n // Mode\n const [mergedMode, setMergedMode] = useMergedState('month', {\n value: mode\n });\n const panelMode = React.useMemo(() => mergedMode === 'year' ? 'month' : 'date', [mergedMode]);\n // Disabled Date\n const mergedDisabledDate = React.useCallback(date => {\n const notInRange = validRange ? generateConfig.isAfter(validRange[0], date) || generateConfig.isAfter(date, validRange[1]) : false;\n return notInRange || !!(disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date));\n }, [disabledDate, validRange]);\n // ====================== Events ======================\n const triggerPanelChange = (date, newMode) => {\n onPanelChange === null || onPanelChange === void 0 ? void 0 : onPanelChange(date, newMode);\n };\n const triggerChange = date => {\n setMergedValue(date);\n if (!isSameDate(date, mergedValue, generateConfig)) {\n // Trigger when month panel switch month\n if (panelMode === 'date' && !isSameMonth(date, mergedValue, generateConfig) || panelMode === 'month' && !isSameYear(date, mergedValue, generateConfig)) {\n triggerPanelChange(date, mergedMode);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(date);\n }\n };\n const triggerModeChange = newMode => {\n setMergedMode(newMode);\n triggerPanelChange(mergedValue, newMode);\n };\n const onInternalSelect = (date, source) => {\n triggerCha