@ug666/ui-core 0.3.0-beta.2 → 0.3.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/RELEASE_PROVENANCE.json +8 -0
- package/dist/chunk-SSXPAFU2.js +3 -0
- package/dist/chunk-SSXPAFU2.js.map +1 -0
- package/dist/compat/table-css.d.ts +12 -0
- package/dist/compat/table-css.d.ts.map +1 -0
- package/dist/controls/rating.d.ts.map +1 -0
- package/dist/controls/select-value.d.ts.map +1 -0
- package/dist/controls/selection-list.d.ts.map +1 -0
- package/dist/controls/text-value.d.ts.map +1 -0
- package/dist/date-time/calendar.d.ts.map +1 -0
- package/dist/date-time/date-picker-modes.d.ts.map +1 -0
- package/dist/date-time/date-range.d.ts.map +1 -0
- package/dist/date-time/date-time.d.ts.map +1 -0
- package/dist/form/form-state.d.ts.map +1 -0
- package/dist/form/form-validation.d.ts.map +1 -0
- package/dist/index.cjs +1 -1238
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -907
- package/dist/index.js.map +1 -1
- package/dist/{table-layout.d.ts → table/table-layout.d.ts} +2 -8
- package/dist/table/table-layout.d.ts.map +1 -0
- package/dist/table/table-structure.d.ts.map +1 -0
- package/dist/table/tree-table.d.ts.map +1 -0
- package/dist/theme/color.d.ts.map +1 -0
- package/dist/theme/state.d.ts +79 -0
- package/dist/theme/state.d.ts.map +1 -0
- package/dist/theme.cjs +1 -287
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.ts +2 -78
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +1 -26
- package/dist/tree/tree-check.d.ts.map +1 -0
- package/dist/tree/tree-drag.d.ts.map +1 -0
- package/dist/tree/tree-path.d.ts.map +1 -0
- package/package.json +2 -1
- package/dist/calendar.d.ts.map +0 -1
- package/dist/chunk-5S74COKZ.js +0 -256
- package/dist/chunk-5S74COKZ.js.map +0 -1
- package/dist/color.d.ts.map +0 -1
- package/dist/date-picker-modes.d.ts.map +0 -1
- package/dist/date-range.d.ts.map +0 -1
- package/dist/date-time.d.ts.map +0 -1
- package/dist/form-state.d.ts.map +0 -1
- package/dist/form-validation.d.ts.map +0 -1
- package/dist/rating.d.ts.map +0 -1
- package/dist/select-value.d.ts.map +0 -1
- package/dist/selection-list.d.ts.map +0 -1
- package/dist/table-layout.d.ts.map +0 -1
- package/dist/table-structure.d.ts.map +0 -1
- package/dist/text-value.d.ts.map +0 -1
- package/dist/tree-check.d.ts.map +0 -1
- package/dist/tree-drag.d.ts.map +0 -1
- package/dist/tree-path.d.ts.map +0 -1
- package/dist/tree-table.d.ts.map +0 -1
- /package/dist/{rating.d.ts → controls/rating.d.ts} +0 -0
- /package/dist/{select-value.d.ts → controls/select-value.d.ts} +0 -0
- /package/dist/{selection-list.d.ts → controls/selection-list.d.ts} +0 -0
- /package/dist/{text-value.d.ts → controls/text-value.d.ts} +0 -0
- /package/dist/{calendar.d.ts → date-time/calendar.d.ts} +0 -0
- /package/dist/{date-picker-modes.d.ts → date-time/date-picker-modes.d.ts} +0 -0
- /package/dist/{date-range.d.ts → date-time/date-range.d.ts} +0 -0
- /package/dist/{date-time.d.ts → date-time/date-time.d.ts} +0 -0
- /package/dist/{form-state.d.ts → form/form-state.d.ts} +0 -0
- /package/dist/{form-validation.d.ts → form/form-validation.d.ts} +0 -0
- /package/dist/{table-structure.d.ts → table/table-structure.d.ts} +0 -0
- /package/dist/{tree-table.d.ts → table/tree-table.d.ts} +0 -0
- /package/dist/{color.d.ts → theme/color.d.ts} +0 -0
- /package/dist/{tree-check.d.ts → tree/tree-check.d.ts} +0 -0
- /package/dist/{tree-drag.d.ts → tree/tree-drag.d.ts} +0 -0
- /package/dist/{tree-path.d.ts → tree/tree-path.d.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,1240 +1,3 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var index_exports = {};
|
|
23
|
-
__export(index_exports, {
|
|
24
|
-
addCalendarDays: () => addCalendarDays,
|
|
25
|
-
addCalendarMonths: () => addCalendarMonths,
|
|
26
|
-
applyUGThemeProfile: () => applyUGThemeProfile,
|
|
27
|
-
buildCalendarMonth: () => buildCalendarMonth,
|
|
28
|
-
buildCalendarWeekdays: () => buildCalendarWeekdays,
|
|
29
|
-
buildTimeSelectOptions: () => buildTimeSelectOptions,
|
|
30
|
-
calendarDateKey: () => calendarDateKey,
|
|
31
|
-
canDropTreeNode: () => canDropTreeNode,
|
|
32
|
-
compareCalendarDates: () => compareCalendarDates,
|
|
33
|
-
countTextCharacters: () => countTextCharacters,
|
|
34
|
-
createFormFieldArray: () => createFormFieldArray,
|
|
35
|
-
createUGThemeValue: () => createUGThemeValue,
|
|
36
|
-
datePickerModeKey: () => datePickerModeKey,
|
|
37
|
-
defaultUGNavigationColors: () => defaultUGNavigationColors,
|
|
38
|
-
defaultUGTheme: () => defaultUGTheme,
|
|
39
|
-
defaultUGThemeConfiguratorOptions: () => defaultUGThemeConfiguratorOptions,
|
|
40
|
-
defaultUGThemeNavigationColors: () => defaultUGThemeNavigationColors,
|
|
41
|
-
defaultUGThemeProfiles: () => defaultUGThemeProfiles,
|
|
42
|
-
encodeSelectValue: () => encodeSelectValue,
|
|
43
|
-
filterSelectionListOptions: () => filterSelectionListOptions,
|
|
44
|
-
findTreeNodePath: () => findTreeNodePath,
|
|
45
|
-
formatCalendarDay: () => formatCalendarDay,
|
|
46
|
-
formatCalendarMonth: () => formatCalendarMonth,
|
|
47
|
-
formatColorHex: () => formatColorHex,
|
|
48
|
-
formatTimeValue: () => formatTimeValue,
|
|
49
|
-
getAvailableTimeValues: () => getAvailableTimeValues,
|
|
50
|
-
getCalendarRangePosition: () => getCalendarRangePosition,
|
|
51
|
-
getFormPath: () => getFormPath,
|
|
52
|
-
getFormPaths: () => getFormPaths,
|
|
53
|
-
getImagePreviewLayout: () => getImagePreviewLayout,
|
|
54
|
-
getRatingKeyboardValue: () => getRatingKeyboardValue,
|
|
55
|
-
getSelectionListScope: () => getSelectionListScope,
|
|
56
|
-
getTableColumnFixed: () => getTableColumnFixed,
|
|
57
|
-
getTableColumnStyle: () => getTableColumnStyle,
|
|
58
|
-
getTableSpanGrid: () => getTableSpanGrid,
|
|
59
|
-
getTableStructure: () => getTableStructure,
|
|
60
|
-
getTimeColumnChoices: () => getTimeColumnChoices,
|
|
61
|
-
getTreeCheckState: () => getTreeCheckState,
|
|
62
|
-
groupSelectionListOptions: () => groupSelectionListOptions,
|
|
63
|
-
isEmptyFormValue: () => isEmptyFormValue,
|
|
64
|
-
isFormPathActive: () => isFormPathActive,
|
|
65
|
-
isFormPathWithin: () => isFormPathWithin,
|
|
66
|
-
isFormValueEqual: () => isFormValueEqual,
|
|
67
|
-
isSameCalendarDay: () => isSameCalendarDay,
|
|
68
|
-
isUGThemeProfileModified: () => isUGThemeProfileModified,
|
|
69
|
-
isValidCalendarDate: () => isValidCalendarDate,
|
|
70
|
-
isoWeekStart: () => isoWeekStart,
|
|
71
|
-
limitTextByCount: () => limitTextByCount,
|
|
72
|
-
localDateTimeKey: () => localDateTimeKey,
|
|
73
|
-
moveTableColumn: () => moveTableColumn,
|
|
74
|
-
normalizeCalendarDate: () => normalizeCalendarDate,
|
|
75
|
-
normalizeFormPath: () => normalizeFormPath,
|
|
76
|
-
normalizeRatingMax: () => normalizeRatingMax,
|
|
77
|
-
normalizeRatingValue: () => normalizeRatingValue,
|
|
78
|
-
normalizeSelectKeys: () => normalizeSelectKeys,
|
|
79
|
-
parseCalendarDateKey: () => parseCalendarDateKey,
|
|
80
|
-
parseCalendarRange: () => parseCalendarRange,
|
|
81
|
-
parseColorHex: () => parseColorHex,
|
|
82
|
-
parseDatePickerModeKey: () => parseDatePickerModeKey,
|
|
83
|
-
parseLocalDateTimeValue: () => parseLocalDateTimeValue,
|
|
84
|
-
parseTimeValue: () => parseTimeValue,
|
|
85
|
-
projectTreeTableRows: () => projectTreeTableRows,
|
|
86
|
-
resolveTableFixedColumns: () => resolveTableFixedColumns,
|
|
87
|
-
resolveUGNavigationColors: () => resolveUGNavigationColors,
|
|
88
|
-
resolveUGNavigationPalette: () => resolveUGNavigationPalette,
|
|
89
|
-
setFormPath: () => setFormPath,
|
|
90
|
-
startOfCalendarMonth: () => startOfCalendarMonth,
|
|
91
|
-
tableColumnLength: () => tableColumnLength,
|
|
92
|
-
toggleTreeCheckedKey: () => toggleTreeCheckedKey,
|
|
93
|
-
ugThemeProfileFields: () => ugThemeProfileFields,
|
|
94
|
-
updateSelectionListScope: () => updateSelectionListScope,
|
|
95
|
-
validateDatePickerModeValue: () => validateDatePickerModeValue,
|
|
96
|
-
validateDateRangeShortcut: () => validateDateRangeShortcut,
|
|
97
|
-
validateDateTimeRangeValue: () => validateDateTimeRangeValue,
|
|
98
|
-
validateDateTimeValue: () => validateDateTimeValue,
|
|
99
|
-
validateDateValue: () => validateDateValue,
|
|
100
|
-
validateFormValue: () => validateFormValue,
|
|
101
|
-
validateTimeRangeValue: () => validateTimeRangeValue,
|
|
102
|
-
validateTimeValue: () => validateTimeValue
|
|
103
|
-
});
|
|
104
|
-
module.exports = __toCommonJS(index_exports);
|
|
105
|
-
|
|
106
|
-
// src/theme.ts
|
|
107
|
-
var defaultUGThemeNavigationColors = {
|
|
108
|
-
default: {
|
|
109
|
-
light: {
|
|
110
|
-
background: "#ffffff",
|
|
111
|
-
text: "#475569",
|
|
112
|
-
activeBackground: "#ecf5ff",
|
|
113
|
-
activeText: "#1d4ed8",
|
|
114
|
-
hoverBackground: "#f1f5f9"
|
|
115
|
-
},
|
|
116
|
-
dark: {
|
|
117
|
-
background: "#151c28",
|
|
118
|
-
text: "#cbd5e1",
|
|
119
|
-
activeBackground: "#3178c2",
|
|
120
|
-
activeText: "#ffffff",
|
|
121
|
-
hoverBackground: "#293442"
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
minimal: {
|
|
125
|
-
light: {
|
|
126
|
-
background: "#ffffff",
|
|
127
|
-
text: "#334155",
|
|
128
|
-
activeBackground: "#e0f2fe",
|
|
129
|
-
activeText: "#0369a1",
|
|
130
|
-
hoverBackground: "#f8fafc"
|
|
131
|
-
},
|
|
132
|
-
dark: {
|
|
133
|
-
background: "#111827",
|
|
134
|
-
text: "#d1d5db",
|
|
135
|
-
activeBackground: "#164e63",
|
|
136
|
-
activeText: "#ecfeff",
|
|
137
|
-
hoverBackground: "#1f2937"
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
mecha: {
|
|
141
|
-
light: {
|
|
142
|
-
background: "#eef2f6",
|
|
143
|
-
text: "#334155",
|
|
144
|
-
activeBackground: "#cffafe",
|
|
145
|
-
activeText: "#0e7490",
|
|
146
|
-
hoverBackground: "#e2e8f0"
|
|
147
|
-
},
|
|
148
|
-
dark: {
|
|
149
|
-
background: "#0b1220",
|
|
150
|
-
text: "#cbd5e1",
|
|
151
|
-
activeBackground: "#155e75",
|
|
152
|
-
activeText: "#ecfeff",
|
|
153
|
-
hoverBackground: "#172033"
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var defaultUGNavigationColors = defaultUGThemeNavigationColors.default;
|
|
158
|
-
function resolveUGNavigationPalette(mode, prefersDark = false) {
|
|
159
|
-
if (mode === "dark") return "dark";
|
|
160
|
-
if (mode === "light") return "light";
|
|
161
|
-
return prefersDark ? "dark" : "light";
|
|
162
|
-
}
|
|
163
|
-
var defaultUGAccentNavigationColors = {
|
|
164
|
-
cyan: {
|
|
165
|
-
light: { activeBackground: "#cffafe", activeText: "#0e7490" },
|
|
166
|
-
dark: { activeBackground: "#0e7490", activeText: "#ecfeff" }
|
|
167
|
-
},
|
|
168
|
-
blue: {
|
|
169
|
-
light: { activeBackground: "#dbeafe", activeText: "#1d4ed8" },
|
|
170
|
-
dark: { activeBackground: "#1d4ed8", activeText: "#eff6ff" }
|
|
171
|
-
},
|
|
172
|
-
violet: {
|
|
173
|
-
light: { activeBackground: "#ede9fe", activeText: "#6d28d9" },
|
|
174
|
-
dark: { activeBackground: "#6d28d9", activeText: "#f5f3ff" }
|
|
175
|
-
},
|
|
176
|
-
emerald: {
|
|
177
|
-
light: { activeBackground: "#d1fae5", activeText: "#047857" },
|
|
178
|
-
dark: { activeBackground: "#047857", activeText: "#ecfdf5" }
|
|
179
|
-
},
|
|
180
|
-
rose: {
|
|
181
|
-
light: { activeBackground: "#ffe4e6", activeText: "#be123c" },
|
|
182
|
-
dark: { activeBackground: "#be123c", activeText: "#fff1f2" }
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
function resolveUGNavigationColors(preset, palette, overrides, accent = "theme") {
|
|
186
|
-
if (overrides) return overrides;
|
|
187
|
-
const themeColors = preset in defaultUGThemeNavigationColors ? defaultUGThemeNavigationColors[preset] : defaultUGThemeNavigationColors.default;
|
|
188
|
-
const resolvedColors = themeColors[palette];
|
|
189
|
-
if (accent in defaultUGAccentNavigationColors) {
|
|
190
|
-
return {
|
|
191
|
-
...resolvedColors,
|
|
192
|
-
...defaultUGAccentNavigationColors[accent][palette]
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
return resolvedColors;
|
|
196
|
-
}
|
|
197
|
-
var ugThemeProfileFields = [
|
|
198
|
-
"density",
|
|
199
|
-
"radius",
|
|
200
|
-
"shadow",
|
|
201
|
-
"font",
|
|
202
|
-
"contrast",
|
|
203
|
-
"motion",
|
|
204
|
-
"background"
|
|
205
|
-
];
|
|
206
|
-
var defaultUGTheme = {
|
|
207
|
-
preset: "default",
|
|
208
|
-
mode: "system",
|
|
209
|
-
surface: "workspace",
|
|
210
|
-
density: "comfortable",
|
|
211
|
-
radius: "default",
|
|
212
|
-
shadow: "standard",
|
|
213
|
-
font: "system",
|
|
214
|
-
contrast: "standard",
|
|
215
|
-
motion: "standard",
|
|
216
|
-
background: "grid",
|
|
217
|
-
accent: "theme"
|
|
218
|
-
};
|
|
219
|
-
var defaultUGThemeProfiles = [
|
|
220
|
-
{
|
|
221
|
-
id: "balanced",
|
|
222
|
-
label: "\u5747\u8861",
|
|
223
|
-
description: "\u8212\u9002\u3001\u6E05\u6670\uFF0C\u9002\u5408\u65E5\u5E38\u901A\u7528\u64CD\u4F5C\u3002",
|
|
224
|
-
value: {
|
|
225
|
-
density: "comfortable",
|
|
226
|
-
radius: "default",
|
|
227
|
-
shadow: "standard",
|
|
228
|
-
font: "system",
|
|
229
|
-
contrast: "standard",
|
|
230
|
-
motion: "standard",
|
|
231
|
-
background: "plain"
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
id: "efficient",
|
|
236
|
-
label: "\u9AD8\u6548",
|
|
237
|
-
description: "\u7D27\u51D1\u3001\u5229\u843D\uFF0C\u9002\u5408\u9AD8\u9891\u64CD\u4F5C\u548C\u6570\u636E\u5DE5\u4F5C\u3002",
|
|
238
|
-
value: {
|
|
239
|
-
density: "compact",
|
|
240
|
-
radius: "sharp",
|
|
241
|
-
shadow: "flat",
|
|
242
|
-
font: "compact",
|
|
243
|
-
contrast: "strong",
|
|
244
|
-
motion: "reduced",
|
|
245
|
-
background: "plain"
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: "readable",
|
|
250
|
-
label: "\u6613\u8BFB",
|
|
251
|
-
description: "\u5BBD\u677E\u3001\u6E05\u6670\uFF0C\u9002\u5408\u957F\u65F6\u95F4\u9605\u8BFB\u548C\u4F4E\u523A\u6FC0\u64CD\u4F5C\u3002",
|
|
252
|
-
value: {
|
|
253
|
-
density: "spacious",
|
|
254
|
-
radius: "soft",
|
|
255
|
-
shadow: "standard",
|
|
256
|
-
font: "readable",
|
|
257
|
-
contrast: "strong",
|
|
258
|
-
motion: "reduced",
|
|
259
|
-
background: "plain"
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
];
|
|
263
|
-
var defaultUGThemeConfiguratorOptions = {
|
|
264
|
-
presets: [
|
|
265
|
-
{ value: "default", label: "\u9ED8\u8BA4", description: "\u5747\u8861\u7684\u8FB9\u754C\u3001\u5C42\u6B21\u4E0E\u4FE1\u606F\u5BC6\u5EA6\u3002" },
|
|
266
|
-
{ value: "minimal", label: "\u7B80\u6D01", description: "\u51CF\u5C11\u88C5\u9970\uFF0C\u8BA9\u5185\u5BB9\u6210\u4E3A\u89C6\u89C9\u4E2D\u5FC3\u3002" },
|
|
267
|
-
{ value: "mecha", label: "\u673A\u68B0", description: "\u786C\u6717\u8FB9\u754C\u4E0E\u7D27\u51D1\u7684\u63A7\u5236\u53F0\u8282\u594F\u3002" }
|
|
268
|
-
],
|
|
269
|
-
modes: [
|
|
270
|
-
{ value: "system", label: "\u8DDF\u968F\u7CFB\u7EDF", description: "\u81EA\u52A8\u5339\u914D\u8BBE\u5907\u5916\u89C2\u3002" },
|
|
271
|
-
{ value: "light", label: "\u4EAE\u8272", description: "\u59CB\u7EC8\u4F7F\u7528\u4EAE\u8272\u754C\u9762\u3002" },
|
|
272
|
-
{ value: "dark", label: "\u6697\u8272", description: "\u59CB\u7EC8\u4F7F\u7528\u6697\u8272\u754C\u9762\u3002" }
|
|
273
|
-
],
|
|
274
|
-
surfaces: [
|
|
275
|
-
{ value: "workspace", label: "\u5DE5\u4F5C\u533A" },
|
|
276
|
-
{ value: "showcase", label: "\u5C55\u793A\u9875" },
|
|
277
|
-
{ value: "auth", label: "\u8BA4\u8BC1\u9875" },
|
|
278
|
-
{ value: "content", label: "\u5185\u5BB9\u9875" }
|
|
279
|
-
],
|
|
280
|
-
densities: [
|
|
281
|
-
{ value: "comfortable", label: "\u8212\u9002" },
|
|
282
|
-
{ value: "compact", label: "\u7D27\u51D1" },
|
|
283
|
-
{ value: "spacious", label: "\u5BBD\u677E" }
|
|
284
|
-
],
|
|
285
|
-
radii: [
|
|
286
|
-
{ value: "sharp", label: "\u5229\u843D" },
|
|
287
|
-
{ value: "default", label: "\u9ED8\u8BA4" },
|
|
288
|
-
{ value: "soft", label: "\u67D4\u548C" }
|
|
289
|
-
],
|
|
290
|
-
shadows: [
|
|
291
|
-
{ value: "flat", label: "\u5E73\u9762" },
|
|
292
|
-
{ value: "standard", label: "\u6807\u51C6" },
|
|
293
|
-
{ value: "layered", label: "\u5C42\u6B21" }
|
|
294
|
-
],
|
|
295
|
-
fonts: [
|
|
296
|
-
{ value: "system", label: "\u7CFB\u7EDF" },
|
|
297
|
-
{ value: "readable", label: "\u6613\u8BFB" },
|
|
298
|
-
{ value: "compact", label: "\u7D27\u51D1" }
|
|
299
|
-
],
|
|
300
|
-
contrasts: [
|
|
301
|
-
{ value: "soft", label: "\u67D4\u548C" },
|
|
302
|
-
{ value: "standard", label: "\u6807\u51C6" },
|
|
303
|
-
{ value: "strong", label: "\u6E05\u6670" }
|
|
304
|
-
],
|
|
305
|
-
motions: [
|
|
306
|
-
{ value: "reduced", label: "\u51CF\u5C11" },
|
|
307
|
-
{ value: "standard", label: "\u6807\u51C6" },
|
|
308
|
-
{ value: "lively", label: "\u7075\u52A8" }
|
|
309
|
-
],
|
|
310
|
-
backgrounds: [
|
|
311
|
-
{ value: "plain", label: "\u7EAF\u51C0" },
|
|
312
|
-
{ value: "grid", label: "\u7F51\u683C" },
|
|
313
|
-
{ value: "soft", label: "\u67D4\u5149" }
|
|
314
|
-
],
|
|
315
|
-
accents: [
|
|
316
|
-
{ value: "theme", label: "\u4E3B\u9898\u9ED8\u8BA4" },
|
|
317
|
-
{ value: "cyan", label: "UG \u9752" },
|
|
318
|
-
{ value: "blue", label: "\u6D77\u84DD" },
|
|
319
|
-
{ value: "violet", label: "\u7D2B\u6676" },
|
|
320
|
-
{ value: "emerald", label: "\u677E\u7EFF" },
|
|
321
|
-
{ value: "rose", label: "\u73AB\u7EA2" }
|
|
322
|
-
]
|
|
323
|
-
};
|
|
324
|
-
function createUGThemeValue(parent, overrides) {
|
|
325
|
-
return {
|
|
326
|
-
preset: overrides.preset ?? parent.preset,
|
|
327
|
-
mode: overrides.mode ?? parent.mode,
|
|
328
|
-
surface: overrides.surface ?? parent.surface,
|
|
329
|
-
density: overrides.density ?? parent.density,
|
|
330
|
-
radius: overrides.radius ?? parent.radius,
|
|
331
|
-
shadow: overrides.shadow ?? parent.shadow,
|
|
332
|
-
font: overrides.font ?? parent.font,
|
|
333
|
-
contrast: overrides.contrast ?? parent.contrast,
|
|
334
|
-
motion: overrides.motion ?? parent.motion,
|
|
335
|
-
background: overrides.background ?? parent.background,
|
|
336
|
-
accent: overrides.accent ?? parent.accent
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
function applyUGThemeProfile(current, profile) {
|
|
340
|
-
return createUGThemeValue(current, profile.value);
|
|
341
|
-
}
|
|
342
|
-
function isUGThemeProfileModified(current, profile) {
|
|
343
|
-
return ugThemeProfileFields.some((field) => current[field] !== profile.value[field]);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// src/form-validation.ts
|
|
347
|
-
function isEmptyFormValue(value) {
|
|
348
|
-
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
349
|
-
}
|
|
350
|
-
function hasTrigger(rule, trigger) {
|
|
351
|
-
if (trigger === "submit") return true;
|
|
352
|
-
if (!rule.trigger) return true;
|
|
353
|
-
return Array.isArray(rule.trigger) ? rule.trigger.includes(trigger) : rule.trigger === trigger;
|
|
354
|
-
}
|
|
355
|
-
function getValueLength(value) {
|
|
356
|
-
if (typeof value === "string" || Array.isArray(value)) return value.length;
|
|
357
|
-
return void 0;
|
|
358
|
-
}
|
|
359
|
-
function isValueType(value, type) {
|
|
360
|
-
switch (type) {
|
|
361
|
-
case "array":
|
|
362
|
-
return Array.isArray(value);
|
|
363
|
-
case "date":
|
|
364
|
-
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
365
|
-
case "email":
|
|
366
|
-
return typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
367
|
-
case "url":
|
|
368
|
-
return typeof value === "string" && /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i.test(value);
|
|
369
|
-
default:
|
|
370
|
-
return typeof value === type;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
function defaultMessage(rule) {
|
|
374
|
-
if (rule.required) return "\u8BE5\u5B57\u6BB5\u4E3A\u5FC5\u586B\u9879";
|
|
375
|
-
if (rule.type) return "\u5B57\u6BB5\u683C\u5F0F\u4E0D\u6B63\u786E";
|
|
376
|
-
if (rule.len !== void 0) return `\u957F\u5EA6\u5FC5\u987B\u4E3A ${rule.len}`;
|
|
377
|
-
if (rule.min !== void 0 && rule.max !== void 0) return `\u503C\u5FC5\u987B\u5728 ${rule.min} \u5230 ${rule.max} \u4E4B\u95F4`;
|
|
378
|
-
if (rule.min !== void 0) return `\u503C\u4E0D\u80FD\u5C0F\u4E8E ${rule.min}`;
|
|
379
|
-
if (rule.max !== void 0) return `\u503C\u4E0D\u80FD\u5927\u4E8E ${rule.max}`;
|
|
380
|
-
if (rule.pattern) return "\u5B57\u6BB5\u683C\u5F0F\u4E0D\u6B63\u786E";
|
|
381
|
-
return "\u5B57\u6BB5\u6821\u9A8C\u672A\u901A\u8FC7";
|
|
382
|
-
}
|
|
383
|
-
function failsRange(value, rule) {
|
|
384
|
-
const comparable = typeof value === "number" ? value : getValueLength(value);
|
|
385
|
-
if (comparable === void 0) return false;
|
|
386
|
-
if (rule.len !== void 0 && comparable !== rule.len) return true;
|
|
387
|
-
if (rule.min !== void 0 && comparable < rule.min) return true;
|
|
388
|
-
if (rule.max !== void 0 && comparable > rule.max) return true;
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
async function validateFormValue(value, fieldRules, values, trigger = "submit") {
|
|
392
|
-
const rules = fieldRules ? Array.isArray(fieldRules) ? fieldRules : [fieldRules] : [];
|
|
393
|
-
for (const rule of rules) {
|
|
394
|
-
if (!hasTrigger(rule, trigger)) continue;
|
|
395
|
-
const empty = isEmptyFormValue(value);
|
|
396
|
-
if (rule.required && empty) return rule.message ?? defaultMessage(rule);
|
|
397
|
-
if (empty) continue;
|
|
398
|
-
if (rule.type && !isValueType(value, rule.type)) {
|
|
399
|
-
return rule.message ?? defaultMessage(rule);
|
|
400
|
-
}
|
|
401
|
-
if (failsRange(value, rule)) {
|
|
402
|
-
return rule.message ?? defaultMessage(rule);
|
|
403
|
-
}
|
|
404
|
-
if (rule.pattern) {
|
|
405
|
-
rule.pattern.lastIndex = 0;
|
|
406
|
-
if (typeof value !== "string" || !rule.pattern.test(value)) {
|
|
407
|
-
return rule.message ?? defaultMessage(rule);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
if (rule.validator) {
|
|
411
|
-
try {
|
|
412
|
-
const result = await rule.validator(value, values);
|
|
413
|
-
if (result === false) return rule.message ?? defaultMessage(rule);
|
|
414
|
-
if (typeof result === "string") return result;
|
|
415
|
-
} catch (error) {
|
|
416
|
-
return error instanceof Error ? error.message : rule.message ?? defaultMessage(rule);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return void 0;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// src/select-value.ts
|
|
424
|
-
function encodeSelectValue(value) {
|
|
425
|
-
return `${typeof value === "number" ? "number" : "string"}:${value}`;
|
|
426
|
-
}
|
|
427
|
-
function normalizeSelectKeys(value) {
|
|
428
|
-
if (value === void 0 || value === "") return [];
|
|
429
|
-
return (Array.isArray(value) ? value : [value]).map(encodeSelectValue);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// src/text-value.ts
|
|
433
|
-
function countTextCharacters(value, counter) {
|
|
434
|
-
if (!counter) return value.length;
|
|
435
|
-
const count = counter(value);
|
|
436
|
-
return Number.isFinite(count) ? Math.max(0, Math.trunc(count)) : value.length;
|
|
437
|
-
}
|
|
438
|
-
function limitTextByCount(value, maxLength, counter) {
|
|
439
|
-
if (!counter || maxLength === void 0) return value;
|
|
440
|
-
const limit = Math.max(0, Math.trunc(maxLength));
|
|
441
|
-
if (countTextCharacters(value, counter) <= limit) return value;
|
|
442
|
-
const characters = Array.from(value);
|
|
443
|
-
let low = 0;
|
|
444
|
-
let high = characters.length;
|
|
445
|
-
while (low < high) {
|
|
446
|
-
const middle = Math.ceil((low + high) / 2);
|
|
447
|
-
const candidate = characters.slice(0, middle).join("");
|
|
448
|
-
if (countTextCharacters(candidate, counter) <= limit) low = middle;
|
|
449
|
-
else high = middle - 1;
|
|
450
|
-
}
|
|
451
|
-
return characters.slice(0, low).join("");
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// src/calendar.ts
|
|
455
|
-
function isValidCalendarDate(value) {
|
|
456
|
-
return value instanceof Date && Number.isFinite(value.getTime());
|
|
457
|
-
}
|
|
458
|
-
function normalizeCalendarDate(value, fallback = /* @__PURE__ */ new Date()) {
|
|
459
|
-
const source = isValidCalendarDate(value) ? value : fallback;
|
|
460
|
-
return localCalendarDate(source.getFullYear(), source.getMonth(), source.getDate());
|
|
461
|
-
}
|
|
462
|
-
function localCalendarDate(year, month, day) {
|
|
463
|
-
const date = /* @__PURE__ */ new Date(0);
|
|
464
|
-
date.setFullYear(year, month, day);
|
|
465
|
-
date.setHours(0, 0, 0, 0);
|
|
466
|
-
return date;
|
|
467
|
-
}
|
|
468
|
-
function startOfCalendarMonth(value) {
|
|
469
|
-
return localCalendarDate(value.getFullYear(), value.getMonth(), 1);
|
|
470
|
-
}
|
|
471
|
-
function addCalendarDays(value, amount) {
|
|
472
|
-
return localCalendarDate(value.getFullYear(), value.getMonth(), value.getDate() + amount);
|
|
473
|
-
}
|
|
474
|
-
function addCalendarMonths(value, amount) {
|
|
475
|
-
return localCalendarDate(value.getFullYear(), value.getMonth() + amount, 1);
|
|
476
|
-
}
|
|
477
|
-
function calendarDateKey(value) {
|
|
478
|
-
const month = `${value.getMonth() + 1}`.padStart(2, "0");
|
|
479
|
-
const day = `${value.getDate()}`.padStart(2, "0");
|
|
480
|
-
return `${`${value.getFullYear()}`.padStart(4, "0")}-${month}-${day}`;
|
|
481
|
-
}
|
|
482
|
-
function compareCalendarDates(left, right) {
|
|
483
|
-
const leftTime = normalizeCalendarDate(left).getTime();
|
|
484
|
-
const rightTime = normalizeCalendarDate(right).getTime();
|
|
485
|
-
return leftTime === rightTime ? 0 : leftTime < rightTime ? -1 : 1;
|
|
486
|
-
}
|
|
487
|
-
function isSameCalendarDay(left, right) {
|
|
488
|
-
return isValidCalendarDate(left) && isValidCalendarDate(right) && left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth() && left.getDate() === right.getDate();
|
|
489
|
-
}
|
|
490
|
-
function buildCalendarMonth(month, weekStartsOn = 1) {
|
|
491
|
-
const firstDay = startOfCalendarMonth(month);
|
|
492
|
-
const offset = (firstDay.getDay() - weekStartsOn + 7) % 7;
|
|
493
|
-
const gridStart = addCalendarDays(firstDay, -offset);
|
|
494
|
-
const today = normalizeCalendarDate(/* @__PURE__ */ new Date());
|
|
495
|
-
return Array.from({ length: 42 }, (_, index) => {
|
|
496
|
-
const date = addCalendarDays(gridStart, index);
|
|
497
|
-
return {
|
|
498
|
-
date,
|
|
499
|
-
key: calendarDateKey(date),
|
|
500
|
-
day: date.getDate(),
|
|
501
|
-
outside: date.getMonth() !== firstDay.getMonth(),
|
|
502
|
-
today: isSameCalendarDay(date, today)
|
|
503
|
-
};
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
function buildCalendarWeekdays(locale = "zh-CN", weekStartsOn = 1) {
|
|
507
|
-
let formatter;
|
|
508
|
-
try {
|
|
509
|
-
formatter = new Intl.DateTimeFormat(locale, { weekday: "short" });
|
|
510
|
-
} catch {
|
|
511
|
-
formatter = new Intl.DateTimeFormat("zh-CN", { weekday: "short" });
|
|
512
|
-
}
|
|
513
|
-
const sunday = new Date(2026, 0, 4);
|
|
514
|
-
return Array.from({ length: 7 }, (_, index) => formatter.format(addCalendarDays(sunday, weekStartsOn + index)));
|
|
515
|
-
}
|
|
516
|
-
function formatCalendarMonth(value, locale = "zh-CN") {
|
|
517
|
-
try {
|
|
518
|
-
return new Intl.DateTimeFormat(locale, { year: "numeric", month: "long" }).format(value);
|
|
519
|
-
} catch {
|
|
520
|
-
return new Intl.DateTimeFormat("zh-CN", { year: "numeric", month: "long" }).format(value);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
function formatCalendarDay(value, locale = "zh-CN") {
|
|
524
|
-
try {
|
|
525
|
-
return new Intl.DateTimeFormat(locale, { year: "numeric", month: "long", day: "numeric", weekday: "long" }).format(value);
|
|
526
|
-
} catch {
|
|
527
|
-
return new Intl.DateTimeFormat("zh-CN", { year: "numeric", month: "long", day: "numeric", weekday: "long" }).format(value);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
// src/date-range.ts
|
|
532
|
-
function parseCalendarDateKey(value) {
|
|
533
|
-
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value ?? "");
|
|
534
|
-
if (!match) return null;
|
|
535
|
-
const year = Number(match[1]);
|
|
536
|
-
const month = Number(match[2]) - 1;
|
|
537
|
-
const day = Number(match[3]);
|
|
538
|
-
const date = /* @__PURE__ */ new Date(0);
|
|
539
|
-
date.setFullYear(year, month, day);
|
|
540
|
-
date.setHours(0, 0, 0, 0);
|
|
541
|
-
return date.getFullYear() === year && date.getMonth() === month && date.getDate() === day ? date : null;
|
|
542
|
-
}
|
|
543
|
-
function parseCalendarRange(value) {
|
|
544
|
-
return [parseCalendarDateKey(value[0]), parseCalendarDateKey(value[1])];
|
|
545
|
-
}
|
|
546
|
-
function getCalendarRangePosition(date, range) {
|
|
547
|
-
if (!range) return void 0;
|
|
548
|
-
const [start, end] = range;
|
|
549
|
-
if (isSameCalendarDay(date, start) && isSameCalendarDay(date, end)) return "single";
|
|
550
|
-
if (isSameCalendarDay(date, start)) return "start";
|
|
551
|
-
if (isSameCalendarDay(date, end)) return "end";
|
|
552
|
-
if (start && end && compareCalendarDates(date, start) > 0 && compareCalendarDates(date, end) < 0) return "middle";
|
|
553
|
-
return void 0;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// src/tree-path.ts
|
|
557
|
-
function findTreeNodePath(items, key) {
|
|
558
|
-
if (key === void 0) return [];
|
|
559
|
-
for (const node of items) {
|
|
560
|
-
if (node.key === key) return [node];
|
|
561
|
-
const path = findTreeNodePath(node.children ?? [], key);
|
|
562
|
-
if (path.length > 0) return [node, ...path];
|
|
563
|
-
}
|
|
564
|
-
return [];
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
// src/selection-list.ts
|
|
568
|
-
function normalizeSearch(value) {
|
|
569
|
-
return value.normalize("NFKC").toLocaleLowerCase().trim();
|
|
570
|
-
}
|
|
571
|
-
function filterSelectionListOptions(options, query = "") {
|
|
572
|
-
const seen = /* @__PURE__ */ new Set();
|
|
573
|
-
const search = normalizeSearch(query);
|
|
574
|
-
return options.filter((option) => {
|
|
575
|
-
if (seen.has(option.id)) return false;
|
|
576
|
-
seen.add(option.id);
|
|
577
|
-
return !search || [option.id, option.label, option.group ?? "", option.description ?? ""].some((text) => normalizeSearch(text).includes(search));
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
function groupSelectionListOptions(options) {
|
|
581
|
-
const groups = /* @__PURE__ */ new Map();
|
|
582
|
-
for (const option of options) {
|
|
583
|
-
const key = option.group === void 0 ? "ungrouped" : `group:${option.group}`;
|
|
584
|
-
const group = groups.get(key) ?? { key, label: option.group ?? "\u5176\u4ED6", options: [] };
|
|
585
|
-
group.options.push(option);
|
|
586
|
-
groups.set(key, group);
|
|
587
|
-
}
|
|
588
|
-
return [...groups.values()];
|
|
589
|
-
}
|
|
590
|
-
function getSelectionListScope(options, selected) {
|
|
591
|
-
const available = options.filter((option) => !option.disabled);
|
|
592
|
-
const ids = new Set(selected);
|
|
593
|
-
const selectedCount = available.filter((option) => ids.has(option.id)).length;
|
|
594
|
-
return {
|
|
595
|
-
total: options.length,
|
|
596
|
-
available: available.length,
|
|
597
|
-
disabled: options.length - available.length,
|
|
598
|
-
selected: options.filter((option) => ids.has(option.id)).length,
|
|
599
|
-
checked: available.length > 0 && selectedCount === available.length,
|
|
600
|
-
indeterminate: selectedCount > 0 && selectedCount < available.length
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
function updateSelectionListScope(selected, options, checked) {
|
|
604
|
-
const scope = new Set(options.filter((option) => !option.disabled).map((option) => option.id));
|
|
605
|
-
if (!checked) return selected.filter((id) => !scope.has(id));
|
|
606
|
-
return [.../* @__PURE__ */ new Set([...selected, ...scope])];
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// src/color.ts
|
|
610
|
-
var clamp = (value, max) => Math.min(max, Math.max(0, Number.isFinite(value) ? value : 0));
|
|
611
|
-
function parseColorHex(value) {
|
|
612
|
-
const input = value.trim();
|
|
613
|
-
if (!/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i.test(input)) return void 0;
|
|
614
|
-
const hex = input.length <= 5 ? input.slice(1).split("").map((part) => part + part).join("") : input.slice(1);
|
|
615
|
-
const [r, g, b] = [0, 2, 4].map((offset) => Number.parseInt(hex.slice(offset, offset + 2), 16) / 255);
|
|
616
|
-
const max = Math.max(r, g, b);
|
|
617
|
-
const min = Math.min(r, g, b);
|
|
618
|
-
const d = max - min;
|
|
619
|
-
let h = 0;
|
|
620
|
-
if (d !== 0) {
|
|
621
|
-
if (max === r) h = (g - b) / d + (g < b ? 6 : 0);
|
|
622
|
-
else if (max === g) h = (b - r) / d + 2;
|
|
623
|
-
else h = (r - g) / d + 4;
|
|
624
|
-
h *= 60;
|
|
625
|
-
}
|
|
626
|
-
return { h, s: max === 0 ? 0 : d / max * 100, v: max * 100, a: hex.length === 8 ? Number.parseInt(hex.slice(6), 16) / 255 : 1 };
|
|
627
|
-
}
|
|
628
|
-
function formatColorHex(color, alpha = false) {
|
|
629
|
-
const h = clamp(color.h, 360) % 360 / 60;
|
|
630
|
-
const s = clamp(color.s, 100) / 100;
|
|
631
|
-
const v = clamp(color.v, 100) / 100;
|
|
632
|
-
const i = Math.floor(h);
|
|
633
|
-
const f = h - i;
|
|
634
|
-
const p = v * (1 - s);
|
|
635
|
-
const q = v * (1 - f * s);
|
|
636
|
-
const t = v * (1 - (1 - f) * s);
|
|
637
|
-
const channels = [[v, q, p, p, t, v][i], [t, v, v, q, p, p][i], [p, p, t, v, v, q][i]];
|
|
638
|
-
if (alpha) channels.push(clamp(color.a, 1));
|
|
639
|
-
return "#" + channels.map((value) => Math.round(value * 255).toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
// src/date-time.ts
|
|
643
|
-
function parseTimeValue(value, showSeconds = false) {
|
|
644
|
-
const match = (showSeconds ? /^(\d{2}):(\d{2}):(\d{2})$/ : /^(\d{2}):(\d{2})$/).exec(value ?? "");
|
|
645
|
-
if (!match) return null;
|
|
646
|
-
const [hours, minutes, seconds] = [Number(match[1]), Number(match[2]), Number(match[3] ?? 0)];
|
|
647
|
-
return hours < 24 && minutes < 60 && seconds < 60 ? hours * 3600 + minutes * 60 + seconds : null;
|
|
648
|
-
}
|
|
649
|
-
function formatTimeValue(seconds, showSeconds = false) {
|
|
650
|
-
if (!Number.isInteger(seconds) || seconds < 0 || seconds >= 86400) return "";
|
|
651
|
-
const parts = [Math.floor(seconds / 3600), Math.floor(seconds / 60) % 60];
|
|
652
|
-
if (showSeconds) parts.push(seconds % 60);
|
|
653
|
-
return parts.map((part) => String(part).padStart(2, "0")).join(":");
|
|
654
|
-
}
|
|
655
|
-
function validateDateValue(value, options = {}) {
|
|
656
|
-
if (value === "") return void 0;
|
|
657
|
-
const date = parseCalendarDateKey(value);
|
|
658
|
-
if (!date) return "\u8BF7\u8F93\u5165\u6709\u6548\u65E5\u671F\uFF0C\u683C\u5F0F\u4E3A YYYY-MM-DD";
|
|
659
|
-
const min = parseCalendarDateKey(options.min);
|
|
660
|
-
const max = parseCalendarDateKey(options.max);
|
|
661
|
-
if (min && date < min) return `\u65E5\u671F\u4E0D\u80FD\u65E9\u4E8E ${options.min}`;
|
|
662
|
-
if (max && date > max) return `\u65E5\u671F\u4E0D\u80FD\u665A\u4E8E ${options.max}`;
|
|
663
|
-
if (options.disabledDate?.(date)) return "\u8BE5\u65E5\u671F\u4E0D\u53EF\u9009\u62E9";
|
|
664
|
-
return void 0;
|
|
665
|
-
}
|
|
666
|
-
function validateTimeValue(value, options = {}) {
|
|
667
|
-
if (value === "") return void 0;
|
|
668
|
-
const seconds = parseTimeValue(value, options.showSeconds);
|
|
669
|
-
const format = options.showSeconds ? "HH:mm:ss" : "HH:mm";
|
|
670
|
-
if (seconds === null) return `\u8BF7\u8F93\u5165\u6709\u6548\u65F6\u95F4\uFF0C\u683C\u5F0F\u4E3A ${format}`;
|
|
671
|
-
const min = parseTimeValue(options.min, options.showSeconds);
|
|
672
|
-
const max = parseTimeValue(options.max, options.showSeconds);
|
|
673
|
-
if (min !== null && seconds < min) return `\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E ${options.min}`;
|
|
674
|
-
if (max !== null && seconds > max) return `\u65F6\u95F4\u4E0D\u80FD\u665A\u4E8E ${options.max}`;
|
|
675
|
-
if (options.disabledTime?.(value)) return "\u8BE5\u65F6\u95F4\u4E0D\u53EF\u9009\u62E9";
|
|
676
|
-
return void 0;
|
|
677
|
-
}
|
|
678
|
-
function parseLocalDateTimeValue(value, showSeconds = false) {
|
|
679
|
-
const parts = value.split(" ");
|
|
680
|
-
if (parts.length !== 2) return null;
|
|
681
|
-
const date = parseCalendarDateKey(parts[0]);
|
|
682
|
-
return date && parseTimeValue(parts[1], showSeconds) !== null ? { date, time: parts[1] } : null;
|
|
683
|
-
}
|
|
684
|
-
function validateDateTimeValue(value, options = {}) {
|
|
685
|
-
if (value === "") return void 0;
|
|
686
|
-
const parsed = parseLocalDateTimeValue(value, options.showSeconds);
|
|
687
|
-
if (!parsed) return `\u8BF7\u8F93\u5165\u6709\u6548\u65E5\u671F\u65F6\u95F4\uFF0C\u683C\u5F0F\u4E3A YYYY-MM-DD ${options.showSeconds ? "HH:mm:ss" : "HH:mm"}`;
|
|
688
|
-
if (parseLocalDateTimeValue(options.min ?? "", options.showSeconds) && value < options.min) return `\u65E5\u671F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E ${options.min}`;
|
|
689
|
-
if (parseLocalDateTimeValue(options.max ?? "", options.showSeconds) && value > options.max) return `\u65E5\u671F\u65F6\u95F4\u4E0D\u80FD\u665A\u4E8E ${options.max}`;
|
|
690
|
-
if (options.disabledDate?.(parsed.date)) return "\u8BE5\u65E5\u671F\u4E0D\u53EF\u9009\u62E9";
|
|
691
|
-
if (options.disabledTime?.(value)) return "\u8BE5\u65F6\u95F4\u4E0D\u53EF\u9009\u62E9";
|
|
692
|
-
return void 0;
|
|
693
|
-
}
|
|
694
|
-
function validateTimeRangeValue(value, options = {}) {
|
|
695
|
-
if (!value[0] && !value[1]) return void 0;
|
|
696
|
-
if (!value[0] || !value[1]) return "\u8BF7\u586B\u5199\u5B8C\u6574\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u65F6\u95F4";
|
|
697
|
-
const error = validateTimeValue(value[0], options) ?? validateTimeValue(value[1], options);
|
|
698
|
-
if (error) return error;
|
|
699
|
-
return parseTimeValue(value[0], options.showSeconds) > parseTimeValue(value[1], options.showSeconds) ? "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65F6\u95F4" : void 0;
|
|
700
|
-
}
|
|
701
|
-
function buildTimeSelectOptions(start = "09:00", end = "18:00", step = "00:30", constraints = {}) {
|
|
702
|
-
const first = parseTimeValue(start);
|
|
703
|
-
const last = parseTimeValue(end);
|
|
704
|
-
const increment = parseTimeValue(step);
|
|
705
|
-
if (first === null || last === null || increment === null || increment <= 0 || first > last) return [];
|
|
706
|
-
const options = [];
|
|
707
|
-
for (let seconds = first; seconds <= last; seconds += increment) {
|
|
708
|
-
const value = formatTimeValue(seconds);
|
|
709
|
-
options.push({ value, label: value, disabled: Boolean(validateTimeValue(value, { ...constraints, showSeconds: false })) });
|
|
710
|
-
}
|
|
711
|
-
return options;
|
|
712
|
-
}
|
|
713
|
-
function getAvailableTimeValues(options = {}) {
|
|
714
|
-
const increment = options.showSeconds ? 1 : 60;
|
|
715
|
-
const min = parseTimeValue(options.min, options.showSeconds) ?? 0;
|
|
716
|
-
const max = parseTimeValue(options.max, options.showSeconds) ?? 86399;
|
|
717
|
-
const values = [];
|
|
718
|
-
for (let value = Math.ceil(min / increment) * increment; value <= max; value += increment) {
|
|
719
|
-
if (!options.disabledTime?.(formatTimeValue(value, options.showSeconds))) values.push(value);
|
|
720
|
-
}
|
|
721
|
-
return values;
|
|
722
|
-
}
|
|
723
|
-
function getTimeColumnChoices(available, current, unit) {
|
|
724
|
-
const divisor = unit === "hour" ? 3600 : unit === "minute" ? 60 : 1;
|
|
725
|
-
const count = unit === "hour" ? 24 : 60;
|
|
726
|
-
const currentUnit = Math.floor(current / divisor) % count;
|
|
727
|
-
const nearest = Array.from({ length: count });
|
|
728
|
-
for (const value of available) {
|
|
729
|
-
const index = Math.floor(value / divisor) % count;
|
|
730
|
-
const previous = nearest[index];
|
|
731
|
-
const target = current + (index - currentUnit) * divisor;
|
|
732
|
-
if (previous === void 0 || Math.abs(value - target) < Math.abs(previous - target)) nearest[index] = value;
|
|
733
|
-
}
|
|
734
|
-
return Array.from({ length: count }, (_, index) => {
|
|
735
|
-
return { label: String(index).padStart(2, "0"), value: index, time: nearest[index], disabled: nearest[index] === void 0 };
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
function localDateTimeKey(date, time) {
|
|
739
|
-
return `${calendarDateKey(date)} ${time}`;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
// src/tree-check.ts
|
|
743
|
-
function getTreeCheckState(items, keys, strict = false) {
|
|
744
|
-
const seed = new Set(keys);
|
|
745
|
-
const known = /* @__PURE__ */ new Set();
|
|
746
|
-
const disabledKeys = [];
|
|
747
|
-
const checkedNodeKeys = [];
|
|
748
|
-
const halfCheckedKeys = [];
|
|
749
|
-
const leaves = [];
|
|
750
|
-
function visit(node, parentDisabled, parentChecked) {
|
|
751
|
-
known.add(node.key);
|
|
752
|
-
const disabled2 = Boolean(node.disabled || !strict && parentDisabled);
|
|
753
|
-
if (disabled2) disabledKeys.push(node.key);
|
|
754
|
-
if (strict) {
|
|
755
|
-
if (seed.has(node.key)) checkedNodeKeys.push(node.key);
|
|
756
|
-
node.children?.forEach((child) => visit(child, disabled2, false));
|
|
757
|
-
return { total: disabled2 ? 0 : 1, checked: seed.has(node.key) ? 1 : 0 };
|
|
758
|
-
}
|
|
759
|
-
const selected = parentChecked || seed.has(node.key);
|
|
760
|
-
if (!node.children?.length) {
|
|
761
|
-
if (seed.has(node.key) || !disabled2 && selected) checkedNodeKeys.push(node.key);
|
|
762
|
-
if (!disabled2 && selected) leaves.push(node.key);
|
|
763
|
-
return { total: disabled2 ? 0 : 1, checked: !disabled2 && selected ? 1 : 0 };
|
|
764
|
-
}
|
|
765
|
-
const coverage = node.children.map((child) => visit(child, disabled2, !disabled2 && selected)).reduce((sum, child) => ({ total: sum.total + child.total, checked: sum.checked + child.checked }), { total: 0, checked: 0 });
|
|
766
|
-
if (disabled2 ? seed.has(node.key) : coverage.total > 0 && coverage.checked === coverage.total) checkedNodeKeys.push(node.key);
|
|
767
|
-
else if (!disabled2 && coverage.checked > 0) halfCheckedKeys.push(node.key);
|
|
768
|
-
return coverage;
|
|
769
|
-
}
|
|
770
|
-
items.forEach((node) => visit(node, false, false));
|
|
771
|
-
const disabled = new Set(disabledKeys);
|
|
772
|
-
return { checkedKeys: strict ? [...seed] : [.../* @__PURE__ */ new Set([...keys.filter((key) => !known.has(key) || disabled.has(key)), ...leaves])], checkedNodeKeys, halfCheckedKeys, disabledKeys };
|
|
773
|
-
}
|
|
774
|
-
function toggleTreeCheckedKey(items, keys, key, checked, strict = false) {
|
|
775
|
-
const state = getTreeCheckState(items, keys, strict);
|
|
776
|
-
const disabled = new Set(state.disabledKeys);
|
|
777
|
-
if (disabled.has(key)) return state;
|
|
778
|
-
const find = (nodes) => {
|
|
779
|
-
for (const node2 of nodes) {
|
|
780
|
-
if (node2.key === key) return node2;
|
|
781
|
-
const child = find(node2.children ?? []);
|
|
782
|
-
if (child) return child;
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
const node = find(items);
|
|
786
|
-
if (!node) return state;
|
|
787
|
-
const next = new Set(state.checkedKeys);
|
|
788
|
-
function update(item) {
|
|
789
|
-
if (disabled.has(item.key)) return;
|
|
790
|
-
if (!strict && item.children?.length) {
|
|
791
|
-
item.children.forEach(update);
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
if (checked) next.add(item.key);
|
|
795
|
-
else next.delete(item.key);
|
|
796
|
-
}
|
|
797
|
-
update(node);
|
|
798
|
-
return getTreeCheckState(items, [...next], strict);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// src/rating.ts
|
|
802
|
-
function normalizeRatingMax(max) {
|
|
803
|
-
return Number.isFinite(max) ? Math.min(100, Math.max(1, Math.floor(max))) : 5;
|
|
804
|
-
}
|
|
805
|
-
function normalizeRatingValue(value, max, precision = 1) {
|
|
806
|
-
if (!Number.isFinite(value)) return 0;
|
|
807
|
-
return Math.min(normalizeRatingMax(max), Math.max(0, Math.floor((value ?? 0) / precision) * precision));
|
|
808
|
-
}
|
|
809
|
-
function getRatingKeyboardValue(value, key, max, precision = 1, allowClear = false) {
|
|
810
|
-
const limit = normalizeRatingMax(max);
|
|
811
|
-
if (key === "Home") return precision;
|
|
812
|
-
if (key === "End") return limit;
|
|
813
|
-
if (allowClear && (key === "Delete" || key === "Backspace")) return 0;
|
|
814
|
-
if (key === "ArrowUp" || key === "ArrowRight") return Math.min(limit, value + precision);
|
|
815
|
-
if (key === "ArrowDown" || key === "ArrowLeft") return Math.max(allowClear ? 0 : precision, value - precision);
|
|
816
|
-
return void 0;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// src/image-preview.ts
|
|
820
|
-
function getImagePreviewLayout(width, height, viewportWidth, viewportHeight, zoom = 1, rotation = 0) {
|
|
821
|
-
const valid = [width, height, viewportWidth, viewportHeight, zoom].every((value) => Number.isFinite(value) && value > 0);
|
|
822
|
-
if (!valid) return { width: 0, height: 0, canvasWidth: Math.max(0, viewportWidth || 0), canvasHeight: Math.max(0, viewportHeight || 0) };
|
|
823
|
-
const scale = Math.min(1, viewportWidth / width, viewportHeight / height) * Math.max(0.25, Math.min(4, zoom));
|
|
824
|
-
const imageWidth = width * scale;
|
|
825
|
-
const imageHeight = height * scale;
|
|
826
|
-
const swap = Math.abs(Math.round(rotation / 90)) % 2 === 1;
|
|
827
|
-
return { width: imageWidth, height: imageHeight, canvasWidth: Math.max(viewportWidth, swap ? imageHeight : imageWidth), canvasHeight: Math.max(viewportHeight, swap ? imageWidth : imageHeight) };
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
// src/table-layout.ts
|
|
831
|
-
function getTableColumnFixed(column) {
|
|
832
|
-
return column.fixed === true ? "left" : column.fixed || void 0;
|
|
833
|
-
}
|
|
834
|
-
function tableColumnLength(value) {
|
|
835
|
-
if (typeof value === "number") return Number.isFinite(value) && value >= 0 ? `${value}px` : void 0;
|
|
836
|
-
return value?.trim() || void 0;
|
|
837
|
-
}
|
|
838
|
-
function resolveTableFixedColumns(columns, widths, regionWidth, priorityIndex, contentWindow = 160) {
|
|
839
|
-
if (!Number.isFinite(regionWidth) || regionWidth <= 0) return [...columns];
|
|
840
|
-
const retained = /* @__PURE__ */ new Set();
|
|
841
|
-
const widthAt = (index) => Number.isFinite(widths[index]) ? Math.max(0, widths[index]) : 0;
|
|
842
|
-
let occupied = 0;
|
|
843
|
-
const budget = Math.max(0, regionWidth - contentWindow);
|
|
844
|
-
const attempt = (index) => {
|
|
845
|
-
if (retained.has(index)) return;
|
|
846
|
-
const width = widthAt(index);
|
|
847
|
-
if (occupied + width <= budget) {
|
|
848
|
-
retained.add(index);
|
|
849
|
-
occupied += width;
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
if (priorityIndex !== void 0 && getTableColumnFixed(columns[priorityIndex] ?? {})) attempt(priorityIndex);
|
|
853
|
-
for (let index = columns.length - 1; index >= 0; index--) if (getTableColumnFixed(columns[index]) === "right") attempt(index);
|
|
854
|
-
for (let index = 0; index < columns.length; index++) if (getTableColumnFixed(columns[index]) === "left") attempt(index);
|
|
855
|
-
return columns.map((column, index) => retained.has(index) ? column : { ...column, fixed: void 0 });
|
|
856
|
-
}
|
|
857
|
-
function getTableColumnStyle(columns, index, widths = []) {
|
|
858
|
-
const column = columns[index] ?? {};
|
|
859
|
-
const fixed = getTableColumnFixed(column);
|
|
860
|
-
const siblings = columns.map((item, position) => ({ item, position })).filter(({ item, position }) => getTableColumnFixed(item) === fixed && (fixed === "left" ? position < index : position > index));
|
|
861
|
-
const offset = siblings.map(({ item, position }) => widths[position] !== void 0 ? `${widths[position]}px` : tableColumnLength(item.width ?? item.minWidth) ?? "0px");
|
|
862
|
-
return {
|
|
863
|
-
width: tableColumnLength(column.width),
|
|
864
|
-
minWidth: tableColumnLength(column.minWidth),
|
|
865
|
-
textAlign: column.align,
|
|
866
|
-
"--ug-table-fixed-offset": fixed ? offset.length ? `calc(${offset.join(" + ")})` : "0px" : void 0
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
// src/tree-table.ts
|
|
871
|
-
function projectTreeTableRows(roots, options) {
|
|
872
|
-
const rows = [];
|
|
873
|
-
const visibleRows = [];
|
|
874
|
-
const expandableIds = [];
|
|
875
|
-
const known = /* @__PURE__ */ new Set();
|
|
876
|
-
const pending = roots.map((record) => ({ record, depth: 0, parentId: void 0, visible: true })).reverse();
|
|
877
|
-
while (pending.length) {
|
|
878
|
-
const entry = pending.pop();
|
|
879
|
-
const rawId = options.getRowId(entry.record);
|
|
880
|
-
if (rawId === void 0 || rawId === null || String(rawId) === "") throw new Error("UGTreeTable \u7684\u6BCF\u6761\u8BB0\u5F55\u5FC5\u987B\u6709\u975E\u7A7A\u7A33\u5B9A\u6807\u8BC6");
|
|
881
|
-
const id = String(rawId);
|
|
882
|
-
if (known.has(id)) throw new Error(`UGTreeTable \u7684\u8BB0\u5F55\u6807\u8BC6\u5FC5\u987B\u552F\u4E00\u4E14\u65E0\u73AF\uFF1A${id}`);
|
|
883
|
-
known.add(id);
|
|
884
|
-
const children = options.getChildren(entry.record) ?? [];
|
|
885
|
-
const expanded = Boolean(children.length && (options.expandedIds?.has(id) ?? options.defaultExpandAll));
|
|
886
|
-
const row = { id, record: entry.record, parentId: entry.parentId, depth: entry.depth, hasChildren: children.length > 0, expanded };
|
|
887
|
-
rows.push(row);
|
|
888
|
-
if (entry.visible) visibleRows.push(row);
|
|
889
|
-
if (children.length) expandableIds.push(id);
|
|
890
|
-
for (let index = children.length - 1; index >= 0; index--) pending.push({ record: children[index], depth: entry.depth + 1, parentId: id, visible: entry.visible && expanded });
|
|
891
|
-
}
|
|
892
|
-
return { rows, visibleRows, expandableIds };
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
// src/table-structure.ts
|
|
896
|
-
function getTableStructure(columns, order = []) {
|
|
897
|
-
const rank = new Map(order.map((id, index) => [id, index]));
|
|
898
|
-
const ids = /* @__PURE__ */ new Set();
|
|
899
|
-
let depth = 1;
|
|
900
|
-
const walk = (nodes, level) => [...nodes].sort((left, right) => (rank.get(left.id) ?? Infinity) - (rank.get(right.id) ?? Infinity)).map((column) => {
|
|
901
|
-
if (!column.id || ids.has(column.id)) throw new Error("UGDataTable \u7684\u5217 id \u5FC5\u987B\u975E\u7A7A\u4E14\u5168\u5C40\u552F\u4E00");
|
|
902
|
-
ids.add(column.id);
|
|
903
|
-
depth = Math.max(depth, level);
|
|
904
|
-
return column.children?.length ? { ...column, children: walk(column.children, level + 1) } : column;
|
|
905
|
-
});
|
|
906
|
-
const ordered = walk(columns, 1);
|
|
907
|
-
const headers = Array.from({ length: depth }, () => []);
|
|
908
|
-
const leaves = [];
|
|
909
|
-
const canonicalOrder = [];
|
|
910
|
-
const project = (nodes, level, parentId) => {
|
|
911
|
-
for (const column of nodes) {
|
|
912
|
-
canonicalOrder.push(column.id);
|
|
913
|
-
const children = column.children;
|
|
914
|
-
const leafIndex = leaves.length;
|
|
915
|
-
if (children?.length) project(children, level + 1, column.id);
|
|
916
|
-
else leaves.push(column);
|
|
917
|
-
headers[level - 1].push({ column, leafIndex, colSpan: leaves.length - leafIndex, rowSpan: children?.length ? 1 : depth - level + 1, parentId, siblingIds: nodes.map((node) => node.id) });
|
|
918
|
-
}
|
|
919
|
-
};
|
|
920
|
-
project(ordered, 1);
|
|
921
|
-
return { columns: ordered, leaves, headers, order: canonicalOrder };
|
|
922
|
-
}
|
|
923
|
-
function moveTableColumn(columns, order, source, target, after = false) {
|
|
924
|
-
const structure = getTableStructure(columns, order);
|
|
925
|
-
const cell = structure.headers.flat().find((item) => item.column.id === source);
|
|
926
|
-
if (!cell || source === target || !cell.siblingIds.includes(target)) return structure.order;
|
|
927
|
-
const next = structure.order.filter((id) => id !== source);
|
|
928
|
-
next.splice(next.indexOf(target) + (after ? 1 : 0), 0, source);
|
|
929
|
-
return getTableStructure(columns, next).order;
|
|
930
|
-
}
|
|
931
|
-
function getTableSpanGrid(rows, columns, span) {
|
|
932
|
-
const grid = Array.from({ length: rows }, () => Array.from({ length: columns }, () => ({ rowSpan: 0, colSpan: 0 })));
|
|
933
|
-
const occupied = /* @__PURE__ */ new Set();
|
|
934
|
-
const normalize = (value, max) => value === 0 ? 0 : Number.isSafeInteger(value) && value > 0 ? Math.min(value, max) : 1;
|
|
935
|
-
for (let row = 0; row < rows; row++) for (let column = 0; column < columns; column++) {
|
|
936
|
-
if (occupied.has(`${row}:${column}`)) continue;
|
|
937
|
-
const requested = span?.(row, column);
|
|
938
|
-
let rowSpan = normalize(requested?.rowSpan, rows - row);
|
|
939
|
-
let colSpan = normalize(requested?.colSpan, columns - column);
|
|
940
|
-
if (!rowSpan || !colSpan) continue;
|
|
941
|
-
let overlap = false;
|
|
942
|
-
for (let r = row; r < row + rowSpan; r++) for (let c = column; c < column + colSpan; c++) if (occupied.has(`${r}:${c}`)) overlap = true;
|
|
943
|
-
if (overlap) {
|
|
944
|
-
rowSpan = 1;
|
|
945
|
-
colSpan = 1;
|
|
946
|
-
}
|
|
947
|
-
grid[row][column] = { rowSpan, colSpan };
|
|
948
|
-
for (let r = row; r < row + rowSpan; r++) for (let c = column; c < column + colSpan; c++) occupied.add(`${r}:${c}`);
|
|
949
|
-
}
|
|
950
|
-
return grid;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
// src/date-picker-modes.ts
|
|
954
|
-
var pad = (value, size = 2) => String(value).padStart(size, "0");
|
|
955
|
-
function localDate(year, month = 0, day = 1) {
|
|
956
|
-
const date = /* @__PURE__ */ new Date(0);
|
|
957
|
-
date.setFullYear(year, month, day);
|
|
958
|
-
date.setHours(0, 0, 0, 0);
|
|
959
|
-
return date;
|
|
960
|
-
}
|
|
961
|
-
function isoWeekStart(date) {
|
|
962
|
-
const start = localDate(date.getFullYear(), date.getMonth(), date.getDate());
|
|
963
|
-
start.setDate(start.getDate() - (start.getDay() + 6) % 7);
|
|
964
|
-
return start;
|
|
965
|
-
}
|
|
966
|
-
function datePickerModeKey(date, mode) {
|
|
967
|
-
if (mode === "year") return pad(date.getFullYear(), 4);
|
|
968
|
-
if (mode === "month") return `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}`;
|
|
969
|
-
if (mode === "week") {
|
|
970
|
-
const start = isoWeekStart(date);
|
|
971
|
-
const thursday = new Date(start);
|
|
972
|
-
thursday.setDate(start.getDate() + 3);
|
|
973
|
-
const year = thursday.getFullYear();
|
|
974
|
-
const first = isoWeekStart(localDate(year, 0, 4));
|
|
975
|
-
return `${pad(year, 4)}-W${pad(Math.round((start.getTime() - first.getTime()) / 6048e5) + 1)}`;
|
|
976
|
-
}
|
|
977
|
-
return calendarDateKey(date);
|
|
978
|
-
}
|
|
979
|
-
function parseDatePickerModeKey(value, mode) {
|
|
980
|
-
if (mode === "date" || mode === "multiple") return parseCalendarDateKey(value);
|
|
981
|
-
if (mode === "year") return /^\d{4}$/.test(value) ? parseCalendarDateKey(`${value}-01-01`) : null;
|
|
982
|
-
if (mode === "month") return /^\d{4}-\d{2}$/.test(value) ? parseCalendarDateKey(`${value}-01`) : null;
|
|
983
|
-
const match = /^(\d{4})-W(\d{2})$/.exec(value);
|
|
984
|
-
if (!match || Number(match[2]) < 1 || Number(match[2]) > 53) return null;
|
|
985
|
-
const start = isoWeekStart(localDate(Number(match[1]), 0, 4));
|
|
986
|
-
start.setDate(start.getDate() + (Number(match[2]) - 1) * 7);
|
|
987
|
-
return datePickerModeKey(start, "week") === value ? start : null;
|
|
988
|
-
}
|
|
989
|
-
function validateDatePickerModeValue(value, mode = "date", policy = {}) {
|
|
990
|
-
if (!value) return void 0;
|
|
991
|
-
if (mode === "multiple") {
|
|
992
|
-
const values = value.split(",").map((part) => part.trim());
|
|
993
|
-
if (values.some((part) => !part)) return "\u8BF7\u4F7F\u7528\u9017\u53F7\u5206\u9694\u5B8C\u6574\u65E5\u671F";
|
|
994
|
-
for (const part of values) {
|
|
995
|
-
const error = validateDatePickerModeValue(part, "date", policy);
|
|
996
|
-
if (error) return error;
|
|
997
|
-
}
|
|
998
|
-
return void 0;
|
|
999
|
-
}
|
|
1000
|
-
const first = parseDatePickerModeKey(value, mode);
|
|
1001
|
-
if (!first) return `\u8BF7\u8F93\u5165\u6709\u6548${mode === "year" ? "\u5E74\u4EFD\uFF0C\u683C\u5F0F\u4E3A YYYY" : mode === "month" ? "\u6708\u4EFD\uFF0C\u683C\u5F0F\u4E3A YYYY-MM" : mode === "week" ? "ISO\u5468\uFF0C\u683C\u5F0F\u4E3A YYYY-Www" : "\u65E5\u671F\uFF0C\u683C\u5F0F\u4E3A YYYY-MM-DD"}`;
|
|
1002
|
-
const last = new Date(first);
|
|
1003
|
-
if (mode === "year") last.setFullYear(first.getFullYear() + 1, 0, 0);
|
|
1004
|
-
if (mode === "month") last.setMonth(first.getMonth() + 1, 0);
|
|
1005
|
-
if (mode === "week") last.setDate(first.getDate() + 6);
|
|
1006
|
-
const min = parseCalendarDateKey(policy.min);
|
|
1007
|
-
const max = parseCalendarDateKey(policy.max);
|
|
1008
|
-
if (min && last < min) return `\u65E5\u671F\u4E0D\u80FD\u65E9\u4E8E ${policy.min}`;
|
|
1009
|
-
if (max && first > max) return `\u65E5\u671F\u4E0D\u80FD\u665A\u4E8E ${policy.max}`;
|
|
1010
|
-
if (policy.disabledDate) {
|
|
1011
|
-
const cursor = new Date(min && first < min ? min : first);
|
|
1012
|
-
while (cursor <= last && (!max || cursor <= max)) {
|
|
1013
|
-
if (!policy.disabledDate(new Date(cursor))) return void 0;
|
|
1014
|
-
cursor.setDate(cursor.getDate() + 1);
|
|
1015
|
-
}
|
|
1016
|
-
return "\u8BE5\u65E5\u671F\u533A\u95F4\u4E0D\u53EF\u9009\u62E9";
|
|
1017
|
-
}
|
|
1018
|
-
return void 0;
|
|
1019
|
-
}
|
|
1020
|
-
function validateDateTimeRangeValue(value, policy = {}) {
|
|
1021
|
-
if (!value[0] && !value[1]) return void 0;
|
|
1022
|
-
if (!value[0] || !value[1]) return "\u8BF7\u586B\u5199\u5B8C\u6574\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u65E5\u671F\u65F6\u95F4";
|
|
1023
|
-
return validateDateTimeValue(value[0], policy) ?? validateDateTimeValue(value[1], policy) ?? (value[0] > value[1] ? "\u7ED3\u675F\u65E5\u671F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65E5\u671F\u65F6\u95F4" : void 0);
|
|
1024
|
-
}
|
|
1025
|
-
function validateDateRangeShortcut(value, policy = {}) {
|
|
1026
|
-
if (!value[0] || !value[1]) return "\u5FEB\u6377\u8303\u56F4\u5FC5\u987B\u5305\u542B\u4E24\u4E2A\u5B8C\u6574\u65E5\u671F";
|
|
1027
|
-
return validateDatePickerModeValue(value[0], "date", policy) ?? validateDatePickerModeValue(value[1], "date", policy) ?? (value[0] > value[1] ? "\u7ED3\u675F\u65E5\u671F\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65E5\u671F" : void 0);
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
// src/tree-drag.ts
|
|
1031
|
-
function canDropTreeNode(items, source, target) {
|
|
1032
|
-
let drag;
|
|
1033
|
-
let exists = false;
|
|
1034
|
-
const walk = (nodes) => {
|
|
1035
|
-
for (const node of nodes) {
|
|
1036
|
-
if (node.key === source) drag = node;
|
|
1037
|
-
if (node.key === target) exists = true;
|
|
1038
|
-
if (node.children) walk(node.children);
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
|
-
walk(items);
|
|
1042
|
-
const contains = (node) => node.key === target || Boolean(node.children?.some(contains));
|
|
1043
|
-
return Boolean(drag && exists && !contains(drag));
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
// src/form-state.ts
|
|
1047
|
-
function isFormPathWithin(field, parent) {
|
|
1048
|
-
const name = normalizeFormPath(field), root = normalizeFormPath(parent);
|
|
1049
|
-
return name === root || name.startsWith(`${root}.`);
|
|
1050
|
-
}
|
|
1051
|
-
function normalizeFormPath(path) {
|
|
1052
|
-
if (/\[\d+\](?=[^.\[])/.test(path)) throw new Error("UGForm \u5B57\u6BB5\u8DEF\u5F84\u65E0\u6548");
|
|
1053
|
-
const normalized = path.replace(/\[(\d+)\]/g, ".$1");
|
|
1054
|
-
const parts = normalized.split(".");
|
|
1055
|
-
if (parts.some((part) => !part || /[\[\]]/.test(part) || ["__proto__", "prototype", "constructor"].includes(part))) {
|
|
1056
|
-
throw new Error("UGForm \u5B57\u6BB5\u8DEF\u5F84\u65E0\u6548");
|
|
1057
|
-
}
|
|
1058
|
-
return normalized;
|
|
1059
|
-
}
|
|
1060
|
-
function getFormPath(values, path) {
|
|
1061
|
-
let current = values;
|
|
1062
|
-
for (const key of normalizeFormPath(path).split(".")) {
|
|
1063
|
-
if (!current || typeof current !== "object" || !Object.hasOwn(current, key)) return void 0;
|
|
1064
|
-
current = current[key];
|
|
1065
|
-
}
|
|
1066
|
-
return current;
|
|
1067
|
-
}
|
|
1068
|
-
function isFormPathActive(values, path) {
|
|
1069
|
-
let current = values;
|
|
1070
|
-
for (const key of normalizeFormPath(path).split(".")) {
|
|
1071
|
-
if (Array.isArray(current) && /^\d+$/.test(key) && Number(key) >= current.length) return false;
|
|
1072
|
-
current = current && typeof current === "object" && Object.hasOwn(current, key) ? current[key] : void 0;
|
|
1073
|
-
}
|
|
1074
|
-
return true;
|
|
1075
|
-
}
|
|
1076
|
-
function setFormPath(values, path, value) {
|
|
1077
|
-
const keys = normalizeFormPath(path).split(".");
|
|
1078
|
-
const write = (current, index) => {
|
|
1079
|
-
const key = keys[index];
|
|
1080
|
-
const copy = Array.isArray(current) ? [...current] : current && typeof current === "object" ? { ...current } : /^\d+$/.test(key) ? [] : {};
|
|
1081
|
-
const record = copy;
|
|
1082
|
-
record[key] = index === keys.length - 1 ? value : write(record[key], index + 1);
|
|
1083
|
-
return copy;
|
|
1084
|
-
};
|
|
1085
|
-
return write(values, 0);
|
|
1086
|
-
}
|
|
1087
|
-
function getFormPaths(values, prefix = "") {
|
|
1088
|
-
if (!values || typeof values !== "object" || values instanceof Date) return prefix ? [prefix] : [];
|
|
1089
|
-
const entries = Object.entries(values);
|
|
1090
|
-
if (!entries.length) return prefix ? [prefix] : [];
|
|
1091
|
-
return entries.flatMap(([key, value]) => {
|
|
1092
|
-
const path = prefix ? `${prefix}.${key}` : key;
|
|
1093
|
-
return [path, ...value && typeof value === "object" && !(value instanceof Date) ? getFormPaths(value, path).filter((item) => item !== path) : []];
|
|
1094
|
-
});
|
|
1095
|
-
}
|
|
1096
|
-
function isFormValueEqual(left, right) {
|
|
1097
|
-
if (Object.is(left, right)) return true;
|
|
1098
|
-
if (left instanceof Date && right instanceof Date) return left.getTime() === right.getTime();
|
|
1099
|
-
if (!left || !right || typeof left !== "object" || typeof right !== "object" || Array.isArray(left) !== Array.isArray(right)) return false;
|
|
1100
|
-
if (!Array.isArray(left) && ![Object.prototype, null].includes(Object.getPrototypeOf(left))) return false;
|
|
1101
|
-
if (!Array.isArray(right) && ![Object.prototype, null].includes(Object.getPrototypeOf(right))) return false;
|
|
1102
|
-
const keys = Object.keys(left);
|
|
1103
|
-
return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && isFormValueEqual(left[key], right[key]));
|
|
1104
|
-
}
|
|
1105
|
-
function createFormFieldArray(path, read, write) {
|
|
1106
|
-
const name = normalizeFormPath(path);
|
|
1107
|
-
let sequence = 0;
|
|
1108
|
-
let ids = [];
|
|
1109
|
-
const nextId = () => `${name}-${++sequence}`;
|
|
1110
|
-
function values() {
|
|
1111
|
-
const current = read();
|
|
1112
|
-
if (current !== void 0 && !Array.isArray(current)) throw new Error("UGForm fieldArray \u53EA\u80FD\u7ED1\u5B9A\u6570\u7EC4\u5B57\u6BB5");
|
|
1113
|
-
const result = current ?? [];
|
|
1114
|
-
ids = result.map((_, index) => ids[index] ?? nextId());
|
|
1115
|
-
return result;
|
|
1116
|
-
}
|
|
1117
|
-
const validIndex = (index, length) => Number.isInteger(index) && index >= 0 && index < length;
|
|
1118
|
-
const controller = {
|
|
1119
|
-
get fields() {
|
|
1120
|
-
return values().map((value, index) => ({ id: ids[index], index, name: `${name}.${index}`, value }));
|
|
1121
|
-
},
|
|
1122
|
-
append(value) {
|
|
1123
|
-
controller.insert(values().length, value);
|
|
1124
|
-
},
|
|
1125
|
-
insert(index, value) {
|
|
1126
|
-
const current = values();
|
|
1127
|
-
if (!Number.isInteger(index) || index < 0 || index > current.length) return;
|
|
1128
|
-
const next = [...current];
|
|
1129
|
-
next.splice(index, 0, value);
|
|
1130
|
-
ids.splice(index, 0, nextId());
|
|
1131
|
-
write(next);
|
|
1132
|
-
},
|
|
1133
|
-
remove(index) {
|
|
1134
|
-
const current = values();
|
|
1135
|
-
if (!validIndex(index, current.length)) return;
|
|
1136
|
-
const next = [...current];
|
|
1137
|
-
next.splice(index, 1);
|
|
1138
|
-
ids.splice(index, 1);
|
|
1139
|
-
write(next);
|
|
1140
|
-
},
|
|
1141
|
-
move(from, to) {
|
|
1142
|
-
const current = values();
|
|
1143
|
-
if (!validIndex(from, current.length) || !validIndex(to, current.length) || from === to) return;
|
|
1144
|
-
const next = [...current];
|
|
1145
|
-
next.splice(to, 0, next.splice(from, 1)[0]);
|
|
1146
|
-
ids.splice(to, 0, ids.splice(from, 1)[0]);
|
|
1147
|
-
write(next);
|
|
1148
|
-
},
|
|
1149
|
-
replace(next) {
|
|
1150
|
-
ids = next.map(nextId);
|
|
1151
|
-
write([...next]);
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
return { controller, resetIds() {
|
|
1155
|
-
ids = [];
|
|
1156
|
-
} };
|
|
1157
|
-
}
|
|
1158
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1159
|
-
0 && (module.exports = {
|
|
1160
|
-
addCalendarDays,
|
|
1161
|
-
addCalendarMonths,
|
|
1162
|
-
applyUGThemeProfile,
|
|
1163
|
-
buildCalendarMonth,
|
|
1164
|
-
buildCalendarWeekdays,
|
|
1165
|
-
buildTimeSelectOptions,
|
|
1166
|
-
calendarDateKey,
|
|
1167
|
-
canDropTreeNode,
|
|
1168
|
-
compareCalendarDates,
|
|
1169
|
-
countTextCharacters,
|
|
1170
|
-
createFormFieldArray,
|
|
1171
|
-
createUGThemeValue,
|
|
1172
|
-
datePickerModeKey,
|
|
1173
|
-
defaultUGNavigationColors,
|
|
1174
|
-
defaultUGTheme,
|
|
1175
|
-
defaultUGThemeConfiguratorOptions,
|
|
1176
|
-
defaultUGThemeNavigationColors,
|
|
1177
|
-
defaultUGThemeProfiles,
|
|
1178
|
-
encodeSelectValue,
|
|
1179
|
-
filterSelectionListOptions,
|
|
1180
|
-
findTreeNodePath,
|
|
1181
|
-
formatCalendarDay,
|
|
1182
|
-
formatCalendarMonth,
|
|
1183
|
-
formatColorHex,
|
|
1184
|
-
formatTimeValue,
|
|
1185
|
-
getAvailableTimeValues,
|
|
1186
|
-
getCalendarRangePosition,
|
|
1187
|
-
getFormPath,
|
|
1188
|
-
getFormPaths,
|
|
1189
|
-
getImagePreviewLayout,
|
|
1190
|
-
getRatingKeyboardValue,
|
|
1191
|
-
getSelectionListScope,
|
|
1192
|
-
getTableColumnFixed,
|
|
1193
|
-
getTableColumnStyle,
|
|
1194
|
-
getTableSpanGrid,
|
|
1195
|
-
getTableStructure,
|
|
1196
|
-
getTimeColumnChoices,
|
|
1197
|
-
getTreeCheckState,
|
|
1198
|
-
groupSelectionListOptions,
|
|
1199
|
-
isEmptyFormValue,
|
|
1200
|
-
isFormPathActive,
|
|
1201
|
-
isFormPathWithin,
|
|
1202
|
-
isFormValueEqual,
|
|
1203
|
-
isSameCalendarDay,
|
|
1204
|
-
isUGThemeProfileModified,
|
|
1205
|
-
isValidCalendarDate,
|
|
1206
|
-
isoWeekStart,
|
|
1207
|
-
limitTextByCount,
|
|
1208
|
-
localDateTimeKey,
|
|
1209
|
-
moveTableColumn,
|
|
1210
|
-
normalizeCalendarDate,
|
|
1211
|
-
normalizeFormPath,
|
|
1212
|
-
normalizeRatingMax,
|
|
1213
|
-
normalizeRatingValue,
|
|
1214
|
-
normalizeSelectKeys,
|
|
1215
|
-
parseCalendarDateKey,
|
|
1216
|
-
parseCalendarRange,
|
|
1217
|
-
parseColorHex,
|
|
1218
|
-
parseDatePickerModeKey,
|
|
1219
|
-
parseLocalDateTimeValue,
|
|
1220
|
-
parseTimeValue,
|
|
1221
|
-
projectTreeTableRows,
|
|
1222
|
-
resolveTableFixedColumns,
|
|
1223
|
-
resolveUGNavigationColors,
|
|
1224
|
-
resolveUGNavigationPalette,
|
|
1225
|
-
setFormPath,
|
|
1226
|
-
startOfCalendarMonth,
|
|
1227
|
-
tableColumnLength,
|
|
1228
|
-
toggleTreeCheckedKey,
|
|
1229
|
-
ugThemeProfileFields,
|
|
1230
|
-
updateSelectionListScope,
|
|
1231
|
-
validateDatePickerModeValue,
|
|
1232
|
-
validateDateRangeShortcut,
|
|
1233
|
-
validateDateTimeRangeValue,
|
|
1234
|
-
validateDateTimeValue,
|
|
1235
|
-
validateDateValue,
|
|
1236
|
-
validateFormValue,
|
|
1237
|
-
validateTimeRangeValue,
|
|
1238
|
-
validateTimeValue
|
|
1239
|
-
});
|
|
2
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var index_exports={};__export(index_exports,{addCalendarDays:()=>addCalendarDays,addCalendarMonths:()=>addCalendarMonths,applyUGThemeProfile:()=>applyUGThemeProfile,buildCalendarMonth:()=>buildCalendarMonth,buildCalendarWeekdays:()=>buildCalendarWeekdays,buildTimeSelectOptions:()=>buildTimeSelectOptions,calendarDateKey:()=>calendarDateKey,canDropTreeNode:()=>canDropTreeNode,compareCalendarDates:()=>compareCalendarDates,countTextCharacters:()=>countTextCharacters,createFormFieldArray:()=>createFormFieldArray,createUGThemeValue:()=>createUGThemeValue,datePickerModeKey:()=>datePickerModeKey,defaultUGNavigationColors:()=>defaultUGNavigationColors,defaultUGTheme:()=>defaultUGTheme,defaultUGThemeConfiguratorOptions:()=>defaultUGThemeConfiguratorOptions,defaultUGThemeNavigationColors:()=>defaultUGThemeNavigationColors,defaultUGThemeProfiles:()=>defaultUGThemeProfiles,encodeSelectValue:()=>encodeSelectValue,filterSelectionListOptions:()=>filterSelectionListOptions,findTreeNodePath:()=>findTreeNodePath,formatCalendarDay:()=>formatCalendarDay,formatCalendarMonth:()=>formatCalendarMonth,formatColorHex:()=>formatColorHex,formatTimeValue:()=>formatTimeValue,getAvailableTimeValues:()=>getAvailableTimeValues,getCalendarRangePosition:()=>getCalendarRangePosition,getFormPath:()=>getFormPath,getFormPaths:()=>getFormPaths,getImagePreviewLayout:()=>getImagePreviewLayout,getRatingKeyboardValue:()=>getRatingKeyboardValue,getSelectionListScope:()=>getSelectionListScope,getTableColumnFixed:()=>getTableColumnFixed,getTableColumnStyle:()=>getTableColumnStyle,getTableOffsetColumns:()=>getTableOffsetColumns,getTableSpanGrid:()=>getTableSpanGrid,getTableStructure:()=>getTableStructure,getTimeColumnChoices:()=>getTimeColumnChoices,getTreeCheckState:()=>getTreeCheckState,groupSelectionListOptions:()=>groupSelectionListOptions,isEmptyFormValue:()=>isEmptyFormValue,isFormPathActive:()=>isFormPathActive,isFormPathWithin:()=>isFormPathWithin,isFormValueEqual:()=>isFormValueEqual,isSameCalendarDay:()=>isSameCalendarDay,isUGThemeProfileModified:()=>isUGThemeProfileModified,isValidCalendarDate:()=>isValidCalendarDate,isoWeekStart:()=>isoWeekStart,limitTextByCount:()=>limitTextByCount,localDateTimeKey:()=>localDateTimeKey,moveTableColumn:()=>moveTableColumn,normalizeCalendarDate:()=>normalizeCalendarDate,normalizeFormPath:()=>normalizeFormPath,normalizeRatingMax:()=>normalizeRatingMax,normalizeRatingValue:()=>normalizeRatingValue,normalizeSelectKeys:()=>normalizeSelectKeys,parseCalendarDateKey:()=>parseCalendarDateKey,parseCalendarRange:()=>parseCalendarRange,parseColorHex:()=>parseColorHex,parseDatePickerModeKey:()=>parseDatePickerModeKey,parseLocalDateTimeValue:()=>parseLocalDateTimeValue,parseTimeValue:()=>parseTimeValue,projectTreeTableRows:()=>projectTreeTableRows,resolveTableFixedColumns:()=>resolveTableFixedColumns,resolveUGNavigationColors:()=>resolveUGNavigationColors,resolveUGNavigationPalette:()=>resolveUGNavigationPalette,setFormPath:()=>setFormPath,startOfCalendarMonth:()=>startOfCalendarMonth,tableColumnLength:()=>tableColumnLength,toggleTreeCheckedKey:()=>toggleTreeCheckedKey,ugThemeProfileFields:()=>ugThemeProfileFields,updateSelectionListScope:()=>updateSelectionListScope,validateDatePickerModeValue:()=>validateDatePickerModeValue,validateDateRangeShortcut:()=>validateDateRangeShortcut,validateDateTimeRangeValue:()=>validateDateTimeRangeValue,validateDateTimeValue:()=>validateDateTimeValue,validateDateValue:()=>validateDateValue,validateFormValue:()=>validateFormValue,validateTimeRangeValue:()=>validateTimeRangeValue,validateTimeValue:()=>validateTimeValue});module.exports=__toCommonJS(index_exports);var defaultUGThemeNavigationColors={default:{light:{background:"#ffffff",text:"#475569",activeBackground:"#ecf5ff",activeText:"#1d4ed8",hoverBackground:"#f1f5f9"},dark:{background:"#151c28",text:"#cbd5e1",activeBackground:"#3178c2",activeText:"#ffffff",hoverBackground:"#293442"}},minimal:{light:{background:"#ffffff",text:"#334155",activeBackground:"#e0f2fe",activeText:"#0369a1",hoverBackground:"#f8fafc"},dark:{background:"#111827",text:"#d1d5db",activeBackground:"#164e63",activeText:"#ecfeff",hoverBackground:"#1f2937"}},mecha:{light:{background:"#eef2f6",text:"#334155",activeBackground:"#cffafe",activeText:"#0e7490",hoverBackground:"#e2e8f0"},dark:{background:"#0b1220",text:"#cbd5e1",activeBackground:"#155e75",activeText:"#ecfeff",hoverBackground:"#172033"}}};var defaultUGNavigationColors=defaultUGThemeNavigationColors.default;function resolveUGNavigationPalette(mode,prefersDark=false){if(mode==="dark")return"dark";if(mode==="light")return"light";return prefersDark?"dark":"light"}var defaultUGAccentNavigationColors={cyan:{light:{activeBackground:"#cffafe",activeText:"#0e7490"},dark:{activeBackground:"#0e7490",activeText:"#ecfeff"}},blue:{light:{activeBackground:"#dbeafe",activeText:"#1d4ed8"},dark:{activeBackground:"#1d4ed8",activeText:"#eff6ff"}},violet:{light:{activeBackground:"#ede9fe",activeText:"#6d28d9"},dark:{activeBackground:"#6d28d9",activeText:"#f5f3ff"}},emerald:{light:{activeBackground:"#d1fae5",activeText:"#047857"},dark:{activeBackground:"#047857",activeText:"#ecfdf5"}},rose:{light:{activeBackground:"#ffe4e6",activeText:"#be123c"},dark:{activeBackground:"#be123c",activeText:"#fff1f2"}}};function resolveUGNavigationColors(preset,palette,overrides,accent="theme"){if(overrides)return overrides;const themeColors=preset in defaultUGThemeNavigationColors?defaultUGThemeNavigationColors[preset]:defaultUGThemeNavigationColors.default;const resolvedColors=themeColors[palette];if(accent in defaultUGAccentNavigationColors){return{...resolvedColors,...defaultUGAccentNavigationColors[accent][palette]}}return resolvedColors}var ugThemeProfileFields=["density","radius","shadow","font","contrast","motion","background"];var defaultUGTheme={preset:"default",mode:"system",surface:"workspace",density:"comfortable",radius:"default",shadow:"standard",font:"system",contrast:"standard",motion:"standard",background:"grid",accent:"theme"};var defaultUGThemeProfiles=[{id:"balanced",label:"\u5747\u8861",description:"\u8212\u9002\u3001\u6E05\u6670\uFF0C\u9002\u5408\u65E5\u5E38\u901A\u7528\u64CD\u4F5C\u3002",value:{density:"comfortable",radius:"default",shadow:"standard",font:"system",contrast:"standard",motion:"standard",background:"plain"}},{id:"efficient",label:"\u9AD8\u6548",description:"\u7D27\u51D1\u3001\u5229\u843D\uFF0C\u9002\u5408\u9AD8\u9891\u64CD\u4F5C\u548C\u6570\u636E\u5DE5\u4F5C\u3002",value:{density:"compact",radius:"sharp",shadow:"flat",font:"compact",contrast:"strong",motion:"reduced",background:"plain"}},{id:"readable",label:"\u6613\u8BFB",description:"\u5BBD\u677E\u3001\u6E05\u6670\uFF0C\u9002\u5408\u957F\u65F6\u95F4\u9605\u8BFB\u548C\u4F4E\u523A\u6FC0\u64CD\u4F5C\u3002",value:{density:"spacious",radius:"soft",shadow:"standard",font:"readable",contrast:"strong",motion:"reduced",background:"plain"}}];var defaultUGThemeConfiguratorOptions={presets:[{value:"default",label:"\u9ED8\u8BA4",description:"\u5747\u8861\u7684\u8FB9\u754C\u3001\u5C42\u6B21\u4E0E\u4FE1\u606F\u5BC6\u5EA6\u3002"},{value:"minimal",label:"\u7B80\u6D01",description:"\u51CF\u5C11\u88C5\u9970\uFF0C\u8BA9\u5185\u5BB9\u6210\u4E3A\u89C6\u89C9\u4E2D\u5FC3\u3002"},{value:"mecha",label:"\u673A\u68B0",description:"\u786C\u6717\u8FB9\u754C\u4E0E\u7D27\u51D1\u7684\u63A7\u5236\u53F0\u8282\u594F\u3002"}],modes:[{value:"system",label:"\u8DDF\u968F\u7CFB\u7EDF",description:"\u81EA\u52A8\u5339\u914D\u8BBE\u5907\u5916\u89C2\u3002"},{value:"light",label:"\u4EAE\u8272",description:"\u59CB\u7EC8\u4F7F\u7528\u4EAE\u8272\u754C\u9762\u3002"},{value:"dark",label:"\u6697\u8272",description:"\u59CB\u7EC8\u4F7F\u7528\u6697\u8272\u754C\u9762\u3002"}],surfaces:[{value:"workspace",label:"\u5DE5\u4F5C\u533A"},{value:"showcase",label:"\u5C55\u793A\u9875"},{value:"auth",label:"\u8BA4\u8BC1\u9875"},{value:"content",label:"\u5185\u5BB9\u9875"}],densities:[{value:"comfortable",label:"\u8212\u9002"},{value:"compact",label:"\u7D27\u51D1"},{value:"spacious",label:"\u5BBD\u677E"}],radii:[{value:"sharp",label:"\u5229\u843D"},{value:"default",label:"\u9ED8\u8BA4"},{value:"soft",label:"\u67D4\u548C"}],shadows:[{value:"flat",label:"\u5E73\u9762"},{value:"standard",label:"\u6807\u51C6"},{value:"layered",label:"\u5C42\u6B21"}],fonts:[{value:"system",label:"\u7CFB\u7EDF"},{value:"readable",label:"\u6613\u8BFB"},{value:"compact",label:"\u7D27\u51D1"}],contrasts:[{value:"soft",label:"\u67D4\u548C"},{value:"standard",label:"\u6807\u51C6"},{value:"strong",label:"\u6E05\u6670"}],motions:[{value:"reduced",label:"\u51CF\u5C11"},{value:"standard",label:"\u6807\u51C6"},{value:"lively",label:"\u7075\u52A8"}],backgrounds:[{value:"plain",label:"\u7EAF\u51C0"},{value:"grid",label:"\u7F51\u683C"},{value:"soft",label:"\u67D4\u5149"}],accents:[{value:"theme",label:"\u4E3B\u9898\u9ED8\u8BA4"},{value:"cyan",label:"UG \u9752"},{value:"blue",label:"\u6D77\u84DD"},{value:"violet",label:"\u7D2B\u6676"},{value:"emerald",label:"\u677E\u7EFF"},{value:"rose",label:"\u73AB\u7EA2"}]};function createUGThemeValue(parent,overrides){return{preset:overrides.preset??parent.preset,mode:overrides.mode??parent.mode,surface:overrides.surface??parent.surface,density:overrides.density??parent.density,radius:overrides.radius??parent.radius,shadow:overrides.shadow??parent.shadow,font:overrides.font??parent.font,contrast:overrides.contrast??parent.contrast,motion:overrides.motion??parent.motion,background:overrides.background??parent.background,accent:overrides.accent??parent.accent}}function applyUGThemeProfile(current,profile){return createUGThemeValue(current,profile.value)}function isUGThemeProfileModified(current,profile){return ugThemeProfileFields.some(field=>current[field]!==profile.value[field])}function isEmptyFormValue(value){return value===void 0||value===null||value===""||Array.isArray(value)&&value.length===0}function hasTrigger(rule,trigger){if(trigger==="submit")return true;if(!rule.trigger)return true;return Array.isArray(rule.trigger)?rule.trigger.includes(trigger):rule.trigger===trigger}function getValueLength(value){if(typeof value==="string"||Array.isArray(value))return value.length;return void 0}function isValueType(value,type){switch(type){case"array":return Array.isArray(value);case"date":return value instanceof Date&&!Number.isNaN(value.getTime());case"email":return typeof value==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);case"url":return typeof value==="string"&&/^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i.test(value);default:return typeof value===type}}function defaultMessage(rule){if(rule.required)return"\u8BE5\u5B57\u6BB5\u4E3A\u5FC5\u586B\u9879";if(rule.type)return"\u5B57\u6BB5\u683C\u5F0F\u4E0D\u6B63\u786E";if(rule.len!==void 0)return`\u957F\u5EA6\u5FC5\u987B\u4E3A ${rule.len}`;if(rule.min!==void 0&&rule.max!==void 0)return`\u503C\u5FC5\u987B\u5728 ${rule.min} \u5230 ${rule.max} \u4E4B\u95F4`;if(rule.min!==void 0)return`\u503C\u4E0D\u80FD\u5C0F\u4E8E ${rule.min}`;if(rule.max!==void 0)return`\u503C\u4E0D\u80FD\u5927\u4E8E ${rule.max}`;if(rule.pattern)return"\u5B57\u6BB5\u683C\u5F0F\u4E0D\u6B63\u786E";return"\u5B57\u6BB5\u6821\u9A8C\u672A\u901A\u8FC7"}function failsRange(value,rule){const comparable=typeof value==="number"?value:getValueLength(value);if(comparable===void 0)return false;if(rule.len!==void 0&&comparable!==rule.len)return true;if(rule.min!==void 0&&comparable<rule.min)return true;if(rule.max!==void 0&&comparable>rule.max)return true;return false}async function validateFormValue(value,fieldRules,values,trigger="submit"){const rules=fieldRules?Array.isArray(fieldRules)?fieldRules:[fieldRules]:[];for(const rule of rules){if(!hasTrigger(rule,trigger))continue;const empty=isEmptyFormValue(value);if(rule.required&&empty)return rule.message??defaultMessage(rule);if(empty)continue;if(rule.type&&!isValueType(value,rule.type)){return rule.message??defaultMessage(rule)}if(failsRange(value,rule)){return rule.message??defaultMessage(rule)}if(rule.pattern){rule.pattern.lastIndex=0;if(typeof value!=="string"||!rule.pattern.test(value)){return rule.message??defaultMessage(rule)}}if(rule.validator){try{const result=await rule.validator(value,values);if(result===false)return rule.message??defaultMessage(rule);if(typeof result==="string")return result}catch(error){return error instanceof Error?error.message:rule.message??defaultMessage(rule)}}}return void 0}function encodeSelectValue(value){return`${typeof value==="number"?"number":"string"}:${value}`}function normalizeSelectKeys(value){if(value===void 0||value==="")return[];return(Array.isArray(value)?value:[value]).map(encodeSelectValue)}function countTextCharacters(value,counter){if(!counter)return value.length;const count=counter(value);return Number.isFinite(count)?Math.max(0,Math.trunc(count)):value.length}function limitTextByCount(value,maxLength,counter){if(!counter||maxLength===void 0)return value;const limit=Math.max(0,Math.trunc(maxLength));if(countTextCharacters(value,counter)<=limit)return value;const characters=Array.from(value);let low=0;let high=characters.length;while(low<high){const middle=Math.ceil((low+high)/2);const candidate=characters.slice(0,middle).join("");if(countTextCharacters(candidate,counter)<=limit)low=middle;else high=middle-1}return characters.slice(0,low).join("")}function isValidCalendarDate(value){return value instanceof Date&&Number.isFinite(value.getTime())}function normalizeCalendarDate(value,fallback=new Date){const source=isValidCalendarDate(value)?value:fallback;return localCalendarDate(source.getFullYear(),source.getMonth(),source.getDate())}function localCalendarDate(year,month,day){const date=new Date(0);date.setFullYear(year,month,day);date.setHours(0,0,0,0);return date}function startOfCalendarMonth(value){return localCalendarDate(value.getFullYear(),value.getMonth(),1)}function addCalendarDays(value,amount){return localCalendarDate(value.getFullYear(),value.getMonth(),value.getDate()+amount)}function addCalendarMonths(value,amount){return localCalendarDate(value.getFullYear(),value.getMonth()+amount,1)}function calendarDateKey(value){const month=`${value.getMonth()+1}`.padStart(2,"0");const day=`${value.getDate()}`.padStart(2,"0");return`${`${value.getFullYear()}`.padStart(4,"0")}-${month}-${day}`}function compareCalendarDates(left,right){const leftTime=normalizeCalendarDate(left).getTime();const rightTime=normalizeCalendarDate(right).getTime();return leftTime===rightTime?0:leftTime<rightTime?-1:1}function isSameCalendarDay(left,right){return isValidCalendarDate(left)&&isValidCalendarDate(right)&&left.getFullYear()===right.getFullYear()&&left.getMonth()===right.getMonth()&&left.getDate()===right.getDate()}function buildCalendarMonth(month,weekStartsOn=1){const firstDay=startOfCalendarMonth(month);const offset=(firstDay.getDay()-weekStartsOn+7)%7;const gridStart=addCalendarDays(firstDay,-offset);const today=normalizeCalendarDate(new Date);return Array.from({length:42},(_,index)=>{const date=addCalendarDays(gridStart,index);return{date,key:calendarDateKey(date),day:date.getDate(),outside:date.getMonth()!==firstDay.getMonth(),today:isSameCalendarDay(date,today)}})}function buildCalendarWeekdays(locale="zh-CN",weekStartsOn=1){let formatter;try{formatter=new Intl.DateTimeFormat(locale,{weekday:"short"})}catch{formatter=new Intl.DateTimeFormat("zh-CN",{weekday:"short"})}const sunday=new Date(2026,0,4);return Array.from({length:7},(_,index)=>formatter.format(addCalendarDays(sunday,weekStartsOn+index)))}function formatCalendarMonth(value,locale="zh-CN"){try{return new Intl.DateTimeFormat(locale,{year:"numeric",month:"long"}).format(value)}catch{return new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"long"}).format(value)}}function formatCalendarDay(value,locale="zh-CN"){try{return new Intl.DateTimeFormat(locale,{year:"numeric",month:"long",day:"numeric",weekday:"long"}).format(value)}catch{return new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"long",day:"numeric",weekday:"long"}).format(value)}}function parseCalendarDateKey(value){const match=/^(\d{4})-(\d{2})-(\d{2})$/.exec(value??"");if(!match)return null;const year=Number(match[1]);const month=Number(match[2])-1;const day=Number(match[3]);const date=new Date(0);date.setFullYear(year,month,day);date.setHours(0,0,0,0);return date.getFullYear()===year&&date.getMonth()===month&&date.getDate()===day?date:null}function parseCalendarRange(value){return[parseCalendarDateKey(value[0]),parseCalendarDateKey(value[1])]}function getCalendarRangePosition(date,range){if(!range)return void 0;const[start,end]=range;if(isSameCalendarDay(date,start)&&isSameCalendarDay(date,end))return"single";if(isSameCalendarDay(date,start))return"start";if(isSameCalendarDay(date,end))return"end";if(start&&end&&compareCalendarDates(date,start)>0&&compareCalendarDates(date,end)<0)return"middle";return void 0}function findTreeNodePath(items,key){if(key===void 0)return[];for(const node of items){if(node.key===key)return[node];const path=findTreeNodePath(node.children??[],key);if(path.length>0)return[node,...path]}return[]}function normalizeSearch(value){return value.normalize("NFKC").toLocaleLowerCase().trim()}function filterSelectionListOptions(options,query=""){const seen=new Set;const search=normalizeSearch(query);return options.filter(option=>{if(seen.has(option.id))return false;seen.add(option.id);return!search||[option.id,option.label,option.group??"",option.description??""].some(text=>normalizeSearch(text).includes(search))})}function groupSelectionListOptions(options){const groups=new Map;for(const option of options){const key=option.group===void 0?"ungrouped":`group:${option.group}`;const group=groups.get(key)??{key,label:option.group??"\u5176\u4ED6",options:[]};group.options.push(option);groups.set(key,group)}return[...groups.values()]}function getSelectionListScope(options,selected){const available=options.filter(option=>!option.disabled);const ids=new Set(selected);const selectedCount=available.filter(option=>ids.has(option.id)).length;return{total:options.length,available:available.length,disabled:options.length-available.length,selected:options.filter(option=>ids.has(option.id)).length,checked:available.length>0&&selectedCount===available.length,indeterminate:selectedCount>0&&selectedCount<available.length}}function updateSelectionListScope(selected,options,checked){const scope=new Set(options.filter(option=>!option.disabled).map(option=>option.id));if(!checked)return selected.filter(id=>!scope.has(id));return[...new Set([...selected,...scope])]}var clamp=(value,max)=>Math.min(max,Math.max(0,Number.isFinite(value)?value:0));function parseColorHex(value){const input=value.trim();if(!/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i.test(input))return void 0;const hex=input.length<=5?input.slice(1).split("").map(part=>part+part).join(""):input.slice(1);const[r,g,b]=[0,2,4].map(offset=>Number.parseInt(hex.slice(offset,offset+2),16)/255);const max=Math.max(r,g,b);const min=Math.min(r,g,b);const d=max-min;let h=0;if(d!==0){if(max===r)h=(g-b)/d+(g<b?6:0);else if(max===g)h=(b-r)/d+2;else h=(r-g)/d+4;h*=60}return{h,s:max===0?0:d/max*100,v:max*100,a:hex.length===8?Number.parseInt(hex.slice(6),16)/255:1}}function formatColorHex(color,alpha=false){const h=clamp(color.h,360)%360/60;const s=clamp(color.s,100)/100;const v=clamp(color.v,100)/100;const i=Math.floor(h);const f=h-i;const p=v*(1-s);const q=v*(1-f*s);const t=v*(1-(1-f)*s);const channels=[[v,q,p,p,t,v][i],[t,v,v,q,p,p][i],[p,p,t,v,v,q][i]];if(alpha)channels.push(clamp(color.a,1));return"#"+channels.map(value=>Math.round(value*255).toString(16).padStart(2,"0")).join("").toUpperCase()}function parseTimeValue(value,showSeconds=false){const match=(showSeconds?/^(\d{2}):(\d{2}):(\d{2})$/:/^(\d{2}):(\d{2})$/).exec(value??"");if(!match)return null;const[hours,minutes,seconds]=[Number(match[1]),Number(match[2]),Number(match[3]??0)];return hours<24&&minutes<60&&seconds<60?hours*3600+minutes*60+seconds:null}function formatTimeValue(seconds,showSeconds=false){if(!Number.isInteger(seconds)||seconds<0||seconds>=86400)return"";const parts=[Math.floor(seconds/3600),Math.floor(seconds/60)%60];if(showSeconds)parts.push(seconds%60);return parts.map(part=>String(part).padStart(2,"0")).join(":")}function validateDateValue(value,options={}){if(value==="")return void 0;const date=parseCalendarDateKey(value);if(!date)return"\u8BF7\u8F93\u5165\u6709\u6548\u65E5\u671F\uFF0C\u683C\u5F0F\u4E3A YYYY-MM-DD";const min=parseCalendarDateKey(options.min);const max=parseCalendarDateKey(options.max);if(min&&date<min)return`\u65E5\u671F\u4E0D\u80FD\u65E9\u4E8E ${options.min}`;if(max&&date>max)return`\u65E5\u671F\u4E0D\u80FD\u665A\u4E8E ${options.max}`;if(options.disabledDate?.(date))return"\u8BE5\u65E5\u671F\u4E0D\u53EF\u9009\u62E9";return void 0}function validateTimeValue(value,options={}){if(value==="")return void 0;const seconds=parseTimeValue(value,options.showSeconds);const format=options.showSeconds?"HH:mm:ss":"HH:mm";if(seconds===null)return`\u8BF7\u8F93\u5165\u6709\u6548\u65F6\u95F4\uFF0C\u683C\u5F0F\u4E3A ${format}`;const min=parseTimeValue(options.min,options.showSeconds);const max=parseTimeValue(options.max,options.showSeconds);if(min!==null&&seconds<min)return`\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E ${options.min}`;if(max!==null&&seconds>max)return`\u65F6\u95F4\u4E0D\u80FD\u665A\u4E8E ${options.max}`;if(options.disabledTime?.(value))return"\u8BE5\u65F6\u95F4\u4E0D\u53EF\u9009\u62E9";return void 0}function parseLocalDateTimeValue(value,showSeconds=false){const parts=value.split(" ");if(parts.length!==2)return null;const date=parseCalendarDateKey(parts[0]);return date&&parseTimeValue(parts[1],showSeconds)!==null?{date,time:parts[1]}:null}function validateDateTimeValue(value,options={}){if(value==="")return void 0;const parsed=parseLocalDateTimeValue(value,options.showSeconds);if(!parsed)return`\u8BF7\u8F93\u5165\u6709\u6548\u65E5\u671F\u65F6\u95F4\uFF0C\u683C\u5F0F\u4E3A YYYY-MM-DD ${options.showSeconds?"HH:mm:ss":"HH:mm"}`;if(parseLocalDateTimeValue(options.min??"",options.showSeconds)&&value<options.min)return`\u65E5\u671F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E ${options.min}`;if(parseLocalDateTimeValue(options.max??"",options.showSeconds)&&value>options.max)return`\u65E5\u671F\u65F6\u95F4\u4E0D\u80FD\u665A\u4E8E ${options.max}`;if(options.disabledDate?.(parsed.date))return"\u8BE5\u65E5\u671F\u4E0D\u53EF\u9009\u62E9";if(options.disabledTime?.(value))return"\u8BE5\u65F6\u95F4\u4E0D\u53EF\u9009\u62E9";return void 0}function validateTimeRangeValue(value,options={}){if(!value[0]&&!value[1])return void 0;if(!value[0]||!value[1])return"\u8BF7\u586B\u5199\u5B8C\u6574\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u65F6\u95F4";const error=validateTimeValue(value[0],options)??validateTimeValue(value[1],options);if(error)return error;return parseTimeValue(value[0],options.showSeconds)>parseTimeValue(value[1],options.showSeconds)?"\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65F6\u95F4":void 0}function buildTimeSelectOptions(start="09:00",end="18:00",step="00:30",constraints={}){const first=parseTimeValue(start);const last=parseTimeValue(end);const increment=parseTimeValue(step);if(first===null||last===null||increment===null||increment<=0||first>last)return[];const options=[];for(let seconds=first;seconds<=last;seconds+=increment){const value=formatTimeValue(seconds);options.push({value,label:value,disabled:Boolean(validateTimeValue(value,{...constraints,showSeconds:false}))})}return options}function getAvailableTimeValues(options={}){const increment=options.showSeconds?1:60;const min=parseTimeValue(options.min,options.showSeconds)??0;const max=parseTimeValue(options.max,options.showSeconds)??86399;const values=[];for(let value=Math.ceil(min/increment)*increment;value<=max;value+=increment){if(!options.disabledTime?.(formatTimeValue(value,options.showSeconds)))values.push(value)}return values}function getTimeColumnChoices(available,current,unit){const divisor=unit==="hour"?3600:unit==="minute"?60:1;const count=unit==="hour"?24:60;const currentUnit=Math.floor(current/divisor)%count;const nearest=Array.from({length:count});for(const value of available){const index=Math.floor(value/divisor)%count;const previous=nearest[index];const target=current+(index-currentUnit)*divisor;if(previous===void 0||Math.abs(value-target)<Math.abs(previous-target))nearest[index]=value}return Array.from({length:count},(_,index)=>{return{label:String(index).padStart(2,"0"),value:index,time:nearest[index],disabled:nearest[index]===void 0}})}function localDateTimeKey(date,time){return`${calendarDateKey(date)} ${time}`}function getTreeCheckState(items,keys,strict=false){const seed=new Set(keys);const known=new Set;const disabledKeys=[];const checkedNodeKeys=[];const halfCheckedKeys=[];const leaves=[];function visit(node,parentDisabled,parentChecked){known.add(node.key);const disabled2=Boolean(node.disabled||!strict&&parentDisabled);if(disabled2)disabledKeys.push(node.key);if(strict){if(seed.has(node.key))checkedNodeKeys.push(node.key);node.children?.forEach(child=>visit(child,disabled2,false));return{total:disabled2?0:1,checked:seed.has(node.key)?1:0}}const selected=parentChecked||seed.has(node.key);if(!node.children?.length){if(seed.has(node.key)||!disabled2&&selected)checkedNodeKeys.push(node.key);if(!disabled2&&selected)leaves.push(node.key);return{total:disabled2?0:1,checked:!disabled2&&selected?1:0}}const coverage=node.children.map(child=>visit(child,disabled2,!disabled2&&selected)).reduce((sum,child)=>({total:sum.total+child.total,checked:sum.checked+child.checked}),{total:0,checked:0});if(disabled2?seed.has(node.key):coverage.total>0&&coverage.checked===coverage.total)checkedNodeKeys.push(node.key);else if(!disabled2&&coverage.checked>0)halfCheckedKeys.push(node.key);return coverage}items.forEach(node=>visit(node,false,false));const disabled=new Set(disabledKeys);return{checkedKeys:strict?[...seed]:[...new Set([...keys.filter(key=>!known.has(key)||disabled.has(key)),...leaves])],checkedNodeKeys,halfCheckedKeys,disabledKeys}}function toggleTreeCheckedKey(items,keys,key,checked,strict=false){const state=getTreeCheckState(items,keys,strict);const disabled=new Set(state.disabledKeys);if(disabled.has(key))return state;const find=nodes=>{for(const node2 of nodes){if(node2.key===key)return node2;const child=find(node2.children??[]);if(child)return child}};const node=find(items);if(!node)return state;const next=new Set(state.checkedKeys);function update(item){if(disabled.has(item.key))return;if(!strict&&item.children?.length){item.children.forEach(update);return}if(checked)next.add(item.key);else next.delete(item.key)}update(node);return getTreeCheckState(items,[...next],strict)}function normalizeRatingMax(max){return Number.isFinite(max)?Math.min(100,Math.max(1,Math.floor(max))):5}function normalizeRatingValue(value,max,precision=1){if(!Number.isFinite(value))return 0;return Math.min(normalizeRatingMax(max),Math.max(0,Math.floor((value??0)/precision)*precision))}function getRatingKeyboardValue(value,key,max,precision=1,allowClear=false){const limit=normalizeRatingMax(max);if(key==="Home")return precision;if(key==="End")return limit;if(allowClear&&(key==="Delete"||key==="Backspace"))return 0;if(key==="ArrowUp"||key==="ArrowRight")return Math.min(limit,value+precision);if(key==="ArrowDown"||key==="ArrowLeft")return Math.max(allowClear?0:precision,value-precision);return void 0}function getImagePreviewLayout(width,height,viewportWidth,viewportHeight,zoom=1,rotation=0){const valid=[width,height,viewportWidth,viewportHeight,zoom].every(value=>Number.isFinite(value)&&value>0);if(!valid)return{width:0,height:0,canvasWidth:Math.max(0,viewportWidth||0),canvasHeight:Math.max(0,viewportHeight||0)};const scale=Math.min(1,viewportWidth/width,viewportHeight/height)*Math.max(.25,Math.min(4,zoom));const imageWidth=width*scale;const imageHeight=height*scale;const swap=Math.abs(Math.round(rotation/90))%2===1;return{width:imageWidth,height:imageHeight,canvasWidth:Math.max(viewportWidth,swap?imageHeight:imageWidth),canvasHeight:Math.max(viewportHeight,swap?imageWidth:imageHeight)}}function getTableColumnFixed(column){return column.fixed===true?"left":column.fixed||void 0}function resolveTableFixedColumns(columns,widths,regionWidth,priorityIndex,contentWindow=160){if(!Number.isFinite(regionWidth)||regionWidth<=0)return[...columns];const retained=new Set;const widthAt=index=>Number.isFinite(widths[index])?Math.max(0,widths[index]):0;let occupied=0;const budget=Math.max(0,regionWidth-contentWindow);const attempt=index=>{if(retained.has(index))return;const width=widthAt(index);if(occupied+width<=budget){retained.add(index);occupied+=width}};if(priorityIndex!==void 0&&getTableColumnFixed(columns[priorityIndex]??{}))attempt(priorityIndex);for(let index=columns.length-1;index>=0;index--)if(getTableColumnFixed(columns[index])==="right")attempt(index);for(let index=0;index<columns.length;index++)if(getTableColumnFixed(columns[index])==="left")attempt(index);return columns.map((column,index)=>retained.has(index)?column:{...column,fixed:void 0})}function getTableOffsetColumns(columns,index){const fixed=getTableColumnFixed(columns[index]??{});if(!fixed)return void 0;const result=[];for(let position=fixed==="left"?0:index+1;position<(fixed==="left"?index:columns.length);position++){const column=columns[position];if(column&&getTableColumnFixed(column)===fixed)result.push(position)}return result}function tableColumnLength(value){if(typeof value==="number")return Number.isFinite(value)&&value>=0?`${value}px`:void 0;return value?.trim()||void 0}function getTableColumnStyle(columns,index,widths=[]){const{width,minWidth,align}=columns[index]??{};const offset=getTableOffsetColumns(columns,index)?.map(position=>widths[position]!==void 0?`${widths[position]}px`:tableColumnLength(columns[position].width??columns[position].minWidth)??"0px");return{width:tableColumnLength(width),minWidth:tableColumnLength(minWidth),textAlign:align,"--ug-table-fixed-offset":offset?offset.length?`calc(${offset.join(" + ")})`:"0px":void 0}}function projectTreeTableRows(roots,options){const rows=[];const visibleRows=[];const expandableIds=[];const known=new Set;const pending=roots.map(record=>({record,depth:0,parentId:void 0,visible:true})).reverse();while(pending.length){const entry=pending.pop();const rawId=options.getRowId(entry.record);if(rawId===void 0||rawId===null||String(rawId)==="")throw new Error("UGTreeTable \u7684\u6BCF\u6761\u8BB0\u5F55\u5FC5\u987B\u6709\u975E\u7A7A\u7A33\u5B9A\u6807\u8BC6");const id=String(rawId);if(known.has(id))throw new Error(`UGTreeTable \u7684\u8BB0\u5F55\u6807\u8BC6\u5FC5\u987B\u552F\u4E00\u4E14\u65E0\u73AF\uFF1A${id}`);known.add(id);const children=options.getChildren(entry.record)??[];const expanded=Boolean(children.length&&(options.expandedIds?.has(id)??options.defaultExpandAll));const row={id,record:entry.record,parentId:entry.parentId,depth:entry.depth,hasChildren:children.length>0,expanded};rows.push(row);if(entry.visible)visibleRows.push(row);if(children.length)expandableIds.push(id);for(let index=children.length-1;index>=0;index--)pending.push({record:children[index],depth:entry.depth+1,parentId:id,visible:entry.visible&&expanded})}return{rows,visibleRows,expandableIds}}function getTableStructure(columns,order=[]){const rank=new Map(order.map((id,index)=>[id,index]));const ids=new Set;let depth=1;const walk=(nodes,level)=>[...nodes].sort((left,right)=>(rank.get(left.id)??Infinity)-(rank.get(right.id)??Infinity)).map(column=>{if(!column.id||ids.has(column.id))throw new Error("UGDataTable \u7684\u5217 id \u5FC5\u987B\u975E\u7A7A\u4E14\u5168\u5C40\u552F\u4E00");ids.add(column.id);depth=Math.max(depth,level);return column.children?.length?{...column,children:walk(column.children,level+1)}:column});const ordered=walk(columns,1);const headers=Array.from({length:depth},()=>[]);const leaves=[];const canonicalOrder=[];const project=(nodes,level,parentId)=>{for(const column of nodes){canonicalOrder.push(column.id);const children=column.children;const leafIndex=leaves.length;if(children?.length)project(children,level+1,column.id);else leaves.push(column);headers[level-1].push({column,leafIndex,colSpan:leaves.length-leafIndex,rowSpan:children?.length?1:depth-level+1,parentId,siblingIds:nodes.map(node=>node.id)})}};project(ordered,1);return{columns:ordered,leaves,headers,order:canonicalOrder}}function moveTableColumn(columns,order,source,target,after=false){const structure=getTableStructure(columns,order);const cell=structure.headers.flat().find(item=>item.column.id===source);if(!cell||source===target||!cell.siblingIds.includes(target))return structure.order;const next=structure.order.filter(id=>id!==source);next.splice(next.indexOf(target)+(after?1:0),0,source);return getTableStructure(columns,next).order}function getTableSpanGrid(rows,columns,span){const grid=Array.from({length:rows},()=>Array.from({length:columns},()=>({rowSpan:0,colSpan:0})));const occupied=new Set;const normalize=(value,max)=>value===0?0:Number.isSafeInteger(value)&&value>0?Math.min(value,max):1;for(let row=0;row<rows;row++)for(let column=0;column<columns;column++){if(occupied.has(`${row}:${column}`))continue;const requested=span?.(row,column);let rowSpan=normalize(requested?.rowSpan,rows-row);let colSpan=normalize(requested?.colSpan,columns-column);if(!rowSpan||!colSpan)continue;let overlap=false;for(let r=row;r<row+rowSpan;r++)for(let c=column;c<column+colSpan;c++)if(occupied.has(`${r}:${c}`))overlap=true;if(overlap){rowSpan=1;colSpan=1}grid[row][column]={rowSpan,colSpan};for(let r=row;r<row+rowSpan;r++)for(let c=column;c<column+colSpan;c++)occupied.add(`${r}:${c}`)}return grid}var pad=(value,size=2)=>String(value).padStart(size,"0");function localDate(year,month=0,day=1){const date=new Date(0);date.setFullYear(year,month,day);date.setHours(0,0,0,0);return date}function isoWeekStart(date){const start=localDate(date.getFullYear(),date.getMonth(),date.getDate());start.setDate(start.getDate()-(start.getDay()+6)%7);return start}function datePickerModeKey(date,mode){if(mode==="year")return pad(date.getFullYear(),4);if(mode==="month")return`${pad(date.getFullYear(),4)}-${pad(date.getMonth()+1)}`;if(mode==="week"){const start=isoWeekStart(date);const thursday=new Date(start);thursday.setDate(start.getDate()+3);const year=thursday.getFullYear();const first=isoWeekStart(localDate(year,0,4));return`${pad(year,4)}-W${pad(Math.round((start.getTime()-first.getTime())/6048e5)+1)}`}return calendarDateKey(date)}function parseDatePickerModeKey(value,mode){if(mode==="date"||mode==="multiple")return parseCalendarDateKey(value);if(mode==="year")return/^\d{4}$/.test(value)?parseCalendarDateKey(`${value}-01-01`):null;if(mode==="month")return/^\d{4}-\d{2}$/.test(value)?parseCalendarDateKey(`${value}-01`):null;const match=/^(\d{4})-W(\d{2})$/.exec(value);if(!match||Number(match[2])<1||Number(match[2])>53)return null;const start=isoWeekStart(localDate(Number(match[1]),0,4));start.setDate(start.getDate()+(Number(match[2])-1)*7);return datePickerModeKey(start,"week")===value?start:null}function validateDatePickerModeValue(value,mode="date",policy={}){if(!value)return void 0;if(mode==="multiple"){const values=value.split(",").map(part=>part.trim());if(values.some(part=>!part))return"\u8BF7\u4F7F\u7528\u9017\u53F7\u5206\u9694\u5B8C\u6574\u65E5\u671F";for(const part of values){const error=validateDatePickerModeValue(part,"date",policy);if(error)return error}return void 0}const first=parseDatePickerModeKey(value,mode);if(!first)return`\u8BF7\u8F93\u5165\u6709\u6548${mode==="year"?"\u5E74\u4EFD\uFF0C\u683C\u5F0F\u4E3A YYYY":mode==="month"?"\u6708\u4EFD\uFF0C\u683C\u5F0F\u4E3A YYYY-MM":mode==="week"?"ISO\u5468\uFF0C\u683C\u5F0F\u4E3A YYYY-Www":"\u65E5\u671F\uFF0C\u683C\u5F0F\u4E3A YYYY-MM-DD"}`;const last=new Date(first);if(mode==="year")last.setFullYear(first.getFullYear()+1,0,0);if(mode==="month")last.setMonth(first.getMonth()+1,0);if(mode==="week")last.setDate(first.getDate()+6);const min=parseCalendarDateKey(policy.min);const max=parseCalendarDateKey(policy.max);if(min&&last<min)return`\u65E5\u671F\u4E0D\u80FD\u65E9\u4E8E ${policy.min}`;if(max&&first>max)return`\u65E5\u671F\u4E0D\u80FD\u665A\u4E8E ${policy.max}`;if(policy.disabledDate){const cursor=new Date(min&&first<min?min:first);while(cursor<=last&&(!max||cursor<=max)){if(!policy.disabledDate(new Date(cursor)))return void 0;cursor.setDate(cursor.getDate()+1)}return"\u8BE5\u65E5\u671F\u533A\u95F4\u4E0D\u53EF\u9009\u62E9"}return void 0}function validateDateTimeRangeValue(value,policy={}){if(!value[0]&&!value[1])return void 0;if(!value[0]||!value[1])return"\u8BF7\u586B\u5199\u5B8C\u6574\u7684\u5F00\u59CB\u548C\u7ED3\u675F\u65E5\u671F\u65F6\u95F4";return validateDateTimeValue(value[0],policy)??validateDateTimeValue(value[1],policy)??(value[0]>value[1]?"\u7ED3\u675F\u65E5\u671F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65E5\u671F\u65F6\u95F4":void 0)}function validateDateRangeShortcut(value,policy={}){if(!value[0]||!value[1])return"\u5FEB\u6377\u8303\u56F4\u5FC5\u987B\u5305\u542B\u4E24\u4E2A\u5B8C\u6574\u65E5\u671F";return validateDatePickerModeValue(value[0],"date",policy)??validateDatePickerModeValue(value[1],"date",policy)??(value[0]>value[1]?"\u7ED3\u675F\u65E5\u671F\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65E5\u671F":void 0)}function canDropTreeNode(items,source,target){let drag;let exists=false;const walk=nodes=>{for(const node of nodes){if(node.key===source)drag=node;if(node.key===target)exists=true;if(node.children)walk(node.children)}};walk(items);const contains=node=>node.key===target||Boolean(node.children?.some(contains));return Boolean(drag&&exists&&!contains(drag))}function isFormPathWithin(field,parent){const name=normalizeFormPath(field),root=normalizeFormPath(parent);return name===root||name.startsWith(`${root}.`)}function normalizeFormPath(path){if(/\[\d+\](?=[^.\[])/.test(path))throw new Error("UGForm \u5B57\u6BB5\u8DEF\u5F84\u65E0\u6548");const normalized=path.replace(/\[(\d+)\]/g,".$1");const parts=normalized.split(".");if(parts.some(part=>!part||/[\[\]]/.test(part)||["__proto__","prototype","constructor"].includes(part))){throw new Error("UGForm \u5B57\u6BB5\u8DEF\u5F84\u65E0\u6548")}return normalized}function getFormPath(values,path){let current=values;for(const key of normalizeFormPath(path).split(".")){if(!current||typeof current!=="object"||!Object.hasOwn(current,key))return void 0;current=current[key]}return current}function isFormPathActive(values,path){let current=values;for(const key of normalizeFormPath(path).split(".")){if(Array.isArray(current)&&/^\d+$/.test(key)&&Number(key)>=current.length)return false;current=current&&typeof current==="object"&&Object.hasOwn(current,key)?current[key]:void 0}return true}function setFormPath(values,path,value){const keys=normalizeFormPath(path).split(".");const write=(current,index)=>{const key=keys[index];const copy=Array.isArray(current)?[...current]:current&&typeof current==="object"?{...current}:/^\d+$/.test(key)?[]:{};const record=copy;record[key]=index===keys.length-1?value:write(record[key],index+1);return copy};return write(values,0)}function getFormPaths(values,prefix=""){if(!values||typeof values!=="object"||values instanceof Date)return prefix?[prefix]:[];const entries=Object.entries(values);if(!entries.length)return prefix?[prefix]:[];return entries.flatMap(([key,value])=>{const path=prefix?`${prefix}.${key}`:key;return[path,...value&&typeof value==="object"&&!(value instanceof Date)?getFormPaths(value,path).filter(item=>item!==path):[]]})}function isFormValueEqual(left,right){if(Object.is(left,right))return true;if(left instanceof Date&&right instanceof Date)return left.getTime()===right.getTime();if(!left||!right||typeof left!=="object"||typeof right!=="object"||Array.isArray(left)!==Array.isArray(right))return false;if(!Array.isArray(left)&&![Object.prototype,null].includes(Object.getPrototypeOf(left)))return false;if(!Array.isArray(right)&&![Object.prototype,null].includes(Object.getPrototypeOf(right)))return false;const keys=Object.keys(left);return keys.length===Object.keys(right).length&&keys.every(key=>Object.hasOwn(right,key)&&isFormValueEqual(left[key],right[key]))}function createFormFieldArray(path,read,write){const name=normalizeFormPath(path);let sequence=0;let ids=[];const nextId=()=>`${name}-${++sequence}`;function values(){const current=read();if(current!==void 0&&!Array.isArray(current))throw new Error("UGForm fieldArray \u53EA\u80FD\u7ED1\u5B9A\u6570\u7EC4\u5B57\u6BB5");const result=current??[];ids=result.map((_,index)=>ids[index]??nextId());return result}const validIndex=(index,length)=>Number.isInteger(index)&&index>=0&&index<length;const controller={get fields(){return values().map((value,index)=>({id:ids[index],index,name:`${name}.${index}`,value}))},append(value){controller.insert(values().length,value)},insert(index,value){const current=values();if(!Number.isInteger(index)||index<0||index>current.length)return;const next=[...current];next.splice(index,0,value);ids.splice(index,0,nextId());write(next)},remove(index){const current=values();if(!validIndex(index,current.length))return;const next=[...current];next.splice(index,1);ids.splice(index,1);write(next)},move(from,to){const current=values();if(!validIndex(from,current.length)||!validIndex(to,current.length)||from===to)return;const next=[...current];next.splice(to,0,next.splice(from,1)[0]);ids.splice(to,0,ids.splice(from,1)[0]);write(next)},replace(next){ids=next.map(nextId);write([...next])}};return{controller,resetIds(){ids=[]}}}0&&(module.exports={addCalendarDays,addCalendarMonths,applyUGThemeProfile,buildCalendarMonth,buildCalendarWeekdays,buildTimeSelectOptions,calendarDateKey,canDropTreeNode,compareCalendarDates,countTextCharacters,createFormFieldArray,createUGThemeValue,datePickerModeKey,defaultUGNavigationColors,defaultUGTheme,defaultUGThemeConfiguratorOptions,defaultUGThemeNavigationColors,defaultUGThemeProfiles,encodeSelectValue,filterSelectionListOptions,findTreeNodePath,formatCalendarDay,formatCalendarMonth,formatColorHex,formatTimeValue,getAvailableTimeValues,getCalendarRangePosition,getFormPath,getFormPaths,getImagePreviewLayout,getRatingKeyboardValue,getSelectionListScope,getTableColumnFixed,getTableColumnStyle,getTableOffsetColumns,getTableSpanGrid,getTableStructure,getTimeColumnChoices,getTreeCheckState,groupSelectionListOptions,isEmptyFormValue,isFormPathActive,isFormPathWithin,isFormValueEqual,isSameCalendarDay,isUGThemeProfileModified,isValidCalendarDate,isoWeekStart,limitTextByCount,localDateTimeKey,moveTableColumn,normalizeCalendarDate,normalizeFormPath,normalizeRatingMax,normalizeRatingValue,normalizeSelectKeys,parseCalendarDateKey,parseCalendarRange,parseColorHex,parseDatePickerModeKey,parseLocalDateTimeValue,parseTimeValue,projectTreeTableRows,resolveTableFixedColumns,resolveUGNavigationColors,resolveUGNavigationPalette,setFormPath,startOfCalendarMonth,tableColumnLength,toggleTreeCheckedKey,ugThemeProfileFields,updateSelectionListScope,validateDatePickerModeValue,validateDateRangeShortcut,validateDateTimeRangeValue,validateDateTimeValue,validateDateValue,validateFormValue,validateTimeRangeValue,validateTimeValue});
|
|
1240
3
|
//# sourceMappingURL=index.cjs.map
|