@m4l/core 0.0.13 → 0.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.
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { EnvironmentProviderProps } from './types';
3
+ declare const EnvironmentContext: import("react").Context<import("../..").EnvironmentType>;
4
+ declare function EnvironmentProvider(props: EnvironmentProviderProps): JSX.Element;
5
+ export { EnvironmentProvider, EnvironmentContext };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ import { EnvironmentType } from '../../types';
3
+ export interface EnvironmentProviderProps extends EnvironmentType {
4
+ children: ReactNode;
5
+ }
6
+ export declare type EnvironmentContextType = EnvironmentType;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { FlagsContextProps, FlagsProviderProps } from './types';
3
+ declare const FlagsContext: import("react").Context<FlagsContextProps>;
4
+ declare function FlagsProvider({ children }: FlagsProviderProps): JSX.Element;
5
+ export { FlagsProvider, FlagsContext };
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ export interface FlagsProviderProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare type Flag = string;
6
+ export interface FlagsContextProps {
7
+ flags: Array<Flag>;
8
+ clearFlags: () => void;
9
+ addFlag: (flag: Flag) => void;
10
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { HostToolsType } from '../../types';
3
+ import { HostToolsProviderProps } from './types';
4
+ declare const HostToolsContext: import("react").Context<HostToolsType>;
5
+ declare function HostToolsProvider(props: HostToolsProviderProps): JSX.Element;
6
+ export { HostToolsProvider, HostToolsContext };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ import { HostToolsType } from '../../types';
3
+ export interface HostToolsProviderProps extends HostToolsType {
4
+ children: ReactNode;
5
+ }
6
+ export declare type HostToolsContextType = HostToolsType;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { ModuleDictionaryContextProps, ModuleDictionaryProviderProps } from './types';
3
+ declare const ModuleDictionaryContext: import("react").Context<ModuleDictionaryContextProps>;
4
+ declare function ModuleDictionaryProvider(props: ModuleDictionaryProviderProps): JSX.Element;
5
+ export { ModuleDictionaryProvider, ModuleDictionaryContext };
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ import type { GetLabelType, ModuleDictionary } from 'src/types/dictionary';
3
+ export interface ModuleDictionaryProviderProps {
4
+ currentLang?: string;
5
+ isAuth?: boolean;
6
+ moduleId: number;
7
+ moduleName?: string;
8
+ componentsDictionary: string[];
9
+ children: ReactNode;
10
+ }
11
+ export interface ModuleDictionaryContextProps {
12
+ moduleDictionary?: ModuleDictionary;
13
+ getLabel: GetLabelType;
14
+ getModuleLabel: () => string;
15
+ }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { NetworkProviderProps } from './types';
3
+ declare const NetworkContext: import("react").Context<import("./types").NetworkType>;
4
+ declare function NetworkProvider(props: NetworkProviderProps): JSX.Element;
5
+ export { NetworkProvider, NetworkContext };
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { AxiosOperation, NetworkProps } from '../../types';
3
+ export declare type EventFunListener = (...args: any[]) => void;
4
+ export interface NetworkType {
5
+ networkOperation: (props: NetworkProps) => Promise<any>;
6
+ }
7
+ export interface NetworkProviderProps {
8
+ axiosOperation: AxiosOperation;
9
+ children: ReactNode;
10
+ }
11
+ export declare type NetworkContextType = NetworkType;
@@ -0,0 +1,5 @@
1
+ export { EnvironmentContext, EnvironmentProvider } from './EnvironmentContext';
2
+ export { HostToolsContext, HostToolsProvider } from './HostToolsContext';
3
+ export { NetworkContext, NetworkProvider } from './NetworkContext';
4
+ export { FlagsContext, FlagsProvider } from './FlagsContext';
5
+ export { ModuleDictionaryContext, ModuleDictionaryProvider } from './ModuleDictionaryContext';
@@ -0,0 +1,6 @@
1
+ export { useLocalStorage } from './useLocalStorage/useLocalStorage';
2
+ export { useHostTools } from './useHostTools';
3
+ export { useNetwork } from './useNetwork';
4
+ export { useEnvironment } from './useEnvironment';
5
+ export { useFlags, useFlagsPresent } from './useFlags';
6
+ export { useModuleDictionary } from './useModuleDictionary';
@@ -0,0 +1,2 @@
1
+ export declare const useEnvironment: () => import("../..").EnvironmentType;
2
+ export default useEnvironment;
@@ -0,0 +1,3 @@
1
+ import type { Flag, FlagsContextProps } from '../../contexts/FlagsContext/types';
2
+ export declare const useFlags: () => FlagsContextProps;
3
+ export declare const useFlagsPresent: (compareFlags: Array<Flag>) => boolean;
@@ -0,0 +1,2 @@
1
+ export declare const useHostTools: () => import("../..").HostToolsType;
2
+ export default useHostTools;
@@ -0,0 +1 @@
1
+ export declare function useLocalStorage<ValueType>(key: string, initialValue: ValueType): any[];
@@ -0,0 +1 @@
1
+ export declare const useModuleDictionary: () => import("../../contexts/ModuleDictionaryContext/types").ModuleDictionaryContextProps;
@@ -0,0 +1,2 @@
1
+ export declare const useNetwork: () => import("../../contexts/NetworkContext/types").NetworkType;
2
+ export default useNetwork;
@@ -0,0 +1,6 @@
1
+ export * from './contexts';
2
+ export * from './hooks';
3
+ export { EmitEvents } from './types';
4
+ export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventFunListener, } from './types';
5
+ export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
6
+ export * from './utils';
@@ -0,0 +1,13 @@
1
+ export declare type GetLabelType = (key: string) => string;
2
+ export interface ComponentDictionary {
3
+ [key: string]: string;
4
+ }
5
+ export interface Dictionary {
6
+ [key: string]: ComponentDictionary | boolean | undefined | string;
7
+ }
8
+ export interface DataDictionary extends ComponentDictionary {
9
+ module_name: string;
10
+ }
11
+ export interface ModuleDictionary extends Dictionary {
12
+ data: DataDictionary;
13
+ }
@@ -0,0 +1,39 @@
1
+ import type { Method } from 'axios';
2
+ import type { Id, ToastContent, ToastOptions } from 'react-toastify';
3
+ import type { BrowserHistory } from 'history';
4
+ export declare type Maybe<T> = T | undefined | null;
5
+ export declare interface EnvironmentType {
6
+ isLocalhost: boolean;
7
+ host: string;
8
+ domain_token: string;
9
+ host_api_remote: string;
10
+ host_api_local: string;
11
+ host_static_assets: string;
12
+ environment: string;
13
+ }
14
+ export declare type NetworkProps = {
15
+ method: Method;
16
+ endPoint: string;
17
+ timeout?: number;
18
+ parms?: object;
19
+ data?: object;
20
+ checkUnAuthorized?: boolean;
21
+ isRemote?: boolean;
22
+ showSuccesInfo?: boolean;
23
+ };
24
+ export declare type ToastFunction = (content: ToastContent, options?: ToastOptions) => Id;
25
+ export declare type EventFunListener = (...args: any[]) => void;
26
+ export declare interface HostToolsType {
27
+ history?: BrowserHistory;
28
+ toast: ToastFunction;
29
+ startProgress: VoidFunction;
30
+ stopProgress: VoidFunction;
31
+ events_add_listener: (eventName: string, handler: EventFunListener) => void;
32
+ events_remove_listener: (eventName: string, handler: Maybe<EventFunListener>) => void;
33
+ events_emit: (eventName: string, arg: any) => void;
34
+ }
35
+ export declare enum EmitEvents {
36
+ EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized",
37
+ EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change"
38
+ }
39
+ export declare type AxiosOperation = (props: NetworkProps, enviroment: EnvironmentType, hostTools: HostToolsType) => Promise<any>;
@@ -0,0 +1,2 @@
1
+ import type { EnvironmentType, HostToolsType, NetworkProps } from '../../types';
2
+ export declare const axiosOperation: (props: NetworkProps, enviroment: EnvironmentType, hostTools: HostToolsType) => Promise<any>;
@@ -0,0 +1,5 @@
1
+ export declare type AxiosOperationError = {
2
+ message: string;
3
+ status: number;
4
+ code: string | number;
5
+ };
@@ -0,0 +1 @@
1
+ export declare function getLocalStorage<ValueType>(key: string, initialValue: ValueType): ValueType;
@@ -0,0 +1 @@
1
+ export declare function getPropertyByString(object: Record<string, unknown>, propString: string): any;
@@ -0,0 +1,5 @@
1
+ export { voidFunction } from './voidFunction';
2
+ export { getPropertyByString } from './getPropertyByString';
3
+ export { getLocalStorage } from './getLocalStorage';
4
+ export { setLocalStorage } from './setLocalStorage';
5
+ export { axiosOperation } from './axiosOperation';
@@ -0,0 +1 @@
1
+ export declare function setLocalStorage<ValueType>(key: string, value: ValueType): void;
@@ -0,0 +1 @@
1
+ export declare function voidFunction(): void;
@@ -0,0 +1,3 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vitest" />
3
+ /// <reference types="vitest/importMeta" />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
3
  "private": false,
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "license": "UNLICENSED",
6
6
  "author": "M4L Team",
7
7
  "scripts": {