carbon-react 106.7.0 → 107.1.1

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 (205) hide show
  1. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +12 -0
  2. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.js +43 -0
  3. package/esm/__internal__/click-away-wrapper/index.d.ts +2 -0
  4. package/esm/__internal__/click-away-wrapper/index.js +1 -0
  5. package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
  6. package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
  7. package/esm/components/badge/badge.style.d.ts +1 -1
  8. package/esm/components/button/button.component.d.ts +1 -3
  9. package/esm/components/button/button.component.js +1 -12
  10. package/esm/components/button/button.style.d.ts +1 -1
  11. package/esm/components/button-toggle-group/button-toggle-group.component.js +1 -1
  12. package/esm/components/confirm/confirm.component.d.ts +1 -5
  13. package/esm/components/confirm/confirm.component.js +2 -14
  14. package/esm/components/confirm/confirm.d.ts +0 -2
  15. package/esm/components/date/date.component.js +19 -20
  16. package/esm/components/date/date.d.ts +10 -1
  17. package/esm/components/date/index.d.ts +1 -0
  18. package/esm/components/date-range/date-range.d.ts +3 -3
  19. package/esm/components/date-range/index.d.ts +1 -0
  20. package/esm/components/dialog-full-screen/content.style.js +4 -10
  21. package/esm/components/heading/heading.component.d.ts +27 -52
  22. package/esm/components/heading/heading.component.js +86 -170
  23. package/esm/components/heading/heading.d.ts +5 -3
  24. package/esm/components/i18n-provider/i18n-provider.component.d.ts +0 -9
  25. package/esm/components/i18n-provider/i18n-provider.component.js +0 -9
  26. package/esm/components/menu/__internal__/submenu/submenu.component.js +11 -17
  27. package/esm/components/menu/index.d.ts +0 -1
  28. package/esm/components/menu/index.js +0 -1
  29. package/esm/components/menu/menu-item/menu-item.component.js +0 -6
  30. package/esm/components/multi-action-button/multi-action-button.component.d.ts +1 -1
  31. package/esm/components/multi-action-button/multi-action-button.component.js +1 -11
  32. package/esm/components/navigation-bar/navigation-bar.component.d.ts +1 -6
  33. package/esm/components/navigation-bar/navigation-bar.component.js +1 -15
  34. package/esm/components/navigation-bar/navigation-bar.style.d.ts +0 -4
  35. package/esm/components/navigation-bar/navigation-bar.style.js +0 -8
  36. package/esm/components/popover-container/popover-container.component.js +16 -3
  37. package/esm/components/radio-button/radio-button-group.component.js +1 -1
  38. package/esm/components/select/select-list/select-list.component.js +2 -2
  39. package/esm/components/simple-color-picker/simple-color-picker.component.js +1 -1
  40. package/esm/components/split-button/split-button-toggle.style.d.ts +1 -1
  41. package/esm/components/split-button/split-button.component.d.ts +1 -4
  42. package/esm/components/split-button/split-button.component.js +3 -16
  43. package/esm/components/split-button/split-button.d.ts +0 -2
  44. package/esm/components/tile/tile.component.d.ts +1 -2
  45. package/esm/components/tile/tile.component.js +1 -13
  46. package/esm/components/tile/tile.d.ts +0 -2
  47. package/esm/components/tile-select/tile-select-group.component.js +1 -1
  48. package/esm/components/toast/toast.component.d.ts +1 -4
  49. package/esm/components/toast/toast.component.js +1 -13
  50. package/esm/components/toast/toast.d.ts +0 -2
  51. package/esm/locales/en-gb.js +0 -9
  52. package/esm/locales/locale.d.ts +0 -9
  53. package/esm/locales/pl-pl.js +0 -9
  54. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +12 -0
  55. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.js +59 -0
  56. package/lib/__internal__/click-away-wrapper/index.d.ts +2 -0
  57. package/lib/{components/menu/submenu-block → __internal__/click-away-wrapper}/index.js +2 -2
  58. package/lib/{components/scrollable-list → __internal__/click-away-wrapper}/package.json +1 -1
  59. package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
  60. package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
  61. package/lib/components/badge/badge.style.d.ts +1 -1
  62. package/lib/components/button/button.component.d.ts +1 -3
  63. package/lib/components/button/button.component.js +1 -14
  64. package/lib/components/button/button.style.d.ts +1 -1
  65. package/lib/components/button-toggle-group/button-toggle-group.component.js +1 -1
  66. package/lib/components/confirm/confirm.component.d.ts +1 -5
  67. package/lib/components/confirm/confirm.component.js +2 -17
  68. package/lib/components/confirm/confirm.d.ts +0 -2
  69. package/lib/components/date/date.component.js +20 -20
  70. package/lib/components/date/date.d.ts +10 -1
  71. package/lib/components/date/index.d.ts +1 -0
  72. package/lib/components/date-range/date-range.d.ts +3 -3
  73. package/lib/components/date-range/index.d.ts +1 -0
  74. package/lib/components/dialog-full-screen/content.style.js +4 -10
  75. package/lib/components/heading/heading.component.d.ts +27 -52
  76. package/lib/components/heading/heading.component.js +86 -170
  77. package/lib/components/heading/heading.d.ts +5 -3
  78. package/lib/components/i18n-provider/i18n-provider.component.d.ts +0 -9
  79. package/lib/components/i18n-provider/i18n-provider.component.js +0 -9
  80. package/lib/components/menu/__internal__/submenu/submenu.component.js +12 -17
  81. package/lib/components/menu/index.d.ts +0 -1
  82. package/lib/components/menu/index.js +0 -8
  83. package/lib/components/menu/menu-item/menu-item.component.js +0 -7
  84. package/lib/components/multi-action-button/multi-action-button.component.d.ts +1 -1
  85. package/lib/components/multi-action-button/multi-action-button.component.js +1 -14
  86. package/lib/components/navigation-bar/navigation-bar.component.d.ts +1 -6
  87. package/lib/components/navigation-bar/navigation-bar.component.js +1 -18
  88. package/lib/components/navigation-bar/navigation-bar.style.d.ts +0 -4
  89. package/lib/components/navigation-bar/navigation-bar.style.js +0 -8
  90. package/lib/components/popover-container/popover-container.component.js +17 -3
  91. package/lib/components/radio-button/radio-button-group.component.js +1 -1
  92. package/lib/components/select/select-list/select-list.component.js +2 -2
  93. package/lib/components/simple-color-picker/simple-color-picker.component.js +1 -1
  94. package/lib/components/split-button/split-button-toggle.style.d.ts +1 -1
  95. package/lib/components/split-button/split-button.component.d.ts +1 -4
  96. package/lib/components/split-button/split-button.component.js +3 -18
  97. package/lib/components/split-button/split-button.d.ts +0 -2
  98. package/lib/components/tile/tile.component.d.ts +1 -2
  99. package/lib/components/tile/tile.component.js +1 -16
  100. package/lib/components/tile/tile.d.ts +0 -2
  101. package/lib/components/tile-select/tile-select-group.component.js +1 -1
  102. package/lib/components/toast/toast.component.d.ts +1 -4
  103. package/lib/components/toast/toast.component.js +1 -16
  104. package/lib/components/toast/toast.d.ts +0 -2
  105. package/lib/locales/en-gb.js +0 -9
  106. package/lib/locales/locale.d.ts +0 -9
  107. package/lib/locales/pl-pl.js +0 -9
  108. package/package.json +1 -1
  109. package/esm/components/app-wrapper/app-wrapper.component.d.ts +0 -25
  110. package/esm/components/app-wrapper/app-wrapper.component.js +0 -104
  111. package/esm/components/app-wrapper/app-wrapper.d.ts +0 -12
  112. package/esm/components/app-wrapper/app-wrapper.style.d.ts +0 -2
  113. package/esm/components/app-wrapper/app-wrapper.style.js +0 -17
  114. package/esm/components/app-wrapper/index.d.ts +0 -1
  115. package/esm/components/app-wrapper/index.js +0 -1
  116. package/esm/components/menu/submenu-block/index.d.ts +0 -2
  117. package/esm/components/menu/submenu-block/index.js +0 -1
  118. package/esm/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
  119. package/esm/components/menu/submenu-block/submenu-block.component.js +0 -34
  120. package/esm/components/menu/submenu-block/submenu-block.d.ts +0 -12
  121. package/esm/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
  122. package/esm/components/menu/submenu-block/submenu-block.style.js +0 -16
  123. package/esm/components/mount-in-app/__spec__.d.ts +0 -1
  124. package/esm/components/mount-in-app/__spec__.js +0 -47
  125. package/esm/components/mount-in-app/index.d.ts +0 -1
  126. package/esm/components/mount-in-app/mount-in-app.d.ts +0 -12
  127. package/esm/components/mount-in-app/mount-in-app.js +0 -90
  128. package/esm/components/mount-in-app/package.json +0 -3
  129. package/esm/components/multi-step-wizard/__spec__.d.ts +0 -1
  130. package/esm/components/multi-step-wizard/__spec__.js +0 -191
  131. package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
  132. package/esm/components/multi-step-wizard/multi-step-wizard.js +0 -383
  133. package/esm/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
  134. package/esm/components/multi-step-wizard/multi-step-wizard.style.js +0 -10
  135. package/esm/components/multi-step-wizard/package.json +0 -4
  136. package/esm/components/multi-step-wizard/step/__spec__.d.ts +0 -1
  137. package/esm/components/multi-step-wizard/step/__spec__.js +0 -399
  138. package/esm/components/multi-step-wizard/step/package.json +0 -4
  139. package/esm/components/multi-step-wizard/step/step.d.ts +0 -166
  140. package/esm/components/multi-step-wizard/step/step.js +0 -407
  141. package/esm/components/multi-step-wizard/step/step.style.d.ts +0 -13
  142. package/esm/components/multi-step-wizard/step/step.style.js +0 -138
  143. package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
  144. package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -10
  145. package/esm/components/scrollable-list/index.d.ts +0 -4
  146. package/esm/components/scrollable-list/index.js +0 -4
  147. package/esm/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
  148. package/esm/components/scrollable-list/scrollable-list-item.component.js +0 -26
  149. package/esm/components/scrollable-list/scrollable-list.component.d.ts +0 -52
  150. package/esm/components/scrollable-list/scrollable-list.component.js +0 -306
  151. package/esm/components/scrollable-list/scrollable-list.context.d.ts +0 -3
  152. package/esm/components/scrollable-list/scrollable-list.context.js +0 -2
  153. package/esm/components/scrollable-list/scrollable-list.style.d.ts +0 -2
  154. package/esm/components/scrollable-list/scrollable-list.style.js +0 -30
  155. package/esm/components/scrollable-list/test-utils.d.ts +0 -2
  156. package/esm/components/scrollable-list/test-utils.js +0 -25
  157. package/lib/components/app-wrapper/app-wrapper.component.d.ts +0 -25
  158. package/lib/components/app-wrapper/app-wrapper.component.js +0 -120
  159. package/lib/components/app-wrapper/app-wrapper.d.ts +0 -12
  160. package/lib/components/app-wrapper/app-wrapper.style.d.ts +0 -2
  161. package/lib/components/app-wrapper/app-wrapper.style.js +0 -28
  162. package/lib/components/app-wrapper/index.d.ts +0 -1
  163. package/lib/components/app-wrapper/index.js +0 -15
  164. package/lib/components/app-wrapper/package.json +0 -6
  165. package/lib/components/menu/submenu-block/index.d.ts +0 -2
  166. package/lib/components/menu/submenu-block/package.json +0 -6
  167. package/lib/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
  168. package/lib/components/menu/submenu-block/submenu-block.component.js +0 -53
  169. package/lib/components/menu/submenu-block/submenu-block.d.ts +0 -12
  170. package/lib/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
  171. package/lib/components/menu/submenu-block/submenu-block.style.js +0 -33
  172. package/lib/components/mount-in-app/__spec__.d.ts +0 -1
  173. package/lib/components/mount-in-app/__spec__.js +0 -55
  174. package/lib/components/mount-in-app/index.d.ts +0 -1
  175. package/lib/components/mount-in-app/mount-in-app.d.ts +0 -12
  176. package/lib/components/mount-in-app/mount-in-app.js +0 -105
  177. package/lib/components/mount-in-app/package.json +0 -3
  178. package/lib/components/multi-step-wizard/__spec__.d.ts +0 -1
  179. package/lib/components/multi-step-wizard/__spec__.js +0 -202
  180. package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
  181. package/lib/components/multi-step-wizard/multi-step-wizard.js +0 -397
  182. package/lib/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
  183. package/lib/components/multi-step-wizard/multi-step-wizard.style.js +0 -21
  184. package/lib/components/multi-step-wizard/package.json +0 -4
  185. package/lib/components/multi-step-wizard/step/__spec__.d.ts +0 -1
  186. package/lib/components/multi-step-wizard/step/__spec__.js +0 -409
  187. package/lib/components/multi-step-wizard/step/package.json +0 -4
  188. package/lib/components/multi-step-wizard/step/step.d.ts +0 -166
  189. package/lib/components/multi-step-wizard/step/step.js +0 -421
  190. package/lib/components/multi-step-wizard/step/step.style.d.ts +0 -13
  191. package/lib/components/multi-step-wizard/step/step.style.js +0 -162
  192. package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
  193. package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -21
  194. package/lib/components/scrollable-list/index.d.ts +0 -4
  195. package/lib/components/scrollable-list/index.js +0 -31
  196. package/lib/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
  197. package/lib/components/scrollable-list/scrollable-list-item.component.js +0 -42
  198. package/lib/components/scrollable-list/scrollable-list.component.d.ts +0 -52
  199. package/lib/components/scrollable-list/scrollable-list.component.js +0 -328
  200. package/lib/components/scrollable-list/scrollable-list.context.d.ts +0 -3
  201. package/lib/components/scrollable-list/scrollable-list.context.js +0 -14
  202. package/lib/components/scrollable-list/scrollable-list.style.d.ts +0 -2
  203. package/lib/components/scrollable-list/scrollable-list.style.js +0 -41
  204. package/lib/components/scrollable-list/test-utils.d.ts +0 -2
  205. package/lib/components/scrollable-list/test-utils.js +0 -37
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface SubmenuBlockProps {
4
- /** Children elements */
5
- children: React.ReactNode;
6
- /** set the colour variant for a menuType */
7
- variant?: "default" | "alternate";
8
- }
9
-
10
- declare function SubmenuBlock(props: SubmenuBlockProps): JSX.Element;
11
-
12
- export default SubmenuBlock;
@@ -1,2 +0,0 @@
1
- export default StyledSubmenuBlock;
2
- declare const StyledSubmenuBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
-
10
- var _menuItem = _interopRequireDefault(require("../menu-item/menu-item.style"));
11
-
12
- var _menu = _interopRequireDefault(require("../menu.config"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
17
-
18
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
19
-
20
- const StyledSubmenuBlock = _styledComponents.default.div`
21
- ${({
22
- menuType,
23
- variant
24
- }) => (0, _styledComponents.css)`
25
- background-color: ${_menu.default[menuType].submenuItemBackground};
26
-
27
- ${_menuItem.default} {
28
- background-color: ${variant === "default" ? "transparent" : _menu.default[menuType].alternate};
29
- }
30
- `}
31
- `;
32
- var _default = StyledSubmenuBlock;
33
- exports.default = _default;
@@ -1 +0,0 @@
1
- export {};
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _enzyme = require("enzyme");
6
-
7
- var _ = _interopRequireDefault(require("./"));
8
-
9
- var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- describe("MountInApp", () => {
14
- let instance, placeholder;
15
-
16
- function renderComponent() {
17
- placeholder = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement("div", null));
18
- instance = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_.default, {
19
- targetId: "say_hello_here"
20
- }, /*#__PURE__*/_react.default.createElement("div", null, "Hello!!")));
21
- }
22
-
23
- describe("if the target element does not exist", () => {
24
- beforeEach(() => {
25
- renderComponent();
26
- });
27
- it("doesn't mount anything inside of the placeholder", () => {
28
- expect(placeholder.children.length).toEqual(0);
29
- });
30
- });
31
- describe("if the target element exists", () => {
32
- beforeEach(() => {
33
- spyOn(document, "getElementById").and.callFake(elementId => {
34
- return elementId === "say_hello_here" ? placeholder : null;
35
- });
36
- renderComponent();
37
- });
38
- it("mounts the specified children in the placeholder", () => {
39
- expect(placeholder.children.length).toEqual(1);
40
- let wrapperDiv = placeholder.children[0];
41
- expect(wrapperDiv.tagName).toEqual("DIV");
42
- expect(wrapperDiv.className).toEqual("carbon-mount-in-app");
43
- expect(wrapperDiv.children.length).toEqual(1);
44
- let contentDiv = wrapperDiv.children[0];
45
- expect(contentDiv.tagName).toEqual("DIV");
46
- expect(contentDiv.textContent).toEqual("Hello!!");
47
- });
48
- describe("componentWillUnmount", () => {
49
- it("removes all children", () => {
50
- instance.unmount();
51
- expect(placeholder.children.length).toEqual(0);
52
- });
53
- });
54
- });
55
- });
@@ -1 +0,0 @@
1
- export { default } from "./mount-in-app";
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface MountInAppProps {
4
- /** Children elements */
5
- children?: React.ReactNode;
6
- /** ID of the element in which the children components will be rendered. */
7
- targetId?: string;
8
- }
9
-
10
- declare class MountInApp extends React.Component<MountInAppProps> {}
11
-
12
- export default MountInApp;
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _reactDom = _interopRequireDefault(require("react-dom"));
13
-
14
- var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
-
20
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21
-
22
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23
-
24
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
25
-
26
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
-
28
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
29
-
30
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
31
-
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
-
34
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
35
-
36
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
-
38
- let deprecatedWarnTriggered = false;
39
-
40
- let MountInApp = /*#__PURE__*/function (_React$Component) {
41
- _inherits(MountInApp, _React$Component);
42
-
43
- var _super = _createSuper(MountInApp);
44
-
45
- function MountInApp() {
46
- _classCallCheck(this, MountInApp);
47
-
48
- return _super.apply(this, arguments);
49
- }
50
-
51
- _createClass(MountInApp, [{
52
- key: "componentDidMount",
53
- value: function componentDidMount() {
54
- if (this.targetElement) {
55
- _reactDom.default.render(this.contentHtml, this.targetElement);
56
- }
57
-
58
- if (!deprecatedWarnTriggered) {
59
- deprecatedWarnTriggered = true;
60
-
61
- _logger.default.deprecate( // eslint-disable-next-line max-len
62
- "The `MountInApp` component is deprecated and will soon be removed. We recommend using React Portals instead (https://reactjs.org/docs/portals.html)");
63
- }
64
- }
65
- }, {
66
- key: "componentWillUnmount",
67
- value: function componentWillUnmount() {
68
- this.targetElement.removeChild(this.targetElement.firstChild);
69
- }
70
- }, {
71
- key: "contentHtml",
72
- get: function () {
73
- return /*#__PURE__*/_react.default.createElement("div", {
74
- "data-component": "mount-in-app",
75
- className: "carbon-mount-in-app"
76
- }, this.props.children);
77
- }
78
- }, {
79
- key: "targetElement",
80
- get: function () {
81
- return document.getElementById(this.props.targetId);
82
- }
83
- }, {
84
- key: "render",
85
- value: function render() {
86
- return null;
87
- }
88
- }]);
89
-
90
- return MountInApp;
91
- }(_react.default.Component);
92
-
93
- MountInApp.propTypes = {
94
- /**
95
- * Children elements
96
- */
97
- children: _propTypes.default.node,
98
-
99
- /**
100
- * ID of the element in which the children components will be rendered.
101
- */
102
- targetId: _propTypes.default.string
103
- };
104
- var _default = MountInApp;
105
- exports.default = _default;
@@ -1,3 +0,0 @@
1
- {
2
- "main": "./mount-in-app"
3
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,202 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
6
-
7
- var _enzyme = require("enzyme");
8
-
9
- var _multiStepWizard = _interopRequireDefault(require("./multi-step-wizard"));
10
-
11
- var _multiActionButton = _interopRequireDefault(require("./../multi-action-button"));
12
-
13
- var _button = _interopRequireDefault(require("./../button"));
14
-
15
- var _tagsSpecs = require("../../__internal__/utils/helpers/tags/tags-specs");
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
- describe("MultiStepWizard", () => {
20
- let instance,
21
- spySubmitHandler = jasmine.createSpy("submitHandler");
22
- beforeEach(() => {
23
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_multiStepWizard.default, {
24
- steps: [/*#__PURE__*/_react.default.createElement("div", null, "Step 1"), /*#__PURE__*/_react.default.createElement("div", null, "Step 2")],
25
- onSubmit: spySubmitHandler
26
- }));
27
- });
28
- describe("lifecycle", () => {
29
- describe("componentWillMount", () => {
30
- it("sets the states", () => {
31
- spyOn(instance, "validateStepProps").and.returnValue({
32
- currentStep: 1,
33
- completed: false
34
- });
35
- expect(instance.state.currentStep).toEqual(1);
36
- expect(instance.state.completed).toEqual(false);
37
- });
38
- });
39
- describe("componentWillReceiveProps", () => {
40
- it("sets the states", () => {
41
- spyOn(instance, "validateStepProps").and.returnValue({
42
- currentStep: 3,
43
- completed: true
44
- });
45
- instance.UNSAFE_componentWillReceiveProps({});
46
- expect(instance.state.currentStep).toEqual(3);
47
- expect(instance.state.completed).toEqual(true);
48
- });
49
- });
50
- });
51
- describe("initialize", () => {
52
- it("sets current step", () => {
53
- expect(instance.state.currentStep).toBeTruthy();
54
- });
55
- it("sets completed to false", () => {
56
- expect(instance.state.completed).toBeFalsy();
57
- });
58
- });
59
- describe("totalSteps", () => {
60
- it("returns the total number of steps", () => {
61
- expect(instance.totalSteps).toEqual(2);
62
- });
63
- });
64
- describe("validateStepProps", () => {
65
- describe("when the completed prop equals to true", () => {
66
- it("returns the valid props", () => {
67
- let props = instance.validateStepProps({
68
- completed: true,
69
- steps: [1, 2, 3]
70
- });
71
- expect(props.currentStep).toEqual(3);
72
- expect(props.completed).toEqual(true);
73
- });
74
- });
75
- describe("when the currentStep prop is not number", () => {
76
- it("returns the valid props", () => {
77
- let props = instance.validateStepProps({
78
- currentStep: "test",
79
- steps: [1, 2, 3]
80
- });
81
- expect(props.currentStep).toEqual(1);
82
- expect(props.completed).toEqual(false);
83
- });
84
- });
85
- describe("when the currentStep prop is less than 1", () => {
86
- it("returns the valid props", () => {
87
- let props = instance.validateStepProps({
88
- currentStep: 0,
89
- steps: [1, 2, 3]
90
- });
91
- expect(props.currentStep).toEqual(1);
92
- expect(props.completed).toEqual(false);
93
- });
94
- });
95
- describe("when the currentStep prop is larger than the total of steps", () => {
96
- it("returns the valid props", () => {
97
- let props = instance.validateStepProps({
98
- currentStep: 4,
99
- steps: [1, 2, 3]
100
- });
101
- expect(props.currentStep).toEqual(1);
102
- expect(props.completed).toEqual(false);
103
- });
104
- });
105
- describe("when the currentStep prop is valid", () => {
106
- it("returns the valid props", () => {
107
- let props = instance.validateStepProps({
108
- currentStep: 2,
109
- steps: [1, 2, 3]
110
- });
111
- expect(props.currentStep).toEqual(2);
112
- expect(props.completed).toEqual(false);
113
- });
114
- });
115
- });
116
- describe("next", () => {
117
- beforeEach(() => {
118
- spyOn(instance, "setState").and.callThrough();
119
- });
120
- describe("when current step is less than the total of steps", () => {
121
- it("moves the step forward", () => {
122
- instance.next();
123
- expect(instance.state.currentStep).toEqual(2);
124
- });
125
- });
126
- describe("when current step is not less than the total of steps", () => {
127
- it("does nothing", () => {
128
- instance.state.currentStep = 3;
129
- instance.next();
130
- expect(instance.setState).not.toHaveBeenCalled();
131
- expect(instance.state.currentStep).toEqual(3);
132
- });
133
- });
134
- });
135
- describe("back", () => {
136
- beforeEach(() => {
137
- spyOn(instance, "setState").and.callThrough();
138
- });
139
- describe("when current step is larger than 1", () => {
140
- it("moves the step backward", () => {
141
- instance.state.currentStep = 2;
142
- instance.back();
143
- expect(instance.state.completed).toEqual(false);
144
- expect(instance.state.currentStep).toEqual(1);
145
- });
146
- });
147
- describe("when current step is not larger than 1", () => {
148
- it("does nothing", () => {
149
- instance.back();
150
- expect(instance.setState).not.toHaveBeenCalled();
151
- expect(instance.state.currentStep).toEqual(1);
152
- });
153
- });
154
- });
155
- describe("complete", () => {
156
- beforeEach(() => {
157
- spyOn(instance, "setState").and.callThrough();
158
- });
159
- describe("when current step is the last step", () => {
160
- it("completes the wizard", () => {
161
- instance.state.currentStep = 2;
162
- instance.complete();
163
- expect(instance.setState).toHaveBeenCalledWith({
164
- completed: true
165
- });
166
- expect(instance.state.completed).toBeTruthy();
167
- });
168
- });
169
- describe("when current step is not the last step", () => {
170
- it("does nothing", () => {
171
- instance.complete();
172
- expect(instance.setState).not.toHaveBeenCalled();
173
- expect(instance.state.completed).toBeFalsy();
174
- });
175
- });
176
- });
177
- describe("wizardStepsHTML", () => {
178
- describe("when passing the steps prop", () => {
179
- it("returns step components", () => {
180
- let steps = instance.wizardStepsHTML,
181
- step1 = steps[0],
182
- step2 = steps[1];
183
- expect(steps.length).toEqual(2);
184
- expect(step1.props.children.props.children).toEqual("Step 1");
185
- expect(step1.props.stepNumber).toEqual(1);
186
- expect(step1.props.defaultButton).toEqual(true);
187
- expect(step2.props.children.props.children).toEqual("Step 2");
188
- expect(step2.props.stepNumber).toEqual(2);
189
- expect(step2.props.defaultButton).toEqual(true);
190
- });
191
- });
192
- describe("when not passing the steps prop", () => {
193
- it("does not returns step components", () => {
194
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_multiStepWizard.default, {
195
- steps: [],
196
- onSubmit: spySubmitHandler
197
- }));
198
- expect(instance.wizardStepsHTML).toEqual([]);
199
- });
200
- });
201
- });
202
- });
@@ -1,109 +0,0 @@
1
- export default MultiStepWizard;
2
- declare class MultiStepWizard extends React.Component<any, any, any> {
3
- constructor(props: any);
4
- /**
5
- * Returns wizard object to child components.
6
- *
7
- * @method getChildContext
8
- * @return {void}
9
- */
10
- getChildContext(): void;
11
- /**
12
- * A lifecycle method that is called before initial render.
13
- * Can set up state of component without causing a re-render.
14
- *
15
- * @method componentWillMount
16
- */
17
- UNSAFE_componentWillMount(): void;
18
- /**
19
- * A lifecycle method to update the currentStep state when a new valid value has been specified.
20
- *
21
- * @method componentWillReceiveProps
22
- * @param {Object} props The new props passed down to the component
23
- * @return {void}
24
- */
25
- UNSAFE_componentWillReceiveProps(nextProps: any): void;
26
- /**
27
- * Validate step props
28
- *
29
- * @method validateStepProps
30
- * @return {Object}
31
- */
32
- validateStepProps: (stepProps: any) => Object;
33
- /**
34
- * Get total number of steps
35
- *
36
- * @method totalSteps
37
- * @return {Number}
38
- */
39
- get totalSteps(): number;
40
- /**
41
- * Moves to the next step.
42
- *
43
- * @method next
44
- * @return {void}
45
- */
46
- next: () => void;
47
- /**
48
- * Back to the previous step.
49
- *
50
- * @method back
51
- * @return {void}
52
- */
53
- back: () => void;
54
- /**
55
- * Completes the wizard.
56
- *
57
- * @method complete
58
- * @return {void}
59
- */
60
- complete: () => void;
61
- /**
62
- * Returns the computed HTML for the wizard's steps.
63
- *
64
- * @method wizardStepsHTML
65
- * @return {Object} JSX
66
- */
67
- get wizardStepsHTML(): Object;
68
- /**
69
- * Renders the component.
70
- *
71
- * @method render
72
- * @return {Object} JSX
73
- */
74
- render(): Object;
75
- }
76
- declare namespace MultiStepWizard {
77
- namespace propTypes {
78
- const steps: any[];
79
- const beforeSubmitValidation: Function;
80
- const className: string;
81
- const onSubmit: Function;
82
- const currentStep: number;
83
- const enableInactiveSteps: boolean;
84
- const onNext: PropTypes.Requireable<(...args: any[]) => any>;
85
- const onBack: PropTypes.Requireable<(...args: any[]) => any>;
86
- const completed: boolean;
87
- }
88
- namespace defaultProps {
89
- const beforeSubmitValidation_1: null;
90
- export { beforeSubmitValidation_1 as beforeSubmitValidation };
91
- const className_1: string;
92
- export { className_1 as className };
93
- const completed_1: boolean;
94
- export { completed_1 as completed };
95
- const currentStep_1: number;
96
- export { currentStep_1 as currentStep };
97
- const enableInactiveSteps_1: boolean;
98
- export { enableInactiveSteps_1 as enableInactiveSteps };
99
- const onNext_1: null;
100
- export { onNext_1 as onNext };
101
- const onBack_1: null;
102
- export { onBack_1 as onBack };
103
- }
104
- namespace childContextTypes {
105
- const wizard: Object;
106
- }
107
- }
108
- import React from "react";
109
- import PropTypes from "prop-types";