@vuu-ui/vuu-utils 0.13.4 → 0.13.6

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.
Files changed (86) hide show
  1. package/cjs/datasource/BaseDataSource.js +4 -0
  2. package/cjs/datasource/BaseDataSource.js.map +1 -1
  3. package/cjs/moving-window.js +0 -2
  4. package/cjs/moving-window.js.map +1 -1
  5. package/cjs/range-utils.js +0 -3
  6. package/cjs/range-utils.js.map +1 -1
  7. package/esm/datasource/BaseDataSource.js +4 -0
  8. package/esm/datasource/BaseDataSource.js.map +1 -1
  9. package/esm/moving-window.js +0 -2
  10. package/esm/moving-window.js.map +1 -1
  11. package/esm/range-utils.js +0 -3
  12. package/esm/range-utils.js.map +1 -1
  13. package/package.json +11 -9
  14. package/types/DataWindow.d.ts +39 -0
  15. package/types/ShellContext.d.ts +11 -0
  16. package/types/ThemeProvider.d.ts +32 -0
  17. package/types/array-utils.d.ts +8 -0
  18. package/types/box-utils.d.ts +24 -0
  19. package/types/broadcast-channel.d.ts +16 -0
  20. package/types/column-utils.d.ts +175 -0
  21. package/types/common-types.d.ts +6 -0
  22. package/types/component-registry.d.ts +62 -0
  23. package/types/context-definitions/DataContext.d.ts +19 -0
  24. package/types/context-definitions/DataProvider.d.ts +8 -0
  25. package/types/context-definitions/DataSourceProvider.d.ts +12 -0
  26. package/types/context-definitions/WorkspaceContext.d.ts +17 -0
  27. package/types/cookie-utils.d.ts +1 -0
  28. package/types/css-utils.d.ts +1 -0
  29. package/types/data-utils.d.ts +19 -0
  30. package/types/datasource/BaseDataSource.d.ts +46 -0
  31. package/types/datasource/datasource-action-utils.d.ts +7 -0
  32. package/types/datasource/datasource-filter-utils.d.ts +2 -0
  33. package/types/datasource/datasource-utils.d.ts +45 -0
  34. package/types/date/date-utils.d.ts +2 -0
  35. package/types/date/dateTimePattern.d.ts +8 -0
  36. package/types/date/formatter.d.ts +4 -0
  37. package/types/date/index.d.ts +4 -0
  38. package/types/date/types.d.ts +24 -0
  39. package/types/debug-utils.d.ts +9 -0
  40. package/types/event-emitter.d.ts +21 -0
  41. package/types/feature-utils.d.ts +104 -0
  42. package/types/filters/filter-utils.d.ts +69 -0
  43. package/types/filters/filterAsQuery.d.ts +7 -0
  44. package/types/filters/index.d.ts +2 -0
  45. package/types/form-utils.d.ts +22 -0
  46. package/types/formatting-utils.d.ts +14 -0
  47. package/types/getUniqueId.d.ts +1 -0
  48. package/types/group-utils.d.ts +10 -0
  49. package/types/html-utils.d.ts +21 -0
  50. package/types/index.d.ts +67 -0
  51. package/types/input-utils.d.ts +2 -0
  52. package/types/invariant.d.ts +1 -0
  53. package/types/itemToString.d.ts +2 -0
  54. package/types/json-types.d.ts +52 -0
  55. package/types/json-utils.d.ts +6 -0
  56. package/types/keyboard-utils.d.ts +15 -0
  57. package/types/keyset.d.ts +12 -0
  58. package/types/layout-types.d.ts +22 -0
  59. package/types/list-utils.d.ts +2 -0
  60. package/types/local-storage-utils.d.ts +3 -0
  61. package/types/logging-utils.d.ts +45 -0
  62. package/types/menu-utils.d.ts +6 -0
  63. package/types/module-utils.d.ts +8 -0
  64. package/types/moving-window.d.ts +18 -0
  65. package/types/nanoid/index.d.ts +1 -0
  66. package/types/perf-utils.d.ts +5 -0
  67. package/types/promise-utils.d.ts +8 -0
  68. package/types/protocol-message-utils.d.ts +28 -0
  69. package/types/range-utils.d.ts +31 -0
  70. package/types/react-utils.d.ts +4 -0
  71. package/types/round-decimal.d.ts +1 -0
  72. package/types/row-utils.d.ts +24 -0
  73. package/types/selection-utils.d.ts +29 -0
  74. package/types/shell-layout-types.d.ts +14 -0
  75. package/types/sort-utils.d.ts +11 -0
  76. package/types/table-schema-utils.d.ts +3 -0
  77. package/types/text-utils.d.ts +2 -0
  78. package/types/tree-types.d.ts +8 -0
  79. package/types/tree-utils.d.ts +9 -0
  80. package/types/ts-utils.d.ts +19 -0
  81. package/types/typeahead-utils.d.ts +1 -0
  82. package/types/url-utils.d.ts +2 -0
  83. package/types/useId.d.ts +1 -0
  84. package/types/useLayoutEffectSkipFirst.d.ts +2 -0
  85. package/types/useStateRef.d.ts +2 -0
  86. package/types/user-types.d.ts +4 -0
