{"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,\n baseDate: baseDate\n // Body\n ,\n\n getCellDate: getCellDate,\n getCellText: getCellText,\n getCellClassName: getCellClassName\n }))));\n}","map":{"version":3,"names":["_extends","_defineProperty","_slicedToArray","React","formatValue","isInRange","isSameYear","PanelContext","useInfo","PanelBody","PanelHeader","YearPanel","props","prefixCls","locale","generateConfig","pickerValue","disabledDate","onPickerValueChange","onModeChange","panelPrefixCls","concat","_useInfo","_useInfo2","info","getStartYear","date","startYear","Math","floor","getYear","setYear","getEndYear","addYear","startYearDate","endYearDate","baseDate","getCellDate","offset","getCellText","format","cellYearFormat","getCellClassName","mergedDisabledDate","currentDate","disabledInfo","startMonth","setMonth","startDate","setDate","endMonth","endDate","addDate","yearNode","createElement","type","key","onClick","tabIndex","className","yearFormat","Provider","value","superOffset","distance","onChange","getStart","getEnd","titleFormat","fieldYearFormat","colNum","rowNum"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-picker/es/PickerPanel/YearPanel/index.js"],"sourcesContent":["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 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,\n baseDate: baseDate\n // Body\n ,\n getCellDate: getCellDate,\n getCellText: getCellText,\n getCellClassName: getCellClassName\n }))));\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAOC,eAAe,MAAM,2CAA2C;AACvE,OAAOC,cAAc,MAAM,0CAA0C;AACrE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,WAAW,EAAEC,SAAS,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