react-os-shell 0.2.68 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +35 -15
  2. package/dist/{Browser-UGZQMWKW.js → Browser-H5KDP5OH.js} +3 -3
  3. package/dist/{Browser-UGZQMWKW.js.map → Browser-H5KDP5OH.js.map} +1 -1
  4. package/dist/{Calculator-3ZXNXWDH.js → Calculator-QQ7NF53Q.js} +4 -4
  5. package/dist/{Calculator-3ZXNXWDH.js.map → Calculator-QQ7NF53Q.js.map} +1 -1
  6. package/dist/{Calendar-ON4AQ54T.js → Calendar-J6L7FGHS.js} +175 -108
  7. package/dist/Calendar-J6L7FGHS.js.map +1 -0
  8. package/dist/{CurrencyConverter-ACTLK72N.js → CurrencyConverter-YHOGBUPH.js} +4 -4
  9. package/dist/{CurrencyConverter-ACTLK72N.js.map → CurrencyConverter-YHOGBUPH.js.map} +1 -1
  10. package/dist/{Documents-STDXQ7I4.js → Documents-6DYALASM.js} +3 -3
  11. package/dist/{Documents-STDXQ7I4.js.map → Documents-6DYALASM.js.map} +1 -1
  12. package/dist/Email-U2U5Z4DL.js +475 -0
  13. package/dist/Email-U2U5Z4DL.js.map +1 -0
  14. package/dist/Files-T62M4V5I.js +11 -0
  15. package/dist/{Files-ASKLEUNU.js.map → Files-T62M4V5I.js.map} +1 -1
  16. package/dist/{Minesweeper-CZNIO75H.js → Minesweeper-S2JHXYLX.js} +3 -3
  17. package/dist/{Minesweeper-CZNIO75H.js.map → Minesweeper-S2JHXYLX.js.map} +1 -1
  18. package/dist/{Notepad-ZYYH4ZXN.js → Notepad-2YF7X3XO.js} +3 -3
  19. package/dist/{Notepad-ZYYH4ZXN.js.map → Notepad-2YF7X3XO.js.map} +1 -1
  20. package/dist/{PomodoroTimer-2MNIEAUM.js → PomodoroTimer-3J7Z3NVQ.js} +4 -4
  21. package/dist/{PomodoroTimer-2MNIEAUM.js.map → PomodoroTimer-3J7Z3NVQ.js.map} +1 -1
  22. package/dist/Preview-WM6ZP5PZ.js +8 -0
  23. package/dist/{Preview-U72UL74H.js.map → Preview-WM6ZP5PZ.js.map} +1 -1
  24. package/dist/Spreadsheet-ZIE2SXAF.js +6 -0
  25. package/dist/{Spreadsheet-T7Y7PRD6.js.map → Spreadsheet-ZIE2SXAF.js.map} +1 -1
  26. package/dist/{TodoList-7JZ2SLDI.js → TodoList-QGXCDEIE.js} +18 -204
  27. package/dist/TodoList-QGXCDEIE.js.map +1 -0
  28. package/dist/{Weather-DYCTCB6T.js → Weather-2GFPSZ5V.js} +4 -4
  29. package/dist/{Weather-DYCTCB6T.js.map → Weather-2GFPSZ5V.js.map} +1 -1
  30. package/dist/{WorldClock-XL4OMFOY.js → WorldClock-P4JR5I6X.js} +4 -4
  31. package/dist/{WorldClock-XL4OMFOY.js.map → WorldClock-P4JR5I6X.js.map} +1 -1
  32. package/dist/apps/index.d.ts +2 -5
  33. package/dist/apps/index.js +23 -26
  34. package/dist/apps/index.js.map +1 -1
  35. package/dist/chunk-57B3WALN.js +114 -0
  36. package/dist/chunk-57B3WALN.js.map +1 -0
  37. package/dist/{chunk-4SHZ7BZO.js → chunk-62FC2FHC.js} +92 -21
  38. package/dist/chunk-62FC2FHC.js.map +1 -0
  39. package/dist/{chunk-FXAOT23O.js → chunk-ATQVRDDQ.js} +3 -3
  40. package/dist/{chunk-FXAOT23O.js.map → chunk-ATQVRDDQ.js.map} +1 -1
  41. package/dist/{chunk-GP4Y3VCB.js → chunk-KMGWSDEI.js} +480 -4
  42. package/dist/chunk-KMGWSDEI.js.map +1 -0
  43. package/dist/{chunk-SU6XVJND.js → chunk-O6FJZAFM.js} +3 -3
  44. package/dist/{chunk-SU6XVJND.js.map → chunk-O6FJZAFM.js.map} +1 -1
  45. package/dist/{chunk-YL47AVBA.js → chunk-SEV7UXGN.js} +4 -4
  46. package/dist/{chunk-YL47AVBA.js.map → chunk-SEV7UXGN.js.map} +1 -1
  47. package/dist/{chunk-L2AFKNSQ.js → chunk-ZBRFMK3E.js} +4 -4
  48. package/dist/{chunk-L2AFKNSQ.js.map → chunk-ZBRFMK3E.js.map} +1 -1
  49. package/dist/index.d.ts +55 -1
  50. package/dist/index.js +241 -135
  51. package/dist/index.js.map +1 -1
  52. package/package.json +10 -3
  53. package/dist/Calendar-ON4AQ54T.js.map +0 -1
  54. package/dist/Email-5WL3TWC6.js +0 -1883
  55. package/dist/Email-5WL3TWC6.js.map +0 -1
  56. package/dist/Files-ASKLEUNU.js +0 -12
  57. package/dist/GeminiChat-XTEBZIVK.js +0 -184
  58. package/dist/GeminiChat-XTEBZIVK.js.map +0 -1
  59. package/dist/Preview-U72UL74H.js +0 -8
  60. package/dist/Spreadsheet-T7Y7PRD6.js +0 -7
  61. package/dist/TodoList-7JZ2SLDI.js.map +0 -1
  62. package/dist/chunk-4SHZ7BZO.js.map +0 -1
  63. package/dist/chunk-5VXRBUEH.js +0 -104
  64. package/dist/chunk-5VXRBUEH.js.map +0 -1
  65. package/dist/chunk-GP4Y3VCB.js.map +0 -1
  66. package/dist/chunk-MUXDKEOC.js +0 -485
  67. package/dist/chunk-MUXDKEOC.js.map +0 -1
  68. package/dist/chunk-MVWEL34Y.js +0 -209
  69. package/dist/chunk-MVWEL34Y.js.map +0 -1
