@vuu-ui/vuu-utils 0.8.79 → 0.8.80

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.
@@ -2,8 +2,22 @@
2
2
 
3
3
  var arrayUtils = require('./array-utils.js');
4
4
  var textUtils = require('./text-utils.js');
5
+ var React = require('react');
6
+ var componentRegistry = require('./component-registry.js');
5
7
 
6
8
  const env = process.env.NODE_ENV;
9
+ function featureFromJson({
10
+ type,
11
+ label
12
+ }) {
13
+ const componentType = type.match(/^[a-z]/) ? type : componentRegistry.getLayoutComponent(type);
14
+ if (componentType === void 0) {
15
+ throw Error(
16
+ `layoutUtils unable to create component from JSON, unknown type ${type}`
17
+ );
18
+ }
19
+ return React.createElement(componentType, { id: label, key: label });
20
+ }
7
21
  const isCustomFeature = (feature) => feature.leftNavLocation === "vuu-features";
8
22
  const isWildcardSchema = (schema) => schema === "*";
9
23
  const isTableSchema = (schema) => typeof schema === "object" && typeof schema.module === "string" && typeof schema.table === "string";
@@ -120,13 +134,14 @@ const getCustomAndTableFeatures = (features, vuuTables) => {
120
134
  customFeatures.push(feature);
121
135
  }
122
136
  }
123
- return [customFeatures, tableFeatures];
137
+ return { dynamicFeatures: customFeatures, tableFeatures };
124
138
  };
125
139
 
126
140
  exports.assertComponentRegistered = assertComponentRegistered;
127
141
  exports.assertComponentsRegistered = assertComponentsRegistered;
128
142
  exports.byModule = byModule;
129
143
  exports.env = env;
144
+ exports.featureFromJson = featureFromJson;
130
145
  exports.getCustomAndTableFeatures = getCustomAndTableFeatures;
131
146
  exports.getFilterTableFeatures = getFilterTableFeatures;
132
147
  exports.hasFilterTableFeatureProps = hasFilterTableFeatureProps;
