linear-react-components-ui 0.4.77-beta.4 → 0.4.77-beta.5

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 (274) hide show
  1. package/.eslintrc.json +95 -0
  2. package/.gitlab-ci.yml +19 -0
  3. package/.husky/pre-push +4 -0
  4. package/.vscode/launch.json +15 -0
  5. package/.vscode/settings.json +3 -0
  6. package/config/getHttpsConfig.js +56 -0
  7. package/config/paths.js +140 -0
  8. package/config/webpackDevServer.config.js +128 -0
  9. package/jest.config.js +3 -3
  10. package/lib/@types/LabelStyles.js +5 -0
  11. package/lib/@types/PermissionAttr.js +5 -0
  12. package/lib/@types/PointerEvents.js +5 -0
  13. package/lib/@types/Position.js +5 -0
  14. package/lib/@types/Size.js +5 -0
  15. package/lib/@types/SizePixels.js +5 -0
  16. package/lib/alerts/AlertContainer.js +2 -2
  17. package/lib/alerts/AlertProvider.js +12 -12
  18. package/lib/alerts/BaseAlert.js +6 -6
  19. package/lib/alerts/Message.js +21 -21
  20. package/lib/alerts/alert.spec.js +3 -3
  21. package/lib/alerts/helpers.js +4 -4
  22. package/lib/alerts/index.js +5 -5
  23. package/lib/alerts/withAlert.js +6 -6
  24. package/lib/assets/styles/commons.scss +0 -10
  25. package/lib/assets/styles/dropdown.scss +2 -36
  26. package/lib/assets/styles/effects.scss +0 -11
  27. package/lib/assets/styles/list.scss +0 -8
  28. package/lib/assets/styles/table.scss +7 -2
  29. package/lib/avatar/avatar.spec.js +20 -20
  30. package/lib/avatar/index.js +28 -28
  31. package/lib/badge/badge.spec.js +3 -3
  32. package/lib/badge/index.js +12 -12
  33. package/lib/buttons/ActivateButton.js +5 -5
  34. package/lib/buttons/AddButton.js +5 -5
  35. package/lib/buttons/Button.js +22 -14
  36. package/lib/buttons/ButtonGroups.js +4 -9
  37. package/lib/buttons/CancelButton.js +19 -6
  38. package/lib/buttons/DangerButton.js +16 -21
  39. package/lib/buttons/DefaultButton.js +73 -137
  40. package/lib/buttons/DestroyButton.js +15 -6
  41. package/lib/buttons/EditButton.js +5 -5
  42. package/lib/buttons/InactivateButton.js +5 -5
  43. package/lib/buttons/InfoButton.js +16 -21
  44. package/lib/buttons/PrimaryButton.js +16 -21
  45. package/lib/buttons/RestoreButton.js +5 -5
  46. package/lib/buttons/SaveButton.js +18 -5
  47. package/lib/buttons/SuccessButton.js +15 -20
  48. package/lib/buttons/WarningButton.js +15 -20
  49. package/lib/buttons/button_container/index.js +9 -22
  50. package/lib/buttons/buttons.spec.js +52 -51
  51. package/lib/buttons/index.js +32 -32
  52. package/lib/buttons/split_button/index.js +6 -43
  53. package/lib/buttons/types.js +5 -0
  54. package/lib/calendar/DangerCalendar.js +4 -4
  55. package/lib/calendar/InfoCalendar.js +4 -4
  56. package/lib/calendar/PrimaryCalendar.js +4 -4
  57. package/lib/calendar/SuccessCalendar.js +4 -4
  58. package/lib/calendar/WarningCalendar.js +4 -4
  59. package/lib/calendar/base/Day.js +8 -8
  60. package/lib/calendar/base/Month.js +6 -6
  61. package/lib/calendar/base/Week.js +7 -7
  62. package/lib/calendar/base/helpers.js +13 -13
  63. package/lib/calendar/base/index.js +20 -20
  64. package/lib/calendar/calendar.spec.js +16 -16
  65. package/lib/calendar/index.js +14 -14
  66. package/lib/checkbox/Label.js +7 -17
  67. package/lib/checkbox/checkbox.spec.js +16 -17
  68. package/lib/checkbox/index.js +45 -77
  69. package/lib/checkbox/types.js +5 -0
  70. package/lib/dialog/Alert.js +7 -7
  71. package/lib/dialog/Custom.js +19 -19
  72. package/lib/dialog/Error.js +7 -7
  73. package/lib/dialog/Information.js +7 -7
  74. package/lib/dialog/Question.js +12 -12
  75. package/lib/dialog/Warning.js +7 -7
  76. package/lib/dialog/base/Content.js +6 -6
  77. package/lib/dialog/base/Footer.js +5 -5
  78. package/lib/dialog/base/Header.js +14 -14
  79. package/lib/dialog/base/index.js +18 -18
  80. package/lib/dialog/base/style.js +2 -2
  81. package/lib/dialog/dialog.spec.js +19 -19
  82. package/lib/dialog/form/index.js +24 -24
  83. package/lib/dialog/index.js +15 -15
  84. package/lib/drawer/Content.js +8 -8
  85. package/lib/drawer/Drawer.js +20 -20
  86. package/lib/drawer/Drawer.spec.js +9 -9
  87. package/lib/drawer/Header.js +26 -26
  88. package/lib/drawer/helpers.js +4 -4
  89. package/lib/drawer/index.js +8 -8
  90. package/lib/dropdown/Popup.js +15 -9
  91. package/lib/dropdown/dropdown.spec.js +8 -8
  92. package/lib/dropdown/types.js +5 -0
  93. package/lib/dropdown/withDropdown.js +21 -48
  94. package/lib/fieldset/fieldset.spec.js +3 -3
  95. package/lib/fieldset/index.js +24 -24
  96. package/lib/form/Field.js +24 -24
  97. package/lib/form/FieldArray.js +25 -25
  98. package/lib/form/FieldNumber.js +15 -15
  99. package/lib/form/FieldPeriod.js +22 -22
  100. package/lib/form/form.spec.js +11 -11
  101. package/lib/form/helpers.js +6 -6
  102. package/lib/form/index.js +37 -37
  103. package/lib/form/withFieldHOC.js +14 -14
  104. package/lib/form/withFormSecurity.js +10 -10
  105. package/lib/gridlayout/GridCol.js +9 -9
  106. package/lib/gridlayout/GridRow.js +10 -10
  107. package/lib/gridlayout/gridLayout.spec.js +4 -4
  108. package/lib/gridlayout/index.js +5 -5
  109. package/lib/icons/helper.js +1 -1
  110. package/lib/icons/icons.spec.js +9 -9
  111. package/lib/icons/index.js +28 -45
  112. package/lib/icons/types.js +5 -0
  113. package/lib/index.js +16 -16
  114. package/lib/inputs/base/InputTextBase.js +65 -65
  115. package/lib/inputs/base/base.spec.js +13 -13
  116. package/lib/inputs/base/helpers.js +7 -7
  117. package/lib/inputs/color/color_input.spec.js +4 -4
  118. package/lib/inputs/color/index.js +16 -16
  119. package/lib/inputs/date/Dialog.js +7 -7
  120. package/lib/inputs/date/Dropdown.js +7 -7
  121. package/lib/inputs/date/date.spec.js +5 -5
  122. package/lib/inputs/date/helpers.js +5 -5
  123. package/lib/inputs/date/index.js +33 -33
  124. package/lib/inputs/inputHOC.js +12 -12
  125. package/lib/inputs/mask/BaseMask.js +9 -9
  126. package/lib/inputs/mask/Cnpj.js +10 -10
  127. package/lib/inputs/mask/Cpf.js +10 -10
  128. package/lib/inputs/mask/Phone.js +5 -5
  129. package/lib/inputs/mask/ZipCode.js +4 -4
  130. package/lib/inputs/mask/helpers.js +4 -4
  131. package/lib/inputs/mask/imaskHOC.js +33 -33
  132. package/lib/inputs/mask/index.js +10 -10
  133. package/lib/inputs/mask/input_mask.spec.js +47 -47
  134. package/lib/inputs/multiSelect/ActionButtons.js +13 -13
  135. package/lib/inputs/multiSelect/Dropdown.js +39 -39
  136. package/lib/inputs/multiSelect/helper.js +2 -2
  137. package/lib/inputs/multiSelect/index.js +22 -22
  138. package/lib/inputs/number/BaseNumber.js +8 -8
  139. package/lib/inputs/number/Currency.js +7 -7
  140. package/lib/inputs/number/Decimal.js +4 -4
  141. package/lib/inputs/number/format_number.js +1 -1
  142. package/lib/inputs/number/index.js +8 -8
  143. package/lib/inputs/number/numberfield.spec.js +5 -5
  144. package/lib/inputs/period/Dialog.js +7 -7
  145. package/lib/inputs/period/Dropdown.js +9 -9
  146. package/lib/inputs/period/PeriodList.js +9 -9
  147. package/lib/inputs/period/helper.js +6 -6
  148. package/lib/inputs/period/index.js +50 -52
  149. package/lib/inputs/search/index.js +24 -25
  150. package/lib/inputs/search/search_input.spec.js +4 -4
  151. package/lib/inputs/select/ActionButtons.js +12 -12
  152. package/lib/inputs/select/Dropdown.js +39 -39
  153. package/lib/inputs/select/helper.js +8 -4
  154. package/lib/inputs/select/index.js +7 -7
  155. package/lib/inputs/select/multiple/Selecteds.js +10 -10
  156. package/lib/inputs/select/multiple/index.js +29 -29
  157. package/lib/inputs/select/select.spec.js +11 -11
  158. package/lib/inputs/select/simple/index.js +31 -30
  159. package/lib/inputs/text/index.js +4 -4
  160. package/lib/inputs/text/textfield.spec.js +4 -4
  161. package/lib/inputs/textarea/index.js +7 -7
  162. package/lib/inputs/textarea/textarea.spec.js +2 -2
  163. package/lib/internals/colorStyles.js +2 -2
  164. package/lib/internals/constants.js +1 -1
  165. package/lib/internals/types.js +5 -0
  166. package/lib/internals/withTooltip.js +31 -39
  167. package/lib/labelMessages/index.js +34 -52
  168. package/lib/labelMessages/labelMessages.spec.js +16 -16
  169. package/lib/labelMessages/types.js +5 -0
  170. package/lib/labels/DangerLabel.js +4 -4
  171. package/lib/labels/DefaultLabel.js +22 -22
  172. package/lib/labels/InfoLabel.js +4 -4
  173. package/lib/labels/PrimaryLabel.js +4 -4
  174. package/lib/labels/SuccessLabel.js +4 -4
  175. package/lib/labels/WarningLabel.js +4 -4
  176. package/lib/labels/index.js +15 -15
  177. package/lib/labels/label.spec.js +18 -18
  178. package/lib/labels/label_container/index.js +8 -8
  179. package/lib/list/Header.js +9 -9
  180. package/lib/list/Item.js +45 -43
  181. package/lib/list/Separator.js +4 -4
  182. package/lib/list/helpers.js +5 -10
  183. package/lib/list/index.js +36 -106
  184. package/lib/list/list.spec.js +98 -127
  185. package/lib/menus/float/MenuItem.js +26 -38
  186. package/lib/menus/float/float-menu.spec.js +13 -13
  187. package/lib/menus/float/helpers.js +4 -4
  188. package/lib/menus/float/index.js +16 -26
  189. package/lib/menus/index.js +4 -4
  190. package/lib/menus/sidenav/ExpandMenu.js +8 -8
  191. package/lib/menus/sidenav/MenuLink.js +9 -9
  192. package/lib/menus/sidenav/NavMenuGroup.js +8 -8
  193. package/lib/menus/sidenav/NavMenuItem.js +25 -25
  194. package/lib/menus/sidenav/NavSubMenuItem.js +11 -11
  195. package/lib/menus/sidenav/helpers.js +5 -5
  196. package/lib/menus/sidenav/index.js +34 -34
  197. package/lib/menus/sidenav/popup_menu_search/EmptyList.js +7 -7
  198. package/lib/menus/sidenav/popup_menu_search/index.js +15 -14
  199. package/lib/menus/sidenav/sidenav.spec.js +9 -9
  200. package/lib/noPermission/index.js +7 -7
  201. package/lib/panel/Content.js +11 -11
  202. package/lib/panel/DangerPanel.js +5 -5
  203. package/lib/panel/Default.js +19 -19
  204. package/lib/panel/Header.js +22 -23
  205. package/lib/panel/InfoPanel.js +5 -5
  206. package/lib/panel/PrimaryPanel.js +5 -5
  207. package/lib/panel/SuccessPanel.js +5 -5
  208. package/lib/panel/ToolBar.js +5 -5
  209. package/lib/panel/WarningPanel.js +5 -5
  210. package/lib/panel/helpers.js +4 -4
  211. package/lib/panel/index.js +18 -18
  212. package/lib/panel/panel.spec.js +8 -8
  213. package/lib/permissionValidations.js +2 -2
  214. package/lib/popover/PopoverText.js +5 -5
  215. package/lib/popover/PopoverTitle.js +5 -5
  216. package/lib/popover/index.js +16 -16
  217. package/lib/popover/popover.spec.js +4 -4
  218. package/lib/progress/Bar.js +19 -19
  219. package/lib/progress/index.js +10 -10
  220. package/lib/progress/progress.spec.js +12 -4
  221. package/lib/radio/index.js +26 -50
  222. package/lib/radio/radio.spec.js +8 -8
  223. package/lib/radio/types.js +5 -0
  224. package/lib/skeleton/SkeletonContainer.js +8 -8
  225. package/lib/skeleton/index.js +14 -14
  226. package/lib/spinner/SpinnerLoading.js +43 -43
  227. package/lib/spinner/index.js +15 -15
  228. package/lib/spinner/spinner.spec.js +2 -2
  229. package/lib/split/Split.js +21 -21
  230. package/lib/split/SplitSide.js +13 -13
  231. package/lib/split/helpers.js +4 -4
  232. package/lib/split/index.js +5 -5
  233. package/lib/split/split.spec.js +25 -13
  234. package/lib/table/Body.js +14 -14
  235. package/lib/table/Header.js +13 -13
  236. package/lib/table/HeaderColumn.js +12 -12
  237. package/lib/table/Row.js +15 -15
  238. package/lib/table/RowColumn.js +15 -15
  239. package/lib/table/helpers.js +5 -5
  240. package/lib/table/index.js +36 -36
  241. package/lib/table/table.spec.js +14 -14
  242. package/lib/tabs/DropdownItems.js +14 -14
  243. package/lib/tabs/Menu.js +9 -9
  244. package/lib/tabs/MenuItems.js +16 -16
  245. package/lib/tabs/Panel.js +21 -21
  246. package/lib/tabs/index.js +22 -22
  247. package/lib/tabs/tabHelpers.js +6 -5
  248. package/lib/tabs/tabs.spec.js +45 -73
  249. package/lib/toolbar/ButtonBar.js +30 -21
  250. package/lib/toolbar/LabelBar.js +13 -13
  251. package/lib/toolbar/Separator.js +4 -4
  252. package/lib/toolbar/ToolBarGroup.js +6 -6
  253. package/lib/toolbar/helpers.js +2 -2
  254. package/lib/toolbar/index.js +19 -19
  255. package/lib/toolbar/toolbar.spec.js +10 -10
  256. package/lib/tooltip/index.js +16 -14
  257. package/lib/tooltip/tooltip.spec.js +15 -3
  258. package/lib/treeview/Header.js +8 -8
  259. package/lib/treeview/Node.js +44 -44
  260. package/lib/treeview/constants.js +2 -2
  261. package/lib/treeview/index.js +43 -43
  262. package/lib/treeview/treeview.spec.js +14 -14
  263. package/lib/treeview_old/Header.js +7 -7
  264. package/lib/treeview_old/Node.js +14 -14
  265. package/lib/treeview_old/index.js +9 -9
  266. package/lib/uitour/helpers.js +1 -1
  267. package/lib/uitour/index.js +25 -25
  268. package/lib/uitour/uitour.spec.js +21 -21
  269. package/package.json +36 -10
  270. package/scripts/start.js +135 -0
  271. package/tsconfig.json +17 -0
  272. package/.eslintrc.js +0 -26
  273. package/.husky/pre-commit +0 -4
  274. package/lib/menus/float/SubMenuContainer.js +0 -66
