foxit-component 0.0.1-alpha.1 → 0.0.1-alpha.11

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 (59) hide show
  1. package/es/Button/Button.d.ts +9 -11
  2. package/es/Button/Button.js +6 -8
  3. package/es/Checkbox/Checkbox.d.ts +18 -0
  4. package/es/Checkbox/Checkbox.js +49 -0
  5. package/es/Empty/Empty.d.ts +7 -0
  6. package/es/Empty/Empty.js +10 -0
  7. package/es/Form/Form.d.ts +14 -0
  8. package/es/Form/Form.js +37 -0
  9. package/es/Form/Form.types.d.ts +39 -0
  10. package/es/Form/FormContext.d.ts +3 -0
  11. package/es/Form/FormContext.js +5 -0
  12. package/es/Form/FormItem.d.ts +16 -0
  13. package/es/Form/FormItem.js +34 -0
  14. package/es/Form/FormProvider.d.ts +10 -0
  15. package/es/Form/FormProvider.js +215 -0
  16. package/es/Icon/index.d.ts +7 -0
  17. package/es/Icon/index.js +9 -0
  18. package/es/Input/Input.d.ts +14 -0
  19. package/es/Input/Input.js +29 -0
  20. package/es/Menu/Menu.d.ts +22 -0
  21. package/es/Menu/Menu.js +49 -0
  22. package/es/Modal/Modal.d.ts +20 -0
  23. package/es/Modal/Modal.js +123 -0
  24. package/es/Modal/ModalTemp.d.ts +11 -0
  25. package/es/Modal/ModalTemp.js +75 -0
  26. package/es/Pagination/Pagination.d.ts +11 -0
  27. package/es/Pagination/Pagination.js +90 -0
  28. package/es/Radio/Radio.d.ts +18 -0
  29. package/es/Radio/Radio.js +44 -0
  30. package/es/Select/Select.d.ts +26 -0
  31. package/es/Select/Select.js +56 -0
  32. package/es/Switch/Switch.d.ts +9 -0
  33. package/es/Switch/Switch.js +20 -0
  34. package/es/Table/Table.d.ts +17 -0
  35. package/es/Table/Table.js +19 -0
  36. package/es/Tabs/Tabs.d.ts +14 -0
  37. package/es/Tabs/Tabs.js +21 -0
  38. package/es/Tag/Tag.d.ts +8 -0
  39. package/es/Tag/Tag.js +10 -0
  40. package/es/Toast/Toast.d.ts +5 -0
  41. package/es/Toast/Toast.js +43 -0
  42. package/es/Toast/Toast.types.d.ts +5 -0
  43. package/es/Toast/ToastContainer.d.ts +3 -0
  44. package/es/Toast/ToastContainer.js +46 -0
  45. package/es/Toast/ToastManager.d.ts +8 -0
  46. package/es/Toast/ToastManager.js +19 -0
  47. package/es/Toast/index.d.ts +8 -0
  48. package/es/Toast/index.js +39 -0
  49. package/es/Tooltip/Tooltip.d.ts +8 -0
  50. package/es/Tooltip/Tooltip.js +30 -0
  51. package/es/constants/icons.d.ts +32 -0
  52. package/es/constants/icons.js +37 -0
  53. package/es/index.css +1 -0
  54. package/es/index.d.ts +32 -0
  55. package/es/index.js +17 -0
  56. package/es/node_modules/tslib/tslib.es6.js +49 -1
  57. package/package.json +16 -14
  58. package/es/Button/button.css.js +0 -6
  59. package/es/node_modules/style-inject/dist/style-inject.es.js +0 -28
