impact-chatbot 2.3.59 → 2.3.61
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/dist/components/message-template/components/message-content/utils/crossFilterAdapter.d.ts +16 -0
- package/dist/hooks/crossFilterCascading/CrossFilterContext.d.ts +24 -0
- package/dist/hooks/crossFilterCascading/CrossFilterProvider.d.ts +21 -0
- package/dist/hooks/crossFilterCascading/index.d.ts +3 -0
- package/dist/hooks/crossFilterCascading/useCrossFilterCascading.d.ts +46 -0
- package/dist/index.cjs.js +737 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +739 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/components/message-template/components/message-content/utils/crossFilterAdapter.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter function that bridges the generic useCrossFilterCascading hook
|
|
3
|
+
* with the existing cross-filter API used by the chatbot.
|
|
4
|
+
*
|
|
5
|
+
* This is the `fetchOptionsFn` passed to the CrossFilterProvider.
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} filterConfig - The filter config for which to fetch options
|
|
8
|
+
* @param {Array} existingSelections - Upstream filter selections
|
|
9
|
+
* Each item: { filterName, attributeName, values, checkAll }
|
|
10
|
+
* @param {Array} allFilters - Full array of all filter configs
|
|
11
|
+
* @returns {Promise<Array<{label, value}>>} - Formatted options
|
|
12
|
+
*/
|
|
13
|
+
export declare const fetchCrossFilterOptions: (filterConfig: any, existingSelections?: any[], allFilters?: any[]) => Promise<{
|
|
14
|
+
label: any;
|
|
15
|
+
value: string;
|
|
16
|
+
}[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context for cross-filter cascading.
|
|
3
|
+
* Provides cascading state and actions to child select components.
|
|
4
|
+
*
|
|
5
|
+
* Shape:
|
|
6
|
+
* {
|
|
7
|
+
* optionsMap: { paramName: Array<{label, value}> },
|
|
8
|
+
* loadingMap: { paramName: boolean },
|
|
9
|
+
* selectionsMap: { paramName: value[] },
|
|
10
|
+
* onFilterChange: (paramName, selectedValues) => void,
|
|
11
|
+
* resetAll: () => void,
|
|
12
|
+
* resetFilter: (paramName) => void,
|
|
13
|
+
* fetchOptions: (paramName) => void,
|
|
14
|
+
* getParamName: (filterConfig) => string,
|
|
15
|
+
* isEnabled: boolean, // flag to know if cascading is active
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
declare const CrossFilterContext: import("react").Context<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Hook to consume cross-filter cascading context.
|
|
21
|
+
* Returns null if not inside a CrossFilterProvider (graceful fallback).
|
|
22
|
+
*/
|
|
23
|
+
export declare const useCrossFilterContext: () => any;
|
|
24
|
+
export default CrossFilterContext;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider component that wraps a group of select components to enable
|
|
3
|
+
* cross-filter cascading between them.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} props
|
|
6
|
+
* @param {Array} props.filters - Array of filter configs (ordered by hierarchy)
|
|
7
|
+
* @param {Function} props.fetchOptionsFn - Async function to fetch options for a filter
|
|
8
|
+
* @param {Object} props.initialSelections - Optional preloaded selections { paramName: values[] }
|
|
9
|
+
* @param {boolean} props.fetchOnMount - Whether to fetch initial options on mount (default: true)
|
|
10
|
+
* @param {Function} props.onSelectionChange - Optional callback on any filter change
|
|
11
|
+
* @param {React.ReactNode} props.children - Child components (selects) that will consume the context
|
|
12
|
+
*/
|
|
13
|
+
declare const CrossFilterProvider: ({ filters, fetchOptionsFn, initialSelections, fetchOnMount, onSelectionChange, children, }: {
|
|
14
|
+
filters: any;
|
|
15
|
+
fetchOptionsFn: any;
|
|
16
|
+
initialSelections?: {};
|
|
17
|
+
fetchOnMount?: boolean;
|
|
18
|
+
onSelectionChange?: any;
|
|
19
|
+
children: any;
|
|
20
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export default CrossFilterProvider;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic hook for cross-filter cascading functionality.
|
|
3
|
+
* When a filter's value changes, downstream filters' options are re-fetched
|
|
4
|
+
* with the current selections of upstream filters included in the payload.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} config
|
|
7
|
+
* @param {Array} config.filters - Array of filter configs. Each must have at minimum:
|
|
8
|
+
* { paramName, dimension?, column_name?, attribute_name?, display_type?, ... }
|
|
9
|
+
* The order in this array determines the cascading hierarchy (index 0 = most upstream).
|
|
10
|
+
* @param {Function} config.fetchOptionsFn - Async function to fetch options for a filter.
|
|
11
|
+
* Signature: (filterConfig, existingSelections, allFilters) => Promise<Array<{label, value}>>
|
|
12
|
+
* - filterConfig: the config of the filter whose options we're fetching
|
|
13
|
+
* - existingSelections: array of { attributeName, filterName, values, checkAll } for upstream filters
|
|
14
|
+
* - allFilters: the full filters array (for reference/lookup)
|
|
15
|
+
* @param {Object} config.initialSelections - Optional. { paramName: value[] } to preload selections.
|
|
16
|
+
* @param {boolean} config.fetchOnMount - Whether to fetch initial options for all filters on mount. Default: true.
|
|
17
|
+
* @param {Function} config.onSelectionChange - Optional callback fired after any filter value changes.
|
|
18
|
+
* Signature: (paramName, selectedValues, allSelections) => void
|
|
19
|
+
*
|
|
20
|
+
* @returns {Object}
|
|
21
|
+
* - optionsMap: { paramName: Array<{label, value}> } — current available options per filter
|
|
22
|
+
* - loadingMap: { paramName: boolean } — loading state per filter
|
|
23
|
+
* - selectionsMap: { paramName: value[] } — current selections per filter
|
|
24
|
+
* - onFilterChange: (paramName, selectedValues) => void — call when user changes a filter
|
|
25
|
+
* - resetAll: () => void — reset all selections and re-fetch initial options
|
|
26
|
+
* - resetFilter: (paramName) => void — reset a single filter and its downstream filters
|
|
27
|
+
*/
|
|
28
|
+
declare const useCrossFilterCascading: ({ filters, fetchOptionsFn, initialSelections, fetchOnMount, onSelectionChange, }: {
|
|
29
|
+
filters?: any[];
|
|
30
|
+
fetchOptionsFn: any;
|
|
31
|
+
initialSelections?: {};
|
|
32
|
+
fetchOnMount?: boolean;
|
|
33
|
+
onSelectionChange: any;
|
|
34
|
+
}) => {
|
|
35
|
+
optionsMap: {};
|
|
36
|
+
loadingMap: {};
|
|
37
|
+
selectionsMap: {};
|
|
38
|
+
onFilterChange: (paramName: any, selectedValues: any) => void;
|
|
39
|
+
resetAll: () => void;
|
|
40
|
+
resetFilter: (paramName: any) => void;
|
|
41
|
+
fetchOptions: (paramName: any) => void;
|
|
42
|
+
fetchDownstreamOptions: (paramName: any) => void;
|
|
43
|
+
fetchUpstreamOptions: (paramName: any) => void;
|
|
44
|
+
getParamName: (filter: any) => any;
|
|
45
|
+
};
|
|
46
|
+
export default useCrossFilterCascading;
|