oiu-core1 0.1.15

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 (90) hide show
  1. package/README.md +143 -0
  2. package/dist/assets/oiu-core.css +1 -0
  3. package/dist/auth/AuthenticationProvider.d.ts +16 -0
  4. package/dist/auth/AuthenticationProvider.d.ts.map +1 -0
  5. package/dist/auth/AuthorizationProvider.d.ts +22 -0
  6. package/dist/auth/AuthorizationProvider.d.ts.map +1 -0
  7. package/dist/auth/Context.d.ts +5 -0
  8. package/dist/auth/Context.d.ts.map +1 -0
  9. package/dist/auth/OAuthService/index.d.ts +58 -0
  10. package/dist/auth/OAuthService/index.d.ts.map +1 -0
  11. package/dist/auth/OAuthService/utils.d.ts +23 -0
  12. package/dist/auth/OAuthService/utils.d.ts.map +1 -0
  13. package/dist/auth/_type.d.ts +157 -0
  14. package/dist/auth/_type.d.ts.map +1 -0
  15. package/dist/auth/index.d.ts +17 -0
  16. package/dist/auth/index.d.ts.map +1 -0
  17. package/dist/auth/utils.d.ts +42 -0
  18. package/dist/auth/utils.d.ts.map +1 -0
  19. package/dist/components/Col/index.d.ts +17 -0
  20. package/dist/components/Col/index.d.ts.map +1 -0
  21. package/dist/components/ConfigLoader/index.d.ts +24 -0
  22. package/dist/components/ConfigLoader/index.d.ts.map +1 -0
  23. package/dist/components/ErrorCode/index.d.ts +16 -0
  24. package/dist/components/ErrorCode/index.d.ts.map +1 -0
  25. package/dist/components/FormErrorSummary/Content.d.ts +10 -0
  26. package/dist/components/FormErrorSummary/Content.d.ts.map +1 -0
  27. package/dist/components/FormErrorSummary/WithErrorFieldsMap.d.ts +28 -0
  28. package/dist/components/FormErrorSummary/WithErrorFieldsMap.d.ts.map +1 -0
  29. package/dist/components/FormErrorSummary/index.d.ts +11 -0
  30. package/dist/components/FormErrorSummary/index.d.ts.map +1 -0
  31. package/dist/components/LangProvider/index.d.ts +31 -0
  32. package/dist/components/LangProvider/index.d.ts.map +1 -0
  33. package/dist/components/Pagination/index.d.ts +18 -0
  34. package/dist/components/Pagination/index.d.ts.map +1 -0
  35. package/dist/components/Row/index.d.ts +15 -0
  36. package/dist/components/Row/index.d.ts.map +1 -0
  37. package/dist/components/SearchWithCard/index.d.ts +35 -0
  38. package/dist/components/SearchWithCard/index.d.ts.map +1 -0
  39. package/dist/components/Wait/_type.d.ts +33 -0
  40. package/dist/components/Wait/_type.d.ts.map +1 -0
  41. package/dist/components/Wait/index.d.ts +9 -0
  42. package/dist/components/Wait/index.d.ts.map +1 -0
  43. package/dist/components/_types.d.ts +4 -0
  44. package/dist/components/_types.d.ts.map +1 -0
  45. package/dist/components/index.d.ts +20 -0
  46. package/dist/components/index.d.ts.map +1 -0
  47. package/dist/hoc/index.d.ts +3 -0
  48. package/dist/hoc/index.d.ts.map +1 -0
  49. package/dist/hoc/withError.d.ts +21 -0
  50. package/dist/hoc/withError.d.ts.map +1 -0
  51. package/dist/hoc/wl.d.ts +31 -0
  52. package/dist/hoc/wl.d.ts.map +1 -0
  53. package/dist/index-BRODpY4Y.js +2659 -0
  54. package/dist/init.d.ts +63 -0
  55. package/dist/init.d.ts.map +1 -0
  56. package/dist/language/index.d.ts +75 -0
  57. package/dist/language/index.d.ts.map +1 -0
  58. package/dist/main-DEwdbtUG.js +23410 -0
  59. package/dist/main.d.ts +10 -0
  60. package/dist/main.d.ts.map +1 -0
  61. package/dist/main.js +12 -0
  62. package/dist/redux/apiSlices/index.d.ts +19 -0
  63. package/dist/redux/apiSlices/index.d.ts.map +1 -0
  64. package/dist/redux/index.d.ts +18 -0
  65. package/dist/redux/index.d.ts.map +1 -0
  66. package/dist/redux/slices/appSlice.d.ts +67 -0
  67. package/dist/redux/slices/appSlice.d.ts.map +1 -0
  68. package/dist/redux/slices/errorSlice.d.ts +57 -0
  69. package/dist/redux/slices/errorSlice.d.ts.map +1 -0
  70. package/dist/redux/slices/langSlice.d.ts +41 -0
  71. package/dist/redux/slices/langSlice.d.ts.map +1 -0
  72. package/dist/theme/UITheme.d.ts +26 -0
  73. package/dist/theme/UITheme.d.ts.map +1 -0
  74. package/dist/theme/index.d.ts +16 -0
  75. package/dist/theme/index.d.ts.map +1 -0
  76. package/dist/utils/_types.d.ts +32 -0
  77. package/dist/utils/_types.d.ts.map +1 -0
  78. package/dist/utils/config.d.ts +32 -0
  79. package/dist/utils/config.d.ts.map +1 -0
  80. package/dist/utils/index.d.ts +8 -0
  81. package/dist/utils/index.d.ts.map +1 -0
  82. package/dist/utils/promise.d.ts +14 -0
  83. package/dist/utils/promise.d.ts.map +1 -0
  84. package/dist/utils/string.d.ts +15 -0
  85. package/dist/utils/string.d.ts.map +1 -0
  86. package/dist/utils/sys.d.ts +3 -0
  87. package/dist/utils/sys.d.ts.map +1 -0
  88. package/dist/utils/url.d.ts +47 -0
  89. package/dist/utils/url.d.ts.map +1 -0
  90. package/package.json +54 -0
