oiu-core 0.0.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.
Files changed (44) hide show
  1. package/README.md +139 -0
  2. package/dist/assets/oiu.css +1 -0
  3. package/dist/auth/_type.d.ts +135 -0
  4. package/dist/auth/_type.d.ts.map +1 -0
  5. package/dist/components/Await/_type.d.ts +29 -0
  6. package/dist/components/Await/_type.d.ts.map +1 -0
  7. package/dist/components/Await/index.d.ts +9 -0
  8. package/dist/components/Await/index.d.ts.map +1 -0
  9. package/dist/components/LangProvider/index.d.ts +22 -0
  10. package/dist/components/LangProvider/index.d.ts.map +1 -0
  11. package/dist/components/Test1/index.d.ts +2 -0
  12. package/dist/components/Test1/index.d.ts.map +1 -0
  13. package/dist/components/Test2/index.d.ts +2 -0
  14. package/dist/components/Test2/index.d.ts.map +1 -0
  15. package/dist/components/index.d.ts +7 -0
  16. package/dist/components/index.d.ts.map +1 -0
  17. package/dist/language/index.d.ts +70 -0
  18. package/dist/language/index.d.ts.map +1 -0
  19. package/dist/main.d.ts +42 -0
  20. package/dist/main.d.ts.map +1 -0
  21. package/dist/main.js +5958 -0
  22. package/dist/redux/index.d.ts +18 -0
  23. package/dist/redux/index.d.ts.map +1 -0
  24. package/dist/redux/slices/appSlice.d.ts +63 -0
  25. package/dist/redux/slices/appSlice.d.ts.map +1 -0
  26. package/dist/redux/slices/langSlice.d.ts +41 -0
  27. package/dist/redux/slices/langSlice.d.ts.map +1 -0
  28. package/dist/theme/UITheme.d.ts +24 -0
  29. package/dist/theme/UITheme.d.ts.map +1 -0
  30. package/dist/theme/index.d.ts +16 -0
  31. package/dist/theme/index.d.ts.map +1 -0
  32. package/dist/utils/_types.d.ts +32 -0
  33. package/dist/utils/_types.d.ts.map +1 -0
  34. package/dist/utils/index.d.ts +6 -0
  35. package/dist/utils/index.d.ts.map +1 -0
  36. package/dist/utils/promise.d.ts +2 -0
  37. package/dist/utils/promise.d.ts.map +1 -0
  38. package/dist/utils/string.d.ts +14 -0
  39. package/dist/utils/string.d.ts.map +1 -0
  40. package/dist/utils/sys.d.ts +3 -0
  41. package/dist/utils/sys.d.ts.map +1 -0
  42. package/dist/utils/url.d.ts +7 -0
  43. package/dist/utils/url.d.ts.map +1 -0
  44. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ ## Guide for creation
