@gridsheet/core 3.0.0-rc.8
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 +17 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +28 -0
- package/dist/constants.js.map +1 -0
- package/dist/formula/evaluator.d.ts +134 -0
- package/dist/formula/evaluator.d.ts.map +1 -0
- package/dist/formula/evaluator.js +585 -0
- package/dist/formula/evaluator.js.map +1 -0
- package/dist/formula/formula-error.d.ts +10 -0
- package/dist/formula/formula-error.d.ts.map +1 -0
- package/dist/formula/formula-error.js +15 -0
- package/dist/formula/formula-error.js.map +1 -0
- package/dist/formula/functions/__async.d.ts +67 -0
- package/dist/formula/functions/__async.d.ts.map +1 -0
- package/dist/formula/functions/__async.js +70 -0
- package/dist/formula/functions/__async.js.map +1 -0
- package/dist/formula/functions/__base.d.ts +112 -0
- package/dist/formula/functions/__base.d.ts.map +1 -0
- package/dist/formula/functions/__base.js +265 -0
- package/dist/formula/functions/__base.js.map +1 -0
- package/dist/formula/functions/__utils.d.ts +28 -0
- package/dist/formula/functions/__utils.d.ts.map +1 -0
- package/dist/formula/functions/__utils.js +179 -0
- package/dist/formula/functions/__utils.js.map +1 -0
- package/dist/formula/functions/abs.d.ts +9 -0
- package/dist/formula/functions/abs.d.ts.map +1 -0
- package/dist/formula/functions/abs.js +15 -0
- package/dist/formula/functions/abs.js.map +1 -0
- package/dist/formula/functions/add.d.ts +10 -0
- package/dist/formula/functions/add.d.ts.map +1 -0
- package/dist/formula/functions/add.js +37 -0
- package/dist/formula/functions/add.js.map +1 -0
- package/dist/formula/functions/and.d.ts +9 -0
- package/dist/formula/functions/and.d.ts.map +1 -0
- package/dist/formula/functions/and.js +23 -0
- package/dist/formula/functions/and.js.map +1 -0
- package/dist/formula/functions/arrayformula.d.ts +12 -0
- package/dist/formula/functions/arrayformula.d.ts.map +1 -0
- package/dist/formula/functions/arrayformula.js +24 -0
- package/dist/formula/functions/arrayformula.js.map +1 -0
- package/dist/formula/functions/average.d.ts +9 -0
- package/dist/formula/functions/average.d.ts.map +1 -0
- package/dist/formula/functions/average.js +40 -0
- package/dist/formula/functions/average.js.map +1 -0
- package/dist/formula/functions/concat.d.ts +9 -0
- package/dist/formula/functions/concat.d.ts.map +1 -0
- package/dist/formula/functions/concat.js +27 -0
- package/dist/formula/functions/concat.js.map +1 -0
- package/dist/formula/functions/count.d.ts +9 -0
- package/dist/formula/functions/count.d.ts.map +1 -0
- package/dist/formula/functions/count.js +32 -0
- package/dist/formula/functions/count.js.map +1 -0
- package/dist/formula/functions/counta.d.ts +9 -0
- package/dist/formula/functions/counta.d.ts.map +1 -0
- package/dist/formula/functions/counta.js +32 -0
- package/dist/formula/functions/counta.js.map +1 -0
- package/dist/formula/functions/divide.d.ts +10 -0
- package/dist/formula/functions/divide.d.ts.map +1 -0
- package/dist/formula/functions/divide.js +34 -0
- package/dist/formula/functions/divide.js.map +1 -0
- package/dist/formula/functions/eq.d.ts +9 -0
- package/dist/formula/functions/eq.d.ts.map +1 -0
- package/dist/formula/functions/eq.js +19 -0
- package/dist/formula/functions/eq.js.map +1 -0
- package/dist/formula/functions/gt.d.ts +9 -0
- package/dist/formula/functions/gt.d.ts.map +1 -0
- package/dist/formula/functions/gt.js +19 -0
- package/dist/formula/functions/gt.js.map +1 -0
- package/dist/formula/functions/gte.d.ts +9 -0
- package/dist/formula/functions/gte.d.ts.map +1 -0
- package/dist/formula/functions/gte.js +19 -0
- package/dist/formula/functions/gte.js.map +1 -0
- package/dist/formula/functions/if.d.ts +9 -0
- package/dist/formula/functions/if.d.ts.map +1 -0
- package/dist/formula/functions/if.js +29 -0
- package/dist/formula/functions/if.js.map +1 -0
- package/dist/formula/functions/iferror.d.ts +10 -0
- package/dist/formula/functions/iferror.d.ts.map +1 -0
- package/dist/formula/functions/iferror.js +28 -0
- package/dist/formula/functions/iferror.js.map +1 -0
- package/dist/formula/functions/len.d.ts +9 -0
- package/dist/formula/functions/len.d.ts.map +1 -0
- package/dist/formula/functions/len.js +21 -0
- package/dist/formula/functions/len.js.map +1 -0
- package/dist/formula/functions/lt.d.ts +9 -0
- package/dist/formula/functions/lt.d.ts.map +1 -0
- package/dist/formula/functions/lt.js +19 -0
- package/dist/formula/functions/lt.js.map +1 -0
- package/dist/formula/functions/lte.d.ts +9 -0
- package/dist/formula/functions/lte.d.ts.map +1 -0
- package/dist/formula/functions/lte.js +19 -0
- package/dist/formula/functions/lte.js.map +1 -0
- package/dist/formula/functions/max.d.ts +9 -0
- package/dist/formula/functions/max.d.ts.map +1 -0
- package/dist/formula/functions/max.js +37 -0
- package/dist/formula/functions/max.js.map +1 -0
- package/dist/formula/functions/min.d.ts +9 -0
- package/dist/formula/functions/min.d.ts.map +1 -0
- package/dist/formula/functions/min.js +37 -0
- package/dist/formula/functions/min.js.map +1 -0
- package/dist/formula/functions/minus.d.ts +10 -0
- package/dist/formula/functions/minus.d.ts.map +1 -0
- package/dist/formula/functions/minus.js +41 -0
- package/dist/formula/functions/minus.js.map +1 -0
- package/dist/formula/functions/multiply.d.ts +9 -0
- package/dist/formula/functions/multiply.d.ts.map +1 -0
- package/dist/formula/functions/multiply.js +19 -0
- package/dist/formula/functions/multiply.js.map +1 -0
- package/dist/formula/functions/ne.d.ts +9 -0
- package/dist/formula/functions/ne.d.ts.map +1 -0
- package/dist/formula/functions/ne.js +19 -0
- package/dist/formula/functions/ne.js.map +1 -0
- package/dist/formula/functions/not.d.ts +9 -0
- package/dist/formula/functions/not.d.ts.map +1 -0
- package/dist/formula/functions/not.js +22 -0
- package/dist/formula/functions/not.js.map +1 -0
- package/dist/formula/functions/now.d.ts +9 -0
- package/dist/formula/functions/now.d.ts.map +1 -0
- package/dist/formula/functions/now.js +14 -0
- package/dist/formula/functions/now.js.map +1 -0
- package/dist/formula/functions/or.d.ts +9 -0
- package/dist/formula/functions/or.d.ts.map +1 -0
- package/dist/formula/functions/or.js +23 -0
- package/dist/formula/functions/or.js.map +1 -0
- package/dist/formula/functions/power.d.ts +9 -0
- package/dist/formula/functions/power.d.ts.map +1 -0
- package/dist/formula/functions/power.js +18 -0
- package/dist/formula/functions/power.js.map +1 -0
- package/dist/formula/functions/sum.d.ts +9 -0
- package/dist/formula/functions/sum.d.ts.map +1 -0
- package/dist/formula/functions/sum.js +34 -0
- package/dist/formula/functions/sum.js.map +1 -0
- package/dist/formula/functions/uminus.d.ts +9 -0
- package/dist/formula/functions/uminus.d.ts.map +1 -0
- package/dist/formula/functions/uminus.js +17 -0
- package/dist/formula/functions/uminus.js.map +1 -0
- package/dist/formula/mapping.d.ts +11 -0
- package/dist/formula/mapping.d.ts.map +1 -0
- package/dist/formula/mapping.js +82 -0
- package/dist/formula/mapping.js.map +1 -0
- package/dist/formula/solver.d.ts +39 -0
- package/dist/formula/solver.d.ts.map +1 -0
- package/dist/formula/solver.js +71 -0
- package/dist/formula/solver.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/autofill.d.ts +22 -0
- package/dist/lib/autofill.d.ts.map +1 -0
- package/dist/lib/autofill.js +276 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/book.d.ts +131 -0
- package/dist/lib/book.d.ts.map +1 -0
- package/dist/lib/book.js +53 -0
- package/dist/lib/book.js.map +1 -0
- package/dist/lib/cell.d.ts +17 -0
- package/dist/lib/cell.d.ts.map +1 -0
- package/dist/lib/cell.js +17 -0
- package/dist/lib/cell.js.map +1 -0
- package/dist/lib/coords.d.ts +22 -0
- package/dist/lib/coords.d.ts.map +1 -0
- package/dist/lib/coords.js +73 -0
- package/dist/lib/coords.js.map +1 -0
- package/dist/lib/date.d.ts +2 -0
- package/dist/lib/date.d.ts.map +1 -0
- package/dist/lib/date.js +91 -0
- package/dist/lib/date.js.map +1 -0
- package/dist/lib/dom.d.ts +7 -0
- package/dist/lib/dom.d.ts.map +1 -0
- package/dist/lib/dom.js +28 -0
- package/dist/lib/dom.js.map +1 -0
- package/dist/lib/filter.d.ts +7 -0
- package/dist/lib/filter.d.ts.map +1 -0
- package/dist/lib/filter.js +122 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/input.d.ts +28 -0
- package/dist/lib/input.d.ts.map +1 -0
- package/dist/lib/input.js +73 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/label.d.ts +4 -0
- package/dist/lib/label.d.ts.map +1 -0
- package/dist/lib/label.js +10 -0
- package/dist/lib/label.js.map +1 -0
- package/dist/lib/operation.d.ts +31 -0
- package/dist/lib/operation.d.ts.map +1 -0
- package/dist/lib/operation.js +36 -0
- package/dist/lib/operation.js.map +1 -0
- package/dist/lib/palette.d.ts +2 -0
- package/dist/lib/palette.d.ts.map +1 -0
- package/dist/lib/palette.js +26 -0
- package/dist/lib/palette.js.map +1 -0
- package/dist/lib/popup.d.ts +24 -0
- package/dist/lib/popup.d.ts.map +1 -0
- package/dist/lib/popup.js +21 -0
- package/dist/lib/popup.js.map +1 -0
- package/dist/lib/reference.d.ts +19 -0
- package/dist/lib/reference.d.ts.map +1 -0
- package/dist/lib/reference.js +40 -0
- package/dist/lib/reference.js.map +1 -0
- package/dist/lib/sheet.d.ts +512 -0
- package/dist/lib/sheet.d.ts.map +1 -0
- package/dist/lib/sheet.js +1530 -0
- package/dist/lib/sheet.js.map +1 -0
- package/dist/lib/sheet_utils.d.ts +55 -0
- package/dist/lib/sheet_utils.d.ts.map +1 -0
- package/dist/lib/sheet_utils.js +125 -0
- package/dist/lib/sheet_utils.js.map +1 -0
- package/dist/lib/spatial.d.ts +79 -0
- package/dist/lib/spatial.d.ts.map +1 -0
- package/dist/lib/spatial.js +227 -0
- package/dist/lib/spatial.js.map +1 -0
- package/dist/lib/time.d.ts +29 -0
- package/dist/lib/time.d.ts.map +1 -0
- package/dist/lib/time.js +113 -0
- package/dist/lib/time.js.map +1 -0
- package/dist/lib/virtualization.d.ts +22 -0
- package/dist/lib/virtualization.d.ts.map +1 -0
- package/dist/lib/virtualization.js +91 -0
- package/dist/lib/virtualization.js.map +1 -0
- package/dist/policy/core.d.ts +161 -0
- package/dist/policy/core.d.ts.map +1 -0
- package/dist/policy/core.js +248 -0
- package/dist/policy/core.js.map +1 -0
- package/dist/policy/thousand_separator.d.ts +4 -0
- package/dist/policy/thousand_separator.d.ts.map +1 -0
- package/dist/policy/thousand_separator.js +13 -0
- package/dist/policy/thousand_separator.js.map +1 -0
- package/dist/sentinels.d.ts +40 -0
- package/dist/sentinels.d.ts.map +1 -0
- package/dist/sentinels.js +41 -0
- package/dist/sentinels.js.map +1 -0
- package/dist/styles/embedder.d.ts +2 -0
- package/dist/styles/embedder.d.ts.map +1 -0
- package/dist/styles/embedder.js +11 -0
- package/dist/styles/embedder.js.map +1 -0
- package/dist/styles/minified.d.ts +3 -0
- package/dist/styles/minified.d.ts.map +1 -0
- package/dist/styles/minified.js +6 -0
- package/dist/styles/minified.js.map +1 -0
- package/dist/types.d.ts +310 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +5 -0
- package/dist/utils.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { DEFAULT_ALPHABET_CACHE_SIZE as $ } from "../constants.js";
|
|
2
|
+
const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), m = (t, e = $) => {
|
|
3
|
+
const n = l.get(--t);
|
|
4
|
+
if (n != null)
|
|
5
|
+
return n;
|
|
6
|
+
if (t === 0)
|
|
7
|
+
return "";
|
|
8
|
+
let r = t, s = "";
|
|
9
|
+
do
|
|
10
|
+
s = i[--r % 26] + s, r = Math.floor(r / 26);
|
|
11
|
+
while (r > 0);
|
|
12
|
+
l.set(t, s);
|
|
13
|
+
const o = l.keys();
|
|
14
|
+
for (let c = o.next(); l.size > e; c = o.next())
|
|
15
|
+
l.delete(c.value);
|
|
16
|
+
return s;
|
|
17
|
+
}, A = (t, e = $) => {
|
|
18
|
+
const n = u.get(t);
|
|
19
|
+
if (n != null)
|
|
20
|
+
return n;
|
|
21
|
+
if (t === "")
|
|
22
|
+
return 0;
|
|
23
|
+
const r = t;
|
|
24
|
+
let s = 0;
|
|
25
|
+
for (let c = 0; c < r.length; c++) {
|
|
26
|
+
const a = r[r.length - c - 1], p = i.indexOf(a) + 1;
|
|
27
|
+
s += i.length ** c * p;
|
|
28
|
+
}
|
|
29
|
+
u.set(t, s);
|
|
30
|
+
const o = u.keys();
|
|
31
|
+
for (let c = o.next(); u.size > e; c = o.next())
|
|
32
|
+
u.delete(c.value);
|
|
33
|
+
return s;
|
|
34
|
+
}, f = (t) => {
|
|
35
|
+
if (t === 0)
|
|
36
|
+
return "";
|
|
37
|
+
const e = m(t + 1);
|
|
38
|
+
return t < 0 ? `$${e}` : e;
|
|
39
|
+
}, d = (t, e = !1) => {
|
|
40
|
+
const n = A(t.toUpperCase());
|
|
41
|
+
return e ? -n : n;
|
|
42
|
+
}, C = (t) => t === 0 ? "" : t < 0 ? `$${t}` : String(t), b = (t, e = !1) => (typeof t == "string" && (t = parseInt(t, 10)), e ? -t : t), h = ({ y: t, x: e, absX: n, absY: r }) => {
|
|
43
|
+
if (e === -1 && t === -1)
|
|
44
|
+
return "?";
|
|
45
|
+
const s = e === void 0 ? "" : e === 0 ? "0" : `${n ? "$" : ""}${f(e)}`, o = t === void 0 ? "" : t === 0 ? "0" : `${r ? "$" : ""}${C(t)}`;
|
|
46
|
+
return `${s}${o}`;
|
|
47
|
+
}, E = (t) => {
|
|
48
|
+
const e = t.match(/(\$)?([a-zA-Z]*)(\$)?([0-9]*)/);
|
|
49
|
+
if (e == null)
|
|
50
|
+
return { y: -1, x: -1 };
|
|
51
|
+
const [, n, r, s, o] = e.slice(), [c, a] = [n != null, s != null];
|
|
52
|
+
return r === "" && o === "" ? { y: -1, x: -1, absX: !1, absY: !1 } : { y: b(o) || 0, x: d(r) || 0, absX: c, absY: a };
|
|
53
|
+
}, _ = (t, e, n) => {
|
|
54
|
+
const r = t.match(/([A-Z]*)([0-9]*)/);
|
|
55
|
+
if (r == null)
|
|
56
|
+
return t;
|
|
57
|
+
const [, s, o] = r.slice();
|
|
58
|
+
return `${e ? "$" : ""}${s.toUpperCase()}${n ? "$" : ""}${o}`;
|
|
59
|
+
}, x = (t) => `0${t}`, H = (t) => typeof t == "number" ? `${f(t)}0` : `${t.toUpperCase()}0`, L = (t) => t.replace(/\$/g, ""), N = (t, e = !1, n = !1) => `${e ? "$" : ""}#${t}${n ? "$" : ""}`;
|
|
60
|
+
export {
|
|
61
|
+
E as a2p,
|
|
62
|
+
N as buildIdentifiedRef,
|
|
63
|
+
d as c2x,
|
|
64
|
+
H as ch,
|
|
65
|
+
_ as grantAddressAbsolute,
|
|
66
|
+
h as p2a,
|
|
67
|
+
b as r2y,
|
|
68
|
+
x as rh,
|
|
69
|
+
L as stripAddressAbsolute,
|
|
70
|
+
f as x2c,
|
|
71
|
+
C as y2r
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=coords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coords.js","sources":["../../src/lib/coords.ts"],"sourcesContent":["import type { Address, PointType, ExtraPointType } from '../types';\nimport { DEFAULT_ALPHABET_CACHE_SIZE } from '../constants';\n\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\nconst N2C_CACHE = new Map<number, string>();\nconst C2N_CACHE = new Map<string, number>();\n\nconst getColumnLetterFromNumber = (key: number, cacheSize = DEFAULT_ALPHABET_CACHE_SIZE): string => {\n const cached = N2C_CACHE.get(--key);\n if (cached != null) {\n return cached;\n }\n if (key === 0) {\n return '';\n }\n let num = key;\n let result = '';\n do {\n result = ALPHABET[--num % 26] + result;\n num = Math.floor(num / 26);\n } while (num > 0);\n\n N2C_CACHE.set(key, result);\n const it = N2C_CACHE.keys();\n for (let st = it.next(); N2C_CACHE.size > cacheSize; st = it.next()) {\n // @ts-ignore\n N2C_CACHE.delete(st.value);\n }\n return result;\n};\n\nconst getNumberFromColumnLetter = (key: string, cacheSize = DEFAULT_ALPHABET_CACHE_SIZE): number => {\n const cached = C2N_CACHE.get(key);\n if (cached != null) {\n return cached;\n }\n if (key === '') {\n return 0;\n }\n const alpha = key;\n let result = 0;\n for (let digit = 0; digit < alpha.length; digit++) {\n const a = alpha[alpha.length - digit - 1];\n const num = ALPHABET.indexOf(a) + 1;\n result += ALPHABET.length ** digit * num;\n }\n C2N_CACHE.set(key, result);\n const it = C2N_CACHE.keys();\n for (let st = it.next(); C2N_CACHE.size > cacheSize; st = it.next()) {\n // @ts-ignore\n C2N_CACHE.delete(st.value);\n }\n return result;\n};\n\nexport const x2c = (x: number): string => {\n if (x === 0) {\n return '';\n }\n const c = getColumnLetterFromNumber(x + 1);\n return x < 0 ? `$${c}` : c;\n};\n\nexport const c2x = (col: string, absolute = false): number => {\n const n = getNumberFromColumnLetter(col.toUpperCase());\n return absolute ? -n : n;\n};\n\nexport const y2r = (y: number) => {\n if (y === 0) {\n return '';\n }\n return y < 0 ? `$${y}` : String(y);\n};\n\nexport const r2y = (row: number | string, absolute = false) => {\n if (typeof row === 'string') {\n row = parseInt(row, 10);\n }\n return absolute ? -row : row;\n};\n\nexport const p2a = ({ y, x, absX, absY }: Partial<ExtraPointType>) => {\n if (x === -1 && y === -1) {\n return '?';\n }\n const colPart = x === undefined ? '' : x === 0 ? '0' : `${absX ? '$' : ''}${x2c(x)}`;\n const rowPart = y === undefined ? '' : y === 0 ? '0' : `${absY ? '$' : ''}${y2r(y)}`;\n return `${colPart}${rowPart}`;\n};\n\nexport const a2p = (address: Address): ExtraPointType => {\n const m = address.match(/(\\$)?([a-zA-Z]*)(\\$)?([0-9]*)/);\n if (m == null) {\n return { y: -1, x: -1 };\n }\n const [, _absX, col, _absY, row] = m.slice();\n const [absX, absY] = [_absX != null, _absY != null];\n if (col === '' && row === '') {\n return { y: -1, x: -1, absX: false, absY: false };\n }\n return { y: r2y(row) || 0, x: c2x(col) || 0, absX, absY };\n};\n\nexport const grantAddressAbsolute = (address: Address, absCol: boolean, absRow: boolean) => {\n const m = address.match(/([A-Z]*)([0-9]*)/);\n if (m == null) {\n return address;\n }\n const [, col, row] = m.slice();\n return `${absCol ? '$' : ''}${col.toUpperCase()}${absRow ? '$' : ''}${row}`;\n};\n\n/**\n * Returns the row header cell address for a given row number by prepending `0`.\n * e.g. rh(6) → '06', rh(1) → '01'\n */\nexport const rh = (y: number): string => `0${y}`;\n\n/**\n * Returns the column header cell address for a given column letter or column index\n * (1-based, same as point.x) by appending `0`.\n * e.g. ch('A') → 'A0', ch(1) → 'A0'\n */\nexport const ch = (col: string | number): string =>\n typeof col === 'number' ? `${x2c(col)}0` : `${col.toUpperCase()}0`;\n\nexport const stripAddressAbsolute = (address: Address) => {\n return address.replace(/\\$/g, '');\n};\n\nexport const buildIdentifiedRef = (id: string, absX = false, absY = false): string => {\n return `${absX ? '$' : ''}#${id}${absY ? '$' : ''}`;\n};\n"],"names":["ALPHABET","N2C_CACHE","C2N_CACHE","getColumnLetterFromNumber","key","cacheSize","DEFAULT_ALPHABET_CACHE_SIZE","cached","num","result","it","st","getNumberFromColumnLetter","alpha","digit","x2c","x","c","c2x","col","absolute","y2r","y","r2y","row","p2a","absX","absY","colPart","rowPart","a2p","address","m","_absX","_absY","grantAddressAbsolute","absCol","absRow","rh","ch","stripAddressAbsolute","buildIdentifiedRef","id"],"mappings":";AAGA,MAAMA,IAAW,8BAEXC,wBAAgB,IAAoB,GACpCC,wBAAgB,IAAoB,GAEpCC,IAA4B,CAACC,GAAaC,IAAYC,MAAwC;AAClG,QAAMC,IAASN,EAAU,IAAI,EAAEG,CAAG;AAClC,MAAIG,KAAU;AACL,WAAAA;AAET,MAAIH,MAAQ;AACH,WAAA;AAET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,IAAS,MAAM,EAAE,GAAGjB,EAAI,YAAa,CAAA,GAAGkB,IAAS,MAAM,EAAE,GAAGb,CAAG;AAC3E,GAMac,IAAK,CAAChB,MAAsB,IAAIA,CAAC,IAOjCiB,IAAK,CAACpB,MACjB,OAAOA,KAAQ,WAAW,GAAGJ,EAAII,CAAG,CAAC,MAAM,GAAGA,EAAI,YAAa,CAAA,KAEpDqB,IAAuB,CAACT,MAC5BA,EAAQ,QAAQ,OAAO,EAAE,GAGrBU,IAAqB,CAACC,GAAYhB,IAAO,IAAOC,IAAO,OAC3D,GAAGD,IAAO,MAAM,EAAE,IAAIgB,CAAE,GAAGf,IAAO,MAAM,EAAE;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/lib/date.ts"],"names":[],"mappings":"AA+EA,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAyBzD"}
|
package/dist/lib/date.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import r from "dayjs";
|
|
2
|
+
import c from "dayjs/plugin/utc.js";
|
|
3
|
+
import d from "dayjs/plugin/timezone.js";
|
|
4
|
+
r.extend(d);
|
|
5
|
+
r.extend(c);
|
|
6
|
+
const o = /* @__PURE__ */ new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]), m = /* @__PURE__ */ new Set([...o, "Z", "z"]), i = /* @__PURE__ */ new Set(["J", "F", "M", "A", "S", "O", "N", "D", ...o]), u = /* @__PURE__ */ new Set(["N", "B", "R", "Y", "N", "L", "G", "P", "T", "V", "C", ...m]), p = /* @__PURE__ */ new Set([
|
|
7
|
+
"jan",
|
|
8
|
+
"feb",
|
|
9
|
+
"mar",
|
|
10
|
+
"apr",
|
|
11
|
+
"may",
|
|
12
|
+
"jun",
|
|
13
|
+
"jul",
|
|
14
|
+
"aug",
|
|
15
|
+
"sep",
|
|
16
|
+
"oct",
|
|
17
|
+
"nov",
|
|
18
|
+
"dec",
|
|
19
|
+
"january",
|
|
20
|
+
"february",
|
|
21
|
+
"march",
|
|
22
|
+
"april",
|
|
23
|
+
"june",
|
|
24
|
+
"july",
|
|
25
|
+
"august",
|
|
26
|
+
"september",
|
|
27
|
+
"october",
|
|
28
|
+
"november",
|
|
29
|
+
"december",
|
|
30
|
+
"mon",
|
|
31
|
+
"tue",
|
|
32
|
+
"wed",
|
|
33
|
+
"thu",
|
|
34
|
+
"fri",
|
|
35
|
+
"sat",
|
|
36
|
+
"sun",
|
|
37
|
+
"monday",
|
|
38
|
+
"tuesday",
|
|
39
|
+
"wednesday",
|
|
40
|
+
"thursday",
|
|
41
|
+
"friday",
|
|
42
|
+
"saturday",
|
|
43
|
+
"sunday",
|
|
44
|
+
"am",
|
|
45
|
+
"pm",
|
|
46
|
+
"utc",
|
|
47
|
+
"gmt",
|
|
48
|
+
"est",
|
|
49
|
+
"cst",
|
|
50
|
+
"mst",
|
|
51
|
+
"pst",
|
|
52
|
+
"jst",
|
|
53
|
+
"cet",
|
|
54
|
+
"eet",
|
|
55
|
+
"ist",
|
|
56
|
+
"aest",
|
|
57
|
+
"edt",
|
|
58
|
+
"cdt",
|
|
59
|
+
"mdt",
|
|
60
|
+
"pdt",
|
|
61
|
+
"bst",
|
|
62
|
+
"hst",
|
|
63
|
+
"akst",
|
|
64
|
+
"akdt",
|
|
65
|
+
"nzst",
|
|
66
|
+
"nzdt",
|
|
67
|
+
"t",
|
|
68
|
+
"z"
|
|
69
|
+
]);
|
|
70
|
+
function w(t) {
|
|
71
|
+
const n = t[0];
|
|
72
|
+
if (n == null || !i.has(n.toUpperCase()) || !u.has(t[t.length - 1].toUpperCase()) || t.match(/[=*&#@!?[\]{}"'()|%\\<>~+\r\n]/))
|
|
73
|
+
return;
|
|
74
|
+
const a = t.split(/[\s,/\-:.]+/).filter(Boolean);
|
|
75
|
+
for (const e of a)
|
|
76
|
+
if (/^[a-zA-Z]+$/.test(e) && !p.has(e.toLowerCase()))
|
|
77
|
+
return;
|
|
78
|
+
let s = "UTC";
|
|
79
|
+
try {
|
|
80
|
+
s = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
return r.tz(t, s).toDate();
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
w as parseDate
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sources":["../../src/lib/date.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc.js';\nimport timezone from 'dayjs/plugin/timezone.js';\ndayjs.extend(timezone);\ndayjs.extend(utc);\n\nconst NUMS = new Set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']);\nconst NUMS_Z = new Set([...NUMS, 'Z', 'z']);\nconst JFMASOND = new Set(['J', 'F', 'M', 'A', 'S', 'O', 'N', 'D', ...NUMS]);\nconst NBRYNLGPTVC = new Set(['N', 'B', 'R', 'Y', 'N', 'L', 'G', 'P', 'T', 'V', 'C', ...NUMS_Z]);\n\n// Reject strings that contain words not typically found in date representations.\n// Date strings consist of month names, digits, separators, and timezone abbreviations.\n// If a word is purely alphabetic and not a recognized date token, it's likely not a date.\nconst DATE_WORDS = new Set([\n 'jan',\n 'feb',\n 'mar',\n 'apr',\n 'may',\n 'jun',\n 'jul',\n 'aug',\n 'sep',\n 'oct',\n 'nov',\n 'dec',\n 'january',\n 'february',\n 'march',\n 'april',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n 'mon',\n 'tue',\n 'wed',\n 'thu',\n 'fri',\n 'sat',\n 'sun',\n 'monday',\n 'tuesday',\n 'wednesday',\n 'thursday',\n 'friday',\n 'saturday',\n 'sunday',\n 'am',\n 'pm',\n 'utc',\n 'gmt',\n 'est',\n 'cst',\n 'mst',\n 'pst',\n 'jst',\n 'cet',\n 'eet',\n 'ist',\n 'aest',\n 'edt',\n 'cdt',\n 'mdt',\n 'pdt',\n 'bst',\n 'hst',\n 'akst',\n 'akdt',\n 'nzst',\n 'nzdt',\n 't',\n 'z',\n]);\n\nexport function parseDate(value: string): Date | undefined {\n const first = value[0];\n if (first == null || !JFMASOND.has(first.toUpperCase())) {\n return;\n }\n if (!NBRYNLGPTVC.has(value[value.length - 1].toUpperCase())) {\n return;\n }\n if (value.match(/[=*&#@!?[\\]{}\"'()|%\\\\<>~+\\r\\n]/)) {\n return;\n }\n const words = value.split(/[\\s,/\\-:.]+/).filter(Boolean);\n for (const word of words) {\n if (/^[a-zA-Z]+$/.test(word) && !DATE_WORDS.has(word.toLowerCase())) {\n return;\n }\n }\n let timeZone = 'UTC';\n try {\n timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch (e) {}\n try {\n const day = dayjs.tz(value, timeZone);\n return day.toDate();\n } catch (e) {}\n}\n"],"names":["dayjs","timezone","utc","NUMS","NUMS_Z","JFMASOND","NBRYNLGPTVC","DATE_WORDS","parseDate","value","first","words","word","timeZone"],"mappings":";;;AAGAA,EAAM,OAAOC,CAAQ;AACrBD,EAAM,OAAOE,CAAG;AAEhB,MAAMC,IAAO,oBAAI,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG,CAAC,GACjEC,wBAAa,IAAI,CAAC,GAAGD,GAAM,KAAK,GAAG,CAAC,GACpCE,IAAW,oBAAI,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAGF,CAAI,CAAC,GACpEG,IAAkB,oBAAA,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAGF,CAAM,CAAC,GAKxFG,wBAAiB,IAAI;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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,7 @@
|
|
|
1
|
+
export declare const focus: (el: HTMLElement | null | undefined) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Prevents Safari elastic bounce (rubber-band) at scroll boundaries.
|
|
4
|
+
* No-op on non-Safari browsers. Returns a cleanup function to remove the listeners.
|
|
5
|
+
*/
|
|
6
|
+
export declare const preventSafariBounce: (el: HTMLDivElement) => (() => void);
|
|
7
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/lib/dom.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,GAAI,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,SAEvD,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,IAAI,cAAc,KAAG,CAAC,MAAM,IAAI,CAmDnE,CAAC"}
|
package/dist/lib/dom.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const E = (e) => {
|
|
2
|
+
e == null || e.focus({ preventScroll: !0 });
|
|
3
|
+
}, B = () => typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent), S = (e) => {
|
|
4
|
+
if (!B())
|
|
5
|
+
return () => {
|
|
6
|
+
};
|
|
7
|
+
const d = (t) => {
|
|
8
|
+
const { scrollTop: o, scrollHeight: r, clientHeight: i, scrollLeft: n, scrollWidth: a, clientWidth: l } = e, c = t.deltaY < 0 && o <= 0, s = t.deltaY > 0 && o + i >= r, h = t.deltaX < 0 && n <= 0, u = t.deltaX > 0 && n + l >= a;
|
|
9
|
+
(c || s || h || u) && (t.preventDefault(), window.scrollBy({ top: t.deltaY, left: t.deltaX, behavior: "auto" }));
|
|
10
|
+
};
|
|
11
|
+
let v = 0, f = 0;
|
|
12
|
+
const p = (t) => {
|
|
13
|
+
t.touches.length === 1 && (v = t.touches[0].clientX, f = t.touches[0].clientY);
|
|
14
|
+
}, g = (t) => {
|
|
15
|
+
if (t.touches.length !== 1)
|
|
16
|
+
return;
|
|
17
|
+
const { scrollTop: o, scrollHeight: r, clientHeight: i, scrollLeft: n, scrollWidth: a, clientWidth: l } = e, c = t.touches[0].clientX - v, s = t.touches[0].clientY - f, h = s > 0 && o <= 0, u = s < 0 && o + i >= r, L = c > 0 && n <= 0, m = c < 0 && n + l >= a;
|
|
18
|
+
(h || u || L || m) && t.preventDefault();
|
|
19
|
+
};
|
|
20
|
+
return e.addEventListener("wheel", d, { passive: !1 }), e.addEventListener("touchstart", p, { passive: !0 }), e.addEventListener("touchmove", g, { passive: !1 }), () => {
|
|
21
|
+
e.removeEventListener("wheel", d), e.removeEventListener("touchstart", p), e.removeEventListener("touchmove", g);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
E as focus,
|
|
26
|
+
S as preventSafariBounce
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.js","sources":["../../src/lib/dom.ts"],"sourcesContent":["export const focus = (el: HTMLElement | null | undefined) => {\n el?.focus({ preventScroll: true });\n};\n\nconst isSafari = (): boolean =>\n typeof navigator !== 'undefined' && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n\n/**\n * Prevents Safari elastic bounce (rubber-band) at scroll boundaries.\n * No-op on non-Safari browsers. Returns a cleanup function to remove the listeners.\n */\nexport const preventSafariBounce = (el: HTMLDivElement): (() => void) => {\n if (!isSafari()) {\n return () => {};\n }\n const preventBounce = (e: WheelEvent) => {\n const { scrollTop, scrollHeight, clientHeight, scrollLeft, scrollWidth, clientWidth } = el;\n const atTop = e.deltaY < 0 && scrollTop <= 0;\n const atBottom = e.deltaY > 0 && scrollTop + clientHeight >= scrollHeight;\n const atLeft = e.deltaX < 0 && scrollLeft <= 0;\n const atRight = e.deltaX > 0 && scrollLeft + clientWidth >= scrollWidth;\n if (atTop || atBottom || atLeft || atRight) {\n e.preventDefault();\n window.scrollBy({ top: e.deltaY, left: e.deltaX, behavior: 'auto' });\n }\n };\n\n let touchStartX = 0;\n let touchStartY = 0;\n\n const onTouchStart = (e: TouchEvent) => {\n if (e.touches.length === 1) {\n touchStartX = e.touches[0].clientX;\n touchStartY = e.touches[0].clientY;\n }\n };\n\n const preventTouchBounce = (e: TouchEvent) => {\n if (e.touches.length !== 1) {\n return;\n }\n const { scrollTop, scrollHeight, clientHeight, scrollLeft, scrollWidth, clientWidth } = el;\n const dx = e.touches[0].clientX - touchStartX;\n const dy = e.touches[0].clientY - touchStartY;\n const atTop = dy > 0 && scrollTop <= 0;\n const atBottom = dy < 0 && scrollTop + clientHeight >= scrollHeight;\n const atLeft = dx > 0 && scrollLeft <= 0;\n const atRight = dx < 0 && scrollLeft + clientWidth >= scrollWidth;\n if (atTop || atBottom || atLeft || atRight) {\n e.preventDefault();\n }\n };\n\n el.addEventListener('wheel', preventBounce, { passive: false });\n el.addEventListener('touchstart', onTouchStart, { passive: true });\n el.addEventListener('touchmove', preventTouchBounce, { passive: false });\n\n return () => {\n el.removeEventListener('wheel', preventBounce);\n el.removeEventListener('touchstart', onTouchStart);\n el.removeEventListener('touchmove', preventTouchBounce);\n };\n};\n"],"names":["focus","el","isSafari","preventSafariBounce","preventBounce","e","scrollTop","scrollHeight","clientHeight","scrollLeft","scrollWidth","clientWidth","atTop","atBottom","atLeft","atRight","touchStartX","touchStartY","onTouchStart","preventTouchBounce","dx","dy"],"mappings":"AAAa,MAAAA,IAAQ,CAACC,MAAuC;AAC3D,EAAAA,KAAA,QAAAA,EAAI,MAAM,EAAE,eAAe,GAAA;AAC7B,GAEMC,IAAW,MACf,OAAO,YAAc,OAAe,iCAAiC,KAAK,UAAU,SAAS,GAMlFC,IAAsB,CAACF,MAAqC;AACnE,MAAA,CAACC;AACH,WAAO,MAAM;AAAA,IAAC;AAEV,QAAAE,IAAgB,CAACC,MAAkB;AACvC,UAAM,EAAE,WAAAC,GAAW,cAAAC,GAAc,cAAAC,G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AAAlB,EAAA,oBAAoB,SAASG,CAAa,GAC1CH,EAAA,oBAAoB,cAAciB,CAAY,GAC9CjB,EAAA,oBAAoB,aAAakB,CAAkB;AAAA,EACxD;AACF;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FilterCondition, FilterConditionMethod, FilterConfig } from '../types';
|
|
2
|
+
type FilterFunction = (condition: FilterCondition, cellValue: any) => boolean;
|
|
3
|
+
export declare const filterFunctions: Record<FilterConditionMethod, FilterFunction>;
|
|
4
|
+
export declare function evaluateFilterCondition(condition: FilterCondition, cellValue: any): boolean;
|
|
5
|
+
export declare function evaluateFilterConfig(filter: FilterConfig, cellValue: any): boolean;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIrF,KAAK,cAAc,GAAG,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,KAAK,OAAO,CAAC;AA+J9E,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,qBAAqB,EAAE,cAAc,CAWzE,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,GAAG,OAAO,CAG3F;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,GAAG,OAAO,CAUlF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { parseDate as d } from "./date.js";
|
|
2
|
+
import { Time as m } from "./time.js";
|
|
3
|
+
const o = (t) => t == null ? "" : String(t);
|
|
4
|
+
function i(t) {
|
|
5
|
+
return typeof t == "number" ? "number" : t instanceof Date ? "date" : m.is(t) ? "time" : typeof t == "boolean" ? "boolean" : "string";
|
|
6
|
+
}
|
|
7
|
+
function c(t, e) {
|
|
8
|
+
switch (e) {
|
|
9
|
+
case "number": {
|
|
10
|
+
let n = t.replace(/[,_]/g, ""), r = 1;
|
|
11
|
+
n.endsWith("%") && (n = n.slice(0, -1), r = 0.01);
|
|
12
|
+
const s = Number(n);
|
|
13
|
+
return { ok: !isNaN(s), num: s * r };
|
|
14
|
+
}
|
|
15
|
+
case "date": {
|
|
16
|
+
const n = d(t);
|
|
17
|
+
return n ? { ok: !0, num: n.getTime() } : { ok: !1, num: NaN };
|
|
18
|
+
}
|
|
19
|
+
case "time": {
|
|
20
|
+
const n = m.parse(t);
|
|
21
|
+
return n ? { ok: !0, num: n.toMilliseconds() } : { ok: !1, num: NaN };
|
|
22
|
+
}
|
|
23
|
+
case "boolean": {
|
|
24
|
+
const n = t.toLowerCase();
|
|
25
|
+
return n === "true" ? { ok: !0, num: 1 } : n === "false" ? { ok: !0, num: 0 } : { ok: !1, num: NaN };
|
|
26
|
+
}
|
|
27
|
+
default:
|
|
28
|
+
return { ok: !1, num: NaN };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function a(t, e) {
|
|
32
|
+
switch (e) {
|
|
33
|
+
case "number":
|
|
34
|
+
return t;
|
|
35
|
+
case "date":
|
|
36
|
+
return t.getTime();
|
|
37
|
+
case "time":
|
|
38
|
+
return m.ensure(t).toMilliseconds();
|
|
39
|
+
case "boolean":
|
|
40
|
+
return t ? 1 : 0;
|
|
41
|
+
default:
|
|
42
|
+
return NaN;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const N = (t, e) => {
|
|
46
|
+
const n = i(e);
|
|
47
|
+
if (n === "string") {
|
|
48
|
+
const s = o(e);
|
|
49
|
+
return t.value.some((u) => s === u);
|
|
50
|
+
}
|
|
51
|
+
const r = a(e, n);
|
|
52
|
+
return t.value.some((s) => {
|
|
53
|
+
const u = c(s, n);
|
|
54
|
+
return u.ok && r === u.num;
|
|
55
|
+
});
|
|
56
|
+
}, v = (t, e) => {
|
|
57
|
+
const n = i(e);
|
|
58
|
+
if (n === "string") {
|
|
59
|
+
const s = o(e);
|
|
60
|
+
return !t.value.some((u) => s === u);
|
|
61
|
+
}
|
|
62
|
+
const r = a(e, n);
|
|
63
|
+
return !t.value.some((s) => {
|
|
64
|
+
const u = c(s, n);
|
|
65
|
+
return u.ok && r === u.num;
|
|
66
|
+
});
|
|
67
|
+
}, k = (t, e) => {
|
|
68
|
+
const n = i(e);
|
|
69
|
+
if (n === "string")
|
|
70
|
+
return o(e) > t.value[0];
|
|
71
|
+
const r = a(e, n), s = c(t.value[0], n);
|
|
72
|
+
return s.ok && r > s.num;
|
|
73
|
+
}, p = (t, e) => {
|
|
74
|
+
const n = i(e);
|
|
75
|
+
if (n === "string")
|
|
76
|
+
return o(e) >= t.value[0];
|
|
77
|
+
const r = a(e, n), s = c(t.value[0], n);
|
|
78
|
+
return s.ok && r >= s.num;
|
|
79
|
+
}, g = (t, e) => {
|
|
80
|
+
const n = i(e);
|
|
81
|
+
if (n === "string")
|
|
82
|
+
return o(e) < t.value[0];
|
|
83
|
+
const r = a(e, n), s = c(t.value[0], n);
|
|
84
|
+
return s.ok && r < s.num;
|
|
85
|
+
}, l = (t, e) => {
|
|
86
|
+
const n = i(e);
|
|
87
|
+
if (n === "string")
|
|
88
|
+
return o(e) <= t.value[0];
|
|
89
|
+
const r = a(e, n), s = c(t.value[0], n);
|
|
90
|
+
return s.ok && r <= s.num;
|
|
91
|
+
}, b = (t, e) => e == null || o(e) === "", w = (t, e) => e != null && o(e) !== "", C = (t, e) => {
|
|
92
|
+
const n = o(e).toLowerCase();
|
|
93
|
+
return t.value.some((r) => n.includes(r.toLowerCase()));
|
|
94
|
+
}, L = (t, e) => {
|
|
95
|
+
const n = o(e).toLowerCase();
|
|
96
|
+
return !t.value.some((r) => n.includes(r.toLowerCase()));
|
|
97
|
+
}, h = {
|
|
98
|
+
eq: N,
|
|
99
|
+
ne: v,
|
|
100
|
+
gt: k,
|
|
101
|
+
gte: p,
|
|
102
|
+
lt: g,
|
|
103
|
+
lte: l,
|
|
104
|
+
blank: b,
|
|
105
|
+
nonblank: w,
|
|
106
|
+
includes: C,
|
|
107
|
+
excludes: L
|
|
108
|
+
};
|
|
109
|
+
function f(t, e) {
|
|
110
|
+
const n = h[t.method];
|
|
111
|
+
return n ? n(t, e) : !0;
|
|
112
|
+
}
|
|
113
|
+
function _(t, e) {
|
|
114
|
+
const n = t.mode ?? "or";
|
|
115
|
+
return t.conditions.length === 0 ? !0 : n === "and" ? t.conditions.every((r) => f(r, e)) : t.conditions.some((r) => f(r, e));
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
f as evaluateFilterCondition,
|
|
119
|
+
_ as evaluateFilterConfig,
|
|
120
|
+
h as filterFunctions
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sources":["../../src/lib/filter.ts"],"sourcesContent":["import type { FilterCondition, FilterConditionMethod, FilterConfig } from '../types';\nimport { parseDate } from './date';\nimport { Time } from './time';\n\ntype FilterFunction = (condition: FilterCondition, cellValue: any) => boolean;\n\nconst _str = (v: any): string => (v == null ? '' : String(v));\n\ntype ValueType = 'number' | 'date' | 'time' | 'boolean' | 'string';\n\nfunction detectType(cellValue: any): ValueType {\n if (typeof cellValue === 'number') {\n return 'number';\n }\n if (cellValue instanceof Date) {\n return 'date';\n }\n if (Time.is(cellValue)) {\n return 'time';\n }\n if (typeof cellValue === 'boolean') {\n return 'boolean';\n }\n return 'string';\n}\n\nfunction parseAsType(v: string, type: ValueType): { ok: boolean; num: number } {\n switch (type) {\n case 'number': {\n let s = v.replace(/[,_]/g, '');\n let scale = 1;\n if (s.endsWith('%')) {\n s = s.slice(0, -1);\n scale = 0.01;\n }\n const n = Number(s);\n return { ok: !isNaN(n), num: n * scale };\n }\n case 'date': {\n const d = parseDate(v);\n if (!d) {\n return { ok: false, num: NaN };\n }\n return { ok: true, num: d.getTime() };\n }\n case 'time': {\n const td = Time.parse(v);\n return td ? { ok: true, num: td.toMilliseconds() } : { ok: false, num: NaN };\n }\n case 'boolean': {\n const bv = v.toLowerCase();\n if (bv === 'true') {\n return { ok: true, num: 1 };\n }\n if (bv === 'false') {\n return { ok: true, num: 0 };\n }\n return { ok: false, num: NaN };\n }\n default:\n return { ok: false, num: NaN };\n }\n}\n\nfunction toNumeric(cellValue: any, type: ValueType): number {\n switch (type) {\n case 'number':\n return cellValue as number;\n case 'date':\n return (cellValue as Date).getTime();\n case 'time':\n return Time.ensure(cellValue).toMilliseconds();\n case 'boolean':\n return cellValue ? 1 : 0;\n default:\n return NaN;\n }\n}\n\nconst filterEq: FilterFunction = (condition, cellValue) => {\n const vt = detectType(cellValue);\n if (vt === 'string') {\n const s = _str(cellValue);\n return condition.value.some((v) => s === v);\n }\n const cellNum = toNumeric(cellValue, vt);\n return condition.value.some((v) => {\n const parsed = parseAsType(v, vt);\n return parsed.ok && cellNum === parsed.num;\n });\n};\n\nconst filterNe: FilterFunction = (condition, cellValue) => {\n const vt = detectType(cellValue);\n if (vt === 'string') {\n const s = _str(cellValue);\n return !condition.value.some((v) => s === v);\n }\n const cellNum = toNumeric(cellValue, vt);\n return !condition.value.some((v) => {\n const parsed = parseAsType(v, vt);\n return parsed.ok && cellNum === parsed.num;\n });\n};\n\nconst filterGt: FilterFunction = (condition, cellValue) => {\n const vt = detectType(cellValue);\n if (vt === 'string') {\n return _str(cellValue) > condition.value[0];\n }\n const cellNum = toNumeric(cellValue, vt);\n const parsed = parseAsType(condition.value[0], vt);\n return parsed.ok && cellNum > parsed.num;\n};\n\nconst filterGte: FilterFunction = (condition, cellValue) => {\n const vt = detectType(cellValue);\n if (vt === 'string') {\n return _str(cellValue) >= condition.value[0];\n }\n const cellNum = toNumeric(cellValue, vt);\n const parsed = parseAsType(condition.value[0], vt);\n return parsed.ok && cellNum >= parsed.num;\n};\n\nconst filterLt: FilterFunction = (condition, cellValue) => {\n const vt = detectType(cellValue);\n if (vt === 'string') {\n return _str(cellValue) < condition.value[0];\n }\n const cellNum = toNumeric(cellValue, vt);\n const parsed = parseAsType(condition.value[0], vt);\n return parsed.ok && cellNum < parsed.num;\n};\n\nconst filterLte: FilterFunction = (condition, cellValue) => {\n const vt = detectType(cellValue);\n if (vt === 'string') {\n return _str(cellValue) <= condition.value[0];\n }\n const cellNum = toNumeric(cellValue, vt);\n const parsed = parseAsType(condition.value[0], vt);\n return parsed.ok && cellNum <= parsed.num;\n};\n\nconst filterBlank: FilterFunction = (_condition, cellValue) => {\n return cellValue == null || _str(cellValue) === '';\n};\n\nconst filterNonblank: FilterFunction = (_condition, cellValue) => {\n return cellValue != null && _str(cellValue) !== '';\n};\n\nconst filterIncludes: FilterFunction = (condition, cellValue) => {\n const s = _str(cellValue).toLowerCase();\n return condition.value.some((v) => s.includes(v.toLowerCase()));\n};\n\nconst filterExcludes: FilterFunction = (condition, cellValue) => {\n const s = _str(cellValue).toLowerCase();\n return !condition.value.some((v) => s.includes(v.toLowerCase()));\n};\n\nexport const filterFunctions: Record<FilterConditionMethod, FilterFunction> = {\n eq: filterEq,\n ne: filterNe,\n gt: filterGt,\n gte: filterGte,\n lt: filterLt,\n lte: filterLte,\n blank: filterBlank,\n nonblank: filterNonblank,\n includes: filterIncludes,\n excludes: filterExcludes,\n};\n\nexport function evaluateFilterCondition(condition: FilterCondition, cellValue: any): boolean {\n const fn = filterFunctions[condition.method];\n return fn ? fn(condition, cellValue) : true;\n}\n\nexport function evaluateFilterConfig(filter: FilterConfig, cellValue: any): boolean {\n const mode = filter.mode ?? 'or';\n if (filter.conditions.length === 0) {\n return true;\n }\n if (mode === 'and') {\n return filter.conditions.every((c) => evaluateFilterCondition(c, cellValue));\n } else {\n return filter.conditions.some((c) => evaluateFilterCondition(c, cellValue));\n }\n}\n"],"names":["_str","v","detectType","cellValue","Time","parseAsType","type","s","scale","n","d","parseDate","td","bv","toNumeric","filterEq","condition","vt","cellNum","parsed","filterNe","filterGt","filterGte","filterLt","filterLte","filterBlank","_condition","filterNonblank","filterIncludes","filterExcludes","filterFunctions","evaluateFilterCondition","fn","evaluateFilterConfig","filter","mode","c"],"mappings":";;AAMA,MAAMA,IAAO,CAACC,MAAoBA,KAAK,OAAO,KAAK,OAAOA,CAAC;AAI3D,SAASC,EAAWC,GAA2B;AACzC,SAAA,OAAOA,KAAc,WAChB,WAELA,aAAqB,OAChB,SAELC,EAAK,GAAGD,CAAS,IACZ,SAEL,OAAOA,KAAc,YAChB,YAEF;AACT;AAEA,SAASE,EAAYJ,GAAWK,GAA+C;AAC7E,UAAQA,GAAM;AAAA,IACZ,KAAK,UAAU;AACb,UAAIC,IAAIN,EAAE,QAAQ,SAAS,EAAE,GACzBO,IAAQ;AACR,MAAAD,EAAE,SAAS,GAAG,MACZA,IAAAA,EAAE,MAAM,GAAG,EAAE,GACTC,IAAA;AAEJ,YAAAC,IAAI,OAAOF,CAAC;AACX,aAAA,EAAE,IAAI,CAAC,MAAME,CAAC,GAAG,KAAKA,IAAID,EAAM;AAAA,IAAA;AAAA,IAEzC,KAAK,QAAQ;AACL,YAAAE,IAAIC,EAAUV,CAAC;AACrB,aAAKS,IAGE,EAAE,IAAI,IAAM,KAAKA,EAAE,UAAU,IAF3B,EAAE,IAAI,IAAO,KAAK,IAAI;AAAA,IAEK;AAAA,IAEtC,KAAK,QAAQ;AACL,YAAAE,IAAKR,EAAK,MAAMH,CAAC;AACvB,aAAOW,IAAK,EAAE,IAAI,IAAM,KAAKA,EAAG,eAAe,EAAA,IAAM,EAAE,IAAI,IAAO,KAAK,IAAI;AAAA,IAAA;AAAA,IAE7E,KAAK,WAAW;AACR,YAAAC,IAAKZ,EAAE,YAAY;AACzB,aAAIY,MAAO,SACF,EAAE,IAAI,IAAM,KAAK,EAAE,IAExBA,MAAO,UACF,EAAE,IAAI,IAAM,KAAK,EAAE,IAErB,EAAE,IAAI,IAAO,KAAK,IAAI;AAAA,IAAA;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AIP,EAAKG,CAAS,EAAE,YAAY;AAC/B,SAAAa,EAAU,MAAM,KAAK,CAACf,MAAMM,EAAE,SAASN,EAAE,YAAY,CAAC,CAAC;AAChE,GAEM4B,IAAiC,CAACb,GAAWb,MAAc;AAC/D,QAAMI,IAAIP,EAAKG,CAAS,EAAE,YAAY;AAC/B,SAAA,CAACa,EAAU,MAAM,KAAK,CAACf,MAAMM,EAAE,SAASN,EAAE,YAAY,CAAC,CAAC;AACjE,GAEa6B,IAAiE;AAAA,EAC5E,IAAIf;AAAA,EACJ,IAAIK;AAAA,EACJ,IAAIC;AAAA,EACJ,KAAKC;AAAA,EACL,IAAIC;AAAA,EACJ,KAAKC;AAAA,EACL,OAAOC;AAAA,EACP,UAAUE;AAAA,EACV,UAAUC;AAAA,EACV,UAAUC;AACZ;AAEgB,SAAAE,EAAwBf,GAA4Bb,GAAyB;AACrF,QAAA6B,IAAKF,EAAgBd,EAAU,MAAM;AAC3C,SAAOgB,IAAKA,EAAGhB,GAAWb,CAAS,IAAI;AACzC;AAEgB,SAAA8B,EAAqBC,GAAsB/B,GAAyB;AAC5E,QAAAgC,IAAOD,EAAO,QAAQ;AACxB,SAAAA,EAAO,WAAW,WAAW,IACxB,KAELC,MAAS,QACJD,EAAO,WAAW,MAAM,CAACE,MAAML,EAAwBK,GAAGjC,CAAS,CAAC,IAEpE+B,EAAO,WAAW,KAAK,CAACE,MAAML,EAAwBK,GAAGjC,CAAS,CAAC;AAE9E;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PointType } from '../types';
|
|
2
|
+
import { Sheet } from './sheet';
|
|
3
|
+
export declare const insertTextAtCursor: (input: HTMLTextAreaElement, text: string) => void;
|
|
4
|
+
type InsertRefProps = {
|
|
5
|
+
input: HTMLTextAreaElement | null;
|
|
6
|
+
ref: string;
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const insertRef: ({ input, ref, dryRun }: InsertRefProps) => boolean;
|
|
10
|
+
export declare const isRefInsertable: (input: HTMLTextAreaElement | null) => boolean;
|
|
11
|
+
export declare const expandInput: (input: HTMLTextAreaElement | null) => void;
|
|
12
|
+
export declare const resetInput: (input: HTMLTextAreaElement | null, sheet: Sheet, point: PointType) => void;
|
|
13
|
+
export declare const isFocus: (input: HTMLTextAreaElement | null) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Handles auto-close behavior for double quotes in formula editing.
|
|
16
|
+
* - Typing `"` inserts `""` and places cursor between them.
|
|
17
|
+
* - Typing `"` when cursor is right before an auto-closed `"` skips over it.
|
|
18
|
+
* - Backspace between empty `""` deletes both quotes.
|
|
19
|
+
*
|
|
20
|
+
* Returns true if the event was handled (caller should preventDefault), false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare const handleFormulaQuoteAutoClose: (e: {
|
|
23
|
+
key: string;
|
|
24
|
+
preventDefault(): void;
|
|
25
|
+
currentTarget: HTMLTextAreaElement;
|
|
26
|
+
}, inputting: string) => boolean;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/lib/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAOrC,eAAO,MAAM,kBAAkB,GAAI,OAAO,mBAAmB,EAAE,MAAM,MAAM,SAQ1E,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,wBAAgC,cAAc,KAAG,OAgD1E,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,mBAAmB,GAAG,IAAI,KAAG,OAEnE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,mBAAmB,GAAG,IAAI,SAM5D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,mBAAmB,GAAG,IAAI,EAAE,OAAO,KAAK,EAAE,OAAO,SAAS,SAS3F,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,OAAO,mBAAmB,GAAG,IAAI,KAAG,OAK3D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,IAAI,IAAI,CAAC;IAAC,aAAa,EAAE,mBAAmB,CAAA;CAAE,EAC9E,WAAW,MAAM,KAChB,OAsEF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Lexer as R, splitRef as y } from "../formula/evaluator.js";
|
|
2
|
+
import { DEFAULT_WIDTH as T, DEFAULT_HEIGHT as S } from "../constants.js";
|
|
3
|
+
import { a2p as F, grantAddressAbsolute as b } from "./coords.js";
|
|
4
|
+
import { toSheetPrefix as k } from "./sheet_utils.js";
|
|
5
|
+
import { focus as C } from "./dom.js";
|
|
6
|
+
const i = (e, s) => {
|
|
7
|
+
var o;
|
|
8
|
+
C(e), !((o = document.execCommand) != null && o.call(document, "insertText", !1, s)) && e.setRangeText(s, e.selectionStart, e.selectionEnd, "end");
|
|
9
|
+
}, I = ({ input: e, ref: s, dryRun: n = !1 }) => {
|
|
10
|
+
var a;
|
|
11
|
+
if (!((a = e == null ? void 0 : e.value) != null && a.startsWith("=")) || e.selectionStart === 0)
|
|
12
|
+
return !1;
|
|
13
|
+
const o = new R(e.value.substring(1));
|
|
14
|
+
o.tokenize();
|
|
15
|
+
const [t, c] = o.getTokenIndexByCharPosition(e.selectionStart - 1);
|
|
16
|
+
let r = o.tokens[t];
|
|
17
|
+
if ((r == null ? void 0 : r.type) === "SPACE" && (r = o.tokens[t - 1]), r == null || r.type === "OPEN" || r.type === "COMMA" || r.type === "INFIX_OPERATOR" || r.type === "PREFIX_OPERATOR")
|
|
18
|
+
n || i(e, s);
|
|
19
|
+
else if (r.type === "REF" || r.type === "RANGE") {
|
|
20
|
+
if (!n) {
|
|
21
|
+
const { sheetName: f, addresses: l } = y(s), { addresses: u } = y(r.entity), h = u.map((d) => F(d));
|
|
22
|
+
u.length === 2 && l.length === 1 && l.push(l[0]), s = k(f) + l.map((d, m) => {
|
|
23
|
+
var g, x;
|
|
24
|
+
return b(d, !!((g = h[m]) != null && g.absX), !!((x = h[m]) != null && x.absY));
|
|
25
|
+
}).join(":");
|
|
26
|
+
const [A, E] = o.getTokenPositionRange(t + 1, 1);
|
|
27
|
+
e.setSelectionRange(A, E), i(e, s);
|
|
28
|
+
}
|
|
29
|
+
} else
|
|
30
|
+
return !1;
|
|
31
|
+
return !0;
|
|
32
|
+
}, O = (e) => I({ input: e, ref: "", dryRun: !0 }), N = (e) => {
|
|
33
|
+
e != null && (e.style.width = `${e.scrollWidth}px`, e.style.height = `${e.scrollHeight}px`);
|
|
34
|
+
}, _ = (e, s, n) => {
|
|
35
|
+
var r, a;
|
|
36
|
+
const o = e == null ? void 0 : e.style;
|
|
37
|
+
if (o == null)
|
|
38
|
+
return;
|
|
39
|
+
const t = ((r = s.getCell({ x: n.x, y: 0 }, { resolution: "SYSTEM" })) == null ? void 0 : r.width) ?? T, c = ((a = s.getCell(n, { resolution: "SYSTEM" })) == null ? void 0 : a.height) ?? S;
|
|
40
|
+
o.width = `${t}px`, o.height = `${c}px`;
|
|
41
|
+
}, $ = (e) => typeof window > "u" || e == null ? !1 : document.activeElement === e, H = (e, s) => {
|
|
42
|
+
const n = e.currentTarget;
|
|
43
|
+
if (!s.startsWith("="))
|
|
44
|
+
return !1;
|
|
45
|
+
const { selectionStart: t, selectionEnd: c } = n;
|
|
46
|
+
if (e.key === '"') {
|
|
47
|
+
if (t !== c) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
const l = s.slice(t, c);
|
|
50
|
+
return i(n, `"${l}"`), requestAnimationFrame(() => {
|
|
51
|
+
n.setSelectionRange(t + 1, c + 1);
|
|
52
|
+
}), !0;
|
|
53
|
+
}
|
|
54
|
+
const r = s[t], a = s.slice(1, t);
|
|
55
|
+
let f = 0;
|
|
56
|
+
for (let l = 0; l < a.length; l++)
|
|
57
|
+
a[l] === '"' && (l + 1 < a.length && a[l + 1] === '"' ? l++ : f++);
|
|
58
|
+
return f % 2 === 1 && r === '"' ? (e.preventDefault(), n.setSelectionRange(t + 1, t + 1), !0) : (e.preventDefault(), i(n, '""'), requestAnimationFrame(() => {
|
|
59
|
+
n.setSelectionRange(t + 1, t + 1);
|
|
60
|
+
}), !0);
|
|
61
|
+
}
|
|
62
|
+
return e.key === "Backspace" && t === c && t > 0 && s[t - 1] === '"' && s[t] === '"' ? (e.preventDefault(), n.setRangeText("", t - 1, t + 1, "end"), n.dispatchEvent(new Event("input", { bubbles: !0 })), !0) : !1;
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
N as expandInput,
|
|
66
|
+
H as handleFormulaQuoteAutoClose,
|
|
67
|
+
I as insertRef,
|
|
68
|
+
i as insertTextAtCursor,
|
|
69
|
+
$ as isFocus,
|
|
70
|
+
O as isRefInsertable,
|
|
71
|
+
_ as resetInput
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../src/lib/input.ts"],"sourcesContent":["import type { PointType } from '../types';\nimport type { Sheet } from './sheet';\nimport { Lexer, splitRef } from '../formula/evaluator';\nimport { DEFAULT_HEIGHT, DEFAULT_WIDTH } from '../constants';\nimport { a2p, grantAddressAbsolute } from './coords';\nimport { toSheetPrefix } from './sheet_utils';\nimport { focus } from './dom';\n\nexport const insertTextAtCursor = (input: HTMLTextAreaElement, text: string) => {\n focus(input);\n const deprecated = !document.execCommand?.('insertText', false, text);\n if (!deprecated) {\n return;\n }\n input.setRangeText(text, input.selectionStart, input.selectionEnd, 'end');\n return;\n};\n\ntype InsertRefProps = {\n input: HTMLTextAreaElement | null;\n ref: string;\n dryRun?: boolean;\n};\n\nexport const insertRef = ({ input, ref, dryRun = false }: InsertRefProps): boolean => {\n // dryRun is used to check if the ref can be inserted without actually inserting it\n if (!input?.value?.startsWith('=') || input.selectionStart === 0) {\n return false;\n }\n const lexer = new Lexer(input.value.substring(1));\n lexer.tokenize();\n const [tokenIndex, _] = lexer.getTokenIndexByCharPosition(input.selectionStart - 1);\n let token = lexer.tokens[tokenIndex];\n if (token?.type === 'SPACE') {\n token = lexer.tokens[tokenIndex - 1];\n }\n if (\n token == null ||\n token.type === 'OPEN' ||\n token.type === 'COMMA' ||\n token.type === 'INFIX_OPERATOR' ||\n token.type === 'PREFIX_OPERATOR'\n ) {\n if (!dryRun) {\n insertTextAtCursor(input, ref);\n }\n } else if (token.type === 'REF' || token.type === 'RANGE') {\n if (!dryRun) {\n // keep the absolute/relative state of the token\n const { sheetName: refSheetName, addresses: refAddresses } = splitRef(ref);\n const { addresses: tokenAddresses } = splitRef(token.entity as string);\n\n const tokenAbsolutes = tokenAddresses.map((a) => a2p(a));\n if (tokenAddresses.length === 2 && refAddresses.length === 1) {\n refAddresses.push(refAddresses[0]);\n }\n ref =\n toSheetPrefix(refSheetName) +\n refAddresses\n .map((r, i) => {\n return grantAddressAbsolute(r, !!tokenAbsolutes[i]?.absX, !!tokenAbsolutes[i]?.absY);\n })\n .join(':');\n\n const [start, end] = lexer.getTokenPositionRange(tokenIndex + 1, 1);\n input.setSelectionRange(start, end);\n insertTextAtCursor(input, ref);\n }\n } else {\n return false;\n }\n return true;\n};\n\nexport const isRefInsertable = (input: HTMLTextAreaElement | null): boolean => {\n return insertRef({ input, ref: '', dryRun: true });\n};\n\nexport const expandInput = (input: HTMLTextAreaElement | null) => {\n if (input == null) {\n return;\n }\n input.style.width = `${input.scrollWidth}px`;\n input.style.height = `${input.scrollHeight}px`;\n};\n\nexport const resetInput = (input: HTMLTextAreaElement | null, sheet: Sheet, point: PointType) => {\n const style = input?.style;\n if (style == null) {\n return;\n }\n const width = sheet.getCell({ x: point.x, y: 0 }, { resolution: 'SYSTEM' })?.width ?? DEFAULT_WIDTH;\n const height = sheet.getCell(point, { resolution: 'SYSTEM' })?.height ?? DEFAULT_HEIGHT;\n style.width = `${width}px`;\n style.height = `${height}px`;\n};\n\nexport const isFocus = (input: HTMLTextAreaElement | null): boolean => {\n if (typeof window === 'undefined' || input == null) {\n return false;\n }\n return document.activeElement === input;\n};\n\n/**\n * Handles auto-close behavior for double quotes in formula editing.\n * - Typing `\"` inserts `\"\"` and places cursor between them.\n * - Typing `\"` when cursor is right before an auto-closed `\"` skips over it.\n * - Backspace between empty `\"\"` deletes both quotes.\n *\n * Returns true if the event was handled (caller should preventDefault), false otherwise.\n */\nexport const handleFormulaQuoteAutoClose = (\n e: { key: string; preventDefault(): void; currentTarget: HTMLTextAreaElement },\n inputting: string,\n): boolean => {\n const input = e.currentTarget;\n const isFormula = inputting.startsWith('=');\n if (!isFormula) {\n return false;\n }\n\n const { selectionStart, selectionEnd } = input;\n\n if (e.key === '\"') {\n // If text is selected, wrap it in quotes\n if (selectionStart !== selectionEnd) {\n e.preventDefault();\n const selectedText = inputting.slice(selectionStart, selectionEnd);\n insertTextAtCursor(input, `\"${selectedText}\"`);\n requestAnimationFrame(() => {\n input.setSelectionRange(selectionStart + 1, selectionEnd + 1);\n });\n return true;\n }\n\n const charAfter = inputting[selectionStart];\n\n // Count unescaped double quotes before cursor (after '=') to determine if we're inside a string\n const beforeCursor = inputting.slice(1, selectionStart); // skip '='\n let quoteCount = 0;\n for (let i = 0; i < beforeCursor.length; i++) {\n if (beforeCursor[i] === '\"') {\n // Skip escaped double quotes (\"\") inside strings\n if (i + 1 < beforeCursor.length && beforeCursor[i + 1] === '\"') {\n i++; // skip the next quote\n } else {\n quoteCount++;\n }\n }\n }\n\n // If odd number of quotes before cursor, we're inside a string.\n // If the next char is `\"`, it's the closing quote — skip over it.\n if (quoteCount % 2 === 1 && charAfter === '\"') {\n e.preventDefault();\n input.setSelectionRange(selectionStart + 1, selectionStart + 1);\n return true;\n }\n\n // Otherwise, insert `\"\"` and place cursor in between\n e.preventDefault();\n insertTextAtCursor(input, '\"\"');\n requestAnimationFrame(() => {\n input.setSelectionRange(selectionStart + 1, selectionStart + 1);\n });\n return true;\n }\n\n if (e.key === 'Backspace') {\n // If cursor is between `\"\"`, delete both\n if (\n selectionStart === selectionEnd &&\n selectionStart > 0 &&\n inputting[selectionStart - 1] === '\"' &&\n inputting[selectionStart] === '\"'\n ) {\n e.preventDefault();\n input.setRangeText('', selectionStart - 1, selectionStart + 1, 'end');\n input.dispatchEvent(new Event('input', { bubbles: true }));\n return true;\n }\n }\n\n return false;\n};\n"],"names":["insertTextAtCursor","input","text","focus","_a","insertRef","ref","dryRun","lexer","Lexer","tokenIndex","_","token","refSheetName","refAddresses","splitRef","tokenAddresses","tokenAbsolutes","a","a2p","toSheetPrefix","r","i","grantAddressAbsolute","_b","start","end","isRefInsertable","expandInput","resetInput","sheet","point","style","width","DEFAULT_WIDTH","height","DEFAULT_HEIGHT","isFocus","handleFormulaQuoteAutoClose","inputting","selectionStart","selectionEnd","selectedText","charAfter","beforeCursor","quoteCount"],"mappings":";;;;;AAQa,MAAAA,IAAqB,CAACC,GAA4BC,MAAiB;;AAG9E,EAFAC,EAAMF,CAAK,GACQ,GAACG,IAAA,SAAS,gBAAT,QAAAA,EAAA,eAAuB,cAAc,IAAOF,OAIhED,EAAM,aAAaC,GAAMD,EAAM,gBAAgBA,EAAM,cAAc,KAAK;AAE1E,GAQaI,IAAY,CAAC,EAAE,OAAAJ,GAAO,KAAAK,GAAK,QAAAC,IAAS,SAAqC;;AAEhF,MAAA,GAACH,IAAAH,KAAA,gBAAAA,EAAO,UAAP,QAAAG,EAAc,WAAW,SAAQH,EAAM,mBAAmB;AACtD,WAAA;AAET,QAAMO,IAAQ,IAAIC,EAAMR,EAAM,MAAM,UAAU,CAA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AGA,IAAIsB,EAAa,QAAQtB;AACnC,MAAAsB,EAAatB,CAAC,MAAM,QAElBA,IAAI,IAAIsB,EAAa,UAAUA,EAAatB,IAAI,CAAC,MAAM,MACzDA,MAEAuB;AAON,WAAIA,IAAa,MAAM,KAAKF,MAAc,OACxC,EAAE,eAAe,GACjB1C,EAAM,kBAAkBuC,IAAiB,GAAGA,IAAiB,CAAC,GACvD,OAIT,EAAE,eAAe,GACjBxC,EAAmBC,GAAO,IAAI,GAC9B,sBAAsB,MAAM;AAC1B,MAAAA,EAAM,kBAAkBuC,IAAiB,GAAGA,IAAiB,CAAC;AAAA,IAAA,CAC/D,GACM;AAAA,EAAA;AAGL,SAAA,EAAE,QAAQ,eAGVA,MAAmBC,KACnBD,IAAiB,KACjBD,EAAUC,IAAiB,CAAC,MAAM,OAClCD,EAAUC,CAAc,MAAM,OAE9B,EAAE,eAAe,GACjBvC,EAAM,aAAa,IAAIuC,IAAiB,GAAGA,IAAiB,GAAG,KAAK,GAC9DvC,EAAA,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,GAAA,CAAM,CAAC,GAClD,MAIJ;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/lib/label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,OAAO,SAAS,EAAE,GAAG,MAAM,KAAG,MAAM,GAAG,IAM5G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../src/lib/label.ts"],"sourcesContent":["import type { PointType } from '../types';\nimport type { UserSheet } from './sheet';\n\nexport const getLabel = (sheet: UserSheet, label: string | undefined, point: PointType, n: number): string | null => {\n if (label != null) {\n return label;\n }\n const policy = sheet.getPolicy(point);\n return (point.x === 0 ? policy.renderRowHeaderLabel(n) : policy.renderColHeaderLabel(n)) ?? null;\n};\n"],"names":["getLabel","sheet","label","point","n","policy"],"mappings":"AAGO,MAAMA,IAAW,CAACC,GAAkBC,GAA2BC,GAAkBC,MAA6B;AACnH,MAAIF,KAAS;AACJ,WAAAA;AAEH,QAAAG,IAASJ,EAAM,UAAUE,CAAK;AAC5B,UAAAA,EAAM,MAAM,IAAIE,EAAO,qBAAqBD,CAAC,IAAIC,EAAO,qBAAqBD,CAAC,MAAM;AAC9F;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OperationType as operations } from '../types';
|
|
2
|
+
export declare const RemoveRows: operations;
|
|
3
|
+
export declare const RemoveCols: operations;
|
|
4
|
+
export declare const InsertRowsAbove: operations;
|
|
5
|
+
export declare const InsertRowsBelow: operations;
|
|
6
|
+
export declare const InsertColsLeft: operations;
|
|
7
|
+
export declare const InsertColsRight: operations;
|
|
8
|
+
export declare const MoveFrom: operations;
|
|
9
|
+
export declare const MoveTo: operations;
|
|
10
|
+
export declare const Write: operations;
|
|
11
|
+
export declare const Style: operations;
|
|
12
|
+
export declare const Copy: operations;
|
|
13
|
+
export declare const Resize: operations;
|
|
14
|
+
export declare const SetPolicy: operations;
|
|
15
|
+
export declare const Sort: operations;
|
|
16
|
+
export declare const Filter: operations;
|
|
17
|
+
export declare const SetLabel: operations;
|
|
18
|
+
export declare const NoOperation: operations;
|
|
19
|
+
export declare const Move: operations;
|
|
20
|
+
export declare const Update: operations;
|
|
21
|
+
export declare const InsertRows: operations;
|
|
22
|
+
export declare const InsertCols: operations;
|
|
23
|
+
export declare const Add: operations;
|
|
24
|
+
export declare const Delete: operations;
|
|
25
|
+
export declare const ReadOnly: operations;
|
|
26
|
+
export declare const ColumnMenu: operations;
|
|
27
|
+
export declare const RowMenu: operations;
|
|
28
|
+
export declare const ViewOnly: operations;
|
|
29
|
+
export declare const hasOperation: (operation: operations | undefined, flag: operations) => boolean;
|
|
30
|
+
export declare const debugOperations: (prevention: operations | undefined) => string[];
|
|
31
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/lib/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAEvD,eAAO,MAAM,UAAU,EAAE,UAAoE,CAAC;AAC9F,eAAO,MAAM,UAAU,EAAE,UAAoE,CAAC;AAC9F,eAAO,MAAM,eAAe,EAAE,UAAoE,CAAC;AACnG,eAAO,MAAM,eAAe,EAAE,UAAoE,CAAC;AACnG,eAAO,MAAM,cAAc,EAAE,UAAoE,CAAC;AAClG,eAAO,MAAM,eAAe,EAAE,UAAoE,CAAC;AACnG,eAAO,MAAM,QAAQ,EAAE,UAAoE,CAAC;AAC5F,eAAO,MAAM,MAAM,EAAE,UAAoE,CAAC;AAC1F,eAAO,MAAM,KAAK,EAAE,UAAoE,CAAC;AACzF,eAAO,MAAM,KAAK,EAAE,UAAoE,CAAC;AACzF,eAAO,MAAM,IAAI,EAAE,UAAoE,CAAC;AACxF,eAAO,MAAM,MAAM,EAAE,UAAoE,CAAC;AAC1F,eAAO,MAAM,SAAS,EAAE,UAAoE,CAAC;AAC7F,eAAO,MAAM,IAAI,EAAE,UAAoE,CAAC;AACxF,eAAO,MAAM,MAAM,EAAE,UAAoE,CAAC;AAC1F,eAAO,MAAM,QAAQ,EAAE,UAAoE,CAAC;AAE5F,eAAO,MAAM,WAAW,EAAE,UAAc,CAAC;AAEzC,eAAO,MAAM,IAAI,EAAE,UAA8B,CAAC;AAElD,eAAO,MAAM,MAAM,EAAE,UAAiE,CAAC;AAEvF,eAAO,MAAM,UAAU,EAAE,UAA8C,CAAC;AAExE,eAAO,MAAM,UAAU,EAAE,UAA6C,CAAC;AAEvE,eAAO,MAAM,GAAG,EA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