@vuu-ui/vuu-utils 0.13.25 → 0.13.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/node_modules/@dnd-kit/dom/index.js +18 -6
- package/cjs/node_modules/@dnd-kit/dom/index.js.map +1 -1
- package/cjs/packages/vuu-utils/src/context-definitions/DataContext.js +1 -1
- package/cjs/packages/vuu-utils/src/context-definitions/DataContext.js.map +1 -1
- package/cjs/packages/vuu-utils/src/feature-utils.js.map +1 -1
- package/esm/node_modules/@dnd-kit/dom/index.js +18 -6
- package/esm/node_modules/@dnd-kit/dom/index.js.map +1 -1
- package/esm/packages/vuu-utils/src/context-definitions/DataContext.js +1 -1
- package/esm/packages/vuu-utils/src/context-definitions/DataContext.js.map +1 -1
- package/esm/packages/vuu-utils/src/feature-utils.js.map +1 -1
- package/package.json +6 -6
- package/types/feature-utils.d.ts +10 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataContext.js","sources":["../../../../../../../packages/vuu-utils/src/context-definitions/DataContext.tsx"],"sourcesContent":["import type {\n DataSource,\n DataSourceConstructorProps,\n ServerAPI,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { createContext } from \"react\";\n\nexport type DataSourceConstructor = {\n new (props: DataSourceConstructorProps): DataSource;\n};\n\nexport interface DataContextProps {\n VuuDataSource: DataSourceConstructor;\n dataSourceExtensions?: unknown;\n isLocalData: boolean;\n getServerAPI: () => Promise<\n Pick<ServerAPI, \"getTableList\" | \"getTableSchema\" | \"rpcCall\">\n >;\n /**\n * A tableSchema would normally be requested via the serverAPI.\n * schemas can be injected, in which case these 'local' schemas\n * will be returned from the getTableSchema API call.\n * The key is formed from concatenation of module and tableName\n * from VuuTable e.g 'SIMUL:instruments'\n */\n tableSchemas?: Record<string, TableSchema>;\n}\n\nconst getServerAPI = () => {\n throw Error(\"no DataProvider has been installed\");\n};\n\nclass NullDataSourceConstructor {\n constructor(_: DataSourceConstructorProps) {\n throw Error(\"no
|
|
1
|
+
{"version":3,"file":"DataContext.js","sources":["../../../../../../../packages/vuu-utils/src/context-definitions/DataContext.tsx"],"sourcesContent":["import type {\n DataSource,\n DataSourceConstructorProps,\n ServerAPI,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { createContext } from \"react\";\n\nexport type DataSourceConstructor = {\n new (props: DataSourceConstructorProps): DataSource;\n};\n\nexport interface DataContextProps {\n VuuDataSource: DataSourceConstructor;\n dataSourceExtensions?: unknown;\n isLocalData: boolean;\n getServerAPI: () => Promise<\n Pick<ServerAPI, \"getTableList\" | \"getTableSchema\" | \"rpcCall\">\n >;\n /**\n * A tableSchema would normally be requested via the serverAPI.\n * schemas can be injected, in which case these 'local' schemas\n * will be returned from the getTableSchema API call.\n * The key is formed from concatenation of module and tableName\n * from VuuTable e.g 'SIMUL:instruments'\n */\n tableSchemas?: Record<string, TableSchema>;\n}\n\nconst getServerAPI = () => {\n throw Error(\"no DataProvider has been installed\");\n};\n\nclass NullDataSourceConstructor {\n constructor(_: DataSourceConstructorProps) {\n throw Error(\"no DataProvider has been installed\");\n }\n}\n\nexport const DataContext = createContext<DataContextProps>({\n isLocalData: false,\n getServerAPI,\n VuuDataSource: NullDataSourceConstructor as DataSourceConstructor,\n});\n"],"names":[],"mappings":";;AA6BA,MAAM,eAAe,MAAM;AACzB,EAAA,MAAM,MAAM,oCAAoC,CAAA;AAClD,CAAA;AAEA,MAAM,yBAA0B,CAAA;AAAA,EAC9B,YAAY,CAA+B,EAAA;AACzC,IAAA,MAAM,MAAM,oCAAoC,CAAA;AAAA;AAEpD;AAEO,MAAM,cAAc,aAAgC,CAAA;AAAA,EACzD,WAAa,EAAA,KAAA;AAAA,EACb,YAAA;AAAA,EACA,aAAe,EAAA;AACjB,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-utils.js","sources":["../../../../../../packages/vuu-utils/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 DynamicFeatureProps<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 vuuTables?: \"*\" | VuuTable[];\n };\n viewProps?: ViewConfig;\n}\n\nexport interface StaticFeatureDescriptor {\n group?: string;\n label: string;\n type: string;\n}\n\nconst isStaticFeature = (\n feature: unknown,\n): feature is StaticFeatureDescriptor =>\n feature !== null && typeof feature === \"object\" && \"type\" in feature;\n\nexport const isStaticFeatures = (\n features: unknown,\n): features is StaticFeatureDescriptor[] =>\n Array.isArray(features) && features.every(isStaticFeature);\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type DynamicFeatures = {\n [key: string]: DynamicFeatureDescriptor;\n};\n\nexport function featureFromJson({ type }: { type: string }): ReactElement {\n const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);\n if (componentType === undefined) {\n throw Error(\n `layoutUtils unable to create feature component from JSON, unknown type ${type}`,\n );\n }\n return React.createElement(componentType);\n}\n\nexport interface VuuConfig {\n features: DynamicFeatures;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\n/**\n * We currently categorize 'features' simply by the leftNavLocation\n * @param feature\n * @returns\n */\nexport const isCustomFeature = (feature: DynamicFeatureDescriptor) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (\n vuuTables?: \"*\" | VuuTable[],\n): vuuTables is \"*\" => vuuTables === \"*\";\nexport const isVuuTables = (\n vuuTables?: \"*\" | VuuTable[],\n): vuuTables is VuuTable[] => Array.isArray(vuuTables);\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<DynamicFeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: DynamicFeatureProps,\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\nexport const isSameTable = (t1: VuuTable, t2: VuuTable) => {\n t1.module === t2.module && t1.table == t2.table;\n};\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}) => DynamicFeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths,\n) =>\n schemas\n .sort(byModule)\n .map<DynamicFeatureProps<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/**\n * Process the DynamicFeature descriptors. Identify\n * the vuu tables required and inject the appropriate TableSchemas\n *\n * @param dynamicFeatures\n * @param tableSchemas\n * @returns\n */\nexport const getCustomAndTableFeatures = (\n dynamicFeatures: DynamicFeatureDescriptor[],\n tableSchemas: TableSchema[],\n): {\n dynamicFeatures: DynamicFeatureProps[];\n tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[];\n} => {\n // Split features into simple tables and 'custom' features\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n dynamicFeatures,\n isCustomFeature,\n );\n\n const customFeatures: DynamicFeatureProps[] = [];\n const tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { vuuTables } = featureProps;\n // Currently FilterTable is the only 'tableFeature' and it uses the wildcard\n if (isWildcardSchema(vuuTables)) {\n if (tableSchemas) {\n for (const tableSchema of tableSchemas) {\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 }\n } /*else if (isVuuTables(vuuTables) && tableSchemas) {\n const tableSchema = tableSchemas.find((tableSchema) =>\n isSameTable(vuuTable, tableSchema.table),\n );\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 { vuuTables } = featureProps;\n if (isVuuTables(vuuTables)) {\n if (tableSchemas) {\n customFeatures.push({\n ...feature,\n ComponentProps: vuuTables.reduce<Record<string, TableSchema>>(\n (map, vuuTable) => {\n map[`${vuuTable.table}Schema`] = tableSchemas.find(\n (tableSchema) => isSameTable(vuuTable, tableSchema.table),\n ) as TableSchema;\n return map;\n },\n {},\n ),\n ViewProps: viewProps,\n });\n }\n } else {\n customFeatures.push(feature);\n }\n }\n return { dynamicFeatures: customFeatures, tableFeatures: tableFeatures };\n};\n"],"names":[],"mappings":";;;;;AAYa,MAAA,GAAA,GAAM,QAAQ,GAAI,CAAA;AAiD/B,MAAM,eAAA,GAAkB,CACtB,OAEA,KAAA,OAAA,KAAY,QAAQ,OAAO,OAAA,KAAY,YAAY,MAAU,IAAA,OAAA;AAElD,MAAA,gBAAA,GAAmB,CAC9B,QAEA,KAAA,KAAA,CAAM,QAAQ,QAAQ,CAAA,IAAK,QAAS,CAAA,KAAA,CAAM,eAAe;AAU3C,SAAA,eAAA,CAAgB,EAAE,IAAA,EAAwC,EAAA;AACxE,EAAA,MAAM,gBAAgB,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,IAAA,GAAO,mBAAmB,IAAI,CAAA;AAC3E,EAAA,IAAI,kBAAkB,KAAW,CAAA,EAAA;AAC/B,IAAM,MAAA,KAAA;AAAA,MACJ,0EAA0E,IAAI,CAAA;AAAA,KAChF;AAAA;AAEF,EAAO,OAAA,KAAA,CAAM,cAAc,aAAa,CAAA;AAC1C;AAcO,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA;AAEjB,MAAA,gBAAA,GAAmB,CAC9B,SAAA,KACqB,SAAc,KAAA;AAC9B,MAAM,WAAc,GAAA,CACzB,SAC4B,KAAA,KAAA,CAAM,QAAQ,SAAS;AAOxC,MAAA,0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A,YACD,SAAW,EAAA;AAAA,cACT,GAAG,SAAA;AAAA,cACH,WAAa,EAAA;AAAA;AACf,WACD,CAAA;AAAA;AACH;AACF;AACF;AAgBF,EAAW,KAAA,MAAA;AAAA,IACT,eAAe,EAAC;AAAA,IAChB,SAAA;AAAA,IACA,GAAG;AAAA,OACA,mBAAqB,EAAA;AACxB,IAAM,MAAA,EAAE,WAAc,GAAA,YAAA;AACtB,IAAI,IAAA,WAAA,CAAY,SAAS,CAAG,EAAA;AAC1B,MAAA,IAAI,YAAc,EAAA;AAChB,QAAA,cAAA,CAAe,IAAK,CAAA;AAAA,UAClB,GAAG,OAAA;AAAA,UACH,gBAAgB,SAAU,CAAA,MAAA;AAAA,YACxB,CAAC,KAAK,QAAa,KAAA;AACjB,cAAA,GAAA,CAAI,CAAG,EAAA,QAAA,CAAS,KAAK,CAAA,MAAA,CAAQ,IAAI,YAAa,CAAA,IAAA;AAAA,gBAC5C,CAAC,WAAA,KAAgB,WAAY,CAAA,QAAA,EAAU,YAAY,KAAK;AAAA,eAC1D;AACA,cAAO,OAAA,GAAA;AAAA,aACT;AAAA,YACA;AAAC,WACH;AAAA,UACA,SAAW,EAAA;AAAA,SACZ,CAAA;AAAA;AACH,KACK,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA;AAAA;AAC7B;AAEF,EAAO,OAAA,EAAE,eAAiB,EAAA,cAAA,EAAgB,aAA6B,EAAA;AACzE;;;;"}
|
|
1
|
+
{"version":3,"file":"feature-utils.js","sources":["../../../../../../packages/vuu-utils/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 DynamicFeatureProps<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 /**\n * url for css file for feature\n */\n css?: string;\n featureProps?: {\n vuuTables?: \"*\" | VuuTable[];\n };\n leftNavLocation: \"vuu-features\" | \"vuu-tables\";\n name: string;\n title: string;\n /**\n * url for javascript bundle to load feature\n */\n url: string;\n viewProps?: ViewConfig;\n}\n\nexport interface StaticFeatureDescriptor {\n group?: string;\n label: string;\n type: string;\n}\n\nconst isStaticFeature = (\n feature: unknown,\n): feature is StaticFeatureDescriptor =>\n feature !== null && typeof feature === \"object\" && \"type\" in feature;\n\nexport const isStaticFeatures = (\n features: unknown,\n): features is StaticFeatureDescriptor[] =>\n Array.isArray(features) && features.every(isStaticFeature);\n\nexport interface FilterTableFeatureProps {\n tableSchema: TableSchema;\n}\n\nexport type DynamicFeatures = {\n [key: string]: DynamicFeatureDescriptor;\n};\n\nexport function featureFromJson({ type }: { type: string }): ReactElement {\n const componentType = type.match(/^[a-z]/) ? type : getLayoutComponent(type);\n if (componentType === undefined) {\n throw Error(\n `layoutUtils unable to create feature component from JSON, unknown type ${type}`,\n );\n }\n return React.createElement(componentType);\n}\n\nexport interface VuuConfig {\n features: DynamicFeatures;\n authUrl?: string;\n websocketUrl: string;\n ssl: boolean;\n}\n\n/**\n * We currently categorize 'features' simply by the leftNavLocation\n * @param feature\n * @returns\n */\nexport const isCustomFeature = (feature: DynamicFeatureDescriptor) =>\n feature.leftNavLocation === \"vuu-features\";\n\nexport const isWildcardSchema = (\n vuuTables?: \"*\" | VuuTable[],\n): vuuTables is \"*\" => vuuTables === \"*\";\nexport const isVuuTables = (\n vuuTables?: \"*\" | VuuTable[],\n): vuuTables is VuuTable[] => Array.isArray(vuuTables);\n\nexport interface FeaturePropsWithFilterTableFeature\n extends Omit<DynamicFeatureProps, \"ComponentProps\"> {\n ComponentProps: FilterTableFeatureProps;\n}\n\nexport const hasFilterTableFeatureProps = (\n props: DynamicFeatureProps,\n): props is FeaturePropsWithFilterTableFeature =>\n typeof props.ComponentProps === \"object\" &&\n props.ComponentProps !== null &&\n \"tableSchema\" in props.ComponentProps;\n\nexport const isSameTable = (t1: VuuTable, t2: VuuTable) => {\n t1.module === t2.module && t1.table == t2.table;\n};\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}) => DynamicFeatureProps;\n\nexport const getFilterTableFeatures = (\n schemas: TableSchema[],\n getFeaturePath: GetFeaturePaths,\n) =>\n schemas\n .sort(byModule)\n .map<DynamicFeatureProps<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/**\n * Process the DynamicFeature descriptors. Identify\n * the vuu tables required and inject the appropriate TableSchemas\n *\n * @param dynamicFeatures\n * @param tableSchemas\n * @returns\n */\nexport const getCustomAndTableFeatures = (\n dynamicFeatures: DynamicFeatureDescriptor[],\n tableSchemas: TableSchema[],\n): {\n dynamicFeatures: DynamicFeatureProps[];\n tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[];\n} => {\n // Split features into simple tables and 'custom' features\n const [customFeatureConfig, tableFeaturesConfig] = partition(\n dynamicFeatures,\n isCustomFeature,\n );\n\n const customFeatures: DynamicFeatureProps[] = [];\n const tableFeatures: DynamicFeatureProps<FilterTableFeatureProps>[] = [];\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of tableFeaturesConfig) {\n const { vuuTables } = featureProps;\n // Currently FilterTable is the only 'tableFeature' and it uses the wildcard\n if (isWildcardSchema(vuuTables)) {\n if (tableSchemas) {\n for (const tableSchema of tableSchemas) {\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 }\n }\n }\n\n for (const {\n featureProps = {},\n viewProps,\n ...feature\n } of customFeatureConfig) {\n const { vuuTables } = featureProps;\n if (isVuuTables(vuuTables)) {\n if (tableSchemas) {\n customFeatures.push({\n ...feature,\n ComponentProps: vuuTables.reduce<Record<string, TableSchema>>(\n (map, vuuTable) => {\n map[`${vuuTable.table}Schema`] = tableSchemas.find(\n (tableSchema) => isSameTable(vuuTable, tableSchema.table),\n ) as TableSchema;\n return map;\n },\n {},\n ),\n ViewProps: viewProps,\n });\n }\n } else {\n customFeatures.push(feature);\n }\n }\n return { dynamicFeatures: customFeatures, tableFeat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AAG,OAAA;AAAA,UACH,gBAAgB,SAAU,CAAA,MAAA;AAAA,YACxB,CAAC,KAAK,QAAa,KAAA;AACjB,cAAA,GAAA,CAAI,CAAG,EAAA,QAAA,CAAS,KAAK,CAAA,MAAA,CAAQ,IAAI,YAAa,CAAA,IAAA;AAAA,gBAC5C,CAAC,WAAA,KAAgB,WAAY,CAAA,QAAA,EAAU,YAAY,KAAK;AAAA,eAC1D;AACA,cAAO,OAAA,GAAA;AAAA,aACT;AAAA,YACA;AAAC,WACH;AAAA,UACA,SAAW,EAAA;AAAA,SACZ,CAAA;AAAA;AACH,KACK,MAAA;AACL,MAAA,cAAA,CAAe,KAAK,OAAO,CAAA;AAAA;AAC7B;AAEF,EAAO,OAAA,EAAE,eAAiB,EAAA,cAAA,EAAgB,aAA6B,EAAA;AACzE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.13.
|
|
2
|
+
"version": "0.13.26",
|
|
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.13.
|
|
8
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
9
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
10
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
7
|
+
"@vuu-ui/vuu-data-types": "0.13.26",
|
|
8
|
+
"@vuu-ui/vuu-table-types": "0.13.26",
|
|
9
|
+
"@vuu-ui/vuu-filter-types": "0.13.26",
|
|
10
|
+
"@vuu-ui/vuu-protocol-types": "0.13.26"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@internationalized/date": "^3.0.0",
|
|
14
|
-
"@vuu-ui/vuu-filter-parser": "0.13.
|
|
14
|
+
"@vuu-ui/vuu-filter-parser": "0.13.26",
|
|
15
15
|
"clsx": "^2.0.0",
|
|
16
16
|
"react": "^19.1.0",
|
|
17
17
|
"react-dom": "^19.1.0"
|
package/types/feature-utils.d.ts
CHANGED
|
@@ -33,14 +33,20 @@ declare global {
|
|
|
33
33
|
const vuuConfig: Promise<VuuConfig>;
|
|
34
34
|
}
|
|
35
35
|
export interface DynamicFeatureDescriptor {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
/**
|
|
37
|
+
* url for css file for feature
|
|
38
|
+
*/
|
|
39
39
|
css?: string;
|
|
40
|
-
leftNavLocation: "vuu-features" | "vuu-tables";
|
|
41
40
|
featureProps?: {
|
|
42
41
|
vuuTables?: "*" | VuuTable[];
|
|
43
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;
|
|
44
50
|
viewProps?: ViewConfig;
|
|
45
51
|
}
|
|
46
52
|
export interface StaticFeatureDescriptor {
|