@@ -1,8 +1,8 @@
1
+ import { WindowTitle } from './chunk-62FC2FHC.js';
1
2
  import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
2
3
  import { createPortal } from 'react-dom';
3
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
5
 
5
- // src/shell/EditableGrid.tsx
6
6
  function rangeContains(anchor, end, row, col) {
7
7
  const r1 = Math.min(anchor.row, end.row), r2 = Math.max(anchor.row, end.row);
8
8
  const c1 = Math.min(anchor.col, end.col), c2 = Math.max(anchor.col, end.col);
@@ -800,7 +800,483 @@ function EditableGrid({ columns, data, onChange, onColumnsChange, fixedRows = fa
800
800
  }
801
801
  );
802
802
  }
803
+ var TITLE_DISPLAY_MAX = 24;
804
+ function truncateForTitle(s) {
805
+ return s.length > TITLE_DISPLAY_MAX ? `${s.slice(0, TITLE_DISPLAY_MAX - 1)}\u2026` : s;
806
+ }
807
+ var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
808
+ var DEFAULT_COLS = 10;
809
+ var DEFAULT_ROWS = 30;
810
+ function colLabel(i) {
811
+ if (i < 26) return ALPHA[i];
812
+ return ALPHA[Math.floor(i / 26) - 1] + ALPHA[i % 26];
813
+ }
814
+ function makeColumns(count) {
815
+ return Array.from({ length: count }, (_, i) => ({
816
+ key: `col_${i}`,
817
+ title: colLabel(i),
818
+ width: 100
819
+ }));
820
+ }
821
+ function makeEmptyData(rows, cols) {
822
+ return Array.from({ length: rows }, () => Array(cols).fill(""));
823
+ }
824
+ function newSheet(name) {
825
+ return {
826
+ id: crypto.randomUUID(),
827
+ name,
828
+ columns: makeColumns(DEFAULT_COLS),
829
+ data: makeEmptyData(DEFAULT_ROWS, DEFAULT_COLS),
830
+ cellStyles: {}
831
+ };
832
+ }
833
+ function parseCSV(text) {
834
+ return text.split("\n").map((line) => {
835
+ if (line.includes(" ")) return line.split(" ").map((s) => s.trim());
836
+ const parts = [];
837
+ let current = "";
838
+ let inQuotes = false;
839
+ for (const ch of line) {
840
+ if (ch === '"') {
841
+ inQuotes = !inQuotes;
842
+ continue;
843
+ }
844
+ if (ch === "," && !inQuotes) {
845
+ parts.push(current.trim());
846
+ current = "";
847
+ continue;
848
+ }
849
+ current += ch;
850
+ }
851
+ parts.push(current.trim());
852
+ return parts;
853
+ }).filter((r) => r.some((c) => c.trim()));
854
+ }
855
+ function sheetFromCSV(text, sheetName) {
856
+ const parsed = parseCSV(text);
857
+ if (parsed.length === 0) return null;
858
+ const maxCols = Math.max(DEFAULT_COLS, parsed.reduce((m, r) => Math.max(m, r.length), 0));
859
+ const padded = parsed.map((r) => {
860
+ while (r.length < maxCols) r.push("");
861
+ return r;
862
+ });
863
+ while (padded.length < DEFAULT_ROWS) padded.push(Array(maxCols).fill(""));
864
+ return { id: crypto.randomUUID(), name: sheetName, columns: makeColumns(maxCols), data: padded, cellStyles: {} };
865
+ }
866
+ var SPREADSHEET_EVENT_NAME = "react-os-shell:spreadsheet-preview";
867
+ var pendingSpreadsheet = null;
868
+ function setSpreadsheetPreview(data) {
869
+ pendingSpreadsheet = data;
870
+ if (typeof window !== "undefined") {
871
+ window.dispatchEvent(new CustomEvent(SPREADSHEET_EVENT_NAME, { detail: data }));
872
+ }
873
+ }
874
+ function Spreadsheet() {
875
+ const containerRef = useRef(null);
876
+ const initialPreview = (() => {
877
+ const p = pendingSpreadsheet;
878
+ pendingSpreadsheet = null;
879
+ if (!p) return null;
880
+ const sheet = sheetFromCSV(p.csv, "Sheet 1");
881
+ if (!sheet) return null;
882
+ const titleName = p.filename.replace(/\.(csv|tsv|txt)$/i, "");
883
+ return { sheet, title: titleName };
884
+ })();
885
+ const [sheets, setSheets] = useState(initialPreview ? [initialPreview.sheet] : [newSheet("Sheet 1")]);
886
+ const [activeIdx, setActiveIdx] = useState(0);
887
+ const undoStackRef = useRef([]);
888
+ const lastCommittedRef = useRef(sheets);
889
+ const skipRecordRef = useRef(false);
890
+ useEffect(() => {
891
+ if (skipRecordRef.current) {
892
+ skipRecordRef.current = false;
893
+ } else if (lastCommittedRef.current !== sheets) {
894
+ undoStackRef.current.push(lastCommittedRef.current);
895
+ if (undoStackRef.current.length > 50) undoStackRef.current.shift();
896
+ }
897
+ lastCommittedRef.current = sheets;
898
+ }, [sheets]);
899
+ const undo = useCallback(() => {
900
+ const prev = undoStackRef.current.pop();
901
+ if (!prev) return;
902
+ skipRecordRef.current = true;
903
+ setSheets(prev);
904
+ }, []);
905
+ useEffect(() => {
906
+ const handler = (e) => {
907
+ if (!containerRef.current?.contains(document.activeElement) && !containerRef.current?.matches(":focus-within")) return;
908
+ const isUndo = (e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === "z" || e.key === "Z");
909
+ if (isUndo) {
910
+ e.preventDefault();
911
+ undo();
912
+ }
913
+ };
914
+ window.addEventListener("keydown", handler);
915
+ return () => window.removeEventListener("keydown", handler);
916
+ }, [undo]);
917
+ const [title, setTitle] = useState(initialPreview?.title ?? "Untitled");
918
+ useEffect(() => {
919
+ const handler = (e) => {
920
+ const next = e.detail;
921
+ const sheet = sheetFromCSV(next.csv, "Sheet 1");
922
+ if (!sheet) return;
923
+ setSheets([sheet]);
924
+ setActiveIdx(0);
925
+ setTitle(next.filename.replace(/\.(csv|tsv|txt)$/i, ""));
926
+ };
927
+ window.addEventListener(SPREADSHEET_EVENT_NAME, handler);
928
+ return () => window.removeEventListener(SPREADSHEET_EVENT_NAME, handler);
929
+ }, []);
930
+ const [editingTitle, setEditingTitle] = useState(false);
931
+ const [editingTab, setEditingTab] = useState(null);
932
+ const [tabName, setTabName] = useState("");
933
+ const fileRef = useRef(null);
934
+ const [addColCount, setAddColCount] = useState("1");
935
+ const [addRowCount, setAddRowCount] = useState("10");
936
+ const active = sheets[activeIdx] || sheets[0];
937
+ const data = active.data;
938
+ const columns = active.columns;
939
+ const cellStyles = active.cellStyles ?? {};
940
+ const [focusedCell, setFocusedCell] = useState(null);
941
+ const [selection, setSelection] = useState(null);
942
+ const targetCells = useCallback(() => {
943
+ if (selection) {
944
+ const r1 = Math.min(selection.anchor.row, selection.end.row);
945
+ const r2 = Math.max(selection.anchor.row, selection.end.row);
946
+ const c1 = Math.min(selection.anchor.col, selection.end.col);
947
+ const c2 = Math.max(selection.anchor.col, selection.end.col);
948
+ const cells = [];
949
+ for (let r = r1; r <= r2; r++) for (let c = c1; c <= c2; c++) cells.push({ row: r, col: c });
950
+ return cells;
951
+ }
952
+ return focusedCell ? [focusedCell] : [];
953
+ }, [selection, focusedCell]);
954
+ const toggleCellStyle = useCallback((key, value) => {
955
+ const cells = targetCells();
956
+ if (cells.length === 0) return;
957
+ setSheets((prev) => prev.map((s, i) => {
958
+ if (i !== activeIdx) return s;
959
+ const styles = { ...s.cellStyles ?? {} };
960
+ const firstKey = `${cells[0].row}:${cells[0].col}`;
961
+ const desired = value !== void 0 ? value : !(styles[firstKey] ?? {})[key];
962
+ for (const { row, col } of cells) {
963
+ const k = `${row}:${col}`;
964
+ styles[k] = { ...styles[k] ?? {}, [key]: desired };
965
+ }
966
+ return { ...s, cellStyles: styles };
967
+ }));
968
+ }, [targetCells, activeIdx]);
969
+ const headCell = selection ? { row: selection.anchor.row, col: selection.anchor.col } : focusedCell;
970
+ const focusedStyle = headCell ? cellStyles[`${headCell.row}:${headCell.col}`] ?? {} : {};
971
+ const hasTarget = !!headCell;
972
+ const updateActiveSheet = useCallback((update) => {
973
+ setSheets((prev) => prev.map((s, i) => i === activeIdx ? { ...s, ...update } : s));
974
+ }, [activeIdx]);
975
+ const handleChange = useCallback((newData) => {
976
+ const maxCols = newData.reduce((m, r) => Math.max(m, r.length), 0);
977
+ if (maxCols !== columns.length) {
978
+ updateActiveSheet({ data: newData, columns: makeColumns(maxCols) });
979
+ } else {
980
+ updateActiveSheet({ data: newData });
981
+ }
982
+ }, [updateActiveSheet, columns.length]);
983
+ const addSheet = () => {
984
+ const name = `Sheet ${sheets.length + 1}`;
985
+ setSheets((prev) => [...prev, newSheet(name)]);
986
+ setActiveIdx(sheets.length);
987
+ };
988
+ const removeSheet = (idx) => {
989
+ if (sheets.length <= 1) return;
990
+ setSheets((prev) => prev.filter((_, i) => i !== idx));
991
+ if (activeIdx >= idx && activeIdx > 0) setActiveIdx(activeIdx - 1);
992
+ };
993
+ const renameSheet = (idx, name) => {
994
+ setSheets((prev) => prev.map((s, i) => i === idx ? { ...s, name } : s));
995
+ setEditingTab(null);
996
+ };
997
+ const addColumns = (count) => {
998
+ const newColCount = columns.length + count;
999
+ updateActiveSheet({
1000
+ columns: makeColumns(newColCount),
1001
+ data: data.map((row) => [...row, ...Array(count).fill("")])
1002
+ });
1003
+ };
1004
+ const addRows = (count) => {
1005
+ updateActiveSheet({
1006
+ data: [...data, ...Array.from({ length: count }, () => Array(columns.length).fill(""))]
1007
+ });
1008
+ };
1009
+ const handleClear = () => {
1010
+ updateActiveSheet({
1011
+ columns: makeColumns(DEFAULT_COLS),
1012
+ data: makeEmptyData(DEFAULT_ROWS, DEFAULT_COLS)
1013
+ });
1014
+ };
1015
+ const exportCSV = () => {
1016
+ const csv = data.filter((row) => row.some((c) => c.trim())).map((row) => row.map((cell) => {
1017
+ if (cell.includes(",") || cell.includes('"') || cell.includes("\n"))
1018
+ return `"${cell.replace(/"/g, '""')}"`;
1019
+ return cell;
1020
+ }).join(",")).join("\n");
1021
+ const blob = new Blob([csv], { type: "text/csv" });
1022
+ const url = URL.createObjectURL(blob);
1023
+ const a = document.createElement("a");
1024
+ a.href = url;
1025
+ a.download = `${title || "spreadsheet"}.csv`;
1026
+ a.click();
1027
+ URL.revokeObjectURL(url);
1028
+ };
1029
+ const importFile = async (e) => {
1030
+ const file = e.target.files?.[0];
1031
+ if (!file) return;
1032
+ const name = file.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i, "");
1033
+ if (/\.(xlsx|xls|ods)$/i.test(file.name)) {
1034
+ const byteArr = new Uint8Array(await file.arrayBuffer());
1035
+ const XLSX = await import('xlsx');
1036
+ const wb = XLSX.read(byteArr, { type: "array" });
1037
+ const newSheets = wb.SheetNames.map((sn) => {
1038
+ const rows = XLSX.utils.sheet_to_json(wb.Sheets[sn], { header: 1, defval: "" });
1039
+ const maxCols = Math.max(DEFAULT_COLS, rows.reduce((m, r) => Math.max(m, r.length), 0));
1040
+ const padded = rows.map((r) => {
1041
+ const nr = r.map((c) => String(c ?? ""));
1042
+ while (nr.length < maxCols) nr.push("");
1043
+ return nr;
1044
+ });
1045
+ while (padded.length < DEFAULT_ROWS) padded.push(Array(maxCols).fill(""));
1046
+ return { id: crypto.randomUUID(), name: sn, columns: makeColumns(maxCols), data: padded };
1047
+ });
1048
+ setSheets(newSheets);
1049
+ setActiveIdx(0);
1050
+ setTitle(name);
1051
+ } else {
1052
+ const text = await file.text();
1053
+ const parsed = parseCSV(text);
1054
+ if (parsed.length === 0) return;
1055
+ const maxCols = Math.max(DEFAULT_COLS, parsed.reduce((m, r) => Math.max(m, r.length), 0));
1056
+ const padded = parsed.map((r) => {
1057
+ while (r.length < maxCols) r.push("");
1058
+ return r;
1059
+ });
1060
+ while (padded.length < DEFAULT_ROWS) padded.push(Array(maxCols).fill(""));
1061
+ updateActiveSheet({ columns: makeColumns(maxCols), data: padded });
1062
+ setTitle(name);
1063
+ }
1064
+ if (fileRef.current) fileRef.current.value = "";
1065
+ };
1066
+ const allNums = [];
1067
+ data.forEach((row) => row.forEach((cell) => {
1068
+ const v = parseFloat(cell);
1069
+ if (!isNaN(v) && cell.trim()) allNums.push(v);
1070
+ }));
1071
+ const filledCount = data.reduce((c, row) => c + row.filter((cell) => cell.trim()).length, 0);
1072
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "flex flex-col h-full", children: [
1073
+ /* @__PURE__ */ jsx(WindowTitle, { title: `${truncateForTitle(title || "Untitled")} - Spreadsheets` }),
1074
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0", children: [
1075
+ editingTitle ? /* @__PURE__ */ jsx(
1076
+ "input",
1077
+ {
1078
+ type: "text",
1079
+ value: title,
1080
+ onChange: (e) => setTitle(e.target.value),
1081
+ onBlur: () => setEditingTitle(false),
1082
+ onKeyDown: (e) => {
1083
+ if (e.key === "Enter") setEditingTitle(false);
1084
+ },
1085
+ autoFocus: true,
1086
+ className: "text-sm font-medium text-gray-900 border border-gray-300 rounded px-2 py-0.5 w-40 focus:border-blue-500 focus:ring-blue-500"
1087
+ }
1088
+ ) : /* @__PURE__ */ jsx("button", { onClick: () => setEditingTitle(true), className: "text-sm font-medium text-gray-900 hover:text-blue-600 truncate max-w-[200px]", title: "Click to rename", children: title || "Untitled" }),
1089
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-gray-300" }),
1090
+ /* @__PURE__ */ jsx("input", { ref: fileRef, type: "file", accept: ".csv,.tsv,.txt,.xlsx,.xls,.ods", onChange: importFile, className: "hidden" }),
1091
+ /* @__PURE__ */ jsx(
1092
+ "button",
1093
+ {
1094
+ onClick: () => fileRef.current?.click(),
1095
+ className: "text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",
1096
+ children: "Open"
1097
+ }
1098
+ ),
1099
+ /* @__PURE__ */ jsx(
1100
+ "button",
1101
+ {
1102
+ onClick: exportCSV,
1103
+ className: "text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",
1104
+ children: "Save CSV"
1105
+ }
1106
+ ),
1107
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-gray-300" }),
1108
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
1109
+ /* @__PURE__ */ jsx(
1110
+ "input",
1111
+ {
1112
+ type: "number",
1113
+ min: "1",
1114
+ max: "50",
1115
+ value: addColCount,
1116
+ onChange: (e) => setAddColCount(e.target.value),
1117
+ className: "w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"
1118
+ }
1119
+ ),
1120
+ /* @__PURE__ */ jsx(
1121
+ "button",
1122
+ {
1123
+ onClick: () => addColumns(parseInt(addColCount) || 1),
1124
+ className: "text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",
1125
+ children: "+ Col"
1126
+ }
1127
+ )
1128
+ ] }),
1129
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
1130
+ /* @__PURE__ */ jsx(
1131
+ "input",
1132
+ {
1133
+ type: "number",
1134
+ min: "1",
1135
+ max: "500",
1136
+ value: addRowCount,
1137
+ onChange: (e) => setAddRowCount(e.target.value),
1138
+ className: "w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"
1139
+ }
1140
+ ),
1141
+ /* @__PURE__ */ jsx(
1142
+ "button",
1143
+ {
1144
+ onClick: () => addRows(parseInt(addRowCount) || 10),
1145
+ className: "text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",
1146
+ children: "+ Row"
1147
+ }
1148
+ )
1149
+ ] }),
1150
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-gray-300" }),
1151
+ /* @__PURE__ */ jsx(
1152
+ "button",
1153
+ {
1154
+ onClick: handleClear,
1155
+ className: "text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",
1156
+ children: "Clear"
1157
+ }
1158
+ ),
1159
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-gray-300" }),
1160
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", title: hasTarget ? "" : "Click a cell first", children: [
1161
+ /* @__PURE__ */ jsx(
1162
+ "button",
1163
+ {
1164
+ onClick: () => toggleCellStyle("bold"),
1165
+ disabled: !hasTarget,
1166
+ className: `px-2 py-1 text-xs rounded transition-colors font-bold ${focusedStyle.bold ? "bg-blue-100 text-blue-700" : "text-gray-600 hover:bg-gray-200"} disabled:opacity-40 disabled:cursor-not-allowed`,
1167
+ children: "B"
1168
+ }
1169
+ ),
1170
+ /* @__PURE__ */ jsx(
1171
+ "button",
1172
+ {
1173
+ onClick: () => toggleCellStyle("italic"),
1174
+ disabled: !hasTarget,
1175
+ className: `px-2 py-1 text-xs rounded transition-colors italic ${focusedStyle.italic ? "bg-blue-100 text-blue-700" : "text-gray-600 hover:bg-gray-200"} disabled:opacity-40 disabled:cursor-not-allowed`,
1176
+ children: "I"
1177
+ }
1178
+ ),
1179
+ /* @__PURE__ */ jsx(
1180
+ "button",
1181
+ {
1182
+ onClick: () => toggleCellStyle("underline"),
1183
+ disabled: !hasTarget,
1184
+ className: `px-2 py-1 text-xs rounded transition-colors underline ${focusedStyle.underline ? "bg-blue-100 text-blue-700" : "text-gray-600 hover:bg-gray-200"} disabled:opacity-40 disabled:cursor-not-allowed`,
1185
+ children: "U"
1186
+ }
1187
+ ),
1188
+ /* @__PURE__ */ jsxs(
1189
+ "select",
1190
+ {
1191
+ value: focusedStyle.fontSize ?? "base",
1192
+ onChange: (e) => toggleCellStyle("fontSize", e.target.value),
1193
+ disabled: !hasTarget,
1194
+ className: "ml-1 text-xs border border-gray-300 rounded px-1 py-0.5 bg-white disabled:opacity-40 disabled:cursor-not-allowed",
1195
+ children: [
1196
+ /* @__PURE__ */ jsx("option", { value: "sm", children: "XS" }),
1197
+ /* @__PURE__ */ jsx("option", { value: "base", children: "S" }),
1198
+ /* @__PURE__ */ jsx("option", { value: "lg", children: "M" }),
1199
+ /* @__PURE__ */ jsx("option", { value: "xl", children: "L" })
1200
+ ]
1201
+ }
1202
+ )
1203
+ ] })
1204
+ ] }),
1205
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0", children: /* @__PURE__ */ jsx(
1206
+ EditableGrid,
1207
+ {
1208
+ columns,
1209
+ data,
1210
+ onChange: handleChange,
1211
+ onColumnsChange: (newCols) => updateActiveSheet({ columns: newCols }),
1212
+ cellStyles,
1213
+ onFocusChange: setFocusedCell,
1214
+ onSelectionChange: setSelection,
1215
+ minRows: DEFAULT_ROWS,
1216
+ maxHeight: "100%"
1217
+ }
1218
+ ) }),
1219
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center border-t border-gray-200 bg-gray-50 shrink-0", children: [
1220
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5 px-1 py-1 overflow-x-auto flex-1 min-w-0", children: [
1221
+ sheets.map((sheet, idx) => /* @__PURE__ */ jsx(
1222
+ "button",
1223
+ {
1224
+ onClick: () => setActiveIdx(idx),
1225
+ onDoubleClick: () => {
1226
+ setEditingTab(idx);
1227
+ setTabName(sheet.name);
1228
+ },
1229
+ onContextMenu: (e) => {
1230
+ e.preventDefault();
1231
+ if (sheets.length > 1) removeSheet(idx);
1232
+ },
1233
+ className: `px-3 py-1 text-xs font-medium rounded-b whitespace-nowrap transition-colors ${idx === activeIdx ? "bg-white text-blue-700 border border-t-0 border-gray-300 -mt-px relative z-10" : "text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`,
1234
+ children: editingTab === idx ? /* @__PURE__ */ jsx(
1235
+ "input",
1236
+ {
1237
+ type: "text",
1238
+ value: tabName,
1239
+ onChange: (e) => setTabName(e.target.value),
1240
+ onBlur: () => renameSheet(idx, tabName || sheet.name),
1241
+ onKeyDown: (e) => {
1242
+ if (e.key === "Enter") renameSheet(idx, tabName || sheet.name);
1243
+ if (e.key === "Escape") setEditingTab(null);
1244
+ },
1245
+ onClick: (e) => e.stopPropagation(),
1246
+ autoFocus: true,
1247
+ className: "w-20 text-xs border border-blue-400 rounded px-1 py-0 focus:ring-0 focus:outline-none"
1248
+ }
1249
+ ) : sheet.name
1250
+ },
1251
+ sheet.id
1252
+ )),
1253
+ /* @__PURE__ */ jsx("button", { onClick: addSheet, className: "px-2 py-1 text-xs text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded", title: "Add sheet", children: "+" })
1254
+ ] }),
1255
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 px-3 py-1 text-xs text-gray-500 shrink-0 border-l border-gray-200", children: [
1256
+ /* @__PURE__ */ jsxs("span", { children: [
1257
+ filledCount,
1258
+ " cells"
1259
+ ] }),
1260
+ allNums.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
1261
+ /* @__PURE__ */ jsxs("span", { children: [
1262
+ "Sum: ",
1263
+ allNums.reduce((s, v) => s + v, 0).toLocaleString(void 0, { maximumFractionDigits: 2 })
1264
+ ] }),
1265
+ /* @__PURE__ */ jsxs("span", { children: [
1266
+ "Avg: ",
1267
+ (allNums.reduce((s, v) => s + v, 0) / allNums.length).toLocaleString(void 0, { maximumFractionDigits: 2 })
1268
+ ] })
1269
+ ] }),
1270
+ /* @__PURE__ */ jsxs("span", { children: [
1271
+ data.length,
1272
+ " \xD7 ",
1273
+ columns.length
1274
+ ] })
1275
+ ] })
1276
+ ] })
1277
+ ] });
1278
+ }
803
1279
 
804
- export { EditableGrid };
805
- //# sourceMappingURL=chunk-GP4Y3VCB.js.map
806
- //# sourceMappingURL=chunk-GP4Y3VCB.js.map
1280
+ export { EditableGrid, Spreadsheet, setSpreadsheetPreview };
1281
+ //# sourceMappingURL=chunk-KMGWSDEI.js.map
1282
+ //# sourceMappingURL=chunk-KMGWSDEI.js.map