1 line
13 KiB
JSON
1 line
13 KiB
JSON
|
{"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, isSameDecade } from \"../../utils/dateUtil\";\nimport { PanelContext, useInfo } from \"../context\";\nimport PanelBody from \"../PanelBody\";\nimport PanelHeader from \"../PanelHeader\";\nexport default function DecadePanel(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 var panelPrefixCls = \"\".concat(prefixCls, \"-decade-panel\");\n\n // ========================== Base ==========================\n var _useInfo = useInfo(props, 'decade'),\n _useInfo2 = _slicedToArray(_useInfo, 1),\n info = _useInfo2[0];\n var getStartYear = function getStartYear(date) {\n var startYear = Math.floor(generateConfig.getYear(pickerValue) / 100) * 100;\n return generateConfig.setYear(date, startYear);\n };\n var getEndYear = function getEndYear(date) {\n var startYear = getStartYear(date);\n return generateConfig.addYear(startYear, 99);\n };\n var startYearDate = getStartYear(pickerValue);\n var endYearDate = getEndYear(pickerValue);\n var baseDate = generateConfig.addYear(startYearDate, -10);\n\n // ========================= Cells ==========================\n var getCellDate = function getCellDate(date, offset) {\n return generateConfig.addYear(date, offset * 10);\n };\n var getCellText = function getCellText(date) {\n var cellYearFormat = locale.cellYearFormat;\n var startYearStr = formatValue(date, {\n locale: locale,\n format: cellYearFormat,\n generateConfig: generateConfig\n });\n var endYearStr = formatValue(generateConfig.addYear(date, 9), {\n locale: locale,\n format: cellYearFormat,\n generateConfig: generateConfig\n });\n return \"\".concat(startYearStr, \"-\").concat(endYearStr);\n };\n var getCellClassName = function getCellClassName(date) {\n return _defineProperty({}, \"\".concat(prefixCls, \"-cell-in-view\"), isSameDecade(generateConfig, date, startYearDate) || isSameDecade(generateConfig, date, endYearDate) || isInRange(generateConfig, startYearDate, endYearDate, date));\n };\n\n // ======================== Disabled ========================\n var mergedDisabledDate = disabledDate ? function (currentDate, disabledInfo) {\n // Start\n var baseStartDate = generateConfig.setDate(currentDate, 1);\n var baseStartMonth = generateConfig.setMonth(baseStartDate, 0);\n var baseStartYear = generateConfig.setYear(baseStartMonth, Math.floor(generateConfig.getYear(baseStartMonth) / 10) * 10);\n\n // End\n var baseEndYear = generateConfig.addYear(baseStartYear, 10);\n var baseEndDate = generateConfig.addDate(baseEndYear, -1);\n return disabledDate(baseStartYear, disabledInfo) && disabledDate(baseEndDate, disabledInfo);\n } : null;\n\n // ========================= Header =========================\n var yearNode = \"\".concat(formatValue(startYearDate, {\n locale: locale,\n format: locale.yearFormat,\n generateConfig: generateConfig\n }), \"-\").concat(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 * 100);\n },\n onChange: onPickerValueChange\n // Limitation\n ,\n\n getStart: getStartYear,\n getEnd: getEndYear\n }, yearNode), /*#__PURE__*/R
|