@gridkitjs/core 0.0.0-dev-20261107202111 → 0.0.0-dev-20261107203826
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/index.d.ts +32 -2
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1374,6 +1374,15 @@ interface ToolbarCustomEntry {
|
|
|
1374
1374
|
* dropdown of the export commands that show; and a custom entry.
|
|
1375
1375
|
*/
|
|
1376
1376
|
type ToolbarEntry<Row> = MenuEntry<Row> | "search" | "spacer" | "export" | ToolbarCustomEntry;
|
|
1377
|
+
/**
|
|
1378
|
+
* Attributes of the app's own for a toolbar entry's element, as hooks for
|
|
1379
|
+
* its tests, analytics or styles: an `id` and `data-*` attributes, nothing
|
|
1380
|
+
* that could change what the entry means or does.
|
|
1381
|
+
*/
|
|
1382
|
+
interface ToolbarItemAttributes {
|
|
1383
|
+
readonly id?: string | undefined;
|
|
1384
|
+
readonly [name: `data-${string}`]: string;
|
|
1385
|
+
}
|
|
1377
1386
|
/**
|
|
1378
1387
|
* A toolbar button ready to draw — a command, or an inline item — with
|
|
1379
1388
|
* every label a string, every flag a boolean, and `run` bound to the
|
|
@@ -1397,6 +1406,8 @@ interface ResolvedToolbarButton {
|
|
|
1397
1406
|
readonly pressed: boolean | undefined;
|
|
1398
1407
|
/** Runs the button, and says whether it ran — see `ResolvedMenuItem.run`. */
|
|
1399
1408
|
readonly run: () => boolean;
|
|
1409
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1410
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1400
1411
|
}
|
|
1401
1412
|
/** A dropdown button, opening the menu its submenu entry lists. */
|
|
1402
1413
|
interface ResolvedToolbarMenu {
|
|
@@ -1408,12 +1419,16 @@ interface ResolvedToolbarMenu {
|
|
|
1408
1419
|
readonly icon?: string | undefined;
|
|
1409
1420
|
/** Never empty: a dropdown with nothing to show is left out. */
|
|
1410
1421
|
readonly items: readonly ResolvedMenuEntry[];
|
|
1422
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1423
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1411
1424
|
}
|
|
1412
1425
|
/** The search box, over the grid's global text filter. */
|
|
1413
1426
|
interface ResolvedToolbarSearch {
|
|
1414
1427
|
readonly type: "search";
|
|
1415
1428
|
/** Always `"search"`. */
|
|
1416
1429
|
readonly key: string;
|
|
1430
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1431
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1417
1432
|
}
|
|
1418
1433
|
/** The free space between the entries either side of it. */
|
|
1419
1434
|
interface ResolvedToolbarSpacer {
|
|
@@ -1427,6 +1442,8 @@ interface ResolvedToolbarCustom {
|
|
|
1427
1442
|
readonly id: string;
|
|
1428
1443
|
/** The same as `id`. */
|
|
1429
1444
|
readonly key: string;
|
|
1445
|
+
/** The app's attributes for its element, from `itemAttributes`. */
|
|
1446
|
+
readonly attributes?: ToolbarItemAttributes | undefined;
|
|
1430
1447
|
}
|
|
1431
1448
|
/**
|
|
1432
1449
|
* One entry of a toolbar as `resolveToolbar` hands it to a renderer to draw.
|
|
@@ -1436,12 +1453,21 @@ interface ResolvedToolbarCustom {
|
|
|
1436
1453
|
*/
|
|
1437
1454
|
type ResolvedToolbarItem = ResolvedToolbarButton | ResolvedToolbarMenu | ResolvedToolbarSearch | ResolvedToolbarSpacer | ResolvedMenuSeparator | ResolvedToolbarCustom;
|
|
1438
1455
|
|
|
1439
|
-
/**
|
|
1456
|
+
/**
|
|
1457
|
+
* A grid's toolbar: what it lists, what a screen reader calls it, and the
|
|
1458
|
+
* attributes of the app's own its entries' elements carry.
|
|
1459
|
+
*/
|
|
1440
1460
|
interface GridToolbarOptions<Row> {
|
|
1441
1461
|
/** The toolbar's entries, in order. Left out, the defaults. */
|
|
1442
1462
|
readonly items?: readonly ToolbarEntry<Row>[] | undefined;
|
|
1443
1463
|
/** The toolbar's accessible name. Left out, `messages.toolbarLabel`. */
|
|
1444
1464
|
readonly label?: string | undefined;
|
|
1465
|
+
/**
|
|
1466
|
+
* Attributes for entries' elements, by the entry's key: a command's,
|
|
1467
|
+
* inline item's, dropdown's or custom entry's id, `"search"` or
|
|
1468
|
+
* `"export"`. A key naming no entry, or a separator or spacer, is ignored.
|
|
1469
|
+
*/
|
|
1470
|
+
readonly itemAttributes?: Readonly<Record<string, ToolbarItemAttributes>> | undefined;
|
|
1445
1471
|
}
|
|
1446
1472
|
/**
|
|
1447
1473
|
* What a toolbar lists unless the grid says otherwise: the search box, then
|
|
@@ -3035,6 +3061,8 @@ interface ToolbarResolveOptions<Row> {
|
|
|
3035
3061
|
* opens a panel anchors it there.
|
|
3036
3062
|
*/
|
|
3037
3063
|
readonly contextFor: (target: GridToolbarTarget) => GridCommandContext<Row>;
|
|
3064
|
+
/** Attributes for entries' elements, by key — see `GridToolbarOptions`. */
|
|
3065
|
+
readonly itemAttributes?: Readonly<Record<string, ToolbarItemAttributes>> | undefined;
|
|
3038
3066
|
}
|
|
3039
3067
|
/**
|
|
3040
3068
|
* A toolbar's entries resolved against the grid, ready to draw, by the
|
|
@@ -3050,6 +3078,8 @@ interface ToolbarResolveOptions<Row> {
|
|
|
3050
3078
|
* - `"search"`, `"spacer"` and custom entries stay as they are.
|
|
3051
3079
|
* - Separators never lead, trail, double up or sit next to a spacer, which
|
|
3052
3080
|
* already parts what is on either side of it.
|
|
3081
|
+
* - A button, dropdown, search box or custom entry whose key
|
|
3082
|
+
* `itemAttributes` names carries those `attributes`.
|
|
3053
3083
|
*
|
|
3054
3084
|
* Resolve again whenever the grid changes, so each button's label, flags
|
|
3055
3085
|
* and `run` follow its state.
|
|
@@ -4259,4 +4289,4 @@ declare const excelFilter: {
|
|
|
4259
4289
|
};
|
|
4260
4290
|
};
|
|
4261
4291
|
|
|
4262
|
-
export { type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
|
4292
|
+
export { type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, HEADER_ROW, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarItemAttributes, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toCsv, toHtmlTable, toJson, toTsv, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
package/dist/index.js
CHANGED
|
@@ -4206,7 +4206,14 @@ function exportMenu() {
|
|
|
4206
4206
|
};
|
|
4207
4207
|
}
|
|
4208
4208
|
function resolveToolbar(entries, options) {
|
|
4209
|
-
const { commands, contextFor } = options;
|
|
4209
|
+
const { commands, contextFor, itemAttributes } = options;
|
|
4210
|
+
function withAttributes(item) {
|
|
4211
|
+
if (item.type === "separator" || item.type === "spacer" || itemAttributes === void 0 || !Object.hasOwn(itemAttributes, item.key)) {
|
|
4212
|
+
return item;
|
|
4213
|
+
}
|
|
4214
|
+
const attributes = itemAttributes[item.key];
|
|
4215
|
+
return attributes === void 0 ? item : { ...item, attributes };
|
|
4216
|
+
}
|
|
4210
4217
|
function resolveEntry(entry, index) {
|
|
4211
4218
|
if (entry === "search") {
|
|
4212
4219
|
return { type: "search", key: "search" };
|
|
@@ -4238,7 +4245,7 @@ function resolveToolbar(entries, options) {
|
|
|
4238
4245
|
return { ...item, type: "button", key: item.id, pressed: checked };
|
|
4239
4246
|
}
|
|
4240
4247
|
return collapseSeparators(
|
|
4241
|
-
entries.map(resolveEntry).filter((entry) => entry !== null),
|
|
4248
|
+
entries.map(resolveEntry).filter((entry) => entry !== null).map(withAttributes),
|
|
4242
4249
|
isSpacer
|
|
4243
4250
|
);
|
|
4244
4251
|
}
|