@vuu-ui/vuu-utils 3.5.5 → 3.5.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 (83) hide show
  1. package/package.json +6 -6
  2. package/src/column-utils.js +7 -4
  3. package/src/feature-utils.js +7 -1
  4. package/src/round-decimal.js +10 -2
  5. package/types/feature-utils.d.ts +16 -2
  6. package/types/tree-types.d.ts +2 -0
  7. package/types/src/Clock.d.ts +0 -20
  8. package/types/src/PageVisibilityObserver.d.ts +0 -36
  9. package/types/src/ScaledDecimal.d.ts +0 -12
  10. package/types/src/ShellContext.d.ts +0 -11
  11. package/types/src/ThemeProvider.d.ts +0 -32
  12. package/types/src/array-utils.d.ts +0 -16
  13. package/types/src/box-utils.d.ts +0 -24
  14. package/types/src/broadcast-channel.d.ts +0 -16
  15. package/types/src/column-utils.d.ts +0 -243
  16. package/types/src/common-types.d.ts +0 -6
  17. package/types/src/component-registry.d.ts +0 -65
  18. package/types/src/context-definitions/DataContext.d.ts +0 -21
  19. package/types/src/context-definitions/DataProvider.d.ts +0 -7
  20. package/types/src/context-definitions/DataSourceProvider.d.ts +0 -12
  21. package/types/src/context-definitions/WorkspaceContext.d.ts +0 -17
  22. package/types/src/cookie-utils.d.ts +0 -9
  23. package/types/src/css-utils.d.ts +0 -1
  24. package/types/src/data-utils.d.ts +0 -33
  25. package/types/src/datasource/BaseDataSource.d.ts +0 -63
  26. package/types/src/datasource/datasource-action-utils.d.ts +0 -7
  27. package/types/src/datasource/datasource-filter-utils.d.ts +0 -2
  28. package/types/src/datasource/datasource-utils.d.ts +0 -61
  29. package/types/src/date/date-utils.d.ts +0 -39
  30. package/types/src/date/dateTimePattern.d.ts +0 -8
  31. package/types/src/date/formatter.d.ts +0 -9
  32. package/types/src/date/index.d.ts +0 -4
  33. package/types/src/date/types.d.ts +0 -29
  34. package/types/src/debug-utils.d.ts +0 -9
  35. package/types/src/edit-utils.d.ts +0 -2
  36. package/types/src/errors.d.ts +0 -2
  37. package/types/src/event-emitter.d.ts +0 -21
  38. package/types/src/feature-utils.d.ts +0 -110
  39. package/types/src/filters/filter-utils.d.ts +0 -75
  40. package/types/src/filters/filterAsQuery.d.ts +0 -8
  41. package/types/src/filters/index.d.ts +0 -2
  42. package/types/src/form-utils.d.ts +0 -37
  43. package/types/src/formatting-utils.d.ts +0 -14
  44. package/types/src/getUniqueId.d.ts +0 -1
  45. package/types/src/group-utils.d.ts +0 -10
  46. package/types/src/html-utils.d.ts +0 -21
  47. package/types/src/index.d.ts +0 -76
  48. package/types/src/input-utils.d.ts +0 -2
  49. package/types/src/invariant.d.ts +0 -1
  50. package/types/src/itemToString.d.ts +0 -2
  51. package/types/src/json-types.d.ts +0 -52
  52. package/types/src/json-utils.d.ts +0 -6
  53. package/types/src/keyboard-utils.d.ts +0 -15
  54. package/types/src/keyset.d.ts +0 -16
  55. package/types/src/layout-types.d.ts +0 -22
  56. package/types/src/list-utils.d.ts +0 -2
  57. package/types/src/local-storage-utils.d.ts +0 -4
  58. package/types/src/logging-utils.d.ts +0 -45
  59. package/types/src/module-utils.d.ts +0 -8
  60. package/types/src/nanoid/index.d.ts +0 -1
  61. package/types/src/perf-utils.d.ts +0 -5
  62. package/types/src/promise-utils.d.ts +0 -8
  63. package/types/src/protocol-message-utils.d.ts +0 -43
  64. package/types/src/range-utils.d.ts +0 -29
  65. package/types/src/react-utils.d.ts +0 -15
  66. package/types/src/round-decimal.d.ts +0 -4
  67. package/types/src/row-utils.d.ts +0 -28
  68. package/types/src/selection-utils.d.ts +0 -9
  69. package/types/src/shell-layout-types.d.ts +0 -15
  70. package/types/src/sort-utils.d.ts +0 -11
  71. package/types/src/table-schema-utils.d.ts +0 -5
  72. package/types/src/text-utils.d.ts +0 -10
  73. package/types/src/theme-utils.d.ts +0 -14
  74. package/types/src/tree-types.d.ts +0 -9
  75. package/types/src/tree-utils.d.ts +0 -9
  76. package/types/src/ts-utils.d.ts +0 -20
  77. package/types/src/typeahead-utils.d.ts +0 -1
  78. package/types/src/url-utils.d.ts +0 -3
  79. package/types/src/useId.d.ts +0 -1
  80. package/types/src/useLayoutEffectSkipFirst.d.ts +0 -2
  81. package/types/src/useResizeObserver.d.ts +0 -15
  82. package/types/src/useStateRef.d.ts +0 -2
  83. package/types/src/user-types.d.ts +0 -3
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.5",
2
+ "version": "3.5.6",
3
3
  "author": "heswell",
4
4
  "main": "./src/index.js",
