@inandu-solutions/grid-react 0.1.0 → 0.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.
- package/README.md +62 -37
- package/package.json +4 -3
- package/dist/components/InanduGrid.d.ts +0 -97
- package/dist/core/aggregate.d.ts +0 -5
- package/dist/core/columns.d.ts +0 -11
- package/dist/core/constants.d.ts +0 -14
- package/dist/core/export/csv.d.ts +0 -2
- package/dist/core/export/download.d.ts +0 -2
- package/dist/core/export/markup.d.ts +0 -2
- package/dist/core/export/pdf.d.ts +0 -3
- package/dist/core/filter.d.ts +0 -26
- package/dist/core/format.d.ts +0 -24
- package/dist/core/i18n/en.d.ts +0 -46
- package/dist/core/i18n/es.d.ts +0 -46
- package/dist/core/i18n/fr.d.ts +0 -46
- package/dist/core/i18n/index.d.ts +0 -8
- package/dist/core/i18n/it.d.ts +0 -46
- package/dist/core/i18n/zh.d.ts +0 -46
- package/dist/core/index.d.ts +0 -16
- package/dist/core/parse.d.ts +0 -14
- package/dist/core/sort.d.ts +0 -1
- package/dist/core/tree.d.ts +0 -28
- package/dist/core/types.d.ts +0 -46
- package/dist/hooks/useInanduGrid.d.ts +0 -187
- package/dist/html2canvas-BE2ZQbtv.js +0 -4021
- package/dist/html2canvas-o9-HsXBE.cjs +0 -5
- package/dist/inandu-grid-react.cjs +0 -2
- package/dist/inandu-grid-react.js +0 -1656
- package/dist/index.d.ts +0 -11
- package/dist/index.es-BqzICVsf.cjs +0 -5
- package/dist/index.es-CPZG9pTc.js +0 -5752
- package/dist/jspdf.es.min-D_8zJvYC.cjs +0 -78
- package/dist/jspdf.es.min-DiTFVZBc.js +0 -18250
- package/dist/purify.es-3_UFdOhH.js +0 -805
- package/dist/purify.es-DXMFKXT6.cjs +0 -3
- package/dist/utils/exporters.d.ts +0 -29
- package/dist/utils/measureColumn.d.ts +0 -15
- package/dist/utils/translate.d.ts +0 -10
package/dist/core/tree.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tree-data flattening (#3) — pure, framework-agnostic. Walks a nested-children hierarchy into the
|
|
3
|
-
* flat list of rows that should render right now: a node's children appear directly below it, but
|
|
4
|
-
* only while that node is expanded. Filtering keeps a node when it (or any descendant) matches, and
|
|
5
|
-
* force-expands the ancestors of a match so it's visible; an optional comparator sorts each level.
|
|
6
|
-
*/
|
|
7
|
-
export interface TreeVisibleRow<T> {
|
|
8
|
-
row: T;
|
|
9
|
-
/** 0 for a root, +1 per level. Drives the first cell's indentation. */
|
|
10
|
-
depth: number;
|
|
11
|
-
/** Has at least one (surviving) child — i.e. worth showing a toggle. */
|
|
12
|
-
expandable: boolean;
|
|
13
|
-
/** Currently showing its children. */
|
|
14
|
-
expanded: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface FlattenTreeOptions<T> {
|
|
17
|
-
/** A node's children array (or `undefined` / `[]` for a leaf). */
|
|
18
|
-
getChildren: (row: T) => readonly T[] | undefined;
|
|
19
|
-
/** Whether `row` is expanded — consulted only when there is no active `match`. */
|
|
20
|
-
isExpanded: (row: T) => boolean;
|
|
21
|
-
/** When set, a node survives iff it or a descendant returns `true`; matches render expanded. */
|
|
22
|
-
match?: (row: T) => boolean;
|
|
23
|
-
/** Sorts the siblings at every level (applied after filtering). */
|
|
24
|
-
compare?: (a: T, b: T) => number;
|
|
25
|
-
}
|
|
26
|
-
export declare function flattenTree<T>(roots: readonly T[], options: FlattenTreeOptions<T>): TreeVisibleRow<T>[];
|
|
27
|
-
/** Every node in the hierarchy, depth-first — used for "expand all" / counting. */
|
|
28
|
-
export declare function collectTreeRows<T>(roots: readonly T[], getChildren: (row: T) => readonly T[] | undefined): T[];
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** How a column's raw cell value is interpreted and formatted. See `InanduColumnComponent.type`. */
|
|
2
|
-
export type InanduColumnType = 'string' | 'number' | 'boolean' | 'date';
|
|
3
|
-
/** Which side of the grid a `sticky="true"` column pins to. See `InanduColumnComponent.stickySide`. */
|
|
4
|
-
export type InanduColumnStickySide = 'left' | 'right';
|
|
5
|
-
/** Aggregate shown in a group's header row when the grid is grouped. See `InanduColumnComponent.aggregate`. */
|
|
6
|
-
export type InanduColumnAggregate = 'sum' | 'avg' | 'min' | 'max' | 'count' | '';
|
|
7
|
-
/** A grid row — a plain bag of field values. The grid never assumes any particular key. */
|
|
8
|
-
export type InanduGridRow = Record<string, unknown>;
|
|
9
|
-
/**
|
|
10
|
-
* The subset of a column definition the pure helpers read, expressed as the signal-getter shape
|
|
11
|
-
* `InanduColumnComponent` already exposes (so an `InanduColumnComponent` instance satisfies this
|
|
12
|
-
* structurally, with no adapter). A non-Angular consumer can pass any object with these five
|
|
13
|
-
* zero-arg accessors — e.g. `{ field: () => 'name', type: () => 'string', ... }`.
|
|
14
|
-
*/
|
|
15
|
-
export interface ColumnConfig {
|
|
16
|
-
field(): string;
|
|
17
|
-
type(): InanduColumnType;
|
|
18
|
-
format(): string;
|
|
19
|
-
order(): number | undefined;
|
|
20
|
-
aggregate(): InanduColumnAggregate;
|
|
21
|
-
}
|
|
22
|
-
/** Raw values from a single column's filter controls; which keys are used depends on that column's `type`. */
|
|
23
|
-
export interface InanduGridColumnFilterValue {
|
|
24
|
-
/** `'string'` columns. */
|
|
25
|
-
text?: string;
|
|
26
|
-
/** `'number'` columns. */
|
|
27
|
-
min?: string;
|
|
28
|
-
max?: string;
|
|
29
|
-
/** `'date'` columns, `yyyy-mm-dd` (native `<input type="date">` value format). */
|
|
30
|
-
from?: string;
|
|
31
|
-
to?: string;
|
|
32
|
-
/** `'boolean'` columns: `''` (no filter), `'true'`, or `'false'`. */
|
|
33
|
-
bool?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Excel-style "set filter" — an explicit list of the column's own *formatted* display values to
|
|
36
|
-
* match (OR within the column, same as every other filter key combines with AND across
|
|
37
|
-
* columns). Works the same regardless of `type` — unlike `text`/`min`/`max`/`from`/`to`/`bool`,
|
|
38
|
-
* which are each specific to one `type` — since it compares against the already-formatted
|
|
39
|
-
* string, not the raw value. Whenever this key is *present* (defined) at all, it takes over
|
|
40
|
-
* matching for the column entirely and the type-specific keys above are ignored — including an
|
|
41
|
-
* **empty array**, which means "every value unchecked" and matches nothing, not "no
|
|
42
|
-
* constraint". Omit the key (or set it to `undefined`) for "no constraint" instead. See
|
|
43
|
-
* `matchesColumnFilter`/`hasMeaningfulFilterValue`.
|
|
44
|
-
*/
|
|
45
|
-
values?: string[];
|
|
46
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { InanduColumnAggregate, InanduColumnStickySide, InanduColumnType, InanduGridColumnFilterValue, InanduGridRow, TreeVisibleRow } from '../core';
|
|
2
|
-
/**
|
|
3
|
-
* Plain-value column definition for the React API — friendlier than the core's `ColumnConfig`
|
|
4
|
-
* getter shape (`field()`, `type()`, ...), which exists to match grid-angular's signal-based
|
|
5
|
-
* columns. `toColumnConfig` below adapts one to the other so the ported core needs no changes.
|
|
6
|
-
*/
|
|
7
|
-
export interface InanduGridColumn {
|
|
8
|
-
field: string;
|
|
9
|
-
headerText?: string;
|
|
10
|
-
type?: InanduColumnType;
|
|
11
|
-
format?: string;
|
|
12
|
-
order?: number;
|
|
13
|
-
aggregate?: InanduColumnAggregate;
|
|
14
|
-
/** Whether this column can be picked in the "group by" control. Default: true. */
|
|
15
|
-
groupable?: boolean;
|
|
16
|
-
/** Whether this field shows an editable control while its row is in edit/add mode. Default: false. */
|
|
17
|
-
editable?: boolean;
|
|
18
|
-
required?: boolean;
|
|
19
|
-
/** `'number'` columns only. */
|
|
20
|
-
min?: number;
|
|
21
|
-
/** `'number'` columns only. */
|
|
22
|
-
max?: number;
|
|
23
|
-
/** Checked against the raw (unparsed) draft value, `'string'`/`'number'`/`'date'` columns only. */
|
|
24
|
-
pattern?: string;
|
|
25
|
-
/** Runs after required/min/max/pattern all pass, against the parsed value and the row's other parsed fields (for cross-field checks). */
|
|
26
|
-
validator?: (parsed: unknown, parsedRow: Record<string, unknown>) => string | null;
|
|
27
|
-
/** Runs only once every synchronous rule (above) has already passed for this field; every field's async check runs concurrently. */
|
|
28
|
-
asyncValidator?: (parsed: unknown, parsedRow: Record<string, unknown>) => Promise<string | null>;
|
|
29
|
-
/** Whether this column can be hidden via the column-visibility toggle. Default: true. */
|
|
30
|
-
hideable?: boolean;
|
|
31
|
-
/** Pins the column to that side of the table, `position: sticky`, regardless of scroll. Unset: not pinned. */
|
|
32
|
-
pinned?: InanduColumnStickySide;
|
|
33
|
-
/** Fixed column width in px — also what `stickyOffset`/`stickyOffsetRight` stack against. Default (unset): 80, same fallback grid-angular's `effectiveWidth() || 80` uses. */
|
|
34
|
-
width?: number;
|
|
35
|
-
/** Whether this column's header can be dragged to reorder columns. Default: true. */
|
|
36
|
-
reorder?: boolean;
|
|
37
|
-
}
|
|
38
|
-
/** Passed to `onRowSave` — everything `saveRow()` parsed and validated for one already-existing row. */
|
|
39
|
-
export interface InanduGridRowSave {
|
|
40
|
-
row: InanduGridRow;
|
|
41
|
-
values: Record<string, unknown>;
|
|
42
|
-
}
|
|
43
|
-
/** One cell update from a `pasteAt()` call — one entry per pasted cell that landed on an existing row and an editable column. */
|
|
44
|
-
export interface InanduGridCellPaste {
|
|
45
|
-
row: InanduGridRow;
|
|
46
|
-
field: string;
|
|
47
|
-
value: unknown;
|
|
48
|
-
}
|
|
49
|
-
export interface InanduGridSort {
|
|
50
|
-
field: string;
|
|
51
|
-
direction: 'asc' | 'desc';
|
|
52
|
-
}
|
|
53
|
-
/** One bucket of `useInanduGrid`'s `groups` — mirrors grid-angular's `groupedRows`. */
|
|
54
|
-
export interface InanduGridGroup {
|
|
55
|
-
/** The grouped column's *formatted* display value for every row in this bucket. */
|
|
56
|
-
key: string;
|
|
57
|
-
rows: InanduGridRow[];
|
|
58
|
-
/** One entry per column with `aggregate` set, keyed by that column's field. */
|
|
59
|
-
aggregates: Record<string, number>;
|
|
60
|
-
}
|
|
61
|
-
export interface UseInanduGridOptions {
|
|
62
|
-
rows: InanduGridRow[];
|
|
63
|
-
columns: InanduGridColumn[];
|
|
64
|
-
locale?: string;
|
|
65
|
-
/** Drives validation-message translation. Default: `locale`'s primary subtag. */
|
|
66
|
-
lang?: string;
|
|
67
|
-
/** 0 disables pagination — `visibleRows` is the full sorted/filtered set. Default: 0. */
|
|
68
|
-
pageSize?: number;
|
|
69
|
-
/** Whether the caller renders a select-checkbox column — `stickyOffset()` needs to know, since that column (when present) is always sticky-left too. Default: false. */
|
|
70
|
-
selectable?: boolean;
|
|
71
|
-
/** `window.confirm()`-gates `deleteRow()`, same as grid-angular. Unset: deletes immediately. */
|
|
72
|
-
deleteConfirmMessage?: string;
|
|
73
|
-
/** `window.confirm()`-gates `deleteSelectedRows()`. Unset: deletes immediately. */
|
|
74
|
-
bulkDeleteConfirmMessage?: string;
|
|
75
|
-
/** Emitted by `saveRow()` once validation passes — the grid never mutates `rows` itself; applying the change is the caller's job. */
|
|
76
|
-
onRowSave?: (event: InanduGridRowSave) => void;
|
|
77
|
-
/** Emitted by `saveNewRow()` once validation passes. No row reference — it doesn't exist in `rows` yet. */
|
|
78
|
-
onRowCreate?: (values: Record<string, unknown>) => void;
|
|
79
|
-
/** Emitted by `deleteRow()` (after confirmation, if any). */
|
|
80
|
-
onRowDelete?: (row: InanduGridRow) => void;
|
|
81
|
-
/** Emitted by `deleteSelectedRows()` (after confirmation, if any) — every currently-selected row. */
|
|
82
|
-
onRowsDelete?: (rows: InanduGridRow[]) => void;
|
|
83
|
-
/** Emitted by `pasteAt()` with every parsed cell update — the grid never mutates `rows` itself. */
|
|
84
|
-
onCellsPaste?: (updates: InanduGridCellPaste[]) => void;
|
|
85
|
-
/** Emitted by `onRowDrop()` with the fully reordered row array — the grid never mutates `rows` itself. */
|
|
86
|
-
onRowOrderChange?: (rows: InanduGridRow[]) => void;
|
|
87
|
-
/**
|
|
88
|
-
* Turns on tree mode: the name of the field on each row holding its child rows (a nested array
|
|
89
|
-
* of the same shape). `rows` is then the root rows; free-text/column filters keep a node when it
|
|
90
|
-
* or any descendant matches, and the active sort orders each level of siblings. Auto-disabled
|
|
91
|
-
* while grouped, same restriction grid-angular's `treeChildrenKey` has (there it also excludes
|
|
92
|
-
* virtual-scroll/server-side, neither of which this port has). Unset (default): tree mode off.
|
|
93
|
-
*/
|
|
94
|
-
treeChildrenKey?: string;
|
|
95
|
-
/** Initial expand state for tree mode: `'none'` (default), `'all'`, or a max depth to open to. */
|
|
96
|
-
treeDefaultExpanded?: 'none' | 'all' | number;
|
|
97
|
-
/** Whether master-detail is on — the caller checks this itself (by passing a `renderDetail`), this only controls `toggleRowExpanded`'s accordion behavior. Off (any number of rows can be expanded at once) by default. */
|
|
98
|
-
singleDetailExpand?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Opt-in row virtualization for large datasets — bypasses pagination entirely (same as grouping),
|
|
101
|
-
* feeding the windowing logic the full sorted/filtered set instead. Auto-disables grouping,
|
|
102
|
-
* master-detail, tree data, row drag-reorder and clipboard, same restrictions grid-angular's
|
|
103
|
-
* `virtualScroll` has (there it also covers server-side infinite-scroll, which this port doesn't
|
|
104
|
-
* have). The actual DOM windowing (which rows are mounted, given a real scroll position) is the
|
|
105
|
-
* `<InanduGrid>` component's job, not this hook's — it has no way to observe scroll state itself.
|
|
106
|
-
*/
|
|
107
|
-
virtualScroll?: boolean;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Headless engine for the grid: owns sort + per-column filter + pagination state and derives
|
|
111
|
-
* `visibleRows` (the current page) and `filteredRowCount` (before pagination) from `rows` using
|
|
112
|
-
* the same pure core as grid-angular. No rendering — `<InanduGrid>` is one consumer of this hook,
|
|
113
|
-
* not the only way to use it.
|
|
114
|
-
*/
|
|
115
|
-
export declare function useInanduGrid({ rows, columns, locale, lang, pageSize, selectable, deleteConfirmMessage, bulkDeleteConfirmMessage, onRowSave, onRowCreate, onRowDelete, onRowsDelete, onCellsPaste, onRowOrderChange, treeChildrenKey, treeDefaultExpanded, singleDetailExpand, virtualScroll, }: UseInanduGridOptions): {
|
|
116
|
-
visibleColumns: InanduGridColumn[];
|
|
117
|
-
stickyOffset: (field: string) => number;
|
|
118
|
-
stickyOffsetRight: (field: string) => number;
|
|
119
|
-
hideableColumns: InanduGridColumn[];
|
|
120
|
-
isColumnHidden: (field: string) => boolean;
|
|
121
|
-
toggleColumnVisibility: (field: string) => void;
|
|
122
|
-
setColumnOrder: (fields: readonly string[]) => void;
|
|
123
|
-
draggingField: string | undefined;
|
|
124
|
-
onColumnDragStart: (field: string) => void;
|
|
125
|
-
onColumnDrop: (targetField: string) => void;
|
|
126
|
-
effectiveWidth: (field: string) => number;
|
|
127
|
-
isColumnResized: (field: string) => boolean;
|
|
128
|
-
setColumnWidth: (field: string, width: number) => void;
|
|
129
|
-
draggingRow: InanduGridRow | undefined;
|
|
130
|
-
onRowDragStart: (row: InanduGridRow) => void;
|
|
131
|
-
onRowDrop: (targetRow: InanduGridRow) => void;
|
|
132
|
-
hasTreeData: boolean;
|
|
133
|
-
treeRows: TreeVisibleRow<InanduGridRow>[];
|
|
134
|
-
isTreeRowExpanded: (row: InanduGridRow) => boolean;
|
|
135
|
-
toggleTreeRow: (row: InanduGridRow) => void;
|
|
136
|
-
setAllTreeRowsExpanded: (expanded: boolean) => void;
|
|
137
|
-
isRowExpanded: (row: InanduGridRow) => boolean;
|
|
138
|
-
toggleRowExpanded: (row: InanduGridRow) => void;
|
|
139
|
-
hasVirtualScroll: boolean;
|
|
140
|
-
visibleRows: InanduGridRow[];
|
|
141
|
-
/** Same "what's on screen right now" set the select-all checkbox and CSV/Excel/PDF export use — the current page, or every group's rows while grouped. */
|
|
142
|
-
exportRows: InanduGridRow[];
|
|
143
|
-
filteredRowCount: number;
|
|
144
|
-
sortCriteria: InanduGridSort[];
|
|
145
|
-
setSort: import('react').Dispatch<import('react').SetStateAction<InanduGridSort[]>>;
|
|
146
|
-
toggleSort: (field: string, additive?: boolean) => void;
|
|
147
|
-
sortDirectionFor: (field: string) => "asc" | "desc" | undefined;
|
|
148
|
-
sortPriorityFor: (field: string) => number | undefined;
|
|
149
|
-
filterValues: Record<string, InanduGridColumnFilterValue>;
|
|
150
|
-
setFilterValue: (field: string, value: InanduGridColumnFilterValue) => void;
|
|
151
|
-
filterQuery: string;
|
|
152
|
-
setFilterQuery: (query: string) => void;
|
|
153
|
-
page: number;
|
|
154
|
-
setPage: import('react').Dispatch<import('react').SetStateAction<number>>;
|
|
155
|
-
pageCount: number;
|
|
156
|
-
groupByField: string | undefined;
|
|
157
|
-
setGroupByField: import('react').Dispatch<import('react').SetStateAction<string | undefined>>;
|
|
158
|
-
groups: InanduGridGroup[] | null;
|
|
159
|
-
totals: Record<string, number>;
|
|
160
|
-
selectedRows: Set<InanduGridRow>;
|
|
161
|
-
isRowSelected: (row: InanduGridRow) => boolean;
|
|
162
|
-
toggleRowSelection: (row: InanduGridRow) => void;
|
|
163
|
-
allSelected: boolean;
|
|
164
|
-
someSelected: boolean;
|
|
165
|
-
toggleSelectAll: () => void;
|
|
166
|
-
clearSelection: () => void;
|
|
167
|
-
editableColumns: InanduGridColumn[];
|
|
168
|
-
editingRow: InanduGridRow | undefined;
|
|
169
|
-
isAddingRow: boolean;
|
|
170
|
-
rowDraft: Record<string, unknown>;
|
|
171
|
-
fieldErrors: Record<string, string>;
|
|
172
|
-
isValidating: boolean;
|
|
173
|
-
isEditingRow: (row: InanduGridRow) => boolean;
|
|
174
|
-
isAnotherRowEditing: (row: InanduGridRow) => boolean;
|
|
175
|
-
startEditingRow: (row: InanduGridRow) => void;
|
|
176
|
-
cancelRowEdit: () => void;
|
|
177
|
-
setRowDraftValue: (field: string, value: unknown) => void;
|
|
178
|
-
saveRow: (row: InanduGridRow) => Promise<void>;
|
|
179
|
-
deleteRow: (row: InanduGridRow) => void;
|
|
180
|
-
deleteSelectedRows: () => void;
|
|
181
|
-
startAddingRow: () => void;
|
|
182
|
-
cancelAddRow: () => void;
|
|
183
|
-
saveNewRow: () => Promise<void>;
|
|
184
|
-
validateCell: (column: InanduGridColumn, value: unknown, row?: Record<string, unknown>) => string | null;
|
|
185
|
-
copyCellText: (rowIndex: number, field: string) => string;
|
|
186
|
-
pasteAt: (anchorRowIndex: number, anchorField: string, text: string) => void;
|
|
187
|
-
};
|