neo.mjs 5.10.0 → 5.10.1

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.10.0'
23
+ * @member {String} version='5.10.1'
24
24
  */
25
- version: '5.10.0'
25
+ version: '5.10.1'
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.10.0'
23
+ * @member {String} version='5.10.1'
24
24
  */
25
- version: '5.10.0'
25
+ version: '5.10.1'
26
26
  }
27
27
 
28
28
  /**
@@ -0,0 +1,78 @@
1
+ import Button from '../../../src/button/Base.mjs';
2
+ import Container from '../../../src/container/Base.mjs';
3
+
4
+ /**
5
+ * @class Neo.examples.container.base.MainContainer
6
+ * @extends Neo.container.Base
7
+ */
8
+ class MainContainer extends Container {
9
+ static config = {
10
+ className: 'Neo.examples.container.base.MainContainer',
11
+ autoMount: true,
12
+ layout : 'vbox',
13
+
14
+ items: [{
15
+ ntype : 'button',
16
+ iconCls: 'fa fa-home',
17
+ text : 'Hello',
18
+ width : 200
19
+ }, {
20
+ ntype : 'button',
21
+ iconCls: 'fa fa-user',
22
+ text : 'World'
23
+ }, {
24
+ ntype : 'container',
25
+ layout: {
26
+ ntype: 'hbox',
27
+ align: 'stretch'
28
+ },
29
+ items : [{
30
+ ntype : 'button',
31
+ iconCls: 'fa fa-home',
32
+ style : {color: 'red'},
33
+ text : 'Hello2',
34
+ width : 200
35
+ }, {
36
+ ntype : 'button',
37
+ flex : 1,
38
+ iconCls : 'fa fa-user',
39
+ iconColor: 'red',
40
+ text : 'World2'
41
+ }]
42
+ }, {
43
+ ntype: 'container',
44
+
45
+ layout: {
46
+ ntype: 'vbox',
47
+ align: 'start'
48
+ },
49
+
50
+ style: {
51
+ marginTop: '30px'
52
+ },
53
+
54
+ items: [{
55
+ ntype : 'button',
56
+ iconCls : 'fa fa-home',
57
+ iconPosition: 'right',
58
+ text : 'Right'
59
+ }, {
60
+ ntype : 'button',
61
+ flex : 1,
62
+ iconCls : 'fa fa-user',
63
+ iconPosition: 'top',
64
+ text : 'Top'
65
+ }, {
66
+ ntype : 'button',
67
+ flex : 1,
68
+ iconCls : 'fa fa-play-circle',
69
+ iconPosition: 'bottom',
70
+ text : 'Bottom'
71
+ }]
72
+ }]
73
+ }
74
+ }
75
+
76
+ Neo.applyClassConfig(MainContainer);
77
+
78
+ export default MainContainer;
@@ -2,6 +2,6 @@ import MainContainer from './MainContainer.mjs';
2
2
 
3
3
  export const onStart = () => Neo.app({
4
4
  mainView: MainContainer,
5
- name : 'Neo.examples.container',
5
+ name : 'Neo.examples.container.base',
6
6
  parentId: 'main-container'
7
7
  });
@@ -9,6 +9,6 @@
9
9
  <p>Container Demo</p>
10
10
  <div id="main-container"></div>
11
11
 
12
- <script src="../../src/MicroLoader.mjs" type="module"></script>
12
+ <script src="../../../src/MicroLoader.mjs" type="module"></script>
13
13
  </body>
14
14
  </html>
