PromoCursed/node_modules/.cache/babel-loader/c8b57474066a1dbfc681740d3fb32b1143f81e4bd37b7453160fa9cf30df174b.json

1 line
23 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useMergedState } from 'rc-util';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\nimport { fillTime, isSame } from \"../../utils/dateUtil\";\nexport function offsetPanelDate(generateConfig, picker, date, offset) {\n switch (picker) {\n case 'date':\n case 'week':\n return generateConfig.addMonth(date, offset);\n case 'month':\n case 'quarter':\n return generateConfig.addYear(date, offset);\n case 'year':\n return generateConfig.addYear(date, offset * 10);\n case 'decade':\n return generateConfig.addYear(date, offset * 100);\n default:\n return date;\n }\n}\nvar EMPTY_LIST = [];\nexport default function useRangePickerValue(generateConfig, locale, calendarValue, modes, open, activeIndex, pickerMode, multiplePanel) {\n var defaultPickerValue = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : EMPTY_LIST;\n var pickerValue = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : EMPTY_LIST;\n var timeDefaultValue = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : EMPTY_LIST;\n var onPickerValueChange = arguments.length > 11 ? arguments[11] : undefined;\n var minDate = arguments.length > 12 ? arguments[12] : undefined;\n var maxDate = arguments.length > 13 ? arguments[13] : undefined;\n var isTimePicker = pickerMode === 'time';\n\n // ======================== Active ========================\n // `activeIndex` must be valid to avoid getting empty `pickerValue`\n var mergedActiveIndex = activeIndex || 0;\n\n // ===================== Picker Value =====================\n var getDefaultPickerValue = function getDefaultPickerValue(index) {\n var now = generateConfig.getNow();\n if (isTimePicker) {\n now = fillTime(generateConfig, now);\n }\n return defaultPickerValue[index] || calendarValue[index] || now;\n };\n\n // Align `pickerValue` with `showTime.defaultValue`\n var _pickerValue = _slicedToArray(pickerValue, 2),\n startPickerValue = _pickerValue[0],\n endPickerValue = _pickerValue[1];\n\n // PickerValue state\n var _useMergedState = useMergedState(function () {\n return getDefaultPickerValue(0);\n }, {\n value: startPickerValue\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n mergedStartPickerValue = _useMergedState2[0],\n setStartPickerValue = _useMergedState2[1];\n var _useMergedState3 = useMergedState(function () {\n return getDefaultPickerValue(1);\n }, {\n value: endPickerValue\n }),\n _useMergedState4 = _slicedToArray(_useMergedState3, 2),\n mergedEndPickerValue = _useMergedState4[0],\n setEndPickerValue = _useMergedState4[1];\n\n // Current PickerValue\n var currentPickerValue = React.useMemo(function () {\n var current = [mergedStartPickerValue, mergedEndPickerValue][mergedActiveIndex];\n\n // Merge the `showTime.defaultValue` into `pickerValue`\n return isTimePicker ? current : fillTime(generateConfig, current, timeDefaultValue[mergedActiveIndex]);\n }, [isTimePicker, mergedStartPickerValue, mergedEndPickerValue, mergedActiveIndex, generateConfig, timeDefaultValue]);\n var setCurrentPickerValue = function setCurrentPickerValue(nextPickerValue) {\n var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'panel';\n var updater = [setStartPickerValue, setEndPickerValue][mergedActiveIndex];\n updater(nextPickerValue);\n var clone = [mergedStartPickerValue, mergedEndPickerValue];\n clone[mergedActiveIndex] = nextPickerValue;\n if (onPickerValueChange && (!isSame(generateConfig, locale, mergedStartPickerValue, clone[0], pickerMode) || !isSame(generateConfig, locale, mergedEndPickerValue, clone[1], pickerMode))) {\n onPickerValueChange(clone, {\n source: source,\n range: mergedActiveIndex === 1 ? 'end' : 'start',\n mode: modes\n });\n }\n };\n\n // ======================== Effe