neo.mjs 4.7.4 → 4.7.6

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.
@@ -150,6 +150,12 @@ class MainContainer extends ConfigurationViewport {
150
150
  labelText: 'spellCheck',
151
151
  listeners: {change: me.onConfigChange.bind(me, 'spellCheck')},
152
152
  style : {marginTop: '10px'}
153
+ }, {
154
+ module : TextField,
155
+ labelText: 'subLabelText',
156
+ listeners: {change: me.onConfigChange.bind(me, 'subLabelText')},
157
+ style : {marginTop: '10px'},
158
+ value : me.exampleComponent.subLabelText
153
159
  }, {
154
160
  module : NumberField,
155
161
  labelText: 'width',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.7.4",
3
+ "version": "4.7.6",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -356,4 +356,13 @@
356
356
  flex : 0 0 auto;
357
357
  user-select: none;
358
358
  }
359
+
360
+ .neo-textfield-sublabel {
361
+ color : v(textfield-sublabel-color);
362
+ display : inline-block;
363
+ flex : 0 0 auto;
364
+ font-size : v(textfield-sublabel-font-size);
365
+ margin : v(textfield-sublabel-margin);
366
+ user-select: none;
367
+ }
359
368
  }
@@ -25,7 +25,10 @@ $neoMap: map-merge($neoMap, (
25
25
  'textfield-opacity-disabled' : #{neo(neo-disabled-opacity)},
26
26
  'textfield-opacity-readonly' : 1,
27
27
  'textfield-outline-active' : none,
28
- 'textfield-outline-hovered' : none
28
+ 'textfield-outline-hovered' : none,
29
+ 'textfield-sublabel-color' : #999,
30
+ 'textfield-sublabel-font-size' : 12px,
31
+ 'textfield-sublabel-margin' : 0 0 5px
29
32
  ));
30
33
 
