foxit-component 0.0.1-alpha.4 → 0.0.1-alpha.40

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 (65) hide show
  1. package/es/Alert/Alert.d.ts +12 -0
  2. package/es/Alert/Alert.js +24 -0
  3. package/es/Button/Button.d.ts +2 -1
  4. package/es/Button/Button.js +4 -4
  5. package/es/Checkbox/Checkbox.d.ts +10 -2
  6. package/es/Checkbox/Checkbox.js +35 -5
  7. package/es/Drawer/Drawer.d.ts +10 -0
  8. package/es/Drawer/Drawer.js +14 -0
  9. package/es/Empty/Empty.js +0 -1
  10. package/es/Form/Form.d.ts +2 -1
  11. package/es/Form/Form.js +3 -3
  12. package/es/Form/Form.types.d.ts +9 -0
  13. package/es/Form/FormItem.d.ts +2 -1
  14. package/es/Form/FormItem.js +3 -4
  15. package/es/Form/FormProvider.js +148 -115
  16. package/es/Form/useFormWatch.d.ts +3 -0
  17. package/es/Form/useFormWatch.js +37 -0
  18. package/es/Input/Input.js +3 -3
  19. package/es/Menu/Menu.d.ts +2 -0
  20. package/es/Menu/Menu.js +128 -11
  21. package/es/Modal/Modal.d.ts +2 -0
  22. package/es/Modal/Modal.js +88 -17
  23. package/es/Modal/ModalTemp.js +4 -1
  24. package/es/Pagination/Pagination.d.ts +2 -0
  25. package/es/Pagination/Pagination.js +25 -12
  26. package/es/Quantity/Quantity.d.ts +10 -0
  27. package/es/Quantity/Quantity.js +45 -0
  28. package/es/Radio/Radio.js +0 -1
  29. package/es/Select/Select.d.ts +10 -0
  30. package/es/Select/Select.js +16 -10
  31. package/es/Spin/Spin.d.ts +10 -0
  32. package/es/Spin/Spin.js +23 -0
  33. package/es/Switch/Switch.d.ts +9 -0
  34. package/es/Switch/Switch.js +20 -0
  35. package/es/Table/Table.d.ts +4 -1
  36. package/es/Table/Table.js +22 -8
  37. package/es/Tabs/Tabs.js +0 -1
  38. package/es/Tag/Tag.d.ts +1 -1
  39. package/es/Tag/Tag.js +1 -2
  40. package/es/Toast/Toast.js +0 -1
  41. package/es/Toast/ToastContainer.js +0 -1
  42. package/es/Tooltip/Tooltip.d.ts +2 -0
  43. package/es/Tooltip/Tooltip.js +56 -19
  44. package/es/constants/icons.d.ts +16 -0
  45. package/es/constants/icons.js +17 -1
  46. package/es/index.css +1 -0
  47. package/es/index.d.ts +7 -2
  48. package/es/index.js +6 -0
  49. package/es/node_modules/tslib/tslib.es6.js +39 -1
  50. package/package.json +3 -3
  51. package/es/Button/button.css.js +0 -6
  52. package/es/Checkbox/checkbox.css.js +0 -6
  53. package/es/Empty/empty.css.js +0 -6
  54. package/es/Form/form.css.js +0 -6
  55. package/es/Input/input.css.js +0 -6
  56. package/es/Menu/menu.css.js +0 -6
  57. package/es/Modal/modal.css.js +0 -6
  58. package/es/Pagination/pagination.css.js +0 -6
  59. package/es/Radio/radio.css.js +0 -6
  60. package/es/Table/table.css.js +0 -6
  61. package/es/Tabs/tabs.css.js +0 -6
  62. package/es/Tag/tag.css.js +0 -6
  63. package/es/Toast/toast.css.js +0 -6
  64. package/es/Tooltip/tooltip.css.js +0 -6
  65. package/es/node_modules/style-inject/dist/style-inject.es.js +0 -28
package/es/Modal/Modal.js CHANGED
@@ -1,39 +1,110 @@
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';
5
+ import classNames from 'classnames';
4
6
  import { createRoot } from 'react-dom/client';
