@contember/bindx-dataview 0.1.5 → 0.1.10
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/package.json +3 -3
- package/src/DataGrid.tsx +7 -7
- package/src/select/SelectDataView.tsx +7 -7
- package/src/useDataView.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/bindx-dataview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Headless DataGrid and DataView components for bindx",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"react": ">=18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@contember/bindx": "0.1.
|
|
19
|
-
"@contember/bindx-react": "0.1.
|
|
18
|
+
"@contember/bindx": "0.1.10",
|
|
19
|
+
"@contember/bindx-react": "0.1.10",
|
|
20
20
|
"@radix-ui/primitive": "^1.1.3",
|
|
21
21
|
"@radix-ui/react-slot": "^1.2.4"
|
|
22
22
|
},
|
package/src/DataGrid.tsx
CHANGED
|
@@ -105,27 +105,27 @@ function DataGridImpl<TRoleMap extends Record<string, object>>({
|
|
|
105
105
|
queryKey: setup.queryKey,
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
-
const items = result
|
|
108
|
+
const items = result.$status === 'ready' ? result.items : []
|
|
109
109
|
const itemCount = items.length
|
|
110
110
|
|
|
111
111
|
// Update loader state
|
|
112
112
|
useEffect(() => {
|
|
113
|
-
if (result
|
|
113
|
+
if (result.$status === 'ready') {
|
|
114
114
|
hasLoadedOnce.current = true
|
|
115
115
|
setLoaderState('loaded')
|
|
116
|
-
} else if (result
|
|
116
|
+
} else if (result.$status === 'error') {
|
|
117
117
|
setLoaderState('failed')
|
|
118
|
-
} else if (result
|
|
118
|
+
} else if (result.$status === 'loading') {
|
|
119
119
|
setLoaderState(hasLoadedOnce.current ? 'refreshing' : 'initial')
|
|
120
120
|
}
|
|
121
|
-
}, [result
|
|
121
|
+
}, [result.$status])
|
|
122
122
|
|
|
123
123
|
// Update total count when data is ready
|
|
124
124
|
useEffect(() => {
|
|
125
|
-
if (result
|
|
125
|
+
if (result.$status === 'ready' && setup.paging.queryLimit !== undefined && setup.paging.queryOffset !== undefined && itemCount < setup.paging.queryLimit) {
|
|
126
126
|
setup.paging.setTotalCount(setup.paging.queryOffset + itemCount)
|
|
127
127
|
}
|
|
128
|
-
}, [result
|
|
128
|
+
}, [result.$status, itemCount, setup.paging.queryLimit, setup.paging.queryOffset, setup.paging.setTotalCount])
|
|
129
129
|
|
|
130
130
|
// ---- Reload ----
|
|
131
131
|
const [, setReloadCounter] = useState(0)
|
|
@@ -162,27 +162,27 @@ function SelectDataViewImpl({
|
|
|
162
162
|
queryKey,
|
|
163
163
|
})
|
|
164
164
|
|
|
165
|
-
const items = result
|
|
165
|
+
const items = result.$status === 'ready' ? result.items : []
|
|
166
166
|
const itemCount = items.length
|
|
167
167
|
|
|
168
168
|
// Update loader state
|
|
169
169
|
useEffect(() => {
|
|
170
|
-
if (result
|
|
170
|
+
if (result.$status === 'ready') {
|
|
171
171
|
hasLoadedOnce.current = true
|
|
172
172
|
setLoaderState('loaded')
|
|
173
|
-
} else if (result
|
|
173
|
+
} else if (result.$status === 'error') {
|
|
174
174
|
setLoaderState('failed')
|
|
175
|
-
} else if (result
|
|
175
|
+
} else if (result.$status === 'loading') {
|
|
176
176
|
setLoaderState(hasLoadedOnce.current ? 'refreshing' : 'initial')
|
|
177
177
|
}
|
|
178
|
-
}, [result
|
|
178
|
+
}, [result.$status])
|
|
179
179
|
|
|
180
180
|
// Update total count for paging
|
|
181
181
|
useEffect(() => {
|
|
182
|
-
if (result
|
|
182
|
+
if (result.$status === 'ready' && paging.queryLimit !== undefined && paging.queryOffset !== undefined && itemCount < paging.queryLimit) {
|
|
183
183
|
paging.setTotalCount(paging.queryOffset + itemCount)
|
|
184
184
|
}
|
|
185
|
-
}, [result
|
|
185
|
+
}, [result.$status, itemCount, paging.queryLimit, paging.queryOffset, paging.setTotalCount])
|
|
186
186
|
|
|
187
187
|
// ---- Reload ----
|
|
188
188
|
const [, setReloadCounter] = useState(0)
|
package/src/useDataView.ts
CHANGED
|
@@ -134,11 +134,11 @@ export function useDataView(
|
|
|
134
134
|
selection,
|
|
135
135
|
})
|
|
136
136
|
|
|
137
|
-
const items = result
|
|
137
|
+
const items = result.$status === 'ready' ? result.items : []
|
|
138
138
|
|
|
139
139
|
return {
|
|
140
|
-
status: result
|
|
141
|
-
error: result
|
|
140
|
+
status: result.$status,
|
|
141
|
+
error: result.$status === 'error' ? result.$error : undefined,
|
|
142
142
|
items,
|
|
143
143
|
filtering,
|
|
144
144
|
sorting,
|