@@ -1 +1 @@
1
- {"version":3,"file":"feature-utils.js","sources":["../src/feature-utils.ts"],"sourcesContent":["import type { TableSchema } from \"@vuu-ui/vuu-data-types\";\nimport type { VuuTable } from \"@vuu-ui/vuu-protocol-types\";\nimport { ListOption } from \"@vuu-ui/vuu-table-types\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\n\nexport type PathMap = { [key: string]: Pick<FeatureConfig, \"css\" | \"url\"> };\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport type LookupTableProvider = (table: VuuTable) => ListOption[];\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\nexport interface FeatureProps<P extends object | undefined = object> {\n /**\n props that will be passed to the lazily loaded component.\n */\n ComponentProps?: P;\n ViewProps?: ViewConfig;\n css?: string;\n height?: number;\n title?: string;\n /** \n The url of javascript bundle to lazily load. Bundle must provide a default export\n and that export must be a React component.\n */\n url: string;\n width?: number;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface FeatureConfig {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n schema?: \"*\" | VuuTable;\n schemas?: VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type Features = {\n [key: string]: FeatureConfig;\n};\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: FeatureConfig) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (schema?: \"*\" | VuuTable): schema is \"*\" =>\n schema === \"*\";\nexport const isTableSchema = (schema?: \"*\" | VuuTable): schema is VuuTable =>\n typeof schema === \"object\" &&\n typeof schema.module === \"string\" &&\n typeof schema.table === \"string\";\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<FeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: FeatureProps\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\n// Sort TableScheas by module\nexport const byModule = (schema1: TableSchema, schema2: TableSchema) => {\n const m1 = schema1.table.module.toLowerCase();\n const m2 = schema2.table.module.toLowerCase();\n if (m1 < m2) {\n return -1;\n } else if (m1 > m2) {\n return 1;\n } else if (schema1.table.table < schema2.table.table) {\n return -1;\n } else if (schema1.table.table > schema2.table.table) {\n return 1;\n } else {\n return 0;\n }\n};\n\nexport type GetFeaturePaths = (params: {\n env: Environment;\n fileName: string;\n withCss?: boolean;\n}) => FeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths\n) =>\n schemas\n .sort(byModule)\n .map<FeatureProps<FilterTableFeatureProps>>((schema) => ({\n ...getFeaturePath({ env, fileName: \"FilterTable\" }),\n ComponentProps: {\n tableSchema: schema,\n },\n ViewProps: {\n allowRename: true,\n },\n title: `${schema.table.module} ${schema.table.table}`,\n }));\n\nexport type Component = {\n componentName: string;\n component: unknown;\n};\n\nexport const assertComponentRegistered = (\n componentName: string,\n component: unknown\n) => {\n if (typeof component !== \"function\") {\n console.warn(\n `${componentName} module not loaded, will be unabale to deserialize from layout JSON`\n );\n }\n};\n\nexport const assertComponentsRegistered = (componentList: Component[]) => {\n for (const { componentName, component } of componentList) {\n assertComponentRegistered(componentName, component);\n }\n};\n\nexport const getCustomAndTableFeatures = (\n features: Features,\n vuuTables: Map<string, TableSchema>\n): [FeatureProps[], FeatureProps<FilterTableFeatureProps>[]] => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n Object.values(features),\n isCustomFeature\n );\n\n const customFeatures: FeatureProps[] = [];\n const tableFeatures: FeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { schema } = featureProps;\n if (isWildcardSchema(schema) && vuuTables) {\n for (const tableSchema of vuuTables.values()) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n title: `${tableSchema.table.module} ${wordify(\n tableSchema.table.table\n )}`,\n ViewProps: {\n ...viewProps,\n allowRename: true,\n },\n });\n }\n } else if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n if (tableSchema) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { schema, schemas } = featureProps;\n if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n customFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n } else if (Array.isArray(schemas) && vuuTables) {\n customFeatures.push({\n ...feature,\n ComponentProps: schemas.reduce<Record<string, TableSchema>>(\n (map, schema) => {\n map[`${schema.table}Schema`] = vuuTables.get(\n schema.table\n ) as TableSchema;\n return map;\n },\n {}\n ),\n ViewProps: viewProps,\n });\n } else {\n customFeatures.push(feature);\n }\n }\n return [customFeatures, tableFeatures];\n};\n"],"names":["partition","wordify","schema"],"mappings":";;;;;AAQa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA,SAAA;AAiExB,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA,eAAA;AAEjB,MAAA,gBAAA,GAAmB,CAAC,MAAA,KAC/B,MAAW,KAAA,IAAA;AACN,MAAM,aAAgB,GAAA,CAAC,MAC5B,KAAA,OAAO,MAAW,KAAA,QAAA,IAClB,OAAO,MAAA,CAAO,MAAW,KAAA,QAAA,IACzB,OAAO,MAAA,CAAO,KAAU,KAAA,SAAA;AAOb,MAAA,0BAAA,GAA6B,CACxC,KAAA,KAEA,OAAO,KAAA,CAAM,cAAmB,KAAA,QAAA,IAChC,KAAM,CAAA,cAAA,KAAmB,IACzB,IAAA,a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,cACvCA,OAAO,CAAA,KAAA;AAAA,aACT,CAAA;AACA,YAAO,OAAA,GAAA,CAAA;AAAA,WACT;AAAA,UACA,EAAC;AAAA,SACH;AAAA,QACA,SAAW,EAAA,SAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACI,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA,CAAA;AAAA,KAC7B;AAAA,GACF;AACA,EAAO,OAAA,CAAC,gBAAgB,aAAa,CAAA,CAAA;AACvC;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"feature-utils.js","sources":["../src/feature-utils.ts"],"sourcesContent":["import type { TableSchema } from \"@vuu-ui/vuu-data-types\";\nimport type { VuuTable } from \"@vuu-ui/vuu-protocol-types\";\nimport { ListOption } from \"@vuu-ui/vuu-table-types\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\nimport React, { ReactElement } from \"react\";\nimport { getLayoutComponent } from \"./component-registry\";\n\nexport type PathMap = {\n [key: string]: Pick<DynamicFeatureDescriptor, \"css\" | \"url\">;\n};\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport type LookupTableProvider = (table: VuuTable) => ListOption[];\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\nexport interface FeatureProps<P extends object | undefined = object> {\n /**\n props that will be passed to the lazily loaded component.\n */\n ComponentProps?: P;\n ViewProps?: ViewConfig;\n css?: string;\n height?: number;\n title?: string;\n /** \n The url of javascript bundle to lazily load. Bundle must provide a default export\n and that export must be a React component.\n */\n url: string;\n width?: number;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface DynamicFeatureDescriptor {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n schema?: \"*\" | VuuTable;\n schemas?: VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface StaticFeatureDescriptor {\n group?: string;\n label: string;\n type: string;\n}\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type DynamicFeatures = {\n [key: string]: DynamicFeatureDescriptor;\n};\n\nexport type StaticFeatures = {\n [key: string]: StaticFeatureDescriptor;\n};\n\nexport function featureFromJson({\n type,\n label,\n}: StaticFeatureDescriptor): ReactElement {\n const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);\n if (componentType === undefined) {\n throw Error(\n `layoutUtils unable to create component from JSON, unknown type ${type}`\n );\n }\n return React.createElement(componentType, { id: label, key: label });\n}\n\nexport interface VuuConfig {\n features: DynamicFeatures;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: DynamicFeatureDescriptor) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (schema?: \"*\" | VuuTable): schema is \"*\" =>\n schema === \"*\";\nexport const isTableSchema = (schema?: \"*\" | VuuTable): schema is VuuTable =>\n typeof schema === \"object\" &&\n typeof schema.module === \"string\" &&\n typeof schema.table === \"string\";\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<FeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: FeatureProps\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\n// Sort TableScheas by module\nexport const byModule = (schema1: TableSchema, schema2: TableSchema) => {\n const m1 = schema1.table.module.toLowerCase();\n const m2 = schema2.table.module.toLowerCase();\n if (m1 < m2) {\n return -1;\n } else if (m1 > m2) {\n return 1;\n } else if (schema1.table.table < schema2.table.table) {\n return -1;\n } else if (schema1.table.table > schema2.table.table) {\n return 1;\n } else {\n return 0;\n }\n};\n\nexport type GetFeaturePaths = (params: {\n env: Environment;\n fileName: string;\n withCss?: boolean;\n}) => FeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths\n) =>\n schemas\n .sort(byModule)\n .map<FeatureProps<FilterTableFeatureProps>>((schema) => ({\n ...getFeaturePath({ env, fileName: \"FilterTable\" }),\n ComponentProps: {\n tableSchema: schema,\n },\n ViewProps: {\n allowRename: true,\n },\n title: `${schema.table.module} ${schema.table.table}`,\n }));\n\nexport type Component = {\n componentName: string;\n component: unknown;\n};\n\nexport const assertComponentRegistered = (\n componentName: string,\n component: unknown\n) => {\n if (typeof component !== \"function\") {\n console.warn(\n `${componentName} module not loaded, will be unabale to deserialize from layout JSON`\n );\n }\n};\n\nexport const assertComponentsRegistered = (componentList: Component[]) => {\n for (const { componentName, component } of componentList) {\n assertComponentRegistered(componentName, component);\n }\n};\n\nexport const getCustomAndTableFeatures = (\n features: DynamicFeatures,\n vuuTables: Map<string, TableSchema>\n): {\n dynamicFeatures: FeatureProps[];\n tableFeatures: FeatureProps<FilterTableFeatureProps>[];\n} => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n Object.values(features),\n isCustomFeature\n );\n\n const customFeatures: FeatureProps[] = [];\n const tableFeatures: FeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { schema } = featureProps;\n if (isWildcardSchema(schema) && vuuTables) {\n for (const tableSchema of vuuTables.values()) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n title: `${tableSchema.table.module} ${wordify(\n tableSchema.table.table\n )}`,\n ViewProps: {\n ...viewProps,\n allowRename: true,\n },\n });\n }\n } else if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n if (tableSchema) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { schema, schemas } = featureProps;\n if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n customFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n } else if (Array.isArray(schemas) && vuuTables) {\n customFeatures.push({\n ...feature,\n ComponentProps: schemas.reduce<Record<string, TableSchema>>(\n (map, schema) => {\n map[`${schema.table}Schema`] = vuuTables.get(\n schema.table\n ) as TableSchema;\n return map;\n },\n {}\n ),\n ViewProps: viewProps,\n });\n } else {\n customFeatures.push(feature);\n }\n }\n return { dynamicFeatures: customFeatures, tableFeatures: tableFeatures };\n};\n"],"names":["getLayoutComponent","partition","wordify","schema"],"mappings":";;;;;;;AAYa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA,SAAA;AA8DxB,SAAS,eAAgB,CAAA;AAAA,EAC9B,IAAA;AAAA,EACA,KAAA;AACF,CAA0C,EAAA;AACxC,EAAA,MAAM,gBAAgB,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,IAAA,GAAOA,qCAAmB,IAAI,CAAA,CAAA;AAC3E,EAAA,IAAI,kBAAkB,KAAW,CAAA,EAAA;AAC/B,IAAM,MAAA,KAAA;AAAA,MACJ,kEAAkE,IAAI,CAAA,CAAA;AAAA,KACxE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,KAAA,CAAM,cAAc,aAAe,EAAA,EAAE,IAAI,KAAO,EAAA,GAAA,EAAK,OAAO,CAAA,CAAA;AACrE,CAAA;AASO,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA,eAAA;AAEjB,MAAA,gBAAA,GAAmB,CAAC,MAAA,KAC/B,MAAW,KAAA,IAAA;AACN,MAAM,aAAgB,GAAA,CAAC,MAC5B,KAAA,OAAO,MAAW,KAAA,QAAA,IAClB,OAAO,MAAA,CAAO,MAAW,KAAA,QAAA,IACzB,OAAO,MAAA,CAAO,KAAU,KAAA,SAAA;AAOb,MAAA,0BAAA,GAA6B,CACxC,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A,CAAI,CAAGA,EAAAA,OAAAA,CAAO,KAAK,CAAA,MAAA,CAAQ,IAAI,SAAU,CAAA,GAAA;AAAA,cACvCA,OAAO,CAAA,KAAA;AAAA,aACT,CAAA;AACA,YAAO,OAAA,GAAA,CAAA;AAAA,WACT;AAAA,UACA,EAAC;AAAA,SACH;AAAA,QACA,SAAW,EAAA,SAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACI,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA,CAAA;AAAA,KAC7B;AAAA,GACF;AACA,EAAO,OAAA,EAAE,eAAiB,EAAA,cAAA,EAAgB,aAA6B,EAAA,CAAA;AACzE;;;;;;;;;;;;;;"}
package/cjs/index.js CHANGED
@@ -234,6 +234,7 @@ exports.assertComponentRegistered = featureUtils.assertComponentRegistered;
234
234
  exports.assertComponentsRegistered = featureUtils.assertComponentsRegistered;
