@easyvision/easyvision-ui 1.7.6 → 1.9.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 +175 -0
- package/dist/EasyVisionTable.css +7 -0
- package/dist/easyvision.css +51 -0
- package/dist/index.cjs +614 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +193 -1
- package/dist/index.d.ts +193 -1
- package/dist/index.js +505 -94
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ComponentType, ReactNode, RefObject, Ref } from 'react';
|
|
4
4
|
import { RowData } from '@tanstack/react-table';
|
|
5
|
+
import ExcelJS from 'exceljs';
|
|
5
6
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
6
7
|
|
|
7
8
|
interface BaseStatefulProps<S = unknown> {
|
|
@@ -239,6 +240,64 @@ declare const EasyVisionCardDescription: React.ForwardRefExoticComponent<React.H
|
|
|
239
240
|
declare const EasyVisionCardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
240
241
|
declare const EasyVisionCardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
241
242
|
|
|
243
|
+
/** A single unfoldable question/answer entry for the data-driven API. */
|
|
244
|
+
interface AccordionItem {
|
|
245
|
+
/** Stable key, also used to track open state. */
|
|
246
|
+
id: string;
|
|
247
|
+
/** Header content — a string or any node (e.g. icon + label). */
|
|
248
|
+
question: ReactNode;
|
|
249
|
+
/** Free-format body revealed when the item is expanded. */
|
|
250
|
+
content: ReactNode;
|
|
251
|
+
/** Start expanded (uncontrolled mode only). */
|
|
252
|
+
defaultOpen?: boolean;
|
|
253
|
+
/** Render the trigger as non-interactive. */
|
|
254
|
+
disabled?: boolean;
|
|
255
|
+
}
|
|
256
|
+
/** 'single' = one item open at a time; 'multiple' = items open independently. */
|
|
257
|
+
type AccordionMode = 'single' | 'multiple';
|
|
258
|
+
interface EasyVisionAccordionProps {
|
|
259
|
+
/** Data-driven items. Omit when composing <EasyVisionAccordionItem> children instead. */
|
|
260
|
+
items?: AccordionItem[];
|
|
261
|
+
/** Compound children (alternative to `items`). */
|
|
262
|
+
children?: ReactNode;
|
|
263
|
+
/** Open behaviour. Default: 'single'. */
|
|
264
|
+
mode?: AccordionMode;
|
|
265
|
+
/** Controlled set of open ids. When provided the component is fully controlled. */
|
|
266
|
+
openIds?: string[];
|
|
267
|
+
/** Uncontrolled initial open ids (ignored when `openIds` is set). */
|
|
268
|
+
defaultOpenIds?: string[];
|
|
269
|
+
/** Fired whenever the open set changes, with the next list of open ids. */
|
|
270
|
+
onOpenChange?: (openIds: string[]) => void;
|
|
271
|
+
className?: string;
|
|
272
|
+
}
|
|
273
|
+
interface EasyVisionAccordionItemProps {
|
|
274
|
+
/** Stable key, also used to track open state. */
|
|
275
|
+
id: string;
|
|
276
|
+
/** Header content — a string or any node. */
|
|
277
|
+
question: ReactNode;
|
|
278
|
+
/** Free-format body revealed when expanded. */
|
|
279
|
+
children: ReactNode;
|
|
280
|
+
/** Start expanded (uncontrolled mode only). */
|
|
281
|
+
defaultOpen?: boolean;
|
|
282
|
+
/** Render the trigger as non-interactive. */
|
|
283
|
+
disabled?: boolean;
|
|
284
|
+
className?: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Marker component for the compound API. It renders nothing on its own — the
|
|
289
|
+
* parent <EasyVisionAccordion> reads its props and draws the row. Rendering it
|
|
290
|
+
* outside an accordion is a no-op.
|
|
291
|
+
*/
|
|
292
|
+
declare function EasyVisionAccordionItem(_props: EasyVisionAccordionItemProps): React.ReactElement | null;
|
|
293
|
+
declare namespace EasyVisionAccordionItem {
|
|
294
|
+
var displayName: string;
|
|
295
|
+
}
|
|
296
|
+
declare function EasyVisionAccordion({ items, children, mode, openIds, defaultOpenIds, onOpenChange, className, }: EasyVisionAccordionProps): React.ReactElement;
|
|
297
|
+
declare namespace EasyVisionAccordion {
|
|
298
|
+
var displayName: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
242
301
|
/**
|
|
243
302
|
* LoopBack adapter for `EasyVisionTable`.
|
|
244
303
|
*
|
|
@@ -343,6 +402,68 @@ declare function createLoopbackTableFetcher<T = unknown>(opts: CreateLoopbackTab
|
|
|
343
402
|
*/
|
|
344
403
|
declare function matchLoopbackWhere(row: unknown, where: LoopbackFilter['where'] | undefined): boolean;
|
|
345
404
|
|
|
405
|
+
/** A value ExcelJS can write into a cell without further coercion. */
|
|
406
|
+
type ExportCellValue = string | number | boolean | Date | null;
|
|
407
|
+
interface ExportCellStyle {
|
|
408
|
+
/** Solid background fill, ARGB (e.g. 'FFDC2626'). */
|
|
409
|
+
fill?: string;
|
|
410
|
+
/** Font colour, ARGB. */
|
|
411
|
+
fontColor?: string;
|
|
412
|
+
bold?: boolean;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* A fully-resolved sheet column: no dependency on table column types, so
|
|
416
|
+
* `buildWorkbook` stays independent of how the columns were derived.
|
|
417
|
+
*/
|
|
418
|
+
interface ExportColumnSpec<T = unknown> {
|
|
419
|
+
header: string;
|
|
420
|
+
getValue: (item: T) => ExportCellValue;
|
|
421
|
+
getStyle?: (value: ExportCellValue, item: T) => ExportCellStyle | undefined;
|
|
422
|
+
}
|
|
423
|
+
interface SheetSpec<T = unknown> {
|
|
424
|
+
/** Pre-sanitizing name. `buildWorkbook` sanitizes and de-duplicates. */
|
|
425
|
+
name: string;
|
|
426
|
+
columns: ExportColumnSpec<T>[];
|
|
427
|
+
rows: T[];
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* What an EasyVisionTable registers so an export button can pull from it.
|
|
431
|
+
* Both resolvers run at export time, never at registration time, so a column
|
|
432
|
+
* toggle or a new multifilter query needs no re-registration.
|
|
433
|
+
*/
|
|
434
|
+
interface ExportSource<T = unknown> {
|
|
435
|
+
/** Default sheet name. The button's `sheetNames` map overrides it. */
|
|
436
|
+
sheetName: string;
|
|
437
|
+
getColumns: () => ExportColumnSpec<T>[];
|
|
438
|
+
getRows: () => Promise<T[]>;
|
|
439
|
+
}
|
|
440
|
+
interface ExportLabels {
|
|
441
|
+
export: string;
|
|
442
|
+
exporting: string;
|
|
443
|
+
}
|
|
444
|
+
interface EasyVisionExportButtonProps {
|
|
445
|
+
/**
|
|
446
|
+
* Table ids, in sheet order. Each id is resolved namespace-first — qualified
|
|
447
|
+
* through the surrounding namespace, the same way a nested id is resolved
|
|
448
|
+
* elsewhere in this library — and only falls back to the raw id verbatim if
|
|
449
|
+
* that namespaced lookup misses.
|
|
450
|
+
*/
|
|
451
|
+
tables: string[];
|
|
452
|
+
/** Timestamp and `.xlsx` are appended. */
|
|
453
|
+
filename: string;
|
|
454
|
+
/** Per-table sheet-name override, keyed by the same id passed in `tables`. */
|
|
455
|
+
sheetNames?: Record<string, string>;
|
|
456
|
+
labels?: Partial<ExportLabels>;
|
|
457
|
+
/** Fetch or workbook failure. The export is aborted whole; no partial file. */
|
|
458
|
+
onError?: (error: unknown) => void;
|
|
459
|
+
/** Nothing to export — no file was written. */
|
|
460
|
+
onEmpty?: () => void;
|
|
461
|
+
disabled?: boolean;
|
|
462
|
+
className?: string;
|
|
463
|
+
/** Replaces the default download icon. */
|
|
464
|
+
icon?: ReactNode;
|
|
465
|
+
}
|
|
466
|
+
|
|
346
467
|
type TableMode = 'local' | 'api';
|
|
347
468
|
/**
|
|
348
469
|
* Controls the fallback sorting behavior when a column does not specify
|
|
@@ -404,6 +525,29 @@ type EasyVisionColumn<T> = {
|
|
|
404
525
|
* survive unmount when the table is mounted with `persist`.
|
|
405
526
|
*/
|
|
406
527
|
resizable?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Header text in an exported sheet. Defaults to `header` when it is a
|
|
530
|
+
* plain string, otherwise to `field`.
|
|
531
|
+
*/
|
|
532
|
+
exportHeader?: string;
|
|
533
|
+
/**
|
|
534
|
+
* Cell value in an exported sheet. Defaults to the value at `field`,
|
|
535
|
+
* with arrays joined by ", ". Use this to format dates, map codes to
|
|
536
|
+
* labels, or reach into fields the column doesn't render.
|
|
537
|
+
*/
|
|
538
|
+
exportValue?: (item: T) => ExportCellValue;
|
|
539
|
+
/**
|
|
540
|
+
* Per-cell styling in an exported sheet. Return ARGB colour strings
|
|
541
|
+
* (alpha first, e.g. 'FFDC2626'). Return undefined to leave the cell
|
|
542
|
+
* unstyled.
|
|
543
|
+
*/
|
|
544
|
+
exportStyle?: (value: ExportCellValue, item: T) => ExportCellStyle | undefined;
|
|
545
|
+
/**
|
|
546
|
+
* Include this column in exports. Defaults to true for `data` columns
|
|
547
|
+
* and false for `ui` columns — set it true on a `ui` column alongside an
|
|
548
|
+
* `exportValue` to export a computed column.
|
|
549
|
+
*/
|
|
550
|
+
exportable?: boolean;
|
|
407
551
|
} | {
|
|
408
552
|
type: 'ui';
|
|
409
553
|
/** Unique column ID. */
|
|
@@ -418,6 +562,29 @@ type EasyVisionColumn<T> = {
|
|
|
418
562
|
truncate?: boolean;
|
|
419
563
|
/** See data-column docs. */
|
|
420
564
|
resizable?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Header text in an exported sheet. Defaults to `header` when it is a
|
|
567
|
+
* plain string, otherwise to `field`.
|
|
568
|
+
*/
|
|
569
|
+
exportHeader?: string;
|
|
570
|
+
/**
|
|
571
|
+
* Cell value in an exported sheet. Defaults to the value at `field`,
|
|
572
|
+
* with arrays joined by ", ". Use this to format dates, map codes to
|
|
573
|
+
* labels, or reach into fields the column doesn't render.
|
|
574
|
+
*/
|
|
575
|
+
exportValue?: (item: T) => ExportCellValue;
|
|
576
|
+
/**
|
|
577
|
+
* Per-cell styling in an exported sheet. Return ARGB colour strings
|
|
578
|
+
* (alpha first, e.g. 'FFDC2626'). Return undefined to leave the cell
|
|
579
|
+
* unstyled.
|
|
580
|
+
*/
|
|
581
|
+
exportStyle?: (value: ExportCellValue, item: T) => ExportCellStyle | undefined;
|
|
582
|
+
/**
|
|
583
|
+
* Include this column in exports. Defaults to true for `data` columns
|
|
584
|
+
* and false for `ui` columns — set it true on a `ui` column alongside an
|
|
585
|
+
* `exportValue` to export a computed column.
|
|
586
|
+
*/
|
|
587
|
+
exportable?: boolean;
|
|
421
588
|
};
|
|
422
589
|
interface ApiFetchParams {
|
|
423
590
|
page: number;
|
|
@@ -627,6 +794,31 @@ interface EasyVisionTableProps<T> extends BaseStatefulProps {
|
|
|
627
794
|
|
|
628
795
|
declare function EasyVisionTable<T extends RowData>(props: EasyVisionTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
629
796
|
|
|
797
|
+
declare function EasyVisionExportButton({ tables, filename, sheetNames, labels: labelOverrides, onError, onEmpty, disabled, className, icon, }: EasyVisionExportButtonProps): react_jsx_runtime.JSX.Element;
|
|
798
|
+
|
|
799
|
+
declare const sanitizeSheetName: (name: string) => string;
|
|
800
|
+
interface ExportSheetsOptions {
|
|
801
|
+
/** Timestamp and `.xlsx` are appended. */
|
|
802
|
+
filename: string;
|
|
803
|
+
/** Injectable for tests. Defaults to an object-URL anchor click. */
|
|
804
|
+
download?: (blob: Blob, filename: string) => void;
|
|
805
|
+
}
|
|
806
|
+
/** Native download — no file-saver needed. */
|
|
807
|
+
declare const downloadBlob: (blob: Blob, filename: string) => void;
|
|
808
|
+
/**
|
|
809
|
+
* Assemble sheets into a workbook. Returns `null` when nothing was worth
|
|
810
|
+
* writing, so callers can distinguish "no file" from "empty file".
|
|
811
|
+
*/
|
|
812
|
+
declare function buildWorkbook<T>(sheets: SheetSpec<T>[]): Promise<ExcelJS.Workbook | null>;
|
|
813
|
+
/** Build and hand the file to the browser. Returns false when no file was written. */
|
|
814
|
+
declare function exportSheets<T>(sheets: SheetSpec<T>[], options: ExportSheetsOptions): Promise<boolean>;
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Flatten table columns into sheet columns, keeping the declared order.
|
|
818
|
+
* `isVisible` is supplied by the caller so this stays free of slice access.
|
|
819
|
+
*/
|
|
820
|
+
declare function toExportColumns<T>(columns: EasyVisionColumn<T>[], isVisible: (field: string) => boolean): ExportColumnSpec<T>[];
|
|
821
|
+
|
|
630
822
|
type SliceKind = 'input' | 'selector' | 'multifilter' | 'table';
|
|
631
823
|
interface InputSliceData {
|
|
632
824
|
kind: 'input';
|
|
@@ -690,4 +882,4 @@ declare const getSlice: <K extends SliceKind>(fullId: string) => SliceFor<K> | u
|
|
|
690
882
|
*/
|
|
691
883
|
declare const defaultCell: (content: ReactNode, title?: string) => ReactNode;
|
|
692
884
|
|
|
693
|
-
export { type ApiFetchParams, type ApiFetchResult, type BaseStatefulProps, type CreateLoopbackTableFetcherOptions, type CustomFieldDef, type DateRangeFieldDef, type DateRangeValue, EasyVisionCard, EasyVisionCardContent, EasyVisionCardDescription, EasyVisionCardFooter, EasyVisionCardHeader, EasyVisionCardTitle, type EasyVisionColumn, EasyVisionInput, type EasyVisionInputProps, EasyVisionMultifilter, type EasyVisionMultifilterProps, EasyVisionSelector, type EasyVisionSelectorProps, EasyVisionTable, type EasyVisionTableProps, type FieldDef, type LoopbackCountResponse, type LoopbackFilter, type LoopbackWhereValue, type MultiSelectFieldDef, type MultifilterConfig, type MultifilterFieldDef, type MultifilterHandle, type MultifilterLabels, type MultifilterQuery, type MultifilterSnapshot, type NumberRangeFieldDef, type NumberRangeValue, type SelectionChange, type SelectorFieldDef, type SelectorOption, type TableLabels, type TableMode, type TextFieldDef, createLoopbackTableFetcher, defaultCell, easyVisionRegistry, getSlice, matchLoopbackWhere };
|
|
885
|
+
export { type AccordionItem, type AccordionMode, type ApiFetchParams, type ApiFetchResult, type BaseStatefulProps, type CreateLoopbackTableFetcherOptions, type CustomFieldDef, type DateRangeFieldDef, type DateRangeValue, EasyVisionAccordion, EasyVisionAccordionItem, type EasyVisionAccordionItemProps, type EasyVisionAccordionProps, EasyVisionCard, EasyVisionCardContent, EasyVisionCardDescription, EasyVisionCardFooter, EasyVisionCardHeader, EasyVisionCardTitle, type EasyVisionColumn, EasyVisionExportButton, type EasyVisionExportButtonProps, EasyVisionInput, type EasyVisionInputProps, EasyVisionMultifilter, type EasyVisionMultifilterProps, EasyVisionSelector, type EasyVisionSelectorProps, EasyVisionTable, type EasyVisionTableProps, type ExportCellStyle, type ExportCellValue, type ExportColumnSpec, type ExportLabels, type ExportSource, type FieldDef, type LoopbackCountResponse, type LoopbackFilter, type LoopbackWhereValue, type MultiSelectFieldDef, type MultifilterConfig, type MultifilterFieldDef, type MultifilterHandle, type MultifilterLabels, type MultifilterQuery, type MultifilterSnapshot, type NumberRangeFieldDef, type NumberRangeValue, type SelectionChange, type SelectorFieldDef, type SelectorOption, type SheetSpec, type TableLabels, type TableMode, type TextFieldDef, buildWorkbook, createLoopbackTableFetcher, defaultCell, downloadBlob, easyVisionRegistry, exportSheets, getSlice, matchLoopbackWhere, sanitizeSheetName, toExportColumns };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ComponentType, ReactNode, RefObject, Ref } from 'react';
|
|
4
4
|
import { RowData } from '@tanstack/react-table';
|
|
5
|
+
import ExcelJS from 'exceljs';
|
|
5
6
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
6
7
|
|
|
7
8
|
interface BaseStatefulProps<S = unknown> {
|
|
@@ -239,6 +240,64 @@ declare const EasyVisionCardDescription: React.ForwardRefExoticComponent<React.H
|
|
|
239
240
|
declare const EasyVisionCardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
240
241
|
declare const EasyVisionCardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
241
242
|
|
|
243
|
+
/** A single unfoldable question/answer entry for the data-driven API. */
|
|
244
|
+
interface AccordionItem {
|
|
245
|
+
/** Stable key, also used to track open state. */
|
|
246
|
+
id: string;
|
|
247
|
+
/** Header content — a string or any node (e.g. icon + label). */
|
|
248
|
+
question: ReactNode;
|
|
249
|
+
/** Free-format body revealed when the item is expanded. */
|
|
250
|
+
content: ReactNode;
|
|
251
|
+
/** Start expanded (uncontrolled mode only). */
|
|
252
|
+
defaultOpen?: boolean;
|
|
253
|
+
/** Render the trigger as non-interactive. */
|
|
254
|
+
disabled?: boolean;
|
|
255
|
+
}
|
|
256
|
+
/** 'single' = one item open at a time; 'multiple' = items open independently. */
|
|
257
|
+
type AccordionMode = 'single' | 'multiple';
|
|
258
|
+
interface EasyVisionAccordionProps {
|
|
259
|
+
/** Data-driven items. Omit when composing <EasyVisionAccordionItem> children instead. */
|
|
260
|
+
items?: AccordionItem[];
|
|
261
|
+
/** Compound children (alternative to `items`). */
|
|
262
|
+
children?: ReactNode;
|
|
263
|
+
/** Open behaviour. Default: 'single'. */
|
|
264
|
+
mode?: AccordionMode;
|
|
265
|
+
/** Controlled set of open ids. When provided the component is fully controlled. */
|
|
266
|
+
openIds?: string[];
|
|
267
|
+
/** Uncontrolled initial open ids (ignored when `openIds` is set). */
|
|
268
|
+
defaultOpenIds?: string[];
|
|
269
|
+
/** Fired whenever the open set changes, with the next list of open ids. */
|
|
270
|
+
onOpenChange?: (openIds: string[]) => void;
|
|
271
|
+
className?: string;
|
|
272
|
+
}
|
|
273
|
+
interface EasyVisionAccordionItemProps {
|
|
274
|
+
/** Stable key, also used to track open state. */
|
|
275
|
+
id: string;
|
|
276
|
+
/** Header content — a string or any node. */
|
|
277
|
+
question: ReactNode;
|
|
278
|
+
/** Free-format body revealed when expanded. */
|
|
279
|
+
children: ReactNode;
|
|
280
|
+
/** Start expanded (uncontrolled mode only). */
|
|
281
|
+
defaultOpen?: boolean;
|
|
282
|
+
/** Render the trigger as non-interactive. */
|
|
283
|
+
disabled?: boolean;
|
|
284
|
+
className?: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Marker component for the compound API. It renders nothing on its own — the
|
|
289
|
+
* parent <EasyVisionAccordion> reads its props and draws the row. Rendering it
|
|
290
|
+
* outside an accordion is a no-op.
|
|
291
|
+
*/
|
|
292
|
+
declare function EasyVisionAccordionItem(_props: EasyVisionAccordionItemProps): React.ReactElement | null;
|
|
293
|
+
declare namespace EasyVisionAccordionItem {
|
|
294
|
+
var displayName: string;
|
|
295
|
+
}
|
|
296
|
+
declare function EasyVisionAccordion({ items, children, mode, openIds, defaultOpenIds, onOpenChange, className, }: EasyVisionAccordionProps): React.ReactElement;
|
|
297
|
+
declare namespace EasyVisionAccordion {
|
|
298
|
+
var displayName: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
242
301
|
/**
|
|
243
302
|
* LoopBack adapter for `EasyVisionTable`.
|
|
244
303
|
*
|
|
@@ -343,6 +402,68 @@ declare function createLoopbackTableFetcher<T = unknown>(opts: CreateLoopbackTab
|
|
|
343
402
|
*/
|
|
344
403
|
declare function matchLoopbackWhere(row: unknown, where: LoopbackFilter['where'] | undefined): boolean;
|
|
345
404
|
|
|
405
|
+
/** A value ExcelJS can write into a cell without further coercion. */
|
|
406
|
+
type ExportCellValue = string | number | boolean | Date | null;
|
|
407
|
+
interface ExportCellStyle {
|
|
408
|
+
/** Solid background fill, ARGB (e.g. 'FFDC2626'). */
|
|
409
|
+
fill?: string;
|
|
410
|
+
/** Font colour, ARGB. */
|
|
411
|
+
fontColor?: string;
|
|
412
|
+
bold?: boolean;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* A fully-resolved sheet column: no dependency on table column types, so
|
|
416
|
+
* `buildWorkbook` stays independent of how the columns were derived.
|
|
417
|
+
*/
|
|
418
|
+
interface ExportColumnSpec<T = unknown> {
|
|
419
|
+
header: string;
|
|
420
|
+
getValue: (item: T) => ExportCellValue;
|
|
421
|
+
getStyle?: (value: ExportCellValue, item: T) => ExportCellStyle | undefined;
|
|
422
|
+
}
|
|
423
|
+
interface SheetSpec<T = unknown> {
|
|
424
|
+
/** Pre-sanitizing name. `buildWorkbook` sanitizes and de-duplicates. */
|
|
425
|
+
name: string;
|
|
426
|
+
columns: ExportColumnSpec<T>[];
|
|
427
|
+
rows: T[];
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* What an EasyVisionTable registers so an export button can pull from it.
|
|
431
|
+
* Both resolvers run at export time, never at registration time, so a column
|
|
432
|
+
* toggle or a new multifilter query needs no re-registration.
|
|
433
|
+
*/
|
|
434
|
+
interface ExportSource<T = unknown> {
|
|
435
|
+
/** Default sheet name. The button's `sheetNames` map overrides it. */
|
|
436
|
+
sheetName: string;
|
|
437
|
+
getColumns: () => ExportColumnSpec<T>[];
|
|
438
|
+
getRows: () => Promise<T[]>;
|
|
439
|
+
}
|
|
440
|
+
interface ExportLabels {
|
|
441
|
+
export: string;
|
|
442
|
+
exporting: string;
|
|
443
|
+
}
|
|
444
|
+
interface EasyVisionExportButtonProps {
|
|
445
|
+
/**
|
|
446
|
+
* Table ids, in sheet order. Each id is resolved namespace-first — qualified
|
|
447
|
+
* through the surrounding namespace, the same way a nested id is resolved
|
|
448
|
+
* elsewhere in this library — and only falls back to the raw id verbatim if
|
|
449
|
+
* that namespaced lookup misses.
|
|
450
|
+
*/
|
|
451
|
+
tables: string[];
|
|
452
|
+
/** Timestamp and `.xlsx` are appended. */
|
|
453
|
+
filename: string;
|
|
454
|
+
/** Per-table sheet-name override, keyed by the same id passed in `tables`. */
|
|
455
|
+
sheetNames?: Record<string, string>;
|
|
456
|
+
labels?: Partial<ExportLabels>;
|
|
457
|
+
/** Fetch or workbook failure. The export is aborted whole; no partial file. */
|
|
458
|
+
onError?: (error: unknown) => void;
|
|
459
|
+
/** Nothing to export — no file was written. */
|
|
460
|
+
onEmpty?: () => void;
|
|
461
|
+
disabled?: boolean;
|
|
462
|
+
className?: string;
|
|
463
|
+
/** Replaces the default download icon. */
|
|
464
|
+
icon?: ReactNode;
|
|
465
|
+
}
|
|
466
|
+
|
|
346
467
|
type TableMode = 'local' | 'api';
|
|
347
468
|
/**
|
|
348
469
|
* Controls the fallback sorting behavior when a column does not specify
|
|
@@ -404,6 +525,29 @@ type EasyVisionColumn<T> = {
|
|
|
404
525
|
* survive unmount when the table is mounted with `persist`.
|
|
405
526
|
*/
|
|
406
527
|
resizable?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Header text in an exported sheet. Defaults to `header` when it is a
|
|
530
|
+
* plain string, otherwise to `field`.
|
|
531
|
+
*/
|
|
532
|
+
exportHeader?: string;
|
|
533
|
+
/**
|
|
534
|
+
* Cell value in an exported sheet. Defaults to the value at `field`,
|
|
535
|
+
* with arrays joined by ", ". Use this to format dates, map codes to
|
|
536
|
+
* labels, or reach into fields the column doesn't render.
|
|
537
|
+
*/
|
|
538
|
+
exportValue?: (item: T) => ExportCellValue;
|
|
539
|
+
/**
|
|
540
|
+
* Per-cell styling in an exported sheet. Return ARGB colour strings
|
|
541
|
+
* (alpha first, e.g. 'FFDC2626'). Return undefined to leave the cell
|
|
542
|
+
* unstyled.
|
|
543
|
+
*/
|
|
544
|
+
exportStyle?: (value: ExportCellValue, item: T) => ExportCellStyle | undefined;
|
|
545
|
+
/**
|
|
546
|
+
* Include this column in exports. Defaults to true for `data` columns
|
|
547
|
+
* and false for `ui` columns — set it true on a `ui` column alongside an
|
|
548
|
+
* `exportValue` to export a computed column.
|
|
549
|
+
*/
|
|
550
|
+
exportable?: boolean;
|
|
407
551
|
} | {
|
|
408
552
|
type: 'ui';
|
|
409
553
|
/** Unique column ID. */
|
|
@@ -418,6 +562,29 @@ type EasyVisionColumn<T> = {
|
|
|
418
562
|
truncate?: boolean;
|
|
419
563
|
/** See data-column docs. */
|
|
420
564
|
resizable?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Header text in an exported sheet. Defaults to `header` when it is a
|
|
567
|
+
* plain string, otherwise to `field`.
|
|
568
|
+
*/
|
|
569
|
+
exportHeader?: string;
|
|
570
|
+
/**
|
|
571
|
+
* Cell value in an exported sheet. Defaults to the value at `field`,
|
|
572
|
+
* with arrays joined by ", ". Use this to format dates, map codes to
|
|
573
|
+
* labels, or reach into fields the column doesn't render.
|
|
574
|
+
*/
|
|
575
|
+
exportValue?: (item: T) => ExportCellValue;
|
|
576
|
+
/**
|
|
577
|
+
* Per-cell styling in an exported sheet. Return ARGB colour strings
|
|
578
|
+
* (alpha first, e.g. 'FFDC2626'). Return undefined to leave the cell
|
|
579
|
+
* unstyled.
|
|
580
|
+
*/
|
|
581
|
+
exportStyle?: (value: ExportCellValue, item: T) => ExportCellStyle | undefined;
|
|
582
|
+
/**
|
|
583
|
+
* Include this column in exports. Defaults to true for `data` columns
|
|
584
|
+
* and false for `ui` columns — set it true on a `ui` column alongside an
|
|
585
|
+
* `exportValue` to export a computed column.
|
|
586
|
+
*/
|
|
587
|
+
exportable?: boolean;
|
|
421
588
|
};
|
|
422
589
|
interface ApiFetchParams {
|
|
423
590
|
page: number;
|
|
@@ -627,6 +794,31 @@ interface EasyVisionTableProps<T> extends BaseStatefulProps {
|
|
|
627
794
|
|
|
628
795
|
declare function EasyVisionTable<T extends RowData>(props: EasyVisionTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
629
796
|
|
|
797
|
+
declare function EasyVisionExportButton({ tables, filename, sheetNames, labels: labelOverrides, onError, onEmpty, disabled, className, icon, }: EasyVisionExportButtonProps): react_jsx_runtime.JSX.Element;
|
|
798
|
+
|
|
799
|
+
declare const sanitizeSheetName: (name: string) => string;
|
|
800
|
+
interface ExportSheetsOptions {
|
|
801
|
+
/** Timestamp and `.xlsx` are appended. */
|
|
802
|
+
filename: string;
|
|
803
|
+
/** Injectable for tests. Defaults to an object-URL anchor click. */
|
|
804
|
+
download?: (blob: Blob, filename: string) => void;
|
|
805
|
+
}
|
|
806
|
+
/** Native download — no file-saver needed. */
|
|
807
|
+
declare const downloadBlob: (blob: Blob, filename: string) => void;
|
|
808
|
+
/**
|
|
809
|
+
* Assemble sheets into a workbook. Returns `null` when nothing was worth
|
|
810
|
+
* writing, so callers can distinguish "no file" from "empty file".
|
|
811
|
+
*/
|
|
812
|
+
declare function buildWorkbook<T>(sheets: SheetSpec<T>[]): Promise<ExcelJS.Workbook | null>;
|
|
813
|
+
/** Build and hand the file to the browser. Returns false when no file was written. */
|
|
814
|
+
declare function exportSheets<T>(sheets: SheetSpec<T>[], options: ExportSheetsOptions): Promise<boolean>;
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Flatten table columns into sheet columns, keeping the declared order.
|
|
818
|
+
* `isVisible` is supplied by the caller so this stays free of slice access.
|
|
819
|
+
*/
|
|
820
|
+
declare function toExportColumns<T>(columns: EasyVisionColumn<T>[], isVisible: (field: string) => boolean): ExportColumnSpec<T>[];
|
|
821
|
+
|
|
630
822
|
type SliceKind = 'input' | 'selector' | 'multifilter' | 'table';
|
|
631
823
|
interface InputSliceData {
|
|
632
824
|
kind: 'input';
|
|
@@ -690,4 +882,4 @@ declare const getSlice: <K extends SliceKind>(fullId: string) => SliceFor<K> | u
|
|
|
690
882
|
*/
|
|
691
883
|
declare const defaultCell: (content: ReactNode, title?: string) => ReactNode;
|
|
692
884
|
|
|
693
|
-
export { type ApiFetchParams, type ApiFetchResult, type BaseStatefulProps, type CreateLoopbackTableFetcherOptions, type CustomFieldDef, type DateRangeFieldDef, type DateRangeValue, EasyVisionCard, EasyVisionCardContent, EasyVisionCardDescription, EasyVisionCardFooter, EasyVisionCardHeader, EasyVisionCardTitle, type EasyVisionColumn, EasyVisionInput, type EasyVisionInputProps, EasyVisionMultifilter, type EasyVisionMultifilterProps, EasyVisionSelector, type EasyVisionSelectorProps, EasyVisionTable, type EasyVisionTableProps, type FieldDef, type LoopbackCountResponse, type LoopbackFilter, type LoopbackWhereValue, type MultiSelectFieldDef, type MultifilterConfig, type MultifilterFieldDef, type MultifilterHandle, type MultifilterLabels, type MultifilterQuery, type MultifilterSnapshot, type NumberRangeFieldDef, type NumberRangeValue, type SelectionChange, type SelectorFieldDef, type SelectorOption, type TableLabels, type TableMode, type TextFieldDef, createLoopbackTableFetcher, defaultCell, easyVisionRegistry, getSlice, matchLoopbackWhere };
|
|
885
|
+
export { type AccordionItem, type AccordionMode, type ApiFetchParams, type ApiFetchResult, type BaseStatefulProps, type CreateLoopbackTableFetcherOptions, type CustomFieldDef, type DateRangeFieldDef, type DateRangeValue, EasyVisionAccordion, EasyVisionAccordionItem, type EasyVisionAccordionItemProps, type EasyVisionAccordionProps, EasyVisionCard, EasyVisionCardContent, EasyVisionCardDescription, EasyVisionCardFooter, EasyVisionCardHeader, EasyVisionCardTitle, type EasyVisionColumn, EasyVisionExportButton, type EasyVisionExportButtonProps, EasyVisionInput, type EasyVisionInputProps, EasyVisionMultifilter, type EasyVisionMultifilterProps, EasyVisionSelector, type EasyVisionSelectorProps, EasyVisionTable, type EasyVisionTableProps, type ExportCellStyle, type ExportCellValue, type ExportColumnSpec, type ExportLabels, type ExportSource, type FieldDef, type LoopbackCountResponse, type LoopbackFilter, type LoopbackWhereValue, type MultiSelectFieldDef, type MultifilterConfig, type MultifilterFieldDef, type MultifilterHandle, type MultifilterLabels, type MultifilterQuery, type MultifilterSnapshot, type NumberRangeFieldDef, type NumberRangeValue, type SelectionChange, type SelectorFieldDef, type SelectorOption, type SheetSpec, type TableLabels, type TableMode, type TextFieldDef, buildWorkbook, createLoopbackTableFetcher, defaultCell, downloadBlob, easyVisionRegistry, exportSheets, getSlice, matchLoopbackWhere, sanitizeSheetName, toExportColumns };
|