neo.mjs 5.11.1 → 5.12.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='5.11.1'
23
+ * @member {String} version='5.12.0'
24
24
  */
25
- version: '5.11.1'
25
+ version: '5.12.0'
26
26
  }
27
27
 
28
28
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.11.1'
23
+ * @member {String} version='5.12.0'
24
24
  */
25
- version: '5.11.1'
25
+ version: '5.12.0'
26
26
  }
27
27
 
28
28
  /**
@@ -174,15 +174,26 @@ class MainContainer extends ConfigurationViewport {
174
174
  return Neo.create({
175
175
  module : Button,
176
176
  badgeText: 'Badge',
177
+ handler : data => console.log('button click =>', data.component.id),
177
178
  height : 50,
178
179
  iconCls : 'fa fa-home',
179
180
  text : 'Hello World',
180
181
  ui : 'primary',
181
182
  width : 150,
182
183
 
183
- handler: (data) => {
184
- console.log('button click =>', data.component.id);
185
- }
184
+ menu: [{
185
+ handler: data => console.log('menu item click =>', data.component.id),
186
+ iconCls: 'fa fa-home',
187
+ text : 'Item 1'
188
+ }, {
189
+ handler: data => console.log('menu item click =>', data.component.id),
190
+ iconCls: 'fa fa-user',
191
+ text : 'Item 2'
192
+ }, {
193
+ handler: data => console.log('menu item click =>', data.component.id),
194
+ iconCls: 'fa fa-play',
195
+ text : 'Item 3'
196
+ }]
186
197
 
187
198
  /*tooltips: [{
188
199
  text: 'Hello World Tooltip'
@@ -1,3 +1,4 @@
1
+ import Button from '../../../src/button/Base.mjs';
1
2
  import CellColumnModel from '../../../src/selection/table/CellColumnModel.mjs';
2
3
  import CellColumnRowModel from '../../../src/selection/table/CellColumnRowModel.mjs';
3
4
  import CellModel from '../../../src/selection/table/CellModel.mjs';
@@ -84,6 +85,9 @@ class MainContainer extends ConfigurationViewport {
84
85
  }];
85
86
  }
86
87
 
88
+ /**
89
+ * @returns {Neo.table.Container}
90
+ */
87
91
  createExampleComponent() {
88
92
  return Neo.create(TableContainer, {
89
93
  autoRender : false,
@@ -95,10 +99,30 @@ class MainContainer extends ConfigurationViewport {
95
99
  {dataField: 'firstname', text: 'Firstname'},
96
100
  {dataField: 'lastname', text: 'Lastname'},
97
101
  {dataField: 'githubId', text: 'Github Id'},
98
- {dataField: 'country', text: 'Country'}
102
+ {dataField: 'country', text: 'Country'},
103
+ {
104
+ renderer: data => {
105
+ let button = Neo.create({
106
+ module : Button,
107
+ appName : this.appName,
108
+ handler : this.editButtonHandler,
109
+ parentId: 'myTableStoreContainer',
110
+ text : 'Edit'
111
+ });
112
+
113
+ return button.vdom
114
+ }
115
+ }
99
116
  ]
100
117
  });
101
118
  }
119
+
120
+ /**
121
+ * @param {Object} data
122
+ */
123
+ editButtonHandler(data) {
124
+ console.log(data)
125
+ }
102
126
  }
103
127
 