235
235
  exports.byModule = featureUtils.byModule;
236
236
  exports.env = featureUtils.env;
237
+ exports.featureFromJson = featureUtils.featureFromJson;
237
238
  exports.getCustomAndTableFeatures = featureUtils.getCustomAndTableFeatures;
238
239
  exports.getFilterTableFeatures = featureUtils.getFilterTableFeatures;
239
240
  exports.hasFilterTableFeatureProps = featureUtils.hasFilterTableFeatureProps;
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,21 @@
1
1
  import { partition } from './array-utils.js';
2
2
  import { wordify } from './text-utils.js';
3
+ import React from 'react';
4
+ import { getLayoutComponent } from './component-registry.js';
3
5
 
4
6
  const env = process.env.NODE_ENV;
7
+ function featureFromJson({
8
+ type,
9
+ label
10
+ }) {
11
+ const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);
12
+ if (componentType === void 0) {
13
+ throw Error(
14
+ `layoutUtils unable to create component from JSON, unknown type ${type}`
15
+ );
16
+ }
17
+ return React.createElement(componentType, { id: label, key: label });
18
+ }
5
19
  const isCustomFeature = (feature) => feature.leftNavLocation === "vuu-features";
6
20
  const isWildcardSchema = (schema) => schema === "*";
7
21
  const isTableSchema = (schema) => typeof schema === "object" && typeof schema.module === "string" && typeof schema.table === "string";
