@operato/input 0.2.31 → 0.2.36
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 +65 -0
- package/demo/index-3dish.html +15 -2
- package/demo/index-angle.html +9 -4
- package/demo/index-button-radio.html +18 -6
- package/demo/index-checkbox.html +16 -5
- package/demo/index-stack.html +15 -3
- package/demo/index.html +79 -69
- package/dist/src/ox-buttons-radio.d.ts +7 -5
- package/dist/src/ox-buttons-radio.js +13 -9
- package/dist/src/ox-buttons-radio.js.map +1 -1
- package/dist/src/ox-checkbox.d.ts +5 -6
- package/dist/src/ox-checkbox.js +28 -25
- package/dist/src/ox-checkbox.js.map +1 -1
- package/dist/src/ox-formfield.d.ts +10 -0
- package/dist/src/ox-formfield.js +38 -0
- package/dist/src/ox-formfield.js.map +1 -0
- package/dist/src/ox-input-3dish.d.ts +15 -14
- package/dist/src/ox-input-3dish.js +51 -23
- package/dist/src/ox-input-3dish.js.map +1 -1
- package/dist/src/ox-input-angle.d.ts +4 -5
- package/dist/src/ox-input-angle.js +10 -12
- package/dist/src/ox-input-angle.js.map +1 -1
- package/dist/src/ox-input-stack.d.ts +5 -3
- package/dist/src/ox-input-stack.js +40 -35
- package/dist/src/ox-input-stack.js.map +1 -1
- package/dist/src/ox-select.d.ts +5 -4
- package/dist/src/ox-select.js +34 -12
- package/dist/src/ox-select.js.map +1 -1
- package/dist/test/property-angle.test.js +3 -3
- package/dist/test/property-angle.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/ox-buttons-radio.ts +15 -9
- package/src/ox-checkbox.ts +32 -25
- package/src/ox-formfield.ts +36 -0
- package/src/ox-input-3dish.ts +65 -29
- package/src/ox-input-angle.ts +11 -12
- package/src/ox-input-stack.ts +43 -24
- package/src/ox-select.ts +44 -15
- package/test/property-angle.test.ts +3 -4
@@ -2,20 +2,21 @@
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
3
|
*/
|
4
4
|
import { __decorate } from "tslib";
|
5
|
-
import { css, html
|
5
|
+
import { css, html } from 'lit';
|
6
6
|
import { customElement, property } from 'lit/decorators.js';
|
7
|
-
|
7
|
+
import { OxFormField } from './ox-formfield';
|
8
|
+
let OxInputStack = class OxInputStack extends OxFormField {
|
8
9
|
constructor() {
|
9
10
|
super(...arguments);
|
10
11
|
/**
|
11
12
|
* `stack`은 stack에 의해 만들어진 층의 배열을 유지한다.
|
12
13
|
*/
|
13
14
|
this.stack = [];
|
14
|
-
/**
|
15
|
-
* `activeIndex`은 현재 active된 층의 인덱스를 유지한다.
|
16
|
-
*/
|
17
|
-
this.activeIndex = 0;
|
18
15
|
}
|
16
|
+
/**
|
17
|
+
* `activeIndex`은 현재 active된 층의 인덱스를 유지한다.
|
18
|
+
*/
|
19
|
+
// @property({ type: Number }) activeIndex: number = 0
|
19
20
|
render() {
|
20
21
|
const stack = [...this.stack].reverse();
|
21
22
|
const length = stack.length;
|
@@ -23,47 +24,54 @@ let OxStack = class OxStack extends LitElement {
|
|
23
24
|
<button id="add-floor" @click=${(e) => this._onClickAddFloor(e)}>+</button>
|
24
25
|
|
25
26
|
${stack.map((item, index) => html `
|
26
|
-
<div
|
27
|
-
?active=${length - index - 1 == this.activeIndex}
|
28
|
-
@click=${(e) => this._onClickToActive(e)}
|
29
|
-
idx=${length - index - 1}
|
30
|
-
>
|
27
|
+
<div floor ?active=${item.active} @click=${(e) => this._onClickToActive(e)} idx=${length - index - 1}>
|
31
28
|
${item.name} <button @click=${(e) => this._onClickRemoveFloor(e)}>-</button>
|
32
29
|
</div>
|
33
30
|
`)}
|
34
31
|
`;
|
35
32
|
}
|
33
|
+
_notifyChange() {
|
34
|
+
this.value = this.stack;
|
35
|
+
this.dispatchEvent(new CustomEvent('change', { detail: this.value, bubbles: true, composed: true }));
|
36
|
+
}
|
36
37
|
_onClickAddFloor(e) {
|
37
38
|
this.stack.push({ name: String(this.stack.length + 1) });
|
38
39
|
this.requestUpdate();
|
40
|
+
this._notifyChange();
|
39
41
|
}
|
40
42
|
_onClickToActive(e) {
|
41
|
-
const
|
42
|
-
if (
|
43
|
+
const floor = e.target.closest('[floor]');
|
44
|
+
if (!floor) {
|
43
45
|
return;
|
44
46
|
}
|
45
|
-
|
47
|
+
e.stopPropagation();
|
48
|
+
const activeIndex = Number(floor.getAttribute('idx'));
|
49
|
+
this.stack = this.stack.map((floor, index) => {
|
50
|
+
return activeIndex === index
|
51
|
+
? {
|
52
|
+
name: floor.name,
|
53
|
+
active: true
|
54
|
+
}
|
55
|
+
: { name: floor.name };
|
56
|
+
});
|
57
|
+
this._notifyChange();
|
46
58
|
}
|
47
59
|
_onClickRemoveFloor(e) {
|
48
|
-
const
|
49
|
-
if (
|
60
|
+
const floor = e.target.closest('[floor]');
|
61
|
+
if (!floor) {
|
50
62
|
return;
|
51
63
|
}
|
52
|
-
|
64
|
+
e.stopPropagation();
|
65
|
+
const idx = Number(floor.getAttribute('idx'));
|
53
66
|
this.stack.splice(idx, 1);
|
54
|
-
if (this.activeIndex == idx) {
|
55
|
-
this.activeIndex = 0;
|
56
|
-
}
|
57
|
-
else if (this.activeIndex >= idx) {
|
58
|
-
this.activeIndex--;
|
59
|
-
}
|
60
|
-
else if (this.activeIndex >= this.stack.length) {
|
61
|
-
this.activeIndex = 0;
|
62
|
-
}
|
63
67
|
this.requestUpdate();
|
68
|
+
this._notifyChange();
|
69
|
+
}
|
70
|
+
appendFormData({ formData }) {
|
71
|
+
this.name && formData.append(this.name, JSON.stringify(this.value));
|
64
72
|
}
|
65
73
|
};
|
66
|
-
|
74
|
+
OxInputStack.styles = [
|
67
75
|
css `
|
68
76
|
:host {
|
69
77
|
display: block;
|
@@ -97,12 +105,9 @@ OxStack.styles = [
|
|
97
105
|
];
|
98
106
|
__decorate([
|
99
107
|
property({ type: Array })
|
100
|
-
],
|
101
|
-
__decorate([
|
102
|
-
|
103
|
-
],
|
104
|
-
|
105
|
-
customElement('ox-stack')
|
106
|
-
], OxStack);
|
107
|
-
export default OxStack;
|
108
|
+
], OxInputStack.prototype, "stack", void 0);
|
109
|
+
OxInputStack = __decorate([
|
110
|
+
customElement('ox-input-stack')
|
111
|
+
], OxInputStack);
|
112
|
+
export default OxInputStack;
|
108
113
|
//# sourceMappingURL=ox-input-stack.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-stack.js","sourceRoot":"","sources":["../../src/ox-input-stack.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,
|
1
|
+
{"version":3,"file":"ox-input-stack.js","sourceRoot":"","sources":["../../src/ox-input-stack.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG5C,IAAqB,YAAY,GAAjC,MAAqB,YAAa,SAAQ,WAAW;IAArD;;QAkCE;;WAEG;QACwB,UAAK,GAAyC,EAAE,CAAA;IAgF7E,CAAC;IA9EC;;OAEG;IACH,sDAAsD;IAEtD,MAAM;QACJ,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAE3B,OAAO,IAAI,CAAA;sCACuB,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;;QAEpE,KAAK,CAAC,GAAG,CACT,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAA;+BACE,IAAI,CAAC,MAAM,WAAW,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,MAAM,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,CAAC,CAAA;QAEF,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAED,mBAAmB,CAAC,CAAQ;QAC1B,MAAM,KAAK,GAAI,CAAC,CAAC,MAAsB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAE1D,IAAI,CAAC,KAAK,EAAE;YACV,OAAM;SACP;QAED,CAAC,CAAC,eAAe,EAAE,CAAA;QAEnB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;QAE7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAEzB,IAAI,CAAC,aAAa,EAAE,CAAA;QAEpB,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAES,cAAc,CAAC,EAAE,QAAQ,EAAiB;QAClD,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrE,CAAC;CACF,CAAA;AApHQ,mBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BF;CACF,CAAA;AAK0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CAAiD;AArCxD,YAAY;IADhC,aAAa,CAAC,gBAAgB,CAAC;GACX,YAAY,CAqHhC;eArHoB,YAAY","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-formfield'\n\n@customElement('ox-input-stack')\nexport default class OxInputStack extends OxFormField {\n static styles = [\n css`\n :host {\n display: block;\n }\n\n #add-floor {\n width: 100%;\n height: 20px;\n background-color: blue;\n color: white;\n }\n\n div {\n background-color: blue;\n width: calc(100% - 40px);\n width: -webkit-calc(100% - 40px);\n min-height: 20px;\n }\n\n div[active] {\n background-color: red;\n }\n\n div button {\n position: absolute;\n right: 10px;\n width: 30px;\n min-height: 20px;\n }\n `\n ]\n\n /**\n * `stack`은 stack에 의해 만들어진 층의 배열을 유지한다.\n */\n @property({ type: Array }) stack: { name: string; active?: boolean }[] = []\n\n /**\n * `activeIndex`은 현재 active된 층의 인덱스를 유지한다.\n */\n // @property({ type: Number }) activeIndex: number = 0\n\n render() {\n const stack = [...this.stack].reverse()\n const length = stack.length\n\n return html`\n <button id=\"add-floor\" @click=${(e: Event) => this._onClickAddFloor(e)}>+</button>\n\n ${stack.map(\n (item, index) => html`\n <div floor ?active=${item.active} @click=${(e: Event) => this._onClickToActive(e)} idx=${length - index - 1}>\n ${item.name} <button @click=${(e: Event) => this._onClickRemoveFloor(e)}>-</button>\n </div>\n `\n )}\n `\n }\n\n _notifyChange() {\n this.value = this.stack\n\n this.dispatchEvent(new CustomEvent('change', { detail: this.value, bubbles: true, composed: true }))\n }\n\n _onClickAddFloor(e: Event) {\n this.stack.push({ name: String(this.stack.length + 1) })\n this.requestUpdate()\n\n this._notifyChange()\n }\n\n _onClickToActive(e: Event) {\n const floor = (e.target as HTMLElement).closest('[floor]')\n\n if (!floor) {\n return\n }\n\n e.stopPropagation()\n\n const activeIndex = Number(floor.getAttribute('idx'))\n this.stack = this.stack.map((floor, index) => {\n return activeIndex === index\n ? {\n name: floor.name,\n active: true\n }\n : { name: floor.name }\n })\n\n this._notifyChange()\n }\n\n _onClickRemoveFloor(e: Event) {\n const floor = (e.target as HTMLElement).closest('[floor]')\n\n if (!floor) {\n return\n }\n\n e.stopPropagation()\n\n const idx = Number(floor.getAttribute('idx'))\n\n this.stack.splice(idx, 1)\n\n this.requestUpdate()\n\n this._notifyChange()\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n this.name && formData.append(this.name, JSON.stringify(this.value))\n }\n}\n"]}
|
package/dist/src/ox-select.d.ts
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
*/
|
4
4
|
import '@material/mwc-icon';
|
5
5
|
import '@operato/popup';
|
6
|
-
import {
|
7
|
-
export declare class Select extends
|
6
|
+
import { OxFormField } from './ox-formfield';
|
7
|
+
export declare class Select extends OxFormField {
|
8
8
|
static styles: import("lit").CSSResult[];
|
9
9
|
name: string;
|
10
|
-
|
10
|
+
placeholder: string;
|
11
11
|
render(): import("lit-html").TemplateResult<1>;
|
12
|
+
connectedCallback(): void;
|
12
13
|
expand(): void;
|
13
|
-
|
14
|
+
protected appendFormData({ formData }: FormDataEvent): void;
|
14
15
|
}
|
package/dist/src/ox-select.js
CHANGED
@@ -4,44 +4,63 @@
|
|
4
4
|
import { __decorate } from "tslib";
|
5
5
|
import '@material/mwc-icon';
|
6
6
|
import '@operato/popup';
|
7
|
-
import {
|
7
|
+
import { css, html } from 'lit';
|
8
8
|
import { customElement, property } from 'lit/decorators.js';
|
9
|
-
|
9
|
+
import { OxFormField } from './ox-formfield';
|
10
|
+
let Select = class Select extends OxFormField {
|
10
11
|
constructor() {
|
11
12
|
super(...arguments);
|
12
13
|
this.name = '';
|
13
|
-
this.
|
14
|
+
this.placeholder = '';
|
14
15
|
}
|
15
16
|
render() {
|
17
|
+
const label = (this.value instanceof Array ? this.value.join(', ') : this.value) || this.placeholder || '';
|
16
18
|
return html `
|
17
19
|
<div @click=${this.expand}>
|
18
|
-
<span>${
|
20
|
+
<span>${label}</span>
|
19
21
|
<mwc-icon>expand_more</mwc-icon>
|
20
22
|
</div>
|
23
|
+
|
21
24
|
<slot></slot>
|
22
25
|
`;
|
23
26
|
}
|
27
|
+
connectedCallback() {
|
28
|
+
super.connectedCallback();
|
29
|
+
this.setAttribute('tabindex', '0');
|
30
|
+
this.addEventListener('select', (e) => {
|
31
|
+
this.value = e.detail;
|
32
|
+
this.dispatchEvent(new CustomEvent('change', {
|
33
|
+
bubbles: true,
|
34
|
+
composed: true,
|
35
|
+
detail: this.value
|
36
|
+
}));
|
37
|
+
});
|
38
|
+
this.addEventListener('keydown', (e) => {
|
39
|
+
e.preventDefault();
|
40
|
+
if (e.key === ' ' || e.key == 'Spacebar' || e.key == 'ArrowDown') {
|
41
|
+
this.expand();
|
42
|
+
}
|
43
|
+
});
|
44
|
+
}
|
24
45
|
expand() {
|
25
46
|
const popupList = this.querySelector('ox-popup-list');
|
26
47
|
if (popupList) {
|
27
48
|
popupList.style.width = `${this.offsetWidth}px`;
|
28
49
|
popupList.open({
|
29
|
-
top: this.
|
30
|
-
left:
|
50
|
+
top: this.offsetHeight,
|
51
|
+
left: 0
|
31
52
|
});
|
32
53
|
}
|
33
54
|
}
|
34
|
-
|
35
|
-
|
36
|
-
if (e.keyCode == 32 || e.code == 'Space') {
|
37
|
-
this.expand();
|
38
|
-
}
|
55
|
+
appendFormData({ formData }) {
|
56
|
+
this.name && formData.append(this.name, JSON.stringify(this.value));
|
39
57
|
}
|
40
58
|
};
|
41
59
|
Select.styles = [
|
42
60
|
css `
|
43
61
|
:host {
|
44
62
|
display: block;
|
63
|
+
position: relative;
|
45
64
|
}
|
46
65
|
|
47
66
|
div {
|
@@ -54,6 +73,9 @@ Select.styles = [
|
|
54
73
|
|
55
74
|
span {
|
56
75
|
flex: 1;
|
76
|
+
overflow: hidden;
|
77
|
+
text-overflow: ellipsis;
|
78
|
+
white-space: nowrap;
|
57
79
|
}
|
58
80
|
|
59
81
|
mwc-icon {
|
@@ -75,7 +97,7 @@ __decorate([
|
|
75
97
|
], Select.prototype, "name", void 0);
|
76
98
|
__decorate([
|
77
99
|
property({ type: String })
|
78
|
-
], Select.prototype, "
|
100
|
+
], Select.prototype, "placeholder", void 0);
|
79
101
|
Select = __decorate([
|
80
102
|
customElement('ox-select')
|
81
103
|
], Select);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-select.js","sourceRoot":"","sources":["../../src/ox-select.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oBAAoB,CAAA;AAC3B,OAAO,gBAAgB,CAAA;AAEvB,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CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAgB,EAAE,EAAE;YACpD,CAAC,CAAC,cAAc,EAAE,CAAA;YAElB,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,UAAU,IAAI,CAAC,CAAC,GAAG,IAAI,WAAW,EAAE;gBAChE,IAAI,CAAC,MAAM,EAAE,CAAA;aACd;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM;QACJ,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,CAAgB,CAAA;QAEpE,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,CAAA;YAE/C,SAAS,CAAC,IAAI,CAAC;gBACb,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,IAAI,EAAE,CAAC;aACR,CAAC,CAAA;SACH;IACH,CAAC;IAES,cAAc,CAAC,EAAE,QAAQ,EAAiB;QAClD,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrE,CAAC;CACF,CAAA;AA/FQ,aAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiCF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAyB;AAvCzC,MAAM;IADlB,aAAa,CAAC,WAAW,CAAC;GACd,MAAM,CAgGlB;SAhGY,MAAM","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\nimport '@operato/popup'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-formfield'\nimport { OxPopupList } from '@operato/popup'\n\n@customElement('ox-select')\nexport class Select extends OxFormField {\n static styles = [\n css`\n :host {\n display: block;\n position: relative;\n }\n\n div {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n }\n\n span {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n mwc-icon {\n display: block;\n width: 24px;\n text-align: right;\n font-size: 18px;\n color: var(--theme-primary-text-color, #3c3938);\n opacity: 0.7;\n }\n\n ::slotted(ox-popup-list) {\n width: 100%;\n }\n `\n ]\n\n @property({ type: String }) name: string = ''\n @property({ type: String }) placeholder: string = ''\n\n render() {\n const label = (this.value instanceof Array ? this.value.join(', ') : this.value) || this.placeholder || ''\n\n return html`\n <div @click=${this.expand}>\n <span>${label}</span>\n <mwc-icon>expand_more</mwc-icon>\n </div>\n\n <slot></slot>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.setAttribute('tabindex', '0')\n\n this.addEventListener('select', (e: Event) => {\n this.value = (e as CustomEvent).detail\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n })\n\n this.addEventListener('keydown', (e: KeyboardEvent) => {\n e.preventDefault()\n\n if (e.key === ' ' || e.key == 'Spacebar' || e.key == 'ArrowDown') {\n this.expand()\n }\n })\n }\n\n expand() {\n const popupList = this.querySelector('ox-popup-list') as OxPopupList\n\n if (popupList) {\n popupList.style.width = `${this.offsetWidth}px`\n\n popupList.open({\n top: this.offsetHeight,\n left: 0\n })\n }\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n this.name && formData.append(this.name, JSON.stringify(this.value))\n }\n}\n"]}
|
@@ -1,15 +1,15 @@
|
|
1
|
-
import { html } from 'lit';
|
2
1
|
import { expect, fixture } from '@open-wc/testing';
|
2
|
+
import { html } from 'lit';
|
3
3
|
describe('OxInputAngle', () => {
|
4
4
|
it('has a default title "Hey there" and angle 5', async () => {
|
5
5
|
const el = await fixture(html `<ox-input-angle></ox-input-angle>`);
|
6
6
|
expect(el.title).to.equal('Hey there');
|
7
|
-
expect(el.
|
7
|
+
expect(el.value).to.equal(5);
|
8
8
|
});
|
9
9
|
it('increases the angle on button click', async () => {
|
10
10
|
const el = await fixture(html `<ox-input-angle></ox-input-angle>`);
|
11
11
|
el.shadowRoot.querySelector('button').click();
|
12
|
-
expect(el.
|
12
|
+
expect(el.value).to.equal(6);
|
13
13
|
});
|
14
14
|
it('can override the title via attribute', async () => {
|
15
15
|
const el = await fixture(html `<ox-input-angle title="attribute title"></ox-input-angle>`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"property-angle.test.js","sourceRoot":"","sources":["../../test/property-angle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"property-angle.test.js","sourceRoot":"","sources":["../../test/property-angle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,EAAE,GAAG,MAAM,OAAO,CAAe,IAAI,CAAA,mCAAmC,CAAC,CAAA;QAE/E,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QACtC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAe,IAAI,CAAA,mCAAmC,CAAC,CAAA;QAC/E,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAC,KAAK,EAAE,CAAA;QAE/C,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAe,IAAI,CAAA,2DAA2D,CAAC,CAAA;QAEvG,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAe,IAAI,CAAA,mCAAmC,CAAC,CAAA;QAE/E,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAA;IAC/C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\n\nimport { OxInputAngle } from '../src/ox-input-angle'\nimport { html } from 'lit'\n\ndescribe('OxInputAngle', () => {\n it('has a default title \"Hey there\" and angle 5', async () => {\n const el = await fixture<OxInputAngle>(html`<ox-input-angle></ox-input-angle>`)\n\n expect(el.title).to.equal('Hey there')\n expect(el.value).to.equal(5)\n })\n\n it('increases the angle on button click', async () => {\n const el = await fixture<OxInputAngle>(html`<ox-input-angle></ox-input-angle>`)\n el.shadowRoot!.querySelector('button')!.click()\n\n expect(el.value).to.equal(6)\n })\n\n it('can override the title via attribute', async () => {\n const el = await fixture<OxInputAngle>(html`<ox-input-angle title=\"attribute title\"></ox-input-angle>`)\n\n expect(el.title).to.equal('attribute title')\n })\n\n it('passes the a11y audit', async () => {\n const el = await fixture<OxInputAngle>(html`<ox-input-angle></ox-input-angle>`)\n\n await expect(el).shadowDom.to.be.accessible()\n })\n})\n"]}
|