@kanunilabs/datagrid 1.9.2 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { GridRowData, DataGridController, GridDictionary, GridDataType, LookupItem, LookupMatchMode, RowKey, EditingEngineOptions, EditingEngine, RowChange, EditMode, RowNode, GridColumnDef, DataGridCoreConfig, FilterRenderContextBase, FilterNode, GridThemeName, GridPaletteName, GridDensity, DescribeFilterOptions, CardViewOptions, StateStoringConfig, InferColumnsOptions, RowStatusSource } from '@kanunilabs/datagrid-core';
1
+ import { GridRowData, DataGridController, GridDictionary, GridDataType, LookupItem, LookupMatchMode, RowKey, EditingEngineOptions, EditingEngine, RowChange, EditMode, RowNode, GridColumnDef, DataGridCoreConfig, FilterRenderContextBase, FilterNode, GridThemeName, GridPaletteName, GridDensity, DescribeFilterOptions, CardViewOptions, ToolbarOptions, PortalContainer, StateStoringConfig, InferColumnsOptions, RowStatusSource } from '@kanunilabs/datagrid-core';
2
2
  export { CustomFilterOperator, CustomFilterOperatorId, DENSITY_ROW_HEIGHT, DataGridController, FilterNode, GRID_COLOR_SCHEMES, GridColorScheme, GridColumnDef, GridDensity, GridPaletteName, GridRowData, GridTheme, GridThemeName, RowKey, RowNode, SortDescriptor, THEME_ROW_HEIGHT, isPackagedTheme, presetRowHeight } from '@kanunilabs/datagrid-core';
3
3
 
4
4
  /** What a header menu is opened against — the React shape, verbatim. */
@@ -705,7 +705,9 @@ interface CreateGridConfig<TRow = GridRowData> extends Omit<DataGridCoreConfig<T
705
705
  * no control — React's rule, and the Enterprise wrapper wires it to its own
706
706
  * builder.
707
707
  */
708
- onOpenFilterBuilder?: () => void;
708
+ onOpenFilterBuilder?: (context?: {
709
+ columnId?: string;
710
+ }) => void;
709
711
  /** Highlight the row that holds focus. Default false — the React default. */
710
712
  focusedRow?: boolean;
711
713
  /**
@@ -780,8 +782,25 @@ interface CreateGridConfig<TRow = GridRowData> extends Omit<DataGridCoreConfig<T
780
782
  * a vanilla caller has no editor surfacing the `@deprecated` tag.
781
783
  */
782
784
  showRowCount?: boolean;
783
- /** Quick-search + CSV export bar above the grid. */
784
- toolbar?: boolean;
785
+ /**
786
+ * Quick-search + export bar above the grid. `true` shows all of it; an
787
+ * object picks the parts and sets the search box up — React's `toolbar`:
788
+ *
789
+ * toolbar: { export: false, search: { maxLength: 100, debounce: 300, validate } }
790
+ *
791
+ * Your own buttons: `toolbarItemsBefore` / `toolbarItemsAfter`, e.g. built
792
+ * with `toolbarButton()`.
793
+ */
794
+ toolbar?: boolean | ToolbarOptions;
795
+ /**
796
+ * Where the grid draws its popups (header filter, menus, date and lookup
797
+ * lists, dialogs, tooltips): an element, or a function returning one.
798
+ * Default `document.body`. Set it when the grid sits in a modal that makes
799
+ * the rest of the page ignore the pointer; pass the modal's content element
800
+ * (one without `overflow: hidden`). Popups stay in place even when the modal
801
+ * is moved with a CSS transform. Every popup carries `data-kanuni-portal`.
802
+ */
803
+ portalContainer?: PortalContainer;
785
804
  /** "Columns" button in the toolbar opening the visibility chooser. */
786
805
  toolbarColumnChooser?: boolean;
