@vuu-ui/vuu-utils 0.6.10-debug → 0.6.11
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 +8 -6
- package/types/DataWindow.d.ts +39 -0
- package/types/array-utils.d.ts +4 -0
- package/types/column-utils.d.ts +55 -0
- package/types/component-registry.d.ts +19 -0
- package/types/data-utils.d.ts +9 -0
- package/types/date-utils.d.ts +1 -0
- package/types/event-emitter.d.ts +19 -0
- package/types/filter-utils.d.ts +8 -0
- package/types/formatting-utils.d.ts +8 -0
- package/types/getUniqueId.d.ts +1 -0
- package/types/group-utils.d.ts +3 -0
- package/types/html-utils.d.ts +1 -0
- package/types/index.d.ts +22 -0
- package/types/input-utils.d.ts +2 -0
- package/types/invariant.d.ts +1 -0
- package/types/logging-level.d.ts +1 -0
- package/types/logging-utils.d.ts +40 -0
- package/types/nanoid/index.d.ts +1 -0
- package/types/range-utils.d.ts +22 -0
- package/types/round-decimal.d.ts +1 -0
- package/types/row-utils.d.ts +10 -0
- package/types/selection-utils.d.ts +5 -0
- package/types/sort-utils.d.ts +5 -0
- package/types/text-utils.d.ts +1 -0
package/package.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data": "0.6.
|
|
7
|
-
"@vuu-ui/vuu-datagrid-types": "0.6.
|
|
8
|
-
"@vuu-ui/vuu-filter-types": "0.6.
|
|
9
|
-
"@vuu-ui/vuu-protocol-types": "0.6.
|
|
6
|
+
"@vuu-ui/vuu-data": "0.6.11",
|
|
7
|
+
"@vuu-ui/vuu-datagrid-types": "0.6.11",
|
|
8
|
+
"@vuu-ui/vuu-filter-types": "0.6.11",
|
|
9
|
+
"@vuu-ui/vuu-protocol-types": "0.6.11"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"react": "^17.0.2",
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"cjs",
|
|
17
|
-
"esm"
|
|
17
|
+
"esm",
|
|
18
|
+
"/types"
|
|
18
19
|
],
|
|
19
20
|
"module": "esm/index.js",
|
|
20
21
|
"main": "cjs/index.js",
|
|
21
|
-
"version": "0.6.
|
|
22
|
+
"version": "0.6.11",
|
|
23
|
+
"types": "types/index.d.ts"
|
|
22
24
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type DataItem = string | number | boolean;
|
|
2
|
+
export type DataRow = [
|
|
3
|
+
/** index */
|
|
4
|
+
number,
|
|
5
|
+
/** render index */
|
|
6
|
+
number,
|
|
7
|
+
/** isLeaf */
|
|
8
|
+
boolean,
|
|
9
|
+
/** isExpanded */
|
|
10
|
+
boolean,
|
|
11
|
+
/** depth */
|
|
12
|
+
number,
|
|
13
|
+
/** child count */
|
|
14
|
+
number,
|
|
15
|
+
/** key */
|
|
16
|
+
string,
|
|
17
|
+
/** selected */
|
|
18
|
+
number,
|
|
19
|
+
/** data values */
|
|
20
|
+
...DataItem[]
|
|
21
|
+
];
|
|
22
|
+
export type RangeLike = {
|
|
23
|
+
from: number;
|
|
24
|
+
to: number;
|
|
25
|
+
};
|
|
26
|
+
export declare class DataWindow {
|
|
27
|
+
private range;
|
|
28
|
+
data: DataRow[];
|
|
29
|
+
rowCount: number;
|
|
30
|
+
constructor({ from, to }: RangeLike);
|
|
31
|
+
setRowCount: (rowCount: number) => void;
|
|
32
|
+
add(data: DataRow): boolean;
|
|
33
|
+
getAtIndex(index: number): DataRow | undefined;
|
|
34
|
+
getByKey(key: string): DataRow | undefined;
|
|
35
|
+
isWithinRange(index: number): boolean;
|
|
36
|
+
setRange(from: number, to: number): void;
|
|
37
|
+
hasData(from: number, to: number): boolean;
|
|
38
|
+
getData(from: number, to: number): any[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type PartitionTest<T> = (value: T, index: number) => boolean;
|
|
2
|
+
export declare function partition<T>(array: T[], test: PartitionTest<T>, pass?: T[], fail?: T[]): [T[], T[]];
|
|
3
|
+
export declare function itemsChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
|
|
4
|
+
export declare const moveItem: <T = unknown>(items: T[], item: T, moveTo: number) => T[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ColumnDescriptor, ColumnType, ColumnTypeDescriptor, ColumnTypeSimple, GroupColumnDescriptor, KeyedColumnDescriptor, TableHeadings } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { VuuAggregation, VuuAggType, VuuColumnDataType, VuuGroupBy, VuuRowRecord, VuuSort } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { CSSProperties } from "react";
|
|
4
|
+
import { DataSourceRow } from "@vuu-ui/vuu-data";
|
|
5
|
+
import { DataSourceFilter } from "@vuu-ui/vuu-data-types";
|
|
6
|
+
import { Filter } from "@vuu-ui/vuu-filter-types";
|
|
7
|
+
export interface ColumnMap {
|
|
8
|
+
[columnName: string]: number;
|
|
9
|
+
}
|
|
10
|
+
export type SortCriteriaItem = string | [string, "asc"];
|
|
11
|
+
export declare const AggregationType: {
|
|
12
|
+
[key: string]: VuuAggType;
|
|
13
|
+
};
|
|
14
|
+
export declare function mapSortCriteria(sortCriteria: SortCriteriaItem[], columnMap: ColumnMap, metadataOffset?: number): [number, "asc"][];
|
|
15
|
+
export declare const isKeyedColumn: (column: ColumnDescriptor) => column is KeyedColumnDescriptor;
|
|
16
|
+
export declare const fromServerDataType: (serverDataType: VuuColumnDataType) => ColumnTypeSimple;
|
|
17
|
+
export declare const isNumericColumn: ({ serverDataType, type }: ColumnDescriptor) => boolean;
|
|
18
|
+
export declare const notHidden: (column: ColumnDescriptor) => boolean;
|
|
19
|
+
export declare const isPinned: (column: ColumnDescriptor) => boolean;
|
|
20
|
+
export declare const hasHeadings: (column: ColumnDescriptor) => boolean;
|
|
21
|
+
export declare const isResizing: (column: KeyedColumnDescriptor) => boolean | undefined;
|
|
22
|
+
export declare const isTextColumn: ({ serverDataType }: ColumnDescriptor) => boolean;
|
|
23
|
+
export declare const toColumnDescriptor: (name: string) => ColumnDescriptor;
|
|
24
|
+
export declare const isTypeDescriptor: (type?: ColumnType) => type is ColumnTypeDescriptor;
|
|
25
|
+
export declare function buildColumnMap(columns?: (KeyedColumnDescriptor | string)[]): ColumnMap;
|
|
26
|
+
export declare function projectUpdates(updates: number[]): number[];
|
|
27
|
+
export declare const metadataKeys: {
|
|
28
|
+
readonly IDX: 0;
|
|
29
|
+
readonly RENDER_IDX: 1;
|
|
30
|
+
readonly IS_LEAF: 2;
|
|
31
|
+
readonly IS_EXPANDED: 3;
|
|
32
|
+
readonly DEPTH: 4;
|
|
33
|
+
readonly COUNT: 5;
|
|
34
|
+
readonly KEY: 6;
|
|
35
|
+
readonly SELECTED: 7;
|
|
36
|
+
readonly count: 8;
|
|
37
|
+
readonly PARENT_IDX: "parent_idx";
|
|
38
|
+
readonly IDX_POINTER: "idx_pointer";
|
|
39
|
+
readonly FILTER_COUNT: "filter_count";
|
|
40
|
+
readonly NEXT_FILTER_IDX: "next_filter_idx";
|
|
41
|
+
};
|
|
42
|
+
export declare const flattenColumnGroup: (columns: KeyedColumnDescriptor[]) => KeyedColumnDescriptor[];
|
|
43
|
+
export declare function extractGroupColumn(columns: KeyedColumnDescriptor[], groupBy?: VuuGroupBy): [GroupColumnDescriptor | null, KeyedColumnDescriptor[]];
|
|
44
|
+
export declare const isGroupColumn: (column: KeyedColumnDescriptor) => column is GroupColumnDescriptor;
|
|
45
|
+
export declare const sortPinnedColumns: (columns: KeyedColumnDescriptor[]) => KeyedColumnDescriptor[];
|
|
46
|
+
export declare const getTableHeadings: (columns: KeyedColumnDescriptor[]) => TableHeadings;
|
|
47
|
+
export declare const getColumnPinStyle: (column: KeyedColumnDescriptor) => CSSProperties | undefined;
|
|
48
|
+
export declare const setAggregations: (aggregations: VuuAggregation[], column: KeyedColumnDescriptor, aggType: VuuAggType) => VuuAggregation[];
|
|
49
|
+
export declare const extractFilterForColumn: (filter: Filter | undefined, columnName: string) => Filter | undefined;
|
|
50
|
+
export declare const applyGroupByToColumns: (columns: KeyedColumnDescriptor[], groupBy: VuuGroupBy) => KeyedColumnDescriptor[];
|
|
51
|
+
export declare const applySortToColumns: (colunms: KeyedColumnDescriptor[], sort: VuuSort) => KeyedColumnDescriptor[];
|
|
52
|
+
export declare const applyFilterToColumns: (columns: KeyedColumnDescriptor[], { filterStruct }: DataSourceFilter) => KeyedColumnDescriptor[];
|
|
53
|
+
export declare const getColumnName: (name: string) => string;
|
|
54
|
+
export declare const toDataSourceColumns: (column: ColumnDescriptor) => string;
|
|
55
|
+
export declare const getRowRecord: (row: DataSourceRow, columnMap: ColumnMap) => VuuRowRecord;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FunctionComponent as FC, HTMLAttributes } from "react";
|
|
2
|
+
import { TableCellProps } from "@vuu-ui/vuu-datatable/src/TableCell";
|
|
3
|
+
import { VuuColumnDataType } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
export interface CellConfigPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
onConfigChange: () => void;
|
|
6
|
+
}
|
|
7
|
+
export type ComponentType = "cell-renderer" | "cell-config-panel";
|
|
8
|
+
type CellRendererOptions = {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
serverDataType?: VuuColumnDataType | VuuColumnDataType[];
|
|
11
|
+
};
|
|
12
|
+
export interface CellRendererDescriptor extends CellRendererOptions {
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
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(name?: string): FC<TableCellProps> | undefined;
|
|
18
|
+
export declare function getCellConfigPanelRenderer(name: string): FC<CellConfigPanelProps> | undefined;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type valueChangeDirection = "up1" | "up2" | "down1" | "down2" | "";
|
|
2
|
+
export declare const UP1 = "up1";
|
|
3
|
+
export declare const UP2 = "up2";
|
|
4
|
+
export declare const DOWN1 = "down1";
|
|
5
|
+
export declare const DOWN2 = "down2";
|
|
6
|
+
export declare const isValidNumber: (n: unknown) => n is number;
|
|
7
|
+
export declare function getMovingValueDirection(newValue: number, direction?: valueChangeDirection, prevValue?: number,
|
|
8
|
+
/** the number of decimal places to take into account when highlighting a change */
|
|
9
|
+
decimalPlaces?: number): valueChangeDirection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatDate: (date: Date, format: string) => string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Event {
|
|
2
|
+
}
|
|
3
|
+
export type EventListener = (evtName: string, ...args: any[]) => void;
|
|
4
|
+
export type EventListenerMap = {
|
|
5
|
+
[eventName: string]: EventListener[] | EventListener;
|
|
6
|
+
};
|
|
7
|
+
export interface IEventEmitter {
|
|
8
|
+
emit: (type: string, ...args: unknown[]) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class EventEmitter implements IEventEmitter {
|
|
11
|
+
private _events?;
|
|
12
|
+
constructor();
|
|
13
|
+
addListener(type: string, listener: EventListener): void;
|
|
14
|
+
removeListener(type: string, listener: EventListener): void;
|
|
15
|
+
removeAllListeners(type: string): void;
|
|
16
|
+
emit(type: string, ...args: unknown[]): void;
|
|
17
|
+
once(type: string, listener: EventListener): void;
|
|
18
|
+
on(type: string, listener: EventListener): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AndFilter, Filter, MultiClauseFilter, MultiValueFilterClause, OrFilter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
|
|
2
|
+
export declare const isSingleValueFilter: (f?: Partial<Filter>) => f is SingleValueFilterClause<string | number | boolean>;
|
|
3
|
+
export declare const isFilterClause: (f?: Partial<Filter>) => f is MultiValueFilterClause | SingleValueFilterClause<string | number | boolean>;
|
|
4
|
+
export declare const isMultiValueFilter: (f?: Partial<Filter>) => f is MultiValueFilterClause;
|
|
5
|
+
export declare const isInFilter: (f: Partial<Filter>) => f is MultiValueFilterClause;
|
|
6
|
+
export declare const isAndFilter: (f: Partial<Filter>) => f is AndFilter;
|
|
7
|
+
export declare const isOrFilter: (f: Partial<Filter>) => f is OrFilter;
|
|
8
|
+
export declare function isMultiClauseFilter(f?: Partial<Filter>): f is MultiClauseFilter;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
export type ValueFormatter = (value: unknown) => string;
|
|
3
|
+
export type ValueFormatters = {
|
|
4
|
+
[key: string]: ValueFormatter;
|
|
5
|
+
};
|
|
6
|
+
export declare const defaultValueFormatter: (value: unknown) => string;
|
|
7
|
+
export declare const numericFormatter: ({ align, type, }: ColumnDescriptor) => (value: unknown) => string;
|
|
8
|
+
export declare const getValueFormatter: (column: ColumnDescriptor) => ValueFormatter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getUniqueId: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createEl: (elementType: "div" | "p" | "span", className?: string, textContent?: string) => HTMLElement;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from "./array-utils";
|
|
2
|
+
export * from "./column-utils";
|
|
3
|
+
export * from "./component-registry";
|
|
4
|
+
export * from "./DataWindow";
|
|
5
|
+
export * from "./data-utils";
|
|
6
|
+
export * from "./date-utils";
|
|
7
|
+
export * from "./filter-utils";
|
|
8
|
+
export * from "./html-utils";
|
|
9
|
+
export * from "./event-emitter";
|
|
10
|
+
export * from "./formatting-utils";
|
|
11
|
+
export * from "./getUniqueId";
|
|
12
|
+
export * from "./group-utils";
|
|
13
|
+
export * from "./input-utils";
|
|
14
|
+
export * from "./invariant";
|
|
15
|
+
export * from "./nanoid";
|
|
16
|
+
export * from "./round-decimal";
|
|
17
|
+
export * from "./range-utils";
|
|
18
|
+
export * from "./row-utils";
|
|
19
|
+
export * from "./selection-utils";
|
|
20
|
+
export * from "./sort-utils";
|
|
21
|
+
export * from "./text-utils";
|
|
22
|
+
export * from "./logging-utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function invariant(condition: boolean, message: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const loggingLevel: (level: string) => void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface LogFn {
|
|
2
|
+
(message?: unknown, ...optionalParams: unknown[]): void;
|
|
3
|
+
}
|
|
4
|
+
export interface AssertLogFn {
|
|
5
|
+
(condition: boolean, message?: unknown, errorMessaage?: unknown): void;
|
|
6
|
+
}
|
|
7
|
+
export interface TableLogFn {
|
|
8
|
+
(properties?: object): void;
|
|
9
|
+
}
|
|
10
|
+
export interface Logger {
|
|
11
|
+
log: LogFn;
|
|
12
|
+
warn: LogFn;
|
|
13
|
+
error: LogFn;
|
|
14
|
+
group: LogFn;
|
|
15
|
+
groupCollapsed: LogFn;
|
|
16
|
+
groupEnd: LogFn;
|
|
17
|
+
assert: AssertLogFn;
|
|
18
|
+
trace: LogFn;
|
|
19
|
+
debug: LogFn;
|
|
20
|
+
info: LogFn;
|
|
21
|
+
table: TableLogFn;
|
|
22
|
+
}
|
|
23
|
+
export type BuildEnv = 'production' | 'development';
|
|
24
|
+
export declare class ConsoleLogger implements Logger {
|
|
25
|
+
readonly log: LogFn;
|
|
26
|
+
readonly warn: LogFn;
|
|
27
|
+
readonly error: LogFn;
|
|
28
|
+
readonly group: LogFn;
|
|
29
|
+
readonly groupCollapsed: LogFn;
|
|
30
|
+
readonly groupEnd: LogFn;
|
|
31
|
+
readonly assert: AssertLogFn;
|
|
32
|
+
readonly trace: LogFn;
|
|
33
|
+
readonly debug: LogFn;
|
|
34
|
+
readonly info: LogFn;
|
|
35
|
+
readonly table: TableLogFn;
|
|
36
|
+
constructor(options?: {
|
|
37
|
+
buildEnv?: string;
|
|
38
|
+
}, level?: string);
|
|
39
|
+
}
|
|
40
|
+
export declare const logger: ConsoleLogger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uuid: (size?: number) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface VuuRange {
|
|
2
|
+
from: number;
|
|
3
|
+
to: number;
|
|
4
|
+
bufferSize?: number;
|
|
5
|
+
reset?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface FromToRange {
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function getFullRange({ from, to }: VuuRange, bufferSize?: number, rowCount?: number): FromToRange;
|
|
12
|
+
export declare function resetRange({ from, to, bufferSize }: VuuRange): VuuRange;
|
|
13
|
+
export declare const withinRange: (value: number, { from, to }: VuuRange) => boolean;
|
|
14
|
+
export declare class WindowRange {
|
|
15
|
+
from: number;
|
|
16
|
+
to: number;
|
|
17
|
+
constructor(from: number, to: number);
|
|
18
|
+
isWithin(index: number): boolean;
|
|
19
|
+
overlap(from: number, to: number): [number, number];
|
|
20
|
+
copy(): WindowRange;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function roundDecimal(value?: number, align?: string, decimals?: number, zeroPad?: boolean, alignOnDecimals?: boolean): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type RowIndex = {
|
|
2
|
+
[field: string]: number;
|
|
3
|
+
};
|
|
4
|
+
export type Row = {
|
|
5
|
+
[strKey: string]: any;
|
|
6
|
+
} & any[];
|
|
7
|
+
export declare function addRowsToIndex(rows: Row[], index: RowIndex, indexField: string): RowIndex;
|
|
8
|
+
export declare function indexRows(rows: Row[], indexField: string): RowIndex;
|
|
9
|
+
export declare function isEmptyRow(row: Row): boolean;
|
|
10
|
+
export declare function update(rows: Row[], updates: any): Row[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Selection, TableSelectionModel } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
export declare const deselectItem: (selectionModel: TableSelectionModel, selected: Selection, itemIndex: number, rangeSelect: boolean, keepExistingSelection?: boolean) => Selection;
|
|
3
|
+
export declare const selectItem: (selectionModel: TableSelectionModel, selected: Selection, itemIndex: number, rangeSelect: boolean, keepExistingSelection?: boolean, activeItemIndex?: number) => Selection;
|
|
4
|
+
export declare const isSelected: (selected: Selection, itemIndex: number) => boolean;
|
|
5
|
+
export declare const expandSelection: (selected: Selection) => number[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ColumnDescriptor, KeyedColumnDescriptor } from "@vuu-ui/vuu-datagrid-types";
|
|
2
|
+
import { VuuSort, VuuSortType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
export declare const applySort: ({ sortDefs }: VuuSort, { name: column }: ColumnDescriptor, extendSort?: boolean, sortType?: VuuSortType) => VuuSort;
|
|
4
|
+
export declare const setSortColumn: ({ sortDefs }: VuuSort, column: KeyedColumnDescriptor, sortType?: "A" | "D") => VuuSort;
|
|
5
|
+
export declare const addSortColumn: ({ sortDefs }: VuuSort, column: KeyedColumnDescriptor, sortType?: "A" | "D") => VuuSort;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const lastWord: (text: string) => string;
|