@vuu-ui/vuu-utils 0.8.78 → 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.
Files changed (127) hide show
  1. package/cjs/ShellContext.js.map +1 -1
  2. package/cjs/feature-utils.js +17 -2
  3. package/cjs/feature-utils.js.map +1 -1
  4. package/cjs/index.js +1 -0
  5. package/cjs/index.js.map +1 -1
  6. package/esm/ShellContext.js.map +1 -1
  7. package/esm/feature-utils.js +17 -3
  8. package/esm/feature-utils.js.map +1 -1
  9. package/esm/index.js +1 -1
  10. package/package.json +6 -6
  11. package/types/{vuu-utils/src/ShellContext.d.ts → ShellContext.d.ts} +2 -2
  12. package/types/{vuu-utils/src/feature-utils.d.ts → feature-utils.d.ts} +37 -13
  13. package/types/vuu-shell/src/ShellContextProvider.d.ts +0 -10
  14. package/types/vuu-shell/src/app-header/AppHeader.d.ts +0 -6
  15. package/types/vuu-shell/src/app-header/index.d.ts +0 -1
  16. package/types/vuu-shell/src/application-provider/ApplicationContext.d.ts +0 -12
  17. package/types/vuu-shell/src/application-provider/ApplicationProvider.d.ts +0 -19
  18. package/types/vuu-shell/src/application-provider/index.d.ts +0 -1
  19. package/types/vuu-shell/src/connection-status/ConnectionStatusIndicator.d.ts +0 -10
  20. package/types/vuu-shell/src/connection-status/index.d.ts +0 -1
  21. package/types/vuu-shell/src/datasource-provider/DataSourceProvider.d.ts +0 -21
  22. package/types/vuu-shell/src/datasource-provider/index.d.ts +0 -1
  23. package/types/vuu-shell/src/feature/Feature.d.ts +0 -26
  24. package/types/vuu-shell/src/feature/FeatureErrorBoundary.d.ts +0 -13
  25. package/types/vuu-shell/src/feature/Loader.d.ts +0 -2
  26. package/types/vuu-shell/src/feature/index.d.ts +0 -1
  27. package/types/vuu-shell/src/feature-list/FeatureList.d.ts +0 -7
  28. package/types/vuu-shell/src/feature-list/index.d.ts +0 -1
  29. package/types/vuu-shell/src/feature-provider/FeatureProvider.d.ts +0 -14
  30. package/types/vuu-shell/src/feature-provider/index.d.ts +0 -2
  31. package/types/vuu-shell/src/feature-provider/useVuuFeatures.d.ts +0 -9
  32. package/types/vuu-shell/src/index.d.ts +0 -16
  33. package/types/vuu-shell/src/left-nav/LeftNav.d.ts +0 -18
  34. package/types/vuu-shell/src/left-nav/index.d.ts +0 -1
  35. package/types/vuu-shell/src/login/LoginPanel.d.ts +0 -7
  36. package/types/vuu-shell/src/login/VuuLogo.d.ts +0 -2
  37. package/types/vuu-shell/src/login/index.d.ts +0 -2
  38. package/types/vuu-shell/src/login/login-utils.d.ts +0 -4
  39. package/types/vuu-shell/src/persistence-manager/LocalPersistenceManager.d.ts +0 -21
  40. package/types/vuu-shell/src/persistence-manager/PersistenceManager.d.ts +0 -66
  41. package/types/vuu-shell/src/persistence-manager/PersistenceProvider.d.ts +0 -11
  42. package/types/vuu-shell/src/persistence-manager/RemotePersistenceManager.d.ts +0 -23
  43. package/types/vuu-shell/src/persistence-manager/StaticPersistenceManager.d.ts +0 -21
  44. package/types/vuu-shell/src/persistence-manager/index.d.ts +0 -5
  45. package/types/vuu-shell/src/shell-layout-templates/context-panel/ContextPanel.d.ts +0 -11
  46. package/types/vuu-shell/src/shell-layout-templates/context-panel/index.d.ts +0 -1
  47. package/types/vuu-shell/src/shell-layout-templates/full-height-left-panel/useFullHeightLeftPanel.d.ts +0 -2
  48. package/types/vuu-shell/src/shell-layout-templates/index.d.ts +0 -3
  49. package/types/vuu-shell/src/shell-layout-templates/inlay-left-panel/useInlayLeftPanel.d.ts +0 -2
  50. package/types/vuu-shell/src/shell-layout-templates/side-panel/SidePanel.d.ts +0 -8
  51. package/types/vuu-shell/src/shell-layout-templates/side-panel/index.d.ts +0 -1
  52. package/types/vuu-shell/src/shell-layout-templates/simple-content-pane/useSimpleContentPane.d.ts +0 -2
  53. package/types/vuu-shell/src/shell-layout-templates/useShellLayout.d.ts +0 -41
  54. package/types/vuu-shell/src/shell.d.ts +0 -15
  55. package/types/vuu-shell/src/theme-switch/ThemeSwitch.d.ts +0 -8
  56. package/types/vuu-shell/src/theme-switch/index.d.ts +0 -1
  57. package/types/vuu-shell/src/user-settings/SettingsForm.d.ts +0 -47
  58. package/types/vuu-shell/src/user-settings/UserSettingsPanel.d.ts +0 -3
  59. package/types/vuu-shell/src/user-settings/index.d.ts +0 -2
  60. package/types/vuu-shell/src/workspace-management/LayoutList.d.ts +0 -2
  61. package/types/vuu-shell/src/workspace-management/LayoutTile.d.ts +0 -7
  62. package/types/vuu-shell/src/workspace-management/SaveLayoutPanel.d.ts +0 -10
  63. package/types/vuu-shell/src/workspace-management/WorkspaceProvider.d.ts +0 -53
  64. package/types/vuu-shell/src/workspace-management/defaultWorkspaceJSON.d.ts +0 -9
  65. package/types/vuu-shell/src/workspace-management/index.d.ts +0 -5
  66. package/types/vuu-shell/src/workspace-management/screenshot-utils.d.ts +0 -6
  67. package/types/vuu-shell/src/workspace-management/useWorkspaceContextMenuItems.d.ts +0 -5
  68. /package/types/{vuu-utils/src/DataWindow.d.ts → DataWindow.d.ts} +0 -0
  69. /package/types/{vuu-utils/src/ThemeProvider.d.ts → ThemeProvider.d.ts} +0 -0
  70. /package/types/{vuu-utils/src/array-utils.d.ts → array-utils.d.ts} +0 -0
  71. /package/types/{vuu-utils/src/box-utils.d.ts → box-utils.d.ts} +0 -0
  72. /package/types/{vuu-utils/src/broadcast-channel.d.ts → broadcast-channel.d.ts} +0 -0
  73. /package/types/{vuu-utils/src/column-utils.d.ts → column-utils.d.ts} +0 -0
  74. /package/types/{vuu-utils/src/common-types.d.ts → common-types.d.ts} +0 -0
  75. /package/types/{vuu-utils/src/component-registry.d.ts → component-registry.d.ts} +0 -0
  76. /package/types/{vuu-utils/src/context-definitions → context-definitions}/WorkspaceContext.d.ts +0 -0
  77. /package/types/{vuu-utils/src/cookie-utils.d.ts → cookie-utils.d.ts} +0 -0
  78. /package/types/{vuu-utils/src/css-utils.d.ts → css-utils.d.ts} +0 -0
  79. /package/types/{vuu-utils/src/data-utils.d.ts → data-utils.d.ts} +0 -0
  80. /package/types/{vuu-utils/src/datasource-action-utils.d.ts → datasource-action-utils.d.ts} +0 -0
  81. /package/types/{vuu-utils/src/datasource-utils.d.ts → datasource-utils.d.ts} +0 -0
  82. /package/types/{vuu-utils/src/date → date}/date-utils.d.ts +0 -0
  83. /package/types/{vuu-utils/src/date → date}/dateTimePattern.d.ts +0 -0
  84. /package/types/{vuu-utils/src/date → date}/formatter.d.ts +0 -0
  85. /package/types/{vuu-utils/src/date → date}/index.d.ts +0 -0
  86. /package/types/{vuu-utils/src/date → date}/types.d.ts +0 -0
  87. /package/types/{vuu-utils/src/debug-utils.d.ts → debug-utils.d.ts} +0 -0
  88. /package/types/{vuu-utils/src/event-emitter.d.ts → event-emitter.d.ts} +0 -0
  89. /package/types/{vuu-utils/src/filters → filters}/filterAsQuery.d.ts +0 -0
  90. /package/types/{vuu-utils/src/filters → filters}/index.d.ts +0 -0
  91. /package/types/{vuu-utils/src/filters → filters}/utils.d.ts +0 -0
  92. /package/types/{vuu-utils/src/form-utils.d.ts → form-utils.d.ts} +0 -0
  93. /package/types/{vuu-utils/src/formatting-utils.d.ts → formatting-utils.d.ts} +0 -0
  94. /package/types/{vuu-utils/src/getUniqueId.d.ts → getUniqueId.d.ts} +0 -0
  95. /package/types/{vuu-utils/src/group-utils.d.ts → group-utils.d.ts} +0 -0
  96. /package/types/{vuu-utils/src/html-utils.d.ts → html-utils.d.ts} +0 -0
  97. /package/types/{vuu-utils/src/index.d.ts → index.d.ts} +0 -0
  98. /package/types/{vuu-utils/src/input-utils.d.ts → input-utils.d.ts} +0 -0
  99. /package/types/{vuu-utils/src/invariant.d.ts → invariant.d.ts} +0 -0
  100. /package/types/{vuu-utils/src/itemToString.d.ts → itemToString.d.ts} +0 -0
  101. /package/types/{vuu-utils/src/json-types.d.ts → json-types.d.ts} +0 -0
  102. /package/types/{vuu-utils/src/json-utils.d.ts → json-utils.d.ts} +0 -0
  103. /package/types/{vuu-utils/src/keyboard-utils.d.ts → keyboard-utils.d.ts} +0 -0
  104. /package/types/{vuu-utils/src/keyset.d.ts → keyset.d.ts} +0 -0
  105. /package/types/{vuu-utils/src/layout-types.d.ts → layout-types.d.ts} +0 -0
  106. /package/types/{vuu-utils/src/list-utils.d.ts → list-utils.d.ts} +0 -0
  107. /package/types/{vuu-utils/src/local-storage-utils.d.ts → local-storage-utils.d.ts} +0 -0
  108. /package/types/{vuu-utils/src/logging-utils.d.ts → logging-utils.d.ts} +0 -0
  109. /package/types/{vuu-utils/src/menu-utils.d.ts → menu-utils.d.ts} +0 -0
  110. /package/types/{vuu-utils/src/module-utils.d.ts → module-utils.d.ts} +0 -0
  111. /package/types/{vuu-utils/src/nanoid → nanoid}/index.d.ts +0 -0
  112. /package/types/{vuu-utils/src/perf-utils.d.ts → perf-utils.d.ts} +0 -0
  113. /package/types/{vuu-utils/src/protocol-message-utils.d.ts → protocol-message-utils.d.ts} +0 -0
  114. /package/types/{vuu-utils/src/range-utils.d.ts → range-utils.d.ts} +0 -0
  115. /package/types/{vuu-utils/src/react-utils.d.ts → react-utils.d.ts} +0 -0
  116. /package/types/{vuu-utils/src/round-decimal.d.ts → round-decimal.d.ts} +0 -0
  117. /package/types/{vuu-utils/src/row-utils.d.ts → row-utils.d.ts} +0 -0
  118. /package/types/{vuu-utils/src/selection-utils.d.ts → selection-utils.d.ts} +0 -0
  119. /package/types/{vuu-utils/src/shell-layout-types.d.ts → shell-layout-types.d.ts} +0 -0
  120. /package/types/{vuu-utils/src/sort-utils.d.ts → sort-utils.d.ts} +0 -0
  121. /package/types/{vuu-utils/src/table-schema-utils.d.ts → table-schema-utils.d.ts} +0 -0
  122. /package/types/{vuu-utils/src/text-utils.d.ts → text-utils.d.ts} +0 -0
  123. /package/types/{vuu-utils/src/ts-utils.d.ts → ts-utils.d.ts} +0 -0
  124. /package/types/{vuu-utils/src/url-utils.d.ts → url-utils.d.ts} +0 -0
  125. /package/types/{vuu-utils/src/useId.d.ts → useId.d.ts} +0 -0
  126. /package/types/{vuu-utils/src/useLayoutEffectSkipFirst.d.ts → useLayoutEffectSkipFirst.d.ts} +0 -0
  127. /package/types/{vuu-utils/src/user-types.d.ts → user-types.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ShellContext.js","sources":["../src/ShellContext.ts"],"sourcesContent":["import { RpcResponseHandler } from \"packages/vuu-data-types\";\nimport { LookupTableProvider } from \"packages/vuu-shell/src\";\nimport {\n DefaultColumnConfiguration,\n DefaultTableConfiguration,\n} from \"packages/vuu-table-types\";\nimport { createContext, useContext } from \"react\";\n\nexport interface ShellContextProps {\n getDefaultColumnConfig?: DefaultColumnConfiguration;\n getDefaultTableConfig?: DefaultTableConfiguration;\n getLookupValues?: LookupTableProvider;\n handleRpcResponse?: RpcResponseHandler;\n}\n\nconst defaultConfig = {};\n\nexport const ShellContext = createContext<ShellContextProps>(defaultConfig);\n\nexport const useShellContext = () => {\n return useContext(ShellContext);\n};\n"],"names":["createContext","useContext"],"mappings":";;;;AAeA,MAAM,gBAAgB,EAAC,CAAA;AAEV,MAAA,YAAA,GAAeA,oBAAiC,aAAa,EAAA;AAEnE,MAAM,kBAAkB,MAAM;AACnC,EAAA,OAAOC,iBAAW,YAAY,CAAA,CAAA;AAChC;;;;;"}
