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