5
7
  import { Modal as Modal$1 } from './ModalTemp.js';
6
8
  import { Button } from '../Button/Button.js';
7
- import './modal.css.js';
8
9
 
9
10
  var ModalContent = function (_a) {
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
- return (jsxs("div", __assign({ className: "foxit-modal-content-container", style: {
12
- maxWidth: width,
11
+ 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, type = _a.type, _e = _a.closable, closable = _e === void 0 ? true : _e;
12
+ var _f = useState(false), loading = _f[0], setLoading = _f[1];
13
+ var _g = useState(false), cancelLoading = _g[0], setCancelLoading = _g[1];
14
+ var handleOk = function () { return __awaiter(void 0, void 0, void 0, function () {
15
+ return __generator(this, function (_a) {
16
+ switch (_a.label) {
17
+ case 0:
18
+ if (!onOk) return [3 /*break*/, 4];
19
+ _a.label = 1;
20
+ case 1:
21
+ _a.trys.push([1, , 3, 4]);
22
+ setLoading(true);
23
+ return [4 /*yield*/, onOk()];
24
+ case 2:
25
+ _a.sent();
26
+ return [3 /*break*/, 4];
27
+ case 3:
28
+ setLoading(false);
29
+ return [7 /*endfinally*/];
30
+ case 4: return [2 /*return*/];
31
+ }
32
+ });
33
+ }); };
34
+ var handleCancel = function () { return __awaiter(void 0, void 0, void 0, function () {
35
+ return __generator(this, function (_a) {
36
+ switch (_a.label) {
37
+ case 0:
38
+ if (!onCancel) return [3 /*break*/, 4];
39
+ _a.label = 1;
40
+ case 1:
41
+ _a.trys.push([1, , 3, 4]);
42
+ setCancelLoading(true);
43
+ return [4 /*yield*/, onCancel()];
44
+ case 2:
45
+ _a.sent();
46
+ return [3 /*break*/, 4];
47
+ case 3:
48
+ setCancelLoading(false);
49
+ return [7 /*endfinally*/];
50
+ case 4: return [2 /*return*/];
51
+ }
52
+ });
53
+ }); };
54
+ return (jsxs("div", __assign({ className: classNames('foxit-modal-content-container', type === 'success' ? 'foxit-modal-success' : ''), style: {
55
+ maxWidth: "min(".concat(width, ", calc(100vw - 32px))"),
13
56
  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 })))] }))] })));
