@arcote.tech/arc-react 0.1.4 → 0.1.6
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/form/form.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/reactModel.d.ts +2 -2
- package/package.json +1 -1
package/dist/form/form.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type FormProps<T extends ArcObjectAny> = {
|
|
|
22
22
|
schema: T;
|
|
23
23
|
onSubmit: (values: $type<T>) => void | Promise<void>;
|
|
24
24
|
onUnvalidatedSubmit?: (values: Partial<$type<T>>, errors: any) => void;
|
|
25
|
-
defaults?: Partial<$type<T
|
|
25
|
+
defaults?: Partial<$type<T>> | null;
|
|
26
26
|
};
|
|
27
27
|
export declare const FormContext: React.Context<FormContextValue<any> | null>;
|
|
28
28
|
export declare const Form: <T extends ArcObjectAny>(props: FormProps<T> & React.RefAttributes<FormRef<T>>) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -273,7 +273,7 @@ var sqliteWasmAdapterFactory = (db) => {
|
|
|
273
273
|
|
|
274
274
|
// reactModel.tsx
|
|
275
275
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
276
|
-
var reactModel = (
|
|
276
|
+
var reactModel = (arcContext, options) => {
|
|
277
277
|
const LiveModelContext = createContext4(null);
|
|
278
278
|
const LocalModelContext = createContext4(null);
|
|
279
279
|
let masterModel = null;
|
|
@@ -281,10 +281,8 @@ var reactModel = (arcContextPromise, options) => {
|
|
|
281
281
|
function LiveModelProvider(props) {
|
|
282
282
|
const [context, setContext] = useState3(null);
|
|
283
283
|
useEffect2(() => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
});
|
|
287
|
-
}, [arcContextPromise]);
|
|
284
|
+
setContext(arcContext);
|
|
285
|
+
}, [arcContext]);
|
|
288
286
|
useEffect2(() => {
|
|
289
287
|
model?.setAuthToken(props.token);
|
|
290
288
|
}, [props.token]);
|
|
@@ -347,6 +345,7 @@ var reactModel = (arcContextPromise, options) => {
|
|
|
347
345
|
if (!model) {
|
|
348
346
|
throw new Error("useQuery must be used within a ModelProvider");
|
|
349
347
|
}
|
|
348
|
+
const [loading, setLoading] = useState3(true);
|
|
350
349
|
const [result, setResult] = useState3(null);
|
|
351
350
|
const [revalidationTrigger, setRevalidationTrigger] = useState3(0);
|
|
352
351
|
const unsubscribeRef = useRef(null);
|
|
@@ -380,6 +379,7 @@ var reactModel = (arcContextPromise, options) => {
|
|
|
380
379
|
const defaultAuthContext = { userId: "react-user", roles: ["user"] };
|
|
381
380
|
const { unsubscribe, result: result2 } = model.subscribe(queryBuilderFn, (newResult) => {
|
|
382
381
|
setResult(newResult);
|
|
382
|
+
setLoading(false);
|
|
383
383
|
}, defaultAuthContext);
|
|
384
384
|
unsubscribeRef.current = unsubscribe;
|
|
385
385
|
return () => {
|
|
@@ -389,7 +389,7 @@ var reactModel = (arcContextPromise, options) => {
|
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
}, [model, revalidationTrigger, ...dependencies]);
|
|
392
|
-
return [result];
|
|
392
|
+
return [result, loading];
|
|
393
393
|
},
|
|
394
394
|
function useRevalidate() {
|
|
395
395
|
const model = useContext3(LocalModelContext) || useContext3(LiveModelContext);
|
|
@@ -452,4 +452,4 @@ export {
|
|
|
452
452
|
Form
|
|
453
453
|
};
|
|
454
454
|
|
|
455
|
-
//# debugId=
|
|
455
|
+
//# debugId=E1410190A2DE6B7864756E2164756E21
|
package/dist/reactModel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Model, type ArcContextAny, type IArcQueryBuilder, type ModelBase, type QueryBuilderFunctionResult, type QueryFactoryFunction, type UnaryFunction } from "@arcote.tech/arc";
|
|
2
2
|
import type { ArcContextElementMethodReturnType, SQLiteDatabase } from "@arcote.tech/arc";
|
|
3
|
-
export declare const reactModel: <C extends ArcContextAny>(
|
|
3
|
+
export declare const reactModel: <C extends ArcContextAny>(arcContext: C, options: {
|
|
4
4
|
sqliteAdapter: SQLiteDatabase;
|
|
5
5
|
} | {
|
|
6
6
|
remoteUrl: string;
|
|
@@ -17,5 +17,5 @@ export declare const reactModel: <C extends ArcContextAny>(arcContextPromise: Pr
|
|
|
17
17
|
catchErrorCallback: (error: any) => void;
|
|
18
18
|
}) => import("react/jsx-dev-runtime").JSX.Element | null, ({ children }: {
|
|
19
19
|
children: React.ReactNode;
|
|
20
|
-
}) => import("react/jsx-dev-runtime").JSX.Element, <Q extends IArcQueryBuilder>(queryBuilderFn: UnaryFunction<ReturnType<C["queryBuilder"]>, Q>, dependencies?: any[], cacheKey?: string) => [ReturnType<Q["toQuery"]>["lastResult"]], () => (cacheKey: string) => void, () => ArcContextElementMethodReturnType<C["elements"], "commandClient">, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn, model?: ModelBase<C> | null) => Promise<QueryBuilderFunctionResult<QueryBuilderFn>>, () => Model<C> | null, (token: string) => ModelBase<C>];
|
|
20
|
+
}) => import("react/jsx-dev-runtime").JSX.Element, <Q extends IArcQueryBuilder>(queryBuilderFn: UnaryFunction<ReturnType<C["queryBuilder"]>, Q>, dependencies?: any[], cacheKey?: string) => [ReturnType<Q["toQuery"]>["lastResult"], false] | [undefined, true], () => (cacheKey: string) => void, () => ArcContextElementMethodReturnType<C["elements"], "commandClient">, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn, model?: ModelBase<C> | null) => Promise<QueryBuilderFunctionResult<QueryBuilderFn>>, () => Model<C> | null, (token: string) => ModelBase<C>];
|
|
21
21
|
//# sourceMappingURL=reactModel.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
7
7
|
"description": "React client for the Arc framework, providing utilities for querying data and executing commands, enhancing the development of reactive and efficient user interfaces.",
|