@gridsheet/react-core 1.4.0-alpha.2 → 1.4.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/dayjs.min.js +8 -0
- package/dist/_virtual/dayjs.min.js.map +1 -0
- package/dist/_virtual/dayjs.min2.js +5 -0
- package/dist/_virtual/dayjs.min2.js.map +1 -0
- package/dist/_virtual/jsx-runtime.js +6 -0
- package/dist/_virtual/jsx-runtime.js.map +1 -0
- package/dist/_virtual/jsx-runtime2.js +5 -0
- package/dist/_virtual/jsx-runtime2.js.map +1 -0
- package/dist/_virtual/react-jsx-runtime.development.js +5 -0
- package/dist/_virtual/react-jsx-runtime.development.js.map +1 -0
- package/dist/_virtual/react-jsx-runtime.production.js +5 -0
- package/dist/_virtual/react-jsx-runtime.production.js.map +1 -0
- package/dist/_virtual/timezone.js +8 -0
- package/dist/_virtual/timezone.js.map +1 -0
- package/dist/_virtual/timezone2.js +5 -0
- package/dist/_virtual/timezone2.js.map +1 -0
- package/dist/_virtual/utc.js +8 -0
- package/dist/_virtual/utc.js.map +1 -0
- package/dist/_virtual/utc2.js +5 -0
- package/dist/_virtual/utc2.js.map +1 -0
- package/dist/components/Cell.js +232 -0
- package/dist/components/Cell.js.map +1 -0
- package/dist/components/ContextMenu.js +297 -0
- package/dist/components/ContextMenu.js.map +1 -0
- package/dist/components/Editor.js +455 -0
- package/dist/components/Editor.js.map +1 -0
- package/dist/components/Emitter.js +26 -0
- package/dist/components/Emitter.js.map +1 -0
- package/dist/components/Fixed.js +17 -0
- package/dist/components/Fixed.js.map +1 -0
- package/dist/components/FormulaBar.js +149 -0
- package/dist/components/FormulaBar.js.map +1 -0
- package/dist/components/GridSheet.js +246 -0
- package/dist/components/GridSheet.js.map +1 -0
- package/dist/components/HeaderCellLeft.js +131 -0
- package/dist/components/HeaderCellLeft.js.map +1 -0
- package/dist/components/HeaderCellTop.js +132 -0
- package/dist/components/HeaderCellTop.js.map +1 -0
- package/dist/components/PluginBase.js +35 -0
- package/dist/components/PluginBase.js.map +1 -0
- package/dist/components/Resizer.js +98 -0
- package/dist/components/Resizer.js.map +1 -0
- package/dist/components/SearchBar.js +108 -0
- package/dist/components/SearchBar.js.map +1 -0
- package/dist/components/SheetProvider.js +56 -0
- package/dist/components/SheetProvider.js.map +1 -0
- package/dist/components/StoreInitializer.js +84 -0
- package/dist/components/StoreInitializer.js.map +1 -0
- package/dist/components/Tabular.js +308 -0
- package/dist/components/Tabular.js.map +1 -0
- package/dist/components/hooks.js +15 -0
- package/dist/components/hooks.js.map +1 -0
- package/dist/components/svg/Base.js +24 -0
- package/dist/components/svg/Base.js.map +1 -0
- package/dist/components/svg/CloseIcon.js +13 -0
- package/dist/components/svg/CloseIcon.js.map +1 -0
- package/dist/components/svg/SearchIcon.js +13 -0
- package/dist/components/svg/SearchIcon.js.map +1 -0
- package/dist/constants.js +43 -0
- package/dist/constants.js.map +1 -0
- package/dist/formula/evaluator.js +674 -0
- package/dist/formula/evaluator.js.map +1 -0
- package/dist/formula/functions/__base.js +19 -0
- package/dist/formula/functions/__base.js.map +1 -0
- package/dist/formula/functions/__utils.js +145 -0
- package/dist/formula/functions/__utils.js.map +1 -0
- package/dist/formula/functions/abs.js +24 -0
- package/dist/formula/functions/abs.js.map +1 -0
- package/dist/formula/functions/acos.js +32 -0
- package/dist/formula/functions/acos.js.map +1 -0
- package/dist/formula/functions/add.js +57 -0
- package/dist/formula/functions/add.js.map +1 -0
- package/dist/formula/functions/and.js +28 -0
- package/dist/formula/functions/and.js.map +1 -0
- package/dist/formula/functions/asin.js +32 -0
- package/dist/formula/functions/asin.js.map +1 -0
- package/dist/formula/functions/atan.js +29 -0
- package/dist/formula/functions/atan.js.map +1 -0
- package/dist/formula/functions/atan2.js +35 -0
- package/dist/formula/functions/atan2.js.map +1 -0
- package/dist/formula/functions/average.js +44 -0
- package/dist/formula/functions/average.js.map +1 -0
- package/dist/formula/functions/col.js +31 -0
- package/dist/formula/functions/col.js.map +1 -0
- package/dist/formula/functions/concat.js +27 -0
- package/dist/formula/functions/concat.js.map +1 -0
- package/dist/formula/functions/concatenate.js +28 -0
- package/dist/formula/functions/concatenate.js.map +1 -0
- package/dist/formula/functions/cos.js +29 -0
- package/dist/formula/functions/cos.js.map +1 -0
- package/dist/formula/functions/count.js +38 -0
- package/dist/formula/functions/count.js.map +1 -0
- package/dist/formula/functions/counta.js +38 -0
- package/dist/formula/functions/counta.js.map +1 -0
- package/dist/formula/functions/countif.js +32 -0
- package/dist/formula/functions/countif.js.map +1 -0
- package/dist/formula/functions/divide.js +33 -0
- package/dist/formula/functions/divide.js.map +1 -0
- package/dist/formula/functions/eq.js +29 -0
- package/dist/formula/functions/eq.js.map +1 -0
- package/dist/formula/functions/exp.js +29 -0
- package/dist/formula/functions/exp.js.map +1 -0
- package/dist/formula/functions/gt.js +29 -0
- package/dist/formula/functions/gt.js.map +1 -0
- package/dist/formula/functions/gte.js +29 -0
- package/dist/formula/functions/gte.js.map +1 -0
- package/dist/formula/functions/hlookup.js +75 -0
- package/dist/formula/functions/hlookup.js.map +1 -0
- package/dist/formula/functions/if.js +39 -0
- package/dist/formula/functions/if.js.map +1 -0
- package/dist/formula/functions/iferror.js +45 -0
- package/dist/formula/functions/iferror.js.map +1 -0
- package/dist/formula/functions/len.js +29 -0
- package/dist/formula/functions/len.js.map +1 -0
- package/dist/formula/functions/lenb.js +29 -0
- package/dist/formula/functions/lenb.js.map +1 -0
- package/dist/formula/functions/ln.js +32 -0
- package/dist/formula/functions/ln.js.map +1 -0
- package/dist/formula/functions/log.js +36 -0
- package/dist/formula/functions/log.js.map +1 -0
- package/dist/formula/functions/log10.js +32 -0
- package/dist/formula/functions/log10.js.map +1 -0
- package/dist/formula/functions/lt.js +29 -0
- package/dist/formula/functions/lt.js.map +1 -0
- package/dist/formula/functions/lte.js +29 -0
- package/dist/formula/functions/lte.js.map +1 -0
- package/dist/formula/functions/max.js +47 -0
- package/dist/formula/functions/max.js.map +1 -0
- package/dist/formula/functions/min.js +47 -0
- package/dist/formula/functions/min.js.map +1 -0
- package/dist/formula/functions/minus.js +57 -0
- package/dist/formula/functions/minus.js.map +1 -0
- package/dist/formula/functions/mod.js +33 -0
- package/dist/formula/functions/mod.js.map +1 -0
- package/dist/formula/functions/multiply.js +27 -0
- package/dist/formula/functions/multiply.js.map +1 -0
- package/dist/formula/functions/ne.js +29 -0
- package/dist/formula/functions/ne.js.map +1 -0
- package/dist/formula/functions/not.js +30 -0
- package/dist/formula/functions/not.js.map +1 -0
- package/dist/formula/functions/now.js +22 -0
- package/dist/formula/functions/now.js.map +1 -0
- package/dist/formula/functions/or.js +28 -0
- package/dist/formula/functions/or.js.map +1 -0
- package/dist/formula/functions/pi.js +22 -0
- package/dist/formula/functions/pi.js.map +1 -0
- package/dist/formula/functions/power.js +27 -0
- package/dist/formula/functions/power.js.map +1 -0
- package/dist/formula/functions/product.js +40 -0
- package/dist/formula/functions/product.js.map +1 -0
- package/dist/formula/functions/radians.js +29 -0
- package/dist/formula/functions/radians.js.map +1 -0
- package/dist/formula/functions/rand.js +22 -0
- package/dist/formula/functions/rand.js.map +1 -0
- package/dist/formula/functions/round.js +35 -0
- package/dist/formula/functions/round.js.map +1 -0
- package/dist/formula/functions/rounddown.js +35 -0
- package/dist/formula/functions/rounddown.js.map +1 -0
- package/dist/formula/functions/roundup.js +35 -0
- package/dist/formula/functions/roundup.js.map +1 -0
- package/dist/formula/functions/row.js +31 -0
- package/dist/formula/functions/row.js.map +1 -0
- package/dist/formula/functions/sin.js +29 -0
- package/dist/formula/functions/sin.js.map +1 -0
- package/dist/formula/functions/sqrt.js +32 -0
- package/dist/formula/functions/sqrt.js.map +1 -0
- package/dist/formula/functions/sum.js +47 -0
- package/dist/formula/functions/sum.js.map +1 -0
- package/dist/formula/functions/sumif.js +65 -0
- package/dist/formula/functions/sumif.js.map +1 -0
- package/dist/formula/functions/tan.js +29 -0
- package/dist/formula/functions/tan.js.map +1 -0
- package/dist/formula/functions/uminus.js +24 -0
- package/dist/formula/functions/uminus.js.map +1 -0
- package/dist/formula/functions/vlookup.js +75 -0
- package/dist/formula/functions/vlookup.js.map +1 -0
- package/dist/formula/mapping.js +118 -0
- package/dist/formula/mapping.js.map +1 -0
- package/dist/formula/solver.js +70 -0
- package/dist/formula/solver.js.map +1 -0
- package/dist/index.js +16 -9113
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.js +391 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/clipboard.js +46 -0
- package/dist/lib/clipboard.js.map +1 -0
- package/dist/lib/converters.js +141 -0
- package/dist/lib/converters.js.map +1 -0
- package/dist/lib/input.js +52 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/palette.js +24 -0
- package/dist/lib/palette.js.map +1 -0
- package/dist/lib/prevention.js +82 -0
- package/dist/lib/prevention.js.map +1 -0
- package/dist/lib/structs.js +276 -0
- package/dist/lib/structs.js.map +1 -0
- package/dist/lib/table.js +1248 -0
- package/dist/lib/table.js.map +1 -0
- package/dist/lib/time.js +79 -0
- package/dist/lib/time.js.map +1 -0
- package/dist/lib/virtualization.js +129 -0
- package/dist/lib/virtualization.js.map +1 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js +287 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js.map +1 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js +72 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js.map +1 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js +85 -0
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js +454 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js +42 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js +18 -0
- package/dist/node_modules/.pnpm/react@19.0.0/node_modules/react/jsx-runtime.js.map +1 -0
- package/dist/parsers/core.js +139 -0
- package/dist/parsers/core.js.map +1 -0
- package/dist/renderers/checkbox.js +20 -0
- package/dist/renderers/checkbox.js.map +1 -0
- package/dist/renderers/core.js +147 -0
- package/dist/renderers/core.js.map +1 -0
- package/dist/renderers/thousand_separator.js +17 -0
- package/dist/renderers/thousand_separator.js.map +1 -0
- package/dist/store/actions.js +762 -0
- package/dist/store/actions.js.map +1 -0
- package/dist/store/helpers.js +88 -0
- package/dist/store/helpers.js.map +1 -0
- package/dist/store/index.js +8 -0
- package/dist/store/index.js.map +1 -0
- package/dist/styles/embedder.js +19 -0
- package/dist/styles/embedder.js.map +1 -0
- package/dist/styles/minified.js +7 -0
- package/dist/styles/minified.js.map +1 -0
- package/package.json +1 -7
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { TimeDelta } from "../lib/time.js";
|
|
2
|
+
import dayjs from "../_virtual/dayjs.min.js";
|
|
3
|
+
import utc from "../_virtual/utc.js";
|
|
4
|
+
import timezone from "../_virtual/timezone.js";
|
|
5
|
+
dayjs.extend(timezone);
|
|
6
|
+
dayjs.extend(utc);
|
|
7
|
+
const BOOLS = { true: true, false: false };
|
|
8
|
+
const NUMS = /* @__PURE__ */ new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
|
|
9
|
+
const NUMS_Z = /* @__PURE__ */ new Set([...NUMS, "Z", "z"]);
|
|
10
|
+
const JFMASOND = /* @__PURE__ */ new Set(["J", "F", "M", "A", "S", "O", "N", "D", ...NUMS]);
|
|
11
|
+
const NBRYNLGPTVC = /* @__PURE__ */ new Set(["N", "B", "R", "Y", "N", "L", "G", "P", "T", "V", "C", ...NUMS_Z]);
|
|
12
|
+
class Parser {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
this.functions = [
|
|
15
|
+
this.number.bind(this),
|
|
16
|
+
this.timedelta.bind(this),
|
|
17
|
+
this.date.bind(this),
|
|
18
|
+
this.bool.bind(this)
|
|
19
|
+
];
|
|
20
|
+
this.applyMixins(props == null ? void 0 : props.mixins);
|
|
21
|
+
if (props == null) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const { condition, complement } = props;
|
|
25
|
+
this.condition = condition;
|
|
26
|
+
this.complement = complement;
|
|
27
|
+
}
|
|
28
|
+
applyMixins(mixins) {
|
|
29
|
+
if (mixins == null) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
for (const mixin of mixins) {
|
|
33
|
+
for (const key in mixin) {
|
|
34
|
+
this[key] = mixin[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
call(value, cell) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = this.parse(value, cell);
|
|
41
|
+
return this.callback(parsed, cell);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return this.callback(e, cell);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
callback(parsed, cell) {
|
|
47
|
+
return { ...cell, value: parsed };
|
|
48
|
+
}
|
|
49
|
+
parse(value, cell) {
|
|
50
|
+
if (this.condition && !this.condition(value)) {
|
|
51
|
+
const result = this.complement ? this.complement(value) : value;
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
if (value[0] === "'") {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < this.functions.length; i++) {
|
|
58
|
+
const result = this.functions[i](value, cell);
|
|
59
|
+
if (result != null) {
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (value === "") {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
bool(value, cell) {
|
|
69
|
+
return BOOLS[value.toLowerCase()];
|
|
70
|
+
}
|
|
71
|
+
number(value, cell) {
|
|
72
|
+
const m = value.match(/^-?[\d.]+$/);
|
|
73
|
+
if (m != null && value.match(/\.$/) == null && (value.match(/\./g) || []).length <= 1) {
|
|
74
|
+
return parseFloat(value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
timedelta(value, cell) {
|
|
78
|
+
if (value.length < 4 || isNaN(value[value.length - 1])) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
{
|
|
82
|
+
const match = value.match(/^([+-]?)(\d+):(\d{2})$/);
|
|
83
|
+
if (match) {
|
|
84
|
+
const [, _sign, hours, minutes] = match;
|
|
85
|
+
const sign = _sign === "-" ? -1 : 1;
|
|
86
|
+
return TimeDelta.create(sign * Number(hours), sign * Number(minutes));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
{
|
|
90
|
+
const match = value.match(/^([+-]?)(\d+):(\d{2}):(\d{2})$/);
|
|
91
|
+
if (match) {
|
|
92
|
+
const [, _sign, hours, minutes, seconds] = match;
|
|
93
|
+
const sign = _sign === "-" ? -1 : 1;
|
|
94
|
+
return TimeDelta.create(sign * Number(hours), sign * Number(minutes), sign * Number(seconds));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
{
|
|
98
|
+
const match = value.match(/^([+-]?)(\d+):(\d{2}):(\d{2})\.(\d+)$/);
|
|
99
|
+
if (match) {
|
|
100
|
+
const [, _sign, hours, minutes, seconds, msecs] = match;
|
|
101
|
+
const sign = _sign === "-" ? -1 : 1;
|
|
102
|
+
return TimeDelta.create(
|
|
103
|
+
sign * Number(hours),
|
|
104
|
+
sign * Number(minutes),
|
|
105
|
+
sign * Number(seconds),
|
|
106
|
+
sign * Number(msecs)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
date(value, cell) {
|
|
112
|
+
const first = value[0];
|
|
113
|
+
if (first == null || !JFMASOND.has(first.toUpperCase())) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!NBRYNLGPTVC.has(value[value.length - 1].toUpperCase())) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (value.match(/[=*&#@!?[\]{}"'()|%\\<>~+\r\n]/)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
let timeZone = "UTC";
|
|
123
|
+
try {
|
|
124
|
+
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
125
|
+
} catch (e) {
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const day = dayjs.tz(value, timeZone);
|
|
129
|
+
return day.toDate();
|
|
130
|
+
} catch (e) {
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const defaultParser = new Parser();
|
|
135
|
+
export {
|
|
136
|
+
Parser,
|
|
137
|
+
defaultParser
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../parsers/core.ts"],"sourcesContent":["import { CellType } from '../types';\nimport { TimeDelta } from '../lib/time';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\ndayjs.extend(timezone);\ndayjs.extend(utc);\n\ntype Condition = (value: string) => boolean;\ntype Stringify = (value: string) => any;\n\ntype Props = {\n condition?: Condition;\n complement?: Stringify;\n mixins?: ParserMixinType[];\n};\n\nconst BOOLS = { true: true, false: false } as { [s: string]: boolean };\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\nexport interface ParserMixinType {\n functions?: ((value: string, cell?: CellType) => any)[];\n callback?(parsed: any, cell?: CellType): CellType;\n parse?(value: string, cell: CellType): any;\n bool?(value: string, cell?: CellType): boolean | undefined;\n number?(value: string, cell?: CellType): number | undefined;\n timedelta?(value: string, cell?: CellType): TimeDelta | undefined;\n date?(value: string, cell?: CellType): Date | undefined;\n}\n\nexport class Parser implements ParserMixinType {\n functions: ((value: string, cell?: CellType) => any)[] = [\n this.number.bind(this),\n this.timedelta.bind(this),\n this.date.bind(this),\n this.bool.bind(this),\n ];\n\n private condition?: Condition;\n private complement?: Stringify;\n\n constructor(props?: Props) {\n this.applyMixins(props?.mixins);\n if (props == null) {\n return;\n }\n const { condition, complement } = props;\n this.condition = condition;\n this.complement = complement;\n }\n\n private applyMixins(mixins?: ParserMixinType[]) {\n if (mixins == null) {\n return;\n }\n for (const mixin of mixins) {\n for (const key in mixin) {\n // @ts-expect-error mixin has the same fields as this\n this[key] = mixin[key];\n }\n }\n }\n public call(value: string, cell: CellType): CellType {\n try {\n const parsed = this.parse(value, cell);\n return this.callback(parsed, cell);\n } catch (e) {\n return this.callback(e, cell);\n }\n }\n public callback(parsed: any, cell?: CellType): CellType {\n return { ...cell, value: parsed };\n }\n public parse(value: string, cell?: CellType): any {\n if (this.condition && !this.condition(value)) {\n const result = this.complement ? this.complement(value) : value;\n return result;\n }\n if (value[0] === \"'\") {\n return value;\n }\n for (let i = 0; i < this.functions.length; i++) {\n const result = this.functions[i](value, cell);\n if (result != null) {\n return result;\n }\n }\n if (value === '') {\n return null;\n }\n return value;\n }\n\n bool(value: string, cell?: CellType): boolean | undefined {\n return BOOLS[value.toLowerCase()];\n }\n\n number(value: string, cell?: CellType): number | undefined {\n const m = value.match(/^-?[\\d.]+$/);\n if (m != null && value.match(/\\.$/) == null && (value.match(/\\./g) || []).length <= 1) {\n return parseFloat(value);\n }\n }\n\n timedelta(value: string, cell?: CellType): TimeDelta | undefined {\n if (value.length < 4 || isNaN(value[value.length - 1] as unknown as number)) {\n return;\n }\n {\n const match = value.match(/^([+-]?)(\\d+):(\\d{2})$/);\n if (match) {\n const [, _sign, hours, minutes] = match;\n const sign = _sign === '-' ? -1 : 1;\n return TimeDelta.create(sign * Number(hours), sign * Number(minutes));\n }\n }\n {\n const match = value.match(/^([+-]?)(\\d+):(\\d{2}):(\\d{2})$/);\n if (match) {\n const [, _sign, hours, minutes, seconds] = match;\n const sign = _sign === '-' ? -1 : 1;\n return TimeDelta.create(sign * Number(hours), sign * Number(minutes), sign * Number(seconds));\n }\n }\n {\n const match = value.match(/^([+-]?)(\\d+):(\\d{2}):(\\d{2})\\.(\\d+)$/);\n if (match) {\n const [, _sign, hours, minutes, seconds, msecs] = match;\n const sign = _sign === '-' ? -1 : 1;\n return TimeDelta.create(\n sign * Number(hours),\n sign * Number(minutes),\n sign * Number(seconds),\n sign * Number(msecs),\n );\n }\n }\n }\n\n date(value: string, cell?: CellType): 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 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}\n\nexport type ParserType = Parser;\n\nexport const defaultParser = new Parser();\n"],"names":[],"mappings":";;;;AAKA,MAAM,OAAO,QAAQ;AACrB,MAAM,OAAO,GAAG;AAWhB,MAAM,QAAQ,EAAE,MAAM,MAAM,OAAO,MAAM;AACzC,MAAM,O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* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5
|
+
"input",
|
|
6
|
+
{
|
|
7
|
+
type: "checkbox",
|
|
8
|
+
checked: value,
|
|
9
|
+
onChange: (e) => {
|
|
10
|
+
writer && writer(e.currentTarget.checked.toString());
|
|
11
|
+
e.currentTarget.blur();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
CheckboxRendererMixin
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../renderers/checkbox.tsx"],"sourcesContent":["import React from 'react';\nimport { WriterType } from '../types';\n\nexport const CheckboxRendererMixin = {\n bool(value: boolean, writer?: WriterType): any {\n return (\n <input\n type=\"checkbox\"\n checked={value}\n onChange={(e) => {\n writer && writer(e.currentTarget.checked.toString());\n e.currentTarget.blur();\n }}\n />\n );\n },\n};\n"],"names":["jsx"],"mappings":";AAGO,MAAM,wBAAwB;AAAA,EACnC,KAAK,OAAgB,QAA0B;AAE3C,WAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,UAAU,CAAC,MAAM;AACf,oBAAU,OAAO,EAAE,cAAc,QAAQ,UAAU;AACnD,YAAE,cAAc,KAAK;AAAA,QAAA;AAAA,MACvB;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import dayjs from "../_virtual/dayjs.min.js";
|
|
2
|
+
import { Table } from "../lib/table.js";
|
|
3
|
+
import { solveFormula } from "../formula/solver.js";
|
|
4
|
+
import { FormulaError } from "../formula/evaluator.js";
|
|
5
|
+
import { p2a } from "../lib/converters.js";
|
|
6
|
+
import { TimeDelta } from "../lib/time.js";
|
|
7
|
+
class Renderer {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.datetimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
10
|
+
this.dateFormat = "YYYY-MM-DD";
|
|
11
|
+
this.timeDeltaFormat = "HH:mm:ss";
|
|
12
|
+
this.applyMixins(props == null ? void 0 : props.mixins);
|
|
13
|
+
if (props == null) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { condition, complement } = props;
|
|
17
|
+
this.condition = condition;
|
|
18
|
+
this.complement = complement;
|
|
19
|
+
}
|
|
20
|
+
applyMixins(mixins) {
|
|
21
|
+
if (mixins == null) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
for (const mixin of mixins) {
|
|
25
|
+
for (const key in mixin) {
|
|
26
|
+
this[key] = mixin[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
call(table, point, writer) {
|
|
31
|
+
var _a;
|
|
32
|
+
const address = p2a(point);
|
|
33
|
+
const cache = table.getSolvedCache(address);
|
|
34
|
+
const value = cache || ((_a = table.getByPoint(point)) == null ? void 0 : _a.value);
|
|
35
|
+
return this.render(value, table, writer);
|
|
36
|
+
}
|
|
37
|
+
render(value, table, writer) {
|
|
38
|
+
var _a;
|
|
39
|
+
if (this.condition && !this.condition(value)) {
|
|
40
|
+
return this.complement ? this.complement(value) : this.stringify({ value });
|
|
41
|
+
}
|
|
42
|
+
switch (typeof value) {
|
|
43
|
+
case "object":
|
|
44
|
+
if (value instanceof Date) {
|
|
45
|
+
return this.date(value, writer);
|
|
46
|
+
}
|
|
47
|
+
if (value instanceof TimeDelta) {
|
|
48
|
+
return this.timedelta(value, writer);
|
|
49
|
+
}
|
|
50
|
+
if (value == null) {
|
|
51
|
+
return this.null(value, writer);
|
|
52
|
+
}
|
|
53
|
+
if (value instanceof Table) {
|
|
54
|
+
return this.render((_a = value.getByPoint({ y: value.top, x: value.left })) == null ? void 0 : _a.value, table, writer);
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
return this.array(value, writer);
|
|
58
|
+
}
|
|
59
|
+
if (value instanceof FormulaError) {
|
|
60
|
+
throw value;
|
|
61
|
+
}
|
|
62
|
+
return this.object(value, writer);
|
|
63
|
+
case "string":
|
|
64
|
+
return this.string(value, table, writer);
|
|
65
|
+
case "number":
|
|
66
|
+
return this.number(value, writer);
|
|
67
|
+
case "boolean":
|
|
68
|
+
return this.bool(value, writer);
|
|
69
|
+
case "undefined":
|
|
70
|
+
return this.undefined(value, writer);
|
|
71
|
+
case "function":
|
|
72
|
+
return value();
|
|
73
|
+
}
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
stringify(cell) {
|
|
77
|
+
const { value } = cell;
|
|
78
|
+
if (value instanceof Date) {
|
|
79
|
+
return this.date(value);
|
|
80
|
+
}
|
|
81
|
+
if (value instanceof TimeDelta) {
|
|
82
|
+
return this.timedelta(value);
|
|
83
|
+
}
|
|
84
|
+
if (value == null) {
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
return value.toString();
|
|
88
|
+
}
|
|
89
|
+
string(value, table, writer) {
|
|
90
|
+
if (value[0] === "'") {
|
|
91
|
+
return value.substring(1);
|
|
92
|
+
}
|
|
93
|
+
if (value[0] === "=") {
|
|
94
|
+
const result = solveFormula({ value, table, raise: true });
|
|
95
|
+
if (result === null) {
|
|
96
|
+
return this.null(null);
|
|
97
|
+
}
|
|
98
|
+
if (result === void 0) {
|
|
99
|
+
return this.undefined(void 0);
|
|
100
|
+
}
|
|
101
|
+
if (result.constructor.name === "Boolean") {
|
|
102
|
+
return String(result).toUpperCase();
|
|
103
|
+
}
|
|
104
|
+
if (result.constructor.name === "Date") {
|
|
105
|
+
return this.date(result);
|
|
106
|
+
}
|
|
107
|
+
return this.render(result, table, writer);
|
|
108
|
+
}
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
bool(value, writer) {
|
|
112
|
+
return value ? "TRUE" : "FALSE";
|
|
113
|
+
}
|
|
114
|
+
number(value, writer) {
|
|
115
|
+
if (isNaN(value)) {
|
|
116
|
+
return "NaN";
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
date(value, writer) {
|
|
121
|
+
if (value.getHours() + value.getMinutes() + value.getSeconds() === 0) {
|
|
122
|
+
return dayjs(value).format(this.dateFormat);
|
|
123
|
+
}
|
|
124
|
+
return dayjs(value).format(this.datetimeFormat);
|
|
125
|
+
}
|
|
126
|
+
timedelta(value, writer) {
|
|
127
|
+
return value.stringify(this.timeDeltaFormat);
|
|
128
|
+
}
|
|
129
|
+
array(value, writer) {
|
|
130
|
+
return value.map((v) => this.stringify({ value: v })).join(",");
|
|
131
|
+
}
|
|
132
|
+
object(value, writer) {
|
|
133
|
+
return JSON.stringify(value);
|
|
134
|
+
}
|
|
135
|
+
null(value, writer) {
|
|
136
|
+
return "";
|
|
137
|
+
}
|
|
138
|
+
undefined(value, writer) {
|
|
139
|
+
return "";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const defaultRenderer = new Renderer();
|
|
143
|
+
export {
|
|
144
|
+
Renderer,
|
|
145
|
+
defaultRenderer
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../renderers/core.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\nimport { CellType, PointType, WriterType } from '../types';\nimport { Table, UserTable } from '../lib/table';\nimport { solveFormula } from '../formula/solver';\nimport { FormulaError } from '../formula/evaluator';\nimport { p2a } from '../lib/converters';\nimport { TimeDelta } from '../lib/time';\n\ntype Condition = (value: any) => boolean;\n\ntype Stringify = (value: any) => string;\n\ntype Props = {\n condition?: Condition;\n complement?: Stringify;\n mixins?: RendererMixinType[];\n};\n\nexport interface RendererMixinType {\n render?(value: any, table: UserTable, writer?: WriterType): any;\n stringify?(cell: CellType): string;\n string?(value: string, table: UserTable, writer?: WriterType): any;\n bool?(value: boolean, writer?: WriterType): any;\n number?(value: number, writer?: WriterType): any;\n date?(value: Date, writer?: WriterType): any;\n timedelta?(value: TimeDelta, writer?: WriterType): any;\n array?(value: any[], writer?: WriterType): any;\n object?(value: any, writer?: WriterType): any;\n null?(value: null, writer?: WriterType): any;\n undefined?(value: undefined, writer?: WriterType): any;\n}\n\nexport class Renderer implements RendererMixinType {\n public datetimeFormat: string = 'YYYY-MM-DD HH:mm:ss';\n public dateFormat: string = 'YYYY-MM-DD';\n public timeDeltaFormat: string = 'HH:mm:ss';\n private condition?: Condition;\n private complement?: Stringify;\n\n constructor(props?: Props) {\n this.applyMixins(props?.mixins);\n if (props == null) {\n return;\n }\n const { condition, complement } = props;\n this.condition = condition;\n this.complement = complement;\n }\n\n private applyMixins(mixins?: RendererMixinType[]) {\n if (mixins == null) {\n return;\n }\n for (const mixin of mixins) {\n for (const key in mixin) {\n // @ts-expect-error mixin has the same fields as this\n this[key] = mixin[key];\n }\n }\n }\n\n public call(table: Table, point: PointType, writer?: WriterType): any {\n const address = p2a(point);\n const cache = table.getSolvedCache(address);\n const value = cache || table.getByPoint(point)?.value;\n return this.render(value, table, writer);\n }\n\n public render(value: any, table: Table, writer?: WriterType): any {\n if (this.condition && !this.condition(value)) {\n return this.complement ? this.complement(value) : this.stringify({ value });\n }\n\n switch (typeof value) {\n case 'object':\n if (value instanceof Date) {\n return this.date(value, writer);\n }\n if (value instanceof TimeDelta) {\n return this.timedelta(value, writer);\n }\n if (value == null) {\n return this.null(value, writer);\n }\n if (value instanceof Table) {\n return this.render(value.getByPoint({ y: value.top, x: value.left })?.value, table, writer);\n }\n if (Array.isArray(value)) {\n return this.array(value, writer);\n }\n if (value instanceof FormulaError) {\n throw value;\n }\n return this.object(value, writer);\n case 'string':\n return this.string(value, table, writer);\n case 'number':\n return this.number(value, writer);\n case 'boolean':\n return this.bool(value, writer);\n case 'undefined':\n return this.undefined(value, writer);\n case 'function':\n return value() as string;\n }\n return '';\n }\n\n stringify(cell: CellType): string {\n const { value } = cell;\n if (value instanceof Date) {\n return this.date(value);\n }\n if (value instanceof TimeDelta) {\n return this.timedelta(value);\n }\n if (value == null) {\n return '';\n }\n\n return value.toString();\n }\n\n string(value: string, table: Table, writer?: WriterType): any {\n if (value[0] === \"'\") {\n return value.substring(1);\n }\n if (value[0] === '=') {\n const result = solveFormula({ value, table, raise: true });\n if (result === null) {\n return this.null(null);\n }\n if (result === undefined) {\n return this.undefined(undefined);\n }\n if (result.constructor.name === 'Boolean') {\n return String(result).toUpperCase();\n }\n if (result.constructor.name === 'Date') {\n return this.date(result as Date);\n }\n return this.render(result, table, writer);\n }\n return value;\n }\n\n bool(value: boolean, writer?: WriterType): any {\n return value ? 'TRUE' : 'FALSE';\n }\n\n number(value: number, writer?: WriterType): any {\n if (isNaN(value)) {\n return 'NaN';\n }\n return value;\n }\n\n date(value: Date, writer?: WriterType): any {\n if (value.getHours() + value.getMinutes() + value.getSeconds() === 0) {\n return dayjs(value).format(this.dateFormat);\n }\n return dayjs(value).format(this.datetimeFormat);\n }\n\n timedelta(value: TimeDelta, writer?: WriterType): any {\n return value.stringify(this.timeDeltaFormat);\n }\n\n array(value: any[], writer?: WriterType): any {\n return value.map((v) => this.stringify({ value: v })).join(',');\n }\n\n object(value: any, writer?: WriterType): any {\n return JSON.stringify(value);\n }\n\n null(value: any, writer?: WriterType): any {\n return '';\n }\n\n undefined(value: undefined, writer?: WriterType): any {\n return '';\n }\n}\n\nexport type RendererType = Renderer;\nexport const defaultRenderer = new Renderer();\n"],"names":[],"mappings":";;;;;;AAiCO,MAAM,SAAsC;AAAA,EAOjD,YAAY,OAAe;AAN3B,SAAO,iBAAyB;AAChC,SAAO,aAAqB;AAC5B,SAAO,kBAA0B;AAK1B,SAAA,YAAY,+BAAO,MAAM;AAC9B,QAAI,SAAS,MAAM;AACjB;AAAA,IAAA;AAEI,UAAA,EAAE,WAAW,WAAA,IAAe;AAClC,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EAAA;AAAA,EAGZ,YAAY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ACT,aAAA;AAAA,IAAA;AAEF,WAAA;AAAA,EAAA;AAAA,EAGT,KAAK,OAAa,QAA0B;AACtC,QAAA,MAAM,aAAa,MAAM,eAAe,MAAM,WAAW,MAAM,GAAG;AACpE,aAAO,MAAM,KAAK,EAAE,OAAO,KAAK,UAAU;AAAA,IAAA;AAE5C,WAAO,MAAM,KAAK,EAAE,OAAO,KAAK,cAAc;AAAA,EAAA;AAAA,EAGhD,UAAU,OAAkB,QAA0B;AAC7C,WAAA,MAAM,UAAU,KAAK,eAAe;AAAA,EAAA;AAAA,EAG7C,MAAM,OAAc,QAA0B;AAC5C,WAAO,MAAM,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,OAAO,EAAG,CAAA,CAAC,EAAE,KAAK,GAAG;AAAA,EAAA;AAAA,EAGhE,OAAO,OAAY,QAA0B;AACpC,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA;AAAA,EAG7B,KAAK,OAAY,QAA0B;AAClC,WAAA;AAAA,EAAA;AAAA,EAGT,UAAU,OAAkB,QAA0B;AAC7C,WAAA;AAAA,EAAA;AAEX;AAGa,MAAA,kBAAkB,IAAI,SAAS;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const ThousandSeparatorRendererMixin = {
|
|
2
|
+
number(value) {
|
|
3
|
+
if (isNaN(value)) {
|
|
4
|
+
return "NaN";
|
|
5
|
+
}
|
|
6
|
+
const [int, fraction] = String(value).split(".");
|
|
7
|
+
const result = int.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
|
8
|
+
if (fraction == null) {
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
return `${result}.${fraction}`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
ThousandSeparatorRendererMixin
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=thousand_separator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thousand_separator.js","sources":["../../renderers/thousand_separator.ts"],"sourcesContent":["export const ThousandSeparatorRendererMixin = {\n number(value: number): any {\n if (isNaN(value)) {\n return 'NaN';\n }\n const [int, fraction] = String(value).split('.');\n const result = int.replace(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/g, '$1,');\n if (fraction == null) {\n return result;\n }\n return `${result}.${fraction}`;\n },\n};\n"],"names":[],"mappings":"AAAO,MAAM,iCAAiC;AAAA,EAC5C,OAAO,OAAoB;AACrB,QAAA,MAAM,KAAK,GAAG;AACT,aAAA;AAAA,IAAA;AAEH,UAAA,CAAC,KAAK,QAAQ,IAAI,OAAO,KAAK,EAAE,MAAM,GAAG;AAC/C,UAAM,SAAS,IAAI,QAAQ,4BAA4B,KAAK;AAC5D,QAAI,YAAY,MAAM;AACb,aAAA;AAAA,IAAA;AAEF,WAAA,GAAG,MAAM,IAAI,QAAQ;AAAA,EAAA;AAEhC;"}
|