@vuu-ui/vuu-utils 3.3.9 → 3.3.10

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 (78) hide show
  1. package/package.json +6 -6
  2. package/types/src/Clock.d.ts +20 -0
  3. package/types/src/PageVisibilityObserver.d.ts +36 -0
  4. package/types/src/ScaledDecimal.d.ts +12 -0
  5. package/types/src/ShellContext.d.ts +11 -0
  6. package/types/src/ThemeProvider.d.ts +32 -0
  7. package/types/src/array-utils.d.ts +16 -0
  8. package/types/src/box-utils.d.ts +24 -0
  9. package/types/src/broadcast-channel.d.ts +16 -0
  10. package/types/src/column-utils.d.ts +243 -0
  11. package/types/src/common-types.d.ts +6 -0
  12. package/types/src/component-registry.d.ts +65 -0
  13. package/types/src/context-definitions/DataContext.d.ts +21 -0
  14. package/types/src/context-definitions/DataProvider.d.ts +7 -0
  15. package/types/src/context-definitions/DataSourceProvider.d.ts +12 -0
  16. package/types/src/context-definitions/WorkspaceContext.d.ts +17 -0
  17. package/types/src/cookie-utils.d.ts +9 -0
  18. package/types/src/css-utils.d.ts +1 -0
  19. package/types/src/data-utils.d.ts +33 -0
  20. package/types/src/datasource/BaseDataSource.d.ts +63 -0
  21. package/types/src/datasource/datasource-action-utils.d.ts +7 -0
  22. package/types/src/datasource/datasource-filter-utils.d.ts +2 -0
  23. package/types/src/datasource/datasource-utils.d.ts +61 -0
  24. package/types/src/date/date-utils.d.ts +39 -0
  25. package/types/src/date/dateTimePattern.d.ts +8 -0
  26. package/types/src/date/formatter.d.ts +9 -0
  27. package/types/src/date/index.d.ts +4 -0
  28. package/types/src/date/types.d.ts +29 -0
  29. package/types/src/debug-utils.d.ts +9 -0
  30. package/types/src/edit-utils.d.ts +2 -0
  31. package/types/src/errors.d.ts +2 -0
  32. package/types/src/event-emitter.d.ts +21 -0
  33. package/types/src/feature-utils.d.ts +110 -0
  34. package/types/src/filters/filter-utils.d.ts +75 -0
  35. package/types/src/filters/filterAsQuery.d.ts +8 -0
  36. package/types/src/filters/index.d.ts +2 -0
  37. package/types/src/form-utils.d.ts +37 -0
  38. package/types/src/formatting-utils.d.ts +14 -0
  39. package/types/src/getUniqueId.d.ts +1 -0
  40. package/types/src/group-utils.d.ts +10 -0
  41. package/types/src/html-utils.d.ts +21 -0
  42. package/types/src/index.d.ts +76 -0
  43. package/types/src/input-utils.d.ts +2 -0
  44. package/types/src/invariant.d.ts +1 -0
  45. package/types/src/itemToString.d.ts +2 -0
  46. package/types/src/json-types.d.ts +52 -0
  47. package/types/src/json-utils.d.ts +6 -0
  48. package/types/src/keyboard-utils.d.ts +15 -0
  49. package/types/src/keyset.d.ts +16 -0
  50. package/types/src/layout-types.d.ts +22 -0
  51. package/types/src/list-utils.d.ts +2 -0
  52. package/types/src/local-storage-utils.d.ts +4 -0
  53. package/types/src/logging-utils.d.ts +45 -0
  54. package/types/src/module-utils.d.ts +8 -0
  55. package/types/src/nanoid/index.d.ts +1 -0
  56. package/types/src/perf-utils.d.ts +5 -0
  57. package/types/src/promise-utils.d.ts +8 -0
  58. package/types/src/protocol-message-utils.d.ts +43 -0
  59. package/types/src/range-utils.d.ts +29 -0
  60. package/types/src/react-utils.d.ts +15 -0
  61. package/types/src/round-decimal.d.ts +4 -0
  62. package/types/src/row-utils.d.ts +28 -0
  63. package/types/src/selection-utils.d.ts +9 -0
  64. package/types/src/shell-layout-types.d.ts +15 -0
  65. package/types/src/sort-utils.d.ts +11 -0
  66. package/types/src/table-schema-utils.d.ts +5 -0
  67. package/types/src/text-utils.d.ts +10 -0
  68. package/types/src/theme-utils.d.ts +14 -0
  69. package/types/src/tree-types.d.ts +9 -0
  70. package/types/src/tree-utils.d.ts +9 -0
  71. package/types/src/ts-utils.d.ts +20 -0
  72. package/types/src/typeahead-utils.d.ts +1 -0
  73. package/types/src/url-utils.d.ts +3 -0
  74. package/types/src/useId.d.ts +1 -0
  75. package/types/src/useLayoutEffectSkipFirst.d.ts +2 -0
  76. package/types/src/useResizeObserver.d.ts +15 -0
  77. package/types/src/useStateRef.d.ts +2 -0
  78. package/types/src/user-types.d.ts +3 -0
