@operato/input 1.13.12 → 1.13.14

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.
@@ -90,7 +90,7 @@ export class OxInputData extends OxFormField {
90
90
  <mwc-icon @click=${() => this._clearData()} title="delete">delete_forever</mwc-icon>
91
91
  </div>
92
92
 
93
- <ox-input-code .value=${this._getData(this.value)} language="javascript" editor ?disabled=${this.disabled}>
93
+ <ox-input-code .value=${this._getStringData(this.value)} language="javascript" editor ?disabled=${this.disabled}>
94
94
  </ox-input-code>
95
95
  `
96
96
  }
@@ -98,13 +98,14 @@ export class OxInputData extends OxFormField {
98
98
  firstUpdated() {
99
99
  this.renderRoot.addEventListener('change', e => {
100
100
  e.stopPropagation()
101
+
101
102
  const target = e.target as OxInputCode
102
103
  if (target.hasAttribute('editor')) {
104
+ if (this.value === undefined && target.value == '') {
105
+ return
106
+ }
103
107
  this.value = target.value
104
108
  }
105
-
106
- const type = this.renderRoot.querySelector('input[name=data-type]:checked')?.getAttribute('data-value')
107
- this._setDataType(type)
108
109
  })
109
110
  }
110
111
 
@@ -115,7 +116,7 @@ export class OxInputData extends OxFormField {
115
116
  try {
116
117
  switch (type) {
117
118
  case 'string':
118
- this.value = this._getData(value)
119
+ this.value = this._getStringData(value)
119
120
  break
120
121
  case 'number':
121
122
  if (!isNaN(value)) {
@@ -140,8 +141,17 @@ export class OxInputData extends OxFormField {
140
141
  this._onAfterValueChange()
141
142
  }
142
143
 
143
- _getData(data: any) {
144
- return typeof data !== 'object' ? data || '' : JSON.stringify(data, null, 1)
144
+ _getStringData(data: any) {
145
+ const type = typeof data
146
+
147
+ switch (type) {
148
+ case 'object':
149
+ return JSON.stringify(data, null, 1)
150
+ case 'undefined':
151
+ return ''
152
+ default:
153
+ return String(data) || ''
154
+ }
145
155
  }
146
156
 
147
157
  async _onAfterValueChange() {