package/.eslintrc.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "extends": "airbnb",
3
+ "env": {
4
+ "browser": true,
5
+ "jest": true
6
+ },
7
+ "parser": "babel-eslint",
8
+ "rules": {
9
+ "indent": "off",
10
+ "no-undef": "off",
11
+ "radix": "off",
12
+ "prefer-destructuring": ["error", {"object": true, "array": false}],
13
+ "react/forbid-prop-types": ["error", { "forbid": ["array"] }],
14
+ "react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
15
+ "react/jsx-closing-bracket-location": ["error", "after-props"],
16
+ "react/no-unused-prop-types": [0],
17
+ "jsx-a11y/anchor-is-valid": [ "error", {
18
+ "components": [ "Link" ],
19
+ "specialLink": [ "hrefLeft", "hrefRight" ],
20
+ "aspects": ["preferButton" ]
21
+ }],
22
+ "jsx-a11y/no-autofocus": [0],
23
+ "object-curly-newline": [0],
24
+ "jsx-a11y/label-has-for": [0],
25
+ "import/extensions": [
26
+ "error",
27
+ "ignorePackages",
28
+ {
29
+ "ts": "never",
30
+ "tsx": "never",
31
+ "js": "never",
32
+ "jsx": "never"
33
+ }
34
+ ]
35
+ },
36
+ "settings": {
37
+ "import/resolver": {
38
+ "node": {
39
+ "extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
40
+ }
41
+ }
42
+ },
43
+ "plugins": [
44
+ "react",
45
+ "class-property"
46
+ ],
47
+ "overrides": [
48
+ {
49
+ "files": ["**/*.ts", "**/*.tsx"],
50
+ "env": {
51
+ "browser": true,
52
+ "jest": true
53
+ },
54
+ "extends": [
55
+ "eslint:recommended",
56
+ "airbnb",
57
+ "airbnb-typescript/base",
58
+ "plugin:@typescript-eslint/eslint-recommended",
59
+ "plugin:@typescript-eslint/recommended"
60
+ ],
61
+ "parser": "@typescript-eslint/parser",
62
+ "parserOptions": {
63
+ "ecmaFeatures": { "jsx": true },
64
+ "ecmaVersion": 2021,
65
+ "sourceType": "module",
66
+ "project": "./tsconfig.json"
67
+ },
68
+ "plugins": ["react", "@typescript-eslint", "class-property"],
69
+ "rules": {
70
+ "react/jsx-indent": "off",
71
+ "@typescript-eslint/indent": ["error", 2],
72
+ "react/jsx-filename-extension": [1, { "extensions": [".ts", ".tsx"] }],
73
+ "prefer-destructuring": ["error", {"object": true, "array": false}],
74
+ "react/forbid-prop-types": ["error", { "forbid": ["array"] }],
75
+ "react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
76
+ "react/jsx-closing-bracket-location": ["error", "after-props"],
77
+ "react/no-unused-prop-types": [0],
78
+ "jsx-a11y/heading-has-content": "off",
79
+ "jsx-a11y/anchor-is-valid": [ "error", {
80
+ "components": [ "Link" ],
81
+ "specialLink": [ "hrefLeft", "hrefRight" ],
82
+ "aspects": ["preferButton" ]
83
+ }],
84
+ "jsx-a11y/no-autofocus": [0],
85
+ "object-curly-newline": [0],
86
+ "jsx-a11y/label-has-for": [0]
87
+ },
88
+ "settings": {
89
+ "import/resolver": {
90
+ "typescript": {}
91
+ }
92
+ }
93
+ }
94
+ ]
95
+ }
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,19 @@
1
+ stages:
2
+ - lint
3
+ - tests-units
4
+
5
+ lint:
6
+ stage: lint
7
+ image: node:12.17
8
+ before_script:
9
+ - npm install
10
+ script:
11
+ - npm run check:js
12
+
13
+ units:
14
+ stage: tests-units
15
+ image: node:12.17
16
+ before_script:
17
+ - npm install
18
+ script:
19
+ - npm run test
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run check:js
@@ -0,0 +1,15 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "pwa-chrome",
9
+ "request": "launch",
10
+ "name": "Launch Chrome against localhost",
11
+ "url": "http://localhost:3001",
12
+ "webRoot": "${workspaceFolder}"
13
+ }
14
+ ]
15
+ }
@@ -7,5 +7,8 @@
7
7
  "yarn.lock": true,
