@evlop/commons 1.0.314 → 1.0.315
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/dist/cjs/src/hooks/useScope.d.ts +1 -1
- package/dist/cjs/src/hooks/useScope.d.ts.map +1 -1
- package/dist/cjs/src/hooks/useScope.js +6 -6
- package/dist/cjs/src/hooks/useScope.js.map +1 -1
- package/dist/esm/src/hooks/useScope.d.ts +1 -1
- package/dist/esm/src/hooks/useScope.d.ts.map +1 -1
- package/dist/esm/src/hooks/useScope.js +6 -6
- package/dist/esm/src/hooks/useScope.js.map +1 -1
- package/dist/types/src/hooks/useScope.d.ts +1 -1
- package/dist/types/src/hooks/useScope.d.ts.map +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useScope.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useScope.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,GAAI,gBAAe,MAAM,GAAG,QAA+B,EAAE,eAAe,GAAG,QAOnG,CAAC;AAEF,OAAO,EAAC,QAAQ,IAAI,OAAO,EAAC,CAAC"}
|
@@ -4,15 +4,15 @@ exports.useData = exports.useScope = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
5
5
|
const react_1 = require("react");
|
6
6
|
const contexts_1 = require("../contexts");
|
7
|
-
const
|
7
|
+
const defaultScopeSelector = (scope) => scope;
|
8
|
+
const useScope = (scopeSelector = defaultScopeSelector, defaultValue) => {
|
8
9
|
const scope = (0, react_1.useContext)(contexts_1.DataContext);
|
9
|
-
if (typeof
|
10
|
-
return (0, lodash_1.get)(scope,
|
10
|
+
if (typeof scopeSelector === 'string') {
|
11
|
+
return (0, lodash_1.get)(scope, scopeSelector, defaultValue);
|
11
12
|
}
|
12
|
-
else
|
13
|
-
return
|
13
|
+
else {
|
14
|
+
return scopeSelector?.(scope);
|
14
15
|
}
|
15
|
-
return scope;
|
16
16
|
};
|
17
17
|
exports.useScope = useScope;
|
18
18
|
exports.useData = exports.useScope;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useScope.js","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":";;;AAAA,mCAA6B;AAC7B,iCAAmC;AACnC,0CAA0C;
|
1
|
+
{"version":3,"file":"useScope.js","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":";;;AAAA,mCAA6B;AAC7B,iCAAmC;AACnC,0CAA0C;AAE1C,MAAM,oBAAoB,GAAG,CAAC,KAAU,EAAC,EAAE,CAAC,KAAK,CAAC;AAE3C,MAAM,QAAQ,GAAG,CAAC,gBAAmC,oBAAoB,EAAE,YAAkB,EAAC,EAAE;IACnG,MAAM,KAAK,GAAS,IAAA,kBAAU,EAAC,sBAAW,CAAC,CAAC;IAC5C,IAAG,OAAO,aAAa,KAAK,QAAQ,EAAC,CAAC;QAClC,OAAO,IAAA,YAAG,EAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IACnD,CAAC;SAAK,CAAC;QACH,OAAO,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,QAAQ,YAOnB;AAEkB,kBATP,gBAAQ,CASM"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useScope.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useScope.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,GAAI,gBAAe,MAAM,GAAG,QAA+B,EAAE,eAAe,GAAG,QAOnG,CAAC;AAEF,OAAO,EAAC,QAAQ,IAAI,OAAO,EAAC,CAAC"}
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import { get } from 'lodash';
|
2
2
|
import { useContext } from 'react';
|
3
3
|
import { DataContext } from '../contexts';
|
4
|
-
|
4
|
+
const defaultScopeSelector = (scope) => scope;
|
5
|
+
export const useScope = (scopeSelector = defaultScopeSelector, defaultValue) => {
|
5
6
|
const scope = useContext(DataContext);
|
6
|
-
if (typeof
|
7
|
-
return get(scope,
|
7
|
+
if (typeof scopeSelector === 'string') {
|
8
|
+
return get(scope, scopeSelector, defaultValue);
|
8
9
|
}
|
9
|
-
else
|
10
|
-
return
|
10
|
+
else {
|
11
|
+
return scopeSelector?.(scope);
|
11
12
|
}
|
12
|
-
return scope;
|
13
13
|
};
|
14
14
|
export { useScope as useData };
|
15
15
|
//# sourceMappingURL=useScope.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useScope.js","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,
|
1
|
+
{"version":3,"file":"useScope.js","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,oBAAoB,GAAG,CAAC,KAAU,EAAC,EAAE,CAAC,KAAK,CAAC;AAElD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,gBAAmC,oBAAoB,EAAE,YAAkB,EAAC,EAAE;IACnG,MAAM,KAAK,GAAS,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAG,OAAO,aAAa,KAAK,QAAQ,EAAC,CAAC;QAClC,OAAO,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IACnD,CAAC;SAAK,CAAC;QACH,OAAO,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAC,QAAQ,IAAI,OAAO,EAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useScope.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useScope.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScope.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,GAAI,gBAAe,MAAM,GAAG,QAA+B,EAAE,eAAe,GAAG,QAOnG,CAAC;AAEF,OAAO,EAAC,QAAQ,IAAI,OAAO,EAAC,CAAC"}
|