neo.mjs 5.0.2 → 5.0.3

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.
@@ -0,0 +1,154 @@
1
+ # neo.mjs Coding Guidelines
2
+
3
+ Inside the neo repo the following coding guidelines are mandatory.
4
+ They ensure a high code quality and consistency.
5
+ We strongly recommend to also stick to them when creating your own workspaces and apps via `npx neo-app`.
6
+
7
+ ## Content
8
+ 1. Import statements
9
+ 2. Anatomy of a neo class / JS module
10
+
11
+
12
+ ## 1. import statements
13
+ ```javascript
14
+ import Container from '../../../node_modules/neo.mjs/src/container/Base.mjs';
15
+ import EarthquakesTable from './earthquakes/Table.mjs';
16
+ import GoogleMapsComponent from '../../../node_modules/neo.mjs/src/component/wrapper/GoogleMaps.mjs';
17
+ import Toast from '../../../node_modules/neo.mjs/src/component/Toast.mjs';
18
+ import ViewController from './MainViewController.mjs';
19
+ import ViewModel from './MainViewModel.mjs';
20
+ ```
21
+ * Use block formatting. This makes it easy to spot invalid paths.
22
+ * Use single quotes.
23
+ * Imports get sorted by module name. There are ongoing discussions if we should switch to a path based sorting instead.
24
+ * Feel free to rename module import names as needed. Neo classes are using the default export.
25
+
26
+ ## 2. Anatomy of a neo class / JS module
27
+ ```javascript
28
+ import Component from '../component/Base.mjs';
29
+ import NeoArray from '../util/Array.mjs';
30
+
31
+ /**
32
+ * @class Neo.button.Base
33
+ * @extends Neo.component.Base
34
+ */
35
+ class Base extends Component {
36
+ /**
37
+ * Valid values for badgePosition
38
+ * @member {String[]} badgePositions=['bottom-left','bottom-right','top-left','top-right']
39
+ * @protected
40
+ * @static
41
+ */
42
+ static badgePositions = ['bottom-left', 'bottom-right', 'top-left', 'top-right']
43
+ /**
44
+ * Valid values for iconPosition
45
+ * @member {String[]} iconPositions=['top','right','bottom','left']
46
+ * @protected
47
+ * @static
48
+ */
49
+ static iconPositions = ['top', 'right', 'bottom', 'left']
50
+
51
+ static config = {
52
+ /**
53
+ * @member {String} className='Neo.button.Base'
54
+ * @protected
55
+ */
56
+ className: 'Neo.button.Base',
57
+ /**
58
+ * @member {String} ntype='button'
59
+ * @protected
60
+ */
61
+ ntype: 'button',
62
+ /**
63
+ * Change the browser hash value on click
64
+ * @member {String|null} route_=null
65
+ */
66
+ route_: null,
67
+ /**
68
+ * True adds an expanding circle on click
69
+ * @member {Boolean} useRippleEffect_=true
70
+ */
71
+ useRippleEffect_: true,
72
+ /**
73
+ * @member {Object} _vdom
74
+ */
75
+ _vdom:
76
+ {tag: 'button', type: 'button', cn: [
77
+ {tag: 'span', cls: ['neo-button-glyph']},
78
+ {tag: 'span', cls: ['neo-button-text']},
79
+ {cls: ['neo-button-badge']},
80
+ {cls: ['neo-button-ripple-wrapper'], cn: [
81
+ {cls: ['neo-button-ripple']}
82
+ ]}
83
+ ]}
84
+ }
85
+
86
+ /**
87
+ * Time in ms for the ripple effect when clicking on the button.
88
+ * Only active if useRippleEffect is set to true.
89
+ * @member {Number} rippleEffectDuration=400
90
+ */
91
+ rippleEffectDuration = 400
92
+ /**
93
+ * Internal flag to store the last setTimeout() id for ripple effect remove node callbacks
94
+ * @member {Number} #rippleTimeoutId=null
95
+ * @private
96
+ */
97
+ #rippleTimeoutId = null
98
+
99
+ /**
100
+ * Triggered after the route config got changed
101
+ * @param {String} value
102
+ * @param {String} oldValue
103
+ * @protected
104
+ */
105
+ afterSetRoute(value, oldValue) {
106
+ let me = this;
107
+
108
+ value && me.addDomListeners({
109
+ click: me.changeRoute,
110
+ scope: me
111
+ });
112
+ }
113
+
114
+ /**
115
+ * Triggered before the iconPosition config gets changed
116
+ * @param {String} value
117
+ * @param {String} oldValue
118
+ * @protected
119
+ */
120
+ beforeSetIconPosition(value, oldValue) {
121
+ return this.beforeSetEnumValue(value, oldValue, 'iconPosition');
122
+ }
123
+
124
+ /**
125
+ * Convenience shortcut
126
+ * @returns {Object}
127
+ */
128
+ getIconNode() {
129
+ return this.getVdomRoot().cn[0];
130
+ }
131
+ }
132
+
133
+ Neo.applyClassConfig(Base);
134
+
135
+ export default Base;
136
+
137
+ ```
138
+ * Use JSDoc based comments for all top level items as well as top level configs
139
+ * Class content order:
140
+ - static configs (ordered chronologically)
141
+ - static config as the last item. This one does not need a comment, but is prefixed with an empty line.
142
+ - non-static class fields (ordered chronologically)
143
+ - construct() in case you are using it
144
+ - all other class methods are ordered chronologically
145
+ * Module order:
146
+ - Import statements formatted according to 1.
147
+ - empty line
148
+ - class definition
149
+ - empty line
150
+ - Neo.applyClassConfig(<ClassName>)
151
+ - empty line
152
+ - export statement
153
+ - empty line
154
+
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.0.2'
23
+ * @member {String} version='5.0.3'
24
24
  */