@@ -0,0 +1,49 @@
1
+ import { __assign, __spreadArray } 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
+
6
+ var getItem = function (label, key, icon, children, type) {
7
+ return {
8
+ key: key,
9
+ icon: icon,
10
+ children: children,
11
+ label: label,
12
+ type: type
13
+ };
14
+ };
15
+ var Menu = function (_a) {
16
+ var items = _a.items, onClick = _a.onClick, _b = _a.defaultSelectedKeys, defaultSelectedKeys = _b === void 0 ? [] : _b, _c = _a.defaultOpenKeys, defaultOpenKeys = _c === void 0 ? [] : _c, style = _a.style;
17
+ var _d = useState(defaultOpenKeys), openKeys = _d[0], setOpenKeys = _d[1];
18
+ var _e = useState(defaultSelectedKeys), selectedKeys = _e[0], setSelectedKeys = _e[1];
19
+ var handleMenuClick = function (e) {
20
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
21
+ setSelectedKeys([e.key]);
22
+ };
23
+ // const handleOpenChange = (keys: string[]) => {
24
+ // setOpenKeys(keys);
25
+ // };
26
+ var isFirstLevel = function (item) {
27
+ return items.some(function (i) { return i.key === item.key; });
28
+ };
29
+ var renderMenuItem = function (item) {
30
+ var isSelected = selectedKeys.includes(item.key.toString());
31
+ return (jsx("div", __assign({ className: "foxit-menu-item ".concat(isSelected ? 'selected' : '') }, { children: jsxs("div", __assign({ className: "foxit-menu-item-content", onClick: function () { return handleMenuClick({ key: item.key.toString() }); } }, { children: [item.icon && jsx("span", __assign({ style: { marginRight: '8px' } }, { children: item.icon })), jsx("span", __assign({ className: isFirstLevel(item) ? 'foxit-menu-item-label' : '' }, { children: item.label }))] })) }), item.key));
32
+ };
33
+ var renderSubMenu = function (item) {
34
+ var isOpen = openKeys.includes(item.key.toString());
35
+ return (jsxs("div", { children: [jsxs("div", __assign({ className: "foxit-menu-submenu-title", onClick: function () {
36
+ if (isOpen) {
37
+ setOpenKeys(openKeys.filter(function (key) { return key !== item.key.toString(); }));
38
+ }
39
+ else {
40
+ setOpenKeys(__spreadArray(__spreadArray([], openKeys, true), [item.key.toString()], false));
41
+ }
42
+ } }, { children: [jsxs("div", __assign({ style: { display: 'flex', alignItems: 'center' } }, { children: [item.icon && jsx("span", __assign({ style: { marginRight: '8px' } }, { children: item.icon })), jsx("span", __assign({ className: isFirstLevel(item) ? 'foxit-menu-item-label' : '' }, { children: item.label }))] })), jsx("span", { children: jsx(Icon, { name: "DownOutlined", className: "foxit-menu-icon ".concat(isOpen ? '' : 'foxit-menu-rotated-icon') }) })] })), isOpen && item.children && (jsx("div", __assign({ className: "foxit-menu-submenu-items" }, { children: item.children.map(function (child) {
43
+ return child.children ? renderSubMenu(child) : renderMenuItem(child);
44
+ }) })))] }, item.key));
45
+ };
46
+ return (jsx("div", __assign({ className: "foxit-menu", style: __assign({}, style) }, { children: items.map(function (item) { return (item.children ? renderSubMenu(item) : renderMenuItem(item)); }) })));
47
+ };
48
+
49
+ export { Menu, getItem };
@@ -0,0 +1,20 @@
1
+ import React, { FC } from 'react';
2
+ import './modal.css';
3
+ interface IModalProps {
4
+ title: string | React.ReactNode;
5
+ opened?: boolean;
6
+ onOk?: () => void;
7
+ onOkText?: string | React.ReactNode;
8
+ onCancel?: () => void;
9
+ onCancelText?: string | React.ReactNode;
10
+ maskClosable?: boolean;
11
+ children?: React.ReactNode;
12
+ width?: string;
13
+ }
14
+ interface ModalComponent extends FC<IModalProps> {
15
+ confirm: (props: IModalProps & {
16
+ content: React.ReactNode;
17
+ }) => void;
18
+ }
19
+ export declare const Modal: ModalComponent;
20
+ export {};
@@ -0,0 +1,123 @@
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 { createRoot } from 'react-dom/client';
6
+ import { Modal as Modal$1 } from './ModalTemp.js';
7
+ import { Button } from '../Button/Button.js';
8
+
9
+ 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
+ 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
+ }); };
67
+ return (jsxs("div", __assign({ className: "foxit-modal-content-container", style: {
68
+ maxWidth: width,
69
+ width: width
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 })))] }))] })));
71
+ };
72
+ var Modal = function (_a) {
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;
74
+ 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 })) })));
75
+ };
76
+ // 语法糖的调用方式
77
+ Modal.confirm = function (_a) {
78
+ 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;
79
+ var modalRoot = document.createElement('div');
80
+ document.body.appendChild(modalRoot);
81
+ var root = createRoot(modalRoot);
82
+ var handleClose = function () {
83
+ root.unmount();
84
+ if (document.body.contains(modalRoot)) {
85
+ document.body.removeChild(modalRoot);
86
+ }
87
+ };
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 })) })));
121
+ };
122
+
123
+ 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,11 @@
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
+ }
10
+ declare const Pagination: React.FC<PaginationProps>;
11
+ export default Pagination;
@@ -0,0 +1,90 @@
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
+
5
+ var $_MORE = 9999999999;
6
+ var Pagination = function (_a) {
7
+ var total = _a.total, pageSize = _a.pageSize, onChange = _a.onChange, _b = _a.defaultCurrent, defaultCurrent = _b === void 0 ? 1 : _b, currentProp = _a.current;
8
+ var _c = useState(currentProp !== undefined ? currentProp : defaultCurrent), current = _c[0], setCurrent = _c[1];
9
+ var _d = useState([]), pages = _d[0], setPages = _d[1];
10
+ var maxButtons = 5;
11
+ var totalPages = Math.ceil(total / pageSize);
12
+ useEffect(function () {
13
+ if (currentProp !== undefined && currentProp !== current) {
14
+ setCurrent(currentProp);
15
+ }
16
+ }, [currentProp, current]);
17
+ useEffect(function () {
18
+ var generatePages = function () {
19
+ var pageArray = [];
20
+ if (totalPages <= maxButtons) {
21
+ for (var i = 1; i <= totalPages; i++) {
22
+ pageArray.push(i);
23
+ }
24
+ }
25
+ else {
26
+ pageArray.push(1);
27
+ var ellipsis = $_MORE;
28
+ if (current <= 3) {
29
+ for (var i = 2; i <= Math.min(maxButtons - 2, totalPages - 1); i++) {
30
+ pageArray.push(i);
31
+ }
32
+ pageArray.push(ellipsis);
33
+ }
34
+ else if (current >= totalPages - 2) {
35
+ pageArray.push(ellipsis);
36
+ for (var i = totalPages - maxButtons + 3; i <= totalPages - 1; i++) {
37
+ pageArray.push(i);
38
+ }
39
+ }
40
+ else {
41
+ pageArray.push(ellipsis);
42
+ pageArray.push(current - 1);
43
+ pageArray.push(current);
44
+ pageArray.push(current + 1);
45
+ pageArray.push(ellipsis);
46
+ }
47
+ pageArray.push(totalPages);
48
+ }
49
+ setPages(pageArray);
50
+ };
51
+ generatePages();
52
+ }, [total, pageSize, current, totalPages]);
53
+ var handleClick = function (page, index) {
54
+ if (page === $_MORE) {
55
+ if (index > 0 && pages[index - 1] !== null && pages[index - 1] !== 1) {
56
+ var newPage = pages[index - 1] + 1;
57
+ setCurrent(newPage);
58
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
59
+ }
60
+ else if (index < pages.length - 1 &&
61
+ pages[index + 1] !== null &&
62
+ pages[index + 1] !== totalPages) {
63
+ var newPage = pages[index + 1] - 1;
64
+ setCurrent(newPage);
65
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
66
+ }
67
+ }
68
+ else if (page !== current) {
69
+ setCurrent(page);
70
+ onChange === null || onChange === void 0 ? void 0 : onChange(page);
71
+ }
72
+ };
73
+ var handlePrev = function () {
74
+ if (current > 1) {
75
+ var newPage = current - 1;
76
+ setCurrent(newPage);
77
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
78
+ }
79
+ };
80
+ var handleNext = function () {
81
+ if (current < totalPages) {
82
+ var newPage = current + 1;
83
+ setCurrent(newPage);
84
+ onChange === null || onChange === void 0 ? void 0 : onChange(newPage);
85
+ }
86
+ };
87
+ 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;
88
+ };
89
+
90
+ export { Pagination as default };
@@ -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,26 @@
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
+ }
18
+ interface CustomOption {
19
+ readonly value: string | number;
20
+ readonly label: string;
21
+ readonly color?: string;
22
+ readonly isFixed?: boolean;
23
+ readonly isDisabled?: boolean;
24
+ }
25
+ declare const Select: React.FC<SelectProps>;
26
+ export default Select;
@@ -0,0 +1,56 @@
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 }, rest, {
43
+ // value={
44
+ // isMulti
45
+ // ? options.filter(
46
+ // (option) =>
47
+ // Array.isArray(value) && (value as (string | number)[]).includes(option.value)
48
+ // )
49
+ // : options.find((option) => option.value === value) || value as CustomOption || null
50
+ // }
51
+ value: isMulti && Array.isArray(value)
52
+ ? value.map(function (v) { return options.find(function (option) { return option.value === v; }); })
53
+ : options.find(function (option) { return option.value === value; }) || value })));
54
+ };
55
+
56
+ export { Select as default };
@@ -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,17 @@
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
+ }
16
+ declare const Table: <T>({ columns, data, loading, emptyText }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
17
+ export default Table;
@@ -0,0 +1,19 @@
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;
8
+ return !loading && data.length === 0 ? (jsx(Empty, { description: emptyText || 'No Data' })) : (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: {
9
+ width: column.width ? "".concat(column.width, "px") : 'auto',
10
+ textAlign: column.align || 'left'
11
+ } }, { 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
12
+ ? column.render(record[column.dataIndex], record)
13
+ : typeof record[column.dataIndex] === 'object'
14
+ ? JSON.stringify(record[column.dataIndex]) // 将对象转换为字符串
15
+ : String(record[column.dataIndex]) // 确保它是一个字符串
16
+ }), colIndex)); }) }), rowIndex)); }) })] }))] })));
17
+ };
18
+
19
+ 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;
@@ -0,0 +1,21 @@
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 ButtonTabs = function (_a) {
6
+ var _b;
7
+ var activeKey = _a.activeKey, items = _a.items, onChange = _a.onChange;
8
+ var _c = useState(activeKey || ((_b = items[0]) === null || _b === void 0 ? void 0 : _b.key)), internalActiveKey = _c[0], setInternalActiveKey = _c[1];
9
+ var handleTabChange = function (key) {
10
+ if (onChange) {
11
+ onChange(key);
12
+ }
13
+ else {
14
+ setInternalActiveKey(key);
15
+ }
16
+ };
17
+ var currentKey = activeKey || internalActiveKey;
18
+ return (jsxs("div", { children: [jsx("div", __assign({ className: "foxit-tabs" }, { children: items.map(function (item) { return (jsx("button", __assign({ className: "foxit-tab-item ".concat(currentKey === item.key ? 'active' : ''), onClick: function () { return handleTabChange(item.key); } }, { children: item.label }), item.key)); }) })), jsx("div", __assign({ className: "foxit-tab-content" }, { children: items.map(function (item) { return item.key === currentKey && jsx("div", { children: item.children }, item.key); }) }))] }));
19
+ };
20
+
21
+ export { ButtonTabs as default };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import './tag.css';
3
+ interface TagProps {
4
+ color?: 'active' | 'canceled' | 'pending' | 'offline' | 'trial' | 'expired' | string;
5
+ children: React.ReactNode;
6
+ }
7
+ declare const Tag: React.FC<TagProps>;
8
+ export default Tag;