@operato/input 8.0.0-beta.0 → 8.0.0-beta.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +7 -7
  3. package/.editorconfig +0 -29
  4. package/.storybook/main.js +0 -3
  5. package/.storybook/preview.js +0 -52
  6. package/.storybook/server.mjs +0 -8
  7. package/src/index.ts +0 -35
  8. package/src/locale/locale-codes.ts +0 -18
  9. package/src/locale/locale-picker.ts +0 -43
  10. package/src/locale/localization.ts +0 -15
  11. package/src/locales/en.ts +0 -30
  12. package/src/locales/ko.ts +0 -30
  13. package/src/locales/ms.ts +0 -30
  14. package/src/locales/zh.ts +0 -30
  15. package/src/ox-buttons-radio.ts +0 -140
  16. package/src/ox-checkbox.ts +0 -181
  17. package/src/ox-form-field.ts +0 -53
  18. package/src/ox-input-3axis.ts +0 -77
  19. package/src/ox-input-3dish.ts +0 -211
  20. package/src/ox-input-angle.ts +0 -73
  21. package/src/ox-input-barcode.ts +0 -318
  22. package/src/ox-input-code.ts +0 -139
  23. package/src/ox-input-color-gradient.ts +0 -349
  24. package/src/ox-input-color-stops.ts +0 -525
  25. package/src/ox-input-color.ts +0 -338
  26. package/src/ox-input-container.ts +0 -32
  27. package/src/ox-input-crontab.ts +0 -595
  28. package/src/ox-input-data.ts +0 -219
  29. package/src/ox-input-direction.ts +0 -92
  30. package/src/ox-input-duration.ts +0 -175
  31. package/src/ox-input-file.ts +0 -209
  32. package/src/ox-input-hashtags.ts +0 -185
  33. package/src/ox-input-i18n-label.ts +0 -140
  34. package/src/ox-input-image.ts +0 -168
  35. package/src/ox-input-key-values.ts +0 -301
  36. package/src/ox-input-layout/ox-input-card-layout.ts +0 -58
  37. package/src/ox-input-layout/ox-input-grid-layout.ts +0 -64
  38. package/src/ox-input-layout/ox-input-layout.ts +0 -77
  39. package/src/ox-input-mass-fraction.ts +0 -437
  40. package/src/ox-input-multiple-colors.ts +0 -135
  41. package/src/ox-input-options.ts +0 -216
  42. package/src/ox-input-partition-keys.ts +0 -303
  43. package/src/ox-input-privilege.ts +0 -163
  44. package/src/ox-input-quantifier.ts +0 -62
  45. package/src/ox-input-range.ts +0 -146
  46. package/src/ox-input-scene-component-id.ts +0 -73
  47. package/src/ox-input-search.ts +0 -126
  48. package/src/ox-input-select-buttons.ts +0 -75
  49. package/src/ox-input-signature.ts +0 -208
  50. package/src/ox-input-stack.ts +0 -136
  51. package/src/ox-input-switch.ts +0 -117
  52. package/src/ox-input-table-column-config.ts +0 -211
  53. package/src/ox-input-table.ts +0 -404
  54. package/src/ox-input-textarea.ts +0 -86
  55. package/src/ox-input-unit-number.ts +0 -354
  56. package/src/ox-input-value-map.ts +0 -342
  57. package/src/ox-input-value-ranges.ts +0 -363
  58. package/src/ox-input-work-shift.ts +0 -290
  59. package/src/ox-select-floor.ts +0 -246
  60. package/src/ox-select.ts +0 -219
  61. package/stories/image-for-select-floor.ts +0 -2
  62. package/stories/ox-buttons-radio.stories.ts +0 -89
  63. package/stories/ox-checkbox.stories.ts +0 -111
  64. package/stories/ox-input-3axis.stories.ts +0 -77
  65. package/stories/ox-input-3dish.stories.ts +0 -106
  66. package/stories/ox-input-angle.stories.ts +0 -84
  67. package/stories/ox-input-barcode.stories.ts +0 -117
  68. package/stories/ox-input-code.stories.ts +0 -99
  69. package/stories/ox-input-crontab.stories.ts +0 -82
  70. package/stories/ox-input-data.stories.ts +0 -82
  71. package/stories/ox-input-direction.stories.ts +0 -91
  72. package/stories/ox-input-duration.stories.ts +0 -84
  73. package/stories/ox-input-file.stories.ts +0 -111
  74. package/stories/ox-input-hashtags.stories.ts +0 -82
  75. package/stories/ox-input-i18n-label.stories.ts +0 -103
  76. package/stories/ox-input-key-values.stories.ts +0 -97
  77. package/stories/ox-input-mass-fraction.stories.ts +0 -102
  78. package/stories/ox-input-multiple-colors.stories.ts +0 -72
  79. package/stories/ox-input-options.stories.ts +0 -80
  80. package/stories/ox-input-partition-keys.stories.ts +0 -84
  81. package/stories/ox-input-privilege.stories.ts +0 -108
  82. package/stories/ox-input-quantifier.stories.ts +0 -80
  83. package/stories/ox-input-range.stories.ts +0 -89
  84. package/stories/ox-input-search.stories.ts +0 -91
  85. package/stories/ox-input-select-buttons.stories.ts +0 -118
  86. package/stories/ox-input-signature.stories.ts +0 -75
  87. package/stories/ox-input-switch.stories.ts +0 -91
  88. package/stories/ox-input-table-column-config.stories.ts +0 -109
  89. package/stories/ox-input-unit.stories.ts +0 -151
  90. package/stories/ox-input-value-map.stories.ts +0 -92
  91. package/stories/ox-input-value-ranges.stories.ts +0 -92
  92. package/stories/ox-input-work-shift.stories.ts +0 -106
  93. package/stories/ox-select-floor.stories.ts +0 -197
  94. package/stories/ox-select-set-options.stories.ts +0 -208
  95. package/stories/ox-select.stories.ts +0 -181
  96. package/tsconfig.json +0 -25
  97. package/web-dev-server.config.mjs +0 -27
  98. package/web-test-runner.config.mjs +0 -41
