@svgrid/enterprise 3.1.0 → 3.1.2

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.
Files changed (78) hide show
  1. package/dist/SvSheet.svelte +93 -8
  2. package/dist/cdn/svgrid-enterprise.svelte-external.js +9339 -9077
  3. package/dist/designer/assets/{GridMenus-8gTNssgV.js → GridMenus-DGZJKFvX.js} +1 -1
  4. package/dist/designer/assets/SvGrid.helpers-DE5mmORW.js +1 -0
  5. package/dist/designer/assets/{SvGridCellEditor-DMoWJjEI.js → SvGridCellEditor-C7NWcnNC.js} +1 -1
  6. package/dist/designer/assets/{SvGridChart-Cy1ATrWh.js → SvGridChart-Fg43Yi0M.js} +2 -2
  7. package/dist/designer/assets/{SvGridChartBuilder-eQ3mn0L9.js → SvGridChartBuilder-BqGuA3yU.js} +1 -1
  8. package/dist/designer/assets/{SvGridChartPanel-CATdVc9X.js → SvGridChartPanel-BsiXRAnx.js} +3 -3
  9. package/dist/designer/assets/{SvGridChartView-CmsZtCED.js → SvGridChartView-BgttK0tR.js} +1 -1
  10. package/dist/designer/assets/{SvListBox-BDS66lmZ.js → SvListBox-v2jm0-vf.js} +1 -1
  11. package/dist/designer/assets/cell-formatting-BWrW_O0n.js +1 -0
  12. package/dist/designer/assets/{chart-Cn7MnNqA.js → chart-BIl-dIRv.js} +1 -1
  13. package/dist/designer/assets/{chart-panel-messages-Dz7PTIqT.js → chart-panel-messages-4cF2vw7L.js} +1 -1
  14. package/dist/designer/assets/{chart-summary-BD1qYB2R.js → chart-summary-B7bTtSCC.js} +1 -1
  15. package/dist/designer/assets/{chart-trend-B8xr5LuD.js → chart-trend-CLsn5Hgd.js} +1 -1
  16. package/dist/designer/assets/export-format-DGscOjS9.js +6 -0
  17. package/dist/designer/assets/{index-BSjv6Qec.js → index-V_cMXdxt.js} +314 -314
  18. package/dist/designer/assets/index-l21iGkpF.css +1 -0
  19. package/dist/designer/assets/src-Mu7AGqT8.js +58 -0
  20. package/dist/designer/assets/validate-YxSrBF1H.js +1 -0
  21. package/dist/designer/index.html +12 -12
  22. package/dist/export-ooxml.d.ts +10 -0
  23. package/dist/export-ooxml.js +22 -5
  24. package/dist/import.js +11 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +1 -1
  27. package/dist/node/studio.js +236 -132
  28. package/dist/server/index.d.ts +1 -0
  29. package/dist/server/index.js +1 -0
  30. package/dist/server/server-row-model.d.ts +9 -0
  31. package/dist/server/server-row-model.js +120 -3
  32. package/dist/server/worker-data-source.d.ts +62 -0
  33. package/dist/server/worker-data-source.js +133 -0
  34. package/dist/sheet/objects.d.ts +47 -0
  35. package/dist/sheet/objects.js +33 -0
  36. package/dist/studio/cli.js +55 -1
  37. package/dist/studio/emit-project.js +8 -3
  38. package/dist/studio/init-flow.d.ts +6 -1
  39. package/dist/studio/init-flow.js +43 -2
  40. package/dist/studio/scaffold-app.d.ts +6 -0
  41. package/dist/studio/scaffold-app.js +5 -3
  42. package/dist/studio/scaffold.js +29 -12
  43. package/dist/sveltekit/in-memory.d.ts +21 -1
  44. package/dist/sveltekit/in-memory.js +153 -105
  45. package/dist/sveltekit/index.d.ts +1 -1
  46. package/dist/version.d.ts +14 -1
  47. package/dist/version.js +14 -1
  48. package/dist/wc/{GridMenus-By9vPuq0.js → GridMenus-6_fF5jIm.js} +2 -2
  49. package/dist/wc/{SvGrid.helpers-BdVDtjUm.js → SvGrid.helpers-zBkDTryR.js} +36 -37
  50. package/dist/wc/{SvGridCellEditor-Bnf1Kr5C.js → SvGridCellEditor-CzUKEbkI.js} +1 -1
  51. package/dist/wc/{SvGridChart-BqUJh2pG.js → SvGridChart-C6UvNIbN.js} +3 -3
  52. package/dist/wc/{SvGridChartBuilder-CGycC5cn.js → SvGridChartBuilder-ikf_5LyW.js} +3 -3
  53. package/dist/wc/{SvGridChartPanel-CRnizsHD.js → SvGridChartPanel-Dc_jj7B-.js} +4 -4
  54. package/dist/wc/{SvGridChartView-D1pa_xMy.js → SvGridChartView-thkznAOb.js} +2 -2
  55. package/dist/wc/{cell-formatting-CBfgahv1.js → cell-formatting-hb3vzxhJ.js} +27 -5
  56. package/dist/wc/{chart-6OXlybVT.js → chart-CV5D7_k8.js} +1 -1
  57. package/dist/wc/{chart-summary-2m3ia1-n.js → chart-summary-DGx0QhJa.js} +1 -1
  58. package/dist/wc/{chart-trend-CQOQtTMl.js → chart-trend-BIRH_xH8.js} +1 -1
  59. package/dist/wc/sv-sheet-element.js +7454 -7352
  60. package/dist/wc/{svelte-virtualizer.svelte-CXtQy2TQ.js → svelte-virtualizer.svelte-Du4tjrIP.js} +7 -3
  61. package/dist/wc/{validate-BqDthkNr.js → validate-JAuMsk6Z.js} +36 -36
  62. package/dist/worker/columnar.d.ts +42 -0
  63. package/dist/worker/columnar.js +410 -0
  64. package/dist/worker/index.d.ts +12 -0
  65. package/dist/worker/index.js +12 -0
  66. package/dist/worker/infer-schema.d.ts +21 -0
  67. package/dist/worker/infer-schema.js +34 -0
  68. package/dist/worker/protocol.d.ts +73 -0
  69. package/dist/worker/protocol.js +14 -0
  70. package/dist/worker/serve.d.ts +44 -0
  71. package/dist/worker/serve.js +100 -0
  72. package/package.json +7 -3
  73. package/dist/designer/assets/SvGrid.helpers-BgT-gnCo.js +0 -1
  74. package/dist/designer/assets/cell-formatting-BbubJTVz.js +0 -1
  75. package/dist/designer/assets/export-format-DGckmgKr.js +0 -6
  76. package/dist/designer/assets/index-_JVFxt02.css +0 -1
  77. package/dist/designer/assets/src-DUQ4xE3x.js +0 -58
  78. package/dist/designer/assets/validate-C3B8QKsM.js +0 -1
