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

1 line
13 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 _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { formatValue, isInRange, isSameYear } from \"../../utils/dateUtil\";\nimport { PanelContext, useInfo } from \"../context\";\nimport PanelBody from \"../PanelBody\";\nimport PanelHeader from \"../PanelHeader\";\nexport default function YearPanel(props) {\n var prefixCls = props.prefixCls,\n locale = props.locale,\n generateConfig = props.generateConfig,\n pickerValue = props.pickerValue,\n disabledDate = props.disabledDate,\n onPickerValueChange = props.onPickerValueChange,\n onModeChange = props.onModeChange;\n var panelPrefixCls = \"\".concat(prefixCls, \"-year-panel\");\n\n // ========================== Base ==========================\n var _useInfo = useInfo(props, 'year'),\n _useInfo2 = _slicedToArray(_useInfo, 1),\n info = _useInfo2[0];\n var getStartYear = function getStartYear(date) {\n var startYear = Math.floor(generateConfig.getYear(pickerValue) / 10) * 10;\n return generateConfig.setYear(date, startYear);\n };\n var getEndYear = function getEndYear(date) {\n var startYear = getStartYear(date);\n return generateConfig.addYear(startYear, 9);\n };\n var startYearDate = getStartYear(pickerValue);\n var endYearDate = getEndYear(pickerValue);\n var baseDate = generateConfig.addYear(startYearDate, -1);\n\n // ========================= Cells ==========================\n var getCellDate = function getCellDate(date, offset) {\n return generateConfig.addYear(date, offset);\n };\n var getCellText = function getCellText(date) {\n return formatValue(date, {\n locale: locale,\n format: locale.cellYearFormat,\n generateConfig: generateConfig\n });\n };\n var getCellClassName = function getCellClassName(date) {\n return _defineProperty({}, \"\".concat(prefixCls, \"-cell-in-view\"), isSameYear(generateConfig, date, startYearDate) || isSameYear(generateConfig, date, endYearDate) || isInRange(generateConfig, startYearDate, endYearDate, date));\n };\n\n // ======================== Disabled ========================\n var mergedDisabledDate = disabledDate ? function (currentDate, disabledInfo) {\n // Start\n var startMonth = generateConfig.setMonth(currentDate, 0);\n var startDate = generateConfig.setDate(startMonth, 1);\n\n // End\n var endMonth = generateConfig.addYear(startDate, 1);\n var endDate = generateConfig.addDate(endMonth, -1);\n return disabledDate(startDate, disabledInfo) && disabledDate(endDate, disabledInfo);\n } : null;\n\n // ========================= Header =========================\n var yearNode = /*#__PURE__*/React.createElement(\"button\", {\n type: \"button\",\n key: \"decade\",\n \"aria-label\": \"decade panel\",\n onClick: function onClick() {\n onModeChange('decade');\n },\n tabIndex: -1,\n className: \"\".concat(prefixCls, \"-decade-btn\")\n }, formatValue(startYearDate, {\n locale: locale,\n format: locale.yearFormat,\n generateConfig: generateConfig\n }), \"-\", formatValue(endYearDate, {\n locale: locale,\n format: locale.yearFormat,\n generateConfig: generateConfig\n }));\n\n // ========================= Render =========================\n return /*#__PURE__*/React.createElement(PanelContext.Provider, {\n value: info\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: panelPrefixCls\n }, /*#__PURE__*/React.createElement(PanelHeader, {\n superOffset: function superOffset(distance) {\n return generateConfig.addYear(pickerValue, distance * 10);\n },\n onChange: onPickerValueChange\n // Limitation\n ,\n\n getStart: getStartYear,\n getEnd: getEndYear\n }, yearNode), /*#__PURE__*/React.createElement(PanelBody, _extends({}, props, {\n disabledDate: mergedDisabledDate,\n titleFormat: locale.fieldYearFormat,\n colNum: 3,\n rowNum: 4,\