25
- version: '5.0.2'
25
+ version: '5.0.3'
26
26
  }
27
27
 
28
28
  /**
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "author" : "Torsten Dinkheller",
4
+ "authorImage" : "author_TorstenDinkheller.jpg",
5
+ "date" : "Jan 28, 2023",
6
+ "id" : 56,
7
+ "image" : "toast-tutorial-medium.jpg",
8
+ "name" : "Reusable Next Gen Toast — to Industry Standard",
9
+ "provider" : "Medium",
10
+ "publisher" : "ITNEXT",
11
+ "selectedInto": [],
12
+ "type" : "Blog Post",
13
+ "url" : "https://itnext.io/reusable-next-gen-toast-to-industry-standard-502d2950701f?source=friends_link&sk=f74ba5b5161986d9d8dec6e91ba11a5b"
14
+ },
2
15
  {
3
16
  "author" : "Tobias Uhlig",
4
17
  "authorImage" : "author_TobiasUhlig.jpeg",
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.0.2'
23
+ * @member {String} version='5.0.3'
24
24
  */
25
- version: '5.0.2'
25
+ version: '5.0.3'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -65,9 +65,10 @@
65
65
  }
66
66
 
67
67
  .website-header-buttons {
68
- position: absolute;
69
- right : 0;
70
- top : 0;
68
+ background-color: transparent;
69
+ position : absolute;
70
+ right : 0;
71
+ top : 0;
71
72
  }
72
73
 
73
74
  @media (max-height: 400px), (max-width: 600px) {
@@ -132,4 +133,4 @@
132
133
  margin-right: 5px;
133
134
  }
134
135
  }
135
- }
136
+ }
@@ -237,12 +237,12 @@ const DefaultConfig = {
237
237
  useVdomWorker: true,
238
238
  /**
239
239
  * buildScripts/injectPackageVersion.mjs will update this value
240
- * @default '5.0.2'
240
+ * @default '5.0.3'
241
241
  * @memberOf! module:Neo
242
242
  * @name config.version
243
243
  * @type String
244
244
  */
245
- version: '5.0.2'
245
+ version: '5.0.3'
246
246
  };
247
247
 
248
248
  Object.assign(DefaultConfig, {
package/src/Neo.mjs CHANGED
@@ -74,26 +74,24 @@ Neo = globalThis.Neo = Object.assign({
74
74
  let cfg = ctor.config || {},
75
75
  mixins;
76
76
 
77
- if (cfg) {
78
- Object.entries(cfg).forEach(([key, value]) => {
79
- if (key.slice(-1) === '_') {
80
- delete cfg[key];
81
- key = key.slice(0, -1);
82
- cfg[key] = value;
83
- autoGenerateGetSet(element, key);
84
- }
77
+ Object.entries(cfg).forEach(([key, value]) => {
78
+ if (key.slice(-1) === '_') {
79
+ delete cfg[key];
80
+ key = key.slice(0, -1);
81
+ cfg[key] = value;
82
+ autoGenerateGetSet(element, key);
83
+ }
85
84
 
86
- // only apply properties which have no setters inside the prototype chain
87
- // those will get applied on create (Neo.core.Base -> initConfig)
88
- else if (!Neo.hasPropertySetter(element, key)) {
89
- Object.defineProperty(element, key, {
90
- enumerable: true,
91
- value,
92
- writable : true
93
- });
94
- }
95
- });
96
- }
85
+ // only apply properties which have no setters inside the prototype chain
86
+ // those will get applied on create (Neo.core.Base -> initConfig)
87
+ else if (!Neo.hasPropertySetter(element, key)) {
88
+ Object.defineProperty(element, key, {
89
+ enumerable: true,
90
+ value,
91
+ writable : true
92
+ });
93
+ }
94
+ });
97
95
 
98
96
  if (Object.hasOwn(cfg, 'ntype')) {
99
97
  if (Object.hasOwn(ntypeMap, cfg.ntype)) {