neo.mjs 8.41.1 → 8.42.0

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='8.41.1'
23
+ * @member {String} version='8.42.0'
24
24
  */
25
- version: '8.41.1'
25
+ version: '8.42.0'
26
26
  }
27
27
 
28
28
  /**
@@ -16,7 +16,7 @@
16
16
  "@type": "Organization",
17
17
  "name": "Neo.mjs"
18
18
  },
19
- "datePublished": "2025-04-08",
19
+ "datePublished": "2025-04-09",
20
20
  "publisher": {
21
21
  "@type": "Organization",
22
22
  "name": "Neo.mjs"
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v8.41.1'
110
+ html : 'v8.42.0'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.41.1'
23
+ * @member {String} version='8.42.0'
24
24
  */
25
- version: '8.41.1'
25
+ version: '8.42.0'
26
26
  }
27
27
 
28
28
  /**
@@ -1,5 +1,6 @@
1
1
  import CheckBox from '../../../src/form/field/CheckBox.mjs';
2
2
  import CountryField from '../../../src/form/field/Country.mjs';
3
+ import DateField from '../../../src/form/field/Date.mjs';
3
4
  import Dialog from '../../../src/dialog/Base.mjs';
4
5
  import TextField from '../../../src/form/field/Text.mjs';
5
6
 
@@ -58,6 +59,11 @@ class EditUserDialog extends Dialog {
58
59
  labelText: 'Lastname',
59
60
  listeners: {change: 'up.onLastnameFieldChange'},
60
61
  reference: 'lastname-field'
62
+ }, {
63
+ module : DateField,
64
+ labelText: 'Date',
65
+ listeners: {change: 'up.onDateFieldChange'},
66
+ reference: 'date-field'
61
67
  }, {
62
68
  module : CountryField,
63
69
  bind : {store: 'stores.countries'},
@@ -89,6 +95,7 @@ class EditUserDialog extends Dialog {
89
95
  await me.timeout(20);
90
96
 
91
97
  me.getItem('country-field') .value = record.country;
98
+ me.getItem('date-field') .value = record.date;
92
99
  me.getItem('firstname-field').value = record['user.firstname'];
93
100
  me.getItem('lastname-field') .value = record['user.lastname'];
94
101
  me.getItem('selected-field') .checked = record['annotations.selected'];
@@ -106,6 +113,17 @@ class EditUserDialog extends Dialog {
106
113
  this.record.set({country: data.value.code})
107
114
  }
108
115
 
116
+ /**
117
+ * @param {Object} data
118
+ */
119
+ onDateFieldChange(data) {
120
+ // You can also access the internal setter directly:
121
+ // this.record.country = data.value.code
122
+ // Using the API allows bulk changes
123
+
124
+ this.record.set({date: data.value})
125
+ }
126
+
109
127
  /**
110
128
  * @param {Object} data
111
129
  */
