carbon-react 106.7.0 → 107.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
  2. package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
  3. package/esm/components/badge/badge.style.d.ts +1 -1
  4. package/esm/components/button/button.component.d.ts +1 -3
  5. package/esm/components/button/button.component.js +1 -12
  6. package/esm/components/button/button.style.d.ts +1 -1
  7. package/esm/components/button-toggle-group/button-toggle-group.component.js +1 -1
  8. package/esm/components/confirm/confirm.component.d.ts +1 -5
  9. package/esm/components/confirm/confirm.component.js +2 -14
  10. package/esm/components/confirm/confirm.d.ts +0 -2
  11. package/esm/components/dialog-full-screen/content.style.js +4 -10
  12. package/esm/components/heading/heading.component.d.ts +27 -52
  13. package/esm/components/heading/heading.component.js +86 -170
  14. package/esm/components/heading/heading.d.ts +5 -3
  15. package/esm/components/i18n-provider/i18n-provider.component.d.ts +0 -9
  16. package/esm/components/i18n-provider/i18n-provider.component.js +0 -9
  17. package/esm/components/menu/index.d.ts +0 -1
  18. package/esm/components/menu/index.js +0 -1
  19. package/esm/components/menu/menu-item/menu-item.component.js +0 -6
  20. package/esm/components/multi-action-button/multi-action-button.component.d.ts +1 -1
  21. package/esm/components/multi-action-button/multi-action-button.component.js +1 -11
  22. package/esm/components/navigation-bar/navigation-bar.component.d.ts +1 -6
  23. package/esm/components/navigation-bar/navigation-bar.component.js +1 -15
  24. package/esm/components/navigation-bar/navigation-bar.style.d.ts +0 -4
  25. package/esm/components/navigation-bar/navigation-bar.style.js +0 -8
  26. package/esm/components/radio-button/radio-button-group.component.js +1 -1
  27. package/esm/components/select/select-list/select-list.component.js +2 -2
  28. package/esm/components/simple-color-picker/simple-color-picker.component.js +1 -1
  29. package/esm/components/split-button/split-button-toggle.style.d.ts +1 -1
  30. package/esm/components/split-button/split-button.component.d.ts +1 -4
  31. package/esm/components/split-button/split-button.component.js +3 -16
  32. package/esm/components/split-button/split-button.d.ts +0 -2
  33. package/esm/components/tile/tile.component.d.ts +1 -2
  34. package/esm/components/tile/tile.component.js +1 -13
  35. package/esm/components/tile/tile.d.ts +0 -2
  36. package/esm/components/tile-select/tile-select-group.component.js +1 -1
  37. package/esm/components/toast/toast.component.d.ts +1 -4
  38. package/esm/components/toast/toast.component.js +1 -13
  39. package/esm/components/toast/toast.d.ts +0 -2
  40. package/esm/locales/en-gb.js +0 -9
  41. package/esm/locales/locale.d.ts +0 -9
  42. package/esm/locales/pl-pl.js +0 -9
  43. package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
  44. package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
  45. package/lib/components/badge/badge.style.d.ts +1 -1
  46. package/lib/components/button/button.component.d.ts +1 -3
  47. package/lib/components/button/button.component.js +1 -14
  48. package/lib/components/button/button.style.d.ts +1 -1
  49. package/lib/components/button-toggle-group/button-toggle-group.component.js +1 -1
  50. package/lib/components/confirm/confirm.component.d.ts +1 -5
  51. package/lib/components/confirm/confirm.component.js +2 -17
  52. package/lib/components/confirm/confirm.d.ts +0 -2
  53. package/lib/components/dialog-full-screen/content.style.js +4 -10
  54. package/lib/components/heading/heading.component.d.ts +27 -52
  55. package/lib/components/heading/heading.component.js +86 -170
  56. package/lib/components/heading/heading.d.ts +5 -3
  57. package/lib/components/i18n-provider/i18n-provider.component.d.ts +0 -9
  58. package/lib/components/i18n-provider/i18n-provider.component.js +0 -9
  59. package/lib/components/menu/index.d.ts +0 -1
  60. package/lib/components/menu/index.js +0 -8
  61. package/lib/components/menu/menu-item/menu-item.component.js +0 -7
  62. package/lib/components/multi-action-button/multi-action-button.component.d.ts +1 -1
  63. package/lib/components/multi-action-button/multi-action-button.component.js +1 -14
  64. package/lib/components/navigation-bar/navigation-bar.component.d.ts +1 -6
  65. package/lib/components/navigation-bar/navigation-bar.component.js +1 -18
  66. package/lib/components/navigation-bar/navigation-bar.style.d.ts +0 -4
  67. package/lib/components/navigation-bar/navigation-bar.style.js +0 -8
  68. package/lib/components/radio-button/radio-button-group.component.js +1 -1
  69. package/lib/components/select/select-list/select-list.component.js +2 -2
  70. package/lib/components/simple-color-picker/simple-color-picker.component.js +1 -1
  71. package/lib/components/split-button/split-button-toggle.style.d.ts +1 -1
  72. package/lib/components/split-button/split-button.component.d.ts +1 -4
  73. package/lib/components/split-button/split-button.component.js +3 -18
  74. package/lib/components/split-button/split-button.d.ts +0 -2
  75. package/lib/components/tile/tile.component.d.ts +1 -2
  76. package/lib/components/tile/tile.component.js +1 -16
  77. package/lib/components/tile/tile.d.ts +0 -2
  78. package/lib/components/tile-select/tile-select-group.component.js +1 -1
  79. package/lib/components/toast/toast.component.d.ts +1 -4
  80. package/lib/components/toast/toast.component.js +1 -16
  81. package/lib/components/toast/toast.d.ts +0 -2
  82. package/lib/locales/en-gb.js +0 -9
  83. package/lib/locales/locale.d.ts +0 -9
  84. package/lib/locales/pl-pl.js +0 -9
  85. package/package.json +1 -1
  86. package/esm/components/app-wrapper/app-wrapper.component.d.ts +0 -25
  87. package/esm/components/app-wrapper/app-wrapper.component.js +0 -104
  88. package/esm/components/app-wrapper/app-wrapper.d.ts +0 -12
  89. package/esm/components/app-wrapper/app-wrapper.style.d.ts +0 -2
  90. package/esm/components/app-wrapper/app-wrapper.style.js +0 -17
  91. package/esm/components/app-wrapper/index.d.ts +0 -1
  92. package/esm/components/app-wrapper/index.js +0 -1
  93. package/esm/components/menu/submenu-block/index.d.ts +0 -2
  94. package/esm/components/menu/submenu-block/index.js +0 -1
  95. package/esm/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
  96. package/esm/components/menu/submenu-block/submenu-block.component.js +0 -34
  97. package/esm/components/menu/submenu-block/submenu-block.d.ts +0 -12
  98. package/esm/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
  99. package/esm/components/menu/submenu-block/submenu-block.style.js +0 -16
  100. package/esm/components/mount-in-app/__spec__.d.ts +0 -1
  101. package/esm/components/mount-in-app/__spec__.js +0 -47
  102. package/esm/components/mount-in-app/index.d.ts +0 -1
  103. package/esm/components/mount-in-app/mount-in-app.d.ts +0 -12
  104. package/esm/components/mount-in-app/mount-in-app.js +0 -90
  105. package/esm/components/mount-in-app/package.json +0 -3
  106. package/esm/components/multi-step-wizard/__spec__.d.ts +0 -1
  107. package/esm/components/multi-step-wizard/__spec__.js +0 -191
  108. package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
  109. package/esm/components/multi-step-wizard/multi-step-wizard.js +0 -383
  110. package/esm/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
  111. package/esm/components/multi-step-wizard/multi-step-wizard.style.js +0 -10
  112. package/esm/components/multi-step-wizard/package.json +0 -4
  113. package/esm/components/multi-step-wizard/step/__spec__.d.ts +0 -1
  114. package/esm/components/multi-step-wizard/step/__spec__.js +0 -399
  115. package/esm/components/multi-step-wizard/step/package.json +0 -4
  116. package/esm/components/multi-step-wizard/step/step.d.ts +0 -166
  117. package/esm/components/multi-step-wizard/step/step.js +0 -407
  118. package/esm/components/multi-step-wizard/step/step.style.d.ts +0 -13
  119. package/esm/components/multi-step-wizard/step/step.style.js +0 -138
  120. package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
  121. package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -10
  122. package/esm/components/scrollable-list/index.d.ts +0 -4
  123. package/esm/components/scrollable-list/index.js +0 -4
  124. package/esm/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
  125. package/esm/components/scrollable-list/scrollable-list-item.component.js +0 -26
  126. package/esm/components/scrollable-list/scrollable-list.component.d.ts +0 -52
  127. package/esm/components/scrollable-list/scrollable-list.component.js +0 -306
  128. package/esm/components/scrollable-list/scrollable-list.context.d.ts +0 -3
  129. package/esm/components/scrollable-list/scrollable-list.context.js +0 -2
  130. package/esm/components/scrollable-list/scrollable-list.style.d.ts +0 -2
  131. package/esm/components/scrollable-list/scrollable-list.style.js +0 -30
  132. package/esm/components/scrollable-list/test-utils.d.ts +0 -2
  133. package/esm/components/scrollable-list/test-utils.js +0 -25
  134. package/lib/components/app-wrapper/app-wrapper.component.d.ts +0 -25
  135. package/lib/components/app-wrapper/app-wrapper.component.js +0 -120
  136. package/lib/components/app-wrapper/app-wrapper.d.ts +0 -12
  137. package/lib/components/app-wrapper/app-wrapper.style.d.ts +0 -2
  138. package/lib/components/app-wrapper/app-wrapper.style.js +0 -28
  139. package/lib/components/app-wrapper/index.d.ts +0 -1
  140. package/lib/components/app-wrapper/index.js +0 -15
  141. package/lib/components/app-wrapper/package.json +0 -6
  142. package/lib/components/menu/submenu-block/index.d.ts +0 -2
  143. package/lib/components/menu/submenu-block/index.js +0 -15
  144. package/lib/components/menu/submenu-block/package.json +0 -6
  145. package/lib/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
  146. package/lib/components/menu/submenu-block/submenu-block.component.js +0 -53
  147. package/lib/components/menu/submenu-block/submenu-block.d.ts +0 -12
  148. package/lib/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
  149. package/lib/components/menu/submenu-block/submenu-block.style.js +0 -33
  150. package/lib/components/mount-in-app/__spec__.d.ts +0 -1
  151. package/lib/components/mount-in-app/__spec__.js +0 -55
  152. package/lib/components/mount-in-app/index.d.ts +0 -1
  153. package/lib/components/mount-in-app/mount-in-app.d.ts +0 -12
  154. package/lib/components/mount-in-app/mount-in-app.js +0 -105
  155. package/lib/components/mount-in-app/package.json +0 -3
  156. package/lib/components/multi-step-wizard/__spec__.d.ts +0 -1
  157. package/lib/components/multi-step-wizard/__spec__.js +0 -202
  158. package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
  159. package/lib/components/multi-step-wizard/multi-step-wizard.js +0 -397
  160. package/lib/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
  161. package/lib/components/multi-step-wizard/multi-step-wizard.style.js +0 -21
  162. package/lib/components/multi-step-wizard/package.json +0 -4
  163. package/lib/components/multi-step-wizard/step/__spec__.d.ts +0 -1
  164. package/lib/components/multi-step-wizard/step/__spec__.js +0 -409
  165. package/lib/components/multi-step-wizard/step/package.json +0 -4
  166. package/lib/components/multi-step-wizard/step/step.d.ts +0 -166
  167. package/lib/components/multi-step-wizard/step/step.js +0 -421
  168. package/lib/components/multi-step-wizard/step/step.style.d.ts +0 -13
  169. package/lib/components/multi-step-wizard/step/step.style.js +0 -162
  170. package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
  171. package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -21
  172. package/lib/components/scrollable-list/index.d.ts +0 -4
  173. package/lib/components/scrollable-list/index.js +0 -31
  174. package/lib/components/scrollable-list/package.json +0 -6
  175. package/lib/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
  176. package/lib/components/scrollable-list/scrollable-list-item.component.js +0 -42
  177. package/lib/components/scrollable-list/scrollable-list.component.d.ts +0 -52
  178. package/lib/components/scrollable-list/scrollable-list.component.js +0 -328
  179. package/lib/components/scrollable-list/scrollable-list.context.d.ts +0 -3
  180. package/lib/components/scrollable-list/scrollable-list.context.js +0 -14
  181. package/lib/components/scrollable-list/scrollable-list.style.d.ts +0 -2
  182. package/lib/components/scrollable-list/scrollable-list.style.js +0 -41
  183. package/lib/components/scrollable-list/test-utils.d.ts +0 -2
  184. package/lib/components/scrollable-list/test-utils.js +0 -37
