@inandu-solutions/grid-react 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/InanduGrid.d.ts +99 -0
- package/dist/core/aggregate.d.ts +5 -0
- package/dist/core/columns.d.ts +11 -0
- package/dist/core/constants.d.ts +14 -0
- package/dist/core/dom.d.ts +8 -0
- package/dist/core/export/csv.d.ts +2 -0
- package/dist/core/export/download.d.ts +2 -0
- package/dist/core/export/markup.d.ts +2 -0
- package/dist/core/export/pdf.d.ts +3 -0
- package/dist/core/filter.d.ts +26 -0
- package/dist/core/format.d.ts +24 -0
- package/dist/core/i18n/en.d.ts +46 -0
- package/dist/core/i18n/es.d.ts +46 -0
- package/dist/core/i18n/fr.d.ts +46 -0
- package/dist/core/i18n/index.d.ts +8 -0
- package/dist/core/i18n/it.d.ts +46 -0
- package/dist/core/i18n/zh.d.ts +46 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/parse.d.ts +14 -0
- package/dist/core/sort.d.ts +1 -0
- package/dist/core/tree.d.ts +28 -0
- package/dist/core/types.d.ts +46 -0
- package/dist/hooks/useInanduGrid.d.ts +197 -0
- package/dist/html2canvas-BE2ZQbtv.js +4021 -0
- package/dist/html2canvas-o9-HsXBE.cjs +5 -0
- package/dist/inandu-grid-react.cjs +2 -0
- package/dist/inandu-grid-react.js +1684 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.es-BqzICVsf.cjs +5 -0
- package/dist/index.es-CPZG9pTc.js +5752 -0
- package/dist/jspdf.es.min-D_8zJvYC.cjs +78 -0
- package/dist/jspdf.es.min-DiTFVZBc.js +18250 -0
- package/dist/purify.es-3_UFdOhH.js +805 -0
- package/dist/purify.es-DXMFKXT6.cjs +3 -0
- package/dist/style.css +350 -0
- package/dist/utils/exporters.d.ts +29 -0
- package/dist/utils/measureColumn.d.ts +15 -0
- package/dist/utils/translate.d.ts +10 -0
- package/package.json +4 -2
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
/** An extra per-row predicate ANDed onto the free-text + column filters — same as grid-angular's `extraRowFilter`. Lets a caller layer its own filtering (e.g. an advanced-filter query) on top of the grid's own. Unset: no extra filtering. */
|
|
109
|
+
extraRowFilter?: (row: InanduGridRow) => boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Headless engine for the grid: owns sort + per-column filter + pagination state and derives
|
|
113
|
+
* `visibleRows` (the current page) and `filteredRowCount` (before pagination) from `rows` using
|
|
114
|
+
* the same pure core as grid-angular. No rendering — `<InanduGrid>` is one consumer of this hook,
|
|
115
|
+
* not the only way to use it.
|
|
116
|
+
*/
|
|
117
|
+
export declare function useInanduGrid({ rows, columns, locale, lang, pageSize, selectable, deleteConfirmMessage, bulkDeleteConfirmMessage, onRowSave, onRowCreate, onRowDelete, onRowsDelete, onCellsPaste, onRowOrderChange, treeChildrenKey, treeDefaultExpanded, singleDetailExpand, virtualScroll, extraRowFilter, }: UseInanduGridOptions): {
|
|
118
|
+
visibleColumns: InanduGridColumn[];
|
|
119
|
+
/** Every column in current drag-reorder order, hidden ones included — same as grid-angular's `displayColumns()`. Most rendering should use `visibleColumns` instead; this is for callers (like a saved-view restore) that need to address a currently-hidden column too. */
|
|
120
|
+
allColumns: InanduGridColumn[];
|
|
121
|
+
stickyOffset: (field: string) => number;
|
|
122
|
+
stickyOffsetRight: (field: string) => number;
|
|
123
|
+
columnPinnedSide: (field: string) => InanduColumnStickySide | undefined;
|
|
124
|
+
setColumnPinned: (field: string, side: InanduColumnStickySide | undefined) => void;
|
|
125
|
+
hideableColumns: InanduGridColumn[];
|
|
126
|
+
isColumnHidden: (field: string) => boolean;
|
|
127
|
+
toggleColumnVisibility: (field: string) => void;
|
|
128
|
+
setColumnOrder: (fields: readonly string[]) => void;
|
|
129
|
+
draggingField: string | undefined;
|
|
130
|
+
onColumnDragStart: (field: string) => void;
|
|
131
|
+
onColumnDrop: (targetField: string) => void;
|
|
132
|
+
effectiveWidth: (field: string) => number;
|
|
133
|
+
isColumnResized: (field: string) => boolean;
|
|
134
|
+
setColumnWidth: (field: string, width: number) => void;
|
|
135
|
+
draggingRow: InanduGridRow | undefined;
|
|
136
|
+
onRowDragStart: (row: InanduGridRow) => void;
|
|
137
|
+
onRowDrop: (targetRow: InanduGridRow) => void;
|
|
138
|
+
hasTreeData: boolean;
|
|
139
|
+
treeRows: TreeVisibleRow<InanduGridRow>[];
|
|
140
|
+
isTreeRowExpanded: (row: InanduGridRow) => boolean;
|
|
141
|
+
toggleTreeRow: (row: InanduGridRow) => void;
|
|
142
|
+
setAllTreeRowsExpanded: (expanded: boolean) => void;
|
|
143
|
+
isRowExpanded: (row: InanduGridRow) => boolean;
|
|
144
|
+
toggleRowExpanded: (row: InanduGridRow) => void;
|
|
145
|
+
hasVirtualScroll: boolean;
|
|
146
|
+
visibleRows: InanduGridRow[];
|
|
147
|
+
/** 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. */
|
|
148
|
+
exportRows: InanduGridRow[];
|
|
149
|
+
/** Every row matching the current filter and sort, in sort order, regardless of pagination or grouping — same as grid-angular's `sortedData()`. Unlike `exportRows`, this never stops at one page: a full-dataset export/print reads from here instead. */
|
|
150
|
+
sortedRows: InanduGridRow[];
|
|
151
|
+
filteredRowCount: number;
|
|
152
|
+
locale: string;
|
|
153
|
+
sortCriteria: InanduGridSort[];
|
|
154
|
+
setSort: import('react').Dispatch<import('react').SetStateAction<InanduGridSort[]>>;
|
|
155
|
+
toggleSort: (field: string, additive?: boolean) => void;
|
|
156
|
+
sortDirectionFor: (field: string) => "asc" | "desc" | undefined;
|
|
157
|
+
sortPriorityFor: (field: string) => number | undefined;
|
|
158
|
+
filterValues: Record<string, InanduGridColumnFilterValue>;
|
|
159
|
+
setFilterValue: (field: string, value: InanduGridColumnFilterValue) => void;
|
|
160
|
+
clearAllFilters: () => void;
|
|
161
|
+
filterQuery: string;
|
|
162
|
+
setFilterQuery: (query: string) => void;
|
|
163
|
+
page: number;
|
|
164
|
+
setPage: import('react').Dispatch<import('react').SetStateAction<number>>;
|
|
165
|
+
pageCount: number;
|
|
166
|
+
groupByField: string | undefined;
|
|
167
|
+
setGroupByField: import('react').Dispatch<import('react').SetStateAction<string | undefined>>;
|
|
168
|
+
groups: InanduGridGroup[] | null;
|
|
169
|
+
totals: Record<string, number>;
|
|
170
|
+
selectedRows: Set<InanduGridRow>;
|
|
171
|
+
isRowSelected: (row: InanduGridRow) => boolean;
|
|
172
|
+
toggleRowSelection: (row: InanduGridRow) => void;
|
|
173
|
+
allSelected: boolean;
|
|
174
|
+
someSelected: boolean;
|
|
175
|
+
toggleSelectAll: () => void;
|
|
176
|
+
clearSelection: () => void;
|
|
177
|
+
editableColumns: InanduGridColumn[];
|
|
178
|
+
editingRow: InanduGridRow | undefined;
|
|
179
|
+
isAddingRow: boolean;
|
|
180
|
+
rowDraft: Record<string, unknown>;
|
|
181
|
+
fieldErrors: Record<string, string>;
|
|
182
|
+
isValidating: boolean;
|
|
183
|
+
isEditingRow: (row: InanduGridRow) => boolean;
|
|
184
|
+
isAnotherRowEditing: (row: InanduGridRow) => boolean;
|
|
185
|
+
startEditingRow: (row: InanduGridRow) => void;
|
|
186
|
+
cancelRowEdit: () => void;
|
|
187
|
+
setRowDraftValue: (field: string, value: unknown) => void;
|
|
188
|
+
saveRow: (row: InanduGridRow) => Promise<void>;
|
|
189
|
+
deleteRow: (row: InanduGridRow) => void;
|
|
190
|
+
deleteSelectedRows: () => void;
|
|
191
|
+
startAddingRow: () => void;
|
|
192
|
+
cancelAddRow: () => void;
|
|
193
|
+
saveNewRow: () => Promise<void>;
|
|
194
|
+
validateCell: (column: InanduGridColumn, value: unknown, row?: Record<string, unknown>) => string | null;
|
|
195
|
+
copyCellText: (rowIndex: number, field: string) => string;
|
|
196
|
+
pasteAt: (anchorRowIndex: number, anchorField: string, text: string) => void;
|
|
197
|
+
};
|