@amsintegra/design-system 1.0.0
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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/index.cjs +1127 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +522 -0
- package/dist/index.d.ts +522 -0
- package/dist/index.js +730 -0
- package/dist/index.js.map +1 -0
- package/llms.txt +78 -0
- package/package.json +103 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,730 @@
|
|
|
1
|
+
import { Button as Button$1, Tag as Tag$1, theme, ConfigProvider, App, Pagination as Pagination$1, Switch, Skeleton, Table, Modal, Select, Upload, Breadcrumb } from 'antd';
|
|
2
|
+
export { Affix, Alert, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Calendar, Card, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker, DatePicker, Descriptions, Divider, Drawer, Dropdown, Empty, Flex, FloatButton, Form, Image, Input, InputNumber, Layout, List, Mentions, Menu, Modal, Popconfirm, Popover, Progress, QRCode, Radio, Rate, Result, Row, Segmented, Select, Skeleton, Slider, Space, Spin, Splitter, Statistic, Steps, Switch, Table, Tabs, TimePicker, Timeline, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, Watermark } from 'antd';
|
|
3
|
+
import { createContext, forwardRef, useContext, useState, useCallback, useMemo, isValidElement, cloneElement, useEffect } from 'react';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { DownloadOutlined, BulbOutlined, BulbFilled, InboxOutlined } from '@ant-design/icons';
|
|
6
|
+
export { CheckCircleOutlined, CheckOutlined, CloseCircleOutlined, CloseOutlined, DeleteOutlined, DownOutlined, DownloadOutlined, EditOutlined, ExclamationCircleOutlined, EyeInvisibleOutlined, EyeOutlined, FileExcelOutlined, FileOutlined, FilePdfOutlined, FilterOutlined, FolderOutlined, InfoCircleOutlined, LeftOutlined, LoadingOutlined, LogoutOutlined, MenuOutlined, PlusOutlined, ReloadOutlined, RightOutlined, SearchOutlined, SettingOutlined, UpOutlined, UploadOutlined, UserOutlined, WarningOutlined } from '@ant-design/icons';
|
|
7
|
+
|
|
8
|
+
// src/theme/AmsConfigProvider.tsx
|
|
9
|
+
|
|
10
|
+
// src/theme/tokens.ts
|
|
11
|
+
var primitives = {
|
|
12
|
+
brandRed: "#A72432",
|
|
13
|
+
brandRedActive: "#8B1D28",
|
|
14
|
+
// darken 10%
|
|
15
|
+
brandRedLight: "#f1faff",
|
|
16
|
+
green: "#50cd89",
|
|
17
|
+
greenActive: "#47be7d",
|
|
18
|
+
greenLight: "#e8fff3",
|
|
19
|
+
purple: "#7239ea",
|
|
20
|
+
purpleActive: "#5014d0",
|
|
21
|
+
purpleLight: "#f8f5ff",
|
|
22
|
+
pink: "#f1416c",
|
|
23
|
+
pinkActive: "#d9214e",
|
|
24
|
+
pinkLight: "#fff5f8",
|
|
25
|
+
yellow: "#ffc700",
|
|
26
|
+
yellowActive: "#f1bc00",
|
|
27
|
+
yellowLight: "#fff8dd",
|
|
28
|
+
white: "#ffffff",
|
|
29
|
+
gray: {
|
|
30
|
+
100: "#f9f9f9",
|
|
31
|
+
200: "#f4f4f4",
|
|
32
|
+
300: "#e1e3ea",
|
|
33
|
+
400: "#b5b5c3",
|
|
34
|
+
500: "#a1a5b7",
|
|
35
|
+
600: "#7e8299",
|
|
36
|
+
700: "#5e6278",
|
|
37
|
+
800: "#3f4254",
|
|
38
|
+
900: "#181c32"
|
|
39
|
+
},
|
|
40
|
+
background: {
|
|
41
|
+
app: "#f5f8fa",
|
|
42
|
+
body: "#ffffff",
|
|
43
|
+
appDark: "#151521",
|
|
44
|
+
bodyDark: "#1e1e2d"
|
|
45
|
+
},
|
|
46
|
+
dark: {
|
|
47
|
+
base: "#181c32",
|
|
48
|
+
bg: "#151521",
|
|
49
|
+
header: "#1e1e2d",
|
|
50
|
+
active: "#2a2a3c",
|
|
51
|
+
separator: "#393945",
|
|
52
|
+
// Dark-mode surfaces (from mf-container's antdTheme).
|
|
53
|
+
inputBg: "#1b1b29",
|
|
54
|
+
cardBg: "#1e1e2d",
|
|
55
|
+
// Dark-mode gray scale — DISTINCT from the light `gray` scale (Metronic).
|
|
56
|
+
gray: {
|
|
57
|
+
100: "#2b2b40",
|
|
58
|
+
200: "#323248",
|
|
59
|
+
300: "#3b3b64",
|
|
60
|
+
400: "#474761",
|
|
61
|
+
500: "#565674",
|
|
62
|
+
600: "#6d6d80",
|
|
63
|
+
700: "#92929f",
|
|
64
|
+
800: "#cdcdde"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var radius = {
|
|
69
|
+
sm: 2,
|
|
70
|
+
base: 4,
|
|
71
|
+
md: 6,
|
|
72
|
+
lg: 8,
|
|
73
|
+
xl: 12
|
|
74
|
+
};
|
|
75
|
+
var typography = {
|
|
76
|
+
fontFamily: "Inter, Helvetica, Arial, sans-serif",
|
|
77
|
+
fontSizeBase: 13,
|
|
78
|
+
weight: {
|
|
79
|
+
light: 300,
|
|
80
|
+
normal: 400,
|
|
81
|
+
medium: 500,
|
|
82
|
+
semibold: 600,
|
|
83
|
+
bold: 700
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var sizing = {
|
|
87
|
+
controlHeight: 32,
|
|
88
|
+
buttonMinWidth: 110
|
|
89
|
+
};
|
|
90
|
+
var semantic = {
|
|
91
|
+
colorPrimary: primitives.brandRed,
|
|
92
|
+
colorPrimaryActive: primitives.brandRedActive,
|
|
93
|
+
colorSuccess: primitives.green,
|
|
94
|
+
colorInfo: primitives.purple,
|
|
95
|
+
colorError: primitives.pink,
|
|
96
|
+
colorWarning: primitives.yellow,
|
|
97
|
+
// Links. Metronic inherits link color from the (red) primary, which reads as
|
|
98
|
+
// "danger" in dense UIs. The AMS default uses a neutral dark gray so links
|
|
99
|
+
// don't look like errors; consumers can override `colorLink`/`colorLinkHover`
|
|
100
|
+
// via AmsConfigProvider's `theme` prop (e.g. back to the brand red or blue).
|
|
101
|
+
colorLink: primitives.gray[800],
|
|
102
|
+
colorLinkHover: primitives.brandRed,
|
|
103
|
+
colorLinkActive: primitives.brandRedActive,
|
|
104
|
+
colorBgLayout: primitives.background.app,
|
|
105
|
+
colorBgContainer: primitives.background.body,
|
|
106
|
+
borderRadius: radius.base,
|
|
107
|
+
fontFamily: typography.fontFamily,
|
|
108
|
+
fontSize: typography.fontSizeBase,
|
|
109
|
+
controlHeight: sizing.controlHeight
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/theme/theme.ts
|
|
113
|
+
var sharedToken = {
|
|
114
|
+
colorPrimary: semantic.colorPrimary,
|
|
115
|
+
colorSuccess: semantic.colorSuccess,
|
|
116
|
+
colorInfo: semantic.colorInfo,
|
|
117
|
+
colorError: semantic.colorError,
|
|
118
|
+
colorWarning: semantic.colorWarning,
|
|
119
|
+
colorLink: semantic.colorLink,
|
|
120
|
+
colorLinkHover: semantic.colorLinkHover,
|
|
121
|
+
colorLinkActive: semantic.colorLinkActive,
|
|
122
|
+
borderRadius: semantic.borderRadius,
|
|
123
|
+
fontFamily: semantic.fontFamily,
|
|
124
|
+
fontSize: semantic.fontSize,
|
|
125
|
+
controlHeight: semantic.controlHeight
|
|
126
|
+
};
|
|
127
|
+
var lightToken = {
|
|
128
|
+
...sharedToken,
|
|
129
|
+
colorBgLayout: semantic.colorBgLayout,
|
|
130
|
+
colorBgContainer: semantic.colorBgContainer,
|
|
131
|
+
colorBgElevated: primitives.background.body,
|
|
132
|
+
colorText: primitives.gray[900],
|
|
133
|
+
colorTextSecondary: primitives.gray[700],
|
|
134
|
+
colorTextTertiary: primitives.gray[500],
|
|
135
|
+
colorTextQuaternary: primitives.gray[400],
|
|
136
|
+
colorBorder: primitives.gray[300],
|
|
137
|
+
colorBorderSecondary: primitives.gray[200]
|
|
138
|
+
};
|
|
139
|
+
var darkToken = {
|
|
140
|
+
...sharedToken,
|
|
141
|
+
colorBgLayout: primitives.background.appDark,
|
|
142
|
+
colorBgContainer: primitives.background.bodyDark,
|
|
143
|
+
colorBgElevated: primitives.background.bodyDark,
|
|
144
|
+
colorText: "#ffffff",
|
|
145
|
+
colorTextHeading: "#ffffff",
|
|
146
|
+
colorTextSecondary: primitives.dark.gray[800],
|
|
147
|
+
colorTextTertiary: primitives.dark.gray[700],
|
|
148
|
+
colorTextQuaternary: primitives.dark.gray[600],
|
|
149
|
+
colorBorder: primitives.dark.gray[300],
|
|
150
|
+
colorBorderSecondary: primitives.dark.gray[200],
|
|
151
|
+
boxShadow: "0 6px 16px 0 rgba(0, 0, 0, 0.48), 0 3px 6px -4px rgba(0, 0, 0, 0.36), 0 9px 28px 8px rgba(0, 0, 0, 0.15)"
|
|
152
|
+
};
|
|
153
|
+
var sharedComponents = {
|
|
154
|
+
Button: { controlHeight: 32 },
|
|
155
|
+
Tabs: {
|
|
156
|
+
itemColor: primitives.gray[600],
|
|
157
|
+
itemSelectedColor: semantic.colorPrimary,
|
|
158
|
+
itemHoverColor: semantic.colorPrimary
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var lightComponents = {
|
|
162
|
+
...sharedComponents,
|
|
163
|
+
Table: {
|
|
164
|
+
headerBg: primitives.gray[100],
|
|
165
|
+
headerColor: primitives.gray[800],
|
|
166
|
+
borderColor: primitives.gray[300],
|
|
167
|
+
cellPaddingBlock: 8,
|
|
168
|
+
cellPaddingInline: 8
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var darkComponents = {
|
|
172
|
+
...sharedComponents,
|
|
173
|
+
Table: {
|
|
174
|
+
headerBg: primitives.dark.gray[200],
|
|
175
|
+
headerColor: primitives.dark.gray[800],
|
|
176
|
+
borderColor: primitives.dark.gray[400],
|
|
177
|
+
rowHoverBg: primitives.dark.gray[200],
|
|
178
|
+
cellPaddingBlock: 8,
|
|
179
|
+
cellPaddingInline: 8
|
|
180
|
+
},
|
|
181
|
+
Input: {
|
|
182
|
+
colorBgContainer: primitives.dark.inputBg,
|
|
183
|
+
colorBorder: primitives.dark.gray[400],
|
|
184
|
+
colorText: "#ffffff"
|
|
185
|
+
},
|
|
186
|
+
Select: {
|
|
187
|
+
colorBgContainer: primitives.dark.inputBg,
|
|
188
|
+
colorBorder: primitives.dark.gray[400],
|
|
189
|
+
colorText: "#ffffff"
|
|
190
|
+
},
|
|
191
|
+
DatePicker: {
|
|
192
|
+
colorBgContainer: primitives.dark.inputBg
|
|
193
|
+
},
|
|
194
|
+
Card: {
|
|
195
|
+
colorBgContainer: primitives.dark.cardBg,
|
|
196
|
+
colorBorderSecondary: primitives.dark.cardBg
|
|
197
|
+
},
|
|
198
|
+
Modal: {
|
|
199
|
+
contentBg: primitives.dark.gray[100],
|
|
200
|
+
headerBg: primitives.dark.gray[100]
|
|
201
|
+
},
|
|
202
|
+
Drawer: {
|
|
203
|
+
colorBgElevated: primitives.dark.gray[100]
|
|
204
|
+
},
|
|
205
|
+
Notification: {
|
|
206
|
+
colorBgElevated: primitives.dark.gray[100]
|
|
207
|
+
},
|
|
208
|
+
Message: {
|
|
209
|
+
contentBg: primitives.dark.gray[100]
|
|
210
|
+
},
|
|
211
|
+
Menu: {
|
|
212
|
+
itemBg: primitives.background.bodyDark,
|
|
213
|
+
itemHoverBg: primitives.dark.gray[100],
|
|
214
|
+
itemSelectedBg: primitives.dark.active,
|
|
215
|
+
itemSelectedColor: semantic.colorPrimary,
|
|
216
|
+
itemActiveBg: primitives.dark.active,
|
|
217
|
+
subMenuItemBg: primitives.background.bodyDark
|
|
218
|
+
},
|
|
219
|
+
Dropdown: {
|
|
220
|
+
colorBgElevated: primitives.background.bodyDark,
|
|
221
|
+
controlItemBgHover: primitives.dark.gray[100]
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
function buildTheme(mode = "light") {
|
|
225
|
+
const isDark = mode === "dark";
|
|
226
|
+
return {
|
|
227
|
+
algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
|
|
228
|
+
token: isDark ? darkToken : lightToken,
|
|
229
|
+
components: isDark ? darkComponents : lightComponents
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
var amsTheme = buildTheme("light");
|
|
233
|
+
var amsThemeDark = buildTheme("dark");
|
|
234
|
+
var STORAGE_KEY = "ams-theme";
|
|
235
|
+
function getInitialThemeMode(defaultMode = "light") {
|
|
236
|
+
if (typeof window === "undefined") return defaultMode;
|
|
237
|
+
const saved = window.localStorage.getItem(STORAGE_KEY);
|
|
238
|
+
if (saved === "light" || saved === "dark") return saved;
|
|
239
|
+
if (window.matchMedia?.("(prefers-color-scheme: dark)").matches) return "dark";
|
|
240
|
+
return defaultMode;
|
|
241
|
+
}
|
|
242
|
+
function applyThemeModeToDOM(mode) {
|
|
243
|
+
if (typeof document === "undefined") return;
|
|
244
|
+
document.documentElement.setAttribute("data-theme", mode);
|
|
245
|
+
document.body?.setAttribute("data-theme", mode);
|
|
246
|
+
}
|
|
247
|
+
var ThemeModeContext = createContext(null);
|
|
248
|
+
function useThemeMode() {
|
|
249
|
+
const ctx = useContext(ThemeModeContext);
|
|
250
|
+
if (!ctx) {
|
|
251
|
+
throw new Error("useThemeMode must be used within an AmsConfigProvider");
|
|
252
|
+
}
|
|
253
|
+
return ctx;
|
|
254
|
+
}
|
|
255
|
+
function useThemeModeState(controlledMode, defaultMode, persist) {
|
|
256
|
+
const isControlled = controlledMode !== void 0;
|
|
257
|
+
const [internalMode, setInternalMode] = useState(
|
|
258
|
+
() => isControlled ? controlledMode : persist ? getInitialThemeMode(defaultMode) : defaultMode
|
|
259
|
+
);
|
|
260
|
+
const mode = isControlled ? controlledMode : internalMode;
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
applyThemeModeToDOM(mode);
|
|
263
|
+
}, [mode]);
|
|
264
|
+
const setMode = useCallback(
|
|
265
|
+
(next) => {
|
|
266
|
+
if (!isControlled) {
|
|
267
|
+
setInternalMode(next);
|
|
268
|
+
if (persist && typeof window !== "undefined") {
|
|
269
|
+
window.localStorage.setItem(STORAGE_KEY, next);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
[isControlled, persist]
|
|
274
|
+
);
|
|
275
|
+
const toggle = useCallback(() => {
|
|
276
|
+
setMode(mode === "light" ? "dark" : "light");
|
|
277
|
+
}, [mode, setMode]);
|
|
278
|
+
return useMemo(
|
|
279
|
+
() => ({ mode, setMode, toggle, isDark: mode === "dark" }),
|
|
280
|
+
[mode, setMode, toggle]
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function mergeTheme(base, override) {
|
|
284
|
+
if (!override) return base;
|
|
285
|
+
return {
|
|
286
|
+
...base,
|
|
287
|
+
...override,
|
|
288
|
+
token: { ...base.token, ...override.token },
|
|
289
|
+
components: { ...base.components, ...override.components },
|
|
290
|
+
// A caller-provided algorithm wins; otherwise keep the mode's algorithm.
|
|
291
|
+
algorithm: override.algorithm ?? base.algorithm
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function AmsConfigProvider({
|
|
295
|
+
mode,
|
|
296
|
+
defaultMode = "light",
|
|
297
|
+
persistMode = true,
|
|
298
|
+
locale,
|
|
299
|
+
theme,
|
|
300
|
+
children
|
|
301
|
+
}) {
|
|
302
|
+
const themeMode = useThemeModeState(mode, defaultMode, persistMode);
|
|
303
|
+
const resolvedTheme = mergeTheme(buildTheme(themeMode.mode), theme);
|
|
304
|
+
return /* @__PURE__ */ jsx(ThemeModeContext.Provider, { value: themeMode, children: /* @__PURE__ */ jsx(ConfigProvider, { theme: resolvedTheme, locale, children: /* @__PURE__ */ jsx(App, { children }) }) });
|
|
305
|
+
}
|
|
306
|
+
var Button = forwardRef(
|
|
307
|
+
function Button2(props, ref) {
|
|
308
|
+
return /* @__PURE__ */ jsx(Button$1, { ref, ...props });
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
var INTENT_COLOR = {
|
|
312
|
+
success: semantic.colorSuccess,
|
|
313
|
+
error: semantic.colorError,
|
|
314
|
+
warning: semantic.colorWarning,
|
|
315
|
+
info: semantic.colorInfo,
|
|
316
|
+
primary: semantic.colorPrimary
|
|
317
|
+
};
|
|
318
|
+
var Tag = forwardRef(function Tag2({ intent, color, ...rest }, ref) {
|
|
319
|
+
const resolvedColor = intent ? INTENT_COLOR[intent] : color;
|
|
320
|
+
return /* @__PURE__ */ jsx(Tag$1, { ref, color: resolvedColor, ...rest });
|
|
321
|
+
});
|
|
322
|
+
function useAmsMessage() {
|
|
323
|
+
return App.useApp().message;
|
|
324
|
+
}
|
|
325
|
+
function useAmsNotification() {
|
|
326
|
+
return App.useApp().notification;
|
|
327
|
+
}
|
|
328
|
+
function buildLocale(labels) {
|
|
329
|
+
if (!labels) return void 0;
|
|
330
|
+
const locale = {};
|
|
331
|
+
if (labels.itemsPerPage !== void 0) locale.items_per_page = labels.itemsPerPage;
|
|
332
|
+
if (labels.jumpTo !== void 0) locale.jump_to = labels.jumpTo;
|
|
333
|
+
if (labels.jumpToConfirm !== void 0) locale.jump_to_confirm = labels.jumpToConfirm;
|
|
334
|
+
if (labels.page !== void 0) locale.page = labels.page;
|
|
335
|
+
if (labels.prevPage !== void 0) locale.prev_page = labels.prevPage;
|
|
336
|
+
if (labels.nextPage !== void 0) locale.next_page = labels.nextPage;
|
|
337
|
+
if (labels.pageSize !== void 0) locale.page_size = labels.pageSize;
|
|
338
|
+
return Object.keys(locale).length > 0 ? locale : void 0;
|
|
339
|
+
}
|
|
340
|
+
function Pagination({
|
|
341
|
+
labels,
|
|
342
|
+
showTotal,
|
|
343
|
+
itemRender,
|
|
344
|
+
locale,
|
|
345
|
+
...rest
|
|
346
|
+
}) {
|
|
347
|
+
const mergedLocale = { ...buildLocale(labels), ...locale };
|
|
348
|
+
const resolvedShowTotal = showTotal ?? (labels?.total ? (total, range) => labels.total(total, range) : labels?.totalText ? (total, range) => {
|
|
349
|
+
const { prefix, suffix, showRange } = labels.totalText;
|
|
350
|
+
const middle = showRange ? `${range[0]}-${range[1]}` : String(total);
|
|
351
|
+
return [prefix, middle, suffix].filter(Boolean).join(" ");
|
|
352
|
+
} : void 0);
|
|
353
|
+
const resolvedItemRender = itemRender ?? (labels?.previousText || labels?.nextText ? (_page, type, element) => {
|
|
354
|
+
if (type === "prev" && labels?.previousText !== void 0) return labels.previousText;
|
|
355
|
+
if (type === "next" && labels?.nextText !== void 0) return labels.nextText;
|
|
356
|
+
return element;
|
|
357
|
+
} : void 0);
|
|
358
|
+
return /* @__PURE__ */ jsx(
|
|
359
|
+
Pagination$1,
|
|
360
|
+
{
|
|
361
|
+
...rest,
|
|
362
|
+
locale: Object.keys(mergedLocale).length > 0 ? mergedLocale : void 0,
|
|
363
|
+
showTotal: resolvedShowTotal,
|
|
364
|
+
itemRender: resolvedItemRender
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
function ThemeToggle(props) {
|
|
369
|
+
const { isDark, toggle } = useThemeMode();
|
|
370
|
+
return /* @__PURE__ */ jsx(
|
|
371
|
+
Switch,
|
|
372
|
+
{
|
|
373
|
+
checked: isDark,
|
|
374
|
+
onChange: toggle,
|
|
375
|
+
checkedChildren: /* @__PURE__ */ jsx(BulbFilled, {}),
|
|
376
|
+
unCheckedChildren: /* @__PURE__ */ jsx(BulbOutlined, {}),
|
|
377
|
+
...props
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
function buildPaginationLocale(labels) {
|
|
382
|
+
if (!labels) return void 0;
|
|
383
|
+
const locale = {};
|
|
384
|
+
if (labels.itemsPerPage !== void 0) locale.items_per_page = labels.itemsPerPage;
|
|
385
|
+
if (labels.jumpTo !== void 0) locale.jump_to = labels.jumpTo;
|
|
386
|
+
if (labels.jumpToConfirm !== void 0) locale.jump_to_confirm = labels.jumpToConfirm;
|
|
387
|
+
if (labels.page !== void 0) locale.page = labels.page;
|
|
388
|
+
if (labels.prevPage !== void 0) locale.prev_page = labels.prevPage;
|
|
389
|
+
if (labels.nextPage !== void 0) locale.next_page = labels.nextPage;
|
|
390
|
+
if (labels.pageSize !== void 0) locale.page_size = labels.pageSize;
|
|
391
|
+
return Object.keys(locale).length > 0 ? locale : void 0;
|
|
392
|
+
}
|
|
393
|
+
var DEFAULT_LABELS = {
|
|
394
|
+
emptyText: "No data",
|
|
395
|
+
sortAsc: "Sort ascending",
|
|
396
|
+
sortDesc: "Sort descending",
|
|
397
|
+
cancelSort: "Cancel sort"
|
|
398
|
+
};
|
|
399
|
+
function toNumericValue(value) {
|
|
400
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
401
|
+
const num = typeof value === "string" ? parseFloat(value.replace(/,/g, "")) : Number(value);
|
|
402
|
+
return Number.isNaN(num) || !Number.isFinite(num) ? null : num;
|
|
403
|
+
}
|
|
404
|
+
function buildTotalText(labels) {
|
|
405
|
+
if (!labels) return void 0;
|
|
406
|
+
if (labels.total) return (total, range) => labels.total(total, range);
|
|
407
|
+
if (labels.totalText) {
|
|
408
|
+
return (total, range) => {
|
|
409
|
+
const { prefix, suffix, showRange } = labels.totalText;
|
|
410
|
+
const middle = showRange ? `${range[0]}-${range[1]}` : String(total);
|
|
411
|
+
return [prefix, middle, suffix].filter(Boolean).join(" ");
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return void 0;
|
|
415
|
+
}
|
|
416
|
+
function buildItemRender(labels) {
|
|
417
|
+
if (!labels || labels.previousText === void 0 && labels.nextText === void 0) {
|
|
418
|
+
return void 0;
|
|
419
|
+
}
|
|
420
|
+
return (_page, type, element) => {
|
|
421
|
+
if (type === "prev" && labels.previousText !== void 0) return labels.previousText;
|
|
422
|
+
if (type === "next" && labels.nextText !== void 0) return labels.nextText;
|
|
423
|
+
return element;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function DataTable({
|
|
427
|
+
heading,
|
|
428
|
+
extra,
|
|
429
|
+
loading = false,
|
|
430
|
+
labels,
|
|
431
|
+
paginationLabels,
|
|
432
|
+
firstColumnNumericTag = false,
|
|
433
|
+
columns,
|
|
434
|
+
dataSource,
|
|
435
|
+
scroll,
|
|
436
|
+
bordered = true,
|
|
437
|
+
pagination,
|
|
438
|
+
className,
|
|
439
|
+
...rest
|
|
440
|
+
}) {
|
|
441
|
+
const mergedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
442
|
+
const resolvedPagination = pagination === false || pagination === void 0 ? pagination : (() => {
|
|
443
|
+
const paginationLocale = buildPaginationLocale(paginationLabels);
|
|
444
|
+
const totalFn = buildTotalText(paginationLabels);
|
|
445
|
+
const itemRenderFn = buildItemRender(paginationLabels);
|
|
446
|
+
return {
|
|
447
|
+
...totalFn ? { showTotal: totalFn } : {},
|
|
448
|
+
...itemRenderFn ? { itemRender: itemRenderFn } : {},
|
|
449
|
+
...paginationLocale ? { locale: paginationLocale } : {},
|
|
450
|
+
...pagination
|
|
451
|
+
};
|
|
452
|
+
})();
|
|
453
|
+
const resolvedColumns = firstColumnNumericTag && columns && columns.length > 0 ? columns.map((col, index) => {
|
|
454
|
+
if (index !== 0) return col;
|
|
455
|
+
const originalRender = col.render;
|
|
456
|
+
return {
|
|
457
|
+
...col,
|
|
458
|
+
render: (value, record, i) => {
|
|
459
|
+
const content = originalRender ? originalRender(value, record, i) : value;
|
|
460
|
+
const numeric = toNumericValue(value);
|
|
461
|
+
if (numeric === null) return content;
|
|
462
|
+
return /* @__PURE__ */ jsx(
|
|
463
|
+
Tag,
|
|
464
|
+
{
|
|
465
|
+
intent: numeric < 0 ? "error" : "success",
|
|
466
|
+
style: { minWidth: 72, textAlign: "center" },
|
|
467
|
+
children: content
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}) : columns;
|
|
473
|
+
const resolvedScroll = scroll ?? { x: "max-content" };
|
|
474
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
475
|
+
heading ? /* @__PURE__ */ jsx("div", { style: { marginBottom: 8 }, children: /* @__PURE__ */ jsx("h3", { style: { margin: 0, fontWeight: 600 }, children: heading }) }) : null,
|
|
476
|
+
extra ? /* @__PURE__ */ jsx("div", { style: { marginBottom: 8 }, children: extra }) : null,
|
|
477
|
+
loading ? /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsx(Skeleton, { active: true, paragraph: { rows: 0 }, title: { width: "100%" } }, i)) }) : /* @__PURE__ */ jsx(
|
|
478
|
+
Table,
|
|
479
|
+
{
|
|
480
|
+
columns: resolvedColumns,
|
|
481
|
+
dataSource,
|
|
482
|
+
bordered,
|
|
483
|
+
scroll: resolvedScroll,
|
|
484
|
+
pagination: resolvedPagination,
|
|
485
|
+
locale: {
|
|
486
|
+
emptyText: mergedLabels.emptyText,
|
|
487
|
+
triggerAsc: mergedLabels.sortAsc,
|
|
488
|
+
triggerDesc: mergedLabels.sortDesc,
|
|
489
|
+
cancelSort: mergedLabels.cancelSort
|
|
490
|
+
},
|
|
491
|
+
...rest
|
|
492
|
+
}
|
|
493
|
+
)
|
|
494
|
+
] });
|
|
495
|
+
}
|
|
496
|
+
function useControllableState({
|
|
497
|
+
value,
|
|
498
|
+
defaultValue,
|
|
499
|
+
onChange
|
|
500
|
+
}) {
|
|
501
|
+
const isControlled = value !== void 0;
|
|
502
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
503
|
+
const current = isControlled ? value : internal;
|
|
504
|
+
const setValue = useCallback(
|
|
505
|
+
(next) => {
|
|
506
|
+
if (!isControlled) {
|
|
507
|
+
setInternal(next);
|
|
508
|
+
}
|
|
509
|
+
onChange?.(next);
|
|
510
|
+
},
|
|
511
|
+
[isControlled, onChange]
|
|
512
|
+
);
|
|
513
|
+
return [current, setValue];
|
|
514
|
+
}
|
|
515
|
+
function isPromise(value) {
|
|
516
|
+
return !!value && typeof value.then === "function";
|
|
517
|
+
}
|
|
518
|
+
function ModalDialog({
|
|
519
|
+
trigger,
|
|
520
|
+
children,
|
|
521
|
+
open,
|
|
522
|
+
defaultOpen = false,
|
|
523
|
+
closeOnOk = true,
|
|
524
|
+
closeOnCancel = true,
|
|
525
|
+
onOk,
|
|
526
|
+
onCancel,
|
|
527
|
+
onOpenChange,
|
|
528
|
+
...modalProps
|
|
529
|
+
}) {
|
|
530
|
+
const [isOpen, setOpen] = useControllableState({
|
|
531
|
+
value: open,
|
|
532
|
+
defaultValue: defaultOpen,
|
|
533
|
+
onChange: onOpenChange
|
|
534
|
+
});
|
|
535
|
+
const handleOpen = useCallback(() => setOpen(true), [setOpen]);
|
|
536
|
+
const handleCancel = useCallback(
|
|
537
|
+
(event) => {
|
|
538
|
+
onCancel?.(event);
|
|
539
|
+
if (closeOnCancel) setOpen(false);
|
|
540
|
+
},
|
|
541
|
+
[onCancel, closeOnCancel, setOpen]
|
|
542
|
+
);
|
|
543
|
+
const handleOk = useCallback(
|
|
544
|
+
async (event) => {
|
|
545
|
+
const result = onOk?.(event);
|
|
546
|
+
if (!closeOnOk) return;
|
|
547
|
+
if (isPromise(result)) {
|
|
548
|
+
try {
|
|
549
|
+
await result;
|
|
550
|
+
} finally {
|
|
551
|
+
setOpen(false);
|
|
552
|
+
}
|
|
553
|
+
} else {
|
|
554
|
+
setOpen(false);
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
[onOk, closeOnOk, setOpen]
|
|
558
|
+
);
|
|
559
|
+
const triggerNode = useMemo(() => {
|
|
560
|
+
if (!trigger) return null;
|
|
561
|
+
if (typeof trigger === "function") {
|
|
562
|
+
return trigger(handleOpen);
|
|
563
|
+
}
|
|
564
|
+
if (isValidElement(trigger)) {
|
|
565
|
+
const el = trigger;
|
|
566
|
+
const originalOnClick = el.props.onClick;
|
|
567
|
+
return cloneElement(el, {
|
|
568
|
+
onClick: (event) => {
|
|
569
|
+
originalOnClick?.(event);
|
|
570
|
+
handleOpen();
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return trigger;
|
|
575
|
+
}, [trigger, handleOpen]);
|
|
576
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
577
|
+
triggerNode,
|
|
578
|
+
/* @__PURE__ */ jsx(Modal, { open: isOpen, onOk: handleOk, onCancel: handleCancel, ...modalProps, children })
|
|
579
|
+
] });
|
|
580
|
+
}
|
|
581
|
+
var normalize = (value) => (value ?? "").toString().normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
582
|
+
var extractText = (node) => {
|
|
583
|
+
if (node === null || node === void 0) return "";
|
|
584
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "boolean") {
|
|
585
|
+
return String(node);
|
|
586
|
+
}
|
|
587
|
+
if (Array.isArray(node)) return node.map(extractText).join(" ");
|
|
588
|
+
if (typeof node === "object" && "props" in node) {
|
|
589
|
+
const props = node.props;
|
|
590
|
+
return extractText(props?.children);
|
|
591
|
+
}
|
|
592
|
+
return "";
|
|
593
|
+
};
|
|
594
|
+
function FilterSelect({
|
|
595
|
+
options,
|
|
596
|
+
showSearch = false,
|
|
597
|
+
filterOption,
|
|
598
|
+
className,
|
|
599
|
+
style,
|
|
600
|
+
...rest
|
|
601
|
+
}) {
|
|
602
|
+
const defaultFilter = (input, option) => {
|
|
603
|
+
if (!option) return false;
|
|
604
|
+
const query = normalize(input);
|
|
605
|
+
const label = normalize(extractText(option.label));
|
|
606
|
+
const value = normalize(typeof option.value === "string" ? option.value : "");
|
|
607
|
+
return label.includes(query) || value.includes(query);
|
|
608
|
+
};
|
|
609
|
+
const resolvedFilter = showSearch && !filterOption ? defaultFilter : filterOption;
|
|
610
|
+
return /* @__PURE__ */ jsx(
|
|
611
|
+
Select,
|
|
612
|
+
{
|
|
613
|
+
options,
|
|
614
|
+
showSearch,
|
|
615
|
+
filterOption: resolvedFilter,
|
|
616
|
+
optionFilterProp: "label",
|
|
617
|
+
className,
|
|
618
|
+
style: { width: "100%", ...style },
|
|
619
|
+
...rest
|
|
620
|
+
}
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
var resolveMessage = (template, fileName, fallback) => {
|
|
624
|
+
if (!template) return fallback.replace("{file}", fileName);
|
|
625
|
+
return typeof template === "function" ? template(fileName) : template.replace("{file}", fileName);
|
|
626
|
+
};
|
|
627
|
+
function FileUploadDragger({
|
|
628
|
+
successMessage,
|
|
629
|
+
errorMessage,
|
|
630
|
+
showStatusMessages = true,
|
|
631
|
+
hintText = "Click or drag a file to this area to upload",
|
|
632
|
+
onUploadSuccess,
|
|
633
|
+
onUploadError,
|
|
634
|
+
onChange: externalOnChange,
|
|
635
|
+
children,
|
|
636
|
+
...uploadProps
|
|
637
|
+
}) {
|
|
638
|
+
const message = useAmsMessage();
|
|
639
|
+
const mergedProps = useMemo(
|
|
640
|
+
() => ({
|
|
641
|
+
...uploadProps,
|
|
642
|
+
onChange(info) {
|
|
643
|
+
const { status, name: fileName } = info.file;
|
|
644
|
+
if (showStatusMessages) {
|
|
645
|
+
if (status === "done") {
|
|
646
|
+
message.success(resolveMessage(successMessage, fileName, `${fileName} uploaded successfully.`));
|
|
647
|
+
onUploadSuccess?.(info);
|
|
648
|
+
} else if (status === "error") {
|
|
649
|
+
message.error(resolveMessage(errorMessage, fileName, `${fileName} failed to upload.`));
|
|
650
|
+
onUploadError?.(info);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
externalOnChange?.(info);
|
|
654
|
+
}
|
|
655
|
+
}),
|
|
656
|
+
[uploadProps, showStatusMessages, message, successMessage, errorMessage, onUploadSuccess, onUploadError, externalOnChange]
|
|
657
|
+
);
|
|
658
|
+
return /* @__PURE__ */ jsx(Upload.Dragger, { ...mergedProps, children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
659
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(InboxOutlined, {}) }),
|
|
660
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: hintText })
|
|
661
|
+
] }) });
|
|
662
|
+
}
|
|
663
|
+
function PageHeader({
|
|
664
|
+
title,
|
|
665
|
+
breadcrumbs,
|
|
666
|
+
separator = ">",
|
|
667
|
+
uppercaseTitle = true,
|
|
668
|
+
extra,
|
|
669
|
+
className
|
|
670
|
+
}) {
|
|
671
|
+
return /* @__PURE__ */ jsxs("div", { className, style: { marginBottom: 32 }, children: [
|
|
672
|
+
/* @__PURE__ */ jsxs(
|
|
673
|
+
"div",
|
|
674
|
+
{
|
|
675
|
+
style: {
|
|
676
|
+
display: "flex",
|
|
677
|
+
alignItems: "center",
|
|
678
|
+
justifyContent: "space-between",
|
|
679
|
+
gap: 16
|
|
680
|
+
},
|
|
681
|
+
children: [
|
|
682
|
+
/* @__PURE__ */ jsx(
|
|
683
|
+
"h1",
|
|
684
|
+
{
|
|
685
|
+
style: {
|
|
686
|
+
fontSize: 20,
|
|
687
|
+
fontWeight: 700,
|
|
688
|
+
margin: 0,
|
|
689
|
+
textTransform: uppercaseTitle ? "uppercase" : void 0
|
|
690
|
+
},
|
|
691
|
+
children: title
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
extra ? /* @__PURE__ */ jsx("div", { children: extra }) : null
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
),
|
|
698
|
+
breadcrumbs && breadcrumbs.length > 0 ? /* @__PURE__ */ jsx(
|
|
699
|
+
Breadcrumb,
|
|
700
|
+
{
|
|
701
|
+
separator,
|
|
702
|
+
items: breadcrumbs,
|
|
703
|
+
style: { fontSize: 13, marginTop: 8 }
|
|
704
|
+
}
|
|
705
|
+
) : null
|
|
706
|
+
] });
|
|
707
|
+
}
|
|
708
|
+
var DownloadButton = forwardRef(function DownloadButton2({ label = "CSV", icon, type = "primary", children, ...rest }, ref) {
|
|
709
|
+
return /* @__PURE__ */ jsx(Button, { ref, type, icon: icon ?? /* @__PURE__ */ jsx(DownloadOutlined, {}), ...rest, children: children ?? label });
|
|
710
|
+
});
|
|
711
|
+
function ConfirmModal({
|
|
712
|
+
message,
|
|
713
|
+
danger = false,
|
|
714
|
+
okButtonProps,
|
|
715
|
+
children,
|
|
716
|
+
...rest
|
|
717
|
+
}) {
|
|
718
|
+
return /* @__PURE__ */ jsx(
|
|
719
|
+
ModalDialog,
|
|
720
|
+
{
|
|
721
|
+
okButtonProps: { danger, ...okButtonProps },
|
|
722
|
+
...rest,
|
|
723
|
+
children: children ?? (message ? /* @__PURE__ */ jsx("p", { children: message }) : null)
|
|
724
|
+
}
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
export { AmsConfigProvider, Button, ConfirmModal, DataTable, DownloadButton, FileUploadDragger, FilterSelect, ModalDialog, PageHeader, Pagination, Tag, ThemeToggle, amsTheme, amsThemeDark, applyThemeModeToDOM, buildTheme, getInitialThemeMode, primitives, radius, semantic, sizing, typography, useAmsMessage, useAmsNotification, useControllableState, useThemeMode };
|
|
729
|
+
//# sourceMappingURL=index.js.map
|
|
730
|
+
//# sourceMappingURL=index.js.map
|