package/dist/init.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { ComponentType } from 'react';
2
+ import { DevToolsEnhancerOptions, Slice } from '@reduxjs/toolkit';
3
+ import { SetupOptions } from './utils';
4
+ import { LangInfo } from './language';
5
+ import { ProviderComponentType } from './theme';
6
+ import { ColProps, PaginationProps, RowProps, SpinProps } from './components';
7
+ export type RTKSetup = {
8
+ slices?: Slice[];
9
+ modules?: Array<Record<string, unknown>>;
10
+ };
11
+ export type RTKDevSetup = SetupOptions<DevToolsEnhancerOptions>;
12
+ export type InitOIUOptions<Token, TSpinProps, TSkeletonProps, TColProps extends ColProps = ColProps, TRowProps extends RowProps = RowProps, TPaginationProps extends PaginationProps = PaginationProps> = {
13
+ /** Translation configuration */
14
+ translation: {
15
+ /** Default language information, this will be used if the browser language is set to an unknown language */
16
+ defaultLang: LangInfo;
17
+ /** Record of language code and its information. Example: { en: { code: 'en', locale: 'en-US' }, es: { code: 'es', locale: 'es-ES' } } */
18
+ langs: Record<string, LangInfo>;
19
+ };
20
+ /** Wait component configuration */
21
+ wait: {
22
+ /** Spin component to be used in the app */
23
+ spin: ComponentType<SpinProps<TSpinProps>>;
24
+ /** Default extra properties set to the spin component, this will ignored if there is spin extra props passed */
25
+ spinProps?: TSpinProps;
26
+ /** Skeleton component to be used in the app */
27
+ skeleton?: ComponentType<SpinProps<TSkeletonProps>>;
28
+ /** Default extra properties set to the skeleton component, this will ignored if there is skeleton extra props passed */
29
+ skeletonProps?: TSkeletonProps;
30
+ };
31
+ /** Custom component to wrap the app, this is useful if you want to wrap the app with a provider or something like that */
32
+ components: {
33
+ /** Column component to be used in the app, this will be used in the Grid component */
34
+ col?: ComponentType<TColProps>;
35
+ /** Row component to be used in the app, this will be used in the Grid component */
36
+ row?: ComponentType<TRowProps>;
37
+ /** Pagination component to be used in the app */
38
+ pagination?: ComponentType<TPaginationProps>;
39
+ };
40
+ themeProvider?: ProviderComponentType<Token>;
41
+ };
42
+ /**
43
+ * Initialize OIU library. This is global initialization that must be done only once in the app.
44
+ * @param defaultLang Default language used in the site en case the browser lang is set in unknow lang
45
+ * @param lang Record of language code and its information. Example: { en: { code: 'en', locale: 'en-US' }, es: { code: 'es', locale: 'es-ES' } }
46
+ * @param themeProvider Custom theme provider to wrap the app
47
+ */
48
+ export declare function initOIU<Token, TSpinProps, TSkeletonProps>(options: InitOIUOptions<Token, TSpinProps, TSkeletonProps>): void;
49
+ /**
50
+ * Hook to initialize OIU in the component
51
+ * @returns
52
+ */
53
+ export declare function useInitOIU(defaultLocale: string, rtkOptions?: RTKSetup, devOptionsSetup?: RTKDevSetup): {
54
+ store: import("@reduxjs/toolkit").EnhancedStore<{
55
+ [x: string]: /*elided*/ any;
56
+ }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
57
+ dispatch: import("redux-thunk").ThunkDispatch<{
58
+ [x: string]: /*elided*/ any;
59
+ }, undefined, import("redux").UnknownAction>;
60
+ }>, import("redux").StoreEnhancer]>>;
61
+ langInfo: LangInfo;
62
+ };
63
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +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cAAc,CAAC,CAAC,CAAC;QACpD,wHAAwH;QACxH,aAAa,CAAC,EAAE,cAAc,CAAC;KAClC,CAAC;IACF,0HAA0H;IAC1H,UAAU,EAAE;QACR,sFAAsF;QACtF,GAAG,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAC/B,mFAAmF;QACnF,GAAG,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;QAC/B,iDAAiD;QACjD,UAAU,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;KAChD,CAAC;IACF,aAAa,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;CAChD,CAAC;AACF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,cAAc,CAAC,QAqBpH;AACD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,GAAE,QAAa,EAAE,eAAe,CAAC,EAAE,WAAW;;;;;;;;;EAoBzG"}
@@ -0,0 +1,75 @@
1
+ import { IntlShape } from 'react-intl';
2
+ export type GL = {
3
+ spin: {
4
+ loading: string;
5
+ config: string;
6
+ lang: string;
7
+ permission: string;
8
+ auth: string;
9
+ fetching: string;
10
+ };
11
+ };
12
+ /** Json path used to validate the language */
13
+ export type JsonPath<T> = T extends object ? {
14
+ [K in keyof T]: K extends string ? (T[K] extends object ? `${K}.${JsonPath<T[K]>}` : `${K}`) : never;
15
+ }[keyof T] : never;
16
+ export type Dfn<T> = () => Promise<T>;
17
+ export type LangInfo = {
18
+ /** Lang generic code like: es, en, ch */
19
+ code: string;
20
+ /** Especified the locale of the language: example es-es, en-US */
21
+ locale: string;
22
+ };
23
+ /**
24
+ * Check if the locale is registered
25
+ * @param locale Localte to be checked
26
+ * @returns
27
+ */
28
+ export declare function isValidLocale(locale: string): boolean;
29
+ /**
30
+ * Allow set the language translation by default. This multiples locales with a single code. This avoid the need to have
31
+ * several language file for diferent locales. This language must have the key _, this will be used by default if the language is not found.
32
+ * @example 'en' could be used for en-US, en-GB, etc.
33
+ * @param defaultLang Default language used in the site en case the browser lang is set in unknow lang
34
+ * @param langs Record of language code and its information. Example: { en: { code: 'en', locale: 'en-US' }, es: { code: 'es', locale: 'es-ES' } }
35
+ */
36
+ export declare function setDefaultTranslation(defaultLang: LangInfo, langs: Record<string, LangInfo>): void;
37
+ /** Return a component that will translate the given path.
38
+ * @param path
39
+ * @returns
40
+ */
41
+ export declare function t<T>(path: JsonPath<T>): import("react/jsx-runtime").JSX.Element;
42
+ /**
43
+ * Allow safe access to json key properties
44
+ * @param path
45
+ * @returns
46
+ */
47
+ export declare function tkey<T>(path: JsonPath<T>): string;
48
+ /**
49
+ * Allow safe access to text mapped with the json file properties
50
+ * @param path
51
+ * @returns
52
+ */
53
+ export declare function ttext<T>(intl: IntlShape, path: JsonPath<T>): string;
54
+ /**
55
+ * Get the language @see {@link LangInfo} for the given language code. Example: 'en', 'es', 'fr', 'en-GB', etc.
56
+ * @param lang
57
+ * @returns
58
+ */
59
+ export declare function getLangInfo(locale: string): LangInfo;
60
+ /**
61
+ * Load dynamic the json language file
62
+ * @param locale locale where the language is defined. Example: 'en', 'es', 'fr', 'en-GB', etc.
63
+ * @param en Dynamic import of the json file for the language. Example: () => import('./en.json')
64
+ * @param es Dynamic import of the json file for the language. Example: () => import('./es.json')
65
+ * @returns The corresponding language file for the given locale.
66
+ */
67
+ export declare function getJsonLang<T>(locale: string, definition: Record<string, Dfn<T>>): Promise<T>;
68
+ /** Get language defined by browser. */
69
+ export declare function getBrowserLocale(): string;
70
+ /**
71
+ * Get the current browser language translate to the valid code
72
+ * @returns
73
+ */
74
+ export declare function getBrowserLangInfo(): LangInfo;
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/language/index.tsx"],"names":[],"mappings":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