1
+ {"version":3,"file":"ShellContext.js","sources":["../src/ShellContext.ts"],"sourcesContent":["import { RpcResponseHandler } from \"@vuu-ui/vuu-data-types\";\nimport {\n DefaultColumnConfiguration,\n DefaultTableConfiguration,\n} from \"packages/vuu-table-types\";\nimport { createContext, useContext } from \"react\";\nimport { LookupTableProvider } from \"./feature-utils\";\n\nexport interface ShellContextProps {\n getDefaultColumnConfig?: DefaultColumnConfiguration;\n getDefaultTableConfig?: DefaultTableConfiguration;\n getLookupValues?: LookupTableProvider;\n handleRpcResponse?: RpcResponseHandler;\n}\n\nconst defaultConfig = {};\n\nexport const ShellContext = createContext<ShellContextProps>(defaultConfig);\n\nexport const useShellContext = () => {\n return useContext(ShellContext);\n};\n"],"names":["createContext","useContext"],"mappings":";;;;AAeA,MAAM,gBAAgB,EAAC,CAAA;AAEV,MAAA,YAAA,GAAeA,oBAAiC,aAAa,EAAA;AAEnE,MAAM,kBAAkB,MAAM;AACnC,EAAA,OAAOC,iBAAW,YAAY,CAAA,CAAA;AAChC;;;;;"}
@@ -2,12 +2,26 @@
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";
10
- const hasFilterTableFeatureProps = (props) => "tableSchema" in (props?.ComponentProps ?? {});
24
+ const hasFilterTableFeatureProps = (props) => typeof props.ComponentProps === "object" && props.ComponentProps !== null && "tableSchema" in props.ComponentProps;
11
25
  const byModule = (schema1, schema2) => {
12
26
  const m1 = schema1.table.module.toLowerCase();
13
27
  const m2 = schema2.table.module.toLowerCase();
@@ -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 type { FeatureProps } from \"@vuu-ui/vuu-shell\";\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 interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\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 \"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;AA8CxB,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;AAOnB,MAAM,6BAA6B,CACxC,KAAA,KAEA,aAAkB,KAAA,KAAA,EAAO,kBAAkB,EAAC,EAAA;AAGjC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,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,KAAA,KAEA,OAAO,KAAA,CAAM,cAAmB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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 +1 @@
1
- {"version":3,"file":"ShellContext.js","sources":["../src/ShellContext.ts"],"sourcesContent":["import { RpcResponseHandler } from \"packages/vuu-data-types\";\nimport { LookupTableProvider } from \"packages/vuu-shell/src\";\nimport {\n DefaultColumnConfiguration,\n DefaultTableConfiguration,\n} from \"packages/vuu-table-types\";\nimport { createContext, useContext } from \"react\";\n\nexport interface ShellContextProps {\n getDefaultColumnConfig?: DefaultColumnConfiguration;\n getDefaultTableConfig?: DefaultTableConfiguration;\n getLookupValues?: LookupTableProvider;\n handleRpcResponse?: RpcResponseHandler;\n}\n\nconst defaultConfig = {};\n\nexport const ShellContext = createContext<ShellContextProps>(defaultConfig);\n\nexport const useShellContext = () => {\n return useContext(ShellContext);\n};\n"],"names":[],"mappings":";;AAeA,MAAM,gBAAgB,EAAC,CAAA;AAEV,MAAA,YAAA,GAAe,cAAiC,aAAa,EAAA;AAEnE,MAAM,kBAAkB,MAAM;AACnC,EAAA,OAAO,WAAW,YAAY,CAAA,CAAA;AAChC;;;;"}
1
+ {"version":3,"file":"ShellContext.js","sources":["../src/ShellContext.ts"],"sourcesContent":["import { RpcResponseHandler } from \"@vuu-ui/vuu-data-types\";\nimport {\n DefaultColumnConfiguration,\n DefaultTableConfiguration,\n} from \"packages/vuu-table-types\";\nimport { createContext, useContext } from \"react\";\nimport { LookupTableProvider } from \"./feature-utils\";\n\nexport interface ShellContextProps {\n getDefaultColumnConfig?: DefaultColumnConfiguration;\n getDefaultTableConfig?: DefaultTableConfiguration;\n getLookupValues?: LookupTableProvider;\n handleRpcResponse?: RpcResponseHandler;\n}\n\nconst defaultConfig = {};\n\nexport const ShellContext = createContext<ShellContextProps>(defaultConfig);\n\nexport const useShellContext = () => {\n return useContext(ShellContext);\n};\n"],"names":[],"mappings":";;AAeA,MAAM,gBAAgB,EAAC,CAAA;AAEV,MAAA,YAAA,GAAe,cAAiC,aAAa,EAAA;AAEnE,MAAM,kBAAkB,MAAM;AACnC,EAAA,OAAO,WAAW,YAAY,CAAA,CAAA;AAChC;;;;"}
@@ -1,11 +1,25 @@
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";
8
- const hasFilterTableFeatureProps = (props) => "tableSchema" in (props?.ComponentProps ?? {});
22
+ const hasFilterTableFeatureProps = (props) => typeof props.ComponentProps === "object" && props.ComponentProps !== null && "tableSchema" in props.ComponentProps;
9
23
  const byModule = (schema1, schema2) => {
10
24
  const m1 = schema1.table.module.toLowerCase();
11
25
  const m2 = schema2.table.module.toLowerCase();
@@ -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 type { FeatureProps } from \"@vuu-ui/vuu-shell\";\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 interface ViewConfig {\n allowRename?: boolean;\n closeable?: boolean;\n header?: boolean;\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 \"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;AA8CxB,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA,eAAA;AAEjB,MAAA,gBAAA,GAAmB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AC9C,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;AASO,MAAM,eAAkB,GAAA,CAAC,OAC9B,KAAA,OAAA,CAAQ,eAAoB,KAAA,eAAA;AAEjB,MAAA,gBAAA,GAAmB,CAAC,MAAA,KA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,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.78",
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.78",
8
- "@vuu-ui/vuu-table-types": "0.8.78",
9
- "@vuu-ui/vuu-filter-types": "0.8.78",
10
- "@vuu-ui/vuu-protocol-types": "0.8.78"
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.78",
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,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { RpcResponseHandler } from "packages/vuu-data-types";
3
- import { LookupTableProvider } from "packages/vuu-shell/src";
2
+ import { RpcResponseHandler } from "@vuu-ui/vuu-data-types";
4
3
  import { DefaultColumnConfiguration, DefaultTableConfiguration } from "packages/vuu-table-types";
4
+ import { LookupTableProvider } from "./feature-utils";
5
5
  export interface ShellContextProps {
6
6
  getDefaultColumnConfig?: DefaultColumnConfiguration;
7
7
  getDefaultTableConfig?: DefaultTableConfiguration;
@@ -1,20 +1,38 @@
1
1
  import type { TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
3
- import type { FeatureProps } from "@vuu-ui/vuu-shell";
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;
10
+ export type LookupTableProvider = (table: VuuTable) => ListOption[];
9
11
  export interface ViewConfig {
10
12
  allowRename?: boolean;
11
13
  closeable?: boolean;
12
14
  header?: boolean;
13
15
  }
16
+ export interface FeatureProps<P extends object | undefined = object> {
17
+ /**
18
+ props that will be passed to the lazily loaded component.
19
+ */
20
+ ComponentProps?: P;
21
+ ViewProps?: ViewConfig;
22
+ css?: string;
23
+ height?: number;
24
+ title?: string;
25
+ /**
26
+ The url of javascript bundle to lazily load. Bundle must provide a default export
27
+ and that export must be a React component.
28
+ */
29
+ url: string;
30
+ width?: number;
31
+ }
14
32
  declare global {
15
33
  const vuuConfig: Promise<VuuConfig>;
16
34
  }
17
- export interface FeatureConfig {
35
+ export interface DynamicFeatureDescriptor {
18
36
  name: string;
19
37
  title: string;
20
38
  url: string;
@@ -26,25 +44,28 @@ export interface FeatureConfig {
26
44
  };
27
45
  viewProps?: ViewConfig;
28
46
  }
29
- export interface VuuConfig {
30
- features: Features;
31
- authUrl?: string;
32
- websocketUrl: string;
33
- ssl: boolean;
47
+ export interface StaticFeatureDescriptor {
48
+ group?: string;
49
+ label: string;
50
+ type: string;
34
51
  }
35
52
  export interface FilterTableFeatureProps {
36
53
  tableSchema: TableSchema;
37
54
  }
38
- export type Features = {
39
- [key: string]: FeatureConfig;
55
+ export type DynamicFeatures = {
56
+ [key: string]: DynamicFeatureDescriptor;
40
57
  };
58
+ export type StaticFeatures = {
59
+ [key: string]: StaticFeatureDescriptor;
60
+ };
61
+ export declare function featureFromJson({ type, label, }: StaticFeatureDescriptor): ReactElement;
41
62
  export interface VuuConfig {
42
- features: Features;
63
+ features: DynamicFeatures;
43
64
  authUrl?: string;
44
65
  websocketUrl: string;
45
66
  ssl: boolean;
46
67
  }
47
- export declare const isCustomFeature: (feature: FeatureConfig) => boolean;
68
+ export declare const isCustomFeature: (feature: DynamicFeatureDescriptor) => boolean;
48
69
  export declare const isWildcardSchema: (schema?: "*" | VuuTable) => schema is "*";
49
70
  export declare const isTableSchema: (schema?: "*" | VuuTable) => schema is VuuTable;
50
71
  export interface FeaturePropsWithFilterTableFeature extends Omit<FeatureProps, "ComponentProps"> {
@@ -64,4 +85,7 @@ export type Component = {
64
85
  };
65
86
  export declare const assertComponentRegistered: (componentName: string, component: unknown) => void;
66
87
  export declare const assertComponentsRegistered: (componentList: Component[]) => void;
67
- 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
+ };
@@ -1,10 +0,0 @@
1
- import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
2
- import { ListOption } from "@vuu-ui/vuu-table-types";
3
- import { ShellContextProps } from "@vuu-ui/vuu-utils";
4
- import { ReactElement, ReactNode } from "react";
5
- export type LookupTableProvider = (table: VuuTable) => ListOption[];
6
- export interface ShellProviderProps {
7
- children: ReactNode;
8
- value?: ShellContextProps;
9
- }
10
- export declare const ShellContextProvider: ({ children, value, }: ShellProviderProps) => ReactElement;
@@ -1,6 +0,0 @@
1
- import { ThemeMode } from "@vuu-ui/vuu-utils";
2
- import { HTMLAttributes } from "react";
3
- export interface AppHeaderProps extends HTMLAttributes<HTMLDivElement> {
4
- themeMode?: ThemeMode;
5
- }
6
- export declare const AppHeader: ({ className: classNameProp, themeMode: _, ...htmlAttributes }: AppHeaderProps) => JSX.Element;
@@ -1 +0,0 @@
1
- export * from './AppHeader';
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import type { Settings, VuuUser } from "@vuu-ui/vuu-utils";
3
- import { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
4
- import { SettingsSchema } from "../user-settings";
5
- export interface ApplicationContextProps {
6
- onUserSettingChanged: (propertyName: string, value: VuuRowDataItemType) => void;
7
- loginUrl?: string;
8
- userSettings?: Settings;
9
- userSettingsSchema?: SettingsSchema;
10
- user: VuuUser;
11
- }
12
- export declare const ApplicationContext: import("react").Context<ApplicationContextProps>;
@@ -1,19 +0,0 @@
1
- import { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
2
- import { Density, ThemeContextProps } from "@salt-ds/core";
3
- import { ReactElement, ReactNode } from "react";
4
- import { ApplicationContextProps } from "./ApplicationContext";
5
- export interface ApplicationProviderProps extends Partial<Pick<ThemeContextProps, "theme" | "mode">>, Partial<Omit<ApplicationContextProps, "userSettings">> {
6
- children: ReactNode;
7
- density?: Density;
8
- }
9
- export declare const ApplicationProvider: ({ children, density: densityProp, loginUrl, mode, theme, userSettingsSchema: userSettingsSchema, user, }: ApplicationProviderProps) => ReactElement | null;
10
- export declare const useApplicationUser: () => import("packages/vuu-utils/src").VuuUser;
11
- export declare const useLoginUrl: () => string | undefined;
12
- export declare const useApplicationSettings: () => {
13
- onUserSettingChanged: (propertyName: string, value: VuuRowDataItemType) => void;
14
- userSettings: import("packages/vuu-utils/src").Settings | undefined;
15
- userSettingsSchema: import("packages/vuu-shell/src").SettingsSchema | undefined;
16
- };
17
- export declare const useUserSetting: () => {
18
- userSettings: import("packages/vuu-utils/src").Settings | undefined;
19
- };
@@ -1 +0,0 @@
1
- export * from "./ApplicationProvider";
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- type connectionStatus = "connected" | "reconnected" | "connecting" | "disconnected";
3
- interface ConnectionStatusProps {
4
- connectionStatus: connectionStatus;
5
- className?: string;
6
- props?: unknown;
7
- element?: string;
8
- }
9
- export declare const ConnectionStatusIndicator: ({ connectionStatus, className, element, ...props }: ConnectionStatusProps) => JSX.Element;
10
- export {};
@@ -1 +0,0 @@
1
- export * from "./ConnectionStatusIndicator";
@@ -1,21 +0,0 @@
1
- import { ServerAPI } from "@vuu-ui/vuu-data-remote";
2
- import { DataSource, DataSourceConstructorProps } from "@vuu-ui/vuu-data-types";
3
- import { ReactNode } from "react";
4
- export type DataSourceConstructor = {
5
- new (props: DataSourceConstructorProps): DataSource;
6
- };
7
- export interface DataSourceContextProps {
8
- isLocalData: boolean;
9
- VuuDataSource: DataSourceConstructor;
10
- vuuModuleName?: string;
11
- getServerAPI: () => Promise<Pick<ServerAPI, "getTableList" | "getTableSchema">>;
12
- }
13
- /**
14
- * If a client is adding a DataSOurceProvider, it will ususlly be
15
- * to install local test data, so we default isLocalData to true
16
- */
17
- export declare const DataSourceProvider: ({ children, getServerAPI, isLocalData, VuuDataSource, vuuModuleName, }: Omit<DataSourceContextProps, "isLocalData"> & {
18
- children: ReactNode;
19
- isLocalData?: boolean | undefined;
20
- }) => JSX.Element;
21
- export declare const useDataSource: () => DataSourceContextProps;
@@ -1 +0,0 @@
1
- export * from "./DataSourceProvider";
@@ -1,26 +0,0 @@
1
- import { ViewConfig } from "@vuu-ui/vuu-utils";
2
- import React from "react";
3
- export interface FeatureProps<P extends object | undefined = object> {
4
- /**
5
- props that will be passed to the lazily loaded component.
6
- */
7
- ComponentProps?: P;
8
- ViewProps?: ViewConfig;
9
- css?: string;
10
- height?: number;
11
- title?: string;
12
- /**
13
- The url of javascript bundle to lazily load. Bundle must provide a default export
14
- and that export must be a React component.
15
- */
16
- url: string;
17
- width?: number;
18
- }
19
- declare function RawFeature<Params extends object | undefined>({ url, css, ComponentProps: params, ...props }: FeatureProps<Params>): JSX.Element;
20
- /**
21
- Feature is a wrapper around React Lazy Loading. It will load a component
22
- from the given url. That url must resolve to a javascript bundle with a
23
- single default export. That export must be a React component.
24
- */
25
- export declare const Feature: React.MemoExoticComponent<typeof RawFeature>;
26
- export {};
@@ -1,13 +0,0 @@
1
- import React, { ErrorInfo, ReactNode } from "react";
2
- import { FeatureProps } from "./Feature";
3
- export interface FeatureErrorBoundaryProps extends FeatureProps {
4
- children: ReactNode;
5
- }
6
- export declare class FeatureErrorBoundary extends React.Component<FeatureErrorBoundaryProps, any> {
7
- constructor(props: FeatureErrorBoundaryProps);
8
- static getDerivedStateFromError(error: Error): {
9
- errorMessage: string;
10
- };
11
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
12
- render(): React.ReactNode;
13
- }
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const Loader: () => JSX.Element;
@@ -1 +0,0 @@
1
- export * from './Feature';
@@ -1,7 +0,0 @@
1
- import { HTMLAttributes } from "react";
2
- import { FeatureProps } from "../feature/Feature";
3
- export type GroupedFeatureProps<P extends object | undefined = object> = Record<string, FeatureProps<P>[]>;
4
- export interface FeatureListProps<P extends object | undefined = object> extends HTMLAttributes<HTMLDivElement> {
5
- features: FeatureProps<P>[] | GroupedFeatureProps<P>;
6
- }
7
- export declare const FeatureList: ({ features, title, ...htmlAttributes }: FeatureListProps) => JSX.Element;
@@ -1 +0,0 @@
1
- export * from "./FeatureList";
@@ -1,14 +0,0 @@
1
- import { Features, FilterTableFeatureProps } from "@vuu-ui/vuu-utils";
2
- import { ReactElement, ReactNode } from "react";
3
- import { FeatureProps } from "../feature/Feature";
4
- export interface FeatureContextProps {
5
- features: FeatureProps[];
6
- tableFeatures: FeatureProps<FilterTableFeatureProps>[];
7
- }
8
- export interface FeatureProviderProps extends Partial<FeatureContextProps> {
9
- children: ReactNode;
10
- configuredFeatures: Features;
11
- }
12
- export declare const FeatureProvider: ({ children, configuredFeatures, features: featuresProp, tableFeatures: tableFeaturesProp, }: FeatureProviderProps) => ReactElement;
13
- export type FeaturesHook = (props?: Partial<FeatureContextProps>) => FeatureContextProps;
14
- export declare const useFeatures: FeaturesHook;
@@ -1,2 +0,0 @@
1
- export * from "./FeatureProvider";
2
- export * from "./useVuuFeatures";
@@ -1,9 +0,0 @@
1
- import { Features, FilterTableFeatureProps } from "@vuu-ui/vuu-utils";
2
- import { FeatureProps } from "../feature/Feature";
3
- export interface FeaturesHookProps {
4
- features: Features;
5
- }
6
- export declare const useVuuFeatures: ({ features, }: FeaturesHookProps) => [
7
- FeatureProps[],
8
- FeatureProps<FilterTableFeatureProps>[]
9
- ];
@@ -1,16 +0,0 @@
1
- export * from "./application-provider";
2
- export * from "./app-header";
3
- export * from "./connection-status";
4
- export * from "./datasource-provider";
5
- export * from "./feature";
6
- export * from "./feature-provider";
7
- export * from "./left-nav";
8
- export * from "./login";
9
- export * from "./persistence-manager";
10
- export * from "./shell";
11
- export * from "./shell-layout-templates";
12
- export * from "./ShellContextProvider";
13
- export * from "./feature-list";
14
- export * from "./theme-switch";
15
- export * from "./user-settings";
16
- export * from "./workspace-management";
@@ -1,18 +0,0 @@
1
- import { FilterTableFeatureProps } from "@vuu-ui/vuu-utils";
2
- import { HTMLAttributes } from "react";
3
- import { FeatureProps } from "../feature";
4
- export type NavDisplayStatus = "menu-full" | "menu-icons" | "menu-full-content" | "menu-icons-content";
5
- export type NavDisplayStatusHandler = (navDisplayStatus: NavDisplayStatus) => void;
6
- export interface LeftNavProps extends HTMLAttributes<HTMLDivElement> {
7
- "data-path"?: string;
8
- defaultActiveTabIndex?: number;
9
- defaultExpanded?: boolean;
10
- features?: FeatureProps[];
11
- onActiveChange?: (activeTabIndex: number) => void;
12
- onTogglePrimaryMenu?: (expanded: boolean) => void;
13
- sizeCollapsed?: number;
14
- sizeContent?: number;
15
- sizeExpanded?: number;
16
- tableFeatures?: FeatureProps<FilterTableFeatureProps>[];
17
- }
18
- export declare const LeftNav: (props: LeftNavProps) => JSX.Element;
@@ -1 +0,0 @@
1
- export * from "./LeftNav";
@@ -1,7 +0,0 @@
1
- import { HTMLAttributes } from "react";
2
- export interface LoginPanelProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSubmit"> {
3
- appName?: string;
4
- onSubmit: (username: string, password?: string) => void;
5
- requirePassword?: boolean;
6
- }
7
- export declare const LoginPanel: ({ appName, className, requirePassword, onSubmit, ...htmlAttributes }: LoginPanelProps) => JSX.Element;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const VuuLogo: () => JSX.Element;
@@ -1,2 +0,0 @@
1
- export * from './LoginPanel';
2
- export * from './login-utils';
@@ -1,4 +0,0 @@
1
- export declare const getAuthModeFromCookies: () => string;
2
- export declare const getAuthDetailsFromCookies: () => [string, string];
3
- export declare const redirectToLogin: (loginUrl?: string) => void;
4
- export declare const logout: (loginUrl?: string) => void;