neo.mjs 6.3.11 → 6.4.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.
Files changed (38) hide show
  1. package/apps/ServiceWorker.mjs +2 -2
  2. package/examples/ConfigurationViewport.mjs +21 -9
  3. package/examples/ServiceWorker.mjs +2 -2
  4. package/examples/container/dialog/MainContainerController.mjs +20 -16
  5. package/examples/dialog/DemoDialog.mjs +24 -3
  6. package/examples/form/field/select/MainContainer.mjs +28 -6
  7. package/package.json +1 -1
  8. package/resources/scss/src/component/Base.scss +26 -0
  9. package/resources/scss/src/form/field/Picker.scss +0 -3
  10. package/resources/scss/src/menu/List.scss +4 -8
  11. package/resources/scss/theme-dark/menu/List.scss +2 -1
  12. package/resources/scss/theme-light/menu/List.scss +1 -0
  13. package/src/DefaultConfig.mjs +2 -2
  14. package/src/button/Base.mjs +41 -6
  15. package/src/component/Base.mjs +236 -44
  16. package/src/container/Dialog.mjs +3 -3
  17. package/src/core/Base.mjs +20 -0
  18. package/src/form/Container.mjs +2 -0
  19. package/src/form/field/Picker.mjs +30 -47
  20. package/src/form/field/Time.mjs +8 -8
  21. package/src/form/field/trigger/Base.mjs +1 -1
  22. package/src/form/field/trigger/CopyToClipboard.mjs +5 -1
  23. package/src/grid/View.mjs +5 -2
  24. package/src/grid/header/Button.mjs +10 -10
  25. package/src/list/Base.mjs +17 -14
  26. package/src/list/plugin/Animate.mjs +3 -3
  27. package/src/main/DomAccess.mjs +272 -28
  28. package/src/menu/List.mjs +35 -102
  29. package/src/table/Container.mjs +2 -2
  30. package/src/table/header/Button.mjs +21 -23
  31. package/src/tree/Accordion.mjs +1 -1
  32. package/src/util/Array.mjs +4 -18
  33. package/src/util/Css.mjs +6 -8
  34. package/src/util/HashHistory.mjs +10 -3
  35. package/src/util/Rectangle.mjs +444 -7
  36. package/test/siesta/siesta-node.js +2 -1
  37. package/test/siesta/siesta.js +1 -0
  38. package/test/siesta/tests/Rectangle.mjs +409 -0
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='6.3.11'
23
+ * @member {String} version='6.4.0'
24
24
  */
25
- version: '6.3.11'
25
+ version: '6.4.0'
26
26
  }
27
27
 
28
28
  /**
@@ -56,9 +56,14 @@ class ConfigurationViewport extends Viewport {
56
56
  *
57
57
  */