@@ -0,0 +1,34 @@
1
+ /** Rows read to decide each field's type. */
2
+ const SAMPLE_SIZE = 200;
3
+ /**
4
+ * A field is `number` or `boolean` when every non-empty sampled value is one,
5
+ * and `text` otherwise. Dates come out as `text`: send them as ISO strings,
6
+ * which sort and compare correctly as text, or as epoch numbers.
7
+ */
8
+ export function inferSchemaFromRows(rows, options = {}) {
9
+ const sample = rows.slice(0, SAMPLE_SIZE);
10
+ const seen = new Map();
11
+ for (const row of sample) {
12
+ for (const [field, value] of Object.entries(row)) {
13
+ let kinds = seen.get(field);
14
+ if (!kinds)
15
+ seen.set(field, (kinds = new Set()));
16
+ if (value != null && value !== '')
17
+ kinds.add(typeof value);
18
+ }
19
+ }
20
+ const fields = [...seen].map(([field, kinds]) => {
21
+ let type = 'text';
22
+ if (kinds.size === 1 && kinds.has('number'))
23
+ type = 'number';
24
+ else if (kinds.size === 1 && kinds.has('boolean'))
25
+ type = 'boolean';
26
+ return { field: field, type };
27
+ });
28
+ const idField = options.idField ?? (seen.has('id') ? 'id' : fields[0]?.field) ?? 'id';
29
+ return {
30
+ name: options.name ?? 'rows',
31
+ idField: idField,
32
+ fields,
33
+ };
34
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The messages between `createWorkerDataSource` (main thread) and
3
+ * `serveWorkerDataSource` (inside the worker). Internal: both ends ship in
4
+ * the same package version, so the shape can change without a migration.
5
+ *
6
+ * Every message carries `channel`, so a worker that also answers messages of
7
+ * its own can host the data source beside them; each end ignores anything
8
+ * without it.
9
+ */
10
+ import type { EntitySchema } from '../schema.js';
11
+ export declare const CHANNEL: "svgrid-worker-data-source";
12
+ /** The data source methods the client may call across the boundary. */
13
+ export type WorkerMethod = 'getRows' | 'createRow' | 'updateRow' | 'deleteRow' | 'updateWhere' | 'getAggregate';
14
+ /** Main thread to worker. */
15
+ export type ToWorker =
16
+ /** Replace the dataset. Answered with a `result` carrying the row count. */
17
+ {
18
+ channel: typeof CHANNEL;
19
+ kind: 'load';
20
+ id: number;
21
+ rows: ReadonlyArray<unknown>;
22
+ schema?: EntitySchema;
23
+ idField?: string;
24
+ } | {
25
+ channel: typeof CHANNEL;
26
+ kind: 'call';
27
+ id: number;
28
+ method: WorkerMethod;
29
+ args: unknown[];
30
+ }
31
+ /** Drop a queued call: its block was evicted, or the sort or filter moved on. */
32
+ | {
33
+ channel: typeof CHANNEL;
34
+ kind: 'cancel';
35
+ id: number;
36
+ };
37
+ /** An error as it crosses the boundary: an `Error` does not survive cloning intact everywhere. */
38
+ export type WorkerError = {
39
+ name: string;
40
+ message: string;
41
+ };
42
+ /** Worker to main thread. */
43
+ export type FromWorker =
44
+ /** The worker holds data and answers calls. Sent after every load. */
45
+ {
46
+ channel: typeof CHANNEL;
47
+ kind: 'ready';
48
+ rowCount: number;
49
+ }
50
+ /** The worker's own `rows` loader threw: nothing will ever be answered. */
51
+ | {
52
+ channel: typeof CHANNEL;
53
+ kind: 'failed';
54
+ error: WorkerError;
55
+ } | {
56
+ channel: typeof CHANNEL;
57
+ kind: 'result';
58
+ id: number;
59
+ ok: true;
60
+ value: unknown;
61
+ } | {
62
+ channel: typeof CHANNEL;
63
+ kind: 'result';
64
+ id: number;
65
+ ok: false;
66
+ error: WorkerError;
67
+ };
68
+ export declare function toWorkerError(error: unknown): WorkerError;
69
+ export declare function fromWorkerError(error: WorkerError): Error;
70
+ export declare function isChannelMessage(data: unknown): data is {
71
+ channel: typeof CHANNEL;
72
+ kind: string;
73
+ };
@@ -0,0 +1,14 @@
1
+ export const CHANNEL = 'svgrid-worker-data-source';
2
+ export function toWorkerError(error) {
3
+ if (error instanceof Error)
4
+ return { name: error.name, message: error.message };
5
+ return { name: 'Error', message: String(error) };
6
+ }
7
+ export function fromWorkerError(error) {
8
+ const out = new Error(error.message);
9
+ out.name = error.name;
10
+ return out;
11
+ }
12
+ export function isChannelMessage(data) {
13
+ return typeof data === 'object' && data !== null && data.channel === CHANNEL;
14
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The worker half of `createWorkerDataSource`: holds the rows, answers the
3
+ * grid's requests with the columnar engine (`createColumnarDataSource`, which
4
+ * answers exactly as the in-memory reference source does), and sends back only
5
+ * the rows each request asks for. While no request is waiting, it builds the
6
+ * next column's index, so the first sort on any column finds it ready.
7
+ *
8
+ * ```ts
9
+ * // grid.worker.ts
10
+ * import { serveWorkerDataSource } from '@svgrid/enterprise/worker'
11
+ * serveWorkerDataSource()
12
+ * ```
13
+ *
14
+ * Calls run one at a time, each in its own task, so a `cancel` that arrives
15
+ * while earlier calls are running still reaches the queue before the call it
16
+ * names: a fast scroll skips the blocks it scrolled past instead of computing
17
+ * every one of them.
18
+ */
19
+ import type { RowData } from '@svgrid/grid';
20
+ import type { EntitySchema } from '../schema.js';
21
+ /** The part of a worker's global scope (or a `MessagePort`) this needs. */
22
+ export type WorkerScopeLike = {
23
+ postMessage(message: unknown): void;
24
+ addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
25
+ removeEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
26
+ };
27
+ export type ServeWorkerDataSourceOptions<TData extends RowData> = {
28
+ /**
29
+ * The rows, loaded inside the worker: an array, or a function that fetches
30
+ * or builds one. Loading here means a large dataset never passes through
31
+ * the main thread. Omit it to wait for the rows the main thread sends
32
+ * (`createWorkerDataSource(worker, { rows })`).
33
+ */
34
+ rows?: ReadonlyArray<TData> | (() => ReadonlyArray<TData> | Promise<ReadonlyArray<TData>>);
35
+ /** Which fields can be filtered, sorted and grouped, and their types. Default: read off the rows. */
36
+ schema?: EntitySchema<TData>;
37
+ /** The row id field, when the schema is inferred. See `inferSchemaFromRows`. */
38
+ idField?: string;
39
+ /** Where to listen. Default: the worker's global scope. */
40
+ scope?: WorkerScopeLike;
41
+ };
42
+ export declare function serveWorkerDataSource<TData extends RowData>(options?: ServeWorkerDataSourceOptions<TData>): {
43
+ dispose(): void;
44
+ };
@@ -0,0 +1,100 @@
1
+ import { createColumnarDataSource } from './columnar.js';
2
+ import { inferSchemaFromRows } from './infer-schema.js';
3
+ import { CHANNEL, isChannelMessage, toWorkerError, } from './protocol.js';
4
+ export function serveWorkerDataSource(options = {}) {
5
+ const scope = options.scope ?? globalThis;
6
+ let source = null;
7
+ let disposed = false;
8
+ const queue = [];
9
+ let scheduled = false;
10
+ // Whether a column is still waiting to be indexed in idle time.
11
+ let warming = false;
12
+ const post = (message) => {
13
+ if (!disposed)
14
+ scope.postMessage(message);
15
+ };
16
+ function install(rows, schema, idField) {
17
+ const resolved = schema ??
18
+ options.schema ??
19
+ inferSchemaFromRows(rows, { idField: idField ?? options.idField });
20
+ source = createColumnarDataSource(rows, resolved);
21
+ warming = true;
22
+ post({ channel: CHANNEL, kind: 'ready', rowCount: rows.length });
23
+ schedule();
24
+ }
25
+ function schedule() {
26
+ if (scheduled || disposed || !source || (queue.length === 0 && !warming))
27
+ return;
28
+ scheduled = true;
29
+ setTimeout(drain, 0);
30
+ }
31
+ async function drain() {
32
+ scheduled = false;
33
+ if (!source || disposed)
34
+ return;
35
+ const call = queue.shift();
36
+ if (!call) {
37
+ // Idle: index one more column, then look at the queue again.
38
+ warming = source.warm();
39
+ schedule();
40
+ return;
41
+ }
42
+ try {
43
+ const method = source[call.method];
44
+ const value = await method(...call.args);
45
+ post({ channel: CHANNEL, kind: 'result', id: call.id, ok: true, value });
46
+ }
47
+ catch (error) {
48
+ post({ channel: CHANNEL, kind: 'result', id: call.id, ok: false, error: toWorkerError(error) });
49
+ }
50
+ // A write drops the columns; index them again once the queue is empty.
51
+ if (call.method !== 'getRows' && call.method !== 'getAggregate')
52
+ warming = true;
53
+ schedule();
54
+ }
55
+ function onMessage(event) {
56
+ const message = event.data;
57
+ if (disposed || !isChannelMessage(message))
58
+ return;
59
+ switch (message.kind) {
60
+ case 'load':
61
+ try {
62
+ install(message.rows, message.schema, message.idField);
63
+ post({ channel: CHANNEL, kind: 'result', id: message.id, ok: true, value: message.rows.length });
64
+ }
65
+ catch (error) {
66
+ post({ channel: CHANNEL, kind: 'result', id: message.id, ok: false, error: toWorkerError(error) });
67
+ }
68
+ break;
69
+ case 'call':
70
+ queue.push({ id: message.id, method: message.method, args: message.args });
71
+ schedule();
72
+ break;
73
+ case 'cancel': {
74
+ // No reply: the client rejected the call when it sent this.
75
+ const at = queue.findIndex((c) => c.id === message.id);
76
+ if (at >= 0)
77
+ queue.splice(at, 1);
78
+ break;
79
+ }
80
+ }
81
+ }
82
+ scope.addEventListener('message', onMessage);
83
+ scope.start?.();
84
+ if (options.rows !== undefined) {
85
+ const rows = options.rows;
86
+ Promise.resolve()
87
+ .then(() => (typeof rows === 'function' ? rows() : rows))
88
+ .then((loaded) => {
89
+ if (!disposed)
90
+ install(loaded);
91
+ }, (error) => post({ channel: CHANNEL, kind: 'failed', error: toWorkerError(error) }));
92
+ }
93
+ return {
94
+ dispose() {
95
+ disposed = true;
96
+ queue.length = 0;
97
+ scope.removeEventListener('message', onMessage);
98
+ },
99
+ };
100
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "commercial",
5
5
  "url": "https://svgrid.com/pricing"
6
6
  },
7
- "version": "3.1.0",
7
+ "version": "3.1.2",
8
8
  "description": "Enterprise feature pack for SvGrid: the server-side row model (lazy grouping, tree, pivot, transactions, selection across unloaded rows), Excel (xlsx) and PDF export, Excel/CSV/JSON import, pivot tables with a drag-and-drop designer, paginated print, Kanban board and scheduler renderers, no-code alerts and batch editing. CSV, TSV and JSON export are already free in @svgrid/grid. Requires a paid license key.",
9
9
  "license": "SEE LICENSE IN LICENSE",
10
10
  "author": "jQWidgets <sales@jqwidgets.com>",
@@ -57,6 +57,10 @@
57
57
  "svelte": "./dist/server/index.js",
58
58
  "import": "./dist/server/index.js"
59
59
  },
