@operato/input 1.2.10 → 1.2.25

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
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/input",
3
3
  "description": "Webcomponents for input following open-wc recommendations",
4
4
  "author": "heartyoh@hatiolab.com",
5
- "version": "1.2.10",
5
+ "version": "1.2.25",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "publishConfig": {
@@ -50,6 +50,109 @@
50
50
  "./ox-input-hashtags.js": "./dist/src/ox-input-hashtags.js",
51
51
  "./ox-input-mass-fraction.js": "./dist/src/ox-input-mass-fraction.js"
52
52
  },
53
+ "typesVersions": {
54
+ "*": {
55
+ "./ox-form-field.js": [
56
+ "./dist/src/ox-form-field.d.ts"
57
+ ],
58
+ "./ox-checkbox.js": [
59
+ "./dist/src/ox-checkbox.d.ts"
60
+ ],
61
+ "./ox-buttons-radio.js": [
62
+ "./dist/src/ox-buttons-radio.d.ts"
63
+ ],
64
+ "./ox-input-3dish.js": [
65
+ "./dist/src/ox-input-3dish.d.ts"
66
+ ],
67
+ "./ox-input-unit-number.js": [
68
+ "./dist/src/ox-input-unit-number.d.ts"
69
+ ],
70
+ "./ox-input-angle.js": [
71
+ "./dist/src/ox-input-angle.d.ts"
72
+ ],
73
+ "./ox-input-barcode.js": [
74
+ "./dist/src/ox-input-barcode.d.ts"
75
+ ],
76
+ "./ox-input-code.js": [
77
+ "./dist/src/ox-input-code.d.ts"
78
+ ],
79
+ "./ox-input-color.js": [
80
+ "./dist/src/ox-input-color.d.ts"
81
+ ],
82
+ "./ox-input-multiple-colors.js": [
83
+ "./dist/src/ox-input-multiple-colors.d.ts"
84
+ ],
85
+ "./ox-input-color-stops.js": [
86
+ "./dist/src/ox-input-color-stops.d.ts"
87
+ ],
88
+ "./ox-input-color-gradient.js": [
89
+ "./dist/src/ox-input-color-gradient.d.ts"
90
+ ],
91
+ "./ox-input-crontab.js": [
92
+ "./dist/src/ox-input-crontab.d.ts"
93
+ ],
94
+ "./ox-input-data.js": [
95
+ "./dist/src/ox-input-data.d.ts"
96
+ ],
97
+ "./ox-input-duration.js": [
98
+ "./dist/src/ox-input-duration.d.ts"
99
+ ],
100
+ "./ox-input-quantifier.js": [
101
+ "./dist/src/ox-input-quantifier.d.ts"
102
+ ],
103
+ "./ox-input-stack.js": [
104
+ "./dist/src/ox-input-stack.d.ts"
105
+ ],
106
+ "./ox-input-range.js": [
107
+ "./dist/src/ox-input-range.d.ts"
108
+ ],
109
+ "./ox-input-key-values.js": [
110
+ "./dist/src/ox-input-key-values.d.ts"
111
+ ],
112
+ "./ox-select.js": [
113
+ "./dist/src/ox-select.d.ts"
114
+ ],
115
+ "./ox-input-file.js": [
116
+ "./dist/src/ox-input-file.d.ts"
117
+ ],
118
+ "./ox-input-image.js": [
119
+ "./dist/src/ox-input-image.d.ts"
120
+ ],
121
+ "./ox-input-options.js": [
122
+ "./dist/src/ox-input-options.d.ts"
123
+ ],
124
+ "./ox-input-select-buttons.js": [
125
+ "./dist/src/ox-input-select-buttons.d.ts"
126
+ ],
127
+ "./ox-input-search.js": [
128
+ "./dist/src/ox-input-search.d.ts"
129
+ ],
130
+ "./ox-input-value-map.js": [
131
+ "./dist/src/ox-input-value-map.d.ts"
132
+ ],
133
+ "./ox-input-value-ranges.js": [
134
+ "./dist/src/ox-input-value-ranges.d.ts"
135
+ ],
136
+ "./ox-input-partition-keys.js": [
137
+ "./dist/src/ox-input-partition-keys.d.ts"
138
+ ],
139
+ "./ox-input-table.js": [
140
+ "./dist/src/ox-input-table.d.ts"
141
+ ],
142
+ "./ox-input-scene-component-id.js": [
143
+ "./dist/src/ox-input-scene-component-id.d.ts"
144
+ ],
145
+ "./ox-input-work-shift.js": [
146
+ "./dist/src/ox-input-work-shift.d.ts"
147
+ ],
148
+ "./ox-input-hashtags.js": [
149
+ "./dist/src/ox-input-hashtags.d.ts"
150
+ ],
151
+ "./ox-input-mass-fraction.js": [
152
+ "./dist/src/ox-input-mass-fraction.d.ts"
153
+ ]
154
+ }
155
+ },
53
156
  "scripts": {
54
157
  "clean": "npx rimraf dist",
55
158
  "analyze": "cem analyze --litelement",
@@ -68,9 +171,9 @@
68
171
  "@material/mwc-icon": "^0.27.0",
69
172
  "@operato/color-picker": "^1.2.0",
70
173
  "@operato/i18n": "^1.2.0",
71
- "@operato/popup": "^1.2.10",
174
+ "@operato/popup": "^1.2.11",
72
175
  "@operato/styles": "^1.2.0",
73
- "@operato/utils": "^1.2.4",
176
+ "@operato/utils": "^1.2.11",
74
177
  "@polymer/paper-dropdown-menu": "^3.2.0",
75
178
  "@polymer/paper-item": "^3.0.1",
76
179
  "@thebespokepixel/es-tinycolor": "^3.1.0",
@@ -116,5 +219,5 @@
116
219
  "prettier --write"
117
220
  ]