@@ -26,6 +26,9 @@ class MainModel extends Model {
26
26
  }, {
27
27
  name: 'country',
28
28
  type: 'String'
29
+ }, {
30
+ name: 'date',
31
+ type: 'String'
29
32
  }, {
30
33
  name: 'edit',
31
34
  type: 'String'
@@ -13,6 +13,7 @@ class MainStore extends Store {
13
13
 
14
14
  data: [{
15
15
  country : 'DE',
16
+ date : '2025-04-15',
16
17
  githubId: 'tobiu',
17
18
 
18
19
  user: {
@@ -25,6 +26,7 @@ class MainStore extends Store {
25
26
  },
26
27
 
27
28
  country : 'US',
29
+ date : '2025-04-16',
28
30
  githubId: 'rwaters',
29
31
 
30
32
  user: {
@@ -33,6 +35,7 @@ class MainStore extends Store {
33
35
  }
34
36
  }, {
35
37
  country : 'DE',
38
+ date : '2025-04-17',
36
39
  githubId: 'mrsunshine',
37
40
 
38
41
  user: {
@@ -41,6 +44,7 @@ class MainStore extends Store {
41
44
  }
42
45
  }, {
43
46
  country : 'US',
47
+ date : '2025-04-18',
44
48
  githubId: 'camtnbikerrwc',
45
49
 
46
50
  user: {
@@ -1,6 +1,7 @@
1
1
  import BaseViewport from '../../../src/container/Viewport.mjs';
2
2
  import Button from '../../../src/button/Base.mjs';
3
3
  import GridContainer from '../../../src/grid/Container.mjs';
4
+ import ViewportController from './ViewportController.mjs';
4
5
  import ViewportStateProvider from './ViewportStateProvider.mjs';
5
6
 
6
7
  /**
@@ -14,6 +15,10 @@ class Viewport extends BaseViewport {
14
15
  * @protected
15
16
  */
16
17
  className: 'Neo.examples.grid.nestedRecordFields.Viewport',
18
+ /**
19
+ * @member {Neo.controller.Component} controller=ViewportController
20
+ */
21
+ controller: ViewportController,
17
22
  /**
18
23
  * @member {Neo.state.Provider} stateProvider=ViewportStateProvider
19
24
  */
@@ -32,12 +37,12 @@ class Viewport extends BaseViewport {
32
37
  style : {marginBottom: '1em'},
33
38
 
34
39
  items: ['->', {
35
- handler: 'up.onSwitchDragModeButtonClick',
40
+ handler: 'onSwitchDragModeButtonClick',
36
41
  iconCls: 'far fa-square',
37
42
  style : {marginRight: '1em'},
38
43
  text : 'Drag column headers only'
39
44
  }, {
40
- handler: 'up.onSwitchThemeButtonClick',
45
+ handler: 'onSwitchThemeButtonClick',
41
46
  iconCls: 'fas fa-sun',
42
47
  text : 'Light Theme'
43
48
  }]
@@ -54,10 +59,11 @@ class Viewport extends BaseViewport {
54
59
  {dataField: 'user.firstname', text: 'Firstname'},
55
60
  {dataField: 'user.lastname', text: 'Lastname'},
56
61
  {dataField: 'githubId', text: 'Github Id'},
62
+ {dataField: 'date', text: 'Date'},
57
63
  {dataField: 'country', text: 'Country', renderer: 'up.countryRenderer'},
58
64
  {dataField: 'edit', text: 'Edit Action', component: {
59
65
  module : Button,
60
- handler: 'up.editButtonHandler',
66
+ handler: 'editButtonHandler',
61
67
  text : 'Edit'
62
68
  }}
63
69
  ],
@@ -68,11 +74,6 @@ class Viewport extends BaseViewport {
68
74
  }]
69
75
  }
70
76
 
71
- /**
72
- * @member {Neo.dialog.Base|null} dialog=null
73
- */
74
- dialog = null
75
-
76
77
  /**
77
78
  * @param {Object} data
78
79
  */
@@ -85,73 +86,6 @@ class Viewport extends BaseViewport {
85
86
 
86
87
  return ''
87
88
  }
88
-
89
- /**
90
- * @param {Object} data
91
- */
92
- editButtonHandler(data) {
93
- let me = this,
94
- button = data.component,
95
- {appName, dialog, theme, windowId} = me,
96
- {record} = button;
97
-
98
- if (!dialog) {
99
- import('./EditUserDialog.mjs').then(module => {
100
- me.dialog = Neo.create({
101
- module : module.default,
102
- animateTargetId: button.id,
103
- appName,
104
- stateProvider : {parent: me.getStateProvider()},
105
- record,
106
- theme,
107
- windowId
108
- })
109
- })
110
- } else {
111
- dialog.animateTargetId = button.id;
112
- dialog.record = record;
113
-
114
- dialog.show()
115
- }
116
- }
117
-
118
- /**
119
- * @param {Object} data
120
- */
121
- onSwitchDragModeButtonClick(data) {
122
- let button = data.component,
123
- grid = this.getReference('grid'),
124
- {sortZone} = grid.headerToolbar;
125
-
126
- if (button.iconCls === 'fas fa-check') {
127
- button.set({iconCls: 'far fa-square'});
128
- sortZone.moveColumnContent = true
129
- } else {
130
- button.set({iconCls: 'fas fa-check'});
131
- sortZone.moveColumnContent = false
132
- }
133
- }
134
-
135
- /**
136
- * @param {Object} data
137
- */
138
- onSwitchThemeButtonClick(data) {
139
- let me = this,
140
- button = data.component,
141
- isDarkTheme = me.theme !== 'neo-theme-light',
142
- theme = isDarkTheme ? 'neo-theme-light' : 'neo-theme-dark';
143
-
144
- button.set({
145
- iconCls: isDarkTheme ? 'fa fa-moon' : 'fa fa-sun',
146
- text : isDarkTheme ? 'Dark Theme' : 'Light Theme'
147
- });
148
-
149
- me.theme = theme;
150
-
151
- if (me.dialog) {
152
- me.dialog.theme = theme
153
- }
154
- }
155
89
  }
156
90
 
157
91
  export default Neo.setupClass(Viewport);
@@ -0,0 +1,110 @@
1
+ import Component from '../../../src/controller/Component.mjs';
2
+
3
+ /**
4
+ * @class Neo.examples.grid.nestedRecordFields.ViewportController
5
+ * @extends Neo.controller.Component
6
+ */
7
+ class ViewportController extends Component {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Neo.examples.grid.nestedRecordFields.ViewportController'
11
+ * @protected
12
+ */
13
+ className: 'Neo.examples.grid.nestedRecordFields.ViewportController'
14
+ }
15
+
16
+ /**
17
+ * @member {Neo.dialog.Base|null} dialog=null
18
+ */
19
+ dialog = null
20
+
21
+ /**
22
+ * @param {Object} data
23
+ */
24
+ editButtonHandler(data) {
25
+ let me = this,
26
+ {dialog} = me,
27
+ button = data.component,
28
+ {appName, record, theme, windowId} = button;
29
+
30
+ if (!dialog) {
31
+ import('./EditUserDialog.mjs').then(module => {
32
+ me.dialog = Neo.create({
33
+ module : module.default,
34
+ animateTargetId: button.id,
35
+ appName,
36
+ stateProvider : {parent: me.getStateProvider()},
37
+ record,
38
+ theme,
39
+ windowId
40
+ })
41
+ })
42
+ } else {
43
+ dialog.animateTargetId = button.id;
44
+ dialog.record = record;
45
+
46
+ dialog.show()
47
+ }
48
+ }
49
+
50
+ /**
51
+ * @param {Record[]} items
52
+ */
53
+ onCountryStoreLoad(items) {
54
+ let me = this,
55
+ mainStore = me.getStore('mainStore'),
56
+ country;
57
+
58
+ // if the main table store is already loaded, the country field renderer had no data
59
+ if (mainStore.getCount() > 0) {
60
+ mainStore.items.forEach(record => {
61
+ country = record.country;
62
+
63
+ // hack resetting the current value to get a new record change
64
+ record.toJSON().country = null;
65
+
66
+ record.country = country
67
+ })
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @param {Object} data
73
+ */
74
+ onSwitchDragModeButtonClick(data) {
75
+ let button = data.component,
76
+ grid = this.getReference('grid'),
77
+ {sortZone} = grid.headerToolbar;
78
+
79
+ if (button.iconCls === 'fas fa-check') {
80
+ button.set({iconCls: 'far fa-square'});
81
+ sortZone.moveColumnContent = true
82
+ } else {
83
+ button.set({iconCls: 'fas fa-check'});
84
+ sortZone.moveColumnContent = false
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @param {Object} data
90
+ */
91
+ onSwitchThemeButtonClick(data) {
92
+ let me = this,
93
+ button = data.component,
94
+ isDarkTheme = button.theme !== 'neo-theme-light',
95
+ theme = isDarkTheme ? 'neo-theme-light' : 'neo-theme-dark';
96
+
97
+ button.set({
98
+ iconCls: isDarkTheme ? 'fa fa-moon' : 'fa fa-sun',
99
+ text : isDarkTheme ? 'Dark Theme' : 'Light Theme'
100
+ });
101
+
102
+ me.component.theme = theme;
103
+
104
+ if (me.dialog) {
105
+ me.dialog.theme = theme
106
+ }
107
+ }
108
+ }
109
+
110
+ export default Neo.setupClass(ViewportController);
@@ -2,8 +2,6 @@ import MainStore from './MainStore.mjs';
2
2
  import StateProvider from '../../../src/state/Provider.mjs';
3
3
  import Store from '../../../src/data/Store.mjs';
4
4
 
5
- const dataSymbol = Symbol.for('data');
6
-
7
5
  /**
8
6
  * @class Neo.examples.grid.nestedRecordFields.ViewportStateProvider
9
7
  * @extends Neo.state.Provider
@@ -36,27 +34,6 @@ class ViewportStateProvider extends StateProvider {
36
34
  mainStore: MainStore
37
35
  }
38
36
  }
39
-
40
- /**
41
- * @param {Record[]} items
42
- */
43
- onCountryStoreLoad(items) {
44
- let me = this,
45
- mainStore = me.getStore('mainStore'),
46
- country;
47
-
48
- // if the main table store is already loaded, the country field renderer had no data
49
- if (mainStore.getCount() > 0) {
50
- mainStore.items.forEach(record => {
51
- country = record.country;
52
-
53
- // hack resetting the current value to get a new record change
54
- record[dataSymbol].country = null;
55
-
56
- record.country = country
57
- })
58
- }
59
- }
60
37
  }
61
38
 
62
39
  export default Neo.setupClass(ViewportStateProvider);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "8.41.1",
3
+ "version": "8.42.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -65,7 +65,7 @@
65
65
  "sass": "^1.86.3",
66
66
  "siesta-lite": "5.5.2",
67
67
  "url": "^0.11.4",
68
- "webpack": "^5.99.3",
68
+ "webpack": "^5.99.5",
69
69
  "webpack-cli": "^6.0.1",
70
70
  "webpack-dev-server": "^5.2.1",
71
71
  "webpack-hook-plugin": "^1.0.7",
@@ -263,12 +263,12 @@ const DefaultConfig = {
263
263
  useVdomWorker: true,
264
264
  /**
265
265
  * buildScripts/injectPackageVersion.mjs will update this value
266
- * @default '8.41.1'
266
+ * @default '8.42.0'
267
267
  * @memberOf! module:Neo
268
268
  * @name config.version
269
269
  * @type String
270
270
  */
271
- version: '8.41.1'
271
+ version: '8.42.0'
272
272
  };
273
273
 
274
274
  Object.assign(DefaultConfig, {
@@ -811,7 +811,7 @@ class Collection extends Base {
811
811
  /**
812
812
  * Returns the first item which matches the property and value
813
813
  * @param {Object|String} property
814
- * @param {String|Number} [value] Only required in case the first param is a string
814
+ * @param {Number|String} [value] Only required in case the first param is a string
815
815
  * @returns {Object} Returns the first found item or null
816
816
  */
817
817
  findFirst(property, value) {
@@ -828,7 +828,7 @@ class Collection extends Base {
828
828
 
829
829
  /**
830
830
  * Returns the object associated to the key, or null if there is none.
831
- * @param key
831
+ * @param {Number|String} key
832
832
  * @returns {Object|null}
833
833
  */
834
834
  get(key) {
@@ -2316,7 +2316,7 @@ class Component extends Base {
2316
2316
  {useVdomWorker} = Neo.config;
2317
2317
 
2318
2318
  // Verify that the critical rendering path => CSS files for the new tree is in place
2319
- if (currentWorker.countLoadingThemeFiles !== 0) {
2319
+ if (autoMount && currentWorker.countLoadingThemeFiles !== 0) {
2320
2320
  currentWorker.on('themeFilesLoaded', function() {
2321
2321
  !me.mounted && me.render(mount)
2322
2322
  }, me, {once: true});
@@ -303,7 +303,7 @@ class Container extends Component {
303
303
  createItem(item, index) {
304
304
  let me = this,
305
305
  config = {appName: me.appName, parentId: me.id, parentIndex: index, windowId: me.windowId},
306
- defaults = {theme: me.theme, ...me.itemDefaults},
306
+ defaults = {...me.itemDefaults},
307
307
  lazyLoadItem, module;
308
308
 
309
309
  if (defaults) {
@@ -319,6 +319,7 @@ class Container extends Component {
319
319
  switch (Neo.typeOf(item)) {
320
320
  case 'NeoClass': {
321
321
  item = Neo.create({
322
+ theme: item.config.theme || me.theme,
322
323
  ...defaults,
323
324
  module: item,
324
325
  ...config
@@ -350,7 +351,8 @@ class Container extends Component {
350
351
  lazyLoadItem = module && !module.isClass && Neo.isFunction(module);
351
352
 
352
353
  if (module && !lazyLoadItem) {
353
- item.className = module.prototype.className
354
+ item.className = module.prototype.className;
355
+ item.theme = defaults.theme || module.config.theme || me.theme
354
356
  }
355
357
 
356
358
  if (item.handlerScope === 'this') {
@@ -1,4 +1,5 @@
1
1
  import Base from './Base.mjs';
2
+ import NeoArray from '../util/Array.mjs';
2
3
  import {resolveCallback} from '../util/Function.mjs';
3
4
 
4
5
  /**
@@ -182,7 +183,7 @@ class Observable extends Base {
182
183
 
183
184
  // remove the listener if the scope no longer exists
184
185
  if (cb.scope && !cb.scope.id) {
185
- listeners[name].splice(i, 1)
186
+ NeoArray.remove(listeners[name], handler)
186
187
  } else {
187
188
  if (!me.suspendEvents) {
188
189
  // Object event format. Inject firer reference in as 'source'
@@ -191,7 +192,7 @@ class Observable extends Base {
191
192
  }
192
193
 
193
194
  // remove the listener if it has the once flag
194
- handler.once && listeners[name].splice(i, 1)
195
+ handler.once && NeoArray.remove(listeners[name], handler);
195
196
 
196
197
  if (Neo.isNumber(delay) && delay > 0) {
197
198
  me.delayedCallback(cb, handler.data ? args.concat(handler.data) : args, delay)
@@ -104,6 +104,9 @@ class Component extends Column {
104
104
  windowId
105
105
  });
106
106
 
107
+ view.getController() ?.parseConfig(component);
108
+ view.getStateProvider()?.parseConfig(component);
109
+
107
110
  me.map.set(id, component)
108
111
  }
109
112
 
@@ -35,7 +35,7 @@ class Component extends Manager {
35
35
  let me = this;
36
36
 
37
37
  Neo.first = me.getFirst.bind(me); // alias
38
- Neo.getComponent = me.getById.bind(me) // alias
38
+ Neo.getComponent = me.get .bind(me) // alias
39
39
  }
40
40
 
41
41
  /**
@@ -157,7 +157,7 @@ class Component extends Manager {
157
157
  }
158
158
 
159
159
  /**
160
- * @param {Array} path
160
+ * @param {Object[]} path
161
161
  * @returns {String|null} the component id in case there is a match
162
162
  */
163
163
  findParentComponent(path) {
@@ -179,11 +179,20 @@ class Component extends Manager {
179
179
 
180
180
  /**
181
181
  * Returns the object associated to the key, or null if there is none.
182
- * @param key
182
+ * @param {Number|String} key
183
+ * @param {Boolean} [includeWrapperNodes=true]
183
184
  * @returns {Neo.component.Base|null}
184
185
  */
185
- get(key) {
186
- return this.wrapperNodes.get(key) || super.get(key)
186
+ get(key, includeWrapperNodes=true) {
187
+ if (includeWrapperNodes) {
188
+ let wrapperNode = this.wrapperNodes.get(key);
189
+
190
+ if (wrapperNode) {
191
+ return wrapperNode
192
+ }
193
+ }
194
+
195
+ return super.get(key)
187
196
  }
188
197
 
189
198
  /**
@@ -333,7 +342,7 @@ class Component extends Manager {
333
342
  let parentIds = [];
334
343
 
335
344
  while (component?.parentId) {
336
- component = this.getById(component.parentId);
345
+ component = this.get(component.parentId);
337
346
 
338
347
  if (component) {
339
348
  parentIds.push(component.id)
@@ -369,13 +378,13 @@ class Component extends Manager {
369
378
  */
370
379
  getParents(component) {
371
380
  if (Neo.isString(component)) {
372
- component = this.getById(component)
381
+ component = this.get(component)
373
382
  }
374
383
 
375
384
  let parents = [];
376
385
 
377
386
  while (component?.parentId) {
378
- component = this.getById(component.parentId);
387
+ component = this.get(component.parentId);
379
388
 
380
389
  if (component) {
381
390
  parents.push(component)
@@ -509,7 +518,7 @@ class Component extends Manager {
509
518
  * @returns {Neo.component.Base|Neo.component.Base[]|null}
510
519
  */
511
520
  up(componentId, config, returnFirstMatch=true) {
512
- let component = this.getById(componentId),
521
+ let component = this.get(componentId),
513
522
  returnArray = [],
514
523
  configArray, configLength, matchArray;
515
524
 
@@ -525,7 +534,7 @@ class Component extends Manager {
525
534
  configLength = configArray.length;
526
535
 
527
536
  while (component?.parentId) {
528
- component = this.getById(component.parentId);
537
+ component = this.get(component.parentId);
529
538
 
530
539
  if (!component) {
531
540
  return returnFirstMatch ? null : returnArray
@@ -163,7 +163,7 @@ class Logger extends Base {
163
163
  component;
164
164
 
165
165
  data.path.forEach(item => {
166
- component = Neo.getComponent(item.id);
166
+ component = Neo.getComponent(item.id, false);
167
167
 
168
168
  if (component) {
169
169
  if (!isGroupSet) {