58
58
  onConstructed() {
59
- let me = this,
59
+ let me = this,
60
+ style = me.exampleContainerConfig?.style,
60
61
  theme;
61
62
 
63
+ if (style) {
64
+ delete me.exampleContainerConfig.style;
65
+ }
66
+
62
67
  me.exampleComponent = me.createExampleComponent();
63
68
  me.configurationComponents = me.createConfigurationComponents() || [];
64
69
 
@@ -69,7 +74,7 @@ class ConfigurationViewport extends Viewport {
69
74
  items : [me.exampleComponent],
70
75
  flex : me.exampleComponentFlex,
71
76
  layout: 'base',
72
- style : {overflow: 'auto', padding: '20px'},
77
+ style : {overflow: 'auto', padding: '20px', ...style},
73
78
  ...me.exampleContainerConfig
74
79
  }, {
75
80
  module: Panel,
@@ -172,22 +177,29 @@ class ConfigurationViewport extends Viewport {
172
177
  onSwitchTheme(target) {
173
178
  let me = this,
174
179
  button = Neo.getComponent(me.id + (target !== 'cmp' ? '__' : '_cmp_') + 'switchThemeButton'),
175
- cls = target === 'cmp' ? me.exampleComponent.cls : me.cls;
180
+ newTheme, oldTheme;
176
181
 
177
182
  if (button.text === 'Theme Light') {
183
+ newTheme = 'neo-theme-light';
184
+ oldTheme = 'neo-theme-dark';
185
+
178
186
  button.text = 'Theme Dark';
179
- NeoArray.remove(cls, 'neo-theme-dark');
180
- NeoArray.add(cls, 'neo-theme-light');
181
187
  } else {
188
+ newTheme = 'neo-theme-dark';
189
+ oldTheme = 'neo-theme-light';
190
+
182
191
  button.text = 'Theme Light';
183
- NeoArray.remove(cls, 'neo-theme-light');
184
- NeoArray.add(cls, 'neo-theme-dark');
185
192
  }
186
193
 
187
194
  if (target === 'cmp') {
188
- me.exampleComponent.cls = cls;
195
+ me.exampleComponent.theme = newTheme;
189
196
  } else {
190
- me.cls = cls;
197
+ Neo.applyDeltas(me.appName, {
198
+ cls: {
199
+ add : [newTheme],
200
+ remove: [oldTheme]
201
+ }
202
+ })
191
203
  }
192
204
  }
193
205
  }
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='6.3.11'
23
+ * @member {String} version='6.4.0'
24
24
  */
25
- version: '6.3.11'
25
+ version: '6.4.0'
26
26
  }
27
27
 
28
28
  /**
@@ -1,4 +1,5 @@
1
- import Component from '../../../src/controller/Component.mjs';
1
+ import Component from '../../../src/controller/Component.mjs';
2
+ import SelectField from '../../../src/form/field/Select.mjs';
2
3
 
3
4
  /**
4
5
  * @class Neo.examples.container.dialog.MainContainerController
@@ -13,22 +14,14 @@ class MainContainerController extends Component {
13
14
  className: 'Neo.examples.container.dialog.MainContainerController'
14
15
  }
15
16
 
16
- dialog = null;
17
- title = 'example dialog';
18
- height = 300;
19
- width = 500;
17
+ dialog = null
18
+ title = 'example dialog'
19
+ height = 300
20
+ width = 500
20
21
 
21
22
  /**
22
- *
23
- * @param {*} config
24
- */
25
- construct(config) {
26
- super.construct(config);
27
- }
28
-
29
- /**
30
- *
31
- * @param {Object} data
23
+ *
24
+ * @param {Object} data
32
25
  */
33
26
  async onButtonClick(data) {
34
27
  if (!this.dialog) {
@@ -42,7 +35,7 @@ class MainContainerController extends Component {
42
35
  height: this.height,
43
36
  width: this.width,
44
37
  iconCls: ['fa', 'fa-home'],
45
-
38
+
46
39
  headerConfig: {
47
40
  items: [{
48
41
  ntype: 'button',
@@ -54,9 +47,20 @@ class MainContainerController extends Component {
54
47
  items: [{
55
48
  ntype: 'container',
56
49
  html: 'text'
50
+ }, {
51
+ module : SelectField,
52
+ labelText: 'Select',
53
+
54
+ store: {
55
+ data: [{
56
+ id : 0,
57
+ name: 'Option 1'
58
+ }]
59
+ }
57
60
  }]
58
61
  })
59
62
  }
63
+
60
64
  this.dialog.show();
61
65
 
62
66
  console.log(data, this);
@@ -1,4 +1,5 @@
1
- import Dialog from '../../src/dialog/Base.mjs';
1
+ import Dialog from '../../src/dialog/Base.mjs';
2
+ import SelectField from '../../src/form/field/Select.mjs';
2
3
 
3
4
  /**
4
5
  * @class Neo.examples.dialog.DemoDialog
@@ -7,12 +8,32 @@ import Dialog from '../../src/dialog/Base.mjs';
7
8
  class DemoDialog extends Dialog {
8
9
  static config = {
9
10
  className: 'Neo.examples.dialog.DemoWindow',
11
+ modal : true,
10
12
  title : 'My Dialog',
11
13
 
12
14
  wrapperStyle: {
13
- height: '40%',
14
15
  width : '40%'
15
- }
16
+ },
17
+
18
+ items : [{
19
+ module : SelectField,
20
+ labelText: 'Select',
21
+
22
+ store: {
23
+ data: (() => {
24
+ const result = [];
25
+
26
+ for (let i = 0; i < 20; i++) {
27
+ result.push({
28
+ id : i,
29
+ name : `Option ${i + 1}`
30
+ });
31
+ }
32
+
33
+ return result;
34
+ })()
35
+ }
36
+ }]
16
37
  }
17
38
  }
18
39
 
@@ -12,10 +12,11 @@ import TextField from '../../../../src/form/field/Text.mjs';
12
12
  */
13
13
  class MainContainer extends ConfigurationViewport {
14
14
  static config = {
15
- className : 'Neo.examples.form.field.select.MainContainer',
16
- autoMount : true,
17
- configItemLabelWidth: 160,
18
- layout : {ntype: 'hbox', align: 'stretch'}
15
+ className : 'Neo.examples.form.field.select.MainContainer',
16
+ autoMount : true,
17
+ configItemLabelWidth : 160,
18
+ exampleContainerConfig: {style: {position: 'relative'}},
19
+ layout : {ntype: 'hbox', align: 'stretch'}
19
20
  }
20
21
 
21
22
  createConfigurationComponents() {
@@ -117,7 +118,7 @@ class MainContainer extends ConfigurationViewport {
117
118
  listeners: {change: me.onConfigChange.bind(me, 'typeAhead')},
118
119
  style : {marginTop: '10px'}
119
120
  }, {
120
- module : NumberField,
121
+ module : TextField,
121
122
  labelText: 'width',
122
123
  listeners: {change: me.onConfigChange.bind(me, 'width')},
123
124
  maxValue : 300,
@@ -125,6 +126,24 @@ class MainContainer extends ConfigurationViewport {
125
126
  stepSize : 5,
126
127
  style : {marginTop: '10px'},
127
128
  value : me.exampleComponent.width
129
+ }, {
130
+ module : CheckBox,
131
+ checked : false,
132
+ labelText: 'At end',
133
+ style : {marginTop: '10px'},
134
+
135
+ listeners: {change: ({ value }) => {
136
+ const
137
+ { exampleComponent } = this,
138
+ { style } = exampleComponent;
139
+
140
+ Object.assign(style, {
141
+ bottom : value ? '1em' : '',
142
+ position : value ? 'absolute' : ''
143
+ });
144
+
145
+ exampleComponent.style = style;
146
+ }}
128
147
  }];
129
148
  }
130
149
 
@@ -137,7 +156,10 @@ class MainContainer extends ConfigurationViewport {
137
156
  store : MainStore,
138
157
  value : 'Arizona', // or 'AZ'
139
158
  valueField : 'abbreviation',
140
- width : 200
159
+ width : '50%',
160
+ pickerConfig : {
161
+ minHeight : '6em'
162
+ }
141
163
  })
142
164
  }
143
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "6.3.11",
3
+ "version": "6.4.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -0,0 +1,26 @@
1
+ .neo-floating {
2
+ top : -10000px;
3
+ left : -10000px;
4
+ position : fixed;
5
+ z-index : 1000;
6
+ }
7
+
8
+ // Shadow at the top
9
+ .neo-aligned-top {
10
+ box-shadow : 0px -2px 10px rgba(0, 0, 0, 0.3);
11
+ }
12
+
13
+ // Shadow at the bottom
14
+ .neo-aligned-bottom {
15
+ box-shadow : 0px 2px 10px rgba(0, 0, 0, 0.3);
16
+ }
17
+
18
+ // Shadow at the left
19
+ .neo-aligned-left {
20
+ box-shadow : -2px 0px 10px rgba(0, 0, 0, 0.3);
21
+ }
22
+
23
+ // Shadow at the right
24
+ .neo-aligned-right {
25
+ box-shadow : 2px 0px 10px rgba(0, 0, 0, 0.3);
26
+ }
@@ -13,9 +13,6 @@
13
13
  .neo-picker-container {
14
14
  background-color: var(--pickerfield-container-background-color);
15
15
  border : var(--pickerfield-container-border);
16
- box-shadow : var(--pickerfield-container-box-shadow);
17
- position : absolute;
18
- z-index : 200;
19
16
 
20
17
  &:focus {
21
18
  outline: none;
@@ -1,7 +1,8 @@
1
1
  .neo-menu-list {
2
- border : 1px solid var(--menu-list-border-color);
3
- overflow-y : auto;
4
- width : fit-content;
2
+ background-color: var(--menu-list-background-color);
3
+ border : 1px solid var(--menu-list-border-color);
4
+ overflow-y : auto;
5
+ width : fit-content;
5
6
 
6
7
  .neo-list-item {
7
8
  align-items : center;
@@ -61,9 +62,4 @@
61
62
  }
62
63
  }
63
64
  }
64
-
65
- &.neo-floating {
66
- box-shadow: var(--menu-list-box-shadow);
67
- position : absolute;
68
- }
69
65
  }
@@ -1,5 +1,6 @@
1
1
  :root .neo-theme-dark { // .neo-menu-list
2
- --menu-list-border-color : #3c3f41;
2
+ --menu-list-background-color : #3c3f41;
3
+ --menu-list-border-color : #2b2b2b;
3
4
  --menu-list-box-shadow : 0 5px 10px rgba(0,0,0,.4);
4
5
  --menu-list-item-background-color : inherit;
5
6
  --menu-list-item-background-color-disabled: inherit;
@@ -1,4 +1,5 @@
1
1
  :root .neo-theme-light { // .neo-menu-list
2
+ --menu-list-background-color : #fff;
2
3
  --menu-list-border-color : #1c60a0;
3
4
  --menu-list-box-shadow : 0 5px 10px rgba(0,0,0,.4);
4
5
  --menu-list-item-background-color : inherit;
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '6.3.11'
239
+ * @default '6.4.0'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '6.3.11'
244
+ version: '6.4.0'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
@@ -79,7 +79,11 @@ class Base extends Component {
79
79
  */
80
80
  iconPosition_: 'left',
81
81
  /**
82
- * @member {Object[]|null} menu_=null
82
+ * An array representing the configuration of the menu items.
83
+ *
84
+ * Or a configuration object which adds custom configuration to the menu to be
85
+ * created and includes an `items` property to define the menu items.
86
+ * @member {Object|Object[]|null} menu_=null
83
87
  */
84
88
  menu_: null,
85
89
  /**
@@ -245,24 +249,32 @@ class Base extends Component {
245
249
 
246
250
  /**
247
251
  * Triggered after the menu config got changed
248
- * @param {Object[]|null} value
249
- * @param {Object[]|null} oldValue
252
+ * @param {Object|Object[]|null} value
253
+ * @param {Object|Object[]|null} oldValue
250
254
  * @protected
251
255
  */
252
256
  afterSetMenu(value, oldValue) {
253
257
  if (value) {
254
258
  import('../menu/List.mjs').then(module => {
255
- let me = this;
259
+ let me = this,
260
+ isArray = Array.isArray(value),
261
+ items = isArray ? value : value.items,
262
+ menuConfig = isArray ? {} : value;
256
263
 
257
264
  me.menuList = Neo.create({
265
+ align : {
266
+ edgeAlign : 't0-b0',
267
+ target : me.id
268
+ },
269
+ ...menuConfig,
258
270
  module : module.default,
259
271
  appName : me.appName,
260
272
  displayField : 'text',
261
273
  floating : true,
262
274
  hidden : true,
263
- items : value,
275
+ items,
264
276
  parentComponent: me,
265
- style : {left: '-5000px', top: '-5000px'},
277
+ theme : me.theme,
266
278
  ...me.menuListConfig
267
279
  })
268
280
  })
@@ -282,6 +294,20 @@ class Base extends Component {
282
294
  this.cls = cls;
283
295
  }
284
296
 
297
+ /**
298
+ * Triggered after the theme config got changed
299
+ * @param {String|null} value
300
+ * @param {String|null} oldValue
301
+ * @protected
302
+ */
303
+ afterSetTheme(value, oldValue) {
304
+ super.afterSetTheme(value, oldValue);
305
+
306
+ if (this.menuList) {
307
+ this.menuList.theme = value
308
+ }
309
+ }
310
+
285
311
  /**
286
312
  * Triggered after the text config got changed
287
313
  * @param {String|null} value
@@ -420,6 +446,15 @@ class Base extends Component {
420
446
  }
421
447
  }
422
448
 
449
+ /**
450
+ * @param {Boolean} updateParentVdom
451
+ * @param {Boolean} silent
452
+ */
453
+ destroy(updateParentVdom=false, silent=false) {
454
+ this.menuList && this.menuList.destroy(true, false);
455
+ super.destroy(updateParentVdom, silent);
456
+ }
457
+
423
458
  /**
424
459
  * Convenience shortcut
425
460
  * @returns {Object}