doui-react 1.0.0 → 1.0.2

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.
@@ -1,4 +1,4 @@
1
- export var inputValueReg = /^[a-zA-Z0-9_\-\s/.:*{}€,()%$|+#@=><']*$/i;
1
+ export var inputValueReg = /.*/i;
2
2
  export var scriptReg = /<[/]*[^/<]*\s*script[\s+]*[^/>]*[/]*>/i;
3
3
  export function validateScript(value) {
4
4
  return !value.match(scriptReg);
@@ -8,9 +8,7 @@ export function validateScript(value) {
8
8
  * validate data of general String type
9
9
  * letters, numbers, spot, underlines and Spaces
10
10
  */
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
12
  export function validateString(value) {
12
- if (!inputValueReg.test(value)) {
13
- return false;
14
- }
15
- return validateScript(value);
13
+ return true;
16
14
  }
@@ -60,9 +60,9 @@ function ButtonWrapper(_ref2) {
60
60
  }
61
61
  if (confirm) {
62
62
  return _jsx(Popconfirm, {
63
- title: confirmMessage || 'Are you sure?',
63
+ title: confirmMessage || '是否确定?',
64
64
  onConfirm: onClick,
65
- okText: okText || 'OK',
65
+ okText: okText,
66
66
  cancelText: cancelText,
67
67
  placement: props.placement,
68
68
  arrowPointAtCenter: props.arrowPointAtCenter,
@@ -17,7 +17,7 @@ export declare function getFormItemProps(props: any): {
17
17
  openClassName?: string | undefined;
18
18
  arrowPointAtCenter: boolean;
19
19
  autoAdjustOverflow?: boolean | import("antd/lib/tooltip").AdjustOverflow | undefined;
20
- getPopupContainer: typeof import("../../api").getPopupContainer;
20
+ getPopupContainer: (triggerNode: HTMLElement) => HTMLElement;
21
21
  children?: import("react").ReactNode;
22
22
  visible?: boolean | undefined;
23
23
  open?: boolean | undefined;
@@ -27,16 +27,15 @@ export declare function getFormItemProps(props: any): {
27
27
  onOpenChange?: ((visible: boolean) => void) | undefined;
28
28
  afterVisibleChange?: ((visible: boolean) => void) | undefined;
29
29
  afterOpenChange?: ((visible: boolean) => void) | undefined;
30
- zIndex?: number | undefined;
31
- animation?: string | undefined;
32
- motion?: import("rc-motion").CSSMotionProps | undefined;
33
30
  id?: string | undefined;
31
+ prefixCls?: string | undefined;
34
32
  onPopupAlign?: ((element: HTMLElement, align: import("rc-trigger/lib/interface").AlignType) => void) | undefined;
35
33
  trigger?: string | string[] | undefined;
36
34
  transitionName?: string | undefined;
35
+ animation?: string | undefined;
36
+ motion?: import("rc-motion").CSSMotionProps | undefined;
37
37
  overlayStyle?: import("react").CSSProperties | undefined;
38
38
  overlayClassName: string;
39
- prefixCls?: string | undefined;
40
39
  mouseEnterDelay?: number | undefined;
41
40
  mouseLeaveDelay?: number | undefined;
42
41
  getTooltipContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
@@ -48,6 +47,7 @@ export declare function getFormItemProps(props: any): {
48
47
  arrowContent?: import("react").ReactNode;
49
48
  popupVisible?: boolean | undefined;
50
49
  overlayInnerStyle?: import("react").CSSProperties | undefined;
50
+ zIndex?: number | undefined;
51
51
  icon: import("@emotion/react/jsx-runtime").JSX.Element;
52
52
  } | undefined;
53
53
  initialValue: any;
@@ -32,7 +32,7 @@ export function getFormProps(props) {
32
32
  autoComplete: 'off',
33
33
  labelWrap: true,
34
34
  validateMessages: {
35
- required: '${label} is required.'
35
+ required: '请输入${label}'
36
36
  },
37
37
  validateTrigger: ['onChange', 'onBlur'],
38
38
  onFinishFailed: function onFinishFailed(error) {
@@ -144,7 +144,7 @@ function generateRules(_ref2) {
144
144
  });
145
145
  }
146
146
  if (item.requiredInOptions) {
147
- var _message = _.isString(item.requiredInOptions) ? item.requiredInOptions : 'The value does not exist.';
147
+ var _message = _.isString(item.requiredInOptions) ? item.requiredInOptions : '该值不存在';
148
148
  var validator = function validator(_ref3) {
149
149
  var _form$getItems;
150
150
  var value = _ref3.value;
@@ -194,7 +194,7 @@ function generateRequiredMessage(item) {
194
194
  return item.required;
195
195
  }
196
196
  if (!item.label) {
197
- return 'The value is required.';
197
+ return '必填项';
198
198
  }
199
199
  }
200
200
  export function isValueNotExistInOptions(value, options) {
@@ -100,6 +100,7 @@ export interface FormItemProps extends UnionType {
100
100
  formListContext?: FormListContext;
101
101
  dependencies?: string[];
102
102
  removeErrorOnBlur?: boolean;
103
+ onBlur?(event: any): void;
103
104
  __noCollectState__?: boolean;
104
105
  }
105
106
  export interface FormItemContext extends Pick<FormItemPropsWithType, 'type' | 'optionDependencies' | 'loading' | 'rules' | 'formListContext'> {
@@ -16,7 +16,7 @@ export function Input(_ref) {
16
16
  var _ref$type = _ref.type,
17
17
  type = _ref$type === void 0 ? 'input' : _ref$type,
18
18
  _ref$placeholder = _ref.placeholder,
19
- placeholder = _ref$placeholder === void 0 ? 'Input' : _ref$placeholder,
19
+ placeholder = _ref$placeholder === void 0 ? '请输入' : _ref$placeholder,
20
20
  props = _objectWithoutProperties(_ref, _excluded);
21
21
  var Component = inputMap[type];
22
22
  return _jsx(Component, _objectSpread({
@@ -1,15 +1,17 @@
1
1
  import { validateScript, validateString } from "../../api";
2
2
  import { InputProps } from "..";
3
+ import { FocusEvent } from 'react';
3
4
  export declare const validateTypeMap: {
4
5
  default: typeof validateString;
5
6
  script: typeof validateScript;
6
7
  };
7
8
  export declare function validateInput(value: string, validate?: InputProps['validate']): boolean;
8
9
  export declare function validateEnter(value: any, allowEnter: boolean): boolean;
9
- export declare function useInputValidate({ value, onChange, onBlur, validate, refs, allowEnter, allowResetOnEmpty, ...props }: InputProps): any;
10
+ export declare function useInputValidate({ value, onChange, onBlur, validate, refs, allowEnter, allowResetOnEmpty, allowTrim, ...props }: InputProps): any;
10
11
  export declare function formatNumber(value: number, precision: number): number;
11
12
  interface ResetOnEmptyProps extends InputProps {
12
13
  validate?: (value: string | number) => boolean;
13
14
  }
14
15
  export declare function useResetOnEmpty({ name, allowResetOnEmpty, validate }: ResetOnEmptyProps): () => Promise<void>;
16
+ export declare function useTrim({ value, onChange, allowTrim }: InputProps): (event: FocusEvent<HTMLInputElement>) => Promise<void>;
15
17
  export {};
@@ -2,7 +2,7 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["value", "onChange", "onBlur", "validate", "refs", "allowEnter", "allowResetOnEmpty"];
5
+ var _excluded = ["value", "onChange", "onBlur", "validate", "refs", "allowEnter", "allowResetOnEmpty", "allowTrim"];
6
6
  import { mergeFunction, validateScript, validateString } from "../../api";
7
7
  import { useFormContext } from "../../form";
8
8
  import { transformPathToName } from "../../form/component/utils";
@@ -35,6 +35,7 @@ export function useInputValidate(_ref) {
35
35
  _ref$allowEnter = _ref.allowEnter,
36
36
  allowEnter = _ref$allowEnter === void 0 ? true : _ref$allowEnter,
37
37
  allowResetOnEmpty = _ref.allowResetOnEmpty,
38
+ allowTrim = _ref.allowTrim,
38
39
  props = _objectWithoutProperties(_ref, _excluded);
39
40
  var resetOnEmpty = useResetOnEmpty(_objectSpread(_objectSpread({}, props), {}, {
40
41
  allowResetOnEmpty: allowResetOnEmpty,
@@ -42,6 +43,11 @@ export function useInputValidate(_ref) {
42
43
  return !value;
43
44
  }
44
45
  }));
46
+ var trim = useTrim({
47
+ value: value,
48
+ onChange: onChange,
49
+ allowTrim: allowTrim
50
+ });
45
51
  var handleChange = function handleChange(e) {
46
52
  var value = e.target.value;
47
53
  if (validateInput(value, validate) && validateEnter(value, allowEnter)) {
@@ -55,7 +61,7 @@ export function useInputValidate(_ref) {
55
61
  autoComplete: 'off',
56
62
  value: _.isNil(value) ? '' : value,
57
63
  onChange: handleChange,
58
- onBlur: mergeFunction(onBlur, resetOnEmpty)
64
+ onBlur: mergeFunction(trim, resetOnEmpty, onBlur)
59
65
  });
60
66
  }
61
67
  export function formatNumber(value, precision) {
@@ -99,4 +105,36 @@ export function useResetOnEmpty(_ref2) {
99
105
  return _onBlur.apply(this, arguments);
100
106
  }
101
107
  return onBlur;
108
+ }
109
+ export function useTrim(_ref3) {
110
+ var value = _ref3.value,
111
+ onChange = _ref3.onChange,
112
+ allowTrim = _ref3.allowTrim;
113
+ function onBlur(_x) {
114
+ return _onBlur2.apply(this, arguments);
115
+ }
116
+ function _onBlur2() {
117
+ _onBlur2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
118
+ var trimValue;
119
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
120
+ while (1) switch (_context2.prev = _context2.next) {
121
+ case 0:
122
+ if (!(!allowTrim || !value)) {
123
+ _context2.next = 2;
124
+ break;
125
+ }
126
+ return _context2.abrupt("return");
127
+ case 2:
128
+ trimValue = _.trim("".concat(value));
129
+ onChange === null || onChange === void 0 || onChange(trimValue);
130
+ _.set(event, 'target.value', trimValue);
131
+ case 5:
132
+ case "end":
133
+ return _context2.stop();
134
+ }
135
+ }, _callee2);
136
+ }));
137
+ return _onBlur2.apply(this, arguments);
138
+ }
139
+ return onBlur;
102
140
  }
@@ -32,6 +32,11 @@ export interface InputProps extends Omit<UnionType, 'form' | 'onChange'> {
32
32
  * @default false
33
33
  */
34
34
  allowResetOnEmpty?: boolean;
35
+ /**
36
+ * @description 是否 trim 输入框前后空格
37
+ * @default false
38
+ */
39
+ allowTrim?: boolean;
35
40
  /**
36
41
  * @description 输入框值改变的回调
37
42
  */
@@ -25,7 +25,9 @@ export function openConfirm(_ref) {
25
25
  style: {
26
26
  display: showCancel ? 'unset' : 'none'
27
27
  }
28
- }
28
+ },
29
+ okText: '确定',
30
+ cancelText: '取消'
29
31
  }, props);
30
32
  return new Promise(function (resolve) {
31
33
  Modal.confirm(_objectSpread(_objectSpread({}, mergedProps), {}, {
@@ -56,7 +56,7 @@ export interface OpenModalProps extends AntdComponentProps {
56
56
  */
57
57
  onOk?(values: FormValues, form: FormInstance): FunctionReturn<boolean | void>;
58
58
  /**
59
- * @description 关闭弹框时的回调
59
+ * @description 关闭弹窗时的回调
60
60
  */
61
61
  unmount?: () => void;
62
62
  }
@@ -5,7 +5,7 @@ import { CheckboxChangeEvent } from 'antd/lib/checkbox/Checkbox';
5
5
  export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGroup, ...props }: BaseBoxProps): {
6
6
  highlightTextProps: Partial<BaseBoxProps>;
7
7
  tooltipProps: {
8
- title?: import("react").ReactNode | import("antd/lib/tooltip").RenderFunction;
8
+ title: import("react").ReactNode | import("antd/lib/tooltip").RenderFunction;
9
9
  overlay?: import("react").ReactNode | import("antd/lib/tooltip").RenderFunction;
10
10
  style?: import("react").CSSProperties | undefined;
11
11
  className?: string | undefined;
@@ -29,12 +29,12 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
29
29
  animation?: string | undefined;
30
30
  motion?: import("rc-motion").CSSMotionProps | undefined;
31
31
  id?: string | undefined;
32
+ prefixCls?: string | undefined;
32
33
  onPopupAlign?: ((element: HTMLElement, align: import("rc-trigger/lib/interface").AlignType) => void) | undefined;
33
34
  trigger?: string | string[] | undefined;
34
35
  transitionName?: string | undefined;
35
36
  overlayStyle?: import("react").CSSProperties | undefined;
36
37
  overlayClassName?: string | undefined;
37
- prefixCls?: string | undefined;
38
38
  mouseEnterDelay?: number | undefined;
39
39
  mouseLeaveDelay?: number | undefined;
40
40
  getTooltipContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
@@ -47,7 +47,7 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
47
47
  popupVisible?: boolean | undefined;
48
48
  overlayInnerStyle?: import("react").CSSProperties | undefined;
49
49
  } | {
50
- title: import("react").ReactNode | import("antd/lib/tooltip").RenderFunction;
50
+ title?: import("react").ReactNode | import("antd/lib/tooltip").RenderFunction;
51
51
  overlay?: import("react").ReactNode | import("antd/lib/tooltip").RenderFunction;
52
52
  style?: import("react").CSSProperties | undefined;
53
53
  className?: string | undefined;
@@ -71,12 +71,12 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
71
71
  animation?: string | undefined;
72
72
  motion?: import("rc-motion").CSSMotionProps | undefined;
73
73
  id?: string | undefined;
74
+ prefixCls?: string | undefined;
74
75
  onPopupAlign?: ((element: HTMLElement, align: import("rc-trigger/lib/interface").AlignType) => void) | undefined;
75
76
  trigger?: string | string[] | undefined;
76
77
  transitionName?: string | undefined;
77
78
  overlayStyle?: import("react").CSSProperties | undefined;
78
79
  overlayClassName?: string | undefined;
79
- prefixCls?: string | undefined;
80
80
  mouseEnterDelay?: number | undefined;
81
81
  mouseLeaveDelay?: number | undefined;
82
82
  getTooltipContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
@@ -100,19 +100,19 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
100
100
  style?: import("react").CSSProperties | undefined;
101
101
  type?: string | undefined;
102
102
  className?: string | undefined;
103
+ onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
103
104
  defaultChecked?: boolean | undefined;
104
105
  autoFocus?: boolean | undefined;
105
106
  id?: string | undefined;
106
107
  tabIndex?: number | undefined;
107
108
  onKeyDown?: import("react").KeyboardEventHandler<HTMLElement> | undefined;
108
109
  onKeyPress?: import("react").KeyboardEventHandler<HTMLElement> | undefined;
109
- onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
110
110
  onMouseEnter?: import("react").MouseEventHandler<HTMLElement> | undefined;
111
111
  onMouseLeave?: import("react").MouseEventHandler<HTMLElement> | undefined;
112
+ disabled?: boolean | undefined;
112
113
  name?: string | undefined;
113
114
  prefixCls?: string | undefined;
114
115
  checked?: boolean | undefined;
115
- disabled?: boolean | undefined;
116
116
  indeterminate?: boolean | undefined;
117
117
  skipGroup?: boolean | undefined;
118
118
  rows?: number | false | undefined;
@@ -121,17 +121,17 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
121
121
  slot?: string | undefined;
122
122
  title?: string | undefined;
123
123
  accessKey?: string | undefined;
124
- dir?: string | undefined;
125
124
  color?: string | undefined;
126
125
  content?: string | undefined;
127
126
  direction?: import("antd/lib/config-provider").DirectionType;
128
- translate?: "no" | "yes" | undefined;
127
+ translate?: "yes" | "no" | undefined;
129
128
  defaultValue?: string | number | readonly string[] | undefined;
130
129
  suppressContentEditableWarning?: boolean | undefined;
131
130
  suppressHydrationWarning?: boolean | undefined;
132
- autoCapitalize?: (string & {}) | "none" | "off" | "on" | "sentences" | "words" | "characters" | undefined;
133
- contentEditable?: "inherit" | (boolean | "true" | "false") | undefined;
131
+ autoCapitalize?: "none" | (string & {}) | "off" | "on" | "sentences" | "words" | "characters" | undefined;
132
+ contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
134
133
  contextMenu?: string | undefined;
134
+ dir?: string | undefined;
135
135
  draggable?: (boolean | "true" | "false") | undefined;
136
136
  enterKeyHint?: "search" | "done" | "enter" | "go" | "next" | "previous" | "send" | undefined;
137
137
  hidden?: boolean | undefined;
@@ -161,7 +161,7 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
161
161
  results?: number | undefined;
162
162
  security?: string | undefined;
163
163
  unselectable?: "off" | "on" | undefined;
164
- inputMode?: "search" | "text" | "none" | "email" | "tel" | "url" | "numeric" | "decimal" | undefined;
164
+ inputMode?: "search" | "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
165
165
  is?: string | undefined;
166
166
  "aria-activedescendant"?: string | undefined;
167
167
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
@@ -172,16 +172,16 @@ export declare function useAbstractBox({ refs, boxTooltip, value, onChange, inGr
172
172
  "aria-colindex"?: number | undefined;
173
173
  "aria-colspan"?: number | undefined;
174
174
  "aria-controls"?: string | undefined;
175
- "aria-current"?: boolean | "time" | "page" | "date" | "true" | "false" | "step" | "location" | undefined;
175
+ "aria-current"?: boolean | "time" | "page" | "true" | "false" | "step" | "location" | "date" | undefined;
176
176
  "aria-describedby"?: string | undefined;
177
177
  "aria-details"?: string | undefined;
178
178
  "aria-disabled"?: (boolean | "true" | "false") | undefined;
179
- "aria-dropeffect"?: "link" | "none" | "copy" | "execute" | "move" | "popup" | undefined;
179
+ "aria-dropeffect"?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
180
180
  "aria-errormessage"?: string | undefined;
181
181
  "aria-expanded"?: (boolean | "true" | "false") | undefined;
182
182
  "aria-flowto"?: string | undefined;
183
183
  "aria-grabbed"?: (boolean | "true" | "false") | undefined;
184
- "aria-haspopup"?: boolean | "dialog" | "menu" | "grid" | "listbox" | "tree" | "true" | "false" | undefined;
184
+ "aria-haspopup"?: boolean | "dialog" | "menu" | "grid" | "true" | "false" | "listbox" | "tree" | undefined;
185
185
  "aria-hidden"?: (boolean | "true" | "false") | undefined;
186
186
  "aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
187
187
  "aria-keyshortcuts"?: string | undefined;
@@ -80,7 +80,7 @@ export function useSelect(_ref3) {
80
80
  _ref3$showSearch = _ref3.showSearch,
81
81
  showSearch = _ref3$showSearch === void 0 ? true : _ref3$showSearch,
82
82
  _ref3$placeholder = _ref3.placeholder,
83
- placeholder = _ref3$placeholder === void 0 ? 'Select' : _ref3$placeholder,
83
+ placeholder = _ref3$placeholder === void 0 ? '请选择' : _ref3$placeholder,
84
84
  renderDropdown = _ref3.renderDropdown,
85
85
  originalSearch = _ref3.search,
86
86
  restProps = _objectWithoutProperties(_ref3, _excluded);
@@ -22,7 +22,7 @@ export declare const componentMap: {
22
22
  export declare function generateColumns({ columns, getSearchColumn }: GenerateColumnsProps): {
23
23
  render: (current: any, record: Record<string, any>, index: number) => import("react").ReactNode;
24
24
  dataIndex?: string | undefined;
25
- type?: "link" | "time" | "switch" | "actions" | "selection" | "editor" | undefined;
25
+ type?: "link" | "switch" | "time" | "actions" | "selection" | "editor" | undefined;
26
26
  width?: string | number | undefined;
27
27
  minWidth?: string | number | undefined;
28
28
  maxWidth?: string | number | undefined;
@@ -41,14 +41,14 @@ export declare function generateColumns({ columns, getSearchColumn }: GenerateCo
41
41
  filterBy?: string[] | ((props: import("../type").CustomFilterProps) => boolean) | undefined;
42
42
  actions?: import("../type").ActionProps[] | ((props: import("../type").CommonProps) => import("../type").ActionProps[]) | undefined;
43
43
  editorProps?: import("../../form").FormItemProps | ((props: import("../type").CommonProps) => import("../../form").FormItemProps) | undefined;
44
- title?: import("antd/lib/table/interface").ColumnTitle<any>;
45
- key?: import("react").Key | undefined;
46
44
  className?: string | undefined;
47
- fixed?: import("rc-table/lib/interface").FixedType | undefined;
45
+ title?: import("antd/lib/table/interface").ColumnTitle<any>;
46
+ responsive?: import("antd/lib/_util/responsiveObserve").Breakpoint[] | undefined;
48
47
  align?: import("rc-table/lib/interface").AlignType | undefined;
48
+ fixed?: import("rc-table/lib/interface").FixedType | undefined;
49
49
  colSpan?: number | undefined;
50
50
  rowSpan?: number | undefined;
51
- responsive?: import("antd/lib/_util/responsiveObserve").Breakpoint[] | undefined;
51
+ key?: import("react").Key | undefined;
52
52
  shouldCellUpdate?: ((record: any, prevRecord: any) => boolean) | undefined;
53
53
  onCell?: import("rc-table/lib/interface").GetComponentProps<any> | undefined;
54
54
  onCellClick?: ((record: any, e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
@@ -75,11 +75,11 @@ export declare function generateColumns({ columns, getSearchColumn }: GenerateCo
75
75
  onFilterDropdownVisibleChange?: ((visible: boolean) => void) | undefined;
76
76
  onFilterDropdownOpenChange?: ((open: boolean) => void) | undefined;
77
77
  filterResetToDefaultFilteredValue?: boolean | undefined;
78
- columnWidth?: string | number | undefined;
79
78
  onChange?: ((selectedRowKeys: import("react").Key[], selectedRows: any[], info: {
80
79
  type: import("antd/lib/table/interface").RowSelectMethod;
81
80
  }) => void) | undefined;
82
81
  onSelect?: import("antd/lib/table/interface").SelectionSelectFn<any> | undefined;
82
+ columnWidth?: string | number | undefined;
83
83
  preserveSelectedRowKeys?: boolean | undefined;
84
84
  selectedRowKeys?: import("react").Key[] | undefined;
85
85
  defaultSelectedRowKeys?: import("react").Key[] | undefined;
@@ -27,12 +27,12 @@ export declare function getTooltipProps(props: TooltipProps): {
27
27
  animation?: string | undefined;
28
28
  motion?: import("rc-motion").CSSMotionProps | undefined;
29
29
  id?: string | undefined;
30
+ prefixCls?: string | undefined;
30
31
  onPopupAlign?: ((element: HTMLElement, align: import("rc-trigger/lib/interface").AlignType) => void) | undefined;
31
32
  trigger?: string | string[] | undefined;
32
33
  transitionName?: string | undefined;
33
34
  overlayStyle?: import("react").CSSProperties | undefined;
34
35
  overlayClassName: string;
35
- prefixCls?: string | undefined;
36
36
  mouseEnterDelay?: number | undefined;
37
37
  mouseLeaveDelay?: number | undefined;
38
38
  getTooltipContainer?: ((node: HTMLElement) => HTMLElement) | undefined;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.scriptReg = exports.inputValueReg = void 0;
7
7
  exports.validateScript = validateScript;
8
8
  exports.validateString = validateString;
9
- var inputValueReg = exports.inputValueReg = /^[a-zA-Z0-9_\-\s/.:*{}€,()%$|+#@=><']*$/i;
9
+ var inputValueReg = exports.inputValueReg = /.*/i;
10
10
  var scriptReg = exports.scriptReg = /<[/]*[^/<]*\s*script[\s+]*[^/>]*[/]*>/i;
11
11
  function validateScript(value) {
12
12
  return !value.match(scriptReg);
@@ -16,9 +16,7 @@ function validateScript(value) {
16
16
  * validate data of general String type
17
17
  * letters, numbers, spot, underlines and Spaces
18
18
  */
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
20
  function validateString(value) {
20
- if (!inputValueReg.test(value)) {
21
- return false;
22
- }
23
- return validateScript(value);
21
+ return true;
24
22
  }
@@ -67,9 +67,9 @@ function ButtonWrapper(_ref2) {
67
67
  }
68
68
  if (confirm) {
69
69
  return (0, _jsxRuntime.jsx)(_antd.Popconfirm, {
70
- title: confirmMessage || 'Are you sure?',
70
+ title: confirmMessage || '是否确定?',
71
71
  onConfirm: onClick,
72
- okText: okText || 'OK',
72
+ okText: okText,
73
73
  cancelText: cancelText,
74
74
  placement: props.placement,
75
75
  arrowPointAtCenter: props.arrowPointAtCenter,
@@ -17,7 +17,7 @@ export declare function getFormItemProps(props: any): {
17
17
  openClassName?: string | undefined;
18
18
  arrowPointAtCenter: boolean;
19
19
  autoAdjustOverflow?: boolean | import("antd/lib/tooltip").AdjustOverflow | undefined;
20
- getPopupContainer: typeof import("../../api").getPopupContainer;
20
+ getPopupContainer: (triggerNode: HTMLElement) => HTMLElement;
21
21
  children?: import("react").ReactNode;
22
22
  visible?: boolean | undefined;
23
23
  open?: boolean | undefined;
@@ -27,14 +27,13 @@ export declare function getFormItemProps(props: any): {
27
27
  onOpenChange?: ((visible: boolean) => void) | undefined;
28
28
  afterVisibleChange?: ((visible: boolean) => void) | undefined;
29
29
  afterOpenChange?: ((visible: boolean) => void) | undefined;
30
- zIndex?: number | undefined;
31
- animation?: string | undefined;
32
- motion?: import("rc-motion").CSSMotionProps | undefined;
33
30
  id?: string | undefined;
34
31
  prefixCls?: string | undefined;
35
32
  onPopupAlign?: ((element: HTMLElement, align: import("rc-trigger/lib/interface").AlignType) => void) | undefined;
36
33
  trigger?: string | string[] | undefined;
37
34
  transitionName?: string | undefined;
35
+ animation?: string | undefined;
36
+ motion?: import("rc-motion").CSSMotionProps | undefined;
38
37
  overlayStyle?: import("react").CSSProperties | undefined;
39
38
  overlayClassName: string;
40
39
  mouseEnterDelay?: number | undefined;
@@ -48,6 +47,7 @@ export declare function getFormItemProps(props: any): {
48
47
  arrowContent?: import("react").ReactNode;
49
48
  popupVisible?: boolean | undefined;
50
49
  overlayInnerStyle?: import("react").CSSProperties | undefined;
50
+ zIndex?: number | undefined;
51
51
  icon: import("@emotion/react/jsx-runtime").JSX.Element;
52
52
  } | undefined;
53
53
  initialValue: any;
@@ -64,7 +64,7 @@ function getFormProps(props) {
64
64
  autoComplete: 'off',
65
65
  labelWrap: true,
66
66
  validateMessages: {
67
- required: '${label} is required.'
67
+ required: '请输入${label}'
68
68
  },
69
69
  validateTrigger: ['onChange', 'onBlur'],
70
70
  onFinishFailed: function onFinishFailed(error) {
@@ -176,7 +176,7 @@ function generateRules(_ref2) {
176
176
  });
177
177
  }
178
178
  if (item.requiredInOptions) {
179
- var _message = _lodash.default.isString(item.requiredInOptions) ? item.requiredInOptions : 'The value does not exist.';
179
+ var _message = _lodash.default.isString(item.requiredInOptions) ? item.requiredInOptions : '该值不存在';
180
180
  var validator = function validator(_ref3) {
181
181
  var _form$getItems;
182
182
  var value = _ref3.value;
@@ -226,7 +226,7 @@ function generateRequiredMessage(item) {
226
226
  return item.required;
227
227
  }
228
228
  if (!item.label) {
229
- return 'The value is required.';
229
+ return '必填项';
230
230
  }
231
231
  }
232
232
  function isValueNotExistInOptions(value, options) {
@@ -100,6 +100,7 @@ export interface FormItemProps extends UnionType {
100
100
  formListContext?: FormListContext;
101
101
  dependencies?: string[];
102
102
  removeErrorOnBlur?: boolean;
103
+ onBlur?(event: any): void;
103
104
  __noCollectState__?: boolean;
104
105
  }
105
106
  export interface FormItemContext extends Pick<FormItemPropsWithType, 'type' | 'optionDependencies' | 'loading' | 'rules' | 'formListContext'> {
@@ -24,7 +24,7 @@ function Input(_ref) {
24
24
  var _ref$type = _ref.type,
25
25
  type = _ref$type === void 0 ? 'input' : _ref$type,
26
26
  _ref$placeholder = _ref.placeholder,
27
- placeholder = _ref$placeholder === void 0 ? 'Input' : _ref$placeholder,
27
+ placeholder = _ref$placeholder === void 0 ? '请输入' : _ref$placeholder,
28
28
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
29
29
  var Component = inputMap[type];
30
30
  return (0, _jsxRuntime.jsx)(Component, (0, _objectSpread2.default)({
@@ -1,15 +1,17 @@
1
1
  import { validateScript, validateString } from "../../api";
2
2
  import { InputProps } from "..";
3
+ import { FocusEvent } from 'react';
3
4
  export declare const validateTypeMap: {
4
5
  default: typeof validateString;
5
6
  script: typeof validateScript;
6
7
  };
7
8
  export declare function validateInput(value: string, validate?: InputProps['validate']): boolean;
8
9
  export declare function validateEnter(value: any, allowEnter: boolean): boolean;
9
- export declare function useInputValidate({ value, onChange, onBlur, validate, refs, allowEnter, allowResetOnEmpty, ...props }: InputProps): any;
10
+ export declare function useInputValidate({ value, onChange, onBlur, validate, refs, allowEnter, allowResetOnEmpty, allowTrim, ...props }: InputProps): any;
10
11
  export declare function formatNumber(value: number, precision: number): number;
11
12
  interface ResetOnEmptyProps extends InputProps {
12
13
  validate?: (value: string | number) => boolean;
13
14
  }
14
15
  export declare function useResetOnEmpty({ name, allowResetOnEmpty, validate }: ResetOnEmptyProps): () => Promise<void>;
16
+ export declare function useTrim({ value, onChange, allowTrim }: InputProps): (event: FocusEvent<HTMLInputElement>) => Promise<void>;
15
17
  export {};
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.formatNumber = formatNumber;
8
8
  exports.useInputValidate = useInputValidate;
9
9
  exports.useResetOnEmpty = useResetOnEmpty;
10
+ exports.useTrim = useTrim;
10
11
  exports.validateEnter = validateEnter;
11
12
  exports.validateInput = validateInput;
12
13
  exports.validateTypeMap = void 0;
@@ -19,7 +20,7 @@ var _form = require("../../form");
19
20
  var _utils = require("../../form/component/utils");
20
21
  var _delay = _interopRequireDefault(require("delay"));
21
22
  var _lodash = _interopRequireDefault(require("lodash"));
22
- var _excluded = ["value", "onChange", "onBlur", "validate", "refs", "allowEnter", "allowResetOnEmpty"];
23
+ var _excluded = ["value", "onChange", "onBlur", "validate", "refs", "allowEnter", "allowResetOnEmpty", "allowTrim"];
23
24
  var validateTypeMap = exports.validateTypeMap = {
24
25
  default: _api.validateString,
25
26
  script: _api.validateScript
@@ -47,6 +48,7 @@ function useInputValidate(_ref) {
47
48
  _ref$allowEnter = _ref.allowEnter,
48
49
  allowEnter = _ref$allowEnter === void 0 ? true : _ref$allowEnter,
49
50
  allowResetOnEmpty = _ref.allowResetOnEmpty,
51
+ allowTrim = _ref.allowTrim,
50
52
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
51
53
  var resetOnEmpty = useResetOnEmpty((0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
52
54
  allowResetOnEmpty: allowResetOnEmpty,
@@ -54,6 +56,11 @@ function useInputValidate(_ref) {
54
56
  return !value;
55
57
  }
56
58
  }));
59
+ var trim = useTrim({
60
+ value: value,
61
+ onChange: onChange,
62
+ allowTrim: allowTrim
63
+ });
57
64
  var handleChange = function handleChange(e) {
58
65
  var value = e.target.value;
59
66
  if (validateInput(value, validate) && validateEnter(value, allowEnter)) {
@@ -67,7 +74,7 @@ function useInputValidate(_ref) {
67
74
  autoComplete: 'off',
68
75
  value: _lodash.default.isNil(value) ? '' : value,
69
76
  onChange: handleChange,
70
- onBlur: (0, _api.mergeFunction)(onBlur, resetOnEmpty)
77
+ onBlur: (0, _api.mergeFunction)(trim, resetOnEmpty, onBlur)
71
78
  });
72
79
  }
73
80
  function formatNumber(value, precision) {
@@ -111,4 +118,36 @@ function useResetOnEmpty(_ref2) {
111
118
  return _onBlur.apply(this, arguments);
112
119
  }
113
120
  return onBlur;
121
+ }
122
+ function useTrim(_ref3) {
123
+ var value = _ref3.value,
124
+ onChange = _ref3.onChange,
125
+ allowTrim = _ref3.allowTrim;
126
+ function onBlur(_x) {
127
+ return _onBlur2.apply(this, arguments);
128
+ }
129
+ function _onBlur2() {
130
+ _onBlur2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(event) {
131
+ var trimValue;
132
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
133
+ while (1) switch (_context2.prev = _context2.next) {
134
+ case 0:
135
+ if (!(!allowTrim || !value)) {
136
+ _context2.next = 2;
137
+ break;
138
+ }
139
+ return _context2.abrupt("return");
140
+ case 2:
141
+ trimValue = _lodash.default.trim("".concat(value));
142
+ onChange === null || onChange === void 0 || onChange(trimValue);
143
+ _lodash.default.set(event, 'target.value', trimValue);
144
+ case 5:
145
+ case "end":
146
+ return _context2.stop();
147
+ }
148
+ }, _callee2);
149
+ }));
150
+ return _onBlur2.apply(this, arguments);
151
+ }
152
+ return onBlur;
114
153
  }
@@ -32,6 +32,11 @@ export interface InputProps extends Omit<UnionType, 'form' | 'onChange'> {
32
32
  * @default false
33
33
  */
34
34
  allowResetOnEmpty?: boolean;
35
+ /**
36
+ * @description 是否 trim 输入框前后空格
37
+ * @default false
38
+ */
39
+ allowTrim?: boolean;
35
40
  /**
36
41
  * @description 输入框值改变的回调
37
42
  */
@@ -50,7 +50,9 @@ function openConfirm(_ref) {
50
50
  style: {
51
51
  display: showCancel ? 'unset' : 'none'
52
52
  }
53
- }
53
+ },
54
+ okText: '确定',
55
+ cancelText: '取消'
54
56
  }, props);
55
57
  return new Promise(function (resolve) {
56
58
  _antd.Modal.confirm((0, _objectSpread2.default)((0, _objectSpread2.default)({}, mergedProps), {}, {
@@ -56,7 +56,7 @@ export interface OpenModalProps extends AntdComponentProps {
56
56
  */
57
57
  onOk?(values: FormValues, form: FormInstance): FunctionReturn<boolean | void>;
58
58
  /**
59
- * @description 关闭弹框时的回调
59
+ * @description 关闭弹窗时的回调
60
60
  */
61
61
  unmount?: () => void;
62
62
  }
@@ -87,7 +87,7 @@ function useSelect(_ref3) {
87
87
  _ref3$showSearch = _ref3.showSearch,
88
88
  showSearch = _ref3$showSearch === void 0 ? true : _ref3$showSearch,
89
89
  _ref3$placeholder = _ref3.placeholder,
90
- placeholder = _ref3$placeholder === void 0 ? 'Select' : _ref3$placeholder,
90
+ placeholder = _ref3$placeholder === void 0 ? '请选择' : _ref3$placeholder,
91
91
  renderDropdown = _ref3.renderDropdown,
92
92
  originalSearch = _ref3.search,
93
93
  restProps = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
@@ -22,7 +22,7 @@ export declare const componentMap: {
22
22
  export declare function generateColumns({ columns, getSearchColumn }: GenerateColumnsProps): {
23
23
  render: (current: any, record: Record<string, any>, index: number) => import("react").ReactNode;
24
24
  dataIndex?: string | undefined;
25
- type?: "link" | "time" | "switch" | "actions" | "selection" | "editor" | undefined;
25
+ type?: "link" | "switch" | "time" | "actions" | "selection" | "editor" | undefined;
26
26
  width?: string | number | undefined;
27
27
  minWidth?: string | number | undefined;
28
28
  maxWidth?: string | number | undefined;
@@ -41,14 +41,14 @@ export declare function generateColumns({ columns, getSearchColumn }: GenerateCo
41
41
  filterBy?: string[] | ((props: import("../type").CustomFilterProps) => boolean) | undefined;
42
42
  actions?: import("../type").ActionProps[] | ((props: import("../type").CommonProps) => import("../type").ActionProps[]) | undefined;
43
43
  editorProps?: import("../../form").FormItemProps | ((props: import("../type").CommonProps) => import("../../form").FormItemProps) | undefined;
44
- title?: import("antd/lib/table/interface").ColumnTitle<any>;
45
- key?: import("react").Key | undefined;
46
44
  className?: string | undefined;
47
- fixed?: import("rc-table/lib/interface").FixedType | undefined;
45
+ title?: import("antd/lib/table/interface").ColumnTitle<any>;
46
+ responsive?: import("antd/lib/_util/responsiveObserve").Breakpoint[] | undefined;
48
47
  align?: import("rc-table/lib/interface").AlignType | undefined;
48
+ fixed?: import("rc-table/lib/interface").FixedType | undefined;
49
49
  colSpan?: number | undefined;
50
50
  rowSpan?: number | undefined;
51
- responsive?: import("antd/lib/_util/responsiveObserve").Breakpoint[] | undefined;
51
+ key?: import("react").Key | undefined;
52
52
  shouldCellUpdate?: ((record: any, prevRecord: any) => boolean) | undefined;
53
53
  onCell?: import("rc-table/lib/interface").GetComponentProps<any> | undefined;
54
54
  onCellClick?: ((record: any, e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
@@ -75,11 +75,11 @@ export declare function generateColumns({ columns, getSearchColumn }: GenerateCo
75
75
  onFilterDropdownVisibleChange?: ((visible: boolean) => void) | undefined;
76
76
  onFilterDropdownOpenChange?: ((open: boolean) => void) | undefined;
77
77
  filterResetToDefaultFilteredValue?: boolean | undefined;
78
- columnWidth?: string | number | undefined;
79
78
  onChange?: ((selectedRowKeys: import("react").Key[], selectedRows: any[], info: {
80
79
  type: import("antd/lib/table/interface").RowSelectMethod;
81
80
  }) => void) | undefined;
82
81
  onSelect?: import("antd/lib/table/interface").SelectionSelectFn<any> | undefined;
82
+ columnWidth?: string | number | undefined;
83
83
  preserveSelectedRowKeys?: boolean | undefined;
84
84
  selectedRowKeys?: import("react").Key[] | undefined;
85
85
  defaultSelectedRowKeys?: import("react").Key[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doui-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A React UI library based on Ant Design",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -137,7 +137,7 @@
137
137
  "typescript": "^5"
138
138
  },
139
139
  "peerDependencies": {
140
- "antd": "~4",
140
+ "antd": "^4",
141
141
  "react": ">=16.9.0",
142
142
  "react-dom": ">=16.9.0"
143
143
  },