@canvas-components/react-components 0.3.27 → 0.3.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -65
- package/dist/index.cjs +1104 -976
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +1104 -977
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var ReactDOM = require('react-dom');
|
|
6
5
|
var icons = require('@canvas-components/icons');
|
|
6
|
+
var ReactDOM = require('react-dom');
|
|
7
7
|
|
|
8
8
|
function _interopNamespace(e) {
|
|
9
9
|
if (e && e.__esModule) return e;
|
|
@@ -195,953 +195,118 @@ function joinClassNames(...values) {
|
|
|
195
195
|
|
|
196
196
|
// src/shared/prefix.ts
|
|
197
197
|
var REACT_COMPONENT_PREFIX = "canvas-react";
|
|
198
|
+
var REACT_ICON_DEFINITIONS = icons.iconDefinitions;
|
|
198
199
|
|
|
199
|
-
// src/components/
|
|
200
|
-
styleInject(".canvas-react-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
200
|
+
// src/components/icon/style.css
|
|
201
|
+
styleInject(".canvas-react-icon {\n display: inline-block;\n vertical-align: -0.125em;\n color: inherit;\n}\n.canvas-react-icon-spin {\n animation: canvas-react-icon-spin 1s infinite linear;\n}\n@keyframes canvas-react-icon-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .canvas-react-icon-spin {\n animation-duration: 2s;\n }\n}\n");
|
|
202
|
+
var PRIMARY_COLOR_TOKEN = "__CC_REACT_ICON_PRIMARY__";
|
|
203
|
+
var SECONDARY_COLOR_TOKEN = "__CC_REACT_ICON_SECONDARY__";
|
|
204
|
+
var ReactIcon = React.forwardRef(
|
|
205
|
+
function ReactIcon2({
|
|
206
|
+
"aria-hidden": ariaHidden,
|
|
207
|
+
"aria-label": ariaLabel,
|
|
208
|
+
className,
|
|
209
|
+
color,
|
|
210
|
+
name,
|
|
211
|
+
rotate,
|
|
212
|
+
size = "1em",
|
|
213
|
+
spin = false,
|
|
214
|
+
style,
|
|
215
|
+
twoToneColor,
|
|
216
|
+
...svgProps
|
|
217
|
+
}, ref) {
|
|
218
|
+
const icon = REACT_ICON_DEFINITIONS[name];
|
|
219
|
+
const [primaryColor, secondaryColor] = resolveTwoToneColors(twoToneColor);
|
|
220
|
+
const svgStyle = {
|
|
221
|
+
color,
|
|
222
|
+
width: size,
|
|
223
|
+
height: size,
|
|
224
|
+
transform: rotate == null ? void 0 : `rotate(${rotate}deg)`,
|
|
225
|
+
...style
|
|
226
|
+
};
|
|
227
|
+
const classes = [
|
|
228
|
+
"canvas-react-icon",
|
|
229
|
+
spin ? "canvas-react-icon-spin" : void 0,
|
|
230
|
+
className
|
|
231
|
+
].filter(Boolean).join(" ");
|
|
232
|
+
return React.createElement(
|
|
233
|
+
"svg",
|
|
234
|
+
{
|
|
235
|
+
...svgProps,
|
|
236
|
+
ref,
|
|
237
|
+
className: classes,
|
|
238
|
+
viewBox: icon.icon.attrs.viewBox,
|
|
239
|
+
width: size,
|
|
240
|
+
height: size,
|
|
241
|
+
fill: "currentColor",
|
|
242
|
+
style: svgStyle,
|
|
243
|
+
role: ariaLabel ? "img" : svgProps.role,
|
|
244
|
+
"aria-label": ariaLabel,
|
|
245
|
+
"aria-hidden": ariaHidden ?? !ariaLabel,
|
|
246
|
+
focusable: "false",
|
|
247
|
+
"data-icon": icon.name
|
|
248
|
+
},
|
|
249
|
+
...renderIconChildren(icon.icon, primaryColor, secondaryColor)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
ReactIcon.displayName = "ReactIcon";
|
|
254
|
+
function createReactIconComponent(name) {
|
|
255
|
+
const IconComponent = React.forwardRef(
|
|
256
|
+
function NamedReactIcon(props, ref) {
|
|
257
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactIcon, { ...props, name, ref });
|
|
227
258
|
}
|
|
228
259
|
);
|
|
260
|
+
IconComponent.displayName = `React${name}`;
|
|
261
|
+
return IconComponent;
|
|
229
262
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
fontFamily: style?.fontFamily,
|
|
234
|
-
fontSize: style?.fontSize,
|
|
235
|
-
fontWeight: style?.fontWeight,
|
|
236
|
-
fontStyle: style?.fontStyle,
|
|
237
|
-
color: style?.color
|
|
238
|
-
});
|
|
239
|
-
function normalizeStyle(input) {
|
|
240
|
-
if (!input) return void 0;
|
|
241
|
-
const style = {};
|
|
242
|
-
if (typeof input.fontFamily === "string" && /^[\p{L}\p{N}_\s,'"-]+$/u.test(input.fontFamily))
|
|
243
|
-
style.fontFamily = input.fontFamily;
|
|
244
|
-
if (typeof input.fontSize === "number" && Number.isFinite(input.fontSize) && input.fontSize >= 1 && input.fontSize <= 240)
|
|
245
|
-
style.fontSize = input.fontSize;
|
|
246
|
-
if (typeof input.fontWeight === "string" && /^(?:[1-9]00|normal|bold)$/.test(input.fontWeight))
|
|
247
|
-
style.fontWeight = input.fontWeight;
|
|
248
|
-
if (input.fontStyle === "normal" || input.fontStyle === "italic")
|
|
249
|
-
style.fontStyle = input.fontStyle;
|
|
250
|
-
if (typeof input.color === "string" && /^#[0-9a-fA-F]{3,8}$/.test(input.color))
|
|
251
|
-
style.color = input.color;
|
|
252
|
-
return Object.keys(style).length ? style : void 0;
|
|
253
|
-
}
|
|
254
|
-
function alignRange(text, start, end) {
|
|
255
|
-
const Segmenter = Intl.Segmenter;
|
|
256
|
-
const boundaries = Segmenter ? [
|
|
257
|
-
0,
|
|
258
|
-
...Array.from(
|
|
259
|
-
new Segmenter(void 0, { granularity: "grapheme" }).segment(text),
|
|
260
|
-
(part) => part.index + part.segment.length
|
|
261
|
-
)
|
|
262
|
-
] : [
|
|
263
|
-
0,
|
|
264
|
-
...Array.from(text).reduce((offsets, character) => {
|
|
265
|
-
offsets.push((offsets[offsets.length - 1] ?? 0) + character.length);
|
|
266
|
-
return offsets;
|
|
267
|
-
}, [])
|
|
268
|
-
];
|
|
269
|
-
const clampedStart = Math.max(0, Math.min(start, text.length));
|
|
270
|
-
const clampedEnd = Math.max(clampedStart, Math.min(end, text.length));
|
|
271
|
-
const from = [...boundaries].reverse().find((boundary) => boundary <= clampedStart) ?? 0;
|
|
272
|
-
const to = clampedStart === clampedEnd ? from : boundaries.find((boundary) => boundary >= clampedEnd) ?? text.length;
|
|
273
|
-
return { from, to };
|
|
274
|
-
}
|
|
275
|
-
function normalizeRichTextRuns(runs) {
|
|
276
|
-
const normalized = [];
|
|
277
|
-
for (const run of runs) {
|
|
278
|
-
if (!run.text) continue;
|
|
279
|
-
const style = normalizeStyle(run.style);
|
|
280
|
-
const previous = normalized[normalized.length - 1];
|
|
281
|
-
if (previous && styleKey(previous.style) === styleKey(style))
|
|
282
|
-
previous.text += run.text;
|
|
283
|
-
else normalized.push({ text: run.text, ...style ? { style } : {} });
|
|
263
|
+
function resolveTwoToneColors(twoToneColor) {
|
|
264
|
+
if (Array.isArray(twoToneColor)) {
|
|
265
|
+
return [twoToneColor[0], twoToneColor[1]];
|
|
284
266
|
}
|
|
285
|
-
|
|
267
|
+
const primaryColor = twoToneColor ?? "#1677ff";
|
|
268
|
+
return [
|
|
269
|
+
primaryColor,
|
|
270
|
+
twoToneColor ? lightenColor(twoToneColor) : "#e6f4ff"
|
|
271
|
+
];
|
|
286
272
|
}
|
|
287
|
-
function
|
|
288
|
-
|
|
273
|
+
function lightenColor(color) {
|
|
274
|
+
const match = color.match(/^#([\da-f]{3}|[\da-f]{6})$/i);
|
|
275
|
+
if (!match) return "#e6e6e6";
|
|
276
|
+
const raw = match[1];
|
|
277
|
+
const normalized = raw.length === 3 ? raw.split("").map((digit) => digit + digit).join("") : raw;
|
|
278
|
+
const channels = normalized.match(/[\da-f]{2}/gi).map((channel) => Number.parseInt(channel, 16));
|
|
279
|
+
return `#${channels.map((channel) => Math.round(channel + (255 - channel) * 0.9)).map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
|
289
280
|
}
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const runStart = offset;
|
|
297
|
-
const runEnd = offset + run.text.length;
|
|
298
|
-
offset = runEnd;
|
|
299
|
-
if (runEnd <= start || runStart >= end) {
|
|
300
|
-
result.push(run);
|
|
301
|
-
continue;
|
|
281
|
+
function renderIconChildren(node, primaryColor, secondaryColor) {
|
|
282
|
+
return (node.children ?? []).map((child, index) => {
|
|
283
|
+
const props = {};
|
|
284
|
+
for (const [key, rawValue] of Object.entries(child.attrs)) {
|
|
285
|
+
const value = rawValue.split(PRIMARY_COLOR_TOKEN).join(primaryColor).split(SECONDARY_COLOR_TOKEN).join(secondaryColor);
|
|
286
|
+
props[normalizeSvgAttribute(key)] = value;
|
|
302
287
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
style: { ...run.style, ...patch }
|
|
310
|
-
});
|
|
311
|
-
if (localEnd < run.text.length)
|
|
312
|
-
result.push({ ...run, text: run.text.slice(localEnd) });
|
|
313
|
-
}
|
|
314
|
-
return normalizeRichTextRuns(result);
|
|
288
|
+
return React.createElement(
|
|
289
|
+
child.tag,
|
|
290
|
+
{ ...props, key: `${child.tag}-${index}` },
|
|
291
|
+
...renderIconChildren(child, primaryColor, secondaryColor)
|
|
292
|
+
);
|
|
293
|
+
});
|
|
315
294
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
);
|
|
332
|
-
if (before) {
|
|
333
|
-
result.push({ ...run, text: before });
|
|
334
|
-
inherited = run.style;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
if (runEnd > to) {
|
|
338
|
-
const after = run.text.slice(Math.max(0, to - runStart));
|
|
339
|
-
if (after) {
|
|
340
|
-
following ?? (following = run.style);
|
|
341
|
-
result.push({ ...run, text: after });
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (text) {
|
|
346
|
-
let length = 0;
|
|
347
|
-
const insertionIndex = result.findIndex((run) => {
|
|
348
|
-
length += run.text.length;
|
|
349
|
-
return length > from;
|
|
350
|
-
});
|
|
351
|
-
result.splice(insertionIndex < 0 ? result.length : insertionIndex, 0, {
|
|
352
|
-
text,
|
|
353
|
-
...inherited ?? following ? { style: inherited ?? following } : {}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
return normalizeRichTextRuns(result);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// src/components/compat/style.css
|
|
360
|
-
styleInject(".canvas-react-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n min-height: 32px;\n padding: 4px 14px;\n border: 1px solid var(--cc-border-color, #d9d9d9);\n border-radius: 6px;\n color: var(--cc-text-color, #1f2937);\n background: var(--cc-surface-color, #fff);\n cursor: pointer;\n}\n.canvas-react-button:hover:not(:disabled) {\n color: #1677ff;\n border-color: #1677ff;\n}\n.canvas-react-button:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n.canvas-react-button-primary {\n color: #fff;\n border-color: #1677ff;\n background: #1677ff;\n}\n.canvas-react-button-primary:hover:not(:disabled) {\n color: #fff;\n border-color: #4096ff;\n background: #4096ff;\n}\n.canvas-react-button-danger {\n color: #dc2626;\n border-color: #fca5a5;\n}\n.canvas-react-button-small {\n min-height: 24px;\n padding: 2px 8px;\n}\n.canvas-react-button-large {\n min-height: 40px;\n padding: 6px 18px;\n}\n.canvas-react-button-icon {\n display: inline-flex;\n}\n.canvas-react-row {\n display: flex;\n flex-flow: row wrap;\n}\n.canvas-react-col {\n min-width: 0;\n padding-inline: 8px;\n}\n.canvas-react-radio-group {\n display: flex;\n gap: 16px;\n}\n.canvas-react-radio {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n cursor: pointer;\n}\n.canvas-react-radio input {\n position: absolute;\n opacity: 0;\n pointer-events: none;\n}\n.canvas-react-radio-mark {\n width: 14px;\n height: 14px;\n border: 1px solid #94a3b8;\n border-radius: 50%;\n box-sizing: border-box;\n}\n.canvas-react-radio input:checked + .canvas-react-radio-mark {\n border: 4px solid #1677ff;\n}\n.canvas-react-form-item {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin-bottom: 16px;\n}\n.canvas-react-form-label {\n color: #334155;\n font-size: 14px;\n}\n.canvas-react-form-error {\n color: #dc2626;\n font-size: 12px;\n}\n.canvas-react-textarea {\n width: 100%;\n min-height: 72px;\n padding: 8px 10px;\n border: 1px solid var(--canvas-react-color-border);\n border-radius: 6px;\n box-sizing: border-box;\n background: var(--canvas-react-color-bg);\n color: var(--canvas-react-color-text);\n font: inherit;\n resize: vertical;\n}\n.canvas-react-textarea:hover:not(:disabled) {\n border-color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-textarea:focus {\n border-color: var(--canvas-react-color-primary);\n box-shadow: var(--canvas-react-shadow-focus);\n outline: none;\n}\n.canvas-react-textarea::placeholder {\n color: var(--canvas-react-color-text-muted);\n}\n.canvas-react-textarea:disabled {\n background: var(--canvas-react-color-bg-soft, #fafafa);\n color: var(--canvas-react-color-text-muted);\n cursor: not-allowed;\n}\n");
|
|
361
|
-
|
|
362
|
-
// src/components/form/style.css
|
|
363
|
-
styleInject(".canvas-react-form {\n min-width: 0;\n}\n.canvas-react-form-vertical {\n display: grid;\n gap: 16px;\n}\n.canvas-react-form-horizontal {\n display: grid;\n gap: 12px;\n}\n.canvas-react-form-inline {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: 12px 16px;\n}\n.canvas-react-form-item {\n box-sizing: border-box;\n min-width: 0;\n}\n.canvas-react-form-item-vertical {\n display: grid;\n gap: 6px;\n}\n.canvas-react-form-item-horizontal {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr);\n align-items: center;\n column-gap: 10px;\n row-gap: 4px;\n}\n.canvas-react-form-item-inline {\n display: inline-grid;\n grid-template-columns: auto minmax(0, 1fr);\n align-items: center;\n column-gap: 8px;\n}\n.canvas-react-form-item-no-wrap {\n flex-wrap: nowrap;\n}\n.canvas-react-form-item-horizontal.canvas-react-form-item-no-wrap {\n display: grid;\n grid-template-columns: max-content minmax(0, 1fr);\n}\n.canvas-react-form-horizontal > .canvas-react-form-item {\n margin-bottom: var(--canvas-react-form-item-spacing, 16px);\n}\n.canvas-react-form-item-inline.canvas-react-form-item-no-wrap {\n display: inline-grid;\n grid-template-columns: max-content minmax(0, 1fr);\n}\n.canvas-react-form-item-no-wrap > .canvas-react-form-label {\n white-space: nowrap;\n}\n.canvas-react-form-label {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n min-width: 0;\n color: #475569;\n font-size: var(--canvas-react-font-size-label);\n line-height: 1.4;\n}\n.canvas-react-form-horizontal > .canvas-react-form-item > .canvas-react-form-label {\n min-height: 32px;\n}\n.canvas-react-form-required {\n color: #dc2626;\n}\n.canvas-react-form-control {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n.canvas-react-form-error {\n color: #dc2626;\n font-size: var(--canvas-react-font-size-secondary);\n}\n.canvas-react-form-help,\n.canvas-react-form-extra {\n color: #64748b;\n font-size: var(--canvas-react-font-size-secondary);\n}\n.canvas-react-form-item-error .canvas-react-form-control > input,\n.canvas-react-form-item-error .canvas-react-form-control > textarea {\n border-color: #dc2626;\n}\n");
|
|
364
|
-
function createFormInstance() {
|
|
365
|
-
const store = {
|
|
366
|
-
values: {},
|
|
367
|
-
initialValues: {},
|
|
368
|
-
errors: {},
|
|
369
|
-
rules: /* @__PURE__ */ new Map(),
|
|
370
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
371
|
-
revision: 0,
|
|
372
|
-
notify() {
|
|
373
|
-
store.revision += 1;
|
|
374
|
-
store.listeners.forEach((listener) => listener());
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
return {
|
|
378
|
-
__store: store,
|
|
379
|
-
getFieldValue: (name) => store.values[name],
|
|
380
|
-
setFieldsValue(values) {
|
|
381
|
-
store.values = { ...store.values, ...values };
|
|
382
|
-
Object.keys(values).forEach((name) => {
|
|
383
|
-
delete store.errors[name];
|
|
384
|
-
});
|
|
385
|
-
store.notify();
|
|
386
|
-
},
|
|
387
|
-
resetFields() {
|
|
388
|
-
store.values = { ...store.initialValues };
|
|
389
|
-
store.errors = {};
|
|
390
|
-
store.notify();
|
|
391
|
-
},
|
|
392
|
-
async validateFields() {
|
|
393
|
-
const errors = {};
|
|
394
|
-
for (const [name, rules] of store.rules) {
|
|
395
|
-
const value = store.values[name];
|
|
396
|
-
for (const rawRule of rules) {
|
|
397
|
-
const rule = typeof rawRule === "function" ? rawRule({ getFieldValue: (field) => store.values[field] }) : rawRule;
|
|
398
|
-
if (rule.required && (value === void 0 || value === null || value === "")) {
|
|
399
|
-
errors[name] = rule.message ?? "\u6B64\u9879\u4E3A\u5FC5\u586B\u9879";
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
if ((rule.type === "number" || rule.type === "integer") && typeof value === "number" && rule.min !== void 0 && value < rule.min) {
|
|
403
|
-
errors[name] = rule.message ?? `\u4E0D\u80FD\u5C0F\u4E8E ${rule.min}`;
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
if ((rule.type === "number" || rule.type === "integer") && typeof value === "number" && rule.max !== void 0 && value > rule.max) {
|
|
407
|
-
errors[name] = rule.message ?? `\u4E0D\u80FD\u5927\u4E8E ${rule.max}`;
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
if (rule.type === "integer" && typeof value === "number" && !Number.isInteger(value)) {
|
|
411
|
-
errors[name] = rule.message ?? "\u8BF7\u8F93\u5165\u6574\u6570";
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
if (rule.validator) {
|
|
415
|
-
try {
|
|
416
|
-
await rule.validator(rule, value);
|
|
417
|
-
} catch (error) {
|
|
418
|
-
errors[name] = error instanceof Error ? error.message : "\u6821\u9A8C\u5931\u8D25";
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
store.errors = errors;
|
|
425
|
-
store.notify();
|
|
426
|
-
if (Object.keys(errors).length > 0) {
|
|
427
|
-
return Promise.reject({
|
|
428
|
-
errorFields: errors,
|
|
429
|
-
values: { ...store.values }
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
return { ...store.values };
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
function useReactForm() {
|
|
437
|
-
const formRef = React.useRef(null);
|
|
438
|
-
if (!formRef.current) formRef.current = createFormInstance();
|
|
439
|
-
return [formRef.current];
|
|
440
|
-
}
|
|
441
|
-
function useReactFormWatch(name, form) {
|
|
442
|
-
React.useSyncExternalStore(
|
|
443
|
-
(listener) => {
|
|
444
|
-
form.__store.listeners.add(listener);
|
|
445
|
-
return () => form.__store.listeners.delete(listener);
|
|
446
|
-
},
|
|
447
|
-
() => form.__store.revision,
|
|
448
|
-
() => 0
|
|
449
|
-
);
|
|
450
|
-
return form.getFieldValue(name);
|
|
451
|
-
}
|
|
452
|
-
var FormContext = React.createContext(null);
|
|
453
|
-
var emptySubscribe = () => () => {
|
|
454
|
-
};
|
|
455
|
-
var emptySnapshot = () => 0;
|
|
456
|
-
function ReactFormRoot({
|
|
457
|
-
form: formProp,
|
|
458
|
-
initialValues,
|
|
459
|
-
layout = "vertical",
|
|
460
|
-
noWrap = false,
|
|
461
|
-
itemSpacing,
|
|
462
|
-
labelWidth,
|
|
463
|
-
labelAlign = "right",
|
|
464
|
-
colon = false,
|
|
465
|
-
requiredMark = true,
|
|
466
|
-
className,
|
|
467
|
-
children,
|
|
468
|
-
...props
|
|
469
|
-
}) {
|
|
470
|
-
const internalForm = React.useRef(null);
|
|
471
|
-
if (!internalForm.current) internalForm.current = createFormInstance();
|
|
472
|
-
const form = formProp ?? internalForm.current;
|
|
473
|
-
const initialKey = React.useMemo(
|
|
474
|
-
() => JSON.stringify(initialValues ?? {}),
|
|
475
|
-
[initialValues]
|
|
476
|
-
);
|
|
477
|
-
React.useEffect(() => {
|
|
478
|
-
form.__store.initialValues = { ...initialValues };
|
|
479
|
-
form.__store.values = { ...initialValues, ...form.__store.values };
|
|
480
|
-
form.__store.notify();
|
|
481
|
-
}, [form, initialKey]);
|
|
482
|
-
const contextValue = React.useMemo(
|
|
483
|
-
() => ({
|
|
484
|
-
form,
|
|
485
|
-
layout,
|
|
486
|
-
noWrap,
|
|
487
|
-
labelWidth,
|
|
488
|
-
labelAlign,
|
|
489
|
-
colon,
|
|
490
|
-
requiredMark
|
|
491
|
-
}),
|
|
492
|
-
[colon, form, labelAlign, labelWidth, layout, noWrap, requiredMark]
|
|
493
|
-
);
|
|
494
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FormContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
495
|
-
"form",
|
|
496
|
-
{
|
|
497
|
-
...props,
|
|
498
|
-
style: itemSpacing === void 0 ? props.style : {
|
|
499
|
-
...props.style,
|
|
500
|
-
"--canvas-react-form-item-spacing": itemSpacing
|
|
501
|
-
},
|
|
502
|
-
className: joinClassNames(
|
|
503
|
-
`${REACT_COMPONENT_PREFIX}-form`,
|
|
504
|
-
`${REACT_COMPONENT_PREFIX}-form-${layout}`,
|
|
505
|
-
className
|
|
506
|
-
),
|
|
507
|
-
onSubmit: (event) => event.preventDefault(),
|
|
508
|
-
children
|
|
509
|
-
}
|
|
510
|
-
) });
|
|
511
|
-
}
|
|
512
|
-
function ReactFormItem({
|
|
513
|
-
label,
|
|
514
|
-
name,
|
|
515
|
-
children,
|
|
516
|
-
rules = [],
|
|
517
|
-
initialValue,
|
|
518
|
-
required,
|
|
519
|
-
colon,
|
|
520
|
-
labelWidth,
|
|
521
|
-
labelAlign,
|
|
522
|
-
labelStyle,
|
|
523
|
-
controlStyle,
|
|
524
|
-
help,
|
|
525
|
-
extra,
|
|
526
|
-
className,
|
|
527
|
-
style,
|
|
528
|
-
noWrap
|
|
529
|
-
}) {
|
|
530
|
-
const context = React.useContext(FormContext);
|
|
531
|
-
const form = context?.form ?? null;
|
|
532
|
-
if (name && !form) throw new Error("ReactForm.Item \u5FC5\u987B\u5728 ReactForm \u5185\u4F7F\u7528");
|
|
533
|
-
React.useSyncExternalStore(
|
|
534
|
-
form ? (listener) => {
|
|
535
|
-
form.__store.listeners.add(listener);
|
|
536
|
-
return () => form.__store.listeners.delete(listener);
|
|
537
|
-
} : emptySubscribe,
|
|
538
|
-
form ? () => form.__store.revision : emptySnapshot,
|
|
539
|
-
emptySnapshot
|
|
540
|
-
);
|
|
541
|
-
React.useEffect(() => {
|
|
542
|
-
if (!form || !name) return;
|
|
543
|
-
form.__store.rules.set(name, rules);
|
|
544
|
-
if (form.getFieldValue(name) === void 0 && initialValue !== void 0) {
|
|
545
|
-
form.setFieldsValue({ [name]: initialValue });
|
|
546
|
-
}
|
|
547
|
-
return () => {
|
|
548
|
-
form.__store.rules.delete(name);
|
|
549
|
-
};
|
|
550
|
-
}, [form, initialValue, name, rules]);
|
|
551
|
-
const childProps = React.isValidElement(children) ? children.props : {};
|
|
552
|
-
const value = form && name ? form.getFieldValue(name) : void 0;
|
|
553
|
-
const child = form && name && React.isValidElement(children) ? React.cloneElement(children, {
|
|
554
|
-
value: value ?? "",
|
|
555
|
-
onChange: (...args) => {
|
|
556
|
-
const first = args[0];
|
|
557
|
-
const nextValue = typeof first === "object" && first !== null && "target" in first ? first.target?.value : first;
|
|
558
|
-
form.setFieldsValue({ [name]: nextValue });
|
|
559
|
-
const childOnChange = childProps.onChange;
|
|
560
|
-
if (typeof childOnChange === "function") childOnChange(...args);
|
|
561
|
-
}
|
|
562
|
-
}) : children;
|
|
563
|
-
const error = form && name ? form.__store.errors[name] : void 0;
|
|
564
|
-
const isRequired = required ?? rules.some((rule) => typeof rule !== "function" && rule.required === true);
|
|
565
|
-
const resolvedLabelWidth = labelWidth ?? context?.labelWidth;
|
|
566
|
-
const resolvedLabelAlign = labelAlign ?? context?.labelAlign ?? "right";
|
|
567
|
-
const showColon = colon ?? context?.colon ?? false;
|
|
568
|
-
const shouldMarkRequired = context?.requiredMark ?? true;
|
|
569
|
-
const resolvedLayout = context?.layout ?? "vertical";
|
|
570
|
-
const resolvedNoWrap = noWrap ?? context?.noWrap ?? false;
|
|
571
|
-
const labelElementId = typeof childProps.id === "string" ? childProps.id : void 0;
|
|
572
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
573
|
-
"div",
|
|
574
|
-
{
|
|
575
|
-
className: joinClassNames(
|
|
576
|
-
`${REACT_COMPONENT_PREFIX}-form-item`,
|
|
577
|
-
`${REACT_COMPONENT_PREFIX}-form-item-${resolvedLayout}`,
|
|
578
|
-
resolvedNoWrap && `${REACT_COMPONENT_PREFIX}-form-item-no-wrap`,
|
|
579
|
-
className,
|
|
580
|
-
error && `${REACT_COMPONENT_PREFIX}-form-item-error`
|
|
581
|
-
),
|
|
582
|
-
style,
|
|
583
|
-
children: [
|
|
584
|
-
label ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
585
|
-
"label",
|
|
586
|
-
{
|
|
587
|
-
className: `${REACT_COMPONENT_PREFIX}-form-label`,
|
|
588
|
-
htmlFor: labelElementId,
|
|
589
|
-
style: {
|
|
590
|
-
width: resolvedLabelWidth,
|
|
591
|
-
flexBasis: resolvedLabelWidth,
|
|
592
|
-
textAlign: resolvedLabelAlign,
|
|
593
|
-
...labelStyle
|
|
594
|
-
},
|
|
595
|
-
children: [
|
|
596
|
-
shouldMarkRequired && isRequired ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
597
|
-
"span",
|
|
598
|
-
{
|
|
599
|
-
"aria-hidden": "true",
|
|
600
|
-
className: `${REACT_COMPONENT_PREFIX}-form-required`,
|
|
601
|
-
children: "*"
|
|
602
|
-
}
|
|
603
|
-
) : null,
|
|
604
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
605
|
-
showColon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: ":" }) : null
|
|
606
|
-
]
|
|
607
|
-
}
|
|
608
|
-
) : null,
|
|
609
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
610
|
-
"div",
|
|
611
|
-
{
|
|
612
|
-
className: `${REACT_COMPONENT_PREFIX}-form-control`,
|
|
613
|
-
style: controlStyle,
|
|
614
|
-
children: [
|
|
615
|
-
child,
|
|
616
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-form-error`, children: error }) : help ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-form-help`, children: help }) : null,
|
|
617
|
-
extra ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-form-extra`, children: extra }) : null
|
|
618
|
-
]
|
|
619
|
-
}
|
|
620
|
-
)
|
|
621
|
-
]
|
|
622
|
-
}
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
var ReactForm = Object.assign(ReactFormRoot, {
|
|
626
|
-
Item: ReactFormItem,
|
|
627
|
-
useForm: useReactForm,
|
|
628
|
-
useWatch: useReactFormWatch
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
// src/components/message/style.css
|
|
632
|
-
styleInject('@import "../../styles/variables.css";\n.canvas-react-message-host {\n position: fixed;\n z-index: 3000;\n inset-inline: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n padding-inline: 16px;\n pointer-events: none;\n font-size: var(--canvas-react-font-size, 14px);\n}\n.canvas-react-message {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n max-width: min(100%, 640px);\n max-height: 240px;\n padding: 9px 12px;\n border-radius: var(--canvas-react-radius-md, 8px);\n background: var(--canvas-react-color-bg, #fff);\n color: var(--canvas-react-color-text, rgba(0, 0, 0, 0.88));\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12);\n line-height: 1.5;\n pointer-events: auto;\n animation: canvas-react-message-enter 0.2s ease-out both;\n}\n.canvas-react-message-leaving {\n overflow: hidden;\n pointer-events: none;\n animation: canvas-react-message-leave 0.3s ease-in forwards;\n}\n.canvas-react-message-icon {\n display: inline-flex;\n flex: none;\n width: 16px;\n height: 16px;\n}\n.canvas-react-message-icon svg {\n width: 16px;\n height: 16px;\n}\n.canvas-react-message-info,\n.canvas-react-message-loading {\n --canvas-react-message-color: #1677ff;\n}\n.canvas-react-message-success {\n --canvas-react-message-color: #52c41a;\n}\n.canvas-react-message-warning {\n --canvas-react-message-color: #faad14;\n}\n.canvas-react-message-error {\n --canvas-react-message-color: #ff4d4f;\n}\n.canvas-react-message-icon {\n color: var(--canvas-react-message-color);\n}\n.canvas-react-message-spinner {\n width: 14px;\n height: 14px;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: canvas-react-message-spin 0.8s linear infinite;\n}\n@keyframes canvas-react-message-enter {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n@keyframes canvas-react-message-leave {\n to {\n opacity: 0;\n transform: translateY(-8px);\n max-height: 0;\n padding-block: 0;\n margin-bottom: -8px;\n }\n}\n@keyframes canvas-react-message-spin {\n to {\n transform: rotate(360deg);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .canvas-react-message,\n .canvas-react-message-spinner {\n animation-duration: 0.01ms;\n }\n}\n');
|
|
633
|
-
var nextKey = 0;
|
|
634
|
-
var LEAVE_DURATION = 300;
|
|
635
|
-
function createMessageStore(initialOptions = {}) {
|
|
636
|
-
let options = initialOptions;
|
|
637
|
-
let entries = [];
|
|
638
|
-
const listeners2 = /* @__PURE__ */ new Set();
|
|
639
|
-
const timers = /* @__PURE__ */ new Map();
|
|
640
|
-
const leaveTimers = /* @__PURE__ */ new Map();
|
|
641
|
-
const publish = () => listeners2.forEach((listener) => listener());
|
|
642
|
-
const remove = (key) => {
|
|
643
|
-
const targets = key === void 0 ? entries.filter((entry) => !entry.leaving) : entries.filter((entry) => entry.key === key && !entry.leaving);
|
|
644
|
-
if (!targets.length) return;
|
|
645
|
-
targets.forEach((entry) => {
|
|
646
|
-
const timer = timers.get(entry.key);
|
|
647
|
-
if (timer) clearTimeout(timer);
|
|
648
|
-
timers.delete(entry.key);
|
|
649
|
-
entry.leaving = true;
|
|
650
|
-
leaveTimers.set(
|
|
651
|
-
entry.key,
|
|
652
|
-
setTimeout(() => {
|
|
653
|
-
leaveTimers.delete(entry.key);
|
|
654
|
-
entries = entries.filter(
|
|
655
|
-
(item) => item.key !== entry.key || item !== entry
|
|
656
|
-
);
|
|
657
|
-
entry.close();
|
|
658
|
-
entry.onClose?.();
|
|
659
|
-
publish();
|
|
660
|
-
}, LEAVE_DURATION)
|
|
661
|
-
);
|
|
662
|
-
});
|
|
663
|
-
publish();
|
|
664
|
-
};
|
|
665
|
-
const open = (config) => {
|
|
666
|
-
const key = config.key ?? ++nextKey;
|
|
667
|
-
const previous = entries.find((entry2) => entry2.key === key);
|
|
668
|
-
const oldTimer = timers.get(key);
|
|
669
|
-
if (oldTimer) clearTimeout(oldTimer);
|
|
670
|
-
timers.delete(key);
|
|
671
|
-
const leaveTimer = leaveTimers.get(key);
|
|
672
|
-
if (leaveTimer) clearTimeout(leaveTimer);
|
|
673
|
-
leaveTimers.delete(key);
|
|
674
|
-
let resolve;
|
|
675
|
-
const promise = previous ? void 0 : new Promise((done) => {
|
|
676
|
-
resolve = done;
|
|
677
|
-
});
|
|
678
|
-
const close = previous?.close ?? resolve;
|
|
679
|
-
const entry = {
|
|
680
|
-
...config,
|
|
681
|
-
key,
|
|
682
|
-
type: config.type ?? "info",
|
|
683
|
-
close
|
|
684
|
-
};
|
|
685
|
-
entries = previous ? entries.map((item) => item.key === key ? entry : item) : [...entries, entry];
|
|
686
|
-
if (options.maxCount && entries.filter((item) => !item.leaving).length > options.maxCount) {
|
|
687
|
-
const oldest = entries.find((item) => item.key !== key && !item.leaving);
|
|
688
|
-
if (oldest && oldest.key !== key) remove(oldest.key);
|
|
689
|
-
}
|
|
690
|
-
const duration = config.duration ?? options.duration ?? (entry.type === "loading" ? 0 : 3);
|
|
691
|
-
if (duration > 0)
|
|
692
|
-
timers.set(
|
|
693
|
-
key,
|
|
694
|
-
setTimeout(() => remove(key), duration * 1e3)
|
|
695
|
-
);
|
|
696
|
-
publish();
|
|
697
|
-
const handle = (() => remove(key));
|
|
698
|
-
handle.then = (onFulfilled, onRejected) => (promise ?? new Promise((done) => {
|
|
699
|
-
const current = entries.find((item) => item.key === key);
|
|
700
|
-
if (!current) done();
|
|
701
|
-
else {
|
|
702
|
-
const originalClose = current.close;
|
|
703
|
-
current.close = () => {
|
|
704
|
-
originalClose();
|
|
705
|
-
done();
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
})).then(onFulfilled, onRejected);
|
|
709
|
-
return handle;
|
|
710
|
-
};
|
|
711
|
-
const level = (type) => (content, duration, onClose) => open(
|
|
712
|
-
isConfig(content) ? { ...content, type } : { content, type, duration, onClose }
|
|
713
|
-
);
|
|
714
|
-
const api = {
|
|
715
|
-
open,
|
|
716
|
-
info: level("info"),
|
|
717
|
-
success: level("success"),
|
|
718
|
-
warning: level("warning"),
|
|
719
|
-
error: level("error"),
|
|
720
|
-
loading: level("loading"),
|
|
721
|
-
destroy: remove,
|
|
722
|
-
config(next) {
|
|
723
|
-
options = { ...options, ...next };
|
|
724
|
-
publish();
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
return {
|
|
728
|
-
api,
|
|
729
|
-
getEntries: () => entries,
|
|
730
|
-
getOptions: () => options,
|
|
731
|
-
subscribe(listener) {
|
|
732
|
-
listeners2.add(listener);
|
|
733
|
-
return () => {
|
|
734
|
-
listeners2.delete(listener);
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
function isConfig(value) {
|
|
740
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && "content" in value;
|
|
741
|
-
}
|
|
742
|
-
function MessageHolder({ store }) {
|
|
743
|
-
const [, refresh] = React.useState(0);
|
|
744
|
-
React.useEffect(() => {
|
|
745
|
-
refresh((value) => value + 1);
|
|
746
|
-
return store.subscribe(() => refresh((value) => value + 1));
|
|
747
|
-
}, [store]);
|
|
748
|
-
const options = store.getOptions();
|
|
749
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
750
|
-
"div",
|
|
751
|
-
{
|
|
752
|
-
className: `${REACT_COMPONENT_PREFIX}-message-host`,
|
|
753
|
-
style: { top: options.top ?? 8 },
|
|
754
|
-
role: "status",
|
|
755
|
-
"aria-live": "polite",
|
|
756
|
-
children: store.getEntries().map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
757
|
-
"div",
|
|
758
|
-
{
|
|
759
|
-
className: [
|
|
760
|
-
`${REACT_COMPONENT_PREFIX}-message`,
|
|
761
|
-
`${REACT_COMPONENT_PREFIX}-message-${entry.type}`,
|
|
762
|
-
entry.leaving && `${REACT_COMPONENT_PREFIX}-message-leaving`,
|
|
763
|
-
entry.className
|
|
764
|
-
].filter(Boolean).join(" "),
|
|
765
|
-
style: entry.style,
|
|
766
|
-
onClick: entry.onClick,
|
|
767
|
-
children: [
|
|
768
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
769
|
-
"span",
|
|
770
|
-
{
|
|
771
|
-
className: `${REACT_COMPONENT_PREFIX}-message-icon`,
|
|
772
|
-
"aria-hidden": "true",
|
|
773
|
-
children: entry.icon ?? /* @__PURE__ */ jsxRuntime.jsx(MessageIcon, { type: entry.type })
|
|
774
|
-
}
|
|
775
|
-
),
|
|
776
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: entry.content })
|
|
777
|
-
]
|
|
778
|
-
},
|
|
779
|
-
entry.key
|
|
780
|
-
))
|
|
781
|
-
}
|
|
782
|
-
);
|
|
783
|
-
}
|
|
784
|
-
function MessageIcon({ type }) {
|
|
785
|
-
if (type === "loading")
|
|
786
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-message-spinner` });
|
|
787
|
-
const path = type === "success" ? "M5 12l4 4L19 6" : type === "error" ? "M6 6l12 12M18 6L6 18" : type === "warning" ? "M12 7v6m0 4h.01" : "M12 11v6m0-10h.01";
|
|
788
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
789
|
-
"svg",
|
|
790
|
-
{
|
|
791
|
-
viewBox: "0 0 24 24",
|
|
792
|
-
fill: "none",
|
|
793
|
-
stroke: "currentColor",
|
|
794
|
-
strokeWidth: "2.4",
|
|
795
|
-
strokeLinecap: "round",
|
|
796
|
-
strokeLinejoin: "round",
|
|
797
|
-
children: [
|
|
798
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
799
|
-
"circle",
|
|
800
|
-
{
|
|
801
|
-
cx: "12",
|
|
802
|
-
cy: "12",
|
|
803
|
-
r: "10",
|
|
804
|
-
fill: "currentColor",
|
|
805
|
-
stroke: "none",
|
|
806
|
-
opacity: ".12"
|
|
807
|
-
}
|
|
808
|
-
),
|
|
809
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: path })
|
|
810
|
-
]
|
|
811
|
-
}
|
|
812
|
-
);
|
|
813
|
-
}
|
|
814
|
-
var staticStore;
|
|
815
|
-
var staticRootMounted = false;
|
|
816
|
-
var staticHost;
|
|
817
|
-
function resolveMessageContainer(value) {
|
|
818
|
-
return (typeof value === "function" ? value() : value) ?? document.body;
|
|
819
|
-
}
|
|
820
|
-
function getStaticStore() {
|
|
821
|
-
if (!staticStore) staticStore = createMessageStore();
|
|
822
|
-
if (typeof document !== "undefined" && !staticRootMounted) {
|
|
823
|
-
const host = document.createElement("div");
|
|
824
|
-
host.id = `${REACT_COMPONENT_PREFIX}-message-root`;
|
|
825
|
-
resolveMessageContainer(staticStore.getOptions().getContainer).appendChild(
|
|
826
|
-
host
|
|
827
|
-
);
|
|
828
|
-
staticHost = host;
|
|
829
|
-
staticRootMounted = true;
|
|
830
|
-
if (typeof ReactDOM__namespace.render === "function") {
|
|
831
|
-
ReactDOM__namespace.render(/* @__PURE__ */ jsxRuntime.jsx(MessageHolder, { store: staticStore }), host);
|
|
832
|
-
} else {
|
|
833
|
-
void import('react-dom/client').then(({ createRoot }) => {
|
|
834
|
-
createRoot(host).render(/* @__PURE__ */ jsxRuntime.jsx(MessageHolder, { store: staticStore }));
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
} else if (staticHost && !staticHost.isConnected) {
|
|
838
|
-
resolveMessageContainer(staticStore.getOptions().getContainer).appendChild(
|
|
839
|
-
staticHost
|
|
840
|
-
);
|
|
841
|
-
}
|
|
842
|
-
return staticStore;
|
|
843
|
-
}
|
|
844
|
-
var reactMessage = {
|
|
845
|
-
open: (config) => getStaticStore().api.open(config),
|
|
846
|
-
info: (content, duration, onClose) => getStaticStore().api.info(content, duration, onClose),
|
|
847
|
-
success: (content, duration, onClose) => getStaticStore().api.success(content, duration, onClose),
|
|
848
|
-
warning: (content, duration, onClose) => getStaticStore().api.warning(content, duration, onClose),
|
|
849
|
-
error: (content, duration, onClose) => getStaticStore().api.error(content, duration, onClose),
|
|
850
|
-
loading: (content, duration, onClose) => getStaticStore().api.loading(content, duration, onClose),
|
|
851
|
-
destroy: (key) => getStaticStore().api.destroy(key),
|
|
852
|
-
config: (options) => {
|
|
853
|
-
const store = getStaticStore();
|
|
854
|
-
store.api.config(options);
|
|
855
|
-
if (staticHost && typeof document !== "undefined") {
|
|
856
|
-
const container = resolveMessageContainer(
|
|
857
|
-
store.getOptions().getContainer
|
|
858
|
-
);
|
|
859
|
-
if (staticHost.parentElement !== container)
|
|
860
|
-
container.appendChild(staticHost);
|
|
861
|
-
}
|
|
862
|
-
},
|
|
863
|
-
/** 创建能读取调用位置 React Context 的消息实例。 */
|
|
864
|
-
useMessage: (options) => useReactMessage(options)
|
|
865
|
-
};
|
|
866
|
-
function useReactMessage(options) {
|
|
867
|
-
const store = React.useMemo(() => createMessageStore(options), []);
|
|
868
|
-
React.useEffect(() => () => store.api.destroy(), [store]);
|
|
869
|
-
const holder = /* @__PURE__ */ jsxRuntime.jsx(MessageHolder, { store }, "message-holder");
|
|
870
|
-
return [
|
|
871
|
-
store.api,
|
|
872
|
-
options?.getContainer && typeof document !== "undefined" ? ReactDOM__namespace.createPortal(
|
|
873
|
-
holder,
|
|
874
|
-
resolveMessageContainer(options.getContainer)
|
|
875
|
-
) : holder
|
|
876
|
-
];
|
|
877
|
-
}
|
|
878
|
-
function ReactButton({
|
|
879
|
-
children,
|
|
880
|
-
className,
|
|
881
|
-
danger,
|
|
882
|
-
htmlType = "button",
|
|
883
|
-
icon,
|
|
884
|
-
size = "middle",
|
|
885
|
-
type = "default",
|
|
886
|
-
...props
|
|
887
|
-
}) {
|
|
888
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
889
|
-
"button",
|
|
890
|
-
{
|
|
891
|
-
...props,
|
|
892
|
-
type: htmlType,
|
|
893
|
-
className: joinClassNames(
|
|
894
|
-
`${REACT_COMPONENT_PREFIX}-button`,
|
|
895
|
-
`${REACT_COMPONENT_PREFIX}-button-${type}`,
|
|
896
|
-
`${REACT_COMPONENT_PREFIX}-button-${size}`,
|
|
897
|
-
danger && `${REACT_COMPONENT_PREFIX}-button-danger`,
|
|
898
|
-
className
|
|
899
|
-
),
|
|
900
|
-
children: [
|
|
901
|
-
icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-button-icon`, children: icon }) : null,
|
|
902
|
-
children
|
|
903
|
-
]
|
|
904
|
-
}
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
function ReactFlex({
|
|
908
|
-
vertical,
|
|
909
|
-
justify,
|
|
910
|
-
align,
|
|
911
|
-
gap,
|
|
912
|
-
style,
|
|
913
|
-
...props
|
|
914
|
-
}) {
|
|
915
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
916
|
-
"div",
|
|
917
|
-
{
|
|
918
|
-
...props,
|
|
919
|
-
style: {
|
|
920
|
-
display: "flex",
|
|
921
|
-
flexDirection: vertical ? "column" : "row",
|
|
922
|
-
justifyContent: justify,
|
|
923
|
-
alignItems: align,
|
|
924
|
-
gap,
|
|
925
|
-
...style
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
|
-
function ReactRow({ gutter = 0, style, ...props }) {
|
|
931
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
932
|
-
"div",
|
|
933
|
-
{
|
|
934
|
-
...props,
|
|
935
|
-
className: joinClassNames(
|
|
936
|
-
`${REACT_COMPONENT_PREFIX}-row`,
|
|
937
|
-
props.className
|
|
938
|
-
),
|
|
939
|
-
style: { marginInline: -gutter / 2, ...style }
|
|
940
|
-
}
|
|
941
|
-
);
|
|
942
|
-
}
|
|
943
|
-
function ReactCol({ span = 24, style, ...props }) {
|
|
944
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
945
|
-
"div",
|
|
946
|
-
{
|
|
947
|
-
...props,
|
|
948
|
-
className: joinClassNames(
|
|
949
|
-
`${REACT_COMPONENT_PREFIX}-col`,
|
|
950
|
-
props.className
|
|
951
|
-
),
|
|
952
|
-
style: {
|
|
953
|
-
flex: `0 0 ${span / 24 * 100}%`,
|
|
954
|
-
maxWidth: `${span / 24 * 100}%`,
|
|
955
|
-
...style
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
);
|
|
959
|
-
}
|
|
960
|
-
var RadioGroupContext = React.createContext({});
|
|
961
|
-
function ReactRadioOption({
|
|
962
|
-
value,
|
|
963
|
-
checked,
|
|
964
|
-
disabled,
|
|
965
|
-
onChange,
|
|
966
|
-
children,
|
|
967
|
-
className,
|
|
968
|
-
...props
|
|
969
|
-
}) {
|
|
970
|
-
const group = React.useContext(RadioGroupContext);
|
|
971
|
-
const selected = checked ?? String(group.value ?? "") === String(value);
|
|
972
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
973
|
-
"label",
|
|
974
|
-
{
|
|
975
|
-
...props,
|
|
976
|
-
className: joinClassNames(
|
|
977
|
-
`${REACT_COMPONENT_PREFIX}-radio`,
|
|
978
|
-
disabled && `${REACT_COMPONENT_PREFIX}-radio-disabled`,
|
|
979
|
-
className
|
|
980
|
-
),
|
|
981
|
-
children: [
|
|
982
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
983
|
-
"input",
|
|
984
|
-
{
|
|
985
|
-
type: "radio",
|
|
986
|
-
checked: selected,
|
|
987
|
-
disabled,
|
|
988
|
-
onChange: () => {
|
|
989
|
-
const event = { target: { value } };
|
|
990
|
-
onChange?.(event);
|
|
991
|
-
group.onChange?.(event);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
),
|
|
995
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-radio-mark` }),
|
|
996
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children })
|
|
997
|
-
]
|
|
998
|
-
}
|
|
999
|
-
);
|
|
1000
|
-
}
|
|
1001
|
-
function ReactRadioGroup({
|
|
1002
|
-
value,
|
|
1003
|
-
onChange,
|
|
1004
|
-
className,
|
|
1005
|
-
...props
|
|
1006
|
-
}) {
|
|
1007
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupContext.Provider, { value: { value, onChange }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1008
|
-
"div",
|
|
1009
|
-
{
|
|
1010
|
-
...props,
|
|
1011
|
-
className: joinClassNames(
|
|
1012
|
-
`${REACT_COMPONENT_PREFIX}-radio-group`,
|
|
1013
|
-
className
|
|
1014
|
-
)
|
|
1015
|
-
}
|
|
1016
|
-
) });
|
|
1017
|
-
}
|
|
1018
|
-
var ReactRadio = Object.assign(ReactRadioOption, {
|
|
1019
|
-
Group: ReactRadioGroup
|
|
1020
|
-
});
|
|
1021
|
-
function ReactTextArea({ className, ...props }) {
|
|
1022
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1023
|
-
"textarea",
|
|
1024
|
-
{
|
|
1025
|
-
...props,
|
|
1026
|
-
className: joinClassNames(
|
|
1027
|
-
`${REACT_COMPONENT_PREFIX}-textarea`,
|
|
1028
|
-
className
|
|
1029
|
-
)
|
|
1030
|
-
}
|
|
1031
|
-
);
|
|
1032
|
-
}
|
|
1033
|
-
var REACT_ICON_DEFINITIONS = icons.iconDefinitions;
|
|
1034
|
-
|
|
1035
|
-
// src/components/icon/style.css
|
|
1036
|
-
styleInject(".canvas-react-icon {\n display: inline-block;\n vertical-align: -0.125em;\n color: inherit;\n}\n.canvas-react-icon-spin {\n animation: canvas-react-icon-spin 1s infinite linear;\n}\n@keyframes canvas-react-icon-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .canvas-react-icon-spin {\n animation-duration: 2s;\n }\n}\n");
|
|
1037
|
-
var PRIMARY_COLOR_TOKEN = "__CC_REACT_ICON_PRIMARY__";
|
|
1038
|
-
var SECONDARY_COLOR_TOKEN = "__CC_REACT_ICON_SECONDARY__";
|
|
1039
|
-
var ReactIcon = React.forwardRef(
|
|
1040
|
-
function ReactIcon2({
|
|
1041
|
-
"aria-hidden": ariaHidden,
|
|
1042
|
-
"aria-label": ariaLabel,
|
|
1043
|
-
className,
|
|
1044
|
-
color,
|
|
1045
|
-
name,
|
|
1046
|
-
rotate,
|
|
1047
|
-
size = "1em",
|
|
1048
|
-
spin = false,
|
|
1049
|
-
style,
|
|
1050
|
-
twoToneColor,
|
|
1051
|
-
...svgProps
|
|
1052
|
-
}, ref) {
|
|
1053
|
-
const icon = REACT_ICON_DEFINITIONS[name];
|
|
1054
|
-
const [primaryColor, secondaryColor] = resolveTwoToneColors(twoToneColor);
|
|
1055
|
-
const svgStyle = {
|
|
1056
|
-
color,
|
|
1057
|
-
width: size,
|
|
1058
|
-
height: size,
|
|
1059
|
-
transform: rotate == null ? void 0 : `rotate(${rotate}deg)`,
|
|
1060
|
-
...style
|
|
1061
|
-
};
|
|
1062
|
-
const classes = [
|
|
1063
|
-
"canvas-react-icon",
|
|
1064
|
-
spin ? "canvas-react-icon-spin" : void 0,
|
|
1065
|
-
className
|
|
1066
|
-
].filter(Boolean).join(" ");
|
|
1067
|
-
return React.createElement(
|
|
1068
|
-
"svg",
|
|
1069
|
-
{
|
|
1070
|
-
...svgProps,
|
|
1071
|
-
ref,
|
|
1072
|
-
className: classes,
|
|
1073
|
-
viewBox: icon.icon.attrs.viewBox,
|
|
1074
|
-
width: size,
|
|
1075
|
-
height: size,
|
|
1076
|
-
fill: "currentColor",
|
|
1077
|
-
style: svgStyle,
|
|
1078
|
-
role: ariaLabel ? "img" : svgProps.role,
|
|
1079
|
-
"aria-label": ariaLabel,
|
|
1080
|
-
"aria-hidden": ariaHidden ?? !ariaLabel,
|
|
1081
|
-
focusable: "false",
|
|
1082
|
-
"data-icon": icon.name
|
|
1083
|
-
},
|
|
1084
|
-
...renderIconChildren(icon.icon, primaryColor, secondaryColor)
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
);
|
|
1088
|
-
ReactIcon.displayName = "ReactIcon";
|
|
1089
|
-
function createReactIconComponent(name) {
|
|
1090
|
-
const IconComponent = React.forwardRef(
|
|
1091
|
-
function NamedReactIcon(props, ref) {
|
|
1092
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ReactIcon, { ...props, name, ref });
|
|
1093
|
-
}
|
|
1094
|
-
);
|
|
1095
|
-
IconComponent.displayName = `React${name}`;
|
|
1096
|
-
return IconComponent;
|
|
1097
|
-
}
|
|
1098
|
-
function resolveTwoToneColors(twoToneColor) {
|
|
1099
|
-
if (Array.isArray(twoToneColor)) {
|
|
1100
|
-
return [twoToneColor[0], twoToneColor[1]];
|
|
1101
|
-
}
|
|
1102
|
-
const primaryColor = twoToneColor ?? "#1677ff";
|
|
1103
|
-
return [
|
|
1104
|
-
primaryColor,
|
|
1105
|
-
twoToneColor ? lightenColor(twoToneColor) : "#e6f4ff"
|
|
1106
|
-
];
|
|
1107
|
-
}
|
|
1108
|
-
function lightenColor(color) {
|
|
1109
|
-
const match = color.match(/^#([\da-f]{3}|[\da-f]{6})$/i);
|
|
1110
|
-
if (!match) return "#e6e6e6";
|
|
1111
|
-
const raw = match[1];
|
|
1112
|
-
const normalized = raw.length === 3 ? raw.split("").map((digit) => digit + digit).join("") : raw;
|
|
1113
|
-
const channels = normalized.match(/[\da-f]{2}/gi).map((channel) => Number.parseInt(channel, 16));
|
|
1114
|
-
return `#${channels.map((channel) => Math.round(channel + (255 - channel) * 0.9)).map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
|
1115
|
-
}
|
|
1116
|
-
function renderIconChildren(node, primaryColor, secondaryColor) {
|
|
1117
|
-
return (node.children ?? []).map((child, index) => {
|
|
1118
|
-
const props = {};
|
|
1119
|
-
for (const [key, rawValue] of Object.entries(child.attrs)) {
|
|
1120
|
-
const value = rawValue.split(PRIMARY_COLOR_TOKEN).join(primaryColor).split(SECONDARY_COLOR_TOKEN).join(secondaryColor);
|
|
1121
|
-
props[normalizeSvgAttribute(key)] = value;
|
|
1122
|
-
}
|
|
1123
|
-
return React.createElement(
|
|
1124
|
-
child.tag,
|
|
1125
|
-
{ ...props, key: `${child.tag}-${index}` },
|
|
1126
|
-
...renderIconChildren(child, primaryColor, secondaryColor)
|
|
1127
|
-
);
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
var SVG_ATTRIBUTE_NAMES = {
|
|
1131
|
-
class: "className",
|
|
1132
|
-
"clip-path": "clipPath",
|
|
1133
|
-
"clip-rule": "clipRule",
|
|
1134
|
-
"fill-rule": "fillRule",
|
|
1135
|
-
"stroke-dasharray": "strokeDasharray",
|
|
1136
|
-
"stroke-dashoffset": "strokeDashoffset",
|
|
1137
|
-
"stroke-linecap": "strokeLinecap",
|
|
1138
|
-
"stroke-linejoin": "strokeLinejoin",
|
|
1139
|
-
"stroke-miterlimit": "strokeMiterlimit",
|
|
1140
|
-
"stroke-width": "strokeWidth",
|
|
1141
|
-
"xlink:href": "xlinkHref"
|
|
1142
|
-
};
|
|
1143
|
-
function normalizeSvgAttribute(name) {
|
|
1144
|
-
return SVG_ATTRIBUTE_NAMES[name] ?? name.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
295
|
+
var SVG_ATTRIBUTE_NAMES = {
|
|
296
|
+
class: "className",
|
|
297
|
+
"clip-path": "clipPath",
|
|
298
|
+
"clip-rule": "clipRule",
|
|
299
|
+
"fill-rule": "fillRule",
|
|
300
|
+
"stroke-dasharray": "strokeDasharray",
|
|
301
|
+
"stroke-dashoffset": "strokeDashoffset",
|
|
302
|
+
"stroke-linecap": "strokeLinecap",
|
|
303
|
+
"stroke-linejoin": "strokeLinejoin",
|
|
304
|
+
"stroke-miterlimit": "strokeMiterlimit",
|
|
305
|
+
"stroke-width": "strokeWidth",
|
|
306
|
+
"xlink:href": "xlinkHref"
|
|
307
|
+
};
|
|
308
|
+
function normalizeSvgAttribute(name) {
|
|
309
|
+
return SVG_ATTRIBUTE_NAMES[name] ?? name.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
1145
310
|
}
|
|
1146
311
|
|
|
1147
312
|
// src/components/icon/icons.tsx
|
|
@@ -2286,6 +1451,866 @@ var ReactZhihuSquareFilled = createReactIconComponent("ZhihuSquareFilled");
|
|
|
2286
1451
|
var ReactZoomInOutlined = createReactIconComponent("ZoomInOutlined");
|
|
2287
1452
|
var ReactZoomOutOutlined = createReactIconComponent("ZoomOutOutlined");
|
|
2288
1453
|
|
|
1454
|
+
// src/components/empty/style.css
|
|
1455
|
+
styleInject('@import "../../styles/variables.css";\n.canvas-react-empty {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-width: 0;\n padding: 24px 12px;\n color: var(--canvas-react-color-text-secondary, #8c8c8c);\n font-size: var(--canvas-react-font-size, 14px);\n text-align: center;\n}\n.canvas-react-empty-image {\n display: flex;\n color: #c8d0dc;\n}\n.canvas-react-empty-description {\n max-width: 100%;\n overflow-wrap: anywhere;\n}\n.canvas-react-empty-actions {\n margin-top: 8px;\n}\n');
|
|
1456
|
+
function ReactEmpty({
|
|
1457
|
+
description = "\u6682\u65E0\u6570\u636E",
|
|
1458
|
+
image = /* @__PURE__ */ jsxRuntime.jsx(ReactInboxOutlined, { "aria-hidden": "true", size: 42 }),
|
|
1459
|
+
children,
|
|
1460
|
+
className,
|
|
1461
|
+
role = "status",
|
|
1462
|
+
...rest
|
|
1463
|
+
}) {
|
|
1464
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1465
|
+
"div",
|
|
1466
|
+
{
|
|
1467
|
+
...rest,
|
|
1468
|
+
role,
|
|
1469
|
+
className: joinClassNames(`${REACT_COMPONENT_PREFIX}-empty`, className),
|
|
1470
|
+
children: [
|
|
1471
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `${REACT_COMPONENT_PREFIX}-empty-image`, children: image }),
|
|
1472
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `${REACT_COMPONENT_PREFIX}-empty-description`, children: description }),
|
|
1473
|
+
children ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${REACT_COMPONENT_PREFIX}-empty-actions`, children }) : null
|
|
1474
|
+
]
|
|
1475
|
+
}
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
// src/components/tag/style.css
|
|
1480
|
+
styleInject(".canvas-react-tag {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n max-width: 100%;\n padding: 3px 6px;\n border: 1px solid var(--canvas-react-color-border);\n border-radius: var(--canvas-react-radius-sm);\n background: var(--canvas-react-color-bg-soft);\n color: var(--canvas-react-color-text);\n font-size: var(--canvas-react-font-size-secondary);\n line-height: 1.4;\n}\n.canvas-react-tag-content {\n display: inline-flex;\n align-items: baseline;\n gap: 4px;\n min-width: 0;\n overflow: hidden;\n}\n.canvas-react-tag-close {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n padding: 0;\n border: 0;\n border-radius: 3px;\n background: transparent;\n color: var(--canvas-react-color-text-muted);\n font: inherit;\n font-size: 16px;\n line-height: 1;\n cursor: pointer;\n}\n.canvas-react-tag-close:hover {\n background: var(--canvas-react-color-bg-hover);\n color: var(--canvas-react-color-text);\n}\n.canvas-react-tag-close:focus-visible {\n outline: 2px solid var(--canvas-react-color-primary);\n outline-offset: 1px;\n}\n");
|
|
1481
|
+
function ReactTag({
|
|
1482
|
+
children,
|
|
1483
|
+
className,
|
|
1484
|
+
closeLabel = "\u79FB\u9664\u6807\u7B7E",
|
|
1485
|
+
onClose,
|
|
1486
|
+
...restProps
|
|
1487
|
+
}) {
|
|
1488
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1489
|
+
"span",
|
|
1490
|
+
{
|
|
1491
|
+
...restProps,
|
|
1492
|
+
className: joinClassNames(`${REACT_COMPONENT_PREFIX}-tag`, className),
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-tag-content`, children }),
|
|
1495
|
+
onClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1496
|
+
"button",
|
|
1497
|
+
{
|
|
1498
|
+
type: "button",
|
|
1499
|
+
className: `${REACT_COMPONENT_PREFIX}-tag-close`,
|
|
1500
|
+
"aria-label": closeLabel,
|
|
1501
|
+
title: closeLabel,
|
|
1502
|
+
onClick: onClose,
|
|
1503
|
+
children: "\xD7"
|
|
1504
|
+
}
|
|
1505
|
+
) : null
|
|
1506
|
+
]
|
|
1507
|
+
}
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
// src/components/rich-text/model.ts
|
|
1512
|
+
var styleKey = (style) => JSON.stringify({
|
|
1513
|
+
fontFamily: style?.fontFamily,
|
|
1514
|
+
fontSize: style?.fontSize,
|
|
1515
|
+
fontWeight: style?.fontWeight,
|
|
1516
|
+
fontStyle: style?.fontStyle,
|
|
1517
|
+
color: style?.color
|
|
1518
|
+
});
|
|
1519
|
+
function normalizeStyle(input) {
|
|
1520
|
+
if (!input) return void 0;
|
|
1521
|
+
const style = {};
|
|
1522
|
+
if (typeof input.fontFamily === "string" && /^[\p{L}\p{N}_\s,'"-]+$/u.test(input.fontFamily))
|
|
1523
|
+
style.fontFamily = input.fontFamily;
|
|
1524
|
+
if (typeof input.fontSize === "number" && Number.isFinite(input.fontSize) && input.fontSize >= 1 && input.fontSize <= 240)
|
|
1525
|
+
style.fontSize = input.fontSize;
|
|
1526
|
+
if (typeof input.fontWeight === "string" && /^(?:[1-9]00|normal|bold)$/.test(input.fontWeight))
|
|
1527
|
+
style.fontWeight = input.fontWeight;
|
|
1528
|
+
if (input.fontStyle === "normal" || input.fontStyle === "italic")
|
|
1529
|
+
style.fontStyle = input.fontStyle;
|
|
1530
|
+
if (typeof input.color === "string" && /^#[0-9a-fA-F]{3,8}$/.test(input.color))
|
|
1531
|
+
style.color = input.color;
|
|
1532
|
+
return Object.keys(style).length ? style : void 0;
|
|
1533
|
+
}
|
|
1534
|
+
function alignRange(text, start, end) {
|
|
1535
|
+
const Segmenter = Intl.Segmenter;
|
|
1536
|
+
const boundaries = Segmenter ? [
|
|
1537
|
+
0,
|
|
1538
|
+
...Array.from(
|
|
1539
|
+
new Segmenter(void 0, { granularity: "grapheme" }).segment(text),
|
|
1540
|
+
(part) => part.index + part.segment.length
|
|
1541
|
+
)
|
|
1542
|
+
] : [
|
|
1543
|
+
0,
|
|
1544
|
+
...Array.from(text).reduce((offsets, character) => {
|
|
1545
|
+
offsets.push((offsets[offsets.length - 1] ?? 0) + character.length);
|
|
1546
|
+
return offsets;
|
|
1547
|
+
}, [])
|
|
1548
|
+
];
|
|
1549
|
+
const clampedStart = Math.max(0, Math.min(start, text.length));
|
|
1550
|
+
const clampedEnd = Math.max(clampedStart, Math.min(end, text.length));
|
|
1551
|
+
const from = [...boundaries].reverse().find((boundary) => boundary <= clampedStart) ?? 0;
|
|
1552
|
+
const to = clampedStart === clampedEnd ? from : boundaries.find((boundary) => boundary >= clampedEnd) ?? text.length;
|
|
1553
|
+
return { from, to };
|
|
1554
|
+
}
|
|
1555
|
+
function normalizeRichTextRuns(runs) {
|
|
1556
|
+
const normalized = [];
|
|
1557
|
+
for (const run of runs) {
|
|
1558
|
+
if (!run.text) continue;
|
|
1559
|
+
const style = normalizeStyle(run.style);
|
|
1560
|
+
const previous = normalized[normalized.length - 1];
|
|
1561
|
+
if (previous && styleKey(previous.style) === styleKey(style))
|
|
1562
|
+
previous.text += run.text;
|
|
1563
|
+
else normalized.push({ text: run.text, ...style ? { style } : {} });
|
|
1564
|
+
}
|
|
1565
|
+
return normalized;
|
|
1566
|
+
}
|
|
1567
|
+
function richTextPlainText(runs) {
|
|
1568
|
+
return runs.map((run) => run.text).join("");
|
|
1569
|
+
}
|
|
1570
|
+
function styleRichTextRange(runs, start, end, patch) {
|
|
1571
|
+
if (start >= end) return normalizeRichTextRuns(runs);
|
|
1572
|
+
({ from: start, to: end } = alignRange(richTextPlainText(runs), start, end));
|
|
1573
|
+
const result = [];
|
|
1574
|
+
let offset = 0;
|
|
1575
|
+
for (const run of runs) {
|
|
1576
|
+
const runStart = offset;
|
|
1577
|
+
const runEnd = offset + run.text.length;
|
|
1578
|
+
offset = runEnd;
|
|
1579
|
+
if (runEnd <= start || runStart >= end) {
|
|
1580
|
+
result.push(run);
|
|
1581
|
+
continue;
|
|
1582
|
+
}
|
|
1583
|
+
const localStart = Math.max(0, start - runStart);
|
|
1584
|
+
const localEnd = Math.min(run.text.length, end - runStart);
|
|
1585
|
+
if (localStart)
|
|
1586
|
+
result.push({ ...run, text: run.text.slice(0, localStart) });
|
|
1587
|
+
result.push({
|
|
1588
|
+
text: run.text.slice(localStart, localEnd),
|
|
1589
|
+
style: { ...run.style, ...patch }
|
|
1590
|
+
});
|
|
1591
|
+
if (localEnd < run.text.length)
|
|
1592
|
+
result.push({ ...run, text: run.text.slice(localEnd) });
|
|
1593
|
+
}
|
|
1594
|
+
return normalizeRichTextRuns(result);
|
|
1595
|
+
}
|
|
1596
|
+
function replaceRichTextRange(runs, start, end, text) {
|
|
1597
|
+
const content = richTextPlainText(runs);
|
|
1598
|
+
const { from, to } = alignRange(content, start, end);
|
|
1599
|
+
const result = [];
|
|
1600
|
+
let offset = 0;
|
|
1601
|
+
let inherited;
|
|
1602
|
+
let following;
|
|
1603
|
+
for (const run of runs) {
|
|
1604
|
+
const runStart = offset;
|
|
1605
|
+
const runEnd = offset + run.text.length;
|
|
1606
|
+
offset = runEnd;
|
|
1607
|
+
if (runStart < from) {
|
|
1608
|
+
const before = run.text.slice(
|
|
1609
|
+
0,
|
|
1610
|
+
Math.min(run.text.length, from - runStart)
|
|
1611
|
+
);
|
|
1612
|
+
if (before) {
|
|
1613
|
+
result.push({ ...run, text: before });
|
|
1614
|
+
inherited = run.style;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (runEnd > to) {
|
|
1618
|
+
const after = run.text.slice(Math.max(0, to - runStart));
|
|
1619
|
+
if (after) {
|
|
1620
|
+
following ?? (following = run.style);
|
|
1621
|
+
result.push({ ...run, text: after });
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
if (text) {
|
|
1626
|
+
let length = 0;
|
|
1627
|
+
const insertionIndex = result.findIndex((run) => {
|
|
1628
|
+
length += run.text.length;
|
|
1629
|
+
return length > from;
|
|
1630
|
+
});
|
|
1631
|
+
result.splice(insertionIndex < 0 ? result.length : insertionIndex, 0, {
|
|
1632
|
+
text,
|
|
1633
|
+
...inherited ?? following ? { style: inherited ?? following } : {}
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
return normalizeRichTextRuns(result);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// src/components/compat/style.css
|
|
1640
|
+
styleInject(".canvas-react-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n min-height: 32px;\n padding: 4px 14px;\n border: 1px solid var(--cc-border-color, #d9d9d9);\n border-radius: 6px;\n color: var(--cc-text-color, #1f2937);\n background: var(--cc-surface-color, #fff);\n cursor: pointer;\n}\n.canvas-react-button:hover:not(:disabled) {\n color: #1677ff;\n border-color: #1677ff;\n}\n.canvas-react-button:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n.canvas-react-button-primary {\n color: #fff;\n border-color: #1677ff;\n background: #1677ff;\n}\n.canvas-react-button-primary:hover:not(:disabled) {\n color: #fff;\n border-color: #4096ff;\n background: #4096ff;\n}\n.canvas-react-button-danger {\n color: #dc2626;\n border-color: #fca5a5;\n}\n.canvas-react-button-small {\n min-height: 24px;\n padding: 2px 8px;\n}\n.canvas-react-button-large {\n min-height: 40px;\n padding: 6px 18px;\n}\n.canvas-react-button-icon {\n display: inline-flex;\n}\n.canvas-react-row {\n display: flex;\n flex-flow: row wrap;\n}\n.canvas-react-col {\n min-width: 0;\n padding-inline: 8px;\n}\n.canvas-react-radio-group {\n display: flex;\n gap: 16px;\n}\n.canvas-react-radio {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n cursor: pointer;\n}\n.canvas-react-radio input {\n position: absolute;\n opacity: 0;\n pointer-events: none;\n}\n.canvas-react-radio-mark {\n width: 14px;\n height: 14px;\n border: 1px solid #94a3b8;\n border-radius: 50%;\n box-sizing: border-box;\n}\n.canvas-react-radio input:checked + .canvas-react-radio-mark {\n border: 4px solid #1677ff;\n}\n.canvas-react-form-item {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin-bottom: 16px;\n}\n.canvas-react-form-label {\n color: #334155;\n font-size: 14px;\n}\n.canvas-react-form-error {\n color: #dc2626;\n font-size: 12px;\n}\n.canvas-react-textarea {\n width: 100%;\n min-height: 72px;\n padding: 8px 10px;\n border: 1px solid var(--canvas-react-color-border);\n border-radius: 6px;\n box-sizing: border-box;\n background: var(--canvas-react-color-bg);\n color: var(--canvas-react-color-text);\n font: inherit;\n resize: vertical;\n}\n.canvas-react-textarea:hover:not(:disabled) {\n border-color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-textarea:focus {\n border-color: var(--canvas-react-color-primary);\n box-shadow: var(--canvas-react-shadow-focus);\n outline: none;\n}\n.canvas-react-textarea::placeholder {\n color: var(--canvas-react-color-text-muted);\n}\n.canvas-react-textarea:disabled {\n background: var(--canvas-react-color-bg-soft, #fafafa);\n color: var(--canvas-react-color-text-muted);\n cursor: not-allowed;\n}\n");
|
|
1641
|
+
|
|
1642
|
+
// src/components/form/style.css
|
|
1643
|
+
styleInject(".canvas-react-form {\n min-width: 0;\n}\n.canvas-react-form-vertical {\n display: grid;\n gap: 16px;\n}\n.canvas-react-form-horizontal {\n display: grid;\n gap: 12px;\n}\n.canvas-react-form-inline {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: 12px 16px;\n}\n.canvas-react-form-item {\n box-sizing: border-box;\n min-width: 0;\n}\n.canvas-react-form-item-vertical {\n display: grid;\n gap: 6px;\n}\n.canvas-react-form-item-horizontal {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr);\n align-items: center;\n column-gap: 10px;\n row-gap: 4px;\n}\n.canvas-react-form-item-inline {\n display: inline-grid;\n grid-template-columns: auto minmax(0, 1fr);\n align-items: center;\n column-gap: 8px;\n}\n.canvas-react-form-item-no-wrap {\n flex-wrap: nowrap;\n}\n.canvas-react-form-item-horizontal.canvas-react-form-item-no-wrap {\n display: grid;\n grid-template-columns: max-content minmax(0, 1fr);\n}\n.canvas-react-form-horizontal > .canvas-react-form-item {\n margin-bottom: var(--canvas-react-form-item-spacing, 16px);\n}\n.canvas-react-form-item-inline.canvas-react-form-item-no-wrap {\n display: inline-grid;\n grid-template-columns: max-content minmax(0, 1fr);\n}\n.canvas-react-form-item-no-wrap > .canvas-react-form-label {\n white-space: nowrap;\n}\n.canvas-react-form-label {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n min-width: 0;\n color: #475569;\n font-size: var(--canvas-react-font-size-label);\n line-height: 1.4;\n}\n.canvas-react-form-horizontal > .canvas-react-form-item > .canvas-react-form-label {\n min-height: 32px;\n}\n.canvas-react-form-required {\n color: #dc2626;\n}\n.canvas-react-form-control {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n.canvas-react-form-error {\n color: #dc2626;\n font-size: var(--canvas-react-font-size-secondary);\n}\n.canvas-react-form-help,\n.canvas-react-form-extra {\n color: #64748b;\n font-size: var(--canvas-react-font-size-secondary);\n}\n.canvas-react-form-item-error .canvas-react-form-control > input,\n.canvas-react-form-item-error .canvas-react-form-control > textarea {\n border-color: #dc2626;\n}\n");
|
|
1644
|
+
function createFormInstance() {
|
|
1645
|
+
const store = {
|
|
1646
|
+
values: {},
|
|
1647
|
+
initialValues: {},
|
|
1648
|
+
errors: {},
|
|
1649
|
+
rules: /* @__PURE__ */ new Map(),
|
|
1650
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
1651
|
+
revision: 0,
|
|
1652
|
+
notify() {
|
|
1653
|
+
store.revision += 1;
|
|
1654
|
+
store.listeners.forEach((listener) => listener());
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
return {
|
|
1658
|
+
__store: store,
|
|
1659
|
+
getFieldValue: (name) => store.values[name],
|
|
1660
|
+
setFieldsValue(values) {
|
|
1661
|
+
store.values = { ...store.values, ...values };
|
|
1662
|
+
Object.keys(values).forEach((name) => {
|
|
1663
|
+
delete store.errors[name];
|
|
1664
|
+
});
|
|
1665
|
+
store.notify();
|
|
1666
|
+
},
|
|
1667
|
+
resetFields() {
|
|
1668
|
+
store.values = { ...store.initialValues };
|
|
1669
|
+
store.errors = {};
|
|
1670
|
+
store.notify();
|
|
1671
|
+
},
|
|
1672
|
+
async validateFields() {
|
|
1673
|
+
const errors = {};
|
|
1674
|
+
for (const [name, rules] of store.rules) {
|
|
1675
|
+
const value = store.values[name];
|
|
1676
|
+
for (const rawRule of rules) {
|
|
1677
|
+
const rule = typeof rawRule === "function" ? rawRule({ getFieldValue: (field) => store.values[field] }) : rawRule;
|
|
1678
|
+
if (rule.required && (value === void 0 || value === null || value === "")) {
|
|
1679
|
+
errors[name] = rule.message ?? "\u6B64\u9879\u4E3A\u5FC5\u586B\u9879";
|
|
1680
|
+
break;
|
|
1681
|
+
}
|
|
1682
|
+
if ((rule.type === "number" || rule.type === "integer") && typeof value === "number" && rule.min !== void 0 && value < rule.min) {
|
|
1683
|
+
errors[name] = rule.message ?? `\u4E0D\u80FD\u5C0F\u4E8E ${rule.min}`;
|
|
1684
|
+
break;
|
|
1685
|
+
}
|
|
1686
|
+
if ((rule.type === "number" || rule.type === "integer") && typeof value === "number" && rule.max !== void 0 && value > rule.max) {
|
|
1687
|
+
errors[name] = rule.message ?? `\u4E0D\u80FD\u5927\u4E8E ${rule.max}`;
|
|
1688
|
+
break;
|
|
1689
|
+
}
|
|
1690
|
+
if (rule.type === "integer" && typeof value === "number" && !Number.isInteger(value)) {
|
|
1691
|
+
errors[name] = rule.message ?? "\u8BF7\u8F93\u5165\u6574\u6570";
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
if (rule.validator) {
|
|
1695
|
+
try {
|
|
1696
|
+
await rule.validator(rule, value);
|
|
1697
|
+
} catch (error) {
|
|
1698
|
+
errors[name] = error instanceof Error ? error.message : "\u6821\u9A8C\u5931\u8D25";
|
|
1699
|
+
break;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
store.errors = errors;
|
|
1705
|
+
store.notify();
|
|
1706
|
+
if (Object.keys(errors).length > 0) {
|
|
1707
|
+
return Promise.reject({
|
|
1708
|
+
errorFields: errors,
|
|
1709
|
+
values: { ...store.values }
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
return { ...store.values };
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
function useReactForm() {
|
|
1717
|
+
const formRef = React.useRef(null);
|
|
1718
|
+
if (!formRef.current) formRef.current = createFormInstance();
|
|
1719
|
+
return [formRef.current];
|
|
1720
|
+
}
|
|
1721
|
+
function useReactFormWatch(name, form) {
|
|
1722
|
+
React.useSyncExternalStore(
|
|
1723
|
+
(listener) => {
|
|
1724
|
+
form.__store.listeners.add(listener);
|
|
1725
|
+
return () => form.__store.listeners.delete(listener);
|
|
1726
|
+
},
|
|
1727
|
+
() => form.__store.revision,
|
|
1728
|
+
() => 0
|
|
1729
|
+
);
|
|
1730
|
+
return form.getFieldValue(name);
|
|
1731
|
+
}
|
|
1732
|
+
var FormContext = React.createContext(null);
|
|
1733
|
+
var emptySubscribe = () => () => {
|
|
1734
|
+
};
|
|
1735
|
+
var emptySnapshot = () => 0;
|
|
1736
|
+
function ReactFormRoot({
|
|
1737
|
+
form: formProp,
|
|
1738
|
+
initialValues,
|
|
1739
|
+
layout = "vertical",
|
|
1740
|
+
noWrap = false,
|
|
1741
|
+
itemSpacing,
|
|
1742
|
+
labelWidth,
|
|
1743
|
+
labelAlign = "right",
|
|
1744
|
+
colon = false,
|
|
1745
|
+
requiredMark = true,
|
|
1746
|
+
className,
|
|
1747
|
+
children,
|
|
1748
|
+
...props
|
|
1749
|
+
}) {
|
|
1750
|
+
const internalForm = React.useRef(null);
|
|
1751
|
+
if (!internalForm.current) internalForm.current = createFormInstance();
|
|
1752
|
+
const form = formProp ?? internalForm.current;
|
|
1753
|
+
const initialKey = React.useMemo(
|
|
1754
|
+
() => JSON.stringify(initialValues ?? {}),
|
|
1755
|
+
[initialValues]
|
|
1756
|
+
);
|
|
1757
|
+
React.useEffect(() => {
|
|
1758
|
+
form.__store.initialValues = { ...initialValues };
|
|
1759
|
+
form.__store.values = { ...initialValues, ...form.__store.values };
|
|
1760
|
+
form.__store.notify();
|
|
1761
|
+
}, [form, initialKey]);
|
|
1762
|
+
const contextValue = React.useMemo(
|
|
1763
|
+
() => ({
|
|
1764
|
+
form,
|
|
1765
|
+
layout,
|
|
1766
|
+
noWrap,
|
|
1767
|
+
labelWidth,
|
|
1768
|
+
labelAlign,
|
|
1769
|
+
colon,
|
|
1770
|
+
requiredMark
|
|
1771
|
+
}),
|
|
1772
|
+
[colon, form, labelAlign, labelWidth, layout, noWrap, requiredMark]
|
|
1773
|
+
);
|
|
1774
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1775
|
+
"form",
|
|
1776
|
+
{
|
|
1777
|
+
...props,
|
|
1778
|
+
style: itemSpacing === void 0 ? props.style : {
|
|
1779
|
+
...props.style,
|
|
1780
|
+
"--canvas-react-form-item-spacing": itemSpacing
|
|
1781
|
+
},
|
|
1782
|
+
className: joinClassNames(
|
|
1783
|
+
`${REACT_COMPONENT_PREFIX}-form`,
|
|
1784
|
+
`${REACT_COMPONENT_PREFIX}-form-${layout}`,
|
|
1785
|
+
className
|
|
1786
|
+
),
|
|
1787
|
+
onSubmit: (event) => event.preventDefault(),
|
|
1788
|
+
children
|
|
1789
|
+
}
|
|
1790
|
+
) });
|
|
1791
|
+
}
|
|
1792
|
+
function ReactFormItem({
|
|
1793
|
+
label,
|
|
1794
|
+
name,
|
|
1795
|
+
children,
|
|
1796
|
+
rules = [],
|
|
1797
|
+
initialValue,
|
|
1798
|
+
required,
|
|
1799
|
+
colon,
|
|
1800
|
+
labelWidth,
|
|
1801
|
+
labelAlign,
|
|
1802
|
+
labelStyle,
|
|
1803
|
+
controlStyle,
|
|
1804
|
+
help,
|
|
1805
|
+
extra,
|
|
1806
|
+
className,
|
|
1807
|
+
style,
|
|
1808
|
+
noWrap
|
|
1809
|
+
}) {
|
|
1810
|
+
const context = React.useContext(FormContext);
|
|
1811
|
+
const form = context?.form ?? null;
|
|
1812
|
+
if (name && !form) throw new Error("ReactForm.Item \u5FC5\u987B\u5728 ReactForm \u5185\u4F7F\u7528");
|
|
1813
|
+
React.useSyncExternalStore(
|
|
1814
|
+
form ? (listener) => {
|
|
1815
|
+
form.__store.listeners.add(listener);
|
|
1816
|
+
return () => form.__store.listeners.delete(listener);
|
|
1817
|
+
} : emptySubscribe,
|
|
1818
|
+
form ? () => form.__store.revision : emptySnapshot,
|
|
1819
|
+
emptySnapshot
|
|
1820
|
+
);
|
|
1821
|
+
React.useEffect(() => {
|
|
1822
|
+
if (!form || !name) return;
|
|
1823
|
+
form.__store.rules.set(name, rules);
|
|
1824
|
+
if (form.getFieldValue(name) === void 0 && initialValue !== void 0) {
|
|
1825
|
+
form.setFieldsValue({ [name]: initialValue });
|
|
1826
|
+
}
|
|
1827
|
+
return () => {
|
|
1828
|
+
form.__store.rules.delete(name);
|
|
1829
|
+
};
|
|
1830
|
+
}, [form, initialValue, name, rules]);
|
|
1831
|
+
const childProps = React.isValidElement(children) ? children.props : {};
|
|
1832
|
+
const value = form && name ? form.getFieldValue(name) : void 0;
|
|
1833
|
+
const child = form && name && React.isValidElement(children) ? React.cloneElement(children, {
|
|
1834
|
+
value: value ?? "",
|
|
1835
|
+
onChange: (...args) => {
|
|
1836
|
+
const first = args[0];
|
|
1837
|
+
const nextValue = typeof first === "object" && first !== null && "target" in first ? first.target?.value : first;
|
|
1838
|
+
form.setFieldsValue({ [name]: nextValue });
|
|
1839
|
+
const childOnChange = childProps.onChange;
|
|
1840
|
+
if (typeof childOnChange === "function") childOnChange(...args);
|
|
1841
|
+
}
|
|
1842
|
+
}) : children;
|
|
1843
|
+
const error = form && name ? form.__store.errors[name] : void 0;
|
|
1844
|
+
const isRequired = required ?? rules.some((rule) => typeof rule !== "function" && rule.required === true);
|
|
1845
|
+
const resolvedLabelWidth = labelWidth ?? context?.labelWidth;
|
|
1846
|
+
const resolvedLabelAlign = labelAlign ?? context?.labelAlign ?? "right";
|
|
1847
|
+
const showColon = colon ?? context?.colon ?? false;
|
|
1848
|
+
const shouldMarkRequired = context?.requiredMark ?? true;
|
|
1849
|
+
const resolvedLayout = context?.layout ?? "vertical";
|
|
1850
|
+
const resolvedNoWrap = noWrap ?? context?.noWrap ?? false;
|
|
1851
|
+
const labelElementId = typeof childProps.id === "string" ? childProps.id : void 0;
|
|
1852
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1853
|
+
"div",
|
|
1854
|
+
{
|
|
1855
|
+
className: joinClassNames(
|
|
1856
|
+
`${REACT_COMPONENT_PREFIX}-form-item`,
|
|
1857
|
+
`${REACT_COMPONENT_PREFIX}-form-item-${resolvedLayout}`,
|
|
1858
|
+
resolvedNoWrap && `${REACT_COMPONENT_PREFIX}-form-item-no-wrap`,
|
|
1859
|
+
className,
|
|
1860
|
+
error && `${REACT_COMPONENT_PREFIX}-form-item-error`
|
|
1861
|
+
),
|
|
1862
|
+
style,
|
|
1863
|
+
children: [
|
|
1864
|
+
label ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1865
|
+
"label",
|
|
1866
|
+
{
|
|
1867
|
+
className: `${REACT_COMPONENT_PREFIX}-form-label`,
|
|
1868
|
+
htmlFor: labelElementId,
|
|
1869
|
+
style: {
|
|
1870
|
+
width: resolvedLabelWidth,
|
|
1871
|
+
flexBasis: resolvedLabelWidth,
|
|
1872
|
+
textAlign: resolvedLabelAlign,
|
|
1873
|
+
...labelStyle
|
|
1874
|
+
},
|
|
1875
|
+
children: [
|
|
1876
|
+
shouldMarkRequired && isRequired ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1877
|
+
"span",
|
|
1878
|
+
{
|
|
1879
|
+
"aria-hidden": "true",
|
|
1880
|
+
className: `${REACT_COMPONENT_PREFIX}-form-required`,
|
|
1881
|
+
children: "*"
|
|
1882
|
+
}
|
|
1883
|
+
) : null,
|
|
1884
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
1885
|
+
showColon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: ":" }) : null
|
|
1886
|
+
]
|
|
1887
|
+
}
|
|
1888
|
+
) : null,
|
|
1889
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1890
|
+
"div",
|
|
1891
|
+
{
|
|
1892
|
+
className: `${REACT_COMPONENT_PREFIX}-form-control`,
|
|
1893
|
+
style: controlStyle,
|
|
1894
|
+
children: [
|
|
1895
|
+
child,
|
|
1896
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-form-error`, children: error }) : help ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-form-help`, children: help }) : null,
|
|
1897
|
+
extra ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-form-extra`, children: extra }) : null
|
|
1898
|
+
]
|
|
1899
|
+
}
|
|
1900
|
+
)
|
|
1901
|
+
]
|
|
1902
|
+
}
|
|
1903
|
+
);
|
|
1904
|
+
}
|
|
1905
|
+
var ReactForm = Object.assign(ReactFormRoot, {
|
|
1906
|
+
Item: ReactFormItem,
|
|
1907
|
+
useForm: useReactForm,
|
|
1908
|
+
useWatch: useReactFormWatch
|
|
1909
|
+
});
|
|
1910
|
+
|
|
1911
|
+
// src/components/message/style.css
|
|
1912
|
+
styleInject('@import "../../styles/variables.css";\n.canvas-react-message-host {\n position: fixed;\n z-index: 3000;\n inset-inline: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n padding-inline: 16px;\n pointer-events: none;\n font-size: var(--canvas-react-font-size, 14px);\n}\n.canvas-react-message {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: 8px;\n max-width: min(100%, 640px);\n max-height: 240px;\n padding: 9px 12px;\n border-radius: var(--canvas-react-radius-md, 8px);\n background: var(--canvas-react-color-bg, #fff);\n color: var(--canvas-react-color-text, rgba(0, 0, 0, 0.88));\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12);\n line-height: 1.5;\n pointer-events: auto;\n animation: canvas-react-message-enter 0.2s ease-out both;\n}\n.canvas-react-message-leaving {\n overflow: hidden;\n pointer-events: none;\n animation: canvas-react-message-leave 0.3s ease-in forwards;\n}\n.canvas-react-message-icon {\n display: inline-flex;\n flex: none;\n width: 16px;\n height: 16px;\n}\n.canvas-react-message-icon svg {\n width: 16px;\n height: 16px;\n}\n.canvas-react-message-info,\n.canvas-react-message-loading {\n --canvas-react-message-color: #1677ff;\n}\n.canvas-react-message-success {\n --canvas-react-message-color: #52c41a;\n}\n.canvas-react-message-warning {\n --canvas-react-message-color: #faad14;\n}\n.canvas-react-message-error {\n --canvas-react-message-color: #ff4d4f;\n}\n.canvas-react-message-icon {\n color: var(--canvas-react-message-color);\n}\n.canvas-react-message-spinner {\n width: 14px;\n height: 14px;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: canvas-react-message-spin 0.8s linear infinite;\n}\n@keyframes canvas-react-message-enter {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n@keyframes canvas-react-message-leave {\n to {\n opacity: 0;\n transform: translateY(-8px);\n max-height: 0;\n padding-block: 0;\n margin-bottom: -8px;\n }\n}\n@keyframes canvas-react-message-spin {\n to {\n transform: rotate(360deg);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .canvas-react-message,\n .canvas-react-message-spinner {\n animation-duration: 0.01ms;\n }\n}\n');
|
|
1913
|
+
var nextKey = 0;
|
|
1914
|
+
var LEAVE_DURATION = 300;
|
|
1915
|
+
function createMessageStore(initialOptions = {}) {
|
|
1916
|
+
let options = initialOptions;
|
|
1917
|
+
let entries = [];
|
|
1918
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
1919
|
+
const timers = /* @__PURE__ */ new Map();
|
|
1920
|
+
const leaveTimers = /* @__PURE__ */ new Map();
|
|
1921
|
+
const publish = () => listeners2.forEach((listener) => listener());
|
|
1922
|
+
const remove = (key) => {
|
|
1923
|
+
const targets = key === void 0 ? entries.filter((entry) => !entry.leaving) : entries.filter((entry) => entry.key === key && !entry.leaving);
|
|
1924
|
+
if (!targets.length) return;
|
|
1925
|
+
targets.forEach((entry) => {
|
|
1926
|
+
const timer = timers.get(entry.key);
|
|
1927
|
+
if (timer) clearTimeout(timer);
|
|
1928
|
+
timers.delete(entry.key);
|
|
1929
|
+
entry.leaving = true;
|
|
1930
|
+
leaveTimers.set(
|
|
1931
|
+
entry.key,
|
|
1932
|
+
setTimeout(() => {
|
|
1933
|
+
leaveTimers.delete(entry.key);
|
|
1934
|
+
entries = entries.filter(
|
|
1935
|
+
(item) => item.key !== entry.key || item !== entry
|
|
1936
|
+
);
|
|
1937
|
+
entry.close();
|
|
1938
|
+
entry.onClose?.();
|
|
1939
|
+
publish();
|
|
1940
|
+
}, LEAVE_DURATION)
|
|
1941
|
+
);
|
|
1942
|
+
});
|
|
1943
|
+
publish();
|
|
1944
|
+
};
|
|
1945
|
+
const open = (config) => {
|
|
1946
|
+
const key = config.key ?? ++nextKey;
|
|
1947
|
+
const previous = entries.find((entry2) => entry2.key === key);
|
|
1948
|
+
const oldTimer = timers.get(key);
|
|
1949
|
+
if (oldTimer) clearTimeout(oldTimer);
|
|
1950
|
+
timers.delete(key);
|
|
1951
|
+
const leaveTimer = leaveTimers.get(key);
|
|
1952
|
+
if (leaveTimer) clearTimeout(leaveTimer);
|
|
1953
|
+
leaveTimers.delete(key);
|
|
1954
|
+
let resolve;
|
|
1955
|
+
const promise = previous ? void 0 : new Promise((done) => {
|
|
1956
|
+
resolve = done;
|
|
1957
|
+
});
|
|
1958
|
+
const close = previous?.close ?? resolve;
|
|
1959
|
+
const entry = {
|
|
1960
|
+
...config,
|
|
1961
|
+
key,
|
|
1962
|
+
type: config.type ?? "info",
|
|
1963
|
+
close
|
|
1964
|
+
};
|
|
1965
|
+
entries = previous ? entries.map((item) => item.key === key ? entry : item) : [...entries, entry];
|
|
1966
|
+
if (options.maxCount && entries.filter((item) => !item.leaving).length > options.maxCount) {
|
|
1967
|
+
const oldest = entries.find((item) => item.key !== key && !item.leaving);
|
|
1968
|
+
if (oldest && oldest.key !== key) remove(oldest.key);
|
|
1969
|
+
}
|
|
1970
|
+
const duration = config.duration ?? options.duration ?? (entry.type === "loading" ? 0 : 3);
|
|
1971
|
+
if (duration > 0)
|
|
1972
|
+
timers.set(
|
|
1973
|
+
key,
|
|
1974
|
+
setTimeout(() => remove(key), duration * 1e3)
|
|
1975
|
+
);
|
|
1976
|
+
publish();
|
|
1977
|
+
const handle = (() => remove(key));
|
|
1978
|
+
handle.then = (onFulfilled, onRejected) => (promise ?? new Promise((done) => {
|
|
1979
|
+
const current = entries.find((item) => item.key === key);
|
|
1980
|
+
if (!current) done();
|
|
1981
|
+
else {
|
|
1982
|
+
const originalClose = current.close;
|
|
1983
|
+
current.close = () => {
|
|
1984
|
+
originalClose();
|
|
1985
|
+
done();
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
})).then(onFulfilled, onRejected);
|
|
1989
|
+
return handle;
|
|
1990
|
+
};
|
|
1991
|
+
const level = (type) => (content, duration, onClose) => open(
|
|
1992
|
+
isConfig(content) ? { ...content, type } : { content, type, duration, onClose }
|
|
1993
|
+
);
|
|
1994
|
+
const api = {
|
|
1995
|
+
open,
|
|
1996
|
+
info: level("info"),
|
|
1997
|
+
success: level("success"),
|
|
1998
|
+
warning: level("warning"),
|
|
1999
|
+
error: level("error"),
|
|
2000
|
+
loading: level("loading"),
|
|
2001
|
+
destroy: remove,
|
|
2002
|
+
config(next) {
|
|
2003
|
+
options = { ...options, ...next };
|
|
2004
|
+
publish();
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
return {
|
|
2008
|
+
api,
|
|
2009
|
+
getEntries: () => entries,
|
|
2010
|
+
getOptions: () => options,
|
|
2011
|
+
subscribe(listener) {
|
|
2012
|
+
listeners2.add(listener);
|
|
2013
|
+
return () => {
|
|
2014
|
+
listeners2.delete(listener);
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
};
|
|
2018
|
+
}
|
|
2019
|
+
function isConfig(value) {
|
|
2020
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && "content" in value;
|
|
2021
|
+
}
|
|
2022
|
+
function MessageHolder({ store }) {
|
|
2023
|
+
const [, refresh] = React.useState(0);
|
|
2024
|
+
React.useEffect(() => {
|
|
2025
|
+
refresh((value) => value + 1);
|
|
2026
|
+
return store.subscribe(() => refresh((value) => value + 1));
|
|
2027
|
+
}, [store]);
|
|
2028
|
+
const options = store.getOptions();
|
|
2029
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2030
|
+
"div",
|
|
2031
|
+
{
|
|
2032
|
+
className: `${REACT_COMPONENT_PREFIX}-message-host`,
|
|
2033
|
+
style: { top: options.top ?? 8 },
|
|
2034
|
+
role: "status",
|
|
2035
|
+
"aria-live": "polite",
|
|
2036
|
+
children: store.getEntries().map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2037
|
+
"div",
|
|
2038
|
+
{
|
|
2039
|
+
className: [
|
|
2040
|
+
`${REACT_COMPONENT_PREFIX}-message`,
|
|
2041
|
+
`${REACT_COMPONENT_PREFIX}-message-${entry.type}`,
|
|
2042
|
+
entry.leaving && `${REACT_COMPONENT_PREFIX}-message-leaving`,
|
|
2043
|
+
entry.className
|
|
2044
|
+
].filter(Boolean).join(" "),
|
|
2045
|
+
style: entry.style,
|
|
2046
|
+
onClick: entry.onClick,
|
|
2047
|
+
children: [
|
|
2048
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2049
|
+
"span",
|
|
2050
|
+
{
|
|
2051
|
+
className: `${REACT_COMPONENT_PREFIX}-message-icon`,
|
|
2052
|
+
"aria-hidden": "true",
|
|
2053
|
+
children: entry.icon ?? /* @__PURE__ */ jsxRuntime.jsx(MessageIcon, { type: entry.type })
|
|
2054
|
+
}
|
|
2055
|
+
),
|
|
2056
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: entry.content })
|
|
2057
|
+
]
|
|
2058
|
+
},
|
|
2059
|
+
entry.key
|
|
2060
|
+
))
|
|
2061
|
+
}
|
|
2062
|
+
);
|
|
2063
|
+
}
|
|
2064
|
+
function MessageIcon({ type }) {
|
|
2065
|
+
if (type === "loading")
|
|
2066
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-message-spinner` });
|
|
2067
|
+
const path = type === "success" ? "M5 12l4 4L19 6" : type === "error" ? "M6 6l12 12M18 6L6 18" : type === "warning" ? "M12 7v6m0 4h.01" : "M12 11v6m0-10h.01";
|
|
2068
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2069
|
+
"svg",
|
|
2070
|
+
{
|
|
2071
|
+
viewBox: "0 0 24 24",
|
|
2072
|
+
fill: "none",
|
|
2073
|
+
stroke: "currentColor",
|
|
2074
|
+
strokeWidth: "2.4",
|
|
2075
|
+
strokeLinecap: "round",
|
|
2076
|
+
strokeLinejoin: "round",
|
|
2077
|
+
children: [
|
|
2078
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2079
|
+
"circle",
|
|
2080
|
+
{
|
|
2081
|
+
cx: "12",
|
|
2082
|
+
cy: "12",
|
|
2083
|
+
r: "10",
|
|
2084
|
+
fill: "currentColor",
|
|
2085
|
+
stroke: "none",
|
|
2086
|
+
opacity: ".12"
|
|
2087
|
+
}
|
|
2088
|
+
),
|
|
2089
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: path })
|
|
2090
|
+
]
|
|
2091
|
+
}
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
var staticStore;
|
|
2095
|
+
var staticRootMounted = false;
|
|
2096
|
+
var staticHost;
|
|
2097
|
+
function resolveMessageContainer(value) {
|
|
2098
|
+
return (typeof value === "function" ? value() : value) ?? document.body;
|
|
2099
|
+
}
|
|
2100
|
+
function getStaticStore() {
|
|
2101
|
+
if (!staticStore) staticStore = createMessageStore();
|
|
2102
|
+
if (typeof document !== "undefined" && !staticRootMounted) {
|
|
2103
|
+
const host = document.createElement("div");
|
|
2104
|
+
host.id = `${REACT_COMPONENT_PREFIX}-message-root`;
|
|
2105
|
+
resolveMessageContainer(staticStore.getOptions().getContainer).appendChild(
|
|
2106
|
+
host
|
|
2107
|
+
);
|
|
2108
|
+
staticHost = host;
|
|
2109
|
+
staticRootMounted = true;
|
|
2110
|
+
if (typeof ReactDOM__namespace.render === "function") {
|
|
2111
|
+
ReactDOM__namespace.render(/* @__PURE__ */ jsxRuntime.jsx(MessageHolder, { store: staticStore }), host);
|
|
2112
|
+
} else {
|
|
2113
|
+
void import('react-dom/client').then(({ createRoot }) => {
|
|
2114
|
+
createRoot(host).render(/* @__PURE__ */ jsxRuntime.jsx(MessageHolder, { store: staticStore }));
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
} else if (staticHost && !staticHost.isConnected) {
|
|
2118
|
+
resolveMessageContainer(staticStore.getOptions().getContainer).appendChild(
|
|
2119
|
+
staticHost
|
|
2120
|
+
);
|
|
2121
|
+
}
|
|
2122
|
+
return staticStore;
|
|
2123
|
+
}
|
|
2124
|
+
var reactMessage = {
|
|
2125
|
+
open: (config) => getStaticStore().api.open(config),
|
|
2126
|
+
info: (content, duration, onClose) => getStaticStore().api.info(content, duration, onClose),
|
|
2127
|
+
success: (content, duration, onClose) => getStaticStore().api.success(content, duration, onClose),
|
|
2128
|
+
warning: (content, duration, onClose) => getStaticStore().api.warning(content, duration, onClose),
|
|
2129
|
+
error: (content, duration, onClose) => getStaticStore().api.error(content, duration, onClose),
|
|
2130
|
+
loading: (content, duration, onClose) => getStaticStore().api.loading(content, duration, onClose),
|
|
2131
|
+
destroy: (key) => getStaticStore().api.destroy(key),
|
|
2132
|
+
config: (options) => {
|
|
2133
|
+
const store = getStaticStore();
|
|
2134
|
+
store.api.config(options);
|
|
2135
|
+
if (staticHost && typeof document !== "undefined") {
|
|
2136
|
+
const container = resolveMessageContainer(
|
|
2137
|
+
store.getOptions().getContainer
|
|
2138
|
+
);
|
|
2139
|
+
if (staticHost.parentElement !== container)
|
|
2140
|
+
container.appendChild(staticHost);
|
|
2141
|
+
}
|
|
2142
|
+
},
|
|
2143
|
+
/** 创建能读取调用位置 React Context 的消息实例。 */
|
|
2144
|
+
useMessage: (options) => useReactMessage(options)
|
|
2145
|
+
};
|
|
2146
|
+
function useReactMessage(options) {
|
|
2147
|
+
const store = React.useMemo(() => createMessageStore(options), []);
|
|
2148
|
+
React.useEffect(() => () => store.api.destroy(), [store]);
|
|
2149
|
+
const holder = /* @__PURE__ */ jsxRuntime.jsx(MessageHolder, { store }, "message-holder");
|
|
2150
|
+
return [
|
|
2151
|
+
store.api,
|
|
2152
|
+
options?.getContainer && typeof document !== "undefined" ? ReactDOM__namespace.createPortal(
|
|
2153
|
+
holder,
|
|
2154
|
+
resolveMessageContainer(options.getContainer)
|
|
2155
|
+
) : holder
|
|
2156
|
+
];
|
|
2157
|
+
}
|
|
2158
|
+
function ReactButton({
|
|
2159
|
+
children,
|
|
2160
|
+
className,
|
|
2161
|
+
danger,
|
|
2162
|
+
htmlType = "button",
|
|
2163
|
+
icon,
|
|
2164
|
+
size = "middle",
|
|
2165
|
+
type = "default",
|
|
2166
|
+
...props
|
|
2167
|
+
}) {
|
|
2168
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2169
|
+
"button",
|
|
2170
|
+
{
|
|
2171
|
+
...props,
|
|
2172
|
+
type: htmlType,
|
|
2173
|
+
className: joinClassNames(
|
|
2174
|
+
`${REACT_COMPONENT_PREFIX}-button`,
|
|
2175
|
+
`${REACT_COMPONENT_PREFIX}-button-${type}`,
|
|
2176
|
+
`${REACT_COMPONENT_PREFIX}-button-${size}`,
|
|
2177
|
+
danger && `${REACT_COMPONENT_PREFIX}-button-danger`,
|
|
2178
|
+
className
|
|
2179
|
+
),
|
|
2180
|
+
children: [
|
|
2181
|
+
icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-button-icon`, children: icon }) : null,
|
|
2182
|
+
children
|
|
2183
|
+
]
|
|
2184
|
+
}
|
|
2185
|
+
);
|
|
2186
|
+
}
|
|
2187
|
+
function ReactFlex({
|
|
2188
|
+
vertical,
|
|
2189
|
+
justify,
|
|
2190
|
+
align,
|
|
2191
|
+
gap,
|
|
2192
|
+
style,
|
|
2193
|
+
...props
|
|
2194
|
+
}) {
|
|
2195
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2196
|
+
"div",
|
|
2197
|
+
{
|
|
2198
|
+
...props,
|
|
2199
|
+
style: {
|
|
2200
|
+
display: "flex",
|
|
2201
|
+
flexDirection: vertical ? "column" : "row",
|
|
2202
|
+
justifyContent: justify,
|
|
2203
|
+
alignItems: align,
|
|
2204
|
+
gap,
|
|
2205
|
+
...style
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
function ReactRow({ gutter = 0, style, ...props }) {
|
|
2211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2212
|
+
"div",
|
|
2213
|
+
{
|
|
2214
|
+
...props,
|
|
2215
|
+
className: joinClassNames(
|
|
2216
|
+
`${REACT_COMPONENT_PREFIX}-row`,
|
|
2217
|
+
props.className
|
|
2218
|
+
),
|
|
2219
|
+
style: { marginInline: -gutter / 2, ...style }
|
|
2220
|
+
}
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
function ReactCol({ span = 24, style, ...props }) {
|
|
2224
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2225
|
+
"div",
|
|
2226
|
+
{
|
|
2227
|
+
...props,
|
|
2228
|
+
className: joinClassNames(
|
|
2229
|
+
`${REACT_COMPONENT_PREFIX}-col`,
|
|
2230
|
+
props.className
|
|
2231
|
+
),
|
|
2232
|
+
style: {
|
|
2233
|
+
flex: `0 0 ${span / 24 * 100}%`,
|
|
2234
|
+
maxWidth: `${span / 24 * 100}%`,
|
|
2235
|
+
...style
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
);
|
|
2239
|
+
}
|
|
2240
|
+
var RadioGroupContext = React.createContext({});
|
|
2241
|
+
function ReactRadioOption({
|
|
2242
|
+
value,
|
|
2243
|
+
checked,
|
|
2244
|
+
disabled,
|
|
2245
|
+
onChange,
|
|
2246
|
+
children,
|
|
2247
|
+
className,
|
|
2248
|
+
...props
|
|
2249
|
+
}) {
|
|
2250
|
+
const group = React.useContext(RadioGroupContext);
|
|
2251
|
+
const selected = checked ?? String(group.value ?? "") === String(value);
|
|
2252
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2253
|
+
"label",
|
|
2254
|
+
{
|
|
2255
|
+
...props,
|
|
2256
|
+
className: joinClassNames(
|
|
2257
|
+
`${REACT_COMPONENT_PREFIX}-radio`,
|
|
2258
|
+
disabled && `${REACT_COMPONENT_PREFIX}-radio-disabled`,
|
|
2259
|
+
className
|
|
2260
|
+
),
|
|
2261
|
+
children: [
|
|
2262
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2263
|
+
"input",
|
|
2264
|
+
{
|
|
2265
|
+
type: "radio",
|
|
2266
|
+
checked: selected,
|
|
2267
|
+
disabled,
|
|
2268
|
+
onChange: () => {
|
|
2269
|
+
const event = { target: { value } };
|
|
2270
|
+
onChange?.(event);
|
|
2271
|
+
group.onChange?.(event);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
),
|
|
2275
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `${REACT_COMPONENT_PREFIX}-radio-mark` }),
|
|
2276
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children })
|
|
2277
|
+
]
|
|
2278
|
+
}
|
|
2279
|
+
);
|
|
2280
|
+
}
|
|
2281
|
+
function ReactRadioGroup({
|
|
2282
|
+
value,
|
|
2283
|
+
onChange,
|
|
2284
|
+
className,
|
|
2285
|
+
...props
|
|
2286
|
+
}) {
|
|
2287
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupContext.Provider, { value: { value, onChange }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2288
|
+
"div",
|
|
2289
|
+
{
|
|
2290
|
+
...props,
|
|
2291
|
+
className: joinClassNames(
|
|
2292
|
+
`${REACT_COMPONENT_PREFIX}-radio-group`,
|
|
2293
|
+
className
|
|
2294
|
+
)
|
|
2295
|
+
}
|
|
2296
|
+
) });
|
|
2297
|
+
}
|
|
2298
|
+
var ReactRadio = Object.assign(ReactRadioOption, {
|
|
2299
|
+
Group: ReactRadioGroup
|
|
2300
|
+
});
|
|
2301
|
+
function ReactTextArea({ className, ...props }) {
|
|
2302
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2303
|
+
"textarea",
|
|
2304
|
+
{
|
|
2305
|
+
...props,
|
|
2306
|
+
className: joinClassNames(
|
|
2307
|
+
`${REACT_COMPONENT_PREFIX}-textarea`,
|
|
2308
|
+
className
|
|
2309
|
+
)
|
|
2310
|
+
}
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2289
2314
|
// src/components/input-number/style.css
|
|
2290
2315
|
styleInject('@import "../../styles/variables.css";\n.canvas-react-input-number {\n box-sizing: border-box;\n display: inline-flex;\n align-items: stretch;\n width: 100%;\n min-width: 0;\n height: var(--canvas-react-control-height);\n border: 1px solid var(--canvas-react-color-border);\n border-radius: var(--canvas-react-radius-sm);\n background: var(--canvas-react-color-bg);\n color: var(--canvas-react-color-text);\n font-size: var(--canvas-react-font-size);\n text-align: left;\n overflow: hidden;\n transition:\n border-color 0.2s ease,\n box-shadow 0.2s ease,\n background-color 0.2s ease;\n}\n.canvas-react-input-number:hover {\n border-color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-input-number-focused {\n border-color: var(--canvas-react-color-primary);\n box-shadow: var(--canvas-react-shadow-focus);\n}\n.canvas-react-input-number-disabled {\n background: #fafafa;\n color: #9ca3af;\n cursor: not-allowed;\n}\n.canvas-react-input-number-handler {\n position: relative;\n display: flex;\n flex: 0 0 28px;\n align-items: center;\n justify-content: center;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n color: var(--canvas-react-color-text-muted);\n cursor: pointer;\n transition: color 0.16s ease, background-color 0.16s ease;\n}\n.canvas-react-input-number-handler-down {\n border-right: 1px solid var(--canvas-react-color-border);\n}\n.canvas-react-input-number-handler-up {\n border-left: 1px solid var(--canvas-react-color-border);\n}\n.canvas-react-input-number-handler:hover:not(:disabled) {\n color: var(--canvas-react-color-primary);\n background: rgba(22, 119, 255, 0.06);\n}\n.canvas-react-input-number-handler:disabled {\n color: #c4c7cf;\n cursor: not-allowed;\n}\n.canvas-react-input-number-handler-icon {\n position: relative;\n display: block;\n width: 10px;\n height: 10px;\n}\n.canvas-react-input-number-handler-icon::before,\n.canvas-react-input-number-handler-icon::after {\n content: "";\n position: absolute;\n top: 50%;\n left: 50%;\n background: currentColor;\n border-radius: 1px;\n transform: translate(-50%, -50%);\n}\n.canvas-react-input-number-handler-icon::before {\n width: 10px;\n height: 1.5px;\n}\n.canvas-react-input-number-handler-up .canvas-react-input-number-handler-icon::after {\n width: 1.5px;\n height: 10px;\n}\n.canvas-react-input-number-input-wrap {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n min-width: 0;\n height: 100%;\n}\n.canvas-react-input-number-input {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 100%;\n padding: 0 var(--canvas-react-control-padding-inline, 8px);\n border: none;\n background: transparent;\n color: inherit;\n font-size: inherit;\n outline: none;\n text-align: inherit;\n appearance: textfield;\n -moz-appearance: textfield;\n}\n.canvas-react-input-number-input::placeholder {\n color: #9ca3af;\n}\n.canvas-react-input-number-input::-webkit-outer-spin-button,\n.canvas-react-input-number-input::-webkit-inner-spin-button {\n margin: 0;\n -webkit-appearance: none;\n}\n.canvas-react-input-number-addon {\n flex: 0 0 auto;\n padding-right: 8px;\n color: var(--canvas-react-color-text-muted);\n font-size: 12px;\n line-height: 1;\n user-select: none;\n}\n');
|
|
2291
2316
|
var ReactInputNumber = React.forwardRef(
|
|
@@ -3553,6 +3578,7 @@ var ReactSelect = React.forwardRef(
|
|
|
3553
3578
|
onFocus,
|
|
3554
3579
|
onKeyDown,
|
|
3555
3580
|
options,
|
|
3581
|
+
renderOptionExtra,
|
|
3556
3582
|
optionHeight = 32,
|
|
3557
3583
|
listHeight = 224,
|
|
3558
3584
|
placeholder,
|
|
@@ -3748,7 +3774,10 @@ var ReactSelect = React.forwardRef(
|
|
|
3748
3774
|
openSelect();
|
|
3749
3775
|
return;
|
|
3750
3776
|
}
|
|
3751
|
-
const targetOption = resolveSelectEnterOption(
|
|
3777
|
+
const targetOption = resolveSelectEnterOption(
|
|
3778
|
+
filteredOptions,
|
|
3779
|
+
activeIndex
|
|
3780
|
+
);
|
|
3752
3781
|
if (targetOption && !targetOption.disabled) {
|
|
3753
3782
|
selectOption(targetOption, "keyboard");
|
|
3754
3783
|
} else if (allowCustomValue && keyword.trim()) {
|
|
@@ -3838,7 +3867,7 @@ var ReactSelect = React.forwardRef(
|
|
|
3838
3867
|
const isSelected = String(option.value) === String(value ?? "");
|
|
3839
3868
|
const isActive = optionIndex === activeIndex;
|
|
3840
3869
|
const isSearching = showSearch && searchKeyword.trim().length > 0;
|
|
3841
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
3870
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3842
3871
|
"div",
|
|
3843
3872
|
{
|
|
3844
3873
|
className: joinClassNames(
|
|
@@ -3861,17 +3890,20 @@ var ReactSelect = React.forwardRef(
|
|
|
3861
3890
|
}
|
|
3862
3891
|
selectOption(option, "mouse");
|
|
3863
3892
|
},
|
|
3864
|
-
children:
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3893
|
+
children: [
|
|
3894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3895
|
+
"span",
|
|
3896
|
+
{
|
|
3897
|
+
className: `${REACT_COMPONENT_PREFIX}-select-option-label`,
|
|
3898
|
+
title: option.label,
|
|
3899
|
+
children: renderSelectOptionLabel(
|
|
3900
|
+
option.label,
|
|
3901
|
+
showSearch ? searchKeyword : ""
|
|
3902
|
+
)
|
|
3903
|
+
}
|
|
3904
|
+
),
|
|
3905
|
+
renderOptionExtra?.(option)
|
|
3906
|
+
]
|
|
3875
3907
|
},
|
|
3876
3908
|
String(option.value)
|
|
3877
3909
|
);
|
|
@@ -3912,7 +3944,8 @@ function scoreSelectMatch(text, search) {
|
|
|
3912
3944
|
return (index === 0 ? 2 : 1) + search.length / normalized.length;
|
|
3913
3945
|
}
|
|
3914
3946
|
function resolveSelectEnterOption(options, activeIndex = -1) {
|
|
3915
|
-
if (options[activeIndex] && !options[activeIndex].disabled)
|
|
3947
|
+
if (options[activeIndex] && !options[activeIndex].disabled)
|
|
3948
|
+
return options[activeIndex];
|
|
3916
3949
|
return options.find((option) => !option.disabled);
|
|
3917
3950
|
}
|
|
3918
3951
|
function resolveSelectKeywordOnOpen(selectedLabel) {
|
|
@@ -9495,15 +9528,19 @@ function ReactScrollbarPositionDialog(props) {
|
|
|
9495
9528
|
}
|
|
9496
9529
|
|
|
9497
9530
|
// src/components/pagination/style.css
|
|
9498
|
-
styleInject('@import "../../styles/variables.css";\n.canvas-react-pagination {\n --canvas-react-pagination-control-size: 32px;\n --canvas-react-pagination-gap: 8px;\n --canvas-react-pagination-padding-inline: 10px;\n --canvas-react-control-height: var(--canvas-react-pagination-control-size);\n display: flex;\n align-items: center;\n flex-wrap: nowrap;\n gap: var(--canvas-react-pagination-gap);\n color: var(--canvas-react-color-text);\n font-size: var(--canvas-react-font-size);\n white-space: nowrap;\n}\n.canvas-react-pagination-small {\n --canvas-react-pagination-control-size: 24px;\n --canvas-react-pagination-gap: 4px;\n --canvas-react-pagination-padding-inline: 6px;\n}\n.canvas-react-pagination > .canvas-react-select-wrap {\n flex: 0 0 auto;\n width: auto;\n height: auto;\n}\n.canvas-react-pagination > .canvas-react-select-wrap > .canvas-react-select {\n flex-shrink: 0;\n}\n.canvas-react-pagination-large {\n --canvas-react-pagination-control-size: 40px;\n --canvas-react-pagination-gap: 10px;\n --canvas-react-pagination-padding-inline: 14px;\n}\n.canvas-react-pagination-pages {\n display: inline-flex;\n align-items: center;\n gap: var(--canvas-react-pagination-gap);\n flex-wrap: nowrap;\n}\n.canvas-react-pagination-button,\n.canvas-react-pagination-page {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: var(--canvas-react-pagination-control-size);\n height: var(--canvas-react-pagination-control-size);\n padding: 0 var(--canvas-react-pagination-padding-inline);\n border: 1px solid var(--canvas-react-color-border);\n border-radius: var(--canvas-react-radius-sm);\n background: var(--canvas-react-color-bg);\n color: var(--canvas-react-color-text);\n cursor: pointer;\n transition:\n border-color 0.2s ease,\n color 0.2s ease,\n background-color 0.2s ease;\n}\n.canvas-react-pagination-button {\n position: relative;\n width: var(--canvas-react-pagination-control-size);\n min-width: var(--canvas-react-pagination-control-size);\n padding: 0;\n}\n.canvas-react-pagination-button:hover,\n.canvas-react-pagination-page:hover {\n border-color: var(--canvas-react-color-primary-hover);\n color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-pagination-page-active {\n border-color: var(--canvas-react-color-primary);\n background: var(--canvas-react-color-bg-active);\n color: var(--canvas-react-color-primary);\n}\n.canvas-react-pagination-button:disabled,\n.canvas-react-pagination-page:disabled {\n opacity: 0.48;\n cursor: not-allowed;\n}\n.canvas-react-pagination-ellipsis {\n color: var(--canvas-react-color-text-muted);\n}\n.canvas-react-pagination-arrow {\n position: absolute;\n top: 50%;\n left: 50%;\n width: 7px;\n height: 7px;\n border-right: 1.5px solid var(--canvas-react-color-text-muted);\n border-bottom: 1.5px solid var(--canvas-react-color-text-muted);\n transition:\n border-color 0.18s ease,\n transform 0.18s ease,\n opacity 0.18s ease;\n}\n.canvas-react-pagination-arrow-prev {\n transform: translate(-42%, -50%) rotate(135deg);\n}\n.canvas-react-pagination-arrow-next {\n transform: translate(-58%, -50%) rotate(-45deg);\n}\n.canvas-react-pagination-button:hover .canvas-react-pagination-arrow {\n border-color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-pagination-button:disabled .canvas-react-pagination-arrow {\n opacity: 0.56;\n}\n.canvas-react-pagination-quick {\n display: inline-flex;\n align-items: center;\n gap: var(--canvas-react-pagination-gap);\n flex-wrap: nowrap;\n}\n.canvas-react-pagination-total {\n color: var(--canvas-react-color-text-muted);\n}\n.canvas-react-pagination button,\n.canvas-react-pagination input {\n font-family: inherit;\n font-weight: inherit;\n font-size: inherit;\n}\n');
|
|
9531
|
+
styleInject('@import "../../styles/variables.css";\n.canvas-react-pagination {\n --canvas-react-pagination-control-size: 32px;\n --canvas-react-pagination-gap: 8px;\n --canvas-react-pagination-padding-inline: 10px;\n --canvas-react-control-height: var(--canvas-react-pagination-control-size);\n display: flex;\n align-items: center;\n flex-wrap: nowrap;\n gap: var(--canvas-react-pagination-gap);\n color: var(--canvas-react-color-text);\n font-size: var(--canvas-react-font-size);\n white-space: nowrap;\n}\n.canvas-react-pagination-small {\n --canvas-react-pagination-control-size: 24px;\n --canvas-react-pagination-gap: 4px;\n --canvas-react-pagination-padding-inline: 6px;\n}\n.canvas-react-pagination > .canvas-react-select-wrap {\n flex: 0 0 auto;\n width: auto;\n height: auto;\n}\n.canvas-react-pagination > .canvas-react-select-wrap > .canvas-react-select {\n flex-shrink: 0;\n}\n.canvas-react-pagination-large {\n --canvas-react-pagination-control-size: 40px;\n --canvas-react-pagination-gap: 10px;\n --canvas-react-pagination-padding-inline: 14px;\n}\n.canvas-react-pagination-pages {\n display: inline-flex;\n align-items: center;\n gap: var(--canvas-react-pagination-gap);\n flex-wrap: nowrap;\n}\n.canvas-react-pagination-button,\n.canvas-react-pagination-page {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: var(--canvas-react-pagination-control-size);\n height: var(--canvas-react-pagination-control-size);\n padding: 0 var(--canvas-react-pagination-padding-inline);\n border: 1px solid var(--canvas-react-color-border);\n border-radius: var(--canvas-react-radius-sm);\n background: var(--canvas-react-color-bg);\n color: var(--canvas-react-color-text);\n cursor: pointer;\n transition:\n border-color 0.2s ease,\n color 0.2s ease,\n background-color 0.2s ease;\n}\n.canvas-react-pagination-button {\n position: relative;\n width: var(--canvas-react-pagination-control-size);\n min-width: var(--canvas-react-pagination-control-size);\n padding: 0;\n}\n.canvas-react-pagination-button:hover,\n.canvas-react-pagination-page:hover {\n border-color: var(--canvas-react-color-primary-hover);\n color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-pagination-page-active {\n border-color: var(--canvas-react-color-primary);\n background: var(--canvas-react-color-bg-active);\n color: var(--canvas-react-color-primary);\n}\n.canvas-react-pagination-button:disabled,\n.canvas-react-pagination-page:disabled {\n opacity: 0.48;\n cursor: not-allowed;\n}\n.canvas-react-pagination-ellipsis {\n color: var(--canvas-react-color-text-muted);\n}\n.canvas-react-pagination-arrow {\n position: absolute;\n top: 50%;\n left: 50%;\n width: 7px;\n height: 7px;\n border-right: 1.5px solid var(--canvas-react-color-text-muted);\n border-bottom: 1.5px solid var(--canvas-react-color-text-muted);\n transition:\n border-color 0.18s ease,\n transform 0.18s ease,\n opacity 0.18s ease;\n}\n.canvas-react-pagination-arrow-prev {\n transform: translate(-42%, -50%) rotate(135deg);\n}\n.canvas-react-pagination-arrow-next {\n transform: translate(-58%, -50%) rotate(-45deg);\n}\n.canvas-react-pagination-button:hover .canvas-react-pagination-arrow {\n border-color: var(--canvas-react-color-primary-hover);\n}\n.canvas-react-pagination-button:disabled .canvas-react-pagination-arrow {\n opacity: 0.56;\n}\n.canvas-react-pagination-quick {\n display: inline-flex;\n align-items: center;\n gap: var(--canvas-react-pagination-gap);\n flex-wrap: nowrap;\n}\n.canvas-react-pagination-total {\n color: var(--canvas-react-color-text-muted);\n}\n.canvas-react-pagination button,\n.canvas-react-pagination input {\n font-family: inherit;\n font-weight: inherit;\n font-size: inherit;\n}\n.canvas-react-pagination-remove-size {\n flex: 0 0 auto;\n margin-left: 6px;\n padding: 0 4px;\n border: 0;\n border-radius: var(--canvas-react-radius-sm);\n background: transparent;\n color: var(--canvas-react-color-text-muted);\n font: inherit;\n cursor: pointer;\n}\n.canvas-react-pagination-remove-size:hover,\n.canvas-react-pagination-remove-size:focus-visible {\n background: var(--canvas-react-color-bg-hover);\n color: var(--canvas-react-color-primary);\n}\n.canvas-react-pagination-remove-size:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n');
|
|
9532
|
+
var DEFAULT_PAGE_SIZE = 10;
|
|
9499
9533
|
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
9500
9534
|
function ReactPagination(props) {
|
|
9501
9535
|
const {
|
|
9536
|
+
allowPageSizeInput = false,
|
|
9537
|
+
minPageSize = 1,
|
|
9538
|
+
maxPageSize = Number.MAX_SAFE_INTEGER,
|
|
9502
9539
|
current,
|
|
9503
9540
|
disabled,
|
|
9504
9541
|
onChange,
|
|
9505
9542
|
onPageSizeChange,
|
|
9506
|
-
pageSize =
|
|
9543
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
9507
9544
|
pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
|
|
9508
9545
|
showLessItems,
|
|
9509
9546
|
showQuickJumper,
|
|
@@ -9517,12 +9554,56 @@ function ReactPagination(props) {
|
|
|
9517
9554
|
} = props;
|
|
9518
9555
|
const style = { ...rootStyle, ...styles?.root };
|
|
9519
9556
|
const [quickValue, setQuickValue] = React.useState("");
|
|
9557
|
+
const [customPageSizes, setCustomPageSizes] = React.useState([]);
|
|
9558
|
+
const pageSizeDraft = React.useRef(null);
|
|
9559
|
+
const sizeChangerRef = React.useRef(null);
|
|
9560
|
+
const minimum = Number.isSafeInteger(minPageSize) && minPageSize > 0 ? minPageSize : 1;
|
|
9561
|
+
const maximum = Number.isSafeInteger(maxPageSize) && maxPageSize > 0 ? Math.max(minimum, maxPageSize) : Number.MAX_SAFE_INTEGER;
|
|
9562
|
+
const defaultPageSize = Math.min(
|
|
9563
|
+
maximum,
|
|
9564
|
+
Math.max(minimum, DEFAULT_PAGE_SIZE)
|
|
9565
|
+
);
|
|
9566
|
+
const isValidPageSize = (value) => Number.isSafeInteger(value) && value >= minimum && value <= maximum;
|
|
9520
9567
|
const resolvedPageSizeOptions = React.useMemo(() => {
|
|
9521
|
-
|
|
9522
|
-
|
|
9568
|
+
const options = allowPageSizeInput ? [.../* @__PURE__ */ new Set([...pageSizeOptions, ...customPageSizes])].sort(
|
|
9569
|
+
(a, b) => a - b
|
|
9570
|
+
) : pageSizeOptions;
|
|
9571
|
+
if (options.length === 0 && !allowPageSizeInput || options.includes(pageSize) || !Number.isSafeInteger(pageSize) || pageSize <= 0) {
|
|
9572
|
+
return options;
|
|
9573
|
+
}
|
|
9574
|
+
return [...options, pageSize].sort((left, right) => left - right);
|
|
9575
|
+
}, [pageSizeOptions, pageSize, customPageSizes, allowPageSizeInput]);
|
|
9576
|
+
const changePageSize = (value) => {
|
|
9577
|
+
pageSizeDraft.current = null;
|
|
9578
|
+
if (disabled || !isValidPageSize(value)) return;
|
|
9579
|
+
if (allowPageSizeInput) {
|
|
9580
|
+
setCustomPageSizes(
|
|
9581
|
+
(sizes) => sizes.includes(value) ? sizes : [...sizes, value]
|
|
9582
|
+
);
|
|
9583
|
+
}
|
|
9584
|
+
onPageSizeChange?.(1, value);
|
|
9585
|
+
};
|
|
9586
|
+
const removeCustomPageSize = (value) => {
|
|
9587
|
+
if (disabled) return;
|
|
9588
|
+
pageSizeDraft.current = null;
|
|
9589
|
+
sizeChangerRef.current?.blur();
|
|
9590
|
+
setCustomPageSizes((sizes) => sizes.filter((size2) => size2 !== value));
|
|
9591
|
+
if (value === pageSize) {
|
|
9592
|
+
onPageSizeChange?.(1, defaultPageSize);
|
|
9523
9593
|
}
|
|
9524
|
-
|
|
9525
|
-
|
|
9594
|
+
};
|
|
9595
|
+
const commitPageSizeInput = () => {
|
|
9596
|
+
const draft = pageSizeDraft.current;
|
|
9597
|
+
pageSizeDraft.current = null;
|
|
9598
|
+
if (!allowPageSizeInput || draft == null || !/^\d+$/.test(draft.trim()))
|
|
9599
|
+
return;
|
|
9600
|
+
changePageSize(Number(draft.trim()));
|
|
9601
|
+
};
|
|
9602
|
+
const pageSizeSelectOptions = resolvedPageSizeOptions.map((size2) => ({
|
|
9603
|
+
label: `${size2} / \u9875`,
|
|
9604
|
+
value: size2,
|
|
9605
|
+
...!isValidPageSize(size2) ? { disabled: true } : {}
|
|
9606
|
+
}));
|
|
9526
9607
|
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
9527
9608
|
const safeCurrent = clampPage(current, totalPages);
|
|
9528
9609
|
const range = total === 0 ? [0, 0] : [
|
|
@@ -9654,26 +9735,65 @@ function ReactPagination(props) {
|
|
|
9654
9735
|
)
|
|
9655
9736
|
}
|
|
9656
9737
|
),
|
|
9657
|
-
showSizeChanger && resolvedPageSizeOptions.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9738
|
+
showSizeChanger && (allowPageSizeInput || resolvedPageSizeOptions.length) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9658
9739
|
ReactSelect,
|
|
9659
9740
|
{
|
|
9741
|
+
ref: sizeChangerRef,
|
|
9660
9742
|
value: String(pageSize),
|
|
9661
9743
|
disabled,
|
|
9744
|
+
"aria-label": "\u6BCF\u9875\u6761\u6570",
|
|
9745
|
+
allowClear: false,
|
|
9746
|
+
showSearch: allowPageSizeInput,
|
|
9747
|
+
allowCustomValue: allowPageSizeInput,
|
|
9748
|
+
inputMode: allowPageSizeInput ? "numeric" : void 0,
|
|
9749
|
+
onInputValueChange: (value) => {
|
|
9750
|
+
pageSizeDraft.current = value;
|
|
9751
|
+
},
|
|
9752
|
+
onKeyDown: (event) => {
|
|
9753
|
+
if (event.key === "Escape") pageSizeDraft.current = null;
|
|
9754
|
+
if ((event.key === "ArrowDown" || event.key === "ArrowUp") && pageSizeDraft.current != null && filterSelectOptions(
|
|
9755
|
+
pageSizeSelectOptions,
|
|
9756
|
+
pageSizeDraft.current,
|
|
9757
|
+
true
|
|
9758
|
+
).some((option) => !option.disabled)) {
|
|
9759
|
+
pageSizeDraft.current = null;
|
|
9760
|
+
}
|
|
9761
|
+
if (allowPageSizeInput && event.key === "Enter" && pageSizeDraft.current != null) {
|
|
9762
|
+
event.preventDefault();
|
|
9763
|
+
commitPageSizeInput();
|
|
9764
|
+
event.currentTarget.blur();
|
|
9765
|
+
}
|
|
9766
|
+
},
|
|
9767
|
+
onBlur: () => commitPageSizeInput(),
|
|
9662
9768
|
style: {
|
|
9663
9769
|
width: resolvePaginationSelectWidth(size, resolvedPageSizeOptions),
|
|
9664
9770
|
...styles?.sizeChanger
|
|
9665
9771
|
},
|
|
9666
|
-
options:
|
|
9667
|
-
|
|
9668
|
-
value
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9772
|
+
options: pageSizeSelectOptions,
|
|
9773
|
+
renderOptionExtra: (option) => {
|
|
9774
|
+
const value = Number(option.value);
|
|
9775
|
+
if (!allowPageSizeInput || pageSizeOptions.includes(value) || value === defaultPageSize)
|
|
9776
|
+
return null;
|
|
9777
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9778
|
+
"button",
|
|
9779
|
+
{
|
|
9780
|
+
type: "button",
|
|
9781
|
+
className: `${REACT_COMPONENT_PREFIX}-pagination-remove-size`,
|
|
9782
|
+
"aria-label": `\u5220\u9664\u6BCF\u9875 ${value} \u6761`,
|
|
9783
|
+
disabled,
|
|
9784
|
+
onMouseDown: (event) => {
|
|
9785
|
+
event.preventDefault();
|
|
9786
|
+
event.stopPropagation();
|
|
9787
|
+
},
|
|
9788
|
+
onClick: (event) => {
|
|
9789
|
+
event.stopPropagation();
|
|
9790
|
+
removeCustomPageSize(value);
|
|
9791
|
+
},
|
|
9792
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\xD7" })
|
|
9793
|
+
}
|
|
9794
|
+
);
|
|
9795
|
+
},
|
|
9796
|
+
onChange: (value) => changePageSize(Number(value))
|
|
9677
9797
|
}
|
|
9678
9798
|
) : null,
|
|
9679
9799
|
showQuickJumper ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -10288,7 +10408,7 @@ function ReactPositionedTooltip(props) {
|
|
|
10288
10408
|
left: request.x,
|
|
10289
10409
|
top: request.y,
|
|
10290
10410
|
boxSizing: "border-box",
|
|
10291
|
-
maxWidth: request.variant === "resize" ? "calc(100vw - 16px)" : `min(${320 * zoom}px, calc(100vw - 16px))`,
|
|
10411
|
+
maxWidth: request.variant === "resize" || request.singleLine ? "calc(100vw - 16px)" : `min(${320 * zoom}px, calc(100vw - 16px))`,
|
|
10292
10412
|
maxHeight: "calc(100vh - 16px)",
|
|
10293
10413
|
padding: `${paddingBlock}px ${paddingInline}px`,
|
|
10294
10414
|
borderRadius: 6 * zoom,
|
|
@@ -10300,7 +10420,7 @@ function ReactPositionedTooltip(props) {
|
|
|
10300
10420
|
border: request.variant === "error" ? "1px solid rgba(255, 77, 79, 0.2)" : "none",
|
|
10301
10421
|
pointerEvents: "none",
|
|
10302
10422
|
zIndex: 1200,
|
|
10303
|
-
whiteSpace: request.variant === "resize" ? "nowrap" : "pre-wrap",
|
|
10423
|
+
whiteSpace: request.variant === "resize" || request.singleLine ? "nowrap" : "pre-wrap",
|
|
10304
10424
|
wordBreak: "break-word"
|
|
10305
10425
|
};
|
|
10306
10426
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: tooltipRef, role: "tooltip", style, children: [
|
|
@@ -10311,7 +10431,7 @@ function ReactPositionedTooltip(props) {
|
|
|
10311
10431
|
display: "block",
|
|
10312
10432
|
maxHeight: `calc(100vh - ${16 + 2 * paddingBlock + 2}px)`,
|
|
10313
10433
|
overflow: "hidden",
|
|
10314
|
-
textOverflow: request.variant === "resize" ? "ellipsis" : void 0
|
|
10434
|
+
textOverflow: request.variant === "resize" || request.singleLine ? "ellipsis" : void 0
|
|
10315
10435
|
},
|
|
10316
10436
|
children: request.content
|
|
10317
10437
|
}
|
|
@@ -11564,8 +11684,15 @@ function ReactCascader(props) {
|
|
|
11564
11684
|
const [focus, setFocus] = React.useState({ column: 0, index: -1 });
|
|
11565
11685
|
const interactive = !disabled && !readOnly;
|
|
11566
11686
|
React.useEffect(() => {
|
|
11567
|
-
|
|
11568
|
-
|
|
11687
|
+
if (multiple)
|
|
11688
|
+
setPath(
|
|
11689
|
+
(current) => resolvePath(
|
|
11690
|
+
options,
|
|
11691
|
+
current.map((item) => item.value)
|
|
11692
|
+
)
|
|
11693
|
+
);
|
|
11694
|
+
else setPath(selected);
|
|
11695
|
+
}, [selected, multiple, options]);
|
|
11569
11696
|
const displayPath = (valuePath) => {
|
|
11570
11697
|
const nodes = resolvePath(options, valuePath);
|
|
11571
11698
|
const labels = valuePath.map(
|
|
@@ -14529,6 +14656,7 @@ exports.ReactEditOutlined = ReactEditOutlined;
|
|
|
14529
14656
|
exports.ReactEditTwoTone = ReactEditTwoTone;
|
|
14530
14657
|
exports.ReactElevenLabsFilled = ReactElevenLabsFilled;
|
|
14531
14658
|
exports.ReactEllipsisOutlined = ReactEllipsisOutlined;
|
|
14659
|
+
exports.ReactEmpty = ReactEmpty;
|
|
14532
14660
|
exports.ReactEnterOutlined = ReactEnterOutlined;
|
|
14533
14661
|
exports.ReactEnvironmentFilled = ReactEnvironmentFilled;
|
|
14534
14662
|
exports.ReactEnvironmentOutlined = ReactEnvironmentOutlined;
|