asasvirtuais 2.4.2 → 2.5.1
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 +82 -84
- package/packages/react-interface.tsx +14 -9
package/package.json
CHANGED
|
@@ -1,85 +1,83 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "asasvirtuais",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "2.
|
|
5
|
-
"description": "React form and action management utilities",
|
|
6
|
-
"directories": {
|
|
7
|
-
"packages": "./packages"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"dev": "next dev"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"packages",
|
|
14
|
-
"tsconfig.json"
|
|
15
|
-
],
|
|
16
|
-
"exports": {
|
|
17
|
-
"./package.json": "./package.json",
|
|
18
|
-
"./auth0": {
|
|
19
|
-
"types": "./packages/auth0.ts",
|
|
20
|
-
"default": "./packages/auth0.ts"
|
|
21
|
-
},
|
|
22
|
-
"./action": {
|
|
23
|
-
"types": "./packages/action.tsx",
|
|
24
|
-
"default": "./packages/action.tsx"
|
|
25
|
-
},
|
|
26
|
-
"./fields": {
|
|
27
|
-
"types": "./packages/fields.tsx",
|
|
28
|
-
"default": "./packages/fields.tsx"
|
|
29
|
-
},
|
|
30
|
-
"./form": {
|
|
31
|
-
"types": "./packages/form.tsx",
|
|
32
|
-
"default": "./packages/form.tsx"
|
|
33
|
-
},
|
|
34
|
-
"./hooks": {
|
|
35
|
-
"types": "./packages/hooks.tsx",
|
|
36
|
-
"default": "./packages/hooks.tsx"
|
|
37
|
-
},
|
|
38
|
-
"./interface": {
|
|
39
|
-
"types": "./packages/interface.ts",
|
|
40
|
-
"default": "./packages/interface.ts"
|
|
41
|
-
},
|
|
42
|
-
"./react-interface": {
|
|
43
|
-
"types": "./packages/react-interface.tsx",
|
|
44
|
-
"default": "./packages/react-interface.tsx"
|
|
45
|
-
},
|
|
46
|
-
"./next-interface": {
|
|
47
|
-
"types": "./packages/next-interface.tsx",
|
|
48
|
-
"default": "./packages/next-interface.tsx"
|
|
49
|
-
},
|
|
50
|
-
"./fetch-interface": {
|
|
51
|
-
"types": "./packages/fetch-interface.tsx",
|
|
52
|
-
"default": "./packages/fetch-interface.tsx"
|
|
53
|
-
},
|
|
54
|
-
"./interface-provider": {
|
|
55
|
-
"types": "./packages/interface-provider.tsx",
|
|
56
|
-
"default": "./packages/interface-provider.tsx"
|
|
57
|
-
},
|
|
58
|
-
"./mem-interface": {
|
|
59
|
-
"types": "./packages/mem-interface.tsx",
|
|
60
|
-
"default": "./packages/mem-interface.tsx"
|
|
61
|
-
},
|
|
62
|
-
"./indexed-interface": {
|
|
63
|
-
"types": "./packages/indexed-interface.tsx",
|
|
64
|
-
"default": "./packages/indexed-interface.tsx"
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"@types/
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
"typescript": "^5.9.3"
|
|
84
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "asasvirtuais",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.5.1",
|
|
5
|
+
"description": "React form and action management utilities",
|
|
6
|
+
"directories": {
|
|
7
|
+
"packages": "./packages"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "next dev"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"packages",
|
|
14
|
+
"tsconfig.json"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./auth0": {
|
|
19
|
+
"types": "./packages/auth0.ts",
|
|
20
|
+
"default": "./packages/auth0.ts"
|
|
21
|
+
},
|
|
22
|
+
"./action": {
|
|
23
|
+
"types": "./packages/action.tsx",
|
|
24
|
+
"default": "./packages/action.tsx"
|
|
25
|
+
},
|
|
26
|
+
"./fields": {
|
|
27
|
+
"types": "./packages/fields.tsx",
|
|
28
|
+
"default": "./packages/fields.tsx"
|
|
29
|
+
},
|
|
30
|
+
"./form": {
|
|
31
|
+
"types": "./packages/form.tsx",
|
|
32
|
+
"default": "./packages/form.tsx"
|
|
33
|
+
},
|
|
34
|
+
"./hooks": {
|
|
35
|
+
"types": "./packages/hooks.tsx",
|
|
36
|
+
"default": "./packages/hooks.tsx"
|
|
37
|
+
},
|
|
38
|
+
"./interface": {
|
|
39
|
+
"types": "./packages/interface.ts",
|
|
40
|
+
"default": "./packages/interface.ts"
|
|
41
|
+
},
|
|
42
|
+
"./react-interface": {
|
|
43
|
+
"types": "./packages/react-interface.tsx",
|
|
44
|
+
"default": "./packages/react-interface.tsx"
|
|
45
|
+
},
|
|
46
|
+
"./next-interface": {
|
|
47
|
+
"types": "./packages/next-interface.tsx",
|
|
48
|
+
"default": "./packages/next-interface.tsx"
|
|
49
|
+
},
|
|
50
|
+
"./fetch-interface": {
|
|
51
|
+
"types": "./packages/fetch-interface.tsx",
|
|
52
|
+
"default": "./packages/fetch-interface.tsx"
|
|
53
|
+
},
|
|
54
|
+
"./interface-provider": {
|
|
55
|
+
"types": "./packages/interface-provider.tsx",
|
|
56
|
+
"default": "./packages/interface-provider.tsx"
|
|
57
|
+
},
|
|
58
|
+
"./mem-interface": {
|
|
59
|
+
"types": "./packages/mem-interface.tsx",
|
|
60
|
+
"default": "./packages/mem-interface.tsx"
|
|
61
|
+
},
|
|
62
|
+
"./indexed-interface": {
|
|
63
|
+
"types": "./packages/indexed-interface.tsx",
|
|
64
|
+
"default": "./packages/indexed-interface.tsx"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"react": "^19.2.3",
|
|
68
|
+
"dexie": "^4.3.0",
|
|
69
|
+
"next": "^16.1.6",
|
|
70
|
+
"next-themes": "^0.4.6",
|
|
71
|
+
"react-icons": "^5.5.0",
|
|
72
|
+
"@auth0/nextjs-auth0": "^4.15.0",
|
|
73
|
+
"@chakra-ui/react": "^3.33.0",
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"zod": "^4.3.6"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/node": "^25.3.0",
|
|
79
|
+
"@types/react": "^19.2.14",
|
|
80
|
+
"@types/react-dom": "^19.2.3",
|
|
81
|
+
"typescript": "^5.9.3"
|
|
82
|
+
}
|
|
85
83
|
}
|
|
@@ -289,15 +289,14 @@ export function useSingleProvider<TSchema extends TableSchema>({
|
|
|
289
289
|
}, [index[id]])
|
|
290
290
|
return {
|
|
291
291
|
id,
|
|
292
|
+
table,
|
|
292
293
|
single,
|
|
293
294
|
setSingle,
|
|
294
295
|
loading: find.loading,
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
|
|
299
|
-
ReturnType<typeof useSingleProvider> | undefined
|
|
300
|
-
>(undefined)
|
|
299
|
+
const SingleRegistryContext = createContext<Record<string, ReturnType<typeof useSingleProvider<any>>> | undefined>(undefined)
|
|
301
300
|
|
|
302
301
|
export function SingleProvider<TSchema extends TableSchema>({
|
|
303
302
|
children,
|
|
@@ -310,20 +309,26 @@ export function SingleProvider<TSchema extends TableSchema>({
|
|
|
310
309
|
nullIfNotFound?: boolean
|
|
311
310
|
}) {
|
|
312
311
|
const value = useSingleProvider<TSchema>(props)
|
|
312
|
+
const registry = useContext(SingleRegistryContext) ?? {}
|
|
313
|
+
|
|
314
|
+
const newRegistry = useMemo(() => {
|
|
315
|
+
return { ...registry, [props.table]: value }
|
|
316
|
+
}, [registry, props.table, value])
|
|
317
|
+
|
|
313
318
|
if (props.nullIfNotFound && !value.single) return null
|
|
314
319
|
return (
|
|
315
|
-
|
|
316
|
-
<SingleContext.Provider value={value}>
|
|
320
|
+
<SingleRegistryContext.Provider value={newRegistry}>
|
|
317
321
|
{typeof children === 'function' ? (
|
|
318
322
|
children(value)
|
|
319
323
|
) : (
|
|
320
324
|
children
|
|
321
325
|
)}
|
|
322
|
-
</
|
|
326
|
+
</SingleRegistryContext.Provider>
|
|
323
327
|
)
|
|
324
328
|
}
|
|
325
329
|
|
|
326
|
-
export function useSingle<TSchema extends TableSchema>() {
|
|
327
|
-
|
|
328
|
-
|
|
330
|
+
export function useSingle<TSchema extends TableSchema>(table: string, _schema: TSchema) {
|
|
331
|
+
const registry = useContext(SingleRegistryContext)
|
|
332
|
+
if (!registry || !registry[table]) throw new Error(`useSingle("${table}") must be used within a SingleProvider for that table.`)
|
|
333
|
+
return registry[table] as ReturnType<typeof useSingleProvider<TSchema>>
|
|
329
334
|
}
|