@ahoo-wang/wow-view-engine 10.0.0-beta.3 → 10.0.0-beta.4
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/{actions-CThpS7Yj.js → actions-G0GVzYhc.js} +2 -2
- package/dist/actions-G0GVzYhc.js.map +1 -0
- package/dist/cartesianBrush-bgRuE6Ks.js.map +1 -1
- package/dist/echarts-rjTKpBsf.js.map +1 -1
- package/dist/echartsGeo-qZv2ZF9e.js.map +1 -1
- package/dist/echartsHierarchy-DHNP9W4v.js.map +1 -1
- package/dist/echartsStatistics-DCDWqvde.js.map +1 -1
- package/dist/echartsTime-DIRSRMnr.js.map +1 -1
- package/dist/{export-D6bnNjrA.js → export-CEOFAImT.js} +2 -2
- package/dist/export-CEOFAImT.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{react-0RrtrG7t.js → react-BlzB-Chr.js} +1173 -1173
- package/dist/react-BlzB-Chr.js.map +1 -0
- package/dist/react-router.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/routes-CMXKbAo2.js.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/ui.js +143 -143
- package/dist/ui.js.map +1 -1
- package/dist/{viewEngine-DL-S0OAZ.js → viewEngine-lAwpy3jk.js} +4 -4
- package/dist/viewEngine-lAwpy3jk.js.map +1 -0
- package/package.json +14 -14
- package/dist/actions-CThpS7Yj.js.map +0 -1
- package/dist/export-D6bnNjrA.js.map +0 -1
- package/dist/react-0RrtrG7t.js.map +0 -1
- package/dist/viewEngine-DL-S0OAZ.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-D6bnNjrA.js","names":["RecordData","recordValue","ExportColumn","field","label","ExportFormat","value","column","C","CSV_BOM","CRLF","MUST_QUOTE","FORMULA_START","PLAIN_NUMBER","CsvOptions","neutralizeFormulas","CsvCell","text","serializeCsv","rows","columns","format","options","writeCsv","map","row","header","neutralize","cell","csvField","lines","push","line","join","written","String","evaluable","test","split","recordValue","CRLF","MUST_QUOTE","FORMULA_START","PLAIN_NUMBER","serializeCsv","writeCsv","columns","column","rows","value","row","format","options","neutralize","field","csvField","cell","lines","header","label","line","written","text","evaluable"],"sources":["../src/record/export.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RecordData } from '../model/index.js';\nimport { recordValue } from './project.js';\n\n/** The least an export needs of a column: where to read it, what to call it. */\nexport interface ExportColumn {\n /** A Wow query path, read the way a cell reads it. */\n field: string;\n /** What the header row calls this column. */\n label: string;\n}\n\n/**\n * How one value is written.\n *\n * It is injected rather than decided here, because how a value *reads* is the\n * UI's answer — an enum by its label, a time in the surface's zone, a number\n * in its field's format — and this layer has no catalogue, no locale and no\n * renderers. The column rides along with the value, so one formatter serves\n * every column of the table.\n */\nexport type ExportFormat<C extends ExportColumn = ExportColumn> = (\n value: unknown,\n column: C,\n) => string;\n\n/**\n * The byte order mark Excel needs to read a UTF-8 CSV as UTF-8.\n *\n * Without it Excel on Windows reads the file in the machine's ANSI code page\n * and every Chinese name in it arrives as mojibake — which is most of what\n * these exports carry.\n */\nexport const CSV_BOM = '';\n\n/** RFC 4180 ends every record with CRLF, the last one included. */\nconst CRLF = '\\r\\n';\n\n/** The characters that oblige a field to be quoted, the quote included. */\nconst MUST_QUOTE = /[\"\\r\\n,]/;\n\n/**\n * What a spreadsheet may read a cell as a formula by: its first character\n * (OWASP, CSV Injection). `=`, `+`, `-` and `@` start a formula or a\n * function; a tab or a carriage return in front hides one from a reader who\n * trims.\n */\nconst FORMULA_START = /^[=+\\-@\\t\\r]/;\n\n/**\n * A text that is a number and nothing else: a sign, digits, one decimal\n * point, an exponent. No separators, no currency, no spaces — nothing a\n * spreadsheet could read as more than one number.\n */\nconst PLAIN_NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\n\n/** How a CSV is written. */\nexport interface CsvOptions {\n /**\n * Whether a cell a spreadsheet could evaluate is written with an\n * apostrophe in front, so it opens as the text it is. On unless set to\n * `false`.\n *\n * A file leaves the page: it is opened in Excel, often by someone other\n * than whoever exported it, and a value somebody typed into a text field\n * — `=HYPERLINK(…)`, `=cmd|' /C calc'!A0` — would run there as a formula\n * (OWASP, CSV Injection). So every cell whose text starts with `=`, `+`,\n * `-`, `@`, a tab or a carriage return gets a leading `'`, the header's\n * labels included, since a definition names them.\n *\n * Two kinds of cell are left alone, because a spreadsheet reads them as a\n * number and never as a formula: one whose value was a number (a negative\n * amount, however its field formats it — `-1,204.50`, `-$12.00`), and one\n * whose text is a plain number (`-12.5` held by a text field). Prefixing\n * either would only make the file differ from the screen.\n *\n * Turn it off only where the file never reaches a spreadsheet — a\n * pipeline that reads the CSV back as data and wants the text as stored.\n */\n neutralizeFormulas?: boolean;\n}\n\n/** One cell of a file: the value it was read from, and the text it reads as. */\nexport interface CsvCell {\n /** What the row held; only its type is looked at: a number is never a formula. */\n value: unknown;\n /** The text written, before any escaping. */\n text: string;\n}\n\n/**\n * The rows as a CSV, RFC 4180 with a BOM in front.\n *\n * The header is the labels of the columns handed over, in the order they are\n * handed over — which is the projected order of the visible columns, so the\n * file carries the table's columns rather than the definition's fields.\n *\n * Nothing here looks at what a value *means*: `format` has already decided\n * that, and what is left is writing it (`writeCsv`) — the escaping, and the\n * formulas neutralized unless `options` says otherwise (`CsvOptions`).\n */\nexport function serializeCsv<C extends ExportColumn>(\n rows: readonly RecordData[],\n columns: readonly C[],\n format: ExportFormat<C>,\n options: CsvOptions = {},\n): string {\n return writeCsv(\n columns.map(column => column.label),\n rows.map(row =>\n columns.map(column => {\n const value = recordValue(row, column.field);\n return { value, text: format(value, column) };\n }),\n ),\n options,\n );\n}\n\n/**\n * Cells already read, as a CSV: the one writer every export goes through —\n * a record view's rows (`serializeCsv`) and an analysis's groups alike — so\n * the escaping and the formula rule (`CsvOptions.neutralizeFormulas`) are\n * one rule rather than one per export.\n */\nexport function writeCsv(\n header: readonly string[],\n rows: readonly (readonly CsvCell[])[],\n options: CsvOptions = {},\n): string {\n const neutralize = options.neutralizeFormulas !== false;\n const field = (cell: CsvCell) => csvField(cell, neutralize);\n const lines = [header.map(label => field({ value: label, text: label }))];\n for (const row of rows) lines.push(row.map(field));\n return `${CSV_BOM}${lines.map(line => line.join(',')).join(CRLF)}${CRLF}`;\n}\n\n/**\n * One field: neutralized where a spreadsheet could evaluate it, then quoted\n * where it has to be.\n *\n * The text is typed as a string, but it comes from a function a host may\n * have written, so it is coerced rather than trusted: `null` written into\n * the file as the word `null` is a value the table never showed.\n */\nfunction csvField({ value, text }: CsvCell, neutralize: boolean): string {\n let written = typeof text === 'string' ? text : String(text ?? '');\n if (neutralize && evaluable(value, written)) written = `'${written}`;\n return MUST_QUOTE.test(written)\n ? `\"${written.split('\"').join('\"\"')}\"`\n : written;\n}\n\n/** Whether a spreadsheet opening this cell could evaluate it (`CsvOptions`). */\nfunction evaluable(value: unknown, text: string): boolean {\n if (typeof value === 'number' || typeof value === 'bigint') return false;\n return FORMULA_START.test(text) && !PLAIN_NUMBER.test(text);\n}\n"],"mappings":";AAgDA,IAAMU,IAAO,QAGPC,IAAa,YAQbC,IAAgB,gBAOhBC,IAAe;AA+CrB,SAAgBK,EACdC,GACAC,GACAC,GACAC,IAAsB,CAAC,GACf;CACR,OAAOC,EACLH,EAAQI,KAAIjB,MAAUA,EAAOH,KAAK,GAClCe,EAAKK,KAAIC,MACPL,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