@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.
- package/dist/index.es.js +1515 -1550
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/table/ViewTable.d.ts +1 -1
- package/dist/viewer/FilterStateContext.d.ts +156 -0
- package/dist/viewer/FilterStateContext.d.ts.map +1 -1
- package/dist/viewer/TableStateContext.d.ts +198 -0
- package/dist/viewer/TableStateContext.d.ts.map +1 -1
- package/dist/viewer/Viewer.d.ts +130 -0
- package/dist/viewer/Viewer.d.ts.map +1 -1
- package/dist/viewer/index.d.ts +0 -1
- package/dist/viewer/index.d.ts.map +1 -1
- package/dist/viewer/panel/ViewItem.d.ts +80 -0
- package/dist/viewer/panel/ViewItem.d.ts.map +1 -1
- package/dist/viewer/panel/ViewItemGroup.d.ts +123 -0
- package/dist/viewer/panel/ViewItemGroup.d.ts.map +1 -1
- package/dist/viewer/panel/ViewPanel.d.ts +146 -0
- package/dist/viewer/panel/ViewPanel.d.ts.map +1 -1
- package/dist/viewer/types.d.ts +11 -11
- package/dist/viewer/types.d.ts.map +1 -1
- package/dist/viewer/useFilterStateReducer.d.ts +152 -1
- package/dist/viewer/useFilterStateReducer.d.ts.map +1 -1
- package/dist/viewer/useTableStateReducer.d.ts +163 -0
- package/dist/viewer/useTableStateReducer.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/viewer/ViewerSharedValueContext.d.ts +0 -17
- package/dist/viewer/ViewerSharedValueContext.d.ts.map +0 -1
|
@@ -1,18 +1,181 @@
|
|
|
1
1
|
import { ViewColumn } from './types';
|
|
2
2
|
import { ReducerActionCapable } from '../types';
|
|
3
3
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
4
|
+
/**
|
|
5
|
+
* Table State Interface
|
|
6
|
+
*
|
|
7
|
+
* Represents the complete state of the table system including column configurations
|
|
8
|
+
* and table sizing preferences.
|
|
9
|
+
*/
|
|
4
10
|
export interface TableState {
|
|
11
|
+
/** Array of column configurations with visibility, width, and positioning */
|
|
5
12
|
columns: ViewColumn[];
|
|
13
|
+
/** Table size preference (small, middle, large) following Ant Design conventions */
|
|
6
14
|
tableSize: SizeType;
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Table State Reducer Action Types
|
|
18
|
+
*
|
|
19
|
+
* Defines the available actions that can be dispatched to update table state.
|
|
20
|
+
*/
|
|
8
21
|
export type TableStateReducerActionType = 'UPDATE_COLUMNS' | 'UPDATE_TABLE_SIZE';
|
|
22
|
+
/**
|
|
23
|
+
* Table State Reducer Action Interface
|
|
24
|
+
*
|
|
25
|
+
* Extends the base reducer action interface with table-specific action types.
|
|
26
|
+
*/
|
|
9
27
|
export interface TableStateReducerAction extends ReducerActionCapable<TableStateReducerActionType> {
|
|
10
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Table State Reducer Return Interface
|
|
31
|
+
*
|
|
32
|
+
* Defines the return type of the useTableStateReducer hook, providing
|
|
33
|
+
* access to current state and state update functions.
|
|
34
|
+
*/
|
|
11
35
|
export interface UseTableStateReducerReturn {
|
|
36
|
+
/** Current array of column configurations */
|
|
12
37
|
columns: ViewColumn[];
|
|
38
|
+
/** Current table size setting */
|
|
13
39
|
tableSize: SizeType;
|
|
40
|
+
/** Function to update the columns configuration array */
|
|
14
41
|
updateColumns: (columns: ViewColumn[]) => void;
|
|
42
|
+
/** Function to change the table size */
|
|
15
43
|
updateTableSize: (tableSize: SizeType) => void;
|
|
16
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Table State Reducer Hook
|
|
47
|
+
*
|
|
48
|
+
* Custom React hook that provides table state management using useReducer.
|
|
49
|
+
* Manages column configurations and table sizing with optimized callback functions
|
|
50
|
+
* for performance and prevents unnecessary re-renders.
|
|
51
|
+
*
|
|
52
|
+
* @param state - Initial table state configuration
|
|
53
|
+
* @param state.columns - Initial array of column configurations
|
|
54
|
+
* @param state.tableSize - Initial table size preference
|
|
55
|
+
* @returns Table state management interface with current state and update functions
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* import { useTableStateReducer } from './useTableStateReducer';
|
|
60
|
+
* import type { ViewColumn } from './types';
|
|
61
|
+
* import type { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
62
|
+
*
|
|
63
|
+
* function TableManager() {
|
|
64
|
+
* const tableState = useTableStateReducer({
|
|
65
|
+
* columns: [
|
|
66
|
+
* { dataIndex: 'id', fixed: false, visible: true, width: '100px' },
|
|
67
|
+
* { dataIndex: 'name', fixed: false, visible: true, width: '200px' },
|
|
68
|
+
* { dataIndex: 'email', fixed: false, visible: false }
|
|
69
|
+
* ],
|
|
70
|
+
* tableSize: 'middle'
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* const {
|
|
74
|
+
* columns,
|
|
75
|
+
* tableSize,
|
|
76
|
+
* updateColumns,
|
|
77
|
+
* updateTableSize
|
|
78
|
+
* } = tableState;
|
|
79
|
+
*
|
|
80
|
+
* const handleColumnVisibilityChange = (columnId: string, visible: boolean) => {
|
|
81
|
+
* const updatedColumns = columns.map(col =>
|
|
82
|
+
* col.dataIndex === columnId
|
|
83
|
+
* ? { ...col, visible }
|
|
84
|
+
* : col
|
|
85
|
+
* );
|
|
86
|
+
* updateColumns(updatedColumns);
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* const handleSizeChange = (newSize: SizeType) => {
|
|
90
|
+
* updateTableSize(newSize);
|
|
91
|
+
* };
|
|
92
|
+
*
|
|
93
|
+
* return (
|
|
94
|
+
* <div>
|
|
95
|
+
* <TableSizeSelector
|
|
96
|
+
* currentSize={tableSize}
|
|
97
|
+
* onChange={handleSizeChange}
|
|
98
|
+
* />
|
|
99
|
+
* <ColumnManager
|
|
100
|
+
* columns={columns}
|
|
101
|
+
* onVisibilityChange={handleColumnVisibilityChange}
|
|
102
|
+
* />
|
|
103
|
+
* <ViewTable
|
|
104
|
+
* columns={columns}
|
|
105
|
+
* tableSize={tableSize}
|
|
106
|
+
* />
|
|
107
|
+
* </div>
|
|
108
|
+
* );
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* // Integration with Viewer component
|
|
115
|
+
* function DataViewer({ viewDefinition }) {
|
|
116
|
+
* const tableState = useTableStateReducer({
|
|
117
|
+
* columns: viewDefinition.columns,
|
|
118
|
+
* tableSize: viewDefinition.tableSize || 'middle'
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* // Use table state in Viewer
|
|
122
|
+
* return (
|
|
123
|
+
* <TableStateContextProvider
|
|
124
|
+
* columns={tableState.columns}
|
|
125
|
+
* tableSize={tableState.tableSize}
|
|
126
|
+
* updateColumns={tableState.updateColumns}
|
|
127
|
+
* updateTableSize={tableState.updateTableSize}
|
|
128
|
+
* refreshData={() => handleRefresh()}
|
|
129
|
+
* >
|
|
130
|
+
* <Viewer definition={viewDefinition} />
|
|
131
|
+
* </TableStateContextProvider>
|
|
132
|
+
* );
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* // Advanced column management
|
|
139
|
+
* function AdvancedTableController() {
|
|
140
|
+
* const tableState = useTableStateReducer({
|
|
141
|
+
* columns: [],
|
|
142
|
+
* tableSize: 'middle'
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* const addColumn = useCallback((newColumn: ViewColumn) => {
|
|
146
|
+
* tableState.updateColumns([...tableState.columns, newColumn]);
|
|
147
|
+
* }, [tableState]);
|
|
148
|
+
*
|
|
149
|
+
* const removeColumn = useCallback((columnId: string) => {
|
|
150
|
+
* const filteredColumns = tableState.columns.filter(
|
|
151
|
+
* col => col.dataIndex !== columnId
|
|
152
|
+
* );
|
|
153
|
+
* tableState.updateColumns(filteredColumns);
|
|
154
|
+
* }, [tableState]);
|
|
155
|
+
*
|
|
156
|
+
* const reorderColumns = useCallback((fromIndex: number, toIndex: number) => {
|
|
157
|
+
* const newColumns = [...tableState.columns];
|
|
158
|
+
* const [movedColumn] = newColumns.splice(fromIndex, 1);
|
|
159
|
+
* newColumns.splice(toIndex, 0, movedColumn);
|
|
160
|
+
* tableState.updateColumns(newColumns);
|
|
161
|
+
* }, [tableState]);
|
|
162
|
+
*
|
|
163
|
+
* return (
|
|
164
|
+
* <div>
|
|
165
|
+
* <ColumnList
|
|
166
|
+
* columns={tableState.columns}
|
|
167
|
+
* onAdd={addColumn}
|
|
168
|
+
* onRemove={removeColumn}
|
|
169
|
+
* onReorder={reorderColumns}
|
|
170
|
+
* />
|
|
171
|
+
* <TableSizeControls
|
|
172
|
+
* size={tableState.tableSize}
|
|
173
|
+
* onChange={tableState.updateTableSize}
|
|
174
|
+
* />
|
|
175
|
+
* </div>
|
|
176
|
+
* );
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
17
180
|
export declare function useTableStateReducer(state: TableState): UseTableStateReducerReturn;
|
|
18
181
|
//# sourceMappingURL=useTableStateReducer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableStateReducer.d.ts","sourceRoot":"","sources":["../../src/viewer/useTableStateReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE/D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,SAAS,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,2BAA2B,GACnC,gBAAgB,GAChB,mBAAmB,CAAC;AAExB,MAAM,WAAW,uBAAwB,SAAQ,oBAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,UAAU,GAChB,0BAA0B,CA2C5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-viewer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "A comprehensive React component library for API documentation viewing and data filtering, built on top of Ant Design and the Fetcher ecosystem. Provides reusable UI components for building rich data-driven applications with advanced filtering capabilities and remote data selection.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { View } from './types';
|
|
3
|
-
export interface ViewerSharedValue {
|
|
4
|
-
aggregateName: string;
|
|
5
|
-
view: View;
|
|
6
|
-
showFilterPanel: boolean;
|
|
7
|
-
setShowFilterPanel: (showFilterPanel: boolean) => void;
|
|
8
|
-
refreshData: () => void;
|
|
9
|
-
}
|
|
10
|
-
export type ViewerSharedValueContext = ViewerSharedValue;
|
|
11
|
-
export declare const ViewerSharedValueContext: import('react').Context<ViewerSharedValue | undefined>;
|
|
12
|
-
export interface ViewerSharedValueOptions extends ViewerSharedValue {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
export declare function ViewerSharedValueProvider({ children, ...options }: ViewerSharedValueOptions): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare function useViewerSharedValue(): ViewerSharedValueContext;
|
|
17
|
-
//# sourceMappingURL=ViewerSharedValueContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ViewerSharedValueContext.d.ts","sourceRoot":"","sources":["../../src/viewer/ViewerSharedValueContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC;IAEX,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,CAAC,eAAe,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAEzD,eAAO,MAAM,wBAAwB,wDAEzB,CAAC;AAEb,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IACjE,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,EACR,GAAG,OAAO,EACX,EAAE,wBAAwB,2CAM1B;AAED,wBAAgB,oBAAoB,IAAI,wBAAwB,CAM/D"}
|