@schukai/monster 4.141.3 → 4.142.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.
@@ -1,83 +1,97 @@
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";
1
+ import * as chai from "chai";
2
+ import { getGlobal } from "../../../../source/types/global.mjs";
3
+ import { chaiDom } from "../../../util/chai-dom.mjs";
4
+ import { initJSDOM } from "../../../util/jsdom.mjs";
5
5
 
6
- let expect = chai.expect;
6
+ const expect = chai.expect;
7
7
  chai.use(chaiDom);
8
8
 
9
9
  const global = getGlobal();
10
10
 
11
-
12
11
  // language=html
13
- let html1 = `
12
+ const html1 = `
14
13
  <monster-panel id="my-panel">
15
-
14
+
16
15
  </monster-panel>
17
16
  `;
18
17
 
19
- let SplitScreen;
20
-
21
- describe('SplitScreen', function () {
22
-
23
- before(function (done) {
24
- initJSDOM().then(() => {
25
-
26
- import("element-internals-polyfill").catch(e => done(e));
27
-
28
- let promises = []
29
-
30
- if (!global['crypto']) {
31
- promises.push(import("@peculiar/webcrypto").then((m) => {
32
- const Crypto = m['Crypto'];
33
- global['crypto'] = new Crypto();
34
- }));
35
- }
36
-
37
- promises.push(import("../../../../source/components/layout/panel.mjs").then((m) => {
38
- SplitScreen = m['Panel'];
39
- }))
40
-
41
- Promise.all(promises).then(()=>{
42
- done();
43
- }).catch(e => done(e))
44
-
45
- });
46
- })
47
-
48
- describe('document.createElement()', function () {
49
-
50
- afterEach(() => {
51
- let mocks = document.getElementById('mocks');
52
- mocks.innerHTML = "";
53
- })
54
-
55
- it('should have buttons and SplitScreen', function (done) {
56
-
57
- let mocks = document.getElementById('mocks');
58
- mocks.innerHTML = html1;
59
-
60
- setTimeout(() => {
61
- try {
62
- const SplitScreen = document.getElementById('my-panel')
63
- expect(SplitScreen).is.instanceof(HTMLElement);
64
-
65
- setTimeout(() => {
66
- let div = SplitScreen.shadowRoot.querySelector('div');
67
- expect(div.hasChildNodes()).to.be.true;
68
- done();
69
- }, 100)
70
-
71
- } catch (e) {
72
- return done(e);
73
- }
74
-
75
- }, 0)
76
-
77
-
78
- });
79
-
80
- });
81
-
82
-
83
- });
18
+ describe("SplitScreen", () => {
19
+ before((done) => {
20
+ initJSDOM().then(() => {
21
+ import("element-internals-polyfill").catch((e) => done(e));
22
+
23
+ const promises = [];
24
+
25
+ if (!global.crypto) {
26
+ promises.push(
27
+ import("@peculiar/webcrypto").then((m) => {
28
+ const Crypto = m.Crypto;
29
+ global.crypto = new Crypto();
30
+ }),
31
+ );
32
+ }
33
+
34
+ promises.push(import("../../../../source/components/layout/panel.mjs"));
35
+
36
+ Promise.all(promises)
37
+ .then(() => {
38
+ done();
39
+ })
40
+ .catch((e) => done(e));
41
+ });
42
+ });
43
+
44
+ describe("document.createElement()", () => {
45
+ afterEach(() => {
46
+ const mocks = document.getElementById("mocks");
47
+ mocks.innerHTML = "";
48
+ });
49
+
50
+ it("should have buttons and SplitScreen", (done) => {
51
+ const mocks = document.getElementById("mocks");
52
+ mocks.innerHTML = html1;
53
+
54
+ setTimeout(() => {
55
+ try {
56
+ const splitScreen = document.getElementById("my-panel");
57
+ expect(splitScreen).is.instanceof(HTMLElement);
58
+
59
+ setTimeout(() => {
60
+ const div = splitScreen.shadowRoot.querySelector("div");
61
+ expect(div.hasChildNodes()).to.be.true;
62
+ done();
63
+ }, 100);
64
+ } catch (e) {
65
+ return done(e);
66
+ }
67
+ }, 0);
68
+ });
69
+
70
+ it("should expose and apply the calculated maximum height", (done) => {
71
+ const mocks = document.getElementById("mocks");
72
+ mocks.innerHTML = html1;
73
+
74
+ setTimeout(() => {
75
+ try {
76
+ const panel = document.getElementById("my-panel");
77
+ panel.setOption("heightAdjustment", 8);
78
+ panel.getBoundingClientRect = () => ({ top: 120 });
79
+
80
+ Object.defineProperty(window, "innerHeight", {
81
+ value: 720,
82
+ configurable: true,
83
+ });
84
+
85
+ const height = panel.getMaximumHeight();
86
+
87
+ expect(height).to.equal(608);
88
+ expect(panel.recalculateHeight()).to.equal(panel);
89
+ expect(panel.style.height).to.equal("608px");
90
+ done();
91
+ } catch (e) {
92
+ return done(e);
93
+ }
94
+ }, 0);
95
+ });
96
+ });
97
+ });
@@ -1,83 +1,131 @@
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";
1
+ import * as chai from "chai";
2
+ import { getGlobal } from "../../../../source/types/global.mjs";
3
+ import { chaiDom } from "../../../util/chai-dom.mjs";
4
+ import { initJSDOM } from "../../../util/jsdom.mjs";
5
5
 
6
- let expect = chai.expect;
6
+ const expect = chai.expect;
7
7
  chai.use(chaiDom);
8
8
 
9
9
  const global = getGlobal();
10
10
 
11
-
12
11
  // language=html
13
- let html1 = `
12
+ const html1 = `
14
13
  <monster-split-panel id="my-split-panel">
15
-
14
+
16
15
  </monster-split-panel>
17
16
  `;
