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