8
8
  ".eslintrc.js": true,
9
9
  ".gitignore": true,
10
+ },
11
+ "editor.codeActionsOnSave": {
12
+ "source.fixAll.eslint": true
10
13
  }
11
14
  }
@@ -0,0 +1,56 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const crypto = require('crypto');
4
+ const chalk = require('react-dev-utils/chalk');
5
+ const paths = require('./paths');
6
+
7
+ // Ensure the certificate and key provided are valid and if not
8
+ // throw an easy to debug error
9
+ function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
10
+ let encrypted;
11
+ try {
12
+ // publicEncrypt will throw an error with an invalid cert
13
+ encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
14
+ } catch (err) {
15
+ throw new Error(`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`);
16
+ }
17
+
18
+ try {
19
+ // privateDecrypt will throw an error with an invalid key
20
+ crypto.privateDecrypt(key, encrypted);
21
+ } catch (err) {
22
+ throw new Error(`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
23
+ err.message
24
+ }`);
25
+ }
26
+ }
27
+
28
+ // Read file and throw an error if it doesn't exist
29
+ function readEnvFile(file, type) {
30
+ if (!fs.existsSync(file)) {
31
+ throw new Error(`You specified ${chalk.cyan(type)} in your env, but the file "${chalk.yellow(file)}" can't be found.`);
32
+ }
33
+ return fs.readFileSync(file);
34
+ }
35
+
36
+ // Get the https config
37
+ // Return cert files if provided in env, otherwise just true or false
38
+ function getHttpsConfig() {
39
+ const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
40
+ const isHttps = HTTPS === 'true';
41
+
42
+ if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
43
+ const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
44
+ const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
45
+ const config = {
46
+ cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
47
+ key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
48
+ };
49
+
50
+ validateKeyAndCerts({ ...config, keyFile, crtFile });
51
+ return config;
52
+ }
53
+ return isHttps;
54
+ }
55
+
56
+ module.exports = getHttpsConfig;
@@ -0,0 +1,140 @@
1
+ /* eslint-disable import/no-dynamic-require */
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ // Make sure any symlinks in the project folder are resolved:
7
+ // https://github.com/facebook/create-react-app/issues/637
8
+ const appDirectory = fs.realpathSync(process.cwd());
9
+ const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
10
+
11
+ // We use `PUBLIC_URL` environment variable or "homepage" field to infer
12
+ // "public path" at which the app is served.
13
+ // webpack needs to know it to put the right <script> hrefs into HTML even in
14
+ // single-page apps that may serve index.html for nested URLs like /todos/42.
15
+ // We can't use a relative path in HTML because we don't want to load something
16
+ // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
17
+ const publicUrlOrPath = '/';
18
+
19
+ const buildPath = process.env.BUILD_PATH || 'build';
20
+
21
+ const moduleFileExtensions = [
22
+ 'web.mjs',
23
+ 'mjs',
24
+ 'web.js',
25
+ 'js',
26
+ 'web.ts',
27
+ 'ts',
28
+ 'web.tsx',
29
+ 'tsx',
30
+ 'json',
31
+ 'web.jsx',
32
+ 'jsx',
33
+ ];
34
+
35
+ // Resolve file paths in the same order as webpack
36
+ const resolveModule = (resolveFn, filePath) => {
37
+ const extension = moduleFileExtensions.find(ext =>
38
+ fs.existsSync(resolveFn(`${filePath}.${ext}`)));
39
+
40
+ if (extension) {
41
+ return resolveFn(`${filePath}.${extension}`);
42
+ }
43
+
44
+ return resolveFn(`${filePath}.js`);
45
+ };
46
+
47
+ // config after eject: we're in ./config/
48
+ module.exports = {
49
+ dotenv: resolveApp('.env'),
50
+ appPath: resolveApp('.'),
51
+ appBuild: resolveApp(buildPath),
52
+ appPublic: resolveApp('src/demo'),
53
+ appHtml: resolveApp('src/demo/index.html'),
54
+ appIndexJs: resolveModule(resolveApp, 'src/demo/index'),
55
+ appPackageJson: resolveApp('package.json'),
56
+ appSrc: resolveApp('src'),
57
+ appTsConfig: resolveApp('tsconfig.json'),
58
+ appJsConfig: resolveApp('jsconfig.json'),
59
+ yarnLockFile: resolveApp('yarn.lock'),
60
+ testsSetup: resolveModule(resolveApp, 'src/setupTests'),
61
+ proxySetup: resolveApp('src/setupProxy.js'),
62
+ appNodeModules: resolveApp('node_modules'),
63
+ appWebpackCache: resolveApp('node_modules/.cache'),
64
+ appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
65
+ swSrc: resolveModule(resolveApp, 'src/service-worker'),
66
+ publicUrlOrPath,
67
+ };
68
+
69
+ // @remove-on-eject-begin
70
+ const resolveOwn = relativePath => path.resolve(__dirname, '..', relativePath);
71
+
72
+ // config before eject: we're in ./node_modules/react-scripts/config/
73
+ module.exports = {
74
+ dotenv: resolveApp('.env'),
75
+ appPath: resolveApp('.'),
76
+ appBuild: resolveApp(buildPath),
77
+ appPublic: resolveApp('src/demo'),
78
+ appHtml: resolveApp('src/demo/index.html'),
79
+ appIndexJs: resolveModule(resolveApp, 'src/demo/index'),
80
+ appPackageJson: resolveApp('package.json'),
81
+ appSrc: resolveApp('src'),
82
+ appTsConfig: resolveApp('tsconfig.json'),
83
+ appJsConfig: resolveApp('jsconfig.json'),
84
+ yarnLockFile: resolveApp('yarn.lock'),
85
+ testsSetup: resolveModule(resolveApp, 'src/setupTests'),
86
+ proxySetup: resolveApp('src/setupProxy.js'),
87
+ appNodeModules: resolveApp('node_modules'),
88
+ appWebpackCache: resolveApp('node_modules/.cache'),
89
+ appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
90
+ swSrc: resolveModule(resolveApp, 'src/service-worker'),
91
+ publicUrlOrPath,
92
+ // These properties only exist before ejecting:
93
+ ownPath: resolveOwn('.'),
94
+ ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
95
+ appTypeDeclarations: resolveApp('src/react-app-env.d.ts'),
96
+ ownTypeDeclarations: resolveOwn('lib/react-app.d.ts'),
97
+ };
98
+
99
+ const ownPackageJson = require('../package.json');
100
+
101
+ const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
102
+ const reactScriptsLinked =
103
+ fs.existsSync(reactScriptsPath) &&
104
+ fs.lstatSync(reactScriptsPath).isSymbolicLink();
105
+
106
+ // config before publish: we're in ./packages/react-scripts/config/
107
+ if (
108
+ !reactScriptsLinked &&
109
+ __dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1
110
+ ) {
111
+ const templatePath = '../cra-template/template';
112
+ module.exports = {
113
+ dotenv: resolveOwn(`${templatePath}/.env`),
114
+ appPath: resolveApp('.'),
115
+ appBuild: resolveOwn(path.join('../..', buildPath)),
116
+ appPublic: resolveOwn(`${templatePath}/public`),
117
+ appHtml: resolveOwn(`${templatePath}/public/index.html`),
118
+ appIndexJs: resolveModule(resolveOwn, `${templatePath}/src/index`),
119
+ appPackageJson: resolveOwn('package.json'),
120
+ appSrc: resolveOwn(`${templatePath}/src`),
121
+ appTsConfig: resolveOwn(`${templatePath}/tsconfig.json`),
122
+ appJsConfig: resolveOwn(`${templatePath}/jsconfig.json`),
123
+ yarnLockFile: resolveOwn(`${templatePath}/yarn.lock`),
124
+ testsSetup: resolveModule(resolveOwn, `${templatePath}/src/setupTests`),
125
+ proxySetup: resolveOwn(`${templatePath}/src/setupProxy.js`),
126
+ appNodeModules: resolveOwn('node_modules'),
127
+ appWebpackCache: resolveOwn('node_modules/.cache'),
128
+ appTsBuildInfoFile: resolveOwn('node_modules/.cache/tsconfig.tsbuildinfo'),
129
+ swSrc: resolveModule(resolveOwn, `${templatePath}/src/service-worker`),
130
+ publicUrlOrPath,
131
+ // These properties only exist before ejecting:
132
+ ownPath: resolveOwn('.'),
133
+ ownNodeModules: resolveOwn('node_modules'),
134
+ appTypeDeclarations: resolveOwn(`${templatePath}/src/react-app-env.d.ts`),
135
+ ownTypeDeclarations: resolveOwn('lib/react-app.d.ts'),
136
+ };
137
+ }
138
+ // @remove-on-eject-end
139
+
140
+ module.exports.moduleFileExtensions = moduleFileExtensions;
@@ -0,0 +1,128 @@
1
+ /* eslint-disable global-require */
2
+ /* eslint-disable import/no-dynamic-require */
3
+
4
+ const fs = require('fs');
5
+ const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
6
+ const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
7
+ const ignoredFiles = require('react-dev-utils/ignoredFiles');
8
+ const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
9
+ const paths = require('./paths');
10
+ const getHttpsConfig = require('./getHttpsConfig');
11
+
12
+ const host = process.env.HOST || '0.0.0.0';
13
+ const sockHost = process.env.WDS_SOCKET_HOST;
14
+ const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
15
+ const sockPort = process.env.WDS_SOCKET_PORT;
16
+
17
+ module.exports = function (proxy, allowedHost) {
18
+ const disableFirewall =
19
+ !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
20
+ return {
21
+ // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
22
+ // websites from potentially accessing local content through DNS rebinding:
23
+ // https://github.com/webpack/webpack-dev-server/issues/887
24
+ // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
25
+ // However, it made several existing use cases such as development in cloud
26
+ // environment or subdomains in development significantly more complicated:
27
+ // https://github.com/facebook/create-react-app/issues/2271
28
+ // https://github.com/facebook/create-react-app/issues/2233
29
+ // While we're investigating better solutions, for now we will take a
30
+ // compromise. Since our WDS configuration only serves files in the `public`
31
+ // folder we won't consider accessing them a vulnerability. However, if you
32
+ // use the `proxy` feature, it gets more dangerous because it can expose
33
+ // remote code execution vulnerabilities in backends like Django and Rails.
34
+ // So we will disable the host check normally, but enable it if you have
35
+ // specified the `proxy` setting. Finally, we let you override it if you
36
+ // really know what you're doing with a special environment variable.
37
+ // Note: ["localhost", ".localhost"] will support subdomains - but we might
38
+ // want to allow setting the allowedHosts manually for more complex setups
39
+ allowedHosts: disableFirewall ? 'all' : [allowedHost],
40
+ headers: {
41
+ 'Access-Control-Allow-Origin': '*',
42
+ 'Access-Control-Allow-Methods': '*',
43
+ 'Access-Control-Allow-Headers': '*',
44
+ },
45
+ // Enable gzip compression of generated files.
46
+ compress: true,
47
+ static: {
48
+ // By default WebpackDevServer serves physical files from current directory
49
+ // in addition to all the virtual build products that it serves from memory.
50
+ // This is confusing because those files won’t automatically be available in
51
+ // production build folder unless we copy them. However, copying the whole
52
+ // project directory is dangerous because we may expose sensitive files.
53
+ // Instead, we establish a convention that only files in `public` directory
54
+ // get served. Our build script will copy `public` into the `build` folder.
55
+ // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
56
+ // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
57
+ // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
58
+ // Note that we only recommend to use `public` folder as an escape hatch
59
+ // for files like `favicon.ico`, `manifest.json`, and libraries that are
60
+ // for some reason broken when imported through webpack. If you just want to
61
+ // use an image, put it in `src` and `import` it from JavaScript instead.
62
+ directory: paths.appPublic,
63
+ publicPath: [paths.publicUrlOrPath],
64
+ // By default files from `contentBase` will not trigger a page reload.
65
+ watch: {
66
+ // Reportedly, this avoids CPU overload on some systems.
67
+ // https://github.com/facebook/create-react-app/issues/293
68
+ // src/node_modules is not ignored to support absolute imports
69
+ // https://github.com/facebook/create-react-app/issues/1065
70
+ ignored: ignoredFiles(paths.appSrc),
71
+ },
72
+ },
73
+ client: {
74
+ webSocketURL: {
75
+ // Enable custom sockjs pathname for websocket connection to hot reloading server.
76
+ // Enable custom sockjs hostname, pathname and port for websocket connection
77
+ // to hot reloading server.
78
+ hostname: sockHost,
79
+ pathname: sockPath,
80
+ port: sockPort,
81
+ },
82
+ overlay: {
83
+ errors: true,
84
+ warnings: false,
85
+ },
86
+ },
87
+ devMiddleware: {
88
+ // It is important to tell WebpackDevServer to use the same "publicPath" path as
89
+ // we specified in the webpack config. When homepage is '.', default to serving
90
+ // from the root.
91
+ // remove last slash so user can land on `/test` instead of `/test/`
92
+ publicPath: paths.publicUrlOrPath.slice(0, -1),
93
+ },
94
+
95
+ https: getHttpsConfig(),
96
+ host,
97
+ historyApiFallback: {
98
+ // Paths with dots should still use the history fallback.
99
+ // See https://github.com/facebook/create-react-app/issues/387.
100
+ disableDotRule: true,
101
+ index: paths.publicUrlOrPath,
102
+ },
103
+ // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
104
+ proxy,
105
+ onBeforeSetupMiddleware(devServer) {
106
+ // Keep `evalSourceMapMiddleware`
107
+ // middlewares before `redirectServedPath` otherwise will not have any effect
108
+ // This lets us fetch source contents from webpack for the error overlay
109
+ devServer.app.use(evalSourceMapMiddleware(devServer));
110
+
111
+ if (fs.existsSync(paths.proxySetup)) {
112
+ // This registers user provided middleware for proxy reasons
113
+ require(paths.proxySetup)(devServer.app);
114
+ }
115
+ },
116
+ onAfterSetupMiddleware(devServer) {
117
+ // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
118
+ devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
119
+
120
+ // This service worker file is effectively a 'no-op' that will reset any
121
+ // previous service worker registered for the same host:port combination.
122
+ // We do this in development to avoid hitting the production cache if
123
+ // it used the same host and port.
124
+ // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
125
+ devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
126
+ },
127
+ };
128
+ };
package/jest.config.js CHANGED
@@ -1,12 +1,12 @@
1
1
  module.exports = {
2
2
  roots: ['<rootDir>'],
3
3
  transform: {
4
- '\\.(js|jsx)?$': 'babel-jest',
4
+ '\\.(js|jsx|tsx|ts)?$': 'babel-jest',
5
5
  },
6
6
  testMatch: [
7
- '<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}',
7
+ '<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx,mjs}',
8
8
  ],
9
- moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
9
+ moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
10
10
  testPathIgnorePatterns: ['/node_modules/', '/public/'],
11
11
  setupFilesAfterEnv: [
12
12
  '@testing-library/jest-dom/extend-expect',
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
9
9
 
@@ -135,4 +135,4 @@ var AlertContainer = /*#__PURE__*/function () {
135
135
  }();
136
136
 
137
137
  var _default2 = AlertContainer;
138
- exports["default"] = _default2;
138
+ exports.default = _default2;
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = void 0;
8
+ exports.default = void 0;
9
9
 
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
 
@@ -21,11 +21,11 @@ var _Message = _interopRequireDefault(require("./Message"));
21
21
 
22
22
  var _helpers = _interopRequireDefault(require("./helpers"));
23
23
 
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
27
 
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
29
 
30
30
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
31
 
@@ -37,7 +37,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
37
37
 
38
38
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
39
39
 
40
- function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
40
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
41
41
 
42
42
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
43
 
@@ -79,7 +79,7 @@ var AlertProvider = function AlertProvider(props) {
79
79
 
80
80
  var buildAlertMessage = function buildAlertMessage(values) {
81
81
  return values.map(function (value) {
82
- return /*#__PURE__*/_react["default"].createElement(_Message["default"], _extends({}, value, {
82
+ return /*#__PURE__*/_react.default.createElement(_Message.default, _extends({}, value, {
83
83
  handleClose: removeAlert,
84
84
  key: value.id
85
85
  }));
@@ -87,15 +87,15 @@ var AlertProvider = function AlertProvider(props) {
87
87
  };
88
88
 
89
89
  var contextValues = {
90
- alert: new _AlertContainer["default"](pushAlert)
90
+ alert: new _AlertContainer.default(pushAlert)
91
91
  };
92
92
 
93
93
  var renderBaseContainer = function renderBaseContainer() {
94
94
  var elements = [];
95
95
 
96
- _lodash["default"].forEach(messages, function (values, key) {
96
+ _lodash.default.forEach(messages, function (values, key) {
97
97
  if (values.length > 0) {
98
- var messageAlert = /*#__PURE__*/_react["default"].createElement("div", {
98
+ var messageAlert = /*#__PURE__*/_react.default.createElement("div", {
99
99
  className: key.toLowerCase(),
100
100
  key: key
101
101
  }, buildAlertMessage(values));
@@ -106,16 +106,16 @@ var AlertProvider = function AlertProvider(props) {
106
106
  }
107
107
  });
108
108
 
109
- return /*#__PURE__*/_react["default"].createElement(_helpers["default"].Provider, {
109
+ return /*#__PURE__*/_react.default.createElement(_helpers.default.Provider, {
110
110
  value: contextValues
111
- }, /*#__PURE__*/_react["default"].createElement(_BaseAlert["default"], null, elements), children);
111
+ }, /*#__PURE__*/_react.default.createElement(_BaseAlert.default, null, elements), children);
112
112
  };
113
113
 
114
114
  return _react.Children.only(renderBaseContainer());
115
115
  };
116
116
 
117
117
  AlertProvider.propTypes = {
118
- children: _propTypes["default"].object.isRequired
118
+ children: _propTypes.default.object.isRequired
119
119
  };
120
120
  var _default = AlertProvider;
121
- exports["default"] = _default;
121
+ exports.default = _default;