neo.mjs 5.1.1 → 5.1.3

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.
@@ -414,7 +414,7 @@ class Select extends Picker {
414
414
  * @protected
415
415
  */
416
416
  onKeyDownEnter(data) {
417
- let me = this;
417
+ let me = this;
418
418
 
419
419
  if (me.pickerIsMounted) {
420
420
  me.selectListItem();
@@ -640,7 +640,7 @@ class Select extends Picker {
640
640
  }
641
641
 
642
642
  if (!hasMatch && inputHintEl) {
643
- inputHintEl.value = '';
643
+ inputHintEl.value = null;
644
644
  me.hintRecordId = null;
645
645
  }
646
646
 
@@ -530,7 +530,17 @@ class Text extends Base {
530
530
  * @protected
531
531
  */
532
532
  afterSetPlaceholderText(value, oldValue) {
533
- this.changeInputElKey('placeholder', value === '' ? null : value);
533
+ let me = this,
534
+ cls = me.cls;
535
+
536
+ me.changeInputElKey('placeholder', value === '' ? null : value);
537
+
538
+ // a non-empty placeholder needs to keep the 'neo-has-content' rule
539
+ // => labelPosition: 'inline' should keep the label at the top
540
+ if (Neo.isEmpty(value) !== Neo.isEmpty(oldValue)) {
541
+ NeoArray[value !== null && value.toString().length > 0 ? 'add' : 'remove'](cls, 'neo-has-content');
542
+ me.cls = cls;
543
+ }
534
544
  }
535
545
 
536
546
  /**
@@ -686,21 +696,19 @@ class Text extends Base {
686
696
  * @protected
687
697
  */
688
698
  afterSetValue(value, oldValue) {
689
- let me = this,
690
- cls = me.cls,
691
- emptyValue = Neo.isEmpty(value),
692
- originalValue = me.originalConfig.value,
693
- isDirty = value !== originalValue && emptyValue !== Neo.isEmpty(originalValue);
699
+ let me = this,
700
+ cls = me.cls,
701
+ placeholderText = me.placeholderText,
702
+ hasContent = placeholderText?.length > 0 || value !== null && value.toString().length > 0,
703
+ originalValue = me.originalConfig.value,
704
+ isDirty = value !== originalValue && Neo.isEmpty(value) !== Neo.isEmpty(originalValue);
694
705
 
695
706
  me.silentVdomUpdate = true;
696
707
 
697
708
  me.getInputEl().value = value;
698
709
 
699
- if (emptyValue !== Neo.isEmpty(oldValue)) {
700
- NeoArray[value !== null && value.toString().length > 0 ? 'add' : 'remove'](cls, 'neo-has-content');
701
- }
702
-
703
- NeoArray[isDirty ? 'add' : 'remove'](cls, 'neo-is-dirty');
710
+ NeoArray[hasContent ? 'add' : 'remove'](cls, 'neo-has-content');
711
+ NeoArray[isDirty ? 'add' : 'remove'](cls, 'neo-is-dirty');
704
712
  me.cls = cls;
705
713
 
706
714
  me.validate(); // silent
@@ -886,17 +894,16 @@ class Text extends Base {
886
894
  * @returns {Object|null}
887
895
  */
888
896
  getCenterBorderEl() {
889
- let el = VDomUtil.findVdomChild(this.vdom, {cls: 'neo-center-border'});
890
- return el?.vdom;
897
+ return VDomUtil.findVdomChild(this.vdom, {cls: 'neo-center-border'})?.vdom || null;
891
898
  }
892
899
 
893
900
  /**
894
901
  * @returns {Object|null}
895
902
  */
896
903
  getInputEl() {
897
- let el = VDomUtil.findVdomChild(this.vdom, {flag: 'neo-real-input'});
898
- return el?.vdom;
904
+ return VDomUtil.findVdomChild(this.vdom, {flag: 'neo-real-input'})?.vdom || null;
899
905
  }
906
+
900
907
  /**
901
908
  * @returns {String}
902
909
  */
@@ -934,8 +941,7 @@ class Text extends Base {
934
941
  * @returns {Object|null}
935
942
  */
936
943
  getLabelEl() {
937
- let el = VDomUtil.findVdomChild(this.vdom, {tag: 'label'});
938
- return el?.vdom;
944
+ return VDomUtil.findVdomChild(this.vdom, {tag: 'label'})?.vdom || null;
939
945
  }
940
946
 
941
947
  /**
@@ -407,11 +407,20 @@ class DomEvents extends Base {
407
407
  * @param {Object} event
408
408
  */
409
409
  onChange(event) {
410
- this.sendMessageToApp({
410
+ let target = event.target,
411
+
412
+ data = {
411
413
  ...this.getEventData(event),
412
- valid: event.target.checkValidity(),
413
- value: event.target.value
414
- });
414
+ valid: target.checkValidity(),
415
+ value: target.value
416
+ };
417
+
418
+ // input and change events can pass a FileList for input type file
419
+ if (target.files) {
420
+ data.files = target.files;
421
+ }
422
+
423
+ this.sendMessageToApp(data);
415
424
  }
416
425
 
417
426
  /**
@@ -13,6 +13,19 @@ class Breadcrumb extends Toolbar {
13
13
  * @protected
14
14
  */
15
15
  className: 'Neo.toolbar.Breadcrumb',
16
+ /**
17
+ * @member {String} ntype='breadcrumb-toolbar'
18
+ * @protected
19
+ */
20
+ ntype: 'breadcrumb-toolbar',
21
+ /**
22
+ * @member {String[]} baseCls=['neo-breadcrumb-toolbar','neo-toolbar']
23
+ */
24
+ baseCls: ['neo-breadcrumb-toolbar', 'neo-toolbar'],
25
+ /**
26
+ * @member {Number|String|null} activeKey_=null
27
+ */
28
+ activeKey_: null,
16
29
  /**
17
30
  * @member {Object[]} items
18
31
  */
@@ -23,6 +36,16 @@ class Breadcrumb extends Toolbar {
23
36
  store_: null
24
37
  }
25
38
 
39
+ /**
40
+ * Triggered after the activeKey config got changed
41
+ * @param {Number|String|null} value
42
+ * @param {Number|String|null} oldValue
43
+ * @protected
44
+ */
45
+ afterSetActiveKey(value, oldValue) {
46
+ this.store.getCount?.() > 0 && this.updateItems()
47
+ }
48
+
26
49
  /**
27
50
  * Triggered after the store config got changed
28
51
  * @param {Neo.data.Store|Object} value
@@ -30,7 +53,14 @@ class Breadcrumb extends Toolbar {
30
53
  * @protected
31
54
  */
32
55
  afterSetStore(value, oldValue) {
56
+ let me = this;
57
+
58
+ value.on({
59
+ load: this.onStoreLoad,
60
+ scope: me
61
+ });
33
62
 
63
+ value?.getCount() > 0 && me.onStoreLoad(value.items)
34
64
  }
35
65
 
36
66
  /**
@@ -44,6 +74,64 @@ class Breadcrumb extends Toolbar {
44
74
  oldValue?.destroy();
45
75
  return ClassSystemUtil.beforeSetInstance(value, Store);
46
76
  }
77
+
78
+ /**
79
+ * @returns {Object[]}
80
+ */
81
+ getPathItems() {
82
+ let items = [],
83
+ parentId = this.activeKey,
84
+ store = this.store,
85
+ item;
86
+
87
+ while (parentId !== null) {
88
+ item = store.get(parentId);
89
+
90
+ items.unshift(item);
91
+
92
+ parentId = item.parentId;
93
+ }
94
+
95
+ return items;
96
+ }
97
+
98
+ /**
99
+ * @param {Object[]} items
100
+ */
101
+ onStoreLoad(items) {
102
+ this.activeKey !== null && this.updateItems()
103
+ }
104
+
105
+ /**
106
+ *
107
+ */
108
+ updateItems() {
109
+ let me = this,
110
+ items = me.items,
111
+ pathItems = me.getPathItems(),
112
+ i = 0,
113
+ len = pathItems.length,
114
+ newItems = [],
115
+ config, item
116
+
117
+ for (; i < len; i++) {
118
+ item = pathItems[i];
119
+
120
+ config = {
121
+ editRoute: false,
122
+ route : item.route,
123
+ text : item.name
124
+ };
125
+
126
+ if (items[i]) {
127
+ items[i].set(config);
128
+ } else {
129
+ newItems.push(config);
130
+ }
131
+ }
132
+
133
+ newItems.length > 0 && me.add(newItems);
134
+ }
47
135
  }
48
136
 
49
137
  Neo.applyClassConfig(Breadcrumb);