57
+ } }, { children: [jsxs("div", __assign({ className: "foxit-modal-head" }, { children: [jsx("div", __assign({ className: "foxit-modal-title" }, { children: title })), closable && (jsx("div", __assign({ onClick: onCancel, className: type === 'success' ? 'foxit-modal-success-icon' : 'foxit-modal-close-button' }, { children: type === 'success' ? (jsx(Icon, { name: "FireWorkColoursOutlined" })) : (jsx(Icon, { name: "CloseOutlined" })) })))] })), jsx("div", __assign({ className: "foxit-modal-children" }, { 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
58
  };
16
59
  var Modal = function (_a) {
17
- 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;
18
- return (jsx(Modal$1, __assign({ opened: opened, onClose: onCancel || (function () { }), maskClosable: maskClosable, position: "top" }, { children: jsx(ModalContent, __assign({ title: title, width: width, onCancel: onCancel, onCancelText: onCancelText, onOk: onOk, onOkText: onOkText }, { children: children })) })));
60
+ 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, type = _a.type, closable = _a.closable;
61
+ return (jsx(Modal$1, __assign({ opened: opened, onClose: onCancel || (function () { }), maskClosable: maskClosable, position: "top" }, { children: jsx(ModalContent, __assign({ title: title, width: width, onCancel: onCancel, onCancelText: onCancelText, onOk: onOk, onOkText: onOkText, type: type, closable: closable }, { children: children })) })));
19
62
  };
20
63
  // 语法糖的调用方式
21
64
  Modal.confirm = function (_a) {
22
- var title = _a.title, onOk = _a.onOk, onCancel = _a.onCancel, onOkText = _a.onOkText, onCancelText = _a.onCancelText, _b = _a.maskClosable, maskClosable = _b === void 0 ? true : _b, content = _a.content, width = _a.width;
65
+ var title = _a.title, onOk = _a.onOk, onCancel = _a.onCancel, onOkText = _a.onOkText, onCancelText = _a.onCancelText, _b = _a.maskClosable, maskClosable = _b === void 0 ? true : _b, content = _a.content, width = _a.width, closable = _a.closable;
23
66
  var modalRoot = document.createElement('div');
24
67
  document.body.appendChild(modalRoot);
25
68
  var root = createRoot(modalRoot);
26
69
  var handleClose = function () {
27
70
  root.unmount();
28
- document.body.removeChild(modalRoot);
71
+ if (document.body.contains(modalRoot)) {
72
+ document.body.removeChild(modalRoot);
73
+ }
29
74
  };
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 })) })));
75
+ 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'
76
+ ? function () { return __awaiter(void 0, void 0, void 0, function () {
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0: return [4 /*yield*/, onCancel()];
80
+ case 1:
81
+ _a.sent();
82
+ handleClose();
83
+ return [2 /*return*/];
84
+ }
85
+ });
86
+ }); }
87
+ : function () {
88
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
89
+ handleClose();
90
+ }, onCancelText: onCancelText, onOk:
91
+ // 判断传进来的onOk是否为async函数
92
+ onOk instanceof Function && onOk.constructor.name === 'AsyncFunction'
93
+ ? function () { return __awaiter(void 0, void 0, void 0, function () {
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0: return [4 /*yield*/, onOk()];
97
+ case 1:
98
+ _a.sent();
99
+ handleClose();
100
+ return [2 /*return*/];
101
+ }
102
+ });
103
+ }); }
104
+ : function () {
105
+ onOk === null || onOk === void 0 ? void 0 : onOk();
106
+ handleClose();
107
+ }, onOkText: onOkText, closable: closable }, { children: content })) })));
37
108
  };
38
109
 
39
110
  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,8 @@ interface PaginationProps {
5
5
  pageSize: number;
6
6
  onChange?: (page: number) => void;
7
7
  defaultCurrent?: number;
8
+ current?: number;
9
+ mobile?: boolean;
8
10
  }
9
11
  declare const Pagination: React.FC<PaginationProps>;
10
12
  export default Pagination;
@@ -1,15 +1,20 @@
1
1
  import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useEffect } from 'react';
4
- import './pagination.css.js';
4
+ import { Button } from '../Button/Button.js';
5
5
 
6
6
  var $_MORE = 9999999999;
