@keepkit/ui 0.27.1 → 0.28.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/README.md +6 -2
- package/dist/index.d.ts +89 -3
- package/dist/index.js +993 -227
- package/dist/index.js.map +1 -1
- package/dist/styles/collection.css +179 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -203,7 +203,16 @@ var DE_LABELS = {
|
|
|
203
203
|
toolbarEnd: "Zus\xE4tzliche Aktionen",
|
|
204
204
|
createCollection: "Create collection",
|
|
205
205
|
createCollectionSubmit: "Create",
|
|
206
|
-
collectionName: "Collection name"
|
|
206
|
+
collectionName: "Collection name",
|
|
207
|
+
manageCollections: "Manage collections",
|
|
208
|
+
renameCollection: "Rename",
|
|
209
|
+
renameCollectionSubmit: "Save name",
|
|
210
|
+
deleteCollection: "Delete",
|
|
211
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
212
|
+
deleteCollectionSubmit: "Delete collection",
|
|
213
|
+
cancel: "Cancel",
|
|
214
|
+
collectionItem: "item",
|
|
215
|
+
collectionItems: "items"
|
|
207
216
|
};
|
|
208
217
|
|
|
209
218
|
// src/locales/en.ts
|
|
@@ -314,7 +323,16 @@ var EN_LABELS = {
|
|
|
314
323
|
toolbarEnd: "Additional actions",
|
|
315
324
|
createCollection: "Create collection",
|
|
316
325
|
createCollectionSubmit: "Create",
|
|
317
|
-
collectionName: "Collection name"
|
|
326
|
+
collectionName: "Collection name",
|
|
327
|
+
manageCollections: "Manage collections",
|
|
328
|
+
renameCollection: "Rename",
|
|
329
|
+
renameCollectionSubmit: "Save name",
|
|
330
|
+
deleteCollection: "Delete",
|
|
331
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
332
|
+
deleteCollectionSubmit: "Delete collection",
|
|
333
|
+
cancel: "Cancel",
|
|
334
|
+
collectionItem: "item",
|
|
335
|
+
collectionItems: "items"
|
|
318
336
|
};
|
|
319
337
|
|
|
320
338
|
// src/locales/es.ts
|
|
@@ -425,7 +443,16 @@ var ES_LABELS = {
|
|
|
425
443
|
toolbarEnd: "Acciones adicionales",
|
|
426
444
|
createCollection: "Create collection",
|
|
427
445
|
createCollectionSubmit: "Create",
|
|
428
|
-
collectionName: "Collection name"
|
|
446
|
+
collectionName: "Collection name",
|
|
447
|
+
manageCollections: "Manage collections",
|
|
448
|
+
renameCollection: "Rename",
|
|
449
|
+
renameCollectionSubmit: "Save name",
|
|
450
|
+
deleteCollection: "Delete",
|
|
451
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
452
|
+
deleteCollectionSubmit: "Delete collection",
|
|
453
|
+
cancel: "Cancel",
|
|
454
|
+
collectionItem: "item",
|
|
455
|
+
collectionItems: "items"
|
|
429
456
|
};
|
|
430
457
|
|
|
431
458
|
// src/locales/fil.ts
|
|
@@ -536,7 +563,16 @@ var FIL_LABELS = {
|
|
|
536
563
|
toolbarEnd: "Mga karagdagang aksyon",
|
|
537
564
|
createCollection: "Create collection",
|
|
538
565
|
createCollectionSubmit: "Create",
|
|
539
|
-
collectionName: "Collection name"
|
|
566
|
+
collectionName: "Collection name",
|
|
567
|
+
manageCollections: "Manage collections",
|
|
568
|
+
renameCollection: "Rename",
|
|
569
|
+
renameCollectionSubmit: "Save name",
|
|
570
|
+
deleteCollection: "Delete",
|
|
571
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
572
|
+
deleteCollectionSubmit: "Delete collection",
|
|
573
|
+
cancel: "Cancel",
|
|
574
|
+
collectionItem: "item",
|
|
575
|
+
collectionItems: "items"
|
|
540
576
|
};
|
|
541
577
|
|
|
542
578
|
// src/locales/fr.ts
|
|
@@ -647,7 +683,16 @@ var FR_LABELS = {
|
|
|
647
683
|
toolbarEnd: "Actions suppl\xE9mentaires",
|
|
648
684
|
createCollection: "Create collection",
|
|
649
685
|
createCollectionSubmit: "Create",
|
|
650
|
-
collectionName: "Collection name"
|
|
686
|
+
collectionName: "Collection name",
|
|
687
|
+
manageCollections: "Manage collections",
|
|
688
|
+
renameCollection: "Rename",
|
|
689
|
+
renameCollectionSubmit: "Save name",
|
|
690
|
+
deleteCollection: "Delete",
|
|
691
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
692
|
+
deleteCollectionSubmit: "Delete collection",
|
|
693
|
+
cancel: "Cancel",
|
|
694
|
+
collectionItem: "item",
|
|
695
|
+
collectionItems: "items"
|
|
651
696
|
};
|
|
652
697
|
|
|
653
698
|
// src/locales/id.ts
|
|
@@ -758,7 +803,16 @@ var ID_LABELS = {
|
|
|
758
803
|
toolbarEnd: "Tindakan tambahan",
|
|
759
804
|
createCollection: "Create collection",
|
|
760
805
|
createCollectionSubmit: "Create",
|
|
761
|
-
collectionName: "Collection name"
|
|
806
|
+
collectionName: "Collection name",
|
|
807
|
+
manageCollections: "Manage collections",
|
|
808
|
+
renameCollection: "Rename",
|
|
809
|
+
renameCollectionSubmit: "Save name",
|
|
810
|
+
deleteCollection: "Delete",
|
|
811
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
812
|
+
deleteCollectionSubmit: "Delete collection",
|
|
813
|
+
cancel: "Cancel",
|
|
814
|
+
collectionItem: "item",
|
|
815
|
+
collectionItems: "items"
|
|
762
816
|
};
|
|
763
817
|
|
|
764
818
|
// src/locales/it.ts
|
|
@@ -869,7 +923,16 @@ var IT_LABELS = {
|
|
|
869
923
|
toolbarEnd: "Azioni aggiuntive",
|
|
870
924
|
createCollection: "Create collection",
|
|
871
925
|
createCollectionSubmit: "Create",
|
|
872
|
-
collectionName: "Collection name"
|
|
926
|
+
collectionName: "Collection name",
|
|
927
|
+
manageCollections: "Manage collections",
|
|
928
|
+
renameCollection: "Rename",
|
|
929
|
+
renameCollectionSubmit: "Save name",
|
|
930
|
+
deleteCollection: "Delete",
|
|
931
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
932
|
+
deleteCollectionSubmit: "Delete collection",
|
|
933
|
+
cancel: "Cancel",
|
|
934
|
+
collectionItem: "item",
|
|
935
|
+
collectionItems: "items"
|
|
873
936
|
};
|
|
874
937
|
|
|
875
938
|
// src/locales/ja.ts
|
|
@@ -980,7 +1043,16 @@ var JA_LABELS = {
|
|
|
980
1043
|
toolbarEnd: "\u8FFD\u52A0\u306E\u64CD\u4F5C",
|
|
981
1044
|
createCollection: "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u4F5C\u6210",
|
|
982
1045
|
createCollectionSubmit: "\u4F5C\u6210",
|
|
983
|
-
collectionName: "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u540D"
|
|
1046
|
+
collectionName: "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u540D",
|
|
1047
|
+
manageCollections: "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u7BA1\u7406",
|
|
1048
|
+
renameCollection: "\u540D\u524D\u3092\u5909\u66F4",
|
|
1049
|
+
renameCollectionSubmit: "\u540D\u524D\u3092\u4FDD\u5B58",
|
|
1050
|
+
deleteCollection: "\u524A\u9664",
|
|
1051
|
+
deleteCollectionConfirm: "\u30A2\u30A4\u30C6\u30E0\u3092\u672A\u5206\u985E\u3078\u79FB\u52D5\u3057\u307E\u3059\u304B\uFF1F",
|
|
1052
|
+
deleteCollectionSubmit: "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u524A\u9664",
|
|
1053
|
+
cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
|
|
1054
|
+
collectionItem: "\u4EF6",
|
|
1055
|
+
collectionItems: "\u4EF6"
|
|
984
1056
|
};
|
|
985
1057
|
|
|
986
1058
|
// src/locales/ko.ts
|
|
@@ -1091,7 +1163,16 @@ var KO_LABELS = {
|
|
|
1091
1163
|
toolbarEnd: "\uCD94\uAC00 \uC791\uC5C5",
|
|
1092
1164
|
createCollection: "Create collection",
|
|
1093
1165
|
createCollectionSubmit: "Create",
|
|
1094
|
-
collectionName: "Collection name"
|
|
1166
|
+
collectionName: "Collection name",
|
|
1167
|
+
manageCollections: "Manage collections",
|
|
1168
|
+
renameCollection: "Rename",
|
|
1169
|
+
renameCollectionSubmit: "Save name",
|
|
1170
|
+
deleteCollection: "Delete",
|
|
1171
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1172
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1173
|
+
cancel: "Cancel",
|
|
1174
|
+
collectionItem: "item",
|
|
1175
|
+
collectionItems: "items"
|
|
1095
1176
|
};
|
|
1096
1177
|
|
|
1097
1178
|
// src/locales/ms.ts
|
|
@@ -1202,7 +1283,16 @@ var MS_LABELS = {
|
|
|
1202
1283
|
toolbarEnd: "Tindakan tambahan",
|
|
1203
1284
|
createCollection: "Create collection",
|
|
1204
1285
|
createCollectionSubmit: "Create",
|
|
1205
|
-
collectionName: "Collection name"
|
|
1286
|
+
collectionName: "Collection name",
|
|
1287
|
+
manageCollections: "Manage collections",
|
|
1288
|
+
renameCollection: "Rename",
|
|
1289
|
+
renameCollectionSubmit: "Save name",
|
|
1290
|
+
deleteCollection: "Delete",
|
|
1291
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1292
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1293
|
+
cancel: "Cancel",
|
|
1294
|
+
collectionItem: "item",
|
|
1295
|
+
collectionItems: "items"
|
|
1206
1296
|
};
|
|
1207
1297
|
|
|
1208
1298
|
// src/locales/pt-BR.ts
|
|
@@ -1313,7 +1403,16 @@ var PT_BR_LABELS = {
|
|
|
1313
1403
|
toolbarEnd: "A\xE7\xF5es adicionais",
|
|
1314
1404
|
createCollection: "Create collection",
|
|
1315
1405
|
createCollectionSubmit: "Create",
|
|
1316
|
-
collectionName: "Collection name"
|
|
1406
|
+
collectionName: "Collection name",
|
|
1407
|
+
manageCollections: "Manage collections",
|
|
1408
|
+
renameCollection: "Rename",
|
|
1409
|
+
renameCollectionSubmit: "Save name",
|
|
1410
|
+
deleteCollection: "Delete",
|
|
1411
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1412
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1413
|
+
cancel: "Cancel",
|
|
1414
|
+
collectionItem: "item",
|
|
1415
|
+
collectionItems: "items"
|
|
1317
1416
|
};
|
|
1318
1417
|
|
|
1319
1418
|
// src/locales/ru.ts
|
|
@@ -1424,7 +1523,16 @@ var RU_LABELS = {
|
|
|
1424
1523
|
toolbarEnd: "\u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F",
|
|
1425
1524
|
createCollection: "Create collection",
|
|
1426
1525
|
createCollectionSubmit: "Create",
|
|
1427
|
-
collectionName: "Collection name"
|
|
1526
|
+
collectionName: "Collection name",
|
|
1527
|
+
manageCollections: "Manage collections",
|
|
1528
|
+
renameCollection: "Rename",
|
|
1529
|
+
renameCollectionSubmit: "Save name",
|
|
1530
|
+
deleteCollection: "Delete",
|
|
1531
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1532
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1533
|
+
cancel: "Cancel",
|
|
1534
|
+
collectionItem: "item",
|
|
1535
|
+
collectionItems: "items"
|
|
1428
1536
|
};
|
|
1429
1537
|
|
|
1430
1538
|
// src/locales/th.ts
|
|
@@ -1535,7 +1643,16 @@ var TH_LABELS = {
|
|
|
1535
1643
|
toolbarEnd: "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21",
|
|
1536
1644
|
createCollection: "Create collection",
|
|
1537
1645
|
createCollectionSubmit: "Create",
|
|
1538
|
-
collectionName: "Collection name"
|
|
1646
|
+
collectionName: "Collection name",
|
|
1647
|
+
manageCollections: "Manage collections",
|
|
1648
|
+
renameCollection: "Rename",
|
|
1649
|
+
renameCollectionSubmit: "Save name",
|
|
1650
|
+
deleteCollection: "Delete",
|
|
1651
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1652
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1653
|
+
cancel: "Cancel",
|
|
1654
|
+
collectionItem: "item",
|
|
1655
|
+
collectionItems: "items"
|
|
1539
1656
|
};
|
|
1540
1657
|
|
|
1541
1658
|
// src/locales/vi.ts
|
|
@@ -1646,7 +1763,16 @@ var VI_LABELS = {
|
|
|
1646
1763
|
toolbarEnd: "Thao t\xE1c b\u1ED5 sung",
|
|
1647
1764
|
createCollection: "Create collection",
|
|
1648
1765
|
createCollectionSubmit: "Create",
|
|
1649
|
-
collectionName: "Collection name"
|
|
1766
|
+
collectionName: "Collection name",
|
|
1767
|
+
manageCollections: "Manage collections",
|
|
1768
|
+
renameCollection: "Rename",
|
|
1769
|
+
renameCollectionSubmit: "Save name",
|
|
1770
|
+
deleteCollection: "Delete",
|
|
1771
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1772
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1773
|
+
cancel: "Cancel",
|
|
1774
|
+
collectionItem: "item",
|
|
1775
|
+
collectionItems: "items"
|
|
1650
1776
|
};
|
|
1651
1777
|
|
|
1652
1778
|
// src/locales/zh-Hans.ts
|
|
@@ -1757,7 +1883,16 @@ var ZH_HANS_LABELS = {
|
|
|
1757
1883
|
toolbarEnd: "\u5176\u4ED6\u64CD\u4F5C",
|
|
1758
1884
|
createCollection: "Create collection",
|
|
1759
1885
|
createCollectionSubmit: "Create",
|
|
1760
|
-
collectionName: "Collection name"
|
|
1886
|
+
collectionName: "Collection name",
|
|
1887
|
+
manageCollections: "Manage collections",
|
|
1888
|
+
renameCollection: "Rename",
|
|
1889
|
+
renameCollectionSubmit: "Save name",
|
|
1890
|
+
deleteCollection: "Delete",
|
|
1891
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
1892
|
+
deleteCollectionSubmit: "Delete collection",
|
|
1893
|
+
cancel: "Cancel",
|
|
1894
|
+
collectionItem: "item",
|
|
1895
|
+
collectionItems: "items"
|
|
1761
1896
|
};
|
|
1762
1897
|
|
|
1763
1898
|
// src/locales/zh-Hant.ts
|
|
@@ -1868,7 +2003,16 @@ var ZH_HANT_LABELS = {
|
|
|
1868
2003
|
toolbarEnd: "\u5176\u4ED6\u64CD\u4F5C",
|
|
1869
2004
|
createCollection: "Create collection",
|
|
1870
2005
|
createCollectionSubmit: "Create",
|
|
1871
|
-
collectionName: "Collection name"
|
|
2006
|
+
collectionName: "Collection name",
|
|
2007
|
+
manageCollections: "Manage collections",
|
|
2008
|
+
renameCollection: "Rename",
|
|
2009
|
+
renameCollectionSubmit: "Save name",
|
|
2010
|
+
deleteCollection: "Delete",
|
|
2011
|
+
deleteCollectionConfirm: "Move its items to Uncategorized?",
|
|
2012
|
+
deleteCollectionSubmit: "Delete collection",
|
|
2013
|
+
cancel: "Cancel",
|
|
2014
|
+
collectionItem: "item",
|
|
2015
|
+
collectionItems: "items"
|
|
1872
2016
|
};
|
|
1873
2017
|
|
|
1874
2018
|
// src/locales/index.ts
|
|
@@ -2930,10 +3074,14 @@ function KeepQuickEditorView({
|
|
|
2930
3074
|
const savingLabel = useUiLabel("saving");
|
|
2931
3075
|
const savedLabel = useUiLabel("saved");
|
|
2932
3076
|
const errorLabel = useUiLabel("error");
|
|
3077
|
+
const [tagsInput, setTagsInput] = useState3(() => formatTags(state.tags));
|
|
2933
3078
|
const submit = (event) => {
|
|
2934
3079
|
event.preventDefault();
|
|
2935
3080
|
void state.flush().catch(() => void 0);
|
|
2936
3081
|
};
|
|
3082
|
+
useEffect3(() => {
|
|
3083
|
+
if (!sameTags(parseTags(tagsInput), state.tags)) setTagsInput(formatTags(state.tags));
|
|
3084
|
+
}, [state.tags, tagsInput]);
|
|
2937
3085
|
const onKeyDown = (event) => {
|
|
2938
3086
|
props.onKeyDown?.(event);
|
|
2939
3087
|
if (event.defaultPrevented) return;
|
|
@@ -2961,11 +3109,13 @@ function KeepQuickEditorView({
|
|
|
2961
3109
|
/* @__PURE__ */ jsx7(
|
|
2962
3110
|
"input",
|
|
2963
3111
|
{
|
|
2964
|
-
value:
|
|
3112
|
+
value: tagsInput,
|
|
2965
3113
|
"aria-label": showTagsLabel ? void 0 : tagsLabel,
|
|
2966
|
-
onChange: (event) =>
|
|
2967
|
-
event.currentTarget.value
|
|
2968
|
-
|
|
3114
|
+
onChange: (event) => {
|
|
3115
|
+
const value = event.currentTarget.value;
|
|
3116
|
+
setTagsInput(value);
|
|
3117
|
+
state.setTags(parseTags(value));
|
|
3118
|
+
}
|
|
2969
3119
|
}
|
|
2970
3120
|
)
|
|
2971
3121
|
] }) : null,
|
|
@@ -3041,6 +3191,12 @@ function getErrorMessage2(error, fallback) {
|
|
|
3041
3191
|
function sameTags(left, right) {
|
|
3042
3192
|
return left.length === right.length && left.every((tag, index) => tag === right[index]);
|
|
3043
3193
|
}
|
|
3194
|
+
function parseTags(value) {
|
|
3195
|
+
return value.split(",").map((tag) => tag.trim()).filter(Boolean);
|
|
3196
|
+
}
|
|
3197
|
+
function formatTags(tags) {
|
|
3198
|
+
return tags.join(", ");
|
|
3199
|
+
}
|
|
3044
3200
|
function trapFocus(event, root) {
|
|
3045
3201
|
if (!root) return;
|
|
3046
3202
|
const elements = [
|
|
@@ -5318,13 +5474,301 @@ function getCollectionState(list) {
|
|
|
5318
5474
|
return "ready";
|
|
5319
5475
|
}
|
|
5320
5476
|
|
|
5477
|
+
// src/features/collection/KeepCollectionManager.tsx
|
|
5478
|
+
import { useId as useId5 } from "react";
|
|
5479
|
+
|
|
5480
|
+
// src/features/collection/hooks/useKeepCollectionManager.ts
|
|
5481
|
+
import { useKeepCollections as useKeepCollections4, useKeepContext as useKeepContext6 } from "@keepkit/core/react";
|
|
5482
|
+
import { useCallback as useCallback6, useState as useState16 } from "react";
|
|
5483
|
+
function useKeepCollectionManager({
|
|
5484
|
+
onError,
|
|
5485
|
+
onRenamed,
|
|
5486
|
+
onDeleted
|
|
5487
|
+
} = {}) {
|
|
5488
|
+
const {
|
|
5489
|
+
items,
|
|
5490
|
+
collections: explicitCollections,
|
|
5491
|
+
createCollection,
|
|
5492
|
+
renameCollection,
|
|
5493
|
+
removeCollection,
|
|
5494
|
+
moveToCollection
|
|
5495
|
+
} = useKeepContext6();
|
|
5496
|
+
const collections = useKeepCollections4({ orderBy: "name" });
|
|
5497
|
+
const [editingId, setEditingId] = useState16(null);
|
|
5498
|
+
const [editingName, setEditingName] = useState16("");
|
|
5499
|
+
const [pendingDeleteId, setPendingDeleteId] = useState16(null);
|
|
5500
|
+
const [error, setError] = useState16(null);
|
|
5501
|
+
const [isMutating, setIsMutating] = useState16(false);
|
|
5502
|
+
const reportError = useCallback6(
|
|
5503
|
+
(cause, fallback) => {
|
|
5504
|
+
const message = cause instanceof Error ? cause.message : fallback;
|
|
5505
|
+
setError(message);
|
|
5506
|
+
onError?.(cause);
|
|
5507
|
+
},
|
|
5508
|
+
[onError]
|
|
5509
|
+
);
|
|
5510
|
+
const runMutation = useCallback6(
|
|
5511
|
+
async (operation) => {
|
|
5512
|
+
setError(null);
|
|
5513
|
+
setIsMutating(true);
|
|
5514
|
+
try {
|
|
5515
|
+
await operation();
|
|
5516
|
+
} catch (cause) {
|
|
5517
|
+
reportError(cause, "Could not update the collection.");
|
|
5518
|
+
} finally {
|
|
5519
|
+
setIsMutating(false);
|
|
5520
|
+
}
|
|
5521
|
+
},
|
|
5522
|
+
[reportError]
|
|
5523
|
+
);
|
|
5524
|
+
const beginRename = useCallback6(
|
|
5525
|
+
(id) => {
|
|
5526
|
+
const collection = collections.find((entry) => entry.id === id);
|
|
5527
|
+
if (!collection) return;
|
|
5528
|
+
setError(null);
|
|
5529
|
+
setPendingDeleteId(null);
|
|
5530
|
+
setEditingId(id);
|
|
5531
|
+
setEditingName(collection.name);
|
|
5532
|
+
},
|
|
5533
|
+
[collections]
|
|
5534
|
+
);
|
|
5535
|
+
const cancelRename = useCallback6(() => {
|
|
5536
|
+
setEditingId(null);
|
|
5537
|
+
setEditingName("");
|
|
5538
|
+
}, []);
|
|
5539
|
+
const rename = useCallback6(
|
|
5540
|
+
async (id) => {
|
|
5541
|
+
const name = editingName.trim();
|
|
5542
|
+
if (!name) return;
|
|
5543
|
+
const duplicate = collections.some(
|
|
5544
|
+
(collection) => collection.id !== id && collection.name.toLowerCase() === name.toLowerCase()
|
|
5545
|
+
);
|
|
5546
|
+
if (duplicate) {
|
|
5547
|
+
setError(`Collection "${name}" already exists.`);
|
|
5548
|
+
return;
|
|
5549
|
+
}
|
|
5550
|
+
await runMutation(async () => {
|
|
5551
|
+
if (explicitCollections[id]) {
|
|
5552
|
+
await renameCollection(id, name);
|
|
5553
|
+
} else {
|
|
5554
|
+
await createCollection(id, name);
|
|
5555
|
+
}
|
|
5556
|
+
cancelRename();
|
|
5557
|
+
await onRenamed?.(id, name);
|
|
5558
|
+
});
|
|
5559
|
+
},
|
|
5560
|
+
[
|
|
5561
|
+
cancelRename,
|
|
5562
|
+
collections,
|
|
5563
|
+
createCollection,
|
|
5564
|
+
editingName,
|
|
5565
|
+
explicitCollections,
|
|
5566
|
+
onRenamed,
|
|
5567
|
+
renameCollection,
|
|
5568
|
+
runMutation
|
|
5569
|
+
]
|
|
5570
|
+
);
|
|
5571
|
+
const requestDelete = useCallback6((id) => {
|
|
5572
|
+
setError(null);
|
|
5573
|
+
setEditingId(null);
|
|
5574
|
+
setPendingDeleteId(id);
|
|
5575
|
+
}, []);
|
|
5576
|
+
const cancelDelete = useCallback6(() => setPendingDeleteId(null), []);
|
|
5577
|
+
const confirmDelete = useCallback6(async () => {
|
|
5578
|
+
if (!pendingDeleteId) return;
|
|
5579
|
+
const id = pendingDeleteId;
|
|
5580
|
+
await runMutation(async () => {
|
|
5581
|
+
if (explicitCollections[id]) {
|
|
5582
|
+
await removeCollection(id);
|
|
5583
|
+
} else {
|
|
5584
|
+
for (const item of items.filter((entry) => entry.collectionId === id)) {
|
|
5585
|
+
await moveToCollection(item.id, void 0);
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
setPendingDeleteId(null);
|
|
5589
|
+
await onDeleted?.(id);
|
|
5590
|
+
});
|
|
5591
|
+
}, [explicitCollections, items, moveToCollection, onDeleted, pendingDeleteId, removeCollection, runMutation]);
|
|
5592
|
+
return {
|
|
5593
|
+
collections,
|
|
5594
|
+
editingId,
|
|
5595
|
+
editingName,
|
|
5596
|
+
setEditingName,
|
|
5597
|
+
beginRename,
|
|
5598
|
+
cancelRename,
|
|
5599
|
+
rename,
|
|
5600
|
+
pendingDeleteId,
|
|
5601
|
+
requestDelete,
|
|
5602
|
+
cancelDelete,
|
|
5603
|
+
confirmDelete,
|
|
5604
|
+
error,
|
|
5605
|
+
isMutating
|
|
5606
|
+
};
|
|
5607
|
+
}
|
|
5608
|
+
|
|
5609
|
+
// src/features/collection/KeepCollectionManager.tsx
|
|
5610
|
+
import { Fragment as Fragment13, jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5611
|
+
function KeepCollectionManager({
|
|
5612
|
+
allowCreate = true,
|
|
5613
|
+
allowRename = true,
|
|
5614
|
+
allowDelete = true,
|
|
5615
|
+
showCounts = true,
|
|
5616
|
+
title,
|
|
5617
|
+
description,
|
|
5618
|
+
empty,
|
|
5619
|
+
collectionLabels,
|
|
5620
|
+
onCreated,
|
|
5621
|
+
onRenamed,
|
|
5622
|
+
onDeleted,
|
|
5623
|
+
onError,
|
|
5624
|
+
className,
|
|
5625
|
+
...rootProps
|
|
5626
|
+
}) {
|
|
5627
|
+
const manager = useKeepCollectionManager({ onError, onRenamed, onDeleted });
|
|
5628
|
+
const headingId = useId5();
|
|
5629
|
+
const renameLabel = useUiLabel("renameCollection");
|
|
5630
|
+
const renameSubmitLabel = useUiLabel("renameCollectionSubmit");
|
|
5631
|
+
const deleteLabel = useUiLabel("deleteCollection");
|
|
5632
|
+
const deleteConfirmLabel = useUiLabel("deleteCollectionConfirm");
|
|
5633
|
+
const deleteSubmitLabel = useUiLabel("deleteCollectionSubmit");
|
|
5634
|
+
const cancelLabel = useUiLabel("cancel");
|
|
5635
|
+
const itemLabel = useUiLabel("collectionItem");
|
|
5636
|
+
const itemsLabel = useUiLabel("collectionItems");
|
|
5637
|
+
const defaultTitle = useUiLabel("manageCollections");
|
|
5638
|
+
return /* @__PURE__ */ jsxs20(
|
|
5639
|
+
"section",
|
|
5640
|
+
{
|
|
5641
|
+
...rootProps,
|
|
5642
|
+
className,
|
|
5643
|
+
"data-keepkit": "collection-manager",
|
|
5644
|
+
"data-state": manager.error ? "error" : manager.isMutating ? "mutating" : "idle",
|
|
5645
|
+
"data-loading": manager.isMutating ? "true" : void 0,
|
|
5646
|
+
"aria-labelledby": rootProps["aria-labelledby"] ?? headingId,
|
|
5647
|
+
children: [
|
|
5648
|
+
/* @__PURE__ */ jsxs20("header", { "data-keepkit": "collection-manager-heading", children: [
|
|
5649
|
+
/* @__PURE__ */ jsx23("h2", { id: headingId, children: title ?? defaultTitle }),
|
|
5650
|
+
hasRenderableContent(description) ? /* @__PURE__ */ jsx23("p", { children: description }) : null
|
|
5651
|
+
] }),
|
|
5652
|
+
allowCreate ? /* @__PURE__ */ jsx23(KeepCollectionCreate, { onCreated, onError }) : null,
|
|
5653
|
+
manager.error ? /* @__PURE__ */ jsx23("p", { "data-keepkit": "collection-manager-error", role: "alert", children: manager.error }) : null,
|
|
5654
|
+
manager.collections.length > 0 ? /* @__PURE__ */ jsx23("ul", { "data-keepkit": "collection-manager-list", children: manager.collections.map((collection) => {
|
|
5655
|
+
const name = collectionLabels?.[collection.id] ?? collection.name;
|
|
5656
|
+
const isEditing = manager.editingId === collection.id;
|
|
5657
|
+
const isPendingDelete = manager.pendingDeleteId === collection.id;
|
|
5658
|
+
return /* @__PURE__ */ jsx23("li", { "data-keepkit": "collection-manager-item", children: isEditing && allowRename ? /* @__PURE__ */ jsxs20(
|
|
5659
|
+
"form",
|
|
5660
|
+
{
|
|
5661
|
+
"data-keepkit": "collection-manager-rename",
|
|
5662
|
+
onSubmit: (event) => {
|
|
5663
|
+
event.preventDefault();
|
|
5664
|
+
void manager.rename(collection.id);
|
|
5665
|
+
},
|
|
5666
|
+
children: [
|
|
5667
|
+
/* @__PURE__ */ jsxs20("label", { htmlFor: `${headingId}-rename-${collection.id}`, children: [
|
|
5668
|
+
renameLabel,
|
|
5669
|
+
": ",
|
|
5670
|
+
name
|
|
5671
|
+
] }),
|
|
5672
|
+
/* @__PURE__ */ jsx23(
|
|
5673
|
+
"input",
|
|
5674
|
+
{
|
|
5675
|
+
id: `${headingId}-rename-${collection.id}`,
|
|
5676
|
+
value: manager.editingName,
|
|
5677
|
+
onChange: (event) => manager.setEditingName(event.currentTarget.value),
|
|
5678
|
+
disabled: manager.isMutating,
|
|
5679
|
+
"data-keep-action": "rename-collection-input"
|
|
5680
|
+
}
|
|
5681
|
+
),
|
|
5682
|
+
/* @__PURE__ */ jsx23(
|
|
5683
|
+
"button",
|
|
5684
|
+
{
|
|
5685
|
+
type: "submit",
|
|
5686
|
+
disabled: manager.isMutating || !manager.editingName.trim(),
|
|
5687
|
+
"data-keep-action": "rename-collection",
|
|
5688
|
+
children: renameSubmitLabel
|
|
5689
|
+
}
|
|
5690
|
+
),
|
|
5691
|
+
/* @__PURE__ */ jsx23(
|
|
5692
|
+
"button",
|
|
5693
|
+
{
|
|
5694
|
+
type: "button",
|
|
5695
|
+
onClick: manager.cancelRename,
|
|
5696
|
+
disabled: manager.isMutating,
|
|
5697
|
+
"data-keep-action": "cancel-rename-collection",
|
|
5698
|
+
children: cancelLabel
|
|
5699
|
+
}
|
|
5700
|
+
)
|
|
5701
|
+
]
|
|
5702
|
+
}
|
|
5703
|
+
) : /* @__PURE__ */ jsxs20(Fragment13, { children: [
|
|
5704
|
+
/* @__PURE__ */ jsxs20("div", { "data-keepkit": "collection-manager-summary", children: [
|
|
5705
|
+
/* @__PURE__ */ jsx23("span", { "data-keepkit": "collection-manager-name", children: name }),
|
|
5706
|
+
showCounts ? /* @__PURE__ */ jsxs20("span", { "data-keepkit": "collection-manager-count", children: [
|
|
5707
|
+
collection.count,
|
|
5708
|
+
" ",
|
|
5709
|
+
collection.count === 1 ? itemLabel : itemsLabel
|
|
5710
|
+
] }) : null
|
|
5711
|
+
] }),
|
|
5712
|
+
isPendingDelete && allowDelete ? /* @__PURE__ */ jsxs20("fieldset", { "data-keepkit": "collection-manager-delete-confirmation", children: [
|
|
5713
|
+
/* @__PURE__ */ jsx23("legend", { children: deleteConfirmLabel }),
|
|
5714
|
+
/* @__PURE__ */ jsx23(
|
|
5715
|
+
"button",
|
|
5716
|
+
{
|
|
5717
|
+
type: "button",
|
|
5718
|
+
onClick: () => void manager.confirmDelete(),
|
|
5719
|
+
disabled: manager.isMutating,
|
|
5720
|
+
"data-keep-action": "delete-collection-confirm",
|
|
5721
|
+
children: deleteSubmitLabel
|
|
5722
|
+
}
|
|
5723
|
+
),
|
|
5724
|
+
/* @__PURE__ */ jsx23(
|
|
5725
|
+
"button",
|
|
5726
|
+
{
|
|
5727
|
+
type: "button",
|
|
5728
|
+
onClick: manager.cancelDelete,
|
|
5729
|
+
disabled: manager.isMutating,
|
|
5730
|
+
"data-keep-action": "cancel-delete-collection",
|
|
5731
|
+
children: cancelLabel
|
|
5732
|
+
}
|
|
5733
|
+
)
|
|
5734
|
+
] }) : /* @__PURE__ */ jsxs20("div", { "data-keepkit": "collection-manager-actions", children: [
|
|
5735
|
+
allowRename ? /* @__PURE__ */ jsx23(
|
|
5736
|
+
"button",
|
|
5737
|
+
{
|
|
5738
|
+
type: "button",
|
|
5739
|
+
onClick: () => manager.beginRename(collection.id),
|
|
5740
|
+
disabled: manager.isMutating,
|
|
5741
|
+
"aria-label": `${renameLabel} ${name}`,
|
|
5742
|
+
"data-keep-action": "rename-collection",
|
|
5743
|
+
children: renameLabel
|
|
5744
|
+
}
|
|
5745
|
+
) : null,
|
|
5746
|
+
allowDelete ? /* @__PURE__ */ jsx23(
|
|
5747
|
+
"button",
|
|
5748
|
+
{
|
|
5749
|
+
type: "button",
|
|
5750
|
+
onClick: () => manager.requestDelete(collection.id),
|
|
5751
|
+
disabled: manager.isMutating,
|
|
5752
|
+
"aria-label": `${deleteLabel} ${name}`,
|
|
5753
|
+
"data-keep-action": "delete-collection",
|
|
5754
|
+
children: deleteLabel
|
|
5755
|
+
}
|
|
5756
|
+
) : null
|
|
5757
|
+
] })
|
|
5758
|
+
] }) }, collection.id);
|
|
5759
|
+
}) }) : hasRenderableContent(empty) ? /* @__PURE__ */ jsx23("div", { "data-keepkit": "collection-manager-empty", children: empty }) : null
|
|
5760
|
+
]
|
|
5761
|
+
}
|
|
5762
|
+
);
|
|
5763
|
+
}
|
|
5764
|
+
|
|
5321
5765
|
// src/features/collection/KeepLayout.tsx
|
|
5322
|
-
import { jsx as
|
|
5766
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
5323
5767
|
function KeepLayout({ layout = "list", children, onKeyDown, onFocusCapture, ...props }) {
|
|
5324
5768
|
const roving = useRovingTabIndex();
|
|
5325
5769
|
return (
|
|
5326
5770
|
// biome-ignore lint/a11y/noStaticElementInteractions: The group manages keyboard focus for descendant cards.
|
|
5327
|
-
/* @__PURE__ */
|
|
5771
|
+
/* @__PURE__ */ jsx24(
|
|
5328
5772
|
"div",
|
|
5329
5773
|
{
|
|
5330
5774
|
...props,
|
|
@@ -5351,7 +5795,7 @@ function KeepLayout({ layout = "list", children, onKeyDown, onFocusCapture, ...p
|
|
|
5351
5795
|
import { isValidElement as isValidElement7 } from "react";
|
|
5352
5796
|
|
|
5353
5797
|
// src/features/navigation/KeepShortcutHint.tsx
|
|
5354
|
-
import { jsx as
|
|
5798
|
+
import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
5355
5799
|
function KeepShortcutHint({ shortcut, separator = "+", ...props }) {
|
|
5356
5800
|
const keys = typeof shortcut === "string" ? shortcut.split("+") : [...shortcut];
|
|
5357
5801
|
const occurrences = /* @__PURE__ */ new Map();
|
|
@@ -5360,24 +5804,24 @@ function KeepShortcutHint({ shortcut, separator = "+", ...props }) {
|
|
|
5360
5804
|
occurrences.set(key, occurrence + 1);
|
|
5361
5805
|
return { id: `${key}-${occurrence}`, value: key };
|
|
5362
5806
|
});
|
|
5363
|
-
return /* @__PURE__ */
|
|
5364
|
-
index > 0 ? /* @__PURE__ */
|
|
5365
|
-
/* @__PURE__ */
|
|
5807
|
+
return /* @__PURE__ */ jsx25("span", { ...props, "data-keepkit": "shortcut-hint", "aria-hidden": props["aria-hidden"] ?? true, children: keyedKeys.map((key, index) => /* @__PURE__ */ jsxs21("span", { children: [
|
|
5808
|
+
index > 0 ? /* @__PURE__ */ jsx25("span", { "data-shortcut-separator": "true", children: separator }) : null,
|
|
5809
|
+
/* @__PURE__ */ jsx25("kbd", { children: key.value.trim() })
|
|
5366
5810
|
] }, key.id)) });
|
|
5367
5811
|
}
|
|
5368
5812
|
|
|
5369
5813
|
// src/features/editor/hooks/useKeepNoteEditor.ts
|
|
5370
5814
|
import { useKeepItem as useKeepItem6 } from "@keepkit/core/react";
|
|
5371
|
-
import { useCallback as
|
|
5815
|
+
import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef9, useState as useState17 } from "react";
|
|
5372
5816
|
function useKeepNoteEditor({ item, debounceMs, onSaved, onSaveError }) {
|
|
5373
5817
|
const itemState = useKeepItem6(item);
|
|
5374
5818
|
const { error, isMutating, item: savedItem, updateNote } = itemState;
|
|
5375
|
-
const [note, setNote] =
|
|
5819
|
+
const [note, setNote] = useState17(item.note ?? "");
|
|
5376
5820
|
const baselineNote = savedItem?.note ?? item.note ?? "";
|
|
5377
5821
|
const isDirty = note !== baselineNote;
|
|
5378
5822
|
const lastSavedNoteRef = useRef9(void 0);
|
|
5379
5823
|
useEffect11(() => setNote(baselineNote), [baselineNote]);
|
|
5380
|
-
const save =
|
|
5824
|
+
const save = useCallback7(async () => {
|
|
5381
5825
|
const nextNote = note.trim() || void 0;
|
|
5382
5826
|
try {
|
|
5383
5827
|
await updateNote(nextNote);
|
|
@@ -5423,7 +5867,7 @@ function useKeepNoteEditor({ item, debounceMs, onSaved, onSaveError }) {
|
|
|
5423
5867
|
}
|
|
5424
5868
|
|
|
5425
5869
|
// src/features/editor/KeepNoteEditor.tsx
|
|
5426
|
-
import { Fragment as
|
|
5870
|
+
import { Fragment as Fragment14, jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
5427
5871
|
function KeepNoteEditor({
|
|
5428
5872
|
item,
|
|
5429
5873
|
label,
|
|
@@ -5446,10 +5890,10 @@ function KeepNoteEditor({
|
|
|
5446
5890
|
const saveAccessibleLabel = useUiLabel("saveNote");
|
|
5447
5891
|
const { error, isDirty, isSaving, note, setNote } = view.state;
|
|
5448
5892
|
const contentChildren = asChild && isValidElement7(children) ? void 0 : children;
|
|
5449
|
-
const body = render ? render(view.state) : typeof contentChildren === "function" ? contentChildren(view.state) : contentChildren ?? /* @__PURE__ */
|
|
5450
|
-
/* @__PURE__ */
|
|
5893
|
+
const body = render ? render(view.state) : typeof contentChildren === "function" ? contentChildren(view.state) : contentChildren ?? /* @__PURE__ */ jsxs22(Fragment14, { children: [
|
|
5894
|
+
/* @__PURE__ */ jsxs22("label", { children: [
|
|
5451
5895
|
showNoteLabel ? label ?? view.labels.note : null,
|
|
5452
|
-
/* @__PURE__ */
|
|
5896
|
+
/* @__PURE__ */ jsx26(
|
|
5453
5897
|
"textarea",
|
|
5454
5898
|
{
|
|
5455
5899
|
"data-keep-action": "edit-note",
|
|
@@ -5462,7 +5906,7 @@ function KeepNoteEditor({
|
|
|
5462
5906
|
}
|
|
5463
5907
|
)
|
|
5464
5908
|
] }),
|
|
5465
|
-
/* @__PURE__ */
|
|
5909
|
+
/* @__PURE__ */ jsxs22(
|
|
5466
5910
|
"button",
|
|
5467
5911
|
{
|
|
5468
5912
|
type: "submit",
|
|
@@ -5472,13 +5916,13 @@ function KeepNoteEditor({
|
|
|
5472
5916
|
"aria-label": showSaveLabel ? void 0 : saveAccessibleLabel,
|
|
5473
5917
|
children: [
|
|
5474
5918
|
showSaveLabel ? saveLabel ?? view.labels.save : null,
|
|
5475
|
-
showShortcutHint ? /* @__PURE__ */
|
|
5919
|
+
showShortcutHint ? /* @__PURE__ */ jsx26(KeepShortcutHint, { shortcut: "Ctrl+Enter" }) : null
|
|
5476
5920
|
]
|
|
5477
5921
|
}
|
|
5478
5922
|
)
|
|
5479
5923
|
] });
|
|
5480
5924
|
if (!asChild) {
|
|
5481
|
-
return /* @__PURE__ */
|
|
5925
|
+
return /* @__PURE__ */ jsxs22(
|
|
5482
5926
|
"form",
|
|
5483
5927
|
{
|
|
5484
5928
|
...formProps,
|
|
@@ -5491,7 +5935,7 @@ function KeepNoteEditor({
|
|
|
5491
5935
|
"data-disabled": isSaving ? "true" : void 0,
|
|
5492
5936
|
children: [
|
|
5493
5937
|
body,
|
|
5494
|
-
error ? /* @__PURE__ */
|
|
5938
|
+
error ? /* @__PURE__ */ jsx26("p", { role: "alert", children: getErrorMessage4(error, view.labels.error) }) : null
|
|
5495
5939
|
]
|
|
5496
5940
|
}
|
|
5497
5941
|
);
|
|
@@ -5519,13 +5963,13 @@ function getErrorMessage4(error, fallback) {
|
|
|
5519
5963
|
|
|
5520
5964
|
// src/features/editor/hooks/useKeepTagEditor.ts
|
|
5521
5965
|
import { useKeepItem as useKeepItem7 } from "@keepkit/core/react";
|
|
5522
|
-
import { useCallback as
|
|
5966
|
+
import { useCallback as useCallback8, useEffect as useEffect12, useState as useState18 } from "react";
|
|
5523
5967
|
function useKeepTagEditor({ item, onSaved, onSaveError }) {
|
|
5524
5968
|
const itemState = useKeepItem7(item);
|
|
5525
|
-
const [tags, setTags] =
|
|
5526
|
-
const [input, setInput] =
|
|
5969
|
+
const [tags, setTags] = useState18(item.tags ?? []);
|
|
5970
|
+
const [input, setInput] = useState18("");
|
|
5527
5971
|
useEffect12(() => setTags(itemState.item?.tags ?? item.tags ?? []), [item.tags, itemState.item?.tags]);
|
|
5528
|
-
const save =
|
|
5972
|
+
const save = useCallback8(async () => {
|
|
5529
5973
|
const nextTags = normalizeUiTags(tags);
|
|
5530
5974
|
try {
|
|
5531
5975
|
await itemState.updateTags(nextTags);
|
|
@@ -5571,7 +6015,7 @@ function useKeepTagEditor({ item, onSaved, onSaveError }) {
|
|
|
5571
6015
|
}
|
|
5572
6016
|
|
|
5573
6017
|
// src/features/editor/KeepTagEditor.tsx
|
|
5574
|
-
import { Fragment as
|
|
6018
|
+
import { Fragment as Fragment15, jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5575
6019
|
function KeepTagEditor({
|
|
5576
6020
|
item,
|
|
5577
6021
|
availableTags = [],
|
|
@@ -5586,10 +6030,10 @@ function KeepTagEditor({
|
|
|
5586
6030
|
const showRemoveLabel = useUiLabelVisibility("remove");
|
|
5587
6031
|
const showApplyLabel = useUiLabelVisibility("applyTags");
|
|
5588
6032
|
const { isSaving, tags } = view.state;
|
|
5589
|
-
const body = render ? render(view.state) : /* @__PURE__ */
|
|
5590
|
-
/* @__PURE__ */
|
|
6033
|
+
const body = render ? render(view.state) : /* @__PURE__ */ jsxs23(Fragment15, { children: [
|
|
6034
|
+
/* @__PURE__ */ jsxs23("label", { children: [
|
|
5591
6035
|
showTagsLabel ? view.labels.tags : null,
|
|
5592
|
-
/* @__PURE__ */
|
|
6036
|
+
/* @__PURE__ */ jsx27(
|
|
5593
6037
|
"input",
|
|
5594
6038
|
{
|
|
5595
6039
|
"data-keep-action": "edit-tags",
|
|
@@ -5601,10 +6045,10 @@ function KeepTagEditor({
|
|
|
5601
6045
|
}
|
|
5602
6046
|
)
|
|
5603
6047
|
] }),
|
|
5604
|
-
availableTags.length > 0 ? /* @__PURE__ */
|
|
5605
|
-
/* @__PURE__ */
|
|
6048
|
+
availableTags.length > 0 ? /* @__PURE__ */ jsx27("datalist", { id: `keep-tags-${item.id}`, children: availableTags.map((tag) => /* @__PURE__ */ jsx27("option", { value: tag }, tag)) }) : null,
|
|
6049
|
+
/* @__PURE__ */ jsx27("ul", { "aria-label": view.labels.tags, children: tags.map((tag) => /* @__PURE__ */ jsxs23("li", { children: [
|
|
5606
6050
|
tag,
|
|
5607
|
-
/* @__PURE__ */
|
|
6051
|
+
/* @__PURE__ */ jsx27(
|
|
5608
6052
|
"button",
|
|
5609
6053
|
{
|
|
5610
6054
|
type: "button",
|
|
@@ -5615,7 +6059,7 @@ function KeepTagEditor({
|
|
|
5615
6059
|
}
|
|
5616
6060
|
)
|
|
5617
6061
|
] }, tag)) }),
|
|
5618
|
-
/* @__PURE__ */
|
|
6062
|
+
/* @__PURE__ */ jsx27(
|
|
5619
6063
|
"button",
|
|
5620
6064
|
{
|
|
5621
6065
|
type: "submit",
|
|
@@ -5627,7 +6071,7 @@ function KeepTagEditor({
|
|
|
5627
6071
|
}
|
|
5628
6072
|
)
|
|
5629
6073
|
] });
|
|
5630
|
-
return /* @__PURE__ */
|
|
6074
|
+
return /* @__PURE__ */ jsxs23(
|
|
5631
6075
|
"form",
|
|
5632
6076
|
{
|
|
5633
6077
|
...props,
|
|
@@ -5639,7 +6083,7 @@ function KeepTagEditor({
|
|
|
5639
6083
|
"data-disabled": isSaving ? "true" : void 0,
|
|
5640
6084
|
children: [
|
|
5641
6085
|
body,
|
|
5642
|
-
view.error ? /* @__PURE__ */
|
|
6086
|
+
view.error ? /* @__PURE__ */ jsx27("p", { role: "alert", children: getErrorMessage5(view.error, view.labels.error) }) : null
|
|
5643
6087
|
]
|
|
5644
6088
|
}
|
|
5645
6089
|
);
|
|
@@ -5649,9 +6093,9 @@ function getErrorMessage5(error, fallback) {
|
|
|
5649
6093
|
}
|
|
5650
6094
|
|
|
5651
6095
|
// src/features/feedback/useKeepToastFeedback.ts
|
|
5652
|
-
import { useCallback as
|
|
6096
|
+
import { useCallback as useCallback9 } from "react";
|
|
5653
6097
|
function useKeepToastFeedback(showToast) {
|
|
5654
|
-
return
|
|
6098
|
+
return useCallback9(
|
|
5655
6099
|
(event) => {
|
|
5656
6100
|
if (!("undo" in event)) {
|
|
5657
6101
|
showToast(event.message);
|
|
@@ -5668,9 +6112,92 @@ function useKeepToastFeedback(showToast) {
|
|
|
5668
6112
|
);
|
|
5669
6113
|
}
|
|
5670
6114
|
|
|
6115
|
+
// src/features/navigation/KeepFloatingTour.tsx
|
|
6116
|
+
import { useKeepList as useKeepList6 } from "@keepkit/core/react";
|
|
6117
|
+
import { useEffect as useEffect15, useMemo as useMemo6, useRef as useRef10, useState as useState20 } from "react";
|
|
6118
|
+
import { createPortal } from "react-dom";
|
|
6119
|
+
|
|
6120
|
+
// src/foundation/theme.tsx
|
|
6121
|
+
import {
|
|
6122
|
+
createContext as createContext4,
|
|
6123
|
+
isValidElement as isValidElement8,
|
|
6124
|
+
useContext as useContext4
|
|
6125
|
+
} from "react";
|
|
6126
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
6127
|
+
var keepThemeNames = [
|
|
6128
|
+
"default",
|
|
6129
|
+
"ocean",
|
|
6130
|
+
"forest",
|
|
6131
|
+
"sunset",
|
|
6132
|
+
"lavender",
|
|
6133
|
+
"compact",
|
|
6134
|
+
"minimal",
|
|
6135
|
+
"rounded",
|
|
6136
|
+
"high-contrast",
|
|
6137
|
+
"dark"
|
|
6138
|
+
];
|
|
6139
|
+
var KeepThemeContext = createContext4({});
|
|
6140
|
+
function useKeepTheme() {
|
|
6141
|
+
return useContext4(KeepThemeContext);
|
|
6142
|
+
}
|
|
6143
|
+
function KeepThemeProvider({
|
|
6144
|
+
children,
|
|
6145
|
+
theme = "default",
|
|
6146
|
+
mode = "system",
|
|
6147
|
+
density = "comfortable",
|
|
6148
|
+
radius = "medium",
|
|
6149
|
+
accentColor,
|
|
6150
|
+
highContrast = false,
|
|
6151
|
+
reducedMotion = false,
|
|
6152
|
+
variables,
|
|
6153
|
+
style,
|
|
6154
|
+
className,
|
|
6155
|
+
asChild = false,
|
|
6156
|
+
...props
|
|
6157
|
+
}) {
|
|
6158
|
+
const themeClassName = [
|
|
6159
|
+
"keep-theme",
|
|
6160
|
+
`keep-theme--${theme}`,
|
|
6161
|
+
`keep-theme--${mode}`,
|
|
6162
|
+
`keep-theme--density-${density}`,
|
|
6163
|
+
`keep-theme--radius-${radius}`,
|
|
6164
|
+
className
|
|
6165
|
+
].filter(Boolean).join(" ");
|
|
6166
|
+
const themeStyle = {
|
|
6167
|
+
...style,
|
|
6168
|
+
...accentColor && !highContrast ? { "--keep-accent": accentColor, "--keep-primary": accentColor } : {},
|
|
6169
|
+
...variables
|
|
6170
|
+
};
|
|
6171
|
+
const rootProps = {
|
|
6172
|
+
...props,
|
|
6173
|
+
className: themeClassName,
|
|
6174
|
+
style: themeStyle,
|
|
6175
|
+
"data-keep-theme": theme,
|
|
6176
|
+
"data-theme": theme,
|
|
6177
|
+
"data-mode": mode,
|
|
6178
|
+
"data-density": density,
|
|
6179
|
+
"data-radius": radius,
|
|
6180
|
+
"data-accent-color": accentColor,
|
|
6181
|
+
"data-high-contrast": highContrast ? "true" : void 0,
|
|
6182
|
+
"data-reduced-motion": reducedMotion ? "true" : void 0
|
|
6183
|
+
};
|
|
6184
|
+
const content = asChild ? (() => {
|
|
6185
|
+
if (!isValidElement8(children))
|
|
6186
|
+
throw new Error("KeepThemeProvider with asChild requires a single React element child.");
|
|
6187
|
+
return createSlot(children, rootProps);
|
|
6188
|
+
})() : /* @__PURE__ */ jsx28("div", { ...rootProps, children });
|
|
6189
|
+
return /* @__PURE__ */ jsx28(
|
|
6190
|
+
KeepThemeContext.Provider,
|
|
6191
|
+
{
|
|
6192
|
+
value: { theme, mode, density, radius, accentColor, highContrast, reducedMotion, variables, style },
|
|
6193
|
+
children: content
|
|
6194
|
+
}
|
|
6195
|
+
);
|
|
6196
|
+
}
|
|
6197
|
+
|
|
5671
6198
|
// src/features/navigation/KeepTourBar.tsx
|
|
5672
6199
|
import { useKeepNavigator } from "@keepkit/core/react";
|
|
5673
|
-
import { useId as
|
|
6200
|
+
import { useId as useId6 } from "react";
|
|
5674
6201
|
|
|
5675
6202
|
// src/features/navigation/hooks/useKeepTourShortcuts.ts
|
|
5676
6203
|
import { useEffect as useEffect13 } from "react";
|
|
@@ -5705,7 +6232,7 @@ function isEditableTarget(target) {
|
|
|
5705
6232
|
}
|
|
5706
6233
|
|
|
5707
6234
|
// src/features/navigation/KeepTourBar.tsx
|
|
5708
|
-
import { Fragment as
|
|
6235
|
+
import { Fragment as Fragment16, jsx as jsx29, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5709
6236
|
function KeepTourBar({
|
|
5710
6237
|
navigation: providedNavigation,
|
|
5711
6238
|
currentId,
|
|
@@ -5775,9 +6302,9 @@ function KeepTourBar({
|
|
|
5775
6302
|
return resolvedPrev();
|
|
5776
6303
|
}
|
|
5777
6304
|
});
|
|
5778
|
-
const body = /* @__PURE__ */
|
|
5779
|
-
showProgress ? /* @__PURE__ */
|
|
5780
|
-
/* @__PURE__ */
|
|
6305
|
+
const body = /* @__PURE__ */ jsxs24(Fragment16, { children: [
|
|
6306
|
+
showProgress ? /* @__PURE__ */ jsx29("span", { "data-keepkit": "tour-progress", "aria-live": "polite", children: progress ?? `${navigation.currentPosition ?? 0} / ${navigation.items.length}` }) : null,
|
|
6307
|
+
/* @__PURE__ */ jsx29(
|
|
5781
6308
|
TourAction,
|
|
5782
6309
|
{
|
|
5783
6310
|
href: resolvedPrevHref,
|
|
@@ -5785,7 +6312,7 @@ function KeepTourBar({
|
|
|
5785
6312
|
onClick: resolvedPrevHref ? notifyPrevNavigation : resolvedPrev,
|
|
5786
6313
|
"data-keep-action": "tour-prev",
|
|
5787
6314
|
shortcut: showShortcutHint ? shortcutOptions?.prevKeys?.[0] ?? "K" : void 0,
|
|
5788
|
-
preview: navigation.prevItem ? /* @__PURE__ */
|
|
6315
|
+
preview: navigation.prevItem ? /* @__PURE__ */ jsxs24(Fragment16, { children: [
|
|
5789
6316
|
previousLabel,
|
|
5790
6317
|
": ",
|
|
5791
6318
|
getItemTitle(navigation.prevItem)
|
|
@@ -5793,7 +6320,7 @@ function KeepTourBar({
|
|
|
5793
6320
|
children: previousLabel
|
|
5794
6321
|
}
|
|
5795
6322
|
),
|
|
5796
|
-
/* @__PURE__ */
|
|
6323
|
+
/* @__PURE__ */ jsx29(
|
|
5797
6324
|
TourAction,
|
|
5798
6325
|
{
|
|
5799
6326
|
href: resolvedNextHref,
|
|
@@ -5801,7 +6328,7 @@ function KeepTourBar({
|
|
|
5801
6328
|
onClick: resolvedNextHref ? notifyNextNavigation : resolvedNext,
|
|
5802
6329
|
"data-keep-action": "tour-next",
|
|
5803
6330
|
shortcut: showShortcutHint ? shortcutOptions?.nextKeys?.[0] ?? "J" : void 0,
|
|
5804
|
-
preview: navigation.nextItem ? /* @__PURE__ */
|
|
6331
|
+
preview: navigation.nextItem ? /* @__PURE__ */ jsxs24(Fragment16, { children: [
|
|
5805
6332
|
nextItemLabel,
|
|
5806
6333
|
": ",
|
|
5807
6334
|
getItemTitle(navigation.nextItem)
|
|
@@ -5809,7 +6336,7 @@ function KeepTourBar({
|
|
|
5809
6336
|
children: nextItemLabel
|
|
5810
6337
|
}
|
|
5811
6338
|
),
|
|
5812
|
-
resolvedBackHref || onBack ? /* @__PURE__ */
|
|
6339
|
+
resolvedBackHref || onBack ? /* @__PURE__ */ jsx29(TourAction, { href: resolvedBackHref, onClick: onBack, "data-keep-action": "tour-back", children: listLabel }) : null
|
|
5813
6340
|
] });
|
|
5814
6341
|
return renderRoot(
|
|
5815
6342
|
asChild,
|
|
@@ -5820,14 +6347,14 @@ function KeepTourBar({
|
|
|
5820
6347
|
);
|
|
5821
6348
|
}
|
|
5822
6349
|
function TourAction({ href, disabled = false, onClick, children, preview, shortcut, ...props }) {
|
|
5823
|
-
const previewId =
|
|
5824
|
-
const content = /* @__PURE__ */
|
|
5825
|
-
/* @__PURE__ */
|
|
5826
|
-
shortcut ? /* @__PURE__ */
|
|
5827
|
-
preview ? /* @__PURE__ */
|
|
6350
|
+
const previewId = useId6();
|
|
6351
|
+
const content = /* @__PURE__ */ jsxs24(Fragment16, { children: [
|
|
6352
|
+
/* @__PURE__ */ jsx29("span", { "data-tour-label": "true", children }),
|
|
6353
|
+
shortcut ? /* @__PURE__ */ jsx29(KeepShortcutHint, { shortcut }) : null,
|
|
6354
|
+
preview ? /* @__PURE__ */ jsx29("small", { id: previewId, "data-tour-preview": "true", children: preview }) : null
|
|
5828
6355
|
] });
|
|
5829
6356
|
if (href && !disabled) {
|
|
5830
|
-
return /* @__PURE__ */
|
|
6357
|
+
return /* @__PURE__ */ jsx29(
|
|
5831
6358
|
"a",
|
|
5832
6359
|
{
|
|
5833
6360
|
...props,
|
|
@@ -5839,7 +6366,7 @@ function TourAction({ href, disabled = false, onClick, children, preview, shortc
|
|
|
5839
6366
|
}
|
|
5840
6367
|
);
|
|
5841
6368
|
}
|
|
5842
|
-
return /* @__PURE__ */
|
|
6369
|
+
return /* @__PURE__ */ jsx29(
|
|
5843
6370
|
"button",
|
|
5844
6371
|
{
|
|
5845
6372
|
...props,
|
|
@@ -5858,14 +6385,306 @@ function navigateTo(item, href) {
|
|
|
5858
6385
|
window.location.assign(href);
|
|
5859
6386
|
}
|
|
5860
6387
|
|
|
6388
|
+
// src/features/navigation/tour-context.tsx
|
|
6389
|
+
import { useKeepList as useKeepList5 } from "@keepkit/core/react";
|
|
6390
|
+
import { createContext as createContext5, useCallback as useCallback10, useContext as useContext5, useEffect as useEffect14, useMemo as useMemo5, useState as useState19 } from "react";
|
|
6391
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
6392
|
+
var SESSION_VERSION = 1;
|
|
6393
|
+
var KeepTourContext = createContext5(null);
|
|
6394
|
+
function KeepTourProvider({
|
|
6395
|
+
children,
|
|
6396
|
+
sessionKey = "keepkit:tour",
|
|
6397
|
+
getItemHref,
|
|
6398
|
+
getBackHref,
|
|
6399
|
+
onNavigate
|
|
6400
|
+
}) {
|
|
6401
|
+
const list = useKeepList5();
|
|
6402
|
+
const [tour, setTour] = useState19(
|
|
6403
|
+
null
|
|
6404
|
+
);
|
|
6405
|
+
const [persistenceStatus, setPersistenceStatus] = useState19("persistent");
|
|
6406
|
+
const itemsById = useMemo5(() => new Map(list.items.map((item) => [item.id, item])), [list.items]);
|
|
6407
|
+
const readStorage = useCallback10(() => {
|
|
6408
|
+
try {
|
|
6409
|
+
const raw = window.sessionStorage.getItem(sessionKey);
|
|
6410
|
+
if (!raw) return null;
|
|
6411
|
+
const parsed = JSON.parse(raw);
|
|
6412
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
6413
|
+
const value2 = parsed;
|
|
6414
|
+
if (value2.version !== SESSION_VERSION || !Array.isArray(value2.itemIds) || typeof value2.currentId !== "string")
|
|
6415
|
+
return null;
|
|
6416
|
+
const ids = value2.itemIds.filter((id) => typeof id === "string");
|
|
6417
|
+
if (!ids.length || new Set(ids).size !== ids.length) return null;
|
|
6418
|
+
return {
|
|
6419
|
+
version: SESSION_VERSION,
|
|
6420
|
+
itemIds: ids,
|
|
6421
|
+
currentId: value2.currentId,
|
|
6422
|
+
collapsed: value2.collapsed === true
|
|
6423
|
+
};
|
|
6424
|
+
} catch {
|
|
6425
|
+
setPersistenceStatus("memory");
|
|
6426
|
+
return null;
|
|
6427
|
+
}
|
|
6428
|
+
}, [sessionKey]);
|
|
6429
|
+
const writeStorage = useCallback10(
|
|
6430
|
+
(value2) => {
|
|
6431
|
+
try {
|
|
6432
|
+
if (value2) window.sessionStorage.setItem(sessionKey, JSON.stringify({ version: SESSION_VERSION, ...value2 }));
|
|
6433
|
+
else window.sessionStorage.removeItem(sessionKey);
|
|
6434
|
+
setPersistenceStatus("persistent");
|
|
6435
|
+
} catch {
|
|
6436
|
+
setPersistenceStatus("memory");
|
|
6437
|
+
}
|
|
6438
|
+
},
|
|
6439
|
+
[sessionKey]
|
|
6440
|
+
);
|
|
6441
|
+
useEffect14(() => {
|
|
6442
|
+
if (!list.isHydrated || list.error || tour) return;
|
|
6443
|
+
const stored = typeof window === "undefined" ? null : readStorage();
|
|
6444
|
+
if (!stored) return;
|
|
6445
|
+
const ids = stored.itemIds.filter((id) => itemsById.has(id));
|
|
6446
|
+
if (!ids.length) {
|
|
6447
|
+
writeStorage(null);
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6450
|
+
const currentId = ids.includes(stored.currentId) ? stored.currentId : ids[0];
|
|
6451
|
+
setTour({ itemIds: ids, currentId, collapsed: stored.collapsed });
|
|
6452
|
+
}, [itemsById, list.error, list.isHydrated, readStorage, tour, writeStorage]);
|
|
6453
|
+
useEffect14(() => {
|
|
6454
|
+
if (!tour || list.isLoading || list.error) return;
|
|
6455
|
+
const ids = tour.itemIds.filter((id) => itemsById.has(id));
|
|
6456
|
+
if (!ids.length) {
|
|
6457
|
+
setTour(null);
|
|
6458
|
+
writeStorage(null);
|
|
6459
|
+
return;
|
|
6460
|
+
}
|
|
6461
|
+
const currentId = tour.currentId && ids.includes(tour.currentId) ? tour.currentId : ids[0];
|
|
6462
|
+
if (ids.length !== tour.itemIds.length || currentId !== tour.currentId) {
|
|
6463
|
+
const next = { ...tour, itemIds: ids, currentId };
|
|
6464
|
+
setTour(next);
|
|
6465
|
+
writeStorage(next);
|
|
6466
|
+
}
|
|
6467
|
+
}, [itemsById, list.error, list.isLoading, tour, writeStorage]);
|
|
6468
|
+
const start = useCallback10(
|
|
6469
|
+
(options) => {
|
|
6470
|
+
const ids = [...options.itemIds];
|
|
6471
|
+
if (!ids.length || new Set(ids).size !== ids.length || ids.some((id) => !itemsById.has(id))) return false;
|
|
6472
|
+
const currentId = options.currentId ?? ids[0];
|
|
6473
|
+
if (!ids.includes(currentId)) return false;
|
|
6474
|
+
const next = { itemIds: ids, currentId, collapsed: false };
|
|
6475
|
+
setTour(next);
|
|
6476
|
+
writeStorage(next);
|
|
6477
|
+
return true;
|
|
6478
|
+
},
|
|
6479
|
+
[itemsById, writeStorage]
|
|
6480
|
+
);
|
|
6481
|
+
const end = useCallback10(() => {
|
|
6482
|
+
setTour(null);
|
|
6483
|
+
writeStorage(null);
|
|
6484
|
+
}, [writeStorage]);
|
|
6485
|
+
const setCurrentId = useCallback10(
|
|
6486
|
+
(id) => {
|
|
6487
|
+
setTour((current) => {
|
|
6488
|
+
if (!current?.currentId || current.currentId === id || !current.itemIds.includes(id)) return current;
|
|
6489
|
+
const next = { ...current, currentId: id };
|
|
6490
|
+
writeStorage(next);
|
|
6491
|
+
return next;
|
|
6492
|
+
});
|
|
6493
|
+
},
|
|
6494
|
+
[writeStorage]
|
|
6495
|
+
);
|
|
6496
|
+
const move = useCallback10(
|
|
6497
|
+
(delta) => {
|
|
6498
|
+
if (!tour?.currentId) return null;
|
|
6499
|
+
const currentId = tour.currentId;
|
|
6500
|
+
const index = tour.itemIds.indexOf(currentId);
|
|
6501
|
+
const id = tour.itemIds[index + delta];
|
|
6502
|
+
if (!id) return null;
|
|
6503
|
+
setCurrentId(id);
|
|
6504
|
+
return itemsById.get(id) ?? null;
|
|
6505
|
+
},
|
|
6506
|
+
[itemsById, setCurrentId, tour]
|
|
6507
|
+
);
|
|
6508
|
+
const value = useMemo5(
|
|
6509
|
+
() => ({
|
|
6510
|
+
active: tour !== null,
|
|
6511
|
+
itemIds: tour?.itemIds ?? [],
|
|
6512
|
+
currentId: tour?.currentId ?? null,
|
|
6513
|
+
collapsed: tour?.collapsed ?? false,
|
|
6514
|
+
persistenceStatus,
|
|
6515
|
+
getItemHref,
|
|
6516
|
+
getBackHref,
|
|
6517
|
+
onNavigate,
|
|
6518
|
+
start,
|
|
6519
|
+
end,
|
|
6520
|
+
collapse: () => setTour((current) => current ? { ...current, collapsed: true } : current),
|
|
6521
|
+
expand: () => setTour((current) => current ? { ...current, collapsed: false } : current),
|
|
6522
|
+
goNext: () => move(1),
|
|
6523
|
+
goPrev: () => move(-1),
|
|
6524
|
+
setCurrentId
|
|
6525
|
+
}),
|
|
6526
|
+
[end, getBackHref, getItemHref, move, onNavigate, persistenceStatus, setCurrentId, start, tour]
|
|
6527
|
+
);
|
|
6528
|
+
useEffect14(() => {
|
|
6529
|
+
if (!tour) return;
|
|
6530
|
+
if (tour.currentId) writeStorage(tour);
|
|
6531
|
+
}, [tour, writeStorage]);
|
|
6532
|
+
return /* @__PURE__ */ jsx30(KeepTourContext.Provider, { value, children });
|
|
6533
|
+
}
|
|
6534
|
+
function useKeepTour(options = {}) {
|
|
6535
|
+
const context = useContext5(KeepTourContext);
|
|
6536
|
+
if (!context) throw new Error("useKeepTour must be used within KeepTourProvider.");
|
|
6537
|
+
useEffect14(() => {
|
|
6538
|
+
if (options.currentId && context.active) context.setCurrentId(options.currentId);
|
|
6539
|
+
}, [context, options.currentId]);
|
|
6540
|
+
return context;
|
|
6541
|
+
}
|
|
6542
|
+
|
|
6543
|
+
// src/features/navigation/KeepFloatingTour.tsx
|
|
6544
|
+
import { Fragment as Fragment17, jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
6545
|
+
function KeepFloatingTour({
|
|
6546
|
+
currentId,
|
|
6547
|
+
getItemHref,
|
|
6548
|
+
getBackHref,
|
|
6549
|
+
onNavigate,
|
|
6550
|
+
onBack,
|
|
6551
|
+
position = "bottom-center",
|
|
6552
|
+
offset = 16,
|
|
6553
|
+
zIndex = 1e3,
|
|
6554
|
+
className,
|
|
6555
|
+
style,
|
|
6556
|
+
keyboardShortcuts = false,
|
|
6557
|
+
showShortcutHint = false
|
|
6558
|
+
}) {
|
|
6559
|
+
const tour = useKeepTour({ currentId });
|
|
6560
|
+
const { items } = useKeepList6();
|
|
6561
|
+
const theme = useKeepTheme();
|
|
6562
|
+
const [mounted, setMounted] = useState20(false);
|
|
6563
|
+
const { labels } = useKeepUiLabels();
|
|
6564
|
+
const collapseLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u6298\u308A\u305F\u305F\u3080" : "Collapse tour";
|
|
6565
|
+
const expandLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u5C55\u958B" : "Expand tour";
|
|
6566
|
+
const endLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u7D42\u4E86" : "End tour";
|
|
6567
|
+
const expandRef = useRef10(null);
|
|
6568
|
+
const collapseRef = useRef10(null);
|
|
6569
|
+
useEffect15(() => setMounted(true), []);
|
|
6570
|
+
useEffect15(() => {
|
|
6571
|
+
if (!mounted || !tour.active) return;
|
|
6572
|
+
const button = tour.collapsed ? expandRef.current : collapseRef.current;
|
|
6573
|
+
if (button) button.focus();
|
|
6574
|
+
}, [mounted, tour.active, tour.collapsed]);
|
|
6575
|
+
const activeId = currentId ?? tour.currentId;
|
|
6576
|
+
const navigation = useMemo6(() => {
|
|
6577
|
+
const tourItems = tour.itemIds.map((id) => items.find((item) => item.id === id)).filter((item) => item !== void 0);
|
|
6578
|
+
const currentIndex = activeId ? tourItems.findIndex((item) => item.id === activeId) : -1;
|
|
6579
|
+
const currentItem = currentIndex >= 0 ? tourItems[currentIndex] ?? null : null;
|
|
6580
|
+
return {
|
|
6581
|
+
items: tourItems,
|
|
6582
|
+
currentIndex,
|
|
6583
|
+
currentPosition: currentIndex >= 0 ? currentIndex + 1 : null,
|
|
6584
|
+
currentItem,
|
|
6585
|
+
hasNext: currentIndex >= 0 && currentIndex < tourItems.length - 1,
|
|
6586
|
+
hasPrev: currentIndex > 0,
|
|
6587
|
+
nextItem: currentIndex >= 0 ? tourItems[currentIndex + 1] ?? null : null,
|
|
6588
|
+
prevItem: currentIndex > 0 ? tourItems[currentIndex - 1] ?? null : null,
|
|
6589
|
+
goToNext: tour.goNext,
|
|
6590
|
+
goToPrev: tour.goPrev,
|
|
6591
|
+
goToIndex: (index) => {
|
|
6592
|
+
const item = tourItems[index];
|
|
6593
|
+
if (!item) return null;
|
|
6594
|
+
tour.setCurrentId(item.id);
|
|
6595
|
+
return item;
|
|
6596
|
+
},
|
|
6597
|
+
goToItem: (id) => tourItems.find((item) => item.id === id) ?? null
|
|
6598
|
+
};
|
|
6599
|
+
}, [activeId, items, tour]);
|
|
6600
|
+
if (!mounted || !tour.active || typeof document === "undefined" || !activeId) return null;
|
|
6601
|
+
const placementStyle = {
|
|
6602
|
+
"--keep-tour-offset": typeof offset === "number" ? `${offset}px` : offset,
|
|
6603
|
+
"--keep-tour-z-index": zIndex,
|
|
6604
|
+
...style
|
|
6605
|
+
};
|
|
6606
|
+
const content = tour.collapsed ? /* @__PURE__ */ jsxs25(
|
|
6607
|
+
"button",
|
|
6608
|
+
{
|
|
6609
|
+
ref: expandRef,
|
|
6610
|
+
type: "button",
|
|
6611
|
+
className: "keep-floating-tour__expand",
|
|
6612
|
+
"data-keep-action": "tour-expand",
|
|
6613
|
+
"aria-label": `${expandLabel} (${tour.itemIds.indexOf(activeId) + 1} / ${tour.itemIds.length})`,
|
|
6614
|
+
onClick: () => tour.expand(),
|
|
6615
|
+
children: [
|
|
6616
|
+
tour.itemIds.indexOf(activeId) + 1,
|
|
6617
|
+
" / ",
|
|
6618
|
+
tour.itemIds.length
|
|
6619
|
+
]
|
|
6620
|
+
}
|
|
6621
|
+
) : /* @__PURE__ */ jsxs25(Fragment17, { children: [
|
|
6622
|
+
/* @__PURE__ */ jsx31(
|
|
6623
|
+
KeepTourBar,
|
|
6624
|
+
{
|
|
6625
|
+
className: "keep-floating-tour__bar",
|
|
6626
|
+
navigation,
|
|
6627
|
+
currentId: activeId,
|
|
6628
|
+
getItemHref: getItemHref ?? tour.getItemHref,
|
|
6629
|
+
getBackHref: getBackHref ?? tour.getBackHref,
|
|
6630
|
+
onNavigate: onNavigate ?? tour.onNavigate,
|
|
6631
|
+
onBack: () => {
|
|
6632
|
+
tour.end();
|
|
6633
|
+
return onBack?.();
|
|
6634
|
+
},
|
|
6635
|
+
keyboardShortcuts,
|
|
6636
|
+
showShortcutHint
|
|
6637
|
+
}
|
|
6638
|
+
),
|
|
6639
|
+
/* @__PURE__ */ jsx31(
|
|
6640
|
+
"button",
|
|
6641
|
+
{
|
|
6642
|
+
ref: collapseRef,
|
|
6643
|
+
type: "button",
|
|
6644
|
+
className: "keep-floating-tour__control",
|
|
6645
|
+
"data-keep-action": "tour-collapse",
|
|
6646
|
+
"aria-label": collapseLabel,
|
|
6647
|
+
onClick: () => tour.collapse(),
|
|
6648
|
+
children: "\u2212"
|
|
6649
|
+
}
|
|
6650
|
+
),
|
|
6651
|
+
/* @__PURE__ */ jsx31(
|
|
6652
|
+
"button",
|
|
6653
|
+
{
|
|
6654
|
+
type: "button",
|
|
6655
|
+
className: "keep-floating-tour__control",
|
|
6656
|
+
"data-keep-action": "tour-end",
|
|
6657
|
+
"aria-label": endLabel,
|
|
6658
|
+
onClick: () => tour.end(),
|
|
6659
|
+
children: "\xD7"
|
|
6660
|
+
}
|
|
6661
|
+
)
|
|
6662
|
+
] });
|
|
6663
|
+
return createPortal(
|
|
6664
|
+
/* @__PURE__ */ jsx31(KeepThemeProvider, { ...theme, children: /* @__PURE__ */ jsx31(
|
|
6665
|
+
"aside",
|
|
6666
|
+
{
|
|
6667
|
+
className: ["keep-floating-tour", `keep-floating-tour--${position}`, className].filter(Boolean).join(" "),
|
|
6668
|
+
style: placementStyle,
|
|
6669
|
+
"data-keepkit": "floating-tour",
|
|
6670
|
+
"data-state": tour.collapsed ? "collapsed" : "expanded",
|
|
6671
|
+
"data-persistence": tour.persistenceStatus,
|
|
6672
|
+
"aria-label": "KeepKit tour",
|
|
6673
|
+
children: content
|
|
6674
|
+
}
|
|
6675
|
+
) }),
|
|
6676
|
+
document.body
|
|
6677
|
+
);
|
|
6678
|
+
}
|
|
6679
|
+
|
|
5861
6680
|
// src/features/status/status.tsx
|
|
5862
|
-
import { isValidElement as
|
|
6681
|
+
import { isValidElement as isValidElement9 } from "react";
|
|
5863
6682
|
|
|
5864
6683
|
// src/features/status/hooks/useStatusViews.ts
|
|
5865
|
-
import { useKeepContext as
|
|
5866
|
-
import { useEffect as
|
|
6684
|
+
import { useKeepContext as useKeepContext7 } from "@keepkit/core/react";
|
|
6685
|
+
import { useEffect as useEffect16, useRef as useRef11, useState as useState21 } from "react";
|
|
5867
6686
|
function useKeepStatus(status) {
|
|
5868
|
-
const context =
|
|
6687
|
+
const context = useKeepContext7();
|
|
5869
6688
|
const resolvedStatus = status ?? getDerivedStatus(context);
|
|
5870
6689
|
const state = {
|
|
5871
6690
|
status: resolvedStatus,
|
|
@@ -5876,13 +6695,13 @@ function useKeepStatus(status) {
|
|
|
5876
6695
|
return { state, defaultLabel: useUiLabel(getStatusLabelKey3(resolvedStatus)) };
|
|
5877
6696
|
}
|
|
5878
6697
|
function useKeepAnnouncements(messages) {
|
|
5879
|
-
const context =
|
|
6698
|
+
const context = useKeepContext7();
|
|
5880
6699
|
const savedMessage = useUiLabel("savedMessage", messages?.save);
|
|
5881
6700
|
const removedMessage = useUiLabel("removedMessage", messages?.remove);
|
|
5882
6701
|
const noteSavedMessage = useUiLabel("noteSavedMessage", messages?.note);
|
|
5883
|
-
const [message, setMessage] =
|
|
5884
|
-
const lastChangeRef =
|
|
5885
|
-
|
|
6702
|
+
const [message, setMessage] = useState21("");
|
|
6703
|
+
const lastChangeRef = useRef11(void 0);
|
|
6704
|
+
useEffect16(() => {
|
|
5886
6705
|
const change = context.lastChange;
|
|
5887
6706
|
if (!change || change === lastChangeRef.current) return;
|
|
5888
6707
|
lastChangeRef.current = change;
|
|
@@ -5910,7 +6729,7 @@ function getStatusLabelKey3(status) {
|
|
|
5910
6729
|
}
|
|
5911
6730
|
|
|
5912
6731
|
// src/features/status/status.tsx
|
|
5913
|
-
import { jsx as
|
|
6732
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
5914
6733
|
function KeepStatus({
|
|
5915
6734
|
status,
|
|
5916
6735
|
labels,
|
|
@@ -5921,12 +6740,12 @@ function KeepStatus({
|
|
|
5921
6740
|
...rootProps
|
|
5922
6741
|
}) {
|
|
5923
6742
|
const view = useKeepStatus(status);
|
|
5924
|
-
const contentChildren = asChild &&
|
|
6743
|
+
const contentChildren = asChild && isValidElement9(children) ? void 0 : children;
|
|
5925
6744
|
const body = render ? render(view.state) : typeof contentChildren === "function" ? contentChildren(view.state) : contentChildren ?? labels?.[view.state.status] ?? view.defaultLabel;
|
|
5926
6745
|
const role = rootProps.role ?? (view.state.status === "error" ? "alert" : "status");
|
|
5927
6746
|
return renderRoot(
|
|
5928
6747
|
asChild,
|
|
5929
|
-
|
|
6748
|
+
isValidElement9(children) ? children : void 0,
|
|
5930
6749
|
{
|
|
5931
6750
|
...rootProps,
|
|
5932
6751
|
className,
|
|
@@ -5942,7 +6761,7 @@ function KeepStatus({
|
|
|
5942
6761
|
}
|
|
5943
6762
|
function KeepAnnouncements({ messages, ...props }) {
|
|
5944
6763
|
const message = useKeepAnnouncements(messages);
|
|
5945
|
-
return /* @__PURE__ */
|
|
6764
|
+
return /* @__PURE__ */ jsx32(
|
|
5946
6765
|
"div",
|
|
5947
6766
|
{
|
|
5948
6767
|
...props,
|
|
@@ -5958,15 +6777,15 @@ function KeepAnnouncements({ messages, ...props }) {
|
|
|
5958
6777
|
var KeepAnnouncer = KeepAnnouncements;
|
|
5959
6778
|
|
|
5960
6779
|
// src/features/sync/hooks/useKeepSyncFeedback.ts
|
|
5961
|
-
import { useKeepContext as
|
|
5962
|
-
import { useEffect as
|
|
6780
|
+
import { useKeepContext as useKeepContext8 } from "@keepkit/core/react";
|
|
6781
|
+
import { useEffect as useEffect17, useRef as useRef12 } from "react";
|
|
5963
6782
|
function useKeepSyncFeedback() {
|
|
5964
|
-
const { syncState } =
|
|
6783
|
+
const { syncState } = useKeepContext8();
|
|
5965
6784
|
const emitFeedback = useKeepUiFeedback();
|
|
5966
6785
|
const completedMessage = useUiLabel("syncSynced");
|
|
5967
6786
|
const failedMessage = useUiLabel("syncFailedMessage");
|
|
5968
|
-
const previousStatus =
|
|
5969
|
-
|
|
6787
|
+
const previousStatus = useRef12("idle");
|
|
6788
|
+
useEffect17(() => {
|
|
5970
6789
|
const previous = previousStatus.current;
|
|
5971
6790
|
previousStatus.current = syncState.status;
|
|
5972
6791
|
if (syncState.status === "error" && previous !== "error") {
|
|
@@ -5986,17 +6805,17 @@ function KeepSyncFeedbackObserver() {
|
|
|
5986
6805
|
}
|
|
5987
6806
|
|
|
5988
6807
|
// src/features/sync/hooks/useKeepSyncRecoveryDialog.ts
|
|
5989
|
-
import { useKeepContext as
|
|
5990
|
-
import { useEffect as
|
|
6808
|
+
import { useKeepContext as useKeepContext9 } from "@keepkit/core/react";
|
|
6809
|
+
import { useEffect as useEffect18, useState as useState22 } from "react";
|
|
5991
6810
|
function useKeepSyncRecoveryDialog(options) {
|
|
5992
6811
|
const { open, onOpenChange, conflicts, onManualMerge } = options;
|
|
5993
|
-
const context =
|
|
6812
|
+
const context = useKeepContext9();
|
|
5994
6813
|
const conflictList = conflicts ?? context.syncState.conflicts ?? [];
|
|
5995
6814
|
const hasRecovery = conflictList.length > 0 || context.syncState.status === "error" || Boolean(context.error);
|
|
5996
|
-
const [dismissed, setDismissed] =
|
|
5997
|
-
const [busyId, setBusyId] =
|
|
5998
|
-
const [error, setError] =
|
|
5999
|
-
|
|
6815
|
+
const [dismissed, setDismissed] = useState22(false);
|
|
6816
|
+
const [busyId, setBusyId] = useState22();
|
|
6817
|
+
const [error, setError] = useState22();
|
|
6818
|
+
useEffect18(() => {
|
|
6000
6819
|
if (hasRecovery) setDismissed(false);
|
|
6001
6820
|
}, [hasRecovery]);
|
|
6002
6821
|
return {
|
|
@@ -6041,7 +6860,7 @@ function useKeepSyncRecoveryDialog(options) {
|
|
|
6041
6860
|
}
|
|
6042
6861
|
|
|
6043
6862
|
// src/features/sync/KeepSyncRecoveryDialog.tsx
|
|
6044
|
-
import { jsx as
|
|
6863
|
+
import { jsx as jsx33, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6045
6864
|
function KeepSyncRecoveryDialog({
|
|
6046
6865
|
open,
|
|
6047
6866
|
onOpenChange,
|
|
@@ -6056,7 +6875,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6056
6875
|
}) {
|
|
6057
6876
|
const view = useKeepSyncRecoveryDialog({ open, onOpenChange, conflicts, onManualMerge });
|
|
6058
6877
|
if (!view.isOpen) return null;
|
|
6059
|
-
return /* @__PURE__ */
|
|
6878
|
+
return /* @__PURE__ */ jsxs26(
|
|
6060
6879
|
"section",
|
|
6061
6880
|
{
|
|
6062
6881
|
...props,
|
|
@@ -6070,17 +6889,17 @@ function KeepSyncRecoveryDialog({
|
|
|
6070
6889
|
"data-state": view.conflictList.length > 0 ? "conflict" : "error",
|
|
6071
6890
|
"data-loading": view.busyId !== void 0 ? "true" : void 0,
|
|
6072
6891
|
children: [
|
|
6073
|
-
/* @__PURE__ */
|
|
6074
|
-
/* @__PURE__ */
|
|
6075
|
-
/* @__PURE__ */
|
|
6892
|
+
/* @__PURE__ */ jsxs26("header", { children: [
|
|
6893
|
+
/* @__PURE__ */ jsx33("h2", { id: "keepkit-sync-recovery-title", children: title ?? view.labels.title }),
|
|
6894
|
+
/* @__PURE__ */ jsx33("button", { type: "button", "data-keep-action": "close-dialog", onClick: view.close, "aria-label": view.labels.close, children: view.labels.close })
|
|
6076
6895
|
] }),
|
|
6077
6896
|
children,
|
|
6078
|
-
view.conflictList.length > 0 ? /* @__PURE__ */
|
|
6079
|
-
/* @__PURE__ */
|
|
6080
|
-
view.conflictList.map((conflict) => /* @__PURE__ */
|
|
6081
|
-
/* @__PURE__ */
|
|
6082
|
-
/* @__PURE__ */
|
|
6083
|
-
/* @__PURE__ */
|
|
6897
|
+
view.conflictList.length > 0 ? /* @__PURE__ */ jsxs26("div", { children: [
|
|
6898
|
+
/* @__PURE__ */ jsx33("p", { children: view.labels.conflict }),
|
|
6899
|
+
view.conflictList.map((conflict) => /* @__PURE__ */ jsxs26("article", { "data-conflict-id": conflict.id, children: [
|
|
6900
|
+
/* @__PURE__ */ jsx33("h3", { children: getMetaTitle(conflict.operation.item?.meta) ?? conflict.id }),
|
|
6901
|
+
/* @__PURE__ */ jsxs26("div", { "data-conflict-preview": true, children: [
|
|
6902
|
+
/* @__PURE__ */ jsx33(
|
|
6084
6903
|
ConflictPreview,
|
|
6085
6904
|
{
|
|
6086
6905
|
item: conflict.operation.item,
|
|
@@ -6090,7 +6909,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6090
6909
|
side: "local"
|
|
6091
6910
|
}
|
|
6092
6911
|
),
|
|
6093
|
-
/* @__PURE__ */
|
|
6912
|
+
/* @__PURE__ */ jsx33(
|
|
6094
6913
|
ConflictPreview,
|
|
6095
6914
|
{
|
|
6096
6915
|
item: conflict.remote,
|
|
@@ -6101,8 +6920,8 @@ function KeepSyncRecoveryDialog({
|
|
|
6101
6920
|
}
|
|
6102
6921
|
)
|
|
6103
6922
|
] }),
|
|
6104
|
-
/* @__PURE__ */
|
|
6105
|
-
/* @__PURE__ */
|
|
6923
|
+
/* @__PURE__ */ jsxs26("div", { children: [
|
|
6924
|
+
/* @__PURE__ */ jsx33(
|
|
6106
6925
|
"button",
|
|
6107
6926
|
{
|
|
6108
6927
|
type: "button",
|
|
@@ -6112,7 +6931,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6112
6931
|
children: view.labels.keepLocal
|
|
6113
6932
|
}
|
|
6114
6933
|
),
|
|
6115
|
-
/* @__PURE__ */
|
|
6934
|
+
/* @__PURE__ */ jsx33(
|
|
6116
6935
|
"button",
|
|
6117
6936
|
{
|
|
6118
6937
|
type: "button",
|
|
@@ -6122,7 +6941,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6122
6941
|
children: view.labels.useServer
|
|
6123
6942
|
}
|
|
6124
6943
|
),
|
|
6125
|
-
/* @__PURE__ */
|
|
6944
|
+
/* @__PURE__ */ jsx33(
|
|
6126
6945
|
"button",
|
|
6127
6946
|
{
|
|
6128
6947
|
type: "button",
|
|
@@ -6135,12 +6954,12 @@ function KeepSyncRecoveryDialog({
|
|
|
6135
6954
|
] })
|
|
6136
6955
|
] }, conflict.id))
|
|
6137
6956
|
] }) : null,
|
|
6138
|
-
view.showBackupRecovery ? /* @__PURE__ */
|
|
6139
|
-
/* @__PURE__ */
|
|
6140
|
-
/* @__PURE__ */
|
|
6141
|
-
backup ?? (showBackupControls ? /* @__PURE__ */
|
|
6957
|
+
view.showBackupRecovery ? /* @__PURE__ */ jsxs26("section", { "data-recovery": "backup", children: [
|
|
6958
|
+
/* @__PURE__ */ jsx33("h3", { children: view.labels.backupRecovery }),
|
|
6959
|
+
/* @__PURE__ */ jsx33("p", { children: view.labels.backupRecoveryDescription }),
|
|
6960
|
+
backup ?? (showBackupControls ? /* @__PURE__ */ jsx33(KeepBackup, {}) : null)
|
|
6142
6961
|
] }) : null,
|
|
6143
|
-
view.error ? /* @__PURE__ */
|
|
6962
|
+
view.error ? /* @__PURE__ */ jsx33("p", { id: "keepkit-sync-recovery-error", role: "alert", "aria-live": "assertive", children: view.error instanceof Error ? view.error.message : view.labels.error }) : null
|
|
6144
6963
|
]
|
|
6145
6964
|
}
|
|
6146
6965
|
);
|
|
@@ -6152,16 +6971,16 @@ function ConflictPreview({
|
|
|
6152
6971
|
noteLabel,
|
|
6153
6972
|
side
|
|
6154
6973
|
}) {
|
|
6155
|
-
return /* @__PURE__ */
|
|
6156
|
-
/* @__PURE__ */
|
|
6157
|
-
/* @__PURE__ */
|
|
6158
|
-
/* @__PURE__ */
|
|
6159
|
-
/* @__PURE__ */
|
|
6160
|
-
/* @__PURE__ */
|
|
6974
|
+
return /* @__PURE__ */ jsxs26("article", { "data-conflict-version": side, "aria-label": heading, children: [
|
|
6975
|
+
/* @__PURE__ */ jsx33("h4", { children: heading }),
|
|
6976
|
+
/* @__PURE__ */ jsxs26("dl", { children: [
|
|
6977
|
+
/* @__PURE__ */ jsxs26("div", { children: [
|
|
6978
|
+
/* @__PURE__ */ jsx33("dt", { children: updatedAtLabel }),
|
|
6979
|
+
/* @__PURE__ */ jsx33("dd", { children: item ? /* @__PURE__ */ jsx33("time", { dateTime: new Date(item.updatedAt).toISOString(), children: formatConflictDate(item.updatedAt) }) : "\u2014" })
|
|
6161
6980
|
] }),
|
|
6162
|
-
/* @__PURE__ */
|
|
6163
|
-
/* @__PURE__ */
|
|
6164
|
-
/* @__PURE__ */
|
|
6981
|
+
/* @__PURE__ */ jsxs26("div", { children: [
|
|
6982
|
+
/* @__PURE__ */ jsx33("dt", { children: noteLabel }),
|
|
6983
|
+
/* @__PURE__ */ jsx33("dd", { children: item?.note || "\u2014" })
|
|
6165
6984
|
] })
|
|
6166
6985
|
] })
|
|
6167
6986
|
] });
|
|
@@ -6171,9 +6990,9 @@ function formatConflictDate(timestamp) {
|
|
|
6171
6990
|
}
|
|
6172
6991
|
|
|
6173
6992
|
// src/features/sync/hooks/useKeepSyncStatusBanner.ts
|
|
6174
|
-
import { useKeepContext as
|
|
6993
|
+
import { useKeepContext as useKeepContext10 } from "@keepkit/core/react";
|
|
6175
6994
|
function useKeepSyncStatusBanner({ onRetry, children }) {
|
|
6176
|
-
const context =
|
|
6995
|
+
const context = useKeepContext10();
|
|
6177
6996
|
const retryLabel = useUiLabel("retrySync");
|
|
6178
6997
|
const resolveLabel = useUiLabel("resolveSync");
|
|
6179
6998
|
const conflictLabel = useUiLabel("syncConflict");
|
|
@@ -6205,7 +7024,7 @@ function getErrorMessage6(error) {
|
|
|
6205
7024
|
}
|
|
6206
7025
|
|
|
6207
7026
|
// src/features/sync/KeepSyncStatusBanner.tsx
|
|
6208
|
-
import { jsx as
|
|
7027
|
+
import { jsx as jsx34, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6209
7028
|
function KeepSyncStatusBanner({
|
|
6210
7029
|
onRetry,
|
|
6211
7030
|
onResolveConflicts,
|
|
@@ -6217,7 +7036,7 @@ function KeepSyncStatusBanner({
|
|
|
6217
7036
|
const showRetryLabel = useUiLabelVisibility("retrySync");
|
|
6218
7037
|
const showResolveLabel = useUiLabelVisibility("resolveSync");
|
|
6219
7038
|
if (view.status === "idle" && !view.hasConflicts) return null;
|
|
6220
|
-
return /* @__PURE__ */
|
|
7039
|
+
return /* @__PURE__ */ jsxs27(
|
|
6221
7040
|
"aside",
|
|
6222
7041
|
{
|
|
6223
7042
|
...props,
|
|
@@ -6227,8 +7046,8 @@ function KeepSyncStatusBanner({
|
|
|
6227
7046
|
"data-keepkit": "sync-status",
|
|
6228
7047
|
"data-state": view.status,
|
|
6229
7048
|
children: [
|
|
6230
|
-
/* @__PURE__ */
|
|
6231
|
-
view.showRetry ? /* @__PURE__ */
|
|
7049
|
+
/* @__PURE__ */ jsx34("p", { children: view.message }),
|
|
7050
|
+
view.showRetry ? /* @__PURE__ */ jsx34(
|
|
6232
7051
|
"button",
|
|
6233
7052
|
{
|
|
6234
7053
|
type: "button",
|
|
@@ -6239,7 +7058,7 @@ function KeepSyncStatusBanner({
|
|
|
6239
7058
|
children: showRetryLabel ? view.retryLabel : null
|
|
6240
7059
|
}
|
|
6241
7060
|
) : null,
|
|
6242
|
-
view.hasConflicts ? /* @__PURE__ */
|
|
7061
|
+
view.hasConflicts ? /* @__PURE__ */ jsx34(
|
|
6243
7062
|
"button",
|
|
6244
7063
|
{
|
|
6245
7064
|
type: "button",
|
|
@@ -6256,7 +7075,7 @@ function KeepSyncStatusBanner({
|
|
|
6256
7075
|
}
|
|
6257
7076
|
|
|
6258
7077
|
// src/features/workspace/hooks/useKeepWorkspace.ts
|
|
6259
|
-
import { useCallback as
|
|
7078
|
+
import { useCallback as useCallback11, useState as useState23 } from "react";
|
|
6260
7079
|
var PRESET_MODULES = {
|
|
6261
7080
|
basic: { syncStatus: false, undo: false, recovery: false, backup: false, stalePrune: false },
|
|
6262
7081
|
standard: { syncStatus: false, undo: true, recovery: false, backup: false, stalePrune: false },
|
|
@@ -6276,16 +7095,16 @@ function useKeepWorkspace({
|
|
|
6276
7095
|
onRecoveryOpenChange,
|
|
6277
7096
|
onResolveConflicts
|
|
6278
7097
|
}) {
|
|
6279
|
-
const [internalRecoveryOpen, setInternalRecoveryOpen] =
|
|
7098
|
+
const [internalRecoveryOpen, setInternalRecoveryOpen] = useState23(false);
|
|
6280
7099
|
const resolvedModules = { ...PRESET_MODULES[preset], ...modules };
|
|
6281
|
-
const setRecoveryOpen =
|
|
7100
|
+
const setRecoveryOpen = useCallback11(
|
|
6282
7101
|
(open) => {
|
|
6283
7102
|
if (recoveryOpen === void 0) setInternalRecoveryOpen(open);
|
|
6284
7103
|
onRecoveryOpenChange?.(open);
|
|
6285
7104
|
},
|
|
6286
7105
|
[onRecoveryOpenChange, recoveryOpen]
|
|
6287
7106
|
);
|
|
6288
|
-
const openRecovery =
|
|
7107
|
+
const openRecovery = useCallback11(() => {
|
|
6289
7108
|
onResolveConflicts?.();
|
|
6290
7109
|
setRecoveryOpen(true);
|
|
6291
7110
|
}, [onResolveConflicts, setRecoveryOpen]);
|
|
@@ -6300,7 +7119,7 @@ function useKeepWorkspace({
|
|
|
6300
7119
|
}
|
|
6301
7120
|
|
|
6302
7121
|
// src/features/workspace/KeepWorkspace.tsx
|
|
6303
|
-
import { jsx as
|
|
7122
|
+
import { jsx as jsx35, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
6304
7123
|
function KeepWorkspace({
|
|
6305
7124
|
preset = "standard",
|
|
6306
7125
|
modules,
|
|
@@ -6339,27 +7158,27 @@ function KeepWorkspace({
|
|
|
6339
7158
|
if (!structuredRegions) return content;
|
|
6340
7159
|
if (!hasRenderableContent(content)) return null;
|
|
6341
7160
|
const resolvedSurface = typeof surface === "string" ? surface : surface[name] ?? "plain";
|
|
6342
|
-
return /* @__PURE__ */
|
|
7161
|
+
return /* @__PURE__ */ jsx35("div", { "data-keepkit": "workspace-region", "data-region": name, "data-surface": resolvedSurface, children: content });
|
|
6343
7162
|
};
|
|
6344
7163
|
const before = resolveOptionalSlot(slots?.before, state);
|
|
6345
7164
|
const syncStatus = view.modules.syncStatus ? resolveSlot(
|
|
6346
7165
|
slots?.syncStatus,
|
|
6347
|
-
/* @__PURE__ */
|
|
7166
|
+
/* @__PURE__ */ jsx35(KeepSyncStatusBanner, { ...syncStatusProps, onResolveConflicts: view.openRecovery }),
|
|
6348
7167
|
state
|
|
6349
7168
|
) : null;
|
|
6350
|
-
const collection = resolveSlot(slots?.collection, /* @__PURE__ */
|
|
7169
|
+
const collection = resolveSlot(slots?.collection, /* @__PURE__ */ jsx35(KeepCollection, { ...resolvedCollectionProps }), state);
|
|
6351
7170
|
const actions = view.modules.backup || view.modules.stalePrune ? resolveSlot(
|
|
6352
7171
|
slots?.actions,
|
|
6353
|
-
/* @__PURE__ */
|
|
6354
|
-
view.modules.stalePrune ? /* @__PURE__ */
|
|
6355
|
-
view.modules.backup ? /* @__PURE__ */
|
|
7172
|
+
/* @__PURE__ */ jsxs28("div", { "data-keepkit": "workspace-actions", children: [
|
|
7173
|
+
view.modules.stalePrune ? /* @__PURE__ */ jsx35(KeepPruneStaleButton, { ...stalePruneProps }) : null,
|
|
7174
|
+
view.modules.backup ? /* @__PURE__ */ jsx35(KeepBackup, { ...backupProps }) : null
|
|
6356
7175
|
] }),
|
|
6357
7176
|
state
|
|
6358
7177
|
) : null;
|
|
6359
|
-
const undo = view.modules.undo ? resolveSlot(slots?.undo, /* @__PURE__ */
|
|
7178
|
+
const undo = view.modules.undo ? resolveSlot(slots?.undo, /* @__PURE__ */ jsx35(KeepUndo, { ...undoProps }), state) : null;
|
|
6360
7179
|
const recovery = view.modules.recovery ? resolveSlot(
|
|
6361
7180
|
slots?.recovery,
|
|
6362
|
-
/* @__PURE__ */
|
|
7181
|
+
/* @__PURE__ */ jsx35(
|
|
6363
7182
|
KeepSyncRecoveryDialog,
|
|
6364
7183
|
{
|
|
6365
7184
|
...recoveryProps,
|
|
@@ -6371,7 +7190,7 @@ function KeepWorkspace({
|
|
|
6371
7190
|
) : null;
|
|
6372
7191
|
const additionalContent = resolveOptionalSlot(children, state);
|
|
6373
7192
|
const after = resolveOptionalSlot(slots?.after, state);
|
|
6374
|
-
return /* @__PURE__ */
|
|
7193
|
+
return /* @__PURE__ */ jsxs28(
|
|
6375
7194
|
"section",
|
|
6376
7195
|
{
|
|
6377
7196
|
...props,
|
|
@@ -6402,79 +7221,15 @@ function resolveOptionalSlot(slot, state) {
|
|
|
6402
7221
|
return resolveContent(slot, state);
|
|
6403
7222
|
}
|
|
6404
7223
|
|
|
6405
|
-
// src/foundation/theme.tsx
|
|
6406
|
-
import { isValidElement as isValidElement9 } from "react";
|
|
6407
|
-
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
6408
|
-
var keepThemeNames = [
|
|
6409
|
-
"default",
|
|
6410
|
-
"ocean",
|
|
6411
|
-
"forest",
|
|
6412
|
-
"sunset",
|
|
6413
|
-
"lavender",
|
|
6414
|
-
"compact",
|
|
6415
|
-
"minimal",
|
|
6416
|
-
"rounded",
|
|
6417
|
-
"high-contrast",
|
|
6418
|
-
"dark"
|
|
6419
|
-
];
|
|
6420
|
-
function KeepThemeProvider({
|
|
6421
|
-
children,
|
|
6422
|
-
theme = "default",
|
|
6423
|
-
mode = "system",
|
|
6424
|
-
density = "comfortable",
|
|
6425
|
-
radius = "medium",
|
|
6426
|
-
accentColor,
|
|
6427
|
-
highContrast = false,
|
|
6428
|
-
reducedMotion = false,
|
|
6429
|
-
variables,
|
|
6430
|
-
style,
|
|
6431
|
-
className,
|
|
6432
|
-
asChild = false,
|
|
6433
|
-
...props
|
|
6434
|
-
}) {
|
|
6435
|
-
const themeClassName = [
|
|
6436
|
-
"keep-theme",
|
|
6437
|
-
`keep-theme--${theme}`,
|
|
6438
|
-
`keep-theme--${mode}`,
|
|
6439
|
-
`keep-theme--density-${density}`,
|
|
6440
|
-
`keep-theme--radius-${radius}`,
|
|
6441
|
-
className
|
|
6442
|
-
].filter(Boolean).join(" ");
|
|
6443
|
-
const themeStyle = {
|
|
6444
|
-
...style,
|
|
6445
|
-
...accentColor && !highContrast ? { "--keep-accent": accentColor, "--keep-primary": accentColor } : {},
|
|
6446
|
-
...variables
|
|
6447
|
-
};
|
|
6448
|
-
const rootProps = {
|
|
6449
|
-
...props,
|
|
6450
|
-
className: themeClassName,
|
|
6451
|
-
style: themeStyle,
|
|
6452
|
-
"data-keep-theme": theme,
|
|
6453
|
-
"data-theme": theme,
|
|
6454
|
-
"data-mode": mode,
|
|
6455
|
-
"data-density": density,
|
|
6456
|
-
"data-radius": radius,
|
|
6457
|
-
"data-accent-color": accentColor,
|
|
6458
|
-
"data-high-contrast": highContrast ? "true" : void 0,
|
|
6459
|
-
"data-reduced-motion": reducedMotion ? "true" : void 0
|
|
6460
|
-
};
|
|
6461
|
-
if (asChild) {
|
|
6462
|
-
if (!isValidElement9(children))
|
|
6463
|
-
throw new Error("KeepThemeProvider with asChild requires a single React element child.");
|
|
6464
|
-
return createSlot(children, rootProps);
|
|
6465
|
-
}
|
|
6466
|
-
return /* @__PURE__ */ jsx32("div", { ...rootProps, children });
|
|
6467
|
-
}
|
|
6468
|
-
|
|
6469
7224
|
// src/index.tsx
|
|
6470
7225
|
import { createAuthenticatedSyncKit } from "@keepkit/core/core";
|
|
6471
7226
|
import {
|
|
6472
7227
|
KeepErrorBoundary as KeepErrorBoundary3,
|
|
6473
7228
|
KeepProvider,
|
|
6474
|
-
useKeepCollections as
|
|
6475
|
-
useKeepContext as
|
|
7229
|
+
useKeepCollections as useKeepCollections5,
|
|
7230
|
+
useKeepContext as useKeepContext11,
|
|
6476
7231
|
useKeepItem as useKeepItem8,
|
|
6477
|
-
useKeepList as
|
|
7232
|
+
useKeepList as useKeepList7,
|
|
6478
7233
|
useKeepNavigator as useKeepNavigator2,
|
|
6479
7234
|
useKeepShortcut
|
|
6480
7235
|
} from "@keepkit/core/react";
|
|
@@ -6488,7 +7243,7 @@ import {
|
|
|
6488
7243
|
LocalStorageSyncQueueAdapter,
|
|
6489
7244
|
SyncStorageAdapter
|
|
6490
7245
|
} from "@keepkit/core/storage";
|
|
6491
|
-
import { jsx as
|
|
7246
|
+
import { jsx as jsx36, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6492
7247
|
function KeepKitProvider({
|
|
6493
7248
|
labels,
|
|
6494
7249
|
labelOptions,
|
|
@@ -6506,10 +7261,11 @@ function KeepKitProvider({
|
|
|
6506
7261
|
className: themeClassName,
|
|
6507
7262
|
style: themeStyle,
|
|
6508
7263
|
asChild: themeAsChild,
|
|
7264
|
+
tour,
|
|
6509
7265
|
children,
|
|
6510
7266
|
...providerProps
|
|
6511
7267
|
}) {
|
|
6512
|
-
return /* @__PURE__ */
|
|
7268
|
+
return /* @__PURE__ */ jsx36(
|
|
6513
7269
|
KeepUiProvider,
|
|
6514
7270
|
{
|
|
6515
7271
|
labels,
|
|
@@ -6517,7 +7273,7 @@ function KeepKitProvider({
|
|
|
6517
7273
|
locale,
|
|
6518
7274
|
labelResolver,
|
|
6519
7275
|
onFeedback,
|
|
6520
|
-
children: /* @__PURE__ */
|
|
7276
|
+
children: /* @__PURE__ */ jsx36(
|
|
6521
7277
|
KeepThemeProvider,
|
|
6522
7278
|
{
|
|
6523
7279
|
theme,
|
|
@@ -6531,10 +7287,10 @@ function KeepKitProvider({
|
|
|
6531
7287
|
className: themeClassName,
|
|
6532
7288
|
style: themeStyle,
|
|
6533
7289
|
asChild: themeAsChild,
|
|
6534
|
-
children: /* @__PURE__ */
|
|
6535
|
-
/* @__PURE__ */
|
|
6536
|
-
children,
|
|
6537
|
-
/* @__PURE__ */
|
|
7290
|
+
children: /* @__PURE__ */ jsxs29(CoreKeepProvider, { ...providerProps, children: [
|
|
7291
|
+
/* @__PURE__ */ jsx36(KeepSyncFeedbackObserver, {}),
|
|
7292
|
+
/* @__PURE__ */ jsx36(KeepTourProvider, { ...tour, children }),
|
|
7293
|
+
/* @__PURE__ */ jsx36(KeepAnnouncements, {})
|
|
6538
7294
|
] })
|
|
6539
7295
|
}
|
|
6540
7296
|
)
|
|
@@ -6558,13 +7314,14 @@ function createKeepKit(options = {}) {
|
|
|
6558
7314
|
variables,
|
|
6559
7315
|
themeClassName,
|
|
6560
7316
|
themeStyle,
|
|
7317
|
+
tour,
|
|
6561
7318
|
getTitle,
|
|
6562
7319
|
getImageProps,
|
|
6563
7320
|
...coreOptions
|
|
6564
7321
|
} = options;
|
|
6565
7322
|
const coreKit = createCoreKeepKit(coreOptions);
|
|
6566
7323
|
return {
|
|
6567
|
-
Provider: (props) => /* @__PURE__ */
|
|
7324
|
+
Provider: (props) => /* @__PURE__ */ jsx36(
|
|
6568
7325
|
KeepKitProvider,
|
|
6569
7326
|
{
|
|
6570
7327
|
...coreOptions,
|
|
@@ -6583,12 +7340,13 @@ function createKeepKit(options = {}) {
|
|
|
6583
7340
|
variables,
|
|
6584
7341
|
className: themeClassName,
|
|
6585
7342
|
style: themeStyle,
|
|
7343
|
+
tour,
|
|
6586
7344
|
...props
|
|
6587
7345
|
}
|
|
6588
7346
|
),
|
|
6589
|
-
Button: (props) => /* @__PURE__ */
|
|
6590
|
-
Backup: (props) => /* @__PURE__ */
|
|
6591
|
-
Collection: (props) => /* @__PURE__ */
|
|
7347
|
+
Button: (props) => /* @__PURE__ */ jsx36(KeepButton, { ...props }),
|
|
7348
|
+
Backup: (props) => /* @__PURE__ */ jsx36(KeepBackup, { ...props }),
|
|
7349
|
+
Collection: (props) => /* @__PURE__ */ jsx36(
|
|
6592
7350
|
KeepCollection,
|
|
6593
7351
|
{
|
|
6594
7352
|
...props,
|
|
@@ -6599,7 +7357,8 @@ function createKeepKit(options = {}) {
|
|
|
6599
7357
|
}
|
|
6600
7358
|
}
|
|
6601
7359
|
),
|
|
6602
|
-
|
|
7360
|
+
CollectionManager: (props) => /* @__PURE__ */ jsx36(KeepCollectionManager, { ...props }),
|
|
7361
|
+
Workspace: (props) => /* @__PURE__ */ jsx36(
|
|
6603
7362
|
KeepWorkspace,
|
|
6604
7363
|
{
|
|
6605
7364
|
...props,
|
|
@@ -6618,7 +7377,10 @@ function createKeepKit(options = {}) {
|
|
|
6618
7377
|
useList: (query) => coreKit.useList(query),
|
|
6619
7378
|
useCollections: (collectionsOptions) => coreKit.useCollections(collectionsOptions),
|
|
6620
7379
|
useNavigator: (navigatorOptions) => coreKit.useNavigator(navigatorOptions),
|
|
6621
|
-
useShortcut: (shortcutOptions) => coreKit.useShortcut(shortcutOptions)
|
|
7380
|
+
useShortcut: (shortcutOptions) => coreKit.useShortcut(shortcutOptions),
|
|
7381
|
+
FloatingTour: (props) => /* @__PURE__ */ jsx36(KeepFloatingTour, { ...props }),
|
|
7382
|
+
TourProvider: (props) => /* @__PURE__ */ jsx36(KeepTourProvider, { ...props }),
|
|
7383
|
+
useTour: (tourOptions) => useKeepTour(tourOptions)
|
|
6622
7384
|
};
|
|
6623
7385
|
}
|
|
6624
7386
|
export {
|
|
@@ -6636,9 +7398,11 @@ export {
|
|
|
6636
7398
|
KeepCollection,
|
|
6637
7399
|
KeepCollectionCreate,
|
|
6638
7400
|
KeepCollectionFilter,
|
|
7401
|
+
KeepCollectionManager,
|
|
6639
7402
|
KeepCollectionSelect,
|
|
6640
7403
|
KeepEmptyState,
|
|
6641
7404
|
KeepErrorBoundary3 as KeepErrorBoundary,
|
|
7405
|
+
KeepFloatingTour,
|
|
6642
7406
|
KeepHighlight,
|
|
6643
7407
|
KeepItemCard,
|
|
6644
7408
|
KeepItemCardSkeleton,
|
|
@@ -6667,6 +7431,7 @@ export {
|
|
|
6667
7431
|
KeepTagFilter,
|
|
6668
7432
|
KeepThemeProvider,
|
|
6669
7433
|
KeepTourBar,
|
|
7434
|
+
KeepTourProvider,
|
|
6670
7435
|
KeepUiProvider,
|
|
6671
7436
|
KeepUndo,
|
|
6672
7437
|
KeepWorkspace,
|
|
@@ -6687,14 +7452,15 @@ export {
|
|
|
6687
7452
|
keepThemeNames,
|
|
6688
7453
|
mergeProps,
|
|
6689
7454
|
toggleSelectAll,
|
|
6690
|
-
|
|
6691
|
-
|
|
7455
|
+
useKeepCollections5 as useKeepCollections,
|
|
7456
|
+
useKeepContext11 as useKeepContext,
|
|
6692
7457
|
useKeepItem8 as useKeepItem,
|
|
6693
|
-
|
|
7458
|
+
useKeepList7 as useKeepList,
|
|
6694
7459
|
useKeepNavigator2 as useKeepNavigator,
|
|
6695
7460
|
useKeepQuickEditor,
|
|
6696
7461
|
useKeepShortcut,
|
|
6697
7462
|
useKeepToastFeedback,
|
|
7463
|
+
useKeepTour,
|
|
6698
7464
|
useKeepTourShortcuts,
|
|
6699
7465
|
useKeepUiLabels,
|
|
6700
7466
|
useKeepUrlSync,
|