@vuu-ui/vuu-utils 0.8.23-debug → 0.8.24-debug

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@vuu-ui/vuu-utils",
3
- "version": "0.8.23-debug",
3
+ "version": "0.8.24-debug",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
6
6
  "devDependencies": {
7
- "@vuu-ui/vuu-data-types": "0.8.23-debug",
8
- "@vuu-ui/vuu-table-types": "0.8.23-debug",
9
- "@vuu-ui/vuu-filter-types": "0.8.23-debug",
10
- "@vuu-ui/vuu-protocol-types": "0.8.23-debug"
7
+ "@vuu-ui/vuu-data-types": "0.8.24-debug",
8
+ "@vuu-ui/vuu-table-types": "0.8.24-debug",
9
+ "@vuu-ui/vuu-filter-types": "0.8.24-debug",
10
+ "@vuu-ui/vuu-protocol-types": "0.8.24-debug"
11
11
  },
12
12
  "peerDependencies": {
13
13
  "react": ">=17.0.2",
@@ -18,6 +18,7 @@ export declare function mapSortCriteria(sortCriteria: SortCriteriaItem[], column
18
18
  export declare const getDefaultAlignment: (serverDataType?: VuuColumnDataType) => ColumnAlignment;
19
19
  export declare const isValidColumnAlignment: (v: string) => v is ColumnAlignment;
20
20
  export declare const isValidPinLocation: (v: string) => v is PinLocation;
21
+ export declare const isVuuColumnDataType: (value: string | undefined | null) => value is VuuColumnDataType;
21
22
  export declare const fromServerDataType: (serverDataType: VuuColumnDataType) => ColumnTypeSimple;
22
23
  export declare const isNumericColumn: ({ serverDataType, type }: ColumnDescriptor) => boolean;
23
24
  export declare const isDateTimeColumn: (column: ColumnDescriptor) => column is DateTimeColumnDescriptor;
@@ -171,5 +172,16 @@ export declare function applyWidthToColumns(columns: RuntimeColumnDescriptor[],
171
172
  * A memo compare function for cell renderers. Can be used to suppress
172
173
  * render where column and data are both unchanged. Avoids render
173
174
  * when row changes, where changes in row are unrelated to this cell.
175
+ * Suitabnle only for readonly cell renderers. See below for editable
176
+ * cell renderers.
174
177
  */
175
178
  export declare const dataAndColumnUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
179
+ /**
180
+ * A memo compare function for cell renderers. Can be used to suppress
181
+ * render where column, row key and data are all unchanged. Avoids render
182
+ * when row changes, where changes in row are unrelated to this cell.
183
+ * Suitable for editable cells. Including key in compare is not strictly
184
+ * necessary for rendering, but it is important in the event that user
185
+ * edits data - ensures we never have a stale key.
186
+ */
187
+ export declare const dataColumnAndKeyUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
@@ -1,6 +1,8 @@
1
- import { FunctionComponent as FC, HTMLAttributes } from "react";
2
- import { ColumnDescriptor, ColumnDescriptorCustomRenderer, ColumnTypeRendering, EditValidationRule, HeaderCellProps, TableCellRendererProps } from "@vuu-ui/vuu-table-types";
1
+ import { DataSourceRow } from "@vuu-ui/vuu-data-types";
3
2
  import { VuuColumnDataType, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
+ import { ColumnDescriptor, ColumnDescriptorCustomRenderer, ColumnTypeRendering, EditValidationRule, HeaderCellProps, TableCellRendererProps } from "@vuu-ui/vuu-table-types";
4
+ import { FunctionComponent as FC, HTMLAttributes } from "react";
5
+ import { ColumnMap } from "./column-utils";
4
6
  export interface CellConfigPanelProps extends HTMLAttributes<HTMLDivElement> {
5
7
  onConfigChange: () => void;
6
8
  }
@@ -10,25 +12,32 @@ export interface ConfigurationEditorProps {
10
12
  column: ColumnDescriptorCustomRenderer;
11
13
  onChangeRendering: ColumnRenderPropsChangeHandler;
12
14
  }
15
+ export type RowClassNameGenerator = (row: DataSourceRow, columnMap: ColumnMap) => string | undefined;
16
+ export type RowClassGenerator = {
17
+ id: string;
18
+ fn: RowClassNameGenerator;
19
+ };
13
20
  export type ConfigEditorComponent = FC<CellConfigPanelProps>;
14
21
  export type EditRuleValidator = (editRule: EditValidationRule, value?: VuuRowDataItemType) => boolean | string;
15
- export type ComponentType = "cell-renderer" | "column-header-content-renderer" | "column-header-label-renderer" | "cell-config-panel" | "data-edit-validator";
22
+ export type ComponentType = "cell-renderer" | "cell-config-panel" | "column-header-content-renderer" | "column-header-label-renderer" | "data-edit-validator" | "row-class-generator";
16
23
  type CellRendererOptions = {
17
24
  configEditor?: string;
18
25
  description?: string;
19
26
  label?: string;
20
27
  serverDataType?: VuuColumnDataType | VuuColumnDataType[] | "json" | "private";
28
+ userCanAssign?: boolean;
21
29
  };
22
30
  export interface CellRendererDescriptor extends CellRendererOptions {
23
31
  name: string;
24
32
  }
25
- export declare function registerComponent<T extends TableCellRendererProps | CellConfigPanelProps | EditRuleValidator | HeaderCellProps = TableCellRendererProps>(componentName: string, component: T extends EditRuleValidator ? T : FC<T>, type: ComponentType | undefined, options: CellRendererOptions): void;
33
+ export declare function registerComponent<T extends CellConfigPanelProps | EditRuleValidator | HeaderCellProps | RowClassGenerator | TableCellRendererProps = TableCellRendererProps>(componentName: string, component: T extends EditRuleValidator | RowClassGenerator ? T : FC<T>, type: ComponentType | undefined, options: CellRendererOptions): void;
26
34
  export declare const registerConfigurationEditor: (componentName: string, configurationEditor: FC<ConfigurationEditorProps>) => void;
27
35
  export declare const getRegisteredCellRenderers: (serverDataType?: VuuColumnDataType | "json") => CellRendererDescriptor[];
28
36
  export declare const getCellRendererOptions: (renderName: string) => CellRendererOptions | undefined;
29
37
  export declare function getCellRenderer(column: ColumnDescriptor): FC<TableCellRendererProps> | undefined;
30
38
  export declare function getColumnHeaderContentRenderer(column: ColumnDescriptor): FC<HeaderCellProps> | undefined;
31
39
  export declare function getColumnHeaderLabelRenderer(column: ColumnDescriptor): FC<HeaderCellProps> | undefined;
40
+ export declare const getRowClassNameGenerator: (generatorId: string) => RowClassGenerator | undefined;
32
41
  export declare function getConfigurationEditor(configEditor?: string): FC<ConfigurationEditorProps> | undefined;
33
42
  export declare function getCellConfigPanelRenderer(name: string): ConfigEditorComponent | undefined;
34
43
  export declare function getEditRuleValidator(name: string): EditRuleValidator | undefined;
@@ -3,11 +3,22 @@ import { LinkDescriptorWithLabel, VuuFilter, VuuSort } from "@vuu-ui/vuu-protoco
3
3
  export declare const NoFilter: VuuFilter;
4
4
  export declare const NoSort: VuuSort;
5
5
  export declare const vanillaConfig: WithFullConfig;
6
+ export type DataSourceConfigChanges = {
7
+ aggregationsChanged: boolean;
8
+ columnsChanged: boolean;
9
+ filterChanged: boolean;
10
+ groupByChanged: boolean;
11
+ sortChanged: boolean;
12
+ visualLinkChanged: boolean;
13
+ };
14
+ export type MaybeDataSourceConfigChanges = DataSourceConfigChanges & {
15
+ noChanges: boolean;
16
+ };
6
17
  type DataConfigPredicate = (config: DataSourceConfig, newConfig: DataSourceConfig) => boolean;
7
- export declare const columnsChanged: DataConfigPredicate;
8
- export declare const filterChanged: DataConfigPredicate;
9
- export declare const groupByChanged: DataConfigPredicate;
10
- export declare const configChanged: (config: DataSourceConfig | undefined, newConfig: DataSourceConfig | undefined) => boolean;
18
+ export declare const isFilterChanged: DataConfigPredicate;
19
+ export declare const isGroupByChanged: DataConfigPredicate;
20
+ export declare const NO_CONFIG_CHANGES: MaybeDataSourceConfigChanges;
21
+ export declare const isConfigChanged: (config: DataSourceConfig | undefined, newConfig: DataSourceConfig | undefined) => MaybeDataSourceConfigChanges;
11
22
  export declare const hasGroupBy: (config?: DataSourceConfig) => config is WithGroupBy;
12
23
  export declare const hasFilter: (config?: DataSourceConfig) => config is WithFilter;
13
24
  export declare const hasSort: (config?: DataSourceConfig) => config is WithSort;
@@ -1,6 +1,7 @@
1
1
  export declare const createEl: (elementType: "div" | "p" | "span", className?: string, textContent?: string) => HTMLElement;
2
2
  export declare const getFocusableElement: (el: HTMLElement | null, tabIndex?: number) => HTMLElement | undefined;
3
3
  export declare const getElementDataIndex: (el: HTMLElement | null) => number;
4
+ export declare const queryClosest: <T extends HTMLElement = HTMLElement>(el: HTMLElement | EventTarget, cssQueryString: string) => T;
4
5
  export declare const getClosest: (el: HTMLElement, dataProperty: string) => HTMLElement;
5
6
  export declare const getClosestIndexItem: (el: HTMLElement) => HTMLElement;
6
7
  export declare function getElementByDataIndex(c: HTMLElement | null, i: number | string, throwIfNotFound: true): HTMLElement;