@@ -118,8 +132,8 @@ const getCustomAndTableFeatures = (features, vuuTables) => {
118
132
  customFeatures.push(feature);
119
133
  }
120
134
  }
121
- return [customFeatures, tableFeatures];
135
+ return { dynamicFeatures: customFeatures, tableFeatures };
122
136
  };
123
137
 
124
- export { assertComponentRegistered, assertComponentsRegistered, byModule, env, getCustomAndTableFeatures, getFilterTableFeatures, hasFilterTableFeatureProps, isCustomFeature, isTableSchema, isWildcardSchema };
138
+ export { assertComponentRegistered, assertComponentsRegistered, byModule, env, featureFromJson, getCustomAndTableFeatures, getFilterTableFeatures, hasFilterTableFeatureProps, isCustomFeature, isTableSchema, isWildcardSchema };
125
139
  //# sourceMappingURL=feature-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature-utils.js","sources":["../src/feature-utils.ts"],"sourcesContent":["import type { TableSchema } from \"@vuu-ui/vuu-data-types\";\nimport type { VuuTable } from \"@vuu-ui/vuu-protocol-types\";\nimport { ListOption } from \"@vuu-ui/vuu-table-types\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\n\nexport type PathMap = { [key: string]: Pick<FeatureConfig, \"css\" | \"url\"> };\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport type LookupTableProvider = (table: VuuTable) => ListOption[];\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\nexport interface FeatureProps<P extends object | undefined = object> {\n /**\n props that will be passed to the lazily loaded component.\n */\n ComponentProps?: P;\n ViewProps?: ViewConfig;\n css?: string;\n height?: number;\n title?: string;\n /** \n The url of javascript bundle to lazily load. Bundle must provide a default export\n and that export must be a React component.\n */\n url: string;\n width?: number;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface FeatureConfig {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n schema?: \"*\" | VuuTable;\n schemas?: VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type Features = {\n [key: string]: FeatureConfig;\n};\nexport interface VuuConfig {\n features: Features;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: FeatureConfig) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (schema?: \"*\" | VuuTable): schema is \"*\" =>\n schema === \"*\";\nexport const isTableSchema = (schema?: \"*\" | VuuTable): schema is VuuTable =>\n typeof schema === \"object\" &&\n typeof schema.module === \"string\" &&\n typeof schema.table === \"string\";\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<FeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: FeatureProps\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\n// Sort TableScheas by module\nexport const byModule = (schema1: TableSchema, schema2: TableSchema) => {\n const m1 = schema1.table.module.toLowerCase();\n const m2 = schema2.table.module.toLowerCase();\n if (m1 < m2) {\n return -1;\n } else if (m1 > m2) {\n return 1;\n } else if (schema1.table.table < schema2.table.table) {\n return -1;\n } else if (schema1.table.table > schema2.table.table) {\n return 1;\n } else {\n return 0;\n }\n};\n\nexport type GetFeaturePaths = (params: {\n env: Environment;\n fileName: string;\n withCss?: boolean;\n}) => FeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths\n) =>\n schemas\n .sort(byModule)\n .map<FeatureProps<FilterTableFeatureProps>>((schema) => ({\n ...getFeaturePath({ env, fileName: \"FilterTable\" }),\n ComponentProps: {\n tableSchema: schema,\n },\n ViewProps: {\n allowRename: true,\n },\n title: `${schema.table.module} ${schema.table.table}`,\n }));\n\nexport type Component = {\n componentName: string;\n component: unknown;\n};\n\nexport const assertComponentRegistered = (\n componentName: string,\n component: unknown\n) => {\n if (typeof component !== \"function\") {\n console.warn(\n `${componentName} module not loaded, will be unabale to deserialize from layout JSON`\n );\n }\n};\n\nexport const assertComponentsRegistered = (componentList: Component[]) => {\n for (const { componentName, component } of componentList) {\n assertComponentRegistered(componentName, component);\n }\n};\n\nexport const getCustomAndTableFeatures = (\n features: Features,\n vuuTables: Map<string, TableSchema>\n): [FeatureProps[], FeatureProps<FilterTableFeatureProps>[]] => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n Object.values(features),\n isCustomFeature\n );\n\n const customFeatures: FeatureProps[] = [];\n const tableFeatures: FeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { schema } = featureProps;\n if (isWildcardSchema(schema) && vuuTables) {\n for (const tableSchema of vuuTables.values()) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n title: `${tableSchema.table.module} ${wordify(\n tableSchema.table.table\n )}`,\n ViewProps: {\n ...viewProps,\n allowRename: true,\n },\n });\n }\n } else if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n if (tableSchema) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { schema, schemas } = featureProps;\n if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n customFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n } else if (Array.isArray(schemas) && vuuTables) {\n customFeatures.push({\n ...feature,\n ComponentProps: schemas.reduce<Record<string, TableSchema>>(\n (map, schema) => {\n map[`${schema.table}Schema`] = vuuTables.get(\n schema.table\n ) as TableSchema;\n return map;\n },\n {}\n ),\n ViewProps: viewProps,\n });\n } else {\n customFeatures.push(feature);\n }\n }\n return [customFeatures, tableFeatures];\n};\n"],"names":["schema"],"mappings":";;;AAQa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA,SAAA;AAiExB,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ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,SAAW,EAAA,SAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACQ,MAAA,IAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,KAAK,SAAW,EAAA;AAC9C,MAAA,cAAA,CAAe,IAAK,CAAA;AAAA,QAClB,GAAG,OAAA;AAAA,QACH,gBAAgB,OAAQ,CAAA,MAAA;AAAA,UACtB,CAAC,KAAKA,OAAW,KAAA;AACf,YAAA,GAAA,CAAI,CAAGA,EAAAA,OAAAA,CAAO,KAAK,CAAA,MAAA,CAAQ,IAAI,SAAU,CAAA,GAAA;AAAA,cACvCA,OAAO,CAAA,KAAA;AAAA,aACT,CAAA;AACA,YAAO,OAAA,GAAA,CAAA;AAAA,WACT;AAAA,UACA,EAAC;AAAA,SACH;AAAA,QACA,SAAW,EAAA,SAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACI,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA,CAAA;AAAA,KAC7B;AAAA,GACF;AACA,EAAO,OAAA,CAAC,gBAAgB,aAAa,CAAA,CAAA;AACvC;;;;"}
