@vuu-ui/vuu-utils 0.8.8-debug → 0.8.9-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,12 +1,12 @@
1
1
  {
2
2
  "name": "@vuu-ui/vuu-utils",
3
- "version": "0.8.8-debug",
3
+ "version": "0.8.9-debug",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
6
6
  "devDependencies": {
7
- "@vuu-ui/vuu-datagrid-types": "0.8.8-debug",
8
- "@vuu-ui/vuu-filter-types": "0.8.8-debug",
9
- "@vuu-ui/vuu-protocol-types": "0.8.8-debug"
7
+ "@vuu-ui/vuu-datagrid-types": "0.8.9-debug",
8
+ "@vuu-ui/vuu-filter-types": "0.8.9-debug",
9
+ "@vuu-ui/vuu-protocol-types": "0.8.9-debug"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "react": "^17.0.2",
@@ -2,4 +2,5 @@ export type PartitionTest<T> = (value: T, index: number) => boolean;
2
2
  export declare function partition<T>(array: T[], test: PartitionTest<T>, pass?: T[], fail?: T[]): [T[], T[]];
3
3
  export declare function itemsChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
4
4
  export declare function itemsOrOrderChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
5
- export declare const moveItem: <T = unknown>(items: T[], item: T, moveTo: number) => T[];
5
+ export declare const moveItemDeprecated: <T = unknown>(items: T[], item: T, moveTo: number) => T[];
6
+ export declare const moveItem: <T = unknown>(items: T[], fromIndex: number, toIndex: number) => T[];
@@ -0,0 +1,9 @@
1
+ export interface rect {
2
+ bottom: number;
3
+ left: number;
4
+ right: number;
5
+ top: number;
6
+ }
7
+ export type rectTuple = [number, number, number, number];
8
+ export type dimension = "width" | "height";
9
+ export declare function boxContainsPoint(rect: rect, x: number, y: number): boolean | undefined;
@@ -1,8 +1,10 @@
1
- import { DataSourceFilter, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
- import { ColumnDescriptor, ColumnType, ColumnTypeDescriptor, ColumnTypeRenderer, GroupColumnDescriptor, KeyedColumnDescriptor, MappedValueTypeRenderer, TableHeadings } from "@vuu-ui/vuu-datagrid-types";
3
- import { Filter } from "@vuu-ui/vuu-filter-types";
4
- import { VuuAggregation, VuuAggType, VuuColumnDataType, VuuDataRow, VuuGroupBy, VuuRowRecord, VuuSort } from "@vuu-ui/vuu-protocol-types";
5
- import { CSSProperties } from "react";
1
+ import type { DataSourceFilter, DataSourceRow } from "@vuu-ui/vuu-data-types";
2
+ import type { ColumnAlignment, ColumnDescriptor, ColumnType, ColumnTypeDescriptor, ColumnTypeRenderer, ColumnTypeWithValidationRules, GroupColumnDescriptor, KeyedColumnDescriptor, MappedValueTypeRenderer, PinLocation, TableHeadings, TypeFormatting } from "@vuu-ui/vuu-datagrid-types";
3
+ import type { Filter } from "@vuu-ui/vuu-filter-types";
4
+ import type { VuuAggregation, VuuAggType, VuuColumnDataType, VuuDataRow, VuuGroupBy, VuuRowRecord, VuuSort } from "@vuu-ui/vuu-protocol-types";
5
+ import type { SchemaColumn } from "@vuu-ui/vuu-data";
6
+ import type { CSSProperties } from "react";
7
+ import type { CellRendererDescriptor } from "./component-registry";
6
8
  export interface ColumnMap {
7
9
  [columnName: string]: number;
8
10
  }
@@ -11,6 +13,9 @@ export declare const AggregationType: {
11
13
  [key: string]: VuuAggType;
12
14
  };
13
15
  export declare function mapSortCriteria(sortCriteria: SortCriteriaItem[], columnMap: ColumnMap, metadataOffset?: number): [number, "asc"][];
16
+ export declare const getDefaultAlignment: (serverDataType?: VuuColumnDataType) => ColumnAlignment;
17
+ export declare const isValidColumnAlignment: (v: string) => v is ColumnAlignment;
18
+ export declare const isValidPinLocation: (v: string) => v is PinLocation;
14
19
  export declare const isKeyedColumn: (column: ColumnDescriptor) => column is KeyedColumnDescriptor;
15
20
  export declare const fromServerDataType: (serverDataType: VuuColumnDataType) => ColumnTypeSimple;
16
21
  export declare const isNumericColumn: ({ serverDataType, type }: ColumnDescriptor) => boolean;
@@ -27,8 +32,9 @@ export declare const isSimpleColumnType: (value: unknown) => value is ColumnType
27
32
  export declare type ColumnTypeSimple = "string" | "number" | "boolean" | "json" | "date" | "time" | "checkbox";
28
33
  export declare const isTypeDescriptor: (type?: ColumnType) => type is ColumnTypeDescriptor;
29
34
  export declare const isColumnTypeRenderer: (renderer?: unknown) => renderer is ColumnTypeRenderer;
35
+ export declare const hasValidationRules: (type?: ColumnType) => type is ColumnTypeWithValidationRules;
30
36
  export declare const isMappedValueTypeRenderer: (renderer?: unknown) => renderer is MappedValueTypeRenderer;
31
- export declare function buildColumnMap(columns?: (KeyedColumnDescriptor | string)[]): ColumnMap;
37
+ export declare function buildColumnMap(columns?: (KeyedColumnDescriptor | SchemaColumn | string)[]): ColumnMap;
32
38
  export declare function projectUpdates(updates: number[]): number[];
33
39
  export declare const metadataKeys: {
34
40
  readonly IDX: 0;
@@ -62,8 +68,9 @@ export declare const applyFilterToColumns: (columns: KeyedColumnDescriptor[], {
62
68
  export declare const isFilteredColumn: (column: KeyedColumnDescriptor) => boolean;
63
69
  export declare const stripFilterFromColumns: (columns: KeyedColumnDescriptor[]) => {
64
70
  align?: "left" | "right" | undefined;
65
- CellRenderer?: import("react").FunctionComponent<import("@vuu-ui/vuu-datagrid-types").TableCellProps> | undefined;
71
+ CellRenderer?: import("react").FunctionComponent<import("@vuu-ui/vuu-datagrid-types").TableCellRendererProps> | undefined;
66
72
  className?: string | undefined;
73
+ clientSideEditValidationCheck?: import("packages/vuu-ui-controls/src").ClientSideValidationChecker | undefined;
67
74
  endPin?: true | undefined;
68
75
  flex?: number | undefined;
69
76
  heading?: string[] | undefined;
@@ -89,7 +96,7 @@ export declare const stripFilterFromColumns: (columns: KeyedColumnDescriptor[])
89
96
  hidden?: boolean | undefined;
90
97
  minWidth?: number | undefined;
91
98
  name: string;
92
- pin?: import("@vuu-ui/vuu-datagrid-types").PinLocation | undefined;
99
+ pin?: PinLocation | undefined;
93
100
  serverDataType?: VuuColumnDataType | undefined;
94
101
  }[];
95
102
  export declare const getColumnName: (name: string) => string;
@@ -102,3 +109,22 @@ export declare const isDataLoading: (columns: KeyedColumnDescriptor[]) => boolea
102
109
  export declare const getColumnsInViewport: (columns: KeyedColumnDescriptor[], vpStart: number, vpEnd: number) => [KeyedColumnDescriptor[], number];
103
110
  export declare const visibleColumnAtIndex: (columns: KeyedColumnDescriptor[], index: number) => KeyedColumnDescriptor | undefined;
104
111
  export declare const getGroupValueAndOffset: (columns: KeyedColumnDescriptor[], row: DataSourceRow) => [unknown, number];
112
+ export declare const getDefaultColumnType: (serverDataType?: VuuColumnDataType) => ColumnTypeSimple;
113
+ export declare const updateColumnType: <T extends ColumnDescriptor = ColumnDescriptor>(column: T, formatting: TypeFormatting) => T;
114
+ export declare const updateColumnRenderer: <T extends ColumnDescriptor = ColumnDescriptor>(column: T, cellRenderer: CellRendererDescriptor) => T;
115
+ export declare const getTypeSettingsFromColumn: (column: ColumnDescriptor) => TypeFormatting;
116
+ /**
117
+ *
118
+ * return a filter predicate that will reject columns, names of which
119
+ * are not in provided list.
120
+ */
121
+ export declare const subscribedOnly: (columnNames?: string[]) => (column: ColumnDescriptor) => boolean | undefined;
122
+ export declare const addColumnToSubscribedColumns: (subscribedColumns: ColumnDescriptor[], availableColumns: SchemaColumn[], columnName: string) => ColumnDescriptor[];
123
+ export declare const isCalculatedColumn: (columnName?: string) => boolean;
124
+ export declare const getCalculatedColumnDetails: (column: ColumnDescriptor) => string[];
125
+ export declare const getCalculatedColumnName: (column: ColumnDescriptor) => string;
126
+ export declare const getCalculatedColumnExpression: (column: ColumnDescriptor) => string;
127
+ export declare const getCalculatedColumnType: (column: ColumnDescriptor) => VuuColumnDataType;
128
+ export declare const setCalculatedColumnName: (column: ColumnDescriptor, name: string) => ColumnDescriptor;
129
+ export declare const setCalculatedColumnExpression: (column: ColumnDescriptor, expression: string) => ColumnDescriptor;
130
+ export declare const setCalculatedColumnType: (column: ColumnDescriptor, type: string) => ColumnDescriptor;
@@ -1,19 +1,23 @@
1
1
  import { FunctionComponent as FC, HTMLAttributes } from "react";
2
- import { ColumnTypeRenderer, MappedValueTypeRenderer, TableCellProps } from "@vuu-ui/vuu-datagrid-types";
3
- import { VuuColumnDataType } from "@vuu-ui/vuu-protocol-types";
2
+ import { ColumnTypeRenderer, EditValidationRule, MappedValueTypeRenderer, TableCellRendererProps } from "@vuu-ui/vuu-datagrid-types";
3
+ import { VuuColumnDataType, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
4
4
  export interface CellConfigPanelProps extends HTMLAttributes<HTMLDivElement> {
5
5
  onConfigChange: () => void;
6
6
  }
7
- export type ComponentType = "cell-renderer" | "cell-config-panel";
7
+ export type EditRuleValidator = (editRule: EditValidationRule, value: VuuRowDataItemType) => boolean | string;
8
+ export type ComponentType = "cell-renderer" | "cell-config-panel" | "data-edit-validator";
8
9
  type CellRendererOptions = {
9
10
  [key: string]: unknown;
10
- serverDataType?: VuuColumnDataType | VuuColumnDataType[];
11
+ description?: string;
12
+ label?: string;
13
+ serverDataType?: VuuColumnDataType | VuuColumnDataType[] | "json" | "private";
11
14
  };
12
15
  export interface CellRendererDescriptor extends CellRendererOptions {
13
16
  name: string;
14
17
  }
15
- export declare function registerComponent<T extends TableCellProps | CellConfigPanelProps = TableCellProps>(componentName: string, component: FC<T>, type: ComponentType | undefined, options: CellRendererOptions): void;
16
- export declare const getRegisteredCellRenderers: (serverDataType?: VuuColumnDataType) => CellRendererDescriptor[];
17
- export declare function getCellRenderer(renderer?: ColumnTypeRenderer | MappedValueTypeRenderer): FC<TableCellProps> | undefined;
18
+ export declare function registerComponent<T extends TableCellRendererProps | CellConfigPanelProps | EditRuleValidator = TableCellRendererProps>(componentName: string, component: T extends EditRuleValidator ? T : FC<T>, type: ComponentType | undefined, options: CellRendererOptions): void;
19
+ export declare const getRegisteredCellRenderers: (serverDataType?: VuuColumnDataType | "json") => CellRendererDescriptor[];
20
+ export declare function getCellRenderer(renderer?: ColumnTypeRenderer | MappedValueTypeRenderer): FC<TableCellRendererProps> | undefined;
18
21
  export declare function getCellConfigPanelRenderer(name: string): FC<CellConfigPanelProps> | undefined;
22
+ export declare function getEditRuleValidator(name: string): EditRuleValidator | undefined;
19
23
  export {};
@@ -9,6 +9,6 @@ export declare const shallowEquals: (o1?: {
9
9
  }, o2?: {
10
10
  [key: string]: unknown;
11
11
  }) => boolean;
12
- export declare function getMovingValueDirection(newValue: number, direction?: valueChangeDirection, prevValue?: number,
12
+ export declare function getMovingValueDirection(newValue?: number, direction?: valueChangeDirection, prevValue?: number,
13
13
  /** the number of decimal places to take into account when highlighting a change */
14
14
  decimalPlaces?: number): valueChangeDirection;
@@ -1,5 +1,5 @@
1
1
  import { KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
2
- import { AndFilter, Filter, FilterClauseOp, MultiClauseFilter, MultiValueFilterClause, OrFilter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
2
+ import { AndFilter, Filter, FilterClauseOp, FilterWithPartialClause, MultiClauseFilter, MultiValueFilterClause, OrFilter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
3
3
  export declare const isValidFilterClauseOp: (op?: string) => op is FilterClauseOp;
4
4
  export declare const isNamedFilter: (f?: Filter) => boolean;
5
5
  export declare const isSingleValueFilter: (f?: Partial<Filter>) => f is SingleValueFilterClause<string | number | boolean>;
@@ -8,6 +8,7 @@ export declare const isMultiValueFilter: (f?: Partial<Filter>) => f is MultiValu
8
8
  export declare const isInFilter: (f: Partial<Filter>) => f is MultiValueFilterClause;
9
9
  export declare const isAndFilter: (f: Partial<Filter>) => f is AndFilter;
10
10
  export declare const isOrFilter: (f: Partial<Filter>) => f is OrFilter;
11
- export declare function isMultiClauseFilter(f?: Partial<Filter>): f is MultiClauseFilter;
11
+ export declare const isCompleteFilter: (filter: Partial<Filter>) => filter is Filter;
12
+ export declare function isMultiClauseFilter(f?: Partial<Filter> | FilterWithPartialClause): f is MultiClauseFilter;
12
13
  export declare const filterAsQuery: (f: Filter) => string;
13
14
  export declare const removeColumnFromFilter: (column: KeyedColumnDescriptor, filter: Filter) => [Filter | undefined, string];
@@ -5,5 +5,5 @@ export type ValueFormatters = {
5
5
  };
6
6
  export declare const defaultValueFormatter: (value: unknown) => string;
7
7
  export declare const dateFormatter: (column: ColumnDescriptor) => (value: unknown) => string;
8
- export declare const numericFormatter: ({ align, type, }: ColumnDescriptor) => (value: unknown) => string;
8
+ export declare const numericFormatter: ({ align, type, }: Partial<ColumnDescriptor>) => (value: unknown) => string;
9
9
  export declare const getValueFormatter: (column: ColumnDescriptor) => ValueFormatter;
@@ -1,3 +1,12 @@
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
+ export declare const getElementDataIndex: (el: HTMLElement | null) => number;
4
+ export declare const getClosest: (el: HTMLElement, dataProperty: string) => HTMLElement;
5
+ export declare const getClosestIndexItem: (el: HTMLElement) => HTMLElement;
6
+ export declare function getElementByDataIndex(c: HTMLElement | null, i: number | string, throwIfNotFound: true): HTMLElement;
7
+ export declare function getElementByDataIndex(c: HTMLElement | null, i: number | string, throwIfNotFound?: false): HTMLElement | undefined;
3
8
  export declare const focusFirstFocusableElement: (el: HTMLElement | null, tabIndex?: number) => void;
9
+ export declare const isSelectableElement: (el?: HTMLElement) => boolean;
10
+ export declare function getScrollbarSize(): number;
11
+ export type MouseEventTypes = "dblclick" | "click";
12
+ export declare const dispatchMouseEvent: (el: HTMLElement, type: MouseEventTypes) => void;
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./array-utils";
2
+ export * from "./box-utils";
2
3
  export * from "./column-utils";
3
4
  export * from "./cookie-utils";
4
5
  export * from "./component-registry";
@@ -30,3 +31,4 @@ export * from "./selection-utils";
30
31
  export * from "./sort-utils";
31
32
  export * from "./text-utils";
32
33
  export * from "./url-utils";
34
+ export * from "./screenshot-utils";
@@ -1,2 +1,2 @@
1
- export declare const isCharacterKey: (evt: KeyboardEvent) => boolean | undefined;
1
+ export declare const isCharacterKey: (key: string) => boolean;
2
2
  export declare const isQuoteKey: (evt: KeyboardEvent) => boolean;
@@ -8,6 +8,7 @@ interface FromToRange {
8
8
  from: number;
9
9
  to: number;
10
10
  }
11
+ export declare const NULL_RANGE: VuuRange;
11
12
  export declare function getFullRange({ from, to }: VuuRange, bufferSize?: number, rowCount?: number): FromToRange;
12
13
  export declare function resetRange({ from, to, bufferSize }: VuuRange): VuuRange;
13
14
  export declare const withinRange: (value: number, { from, to }: VuuRange) => boolean;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Takes a screenshot of the given node and returns the base64 encoded image url
3
+ * @param node Node to take screenshot of
4
+ * @returns Base64 encoded image url
5
+ */
6
+ export declare function takeScreenshot(node: HTMLElement): Promise<string | undefined>;
@@ -9,8 +9,17 @@ export declare const RowSelected: {
9
9
  export declare const isRowSelected: (row: DataSourceRow) => boolean;
10
10
  export declare const deselectItem: (selectionModel: TableSelectionModel, selected: Selection, itemIndex: number, rangeSelect: boolean, keepExistingSelection?: boolean) => Selection;
11
11
  export declare const selectItem: (selectionModel: TableSelectionModel, selected: Selection, itemIndex: number, rangeSelect: boolean, keepExistingSelection?: boolean, activeItemIndex?: number) => Selection;
12
+ /**
13
+ * Determine the value for selected. We use a bitmap to represent a number of selection states
14
+ * a row might exhibit. selected/not-selected is the fundamental value. We also identify first
15
+ * row of a selected block, last row of a selected block;
16
+ */
12
17
  export declare const getSelectionStatus: (selected: Selection, itemIndex: number) => number;
13
18
  export declare const isSelected: (selected: Selection, itemIndex: number) => boolean;
19
+ /**
20
+ * Vuu server expects a full list if indexes of selected rows. Client represents selection in a more
21
+ * efficient structure. This converts client structure to full server format.
22
+ */
14
23
  export declare const expandSelection: (selected: Selection) => number[];
15
24
  export type SelectionDiff = {
16
25
  added: SelectionItem[];
@@ -1 +1,2 @@
1
1
  export declare const lastWord: (text: string) => string;
2
+ export declare const wordify: (text: string) => string;