foxit-component 0.0.1-alpha.5 → 0.0.1-alpha.8

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.
Files changed (49) hide show
  1. package/es/Button/Button.d.ts +2 -1
  2. package/es/Button/Button.js +4 -4
  3. package/es/Checkbox/Checkbox.d.ts +10 -2
  4. package/es/Checkbox/Checkbox.js +35 -5
  5. package/es/Empty/Empty.js +0 -1
  6. package/es/Form/Form.js +0 -1
  7. package/es/Form/FormItem.js +0 -1
  8. package/es/Form/FormProvider.js +95 -107
  9. package/es/Input/Input.js +3 -3
  10. package/es/Menu/Menu.js +0 -1
  11. package/es/Modal/Modal.js +95 -11
  12. package/es/Modal/ModalTemp.js +4 -1
  13. package/es/Pagination/Pagination.d.ts +1 -0
  14. package/es/Pagination/Pagination.js +19 -11
  15. package/es/Radio/Radio.js +0 -1
  16. package/es/Select/Select.d.ts +9 -0
  17. package/es/Select/Select.js +24 -10
  18. package/es/Switch/Switch.d.ts +9 -0
  19. package/es/Switch/Switch.js +20 -0
  20. package/es/Table/Table.d.ts +3 -1
  21. package/es/Table/Table.js +12 -8
  22. package/es/Tabs/Tabs.js +0 -1
  23. package/es/Tag/Tag.d.ts +1 -1
  24. package/es/Tag/Tag.js +1 -2
  25. package/es/Toast/Toast.js +0 -1
  26. package/es/Toast/ToastContainer.js +0 -1
  27. package/es/Tooltip/Tooltip.js +0 -1
  28. package/es/constants/icons.d.ts +1 -0
  29. package/es/constants/icons.js +1 -0
  30. package/es/index.css +1 -0
  31. package/es/index.d.ts +1 -0
  32. package/es/index.js +1 -0
  33. package/es/node_modules/tslib/tslib.es6.js +39 -1
  34. package/package.json +1 -1
  35. package/es/Button/button.css.js +0 -6
  36. package/es/Checkbox/checkbox.css.js +0 -6
  37. package/es/Empty/empty.css.js +0 -6
  38. package/es/Form/form.css.js +0 -6
  39. package/es/Input/input.css.js +0 -6
  40. package/es/Menu/menu.css.js +0 -6
  41. package/es/Modal/modal.css.js +0 -6
  42. package/es/Pagination/pagination.css.js +0 -6
  43. package/es/Radio/radio.css.js +0 -6
  44. package/es/Table/table.css.js +0 -6
  45. package/es/Tabs/tabs.css.js +0 -6
  46. package/es/Tag/tag.css.js +0 -6
  47. package/es/Toast/toast.css.js +0 -6
  48. package/es/Tooltip/tooltip.css.js +0 -6
  49. package/es/node_modules/style-inject/dist/style-inject.es.js +0 -28
@@ -8,5 +8,6 @@ export interface ButtonProps {
8
8
  className?: string;
9
9
  style?: React.CSSProperties;
10
10
  [key: string]: unknown;
11
+ loading?: boolean;
11
12
  }
