Skip to content

Commit 906cdcb

Browse files
committed
fix: publish new release
1 parent ce09696 commit 906cdcb

File tree

6 files changed

+72
-2959
lines changed

6 files changed

+72
-2959
lines changed

dist/index.cjs.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import * as react_jsx_runtime from 'react/jsx-runtime';
2-
import React from 'react';
1+
import React from "react";
32
import { Config } from 'js-config-helper';
43
import { AxiosInstance } from 'axios';
5-
import { Form } from 'js-form-helper';
4+
import { Form } from "js-form-helper";
65
import i18next, { InitOptions, TFunction } from 'i18next';
7-
8-
interface UpOptions {
6+
export interface UpOptions {
97
debug?: boolean;
108
project?: {
119
name: string;
@@ -26,7 +24,7 @@ interface UpOptions {
2624
loading?: boolean;
2725
setLoading?: (loading: boolean) => void;
2826
}
29-
interface exportedVars {
27+
export interface exportedVars {
3028
config: Config;
3129
api: AxiosInstance;
3230
http: AxiosInstance;
@@ -36,31 +34,29 @@ interface exportedVars {
3634
graphqlClient: any;
3735
t: TFunction;
3836
}
39-
declare let exported: exportedVars | any;
40-
declare let UpInit: boolean;
37+
export declare let exported: exportedVars | any;
38+
export declare let UpInit: boolean;
4139
/**
4240
* Setup
4341
*
4442
* @param options
4543
*/
46-
declare const setUp: (options: UpOptions) => Promise<any>;
44+
export declare const setUp: (options: UpOptions) => Promise<any>;
4745
/**
4846
* useUp helper function
4947
*
5048
*/
51-
declare const useUp: () => exportedVars;
52-
interface Props {
49+
export declare const useUp: () => exportedVars;
50+
export interface Props {
5351
options: UpOptions;
5452
children?: React.ReactNode;
5553
}
56-
declare const UpContext: React.Context<{}>;
54+
export declare const UpContext: React.Context<{}>;
5755
/**
5856
* UpProvider should be wrapped in the early stage of your app
5957
*
6058
* @param options
6159
* @param children
6260
* @constructor
6361
*/
64-
declare function UpProvider({ options, children }: Props): react_jsx_runtime.JSX.Element;
65-
66-
export { type Props, UpContext, UpInit, type UpOptions, UpProvider, exported, type exportedVars, setUp, useUp };
62+
export declare function UpProvider({ options, children }: Props): import("react/jsx-runtime").JSX.Element;

dist/index.es.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { jsx as c, Fragment as w } from "react/jsx-runtime";
2+
import { createContext as b, useState as p, useEffect as y } from "react";
3+
import { Config as C } from "js-config-helper";
4+
import l from "axios";
5+
import { Form as m } from "js-form-helper";
6+
import s from "i18next";
7+
import { initReactI18next as I } from "react-i18next";
8+
let a, u, t, d, U, i, g = !1;
9+
const P = async function(r) {
10+
return t = new C(r), u = t.get("override.http") || l.create(), a = t.get("override") || l.create({
11+
baseURL: t.get("api.url")
12+
}), t.has("exclude.form") || (d = function(n, e) {
13+
return new m(n, {
14+
http: u,
15+
...e
16+
});
17+
}, U = function(n, e) {
18+
return new m(n, {
19+
http: a,
20+
...e
21+
});
22+
}), t.has("exclude.i18n") || r.i18n && await s.use(I).init(r.i18n), i = {
23+
config: t,
24+
api: a,
25+
http: u,
26+
i18n: s,
27+
form: d,
28+
formApi: U,
29+
t: s.t
30+
}, t.has("debug") && console.log("\u2934 useUp() accessible vars :", i), g = !0, i;
31+
}, k = function() {
32+
return g || console.warn("Up is not initialized, you must run setUp() first or add an UpProvider !"), i;
33+
}, F = b({});
34+
function q({ options: o, children: r }) {
35+
const [n, e] = p(!0), [f, x] = p(), h = async () => {
36+
const v = await P({
37+
...o,
38+
loading: n,
39+
setLoading: e
40+
});
41+
x(v), e(!1);
42+
};
43+
return y(() => {
44+
h().then(() => {
45+
o.debug && console.log("Up loaded");
46+
});
47+
}, []), f ? /* @__PURE__ */ c(F.Provider, {
48+
value: f,
49+
children: r
50+
}) : /* @__PURE__ */ c(w, {});
51+
}
52+
export {
53+
F as UpContext,
54+
g as UpInit,
55+
q as UpProvider,
56+
i as exported,
57+
P as setUp,
58+
k as useUp
59+
};

0 commit comments

Comments
 (0)