@box-kite/react 0.0.1 → 1.0.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/.claude/rules/box-kite-rules.md +43 -0
- package/.claude/skills/box-kite/SKILL.md +431 -0
- package/BOX_AI_CONTEXT.md +1833 -0
- package/BOX_KITE_AI_CONTEXT.md +1833 -0
- package/LICENSE +21 -0
- package/README.md +710 -7
- package/a11y.cjs +1 -0
- package/a11y.d.ts +15 -0
- package/a11y.mjs +3 -0
- package/behavior.cjs +1 -0
- package/behavior.mjs +295 -0
- package/box.cjs +1 -0
- package/box.d.ts +46 -0
- package/box.mjs +23 -0
- package/client.cjs +1 -0
- package/client.mjs +163 -0
- package/components/baseSvg.cjs +1 -0
- package/components/baseSvg.d.ts +5 -0
- package/components/baseSvg.mjs +21 -0
- package/components/button.cjs +1 -0
- package/components/button.d.ts +16 -0
- package/components/button.mjs +19 -0
- package/components/chart.cjs +1 -0
- package/components/chart.d.ts +82 -0
- package/components/chart.mjs +261 -0
- package/components/checkbox.cjs +1 -0
- package/components/checkbox.d.ts +28 -0
- package/components/checkbox.mjs +38 -0
- package/components/dataGrid/components/dataGridBody.d.ts +7 -0
- package/components/dataGrid/components/dataGridBottomBar.d.ts +6 -0
- package/components/dataGrid/components/dataGridCell.d.ts +15 -0
- package/components/dataGrid/components/dataGridCellRowDetail.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellRowSelection.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellText.d.ts +6 -0
- package/components/dataGrid/components/dataGridColumnFilter.d.ts +9 -0
- package/components/dataGrid/components/dataGridColumnGroups.d.ts +7 -0
- package/components/dataGrid/components/dataGridContent.d.ts +6 -0
- package/components/dataGrid/components/dataGridDetailRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridEmptyColumns.d.ts +6 -0
- package/components/dataGrid/components/dataGridFilterCell.d.ts +11 -0
- package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
- package/components/dataGrid/components/dataGridGlobalFilter.d.ts +6 -0
- package/components/dataGrid/components/dataGridGroupRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridHeader.d.ts +6 -0
- package/components/dataGrid/components/dataGridHeaderCell.d.ts +9 -0
- package/components/dataGrid/components/dataGridHeaderCellContextMenu.d.ts +11 -0
- package/components/dataGrid/components/dataGridHeaderCellResizer.d.ts +14 -0
- package/components/dataGrid/components/dataGridLoader.d.ts +11 -0
- package/components/dataGrid/components/dataGridPagination.d.ts +6 -0
- package/components/dataGrid/components/dataGridRow.d.ts +8 -0
- package/components/dataGrid/components/dataGridTopBar.d.ts +6 -0
- package/components/dataGrid/components/dataGridTopBarContextMenu.d.ts +6 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +213 -0
- package/components/dataGrid/gridNavigationContext.d.ts +24 -0
- package/components/dataGrid/models/cellModel.d.ts +18 -0
- package/components/dataGrid/models/columnModel.d.ts +150 -0
- package/components/dataGrid/models/columnVisibilityModel.d.ts +24 -0
- package/components/dataGrid/models/detailRowModel.d.ts +22 -0
- package/components/dataGrid/models/filterModel.d.ts +22 -0
- package/components/dataGrid/models/gridModel.d.ts +206 -0
- package/components/dataGrid/models/groupRowCellModel.d.ts +26 -0
- package/components/dataGrid/models/groupRowModel.d.ts +48 -0
- package/components/dataGrid/models/headerCellModel.d.ts +83 -0
- package/components/dataGrid/models/paginationModel.d.ts +32 -0
- package/components/dataGrid/models/rowModel.d.ts +34 -0
- package/components/dataGrid/models/viewportModel.d.ts +44 -0
- package/components/dataGrid/useGrid.d.ts +8 -0
- package/components/dataGrid/useGridNavigation.d.ts +21 -0
- package/components/dataGrid.cjs +1 -0
- package/components/dataGrid.d.ts +2 -0
- package/components/dataGrid.mjs +3178 -0
- package/components/dropdown/dropdownContext.d.ts +44 -0
- package/components/dropdown/dropdownItems.d.ts +22 -0
- package/components/dropdown/dropdownRowRenderer.d.ts +8 -0
- package/components/dropdown/dropdownSearch.d.ts +21 -0
- package/components/dropdown/utils.d.ts +1 -0
- package/components/dropdown.cjs +1 -0
- package/components/dropdown.d.ts +47 -0
- package/components/dropdown.mjs +479 -0
- package/components/flex.cjs +1 -0
- package/components/flex.d.ts +6 -0
- package/components/flex.mjs +16 -0
- package/components/form.cjs +1 -0
- package/components/form.d.ts +10 -0
- package/components/form.mjs +58 -0
- package/components/grid.cjs +1 -0
- package/components/grid.d.ts +6 -0
- package/components/grid.mjs +16 -0
- package/components/icon.cjs +1 -0
- package/components/icon.d.ts +36 -0
- package/components/icon.mjs +41 -0
- package/components/overlay.cjs +1 -0
- package/components/overlay.d.ts +43 -0
- package/components/overlay.mjs +82 -0
- package/components/presence.cjs +1 -0
- package/components/presence.d.ts +30 -0
- package/components/presence.mjs +11 -0
- package/components/radioButton.cjs +1 -0
- package/components/radioButton.d.ts +24 -0
- package/components/radioButton.mjs +32 -0
- package/components/radioGroup.cjs +1 -0
- package/components/radioGroup.d.ts +38 -0
- package/components/radioGroup.mjs +79 -0
- package/components/select.cjs +1 -0
- package/components/select.d.ts +42 -0
- package/components/select.mjs +36 -0
- package/components/semantics.cjs +1 -0
- package/components/semantics.d.ts +34 -0
- package/components/semantics.mjs +17 -0
- package/components/svg.cjs +1 -0
- package/components/svg.d.ts +63 -0
- package/components/svg.mjs +141 -0
- package/components/switch.cjs +1 -0
- package/components/switch.d.ts +20 -0
- package/components/switch.mjs +25 -0
- package/components/textarea.cjs +1 -0
- package/components/textarea.d.ts +27 -0
- package/components/textarea.mjs +33 -0
- package/components/textbox.cjs +1 -0
- package/components/textbox.d.ts +26 -0
- package/components/textbox.mjs +33 -0
- package/components/tooltip.cjs +1 -0
- package/components/tooltip.d.ts +63 -0
- package/components/tooltip.mjs +108 -0
- package/components/visuallyHidden.cjs +1 -0
- package/components/visuallyHidden.d.ts +6 -0
- package/components/visuallyHidden.mjs +23 -0
- package/effects.cjs +1 -0
- package/effects.mjs +6 -0
- package/forms.cjs +1 -0
- package/forms.mjs +21 -0
- package/icons/dotsIcon.d.ts +2 -0
- package/icons/expandIcon.d.ts +2 -0
- package/icons/groupingIcon.d.ts +2 -0
- package/icons/pinIcon.d.ts +2 -0
- package/icons/searchIcon.d.ts +2 -0
- package/icons/sortIcon.d.ts +2 -0
- package/motion.cjs +1 -0
- package/motion.mjs +66 -0
- package/package.json +203 -7
- package/platform.cjs +1 -0
- package/platform.mjs +32 -0
- package/react/a11y/callbacks.d.ts +12 -0
- package/react/a11y/useControllableState.d.ts +25 -0
- package/react/a11y/useDismiss.d.ts +25 -0
- package/react/a11y/useFocusReturn.d.ts +18 -0
- package/react/a11y/useIdentifier.d.ts +17 -0
- package/react/a11y/useRovingFocus.d.ts +84 -0
- package/react/animation/usePresence.d.ts +32 -0
- package/react/boxClassNames.d.ts +25 -0
- package/react/boxProps.d.ts +49 -0
- package/react/boxTagProps.d.ts +7 -0
- package/react/clientRuntime.d.ts +11 -0
- package/react/effects.d.ts +10 -0
- package/react/forms/labelledControl.d.ts +17 -0
- package/react/forms/placeholderProp.d.ts +13 -0
- package/react/hooks/usePortalContainer.d.ts +1 -0
- package/react/hooks/useVirtualization.d.ts +43 -0
- package/react/hooks/useVisibility.d.ts +9 -0
- package/react/reactTypes.d.ts +10 -0
- package/react/resolveStyles.d.ts +18 -0
- package/react/styleElements.d.ts +3 -0
- package/react/svg/attributesInProps.d.ts +4 -0
- package/react/svg/svgNaming.d.ts +15 -0
- package/react/theme/theme.d.ts +26 -0
- package/react/theme/themeContext.d.ts +7 -0
- package/react/useStyles.d.ts +22 -0
- package/react-shared.cjs +1 -0
- package/react-shared.mjs +105 -0
- package/rolldown-runtime.cjs +1 -0
- package/rsc.cjs +1 -0
- package/rsc.d.ts +27 -0
- package/rsc.mjs +18 -0
- package/ssg.cjs +1 -0
- package/ssg.d.ts +24 -0
- package/ssg.mjs +25 -0
- package/utils/animation/animationUtils.d.ts +29 -0
- package/utils/array/arrayUtils.d.ts +15 -0
- package/utils/box/boxUtils.d.ts +5 -0
- package/utils/chart/chartUtils.d.ts +98 -0
- package/utils/dom/domUtils.d.ts +26 -0
- package/utils/environment/environmentUtils.d.ts +18 -0
- package/utils/fn/fnUtils.d.ts +4 -0
- package/utils/form/formUtils.d.ts +8 -0
- package/utils/memo.d.ts +10 -0
- package/utils/object/objectUtils.d.ts +13 -0
- package/utils/string/fuzzySearch.d.ts +27 -0
- package/utils/string/stringUtils.d.ts +4 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { ComponentsAndVariants } from '../../../types';
|
|
2
|
+
import { SortDirection } from '../../../utils/array/arrayUtils';
|
|
3
|
+
import { default as CellModel } from '../models/cellModel';
|
|
4
|
+
export type { SortDirection };
|
|
5
|
+
export type Key = string | number;
|
|
6
|
+
/**
|
|
7
|
+
* Which edge a column is pinned to, named by the reading order rather than by the screen: `START` is the
|
|
8
|
+
* left edge of a left-to-right grid and the right edge of a right-to-left one, so a pinned column stays
|
|
9
|
+
* where the reading starts under either `dir`. `LEFT`/`RIGHT` are the older spelling of the same two.
|
|
10
|
+
*/
|
|
11
|
+
export type PinPosition = 'START' | 'END';
|
|
12
|
+
/** What `pin` accepts — the logical pair, plus the physical names it used to be spelled with. */
|
|
13
|
+
export type PinPositionInput = PinPosition | 'LEFT' | 'RIGHT';
|
|
14
|
+
/** The logical side behind whichever spelling the caller used. */
|
|
15
|
+
export declare function pinPositionOf(pin?: PinPositionInput): PinPosition | undefined;
|
|
16
|
+
export declare const NO_PIN = "NO_PIN";
|
|
17
|
+
export type SortColumnType<TRow> = {
|
|
18
|
+
key: keyof TRow;
|
|
19
|
+
dir: SortDirection;
|
|
20
|
+
};
|
|
21
|
+
export type KeysMatching<T, V> = {
|
|
22
|
+
[K in keyof T]-?: T[K] extends V ? K : never;
|
|
23
|
+
}[keyof T];
|
|
24
|
+
export interface PaginationState {
|
|
25
|
+
pageSize: number;
|
|
26
|
+
page: number;
|
|
27
|
+
totalItems: number;
|
|
28
|
+
totalPages: number;
|
|
29
|
+
}
|
|
30
|
+
/** Server-side pagination configuration on GridDefinition */
|
|
31
|
+
export interface PaginationConfig {
|
|
32
|
+
/** Total number of items across all pages (from server response) */
|
|
33
|
+
totalCount: number;
|
|
34
|
+
/** Page size override. If omitted, defaults to visibleRowsCount (or 10). */
|
|
35
|
+
pageSize?: number;
|
|
36
|
+
/** Options shown in the page size selector dropdown. If omitted, no selector is shown. */
|
|
37
|
+
pageSizeOptions?: number[];
|
|
38
|
+
}
|
|
39
|
+
/** Snapshot of all server-relevant grid state, passed to onServerStateChange */
|
|
40
|
+
export interface ServerState<TRow> {
|
|
41
|
+
page: number;
|
|
42
|
+
pageSize: number;
|
|
43
|
+
sortColumn: Key | undefined;
|
|
44
|
+
sortDirection: SortDirection | undefined;
|
|
45
|
+
columnFilters: ColumnFilters<TRow>;
|
|
46
|
+
globalFilterValue: string;
|
|
47
|
+
}
|
|
48
|
+
/** Filter type for column-level filtering */
|
|
49
|
+
export type ColumnFilterType = 'text' | 'number' | 'multiselect';
|
|
50
|
+
/** Text filter configuration (fuzzy search) */
|
|
51
|
+
export interface TextFilterValue {
|
|
52
|
+
type: 'text';
|
|
53
|
+
value: string;
|
|
54
|
+
}
|
|
55
|
+
/** Number filter configuration with comparison operators */
|
|
56
|
+
export interface NumberFilterValue {
|
|
57
|
+
type: 'number';
|
|
58
|
+
operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'between';
|
|
59
|
+
value: number;
|
|
60
|
+
valueTo?: number;
|
|
61
|
+
}
|
|
62
|
+
/** Multi-select filter configuration */
|
|
63
|
+
export interface MultiselectFilterValue {
|
|
64
|
+
type: 'multiselect';
|
|
65
|
+
values: (string | number | boolean | null)[];
|
|
66
|
+
}
|
|
67
|
+
/** Union type for all filter values */
|
|
68
|
+
export type FilterValue = TextFilterValue | NumberFilterValue | MultiselectFilterValue;
|
|
69
|
+
/** Column filters record - maps column key to filter value */
|
|
70
|
+
export type ColumnFilters<TRow> = Partial<Record<keyof TRow | Key, FilterValue>>;
|
|
71
|
+
/** Filter configuration for a column */
|
|
72
|
+
export interface ColumnFilterConfig {
|
|
73
|
+
type: ColumnFilterType;
|
|
74
|
+
/** Placeholder text for input */
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
/** For multiselect: custom options. If not provided, unique values are computed from data */
|
|
77
|
+
options?: {
|
|
78
|
+
label: string;
|
|
79
|
+
value: string | number | boolean | null;
|
|
80
|
+
}[];
|
|
81
|
+
/** For number: step value for input */
|
|
82
|
+
step?: number;
|
|
83
|
+
/** For number: min value */
|
|
84
|
+
min?: number;
|
|
85
|
+
/** For number: max value */
|
|
86
|
+
max?: number;
|
|
87
|
+
}
|
|
88
|
+
/** Configuration for expandable row detail panel */
|
|
89
|
+
export interface RowDetailConfig<TRow> {
|
|
90
|
+
/** Render function for the detail content */
|
|
91
|
+
content: (row: TRow) => React.ReactNode;
|
|
92
|
+
/** Height of the detail row. 'auto' sizes to content. Default: 'auto' */
|
|
93
|
+
height?: 'auto' | number | ((row: TRow) => number);
|
|
94
|
+
/** Whether clicking the row also toggles expansion. Default: false */
|
|
95
|
+
expandOnRowClick?: boolean;
|
|
96
|
+
/** Pin the expand column to LEFT. Default: false */
|
|
97
|
+
pinned?: boolean;
|
|
98
|
+
/** Width of the expand column. Default: 50 */
|
|
99
|
+
expandColumnWidth?: number;
|
|
100
|
+
/** Header text for the expand column. Default: '' (empty) */
|
|
101
|
+
expandColumnHeader?: string;
|
|
102
|
+
}
|
|
103
|
+
/** Controls which sections appear in the column header context menu */
|
|
104
|
+
export interface ContextMenuConfig {
|
|
105
|
+
/** Show sort actions (Sort Ascending, Sort Descending, Clear Sort). Default: true */
|
|
106
|
+
sort?: boolean;
|
|
107
|
+
/** Show pin actions (pin to start, pin to end, unpin). Default: true */
|
|
108
|
+
pin?: boolean;
|
|
109
|
+
/** Show group actions (Group By, Un-Group All). Default: true */
|
|
110
|
+
group?: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface ColumnType<TRow> {
|
|
113
|
+
key: Key;
|
|
114
|
+
header?: string;
|
|
115
|
+
pin?: PinPositionInput;
|
|
116
|
+
width?: number;
|
|
117
|
+
columns?: ColumnType<TRow>[];
|
|
118
|
+
/** `start`/`end` follow the reading order; `left`/`right` stay on the screen side they name. */
|
|
119
|
+
align?: 'start' | 'end' | 'center' | 'left' | 'right';
|
|
120
|
+
Cell?: React.ComponentType<{
|
|
121
|
+
cell: CellModel<TRow>;
|
|
122
|
+
}>;
|
|
123
|
+
/** Enable filtering for this column. Set to true for default text filter, or provide config */
|
|
124
|
+
filterable?: boolean | ColumnFilterConfig;
|
|
125
|
+
/** Enable sorting for this column. If undefined, inherits from GridDefinition.sortable */
|
|
126
|
+
sortable?: boolean;
|
|
127
|
+
/** Enable resizing for this column. If undefined, inherits from GridDefinition.resizable */
|
|
128
|
+
resizable?: boolean;
|
|
129
|
+
/** If false, column stays fixed at its width and doesn't participate in flex distribution. Default: true */
|
|
130
|
+
flexible?: boolean;
|
|
131
|
+
/** Control the header context menu. false hides it entirely. Object controls individual sections. Inherits from GridDefinition.contextMenu if undefined. */
|
|
132
|
+
contextMenu?: boolean | ContextMenuConfig;
|
|
133
|
+
}
|
|
134
|
+
export interface GridDefinition<TRow> {
|
|
135
|
+
rowKey?: KeysMatching<TRow, Key> | ((rowData: TRow) => Key);
|
|
136
|
+
columns: ColumnType<TRow>[];
|
|
137
|
+
showRowNumber?: boolean | {
|
|
138
|
+
pinned?: boolean;
|
|
139
|
+
width?: number;
|
|
140
|
+
};
|
|
141
|
+
rowSelection?: boolean | {
|
|
142
|
+
pinned?: boolean;
|
|
143
|
+
};
|
|
144
|
+
rowHeight?: number;
|
|
145
|
+
/** Number of visible rows. Set to 'all' to render all rows without virtualization or vertical scrollbar. */
|
|
146
|
+
visibleRowsCount?: number | 'all';
|
|
147
|
+
topBar?: boolean;
|
|
148
|
+
bottomBar?: boolean;
|
|
149
|
+
/** Title displayed in the top bar */
|
|
150
|
+
title?: React.ReactNode;
|
|
151
|
+
/** Custom filters or actions rendered in the top bar */
|
|
152
|
+
topBarContent?: React.ReactNode;
|
|
153
|
+
/** Enable global filter with fuzzy search */
|
|
154
|
+
globalFilter?: boolean;
|
|
155
|
+
/** Keys of columns to search in global filter. If not provided, all columns are searched */
|
|
156
|
+
globalFilterKeys?: (keyof TRow | Key)[];
|
|
157
|
+
/** Enable sorting for all columns. Default is true. Individual column settings take priority. */
|
|
158
|
+
sortable?: boolean;
|
|
159
|
+
/** Enable resizing for all columns. Default is true. Individual column settings take priority. */
|
|
160
|
+
resizable?: boolean;
|
|
161
|
+
/** Controls the visual style of column resizer handles. 'visible' (default): always shown. 'hover': visible on header cell hover. 'hidden': invisible but resize still works. */
|
|
162
|
+
resizerStyle?: 'visible' | 'hover' | 'hidden';
|
|
163
|
+
/** How the column follows the pointer during a resize drag. 'smooth' (default): updates batched once per animation frame (~60fps, ~1 frame behind the cursor). 'instant': updates synchronously on every pointer move so the column tracks the cursor with no added latency. */
|
|
164
|
+
resizeMode?: 'smooth' | 'instant';
|
|
165
|
+
/** Control the header context menu for all columns. false hides it entirely. Object controls individual sections. Default: true. Individual column settings take priority. */
|
|
166
|
+
contextMenu?: boolean | ContextMenuConfig;
|
|
167
|
+
/** Custom component to render when data is empty */
|
|
168
|
+
noDataComponent?: React.ReactNode;
|
|
169
|
+
/** Enable expandable row detail panel */
|
|
170
|
+
rowDetail?: RowDetailConfig<TRow>;
|
|
171
|
+
/** Server-side pagination. Provide totalCount from the API response. */
|
|
172
|
+
pagination?: PaginationConfig;
|
|
173
|
+
}
|
|
174
|
+
export interface DataGridProps<TRow> {
|
|
175
|
+
/** Component name for style resolution. Default: 'datagrid'. Set to a custom name to use a different component style tree. */
|
|
176
|
+
component?: keyof ComponentsAndVariants;
|
|
177
|
+
data: TRow[];
|
|
178
|
+
def: GridDefinition<TRow>;
|
|
179
|
+
loading?: boolean;
|
|
180
|
+
onSelectionChange?: (event: SelectionChangeEvent<TRow>) => void;
|
|
181
|
+
/** Controlled global filter value */
|
|
182
|
+
globalFilterValue?: string;
|
|
183
|
+
/** Callback when global filter changes */
|
|
184
|
+
onGlobalFilterChange?: (value: string) => void;
|
|
185
|
+
/** Controlled column filters */
|
|
186
|
+
columnFilters?: ColumnFilters<TRow>;
|
|
187
|
+
/** Callback when column filters change */
|
|
188
|
+
onColumnFiltersChange?: (filters: ColumnFilters<TRow>) => void;
|
|
189
|
+
/** External predicate filters applied before global/column filters. Memoize with useMemo for performance. */
|
|
190
|
+
filters?: ((row: TRow) => boolean)[];
|
|
191
|
+
/** Controlled expanded detail row keys */
|
|
192
|
+
expandedRowKeys?: Key[];
|
|
193
|
+
/** Callback when expanded detail rows change */
|
|
194
|
+
onExpandedRowKeysChange?: (keys: Key[]) => void;
|
|
195
|
+
/** Controlled current page (1-indexed). Used with pagination. */
|
|
196
|
+
page?: number;
|
|
197
|
+
/** Callback when page changes. Receives page (1-indexed) and pageSize. */
|
|
198
|
+
onPageChange?: (page: number, pageSize: number) => void;
|
|
199
|
+
/** Controlled page size. Used with pagination and pageSizeOptions. */
|
|
200
|
+
pageSize?: number;
|
|
201
|
+
/** Callback when the user changes the page size. */
|
|
202
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
203
|
+
/** Callback when sort changes. For server-side sorting with pagination. */
|
|
204
|
+
onSortChange?: (columnKey: Key | undefined, direction: SortDirection | undefined) => void;
|
|
205
|
+
/** Fires on any server-relevant state change (page, sort, filter). Provides full state snapshot for API calls. */
|
|
206
|
+
onServerStateChange?: (state: ServerState<TRow>) => void;
|
|
207
|
+
}
|
|
208
|
+
interface SelectionChangeEvent<TRow, TKey = TRow[keyof TRow] | number | string> {
|
|
209
|
+
action: 'select' | 'deselect';
|
|
210
|
+
selectedRowKeys: TKey[];
|
|
211
|
+
affectedRowKeys: TKey[];
|
|
212
|
+
isAllSelected: boolean;
|
|
213
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RovingFocusItemProps } from '../../react/a11y/useRovingFocus';
|
|
2
|
+
/**
|
|
3
|
+
* The grid's keyboard coordinates, shared with every cell. Rows are numbered as `aria-rowindex` is —
|
|
4
|
+
* headers, then the filter row, then the body — and a cell asks for its roving tabindex by that pair, so
|
|
5
|
+
* the numbering has to be one thing the whole grid agrees on rather than three local ones.
|
|
6
|
+
*/
|
|
7
|
+
export interface GridNavigation {
|
|
8
|
+
/** `aria-rowcount`: every row the grid has, not the window of them that is rendered. */
|
|
9
|
+
rowCount: number;
|
|
10
|
+
/** `aria-colcount`: the visible leaf columns. */
|
|
11
|
+
columnCount: number;
|
|
12
|
+
/** How many rows sit above the body — the offset from a body row's index to its row number. */
|
|
13
|
+
headerRowCount: number;
|
|
14
|
+
/** The roving tabindex and the ref for one cell, in the coordinates above. */
|
|
15
|
+
cellProps: (row: number, column: number) => RovingFocusItemProps;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Absent outside a DataGrid, and absent on purpose: `DataGridCell` is rendered by the grid and by
|
|
19
|
+
* nothing else, so a missing provider is a bug rather than a supported way to use the component.
|
|
20
|
+
*/
|
|
21
|
+
declare const GridNavigationContext: import('react').Context<GridNavigation | null>;
|
|
22
|
+
export default GridNavigationContext;
|
|
23
|
+
/** The grid navigation a cell belongs to. */
|
|
24
|
+
export declare function useGridNavigationContext(): GridNavigation | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as ColumnModel } from './columnModel';
|
|
2
|
+
import { default as GridModel } from './gridModel';
|
|
3
|
+
import { default as RowModel } from './rowModel';
|
|
4
|
+
export default class CellModel<TRow> {
|
|
5
|
+
readonly grid: GridModel<TRow>;
|
|
6
|
+
readonly row: RowModel<TRow>;
|
|
7
|
+
readonly column: ColumnModel<TRow>;
|
|
8
|
+
constructor(grid: GridModel<TRow>, row: RowModel<TRow>, column: ColumnModel<TRow>);
|
|
9
|
+
get value(): number | TRow[keyof TRow];
|
|
10
|
+
get isExpanded(): boolean;
|
|
11
|
+
get selected(): boolean;
|
|
12
|
+
get isFirst(): boolean;
|
|
13
|
+
get isLast(): boolean;
|
|
14
|
+
/** Toggle this row's detail panel (used by the row-detail expand cell). */
|
|
15
|
+
toggleDetail: () => void;
|
|
16
|
+
/** Toggle this row's selection (used by the row-selection checkbox cell). */
|
|
17
|
+
toggleSelection: () => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { ColumnFilterConfig, ColumnType, ContextMenuConfig, FilterValue, Key, NumberFilterValue, PinPosition, PinPositionInput, SortDirection } from '../contracts/dataGridContract';
|
|
2
|
+
import { default as GridModel } from './gridModel';
|
|
3
|
+
import { default as HeaderCellModel } from './headerCellModel';
|
|
4
|
+
/** Discriminates the structural role of a column — replaces scattered `key === *_CELL_KEY` checks. */
|
|
5
|
+
export type ColumnKind = 'data' | 'rowNumber' | 'rowSelection' | 'rowDetail' | 'grouping';
|
|
6
|
+
export default class ColumnModel<TRow> {
|
|
7
|
+
readonly def: ColumnType<TRow>;
|
|
8
|
+
readonly grid: GridModel<TRow>;
|
|
9
|
+
private parent?;
|
|
10
|
+
constructor(def: ColumnType<TRow>, grid: GridModel<TRow>, parent?: ColumnModel<TRow> | undefined);
|
|
11
|
+
columns: ColumnModel<TRow>[];
|
|
12
|
+
get kind(): ColumnKind;
|
|
13
|
+
get isRowNumber(): boolean;
|
|
14
|
+
get isRowSelection(): boolean;
|
|
15
|
+
get isRowDetail(): boolean;
|
|
16
|
+
get isGrouping(): boolean;
|
|
17
|
+
get isData(): boolean;
|
|
18
|
+
readonly pinFlags: import('../../../utils/memo').Memo<{
|
|
19
|
+
isStartPinned: boolean;
|
|
20
|
+
isEndPinned: boolean;
|
|
21
|
+
isPinned: boolean;
|
|
22
|
+
isFirstStartPinned: boolean;
|
|
23
|
+
isLastStartPinned: boolean;
|
|
24
|
+
isFirstEndPinned: boolean;
|
|
25
|
+
isLastEndPinned: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/** Variant flags for the body cell that depend only on the column (not the row). */
|
|
28
|
+
readonly cellVariant: import('../../../utils/memo').Memo<{
|
|
29
|
+
isPinned: boolean;
|
|
30
|
+
isFirstStartPinned: boolean;
|
|
31
|
+
isLastStartPinned: boolean;
|
|
32
|
+
isFirstEndPinned: boolean;
|
|
33
|
+
isLastEndPinned: boolean;
|
|
34
|
+
isRowSelection: boolean;
|
|
35
|
+
isRowNumber: boolean;
|
|
36
|
+
isFirstLeaf: boolean;
|
|
37
|
+
isLastLeaf: boolean;
|
|
38
|
+
isRowDetail: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
/** Static CSS-var references for the body/filter cell (stable string identity). */
|
|
41
|
+
readonly cellStyleVars: import('../../../utils/memo').Memo<{
|
|
42
|
+
width: string;
|
|
43
|
+
height: string;
|
|
44
|
+
insetInlineStart: string | undefined;
|
|
45
|
+
insetInlineEnd: string | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
/** Derived state for this column's header cell + context menu. */
|
|
48
|
+
private readonly _headerCell;
|
|
49
|
+
get headerCell(): HeaderCellModel<TRow>;
|
|
50
|
+
get visibleColumns(): ColumnModel<TRow>[];
|
|
51
|
+
get isFirstLeaf(): boolean;
|
|
52
|
+
get isLastLeaf(): boolean;
|
|
53
|
+
get key(): Key;
|
|
54
|
+
get header(): string | undefined;
|
|
55
|
+
get align(): "left" | "right" | "center" | "end" | "start" | undefined;
|
|
56
|
+
/** End-aligned either way it is spelled — `right` is the physical name of `end` in a left-to-right grid. */
|
|
57
|
+
get isEndAligned(): boolean;
|
|
58
|
+
/** Whether an explicit `align` was provided (mirrors the original `'align' in def` check). */
|
|
59
|
+
get hasAlign(): boolean;
|
|
60
|
+
get isLeaf(): boolean;
|
|
61
|
+
get Cell(): import('react').ComponentType<{
|
|
62
|
+
cell: import('./cellModel').default<TRow>;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
get filterable(): boolean | ColumnFilterConfig | undefined;
|
|
65
|
+
/** Resolved filter config, or undefined when this column isn't filterable. */
|
|
66
|
+
get filterConfig(): ColumnFilterConfig | undefined;
|
|
67
|
+
/** The active filter on this column, if any. */
|
|
68
|
+
get currentFilter(): FilterValue | undefined;
|
|
69
|
+
/** Options for a multiselect filter (config-provided, else unique values from data). */
|
|
70
|
+
get filterOptions(): {
|
|
71
|
+
label: string;
|
|
72
|
+
value: string | number | boolean | null;
|
|
73
|
+
}[];
|
|
74
|
+
setTextFilter(value: string): void;
|
|
75
|
+
setNumberFilter(operator: NumberFilterValue['operator'], value: string | number, valueTo?: string | number): void;
|
|
76
|
+
setMultiselectFilter(values: (string | number | boolean | null)[]): void;
|
|
77
|
+
clearFilter(): void;
|
|
78
|
+
/** Whether sorting is enabled for this column. Column-level setting takes priority over grid-level. */
|
|
79
|
+
get sortable(): boolean;
|
|
80
|
+
/** Whether resizing is enabled for this column. Column-level setting takes priority over grid-level. */
|
|
81
|
+
get resizable(): boolean;
|
|
82
|
+
/** Resolved context menu configuration. Column-level takes priority over grid-level. Default: true. */
|
|
83
|
+
get contextMenu(): boolean | ContextMenuConfig;
|
|
84
|
+
/** Whether the context menu button should be shown at all. */
|
|
85
|
+
get showContextMenu(): boolean;
|
|
86
|
+
/** Resolved context menu sections visibility. */
|
|
87
|
+
get contextMenuSections(): {
|
|
88
|
+
sort: boolean;
|
|
89
|
+
pin: boolean;
|
|
90
|
+
group: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Whether column participates in flex distribution. Default true unless explicitly false. */
|
|
93
|
+
get isFlexible(): boolean;
|
|
94
|
+
/** The base width before flex calculation (what user set or DEFAULT). */
|
|
95
|
+
get baseWidth(): number;
|
|
96
|
+
private _pin?;
|
|
97
|
+
get pin(): PinPosition | undefined;
|
|
98
|
+
get uniqueKey(): string;
|
|
99
|
+
getPinnedColumn(pin?: PinPosition): ColumnModel<TRow> | undefined;
|
|
100
|
+
private hasPin;
|
|
101
|
+
get death(): number;
|
|
102
|
+
get flatColumns(): ColumnModel<TRow>[];
|
|
103
|
+
private _inlineWidth?;
|
|
104
|
+
get inlineWidth(): number | undefined;
|
|
105
|
+
get startOffset(): number;
|
|
106
|
+
get endOffset(): number;
|
|
107
|
+
get isEdge(): boolean;
|
|
108
|
+
get isVisible(): boolean;
|
|
109
|
+
get leafs(): ColumnModel<TRow>[];
|
|
110
|
+
get groupColumnWidthVarName(): string;
|
|
111
|
+
get widthVarName(): string;
|
|
112
|
+
get inlineStartVarName(): string;
|
|
113
|
+
get inlineEndVarName(): string;
|
|
114
|
+
get gridRows(): number;
|
|
115
|
+
private _resizeStartX;
|
|
116
|
+
private _resizeSizes;
|
|
117
|
+
private _resizeTotalWidth;
|
|
118
|
+
/** Begin a resize drag from a pointer x-coordinate (page space). */
|
|
119
|
+
beginResize: (startX: number) => void;
|
|
120
|
+
/**
|
|
121
|
+
* A pointer moves in screen coordinates and a column grows along the inline axis, so turning one into
|
|
122
|
+
* the other takes both facts: which edge the separator sits on, and which way the reading runs. The two
|
|
123
|
+
* flips compose — an end-pinned column in a right-to-left grid resizes the way an unpinned one does.
|
|
124
|
+
*/
|
|
125
|
+
private get resizeSign();
|
|
126
|
+
/**
|
|
127
|
+
* Apply the drag to a new pointer x-coordinate, distributing the delta across leafs.
|
|
128
|
+
* Does NOT notify — the caller decides how to reflect the change (the React adapter
|
|
129
|
+
* writes the resulting width CSS variables straight to the DOM for a 60fps drag).
|
|
130
|
+
*/
|
|
131
|
+
applyResize: (currentX: number) => void;
|
|
132
|
+
/** Apply the drag and notify subscribers (headless API for non-DOM hosts). */
|
|
133
|
+
resizeTo: (currentX: number) => void;
|
|
134
|
+
/** End a resize drag. */
|
|
135
|
+
endResize: () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Move the resize separator `delta` pixels right — one step of a keyboard resize, from the widths as they
|
|
138
|
+
* are, so pressing again carries on. Rightwards widens a column whose separator is on its right edge and
|
|
139
|
+
* narrows a right-pinned one, as dragging does. Does **not** notify: a held arrow repeats thirty times a
|
|
140
|
+
* second, so the caller paints the widths and calls `endResize()` when the gesture ends.
|
|
141
|
+
*/
|
|
142
|
+
moveResizer: (delta: number) => void;
|
|
143
|
+
/** Resize to an exact total width — where Home and End on the separator land. Does not notify. */
|
|
144
|
+
resizeWidthTo: (width: number) => void;
|
|
145
|
+
pinColumn: (pin?: PinPositionInput) => void;
|
|
146
|
+
toggleGrouping: () => void;
|
|
147
|
+
sortColumn: (sortDirection?: SortDirection) => void;
|
|
148
|
+
setWidth: (width: number) => void;
|
|
149
|
+
toggleVisibility: () => void;
|
|
150
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as ColumnModel } from './columnModel';
|
|
2
|
+
import { default as GridModel } from './gridModel';
|
|
3
|
+
export interface ColumnVisibilityEntry<TRow> {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
column: ColumnModel<TRow>;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Backs the top-bar column-visibility menu: the toggleable (user data) columns, which
|
|
11
|
+
* are currently shown, and a diff-based bulk setter.
|
|
12
|
+
*/
|
|
13
|
+
export default class ColumnVisibilityModel<TRow> {
|
|
14
|
+
readonly grid: GridModel<TRow>;
|
|
15
|
+
constructor(grid: GridModel<TRow>);
|
|
16
|
+
/** All user data leafs (visible and hidden) — excludes row-number/selection/detail/grouping. */
|
|
17
|
+
get entries(): ColumnVisibilityEntry<TRow>[];
|
|
18
|
+
get selectedIds(): string[];
|
|
19
|
+
get total(): number;
|
|
20
|
+
get hiddenCount(): number;
|
|
21
|
+
get hasHidden(): boolean;
|
|
22
|
+
/** Make exactly the columns in `ids` visible, toggling only those whose state must change. */
|
|
23
|
+
setVisibility: (ids: string[]) => void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Key } from '../contracts/dataGridContract';
|
|
2
|
+
import { default as GridModel } from './gridModel';
|
|
3
|
+
import { default as RowModel } from './rowModel';
|
|
4
|
+
export default class DetailRowModel<TRow> {
|
|
5
|
+
readonly grid: GridModel<TRow>;
|
|
6
|
+
readonly parentRow: RowModel<TRow>;
|
|
7
|
+
constructor(grid: GridModel<TRow>, parentRow: RowModel<TRow>);
|
|
8
|
+
readonly kind: "detail";
|
|
9
|
+
get key(): Key;
|
|
10
|
+
get isAutoHeight(): boolean;
|
|
11
|
+
static readonly AUTO_HEIGHT_ESTIMATE = 200;
|
|
12
|
+
get height(): 'auto' | number;
|
|
13
|
+
/** Numeric height for virtualization offset calculations. Uses estimate for 'auto'. */
|
|
14
|
+
get heightForOffset(): number;
|
|
15
|
+
readonly count = 0;
|
|
16
|
+
/** One cell, spanning every column — the width the grid navigation sees for this row. */
|
|
17
|
+
readonly cellCount = 1;
|
|
18
|
+
/** That one cell starts at the first column and covers the rest of them. */
|
|
19
|
+
columnOf(): number;
|
|
20
|
+
get flatRows(): this[];
|
|
21
|
+
get allRows(): RowModel<TRow>[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ColumnFilters } from '../contracts/dataGridContract';
|
|
2
|
+
import { default as GridModel } from './gridModel';
|
|
3
|
+
/**
|
|
4
|
+
* Filtering concern: grid-level filter state + the derived flags the UI needs. Per-column
|
|
5
|
+
* filter config/value/parse helpers live on ColumnModel; the coupled mutations (page-reset,
|
|
6
|
+
* server-state events, filteredData) live on GridModel.
|
|
7
|
+
*/
|
|
8
|
+
export default class FilterModel<TRow> {
|
|
9
|
+
readonly grid: GridModel<TRow>;
|
|
10
|
+
constructor(grid: GridModel<TRow>);
|
|
11
|
+
get globalFilterValue(): string;
|
|
12
|
+
get columnFilters(): ColumnFilters<TRow>;
|
|
13
|
+
get hasActiveFilters(): boolean;
|
|
14
|
+
get filterStats(): {
|
|
15
|
+
filtered: number;
|
|
16
|
+
total: number;
|
|
17
|
+
};
|
|
18
|
+
/** Whether any visible column is filterable (controls the filter row's visibility). */
|
|
19
|
+
get hasFilterableColumns(): boolean;
|
|
20
|
+
setGlobalFilter: (value: string) => void;
|
|
21
|
+
clearAllFilters: () => void;
|
|
22
|
+
}
|