60
+ "./worker": {
61
+ "types": "./dist/worker/index.d.ts",
62
+ "import": "./dist/worker/index.js"
63
+ },
60
64
  "./license": {
61
65
  "types": "./dist/license.d.ts",
62
66
  "svelte": "./dist/license.js",
@@ -101,7 +105,7 @@
101
105
  "jszip": "^3.10.0",
102
106
  "pdfmake": "^0.2.0",
103
107
  "svelte": "^5.0.0",
104
- "@svgrid/grid": "^3.0.6"
108
+ "@svgrid/grid": "^3.0.8"
105
109
  },
106
110
  "peerDependenciesMeta": {
107
111
  "jszip": {
@@ -119,7 +123,7 @@
119
123
  "svelte": "^5.55.5",
120
124
  "typescript": "6.0.3",
121
125
  "vite": "^8.2.1",
122
- "@svgrid/grid": "^3.0.6"
126
+ "@svgrid/grid": "^3.0.8"
123
127
  },
124
128
  "repository": {
125
129
  "type": "git",
@@ -1 +0,0 @@
1
- function e(e){let t=``;return e.color&&(t+=`color:${e.color};`),e.fontWeight!=null&&(t+=`font-weight:${e.fontWeight};`),t}function t(e){return Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2})}function n(e,t){return`${e}:${t}`}function r(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.filter(Boolean).join(` `);if(typeof e==`object`){let t=[];for(let[n,r]of Object.entries(e))r&&t.push(n);return t.join(` `)}return``}function i(e){if(e==null||e===``)return``;if(typeof e==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function a(e){if(e==null||e===``)return``;if(typeof e==`string`&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(e))return e;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function o(e){return String(e).replace(/-native$/,``)}function s(e){if(e instanceof Date)return e;if(typeof e==`string`){let t=e.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?/);if(t){let e=new Date;return e.setHours(Math.min(23,+t[1]),Math.min(59,+t[2]),t[3]?+t[3]:0,0),e}}return null}function c(e){return e?`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`:null}function l(e,t){let n=o(e);return n===`date`?i(t):n===`datetime`?a(t):String(t??``)}function u(e){let t=o(e);return t===`number`?`number`:t===`date`?`date`:t===`datetime`?`datetime-local`:t===`time`?`time`:t===`password`?`password`:t===`color`?`color`:`text`}function d(e){if(!e||Number.isNaN(e.getTime()))return``;let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function f(e){if(!e)return null;let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?null:n}function p(e){if(!e||String(e).endsWith(`-native`))return!1;let t=o(e);return t===`date`||t===`datetime`||t===`time`}function m(e){return o(e)===`number`?`text`:u(e)}function h(e){return/^-?(\d*\.?\d*)(e-?\d*)?$/i.test(e)}function g(e){return e==null||e===``?[]:Array.isArray(e)?e.filter(e=>e!=null&&e!==``):[e]}function _(e,t){let n=e.find(e=>e.value===t||String(e.value)===String(t));return n?n.label:String(t??``)}function v(e,t){return e.find(e=>e.value===t||String(e.value)===String(t))?.color}function y(e){return e?`background: color-mix(in srgb, ${e} 22%, transparent);border-color: color-mix(in srgb, ${e} 45%, transparent);color: color-mix(in srgb, ${e} 80%, var(--sg-fg, #0f172a));`:``}function b(e){let t=o(e);return t===`number`?`sv-grid-cell-editor sv-grid-cell-editor-number`:t===`date`?`sv-grid-cell-editor sv-grid-cell-editor-date`:t===`datetime`?`sv-grid-cell-editor sv-grid-cell-editor-datetime`:t===`color`?`sv-grid-cell-editor sv-grid-cell-editor-color`:`sv-grid-cell-editor`}function x(e){if(e==null||e===``)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function S(e,t){return Math.max(8,Math.min(e,window.innerWidth-t-8))}function C(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/"/g,`\\"`)}function w(e,t){if(e==null||e===``)return NaN;if(t){let t=(e instanceof Date?e:new Date(String(e))).getTime();return Number.isFinite(t)?t:NaN}let n=typeof e==`number`?e:Number(e);return Number.isFinite(n)?n:NaN}function T(e){let t=Math.abs(e),n=t>=1e3?0:t>=100?1:t>=1?2:4;return e.toLocaleString(void 0,{maximumFractionDigits:n})}function E(e){return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}export{g as C,d as S,_,C as a,r as b,E as c,m as d,n as f,v as g,u as h,y as i,T as l,b as m,e as n,c as o,l as p,S as r,t as s,x as t,f as u,h as v,p as w,s as x,w as y};
@@ -1 +0,0 @@
1
- function e(e,t){if(e)switch(e.trim()){case`d`:return t===`datetime`?{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};case`D`:return t===`datetime`?{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`,hour:`numeric`,minute:`numeric`}:{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`};case`y-m-d`:return t===`datetime`?{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}:{year:`numeric`,month:`2-digit`,day:`2-digit`};case`medium`:return{dateStyle:`medium`,timeStyle:t===`datetime`?`short`:void 0};case`short`:return{dateStyle:`short`,timeStyle:t===`datetime`?`short`:void 0};case`long`:return{dateStyle:`long`,timeStyle:t===`datetime`?`short`:void 0};default:return}}var t=new Map;function n(e,n){let r=(Array.isArray(e)?e.join(`,`):e??``)+`|`+(n.style??``)+`|`+(n.currency??``)+`|`+(n.minimumFractionDigits??``)+`|`+(n.maximumFractionDigits??``)+`|`+(n.useGrouping??``)+`|`+(n.currencyDisplay??``)+`|`+(n.notation??``)+`|`+(n.signDisplay??``)+`|`+(n.minimumIntegerDigits??``)+`|`+(n.compactDisplay??``)+`|`+(n.unit??``)+`|`+(n.unitDisplay??``)+`|`+(n.minimumSignificantDigits??``)+`|`+(n.maximumSignificantDigits??``),i=t.get(r);return i||(i=new Intl.NumberFormat(e,n),t.set(r,i)),i}var r=new Map;function i(e,t){let n=(Array.isArray(e)?e.join(`,`):e??``)+`|`+(t.dateStyle??``)+`|`+(t.timeStyle??``)+`|`+(t.year??``)+`|`+(t.month??``)+`|`+(t.day??``)+`|`+(t.hour??``)+`|`+(t.minute??``)+`|`+(t.second??``)+`|`+(t.weekday??``)+`|`+(t.hour12??``),i=r.get(n);return i||(i=new Intl.DateTimeFormat(e,t),r.set(n,i)),i}function a(e,t){let r=typeof e==`number`?e:Number(e);if(!Number.isFinite(r))return String(e??``);let i=t.locales;if(t.type===`currency`)return n(i,{style:`currency`,currency:t.currency??`USD`,...t.options}).format(r);if(t.type===`percent`){let e=t.valueIsPercentPoints===!0?r/100:r;return n(i,{style:`percent`,minimumFractionDigits:0,maximumFractionDigits:2,...t.options}).format(e)}return n(i,t.options??{}).format(r)}export{e as i,i as n,n as r,a as t};
@@ -1,6 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n,t as r}from"./cell-formatting-BbubJTVz.js";var i=e({coerceExportDate:()=>a,copyTextToClipboard:()=>O,downloadBlobFile:()=>E,downloadTextFile:()=>D,formatValueForExport:()=>o,projectGridRows:()=>c,serializeDelimited:()=>h,serializeHtml:()=>v,serializeJson:()=>y,serializeMarkdown:()=>x,serializeXml:()=>T,toExcelNumFmt:()=>s,valueForExcel:()=>u});function a(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e==`number`&&Number.isFinite(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}if(typeof e==`string`&&e.trim()!==``){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}return null}function o(e,i){if(e==null)return``;if(!i)return String(e);if(i.type===`number`||i.type===`currency`||i.type===`percent`)return r(e,{type:i.type,locales:i.locales,currency:i.type===`currency`?i.currency??`USD`:void 0,valueIsPercentPoints:i.type===`percent`?i.valueIsPercentPoints:void 0,options:i.options});if(i.type===`date`||i.type===`datetime`){let r=a(e);if(r){let e=t(i.pattern,i.type),a=e||i.options?{...e,...i.options}:i.type===`date`?{year:`numeric`,month:`2-digit`,day:`2-digit`}:{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`};return n(i.locales,a).format(r)}}return String(e)}function s(e){if(!e)return;let t=()=>{let t=e.options;return t&&typeof t.maximumFractionDigits==`number`?t.maximumFractionDigits:t&&typeof t.minimumFractionDigits==`number`?t.minimumFractionDigits:e.type===`currency`?2:e.type===`number`?0:2},n=e=>e>0?`.`+`0`.repeat(e):``;switch(e.type){case`number`:return`#,##0${n(t())}`;case`currency`:return`"${l(e.currency??`USD`)}"#,##0${n(t())}`;case`percent`:return`0${n(t())}%`;case`date`:return`yyyy-mm-dd`;case`datetime`:return`yyyy-mm-dd hh:mm`;default:return}}function c(e,t,n={}){let r=n.columns&&n.columns.length?n.columns.map(e=>t.find(t=>t.field===e)).filter(e=>!!e):t.filter(e=>e.field),i=r.map(e=>e.field),a={};for(let e of r)e.align&&(a[e.field]=e.align);let s={};for(let e of r)s[e.field]=e.header;let c=[s];for(let t of e){let e={};for(let i of r){let r=t[i.field];e[i.field]=n.rawValues?r:o(r,i.format)}c.push(e)}return{records:c,fields:i,align:a}}function l(e){return{USD:`$`,EUR:`€`,GBP:`£`,JPY:`¥`,CNY:`¥`,INR:`₹`,KRW:`₩`,RUB:`₽`,BRL:`R$`}[e.toUpperCase()]??e.toUpperCase()}function u(e,t){if(e==null||!t)return{ok:!1};if(t.type===`number`||t.type===`currency`){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?{ok:!0,value:t}:{ok:!1}}if(t.type===`percent`){let n=typeof e==`number`?e:Number(e);return Number.isFinite(n)?{ok:!0,value:t.valueIsPercentPoints===!0?n/100:n}:{ok:!1}}if(t.type===`date`||t.type===`datetime`){let t=a(e);return t?{ok:!0,value:t}:{ok:!1}}return{ok:!1}}var d=``;function f(e){if(e?.aborted)throw new DOMException(`Export aborted`,`AbortError`)}var p=()=>new Promise(e=>setTimeout(e,0));function m(e,t){let n=e==null?``:e instanceof Date?e.toISOString():String(e);return n===``?n:n.includes(t)||n.includes(`"`)||n.includes(`
2
- `)||n.includes(`\r`)?`"${n.replace(/"/g,`""`)}"`:n}async function h(e,t,n={}){let r=n.csv?.delimiter??`,`,i=n.csv?.eol??`\r
3
- `,a=n.csv?.bom??!0,o=Math.max(1,n.chunkRows??5e3),s=e.length,c=[];for(let i=0;i<e.length;i++){f(n.signal);let a=e[i];c.push(t.map(e=>m(a[e],r)).join(r)),i>0&&i%o===0&&(n.onProgress?.({phase:`serialize`,ratio:i/s,row:i,total:s}),await p())}n.onProgress?.({phase:`serialize`,ratio:1,row:s,total:s});let l=c.join(i);return(a?d:``)+l}var g={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function _(e){return(e==null?``:e instanceof Date?e.toISOString():String(e)).replace(/[&<>"']/g,e=>g[e])}async function v(e,t,n={}){let r=Math.max(1,n.chunkRows??5e3),i=e.length,a=n.align??{},o=n.cellStyle,s=n.cellLink,c=n.title??`Grid export`,l=e[0],u=l?t.map(e=>`<th>${_(l[e])}</th>`).join(``):``,d=[];for(let c=1;c<e.length;c++){f(n.signal);let l=e[c],u=t.map((e,t)=>{let n=a[e],r=[];n&&n!==`left`&&r.push(`text-align:${n}`);let i=o?.(c-1,t);i?.fill&&r.push(`background:${i.fill}`),i?.color&&r.push(`color:${i.color}`),i?.bold&&r.push(`font-weight:700`);let u=r.length?` style="${r.join(`;`)}"`:``,d=i?.icon?`${i.icon} ${_(l[e])}`:_(l[e]),f=s?.(c-1,t);return f&&(d=`<a href="${_(f)}">${d}</a>`),`<td${u}>${d}</td>`}).join(``);d.push(`<tr>${u}</tr>`),c>0&&c%r===0&&(n.onProgress?.({phase:`serialize`,ratio:c/i,row:c,total:i}),await p())}return n.onProgress?.({phase:`serialize`,ratio:1,row:i,total:i}),`<!doctype html><html><head><meta charset="utf-8"><title>${_(c)}</title><style>table{border-collapse:collapse;font-family:system-ui,sans-serif;font-size:13px}th,td{border:1px solid #d0d7de;padding:6px 10px}th{background:#f6f8fa;text-align:left}</style></head><body><table><thead><tr>${u}</tr></thead><tbody>${d.join(``)}</tbody></table></body></html>`}async function y(e,t,n={}){let r=Math.max(1,n.chunkRows??5e3),i=e.length-1,a=[];for(let o=1;o<e.length;o++){f(n.signal);let s=e[o],c={};for(let e of t)c[e]=s[e];a.push(c),o>0&&o%r===0&&(n.onProgress?.({phase:`serialize`,ratio:o/i,row:o,total:i}),await p())}return n.onProgress?.({phase:`serialize`,ratio:1,row:i,total:i}),JSON.stringify(a,null,2)}function b(e){return(e==null?``:e instanceof Date?e.toISOString():String(e)).replace(/\\/g,`\\\\`).replace(/\|/g,`\\|`).replace(/\r?\n/g,`<br>`)}async function x(e,t,n={}){let r=Math.max(1,n.chunkRows??5e3),i=e.length,a=n.align??{},o=e[0],s=`| ${t.map(e=>b(o?.[e])).join(` | `)} |`,c=`| ${t.map(e=>{let t=a[e];return t===`right`?`---:`:t===`center`?`:--:`:`---`}).join(` | `)} |`,l=[];for(let a=1;a<e.length;a++){f(n.signal);let o=e[a];l.push(`| ${t.map(e=>b(o[e])).join(` | `)} |`),a>0&&a%r===0&&(n.onProgress?.({phase:`serialize`,ratio:a/i,row:a,total:i}),await p())}return n.onProgress?.({phase:`serialize`,ratio:1,row:i,total:i}),[s,c,...l].join(`
4
- `)+`
5
- `}var S={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&apos;`};function C(e){return(e==null?``:e instanceof Date?e.toISOString():String(e)).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,``).replace(/[&<>"']/g,e=>S[e])}function w(e){let t=e.replace(/[^A-Za-z0-9_.-]/g,`_`);return/^[A-Za-z_]/.test(t)?t:`_${t}`}async function T(e,t,n={}){let r=Math.max(1,n.chunkRows??5e3),i=e.length-1,a=n.rootTag??`rows`,o=n.rowTag??`row`,s=t.map(w),c=[`<?xml version="1.0" encoding="UTF-8"?>`,`<${a}>`];for(let a=1;a<e.length;a++){f(n.signal);let l=e[a],u=t.map((e,t)=>`<${s[t]}>${C(l[e])}</${s[t]}>`).join(``);c.push(` <${o}>${u}</${o}>`),a>0&&a%r===0&&(n.onProgress?.({phase:`serialize`,ratio:a/i,row:a,total:i}),await p())}return c.push(`</${a}>`),n.onProgress?.({phase:`serialize`,ratio:1,row:i,total:i}),c.join(`
6
- `)}function E(e,t){if(typeof document>`u`||typeof URL>`u`)throw Error(`@svgrid/grid: export requires a browser environment`);let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)}function D(e,t,n){if(typeof document>`u`||typeof URL>`u`)throw Error(`@svgrid/grid: text export requires a browser environment`);E(new Blob([e],{type:n}),t)}async function O(e){if(typeof navigator>`u`||!navigator.clipboard)throw Error(`@svgrid/grid: clipboard API is unavailable in this context`);await navigator.clipboard.writeText(e)}export{h as a,x as c,u as d,o as i,T as l,D as n,v as o,i as r,y as s,E as t,s as u};