@@ -1,181 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- /*
6
- This component is inspired by https://github.com/Polydile/dile-components, thanks Dile.
7
- */
8
-
9
- import { css, html } from 'lit'
10
- import { customElement, property, state } from 'lit/decorators.js'
11
-
12
- import { OxFormField } from './ox-form-field'
13
-
14
- @customElement('ox-checkbox')
15
- export class OxCheckbox extends OxFormField {
16
- static styles = [
17
- css`
18
- div {
19
- display: flex;
20
- gap: var(--input-intra-gap, 7px);
21
-
22
- align-items: center;
23
- cursor: pointer;
24
- }
25
-
26
- [disabled] {
27
- opacity: var(--ox-checkbox-disabled-opacity, 0.5);
28
- cursor: auto;
29
- }
30
-
31
- .checkbox {
32
- display: flex;
33
- border-radius: var(--ox-checkbox-border-radius, 4px);
34
- background-color: var(--ox-checkbox-unchecked-background-color, var(--md-sys-color-surface-container-lowest));
35
- border: var(--ox-checkbox-unchecked-border, 1px solid var(--md-sys-color-outline));
36
- width: var(--ox-checkbox-size, 15px);
37
- height: var(--ox-checkbox-size, 15px);
38
- align-items: center;
39
- justify-content: center;
40
- }
41
-
42
- :host([checked]) .checkbox {
43
- background-color: var(--ox-checkbox-checked-background-color, var(--md-sys-color-primary));
44
- }
45
-
46
- path {
47
- fill: var(--ox-checkbox-unchecked-color, var(--md-sys-color-surface-container-lowest));
48
- }
49
-
50
- :host([indeterminate]) line {
51
- stroke: var(--ox-checkbox-intermidiate-color, var(--md-sys-color-outline));
52
- }
53
-
54
- :host([checked]) path {
55
- fill: var(--ox-checkbox-checked-color, var(--md-sys-color-on-primary));
56
- }
57
-
58
- svg {
59
- width: var(--ox-checkbox-size, 15px);
60
- height: var(--ox-checkbox-size, 15px);
61
- }
62
-
63
- .label {
64
- color: var(--ox-checkbox-label-color, var(--md-sys-color-on-surface));
65
- line-height: var(--md-sys-typescale-label-medium-line-height, 1rem);
66
- }
67
-
68
- :host([checked]) .label {
69
- color: var(ox-checkbox-label-checked-color, var(--md-sys-color-on-surface));
70
- font-weight: 700;
71
- }
72
- `
73
- ]
74
-
75
- @property({ type: Boolean, attribute: 'checked', reflect: true }) checked: boolean | undefined = false
76
- @property({ type: Boolean, attribute: 'indeterminatable' }) indeterminatable: boolean = false
77
- @property({ type: Boolean, attribute: 'indeterminate', reflect: true }) indeterminate: boolean = false
78
- @property({ type: Boolean, attribute: 'left-label' }) left: boolean = false
79
-
80
- @state() _hasInner: boolean = !!this.innerHTML.trim().length
81
-
82
- render() {
83
- return html`
84
- <div ?disabled=${this.disabled} @click=${this.onClick}>
85
- ${this._hasInner && this.left
86
- ? html` <span label>
87
- <slot></slot>
88
- </span>`
89
- : ''}
90
- <a href="#" @click=${(e: Event) => e.preventDefault()} class="checkbox">
91
- ${this.indeterminate ? this.indeterminateIcon : this.checked ? this.checkedIcon : this.uncheckedIcon}
92
- </a>
93
- ${this._hasInner && !this.left
94
- ? html` <span class="label">
95
- <slot></slot>
96
- </span>`
97
- : ''}
98
- </div>
99
- `
100
- }
101
-
102
- connectedCallback(): void {
103
- super.connectedCallback()
104
-
105
- this.setAttribute('tabindex', '0')
106
- this.addEventListener('keydown', this.onKeyDown)
107
- }
108
-
109
- disconnectedCallback(): void {
110
- super.disconnectedCallback()
111
-
112
- this.setAttribute('tabindex', '-1')
113
- this.removeEventListener('keydown', this.onKeyDown)
114
- }
115
-
116
- onClick() {
117
- if (this.disabled) {
118
- return
119
- }
120
-
121
- if (!this.indeterminatable) {
122
- this.indeterminate = false
123
- this.checked = !this.checked
124
- } else {
125
- if (this.indeterminate) {
126
- this.indeterminate = false
127
- this.checked = true
128
- } else if (this.checked) {
129
- this.indeterminate = false
130
- this.checked = false
131
- } else {
132
- this.indeterminate = true
133
- this.checked = undefined
134
- }
135
- }
136
-
137
- this.dispatchEvent(
138
- new CustomEvent('change', {
139
- bubbles: true,
140
- composed: true,
141
- detail: this.checked
142
- })
143
- )
144
- }
145
-
146
- get checkedIcon() {
147
- return html`
148
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
149
- <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
150
- </svg>
151
- `
152
- }
153
-
154
- get uncheckedIcon() {
155
- return html`
156
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
157
- <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
158
- </svg>
159
- `
160
- }
161
-
162
- get indeterminateIcon() {
163
- return html`
164
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
165
- <line x1="4" x2="20" y1="12" y2="12" stroke-width="2" stroke-linecap="round" />
166
- </svg>
167
- `
168
- }
169
-
170
- onKeyDown(e: KeyboardEvent) {
171
- e.preventDefault()
172
-
173
- if (e.key === ' ' || e.key == 'Spacebar') {
174
- this.onClick()
175
- }
176
- }
177
-
178
- protected appendFormData({ formData }: FormDataEvent): void {
179
- this.name && !this.indeterminate && formData.append(this.name, this.checked ? 'true' : 'false')
180
- }
181
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { LitElement } from 'lit'
6
- import { property } from 'lit/decorators.js'
7
-
8
- export abstract class OxFormField extends LitElement {
9
- @property({ type: String, attribute: true }) name?: string
10
- @property({ type: Boolean }) disabled?: boolean
11
- @property() value?: any
12
-
13
- protected _form: HTMLFormElement | null = null
14
- protected _formdataEventHandler: EventListener | null = null
15
-
16
- override connectedCallback(): void {
17
- super.connectedCallback()
18
-
19
- if (this.name) {
20
- this._form = this.closest('form')
21
- if (this._form) {
22
- this._formdataEventHandler = this.appendFormData.bind(this) as EventListener
23
- this._form.addEventListener('formdata', this._formdataEventHandler)
24
- }
25
- }
26
- }
27
-
28
- override disconnectedCallback(): void {
29
- super.disconnectedCallback()
30
-
31
- if (this._form) {
32
- this._form.removeEventListener('formdata', this._formdataEventHandler!)
33
- this._form = null
34
- this._formdataEventHandler = null
35
- }
36
- }
37
-
38
- protected appendFormData({ formData }: FormDataEvent): void {
39
- if (!this.name) return
40
-
41
- var values = this.value
42
- if (!(values instanceof Array)) {
43
- values = [this.value]
44
- }
45
-
46
- values.forEach((value: any) => {
47
- formData.append(
48
- this.name!,
49
- typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value)
50
- )
51
- })
52
- }
53
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { css, html } from 'lit'
6
- import { customElement, property } from 'lit/decorators.js'
7
-
8
- import { localized } from '@lit/localize'
9
-
10
- import { OxFormField } from './ox-form-field'
11
-
12
- @localized()
13
- @customElement('ox-input-3axis')
14
- export class OxInput3Axis extends OxFormField {
15
- static styles = [
16
- css`
17
- :host {
18
- display: flex;
19
- }
20
-
21
- input {
22
- box-sizing: border-box;
23
- padding: 0 var(--spacing-small);
24
- height: var(--form-element-height-medium);
25
- border: 1px solid var(--md-sys-color-outline);
26
- border-radius: var(--md-sys-shape-corner-small);
27
- background-color: var(--md-sys-color-on-primary);
28
- font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
29
- color: var(--md-sys-color-on-primary-container);
30
- }
31
-
32
- input:not(:last-child) {
33
- margin-right: var(--margin-default, 2px);
34
- }
35
-
36
- input:focus {
37
- outline: none;
38
- border-color: var(--md-sys-color-secondary-fixed-dim);
39
- }
40
- `
41
- ]
42
-
43
- firstUpdated() {
44
- this.renderRoot.addEventListener('change', this._onChange.bind(this))
45
- }
46
-
47
- _onChange(e: Event) {
48
- e.stopPropagation()
49
- e.preventDefault()
50
-
51
- var element = e.target as HTMLElement
52
- var id = element.id as 'x' | 'y' | 'z'
53
- var value = Number((element as HTMLInputElement).value)
54
-
55
- this.value = {
56
- ...this.value,
57
- [id]: value
58
- }
59
-
60
- this.dispatchEvent(
61
- new CustomEvent('change', {
62
- bubbles: true,
63
- composed: true,
64
- detail: this.value
65
- })
66
- )
67
- }
68
-
69
- render() {
70
- const { x, y, z } = this.value
71
- return html`
72
- <input type="number" id="x" placeholder="X" .value=${String(x)} ?disabled=${this.disabled} />
73
- <input type="number" id="y" placeholder="Y" .value=${String(y)} ?disabled=${this.disabled} />
74
- <input type="number" id="z" placeholder="Z" .value=${String(z)} ?disabled=${this.disabled} />
75
- `
76
- }
77
- }
@@ -1,211 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import './ox-input-angle'
6
-
7
- import { css, html } from 'lit'
8
- import { customElement, property } from 'lit/decorators.js'
9
-
10
- import { localized, msg } from '@lit/localize'
11
-
12
- import { OxFormField } from './ox-form-field'
13
- import { OxInputAngle } from './ox-input-angle'
14
-
15
- @localized()
16
- @customElement('ox-input-3dish')
17
- export class OxInput3Dish extends OxFormField {
18
- static styles = [
19
- css`
20
- :host {
21
- display: grid;
22
- grid-template-columns: repeat(7, minmax(50px, 1fr));
23
- grid-gap: var(--spacing-medium);
24
- }
25
-
26
- label {
27
- text-align: right;
28
- align-self: center;
29
- font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
30
- color: var(--md-sys-color-on-primary-container);
31
- text-transform: var(--label-text-transform);
32
- grid-column: span 1;
33
- }
34
-
35
- span {
36
- grid-column: span 2;
37
- text-align: center;
38
- font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
39
- color: var(--md-sys-color-surface-tint);
40
- font-weight: var(--md-sys-typescale-label-medium-weight, var(--md-ref-typeface-weight-medium, 500));
41
- }
42
-
43
- input,
44
- ox-input-angle {
45
- grid-column: span 2;
46
- box-sizing: border-box;
47
- padding: 0 var(--spacing-small);
48
- height: var(--form-element-height-medium);
49
- border: 1px solid var(--md-sys-color-outline);
50
- border-radius: var(--md-sys-shape-corner-small);
51
- overflow: hidden;
52
- background-color: var(--md-sys-color-on-primary);
53
- font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
54
- color: var(--md-sys-color-on-primary-container);
55
- }
56
-
57
- ox-input-angle {
58
- --input-border: 0;
59
- }
60
-
61
- input:focus {
62
- outline: none;
63
- border-color: var(--md-sys-color-secondary-fixed-dim);
64
- }
65
- `
66
- ]
67
-
68
- @property({ type: Object }) dimension?: { width?: number; height?: number; depth?: number }
69
- @property({ type: Object }) position?: { x?: number; y?: number; z?: number }
70
- @property({ type: Object }) rotate?: { x?: number; y?: number; z?: number }
71
- @property({ type: Object }) scale?: { x?: number; y?: number; z?: number }
72
-
73
- firstUpdated() {
74
- this.renderRoot.addEventListener('change', this._onChange.bind(this))
75
- }
76
-
77
- _onChange(e: Event) {
78
- e.stopPropagation()
79
- e.preventDefault()
80
-
81
- var element = e.target as HTMLElement
82
- var id = element.id
83
- var prop = id.substr(1)
84
- var value = Number((element as HTMLInputElement).value)
85
-
86
- switch (element.tagName) {
87
- case 'PROPERTY-ANGLE':
88
- value = Number((element as OxInputAngle).value || 0)
89
- break
90
- }
91
-
92
- switch (id) {
93
- case 'tx':
94
- case 'ty':
95
- case 'tz':
96
- this.position = {
97
- ...this.position,
98
- [prop]: value
99
- }
100
-
101
- this.dispatchEvent(
102
- new CustomEvent('position-changed', {
103
- bubbles: true,
104
- composed: true,
105
- detail: {
106
- value: this.position
107
- }
108
- })
109
- )
110
- break
111
-
112
- case 'rx':
113
- case 'ry':
114
- case 'rz':
115
- this.rotate = {
116
- ...this.rotate,
117
- [prop]: value
118
- }
119
-
120
- this.dispatchEvent(
121
- new CustomEvent('rotate-changed', {
122
- bubbles: true,
123
- composed: true,
124
- detail: {
125
- value: this.rotate
126
- }
127
- })
128
- )
129
- break
130
-
131
- case 'sx':
132
- case 'sy':
133
- case 'sz':
134
- this.scale = {
135
- ...this.scale,
136
- [prop]: value
137
- }
138
-
139
- this.dispatchEvent(
140
- new CustomEvent('scale-changed', {
141
- bubbles: true,
142
- composed: true,
143
- detail: {
144
- value: this.scale
145
- }
146
- })
147
- )
148
- break
149
-
150
- default:
151
- // dimension
152
- this.dimension = {
153
- ...this.dimension,
154
- [prop]: value
155
- }
156
-
157
- this.dispatchEvent(
158
- new CustomEvent('dimension-changed', {
159
- bubbles: true,
160
- composed: true,
161
- detail: {
162
- value: this.dimension
163
- }
164
- })
165
- )
166
- }
167
-
168
- this.value = {
169
- position: this.position,
170
- rotate: this.rotate,
171
- scale: this.scale,
172
- dimension: this.dimension
173
- }
174
-
175
- this.dispatchEvent(
176
- new CustomEvent('change', {
177
- bubbles: true,
178
- composed: true,
179
- detail: this.value
180
- })
181
- )
182
- }
183
-
184
- render() {
185
- return html`
186
- <label></label> <span>${msg('x-axes')}</span>
187
- <span>${msg('y-axes')}</span>
188
- <span>${msg('z-axes')}</span>
189
-
190
- <label>${msg('dimension')}</label>
191
- <input type="number" id="dwidth" .value=${String(this.dimension?.width)} ?disabled=${this.disabled} />
192
- <input type="number" id="dheight" .value=${String(this.dimension?.height)} ?disabled=${this.disabled} />
193
- <input type="number" id="ddepth" .value=${String(this.dimension?.depth)} ?disabled=${this.disabled} />
194
-
195
- <label>${msg('position')}</label>
196
- <input type="number" id="tx" .value=${String(this.position?.x)} ?disabled=${this.disabled} />
197
- <input type="number" id="ty" .value=${String(this.position?.y)} ?disabled=${this.disabled} />
198
- <input type="number" id="tz" .value=${String(this.position?.z)} ?disabled=${this.disabled} />
199
-
200
- <label>${msg('scale')}</label>
201
- <input type="number" id="sx" .value=${String(this.scale?.x)} ?disabled=${this.disabled} />
202
- <input type="number" id="sy" .value=${String(this.scale?.y)} ?disabled=${this.disabled} />
203
- <input type="number" id="sz" .value=${String(this.scale?.z)} ?disabled=${this.disabled} />
204
-
205
- <label>${msg('rotate')}</label>
206
- <ox-input-angle id="rx" .value=${String(this.rotate?.x)} ?disabled=${this.disabled}></ox-input-angle>
207
- <ox-input-angle id="ry" .value=${String(this.rotate?.y)} ?disabled=${this.disabled}></ox-input-angle>
208
- <ox-input-angle id="rz" .value=${String(this.rotate?.z)} ?disabled=${this.disabled}></ox-input-angle>
209
- `
210
- }
211
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { css, html } from 'lit'
6
- import { customElement, property, query } from 'lit/decorators.js'
7
-
8
- import { OxFormField } from './ox-form-field'
9
-
10
- @customElement('ox-input-angle')
11
- export class OxInputAngle extends OxFormField {
12
- static styles = [
13
- css`
14
- :host {
15
- display: inline-block;
16
- }
17
-
18
- input {
19
- width: 100%;
20
- height: 100%;
21
- min-height: var(--form-element-height-medium);
22
- padding: 0 var(--spacing-small);
23
- box-sizing: border-box;
24
- border: var(--input-border, 1px solid var(--md-sys-color-outline));
25
- border-radius: var(--md-sys-shape-corner-small);
26
- background-color: var(--md-sys-color-on-primary);
27
- font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
28
- color: var(--md-sys-color-on-primary-container);
29
- }
30
-
31
- input:focus {
32
- outline: var(--input-focus-outline, inherit);
33
- border-color: var(--md-sys-color-secondary-fixed-dim);
34
- }
35
- `
36
- ]
37
-
38
- @property({ type: String }) placeholder?: string
39
-
40
- @query('input') input!: HTMLInputElement
41
-
42
- render() {
43
- return html`
44
- <input
45
- type="number"
46
- .value=${String(this._toDegree(this.value))}
47
- .placeholder=${this.placeholder || '0°'}
48
- @change=${(e: Event) => this._onChangeValue(e)}
49
- ?disabled=${this.disabled}
50
- />
51
- `
52
- }
53
-
54
- _onChangeValue(e: Event) {
55
- this.value = this._toRadian(this.input.value)
56
-
57
- this.dispatchEvent(
58
- new CustomEvent('change', {
59
- bubbles: true,
60
- composed: true,
61
- detail: this.value
62
- })
63
- )
64
- }
65
-
66
- _toDegree(value: string | number | undefined) {
67
- return Math.round(((Number(value) || 0) * 180) / Math.PI)
68
- }
69
-
70
- _toRadian(degree: string | number | undefined) {
71
- return isNaN(Number(degree)) ? undefined : Number(degree) * (Math.PI / 180)
72
- }
73
- }