rita-workspace 0.5.43 → 0.5.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1767,6 +1767,20 @@ var DrawingsDialog = ({
1767
1767
  newFolderInputRef.current.focus();
1768
1768
  }
1769
1769
  }, [creatingFolder]);
1770
+ (0, import_react5.useEffect)(() => {
1771
+ if (!open) return;
1772
+ const handler = (e) => {
1773
+ if (e.key !== "Escape") return;
1774
+ const active = document.activeElement;
1775
+ const tag = active?.tagName;
1776
+ if (tag === "INPUT" || tag === "TEXTAREA" || active?.isContentEditable) {
1777
+ return;
1778
+ }
1779
+ onClose();
1780
+ };
1781
+ document.addEventListener("keydown", handler);
1782
+ return () => document.removeEventListener("keydown", handler);
1783
+ }, [open, onClose]);
1770
1784
  const handleMouseDown = (0, import_react5.useCallback)((e) => {
1771
1785
  if (e.target.closest("button")) return;
1772
1786
  if (e.target.closest("input")) return;
@@ -1894,10 +1908,19 @@ var DrawingsDialog = ({
1894
1908
  minute: "2-digit"
1895
1909
  });
1896
1910
  };
1897
- const daysSinceBackup = (0, import_react5.useMemo)(() => {
1911
+ const { daysSinceBackup, lastBackupTimestamp } = (0, import_react5.useMemo)(() => {
1898
1912
  const lastBackup = localStorage.getItem("rita-workspace-last-backup");
1899
- if (!lastBackup) return drawings.length > 0 ? 999 : null;
1900
- return Math.floor((Date.now() - parseInt(lastBackup, 10)) / (1e3 * 60 * 60 * 24));
1913
+ if (!lastBackup) {
1914
+ return {
1915
+ daysSinceBackup: drawings.length > 0 ? 999 : null,
1916
+ lastBackupTimestamp: null
1917
+ };
1918
+ }
1919
+ const ts = parseInt(lastBackup, 10);
1920
+ return {
1921
+ daysSinceBackup: Math.floor((Date.now() - ts) / (1e3 * 60 * 60 * 24)),
1922
+ lastBackupTimestamp: ts
1923
+ };
1901
1924
  }, [drawings.length, open]);
1902
1925
  const { rootDrawings, drawingsByFolder, filteredFolders } = (0, import_react5.useMemo)(() => {
1903
1926
  const query = searchQuery.toLowerCase().trim();
@@ -2572,42 +2595,66 @@ var DrawingsDialog = ({
2572
2595
  )
2573
2596
  ] }),
2574
2597
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: sectionHeaderStyle, children: t.sectionWorkspace }),
2575
- daysSinceBackup !== null && daysSinceBackup >= 7 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2576
- "div",
2577
- {
2578
- style: {
2579
- margin: "0 20px 12px",
2580
- padding: "10px 14px",
2581
- backgroundColor: daysSinceBackup >= 30 ? "#f8d7da" : "#fff3cd",
2582
- color: daysSinceBackup >= 30 ? "#721c24" : "#856404",
2583
- fontSize: "13px",
2584
- fontWeight: 500,
2585
- border: `1px solid ${daysSinceBackup >= 30 ? "#dc3545" : "#ffc107"}`,
2586
- borderRadius: "6px",
2587
- display: "flex",
2588
- alignItems: "center",
2589
- gap: "8px"
2590
- },
2591
- children: [
2592
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "16px" }, children: daysSinceBackup >= 30 ? "\u{1F6A8}" : "\u26A0\uFE0F" }),
2593
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: daysSinceBackup >= 999 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2594
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Ingen backup gjord \xE4nnu." }),
2595
- ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2596
- ] }) : daysSinceBackup >= 30 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2597
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("strong", { children: [
2598
- "Ingen backup p\xE5 ",
2599
- daysSinceBackup,
2600
- " dagar."
2601
- ] }),
2602
- " Det \xE4r dags att spara en kopia av dina ritningar."
2603
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2604
- "Senaste backup f\xF6r ",
2605
- daysSinceBackup,
2606
- " dagar sedan. \xD6verv\xE4g att spara en ny."
2607
- ] }) })
2608
- ]
2609
- }
2610
- ),
2598
+ daysSinceBackup !== null && (() => {
2599
+ const isNever = daysSinceBackup >= 999;
2600
+ const isCritical = !isNever && daysSinceBackup >= 30;
2601
+ const isWarning = !isNever && !isCritical && daysSinceBackup >= 7;
2602
+ const isInfo = !isNever && !isCritical && !isWarning;
2603
+ const dateStr = lastBackupTimestamp ? new Date(lastBackupTimestamp).toLocaleString(effectiveLang || "sv", {
2604
+ year: "numeric",
2605
+ month: "short",
2606
+ day: "numeric",
2607
+ hour: "2-digit",
2608
+ minute: "2-digit"
2609
+ }) : null;
2610
+ const ageStr = daysSinceBackup === 0 ? "idag" : `f\xF6r ${daysSinceBackup} dagar sedan`;
2611
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2612
+ "div",
2613
+ {
2614
+ style: {
2615
+ margin: "0 20px 12px",
2616
+ padding: "10px 14px",
2617
+ backgroundColor: isCritical || isNever ? "#f8d7da" : isWarning ? "#fff3cd" : "transparent",
2618
+ color: isCritical || isNever ? "#721c24" : isWarning ? "#856404" : "var(--text-secondary-color, #888)",
2619
+ fontSize: "13px",
2620
+ fontWeight: isInfo ? 400 : 500,
2621
+ border: isInfo ? "1px solid var(--default-border-color, #e0e0e0)" : `1px solid ${isCritical || isNever ? "#dc3545" : "#ffc107"}`,
2622
+ borderRadius: "6px",
2623
+ display: "flex",
2624
+ alignItems: "center",
2625
+ gap: "8px"
2626
+ },
2627
+ children: [
2628
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "16px" }, children: isNever || isCritical ? "\u{1F6A8}" : isWarning ? "\u26A0\uFE0F" : "\u{1F4BE}" }),
2629
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: isNever ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2630
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Ingen backup gjord \xE4nnu." }),
2631
+ ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2632
+ ] }) : isCritical ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2633
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("strong", { children: [
2634
+ "Ingen backup p\xE5 ",
2635
+ daysSinceBackup,
2636
+ " dagar."
2637
+ ] }),
2638
+ " Senast: ",
2639
+ dateStr,
2640
+ "."
2641
+ ] }) : isWarning ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2642
+ "Senaste backup ",
2643
+ ageStr,
2644
+ " (",
2645
+ dateStr,
2646
+ "). \xD6verv\xE4g att spara en ny."
2647
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2648
+ "Senaste backup ",
2649
+ ageStr,
2650
+ " (",
2651
+ dateStr,
2652
+ ")."
2653
+ ] }) })
2654
+ ]
2655
+ }
2656
+ );
2657
+ })(),
2611
2658
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { padding: "0 20px 16px", display: "flex", gap: "8px" }, children: [
2612
2659
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2613
2660
  ActionButton,
package/dist/index.mjs CHANGED
@@ -1695,6 +1695,20 @@ var DrawingsDialog = ({
1695
1695
  newFolderInputRef.current.focus();
1696
1696
  }
1697
1697
  }, [creatingFolder]);
