pytech-ui 1.0.12 → 1.0.14
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/build/contexts/app/context.d.ts +2 -2
- package/build/contexts/app/context.js +3 -3
- package/build/contexts/app/index.d.ts +10 -1
- package/build/contexts/app/index.js +8 -3
- package/build/contexts/app/src/Head/index.d.ts +3 -0
- package/build/contexts/app/src/Head/index.js +3 -0
- package/build/contexts/app/src/Head/index.web.d.ts +3 -0
- package/build/contexts/app/src/Head/index.web.js +29 -0
- package/build/contexts/app/src/Head/types.d.ts +24 -0
- package/build/contexts/app/src/Head/types.js +2 -0
- package/build/contexts/app/src/Loading.d.ts +4 -0
- package/build/contexts/app/src/Loading.js +4 -0
- package/build/contexts/app/src/Wrapper/index.d.ts +5 -0
- package/build/contexts/app/src/Wrapper/index.js +68 -0
- package/build/contexts/app/src/Wrapper/types.d.ts +20 -0
- package/build/contexts/app/src/Wrapper/types.js +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WrapperProps } from './src/Wrapper';
|
|
2
2
|
import { AppContext } from './types';
|
|
3
3
|
import './src/styles.css';
|
|
4
4
|
export declare const Provider: import("react").Provider<AppContext>, useApp: () => AppContext;
|
|
5
|
-
declare const _default: import("react").MemoExoticComponent<({ children, ...props }:
|
|
5
|
+
declare const _default: import("react").MemoExoticComponent<({ children, ...props }: WrapperProps) => import("react").JSX.Element>;
|
|
6
6
|
export default _default;
|
|
@@ -12,7 +12,7 @@ const expo_router_1 = require("expo-router");
|
|
|
12
12
|
const constants_1 = require("@/constants");
|
|
13
13
|
const router_1 = __importDefault(require("@/contexts/router"));
|
|
14
14
|
const pathname_1 = __importDefault(require("@/contexts/pathname"));
|
|
15
|
-
const
|
|
15
|
+
const Wrapper_1 = __importDefault(require("./src/Wrapper"));
|
|
16
16
|
require("./src/styles.css");
|
|
17
17
|
_a = (0, constants_1.createCtx)(), exports.Provider = _a[0], exports.useApp = _a[1];
|
|
18
18
|
exports.default = (0, react_1.memo)(({ children, ...props }) => {
|
|
@@ -24,9 +24,9 @@ exports.default = (0, react_1.memo)(({ children, ...props }) => {
|
|
|
24
24
|
<react_native_safe_area_context_1.SafeAreaProvider>
|
|
25
25
|
<expo_router_1.ThemeProvider value={colorScheme === 'dark' ? expo_router_1.DarkTheme : expo_router_1.DefaultTheme}>
|
|
26
26
|
<exports.Provider value={value}>
|
|
27
|
-
<
|
|
27
|
+
<Wrapper_1.default {...props}>
|
|
28
28
|
{children}
|
|
29
|
-
</
|
|
29
|
+
</Wrapper_1.default>
|
|
30
30
|
</exports.Provider>
|
|
31
31
|
</expo_router_1.ThemeProvider>
|
|
32
32
|
</react_native_safe_area_context_1.SafeAreaProvider>
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import Provider from './context';
|
|
2
|
+
import Head from './src/Head';
|
|
3
|
+
import Loading from './src/Loading';
|
|
2
4
|
export { useApp } from './context';
|
|
3
5
|
export { useRouter } from '@/contexts/router';
|
|
4
6
|
export { useAlert } from '@/contexts/alert';
|
|
7
|
+
export { WrapperProps as AppProps } from './src/Wrapper';
|
|
5
8
|
export type { AppContext } from './types';
|
|
9
|
+
type Component = typeof Provider & {
|
|
10
|
+
Head: typeof Head;
|
|
11
|
+
Loading: typeof Loading;
|
|
12
|
+
};
|
|
13
|
+
declare const App: Component;
|
|
14
|
+
export default App;
|
|
@@ -3,12 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useAlert = exports.useRouter = exports.useApp =
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
exports.useAlert = exports.useRouter = exports.useApp = void 0;
|
|
7
|
+
const context_1 = __importDefault(require("./context"));
|
|
8
|
+
const Head_1 = __importDefault(require("./src/Head"));
|
|
9
|
+
const Loading_1 = __importDefault(require("./src/Loading"));
|
|
9
10
|
var context_2 = require("./context");
|
|
10
11
|
Object.defineProperty(exports, "useApp", { enumerable: true, get: function () { return context_2.useApp; } });
|
|
11
12
|
var router_1 = require("@/contexts/router");
|
|
12
13
|
Object.defineProperty(exports, "useRouter", { enumerable: true, get: function () { return router_1.useRouter; } });
|
|
13
14
|
var alert_1 = require("@/contexts/alert");
|
|
14
15
|
Object.defineProperty(exports, "useAlert", { enumerable: true, get: function () { return alert_1.useAlert; } });
|
|
16
|
+
const App = context_1.default;
|
|
17
|
+
App.Head = Head_1.default;
|
|
18
|
+
App.Loading = Loading_1.default;
|
|
19
|
+
exports.default = App;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const expo_router_1 = require("expo-router");
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const head_1 = __importDefault(require("expo-router/head"));
|
|
10
|
+
exports.default = (0, react_1.memo)(({ title = 'Pytech UI', description, ogDescription, siteUrl, ogImage }) => {
|
|
11
|
+
const pathname = (0, expo_router_1.usePathname)();
|
|
12
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
13
|
+
if (react_native_1.Platform.OS === 'web')
|
|
14
|
+
document.title = title;
|
|
15
|
+
}, [pathname, title]);
|
|
16
|
+
return (<head_1.default>
|
|
17
|
+
<title>{title}</title>
|
|
18
|
+
<meta name="description" content={description}/>
|
|
19
|
+
<meta property="og:type" content="website"/>
|
|
20
|
+
<meta property="og:title" content={title}/>
|
|
21
|
+
<meta property="og:description" content={ogDescription ?? description}/>
|
|
22
|
+
<meta property="og:url" content={siteUrl}/>
|
|
23
|
+
<meta property="og:image" content={ogImage}/>
|
|
24
|
+
<meta name="twitter:card" content="summary_large_image"/>
|
|
25
|
+
<meta name="twitter:title" content={title}/>
|
|
26
|
+
<meta name="twitter:description" content={ogDescription ?? description}/>
|
|
27
|
+
<meta name="twitter:image" content={ogImage}/>
|
|
28
|
+
</head_1.default>);
|
|
29
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
/**
|
|
3
|
+
Title of the page.
|
|
4
|
+
@default 'Application'
|
|
5
|
+
*/
|
|
6
|
+
title?: string;
|
|
7
|
+
/**
|
|
8
|
+
Description of the page.
|
|
9
|
+
*/
|
|
10
|
+
description?: string;
|
|
11
|
+
/**
|
|
12
|
+
Description of the page for the Open Graph protocol.
|
|
13
|
+
*/
|
|
14
|
+
ogDescription?: string;
|
|
15
|
+
/**
|
|
16
|
+
URL of the site.
|
|
17
|
+
*/
|
|
18
|
+
siteUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
Image of the page for the Open Graph protocol.
|
|
21
|
+
*/
|
|
22
|
+
ogImage?: string;
|
|
23
|
+
};
|
|
24
|
+
export default Props;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Props from './types';
|
|
3
|
+
export { Props as WrapperProps };
|
|
4
|
+
declare const _default: React.MemoExoticComponent<({ children, getSession, onLoadingRealsed }: Props) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | React.JSX.Element>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const universal_1 = require("@/universal");
|
|
41
|
+
const constants_1 = require("@/constants");
|
|
42
|
+
const Loading_1 = __importDefault(require("../Loading"));
|
|
43
|
+
exports.default = (0, react_1.memo)(({ children, getSession, onLoadingRealsed }) => {
|
|
44
|
+
const getSlots = (0, react_1.useCallback)(() => {
|
|
45
|
+
const slots = {};
|
|
46
|
+
react_1.default.Children.map(children, (child) => {
|
|
47
|
+
if (!react_1.default.isValidElement(child))
|
|
48
|
+
return;
|
|
49
|
+
if (child.type === Loading_1.default)
|
|
50
|
+
slots.loading = child;
|
|
51
|
+
});
|
|
52
|
+
return slots;
|
|
53
|
+
}, [children]);
|
|
54
|
+
const { loading } = getSlots();
|
|
55
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(getSession ? true : false);
|
|
56
|
+
const hasSessionRef = (0, react_1.useRef)(isLoading);
|
|
57
|
+
(0, react_1.useEffect)(() => {
|
|
58
|
+
if (!isLoading)
|
|
59
|
+
onLoadingRealsed?.({ hasSession: hasSessionRef.current });
|
|
60
|
+
}, [isLoading]);
|
|
61
|
+
(0, constants_1.useAsyncEffect)(async () => {
|
|
62
|
+
hasSessionRef.current = (await getSession?.()) ?? true;
|
|
63
|
+
setIsLoading(false);
|
|
64
|
+
}, []);
|
|
65
|
+
if (isLoading)
|
|
66
|
+
return loading ?? <universal_1.Host />;
|
|
67
|
+
return children;
|
|
68
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
/**
|
|
3
|
+
Stack from expo-router.
|
|
4
|
+
*/
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
Function to get the current session.
|
|
8
|
+
This will active the loading page until the session is obtained.
|
|
9
|
+
@default true
|
|
10
|
+
*/
|
|
11
|
+
getSession?: () => Promise<boolean> | boolean;
|
|
12
|
+
/**
|
|
13
|
+
Function to execute when the loading state is changed to false.
|
|
14
|
+
This will be used to redirect to the home page.
|
|
15
|
+
*/
|
|
16
|
+
onLoadingRealsed?: ({ hasSession }: {
|
|
17
|
+
hasSession: boolean;
|
|
18
|
+
}) => Promise<void> | void;
|
|
19
|
+
};
|
|
20
|
+
export default Props;
|