787
806
  /**
@@ -956,6 +975,26 @@ interface GridApi<TRow = GridRowData> {
956
975
  }
957
976
  declare function createGrid<TRow = GridRowData>(container: HTMLElement, config: CreateGridConfig<TRow>): GridApi<TRow>;
958
977
 
978
+ interface ToolbarButtonSpec {
979
+ /** The glyph: an element (e.g. an inline SVG) or SVG/HTML markup. */
980
+ icon: Element | string;
981
+ /** The button's name: its accessible name and the start of its tooltip. */
982
+ label: string;
983
+ /** Keyboard shortcut shown in the tooltip and as `aria-keyshortcuts`. */
984
+ shortcut?: string;
985
+ /** Set while the button cannot be used: clicks are ignored and this is the reason given. */
986
+ disabledReason?: string;
987
+ /** Show the label beside the icon. Default false (icon only). */
988
+ showLabel?: boolean;
989
+ onClick?: () => void;
990
+ /** `data-testid` on the button. */
991
+ testId?: string;
992
+ }
993
+ /** A button for the toolbar or status bar. Call `update()` to change it later. */
994
+ declare function toolbarButton(spec: ToolbarButtonSpec): HTMLButtonElement & {
995
+ update(next: Partial<ToolbarButtonSpec>): void;
996
+ };
997
+
959
998
  /**
960
999
  * Width that fits the header and every rendered cell of `columnId`.
961
1000
  * Returns null when nothing could be measured (no such column on screen, or no
@@ -1010,8 +1049,13 @@ interface ConfirmDialogSpec {
1010
1049
  danger?: boolean;
1011
1050
  /** The enterprise wrapper's theme/dark classes, re-established here. */
1012
1051
  surfaceClass?: string;
1052
+ /**
1053
+ * An element inside the grid, so the dialog follows the grid's
1054
+ * `portalContainer` (core `portalContainerFor`). Default: <body>.
1055
+ */
1056
+ anchor?: Element;
1013
1057
  }
1014
1058
  /** Open the dialog; resolves the user's answer and removes itself. */
1015
1059
  declare function openConfirmDialog(spec: ConfirmDialogSpec): Promise<boolean>;
1016
1060
 
1017
- export { CHECKBOX_COLUMN_WIDTH, type CellEditingExtension, type CellEditingHelpers, type CellEditingLayer, type CellEditingOptions, type CellEditorSpec, type CellLookupEditorSpec, type CellMenuOptions, type CellRenderContext, type CellSlotContext, type ConfirmDialogSpec, type CreateGridConfig, DETAIL_COLUMN_WIDTH, type DateEditorSpec, type EditFormField, type EditFormHandle, type EditFormSpec, type ExportKind, type GridApi, type GridMenuItem, type GridNotesConfig, type HeaderMenuContext, type HeaderMenuDeps, type NoteCellContext, PRINT_MAX_ROWS, type PrintLayoutOptions, ROW_DRAG_MIME, ROW_NUMBER_COLUMN_WIDTH, type RowDragConfig, type RowDragPayload, type RowDropEvent, type RowMenuContext, type RowReorderEvent, type RowTemplateContext, type VanillaColumnDef, type VanillaEditorRenderContext, type VanillaFilterRenderApi, attachCellEditing, buildCellEditor, buildDateEditor, buildEditForm, buildHeaderMenu, createGrid, measureBestFitWidth, openConfirmDialog };
1061
+ export { CHECKBOX_COLUMN_WIDTH, type CellEditingExtension, type CellEditingHelpers, type CellEditingLayer, type CellEditingOptions, type CellEditorSpec, type CellLookupEditorSpec, type CellMenuOptions, type CellRenderContext, type CellSlotContext, type ConfirmDialogSpec, type CreateGridConfig, DETAIL_COLUMN_WIDTH, type DateEditorSpec, type EditFormField, type EditFormHandle, type EditFormSpec, type ExportKind, type GridApi, type GridMenuItem, type GridNotesConfig, type HeaderMenuContext, type HeaderMenuDeps, type NoteCellContext, PRINT_MAX_ROWS, type PrintLayoutOptions, ROW_DRAG_MIME, ROW_NUMBER_COLUMN_WIDTH, type RowDragConfig, type RowDragPayload, type RowDropEvent, type RowMenuContext, type RowReorderEvent, type RowTemplateContext, type ToolbarButtonSpec, type VanillaColumnDef, type VanillaEditorRenderContext, type VanillaFilterRenderApi, attachCellEditing, buildCellEditor, buildDateEditor, buildEditForm, buildHeaderMenu, createGrid, measureBestFitWidth, openConfirmDialog, toolbarButton };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { GridRowData, DataGridController, GridDictionary, GridDataType, LookupItem, LookupMatchMode, RowKey, EditingEngineOptions, EditingEngine, RowChange, EditMode, RowNode, GridColumnDef, DataGridCoreConfig, FilterRenderContextBase, FilterNode, GridThemeName, GridPaletteName, GridDensity, DescribeFilterOptions, CardViewOptions, StateStoringConfig, InferColumnsOptions, RowStatusSource } from '@kanunilabs/datagrid-core';
1
+ import { GridRowData, DataGridController, GridDictionary, GridDataType, LookupItem, LookupMatchMode, RowKey, EditingEngineOptions, EditingEngine, RowChange, EditMode, RowNode, GridColumnDef, DataGridCoreConfig, FilterRenderContextBase, FilterNode, GridThemeName, GridPaletteName, GridDensity, DescribeFilterOptions, CardViewOptions, ToolbarOptions, PortalContainer, StateStoringConfig, InferColumnsOptions, RowStatusSource } from '@kanunilabs/datagrid-core';
2
2
  export { CustomFilterOperator, CustomFilterOperatorId, DENSITY_ROW_HEIGHT, DataGridController, FilterNode, GRID_COLOR_SCHEMES, GridColorScheme, GridColumnDef, GridDensity, GridPaletteName, GridRowData, GridTheme, GridThemeName, RowKey, RowNode, SortDescriptor, THEME_ROW_HEIGHT, isPackagedTheme, presetRowHeight } from '@kanunilabs/datagrid-core';
