foxit-component 0.0.1 → 1.0.0-alpha.29

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 (70) hide show
  1. package/README.md +44 -1
  2. package/es/Alert/Alert.d.ts +12 -0
  3. package/es/Alert/Alert.js +24 -0
  4. package/es/Button/Button.d.ts +9 -11
  5. package/es/Button/Button.js +6 -8
  6. package/es/Checkbox/Checkbox.d.ts +18 -0
  7. package/es/Checkbox/Checkbox.js +49 -0
  8. package/es/Drawer/Drawer.d.ts +10 -0
  9. package/es/Drawer/Drawer.js +14 -0
  10. package/es/Empty/Empty.d.ts +7 -0
  11. package/es/Empty/Empty.js +10 -0
  12. package/es/Form/Form.d.ts +15 -0
  13. package/es/Form/Form.js +38 -0
  14. package/es/Form/Form.types.d.ts +48 -0
  15. package/es/Form/FormContext.d.ts +3 -0
  16. package/es/Form/FormContext.js +5 -0
  17. package/es/Form/FormItem.d.ts +16 -0
  18. package/es/Form/FormItem.js +34 -0
  19. package/es/Form/FormProvider.d.ts +10 -0
  20. package/es/Form/FormProvider.js +260 -0
  21. package/es/Form/useFormWatch.d.ts +3 -0
  22. package/es/Form/useFormWatch.js +37 -0
  23. package/es/Icon/index.d.ts +7 -0
  24. package/es/Icon/index.js +9 -0
  25. package/es/Input/Input.d.ts +14 -0
  26. package/es/Input/Input.js +29 -0
  27. package/es/Menu/Menu.d.ts +23 -0
  28. package/es/Menu/Menu.js +163 -0
  29. package/es/Modal/Modal.d.ts +22 -0
  30. package/es/Modal/Modal.js +110 -0
  31. package/es/Modal/ModalTemp.d.ts +11 -0
  32. package/es/Modal/ModalTemp.js +75 -0
  33. package/es/Pagination/Pagination.d.ts +12 -0
  34. package/es/Pagination/Pagination.js +95 -0
  35. package/es/Quantity/Quantity.d.ts +10 -0
  36. package/es/Quantity/Quantity.js +45 -0
  37. package/es/Radio/Radio.d.ts +18 -0
  38. package/es/Radio/Radio.js +44 -0
  39. package/es/Select/Select.d.ts +27 -0
  40. package/es/Select/Select.js +47 -0
  41. package/es/Spin/Spin.d.ts +10 -0
  42. package/es/Spin/Spin.js +23 -0
  43. package/es/Switch/Switch.d.ts +9 -0
  44. package/es/Switch/Switch.js +20 -0
  45. package/es/Table/Table.d.ts +18 -0
  46. package/es/Table/Table.js +29 -0
  47. package/es/Tabs/Tabs.d.ts +14 -0
  48. package/es/Tabs/Tabs.js +21 -0
  49. package/es/Tag/Tag.d.ts +8 -0
  50. package/es/Tag/Tag.js +10 -0
  51. package/es/Toast/Toast.d.ts +5 -0
  52. package/es/Toast/Toast.js +43 -0
  53. package/es/Toast/Toast.types.d.ts +5 -0
  54. package/es/Toast/ToastContainer.d.ts +3 -0
  55. package/es/Toast/ToastContainer.js +46 -0
  56. package/es/Toast/ToastManager.d.ts +8 -0
  57. package/es/Toast/ToastManager.js +19 -0
  58. package/es/Toast/index.d.ts +8 -0
  59. package/es/Toast/index.js +39 -0
  60. package/es/Tooltip/Tooltip.d.ts +8 -0
  61. package/es/Tooltip/Tooltip.js +51 -0
  62. package/es/constants/icons.d.ts +40 -0
  63. package/es/constants/icons.js +45 -0
  64. package/es/index.css +1 -0
  65. package/es/index.d.ts +36 -0
  66. package/es/index.js +22 -0
  67. package/es/node_modules/tslib/tslib.es6.js +49 -1
  68. package/package.json +32 -16
  69. package/es/Button/button.css.js +0 -6
  70. package/es/node_modules/style-inject/dist/style-inject.es.js +0 -28
