@schukai/monster 4.125.3 → 4.126.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/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/source/components/form/style/field-layout.pcss +350 -0
- package/source/components/form/style/field-set.pcss +4 -0
- package/source/components/form/style/wizard.pcss +57 -0
- package/source/components/form/stylesheet/field-layout.mjs +38 -0
- package/source/components/form/stylesheet/field-set.mjs +1 -1
- package/source/components/form/stylesheet/wizard.mjs +38 -0
- package/source/components/form/wizard.mjs +1326 -0
- package/source/monster.mjs +1 -0
- package/test/cases/components/datatable/pagination.mjs +1 -1
- package/test/cases/components/form/wizard.mjs +153 -0
package/source/monster.mjs
CHANGED
|
@@ -80,6 +80,7 @@ export * from "./components/form/tree-select.mjs";
|
|
|
80
80
|
export * from "./components/form/popper-button.mjs";
|
|
81
81
|
export * from "./components/form/quantity.mjs";
|
|
82
82
|
export * from "./components/form/credential-button.mjs";
|
|
83
|
+
export * from "./components/form/wizard.mjs";
|
|
83
84
|
export * from "./components/form/input-group.mjs";
|
|
84
85
|
export * from "./components/form/checklist.mjs";
|
|
85
86
|
export * from "./components/form/shadow-reload.mjs";
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { getGlobal } from "../../../../source/types/global.mjs";
|
|
2
|
+
import * as chai from "chai";
|
|
3
|
+
import { chaiDom } from "../../../util/chai-dom.mjs";
|
|
4
|
+
import { initJSDOM } from "../../../util/jsdom.mjs";
|
|
5
|
+
|
|
6
|
+
let expect = chai.expect;
|
|
7
|
+
chai.use(chaiDom);
|
|
8
|
+
|
|
9
|
+
const global = getGlobal();
|
|
10
|
+
|
|
11
|
+
let html = `
|
|
12
|
+
<monster-wizard id="wizard-under-test">
|
|
13
|
+
<section
|
|
14
|
+
data-monster-option-navigation-id="account-email"
|
|
15
|
+
data-monster-option-navigation-label="Account"
|
|
16
|
+
data-monster-option-navigation-sub-label="Email"
|
|
17
|
+
>
|
|
18
|
+
<input id="wizard-email" type="email" required>
|
|
19
|
+
</section>
|
|
20
|
+
<section
|
|
21
|
+
data-monster-option-navigation-id="account-password"
|
|
22
|
+
data-monster-option-navigation-label="Account"
|
|
23
|
+
data-monster-option-navigation-sub-label="Password"
|
|
24
|
+
>
|
|
25
|
+
<input id="wizard-password" type="password" required>
|
|
26
|
+
</section>
|
|
27
|
+
<section
|
|
28
|
+
data-monster-option-navigation-id="profile"
|
|
29
|
+
data-monster-option-navigation-label="Profile"
|
|
30
|
+
>
|
|
31
|
+
<input id="wizard-name" type="text">
|
|
32
|
+
</section>
|
|
33
|
+
</monster-wizard>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
let Wizard;
|
|
37
|
+
|
|
38
|
+
describe("Wizard", function () {
|
|
39
|
+
before(function (done) {
|
|
40
|
+
initJSDOM().then(() => {
|
|
41
|
+
import("element-internals-polyfill").catch((e) => done(e));
|
|
42
|
+
|
|
43
|
+
let promises = [];
|
|
44
|
+
|
|
45
|
+
if (!global.crypto) {
|
|
46
|
+
promises.push(
|
|
47
|
+
import("@peculiar/webcrypto").then((m) => {
|
|
48
|
+
const Crypto = m.Crypto;
|
|
49
|
+
global.crypto = new Crypto();
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
promises.push(
|
|
55
|
+
import("../../../../source/components/form/wizard.mjs").then((m) => {
|
|
56
|
+
Wizard = m.Wizard;
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
Promise.all(promises)
|
|
61
|
+
.then(() => done())
|
|
62
|
+
.catch((e) => done(e));
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
const mocks = document.getElementById("mocks");
|
|
68
|
+
mocks.innerHTML = "";
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should register monster-wizard", function () {
|
|
72
|
+
expect(document.createElement("monster-wizard")).is.instanceof(Wizard);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should build grouped navigation from panel labels", async function () {
|
|
76
|
+
const mocks = document.getElementById("mocks");
|
|
77
|
+
mocks.innerHTML = html;
|
|
78
|
+
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
80
|
+
|
|
81
|
+
const wizard = document.getElementById("wizard-under-test");
|
|
82
|
+
expect(wizard.getCurrentIndex()).to.equal(0);
|
|
83
|
+
|
|
84
|
+
const nav = wizard.shadowRoot.querySelector("monster-wizard-navigation");
|
|
85
|
+
expect(nav).to.not.equal(null);
|
|
86
|
+
|
|
87
|
+
const items = nav.querySelectorAll("ol.wizard-steps > li.step");
|
|
88
|
+
expect(items.length).to.equal(2);
|
|
89
|
+
expect(items[0].querySelectorAll("ul li").length).to.equal(2);
|
|
90
|
+
expect(
|
|
91
|
+
wizard.querySelector('[data-monster-option-navigation-id="account-email"]')
|
|
92
|
+
.hidden,
|
|
93
|
+
).to.equal(false);
|
|
94
|
+
expect(
|
|
95
|
+
wizard.querySelector(
|
|
96
|
+
'[data-monster-option-navigation-id="account-password"]',
|
|
97
|
+
).hidden,
|
|
98
|
+
).to.equal(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should use panel-specific validation callbacks before moving forward", async function () {
|
|
102
|
+
const mocks = document.getElementById("mocks");
|
|
103
|
+
mocks.innerHTML = html;
|
|
104
|
+
|
|
105
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
106
|
+
|
|
107
|
+
const wizard = document.getElementById("wizard-under-test");
|
|
108
|
+
wizard.setOption("validation.native", false);
|
|
109
|
+
wizard.setOption("validation.panels.account-email", () => false);
|
|
110
|
+
|
|
111
|
+
const moved = await wizard.next();
|
|
112
|
+
expect(moved).to.equal(false);
|
|
113
|
+
expect(wizard.getCurrentIndex()).to.equal(0);
|
|
114
|
+
|
|
115
|
+
wizard.setOption("validation.panels.account-email", () => true);
|
|
116
|
+
const movedAfter = await wizard.next();
|
|
117
|
+
expect(movedAfter).to.equal(true);
|
|
118
|
+
expect(wizard.getCurrentIndex()).to.equal(1);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("should block backward navigation when disabled", async function () {
|
|
122
|
+
const mocks = document.getElementById("mocks");
|
|
123
|
+
mocks.innerHTML = html;
|
|
124
|
+
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
126
|
+
|
|
127
|
+
const wizard = document.getElementById("wizard-under-test");
|
|
128
|
+
wizard.setOption("validation.native", false);
|
|
129
|
+
await wizard.goTo(1, { force: true });
|
|
130
|
+
wizard.setOption("features.allowBackNavigation", false);
|
|
131
|
+
|
|
132
|
+
const moved = await wizard.previous();
|
|
133
|
+
expect(moved).to.equal(false);
|
|
134
|
+
expect(wizard.getCurrentIndex()).to.equal(1);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("should complete navigation on submit", async function () {
|
|
138
|
+
const mocks = document.getElementById("mocks");
|
|
139
|
+
mocks.innerHTML = html;
|
|
140
|
+
|
|
141
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
142
|
+
|
|
143
|
+
const wizard = document.getElementById("wizard-under-test");
|
|
144
|
+
wizard.setOption("validation.native", false);
|
|
145
|
+
await wizard.goTo(2, { force: true });
|
|
146
|
+
|
|
147
|
+
const submitted = await wizard.submit();
|
|
148
|
+
expect(submitted).to.equal(true);
|
|
149
|
+
|
|
150
|
+
const navigation = wizard.shadowRoot.querySelector("monster-wizard-navigation");
|
|
151
|
+
expect(navigation.getCurrentStepIndex()).to.equal(-1);
|
|
152
|
+
});
|
|
153
|
+
});
|