neo.mjs 6.7.0 → 6.7.2

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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='6.7.0'
23
+ * @member {String} version='6.7.2'
24
24
  */
25
- version: '6.7.0'
25
+ version: '6.7.2'
26
26
  }
27
27
 
28
28
  /**
@@ -1,8 +1,14 @@
1
- import Button from '../src/button/Base.mjs';
2
- import Container from '../src/container/Base.mjs';
3
- import NeoArray from '../src/util/Array.mjs';
4
- import Panel from '../src/container/Panel.mjs';
5
- import Viewport from '../src/container/Viewport.mjs';
1
+ import Button from '../src/button/Base.mjs';
2
+ import Container from '../src/container/Base.mjs';
3
+ import {bindAppend} from '../src/util/Function.mjs';
4
+ import Panel from '../src/container/Panel.mjs';
5
+ import Viewport from '../src/container/Viewport.mjs';
6
+
7
+ // add custom themes here
8
+ const themes = [
9
+ {name: 'neo-theme-dark', label: 'Theme Dark'},
10
+ {name: 'neo-theme-light', label: 'Theme Light'}
11
+ ]
6
12
 
7
13
  /**
8
14
  * Base class for example Apps which should be configurable
@@ -112,8 +118,7 @@ class ConfigurationViewport extends Viewport {
112
118
 
113
119
  items: [...me.configurationComponents, {
114
120
  module : Button,
115
- handler: me.onSwitchTheme.bind(me, 'cmp'),
116
- id : me.id + '_cmp_' + 'switchThemeButton',
121
+ handler: bindAppend(me.onSwitchTheme, me, 'cmp'),
117
122
  style : {marginTop: '20px'},
118
123
  text : theme === 'neo-theme-dark' ? 'Theme Light' : 'Theme Dark',
119
124
  width : 100
@@ -172,24 +177,26 @@ class ConfigurationViewport extends Viewport {
172
177
  }
173
178
 
174
179
  /**
180
+ * @param {Object} data
175
181
  * @param {String} target
176
182
  */
