@qsxy/element-plus-react 1.0.0-next.17 → 1.0.0-next.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,6 +68,7 @@ var CheckboxGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (props,
68
68
  if (itemChecked) {
69
69
  nextValue.push(itemValue);
70
70
  } else {
71
+ // @ts-ignore
71
72
  remove(nextValue, function (i) {
72
73
  return shallowEqual(i, itemValue);
73
74
  });
@@ -16,6 +16,8 @@ export interface ConfigProviderProps {
16
16
  popper?: {
17
17
  appendTo?: HTMLElement;
18
18
  };
19
+ locale?: 'en' | 'zh-CN';
19
20
  }
20
21
  declare const ConfigProvider: import("react").Context<ConfigProviderProps>;
22
+ export declare const useConfigProvider: () => ConfigProviderProps;
21
23
  export default ConfigProvider;
@@ -1,10 +1,14 @@
1
- import { createContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
2
  var ConfigProvider = /*#__PURE__*/createContext({
3
3
  // message: { max: Infinity },
4
4
  inputNumber: {
5
5
  controlsPositionRight: false
6
6
  },
7
+ locale: 'en',
7
8
  popper: {}
8
9
  });
10
+ export var useConfigProvider = function useConfigProvider() {
11
+ return useContext(ConfigProvider);
12
+ };
9
13
  ConfigProvider.displayName = 'ConfigProvider';
10
14
  export default ConfigProvider;
@@ -1,2 +1,2 @@
1
- export { default as ConfigProvider } from './ConfigProvider';
1
+ export { default as ConfigProvider, useConfigProvider } from './ConfigProvider';
2
2
  export type { ConfigProviderProps } from './ConfigProvider';
@@ -1 +1 @@
1
- export { default as ConfigProvider } from "./ConfigProvider";
1
+ export { default as ConfigProvider, useConfigProvider } from "./ConfigProvider";
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DateTimePickerRef } from './typings';
3
- declare const DateTimePicker: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<import("..").DatePickerProps, "type" | "name"> & {
3
+ declare const DateTimePicker: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<import("..").DatePickerProps, "name" | "type"> & {
4
4
  name?: string;
5
5
  onClear?: (event?: any) => void;
6
6
  defaultTime?: Date;
@@ -6,7 +6,7 @@ import { FormInstance, FormProps, Store } from './typings';
6
6
  import useForm from './useForm';
7
7
  import useWatch from './useWatch';
8
8
  declare const ForwardForm: <RecordType = Store>(props: FormProps<RecordType> & {
9
- ref?: React.ForwardedRef<FormInstance<RecordType>>;
9
+ ref?: ForwardedRef<FormInstance<RecordType>>;
10
10
  }) => React.ReactElement;
11
11
  type InternalFormType = typeof ForwardForm;
12
12
  interface FormInterface extends InternalFormType {
@@ -208,6 +208,7 @@ var MessageBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (props, ref
208
208
  get ref() {
209
209
  return containerRef;
210
210
  },
211
+ inputValue: inputValue,
211
212
  close: done,
212
213
  setConfirmButtonLoading: setConfirmButtonLoading,
213
214
  setConfirmButtonText: setConfirmButtonText
@@ -104,6 +104,7 @@ export interface MessageBoxMethod {
104
104
  }
105
105
  export interface MessageBoxRef {
106
106
  ref: RefObject<HTMLDivElement>;
107
+ inputValue?: string;
107
108
  /** 关闭方法 */
108
109
  close: () => void;
109
110
  /** 设置确认按钮是否加载状态 */
@@ -1,16 +1,21 @@
1
1
  import React, { FC } from 'react';
2
+ import { TypeAttributes } from '../types/common';
2
3
  interface Props {
3
4
  goButton?: React.ReactElement | boolean;
4
5
  quickGo?: (val: number) => void;
5
6
  rootPrefixCls?: string;
6
7
  pageSize: number;
7
- pageSizeOptions?: Array<string>;
8
+ /** 默认的每页条数 */
9
+ defaultPageSize?: number;
10
+ pageSizeOptions?: Array<number>;
8
11
  selectComponentClass?: string;
9
12
  selectPrefixCls?: string;
10
13
  disabled?: boolean;
14
+ simple?: boolean;
11
15
  current?: number;
12
16
  changeSize: ((page: number) => void) | null;
13
- mini?: boolean;
17
+ size?: TypeAttributes.Size;
18
+ type: 'sizes' | 'jumper';
14
19
  }
15
20
  declare const Options: FC<Props>;
16
21
  export default Options;
@@ -1,4 +1,4 @@
1
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
2
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -6,7 +6,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
7
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
8
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
- import React, { useCallback, useMemo, useState } from 'react';
9
+ import classNames from 'classnames';
10
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
11
+ import { useTranslation } from 'react-i18next';
12
+ import { ElInput } from '..';
13
+ import { useConfigProvider } from "../ConfigProvider";
10
14
  import ElOption from "../Select/Option";
11
15
  import Select from "../Select/Select";
12
16
  import { useClassNames } from "../hooks";
@@ -14,42 +18,50 @@ var Options = function Options(props) {
14
18
  var rootPrefixCls = props.rootPrefixCls,
15
19
  changeSize = props.changeSize,
16
20
  quickGo = props.quickGo,
21
+ current = props.current,
17
22
  goButton = props.goButton,
18
23
  disabled = props.disabled,
19
- _props$pageSizeOption = props.pageSizeOptions,
20
- _pageSizeOptions = _props$pageSizeOption === void 0 ? ['10', '20', '50', '100'] : _props$pageSizeOption,
24
+ simple = props.simple,
25
+ _pageSizeOptions = props.pageSizeOptions,
21
26
  pageSize = props.pageSize,
22
- mini = props.mini;
27
+ defaultPageSize = props.defaultPageSize,
28
+ type = props.type,
29
+ size = props.size;
23
30
  var _useState = useState(''),
24
31
  _useState2 = _slicedToArray(_useState, 2),
25
32
  goInputText = _useState2[0],
26
33
  setGoInputText = _useState2[1];
27
- var _useClassNames = useClassNames("".concat(rootPrefixCls, "-options")),
28
- b = _useClassNames.b;
34
+ var _useClassNames = useClassNames(rootPrefixCls),
35
+ b = _useClassNames.b,
36
+ e = _useClassNames.e,
37
+ is = _useClassNames.is;
38
+ var _useTranslation = useTranslation(),
39
+ t = _useTranslation.t;
40
+ var _useConfigProvider = useConfigProvider(),
41
+ locale = _useConfigProvider.locale;
29
42
  var getValidValue = useMemo(function () {
30
43
  return !goInputText || typeof goInputText === 'number' ? undefined : Number(goInputText);
31
44
  }, [goInputText]);
32
- var go = useCallback(function (e) {
45
+ var go = useCallback(function (event) {
33
46
  if (goInputText === '') {
34
47
  return;
35
48
  }
36
- if (e.key === 'Enter' || e.type === 'click') {
37
- setGoInputText('');
49
+ if (event.key === 'Enter' || event.type === 'click') {
38
50
  getValidValue && (quickGo === null || quickGo === void 0 ? void 0 : quickGo(getValidValue));
39
51
  }
40
52
  }, [getValidValue, goInputText, quickGo]);
41
53
  var handleChangeSize = useCallback(function (value) {
42
54
  changeSize === null || changeSize === void 0 || changeSize(Number(value));
43
55
  }, [changeSize]);
44
- var handleChange = useCallback(function (e) {
45
- setGoInputText(e.target.value);
56
+ var handleChange = useCallback(function (value) {
57
+ setGoInputText(value);
46
58
  }, []);
47
- var handleBlur = useCallback(function (e) {
59
+ var handleBlur = useCallback(function (event) {
48
60
  if (goButton || goInputText === '') {
49
61
  return;
50
62
  }
51
63
  setGoInputText('');
52
- if (e.relatedTarget && (e.relatedTarget.className.indexOf(b(_templateObject || (_templateObject = _taggedTemplateLiteral(["item-link"])))) >= 0 || e.relatedTarget.className.indexOf(b(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["item"])))) >= 0)) {
64
+ if (event.relatedTarget && (event.relatedTarget.className.indexOf(b(_templateObject || (_templateObject = _taggedTemplateLiteral(["item-link"])))) >= 0 || event.relatedTarget.className.indexOf(b(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["item"])))) >= 0)) {
53
65
  return;
54
66
  }
55
67
  getValidValue && (quickGo === null || quickGo === void 0 ? void 0 : quickGo(getValidValue));
@@ -60,7 +72,7 @@ var Options = function Options(props) {
60
72
  })) {
61
73
  return _pageSizeOptions;
62
74
  }
63
- return _pageSizeOptions.concat([pageSize.toString()]).sort(function (x, y) {
75
+ return _pageSizeOptions.concat([pageSize]).sort(function (x, y) {
64
76
  var numberA = isNaN(Number(x)) ? 0 : Number(x);
65
77
  var numberB = isNaN(Number(y)) ? 0 : Number(y);
66
78
  return numberA - numberB;
@@ -72,52 +84,55 @@ var Options = function Options(props) {
72
84
  filterable: false,
73
85
  className: b(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["size-changer"]))),
74
86
  clearable: false,
75
- size: mini ? 'small' : null,
76
- value: (pageSize.toString() || _pageSizeOptions[0]).toString()
77
- // @ts-ignore
78
- ,
87
+ size: size,
88
+ value: pageSize,
89
+ defaultValue: defaultPageSize || _pageSizeOptions[0],
79
90
  onChange: handleChangeSize
80
91
  }, pageSizeOptions.map(function (opt, i) {
81
92
  return /*#__PURE__*/React.createElement(ElOption, {
82
93
  key: i,
83
94
  value: opt,
84
- label: "".concat(opt, " \u6761/\u9875")
95
+ label: "".concat(opt, " ").concat(t('el.pagination.pagesize', {
96
+ lng: locale
97
+ }))
85
98
  });
86
99
  }));
87
- }, [changeSize, disabled, b, mini, pageSize, _pageSizeOptions, handleChangeSize, pageSizeOptions]);
100
+ }, [changeSize, disabled, b, size, pageSize, defaultPageSize, _pageSizeOptions, handleChangeSize, pageSizeOptions, t, locale]);
101
+ useEffect(function () {
102
+ return setGoInputText(current + '');
103
+ }, [current]);
88
104
  var goInput = useMemo(function () {
89
- if (quickGo) {
90
- var gotoButton;
91
- if (goButton) {
92
- gotoButton = typeof goButton === 'boolean' ? /*#__PURE__*/React.createElement("button", {
93
- type: "button",
94
- onClick: go,
95
- onKeyUp: go,
96
- disabled: disabled,
97
- className: b(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["quick-jumper-button"])))
98
- }, "\u786E\u5B9A") : /*#__PURE__*/React.createElement("span", {
99
- onClick: go,
100
- onKeyUp: go
101
- }, goButton);
102
- }
103
- return /*#__PURE__*/React.createElement("div", {
104
- className: b(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["quick-jumper"])))
105
- }, "\u8DF3\u81F3", /*#__PURE__*/React.createElement("input", {
106
- disabled: disabled,
107
- type: "text",
108
- value: goInputText,
109
- onChange: handleChange,
110
- onKeyUp: go,
111
- onBlur: handleBlur
112
- }), "\u9875", gotoButton);
113
- }
114
- return null;
115
- }, [b, disabled, go, goButton, goInputText, handleBlur, handleChange, quickGo]);
116
- if (!changeSize && !quickGo) {
117
- return null;
105
+ return /*#__PURE__*/React.createElement(React.Fragment, null, simple ? null : /*#__PURE__*/React.createElement("span", {
106
+ className: e(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["goto"])))
107
+ }, t('el.pagination.goto', {
108
+ lng: locale
109
+ })), /*#__PURE__*/React.createElement(ElInput, {
110
+ className: e(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["editor"]))),
111
+ disabled: disabled,
112
+ value: goInputText,
113
+ size: size,
114
+ onChange: handleChange,
115
+ onKeyUp: go,
116
+ placeholder: "",
117
+ clearable: false
118
+ }), simple ? null : /*#__PURE__*/React.createElement("span", {
119
+ className: e(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["classifier"])))
120
+ }, t('el.pagination.pageClassifier', {
121
+ lng: locale
122
+ })));
123
+ }, [disabled, e, go, goInputText, handleChange, locale, simple, size, t]);
124
+ if (type === 'sizes') {
125
+ return /*#__PURE__*/React.createElement("span", {
126
+ className: classNames(e(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["sizes"]))), b(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["item"]))))
127
+ }, changeSelect);
128
+ }
129
+ if (type === 'jumper') {
130
+ return /*#__PURE__*/React.createElement("span", {
131
+ className: classNames(e(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["jump"]))), b(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["item"]))), is({
132
+ simple: simple
133
+ }))
134
+ }, goInput);
118
135
  }