@@ -1,6 +1,6 @@
1
1
  {
2
- "appPath" : "examples/container/app.mjs",
3
- "basePath" : "../../",
2
+ "appPath" : "examples/container/base/app.mjs",
3
+ "basePath" : "../../../",
4
4
  "environment": "development",
5
5
  "mainPath" : "./Main.mjs",
6
6
  "themes" : ["neo-theme-dark"]
@@ -0,0 +1,68 @@
1
+ import Button from '../../../src/button/Base.mjs';
2
+ import ConfigurationViewport from '../../ConfigurationViewport.mjs';
3
+ import MainContainerController from './MainContainerController.mjs';
4
+ import NumberField from '../../../src/form/field/Number.mjs';
5
+ import TextField from '../../../src/form/field/Text.mjs';
6
+
7
+ /**
8
+ * @class Neo.examples.container.dialog.MainContainer
9
+ * @extends Neo.examples.ConfigurationViewport
10
+ */
11
+ class MainContainer extends ConfigurationViewport {
12
+ static config = {
13
+ className : 'Neo.examples.container.dialog.MainContainer',
14
+ configItemLabelWidth: 160,
15
+ configItemWidth : 280,
16
+ controller : MainContainerController,
17
+ layout : {ntype: 'hbox', align: 'stretch'}
18
+ }
19
+
20
+ createConfigurationComponents() {
21
+ let me = this;
22
+
23
+ return [{
24
+ module : TextField,
25
+ clearable : true,
26
+ labelText : 'title',
27
+ listeners : {change: me.controller.onConfigChange.bind(me.controller, 'title')},
28
+ style : {marginTop: '10px'},
29
+ value : 'example dialog'
30
+ }, {
31
+ module : NumberField,
32
+ clearable : true,
33
+ labelText : 'height',
34
+ listeners : {change: me.controller.onConfigChange.bind(me.controller, 'height')},
35
+ maxValue : 1000,
36
+ minValue : 100,
37
+ stepSize : 10,
38
+ style : {marginTop: '10px'},
39
+ value : 300
40
+ }, {
41
+ module : NumberField,
42
+ clearable : true,
43
+ labelText : 'width',
44
+ listeners : {change: me.controller.onConfigChange.bind(me.controller, 'width')},
45
+ maxValue : 2000,
46
+ minValue : 100,
47
+ stepSize : 10,
48
+ style : {marginTop: '10px'},
49
+ value : 500
50
+ }];
51
+ }
52
+
53
+ createExampleComponent() {
54
+ let controller = this.getController();
55
+ return Neo.create({
56
+ module : Button,
57
+ height : 50,
58
+ text : 'show Dialog',
59
+ ui : 'primary',
60
+ width : 150,
61
+ handler : controller.onButtonClick.bind(controller)
62
+ });
63
+ }
64
+ }
65
+
66
+ Neo.applyClassConfig(MainContainer);
67
+
68
+ export default MainContainer;
@@ -0,0 +1,80 @@
1
+ import Component from '../../../src/controller/Component.mjs';
2
+
3
+ /**
4
+ * @class Neo.examples.container.dialog.MainContainerController
5
+ * @extends Neo.controller.Component
6
+ */
7
+ class MainContainerController extends Component {
8
+ static config = {
9
+ /**
10
+ * @member {String} className='Neo.examples.container.dialog.MainContainerController'
11
+ * @protected
12
+ */
13
+ className: 'Neo.examples.container.dialog.MainContainerController'
14
+ }
15
+
16
+ dialog = null;
17
+ title = 'example dialog';
18
+ height = 300;
19
+ width = 500;
20
+
21
+ /**
22
+ *
23
+ * @param {*} config
24
+ */
25
+ construct(config) {
26
+ super.construct(config);
27
+ }
28
+
29
+ /**
30
+ *
31
+ * @param {Object} data
32
+ */
33
+ async onButtonClick(data) {
34
+ if (!this.dialog) {
35
+ let module = await import ('../../../src/container/Dialog.mjs');
36
+ this.dialog = Neo.create({
37
+ module: module.default,
38
+ appName: this.component.appName,
39
+ autoMount: true,
40
+ autoRender: true,
41
+ title: this.title,
42
+ height: this.height,
43
+ width: this.width,
44
+ iconCls: ['fa', 'fa-home'],
45
+
46
+ headerConfig: {
47
+ items: [{
48
+ ntype: 'button',
49
+ text: 'foo'
50
+ }],
51
+ style: {borderBottom: 'solid 1px #bdbdbd'}
52
+ },
53
+
54
+ items: [{
55
+ ntype: 'container',
56
+ html: 'text'
57
+ }]
58
+ })
59
+ }
60
+ this.dialog.show();
61
+
62
+ console.log(data, this);
63
+ }
64
+
65
+ /**
66
+ * @param {String} config
67
+ * @param {Object} opts
68
+ */
69
+ onConfigChange(config, opts) {
70
+ if (this.dialog) {
71
+ this.dialog[config] = opts.value;
72
+ } else {
73
+ this[config] = opts.value;
74
+ }
75
+ }
76
+ }
77
+
78
+ Neo.applyClassConfig(MainContainerController);
79
+
80
+ export default MainContainerController;
@@ -0,0 +1,6 @@
1
+ import MainContainer from './MainContainer.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: MainContainer,
5
+ name : 'Neo.examples.container.dialog'
6
+ });
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <meta charset="UTF-8">
6
+ <title>Neo Dialog</title>
7
+ </head>
8
+ <body>
9
+ <script src="../../../src/MicroLoader.mjs" type="module"></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,7 @@
1
+ {
2
+ "appPath" : "examples/container/dialog/app.mjs",
3
+ "basePath" : "../../../",
4
+ "environment": "development",
5
+ "mainPath" : "./Main.mjs",
6
+ "mainThreadAddons": ["DragDrop", "ScrollSync", "Stylesheet", "Dialog"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.10.0",
3
+ "version": "5.10.1",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -52,12 +52,12 @@
52
52
  "envinfo": "^7.8.1",
53
53
  "fs-extra": "^11.1.1",
54
54
  "highlightjs-line-numbers.js": "^2.8.0",
55
- "inquirer": "^9.2.3",
55
+ "inquirer": "^9.2.6",
56
56
  "neo-jsdoc": "^1.0.1",
57
57
  "neo-jsdoc-x": "^1.0.5",
58
58
  "postcss": "^8.4.23",
59
59
  "sass": "^1.62.1",
60
- "webpack": "^5.82.1",
60
+ "webpack": "^5.84.1",
61
61
  "webpack-cli": "^5.1.1",
62
62
  "webpack-dev-server": "4.15.0",
63
63
  "webpack-hook-plugin": "^1.0.7",
@@ -0,0 +1,12 @@
1
+ .neo-container-dialog {
2
+ padding: 0;
3
+ z-index: 100;
4
+
5
+ &:not([open]) {
6
+ display: none;
7
+ }
8
+
9
+ > div {
10
+ padding: 1em;
11
+ }
12
+ }
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '5.10.0'
239
+ * @default '5.10.1'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '5.10.0'
244
+ version: '5.10.1'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
@@ -0,0 +1,221 @@
1
+ import Base from '../container/Panel.mjs';
2
+ import NeoArray from '../util/Array.mjs';
3
+ import HeaderToolbar from '../dialog/header/Toolbar.mjs';
4
+
5
+ /**
6
+ * Lightweight implementation using the dialog tag.
7
+ * See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
8
+ * @class Neo.container.Dialog
9
+ * @extends Neo.container.Panel
10
+ */
11
+ class Dialog extends Base {
12
+ static config = {
13
+ /**
14
+ * @member {String} className='Neo.container.Dialog'
15
+ * @protected
16
+ */
17
+ className: 'Neo.container.Dialog',
18
+ /**
19
+ * @member {String} ntype='container-dialog'
20
+ * @protected
21
+ */
22
+ ntype: 'container-dialog',
23
+ /**
24
+ * @member {String[]} baseCls=['container-dialog']
25
+ * @protected
26
+ */
27
+ baseCls: ['neo-container-dialog', 'neo-panel', 'neo-container'],
28
+ /**
29
+ * @member {Object} headerConfig=null
30
+ */
31
+ headerConfig: null,
32
+ /**
33
+ * @member {Neo.toolbar.Base|null} headerToolbar=null
34
+ */
35
+ headerToolbar: null,
36
+ /**
37
+ * The CSS class to use for an icon, e.g. 'fa fa-home'
38
+ * @member {String|null} [iconCls_=null]
39
+ */
40
+ iconCls_: null,
41
+ /**
42
+ * @member {Object[]} items
43
+ */
44
+ items: [],
45
+ /**
46
+ * @member {String} title=null
47
+ */
48
+ title_: null,
49
+ /**
50
+ * @member {Object} _vdom={tag: 'dialog', cn: []}
51
+ */
52
+ _vdom:
53
+ {tag: 'dialog', cn: []}
54
+ }
55
+
56
+ /**
57
+ * @param {Object} config
58
+ */
59
+ construct(config) {
60
+ super.construct(config);
61
+ this.createHeader();
62
+ }
63
+
64
+ /**
65
+ * Triggered after the iconCls config got changed
66
+ * @param {String} value
67
+ * @param {String} oldValue
68
+ * @protected
69
+ */
70
+ afterSetIconCls(value, oldValue) {
71
+ console.log(value, oldValue)
72
+
73
+ if (!this.headers) { return }
74
+ let iconNode = this.headers.down({flag: 'dialog-header-icon'});
75
+ let iconNodeCls = [...iconNode.cls];
76
+
77
+ NeoArray.remove(iconNodeCls, oldValue);
78
+ NeoArray.add( iconNodeCls, value);
79
+
80
+ iconNode.cls = iconNodeCls;
81
+
82
+ iconNode.removeDom = !value || value === '';
83
+ this.update();
84
+ }
85
+
86
+ /**
87
+ * Triggered after the title config got changed
88
+ * @param {String} value
89
+ * @param {String} oldValue
90
+ * @protected
91
+ */
92
+ afterSetTitle(value, oldValue) {
93
+ this.headerToolbar?.set({
94
+ title: value
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Converts the iconCls array into a string on beforeGet
100
+ * @returns {String}
101
+ * @protected
102
+ */
103
+ beforeGetIconCls() {
104
+ let iconCls = this._iconCls;
105
+
106
+ if (Array.isArray(iconCls)) {
107
+ return iconCls.join(' ');
108
+ }
109
+
110
+ return iconCls;
111
+ }
112
+
113
+ /**
114
+ * Triggered before the iconCls config gets changed. Converts the string into an array if needed.
115
+ * @param {Array|String|null} value
116
+ * @param {Array|String|null} oldValue
117
+ * @returns {Array}
118
+ * @protected
119
+ */
120
+ beforeSetIconCls(value, oldValue) {
121
+ if (value && !Array.isArray(value)) {
122
+ value = value.split(' ').filter(Boolean);
123
+ }
124
+
125
+ return value;
126
+ }
127
+
128
+ /**
129
+ * close the dialog in main thread
130
+ */
131
+ close() {
132
+ let me = this;
133
+
134
+ Neo.main.addon.Dialog.close({
135
+ id: me.id,
136
+ appName: me.appName
137
+ });
138
+ }
139
+
140
+ /**
141
+ * @protected
142
+ */
143
+ createHeader() {
144
+ let me = this,
145
+ cls = ['neo-header-toolbar', 'neo-toolbar'],
146
+ headers = me.headers || [],
147
+ headerConfigCopy = {...me.headerConfig};
148
+ delete headerConfigCopy.items;
149
+
150
+ me.headerToolbar = Neo.create({
151
+ module : HeaderToolbar,
152
+ actions: [{action: 'close', iconCls: 'fa-solid fa-xmark'}],
153
+ appName : me.appName,
154
+ cls,
155
+ dock : 'top',
156
+ flex : 'none',
157
+ id : me.getHeaderToolbarId(),
158
+ listeners: {headerAction: me.executeHeaderAction, scope: me},
159
+ items : [{
160
+ cls: me.iconCls,
161
+ flag : 'dialog-header-icon',
162
+ }, {
163
+ ntype : 'label',
164
+ cls : ['neo-panel-header-text', 'neo-label'],
165
+ flag : 'title-label',
166
+ removeDom: !me.title,
167
+ text : me.title
168
+ }, ...me.headerConfig.items],
169
+
170
+ ...headerConfigCopy
171
+ });
172
+
173
+ headers.unshift(me.headerToolbar);
174
+
175
+ me.headers = headers;
176
+ }
177
+
178
+ /**
179
+ * {Object} data
180
+ */
181
+ executeHeaderAction(data) {
182
+ let me = this,
183
+
184
+ map = {
185
+ close : me.close
186
+ };
187
+
188
+ map[data.action]?.call(me, data);
189
+
190
+ me.fire('headerAction', {
191
+ dialog: me,
192
+ ...data
193
+ })
194
+ }
195
+
196
+ /**
197
+ * Returns the id of the header toolbar
198
+ * @returns {String}
199
+ */
200
+ getHeaderToolbarId() {
201
+ return this.id + '-header-toolbar';
202
+ }
203
+
204
+ /**
205
+ * Shows the dialog (with / without Modal) in main thread
206
+ * @param {Boolean} modal
207
+ */
208
+ async show(modal = true) {
209
+ let me = this;
210
+ await Neo.timeout(20);
211
+
212
+ Neo.main.addon.Dialog[modal ? 'showModal': 'show']({
213
+ id: me.id,
214
+ appName: me.appName
215
+ });
216
+ }
217
+ }
218
+
219
+ Neo.applyClassConfig(Dialog);
220
+
221
+ export default Dialog;
@@ -48,8 +48,8 @@ class Toolbar extends Base {
48
48
  */
49
49
  afterSetTitle(value, oldValue) {
50
50
  this.down({flag: 'title-label'})?.set({
51
- removeDom: !value,
52
- text : value
51
+ hidden: !value,
52
+ text : value
53
53
  })
54
54
  }
55
55
 
@@ -62,11 +62,11 @@ class Toolbar extends Base {
62
62
  items = me.items || [];
63
63
 
64
64
  items.push({
65
- ntype : 'label',
66
- cls : ['neo-panel-header-text', 'neo-label'],
67
- flag : 'title-label',
68
- removeDom: !me.title,
69
- text : me.title
65
+ ntype : 'label',
66
+ cls : ['neo-panel-header-text', 'neo-label'],
67
+ flag : 'title-label',
68
+ hidden: !me.title,
69
+ text : me.title
70
70
  });
71
71
 
72
72
  if (me.actions) {
@@ -193,17 +193,23 @@ class Select extends Picker {
193
193
  let me = this,
194
194
  filters;
195
195
 
196
- if (value && me.useFilter) {
197
- filters = value.filters || [];
196
+ if (value) {
197
+ if (me.useFilter) {
198
+ filters = value.filters || [];
199
+
200
+ filters.push({
201
+ includeEmptyValues: true,
202
+ operator : me.filterOperator,
203
+ property : me.displayField,
204
+ value : value.get(me.value)?.[me.displayField] || me.value
205
+ });
198
206
 
199
- filters.push({
200
- includeEmptyValues: true,
201
- operator : me.filterOperator,
202
- property : me.displayField,
203
- value : value.get(me.value)?.[me.displayField] || me.value
204
- });
207
+ value.filters = filters
208
+ }
205
209
 
206
- value.filters = filters
210
+ if (me.list) {
211
+ me.list.store = value
212
+ }
207
213
  }
208
214
  }
209
215
 
@@ -0,0 +1,68 @@
1
+ import Base from '../../core/Base.mjs';
2
+ import DomAccess from '../DomAccess.mjs'
3
+ /**
4
+ * Addon for component.Dialog
5
+ * @class Neo.main.addon.Dialog
6
+ * @extends Neo.core.Base
7
+ * @singleton
8
+ */
9
+ class Dialog extends Base {
10
+ static config = {
11
+ /**
12
+ * @member {String} className='Neo.main.addon.Dialog'
13
+ * @protected
14
+ */
15
+ className: 'Neo.main.addon.Dialog',
16
+ /**
17
+ * Remote method access for other workers
18
+ * @member {Object} remote={app: [//...]}
19
+ * @protected
20
+ */
21
+ remote: {
22
+ app: [
23
+ 'close',
24
+ 'show',
25
+ 'showModal'
26
+ ]
27
+ },
28
+ /**
29
+ * @member {Boolean} singleton=true
30
+ * @protected
31
+ */
32
+ singleton: true
33
+ }
34
+
35
+ /**
36
+ * @param {Object} data
37
+ * @param {String} data.id
38
+ * @returns {Boolean}
39
+ */
40
+ close(data) {
41
+ DomAccess.getElement(data.id).close()
42
+ return true;
43
+ }
44
+
45
+ /**
46
+ * @param {Object} data
47
+ * @param {String} data.id
48
+ * @returns {Boolean}
49
+ */
50
+ show(data) {
51
+ DomAccess.getElement(data.id).show()
52
+ return true;
53
+ }
54
+
55
+ /**
56
+ * @param {Object} data
57
+ * @param {String} data.id
58
+ * @returns {Boolean}
59
+ */
60
+ showModal(data) {
61
+ DomAccess.getElement(data.id).showModal()
62
+ return true;
63
+ }
64
+ }
65
+
66
+ let instance = Neo.applyClassConfig(Dialog);
67
+
68
+ export default instance;
@@ -1,93 +0,0 @@
1
- import Button from '../../src/button/Base.mjs';
2
- import Container from '../../src/container/Base.mjs';
3
-
4
- /**
5
- * @class Neo.examples.container.MainContainer
6
- * @extends Neo.container.Base
7
- */
8
- class MainContainer extends Container {
9
- static config = {
10
- className: 'Neo.examples.container.MainContainer',
11
- autoMount: true,
12
- layout : 'vbox',
13
-
14
- items: [
15
- {
16
- ntype : 'button',
17
- iconCls: 'fa fa-home',
18
- text : 'Hello',
19
- width : 200
20
- },
21
- {
22
- ntype : 'button',
23
- iconCls: 'fa fa-user',
24
- text : 'World'
25
- },
26
- {
27
- ntype : 'container',
28
- layout: {
29
- ntype: 'hbox',
30
- align: 'stretch'
31
- },
32
- items: [
33
- {
34
- ntype : 'button',
35
- iconCls: 'fa fa-home',
36
- text : 'Hello2',
37
- width : 200,
38
-
39
- style: {
40
- color: 'red'
41
- }
42
- },
43
- {
44
- ntype : 'button',
45
- flex : 1,
46
- iconCls : 'fa fa-user',
47
- iconColor: 'red',
48
- text : 'World2'
49
- },
50
- ]
51
- },
52
- {
53
- ntype : 'container',
54
-
55
- layout: {
56
- ntype: 'vbox',
57
- align: 'start'
58
- },
59
-
60
- style: {
61
- marginTop: '30px'
62
- },
63
-
64
- items: [
65
- {
66
- ntype : 'button',
67
- iconCls : 'fa fa-home',
68
- iconPosition: 'right',
69
- text : 'Right'
70
- },
71
- {
72
- ntype : 'button',
73
- flex : 1,
74
- iconCls : 'fa fa-user',
75
- iconPosition: 'top',
76
- text : 'Top'
77
- },
78
- {
79
- ntype : 'button',
80
- flex : 1,
81
- iconCls : 'fa fa-play-circle',
82
- iconPosition: 'bottom',
83
- text : 'Bottom'
84
- }
85
- ]
86
- }
87
- ]
88
- }
89
- }
90
-
91
- Neo.applyClassConfig(MainContainer);
92
-
93
- export default MainContainer;