12
- export declare const Button: ({ primary, size, children, className, style, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const Button: ({ primary, size, children, className, style, loading, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,12 @@
1
1
  import { __rest, __assign } from '../node_modules/tslib/tslib.es6.js';
2
- import { jsx } from 'react/jsx-runtime';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import classNames from 'classnames';
4
- import './button.css.js';
4
+ import { Icon } from '../Icon/index.js';
5
5
 
6
6
  var Button = function (_a) {
7
- var _b = _a.primary, primary = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'large' : _c, _d = _a.children, children = _d === void 0 ? '' : _d, className = _a.className, style = _a.style, props = __rest(_a, ["primary", "size", "children", "className", "style"]);
7
+ var _b = _a.primary, primary = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'large' : _c, _d = _a.children, children = _d === void 0 ? '' : _d, className = _a.className, style = _a.style, loading = _a.loading, props = __rest(_a, ["primary", "size", "children", "className", "style", "loading"]);
8
8
  var mode = primary ? 'foxit-button-primary' : 'foxit-button-secondary';
9
- return (jsx("button", __assign({ type: "button", className: classNames('foxit-button', "foxit-button-".concat(size), mode, className), style: style }, props, { children: children })));
9
+ return (jsxs("button", __assign({ type: "button", className: classNames('foxit-button', "foxit-button-".concat(size), mode, className), style: style }, props, { children: [loading && jsx(Icon, { name: "LoadingOutlined", className: "foxit-button-loading" }), children] })));
10
10
  };
11
11
 
12
12
  export { Button };
@@ -1,10 +1,18 @@
1
- import React from 'react';
1
+ import React, { FC } from 'react';
2
2
  import './checkbox.css';
3
3
  interface CheckboxProps {
4
4
  onChange?: (checked: boolean) => void;
5
5
  checked?: boolean;
6
6
  disabled?: boolean;
7
+ value?: string;
7
8
  children: React.ReactNode;
8
9
  }
9
- declare const Checkbox: React.FC<CheckboxProps>;
10
+ interface CheckboxGroupProps {
11
+ value?: string[];
12
+ onChange?: (checkedValues: string[]) => void;
13
+ children: React.ReactNode;
14
+ }
15
+ declare const Checkbox: React.FC<CheckboxProps> & {
16
+ Group: FC<CheckboxGroupProps>;
17
+ };
10
18
  export default Checkbox;
@@ -1,19 +1,49 @@
1
- import { __assign } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __assign, __spreadArray } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useState } from 'react';
4
- import './checkbox.css.js';
3
+ import { createContext, useContext, useState, useEffect } from 'react';
5
4
 
5
+ var CheckboxGroupContext = createContext(null);
6
6
  var Checkbox = function (_a) {
7
- var onChange = _a.onChange, checked = _a.checked, _b = _a.disabled, disabled = _b === void 0 ? false : _b, children = _a.children;
7
+ var onChange = _a.onChange, checked = _a.checked, _b = _a.disabled, disabled = _b === void 0 ? false : _b, value = _a.value, children = _a.children;
8
+ var groupContext = useContext(CheckboxGroupContext);
8
9
  var _c = useState(checked || false), internalChecked = _c[0], setInternalChecked = _c[1];
10
+ useEffect(function () {
11
+ if (checked !== undefined) {
12
+ setInternalChecked(checked);
13
+ }
14
+ }, [checked]);
9
15
  var handleChange = function (e) {
10
16
  var newChecked = e.target.checked;
11
17
  setInternalChecked(newChecked);
12
18
  if (onChange) {
13
19
  onChange(newChecked);
14
20
  }
21
+ if (groupContext && value) {
22
+ groupContext.onChange(value, newChecked);
23
+ }
24
+ };
25
+ var isChecked = groupContext ? groupContext.value.includes(value || '') : internalChecked;
26
+ return (jsxs("label", __assign({ className: "foxit-checkbox-container ".concat(disabled ? 'disabled' : '') }, { children: [jsx("input", { type: "checkbox", checked: isChecked, disabled: disabled, onChange: handleChange }), jsx("span", { className: "foxit-checkbox-checkmark ".concat(disabled ? 'disabled' : '') }), jsx("span", __assign({ className: "foxit-checkbox-content" }, { children: children }))] })));
27
+ };
28
+ var CheckboxGroup = function (_a) {
29
+ var value = _a.value, onChange = _a.onChange, children = _a.children;
30
+ var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
31
+ useEffect(function () {
32
+ if (value !== undefined) {
33
+ setCheckedValues(value);
34
+ }
35
+ }, [value]);
36
+ var handleCheckboxChange = function (checkboxValue, checked) {
37
+ var newCheckedValues = checked
38
+ ? __spreadArray(__spreadArray([], checkedValues, true), [checkboxValue], false) : checkedValues.filter(function (v) { return v !== checkboxValue; });
39
+ setCheckedValues(newCheckedValues);
40
+ if (onChange) {
41
+ onChange(newCheckedValues);
42
+ }
15
43
  };
16
- return (jsxs("label", __assign({ className: "foxit-checkbox-container ".concat(disabled ? 'disabled' : '') }, { children: [jsx("input", { type: "checkbox", checked: checked !== undefined ? checked : internalChecked, disabled: disabled, onChange: handleChange }), jsx("span", { className: "foxit-checkbox-checkmark ".concat(disabled ? 'disabled' : '') }), jsx("span", __assign({ className: "foxit-checkbox-content" }, { children: children }))] })));
44
+ var currentValue = value !== undefined ? value : checkedValues;
45
+ return (jsx(CheckboxGroupContext.Provider, __assign({ value: { value: currentValue, onChange: handleCheckboxChange } }, { children: jsx("div", __assign({ className: "foxit-checkbox-group" }, { children: children })) })));
17
46
  };
47
+ Checkbox.Group = CheckboxGroup;
18
48
 
19
49
  export { Checkbox as default };
package/es/Empty/Empty.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { Icon } from '../Icon/index.js';
4
- import './empty.css.js';
5
4
 
6
5
  var Empty = function (_a) {
7
6
  var description = _a.description;
package/es/Form/Form.js CHANGED
@@ -3,7 +3,6 @@ import { jsx } from 'react/jsx-runtime';
3
3
  import { forwardRef, useRef, useCallback, useImperativeHandle } from 'react';
4
4
  import FormProvider from './FormProvider.js';
5
5
  import './FormContext.js';
6
- import './form.css.js';
7
6
 
8
7
  var Form = function (_a, ref) {
9
8
  var children = _a.children, onFinish = _a.onFinish, initialValues = _a.initialValues;
@@ -2,7 +2,6 @@ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import React, { useContext, useEffect, useCallback } from 'react';
4
4
  import { FormContext } from './FormContext.js';
5
- import './form.css.js';
6
5
 
7
6
  var FormItem = function (_a) {
8
7
  var _b, _c, _d;
@@ -1,43 +1,39 @@
1
1
  import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useState, useRef, useEffect, useCallback, useImperativeHandle } from 'react';
3
+ import { forwardRef, useRef, useState, useEffect, useCallback, useImperativeHandle } from 'react';
4
4
  import { FormContext } from './FormContext.js';
5
5
 
6
6
  var FormProvider = function (_a, ref) {
7
7
  var children = _a.children, _b = _a.initialValues, initialValues = _b === void 0 ? {} : _b;
8
- var _c = useState({}), formFields = _c[0], setFormFields = _c[1];
8
+ var formFieldsRef = useRef({});
9
+ var _c = useState({}), forceUpdate = _c[1]; // Used to force re-render when ref changes
9
10
  var formInstanceRef = useRef({});
10
11
  // 初始值的设置
11
12
  useEffect(function () {
12
13
  if (Object.keys(initialValues).length > 0) {
13
- setFormFields(function (prevFields) {
14
- var newFields = __assign({}, prevFields);
15
- for (var key in initialValues) {
16
- if (!newFields[key]) {
17
- newFields[key] = { value: initialValues[key], rules: [] };
18
- }
19
- else {
20
- newFields[key] = __assign(__assign({}, newFields[key]), { value: initialValues[key] });
21
- }
14
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
15
+ for (var key in initialValues) {
16
+ if (!formFieldsRef.current[key]) {
17
+ formFieldsRef.current[key] = { value: initialValues[key], rules: [] };
22
18
  }
23
- return newFields;
24
- });
19
+ else {
20
+ formFieldsRef.current[key] = __assign(__assign({}, formFieldsRef.current[key]), { value: initialValues[key] });
21
+ }
22
+ }
23
+ forceUpdate({}); // Trigger re-render
25
24
  }
26
25
  }, [initialValues]);
27
26
  // 注册字段
28
27
  var registerField = useCallback(function (name, rules) {
29
- setFormFields(function (prevFields) {
30
- var _a;
31
- return (__assign(__assign({}, prevFields), (_a = {}, _a[name] = __assign(__assign({}, prevFields[name]), { rules: rules || [] }), _a)));
32
- });
28
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
29
+ formFieldsRef.current[name] = __assign(__assign({}, formFieldsRef.current[name]), { rules: rules || [] });
30
+ forceUpdate({}); // Trigger re-render
33
31
  }, []);
34
32
  // 销毁字段
35
33
  var unregisterField = useCallback(function (name) {
36
- setFormFields(function (prevFields) {
37
- var newFields = __assign({}, prevFields);
38
- delete newFields[name];
39
- return newFields;
40
- });
34
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
35
+ delete formFieldsRef.current[name];
36
+ forceUpdate({}); // Trigger re-render
41
37
  }, []);
42
38
  // 验证字段
43
39
  var validateField = useCallback(function (name, value, rules) {
@@ -77,78 +73,74 @@ var FormProvider = function (_a, ref) {
77
73
  }, []);
78
74
  // 设置字段值
79
75
  var setFieldsValue = useCallback(function (values) {
80
- setFormFields(function (prevFields) {
81
- var _a;
82
- var newFields = __assign({}, prevFields);
83
- for (var key in values) {
84
- if (Object.prototype.hasOwnProperty.call(values, key)) {
85
- var newValue = values[key];
86
- newFields[key] = __assign(__assign({}, newFields[key]), { value: newValue });
87
- // 验证字段
88
- var validation = validateField(key, newValue, ((_a = newFields[key]) === null || _a === void 0 ? void 0 : _a.rules) || []);
89
- if (validation) {
90
- if (validation.type === 'error') {
91
- newFields[key] = __assign(__assign({}, newFields[key]), { error: validation.message, warning: undefined // Clear any previous warnings
92
- });
93
- }
94
- else if (validation.type === 'warning') {
95
- newFields[key] = __assign(__assign({}, newFields[key]), { warning: validation.message, error: undefined // Clear any previous errors
96
- });
97
- }
76
+ var _a;
77
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
78
+ for (var key in values) {
79
+ if (Object.prototype.hasOwnProperty.call(values, key)) {
80
+ var newValue = values[key];
81
+ formFieldsRef.current[key] = __assign(__assign({}, formFieldsRef.current[key]), { value: newValue });
82
+ // 验证字段
83
+ var validation = validateField(key, newValue, ((_a = formFieldsRef.current[key]) === null || _a === void 0 ? void 0 : _a.rules) || []);
84
+ if (validation) {
85
+ if (validation.type === 'error') {
86
+ formFieldsRef.current[key] = __assign(__assign({}, formFieldsRef.current[key]), { error: validation.message, warning: undefined // Clear any previous warnings
87
+ });
98
88
  }
99
- else {
100
- newFields[key] = __assign(__assign({}, newFields[key]), { error: undefined, warning: undefined });
89
+ else if (validation.type === 'warning') {
90
+ formFieldsRef.current[key] = __assign(__assign({}, formFieldsRef.current[key]), { warning: validation.message, error: undefined // Clear any previous errors
91
+ });
101
92
  }
102
93
  }
94
+ else {
95
+ formFieldsRef.current[key] = __assign(__assign({}, formFieldsRef.current[key]), { error: undefined, warning: undefined });
96
+ }
103
97
  }
104
- return newFields;
105
- });
106
- }, [formFields, validateField]);
98
+ }
99
+ forceUpdate({}); // Trigger re-render
100
+ }, [validateField]);
107
101
  // 获取字段值
108
102
  var getFieldsValue = useCallback(function (names) {
109
103
  if (!names) {
110
- return Object.keys(formFields).reduce(function (acc, key) {
111
- acc[key] = formFields[key].value;
104
+ return Object.keys(formFieldsRef.current).reduce(function (acc, key) {
105
+ acc[key] = formFieldsRef.current[key].value;
112
106
  return acc;
113
107
  }, {});
114
108
  }
115
109
  return names.reduce(function (acc, key) {
116
110
  var _a;
117
- acc[key] = (_a = formFields[key]) === null || _a === void 0 ? void 0 : _a.value;
111
+ acc[key] = (_a = formFieldsRef.current[key]) === null || _a === void 0 ? void 0 : _a.value;
118
112
  return acc;
119
113
  }, {});
120
- }, [formFields]);
114
+ }, []);
121
115
  // 重置字段
122
116
  var resetFields = useCallback(function (names) {
123
- setFormFields(function (prevFields) {
124
- var newFields = __assign({}, prevFields);
125
- if (names) {
126
- names.forEach(function (name) {
127
- if (newFields[name]) {
128
- newFields[name].value = initialValues[name] || '';
129
- newFields[name].error = undefined;
130
- newFields[name].warning = undefined;
131
- }
132
- });
133
- }
134
- else {
135
- Object.keys(newFields).forEach(function (key) {
136
- newFields[key].value = initialValues[key] || '';
137
- newFields[key].error = undefined;
138
- newFields[key].warning = undefined;
139
- });
140
- }
141
- return newFields;
142
- });
143
- }, [formFields, initialValues]);
117
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
118
+ if (names) {
119
+ names.forEach(function (name) {
120
+ if (formFieldsRef.current[name]) {
121
+ formFieldsRef.current[name].value = initialValues[name] || '';
122
+ formFieldsRef.current[name].error = undefined;
123
+ formFieldsRef.current[name].warning = undefined;
124
+ }
125
+ });
126
+ }
127
+ else {
128
+ Object.keys(formFieldsRef.current).forEach(function (key) {
129
+ formFieldsRef.current[key].value = initialValues[key] || '';
130
+ formFieldsRef.current[key].error = undefined;
131
+ formFieldsRef.current[key].warning = undefined;
132
+ });
133
+ }
134
+ forceUpdate({}); // Trigger re-render
135
+ }, [initialValues]);
144
136
  var validateFields = useCallback(function (names) {
145
137
  return new Promise(function (resolve, reject) {
146
- var fieldsToValidate = names || Object.keys(formFields);
138
+ var fieldsToValidate = names || Object.keys(formFieldsRef.current);
147
139
  var values = getFieldsValue(fieldsToValidate);
148
140
  var errors = {};
149
141
  for (var _i = 0, fieldsToValidate_1 = fieldsToValidate; _i < fieldsToValidate_1.length; _i++) {
150
142
  var key = fieldsToValidate_1[_i];
151
- var field = formFields[key];
143
+ var field = formFieldsRef.current[key];
152
144
  if (!field)
153
145
  continue; // Skip if field is not registered
154
146
  var validation = validateField(key, values[key], field.rules || []);
@@ -162,55 +154,49 @@ var FormProvider = function (_a, ref) {
162
154
  }
163
155
  }
164
156
  if (Object.keys(errors).length > 0) {
165
- setFormFields(function (prevFields) {
166
- var newFields = __assign({}, prevFields);
167
- for (var key in errors) {
168
- newFields[key] = __assign(__assign({}, newFields[key]), { error: errors[key] });
169
- }
170
- return newFields;
171
- });
157
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
158
+ for (var key in errors) {
159
+ formFieldsRef.current[key] = __assign(__assign({}, formFieldsRef.current[key]), { error: errors[key] });
160
+ }
161
+ forceUpdate({}); // Trigger re-render
172
162
  reject(errors);
173
163
  }
174
164
  else {
175
165
  resolve(values);
176
166
  }
177
167
  });
178
- }, [formFields, getFieldsValue, validateField]);
168
+ }, [getFieldsValue, validateField]);
179
169
  var setFieldsStatus = useCallback(function (status) {
180
- setFormFields(function (prevFields) {
181
- var newFields = __assign({}, prevFields);
182
- status.forEach(function (_a) {
183
- var type = _a.type, name = _a.name, message = _a.message;
184
- if (Array.isArray(name)) {
185
- name.forEach(function (n) {
186
- if (newFields[n]) {
187
- // Only update if field exists
188
- if (type === 'error') {
189
- newFields[n] = __assign(__assign({}, newFields[n]), { error: message });
190
- }
191
- else if (type === 'warning') {
192
- newFields[n] = __assign(__assign({}, newFields[n]), { warning: message });
193
- }
194
- }
195
- });
196
- }
197
- else {
198
- if (newFields[name]) {
170
+ formFieldsRef.current = __assign({}, formFieldsRef.current); // Create a new object
171
+ status.forEach(function (_a) {
172
+ var type = _a.type, name = _a.name, message = _a.message;
173
+ if (Array.isArray(name)) {
174
+ name.forEach(function (n) {
175
+ if (formFieldsRef.current[n]) {
199
176
  // Only update if field exists
200
177
  if (type === 'error') {
201
- newFields[name] = __assign(__assign({}, newFields[name]), { error: message });
178
+ formFieldsRef.current[n] = __assign(__assign({}, formFieldsRef.current[n]), { error: message });
202
179
  }
203
180
  else if (type === 'warning') {
204
- newFields[name] = __assign(__assign({}, newFields[name]), { warning: message });
181
+ formFieldsRef.current[n] = __assign(__assign({}, formFieldsRef.current[n]), { warning: message });
205
182
  }
206
183
  }
184
+ });
185
+ }
186
+ else {
187
+ if (formFieldsRef.current[name]) {
188
+ // Only update if field exists
189
+ if (type === 'error') {
190
+ formFieldsRef.current[name] = __assign(__assign({}, formFieldsRef.current[name]), { error: message });
191
+ }
192
+ else if (type === 'warning') {
193
+ formFieldsRef.current[name] = __assign(__assign({}, formFieldsRef.current[name]), { warning: message });
194
+ }
207
195
  }
208
- });
209
- return newFields;
196
+ }
210
197
  });
211
- }, [formFields]);
212
- // 暴露给外部的方法
213
- useImperativeHandle(ref, function () { return (__assign({}, formInstanceRef.current)); });
198
+ forceUpdate({}); // Trigger re-render
199
+ }, []);
214
200
  formInstanceRef.current = {
215
201
  setFieldsValue: setFieldsValue,
216
202
  getFieldsValue: getFieldsValue,
@@ -220,7 +206,9 @@ var FormProvider = function (_a, ref) {
220
206
  registerField: registerField,
221
207
  unregisterField: unregisterField
222
208
  };
223
- return (jsx(FormContext.Provider, __assign({ value: { form: formInstanceRef.current, formFields: formFields } }, { children: children })));
209
+ // 暴露给外部的方法
210
+ useImperativeHandle(ref, function () { return (__assign({}, formInstanceRef.current)); });
211
+ return (jsx(FormContext.Provider, __assign({ value: { form: formInstanceRef.current, formFields: formFieldsRef.current } }, { children: children })));
224
212
  };
225
213
  var FormProvider$1 = forwardRef(FormProvider);
226
214
 
package/es/Input/Input.js CHANGED
@@ -2,7 +2,6 @@ import { __rest, __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
4
  import classNames from 'classnames';
5
- import './input.css.js';
6
5
  import { Icon } from '../Icon/index.js';
7
6
 
8
7
  var Input = function (_a) {
@@ -11,12 +10,13 @@ var Input = function (_a) {
11
10
  };
12
11
  var SearchInput = function (_a) {
13
12
  var onSearch = _a.onSearch, rest = __rest(_a, ["onSearch"]);
13
+ var _b = useState(rest.value || ''), value = _b[0], setValue = _b[1];
14
14
  var handleSearch = function () {
15
15
  if (onSearch) {
16
- onSearch(rest.value);
16
+ onSearch(value);
17
17
  }
18
18
  };
19
- return (jsx(Input, __assign({}, rest, { addonAfter: jsx("div", __assign({ style: { display: 'flex' }, onClick: handleSearch }, { children: jsx(Icon, { name: "SearchOutlined" }) })) })));
19
+ return (jsx(Input, __assign({}, rest, { onChange: function (e) { return setValue(e.target.value); }, addonAfter: jsx("div", __assign({ style: { display: 'flex' }, onClick: handleSearch }, { children: jsx(Icon, { name: "SearchOutlined" }) })) })));
20
20
  };
21
21
  var PasswordInput = function (props) {
22
22
  var _a = useState(false), visible = _a[0], setVisible = _a[1];
package/es/Menu/Menu.js CHANGED
@@ -2,7 +2,6 @@ import { __assign, __spreadArray } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
4
  import { Icon } from '../Icon/index.js';
5
- import './menu.css.js';
6
5
 
7
6
  var getItem = function (label, key, icon, children, type) {
8
7
  return {
package/es/Modal/Modal.js CHANGED
@@ -1,17 +1,73 @@
1
- import { __assign } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __assign, __awaiter, __generator } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
3
4
  import { Icon } from '../Icon/index.js';
4
5
  import { createRoot } from 'react-dom/client';
5
6
  import { Modal as Modal$1 } from './ModalTemp.js';
6
7
  import { Button } from '../Button/Button.js';
7
- import './modal.css.js';
8
8
 
9
9
  var ModalContent = function (_a) {
10
10
  var title = _a.title, onCancel = _a.onCancel, _b = _a.onCancelText, onCancelText = _b === void 0 ? undefined : _b, onOk = _a.onOk, _c = _a.onOkText, onOkText = _c === void 0 ? undefined : _c, children = _a.children, _d = _a.width, width = _d === void 0 ? '400px' : _d;
11
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
12
+ var _f = useState(false), cancelLoading = _f[0], setCancelLoading = _f[1];
13
+ var handleOk = function () { return __awaiter(void 0, void 0, void 0, function () {
14
+ var result;
15
+ return __generator(this, function (_a) {
16
+ switch (_a.label) {
17
+ case 0:
18
+ if (!onOk) return [3 /*break*/, 6];
19
+ _a.label = 1;
20
+ case 1:
21
+ _a.trys.push([1, , 5, 6]);
22
+ result = onOk();
23
+ if (!(result instanceof Promise)) return [3 /*break*/, 3];
24
+ setLoading(true);
25
+ return [4 /*yield*/, result];
26
+ case 2:
27
+ _a.sent();
28
+ return [3 /*break*/, 4];
29
+ case 3:
30
+ onOk();
31
+ _a.label = 4;
32
+ case 4: return [3 /*break*/, 6];
33
+ case 5:
34
+ setLoading(false);
35
+ return [7 /*endfinally*/];
36
+ case 6: return [2 /*return*/];
37
+ }
38
+ });
39
+ }); };
40
+ var handleCancel = function () { return __awaiter(void 0, void 0, void 0, function () {
41
+ var result;
42
+ return __generator(this, function (_a) {
43
+ switch (_a.label) {
44
+ case 0:
45
+ if (!onCancel) return [3 /*break*/, 6];
46
+ _a.label = 1;
47
+ case 1:
48
+ _a.trys.push([1, , 5, 6]);
49
+ result = onCancel();
50
+ if (!(result instanceof Promise)) return [3 /*break*/, 3];
51
+ setCancelLoading(true);
52
+ return [4 /*yield*/, result];
53
+ case 2:
54
+ _a.sent();
55
+ return [3 /*break*/, 4];
56
+ case 3:
57
+ onCancel();
58
+ _a.label = 4;
59
+ case 4: return [3 /*break*/, 6];
60
+ case 5:
61
+ setCancelLoading(false);
62
+ return [7 /*endfinally*/];
63
+ case 6: return [2 /*return*/];
64
+ }
65
+ });
66
+ }); };
11
67
  return (jsxs("div", __assign({ className: "foxit-modal-content-container", style: {
12
68
  maxWidth: width,
13
69
  width: width
14
- } }, { children: [jsxs("div", __assign({ className: "foxit-modal-head" }, { children: [jsx("div", __assign({ className: "foxit-modal-title" }, { children: title })), jsx("div", __assign({ onClick: onCancel, className: "foxit-modal-close-button" }, { children: jsx(Icon, { name: "CloseOutlined" }) }))] })), jsx("div", { children: children }), jsxs("div", __assign({ className: "foxit-modal-footer" }, { children: [onCancelText && (jsx(Button, __assign({ size: "medium", onClick: onCancel }, { children: onCancelText }))), onOkText && (jsx(Button, __assign({ primary: true, size: "medium", onClick: onOk }, { children: onOkText })))] }))] })));
70
+ } }, { children: [jsxs("div", __assign({ className: "foxit-modal-head" }, { children: [jsx("div", __assign({ className: "foxit-modal-title" }, { children: title })), jsx("div", __assign({ onClick: onCancel, className: "foxit-modal-close-button" }, { children: jsx(Icon, { name: "CloseOutlined" }) }))] })), jsx("div", { children: children }), jsxs("div", __assign({ className: "foxit-modal-footer" }, { children: [onCancelText && (jsx(Button, __assign({ size: "medium", onClick: handleCancel, loading: cancelLoading }, { children: onCancelText }))), onOkText && (jsx(Button, __assign({ primary: true, size: "medium", onClick: handleOk, loading: loading }, { children: onOkText })))] }))] })));
15
71
  };
16
72
  var Modal = function (_a) {
17
73
  var title = _a.title, opened = _a.opened, onOk = _a.onOk, onOkText = _a.onOkText, onCancel = _a.onCancel, onCancelText = _a.onCancelText, maskClosable = _a.maskClosable, children = _a.children, width = _a.width;
@@ -25,15 +81,43 @@ Modal.confirm = function (_a) {
25
81
  var root = createRoot(modalRoot);
26
82
  var handleClose = function () {
27
83
  root.unmount();
28
- document.body.removeChild(modalRoot);
84
+ if (document.body.contains(modalRoot)) {
85
+ document.body.removeChild(modalRoot);
86
+ }
29
87
  };
30
- root.render(jsx(Modal$1, __assign({ opened: true, onClose: handleClose, maskClosable: maskClosable, position: "top" }, { children: jsx(ModalContent, __assign({ title: title, width: width, onCancel: function () {
31
- onCancel === null || onCancel === void 0 ? void 0 : onCancel();
32
- handleClose();
33
- }, onCancelText: onCancelText, onOk: function () {
34
- onOk === null || onOk === void 0 ? void 0 : onOk();
35
- handleClose();
36
- }, onOkText: onOkText }, { children: content })) })));
88
+ root.render(jsx(Modal$1, __assign({ opened: true, onClose: handleClose, maskClosable: maskClosable, position: "top" }, { children: jsx(ModalContent, __assign({ title: title, width: width, onCancel: onCancel instanceof Function && onCancel.constructor.name === 'AsyncFunction'
89
+ ? function () { return __awaiter(void 0, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0: return [4 /*yield*/, onCancel()];
93
+ case 1:
94
+ _a.sent();
95
+ handleClose();
96
+ return [2 /*return*/];
97
+ }
98
+ });
99
+ }); }
100
+ : function () {
101
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
102
+ handleClose();
103
+ }, onCancelText: onCancelText, onOk:
104
+ // 判断传进来的onOk是否为async函数
105
+ onOk instanceof Function && onOk.constructor.name === 'AsyncFunction'
106
+ ? function () { return __awaiter(void 0, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0: return [4 /*yield*/, onOk()];
110
+ case 1:
111
+ _a.sent();
112
+ handleClose();
113
+ return [2 /*return*/];
114
+ }
115
+ });
116
+ }); }
117
+ : function () {
118
+ onOk === null || onOk === void 0 ? void 0 : onOk();
119
+ handleClose();
120
+ }, onOkText: onOkText }, { children: content })) })));
37
121
  };
