@panoramax/web-viewer 4.0.3-develop-0b852670 → 4.0.3-develop-d8c835a2

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.
@@ -10,6 +10,7 @@
10
10
  * [new SemanticsEditor()](#new_Panoramax.components.ui.SemanticsEditor_new)
11
11
  * [.properties](#Panoramax.components.ui.SemanticsEditor+properties) : <code>Object</code>
12
12
  * [.getDiff()](#Panoramax.components.ui.SemanticsEditor+getDiff) ⇒ <code>Array.&lt;object&gt;</code>
13
+ * [.checkValidity()](#Panoramax.components.ui.SemanticsEditor+checkValidity) ⇒ <code>boolean</code>
13
14
  * ["change"](#Panoramax.components.ui.SemanticsEditor+event_change)
14
15
 
15
16
  <a name="new_Panoramax.components.ui.SemanticsEditor_new"></a>
@@ -62,6 +63,13 @@ Get current delta between initial tags and user changes.
62
63
 
63
64
  **Kind**: instance method of [<code>SemanticsEditor</code>](#Panoramax.components.ui.SemanticsEditor)
64
65
  **Returns**: <code>Array.&lt;object&gt;</code> - The list of tag changes (in API format)
66
+ <a name="Panoramax.components.ui.SemanticsEditor+checkValidity"></a>
67
+
68
+ ### semanticsEditor.checkValidity() ⇒ <code>boolean</code>
69
+ Check if input is having a valid value.
70
+
71
+ **Kind**: instance method of [<code>SemanticsEditor</code>](#Panoramax.components.ui.SemanticsEditor)
72
+ **Returns**: <code>boolean</code> - True if it's valid
65
73
  <a name="Panoramax.components.ui.SemanticsEditor+event_change"></a>
66
74
 
67
75
  ### "change"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "4.0.3-develop-0b852670",
3
+ "version": "4.0.3-develop-d8c835a2",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "build/index.js",
6
6
  "author": "Panoramax team",
@@ -341,7 +341,9 @@ export default class Basic extends LitElement {
341
341
  static GetJSONConverter() {
342
342
  return {
343
343
  fromAttribute: (value) => {
344
- return typeof value === "object" || Array.isArray(value) ? value : JSON5.parse(value);
344
+ if(value === null || value === "") { return null; }
345
+ else if(typeof value === "object" || Array.isArray(value)) { return value; }
346
+ else { return JSON5.parse(value); }
345
347
  },
346
348
  toAttribute: (value) => JSON.stringify(value)
347
349
  };
@@ -83,6 +83,15 @@ export default class SemanticsEditor extends LitElement {
83
83
  return computeDiffTags(this._firstSemantics || [], this.semantics);
84
84
  }
85
85
 
86
+ /**
87
+ * Check if input is having a valid value.
88
+ * @memberof Panoramax.components.ui.SemanticsEditor#
89
+ * @returns {boolean} True if it's valid
90
+ */
91
+ checkValidity() {
92
+ return this._valid;
93
+ }
94
+
86
95
  /** @private */
87
96
  _onInput(e) {
88
97
  const tarea = e.target;
@@ -97,6 +106,8 @@ export default class SemanticsEditor extends LitElement {
97
106
 
98
107
  /** @private */
99
108
  _onBlur(e) {
109
+ const prevValidity = e.target.checkValidity();
110
+
100
111
  if(this._valid) {
101
112
  e.target.setCustomValidity("");
102
113
 
@@ -117,11 +128,10 @@ export default class SemanticsEditor extends LitElement {
117
128
  }
118
129
  }));
119
130
  }
120
- else {
131
+ else if(prevValidity) { // Do not call again if already shows up, to fix Chrome issue
121
132
  e.target.setCustomValidity(this._t?.pnx.semantics_editor_error || "Invalid syntax");
133
+ e.target.reportValidity();
122
134
  }
123
-
124
- e.target.reportValidity();
125
135
  }
126
136
 
127
137
  /** @private */