119
- return /*#__PURE__*/React.createElement("li", {
120
- className: b()
121
- }, changeSelect, goInput);
136
+ return null;
122
137
  };
123
138
  export default Options;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _templateObject, _templateObject2, _templateObject3;
2
+ var _templateObject;
3
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
5
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -11,22 +11,22 @@ var Pager = function Pager(props) {
11
11
  var _props$classPrefix = props.classPrefix,
12
12
  classPrefix = _props$classPrefix === void 0 ? 'pagination-item' : _props$classPrefix,
13
13
  page = props.page,
14
- showTitle = props.showTitle,
15
14
  active = props.active,
16
- onClick = props.onClick,
17
- itemRender = props.itemRender;
15
+ disabled = props.disabled,
16
+ onClick = props.onClick;
18
17
  var _useClassNames = useClassNames(classPrefix),
19
- b = _useClassNames.b;
18
+ b = _useClassNames.b,
19
+ is = _useClassNames.is;
20
20
  var handleClick = function handleClick() {
21
21
  onClick === null || onClick === void 0 || onClick(page);
22
22
  };
23
23
  return /*#__PURE__*/React.createElement("li", {
24
- title: showTitle ? page + '' : undefined,
25
- className: classNames(b(), b(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ""])), page), _defineProperty(_defineProperty({}, b(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["active"]))), active), b(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["disabled"]))), !page), props.className),
24
+ className: classNames('number', is({
25
+ active: active,
26
+ disabled: disabled
27
+ }), _defineProperty({}, b(_templateObject || (_templateObject = _taggedTemplateLiteral(["disabled"]))), !page), props.className),
26
28
  onClick: handleClick,
27
29
  tabIndex: 0
28
- }, itemRender === null || itemRender === void 0 ? void 0 : itemRender(page, 'page', /*#__PURE__*/React.createElement("a", {
29
- rel: "nofollow"
30
- }, page)));
30
+ }, page);
31
31
  };
32
32
  export default Pager;