@@ -1,409 +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 _step = _interopRequireDefault(require("./step"));
8
-
9
- var _button = _interopRequireDefault(require("./../../button"));
10
-
11
- var _enzyme = require("enzyme");
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- describe("Step", () => {
16
- let instance,
17
- stepContext,
18
- stepNumber = 1,
19
- spyNextHandler = jasmine.createSpy("nextHandler"),
20
- spyBackHandler = jasmine.createSpy("backHandler"),
21
- spyBeforeSubmitValidation = null,
22
- spySubmitHandler = jasmine.createSpy("submitHandler"),
23
- spyOnNext = jasmine.createSpy("onNext"),
24
- spyOnBack = jasmine.createSpy("onBack"),
25
- spyNext = jasmine.createSpy("next"),
26
- spyBack = jasmine.createSpy("back"),
27
- spyComplete = jasmine.createSpy("complete"),
28
- enableInactiveSteps = false,
29
- currentStep = 1,
30
- completed = false,
31
- totalSteps = 3;
32
- beforeEach(() => {
33
- stepContext = {
34
- wizard: {
35
- nextHandler: spyNextHandler,
36
- backHandler: spyBackHandler,
37
- beforeSubmitValidation: spyBeforeSubmitValidation,
38
- submitHandler: spySubmitHandler,
39
- enableInactiveSteps: enableInactiveSteps,
40
- currentStep: currentStep,
41
- completed: completed,
42
- next: spyNext,
43
- back: spyBack,
44
- complete: spyComplete,
45
- totalSteps: totalSteps
46
- }
47
- };
48
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
49
- stepNumber: stepNumber
50
- }, "Demo Step"));
51
- instance.context = stepContext;
52
- });
53
- describe("handleOnSubmit", () => {
54
- describe("when beforeSubmitValidation props is not null", () => {
55
- beforeEach(() => {
56
- spyBeforeSubmitValidation = jasmine.createSpy("beforeSubmitValidation");
57
- instance.context.wizard.beforeSubmitValidation = spyBeforeSubmitValidation;
58
- });
59
- describe("when beforeSubmitValidation props does not returns true", () => {
60
- beforeEach(() => {
61
- spyBeforeSubmitValidation.and.returnValue(false);
62
- });
63
- it("does not call the parent wizard to complete and submit", () => {
64
- instance.handleOnSubmit();
65
- expect(spyComplete).not.toHaveBeenCalled();
66
- });
67
- it("does not call submitHandler of parent wizard", () => {
68
- instance.handleOnSubmit();
69
- expect(spySubmitHandler).not.toHaveBeenCalled();
70
- });
71
- });
72
- describe("when beforeSubmitValidation props returns true", () => {
73
- beforeEach(() => {
74
- spyBeforeSubmitValidation.and.returnValue(true);
75
- });
76
- it("calls the parent wizard to complete", () => {
77
- instance.handleOnSubmit();
78
- expect(spyComplete).toHaveBeenCalled();
79
- });
80
- it("calls submitHandler of parent wizard", () => {
81
- instance.handleOnSubmit();
82
- expect(spySubmitHandler).toHaveBeenCalled();
83
- });
84
- });
85
- });
86
- describe("when beforeSubmitValidation props is null", () => {
87
- beforeEach(() => {
88
- spyBeforeSubmitValidation = null;
89
- instance.context.wizard.beforeSubmitValidation = spyBeforeSubmitValidation;
90
- });
91
- it("calls the parent wizard to complete", () => {
92
- instance.handleOnSubmit();
93
- expect(spyComplete).toHaveBeenCalled();
94
- });
95
- it("calls submitHandler of parent wizard", () => {
96
- instance.handleOnSubmit();
97
- expect(spySubmitHandler).toHaveBeenCalled();
98
- });
99
- });
100
- });
101
- describe("handleOnNext", () => {
102
- describe("when onNext props is not null", () => {
103
- it("calls the onNext props", () => {
104
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
105
- stepNumber: 1,
106
- onNext: spyOnNext
107
- }, "Demo Step"));
108
- instance.context = stepContext;
109
- instance.handleOnNext();
110
- expect(spyOnNext).toHaveBeenCalled();
111
- expect(spyNext).not.toHaveBeenCalled();
112
- });
113
- });
114
- describe("when onNext props is null", () => {
115
- it("calls the parent wizard to step forward", () => {
116
- instance.handleOnNext();
117
- expect(spyNext).toHaveBeenCalled();
118
- });
119
- });
120
- });
121
- describe("handleOnBack", () => {
122
- describe("when onBack props is not null", () => {
123
- it("calls the onBack props", () => {
124
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
125
- stepNumber: 1,
126
- onBack: spyOnBack
127
- }, "Demo Step"));
128
- instance.context = stepContext;
129
- instance.handleOnBack();
130
- expect(spyOnBack).toHaveBeenCalled();
131
- expect(spyBack).not.toHaveBeenCalled();
132
- });
133
- });
134
- describe("when onBack props is null", () => {
135
- it("calls the parent wizard to step backward", () => {
136
- instance.handleOnBack();
137
- expect(spyBack).toHaveBeenCalled();
138
- });
139
- });
140
- });
141
- describe("wizard", () => {
142
- it("returns the parent wizard", () => {
143
- expect(instance.wizard).toEqual(stepContext.wizard);
144
- });
145
- });
146
- describe("currentStepNumber", () => {
147
- it("returns the current step number", () => {
148
- expect(instance.currentStepNumber).toEqual(stepNumber);
149
- });
150
- });
151
- describe("isFirstStep", () => {
152
- describe("when at the first step", () => {
153
- it("returns true", () => {
154
- expect(instance.isFirstStep).toBeTruthy();
155
- });
156
- });
157
- describe("when not at the first step", () => {
158
- it("returns false", () => {
159
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
160
- stepNumber: 2
161
- }, "Demo Step"));
162
- instance.context = stepContext;
163
- expect(instance.isFirstStep).toBeFalsy();
164
- });
165
- });
166
- });
167
- describe("isLastStep", () => {
168
- describe("when at the last step", () => {
169
- it("returns true", () => {
170
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
171
- stepNumber: 3
172
- }, "Demo Step"));
173
- instance.context = stepContext;
174
- expect(instance.isLastStep).toBeTruthy();
175
- });
176
- });
177
- describe("when not at the first step", () => {
178
- it("returns false", () => {
179
- expect(instance.isLastStep).toBeFalsy();
180
- });
181
- });
182
- });
183
- describe("stepDisabled", () => {
184
- describe("when inactive step is enabled", () => {
185
- it("returns false", () => {
186
- stepContext.wizard.enableInactiveSteps = true;
187
- expect(instance.stepDisabled).toBeFalsy();
188
- });
189
- });
190
- describe("when step number is equal to current step", () => {
191
- it("returns false", () => {
192
- expect(instance.stepDisabled).toBeFalsy();
193
- });
194
- });
195
- describe("when step number is not equal to current step", () => {
196
- it("returns true", () => {
197
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
198
- stepNumber: 2
199
- }, "Demo Step"));
200
- instance.context = stepContext;
201
- expect(instance.stepDisabled).toBeTruthy();
202
- });
203
- });
204
- describe("when step is enabled", () => {
205
- it("returns false", () => {
206
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
207
- stepNumber: 1,
208
- enabled: true
209
- }, "Demo Step"));
210
- instance.context = stepContext;
211
- expect(instance.stepDisabled).toBeFalsy();
212
- });
213
- });
214
- });
215
- describe("stepProcessed", () => {
216
- describe("when at the last step", () => {
217
- it("returns parent wizard completion status", () => {
218
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
219
- stepNumber: 3
220
- }, "Demo Step"));
221
- instance.context = stepContext;
222
- expect(instance.stepProcessed).toEqual(completed);
223
- });
224
- });
225
- describe("when not at the last step", () => {
226
- describe("when step number is less than to current step", () => {
227
- it("returns true", () => {
228
- stepContext.wizard.currentStep = 2;
229
- expect(instance.stepProcessed).toBeTruthy();
230
- });
231
- });
232
- describe("when step number is not less than to current step", () => {
233
- it("returns false", () => {
234
- expect(instance.stepProcessed).toBeFalsy();
235
- });
236
- });
237
- });
238
- });
239
- describe("stepsCompleted", () => {
240
- it("returns parent wizard completion status", () => {
241
- expect(instance.stepsCompleted).toEqual(completed);
242
- });
243
- });
244
- describe("buttonHTML", () => {
245
- describe("when defaultButton props is true", () => {
246
- describe("when at the last step", () => {
247
- it("returns the Submit and Back buttons", () => {
248
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
249
- stepNumber: 3
250
- }, "Demo Step"));
251
- instance.context = stepContext;
252
- let buttons = instance.buttonHTML.props.children,
253
- nextButton = buttons[0],
254
- submitButton = buttons[1],
255
- backButton = buttons[2],
256
- extraButtons = buttons[3];
257
- expect(nextButton).toBeUndefined();
258
- expect(submitButton).toBeDefined();
259
- expect(backButton).toBeDefined();
260
- expect(extraButtons).toEqual([]);
261
- });
262
- });
263
- describe("when not at the last step and not at the first step", () => {
264
- it("returns the Next and Back buttons", () => {
265
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
266
- stepNumber: 2
267
- }, "Demo Step"));
268
- instance.context = stepContext;
269
- let buttons = instance.buttonHTML.props.children,
270
- nextButton = buttons[0],
271
- submitButton = buttons[1],
272
- backButton = buttons[2],
273
- extraButtons = buttons[3];
274
- expect(nextButton).toBeDefined();
275
- expect(submitButton).toBeUndefined();
276
- expect(backButton).toBeDefined();
277
- expect(extraButtons).toEqual([]);
278
- });
279
- });
280
- describe("when at the first step", () => {
281
- it("returns the Next button", () => {
282
- let buttons = instance.buttonHTML.props.children,
283
- nextButton = buttons[0],
284
- submitButton = buttons[1],
285
- backButton = buttons[2],
286
- extraButtons = buttons[3];
287
- expect(nextButton).toBeDefined();
288
- expect(submitButton).toBeUndefined();
289
- expect(backButton).toBeUndefined();
290
- expect(extraButtons).toEqual([]);
291
- });
292
- });
293
- });
294
- describe("when defaultButton props is false", () => {
295
- it("returns the Extra buttons", () => {
296
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
297
- stepNumber: 2,
298
- defaultButton: false,
299
- extraButtons: [/*#__PURE__*/_react.default.createElement(_button.default, null, "Extra Buttons")]
300
- }, "Demo Step"));
301
- instance.context = stepContext;
302
- let extraButton = instance.buttonHTML[0],
303
- extraButtonText = extraButton.props.children.props.children;
304
- expect(extraButtonText).toEqual("Extra Buttons");
305
- });
306
- });
307
- });
308
- describe("indicatorHTML", () => {
309
- describe("when the step is not processed", () => {
310
- it("returns the step number", () => {
311
- let indicator = instance.indicatorHTML;
312
- expect(indicator.props.children).toEqual(stepNumber);
313
- });
314
- });
315
- describe("when the step is processed", () => {
316
- it("returns the step number", () => {
317
- stepContext.wizard.currentStep = 2;
318
- let indicator = instance.indicatorHTML;
319
- expect(indicator.props.type).toEqual("white-tick");
320
- });
321
- });
322
- });
323
- describe("indicatorStatus", () => {
324
- describe("when the step is not processed", () => {
325
- it("returns pending status", () => {
326
- let status = instance.indicatorStatus;
327
- expect(status).toEqual("pending");
328
- });
329
- });
330
- describe("when the step is processed", () => {
331
- it("returns processed status", () => {
332
- stepContext.wizard.currentStep = 2;
333
- let status = instance.indicatorStatus;
334
- expect(status).toEqual("processed");
335
- });
336
- });
337
- });
338
- describe("mainClasses", () => {
339
- it("adds a className based on the step number", () => {
340
- expect(instance.mainClasses).toContain("multi-step-wizard-step-1");
341
- });
342
- it("adds a className based on the step progress", () => {
343
- expect(instance.mainClasses).toContain("multi-step-wizard-step-1");
344
- });
345
- it("adds a className if the step is the last step", () => {
346
- instance = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(_step.default, {
347
- stepNumber: 3
348
- }, "Demo Step"));
349
- instance.context = stepContext;
350
- expect(instance.mainClasses).toContain("multi-step-wizard-step-final");
351
- });
352
- });
353
- describe("render", () => {
354
- it("renders a div if parent wizard is not available", () => {
355
- let div = _testUtils.default.scryRenderedDOMComponentsWithTag(instance, "div")[0];
356
-
357
- expect(div.className).toEqual("multi-step-wizard-step--none");
358
- });
359
- });
360
- describe("component tags", () => {
361
- describe("button tags", () => {
362
- describe("next button", () => {
363
- let wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_step.default, {
364
- stepNumber: 1
365
- }, "Demo Step"), {
366
- context: {
367
- wizard: {
368
- totalSteps: 3
369
- }
370
- }
371
- });
372
- it("includes correct tags for the button", () => {
373
- let next = wrapper.find("[data-element='next']");
374
- expect(next.exists()).toBe(true);
375
- });
376
- });
377
- describe("back button", () => {
378
- let wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_step.default, {
379
- stepNumber: 2
380
- }, "Demo Step"), {
381
- context: {
382
- wizard: {
383
- totalSteps: 3
384
- }
385
- }
386
- });
387
- it("includes correct tags for the button", () => {
388
- let back = wrapper.find("[data-element='back']");
389
- expect(back.exists()).toBe(true);
390
- });
391
- });
392
- describe("submit button", () => {
393
- let wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_step.default, {
394
- stepNumber: 3
395
- }, "Demo Step"), {
396
- context: {
397
- wizard: {
398
- totalSteps: 3
399
- }
400
- }
401
- });
402
- it("includes correct tags for the button", () => {
403
- let submit = wrapper.find("[data-element='submit']");
404
- expect(submit.exists()).toBe(true);
405
- });
406
- });
407
- });
408
- });
409
- });
@@ -1,4 +0,0 @@
1
- {
2
- "name": "step",
3
- "main": "./step.js"
4
- }
@@ -1,166 +0,0 @@
1
- export default Step;
2
- /**
3
- * A Step widget.
4
- * This widget is part of MultiStepWizard and it is a wrapper for a step element that is passed to MultiStepWizard.
5
- *
6
- * == How to use a Step Widget in a component:
7
- * See MultiStepWizard widget
8
- *
9
- * @class Step
10
- * @constructor
11
- */
12
- declare class Step extends React.Component<any, any, any> {
13
- constructor(props: any);
14
- constructor(props: any, context: any);
15
- /**
16
- * Completes the step's wizard and triggers the custom submit event handler of the step's wizard
17
- *
18
- * @method handleOnSubmit
19
- * @return {void}
20
- */
21
- handleOnSubmit: (ev: any) => void;
22
- /**
23
- * Triggers the custom next event handler of the step's wizard
24
- *
25
- * @method handleOnNext
26
- * @return {void}
27
- */
28
- handleOnNext: (ev: any) => void;
29
- /**
30
- * Triggers the custom back event handler of the step's wizard
31
- *
32
- * @method handleOnBack
33
- * @return {void}
34
- */
35
- handleOnBack: (ev: any) => void;
36
- /**
37
- * Gets the step's wizard
38
- *
39
- * @method wizard
40
- * @return {Object}
41
- */
42
- get wizard(): Object;
43
- /**
44
- * Gets the current step number
45
- *
46
- * @method currentStepNumber
47
- * @return {Number}
48
- */
49
- get currentStepNumber(): number;
50
- /**
51
- * Checks if the step is the first step
52
- *
53
- * @method isFirstStep
54
- * @return {Boolean}
55
- */
56
- get isFirstStep(): boolean;
57
- /**
58
- * Checks if the step is the last step
59
- *
60
- * @method isLastStep
61
- * @return {Boolean}
62
- */
63
- get isLastStep(): boolean;
64
- /**
65
- * Checks if step component should be disabled.
66
- *
67
- * @method stepDisabled
68
- * @return {Boolean}
69
- */
70
- get stepDisabled(): boolean;
71
- /**
72
- * Checks if step has been processed.
73
- *
74
- * @method stepProcessed
75
- * @return {Boolean}
76
- */
77
- get stepProcessed(): boolean;
78
- /**
79
- * Checks if all steps are completed
80
- *
81
- * @method stepsCompleted
82
- * @return {Boolean}
83
- */
84
- get stepsCompleted(): boolean;
85
- /**
86
- * Returns the computed HTML for the step.
87
- *
88
- * @method stepHTML
89
- * @return {Object} JSX
90
- */
91
- get stepHTML(): Object;
92
- /**
93
- * Returns the computed HTML for the buttons.
94
- *
95
- * @method buttonHTML
96
- * @return {Object} JSX
97
- */
98
- get buttonHTML(): Object;
99
- /**
100
- * Returns the computed HTML for the step indicator.
101
- *
102
- * @method indicatorHTML
103
- * @return {Object} JSX
104
- */
105
- get indicatorHTML(): Object;
106
- /**
107
- * Returns the step indicator status.
108
- *
109
- * @method indicatorStatus
110
- * @return {Boolean}
111
- */
112
- get indicatorStatus(): boolean;
113
- /**
114
- * Returns the computed HTML for the extra buttons.
115
- *
116
- * @method extraButtonHTML
117
- * @return {Object} JSX
118
- */
119
- get extraButtonHTML(): Object;
120
- /**
121
- * Main class getter
122
- *
123
- * @method mainClasses
124
- * @return {String}
125
- */
126
- get mainClasses(): string;
127
- /**
128
- * Renders the component.
129
- *
130
- * @method render
131
- */
132
- render(): JSX.Element;
133
- }
134
- declare namespace Step {
135
- namespace propTypes {
136
- const stepNumber: number;
137
- const defaultButton: boolean;
138
- const onNext: Function;
139
- const onBack: Function;
140
- const extraButtons: any[];
141
- const enabled: boolean;
142
- const className: string;
143
- const children: Node;
144
- }
145
- namespace defaultProps {
146
- const children_1: null;
147
- export { children_1 as children };
148
- const className_1: string;
149
- export { className_1 as className };
150
- const defaultButton_1: boolean;
151
- export { defaultButton_1 as defaultButton };
152
- const enabled_1: boolean;
153
- export { enabled_1 as enabled };
154
- const extraButtons_1: never[];
155
- export { extraButtons_1 as extraButtons };
156
- const onBack_1: null;
157
- export { onBack_1 as onBack };
158
- const onNext_1: null;
159
- export { onNext_1 as onNext };
160
- }
161
- namespace contextTypes {
162
- const wizard: PropTypes.Requireable<object>;
163
- }
164
- }
165
- import React from "react";
166
- import PropTypes from "prop-types";