asasvirtuais 2.2.6 → 2.2.8
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
CHANGED
|
@@ -186,12 +186,14 @@ export function FilterForm<TSchema extends TableSchema>({
|
|
|
186
186
|
schema,
|
|
187
187
|
table,
|
|
188
188
|
defaults,
|
|
189
|
+
autoTrigger,
|
|
189
190
|
onSuccess,
|
|
190
191
|
children,
|
|
191
192
|
}: {
|
|
192
193
|
schema: TSchema
|
|
193
194
|
table: string
|
|
194
195
|
defaults?: Partial<ListProps<z.infer<TSchema['readable']>>>
|
|
196
|
+
autoTrigger?: boolean
|
|
195
197
|
onSuccess?: (result: z.infer<TSchema['readable']>[]) => void
|
|
196
198
|
children: React.ReactNode | (
|
|
197
199
|
(props: ReturnType<typeof useActionProvider<ListProps<z.infer<TSchema['readable']>>, z.infer<TSchema['readable']>[]>>
|
|
@@ -217,7 +219,7 @@ export function FilterForm<TSchema extends TableSchema>({
|
|
|
217
219
|
defaults={(defaults || { query: {} }) as ListProps<Readable>}
|
|
218
220
|
>
|
|
219
221
|
{fields => (
|
|
220
|
-
<ActionProvider<ListProps<Readable>, Readable[]> action={callback} params={fields.fields}>
|
|
222
|
+
<ActionProvider<ListProps<Readable>, Readable[]> action={callback} params={fields.fields} autoTrigger={autoTrigger}>
|
|
221
223
|
{typeof children === 'function' ? (
|
|
222
224
|
form => children({ ...form, ...fields })
|
|
223
225
|
) : (
|
|
@@ -249,7 +251,7 @@ export function useUpdateForm<TSchema extends TableSchema>(schema: TSchema) {
|
|
|
249
251
|
}
|
|
250
252
|
}
|
|
251
253
|
|
|
252
|
-
export function
|
|
254
|
+
export function useFilterForm<TSchema extends TableSchema>(schema: TSchema) {
|
|
253
255
|
return {
|
|
254
256
|
...useFields<z.infer<TSchema['readable']>>(),
|
|
255
257
|
...useAction<z.infer<TSchema['readable']>,
|
|
@@ -269,16 +271,14 @@ export function useSingleProvider<TSchema extends TableSchema>({
|
|
|
269
271
|
}) {
|
|
270
272
|
const { find, index } = useTable(table, schema)
|
|
271
273
|
const [single, setSingle] = useState<z.infer<TSchema['readable']>>(
|
|
272
|
-
|
|
273
|
-
() => index[table][id]
|
|
274
|
+
() => index[id]
|
|
274
275
|
)
|
|
275
276
|
useEffect(() => {
|
|
276
277
|
if (!single) find.trigger({ id }).then(setSingle)
|
|
277
278
|
}, [])
|
|
278
279
|
useEffect(() => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}, [index[table][id as keyof typeof index]])
|
|
280
|
+
setSingle(index[id])
|
|
281
|
+
}, [index[id]])
|
|
282
282
|
return {
|
|
283
283
|
id,
|
|
284
284
|
single,
|