@qq1948037137/adminsmart-ui 0.0.0-stage → 0.1.21
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 +76 -2
- package/dist/icons.cjs +25 -0
- package/dist/icons.cjs.map +1 -0
- package/dist/icons.d.cts +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +3 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.cjs +1278 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +420 -0
- package/dist/index.d.ts +420 -0
- package/dist/index.js +1199 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/zh_CN.cjs +40 -0
- package/dist/locale/zh_CN.cjs.map +1 -0
- package/dist/locale/zh_CN.d.cts +5 -0
- package/dist/locale/zh_CN.d.ts +5 -0
- package/dist/locale/zh_CN.js +9 -0
- package/dist/locale/zh_CN.js.map +1 -0
- package/package.json +103 -4
- package/styles/composites.css +143 -0
- package/styles/scrollbars.css +48 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
// src/components/Button.ts
|
|
2
|
+
import { Button as AntButton } from "antd";
|
|
3
|
+
|
|
4
|
+
// src/internal/wrapAntComponent.tsx
|
|
5
|
+
import { createElement, forwardRef } from "react";
|
|
6
|
+
var REACT_STATIC_KEYS = /* @__PURE__ */ new Set([
|
|
7
|
+
"$$typeof",
|
|
8
|
+
"render",
|
|
9
|
+
"displayName",
|
|
10
|
+
"name",
|
|
11
|
+
"length",
|
|
12
|
+
"prototype",
|
|
13
|
+
"caller",
|
|
14
|
+
"arguments"
|
|
15
|
+
]);
|
|
16
|
+
function wrapAntComponent(component, displayName, defaults = {}, normalizeProps) {
|
|
17
|
+
const wrapped = forwardRef((props, ref) => {
|
|
18
|
+
const mergedProps = { ...defaults, ...props };
|
|
19
|
+
const normalizedProps = normalizeProps ? normalizeProps(mergedProps) : mergedProps;
|
|
20
|
+
const forwardedProps = ref == null ? normalizedProps : { ...normalizedProps, ref };
|
|
21
|
+
return createElement(component, forwardedProps);
|
|
22
|
+
});
|
|
23
|
+
for (const key of Reflect.ownKeys(component)) {
|
|
24
|
+
if (REACT_STATIC_KEYS.has(key) || Reflect.has(wrapped, key)) continue;
|
|
25
|
+
const descriptor = Object.getOwnPropertyDescriptor(component, key);
|
|
26
|
+
if (descriptor) Object.defineProperty(wrapped, key, descriptor);
|
|
27
|
+
}
|
|
28
|
+
wrapped.displayName = `Ui${displayName}`;
|
|
29
|
+
return wrapped;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/components/Button.ts
|
|
33
|
+
var Button = Object.assign(wrapAntComponent(AntButton, "Button"), {
|
|
34
|
+
Group: wrapAntComponent(AntButton.Group, "Button.Group")
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// src/components/ThemeModeButton.tsx
|
|
38
|
+
import { MoonOutlined, SunOutlined } from "@ant-design/icons";
|
|
39
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
40
|
+
|
|
41
|
+
// src/components/overlay.ts
|
|
42
|
+
import { Popover as AntPopover, Tooltip as AntTooltip } from "antd";
|
|
43
|
+
var Popover = wrapAntComponent(AntPopover, "Popover");
|
|
44
|
+
var Tooltip = Object.assign(wrapAntComponent(AntTooltip, "Tooltip"), {
|
|
45
|
+
UniqueProvider: wrapAntComponent(AntTooltip.UniqueProvider, "Tooltip.UniqueProvider")
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// src/components/ThemeModeButton.tsx
|
|
49
|
+
import { jsx } from "react/jsx-runtime";
|
|
50
|
+
var ThemeModeButton = forwardRef2(
|
|
51
|
+
function ThemeModeButton2({ mode, onModeChange, tooltipProps, onClick, ...props }, ref) {
|
|
52
|
+
const nextMode = mode === "dark" ? "light" : "dark";
|
|
53
|
+
const actionLabel = nextMode === "dark" ? "\u5207\u6362\u5230\u591C\u95F4\u4E3B\u9898" : "\u5207\u6362\u5230\u65E5\u95F4\u4E3B\u9898";
|
|
54
|
+
const nextModeIcon = nextMode === "dark" ? /* @__PURE__ */ jsx(MoonOutlined, { "aria-hidden": true }) : /* @__PURE__ */ jsx(SunOutlined, { "aria-hidden": true });
|
|
55
|
+
const handleClick = (event) => {
|
|
56
|
+
onClick?.(event);
|
|
57
|
+
if (!event.defaultPrevented) onModeChange?.(nextMode);
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: actionLabel, ...tooltipProps, children: /* @__PURE__ */ jsx(
|
|
60
|
+
Button,
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
size: "large",
|
|
64
|
+
icon: nextModeIcon,
|
|
65
|
+
"aria-label": actionLabel,
|
|
66
|
+
"aria-pressed": mode === "dark",
|
|
67
|
+
...props,
|
|
68
|
+
ref,
|
|
69
|
+
onClick: handleClick
|
|
70
|
+
}
|
|
71
|
+
) });
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// src/components/ConfigProvider.ts
|
|
76
|
+
import { ConfigProvider as AntConfigProvider } from "antd";
|
|
77
|
+
var ConfigProvider = wrapAntComponent(AntConfigProvider, "ConfigProvider");
|
|
78
|
+
|
|
79
|
+
// src/components/Drawer.ts
|
|
80
|
+
import { Drawer as AntDrawer } from "antd";
|
|
81
|
+
var Drawer = wrapAntComponent(AntDrawer, "Drawer", {
|
|
82
|
+
placement: "right",
|
|
83
|
+
width: "min(560px, 100vw)"
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// src/components/Form.ts
|
|
87
|
+
import { Form as AntForm } from "antd";
|
|
88
|
+
var Form = Object.assign(wrapAntComponent(AntForm, "Form"), {
|
|
89
|
+
Item: wrapAntComponent(AntForm.Item, "Form.Item"),
|
|
90
|
+
List: wrapAntComponent(AntForm.List, "Form.List"),
|
|
91
|
+
ErrorList: wrapAntComponent(AntForm.ErrorList, "Form.ErrorList"),
|
|
92
|
+
Provider: wrapAntComponent(AntForm.Provider, "Form.Provider")
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/components/Input.ts
|
|
96
|
+
import { Input as AntInput } from "antd";
|
|
97
|
+
var Input = Object.assign(wrapAntComponent(AntInput, "Input"), {
|
|
98
|
+
Group: wrapAntComponent(AntInput.Group, "Input.Group"),
|
|
99
|
+
Search: wrapAntComponent(AntInput.Search, "Input.Search"),
|
|
100
|
+
TextArea: wrapAntComponent(AntInput.TextArea, "Input.TextArea"),
|
|
101
|
+
Password: wrapAntComponent(AntInput.Password, "Input.Password"),
|
|
102
|
+
OTP: wrapAntComponent(AntInput.OTP, "Input.OTP")
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// src/components/Modal.ts
|
|
106
|
+
import { Modal as AntModal } from "antd";
|
|
107
|
+
var Modal = wrapAntComponent(AntModal, "Modal");
|
|
108
|
+
|
|
109
|
+
// src/components/Select.ts
|
|
110
|
+
import { Select as AntSelect } from "antd";
|
|
111
|
+
var Select = Object.assign(wrapAntComponent(AntSelect, "Select"), {
|
|
112
|
+
Option: wrapAntComponent(AntSelect.Option, "Select.Option"),
|
|
113
|
+
OptGroup: wrapAntComponent(AntSelect.OptGroup, "Select.OptGroup")
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// src/components/Table.ts
|
|
117
|
+
import { Table as AntTable } from "antd";
|
|
118
|
+
import { createElement as createElement2 } from "react";
|
|
119
|
+
|
|
120
|
+
// src/components/feedback.ts
|
|
121
|
+
import {
|
|
122
|
+
Alert as AntAlert,
|
|
123
|
+
App as AntApp,
|
|
124
|
+
Empty as AntEmpty,
|
|
125
|
+
Progress as AntProgress,
|
|
126
|
+
Result as AntResult,
|
|
127
|
+
Spin as AntSpin,
|
|
128
|
+
Statistic as AntStatistic,
|
|
129
|
+
Tag as AntTag,
|
|
130
|
+
Timeline as AntTimeline
|
|
131
|
+
} from "antd";
|
|
132
|
+
var Alert = Object.assign(wrapAntComponent(AntAlert, "Alert"), {
|
|
133
|
+
ErrorBoundary: wrapAntComponent(AntAlert.ErrorBoundary, "Alert.ErrorBoundary")
|
|
134
|
+
});
|
|
135
|
+
var App = wrapAntComponent(AntApp, "App");
|
|
136
|
+
var Empty = wrapAntComponent(AntEmpty, "Empty");
|
|
137
|
+
var Progress = wrapAntComponent(AntProgress, "Progress");
|
|
138
|
+
var Result = wrapAntComponent(AntResult, "Result");
|
|
139
|
+
var Spin = wrapAntComponent(AntSpin, "Spin");
|
|
140
|
+
var Statistic = Object.assign(wrapAntComponent(AntStatistic, "Statistic"), {
|
|
141
|
+
Timer: wrapAntComponent(AntStatistic.Timer, "Statistic.Timer"),
|
|
142
|
+
Countdown: wrapAntComponent(AntStatistic.Countdown, "Statistic.Countdown")
|
|
143
|
+
});
|
|
144
|
+
var Tag = Object.assign(wrapAntComponent(AntTag, "Tag"), {
|
|
145
|
+
CheckableTag: wrapAntComponent(AntTag.CheckableTag, "Tag.CheckableTag"),
|
|
146
|
+
CheckableTagGroup: wrapAntComponent(AntTag.CheckableTagGroup, "Tag.CheckableTagGroup")
|
|
147
|
+
});
|
|
148
|
+
var Timeline = Object.assign(wrapAntComponent(AntTimeline, "Timeline"), {
|
|
149
|
+
Item: wrapAntComponent(AntTimeline.Item, "Timeline.Item")
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// src/components/TableEmpty.tsx
|
|
153
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
154
|
+
function TableEmpty({ className, description = "\u6682\u65E0\u6570\u636E", image = Empty.PRESENTED_IMAGE_SIMPLE, ...props }) {
|
|
155
|
+
const classes = ["adminsmart-table-empty", className].filter(Boolean).join(" ");
|
|
156
|
+
return /* @__PURE__ */ jsx2(Empty, { ...props, className: classes, description, image });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/components/Table.ts
|
|
160
|
+
function normalizeTableProps(props) {
|
|
161
|
+
const locale = props.locale ?? {};
|
|
162
|
+
const content = locale.emptyText;
|
|
163
|
+
const emptyText = content === void 0 ? createElement2(TableEmpty) : typeof content === "string" || typeof content === "number" ? createElement2(TableEmpty, { description: content }) : content;
|
|
164
|
+
return { ...props, locale: { ...locale, emptyText } };
|
|
165
|
+
}
|
|
166
|
+
var Summary = Object.assign(wrapAntComponent(AntTable.Summary, "Table.Summary"), {
|
|
167
|
+
Row: wrapAntComponent(AntTable.Summary.Row, "Table.Summary.Row"),
|
|
168
|
+
Cell: wrapAntComponent(AntTable.Summary.Cell, "Table.Summary.Cell")
|
|
169
|
+
});
|
|
170
|
+
var Table = Object.assign(wrapAntComponent(AntTable, "Table", {}, normalizeTableProps), {
|
|
171
|
+
Column: wrapAntComponent(AntTable.Column, "Table.Column"),
|
|
172
|
+
ColumnGroup: wrapAntComponent(AntTable.ColumnGroup, "Table.ColumnGroup"),
|
|
173
|
+
Summary
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// src/components/Typography.ts
|
|
177
|
+
import { Typography as AntTypography } from "antd";
|
|
178
|
+
var Typography = Object.assign(wrapAntComponent(AntTypography, "Typography"), {
|
|
179
|
+
Text: wrapAntComponent(AntTypography.Text, "Typography.Text"),
|
|
180
|
+
Link: wrapAntComponent(AntTypography.Link, "Typography.Link"),
|
|
181
|
+
Title: wrapAntComponent(AntTypography.Title, "Typography.Title"),
|
|
182
|
+
Paragraph: wrapAntComponent(AntTypography.Paragraph, "Typography.Paragraph")
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// src/components/formControls.ts
|
|
186
|
+
import {
|
|
187
|
+
AutoComplete as AntAutoComplete,
|
|
188
|
+
Checkbox as AntCheckbox,
|
|
189
|
+
DatePicker as AntDatePicker,
|
|
190
|
+
InputNumber as AntInputNumber,
|
|
191
|
+
Radio as AntRadio,
|
|
192
|
+
Slider as AntSlider,
|
|
193
|
+
Switch as AntSwitch,
|
|
194
|
+
TreeSelect as AntTreeSelect,
|
|
195
|
+
Upload as AntUpload
|
|
196
|
+
} from "antd";
|
|
197
|
+
var AutoComplete = Object.assign(wrapAntComponent(AntAutoComplete, "AutoComplete"), {
|
|
198
|
+
Option: wrapAntComponent(AntAutoComplete.Option, "AutoComplete.Option")
|
|
199
|
+
});
|
|
200
|
+
var Checkbox = Object.assign(wrapAntComponent(AntCheckbox, "Checkbox"), {
|
|
201
|
+
Group: wrapAntComponent(AntCheckbox.Group, "Checkbox.Group")
|
|
202
|
+
});
|
|
203
|
+
var DatePicker = Object.assign(wrapAntComponent(AntDatePicker, "DatePicker"), {
|
|
204
|
+
WeekPicker: wrapAntComponent(AntDatePicker.WeekPicker, "DatePicker.WeekPicker"),
|
|
205
|
+
MonthPicker: wrapAntComponent(AntDatePicker.MonthPicker, "DatePicker.MonthPicker"),
|
|
206
|
+
YearPicker: wrapAntComponent(AntDatePicker.YearPicker, "DatePicker.YearPicker"),
|
|
207
|
+
RangePicker: wrapAntComponent(AntDatePicker.RangePicker, "DatePicker.RangePicker"),
|
|
208
|
+
TimePicker: wrapAntComponent(AntDatePicker.TimePicker, "DatePicker.TimePicker"),
|
|
209
|
+
QuarterPicker: wrapAntComponent(AntDatePicker.QuarterPicker, "DatePicker.QuarterPicker")
|
|
210
|
+
});
|
|
211
|
+
var InputNumber = wrapAntComponent(AntInputNumber, "InputNumber");
|
|
212
|
+
var Radio = Object.assign(wrapAntComponent(AntRadio, "Radio"), {
|
|
213
|
+
Button: wrapAntComponent(AntRadio.Button, "Radio.Button"),
|
|
214
|
+
Group: wrapAntComponent(AntRadio.Group, "Radio.Group")
|
|
215
|
+
});
|
|
216
|
+
var Slider = wrapAntComponent(AntSlider, "Slider");
|
|
217
|
+
var Switch = wrapAntComponent(AntSwitch, "Switch");
|
|
218
|
+
var TreeSelect = Object.assign(wrapAntComponent(AntTreeSelect, "TreeSelect"), {
|
|
219
|
+
TreeNode: wrapAntComponent(AntTreeSelect.TreeNode, "TreeSelect.TreeNode")
|
|
220
|
+
});
|
|
221
|
+
var Upload = Object.assign(wrapAntComponent(AntUpload, "Upload"), {
|
|
222
|
+
Dragger: wrapAntComponent(AntUpload.Dragger, "Upload.Dragger")
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// src/components/data.ts
|
|
226
|
+
import {
|
|
227
|
+
Card as AntCard,
|
|
228
|
+
Descriptions as AntDescriptions,
|
|
229
|
+
List as AntList,
|
|
230
|
+
Pagination as AntPagination,
|
|
231
|
+
Tree as AntTree
|
|
232
|
+
} from "antd";
|
|
233
|
+
var Card = Object.assign(wrapAntComponent(AntCard, "Card"), {
|
|
234
|
+
Grid: wrapAntComponent(AntCard.Grid, "Card.Grid"),
|
|
235
|
+
Meta: wrapAntComponent(AntCard.Meta, "Card.Meta")
|
|
236
|
+
});
|
|
237
|
+
var Descriptions = Object.assign(wrapAntComponent(AntDescriptions, "Descriptions"), {
|
|
238
|
+
Item: wrapAntComponent(AntDescriptions.Item, "Descriptions.Item")
|
|
239
|
+
});
|
|
240
|
+
var ListItem = Object.assign(wrapAntComponent(AntList.Item, "List.Item"), {
|
|
241
|
+
Meta: wrapAntComponent(AntList.Item.Meta, "List.Item.Meta")
|
|
242
|
+
});
|
|
243
|
+
var List = Object.assign(wrapAntComponent(AntList, "List"), {
|
|
244
|
+
Item: ListItem
|
|
245
|
+
});
|
|
246
|
+
var Pagination = wrapAntComponent(AntPagination, "Pagination");
|
|
247
|
+
var Tree = Object.assign(wrapAntComponent(AntTree, "Tree"), {
|
|
248
|
+
DirectoryTree: wrapAntComponent(AntTree.DirectoryTree, "Tree.DirectoryTree"),
|
|
249
|
+
TreeNode: wrapAntComponent(AntTree.TreeNode, "Tree.TreeNode")
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// src/components/layout.ts
|
|
253
|
+
import {
|
|
254
|
+
Avatar as AntAvatar,
|
|
255
|
+
Col as AntCol,
|
|
256
|
+
Flex as AntFlex,
|
|
257
|
+
Layout as AntLayout,
|
|
258
|
+
Row as AntRow,
|
|
259
|
+
Space as AntSpace
|
|
260
|
+
} from "antd";
|
|
261
|
+
var Avatar = Object.assign(wrapAntComponent(AntAvatar, "Avatar"), {
|
|
262
|
+
Group: wrapAntComponent(AntAvatar.Group, "Avatar.Group")
|
|
263
|
+
});
|
|
264
|
+
var Col = wrapAntComponent(AntCol, "Col");
|
|
265
|
+
var Flex = wrapAntComponent(AntFlex, "Flex");
|
|
266
|
+
var Layout = Object.assign(wrapAntComponent(AntLayout, "Layout"), {
|
|
267
|
+
Header: wrapAntComponent(AntLayout.Header, "Layout.Header"),
|
|
268
|
+
Footer: wrapAntComponent(AntLayout.Footer, "Layout.Footer"),
|
|
269
|
+
Content: wrapAntComponent(AntLayout.Content, "Layout.Content"),
|
|
270
|
+
Sider: wrapAntComponent(AntLayout.Sider, "Layout.Sider")
|
|
271
|
+
});
|
|
272
|
+
var Row = wrapAntComponent(AntRow, "Row");
|
|
273
|
+
var Space = Object.assign(wrapAntComponent(AntSpace, "Space"), {
|
|
274
|
+
Compact: wrapAntComponent(AntSpace.Compact, "Space.Compact"),
|
|
275
|
+
Addon: wrapAntComponent(AntSpace.Addon, "Space.Addon")
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// src/components/navigation.ts
|
|
279
|
+
import { Dropdown as AntDropdown, Menu as AntMenu, Tabs as AntTabs } from "antd";
|
|
280
|
+
var Dropdown = Object.assign(wrapAntComponent(AntDropdown, "Dropdown"), {
|
|
281
|
+
Button: wrapAntComponent(AntDropdown.Button, "Dropdown.Button")
|
|
282
|
+
});
|
|
283
|
+
var Menu = Object.assign(wrapAntComponent(AntMenu, "Menu"), {
|
|
284
|
+
Item: wrapAntComponent(AntMenu.Item, "Menu.Item"),
|
|
285
|
+
SubMenu: wrapAntComponent(AntMenu.SubMenu, "Menu.SubMenu"),
|
|
286
|
+
Divider: wrapAntComponent(AntMenu.Divider, "Menu.Divider"),
|
|
287
|
+
ItemGroup: wrapAntComponent(AntMenu.ItemGroup, "Menu.ItemGroup")
|
|
288
|
+
});
|
|
289
|
+
var Tabs = Object.assign(wrapAntComponent(AntTabs, "Tabs"), {
|
|
290
|
+
TabPane: wrapAntComponent(AntTabs.TabPane, "Tabs.TabPane")
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// src/components/Affix.ts
|
|
294
|
+
import { Affix as AntAffix } from "antd";
|
|
295
|
+
var Affix = wrapAntComponent(AntAffix, "Affix");
|
|
296
|
+
|
|
297
|
+
// src/components/Anchor.ts
|
|
298
|
+
import { Anchor as AntAnchor } from "antd";
|
|
299
|
+
var Anchor = Object.assign(wrapAntComponent(AntAnchor, "Anchor"), {
|
|
300
|
+
Link: wrapAntComponent(AntAnchor.Link, "Anchor.Link")
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// src/components/BackTop.ts
|
|
304
|
+
import { BackTop as AntBackTop } from "antd";
|
|
305
|
+
var BackTop = wrapAntComponent(AntBackTop, "BackTop");
|
|
306
|
+
|
|
307
|
+
// src/components/Badge.ts
|
|
308
|
+
import { Badge as AntBadge } from "antd";
|
|
309
|
+
var Badge = Object.assign(wrapAntComponent(AntBadge, "Badge"), {
|
|
310
|
+
Ribbon: wrapAntComponent(AntBadge.Ribbon, "Badge.Ribbon")
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// src/components/BorderBeam.ts
|
|
314
|
+
import { BorderBeam as AntBorderBeam } from "antd";
|
|
315
|
+
var BorderBeam = wrapAntComponent(AntBorderBeam, "BorderBeam");
|
|
316
|
+
|
|
317
|
+
// src/components/Breadcrumb.ts
|
|
318
|
+
import { Breadcrumb as AntBreadcrumb } from "antd";
|
|
319
|
+
var Breadcrumb = Object.assign(wrapAntComponent(AntBreadcrumb, "Breadcrumb"), {
|
|
320
|
+
Item: wrapAntComponent(AntBreadcrumb.Item, "Breadcrumb.Item"),
|
|
321
|
+
Separator: wrapAntComponent(AntBreadcrumb.Separator, "Breadcrumb.Separator")
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// src/components/Calendar.ts
|
|
325
|
+
import { Calendar as AntCalendar } from "antd";
|
|
326
|
+
var Calendar = wrapAntComponent(AntCalendar, "Calendar");
|
|
327
|
+
|
|
328
|
+
// src/components/Carousel.ts
|
|
329
|
+
import { Carousel as AntCarousel } from "antd";
|
|
330
|
+
var Carousel = wrapAntComponent(AntCarousel, "Carousel");
|
|
331
|
+
|
|
332
|
+
// src/components/Cascader.ts
|
|
333
|
+
import { Cascader as AntCascader } from "antd";
|
|
334
|
+
var Cascader = Object.assign(wrapAntComponent(AntCascader, "Cascader"), {
|
|
335
|
+
Panel: wrapAntComponent(AntCascader.Panel, "Cascader.Panel")
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// src/components/Collapse.ts
|
|
339
|
+
import { Collapse as AntCollapse } from "antd";
|
|
340
|
+
var Collapse = Object.assign(wrapAntComponent(AntCollapse, "Collapse"), {
|
|
341
|
+
Panel: wrapAntComponent(AntCollapse.Panel, "Collapse.Panel")
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// src/components/ColorPicker.ts
|
|
345
|
+
import { ColorPicker as AntColorPicker } from "antd";
|
|
346
|
+
var ColorPicker = wrapAntComponent(AntColorPicker, "ColorPicker");
|
|
347
|
+
|
|
348
|
+
// src/components/Divider.ts
|
|
349
|
+
import { Divider as AntDivider } from "antd";
|
|
350
|
+
var Divider = wrapAntComponent(AntDivider, "Divider");
|
|
351
|
+
|
|
352
|
+
// src/components/FloatButton.ts
|
|
353
|
+
import { FloatButton as AntFloatButton } from "antd";
|
|
354
|
+
var FloatButton = Object.assign(wrapAntComponent(AntFloatButton, "FloatButton"), {
|
|
355
|
+
BackTop: wrapAntComponent(AntFloatButton.BackTop, "FloatButton.BackTop"),
|
|
356
|
+
Group: wrapAntComponent(AntFloatButton.Group, "FloatButton.Group")
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// src/components/Grid.ts
|
|
360
|
+
import { Grid as AntGrid } from "antd";
|
|
361
|
+
var Grid = { useBreakpoint: AntGrid.useBreakpoint };
|
|
362
|
+
|
|
363
|
+
// src/components/Image.ts
|
|
364
|
+
import { Image as AntImage } from "antd";
|
|
365
|
+
var Image = Object.assign(wrapAntComponent(AntImage, "Image"), {
|
|
366
|
+
PreviewGroup: wrapAntComponent(AntImage.PreviewGroup, "Image.PreviewGroup")
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// src/components/Listy.ts
|
|
370
|
+
import { Listy as AntListy } from "antd";
|
|
371
|
+
var Listy = wrapAntComponent(AntListy, "Listy");
|
|
372
|
+
|
|
373
|
+
// src/components/Masonry.ts
|
|
374
|
+
import { Masonry as AntMasonry } from "antd";
|
|
375
|
+
var Masonry = wrapAntComponent(AntMasonry, "Masonry");
|
|
376
|
+
|
|
377
|
+
// src/components/Mentions.ts
|
|
378
|
+
import { Mentions as AntMentions } from "antd";
|
|
379
|
+
var Mentions = Object.assign(wrapAntComponent(AntMentions, "Mentions"), {
|
|
380
|
+
Option: wrapAntComponent(AntMentions.Option, "Mentions.Option")
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
// src/components/Popconfirm.ts
|
|
384
|
+
import { Popconfirm as AntPopconfirm } from "antd";
|
|
385
|
+
var Popconfirm = wrapAntComponent(AntPopconfirm, "Popconfirm");
|
|
386
|
+
|
|
387
|
+
// src/components/QRCode.ts
|
|
388
|
+
import { QRCode as AntQRCode } from "antd";
|
|
389
|
+
var QRCode = wrapAntComponent(AntQRCode, "QRCode");
|
|
390
|
+
|
|
391
|
+
// src/components/Rate.ts
|
|
392
|
+
import { Rate as AntRate } from "antd";
|
|
393
|
+
var Rate = wrapAntComponent(AntRate, "Rate");
|
|
394
|
+
|
|
395
|
+
// src/components/Segmented.ts
|
|
396
|
+
import { Segmented as AntSegmented } from "antd";
|
|
397
|
+
var Segmented = wrapAntComponent(AntSegmented, "Segmented");
|
|
398
|
+
|
|
399
|
+
// src/components/Skeleton.ts
|
|
400
|
+
import { Skeleton as AntSkeleton } from "antd";
|
|
401
|
+
var Skeleton = Object.assign(wrapAntComponent(AntSkeleton, "Skeleton"), {
|
|
402
|
+
Button: wrapAntComponent(AntSkeleton.Button, "Skeleton.Button"),
|
|
403
|
+
Avatar: wrapAntComponent(AntSkeleton.Avatar, "Skeleton.Avatar"),
|
|
404
|
+
Input: wrapAntComponent(AntSkeleton.Input, "Skeleton.Input"),
|
|
405
|
+
Image: wrapAntComponent(AntSkeleton.Image, "Skeleton.Image"),
|
|
406
|
+
Node: wrapAntComponent(AntSkeleton.Node, "Skeleton.Node")
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// src/components/Splitter.ts
|
|
410
|
+
import { Splitter as AntSplitter } from "antd";
|
|
411
|
+
var Splitter = Object.assign(wrapAntComponent(AntSplitter, "Splitter"), {
|
|
412
|
+
Panel: wrapAntComponent(AntSplitter.Panel, "Splitter.Panel")
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// src/components/Steps.ts
|
|
416
|
+
import { Steps as AntSteps } from "antd";
|
|
417
|
+
var Steps = wrapAntComponent(AntSteps, "Steps");
|
|
418
|
+
|
|
419
|
+
// src/components/TimePicker.ts
|
|
420
|
+
import { TimePicker as AntTimePicker } from "antd";
|
|
421
|
+
var TimePicker = Object.assign(wrapAntComponent(AntTimePicker, "TimePicker"), {
|
|
422
|
+
RangePicker: wrapAntComponent(AntTimePicker.RangePicker, "TimePicker.RangePicker")
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// src/components/Tour.ts
|
|
426
|
+
import { Tour as AntTour } from "antd";
|
|
427
|
+
var Tour = wrapAntComponent(AntTour, "Tour");
|
|
428
|
+
|
|
429
|
+
// src/components/Transfer.ts
|
|
430
|
+
import { Transfer as AntTransfer } from "antd";
|
|
431
|
+
var Transfer = Object.assign(wrapAntComponent(AntTransfer, "Transfer"), {
|
|
432
|
+
List: wrapAntComponent(AntTransfer.List, "Transfer.List"),
|
|
433
|
+
Search: wrapAntComponent(AntTransfer.Search, "Transfer.Search"),
|
|
434
|
+
Operation: wrapAntComponent(AntTransfer.Operation, "Transfer.Operation")
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// src/components/Watermark.ts
|
|
438
|
+
import { Watermark as AntWatermark } from "antd";
|
|
439
|
+
var Watermark = wrapAntComponent(AntWatermark, "Watermark");
|
|
440
|
+
|
|
441
|
+
// src/index.ts
|
|
442
|
+
import { theme as theme2 } from "antd";
|
|
443
|
+
|
|
444
|
+
// src/composites/BusinessDrawer.tsx
|
|
445
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
446
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
447
|
+
var BUSINESS_DRAWER_WIDTH = {
|
|
448
|
+
narrow: "min(420px, 100vw)",
|
|
449
|
+
standard: "min(640px, 100vw)",
|
|
450
|
+
wide: "min(960px, 100vw)"
|
|
451
|
+
};
|
|
452
|
+
var DrawerWithRef = Drawer;
|
|
453
|
+
var BusinessDrawer = forwardRef3(function BusinessDrawer2({ sizeVariant = "standard", placement = "right", closable = { placement: "end" }, width, size, footer, ...props }, ref) {
|
|
454
|
+
const resolvedWidth = width ?? (size == null ? BUSINESS_DRAWER_WIDTH[sizeVariant] : void 0);
|
|
455
|
+
const alignedFooter = footer == null ? footer : /* @__PURE__ */ jsx3("div", { style: { display: "flex", alignItems: "center", justifyContent: "flex-end", gap: 8, flexWrap: "wrap" }, children: footer });
|
|
456
|
+
return /* @__PURE__ */ jsx3(
|
|
457
|
+
DrawerWithRef,
|
|
458
|
+
{
|
|
459
|
+
...props,
|
|
460
|
+
ref,
|
|
461
|
+
placement,
|
|
462
|
+
closable,
|
|
463
|
+
width: resolvedWidth,
|
|
464
|
+
size,
|
|
465
|
+
footer: alignedFooter
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// src/composites/SearchPanel.tsx
|
|
471
|
+
import { DownOutlined, UpOutlined } from "@ant-design/icons";
|
|
472
|
+
import {
|
|
473
|
+
Children,
|
|
474
|
+
forwardRef as forwardRef4,
|
|
475
|
+
isValidElement,
|
|
476
|
+
useEffect,
|
|
477
|
+
useRef,
|
|
478
|
+
useState
|
|
479
|
+
} from "react";
|
|
480
|
+
|
|
481
|
+
// src/composites/searchPanelModel.ts
|
|
482
|
+
function searchColumnCount(width) {
|
|
483
|
+
return Math.min(6, Math.max(1, Math.floor((Math.max(0, width) + 16) / 256)));
|
|
484
|
+
}
|
|
485
|
+
function collapsedSearchFieldLimit(columns) {
|
|
486
|
+
return Math.max(1, columns * 2 - Math.min(2, columns));
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/composites/SearchPanel.tsx
|
|
490
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
491
|
+
var SearchPanel = forwardRef4(function SearchPanel2({ fields, actions, tools, trailingTools, searchVisible = true, defaultExpanded = false, role = "search", style, ...props }, ref) {
|
|
492
|
+
const rootRef = useRef(null);
|
|
493
|
+
const [width, setWidth] = useState(0);
|
|
494
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
495
|
+
const items = Children.toArray(fields);
|
|
496
|
+
const columns = searchColumnCount(width);
|
|
497
|
+
const collapsedLimit = collapsedSearchFieldLimit(columns);
|
|
498
|
+
const hasMore = items.length > collapsedLimit;
|
|
499
|
+
const fieldWidth = Math.min(240, Math.max(0, width));
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
const element = rootRef.current;
|
|
502
|
+
if (!element) return void 0;
|
|
503
|
+
const update = () => {
|
|
504
|
+
setWidth(element.getBoundingClientRect().width);
|
|
505
|
+
};
|
|
506
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
|
507
|
+
observer?.observe(element);
|
|
508
|
+
window.addEventListener("resize", update);
|
|
509
|
+
update();
|
|
510
|
+
return () => {
|
|
511
|
+
observer?.disconnect();
|
|
512
|
+
window.removeEventListener("resize", update);
|
|
513
|
+
};
|
|
514
|
+
}, []);
|
|
515
|
+
const setRootRef = (element) => {
|
|
516
|
+
rootRef.current = element;
|
|
517
|
+
if (typeof ref === "function") ref(element);
|
|
518
|
+
else if (ref) ref.current = element;
|
|
519
|
+
};
|
|
520
|
+
const panelStyle = {
|
|
521
|
+
display: "flex",
|
|
522
|
+
width: "100%",
|
|
523
|
+
flexDirection: "column",
|
|
524
|
+
alignItems: "stretch",
|
|
525
|
+
gap: 16,
|
|
526
|
+
...style
|
|
527
|
+
};
|
|
528
|
+
const hasToolbar = tools != null || trailingTools != null;
|
|
529
|
+
return /* @__PURE__ */ jsxs("div", { ...props, ref: setRootRef, role: hasToolbar ? "toolbar" : role, style: panelStyle, "data-adminsmart-search-panel": "true", children: [
|
|
530
|
+
/* @__PURE__ */ jsx4("style", { children: "[data-adminsmart-search-field] > .ant-form-item { margin-bottom: 0; }" }),
|
|
531
|
+
(items.length > 0 || actions != null) && /* @__PURE__ */ jsxs("div", { role: hasToolbar ? role : void 0, "aria-hidden": !searchVisible, style: { display: searchVisible ? "flex" : "none", width: "100%", flexWrap: "wrap", alignItems: "end", gap: "12px 16px" }, children: [
|
|
532
|
+
items.map((item, index) => /* @__PURE__ */ jsx4(
|
|
533
|
+
"div",
|
|
534
|
+
{
|
|
535
|
+
hidden: !expanded && index >= collapsedLimit,
|
|
536
|
+
"data-adminsmart-search-field": "true",
|
|
537
|
+
style: { minWidth: 0, width: fieldWidth || "min(240px, 100%)", flex: "0 0 auto" },
|
|
538
|
+
children: item
|
|
539
|
+
},
|
|
540
|
+
isValidElement(item) ? item.key ?? index : index
|
|
541
|
+
)),
|
|
542
|
+
/* @__PURE__ */ jsxs("div", { "data-adminsmart-search-actions": "true", style: { display: "flex", alignItems: "center", gap: 8, minHeight: 32 }, children: [
|
|
543
|
+
hasMore ? /* @__PURE__ */ jsx4(
|
|
544
|
+
Button,
|
|
545
|
+
{
|
|
546
|
+
type: "link",
|
|
547
|
+
icon: expanded ? /* @__PURE__ */ jsx4(UpOutlined, {}) : /* @__PURE__ */ jsx4(DownOutlined, {}),
|
|
548
|
+
"aria-expanded": expanded,
|
|
549
|
+
onClick: () => setExpanded((value) => !value),
|
|
550
|
+
children: expanded ? "\u6536\u8D77\u7B5B\u9009" : "\u5C55\u5F00\u7B5B\u9009"
|
|
551
|
+
}
|
|
552
|
+
) : null,
|
|
553
|
+
/* @__PURE__ */ jsx4("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 }, children: actions })
|
|
554
|
+
] })
|
|
555
|
+
] }),
|
|
556
|
+
hasToolbar && /* @__PURE__ */ jsxs("div", { "data-adminsmart-toolbar-row": "true", style: { display: "flex", width: "100%", minWidth: 0, alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: 12 }, children: [
|
|
557
|
+
/* @__PURE__ */ jsx4("div", { role: "group", "aria-label": "\u529F\u80FD\u64CD\u4F5C", "data-adminsmart-toolbar-actions": "true", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 12, minHeight: 32 }, children: tools }),
|
|
558
|
+
/* @__PURE__ */ jsx4("div", { role: "group", "aria-label": "\u8868\u683C\u5DE5\u5177", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 12, marginLeft: "auto", minHeight: 32 }, children: trailingTools })
|
|
559
|
+
] })
|
|
560
|
+
] });
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
// src/composites/DataTable.tsx
|
|
564
|
+
import {
|
|
565
|
+
forwardRef as forwardRef5,
|
|
566
|
+
useLayoutEffect,
|
|
567
|
+
useRef as useRef2,
|
|
568
|
+
useState as useState2
|
|
569
|
+
} from "react";
|
|
570
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
571
|
+
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
572
|
+
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
573
|
+
}
|
|
574
|
+
function tableChromeHeight(container) {
|
|
575
|
+
const heightOf = (selector) => {
|
|
576
|
+
const element = container.querySelector(selector);
|
|
577
|
+
if (!element) return 0;
|
|
578
|
+
const style = getComputedStyle(element);
|
|
579
|
+
return element.getBoundingClientRect().height + (Number.parseFloat(style.marginTop) || 0) + (Number.parseFloat(style.marginBottom) || 0);
|
|
580
|
+
};
|
|
581
|
+
return (heightOf(".ant-table-header") || heightOf(".ant-table-thead")) + heightOf(".ant-table-pagination") + heightOf(".ant-table-title") + heightOf(".ant-table-footer");
|
|
582
|
+
}
|
|
583
|
+
function DataTableInner({
|
|
584
|
+
containerHeight,
|
|
585
|
+
containerStyle,
|
|
586
|
+
containerClassName,
|
|
587
|
+
pagination,
|
|
588
|
+
scroll,
|
|
589
|
+
...tableProps
|
|
590
|
+
}, ref) {
|
|
591
|
+
const containerRef = useRef2(null);
|
|
592
|
+
const [bodyHeight, setBodyHeight] = useState2(360);
|
|
593
|
+
const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
|
|
594
|
+
useLayoutEffect(() => {
|
|
595
|
+
const container = containerRef.current;
|
|
596
|
+
if (!container || scroll?.y != null) return void 0;
|
|
597
|
+
const update = () => {
|
|
598
|
+
const top = container.getBoundingClientRect().top;
|
|
599
|
+
let boundary = container.parentElement;
|
|
600
|
+
while (boundary && ["", "visible", "clip"].includes(getComputedStyle(boundary).overflowY)) {
|
|
601
|
+
boundary = boundary.parentElement;
|
|
602
|
+
}
|
|
603
|
+
const boundaryStyle = boundary ? getComputedStyle(boundary) : null;
|
|
604
|
+
const parentBottom = boundary ? boundary.getBoundingClientRect().bottom - Number.parseFloat(boundaryStyle?.paddingBottom || "0") : Number.POSITIVE_INFINITY;
|
|
605
|
+
const viewportBottom = window.visualViewport?.height ?? window.innerHeight;
|
|
606
|
+
const availableHeight = !hasExplicitHeight ? Math.max(200, Math.min(viewportBottom - 16, parentBottom - 16) - top) : container.getBoundingClientRect().height;
|
|
607
|
+
const nextHeight = tableBodyHeight(availableHeight, tableChromeHeight(container));
|
|
608
|
+
setBodyHeight((current) => current === nextHeight ? current : nextHeight);
|
|
609
|
+
};
|
|
610
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
|
611
|
+
observer?.observe(container);
|
|
612
|
+
if (container.parentElement) observer?.observe(container.parentElement);
|
|
613
|
+
window.addEventListener("resize", update);
|
|
614
|
+
window.visualViewport?.addEventListener("resize", update);
|
|
615
|
+
update();
|
|
616
|
+
return () => {
|
|
617
|
+
observer?.disconnect();
|
|
618
|
+
window.removeEventListener("resize", update);
|
|
619
|
+
window.visualViewport?.removeEventListener("resize", update);
|
|
620
|
+
};
|
|
621
|
+
}, [hasExplicitHeight, containerHeight, pagination, scroll?.y, tableProps.dataSource?.length]);
|
|
622
|
+
const tableScroll = {
|
|
623
|
+
...scroll,
|
|
624
|
+
x: scroll?.x ?? "max-content",
|
|
625
|
+
y: scroll?.y ?? bodyHeight
|
|
626
|
+
};
|
|
627
|
+
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
628
|
+
return /* @__PURE__ */ jsx5(
|
|
629
|
+
"div",
|
|
630
|
+
{
|
|
631
|
+
ref: containerRef,
|
|
632
|
+
className: containerClassName,
|
|
633
|
+
"data-adminsmart-data-table": "true",
|
|
634
|
+
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
|
|
635
|
+
children: /* @__PURE__ */ jsx5(
|
|
636
|
+
Table,
|
|
637
|
+
{
|
|
638
|
+
...tableProps,
|
|
639
|
+
ref,
|
|
640
|
+
scroll: tableScroll,
|
|
641
|
+
pagination: tablePagination
|
|
642
|
+
}
|
|
643
|
+
)
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
var DataTable = forwardRef5(DataTableInner);
|
|
648
|
+
|
|
649
|
+
// src/composites/WorkspaceLayout.tsx
|
|
650
|
+
import { theme } from "antd";
|
|
651
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
652
|
+
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
653
|
+
function WorkspaceLayout({
|
|
654
|
+
header,
|
|
655
|
+
sidebar,
|
|
656
|
+
tabs,
|
|
657
|
+
footer,
|
|
658
|
+
children,
|
|
659
|
+
sidebarWidth = 220,
|
|
660
|
+
collapsedWidth = 58,
|
|
661
|
+
collapsed = false,
|
|
662
|
+
themeMode = "light",
|
|
663
|
+
contentMode = "default",
|
|
664
|
+
siderProps,
|
|
665
|
+
className,
|
|
666
|
+
contentClassName,
|
|
667
|
+
height
|
|
668
|
+
}) {
|
|
669
|
+
const { token } = theme.useToken();
|
|
670
|
+
const rootClassName = ["adminsmart-workspace", className].filter(Boolean).join(" ");
|
|
671
|
+
const contentClasses = ["adminsmart-workspace__content", contentClassName].filter(Boolean).join(" ");
|
|
672
|
+
const siderClasses = ["adminsmart-workspace__sider", siderProps?.className].filter(Boolean).join(" ");
|
|
673
|
+
const workspaceStyle = {
|
|
674
|
+
height,
|
|
675
|
+
// 保留嵌入示例或宿主指定的高度。
|
|
676
|
+
colorScheme: themeMode,
|
|
677
|
+
// 原生滚动条和浏览器表单能力使用当前日夜外观。
|
|
678
|
+
color: token.colorText,
|
|
679
|
+
// 自定义顶栏和页脚文本继承原生语义文字色。
|
|
680
|
+
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
681
|
+
// 夜间不复用日间固定底色。
|
|
682
|
+
};
|
|
683
|
+
return /* @__PURE__ */ jsxs2(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
|
|
684
|
+
/* @__PURE__ */ jsx6("header", { className: "adminsmart-workspace__header", children: header }),
|
|
685
|
+
/* @__PURE__ */ jsxs2(Layout, { className: "adminsmart-workspace__body", children: [
|
|
686
|
+
/* @__PURE__ */ jsx6(
|
|
687
|
+
Layout.Sider,
|
|
688
|
+
{
|
|
689
|
+
theme: themeMode,
|
|
690
|
+
...siderProps,
|
|
691
|
+
width: sidebarWidth,
|
|
692
|
+
collapsedWidth,
|
|
693
|
+
collapsed,
|
|
694
|
+
className: siderClasses,
|
|
695
|
+
children: sidebar
|
|
696
|
+
}
|
|
697
|
+
),
|
|
698
|
+
/* @__PURE__ */ jsxs2(Layout, { className: "adminsmart-workspace__main", children: [
|
|
699
|
+
tabs,
|
|
700
|
+
/* @__PURE__ */ jsx6(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
701
|
+
footer
|
|
702
|
+
] })
|
|
703
|
+
] })
|
|
704
|
+
] });
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/composites/CrudScaffold.tsx
|
|
708
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
709
|
+
function CrudScaffold({
|
|
710
|
+
label,
|
|
711
|
+
description,
|
|
712
|
+
filters,
|
|
713
|
+
status,
|
|
714
|
+
results,
|
|
715
|
+
drawer,
|
|
716
|
+
className,
|
|
717
|
+
...props
|
|
718
|
+
}) {
|
|
719
|
+
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
720
|
+
return /* @__PURE__ */ jsxs3("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
|
|
721
|
+
/* @__PURE__ */ jsx7("div", { className: "adminsmart-crud__filters", children: filters }),
|
|
722
|
+
status ? /* @__PURE__ */ jsx7("div", { className: "adminsmart-crud__status", children: status }) : null,
|
|
723
|
+
/* @__PURE__ */ jsx7("div", { className: "adminsmart-crud__results", children: results }),
|
|
724
|
+
drawer
|
|
725
|
+
] });
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// src/composites/EllipsisText.tsx
|
|
729
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
730
|
+
function EllipsisText({
|
|
731
|
+
children,
|
|
732
|
+
maxWidth = 240,
|
|
733
|
+
ellipsis,
|
|
734
|
+
className,
|
|
735
|
+
style,
|
|
736
|
+
...props
|
|
737
|
+
}) {
|
|
738
|
+
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
739
|
+
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
740
|
+
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
741
|
+
return /* @__PURE__ */ jsx8(
|
|
742
|
+
Typography.Text,
|
|
743
|
+
{
|
|
744
|
+
...props,
|
|
745
|
+
className: classes,
|
|
746
|
+
style: textStyle,
|
|
747
|
+
ellipsis: ellipsis ?? { tooltip: children },
|
|
748
|
+
children
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// src/composites/RowActions.tsx
|
|
754
|
+
import { EllipsisOutlined } from "@ant-design/icons";
|
|
755
|
+
import { Children as Children2, Fragment, isValidElement as isValidElement2 } from "react";
|
|
756
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
757
|
+
function collectButtons(children) {
|
|
758
|
+
const actions = [];
|
|
759
|
+
Children2.forEach(children, (child) => {
|
|
760
|
+
if (!isValidElement2(child)) return;
|
|
761
|
+
if (child.type === Fragment) actions.push(...collectButtons(child.props.children));
|
|
762
|
+
else {
|
|
763
|
+
if (child.type !== Button && child.type !== "button") throw new TypeError("RowActions \u53EA\u63A5\u53D7\u5DF2\u6309\u6743\u9650\u7B5B\u9009\u7684 Button \u6216 Fragment");
|
|
764
|
+
if (!child.props.hidden) actions.push(child);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
return actions;
|
|
768
|
+
}
|
|
769
|
+
function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\u4F5C", className, size = 8, wrap = false, ...props }) {
|
|
770
|
+
const actions = collectButtons(children);
|
|
771
|
+
const visibleLimit = Math.max(0, Math.floor(Number.isFinite(maxVisible) ? maxVisible : 2));
|
|
772
|
+
const direct = actions.slice(0, visibleLimit);
|
|
773
|
+
const overflow = actions.slice(visibleLimit);
|
|
774
|
+
const items = overflow.map((action, index) => ({
|
|
775
|
+
key: String(index),
|
|
776
|
+
// 菜单索引只在当前行的最新按钮序列内使用。
|
|
777
|
+
label: action.props.children ?? action.props["aria-label"] ?? action.props.title,
|
|
778
|
+
// 图标动作仍有可访问文案。
|
|
779
|
+
icon: action.props.icon,
|
|
780
|
+
// 保留原动作图标。
|
|
781
|
+
disabled: Boolean(action.props.disabled || action.props.loading),
|
|
782
|
+
// 不允许从更多菜单绕过禁用和重复提交锁。
|
|
783
|
+
danger: action.props.danger
|
|
784
|
+
// 菜单仍按官方语义标识需要确认的动作。
|
|
785
|
+
}));
|
|
786
|
+
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
787
|
+
return /* @__PURE__ */ jsxs4(Space, { ...props, className: classes, size, wrap, children: [
|
|
788
|
+
direct,
|
|
789
|
+
overflow.length > 0 && /* @__PURE__ */ jsx9(
|
|
790
|
+
Dropdown,
|
|
791
|
+
{
|
|
792
|
+
trigger: ["click"],
|
|
793
|
+
menu: {
|
|
794
|
+
items,
|
|
795
|
+
onClick: ({ key, domEvent }) => {
|
|
796
|
+
const action = overflow[Number(key)];
|
|
797
|
+
if (!action || action.props.disabled || action.props.loading) return;
|
|
798
|
+
action.props.onClick?.(domEvent);
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
children: /* @__PURE__ */ jsx9(Tooltip, { title: moreLabel, children: /* @__PURE__ */ jsx9(
|
|
802
|
+
Button,
|
|
803
|
+
{
|
|
804
|
+
type: "text",
|
|
805
|
+
size: "small",
|
|
806
|
+
icon: /* @__PURE__ */ jsx9(EllipsisOutlined, {}),
|
|
807
|
+
"aria-label": moreLabel,
|
|
808
|
+
"aria-haspopup": "menu",
|
|
809
|
+
"data-adminsmart-row-more": "true",
|
|
810
|
+
onClick: (event) => event.stopPropagation()
|
|
811
|
+
}
|
|
812
|
+
) })
|
|
813
|
+
}
|
|
814
|
+
)
|
|
815
|
+
] });
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// src/schema/SchemaForm.tsx
|
|
819
|
+
import dayjs from "dayjs";
|
|
820
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
821
|
+
|
|
822
|
+
// src/schema/model.ts
|
|
823
|
+
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
824
|
+
"input",
|
|
825
|
+
"password",
|
|
826
|
+
"textarea",
|
|
827
|
+
"number",
|
|
828
|
+
"select",
|
|
829
|
+
"radio",
|
|
830
|
+
"checkbox",
|
|
831
|
+
"switch",
|
|
832
|
+
"date",
|
|
833
|
+
"dateRange"
|
|
834
|
+
]);
|
|
835
|
+
var BASE_KEYS = /* @__PURE__ */ new Set(["type", "name", "label", "required", "placeholder", "default"]);
|
|
836
|
+
var RESERVED_NAMES = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
837
|
+
var DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
838
|
+
function isRecord(value) {
|
|
839
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
840
|
+
const prototype = Object.getPrototypeOf(value);
|
|
841
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
842
|
+
return Reflect.ownKeys(value).every((key) => "value" in (Object.getOwnPropertyDescriptor(value, key) ?? {}));
|
|
843
|
+
}
|
|
844
|
+
function checkKeys(value, allowed, path, errors) {
|
|
845
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
846
|
+
if (typeof key !== "string" || !allowed.has(key)) errors.push({ path: `${path}.${String(key)}`, message: "\u4E0D\u652F\u6301\u7684\u914D\u7F6E\u9879" });
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
function isFiniteNumber(value) {
|
|
850
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
851
|
+
}
|
|
852
|
+
function isCalendarDate(value) {
|
|
853
|
+
if (typeof value !== "string" || !DATE_PATTERN.test(value)) return false;
|
|
854
|
+
const [year, month, day] = value.split("-").map(Number);
|
|
855
|
+
if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31) return false;
|
|
856
|
+
const actual = /* @__PURE__ */ new Date(0);
|
|
857
|
+
actual.setUTCFullYear(year, month - 1, day);
|
|
858
|
+
return actual.getUTCFullYear() === year && actual.getUTCMonth() === month - 1 && actual.getUTCDate() === day;
|
|
859
|
+
}
|
|
860
|
+
function validateOptions(value, path, errors) {
|
|
861
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
862
|
+
errors.push({ path, message: "\u9009\u9879\u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4" });
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
const seen = /* @__PURE__ */ new Set();
|
|
866
|
+
value.forEach((option, index) => {
|
|
867
|
+
const itemPath = `${path}[${index}]`;
|
|
868
|
+
if (!isRecord(option)) {
|
|
869
|
+
errors.push({ path: itemPath, message: "\u9009\u9879\u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61" });
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
checkKeys(option, /* @__PURE__ */ new Set(["label", "value", "disabled"]), itemPath, errors);
|
|
873
|
+
if (typeof option.label !== "string" || !option.label.trim()) errors.push({ path: `${itemPath}.label`, message: "\u9009\u9879\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A" });
|
|
874
|
+
if (typeof option.value !== "string" && !isFiniteNumber(option.value)) errors.push({ path: `${itemPath}.value`, message: "\u9009\u9879\u503C\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216\u6709\u9650\u6570\u5B57" });
|
|
875
|
+
if (option.disabled !== void 0 && typeof option.disabled !== "boolean") errors.push({ path: `${itemPath}.disabled`, message: "disabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C" });
|
|
876
|
+
if (typeof option.value === "string" || isFiniteNumber(option.value)) {
|
|
877
|
+
const identity = `${typeof option.value}:${option.value}`;
|
|
878
|
+
if (seen.has(identity)) errors.push({ path: `${itemPath}.value`, message: "\u9009\u9879\u503C\u4E0D\u80FD\u91CD\u590D" });
|
|
879
|
+
seen.add(identity);
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
function validateTextRules(value, path, errors) {
|
|
885
|
+
if (!isRecord(value)) {
|
|
886
|
+
errors.push({ path, message: "validation \u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61" });
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
checkKeys(value, /* @__PURE__ */ new Set(["minLength", "maxLength", "email"]), path, errors);
|
|
890
|
+
for (const key of ["minLength", "maxLength"]) {
|
|
891
|
+
if (value[key] !== void 0 && (!Number.isSafeInteger(value[key]) || Number(value[key]) < 0)) {
|
|
892
|
+
errors.push({ path: `${path}.${key}`, message: "\u957F\u5EA6\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570" });
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
if (value.email !== void 0 && typeof value.email !== "boolean") errors.push({ path: `${path}.email`, message: "email \u5FC5\u987B\u662F\u5E03\u5C14\u503C" });
|
|
896
|
+
if (isFiniteNumber(value.minLength) && isFiniteNumber(value.maxLength) && value.minLength > value.maxLength) {
|
|
897
|
+
errors.push({ path, message: "\u6700\u5C0F\u957F\u5EA6\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u957F\u5EA6" });
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function validateNumberRules(value, path, errors) {
|
|
901
|
+
if (!isRecord(value)) {
|
|
902
|
+
errors.push({ path, message: "validation \u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61" });
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
checkKeys(value, /* @__PURE__ */ new Set(["min", "max"]), path, errors);
|
|
906
|
+
for (const key of ["min", "max"]) {
|
|
907
|
+
if (value[key] !== void 0 && !isFiniteNumber(value[key])) errors.push({ path: `${path}.${key}`, message: "\u8FB9\u754C\u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57" });
|
|
908
|
+
}
|
|
909
|
+
if (isFiniteNumber(value.min) && isFiniteNumber(value.max) && value.min > value.max) {
|
|
910
|
+
errors.push({ path, message: "\u4E0B\u754C\u4E0D\u80FD\u5927\u4E8E\u4E0A\u754C" });
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
function validateField(value, path, errors) {
|
|
914
|
+
if (!isRecord(value)) {
|
|
915
|
+
errors.push({ path, message: "\u5B57\u6BB5\u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61" });
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
const type = value.type;
|
|
919
|
+
if (typeof type !== "string" || !FIELD_TYPES.has(type)) {
|
|
920
|
+
errors.push({ path: `${path}.type`, message: "\u4E0D\u652F\u6301\u7684\u5B57\u6BB5\u7C7B\u578B" });
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
const allowed = new Set(BASE_KEYS);
|
|
924
|
+
if (type === "input" || type === "password" || type === "textarea" || type === "number") allowed.add("validation");
|
|
925
|
+
if (type === "select" || type === "radio") allowed.add("options");
|
|
926
|
+
checkKeys(value, allowed, path, errors);
|
|
927
|
+
if (typeof value.name !== "string" || !value.name.trim() || value.name.trim() !== value.name || RESERVED_NAMES.has(value.name)) {
|
|
928
|
+
errors.push({ path: `${path}.name`, message: "\u5B57\u6BB5\u540D\u5FC5\u987B\u662F\u975E\u7A7A\u7684\u666E\u901A\u5B57\u7B26\u4E32\u952E" });
|
|
929
|
+
}
|
|
930
|
+
if (typeof value.label !== "string" || !value.label.trim()) errors.push({ path: `${path}.label`, message: "\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A" });
|
|
931
|
+
if (value.required !== void 0 && typeof value.required !== "boolean") errors.push({ path: `${path}.required`, message: "required \u5FC5\u987B\u662F\u5E03\u5C14\u503C" });
|
|
932
|
+
if (value.placeholder !== void 0 && typeof value.placeholder !== "string") errors.push({ path: `${path}.placeholder`, message: "placeholder \u5FC5\u987B\u662F\u5B57\u7B26\u4E32" });
|
|
933
|
+
const defaultValue = value.default;
|
|
934
|
+
if (type === "input" || type === "password" || type === "textarea") {
|
|
935
|
+
if (defaultValue !== void 0 && typeof defaultValue !== "string") errors.push({ path: `${path}.default`, message: "\u6587\u672C\u9ED8\u8BA4\u503C\u5FC5\u987B\u662F\u5B57\u7B26\u4E32" });
|
|
936
|
+
if (value.validation !== void 0) validateTextRules(value.validation, `${path}.validation`, errors);
|
|
937
|
+
} else if (type === "number") {
|
|
938
|
+
if (defaultValue !== void 0 && !isFiniteNumber(defaultValue)) errors.push({ path: `${path}.default`, message: "\u6570\u503C\u9ED8\u8BA4\u503C\u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57" });
|
|
939
|
+
if (value.validation !== void 0) validateNumberRules(value.validation, `${path}.validation`, errors);
|
|
940
|
+
if (isFiniteNumber(defaultValue) && isRecord(value.validation)) {
|
|
941
|
+
if (isFiniteNumber(value.validation.min) && defaultValue < value.validation.min) errors.push({ path: `${path}.default`, message: "\u9ED8\u8BA4\u503C\u4F4E\u4E8E\u4E0B\u754C" });
|
|
942
|
+
if (isFiniteNumber(value.validation.max) && defaultValue > value.validation.max) errors.push({ path: `${path}.default`, message: "\u9ED8\u8BA4\u503C\u9AD8\u4E8E\u4E0A\u754C" });
|
|
943
|
+
}
|
|
944
|
+
} else if (type === "select" || type === "radio") {
|
|
945
|
+
if (validateOptions(value.options, `${path}.options`, errors) && defaultValue !== void 0) {
|
|
946
|
+
if (!value.options.some((option) => option.value === defaultValue)) errors.push({ path: `${path}.default`, message: "\u9ED8\u8BA4\u503C\u5FC5\u987B\u5B58\u5728\u4E8E\u9009\u9879\u4E2D" });
|
|
947
|
+
}
|
|
948
|
+
} else if (type === "checkbox" || type === "switch") {
|
|
949
|
+
if (defaultValue !== void 0 && typeof defaultValue !== "boolean") errors.push({ path: `${path}.default`, message: "\u5F00\u5173\u9ED8\u8BA4\u503C\u5FC5\u987B\u662F\u5E03\u5C14\u503C" });
|
|
950
|
+
} else if (type === "date") {
|
|
951
|
+
if (defaultValue !== void 0 && !isCalendarDate(defaultValue)) errors.push({ path: `${path}.default`, message: "\u65E5\u671F\u5FC5\u987B\u662F\u6709\u6548\u7684 YYYY-MM-DD" });
|
|
952
|
+
} else if (type === "dateRange" && defaultValue !== void 0) {
|
|
953
|
+
if (!Array.isArray(defaultValue) || defaultValue.length !== 2 || !defaultValue.every(isCalendarDate)) {
|
|
954
|
+
errors.push({ path: `${path}.default`, message: "\u65E5\u671F\u533A\u95F4\u5FC5\u987B\u662F\u4E24\u4E2A\u6709\u6548\u7684 YYYY-MM-DD" });
|
|
955
|
+
} else if (defaultValue[0] > defaultValue[1]) {
|
|
956
|
+
errors.push({ path: `${path}.default`, message: "\u8D77\u59CB\u65E5\u671F\u4E0D\u80FD\u665A\u4E8E\u7ED3\u675F\u65E5\u671F" });
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
function validateSchemaForm(input) {
|
|
961
|
+
const errors = [];
|
|
962
|
+
if (!isRecord(input)) return { valid: false, errors: [{ path: "schema", message: "schema \u5FC5\u987B\u662F\u666E\u901A\u5BF9\u8C61" }] };
|
|
963
|
+
checkKeys(input, /* @__PURE__ */ new Set(["fields", "submitText"]), "schema", errors);
|
|
964
|
+
if (input.submitText !== void 0 && (typeof input.submitText !== "string" || !input.submitText.trim())) {
|
|
965
|
+
errors.push({ path: "schema.submitText", message: "\u63D0\u4EA4\u6587\u6848\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32" });
|
|
966
|
+
}
|
|
967
|
+
if (!Array.isArray(input.fields) || input.fields.length === 0) {
|
|
968
|
+
errors.push({ path: "schema.fields", message: "fields \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4" });
|
|
969
|
+
} else {
|
|
970
|
+
const names = /* @__PURE__ */ new Set();
|
|
971
|
+
input.fields.forEach((field, index) => {
|
|
972
|
+
const path = `schema.fields[${index}]`;
|
|
973
|
+
validateField(field, path, errors);
|
|
974
|
+
if (isRecord(field) && typeof field.name === "string") {
|
|
975
|
+
if (names.has(field.name)) errors.push({ path: `${path}.name`, message: "\u5B57\u6BB5\u540D\u4E0D\u80FD\u91CD\u590D" });
|
|
976
|
+
names.add(field.name);
|
|
977
|
+
}
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
return { valid: errors.length === 0, errors };
|
|
981
|
+
}
|
|
982
|
+
function mapSchemaField(field) {
|
|
983
|
+
return {
|
|
984
|
+
name: field.name,
|
|
985
|
+
label: field.label,
|
|
986
|
+
control: field.type,
|
|
987
|
+
valuePropName: field.type === "checkbox" || field.type === "switch" ? "checked" : "value",
|
|
988
|
+
placeholder: field.placeholder,
|
|
989
|
+
required: field.required === true
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
function schemaInitialValues(schema) {
|
|
993
|
+
const validation = validateSchemaForm(schema);
|
|
994
|
+
if (!validation.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${validation.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
995
|
+
const values = {};
|
|
996
|
+
for (const field of schema.fields) {
|
|
997
|
+
if (field.default !== void 0) values[field.name] = Array.isArray(field.default) ? [...field.default] : field.default;
|
|
998
|
+
}
|
|
999
|
+
return values;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/schema/SchemaForm.tsx
|
|
1003
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1004
|
+
function fieldRules(field) {
|
|
1005
|
+
const rules = [];
|
|
1006
|
+
if (field.required) {
|
|
1007
|
+
if (field.type === "checkbox" || field.type === "switch") {
|
|
1008
|
+
rules.push({
|
|
1009
|
+
validator: async (_, value) => {
|
|
1010
|
+
if (value !== true) throw new Error(`\u8BF7\u786E\u8BA4${field.label}`);
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
} else {
|
|
1014
|
+
rules.push({ required: true, message: `\u8BF7\u586B\u5199${field.label}` });
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (field.type === "input" || field.type === "password" || field.type === "textarea") {
|
|
1018
|
+
if (field.validation?.minLength !== void 0) rules.push({ min: field.validation.minLength, message: `${field.label}\u81F3\u5C11 ${field.validation.minLength} \u4E2A\u5B57\u7B26` });
|
|
1019
|
+
if (field.validation?.maxLength !== void 0) rules.push({ max: field.validation.maxLength, message: `${field.label}\u6700\u591A ${field.validation.maxLength} \u4E2A\u5B57\u7B26` });
|
|
1020
|
+
if (field.validation?.email === true) rules.push({ type: "email", message: `${field.label}\u683C\u5F0F\u4E0D\u6B63\u786E` });
|
|
1021
|
+
}
|
|
1022
|
+
if (field.type === "number") {
|
|
1023
|
+
if (field.validation?.min !== void 0) rules.push({ type: "number", min: field.validation.min, message: `${field.label}\u4E0D\u80FD\u5C0F\u4E8E ${field.validation.min}` });
|
|
1024
|
+
if (field.validation?.max !== void 0) rules.push({ type: "number", max: field.validation.max, message: `${field.label}\u4E0D\u80FD\u5927\u4E8E ${field.validation.max}` });
|
|
1025
|
+
}
|
|
1026
|
+
return rules;
|
|
1027
|
+
}
|
|
1028
|
+
function dateItemProps(field) {
|
|
1029
|
+
if (field.type === "date") {
|
|
1030
|
+
return {
|
|
1031
|
+
getValueProps: (value) => ({ value: typeof value === "string" && value ? dayjs(value) : null }),
|
|
1032
|
+
getValueFromEvent: (value) => dayjs.isDayjs(value) ? value.format("YYYY-MM-DD") : void 0
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
if (field.type === "dateRange") {
|
|
1036
|
+
return {
|
|
1037
|
+
getValueProps: (value) => ({
|
|
1038
|
+
value: Array.isArray(value) && value.length === 2 && value.every((part) => typeof part === "string") ? [dayjs(value[0]), dayjs(value[1])] : null
|
|
1039
|
+
}),
|
|
1040
|
+
getValueFromEvent: (value) => Array.isArray(value) && value.length === 2 && value.every(dayjs.isDayjs) ? [value[0].format("YYYY-MM-DD"), value[1].format("YYYY-MM-DD")] : void 0
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
return {};
|
|
1044
|
+
}
|
|
1045
|
+
function renderControl(field) {
|
|
1046
|
+
switch (field.type) {
|
|
1047
|
+
case "input":
|
|
1048
|
+
return /* @__PURE__ */ jsx10(Input, { placeholder: field.placeholder });
|
|
1049
|
+
case "password":
|
|
1050
|
+
return /* @__PURE__ */ jsx10(Input.Password, { placeholder: field.placeholder });
|
|
1051
|
+
case "textarea":
|
|
1052
|
+
return /* @__PURE__ */ jsx10(Input.TextArea, { placeholder: field.placeholder });
|
|
1053
|
+
case "number":
|
|
1054
|
+
return /* @__PURE__ */ jsx10(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
|
|
1055
|
+
case "select":
|
|
1056
|
+
return /* @__PURE__ */ jsx10(Select, { placeholder: field.placeholder, options: field.options });
|
|
1057
|
+
case "radio":
|
|
1058
|
+
return /* @__PURE__ */ jsx10(Radio.Group, { options: field.options });
|
|
1059
|
+
case "checkbox":
|
|
1060
|
+
return /* @__PURE__ */ jsx10(Checkbox, {});
|
|
1061
|
+
case "switch":
|
|
1062
|
+
return /* @__PURE__ */ jsx10(Switch, {});
|
|
1063
|
+
case "date":
|
|
1064
|
+
return /* @__PURE__ */ jsx10(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1065
|
+
case "dateRange":
|
|
1066
|
+
return /* @__PURE__ */ jsx10(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
var SchemaForm = forwardRef6(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1070
|
+
const result = validateSchemaForm(schema);
|
|
1071
|
+
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1072
|
+
const defaults = schemaInitialValues(schema);
|
|
1073
|
+
return /* @__PURE__ */ jsxs5(
|
|
1074
|
+
Form,
|
|
1075
|
+
{
|
|
1076
|
+
...formProps,
|
|
1077
|
+
ref,
|
|
1078
|
+
layout,
|
|
1079
|
+
initialValues: { ...defaults, ...initialValues },
|
|
1080
|
+
onFinish: (values) => {
|
|
1081
|
+
onSubmit?.(values);
|
|
1082
|
+
onFinish?.(values);
|
|
1083
|
+
},
|
|
1084
|
+
onValuesChange: (changedValues, allValues) => {
|
|
1085
|
+
onChange?.(changedValues, allValues);
|
|
1086
|
+
onValuesChange?.(changedValues, allValues);
|
|
1087
|
+
},
|
|
1088
|
+
children: [
|
|
1089
|
+
schema.fields.map((field) => {
|
|
1090
|
+
const mapped = mapSchemaField(field);
|
|
1091
|
+
return /* @__PURE__ */ jsx10(
|
|
1092
|
+
Form.Item,
|
|
1093
|
+
{
|
|
1094
|
+
name: mapped.name,
|
|
1095
|
+
label: mapped.label,
|
|
1096
|
+
valuePropName: mapped.valuePropName,
|
|
1097
|
+
rules: fieldRules(field),
|
|
1098
|
+
...dateItemProps(field),
|
|
1099
|
+
children: renderControl(field)
|
|
1100
|
+
},
|
|
1101
|
+
mapped.name
|
|
1102
|
+
);
|
|
1103
|
+
}),
|
|
1104
|
+
/* @__PURE__ */ jsx10(Form.Item, { children: /* @__PURE__ */ jsx10(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
|
|
1105
|
+
]
|
|
1106
|
+
}
|
|
1107
|
+
);
|
|
1108
|
+
});
|
|
1109
|
+
export {
|
|
1110
|
+
Affix,
|
|
1111
|
+
Alert,
|
|
1112
|
+
Anchor,
|
|
1113
|
+
App,
|
|
1114
|
+
AutoComplete,
|
|
1115
|
+
Avatar,
|
|
1116
|
+
BUSINESS_DRAWER_WIDTH,
|
|
1117
|
+
BackTop,
|
|
1118
|
+
Badge,
|
|
1119
|
+
BorderBeam,
|
|
1120
|
+
Breadcrumb,
|
|
1121
|
+
BusinessDrawer,
|
|
1122
|
+
Button,
|
|
1123
|
+
Calendar,
|
|
1124
|
+
Card,
|
|
1125
|
+
Carousel,
|
|
1126
|
+
Cascader,
|
|
1127
|
+
Checkbox,
|
|
1128
|
+
Col,
|
|
1129
|
+
Collapse,
|
|
1130
|
+
ColorPicker,
|
|
1131
|
+
ConfigProvider,
|
|
1132
|
+
CrudScaffold,
|
|
1133
|
+
DataTable,
|
|
1134
|
+
DatePicker,
|
|
1135
|
+
Descriptions,
|
|
1136
|
+
Divider,
|
|
1137
|
+
Drawer,
|
|
1138
|
+
Dropdown,
|
|
1139
|
+
EllipsisText,
|
|
1140
|
+
Empty,
|
|
1141
|
+
Flex,
|
|
1142
|
+
FloatButton,
|
|
1143
|
+
Form,
|
|
1144
|
+
Grid,
|
|
1145
|
+
Image,
|
|
1146
|
+
Input,
|
|
1147
|
+
InputNumber,
|
|
1148
|
+
Layout,
|
|
1149
|
+
List,
|
|
1150
|
+
Listy,
|
|
1151
|
+
Masonry,
|
|
1152
|
+
Mentions,
|
|
1153
|
+
Menu,
|
|
1154
|
+
Modal,
|
|
1155
|
+
Pagination,
|
|
1156
|
+
Popconfirm,
|
|
1157
|
+
Popover,
|
|
1158
|
+
Progress,
|
|
1159
|
+
QRCode,
|
|
1160
|
+
Radio,
|
|
1161
|
+
Rate,
|
|
1162
|
+
Result,
|
|
1163
|
+
Row,
|
|
1164
|
+
RowActions,
|
|
1165
|
+
SchemaForm,
|
|
1166
|
+
SearchPanel,
|
|
1167
|
+
Segmented,
|
|
1168
|
+
Select,
|
|
1169
|
+
Skeleton,
|
|
1170
|
+
Slider,
|
|
1171
|
+
Space,
|
|
1172
|
+
Spin,
|
|
1173
|
+
Splitter,
|
|
1174
|
+
Statistic,
|
|
1175
|
+
Steps,
|
|
1176
|
+
Switch,
|
|
1177
|
+
Table,
|
|
1178
|
+
TableEmpty,
|
|
1179
|
+
Tabs,
|
|
1180
|
+
Tag,
|
|
1181
|
+
ThemeModeButton,
|
|
1182
|
+
TimePicker,
|
|
1183
|
+
Timeline,
|
|
1184
|
+
Tooltip,
|
|
1185
|
+
Tour,
|
|
1186
|
+
Transfer,
|
|
1187
|
+
Tree,
|
|
1188
|
+
TreeSelect,
|
|
1189
|
+
Typography,
|
|
1190
|
+
Upload,
|
|
1191
|
+
Watermark,
|
|
1192
|
+
WorkspaceLayout,
|
|
1193
|
+
mapSchemaField,
|
|
1194
|
+
schemaInitialValues,
|
|
1195
|
+
tableBodyHeight,
|
|
1196
|
+
theme2 as theme,
|
|
1197
|
+
validateSchemaForm
|
|
1198
|
+
};
|
|
1199
|
+
//# sourceMappingURL=index.js.map
|