3
3
 
4
4
  /** What a header menu is opened against — the React shape, verbatim. */
@@ -705,7 +705,9 @@ interface CreateGridConfig<TRow = GridRowData> extends Omit<DataGridCoreConfig<T
705
705
  * no control — React's rule, and the Enterprise wrapper wires it to its own
706
706
  * builder.
707
707
  */
708
- onOpenFilterBuilder?: () => void;
708
+ onOpenFilterBuilder?: (context?: {
709
+ columnId?: string;
710
+ }) => void;
709
711
  /** Highlight the row that holds focus. Default false — the React default. */
710
712
  focusedRow?: boolean;
711
713
  /**
@@ -780,8 +782,25 @@ interface CreateGridConfig<TRow = GridRowData> extends Omit<DataGridCoreConfig<T
780
782
  * a vanilla caller has no editor surfacing the `@deprecated` tag.
781
783
  */
782
784
  showRowCount?: boolean;
783
- /** Quick-search + CSV export bar above the grid. */
784
- toolbar?: boolean;
785
+ /**
786
+ * Quick-search + export bar above the grid. `true` shows all of it; an
787
+ * object picks the parts and sets the search box up — React's `toolbar`:
788
+ *
789
+ * toolbar: { export: false, search: { maxLength: 100, debounce: 300, validate } }
790
+ *
791
+ * Your own buttons: `toolbarItemsBefore` / `toolbarItemsAfter`, e.g. built
792
+ * with `toolbarButton()`.
793
+ */
794
+ toolbar?: boolean | ToolbarOptions;
795
+ /**
796
+ * Where the grid draws its popups (header filter, menus, date and lookup
797
+ * lists, dialogs, tooltips): an element, or a function returning one.
798
+ * Default `document.body`. Set it when the grid sits in a modal that makes
799
+ * the rest of the page ignore the pointer; pass the modal's content element
800
+ * (one without `overflow: hidden`). Popups stay in place even when the modal
801
+ * is moved with a CSS transform. Every popup carries `data-kanuni-portal`.
802
+ */
803
+ portalContainer?: PortalContainer;
785
804
  /** "Columns" button in the toolbar opening the visibility chooser. */
786
805
  toolbarColumnChooser?: boolean;
