@bigbinary/neeto-commons-frontend 2.0.36 → 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 +5 -0
- package/configs/babel.js +1 -0
- package/configs/eslint/helpers/index.js +51 -35
- package/initializers.cjs.js +52 -574
- package/initializers.d.ts +2 -1
- package/initializers.js +50 -573
- package/package.json +8 -3
- package/react-utils.cjs.js +4323 -213
- package/react-utils.d.ts +73 -11
- package/react-utils.js +4324 -220
- package/utils.cjs.js +33 -0
- package/utils.d.ts +14 -3
- package/utils.js +30 -1
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)
|
|
@@ -60,11 +63,13 @@ Category
|
|
|
60
63
|
- [BrowserSupport](./docs/react/components.md#browsersupport)
|
|
61
64
|
- [IpRestriction](./docs/react/components.md#iprestriction)
|
|
62
65
|
- [PublishBlock](./docs/react/components.md#publishblock)
|
|
66
|
+
- [KeyboardShortcutsPane](./docs/react/components.md#keyboardshortcutspane)
|
|
63
67
|
- [withImmutableActions](./docs/react/utils.md#withimmutableactions)
|
|
64
68
|
- [withTitle](./docs/react/utils.md#withtitle)
|
|
65
69
|
- [registerBrowserNotifications](./docs/react/utils.md#registerbrowsernotifications)
|
|
66
70
|
- [destroyBrowserSubscription](./docs/react/utils.md#destroybrowsersubscription)
|
|
67
71
|
- [handleMetaClick](./docs/react/utils.md#handlemetaclick)
|
|
72
|
+
- [isMetaKeyPressed](./docs/react/utils.md#ismetakeypressed)
|
|
68
73
|
|
|
69
74
|
</td>
|
|
70
75
|
<td style="vertical-align: top;">
|
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,62 +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(
|
|
8
|
+
return require(jsPath);
|
|
9
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
|
-
|
|
35
|
-
const railsJSFilesRoot = rootOfProject + customJSRoot;
|
|
36
|
-
|
|
37
|
-
const pathGroups = Object.entries(alias).map(([name, path]) => {
|
|
38
|
-
// sometimes alias might be already resolved to full absolute path
|
|
39
|
-
const isAlreadyAnAbsolutePath =
|
|
40
|
-
path.includes("cypress-tests/") || path.includes("app/");
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
);
|
|
45
56
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
);
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
if (name === "neetoui") {
|
|
53
|
-
group = "external";
|
|
54
|
-
}
|
|
63
|
+
if (isFile) return { pattern, group };
|
|
55
64
|
|
|
56
|
-
return
|
|
65
|
+
return [
|
|
66
|
+
{ pattern, group },
|
|
67
|
+
{ pattern: `${pattern}/**`, group },
|
|
68
|
+
];
|
|
57
69
|
});
|
|
58
70
|
|
|
59
|
-
|
|
71
|
+
const pathGroupsFromAssets = generatePathGroupsFromAssets(
|
|
72
|
+
path.join(rootOfProject, "app/assets/")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return pathGroups.concat(pathGroupsFromAssets);
|
|
60
76
|
};
|
|
61
77
|
|
|
62
78
|
module.exports = { buildPathGroupsBasedOnWebpackAliases };
|