7
7
  var Pagination = function (_a) {
8
- var total = _a.total, pageSize = _a.pageSize, onChange = _a.onChange, _b = _a.defaultCurrent, defaultCurrent = _b === void 0 ? 1 : _b;
9
- var _c = useState(defaultCurrent), current = _c[0], setCurrent = _c[1];
10
- var _d = useState([]), pages = _d[0], setPages = _d[1];
8
+ var total = _a.total, pageSize = _a.pageSize, onChange = _a.onChange, _b = _a.defaultCurrent, defaultCurrent = _b === void 0 ? 1 : _b, currentProp = _a.current, _c = _a.mobile, mobile = _c === void 0 ? false : _c;
9
+ var _d = useState(currentProp !== undefined ? currentProp : defaultCurrent), current = _d[0], setCurrent = _d[1];
10
+ var _e = useState([]), pages = _e[0], setPages = _e[1];
11
11
  var maxButtons = 5;
12
12
  var totalPages = Math.ceil(total / pageSize);
13
+ useEffect(function () {
14
+ if (currentProp !== undefined && currentProp !== current) {
15
+ setCurrent(currentProp);
16
+ }
17
+ }, [currentProp, current]);
13
18
  useEffect(function () {
14
19
  var generatePages = function () {
15
20
  var pageArray = [];
@@ -49,14 +54,16 @@ var Pagination = function (_a) {
49
54
  var handleClick = function (page, index) {
50
55
  if (page === $_MORE) {
51
56
  if (index > 0 && pages[index - 1] !== null && pages[index - 1] !== 1) {
52
- setCurrent(pages[index - 1] + 1);
53
- onChange === null || onChange === void 0 ? void 0 : onChange(pages[index - 1] + 1);
57
+ var newPage = pages[index - 1] + 1;
58
+ setCurrent(newPage);
59
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
54
60
  }
55
61
  else if (index < pages.length - 1 &&
56
62
  pages[index + 1] !== null &&
57
63
  pages[index + 1] !== totalPages) {
58
- setCurrent(pages[index + 1] - 1);
59
- onChange === null || onChange === void 0 ? void 0 : onChange(pages[index + 1] - 1);
64
+ var newPage = pages[index + 1] - 1;
65
+ setCurrent(newPage);
66
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
60
67
  }
61
68
  }
62
69
  else if (page !== current) {
@@ -66,16 +73,22 @@ var Pagination = function (_a) {
66
73
  };
67
74
  var handlePrev = function () {
68
75
  if (current > 1) {
69
- setCurrent(current - 1);
70
- onChange === null || onChange === void 0 ? void 0 : onChange(current - 1);
76
+ var newPage = current - 1;
77
+ setCurrent(newPage);
78
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
71
79
  }
72
80
  };
73
81
  var handleNext = function () {
74
82
  if (current < totalPages) {
75
- setCurrent(current + 1);
76
- onChange === null || onChange === void 0 ? void 0 : onChange(current + 1);
83
+ var newPage = current + 1;
84
+ setCurrent(newPage);
85
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
77
86
  }
78
87
  };
88
+ // 新增:移动端只显示“展开更多”按钮
89
+ if (mobile) {
90
+ return total > pageSize ? (jsxs("div", __assign({ className: "foxit-pagination-mobile-container" }, { children: [jsx(Button, __assign({ className: "foxit-pagination-mobile-prev", onClick: handlePrev, size: "small", disabled: current === 1 }, { children: '<' })), jsxs("span", __assign({ className: "foxit-pagination-mobile-info" }, { children: [current, " / ", totalPages] })), jsx(Button, __assign({ className: "foxit-pagination-mobile-next", onClick: handleNext, size: "small", disabled: current === totalPages }, { children: '>' }))] }))) : null;
91
+ }
79
92
  return total > pageSize ? (jsxs("div", __assign({ className: "foxit-pagination-container" }, { children: [jsx("button", __assign({ className: "foxit-pagination-prev", onClick: handlePrev, disabled: current === 1 }, { children: '<' })), pages.map(function (page, index) { return (jsx("button", __assign({ className: "foxit-pagination-button", onClick: function () { return handleClick(page, index); }, disabled: page === current }, { children: page === $_MORE ? '...' : page }), index)); }), jsx("button", __assign({ className: "foxit-pagination-next", onClick: handleNext, disabled: current === totalPages }, { children: '>' }))] }))) : null;
80
93
  };
81
94
 
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import './quantity.css';
3
+ interface QuantityProps {
4
+ value?: number;
5
+ onChange?: (value: number) => void;
6
+ min?: number;
7
+ max?: number;
8
+ }
9
+ declare const Quantity: React.FC<QuantityProps>;
10
+ export { Quantity };
@@ -0,0 +1,45 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+
5
+ var Quantity = function (_a) {
6
+ var value = _a.value, onChange = _a.onChange, min = _a.min, max = _a.max;
7
+ var _b = useState(value || min || 0), internalValue = _b[0], setInternalValue = _b[1];
8
+ var currentValue = value !== undefined ? value : internalValue;
9
+ var handleIncrement = function () {
10
+ var newValue = currentValue + 1;
11
+ if (max !== undefined && newValue > max)
12
+ return;
13
+ if (onChange) {
14
+ onChange(newValue);
15
+ }
16
+ setInternalValue(newValue);
17
+ };
18
+ var handleDecrement = function () {
19
+ var newValue = currentValue - 1;
20
+ if (min !== undefined && newValue < min)
21
+ return;
22
+ if (onChange) {
23
+ onChange(newValue);
24
+ }
25
+ setInternalValue(newValue);
26
+ };
27
+ var handleChange = function (e) {
28
+ var newValue = parseInt(e.target.value, 10) || 0;
29
+ if (min !== undefined && newValue < min) {
30
+ newValue = min;
31
+ }
32
+ if (max !== undefined && newValue > max) {
33
+ newValue = max;
34
+ }
35
+ if (onChange) {
36
+ onChange(newValue);
37
+ }
38
+ setInternalValue(newValue);
39
+ };
40
+ return (jsxs("div", __assign({ className: "foxit-quantity" }, { children: [jsx("button", __assign({ className: "foxit-quantity-button", onClick: handleDecrement, disabled: min !== undefined && currentValue <= min }, { children: jsx("div", { children: "-" }) })), jsx("input", {
41
+ // type="number"
42
+ value: currentValue, onChange: handleChange, min: min, max: max, className: "foxit-quantity-number" }), jsx("button", __assign({ className: "foxit-quantity-button", onClick: handleIncrement, disabled: max !== undefined && currentValue >= max }, { children: jsx("div", { children: "+" }) }))] })));
43
+ };
44
+
45
+ export { Quantity };
package/es/Radio/Radio.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 { createContext, useContext, useState } from 'react';
4
- import './radio.css.js';
5
4
 
6
5
  var RadioContext = createContext({});
7
6
  var Radio = function (_a) {
@@ -12,6 +12,16 @@ export interface SelectProps {
12
12
  isMulti?: boolean;
13
13
  placeholder?: string;
14
14
  preIcon?: React.ReactNode;
15
+ value?: string | number | CustomOption | null;
16
+ onChange?: (v: unknown) => void;
17
+ [key: string]: unknown;
18
+ }
19
+ interface CustomOption {
20
+ readonly value: string | number;
21
+ readonly label: string;
22
+ readonly color?: string;
23
+ readonly isFixed?: boolean;
24
+ readonly isDisabled?: boolean;
15
25
  }
16
26
  declare const Select: React.FC<SelectProps>;
17
27
  export default Select;
@@ -5,15 +5,18 @@ import classNames from 'classnames';
5
5
  import { Icon } from '../Icon/index.js';
6
6
 
7
7
  var Select = function (_a) {
8
- var options = _a.options, className = _a.className, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, isClearable = _a.isClearable, isSearchable = _a.isSearchable, isMulti = _a.isMulti, _b = _a.placeholder, placeholder = _b === void 0 ? 'Select...' : _b, preIcon = _a.preIcon, rest = __rest(_a, ["options", "className", "defaultValue", "isDisabled", "isClearable", "isSearchable", "isMulti", "placeholder", "preIcon"]);
8
+ var options = _a.options, className = _a.className, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, isClearable = _a.isClearable, isSearchable = _a.isSearchable, isMulti = _a.isMulti, _b = _a.placeholder, placeholder = _b === void 0 ? 'Select...' : _b, preIcon = _a.preIcon, value = _a.value, onChange = _a.onChange, rest = __rest(_a, ["options", "className", "defaultValue", "isDisabled", "isClearable", "isSearchable", "isMulti", "placeholder", "preIcon", "value", "onChange"]);
9
9
  var customStyles = {
10
- control: function (styles) { return (__assign(__assign({}, styles), { backgroundColor: 'white',
11
- // minWidth: 200,
12
- height: 48, borderRadius: 10, fontSize: 14, boxShadow: 'none', border: '1px solid #B3B3B3', ':hover': {
13
- border: '1px solid #757575'
14
- }, ':focus-within': {
15
- border: '1px solid #FF5F00'
16
- } })); },
10
+ control: function (styles, _a) {
11
+ var isDisabled = _a.isDisabled;
12
+ return (__assign(__assign({}, styles), { backgroundColor: isDisabled ? '#f8f8f8' : 'white',
13
+ // minWidth: 200,
14
+ height: 48, paddingLeft: 8, borderRadius: 10, fontSize: 14, boxShadow: 'none', border: '1px solid #D9D9D9', ':hover': {
15
+ border: '1px solid #757575'
16
+ }, ':focus-within': {
17
+ border: '1px solid #FF5F00'
18
+ } }));
19
+ },
17
20
  option: function (styles, _a) {
18
21
  var isSelected = _a.isSelected, isFocused = _a.isFocused;
19
22
  return __assign(__assign({}, styles), { backgroundColor: isFocused ? '#FFF6F0' : 'white', color: isSelected ? '#FF5F00' : '#666', ':hover': {
@@ -26,17 +29,20 @@ var Select = function (_a) {
26
29
  };
27
30
  var CustomControl = function (props) { return (jsxs(components.Control, __assign({}, props, { children: [preIcon && (jsx("div", __assign({ style: {
28
31
  display: 'flex',
29
- paddingLeft: 16,
32
+ paddingLeft: 8,
30
33
  marginRight: -4,
31
34
  color: props.hasValue ? '#525252' : '#B3B3B3'
32
35
  } }, { children: preIcon }))), props.children] }))); };
33
36
  var CustomOptionComp = function (props) { return (jsxs(components.Option, __assign({}, props, { children: [props.children, props.isSelected && jsx(Icon, { name: "CheckCircleOutlined" })] }))); };
37
+ var isMobile = typeof window !== 'undefined' && /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);
34
38
  return (jsx(ReactSelect, __assign({ options: options, className: classNames('foxit-select-wrapper', className), placeholder: placeholder, styles: customStyles, defaultValue: isMulti
35
39
  ? options.filter(function (option) {
36
40
  return Array.isArray(defaultValue) &&
37
41
  defaultValue.includes(option.value);
38
42
  })
39
- : options.find(function (option) { return option.value === defaultValue; }), isDisabled: isDisabled, isClearable: isClearable, isSearchable: isSearchable, isMulti: isMulti, components: { Control: CustomControl, Option: CustomOptionComp } }, rest)));
43
+ : options.find(function (option) { return option.value === defaultValue; }), isDisabled: isDisabled, isClearable: isClearable, isSearchable: isMobile ? false : isSearchable, isMulti: isMulti, components: { Control: CustomControl, Option: CustomOptionComp }, onChange: onChange, menuPosition: "fixed" }, rest, { value: isMulti && Array.isArray(value)
44
+ ? value.map(function (v) { return options.find(function (option) { return option.value === v; }); })
45
+ : options.find(function (option) { return option.value === value; }) || value })));
40
46
  };
41
47
 
42
48
  export { Select as default };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import './spin.css';
3
+ interface FoxitSpinProps {
4
+ spinning: boolean;
5
+ size?: 'small' | 'default' | 'large';
6
+ children?: React.ReactNode;
7
+ className?: string;
8
+ }
9
+ declare const Spin: React.FC<FoxitSpinProps>;
10
+ export { Spin };
@@ -0,0 +1,23 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import classNames from 'classnames';
4
+ import { Icon } from '../Icon/index.js';
5
+
6
+ var Spin = function (_a) {
7
+ var _b = _a.spinning, spinning = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'default' : _c, children = _a.children, className = _a.className;
8
+ // return spinning ? (
9
+ // <div className={classNames('foxit-spin', `foxit-spin-${size}`)}>
10
+ // <div className="foxit-spin-icon">
11
+ // <Icon name="LoadingOutlined" className={classNames('foxit-spin-spinning', className)} />
12
+ // </div>
13
+ // {children && <div className="foxit-spin-container">{children}</div>}
14
+ // </div>
15
+ // ) : children ? (
16
+ // <>{children}</>
17
+ // ) : (
18
+ // <></>
19
+ // );
20
+ return (jsxs("div", __assign({ className: classNames(spinning && 'foxit-spin', spinning && "foxit-spin-".concat(size)) }, { children: [spinning && (jsx("div", __assign({ className: "foxit-spin-icon" }, { children: jsx(Icon, { name: "LoadingOutlined", className: classNames('foxit-spin-spinning', className) }) }))), children && jsx("div", __assign({ className: classNames(spinning && 'foxit-spin-container') }, { children: children })), !children && !spinning && jsx(Fragment, {})] })));
21
+ };
22
+
23
+ export { Spin };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './switch.css';
3
+ interface FoxitSwitchProps {
4
+ value?: boolean;
5
+ onChange?: (value: boolean) => void;
6
+ size?: 'small' | 'large';
7
+ }
8
+ declare const Switch: React.FC<FoxitSwitchProps>;
9
+ export { Switch };
@@ -0,0 +1,20 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+
5
+ var Switch = function (_a) {
6
+ var value = _a.value, onChange = _a.onChange, _b = _a.size, size = _b === void 0 ? 'large' : _b;
7
+ var _c = useState(value || false), internalValue = _c[0], setInternalValue = _c[1];
8
+ var isControlled = value !== undefined;
9
+ var handleToggle = function () {
10
+ if (onChange) {
11
+ onChange(!isControlled ? !internalValue : !value);
12
+ }
13
+ if (!isControlled) {
14
+ setInternalValue(!internalValue);
15
+ }
16
+ };
17
+ return (jsx("div", __assign({ className: "foxit-switch ".concat(size, " ").concat(isControlled ? (value ? 'checked' : '') : internalValue ? 'checked' : ''), onClick: handleToggle }, { children: jsx("div", { className: "foxit-switch-handle" }) })));
18
+ };
19
+
20
+ export { Switch };
@@ -10,6 +10,9 @@ export interface Column<T> {
10
10
  interface TableProps<T> {
11
11
  columns: Column<T>[];
12
12
  data: T[];
13
+ loading?: boolean;
14
+ emptyText?: React.ReactNode;
15
+ mobile?: boolean;
13
16
  }
14
- declare const Table: <T>({ columns, data }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
17
+ declare const Table: <T>({ columns, data, loading, emptyText, mobile }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
15
18
  export default Table;
package/es/Table/Table.js CHANGED
@@ -1,15 +1,29 @@
1
1
  import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import './table.css.js';
3
+ import Empty from '../Empty/Empty.js';
4
+ import { Icon } from '../Icon/index.js';
4
5
 
5
6
  var Table = function (_a) {
6
- var columns = _a.columns, data = _a.data;
7
- return (jsx("div", __assign({ className: "foxit-table" }, { children: jsxs("table", __assign({ className: "foxit-table-container" }, { children: [jsx("thead", { children: jsx("tr", { children: columns.map(function (column, index) { return (jsx("th", __assign({ style: {
8
- width: column.width ? "".concat(column.width, "px") : 'auto',
9
- textAlign: column.align || 'left'
10
- } }, { children: column.title }), index)); }) }) }), jsx("tbody", { children: data.map(function (record, rowIndex) { return (jsx("tr", __assign({ className: rowIndex % 2 === 0 ? 'foxit-even-row' : 'foxit-odd-row' }, { children: columns.map(function (column, colIndex) { return (jsx("td", __assign({ style: { textAlign: column.align || 'left' } }, { children: column.render
11
- ? column.render(record[column.dataIndex], record)
12
- : record[column.dataIndex] }), colIndex)); }) }), rowIndex)); }) })] })) })));
7
+ var columns = _a.columns, data = _a.data, loading = _a.loading, emptyText = _a.emptyText, _b = _a.mobile, mobile = _b === void 0 ? false : _b;
8
+ if (!loading && data.length === 0) {
9
+ return jsx(Empty, { description: emptyText || 'No Data' });
10
+ }
11
+ if (mobile) {
12
+ return (jsxs("div", __assign({ className: "foxit-table-mobile-list" }, { children: [loading && (jsx("div", __assign({ className: "foxit-table-mobile-loading" }, { children: jsx(Icon, { name: "LoadingOutlined", className: "foxit-table-icon-loading" }) }))), data.map(function (record, rowIndex) { return (jsx("div", __assign({ className: "foxit-table-mobile-card" }, { children: columns.map(function (column, colIndex) { return (jsxs("div", __assign({ className: "foxit-table-mobile-row" }, { children: [jsx("span", __assign({ className: "foxit-table-mobile-label" }, { children: column.title })), jsx("span", __assign({ className: "foxit-table-mobile-value" }, { children: column.render
13
+ ? column.render(record[column.dataIndex], record)
14
+ : typeof record[column.dataIndex] === 'object'
15
+ ? JSON.stringify(record[column.dataIndex])
16
+ : String(record[column.dataIndex]) }))] }), colIndex)); }) }), rowIndex)); })] })));
17
+ }
18
+ return (jsxs("div", __assign({ className: "foxit-table" }, { children: [loading ? (jsx("div", __assign({ className: "foxit-table-loading" }, { children: jsx(Icon, { name: "LoadingOutlined", className: "foxit-table-icon-loading" }) }))) : null, jsxs("table", __assign({ className: "foxit-table-container" }, { children: [jsx("thead", { children: jsx("tr", { children: columns.map(function (column, index) { return (jsx("th", __assign({ style: {
19
+ width: column.width ? "".concat(column.width, "px") : 'auto',
20
+ textAlign: column.align || 'left'
21
+ } }, { children: column.title }), index)); }) }) }), jsx("tbody", { children: data.map(function (record, rowIndex) { return (jsx("tr", __assign({ className: rowIndex % 2 === 0 ? 'foxit-even-row' : 'foxit-odd-row' }, { children: columns.map(function (column, colIndex) { return (jsx("td", __assign({ style: { textAlign: column.align || 'left' } }, { children: column.render
22
+ ? column.render(record[column.dataIndex], record)
23
+ : typeof record[column.dataIndex] === 'object'
24
+ ? JSON.stringify(record[column.dataIndex]) // 将对象转换为字符串
25
+ : String(record[column.dataIndex]) // 确保它是一个字符串
26
+ }), colIndex)); }) }), rowIndex)); }) })] }))] })));
13
27
  };
14
28
 
15
29
  export { Table as default };
package/es/Tabs/Tabs.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 { useState } from 'react';
4
- import './tabs.css.js';
5
4
 
6
5
  var ButtonTabs = function (_a) {
7
6
  var _b;
package/es/Tag/Tag.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './tag.css';
3
3
  interface TagProps {
4
- color: 'active' | 'canceled' | 'pending' | 'offline' | 'trial' | 'expired';
4
+ color?: 'active' | 'canceled' | 'pending' | 'offline' | 'trial' | 'expired' | 'completed' | string;
5
5
  children: React.ReactNode;
6
6
  }
7
7
  declare const Tag: React.FC<TagProps>;
package/es/Tag/Tag.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import './tag.css.js';
4
3
 
5
4
  var Tag = function (_a) {
6
- var color = _a.color, children = _a.children;
5
+ var _b = _a.color, color = _b === void 0 ? 'active' : _b, children = _a.children;
7
6
  var className = "foxit-tag foxit-tag-".concat(color);
8
7
  return jsx("span", __assign({ className: className }, { children: children }));
9
8
  };
package/es/Toast/Toast.js CHANGED
@@ -3,7 +3,6 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useRef, useEffect } from 'react';
4
4
  import { CSSTransition } from 'react-transition-group';
5
5
  import classNames from 'classnames';
6
- import './toast.css.js';
7
6
  import { Icon } from '../Icon/index.js';
8
7
 
9
8
  var Toast = function (_a) {
@@ -2,7 +2,6 @@ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
3
  import { useState, useEffect } from 'react';
4
4
  import { createRoot } from 'react-dom/client';
5
- import './toast.css.js';
6
5
  import Toast from './Toast.js';
7
6
 
8
7
  var createToastContainer = function (toastManager, duration, unique) {
@@ -3,6 +3,8 @@ import './tooltip.css';
3
3
  interface TooltipProps {
4
4
  title: string | ReactNode;
5
5
  children: ReactNode;
6
+ whiteGround?: boolean;
7
+ className?: string;
6
8
  }
7
9
  declare const Tooltip: React.FC<TooltipProps>;
8
10
  export default Tooltip;