gov-ui-core 0.2.6-beta.9 → 1.0.0

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.
Files changed (150) hide show
  1. package/.eslintrc.json +54 -54
  2. package/.husky/pre-commit +4 -4
  3. package/.prettierrc +12 -12
  4. package/.storybook/main.ts +37 -37
  5. package/.storybook/preview.tsx +27 -27
  6. package/.stylelintrc.json +19 -16
  7. package/@types/custom.d.ts +43 -43
  8. package/@types/styles.d.ts +99 -86
  9. package/README.md +46 -46
  10. package/build/App.d.ts +3 -3
  11. package/build/Main.d.ts +5 -5
  12. package/build/components/Badge/index.d.ts +8 -0
  13. package/build/components/Badge/styled.d.ts +1 -0
  14. package/build/components/Breadcrumb/index.d.ts +6 -0
  15. package/build/components/Breadcrumb/styled.d.ts +2 -0
  16. package/build/components/Button/DropdownButton.d.ts +15 -15
  17. package/build/components/Button/SwitchButton.d.ts +10 -7
  18. package/build/components/Button/TextButton.d.ts +8 -0
  19. package/build/components/Button/constants.d.ts +19 -19
  20. package/build/components/Button/index.d.ts +11 -11
  21. package/build/components/Button/styled.d.ts +18 -11
  22. package/build/components/Calendar/CalendarNavigation.d.ts +9 -9
  23. package/build/components/Calendar/constants.d.ts +2 -2
  24. package/build/components/Calendar/index.d.ts +11 -11
  25. package/build/components/Calendar/styled.d.ts +2 -2
  26. package/build/components/Card/index.d.ts +12 -0
  27. package/build/components/Carousel/ArrowButton.d.ts +7 -7
  28. package/build/components/Carousel/index.d.ts +14 -14
  29. package/build/components/Carousel/styled.d.ts +2 -2
  30. package/build/components/Chip/constants.d.ts +11 -9
  31. package/build/components/Chip/index.d.ts +11 -12
  32. package/build/components/Directory/index.d.ts +32 -32
  33. package/build/components/Directory/styled.d.ts +6 -6
  34. package/build/components/EmptyBox/index.d.ts +8 -8
  35. package/build/components/EmptyBox/styled.d.ts +4 -4
  36. package/build/components/Form/Form.d.ts +21 -21
  37. package/build/components/Form/Group.d.ts +6 -6
  38. package/build/components/Form/Item.d.ts +27 -22
  39. package/build/components/Form/index.d.ts +14 -14
  40. package/build/components/Form/styled.d.ts +7 -7
  41. package/build/components/Header/ContentHeader.d.ts +15 -15
  42. package/build/components/Header/styled.d.ts +5 -5
  43. package/build/components/Icons/index.d.ts +14 -14
  44. package/build/components/Input/Checkbox.d.ts +22 -19
  45. package/build/components/Input/ErrorMessage.d.ts +8 -8
  46. package/build/components/Input/Input.d.ts +24 -23
  47. package/build/components/Input/InputNumber.d.ts +8 -8
  48. package/build/components/Input/Radio.d.ts +18 -16
  49. package/build/components/Input/Search.d.ts +13 -13
  50. package/build/components/Input/Select.d.ts +40 -40
  51. package/build/components/Input/TextArea.d.ts +18 -15
  52. package/build/components/Input/index.d.ts +19 -19
  53. package/build/components/Input/styled.d.ts +29 -25
  54. package/build/components/IntlText/index.d.ts +5 -5
  55. package/build/components/Loading/OverlayLoading.d.ts +10 -10
  56. package/build/components/Loading/Spinner.d.ts +9 -9
  57. package/build/components/Loading/styled.d.ts +10 -10
  58. package/build/components/Menu/index.d.ts +26 -0
  59. package/build/components/Modal/index.d.ts +10 -0
  60. package/build/components/Modal/styled.d.ts +6 -0
  61. package/build/components/Pannel/index.d.ts +10 -0
  62. package/build/components/Pannel/styled.d.ts +5 -0
  63. package/build/components/Progress/index.d.ts +11 -0
  64. package/build/components/Progress/styled.d.ts +4 -0
  65. package/build/components/Sliders/index.d.ts +9 -0
  66. package/build/components/Sliders/styled.d.ts +9 -0
  67. package/build/components/Styled/mixins.d.ts +13 -13
  68. package/build/components/Styled/variable.d.ts +6 -6
  69. package/build/components/Table/AppendTable.d.ts +26 -26
  70. package/build/components/Table/AutoTooltip.d.ts +8 -8
  71. package/build/components/Table/TableBase.d.ts +16 -16
  72. package/build/components/Table/TableLoading.d.ts +9 -9
  73. package/build/components/Table/components/Pagination.d.ts +18 -18
  74. package/build/components/Table/components/PaginationItem.d.ts +9 -9
  75. package/build/components/Table/index.d.ts +27 -27
  76. package/build/components/Table/styled.d.ts +26 -25
  77. package/build/components/Tabs/TabContent.d.ts +8 -0
  78. package/build/components/Tabs/index.d.ts +19 -0
  79. package/build/components/Tabs/styled.d.ts +12 -0
  80. package/build/components/TextBox/index.d.ts +12 -0
  81. package/build/components/ThemeProvider.d.ts +17 -16
  82. package/build/components/Toast/index.d.ts +10 -0
  83. package/build/components/Toast/styled.d.ts +6 -0
  84. package/build/components/Tooltips/index.d.ts +16 -0
  85. package/build/components/Tree/index.d.ts +8 -0
  86. package/build/globalStyle.d.ts +5 -5
  87. package/build/index.d.ts +2 -1
  88. package/build/index.js +1 -1
  89. package/build/modules.d.ts +31 -24
  90. package/build/pages/BreadcrumbSample.d.ts +5 -0
  91. package/build/pages/ButtonSample.d.ts +6 -6
  92. package/build/pages/CardSample.d.ts +5 -0
  93. package/build/pages/CheckboxSample.d.ts +6 -0
  94. package/build/pages/ChipSample.d.ts +6 -6
  95. package/build/pages/FormSample.d.ts +5 -5
  96. package/build/pages/InputSample.d.ts +6 -6
  97. package/build/pages/ModalSample.d.ts +5 -0
  98. package/build/pages/PannelSample.d.ts +5 -0
  99. package/build/pages/ProgressSample.d.ts +5 -0
  100. package/build/pages/RadioSample.d.ts +6 -0
  101. package/build/pages/Sample.d.ts +5 -5
  102. package/build/pages/Sample2.d.ts +5 -5
  103. package/build/pages/Sample3.d.ts +5 -5
  104. package/build/pages/Sample4.d.ts +5 -5
  105. package/build/pages/SlidersSample.d.ts +5 -0
  106. package/build/pages/TableSample.d.ts +5 -5
  107. package/build/pages/TabsSample.d.ts +6 -0
  108. package/build/pages/TailwindSample.d.ts +1 -1
  109. package/build/pages/TextBoxSample.d.ts +2 -0
  110. package/build/pages/ToastSample.d.ts +6 -0
  111. package/build/pages/TooltipsSample.d.ts +5 -0
  112. package/build/pages/TreeSample.d.ts +5 -0
  113. package/build/pages/sampleData.d.ts +59 -59
  114. package/build/reportWebVitals.d.ts +3 -3
  115. package/build/theme.d.ts +3 -3
  116. package/build/utils/customState.d.ts +28 -28
  117. package/build/utils/hookUtils.d.ts +16 -16
  118. package/build/utils/index.d.ts +35 -35
  119. package/config/env.js +104 -104
  120. package/config/getHttpsConfig.js +66 -66
  121. package/config/jest/babelTransform.js +29 -29
  122. package/config/jest/cssTransform.js +14 -14
  123. package/config/jest/fileTransform.js +40 -40
  124. package/config/modules.js +134 -134
  125. package/config/paths.js +77 -77
  126. package/config/webpack/persistentCache/createEnvironmentHash.js +9 -9
  127. package/config/webpack.config.js +756 -756
  128. package/config/webpack.prod.config.js +91 -91
  129. package/config/webpackDevServer.config.js +127 -127
  130. package/doctor-storybook.log +18 -0
  131. package/migration-storybook.log +98 -0
  132. package/package.json +250 -247
  133. package/postcss.config.js +8 -8
  134. package/public/index.html +43 -43
  135. package/public/manifest.json +25 -25
  136. package/public/robots.txt +3 -3
  137. package/scripts/build.js +217 -217
  138. package/scripts/start.js +154 -154
  139. package/scripts/test.js +52 -52
  140. package/tailwind.config.js +185 -185
  141. package/tsconfig.json +34 -34
  142. package/build/20d0d451f31ed3b5c15f.woff +0 -1
  143. package/build/39285e8af490890e2df4.otf +0 -0
  144. package/build/3965b6176d1ce958b445.woff +0 -1
  145. package/build/508d69efb37042551458.woff +0 -1
  146. package/build/72ba455576ce8174ffa8.otf +0 -0
  147. package/build/a9ba4978d441af03cd27.woff +0 -1
  148. package/build/e65c7edcd47e3e9f5c99.otf +0 -0
  149. package/build/f7a8dce8dfc249d7e12b.otf +0 -0
  150. package/build/pages/CreateTable.d.ts +0 -20