2
+ 1. `npm create vite@latest . -- --template react-ts`
3
+ 2. Create the tsconfig.build.json (this is the file used in the build process)
4
+ ```json
5
+ {
6
+ "extends": "./tsconfig.json",
7
+ "compilerOptions": {
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "emitDeclarationOnly": true,
11
+ "declarationDir": "./dist",
12
+ "outDir": "./dist",
13
+ "skipLibCheck": true,
14
+ "jsx": "react-jsx",
15
+ "resolveJsonModule": true,
16
+ "esModuleInterop": true,
17
+ },
18
+ "include": ["lib"]
19
+ }
20
+ ```
21
+ 3. Update vite.config.ts with the build configuration
22
+ ```js
23
+ import { defineConfig } from 'vite';
24
+ import react from '@vitejs/plugin-react';
25
+ import { dirname, resolve } from 'node:path';
26
+ import { fileURLToPath } from 'node:url';
27
+
28
+
29
+ // https://vite.dev/config/
30
+
31
+ const __dirname = dirname(fileURLToPath(import.meta.url));
32
+ console.log('Vite build path:', __dirname);
33
+
34
+ export default defineConfig({
35
+ plugins: [react()],
36
+ resolve: {
37
+ alias: {
38
+ '@': resolve(__dirname, 'src'),
39
+ },
40
+ },
41
+ build: {
42
+ copyPublicDir: false,
43
+ lib: {
44
+ entry: resolve(__dirname, 'lib/main.ts'),
45
+ formats: ['es'],
46
+ },
47
+ rollupOptions: {
48
+ external: ['react', 'react-dom', 'react/jsx-runtime'],
49
+ output: {
50
+ globals: {
51
+ react: 'React',
52
+ 'react-dom': 'ReactDOM',
53
+ },
54
+ assetFileNames: 'assets/[name][extname]',
55
+ entryFileNames: '[name].js',
56
+ },
57
+ },
58
+ },
59
+ });
60
+ ```
61
+ 4. Add CSS module d.ts (css-modules.d.ts)
62
+ 5. `npm publish` (for that you need to enable the 2fa in your npm account if you use the public registry)
63
+
64
+
65
+
66
+
67
+ # React + TypeScript + Vite
68
+
69
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
70
+
71
+ Currently, two official plugins are available:
72
+
73
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
74
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
75
+
76
+ ## React Compiler
77
+
78
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
79
+
80
+ ## Expanding the ESLint configuration
81
+
82
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
83
+
84
+ ```js
85
+ export default defineConfig([
86
+ globalIgnores(['dist']),
87
+ {
88
+ files: ['**/*.{ts,tsx}'],
89
+ extends: [
90
+ // Other configs...
91
+
92
+ // Remove tseslint.configs.recommended and replace with this
93
+ tseslint.configs.recommendedTypeChecked,
94
+ // Alternatively, use this for stricter rules
95
+ tseslint.configs.strictTypeChecked,
96
+ // Optionally, add this for stylistic rules
97
+ tseslint.configs.stylisticTypeChecked,
98
+
99
+ // Other configs...
100
+ ],
101
+ languageOptions: {
102
+ parserOptions: {
103
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
104
+ tsconfigRootDir: import.meta.dirname,
105
+ },
106
+ // other options...
107
+ },
108
+ },
109
+ ])
110
+ ```
111
+
112
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
113
+
114
+ ```js
115
+ // eslint.config.js
116
+ import reactX from 'eslint-plugin-react-x'
117
+ import reactDom from 'eslint-plugin-react-dom'
118
+
119
+ export default defineConfig([
120
+ globalIgnores(['dist']),
121
+ {
122
+ files: ['**/*.{ts,tsx}'],
123
+ extends: [
124
+ // Other configs...
125
+ // Enable lint rules for React
126
+ reactX.configs['recommended-typescript'],
127
+ // Enable lint rules for React DOM
128
+ reactDom.configs.recommended,
129
+ ],
130
+ languageOptions: {
131
+ parserOptions: {
132
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
133
+ tsconfigRootDir: import.meta.dirname,
134
+ },
135
+ // other options...
136
+ },
137
+ },
138
+ ])
139
+ ```
@@ -0,0 +1 @@
1
+ ._overlay_o73ej_1{min-width:100%}._dummy_o73ej_7{min-height:100vh}
@@ -0,0 +1,135 @@
1
+ import { State } from "../utils/url";
2
+ import { Guid } from "../utils/_types";
3
+ /** Base type from the principal */
4
+ export type Principal = {
5
+ id: Guid;
6
+ username: string;
7
+ firstName: string;
8
+ lastName: string;
9
+ roles: string[];
10
+ };
11
+ /** Identity information of the customer */
12
+ export type Identity<T = Principal> = {
13
+ /** The id_token returned from the OIDC provider */
14
+ id_token?: string;
15
+ /** The session state value returned from the OIDC provider (opaque) */
16
+ session_state?: string | null;
17
+ /** The access token returned from the OIDC provider. */
18
+ access_token?: string;
19
+ /** Refresh token returned from the OIDC provider (if requested) */
20
+ refresh_token?: string;
21
+ /** The token_type returned from the OIDC provider */
22
+ token_type: string;
23
+ /** The scope returned from the OIDC provider */
24
+ scope?: string;
25
+ /** The claims represented by a combination of the id_token and the user info endpoint */
26
+ profile: T;
27
+ /** The expires at returned from the OIDC provider */
28
+ expires_at: number;
29
+ };
30
+ /** Status of the autentication process */
31
+ export declare enum AuthResultStatus {
32
+ Redirect = 0,
33
+ Success = 1,
34
+ Fail = 2
35
+ }
36
+ /** Auth result */
37
+ export type AuthResult = {
38
+ status: AuthResultStatus;
39
+ state?: State;
40
+ message?: string;
41
+ };
42
+ type CallbackFn = (event: string, identity?: Identity) => void;
43
+ export interface IAuthService {
44
+ /**
45
+ * Get the unsafe instance of the authentication service. Do not use this method unless you know what you are doing.
46
+ */
47
+ getUnsafeInstance(): unknown;
48
+ /**
49
+ * Indicate if customer is autenticate
50
+ */
51
+ isAuthenticated(): Promise<boolean>;
52
+ /**
53
+ * Get identity information
54
+ */
55
+ getIdentity(): Promise<Identity | undefined>;
56
+ /**
57
+ * Initialize sign in process
58
+ * @param state
59
+ * @param args
60
+ */
61
+ getUser(): Promise<unknown | null>;
62
+ /** Clear the identity information
63
+ * @param identity: if true, clear the identity information and remove the token from the storage
64
+ */
65
+ clear(identity?: boolean): Promise<void>;
66
+ /**
67
+ * Start the sign in process
68
+ * @param state state to be passed to the authentication provider
69
+ * @param args arguments to be passed to the authentication provider
70
+ * @param onFeedback Provide feedback to the authentication process. Like error message or any other information
71
+ * @param explicit Indicate the silent sign in is not allow and the user must be see the login page
72
+ */
73
+ signIn(state?: unknown, args?: unknown, onFeedback?: (feedback: string) => void, explicit?: boolean): Promise<AuthResult>;
74
+ /**
75
+ * Complete sign in process (this is use in case the sign out requiere 2 stages)
76
+ * @param url
77
+ */
78
+ completeSignIn(url?: string): Promise<AuthResult>;
79
+ /**
80
+ * Try to sign in silently. This is use to refresh the token or get the user information
81
+ * @param state
82
+ * @param args
83
+ */
84
+ silentSignIn(state?: unknown, args?: unknown): Promise<AuthResult | undefined>;
85
+ /**
86
+ * Complete silent sign in process (this is use in case the sign out requiere 2 stages)
87
+ * @param url
88
+ */
89
+ completeSilentSignin(url?: string): Promise<AuthResult>;
90
+ /**
91
+ * Initialize the sign out process
92
+ * @param state
93
+ */
94
+ signOut(state?: unknown): Promise<AuthResult>;
95
+ /**
96
+ * Complete sign out process (this is use in case the sign out requiere 2 stages)
97
+ * @param url
98
+ */
99
+ completeSignOut(url?: string): Promise<AuthResult>;
100
+ /**
101
+ * Subscribe to identity back changes. If activate silence refresh token or any other approach to update the identity
102
+ * @param callback
103
+ */
104
+ subscribe(callback: CallbackFn): number;
105
+ /**
106
+ * Unsubscribe to identity back changes. If activate silence refresh token or any other approach to update the identity
107
+ * @param subscriptionId
108
+ */
109
+ unsubscribe(subscriptionId: number): void;
110
+ }
111
+ export declare abstract class AuthService implements IAuthService {
112
+ protected _identity?: Identity;
113
+ private _callbacks;
114
+ private _nextSubscriptionId;
115
+ constructor();
116
+ abstract getUnsafeInstance(): unknown;
117
+ abstract getIdentity(): Promise<Identity | undefined>;
118
+ abstract getUser(): Promise<unknown | null>;
119
+ abstract clear(identity?: boolean): Promise<void>;
120
+ abstract signIn(state?: unknown, args?: unknown, onFeedback?: (feedback: string) => void, explicit?: boolean): Promise<AuthResult>;
121
+ abstract completeSignIn(url?: string): Promise<AuthResult>;
122
+ abstract silentSignIn(state?: unknown, args?: unknown): Promise<AuthResult | undefined>;
123
+ abstract completeSilentSignin(url?: string): Promise<AuthResult>;
124
+ abstract signOut(state?: unknown): Promise<AuthResult>;
125
+ abstract completeSignOut(url?: string): Promise<AuthResult>;
126
+ /** @inheritdoc */
127
+ isAuthenticated(): Promise<boolean>;
128
+ /** @inheritdoc */
129
+ unsubscribe(subscriptionId: number): void;
130
+ /** @inheritdoc */
131
+ subscribe(callback: CallbackFn): number;
132
+ protected _notifySubscribers(event: string, identity?: Identity): void;
133
+ }
134
+ export {};
135
+ //# sourceMappingURL=_type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_type.d.ts","sourceRoot":"","sources":["../../lib/auth/_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAYvC,mCAAmC;AACnC,MAAM,MAAM,SAAS,GAAG;IACpB,EAAE,EAAE,IAAI,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAA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EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IACjD,QAAQ,CAAC,MAAM,CACX,KAAK,CAAC,EAAE,OAAO,EACf,IAAI,CAAC,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EACvC,QAAQ,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,UAAU,CAAC;IACtB,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAC1D,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IACvF,QAAQ,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAChE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IACtD,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAE3D,kBAAkB;IACL,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhD,kBAAkB;IACX,WAAW,CAAC,cAAc,EAAE,MAAM;IAMzC,kBAAkB;IACX,SAAS,CAAC,QAAQ,EAAE,UAAU;IAMrC,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;CAMlE"}
@@ -0,0 +1,29 @@
1
+ import { ComponentType, PropsWithChildren, ReactNode } from "react";
2
+ export type SpinProps<T = unknown> = PropsWithChildren<{
3
+ /** Whether to show the spin */
4
+ spinning?: boolean;
5
+ /** The text to show when the spin is spinning */
6
+ tip?: ReactNode;
7
+ /** Class name */
8
+ className?: string;
9
+ /** Allow set extra properties to be passed to the final spin component */
10
+ extraProps?: T;
11
+ }>;
12
+ export type SpinOrSkeletonProps<T = unknown> = {
13
+ spin: SpinProps<T>;
14
+ skeleton?: never;
15
+ } | {
16
+ spin?: never;
17
+ skeleton: SpinProps<T>;
18
+ };
19
+ export type AwaitProps<T = unknown> = PropsWithChildren<{
20
+ /** Use translation api to resolve the text */
21
+ useTranslation?: boolean;
22
+ /** Show children when the spin is spinning in other case hide the children component */
23
+ showChildren?: boolean;
24
+ } & SpinOrSkeletonProps<T>>;
25
+ export type AwaitComponentType = ComponentType<AwaitProps> & {
26
+ spin: ComponentType<SpinProps>;
27
+ skeleton?: ComponentType<SpinProps>;
28
+ };
29
+ //# sourceMappingURL=_type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_type.d.ts","sourceRoot":"","sources":["../../../lib/components/Await/_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpE,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC;IACnD,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,CAAC,CAAC;CAClB,CAAC,CAAC;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,OAAO,IAAI;IAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AACnI,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CACnD;IACI,8CAA8C;IAC9C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAC7B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG;IACzD,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACvC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AwaitProps, SpinProps } from './_type';
2
+ /**
3
+ *
4
+ * @param param0
5
+ * @returns
6
+ */
7
+ export declare const Await: import("react").MemoExoticComponent<({ showChildren, useTranslation, spin, skeleton, children }: AwaitProps) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode>>>;
8
+ export type { SpinProps, AwaitProps };
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Await/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAsB,MAAM,SAAS,CAAC;AAOpE;;;;GAIG;AACH,eAAO,MAAM,KAAK,mGAAmF,UAAU,uUAwB7G,CAAC;AAsDH,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { Dfn, GL, LangInfo } from '../../language';
3
+ export type LangText = Record<string, {
4
+ loading: {
5
+ _: string;
6
+ languages: string;
7
+ };
8
+ }>;
9
+ export type LangProviderProps = PropsWithChildren<{
10
+ /** Language information to be use in the site */
11
+ lang: LangInfo;
12
+ defaultTexts?: LangText;
13
+ langFiles: Record<string, Dfn<{
14
+ default: GL;
15
+ }>>;
16
+ }>;
17
+ /** Provide internationalization
18
+ * @param param0 component arguments
19
+ * @returns
20
+ */
21
+ export declare function LangProvider({ children, lang, langFiles, defaultTexts }: LangProviderProps): import("react/jsx-runtime").JSX.Element;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/LangProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA8B,MAAM,OAAO,CAAC;AAKtE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAyBhE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAAC;AACrF,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;IAC9C,iDAAiD;IACjD,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;QAAE,OAAO,EAAE,EAAE,CAAA;KAAE,CAAC,CAAC,CAAC;CACnD,CAAC,CAAC;AACH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,YAAuB,EAAE,EAAE,iBAAiB,2CAiDrG"}
@@ -0,0 +1,2 @@
1
+ export declare function Test1(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Test1/index.tsx"],"names":[],"mappings":"AAEA,wBAAgB,KAAK,4CAOpB"}
@@ -0,0 +1,2 @@
1
+ export declare function Test2(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Test2/index.tsx"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,4CAEpB"}
@@ -0,0 +1,7 @@
1
+ export { Test1 } from './Test1';
2
+ export { Test2 } from './Test2';
3
+ export { Await } from './Await';
4
+ export type { AwaitProps, SpinProps } from './Await';
5
+ export { LangProvider } from './LangProvider';
6
+ export type { LangProviderProps } from './LangProvider';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,70 @@
1
+ export type GL = {
2
+ _no: string;
3
+ _yes: string;
4
+ spin: {
5
+ loading: string;
6
+ config: string;
7
+ lang: string;
8
+ permission: string;
9
+ auth: string;
10
+ fetching: string;
11
+ };
12
+ };
13
+ /** Json path used to validate the language */
14
+ export type JsonPath<T> = T extends object ? {
15
+ [K in keyof T]: K extends string ? (T[K] extends object ? `${K}.${JsonPath<T[K]>}` : `${K}`) : never;
16
+ }[keyof T] : never;
17
+ export type Dfn<T> = () => Promise<T>;
18
+ export type LangInfo = {
19
+ /** Lang generic code like: es, en, ch */
20
+ code: string;
21
+ /** Especified the locale of the language: example es-es, en-US */
22
+ locale: string;
23
+ };
24
+ /**
25
+ * Check if the locale is registered
26
+ * @param locale Localte to be checked
27
+ * @returns
28
+ */
29
+ export declare function isValidLocale(locale: string): boolean;
30
+ /**
31
+ * Allow set the language translation by default. This multiples locales with a single code. This avoid the need to have
32
+ * several language file for diferent locales. This language must have the key _, this will be used by default if the language is not found.
33
+ * @example 'en' could be used for en-US, en-GB, etc.
34
+ * @param defaultLang Default language used in the site en case the browser lang is set in unknow lang
35
+ * @param langs Record of language code and its information. Example: { en: { code: 'en', locale: 'en-US' }, es: { code: 'es', locale: 'es-ES' } }
36
+ */
37
+ export declare function setDefaultTranslation(defaultLang: LangInfo, langs: Record<string, LangInfo>): void;
38
+ /** Return a component that will translate the given path.
39
+ * @param path
40
+ * @returns
41
+ */
42
+ export declare function t<T>(path: JsonPath<T>): import("react/jsx-runtime").JSX.Element;
43
+ /**
44
+ * Allow safe access to json file properties
45
+ * @param path
46
+ * @returns
47
+ */
48
+ export declare function traw<T>(path: JsonPath<T>): string;
49
+ /**
50
+ * Get the language @see {@link LangInfo} for the given language code. Example: 'en', 'es', 'fr', 'en-GB', etc.
51
+ * @param lang
52
+ * @returns
53
+ */
54
+ export declare function getLangInfo(locale: string): LangInfo;
55
+ /**
56
+ * Load dynamic the json language file
57
+ * @param locale locale where the language is defined. Example: 'en', 'es', 'fr', 'en-GB', etc.
58
+ * @param en Dynamic import of the json file for the language. Example: () => import('./en.json')
59
+ * @param es Dynamic import of the json file for the language. Example: () => import('./es.json')
60
+ * @returns The corresponding language file for the given locale.
61
+ */
62
+ export declare function getJsonLang<T>(locale: string, definition: Record<string, Dfn<T>>): Promise<T>;
63
+ /** Get language defined by browser. */
64
+ export declare function getBrowserLocale(): string;
65
+ /**
66
+ * Get the current browser language translate to the valid code
67
+ * @returns
68
+ */
69
+ export declare function getBrowserLangInfo(): LangInfo;
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/language/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,EAAE,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC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AE,MAAM,GAAG,QAAQ,CASpD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ7F;AAED,uCAAuC;AACvC,wBAAgB,gBAAgB,WAG/B;AACD;;;GAGG;AACH,wBAAgB,kBAAkB,aAKjC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { ComponentType } from 'react';
2
+ import { DevToolsEnhancerOptions } from '@reduxjs/toolkit';
3
+ import * as utils from './utils';
4
+ import * as redux from './redux';
5
+ import * as language from './language';
6
+ import * as components from './components';
7
+ import * as theme from './theme';
8
+ export type RTKDevSetup = utils.SetupOptions<DevToolsEnhancerOptions>;
9
+ export type InitOIUOptions<Token> = {
10
+ translation: {
11
+ defaultLang: language.LangInfo;
12
+ langs: Record<string, language.LangInfo>;
13
+ };
14
+ wait: {
15
+ spin: ComponentType<components.SpinProps>;
16
+ skeleton?: ComponentType<components.SpinProps>;
17
+ };
18
+ themeProvider?: theme.ProviderComponentType<Token>;
19
+ };
20
+ /**
21
+ * Initialize OIU library. This is global initialization that must be done only once in the app.
22
+ * @param defaultLang Default language used in the site en case the browser lang is set in unknow lang
23
+ * @param lang Record of language code and its information. Example: { en: { code: 'en', locale: 'en-US' }, es: { code: 'es', locale: 'es-ES' } }
24
+ * @param themeProvider
25
+ */
26
+ export declare function initOIU<Token>(options: InitOIUOptions<Token>): void;
27
+ /**
28
+ * Hook to initialize OIU in the component
29
+ * @returns
30
+ */
31
+ export declare function useInitOIU(defaultLocale: string, devOptionsSetup?: RTKDevSetup): {
32
+ store: import("@reduxjs/toolkit").EnhancedStore<{
33
+ [x: string]: /*elided*/ any;
34
+ }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
35
+ dispatch: import("redux-thunk").ThunkDispatch<{
36
+ [x: string]: /*elided*/ any;
37
+ }, undefined, import("redux").UnknownAction>;
38
+ }>, import("redux").StoreEnhancer]>>;
39
+ langInfo: language.LangInfo;
40
+ };
41
+ export { components, language, redux, theme, utils };
42
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../lib/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAW,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAQjC,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAEtE,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI;IAChC,WAAW,EAAE;QACT,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC;QAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC5C,CAAC;IACF,IAAI,EAAE;QACF,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC1C,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;KAClD,CAAC;IACF,aAAa,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACtD,CAAC;AACF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,QAkB5D;AACD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,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