-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add static features to featuresProvider
- Loading branch information
1 parent
d1a7f12
commit a65192c
Showing
9 changed files
with
200 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./FeatureProvider"; | ||
export * from "./useVuuFeatures"; | ||
// export * from "./useVuuFeatures"; |
85 changes: 47 additions & 38 deletions
85
vuu-ui/packages/vuu-shell/src/feature-provider/useVuuFeatures.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,51 @@ | ||
import { useVuuTables } from "@finos/vuu-data-react"; | ||
import { | ||
DynamicFeatures, | ||
FeatureProps, | ||
FilterTableFeatureProps, | ||
StaticFeatureDescriptor, | ||
getCustomAndTableFeatures, | ||
} from "@finos/vuu-utils"; | ||
import { useMemo } from "react"; | ||
// import { useVuuTables } from "@finos/vuu-data-react"; | ||
// import { | ||
// DynamicFeatures, | ||
// FeatureProps, | ||
// FilterTableFeatureProps, | ||
// getCustomAndTableFeatures, | ||
// } from "@finos/vuu-utils"; | ||
// import { useMemo } from "react"; | ||
// import { FeatureContextProps } from "./FeatureProvider"; | ||
|
||
export interface FeaturesHookProps { | ||
features: DynamicFeatures; | ||
staticFeatures?: StaticFeatureDescriptor[]; | ||
} | ||
// export interface FeaturesHookProps { | ||
// dynamicFeatures: DynamicFeatures; | ||
// } | ||
|
||
const NO_FEATURES: ReturnType<typeof useVuuFeatures> = [[], [], []]; | ||
// const NO_FEATURES: { | ||
// vuuFeatures: FeatureProps[]; | ||
// vuuTableFeatures: FeatureProps<FilterTableFeatureProps>[]; | ||
// } = { vuuFeatures: [], vuuTableFeatures: [] }; | ||
|
||
export const useVuuFeatures = ({ | ||
features, | ||
staticFeatures, | ||
}: FeaturesHookProps): [ | ||
FeatureProps[], | ||
FeatureProps<FilterTableFeatureProps>[], | ||
StaticFeatureDescriptor[] | undefined | ||
] => { | ||
const tables = useVuuTables(); | ||
const [customFeatures, tableFeatures, staticCustomFeatures] = useMemo< | ||
[ | ||
FeatureProps[], | ||
FeatureProps<FilterTableFeatureProps>[], | ||
StaticFeatureDescriptor[] | undefined | ||
] | ||
>( | ||
() => | ||
tables | ||
? getCustomAndTableFeatures(features, tables, staticFeatures) | ||
: NO_FEATURES, | ||
[features, staticFeatures, tables] | ||
); | ||
// export const useVuuFeatures = ({ | ||
// dynamicFeatures: features, | ||
// }: FeaturesHookProps): FeatureContextProps => { | ||
// const tables = useVuuTables(); | ||
// const { vuuFeatures, vuuTableFeatures } = useMemo<{ | ||
// vuuFeatures: FeatureProps[]; | ||
// vuuTableFeatures: FeatureProps<FilterTableFeatureProps>[]; | ||
// }>( | ||
// () => (tables ? getCustomAndTableFeatures(features, tables) : NO_FEATURES), | ||
// [features, tables] | ||
// ); | ||
|
||
return [customFeatures, tableFeatures, staticCustomFeatures]; | ||
}; | ||
// return { | ||
// dynamicFeatures: vuuFeatures, | ||
// tableFeatures: vuuTableFeatures, | ||
// }; | ||
// }; | ||
|
||
// const vuuTables = useVuuTables(); | ||
// console.log("vuutable: ", vuuTables); | ||
// const { vuuFeatures, vuuTableFeatures } = useMemo<{ | ||
// vuuFeatures: FeatureProps[]; | ||
// vuuTableFeatures: FeatureProps<FilterTableFeatureProps>[]; | ||
// }>(() => { | ||
// console.log("vuutable"); | ||
// const a = vuuTables | ||
// ? getCustomAndTableFeatures(features, vuuTables) | ||
// : NO_FEATURES_VUU; | ||
// return a; | ||
// }, [features, vuuTables]); | ||
// console.log("vuuFeature: ", vuuFeatures); | ||
// console.log("table: ", vuuTableFeatures); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.