@dcs-tech/ui 0.6.0 → 0.7.0
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/README.md +27 -0
- package/dist/{ChartImageMenu-CuuFnW9q.js → ChartImageMenu-C6MwKKjc.js} +39 -26
- package/dist/{SummaryImage-CoEFzMl6.js → SummaryImage-OHJHjCqe.js} +1 -1
- package/dist/{SummarySeeAll-C_OUs3kn.js → SummarySeeAll-BYrvXSJ6.js} +1 -1
- package/dist/assets/fileTask.worker-BHT1olUk.js +1 -0
- package/dist/{exportEngine-CDLYHH0d.js → exportEngine-S8JHzYbS.js} +377 -382
- package/dist/file-worker.js +1 -0
- package/dist/{fileActions-KSaVGnaE.js → fileActions-COf5Q4Eg.js} +2 -2
- package/dist/index.js +4000 -3916
- package/dist/runFileTask--4YjQH7Y.js +210 -0
- package/dist/types/components/DataTable/export/exportEngine.d.ts +11 -4
- package/dist/types/components/Dialog/DialogHost.d.ts +1 -0
- package/dist/types/components/FileEngine/FileEngineProvider.d.ts +20 -1
- package/dist/types/components/FileEngine/index.d.ts +1 -1
- package/dist/types/components/UIProvider/UIHostContext.d.ts +20 -0
- package/dist/types/components/UIProvider/UIProvider.d.ts +2 -0
- package/dist/types/components/UIProvider/index.d.ts +2 -0
- package/dist/types/core/types/fileEngine.types.d.ts +51 -0
- package/dist/types/core/types/form.types.d.ts +4 -0
- package/dist/types/file/fileEngine.d.ts +2 -1
- package/dist/types/file/tasks/runFileTask.d.ts +4 -1
- package/dist/types/file/workerPool.d.ts +1 -0
- package/dist/types/index.d.ts +6 -4
- package/package.json +3 -2
- package/dist/assets/fileTask.worker-FQSUtwcz.js +0 -1
- package/dist/runFileTask-BClLQjmv.js +0 -109
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
4
|
+
let r = {};
|
|
5
|
+
for (var i in t) e(r, i, {
|
|
6
|
+
get: t[i],
|
|
7
|
+
enumerable: !0
|
|
8
|
+
});
|
|
9
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
10
|
+
}, n = /* @__PURE__ */ t({ runFileTask: () => i }), r = () => new DOMException("Aborted", "AbortError");
|
|
11
|
+
async function i(e, t) {
|
|
12
|
+
if (t.signal?.aborted) throw r();
|
|
13
|
+
switch (e.kind) {
|
|
14
|
+
case "xlsx": return f(e.workbook, t);
|
|
15
|
+
case "pdf": return g(e, t);
|
|
16
|
+
default: throw Error(`Unknown file task: ${e.kind}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var a = globalThis;
|
|
20
|
+
async function o() {
|
|
21
|
+
let e = await import("exceljs"), t = [
|
|
22
|
+
e.default?.default,
|
|
23
|
+
e.default,
|
|
24
|
+
e,
|
|
25
|
+
a.ExcelJS
|
|
26
|
+
].find((e) => e && typeof e.Workbook == "function");
|
|
27
|
+
if (!t) throw Error("ExcelJS did not load");
|
|
28
|
+
return t;
|
|
29
|
+
}
|
|
30
|
+
async function s() {
|
|
31
|
+
let e = await import("pdfmake/build/pdfmake.js"), t = [
|
|
32
|
+
e.default?.default,
|
|
33
|
+
e.default,
|
|
34
|
+
e,
|
|
35
|
+
a.pdfMake
|
|
36
|
+
].find((e) => e && typeof e.createPdf == "function");
|
|
37
|
+
if (!t) throw Error("pdfmake did not load");
|
|
38
|
+
let n = await import("pdfmake/build/vfs_fonts.js");
|
|
39
|
+
return {
|
|
40
|
+
pdfMake: t,
|
|
41
|
+
vfs: [
|
|
42
|
+
n?.default,
|
|
43
|
+
n,
|
|
44
|
+
n?.pdfMake?.vfs,
|
|
45
|
+
n?.default?.pdfMake?.vfs,
|
|
46
|
+
t.vfs,
|
|
47
|
+
a.pdfMake?.vfs
|
|
48
|
+
].find((e) => e && e["Roboto-Regular.ttf"])
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var c = (e) => ArrayBuffer.isView(e) ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e, l = (e) => "FF" + e.replace("#", "").toUpperCase();
|
|
52
|
+
function u(e, t) {
|
|
53
|
+
if (t && ((t.bold !== void 0 || t.italic !== void 0 || t.size || t.color) && (e.font = {
|
|
54
|
+
...e.font ?? {},
|
|
55
|
+
...t.bold === void 0 ? {} : { bold: t.bold },
|
|
56
|
+
...t.italic === void 0 ? {} : { italic: t.italic },
|
|
57
|
+
...t.size ? { size: t.size } : {},
|
|
58
|
+
...t.color ? { color: { argb: l(t.color) } } : {}
|
|
59
|
+
}), t.fill && (e.fill = {
|
|
60
|
+
type: "pattern",
|
|
61
|
+
pattern: "solid",
|
|
62
|
+
fgColor: { argb: l(t.fill) }
|
|
63
|
+
}), t.align && (e.alignment = {
|
|
64
|
+
horizontal: t.align,
|
|
65
|
+
vertical: "middle"
|
|
66
|
+
}), t.numFmt && (typeof e.value == "number" || e.value instanceof Date) && (e.numFmt = t.numFmt), t.borderTop || t.borderBottom)) {
|
|
67
|
+
let n = (e) => ({
|
|
68
|
+
style: e.style,
|
|
69
|
+
...e.color ? { color: { argb: l(e.color) } } : {}
|
|
70
|
+
});
|
|
71
|
+
e.border = {
|
|
72
|
+
...t.borderTop ? { top: n(t.borderTop) } : {},
|
|
73
|
+
...t.borderBottom ? { bottom: n(t.borderBottom) } : {}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function d(e, t, n) {
|
|
78
|
+
let r = e.addRow(t.values);
|
|
79
|
+
t.style?.bold && (r.font = { bold: !0 }), t.merge && n > 1 && e.mergeCells(r.number, 1, r.number, n);
|
|
80
|
+
let i = t.merge ? 1 : Math.max(t.values.length, 0);
|
|
81
|
+
for (let e = 0; e < i; e++) {
|
|
82
|
+
let n = r.getCell(e + 1);
|
|
83
|
+
u(n, t.style), u(n, t.cells?.[e]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function f(e, t) {
|
|
87
|
+
let n = new (await (o())).Workbook(), i = Math.max(1, e.sheets.reduce((e, t) => e + t.rows.length, 0)), a = Math.max(1, Math.floor(i / 50)), s = 0;
|
|
88
|
+
for (let o of e.sheets) {
|
|
89
|
+
let e = n.addWorksheet(o.name), c = o.columns.length;
|
|
90
|
+
e.columns = o.columns.map((e, t) => ({
|
|
91
|
+
key: String(t),
|
|
92
|
+
width: e.width
|
|
93
|
+
}));
|
|
94
|
+
for (let t of o.before ?? []) d(e, t, c);
|
|
95
|
+
let f = e.addRow(o.columns.map((e) => e.header));
|
|
96
|
+
f.font = { bold: o.headerStyle?.bold ?? !0 }, f.eachCell((e, t) => {
|
|
97
|
+
let n = o.columns[t - 1]?.align;
|
|
98
|
+
n && (e.alignment = {
|
|
99
|
+
horizontal: n,
|
|
100
|
+
vertical: "middle"
|
|
101
|
+
}), u(e, o.headerStyle);
|
|
102
|
+
});
|
|
103
|
+
let p = f.number;
|
|
104
|
+
o.freeze ? e.views = [{
|
|
105
|
+
state: "frozen",
|
|
106
|
+
ySplit: o.freeze.rows ?? 0,
|
|
107
|
+
xSplit: o.freeze.cols ?? 0
|
|
108
|
+
}] : o.freezeHeader !== !1 && (e.views = [{
|
|
109
|
+
state: "frozen",
|
|
110
|
+
ySplit: p
|
|
111
|
+
}]), o.rows.forEach((n, c) => {
|
|
112
|
+
let d = e.addRow(n), f = o.cellStyles?.[c], p = o.stripe && c % 2 == 1;
|
|
113
|
+
if (o.columns.forEach((e, t) => {
|
|
114
|
+
let n = d.getCell(t + 1);
|
|
115
|
+
e.numFmt && (typeof n.value == "number" || n.value instanceof Date) && (n.numFmt = e.numFmt), e.align && (n.alignment = {
|
|
116
|
+
horizontal: e.align,
|
|
117
|
+
vertical: "middle"
|
|
118
|
+
}), p && (n.fill = {
|
|
119
|
+
type: "pattern",
|
|
120
|
+
pattern: "solid",
|
|
121
|
+
fgColor: { argb: l(o.stripe) }
|
|
122
|
+
}), u(n, e.style), u(n, f?.[t]);
|
|
123
|
+
}), ++s % a === 0) {
|
|
124
|
+
if (t.signal?.aborted) throw r();
|
|
125
|
+
t.progress(s / i * .9);
|
|
126
|
+
}
|
|
127
|
+
}), o.autoFilter && o.rows.length > 0 && (e.autoFilter = {
|
|
128
|
+
from: {
|
|
129
|
+
row: p,
|
|
130
|
+
column: 1
|
|
131
|
+
},
|
|
132
|
+
to: {
|
|
133
|
+
row: p,
|
|
134
|
+
column: c
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
for (let t of o.after ?? []) d(e, t, c);
|
|
138
|
+
}
|
|
139
|
+
let f = await n.xlsx.writeBuffer();
|
|
140
|
+
return t.progress(1), c(f);
|
|
141
|
+
}
|
|
142
|
+
var p = { Roboto: {
|
|
143
|
+
normal: "Roboto-Regular.ttf",
|
|
144
|
+
bold: "Roboto-Medium.ttf",
|
|
145
|
+
italics: "Roboto-Italic.ttf",
|
|
146
|
+
bolditalics: "Roboto-MediumItalic.ttf"
|
|
147
|
+
} };
|
|
148
|
+
function m(e) {
|
|
149
|
+
let t = e.hLineWidth ?? 1, n = e.edgeLineWidth ?? t;
|
|
150
|
+
return {
|
|
151
|
+
hLineWidth: (e, r) => e === 0 || e === (r.table.headerRows ?? 0) || e === r.table.body.length ? n : t,
|
|
152
|
+
vLineWidth: () => e.vLineWidth ?? 1,
|
|
153
|
+
...e.hLineColor ? { hLineColor: () => e.hLineColor } : {},
|
|
154
|
+
...e.vLineColor ? { vLineColor: () => e.vLineColor } : {},
|
|
155
|
+
...e.paddingX === void 0 ? {} : {
|
|
156
|
+
paddingLeft: () => e.paddingX,
|
|
157
|
+
paddingRight: () => e.paddingX
|
|
158
|
+
},
|
|
159
|
+
...e.paddingY === void 0 ? {} : {
|
|
160
|
+
paddingTop: () => e.paddingY,
|
|
161
|
+
paddingBottom: () => e.paddingY
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function h(e) {
|
|
166
|
+
return (t, n) => ({
|
|
167
|
+
text: e.text.replace(/\{page\}/g, String(t)).replace(/\{pages\}/g, String(n)),
|
|
168
|
+
...e.font ? { font: e.font } : {},
|
|
169
|
+
alignment: e.alignment ?? "center",
|
|
170
|
+
fontSize: e.fontSize ?? 8,
|
|
171
|
+
...e.color ? { color: e.color } : {},
|
|
172
|
+
...e.margin ? { margin: e.margin } : {}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async function g(e, t) {
|
|
176
|
+
let n = t.pdfFonts ? {
|
|
177
|
+
fonts: {
|
|
178
|
+
...t.pdfFonts.fonts,
|
|
179
|
+
...e.fonts?.fonts
|
|
180
|
+
},
|
|
181
|
+
vfs: t.pdfFonts.vfs || e.fonts?.vfs ? {
|
|
182
|
+
...t.pdfFonts.vfs,
|
|
183
|
+
...e.fonts?.vfs
|
|
184
|
+
} : void 0
|
|
185
|
+
} : e.fonts, i = e.footer ? {
|
|
186
|
+
...e.document,
|
|
187
|
+
footer: h(e.footer)
|
|
188
|
+
} : e.document, a = e.tableLayouts ? Object.fromEntries(Object.entries(e.tableLayouts).map(([e, t]) => [e, m(t)])) : void 0, { pdfMake: o, vfs: c } = await s();
|
|
189
|
+
if (t.progress(.1), t.signal?.aborted) throw r();
|
|
190
|
+
let l = {
|
|
191
|
+
...p,
|
|
192
|
+
...n?.fonts ?? {}
|
|
193
|
+
}, u = n?.vfs ? {
|
|
194
|
+
...c ?? {},
|
|
195
|
+
...n.vfs
|
|
196
|
+
} : c, d = await new Promise((e, t) => {
|
|
197
|
+
try {
|
|
198
|
+
let n = o.createPdf(i, a, l, u).getStream(), r = [];
|
|
199
|
+
n.on("data", (e) => r.push(e)), n.on("error", t), n.on("end", () => {
|
|
200
|
+
let t = new Uint8Array(r.reduce((e, t) => e + t.byteLength, 0)), n = 0;
|
|
201
|
+
for (let e of r) t.set(e, n), n += e.byteLength;
|
|
202
|
+
e(t.buffer);
|
|
203
|
+
}), n.end();
|
|
204
|
+
} catch (e) {
|
|
205
|
+
t(e);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return t.progress(1), d;
|
|
209
|
+
}
|
|
210
|
+
export { n, t as r, i as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FileTask, PdfTaskFonts, XlsxWorkbookSpec } from '../../../core/types';
|
|
1
2
|
import { type DataTableExportFormat, type DataTableExportMetadata, type DataTableXlsxStyle, type DataTablePdfConfig, type DataTableColumn, type DataTableCellStyle, type DataTableExportSummary } from '../types';
|
|
2
3
|
export { autoFormatValue, prepareExportRows, buildBusinessMeta } from './exportRows';
|
|
3
4
|
export { formatContextLine, formatMetadataLines } from './exportContext';
|
|
@@ -13,7 +14,7 @@ export interface ColumnMeta {
|
|
|
13
14
|
}
|
|
14
15
|
export declare function buildColumnMeta(columns: DataTableColumn[], headers: string[]): ColumnMeta[];
|
|
15
16
|
export declare function generateCSV(headers: string[], rows: Record<string, any>[], totals?: Record<string, any> | null, summary?: DataTableExportSummary | null, metadata?: DataTableExportMetadata, subtitle?: string): Blob;
|
|
16
|
-
|
|
17
|
+
type XlsxConfig = {
|
|
17
18
|
totals?: Record<string, any> | null;
|
|
18
19
|
summary?: DataTableExportSummary | null;
|
|
19
20
|
style?: DataTableXlsxStyle;
|
|
@@ -22,7 +23,9 @@ export declare function generateXLSX(headers: string[], rows: Record<string, any
|
|
|
22
23
|
cellStyles?: Record<string, DataTableCellStyle>[];
|
|
23
24
|
metadata?: DataTableExportMetadata;
|
|
24
25
|
subtitle?: string;
|
|
25
|
-
}
|
|
26
|
+
};
|
|
27
|
+
export declare function buildTableXlsxSpec(headers: string[], rows: Record<string, any>[], config?: XlsxConfig): XlsxWorkbookSpec;
|
|
28
|
+
export declare function generateXLSX(headers: string[], rows: Record<string, any>[], config?: XlsxConfig): Promise<Blob>;
|
|
26
29
|
export declare function generateJSON(rows: Record<string, any>[], summary?: DataTableExportSummary | null, metadata?: DataTableExportMetadata, subtitle?: string): Blob;
|
|
27
30
|
export declare function generateHTML(headers: string[], rows: Record<string, any>[], config?: {
|
|
28
31
|
title?: string;
|
|
@@ -38,7 +41,10 @@ export declare function generateHTML(headers: string[], rows: Record<string, any
|
|
|
38
41
|
url?: string;
|
|
39
42
|
};
|
|
40
43
|
}): Blob;
|
|
41
|
-
export
|
|
44
|
+
export type TablePdfTask = Extract<FileTask, {
|
|
45
|
+
kind: 'pdf';
|
|
46
|
+
}>;
|
|
47
|
+
export declare function generateTablePDFTask(headers: string[], rows: Record<string, any>[], config?: {
|
|
42
48
|
pdfConfig?: DataTablePdfConfig;
|
|
43
49
|
totals?: Record<string, any> | null;
|
|
44
50
|
summary?: DataTableExportSummary | null;
|
|
@@ -47,7 +53,8 @@ export declare function generateTablePDFDocDef(headers: string[], rows: Record<s
|
|
|
47
53
|
cellStyles?: Record<string, DataTableCellStyle>[];
|
|
48
54
|
metadata?: DataTableExportMetadata;
|
|
49
55
|
fontFor?: PdfFontFor;
|
|
50
|
-
|
|
56
|
+
fonts?: PdfTaskFonts;
|
|
57
|
+
}): TablePdfTask;
|
|
51
58
|
export { rawDataToBlob, downloadBlob, shareFile, openPreview, executeFileAction, getExtension, getFormatLabel, } from '../vendor';
|
|
52
59
|
export declare function generateXML(headers: string[], rows: Record<string, any>[], config?: {
|
|
53
60
|
title?: string;
|
|
@@ -37,6 +37,7 @@ export interface DialogApi {
|
|
|
37
37
|
choose: (opts: ChooseOptions) => Promise<string | null>;
|
|
38
38
|
alert: (opts: AlertOptions) => Promise<void>;
|
|
39
39
|
}
|
|
40
|
+
export declare const useOptionalDialog: () => DialogApi | null;
|
|
40
41
|
export declare const useDialog: () => DialogApi;
|
|
41
42
|
export declare const DialogHost: React.FC<{
|
|
42
43
|
children?: React.ReactNode;
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { FileJob } from '../../core/types';
|
|
2
3
|
import { type CreateFileEngineOptions, type FileEngine } from '../../file/fileEngine';
|
|
3
4
|
import { type FileEngineLabels, type FileEngineLabelsInput } from './labels';
|
|
4
5
|
export interface FileEngineProviderProps {
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
engine?: FileEngine;
|
|
7
8
|
options?: CreateFileEngineOptions;
|
|
8
|
-
notify?: boolean;
|
|
9
|
+
notify?: boolean | ((notice: FileJobNotice) => void);
|
|
9
10
|
labels?: FileEngineLabelsInput;
|
|
10
11
|
}
|
|
12
|
+
export type FileJobNotice = {
|
|
13
|
+
type: 'awaiting-click';
|
|
14
|
+
job: FileJob;
|
|
15
|
+
message: string;
|
|
16
|
+
actionLabel: string;
|
|
17
|
+
deliver: () => Promise<void>;
|
|
18
|
+
dismiss: () => void;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'failed';
|
|
21
|
+
job: FileJob;
|
|
22
|
+
message: string;
|
|
23
|
+
actionLabel: string;
|
|
24
|
+
retry: () => void;
|
|
25
|
+
dismiss: () => void;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'resolved';
|
|
28
|
+
job: FileJob;
|
|
29
|
+
};
|
|
11
30
|
export declare function useFileEngineLabels(labels?: FileEngineLabelsInput): FileEngineLabels;
|
|
12
31
|
export declare const FileEngineProvider: React.FC<FileEngineProviderProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { FileEngineProvider, useFileEngineLabels } from './FileEngineProvider';
|
|
2
|
-
export type { FileEngineProviderProps } from './FileEngineProvider';
|
|
2
|
+
export type { FileEngineProviderProps, FileJobNotice } from './FileEngineProvider';
|
|
3
3
|
export { FileJobsTray } from './FileJobsTray';
|
|
4
4
|
export type { FileJobsTrayProps } from './FileJobsTray';
|
|
5
5
|
export { FileEngineContext, useFileEngine, useFileJob, getDefaultFileEngine } from './FileEngineContext';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { FileJobNotice } from '../FileEngine/FileEngineProvider';
|
|
4
|
+
export interface UIConfirmRequest {
|
|
5
|
+
title: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UIHostDefaults {
|
|
9
|
+
renderAuthorize?: (authorize: any, children: ReactNode) => ReactNode;
|
|
10
|
+
onToast?: (type: 'success' | 'error' | 'info' | 'warning', message: string) => void;
|
|
11
|
+
onNavigate?: (path: string) => void;
|
|
12
|
+
renderLoading?: (isOpen: boolean, message?: string) => ReactNode;
|
|
13
|
+
onConfirm?: (request: UIConfirmRequest) => boolean | Promise<boolean>;
|
|
14
|
+
onFileNotice?: (notice: FileJobNotice) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const HostProvider: React.FC<{
|
|
17
|
+
host?: UIHostDefaults;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const useUIHost: () => UIHostDefaults;
|
|
@@ -4,6 +4,7 @@ import type { ToastDefaults } from '../Toast/toast.types';
|
|
|
4
4
|
import type { CreateFileEngineOptions, FileEngine } from '../../file/fileEngine';
|
|
5
5
|
import type { UIFormatSettings } from '../../core/types';
|
|
6
6
|
import { type UILabelsInput } from './UILabelsContext';
|
|
7
|
+
import { type UIHostDefaults } from './UIHostContext';
|
|
7
8
|
import { type ResolvedUITheme, type UITheme } from './UIThemeContext';
|
|
8
9
|
export interface UIProviderProps extends Pick<FieldProviderProps, 'size' | 'variant' | 'layout'>, UIFormatSettings {
|
|
9
10
|
children?: React.ReactNode;
|
|
@@ -13,6 +14,7 @@ export interface UIProviderProps extends Pick<FieldProviderProps, 'size' | 'vari
|
|
|
13
14
|
toast?: ToastDefaults;
|
|
14
15
|
fileEngine?: CreateFileEngineOptions | FileEngine;
|
|
15
16
|
labels?: UILabelsInput;
|
|
17
|
+
host?: UIHostDefaults;
|
|
16
18
|
}
|
|
17
19
|
declare const UIProvider: React.FC<UIProviderProps>;
|
|
18
20
|
export default UIProvider;
|
|
@@ -7,3 +7,5 @@ export { FormatProvider, useFormat } from './UIFormatContext';
|
|
|
7
7
|
export type { FormatProviderProps } from './UIFormatContext';
|
|
8
8
|
export { LabelsProvider, useUILabels, DEFAULT_UI_LABELS } from './UILabelsContext';
|
|
9
9
|
export type { UILabels, UILabelsInput } from './UILabelsContext';
|
|
10
|
+
export { HostProvider, useUIHost } from './UIHostContext';
|
|
11
|
+
export type { UIHostDefaults, UIConfirmRequest } from './UIHostContext';
|
|
@@ -31,17 +31,49 @@ export interface FileEngineOptions {
|
|
|
31
31
|
workers?: 'auto' | 'off';
|
|
32
32
|
}
|
|
33
33
|
export type XlsxCellValue = string | number | boolean | Date | null;
|
|
34
|
+
export interface XlsxCellStyle {
|
|
35
|
+
bold?: boolean;
|
|
36
|
+
italic?: boolean;
|
|
37
|
+
size?: number;
|
|
38
|
+
color?: string;
|
|
39
|
+
fill?: string;
|
|
40
|
+
align?: 'left' | 'center' | 'right';
|
|
41
|
+
numFmt?: string;
|
|
42
|
+
borderTop?: XlsxBorder;
|
|
43
|
+
borderBottom?: XlsxBorder;
|
|
44
|
+
}
|
|
45
|
+
export interface XlsxBorder {
|
|
46
|
+
style: 'thin' | 'medium' | 'thick' | 'dotted' | 'dashed' | 'double';
|
|
47
|
+
color?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface XlsxRowSpec {
|
|
50
|
+
values: XlsxCellValue[];
|
|
51
|
+
style?: XlsxCellStyle;
|
|
52
|
+
cells?: Record<number, XlsxCellStyle>;
|
|
53
|
+
merge?: boolean;
|
|
54
|
+
}
|
|
34
55
|
export interface XlsxColumnSpec {
|
|
35
56
|
header: string;
|
|
36
57
|
width?: number;
|
|
37
58
|
numFmt?: string;
|
|
38
59
|
align?: 'left' | 'center' | 'right';
|
|
60
|
+
style?: XlsxCellStyle;
|
|
39
61
|
}
|
|
40
62
|
export interface XlsxSheetSpec {
|
|
41
63
|
name: string;
|
|
42
64
|
columns: XlsxColumnSpec[];
|
|
43
65
|
rows: XlsxCellValue[][];
|
|
44
66
|
freezeHeader?: boolean;
|
|
67
|
+
before?: XlsxRowSpec[];
|
|
68
|
+
after?: XlsxRowSpec[];
|
|
69
|
+
headerStyle?: XlsxCellStyle;
|
|
70
|
+
stripe?: string;
|
|
71
|
+
cellStyles?: Array<Record<number, XlsxCellStyle> | null | undefined>;
|
|
72
|
+
autoFilter?: boolean;
|
|
73
|
+
freeze?: {
|
|
74
|
+
rows?: number;
|
|
75
|
+
cols?: number;
|
|
76
|
+
};
|
|
45
77
|
}
|
|
46
78
|
export interface XlsxWorkbookSpec {
|
|
47
79
|
sheets: XlsxSheetSpec[];
|
|
@@ -55,10 +87,29 @@ export interface PdfTaskFonts {
|
|
|
55
87
|
}>;
|
|
56
88
|
vfs?: Record<string, string>;
|
|
57
89
|
}
|
|
90
|
+
export interface PdfTableLayoutSpec {
|
|
91
|
+
hLineWidth?: number;
|
|
92
|
+
edgeLineWidth?: number;
|
|
93
|
+
vLineWidth?: number;
|
|
94
|
+
hLineColor?: string;
|
|
95
|
+
vLineColor?: string;
|
|
96
|
+
paddingX?: number;
|
|
97
|
+
paddingY?: number;
|
|
98
|
+
}
|
|
99
|
+
export interface PdfPageFooterSpec {
|
|
100
|
+
text: string;
|
|
101
|
+
alignment?: 'left' | 'center' | 'right';
|
|
102
|
+
fontSize?: number;
|
|
103
|
+
color?: string;
|
|
104
|
+
font?: string;
|
|
105
|
+
margin?: [number, number, number, number];
|
|
106
|
+
}
|
|
58
107
|
export type FileTask = {
|
|
59
108
|
kind: 'pdf';
|
|
60
109
|
document: Record<string, unknown>;
|
|
61
110
|
fonts?: PdfTaskFonts;
|
|
111
|
+
tableLayouts?: Record<string, PdfTableLayoutSpec>;
|
|
112
|
+
footer?: PdfPageFooterSpec;
|
|
62
113
|
} | {
|
|
63
114
|
kind: 'xlsx';
|
|
64
115
|
workbook: XlsxWorkbookSpec;
|
|
@@ -100,6 +100,10 @@ export interface FormCallbacks<T = any> {
|
|
|
100
100
|
onUnhandledError?: (error: Error, methods: FormMethods<T>) => void;
|
|
101
101
|
onToast?: (type: 'success' | 'error' | 'info' | 'warning', message: string) => void;
|
|
102
102
|
onNavigate?: (path: string) => void;
|
|
103
|
+
onConfirm?: (request: {
|
|
104
|
+
title: string;
|
|
105
|
+
message: string;
|
|
106
|
+
}) => boolean | Promise<boolean>;
|
|
103
107
|
}
|
|
104
108
|
export interface FormProps<T = any> extends FormCallbacks<T> {
|
|
105
109
|
id?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileDeliveryAction, FileEngineOptions, FileFormat, FileJob, FileJobAction, FileJobPriority, FileTask } from '../core/types';
|
|
1
|
+
import type { FileDeliveryAction, FileEngineOptions, FileFormat, FileJob, FileJobAction, FileJobPriority, FileTask, PdfTaskFonts } from '../core/types';
|
|
2
2
|
export interface FileBuildContext {
|
|
3
3
|
signal: AbortSignal;
|
|
4
4
|
progress: (fraction: number) => void;
|
|
@@ -27,6 +27,7 @@ export type FileDeliverer = (blob: Blob, job: FileJob, action: FileDeliveryActio
|
|
|
27
27
|
export interface CreateFileEngineOptions extends FileEngineOptions {
|
|
28
28
|
deliver?: FileDeliverer;
|
|
29
29
|
createWorker?: () => Worker;
|
|
30
|
+
pdfFonts?: PdfTaskFonts;
|
|
30
31
|
}
|
|
31
32
|
export type FileEngineErrorCode = 'queue-full' | 'timeout' | 'disposed';
|
|
32
33
|
export declare class FileEngineError extends Error {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { FileTask } from '../../core/types';
|
|
1
|
+
import type { FileTask, PdfTaskFonts, PdfPageFooterSpec, PdfTableLayoutSpec } from '../../core/types';
|
|
2
2
|
export interface TaskContext {
|
|
3
3
|
progress: (fraction: number) => void;
|
|
4
4
|
signal?: AbortSignal;
|
|
5
|
+
pdfFonts?: PdfTaskFonts;
|
|
5
6
|
}
|
|
6
7
|
export declare function runFileTask(task: FileTask, ctx: TaskContext): Promise<ArrayBuffer>;
|
|
8
|
+
export declare function pdfTableLayout(spec: PdfTableLayoutSpec): Record<string, unknown>;
|
|
9
|
+
export declare function pdfFooter(spec: PdfPageFooterSpec): (page: number, pages: number) => Record<string, unknown>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -44,8 +44,8 @@ export * from './components/Charts';
|
|
|
44
44
|
export * from './components/Scroll';
|
|
45
45
|
export { ColorSchemeSelect } from './components/ColorSchemeSelect';
|
|
46
46
|
export type { ColorSchemeSelectProps } from './components/ColorSchemeSelect';
|
|
47
|
-
export { UIProvider, useUIPortalContainer, useUITheme, FormatProvider, useFormat, LabelsProvider, useUILabels, DEFAULT_UI_LABELS } from './components/UIProvider';
|
|
48
|
-
export type { FormatProviderProps, UILabels, UILabelsInput } from './components/UIProvider';
|
|
47
|
+
export { UIProvider, useUIPortalContainer, useUITheme, FormatProvider, useFormat, LabelsProvider, useUILabels, DEFAULT_UI_LABELS, HostProvider, useUIHost } from './components/UIProvider';
|
|
48
|
+
export type { FormatProviderProps, UILabels, UILabelsInput, UIHostDefaults, UIConfirmRequest } from './components/UIProvider';
|
|
49
49
|
export type { UIFormat, UIFormatSettings } from './core/types';
|
|
50
50
|
export type { UIProviderProps, UITheme, ResolvedUITheme, UIThemeValue } from './components/UIProvider';
|
|
51
51
|
export { Skeleton } from './components/Skeleton';
|
|
@@ -69,10 +69,12 @@ export type { DialogApi, DialogChoice, DialogActionProps, ConfirmOptions, Choose
|
|
|
69
69
|
export { ToastHost, useToast } from './components/Toast';
|
|
70
70
|
export type { ToastApi, ToastDefaults, ToastOptions, ToastPosition, ToastRecord, ToastType, ToastHostProps, } from './components/Toast';
|
|
71
71
|
export { createFileEngine, FileEngineError } from './file/fileEngine';
|
|
72
|
+
export { createPdfBlob, rawDataToBlob, downloadBlob, shareFile, openPreview, executeFileAction, getExtension, getFormatLabel, safeFileName, safeFileBaseName, EXTENSION_MAP, MIME_MAP, } from './file/fileActions';
|
|
73
|
+
export type { PdfFontConfig, FileAction } from './file/fileActions';
|
|
72
74
|
export type { FileEngine, CreateFileEngineOptions, FileJobRequest, FileBuildContext, FileDeliverer, FileEngineErrorCode, } from './file/fileEngine';
|
|
73
|
-
export type { FileFormat, FileDeliveryAction, FileJobAction, FileJobPriority, FileJobStatus, FileJob, FileEngineOptions, FileTask, XlsxWorkbookSpec, XlsxSheetSpec, XlsxColumnSpec, XlsxCellValue, PdfTaskFonts, } from './core/types';
|
|
75
|
+
export type { FileFormat, FileDeliveryAction, FileJobAction, FileJobPriority, FileJobStatus, FileJob, FileEngineOptions, FileTask, XlsxWorkbookSpec, XlsxSheetSpec, XlsxColumnSpec, XlsxCellValue, PdfTaskFonts, XlsxCellStyle, XlsxBorder, XlsxRowSpec, PdfTableLayoutSpec, PdfPageFooterSpec, } from './core/types';
|
|
74
76
|
export { FileEngineProvider, FileJobsTray, useFileEngine, useFileJob, DEFAULT_FILE_ENGINE_LABELS, } from './components/FileEngine';
|
|
75
|
-
export type { FileEngineProviderProps, FileJobsTrayProps, UseFileEngineResult, FileEngineLabels, FileEngineLabelsInput, } from './components/FileEngine';
|
|
77
|
+
export type { FileEngineProviderProps, FileJobNotice, FileJobsTrayProps, UseFileEngineResult, FileEngineLabels, FileEngineLabelsInput, } from './components/FileEngine';
|
|
76
78
|
export { Stepper } from './components/Stepper';
|
|
77
79
|
export type { StepperProps, StepperStep } from './components/Stepper';
|
|
78
80
|
export { Tabs, TabPanel } from './components/Tabs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcs-tech/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "React UI component library — fields, buttons, tooltips, tables and design tokens.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
"import": "./dist/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./style.css": "./dist/style.css",
|
|
21
|
+
"./file-worker": "./dist/file-worker.js",
|
|
21
22
|
"./package.json": "./package.json"
|
|
22
23
|
},
|
|
23
24
|
"publishConfig": {
|
|
24
25
|
"access": "public"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
|
-
"build": "vite build && npm run build:types && npm run verify:types && npm run verify:no-leak && npm run verify:tokens",
|
|
28
|
+
"build": "vite build && node scripts/copy-worker.mjs && npm run build:types && npm run verify:types && npm run verify:no-leak && npm run verify:tokens",
|
|
28
29
|
"build:types": "tsc -p tsconfig.build.json",
|
|
29
30
|
"verify:types": "tsc -p tsconfig.verify.json",
|
|
30
31
|
"verify:no-leak": "node scripts/verify-no-leak.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=()=>new DOMException(`Aborted`,`AbortError`);async function t(t,n){if(n.signal?.aborted)throw e();switch(t.kind){case`xlsx`:return o(t.workbook,n);case`pdf`:return c(t.document,t.fonts,n);default:throw Error(`Unknown file task: ${t.kind}`)}}const n=globalThis;async function r(){let e=await import(`exceljs`),t=[e.default?.default,e.default,e,n.ExcelJS].find(e=>e&&typeof e.Workbook==`function`);if(!t)throw Error(`ExcelJS did not load`);return t}async function i(){let e=await import(`pdfmake/build/pdfmake.js`),t=[e.default?.default,e.default,e,n.pdfMake].find(e=>e&&typeof e.createPdf==`function`);if(!t)throw Error(`pdfmake did not load`);let r=await import(`pdfmake/build/vfs_fonts.js`);return{pdfMake:t,vfs:[r?.default,r,r?.pdfMake?.vfs,r?.default?.pdfMake?.vfs,t.vfs,n.pdfMake?.vfs].find(e=>e&&e[`Roboto-Regular.ttf`])}}const a=e=>ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e;async function o(t,n){let i=new(await(r())).Workbook,o=Math.max(1,t.sheets.reduce((e,t)=>e+t.rows.length,0)),s=Math.max(1,Math.floor(o/50)),c=0;for(let r of t.sheets){let t=i.addWorksheet(r.name);t.columns=r.columns.map((e,t)=>({key:String(t),width:e.width}));let a=t.addRow(r.columns.map(e=>e.header));r.freezeHeader!==!1&&(a.font={bold:!0},t.views=[{state:`frozen`,ySplit:1}]);for(let i of r.rows){let a=t.addRow(i);if(r.columns.forEach((e,t)=>{if(!e.numFmt&&!e.align)return;let n=a.getCell(t+1);e.numFmt&&(n.numFmt=e.numFmt),e.align&&(n.alignment={horizontal:e.align})}),++c%s===0){if(n.signal?.aborted)throw e();n.progress(c/o*.9)}}}let l=await i.xlsx.writeBuffer();return n.progress(1),a(l)}const s={Roboto:{normal:`Roboto-Regular.ttf`,bold:`Roboto-Medium.ttf`,italics:`Roboto-Italic.ttf`,bolditalics:`Roboto-MediumItalic.ttf`}};async function c(t,n,r){let{pdfMake:a,vfs:o}=await i();if(r.progress(.1),r.signal?.aborted)throw e();let c={...s,...n?.fonts??{}},l=n?.vfs?{...o??{},...n.vfs}:o,u=await new Promise((e,n)=>{try{let r=a.createPdf(t,void 0,c,l).getStream(),i=[];r.on(`data`,e=>i.push(e)),r.on(`error`,n),r.on(`end`,()=>{let t=new Uint8Array(i.reduce((e,t)=>e+t.byteLength,0)),n=0;for(let e of i)t.set(e,n),n+=e.byteLength;e(t.buffer)}),r.end()}catch(e){n(e)}});return r.progress(1),u}const l=self;l.onmessage=async e=>{let{id:n,task:r}=e.data;try{let e=await t(r,{progress:e=>l.postMessage({type:`progress`,id:n,fraction:e})});l.postMessage({type:`done`,id:n,buffer:e},[e])}catch(e){l.postMessage({type:`error`,id:n,message:e instanceof Error?e.message:String(e)})}};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
// \0rolldown/runtime.js
|
|
3
|
-
var e = Object.defineProperty, t = (t, n) => {
|
|
4
|
-
let r = {};
|
|
5
|
-
for (var i in t) e(r, i, {
|
|
6
|
-
get: t[i],
|
|
7
|
-
enumerable: !0
|
|
8
|
-
});
|
|
9
|
-
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
10
|
-
}, n = /* @__PURE__ */ t({ runFileTask: () => i }), r = () => new DOMException("Aborted", "AbortError");
|
|
11
|
-
async function i(e, t) {
|
|
12
|
-
if (t.signal?.aborted) throw r();
|
|
13
|
-
switch (e.kind) {
|
|
14
|
-
case "xlsx": return l(e.workbook, t);
|
|
15
|
-
case "pdf": return d(e.document, e.fonts, t);
|
|
16
|
-
default: throw Error(`Unknown file task: ${e.kind}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
var a = globalThis;
|
|
20
|
-
async function o() {
|
|
21
|
-
let e = await import("exceljs"), t = [
|
|
22
|
-
e.default?.default,
|
|
23
|
-
e.default,
|
|
24
|
-
e,
|
|
25
|
-
a.ExcelJS
|
|
26
|
-
].find((e) => e && typeof e.Workbook == "function");
|
|
27
|
-
if (!t) throw Error("ExcelJS did not load");
|
|
28
|
-
return t;
|
|
29
|
-
}
|
|
30
|
-
async function s() {
|
|
31
|
-
let e = await import("pdfmake/build/pdfmake.js"), t = [
|
|
32
|
-
e.default?.default,
|
|
33
|
-
e.default,
|
|
34
|
-
e,
|
|
35
|
-
a.pdfMake
|
|
36
|
-
].find((e) => e && typeof e.createPdf == "function");
|
|
37
|
-
if (!t) throw Error("pdfmake did not load");
|
|
38
|
-
let n = await import("pdfmake/build/vfs_fonts.js");
|
|
39
|
-
return {
|
|
40
|
-
pdfMake: t,
|
|
41
|
-
vfs: [
|
|
42
|
-
n?.default,
|
|
43
|
-
n,
|
|
44
|
-
n?.pdfMake?.vfs,
|
|
45
|
-
n?.default?.pdfMake?.vfs,
|
|
46
|
-
t.vfs,
|
|
47
|
-
a.pdfMake?.vfs
|
|
48
|
-
].find((e) => e && e["Roboto-Regular.ttf"])
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
var c = (e) => ArrayBuffer.isView(e) ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e;
|
|
52
|
-
async function l(e, t) {
|
|
53
|
-
let n = new (await (o())).Workbook(), i = Math.max(1, e.sheets.reduce((e, t) => e + t.rows.length, 0)), a = Math.max(1, Math.floor(i / 50)), s = 0;
|
|
54
|
-
for (let o of e.sheets) {
|
|
55
|
-
let e = n.addWorksheet(o.name);
|
|
56
|
-
e.columns = o.columns.map((e, t) => ({
|
|
57
|
-
key: String(t),
|
|
58
|
-
width: e.width
|
|
59
|
-
}));
|
|
60
|
-
let c = e.addRow(o.columns.map((e) => e.header));
|
|
61
|
-
o.freezeHeader !== !1 && (c.font = { bold: !0 }, e.views = [{
|
|
62
|
-
state: "frozen",
|
|
63
|
-
ySplit: 1
|
|
64
|
-
}]);
|
|
65
|
-
for (let n of o.rows) {
|
|
66
|
-
let c = e.addRow(n);
|
|
67
|
-
if (o.columns.forEach((e, t) => {
|
|
68
|
-
if (!e.numFmt && !e.align) return;
|
|
69
|
-
let n = c.getCell(t + 1);
|
|
70
|
-
e.numFmt && (n.numFmt = e.numFmt), e.align && (n.alignment = { horizontal: e.align });
|
|
71
|
-
}), ++s % a === 0) {
|
|
72
|
-
if (t.signal?.aborted) throw r();
|
|
73
|
-
t.progress(s / i * .9);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
let l = await n.xlsx.writeBuffer();
|
|
78
|
-
return t.progress(1), c(l);
|
|
79
|
-
}
|
|
80
|
-
var u = { Roboto: {
|
|
81
|
-
normal: "Roboto-Regular.ttf",
|
|
82
|
-
bold: "Roboto-Medium.ttf",
|
|
83
|
-
italics: "Roboto-Italic.ttf",
|
|
84
|
-
bolditalics: "Roboto-MediumItalic.ttf"
|
|
85
|
-
} };
|
|
86
|
-
async function d(e, t, n) {
|
|
87
|
-
let { pdfMake: i, vfs: a } = await s();
|
|
88
|
-
if (n.progress(.1), n.signal?.aborted) throw r();
|
|
89
|
-
let o = {
|
|
90
|
-
...u,
|
|
91
|
-
...t?.fonts ?? {}
|
|
92
|
-
}, c = t?.vfs ? {
|
|
93
|
-
...a ?? {},
|
|
94
|
-
...t.vfs
|
|
95
|
-
} : a, l = await new Promise((t, n) => {
|
|
96
|
-
try {
|
|
97
|
-
let r = i.createPdf(e, void 0, o, c).getStream(), a = [];
|
|
98
|
-
r.on("data", (e) => a.push(e)), r.on("error", n), r.on("end", () => {
|
|
99
|
-
let e = new Uint8Array(a.reduce((e, t) => e + t.byteLength, 0)), n = 0;
|
|
100
|
-
for (let t of a) e.set(t, n), n += t.byteLength;
|
|
101
|
-
t(e.buffer);
|
|
102
|
-
}), r.end();
|
|
103
|
-
} catch (e) {
|
|
104
|
-
n(e);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return n.progress(1), l;
|
|
108
|
-
}
|
|
109
|
-
export { n, t as r, i as t };
|