@@ -0,0 +1,63 @@
1
+ import type { DataSource, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceSuspenseProps, 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 { Range } from "../range-utils";
5
+ import { Filter } from "@vuu-ui/vuu-filter-types";
6
+ export type ConfigWithVisualLink = WithBaseFilter<WithFullConfig> & {
7
+ visualLink?: LinkDescriptorWithLabel;
8
+ };
9
+ export declare const defaultSuspenseProps: DataSourceSuspenseProps;
10
+ export declare abstract class BaseDataSource extends EventEmitter<DataSourceEvents> implements Pick<DataSource, "config"> {
11
+ #private;
12
+ viewport: string;
13
+ protected _clientCallback: DataSourceSubscribeCallback | undefined;
14
+ protected _configWithVisualLink: ConfigWithVisualLink;
15
+ protected _impendingConfigWithVisualLink: ConfigWithVisualLink | undefined;
16
+ protected _range: Range;
17
+ protected _size: number;
18
+ protected _title: string | undefined;
19
+ protected _defaultSuspenseProps: DataSourceSuspenseProps;
20
+ private awaitingConfirmationOfConfigChanges;
21
+ constructor({ aggregations, baseFilterSpec, columns, filterSpec, groupBy, sort, suspenseProps, title, viewport, }: Omit<DataSourceConstructorProps, "table">);
22
+ subscribe({ baseFilterSpec, columns, aggregations, range, sort, groupBy, filterSpec, viewport, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): void;
23
+ get aggregations(): VuuAggregation[];
24
+ set aggregations(aggregations: VuuAggregation[]);
25
+ get baseFilter(): DataSourceFilter | undefined;
26
+ set baseFilter(baseFilter: DataSourceFilter | undefined);
27
+ get columns(): string[];
28
+ set columns(columns: string[]);
29
+ get filter(): DataSourceFilter;
30
+ set filter(filter: DataSourceFilter);
31
+ setFilter(filter: Filter): void;
32
+ clearFilter(): void;
33
+ get isAwaitingConfirmationOfConfigChange(): boolean;
34
+ protected confirmConfigChange(): void;
35
+ get config(): WithBaseFilter<WithFullConfig>;
36
+ set config(config: WithBaseFilter<WithFullConfig>);
37
+ get impendingConfig(): undefined | WithBaseFilter<WithFullConfig>;
38
+ /**
39
+ * This can be set by subclass in cases where we want to await ACK of async request
40
+ * before we go ahead and apply change to config.
41
+ * It is set in place of 'config' itself and it is then the responsibility of the client
42
+ * to call 'confirmConfigChange' once confirmation of the change is received.
43
+ * Client can check 'isAwaitingConfirmationOfConfigChange' to see if a change is pending
44
+ * confirmation.
45
+ */
46
+ set impendingConfig(config: undefined | WithBaseFilter<WithFullConfig>);
47
+ get pageCount(): number;
48
+ set pageCount(pageCount: number);
49
+ get range(): Range;
50
+ set range(range: Range);
51
+ get size(): number;
52
+ set size(size: number);
53
+ get sort(): VuuSort;
54
+ set sort(sort: VuuSort);
55
+ get title(): string;
56
+ set title(title: string);
57
+ private applyConfig;
58
+ freeze(): void;
59
+ unfreeze(): void;
60
+ get freezeTimestamp(): number | undefined;
61
+ get isFrozen(): boolean;
62
+ abstract rangeRequest(range: VuuRange): void;
63
+ }
@@ -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,61 @@
1
+ import type { ConnectionQualityMetrics, DataSourceCallbackMessage, DataSourceConfig, DataSourceDataMessage, DataSourceRow, DataSourceVisualLinksMessage, TypeaheadSuggestionProvider, VuuUIMessageIn, VuuUIMessageInRPC, VuuUIMessageInTableMeta, VuuUIMessageOutViewport, WithBaseFilter, WithFilter, WithFullConfig, WithGroupBy, WithSort } from "@vuu-ui/vuu-data-types";
2
+ import type { LinkDescriptorWithLabel, VuuColumns, VuuCreateVisualLink, VuuFilter, VuuRemoveVisualLink, VuuRowDataItemType, VuuSort, VuuTable } from "@vuu-ui/vuu-protocol-types";
3
+ import type { ColumnMap } from "../column-utils";
4
+ import type { ConfigWithVisualLink } from "./BaseDataSource";
5
+ export declare const NoFilter: VuuFilter;
6
+ export declare const NoSort: VuuSort;
7
+ export declare const vanillaConfig: WithFullConfig;
8
+ /**
9
+ * Derive the config for a session (edit) datasource from the source (view) datasource config.
10
+ * When the edit table declares its own columns, the view config's filter, groupBy, sort and
11
+ * aggregations are discarded rather than inherited - they may reference view-only columns.
12
+ */
13
+ export declare const sessionDataSourceConfig: (sourceConfig: WithFullConfig, overrideColumns?: VuuColumns) => WithFullConfig;
14
+ /**
15
+ * The session table name is server generated, so only the module is compared.
16
+ */
17
+ export declare const assertExpectedSessionTable: (sessionTable: VuuTable, expectedTable?: VuuTable) => void;
18
+ export declare const stripVisualLink: (configWithVisualLink: ConfigWithVisualLink) => WithBaseFilter<WithFullConfig>;
19
+ export type DataSourceConfigChanges = {
20
+ aggregationsChanged: boolean;
21
+ baseFilterChanged: boolean;
22
+ columnsChanged: boolean;
23
+ filterChanged: boolean;
24
+ groupByChanged: boolean;
25
+ sortChanged: boolean;
26
+ visualLinkChanged: boolean;
27
+ };
28
+ export type MaybeDataSourceConfigChanges = DataSourceConfigChanges & {
29
+ noChanges: boolean;
30
+ };
31
+ type DataConfigPredicate = (config: WithBaseFilter<DataSourceConfig>, newConfig: WithBaseFilter<DataSourceConfig>) => boolean;
32
+ export declare const isBaseFilterChanged: DataConfigPredicate;
33
+ export declare const isFilterChanged: DataConfigPredicate;
34
+ export declare const isGroupByChanged: DataConfigPredicate;
35
+ export declare const NO_CONFIG_CHANGES: MaybeDataSourceConfigChanges;
36
+ export declare const isConfigChanged: (config: DataSourceConfig | undefined, newConfig: DataSourceConfig | undefined) => MaybeDataSourceConfigChanges;
37
+ export declare const hasGroupBy: (config?: WithBaseFilter<DataSourceConfig>) => config is WithGroupBy;
38
+ export declare const hasBaseFilter: (config?: WithBaseFilter<DataSourceConfig>) => config is WithFilter;
39
+ export declare const hasFilter: (config?: DataSourceConfig) => config is WithFilter;
40
+ export declare const hasSort: (config?: DataSourceConfig) => config is WithSort;
41
+ export declare const isTypeaheadSuggestionProvider: (source: unknown) => source is TypeaheadSuggestionProvider;
42
+ export declare const isTableSchemaMessage: (message: VuuUIMessageIn) => message is VuuUIMessageInTableMeta;
43
+ export declare const isConnectionQualityMetrics: (msg: object) => msg is ConnectionQualityMetrics;
44
+ export declare const messageHasResult: (msg: object) => msg is VuuUIMessageInRPC;
45
+ export declare const isVisualLinkMessage: (msg: unknown) => msg is VuuCreateVisualLink | VuuRemoveVisualLink;
46
+ export declare const isVisualLinksMessage: (msg: unknown) => msg is DataSourceVisualLinksMessage;
47
+ export declare const isViewportMessage: (msg: object) => msg is VuuUIMessageOutViewport;
48
+ export type DataSourceDataMessageWithRows = Omit<DataSourceDataMessage, "rows"> & {
49
+ rows: DataSourceRow[];
50
+ };
51
+ export type DataSourceDataMessageWithSize = Omit<DataSourceDataMessage, "size"> & {
52
+ size: number;
53
+ };
54
+ export declare const messageHasDataRows: (message: DataSourceCallbackMessage) => message is DataSourceDataMessageWithRows;
55
+ export declare const messageHasSize: (message: DataSourceCallbackMessage) => message is DataSourceDataMessageWithSize;
56
+ export declare const withConfigDefaults: (config: WithBaseFilter<DataSourceConfig>) => WithBaseFilter<WithFullConfig> & {
57
+ visualLink?: LinkDescriptorWithLabel;
58
+ };
59
+ export type Entity = Record<string, VuuRowDataItemType>;
60
+ export declare const dataSourceRowToEntity: <T extends Entity = Entity>(row: DataSourceRow, columnMap: ColumnMap) => T;
61
+ export {};
@@ -0,0 +1,39 @@
1
+ import { CalendarDate } from "@internationalized/date";
2
+ export declare function toCalendarDate(d: Date): CalendarDate;
3
+ export type oneToFive = 1 | 2 | 3 | 4 | 5;
4
+ export type zeroToFive = 0 | oneToFive;
5
+ export type sixToNine = 6 | 7 | 8 | 9;
6
+ export type zeroToNine = zeroToFive | sixToNine;
7
+ export type oneToNine = oneToFive | sixToNine;
8
+ export type TimeUnit = "hours" | "minutes" | "seconds";
9
+ export type Hours = `${0 | 1}${zeroToNine}` | `2${0 | 1 | 2 | 3}`;
10
+ export type Minutes = `${zeroToFive}${zeroToNine}`;
11
+ export type Seconds = `${zeroToFive}${zeroToNine}`;
12
+ export type TimeUnitValue<T extends TimeUnit> = T extends "hours" ? Hours : T extends "minutes" ? Minutes : Seconds;
13
+ export type TimeString = `${number}${number}:${number}${number}:${number}${number}`;
14
+ type YYYY = `19${zeroToNine}${zeroToNine}` | `20${zeroToNine}${zeroToNine}`;
15
+ type MM = `0${oneToNine}` | `1${0 | 1 | 2}`;
16
+ type DD = `${0}${oneToNine}` | `${1 | 2}${zeroToNine}` | `3${0 | 1}`;
17
+ export type DateStringISO = `${YYYY}-${MM}-${DD}`;
18
+ export declare const zeroTime: TimeString;
19
+ export declare const zeroTimeUnit: TimeUnitValue<TimeUnit>;
20
+ export declare function incrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): TimeUnitValue<T> | Hours;
21
+ export declare function decrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): TimeUnitValue<T> | Hours;
22
+ export declare function updateTimeString<T extends TimeUnit>(timeString: TimeString, unit: T, value: TimeUnitValue<T>): TimeString;
23
+ export declare const isValidTimeString: (value: unknown) => value is TimeString;
24
+ export declare function asTimeString(value: unknown, allowUndefined: false): TimeString;
25
+ export declare function asTimeString(value: unknown, allowUndefined?: true): TimeString | undefined;
26
+ export interface Time {
27
+ hours: number;
28
+ minutes: number;
29
+ seconds: number;
30
+ asDate: (date?: Date | DateStringISO) => Date;
31
+ }
32
+ export declare function Time(timeString: TimeString): Time;
33
+ export declare namespace Time {
34
+ export var millisToTimeString: (timestamp: number) => TimeString;
35
+ var _a: (hours: number, minutes: number, seconds: number) => TimeString;
36
+ export { _a as toString };
37
+ export var isDateInMillis: (dtInMillis: string | number) => boolean;
38
+ }
39
+ export {};
@@ -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,9 @@
1
+ import { DateFormatter } from "@internationalized/date";
2
+ import { DateTimePattern } from "./types";
3
+ type DateTimeFormatConfig = {
4
+ locale: string;
5
+ options: Intl.DateTimeFormatOptions;
6
+ };
7
+ export declare function getDateFormatter({ locale, options }: DateTimeFormatConfig): DateFormatter;
8
+ export declare function formatDate(pattern: DateTimePattern): (d: Date) => string;
9
+ export {};
@@ -0,0 +1,4 @@
1
+ export { asTimeString, decrementTimeUnitValue, incrementTimeUnitValue, isValidTimeString, Time, toCalendarDate, type DateStringISO, type Hours, type Minutes, type Seconds, type TimeString, type TimeUnit, type TimeUnitValue, updateTimeString, zeroTime, zeroTimeUnit, } from "./date-utils";
2
+ export { dateTimePattern, defaultPatternsByType, fallbackDateTimePattern, } from "./dateTimePattern";
3
+ export * from "./formatter";
4
+ export { dateTimeLabelByType, isDatePattern, isTimePattern, supportedDateTimePatterns, type DatePattern, type DateTimePattern, type TimePattern, } from "./types";
@@ -0,0 +1,29 @@
1
+ import { ColumnTypeFormatting } from "@vuu-ui/vuu-table-types";
2
+ /**
3
+ * In the code below we distinguish between an ISO date pattern (yyyy-mm-dd) and
4
+ * other supported date patterns because the ISO format is not supported by the
5
+ * Intl dateFormatting function
6
+ */
7
+ declare const supportedDatePatterns: readonly ["yyyy-mm-dd", "dd.mm.yyyy", "dd/mm/yyyy", "dd MMM yyyy", "dd MMMM yyyy", "mm/dd/yyyy", "MMM dd, yyyy", "MMMM dd, yyyy"];
8
+ declare const supportedTimePatterns: readonly ["hh:mm:ss", "hh:mm:ss a", "hh:mm:ss.ms"];
9
+ export declare const supportedDateTimePatterns: {
10
+ date: readonly ["yyyy-mm-dd", "dd.mm.yyyy", "dd/mm/yyyy", "dd MMM yyyy", "dd MMMM yyyy", "mm/dd/yyyy", "MMM dd, yyyy", "MMMM dd, yyyy"];
11
+ time: readonly ["hh:mm:ss", "hh:mm:ss a", "hh:mm:ss.ms"];
12
+ };
13
+ export declare const dateTimeLabelByType: {
14
+ readonly date: "Date";
15
+ readonly time: "Time";
16
+ };
17
+ export type DatePattern = (typeof supportedDatePatterns)[number];
18
+ export type TimePattern = (typeof supportedTimePatterns)[number];
19
+ export type DateTimePattern = {
20
+ date?: DatePattern;
21
+ time: TimePattern;
22
+ } | {
23
+ date: DatePattern;
24
+ time?: TimePattern;
25
+ };
26
+ export declare const isDatePattern: (pattern?: string) => pattern is DatePattern;
27
+ export declare const isTimePattern: (pattern?: string) => pattern is TimePattern;
28
+ export declare const isDateTimePattern: (pattern?: ColumnTypeFormatting["pattern"]) => pattern is DateTimePattern;
29
+ 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,2 @@
1
+ import type { EditSessionMode } from "@vuu-ui/vuu-data-types";
2
+ export declare const isInlineEditingSession: (editSessionMode: EditSessionMode) => editSessionMode is "inline-all-rows";
@@ -0,0 +1,2 @@
1
+ export declare class StaleUpdateError extends Error {
2
+ }
@@ -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,110 @@
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
+ /**
37
+ * url for css file for feature
38
+ */
39
+ css?: string;
40
+ featureProps?: {
41
+ vuuTables?: "*" | VuuTable[];
42
+ };
43
+ leftNavLocation: "vuu-features" | "vuu-tables";
44
+ name: string;
45
+ title: string;
46
+ /**
47
+ * url for javascript bundle to load feature
48
+ */
49
+ url: string;
50
+ viewProps?: ViewConfig;
51
+ }
52
+ export interface StaticFeatureDescriptor {
53
+ group?: string;
54
+ label: string;
55
+ type: string;
56
+ }
57
+ export declare const isStaticFeatures: (features: unknown) => features is StaticFeatureDescriptor[];
58
+ export interface FilterTableFeatureProps {
59
+ tableSchema: TableSchema;
60
+ }
61
+ export type DynamicFeatures = {
62
+ [key: string]: DynamicFeatureDescriptor;
63
+ };
64
+ export declare function featureFromJson({ type }: {
65
+ type: string;
66
+ }): ReactElement;
67
+ export interface VuuConfig {
68
+ features: DynamicFeatures;
69
+ authUrl?: string;
70
+ websocketUrl: string;
71
+ ssl: boolean;
72
+ }
73
+ /**
74
+ * We currently categorize 'features' simply by the leftNavLocation
75
+ * @param feature
76
+ * @returns
77
+ */
78
+ export declare const isCustomFeature: (feature: DynamicFeatureDescriptor) => boolean;
79
+ export declare const isWildcardSchema: (vuuTables?: "*" | VuuTable[]) => vuuTables is "*";
80
+ export declare const isVuuTables: (vuuTables?: "*" | VuuTable[]) => vuuTables is VuuTable[];
81
+ export interface FeaturePropsWithFilterTableFeature extends Omit<DynamicFeatureProps, "ComponentProps"> {
82
+ ComponentProps: FilterTableFeatureProps;
83
+ }
84
+ export declare const hasFilterTableFeatureProps: (props: DynamicFeatureProps) => props is FeaturePropsWithFilterTableFeature;
85
+ export declare const isSameTable: (t1: VuuTable, t2: VuuTable) => void;
86
+ export declare const byModule: (schema1: TableSchema, schema2: TableSchema) => -1 | 0 | 1;
87
+ export type GetFeaturePaths = (params: {
88
+ env: Environment;
89
+ fileName: string;
90
+ withCss?: boolean;
91
+ }) => DynamicFeatureProps;
92
+ export declare const getFilterTableFeatures: (schemas: TableSchema[], getFeaturePath: GetFeaturePaths) => DynamicFeatureProps<FilterTableFeatureProps>[];
93
+ export type Component = {
94
+ componentName: string;
95
+ component: unknown;
96
+ };
97
+ export declare const assertComponentRegistered: (componentName: string, component: unknown) => void;
98
+ export declare const assertComponentsRegistered: (componentList: Component[]) => void;
99
+ /**
100
+ * Process the DynamicFeature descriptors. Identify
101
+ * the vuu tables required and inject the appropriate TableSchemas
102
+ *
103
+ * @param dynamicFeatures
104
+ * @param tableSchemas
105
+ * @returns
106
+ */
107
+ export declare const getCustomAndTableFeatures: (dynamicFeatures: DynamicFeatureDescriptor[], tableSchemas: TableSchema[]) => {
108
+ dynamicFeatures: DynamicFeatureProps[];
109
+ tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[];
110
+ };
@@ -0,0 +1,75 @@
1
+ import type { DataSourceFilter } from "@vuu-ui/vuu-data-types";
2
+ import { ColumnFilterOp, ColumnFilterValue, ExtendedFilter, Filter, FilterClauseOp, FilterClauseOpBetween, FilterContainerFilter, FilterWithPartialClause, MultiClauseFilter, MultiValueFilterClause, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
3
+ import { SerializableFilter } from "@vuu-ui/vuu-filters/src/filter-container/ExtendedSingleValueFilterClause";
4
+ import { ColumnDescriptor, RuntimeColumnDescriptor } from "@vuu-ui/vuu-table-types";
5
+ import { ScaledDecimal } from "../ScaledDecimal";
6
+ export declare const isBetweenOperator: (op: ColumnFilterOp) => op is FilterClauseOpBetween;
7
+ export declare const isValidFilterClauseOp: (op?: string) => op is FilterClauseOp;
8
+ export declare const isNamedFilter: (f?: Filter) => boolean;
9
+ export declare const isSingleValueFilter: (f?: Partial<Filter>) => f is SingleValueFilterClause;
10
+ export declare const isScaledDecimalFilterClause: (f: SingleValueFilterClause) => f is SingleValueFilterClause<ScaledDecimal>;
11
+ export declare const isSerializableFilter: (f: object) => f is SerializableFilter;
12
+ export declare const isFilter: (f: unknown) => f is Filter;
13
+ export declare const isFilterClause: (f?: Partial<Filter>) => f is SingleValueFilterClause | MultiValueFilterClause;
14
+ export declare const isMultiValueFilter: (f?: Partial<Filter>) => f is MultiValueFilterClause;
15
+ export declare const isInFilter: (f: Partial<Filter>) => f is MultiValueFilterClause;
16
+ export declare const isAndFilter: (f?: Partial<Filter>) => f is MultiClauseFilter<"and">;
17
+ export declare const isBetweenFilter: (f?: Filter) => f is MultiClauseFilter<"and", SingleValueFilterClause>;
18
+ export declare const isOrFilter: (f?: Partial<Filter>) => f is MultiClauseFilter<"or">;
19
+ export declare const isCompleteFilter: (filter: Partial<Filter>) => filter is Filter;
20
+ export declare function isMultiClauseFilter(f?: Partial<Filter> | FilterWithPartialClause): f is MultiClauseFilter;
21
+ export declare const isExtendedFilter: (f: Filter) => f is ExtendedFilter;
22
+ export declare const applyFilterToColumns: (columns: RuntimeColumnDescriptor[], { filterStruct }: DataSourceFilter) => RuntimeColumnDescriptor[];
23
+ export declare const isFilteredColumn: (column: RuntimeColumnDescriptor) => boolean;
24
+ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]) => {
25
+ aggregate?: import("@vuu-ui/vuu-protocol-types").VuuAggType;
26
+ allowColumnHeaderMenu?: false;
27
+ colHeaderContentRenderer?: string;
28
+ colHeaderLabelRenderer?: string;
29
+ exportFormatter?: (value: unknown) => string;
30
+ getIcon?: (row: import("@vuu-ui/vuu-table-types").DataRow) => string | undefined;
31
+ groupable?: boolean;
32
+ hidden?: boolean;
33
+ locked?: Exclude<import("@vuu-ui/vuu-table-types").PinLocation, "left"> | false;
34
+ maxWidth?: number;
35
+ minWidth?: number;
36
+ pin?: import("@vuu-ui/vuu-table-types").PinLocation | false;
37
+ removeable?: boolean;
38
+ selected?: boolean;
39
+ source?: "client" | "server";
40
+ status?: import("@salt-ds/core").ValidationStatus;
41
+ align?: "left" | "right";
42
+ ariaColIndex: number;
43
+ CellRenderer?: import("react").FunctionComponent<import("@vuu-ui/vuu-table-types").TableCellRendererProps>;
44
+ HeaderCellContentRenderer?: import("react").FunctionComponent<Omit<import("@vuu-ui/vuu-table-types").HeaderCellProps, "id" | "index">>;
45
+ HeaderCellLabelRenderer?: import("react").FunctionComponent<Omit<import("@vuu-ui/vuu-table-types").HeaderCellProps, "id" | "index">>;
46
+ canStretch?: boolean;
47
+ className?: string;
48
+ clientSideEditValidationCheck?: import("@vuu-ui/vuu-data-types").DataValueValidationChecker;
49
+ draggable?: boolean;
50
+ flex?: number;
51
+ heading?: [...string[]];
52
+ isGroup?: boolean;
53
+ isSystemColumn?: boolean;
54
+ label: string;
55
+ marginLeft?: number;
56
+ moving?: boolean;
57
+ originalIdx?: number;
58
+ pinnedOffset?: number;
59
+ pinnedWidth?: number;
60
+ resizeable?: boolean;
61
+ resizing?: boolean;
62
+ sortable?: boolean;
63
+ sorted?: import("@vuu-ui/vuu-table-types").ColumnSort;
64
+ valueFormatter: import("@vuu-ui/vuu-table-types").ValueFormatter;
65
+ width: number;
66
+ editable?: import("@vuu-ui/vuu-data-types").DataEditable;
67
+ editableBulk?: import("@vuu-ui/vuu-data-types").BulkEdit;
68
+ name: string;
69
+ required?: boolean;
70
+ serverDataType?: import("@vuu-ui/vuu-protocol-types").VuuColumnDataType;
71
+ type?: import("@vuu-ui/vuu-data-types").DataValueType;
72
+ }[];
73
+ export declare const extractFilterForColumn: (filter: Filter | undefined, columnName: string) => Filter | undefined;
74
+ export declare const getColumnValueFromFilter: (column: ColumnDescriptor, operator: ColumnFilterOp, filter?: FilterContainerFilter) => ColumnFilterValue;
75
+ export declare const filtersAreEqual: (f1: FilterContainerFilter | null | undefined, f2: FilterContainerFilter | null | undefined) => boolean;
@@ -0,0 +1,8 @@
1
+ import type { ColumnDescriptorsByName, Filter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
2
+ export declare const filterAsQuery: (f: Filter, opts?: {
3
+ columnsByName?: ColumnDescriptorsByName;
4
+ }) => string;
5
+ export declare const ONE_DAY_IN_MILLIS: number;
6
+ export declare function dateFilterAsQuery(f: SingleValueFilterClause<number>, opts?: {
7
+ columnsByName?: ColumnDescriptorsByName;
8
+ }): string;
@@ -0,0 +1,2 @@
1
+ export * from "./filter-utils";
2
+ export * from "./filterAsQuery";
@@ -0,0 +1,37 @@
1
+ import { DataValueTypeSimple } from "@vuu-ui/vuu-data-types";
2
+ import { VuuColumnDataType, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
+ import { KeyboardEvent, SyntheticEvent } from "react";
4
+ import { ExtendedFilterOptions } from "@vuu-ui/vuu-filter-types";
5
+ export declare class DataValidationError extends Error {
6
+ actualType: string;
7
+ expectedType: string;
8
+ constructor(message: string, expectedType: string, actualType: string);
9
+ }
10
+ /**
11
+ * Use with the following convention:
12
+ *
13
+ * <FormField data-field="my-field-name">
14
+ */
15
+ export declare const getFieldName: (target: EventTarget | HTMLElement) => string;
16
+ export type InputSource = "typeahead-suggestion" | "text-input";
17
+ export declare const isNumber: (type: string, value: VuuRowDataItemType) => value is number;
18
+ export type CommitHandler<E extends HTMLElement = HTMLInputElement, T = VuuRowDataItemType> = (evt: SyntheticEvent<E> | KeyboardEvent<E>, value: T, source?: InputSource) => void;
19
+ export declare const isValidRange: <T>([val1, val2]: [T, T]) => boolean;
20
+ /**
21
+ * Convert a pair of string values to the type appropriate for the
22
+ * associated column or form field. Can be used when processing a string value
23
+ * from an input used for user editing.
24
+ *
25
+ */
26
+ export declare function getTypedRange([value1, value2]: [string, string], dataType: VuuColumnDataType | DataValueTypeSimple, options?: ExtendedFilterOptions): (VuuRowDataItemType | undefined)[];
27
+ /**
28
+ * Convert a string value to the type appropriate for the associated
29
+ * column or form field. Can be used when processing a string value
30
+ * from an input used for user editing.
31
+ *
32
+ * @param value
33
+ * @param type
34
+ * @param throwIfInvalid
35
+ */
36
+ export declare function getTypedValue(value: string, type: VuuColumnDataType | DataValueTypeSimple, throwIfInvalid?: false, options?: ExtendedFilterOptions): VuuRowDataItemType | undefined;
37
+ export declare function getTypedValue(value: string, type: VuuColumnDataType | DataValueTypeSimple, throwIfInvalid: true, options?: ExtendedFilterOptions): VuuRowDataItemType;
@@ -0,0 +1,14 @@
1
+ import { ColumnDescriptor, ValueFormatter } from "@vuu-ui/vuu-table-types";
2
+ export type ValueFormatters = {
3
+ [key: string]: ValueFormatter;
4
+ };
5
+ export declare const defaultValueFormatter: (value: unknown) => string;
6
+ export declare const numericFormatter: ({ align, serverDataType, type, }: Partial<ColumnDescriptor>) => typeof defaultValueFormatter;
7
+ export declare const getValueFormatter: (column: ColumnDescriptor) => ValueFormatter;
8
+ /**
9
+ * Lowercases a string and returns as Lowercase typescript type
10
+ *
11
+ * @param str the input string
12
+ * @returns str converted to Lowercase
13
+ */
14
+ export declare const lowerCase: (str: string) => Lowercase<string>;
@@ -0,0 +1 @@
1
+ export declare const getUniqueId: () => string;
@@ -0,0 +1,10 @@
1
+ import { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
+ import { VuuGroupBy } from "@vuu-ui/vuu-protocol-types";
3
+ export declare function addGroupColumn(groupBy: VuuGroupBy, column: ColumnDescriptor): string[];
4
+ export declare const removeGroupColumn: (groupBy: VuuGroupBy, column: ColumnDescriptor) => string[];
5
+ export type ColumnGroupStatus = "no-groupby" | "single-groupby-other-column" | "single-groupby" | "multi-groupby-other-columns" | "multi-groupby-includes-column";
6
+ /**
7
+ * Given a VuuGroupby definition and a column, determine whether the given column
8
+ * is included in the grouping and if so, in what position/direction.
9
+ */
10
+ export declare const getGroupStatus: (columnName: string, groupBy?: VuuGroupBy) => ColumnGroupStatus;
@@ -0,0 +1,21 @@
1
+ export declare const createEl: (elementType: "div" | "p" | "span", className?: string, textContent?: string) => HTMLElement;
2
+ export declare const getFocusableElement: (el: HTMLElement | null, tabIndex?: number) => HTMLElement | undefined;
3
+ export declare const getElementDataIndex: (el: HTMLElement | null) => number;
4
+ export declare function queryClosest<T extends HTMLElement = HTMLElement>(el: HTMLElement | EventTarget | null, cssQueryString: string, throwIfNotFound?: false): T | null;
5
+ export declare function queryClosest<T extends HTMLElement = HTMLElement>(el: HTMLElement | EventTarget | null, cssQueryString: string, throwIfNotFound: true): T;
6
+ export declare const getClosest: (el: HTMLElement, dataProperty: string) => HTMLElement | null;
7
+ export declare const getClosestIndexItem: (el: HTMLElement) => HTMLElement | null;
8
+ export declare function getElementByDataIndex(c: HTMLElement | null | undefined, i: number | string, throwIfNotFound: true): HTMLElement;
9
+ export declare function getElementByDataIndex(c: HTMLElement | null | undefined, i: number | string, throwIfNotFound?: false): HTMLElement | undefined;
10
+ export declare const focusFirstFocusableElement: (el: HTMLElement | null, tabIndex?: number) => void;
11
+ export declare const isSelectableElement: (el?: HTMLElement | null) => boolean;
12
+ export declare const isInputElement: (el: HTMLElement | EventTarget | null) => el is HTMLInputElement;
13
+ export declare const isDateInput: (el: HTMLElement | EventTarget | null) => el is HTMLInputElement;
14
+ export declare const hasOpenOptionList: (el: HTMLElement | EventTarget | null) => boolean | undefined;
15
+ export declare function getScrollbarSize(): number;
16
+ export type MouseEventTypes = "dblclick" | "click";
17
+ export type KeyboardEventTypes = "keydown" | "keypress" | "keyup";
18
+ export declare const dispatchMouseEvent: (el: HTMLElement, type: MouseEventTypes) => void;
19
+ export declare const dispatchKeyboardEvent: (el: HTMLElement, type: KeyboardEventTypes, key: string) => void;
20
+ export type VuuDomEventType = "vuu-commit" | "vuu-dropped" | "vuu-begin-edit" | "vuu-enter-edit-mode" | "vuu-exit-edit-mode";
21
+ export declare const dispatchCustomEvent: (el: HTMLElement, type: VuuDomEventType) => void;