@ahoo-wang/fetcher-viewer 3.8.9 → 3.9.2

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.
@@ -1,9 +1,132 @@
1
1
  import { View } from '../types';
2
+ /**
3
+ * Props for the ViewItemGroup component.
4
+ *
5
+ * @interface ViewItemGroupProps
6
+ */
2
7
  export interface ViewItemGroupProps {
8
+ /** Array of view configurations to display in the group */
3
9
  views: View[];
10
+ /** The currently active/selected view */
4
11
  activeView: View;
12
+ /** API endpoint URL for fetching record counts for each view */
5
13
  countUrl: string;
14
+ /** Callback function called when a view is selected/clicked */
6
15
  onViewChange: (view: View) => void;
7
16
  }
17
+ /**
18
+ * ViewItemGroup Component
19
+ *
20
+ * A container component that displays a vertical list of view items, allowing users to
21
+ * switch between different views. Each view item shows the view name, system tag (if applicable),
22
+ * and record count. The component handles click events to change the active view and
23
+ * provides visual feedback for the currently selected view.
24
+ *
25
+ * @param props - The properties for configuring the view item group
26
+ * @param props.views - Array of view objects to display as selectable items
27
+ * @param props.activeView - The currently active view (used for visual highlighting)
28
+ * @param props.countUrl - API endpoint for fetching record counts for each view
29
+ * @param props.onViewChange - Callback fired when user clicks on a different view
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * import { ViewItemGroup } from './ViewItemGroup';
34
+ * import type { View } from '../types';
35
+ *
36
+ * const views: View[] = [
37
+ * {
38
+ * id: 'all-users',
39
+ * name: 'All Users',
40
+ * viewType: 'PUBLIC',
41
+ * viewSource: 'CUSTOM',
42
+ * isDefault: true,
43
+ * filters: [],
44
+ * columns: [
45
+ * { dataIndex: 'id', fixed: false, visible: true },
46
+ * { dataIndex: 'name', fixed: false, visible: true },
47
+ * { dataIndex: 'email', fixed: false, visible: true }
48
+ * ],
49
+ * tableSize: 'middle',
50
+ * condition: {},
51
+ * pageSize: 20,
52
+ * sortId: 1
53
+ * },
54
+ * {
55
+ * id: 'active-users',
56
+ * name: 'Active Users',
57
+ * viewType: 'PERSONAL',
58
+ * viewSource: 'CUSTOM',
59
+ * isDefault: false,
60
+ * filters: [],
61
+ * columns: [
62
+ * { dataIndex: 'id', fixed: false, visible: true },
63
+ * { dataIndex: 'name', fixed: false, visible: true },
64
+ * { dataIndex: 'status', fixed: false, visible: true }
65
+ * ],
66
+ * tableSize: 'middle',
67
+ * condition: { status: 'active' },
68
+ * pageSize: 20,
69
+ * sortId: 2
70
+ * },
71
+ * {
72
+ * id: 'admin-users',
73
+ * name: 'Admin Users',
74
+ * viewType: 'PUBLIC',
75
+ * viewSource: 'SYSTEM',
76
+ * isDefault: false,
77
+ * filters: [],
78
+ * columns: [
79
+ * { dataIndex: 'id', fixed: false, visible: true },
80
+ * { dataIndex: 'name', fixed: false, visible: true },
81
+ * { dataIndex: 'role', fixed: false, visible: true }
82
+ * ],
83
+ * tableSize: 'middle',
84
+ * condition: { role: 'admin' },
85
+ * pageSize: 10,
86
+ * sortId: 3
87
+ * }
88
+ * ];
89
+ *
90
+ * function ViewSelector() {
91
+ * const [activeView, setActiveView] = useState(views[0]);
92
+ *
93
+ * const handleViewChange = (view: View) => {
94
+ * setActiveView(view);
95
+ * // Update table data, filters, etc. based on new view
96
+ * console.log('Switched to view:', view.name);
97
+ * };
98
+ *
99
+ * return (
100
+ * <ViewItemGroup
101
+ * views={views}
102
+ * activeView={activeView}
103
+ * countUrl="/api/users/count"
104
+ * onViewChange={handleViewChange}
105
+ * />
106
+ * );
107
+ * }
108
+ * ```
109
+ *
110
+ * @example
111
+ * ```tsx
112
+ * // Integration with data fetching
113
+ * function ViewPanel({ views, onViewSelect }) {
114
+ * return (
115
+ * <div className="view-panel">
116
+ * <h3>Available Views</h3>
117
+ * <ViewItemGroup
118
+ * views={views}
119
+ * activeView={views.find(v => v.isDefault) || views[0]}
120
+ * countUrl="/api/records/count"
121
+ * onViewChange={(view) => {
122
+ * onViewSelect(view);
123
+ * // Could trigger data refetch with new view's condition
124
+ * }}
125
+ * />
126
+ * </div>
127
+ * );
128
+ * }
129
+ * ```
130
+ */
8
131
  export declare function ViewItemGroup(props: ViewItemGroupProps): import("react/jsx-runtime").JSX.Element;