177
- onSwitchTheme(target) {
178
- let me = this,
179
- button = Neo.getComponent(me.id + (target !== 'cmp' ? '__' : '_cmp_') + 'switchThemeButton'),
180
- newTheme, oldTheme;
181
-
182
- if (button.text === 'Theme Light') {
183
- newTheme = 'neo-theme-light';
184
- oldTheme = 'neo-theme-dark';
185
-
186
- button.text = 'Theme Dark';
187
- } else {
188
- newTheme = 'neo-theme-dark';
189
- oldTheme = 'neo-theme-light';
190
-
191
- button.text = 'Theme Light';
192
- }
183
+ onSwitchTheme(data, target) {
184
+ let me = this,
185
+ button = data.component,
186
+ countThemes = themes.length,
187
+ newTheme, oldIndex, oldTheme, themeIndex;
188
+
189
+ themes.forEach((theme, index) => {
190
+ if (button.text === theme.label) {
191
+ newTheme = theme.name;
192
+ themeIndex = index;
193
+ }
194
+ });
195
+
196
+ oldIndex = (themeIndex + 1) % countThemes;
197
+ oldTheme = themes[oldIndex].name;
198
+
199
+ button.text = themes[oldIndex].label;
193
200
 
194
201
  if (target === 'cmp') {
195
202
  me.exampleComponent.theme = newTheme;
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='6.7.0'
23
+ * @member {String} version='6.7.2'
24
24
  */
25
- version: '6.7.0'
25
+ version: '6.7.2'
26
26
  }
27
27
 
28
28
  /**
@@ -44,11 +44,12 @@ class DemoDialog extends Dialog {
44
44
  })()
45
45
  }
46
46
  }, {
47
- module : Button,
48
- handler: me.createDialog.bind(me),
49
- iconCls: 'fa fa-window-maximize',
50
- text : 'Create new modal Dialog',
51
- }];
47
+ module : Button,
48
+ handler : me.createDialog.bind(me),
49
+ iconCls : 'fa fa-window-maximize',
50
+ reference: 'create-second-dialog-button',
51
+ text : 'Create new modal Dialog',
52
+ }]
52
53
  }
53
54
 
54
55
  /**
@@ -63,16 +64,16 @@ class DemoDialog extends Dialog {
63
64
  appName : me.appName,
64
65
  boundaryContainerId: me.boundaryContainerId,
65
66
  listeners : {close: me.onWindowClose, scope: me},
66
- modal : true
67
+ modal : true,
68
+ title : 'Second Dialog'
67
69
  });
68
70
  }
69
71
 
72
+ /**
73
+ *
74
+ */
70
75
  onWindowClose() {
71
- let button = this.down({
72
- text: 'Create new modal Dialog'
73
- });
74
-
75
- button.disabled = false;
76
+ this.getReference('create-second-dialog-button').disabled = false;
76
77
  }
77
78
  }
78
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "6.7.0",
3
+ "version": "6.7.2",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "@fortawesome/fontawesome-free": "^6.4.2",
46
46
  "@material/mwc-button": "^0.27.0",
47
47
  "@material/mwc-textfield": "^0.27.0",
48
- "autoprefixer": "^10.4.15",
48
+ "autoprefixer": "^10.4.16",
49
49
  "chalk": "^5.3.0",
50
50
  "clean-webpack-plugin": "^4.0.0",
51
51
  "commander": "^11.0.0",
@@ -57,7 +57,7 @@
57
57
  "neo-jsdoc": "1.0.1",
58
58
  "neo-jsdoc-x": "1.0.5",
59
59
  "postcss": "^8.4.30",
60
- "sass": "^1.67.0",
60
+ "sass": "^1.68.0",
61
61
  "showdown": "^2.1.0",
62
62
  "webpack": "^5.88.2",
63
63
  "webpack-cli": "^5.1.4",
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '6.7.0'
239
+ * @default '6.7.2'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '6.7.0'
244
+ version: '6.7.2'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
@@ -1336,7 +1336,7 @@ class Base extends CoreBase {
1336
1336
  }
1337
1337
 
1338
1338
  if (me.parentId) {
1339
- parentComponent = Neo.getComponent(me.parentId) || Neo.get(me.parentId);
1339
+ parentComponent = me.parent || Neo.get(me.parentId);
1340
1340
 
1341
1341
  if (parentComponent) {
1342
1342
  return parentComponent.getConfigInstanceByNtype(configName, ntype)
@@ -1419,7 +1419,7 @@ class Base extends CoreBase {
1419
1419
  * @returns {Number|undefined}
1420
1420
  */
1421
1421
  getMountedParentIndex() {
1422
- let parent = Neo.getComponent(this.parentId),
1422
+ let parent = this.parent,
1423
1423
  items = parent?.items || [],
1424
1424
  i = 0,
1425
1425
  index = 0,
@@ -1559,7 +1559,7 @@ class Base extends CoreBase {
1559
1559
  let removeFn = function() {
1560
1560
  if(me.parentId !== 'document.body') {
1561
1561
  me.vdom.removeDom = true;
1562
- Neo.getComponent(me.parentId).update()
1562
+ me.parent.update()
1563
1563
  } else {
1564
1564
  me.unmount()
1565
1565
  }
@@ -2033,7 +2033,7 @@ class Base extends CoreBase {
2033
2033
  if (me.silentVdomUpdate) {
2034
2034
  me.needsVdomUpdate = true
2035
2035
  } else if(me.parentId !== 'document.body') {
2036
- Neo.getComponent(me.parentId).update()
2036
+ me.parent.update()
2037
2037
  } else {
2038
2038
  !me.mounted && me.render(true)
2039
2039
  }
@@ -2161,7 +2161,7 @@ class Base extends CoreBase {
2161
2161
  /**
2162
2162
  * Convenience shortcut for Neo.manager.Component.up
2163
2163
  * @param {Object|String} config
2164
- * @returns {Neo.core.Base} The matching instance or null
2164
+ * @returns {Neo.component.Base|null} The matching instance or null
2165
2165
  */
2166
2166
  up(config) {
2167
2167
  return ComponentManager.up(this.id, config)
@@ -13,8 +13,8 @@ class Base extends Component {
13
13
  * @static
14
14
  */
15
15
  static delayable = {
16
- fireChangeEvent : {type: 'debounce', timer: 300},
17
- fireUserChangeEvent: {type: 'debounce', timer: 300}
16
+ fireChangeEvent : {type: 'debounce', timer: 1000},
17
+ fireUserChangeEvent: {type: 'debounce', timer: 1000}
18
18
  }
19
19
 
20
20
  static config = {
@@ -142,7 +142,7 @@ class Container extends BaseContainer {
142
142
 
143
143
  me.vdom.id = me.getWrapperId();
144
144
 
145
- me.createColumns(me.columns);
145
+ me.createColumns(me.columns)
146
146
  }
147
147
 
148
148
  /**
@@ -152,7 +152,7 @@ class Container extends BaseContainer {
152
152
  * @protected
153
153
  */
154
154
  afterSetSelectionModel(value, oldValue) {
155
- this.rendered && value.register(this);
155
+ this.rendered && value.register(this)
156
156
  }
157
157
 
158
158
  /**
@@ -163,7 +163,7 @@ class Container extends BaseContainer {
163
163
  */
164
164
  afterSetShowHeaderFilters(value, oldValue) {
165
165
  if (oldValue !== undefined) {
166
- Neo.getComponent(this.headerToolbarId).showHeaderFilters = value;
166
+ Neo.getComponent(this.headerToolbarId).showHeaderFilters = value
167
167
  }
168
168
  }
169
169
 
@@ -175,7 +175,7 @@ class Container extends BaseContainer {
175
175
  */
176
176
  afterSetSortable(value, oldValue) {
177
177
  if (oldValue !== undefined) {
178
- Neo.getComponent(this.headerToolbarId).sortable = value;
178
+ Neo.getComponent(this.headerToolbarId).sortable = value
179
179
  }
180
180
  }
181
181
 
@@ -187,7 +187,7 @@ class Container extends BaseContainer {
187
187
  */
188
188
  afterSetUseCustomScrollbars(value, oldValue) {
189
189
  if (value === true) {
190
- this.vdom.cls = NeoArray.union(this.vdom.cls, ['neo-use-custom-scrollbar']);
190
+ this.vdom.cls = NeoArray.union(this.vdom.cls, ['neo-use-custom-scrollbar'])
191
191
  }
192
192
  }
193
193
 
@@ -200,17 +200,17 @@ class Container extends BaseContainer {
200
200
  cssRules = [];
201
201
 
202
202
  if (me.dockLeftMargin) {
203
- cssRules.push('#' + id + '::-webkit-scrollbar-track:horizontal {margin-left: ' + me.dockLeftMargin + 'px;}');
203
+ cssRules.push('#' + id + '::-webkit-scrollbar-track:horizontal {margin-left: ' + me.dockLeftMargin + 'px;}')
204
204
  }
205
205
 
206
206
  if (me.dockRightMargin) {
207
- cssRules.push('#' + id + '::-webkit-scrollbar-track:horizontal {margin-right: ' + me.dockRightMargin + 'px;}');
207
+ cssRules.push('#' + id + '::-webkit-scrollbar-track:horizontal {margin-right: ' + me.dockRightMargin + 'px;}')
208
208
  }
209
209
  if (cssRules.length > 0) {
210
- CssUtil.insertRules(me.appName, cssRules);
210
+ CssUtil.insertRules(me.appName, cssRules)
211
211
  }
212
212
 
213
- me.scrollbarsCssApplied = true;
213
+ me.scrollbarsCssApplied = true
214
214
  }
215
215
 
216
216
  /**
@@ -221,10 +221,10 @@ class Container extends BaseContainer {
221
221
  */
222
222
  beforeSetColumns(value, oldValue) {
223
223
  if (this.configsApplied) {
224
- return this.createColumns(value);
224
+ return this.createColumns(value)
225
225
  }
226
226
 
227
- return value;
227
+ return value
228
228
  }
229
229
 
230
230
  /**
@@ -234,7 +234,7 @@ class Container extends BaseContainer {
234
234
  * @protected
235
235
  */
236
236
  beforeSetHeaderToolbarId(value, oldValue) {
237
- return value ? value : oldValue;
237
+ return value || oldValue
238
238
  }
239
239
 
240
240
  /**
@@ -246,7 +246,7 @@ class Container extends BaseContainer {
246
246
  beforeSetSelectionModel(value, oldValue) {
247
247
  oldValue?.destroy();
248
248
 
249
- return ClassSystemUtil.beforeSetInstance(value, RowModel);
249
+ return ClassSystemUtil.beforeSetInstance(value, RowModel)
250
250
  }
251
251
 
252
252
  /**
@@ -270,20 +270,20 @@ class Container extends BaseContainer {
270
270
 
271
271
  if (value instanceof Store) {
272
272
  value.on(listeners);
273
- value.getCount() > 0 && me.onStoreLoad(value.items);
273
+ value.getCount() > 0 && me.onStoreLoad(value.items)
274
274
  } else {
275
275
  value = ClassSystemUtil.beforeSetInstance(value, Store, {
276
276
  listeners
277
- });
277
+ })
278
278
  }
279
279
 
280
280
  // in case we dynamically change the store, the view needs to get the new reference
281
281
  if (me.view) {
282
- me.view.store = value;
282
+ me.view.store = value
283
283
  }
284
284
  }
285
285
 
286
- return value;
286
+ return value
287
287
  }
288
288
 
289
289
  /**
@@ -293,7 +293,7 @@ class Container extends BaseContainer {
293
293
  * @protected
294
294
  */
295
295
  beforeSetViewId(value, oldValue) {
296
- return value ? value : oldValue;
296
+ return value || oldValue
297
297
  }
298
298
 
299
299
  /**
@@ -325,26 +325,26 @@ class Container extends BaseContainer {
325
325
 
326
326
  if (sorters?.[0]) {
327
327
  if (column.dataField === sorters[0].property) {
328
- column.isSorted = sorters[0].direction;
328
+ column.isSorted = sorters[0].direction
329
329
  }
330
330
  }
331
331
 
332
332
  column.listeners = {
333
333
  sort : me.onSortColumn,
334
334
  scope: me
335
- };
335
+ }
336
336
  });
337
337
 
338
338
  me.items[0].items = columns;
339
339
 
340
- return columns;
340
+ return columns
341
341
  }
342
342
 
343
343
  /**
344
344
  * @param {Number} countRows
345
345
  */
346
346
  createRandomViewData(countRows) {
347
- this.loadData(countRows);
347
+ this.loadData(countRows)
348
348
  }
349
349
 
350
350
  /**
@@ -360,7 +360,7 @@ class Container extends BaseContainer {
360
360
  me.applyCustomScrollbarsCss();
361
361
  }
362
362
 
363
- me.items = items;
363
+ me.items = items
364
364
  }
365
365
 
366
366
  /**
@@ -368,21 +368,21 @@ class Container extends BaseContainer {
368
368
  * @returns {*}
369
369
  */
370
370
  getVdomRoot() {
371
- return this.vdom.cn[0];
371
+ return this.vdom.cn[0]
372
372
  }
373
373
 
374
374
  /**
375
375
  * @returns {Object[]} The new vdom items root
376
376
  */
377
377
  getVdomItemsRoot() {
378
- return this.vdom.cn[0];
378
+ return this.vdom.cn[0]
379
379
  }
380
380
 
381
381
  /**
382
382
  * @returns {Neo.table.View}
383
383
  */
384
384
  getView() {
385
- return Neo.getComponent(this.viewId) || Neo.get(this.viewId);
385
+ return Neo.getComponent(this.viewId) || Neo.get(this.viewId)
386
386
  }
387
387
 
388
388
  /**
@@ -390,14 +390,14 @@ class Container extends BaseContainer {
390
390
  * @returns {Neo.vdom.VNode}
391
391
  */
392
392
  getVnodeRoot() {
393
- return this.vnode.childNodes[0];
393
+ return this.vnode.childNodes[0]
394
394
  }
395
395
 
396
396
  /**
397
397
  * @returns {String}
398
398
  */
399
399
  getWrapperId() {
400
- return `${this.id}__wrapper`;
400
+ return `${this.id}__wrapper`
401
401
  }
402
402
 
403
403
  /**
@@ -409,8 +409,8 @@ class Container extends BaseContainer {
409
409
  countColumns = columns.length;
410
410
 
411
411
  Neo.manager.Store.createRandomData([countColumns, countRows]).then(data => {
412
- me.createViewData(data);
413
- });
412
+ me.createViewData(data)
413
+ })
414
414
  }
415
415
 
416
416
  /**
@@ -426,8 +426,8 @@ class Container extends BaseContainer {
426
426
  if (me.createRandomData) {
427
427
  // todo: if mounting apply after mount
428
428
  setTimeout(() => {
429
- me.createRandomViewData(me.amountRows);
430
- }, 50);
429
+ me.createRandomViewData(me.amountRows)
430
+ }, 50)
431
431
  }
432
432
  }
433
433
 
@@ -442,14 +442,14 @@ class Container extends BaseContainer {
442
442
 
443
443
  me.store.sort(opts);
444
444
  me.removeSortingCss(opts.property);
445
- me.onStoreLoad(me.store.items);
445
+ me.onStoreLoad(me.store.items)
446
446
  }
447
447
 
448
448
  /**
449
449
  *
450
450
  */
451
451
  onStoreFilter() {
452
- this.onStoreLoad(this.store.items);
452
+ this.onStoreLoad(this.store.items)
453
453
  }
454
454
 
455
455
  /**
@@ -464,14 +464,14 @@ class Container extends BaseContainer {
464
464
  me.createViewData(data);
465
465
 
466
466
  if (me.store.sorters.length < 1) {
467
- me.removeSortingCss();
467
+ me.removeSortingCss()
468
468
  }
469
469
  } else {
470
470
  listenerId = me.on('rendered', () => {
471
471
  me.un('rendered', listenerId);
472
472
  setTimeout(() => {
473
- me.createViewData(data);
474
- }, 50);
473
+ me.createViewData(data)
474
+ }, 50)
475
475
  });
476
476
  }
477
477
  }
@@ -487,7 +487,7 @@ class Container extends BaseContainer {
487
487
  * @param {*} opts.value
488
488
  */
489
489
  onStoreRecordChange(opts) {
490
- Neo.getComponent(this.viewId).onStoreRecordChange(opts);
490
+ Neo.getComponent(this.viewId).onStoreRecordChange(opts)
491
491
  }
492
492
 
493
493
  /**
@@ -497,9 +497,9 @@ class Container extends BaseContainer {
497
497
  removeSortingCss(dataField) {
498
498
  this.items[0].items.forEach(column => {
499
499
  if (column.dataField !== dataField) {
500
- column.removeSortingCss();
500
+ column.removeSortingCss()
501
501
  }
502
- });
502
+ })
503
503
  }
504
504
  }
505
505
 
@@ -134,7 +134,7 @@ class View extends Component {
134
134
  createViewData(inputData) {
135
135
  let me = this,
136
136
  amountRows = inputData.length,
137
- container = Neo.getComponent(me.parentId),
137
+ container = me.parent,
138
138
  columns = container.items[0].items,
139
139
  colCount = columns.length,
140
140
  data = [],
@@ -248,8 +248,8 @@ class View extends Component {
248
248
  * @returns {Object|null}
249
249
  */
250
250
  getColumn(field) {
251
- let container = Neo.getComponent(this.parentId),
252
- columns = container.columns,
251
+ let container = this.parent,
252
+ columns = container.items[0].items, // todo: we need a shortcut for accessing the header toolbar
253
253
  i = 0,
254
254
  len = columns.length,
255
255
  column;
@@ -337,7 +337,7 @@ class View extends Component {
337
337
  */
338
338
  onStoreRecordChange(opts) {
339
339
  let me = this,
340
- container = Neo.getComponent(me.parentId),
340
+ container = me.parent,
341
341
  needsUpdate = false,
342
342
  vdom = me.vdom,
343
343
  cellId, cellNode, column, index, scope;
@@ -369,9 +369,9 @@ class Button extends BaseButton {
369
369
  */
370
370
  onDrop(data) {
371
371
  let me = this,
372
- headerToolbar = Neo.getComponent(me.parentId),
372
+ headerToolbar = me.parent,
373
373
  style = me.style,
374
- tableContainer = Neo.getComponent(headerToolbar.parentId);
374
+ tableContainer = headerToolbar.parent;
375
375
 
376
376
  me.onDragLeave();
377
377
  headerToolbar.switchItems(me.id, data.srcId);
@@ -27,6 +27,13 @@ class Breadcrumb extends Toolbar {
27
27
  * @member {String[]} baseCls=['neo-breadcrumb-toolbar','neo-toolbar']
28
28
  */
29
29
  baseCls: ['neo-breadcrumb-toolbar', 'neo-toolbar'],
30
+ /**
31
+ * @member {Object} itemDefaults={ntype:'button', ui: 'tertiary'}
32
+ */
33
+ itemDefaults: {
34
+ ntype: 'button',
35
+ ui : 'tertiary'
36
+ },
30
37
  /**
31
38
  * @member {Neo.data.Store|Object} store_=null
32
39
  */
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Append args instead of prepending them
3
+ * @param {Function} fn
3
4
  * @param {Object} scope
4
5
  * @returns {Function}
5
6
  */
6
- export function bindAppend(scope) {
7
- const fn = this,
8
- args = [].slice.call(arguments).slice(1);
7
+ export function bindAppend(fn, scope) {
8
+ const args = [].slice.call(arguments).slice(2);
9
9
 
10
10
  return function() {
11
11
  return fn.apply(scope, [].slice.call(arguments).concat(args))