package/config/env.js CHANGED
@@ -1,104 +1,104 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const paths = require('./paths');
6
-
7
- // Make sure that including paths.js after env.js will read .env variables.
8
- delete require.cache[require.resolve('./paths')];
9
-
10
- const NODE_ENV = process.env.NODE_ENV;
11
- if (!NODE_ENV) {
12
- throw new Error(
13
- 'The NODE_ENV environment variable is required but was not specified.'
14
- );
15
- }
16
-
17
- // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18
- const dotenvFiles = [
19
- `${paths.dotenv}.${NODE_ENV}.local`,
20
- // Don't include `.env.local` for `test` environment
21
- // since normally you expect tests to produce the same
22
- // results for everyone
23
- NODE_ENV !== 'test' && `${paths.dotenv}.local`,
24
- `${paths.dotenv}.${NODE_ENV}`,
25
- paths.dotenv,
26
- ].filter(Boolean);
27
-
28
- // Load environment variables from .env* files. Suppress warnings using silent
29
- // if this file is missing. dotenv will never modify any environment variables
30
- // that have already been set. Variable expansion is supported in .env files.
31
- // https://github.com/motdotla/dotenv
32
- // https://github.com/motdotla/dotenv-expand
33
- dotenvFiles.forEach(dotenvFile => {
34
- if (fs.existsSync(dotenvFile)) {
35
- require('dotenv-expand')(
36
- require('dotenv').config({
37
- path: dotenvFile,
38
- })
39
- );
40
- }
41
- });
42
-
43
- // We support resolving modules according to `NODE_PATH`.
44
- // This lets you use absolute paths in imports inside large monorepos:
45
- // https://github.com/facebook/create-react-app/issues/253.
46
- // It works similar to `NODE_PATH` in Node itself:
47
- // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48
- // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49
- // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
50
- // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51
- // We also resolve them to make sure all tools using them work consistently.
52
- const appDirectory = fs.realpathSync(process.cwd());
53
- process.env.NODE_PATH = (process.env.NODE_PATH || '')
54
- .split(path.delimiter)
55
- .filter(folder => folder && !path.isAbsolute(folder))
56
- .map(folder => path.resolve(appDirectory, folder))
57
- .join(path.delimiter);
58
-
59
- // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60
- // injected into the application via DefinePlugin in webpack configuration.
61
- const REACT_APP = /^REACT_APP_/i;
62
-
63
- function getClientEnvironment(publicUrl) {
64
- const raw = Object.keys(process.env)
65
- .filter(key => REACT_APP.test(key))
66
- .reduce(
67
- (env, key) => {
68
- env[key] = process.env[key];
69
- return env;
70
- },
71
- {
72
- // Useful for determining whether we’re running in production mode.
73
- // Most importantly, it switches React into the correct mode.
74
- NODE_ENV: process.env.NODE_ENV || 'development',
75
- // Useful for resolving the correct path to static assets in `public`.
76
- // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77
- // This should only be used as an escape hatch. Normally you would put
78
- // images into the `src` and `import` them in code to get their paths.
79
- PUBLIC_URL: publicUrl,
80
- // We support configuring the sockjs pathname during development.
81
- // These settings let a developer run multiple simultaneous projects.
82
- // They are used as the connection `hostname`, `pathname` and `port`
83
- // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
84
- // and `sockPort` options in webpack-dev-server.
85
- WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
86
- WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
87
- WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
88
- // Whether or not react-refresh is enabled.
89
- // It is defined here so it is available in the webpackHotDevClient.
90
- FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
91
- }
92
- );
93
- // Stringify all values so we can feed into webpack DefinePlugin
94
- const stringified = {
95
- 'process.env': Object.keys(raw).reduce((env, key) => {
96
- env[key] = JSON.stringify(raw[key]);
97
- return env;
98
- }, {}),
99
- };
100
-
101
- return { raw, stringified };
102
- }
103
-
104
- module.exports = getClientEnvironment;
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const paths = require('./paths');
6
+
7
+ // Make sure that including paths.js after env.js will read .env variables.
8
+ delete require.cache[require.resolve('./paths')];
9
+
10
+ const NODE_ENV = process.env.NODE_ENV;
11
+ if (!NODE_ENV) {
12
+ throw new Error(
13
+ 'The NODE_ENV environment variable is required but was not specified.'
14
+ );
15
+ }
16
+
17
+ // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18
+ const dotenvFiles = [
19
+ `${paths.dotenv}.${NODE_ENV}.local`,
20
+ // Don't include `.env.local` for `test` environment
21
+ // since normally you expect tests to produce the same
22
+ // results for everyone
23
+ NODE_ENV !== 'test' && `${paths.dotenv}.local`,
24
+ `${paths.dotenv}.${NODE_ENV}`,
25
+ paths.dotenv,
26
+ ].filter(Boolean);
27
+
28
+ // Load environment variables from .env* files. Suppress warnings using silent
29
+ // if this file is missing. dotenv will never modify any environment variables
30
+ // that have already been set. Variable expansion is supported in .env files.
31
+ // https://github.com/motdotla/dotenv
32
+ // https://github.com/motdotla/dotenv-expand
33
+ dotenvFiles.forEach(dotenvFile => {
34
+ if (fs.existsSync(dotenvFile)) {
35
+ require('dotenv-expand')(
36
+ require('dotenv').config({
37
+ path: dotenvFile,
38
+ })
39
+ );
40
+ }
41
+ });
42
+
43
+ // We support resolving modules according to `NODE_PATH`.
44
+ // This lets you use absolute paths in imports inside large monorepos:
45
+ // https://github.com/facebook/create-react-app/issues/253.
46
+ // It works similar to `NODE_PATH` in Node itself:
47
+ // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48
+ // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49
+ // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
50
+ // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51
+ // We also resolve them to make sure all tools using them work consistently.
52
+ const appDirectory = fs.realpathSync(process.cwd());
53
+ process.env.NODE_PATH = (process.env.NODE_PATH || '')
54
+ .split(path.delimiter)
55
+ .filter(folder => folder && !path.isAbsolute(folder))
56
+ .map(folder => path.resolve(appDirectory, folder))
57
+ .join(path.delimiter);
58
+
59
+ // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60
+ // injected into the application via DefinePlugin in webpack configuration.
61
+ const REACT_APP = /^REACT_APP_/i;
62
+
63
+ function getClientEnvironment(publicUrl) {
64
+ const raw = Object.keys(process.env)
65
+ .filter(key => REACT_APP.test(key))
66
+ .reduce(
67
+ (env, key) => {
68
+ env[key] = process.env[key];
69
+ return env;
70
+ },
71
+ {
72
+ // Useful for determining whether we’re running in production mode.
73
+ // Most importantly, it switches React into the correct mode.
74
+ NODE_ENV: process.env.NODE_ENV || 'development',
75
+ // Useful for resolving the correct path to static assets in `public`.
76
+ // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77
+ // This should only be used as an escape hatch. Normally you would put
78
+ // images into the `src` and `import` them in code to get their paths.
79
+ PUBLIC_URL: publicUrl,
80
+ // We support configuring the sockjs pathname during development.
81
+ // These settings let a developer run multiple simultaneous projects.
82
+ // They are used as the connection `hostname`, `pathname` and `port`
83
+ // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
84
+ // and `sockPort` options in webpack-dev-server.
85
+ WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
86
+ WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
87
+ WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
88
+ // Whether or not react-refresh is enabled.
89
+ // It is defined here so it is available in the webpackHotDevClient.
90
+ FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
91
+ }
92
+ );
93
+ // Stringify all values so we can feed into webpack DefinePlugin
94
+ const stringified = {
95
+ 'process.env': Object.keys(raw).reduce((env, key) => {
96
+ env[key] = JSON.stringify(raw[key]);
97
+ return env;
98
+ }, {}),
99
+ };
100
+
101
+ return { raw, stringified };
102
+ }
103
+
104
+ module.exports = getClientEnvironment;
@@ -1,66 +1,66 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const crypto = require('crypto');
6
- const chalk = require('react-dev-utils/chalk');
7
- const paths = require('./paths');
8
-
9
- // Ensure the certificate and key provided are valid and if not
10
- // throw an easy to debug error
11
- function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
- let encrypted;
13
- try {
14
- // publicEncrypt will throw an error with an invalid cert
15
- encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
- } catch (err) {
17
- throw new Error(
18
- `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
- );
20
- }
21
-
22
- try {
23
- // privateDecrypt will throw an error with an invalid key
24
- crypto.privateDecrypt(key, encrypted);
25
- } catch (err) {
26
- throw new Error(
27
- `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
- err.message
29
- }`
30
- );
31
- }
32
- }
33
-
34
- // Read file and throw an error if it doesn't exist
35
- function readEnvFile(file, type) {
36
- if (!fs.existsSync(file)) {
37
- throw new Error(
38
- `You specified ${chalk.cyan(
39
- type
40
- )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
- );
42
- }
43
- return fs.readFileSync(file);
44
- }
45
-
46
- // Get the https config
47
- // Return cert files if provided in env, otherwise just true or false
48
- function getHttpsConfig() {
49
- const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
- const isHttps = HTTPS === 'true';
51
-
52
- if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
- const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
- const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
- const config = {
56
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
- };
59
-
60
- validateKeyAndCerts({ ...config, keyFile, crtFile });
61
- return config;
62
- }
63
- return isHttps;
64
- }
65
-
66
- module.exports = getHttpsConfig;
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const crypto = require('crypto');
6
+ const chalk = require('react-dev-utils/chalk');
7
+ const paths = require('./paths');
8
+
9
+ // Ensure the certificate and key provided are valid and if not
10
+ // throw an easy to debug error
11
+ function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
+ let encrypted;
13
+ try {
14
+ // publicEncrypt will throw an error with an invalid cert
15
+ encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
+ } catch (err) {
17
+ throw new Error(
18
+ `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
+ );
20
+ }
21
+
22
+ try {
23
+ // privateDecrypt will throw an error with an invalid key
24
+ crypto.privateDecrypt(key, encrypted);
25
+ } catch (err) {
26
+ throw new Error(
27
+ `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
+ err.message
29
+ }`
30
+ );
31
+ }
32
+ }
33
+
34
+ // Read file and throw an error if it doesn't exist
35
+ function readEnvFile(file, type) {
36
+ if (!fs.existsSync(file)) {
37
+ throw new Error(
38
+ `You specified ${chalk.cyan(
39
+ type
40
+ )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
+ );
42
+ }
43
+ return fs.readFileSync(file);
44
+ }
45
+
46
+ // Get the https config
47
+ // Return cert files if provided in env, otherwise just true or false
48
+ function getHttpsConfig() {
49
+ const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
+ const isHttps = HTTPS === 'true';
51
+
52
+ if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
+ const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
+ const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
+ const config = {
56
+ cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
+ key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
+ };
59
+
60
+ validateKeyAndCerts({ ...config, keyFile, crtFile });
61
+ return config;
62
+ }
63
+ return isHttps;
64
+ }
65
+
66
+ module.exports = getHttpsConfig;
@@ -1,29 +1,29 @@
1
- 'use strict';
2
-
3
- const babelJest = require('babel-jest').default;
4
-
5
- const hasJsxRuntime = (() => {
6
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
7
- return false;
8
- }
9
-
10
- try {
11
- require.resolve('react/jsx-runtime');
12
- return true;
13
- } catch (e) {
14
- return false;
15
- }
16
- })();
17
-
18
- module.exports = babelJest.createTransformer({
19
- presets: [
20
- [
21
- require.resolve('babel-preset-react-app'),
22
- {
23
- runtime: hasJsxRuntime ? 'automatic' : 'classic',
24
- },
25
- ],
26
- ],
27
- babelrc: false,
28
- configFile: false,
29
- });
1
+ 'use strict';
2
+
3
+ const babelJest = require('babel-jest').default;
4
+
5
+ const hasJsxRuntime = (() => {
6
+ if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
7
+ return false;
8
+ }
9
+
10
+ try {
11
+ require.resolve('react/jsx-runtime');
12
+ return true;
13
+ } catch (e) {
14
+ return false;
15
+ }
16
+ })();
17
+
18
+ module.exports = babelJest.createTransformer({
19
+ presets: [
20
+ [
21
+ require.resolve('babel-preset-react-app'),
22
+ {
23
+ runtime: hasJsxRuntime ? 'automatic' : 'classic',
24
+ },
25
+ ],
26
+ ],
27
+ babelrc: false,
28
+ configFile: false,
29
+ });
@@ -1,14 +1,14 @@
1
- 'use strict';
2
-
3
- // This is a custom Jest transformer turning style imports into empty objects.
4
- // http://facebook.github.io/jest/docs/en/webpack.html
5
-
6
- module.exports = {
7
- process() {
8
- return 'module.exports = {};';
9
- },
10
- getCacheKey() {
11
- // The output is always the same.
12
- return 'cssTransform';
13
- },
14
- };
1
+ 'use strict';
2
+
3
+ // This is a custom Jest transformer turning style imports into empty objects.
4
+ // http://facebook.github.io/jest/docs/en/webpack.html
5
+
6
+ module.exports = {
7
+ process() {
8
+ return 'module.exports = {};';
9
+ },
10
+ getCacheKey() {
11
+ // The output is always the same.
12
+ return 'cssTransform';
13
+ },
14
+ };
@@ -1,40 +1,40 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const camelcase = require('camelcase');
5
-
6
- // This is a custom Jest transformer turning file imports into filenames.
7
- // http://facebook.github.io/jest/docs/en/webpack.html
8
-
9
- module.exports = {
10
- process(src, filename) {
11
- const assetFilename = JSON.stringify(path.basename(filename));
12
-
13
- if (filename.match(/\.svg$/)) {
14
- // Based on how SVGR generates a component name:
15
- // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16
- const pascalCaseFilename = camelcase(path.parse(filename).name, {
17
- pascalCase: true,
18
- });
19
- const componentName = `Svg${pascalCaseFilename}`;
20
- return `const React = require('react');
21
- module.exports = {
22
- __esModule: true,
23
- default: ${assetFilename},
24
- ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25
- return {
26
- $$typeof: Symbol.for('react.element'),
27
- type: 'svg',
28
- ref: ref,
29
- key: null,
30
- props: Object.assign({}, props, {
31
- children: ${assetFilename}
32
- })
33
- };
34
- }),
35
- };`;
36
- }
37
-
38
- return `module.exports = ${assetFilename};`;
39
- },
40
- };
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const camelcase = require('camelcase');
5
+
6
+ // This is a custom Jest transformer turning file imports into filenames.
7
+ // http://facebook.github.io/jest/docs/en/webpack.html
8
+
9
+ module.exports = {
10
+ process(src, filename) {
11
+ const assetFilename = JSON.stringify(path.basename(filename));
12
+
13
+ if (filename.match(/\.svg$/)) {
14
+ // Based on how SVGR generates a component name:
15
+ // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16
+ const pascalCaseFilename = camelcase(path.parse(filename).name, {
17
+ pascalCase: true,
18
+ });
19
+ const componentName = `Svg${pascalCaseFilename}`;
20
+ return `const React = require('react');
21
+ module.exports = {
22
+ __esModule: true,
23
+ default: ${assetFilename},
24
+ ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25
+ return {
26
+ $$typeof: Symbol.for('react.element'),
27
+ type: 'svg',
28
+ ref: ref,
29
+ key: null,
30
+ props: Object.assign({}, props, {
31
+ children: ${assetFilename}
32
+ })
33
+ };
34
+ }),
35
+ };`;
36
+ }
37
+
38
+ return `module.exports = ${assetFilename};`;
39
+ },
40
+ };