@schukai/monster 4.129.0 → 4.129.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.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/source/components/form/message-state-button.mjs +233 -18
- package/source/components/form/style/message-state-button.pcss +46 -3
- package/source/components/form/stylesheet/message-state-button.mjs +7 -14
- package/source/components/form/stylesheet/popper-button.mjs +7 -14
- package/source/components/layout/popper.mjs +72 -1
- package/source/components/layout/stylesheet/popper.mjs +7 -14
- package/source/components/style/floating-ui.css +1 -49
- package/source/components/style/floating-ui.pcss +10 -0
- package/source/components/stylesheet/floating-ui.mjs +7 -14
- package/source/dom/util/extract-keys.mjs +46 -10
- package/source/dom/util/init-options-from-attributes.mjs +4 -2
- package/source/dom/util/set-option-from-attribute.mjs +4 -2
- package/test/cases/components/form/message-state-button.mjs +272 -0
- package/test/cases/components/form/popper-button.mjs +89 -0
- package/test/cases/dom/util/extract-keys.mjs +34 -23
- package/test/cases/dom/util/init-options-from-attributes.mjs +21 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as chai from "chai";
|
|
2
|
+
import { chaiDom } from "../../../util/chai-dom.mjs";
|
|
3
|
+
import { initJSDOM } from "../../../util/jsdom.mjs";
|
|
4
|
+
|
|
5
|
+
let expect = chai.expect;
|
|
6
|
+
chai.use(chaiDom);
|
|
7
|
+
|
|
8
|
+
let PopperButton;
|
|
9
|
+
|
|
10
|
+
describe("PopperButton", function () {
|
|
11
|
+
before(function (done) {
|
|
12
|
+
initJSDOM()
|
|
13
|
+
.then(() => {
|
|
14
|
+
return import("../../../../source/components/form/popper-button.mjs");
|
|
15
|
+
})
|
|
16
|
+
.then((m) => {
|
|
17
|
+
PopperButton = m["PopperButton"];
|
|
18
|
+
done();
|
|
19
|
+
})
|
|
20
|
+
.catch((e) => done(e));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
let mocks = document.getElementById("mocks");
|
|
25
|
+
mocks.innerHTML = "";
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should instance of popper-button", function () {
|
|
29
|
+
expect(document.createElement("monster-popper-button")).is.instanceof(
|
|
30
|
+
PopperButton,
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should apply content overflow mode to the rendered content wrapper", function (done) {
|
|
35
|
+
let mocks = document.getElementById("mocks");
|
|
36
|
+
const button = document.createElement("monster-popper-button");
|
|
37
|
+
mocks.appendChild(button);
|
|
38
|
+
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
try {
|
|
41
|
+
const content = button.shadowRoot.querySelector('[part="content"]');
|
|
42
|
+
expect(content).to.exist;
|
|
43
|
+
expect(content.getAttribute("data-monster-overflow-mode")).to.equal(
|
|
44
|
+
"both",
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
button.setOption("popper.contentOverflow", "horizontal");
|
|
48
|
+
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
try {
|
|
51
|
+
expect(
|
|
52
|
+
content.getAttribute("data-monster-overflow-mode"),
|
|
53
|
+
).to.equal("horizontal");
|
|
54
|
+
done();
|
|
55
|
+
} catch (e) {
|
|
56
|
+
done(e);
|
|
57
|
+
}
|
|
58
|
+
}, 0);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
done(e);
|
|
61
|
+
}
|
|
62
|
+
}, 0);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should apply content overflow mode from the HTML attribute", function (done) {
|
|
66
|
+
let mocks = document.getElementById("mocks");
|
|
67
|
+
mocks.innerHTML = `
|
|
68
|
+
<monster-popper-button
|
|
69
|
+
data-monster-option-popper-content-overflow="horizontal"
|
|
70
|
+
></monster-popper-button>
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
try {
|
|
75
|
+
const button = mocks.querySelector("monster-popper-button");
|
|
76
|
+
const content = button.shadowRoot.querySelector('[part="content"]');
|
|
77
|
+
expect(button.getOption("popper.contentOverflow")).to.equal(
|
|
78
|
+
"horizontal",
|
|
79
|
+
);
|
|
80
|
+
expect(content.getAttribute("data-monster-overflow-mode")).to.equal(
|
|
81
|
+
"horizontal",
|
|
82
|
+
);
|
|
83
|
+
done();
|
|
84
|
+
} catch (e) {
|
|
85
|
+
done(e);
|
|
86
|
+
}
|
|
87
|
+
}, 0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -13,16 +13,14 @@ describe('extractKeys', () => {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const expected = new Map([
|
|
17
|
-
['firstname', 'firstName'],
|
|
18
|
-
['lastname', 'lastName'],
|
|
19
|
-
['address-street', 'address.street'],
|
|
20
|
-
['address-city', 'address.city'],
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
16
|
const result = extractKeys(obj);
|
|
24
17
|
|
|
25
|
-
expect(
|
|
18
|
+
expect(result.get('firstname')).to.equal('firstName');
|
|
19
|
+
expect(result.get('first-name')).to.equal('firstName');
|
|
20
|
+
expect(result.get('lastname')).to.equal('lastName');
|
|
21
|
+
expect(result.get('last-name')).to.equal('lastName');
|
|
22
|
+
expect(result.get('address-street')).to.equal('address.street');
|
|
23
|
+
expect(result.get('address-city')).to.equal('address.city');
|
|
26
24
|
});
|
|
27
25
|
|
|
28
26
|
it('should use custom key and value separators', () => {
|
|
@@ -31,14 +29,12 @@ describe('extractKeys', () => {
|
|
|
31
29
|
lastName: 'Doe',
|
|
32
30
|
};
|
|
33
31
|
|
|
34
|
-
const expected = new Map([
|
|
35
|
-
['prefix+firstname', 'prefix+firstName'],
|
|
36
|
-
['prefix+lastname', 'prefix+lastName'],
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
32
|
const result = extractKeys(obj, 'prefix', '+', '+');
|
|
40
33
|
|
|
41
|
-
expect(
|
|
34
|
+
expect(result.get('prefix+firstname')).to.equal('prefix+firstName');
|
|
35
|
+
expect(result.get('prefix+first-name')).to.equal('prefix+firstName');
|
|
36
|
+
expect(result.get('prefix+lastname')).to.equal('prefix+lastName');
|
|
37
|
+
expect(result.get('prefix+last-name')).to.equal('prefix+lastName');
|
|
42
38
|
});
|
|
43
39
|
|
|
44
40
|
it('check if value is null', () => {
|
|
@@ -48,17 +44,32 @@ describe('extractKeys', () => {
|
|
|
48
44
|
address: null,
|
|
49
45
|
};
|
|
50
46
|
|
|
51
|
-
const expected = new Map([
|
|
52
|
-
['firstname', 'firstName'],
|
|
53
|
-
['lastname', 'lastName'],
|
|
54
|
-
['address', 'address'],
|
|
55
|
-
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
47
|
const result = extractKeys(obj);
|
|
59
48
|
|
|
60
|
-
expect(
|
|
49
|
+
expect(result.get('firstname')).to.equal('firstName');
|
|
50
|
+
expect(result.get('first-name')).to.equal('firstName');
|
|
51
|
+
expect(result.get('lastname')).to.equal('lastName');
|
|
52
|
+
expect(result.get('last-name')).to.equal('lastName');
|
|
53
|
+
expect(result.get('address')).to.equal('address');
|
|
61
54
|
});
|
|
62
55
|
|
|
63
|
-
|
|
56
|
+
it('should expose kebab-case aliases for camelCase nested keys', () => {
|
|
57
|
+
const obj = {
|
|
58
|
+
popper: {
|
|
59
|
+
contentOverflow: 'both',
|
|
60
|
+
},
|
|
61
|
+
message: {
|
|
62
|
+
width: {
|
|
63
|
+
viewportRatio: 0.7,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const result = extractKeys(obj);
|
|
69
|
+
|
|
70
|
+
expect(result.get('popper-contentoverflow')).to.equal('popper.contentOverflow');
|
|
71
|
+
expect(result.get('popper-content-overflow')).to.equal('popper.contentOverflow');
|
|
72
|
+
expect(result.get('message-width-viewportratio')).to.equal('message.width.viewportRatio');
|
|
73
|
+
expect(result.get('message-width-viewport-ratio')).to.equal('message.width.viewportRatio');
|
|
74
|
+
});
|
|
64
75
|
});
|
|
@@ -164,4 +164,25 @@ describe('initOptionsFromAttributes', () => {
|
|
|
164
164
|
expect(result.key.caseSensitive).to.equal(false);
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
+
it('should support kebab-case aliases for camelCase option names', () => {
|
|
168
|
+
options = {
|
|
169
|
+
popper: {
|
|
170
|
+
contentOverflow: 'both',
|
|
171
|
+
},
|
|
172
|
+
message: {
|
|
173
|
+
width: {
|
|
174
|
+
viewportRatio: 0.7,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
element.setAttribute('data-monster-option-popper-content-overflow', 'horizontal');
|
|
180
|
+
element.setAttribute('data-monster-option-message-width-viewport-ratio', '0.9');
|
|
181
|
+
|
|
182
|
+
const result = initOptionsFromAttributes(element, options);
|
|
183
|
+
|
|
184
|
+
expect(result.popper.contentOverflow).to.equal('horizontal');
|
|
185
|
+
expect(result.message.width.viewportRatio).to.equal(0.9);
|
|
186
|
+
});
|
|
187
|
+
|
|
167
188
|
});
|