1 line
16 KiB
JSON
1 line
16 KiB
JSON
|
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport KEYCODE from \"rc-util/es/KeyCode\";\nimport React from 'react';\nvar defaultPageSizeOptions = ['10', '20', '50', '100'];\nvar Options = function Options(props) {\n var _props$pageSizeOption = props.pageSizeOptions,\n pageSizeOptions = _props$pageSizeOption === void 0 ? defaultPageSizeOptions : _props$pageSizeOption,\n locale = props.locale,\n changeSize = props.changeSize,\n pageSize = props.pageSize,\n goButton = props.goButton,\n quickGo = props.quickGo,\n rootPrefixCls = props.rootPrefixCls,\n Select = props.selectComponentClass,\n selectPrefixCls = props.selectPrefixCls,\n disabled = props.disabled,\n buildOptionText = props.buildOptionText;\n var _React$useState = React.useState(''),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n goInputText = _React$useState2[0],\n setGoInputText = _React$useState2[1];\n var getValidValue = function getValidValue() {\n return !goInputText || Number.isNaN(goInputText) ? undefined : Number(goInputText);\n };\n var mergeBuildOptionText = typeof buildOptionText === 'function' ? buildOptionText : function (value) {\n return \"\".concat(value, \" \").concat(locale.items_per_page);\n };\n var changeSizeHandle = function changeSizeHandle(value) {\n changeSize === null || changeSize === void 0 || changeSize(Number(value));\n };\n var handleChange = function handleChange(e) {\n setGoInputText(e.target.value);\n };\n var handleBlur = function handleBlur(e) {\n if (goButton || goInputText === '') {\n return;\n }\n setGoInputText('');\n if (e.relatedTarget && (e.relatedTarget.className.indexOf(\"\".concat(rootPrefixCls, \"-item-link\")) >= 0 || e.relatedTarget.className.indexOf(\"\".concat(rootPrefixCls, \"-item\")) >= 0)) {\n return;\n }\n quickGo === null || quickGo === void 0 || quickGo(getValidValue());\n };\n var go = function go(e) {\n if (goInputText === '') {\n return;\n }\n if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {\n setGoInputText('');\n quickGo === null || quickGo === void 0 || quickGo(getValidValue());\n }\n };\n var getPageSizeOptions = function getPageSizeOptions() {\n if (pageSizeOptions.some(function (option) {\n return option.toString() === pageSize.toString();\n })) {\n return pageSizeOptions;\n }\n return pageSizeOptions.concat([pageSize.toString()]).sort(function (a, b) {\n var numberA = Number.isNaN(Number(a)) ? 0 : Number(a);\n var numberB = Number.isNaN(Number(b)) ? 0 : Number(b);\n return numberA - numberB;\n });\n };\n // ============== cls ==============\n var prefixCls = \"\".concat(rootPrefixCls, \"-options\");\n\n // ============== render ==============\n\n if (!changeSize && !quickGo) {\n return null;\n }\n var changeSelect = null;\n var goInput = null;\n var gotoButton = null;\n if (changeSize && Select) {\n var options = getPageSizeOptions().map(function (opt, i) {\n return /*#__PURE__*/React.createElement(Select.Option, {\n key: i,\n value: opt.toString()\n }, mergeBuildOptionText(opt));\n });\n changeSelect = /*#__PURE__*/React.createElement(Select, {\n disabled: disabled,\n prefixCls: selectPrefixCls,\n showSearch: false,\n className: \"\".concat(prefixCls, \"-size-changer\"),\n optionLabelProp: \"children\",\n popupMatchSelectWidth: false,\n value: (pageSize || pageSizeOptions[0]).toString(),\n onChange: changeSizeHandle,\n getPopupContainer: function getPopupContainer(triggerNode) {\n return triggerNode.parentNode;\n },\n \"aria-label\": locale.page_size,\n defaultOpen: false\n }, options);\n }\n if (quickGo) {\n if (goButton) {\n gotoButton = typeof goButton === 'boolean' ? /*#__PURE__*/React.createElement(\"button\", {\n type: \"button\",\n onClick: go,\n onKeyUp: go,\n disabled: disabled,\n className: \"\".co
|