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

1 line
33 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport useTimeInfo from \"../../../hooks/useTimeInfo\";\nimport { formatValue } from \"../../../utils/dateUtil\";\nimport { PickerHackContext, usePanelContext } from \"../../context\";\nimport TimeColumn from \"./TimeColumn\";\nfunction isAM(hour) {\n return hour < 12;\n}\nexport default function TimePanelBody(props) {\n var showHour = props.showHour,\n showMinute = props.showMinute,\n showSecond = props.showSecond,\n showMillisecond = props.showMillisecond,\n showMeridiem = props.use12Hours,\n changeOnScroll = props.changeOnScroll;\n var _usePanelContext = usePanelContext(),\n prefixCls = _usePanelContext.prefixCls,\n values = _usePanelContext.values,\n generateConfig = _usePanelContext.generateConfig,\n locale = _usePanelContext.locale,\n onSelect = _usePanelContext.onSelect,\n onHover = _usePanelContext.onHover,\n pickerValue = _usePanelContext.pickerValue;\n var value = (values === null || values === void 0 ? void 0 : values[0]) || null;\n var _React$useContext = React.useContext(PickerHackContext),\n onCellDblClick = _React$useContext.onCellDblClick;\n\n // ========================== Info ==========================\n var _useTimeInfo = useTimeInfo(generateConfig, props, value),\n _useTimeInfo2 = _slicedToArray(_useTimeInfo, 5),\n getValidTime = _useTimeInfo2[0],\n rowHourUnits = _useTimeInfo2[1],\n getMinuteUnits = _useTimeInfo2[2],\n getSecondUnits = _useTimeInfo2[3],\n getMillisecondUnits = _useTimeInfo2[4];\n\n // ========================= Value ==========================\n // PickerValue will tell which one to align on the top\n var getUnitValue = function getUnitValue(func) {\n var valueUnitVal = value && generateConfig[func](value);\n var pickerUnitValue = pickerValue && generateConfig[func](pickerValue);\n return [valueUnitVal, pickerUnitValue];\n };\n var _getUnitValue = getUnitValue('getHour'),\n _getUnitValue2 = _slicedToArray(_getUnitValue, 2),\n hour = _getUnitValue2[0],\n pickerHour = _getUnitValue2[1];\n var _getUnitValue3 = getUnitValue('getMinute'),\n _getUnitValue4 = _slicedToArray(_getUnitValue3, 2),\n minute = _getUnitValue4[0],\n pickerMinute = _getUnitValue4[1];\n var _getUnitValue5 = getUnitValue('getSecond'),\n _getUnitValue6 = _slicedToArray(_getUnitValue5, 2),\n second = _getUnitValue6[0],\n pickerSecond = _getUnitValue6[1];\n var _getUnitValue7 = getUnitValue('getMillisecond'),\n _getUnitValue8 = _slicedToArray(_getUnitValue7, 2),\n millisecond = _getUnitValue8[0],\n pickerMillisecond = _getUnitValue8[1];\n var meridiem = hour === null ? null : isAM(hour) ? 'am' : 'pm';\n\n // ========================= Column =========================\n // Hours\n var hourUnits = React.useMemo(function () {\n if (!showMeridiem) {\n return rowHourUnits;\n }\n return isAM(hour) ? rowHourUnits.filter(function (h) {\n return isAM(h.value);\n }) : rowHourUnits.filter(function (h) {\n return !isAM(h.value);\n });\n }, [hour, rowHourUnits, showMeridiem]);\n\n // >>> Pick Fallback\n var getEnabled = function getEnabled(units, val) {\n var _enabledUnits$;\n var enabledUnits = units.filter(function (unit) {\n return !unit.disabled;\n });\n return val !== null && val !== void 0 ? val :\n // Fallback to enabled value\n enabledUnits === null || enabledUnits === void 0 || (_enabledUnits$ = enabledUnits[0]) === null || _enabledUnits$ === void 0 ? void 0 : _enabledUnits$.value;\n };\n\n // >>> Minutes\n var validHour = getEnabled(rowHourUnits, hour);\n var minuteUnits = React.useMemo(function () {\n return getMinuteUnits(validHour);\n }, [getMinuteUnits, validHour]);\n\n // >>> Seconds\n var validMinute = getEnabled(minuteUnits, minute);\n var secondUnits = React.useMemo(function () {\n return getSecondUnits(validHour, validMinute);\n }, [getSecond