5
5
  "license": "Apache-2.0",
@@ -15,14 +15,14 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@dnd-kit/react": "^0.1.21",
18
- "@vuu-ui/vuu-data-types": "3.5.5",
19
- "@vuu-ui/vuu-table-types": "3.5.5",
20
- "@vuu-ui/vuu-filter-types": "3.5.5",
21
- "@vuu-ui/vuu-protocol-types": "3.5.5"
18
+ "@vuu-ui/vuu-data-types": "3.5.6",
19
+ "@vuu-ui/vuu-table-types": "3.5.6",
20
+ "@vuu-ui/vuu-filter-types": "3.5.6",
21
+ "@vuu-ui/vuu-protocol-types": "3.5.6"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@internationalized/date": "^3.0.0",
25
- "@vuu-ui/vuu-filter-parser": "3.5.5",
25
+ "@vuu-ui/vuu-filter-parser": "3.5.6",
26
26
  "clsx": "^2.0.0",
27
27
  "react": "^19.2.3",
28
28
  "react-dom": "^19.2.3"
@@ -45,14 +45,17 @@ const getRuntimeColumnWidth = (col, runtimeColumns)=>{
45
45
  if (runtimeColumn) return runtimeColumn.width;
46
46
  return DEFAULT_COL_WIDTH;
47
47
  };
