carbon-react 109.2.2 → 109.3.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 (89) hide show
  1. package/esm/__internal__/field-help/field-help.component.d.ts +10 -0
  2. package/esm/__internal__/field-help/field-help.component.js +12 -16
  3. package/esm/__internal__/field-help/field-help.style.d.ts +8 -0
  4. package/esm/__internal__/field-help/field-help.style.js +2 -10
  5. package/esm/__internal__/field-help/index.d.ts +2 -1
  6. package/esm/__internal__/focus-trap/focus-trap-utils.d.ts +1 -2
  7. package/esm/__internal__/focus-trap/focus-trap-utils.js +57 -8
  8. package/esm/__internal__/focus-trap/focus-trap.component.js +35 -25
  9. package/esm/__internal__/validations/validation-icon.component.js +1 -1
  10. package/esm/__spec_helper__/index.d.ts +1 -0
  11. package/esm/__spec_helper__/index.js +4 -10
  12. package/esm/__spec_helper__/mock-match-media.d.ts +2 -2
  13. package/esm/__spec_helper__/mock-match-media.js +2 -2
  14. package/esm/__spec_helper__/mock-resize-observer.d.ts +2 -0
  15. package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -1
  16. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
  17. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
  18. package/esm/components/action-popover/action-popover.component.js +1 -1
  19. package/esm/components/alert/alert.component.js +9 -0
  20. package/esm/components/anchor-navigation/anchor-navigation.component.js +2 -2
  21. package/esm/components/button/button.component.js +2 -2
  22. package/esm/components/button-bar/button-bar.component.js +1 -1
  23. package/esm/components/decimal/decimal.component.js +3 -3
  24. package/esm/components/dialog/dialog.component.js +9 -2
  25. package/esm/components/dialog/dialog.d.ts +2 -0
  26. package/esm/components/dialog-full-screen/dialog-full-screen.component.js +9 -2
  27. package/esm/components/dialog-full-screen/dialog-full-screen.d.ts +2 -0
  28. package/esm/components/drawer/drawer.component.js +1 -1
  29. package/esm/components/icon/icon.component.js +1 -1
  30. package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -0
  31. package/esm/components/note/note.component.js +6 -6
  32. package/esm/components/numeral-date/numeral-date.component.js +1 -1
  33. package/esm/components/search/search.component.js +1 -1
  34. package/esm/components/select/filterable-select/filterable-select.component.js +3 -3
  35. package/esm/components/select/multi-select/multi-select.component.js +2 -2
  36. package/esm/components/select/simple-select/simple-select.component.js +2 -2
  37. package/esm/components/sidebar/sidebar.component.js +9 -2
  38. package/esm/components/sidebar/sidebar.d.ts +2 -0
  39. package/esm/components/toast/toast.component.js +35 -9
  40. package/esm/components/toast/toast.d.ts +5 -1
  41. package/esm/components/tooltip/tooltip.component.js +1 -1
  42. package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +39 -37
  43. package/lib/__internal__/field-help/field-help.component.d.ts +10 -0
  44. package/lib/__internal__/field-help/field-help.component.js +12 -16
  45. package/lib/__internal__/field-help/field-help.style.d.ts +8 -0
  46. package/lib/__internal__/field-help/field-help.style.js +2 -13
  47. package/lib/__internal__/field-help/index.d.ts +2 -1
  48. package/lib/__internal__/focus-trap/focus-trap-utils.d.ts +1 -2
  49. package/lib/__internal__/focus-trap/focus-trap-utils.js +57 -10
  50. package/lib/__internal__/focus-trap/focus-trap.component.js +34 -24
  51. package/lib/__internal__/validations/validation-icon.component.js +1 -1
  52. package/lib/__spec_helper__/index.d.ts +1 -0
  53. package/lib/__spec_helper__/index.js +3 -10
  54. package/lib/__spec_helper__/mock-match-media.d.ts +2 -2
  55. package/lib/__spec_helper__/mock-match-media.js +4 -4
  56. package/lib/__spec_helper__/mock-resize-observer.d.ts +2 -0
  57. package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -1
  58. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
  59. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
  60. package/lib/components/action-popover/action-popover.component.js +1 -1
  61. package/lib/components/alert/alert.component.js +9 -0
  62. package/lib/components/anchor-navigation/anchor-navigation.component.js +2 -2
  63. package/lib/components/button/button.component.js +2 -2
  64. package/lib/components/button-bar/button-bar.component.js +1 -1
  65. package/lib/components/decimal/decimal.component.js +3 -3
  66. package/lib/components/dialog/dialog.component.js +9 -2
  67. package/lib/components/dialog/dialog.d.ts +2 -0
  68. package/lib/components/dialog-full-screen/dialog-full-screen.component.js +9 -2
  69. package/lib/components/dialog-full-screen/dialog-full-screen.d.ts +2 -0
  70. package/lib/components/drawer/drawer.component.js +1 -1
  71. package/lib/components/icon/icon.component.js +1 -1
  72. package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -0
  73. package/lib/components/note/note.component.js +6 -6
  74. package/lib/components/numeral-date/numeral-date.component.js +1 -1
  75. package/lib/components/search/search.component.js +1 -1
  76. package/lib/components/select/filterable-select/filterable-select.component.js +3 -3
  77. package/lib/components/select/multi-select/multi-select.component.js +2 -2
  78. package/lib/components/select/simple-select/simple-select.component.js +2 -2
  79. package/lib/components/sidebar/sidebar.component.js +9 -2
  80. package/lib/components/sidebar/sidebar.d.ts +2 -0
  81. package/lib/components/toast/toast.component.js +35 -7
  82. package/lib/components/toast/toast.d.ts +5 -1
  83. package/lib/components/tooltip/tooltip.component.js +1 -1
  84. package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +38 -36
  85. package/package.json +19 -17
  86. package/scripts/{check_carbon_version.js → check_carbon_version/check_carbon_version.js} +10 -2
  87. package/scripts/{check_rfcs.js → check_rfcs/check_rfcs.js} +8 -1
  88. package/esm/__internal__/field-help/field-help.d.ts +0 -14
  89. package/lib/__internal__/field-help/field-help.d.ts +0 -14
