react-excel-lite 0.0.6 → 0.0.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"excel-grid.d.ts","sourceRoot":"","sources":["../../src/components/excel-grid.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"excel-grid.d.ts","sourceRoot":"","sources":["../../src/components/excel-grid.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;AA2D1D,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,cAAmB,EACnB,MAAM,GACP,EAAE,cAAc,2CA+PhB"}
|
package/dist/react-excel-lite.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
function
|
|
1
|
+
import { jsxs as K, jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useCallback as C, useEffect as W, useRef as O, useMemo as U } from "react";
|
|
3
|
+
function H(...o) {
|
|
4
4
|
return o.filter(Boolean).join(" ");
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function Co(o) {
|
|
7
7
|
return `${o.row}-${o.col}`;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const [
|
|
11
|
-
return { row:
|
|
9
|
+
function xo(o) {
|
|
10
|
+
const [t, n] = o.split("-").map(Number);
|
|
11
|
+
return { row: t, col: n };
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (!o || !
|
|
15
|
-
const
|
|
16
|
-
for (let h =
|
|
13
|
+
function So(o, t) {
|
|
14
|
+
if (!o || !t) return o ? [o] : [];
|
|
15
|
+
const n = Math.min(o.row, t.row), s = Math.max(o.row, t.row), u = Math.min(o.col, t.col), b = Math.max(o.col, t.col), c = [];
|
|
16
|
+
for (let h = n; h <= s; h++)
|
|
17
17
|
for (let f = u; f <= b; f++)
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
function O(o, n) {
|
|
22
|
-
if (!n.start) return !1;
|
|
23
|
-
const l = n.end || n.start, s = Math.min(n.start.row, l.row), u = Math.max(n.start.row, l.row), b = Math.min(n.start.col, l.col), i = Math.max(n.start.col, l.col);
|
|
24
|
-
return o.row >= s && o.row <= u && o.col >= b && o.col <= i;
|
|
18
|
+
c.push({ row: h, col: f });
|
|
19
|
+
return c;
|
|
25
20
|
}
|
|
26
|
-
function X(o) {
|
|
27
|
-
|
|
21
|
+
function X(o, t) {
|
|
22
|
+
if (!t.start) return !1;
|
|
23
|
+
const n = t.end || t.start, s = Math.min(t.start.row, n.row), u = Math.max(t.start.row, n.row), b = Math.min(t.start.col, n.col), c = Math.max(t.start.col, n.col);
|
|
24
|
+
return o.row >= s && o.row <= u && o.col >= b && o.col <= c;
|
|
28
25
|
}
|
|
29
26
|
function _(o) {
|
|
30
|
-
return o.map((
|
|
27
|
+
return o.split(/\r?\n/).filter((t) => t.trim()).map((t) => t.split(" ").map((n) => n.trim()));
|
|
28
|
+
}
|
|
29
|
+
function J(o) {
|
|
30
|
+
return o.map((t) => t.join(" ")).join(`
|
|
31
31
|
`);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function j(o) {
|
|
34
34
|
return !o.start || !o.end ? o : {
|
|
35
35
|
start: {
|
|
36
36
|
row: Math.min(o.start.row, o.end.row),
|
|
@@ -42,220 +42,220 @@ function L(o) {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
if (o.row ===
|
|
45
|
+
function yo(o, t) {
|
|
46
|
+
if (o.row === t.row && o.col === t.col)
|
|
47
47
|
return [];
|
|
48
|
-
const
|
|
49
|
-
for (let h =
|
|
48
|
+
const n = Math.min(o.row, t.row), s = Math.max(o.row, t.row), u = Math.min(o.col, t.col), b = Math.max(o.col, t.col), c = [];
|
|
49
|
+
for (let h = n; h <= s; h++)
|
|
50
50
|
for (let f = u; f <= b; f++)
|
|
51
|
-
h === o.row && f === o.col ||
|
|
52
|
-
return
|
|
51
|
+
h === o.row && f === o.col || c.push({ row: h, col: f });
|
|
52
|
+
return c;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const [o,
|
|
54
|
+
function Q() {
|
|
55
|
+
const [o, t] = L({
|
|
56
56
|
start: null,
|
|
57
57
|
end: null
|
|
58
|
-
}), [
|
|
59
|
-
|
|
60
|
-
}, []), b =
|
|
58
|
+
}), [n, s] = L(!1), u = C((a) => {
|
|
59
|
+
t({ start: a, end: a }), s(!0);
|
|
60
|
+
}, []), b = C(
|
|
61
61
|
(a) => {
|
|
62
|
-
|
|
62
|
+
n && t((l) => ({ ...l, end: a }));
|
|
63
63
|
},
|
|
64
|
-
[
|
|
65
|
-
),
|
|
64
|
+
[n]
|
|
65
|
+
), c = C(() => {
|
|
66
66
|
s(!1);
|
|
67
|
-
}, []), h =
|
|
68
|
-
|
|
69
|
-
}, []), f =
|
|
70
|
-
(a) =>
|
|
67
|
+
}, []), h = C(() => {
|
|
68
|
+
t({ start: null, end: null }), s(!1);
|
|
69
|
+
}, []), f = C(
|
|
70
|
+
(a) => X(a, o),
|
|
71
71
|
[o]
|
|
72
72
|
);
|
|
73
73
|
return W(() => {
|
|
74
74
|
const a = () => {
|
|
75
|
-
|
|
75
|
+
n && s(!1);
|
|
76
76
|
};
|
|
77
77
|
return window.addEventListener("mouseup", a), () => window.removeEventListener("mouseup", a);
|
|
78
|
-
}, [
|
|
78
|
+
}, [n]), {
|
|
79
79
|
selection: o,
|
|
80
|
-
isSelecting:
|
|
80
|
+
isSelecting: n,
|
|
81
81
|
isCellSelected: f,
|
|
82
82
|
handleCellMouseDown: u,
|
|
83
83
|
handleCellMouseEnter: b,
|
|
84
|
-
handleMouseUp:
|
|
84
|
+
handleMouseUp: c,
|
|
85
85
|
clearSelection: h,
|
|
86
|
-
setSelection:
|
|
86
|
+
setSelection: t
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function Y({
|
|
90
90
|
selection: o,
|
|
91
|
-
getValue:
|
|
92
|
-
setValues:
|
|
91
|
+
getValue: t,
|
|
92
|
+
setValues: n,
|
|
93
93
|
rowCount: s,
|
|
94
94
|
colCount: u
|
|
95
95
|
}) {
|
|
96
|
-
const b =
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
99
|
-
const
|
|
100
|
-
for (let
|
|
101
|
-
const
|
|
102
|
-
for (let g =
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
const b = C(() => {
|
|
97
|
+
const l = j(o);
|
|
98
|
+
if (!l.start || !l.end) return [];
|
|
99
|
+
const x = [];
|
|
100
|
+
for (let y = l.start.row; y <= l.end.row; y++) {
|
|
101
|
+
const M = [];
|
|
102
|
+
for (let g = l.start.col; g <= l.end.col; g++)
|
|
103
|
+
M.push(t({ row: y, col: g }));
|
|
104
|
+
x.push(M);
|
|
105
105
|
}
|
|
106
|
-
return
|
|
107
|
-
}, [o,
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
const
|
|
106
|
+
return x;
|
|
107
|
+
}, [o, t]), c = C(async () => {
|
|
108
|
+
const l = b();
|
|
109
|
+
if (l.length === 0) return;
|
|
110
|
+
const x = J(l);
|
|
111
111
|
try {
|
|
112
|
-
await navigator.clipboard.writeText(
|
|
113
|
-
} catch (
|
|
114
|
-
console.error("Clipboard copy failed:",
|
|
112
|
+
await navigator.clipboard.writeText(x);
|
|
113
|
+
} catch (y) {
|
|
114
|
+
console.error("Clipboard copy failed:", y);
|
|
115
115
|
}
|
|
116
|
-
}, [b]), h =
|
|
116
|
+
}, [b]), h = C(async () => {
|
|
117
117
|
if (o.start)
|
|
118
118
|
try {
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const d =
|
|
124
|
-
d >= s || w.forEach((
|
|
125
|
-
const
|
|
126
|
-
|
|
119
|
+
const l = await navigator.clipboard.readText(), x = _(l);
|
|
120
|
+
if (x.length === 0) return;
|
|
121
|
+
const y = o.start.row, M = o.start.col, g = [];
|
|
122
|
+
x.forEach((w, p) => {
|
|
123
|
+
const d = y + p;
|
|
124
|
+
d >= s || w.forEach((i, R) => {
|
|
125
|
+
const F = M + R;
|
|
126
|
+
F >= u || g.push({ coord: { row: d, col: F }, value: i });
|
|
127
127
|
});
|
|
128
|
-
}), g.length > 0 &&
|
|
129
|
-
} catch (
|
|
130
|
-
console.error("Clipboard paste failed:",
|
|
128
|
+
}), g.length > 0 && n(g);
|
|
129
|
+
} catch (l) {
|
|
130
|
+
console.error("Clipboard paste failed:", l);
|
|
131
131
|
}
|
|
132
|
-
}, [o.start,
|
|
133
|
-
const
|
|
134
|
-
if (!
|
|
135
|
-
const
|
|
136
|
-
for (let
|
|
137
|
-
for (let
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}, [o,
|
|
141
|
-
(
|
|
142
|
-
(
|
|
132
|
+
}, [o.start, n, s, u]), f = C(() => {
|
|
133
|
+
const l = j(o);
|
|
134
|
+
if (!l.start || !l.end) return;
|
|
135
|
+
const x = [];
|
|
136
|
+
for (let y = l.start.row; y <= l.end.row; y++)
|
|
137
|
+
for (let M = l.start.col; M <= l.end.col; M++)
|
|
138
|
+
x.push({ coord: { row: y, col: M }, value: "" });
|
|
139
|
+
x.length > 0 && n(x);
|
|
140
|
+
}, [o, n]), a = C(
|
|
141
|
+
(l) => {
|
|
142
|
+
(l.ctrlKey || l.metaKey) && l.key === "c" && (l.preventDefault(), c()), (l.ctrlKey || l.metaKey) && l.key === "v" && (l.preventDefault(), h()), (l.key === "Backspace" || l.key === "Delete") && (l.preventDefault(), f());
|
|
143
143
|
},
|
|
144
|
-
[
|
|
144
|
+
[c, h, f]
|
|
145
145
|
);
|
|
146
146
|
return {
|
|
147
|
-
handleCopy:
|
|
147
|
+
handleCopy: c,
|
|
148
148
|
handlePaste: h,
|
|
149
149
|
handleKeyDown: a
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function Z(o) {
|
|
153
153
|
if (o.trim() === "") return null;
|
|
154
|
-
const
|
|
155
|
-
return isNaN(
|
|
154
|
+
const t = Number(o);
|
|
155
|
+
return isNaN(t) ? null : t;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function q(o) {
|
|
158
158
|
if (o.length === 0) return null;
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
return { numbers:
|
|
164
|
-
const s =
|
|
165
|
-
for (let u = 2; u <
|
|
166
|
-
if (
|
|
167
|
-
return { numbers:
|
|
168
|
-
return { numbers:
|
|
159
|
+
const t = o.map(Z);
|
|
160
|
+
if (t.some((u) => u === null)) return null;
|
|
161
|
+
const n = t;
|
|
162
|
+
if (n.length === 1)
|
|
163
|
+
return { numbers: n, diff: 0 };
|
|
164
|
+
const s = n[1] - n[0];
|
|
165
|
+
for (let u = 2; u < n.length; u++)
|
|
166
|
+
if (n[u] - n[u - 1] !== s)
|
|
167
|
+
return { numbers: n, diff: 0 };
|
|
168
|
+
return { numbers: n, diff: s };
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function oo({
|
|
171
171
|
selection: o,
|
|
172
|
-
getValue:
|
|
173
|
-
setValues:
|
|
172
|
+
getValue: t,
|
|
173
|
+
setValues: n
|
|
174
174
|
}) {
|
|
175
|
-
const [s, u] =
|
|
176
|
-
u(w), f(!0),
|
|
177
|
-
}, []),
|
|
175
|
+
const [s, u] = L(null), [b, c] = L([]), [h, f] = L(!1), [a, l] = L(null), x = C((w) => {
|
|
176
|
+
u(w), f(!0), c([]), l(null);
|
|
177
|
+
}, []), y = C(
|
|
178
178
|
(w) => {
|
|
179
179
|
if (!h || !o.start) return;
|
|
180
|
-
const p =
|
|
180
|
+
const p = j(o);
|
|
181
181
|
if (!p.start || !p.end) return;
|
|
182
|
-
|
|
182
|
+
l(w);
|
|
183
183
|
const d = {
|
|
184
184
|
row: Math.min(p.start.row, w.row),
|
|
185
185
|
col: Math.min(p.start.col, w.col)
|
|
186
|
-
},
|
|
186
|
+
}, i = {
|
|
187
187
|
row: Math.max(p.end.row, w.row),
|
|
188
188
|
col: Math.max(p.end.col, w.col)
|
|
189
|
-
},
|
|
190
|
-
for (let
|
|
191
|
-
for (let r = d.col; r <=
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
}, R = [];
|
|
190
|
+
for (let F = d.row; F <= i.row; F++)
|
|
191
|
+
for (let r = d.col; r <= i.col; r++)
|
|
192
|
+
F >= p.start.row && F <= p.end.row && r >= p.start.col && r <= p.end.col || R.push({ row: F, col: r });
|
|
193
|
+
c(R);
|
|
194
194
|
},
|
|
195
195
|
[h, o]
|
|
196
|
-
),
|
|
196
|
+
), M = C(() => {
|
|
197
197
|
if (!o.start || b.length === 0 || !a) {
|
|
198
|
-
u(null),
|
|
198
|
+
u(null), c([]), f(!1), l(null);
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
-
const w =
|
|
201
|
+
const w = j(o);
|
|
202
202
|
if (!w.start || !w.end) {
|
|
203
|
-
u(null),
|
|
203
|
+
u(null), c([]), f(!1), l(null);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
const p = [], d = w.start,
|
|
206
|
+
const p = [], d = w.start, i = w.end, R = i.row - d.row + 1, F = i.col - d.col + 1;
|
|
207
207
|
b.forEach((r) => {
|
|
208
|
-
let
|
|
208
|
+
let k, T;
|
|
209
209
|
if (r.row < d.row) {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
} else if (r.row >
|
|
213
|
-
const
|
|
214
|
-
|
|
210
|
+
const N = d.row - r.row;
|
|
211
|
+
k = i.row - (N - 1) % R;
|
|
212
|
+
} else if (r.row > i.row) {
|
|
213
|
+
const N = r.row - i.row;
|
|
214
|
+
k = d.row + (N - 1) % R;
|
|
215
215
|
} else
|
|
216
|
-
|
|
216
|
+
k = r.row;
|
|
217
217
|
if (r.col < d.col) {
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
} else if (r.col >
|
|
221
|
-
const
|
|
222
|
-
|
|
218
|
+
const N = d.col - r.col;
|
|
219
|
+
T = i.col - (N - 1) % F;
|
|
220
|
+
} else if (r.col > i.col) {
|
|
221
|
+
const N = r.col - i.col;
|
|
222
|
+
T = d.col + (N - 1) % F;
|
|
223
223
|
} else
|
|
224
|
-
|
|
225
|
-
let
|
|
226
|
-
if (r.row !==
|
|
227
|
-
const
|
|
228
|
-
for (let
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
if (r.row >
|
|
233
|
-
const
|
|
234
|
-
|
|
224
|
+
T = r.col;
|
|
225
|
+
let G = t({ row: k, col: T });
|
|
226
|
+
if (r.row !== k && r.col >= d.col && r.col <= i.col) {
|
|
227
|
+
const N = [];
|
|
228
|
+
for (let S = d.row; S <= i.row; S++)
|
|
229
|
+
N.push(t({ row: S, col: r.col }));
|
|
230
|
+
const D = q(N);
|
|
231
|
+
if (D && D.diff !== 0) {
|
|
232
|
+
if (r.row > i.row) {
|
|
233
|
+
const S = r.row - i.row;
|
|
234
|
+
G = String(D.numbers[D.numbers.length - 1] + D.diff * S);
|
|
235
235
|
} else if (r.row < d.row) {
|
|
236
|
-
const
|
|
237
|
-
|
|
236
|
+
const S = d.row - r.row;
|
|
237
|
+
G = String(D.numbers[0] - D.diff * S);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
if (r.col !==
|
|
242
|
-
const
|
|
243
|
-
for (let
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
if (r.col >
|
|
248
|
-
const
|
|
249
|
-
|
|
241
|
+
if (r.col !== T && r.row >= d.row && r.row <= i.row) {
|
|
242
|
+
const N = [];
|
|
243
|
+
for (let S = d.col; S <= i.col; S++)
|
|
244
|
+
N.push(t({ row: r.row, col: S }));
|
|
245
|
+
const D = q(N);
|
|
246
|
+
if (D && D.diff !== 0) {
|
|
247
|
+
if (r.col > i.col) {
|
|
248
|
+
const S = r.col - i.col;
|
|
249
|
+
G = String(D.numbers[D.numbers.length - 1] + D.diff * S);
|
|
250
250
|
} else if (r.col < d.col) {
|
|
251
|
-
const
|
|
252
|
-
|
|
251
|
+
const S = d.col - r.col;
|
|
252
|
+
G = String(D.numbers[0] - D.diff * S);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
p.push({ coord: r, value:
|
|
257
|
-
}), p.length > 0 &&
|
|
258
|
-
}, [o, b, a,
|
|
256
|
+
p.push({ coord: r, value: G });
|
|
257
|
+
}), p.length > 0 && n(p), u(null), c([]), f(!1), l(null);
|
|
258
|
+
}, [o, b, a, t, n]), g = C(
|
|
259
259
|
(w) => b.some(
|
|
260
260
|
(p) => p.row === w.row && p.col === w.col
|
|
261
261
|
),
|
|
@@ -263,24 +263,24 @@ function Z({
|
|
|
263
263
|
);
|
|
264
264
|
return W(() => {
|
|
265
265
|
const w = () => {
|
|
266
|
-
h &&
|
|
266
|
+
h && M();
|
|
267
267
|
};
|
|
268
268
|
return window.addEventListener("mouseup", w), () => window.removeEventListener("mouseup", w);
|
|
269
|
-
}, [h,
|
|
269
|
+
}, [h, M]), {
|
|
270
270
|
fillSource: s,
|
|
271
271
|
fillTargets: b,
|
|
272
272
|
isDraggingFill: h,
|
|
273
273
|
isFillTarget: g,
|
|
274
|
-
handleFillHandleMouseDown:
|
|
275
|
-
handleCellMouseEnterForFill:
|
|
276
|
-
handleFillMouseUp:
|
|
274
|
+
handleFillHandleMouseDown: x,
|
|
275
|
+
handleCellMouseEnterForFill: y,
|
|
276
|
+
handleFillMouseUp: M
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
const
|
|
279
|
+
const to = {
|
|
280
280
|
position: "relative",
|
|
281
281
|
border: "1px solid #d1d5db",
|
|
282
282
|
padding: 0
|
|
283
|
-
},
|
|
283
|
+
}, no = {
|
|
284
284
|
width: "100%",
|
|
285
285
|
height: "100%",
|
|
286
286
|
paddingLeft: "4px",
|
|
@@ -292,7 +292,7 @@ const V = {
|
|
|
292
292
|
backgroundColor: "transparent",
|
|
293
293
|
outline: "none",
|
|
294
294
|
cursor: "cell"
|
|
295
|
-
},
|
|
295
|
+
}, lo = {
|
|
296
296
|
position: "absolute",
|
|
297
297
|
bottom: "-2px",
|
|
298
298
|
right: "-2px",
|
|
@@ -301,261 +301,273 @@ const V = {
|
|
|
301
301
|
cursor: "crosshair",
|
|
302
302
|
zIndex: 20,
|
|
303
303
|
backgroundColor: "#3b82f6"
|
|
304
|
-
},
|
|
304
|
+
}, eo = {
|
|
305
305
|
backgroundColor: "#dbeafe",
|
|
306
306
|
outline: "2px solid #3b82f6",
|
|
307
307
|
outlineOffset: "-2px"
|
|
308
|
-
},
|
|
308
|
+
}, ro = {
|
|
309
309
|
backgroundColor: "#eff6ff"
|
|
310
310
|
};
|
|
311
|
-
function
|
|
311
|
+
function so({
|
|
312
312
|
coord: o,
|
|
313
|
-
value:
|
|
314
|
-
isSelected:
|
|
313
|
+
value: t,
|
|
314
|
+
isSelected: n,
|
|
315
315
|
isFillTarget: s,
|
|
316
316
|
showFillHandle: u,
|
|
317
317
|
onMouseDown: b,
|
|
318
|
-
onMouseEnter:
|
|
318
|
+
onMouseEnter: c,
|
|
319
319
|
onChange: h,
|
|
320
320
|
onFillHandleMouseDown: f,
|
|
321
321
|
styles: a
|
|
322
322
|
}) {
|
|
323
|
-
const
|
|
324
|
-
h(o,
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
},
|
|
328
|
-
|
|
329
|
-
},
|
|
330
|
-
...
|
|
331
|
-
...
|
|
332
|
-
...s && !g ?
|
|
323
|
+
const l = (i) => {
|
|
324
|
+
h(o, i.target.value);
|
|
325
|
+
}, x = (i) => {
|
|
326
|
+
i.target.classList.contains("fill-handle") || b(o);
|
|
327
|
+
}, y = (i) => {
|
|
328
|
+
i.stopPropagation(), i.preventDefault(), f(o);
|
|
329
|
+
}, M = !!a?.selected, g = !!a?.fillTarget, w = !!a?.fillHandle, p = {
|
|
330
|
+
...to,
|
|
331
|
+
...n && !M ? eo : {},
|
|
332
|
+
...s && !g ? ro : {}
|
|
333
333
|
}, d = {
|
|
334
|
-
...
|
|
334
|
+
...lo,
|
|
335
335
|
...w ? { backgroundColor: void 0 } : {}
|
|
336
336
|
};
|
|
337
|
-
return /* @__PURE__ */
|
|
337
|
+
return /* @__PURE__ */ K(
|
|
338
338
|
"td",
|
|
339
339
|
{
|
|
340
|
-
className:
|
|
340
|
+
className: H(
|
|
341
341
|
a?.cell,
|
|
342
|
-
|
|
342
|
+
n && a?.selected,
|
|
343
343
|
s && a?.fillTarget
|
|
344
344
|
),
|
|
345
345
|
style: p,
|
|
346
|
-
onMouseDown:
|
|
347
|
-
onMouseEnter: () =>
|
|
346
|
+
onMouseDown: x,
|
|
347
|
+
onMouseEnter: () => c(o),
|
|
348
348
|
children: [
|
|
349
349
|
/* @__PURE__ */ v(
|
|
350
350
|
"input",
|
|
351
351
|
{
|
|
352
352
|
type: "text",
|
|
353
|
-
value:
|
|
354
|
-
onChange:
|
|
355
|
-
style:
|
|
353
|
+
value: t,
|
|
354
|
+
onChange: l,
|
|
355
|
+
style: no
|
|
356
356
|
}
|
|
357
357
|
),
|
|
358
358
|
u && /* @__PURE__ */ v(
|
|
359
359
|
"div",
|
|
360
360
|
{
|
|
361
|
-
className:
|
|
361
|
+
className: H("fill-handle", a?.fillHandle),
|
|
362
362
|
style: d,
|
|
363
|
-
onMouseDown:
|
|
363
|
+
onMouseDown: y
|
|
364
364
|
}
|
|
365
365
|
)
|
|
366
366
|
]
|
|
367
367
|
}
|
|
368
368
|
);
|
|
369
369
|
}
|
|
370
|
-
const
|
|
370
|
+
const co = {
|
|
371
371
|
outline: "none",
|
|
372
372
|
overflowX: "auto"
|
|
373
|
-
},
|
|
373
|
+
}, io = {
|
|
374
374
|
borderCollapse: "collapse",
|
|
375
375
|
fontSize: "12px",
|
|
376
376
|
userSelect: "none"
|
|
377
|
-
},
|
|
377
|
+
}, ao = {
|
|
378
378
|
position: "sticky",
|
|
379
379
|
left: 0,
|
|
380
380
|
zIndex: 10,
|
|
381
|
-
backgroundColor: "#f3f4f6",
|
|
382
381
|
border: "1px solid #d1d5db",
|
|
383
382
|
padding: "6px 8px",
|
|
384
383
|
textAlign: "center",
|
|
385
384
|
fontWeight: 500
|
|
386
|
-
},
|
|
387
|
-
backgroundColor: "#dbeafe",
|
|
385
|
+
}, uo = {
|
|
388
386
|
border: "1px solid #d1d5db",
|
|
389
387
|
padding: "6px 4px",
|
|
390
388
|
textAlign: "center",
|
|
391
|
-
fontWeight: 500
|
|
392
|
-
|
|
393
|
-
}, io = {
|
|
394
|
-
backgroundColor: "#f9fafb",
|
|
389
|
+
fontWeight: 500
|
|
390
|
+
}, fo = {
|
|
395
391
|
border: "1px solid #d1d5db",
|
|
396
392
|
padding: "4px",
|
|
397
393
|
textAlign: "center",
|
|
398
394
|
fontWeight: 500,
|
|
399
395
|
fontSize: "11px"
|
|
396
|
+
}, wo = {
|
|
397
|
+
backgroundColor: "#f3f4f6"
|
|
398
|
+
}, ho = {
|
|
399
|
+
backgroundColor: "#dbeafe",
|
|
400
|
+
color: "#1d4ed8"
|
|
401
|
+
}, po = {
|
|
402
|
+
backgroundColor: "#f9fafb"
|
|
400
403
|
};
|
|
401
|
-
function
|
|
404
|
+
function Mo({
|
|
402
405
|
data: o,
|
|
403
|
-
onChange:
|
|
404
|
-
rowHeaders:
|
|
406
|
+
onChange: t,
|
|
407
|
+
rowHeaders: n,
|
|
405
408
|
colHeaders: s,
|
|
406
409
|
className: u,
|
|
407
410
|
rowHeaderTitle: b = "",
|
|
408
|
-
styles:
|
|
411
|
+
styles: c
|
|
409
412
|
}) {
|
|
410
|
-
const h =
|
|
411
|
-
(
|
|
413
|
+
const h = O(null), f = o.length, a = U(() => s ? s.reduce(
|
|
414
|
+
(e, m) => e + m.headers.length,
|
|
412
415
|
0
|
|
413
|
-
) : o[0]?.length ?? 0, [s, o]),
|
|
414
|
-
(
|
|
416
|
+
) : o[0]?.length ?? 0, [s, o]), l = U(() => s ? s.flatMap((e) => e.headers) : [], [s]), x = C(
|
|
417
|
+
(e) => e.row < 0 || e.row >= f || e.col < 0 || e.col >= a ? "" : o[e.row]?.[e.col] ?? "",
|
|
415
418
|
[o, f, a]
|
|
416
|
-
),
|
|
417
|
-
(
|
|
419
|
+
), y = C(
|
|
420
|
+
(e, m) => {
|
|
418
421
|
const E = o.map(
|
|
419
|
-
(
|
|
420
|
-
(
|
|
421
|
-
) :
|
|
422
|
+
(z, B) => B === e.row ? z.map(
|
|
423
|
+
(A, I) => I === e.col ? m : A
|
|
424
|
+
) : z
|
|
422
425
|
);
|
|
423
|
-
|
|
426
|
+
t(E);
|
|
424
427
|
},
|
|
425
|
-
[o,
|
|
426
|
-
),
|
|
427
|
-
(
|
|
428
|
-
if (
|
|
428
|
+
[o, t]
|
|
429
|
+
), M = C(
|
|
430
|
+
(e) => {
|
|
431
|
+
if (e.length === 0) return;
|
|
429
432
|
const m = o.map((E) => [...E]);
|
|
430
|
-
|
|
431
|
-
E.row >= 0 && E.row < f && E.col >= 0 && E.col < a && (m[E.row][E.col] =
|
|
432
|
-
}),
|
|
433
|
+
e.forEach(({ coord: E, value: z }) => {
|
|
434
|
+
E.row >= 0 && E.row < f && E.col >= 0 && E.col < a && (m[E.row][E.col] = z);
|
|
435
|
+
}), t(m);
|
|
433
436
|
},
|
|
434
|
-
[o,
|
|
437
|
+
[o, t, f, a]
|
|
435
438
|
), {
|
|
436
439
|
selection: g,
|
|
437
440
|
isSelecting: w,
|
|
438
441
|
isCellSelected: p,
|
|
439
442
|
handleCellMouseDown: d,
|
|
440
|
-
handleCellMouseEnter:
|
|
441
|
-
} =
|
|
443
|
+
handleCellMouseEnter: i
|
|
444
|
+
} = Q(), { handleKeyDown: R } = Y({
|
|
442
445
|
selection: g,
|
|
443
|
-
getValue:
|
|
444
|
-
setValues:
|
|
446
|
+
getValue: x,
|
|
447
|
+
setValues: M,
|
|
445
448
|
rowCount: f,
|
|
446
449
|
colCount: a
|
|
447
450
|
}), {
|
|
448
|
-
isDraggingFill:
|
|
451
|
+
isDraggingFill: F,
|
|
449
452
|
isFillTarget: r,
|
|
450
|
-
handleFillHandleMouseDown:
|
|
451
|
-
handleCellMouseEnterForFill:
|
|
452
|
-
} =
|
|
453
|
+
handleFillHandleMouseDown: k,
|
|
454
|
+
handleCellMouseEnterForFill: T
|
|
455
|
+
} = oo({
|
|
453
456
|
selection: g,
|
|
454
|
-
getValue:
|
|
455
|
-
setValues:
|
|
456
|
-
}),
|
|
457
|
-
(
|
|
458
|
-
|
|
457
|
+
getValue: x,
|
|
458
|
+
setValues: M
|
|
459
|
+
}), G = C(
|
|
460
|
+
(e) => {
|
|
461
|
+
F ? T(e) : w && i(e);
|
|
459
462
|
},
|
|
460
463
|
[
|
|
461
|
-
|
|
464
|
+
F,
|
|
462
465
|
w,
|
|
463
|
-
|
|
464
|
-
|
|
466
|
+
T,
|
|
467
|
+
i
|
|
465
468
|
]
|
|
466
|
-
),
|
|
467
|
-
(
|
|
468
|
-
|
|
469
|
+
), N = C(
|
|
470
|
+
(e, m) => {
|
|
471
|
+
y(e, m);
|
|
469
472
|
},
|
|
470
|
-
[
|
|
471
|
-
),
|
|
472
|
-
(
|
|
473
|
+
[y]
|
|
474
|
+
), D = C(
|
|
475
|
+
(e) => {
|
|
473
476
|
if (!g.start) return !1;
|
|
474
|
-
const m =
|
|
475
|
-
return !m.start || !m.end ? !1 :
|
|
477
|
+
const m = j(g);
|
|
478
|
+
return !m.start || !m.end ? !1 : e.row === m.end.row && e.col === m.end.col;
|
|
476
479
|
},
|
|
477
480
|
[g]
|
|
478
|
-
)
|
|
481
|
+
), S = (e) => ({
|
|
482
|
+
...ao,
|
|
483
|
+
...!e && !c?.rowHeader ? wo : {}
|
|
484
|
+
}), P = (e) => ({
|
|
485
|
+
...uo,
|
|
486
|
+
...!e && !c?.colGroup ? ho : {}
|
|
487
|
+
}), V = (e) => ({
|
|
488
|
+
...fo,
|
|
489
|
+
...!e && !c?.colHeader ? po : {}
|
|
490
|
+
});
|
|
479
491
|
return /* @__PURE__ */ v(
|
|
480
492
|
"div",
|
|
481
493
|
{
|
|
482
494
|
ref: h,
|
|
483
495
|
className: u,
|
|
484
|
-
style:
|
|
496
|
+
style: co,
|
|
485
497
|
tabIndex: 0,
|
|
486
|
-
onKeyDown:
|
|
487
|
-
children: /* @__PURE__ */
|
|
488
|
-
/* @__PURE__ */
|
|
489
|
-
s && /* @__PURE__ */
|
|
490
|
-
|
|
498
|
+
onKeyDown: R,
|
|
499
|
+
children: /* @__PURE__ */ K("table", { style: io, children: [
|
|
500
|
+
/* @__PURE__ */ K("thead", { children: [
|
|
501
|
+
s && /* @__PURE__ */ K("tr", { children: [
|
|
502
|
+
n && /* @__PURE__ */ v(
|
|
491
503
|
"th",
|
|
492
504
|
{
|
|
493
|
-
className:
|
|
494
|
-
style:
|
|
505
|
+
className: c?.rowHeader,
|
|
506
|
+
style: S(),
|
|
495
507
|
children: b
|
|
496
508
|
}
|
|
497
509
|
),
|
|
498
|
-
s.map((
|
|
510
|
+
s.map((e, m) => /* @__PURE__ */ v(
|
|
499
511
|
"th",
|
|
500
512
|
{
|
|
501
|
-
colSpan:
|
|
502
|
-
className:
|
|
503
|
-
style:
|
|
504
|
-
children:
|
|
513
|
+
colSpan: e.headers.length,
|
|
514
|
+
className: H(c?.colGroup, e.className),
|
|
515
|
+
style: P(e.className),
|
|
516
|
+
children: e.label
|
|
505
517
|
},
|
|
506
518
|
m
|
|
507
519
|
))
|
|
508
520
|
] }),
|
|
509
|
-
s && /* @__PURE__ */
|
|
510
|
-
|
|
521
|
+
s && /* @__PURE__ */ K("tr", { children: [
|
|
522
|
+
n && /* @__PURE__ */ v(
|
|
511
523
|
"th",
|
|
512
524
|
{
|
|
513
|
-
className:
|
|
514
|
-
style:
|
|
525
|
+
className: c?.rowHeader,
|
|
526
|
+
style: S()
|
|
515
527
|
}
|
|
516
528
|
),
|
|
517
|
-
|
|
529
|
+
l.map((e) => /* @__PURE__ */ v(
|
|
518
530
|
"th",
|
|
519
531
|
{
|
|
520
|
-
className:
|
|
521
|
-
style:
|
|
522
|
-
title:
|
|
523
|
-
children:
|
|
532
|
+
className: H(c?.colHeader, e.className),
|
|
533
|
+
style: V(e.className),
|
|
534
|
+
title: e.description,
|
|
535
|
+
children: e.label
|
|
524
536
|
},
|
|
525
|
-
|
|
537
|
+
e.key
|
|
526
538
|
))
|
|
527
539
|
] })
|
|
528
540
|
] }),
|
|
529
|
-
/* @__PURE__ */ v("tbody", { children: o.map((
|
|
530
|
-
|
|
541
|
+
/* @__PURE__ */ v("tbody", { children: o.map((e, m) => /* @__PURE__ */ K("tr", { children: [
|
|
542
|
+
n && n[m] && /* @__PURE__ */ v(
|
|
531
543
|
"td",
|
|
532
544
|
{
|
|
533
|
-
className:
|
|
534
|
-
|
|
535
|
-
|
|
545
|
+
className: H(
|
|
546
|
+
c?.rowHeader,
|
|
547
|
+
n[m].className
|
|
536
548
|
),
|
|
537
|
-
style:
|
|
538
|
-
title:
|
|
539
|
-
children:
|
|
549
|
+
style: S(n[m].className),
|
|
550
|
+
title: n[m].description,
|
|
551
|
+
children: n[m].label
|
|
540
552
|
}
|
|
541
553
|
),
|
|
542
|
-
|
|
543
|
-
const
|
|
554
|
+
e.map((E, z) => {
|
|
555
|
+
const B = { row: m, col: z }, A = p(B), I = r(B), $ = D(B);
|
|
544
556
|
return /* @__PURE__ */ v(
|
|
545
|
-
|
|
557
|
+
so,
|
|
546
558
|
{
|
|
547
|
-
coord:
|
|
548
|
-
value:
|
|
549
|
-
isSelected:
|
|
550
|
-
isFillTarget:
|
|
551
|
-
showFillHandle:
|
|
559
|
+
coord: B,
|
|
560
|
+
value: x(B),
|
|
561
|
+
isSelected: A,
|
|
562
|
+
isFillTarget: I,
|
|
563
|
+
showFillHandle: $ && !F,
|
|
552
564
|
onMouseDown: d,
|
|
553
|
-
onMouseEnter:
|
|
554
|
-
onChange:
|
|
555
|
-
onFillHandleMouseDown:
|
|
556
|
-
styles:
|
|
565
|
+
onMouseEnter: G,
|
|
566
|
+
onChange: N,
|
|
567
|
+
onFillHandleMouseDown: k,
|
|
568
|
+
styles: c
|
|
557
569
|
},
|
|
558
|
-
|
|
570
|
+
z
|
|
559
571
|
);
|
|
560
572
|
})
|
|
561
573
|
] }, m)) })
|
|
@@ -563,29 +575,29 @@ function mo({
|
|
|
563
575
|
}
|
|
564
576
|
);
|
|
565
577
|
}
|
|
566
|
-
function
|
|
567
|
-
const
|
|
568
|
-
return isNaN(
|
|
578
|
+
function go(o) {
|
|
579
|
+
const t = typeof o == "string" ? parseFloat(o.replace(/,/g, "")) : o;
|
|
580
|
+
return isNaN(t) ? "0" : new Intl.NumberFormat("ko-KR").format(t);
|
|
569
581
|
}
|
|
570
|
-
function
|
|
571
|
-
const
|
|
572
|
-
return isNaN(
|
|
582
|
+
function Do(o) {
|
|
583
|
+
const t = parseInt(o.replace(/,/g, ""), 10);
|
|
584
|
+
return isNaN(t) ? 0 : t;
|
|
573
585
|
}
|
|
574
586
|
export {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
587
|
+
Mo as ExcelGrid,
|
|
588
|
+
so as GridCell,
|
|
589
|
+
H as cn,
|
|
590
|
+
Co as coordToKey,
|
|
591
|
+
go as formatCurrency,
|
|
592
|
+
So as getCellsInRange,
|
|
593
|
+
yo as getFillTargetCells,
|
|
594
|
+
X as isCellInRange,
|
|
595
|
+
xo as keyToCoord,
|
|
596
|
+
j as normalizeRange,
|
|
597
|
+
Do as parseCurrency,
|
|
598
|
+
_ as parseTSV,
|
|
599
|
+
J as toTSV,
|
|
600
|
+
Y as useGridClipboard,
|
|
601
|
+
oo as useGridDragFill,
|
|
602
|
+
Q as useGridSelection
|
|
591
603
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(m,
|
|
2
|
-
`)}function j(l){return!l.start||!l.end?l:{start:{row:Math.min(l.start.row,l.end.row),col:Math.min(l.start.col,l.end.col)},end:{row:Math.max(l.start.row,l.end.row),col:Math.max(l.start.col,l.end.col)}}}function Q(l,o){if(l.row===o.row&&l.col===o.col)return[];const e=Math.min(l.row,o.row),c=Math.max(l.row,o.row),f=Math.min(l.col,o.col),S=Math.max(l.col,o.col),
|
|
1
|
+
(function(m,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],y):(m=typeof globalThis<"u"?globalThis:m||self,y(m.ReactExcelLite={},m.ReactJsxRuntime,m.React))})(this,(function(m,y,r){"use strict";function L(...l){return l.filter(Boolean).join(" ")}function J(l){return`${l.row}-${l.col}`}function X(l){const[o,e]=l.split("-").map(Number);return{row:o,col:e}}function _(l,o){if(!l||!o)return l?[l]:[];const e=Math.min(l.row,o.row),c=Math.max(l.row,o.row),f=Math.min(l.col,o.col),S=Math.max(l.col,o.col),i=[];for(let p=e;p<=c;p++)for(let d=f;d<=S;d++)i.push({row:p,col:d});return i}function q(l,o){if(!o.start)return!1;const e=o.end||o.start,c=Math.min(o.start.row,e.row),f=Math.max(o.start.row,e.row),S=Math.min(o.start.col,e.col),i=Math.max(o.start.col,e.col);return l.row>=c&&l.row<=f&&l.col>=S&&l.col<=i}function A(l){return l.split(/\r?\n/).filter(o=>o.trim()).map(o=>o.split(" ").map(e=>e.trim()))}function U(l){return l.map(o=>o.join(" ")).join(`
|
|
2
|
+
`)}function j(l){return!l.start||!l.end?l:{start:{row:Math.min(l.start.row,l.end.row),col:Math.min(l.start.col,l.end.col)},end:{row:Math.max(l.start.row,l.end.row),col:Math.max(l.start.col,l.end.col)}}}function Q(l,o){if(l.row===o.row&&l.col===o.col)return[];const e=Math.min(l.row,o.row),c=Math.max(l.row,o.row),f=Math.min(l.col,o.col),S=Math.max(l.col,o.col),i=[];for(let p=e;p<=c;p++)for(let d=f;d<=S;d++)p===l.row&&d===l.col||i.push({row:p,col:d});return i}function V(){const[l,o]=r.useState({start:null,end:null}),[e,c]=r.useState(!1),f=r.useCallback(u=>{o({start:u,end:u}),c(!0)},[]),S=r.useCallback(u=>{e&&o(n=>({...n,end:u}))},[e]),i=r.useCallback(()=>{c(!1)},[]),p=r.useCallback(()=>{o({start:null,end:null}),c(!1)},[]),d=r.useCallback(u=>q(u,l),[l]);return r.useEffect(()=>{const u=()=>{e&&c(!1)};return window.addEventListener("mouseup",u),()=>window.removeEventListener("mouseup",u)},[e]),{selection:l,isSelecting:e,isCellSelected:d,handleCellMouseDown:f,handleCellMouseEnter:S,handleMouseUp:i,clearSelection:p,setSelection:o}}function P({selection:l,getValue:o,setValues:e,rowCount:c,colCount:f}){const S=r.useCallback(()=>{const n=j(l);if(!n.start||!n.end)return[];const g=[];for(let k=n.start.row;k<=n.end.row;k++){const x=[];for(let D=n.start.col;D<=n.end.col;D++)x.push(o({row:k,col:D}));g.push(x)}return g},[l,o]),i=r.useCallback(async()=>{const n=S();if(n.length===0)return;const g=U(n);try{await navigator.clipboard.writeText(g)}catch(k){console.error("Clipboard copy failed:",k)}},[S]),p=r.useCallback(async()=>{if(l.start)try{const n=await navigator.clipboard.readText(),g=A(n);if(g.length===0)return;const k=l.start.row,x=l.start.col,D=[];g.forEach((h,C)=>{const w=k+C;w>=c||h.forEach((a,v)=>{const E=x+v;E>=f||D.push({coord:{row:w,col:E},value:a})})}),D.length>0&&e(D)}catch(n){console.error("Clipboard paste failed:",n)}},[l.start,e,c,f]),d=r.useCallback(()=>{const n=j(l);if(!n.start||!n.end)return;const g=[];for(let k=n.start.row;k<=n.end.row;k++)for(let x=n.start.col;x<=n.end.col;x++)g.push({coord:{row:k,col:x},value:""});g.length>0&&e(g)},[l,e]),u=r.useCallback(n=>{(n.ctrlKey||n.metaKey)&&n.key==="c"&&(n.preventDefault(),i()),(n.ctrlKey||n.metaKey)&&n.key==="v"&&(n.preventDefault(),p()),(n.key==="Backspace"||n.key==="Delete")&&(n.preventDefault(),d())},[i,p,d]);return{handleCopy:i,handlePaste:p,handleKeyDown:u}}function Y(l){if(l.trim()==="")return null;const o=Number(l);return isNaN(o)?null:o}function W(l){if(l.length===0)return null;const o=l.map(Y);if(o.some(f=>f===null))return null;const e=o;if(e.length===1)return{numbers:e,diff:0};const c=e[1]-e[0];for(let f=2;f<e.length;f++)if(e[f]-e[f-1]!==c)return{numbers:e,diff:0};return{numbers:e,diff:c}}function O({selection:l,getValue:o,setValues:e}){const[c,f]=r.useState(null),[S,i]=r.useState([]),[p,d]=r.useState(!1),[u,n]=r.useState(null),g=r.useCallback(h=>{f(h),d(!0),i([]),n(null)},[]),k=r.useCallback(h=>{if(!p||!l.start)return;const C=j(l);if(!C.start||!C.end)return;n(h);const w={row:Math.min(C.start.row,h.row),col:Math.min(C.start.col,h.col)},a={row:Math.max(C.end.row,h.row),col:Math.max(C.end.col,h.col)},v=[];for(let E=w.row;E<=a.row;E++)for(let s=w.col;s<=a.col;s++)E>=C.start.row&&E<=C.end.row&&s>=C.start.col&&s<=C.end.col||v.push({row:E,col:s});i(v)},[p,l]),x=r.useCallback(()=>{if(!l.start||S.length===0||!u){f(null),i([]),d(!1),n(null);return}const h=j(l);if(!h.start||!h.end){f(null),i([]),d(!1),n(null);return}const C=[],w=h.start,a=h.end,v=a.row-w.row+1,E=a.col-w.col+1;S.forEach(s=>{let G,z;if(s.row<w.row){const T=w.row-s.row;G=a.row-(T-1)%v}else if(s.row>a.row){const T=s.row-a.row;G=w.row+(T-1)%v}else G=s.row;if(s.col<w.col){const T=w.col-s.col;z=a.col-(T-1)%E}else if(s.col>a.col){const T=s.col-a.col;z=w.col+(T-1)%E}else z=s.col;let R=o({row:G,col:z});if(s.row!==G&&s.col>=w.col&&s.col<=a.col){const T=[];for(let M=w.row;M<=a.row;M++)T.push(o({row:M,col:s.col}));const F=W(T);if(F&&F.diff!==0){if(s.row>a.row){const M=s.row-a.row;R=String(F.numbers[F.numbers.length-1]+F.diff*M)}else if(s.row<w.row){const M=w.row-s.row;R=String(F.numbers[0]-F.diff*M)}}}if(s.col!==z&&s.row>=w.row&&s.row<=a.row){const T=[];for(let M=w.col;M<=a.col;M++)T.push(o({row:s.row,col:M}));const F=W(T);if(F&&F.diff!==0){if(s.col>a.col){const M=s.col-a.col;R=String(F.numbers[F.numbers.length-1]+F.diff*M)}else if(s.col<w.col){const M=w.col-s.col;R=String(F.numbers[0]-F.diff*M)}}}C.push({coord:s,value:R})}),C.length>0&&e(C),f(null),i([]),d(!1),n(null)},[l,S,u,o,e]),D=r.useCallback(h=>S.some(C=>C.row===h.row&&C.col===h.col),[S]);return r.useEffect(()=>{const h=()=>{p&&x()};return window.addEventListener("mouseup",h),()=>window.removeEventListener("mouseup",h)},[p,x]),{fillSource:c,fillTargets:S,isDraggingFill:p,isFillTarget:D,handleFillHandleMouseDown:g,handleCellMouseEnterForFill:k,handleFillMouseUp:x}}const Z={position:"relative",border:"1px solid #d1d5db",padding:0},ll={width:"100%",height:"100%",paddingLeft:"4px",paddingRight:"4px",paddingTop:"4px",paddingBottom:"4px",textAlign:"right",fontSize:"12px",backgroundColor:"transparent",outline:"none",cursor:"cell"},ol={position:"absolute",bottom:"-2px",right:"-2px",width:"8px",height:"8px",cursor:"crosshair",zIndex:20,backgroundColor:"#3b82f6"},el={backgroundColor:"#dbeafe",outline:"2px solid #3b82f6",outlineOffset:"-2px"},nl={backgroundColor:"#eff6ff"};function $({coord:l,value:o,isSelected:e,isFillTarget:c,showFillHandle:f,onMouseDown:S,onMouseEnter:i,onChange:p,onFillHandleMouseDown:d,styles:u}){const n=a=>{p(l,a.target.value)},g=a=>{a.target.classList.contains("fill-handle")||S(l)},k=a=>{a.stopPropagation(),a.preventDefault(),d(l)},x=!!u?.selected,D=!!u?.fillTarget,h=!!u?.fillHandle,C={...Z,...e&&!x?el:{},...c&&!D?nl:{}},w={...ol,...h?{backgroundColor:void 0}:{}};return y.jsxs("td",{className:L(u?.cell,e&&u?.selected,c&&u?.fillTarget),style:C,onMouseDown:g,onMouseEnter:()=>i(l),children:[y.jsx("input",{type:"text",value:o,onChange:n,style:ll}),f&&y.jsx("div",{className:L("fill-handle",u?.fillHandle),style:w,onMouseDown:k})]})}const tl={outline:"none",overflowX:"auto"},sl={borderCollapse:"collapse",fontSize:"12px",userSelect:"none"},rl={position:"sticky",left:0,zIndex:10,border:"1px solid #d1d5db",padding:"6px 8px",textAlign:"center",fontWeight:500},cl={border:"1px solid #d1d5db",padding:"6px 4px",textAlign:"center",fontWeight:500},il={border:"1px solid #d1d5db",padding:"4px",textAlign:"center",fontWeight:500,fontSize:"11px"},al={backgroundColor:"#f3f4f6"},ul={backgroundColor:"#dbeafe",color:"#1d4ed8"},fl={backgroundColor:"#f9fafb"};function dl({data:l,onChange:o,rowHeaders:e,colHeaders:c,className:f,rowHeaderTitle:S="",styles:i}){const p=r.useRef(null),d=l.length,u=r.useMemo(()=>c?c.reduce((t,b)=>t+b.headers.length,0):l[0]?.length??0,[c,l]),n=r.useMemo(()=>c?c.flatMap(t=>t.headers):[],[c]),g=r.useCallback(t=>t.row<0||t.row>=d||t.col<0||t.col>=u?"":l[t.row]?.[t.col]??"",[l,d,u]),k=r.useCallback((t,b)=>{const N=l.map((B,K)=>K===t.row?B.map((H,I)=>I===t.col?b:H):B);o(N)},[l,o]),x=r.useCallback(t=>{if(t.length===0)return;const b=l.map(N=>[...N]);t.forEach(({coord:N,value:B})=>{N.row>=0&&N.row<d&&N.col>=0&&N.col<u&&(b[N.row][N.col]=B)}),o(b)},[l,o,d,u]),{selection:D,isSelecting:h,isCellSelected:C,handleCellMouseDown:w,handleCellMouseEnter:a}=V(),{handleKeyDown:v}=P({selection:D,getValue:g,setValues:x,rowCount:d,colCount:u}),{isDraggingFill:E,isFillTarget:s,handleFillHandleMouseDown:G,handleCellMouseEnterForFill:z}=O({selection:D,getValue:g,setValues:x}),R=r.useCallback(t=>{E?z(t):h&&a(t)},[E,h,z,a]),T=r.useCallback((t,b)=>{k(t,b)},[k]),F=r.useCallback(t=>{if(!D.start)return!1;const b=j(D);return!b.start||!b.end?!1:t.row===b.end.row&&t.col===b.end.col},[D]),M=t=>({...rl,...!t&&!i?.rowHeader?al:{}}),pl=t=>({...cl,...!t&&!i?.colGroup?ul:{}}),ml=t=>({...il,...!t&&!i?.colHeader?fl:{}});return y.jsx("div",{ref:p,className:f,style:tl,tabIndex:0,onKeyDown:v,children:y.jsxs("table",{style:sl,children:[y.jsxs("thead",{children:[c&&y.jsxs("tr",{children:[e&&y.jsx("th",{className:i?.rowHeader,style:M(),children:S}),c.map((t,b)=>y.jsx("th",{colSpan:t.headers.length,className:L(i?.colGroup,t.className),style:pl(t.className),children:t.label},b))]}),c&&y.jsxs("tr",{children:[e&&y.jsx("th",{className:i?.rowHeader,style:M()}),n.map(t=>y.jsx("th",{className:L(i?.colHeader,t.className),style:ml(t.className),title:t.description,children:t.label},t.key))]})]}),y.jsx("tbody",{children:l.map((t,b)=>y.jsxs("tr",{children:[e&&e[b]&&y.jsx("td",{className:L(i?.rowHeader,e[b].className),style:M(e[b].className),title:e[b].description,children:e[b].label}),t.map((N,B)=>{const K={row:b,col:B},H=C(K),I=s(K),Cl=F(K);return y.jsx($,{coord:K,value:g(K),isSelected:H,isFillTarget:I,showFillHandle:Cl&&!E,onMouseDown:w,onMouseEnter:R,onChange:T,onFillHandleMouseDown:G,styles:i},B)})]},b))})]})})}function wl(l){const o=typeof l=="string"?parseFloat(l.replace(/,/g,"")):l;return isNaN(o)?"0":new Intl.NumberFormat("ko-KR").format(o)}function hl(l){const o=parseInt(l.replace(/,/g,""),10);return isNaN(o)?0:o}m.ExcelGrid=dl,m.GridCell=$,m.cn=L,m.coordToKey=J,m.formatCurrency=wl,m.getCellsInRange=_,m.getFillTargetCells=Q,m.isCellInRange=q,m.keyToCoord=X,m.normalizeRange=j,m.parseCurrency=hl,m.parseTSV=A,m.toTSV=U,m.useGridClipboard=P,m.useGridDragFill=O,m.useGridSelection=V,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-excel-lite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "A lightweight, Excel-like editable grid component for React with cell selection, copy/paste, auto-fill with arithmetic sequence detection, and customizable styling.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|