1
+ {"version":3,"file":"feature-utils.js","sources":["../src/feature-utils.ts"],"sourcesContent":["import type { TableSchema } from \"@vuu-ui/vuu-data-types\";\nimport type { VuuTable } from \"@vuu-ui/vuu-protocol-types\";\nimport { ListOption } from \"@vuu-ui/vuu-table-types\";\nimport { partition } from \"./array-utils\";\nimport { wordify } from \"./text-utils\";\nimport React, { ReactElement } from \"react\";\nimport { getLayoutComponent } from \"./component-registry\";\n\nexport type PathMap = {\n [key: string]: Pick<DynamicFeatureDescriptor, \"css\" | \"url\">;\n};\nexport type Environment = \"development\" | \"production\";\nexport const env = process.env.NODE_ENV as Environment;\n\nexport type LookupTableProvider = (table: VuuTable) => ListOption[];\n\nexport interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\n}\n\nexport interface FeatureProps<P extends object | undefined = object> {\n /**\n props that will be passed to the lazily loaded component.\n */\n ComponentProps?: P;\n ViewProps?: ViewConfig;\n css?: string;\n height?: number;\n title?: string;\n /** \n The url of javascript bundle to lazily load. Bundle must provide a default export\n and that export must be a React component.\n */\n url: string;\n width?: number;\n}\n\ndeclare global {\n const vuuConfig: Promise<VuuConfig>;\n}\n\nexport interface DynamicFeatureDescriptor {\n name: string;\n title: string;\n url: string;\n css?: string;\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n featureProps?: {\n schema?: \"*\" | VuuTable;\n schemas?: VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface StaticFeatureDescriptor {\n group?: string;\n label: string;\n type: string;\n}\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type DynamicFeatures = {\n [key: string]: DynamicFeatureDescriptor;\n};\n\nexport type StaticFeatures = {\n [key: string]: StaticFeatureDescriptor;\n};\n\nexport function featureFromJson({\n type,\n label,\n}: StaticFeatureDescriptor): ReactElement {\n const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);\n if (componentType === undefined) {\n throw Error(\n `layoutUtils unable to create component from JSON, unknown type ${type}`\n );\n }\n return React.createElement(componentType, { id: label, key: label });\n}\n\nexport interface VuuConfig {\n features: DynamicFeatures;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\nexport const isCustomFeature = (feature: DynamicFeatureDescriptor) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (schema?: \"*\" | VuuTable): schema is \"*\" =>\n schema === \"*\";\nexport const isTableSchema = (schema?: \"*\" | VuuTable): schema is VuuTable =>\n typeof schema === \"object\" &&\n typeof schema.module === \"string\" &&\n typeof schema.table === \"string\";\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<FeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: FeatureProps\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\n// Sort TableScheas by module\nexport const byModule = (schema1: TableSchema, schema2: TableSchema) => {\n const m1 = schema1.table.module.toLowerCase();\n const m2 = schema2.table.module.toLowerCase();\n if (m1 < m2) {\n return -1;\n } else if (m1 > m2) {\n return 1;\n } else if (schema1.table.table < schema2.table.table) {\n return -1;\n } else if (schema1.table.table > schema2.table.table) {\n return 1;\n } else {\n return 0;\n }\n};\n\nexport type GetFeaturePaths = (params: {\n env: Environment;\n fileName: string;\n withCss?: boolean;\n}) => FeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths\n) =>\n schemas\n .sort(byModule)\n .map<FeatureProps<FilterTableFeatureProps>>((schema) => ({\n ...getFeaturePath({ env, fileName: \"FilterTable\" }),\n ComponentProps: {\n tableSchema: schema,\n },\n ViewProps: {\n allowRename: true,\n },\n title: `${schema.table.module} ${schema.table.table}`,\n }));\n\nexport type Component = {\n componentName: string;\n component: unknown;\n};\n\nexport const assertComponentRegistered = (\n componentName: string,\n component: unknown\n) => {\n if (typeof component !== \"function\") {\n console.warn(\n `${componentName} module not loaded, will be unabale to deserialize from layout JSON`\n );\n }\n};\n\nexport const assertComponentsRegistered = (componentList: Component[]) => {\n for (const { componentName, component } of componentList) {\n assertComponentRegistered(componentName, component);\n }\n};\n\nexport const getCustomAndTableFeatures = (\n features: DynamicFeatures,\n vuuTables: Map<string, TableSchema>\n): {\n dynamicFeatures: FeatureProps[];\n tableFeatures: FeatureProps<FilterTableFeatureProps>[];\n} => {\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n Object.values(features),\n isCustomFeature\n );\n\n const customFeatures: FeatureProps[] = [];\n const tableFeatures: FeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { schema } = featureProps;\n if (isWildcardSchema(schema) && vuuTables) {\n for (const tableSchema of vuuTables.values()) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n title: `${tableSchema.table.module} ${wordify(\n tableSchema.table.table\n )}`,\n ViewProps: {\n ...viewProps,\n allowRename: true,\n },\n });\n }\n } else if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n if (tableSchema) {\n tableFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { schema, schemas } = featureProps;\n if (isTableSchema(schema) && vuuTables) {\n const tableSchema = vuuTables.get(schema.table);\n customFeatures.push({\n ...feature,\n ComponentProps: {\n tableSchema,\n },\n ViewProps: viewProps,\n });\n } else if (Array.isArray(schemas) && vuuTables) {\n customFeatures.push({\n ...feature,\n ComponentProps: schemas.reduce<Record<string, TableSchema>>(\n (map, schema) => {\n map[`${schema.table}Schema`] = vuuTables.get(\n schema.table\n ) as TableSchema;\n return map;\n },\n {}\n ),\n ViewProps: viewProps,\n });\n } else {\n customFeatures.push(feature);\n }\n }\n return { dynamicFeatures: customFeatures, tableFeatures: tableFeatures };\n};\n"],"names":["schema"],"mappings":";;;;;AAYa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA,SAAA;AA8DxB,SAAS,eAAgB,CAAA;AAAA,EAC9B,IAAA;AAAA,EACA,KAAA;AACF,CAA0C,EAAA;AACxC,EAAA,MAAM,gBAAgB,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,IAAA,GAAO,mBAAmB,IAAI,CAAA,CAAA;AAC3E,EAAA,IAAI,kBAAkB,KAAW,CAAA,EAAA;AAC/B,IAAM,MAAA,KAAA;AAAA,MACJ,kEAAkE,IAAI,CAAA,CAAA;AAAA,KACxE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,KAAA,CAAM,cAAc,aAAe,EAAA,EAAE,IAAI,KAAO,EAAA,GAAA,EAAK,OAAO,CAAA,CAAA;AACrE,CAAA;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,cAAgB,EAAA;AAAA,UACd,WAAA;AAAA,SACF;AAAA,QACA,SAAW,EAAA,SAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACQ,MAAA,IAAA,KAAA,CAAM,OAAQ,CAAA,OAAO,KAAK,SAAW,EAAA;AAC9C,MAAA,cAAA,CAAe,IAAK,CAAA;AAAA,QAClB,GAAG,OAAA;AAAA,QACH,gBAAgB,OAAQ,CAAA,MAAA;AAAA,UACtB,CAAC,KAAKA,OAAW,KAAA;AACf,YAAA,GAAA,CAAI,CAAGA,EAAAA,OAAAA,CAAO,KAAK,CAAA,MAAA,CAAQ,IAAI,SAAU,CAAA,GAAA;AAAA,cACvCA,OAAO,CAAA,KAAA;AAAA,aACT,CAAA;AACA,YAAO,OAAA,GAAA,CAAA;AAAA,WACT;AAAA,UACA,EAAC;AAAA,SACH;AAAA,QACA,SAAW,EAAA,SAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACI,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA,CAAA;AAAA,KAC7B;AAAA,GACF;AACA,EAAO,OAAA,EAAE,eAAiB,EAAA,cAAA,EAAgB,aAA6B,EAAA,CAAA;AACzE;;;;"}
package/esm/index.js CHANGED
@@ -18,7 +18,7 @@ export { applyFilterToColumns, extractFilterForColumn, isAndFilter, isCompleteFi
18
18
  export { dateFilterAsQuery, filterAsQuery, removeColumnFromFilter } from './filters/filterAsQuery.js';
19
19
  export { createEl, dispatchCustomEvent, dispatchKeyboardEvent, dispatchMouseEvent, focusFirstFocusableElement, getClosest, getClosestIndexItem, getElementByDataIndex, getElementDataIndex, getFocusableElement, getScrollbarSize, hasOpenOptionList, isSelectableElement, queryClosest } from './html-utils.js';
20
20
  export { EventEmitter } from './event-emitter.js';
21
- export { assertComponentRegistered, assertComponentsRegistered, byModule, env, getCustomAndTableFeatures, getFilterTableFeatures, hasFilterTableFeatureProps, isCustomFeature, isTableSchema, isWildcardSchema } from './feature-utils.js';
21
+ export { assertComponentRegistered, assertComponentsRegistered, byModule, env, featureFromJson, getCustomAndTableFeatures, getFilterTableFeatures, hasFilterTableFeatureProps, isCustomFeature, isTableSchema, isWildcardSchema } from './feature-utils.js';
22
22
  export { getFieldName } from './form-utils.js';
23
23
  export { defaultValueFormatter, getValueFormatter, numericFormatter } from './formatting-utils.js';
24
24
  export { getUniqueId } from './getUniqueId.js';
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "version": "0.8.79",
2
+ "version": "0.8.80",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "types": "types/index.d.ts",
6
6
  "devDependencies": {
7
- "@vuu-ui/vuu-data-types": "0.8.79",
8
- "@vuu-ui/vuu-table-types": "0.8.79",
9
- "@vuu-ui/vuu-filter-types": "0.8.79",
10
- "@vuu-ui/vuu-protocol-types": "0.8.79"
7
+ "@vuu-ui/vuu-data-types": "0.8.80",
8
+ "@vuu-ui/vuu-table-types": "0.8.80",
9
+ "@vuu-ui/vuu-filter-types": "0.8.80",
10
+ "@vuu-ui/vuu-protocol-types": "0.8.80"
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@internationalized/date": "^3.0.0",
14
- "@vuu-ui/vuu-filter-parser": "0.8.79",
14
+ "@vuu-ui/vuu-filter-parser": "0.8.80",
15
15
  "clsx": "^2.0.0",
16
16
  "react": ">=17.0.2",
17
17
  "react-dom": ">=17.0.2"
@@ -1,8 +1,9 @@
1
1
  import type { TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
3
3
  import { ListOption } from "@vuu-ui/vuu-table-types";
4
+ import { ReactElement } from "react";
4
5
  export type PathMap = {
5
- [key: string]: Pick<FeatureConfig, "css" | "url">;
6
+ [key: string]: Pick<DynamicFeatureDescriptor, "css" | "url">;
6
7
  };
7
8
  export type Environment = "development" | "production";
8
9
  export declare const env: Environment;
@@ -31,7 +32,7 @@ export interface FeatureProps<P extends object | undefined = object> {
31
32
  declare global {
32
33
  const vuuConfig: Promise<VuuConfig>;
33
34
  }
34
- export interface FeatureConfig {
35
+ export interface DynamicFeatureDescriptor {
35
36
  name: string;
36
37
  title: string;
37
38
  url: string;
@@ -43,25 +44,28 @@ export interface FeatureConfig {
43
44
  };
44
45
  viewProps?: ViewConfig;
45
46
  }
46
- export interface VuuConfig {
47
- features: Features;
48
- authUrl?: string;
49
- websocketUrl: string;
50
- ssl: boolean;
47
+ export interface StaticFeatureDescriptor {
48
+ group?: string;
49
+ label: string;
50
+ type: string;
51
51
  }
52
52
  export interface FilterTableFeatureProps {
53
53
  tableSchema: TableSchema;
54
54
  }
55
- export type Features = {
56
- [key: string]: FeatureConfig;
55
+ export type DynamicFeatures = {
56
+ [key: string]: DynamicFeatureDescriptor;
57
+ };
58
+ export type StaticFeatures = {
59
+ [key: string]: StaticFeatureDescriptor;
57
60
  };
61
+ export declare function featureFromJson({ type, label, }: StaticFeatureDescriptor): ReactElement;
58
62
  export interface VuuConfig {
59
- features: Features;
63
+ features: DynamicFeatures;
60
64
  authUrl?: string;
61
65
  websocketUrl: string;
62
66
  ssl: boolean;
63
67
  }
64
- export declare const isCustomFeature: (feature: FeatureConfig) => boolean;
68
+ export declare const isCustomFeature: (feature: DynamicFeatureDescriptor) => boolean;
65
69
  export declare const isWildcardSchema: (schema?: "*" | VuuTable) => schema is "*";
66
70
  export declare const isTableSchema: (schema?: "*" | VuuTable) => schema is VuuTable;
67
71
  export interface FeaturePropsWithFilterTableFeature extends Omit<FeatureProps, "ComponentProps"> {
@@ -81,4 +85,7 @@ export type Component = {
81
85
  };
82
86
  export declare const assertComponentRegistered: (componentName: string, component: unknown) => void;
83
87
  export declare const assertComponentsRegistered: (componentList: Component[]) => void;
84
- export declare const getCustomAndTableFeatures: (features: Features, vuuTables: Map<string, TableSchema>) => [FeatureProps[], FeatureProps<FilterTableFeatureProps>[]];
88
+ export declare const getCustomAndTableFeatures: (features: DynamicFeatures, vuuTables: Map<string, TableSchema>) => {
89
+ dynamicFeatures: FeatureProps[];
90
+ tableFeatures: FeatureProps<FilterTableFeatureProps>[];
91
+ };