@gridsheet/react-core 1.4.0-alpha.10 → 1.4.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export { TimeDelta } from './lib/time';
9
9
  export { x2c, c2x, y2r, r2y, p2a, a2p } from './lib/converters';
10
10
  export { updateTable } from './store/actions';
11
11
  export { PluginBase, useInitialPluginContext, usePluginContext } from './components/PluginBase';
12
- export type { MatrixType, CellType, FeedbackType, OptionsType, WriterType, CellsByAddressType, CellsByIdType, ModeType, HeadersType, HistoryType, StoreType, } from './types';
12
+ export type { MatrixType, CellType, FeedbackType, OptionsType, WriterType, CellsByAddressType, CellsByIdType, ModeType, HeadersType, HistoryType, StoreType, PointType, AreaType, ZoneType, } from './types';
13
13
  export type { Dispatcher } from './store';
14
14
  export { ThousandSeparatorRendererMixin } from './renderers/thousand_separator';
15
15
  export { CheckboxRendererMixin } from './renderers/checkbox';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EACL,KAAK,EACL,KAAK,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE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AM,YAAY,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChG,YAAY,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,GACT,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
@@ -27,9 +27,11 @@ const table2tsv = (table) => {
27
27
  const lines = [];
28
28
  const matrix = solveTable({ table, raise: false });
29
29
  matrix.forEach((row, i) => {
30
+ const x = table.left + i;
30
31
  const cols = [];
31
32
  row.forEach((col, j) => {
32
- const value = table.stringify({ y: i, x: j }, col);
33
+ const y = table.top + j;
34
+ const value = table.stringify({ y, x }, col);
33
35
  if (value.indexOf("\n") !== -1) {
34
36
  cols.push(`"${value.replace(/"/g, '""')}"`);
35
37
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.js","sources":["../../lib/clipboard.ts"],"sourcesContent":["import type { StoreType, AreaType } from '../types';\n\nimport { zoneToArea } from './structs';\nimport { solveTable } from '../formula/solver';\nimport { Table } from './table';\n\nexport const clip = (store: StoreType): AreaType => {\n const { selectingZone, choosing, editorRef, table } = store;\n const { y, x } = choosing;\n const selectingArea = zoneToArea(selectingZone);\n let area = selectingArea;\n if (area.left === -1) {\n area = { top: y, left: x, bottom: y, right: x };\n }\n const input = editorRef.current;\n const trimmed = table.trim(area);\n const tsv = table2tsv(trimmed);\n\n if (navigator.clipboard) {\n navigator.clipboard.writeText(tsv);\n } else if (input != null) {\n input.value = tsv;\n input.focus();\n input.select();\n document.execCommand('copy');\n input.value = '';\n input.blur();\n }\n return area;\n};\n\nconst table2tsv = (table: Table): string => {\n const lines: string[] = [];\n const matrix = solveTable({ table, raise: false });\n matrix.forEach((row, i) => {\n const cols: string[] = [];\n row.forEach((col, j) => {\n const value = table.stringify({ y: i, x: j }, col);\n if (value.indexOf('\\n') !== -1) {\n cols.push(`\"${value.replace(/\"/g, '\"\"')}\"`);\n } else {\n cols.push(value);\n }\n });\n lines.push(cols.join('\\t'));\n });\n return lines.join('\\n');\n};\n"],"names":[],"mappings":";;AAMa,MAAA,OAAO,CAAC,UAA+B;AAClD,QAAM,EAAE,eAAe,UAAU,WAAW,MAAU,IAAA;AAChD,QAAA,EAAE,GAAG,EAAA,IAAM;AACX,QAAA,gBAAgB,WAAW,aAAa;AAC9C,MAAI,OAAO;AACP,MAAA,KAAK,SAAS,IAAI;AACb,WAAA,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,EAAE;AAAA,EAAA;AAEhD,QAAM,QAAQ,UAAU;AAClB,QAAA,UAAU,MAAM,KAAK,IAAI;AACzB,QAAA,MAAM,UAAU,OAAO;AAE7B,MAAI,UAAU,WAAW;AACb,cAAA,UAAU,UAAU,GAAG;AAAA,EAAA,WACxB,SAAS,MAAM;AACxB,UAAM,QAAQ;AACd,UAAM,MAAM;AACZ,UAAM,OAAO;AACb,aAAS,YAAY,MAAM;AAC3B,UAAM,QAAQ;AACd,UAAM,KAAK;AAAA,EAAA;AAEN,SAAA;AACT;AAEA,MAAM,YAAY,CAAC,UAAyB;AAC1C,QAAM,QAAkB,CAAC;AACzB,QAAM,SAAS,WAAW,EAAE,OAAO,OAAO,OAAO;AAC1C,SAAA,QAAQ,CAAC,KAAK,MAAM;AACzB,UAAM,OAAiB,CAAC;AACpB,QAAA,QAAQ,CAAC,KAAK,MAAM;AAChB,YAAA,QAAQ,MAAM,UAAU,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG;AACjD,UAAI,MAAM,QAAQ,IAAI,MAAM,IAAI;AAC9B,aAAK,KAAK,IAAI,MAAM,QAAQ,MAAM,IAAI,CAAC,GAAG;AAAA,MAAA,OACrC;AACL,aAAK,KAAK,KAAK;AAAA,MAAA;AAAA,IACjB,CACD;AACD,UAAM,KAAK,KAAK,KAAK,GAAI,CAAC;AAAA,EAAA,CAC3B;AACM,SAAA,MAAM,KAAK,IAAI;AACxB;"}
1
+ {"version":3,"file":"clipboard.js","sources":["../../lib/clipboard.ts"],"sourcesContent":["import type { StoreType, AreaType } from '../types';\n\nimport { zoneToArea } from './structs';\nimport { solveTable } from '../formula/solver';\nimport { Table } from './table';\n\nexport const clip = (store: StoreType): AreaType => {\n const { selectingZone, choosing, editorRef, table } = store;\n const { y, x } = choosing;\n const selectingArea = zoneToArea(selectingZone);\n let area = selectingArea;\n if (area.left === -1) {\n area = { top: y, left: x, bottom: y, right: x };\n }\n const input = editorRef.current;\n const trimmed = table.trim(area);\n const tsv = table2tsv(trimmed);\n\n if (navigator.clipboard) {\n navigator.clipboard.writeText(tsv);\n } else if (input != null) {\n input.value = tsv;\n input.focus();\n input.select();\n document.execCommand('copy');\n input.value = '';\n input.blur();\n }\n return area;\n};\n\nconst table2tsv = (table: Table): string => {\n const lines: string[] = [];\n const matrix = solveTable({ table, raise: false });\n matrix.forEach((row, i) => {\n const x = table.left + i;\n const cols: string[] = [];\n row.forEach((col, j) => {\n const y = table.top + j;\n const value = table.stringify({ y, x }, col);\n if (value.indexOf('\\n') !== -1) {\n cols.push(`\"${value.replace(/\"/g, '\"\"')}\"`);\n } else {\n cols.push(value);\n }\n });\n lines.push(cols.join('\\t'));\n });\n return lines.join('\\n');\n};\n"],"names":[],"mappings":";;AAMa,MAAA,OAAO,CAAC,UAA+B;AAClD,QAAM,EAAE,eAAe,UAAU,WAAW,MAAU,IAAA;AAChD,QAAA,EAAE,GAAG,EAAA,IAAM;AACX,QAAA,gBAAgB,WAAW,aAAa;AAC9C,MAAI,OAAO;AACP,MAAA,KAAK,SAAS,IAAI;AACb,WAAA,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,EAAE;AAAA,EAAA;AAEhD,QAAM,QAAQ,UAAU;AAClB,QAAA,UAAU,MAAM,KAAK,IAAI;AACzB,QAAA,MAAM,UAAU,OAAO;AAE7B,MAAI,UAAU,WAAW;AACb,cAAA,UAAU,UAAU,GAAG;AAAA,EAAA,WACxB,SAAS,MAAM;AACxB,UAAM,QAAQ;AACd,UAAM,MAAM;AACZ,UAAM,OAAO;AACb,aAAS,YAAY,MAAM;AAC3B,UAAM,QAAQ;AACd,UAAM,KAAK;AAAA,EAAA;AAEN,SAAA;AACT;AAEA,MAAM,YAAY,CAAC,UAAyB;AAC1C,QAAM,QAAkB,CAAC;AACzB,QAAM,SAAS,WAAW,EAAE,OAAO,OAAO,OAAO;AAC1C,SAAA,QAAQ,CAAC,KAAK,MAAM;AACnB,UAAA,IAAI,MAAM,OAAO;AACvB,UAAM,OAAiB,CAAC;AACpB,QAAA,QAAQ,CAAC,KAAK,MAAM;AAChB,YAAA,IAAI,MAAM,MAAM;AACtB,YAAM,QAAQ,MAAM,UAAU,EAAE,GAAG,KAAK,GAAG;AAC3C,UAAI,MAAM,QAAQ,IAAI,MAAM,IAAI;AAC9B,aAAK,KAAK,IAAI,MAAM,QAAQ,MAAM,IAAI,CAAC,GAAG;AAAA,MAAA,OACrC;AACL,aAAK,KAAK,KAAK;AAAA,MAAA;AAAA,IACjB,CACD;AACD,UAAM,KAAK,KAAK,KAAK,GAAI,CAAC;AAAA,EAAA,CAC3B;AACM,SAAA,MAAM,KAAK,IAAI;AACxB;"}
@@ -9,17 +9,17 @@ type Props = {
9
9
  mixins?: RendererMixinType[];
10
10
  };
11
11
  export interface RendererMixinType {
12
- render?(value: any, table: UserTable, writer?: WriterType): any;
12
+ render?(value: any, table: UserTable, writer?: WriterType, position?: PointType): any;
13
13
  stringify?(cell: CellType): string;
14
- string?(value: string, table: UserTable, writer?: WriterType): any;
15
- bool?(value: boolean, writer?: WriterType): any;
16
- number?(value: number, writer?: WriterType): any;
17
- date?(value: Date, writer?: WriterType): any;
18
- timedelta?(value: TimeDelta, writer?: WriterType): any;
19
- array?(value: any[], writer?: WriterType): any;
20
- object?(value: any, writer?: WriterType): any;
21
- null?(value: null, writer?: WriterType): any;
22
- undefined?(value: undefined, writer?: WriterType): any;
14
+ string?(value: string, table: UserTable, writer?: WriterType, position?: PointType): any;
15
+ bool?(value: boolean, writer?: WriterType, position?: PointType): any;
16
+ number?(value: number, writer?: WriterType, position?: PointType): any;
17
+ date?(value: Date, writer?: WriterType, position?: PointType): any;
18
+ timedelta?(value: TimeDelta, writer?: WriterType, position?: PointType): any;
19
+ array?(value: any[], writer?: WriterType, position?: PointType): any;
20
+ object?(value: any, writer?: WriterType, position?: PointType): any;
21
+ null?(value: null, writer?: WriterType, position?: PointType): any;
22
+ undefined?(value: undefined, writer?: WriterType, position?: PointType): any;
23
23
  }
24
24
  export declare class Renderer implements RendererMixinType {
25
25
  datetimeFormat: string;
@@ -30,17 +30,17 @@ export declare class Renderer implements RendererMixinType {
30
30
  constructor(props?: Props);
31
31
  private applyMixins;
32
32
  call(table: Table, point: PointType, writer?: WriterType): any;
33
- render(value: any, table: Table, writer?: WriterType): any;
34
- stringify(cell: CellType): string;
35
- string(value: string, table: Table, writer?: WriterType): any;
36
- bool(value: boolean, writer?: WriterType): any;
37
- number(value: number, writer?: WriterType): any;
38
- date(value: Date, writer?: WriterType): any;
39
- timedelta(value: TimeDelta, writer?: WriterType): any;
40
- array(value: any[], writer?: WriterType): any;
41
- object(value: any, writer?: WriterType): any;
42
- null(value: any, writer?: WriterType): any;
43
- undefined(value: undefined, writer?: WriterType): any;
33
+ render(value: any, table: Table, writer?: WriterType, position?: PointType): any;
34
+ stringify(cell: CellType, position?: PointType): string;
35
+ string(value: string, table: Table, writer?: WriterType, position?: PointType): any;
36
+ bool(value: boolean, writer?: WriterType, position?: PointType): any;
37
+ number(value: number, writer?: WriterType, position?: PointType): any;
38
+ date(value: Date, writer?: WriterType, position?: PointType): any;
39
+ timedelta(value: TimeDelta, writer?: WriterType, position?: PointType): any;
40
+ array(value: any[], writer?: WriterType, position?: PointType): any;
41
+ object(value: any, writer?: WriterType, position?: PointType): any;
42
+ null(value: any, writer?: WriterType, position?: PointType): any;
43
+ undefined(value: undefined, writer?: WriterType, position?: PointType): any;
44
44
  }
45
45
  export type RendererType = Renderer;
46
46
  export declare const defaultRenderer: Renderer;
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../renderers/core.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;AAEzC,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AAExC,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,CAAC,KAAK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AE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAuBnF,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAIpE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAOrE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAOjE,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAI3E,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAInE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAIlE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;IAIhE,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;CAG5E;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;AACpC,eAAO,MAAM,eAAe,UAAiB,CAAC"}
@@ -32,9 +32,9 @@ class Renderer {
32
32
  const address = p2a(point);
33
33
  const cache = table.getSolvedCache(address);
34
34
  const value = cache || ((_a = table.getByPoint(point)) == null ? void 0 : _a.value);
35
- return this.render(value, table, writer);
35
+ return this.render(value, table, writer, point);
36
36
  }
37
- render(value, table, writer) {
37
+ render(value, table, writer, position) {
38
38
  var _a;
39
39
  if (this.condition && !this.condition(value)) {
40
40
  return this.complement ? this.complement(value) : this.stringify({ value });
@@ -42,38 +42,38 @@ class Renderer {
42
42
  switch (typeof value) {
43
43
  case "object":
44
44
  if (value instanceof Date) {
45
- return this.date(value, writer);
45
+ return this.date(value, writer, position);
46
46
  }
47
47
  if (value instanceof TimeDelta) {
48
- return this.timedelta(value, writer);
48
+ return this.timedelta(value, writer, position);
49
49
  }
50
50
  if (value == null) {
51
- return this.null(value, writer);
51
+ return this.null(value, writer, position);
52
52
  }
53
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);
54
+ return this.render((_a = value.getByPoint({ y: value.top, x: value.left })) == null ? void 0 : _a.value, table, writer, position);
55
55
  }
56
56
  if (Array.isArray(value)) {
57
- return this.array(value, writer);
57
+ return this.array(value, writer, position);
58
58
  }
59
59
  if (value instanceof FormulaError) {
60
60
  throw value;
61
61
  }
62
- return this.object(value, writer);
62
+ return this.object(value, writer, position);
63
63
  case "string":
64
- return this.string(value, table, writer);
64
+ return this.string(value, table, writer, position);
65
65
  case "number":
66
- return this.number(value, writer);
66
+ return this.number(value, writer, position);
67
67
  case "boolean":
68
- return this.bool(value, writer);
68
+ return this.bool(value, writer, position);
69
69
  case "undefined":
70
- return this.undefined(value, writer);
70
+ return this.undefined(value, writer, position);
71
71
  case "function":
72
72
  return value();
73
73
  }
74
74
  return "";
75
75
  }
76
- stringify(cell) {
76
+ stringify(cell, position) {
77
77
  const { value } = cell;
78
78
  if (value instanceof Date) {
79
79
  return this.date(value);
@@ -86,7 +86,7 @@ class Renderer {
86
86
  }
87
87
  return value.toString();
88
88
  }
89
- string(value, table, writer) {
89
+ string(value, table, writer, position) {
90
90
  if (value[0] === "'") {
91
91
  return value.substring(1);
92
92
  }
@@ -108,34 +108,34 @@ class Renderer {
108
108
  }
109
109
  return value;
110
110
  }
111
- bool(value, writer) {
111
+ bool(value, writer, position) {
112
112
  return value ? "TRUE" : "FALSE";
113
113
  }
114
- number(value, writer) {
114
+ number(value, writer, position) {
115
115
  if (isNaN(value)) {
116
116
  return "NaN";
117
117
  }
118
118
  return value;
119
119
  }
120
- date(value, writer) {
120
+ date(value, writer, position) {
121
121
  if (value.getHours() + value.getMinutes() + value.getSeconds() === 0) {
122
122
  return dayjs(value).format(this.dateFormat);
123
123
  }
124
124
  return dayjs(value).format(this.datetimeFormat);
125
125
  }
126
- timedelta(value, writer) {
126
+ timedelta(value, writer, position) {
127
127
  return value.stringify(this.timeDeltaFormat);
128
128
  }
129
- array(value, writer) {
129
+ array(value, writer, position) {
130
130
  return value.map((v) => this.stringify({ value: v })).join(",");
131
131
  }
132
- object(value, writer) {
132
+ object(value, writer, position) {
133
133
  return JSON.stringify(value);
134
134
  }
135
- null(value, writer) {
135
+ null(value, writer, position) {
136
136
  return "";
137
137
  }
138
- undefined(value, writer) {
138
+ undefined(value, writer, position) {
139
139
  return "";
140
140
  }
141
141
  }
@@ -1 +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,QAA8B;AAChD,QAAI,UAAU,MAAM;AAClB;AAAA,IAAA;AAEF,eAAW,SAAS,QAAQ;AAC1B,iBAAW,OAAO,OAAO;AAElB,aAAA,GAAG,IAAI,MAAM,GAAG;AAAA,MAAA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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;"}
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, position?: PointType): any;\n stringify?(cell: CellType): string;\n string?(value: string, table: UserTable, writer?: WriterType, position?: PointType): any;\n bool?(value: boolean, writer?: WriterType, position?: PointType): any;\n number?(value: number, writer?: WriterType, position?: PointType): any;\n date?(value: Date, writer?: WriterType, position?: PointType): any;\n timedelta?(value: TimeDelta, writer?: WriterType, position?: PointType): any;\n array?(value: any[], writer?: WriterType, position?: PointType): any;\n object?(value: any, writer?: WriterType, position?: PointType): any;\n null?(value: null, writer?: WriterType, position?: PointType): any;\n undefined?(value: undefined, writer?: WriterType, position?: PointType): 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, point);\n }\n\n public render(value: any, table: Table, writer?: WriterType, position?: PointType): 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, position);\n }\n if (value instanceof TimeDelta) {\n return this.timedelta(value, writer, position);\n }\n if (value == null) {\n return this.null(value, writer, position);\n }\n if (value instanceof Table) {\n return this.render(value.getByPoint({ y: value.top, x: value.left })?.value, table, writer, position);\n }\n if (Array.isArray(value)) {\n return this.array(value, writer, position);\n }\n if (value instanceof FormulaError) {\n throw value;\n }\n return this.object(value, writer, position);\n case 'string':\n return this.string(value, table, writer, position);\n case 'number':\n return this.number(value, writer, position);\n case 'boolean':\n return this.bool(value, writer, position);\n case 'undefined':\n return this.undefined(value, writer, position);\n case 'function':\n return value() as string;\n }\n return '';\n }\n\n stringify(cell: CellType, position?: PointType): 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, position?: PointType): 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, position?: PointType): any {\n return value ? 'TRUE' : 'FALSE';\n }\n\n number(value: number, writer?: WriterType, position?: PointType): any {\n if (isNaN(value)) {\n return 'NaN';\n }\n return value;\n }\n\n date(value: Date, writer?: WriterType, position?: PointType): 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, position?: PointType): any {\n return value.stringify(this.timeDeltaFormat);\n }\n\n array(value: any[], writer?: WriterType, position?: PointType): any {\n return value.map((v) => this.stringify({ value: v })).join(',');\n }\n\n object(value: any, writer?: WriterType, position?: PointType): any {\n return JSON.stringify(value);\n }\n\n null(value: any, writer?: WriterType, position?: PointType): any {\n return '';\n }\n\n undefined(value: undefined, writer?: WriterType, position?: PointType): 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,QAA8B;AACh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UAA2B;AACnE,WAAO,QAAQ,SAAS;AAAA,EAAA;AAAA,EAG1B,OAAO,OAAe,QAAqB,UAA2B;AAChE,QAAA,MAAM,KAAK,GAAG;AACT,aAAA;AAAA,IAAA;AAEF,WAAA;AAAA,EAAA;AAAA,EAGT,KAAK,OAAa,QAAqB,UAA2B;AAC5D,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,QAAqB,UAA2B;AACnE,WAAA,MAAM,UAAU,KAAK,eAAe;AAAA,EAAA;AAAA,EAG7C,MAAM,OAAc,QAAqB,UAA2B;AAClE,WAAO,MAAM,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,OAAO,EAAG,CAAA,CAAC,EAAE,KAAK,GAAG;AAAA,EAAA;AAAA,EAGhE,OAAO,OAAY,QAAqB,UAA2B;AAC1D,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA;AAAA,EAG7B,KAAK,OAAY,QAAqB,UAA2B;AACxD,WAAA;AAAA,EAAA;AAAA,EAGT,UAAU,OAAkB,QAAqB,UAA2B;AACnE,WAAA;AAAA,EAAA;AAEX;AAGa,MAAA,kBAAkB,IAAI,SAAS;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsheet/react-core",
3
- "version": "1.4.0-alpha.10",
3
+ "version": "1.4.0-alpha.12",
4
4
  "description": "Spreadsheet component for React",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",