9
132
  //# sourceMappingURL=ViewItemGroup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ViewItemGroup.d.ts","sourceRoot":"","sources":["../../../src/viewer/panel/ViewItemGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAgBtD"}
1
+ {"version":3,"file":"ViewItemGroup.d.ts","sourceRoot":"","sources":["../../../src/viewer/panel/ViewItemGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,yCAAyC;IACzC,UAAU,EAAE,IAAI,CAAC;IACjB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiHG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAoBtD"}
@@ -1,12 +1,158 @@
1
1
  import { View } from '../types';
2
+ /**
3
+ * Props for the ViewPanel component.
4
+ *
5
+ * @interface ViewPanelProps
6
+ */
2
7
  export interface ViewPanelProps {
8
+ /** Name of the aggregate/entity being viewed (displayed as panel title) */
3
9
  aggregateName: string;
10
+ /** Array of all available views (both personal and public) */
4
11
  views: View[];
12
+ /** The currently active/selected view */
5
13
  activeView: View;
14
+ /** API endpoint URL for fetching record counts for views */
6
15
  countUrl: string;
16
+ /** Callback function called when user selects a different view */
7
17
  onViewChange: (view: View) => void;
18
+ /** Whether the view panel is currently visible (used for fold/unfold logic) */
8
19
  showViewPanel: boolean;
20
+ /** Callback function called when user clicks the fold/unfold button */
9
21
  onViewPanelFold: () => void;
10
22
  }
23
+ /**
24
+ * ViewPanel Component
25
+ *
26
+ * A comprehensive panel component that organizes and displays data views in a collapsible,
27
+ * categorized interface. Views are separated into "Personal" (个人) and "Public" (公共)
28
+ * sections, allowing users to easily manage their own views while accessing shared ones.
29
+ * The panel includes a header with the aggregate name and a fold/unfold control.
30
+ *
31
+ * @param props - The properties for configuring the view panel
32
+ * @param props.aggregateName - Display name for the data entity being viewed
33
+ * @param props.views - Complete array of available views (mixed personal/public)
34
+ * @param props.activeView - Currently selected view for highlighting
35
+ * @param props.countUrl - API endpoint for fetching view record counts
36
+ * @param props.onViewChange - Callback when user selects a different view
37
+ * @param props.showViewPanel - Current visibility state of the panel
38
+ * @param props.onViewPanelFold - Callback when user toggles panel visibility
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { ViewPanel } from './ViewPanel';
43
+ * import type { View } from '../types';
44
+ *
45
+ * const userViews: View[] = [
46
+ * {
47
+ * id: 'personal-1',
48
+ * name: 'My Active Users',
49
+ * viewType: 'PERSONAL',
50
+ * viewSource: 'CUSTOM',
51
+ * isDefault: false,
52
+ * filters: [],
53
+ * columns: [
54
+ * { dataIndex: 'id', fixed: false, visible: true },
55
+ * { dataIndex: 'name', fixed: false, visible: true },
56
+ * { dataIndex: 'status', fixed: false, visible: true }
57
+ * ],
58
+ * tableSize: 'middle',
59
+ * condition: { status: 'active' },
60
+ * pageSize: 20,
61
+ * sortId: 1
62
+ * },
63
+ * {
64
+ * id: 'public-1',
65
+ * name: 'All Team Members',
66
+ * viewType: 'SHARED',
67
+ * viewSource: 'CUSTOM',
68
+ * isDefault: true,
69
+ * filters: [],
70
+ * columns: [
71
+ * { dataIndex: 'id', fixed: false, visible: true },
72
+ * { dataIndex: 'name', fixed: false, visible: true },
73
+ * { dataIndex: 'department', fixed: false, visible: true }
74
+ * ],
75
+ * tableSize: 'middle',
76
+ * condition: {},
77
+ * pageSize: 25,
78
+ * sortId: 2
79
+ * },
80
+ * {
81
+ * id: 'system-1',
82
+ * name: 'Admin Users',
83
+ * viewType: 'SHARED',
84
+ * viewSource: 'SYSTEM',
85
+ * isDefault: false,
86
+ * filters: [],
87
+ * columns: [
88
+ * { dataIndex: 'id', fixed: false, visible: true },
89
+ * { dataIndex: 'name', fixed: false, visible: true },
90
+ * { dataIndex: 'role', fixed: false, visible: true }
91
+ * ],
92
+ * tableSize: 'middle',
93
+ * condition: { role: 'admin' },
94
+ * pageSize: 10,
95
+ * sortId: 3
96
+ * }
97
+ * ];
98
+ *
99
+ * function DataViewer() {
100
+ * const [activeView, setActiveView] = useState(userViews[1]); // Default to public view
101
+ * const [showPanel, setShowPanel] = useState(true);
102
+ *
103
+ * const handleViewChange = (view: View) => {
104
+ * setActiveView(view);
105
+ * // Update table data, filters, sorting based on new view
106
+ * console.log('Switched to view:', view.name);
107
+ * };
108
+ *
109
+ * const handlePanelToggle = () => {
110
+ * setShowPanel(!showPanel);
111
+ * };
112
+ *
113
+ * return (
114
+ * <div className="data-viewer">
115
+ * <ViewPanel
116
+ * aggregateName="用户管理" // "User Management" in Chinese
117
+ * views={userViews}
118
+ * activeView={activeView}
119
+ * countUrl="/api/users/count"
120
+ * onViewChange={handleViewChange}
121
+ * showViewPanel={showPanel}
122
+ * onViewPanelFold={handlePanelToggle}
123
+ * />
124
+ * </div>
125
+ * );
126
+ * }
127
+ * </div>
128
+ * );
129
+ * }
130
+ * ```
131
+ *
132
+ * @example
133
+ * ```tsx
134
+ * // Integration with routing and URL state
135
+ * function RoutedViewPanel({ views, currentViewId }) {
136
+ * const activeView = views.find(v => v.id === currentViewId) || views[0];
137
+ *
138
+ * const handleViewChange = (view: View) => {
139
+ * // Update URL with new view ID
140
+ * navigate(`/data?view=${view.id}`);
141
+ * };
142
+ *
143
+ * return (
144
+ * <ViewPanel
145
+ * aggregateName="数据视图"
146
+ * views={views}
147
+ * activeView={activeView}
148
+ * countUrl="/api/records/count"
149
+ * onViewChange={handleViewChange}
150
+ * showViewPanel={true}
151
+ * onViewPanelFold={() => handlePanelToggle()}
152
+ * />
153
+ * );
154
+ * }
155
+ * ```
156
+ */
11
157
  export declare function ViewPanel(props: ViewPanelProps): import("react/jsx-runtime").JSX.Element;
12
158
  //# sourceMappingURL=ViewPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ViewPanel.d.ts","sourceRoot":"","sources":["../../../src/viewer/panel/ViewPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEnC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CAiD9C"}
1
+ {"version":3,"file":"ViewPanel.d.ts","sourceRoot":"","sources":["../../../src/viewer/panel/ViewPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,yCAAyC;IACzC,UAAU,EAAE,IAAI,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEnC,+EAA+E;IAC/E,aAAa,EAAE,OAAO,CAAC;IACvB,uEAAuE;IACvE,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CAkE9C"}
@@ -3,34 +3,34 @@ import { TypeCapable } from '../registry';
3
3
  import { AttributesCapable } from '../types';
4
4
  import { SortOrder } from 'antd/es/table/interface';
5
5
  import { SizeType } from 'antd/es/config-provider/SizeContext';
6
- import { Condition, FieldSort } from '@ahoo-wang/fetcher-wow';
6
+ import { Condition, FieldSort, PagedQuery } from '@ahoo-wang/fetcher-wow';
7
7
  import { default as React } from 'react';
8
8
  import { ButtonProps } from 'antd';
9
+ import { NamedCapable } from '@ahoo-wang/fetcher';
9
10
  export interface ViewDefinition {
10
11
  name: string;
11
- columns: ViewColumnDefinition[];
12
+ fields: ViewColumnDefinition[];
12
13
  availableFilters: AvailableFilterGroup[];
13
- dataSourceUrl: string;
14
+ dataUrl: string;
14
15
  countUrl: string;
15
16
  internalCondition?: Condition;
16
17
  checkable?: boolean;
17
18
  }
18
- export interface ViewColumnDefinition extends TypeCapable, AttributesCapable {
19
- title: string;
20
- dataIndex: string;
19
+ export interface ViewColumnDefinition extends NamedCapable, TypeCapable, AttributesCapable {
20
+ label: string;
21
21
  primaryKey: boolean;
22
22
  render?: (value: any, record: any, index: number) => React.ReactNode;
23
23
  sorter: boolean | {
24
24
  multiple: number;
25
25
  };
26
26
  }
27
- export type ViewType = 'PERSONAL' | 'PUBLIC';
27
+ export type ViewType = 'PERSONAL' | 'SHARED';
28
28
  export type ViewSource = 'SYSTEM' | 'CUSTOM';
29
29
  export interface View {
30
30
  id: string;
31
31
  name: string;
32
- viewType: ViewType;
33
- viewSource: ViewSource;
32
+ type: ViewType;
33
+ source: ViewSource;
34
34
  isDefault: boolean;
35
35
  filters: ActiveFilter[];
36
36
  columns: ViewColumn[];
@@ -39,9 +39,9 @@ export interface View {
39
39
  pageSize: number;
40
40
  sort?: FieldSort[];
41
41
  sortId: number;
42
+ pagedQuery: PagedQuery;
42
43
  }
43
- export interface ViewColumn {
44
- dataIndex: string;
44
+ export interface ViewColumn extends NamedCapable {
45
45
  fixed: boolean;
46
46
  visible: boolean;
47
47
  width?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/viewer/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;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Filter } from '../filter/panel';
2
2
  import { ReducerActionCapable } from '../types';
3
3
  import { Condition } from '@ahoo-wang/fetcher-wow';
4
+ /**
5
+ * Filter State Interface
6
+ *
7
+ * Represents the complete state of the filter system including active filters,
8
+ * query conditions, and UI panel visibility.
9
+ */
4
10
  export interface FilterState {
11
+ /** Array of currently active filters applied to the data */
5
12
  activeFilters: ActiveFilter[];
13
+ /** Query condition object used for data filtering */
6
14
  queryCondition: Condition;
15
+ /** Whether the filter panel is currently visible */
7
16
  showFilterPanel: boolean;
8
17
  }
18
+ /**
19
+ * Filter State Reducer Action Types
20
+ *
21
+ * Defines the available actions that can be dispatched to update filter state.
22
+ */
9
23
  export type FilterStateReducerActionType = 'UPDATE_ACTIVE_FILTERS' | 'UPDATE_SHOW_FILTER_PANEL' | 'UPDATE_QUERY_CONDITION';
24
+ /**
25
+ * Filter State Reducer Action Interface
26
+ *
27
+ * Extends the base reducer action interface with filter-specific action types.
28
+ */
10
29
  export interface FilterStateReducerAction extends ReducerActionCapable<FilterStateReducerActionType> {
11
30
  }
31
+ /**
32
+ * Filter State Reducer Return Interface
33
+ *
34
+ * Defines the return type of the useFilterStateReducer hook, providing
35
+ * access to current state and state update functions.
36
+ */
12
37
  export interface FilterStateReducerReturn {
38
+ /** Current array of active filters */
13
39
  activeFilters: ActiveFilter[];
40
+ /** Current filter panel visibility state */
14
41
  showFilterPanel: boolean;
42
+ /** Current query condition for data filtering */
15
43
  queryCondition: Condition;
44
+ /** Function to update the active filters array */
16
45
  updateActiveFilters: (activeFilters: ActiveFilter[]) => void;
46
+ /** Function to show/hide the filter panel */
17
47
  updateShowFilterPanel: (showFilterPanel: boolean) => void;
48
+ /** Function to update the query condition */
18
49
  updateQueryCondition: (condition: Condition) => void;
19
50
  }
51
+ /**
52
+ * Filter State Reducer Hook
53
+ *
54
+ * Custom React hook that provides filter state management using useReducer.
55
+ * Manages active filters, query conditions, and filter panel visibility with
56
+ * optimized callback functions for performance.
57
+ *
58
+ * @param state - Initial filter state configuration
59
+ * @param state.activeFilters - Initial array of active filters
60
+ * @param state.queryCondition - Initial query condition
61
+ * @param state.showFilterPanel - Initial filter panel visibility
62
+ * @returns Filter state management interface with current state and update functions
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * import { useFilterStateReducer } from './useFilterStateReducer';
67
+ * import type { ActiveFilter } from '../filter';
68
+ * import type { Condition } from '@ahoo-wang/fetcher-wow';
69
+ *
70
+ * function FilterableComponent() {
71
+ * const filterState = useFilterStateReducer({
72
+ * activeFilters: [],
73
+ * queryCondition: {},
74
+ * showFilterPanel: false
75
+ * });
76
+ *
77
+ * const {
78
+ * activeFilters,
79
+ * showFilterPanel,
80
+ * queryCondition,
81
+ * updateActiveFilters,
82
+ * updateShowFilterPanel,
83
+ * updateQueryCondition
84
+ * } = filterState;
85
+ *
86
+ * const handleAddFilter = (newFilter: ActiveFilter) => {
87
+ * updateActiveFilters([...activeFilters, newFilter]);
88
+ * };
89
+ *
90
+ * const handleTogglePanel = () => {
91
+ * updateShowFilterPanel(!showFilterPanel);
92
+ * };
93
+ *
94
+ * const handleConditionChange = (newCondition: Condition) => {
95
+ * updateQueryCondition(newCondition);
96
+ * };
97
+ *
98
+ * return (
99
+ * <div>
100
+ * <button onClick={handleTogglePanel}>
101
+ * {showFilterPanel ? 'Hide' : 'Show'} Filters
102
+ * </button>
103
+ * <FilterPanel
104
+ * filters={activeFilters}
105
+ * onChange={updateActiveFilters}
106
+ * visible={showFilterPanel}
107
+ * />
108
+ * <DataTable
109
+ * condition={queryCondition}
110
+ * onConditionChange={handleConditionChange}
111
+ * />
112
+ * </div>
113
+ * );
114
+ * }
115
+ * ```
116
+ *
117
+ * @example
118
+ * ```tsx
119
+ * // Integration with Viewer component
120
+ * function DataViewer({ viewDefinition }) {
121
+ * const filterState = useFilterStateReducer({
122
+ * activeFilters: viewDefinition.filters || [],
123
+ * queryCondition: viewDefinition.condition || {},
124
+ * showFilterPanel: false
125
+ * });
126
+ *
127
+ * // Use filter state in Viewer
128
+ * return (
129
+ * <FilterStateContextProvider {...filterState}>
130
+ * <Viewer definition={viewDefinition} />
131
+ * </FilterStateContextProvider>
132
+ * );
133
+ * }
134
+ * ```
135
+ *
136
+ * @example
137
+ * ```tsx
138
+ * // Advanced filter management
139
+ * function AdvancedFilterManager() {
140
+ * const filterState = useFilterStateReducer({
141
+ * activeFilters: [],
142
+ * queryCondition: {},
143
+ * showFilterPanel: true
144
+ * });
145
+ *
146
+ * const clearAllFilters = useCallback(() => {
147
+ * filterState.updateActiveFilters([]);
148
+ * filterState.updateQueryCondition({});
149
+ * }, [filterState]);
150
+ *
151
+ * const hasActiveFilters = filterState.activeFilters.length > 0;
152
+ *
153
+ * return (
154
+ * <div>
155
+ * <FilterControls
156
+ * filters={filterState.activeFilters}
157
+ * onChange={filterState.updateActiveFilters}
158
+ * visible={filterState.showFilterPanel}
159
+ * onToggle={filterState.updateShowFilterPanel}
160
+ * />
161
+ * {hasActiveFilters && (
162
+ * <button onClick={clearAllFilters}>
163
+ * Clear All Filters ({filterState.activeFilters.length})
164
+ * </button>
165
+ * )}
166
+ * </div>
167
+ * );
168
+ * }
169
+ * ```
170
+ */
20
171
  export declare function useFilterStateReducer(state: FilterState): FilterStateReducerReturn;
21
172
  //# sourceMappingURL=useFilterStateReducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFilterStateReducer.d.ts","sourceRoot":"","sources":["../../src/viewer/useFilterStateReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,cAAc,EAAE,SAAS,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,4BAA4B,GACpC,uBAAuB,GAC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