@gridkitjs/core 0.13.0 → 0.14.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/dist/index.d.ts +81 -62
- package/dist/index.js +180 -144
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -289,6 +289,56 @@ declare function parseFilterOperand(text: string, type: ColumnType | undefined):
|
|
|
289
289
|
*/
|
|
290
290
|
declare function formatFilterOperand(value: FilterScalar | undefined, type: ColumnType | undefined): string;
|
|
291
291
|
|
|
292
|
+
/** The locale(s) values are formatted for — `undefined` is the runtime's own. */
|
|
293
|
+
type FormatLocale = string | readonly string[] | undefined;
|
|
294
|
+
/**
|
|
295
|
+
* The text a value reads as in `column` — what a cell shows when the column
|
|
296
|
+
* has no `cellTemplate`, and what an export or a print writes, so the two
|
|
297
|
+
* cannot disagree.
|
|
298
|
+
*
|
|
299
|
+
* A `valueFormatter` decides outright. `null`/`undefined` read `""`, a
|
|
300
|
+
* boolean `"true"`/`"false"` — or `messages.booleanTrue`/`booleanFalse`
|
|
301
|
+
* when given, for a grid speaking another language — a string as it is, a
|
|
302
|
+
* plain object or array as JSON.
|
|
303
|
+
*
|
|
304
|
+
* Dates and numbers are formatted through `Intl` only once asked to — the
|
|
305
|
+
* column has a `format`, or a `locale` is given. Until then they print as a
|
|
306
|
+
* grid always printed them, so adopting this changes nothing on screen: a
|
|
307
|
+
* `Date` through `toLocaleString()`, a number as-is (`1234.5`, never
|
|
308
|
+
* `1,234.5`). Once asked:
|
|
309
|
+
*
|
|
310
|
+
* - A `Date` → `Intl.DateTimeFormat`: the date alone under `"date"`, the time
|
|
311
|
+
* alone under `"time"`, both otherwise.
|
|
312
|
+
* - A number under a numeric `type` → `Intl.NumberFormat`: `"currency"` with
|
|
313
|
+
* a currency symbol once `format.currency` names one (two fraction digits
|
|
314
|
+
* until then), `"percent"` reading `0.25` as 25 %. Under any other type it
|
|
315
|
+
* is still printed as-is, the way a number id should be.
|
|
316
|
+
*
|
|
317
|
+
* `format` and `locale` go to the `Intl` constructor unchanged, so any
|
|
318
|
+
* option it accepts is honoured.
|
|
319
|
+
*/
|
|
320
|
+
declare function formatCellValue<Row>(value: unknown, column: ColumnDefinition<Row, unknown>, locale?: FormatLocale, row?: Row, messages?: Pick<GridMessages, "booleanTrue" | "booleanFalse">): string;
|
|
321
|
+
/**
|
|
322
|
+
* The text an aggregate result reads as — a footer cell, a group's subtotal
|
|
323
|
+
* — through `formatCellValue`, so once a `format` or `locale` asks for it a
|
|
324
|
+
* `sum` of a currency column reads as currency and a `max` of a date column
|
|
325
|
+
* as a date. `column` is `undefined` for a spec naming a column the grid
|
|
326
|
+
* does not have, which then formats by its value alone.
|
|
327
|
+
*
|
|
328
|
+
* Until then a numeric result reads through `toLocaleString()`, with digit
|
|
329
|
+
* grouping, where a cell prints its number as-is: that is how a grid has
|
|
330
|
+
* always shown its totals, and a sum easily runs into the thousands.
|
|
331
|
+
*/
|
|
332
|
+
declare function formatAggregateValue<Row>(value: unknown, spec: AggregateSpec<Row>, column: ColumnDefinition<Row, unknown> | undefined, locale?: FormatLocale): string;
|
|
333
|
+
/**
|
|
334
|
+
* The text a group's own value reads as — a group header's name, and the
|
|
335
|
+
* label an export writes for it: as the grouped column's cells read it,
|
|
336
|
+
* except that a missing value reads `messages.blankGroupValue` ("(blank)"),
|
|
337
|
+
* since an empty label would leave the group looking unnamed rather than
|
|
338
|
+
* named "nothing".
|
|
339
|
+
*/
|
|
340
|
+
declare function formatGroupValue<Row>(value: unknown, column: ColumnDefinition<Row, unknown>, locale: FormatLocale, messages: Pick<GridMessages, "booleanTrue" | "booleanFalse" | "blankGroupValue">): string;
|
|
341
|
+
|
|
292
342
|
/**
|
|
293
343
|
* Every string a grid shows or announces of its own — the pager, the group-by
|
|
294
344
|
* bar, the loading row, the text of a boolean or missing value, the labels of
|
|
@@ -301,13 +351,20 @@ declare function formatFilterOperand(value: FilterScalar | undefined, type: Colu
|
|
|
301
351
|
*
|
|
302
352
|
* Text the data supplies (cells, headers, labels) is not here: it is already
|
|
303
353
|
* the app's to choose. Nor is formatting — dates and numbers follow
|
|
304
|
-
* `locale
|
|
354
|
+
* `locale`, and so do the counts the defaults print: "1,204 of 10,000 rows"
|
|
355
|
+
* under `"en"`, "1.204 of 10.000 rows" under `"de-DE"`.
|
|
305
356
|
*/
|
|
306
357
|
interface GridMessages {
|
|
307
358
|
/** The pager's accessible name. */
|
|
308
359
|
pagerLabel: string;
|
|
360
|
+
/** The pager button to the first page; drawn as an icon, so this is its accessible name. */
|
|
361
|
+
firstPage: string;
|
|
362
|
+
/** The pager button to the previous page; its accessible name. */
|
|
309
363
|
previousPage: string;
|
|
364
|
+
/** The pager button to the next page; its accessible name. */
|
|
310
365
|
nextPage: string;
|
|
366
|
+
/** The pager button to the last page; its accessible name. */
|
|
367
|
+
lastPage: string;
|
|
311
368
|
/** The page-size control's label. */
|
|
312
369
|
pageSizeLabel: string;
|
|
313
370
|
/** A numbered pager button's accessible name. */
|
|
@@ -524,64 +581,22 @@ interface GridMessages {
|
|
|
524
581
|
/** `print` */
|
|
525
582
|
print: string;
|
|
526
583
|
}
|
|
527
|
-
/** The grid's own English, which `messages` replaces key by key. */
|
|
528
|
-
declare const defaultMessages: GridMessages;
|
|
529
584
|
/**
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
585
|
+
* The grid's own English, its counts printed in `locale`'s digits —
|
|
586
|
+
* "1,204 of 10,000 rows" under `"en"`, "1.204 of 10.000 rows" under
|
|
587
|
+
* `"de-DE"`. Without a locale, the runtime's own; that one is
|
|
588
|
+
* `defaultMessages`.
|
|
533
589
|
*/
|
|
534
|
-
declare function
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
type FormatLocale = string | readonly string[] | undefined;
|
|
538
|
-
/**
|
|
539
|
-
* The text a value reads as in `column` — what a cell shows when the column
|
|
540
|
-
* has no `cellTemplate`, and what an export or a print writes, so the two
|
|
541
|
-
* cannot disagree.
|
|
542
|
-
*
|
|
543
|
-
* A `valueFormatter` decides outright. `null`/`undefined` read `""`, a
|
|
544
|
-
* boolean `"true"`/`"false"` — or `messages.booleanTrue`/`booleanFalse`
|
|
545
|
-
* when given, for a grid speaking another language — a string as it is, a
|
|
546
|
-
* plain object or array as JSON.
|
|
547
|
-
*
|
|
548
|
-
* Dates and numbers are formatted through `Intl` only once asked to — the
|
|
549
|
-
* column has a `format`, or a `locale` is given. Until then they print as a
|
|
550
|
-
* grid always printed them, so adopting this changes nothing on screen: a
|
|
551
|
-
* `Date` through `toLocaleString()`, a number as-is (`1234.5`, never
|
|
552
|
-
* `1,234.5`). Once asked:
|
|
553
|
-
*
|
|
554
|
-
* - A `Date` → `Intl.DateTimeFormat`: the date alone under `"date"`, the time
|
|
555
|
-
* alone under `"time"`, both otherwise.
|
|
556
|
-
* - A number under a numeric `type` → `Intl.NumberFormat`: `"currency"` with
|
|
557
|
-
* a currency symbol once `format.currency` names one (two fraction digits
|
|
558
|
-
* until then), `"percent"` reading `0.25` as 25 %. Under any other type it
|
|
559
|
-
* is still printed as-is, the way a number id should be.
|
|
560
|
-
*
|
|
561
|
-
* `format` and `locale` go to the `Intl` constructor unchanged, so any
|
|
562
|
-
* option it accepts is honoured.
|
|
563
|
-
*/
|
|
564
|
-
declare function formatCellValue<Row>(value: unknown, column: ColumnDefinition<Row, unknown>, locale?: FormatLocale, row?: Row, messages?: Pick<GridMessages, "booleanTrue" | "booleanFalse">): string;
|
|
565
|
-
/**
|
|
566
|
-
* The text an aggregate result reads as — a footer cell, a group's subtotal
|
|
567
|
-
* — through `formatCellValue`, so once a `format` or `locale` asks for it a
|
|
568
|
-
* `sum` of a currency column reads as currency and a `max` of a date column
|
|
569
|
-
* as a date. `column` is `undefined` for a spec naming a column the grid
|
|
570
|
-
* does not have, which then formats by its value alone.
|
|
571
|
-
*
|
|
572
|
-
* Until then a numeric result reads through `toLocaleString()`, with digit
|
|
573
|
-
* grouping, where a cell prints its number as-is: that is how a grid has
|
|
574
|
-
* always shown its totals, and a sum easily runs into the thousands.
|
|
575
|
-
*/
|
|
576
|
-
declare function formatAggregateValue<Row>(value: unknown, spec: AggregateSpec<Row>, column: ColumnDefinition<Row, unknown> | undefined, locale?: FormatLocale): string;
|
|
590
|
+
declare function createDefaultMessages(locale?: FormatLocale): GridMessages;
|
|
591
|
+
/** The grid's own English, which `messages` replaces key by key. */
|
|
592
|
+
declare const defaultMessages: GridMessages;
|
|
577
593
|
/**
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* named "nothing".
|
|
594
|
+
* `messages` over the defaults for `locale` — every key the grid needs,
|
|
595
|
+
* whichever the caller gave, the defaults counting in `locale`'s digits. The
|
|
596
|
+
* defaults themselves, same object for the same locale, when it gave none, so
|
|
597
|
+
* a renderer memoising on the result does not see a change that is not one.
|
|
583
598
|
*/
|
|
584
|
-
declare function
|
|
599
|
+
declare function resolveMessages(messages: Partial<GridMessages> | undefined, locale?: FormatLocale): GridMessages;
|
|
585
600
|
|
|
586
601
|
/**
|
|
587
602
|
* A value an export stores as it is rather than as text — what a cell's
|
|
@@ -3634,12 +3649,16 @@ declare function paginateRows<Row>(rows: readonly DisplayRow<Row>[], pagination:
|
|
|
3634
3649
|
type PaginationWindowEntry = number | "ellipsis";
|
|
3635
3650
|
/**
|
|
3636
3651
|
* Which page numbers a numbered pager should show for `currentPage` of
|
|
3637
|
-
* `pageCount
|
|
3638
|
-
*
|
|
3639
|
-
* `
|
|
3640
|
-
*
|
|
3641
|
-
*
|
|
3642
|
-
*
|
|
3652
|
+
* `pageCount` — the boundary + sibling windowing MUI's `usePagination` uses.
|
|
3653
|
+
* Always includes the first/last `boundaryCount` pages and a run of
|
|
3654
|
+
* `2 * siblingCount + 1` pages around `currentPage`, slid inwards rather than
|
|
3655
|
+
* cut short near either end, with one slot between each boundary and that
|
|
3656
|
+
* run holding either the single page it skips or an `"ellipsis"`.
|
|
3657
|
+
*
|
|
3658
|
+
* So once `pageCount` exceeds `2 * boundaryCount + 2 * siblingCount + 3`,
|
|
3659
|
+
* every window is exactly that many entries long, wherever `currentPage`
|
|
3660
|
+
* sits: a pager drawing one fixed-width slot per entry keeps its trailing
|
|
3661
|
+
* controls in place as the user pages through. Below that, every page shows.
|
|
3643
3662
|
*/
|
|
3644
3663
|
declare function paginationWindow(currentPage: number, pageCount: number, options?: {
|
|
3645
3664
|
boundaryCount?: number | undefined;
|
|
@@ -4205,4 +4224,4 @@ declare const excelFilter: {
|
|
|
4205
4224
|
};
|
|
4206
4225
|
};
|
|
4207
4226
|
|
|
4208
|
-
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 PaginatedRows, type PaginationChangeEvent, type PaginationState, 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, 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 };
|
|
4227
|
+
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 PaginatedRows, type PaginationChangeEvent, type PaginationState, 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 };
|
package/dist/index.js
CHANGED
|
@@ -3030,21 +3030,37 @@ function resolveColumnFilterMenu(options, column) {
|
|
|
3030
3030
|
}
|
|
3031
3031
|
|
|
3032
3032
|
// src/messages.ts
|
|
3033
|
-
function
|
|
3034
|
-
return
|
|
3033
|
+
function localeKey2(locale) {
|
|
3034
|
+
return typeof locale === "string" ? locale : locale?.join(",") ?? "";
|
|
3035
|
+
}
|
|
3036
|
+
var countFormats = /* @__PURE__ */ new Map();
|
|
3037
|
+
function countFormat(locale) {
|
|
3038
|
+
const key = localeKey2(locale);
|
|
3039
|
+
let format = countFormats.get(key);
|
|
3040
|
+
if (format === void 0) {
|
|
3041
|
+
const numberFormat = new Intl.NumberFormat(locale, {
|
|
3042
|
+
maximumFractionDigits: 0
|
|
3043
|
+
});
|
|
3044
|
+
format = (count) => numberFormat.format(count);
|
|
3045
|
+
countFormats.set(key, format);
|
|
3046
|
+
}
|
|
3047
|
+
return format;
|
|
3048
|
+
}
|
|
3049
|
+
function columnCount(n, count, change) {
|
|
3050
|
+
return count === 1 ? `1 column ${change}` : `${n(count)} columns ${change}`;
|
|
3035
3051
|
}
|
|
3036
|
-
function searchResults(count) {
|
|
3052
|
+
function searchResults(n, count) {
|
|
3037
3053
|
if (count === 0) {
|
|
3038
3054
|
return "No rows found";
|
|
3039
3055
|
}
|
|
3040
|
-
return count === 1 ? "1 row found" : `${
|
|
3056
|
+
return count === 1 ? "1 row found" : `${n(count)} rows found`;
|
|
3041
3057
|
}
|
|
3042
|
-
function selectedCount(count, target) {
|
|
3058
|
+
function selectedCount(n, count, target) {
|
|
3043
3059
|
const noun = target === "rows" ? "row" : "column";
|
|
3044
3060
|
if (count === 0) {
|
|
3045
3061
|
return `No ${noun}s selected`;
|
|
3046
3062
|
}
|
|
3047
|
-
return count === 1 ? `1 ${noun} selected` : `${
|
|
3063
|
+
return count === 1 ? `1 ${noun} selected` : `${n(count)} ${noun}s selected`;
|
|
3048
3064
|
}
|
|
3049
3065
|
var operatorLabels = {
|
|
3050
3066
|
eq: "Equals",
|
|
@@ -3071,11 +3087,11 @@ var dateOperatorLabels = {
|
|
|
3071
3087
|
function filterOperatorLabel(operator, family) {
|
|
3072
3088
|
return (family === "date" ? dateOperatorLabels[operator] : void 0) ?? operatorLabels[operator];
|
|
3073
3089
|
}
|
|
3074
|
-
function filterSearchFirst(total) {
|
|
3075
|
-
return total === 1 ? "Type to search 1 value" : `Type to search ${
|
|
3090
|
+
function filterSearchFirst(n, total) {
|
|
3091
|
+
return total === 1 ? "Type to search 1 value" : `Type to search ${n(total)} values`;
|
|
3076
3092
|
}
|
|
3077
|
-
function filterResults(shown, total) {
|
|
3078
|
-
return `${
|
|
3093
|
+
function filterResults(n, shown, total) {
|
|
3094
|
+
return `${n(shown)} of ${n(total)} ${total === 1 ? "row" : "rows"}`;
|
|
3079
3095
|
}
|
|
3080
3096
|
var filterValueRequests = {
|
|
3081
3097
|
text: "Enter a value",
|
|
@@ -3089,117 +3105,137 @@ var filterOperatorMenus = {
|
|
|
3089
3105
|
date: "Date filters",
|
|
3090
3106
|
boolean: "Boolean filters"
|
|
3091
3107
|
};
|
|
3092
|
-
function copied(count, unit) {
|
|
3093
|
-
return count === 1 ? `1 ${unit.slice(0, -1)} copied` : `${
|
|
3094
|
-
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3108
|
+
function copied(n, count, unit) {
|
|
3109
|
+
return count === 1 ? `1 ${unit.slice(0, -1)} copied` : `${n(count)} ${unit} copied`;
|
|
3110
|
+
}
|
|
3111
|
+
function createDefaultMessages(locale) {
|
|
3112
|
+
const n = countFormat(locale);
|
|
3113
|
+
return {
|
|
3114
|
+
pagerLabel: "Pagination",
|
|
3115
|
+
firstPage: "First",
|
|
3116
|
+
previousPage: "Previous",
|
|
3117
|
+
nextPage: "Next",
|
|
3118
|
+
lastPage: "Last",
|
|
3119
|
+
pageSizeLabel: "Rows per page",
|
|
3120
|
+
pageButtonLabel: (page) => `Page ${n(page)}`,
|
|
3121
|
+
pageStatus: (page, pageCount) => `Page ${n(page)} of ${n(pageCount)}`,
|
|
3122
|
+
loadingMore: "Loading more\u2026",
|
|
3123
|
+
booleanTrue: "true",
|
|
3124
|
+
booleanFalse: "false",
|
|
3125
|
+
blankGroupValue: "(blank)",
|
|
3126
|
+
groupByBarLabel: "Grouped by",
|
|
3127
|
+
groupByBarPlaceholder: "Drag a column here to group by it",
|
|
3128
|
+
groupByChipLabel: (columnName2, level, levelCount) => levelCount > 1 ? `${columnName2}, level ${n(level)} of ${n(levelCount)}` : columnName2,
|
|
3129
|
+
removeGroupBy: (columnName2) => `Stop grouping by ${columnName2}`,
|
|
3130
|
+
columnResized: (columnName2, width) => `${columnName2}, ${n(width)} pixels wide`,
|
|
3131
|
+
columnMoved: (columnName2, position, columnCount2) => `${columnName2}, column ${n(position)} of ${n(columnCount2)}`,
|
|
3132
|
+
columnSorted: (columnName2, direction, key, keyCount) => {
|
|
3133
|
+
const sorted = `${columnName2} sorted ${direction === "asc" ? "ascending" : "descending"}`;
|
|
3134
|
+
return keyCount > 1 ? `${sorted}, key ${n(key)} of ${n(keyCount)}` : sorted;
|
|
3135
|
+
},
|
|
3136
|
+
sortCleared: (columnName2) => `${columnName2}, sort cleared`,
|
|
3137
|
+
groupedBy: (columnName2, level, levelCount) => levelCount > 1 ? `Grouped by ${columnName2}, level ${n(level)} of ${n(levelCount)}` : `Grouped by ${columnName2}`,
|
|
3138
|
+
groupingRemoved: (columnName2) => `${columnName2}, grouping removed`,
|
|
3139
|
+
groupExpanded: "Group expanded",
|
|
3140
|
+
groupCollapsed: "Group collapsed",
|
|
3141
|
+
allGroupsExpanded: "All groups expanded",
|
|
3142
|
+
allGroupsCollapsed: "All groups collapsed",
|
|
3143
|
+
selectedCount: (count, target) => selectedCount(n, count, target),
|
|
3144
|
+
cellSelected: (columnName2, rowNumber) => `${columnName2}, row ${n(rowNumber)}, selected`,
|
|
3145
|
+
columnHidden: (columnName2) => `${columnName2}, column hidden`,
|
|
3146
|
+
columnShown: (columnName2) => `${columnName2}, column shown`,
|
|
3147
|
+
columnsHidden: (count) => columnCount(n, count, "hidden"),
|
|
3148
|
+
columnsShown: (count) => columnCount(n, count, "shown"),
|
|
3149
|
+
columnsAutoFitted: (count) => columnCount(n, count, "autofitted"),
|
|
3150
|
+
headerMenuLabel: (columnName2) => `${columnName2} column menu`,
|
|
3151
|
+
cellMenuLabel: "Row menu",
|
|
3152
|
+
groupMenuLabel: "Group menu",
|
|
3153
|
+
bodyMenuLabel: "Grid menu",
|
|
3154
|
+
sortAscending: "Sort ascending",
|
|
3155
|
+
sortDescending: "Sort descending",
|
|
3156
|
+
clearSort: "Clear sort",
|
|
3157
|
+
clearAllSorting: "Clear all sorting",
|
|
3158
|
+
groupByColumn: (columnName2) => `Group by ${columnName2}`,
|
|
3159
|
+
ungroupAll: "Ungroup all",
|
|
3160
|
+
expandAllGroups: "Expand all groups",
|
|
3161
|
+
collapseAllGroups: "Collapse all groups",
|
|
3162
|
+
hideColumn: "Hide column",
|
|
3163
|
+
autoFitColumn: "Autofit column",
|
|
3164
|
+
autoFitAllColumns: "Autofit all columns",
|
|
3165
|
+
selectAllRows: "Select all rows",
|
|
3166
|
+
clearSelection: "Clear selection",
|
|
3167
|
+
clearFilters: "Clear filters",
|
|
3168
|
+
chooseColumns: "Choose columns",
|
|
3169
|
+
toolbarLabel: "Grid toolbar",
|
|
3170
|
+
searchLabel: "Search",
|
|
3171
|
+
searchPlaceholder: "Search\u2026",
|
|
3172
|
+
moreToolbarItems: "More",
|
|
3173
|
+
searchResults: (count) => searchResults(n, count),
|
|
3174
|
+
columnChooserLabel: "Columns",
|
|
3175
|
+
columnChooserSearchLabel: "Search columns",
|
|
3176
|
+
showAllColumns: "Show all",
|
|
3177
|
+
noMatchingColumns: "No matching columns",
|
|
3178
|
+
filterOperatorLabel,
|
|
3179
|
+
filterBlanks: "(Blanks)",
|
|
3180
|
+
filterSearchFirst: (total) => filterSearchFirst(n, total),
|
|
3181
|
+
filterMoreValues: (count) => `${n(count)} more, refine the search`,
|
|
3182
|
+
openFilter: "Filter\u2026",
|
|
3183
|
+
clearColumnFilter: "Clear filter",
|
|
3184
|
+
filterMenuLabel: (columnName2) => `${columnName2} filter`,
|
|
3185
|
+
columnFiltered: "Filtered",
|
|
3186
|
+
applyFilter: "OK",
|
|
3187
|
+
cancelFilter: "Cancel",
|
|
3188
|
+
customFilter: "Custom filter",
|
|
3189
|
+
filterResults: (shown, total) => filterResults(n, shown, total),
|
|
3190
|
+
filterConditionLabel: (position) => `Condition ${n(position)}`,
|
|
3191
|
+
filterOperatorFieldLabel: "Operator",
|
|
3192
|
+
filterValueLabel: "Value",
|
|
3193
|
+
filterFromLabel: "From",
|
|
3194
|
+
filterToLabel: "To",
|
|
3195
|
+
filterCombinatorLabel: "Combine conditions",
|
|
3196
|
+
filterAnd: "And",
|
|
3197
|
+
filterOr: "Or",
|
|
3198
|
+
filterValueInvalid: (family) => filterValueRequests[family],
|
|
3199
|
+
filterSearchLabel: "Search values",
|
|
3200
|
+
filterSelectAll: "Select all",
|
|
3201
|
+
filterValuesLabel: "Values",
|
|
3202
|
+
filterByCondition: "Filtered by condition",
|
|
3203
|
+
filterOperatorMenu: (family) => filterOperatorMenus[family],
|
|
3204
|
+
filterBackToValues: "Back to values",
|
|
3205
|
+
exportMenu: "Export",
|
|
3206
|
+
exportCsv: "Export to CSV",
|
|
3207
|
+
exportJson: "Export to JSON",
|
|
3208
|
+
exportXlsx: "Export to Excel",
|
|
3209
|
+
exportPdf: "Export to PDF",
|
|
3210
|
+
exportSelectionCsv: "Export selection to CSV",
|
|
3211
|
+
exportSelectionJson: "Export selection to JSON",
|
|
3212
|
+
exportSelectionXlsx: "Export selection to Excel",
|
|
3213
|
+
exportFailed: "Export failed",
|
|
3214
|
+
copyCell: "Copy cell",
|
|
3215
|
+
copyRow: "Copy row",
|
|
3216
|
+
copySelection: "Copy selection",
|
|
3217
|
+
copied: (count, unit) => copied(n, count, unit),
|
|
3218
|
+
copyFailed: "Copy failed",
|
|
3219
|
+
print: "Print"
|
|
3220
|
+
};
|
|
3221
|
+
}
|
|
3222
|
+
var defaultMessages = createDefaultMessages();
|
|
3223
|
+
var localeDefaults = /* @__PURE__ */ new Map();
|
|
3224
|
+
function defaultsFor(locale) {
|
|
3225
|
+
if (locale === void 0) {
|
|
3226
|
+
return defaultMessages;
|
|
3227
|
+
}
|
|
3228
|
+
const key = localeKey2(locale);
|
|
3229
|
+
let defaults = localeDefaults.get(key);
|
|
3230
|
+
if (defaults === void 0) {
|
|
3231
|
+
defaults = createDefaultMessages(locale);
|
|
3232
|
+
localeDefaults.set(key, defaults);
|
|
3233
|
+
}
|
|
3234
|
+
return defaults;
|
|
3235
|
+
}
|
|
3236
|
+
function resolveMessages(messages, locale) {
|
|
3237
|
+
const defaults = defaultsFor(locale);
|
|
3238
|
+
return messages === void 0 ? defaults : { ...defaults, ...messages };
|
|
3203
3239
|
}
|
|
3204
3240
|
|
|
3205
3241
|
// src/util/filterEditor.ts
|
|
@@ -3283,7 +3319,7 @@ function columnValueOptions(rows, dataColumns, filter, columnId, query = {}) {
|
|
|
3283
3319
|
}
|
|
3284
3320
|
}
|
|
3285
3321
|
const { search = "", limit, locale } = query;
|
|
3286
|
-
const messages = resolveMessages(query.messages);
|
|
3322
|
+
const messages = resolveMessages(query.messages, locale);
|
|
3287
3323
|
const options = [...buckets.values()].sort((a, b) => compareValues(a.value, b.value, column.type)).map(({ value, row, count }) => ({
|
|
3288
3324
|
value,
|
|
3289
3325
|
label: formatCellValue(value, column, locale, row, messages),
|
|
@@ -4342,32 +4378,31 @@ function paginationWindow(currentPage, pageCount, options) {
|
|
|
4342
4378
|
if (pageCount <= 0) {
|
|
4343
4379
|
return [];
|
|
4344
4380
|
}
|
|
4345
|
-
const boundaryCount = Math.max(0, options?.boundaryCount ?? 1);
|
|
4346
|
-
const siblingCount = Math.max(0, options?.siblingCount ?? 1);
|
|
4347
|
-
const
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
pages.add(page);
|
|
4381
|
+
const boundaryCount = Math.max(0, Math.floor(options?.boundaryCount ?? 1));
|
|
4382
|
+
const siblingCount = Math.max(0, Math.floor(options?.siblingCount ?? 1));
|
|
4383
|
+
const slotCount = 2 * boundaryCount + 2 * siblingCount + 3;
|
|
4384
|
+
if (pageCount <= slotCount) {
|
|
4385
|
+
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
4351
4386
|
}
|
|
4352
|
-
|
|
4353
|
-
|
|
4387
|
+
const current = Math.min(Math.max(currentPage, 1), pageCount);
|
|
4388
|
+
const runStart = Math.min(
|
|
4389
|
+
Math.max(current - siblingCount, boundaryCount + 2),
|
|
4390
|
+
pageCount - boundaryCount - 1 - 2 * siblingCount
|
|
4391
|
+
);
|
|
4392
|
+
const runEnd = runStart + 2 * siblingCount;
|
|
4393
|
+
const entries = [];
|
|
4394
|
+
for (let page = 1; page <= boundaryCount; page++) {
|
|
4395
|
+
entries.push(page);
|
|
4354
4396
|
}
|
|
4355
|
-
|
|
4356
|
-
|
|
4397
|
+
entries.push(runStart === boundaryCount + 2 ? boundaryCount + 1 : "ellipsis");
|
|
4398
|
+
for (let page = runStart; page <= runEnd; page++) {
|
|
4399
|
+
entries.push(page);
|
|
4357
4400
|
}
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
for (
|
|
4362
|
-
if (previous !== void 0) {
|
|
4363
|
-
if (page - previous === 2) {
|
|
4364
|
-
entries.push(previous + 1);
|
|
4365
|
-
} else if (page - previous > 2) {
|
|
4366
|
-
entries.push("ellipsis");
|
|
4367
|
-
}
|
|
4368
|
-
}
|
|
4401
|
+
entries.push(
|
|
4402
|
+
runEnd === pageCount - boundaryCount - 1 ? pageCount - boundaryCount : "ellipsis"
|
|
4403
|
+
);
|
|
4404
|
+
for (let page = pageCount - boundaryCount + 1; page <= pageCount; page++) {
|
|
4369
4405
|
entries.push(page);
|
|
4370
|
-
previous = page;
|
|
4371
4406
|
}
|
|
4372
4407
|
return entries;
|
|
4373
4408
|
}
|
|
@@ -4627,6 +4662,7 @@ export {
|
|
|
4627
4662
|
copyContent,
|
|
4628
4663
|
createColumnValueOptionsCache,
|
|
4629
4664
|
createCommandContext,
|
|
4665
|
+
createDefaultMessages,
|
|
4630
4666
|
createGridController,
|
|
4631
4667
|
createGridViewResolver,
|
|
4632
4668
|
csvWriter,
|