@publishfx/publish-components 2.0.3
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.
- package/README.md +191 -0
- package/dist/ActionButton/index.d.ts +10 -0
- package/dist/ActionButton/index.js +40 -0
- package/dist/ActionButton/index.module.js +9 -0
- package/dist/ActionButton/index_module.css +23 -0
- package/dist/ActionButton/interface.d.ts +12 -0
- package/dist/ActionButton/interface.js +9 -0
- package/dist/CommonModal/config.d.ts +8 -0
- package/dist/CommonModal/config.js +13 -0
- package/dist/CommonModal/confirm.d.ts +7 -0
- package/dist/CommonModal/confirm.js +132 -0
- package/dist/CommonModal/index.d.ts +2 -0
- package/dist/CommonModal/index.js +3 -0
- package/dist/CommonModal/interface.d.ts +17 -0
- package/dist/CommonModal/interface.js +0 -0
- package/dist/CommonModal/modal.d.ts +11 -0
- package/dist/CommonModal/modal.js +161 -0
- package/dist/CompareChange/index.d.ts +20 -0
- package/dist/CompareChange/index.js +66 -0
- package/dist/CustomTransfer/BaseTransfer.d.ts +35 -0
- package/dist/CustomTransfer/BaseTransfer.js +155 -0
- package/dist/CustomTransfer/SelectItemList.d.ts +9 -0
- package/dist/CustomTransfer/SelectItemList.js +54 -0
- package/dist/CustomTransfer/SelectTreeList.d.ts +43 -0
- package/dist/CustomTransfer/SelectTreeList.js +248 -0
- package/dist/CustomTransfer/SelectedItemList.d.ts +21 -0
- package/dist/CustomTransfer/SelectedItemList.js +132 -0
- package/dist/CustomTransfer/SimpleLink.d.ts +4 -0
- package/dist/CustomTransfer/SimpleLink.js +20 -0
- package/dist/CustomTransfer/index.d.ts +22 -0
- package/dist/CustomTransfer/index.js +92 -0
- package/dist/CustomTransfer/styled.d.ts +27 -0
- package/dist/CustomTransfer/styled.js +181 -0
- package/dist/PerformanceTable/ResizableTitle.d.ts +12 -0
- package/dist/PerformanceTable/ResizableTitle.js +85 -0
- package/dist/PerformanceTable/index.d.ts +4 -0
- package/dist/PerformanceTable/index.js +417 -0
- package/dist/PerformanceTable/interface.d.ts +47 -0
- package/dist/PerformanceTable/interface.js +0 -0
- package/dist/PerformanceTable/style.d.ts +19 -0
- package/dist/PerformanceTable/style.js +402 -0
- package/dist/PerformanceTable/useResizable.d.ts +29 -0
- package/dist/PerformanceTable/useResizable.js +108 -0
- package/dist/ReactSticky/Container.d.ts +19 -0
- package/dist/ReactSticky/Container.js +93 -0
- package/dist/ReactSticky/Sticky.d.ts +27 -0
- package/dist/ReactSticky/Sticky.js +123 -0
- package/dist/ReactSticky/index.d.ts +5 -0
- package/dist/ReactSticky/index.js +4 -0
- package/dist/assets/icons/403.js +15 -0
- package/dist/assets/icons/Icon403.d.ts +3 -0
- package/dist/assets/icons/Icon403.js +14 -0
- package/dist/assets/icons/IconAdd.d.ts +3 -0
- package/dist/assets/icons/IconAdd.js +24 -0
- package/dist/assets/icons/IconAim.d.ts +3 -0
- package/dist/assets/icons/IconAim.js +36 -0
- package/dist/assets/icons/IconBatchupload.d.ts +3 -0
- package/dist/assets/icons/IconBatchupload.js +23 -0
- package/dist/assets/icons/IconClose.d.ts +3 -0
- package/dist/assets/icons/IconClose.js +15 -0
- package/dist/assets/icons/IconDrag_sort.d.ts +3 -0
- package/dist/assets/icons/IconDrag_sort.js +28 -0
- package/dist/assets/icons/IconError.d.ts +3 -0
- package/dist/assets/icons/IconError.js +42 -0
- package/dist/assets/icons/IconExport.d.ts +3 -0
- package/dist/assets/icons/IconExport.js +15 -0
- package/dist/assets/icons/IconFolder.d.ts +3 -0
- package/dist/assets/icons/IconFolder.js +126 -0
- package/dist/assets/icons/IconOpen_down.d.ts +3 -0
- package/dist/assets/icons/IconOpen_down.js +13 -0
- package/dist/assets/icons/IconOpen_right.d.ts +3 -0
- package/dist/assets/icons/IconOpen_right.js +13 -0
- package/dist/assets/icons/IconPlus.d.ts +3 -0
- package/dist/assets/icons/IconPlus.js +17 -0
- package/dist/assets/icons/IconSearch.d.ts +3 -0
- package/dist/assets/icons/IconSearch.js +15 -0
- package/dist/assets/icons/IconSelected_transfer.d.ts +3 -0
- package/dist/assets/icons/IconSelected_transfer.js +15 -0
- package/dist/assets/icons/IconSettings.d.ts +3 -0
- package/dist/assets/icons/IconSettings.js +15 -0
- package/dist/assets/icons/IconUp_down.d.ts +3 -0
- package/dist/assets/icons/IconUp_down.js +15 -0
- package/dist/assets/icons/IconUpload.d.ts +3 -0
- package/dist/assets/icons/IconUpload.js +20 -0
- package/dist/assets/icons/Up_down.js +17 -0
- package/dist/assets/icons/add.js +28 -0
- package/dist/assets/icons/batchupload.js +24 -0
- package/dist/assets/icons/close.js +17 -0
- package/dist/assets/icons/data_increase.js +31 -0
- package/dist/assets/icons/data_no_change.js +19 -0
- package/dist/assets/icons/data_reduction.js +31 -0
- package/dist/assets/icons/drag_sort.js +30 -0
- package/dist/assets/icons/error.js +44 -0
- package/dist/assets/icons/export.js +16 -0
- package/dist/assets/icons/folder.js +128 -0
- package/dist/assets/icons/open_down.js +15 -0
- package/dist/assets/icons/open_right.js +15 -0
- package/dist/assets/icons/plus.js +19 -0
- package/dist/assets/icons/search.js +17 -0
- package/dist/assets/icons/selected.js +17 -0
- package/dist/assets/icons/selected_transfer.js +17 -0
- package/dist/assets/icons/settings.js +17 -0
- package/dist/assets/icons/upload.js +23 -0
- package/dist/assets/images/book.js +2 -0
- package/dist/assets/images/emptyVideo.js +2 -0
- package/dist/assets/images/excel.js +2 -0
- package/dist/assets/images/fail.js +2 -0
- package/dist/assets/images/file.js +2 -0
- package/dist/assets/images/noResult.js +2 -0
- package/dist/assets/images/platform/Apple.js +23 -0
- package/dist/assets/images/platform/Facebook.js +42 -0
- package/dist/assets/images/platform/Google.js +54 -0
- package/dist/assets/images/platform/Instagram.js +2 -0
- package/dist/assets/images/platform/TikTok.js +42 -0
- package/dist/assets/images/platform/Twitch.js +2 -0
- package/dist/assets/images/platform/Twitter.js +2 -0
- package/dist/assets/images/platform/Youtube.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/static/image/Instagram.png +0 -0
- package/dist/static/image/Twitch.png +0 -0
- package/dist/static/image/Twitter.png +0 -0
- package/dist/static/image/Youtube.png +0 -0
- package/dist/static/image/book.png +0 -0
- package/dist/static/image/emptyVideo.png +0 -0
- package/dist/static/image/excel.png +0 -0
- package/dist/static/image/fail.png +0 -0
- package/dist/static/image/file.png +0 -0
- package/dist/static/image/noResult.png +0 -0
- package/dist/static/svg/403.svg +22 -0
- package/dist/static/svg/Apple.svg +4 -0
- package/dist/static/svg/Facebook.svg +9 -0
- package/dist/static/svg/Google.svg +14 -0
- package/dist/static/svg/TikTok.svg +9 -0
- package/dist/static/svg/Up_down.svg +1 -0
- package/dist/static/svg/add.svg +1 -0
- package/dist/static/svg/batchupload.svg +1 -0
- package/dist/static/svg/close.svg +1 -0
- package/dist/static/svg/data_increase.svg +15 -0
- package/dist/static/svg/data_no_change.svg +1 -0
- package/dist/static/svg/data_reduction.svg +15 -0
- package/dist/static/svg/drag_sort.svg +1 -0
- package/dist/static/svg/error.svg +8 -0
- package/dist/static/svg/export.svg +1 -0
- package/dist/static/svg/folder.svg +36 -0
- package/dist/static/svg/open_down.svg +1 -0
- package/dist/static/svg/open_right.svg +8 -0
- package/dist/static/svg/plus.svg +3 -0
- package/dist/static/svg/search.svg +1 -0
- package/dist/static/svg/selected.svg +3 -0
- package/dist/static/svg/selected_transfer.svg +3 -0
- package/dist/static/svg/settings.svg +1 -0
- package/dist/static/svg/upload.svg +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# @moonton/publish-components
|
|
2
|
+
|
|
3
|
+
A React UI component library for the Publish platform, built with React, TypeScript, and styled-components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @moonton/publish-components
|
|
9
|
+
# or
|
|
10
|
+
npm install @moonton/publish-components
|
|
11
|
+
# or
|
|
12
|
+
yarn add @moonton/publish-components
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Peer Dependencies
|
|
16
|
+
|
|
17
|
+
This package requires the following peer dependencies:
|
|
18
|
+
- `react` (>=18.3.1)
|
|
19
|
+
- `react-dom` (>=18.3.1)
|
|
20
|
+
|
|
21
|
+
Make sure to install them in your project:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add react react-dom
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Components
|
|
28
|
+
|
|
29
|
+
### ActionButton
|
|
30
|
+
|
|
31
|
+
A customizable button component with predefined action types and icons.
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
import { ActionButton, ActionButtonType } from '@moonton/publish-components';
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
return (
|
|
38
|
+
<ActionButton
|
|
39
|
+
action={ActionButtonType.Export}
|
|
40
|
+
onClick={() => console.log('Export clicked')}
|
|
41
|
+
monitorId="export-button"
|
|
42
|
+
>
|
|
43
|
+
Export
|
|
44
|
+
</ActionButton>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Props:**
|
|
50
|
+
- `action`: `ActionButtonType` - The action type (export, batchupload, add, setting, upload)
|
|
51
|
+
- `monitorId?`: `string` - Monitoring ID for analytics
|
|
52
|
+
- All other `ButtonProps` from `@arco-design/web-react`
|
|
53
|
+
|
|
54
|
+
**Available Action Types:**
|
|
55
|
+
- `ActionButtonType.Export` - Export action
|
|
56
|
+
- `ActionButtonType.Batchupload` - Batch upload action
|
|
57
|
+
- `ActionButtonType.Add` - Add action
|
|
58
|
+
- `ActionButtonType.SETTING` - Settings action
|
|
59
|
+
- `ActionButtonType.Upload` - Upload action
|
|
60
|
+
|
|
61
|
+
### PerformanceTable
|
|
62
|
+
|
|
63
|
+
A high-performance data table component with column resizing, sorting, pagination, and advanced formatting features.
|
|
64
|
+
|
|
65
|
+
```jsx
|
|
66
|
+
import { PerformanceTable, PerformanceTableColumn } from '@moonton/publish-components';
|
|
67
|
+
|
|
68
|
+
const columns: PerformanceTableColumn[] = [
|
|
69
|
+
{
|
|
70
|
+
title: 'Name',
|
|
71
|
+
dataIndex: 'name',
|
|
72
|
+
minWidth: 100,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: 'Revenue',
|
|
76
|
+
dataIndex: 'revenue',
|
|
77
|
+
showCurrency: true,
|
|
78
|
+
showPercent: true,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
function App() {
|
|
83
|
+
return (
|
|
84
|
+
<PerformanceTable
|
|
85
|
+
columns={columns}
|
|
86
|
+
dataSource={data}
|
|
87
|
+
showPagination
|
|
88
|
+
pagination={{
|
|
89
|
+
pageSize: 10,
|
|
90
|
+
current: 1,
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Key Features:**
|
|
98
|
+
- Column resizing with min/max width constraints
|
|
99
|
+
- Number, currency, and percentage formatting
|
|
100
|
+
- Color scale visualization
|
|
101
|
+
- Custom formatters
|
|
102
|
+
- Sorting and pagination
|
|
103
|
+
- Row selection
|
|
104
|
+
- Summary rows
|
|
105
|
+
- Highlight settings for weekends/special dates
|
|
106
|
+
- Full-screen mode support
|
|
107
|
+
|
|
108
|
+
**Props:**
|
|
109
|
+
- `columns`: `PerformanceTableColumn[]` - Column configuration
|
|
110
|
+
- `dataSource?`: `T[]` - Table data
|
|
111
|
+
- `showPagination?`: `boolean` - Show pagination
|
|
112
|
+
- `pagination?`: `TableProps['pagination'] | false` - Pagination config
|
|
113
|
+
- `loading?`: `boolean` - Loading state
|
|
114
|
+
- `onSort?`: `(dataIndex: string, direction: 'ascend' | 'descend' | null) => void` - Sort callback
|
|
115
|
+
- `isFullScreen?`: `boolean` - Full screen mode
|
|
116
|
+
- And more... See TypeScript definitions for complete API
|
|
117
|
+
|
|
118
|
+
### ReactSticky
|
|
119
|
+
|
|
120
|
+
Sticky positioning components for creating sticky headers, sidebars, and other elements.
|
|
121
|
+
|
|
122
|
+
```jsx
|
|
123
|
+
import { Sticky, StickyContainer } from '@moonton/publish-components';
|
|
124
|
+
|
|
125
|
+
function App() {
|
|
126
|
+
return (
|
|
127
|
+
<StickyContainer>
|
|
128
|
+
<Sticky>
|
|
129
|
+
<div>This will stick to the top when scrolling</div>
|
|
130
|
+
</Sticky>
|
|
131
|
+
<div>Regular content</div>
|
|
132
|
+
</StickyContainer>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Components:**
|
|
138
|
+
- `StickyContainer` - Container component that manages sticky context
|
|
139
|
+
- `Sticky` - Component that sticks to a position when scrolling
|
|
140
|
+
|
|
141
|
+
### Icons
|
|
142
|
+
|
|
143
|
+
A collection of SVG icon components.
|
|
144
|
+
|
|
145
|
+
```jsx
|
|
146
|
+
import {
|
|
147
|
+
IconExport,
|
|
148
|
+
IconAdd,
|
|
149
|
+
IconUpload,
|
|
150
|
+
IconSearch,
|
|
151
|
+
// ... and more
|
|
152
|
+
} from '@moonton/publish-components';
|
|
153
|
+
|
|
154
|
+
function App() {
|
|
155
|
+
return (
|
|
156
|
+
<div>
|
|
157
|
+
<IconExport width={24} height={24} />
|
|
158
|
+
<IconAdd width={24} height={24} />
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Available Icons:**
|
|
165
|
+
- Icon403, IconAdd, IconBatchupload, IconClose, IconDrag_sort
|
|
166
|
+
- IconError, IconExport, IconFolder, IconOpen_down, IconOpen_right
|
|
167
|
+
- IconPlus, IconSearch, IconSelected_transfer, IconSettings
|
|
168
|
+
- IconUp_down, IconUpload
|
|
169
|
+
- And more platform icons (Apple, Facebook, Google, Instagram, TikTok, Twitch, Twitter, Youtube)
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
### Build
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
pnpm build
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Development Mode (Watch)
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
pnpm dev
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## TypeScript Support
|
|
186
|
+
|
|
187
|
+
This package is written in TypeScript and includes full type definitions. All components and their props are fully typed.
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
ISC
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ButtonProps } from "@arco-design/web-react";
|
|
3
|
+
import { ActionButtonType } from "./interface";
|
|
4
|
+
type ActionButtonProps = {
|
|
5
|
+
action: ActionButtonType;
|
|
6
|
+
monitorId?: string;
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
} & ButtonProps;
|
|
9
|
+
declare const ActionButton: (props: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default ActionButton;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { omit } from "lodash";
|
|
4
|
+
import { Button } from "@arco-design/web-react";
|
|
5
|
+
import IconExport from "../assets/icons/IconExport.js";
|
|
6
|
+
import IconBatchupload from "../assets/icons/IconBatchupload.js";
|
|
7
|
+
import IconAdd from "../assets/icons/IconAdd.js";
|
|
8
|
+
import IconSettings from "../assets/icons/IconSettings.js";
|
|
9
|
+
import IconUpload from "../assets/icons/IconUpload.js";
|
|
10
|
+
import index_module from "./index.module.js";
|
|
11
|
+
const IconComponents = {
|
|
12
|
+
export: IconExport,
|
|
13
|
+
batchupload: IconBatchupload,
|
|
14
|
+
add: IconAdd,
|
|
15
|
+
setting: IconSettings,
|
|
16
|
+
upload: IconUpload
|
|
17
|
+
};
|
|
18
|
+
const ActionButton = (props)=>{
|
|
19
|
+
const getIcon = (action)=>{
|
|
20
|
+
const Component = IconComponents[action];
|
|
21
|
+
return props.icon ? props.icon : Component && /*#__PURE__*/ jsx(Component, {
|
|
22
|
+
width: 16,
|
|
23
|
+
height: 16
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
return /*#__PURE__*/ jsx("div", {
|
|
27
|
+
id: props.monitorId,
|
|
28
|
+
className: index_module.actionbutton_wrapper,
|
|
29
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
30
|
+
type: "text",
|
|
31
|
+
className: `${index_module["arco-btn-text"]} ${props.disabled ? index_module.disabled : ''}`,
|
|
32
|
+
...omit(props, [
|
|
33
|
+
"monitorId"
|
|
34
|
+
]),
|
|
35
|
+
icon: getIcon(props.action)
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const src_ActionButton = ActionButton;
|
|
40
|
+
export { src_ActionButton as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./index_module.css";
|
|
2
|
+
const index_module = {
|
|
3
|
+
actionbutton_wrapper: "actionbutton_wrapper-RqUrTb",
|
|
4
|
+
actionbuttonWrapper: "actionbutton_wrapper-RqUrTb",
|
|
5
|
+
"arco-btn-text": "arco-btn-text-ojQRJu",
|
|
6
|
+
arcoBtnText: "arco-btn-text-ojQRJu",
|
|
7
|
+
disabled: "disabled-op18gA"
|
|
8
|
+
};
|
|
9
|
+
export { index_module as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.actionbutton_wrapper-RqUrTb {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.actionbutton_wrapper-RqUrTb.actionbutton_wrapper-RqUrTb .arco-btn-text-ojQRJu {
|
|
6
|
+
color: var(--color-text-1);
|
|
7
|
+
padding: 0 10px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.actionbutton_wrapper-RqUrTb.actionbutton_wrapper-RqUrTb .arco-btn-text-ojQRJu svg {
|
|
11
|
+
vertical-align: -3px;
|
|
12
|
+
fill: currentColor;
|
|
13
|
+
color: var(--color-text-1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.actionbutton_wrapper-RqUrTb.actionbutton_wrapper-RqUrTb .arco-btn-text-ojQRJu > svg + span {
|
|
17
|
+
margin-left: 4px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.actionbutton_wrapper-RqUrTb .disabled-op18gA, .actionbutton_wrapper-RqUrTb .disabled-op18gA svg {
|
|
21
|
+
color: #c9cdd4;
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ButtonProps } from "@arco-design/web-react";
|
|
2
|
+
export declare enum ActionButtonType {
|
|
3
|
+
Export = "export",
|
|
4
|
+
Batchupload = "batchupload",
|
|
5
|
+
Add = "add",
|
|
6
|
+
SETTING = "setting",
|
|
7
|
+
Upload = "upload"
|
|
8
|
+
}
|
|
9
|
+
export declare type ActionButtonProps = {
|
|
10
|
+
action: ActionButtonType;
|
|
11
|
+
monitorId?: string;
|
|
12
|
+
} & ButtonProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var interface_ActionButtonType = /*#__PURE__*/ function(ActionButtonType) {
|
|
2
|
+
ActionButtonType["Export"] = "export";
|
|
3
|
+
ActionButtonType["Batchupload"] = "batchupload";
|
|
4
|
+
ActionButtonType["Add"] = "add";
|
|
5
|
+
ActionButtonType["SETTING"] = "setting";
|
|
6
|
+
ActionButtonType["Upload"] = "upload";
|
|
7
|
+
return ActionButtonType;
|
|
8
|
+
}({});
|
|
9
|
+
export { interface_ActionButtonType as ActionButtonType };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ModalConfigType = {
|
|
2
|
+
prefixCls?: string;
|
|
3
|
+
simple?: boolean;
|
|
4
|
+
showIcon?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const setModalConfig: (config: ModalConfigType) => void;
|
|
7
|
+
export declare const getModalConfig: () => ModalConfigType;
|
|
8
|
+
export declare const destroyList: Array<() => void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let modalConfig = {
|
|
2
|
+
simple: true,
|
|
3
|
+
showIcon: false
|
|
4
|
+
};
|
|
5
|
+
const setModalConfig = (config)=>{
|
|
6
|
+
modalConfig = {
|
|
7
|
+
...modalConfig,
|
|
8
|
+
...config
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const getModalConfig = ()=>modalConfig;
|
|
12
|
+
const destroyList = [];
|
|
13
|
+
export { destroyList, getModalConfig, setModalConfig };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfirmProps } from './interface';
|
|
2
|
+
export declare const normalizeConfig: (_config: ConfirmProps) => ConfirmProps;
|
|
3
|
+
declare function confirm(config: ConfirmProps, renderFunc?: (props: ConfirmProps) => void): {
|
|
4
|
+
close: () => void;
|
|
5
|
+
update: (newConfig: ConfirmProps) => void;
|
|
6
|
+
};
|
|
7
|
+
export default confirm;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { IconCheckCircleFill, IconCloseCircleFill, IconExclamationCircleFill, IconInfoCircleFill } from "@arco-design/web-react/icon";
|
|
5
|
+
import IconClose from "../assets/icons/IconClose.js";
|
|
6
|
+
import modal from "./modal.js";
|
|
7
|
+
import { destroyList, getModalConfig } from "./config.js";
|
|
8
|
+
function ConfirmModal(props) {
|
|
9
|
+
const { simple } = getModalConfig();
|
|
10
|
+
return /*#__PURE__*/ jsx(modal, {
|
|
11
|
+
simple: simple,
|
|
12
|
+
...props,
|
|
13
|
+
children: props.content
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const normalizeConfig = (_config)=>{
|
|
17
|
+
const showIcon = _config.showIcon || false;
|
|
18
|
+
if (_config.isNotice) {
|
|
19
|
+
let icon = _config.icon;
|
|
20
|
+
if (!icon && null !== icon) switch(_config.noticeType){
|
|
21
|
+
case 'info':
|
|
22
|
+
icon = /*#__PURE__*/ jsx(IconInfoCircleFill, {});
|
|
23
|
+
break;
|
|
24
|
+
case 'success':
|
|
25
|
+
icon = /*#__PURE__*/ jsx(IconCheckCircleFill, {});
|
|
26
|
+
break;
|
|
27
|
+
case 'warning':
|
|
28
|
+
icon = /*#__PURE__*/ jsx(IconExclamationCircleFill, {});
|
|
29
|
+
break;
|
|
30
|
+
case 'error':
|
|
31
|
+
icon = /*#__PURE__*/ jsx(IconCloseCircleFill, {});
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
_config.title = /*#__PURE__*/ jsxs("span", {
|
|
37
|
+
children: [
|
|
38
|
+
showIcon && icon,
|
|
39
|
+
_config.title
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
_config.hideCancel = true;
|
|
43
|
+
} else _config.title = /*#__PURE__*/ jsxs("span", {
|
|
44
|
+
children: [
|
|
45
|
+
showIcon && null !== _config.icon && (_config.icon || /*#__PURE__*/ jsx(IconExclamationCircleFill, {})),
|
|
46
|
+
_config.title
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
return _config;
|
|
50
|
+
};
|
|
51
|
+
function confirm_confirm(config, renderFunc) {
|
|
52
|
+
const div = document.createElement('div');
|
|
53
|
+
document.body.appendChild(div);
|
|
54
|
+
const root = createRoot(div);
|
|
55
|
+
function render(props) {
|
|
56
|
+
root.render(/*#__PURE__*/ jsx(ConfirmModal, {
|
|
57
|
+
closeIcon: /*#__PURE__*/ jsx(IconClose, {}),
|
|
58
|
+
...props,
|
|
59
|
+
onCancel: onCancel
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
const renderFunction = renderFunc || render;
|
|
63
|
+
let modalConfig = {
|
|
64
|
+
...config,
|
|
65
|
+
visible: false
|
|
66
|
+
};
|
|
67
|
+
const onOk = ()=>{
|
|
68
|
+
let ret;
|
|
69
|
+
const _onOk = config.onOk || config.onConfirm;
|
|
70
|
+
if (_onOk) ret = _onOk();
|
|
71
|
+
if (ret && ret.then) {
|
|
72
|
+
modalConfig.confirmLoading = true;
|
|
73
|
+
renderFunction(modalConfig);
|
|
74
|
+
ret.then(()=>{
|
|
75
|
+
onCancel(true);
|
|
76
|
+
}, (e)=>{
|
|
77
|
+
console.error(e);
|
|
78
|
+
modalConfig.confirmLoading = false;
|
|
79
|
+
renderFunction(modalConfig);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (!ret) onCancel(true);
|
|
83
|
+
};
|
|
84
|
+
modalConfig.onOk = onOk;
|
|
85
|
+
modalConfig = normalizeConfig(modalConfig);
|
|
86
|
+
modalConfig.visible = true;
|
|
87
|
+
renderFunction(modalConfig);
|
|
88
|
+
function destroy() {
|
|
89
|
+
root.unmount();
|
|
90
|
+
if (div.parentNode) div.parentNode.removeChild(div);
|
|
91
|
+
for(let i = 0; i < destroyList.length; i++){
|
|
92
|
+
const fn = destroyList[i];
|
|
93
|
+
if (fn === close) {
|
|
94
|
+
destroyList.splice(i, 1);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function onCancel(isOnOk) {
|
|
100
|
+
!isOnOk && config.onCancel && config.onCancel();
|
|
101
|
+
modalConfig.visible = false;
|
|
102
|
+
modalConfig.afterClose = ()=>{
|
|
103
|
+
config.afterClose && config.afterClose();
|
|
104
|
+
destroy();
|
|
105
|
+
};
|
|
106
|
+
renderFunction(modalConfig);
|
|
107
|
+
}
|
|
108
|
+
function update(newConfig) {
|
|
109
|
+
modalConfig = {
|
|
110
|
+
...modalConfig,
|
|
111
|
+
title: config.title,
|
|
112
|
+
...newConfig
|
|
113
|
+
};
|
|
114
|
+
modalConfig = normalizeConfig(modalConfig);
|
|
115
|
+
renderFunction(modalConfig);
|
|
116
|
+
}
|
|
117
|
+
function close() {
|
|
118
|
+
modalConfig.visible = false;
|
|
119
|
+
modalConfig.afterClose = ()=>{
|
|
120
|
+
config.afterClose && config.afterClose();
|
|
121
|
+
destroy();
|
|
122
|
+
};
|
|
123
|
+
renderFunction(modalConfig);
|
|
124
|
+
}
|
|
125
|
+
destroyList.push(close);
|
|
126
|
+
return {
|
|
127
|
+
close,
|
|
128
|
+
update
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const CommonModal_confirm = confirm_confirm;
|
|
132
|
+
export { CommonModal_confirm as default, normalizeConfig };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ModalProps } from '@arco-design/web-react/es/Modal/interface';
|
|
3
|
+
export interface CommonModalProps extends ModalProps {
|
|
4
|
+
footerLeft?: ReactNode;
|
|
5
|
+
customButtons?: ReactNode;
|
|
6
|
+
isFixHeight?: boolean;
|
|
7
|
+
isCancelShow?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ConfirmProps extends CommonModalProps {
|
|
10
|
+
content?: ReactNode;
|
|
11
|
+
showIcon?: boolean;
|
|
12
|
+
icon?: ReactNode | null;
|
|
13
|
+
isNotice?: boolean;
|
|
14
|
+
noticeType?: string;
|
|
15
|
+
isCustomNotice?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type { ModalReturnProps } from '@arco-design/web-react/es/Modal/interface';
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, PropsWithChildren } from 'react';
|
|
2
|
+
import { CommonModalProps, ConfirmProps, ModalReturnProps } from './interface';
|
|
3
|
+
export interface ModalComponent extends ForwardRefExoticComponent<PropsWithChildren<CommonModalProps>> {
|
|
4
|
+
confirm: (props: ConfirmProps) => ModalReturnProps;
|
|
5
|
+
info: (props: ConfirmProps) => ModalReturnProps;
|
|
6
|
+
success: (props: ConfirmProps) => ModalReturnProps;
|
|
7
|
+
warning: (props: ConfirmProps) => ModalReturnProps;
|
|
8
|
+
error: (props: ConfirmProps) => ModalReturnProps;
|
|
9
|
+
}
|
|
10
|
+
declare const ExportedModalComponent: ModalComponent;
|
|
11
|
+
export default ExportedModalComponent;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Modal } from "@arco-design/web-react";
|
|
4
|
+
import styled_components from "styled-components";
|
|
5
|
+
import confirm_0 from "./confirm.js";
|
|
6
|
+
const StyledModal = styled_components(Modal)`
|
|
7
|
+
&.arco-modal {
|
|
8
|
+
border-radius: 12px;
|
|
9
|
+
|
|
10
|
+
.arco-modal-close-icon {
|
|
11
|
+
font-size: 20px;
|
|
12
|
+
top: 32px;
|
|
13
|
+
right: 32px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.arco-modal-header {
|
|
17
|
+
height: 79px;
|
|
18
|
+
|
|
19
|
+
.arco-modal-title {
|
|
20
|
+
text-align: left;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
font-size: 18px;
|
|
23
|
+
line-height: 26px;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.arco-modal-header,
|
|
28
|
+
.arco-modal-footer {
|
|
29
|
+
padding: 24px 32px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.arco-modal-content {
|
|
33
|
+
padding: 16px 32px;
|
|
34
|
+
/* TODO: fix select dropdown style add max height */
|
|
35
|
+
/* 设置弹框整体最大高度为600px */
|
|
36
|
+
/* max-height: 408px;
|
|
37
|
+
overflow: auto; */
|
|
38
|
+
word-wrap: break-word;
|
|
39
|
+
word-break: break-all;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.arco-fix-height-modal {
|
|
43
|
+
height: 600px;
|
|
44
|
+
|
|
45
|
+
.arco-modal-content {
|
|
46
|
+
height: 408px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.arco-modal-simple {
|
|
52
|
+
width: 500px;
|
|
53
|
+
padding: 0;
|
|
54
|
+
|
|
55
|
+
&.arco-notice-modal {
|
|
56
|
+
width: 420px;
|
|
57
|
+
|
|
58
|
+
.arco-modal-footer,
|
|
59
|
+
.arco-modal-content,
|
|
60
|
+
.arco-modal-header {
|
|
61
|
+
border: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.arco-modal-content {
|
|
65
|
+
padding: 0 32px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.arco-modal-footer,
|
|
70
|
+
.arco-modal-content,
|
|
71
|
+
.arco-modal-header {
|
|
72
|
+
height: unset;
|
|
73
|
+
margin: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.arco-modal-header {
|
|
77
|
+
border-bottom: 1px solid var(--color-neutral-3);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.arco-modal-footer {
|
|
81
|
+
border-top: 1px solid var(--color-neutral-3);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.arco-modal-close-icon {
|
|
85
|
+
top: 24px;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
const Footer = styled_components.div`
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: baseline;
|
|
92
|
+
|
|
93
|
+
.footer-left {
|
|
94
|
+
flex: 1;
|
|
95
|
+
text-align: left;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.button-groups > .arco-btn {
|
|
99
|
+
margin-left: 16px;
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
const CommonModal = ({ footerLeft, customButtons, className, isFixHeight = false, isCancelShow = true, ...props })=>{
|
|
103
|
+
let clazzName = [];
|
|
104
|
+
if (className) clazzName = 'string' == typeof className ? [
|
|
105
|
+
className
|
|
106
|
+
] : className;
|
|
107
|
+
if (isFixHeight) clazzName.push('arco-fix-height-modal');
|
|
108
|
+
return /*#__PURE__*/ jsx(StyledModal, {
|
|
109
|
+
autoFocus: false,
|
|
110
|
+
maskClosable: false,
|
|
111
|
+
className: clazzName,
|
|
112
|
+
footer: (cancelButtonNode, okButtonNode)=>/*#__PURE__*/ jsxs(Footer, {
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ jsx("div", {
|
|
115
|
+
className: "footer-left",
|
|
116
|
+
children: footerLeft
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ jsx("div", {
|
|
119
|
+
className: "button-groups",
|
|
120
|
+
children: customButtons ? customButtons : /*#__PURE__*/ jsxs(Fragment, {
|
|
121
|
+
children: [
|
|
122
|
+
isCancelShow && cancelButtonNode,
|
|
123
|
+
okButtonNode
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
}),
|
|
129
|
+
...props
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
function wrappedConfirm({ className, noticeType, isCustomNotice = true, ...rest }) {
|
|
133
|
+
let clazzName = [];
|
|
134
|
+
if (className) clazzName = 'string' == typeof className ? [
|
|
135
|
+
className
|
|
136
|
+
] : className;
|
|
137
|
+
if (isCustomNotice || confirmMethods.includes(noticeType)) clazzName.push('arco-notice-modal');
|
|
138
|
+
return confirm_0({
|
|
139
|
+
className: clazzName,
|
|
140
|
+
noticeType,
|
|
141
|
+
...rest
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const ExportedModalComponent = CommonModal;
|
|
145
|
+
ExportedModalComponent.displayName = 'Modal';
|
|
146
|
+
ExportedModalComponent.confirm = (props)=>wrappedConfirm(props);
|
|
147
|
+
const confirmMethods = [
|
|
148
|
+
'info',
|
|
149
|
+
'success',
|
|
150
|
+
'warning',
|
|
151
|
+
'error'
|
|
152
|
+
];
|
|
153
|
+
confirmMethods.forEach((type)=>{
|
|
154
|
+
ExportedModalComponent[type] = (props)=>wrappedConfirm({
|
|
155
|
+
...props,
|
|
156
|
+
isNotice: true,
|
|
157
|
+
noticeType: type
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
const modal = ExportedModalComponent;
|
|
161
|
+
export { modal as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
export declare const formatPercentage: (value?: number | string, decimalPlaces?: number) => string;
|
|
3
|
+
export interface ChangeRateProps {
|
|
4
|
+
/** 数值,可以是数字或字符串 */
|
|
5
|
+
value: string | number;
|
|
6
|
+
fontSize?: number;
|
|
7
|
+
fontWeight?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 通用涨跌幅组件
|
|
11
|
+
* @param value - 数值(可为空)
|
|
12
|
+
* @returns JSX.Element
|
|
13
|
+
*
|
|
14
|
+
* 示例:
|
|
15
|
+
* - 正值:绿色向上箭头 + 绿色数值
|
|
16
|
+
* - 负值:红色向下箭头 + 红色数值
|
|
17
|
+
* - 零值/空值:灰色无变化图标 + 灰色数值或 '-'
|
|
18
|
+
*/
|
|
19
|
+
declare const CompareChange: FunctionComponent<ChangeRateProps>;
|
|
20
|
+
export default CompareChange;
|