@@ -0,0 +1,175 @@
1
+ import type { DataSourceRow, DataValueType, DataValueTypeSimple, DateTimeDataValueDescriptor, SchemaColumn, TableSchema } from "@vuu-ui/vuu-data-types";
2
+ import type { VuuAggType, VuuAggregation, VuuColumnDataType, VuuDataRow, VuuDataRowDto, VuuGroupBy, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
+ import type { ColumnAlignment, ColumnDescriptor, ColumnLayout, DataValueTypeDescriptor, ColumnTypeFormatting, ColumnTypeRendering, ColumnTypeWithValidationRules, DefaultColumnConfiguration, GroupColumnDescriptor, LookupRenderer, MappedValueTypeRenderer, PinLocation, RuntimeColumnDescriptor, TableCellRendererProps, TableConfig, TableHeadings, ValueListRenderer } from "@vuu-ui/vuu-table-types";
4
+ import { type CSSProperties } from "react";
5
+ import { TableModel } from "@vuu-ui/vuu-table";
6
+ /**
7
+ * ColumnMap provides a lookup of the index position of a data item within a row
8
+ * by column name.
9
+ */
10
+ export interface ColumnMap {
11
+ [columnName: string]: number;
12
+ }
13
+ export type SortCriteriaItem = string | [string, "asc"];
14
+ export declare const AggregationType: {
15
+ [key: string]: VuuAggType;
16
+ };
17
+ export declare function mapSortCriteria(sortCriteria: SortCriteriaItem[], columnMap: ColumnMap, metadataOffset?: number): [number, "asc"][];
18
+ export declare const getDefaultAlignment: (serverDataType?: VuuColumnDataType) => ColumnAlignment;
19
+ export declare const getRuntimeColumnWidth: (col: ColumnDescriptor, runtimeColumns: RuntimeColumnDescriptor[]) => number;
20
+ export declare const applyRuntimeColumnWidthsToConfig: (tableConfig: TableConfig, columns: RuntimeColumnDescriptor[]) => TableConfig;
21
+ export declare const isValidColumnAlignment: (v: string) => v is ColumnAlignment;
22
+ export declare const isValidPinLocation: (v: string) => v is PinLocation;
23
+ export type CalculatedColumn = {
24
+ name: string;
25
+ expression: string;
26
+ serverDataType: VuuColumnDataType;
27
+ };
28
+ export declare const isVuuColumnDataType: (value: string | undefined | null) => value is VuuColumnDataType;
29
+ export declare const fromServerDataType: (serverDataType: VuuColumnDataType) => DataValueTypeSimple;
30
+ export declare const isNumericColumn: ({ serverDataType, type }: ColumnDescriptor) => boolean;
31
+ export declare const isDateTimeDataValue: (column: ColumnDescriptor) => column is DateTimeDataValueDescriptor;
32
+ export declare const isPinned: (column: ColumnDescriptor) => boolean;
33
+ export declare const hasHeadings: (column: ColumnDescriptor) => boolean;
34
+ export declare const isResizing: (column: RuntimeColumnDescriptor) => boolean | undefined;
35
+ export declare const isTextColumn: ({ serverDataType }: ColumnDescriptor) => boolean;
36
+ export declare const toColumnDescriptor: (name: string) => ColumnDescriptor;
37
+ /**
38
+ *
39
+ */
40
+ export declare const isTypeDescriptor: (type?: DataValueType) => type is DataValueTypeDescriptor;
41
+ export declare const isColumnTypeRenderer: (renderer?: unknown) => renderer is ColumnTypeRendering;
42
+ export declare const hasCustomRenderer: (type?: DataValueType) => type is DataValueTypeDescriptor;
43
+ export declare const isLookupRenderer: (renderer?: unknown) => renderer is LookupRenderer;
44
+ export declare const isValueListRenderer: (renderer?: unknown) => renderer is ValueListRenderer;
45
+ export declare const hasValidationRules: (type?: DataValueType) => type is ColumnTypeWithValidationRules;
46
+ export declare const isMappedValueTypeRenderer: (renderer?: unknown) => renderer is MappedValueTypeRenderer;
47
+ export declare function buildColumnMap(columns?: (ColumnDescriptor | SchemaColumn | string)[]): ColumnMap;
48
+ export declare function projectUpdates(updates: number[]): number[];
49
+ export declare const metadataKeys: {
50
+ readonly IDX: 0;
51
+ readonly RENDER_IDX: 1;
52
+ readonly IS_LEAF: 2;
53
+ readonly IS_EXPANDED: 3;
54
+ readonly DEPTH: 4;
55
+ readonly COUNT: 5;
56
+ readonly KEY: 6;
57
+ readonly SELECTED: 7;
58
+ readonly count: 8;
59
+ readonly PARENT_IDX: "parent_idx";
60
+ readonly IDX_POINTER: "idx_pointer";
61
+ readonly FILTER_COUNT: "filter_count";
62
+ readonly NEXT_FILTER_IDX: "next_filter_idx";
63
+ };
64
+ export declare const flattenColumnGroup: (columns: RuntimeColumnDescriptor[]) => RuntimeColumnDescriptor[];
65
+ export declare function extractGroupColumn({ availableWidth, columns, groupBy, confirmed, }: ColumnGroupProps): [
66
+ GroupColumnDescriptor | null,
67
+ RuntimeColumnDescriptor[]
68
+ ];
69
+ export declare const isGroupColumn: (column: RuntimeColumnDescriptor) => column is GroupColumnDescriptor;
70
+ /**
71
+ * groupConfirmed is currently the only 'pending' attribute we use. A
72
+ * value of true is only reset by a follow-up value of false. Intermediary
73
+ * values of undefined are discounted.
74
+ */
75
+ export declare const checkConfirmationPending: (previousConfig?: TableModel) => boolean | undefined;
76
+ export declare const isJsonAttribute: (value: unknown) => boolean;
77
+ export declare const isJsonGroup: (column: RuntimeColumnDescriptor, row: VuuDataRow, columnMap: ColumnMap) => boolean;
78
+ export declare const isJsonColumn: (column: RuntimeColumnDescriptor) => boolean;
79
+ export declare const sortPinnedColumns: (columns: RuntimeColumnDescriptor[]) => RuntimeColumnDescriptor[];
80
+ export declare const measurePinnedColumns: (columns: RuntimeColumnDescriptor[], selectionEndSize: number) => {
81
+ pinnedWidthLeft: number;
82
+ pinnedWidthRight: number;
83
+ unpinnedWidth: number;
84
+ };
85
+ export declare const getTableHeadings: (columns: RuntimeColumnDescriptor[]) => TableHeadings;
86
+ export declare const getColumnStyle: ({ pin, pinnedOffset, width, }: RuntimeColumnDescriptor) => CSSProperties;
87
+ export declare const setAggregations: (aggregations: VuuAggregation[], column: ColumnDescriptor, aggType: VuuAggType) => VuuAggregation[];
88
+ export type ColumnGroupProps = {
89
+ columns: RuntimeColumnDescriptor[];
90
+ groupBy: VuuGroupBy;
91
+ confirmed?: boolean;
92
+ availableWidth: number;
93
+ };
94
+ export declare const applyGroupByToColumns: (props: ColumnGroupProps) => RuntimeColumnDescriptor[];
95
+ export declare const applySortToColumns: (columns: RuntimeColumnDescriptor[], sort: VuuSort) => RuntimeColumnDescriptor[];
96
+ export declare const removeSort: (columns: RuntimeColumnDescriptor[]) => RuntimeColumnDescriptor[];
97
+ export declare const existingSort: (columns: RuntimeColumnDescriptor[]) => boolean;
98
+ export declare const getColumnName: (name: string) => string;
99
+ export declare const getColumnLabel: (column: ColumnDescriptor) => string;
100
+ export declare const findColumn: (columns: RuntimeColumnDescriptor[], columnName: string) => RuntimeColumnDescriptor | undefined;
101
+ export declare function updateColumn<T extends ColumnDescriptor>(columns: T[], column: T): T[];
102
+ export declare function updateColumn(columns: RuntimeColumnDescriptor[], column: string, options: Partial<ColumnDescriptor>): RuntimeColumnDescriptor[];
103
+ export declare const toDataSourceColumns: (column: ColumnDescriptor) => string;
104
+ export declare const dataSourceRowToDataRowDto: (row: DataSourceRow, columnMap: ColumnMap) => VuuDataRowDto;
105
+ export declare const isDataLoading: (columns: RuntimeColumnDescriptor[]) => boolean;
106
+ export declare const getColumnsInViewport: (columns: RuntimeColumnDescriptor[], vpStart: number, vpEnd: number) => [RuntimeColumnDescriptor[], number];
107
+ export declare const isNotHidden: (column: RuntimeColumnDescriptor) => boolean;
108
+ export declare const visibleColumnAtIndex: (columns: RuntimeColumnDescriptor[], index: number) => RuntimeColumnDescriptor | undefined;
109
+ export declare const getGroupIcon: (columns: RuntimeColumnDescriptor[], row: DataSourceRow) => string | undefined;
110
+ export declare const getGroupValue: (columns: RuntimeColumnDescriptor[], row: DataSourceRow, columnMap: ColumnMap) => string | null;
111
+ export declare const getDefaultColumnType: (serverDataType?: VuuColumnDataType) => DataValueTypeSimple;
112
+ export declare const updateColumnFormatting: <T extends ColumnDescriptor = ColumnDescriptor>(column: T, formatting: ColumnTypeFormatting) => T;
113
+ export declare function updateColumnType<T extends ColumnDescriptor = ColumnDescriptor>(column: T, type: DataValueTypeSimple): T;
114
+ export declare const updateColumnRenderProps: <T extends ColumnDescriptor = ColumnDescriptor>(column: T, renderer: ColumnTypeRendering) => T;
115
+ export declare const getTypeFormattingFromColumn: (column: ColumnDescriptor) => ColumnTypeFormatting;
116
+ /**
117
+ * Return a filter predicate that will reject columns, names of which
118
+ * are not in provided list. Exception made for columns explicitly
119
+ * configured as client columns.
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) => Partial<CalculatedColumn>;
125
+ export declare const setCalculatedColumnName: (column: ColumnDescriptor, name: string) => ColumnDescriptor;
126
+ export declare const setCalculatedColumnType: (column: ColumnDescriptor, type: string) => ColumnDescriptor;
127
+ export declare const setCalculatedColumnExpression: (column: ColumnDescriptor, expression: string) => ColumnDescriptor;
128
+ export declare const moveColumnTo: (columns: ColumnDescriptor[], column: ColumnDescriptor, newIndex: number) => ColumnDescriptor[];
129
+ export declare function replaceColumn<C extends ColumnDescriptor = RuntimeColumnDescriptor>(columns: C[], column: C): C[];
130
+ export declare const applyDefaultColumnConfig: ({ columns, table }: TableSchema, getDefaultColumnConfig?: DefaultColumnConfiguration) => SchemaColumn[];
131
+ export type columnOptions = {
132
+ availableWidth?: number;
133
+ columnLayout?: ColumnLayout;
134
+ defaultWidth?: number;
135
+ defaultMinWidth?: number;
136
+ defaultMaxWidth?: number;
137
+ defaultFlex?: number;
138
+ };
139
+ type ColumnLayoutOptions = Pick<columnOptions, "defaultMinWidth" | "defaultMaxWidth" | "defaultWidth">;
140
+ interface StaticColumnLayoutOptions extends ColumnLayoutOptions {
141
+ columnLayout: "manual" | "static";
142
+ }
143
+ interface FitColumnLayoutOptions extends ColumnLayoutOptions {
144
+ availableWidth?: number;
145
+ columnLayout: "fit";
146
+ }
147
+ export declare function applyWidthToColumns(columns: RuntimeColumnDescriptor[], options: StaticColumnLayoutOptions | FitColumnLayoutOptions): RuntimeColumnDescriptor[];
148
+ /**
149
+ * A memo compare function for cell renderers. Can be used to suppress
150
+ * render where column and data are both unchanged. Avoids render
151
+ * when row changes, where changes in row are unrelated to this cell.
152
+ * Suitabnle only for readonly cell renderers. See below for editable
153
+ * cell renderers.
154
+ */
155
+ export declare const dataAndColumnUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
156
+ /**
157
+ * A memo compare function for cell renderers. Can be used to suppress
158
+ * render where column, row key and data are all unchanged. Avoids render
159
+ * when row changes, where changes in row are unrelated to this cell.
160
+ * Suitable for editable cells. Including key in compare is not strictly
161
+ * necessary for rendering, but it is important in the event that user
162
+ * edits data - ensures we never have a stale key.
163
+ */
164
+ export declare const dataColumnAndKeyUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
165
+ export declare const toColumnName: (column: ColumnDescriptor) => string;
166
+ export declare const isStringColumn: (column: ColumnDescriptor) => boolean;
167
+ /**
168
+ * Given an ordered list of column names, return column items in same order
169
+ */
170
+ export declare const reorderColumnItems: <T extends {
171
+ name: string;
172
+ } = {
173
+ name: string;
174
+ }>(columnItems: Array<T>, orderedNames: string[]) => T[];
175
+ export {};
@@ -0,0 +1,6 @@
1
+ export type orientationType = "horizontal" | "vertical";
2
+ type measureProp = keyof DOMRect;
3
+ type measureType = Record<string, measureProp>;
4
+ type measuresType = Record<orientationType, measureType>;
5
+ export declare const MEASURES: measuresType;
6
+ export {};
@@ -0,0 +1,62 @@
1
+ import { DataSourceRow, EditRuleValidator } from "@vuu-ui/vuu-data-types";
2
+ import { VuuColumnDataType } from "@vuu-ui/vuu-protocol-types";
3
+ import { ColumnDescriptor, ColumnDescriptorCustomRenderer, ColumnTypeRendering, HeaderCellProps, TableCellRendererProps } from "@vuu-ui/vuu-table-types";
4
+ import { FunctionComponent as FC, HTMLAttributes } from "react";
5
+ import { ColumnMap } from "./column-utils";
6
+ export interface CellConfigPanelProps extends HTMLAttributes<HTMLDivElement> {
7
+ onConfigChange: () => void;
8
+ }
9
+ export type PropertyChangeHandler = (propertyName: string, propertyValue: string | number | boolean) => void;
10
+ export type ColumnRenderPropsChangeHandler = (renderProps: ColumnTypeRendering) => void;
11
+ export interface ConfigurationEditorProps {
12
+ column: ColumnDescriptorCustomRenderer;
13
+ onChangeRendering: ColumnRenderPropsChangeHandler;
14
+ }
15
+ export type RowClassNameGenerator = (row: DataSourceRow, columnMap: ColumnMap) => string | undefined;
16
+ export type RowClassGenerator = {
17
+ id: string;
18
+ fn: RowClassNameGenerator;
19
+ };
20
+ export type ConfigEditorComponent = FC<CellConfigPanelProps>;
21
+ export type layoutComponentType = "container" | "view";
22
+ export type ComponentType = layoutComponentType | "cell-renderer" | "cell-config-panel" | "column-header-content-renderer" | "column-header-label-renderer" | "component" | "data-edit-validator" | "row-class-generator";
23
+ type CellRendererOptions = {
24
+ configEditor?: string;
25
+ description?: string;
26
+ label?: string;
27
+ serverDataType?: VuuColumnDataType | VuuColumnDataType[] | "json" | "private";
28
+ userCanAssign?: boolean;
29
+ };
30
+ export interface CellRendererDescriptor extends CellRendererOptions {
31
+ name: string;
32
+ }
33
+ /**
34
+ * This check is performed during construction of UI from JSON. If component
35
+ * is not registered, it will log a warning.
36
+ */
37
+ export declare const isContainer: (componentType: string) => boolean;
38
+ /**
39
+ * This check is performed during construction of UI from JSON. If component
40
+ * is not registered, it will log a warning.
41
+ */
42
+ export declare const isView: (componentType: string) => boolean;
43
+ /**
44
+ * This check is performed during construction of UI from JSON. If component
45
+ * is not registered, it will log a warning.
46
+ */
47
+ export declare const isLayoutComponent: (componentType: string) => componentType is layoutComponentType;
48
+ export declare function registerComponent(componentName: string, component: RowClassGenerator, componentType: "row-class-generator", options?: CellRendererOptions): void;
49
+ export declare function registerComponent(componentName: string, component: EditRuleValidator, componentType: "data-edit-validator", options?: CellRendererOptions): void;
50
+ export declare function registerComponent(componentName: string, component: FC<any>, componentType: Omit<ComponentType, "data-edit-validator" | "row-class-generator">, options?: CellRendererOptions): void;
51
+ export declare const registerConfigurationEditor: (componentName: string, configurationEditor: FC<ConfigurationEditorProps>) => void;
52
+ export declare const getRegisteredCellRenderers: (serverDataType?: VuuColumnDataType | "json") => CellRendererDescriptor[];
53
+ export declare const getLayoutComponent: (componentName: string) => FC<any>;
54
+ export declare const getCellRendererOptions: (renderName: string) => CellRendererOptions | undefined;
55
+ export declare function getCellRenderer(column: ColumnDescriptor): FC<TableCellRendererProps> | undefined;
56
+ export declare function getColumnHeaderContentRenderer(column: ColumnDescriptor): FC<HeaderCellProps> | undefined;
57
+ export declare function getColumnHeaderLabelRenderer(column: ColumnDescriptor): FC<HeaderCellProps> | undefined;
58
+ export declare const getRowClassNameGenerator: (generatorId: string) => RowClassGenerator | undefined;
59
+ export declare function getConfigurationEditor(configEditor?: string): FC<ConfigurationEditorProps> | undefined;
60
+ export declare function getCellConfigPanelRenderer(name: string): ConfigEditorComponent | undefined;
61
+ export declare function getEditRuleValidator(name: string): EditRuleValidator | undefined;
62
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { DataSource, DataSourceConstructorProps, ServerAPI, TableSchema } from "@vuu-ui/vuu-data-types";
2
+ export type DataSourceConstructor = {
3
+ new (props: DataSourceConstructorProps): DataSource;
4
+ };
5
+ export interface DataContextProps {
6
+ VuuDataSource: DataSourceConstructor;
7
+ dataSourceExtensions?: unknown;
8
+ isLocalData: boolean;
9
+ getServerAPI: () => Promise<Pick<ServerAPI, "getTableList" | "getTableSchema" | "rpcCall">>;
10
+ /**
11
+ * A tableSchema would normally be requested via the serverAPI.
12
+ * schemas can be injected, in which case these 'local' schemas
13
+ * will be returned from the getTableSchema API call.
14
+ * The key is formed from concatenation of module and tableName
15
+ * from VuuTable e.g 'SIMUL:instruments'
16
+ */
17
+ tableSchemas?: Record<string, TableSchema>;
18
+ }
19
+ export declare const DataContext: import("react").Context<DataContextProps>;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ import { DataContextProps } from "./DataContext";
3
+ export declare const DataProvider: ({ children, getServerAPI, isLocalData, VuuDataSource, }: Omit<DataContextProps, "isLocalData"> & {
4
+ children: ReactNode;
5
+ isLocalData?: boolean;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const useData: () => DataContextProps;
8
+ export declare const useDataSourceExtensions: () => unknown;
@@ -0,0 +1,12 @@
1
+ import { DataSource } from "@vuu-ui/vuu-data-types";
2
+ import { ReactNode } from "react";
3
+ export interface DataSourceContextProps {
4
+ dataSource?: DataSource;
5
+ }
6
+ export declare const DataSourceContext: import("react").Context<DataSourceContextProps>;
7
+ export declare const DataSourceProvider: ({ children, dataSource, }: {
8
+ children: ReactNode;
9
+ dataSource: DataSource;
10
+ }) => import("react/jsx-runtime").JSX.Element;
11
+ export declare function useDataSource(throwIfNoDataSource: true): DataSource;
12
+ export declare function useDataSource(throwIfNoDataSource: false | undefined): DataSource | undefined;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { ApplicationSetting, ApplicationSettings, LayoutJSON } from "../json-types";
3
+ import { LayoutMetadata, LayoutMetadataDto } from "../layout-types";
4
+ export interface WorkspaceContextProps {
5
+ layoutMetadata: LayoutMetadata[];
6
+ layoutPlaceholderJSON?: LayoutJSON;
7
+ getApplicationSettings: (key?: keyof ApplicationSettings) => ApplicationSettings | ApplicationSetting | undefined;
8
+ loadLayoutById: (id: string) => void;
9
+ saveApplicationSettings: (settings: ApplicationSettings | ApplicationSetting, key?: keyof ApplicationSettings) => void;
10
+ saveLayout: (n: LayoutMetadataDto) => void;
11
+ saveApplicationLayout: (layout: LayoutJSON) => void;
12
+ workspaceJSON?: LayoutJSON | LayoutJSON[];
13
+ }
14
+ export declare const WorkspaceContext: React.Context<WorkspaceContextProps>;
15
+ export declare const usePlaceholderJSON: () => LayoutJSON<{
16
+ [key: string]: any;
17
+ }> | undefined;
@@ -0,0 +1 @@
1
+ export declare const getCookieValue: (name: string) => string | number | undefined;
@@ -0,0 +1 @@
1
+ export declare const importCSS: (path: string) => Promise<CSSStyleSheet>;
@@ -0,0 +1,19 @@
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 stringIsValidInt: (val: string) => boolean;
7
+ export declare const stringIsValidDecimal: (val: string) => boolean;
8
+ export declare const stringIsValidNumber: (val: string) => boolean;
9
+ export declare const numericTypeOfStringValue: (val: string) => "int" | "double" | "NaN";
10
+ export declare const isValidNumber: (n: unknown) => n is number;
11
+ export declare const shallowEquals: (o1?: {
12
+ [key: string]: unknown;
13
+ }, o2?: {
14
+ [key: string]: unknown;
15
+ }) => boolean;
16
+ export declare function getMovingValueDirection(newValue?: number, direction?: valueChangeDirection, prevValue?: number,
17
+ /** the number of decimal places to take into account when highlighting a change */
18
+ decimalPlaces?: number): valueChangeDirection;
19
+ export declare function asInteger(index: number | string | undefined, defaultValue?: number): number;
@@ -0,0 +1,46 @@
1
+ import type { DataSource, DataSourceConfig, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceSubscribeCallback, DataSourceSubscribeProps, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
+ import { LinkDescriptorWithLabel, VuuAggregation, VuuRange, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
+ import { EventEmitter } from "../event-emitter";
4
+ import { DataSourceConfigChanges } from "./datasource-utils";
5
+ import { Range } from "../range-utils";
6
+ export type RuntimeConfig = WithBaseFilter<WithFullConfig> & {
7
+ visualLink?: LinkDescriptorWithLabel;
8
+ };
9
+ export declare abstract class BaseDataSource extends EventEmitter<DataSourceEvents> implements Pick<DataSource, "config"> {
10
+ #private;
11
+ viewport: string;
12
+ protected _clientCallback: DataSourceSubscribeCallback | undefined;
13
+ protected _config: RuntimeConfig;
14
+ protected _impendingConfig: RuntimeConfig | undefined;
15
+ protected _range: Range;
16
+ protected _size: number;
17
+ protected _title: string | undefined;
18
+ private awaitingConfirmationOfConfigChanges;
19
+ constructor({ aggregations, baseFilterSpec, columns, filterSpec, groupBy, sort, title, viewport, }: Omit<DataSourceConstructorProps, "table">);
20
+ subscribe({ baseFilterSpec, columns, aggregations, range, sort, groupBy, filterSpec, viewport, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): void;
21
+ get aggregations(): VuuAggregation[];
22
+ set aggregations(aggregations: VuuAggregation[]);
23
+ get baseFilter(): DataSourceFilter | undefined;
24
+ set baseFilter(baseFilter: DataSourceFilter | undefined);
25
+ get columns(): string[];
26
+ set columns(columns: string[]);
27
+ get filter(): DataSourceFilter;
28
+ set filter(filter: DataSourceFilter);
29
+ get isAwaitingConfirmationOfConfigChange(): boolean;
30
+ protected confirmConfigChange(): void;
31
+ get config(): WithBaseFilter<WithFullConfig>;
32
+ set config(config: WithBaseFilter<WithFullConfig>);
33
+ set impendingConfig(config: WithBaseFilter<WithFullConfig>);
34
+ get pageCount(): number;
35
+ set pageCount(pageCount: number);
36
+ get range(): Range;
37
+ set range(range: Range);
38
+ get size(): number;
39
+ set size(size: number);
40
+ get sort(): VuuSort;
41
+ set sort(sort: VuuSort);
42
+ get title(): string;
43
+ set title(title: string);
44
+ applyConfig(config: WithBaseFilter<DataSourceConfig>, preserveExistingConfigAttributes?: boolean): DataSourceConfigChanges | undefined;
45
+ abstract rangeRequest(range: VuuRange): void;
46
+ }
@@ -0,0 +1,7 @@
1
+ import { DataSourceMenusMessage, DataSourceVisualLinkCreatedMessage, DataSourceVisualLinkRemovedMessage, DataSourceVisualLinksMessage, VuuFeatureMessage } from "@vuu-ui/vuu-data-types";
2
+ import { GridAction } from "@vuu-ui/vuu-table-types";
3
+ export declare const isVisualLinksAction: (action: GridAction) => action is DataSourceVisualLinksMessage;
4
+ export declare const isVisualLinkCreatedAction: (action: GridAction) => action is DataSourceVisualLinkCreatedMessage;
5
+ export declare const isVisualLinkRemovedAction: (action: GridAction) => action is DataSourceVisualLinkRemovedMessage;
6
+ export declare const isViewportMenusAction: (action: GridAction) => action is DataSourceMenusMessage;
7
+ export declare const isVuuFeatureAction: (action: GridAction) => action is VuuFeatureMessage;
@@ -0,0 +1,2 @@
1
+ import { WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
+ export declare const combineFilters: ({ baseFilterSpec, filterSpec, ...config }: WithBaseFilter<WithFullConfig>) => WithFullConfig;
@@ -0,0 +1,45 @@
1
+ import { ConnectionQualityMetrics, DataSourceCallbackMessage, DataSourceConfig, DataSourceDataMessage, DataSourceRow, RpcResponse, TypeaheadSuggestionProvider, VuuUIMessageIn, VuuUIMessageInRPC, VuuUIMessageInRPCEditReject, VuuUIMessageInTableMeta, VuuUIMessageOutViewport, WithBaseFilter, WithFilter, WithFullConfig, WithGroupBy, WithSort } from "@vuu-ui/vuu-data-types";
2
+ import { LinkDescriptorWithLabel, VuuCreateVisualLink, VuuFilter, VuuRemoveVisualLink, VuuRowDataItemType, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
+ import { ColumnMap } from "../column-utils";
4
+ export declare const NoFilter: VuuFilter;
5
+ export declare const NoSort: VuuSort;
6
+ export declare const vanillaConfig: WithFullConfig;
7
+ export type DataSourceConfigChanges = {
8
+ aggregationsChanged: boolean;
9
+ baseFilterChanged: boolean;
10
+ columnsChanged: boolean;
11
+ filterChanged: boolean;
12
+ groupByChanged: boolean;
13
+ sortChanged: boolean;
14
+ visualLinkChanged: boolean;
15
+ };
16
+ export type MaybeDataSourceConfigChanges = DataSourceConfigChanges & {
17
+ noChanges: boolean;
18
+ };
19
+ type DataConfigPredicate = (config: WithBaseFilter<DataSourceConfig>, newConfig: WithBaseFilter<DataSourceConfig>) => boolean;
20
+ export declare const isBaseFilterChanged: DataConfigPredicate;
21
+ export declare const isFilterChanged: DataConfigPredicate;
22
+ export declare const isGroupByChanged: DataConfigPredicate;
23
+ export declare const NO_CONFIG_CHANGES: MaybeDataSourceConfigChanges;
24
+ export declare const isConfigChanged: (config: DataSourceConfig | undefined, newConfig: DataSourceConfig | undefined) => MaybeDataSourceConfigChanges;
25
+ export declare const hasGroupBy: (config?: WithBaseFilter<DataSourceConfig>) => config is WithGroupBy;
26
+ export declare const hasBaseFilter: (config?: WithBaseFilter<DataSourceConfig>) => config is WithFilter;
27
+ export declare const hasFilter: (config?: DataSourceConfig) => config is WithFilter;
28
+ export declare const hasSort: (config?: DataSourceConfig) => config is WithSort;
29
+ export declare const isTypeaheadSuggestionProvider: (source: unknown) => source is TypeaheadSuggestionProvider;
30
+ export declare const isTableSchemaMessage: (message: VuuUIMessageIn) => message is VuuUIMessageInTableMeta;
31
+ export declare const isConnectionQualityMetrics: (msg: object) => msg is ConnectionQualityMetrics;
32
+ export declare const messageHasResult: (msg: object) => msg is VuuUIMessageInRPC;
33
+ export declare const isErrorResponse: (response?: Partial<RpcResponse>) => response is VuuUIMessageInRPCEditReject;
34
+ export declare const isVisualLinkMessage: (msg: unknown) => msg is VuuCreateVisualLink | VuuRemoveVisualLink;
35
+ export declare const isViewportMessage: (msg: object) => msg is VuuUIMessageOutViewport;
36
+ export type DataSourceDataMessageWithRows = Omit<DataSourceDataMessage, "rows"> & {
37
+ rows: DataSourceRow[];
38
+ };
39
+ export declare const messageHasDataRows: (message: DataSourceCallbackMessage) => message is DataSourceDataMessageWithRows;
40
+ export declare const withConfigDefaults: (config: WithBaseFilter<DataSourceConfig>) => WithBaseFilter<WithFullConfig> & {
41
+ visualLink?: LinkDescriptorWithLabel;
42
+ };
43
+ export type Entity = Record<string, VuuRowDataItemType>;
44
+ export declare const dataSourceRowToEntity: <T extends Entity = Entity>(row: DataSourceRow, columnMap: ColumnMap) => T;
45
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CalendarDate } from "@internationalized/date";
2
+ export declare function toCalendarDate(d: Date): CalendarDate;
@@ -0,0 +1,8 @@
1
+ import { DateTimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
2
+ import { DateTimePattern } from "./types";
3
+ export declare const defaultPatternsByType: {
4
+ readonly time: "hh:mm:ss";
5
+ readonly date: "dd.mm.yyyy";
6
+ };
7
+ export declare const fallbackDateTimePattern: DateTimePattern;
8
+ export declare function dateTimePattern(type: DateTimeDataValueDescriptor["type"]): DateTimePattern;
@@ -0,0 +1,4 @@
1
+ import { DateFormatter } from "@internationalized/date";
2
+ import { DateTimePattern } from "./types";
3
+ export declare function formatDate(pattern: DateTimePattern): (d: Date) => string;
4
+ export declare function getDateFormatter(locale: string, options?: Intl.DateTimeFormatOptions): DateFormatter;
@@ -0,0 +1,4 @@
1
+ export * from "./formatter";
2
+ export { dateTimeLabelByType, isDatePattern, isTimePattern, isDateTimePattern, type DatePattern, type TimePattern, type DateTimePattern, supportedDateTimePatterns, } from "./types";
3
+ export { toCalendarDate } from "./date-utils";
4
+ export { dateTimePattern, defaultPatternsByType, fallbackDateTimePattern, } from "./dateTimePattern";
@@ -0,0 +1,24 @@
1
+ import { ColumnTypeFormatting } from "@vuu-ui/vuu-table-types";
2
+ declare const supportedDatePatterns: readonly ["dd.mm.yyyy", "dd/mm/yyyy", "dd MMM yyyy", "dd MMMM yyyy", "mm/dd/yyyy", "MMM dd, yyyy", "MMMM dd, yyyy"];
3
+ declare const supportedTimePatterns: readonly ["hh:mm:ss", "hh:mm:ss a"];
4
+ export declare const supportedDateTimePatterns: {
5
+ date: readonly ["dd.mm.yyyy", "dd/mm/yyyy", "dd MMM yyyy", "dd MMMM yyyy", "mm/dd/yyyy", "MMM dd, yyyy", "MMMM dd, yyyy"];
6
+ time: readonly ["hh:mm:ss", "hh:mm:ss a"];
7
+ };
8
+ export declare const dateTimeLabelByType: {
9
+ readonly date: "Date";
10
+ readonly time: "Time";
11
+ };
12
+ export type DatePattern = (typeof supportedDatePatterns)[number];
13
+ export type TimePattern = (typeof supportedTimePatterns)[number];
14
+ export type DateTimePattern = {
15
+ date?: DatePattern;
16
+ time: TimePattern;
17
+ } | {
18
+ date: DatePattern;
19
+ time?: TimePattern;
20
+ };
21
+ export declare const isDatePattern: (pattern?: string) => pattern is DatePattern;
22
+ export declare const isTimePattern: (pattern?: string) => pattern is TimePattern;
23
+ export declare const isDateTimePattern: (pattern?: ColumnTypeFormatting["pattern"]) => pattern is DateTimePattern;
24
+ export {};
@@ -0,0 +1,9 @@
1
+ import { VuuRange } from "@vuu-ui/vuu-protocol-types";
2
+ export declare class RangeMonitor {
3
+ private source;
4
+ range: VuuRange;
5
+ timestamp: number;
6
+ constructor(source: string);
7
+ isSet(): boolean;
8
+ set({ from, to }: VuuRange): 0 | undefined;
9
+ }
@@ -0,0 +1,21 @@
1
+ type Listener = (...args: any[]) => void;
2
+ export type EmittedEvents = Record<string, Listener>;
3
+ export interface IEventEmitter<Events extends EmittedEvents> {
4
+ addListener<E extends keyof Events>(event: E, listener: Events[E]): void;
5
+ emit<E extends keyof Events>(event: E, ...args: Parameters<Events[E]>): void;
6
+ on<E extends keyof Events>(event: E, listener: Events[E]): void;
7
+ removeListener<E extends keyof Events>(event: E, listener: Events[E]): void;
8
+ removeAllListeners<E extends keyof Events>(event?: E): void;
9
+ }
10
+ export declare class EventEmitter<Events extends EmittedEvents> implements IEventEmitter<Events> {
11
+ #private;
12
+ addListener<E extends keyof Events>(event: E, listener: Events[E]): void;
13
+ removeListener<E extends keyof Events>(event: E, listener: Events[E]): void;
14
+ removeAllListeners<E extends keyof Events>(event?: E): void;
15
+ emit<E extends keyof Events>(event: E, ...args: Parameters<Events[E]>): void;
16
+ once<E extends keyof Events>(event: E, listener: Events[E]): void;
17
+ on<E extends keyof Events>(event: E, listener: Events[E]): void;
18
+ hasListener<E extends keyof Events>(event: E, listener: Events[E]): boolean;
19
+ private invokeHandler;
20
+ }
21
+ export {};
@@ -0,0 +1,104 @@
1
+ import type { TableSchema } from "@vuu-ui/vuu-data-types";
2
+ import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
3
+ import { ListOption } from "@vuu-ui/vuu-table-types";
4
+ import { ReactElement } from "react";
5
+ export type PathMap = {
6
+ [key: string]: Pick<DynamicFeatureDescriptor, "css" | "url">;
7
+ };
8
+ export type Environment = "development" | "production";
9
+ export declare const env: Environment;
10
+ export type LookupTableProvider = (table: VuuTable) => ListOption[];
11
+ export interface ViewConfig {
12
+ allowRename?: boolean;
13
+ closeable?: boolean;
14
+ header?: boolean;
15
+ }
16
+ export interface DynamicFeatureProps<P extends object | undefined = object> {
17
+ /**
18
+ props that will be passed to the lazily loaded component.
19
+ */
20
+ ComponentProps?: P;
21
+ ViewProps?: ViewConfig;
22
+ css?: string;
23
+ height?: number;
24
+ title?: string;
25
+ /**
26
+ The url of javascript bundle to lazily load. Bundle must provide a default export
27
+ and that export must be a React component.
28
+ */
29
+ url: string;
30
+ width?: number;
31
+ }
32
+ declare global {
33
+ const vuuConfig: Promise<VuuConfig>;
34
+ }
35
+ export interface DynamicFeatureDescriptor {
36
+ name: string;
37
+ title: string;
38
+ url: string;
39
+ css?: string;
40
+ leftNavLocation: "vuu-features" | "vuu-tables";
41
+ featureProps?: {
42
+ vuuTables?: "*" | VuuTable[];
43
+ };
44
+ viewProps?: ViewConfig;
45
+ }
46
+ export interface StaticFeatureDescriptor {
47
+ group?: string;
48
+ label: string;
49
+ type: string;
50
+ }
51
+ export declare const isStaticFeatures: (features: unknown) => features is StaticFeatureDescriptor[];
52
+ export interface FilterTableFeatureProps {
53
+ tableSchema: TableSchema;
54
+ }
55
+ export type DynamicFeatures = {
56
+ [key: string]: DynamicFeatureDescriptor;
57
+ };
58
+ export declare function featureFromJson({ type }: {
59
+ type: string;
60
+ }): ReactElement;
61
+ export interface VuuConfig {
62
+ features: DynamicFeatures;
63
+ authUrl?: string;
64
+ websocketUrl: string;
65
+ ssl: boolean;
66
+ }
67
+ /**
68
+ * We currently categorize 'features' simply by the leftNavLocation
69
+ * @param feature
70
+ * @returns
71
+ */
72
+ export declare const isCustomFeature: (feature: DynamicFeatureDescriptor) => boolean;
73
+ export declare const isWildcardSchema: (vuuTables?: "*" | VuuTable[]) => vuuTables is "*";
74
+ export declare const isVuuTables: (vuuTables?: "*" | VuuTable[]) => vuuTables is VuuTable[];
75
+ export interface FeaturePropsWithFilterTableFeature extends Omit<DynamicFeatureProps, "ComponentProps"> {
76
+ ComponentProps: FilterTableFeatureProps;
77
+ }
78
+ export declare const hasFilterTableFeatureProps: (props: DynamicFeatureProps) => props is FeaturePropsWithFilterTableFeature;
79
+ export declare const isSameTable: (t1: VuuTable, t2: VuuTable) => void;
80
+ export declare const byModule: (schema1: TableSchema, schema2: TableSchema) => 0 | 1 | -1;
81
+ export type GetFeaturePaths = (params: {
82
+ env: Environment;
83
+ fileName: string;
84
+ withCss?: boolean;
85
+ }) => DynamicFeatureProps;
86
+ export declare const getFilterTableFeatures: (schemas: TableSchema[], getFeaturePath: GetFeaturePaths) => DynamicFeatureProps<FilterTableFeatureProps>[];
87
+ export type Component = {
88
+ componentName: string;
89
+ component: unknown;
90
+ };
91
+ export declare const assertComponentRegistered: (componentName: string, component: unknown) => void;
92
+ export declare const assertComponentsRegistered: (componentList: Component[]) => void;
93
+ /**
94
+ * Process the DynamicFeature descriptors. Identify
95
+ * the vuu tables required and inject the appropriate TableSchemas
96
+ *
97
+ * @param dynamicFeatures
98
+ * @param tableSchemas
99
+ * @returns
100
+ */
101
+ export declare const getCustomAndTableFeatures: (dynamicFeatures: DynamicFeatureDescriptor[], tableSchemas: TableSchema[]) => {
102
+ dynamicFeatures: DynamicFeatureProps[];
103
+ tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[];
104
+ };