@m4l/core 0.0.4 → 0.0.7

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.
@@ -2,5 +2,5 @@ export { useLocalStorage } from './useLocalStorage/useLocalStorage';
2
2
  export { useHostTools } from './useHostTools';
3
3
  export { useNetwork } from './useNetwork';
4
4
  export { useEnvironment } from './useEnvironment';
5
- export { useFlags } from './useFlags';
5
+ export { useFlags, useFlagsPresent } from './useFlags';
6
6
  export { useModuleDictionary } from './useModuleDictionary';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './contexts';
2
2
  export * from './hooks';
3
3
  export { EmitEvents } from './types';
4
- export type { Maybe, HostToolsType, NetworkProps, EnvironmentType } from './types';
4
+ export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation } from './types';
5
+ export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
5
6
  export * from './utils';
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var __objRest = (source2, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { createContext, useState, useContext, useCallback, useLayoutEffect } from "react";
32
+ import { createContext, useState, useContext, useCallback, useEffect, useLayoutEffect } from "react";
33
33
  import { jsx } from "react/jsx-runtime";
34
34
  const initialValue$2 = {
35
35
  isLocalhost: true,
@@ -1630,6 +1630,20 @@ const useFlags = () => {
1630
1630
  throw new Error("useFlags context must be use inside FlagsProvider");
1631
1631
  return context;
1632
1632
  };
1633
+ function isFlagsPresent(compareFlags, flags) {
1634
+ const filterFlags = compareFlags.filter((findFlag) => flags.findIndex((sFlag) => sFlag === findFlag) !== -1);
1635
+ return filterFlags.length === compareFlags.length;
1636
+ }
1637
+ const useFlagsPresent = (compareFlags) => {
1638
+ const context = useFlags();
1639
+ const [isPresent, setIsPresent] = useState(isFlagsPresent(compareFlags, context.flags));
1640
+ useEffect(() => {
1641
+ if (isFlagsPresent(compareFlags, context.flags)) {
1642
+ setIsPresent(true);
1643
+ }
1644
+ }, [context.flags, compareFlags]);
1645
+ return isPresent;
1646
+ };
1633
1647
  const useModuleDictionary = () => {
1634
1648
  const context = useContext(ModuleDictionaryContext);
1635
1649
  if (!context)
@@ -1714,4 +1728,4 @@ function ModuleDictionaryProvider(props) {
1714
1728
  children
1715
1729
  });
1716
1730
  }
1717
- export { EmitEvents, EnvironmentContext, EnvironmentProvider, FlagsContext, FlagsProvider, HostToolsContext, HostToolsProvider, ModuleDictionaryContext, ModuleDictionaryProvider, NetworkContext, NetworkProvider, axiosOperation, getLocalStorage, getPropertyByString, setLocalStorage, useEnvironment, useFlags, useHostTools, useLocalStorage, useModuleDictionary, useNetwork, voidFunction };
1731
+ export { EmitEvents, EnvironmentContext, EnvironmentProvider, FlagsContext, FlagsProvider, HostToolsContext, HostToolsProvider, ModuleDictionaryContext, ModuleDictionaryProvider, NetworkContext, NetworkProvider, axiosOperation, getLocalStorage, getPropertyByString, setLocalStorage, useEnvironment, useFlags, useFlagsPresent, useHostTools, useLocalStorage, useModuleDictionary, useNetwork, voidFunction };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
3
  "private": false,
4
- "version": "0.0.4",
4
+ "version": "0.0.7",
5
5
  "license": "UNLICENSED",
6
6
  "author": "M4L Team",
7
7
  "scripts": {