@keepkit/ui 0.28.0 → 0.28.2
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 +50 -10
- package/dist/index.js +567 -282
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ function useKeepUrlSync({
|
|
|
51
51
|
...decoded.tags ? { tags: decoded.tags } : { tags: void 0 },
|
|
52
52
|
...decoded.sort ? { sort: decoded.sort } : {},
|
|
53
53
|
...decoded.pagination ? { pagination: { ...previousQuery.pagination, ...decoded.pagination } } : {},
|
|
54
|
+
...decoded.activity ? { activity: decoded.activity } : {},
|
|
54
55
|
...decoded.archiveScope !== void 0 ? { archived: decoded.archived, archiveScope: decoded.archiveScope } : decoded.archived !== void 0 ? { archived: decoded.archived, archiveScope: void 0 } : { archived: void 0, archiveScope: void 0 }
|
|
55
56
|
}));
|
|
56
57
|
};
|
|
@@ -196,6 +197,11 @@ var DE_LABELS = {
|
|
|
196
197
|
archiveScopeActive: "Aktiv",
|
|
197
198
|
archiveScopeArchived: "Archiviert",
|
|
198
199
|
archiveScopeAll: "Alle Elemente",
|
|
200
|
+
activityNeverOpened: "Noch nie ge\xF6ffnet",
|
|
201
|
+
activityOpened: "Ge\xF6ffnet",
|
|
202
|
+
activityInactiveFor: "Tage inaktiv",
|
|
203
|
+
activityBefore: "Ge\xF6ffnet vor",
|
|
204
|
+
activityAfter: "Ge\xF6ffnet nach",
|
|
199
205
|
undoReorder: "Sortierung r\xFCckg\xE4ngig machen",
|
|
200
206
|
toolbarStart: "Sammlungsaktionen",
|
|
201
207
|
toolbarQuery: "Suchen und sortieren",
|
|
@@ -316,6 +322,11 @@ var EN_LABELS = {
|
|
|
316
322
|
archiveScopeActive: "Active",
|
|
317
323
|
archiveScopeArchived: "Archived",
|
|
318
324
|
archiveScopeAll: "All items",
|
|
325
|
+
activityNeverOpened: "Never opened",
|
|
326
|
+
activityOpened: "Opened",
|
|
327
|
+
activityInactiveFor: "days inactive",
|
|
328
|
+
activityBefore: "Opened before",
|
|
329
|
+
activityAfter: "Opened after",
|
|
319
330
|
undoReorder: "Undo reorder",
|
|
320
331
|
toolbarStart: "Collection actions",
|
|
321
332
|
toolbarQuery: "Search and sort",
|
|
@@ -436,6 +447,11 @@ var ES_LABELS = {
|
|
|
436
447
|
archiveScopeActive: "Activos",
|
|
437
448
|
archiveScopeArchived: "Archivados",
|
|
438
449
|
archiveScopeAll: "Todos los elementos",
|
|
450
|
+
activityNeverOpened: "Nunca abierto",
|
|
451
|
+
activityOpened: "Abierto",
|
|
452
|
+
activityInactiveFor: "d\xEDas inactivo",
|
|
453
|
+
activityBefore: "Abierto antes de",
|
|
454
|
+
activityAfter: "Abierto despu\xE9s de",
|
|
439
455
|
undoReorder: "Deshacer ordenaci\xF3n",
|
|
440
456
|
toolbarStart: "Acciones de la colecci\xF3n",
|
|
441
457
|
toolbarQuery: "Buscar y ordenar",
|
|
@@ -556,6 +572,11 @@ var FIL_LABELS = {
|
|
|
556
572
|
archiveScopeActive: "Aktibo",
|
|
557
573
|
archiveScopeArchived: "Naka-archive",
|
|
558
574
|
archiveScopeAll: "Lahat ng item",
|
|
575
|
+
activityNeverOpened: "Hindi pa nabubuksan",
|
|
576
|
+
activityOpened: "Nabuksan",
|
|
577
|
+
activityInactiveFor: "araw na hindi aktibo",
|
|
578
|
+
activityBefore: "Nabuksan bago",
|
|
579
|
+
activityAfter: "Nabuksan pagkatapos",
|
|
559
580
|
undoReorder: "I-undo ang pag-aayos",
|
|
560
581
|
toolbarStart: "Mga aksyon ng koleksyon",
|
|
561
582
|
toolbarQuery: "Maghanap at mag-ayos",
|
|
@@ -676,6 +697,11 @@ var FR_LABELS = {
|
|
|
676
697
|
archiveScopeActive: "Actifs",
|
|
677
698
|
archiveScopeArchived: "Archiv\xE9s",
|
|
678
699
|
archiveScopeAll: "Tous les \xE9l\xE9ments",
|
|
700
|
+
activityNeverOpened: "Jamais ouvert",
|
|
701
|
+
activityOpened: "Ouvert",
|
|
702
|
+
activityInactiveFor: "jours inactif",
|
|
703
|
+
activityBefore: "Ouvert avant",
|
|
704
|
+
activityAfter: "Ouvert apr\xE8s",
|
|
679
705
|
undoReorder: "Annuler le r\xE9ordonnancement",
|
|
680
706
|
toolbarStart: "Actions de la collection",
|
|
681
707
|
toolbarQuery: "Recherche et tri",
|
|
@@ -796,6 +822,11 @@ var ID_LABELS = {
|
|
|
796
822
|
archiveScopeActive: "Aktif",
|
|
797
823
|
archiveScopeArchived: "Diarsipkan",
|
|
798
824
|
archiveScopeAll: "Semua item",
|
|
825
|
+
activityNeverOpened: "Belum pernah dibuka",
|
|
826
|
+
activityOpened: "Sudah dibuka",
|
|
827
|
+
activityInactiveFor: "hari tidak aktif",
|
|
828
|
+
activityBefore: "Dibuka sebelum",
|
|
829
|
+
activityAfter: "Dibuka setelah",
|
|
799
830
|
undoReorder: "Batalkan pengurutan",
|
|
800
831
|
toolbarStart: "Tindakan koleksi",
|
|
801
832
|
toolbarQuery: "Cari dan urutkan",
|
|
@@ -916,6 +947,11 @@ var IT_LABELS = {
|
|
|
916
947
|
archiveScopeActive: "Attivi",
|
|
917
948
|
archiveScopeArchived: "Archiviati",
|
|
918
949
|
archiveScopeAll: "Tutti gli elementi",
|
|
950
|
+
activityNeverOpened: "Mai aperto",
|
|
951
|
+
activityOpened: "Aperto",
|
|
952
|
+
activityInactiveFor: "giorni inattivo",
|
|
953
|
+
activityBefore: "Aperto prima di",
|
|
954
|
+
activityAfter: "Aperto dopo",
|
|
919
955
|
undoReorder: "Annulla riordinamento",
|
|
920
956
|
toolbarStart: "Azioni della raccolta",
|
|
921
957
|
toolbarQuery: "Cerca e ordina",
|
|
@@ -1036,6 +1072,11 @@ var JA_LABELS = {
|
|
|
1036
1072
|
archiveScopeActive: "\u4FDD\u5B58\u4E2D",
|
|
1037
1073
|
archiveScopeArchived: "\u30A2\u30FC\u30AB\u30A4\u30D6\u6E08\u307F",
|
|
1038
1074
|
archiveScopeAll: "\u3059\u3079\u3066",
|
|
1075
|
+
activityNeverOpened: "\u672A\u95B2\u89A7",
|
|
1076
|
+
activityOpened: "\u95B2\u89A7\u6E08\u307F",
|
|
1077
|
+
activityInactiveFor: "\u65E5\u9593\u672A\u95B2\u89A7",
|
|
1078
|
+
activityBefore: "\u95B2\u89A7\u65E5\u6642\u304C\u6B21\u3088\u308A\u524D",
|
|
1079
|
+
activityAfter: "\u95B2\u89A7\u65E5\u6642\u304C\u6B21\u3088\u308A\u5F8C",
|
|
1039
1080
|
undoReorder: "\u4E26\u3073\u66FF\u3048\u3092\u5143\u306B\u623B\u3059",
|
|
1040
1081
|
toolbarStart: "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u64CD\u4F5C",
|
|
1041
1082
|
toolbarQuery: "\u691C\u7D22\u3068\u4E26\u3073\u66FF\u3048",
|
|
@@ -1156,6 +1197,11 @@ var KO_LABELS = {
|
|
|
1156
1197
|
archiveScopeActive: "\uD65C\uC131",
|
|
1157
1198
|
archiveScopeArchived: "\uBCF4\uAD00\uB428",
|
|
1158
1199
|
archiveScopeAll: "\uBAA8\uB4E0 \uD56D\uBAA9",
|
|
1200
|
+
activityNeverOpened: "\uC5F4\uC9C0 \uC54A\uC74C",
|
|
1201
|
+
activityOpened: "\uC5F4\uC5C8\uC74C",
|
|
1202
|
+
activityInactiveFor: "\uC77C \uB3D9\uC548 \uBE44\uD65C\uC131",
|
|
1203
|
+
activityBefore: "\uB2E4\uC74C \uC774\uC804\uC5D0 \uC5F4\uB9BC",
|
|
1204
|
+
activityAfter: "\uB2E4\uC74C \uC774\uD6C4\uC5D0 \uC5F4\uB9BC",
|
|
1159
1205
|
undoReorder: "\uC815\uB82C \uC2E4\uD589 \uCDE8\uC18C",
|
|
1160
1206
|
toolbarStart: "\uCEEC\uB809\uC158 \uC791\uC5C5",
|
|
1161
1207
|
toolbarQuery: "\uAC80\uC0C9 \uBC0F \uC815\uB82C",
|
|
@@ -1276,6 +1322,11 @@ var MS_LABELS = {
|
|
|
1276
1322
|
archiveScopeActive: "Aktif",
|
|
1277
1323
|
archiveScopeArchived: "Diarkibkan",
|
|
1278
1324
|
archiveScopeAll: "Semua item",
|
|
1325
|
+
activityNeverOpened: "Belum pernah dibuka",
|
|
1326
|
+
activityOpened: "Telah dibuka",
|
|
1327
|
+
activityInactiveFor: "hari tidak aktif",
|
|
1328
|
+
activityBefore: "Dibuka sebelum",
|
|
1329
|
+
activityAfter: "Dibuka selepas",
|
|
1279
1330
|
undoReorder: "Buat asal susunan",
|
|
1280
1331
|
toolbarStart: "Tindakan koleksi",
|
|
1281
1332
|
toolbarQuery: "Cari dan susun",
|
|
@@ -1396,6 +1447,11 @@ var PT_BR_LABELS = {
|
|
|
1396
1447
|
archiveScopeActive: "Ativos",
|
|
1397
1448
|
archiveScopeArchived: "Arquivados",
|
|
1398
1449
|
archiveScopeAll: "Todos os itens",
|
|
1450
|
+
activityNeverOpened: "Nunca aberto",
|
|
1451
|
+
activityOpened: "Aberto",
|
|
1452
|
+
activityInactiveFor: "dias inativo",
|
|
1453
|
+
activityBefore: "Aberto antes de",
|
|
1454
|
+
activityAfter: "Aberto depois de",
|
|
1399
1455
|
undoReorder: "Desfazer reordena\xE7\xE3o",
|
|
1400
1456
|
toolbarStart: "A\xE7\xF5es da cole\xE7\xE3o",
|
|
1401
1457
|
toolbarQuery: "Pesquisar e ordenar",
|
|
@@ -1516,6 +1572,11 @@ var RU_LABELS = {
|
|
|
1516
1572
|
archiveScopeActive: "\u0410\u043A\u0442\u0438\u0432\u043D\u044B\u0435",
|
|
1517
1573
|
archiveScopeArchived: "\u0412 \u0430\u0440\u0445\u0438\u0432\u0435",
|
|
1518
1574
|
archiveScopeAll: "\u0412\u0441\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",
|
|
1575
|
+
activityNeverOpened: "\u041D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0441\u044F",
|
|
1576
|
+
activityOpened: "\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u043B\u0441\u044F",
|
|
1577
|
+
activityInactiveFor: "\u0434\u043D. \u0431\u0435\u0437 \u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0441\u0442\u0438",
|
|
1578
|
+
activityBefore: "\u041E\u0442\u043A\u0440\u044B\u0442 \u0434\u043E",
|
|
1579
|
+
activityAfter: "\u041E\u0442\u043A\u0440\u044B\u0442 \u043F\u043E\u0441\u043B\u0435",
|
|
1519
1580
|
undoReorder: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0443",
|
|
1520
1581
|
toolbarStart: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F \u043A\u043E\u043B\u043B\u0435\u043A\u0446\u0438\u0438",
|
|
1521
1582
|
toolbarQuery: "\u041F\u043E\u0438\u0441\u043A \u0438 \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0430",
|
|
@@ -1636,6 +1697,11 @@ var TH_LABELS = {
|
|
|
1636
1697
|
archiveScopeActive: "\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E2D\u0E22\u0E39\u0E48",
|
|
1637
1698
|
archiveScopeArchived: "\u0E40\u0E01\u0E47\u0E1A\u0E16\u0E32\u0E27\u0E23\u0E41\u0E25\u0E49\u0E27",
|
|
1638
1699
|
archiveScopeAll: "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14",
|
|
1700
|
+
activityNeverOpened: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E40\u0E04\u0E22\u0E40\u0E1B\u0E34\u0E14",
|
|
1701
|
+
activityOpened: "\u0E40\u0E04\u0E22\u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E49\u0E27",
|
|
1702
|
+
activityInactiveFor: "\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E21\u0E35\u0E01\u0E32\u0E23\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19",
|
|
1703
|
+
activityBefore: "\u0E40\u0E1B\u0E34\u0E14\u0E01\u0E48\u0E2D\u0E19",
|
|
1704
|
+
activityAfter: "\u0E40\u0E1B\u0E34\u0E14\u0E2B\u0E25\u0E31\u0E07",
|
|
1639
1705
|
undoReorder: "\u0E40\u0E25\u0E34\u0E01\u0E17\u0E33\u0E01\u0E32\u0E23\u0E08\u0E31\u0E14\u0E40\u0E23\u0E35\u0E22\u0E07",
|
|
1640
1706
|
toolbarStart: "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E02\u0E2D\u0E07\u0E04\u0E2D\u0E25\u0E40\u0E25\u0E01\u0E0A\u0E31\u0E19",
|
|
1641
1707
|
toolbarQuery: "\u0E04\u0E49\u0E19\u0E2B\u0E32\u0E41\u0E25\u0E30\u0E08\u0E31\u0E14\u0E40\u0E23\u0E35\u0E22\u0E07",
|
|
@@ -1756,6 +1822,11 @@ var VI_LABELS = {
|
|
|
1756
1822
|
archiveScopeActive: "\u0110ang ho\u1EA1t \u0111\u1ED9ng",
|
|
1757
1823
|
archiveScopeArchived: "\u0110\xE3 l\u01B0u tr\u1EEF",
|
|
1758
1824
|
archiveScopeAll: "T\u1EA5t c\u1EA3 m\u1EE5c",
|
|
1825
|
+
activityNeverOpened: "Ch\u01B0a t\u1EEBng m\u1EDF",
|
|
1826
|
+
activityOpened: "\u0110\xE3 m\u1EDF",
|
|
1827
|
+
activityInactiveFor: "ng\xE0y kh\xF4ng ho\u1EA1t \u0111\u1ED9ng",
|
|
1828
|
+
activityBefore: "\u0110\xE3 m\u1EDF tr\u01B0\u1EDBc",
|
|
1829
|
+
activityAfter: "\u0110\xE3 m\u1EDF sau",
|
|
1759
1830
|
undoReorder: "Ho\xE0n t\xE1c s\u1EAFp x\u1EBFp",
|
|
1760
1831
|
toolbarStart: "Thao t\xE1c b\u1ED9 s\u01B0u t\u1EADp",
|
|
1761
1832
|
toolbarQuery: "T\xECm ki\u1EBFm v\xE0 s\u1EAFp x\u1EBFp",
|
|
@@ -1876,6 +1947,11 @@ var ZH_HANS_LABELS = {
|
|
|
1876
1947
|
archiveScopeActive: "\u4FDD\u5B58\u4E2D",
|
|
1877
1948
|
archiveScopeArchived: "\u5DF2\u5F52\u6863",
|
|
1878
1949
|
archiveScopeAll: "\u5168\u90E8\u9879\u76EE",
|
|
1950
|
+
activityNeverOpened: "\u4ECE\u672A\u6253\u5F00",
|
|
1951
|
+
activityOpened: "\u5DF2\u6253\u5F00",
|
|
1952
|
+
activityInactiveFor: "\u5929\u672A\u6D3B\u52A8",
|
|
1953
|
+
activityBefore: "\u6253\u5F00\u65F6\u95F4\u65E9\u4E8E",
|
|
1954
|
+
activityAfter: "\u6253\u5F00\u65F6\u95F4\u665A\u4E8E",
|
|
1879
1955
|
undoReorder: "\u64A4\u9500\u6392\u5E8F",
|
|
1880
1956
|
toolbarStart: "\u96C6\u5408\u64CD\u4F5C",
|
|
1881
1957
|
toolbarQuery: "\u641C\u7D22\u548C\u6392\u5E8F",
|
|
@@ -1996,6 +2072,11 @@ var ZH_HANT_LABELS = {
|
|
|
1996
2072
|
archiveScopeActive: "\u4FDD\u5B58\u4E2D",
|
|
1997
2073
|
archiveScopeArchived: "\u5DF2\u5C01\u5B58",
|
|
1998
2074
|
archiveScopeAll: "\u6240\u6709\u9805\u76EE",
|
|
2075
|
+
activityNeverOpened: "\u5F9E\u672A\u958B\u555F",
|
|
2076
|
+
activityOpened: "\u5DF2\u958B\u555F",
|
|
2077
|
+
activityInactiveFor: "\u5929\u672A\u6D3B\u52D5",
|
|
2078
|
+
activityBefore: "\u958B\u555F\u6642\u9593\u65E9\u65BC",
|
|
2079
|
+
activityAfter: "\u958B\u555F\u6642\u9593\u665A\u65BC",
|
|
1999
2080
|
undoReorder: "\u5FA9\u539F\u6392\u5E8F",
|
|
2000
2081
|
toolbarStart: "\u96C6\u5408\u64CD\u4F5C",
|
|
2001
2082
|
toolbarQuery: "\u641C\u5C0B\u8207\u6392\u5E8F",
|
|
@@ -2217,160 +2298,6 @@ function KeepPinButton({
|
|
|
2217
2298
|
);
|
|
2218
2299
|
}
|
|
2219
2300
|
|
|
2220
|
-
// src/features/actions/hooks/useKeepBackup.ts
|
|
2221
|
-
import { useKeepContext } from "@keepkit/core/react";
|
|
2222
|
-
import { useRef as useRef2, useState } from "react";
|
|
2223
|
-
function useKeepBackup({ filename, onExport, onImported }) {
|
|
2224
|
-
const context = useKeepContext();
|
|
2225
|
-
const inputRef = useRef2(null);
|
|
2226
|
-
const [mode, setMode] = useState("merge");
|
|
2227
|
-
const [result, setResult] = useState();
|
|
2228
|
-
const [error, setError] = useState();
|
|
2229
|
-
async function exportBackup() {
|
|
2230
|
-
setError(void 0);
|
|
2231
|
-
try {
|
|
2232
|
-
const data = await context.exportBackup();
|
|
2233
|
-
onExport?.(data);
|
|
2234
|
-
if (typeof document === "undefined") return;
|
|
2235
|
-
const url = URL.createObjectURL(new Blob([data], { type: "application/json" }));
|
|
2236
|
-
const anchor = document.createElement("a");
|
|
2237
|
-
anchor.href = url;
|
|
2238
|
-
anchor.download = filename;
|
|
2239
|
-
anchor.click();
|
|
2240
|
-
URL.revokeObjectURL(url);
|
|
2241
|
-
} catch (cause) {
|
|
2242
|
-
setError(cause);
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
async function importBackup(event) {
|
|
2246
|
-
const file = event.currentTarget.files?.[0];
|
|
2247
|
-
event.currentTarget.value = "";
|
|
2248
|
-
if (!file) return;
|
|
2249
|
-
setError(void 0);
|
|
2250
|
-
setResult(void 0);
|
|
2251
|
-
try {
|
|
2252
|
-
const imported = await context.importBackup(await file.text(), { mode });
|
|
2253
|
-
setResult(imported);
|
|
2254
|
-
onImported?.(imported);
|
|
2255
|
-
} catch (cause) {
|
|
2256
|
-
setError(cause);
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
return {
|
|
2260
|
-
inputRef,
|
|
2261
|
-
mode,
|
|
2262
|
-
setMode,
|
|
2263
|
-
result,
|
|
2264
|
-
error,
|
|
2265
|
-
isMutating: context.isMutating,
|
|
2266
|
-
exportBackup,
|
|
2267
|
-
importBackup,
|
|
2268
|
-
openFilePicker: () => inputRef.current?.click(),
|
|
2269
|
-
labels: {
|
|
2270
|
-
export: useUiLabel("exportData"),
|
|
2271
|
-
import: useUiLabel("importData"),
|
|
2272
|
-
importMode: useUiLabel("importMode"),
|
|
2273
|
-
merge: useUiLabel("merge"),
|
|
2274
|
-
replace: useUiLabel("replace"),
|
|
2275
|
-
importedCount: useUiLabel("importedCount"),
|
|
2276
|
-
failedCount: useUiLabel("failedCount"),
|
|
2277
|
-
quotaError: useUiLabel("storageQuotaError")
|
|
2278
|
-
}
|
|
2279
|
-
};
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
// src/features/actions/KeepBackup.tsx
|
|
2283
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2284
|
-
function KeepBackup({
|
|
2285
|
-
filename = "keepkit-backup.json",
|
|
2286
|
-
onExport,
|
|
2287
|
-
onImported,
|
|
2288
|
-
...props
|
|
2289
|
-
}) {
|
|
2290
|
-
const view = useKeepBackup({ filename, onExport, onImported });
|
|
2291
|
-
const showExportLabel = useUiLabelVisibility("exportData");
|
|
2292
|
-
const showImportModeLabel = useUiLabelVisibility("importMode");
|
|
2293
|
-
const showImportLabel = useUiLabelVisibility("importData");
|
|
2294
|
-
return /* @__PURE__ */ jsxs2(
|
|
2295
|
-
"section",
|
|
2296
|
-
{
|
|
2297
|
-
...props,
|
|
2298
|
-
"data-keepkit": "backup",
|
|
2299
|
-
"data-state": view.error ? "error" : view.result ? "complete" : "idle",
|
|
2300
|
-
"data-loading": view.isMutating ? "true" : void 0,
|
|
2301
|
-
children: [
|
|
2302
|
-
/* @__PURE__ */ jsx2(
|
|
2303
|
-
"button",
|
|
2304
|
-
{
|
|
2305
|
-
type: "button",
|
|
2306
|
-
"data-keep-action": "export-backup",
|
|
2307
|
-
onClick: () => void view.exportBackup(),
|
|
2308
|
-
disabled: view.isMutating,
|
|
2309
|
-
"aria-label": showExportLabel ? void 0 : view.labels.export,
|
|
2310
|
-
children: showExportLabel ? view.labels.export : null
|
|
2311
|
-
}
|
|
2312
|
-
),
|
|
2313
|
-
/* @__PURE__ */ jsxs2("label", { children: [
|
|
2314
|
-
showImportModeLabel ? view.labels.importMode : null,
|
|
2315
|
-
/* @__PURE__ */ jsxs2(
|
|
2316
|
-
"select",
|
|
2317
|
-
{
|
|
2318
|
-
"data-keep-action": "select-import-mode",
|
|
2319
|
-
value: view.mode,
|
|
2320
|
-
"aria-label": showImportModeLabel ? void 0 : view.labels.importMode,
|
|
2321
|
-
onChange: (event) => view.setMode(event.currentTarget.value),
|
|
2322
|
-
children: [
|
|
2323
|
-
/* @__PURE__ */ jsx2("option", { value: "merge", children: view.labels.merge }),
|
|
2324
|
-
/* @__PURE__ */ jsx2("option", { value: "replace", children: view.labels.replace })
|
|
2325
|
-
]
|
|
2326
|
-
}
|
|
2327
|
-
)
|
|
2328
|
-
] }),
|
|
2329
|
-
/* @__PURE__ */ jsx2(
|
|
2330
|
-
"button",
|
|
2331
|
-
{
|
|
2332
|
-
type: "button",
|
|
2333
|
-
"data-keep-action": "import-backup",
|
|
2334
|
-
onClick: view.openFilePicker,
|
|
2335
|
-
disabled: view.isMutating,
|
|
2336
|
-
"aria-label": showImportLabel ? void 0 : view.labels.import,
|
|
2337
|
-
children: showImportLabel ? view.labels.import : null
|
|
2338
|
-
}
|
|
2339
|
-
),
|
|
2340
|
-
/* @__PURE__ */ jsx2(
|
|
2341
|
-
"input",
|
|
2342
|
-
{
|
|
2343
|
-
ref: view.inputRef,
|
|
2344
|
-
type: "file",
|
|
2345
|
-
"data-keep-action": "select-backup-file",
|
|
2346
|
-
accept: "application/json,.json",
|
|
2347
|
-
"aria-label": view.labels.import,
|
|
2348
|
-
onChange: (event) => void view.importBackup(event)
|
|
2349
|
-
}
|
|
2350
|
-
),
|
|
2351
|
-
view.result ? /* @__PURE__ */ jsxs2("p", { role: "status", children: [
|
|
2352
|
-
view.result.imported,
|
|
2353
|
-
" ",
|
|
2354
|
-
view.labels.importedCount,
|
|
2355
|
-
"; ",
|
|
2356
|
-
view.result.failed,
|
|
2357
|
-
" ",
|
|
2358
|
-
view.labels.failedCount
|
|
2359
|
-
] }) : null,
|
|
2360
|
-
view.error ? /* @__PURE__ */ jsx2("p", { role: "alert", children: isQuotaError(view.error) ? view.labels.quotaError : getErrorMessage(view.error) }) : null
|
|
2361
|
-
]
|
|
2362
|
-
}
|
|
2363
|
-
);
|
|
2364
|
-
}
|
|
2365
|
-
function isQuotaError(error) {
|
|
2366
|
-
if (error instanceof Error && error.name === "KeepStorageQuotaError") return true;
|
|
2367
|
-
if (error && typeof error === "object" && "cause" in error) return isQuotaError(error.cause);
|
|
2368
|
-
return false;
|
|
2369
|
-
}
|
|
2370
|
-
function getErrorMessage(error) {
|
|
2371
|
-
return error instanceof Error ? error.message : "Something went wrong.";
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
2301
|
// src/foundation/shared.tsx
|
|
2375
2302
|
import {
|
|
2376
2303
|
cloneElement,
|
|
@@ -2380,10 +2307,10 @@ import {
|
|
|
2380
2307
|
useContext as useContext2,
|
|
2381
2308
|
useMemo as useMemo2
|
|
2382
2309
|
} from "react";
|
|
2383
|
-
import { Fragment as Fragment2, jsx as
|
|
2310
|
+
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
2384
2311
|
var KeepSearchQueryContext = createContext2(void 0);
|
|
2385
2312
|
function KeepSearchQueryProvider({ query, children }) {
|
|
2386
|
-
return /* @__PURE__ */
|
|
2313
|
+
return /* @__PURE__ */ jsx2(KeepSearchQueryContext.Provider, { value: query, children });
|
|
2387
2314
|
}
|
|
2388
2315
|
function useKeepSearchQuery() {
|
|
2389
2316
|
return useContext2(KeepSearchQueryContext);
|
|
@@ -2410,14 +2337,14 @@ function highlightText(text, query) {
|
|
|
2410
2337
|
const index = match.index;
|
|
2411
2338
|
if (index > lastIndex) parts.push(text.slice(lastIndex, index));
|
|
2412
2339
|
parts.push(
|
|
2413
|
-
/* @__PURE__ */
|
|
2340
|
+
/* @__PURE__ */ jsx2("mark", { className: "keep-highlight", "data-highlight": "true", children: match[0] }, `highlight-${matchIndex}`)
|
|
2414
2341
|
);
|
|
2415
2342
|
lastIndex = index + match[0].length;
|
|
2416
2343
|
matchIndex += 1;
|
|
2417
2344
|
}
|
|
2418
2345
|
if (lastIndex === 0) return text;
|
|
2419
2346
|
if (lastIndex < text.length) parts.push(text.slice(lastIndex));
|
|
2420
|
-
return /* @__PURE__ */
|
|
2347
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: parts });
|
|
2421
2348
|
}
|
|
2422
2349
|
function escapeRegExp(value) {
|
|
2423
2350
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -2439,6 +2366,9 @@ function getMetaTitle(meta) {
|
|
|
2439
2366
|
const title = meta.title;
|
|
2440
2367
|
return typeof title === "string" && title.trim() ? title.trim() : void 0;
|
|
2441
2368
|
}
|
|
2369
|
+
function getErrorMessage(error, fallback) {
|
|
2370
|
+
return error instanceof Error ? error.message : fallback;
|
|
2371
|
+
}
|
|
2442
2372
|
function normalizeUiTags(tags) {
|
|
2443
2373
|
return [...new Set(tags.map((tag) => tag.trim()).filter(Boolean))];
|
|
2444
2374
|
}
|
|
@@ -2531,7 +2461,158 @@ function renderRoot(asChild, child, props, body, componentName) {
|
|
|
2531
2461
|
if (!isValidElement(child)) throw new Error(`${componentName} with asChild requires a single React element child.`);
|
|
2532
2462
|
return createSlot(child, props, body);
|
|
2533
2463
|
}
|
|
2534
|
-
return /* @__PURE__ */
|
|
2464
|
+
return /* @__PURE__ */ jsx2("div", { ...props, children: body });
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
// src/features/actions/hooks/useKeepBackup.ts
|
|
2468
|
+
import { useKeepContext } from "@keepkit/core/react";
|
|
2469
|
+
import { useRef as useRef2, useState } from "react";
|
|
2470
|
+
function useKeepBackup({ filename, onExport, onImported }) {
|
|
2471
|
+
const context = useKeepContext();
|
|
2472
|
+
const inputRef = useRef2(null);
|
|
2473
|
+
const [mode, setMode] = useState("merge");
|
|
2474
|
+
const [result, setResult] = useState();
|
|
2475
|
+
const [error, setError] = useState();
|
|
2476
|
+
async function exportBackup() {
|
|
2477
|
+
setError(void 0);
|
|
2478
|
+
try {
|
|
2479
|
+
const data = await context.exportBackup();
|
|
2480
|
+
onExport?.(data);
|
|
2481
|
+
if (typeof document === "undefined") return;
|
|
2482
|
+
const url = URL.createObjectURL(new Blob([data], { type: "application/json" }));
|
|
2483
|
+
const anchor = document.createElement("a");
|
|
2484
|
+
anchor.href = url;
|
|
2485
|
+
anchor.download = filename;
|
|
2486
|
+
anchor.click();
|
|
2487
|
+
URL.revokeObjectURL(url);
|
|
2488
|
+
} catch (cause) {
|
|
2489
|
+
setError(cause);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
async function importBackup(event) {
|
|
2493
|
+
const file = event.currentTarget.files?.[0];
|
|
2494
|
+
event.currentTarget.value = "";
|
|
2495
|
+
if (!file) return;
|
|
2496
|
+
setError(void 0);
|
|
2497
|
+
setResult(void 0);
|
|
2498
|
+
try {
|
|
2499
|
+
const imported = await context.importBackup(await file.text(), { mode });
|
|
2500
|
+
setResult(imported);
|
|
2501
|
+
onImported?.(imported);
|
|
2502
|
+
} catch (cause) {
|
|
2503
|
+
setError(cause);
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
return {
|
|
2507
|
+
inputRef,
|
|
2508
|
+
mode,
|
|
2509
|
+
setMode,
|
|
2510
|
+
result,
|
|
2511
|
+
error,
|
|
2512
|
+
isMutating: context.isMutating,
|
|
2513
|
+
exportBackup,
|
|
2514
|
+
importBackup,
|
|
2515
|
+
openFilePicker: () => inputRef.current?.click(),
|
|
2516
|
+
labels: {
|
|
2517
|
+
export: useUiLabel("exportData"),
|
|
2518
|
+
import: useUiLabel("importData"),
|
|
2519
|
+
importMode: useUiLabel("importMode"),
|
|
2520
|
+
merge: useUiLabel("merge"),
|
|
2521
|
+
replace: useUiLabel("replace"),
|
|
2522
|
+
importedCount: useUiLabel("importedCount"),
|
|
2523
|
+
failedCount: useUiLabel("failedCount"),
|
|
2524
|
+
quotaError: useUiLabel("storageQuotaError")
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
// src/features/actions/KeepBackup.tsx
|
|
2530
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2531
|
+
function KeepBackup({
|
|
2532
|
+
filename = "keepkit-backup.json",
|
|
2533
|
+
onExport,
|
|
2534
|
+
onImported,
|
|
2535
|
+
...props
|
|
2536
|
+
}) {
|
|
2537
|
+
const view = useKeepBackup({ filename, onExport, onImported });
|
|
2538
|
+
const showExportLabel = useUiLabelVisibility("exportData");
|
|
2539
|
+
const showImportModeLabel = useUiLabelVisibility("importMode");
|
|
2540
|
+
const showImportLabel = useUiLabelVisibility("importData");
|
|
2541
|
+
return /* @__PURE__ */ jsxs2(
|
|
2542
|
+
"section",
|
|
2543
|
+
{
|
|
2544
|
+
...props,
|
|
2545
|
+
"data-keepkit": "backup",
|
|
2546
|
+
"data-state": view.error ? "error" : view.result ? "complete" : "idle",
|
|
2547
|
+
"data-loading": view.isMutating ? "true" : void 0,
|
|
2548
|
+
children: [
|
|
2549
|
+
/* @__PURE__ */ jsx3(
|
|
2550
|
+
"button",
|
|
2551
|
+
{
|
|
2552
|
+
type: "button",
|
|
2553
|
+
"data-keep-action": "export-backup",
|
|
2554
|
+
onClick: () => void view.exportBackup(),
|
|
2555
|
+
disabled: view.isMutating,
|
|
2556
|
+
"aria-label": showExportLabel ? void 0 : view.labels.export,
|
|
2557
|
+
children: showExportLabel ? view.labels.export : null
|
|
2558
|
+
}
|
|
2559
|
+
),
|
|
2560
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
2561
|
+
showImportModeLabel ? view.labels.importMode : null,
|
|
2562
|
+
/* @__PURE__ */ jsxs2(
|
|
2563
|
+
"select",
|
|
2564
|
+
{
|
|
2565
|
+
"data-keep-action": "select-import-mode",
|
|
2566
|
+
value: view.mode,
|
|
2567
|
+
"aria-label": showImportModeLabel ? void 0 : view.labels.importMode,
|
|
2568
|
+
onChange: (event) => view.setMode(event.currentTarget.value),
|
|
2569
|
+
children: [
|
|
2570
|
+
/* @__PURE__ */ jsx3("option", { value: "merge", children: view.labels.merge }),
|
|
2571
|
+
/* @__PURE__ */ jsx3("option", { value: "replace", children: view.labels.replace })
|
|
2572
|
+
]
|
|
2573
|
+
}
|
|
2574
|
+
)
|
|
2575
|
+
] }),
|
|
2576
|
+
/* @__PURE__ */ jsx3(
|
|
2577
|
+
"button",
|
|
2578
|
+
{
|
|
2579
|
+
type: "button",
|
|
2580
|
+
"data-keep-action": "import-backup",
|
|
2581
|
+
onClick: view.openFilePicker,
|
|
2582
|
+
disabled: view.isMutating,
|
|
2583
|
+
"aria-label": showImportLabel ? void 0 : view.labels.import,
|
|
2584
|
+
children: showImportLabel ? view.labels.import : null
|
|
2585
|
+
}
|
|
2586
|
+
),
|
|
2587
|
+
/* @__PURE__ */ jsx3(
|
|
2588
|
+
"input",
|
|
2589
|
+
{
|
|
2590
|
+
ref: view.inputRef,
|
|
2591
|
+
type: "file",
|
|
2592
|
+
"data-keep-action": "select-backup-file",
|
|
2593
|
+
accept: "application/json,.json",
|
|
2594
|
+
"aria-label": view.labels.import,
|
|
2595
|
+
onChange: (event) => void view.importBackup(event)
|
|
2596
|
+
}
|
|
2597
|
+
),
|
|
2598
|
+
view.result ? /* @__PURE__ */ jsxs2("p", { role: "status", children: [
|
|
2599
|
+
view.result.imported,
|
|
2600
|
+
" ",
|
|
2601
|
+
view.labels.importedCount,
|
|
2602
|
+
"; ",
|
|
2603
|
+
view.result.failed,
|
|
2604
|
+
" ",
|
|
2605
|
+
view.labels.failedCount
|
|
2606
|
+
] }) : null,
|
|
2607
|
+
view.error ? /* @__PURE__ */ jsx3("p", { role: "alert", children: isQuotaError(view.error) ? view.labels.quotaError : getErrorMessage(view.error, "Something went wrong.") }) : null
|
|
2608
|
+
]
|
|
2609
|
+
}
|
|
2610
|
+
);
|
|
2611
|
+
}
|
|
2612
|
+
function isQuotaError(error) {
|
|
2613
|
+
if (error instanceof Error && error.name === "KeepStorageQuotaError") return true;
|
|
2614
|
+
if (error && typeof error === "object" && "cause" in error) return isQuotaError(error.cause);
|
|
2615
|
+
return false;
|
|
2535
2616
|
}
|
|
2536
2617
|
|
|
2537
2618
|
// src/features/actions/hooks/useKeepBulkActions.ts
|
|
@@ -3091,7 +3172,7 @@ function KeepQuickEditorView({
|
|
|
3091
3172
|
}
|
|
3092
3173
|
if (event.key === "Tab") trapFocus(event, focusScopeRef?.current ?? rootRef.current);
|
|
3093
3174
|
};
|
|
3094
|
-
const statusMessage = state.saveStatus === "dirty" ? unsavedChangesLabel : state.saveStatus === "saving" ? savingLabel : state.saveStatus === "saved" ? savedLabel : state.saveStatus === "error" ?
|
|
3175
|
+
const statusMessage = state.saveStatus === "dirty" ? unsavedChangesLabel : state.saveStatus === "saving" ? savingLabel : state.saveStatus === "saved" ? savedLabel : state.saveStatus === "error" ? getErrorMessage(state.error, errorLabel) : null;
|
|
3095
3176
|
const body = typeof children === "function" ? children(state) : children ?? /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
3096
3177
|
enabled.note ? /* @__PURE__ */ jsxs5("label", { "data-keep-field": "note", children: [
|
|
3097
3178
|
showNoteLabel ? /* @__PURE__ */ jsx7("span", { "data-keep-field-icon": true, children: noteLabel }) : null,
|
|
@@ -3185,9 +3266,6 @@ function KeepQuickEditorView({
|
|
|
3185
3266
|
function sameDraft(left, right) {
|
|
3186
3267
|
return left.note === right.note && sameTags(left.tags, right.tags) && left.collectionId === right.collectionId;
|
|
3187
3268
|
}
|
|
3188
|
-
function getErrorMessage2(error, fallback) {
|
|
3189
|
-
return error instanceof Error ? error.message : fallback;
|
|
3190
|
-
}
|
|
3191
3269
|
function sameTags(left, right) {
|
|
3192
3270
|
return left.length === right.length && left.every((tag, index) => tag === right[index]);
|
|
3193
3271
|
}
|
|
@@ -3440,7 +3518,7 @@ function KeepUndo({ children, label, ...props }) {
|
|
|
3440
3518
|
|
|
3441
3519
|
// src/features/collection/KeepCollection.tsx
|
|
3442
3520
|
import { KeepErrorBoundary as KeepErrorBoundary2 } from "@keepkit/core/react";
|
|
3443
|
-
import { useEffect as useEffect10, useId as useId4, useState as useState15 } from "react";
|
|
3521
|
+
import { useEffect as useEffect10, useId as useId4, useRef as useRef9, useState as useState15 } from "react";
|
|
3444
3522
|
|
|
3445
3523
|
// src/features/query/KeepActiveFiltersSummary.tsx
|
|
3446
3524
|
import {
|
|
@@ -3452,8 +3530,18 @@ function KeepActiveFiltersSummary({
|
|
|
3452
3530
|
query,
|
|
3453
3531
|
search: providedSearch,
|
|
3454
3532
|
tags: providedTags,
|
|
3533
|
+
collection: providedCollection,
|
|
3534
|
+
collectionLabel: providedCollectionLabel,
|
|
3535
|
+
activity: providedActivity,
|
|
3536
|
+
activityLabel: providedActivityLabel,
|
|
3537
|
+
archiveScope: providedArchiveScope,
|
|
3538
|
+
archiveScopeLabel: providedArchiveScopeLabel,
|
|
3539
|
+
totalCount,
|
|
3455
3540
|
onSearchChange,
|
|
3456
3541
|
onTagChange,
|
|
3542
|
+
onCollectionChange,
|
|
3543
|
+
onActivityChange,
|
|
3544
|
+
onArchiveScopeChange,
|
|
3457
3545
|
onClear,
|
|
3458
3546
|
children,
|
|
3459
3547
|
asChild = false,
|
|
@@ -3461,15 +3549,42 @@ function KeepActiveFiltersSummary({
|
|
|
3461
3549
|
...rootProps
|
|
3462
3550
|
}) {
|
|
3463
3551
|
const search = (providedSearch ?? query?.search?.query ?? "").trim();
|
|
3464
|
-
const tags =
|
|
3465
|
-
const
|
|
3552
|
+
const tags = normalizeUiTags(providedTags ?? query?.tags ?? []);
|
|
3553
|
+
const collection = providedCollection ?? query?.collectionId;
|
|
3554
|
+
const activity = providedActivity ?? query?.activity;
|
|
3555
|
+
const hasActivity = Boolean(activity && Object.keys(activity).length > 0);
|
|
3556
|
+
const archiveScope = providedArchiveScope ?? query?.archiveScope ?? (query?.archived === true ? "archived" : "active");
|
|
3557
|
+
const hasArchiveScope = archiveScope !== void 0 && archiveScope !== "active";
|
|
3558
|
+
const hasFilters = Boolean(search) || tags.length > 0 || Boolean(collection) || hasActivity || hasArchiveScope;
|
|
3466
3559
|
const activeFiltersLabel = useUiLabel("activeFilters");
|
|
3467
3560
|
const showActiveFiltersLabel = useUiLabelVisibility("activeFilters");
|
|
3468
3561
|
const clearAllLabel = useUiLabel("clearAllFilters");
|
|
3469
3562
|
const clearLabel = useUiLabel("clearFilters");
|
|
3470
3563
|
const removeLabel = useUiLabel("removeFilter");
|
|
3564
|
+
const uncategorizedLabel = useUiLabel("uncategorized");
|
|
3565
|
+
const collectionItemLabel = useUiLabel("collectionItem");
|
|
3566
|
+
const collectionItemsLabel = useUiLabel("collectionItems");
|
|
3567
|
+
const collectionLabel = providedCollectionLabel ?? (collection === "__uncategorized__" ? uncategorizedLabel : collection);
|
|
3568
|
+
const archiveLabels = {
|
|
3569
|
+
active: useUiLabel("archiveScopeActive"),
|
|
3570
|
+
archived: useUiLabel("archiveScopeArchived"),
|
|
3571
|
+
all: useUiLabel("archiveScopeAll")
|
|
3572
|
+
};
|
|
3573
|
+
const activityLabels = {
|
|
3574
|
+
neverOpened: useUiLabel("activityNeverOpened"),
|
|
3575
|
+
opened: useUiLabel("activityOpened"),
|
|
3576
|
+
inactiveFor: useUiLabel("activityInactiveFor"),
|
|
3577
|
+
before: useUiLabel("activityBefore"),
|
|
3578
|
+
after: useUiLabel("activityAfter")
|
|
3579
|
+
};
|
|
3580
|
+
const { locale } = useKeepUiLabels();
|
|
3581
|
+
const resolvedActivityLabel = providedActivityLabel ?? formatActivity(activity, activityLabels, locale);
|
|
3582
|
+
const resolvedArchiveScopeLabel = providedArchiveScopeLabel ?? (archiveScope === void 0 ? void 0 : archiveLabels[archiveScope]);
|
|
3471
3583
|
const chipRefs = useRef6([]);
|
|
3472
|
-
const
|
|
3584
|
+
const collectionIndex = Number(Boolean(search)) + tags.length;
|
|
3585
|
+
const activityIndex = collectionIndex + Number(Boolean(collection));
|
|
3586
|
+
const archiveScopeIndex = activityIndex + Number(hasActivity);
|
|
3587
|
+
const filterCount = archiveScopeIndex + Number(hasArchiveScope);
|
|
3473
3588
|
function focusChip(index) {
|
|
3474
3589
|
chipRefs.current[index]?.focus();
|
|
3475
3590
|
}
|
|
@@ -3500,13 +3615,32 @@ function KeepActiveFiltersSummary({
|
|
|
3500
3615
|
focusAfterRemoval(index, event.currentTarget);
|
|
3501
3616
|
onTagChange?.(tag);
|
|
3502
3617
|
}
|
|
3618
|
+
function removeCollection(event) {
|
|
3619
|
+
focusAfterRemoval(collectionIndex, event.currentTarget);
|
|
3620
|
+
onCollectionChange?.(void 0);
|
|
3621
|
+
}
|
|
3622
|
+
function removeActivity(event) {
|
|
3623
|
+
focusAfterRemoval(activityIndex, event.currentTarget);
|
|
3624
|
+
onActivityChange?.(void 0);
|
|
3625
|
+
}
|
|
3626
|
+
function removeArchiveScope(event) {
|
|
3627
|
+
focusAfterRemoval(archiveScopeIndex, event.currentTarget);
|
|
3628
|
+
onArchiveScopeChange?.("active");
|
|
3629
|
+
}
|
|
3503
3630
|
const state = {
|
|
3504
3631
|
search,
|
|
3505
3632
|
tags,
|
|
3633
|
+
collection,
|
|
3634
|
+
activity,
|
|
3635
|
+
archiveScope,
|
|
3636
|
+
totalCount,
|
|
3506
3637
|
hasFilters,
|
|
3507
3638
|
clear: () => onClear?.(),
|
|
3508
3639
|
removeSearch: () => onSearchChange?.(""),
|
|
3509
|
-
removeTag: (tag) => onTagChange?.(tag)
|
|
3640
|
+
removeTag: (tag) => onTagChange?.(tag),
|
|
3641
|
+
removeCollection: () => onCollectionChange?.(void 0),
|
|
3642
|
+
removeActivity: () => onActivityChange?.(void 0),
|
|
3643
|
+
removeArchiveScope: () => onArchiveScopeChange?.("active")
|
|
3510
3644
|
};
|
|
3511
3645
|
const contentChildren = asChild && isElement(children) ? void 0 : children;
|
|
3512
3646
|
const body = typeof contentChildren === "function" ? contentChildren(state) : contentChildren ?? (hasFilters ? /* @__PURE__ */ jsxs8(Fragment6, { children: [
|
|
@@ -3545,8 +3679,64 @@ function KeepActiveFiltersSummary({
|
|
|
3545
3679
|
children: "\xD7"
|
|
3546
3680
|
}
|
|
3547
3681
|
)
|
|
3548
|
-
] }, tag))
|
|
3682
|
+
] }, tag)),
|
|
3683
|
+
collection && collectionLabel ? /* @__PURE__ */ jsxs8("li", { "data-filter-kind": "collection", children: [
|
|
3684
|
+
/* @__PURE__ */ jsx10("span", { "data-filter-value": "true", children: collectionLabel }),
|
|
3685
|
+
/* @__PURE__ */ jsx10(
|
|
3686
|
+
"button",
|
|
3687
|
+
{
|
|
3688
|
+
type: "button",
|
|
3689
|
+
"data-keep-action": "remove-collection-filter",
|
|
3690
|
+
"aria-label": `${collectionLabel} ${removeLabel}`,
|
|
3691
|
+
ref: (element) => {
|
|
3692
|
+
chipRefs.current[collectionIndex] = element;
|
|
3693
|
+
},
|
|
3694
|
+
onKeyDown: (event) => handleChipKeyDown(event, collectionIndex),
|
|
3695
|
+
onClick: removeCollection,
|
|
3696
|
+
children: "\xD7"
|
|
3697
|
+
}
|
|
3698
|
+
)
|
|
3699
|
+
] }) : null,
|
|
3700
|
+
hasActivity ? /* @__PURE__ */ jsxs8("li", { "data-filter-kind": "activity", children: [
|
|
3701
|
+
/* @__PURE__ */ jsx10("span", { "data-filter-value": "true", children: resolvedActivityLabel }),
|
|
3702
|
+
/* @__PURE__ */ jsx10(
|
|
3703
|
+
"button",
|
|
3704
|
+
{
|
|
3705
|
+
type: "button",
|
|
3706
|
+
"data-keep-action": "remove-activity-filter",
|
|
3707
|
+
"aria-label": `${resolvedActivityLabel} ${removeLabel}`,
|
|
3708
|
+
ref: (element) => {
|
|
3709
|
+
chipRefs.current[activityIndex] = element;
|
|
3710
|
+
},
|
|
3711
|
+
onKeyDown: (event) => handleChipKeyDown(event, activityIndex),
|
|
3712
|
+
onClick: removeActivity,
|
|
3713
|
+
children: "\xD7"
|
|
3714
|
+
}
|
|
3715
|
+
)
|
|
3716
|
+
] }) : null,
|
|
3717
|
+
hasArchiveScope && resolvedArchiveScopeLabel ? /* @__PURE__ */ jsxs8("li", { "data-filter-kind": "archive-scope", children: [
|
|
3718
|
+
/* @__PURE__ */ jsx10("span", { "data-filter-value": "true", children: resolvedArchiveScopeLabel }),
|
|
3719
|
+
/* @__PURE__ */ jsx10(
|
|
3720
|
+
"button",
|
|
3721
|
+
{
|
|
3722
|
+
type: "button",
|
|
3723
|
+
"data-keep-action": "remove-archive-scope-filter",
|
|
3724
|
+
"aria-label": `${resolvedArchiveScopeLabel} ${removeLabel}`,
|
|
3725
|
+
ref: (element) => {
|
|
3726
|
+
chipRefs.current[archiveScopeIndex] = element;
|
|
3727
|
+
},
|
|
3728
|
+
onKeyDown: (event) => handleChipKeyDown(event, archiveScopeIndex),
|
|
3729
|
+
onClick: removeArchiveScope,
|
|
3730
|
+
children: "\xD7"
|
|
3731
|
+
}
|
|
3732
|
+
)
|
|
3733
|
+
] }) : null
|
|
3549
3734
|
] }),
|
|
3735
|
+
totalCount !== void 0 ? /* @__PURE__ */ jsxs8("span", { "data-filter-count": "true", children: [
|
|
3736
|
+
totalCount,
|
|
3737
|
+
" ",
|
|
3738
|
+
totalCount === 1 ? collectionItemLabel : collectionItemsLabel
|
|
3739
|
+
] }) : null,
|
|
3550
3740
|
/* @__PURE__ */ jsx10("button", { type: "button", "data-keep-action": "clear-filters", onClick: state.clear, children: clearAllLabel || clearLabel })
|
|
3551
3741
|
] }) : null);
|
|
3552
3742
|
if (!hasFilters && !asChild && contentChildren === void 0) return null;
|
|
@@ -3564,8 +3754,21 @@ function KeepActiveFiltersSummary({
|
|
|
3564
3754
|
"KeepActiveFiltersSummary"
|
|
3565
3755
|
);
|
|
3566
3756
|
}
|
|
3567
|
-
function
|
|
3568
|
-
|
|
3757
|
+
function formatActivity(activity, labels, locale) {
|
|
3758
|
+
if (!activity || Object.keys(activity).length === 0) return void 0;
|
|
3759
|
+
if (activity.opened === "never") return labels.neverOpened;
|
|
3760
|
+
if (activity.opened === "ever") return labels.opened;
|
|
3761
|
+
if (activity.inactiveForMs !== void 0) {
|
|
3762
|
+
const days = Math.max(1, Math.round(activity.inactiveForMs / (24 * 60 * 60 * 1e3)));
|
|
3763
|
+
return `${days}${locale?.toLowerCase().startsWith("ja") ? "" : " "}${labels.inactiveFor}`;
|
|
3764
|
+
}
|
|
3765
|
+
if (activity.lastOpenedBefore !== void 0) {
|
|
3766
|
+
return `${labels.before} ${new Date(activity.lastOpenedBefore).toLocaleDateString(locale)}`;
|
|
3767
|
+
}
|
|
3768
|
+
if (activity.lastOpenedAfter !== void 0) {
|
|
3769
|
+
return `${labels.after} ${new Date(activity.lastOpenedAfter).toLocaleDateString(locale)}`;
|
|
3770
|
+
}
|
|
3771
|
+
return void 0;
|
|
3569
3772
|
}
|
|
3570
3773
|
function isElement(value) {
|
|
3571
3774
|
return isValidElement2(value);
|
|
@@ -4014,7 +4217,7 @@ function KeepPagination({
|
|
|
4014
4217
|
|
|
4015
4218
|
// src/features/collection/hooks/useKeepCollection.ts
|
|
4016
4219
|
import { useKeepList as useKeepList3 } from "@keepkit/core/react";
|
|
4017
|
-
import { useEffect as useEffect7, useMemo as useMemo4, useState as useState10 } from "react";
|
|
4220
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo4, useState as useState10 } from "react";
|
|
4018
4221
|
function useKeepCollection({
|
|
4019
4222
|
query,
|
|
4020
4223
|
pageSize,
|
|
@@ -4040,6 +4243,7 @@ function useKeepCollection({
|
|
|
4040
4243
|
const [sort, setSort] = useState10(query.sort ?? { by: "updatedAt", direction: "desc" });
|
|
4041
4244
|
const [activeTags, setActiveTags] = useState10(query.tags ?? []);
|
|
4042
4245
|
const [activeCollection, setActiveCollection] = useState10(query.collectionId);
|
|
4246
|
+
const [activeActivity, setActiveActivity] = useState10(query.activity);
|
|
4043
4247
|
const [page, setPage] = useState10(query.pagination?.page ?? 1);
|
|
4044
4248
|
const [activeArchiveScope, setActiveArchiveScope] = useState10(
|
|
4045
4249
|
archiveScope ?? query.archiveScope ?? scopeFromArchived(query.archived)
|
|
@@ -4051,6 +4255,7 @@ function useKeepCollection({
|
|
|
4051
4255
|
const resolvedQuery = useMemo4(
|
|
4052
4256
|
() => ({
|
|
4053
4257
|
...query,
|
|
4258
|
+
activity: activeActivity,
|
|
4054
4259
|
archiveScope: activeArchiveScope,
|
|
4055
4260
|
archived: activeArchiveScope === "active" ? false : activeArchiveScope === "archived" ? true : void 0,
|
|
4056
4261
|
search: enabled.search ? { ...query.search, query: searchValue } : query.search,
|
|
@@ -4062,6 +4267,7 @@ function useKeepCollection({
|
|
|
4062
4267
|
}),
|
|
4063
4268
|
[
|
|
4064
4269
|
activeCollection,
|
|
4270
|
+
activeActivity,
|
|
4065
4271
|
activeTags,
|
|
4066
4272
|
enabled.pagination,
|
|
4067
4273
|
enabled.search,
|
|
@@ -4083,6 +4289,7 @@ function useKeepCollection({
|
|
|
4083
4289
|
setSort(next.sort ?? { by: "updatedAt", direction: "desc" });
|
|
4084
4290
|
setActiveTags(next.tags ?? []);
|
|
4085
4291
|
setActiveCollection(next.collectionId);
|
|
4292
|
+
setActiveActivity(next.activity);
|
|
4086
4293
|
setActiveArchiveScope(next.archiveScope ?? scopeFromArchived(next.archived));
|
|
4087
4294
|
setPage(next.pagination?.page ?? 1);
|
|
4088
4295
|
},
|
|
@@ -4091,12 +4298,33 @@ function useKeepCollection({
|
|
|
4091
4298
|
});
|
|
4092
4299
|
const list = useKeepList3(resolvedQuery);
|
|
4093
4300
|
const allState = useKeepList3({ archiveScope: "all" });
|
|
4301
|
+
const reveal = useCallback5(
|
|
4302
|
+
(itemId) => {
|
|
4303
|
+
const target = allState.items.find((item) => item.id === itemId);
|
|
4304
|
+
if (!target) return "not-found";
|
|
4305
|
+
if (query.targetType !== void 0 && target.targetType !== query.targetType) return "excluded";
|
|
4306
|
+
if (query.filter && !query.filter(target)) return "excluded";
|
|
4307
|
+
const candidates = allState.items.filter(
|
|
4308
|
+
(item) => (query.targetType === void 0 || item.targetType === query.targetType) && (!query.filter || query.filter(item))
|
|
4309
|
+
).filter((item) => target.archived === true ? item.archived === true : item.archived !== true).sort((a, b) => compareItems(a, b, sort, query.pinnedFirst));
|
|
4310
|
+
const index = candidates.findIndex((item) => item.id === itemId);
|
|
4311
|
+
if (index < 0) return "excluded";
|
|
4312
|
+
setSearchValue("");
|
|
4313
|
+
setActiveTags([]);
|
|
4314
|
+
setActiveCollection(void 0);
|
|
4315
|
+
setActiveArchiveScope(target.archived === true ? "archived" : "active");
|
|
4316
|
+
setPage(Math.floor(index / resolvedPageSize) + 1);
|
|
4317
|
+
return "visible";
|
|
4318
|
+
},
|
|
4319
|
+
[allState.items, query, resolvedPageSize, sort]
|
|
4320
|
+
);
|
|
4094
4321
|
return {
|
|
4095
4322
|
enabled,
|
|
4096
4323
|
searchValue,
|
|
4097
4324
|
sortValue: sortToValue(sort),
|
|
4098
4325
|
activeTags,
|
|
4099
4326
|
activeCollection,
|
|
4327
|
+
activity: activeActivity,
|
|
4100
4328
|
archiveScope: activeArchiveScope,
|
|
4101
4329
|
resolvedPageSize,
|
|
4102
4330
|
resolvedQuery,
|
|
@@ -4118,6 +4346,10 @@ function useKeepCollection({
|
|
|
4118
4346
|
setActiveCollection(value);
|
|
4119
4347
|
setPage(1);
|
|
4120
4348
|
},
|
|
4349
|
+
setActivity: (value) => {
|
|
4350
|
+
setActiveActivity(value);
|
|
4351
|
+
setPage(1);
|
|
4352
|
+
},
|
|
4121
4353
|
setArchiveScope: (value) => {
|
|
4122
4354
|
setActiveArchiveScope(value);
|
|
4123
4355
|
setPage(1);
|
|
@@ -4127,14 +4359,27 @@ function useKeepCollection({
|
|
|
4127
4359
|
setPage(1);
|
|
4128
4360
|
},
|
|
4129
4361
|
clearFilters: () => {
|
|
4130
|
-
setSearchValue("");
|
|
4131
|
-
setActiveTags([]);
|
|
4132
|
-
setActiveCollection(
|
|
4133
|
-
|
|
4362
|
+
setSearchValue(query.search?.query ?? "");
|
|
4363
|
+
setActiveTags(query.tags ?? []);
|
|
4364
|
+
setActiveCollection(query.collectionId);
|
|
4365
|
+
setActiveActivity(query.activity);
|
|
4366
|
+
setActiveArchiveScope(archiveScope ?? query.archiveScope ?? scopeFromArchived(query.archived));
|
|
4367
|
+
setPage(query.pagination?.page ?? 1);
|
|
4134
4368
|
},
|
|
4135
|
-
setPage
|
|
4369
|
+
setPage,
|
|
4370
|
+
reveal
|
|
4136
4371
|
};
|
|
4137
4372
|
}
|
|
4373
|
+
function compareItems(a, b, sort, pinnedFirst) {
|
|
4374
|
+
if (pinnedFirst && a.pinned !== b.pinned) return a.pinned === true ? -1 : 1;
|
|
4375
|
+
const aValue = sort.by === "savedAt" ? a.savedAt : sort.by === "updatedAt" ? a.updatedAt : a.lastOpenedAt;
|
|
4376
|
+
const bValue = sort.by === "savedAt" ? b.savedAt : sort.by === "updatedAt" ? b.updatedAt : b.lastOpenedAt;
|
|
4377
|
+
const direction = sort.direction === "asc" ? 1 : -1;
|
|
4378
|
+
if (aValue === void 0 && bValue === void 0) return 0;
|
|
4379
|
+
if (aValue === void 0) return 1;
|
|
4380
|
+
if (bValue === void 0) return -1;
|
|
4381
|
+
return (aValue - bValue) * direction;
|
|
4382
|
+
}
|
|
4138
4383
|
function scopeFromArchived(archived) {
|
|
4139
4384
|
return archived === true ? "archived" : "active";
|
|
4140
4385
|
}
|
|
@@ -4184,7 +4429,7 @@ function KeepCollectionCreate({
|
|
|
4184
4429
|
setName("");
|
|
4185
4430
|
onCreated?.(normalizedId);
|
|
4186
4431
|
} catch (cause) {
|
|
4187
|
-
const message = cause
|
|
4432
|
+
const message = getErrorMessage(cause, "Failed to create collection.");
|
|
4188
4433
|
setError(message);
|
|
4189
4434
|
onError?.(cause);
|
|
4190
4435
|
} finally {
|
|
@@ -4476,7 +4721,7 @@ function KeepStaleNotice({
|
|
|
4476
4721
|
}
|
|
4477
4722
|
)
|
|
4478
4723
|
] }),
|
|
4479
|
-
view.error ? /* @__PURE__ */ jsx17("p", { role: "alert", children: view.error
|
|
4724
|
+
view.error ? /* @__PURE__ */ jsx17("p", { role: "alert", children: getErrorMessage(view.error, view.labels.error) }) : null
|
|
4480
4725
|
] });
|
|
4481
4726
|
}
|
|
4482
4727
|
function KeepPruneStaleButton({
|
|
@@ -4640,6 +4885,7 @@ function KeepItemCardRoot({
|
|
|
4640
4885
|
asChild = false,
|
|
4641
4886
|
href: hrefOption,
|
|
4642
4887
|
onOpen,
|
|
4888
|
+
trackOpen = false,
|
|
4643
4889
|
linkTarget = "title",
|
|
4644
4890
|
linkComponent: LinkComponent,
|
|
4645
4891
|
linkTargetAttribute,
|
|
@@ -4679,7 +4925,10 @@ function KeepItemCardRoot({
|
|
|
4679
4925
|
href: view.href,
|
|
4680
4926
|
target: view.resolvedLinkTarget,
|
|
4681
4927
|
rel: view.resolvedLinkRel,
|
|
4682
|
-
onClick: (event) =>
|
|
4928
|
+
onClick: (event) => {
|
|
4929
|
+
if (trackOpen) void view.itemState.recordOpen();
|
|
4930
|
+
onOpen?.(item, event);
|
|
4931
|
+
},
|
|
4683
4932
|
children: content
|
|
4684
4933
|
};
|
|
4685
4934
|
return LinkComponent ? /* @__PURE__ */ jsx18(LinkComponent, { ...linkProps }) : /* @__PURE__ */ jsx18("a", { ...linkProps });
|
|
@@ -4722,7 +4971,7 @@ function KeepItemCardRoot({
|
|
|
4722
4971
|
showSavedAtLabel ? " " : null,
|
|
4723
4972
|
/* @__PURE__ */ jsx18("time", { dateTime: new Date(item.savedAt).toISOString(), children: formatSavedAt(item.savedAt) })
|
|
4724
4973
|
] }) : null;
|
|
4725
|
-
const error = view.itemState.error ? /* @__PURE__ */ jsx18("p", { role: "alert", children:
|
|
4974
|
+
const error = view.itemState.error ? /* @__PURE__ */ jsx18("p", { role: "alert", children: getErrorMessage(view.itemState.error, view.labels.error) }) : null;
|
|
4726
4975
|
const actions = view.statusLabel ? /* @__PURE__ */ jsx18(KeepStaleNotice, { item, onRetry, onRemoved }) : /* @__PURE__ */ jsxs16(Fragment9, { children: [
|
|
4727
4976
|
showEditButton ? isEditOpen ? /* @__PURE__ */ jsx18("div", { id: editPanelId, role: "dialog", "aria-label": editLabel, "data-keepkit": "item-edit-dialog", children: editSlot ? editSlot(item, closeEdit) : /* @__PURE__ */ jsx18(KeepQuickEditor, { item: view.itemState.item ?? item, onClose: closeEdit, features: editFeatures }) }) : /* @__PURE__ */ jsx18(
|
|
4728
4977
|
"button",
|
|
@@ -4917,9 +5166,6 @@ function KeepItemCardSkeleton({ layout = "list", ...props }) {
|
|
|
4917
5166
|
function formatSavedAt(timestamp) {
|
|
4918
5167
|
return new Date(timestamp).toISOString().slice(0, 10);
|
|
4919
5168
|
}
|
|
4920
|
-
function getErrorMessage3(error, fallback) {
|
|
4921
|
-
return error instanceof Error ? error.message : fallback;
|
|
4922
|
-
}
|
|
4923
5169
|
|
|
4924
5170
|
// src/features/status/KeepEmptyState.tsx
|
|
4925
5171
|
import { isValidElement as isValidElement5 } from "react";
|
|
@@ -4971,17 +5217,17 @@ function useKeepListView(query) {
|
|
|
4971
5217
|
}
|
|
4972
5218
|
|
|
4973
5219
|
// src/features/collection/hooks/useRovingTabIndex.ts
|
|
4974
|
-
import { useCallback as
|
|
5220
|
+
import { useCallback as useCallback6, useEffect as useEffect9, useRef as useRef8 } from "react";
|
|
4975
5221
|
function useRovingTabIndex() {
|
|
4976
5222
|
const ref = useRef8(null);
|
|
4977
|
-
const getItems =
|
|
5223
|
+
const getItems = useCallback6(() => {
|
|
4978
5224
|
const root = ref.current;
|
|
4979
5225
|
if (!root) return [];
|
|
4980
5226
|
return Array.from(root.querySelectorAll('[data-keepkit="card"]')).filter(
|
|
4981
5227
|
(item) => item.getAttribute("aria-hidden") !== "true" && item.getAttribute("data-roving-disabled") !== "true"
|
|
4982
5228
|
);
|
|
4983
5229
|
}, []);
|
|
4984
|
-
const syncTabIndices =
|
|
5230
|
+
const syncTabIndices = useCallback6(() => {
|
|
4985
5231
|
const items = getItems();
|
|
4986
5232
|
if (items.length === 0) return;
|
|
4987
5233
|
const activeElement = document.activeElement;
|
|
@@ -4999,7 +5245,7 @@ function useRovingTabIndex() {
|
|
|
4999
5245
|
observer.observe(root, { childList: true, subtree: true });
|
|
5000
5246
|
return () => observer.disconnect();
|
|
5001
5247
|
}, [syncTabIndices]);
|
|
5002
|
-
const onFocusCapture =
|
|
5248
|
+
const onFocusCapture = useCallback6(
|
|
5003
5249
|
(event) => {
|
|
5004
5250
|
if (!(event.target instanceof HTMLElement)) return;
|
|
5005
5251
|
const item = event.target.closest('[data-keepkit="card"]');
|
|
@@ -5010,7 +5256,7 @@ function useRovingTabIndex() {
|
|
|
5010
5256
|
},
|
|
5011
5257
|
[getItems]
|
|
5012
5258
|
);
|
|
5013
|
-
const onKeyDown =
|
|
5259
|
+
const onKeyDown = useCallback6(
|
|
5014
5260
|
(event) => {
|
|
5015
5261
|
if (event.defaultPrevented) return;
|
|
5016
5262
|
const items = getItems();
|
|
@@ -5276,7 +5522,7 @@ function getListBody(state, options) {
|
|
|
5276
5522
|
function hasActiveQueryFilters(query) {
|
|
5277
5523
|
if (!query) return false;
|
|
5278
5524
|
return Boolean(
|
|
5279
|
-
query.search?.query?.trim() || query.tags?.some((tag) => tag.trim()) || query.targetType || query.savedBetween || query.archiveScope !== void 0 && query.archiveScope !== "active" || query.collectionId || query.filter
|
|
5525
|
+
query.search?.query?.trim() || query.tags?.some((tag) => tag.trim()) || query.targetType || query.savedBetween || query.archiveScope !== void 0 && query.archiveScope !== "active" || query.collectionId || query.activity || query.filter
|
|
5280
5526
|
);
|
|
5281
5527
|
}
|
|
5282
5528
|
|
|
@@ -5312,10 +5558,19 @@ function KeepCollectionContent({
|
|
|
5312
5558
|
activeFilters,
|
|
5313
5559
|
empty,
|
|
5314
5560
|
error,
|
|
5561
|
+
revealRequest,
|
|
5562
|
+
onRevealResult,
|
|
5315
5563
|
className,
|
|
5316
5564
|
...rootProps
|
|
5317
5565
|
}) {
|
|
5318
5566
|
const view = useKeepCollection({ query, pageSize, urlSync, urlAdapter, features, archiveScope });
|
|
5567
|
+
const revealRequestId = useRef9(void 0);
|
|
5568
|
+
useEffect10(() => {
|
|
5569
|
+
if (!revealRequest || revealRequestId.current === revealRequest.requestId) return;
|
|
5570
|
+
revealRequestId.current = revealRequest.requestId;
|
|
5571
|
+
const status = view.reveal(revealRequest.itemId);
|
|
5572
|
+
onRevealResult?.({ ...revealRequest, status });
|
|
5573
|
+
}, [onRevealResult, revealRequest, view.reveal]);
|
|
5319
5574
|
const [reorderUndoIds, setReorderUndoIds] = useState15(null);
|
|
5320
5575
|
const reorderUndoLabel = useUiLabel("undoReorder");
|
|
5321
5576
|
const handleReorder = async (orderedIds) => {
|
|
@@ -5381,6 +5636,8 @@ function KeepCollectionContent({
|
|
|
5381
5636
|
const toolbarQueryLabel = useUiLabel("toolbarQuery");
|
|
5382
5637
|
const toolbarFiltersLabel = useUiLabel("toolbarFilters");
|
|
5383
5638
|
const toolbarEndLabel = useUiLabel("toolbarEnd");
|
|
5639
|
+
const uncategorizedLabel = useUiLabel("uncategorized");
|
|
5640
|
+
const activeCollectionLabel = view.activeCollection === "__uncategorized__" ? uncategorizedLabel : view.activeCollection === void 0 ? void 0 : collectionLabels?.[view.activeCollection] ?? view.activeCollection;
|
|
5384
5641
|
const toolbarStartContent = slots?.toolbarStart === void 0 ? null : resolveContent(slots.toolbarStart, view.list);
|
|
5385
5642
|
const creatableContent = creatable ? /* @__PURE__ */ jsx22(KeepCollectionCreate, {}) : null;
|
|
5386
5643
|
const toolbarEndContent = creatableContent ?? (slots?.toolbarEnd === void 0 ? null : resolveContent(slots.toolbarEnd, view.list));
|
|
@@ -5430,8 +5687,19 @@ function KeepCollectionContent({
|
|
|
5430
5687
|
{
|
|
5431
5688
|
search: view.searchValue,
|
|
5432
5689
|
tags: view.activeTags,
|
|
5690
|
+
collection: view.activeCollection,
|
|
5691
|
+
collectionLabel: activeCollectionLabel,
|
|
5692
|
+
activity: view.activity,
|
|
5693
|
+
archiveScope: view.archiveScope,
|
|
5694
|
+
totalCount: view.list.totalCount,
|
|
5433
5695
|
onSearchChange: view.setSearchValue,
|
|
5434
5696
|
onTagChange: view.removeTag,
|
|
5697
|
+
onCollectionChange: view.setCollection,
|
|
5698
|
+
onActivityChange: view.setActivity,
|
|
5699
|
+
onArchiveScopeChange: (next) => {
|
|
5700
|
+
view.setArchiveScope(next);
|
|
5701
|
+
onArchiveScopeChange?.(next);
|
|
5702
|
+
},
|
|
5435
5703
|
onClear: view.clearFilters
|
|
5436
5704
|
}
|
|
5437
5705
|
) : resolveContent(activeFilters, view.list),
|
|
@@ -5479,7 +5747,7 @@ import { useId as useId5 } from "react";
|
|
|
5479
5747
|
|
|
5480
5748
|
// src/features/collection/hooks/useKeepCollectionManager.ts
|
|
5481
5749
|
import { useKeepCollections as useKeepCollections4, useKeepContext as useKeepContext6 } from "@keepkit/core/react";
|
|
5482
|
-
import { useCallback as
|
|
5750
|
+
import { useCallback as useCallback7, useState as useState16 } from "react";
|
|
5483
5751
|
function useKeepCollectionManager({
|
|
5484
5752
|
onError,
|
|
5485
5753
|
onRenamed,
|
|
@@ -5499,7 +5767,7 @@ function useKeepCollectionManager({
|
|
|
5499
5767
|
const [pendingDeleteId, setPendingDeleteId] = useState16(null);
|
|
5500
5768
|
const [error, setError] = useState16(null);
|
|
5501
5769
|
const [isMutating, setIsMutating] = useState16(false);
|
|
5502
|
-
const reportError =
|
|
5770
|
+
const reportError = useCallback7(
|
|
5503
5771
|
(cause, fallback) => {
|
|
5504
5772
|
const message = cause instanceof Error ? cause.message : fallback;
|
|
5505
5773
|
setError(message);
|
|
@@ -5507,7 +5775,7 @@ function useKeepCollectionManager({
|
|
|
5507
5775
|
},
|
|
5508
5776
|
[onError]
|
|
5509
5777
|
);
|
|
5510
|
-
const runMutation =
|
|
5778
|
+
const runMutation = useCallback7(
|
|
5511
5779
|
async (operation) => {
|
|
5512
5780
|
setError(null);
|
|
5513
5781
|
setIsMutating(true);
|
|
@@ -5521,7 +5789,7 @@ function useKeepCollectionManager({
|
|
|
5521
5789
|
},
|
|
5522
5790
|
[reportError]
|
|
5523
5791
|
);
|
|
5524
|
-
const beginRename =
|
|
5792
|
+
const beginRename = useCallback7(
|
|
5525
5793
|
(id) => {
|
|
5526
5794
|
const collection = collections.find((entry) => entry.id === id);
|
|
5527
5795
|
if (!collection) return;
|
|
@@ -5532,11 +5800,11 @@ function useKeepCollectionManager({
|
|
|
5532
5800
|
},
|
|
5533
5801
|
[collections]
|
|
5534
5802
|
);
|
|
5535
|
-
const cancelRename =
|
|
5803
|
+
const cancelRename = useCallback7(() => {
|
|
5536
5804
|
setEditingId(null);
|
|
5537
5805
|
setEditingName("");
|
|
5538
5806
|
}, []);
|
|
5539
|
-
const rename =
|
|
5807
|
+
const rename = useCallback7(
|
|
5540
5808
|
async (id) => {
|
|
5541
5809
|
const name = editingName.trim();
|
|
5542
5810
|
if (!name) return;
|
|
@@ -5568,13 +5836,13 @@ function useKeepCollectionManager({
|
|
|
5568
5836
|
runMutation
|
|
5569
5837
|
]
|
|
5570
5838
|
);
|
|
5571
|
-
const requestDelete =
|
|
5839
|
+
const requestDelete = useCallback7((id) => {
|
|
5572
5840
|
setError(null);
|
|
5573
5841
|
setEditingId(null);
|
|
5574
5842
|
setPendingDeleteId(id);
|
|
5575
5843
|
}, []);
|
|
5576
|
-
const cancelDelete =
|
|
5577
|
-
const confirmDelete =
|
|
5844
|
+
const cancelDelete = useCallback7(() => setPendingDeleteId(null), []);
|
|
5845
|
+
const confirmDelete = useCallback7(async () => {
|
|
5578
5846
|
if (!pendingDeleteId) return;
|
|
5579
5847
|
const id = pendingDeleteId;
|
|
5580
5848
|
await runMutation(async () => {
|
|
@@ -5812,16 +6080,16 @@ function KeepShortcutHint({ shortcut, separator = "+", ...props }) {
|
|
|
5812
6080
|
|
|
5813
6081
|
// src/features/editor/hooks/useKeepNoteEditor.ts
|
|
5814
6082
|
import { useKeepItem as useKeepItem6 } from "@keepkit/core/react";
|
|
5815
|
-
import { useCallback as
|
|
6083
|
+
import { useCallback as useCallback8, useEffect as useEffect11, useRef as useRef10, useState as useState17 } from "react";
|
|
5816
6084
|
function useKeepNoteEditor({ item, debounceMs, onSaved, onSaveError }) {
|
|
5817
6085
|
const itemState = useKeepItem6(item);
|
|
5818
6086
|
const { error, isMutating, item: savedItem, updateNote } = itemState;
|
|
5819
6087
|
const [note, setNote] = useState17(item.note ?? "");
|
|
5820
6088
|
const baselineNote = savedItem?.note ?? item.note ?? "";
|
|
5821
6089
|
const isDirty = note !== baselineNote;
|
|
5822
|
-
const lastSavedNoteRef =
|
|
6090
|
+
const lastSavedNoteRef = useRef10(void 0);
|
|
5823
6091
|
useEffect11(() => setNote(baselineNote), [baselineNote]);
|
|
5824
|
-
const save =
|
|
6092
|
+
const save = useCallback8(async () => {
|
|
5825
6093
|
const nextNote = note.trim() || void 0;
|
|
5826
6094
|
try {
|
|
5827
6095
|
await updateNote(nextNote);
|
|
@@ -5935,7 +6203,7 @@ function KeepNoteEditor({
|
|
|
5935
6203
|
"data-disabled": isSaving ? "true" : void 0,
|
|
5936
6204
|
children: [
|
|
5937
6205
|
body,
|
|
5938
|
-
error ? /* @__PURE__ */ jsx26("p", { role: "alert", children:
|
|
6206
|
+
error ? /* @__PURE__ */ jsx26("p", { role: "alert", children: getErrorMessage(error, view.labels.error) }) : null
|
|
5939
6207
|
]
|
|
5940
6208
|
}
|
|
5941
6209
|
);
|
|
@@ -5957,19 +6225,16 @@ function KeepNoteEditor({
|
|
|
5957
6225
|
"KeepNoteEditor"
|
|
5958
6226
|
);
|
|
5959
6227
|
}
|
|
5960
|
-
function getErrorMessage4(error, fallback) {
|
|
5961
|
-
return error instanceof Error ? error.message : fallback;
|
|
5962
|
-
}
|
|
5963
6228
|
|
|
5964
6229
|
// src/features/editor/hooks/useKeepTagEditor.ts
|
|
5965
6230
|
import { useKeepItem as useKeepItem7 } from "@keepkit/core/react";
|
|
5966
|
-
import { useCallback as
|
|
6231
|
+
import { useCallback as useCallback9, useEffect as useEffect12, useState as useState18 } from "react";
|
|
5967
6232
|
function useKeepTagEditor({ item, onSaved, onSaveError }) {
|
|
5968
6233
|
const itemState = useKeepItem7(item);
|
|
5969
6234
|
const [tags, setTags] = useState18(item.tags ?? []);
|
|
5970
6235
|
const [input, setInput] = useState18("");
|
|
5971
6236
|
useEffect12(() => setTags(itemState.item?.tags ?? item.tags ?? []), [item.tags, itemState.item?.tags]);
|
|
5972
|
-
const save =
|
|
6237
|
+
const save = useCallback9(async () => {
|
|
5973
6238
|
const nextTags = normalizeUiTags(tags);
|
|
5974
6239
|
try {
|
|
5975
6240
|
await itemState.updateTags(nextTags);
|
|
@@ -6083,19 +6348,16 @@ function KeepTagEditor({
|
|
|
6083
6348
|
"data-disabled": isSaving ? "true" : void 0,
|
|
6084
6349
|
children: [
|
|
6085
6350
|
body,
|
|
6086
|
-
view.error ? /* @__PURE__ */ jsx27("p", { role: "alert", children:
|
|
6351
|
+
view.error ? /* @__PURE__ */ jsx27("p", { role: "alert", children: getErrorMessage(view.error, view.labels.error) }) : null
|
|
6087
6352
|
]
|
|
6088
6353
|
}
|
|
6089
6354
|
);
|
|
6090
6355
|
}
|
|
6091
|
-
function getErrorMessage5(error, fallback) {
|
|
6092
|
-
return error instanceof Error ? error.message : fallback;
|
|
6093
|
-
}
|
|
6094
6356
|
|
|
6095
6357
|
// src/features/feedback/useKeepToastFeedback.ts
|
|
6096
|
-
import { useCallback as
|
|
6358
|
+
import { useCallback as useCallback10 } from "react";
|
|
6097
6359
|
function useKeepToastFeedback(showToast) {
|
|
6098
|
-
return
|
|
6360
|
+
return useCallback10(
|
|
6099
6361
|
(event) => {
|
|
6100
6362
|
if (!("undo" in event)) {
|
|
6101
6363
|
showToast(event.message);
|
|
@@ -6114,7 +6376,7 @@ function useKeepToastFeedback(showToast) {
|
|
|
6114
6376
|
|
|
6115
6377
|
// src/features/navigation/KeepFloatingTour.tsx
|
|
6116
6378
|
import { useKeepList as useKeepList6 } from "@keepkit/core/react";
|
|
6117
|
-
import { useEffect as useEffect15, useMemo as useMemo6, useRef as
|
|
6379
|
+
import { useEffect as useEffect15, useMemo as useMemo6, useRef as useRef11, useState as useState20 } from "react";
|
|
6118
6380
|
import { createPortal } from "react-dom";
|
|
6119
6381
|
|
|
6120
6382
|
// src/foundation/theme.tsx
|
|
@@ -6387,7 +6649,7 @@ function navigateTo(item, href) {
|
|
|
6387
6649
|
|
|
6388
6650
|
// src/features/navigation/tour-context.tsx
|
|
6389
6651
|
import { useKeepList as useKeepList5 } from "@keepkit/core/react";
|
|
6390
|
-
import { createContext as createContext5, useCallback as
|
|
6652
|
+
import { createContext as createContext5, useCallback as useCallback11, useContext as useContext5, useEffect as useEffect14, useMemo as useMemo5, useState as useState19 } from "react";
|
|
6391
6653
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
6392
6654
|
var SESSION_VERSION = 1;
|
|
6393
6655
|
var KeepTourContext = createContext5(null);
|
|
@@ -6404,7 +6666,7 @@ function KeepTourProvider({
|
|
|
6404
6666
|
);
|
|
6405
6667
|
const [persistenceStatus, setPersistenceStatus] = useState19("persistent");
|
|
6406
6668
|
const itemsById = useMemo5(() => new Map(list.items.map((item) => [item.id, item])), [list.items]);
|
|
6407
|
-
const readStorage =
|
|
6669
|
+
const readStorage = useCallback11(() => {
|
|
6408
6670
|
try {
|
|
6409
6671
|
const raw = window.sessionStorage.getItem(sessionKey);
|
|
6410
6672
|
if (!raw) return null;
|
|
@@ -6426,7 +6688,7 @@ function KeepTourProvider({
|
|
|
6426
6688
|
return null;
|
|
6427
6689
|
}
|
|
6428
6690
|
}, [sessionKey]);
|
|
6429
|
-
const writeStorage =
|
|
6691
|
+
const writeStorage = useCallback11(
|
|
6430
6692
|
(value2) => {
|
|
6431
6693
|
try {
|
|
6432
6694
|
if (value2) window.sessionStorage.setItem(sessionKey, JSON.stringify({ version: SESSION_VERSION, ...value2 }));
|
|
@@ -6465,7 +6727,7 @@ function KeepTourProvider({
|
|
|
6465
6727
|
writeStorage(next);
|
|
6466
6728
|
}
|
|
6467
6729
|
}, [itemsById, list.error, list.isLoading, tour, writeStorage]);
|
|
6468
|
-
const start =
|
|
6730
|
+
const start = useCallback11(
|
|
6469
6731
|
(options) => {
|
|
6470
6732
|
const ids = [...options.itemIds];
|
|
6471
6733
|
if (!ids.length || new Set(ids).size !== ids.length || ids.some((id) => !itemsById.has(id))) return false;
|
|
@@ -6478,11 +6740,11 @@ function KeepTourProvider({
|
|
|
6478
6740
|
},
|
|
6479
6741
|
[itemsById, writeStorage]
|
|
6480
6742
|
);
|
|
6481
|
-
const end =
|
|
6743
|
+
const end = useCallback11(() => {
|
|
6482
6744
|
setTour(null);
|
|
6483
6745
|
writeStorage(null);
|
|
6484
6746
|
}, [writeStorage]);
|
|
6485
|
-
const setCurrentId =
|
|
6747
|
+
const setCurrentId = useCallback11(
|
|
6486
6748
|
(id) => {
|
|
6487
6749
|
setTour((current) => {
|
|
6488
6750
|
if (!current?.currentId || current.currentId === id || !current.itemIds.includes(id)) return current;
|
|
@@ -6493,7 +6755,7 @@ function KeepTourProvider({
|
|
|
6493
6755
|
},
|
|
6494
6756
|
[writeStorage]
|
|
6495
6757
|
);
|
|
6496
|
-
const move =
|
|
6758
|
+
const move = useCallback11(
|
|
6497
6759
|
(delta) => {
|
|
6498
6760
|
if (!tour?.currentId) return null;
|
|
6499
6761
|
const currentId = tour.currentId;
|
|
@@ -6564,8 +6826,8 @@ function KeepFloatingTour({
|
|
|
6564
6826
|
const collapseLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u6298\u308A\u305F\u305F\u3080" : "Collapse tour";
|
|
6565
6827
|
const expandLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u5C55\u958B" : "Expand tour";
|
|
6566
6828
|
const endLabel = labels.previousPage === "\u524D\u306E\u30DA\u30FC\u30B8" ? "\u7D42\u4E86" : "End tour";
|
|
6567
|
-
const expandRef =
|
|
6568
|
-
const collapseRef =
|
|
6829
|
+
const expandRef = useRef11(null);
|
|
6830
|
+
const collapseRef = useRef11(null);
|
|
6569
6831
|
useEffect15(() => setMounted(true), []);
|
|
6570
6832
|
useEffect15(() => {
|
|
6571
6833
|
if (!mounted || !tour.active) return;
|
|
@@ -6677,12 +6939,33 @@ function KeepFloatingTour({
|
|
|
6677
6939
|
);
|
|
6678
6940
|
}
|
|
6679
6941
|
|
|
6942
|
+
// src/features/rediscovery/KeepRediscovery.tsx
|
|
6943
|
+
import { createRediscoveryQuery } from "@keepkit/core/core";
|
|
6944
|
+
import { useMemo as useMemo7 } from "react";
|
|
6945
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
6946
|
+
function KeepRediscovery({
|
|
6947
|
+
strategy,
|
|
6948
|
+
inactiveForMs,
|
|
6949
|
+
limit = 5,
|
|
6950
|
+
itemCardProps,
|
|
6951
|
+
...props
|
|
6952
|
+
}) {
|
|
6953
|
+
const query = useMemo7(
|
|
6954
|
+
() => ({
|
|
6955
|
+
...createRediscoveryQuery({ strategy, inactiveForMs }),
|
|
6956
|
+
pagination: { page: 1, pageSize: Math.max(1, limit) }
|
|
6957
|
+
}),
|
|
6958
|
+
[inactiveForMs, limit, strategy]
|
|
6959
|
+
);
|
|
6960
|
+
return /* @__PURE__ */ jsx32(KeepList, { ...props, query, itemCardProps: { trackOpen: true, ...itemCardProps } });
|
|
6961
|
+
}
|
|
6962
|
+
|
|
6680
6963
|
// src/features/status/status.tsx
|
|
6681
6964
|
import { isValidElement as isValidElement9 } from "react";
|
|
6682
6965
|
|
|
6683
6966
|
// src/features/status/hooks/useStatusViews.ts
|
|
6684
6967
|
import { useKeepContext as useKeepContext7 } from "@keepkit/core/react";
|
|
6685
|
-
import { useEffect as useEffect16, useRef as
|
|
6968
|
+
import { useEffect as useEffect16, useRef as useRef12, useState as useState21 } from "react";
|
|
6686
6969
|
function useKeepStatus(status) {
|
|
6687
6970
|
const context = useKeepContext7();
|
|
6688
6971
|
const resolvedStatus = status ?? getDerivedStatus(context);
|
|
@@ -6700,7 +6983,7 @@ function useKeepAnnouncements(messages) {
|
|
|
6700
6983
|
const removedMessage = useUiLabel("removedMessage", messages?.remove);
|
|
6701
6984
|
const noteSavedMessage = useUiLabel("noteSavedMessage", messages?.note);
|
|
6702
6985
|
const [message, setMessage] = useState21("");
|
|
6703
|
-
const lastChangeRef =
|
|
6986
|
+
const lastChangeRef = useRef12(void 0);
|
|
6704
6987
|
useEffect16(() => {
|
|
6705
6988
|
const change = context.lastChange;
|
|
6706
6989
|
if (!change || change === lastChangeRef.current) return;
|
|
@@ -6729,7 +7012,7 @@ function getStatusLabelKey3(status) {
|
|
|
6729
7012
|
}
|
|
6730
7013
|
|
|
6731
7014
|
// src/features/status/status.tsx
|
|
6732
|
-
import { jsx as
|
|
7015
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
6733
7016
|
function KeepStatus({
|
|
6734
7017
|
status,
|
|
6735
7018
|
labels,
|
|
@@ -6761,7 +7044,7 @@ function KeepStatus({
|
|
|
6761
7044
|
}
|
|
6762
7045
|
function KeepAnnouncements({ messages, ...props }) {
|
|
6763
7046
|
const message = useKeepAnnouncements(messages);
|
|
6764
|
-
return /* @__PURE__ */
|
|
7047
|
+
return /* @__PURE__ */ jsx33(
|
|
6765
7048
|
"div",
|
|
6766
7049
|
{
|
|
6767
7050
|
...props,
|
|
@@ -6778,13 +7061,13 @@ var KeepAnnouncer = KeepAnnouncements;
|
|
|
6778
7061
|
|
|
6779
7062
|
// src/features/sync/hooks/useKeepSyncFeedback.ts
|
|
6780
7063
|
import { useKeepContext as useKeepContext8 } from "@keepkit/core/react";
|
|
6781
|
-
import { useEffect as useEffect17, useRef as
|
|
7064
|
+
import { useEffect as useEffect17, useRef as useRef13 } from "react";
|
|
6782
7065
|
function useKeepSyncFeedback() {
|
|
6783
7066
|
const { syncState } = useKeepContext8();
|
|
6784
7067
|
const emitFeedback = useKeepUiFeedback();
|
|
6785
7068
|
const completedMessage = useUiLabel("syncSynced");
|
|
6786
7069
|
const failedMessage = useUiLabel("syncFailedMessage");
|
|
6787
|
-
const previousStatus =
|
|
7070
|
+
const previousStatus = useRef13("idle");
|
|
6788
7071
|
useEffect17(() => {
|
|
6789
7072
|
const previous = previousStatus.current;
|
|
6790
7073
|
previousStatus.current = syncState.status;
|
|
@@ -6860,7 +7143,7 @@ function useKeepSyncRecoveryDialog(options) {
|
|
|
6860
7143
|
}
|
|
6861
7144
|
|
|
6862
7145
|
// src/features/sync/KeepSyncRecoveryDialog.tsx
|
|
6863
|
-
import { jsx as
|
|
7146
|
+
import { jsx as jsx34, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6864
7147
|
function KeepSyncRecoveryDialog({
|
|
6865
7148
|
open,
|
|
6866
7149
|
onOpenChange,
|
|
@@ -6890,16 +7173,16 @@ function KeepSyncRecoveryDialog({
|
|
|
6890
7173
|
"data-loading": view.busyId !== void 0 ? "true" : void 0,
|
|
6891
7174
|
children: [
|
|
6892
7175
|
/* @__PURE__ */ jsxs26("header", { children: [
|
|
6893
|
-
/* @__PURE__ */
|
|
6894
|
-
/* @__PURE__ */
|
|
7176
|
+
/* @__PURE__ */ jsx34("h2", { id: "keepkit-sync-recovery-title", children: title ?? view.labels.title }),
|
|
7177
|
+
/* @__PURE__ */ jsx34("button", { type: "button", "data-keep-action": "close-dialog", onClick: view.close, "aria-label": view.labels.close, children: view.labels.close })
|
|
6895
7178
|
] }),
|
|
6896
7179
|
children,
|
|
6897
7180
|
view.conflictList.length > 0 ? /* @__PURE__ */ jsxs26("div", { children: [
|
|
6898
|
-
/* @__PURE__ */
|
|
7181
|
+
/* @__PURE__ */ jsx34("p", { children: view.labels.conflict }),
|
|
6899
7182
|
view.conflictList.map((conflict) => /* @__PURE__ */ jsxs26("article", { "data-conflict-id": conflict.id, children: [
|
|
6900
|
-
/* @__PURE__ */
|
|
7183
|
+
/* @__PURE__ */ jsx34("h3", { children: getMetaTitle(conflict.operation.item?.meta) ?? conflict.id }),
|
|
6901
7184
|
/* @__PURE__ */ jsxs26("div", { "data-conflict-preview": true, children: [
|
|
6902
|
-
/* @__PURE__ */
|
|
7185
|
+
/* @__PURE__ */ jsx34(
|
|
6903
7186
|
ConflictPreview,
|
|
6904
7187
|
{
|
|
6905
7188
|
item: conflict.operation.item,
|
|
@@ -6909,7 +7192,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6909
7192
|
side: "local"
|
|
6910
7193
|
}
|
|
6911
7194
|
),
|
|
6912
|
-
/* @__PURE__ */
|
|
7195
|
+
/* @__PURE__ */ jsx34(
|
|
6913
7196
|
ConflictPreview,
|
|
6914
7197
|
{
|
|
6915
7198
|
item: conflict.remote,
|
|
@@ -6921,7 +7204,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6921
7204
|
)
|
|
6922
7205
|
] }),
|
|
6923
7206
|
/* @__PURE__ */ jsxs26("div", { children: [
|
|
6924
|
-
/* @__PURE__ */
|
|
7207
|
+
/* @__PURE__ */ jsx34(
|
|
6925
7208
|
"button",
|
|
6926
7209
|
{
|
|
6927
7210
|
type: "button",
|
|
@@ -6931,7 +7214,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6931
7214
|
children: view.labels.keepLocal
|
|
6932
7215
|
}
|
|
6933
7216
|
),
|
|
6934
|
-
/* @__PURE__ */
|
|
7217
|
+
/* @__PURE__ */ jsx34(
|
|
6935
7218
|
"button",
|
|
6936
7219
|
{
|
|
6937
7220
|
type: "button",
|
|
@@ -6941,7 +7224,7 @@ function KeepSyncRecoveryDialog({
|
|
|
6941
7224
|
children: view.labels.useServer
|
|
6942
7225
|
}
|
|
6943
7226
|
),
|
|
6944
|
-
/* @__PURE__ */
|
|
7227
|
+
/* @__PURE__ */ jsx34(
|
|
6945
7228
|
"button",
|
|
6946
7229
|
{
|
|
6947
7230
|
type: "button",
|
|
@@ -6955,11 +7238,11 @@ function KeepSyncRecoveryDialog({
|
|
|
6955
7238
|
] }, conflict.id))
|
|
6956
7239
|
] }) : null,
|
|
6957
7240
|
view.showBackupRecovery ? /* @__PURE__ */ jsxs26("section", { "data-recovery": "backup", children: [
|
|
6958
|
-
/* @__PURE__ */
|
|
6959
|
-
/* @__PURE__ */
|
|
6960
|
-
backup ?? (showBackupControls ? /* @__PURE__ */
|
|
7241
|
+
/* @__PURE__ */ jsx34("h3", { children: view.labels.backupRecovery }),
|
|
7242
|
+
/* @__PURE__ */ jsx34("p", { children: view.labels.backupRecoveryDescription }),
|
|
7243
|
+
backup ?? (showBackupControls ? /* @__PURE__ */ jsx34(KeepBackup, {}) : null)
|
|
6961
7244
|
] }) : null,
|
|
6962
|
-
view.error ? /* @__PURE__ */
|
|
7245
|
+
view.error ? /* @__PURE__ */ jsx34("p", { id: "keepkit-sync-recovery-error", role: "alert", "aria-live": "assertive", children: getErrorMessage(view.error, view.labels.error) }) : null
|
|
6963
7246
|
]
|
|
6964
7247
|
}
|
|
6965
7248
|
);
|
|
@@ -6972,15 +7255,15 @@ function ConflictPreview({
|
|
|
6972
7255
|
side
|
|
6973
7256
|
}) {
|
|
6974
7257
|
return /* @__PURE__ */ jsxs26("article", { "data-conflict-version": side, "aria-label": heading, children: [
|
|
6975
|
-
/* @__PURE__ */
|
|
7258
|
+
/* @__PURE__ */ jsx34("h4", { children: heading }),
|
|
6976
7259
|
/* @__PURE__ */ jsxs26("dl", { children: [
|
|
6977
7260
|
/* @__PURE__ */ jsxs26("div", { children: [
|
|
6978
|
-
/* @__PURE__ */
|
|
6979
|
-
/* @__PURE__ */
|
|
7261
|
+
/* @__PURE__ */ jsx34("dt", { children: updatedAtLabel }),
|
|
7262
|
+
/* @__PURE__ */ jsx34("dd", { children: item ? /* @__PURE__ */ jsx34("time", { dateTime: new Date(item.updatedAt).toISOString(), children: formatConflictDate(item.updatedAt) }) : "\u2014" })
|
|
6980
7263
|
] }),
|
|
6981
7264
|
/* @__PURE__ */ jsxs26("div", { children: [
|
|
6982
|
-
/* @__PURE__ */
|
|
6983
|
-
/* @__PURE__ */
|
|
7265
|
+
/* @__PURE__ */ jsx34("dt", { children: noteLabel }),
|
|
7266
|
+
/* @__PURE__ */ jsx34("dd", { children: item?.note || "\u2014" })
|
|
6984
7267
|
] })
|
|
6985
7268
|
] })
|
|
6986
7269
|
] });
|
|
@@ -6998,9 +7281,10 @@ function useKeepSyncStatusBanner({ onRetry, children }) {
|
|
|
6998
7281
|
const conflictLabel = useUiLabel("syncConflict");
|
|
6999
7282
|
const pendingLabel = useUiLabel("syncPending");
|
|
7000
7283
|
const syncedLabel = useUiLabel("syncSynced");
|
|
7284
|
+
const failedLabel = useUiLabel("syncFailedMessage");
|
|
7001
7285
|
const status = context.syncState.status;
|
|
7002
7286
|
const hasConflicts = (context.syncState.conflicts?.length ?? 0) > 0 || context.syncState.conflictIds.length > 0;
|
|
7003
|
-
const message = children ?? (status === "error" ?
|
|
7287
|
+
const message = children ?? (status === "error" ? getErrorMessage(context.syncState.error, failedLabel) : status === "conflict" || hasConflicts ? conflictLabel : status === "pending" || status === "syncing" ? pendingLabel : syncedLabel);
|
|
7004
7288
|
return {
|
|
7005
7289
|
status,
|
|
7006
7290
|
hasConflicts,
|
|
@@ -7019,12 +7303,9 @@ function useKeepSyncStatusBanner({ onRetry, children }) {
|
|
|
7019
7303
|
}
|
|
7020
7304
|
};
|
|
7021
7305
|
}
|
|
7022
|
-
function getErrorMessage6(error) {
|
|
7023
|
-
return error instanceof Error ? error.message : "Sync failed.";
|
|
7024
|
-
}
|
|
7025
7306
|
|
|
7026
7307
|
// src/features/sync/KeepSyncStatusBanner.tsx
|
|
7027
|
-
import { jsx as
|
|
7308
|
+
import { jsx as jsx35, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
7028
7309
|
function KeepSyncStatusBanner({
|
|
7029
7310
|
onRetry,
|
|
7030
7311
|
onResolveConflicts,
|
|
@@ -7046,8 +7327,8 @@ function KeepSyncStatusBanner({
|
|
|
7046
7327
|
"data-keepkit": "sync-status",
|
|
7047
7328
|
"data-state": view.status,
|
|
7048
7329
|
children: [
|
|
7049
|
-
/* @__PURE__ */
|
|
7050
|
-
view.showRetry ? /* @__PURE__ */
|
|
7330
|
+
/* @__PURE__ */ jsx35("p", { children: view.message }),
|
|
7331
|
+
view.showRetry ? /* @__PURE__ */ jsx35(
|
|
7051
7332
|
"button",
|
|
7052
7333
|
{
|
|
7053
7334
|
type: "button",
|
|
@@ -7058,7 +7339,7 @@ function KeepSyncStatusBanner({
|
|
|
7058
7339
|
children: showRetryLabel ? view.retryLabel : null
|
|
7059
7340
|
}
|
|
7060
7341
|
) : null,
|
|
7061
|
-
view.hasConflicts ? /* @__PURE__ */
|
|
7342
|
+
view.hasConflicts ? /* @__PURE__ */ jsx35(
|
|
7062
7343
|
"button",
|
|
7063
7344
|
{
|
|
7064
7345
|
type: "button",
|
|
@@ -7075,7 +7356,7 @@ function KeepSyncStatusBanner({
|
|
|
7075
7356
|
}
|
|
7076
7357
|
|
|
7077
7358
|
// src/features/workspace/hooks/useKeepWorkspace.ts
|
|
7078
|
-
import { useCallback as
|
|
7359
|
+
import { useCallback as useCallback12, useState as useState23 } from "react";
|
|
7079
7360
|
var PRESET_MODULES = {
|
|
7080
7361
|
basic: { syncStatus: false, undo: false, recovery: false, backup: false, stalePrune: false },
|
|
7081
7362
|
standard: { syncStatus: false, undo: true, recovery: false, backup: false, stalePrune: false },
|
|
@@ -7097,14 +7378,14 @@ function useKeepWorkspace({
|
|
|
7097
7378
|
}) {
|
|
7098
7379
|
const [internalRecoveryOpen, setInternalRecoveryOpen] = useState23(false);
|
|
7099
7380
|
const resolvedModules = { ...PRESET_MODULES[preset], ...modules };
|
|
7100
|
-
const setRecoveryOpen =
|
|
7381
|
+
const setRecoveryOpen = useCallback12(
|
|
7101
7382
|
(open) => {
|
|
7102
7383
|
if (recoveryOpen === void 0) setInternalRecoveryOpen(open);
|
|
7103
7384
|
onRecoveryOpenChange?.(open);
|
|
7104
7385
|
},
|
|
7105
7386
|
[onRecoveryOpenChange, recoveryOpen]
|
|
7106
7387
|
);
|
|
7107
|
-
const openRecovery =
|
|
7388
|
+
const openRecovery = useCallback12(() => {
|
|
7108
7389
|
onResolveConflicts?.();
|
|
7109
7390
|
setRecoveryOpen(true);
|
|
7110
7391
|
}, [onResolveConflicts, setRecoveryOpen]);
|
|
@@ -7119,7 +7400,7 @@ function useKeepWorkspace({
|
|
|
7119
7400
|
}
|
|
7120
7401
|
|
|
7121
7402
|
// src/features/workspace/KeepWorkspace.tsx
|
|
7122
|
-
import { jsx as
|
|
7403
|
+
import { jsx as jsx36, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
7123
7404
|
function KeepWorkspace({
|
|
7124
7405
|
preset = "standard",
|
|
7125
7406
|
modules,
|
|
@@ -7158,27 +7439,27 @@ function KeepWorkspace({
|
|
|
7158
7439
|
if (!structuredRegions) return content;
|
|
7159
7440
|
if (!hasRenderableContent(content)) return null;
|
|
7160
7441
|
const resolvedSurface = typeof surface === "string" ? surface : surface[name] ?? "plain";
|
|
7161
|
-
return /* @__PURE__ */
|
|
7442
|
+
return /* @__PURE__ */ jsx36("div", { "data-keepkit": "workspace-region", "data-region": name, "data-surface": resolvedSurface, children: content });
|
|
7162
7443
|
};
|
|
7163
7444
|
const before = resolveOptionalSlot(slots?.before, state);
|
|
7164
7445
|
const syncStatus = view.modules.syncStatus ? resolveSlot(
|
|
7165
7446
|
slots?.syncStatus,
|
|
7166
|
-
/* @__PURE__ */
|
|
7447
|
+
/* @__PURE__ */ jsx36(KeepSyncStatusBanner, { ...syncStatusProps, onResolveConflicts: view.openRecovery }),
|
|
7167
7448
|
state
|
|
7168
7449
|
) : null;
|
|
7169
|
-
const collection = resolveSlot(slots?.collection, /* @__PURE__ */
|
|
7450
|
+
const collection = resolveSlot(slots?.collection, /* @__PURE__ */ jsx36(KeepCollection, { ...resolvedCollectionProps }), state);
|
|
7170
7451
|
const actions = view.modules.backup || view.modules.stalePrune ? resolveSlot(
|
|
7171
7452
|
slots?.actions,
|
|
7172
7453
|
/* @__PURE__ */ jsxs28("div", { "data-keepkit": "workspace-actions", children: [
|
|
7173
|
-
view.modules.stalePrune ? /* @__PURE__ */
|
|
7174
|
-
view.modules.backup ? /* @__PURE__ */
|
|
7454
|
+
view.modules.stalePrune ? /* @__PURE__ */ jsx36(KeepPruneStaleButton, { ...stalePruneProps }) : null,
|
|
7455
|
+
view.modules.backup ? /* @__PURE__ */ jsx36(KeepBackup, { ...backupProps }) : null
|
|
7175
7456
|
] }),
|
|
7176
7457
|
state
|
|
7177
7458
|
) : null;
|
|
7178
|
-
const undo = view.modules.undo ? resolveSlot(slots?.undo, /* @__PURE__ */
|
|
7459
|
+
const undo = view.modules.undo ? resolveSlot(slots?.undo, /* @__PURE__ */ jsx36(KeepUndo, { ...undoProps }), state) : null;
|
|
7179
7460
|
const recovery = view.modules.recovery ? resolveSlot(
|
|
7180
7461
|
slots?.recovery,
|
|
7181
|
-
/* @__PURE__ */
|
|
7462
|
+
/* @__PURE__ */ jsx36(
|
|
7182
7463
|
KeepSyncRecoveryDialog,
|
|
7183
7464
|
{
|
|
7184
7465
|
...recoveryProps,
|
|
@@ -7231,6 +7512,7 @@ import {
|
|
|
7231
7512
|
useKeepItem as useKeepItem8,
|
|
7232
7513
|
useKeepList as useKeepList7,
|
|
7233
7514
|
useKeepNavigator as useKeepNavigator2,
|
|
7515
|
+
useKeepRediscovery,
|
|
7234
7516
|
useKeepShortcut
|
|
7235
7517
|
} from "@keepkit/core/react";
|
|
7236
7518
|
import {
|
|
@@ -7243,7 +7525,7 @@ import {
|
|
|
7243
7525
|
LocalStorageSyncQueueAdapter,
|
|
7244
7526
|
SyncStorageAdapter
|
|
7245
7527
|
} from "@keepkit/core/storage";
|
|
7246
|
-
import { jsx as
|
|
7528
|
+
import { jsx as jsx37, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
7247
7529
|
function KeepKitProvider({
|
|
7248
7530
|
labels,
|
|
7249
7531
|
labelOptions,
|
|
@@ -7265,7 +7547,7 @@ function KeepKitProvider({
|
|
|
7265
7547
|
children,
|
|
7266
7548
|
...providerProps
|
|
7267
7549
|
}) {
|
|
7268
|
-
return /* @__PURE__ */
|
|
7550
|
+
return /* @__PURE__ */ jsx37(
|
|
7269
7551
|
KeepUiProvider,
|
|
7270
7552
|
{
|
|
7271
7553
|
labels,
|
|
@@ -7273,7 +7555,7 @@ function KeepKitProvider({
|
|
|
7273
7555
|
locale,
|
|
7274
7556
|
labelResolver,
|
|
7275
7557
|
onFeedback,
|
|
7276
|
-
children: /* @__PURE__ */
|
|
7558
|
+
children: /* @__PURE__ */ jsx37(
|
|
7277
7559
|
KeepThemeProvider,
|
|
7278
7560
|
{
|
|
7279
7561
|
theme,
|
|
@@ -7288,9 +7570,9 @@ function KeepKitProvider({
|
|
|
7288
7570
|
style: themeStyle,
|
|
7289
7571
|
asChild: themeAsChild,
|
|
7290
7572
|
children: /* @__PURE__ */ jsxs29(CoreKeepProvider, { ...providerProps, children: [
|
|
7291
|
-
/* @__PURE__ */
|
|
7292
|
-
/* @__PURE__ */
|
|
7293
|
-
/* @__PURE__ */
|
|
7573
|
+
/* @__PURE__ */ jsx37(KeepSyncFeedbackObserver, {}),
|
|
7574
|
+
/* @__PURE__ */ jsx37(KeepTourProvider, { ...tour, children }),
|
|
7575
|
+
/* @__PURE__ */ jsx37(KeepAnnouncements, {})
|
|
7294
7576
|
] })
|
|
7295
7577
|
}
|
|
7296
7578
|
)
|
|
@@ -7321,7 +7603,7 @@ function createKeepKit(options = {}) {
|
|
|
7321
7603
|
} = options;
|
|
7322
7604
|
const coreKit = createCoreKeepKit(coreOptions);
|
|
7323
7605
|
return {
|
|
7324
|
-
Provider: (props) => /* @__PURE__ */
|
|
7606
|
+
Provider: (props) => /* @__PURE__ */ jsx37(
|
|
7325
7607
|
KeepKitProvider,
|
|
7326
7608
|
{
|
|
7327
7609
|
...coreOptions,
|
|
@@ -7344,9 +7626,9 @@ function createKeepKit(options = {}) {
|
|
|
7344
7626
|
...props
|
|
7345
7627
|
}
|
|
7346
7628
|
),
|
|
7347
|
-
Button: (props) => /* @__PURE__ */
|
|
7348
|
-
Backup: (props) => /* @__PURE__ */
|
|
7349
|
-
Collection: (props) => /* @__PURE__ */
|
|
7629
|
+
Button: (props) => /* @__PURE__ */ jsx37(KeepButton, { ...props }),
|
|
7630
|
+
Backup: (props) => /* @__PURE__ */ jsx37(KeepBackup, { ...props }),
|
|
7631
|
+
Collection: (props) => /* @__PURE__ */ jsx37(
|
|
7350
7632
|
KeepCollection,
|
|
7351
7633
|
{
|
|
7352
7634
|
...props,
|
|
@@ -7357,8 +7639,8 @@ function createKeepKit(options = {}) {
|
|
|
7357
7639
|
}
|
|
7358
7640
|
}
|
|
7359
7641
|
),
|
|
7360
|
-
CollectionManager: (props) => /* @__PURE__ */
|
|
7361
|
-
Workspace: (props) => /* @__PURE__ */
|
|
7642
|
+
CollectionManager: (props) => /* @__PURE__ */ jsx37(KeepCollectionManager, { ...props }),
|
|
7643
|
+
Workspace: (props) => /* @__PURE__ */ jsx37(
|
|
7362
7644
|
KeepWorkspace,
|
|
7363
7645
|
{
|
|
7364
7646
|
...props,
|
|
@@ -7375,11 +7657,12 @@ function createKeepKit(options = {}) {
|
|
|
7375
7657
|
useContext: () => coreKit.useContext(),
|
|
7376
7658
|
useItem: (item) => coreKit.useItem(item),
|
|
7377
7659
|
useList: (query) => coreKit.useList(query),
|
|
7660
|
+
useRediscovery: (rediscoveryOptions) => coreKit.useRediscovery(rediscoveryOptions),
|
|
7378
7661
|
useCollections: (collectionsOptions) => coreKit.useCollections(collectionsOptions),
|
|
7379
7662
|
useNavigator: (navigatorOptions) => coreKit.useNavigator(navigatorOptions),
|
|
7380
7663
|
useShortcut: (shortcutOptions) => coreKit.useShortcut(shortcutOptions),
|
|
7381
|
-
FloatingTour: (props) => /* @__PURE__ */
|
|
7382
|
-
TourProvider: (props) => /* @__PURE__ */
|
|
7664
|
+
FloatingTour: (props) => /* @__PURE__ */ jsx37(KeepFloatingTour, { ...props }),
|
|
7665
|
+
TourProvider: (props) => /* @__PURE__ */ jsx37(KeepTourProvider, { ...props }),
|
|
7383
7666
|
useTour: (tourOptions) => useKeepTour(tourOptions)
|
|
7384
7667
|
};
|
|
7385
7668
|
}
|
|
@@ -7418,6 +7701,7 @@ export {
|
|
|
7418
7701
|
KeepProvider,
|
|
7419
7702
|
KeepPruneStaleButton,
|
|
7420
7703
|
KeepQuickEditor,
|
|
7704
|
+
KeepRediscovery,
|
|
7421
7705
|
KeepReorderableList,
|
|
7422
7706
|
KeepSavePopover,
|
|
7423
7707
|
KeepSearchInput,
|
|
@@ -7458,6 +7742,7 @@ export {
|
|
|
7458
7742
|
useKeepList7 as useKeepList,
|
|
7459
7743
|
useKeepNavigator2 as useKeepNavigator,
|
|
7460
7744
|
useKeepQuickEditor,
|
|
7745
|
+
useKeepRediscovery,
|
|
7461
7746
|
useKeepShortcut,
|
|
7462
7747
|
useKeepToastFeedback,
|
|
7463
7748
|
useKeepTour,
|