18
17
 
19
- let SplitScreen;
20
-
21
- describe('SplitScreen', function () {
22
-
23
- before(function (done) {
24
- initJSDOM().then(() => {
25
-
26
- import("element-internals-polyfill").catch(e => done(e));
27
-
28
- let promises = []
29
-
30
- if (!global['crypto']) {
31
- promises.push(import("@peculiar/webcrypto").then((m) => {
32
- const Crypto = m['Crypto'];
33
- global['crypto'] = new Crypto();
34
- }));
35
- }
36
-
37
- promises.push(import("../../../../source/components/layout/split-panel.mjs").then((m) => {
38
- SplitScreen = m['SplitPanel'];
39
- }))
40
-
41
- Promise.all(promises).then(()=>{
42
- done();
43
- }).catch(e => done(e))
44
-
45
- });
46
- })
47
-
48
- describe('document.createElement()', function () {
49
-
50
- afterEach(() => {
51
- let mocks = document.getElementById('mocks');
52
- mocks.innerHTML = "";
53
- })
54
-
55
- it('should have buttons and SplitScreen', function (done) {
56
-
57
- let mocks = document.getElementById('mocks');
58
- mocks.innerHTML = html1;
59
-
60
- setTimeout(() => {
61
- try {
62
- const SplitScreen = document.getElementById('my-split-panel')
63
- expect(SplitScreen).is.instanceof(HTMLElement);
64
-
65
- setTimeout(() => {
66
- let div = SplitScreen.shadowRoot.querySelector('div');
67
- expect(div.hasChildNodes()).to.be.true;
68
- done();
69
- }, 100)
70
-
71
- } catch (e) {
72
- return done(e);
73
- }
74
-
75
- }, 0)
76
-
77
-
78
- });
79
-
80
- });
81
-
82
-
83
- });
18
+ describe("SplitScreen", () => {
19
+ before((done) => {
20
+ initJSDOM().then(() => {
21
+ import("element-internals-polyfill").catch((e) => done(e));
22
+
23
+ const promises = [];
24
+
25
+ if (!global.crypto) {
26
+ promises.push(
27
+ import("@peculiar/webcrypto").then((m) => {
28
+ const Crypto = m.Crypto;
29
+ global.crypto = new Crypto();
30
+ }),
31
+ );
32
+ }
33
+
34
+ promises.push(
35
+ import("../../../../source/components/layout/split-panel.mjs"),
36
+ );
37
+
38
+ Promise.all(promises)
39
+ .then(() => {
40
+ done();
41
+ })
42
+ .catch((e) => done(e));
43
+ });
44
+ });
45
+
46
+ describe("document.createElement()", () => {
47
+ afterEach(() => {
48
+ const mocks = document.getElementById("mocks");
49
+ mocks.innerHTML = "";
50
+ });
51
+
52
+ it("should have buttons and SplitScreen", (done) => {
53
+ const mocks = document.getElementById("mocks");
54
+ mocks.innerHTML = html1;
55
+
56
+ setTimeout(() => {
57
+ try {
58
+ const splitScreen = document.getElementById("my-split-panel");
59
+ expect(splitScreen).is.instanceof(HTMLElement);
60
+
61
+ setTimeout(() => {
62
+ const div = splitScreen.shadowRoot.querySelector("div");
63
+ expect(div.hasChildNodes()).to.be.true;
64
+ done();
65
+ }, 100);
66
+ } catch (e) {
67
+ return done(e);
68
+ }
69
+ }, 0);
70
+ });
71
+
72
+ it("should use the configured dragger width for vertical panel dimensions", (done) => {
73
+ const mocks = document.getElementById("mocks");
74
+ mocks.innerHTML = html1;
75
+
76
+ setTimeout(() => {
77
+ try {
78
+ const splitPanel = document.getElementById("my-split-panel");
79
+ const dragger = splitPanel.shadowRoot.querySelector(
80
+ "[data-monster-role=dragger]",
81
+ );
82
+ const startPanel = splitPanel.shadowRoot.querySelector(
83
+ "[data-monster-role=startPanel]",
84
+ );
85
+ const endPanel = splitPanel.shadowRoot.querySelector(
86
+ "[data-monster-role=endPanel]",
87
+ );
88
+
89
+ dragger.style.setProperty("--monster-dragger-width", "12px");
90
+ splitPanel.setDimension("40%");
91
+
92
+ expect(startPanel.style.width).to.equal("40%");
93
+ expect(endPanel.style.width).to.equal("calc(60% - 12px)");
94
+ done();
95
+ } catch (e) {
96
+ return done(e);
97
+ }
98
+ }, 0);
99
+ });
100
+
101
+ it("should use the configured dragger width for horizontal panel dimensions", (done) => {
102
+ const mocks = document.getElementById("mocks");
103
+ mocks.innerHTML = html1;
104
+
105
+ setTimeout(() => {
106
+ try {
107
+ const splitPanel = document.getElementById("my-split-panel");
108
+ const dragger = splitPanel.shadowRoot.querySelector(
109
+ "[data-monster-role=dragger]",
110
+ );
111
+ const startPanel = splitPanel.shadowRoot.querySelector(
112
+ "[data-monster-role=startPanel]",
113
+ );
114
+ const endPanel = splitPanel.shadowRoot.querySelector(
115
+ "[data-monster-role=endPanel]",
116
+ );
117
+
118
+ dragger.style.setProperty("--monster-dragger-width", "14px");
119
+ splitPanel.setOption("splitType", "horizontal");
120
+ splitPanel.setDimension("35%");
121
+
122
+ expect(startPanel.style.height).to.equal("35%");
123
+ expect(endPanel.style.height).to.equal("calc(65% - 14px)");
124
+ done();
125
+ } catch (e) {
126
+ return done(e);
127
+ }
128
+ }, 0);
129
+ });
130
+ });
131
+ });