787
806
  /**
@@ -956,6 +975,26 @@ interface GridApi<TRow = GridRowData> {
956
975
  }
957
976
  declare function createGrid<TRow = GridRowData>(container: HTMLElement, config: CreateGridConfig<TRow>): GridApi<TRow>;
958
977
 
978
+ interface ToolbarButtonSpec {
979
+ /** The glyph: an element (e.g. an inline SVG) or SVG/HTML markup. */
980
+ icon: Element | string;
981
+ /** The button's name: its accessible name and the start of its tooltip. */
982
+ label: string;
983
+ /** Keyboard shortcut shown in the tooltip and as `aria-keyshortcuts`. */
984
+ shortcut?: string;
985
+ /** Set while the button cannot be used: clicks are ignored and this is the reason given. */
986
+ disabledReason?: string;
987
+ /** Show the label beside the icon. Default false (icon only). */
988
+ showLabel?: boolean;
989
+ onClick?: () => void;
990
+ /** `data-testid` on the button. */
991
+ testId?: string;
992
+ }
993
+ /** A button for the toolbar or status bar. Call `update()` to change it later. */
994
+ declare function toolbarButton(spec: ToolbarButtonSpec): HTMLButtonElement & {
995
+ update(next: Partial<ToolbarButtonSpec>): void;
996
+ };
997
+
959
998
  /**
960
999
  * Width that fits the header and every rendered cell of `columnId`.
961
1000
  * Returns null when nothing could be measured (no such column on screen, or no
@@ -1010,8 +1049,13 @@ interface ConfirmDialogSpec {
1010
1049
  danger?: boolean;
1011
1050
  /** The enterprise wrapper's theme/dark classes, re-established here. */
1012
1051
  surfaceClass?: string;
1052
+ /**
1053
+ * An element inside the grid, so the dialog follows the grid's
1054
+ * `portalContainer` (core `portalContainerFor`). Default: <body>.
1055
+ */
1056
+ anchor?: Element;
1013
1057
  }
1014
1058
  /** Open the dialog; resolves the user's answer and removes itself. */
1015
1059
  declare function openConfirmDialog(spec: ConfirmDialogSpec): Promise<boolean>;
1016
1060
 
1017
- export { CHECKBOX_COLUMN_WIDTH, type CellEditingExtension, type CellEditingHelpers, type CellEditingLayer, type CellEditingOptions, type CellEditorSpec, type CellLookupEditorSpec, type CellMenuOptions, type CellRenderContext, type CellSlotContext, type ConfirmDialogSpec, type CreateGridConfig, DETAIL_COLUMN_WIDTH, type DateEditorSpec, type EditFormField, type EditFormHandle, type EditFormSpec, type ExportKind, type GridApi, type GridMenuItem, type GridNotesConfig, type HeaderMenuContext, type HeaderMenuDeps, type NoteCellContext, PRINT_MAX_ROWS, type PrintLayoutOptions, ROW_DRAG_MIME, ROW_NUMBER_COLUMN_WIDTH, type RowDragConfig, type RowDragPayload, type RowDropEvent, type RowMenuContext, type RowReorderEvent, type RowTemplateContext, type VanillaColumnDef, type VanillaEditorRenderContext, type VanillaFilterRenderApi, attachCellEditing, buildCellEditor, buildDateEditor, buildEditForm, buildHeaderMenu, createGrid, measureBestFitWidth, openConfirmDialog };
1061
+ export { CHECKBOX_COLUMN_WIDTH, type CellEditingExtension, type CellEditingHelpers, type CellEditingLayer, type CellEditingOptions, type CellEditorSpec, type CellLookupEditorSpec, type CellMenuOptions, type CellRenderContext, type CellSlotContext, type ConfirmDialogSpec, type CreateGridConfig, DETAIL_COLUMN_WIDTH, type DateEditorSpec, type EditFormField, type EditFormHandle, type EditFormSpec, type ExportKind, type GridApi, type GridMenuItem, type GridNotesConfig, type HeaderMenuContext, type HeaderMenuDeps, type NoteCellContext, PRINT_MAX_ROWS, type PrintLayoutOptions, ROW_DRAG_MIME, ROW_NUMBER_COLUMN_WIDTH, type RowDragConfig, type RowDragPayload, type RowDropEvent, type RowMenuContext, type RowReorderEvent, type RowTemplateContext, type ToolbarButtonSpec, type VanillaColumnDef, type VanillaEditorRenderContext, type VanillaFilterRenderApi, attachCellEditing, buildCellEditor, buildDateEditor, buildEditForm, buildHeaderMenu, createGrid, measureBestFitWidth, openConfirmDialog, toolbarButton };