@gridsheet/react-core 1.4.0-alpha.11 → 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.
@@ -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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsheet/react-core",
3
- "version": "1.4.0-alpha.11",
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",