neo.mjs 4.4.1 → 4.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.4.1",
3
+ "version": "4.4.3",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -26,15 +26,17 @@
26
26
  }
27
27
 
28
28
  .neo-spin-button {
29
- border-left: 1px solid v(textfield-border-color);
30
- color : v(trigger-color);
31
- cursor : pointer;
32
- display : block;
33
- font-size : 10px;
34
- height : 50%;
35
- line-height: 11px;
36
- text-align : center;
37
- width : 22px;
29
+ align-items : center;
30
+ border-left : 1px solid v(textfield-border-color);
31
+ color : v(trigger-color);
32
+ cursor : pointer;
33
+ display : flex;
34
+ font-size : 10px;
35
+ height : 50%;
36
+ justify-content: center;
37
+ line-height : 11px;
38
+ text-align : center;
39
+ width : 22px;
38
40
 
39
41
  &.neo-up {
40
42
  border-bottom: 1px solid v(textfield-border-color);
@@ -51,4 +53,4 @@
51
53
  color : v(trigger-color-hover);
52
54
  }
53
55
  }
54
- }
56
+ }
@@ -1,7 +1,7 @@
1
1
  .neo-textfield {
2
2
  align-items : center;
3
3
  display : flex;
4
- height : 27px;
4
+ height : calc(v(textfield-input-height) + v(textfield-border-width) * 2);
5
5
  margin-bottom: 5px;
6
6
  margin-top : 5px;
7
7
  white-space : nowrap;
@@ -181,7 +181,7 @@
181
181
  border-radius : v(textfield-border-radius);
182
182
  display : flex;
183
183
  flex : 1 1 100px;
184
- min-height : 25px;
184
+ min-height : v(textfield-input-height);
185
185
  overflow : hidden;
186
186
 
187
187
  .neo-textfield-input {
@@ -208,9 +208,9 @@
208
208
  border : 1px solid v(textfield-border-color);
209
209
  border-radius : v(textfield-border-radius);
210
210
  color : v(textfield-input-color);
211
- font : 400 13px/17px #{neo(neo-font-family)};
211
+ font : v(textfield-input-font);
212
212
  min-height : 27px;
213
- padding : 3px 6px 2px;
213
+ padding : v(textfield-input-padding);
214
214
  transition : 250ms border-color cubic-bezier(0.4, 0, 0.2, 1);
215
215
  width : 140px;
216
216
 
@@ -4,7 +4,7 @@
4
4
  cursor : pointer;
5
5
  display : inline-block;
6
6
  font-size : 14px;
7
- height : 25px; // has to be 1px smaller to not overlap the bottom border on hover
7
+ height : v(textfield-input-height); // has to be 1px smaller to not overlap the bottom border on hover
8
8
  line-height: 26px;
9
9
  text-align : center;
10
10
  width : 22px;
@@ -24,4 +24,4 @@
24
24
  .neo-field-trigger {
25
25
  outline: none;
26
26
  }
27
- }
27
+ }
@@ -6,6 +6,9 @@ $neoMap: map-merge($neoMap, (
6
6
  'textfield-border-width' : 1px,
7
7
  'textfield-input-background-color' : #2b2b2b,
8
8
  'textfield-input-color' : #ccc,
9
+ 'textfield-input-font' : 400 13px/17px Arial,
10
+ 'textfield-input-height' : 25px,
11
+ 'textfield-input-padding' : 3px 6px 2px,
9
12
  'textfield-input-placeholder-color' : #ccc,
10
13
  'textfield-input-placeholder-opacity': 0.6,
11
14
  'textfield-label-color' : #bbb,
@@ -22,6 +25,9 @@ $neoMap: map-merge($neoMap, (
22
25
  --textfield-border-width : #{neo(textfield-border-width)};
23
26
  --textfield-input-background-color : #{neo(textfield-input-background-color)};
24
27
  --textfield-input-color : #{neo(textfield-input-color)};
28
+ --textfield-input-font : #{neo(textfield-input-font)};
29
+ --textfield-input-height : #{neo(textfield-input-height)};
30
+ --textfield-input-padding : #{neo(textfield-input-padding)};
25
31
  --textfield-input-placeholder-color : #{neo(textfield-input-placeholder-color)};
26
32
  --textfield-input-placeholder-opacity: #{neo(textfield-input-placeholder-opacity)};
27
33
  --textfield-label-color : #{neo(textfield-label-color)};
@@ -6,6 +6,9 @@ $neoMap: map-merge($neoMap, (
6
6
  'textfield-border-width' : 1px,
7
7
  'textfield-input-background-color' : #fff,
8
8
  'textfield-input-color' : #000,
9
+ 'textfield-input-font' : 400 13px/17px Arial,
10
+ 'textfield-input-height' : 25px,
11
+ 'textfield-input-padding' : 3px 6px 2px,
9
12
  'textfield-input-placeholder-color' : #333,
10
13
  'textfield-input-placeholder-opacity': 0.6,
11
14
  'textfield-label-color' : #666,
@@ -22,6 +25,9 @@ $neoMap: map-merge($neoMap, (
22
25
  --textfield-border-width : #{neo(textfield-border-width)};
23
26
  --textfield-input-background-color : #{neo(textfield-input-background-color)};
24
27
  --textfield-input-color : #{neo(textfield-input-color)};
28
+ --textfield-input-font : #{neo(textfield-input-font)};
29
+ --textfield-input-height : #{neo(textfield-input-height)};
30
+ --textfield-input-padding : #{neo(textfield-input-padding)};
25
31
  --textfield-input-placeholder-color : #{neo(textfield-input-placeholder-color)};
26
32
  --textfield-input-placeholder-opacity: #{neo(textfield-input-placeholder-opacity)};
27
33
  --textfield-label-color : #{neo(textfield-label-color)};
package/src/list/Base.mjs CHANGED
@@ -57,6 +57,12 @@ class Base extends Component {
57
57
  * @member {Object} dragZoneConfig=null
58
58
  */
59
59
  dragZoneConfig: null,
60
+ /**
61
+ * In case we are using list item headers and want to bind list item indexes to e.g. a card layout
62
+ * for e.g. a sidenav, this config comes in handy.
63
+ * @member {Number|null} headerlessActiveIndex_=null
64
+ */
65
+ headerlessActiveIndex_: null,
60
66
  /**
61
67
  * @member {Boolean} highlightFilterValue=true
62
68
  */
@@ -147,12 +153,15 @@ class Base extends Component {
147
153
  * @protected
148
154
  */
149
155
  afterSetActiveIndex(value, oldValue) {
150
- let selectionModel = this.selectionModel;
156
+ let me = this,
157
+ selectionModel = me.selectionModel;
151
158
 
152
159
  if (Neo.isNumber(value)) {
153
160
  selectionModel?.selectAt(value);
161
+ me.headerlessActiveIndex = me.getHeaderlessIndex(value);
154
162
  } else if (Neo.isNumber(oldValue)) {
155
163
  selectionModel.deselectAll();
164
+ me.headerlessActiveIndex = null;
156
165
  }
157
166
  }
158
167
 
@@ -209,6 +218,25 @@ class Base extends Component {
209
218
  }
210
219
  }
211
220
 
221
+ /**
222
+ * Triggered after the headerlessActiveIndex config got changed
223
+ * @param {Number} value
224
+ * @param {Number} oldValue
225
+ * @protected
226
+ */
227
+ afterSetHeaderlessActiveIndex(value, oldValue) {
228
+ let me = this,
229
+ activeIndex;
230
+
231
+ if (Neo.isNumber(value)) {
232
+ activeIndex = me.getActiveIndex(value);
233
+
234
+ me.activeIndex = activeIndex;
235
+ } else if (Neo.isNumber(oldValue)) {
236
+ me.activeIndex = null;
237
+ }
238
+ }
239
+
212
240
  /**
213
241
  * Triggered after the selectionModel config got changed
214
242
  * @param {Neo.selection.Model} value
@@ -448,6 +476,25 @@ class Base extends Component {
448
476
  });
449
477
  }
450
478
 
479
+ /**
480
+ * Transforms an index excluding list item headers into the real store index
481
+ * @param {Number} headerlessIndex
482
+ * @returns {Number}
483
+ */
484
+ getActiveIndex(headerlessIndex) {
485
+ let delta = 0,
486
+ i = 0,
487
+ records = this.store.items;
488
+
489
+ for (; i <= headerlessIndex; i++) {
490
+ if (records[i].isHeader) {
491
+ delta++;
492
+ }
493
+ }
494
+
495
+ return headerlessIndex + delta;
496
+ }
497
+
451
498
  /**
452
499
  * @param {Number|String} recordId
453
500
  * @returns {String}
@@ -456,6 +503,28 @@ class Base extends Component {
456
503
  return `${this.id}__${recordId}`;
457
504
  }
458
505
 
506
+ /**
507
+ * Returns the index of a list item excluding item headers
508
+ * @param {Number} index
509
+ * @returns {Number}
510
+ */
511
+ getHeaderlessIndex(index) {
512
+ let headerlessIndex = 0,
513
+ i = 0,
514
+ records = this.store.items,
515
+ len = records.length;
516
+
517
+ for (; i < len; i++) {
518
+ if (!records[i].isHeader) {
519
+ headerlessIndex++;
520
+
521
+ if (headerlessIndex === index) {
522
+ return i;
523
+ }
524
+ }
525
+ }
526
+ }
527
+
459
528
  /**
460
529
  * @param {String} vnodeId
461
530
  * @returns {String|Number} itemId