@bigbinary/neeto-commons-frontend 2.0.35 → 2.0.37
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/README.md +10 -6
- package/configs/babel.js +1 -0
- package/configs/eslint/helpers/index.js +52 -35
- package/initializers.cjs.js +60 -605
- package/initializers.d.ts +2 -1
- package/initializers.js +58 -604
- package/package.json +10 -3
- package/pure.cjs.js +5 -5
- package/pure.js +5 -5
- package/react-utils.cjs.js +4546 -341
- package/react-utils.d.ts +84 -5
- package/react-utils.js +4558 -360
- package/utils.cjs.js +48 -33
- package/utils.d.ts +16 -3
- package/utils.js +44 -34
package/README.md
CHANGED
|
@@ -47,6 +47,9 @@ Category
|
|
|
47
47
|
- [useLocalStorage](./docs/react/hooks.md#uselocalstorage)
|
|
48
48
|
- [useOnClickOutside](./docs/react/hooks.md#useonclickoutside)
|
|
49
49
|
- [useFieldSubmit](./docs/react/hooks.md#usefieldsubmit)
|
|
50
|
+
- [useDisplayErrorPage](./docs/react/hooks.md#usedisplayerrorpage)
|
|
51
|
+
- [useErrorDisplayStore](./docs/react/hooks.md#useerrordisplaystore)
|
|
52
|
+
- [useHotKeys](./docs/react/hooks.md#useHotKeys)
|
|
50
53
|
- [PrivateRoute](./docs/react/components.md#privateroute)
|
|
51
54
|
- [HoneybadgerErrorBoundary](./docs/react/components.md#honeybadgererrorboundary)
|
|
52
55
|
- [Sidebar](./docs/react/components.md#sidebar)
|
|
@@ -59,13 +62,14 @@ Category
|
|
|
59
62
|
- [CustomDomain](./docs/react/components.md#customdomain)
|
|
60
63
|
- [BrowserSupport](./docs/react/components.md#browsersupport)
|
|
61
64
|
- [IpRestriction](./docs/react/components.md#iprestriction)
|
|
62
|
-
- [
|
|
63
|
-
- [
|
|
65
|
+
- [PublishBlock](./docs/react/components.md#publishblock)
|
|
66
|
+
- [KeyboardShortcutsPane](./docs/react/components.md#keyboardshortcutspane)
|
|
67
|
+
- [withImmutableActions](./docs/react/utils.md#withimmutableactions)
|
|
68
|
+
- [withTitle](./docs/react/utils.md#withtitle)
|
|
64
69
|
- [registerBrowserNotifications](./docs/react/utils.md#registerbrowsernotifications)
|
|
65
|
-
(register browser subscription for push notifications)
|
|
66
70
|
- [destroyBrowserSubscription](./docs/react/utils.md#destroybrowsersubscription)
|
|
67
|
-
|
|
68
|
-
- [
|
|
71
|
+
- [handleMetaClick](./docs/react/utils.md#handlemetaclick)
|
|
72
|
+
- [isMetaKeyPressed](./docs/react/utils.md#ismetakeypressed)
|
|
69
73
|
|
|
70
74
|
</td>
|
|
71
75
|
<td style="vertical-align: top;">
|
|
@@ -186,7 +190,7 @@ them to read more:
|
|
|
186
190
|
3. [Pure utility functions](./docs/pure/README.md)
|
|
187
191
|
4. [Web utility functions](./docs/utils/README.md)
|
|
188
192
|
5. [Default configurations](./docs/configs/README.md)
|
|
189
|
-
|
|
193
|
+
6. [Cypress Utils](./docs/cypress/README.md)
|
|
190
194
|
|
|
191
195
|
## Other references
|
|
192
196
|
|
package/configs/babel.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports = function (api) {
|
|
|
33
33
|
isTestEnv
|
|
34
34
|
? "babel-plugin-dynamic-import-node" // tests run in node environment
|
|
35
35
|
: "@babel/plugin-syntax-dynamic-import",
|
|
36
|
+
["istanbul", { useInlineSourceMaps: false }],
|
|
36
37
|
isProductionEnv && [
|
|
37
38
|
"babel-plugin-transform-react-remove-prop-types",
|
|
38
39
|
{ removeImport: true },
|
|
@@ -1,61 +1,78 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const { mergeDeepLeft } = require("ramda");
|
|
4
|
+
const { mergeDeepLeft, mergeLeft, keys } = require("ramda");
|
|
5
5
|
|
|
6
6
|
const loadJS = jsPath => {
|
|
7
7
|
try {
|
|
8
|
-
return require(
|
|
9
|
-
} catch
|
|
8
|
+
return require(jsPath);
|
|
9
|
+
} catch {
|
|
10
10
|
return {};
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
14
|
+
const doesFileExist = filePath =>
|
|
15
|
+
fs.existsSync(filePath) && fs.lstatSync(filePath).isFile();
|
|
16
|
+
|
|
17
|
+
const generateAllPathsInsideDir = dirPath => {
|
|
18
|
+
const files = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
return files.flatMap(file => {
|
|
21
|
+
const filePath = path.join(dirPath, file.name);
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
return file.isDirectory() ? generateAllPathsInsideDir(filePath) : filePath;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
const generatePathGroupsFromAssets = assetsPath => {
|
|
28
|
+
if (!fs.existsSync(assetsPath)) return [];
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
return generateAllPathsInsideDir(assetsPath).map(absPath => ({
|
|
31
|
+
pattern: absPath.replace(assetsPath, "").split(".")[0],
|
|
32
|
+
group: "internal",
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
const buildPathGroupsBasedOnWebpackAliases = ({
|
|
37
|
+
customAliasPath = "config/webpack/resolve.js",
|
|
38
|
+
}) => {
|
|
39
|
+
const rootOfProject = path.join(__dirname, "../../../../../../");
|
|
40
|
+
const projectResolve = loadJS(path.join(rootOfProject, customAliasPath));
|
|
30
41
|
const commonResolve = loadJS(
|
|
31
|
-
|
|
42
|
+
path.join(
|
|
43
|
+
rootOfProject,
|
|
44
|
+
"node_modules/@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js"
|
|
45
|
+
)
|
|
32
46
|
);
|
|
33
|
-
const { alias } = mergeDeepLeft(projectResolve, commonResolve);
|
|
34
47
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
const { dependencies = [], devDependencies = [] } = loadJS(
|
|
49
|
+
path.join(rootOfProject, "package.json")
|
|
50
|
+
);
|
|
51
|
+
const packages = keys(mergeLeft(dependencies, devDependencies));
|
|
52
|
+
const { alias = {}, extensions = [] } = mergeDeepLeft(
|
|
53
|
+
projectResolve,
|
|
54
|
+
commonResolve
|
|
55
|
+
);
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
? ""
|
|
48
|
-
: "/**";
|
|
57
|
+
const pathGroups = Object.entries(alias).flatMap(([pattern, aliasPath]) => {
|
|
58
|
+
const group = packages.includes(aliasPath) ? "external" : "internal";
|
|
59
|
+
const isFile = ["", ...extensions].some(extension =>
|
|
60
|
+
doesFileExist(`${aliasPath}${extension}`)
|
|
61
|
+
);
|
|
49
62
|
|
|
50
|
-
|
|
51
|
-
if (name === "neetoui") {
|
|
52
|
-
group = "external";
|
|
53
|
-
}
|
|
63
|
+
if (isFile) return { pattern, group };
|
|
54
64
|
|
|
55
|
-
return
|
|
65
|
+
return [
|
|
66
|
+
{ pattern, group },
|
|
67
|
+
{ pattern: `${pattern}/**`, group },
|
|
68
|
+
];
|
|
56
69
|
});
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
const pathGroupsFromAssets = generatePathGroupsFromAssets(
|
|
72
|
+
path.join(rootOfProject, "app/assets/")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return pathGroups.concat(pathGroupsFromAssets);
|
|
59
76
|
};
|
|
60
77
|
|
|
61
78
|
module.exports = { buildPathGroupsBasedOnWebpackAliases };
|