118
221
  },
119
- "gitHead": "747fe62f88beeab1fe5ac58f06dfbf06c1ccd988"
222
+ "gitHead": "73998868ecf0925a0691da776f8fd6df40e7a554"
120
223
  }
@@ -6,6 +6,8 @@ import './ox-input-color'
6
6
 
7
7
  import { css, html } from 'lit'
8
8
  import { customElement, property } from 'lit/decorators.js'
9
+ import { keyed } from 'lit/directives/keyed.js'
10
+ import { ifDefined } from 'lit/directives/if-defined.js'
9
11
 
10
12
  import { OxFormField } from './ox-form-field'
11
13
 
@@ -72,10 +74,11 @@ export class OxInputValueMap extends OxFormField {
72
74
  color: var(--theme-white-color);
73
75
  }
74
76
 
75
- input,
76
- ox-input-color {
77
+ [data-key],
78
+ [data-value] {
77
79
  flex: 1;
78
80
  }
81
+
79
82
  input {
80
83
  border: 0;
81
84
  border-bottom: var(--border-dark-color);
@@ -83,10 +86,12 @@ export class OxInputValueMap extends OxFormField {
83
86
  font: var(--input-font);
84
87
  color: var(--primary-text-color);
85
88
  }
89
+
86
90
  input:focus {
87
91
  outline: none;
88
92
  border-bottom: 1px solid var(--primary-color);
89
93
  }
94
+
90
95
  button.hidden {
91
96
  opacity: 0;
92
97
  cursor: default;
@@ -103,6 +108,7 @@ export class OxInputValueMap extends OxFormField {
103
108
  }
104
109
 
105
110
  input[type='checkbox'] {
111
+ flex: none;
106
112
  width: initial;
107
113
  }
108
114
  `
@@ -117,72 +123,61 @@ export class OxInputValueMap extends OxFormField {
117
123
  this.renderRoot.addEventListener('change', this._onChange.bind(this))
118
124
  }
119
125
 
126
+ updated() {
127
+ const inputs = this.renderRoot.querySelectorAll('[data-record-new] > :not([style*="display: none"])') as NodeListOf<
128
+ HTMLInputElement & { value: any }
129
+ >
130
+
131
+ inputs[0].focus()
132
+ }
133
+
134
+ valueInputTemplate(value?: any) {
135
+ return this.valuetype == 'boolean'
136
+ ? html` <input type="checkbox" data-value .checked=${!!value} data-value-type=${this.valuetype} /> `
137
+ : this.valuetype == 'color'
138
+ ? html` <ox-input-color data-value value=${ifDefined(value)}> </ox-input-color> `
139
+ : html`
140
+ <input
141
+ type="text"
142
+ data-value
143
+ placeholder="value"
144
+ value=${ifDefined(value)}
145
+ data-value-type=${this.valuetype}
146
+ />
147
+ `
148
+ }
149
+
120
150
  render() {
121
151
  return html`
122
152
  ${this._toArray(this.value).map(
123
153
  item => html`
124
154
  <div data-record>
125
155
  <input type="text" data-key placeholder="key" .value=${item.key} />
126
- ${this.valuetype == 'boolean'
127
- ? html` <input type="checkbox" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `
128
- : this.valuetype == 'color'
129
- ? html` <ox-input-color data-value .value=${item.value} tabindex="-1"> </ox-input-color> `
130
- : html`
131
- <input
132
- type="text"
133
- data-value
134
- placeholder="value"
135
- .value=${item.value}
136
- data-value-type=${this.valuetype}
137
- />
138
- `}
156
+ ${this.valueInputTemplate(item.value)}
139
157
  <button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">
140
158
  <mwc-icon>remove</mwc-icon>
141
159
  </button>
142
160
  </div>
143
161
  `
144
162
  )}
145
-
146
- <div data-record-new>
147
- <input type="text" data-key placeholder="key" value="" /> ${this.valuetype == 'boolean'
148
- ? html` <input type="checkbox" data-value data-value-type=${this.valuetype} /> `
149
- : this.valuetype == 'color'
150
- ? html` <ox-input-color data-value value="" tabindex="-1" placeholder="value"> </ox-input-color> `
151
- : html` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
152
- <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
153
- <mwc-icon>add</mwc-icon>
154
- </button>
155
- </div>
163
+ ${keyed(
164
+ Date.now(),
165
+ html`
166
+ <div data-record-new>
167
+ <input type="text" data-key placeholder="key" value="" />
168
+
169
+ ${this.valueInputTemplate()}
170
+ <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
171
+ <mwc-icon>add</mwc-icon>
172
+ </button>
173
+ </div>
174
+ `
175
+ )}
156
176
 
157
177
  <div data-record>
158
- <input type="text" data-key data-default="" value="default" disabled /> ${this.valuetype == 'boolean'
159
- ? html`
160
- <input
161
- type="checkbox"
162
- data-value
163
- .checked=${this.value && this.value.default}
164
- data-value-type=${this.valuetype}
165
- />
166
- `
167
- : this.valuetype == 'color'
168
- ? html`
169
- <ox-input-color
170
- data-value
171
- .value=${(this.value && this.value.default) || ''}
172
- placeholder="value"
173
- tabindex="-1"
174
- >
175
- </ox-input-color>
176
- `
177
- : html`
178
- <input
179
- type="text"
180
- data-value
181
- placeholder="value"
182
- .value=${(this.value && this.value.default) || ''}
183
- data-value-type=${this.valuetype}
184
- />
185
- `}
178
+ <input type="text" data-key data-default="" value="default" disabled />
179
+
180
+ ${this.valueInputTemplate(this.value && this.value.default)}
186
181
  <button class="record-action" @click=${() => this._sort()} tabindex="-1">
187
182
  <mwc-icon>chevron_right</mwc-icon>
188
183
  </button>
@@ -220,7 +215,7 @@ export class OxInputValueMap extends OxFormField {
220
215
 
221
216
  const div = input.parentElement as HTMLDivElement
222
217
 
223
- if (div.hasAttribute('data-record')) {
218
+ if (div.hasAttribute('data-record') && input.hasAttribute('data-value')) {
224
219
  var dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLElement & { value: any }>
225
220
 
226
221
  for (var i = 0; i < dataList.length; i++) {
@@ -276,6 +271,7 @@ export class OxInputValueMap extends OxFormField {
276
271
  }
277
272
 
278
273
  this.value = newmap
274
+
279
275
  this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
280
276
  }
281
277
 
@@ -319,19 +315,6 @@ export class OxInputValueMap extends OxFormField {
319
315
 
320
316
  _add() {
321
317
  this._build(true)
322
-
323
- const inputs = this.renderRoot.querySelectorAll(
324
- '[data-record-new] input:not([style*="display: none"])'
325
- ) as NodeListOf<HTMLInputElement & { value: any }>
326
-
327
- for (var i = 0; i < inputs.length; i++) {
328
- let input = inputs[i]
329
-
330
- if (input.type == 'checkbox') input.checked = false
331
- else input.value = this._defaultValue(input.type)
332
- }
333
-
334
- inputs[0].focus()
335
318
  }
336
319
 
337
320
  _delete(e: MouseEvent) {
@@ -6,6 +6,8 @@ import './ox-input-color'
6
6
 
7
7
  import { css, html } from 'lit'
8
8
  import { customElement, property } from 'lit/decorators.js'
9
+ import { keyed } from 'lit/directives/keyed.js'
10
+ import { ifDefined } from 'lit/directives/if-defined.js'
9
11
 
10
12
  import { OxFormField } from './ox-form-field.js'
11
13
 
@@ -72,10 +74,15 @@ export class OxInputValueRange extends OxFormField {
72
74
  color: var(--theme-white-color);
73
75
  }
74
76
 
75
- input,
76
- ox-input-color {
77
+ [data-from],
78
+ [data-to] {
77
79
  flex: 1;
78
80
  }
81
+
82
+ [data-value] {
83
+ flex: 2;
84
+ }
85
+
79
86
  input {
80
87
  border: 0;
81
88
  border-bottom: var(--border-dark-color);
@@ -83,10 +90,12 @@ export class OxInputValueRange extends OxFormField {
83
90
  font: var(--input-font);
84
91
  color: var(--primary-text-color);
85
92
  }
93
+
86
94
  input:focus {
87
95
  outline: none;
88
96
  border-bottom: 1px solid var(--primary-color);
89
97
  }
98
+
90
99
  button.hidden {
91
100
  opacity: 0;
92
101
  cursor: default;
@@ -108,6 +117,7 @@ export class OxInputValueRange extends OxFormField {
108
117
  }
109
118
 
110
119
  input[type='checkbox'] {
120
+ flex: none;
111
121
  width: initial;
112
122
  }
113
123
  `
@@ -122,6 +132,30 @@ export class OxInputValueRange extends OxFormField {
122
132
  this.renderRoot.addEventListener('change', this._onChange.bind(this))
123
133
  }
124
134
 
135
+ updated() {
136
+ const inputs = this.renderRoot.querySelectorAll('[data-record-new] > :not([style*="display: none"])') as NodeListOf<
137
+ HTMLInputElement & { value: any }
138
+ >
139
+
140
+ inputs[0].focus()
141
+ }
142
+
143
+ valueInputTemplate(value?: any) {
144
+ return this.valuetype == 'boolean'
145
+ ? html` <input type="checkbox" data-value .checked=${!!value} data-value-type=${this.valuetype} /> `
146
+ : this.valuetype == 'color'
147
+ ? html` <ox-input-color data-value value=${ifDefined(value)}> </ox-input-color> `
148
+ : html`
149
+ <input
150
+ type="text"
151
+ data-value
152
+ placeholder="value"
153
+ value=${ifDefined(value)}
154
+ data-value-type=${this.valuetype}
155
+ />
156
+ `
157
+ }
158
+
125
159
  render() {
126
160
  return html`
127
161
  ${this._toArray(this.value).map(
@@ -130,68 +164,33 @@ export class OxInputValueRange extends OxFormField {
130
164
  <input type="text" data-from placeholder="<=" .value=${item.from} />
131
165
  <input type="text" data-to placeholder="&gt;" .value=${item.to} />
132
166
 
133
- ${this.valuetype == 'boolean'
134
- ? html` <input type="checkbox" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `
135
- : this.valuetype == 'color'
136
- ? html` <ox-input-color data-value .value=${item.value}> </ox-input-color> `
137
- : html`
138
- <input
139
- type="text"
140
- data-value
141
- placeholder="value"
142
- .value=${item.value}
143
- data-value-type=${this.valuetype}
144
- />
145
- `}
167
+ ${this.valueInputTemplate(item.value)}
146
168
  <button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1">
147
169
  <mwc-icon>remove</mwc-icon>
148
170
  </button>
149
171
  </div>
150
172
  `
151
173
  )}
152
-
153
- <div data-record-new>
154
- <input type="text" data-from placeholder="<=" value="" />
155
- <input type="text" data-to placeholder="&gt;" value="" />
156
-
157
- ${this.valuetype == 'boolean'
158
- ? html` <input type="checkbox" data-value data-value-type=${this.valuetype} /> `
159
- : this.valuetype == 'color'
160
- ? html` <ox-input-color data-value value="" placeholder="value"> </ox-input-color> `
161
- : html` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
162
- <button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">
163
- <mwc-icon>add</mwc-icon>
164
- </button>
165
- </div>
174
+ ${keyed(
175
+ Date.now(),
176
+ html`
177
+ <div data-record-new>
178
+ <input type="text" data-from placeholder="<=" value="" />
179
+ <input type="text" data-to placeholder="&gt;" value="" />
180
+
181
+ ${this.valueInputTemplate()}
182
+ <button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">
183
+ <mwc-icon>add</mwc-icon>
184
+ </button>
185
+ </div>
186
+ `
187
+ )}
166
188
 
167
189
  <div data-record>
168
190
  <input type="text" data-from data-default="" disabled value="default" />
169
191
  <input type="text" data-to placeholder="&gt;" value="" hidden />
170
192
 
171
- ${this.valuetype == 'boolean'
172
- ? html`
173
- <input
174
- type="checkbox"
175
- data-value
176
- .checked=${this.value && this.value.default}
177
- data-value-type=${this.valuetype}
178
- />
179
- `
180
- : this.valuetype == 'color'
181
- ? html`
182
- <ox-input-color data-value .value=${(this.value && this.value.default) || ''} placeholder="value">
183
- </ox-input-color>
184
- `
185
- : html`
186
- <input
187
- type="text"
188
- data-value
189
- .value=${(this.value && this.value.default) || ''}
190
- placeholder="value"
191
- class="default-value"
192
- data-value-type=${this.valuetype}
193
- />
194
- `}
193
+ ${this.valueInputTemplate(this.value && this.value.default)}
195
194
  <button class="record-action" @click=${(e: Event) => this._sort()}><mwc-icon>chevron_right</mwc-icon></button>
196
195
  </div>
197
196
  `
@@ -220,7 +219,7 @@ export class OxInputValueRange extends OxFormField {
220
219
  var value = input.type === 'checkbox' ? Boolean(input.checked) : input.value
221
220
 
222
221
  const div = input.parentElement as HTMLDivElement
223
- if (input.hasAttribute('data-value')) {
222
+ if (input.hasAttribute('data-value') && input.hasAttribute('data-value')) {
224
223
  const dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLElement & { value: any }>
225
224
 
226
225
  for (var i = 0; i < dataList.length; i++) {
@@ -260,6 +259,7 @@ export class OxInputValueRange extends OxFormField {
260
259
  }
261
260
 
262
261
  var input = inputs[inputs.length - 1]
262
+
263
263
  var value
264
264
 
265
265
  if (input.type == 'checkbox') {
@@ -324,21 +324,6 @@ export class OxInputValueRange extends OxFormField {
324
324
 
325
325
  _add() {
326
326
  this._build(true)
327
-
328
- const inputs = this.renderRoot.querySelectorAll(
329
- '[data-record-new] input:not([style*="display: none"])'
330
- ) as NodeListOf<HTMLInputElement & { value: any; type: string }>
331
-
332
- for (var i = 0; i < inputs.length; i++) {
333
- let input = inputs[i]
334
- if (input.type == 'checkbox') {
335
- input.checked = false
336
- } else {
337
- input.value = this._defaultValue(input.type)
338
- }
339
- }
340
-
341
- inputs[0].focus()
342
327
  }
343
328
 
344
329
  _delete(e: Event) {