38
122
 
39
123
  export { Modal };
@@ -4,7 +4,6 @@ import { useState, useEffect, useRef } from 'react';
4
4
  import { CSSTransition } from 'react-transition-group';
5
5
  import { createPortal } from 'react-dom';
6
6
  import classNames from 'classnames';
7
- import './modal.css.js';
8
7
 
9
8
  var contentAnimation = {
10
9
  enter: 'foxit-modal-opacity-0 foxit-modal-scale-0',
@@ -24,6 +23,10 @@ var Portal = function (_a) {
24
23
  useEffect(function () {
25
24
  var _a, _b;
26
25
  (_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.appendChild) === null || _b === void 0 ? void 0 : _b.call(_a, container);
26
+ return function () {
27
+ var _a, _b;
28
+ (_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.removeChild) === null || _b === void 0 ? void 0 : _b.call(_a, container);
29
+ };
27
30
  }, [container]);
28
31
  return createPortal(children, container);
29
32
  };
@@ -5,6 +5,7 @@ interface PaginationProps {
5
5
  pageSize: number;
6
6
  onChange?: (page: number) => void;
7
7
  defaultCurrent?: number;
8
+ current?: number;
8
9
  }
9
10
  declare const Pagination: React.FC<PaginationProps>;
10
11
  export default Pagination;