1698
+ useEffect3(() => {
1699
+ if (!open) return;
1700
+ const handler = (e) => {
1701
+ if (e.key !== "Escape") return;
1702
+ const active = document.activeElement;
1703
+ const tag = active?.tagName;
1704
+ if (tag === "INPUT" || tag === "TEXTAREA" || active?.isContentEditable) {
1705
+ return;
1706
+ }
1707
+ onClose();
1708
+ };
1709
+ document.addEventListener("keydown", handler);
1710
+ return () => document.removeEventListener("keydown", handler);
1711
+ }, [open, onClose]);
1698
1712
  const handleMouseDown = useCallback2((e) => {
1699
1713
  if (e.target.closest("button")) return;
1700
1714
  if (e.target.closest("input")) return;
@@ -1822,10 +1836,19 @@ var DrawingsDialog = ({
1822
1836
  minute: "2-digit"
1823
1837
  });
1824
1838
  };
1825
- const daysSinceBackup = useMemo(() => {
1839
+ const { daysSinceBackup, lastBackupTimestamp } = useMemo(() => {
1826
1840
  const lastBackup = localStorage.getItem("rita-workspace-last-backup");
1827
- if (!lastBackup) return drawings.length > 0 ? 999 : null;
1828
- return Math.floor((Date.now() - parseInt(lastBackup, 10)) / (1e3 * 60 * 60 * 24));
1841
+ if (!lastBackup) {
1842
+ return {
1843
+ daysSinceBackup: drawings.length > 0 ? 999 : null,
1844
+ lastBackupTimestamp: null
1845
+ };
1846
+ }
1847
+ const ts = parseInt(lastBackup, 10);
1848
+ return {
1849
+ daysSinceBackup: Math.floor((Date.now() - ts) / (1e3 * 60 * 60 * 24)),
1850
+ lastBackupTimestamp: ts
1851
+ };
1829
1852
  }, [drawings.length, open]);
1830
1853
  const { rootDrawings, drawingsByFolder, filteredFolders } = useMemo(() => {
1831
1854
  const query = searchQuery.toLowerCase().trim();
@@ -2500,42 +2523,66 @@ var DrawingsDialog = ({
2500
2523
  )
2501
2524
  ] }),
2502
2525
  /* @__PURE__ */ jsx6("div", { style: sectionHeaderStyle, children: t.sectionWorkspace }),
2503
- daysSinceBackup !== null && daysSinceBackup >= 7 && /* @__PURE__ */ jsxs4(
2504
- "div",
2505
- {
2506
- style: {
2507
- margin: "0 20px 12px",
2508
- padding: "10px 14px",
2509
- backgroundColor: daysSinceBackup >= 30 ? "#f8d7da" : "#fff3cd",
2510
- color: daysSinceBackup >= 30 ? "#721c24" : "#856404",
2511
- fontSize: "13px",
2512
- fontWeight: 500,
2513
- border: `1px solid ${daysSinceBackup >= 30 ? "#dc3545" : "#ffc107"}`,
2514
- borderRadius: "6px",
2515
- display: "flex",
2516
- alignItems: "center",
2517
- gap: "8px"
2518
- },
2519
- children: [
2520
- /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px" }, children: daysSinceBackup >= 30 ? "\u{1F6A8}" : "\u26A0\uFE0F" }),
2521
- /* @__PURE__ */ jsx6("span", { children: daysSinceBackup >= 999 ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2522
- /* @__PURE__ */ jsx6("strong", { children: "Ingen backup gjord \xE4nnu." }),
2523
- ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2524
- ] }) : daysSinceBackup >= 30 ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2525
- /* @__PURE__ */ jsxs4("strong", { children: [
2526
- "Ingen backup p\xE5 ",
2527
- daysSinceBackup,
2528
- " dagar."
2529
- ] }),
2530
- " Det \xE4r dags att spara en kopia av dina ritningar."
2531
- ] }) : /* @__PURE__ */ jsxs4(Fragment3, { children: [
2532
- "Senaste backup f\xF6r ",
2533
- daysSinceBackup,
2534
- " dagar sedan. \xD6verv\xE4g att spara en ny."
2535
- ] }) })
2536
- ]
2537
- }
2538
- ),
2526
+ daysSinceBackup !== null && (() => {
2527
+ const isNever = daysSinceBackup >= 999;
2528
+ const isCritical = !isNever && daysSinceBackup >= 30;
2529
+ const isWarning = !isNever && !isCritical && daysSinceBackup >= 7;
2530
+ const isInfo = !isNever && !isCritical && !isWarning;
2531
+ const dateStr = lastBackupTimestamp ? new Date(lastBackupTimestamp).toLocaleString(effectiveLang || "sv", {
2532
+ year: "numeric",
2533
+ month: "short",
2534
+ day: "numeric",
2535
+ hour: "2-digit",
2536
+ minute: "2-digit"
2537
+ }) : null;
2538
+ const ageStr = daysSinceBackup === 0 ? "idag" : `f\xF6r ${daysSinceBackup} dagar sedan`;
2539
+ return /* @__PURE__ */ jsxs4(
2540
+ "div",
2541
+ {
2542
+ style: {
2543
+ margin: "0 20px 12px",
2544
+ padding: "10px 14px",
2545
+ backgroundColor: isCritical || isNever ? "#f8d7da" : isWarning ? "#fff3cd" : "transparent",
2546
+ color: isCritical || isNever ? "#721c24" : isWarning ? "#856404" : "var(--text-secondary-color, #888)",
2547
+ fontSize: "13px",
2548
+ fontWeight: isInfo ? 400 : 500,
2549
+ border: isInfo ? "1px solid var(--default-border-color, #e0e0e0)" : `1px solid ${isCritical || isNever ? "#dc3545" : "#ffc107"}`,
2550
+ borderRadius: "6px",
2551
+ display: "flex",
2552
+ alignItems: "center",
2553
+ gap: "8px"
2554
+ },
2555
+ children: [
2556
+ /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px" }, children: isNever || isCritical ? "\u{1F6A8}" : isWarning ? "\u26A0\uFE0F" : "\u{1F4BE}" }),
2557
+ /* @__PURE__ */ jsx6("span", { children: isNever ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2558
+ /* @__PURE__ */ jsx6("strong", { children: "Ingen backup gjord \xE4nnu." }),
2559
+ ' Klicka "Spara alla ritningar" nedan f\xF6r att ladda ner en kopia.'
2560
+ ] }) : isCritical ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2561
+ /* @__PURE__ */ jsxs4("strong", { children: [
2562
+ "Ingen backup p\xE5 ",
2563
+ daysSinceBackup,
2564
+ " dagar."
2565
+ ] }),
2566
+ " Senast: ",
2567
+ dateStr,
2568
+ "."
2569
+ ] }) : isWarning ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2570
+ "Senaste backup ",
2571
+ ageStr,
2572
+ " (",
2573
+ dateStr,
2574
+ "). \xD6verv\xE4g att spara en ny."
2575
+ ] }) : /* @__PURE__ */ jsxs4(Fragment3, { children: [
2576
+ "Senaste backup ",
2577
+ ageStr,
2578
+ " (",
2579
+ dateStr,
2580
+ ")."
2581
+ ] }) })
2582
+ ]
2583
+ }
2584
+ );
2585
+ })(),
2539
2586
  /* @__PURE__ */ jsxs4("div", { style: { padding: "0 20px 16px", display: "flex", gap: "8px" }, children: [
2540
2587
  /* @__PURE__ */ jsx6(
2541
2588
  ActionButton,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rita-workspace",
3
- "version": "0.5.43",
3
+ "version": "0.5.45",
4
4
  "description": "Multi-drawing workspace feature for Rita (Excalidraw fork)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",