31
34
  @if $useCssVars == true {
@@ -57,5 +60,8 @@ $neoMap: map-merge($neoMap, (
57
60
  --textfield-opacity-readonly : #{neo(textfield-opacity-readonly)};
58
61
  --textfield-outline-active : #{neo(textfield-outline-active)};
59
62
  --textfield-outline-hovered : #{neo(textfield-outline-hovered)};
63
+ --textfield-sublabel-color : #{neo(textfield-sublabel-color)};
64
+ --textfield-sublabel-font-size : #{neo(textfield-sublabel-font-size)};
65
+ --textfield-sublabel-margin : #{neo(textfield-sublabel-margin)};
60
66
  }
61
67
  }
@@ -25,7 +25,10 @@ $neoMap: map-merge($neoMap, (
25
25
  'textfield-opacity-disabled' : #{neo(neo-disabled-opacity)},
26
26
  'textfield-opacity-readonly' : 1,
27
27
  'textfield-outline-active' : none,
28
- 'textfield-outline-hovered' : none
28
+ 'textfield-outline-hovered' : none,
29
+ 'textfield-sublabel-color' : #666,
30
+ 'textfield-sublabel-font-size' : 12px,
31
+ 'textfield-sublabel-margin' : 0 0 5px
29
32
  ));
30
33
 
31
34
  @if $useCssVars == true {
@@ -57,5 +60,8 @@ $neoMap: map-merge($neoMap, (
57
60
  --textfield-opacity-readonly : #{neo(textfield-opacity-readonly)};
58
61
  --textfield-outline-active : #{neo(textfield-outline-active)};
59
62
  --textfield-outline-hovered : #{neo(textfield-outline-hovered)};
63
+ --textfield-sublabel-color : #{neo(textfield-sublabel-color)};
64
+ --textfield-sublabel-font-size : #{neo(textfield-sublabel-font-size)};
65
+ --textfield-sublabel-margin : #{neo(textfield-sublabel-margin)};
60
66
  }
61
67
  }
@@ -52,13 +52,13 @@ class Range extends Number {
52
52
  super.construct(config);
53
53
 
54
54
  let me = this,
55
- inputEl = me.vdom.cn[1];
55
+ inputEl = me.vdom.cn[2];
56
56
 
57
57
  if (me.useInputEvent) {
58
58
  me.addDomListeners({
59
59
  input: {
60
60
  fn : me.onInputValueChange,
61
- id : me.vdom.cn[1].id,
61
+ id : me.vdom.cn[2].id,
62
62
  scope : me
63
63
  }
64
64
  });
@@ -142,6 +142,18 @@ class Text extends Base {
142
142
  * @member {Boolean|null} spellCheck_=false
143
143
  */
144
144
  spellCheck_: false,
145
+ /**
146
+ * @member {String[]} subLabelBaseCls=['neo-textfield-sublabel']
147
+ */
148
+ subLabelBaseCls: ['neo-textfield-sublabel'],
149
+ /**
150
+ * @member {String[]} subLabelCls_=[]
151
+ */
152
+ subLabelCls_: [],
153
+ /**
154
+ * @member {String} subLabelText_=null
155
+ */
156
+ subLabelText_: null,
145
157
  /**
146
158
  * @member {Object|Object[]|null} triggers_=null
147
159
  */
@@ -152,6 +164,7 @@ class Text extends Base {
152
164
  _vdom:
153
165
  {cn: [
154
166
  {tag: 'label', cls: [], style: {}},
167
+ {tag: 'label', cls: []},
155
168
  {tag: 'input', cls: ['neo-textfield-input'], flag: 'neo-real-input', style: {}},
156
169
  {cls: ['neo-textfield-error'], removeDom: true}
157
170
  ]}
@@ -327,17 +340,18 @@ class Text extends Base {
327
340
  * @protected
328
341
  */
329
342
  afterSetLabelPosition(value, oldValue) {
330
- let me = this,
331
- cls = me.cls,
332
- centerBorderElCls, isEmpty, vdom;
343
+ let me = this,
344
+ cls = me.cls,
345
+ vdom = me.vdom,
346
+ centerBorderElCls, isEmpty;
347
+
348
+ vdom.cn[1].removeDom = value !== 'top' ? true : !Boolean(me.subLabelText);
333
349
 
334
350
  NeoArray.remove(cls, 'label-' + oldValue);
335
351
  NeoArray.add(cls, 'label-' + value);
336
352
  me.cls = cls; // todo: silent update if needed
337
353
 
338
354
  if (oldValue === 'inline') {
339
- vdom = me.vdom;
340
-
341
355
  vdom.cn[0] = me.getLabelEl(); // remove the wrapper
342
356
 
343
357
  vdom.cn[0].removeDom = me.hideLabel;
@@ -521,6 +535,39 @@ class Text extends Base {
521
535
  this.changeInputElKey('spellcheck', Neo.isBoolean(value) ? value : null);
522
536
  }
523
537
 
538
+ /**
539
+ * Triggered after the subLabelCls config got changed
540
+ * @param {String[]} value
541
+ * @param {String[]} oldValue
542
+ * @protected
543
+ */
544
+ afterSetSubLabelCls(value, oldValue) {
545
+ let me = this,
546
+ cls = me.vdom.cn[1].cls;
547
+
548
+ NeoArray.remove(cls, oldValue);
549
+ NeoArray.add(cls, value);
550
+
551
+ me.update();
552
+ }
553
+
554
+ /**
555
+ * Triggered after the subLabelText config got changed
556
+ * @param {String|null} value
557
+ * @param {String|null} oldValue
558
+ * @protected
559
+ */
560
+ afterSetSubLabelText(value, oldValue) {
561
+ let me = this,
562
+ showLabel = me.labelPosition === 'top',
563
+ subLabel = me.vdom.cn[1];
564
+
565
+ subLabel.html = value;
566
+ subLabel.removeDom = !showLabel;
567
+
568
+ me.update();
569
+ }
570
+
524
571
  /**
525
572
  * Triggered after the triggers config got changed
526
573
  * @param {Object[]} value
@@ -530,7 +577,7 @@ class Text extends Base {
530
577
  afterSetTriggers(value, oldValue) {
531
578
  let me = this,
532
579
  vdom = me.vdom,
533
- inputEl = vdom.cn[1], // inputEl or inputWrapperEl
580
+ inputEl = vdom.cn[2], // inputEl or inputWrapperEl
534
581
  preTriggers = [],
535
582
  postTriggers = [],
536
583
  width;
@@ -558,7 +605,7 @@ class Text extends Base {
558
605
 
559
606
  if (inputEl.tag === 'input') {
560
607
  // wrap the input tag
561
- vdom.cn[1] = {
608
+ vdom.cn[2] = {
562
609
  cls : ['neo-input-wrapper'],
563
610
  cn : [...preTriggers, inputEl, ...postTriggers],
564
611
  id : me.getInputWrapperId(),
@@ -573,8 +620,8 @@ class Text extends Base {
573
620
  if (inputEl.tag !== 'input') {
574
621
  // replacing the input wrapper div with the input tag
575
622
  width = inputEl.width;
576
- vdom.cn[1] = me.getInputEl();
577
- vdom.cn[1].width = width;
623
+ vdom.cn[2] = me.getInputEl();
624
+ vdom.cn[2].width = width;
578
625
  }
579
626
  }
580
627
 
@@ -673,6 +720,17 @@ class Text extends Base {
673
720
  return this.beforeSetEnumValue(value, oldValue, 'labelPosition');
674
721
  }
675
722
 
723
+ /**
724
+ * Triggered before the subLabelCls config gets changed
725
+ * @param {String[]} value
726
+ * @param {String[]} oldValue
727
+ * @returns {String[]}
728
+ * @protected
729
+ */
730
+ beforeSetSubLabelCls(value, oldValue) {
731
+ return NeoArray.union(value || [], this.subLabelBaseCls);
732
+ }
733
+
676
734
  /**
677
735
  * Triggered before the triggers config gets changed
678
736
  * @param {Object|Object[]} value
@@ -9,6 +9,10 @@ import Observable from '../../core/Observable.mjs';
9
9
  * @singleton
10
10
  */
11
11
  class GoogleMaps extends Base {
12
+ /**
13
+ * @member {google.maps.Geocoder|null} maps=null
14
+ */
15
+ geoCoder = null
12
16
  /**
13
17
  * @member {Object} maps={}
14
18
  */
@@ -36,6 +40,7 @@ class GoogleMaps extends Base {
36
40
  app: [
37
41
  'addMarker',
38
42
  'create',
43
+ 'geocode',
39
44
  'hideMarker',
40
45
  'panTo',
41
46
  'removeMap',
@@ -125,6 +130,24 @@ class GoogleMaps extends Base {
125
130
  me.fire('mapCreated', id);
126
131
  }
127
132
 
133
+ /**
134
+ * Use either address, location or placeId
135
+ * @param {Object} data
136
+ * @param {String} data.address
137
+ * @param {Object} data.location
138
+ * @param {String} data.placeId
139
+ * @returns {Object}
140
+ */
141
+ async geocode(data) {
142
+ let me = this;
143
+
144
+ if (!me.geoCoder) {
145
+ me.geoCoder = new google.maps.Geocoder();
146
+ }
147
+
148
+ return await me.geoCoder.geocode(data);
149
+ }
150
+
128
151
  /**
129
152
  * @param {Object} data
130
153
  * @param {String} data.id