@@ -0,0 +1,110 @@
1
+ import { __assign, __awaiter, __generator } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import { Icon } from '../Icon/index.js';
5
+ import classNames from 'classnames';
6
+ import { createRoot } from 'react-dom/client';
7
+ import { Modal as Modal$1 } from './ModalTemp.js';
8
+ import { Button } from '../Button/Button.js';
9
+
10
+ var ModalContent = function (_a) {
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))"),
56
+ width: width
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 })))] }))] })));
58
+ };
59
+ var Modal = function (_a) {
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 })) })));
62
+ };
63
+ // 语法糖的调用方式
64
+ Modal.confirm = function (_a) {
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;
66
+ var modalRoot = document.createElement('div');
67
+ document.body.appendChild(modalRoot);
68
+ var root = createRoot(modalRoot);
69
+ var handleClose = function () {
70
+ root.unmount();
71
+ if (document.body.contains(modalRoot)) {
72
+ document.body.removeChild(modalRoot);
73
+ }
74
+ };
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 })) })));
108
+ };
109
+
110
+ export { Modal };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import './modal.css';
3
+ interface IModalProps {
4
+ opened: boolean;
5
+ onClose: () => void;
6
+ maskClosable?: boolean;
7
+ position?: 'center' | 'top' | 'bottom';
8
+ text?: string | React.ReactNode;
9
+ }
10
+ export declare const Modal: React.FC<React.PropsWithChildren<IModalProps>>;
11
+ export {};
@@ -0,0 +1,75 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useState, useEffect, useRef } from 'react';
4
+ import { CSSTransition } from 'react-transition-group';
5
+ import { createPortal } from 'react-dom';
6
+ import classNames from 'classnames';
7
+
8
+ var contentAnimation = {
9
+ enter: 'foxit-modal-opacity-0 foxit-modal-scale-0',
10
+ enterActive: 'foxit-modal-transition foxit-modal-scale-100 foxit-modal-opacity-100',
11
+ exit: 'foxit-modal-opacity-100 foxit-modal-scale-100',
12
+ exitActive: 'foxit-modal-transition !foxit-modal-opacity-0 !foxit-modal-scale-0'
13
+ };
14
+ var overlayAnimation = {
15
+ enter: 'foxit-modal-opacity-0',
16
+ enterActive: 'foxit-modal-transition foxit-modal-opacity-100',
17
+ exit: 'foxit-modal-opacity-100',
18
+ exitActive: 'foxit-modal-transition !foxit-modal-opacity-0'
19
+ };
20
+ var Portal = function (_a) {
21
+ var children = _a.children;
22
+ var container = useState(function () { return document.createElement('div'); })[0];
23
+ useEffect(function () {
24
+ var _a, _b;
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
+ };
30
+ }, [container]);
31
+ return createPortal(children, container);
32
+ };
33
+ var ModalLayout = function (_a) {
34
+ var _b = _a.onClose, onClose = _b === void 0 ? function () { } : _b, children = _a.children, opened = _a.opened, _c = _a.maskClosable, maskClosable = _c === void 0 ? true : _c, _d = _a.position, position = _d === void 0 ? 'center' : _d;
35
+ var overlayRef = useRef(null);
36
+ var contentRef = useRef(null);
37
+ var _e = useState(false), animationIn = _e[0], setAnimationIn = _e[1];
38
+ useEffect(function () {
39
+ setAnimationIn(opened);
40
+ }, [opened]);
41
+ var justifyClass = 'foxit-modal-justify-center';
42
+ if (position === 'top') {
43
+ justifyClass = 'foxit-modal-justify-top';
44
+ }
45
+ else if (position === 'bottom') {
46
+ justifyClass = 'foxit-modal-justify-bottom';
47
+ }
48
+ return (jsxs("div", __assign({ className: classNames('foxit-modal-fixed-layout', justifyClass) }, { children: [jsx(CSSTransition, __assign({ in: animationIn, nodeRef: overlayRef, timeout: 150, mountOnEnter: true, unmountOnExit: true, classNames: overlayAnimation }, { children: jsx("div", __assign({ ref: overlayRef, className: "foxit-modal-overlay", onClick: maskClosable ? onClose : undefined }, { children: jsx("div", { className: "foxit-modal-overlay-bg" }) })) })), jsx(CSSTransition, __assign({ in: animationIn, nodeRef: contentRef, timeout: 150, mountOnEnter: true, unmountOnExit: true, classNames: contentAnimation }, { children: jsx("div", __assign({ ref: contentRef, className: "foxit-modal-content" }, { children: children })) }))] })));
49
+ };
50
+ var Modal = function (_a) {
51
+ var opened = _a.opened, onClose = _a.onClose, maskClosable = _a.maskClosable, children = _a.children, position = _a.position;
52
+ var _b = useState(false), mounted = _b[0], setMounted = _b[1];
53
+ useEffect(function () {
54
+ if (opened && !mounted) {
55
+ setMounted(true);
56
+ }
57
+ else if (!opened && mounted) {
58
+ setTimeout(function () {
59
+ setMounted(false);
60
+ }, 150);
61
+ }
62
+ }, [opened, mounted]);
63
+ useEffect(function () {
64
+ document.body.style.overflowY = opened ? 'hidden' : '';
65
+ return function () {
66
+ document.body.style.overflow = '';
67
+ };
68
+ }, [opened]);
69
+ if (!mounted) {
70
+ return null;
71
+ }
72
+ return (jsx(Portal, { children: jsx(ModalLayout, __assign({ onClose: onClose, opened: opened, maskClosable: maskClosable, position: position }, { children: children })) }));
73
+ };
74
+
75
+ export { Modal };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import './pagination.css';
3
+ interface PaginationProps {
4
+ total: number;
5
+ pageSize: number;
6
+ onChange?: (page: number) => void;
7
+ defaultCurrent?: number;
8
+ current?: number;
9
+ mobile?: boolean;
10
+ }
11
+ declare const Pagination: React.FC<PaginationProps>;
12
+ export default Pagination;
@@ -0,0 +1,95 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useEffect } from 'react';
4
+ import { Button } from '../Button/Button.js';
5
+
6
+ var $_MORE = 9999999999;
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, 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
+ var maxButtons = 5;
12
+ var totalPages = Math.ceil(total / pageSize);
13
+ useEffect(function () {
14
+ if (currentProp !== undefined && currentProp !== current) {
15
+ setCurrent(currentProp);
16
+ }
17
+ }, [currentProp, current]);
18
+ useEffect(function () {
19
+ var generatePages = function () {
20
+ var pageArray = [];
21
+ if (totalPages <= maxButtons) {
22
+ for (var i = 1; i <= totalPages; i++) {
23
+ pageArray.push(i);
24
+ }
25
+ }
26
+ else {
27
+ pageArray.push(1);
28
+ var ellipsis = $_MORE;
29
+ if (current <= 3) {
30
+ for (var i = 2; i <= Math.min(maxButtons - 2, totalPages - 1); i++) {
31
+ pageArray.push(i);
32
+ }
33
+ pageArray.push(ellipsis);
34
+ }
35
+ else if (current >= totalPages - 2) {
36
+ pageArray.push(ellipsis);
37
+ for (var i = totalPages - maxButtons + 3; i <= totalPages - 1; i++) {
38
+ pageArray.push(i);
39
+ }
40
+ }
41
+ else {
42
+ pageArray.push(ellipsis);
43
+ pageArray.push(current - 1);
44
+ pageArray.push(current);
45
+ pageArray.push(current + 1);
46
+ pageArray.push(ellipsis);
47
+ }
48
+ pageArray.push(totalPages);
49
+ }
50
+ setPages(pageArray);
51
+ };
52
+ generatePages();
53
+ }, [total, pageSize, current, totalPages]);
54
+ var handleClick = function (page, index) {
55
+ if (page === $_MORE) {
56
+ if (index > 0 && pages[index - 1] !== null && pages[index - 1] !== 1) {
57
+ var newPage = pages[index - 1] + 1;
58
+ setCurrent(newPage);
59
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
60
+ }
61
+ else if (index < pages.length - 1 &&
62
+ pages[index + 1] !== null &&
63
+ pages[index + 1] !== totalPages) {
64
+ var newPage = pages[index + 1] - 1;
65
+ setCurrent(newPage);
66
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
67
+ }
68
+ }
69
+ else if (page !== current) {
70
+ setCurrent(page);
71
+ onChange === null || onChange === void 0 ? void 0 : onChange(page);
72
+ }
73
+ };
74
+ var handlePrev = function () {
75
+ if (current > 1) {
76
+ var newPage = current - 1;
77
+ setCurrent(newPage);
78
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
79
+ }
80
+ };
81
+ var handleNext = function () {
82
+ if (current < totalPages) {
83
+ var newPage = current + 1;
84
+ setCurrent(newPage);
85
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
86
+ }
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
+ }
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;
93
+ };
94
+
95
+ export { Pagination as default };
@@ -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 };
@@ -0,0 +1,18 @@
1
+ import { ReactNode, FC } from 'react';
2
+ import './radio.css';
3
+ interface RadioProps {
4
+ value: string;
5
+ checked?: boolean;
6
+ disabled?: boolean;
7
+ children: ReactNode;
8
+ onChange?: (value: string) => void;
9
+ }
10
+ interface RadioGroupProps {
11
+ onChange?: (value: string) => void;
12
+ value?: string;
13
+ children: ReactNode;
14
+ }
15
+ declare const Radio: FC<RadioProps> & {
16
+ Group: FC<RadioGroupProps>;
17
+ };
18
+ export default Radio;
@@ -0,0 +1,44 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { createContext, useContext, useState } from 'react';
4
+
5
+ var RadioContext = createContext({});
6
+ var Radio = function (_a) {
7
+ var value = _a.value, checked = _a.checked, _b = _a.disabled, disabled = _b === void 0 ? false : _b, children = _a.children, onChange = _a.onChange;
8
+ var context = useContext(RadioContext);
9
+ var _c = useState(checked || false), internalChecked = _c[0], setInternalChecked = _c[1];
10
+ var isChecked = context.selectedValue !== undefined
11
+ ? context.selectedValue === value
12
+ : checked !== undefined
13
+ ? checked
14
+ : internalChecked;
15
+ var handleChange = function () {
16
+ if (!disabled) {
17
+ if (context.onChange) {
18
+ context.onChange(value);
19
+ }
20
+ else if (onChange) {
21
+ setInternalChecked(true);
22
+ onChange(value);
23
+ }
24
+ else {
25
+ setInternalChecked(true);
26
+ }
27
+ }
28
+ };
29
+ return (jsxs("label", __assign({ className: "foxit-radio-container ".concat(disabled ? 'disabled' : '') }, { children: [jsx("input", { type: "radio", value: value, checked: isChecked, disabled: disabled, onChange: handleChange }), jsx("span", { className: "foxit-radio-checkmark" }), jsx("span", __assign({ className: "foxit-radio-content" }, { children: children }))] })));
30
+ };
31
+ var RadioGroup = function (_a) {
32
+ var onChange = _a.onChange, value = _a.value, children = _a.children;
33
+ var _b = useState(value), selectedValue = _b[0], setSelectedValue = _b[1];
34
+ var handleChange = function (val) {
35
+ setSelectedValue(val);
36
+ if (onChange) {
37
+ onChange(val);
38
+ }
39
+ };
40
+ return (jsx(RadioContext.Provider, __assign({ value: { onChange: handleChange, selectedValue: value !== undefined ? value : selectedValue } }, { children: children })));
41
+ };
42
+ Radio.Group = RadioGroup;
43
+
44
+ export { Radio as default };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ export interface SelectProps {
3
+ options: {
4
+ value: string | number;
5
+ label: string;
6
+ }[];
7
+ className?: string;
8
+ defaultValue?: string | number | string[] | number[];
9
+ isDisabled?: boolean;
10
+ isClearable?: boolean;
11
+ isSearchable?: boolean;
12
+ isMulti?: boolean;
13
+ placeholder?: string;
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;
25
+ }
26
+ declare const Select: React.FC<SelectProps>;
27
+ export default Select;
@@ -0,0 +1,47 @@
1
+ import { __rest, __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import ReactSelect, { components } from 'react-select';
4
+ import classNames from 'classnames';
5
+ import { Icon } from '../Icon/index.js';
6
+
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, value = _a.value, onChange = _a.onChange, rest = __rest(_a, ["options", "className", "defaultValue", "isDisabled", "isClearable", "isSearchable", "isMulti", "placeholder", "preIcon", "value", "onChange"]);
9
+ var customStyles = {
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
+ },
20
+ option: function (styles, _a) {
21
+ var isSelected = _a.isSelected, isFocused = _a.isFocused;
22
+ return __assign(__assign({}, styles), { backgroundColor: isFocused ? '#FFF6F0' : 'white', color: isSelected ? '#FF5F00' : '#666', ':hover': {
23
+ backgroundColor: '#FFF6F0'
24
+ }, fontSize: 16, display: 'flex', justifyContent: 'space-between', alignItems: 'center' });
25
+ },
26
+ indicatorSeparator: function (styles) { return (__assign(__assign({}, styles), { display: 'none' })); },
27
+ placeholder: function (styles) { return (__assign(__assign({}, styles), { color: '#B3B3B3' })); },
28
+ dropdownIndicator: function (styles) { return (__assign(__assign({}, styles), { paddingRight: 16 })); }
29
+ };
30
+ var CustomControl = function (props) { return (jsxs(components.Control, __assign({}, props, { children: [preIcon && (jsx("div", __assign({ style: {
31
+ display: 'flex',
32
+ paddingLeft: 8,
33
+ marginRight: -4,
34
+ color: props.hasValue ? '#525252' : '#B3B3B3'
35
+ } }, { children: preIcon }))), props.children] }))); };
36
+ var CustomOptionComp = function (props) { return (jsxs(components.Option, __assign({}, props, { children: [props.children, props.isSelected && jsx(Icon, { name: "CheckCircleOutlined" })] }))); };
37
+ return (jsx(ReactSelect, __assign({ options: options, className: classNames('foxit-select-wrapper', className), placeholder: placeholder, styles: customStyles, defaultValue: isMulti
38
+ ? options.filter(function (option) {
39
+ return Array.isArray(defaultValue) &&
40
+ defaultValue.includes(option.value);
41
+ })
42
+ : options.find(function (option) { return option.value === defaultValue; }), isDisabled: isDisabled, isClearable: isClearable, isSearchable: isSearchable, isMulti: isMulti, components: { Control: CustomControl, Option: CustomOptionComp }, onChange: onChange, menuPosition: "fixed" }, rest, { value: isMulti && Array.isArray(value)
43
+ ? value.map(function (v) { return options.find(function (option) { return option.value === v; }); })
44
+ : options.find(function (option) { return option.value === value; }) || value })));
45
+ };
46
+
47
+ 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 };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import './table.css';
3
+ export interface Column<T> {
4
+ title: string;
5
+ dataIndex: keyof T;
6
+ width?: number;
7
+ align?: 'left' | 'center' | 'right';
8
+ render?: (text: T[keyof T], record: T) => React.ReactNode;
9
+ }
10
+ interface TableProps<T> {
11
+ columns: Column<T>[];
12
+ data: T[];
13
+ loading?: boolean;
14
+ emptyText?: React.ReactNode;
15
+ mobile?: boolean;
16
+ }
17
+ declare const Table: <T>({ columns, data, loading, emptyText, mobile }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
18
+ export default Table;
@@ -0,0 +1,29 @@
1
+ import { __assign } from '../node_modules/tslib/tslib.es6.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import Empty from '../Empty/Empty.js';
4
+ import { Icon } from '../Icon/index.js';
5
+
6
+ var Table = function (_a) {
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)); }) })] }))] })));
27
+ };
28
+
29
+ export { Table as default };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import './tabs.css';
3
+ interface TabItem {
4
+ key: string;
5
+ label: string;
6
+ children: React.ReactNode;
7
+ }
8
+ interface ButtonTabsProps {
9
+ activeKey?: string;
10
+ items: TabItem[];
11
+ onChange?: (key: string) => void;
12
+ }
13
+ declare const ButtonTabs: React.FC<ButtonTabsProps>;
14
+ export default ButtonTabs;