104
128
  Neo.applyClassConfig(MainContainer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.11.1",
3
+ "version": "5.12.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -55,9 +55,9 @@
55
55
  "inquirer": "^9.2.8",
56
56
  "neo-jsdoc": "^1.0.1",
57
57
  "neo-jsdoc-x": "^1.0.5",
58
- "postcss": "^8.4.26",
59
- "sass": "^1.63.6",
60
- "webpack": "^5.88.1",
58
+ "postcss": "^8.4.27",
59
+ "sass": "^1.64.1",
60
+ "webpack": "^5.88.2",
61
61
  "webpack-cli": "^5.1.4",
62
62
  "webpack-dev-server": "4.15.1",
63
63
  "webpack-hook-plugin": "^1.0.7",
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '5.11.1'
239
+ * @default '5.12.0'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '5.11.1'
244
+ version: '5.12.0'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
package/src/Main.mjs CHANGED
@@ -48,6 +48,7 @@ class Main extends core.Base {
48
48
  app: [
49
49
  'alert',
50
50
  'editRoute',
51
+ 'getByPath',
51
52
  'getWindowData',
52
53
  'redirectTo',
53
54
  'setNeoConfig',
@@ -150,6 +151,18 @@ class Main extends core.Base {
150
151
  window.location.hash = hashArr.join('&');
151
152
  }
152
153
 
154
+ /**
155
+ * Request specific accessible window attributes by path into the app worker.
156
+ * Keep in mind that this excludes anything DOM related or instances.
157
+ * Example: Neo.Main.getByPath({path: 'navigator.language'}).then(data => {})
158
+ * @param {Object} data
159
+ * @param {String} data.path
160
+ * @returns {*}
161
+ */
162
+ getByPath(data) {
163
+ return Neo.nsWithArrays(data.path)
164
+ }
165
+
153
166
  /**
154
167
  * window.screen is not spreadable
155
168
  * @returns {Object}
@@ -385,7 +398,7 @@ class Main extends core.Base {
385
398
  }
386
399
 
387
400
  /**
388
- * Change the location.hash value
401
+ * Change a Neo.config from the app worker
389
402
  * @param {Object} data
390
403
  * @param {String} data.key
391
404
  * @param {*} data.value
@@ -437,7 +450,7 @@ class Main extends core.Base {
437
450
  * @param {String} data.windowFeatures
438
451
  * @param {String} data.windowName
439
452
  * @return {Boolean}
440
- */
453
+ */
441
454
  windowOpen(data) {
442
455
  let openedWindow = window.open(data.url, data.windowName, data.windowFeatures),
443
456
  success = !!openedWindow;
@@ -78,6 +78,10 @@ class Base extends Component {
78
78
  * @member {String} iconPosition_='left'
79
79
  */
80
80
  iconPosition_: 'left',
81
+ /**
82
+ * @member {Object[]|null} menu_=null
83
+ */
84
+ menu_: null,
81
85
  /**
82
86
  * The pressed state of the Button
83
87
  * @member {Boolean} pressed_=false
@@ -236,6 +240,29 @@ class Base extends Component {
236
240
  this.cls = cls;
237
241
  }
238
242
 
243
+ /**
244
+ * Triggered after the menu config got changed
245
+ * @param {Object[]|null} value
246
+ * @param {Object[]|null} oldValue
247
+ * @protected
248
+ */
249
+ afterSetMenu(value, oldValue) {
250
+ if (value) {
251
+ import('../menu/List.mjs').then(module => {
252
+ let list = Neo.create({
253
+ module : module.default,
254
+ appName : this.appName,
255
+ floating: true,
256
+ items : value
257
+ });
258
+
259
+ list.render(true);
260
+
261
+ console.log('afterSetMenu', list);
262
+ })
263
+ }
264
+ }
265
+
239
266
  /**
240
267
  * Triggered after the pressed config got changed
241
268
  * @param {Boolean} value
@@ -17,31 +17,31 @@ class Video extends BaseComponent {
17
17
  */
18
18
  className: 'Neo.component.Video',
19
19
  /*
20
- * @member {String} ntype='neo-video'
20
+ * @member {String} ntype='video'
21
21
  * @protected
22
22
  */
23
23
  ntype: 'video',
24
24
  /*
25
- * @member {[String]} cls=['neo-video']
25
+ * @member {String[]} baseCls=['neo-video']
26
26
  */
27
27
  baseCls: ['neo-video'],
28
- /*
29
- * @member {String} url=null
30
- * @public
31
- */
32
- url_: null,
33
-
34
28
  /**
35
29
  * Current state of the video
36
- * @member {boolean} playing=false
30
+ * @member {Boolean} playing=false
37
31
  */
38
32
  playing_: false,
39
33
  /**
40
34
  * Type of the video
41
- * @member {boolean} type='video/mp4'
35
+ * @member {Boolean} type='video/mp4'
42
36
  */
43
37
  type: 'video/mp4',
44
-
38
+ /*
39
+ * @member {String} url=null
40
+ */
41
+ url_: null,
42
+ /**
43
+ * @member {Object} _vdom
44
+ */
45
45
  _vdom: {
46
46
  cn: [{
47
47
  flag: 'ghost',
@@ -64,17 +64,12 @@ class Video extends BaseComponent {
64
64
  }
65
65
  }
66
66
 
67
-
68
67
  /**
69
- * construct is earlier in component life cicle than init
70
- *
71
- * @param config
68
+ * @param {Object} config
72
69
  */
73
70
  construct(config) {
74
71
  super.construct(config);
75
72
 
76
- console.log(this);
77
-
78
73
  let me = this,
79
74
  domListeners = me.domListeners;
80
75
 
@@ -162,4 +157,4 @@ class Video extends BaseComponent {
162
157
 
163
158
  Neo.applyClassConfig(Video);
164
159
 
165
- export default Video;
160
+ export default Video;
@@ -86,12 +86,12 @@ class Fetch extends Base {
86
86
 
87
87
  /**
88
88
  * @param {Object|String} url
89
- * @param {Object} config
89
+ * @param {Object} config={}
90
90
  * @param {String} method
91
91
  * @param {Object} [data]
92
92
  * @returns {Promise<any>}
93
93
  */
94
- request(url, config, method, data) {
94
+ request(url, config={}, method, data) {
95
95
  if (!Neo.isString(url)) {
96
96
  config = url;
97
97
  url = config.url;
@@ -320,14 +320,7 @@ class Picker extends Text {
320
320
  * @param {Object} data
321
321
  */
322
322
  onInputClick(data) {
323
- let me = this;
324
-
325
- if (!me.editable) {
326
- me.togglePicker();
327
-
328
- // stay in sync to the trigger-click logic
329
- !me.pickerIsMounted && me.focus()
330
- }
323
+ !this.editable && this.togglePicker()
331
324
  }
332
325
 
333
326
  /**
@@ -981,10 +981,10 @@ class Text extends Base {
981
981
 
982
982
  /**
983
983
  * Calls focus() on the inputEl node instead
984
- * @param {String} id=this.id
984
+ * @param {String} id
985
985
  * @override
986
986
  */
987
- focus(id=this.id) {
987
+ focus(id) {
988
988
  super.focus(this.getInputElId())
989
989
  }
990
990
 
@@ -105,7 +105,9 @@ class DomEvent extends Base {
105
105
  }
106
106
 
107
107
  if (!preventFire) {
108
- // console.log(Neo.get(id));
108
+ // multiple listeners would change the reference of data.component
109
+ data = Neo.clone(data, true);
110
+
109
111
  data.component = component;
110
112
  listener.fn.apply(listener.scope || globalThis, [data]);
111
113
 
@@ -59,12 +59,10 @@ class View extends Component {
59
59
  i = 0,
60
60
  vdom = me.vdom,
61
61
  cellCls, cellId, config, column, dockLeftMargin, dockRightMargin, id, index, j, rendererOutput,
62
- record, rendererValue, selectedRows, trCls;
62
+ record, rendererType, rendererValue, selectedRows, trCls;
63
63
 
64
64
  me.recordVnodeMap = {}; // remove old data
65
65
 
66
- // console.log('createViewData', me.id, inputData);
67
-
68
66
  if (container.selectionModel.ntype === 'selection-table-rowmodel') {
69
67
  selectedRows = container.selectionModel.items || [];
70
68
  }
@@ -113,17 +111,29 @@ class View extends Component {
113
111
  value : rendererValue
114
112
  });
115
113
 
116
- cellCls = rendererOutput?.cls || ['neo-table-cell'];
117
-
118
- if (column.align !== 'left') {
119
- cellCls.push('neo-' + column.align);
114
+ cellCls = ['neo-table-cell'];
115
+ rendererType = Neo.typeOf(rendererOutput);
116
+
117
+ switch (rendererType) {
118
+ case 'Object': {
119
+ if (rendererOutput.cls && rendererOutput.html) {
120
+ cellCls.push(...rendererOutput.cls);
121
+ } else {
122
+ rendererOutput = [rendererOutput];
123
+ }
124
+ break;
125
+ }
126
+ case 'String': {
127
+ rendererOutput = {
128
+ cls : cellCls,
129
+ html: rendererOutput?.toString()
130
+ };
131
+ break;
132
+ }
120
133
  }
121
134
 
122
- if (!Neo.isObject(rendererOutput)) {
123
- rendererOutput = {
124
- cls : cellCls,
125
- html: rendererOutput?.toString()
126
- };
135
+ if (column.align !== 'left') {
136
+ cellCls.push('neo-' + column.align)
127
137
  }
128
138
 
129
139
  // todo: remove the else part as soon as all tables use stores (examples table)
@@ -134,14 +144,19 @@ class View extends Component {
134
144
  }
135
145
 
136
146
  config = {
137
- tag : 'td',
138
- id : cellId,
139
- cls : cellCls,
140
- innerHTML: rendererOutput.html || '',
141
- style : rendererOutput.style || {},
142
- tabIndex : '-1'
147
+ tag : 'td',
148
+ id : cellId,
149
+ cls : cellCls,
150
+ style : rendererOutput.style || {},
151
+ tabIndex: '-1'
143
152
  };
144
153
 
154
+ if (rendererType === 'String') {
155
+ config.innerHTML = rendererOutput.html || ''
156
+ } else {
157
+ config.cn = rendererOutput
158
+ }
159
+
145
160
  if (column.dock) {
146
161
  config.cls = ['neo-locked', ...config.cls || []];
147
162