neo.mjs 4.4.12 → 4.4.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.
@@ -21,6 +21,10 @@ class MainContainer extends Viewport {
21
21
  flex : 1,
22
22
  reference: 'google-maps-component',
23
23
 
24
+ listeners: {
25
+ zoomChange: 'onMapZoomChance'
26
+ },
27
+
24
28
  markerStoreConfig: {
25
29
  data: [{
26
30
  id : '1',
@@ -50,6 +54,7 @@ class MainContainer extends Viewport {
50
54
  listeners : {change: 'onZoomFieldChange'},
51
55
  minValue : 0,
52
56
  maxValue : 10,
57
+ reference : 'zoom-field',
53
58
  style : {marginLeft: '10px'},
54
59
  value : 8,
55
60
  width : 100
@@ -20,6 +20,13 @@ class MainContainerController extends ComponentController {
20
20
  this.getReference('google-maps-component').panTo({lat: 37.655, lng: -122.4175})
21
21
  }
22
22
 
23
+ /**
24
+ * @param {Object} data
25
+ */
26
+ onMapZoomChance(data) {
27
+ this.getReference('zoom-field').value = data.value;
28
+ }
29
+
23
30
  /**
24
31
  * @param {Object} data
25
32
  */
@@ -70,7 +70,7 @@ class MainContainer extends Viewport {
70
70
  iconCls: 'fa fa-home',
71
71
 
72
72
  bind: {
73
- text: data => `${data.button1Text}`
73
+ text: data => data.button1Text
74
74
  }
75
75
  }, {
76
76
  handler: 'onButton2Click',
@@ -91,11 +91,7 @@ class MainContainer extends Viewport {
91
91
  width : 300,
92
92
 
93
93
  bind: {
94
- value: data => `${data.button1Text}`
95
- },
96
-
97
- listeners: {
98
- change: 'onTextField1Change'
94
+ value: {twoWay: true, value: data => data.button1Text}
99
95
  }
100
96
  }, {
101
97
  module : TextField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.4.12",
3
+ "version": "4.4.14",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -104,9 +104,9 @@ class Base extends Component {
104
104
  route_: null,
105
105
  /**
106
106
  * The text displayed on the button [optional]
107
- * @member {String} text_=''
107
+ * @member {String|null} text_=null
108
108
  */
109
- text_: '',
109
+ text_: null,
110
110
  /**
111
111
  * Transforms the button tag into an a tag [optional]
112
112
  * @member {String|null} url_=null
@@ -271,8 +271,8 @@ class Base extends Component {
271
271
 
272
272
  /**
273
273
  * Triggered after the text config got changed
274
- * @param {String} value
275
- * @param {String} oldValue
274
+ * @param {String|null} value
275
+ * @param {String|null} oldValue
276
276
  * @protected
277
277
  */
278
278
  afterSetText(value, oldValue) {
@@ -280,7 +280,7 @@ class Base extends Component {
280
280
  vdomRoot = me.getVdomRoot(),
281
281
  textNode = vdomRoot.cn[1];
282
282
 
283
- if (value === '') {
283
+ if (!value || value === '') {
284
284
  NeoArray.add(me._cls, 'no-text');
285
285
  NeoArray.add(vdomRoot.cls, 'no-text');
286
286
  textNode.removeDom = true;
@@ -425,9 +425,11 @@ class Base extends CoreBase {
425
425
  * @protected
426
426
  */
427
427
  afterSetConfig(key, value, oldValue) {
428
- if (Neo.currentWorker.isUsingViewModels) {
429
- if (this.bind?.[key]?.twoWay) {
430
- this.getModel()?.setData(key, value);
428
+ if (Neo.currentWorker.isUsingViewModels && oldValue !== undefined) {
429
+ let binding = this.bind?.[key];
430
+
431
+ if (binding?.twoWay) {
432
+ this.getModel()?.setData(binding.key, value);
431
433
  }
432
434
  }
433
435
  }
@@ -82,9 +82,10 @@ class GoogleMaps extends Base {
82
82
  let me = this;
83
83
 
84
84
  me.addDomListeners({
85
- googleMarkerClick: me.parseMarkerClick,
86
- local : false,
87
- scope : me
85
+ googleMapZoomChange: me.onMapZoomChange,
86
+ googleMarkerClick : me.parseMarkerClick,
87
+ local : false,
88
+ scope : me
88
89
  })
89
90
  }
90
91
 
@@ -181,9 +182,16 @@ class GoogleMaps extends Base {
181
182
  */
182
183
  afterSetZoom(value, oldValue) {
183
184
  if (oldValue !== undefined) {
185
+ let me = this;
186
+
184
187
  Neo.main.addon.GoogleMaps.setZoom({
185
- appName: this.appName,
186
- id : this.id,
188
+ appName: me.appName,
189
+ id : me.id,
190
+ value
191
+ });
192
+
193
+ me.fire('zoomChange', {
194
+ id: me.id,
187
195
  value
188
196
  })
189
197
  }
@@ -226,6 +234,13 @@ class GoogleMaps extends Base {
226
234
  */
227
235
  onComponentMounted() {}
228
236
 
237
+ /**
238
+ * @param {Object} data
239
+ */
240
+ onMapZoomChange(data) {
241
+ this.zoom = data.value;
242
+ }
243
+
229
244
  /**
230
245
  * @param {Object} record
231
246
  */
@@ -68,23 +68,24 @@ class GoogleMaps extends Base {
68
68
  * @param {String} [data.title]
69
69
  */
70
70
  addMarker(data) {
71
- let me = this,
71
+ let me = this,
72
+ mapId = data.mapId,
72
73
  listenerId, marker;
73
74
 
74
- if (!me.maps[data.mapId]) {
75
- listenerId = me.on('mapCreated', mapId => {
76
- if (data.mapId === mapId) {
75
+ if (!me.maps[mapId]) {
76
+ listenerId = me.on('mapCreated', id => {
77
+ if (mapId === id) {
77
78
  me.un(listenerId);
78
79
  me.addMarker(data);
79
80
  }
80
81
  })
81
82
  } else {
82
- Neo.ns(`${data.mapId}`, true, me.markers);
83
+ Neo.ns(`${mapId}`, true, me.markers);
83
84
 
84
- me.markers[data.mapId][data.id] = marker = new google.maps.Marker({
85
- map : me.maps[data.mapId],
86
- neoId : data.id, // custom property
87
- neoMapId: data.mapId, // custom property
85
+ me.markers[mapId][data.id] = marker = new google.maps.Marker({
86
+ map : me.maps[mapId],
87
+ neoId : data.id, // custom property
88
+ neoMapId: mapId, // custom property
88
89
  position: data.position,
89
90
  title : data.title,
90
91
  });
@@ -105,9 +106,11 @@ class GoogleMaps extends Base {
105
106
  * @param {Boolean} data.zoomControl
106
107
  */
107
108
  create(data) {
108
- let me = this;
109
+ let me = this,
110
+ id = data.id,
111
+ map;
109
112
 
110
- me.maps[data.id] = new google.maps.Map(DomAccess.getElement(data.id), {
113
+ me.maps[id] = map = new google.maps.Map(DomAccess.getElement(id), {
111
114
  center : data.center,
112
115
  fullscreenControl: data.fullscreenControl,
113
116
  maxZoom : data.maxZoom,
@@ -117,7 +120,9 @@ class GoogleMaps extends Base {
117
120
  ...data.mapOptions
118
121
  });
119
122
 
120
- me.fire('mapCreated', data.id);
123
+ map.addListener('zoom_changed', me.onMapZoomChange.bind(me, map, id));
124
+
125
+ me.fire('mapCreated', id);
121
126
  }
122
127
 
123
128
  /**
@@ -140,6 +145,19 @@ class GoogleMaps extends Base {
140
145
  })
141
146
  }
142
147
 
148
+ /**
149
+ * @param {google.maps.Map} map
150
+ * @param {String} mapId
151
+ */
152
+ onMapZoomChange(map, mapId){
153
+ DomEvents.sendMessageToApp({
154
+ id : mapId,
155
+ path : [{cls: [], id: mapId}],
156
+ type : 'googleMapZoomChange',
157
+ value: map.zoom
158
+ })
159
+ }
160
+
143
161
  /**
144
162
  * @param {google.maps.Marker} marker
145
163
  * @param {Object} event
@@ -564,6 +564,7 @@ class Component extends Base {
564
564
 
565
565
  Object.entries(component.bind).forEach(([key, value]) => {
566
566
  if (Neo.isObject(value)) {
567
+ value.key = me.getFormatterVariables(value.value)[0];
567
568
  value = value.value;
568
569
  }
569
570