@@ -17,51 +17,53 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  // we can confirm that all Sage products use version 105.0.0^
18
18
  const scrollBlockManager = new _scrollBlockManager.default();
19
19
 
20
+ const getRules = () => {
21
+ /* istanbul ignore next */
22
+ const {
23
+ documentElement,
24
+ body
25
+ } = document || {};
26
+ const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
27
+ const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
28
+ return [// TODO: First two entries of this array with the documentElement can be removed
29
+ {
30
+ element: documentElement,
31
+ property: "position",
32
+ blockingValue: "relative"
33
+ }, {
34
+ element: documentElement,
35
+ property: "overflow",
36
+ blockingValue: "hidden"
37
+ }, {
38
+ element: body,
39
+ property: "position",
40
+ blockingValue: "relative"
41
+ }, {
42
+ element: body,
43
+ property: "overflow",
44
+ blockingValue: "hidden"
45
+ }, {
46
+ element: body,
47
+ property: "paddingRight",
48
+ blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
49
+ }];
50
+ };
51
+
20
52
  const useScrollBlock = () => {
21
53
  const {
22
54
  current: containerGuid
23
55
  } = (0, _react.useRef)((0, _guid.default)());
24
56
  const originalValuesRef = (0, _react.useRef)([]);
25
- const rules = (0, _react.useMemo)(() => {
26
- /* istanbul ignore next */
27
- const {
28
- documentElement,
29
- body
30
- } = document || {};
31
- const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
32
- const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
33
- return [// TODO: First two entries of this array with the documentElement can be removed
34
- {
35
- element: documentElement,
36
- property: "position",
37
- blockingValue: "relative"
38
- }, {
39
- element: documentElement,
40
- property: "overflow",
41
- blockingValue: "hidden"
42
- }, {
43
- element: body,
44
- property: "position",
45
- blockingValue: "relative"
46
- }, {
47
- element: body,
48
- property: "overflow",
49
- blockingValue: "hidden"
50
- }, {
51
- element: body,
52
- property: "paddingRight",
53
- blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
54
- }];
55
- }, []);
56
57
  const restoreValues = (0, _react.useCallback)(() => {
57
- rules.forEach(({
58
+ getRules().forEach(({
58
59
  element,
59
60
  property
60
61
  }, index) => {
61
62
  element.style[property] = originalValuesRef.current[index];
62
63
  });
63
- }, [rules]);
64
+ }, []);
64
65
  const blockScroll = (0, _react.useCallback)(() => {
66
+ const rules = getRules();
65
67
  const isBlocked = scrollBlockManager.isBlocked();
66
68
  scrollBlockManager.registerComponent(containerGuid);
67
69
 
@@ -85,7 +87,7 @@ const useScrollBlock = () => {
85
87
  }) => {
86
88
  element.style[property] = blockingValue;
87
89
  });
88
- }, [restoreValues, containerGuid, rules]);
90
+ }, [restoreValues, containerGuid]);
89
91
  const allowScroll = (0, _react.useCallback)(() => {
90
92
  scrollBlockManager.unregisterComponent(containerGuid);
91
93
  const isBlocked = scrollBlockManager.isBlocked();
@@ -100,14 +102,14 @@ const useScrollBlock = () => {
100
102
 
101
103
 
102
104
  const originalValues = scrollBlockManager.getOriginalValues();
103
- rules.forEach(({
105
+ getRules().forEach(({
104
106
  element,
105
107
  property
106
108
  }, index) => {
107
109
  element.style[property] = originalValues[index];
108
110
  });
109
111
  scrollBlockManager.saveOriginalValues([]);
110
- }, [containerGuid, rules]);
112
+ }, [containerGuid]);
111
113
  return {
112
114
  blockScroll,
113
115
  allowScroll
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "109.2.2",
3
+ "version": "109.3.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -10,24 +10,23 @@
10
10
  "files": [
11
11
  "lib",
12
12
  "esm",
13
- "scripts/check_carbon_version.js",
14
- "scripts/check_rfcs.js"
13
+ "scripts/check_carbon_version/check_carbon_version.js",
14
+ "scripts/check_rfcs/check_rfcs.js"
15
15
  ],
16
16
  "scripts": {
17
17
  "start": "node ./scripts/check_node_version.js && start-storybook -p 9001 -c .storybook",
18
18
  "start:debug-theme": "cross-env STORYBOOK_DEBUG_THEME=true npm run start",
19
- "test": "jest --config=./jest.conf.json",
20
- "test-update": "jest --config=./jest.conf.json --updateSnapshot",
19
+ "test": "jest --config=./jest.config.json",
20
+ "test-update": "jest --config=./jest.config.json --updateSnapshot",
21
21
  "test:cypress": "npx cypress open --e2e",
22
22
  "cypress:react": "npx cypress open --component",
23
- "debug": "node --inspect ./node_modules/jest-cli/bin/jest --watch --config=./jest.conf.json",
24
23
  "format": "prettier --write './src'",
25
24
  "lint": "eslint ./src",
26
25
  "build": "node ./scripts/build.js",
27
26
  "copy-files": "node ./scripts/copy-files.js",
28
27
  "precompile": "npm run type-check && npm run clean-lib && npm run build && npm run build:types && npm run copy-files",
29
28
  "prepublishOnly": "npm run precompile",
30
- "postinstall": "node ./scripts/check_carbon_version.js && node ./scripts/check_rfcs.js",
29
+ "postinstall": "node ./scripts/check_carbon_version/check_carbon_version.js && node ./scripts/check_rfcs/check_rfcs.js",
31
30
  "watch": "npm run clean-lib && npm run copy-files -- --watch & npm run babel -- --watch",
32
31
  "build-storybook": "cross-env STORYBOOK_BUILD=true build-storybook -c .storybook",
33
32
  "start-storybook": "cross-env STORYBOOK_BUILD=true start-storybook -c .storybook",
@@ -109,6 +108,7 @@
109
108
  "axe-core": "^3.5.5",
110
109
  "babel-eslint": "10.0.3",
111
110
  "babel-jest": "^26.6.3",
111
+ "babel-plugin-dev-expression": "^0.2.3",
112
112
  "browserslist": "^4.16.6",
113
113
  "chalk": "^4.1.1",
114
114
  "chromatic": "^6.0.5",
@@ -117,9 +117,8 @@
117
117
  "core-js": "^3.20.3",
118
118
  "cross-env": "^5.2.0",
119
119
  "css-loader": "4.0.0",
120
- "cypress": "^10.1.0",
121
- "cypress-axe": "^0.14.0",
122
- "cypress-cucumber-preprocessor": "^4.3.1",
120
+ "cypress": "^10.3.0",
121
+ "cypress-axe": "^1.0.0",
123
122
  "cypress-each": "^1.11.0",
124
123
  "cypress-plugin-tab": "^1.0.5",
125
124
  "cypress-real-events": "^1.7.0",
@@ -151,6 +150,7 @@
151
150
  "jest-styled-components": "^6.3.1",
152
151
  "lint-staged": "^10.5.3",
153
152
  "mockdate": "^2.0.2",
153
+ "nock": "^13.2.8",
154
154
  "prettier": "^2.1.2",
155
155
  "raf": "^3.4.0",
156
156
  "react": "^17.0.2",
@@ -169,15 +169,19 @@
169
169
  "webpack-dev-server": "^4.0.0"
170
170
  },
171
171
  "dependencies": {
172
+ "@badeball/cypress-cucumber-preprocessor": "^11.4.0",
173
+ "@bahmutov/cypress-esbuild-preprocessor": "^2.1.3",
172
174
  "@octokit/rest": "^18.12.0",
173
175
  "@popperjs/core": "^2.11.5",
174
176
  "@styled-system/prop-types": "^5.1.5",
175
177
  "@tippyjs/react": "^4.2.5",
176
178
  "@types/styled-system": "^5.1.11",
179
+ "ci-info": "^3.3.2",
177
180
  "classnames": "~2.2.6",
178
181
  "crypto-js": "~3.3.0",
179
182
  "date-fns": "^2.26.0",
180
183
  "dotenv": "^10.0.0",
184
+ "esbuild": "^0.14.47",
181
185
  "immutable": "~3.8.2",
182
186
  "invariant": "^2.2.4",
183
187
  "lodash": "^4.17.20",
@@ -193,13 +197,11 @@
193
197
  "wait-on": "^5.2.1"
194
198
  },
195
199
  "cypress-cucumber-preprocessor": {
196
- "step_definitions": "cypress/support/step-definitions/",
197
- "cucumberJson": {
198
- "generate": false,
199
- "outputFolder": "cypress/cucumber-json",
200
- "filePrefix": "",
201
- "fileSuffix": ".cucumber"
202
- }
200
+ "nonGlobalStepDefinitions": true,
201
+ "stepDefinitions": [
202
+ "cypress/support/step-definitions/*.{js,ts}",
203
+ "cypress/support/helper.js"
204
+ ]
203
205
  },
204
206
  "config": {
205
207
  "commitizen": {
@@ -2,12 +2,17 @@
2
2
  const fetch = require("node-fetch");
3
3
  const dotenv = require("dotenv");
4
4
  const chalk = require("chalk");
5
- const { version } = require("../package.json");
5
+ const ci = require("ci-info");
6
+ const { version } = require("../../package.json");
6
7
 
7
8
  dotenv.config();
8
9
  const majorVersion = version.split(".")[0];
9
10
 
10
11
  const checkCarbonVersion = () => {
12
+ if (ci.BITRISE) {
13
+ return;
14
+ }
15
+
11
16
  fetch("https://registry.npmjs.com/carbon-react")
12
17
  .then((res) => res.json())
13
18
  .then((data) => {
@@ -16,6 +21,7 @@ const checkCarbonVersion = () => {
16
21
 
17
22
  const diff = Number(latestMajor) - Number(majorVersion);
18
23
 
24
+ // This is ignored as coverage will fail when run in CI without it
19
25
  if (diff > 1) {
20
26
  console.log(
21
27
  `carbon-react version installed is currently ${chalk.yellow(
@@ -27,4 +33,6 @@ const checkCarbonVersion = () => {
27
33
  .catch((err) => console.log(err));
28
34
  };
29
35
 
30
- if (!process.env.CARBON_INSTALL) checkCarbonVersion();
36
+ checkCarbonVersion();
37
+
38
+ module.exports = checkCarbonVersion;
@@ -2,6 +2,7 @@
2
2
  const { Octokit } = require("@octokit/rest");
3
3
  const dotenv = require("dotenv");
4
4
  const chalk = require("chalk");
5
+ const ci = require("ci-info");
5
6
 
6
7
  dotenv.config();
7
8
  const octokit = new Octokit({
@@ -33,6 +34,10 @@ const getOpenRfcs = async () => {
33
34
  const getRfcTitle = (rfc) => rfc.title.split(": ")[1];
34
35
 
35
36
  const checkRfcs = async () => {
37
+ if (ci.BITRISE) {
38
+ return;
39
+ }
40
+
36
41
  const openRfcs = await getOpenRfcs();
37
42
 
38
43
  if (openRfcs.length > 0) {
@@ -46,4 +51,6 @@ const checkRfcs = async () => {
46
51
  }
47
52
  };
48
53
 
49
- if (!process.env.CARBON_INSTALL) checkRfcs();
54
+ checkRfcs();
55
+
56
+ module.exports = checkRfcs;
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface FieldHelpProps {
4
- /** Child elements */
5
- children?: React.ReactNode;
6
- /** When true, label is placed in line an input */
7
- labelInline?: boolean;
8
- /** Width of a label in percentage. Works only when labelInline is true */
9
- labelWidth?: number;
10
- }
11
-
12
- declare function FieldHelp(props: FieldHelpProps): JSX.Element;
13
-
14
- export default FieldHelp;
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface FieldHelpProps {
4
- /** Child elements */
5
- children?: React.ReactNode;
6
- /** When true, label is placed in line an input */
7
- labelInline?: boolean;
8
- /** Width of a label in percentage. Works only when labelInline is true */
9
- labelWidth?: number;
10
- }
11
-
12
- declare function FieldHelp(props: FieldHelpProps): JSX.Element;
13
-
14
- export default FieldHelp;