@expcat/tigercat-core 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/icons/registry.cjs +1 -3
- package/dist/icons/registry.js +1 -3
- package/dist/index.cjs +562 -197
- package/dist/index.d.cts +370 -268
- package/dist/index.d.ts +370 -268
- package/dist/index.js +543 -196
- package/dist/locale-9tTj1QdZ.d.ts +300 -0
- package/dist/locale-DxwhmqfF.d.cts +300 -0
- package/dist/locales/ar-SA.cjs +67 -4
- package/dist/locales/ar-SA.d.cts +1 -1
- package/dist/locales/ar-SA.d.ts +1 -1
- package/dist/locales/ar-SA.js +67 -4
- package/dist/locales/de-DE.cjs +67 -4
- package/dist/locales/de-DE.d.cts +1 -1
- package/dist/locales/de-DE.d.ts +1 -1
- package/dist/locales/de-DE.js +67 -4
- package/dist/locales/en-US.cjs +64 -2
- package/dist/locales/en-US.d.cts +1 -1
- package/dist/locales/en-US.d.ts +1 -1
- package/dist/locales/en-US.js +62 -2
- package/dist/locales/es-ES.cjs +67 -4
- package/dist/locales/es-ES.d.cts +1 -1
- package/dist/locales/es-ES.d.ts +1 -1
- package/dist/locales/es-ES.js +67 -4
- package/dist/locales/fr-FR.cjs +67 -4
- package/dist/locales/fr-FR.d.cts +1 -1
- package/dist/locales/fr-FR.d.ts +1 -1
- package/dist/locales/fr-FR.js +67 -4
- package/dist/locales/id-ID.cjs +5 -2
- package/dist/locales/id-ID.d.cts +1 -1
- package/dist/locales/id-ID.d.ts +1 -1
- package/dist/locales/id-ID.js +5 -2
- package/dist/locales/ja-JP.cjs +5 -2
- package/dist/locales/ja-JP.d.cts +1 -1
- package/dist/locales/ja-JP.d.ts +1 -1
- package/dist/locales/ja-JP.js +5 -2
- package/dist/locales/ko-KR.cjs +5 -2
- package/dist/locales/ko-KR.d.cts +1 -1
- package/dist/locales/ko-KR.d.ts +1 -1
- package/dist/locales/ko-KR.js +5 -2
- package/dist/locales/pt-BR.cjs +67 -4
- package/dist/locales/pt-BR.d.cts +1 -1
- package/dist/locales/pt-BR.d.ts +1 -1
- package/dist/locales/pt-BR.js +67 -4
- package/dist/locales/th-TH.cjs +5 -2
- package/dist/locales/th-TH.d.cts +1 -1
- package/dist/locales/th-TH.d.ts +1 -1
- package/dist/locales/th-TH.js +5 -2
- package/dist/locales/vi-VN.cjs +5 -2
- package/dist/locales/vi-VN.d.cts +1 -1
- package/dist/locales/vi-VN.d.ts +1 -1
- package/dist/locales/vi-VN.js +5 -2
- package/dist/locales/zh-CN.cjs +64 -2
- package/dist/locales/zh-CN.d.cts +1 -1
- package/dist/locales/zh-CN.d.ts +1 -1
- package/dist/locales/zh-CN.js +62 -2
- package/dist/locales/zh-TW.cjs +5 -2
- package/dist/locales/zh-TW.d.cts +1 -1
- package/dist/locales/zh-TW.d.ts +1 -1
- package/dist/locales/zh-TW.js +5 -2
- package/dist/{table-export-CwJR6vfP.d.cts → table-export-BMBH75rj.d.cts} +2 -2
- package/dist/{table-export-B4VAha5n.d.ts → table-export-GRimhvlM.d.ts} +2 -2
- package/dist/tailwind/modern.cjs +1 -1
- package/dist/tailwind/modern.js +1 -1
- package/dist/utils/table-export.cjs +7 -0
- package/dist/utils/table-export.d.cts +2 -2
- package/dist/utils/table-export.d.ts +2 -2
- package/dist/utils/table-export.js +7 -0
- package/package.json +2 -10
- package/tokens/tailwind-tokens.js +3 -6
- package/tokens/tokens.css +15 -30
- package/dist/locale-BRmojkDM.d.cts +0 -131
- package/dist/locale-BxSSFEo2.d.ts +0 -131
package/dist/index.js
CHANGED
|
@@ -585,6 +585,10 @@ function normalizeStringOption(options, key) {
|
|
|
585
585
|
}
|
|
586
586
|
return options;
|
|
587
587
|
}
|
|
588
|
+
function createInstanceCounter() {
|
|
589
|
+
let counter = 0;
|
|
590
|
+
return () => ++counter;
|
|
591
|
+
}
|
|
588
592
|
|
|
589
593
|
// src/utils/icons/common.ts
|
|
590
594
|
var closeIconViewBox = "0 0 24 24";
|
|
@@ -659,9 +663,7 @@ var iconRegistry = {
|
|
|
659
663
|
"arrow-right": stroke24("M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"),
|
|
660
664
|
"arrow-up": stroke24("M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"),
|
|
661
665
|
"arrow-down": stroke24("M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"),
|
|
662
|
-
search: stroke24(
|
|
663
|
-
"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"
|
|
664
|
-
),
|
|
666
|
+
search: stroke24("m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"),
|
|
665
667
|
plus: stroke24("M12 4.5v15m7.5-7.5h-15"),
|
|
666
668
|
minus: stroke24("M5 12h14"),
|
|
667
669
|
edit: stroke24(
|
|
@@ -838,6 +840,14 @@ function getFocusableElements(container) {
|
|
|
838
840
|
);
|
|
839
841
|
}
|
|
840
842
|
function createFocusTrap(container, options = {}) {
|
|
843
|
+
if (!isBrowser()) {
|
|
844
|
+
return {
|
|
845
|
+
activate() {
|
|
846
|
+
},
|
|
847
|
+
deactivate() {
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
}
|
|
841
851
|
const {
|
|
842
852
|
initialFocus = null,
|
|
843
853
|
returnFocusOnDeactivate = true,
|
|
@@ -920,6 +930,7 @@ function getOrCreateLiveRegion(level) {
|
|
|
920
930
|
return el;
|
|
921
931
|
}
|
|
922
932
|
function announceToScreenReader(message, level = "polite") {
|
|
933
|
+
if (!isBrowser()) return;
|
|
923
934
|
const region = getOrCreateLiveRegion(level);
|
|
924
935
|
region.textContent = "";
|
|
925
936
|
requestAnimationFrame(() => {
|
|
@@ -927,6 +938,16 @@ function announceToScreenReader(message, level = "polite") {
|
|
|
927
938
|
});
|
|
928
939
|
}
|
|
929
940
|
function manageLiveRegion(level = "polite") {
|
|
941
|
+
if (!isBrowser()) {
|
|
942
|
+
return {
|
|
943
|
+
announce() {
|
|
944
|
+
},
|
|
945
|
+
clear() {
|
|
946
|
+
},
|
|
947
|
+
destroy() {
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
}
|
|
930
951
|
const region = getOrCreateLiveRegion(level);
|
|
931
952
|
return {
|
|
932
953
|
announce(message) {
|
|
@@ -953,8 +974,8 @@ function getActiveElement(doc) {
|
|
|
953
974
|
const active = doc?.activeElement;
|
|
954
975
|
return isHTMLElement(active) ? active : null;
|
|
955
976
|
}
|
|
956
|
-
function captureActiveElement(doc
|
|
957
|
-
return getActiveElement(doc);
|
|
977
|
+
function captureActiveElement(doc) {
|
|
978
|
+
return getActiveElement(doc ?? (isBrowser() ? document : void 0));
|
|
958
979
|
}
|
|
959
980
|
function focusElement(element, options) {
|
|
960
981
|
if (!element) return false;
|
|
@@ -985,7 +1006,8 @@ function getMenuItems(container) {
|
|
|
985
1006
|
function handleMenuNavigation(container, event) {
|
|
986
1007
|
const items = getMenuItems(container);
|
|
987
1008
|
if (items.length === 0) return false;
|
|
988
|
-
const
|
|
1009
|
+
const activeElement = container.ownerDocument?.activeElement ?? (isBrowser() ? document.activeElement : null);
|
|
1010
|
+
const currentIndex = items.indexOf(activeElement);
|
|
989
1011
|
let nextIndex = -1;
|
|
990
1012
|
switch (event.key) {
|
|
991
1013
|
case "ArrowDown":
|
|
@@ -1135,8 +1157,10 @@ var TIGER_LOCALE_KEYS = [
|
|
|
1135
1157
|
"pagination",
|
|
1136
1158
|
"table",
|
|
1137
1159
|
"datePicker",
|
|
1160
|
+
"timePicker",
|
|
1138
1161
|
"formWizard",
|
|
1139
|
-
"taskBoard"
|
|
1162
|
+
"taskBoard",
|
|
1163
|
+
"formValidation"
|
|
1140
1164
|
];
|
|
1141
1165
|
function isRecord3(value) {
|
|
1142
1166
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1182,8 +1206,10 @@ function mergeTigerLocale(base, override) {
|
|
|
1182
1206
|
pagination: { ...base?.pagination, ...override?.pagination },
|
|
1183
1207
|
table: { ...base?.table, ...override?.table },
|
|
1184
1208
|
datePicker: { ...base?.datePicker, ...override?.datePicker },
|
|
1209
|
+
timePicker: { ...base?.timePicker, ...override?.timePicker },
|
|
1185
1210
|
formWizard: { ...base?.formWizard, ...override?.formWizard },
|
|
1186
|
-
taskBoard: { ...base?.taskBoard, ...override?.taskBoard }
|
|
1211
|
+
taskBoard: { ...base?.taskBoard, ...override?.taskBoard },
|
|
1212
|
+
formValidation: { ...base?.formValidation, ...override?.formValidation }
|
|
1187
1213
|
};
|
|
1188
1214
|
}
|
|
1189
1215
|
var RTL_LANGUAGE_CODES = /* @__PURE__ */ new Set(["ar", "fa", "he", "iw", "ps", "ur"]);
|
|
@@ -1292,7 +1318,9 @@ var DEFAULT_TABLE_LABELS = {
|
|
|
1292
1318
|
selectedText: "Selected",
|
|
1293
1319
|
selectedItemsText: "items",
|
|
1294
1320
|
columnSettingsText: "Column settings",
|
|
1295
|
-
columnSettingsAriaLabel: "Column settings"
|
|
1321
|
+
columnSettingsAriaLabel: "Column settings",
|
|
1322
|
+
lockColumnAriaLabel: "Lock column {column}",
|
|
1323
|
+
unlockColumnAriaLabel: "Unlock column {column}"
|
|
1296
1324
|
};
|
|
1297
1325
|
var ZH_CN_TABLE_LABELS = {
|
|
1298
1326
|
emptyText: "\u6682\u65E0\u6570\u636E",
|
|
@@ -1309,7 +1337,9 @@ var ZH_CN_TABLE_LABELS = {
|
|
|
1309
1337
|
selectedText: "\u5DF2\u9009\u62E9",
|
|
1310
1338
|
selectedItemsText: "\u9879",
|
|
1311
1339
|
columnSettingsText: "\u5217\u8BBE\u7F6E",
|
|
1312
|
-
columnSettingsAriaLabel: "\u5217\u8BBE\u7F6E"
|
|
1340
|
+
columnSettingsAriaLabel: "\u5217\u8BBE\u7F6E",
|
|
1341
|
+
lockColumnAriaLabel: "\u9501\u5B9A{column}\u5217",
|
|
1342
|
+
unlockColumnAriaLabel: "\u53D6\u6D88\u9501\u5B9A{column}\u5217"
|
|
1313
1343
|
};
|
|
1314
1344
|
function getTableLabels(locale, overrides) {
|
|
1315
1345
|
const isZh = !!locale?.locale?.startsWith("zh") || locale?.common?.emptyText === "\u6682\u65E0\u6570\u636E" || locale?.table?.searchButtonText === "\u641C\u7D22";
|
|
@@ -1329,7 +1359,9 @@ function getTableLabels(locale, overrides) {
|
|
|
1329
1359
|
selectedText: overrides?.selectedText ?? locale?.table?.selectedText ?? defaultLabels.selectedText,
|
|
1330
1360
|
selectedItemsText: overrides?.selectedItemsText ?? locale?.table?.selectedItemsText ?? defaultLabels.selectedItemsText,
|
|
1331
1361
|
columnSettingsText: overrides?.columnSettingsText ?? locale?.table?.columnSettingsText ?? defaultLabels.columnSettingsText,
|
|
1332
|
-
columnSettingsAriaLabel: overrides?.columnSettingsAriaLabel ?? locale?.table?.columnSettingsAriaLabel ?? defaultLabels.columnSettingsAriaLabel
|
|
1362
|
+
columnSettingsAriaLabel: overrides?.columnSettingsAriaLabel ?? locale?.table?.columnSettingsAriaLabel ?? defaultLabels.columnSettingsAriaLabel,
|
|
1363
|
+
lockColumnAriaLabel: overrides?.lockColumnAriaLabel ?? locale?.table?.lockColumnAriaLabel ?? defaultLabels.lockColumnAriaLabel,
|
|
1364
|
+
unlockColumnAriaLabel: overrides?.unlockColumnAriaLabel ?? locale?.table?.unlockColumnAriaLabel ?? defaultLabels.unlockColumnAriaLabel
|
|
1333
1365
|
};
|
|
1334
1366
|
}
|
|
1335
1367
|
function formatTableSelectRowAriaLabel(template, row, locale) {
|
|
@@ -1363,6 +1395,118 @@ function getTaskBoardLabels(locale, overrides) {
|
|
|
1363
1395
|
boardAriaLabel: overrides?.boardAriaLabel ?? locale?.taskBoard?.boardAriaLabel ?? defaultLabels.boardAriaLabel
|
|
1364
1396
|
};
|
|
1365
1397
|
}
|
|
1398
|
+
var DEFAULT_FORM_VALIDATION_LABELS = {
|
|
1399
|
+
required: "This field is required",
|
|
1400
|
+
typeString: "Value must be a string",
|
|
1401
|
+
typeNumber: "Value must be a number",
|
|
1402
|
+
typeBoolean: "Value must be a boolean",
|
|
1403
|
+
typeArray: "Value must be an array",
|
|
1404
|
+
typeObject: "Value must be an object",
|
|
1405
|
+
email: "Please enter a valid email address",
|
|
1406
|
+
phone: "Please enter a valid phone number",
|
|
1407
|
+
url: "Please enter a valid URL",
|
|
1408
|
+
date: "Please enter a valid date",
|
|
1409
|
+
idCard: "Please enter a valid ID card number",
|
|
1410
|
+
minLength: "Minimum length is {min} characters",
|
|
1411
|
+
maxLength: "Maximum length is {max} characters",
|
|
1412
|
+
minValue: "Minimum value is {min}",
|
|
1413
|
+
maxValue: "Maximum value is {max}",
|
|
1414
|
+
minItems: "Minimum {min} items required",
|
|
1415
|
+
maxItems: "Maximum {max} items allowed",
|
|
1416
|
+
patternMismatch: "Value does not match the required pattern",
|
|
1417
|
+
validatorFailed: "Validation failed",
|
|
1418
|
+
validatorError: "Validation error occurred"
|
|
1419
|
+
};
|
|
1420
|
+
var ZH_CN_FORM_VALIDATION_LABELS = {
|
|
1421
|
+
required: "\u6B64\u5B57\u6BB5\u4E3A\u5FC5\u586B\u9879",
|
|
1422
|
+
typeString: "\u503C\u5FC5\u987B\u662F\u5B57\u7B26\u4E32",
|
|
1423
|
+
typeNumber: "\u503C\u5FC5\u987B\u662F\u6570\u5B57",
|
|
1424
|
+
typeBoolean: "\u503C\u5FC5\u987B\u662F\u5E03\u5C14\u503C",
|
|
1425
|
+
typeArray: "\u503C\u5FC5\u987B\u662F\u6570\u7EC4",
|
|
1426
|
+
typeObject: "\u503C\u5FC5\u987B\u662F\u5BF9\u8C61",
|
|
1427
|
+
email: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u5730\u5740",
|
|
1428
|
+
phone: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u7535\u8BDD\u53F7\u7801",
|
|
1429
|
+
url: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u7F51\u5740",
|
|
1430
|
+
date: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65E5\u671F",
|
|
1431
|
+
idCard: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u8EAB\u4EFD\u8BC1\u53F7\u7801",
|
|
1432
|
+
minLength: "\u957F\u5EA6\u4E0D\u80FD\u5C11\u4E8E {min} \u4E2A\u5B57\u7B26",
|
|
1433
|
+
maxLength: "\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 {max} \u4E2A\u5B57\u7B26",
|
|
1434
|
+
minValue: "\u6570\u503C\u4E0D\u80FD\u5C0F\u4E8E {min}",
|
|
1435
|
+
maxValue: "\u6570\u503C\u4E0D\u80FD\u5927\u4E8E {max}",
|
|
1436
|
+
minItems: "\u81F3\u5C11\u9700\u8981 {min} \u9879",
|
|
1437
|
+
maxItems: "\u6700\u591A\u5141\u8BB8 {max} \u9879",
|
|
1438
|
+
patternMismatch: "\u683C\u5F0F\u4E0D\u6B63\u786E",
|
|
1439
|
+
validatorFailed: "\u6821\u9A8C\u672A\u901A\u8FC7",
|
|
1440
|
+
validatorError: "\u6821\u9A8C\u65F6\u53D1\u751F\u9519\u8BEF"
|
|
1441
|
+
};
|
|
1442
|
+
function getFormValidationLabels(locale, overrides) {
|
|
1443
|
+
const isZh = !!locale?.locale?.startsWith("zh");
|
|
1444
|
+
const defaultLabels = isZh ? ZH_CN_FORM_VALIDATION_LABELS : DEFAULT_FORM_VALIDATION_LABELS;
|
|
1445
|
+
const fv = locale?.formValidation;
|
|
1446
|
+
const resolved = {};
|
|
1447
|
+
for (const key of Object.keys(defaultLabels)) {
|
|
1448
|
+
resolved[key] = overrides?.[key] ?? fv?.[key] ?? defaultLabels[key];
|
|
1449
|
+
}
|
|
1450
|
+
return resolved;
|
|
1451
|
+
}
|
|
1452
|
+
var DEFAULT_TIME_PICKER_LABELS = {
|
|
1453
|
+
hour: "Hour",
|
|
1454
|
+
minute: "Min",
|
|
1455
|
+
second: "Sec",
|
|
1456
|
+
now: "Now",
|
|
1457
|
+
ok: "OK",
|
|
1458
|
+
start: "Start",
|
|
1459
|
+
end: "End",
|
|
1460
|
+
clear: "Clear time",
|
|
1461
|
+
toggle: "Toggle time picker",
|
|
1462
|
+
dialog: "Time picker",
|
|
1463
|
+
selectTime: "Select time",
|
|
1464
|
+
selectTimeRange: "Select time range"
|
|
1465
|
+
};
|
|
1466
|
+
var ZH_CN_TIME_PICKER_LABELS = {
|
|
1467
|
+
hour: "\u65F6",
|
|
1468
|
+
minute: "\u5206",
|
|
1469
|
+
second: "\u79D2",
|
|
1470
|
+
now: "\u73B0\u5728",
|
|
1471
|
+
ok: "\u786E\u5B9A",
|
|
1472
|
+
start: "\u5F00\u59CB",
|
|
1473
|
+
end: "\u7ED3\u675F",
|
|
1474
|
+
clear: "\u6E05\u9664\u65F6\u95F4",
|
|
1475
|
+
toggle: "\u6253\u5F00\u65F6\u95F4\u9009\u62E9\u5668",
|
|
1476
|
+
dialog: "\u65F6\u95F4\u9009\u62E9\u5668",
|
|
1477
|
+
selectTime: "\u8BF7\u9009\u62E9\u65F6\u95F4",
|
|
1478
|
+
selectTimeRange: "\u8BF7\u9009\u62E9\u65F6\u95F4\u8303\u56F4"
|
|
1479
|
+
};
|
|
1480
|
+
var DEFAULT_UPLOAD_LABELS = {
|
|
1481
|
+
dragAreaAriaLabel: "Upload file by clicking or dragging",
|
|
1482
|
+
buttonAriaLabel: "Upload file",
|
|
1483
|
+
clickToUploadText: "Click to upload",
|
|
1484
|
+
dragAndDropText: "or drag and drop",
|
|
1485
|
+
acceptInfoText: "Accepted: {accept}",
|
|
1486
|
+
maxSizeInfoText: "Max size: {maxSize}",
|
|
1487
|
+
selectFileText: "Select File",
|
|
1488
|
+
uploadedFilesAriaLabel: "Uploaded files",
|
|
1489
|
+
successAriaLabel: "Success",
|
|
1490
|
+
errorAriaLabel: "Error",
|
|
1491
|
+
uploadingAriaLabel: "Uploading",
|
|
1492
|
+
removeFileAriaLabel: "Remove {fileName}",
|
|
1493
|
+
previewFileAriaLabel: "Preview {fileName}"
|
|
1494
|
+
};
|
|
1495
|
+
var ZH_CN_UPLOAD_LABELS = {
|
|
1496
|
+
dragAreaAriaLabel: "\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",
|
|
1497
|
+
buttonAriaLabel: "\u4E0A\u4F20\u6587\u4EF6",
|
|
1498
|
+
clickToUploadText: "\u70B9\u51FB\u4E0A\u4F20",
|
|
1499
|
+
dragAndDropText: "\u6216\u62D6\u62FD\u5230\u6B64\u5904",
|
|
1500
|
+
acceptInfoText: "\u652F\u6301\uFF1A{accept}",
|
|
1501
|
+
maxSizeInfoText: "\u6700\u5927\u5927\u5C0F\uFF1A{maxSize}",
|
|
1502
|
+
selectFileText: "\u9009\u62E9\u6587\u4EF6",
|
|
1503
|
+
uploadedFilesAriaLabel: "\u5DF2\u4E0A\u4F20\u6587\u4EF6",
|
|
1504
|
+
successAriaLabel: "\u6210\u529F",
|
|
1505
|
+
errorAriaLabel: "\u9519\u8BEF",
|
|
1506
|
+
uploadingAriaLabel: "\u4E0A\u4F20\u4E2D",
|
|
1507
|
+
removeFileAriaLabel: "\u79FB\u9664 {fileName}",
|
|
1508
|
+
previewFileAriaLabel: "\u9884\u89C8 {fileName}"
|
|
1509
|
+
};
|
|
1366
1510
|
|
|
1367
1511
|
// src/utils/datepicker-i18n.ts
|
|
1368
1512
|
var EN_US_DATEPICKER_LOCALE = {
|
|
@@ -1463,35 +1607,104 @@ function getDatePickerLabels(locale, overrides) {
|
|
|
1463
1607
|
};
|
|
1464
1608
|
}
|
|
1465
1609
|
|
|
1610
|
+
// src/utils/picker-utils.ts
|
|
1611
|
+
var defaultIsDisabled = (item) => !!item?.disabled;
|
|
1612
|
+
function findFirstEnabledIndex(items, isDisabled = defaultIsDisabled) {
|
|
1613
|
+
for (let i = 0; i < items.length; i++) {
|
|
1614
|
+
if (!isDisabled(items[i])) return i;
|
|
1615
|
+
}
|
|
1616
|
+
return -1;
|
|
1617
|
+
}
|
|
1618
|
+
function findLastEnabledIndex(items, isDisabled = defaultIsDisabled) {
|
|
1619
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
1620
|
+
if (!isDisabled(items[i])) return i;
|
|
1621
|
+
}
|
|
1622
|
+
return -1;
|
|
1623
|
+
}
|
|
1624
|
+
function findNextEnabledIndex(items, current, direction, isDisabled = defaultIsDisabled) {
|
|
1625
|
+
if (items.length === 0) return -1;
|
|
1626
|
+
const start = current < 0 ? direction === 1 ? 0 : items.length - 1 : current + direction;
|
|
1627
|
+
for (let i = start; i >= 0 && i < items.length; i += direction) {
|
|
1628
|
+
if (!isDisabled(items[i])) return i;
|
|
1629
|
+
}
|
|
1630
|
+
return current;
|
|
1631
|
+
}
|
|
1632
|
+
function getCyclicIndex(length, current, direction) {
|
|
1633
|
+
if (length <= 0) return -1;
|
|
1634
|
+
return (current + direction + length) % length;
|
|
1635
|
+
}
|
|
1636
|
+
function getInitialPickerActiveIndex(items, activeFirst, isDisabled = defaultIsDisabled) {
|
|
1637
|
+
return activeFirst ? findFirstEnabledIndex(items, isDisabled) : -1;
|
|
1638
|
+
}
|
|
1639
|
+
function getPickerNavigationIndex(items, current, key, isDisabled = defaultIsDisabled) {
|
|
1640
|
+
switch (key) {
|
|
1641
|
+
case "ArrowDown":
|
|
1642
|
+
return findNextEnabledIndex(items, current, 1, isDisabled);
|
|
1643
|
+
case "ArrowUp":
|
|
1644
|
+
return findNextEnabledIndex(items, current, -1, isDisabled);
|
|
1645
|
+
case "Home":
|
|
1646
|
+
return findFirstEnabledIndex(items, isDisabled);
|
|
1647
|
+
case "End":
|
|
1648
|
+
return findLastEnabledIndex(items, isDisabled);
|
|
1649
|
+
default:
|
|
1650
|
+
return current;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
function getPickerOptionId(listboxId, index) {
|
|
1654
|
+
return `${listboxId}-option-${index}`;
|
|
1655
|
+
}
|
|
1656
|
+
function getDisclosureStateAttr(open) {
|
|
1657
|
+
return { "data-state": open ? "open" : "closed" };
|
|
1658
|
+
}
|
|
1659
|
+
function getPickerComboboxAria({
|
|
1660
|
+
expanded,
|
|
1661
|
+
listboxId,
|
|
1662
|
+
activeIndex = -1,
|
|
1663
|
+
activeOptionId
|
|
1664
|
+
}) {
|
|
1665
|
+
return {
|
|
1666
|
+
role: "combobox",
|
|
1667
|
+
"aria-expanded": expanded,
|
|
1668
|
+
"aria-haspopup": "listbox",
|
|
1669
|
+
"aria-controls": expanded ? listboxId : void 0,
|
|
1670
|
+
"aria-activedescendant": expanded ? activeOptionId ?? (activeIndex >= 0 ? getPickerOptionId(listboxId, activeIndex) : void 0) : void 0,
|
|
1671
|
+
"data-state": expanded ? "open" : "closed"
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
function getPickerListboxAria({ id, label } = {}) {
|
|
1675
|
+
return {
|
|
1676
|
+
id,
|
|
1677
|
+
role: "listbox",
|
|
1678
|
+
"aria-label": label
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
function getPickerOptionAria({
|
|
1682
|
+
selected = false,
|
|
1683
|
+
disabled = false
|
|
1684
|
+
}) {
|
|
1685
|
+
return {
|
|
1686
|
+
role: "option",
|
|
1687
|
+
"aria-selected": selected,
|
|
1688
|
+
"aria-disabled": disabled || void 0
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
function getPickerTriggerKeyAction(key, expanded) {
|
|
1692
|
+
switch (key) {
|
|
1693
|
+
case "Enter":
|
|
1694
|
+
case " ":
|
|
1695
|
+
return "toggle";
|
|
1696
|
+
case "ArrowDown":
|
|
1697
|
+
return expanded ? "none" : "open";
|
|
1698
|
+
case "Escape":
|
|
1699
|
+
return expanded ? "close" : "none";
|
|
1700
|
+
default:
|
|
1701
|
+
return "none";
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1466
1705
|
// src/utils/timepicker-utils.ts
|
|
1467
|
-
var
|
|
1468
|
-
|
|
1469
|
-
minute: "\u5206",
|
|
1470
|
-
second: "\u79D2",
|
|
1471
|
-
now: "\u73B0\u5728",
|
|
1472
|
-
ok: "\u786E\u5B9A",
|
|
1473
|
-
start: "\u5F00\u59CB",
|
|
1474
|
-
end: "\u7ED3\u675F",
|
|
1475
|
-
clear: "\u6E05\u9664\u65F6\u95F4",
|
|
1476
|
-
toggle: "\u6253\u5F00\u65F6\u95F4\u9009\u62E9\u5668",
|
|
1477
|
-
dialog: "\u65F6\u95F4\u9009\u62E9\u5668",
|
|
1478
|
-
selectTime: "\u8BF7\u9009\u62E9\u65F6\u95F4",
|
|
1479
|
-
selectTimeRange: "\u8BF7\u9009\u62E9\u65F6\u95F4\u8303\u56F4"
|
|
1480
|
-
};
|
|
1481
|
-
var EN_LABELS = {
|
|
1482
|
-
hour: "Hour",
|
|
1483
|
-
minute: "Min",
|
|
1484
|
-
second: "Sec",
|
|
1485
|
-
now: "Now",
|
|
1486
|
-
ok: "OK",
|
|
1487
|
-
start: "Start",
|
|
1488
|
-
end: "End",
|
|
1489
|
-
clear: "Clear time",
|
|
1490
|
-
toggle: "Toggle time picker",
|
|
1491
|
-
dialog: "Time picker",
|
|
1492
|
-
selectTime: "Select time",
|
|
1493
|
-
selectTimeRange: "Select time range"
|
|
1494
|
-
};
|
|
1706
|
+
var EN_LABELS = DEFAULT_TIME_PICKER_LABELS;
|
|
1707
|
+
var ZH_LABELS = ZH_CN_TIME_PICKER_LABELS;
|
|
1495
1708
|
var TIME_PICKER_LABELS_BY_LANGUAGE = {
|
|
1496
1709
|
en: EN_LABELS,
|
|
1497
1710
|
zh: ZH_LABELS,
|
|
@@ -1566,26 +1779,59 @@ var TIME_PICKER_LABELS_BY_LANGUAGE = {
|
|
|
1566
1779
|
selectTimeRange: "\u0627\u062E\u062A\u0631 \u0646\u0637\u0627\u0642 \u0627\u0644\u0648\u0642\u062A"
|
|
1567
1780
|
}
|
|
1568
1781
|
};
|
|
1782
|
+
function getTimePickerLocaleCode(locale) {
|
|
1783
|
+
return typeof locale === "string" ? locale : locale?.locale;
|
|
1784
|
+
}
|
|
1569
1785
|
function isZhLocale(locale) {
|
|
1570
|
-
return (locale ?? "").toLowerCase().startsWith("zh");
|
|
1786
|
+
return (getTimePickerLocaleCode(locale) ?? "").toLowerCase().startsWith("zh");
|
|
1571
1787
|
}
|
|
1572
1788
|
function getTimePickerLabels(locale, overrides) {
|
|
1573
|
-
const
|
|
1789
|
+
const localeCode = getTimePickerLocaleCode(locale);
|
|
1790
|
+
const language = (localeCode ?? "").split("-")[0]?.toLowerCase();
|
|
1574
1791
|
const base = language ? TIME_PICKER_LABELS_BY_LANGUAGE[language] ?? EN_LABELS : EN_LABELS;
|
|
1575
|
-
|
|
1792
|
+
const localeLabels = typeof locale === "string" ? void 0 : locale?.timePicker;
|
|
1793
|
+
return { ...base, ...localeLabels ?? {}, ...overrides ?? {} };
|
|
1576
1794
|
}
|
|
1577
1795
|
function pluralizeEn(value, singular) {
|
|
1578
1796
|
return getIntlPluralCategory(value, "en") === "one" ? singular : `${singular}s`;
|
|
1579
1797
|
}
|
|
1580
1798
|
function getTimePickerOptionAriaLabel(value, unit, locale, labelOverrides) {
|
|
1581
1799
|
const labels = getTimePickerLabels(locale, labelOverrides);
|
|
1800
|
+
const localeCode = getTimePickerLocaleCode(locale);
|
|
1582
1801
|
const unitLabel = unit === "hour" ? labels.hour : unit === "minute" ? labels.minute : labels.second;
|
|
1583
|
-
if (isZhLocale(locale)) return `${formatIntlNumber(value,
|
|
1584
|
-
const lc = (
|
|
1802
|
+
if (isZhLocale(locale)) return `${formatIntlNumber(value, localeCode)}${unitLabel}`;
|
|
1803
|
+
const lc = (localeCode ?? "").toLowerCase();
|
|
1585
1804
|
if (lc.startsWith("en") || !lc && !labelOverrides) {
|
|
1586
|
-
return `${formatIntlNumber(value,
|
|
1805
|
+
return `${formatIntlNumber(value, localeCode)} ${pluralizeEn(value, unit)}`;
|
|
1806
|
+
}
|
|
1807
|
+
return `${formatIntlNumber(value, localeCode)} ${unitLabel}`;
|
|
1808
|
+
}
|
|
1809
|
+
function focusTimePickerOption(panel, unit, action) {
|
|
1810
|
+
if (!panel) return;
|
|
1811
|
+
const nodes = Array.from(
|
|
1812
|
+
panel.querySelectorAll(`button[data-tiger-timepicker-unit="${unit}"]`)
|
|
1813
|
+
).filter((button) => !button.disabled);
|
|
1814
|
+
if (nodes.length === 0) return;
|
|
1815
|
+
const active = panel.ownerDocument.activeElement;
|
|
1816
|
+
const activeIndex = active ? nodes.indexOf(active) : -1;
|
|
1817
|
+
const selectedIndex = nodes.findIndex((button) => button.getAttribute("aria-selected") === "true");
|
|
1818
|
+
const baseIndex = activeIndex >= 0 ? activeIndex : Math.max(0, selectedIndex);
|
|
1819
|
+
let nextIndex = baseIndex;
|
|
1820
|
+
switch (action) {
|
|
1821
|
+
case "prev":
|
|
1822
|
+
nextIndex = findNextEnabledIndex(nodes, baseIndex, -1);
|
|
1823
|
+
break;
|
|
1824
|
+
case "next":
|
|
1825
|
+
nextIndex = findNextEnabledIndex(nodes, baseIndex, 1);
|
|
1826
|
+
break;
|
|
1827
|
+
case "first":
|
|
1828
|
+
nextIndex = findFirstEnabledIndex(nodes);
|
|
1829
|
+
break;
|
|
1830
|
+
case "last":
|
|
1831
|
+
nextIndex = findLastEnabledIndex(nodes);
|
|
1832
|
+
break;
|
|
1587
1833
|
}
|
|
1588
|
-
|
|
1834
|
+
nodes[nextIndex]?.focus();
|
|
1589
1835
|
}
|
|
1590
1836
|
var timePickerBaseClasses = "relative inline-block w-full max-w-xs";
|
|
1591
1837
|
var timePickerInputWrapperClasses = "relative flex items-center";
|
|
@@ -1722,67 +1968,67 @@ function interpolateUploadLabel(template, params) {
|
|
|
1722
1968
|
function getUploadLabels(locale, overrides) {
|
|
1723
1969
|
return {
|
|
1724
1970
|
dragAreaAriaLabel: resolveLocaleText(
|
|
1725
|
-
|
|
1971
|
+
DEFAULT_UPLOAD_LABELS.dragAreaAriaLabel,
|
|
1726
1972
|
overrides?.dragAreaAriaLabel,
|
|
1727
1973
|
locale?.upload?.dragAreaAriaLabel
|
|
1728
1974
|
),
|
|
1729
1975
|
buttonAriaLabel: resolveLocaleText(
|
|
1730
|
-
|
|
1976
|
+
DEFAULT_UPLOAD_LABELS.buttonAriaLabel,
|
|
1731
1977
|
overrides?.buttonAriaLabel,
|
|
1732
1978
|
locale?.upload?.buttonAriaLabel
|
|
1733
1979
|
),
|
|
1734
1980
|
clickToUploadText: resolveLocaleText(
|
|
1735
|
-
|
|
1981
|
+
DEFAULT_UPLOAD_LABELS.clickToUploadText,
|
|
1736
1982
|
overrides?.clickToUploadText,
|
|
1737
1983
|
locale?.upload?.clickToUploadText
|
|
1738
1984
|
),
|
|
1739
1985
|
dragAndDropText: resolveLocaleText(
|
|
1740
|
-
|
|
1986
|
+
DEFAULT_UPLOAD_LABELS.dragAndDropText,
|
|
1741
1987
|
overrides?.dragAndDropText,
|
|
1742
1988
|
locale?.upload?.dragAndDropText
|
|
1743
1989
|
),
|
|
1744
1990
|
acceptInfoText: resolveLocaleText(
|
|
1745
|
-
|
|
1991
|
+
DEFAULT_UPLOAD_LABELS.acceptInfoText,
|
|
1746
1992
|
overrides?.acceptInfoText,
|
|
1747
1993
|
locale?.upload?.acceptInfoText
|
|
1748
1994
|
),
|
|
1749
1995
|
maxSizeInfoText: resolveLocaleText(
|
|
1750
|
-
|
|
1996
|
+
DEFAULT_UPLOAD_LABELS.maxSizeInfoText,
|
|
1751
1997
|
overrides?.maxSizeInfoText,
|
|
1752
1998
|
locale?.upload?.maxSizeInfoText
|
|
1753
1999
|
),
|
|
1754
2000
|
selectFileText: resolveLocaleText(
|
|
1755
|
-
|
|
2001
|
+
DEFAULT_UPLOAD_LABELS.selectFileText,
|
|
1756
2002
|
overrides?.selectFileText,
|
|
1757
2003
|
locale?.upload?.selectFileText
|
|
1758
2004
|
),
|
|
1759
2005
|
uploadedFilesAriaLabel: resolveLocaleText(
|
|
1760
|
-
|
|
2006
|
+
DEFAULT_UPLOAD_LABELS.uploadedFilesAriaLabel,
|
|
1761
2007
|
overrides?.uploadedFilesAriaLabel,
|
|
1762
2008
|
locale?.upload?.uploadedFilesAriaLabel
|
|
1763
2009
|
),
|
|
1764
2010
|
successAriaLabel: resolveLocaleText(
|
|
1765
|
-
|
|
2011
|
+
DEFAULT_UPLOAD_LABELS.successAriaLabel,
|
|
1766
2012
|
overrides?.successAriaLabel,
|
|
1767
2013
|
locale?.upload?.successAriaLabel
|
|
1768
2014
|
),
|
|
1769
2015
|
errorAriaLabel: resolveLocaleText(
|
|
1770
|
-
|
|
2016
|
+
DEFAULT_UPLOAD_LABELS.errorAriaLabel,
|
|
1771
2017
|
overrides?.errorAriaLabel,
|
|
1772
2018
|
locale?.upload?.errorAriaLabel
|
|
1773
2019
|
),
|
|
1774
2020
|
uploadingAriaLabel: resolveLocaleText(
|
|
1775
|
-
|
|
2021
|
+
DEFAULT_UPLOAD_LABELS.uploadingAriaLabel,
|
|
1776
2022
|
overrides?.uploadingAriaLabel,
|
|
1777
2023
|
locale?.upload?.uploadingAriaLabel
|
|
1778
2024
|
),
|
|
1779
2025
|
removeFileAriaLabel: resolveLocaleText(
|
|
1780
|
-
|
|
2026
|
+
DEFAULT_UPLOAD_LABELS.removeFileAriaLabel,
|
|
1781
2027
|
overrides?.removeFileAriaLabel,
|
|
1782
2028
|
locale?.upload?.removeFileAriaLabel
|
|
1783
2029
|
),
|
|
1784
2030
|
previewFileAriaLabel: resolveLocaleText(
|
|
1785
|
-
|
|
2031
|
+
DEFAULT_UPLOAD_LABELS.previewFileAriaLabel,
|
|
1786
2032
|
overrides?.previewFileAriaLabel,
|
|
1787
2033
|
locale?.upload?.previewFileAriaLabel
|
|
1788
2034
|
)
|
|
@@ -1798,7 +2044,10 @@ var enUS = {
|
|
|
1798
2044
|
cancelText: "Cancel",
|
|
1799
2045
|
closeText: "Close",
|
|
1800
2046
|
loadingText: "Loading...",
|
|
1801
|
-
emptyText: "No data"
|
|
2047
|
+
emptyText: "No data",
|
|
2048
|
+
noMoreText: "No more data",
|
|
2049
|
+
searchPlaceholder: "Search",
|
|
2050
|
+
clearText: "Clear"
|
|
1802
2051
|
},
|
|
1803
2052
|
modal: {
|
|
1804
2053
|
closeAriaLabel: "Close",
|
|
@@ -1808,6 +2057,7 @@ var enUS = {
|
|
|
1808
2057
|
drawer: {
|
|
1809
2058
|
closeAriaLabel: "Close"
|
|
1810
2059
|
},
|
|
2060
|
+
upload: DEFAULT_UPLOAD_LABELS,
|
|
1811
2061
|
pagination: {
|
|
1812
2062
|
totalText: "Total {total} items",
|
|
1813
2063
|
itemsPerPageText: "/ page",
|
|
@@ -1833,8 +2083,11 @@ var enUS = {
|
|
|
1833
2083
|
selectedText: "Selected",
|
|
1834
2084
|
selectedItemsText: "items",
|
|
1835
2085
|
columnSettingsText: "Column settings",
|
|
1836
|
-
columnSettingsAriaLabel: "Column settings"
|
|
2086
|
+
columnSettingsAriaLabel: "Column settings",
|
|
2087
|
+
lockColumnAriaLabel: "Lock column {column}",
|
|
2088
|
+
unlockColumnAriaLabel: "Unlock column {column}"
|
|
1837
2089
|
},
|
|
2090
|
+
timePicker: DEFAULT_TIME_PICKER_LABELS,
|
|
1838
2091
|
formWizard: {
|
|
1839
2092
|
prevText: "Previous",
|
|
1840
2093
|
nextText: "Next",
|
|
@@ -1846,6 +2099,28 @@ var enUS = {
|
|
|
1846
2099
|
wipLimitText: "WIP limit: {limit}",
|
|
1847
2100
|
dragHintText: "Drag to move",
|
|
1848
2101
|
boardAriaLabel: "Task Board"
|
|
2102
|
+
},
|
|
2103
|
+
formValidation: {
|
|
2104
|
+
required: "This field is required",
|
|
2105
|
+
typeString: "Value must be a string",
|
|
2106
|
+
typeNumber: "Value must be a number",
|
|
2107
|
+
typeBoolean: "Value must be a boolean",
|
|
2108
|
+
typeArray: "Value must be an array",
|
|
2109
|
+
typeObject: "Value must be an object",
|
|
2110
|
+
email: "Please enter a valid email address",
|
|
2111
|
+
phone: "Please enter a valid phone number",
|
|
2112
|
+
url: "Please enter a valid URL",
|
|
2113
|
+
date: "Please enter a valid date",
|
|
2114
|
+
idCard: "Please enter a valid ID card number",
|
|
2115
|
+
minLength: "Minimum length is {min} characters",
|
|
2116
|
+
maxLength: "Maximum length is {max} characters",
|
|
2117
|
+
minValue: "Minimum value is {min}",
|
|
2118
|
+
maxValue: "Maximum value is {max}",
|
|
2119
|
+
minItems: "Minimum {min} items required",
|
|
2120
|
+
maxItems: "Maximum {max} items allowed",
|
|
2121
|
+
patternMismatch: "Value does not match the required pattern",
|
|
2122
|
+
validatorFailed: "Validation failed",
|
|
2123
|
+
validatorError: "Validation error occurred"
|
|
1849
2124
|
}
|
|
1850
2125
|
};
|
|
1851
2126
|
|
|
@@ -2098,6 +2373,18 @@ function isAtMax(value, max = Infinity) {
|
|
|
2098
2373
|
if (value === null || value === void 0) return false;
|
|
2099
2374
|
return value >= max;
|
|
2100
2375
|
}
|
|
2376
|
+
function formatInputNumberDisplay(value, options = {}) {
|
|
2377
|
+
if (value === null || value === void 0) return "";
|
|
2378
|
+
if (options.formatter) return options.formatter(value);
|
|
2379
|
+
if (options.precision !== void 0) return value.toFixed(options.precision);
|
|
2380
|
+
return String(value);
|
|
2381
|
+
}
|
|
2382
|
+
function parseInputNumberValue(str, options = {}) {
|
|
2383
|
+
if (str === "" || str === "-") return null;
|
|
2384
|
+
if (options.parser) return options.parser(str);
|
|
2385
|
+
const num = Number(str);
|
|
2386
|
+
return Number.isNaN(num) ? null : num;
|
|
2387
|
+
}
|
|
2101
2388
|
|
|
2102
2389
|
// src/utils/form-item-styles.ts
|
|
2103
2390
|
var FORM_ITEM_SPACING = {
|
|
@@ -2492,128 +2779,128 @@ function isEmpty(value) {
|
|
|
2492
2779
|
}
|
|
2493
2780
|
return false;
|
|
2494
2781
|
}
|
|
2495
|
-
function validateType(value, type, customMessage) {
|
|
2782
|
+
function validateType(value, type, customMessage, messages = DEFAULT_FORM_VALIDATION_LABELS) {
|
|
2496
2783
|
switch (type) {
|
|
2497
2784
|
case "string":
|
|
2498
2785
|
if (typeof value !== "string") {
|
|
2499
|
-
return customMessage ||
|
|
2786
|
+
return customMessage || messages.typeString;
|
|
2500
2787
|
}
|
|
2501
2788
|
break;
|
|
2502
2789
|
case "number":
|
|
2503
2790
|
if (typeof value !== "number" && isNaN(Number(value))) {
|
|
2504
|
-
return customMessage ||
|
|
2791
|
+
return customMessage || messages.typeNumber;
|
|
2505
2792
|
}
|
|
2506
2793
|
break;
|
|
2507
2794
|
case "boolean":
|
|
2508
2795
|
if (typeof value !== "boolean") {
|
|
2509
|
-
return customMessage ||
|
|
2796
|
+
return customMessage || messages.typeBoolean;
|
|
2510
2797
|
}
|
|
2511
2798
|
break;
|
|
2512
2799
|
case "array":
|
|
2513
2800
|
if (!Array.isArray(value)) {
|
|
2514
|
-
return customMessage ||
|
|
2801
|
+
return customMessage || messages.typeArray;
|
|
2515
2802
|
}
|
|
2516
2803
|
break;
|
|
2517
2804
|
case "object":
|
|
2518
2805
|
if (typeof value !== "object" || Array.isArray(value)) {
|
|
2519
|
-
return customMessage ||
|
|
2806
|
+
return customMessage || messages.typeObject;
|
|
2520
2807
|
}
|
|
2521
2808
|
break;
|
|
2522
2809
|
case "email":
|
|
2523
2810
|
if (typeof value === "string" && !EMAIL_PATTERN.test(value)) {
|
|
2524
|
-
return customMessage ||
|
|
2811
|
+
return customMessage || messages.email;
|
|
2525
2812
|
}
|
|
2526
2813
|
break;
|
|
2527
2814
|
case "phone":
|
|
2528
2815
|
if (typeof value === "string") {
|
|
2529
2816
|
const digits = value.replace(/\D/g, "");
|
|
2530
2817
|
if (!PHONE_PATTERN.test(value) || digits.length < 7) {
|
|
2531
|
-
return customMessage ||
|
|
2818
|
+
return customMessage || messages.phone;
|
|
2532
2819
|
}
|
|
2533
2820
|
}
|
|
2534
2821
|
break;
|
|
2535
2822
|
case "url":
|
|
2536
2823
|
if (typeof value === "string" && !URL_PATTERN.test(value)) {
|
|
2537
|
-
return customMessage ||
|
|
2824
|
+
return customMessage || messages.url;
|
|
2538
2825
|
}
|
|
2539
2826
|
break;
|
|
2540
2827
|
case "date":
|
|
2541
2828
|
if (!(value instanceof Date) && isNaN(Date.parse(String(value)))) {
|
|
2542
|
-
return customMessage ||
|
|
2829
|
+
return customMessage || messages.date;
|
|
2543
2830
|
}
|
|
2544
2831
|
break;
|
|
2545
2832
|
case "id-card":
|
|
2546
2833
|
if (typeof value === "string" && !ID_CARD_PATTERN.test(value)) {
|
|
2547
|
-
return customMessage ||
|
|
2834
|
+
return customMessage || messages.idCard;
|
|
2548
2835
|
}
|
|
2549
2836
|
break;
|
|
2550
2837
|
}
|
|
2551
2838
|
return null;
|
|
2552
2839
|
}
|
|
2553
|
-
function validateRange(value, min, max, customMessage) {
|
|
2840
|
+
function validateRange(value, min, max, customMessage, messages = DEFAULT_FORM_VALIDATION_LABELS) {
|
|
2554
2841
|
if (typeof value === "string") {
|
|
2555
2842
|
if (min !== void 0 && value.length < min) {
|
|
2556
|
-
return customMessage ||
|
|
2843
|
+
return customMessage || messages.minLength.replace("{min}", String(min));
|
|
2557
2844
|
}
|
|
2558
2845
|
if (max !== void 0 && value.length > max) {
|
|
2559
|
-
return customMessage ||
|
|
2846
|
+
return customMessage || messages.maxLength.replace("{max}", String(max));
|
|
2560
2847
|
}
|
|
2561
2848
|
}
|
|
2562
2849
|
if (typeof value === "number") {
|
|
2563
2850
|
if (min !== void 0 && value < min) {
|
|
2564
|
-
return customMessage ||
|
|
2851
|
+
return customMessage || messages.minValue.replace("{min}", String(min));
|
|
2565
2852
|
}
|
|
2566
2853
|
if (max !== void 0 && value > max) {
|
|
2567
|
-
return customMessage ||
|
|
2854
|
+
return customMessage || messages.maxValue.replace("{max}", String(max));
|
|
2568
2855
|
}
|
|
2569
2856
|
}
|
|
2570
2857
|
if (Array.isArray(value)) {
|
|
2571
2858
|
if (min !== void 0 && value.length < min) {
|
|
2572
|
-
return customMessage ||
|
|
2859
|
+
return customMessage || messages.minItems.replace("{min}", String(min));
|
|
2573
2860
|
}
|
|
2574
2861
|
if (max !== void 0 && value.length > max) {
|
|
2575
|
-
return customMessage ||
|
|
2862
|
+
return customMessage || messages.maxItems.replace("{max}", String(max));
|
|
2576
2863
|
}
|
|
2577
2864
|
}
|
|
2578
2865
|
return null;
|
|
2579
2866
|
}
|
|
2580
|
-
async function validateRule(value, rule, allValues) {
|
|
2867
|
+
async function validateRule(value, rule, allValues, messages = DEFAULT_FORM_VALIDATION_LABELS) {
|
|
2581
2868
|
if (!rule.required && isEmpty(value)) {
|
|
2582
2869
|
return null;
|
|
2583
2870
|
}
|
|
2584
2871
|
const transformedValue = rule.transform ? rule.transform(value) : value;
|
|
2585
2872
|
if (rule.required && isEmpty(transformedValue)) {
|
|
2586
|
-
return rule.message ||
|
|
2873
|
+
return rule.message || messages.required;
|
|
2587
2874
|
}
|
|
2588
2875
|
if (rule.type && !isEmpty(transformedValue)) {
|
|
2589
|
-
const typeError = validateType(transformedValue, rule.type, rule.message);
|
|
2876
|
+
const typeError = validateType(transformedValue, rule.type, rule.message, messages);
|
|
2590
2877
|
if (typeError) return typeError;
|
|
2591
2878
|
}
|
|
2592
2879
|
if (!isEmpty(transformedValue)) {
|
|
2593
|
-
const rangeError = validateRange(transformedValue, rule.min, rule.max, rule.message);
|
|
2880
|
+
const rangeError = validateRange(transformedValue, rule.min, rule.max, rule.message, messages);
|
|
2594
2881
|
if (rangeError) return rangeError;
|
|
2595
2882
|
}
|
|
2596
2883
|
if (rule.pattern && typeof transformedValue === "string") {
|
|
2597
2884
|
if (!rule.pattern.test(transformedValue)) {
|
|
2598
|
-
return rule.message ||
|
|
2885
|
+
return rule.message || messages.patternMismatch;
|
|
2599
2886
|
}
|
|
2600
2887
|
}
|
|
2601
2888
|
if (rule.validator) {
|
|
2602
2889
|
try {
|
|
2603
2890
|
const result = await rule.validator(transformedValue, allValues);
|
|
2604
2891
|
if (result === false) {
|
|
2605
|
-
return rule.message ||
|
|
2892
|
+
return rule.message || messages.validatorFailed;
|
|
2606
2893
|
}
|
|
2607
2894
|
if (typeof result === "string") {
|
|
2608
2895
|
return result;
|
|
2609
2896
|
}
|
|
2610
2897
|
} catch {
|
|
2611
|
-
return rule.message ||
|
|
2898
|
+
return rule.message || messages.validatorError;
|
|
2612
2899
|
}
|
|
2613
2900
|
}
|
|
2614
2901
|
return null;
|
|
2615
2902
|
}
|
|
2616
|
-
async function validateField(fieldName, value, rules, allValues, trigger) {
|
|
2903
|
+
async function validateField(fieldName, value, rules, allValues, trigger, messages = DEFAULT_FORM_VALIDATION_LABELS) {
|
|
2617
2904
|
if (!rules) {
|
|
2618
2905
|
return null;
|
|
2619
2906
|
}
|
|
@@ -2626,18 +2913,18 @@ async function validateField(fieldName, value, rules, allValues, trigger) {
|
|
|
2626
2913
|
continue;
|
|
2627
2914
|
}
|
|
2628
2915
|
}
|
|
2629
|
-
const error = await validateRule(value, rule, allValues);
|
|
2916
|
+
const error = await validateRule(value, rule, allValues, messages);
|
|
2630
2917
|
if (error) {
|
|
2631
2918
|
return error;
|
|
2632
2919
|
}
|
|
2633
2920
|
}
|
|
2634
2921
|
return null;
|
|
2635
2922
|
}
|
|
2636
|
-
async function validateForm(values, rules) {
|
|
2923
|
+
async function validateForm(values, rules, messages = DEFAULT_FORM_VALIDATION_LABELS) {
|
|
2637
2924
|
const errors = [];
|
|
2638
2925
|
for (const [fieldName, fieldRules] of Object.entries(rules)) {
|
|
2639
2926
|
const value = getValueByPath(values, fieldName);
|
|
2640
|
-
const error = await validateField(fieldName, value, fieldRules, values);
|
|
2927
|
+
const error = await validateField(fieldName, value, fieldRules, values, void 0, messages);
|
|
2641
2928
|
if (error) {
|
|
2642
2929
|
errors.push({
|
|
2643
2930
|
field: fieldName,
|
|
@@ -2650,14 +2937,14 @@ async function validateForm(values, rules) {
|
|
|
2650
2937
|
errors
|
|
2651
2938
|
};
|
|
2652
2939
|
}
|
|
2653
|
-
async function validateFormFields(values, rules, fieldNames, trigger) {
|
|
2940
|
+
async function validateFormFields(values, rules, fieldNames, trigger, messages = DEFAULT_FORM_VALIDATION_LABELS) {
|
|
2654
2941
|
const errors = [];
|
|
2655
2942
|
const uniqueFieldNames = Array.from(new Set(fieldNames));
|
|
2656
2943
|
for (const fieldName of uniqueFieldNames) {
|
|
2657
2944
|
const fieldRules = rules[fieldName];
|
|
2658
2945
|
if (!fieldRules) continue;
|
|
2659
2946
|
const value = getValueByPath(values, fieldName);
|
|
2660
|
-
const error = await validateField(fieldName, value, fieldRules, values, trigger);
|
|
2947
|
+
const error = await validateField(fieldName, value, fieldRules, values, trigger, messages);
|
|
2661
2948
|
if (error) {
|
|
2662
2949
|
errors.push({ field: fieldName, message: error });
|
|
2663
2950
|
}
|
|
@@ -2805,6 +3092,23 @@ function normalizeDate(date) {
|
|
|
2805
3092
|
normalized.setHours(0, 0, 0, 0);
|
|
2806
3093
|
return normalized;
|
|
2807
3094
|
}
|
|
3095
|
+
function addDays(date, days) {
|
|
3096
|
+
const next = new Date(date);
|
|
3097
|
+
next.setDate(next.getDate() + days);
|
|
3098
|
+
return next;
|
|
3099
|
+
}
|
|
3100
|
+
function addMonths(date, months) {
|
|
3101
|
+
const next = new Date(date);
|
|
3102
|
+
const day = next.getDate();
|
|
3103
|
+
next.setDate(1);
|
|
3104
|
+
next.setMonth(next.getMonth() + months);
|
|
3105
|
+
const maxDay = getDaysInMonth(next.getFullYear(), next.getMonth());
|
|
3106
|
+
next.setDate(Math.min(day, maxDay));
|
|
3107
|
+
return next;
|
|
3108
|
+
}
|
|
3109
|
+
function addYears(date, years) {
|
|
3110
|
+
return addMonths(date, years * 12);
|
|
3111
|
+
}
|
|
2808
3112
|
function isDateInRange(date, minDate, maxDate) {
|
|
2809
3113
|
if (isNaN(date.getTime())) return false;
|
|
2810
3114
|
const normalizedDate = normalizeDate(date);
|
|
@@ -3960,6 +4264,22 @@ function filterHiddenColumns(columns, hiddenKeys) {
|
|
|
3960
4264
|
const visible = columns.filter((column) => !hidden.has(column.key));
|
|
3961
4265
|
return visible.length === columns.length ? columns : visible;
|
|
3962
4266
|
}
|
|
4267
|
+
function orderTableFixedColumns(columns) {
|
|
4268
|
+
const left = [];
|
|
4269
|
+
const normal = [];
|
|
4270
|
+
const right = [];
|
|
4271
|
+
for (const column of columns) {
|
|
4272
|
+
if (column.fixed === "left") {
|
|
4273
|
+
left.push(column);
|
|
4274
|
+
} else if (column.fixed === "right") {
|
|
4275
|
+
right.push(column);
|
|
4276
|
+
} else {
|
|
4277
|
+
normal.push(column);
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
if (left.length === 0 && right.length === 0) return columns;
|
|
4281
|
+
return [...left, ...normal, ...right];
|
|
4282
|
+
}
|
|
3963
4283
|
function parseWidthToPx(width) {
|
|
3964
4284
|
if (typeof width === "number" && Number.isFinite(width)) {
|
|
3965
4285
|
return width;
|
|
@@ -4024,6 +4344,9 @@ function freezeTableColumnWidths(columns, measuredWidths = {}, previousFrozen =
|
|
|
4024
4344
|
const unchanged = previousKeys.length === nextKeys.length && nextKeys.every((key) => previousFrozen[key] === next[key]);
|
|
4025
4345
|
return unchanged ? previousFrozen : next;
|
|
4026
4346
|
}
|
|
4347
|
+
function getColumnWidthForOffset(column, measuredColumnWidths) {
|
|
4348
|
+
return measuredColumnWidths[column.key] || parseWidthToPx(column.width);
|
|
4349
|
+
}
|
|
4027
4350
|
function getFixedColumnOffsets(columns, measuredColumnWidths = {}) {
|
|
4028
4351
|
const leftOffsets = {};
|
|
4029
4352
|
const rightOffsets = {};
|
|
@@ -4034,8 +4357,8 @@ function getFixedColumnOffsets(columns, measuredColumnWidths = {}) {
|
|
|
4034
4357
|
if (column.fixed === "left") {
|
|
4035
4358
|
leftOffsets[column.key] = left;
|
|
4036
4359
|
hasLeftFixedColumns = true;
|
|
4360
|
+
left += getColumnWidthForOffset(column, measuredColumnWidths);
|
|
4037
4361
|
}
|
|
4038
|
-
left += measuredColumnWidths[column.key] || parseWidthToPx(column.width);
|
|
4039
4362
|
}
|
|
4040
4363
|
let right = 0;
|
|
4041
4364
|
for (let i = columns.length - 1; i >= 0; i--) {
|
|
@@ -4043,11 +4366,11 @@ function getFixedColumnOffsets(columns, measuredColumnWidths = {}) {
|
|
|
4043
4366
|
if (column.fixed === "right") {
|
|
4044
4367
|
rightOffsets[column.key] = right;
|
|
4045
4368
|
hasRightFixedColumns = true;
|
|
4369
|
+
right += getColumnWidthForOffset(column, measuredColumnWidths);
|
|
4046
4370
|
}
|
|
4047
|
-
right += measuredColumnWidths[column.key] || parseWidthToPx(column.width);
|
|
4048
4371
|
}
|
|
4049
4372
|
const minTableWidth = columns.reduce(
|
|
4050
|
-
(sum, col) => sum + (
|
|
4373
|
+
(sum, col) => sum + getColumnWidthForOffset(col, measuredColumnWidths),
|
|
4051
4374
|
0
|
|
4052
4375
|
);
|
|
4053
4376
|
const hasFixedColumns = hasLeftFixedColumns || hasRightFixedColumns;
|
|
@@ -4767,6 +5090,75 @@ function getVisibleTreeItems(treeData, expandedKeys = /* @__PURE__ */ new Set(),
|
|
|
4767
5090
|
traverse(treeData, 1);
|
|
4768
5091
|
return result;
|
|
4769
5092
|
}
|
|
5093
|
+
function getFirstVisibleChildKey(visibleItems, parentKey) {
|
|
5094
|
+
const index = visibleItems.findIndex((item) => item.key === parentKey);
|
|
5095
|
+
if (index < 0) return void 0;
|
|
5096
|
+
const base = visibleItems[index];
|
|
5097
|
+
for (let i = index + 1; i < visibleItems.length; i++) {
|
|
5098
|
+
const item = visibleItems[i];
|
|
5099
|
+
if (item.level <= base.level) break;
|
|
5100
|
+
if (item.parentKey === parentKey && !item.node.disabled) return item.key;
|
|
5101
|
+
}
|
|
5102
|
+
return void 0;
|
|
5103
|
+
}
|
|
5104
|
+
function getTreeKeyboardAction(ctx) {
|
|
5105
|
+
const {
|
|
5106
|
+
key,
|
|
5107
|
+
nodeKey,
|
|
5108
|
+
currentKey,
|
|
5109
|
+
focusableKeys,
|
|
5110
|
+
parentKey,
|
|
5111
|
+
firstChildKey,
|
|
5112
|
+
isExpandable,
|
|
5113
|
+
isExpanded,
|
|
5114
|
+
isParentExpanded,
|
|
5115
|
+
isChecked,
|
|
5116
|
+
selectable,
|
|
5117
|
+
checkable
|
|
5118
|
+
} = ctx;
|
|
5119
|
+
const currentIndex = focusableKeys.findIndex((k) => k === currentKey);
|
|
5120
|
+
const focusAt = (index) => ({
|
|
5121
|
+
type: "focus",
|
|
5122
|
+
key: focusableKeys[index] ?? currentKey
|
|
5123
|
+
});
|
|
5124
|
+
switch (key) {
|
|
5125
|
+
case "ArrowDown":
|
|
5126
|
+
return focusAt(currentIndex + 1);
|
|
5127
|
+
case "ArrowUp":
|
|
5128
|
+
return focusAt(currentIndex - 1);
|
|
5129
|
+
case "Home":
|
|
5130
|
+
return focusAt(0);
|
|
5131
|
+
case "End":
|
|
5132
|
+
return focusAt(focusableKeys.length - 1);
|
|
5133
|
+
case "ArrowRight":
|
|
5134
|
+
if (isExpandable && !isExpanded) return { type: "toggleExpand", key: nodeKey };
|
|
5135
|
+
if (isExpandable && isExpanded) return { type: "focus", key: firstChildKey ?? currentKey };
|
|
5136
|
+
return { type: "none" };
|
|
5137
|
+
case "ArrowLeft":
|
|
5138
|
+
if (isExpandable && isExpanded) return { type: "toggleExpand", key: nodeKey };
|
|
5139
|
+
return { type: "focus", key: parentKey ?? currentKey };
|
|
5140
|
+
case "Escape":
|
|
5141
|
+
if (isExpandable && isExpanded) return { type: "toggleExpand", key: nodeKey };
|
|
5142
|
+
if (parentKey !== void 0) {
|
|
5143
|
+
return {
|
|
5144
|
+
type: "collapseAndFocus",
|
|
5145
|
+
collapseKey: isParentExpanded ? parentKey : void 0,
|
|
5146
|
+
focusKey: parentKey
|
|
5147
|
+
};
|
|
5148
|
+
}
|
|
5149
|
+
return { type: "none" };
|
|
5150
|
+
case "Enter":
|
|
5151
|
+
if (selectable) return { type: "select", key: nodeKey };
|
|
5152
|
+
if (isExpandable) return { type: "toggleExpand", key: nodeKey };
|
|
5153
|
+
return { type: "none" };
|
|
5154
|
+
case " ":
|
|
5155
|
+
if (checkable) return { type: "check", key: nodeKey, checked: !isChecked };
|
|
5156
|
+
if (isExpandable) return { type: "toggleExpand", key: nodeKey };
|
|
5157
|
+
return { type: "none" };
|
|
5158
|
+
default:
|
|
5159
|
+
return null;
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
4770
5162
|
var treeBaseClasses = "w-full bg-white rounded-[var(--tiger-radius-md,0.5rem)]";
|
|
4771
5163
|
var treeNodeWrapperClasses = "select-none";
|
|
4772
5164
|
var treeNodeContentClasses = "flex items-center px-2 py-1.5 cursor-pointer rounded transition-colors duration-200";
|
|
@@ -5524,6 +5916,10 @@ function createSubmenuHeightTransitionController(element, options) {
|
|
|
5524
5916
|
}
|
|
5525
5917
|
};
|
|
5526
5918
|
}
|
|
5919
|
+
function getMenuNavigationKeys(mode, isRoot) {
|
|
5920
|
+
const isHorizontalRoot = isRoot && mode === "horizontal";
|
|
5921
|
+
return isHorizontalRoot ? { nextKey: "ArrowRight", prevKey: "ArrowLeft" } : { nextKey: "ArrowDown", prevKey: "ArrowUp" };
|
|
5922
|
+
}
|
|
5527
5923
|
function getMenuButtons(container) {
|
|
5528
5924
|
return Array.from(
|
|
5529
5925
|
container.querySelectorAll('button[data-tiger-menuitem="true"]')
|
|
@@ -7049,7 +7445,7 @@ function getCodeBlockCopyButtonClasses(isCopied, ...classes) {
|
|
|
7049
7445
|
);
|
|
7050
7446
|
}
|
|
7051
7447
|
|
|
7052
|
-
// src/theme/colors.ts
|
|
7448
|
+
// src/theme-runtime/colors.ts
|
|
7053
7449
|
var defaultThemeColors = {
|
|
7054
7450
|
primary: {
|
|
7055
7451
|
bg: "bg-[var(--tiger-primary,#2563eb)]",
|
|
@@ -7527,6 +7923,9 @@ function getInitialCropRect(imageWidth, imageHeight, aspectRatio) {
|
|
|
7527
7923
|
};
|
|
7528
7924
|
}
|
|
7529
7925
|
function cropCanvas(image, cropRect, displayWidth, displayHeight, outputType = "image/png", quality = 0.92) {
|
|
7926
|
+
if (!isBrowser()) {
|
|
7927
|
+
throw new Error("Image canvas cropping is only available in the browser");
|
|
7928
|
+
}
|
|
7530
7929
|
const scaleX = image.naturalWidth / displayWidth;
|
|
7531
7930
|
const scaleY = image.naturalHeight / displayHeight;
|
|
7532
7931
|
const sx = cropRect.x * scaleX;
|
|
@@ -7867,6 +8266,9 @@ function getAnchorLinkClasses(active, className) {
|
|
|
7867
8266
|
return [anchorLinkBaseClasses, active && anchorLinkActiveClasses, className].filter(Boolean).join(" ");
|
|
7868
8267
|
}
|
|
7869
8268
|
function getAnchorTargetElement(href) {
|
|
8269
|
+
if (!isBrowser()) {
|
|
8270
|
+
return null;
|
|
8271
|
+
}
|
|
7870
8272
|
if (!href || !href.startsWith("#")) {
|
|
7871
8273
|
return null;
|
|
7872
8274
|
}
|
|
@@ -7877,18 +8279,27 @@ function getAnchorTargetElement(href) {
|
|
|
7877
8279
|
return document.getElementById(id);
|
|
7878
8280
|
}
|
|
7879
8281
|
function getContainerScrollTop(container) {
|
|
8282
|
+
if (!isBrowser()) {
|
|
8283
|
+
return container?.scrollTop ?? 0;
|
|
8284
|
+
}
|
|
7880
8285
|
if (container === window) {
|
|
7881
8286
|
return window.scrollY || document.documentElement.scrollTop;
|
|
7882
8287
|
}
|
|
7883
8288
|
return container.scrollTop;
|
|
7884
8289
|
}
|
|
7885
8290
|
function getContainerHeight(container) {
|
|
8291
|
+
if (!isBrowser()) {
|
|
8292
|
+
return container?.clientHeight ?? 0;
|
|
8293
|
+
}
|
|
7886
8294
|
if (container === window) {
|
|
7887
8295
|
return window.innerHeight;
|
|
7888
8296
|
}
|
|
7889
8297
|
return container.clientHeight;
|
|
7890
8298
|
}
|
|
7891
8299
|
function getElementOffsetTop(element, container) {
|
|
8300
|
+
if (!isBrowser()) {
|
|
8301
|
+
return 0;
|
|
8302
|
+
}
|
|
7892
8303
|
if (container === window) {
|
|
7893
8304
|
const rect = element.getBoundingClientRect();
|
|
7894
8305
|
return rect.top + window.scrollY;
|
|
@@ -7908,6 +8319,9 @@ function getElementOffsetTop(element, container) {
|
|
|
7908
8319
|
return offset2;
|
|
7909
8320
|
}
|
|
7910
8321
|
function scrollToAnchor(href, container, targetOffset = 0) {
|
|
8322
|
+
if (!isBrowser()) {
|
|
8323
|
+
return;
|
|
8324
|
+
}
|
|
7911
8325
|
const element = getAnchorTargetElement(href);
|
|
7912
8326
|
if (!element) {
|
|
7913
8327
|
return;
|
|
@@ -7920,6 +8334,9 @@ function findActiveAnchor(links, container, bounds = 5, targetOffset = 0) {
|
|
|
7920
8334
|
if (links.length === 0) {
|
|
7921
8335
|
return "";
|
|
7922
8336
|
}
|
|
8337
|
+
if (!isBrowser()) {
|
|
8338
|
+
return links[0] || "";
|
|
8339
|
+
}
|
|
7923
8340
|
const scrollTop = getContainerScrollTop(container);
|
|
7924
8341
|
for (let i = links.length - 1; i >= 0; i--) {
|
|
7925
8342
|
const href = links[i];
|
|
@@ -7934,11 +8351,11 @@ function findActiveAnchor(links, container, bounds = 5, targetOffset = 0) {
|
|
|
7934
8351
|
return links[0] || "";
|
|
7935
8352
|
}
|
|
7936
8353
|
function createAnchorObserver(links, options) {
|
|
8354
|
+
if (!isBrowser()) return () => {
|
|
8355
|
+
};
|
|
7937
8356
|
if (typeof IntersectionObserver === "undefined") return () => {
|
|
7938
8357
|
};
|
|
7939
8358
|
const { offsetTop = 0, root = null, onChange } = options;
|
|
7940
|
-
if (!isBrowser()) return () => {
|
|
7941
|
-
};
|
|
7942
8359
|
const targets = /* @__PURE__ */ new Map();
|
|
7943
8360
|
for (const href of links) {
|
|
7944
8361
|
const el = getAnchorTargetElement(href);
|
|
@@ -11415,97 +11832,6 @@ function clampCronNumber(value, min, max) {
|
|
|
11415
11832
|
return Math.max(min, Math.min(max, Math.round(value)));
|
|
11416
11833
|
}
|
|
11417
11834
|
|
|
11418
|
-
// src/utils/picker-utils.ts
|
|
11419
|
-
var defaultIsDisabled = (item) => !!item?.disabled;
|
|
11420
|
-
function findFirstEnabledIndex(items, isDisabled = defaultIsDisabled) {
|
|
11421
|
-
for (let i = 0; i < items.length; i++) {
|
|
11422
|
-
if (!isDisabled(items[i])) return i;
|
|
11423
|
-
}
|
|
11424
|
-
return -1;
|
|
11425
|
-
}
|
|
11426
|
-
function findLastEnabledIndex(items, isDisabled = defaultIsDisabled) {
|
|
11427
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
|
11428
|
-
if (!isDisabled(items[i])) return i;
|
|
11429
|
-
}
|
|
11430
|
-
return -1;
|
|
11431
|
-
}
|
|
11432
|
-
function findNextEnabledIndex(items, current, direction, isDisabled = defaultIsDisabled) {
|
|
11433
|
-
if (items.length === 0) return -1;
|
|
11434
|
-
const start = current < 0 ? direction === 1 ? 0 : items.length - 1 : current + direction;
|
|
11435
|
-
for (let i = start; i >= 0 && i < items.length; i += direction) {
|
|
11436
|
-
if (!isDisabled(items[i])) return i;
|
|
11437
|
-
}
|
|
11438
|
-
return current;
|
|
11439
|
-
}
|
|
11440
|
-
function getInitialPickerActiveIndex(items, activeFirst, isDisabled = defaultIsDisabled) {
|
|
11441
|
-
return activeFirst ? findFirstEnabledIndex(items, isDisabled) : -1;
|
|
11442
|
-
}
|
|
11443
|
-
function getPickerNavigationIndex(items, current, key, isDisabled = defaultIsDisabled) {
|
|
11444
|
-
switch (key) {
|
|
11445
|
-
case "ArrowDown":
|
|
11446
|
-
return findNextEnabledIndex(items, current, 1, isDisabled);
|
|
11447
|
-
case "ArrowUp":
|
|
11448
|
-
return findNextEnabledIndex(items, current, -1, isDisabled);
|
|
11449
|
-
case "Home":
|
|
11450
|
-
return findFirstEnabledIndex(items, isDisabled);
|
|
11451
|
-
case "End":
|
|
11452
|
-
return findLastEnabledIndex(items, isDisabled);
|
|
11453
|
-
default:
|
|
11454
|
-
return current;
|
|
11455
|
-
}
|
|
11456
|
-
}
|
|
11457
|
-
function getPickerOptionId(listboxId, index) {
|
|
11458
|
-
return `${listboxId}-option-${index}`;
|
|
11459
|
-
}
|
|
11460
|
-
function getDisclosureStateAttr(open) {
|
|
11461
|
-
return { "data-state": open ? "open" : "closed" };
|
|
11462
|
-
}
|
|
11463
|
-
function getPickerComboboxAria({
|
|
11464
|
-
expanded,
|
|
11465
|
-
listboxId,
|
|
11466
|
-
activeIndex = -1,
|
|
11467
|
-
activeOptionId
|
|
11468
|
-
}) {
|
|
11469
|
-
return {
|
|
11470
|
-
role: "combobox",
|
|
11471
|
-
"aria-expanded": expanded,
|
|
11472
|
-
"aria-haspopup": "listbox",
|
|
11473
|
-
"aria-controls": expanded ? listboxId : void 0,
|
|
11474
|
-
"aria-activedescendant": expanded ? activeOptionId ?? (activeIndex >= 0 ? getPickerOptionId(listboxId, activeIndex) : void 0) : void 0,
|
|
11475
|
-
"data-state": expanded ? "open" : "closed"
|
|
11476
|
-
};
|
|
11477
|
-
}
|
|
11478
|
-
function getPickerListboxAria({ id, label } = {}) {
|
|
11479
|
-
return {
|
|
11480
|
-
id,
|
|
11481
|
-
role: "listbox",
|
|
11482
|
-
"aria-label": label
|
|
11483
|
-
};
|
|
11484
|
-
}
|
|
11485
|
-
function getPickerOptionAria({
|
|
11486
|
-
selected = false,
|
|
11487
|
-
disabled = false
|
|
11488
|
-
}) {
|
|
11489
|
-
return {
|
|
11490
|
-
role: "option",
|
|
11491
|
-
"aria-selected": selected,
|
|
11492
|
-
"aria-disabled": disabled || void 0
|
|
11493
|
-
};
|
|
11494
|
-
}
|
|
11495
|
-
function getPickerTriggerKeyAction(key, expanded) {
|
|
11496
|
-
switch (key) {
|
|
11497
|
-
case "Enter":
|
|
11498
|
-
case " ":
|
|
11499
|
-
return "toggle";
|
|
11500
|
-
case "ArrowDown":
|
|
11501
|
-
return expanded ? "none" : "open";
|
|
11502
|
-
case "Escape":
|
|
11503
|
-
return expanded ? "close" : "none";
|
|
11504
|
-
default:
|
|
11505
|
-
return "none";
|
|
11506
|
-
}
|
|
11507
|
-
}
|
|
11508
|
-
|
|
11509
11835
|
// src/utils/spotlight-utils.ts
|
|
11510
11836
|
var spotlightRootClasses = "fixed inset-0 flex items-start justify-center px-4 py-6 sm:py-10";
|
|
11511
11837
|
var spotlightMaskClasses = "absolute inset-0 bg-black/35";
|
|
@@ -12756,6 +13082,7 @@ function exportTableToExcel(columns, data) {
|
|
|
12756
13082
|
return `<!doctype html><html><head><meta charset="utf-8"></head><body><table><thead><tr>${headerCells}</tr></thead><tbody>${bodyRows}</tbody></table></body></html>`;
|
|
12757
13083
|
}
|
|
12758
13084
|
function downloadCsv(csvContent, filename = "export") {
|
|
13085
|
+
if (!isBrowser()) return;
|
|
12759
13086
|
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
12760
13087
|
const url = URL.createObjectURL(blob);
|
|
12761
13088
|
const link = document.createElement("a");
|
|
@@ -12768,6 +13095,7 @@ function downloadCsv(csvContent, filename = "export") {
|
|
|
12768
13095
|
URL.revokeObjectURL(url);
|
|
12769
13096
|
}
|
|
12770
13097
|
function downloadExcel(excelContent, filename = "export") {
|
|
13098
|
+
if (!isBrowser()) return;
|
|
12771
13099
|
const blob = new Blob([excelContent], { type: "application/vnd.ms-excel;charset=utf-8;" });
|
|
12772
13100
|
const url = URL.createObjectURL(blob);
|
|
12773
13101
|
const link = document.createElement("a");
|
|
@@ -14229,7 +14557,6 @@ var kanbanSwimlaneDotClasses = "w-2.5 h-2.5 rounded-full shrink-0";
|
|
|
14229
14557
|
var kanbanSwimlaneCollapsedClasses = "hidden";
|
|
14230
14558
|
var kanbanFilterHighlightClasses = "bg-[var(--tiger-warning,#fbbf24)]/20";
|
|
14231
14559
|
var kanbanAddColumnClasses = "flex items-center justify-center shrink-0 w-76 min-h-[120px] rounded-[var(--tiger-radius-lg,0.75rem)] border-2 border-dashed border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface-muted,#f9fafb)]/40 text-sm font-medium text-[var(--tiger-text-muted,#6b7280)] hover:border-[var(--tiger-primary,#2563eb)]/80 hover:text-[var(--tiger-primary,#2563eb)] hover:bg-[var(--tiger-surface,#ffffff)] hover:shadow-sm cursor-pointer transition-all duration-300 active:scale-98";
|
|
14232
|
-
var kanbanAddCardClasses = taskBoardAddCardClasses;
|
|
14233
14560
|
function filterCards(cards, filterText) {
|
|
14234
14561
|
if (!filterText.trim()) return cards;
|
|
14235
14562
|
const lower = filterText.toLowerCase();
|
|
@@ -15250,6 +15577,7 @@ function getChartSvgDataUrl(svg) {
|
|
|
15250
15577
|
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(serializeChartSvg(svg))}`;
|
|
15251
15578
|
}
|
|
15252
15579
|
function downloadChartSvg(svg, filename = "chart") {
|
|
15580
|
+
if (!isBrowser()) return;
|
|
15253
15581
|
downloadChartBlob(
|
|
15254
15582
|
new Blob([serializeChartSvg(svg)], { type: "image/svg+xml;charset=utf-8" }),
|
|
15255
15583
|
`${filename}.svg`
|
|
@@ -15289,6 +15617,7 @@ async function exportChartPng(svg, options = {}) {
|
|
|
15289
15617
|
});
|
|
15290
15618
|
}
|
|
15291
15619
|
async function downloadChartPng(svg, options = {}) {
|
|
15620
|
+
if (!isBrowser()) return;
|
|
15292
15621
|
const blob = await exportChartPng(svg, options);
|
|
15293
15622
|
downloadChartBlob(blob, `${options.filename ?? "chart"}.png`);
|
|
15294
15623
|
}
|
|
@@ -15465,7 +15794,7 @@ async function getCropperResult(cropper) {
|
|
|
15465
15794
|
return await cropper.getCropResult();
|
|
15466
15795
|
}
|
|
15467
15796
|
|
|
15468
|
-
// src/theme/checkbox.ts
|
|
15797
|
+
// src/theme-runtime/checkbox.ts
|
|
15469
15798
|
var checkboxSizeClasses2 = {
|
|
15470
15799
|
sm: "w-4 h-4",
|
|
15471
15800
|
md: "w-5 h-5",
|
|
@@ -15490,7 +15819,7 @@ function getCheckboxLabelClasses(size = "md", disabled = false) {
|
|
|
15490
15819
|
return [baseClasses2, sizeClass, disabledClasses].filter(Boolean).join(" ");
|
|
15491
15820
|
}
|
|
15492
15821
|
|
|
15493
|
-
// src/theme/switch.ts
|
|
15822
|
+
// src/theme-runtime/switch.ts
|
|
15494
15823
|
var switchBaseClasses = "relative inline-flex items-center rounded-full transition-all duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-[var(--tiger-focus-ring,var(--tiger-primary,#2563eb))] active:scale-[0.98]";
|
|
15495
15824
|
var switchSizeClasses = {
|
|
15496
15825
|
sm: "h-5 w-9",
|
|
@@ -15525,7 +15854,7 @@ function getSwitchThumbClasses(size = "md", checked = false) {
|
|
|
15525
15854
|
return classNames(baseClasses2, sizeClass, translateClass);
|
|
15526
15855
|
}
|
|
15527
15856
|
|
|
15528
|
-
// src/theme/slider.ts
|
|
15857
|
+
// src/theme-runtime/slider.ts
|
|
15529
15858
|
var sliderBaseClasses = "relative w-full";
|
|
15530
15859
|
var sliderTrackClasses = "bg-[var(--tiger-border,#e5e7eb)] rounded-full";
|
|
15531
15860
|
var sliderRangeClasses = "bg-[var(--tiger-primary,#2563eb)] rounded-full absolute h-full";
|
|
@@ -15564,7 +15893,7 @@ function getSliderTooltipClasses(size = "md") {
|
|
|
15564
15893
|
return [sliderTooltipClasses, sizeClass].filter(Boolean).join(" ");
|
|
15565
15894
|
}
|
|
15566
15895
|
|
|
15567
|
-
// src/theme/index.ts
|
|
15896
|
+
// src/theme-runtime/index.ts
|
|
15568
15897
|
var THEME_CSS_VARS = {
|
|
15569
15898
|
// Primary colors
|
|
15570
15899
|
primary: "--tiger-primary",
|
|
@@ -17127,7 +17456,7 @@ var designTokens = {
|
|
|
17127
17456
|
};
|
|
17128
17457
|
|
|
17129
17458
|
// src/index.ts
|
|
17130
|
-
var version = "1.
|
|
17459
|
+
var version = "1.4.0";
|
|
17131
17460
|
export {
|
|
17132
17461
|
ANIMATION_DURATION_FAST_MS,
|
|
17133
17462
|
ANIMATION_DURATION_MS,
|
|
@@ -17142,12 +17471,15 @@ export {
|
|
|
17142
17471
|
ClockIconPath,
|
|
17143
17472
|
CloseIconPath,
|
|
17144
17473
|
DEFAULT_CHART_COLORS,
|
|
17474
|
+
DEFAULT_FORM_VALIDATION_LABELS,
|
|
17145
17475
|
DEFAULT_FORM_WIZARD_LABELS,
|
|
17146
17476
|
DEFAULT_HEATMAP_CANVAS_THRESHOLD,
|
|
17147
17477
|
DEFAULT_PAGINATION_LABELS,
|
|
17148
17478
|
DEFAULT_TABLE_LABELS,
|
|
17149
17479
|
DEFAULT_TASK_BOARD_LABELS,
|
|
17480
|
+
DEFAULT_TIME_PICKER_LABELS,
|
|
17150
17481
|
DEFAULT_UPLOAD_CHUNK_SIZE,
|
|
17482
|
+
DEFAULT_UPLOAD_LABELS,
|
|
17151
17483
|
DONUT_BASE_SHADOW,
|
|
17152
17484
|
DONUT_EMPHASIS_SHADOW,
|
|
17153
17485
|
DROPDOWN_CHEVRON_PATH,
|
|
@@ -17205,10 +17537,13 @@ export {
|
|
|
17205
17537
|
VIEW_TRANSITION_CSS,
|
|
17206
17538
|
WEEKDAYS,
|
|
17207
17539
|
ZH_CN_DATEPICKER_LOCALE,
|
|
17540
|
+
ZH_CN_FORM_VALIDATION_LABELS,
|
|
17208
17541
|
ZH_CN_FORM_WIZARD_LABELS,
|
|
17209
17542
|
ZH_CN_PAGINATION_LABELS,
|
|
17210
17543
|
ZH_CN_TABLE_LABELS,
|
|
17211
17544
|
ZH_CN_TASK_BOARD_LABELS,
|
|
17545
|
+
ZH_CN_TIME_PICKER_LABELS,
|
|
17546
|
+
ZH_CN_UPLOAD_LABELS,
|
|
17212
17547
|
activeOpacityClasses,
|
|
17213
17548
|
activePressClasses,
|
|
17214
17549
|
activityItemActionsClasses,
|
|
@@ -17218,6 +17553,9 @@ export {
|
|
|
17218
17553
|
activityItemHeaderClasses,
|
|
17219
17554
|
activityItemLayoutClasses,
|
|
17220
17555
|
activityItemTitleGroupClasses,
|
|
17556
|
+
addDays,
|
|
17557
|
+
addMonths,
|
|
17558
|
+
addYears,
|
|
17221
17559
|
affixWrapperClasses,
|
|
17222
17560
|
alertBannerClasses,
|
|
17223
17561
|
alertBaseClasses,
|
|
@@ -17497,6 +17835,7 @@ export {
|
|
|
17497
17835
|
createImageAnnotationBox,
|
|
17498
17836
|
createImageAnnotationPath,
|
|
17499
17837
|
createInfiniteScrollObserver,
|
|
17838
|
+
createInstanceCounter,
|
|
17500
17839
|
createLinePath,
|
|
17501
17840
|
createLinearScale,
|
|
17502
17841
|
createLongPressController,
|
|
@@ -17692,6 +18031,7 @@ export {
|
|
|
17692
18031
|
focusMenuEdge,
|
|
17693
18032
|
focusRingClasses,
|
|
17694
18033
|
focusRingInsetClasses,
|
|
18034
|
+
focusTimePickerOption,
|
|
17695
18035
|
formatActivityTime,
|
|
17696
18036
|
formatBadgeContent,
|
|
17697
18037
|
formatChatTime,
|
|
@@ -17703,6 +18043,7 @@ export {
|
|
|
17703
18043
|
formatFileSize,
|
|
17704
18044
|
formatFileSizeLabel,
|
|
17705
18045
|
formatGanttDate,
|
|
18046
|
+
formatInputNumberDisplay,
|
|
17706
18047
|
formatIntlNumber,
|
|
17707
18048
|
formatMonthYear,
|
|
17708
18049
|
formatPageAriaLabel,
|
|
@@ -17838,6 +18179,7 @@ export {
|
|
|
17838
18179
|
getCropperResult,
|
|
17839
18180
|
getCurrentActiveTourStep,
|
|
17840
18181
|
getCurrentTime,
|
|
18182
|
+
getCyclicIndex,
|
|
17841
18183
|
getDatePickerDayCellClasses,
|
|
17842
18184
|
getDatePickerIconButtonClasses,
|
|
17843
18185
|
getDatePickerInputClasses,
|
|
@@ -17889,6 +18231,7 @@ export {
|
|
|
17889
18231
|
getFileListItemClasses,
|
|
17890
18232
|
getFileManagerContainerClasses,
|
|
17891
18233
|
getFirstDayOfMonth,
|
|
18234
|
+
getFirstVisibleChildKey,
|
|
17892
18235
|
getFixedColumnOffsets,
|
|
17893
18236
|
getFixedColumnPosition,
|
|
17894
18237
|
getFixedColumnStyle,
|
|
@@ -17904,6 +18247,7 @@ export {
|
|
|
17904
18247
|
getFormItemErrorClasses,
|
|
17905
18248
|
getFormItemFieldClasses,
|
|
17906
18249
|
getFormItemLabelClasses,
|
|
18250
|
+
getFormValidationLabels,
|
|
17907
18251
|
getFormWizardLabels,
|
|
17908
18252
|
getFunnelGradientPrefix,
|
|
17909
18253
|
getGanttDependencyPath,
|
|
@@ -17983,6 +18327,7 @@ export {
|
|
|
17983
18327
|
getMenuItemClasses,
|
|
17984
18328
|
getMenuItemIndent,
|
|
17985
18329
|
getMenuItems,
|
|
18330
|
+
getMenuNavigationKeys,
|
|
17986
18331
|
getMessageIconPath,
|
|
17987
18332
|
getMessageTypeClasses,
|
|
17988
18333
|
getModalContainerClasses,
|
|
@@ -18205,6 +18550,7 @@ export {
|
|
|
18205
18550
|
getTransferItemClasses,
|
|
18206
18551
|
getTransformOrigin,
|
|
18207
18552
|
getTransitionClasses,
|
|
18553
|
+
getTreeKeyboardAction,
|
|
18208
18554
|
getTreeMapGradientPrefix,
|
|
18209
18555
|
getTreeNodeClasses,
|
|
18210
18556
|
getTreeNodeExpandIconClasses,
|
|
@@ -18379,7 +18725,6 @@ export {
|
|
|
18379
18725
|
isValidHex,
|
|
18380
18726
|
isValidUrl,
|
|
18381
18727
|
isWipExceeded,
|
|
18382
|
-
kanbanAddCardClasses,
|
|
18383
18728
|
kanbanAddColumnClasses,
|
|
18384
18729
|
kanbanCardCountClasses,
|
|
18385
18730
|
kanbanFilterHighlightClasses,
|
|
@@ -18536,6 +18881,7 @@ export {
|
|
|
18536
18881
|
numberKeyboardGridClasses,
|
|
18537
18882
|
numberKeyboardKeyClasses,
|
|
18538
18883
|
numberKeyboardRootClasses,
|
|
18884
|
+
orderTableFixedColumns,
|
|
18539
18885
|
orgChartLinkClasses,
|
|
18540
18886
|
orgChartNodeClasses,
|
|
18541
18887
|
orgChartNodeLabelClasses,
|
|
@@ -18551,6 +18897,7 @@ export {
|
|
|
18551
18897
|
parseDragData,
|
|
18552
18898
|
parseHeight,
|
|
18553
18899
|
parseHotkey,
|
|
18900
|
+
parseInputNumberValue,
|
|
18554
18901
|
parseInputValue,
|
|
18555
18902
|
parseHeight as parseMarkdownHeight,
|
|
18556
18903
|
parsePaneSize,
|