@spectrum-web-components/slider 0.12.7 → 0.12.8-express.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/slider",
3
- "version": "0.12.7",
3
+ "version": "0.12.8-express.6+374824f06",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -53,7 +53,7 @@
53
53
  "@spectrum-web-components/field-label": "^0.7.6",
54
54
  "@spectrum-web-components/number-field": "^0.3.7",
55
55
  "@spectrum-web-components/shared": "^0.13.6",
56
- "@spectrum-web-components/theme": "^0.10.1",
56
+ "@spectrum-web-components/theme": "^0.10.2-express.6+374824f06",
57
57
  "tslib": "^2.0.0"
58
58
  },
59
59
  "devDependencies": {
@@ -65,5 +65,5 @@
65
65
  "./sp-*.js",
66
66
  "./sync/sp-*.js"
67
67
  ],
68
- "gitHead": "caf12727e7f91dcf961e1fadacc727eea9ece27b"
68
+ "gitHead": "374824f06c36278e67f1616e9eae688b94a306a5"
69
69
  }
@@ -0,0 +1,14 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '@spectrum-web-components/number-field/sp-number-field.js';
13
+ import '../sp-slider.js';
14
+ //# sourceMappingURL=sp-slider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sp-slider.js","sourceRoot":"","sources":["sp-slider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,0DAA0D,CAAC;AAClE,OAAO,iBAAiB,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/number-field/sp-number-field.js';\nimport '../sp-slider.js';\n"]}
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '@spectrum-web-components/slider/sp-slider.js';
13
+ import { html } from 'lit';
14
+ import { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';
15
+ measureFixtureCreation(html `
16
+ <sp-slider
17
+ value="50"
18
+ step="1"
19
+ min="0"
20
+ max="100"
21
+ label="Opacity"
22
+ id="opacity-slider"
23
+ ></sp-slider>
24
+ `);
25
+ //# sourceMappingURL=test-basic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-basic.js","sourceRoot":"","sources":["test-basic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,8CAA8C,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,sBAAsB,CAAC,IAAI,CAAA;;;;;;;;;CAS1B,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/slider/sp-slider.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-slider\n value=\"50\"\n step=\"1\"\n min=\"0\"\n max=\"100\"\n label=\"Opacity\"\n id=\"opacity-slider\"\n ></sp-slider>\n`);\n"]}
@@ -0,0 +1,147 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '../sync/sp-slider.js';
13
+ import { editable, hideStepper } from '../stories/slider.stories.js';
14
+ import { elementUpdated, expect, fixture } from '@open-wc/testing';
15
+ import { sendKeys } from '@web/test-runner-commands';
16
+ import { spy } from 'sinon';
17
+ async function sliderFromFixture(sliderFixture) {
18
+ const el = await fixture(sliderFixture());
19
+ const slider = el.querySelector('sp-slider');
20
+ return slider;
21
+ }
22
+ describe('Slider - editable, sync', () => {
23
+ it('loads', async () => {
24
+ const el = await sliderFromFixture(editable);
25
+ await elementUpdated(el);
26
+ await expect(el).to.be.accessible();
27
+ });
28
+ it('loads - [hide-stepper]', async () => {
29
+ const el = await sliderFromFixture(hideStepper);
30
+ await elementUpdated(el);
31
+ await expect(el).to.be.accessible();
32
+ });
33
+ it('loads - [disabled]', async () => {
34
+ const el = document.createElement('sp-slider');
35
+ el.editable = true;
36
+ el.disabled = true;
37
+ el.label = 'Disabled, editable, slider';
38
+ try {
39
+ document.body.append(el);
40
+ }
41
+ catch (error) {
42
+ expect(true).to.be.false;
43
+ }
44
+ await elementUpdated(el);
45
+ await expect(el).to.be.accessible();
46
+ el.remove();
47
+ });
48
+ it('focuses `<sp-number-field>` directly', async () => {
49
+ const el = await sliderFromFixture(editable);
50
+ await elementUpdated(el);
51
+ el.focus();
52
+ await elementUpdated(el);
53
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
54
+ });
55
+ it('edits via the `<sp-number-field>`', async () => {
56
+ const inputSpy = spy();
57
+ const changeSpy = spy();
58
+ const el = await sliderFromFixture(editable);
59
+ el.addEventListener('input', () => inputSpy());
60
+ el.addEventListener('change', () => changeSpy());
61
+ await elementUpdated(el);
62
+ el.focus();
63
+ await elementUpdated(el);
64
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
65
+ expect(el.value).to.equal(90);
66
+ await sendKeys({ press: 'Backspace' });
67
+ await sendKeys({ press: 'Backspace' });
68
+ await sendKeys({ press: 'Backspace' });
69
+ await sendKeys({ type: '45' });
70
+ await sendKeys({ press: 'Enter' });
71
+ await elementUpdated(el);
72
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
73
+ expect(el.value).to.equal(45);
74
+ expect(inputSpy.callCount, 'one input').to.equal(1);
75
+ expect(changeSpy.callCount, 'one change').to.equal(1);
76
+ await sendKeys({ press: 'Backspace' });
77
+ await sendKeys({ press: 'Backspace' });
78
+ await sendKeys({ press: 'Backspace' });
79
+ await sendKeys({ press: 'Enter' });
80
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
81
+ expect(el.value).to.equal(45);
82
+ expect(inputSpy.callCount, 'still one input').to.equal(1);
83
+ expect(changeSpy.callCount, 'still one change').to.equal(1);
84
+ });
85
+ it('focuses `<input>` after pointer interactions', async () => {
86
+ let pointerId = -1;
87
+ const el = await sliderFromFixture(editable);
88
+ await elementUpdated(el);
89
+ expect(el.dragging).to.be.false;
90
+ expect(el.highlight).to.be.false;
91
+ expect(pointerId).to.equal(-1);
92
+ const handle = el.shadowRoot.querySelector('.handle');
93
+ el.track.setPointerCapture = (id) => (pointerId = id);
94
+ el.track.releasePointerCapture = (id) => (pointerId = id);
95
+ handle.dispatchEvent(new PointerEvent('pointerdown', {
96
+ button: 1,
97
+ pointerId: 1,
98
+ cancelable: true,
99
+ bubbles: true,
100
+ composed: true,
101
+ }));
102
+ await elementUpdated(el);
103
+ expect(el.dragging).to.be.false;
104
+ expect(pointerId, '1').to.equal(-1);
105
+ handle.dispatchEvent(new PointerEvent('pointerdown', {
106
+ button: 0,
107
+ pointerId: 1,
108
+ cancelable: true,
109
+ bubbles: true,
110
+ composed: true,
111
+ }));
112
+ await elementUpdated(el);
113
+ expect(el.dragging, 'it is dragging 1').to.be.true;
114
+ expect(pointerId, '2').to.equal(1);
115
+ handle.dispatchEvent(new PointerEvent('pointerup', {
116
+ pointerId: 2,
117
+ cancelable: true,
118
+ bubbles: true,
119
+ composed: true,
120
+ }));
121
+ await elementUpdated(el);
122
+ expect(el.dragging).to.be.false;
123
+ expect(el.highlight).to.be.false;
124
+ expect(pointerId, '3').to.equal(2);
125
+ handle.dispatchEvent(new PointerEvent('pointerdown', {
126
+ button: 0,
127
+ pointerId: 1,
128
+ cancelable: true,
129
+ bubbles: true,
130
+ composed: true,
131
+ }));
132
+ await elementUpdated(el);
133
+ expect(el.dragging, 'it is dragging 2').to.be.true;
134
+ expect(pointerId, '4').to.equal(1);
135
+ handle.dispatchEvent(new PointerEvent('pointercancel', {
136
+ pointerId: 3,
137
+ cancelable: true,
138
+ bubbles: true,
139
+ composed: true,
140
+ }));
141
+ await elementUpdated(el);
142
+ expect(el.dragging).to.be.false;
143
+ expect(pointerId, '5').to.equal(3);
144
+ expect(el.shadowRoot.activeElement).to.equal(el.handleController.inputForHandle(el));
145
+ });
146
+ });
147
+ //# sourceMappingURL=slider-editable-sync.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider-editable-sync.test.js","sourceRoot":"","sources":["slider-editable-sync.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,KAAK,UAAU,iBAAiB,CAC5B,aAAmC;IAEnC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAS,aAAa,EAAE,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC,WAAW,CAAW,CAAC;IACvD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;QACnB,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAE7C,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAEhD,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,MAAM,CAAC,EAAE,CAAC,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AAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CACxC,EAAE,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,CAAC,CACzC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '../sync/sp-slider.js';\nimport { Slider } from '../';\nimport { editable, hideStepper } from '../stories/slider.stories.js';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\nimport { TemplateResult } from '@spectrum-web-components/base';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { spy } from 'sinon';\n\nasync function sliderFromFixture(\n sliderFixture: () => TemplateResult\n): Promise<Slider> {\n const el = await fixture<Slider>(sliderFixture());\n const slider = el.querySelector('sp-slider') as Slider;\n return slider;\n}\n\ndescribe('Slider - editable, sync', () => {\n it('loads', async () => {\n const el = await sliderFromFixture(editable);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('loads - [hide-stepper]', async () => {\n const el = await sliderFromFixture(hideStepper);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('loads - [disabled]', async () => {\n const el = document.createElement('sp-slider');\n el.editable = true;\n el.disabled = true;\n el.label = 'Disabled, editable, slider';\n\n try {\n document.body.append(el);\n } catch (error) {\n expect(true).to.be.false;\n }\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n el.remove();\n });\n\n it('focuses `<sp-number-field>` directly', async () => {\n const el = await sliderFromFixture(editable);\n\n await elementUpdated(el);\n\n el.focus();\n\n await elementUpdated(el);\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n });\n\n it('edits via the `<sp-number-field>`', async () => {\n const inputSpy = spy();\n const changeSpy = spy();\n const el = await sliderFromFixture(editable);\n el.addEventListener('input', () => inputSpy());\n el.addEventListener('change', () => changeSpy());\n\n await elementUpdated(el);\n\n el.focus();\n\n await elementUpdated(el);\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n expect(el.value).to.equal(90);\n\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ type: '45' });\n await sendKeys({ press: 'Enter' });\n\n await elementUpdated(el);\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n expect(el.value).to.equal(45);\n expect(inputSpy.callCount, 'one input').to.equal(1);\n expect(changeSpy.callCount, 'one change').to.equal(1);\n\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Enter' });\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n expect(el.value).to.equal(45);\n expect(inputSpy.callCount, 'still one input').to.equal(1);\n expect(changeSpy.callCount, 'still one change').to.equal(1);\n });\n\n it('focuses `<input>` after pointer interactions', async () => {\n let pointerId = -1;\n const el = await sliderFromFixture(editable);\n\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(el.highlight).to.be.false;\n expect(pointerId).to.equal(-1);\n\n const handle = el.shadowRoot.querySelector('.handle') as HTMLDivElement;\n el.track.setPointerCapture = (id: number) => (pointerId = id);\n el.track.releasePointerCapture = (id: number) => (pointerId = id);\n handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button: 1,\n pointerId: 1,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(pointerId, '1').to.equal(-1);\n\n handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button: 0,\n pointerId: 1,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging, 'it is dragging 1').to.be.true;\n expect(pointerId, '2').to.equal(1);\n\n handle.dispatchEvent(\n new PointerEvent('pointerup', {\n pointerId: 2,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(el.highlight).to.be.false;\n expect(pointerId, '3').to.equal(2);\n\n handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button: 0,\n pointerId: 1,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging, 'it is dragging 2').to.be.true;\n expect(pointerId, '4').to.equal(1);\n\n handle.dispatchEvent(\n new PointerEvent('pointercancel', {\n pointerId: 3,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(pointerId, '5').to.equal(3);\n expect(el.shadowRoot.activeElement).to.equal(\n el.handleController.inputForHandle(el)\n );\n });\n});\n"]}
@@ -0,0 +1,147 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import '../sp-slider.js';
13
+ import { editable, hideStepper } from '../stories/slider.stories.js';
14
+ import { elementUpdated, expect, fixture } from '@open-wc/testing';
15
+ import { sendKeys } from '@web/test-runner-commands';
16
+ import { spy } from 'sinon';
17
+ async function sliderFromFixture(sliderFixture) {
18
+ const el = await fixture(sliderFixture({}));
19
+ const slider = el.querySelector('sp-slider');
20
+ return slider;
21
+ }
22
+ describe('Slider - editable', () => {
23
+ it('loads', async () => {
24
+ const el = await sliderFromFixture(editable);
25
+ await elementUpdated(el);
26
+ await expect(el).to.be.accessible();
27
+ });
28
+ it('loads - [hide-stepper]', async () => {
29
+ const el = await sliderFromFixture(hideStepper);
30
+ await elementUpdated(el);
31
+ await expect(el).to.be.accessible();
32
+ });
33
+ it('loads - [disabled]', async () => {
34
+ const el = document.createElement('sp-slider');
35
+ el.editable = true;
36
+ el.disabled = true;
37
+ el.label = 'Disabled, editable, slider';
38
+ try {
39
+ document.body.append(el);
40
+ }
41
+ catch (error) {
42
+ expect(true).to.be.false;
43
+ }
44
+ await elementUpdated(el);
45
+ await expect(el).to.be.accessible();
46
+ el.remove();
47
+ });
48
+ it('focuses `<sp-number-field>` directly', async () => {
49
+ const el = await sliderFromFixture(editable);
50
+ await elementUpdated(el);
51
+ el.focus();
52
+ await elementUpdated(el);
53
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
54
+ });
55
+ it('edits via the `<sp-number-field>`', async () => {
56
+ const inputSpy = spy();
57
+ const changeSpy = spy();
58
+ const el = await sliderFromFixture(editable);
59
+ el.addEventListener('input', () => inputSpy());
60
+ el.addEventListener('change', () => changeSpy());
61
+ await elementUpdated(el);
62
+ el.focus();
63
+ await elementUpdated(el);
64
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
65
+ expect(el.value).to.equal(90);
66
+ await sendKeys({ press: 'Backspace' });
67
+ await sendKeys({ press: 'Backspace' });
68
+ await sendKeys({ press: 'Backspace' });
69
+ await sendKeys({ type: '45' });
70
+ await sendKeys({ press: 'Enter' });
71
+ await elementUpdated(el);
72
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
73
+ expect(el.value).to.equal(45);
74
+ expect(inputSpy.callCount, 'one input').to.equal(1);
75
+ expect(changeSpy.callCount, 'one change').to.equal(1);
76
+ await sendKeys({ press: 'Backspace' });
77
+ await sendKeys({ press: 'Backspace' });
78
+ await sendKeys({ press: 'Backspace' });
79
+ await sendKeys({ press: 'Enter' });
80
+ expect(el.shadowRoot.activeElement).to.equal(el.numberField);
81
+ expect(el.value).to.equal(45);
82
+ expect(inputSpy.callCount, 'still one input').to.equal(1);
83
+ expect(changeSpy.callCount, 'still one change').to.equal(1);
84
+ });
85
+ it('focuses `<input>` after pointer interactions', async () => {
86
+ let pointerId = -1;
87
+ const el = await sliderFromFixture(editable);
88
+ await elementUpdated(el);
89
+ expect(el.dragging).to.be.false;
90
+ expect(el.highlight).to.be.false;
91
+ expect(pointerId).to.equal(-1);
92
+ const handle = el.shadowRoot.querySelector('.handle');
93
+ el.track.setPointerCapture = (id) => (pointerId = id);
94
+ el.track.releasePointerCapture = (id) => (pointerId = id);
95
+ handle.dispatchEvent(new PointerEvent('pointerdown', {
96
+ button: 1,
97
+ pointerId: 1,
98
+ cancelable: true,
99
+ bubbles: true,
100
+ composed: true,
101
+ }));
102
+ await elementUpdated(el);
103
+ expect(el.dragging).to.be.false;
104
+ expect(pointerId, '1').to.equal(-1);
105
+ handle.dispatchEvent(new PointerEvent('pointerdown', {
106
+ button: 0,
107
+ pointerId: 1,
108
+ cancelable: true,
109
+ bubbles: true,
110
+ composed: true,
111
+ }));
112
+ await elementUpdated(el);
113
+ expect(el.dragging, 'it is dragging 1').to.be.true;
114
+ expect(pointerId, '2').to.equal(1);
115
+ handle.dispatchEvent(new PointerEvent('pointerup', {
116
+ pointerId: 2,
117
+ cancelable: true,
118
+ bubbles: true,
119
+ composed: true,
120
+ }));
121
+ await elementUpdated(el);
122
+ expect(el.dragging).to.be.false;
123
+ expect(el.highlight).to.be.false;
124
+ expect(pointerId, '3').to.equal(2);
125
+ handle.dispatchEvent(new PointerEvent('pointerdown', {
126
+ button: 0,
127
+ pointerId: 1,
128
+ cancelable: true,
129
+ bubbles: true,
130
+ composed: true,
131
+ }));
132
+ await elementUpdated(el);
133
+ expect(el.dragging, 'it is dragging 2').to.be.true;
134
+ expect(pointerId, '4').to.equal(1);
135
+ handle.dispatchEvent(new PointerEvent('pointercancel', {
136
+ pointerId: 3,
137
+ cancelable: true,
138
+ bubbles: true,
139
+ composed: true,
140
+ }));
141
+ await elementUpdated(el);
142
+ expect(el.dragging).to.be.false;
143
+ expect(pointerId, '5').to.equal(3);
144
+ expect(el.shadowRoot.activeElement).to.equal(el.handleController.inputForHandle(el));
145
+ });
146
+ });
147
+ //# sourceMappingURL=slider-editable.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider-editable.test.js","sourceRoot":"","sources":["slider-editable.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAa,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,KAAK,UAAU,iBAAiB,CAC5B,aAAkD;IAElD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAS,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC,WAAW,CAAW,CAAC;IACvD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;QACnB,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAE7C,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CA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Z,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACjB,CAAC,CACL,CAAC;QACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAChC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CACxC,EAAE,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,CAAC,CACzC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '../sp-slider.js';\nimport { Slider } from '../';\nimport { editable, hideStepper, StoryArgs } from '../stories/slider.stories.js';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\nimport { TemplateResult } from '@spectrum-web-components/base';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { spy } from 'sinon';\n\nasync function sliderFromFixture(\n sliderFixture: (args: StoryArgs) => TemplateResult\n): Promise<Slider> {\n const el = await fixture<Slider>(sliderFixture({}));\n const slider = el.querySelector('sp-slider') as Slider;\n return slider;\n}\n\ndescribe('Slider - editable', () => {\n it('loads', async () => {\n const el = await sliderFromFixture(editable);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('loads - [hide-stepper]', async () => {\n const el = await sliderFromFixture(hideStepper);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('loads - [disabled]', async () => {\n const el = document.createElement('sp-slider');\n el.editable = true;\n el.disabled = true;\n el.label = 'Disabled, editable, slider';\n\n try {\n document.body.append(el);\n } catch (error) {\n expect(true).to.be.false;\n }\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n el.remove();\n });\n\n it('focuses `<sp-number-field>` directly', async () => {\n const el = await sliderFromFixture(editable);\n\n await elementUpdated(el);\n\n el.focus();\n\n await elementUpdated(el);\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n });\n\n it('edits via the `<sp-number-field>`', async () => {\n const inputSpy = spy();\n const changeSpy = spy();\n const el = await sliderFromFixture(editable);\n el.addEventListener('input', () => inputSpy());\n el.addEventListener('change', () => changeSpy());\n\n await elementUpdated(el);\n\n el.focus();\n\n await elementUpdated(el);\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n expect(el.value).to.equal(90);\n\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ type: '45' });\n await sendKeys({ press: 'Enter' });\n\n await elementUpdated(el);\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n expect(el.value).to.equal(45);\n expect(inputSpy.callCount, 'one input').to.equal(1);\n expect(changeSpy.callCount, 'one change').to.equal(1);\n\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Backspace' });\n await sendKeys({ press: 'Enter' });\n\n expect(el.shadowRoot.activeElement).to.equal(el.numberField);\n expect(el.value).to.equal(45);\n expect(inputSpy.callCount, 'still one input').to.equal(1);\n expect(changeSpy.callCount, 'still one change').to.equal(1);\n });\n\n it('focuses `<input>` after pointer interactions', async () => {\n let pointerId = -1;\n const el = await sliderFromFixture(editable);\n\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(el.highlight).to.be.false;\n expect(pointerId).to.equal(-1);\n\n const handle = el.shadowRoot.querySelector('.handle') as HTMLDivElement;\n el.track.setPointerCapture = (id: number) => (pointerId = id);\n el.track.releasePointerCapture = (id: number) => (pointerId = id);\n handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button: 1,\n pointerId: 1,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(pointerId, '1').to.equal(-1);\n\n handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button: 0,\n pointerId: 1,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging, 'it is dragging 1').to.be.true;\n expect(pointerId, '2').to.equal(1);\n\n handle.dispatchEvent(\n new PointerEvent('pointerup', {\n pointerId: 2,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(el.highlight).to.be.false;\n expect(pointerId, '3').to.equal(2);\n\n handle.dispatchEvent(\n new PointerEvent('pointerdown', {\n button: 0,\n pointerId: 1,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging, 'it is dragging 2').to.be.true;\n expect(pointerId, '4').to.equal(1);\n\n handle.dispatchEvent(\n new PointerEvent('pointercancel', {\n pointerId: 3,\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n await elementUpdated(el);\n\n expect(el.dragging).to.be.false;\n expect(pointerId, '5').to.equal(3);\n expect(el.shadowRoot.activeElement).to.equal(\n el.handleController.inputForHandle(el)\n );\n });\n});\n"]}
@@ -0,0 +1,38 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { expect, fixture, html } from '@open-wc/testing';
13
+ import '../sp-slider.js';
14
+ describe('Slider - upgrade order', () => {
15
+ it('loads both handles when document imports sp-slider-handle after sp-slider', async () => {
16
+ const el = await fixture(html `
17
+ <sp-slider variant="range" step="1" min="0" max="255">
18
+ Output Levels
19
+ <sp-slider-handle
20
+ slot="handle"
21
+ name="min"
22
+ label="Minimum"
23
+ value="5"
24
+ ></sp-slider-handle>
25
+ <sp-slider-handle
26
+ slot="handle"
27
+ name="max"
28
+ label="Maximum"
29
+ value="250"
30
+ ></sp-slider-handle>
31
+ </sp-slider>
32
+ `);
33
+ import('../sp-slider-handle.js');
34
+ const handles = el.shadowRoot.querySelectorAll('.handle');
35
+ expect(handles).to.have.lengthOf(2);
36
+ });
37
+ });
38
+ //# sourceMappingURL=slider-handle-upgrade.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider-handle-upgrade.test.js","sourceRoot":"","sources":["slider-handle-upgrade.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,iBAAiB,CAAC;AAGzB,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,2EAA2E,EAAE,KAAK,IAAI,EAAE;QACvF,MAAM,EAAE,GAAG,MAAM,OAAO,CAAS,IAAI,CAAA;;;;;;;;;;;;;;;;SAgBpC,CAAC,CAAC;QAEH,MAAM,CAAC,wBAAwB,CAAC,CAAC;QAEjC,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2021 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { expect, fixture, html } from '@open-wc/testing';\nimport '../sp-slider.js';\nimport { Slider } from '../src/Slider.js';\n\ndescribe('Slider - upgrade order', () => {\n it('loads both handles when document imports sp-slider-handle after sp-slider', async () => {\n const el = await fixture<Slider>(html`\n <sp-slider variant=\"range\" step=\"1\" min=\"0\" max=\"255\">\n Output Levels\n <sp-slider-handle\n slot=\"handle\"\n name=\"min\"\n label=\"Minimum\"\n value=\"5\"\n ></sp-slider-handle>\n <sp-slider-handle\n slot=\"handle\"\n name=\"max\"\n label=\"Maximum\"\n value=\"250\"\n ></sp-slider-handle>\n </sp-slider>\n `);\n\n import('../sp-slider-handle.js');\n\n const handles = el.shadowRoot.querySelectorAll('.handle');\n expect(handles).to.have.lengthOf(2);\n });\n});\n"]}
@@ -0,0 +1,15 @@
1
+ /*
2
+ Copyright 2020 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import * as stories from '../stories/slider.stories.js';
13
+ import { regressVisuals } from '../../../test/visual/test.js';
14
+ regressVisuals('SliderStories', stories);
15
+ //# sourceMappingURL=slider.test-vrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.test-vrt.js","sourceRoot":"","sources":["slider.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/slider.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('SliderStories', stories);\n"]}