48
- const applyRuntimeColumnWidthsToConfig = (tableConfig, columns)=>({
48
+ const applyRuntimeColumnWidthsToConfig = (tableConfig, columns)=>{
49
+ const runtimeColumns = columns.flatMap((column)=>isGroupColumn(column) ? column.columns : column);
50
+ return {
49
51
  ...tableConfig,
50
- columns: columns.map((column)=>({
52
+ columns: tableConfig.columns.map((column)=>({
51
53
  ...column,
52
- width: column.width ?? getRuntimeColumnWidth(column, columns)
54
+ width: runtimeColumns.find(({ name })=>name === column.name)?.width ?? column.width ?? DEFAULT_COL_WIDTH
53
55
  })),
54
56
  columnLayout: "manual"
55
- });
57
+ };
58
+ };
56
59
  const isValidColumnAlignment = (v)=>"left" === v || "right" === v;
57
60
  const isValidPinLocation = (v)=>isValidColumnAlignment(v) || "floating" === v || "" === v;
58
61
  const VUU_COLUMN_DATA_TYPES = [
@@ -3,6 +3,12 @@ import { wordify } from "./text-utils.js";
3
3
  import react from "react";
4
4
  import { getLayoutComponent } from "./component-registry.js";
5
5
  const env = process.env.NODE_ENV;
6
+ const importFeatureByUrl = (url)=>import(/* @vite-ignore */ url);
7
+ let featureImporter = importFeatureByUrl;
8
+ const setFeatureImporter = (importer)=>{
9
+ featureImporter = importer;
10
+ };
11
+ const importFeature = (url)=>featureImporter(url);
6
12
  const isStaticFeature = (feature)=>null !== feature && "object" == typeof feature && "type" in feature;
7
13
  const isStaticFeatures = (features)=>Array.isArray(features) && features.every(isStaticFeature);
8
14
  function featureFromJson({ type }) {
@@ -83,4 +89,4 @@ const getCustomAndTableFeatures = (dynamicFeatures, tableSchemas)=>{
83
89
  tableFeatures: tableFeatures
84
90
  };
85
91
  };
86
- export { assertComponentRegistered, assertComponentsRegistered, byModule, env, featureFromJson, getCustomAndTableFeatures, getFilterTableFeatures, hasFilterTableFeatureProps, isCustomFeature, isSameTable, isStaticFeatures, isVuuTables, isWildcardSchema };
92
+ export { assertComponentRegistered, assertComponentsRegistered, byModule, env, featureFromJson, getCustomAndTableFeatures, getFilterTableFeatures, hasFilterTableFeatureProps, importFeature, importFeatureByUrl, isCustomFeature, isSameTable, isStaticFeatures, isVuuTables, isWildcardSchema, setFeatureImporter };
@@ -4,6 +4,12 @@ const DECIMALS_AUTO = -1;
4
4
  const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER.toString();
5
5
  const MAX_INTEGER_DIGITS = MAX_SAFE_INTEGER.length;
6
6
  const exceedsMaxSafeInteger = (value)=>value.length > MAX_INTEGER_DIGITS || value.length === MAX_INTEGER_DIGITS && value > MAX_SAFE_INTEGER;
7
+ const carriesIntoIntegral = (fraction, decimals, roundingRule)=>"round" === roundingRule && decimals !== DECIMALS_AUTO && fraction.length > decimals && parseFloat(`0.${fraction}`).toFixed(decimals).startsWith("1");
8
+ const incrementIntegral = (integral)=>{
9
+ const negative = integral.startsWith("-");
10
+ const magnitude = BigInt(negative ? integral.slice(1) : integral) + 1n;
11
+ return `${negative ? "-" : ""}${magnitude}`;
12
+ };
7
13
  const Space = {
8
14
  DIGIT: DIGIT_STR,
9
15
  TWO_DIGITS: DIGIT_STR + DIGIT_STR,
@@ -61,7 +67,8 @@ function roundDecimal(value, align = Align.Right, decimals = 4, zeroPad, alignOn
61
67
  let integral;
62
68
  let fraction;
63
69
  let Pad;
64
- const [part1, part2 = ""] = value.toString().split(".");
70
+ const [whole, part2 = ""] = value.toString().split(".");
71
+ const part1 = carriesIntoIntegral(part2, decimals, roundingRule) ? incrementIntegral(whole) : whole;
65
72
  const actualDecimals = part2.length;
66
73
  integral = "-0" === part1 ? "-0" : useLocaleString ? parseFloat(part1).toLocaleString() : parseFloat(part1).toString();
67
74
  if (align === Align.Left && alignOnDecimals) integral = padLeft(integral);
@@ -73,7 +80,8 @@ function roundScaledDecimal(value, align = Align.Right, decimals = 4, zeroPad, a
73
80
  let fraction;
74
81
  let Pad;
75
82
  if ("" === value) return "";
76
- const [part1, part2 = ""] = value.split(".");
83
+ const [whole, part2 = ""] = value.split(".");
84
+ const part1 = carriesIntoIntegral(part2, decimals, roundingRule) ? incrementIntegral(whole) : whole;
77
85
  const actualDecimals = part2.length;
78
86
  integral = "" === part1 ? "0" : "-0" === part1 ? "-0" : useLocaleString ? exceedsMaxSafeInteger(value) ? BigInt(part1).toLocaleString() : parseFloat(part1).toLocaleString() : part1;
79
87
  if (align === Align.Left && alignOnDecimals) integral = padLeft(integral);
@@ -1,7 +1,7 @@
1
1
  import type { TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
3
- import { ListOption } from "@vuu-ui/vuu-table-types";
4
- import { ReactElement } from "react";
3
+ import type { ListOption } from "@vuu-ui/vuu-table-types";
4
+ import React, { type ReactElement } from "react";
5
5
  export type PathMap = {
6
6
  [key: string]: Pick<DynamicFeatureDescriptor, "css" | "url">;
7
7
  };
@@ -29,6 +29,20 @@ export interface DynamicFeatureProps<P extends object | undefined = object> {
29
29
  url: string;
30
30
  width?: number;
31
31
  }
32
+ export type FeatureModule = {
33
+ default: React.ComponentType<object>;
34
+ };
35
+ export type FeatureImporter = (url: string) => Promise<FeatureModule>;
36
+ declare const importFeatureByUrl: FeatureImporter;
37
+ /**
38
+ * By default, a dynamic feature is loaded from its url with a native
39
+ * dynamic import. An application that bundles its features can install
40
+ * an importer that resolves feature urls to bundled modules. Use
41
+ * `importFeatureByUrl` as a fallback for unknown urls.
42
+ */
43
+ export declare const setFeatureImporter: (importer: FeatureImporter) => void;
44
+ export declare const importFeature: (url: string) => Promise<FeatureModule>;
45
+ export { importFeatureByUrl };
32
46
  declare global {
33
47
  const vuuConfig: Promise<VuuConfig>;
34
48
  }
@@ -5,5 +5,7 @@ export interface TreeSourceNode<T = unknown> {
5
5
  header?: boolean;
6
6
  label: string;
7
7
  childNodes?: TreeSourceNode<T>[];
8
+ /** node is rendered expanded initially */
9
+ expanded?: boolean;
8
10
  tags?: string[];
9
11
  }
@@ -1,20 +0,0 @@
1
- export interface ClockProps {
2
- year?: number;
3
- month?: number;
4
- day?: number;
5
- hours?: number;
6
- minutes?: number;
7
- seconds?: number;
8
- milliseconds?: number;
9
- }
10
- export type ClockTimeUnit = "minutes" | "seconds" | "ms";
11
- export declare class Clock {
12
- #private;
13
- constructor(props?: ClockProps);
14
- goBack(value: number, units?: ClockTimeUnit): this;
15
- advance(value: number, units?: ClockTimeUnit): this;
16
- set showCurrentTime(value: boolean);
17
- toString(): string;
18
- get now(): number;
19
- get date(): Date;
20
- }
@@ -1,36 +0,0 @@
1
- import { EventEmitter } from "./event-emitter";
2
- export type PageVisibilityEvents = {
3
- /**
4
- * emits when page has been hidden for this period of time
5
- */
6
- "inactive-timeout": () => void;
7
- /**
8
- * emits when page is hidden
9
- */
10
- hidden: () => void;
11
- /**
12
- * emits when page is made visible
13
- */
14
- visible: () => void;
15
- /**
16
- * emits when page visibility status changes
17
- */
18
- visibilityChange: (hidden: boolean) => void;
19
- };
20
- export interface PageVisibilityObserverConstructorProps {
21
- /**
22
- * timeout period in seconds. Defaults to zero which will never timeout
23
- */
24
- inactiveTimeout?: number;
25
- onHidden?: () => void;
26
- onInactiveTimeout?: () => void;
27
- onVisible?: () => void;
28
- onVisibilityChange?: () => void;
29
- }
30
- export declare class PageVisibilityObserver extends EventEmitter<PageVisibilityEvents> {
31
- #private;
32
- visibilityChangeHandler: () => void;
33
- constructor({ inactiveTimeout, onHidden, onInactiveTimeout, onVisibilityChange, onVisible, }?: PageVisibilityObserverConstructorProps);
34
- clear(): void;
35
- private set hidden(value);
36
- }
@@ -1,12 +0,0 @@
1
- export declare class ScaledDecimal {
2
- protected readonly value: string;
3
- private readonly decimals;
4
- constructor(value: string, decimals?: number);
5
- get asLong(): string;
6
- toJSON(): string;
7
- toString(): string;
8
- }
9
- export declare const ScaledDecimal2: (value: string) => ScaledDecimal;
10
- export declare const ScaledDecimal4: (value: string) => ScaledDecimal;
11
- export declare const ScaledDecimal6: (value: string) => ScaledDecimal;
12
- export declare const ScaledDecimal8: (value: string) => ScaledDecimal;
@@ -1,11 +0,0 @@
1
- import type { RpcResponseHandler } from "@vuu-ui/vuu-data-types";
2
- import type { DefaultColumnConfiguration, DefaultTableConfiguration } from "@vuu-ui/vuu-table-types";
3
- import { LookupTableProvider } from "./feature-utils";
4
- export interface ShellContextProps {
5
- getDefaultColumnConfig?: DefaultColumnConfiguration;
6
- getDefaultTableConfig?: DefaultTableConfiguration;
7
- getLookupValues?: LookupTableProvider;
8
- handleRpcResponse?: RpcResponseHandler;
9
- }
10
- export declare const ShellContext: import("react").Context<ShellContextProps>;
11
- export declare const useShellContext: () => ShellContextProps;
@@ -1,32 +0,0 @@
1
- import { type ReactNode } from "react";
2
- export declare const DEFAULT_DENSITY: Density;
3
- export declare const DEFAULT_THEME = "salt-theme";
4
- export declare const DEFAULT_THEME_MODE: ThemeMode;
5
- export type Density = "high" | "medium" | "low" | "touch";
6
- export type ThemeMode = "light" | "dark";
7
- export type TargetElement = "root" | "scope" | "child";
8
- export interface ThemeContextProps {
9
- density: Density;
10
- theme: string;
11
- themeMode: ThemeMode;
12
- }
13
- export declare const ThemeContext: import("react").Context<ThemeContextProps>;
14
- export type ThemeClasses = [string, string, ThemeMode];
15
- export type ThemeAttributes = {
16
- themeClass: string;
17
- densityClass: string;
18
- dataMode: ThemeMode;
19
- };
20
- export declare const useThemeAttributes: (themeAttributes?: ThemeAttributes) => [string, string, ThemeMode];
21
- interface ThemeProviderProps {
22
- applyThemeClasses?: boolean;
23
- children: ReactNode;
24
- density?: Density;
25
- theme?: string;
26
- themeMode?: ThemeMode;
27
- }
28
- export declare function ThemeProvider({ applyThemeClasses, children, theme: themeProp, themeMode: themeModeProp, density: densityProp, }: ThemeProviderProps): import("react").JSX.Element;
29
- export declare namespace ThemeProvider {
30
- var displayName: string;
31
- }
32
- export {};
@@ -1,16 +0,0 @@
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 function itemsOrOrderChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
5
- export declare const moveItemDeprecated: <T = unknown>(items: T[], item: T, moveTo: number) => T[];
6
- export declare const moveItem: <T = unknown>(items: T[], fromIndex: number, toIndex: number) => T[];
7
- export declare const getAddedItems: <T>(values: undefined | T[], newValues: T[]) => T[];
8
- export declare const getMissingItems: <T, I>(sourceItems: T[], items: I[], identity: (s: T) => I) => I[];
9
- /**
10
- * Given an ordered list of item names, return items in same order
11
- */
12
- export declare const reorderItems: <T extends {
13
- name: string;
14
- } = {
15
- name: string;
16
- }>(originalItems: readonly T[], orderedNames: string[]) => T[];
@@ -1,24 +0,0 @@
1
- export interface rect {
2
- bottom: number;
3
- left: number;
4
- right: number;
5
- top: number;
6
- }
7
- export type rectTuple = [number, number, number, number];
8
- export type dimension = "width" | "height";
9
- export declare function boxContainsPoint(rect: rect, x: number, y: number): boolean | undefined;
10
- export type GridLayoutSplitDirection = "north" | "south" | "east" | "west";
11
- export type GridLayoutDropPosition = GridLayoutSplitDirection | "header" | "centre";
12
- export declare function getCenteredBox({ right, left, top, bottom }: rect, pctSize: number): {
13
- left: number;
14
- top: number;
15
- right: number;
16
- bottom: number;
17
- };
18
- export declare function pointPositionWithinRect(x: number, y: number, rect: rect, borderZone?: number): {
19
- pctX: number;
20
- pctY: number;
21
- closeToTheEdge: number;
22
- };
23
- export declare const isGridLayoutSplitDirection: (position: GridLayoutDropPosition) => position is GridLayoutSplitDirection;
24
- export declare function getPositionWithinBox(x: number, y: number, rect: rect, pctX: number, pctY: number): GridLayoutDropPosition;
@@ -1,16 +0,0 @@
1
- interface VuuBroadcastChannelEventMap<T> {
2
- message: MessageEvent<T>;
3
- messageerror: MessageEvent<T>;
4
- }
5
- export interface VuuBroadcastChannel<T> extends EventTarget {
6
- readonly name: string;
7
- onmessage: ((this: BroadcastChannel, evt: MessageEvent<T>) => void) | null;
8
- onmessageerror: ((this: BroadcastChannel, evt: MessageEvent<T>) => void) | null;
9
- close(): void;
10
- postMessage<M extends T = T>(message: M): void;
11
- addEventListener<K extends keyof VuuBroadcastChannelEventMap<T>>(type: K, listener: (this: BroadcastChannel, evt: VuuBroadcastChannelEventMap<T>[K]) => void, options?: boolean | AddEventListenerOptions): void;
12
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
13
- removeEventListener<K extends keyof VuuBroadcastChannelEventMap<T>>(type: K, listener: (this: BroadcastChannel, evt: VuuBroadcastChannelEventMap<T>[K]) => void, options?: boolean | EventListenerOptions): void;
14
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
15
- }
16
- export {};
@@ -1,243 +0,0 @@
1
- import type { DataSourceRow, DataValueDescriptor, DataValueType, DataValueTypeSimple, DateTimeDataValueDescriptor, SchemaColumn, TableSchema, TimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
2
- import type { VuuAggType, VuuAggregation, VuuColumnDataType, VuuDataRowDto, VuuGroupBy, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
- import { TableModel } from "@vuu-ui/vuu-table";
4
- import type { ColumnAlignment, ColumnDescriptor, ColumnLayout, ColumnTypeFormatting, ColumnTypeRendering, ColumnTypeWithValidationRules, DataRow, DataValueTypeDescriptor, DefaultColumnConfiguration, GroupColumnDescriptor, LookupRenderer, MappedValueTypeRenderer, PinLocation, RuntimeColumnDescriptor, TableCellRendererProps, TableConfig, TableHeadings, ValueListRenderer } from "@vuu-ui/vuu-table-types";
5
- import { type CSSProperties } from "react";
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 interface ReverseColumnMap {
14
- [columnIndex: number]: string;
15
- }
16
- export type SortCriteriaItem = string | [string, "asc"];
17
- export declare const AggregationType: {
18
- [key: string]: VuuAggType;
19
- };
20
- export declare function mapSortCriteria(sortCriteria: SortCriteriaItem[], columnMap: ColumnMap, metadataOffset?: number): [number, "asc"][];
21
- export declare const getDefaultAlignment: (serverDataType?: VuuColumnDataType) => ColumnAlignment;
22
- export type EditOperation = "insert" | "update";
23
- export declare const isDataValueEditable: (dataDescriptor: Pick<DataValueDescriptor, "editable">, operation: EditOperation, defaultValue?: boolean) => boolean;
24
- export declare const getRuntimeColumnWidth: (col: ColumnDescriptor, runtimeColumns: RuntimeColumnDescriptor[]) => number;
25
- export declare const applyRuntimeColumnWidthsToConfig: (tableConfig: TableConfig, columns: RuntimeColumnDescriptor[]) => TableConfig;
26
- export declare const isValidColumnAlignment: (v: string) => v is ColumnAlignment;
27
- export declare const isValidPinLocation: (v: string) => v is PinLocation;
28
- export type CalculatedColumn = {
29
- name: string;
30
- expression: string;
31
- serverDataType: VuuColumnDataType;
32
- };
33
- export declare const isVuuColumnDataType: (value: string | undefined | null) => value is VuuColumnDataType;
34
- export declare const fromServerDataType: (serverDataType: VuuColumnDataType) => DataValueTypeSimple;
35
- export declare const isNanoTimestampColumn: ({ serverDataType, }: DataValueDescriptor) => boolean;
36
- export declare const isTimestampColumn: (column: ColumnDescriptor) => boolean;
37
- export declare const isNumericColumn: ({ serverDataType, type }: ColumnDescriptor) => boolean;
38
- export declare const isDateTimeDataType: (column: ColumnDescriptor) => column is DateTimeDataValueDescriptor;
39
- export declare const isTimeDataType: (column: ColumnDescriptor) => column is TimeDataValueDescriptor;
40
- export declare const isDateTimeDataValue: (column: ColumnDescriptor) => boolean;
41
- export declare const isTimeDataValue: (column?: ColumnDescriptor) => column is TimeDataValueDescriptor;
42
- export declare const isPinned: (column: ColumnDescriptor) => boolean;
43
- export declare const hasHeadings: (column: ColumnDescriptor) => boolean;
44
- export declare const isResizing: (column: RuntimeColumnDescriptor) => boolean | undefined;
45
- export declare const isTextColumn: ({ serverDataType }: ColumnDescriptor) => boolean;
46
- export declare const toColumnDescriptor: (name: string, serverDataType?: ColumnDescriptor["serverDataType"]) => ColumnDescriptor;
47
- /**
48
- *
49
- */
50
- export declare const isTypeDescriptor: (type?: DataValueType) => type is DataValueTypeDescriptor;
51
- export declare const isColumnTypeRenderer: (renderer?: unknown) => renderer is ColumnTypeRendering;
52
- export declare const hasCustomRenderer: (type?: DataValueType) => type is DataValueTypeDescriptor;
53
- export declare const isLookupRenderer: (renderer?: unknown) => renderer is LookupRenderer;
54
- export declare const isValueListRenderer: (renderer?: unknown) => renderer is ValueListRenderer;
55
- export declare const hasValidationRules: (type?: DataValueType) => type is ColumnTypeWithValidationRules;
56
- export declare const isMappedValueTypeRenderer: (renderer?: unknown) => renderer is MappedValueTypeRenderer;
57
- export declare function buildColumnMap(columns?: readonly (ColumnDescriptor | SchemaColumn | string)[]): ColumnMap;
58
- export declare function projectUpdates(updates: number[]): number[];
59
- export declare const metadataKeys: {
60
- readonly IDX: 0;
61
- readonly RENDER_IDX: 1;
62
- readonly IS_LEAF: 2;
63
- readonly IS_EXPANDED: 3;
64
- readonly DEPTH: 4;
65
- readonly COUNT: 5;
66
- readonly KEY: 6;
67
- readonly SELECTED: 7;
68
- readonly TIMESTAMP: 8;
69
- readonly IS_NEW: 9;
70
- readonly count: 10;
71
- readonly PARENT_IDX: "parent_idx";
72
- readonly IDX_POINTER: "idx_pointer";
73
- readonly FILTER_COUNT: "filter_count";
74
- readonly NEXT_FILTER_IDX: "next_filter_idx";
75
- };
76
- export declare const flattenColumnGroup: (columns: RuntimeColumnDescriptor[]) => RuntimeColumnDescriptor[];
77
- export declare function extractGroupColumn({ availableWidth, columns, groupBy, confirmed, }: ColumnGroupProps): [
78
- GroupColumnDescriptor | null,
79
- RuntimeColumnDescriptor[]
80
- ];
81
- export declare const isGroupColumn: (column: RuntimeColumnDescriptor) => column is GroupColumnDescriptor;
82
- /**
83
- * groupConfirmed is currently the only 'pending' attribute we use. A
84
- * value of true is only reset by a follow-up value of false. Intermediary
85
- * values of undefined are discounted.
86
- */
87
- export declare const checkConfirmationPending: (previousConfig?: TableModel) => boolean | undefined;
88
- export declare const isJsonAttribute: (value: unknown) => boolean;
89
- export declare const isJsonGroup: (column: RuntimeColumnDescriptor, dataRow: DataRow) => boolean;
90
- export declare const isJsonColumn: (column: RuntimeColumnDescriptor) => boolean;
91
- export declare const sortPinnedColumns: (columns: RuntimeColumnDescriptor[], selectionBookendWidth?: number) => RuntimeColumnDescriptor[];
92
- export declare const measurePinnedColumns: (columns: RuntimeColumnDescriptor[], selectionEndSize: number) => {
93
- pinnedWidthLeft: number;
94
- pinnedWidthRight: number;
95
- unpinnedWidth: number;
96
- };
97
- export declare const getTableHeadings: (columns: RuntimeColumnDescriptor[]) => TableHeadings;
98
- export declare const getColumnStyle: ({ pin, pinnedOffset, pinnedWidth, width, }: RuntimeColumnDescriptor) => CSSProperties;
99
- export declare const getAllCellsInColumn: (container: HTMLElement | null, colIndex: number) => HTMLDivElement[];
100
- export type PinState = {
101
- /**
102
- * The pinned 'endPin' cell
103
- */
104
- cell: HTMLElement;
105
- /**
106
- * With multiple columns pinned, left pinned columns that follow
107
- * // the resized column. These will need pinOffset adjustments.
108
- */
109
- pinnedCells?: HTMLElement[];
110
- pinnedWidth: number;
111
- };
112
- export declare const getAriaRowIndex: (rowElement: HTMLElement | null) => number;
113
- export declare const getAriaColIndex: (cellElement: HTMLElement | null) => number;
114
- export declare const getPinStateFromElement: (cell: HTMLElement) => PinState | undefined;
115
- export declare const setAggregations: (aggregations: VuuAggregation[], column: ColumnDescriptor, aggType: VuuAggType) => VuuAggregation[];
116
- export type ColumnGroupProps = {
117
- columns: RuntimeColumnDescriptor[];
118
- groupBy: VuuGroupBy;
119
- confirmed?: boolean;
120
- availableWidth: number;
121
- };
122
- export declare const applyGroupByToColumns: (props: ColumnGroupProps) => RuntimeColumnDescriptor[];
123
- export declare const applySortToColumns: (columns: RuntimeColumnDescriptor[], sort: VuuSort) => RuntimeColumnDescriptor[];
124
- export declare const removeSort: (columns: RuntimeColumnDescriptor[]) => RuntimeColumnDescriptor[];
125
- export declare const existingSort: (columns: RuntimeColumnDescriptor[]) => boolean;
126
- export declare const getColumnName: (name: string) => string;
127
- export declare const getColumnLabel: (column: ColumnDescriptor) => string;
128
- export declare const findColumn: (columns: RuntimeColumnDescriptor[], columnName: string) => RuntimeColumnDescriptor | undefined;
129
- export declare function updateColumn<T extends ColumnDescriptor>(columns: readonly T[], column: T): T[];
130
- export declare function updateColumn(columns: readonly RuntimeColumnDescriptor[], column: string, options: Partial<ColumnDescriptor>): RuntimeColumnDescriptor[];
131
- export declare const toDataSourceColumns: (column: ColumnDescriptor) => string;
132
- export declare const dataSourceRowToDataRowDto: (row: DataSourceRow, columnMap: ColumnMap) => VuuDataRowDto;
133
- export declare const isDataLoading: (columns: RuntimeColumnDescriptor[]) => boolean;
134
- export declare const getColumnsInViewport: (columns: RuntimeColumnDescriptor[], vpStart: number, vpEnd: number) => [RuntimeColumnDescriptor[], number];
135
- export declare const isNotHidden: (column: RuntimeColumnDescriptor) => boolean;
136
- export declare const visibleColumnAtIndex: (columns: RuntimeColumnDescriptor[], index: number) => RuntimeColumnDescriptor | undefined;
137
- export declare const getGroupIcon: (columns: RuntimeColumnDescriptor[], dataRow: DataRow) => string | undefined;
138
- export declare const getGroupValue: (columns: RuntimeColumnDescriptor[], dataRow: DataRow) => string | null;
139
- export declare const getDefaultColumnType: (serverDataType?: VuuColumnDataType) => DataValueTypeSimple;
140
- export declare const updateColumnFormatting: <T extends ColumnDescriptor = ColumnDescriptor>(column: T, formatting: ColumnTypeFormatting) => T;
141
- export declare function updateColumnType<T extends ColumnDescriptor = ColumnDescriptor>(column: T, type: DataValueTypeSimple): T;
142
- export declare const updateColumnRenderProps: <T extends ColumnDescriptor = ColumnDescriptor>(column: T, renderer: ColumnTypeRendering) => T;
143
- export declare const getTypeFormattingFromColumn: (column: ColumnDescriptor) => ColumnTypeFormatting;
144
- /**
145
- * Check that columnDescriptors are included in provided list of subscribec column names (unless they
146
- * atr 'client side' columns).
147
- */
148
- export declare const assertAllColumnsAreIncludedInSubscription: (columns: readonly ColumnDescriptor[], columnNames: string[]) => void;
149
- /**
150
- * Return a filter predicate that will reject columns, names of which
151
- * are not in provided list. Exception made for columns explicitly
152
- * configured as client columns.
153
- */
154
- export declare const subscribedOnly: (columnNames?: string[]) => (column: ColumnDescriptor) => boolean | undefined;
155
- /**
156
- * Called from TableSettings.ColumnList when a column is added to subscription.
157
- *
158
- * @param subscribedColumns
159
- * @param availableColumns
160
- * @param columnName
161
- * @returns
162
- */
163
- export declare const addColumnToSubscribedColumns: (subscribedColumns: readonly ColumnDescriptor[], availableColumns: readonly SchemaColumn[], columnName: string) => ColumnDescriptor[];
164
- export declare function getServerDataType(column: ColumnDescriptor): VuuColumnDataType | undefined;
165
- export declare function getServerDataType(column: ColumnDescriptor, throwIfUndefined: true): VuuColumnDataType;
166
- export declare const isCalculatedColumn: (columnName?: string) => boolean;
167
- export declare const getCalculatedColumnDetails: (column: ColumnDescriptor | string) => Partial<CalculatedColumn>;
168
- export declare const setCalculatedColumnName: (column: ColumnDescriptor, name: string) => ColumnDescriptor;
169
- export declare const setCalculatedColumnType: (column: ColumnDescriptor, serverDataType: VuuColumnDataType) => ColumnDescriptor;
170
- export declare const setCalculatedColumnExpression: (column: ColumnDescriptor, expression: string) => ColumnDescriptor;
171
- export declare const moveColumnTo: (columns: ColumnDescriptor[], column: ColumnDescriptor, newIndex: number) => ColumnDescriptor[];
172
- export declare function replaceColumn<C extends ColumnDescriptor = RuntimeColumnDescriptor>(columns: readonly C[], column: C): C[];
173
- export declare const applyDefaultColumnConfig: ({ columns: columnsProp, table }: TableSchema, getDefaultColumnConfig?: DefaultColumnConfiguration, includeVuuDefaultColumns?: boolean) => (SchemaColumn | {
174
- aggregate?: VuuAggType;
175
- align?: ColumnAlignment;
176
- allowColumnHeaderMenu?: false;
177
- className?: string;
178
- colHeaderContentRenderer?: string;
179
- colHeaderLabelRenderer?: string;
180
- exportFormatter?: (value: unknown) => string;
181
- flex?: number;
182
- getIcon?: (row: DataRow) => string | undefined;
183
- groupable?: boolean;
184
- heading?: string[];
185
- hidden?: boolean;
186
- isSystemColumn?: boolean;
187
- locked?: Exclude<PinLocation, "left"> | false;
188
- maxWidth?: number;
189
- minWidth?: number;
190
- pin?: PinLocation | false;
191
- removeable?: boolean;
192
- resizeable?: boolean;
193
- selected?: boolean;
194
- sortable?: boolean;
195
- source?: "client" | "server";
196
- status?: import("@salt-ds/core").ValidationStatus;
197
- width?: number;
198
- editableBulk?: import("@vuu-ui/vuu-data-types").BulkEdit;
199
- label?: string;
200
- required?: boolean;
201
- type?: DataValueType;
202
- editable?: import("@vuu-ui/vuu-data-types").DataEditable | undefined;
203
- name: string;
204
- serverDataType: VuuColumnDataType;
205
- })[] | readonly SchemaColumn[];
206
- export type columnOptions = {
207
- availableWidth?: number;
208
- columnLayout?: ColumnLayout;
209
- defaultWidth?: number;
210
- defaultMinWidth?: number;
211
- defaultMaxWidth?: number;
212
- defaultFlex?: number;
213
- };
214
- type ColumnLayoutOptions = Pick<columnOptions, "defaultMinWidth" | "defaultMaxWidth" | "defaultWidth">;
215
- interface StaticColumnLayoutOptions extends ColumnLayoutOptions {
216
- columnLayout: "manual" | "static";
217
- }
218
- interface FitColumnLayoutOptions extends ColumnLayoutOptions {
219
- availableWidth?: number;
220
- columnLayout: "fit";
221
- }
222
- export declare function applyWidthToColumns(columns: RuntimeColumnDescriptor[], options: StaticColumnLayoutOptions | FitColumnLayoutOptions): RuntimeColumnDescriptor[];
223
- /**
224
- * A memo compare function for cell renderers. Can be used to suppress
225
- * render where column and data are both unchanged. Avoids render
226
- * when row changes, where changes in row are unrelated to this cell.
227
- * Suitabnle only for readonly cell renderers. See below for editable
228
- * cell renderers.
229
- */
230
- export declare const dataAndColumnUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
231
- /**
232
- * A memo compare function for cell renderers. Can be used to suppress
233
- * render where column, row key and data are all unchanged. Avoids render
234
- * when row changes, where changes in row are unrelated to this cell.
235
- * Suitable for editable cells. Including key in compare is not strictly
236
- * necessary for rendering, but it is important in the event that user
237
- * edits data - ensures we never have a stale key.
238
- */
239
- export declare const dataColumnAndKeyUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
240
- export declare const toColumnName: (column: ColumnDescriptor) => string;
241
- export declare const isStringColumn: (column: ColumnDescriptor) => boolean;
242
- export declare const columnByAriaIndex: (columns: RuntimeColumnDescriptor[], ariaColIndex: number) => RuntimeColumnDescriptor;
243
- export {};
@@ -1,6 +0,0 @@
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 {};
@@ -1,65 +0,0 @@
1
- import { EditRuleValidator } from "@vuu-ui/vuu-data-types";
2
- import { VuuColumnDataType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnDescriptor, ColumnDescriptorCustomRenderer, ColumnTypeRendering, DataRow, HeaderCellProps, TableCellRendererProps } from "@vuu-ui/vuu-table-types";
4
- import { FunctionComponent as FC, HTMLAttributes } from "react";
5
- export interface CellConfigPanelProps extends HTMLAttributes<HTMLDivElement> {
6
- onConfigChange: () => void;
7
- }
8
- export type PropertyChangeHandler = (propertyName: string, propertyValue: string | number | boolean) => void;
9
- export type ColumnRenderPropsChangeHandler = (renderProps: ColumnTypeRendering) => void;
10
- export interface ConfigurationEditorProps {
11
- column: ColumnDescriptorCustomRenderer;
12
- onChangeRendering: ColumnRenderPropsChangeHandler;
13
- }
14
- export type RowClassNameGenerator = (dataRow: DataRow) => string | undefined;
15
- export type RowClassGenerator = {
16
- id: string;
17
- fn: RowClassNameGenerator;
18
- };
19
- export type ConfigEditorComponent = FC<CellConfigPanelProps>;
20
- export type layoutComponentType = "container" | "view";
21
- export type ComponentType = layoutComponentType | "cell-renderer" | "cell-config-panel" | "column-header-content-renderer" | "column-header-label-renderer" | "component" | "data-edit-validator" | "row-class-generator";
22
- /**
23
- * The CellRenderer Options provide configuration for the Column Settings panel
24
- */
25
- type CellRendererOptions = {
26
- configEditor?: string;
27
- description?: string;
28
- label?: string;
29
- serverDataType?: VuuColumnDataType | VuuColumnDataType[] | "json" | "private";
30
- userCanAssign?: boolean;
31
- };
32
- export interface CellRendererDescriptor extends CellRendererOptions {
33
- name: string;
34
- }
35
- /**
36
- * This check is performed during construction of UI from JSON. If component
37
- * is not registered, it will log a warning.
38
- */
39
- export declare const isContainer: (componentType: string) => boolean;
40
- /**
41
- * This check is performed during construction of UI from JSON. If component
42
- * is not registered, it will log a warning.
43
- */
44
- export declare const isView: (componentType: string) => boolean;
45
- /**
46
- * This check is performed during construction of UI from JSON. If component
47
- * is not registered, it will log a warning.
48
- */
49
- export declare const isLayoutComponent: (componentType: string) => componentType is layoutComponentType;
50
- export declare function registerComponent(componentName: string, component: RowClassGenerator, componentType: "row-class-generator", options?: CellRendererOptions): void;
51
- export declare function registerComponent(componentName: string, component: EditRuleValidator, componentType: "data-edit-validator", options?: CellRendererOptions): void;
52
- export declare function registerComponent(componentName: string, component: FC<any>, componentType: Omit<ComponentType, "data-edit-validator" | "row-class-generator">, options?: CellRendererOptions): void;
53
- export declare const registerConfigurationEditor: (componentName: string, configurationEditor: FC<ConfigurationEditorProps>) => void;
54
- type CellRendererDataType = VuuColumnDataType | "json";
55
- export declare const getRegisteredCellRenderers: (cellRendererDataType?: CellRendererDataType) => CellRendererDescriptor[];
56
- export declare const getLayoutComponent: (componentName: string) => FC<any>;
57
- export declare const getCellRendererOptions: (renderName: string) => CellRendererOptions | undefined;
58
- export declare function getCellRenderer(column: ColumnDescriptor): FC<TableCellRendererProps> | undefined;
59
- export declare function getColumnHeaderContentRenderer(column: ColumnDescriptor): FC<Omit<HeaderCellProps, "id" | "index">> | undefined;
60
- export declare function getColumnHeaderLabelRenderer(column: ColumnDescriptor): FC<Omit<HeaderCellProps, "id" | "index">> | undefined;
61
- export declare const getRowClassNameGenerator: (generatorId: string) => RowClassGenerator | undefined;
62
- export declare function getConfigurationEditor(configEditor?: string): FC<ConfigurationEditorProps> | undefined;
63
- export declare function getCellConfigPanelRenderer(name: string): ConfigEditorComponent | undefined;
64
- export declare function getEditRuleValidator(name: string): EditRuleValidator | undefined;
65
- export {};