neo.mjs 10.0.0-alpha.4 → 10.0.0-beta.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.
- package/ServiceWorker.mjs +2 -2
- package/apps/portal/index.html +1 -1
- package/apps/portal/resources/data/examples_devmode.json +26 -27
- package/apps/portal/resources/data/examples_dist_dev.json +26 -27
- package/apps/portal/resources/data/examples_dist_esm.json +26 -27
- package/apps/portal/resources/data/examples_dist_prod.json +27 -28
- package/apps/portal/view/blog/List.mjs +1 -1
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/portal/view/learn/ContentComponent.mjs +102 -111
- package/buildScripts/buildThemes.mjs +1 -1
- package/examples/grid/animatedRowSorting/Viewport.mjs +4 -4
- package/examples/grid/bigData/ControlsContainer.mjs +3 -3
- package/examples/grid/bigData/GridContainer.mjs +8 -8
- package/examples/grid/cellEditing/MainContainer.mjs +5 -5
- package/examples/grid/container/MainContainer.mjs +4 -4
- package/examples/grid/nestedRecordFields/Viewport.mjs +5 -5
- package/examples/table/cellEditing/MainContainer.mjs +1 -1
- package/examples/table/container/MainContainer.mjs +3 -3
- package/examples/table/nestedRecordFields/Viewport.mjs +6 -6
- package/examples/tableFiltering/MainContainer.mjs +1 -1
- package/examples/tablePerformance/MainContainer.mjs +1 -1
- package/examples/tablePerformance/MainContainer2.mjs +1 -1
- package/examples/tablePerformance/MainContainer3.mjs +2 -2
- package/examples/tableStore/MainContainer.mjs +2 -2
- package/learn/UsingTheseTopics.md +2 -2
- package/learn/benefits/ConfigSystem.md +2 -2
- package/learn/benefits/FormsEngine.md +14 -14
- package/learn/benefits/MultiWindow.md +2 -2
- package/learn/benefits/OffTheMainThread.md +2 -2
- package/learn/benefits/Speed.md +2 -2
- package/learn/gettingstarted/ComponentModels.md +4 -4
- package/learn/gettingstarted/Config.md +6 -6
- package/learn/gettingstarted/DescribingTheUI.md +4 -4
- package/learn/gettingstarted/Events.md +6 -6
- package/learn/gettingstarted/Extending.md +4 -4
- package/learn/gettingstarted/References.md +6 -6
- package/learn/gettingstarted/Workspaces.md +6 -6
- package/learn/guides/ApplicationBootstrap.md +40 -42
- package/learn/guides/ComponentsAndContainers.md +12 -12
- package/learn/guides/CustomComponents.md +2 -2
- package/learn/guides/MainThreadAddonIntro.md +2 -2
- package/learn/guides/PortalApp.md +2 -2
- package/learn/guides/StateProviders.md +12 -12
- package/learn/guides/events/CustomEvents.md +16 -16
- package/learn/guides/events/DomEvents.md +12 -12
- package/learn/javascript/ClassFeatures.md +3 -2
- package/learn/javascript/Classes.md +8 -8
- package/learn/javascript/NewNode.md +4 -4
- package/learn/javascript/Overrides.md +8 -8
- package/learn/javascript/Super.md +10 -8
- package/learn/tutorials/Earthquakes.md +54 -57
- package/learn/tutorials/TodoList.md +4 -4
- package/package.json +1 -1
- package/resources/scss/src/apps/portal/learn/ContentComponent.scss +12 -0
- package/resources/scss/src/grid/{View.scss → Body.scss} +2 -2
- package/resources/scss/src/grid/VerticalScrollbar.scss +1 -1
- package/resources/scss/src/grid/plugin/AnimateRows.scss +1 -1
- package/resources/scss/src/grid/plugin/CellEditing.scss +1 -1
- package/resources/scss/src/table/{View.scss → Body.scss} +1 -1
- package/resources/scss/src/table/plugin/CellEditing.scss +1 -1
- package/resources/scss/theme-dark/grid/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-dark/table/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-light/grid/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-light/table/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-neo-light/Global.scss +1 -2
- package/resources/scss/theme-neo-light/grid/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-neo-light/table/{View.scss → Body.scss} +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/core/Base.mjs +59 -12
- package/src/core/Util.mjs +14 -2
- package/src/draggable/grid/header/toolbar/SortZone.mjs +21 -21
- package/src/draggable/table/header/toolbar/SortZone.mjs +1 -1
- package/src/grid/{View.mjs → Body.mjs} +19 -20
- package/src/grid/Container.mjs +58 -58
- package/src/grid/ScrollManager.mjs +56 -56
- package/src/grid/VerticalScrollbar.mjs +2 -2
- package/src/grid/_export.mjs +2 -2
- package/src/grid/column/AnimatedChange.mjs +5 -5
- package/src/grid/column/Base.mjs +1 -1
- package/src/grid/column/Component.mjs +6 -6
- package/src/grid/header/Toolbar.mjs +9 -9
- package/src/grid/plugin/AnimateRows.mjs +1 -2
- package/src/main/addon/AmCharts.mjs +8 -11
- package/src/main/addon/Base.mjs +150 -42
- package/src/main/addon/GoogleMaps.mjs +9 -16
- package/src/main/addon/HighlightJS.mjs +2 -13
- package/src/main/addon/IntersectionObserver.mjs +21 -21
- package/src/main/addon/MonacoEditor.mjs +1 -6
- package/src/table/{View.mjs → Body.mjs} +19 -20
- package/src/table/Container.mjs +43 -43
- package/src/table/_export.mjs +2 -2
- package/src/table/plugin/CellEditing.mjs +19 -19
- package/src/util/Style.mjs +2 -6
- package/src/vdom/Helper.mjs +10 -13
- package/src/worker/App.mjs +6 -18
- package/src/worker/Base.mjs +1 -1
- package/src/worker/Manager.mjs +4 -8
- package/src/worker/mixin/RemoteMethodAccess.mjs +1 -1
@@ -2,7 +2,7 @@ Neo.mjs classes are standard JavaScript classes. Every source file
|
|
2
2
|
you write will be a class definition, extending some Neo.mjs
|
3
3
|
class.
|
4
4
|
|
5
|
-
|
5
|
+
```javascript readonly
|
6
6
|
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
7
7
|
|
8
8
|
class Mammal extends Base {
|
@@ -15,7 +15,7 @@ const myMammal = Neo.create(Mammal);
|
|
15
15
|
|
16
16
|
Neo.setupClass(Mammal); // Where Neo.mjs initializes the class config.
|
17
17
|
export default Mammal; // Makes the class available elsewhere.
|
18
|
-
|
18
|
+
```
|
19
19
|
|
20
20
|
In the example above, we're extending the Neo.mjs base class. The static
|
21
21
|
config block is unique to Neo.mjs; it provides a way of defining special
|
@@ -29,7 +29,7 @@ and create instances as needed.
|
|
29
29
|
|
30
30
|
Let's add a `name` propery to the class.
|
31
31
|
|
32
|
-
|
32
|
+
```javascript readonly
|
33
33
|
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
34
34
|
|
35
35
|
class Mammal extends Base {
|
@@ -47,7 +47,7 @@ console.log(myMammal.name); // Logs "Herbert"
|
|
47
47
|
Neo.setupClass(Mammal);
|
48
48
|
|
49
49
|
export default Mammal;
|
50
|
-
|
50
|
+
```
|
51
51
|
|
52
52
|
In Neo.mjs, instance properties are usually added in the `static config` block.
|
53
53
|
The `static config` block does two things:
|
@@ -61,19 +61,19 @@ anywhere in the class hierarchy.
|
|
61
61
|
Since our class defines a `name` property, we can specify that when creating
|
62
62
|
the instance, using the second argument to the `create` method.
|
63
63
|
|
64
|
-
|
64
|
+
```javascript readonly
|
65
65
|
const myMammal = Neo.create(Mammal, {
|
66
66
|
name: 'Creature'
|
67
67
|
});
|
68
68
|
console.log(myMammal.name); // Logs "Creature"
|
69
|
-
|
69
|
+
```
|
70
70
|
|
71
71
|
|
72
72
|
Since _you_ define those properties, you can
|
73
73
|
look for them in class methods and use them as needed.
|
74
74
|
Let's add a `speak()` method that uses the `name` property.
|
75
75
|
|
76
|
-
|
76
|
+
```javascript readonly
|
77
77
|
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
78
78
|
|
79
79
|
class Mammal extends Base {
|
@@ -96,7 +96,7 @@ myMammal.speak(); // Logs "Creature is grunting."
|
|
96
96
|
Neo.setupClass(Mammal);
|
97
97
|
|
98
98
|
export default Mammal;
|
99
|
-
|
99
|
+
```
|
100
100
|
|
101
101
|
|
102
102
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
```javascript readonly
|
2
2
|
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
3
3
|
|
4
4
|
class Mammal extends Base {
|
@@ -11,11 +11,11 @@ const myMammal = Neo.create(Mammal);
|
|
11
11
|
|
12
12
|
Mammal = Neo.setupClass(Mammal); // Where Neo.mjs initializes the class config.
|
13
13
|
export default Mammal; // Makes the class available elsewhere.
|
14
|
-
|
14
|
+
```
|
15
15
|
|
16
16
|
|
17
17
|
|
18
|
-
|
18
|
+
```javascript live-preview
|
19
19
|
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
20
20
|
|
21
21
|
class Mammal extends Base {
|
@@ -28,4 +28,4 @@ const myMammal = Neo.create(Mammal);
|
|
28
28
|
|
29
29
|
Mammal = Neo.setupClass(Mammal); // Where Neo.mjs initializes the class config.
|
30
30
|
export default Mammal; // Makes the class available elsewhere.
|
31
|
-
|
31
|
+
```
|
@@ -3,7 +3,7 @@ In Neo.mjs you sub-class and override methods in the usual way.
|
|
3
3
|
Here, we'll extend `Mammal` and override the `speak()` method.
|
4
4
|
(For brevity, we'll exclude `export` and `import` statements.)
|
5
5
|
|
6
|
-
|
6
|
+
```javascript readonly
|
7
7
|
class Mammal extends Base {
|
8
8
|
static config = {
|
9
9
|
className: 'Simple.example.Mammal',
|
@@ -15,9 +15,9 @@ class Mammal extends Base {
|
|
15
15
|
}
|
16
16
|
}
|
17
17
|
Neo.setupClass(Mammal);
|
18
|
-
|
18
|
+
```
|
19
19
|
|
20
|
-
|
20
|
+
```javascript readonly
|
21
21
|
class Human extends Mammal {
|
22
22
|
static config = {
|
23
23
|
className: 'Simple.example.Human',
|
@@ -33,12 +33,12 @@ const myMammal = Neo.create(Human, {
|
|
33
33
|
myMammal.speak(); // Logs "Hello! My name is Herbert. I am not married."
|
34
34
|
|
35
35
|
Neo.setupClass(Mammal);
|
36
|
-
|
36
|
+
```
|
37
37
|
|
38
38
|
Any class in the hierarchy is free to add new properties and methods. Let's add
|
39
39
|
a property and behavior (method) to the Human class.
|
40
40
|
|
41
|
-
|
41
|
+
```javascript readonly
|
42
42
|
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
43
43
|
|
44
44
|
class Mammal extends Base {
|
@@ -51,9 +51,9 @@ class Mammal extends Base {
|
|
51
51
|
console.log(`(${this.name} is grunting)`);
|
52
52
|
}
|
53
53
|
}
|
54
|
-
|
54
|
+
```
|
55
55
|
|
56
|
-
|
56
|
+
```javascript readonly
|
57
57
|
class Human extends Mammal {
|
58
58
|
static config = {
|
59
59
|
className: 'Simple.example.Human',
|
@@ -74,4 +74,4 @@ myPerson.speak(); // Logs "Hello! My name is Herbert. I am not married."
|
|
74
74
|
myPerson.yodel(); // Logs "Yodelay hee hoo!"
|
75
75
|
|
76
76
|
Neo.setupClass(Human);
|
77
|
-
|
77
|
+
```
|
@@ -1,6 +1,6 @@
|
|
1
1
|
To call a super-class method use the `super` keyword.
|
2
2
|
|
3
|
-
|
3
|
+
```javascript readonly
|
4
4
|
class Mammal extends Base {
|
5
5
|
static config = {
|
6
6
|
className: 'Simple.example.Mammal',
|
@@ -12,8 +12,9 @@ class Mammal extends Base {
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
Neo.setupClass(Mammal);
|
15
|
-
|
16
|
-
|
15
|
+
```
|
16
|
+
|
17
|
+
```javascript readonly
|
17
18
|
class Human extends Mammal {
|
18
19
|
static config = {
|
19
20
|
className: 'Simple.example.Human',
|
@@ -30,12 +31,12 @@ const myPerson = Neo.create(Human, {
|
|
30
31
|
myPerson.doSomething();
|
31
32
|
|
32
33
|
Neo.setupClass(Mammal);
|
33
|
-
|
34
|
+
```
|
34
35
|
|
35
36
|
Sometimes you aren't sure if a super class has a method. In that case use the
|
36
37
|
conditional chaining operator — `?.`
|
37
38
|
|
38
|
-
|
39
|
+
```javascript readonly
|
39
40
|
class Mammal extends Base {
|
40
41
|
static config = {
|
41
42
|
className: 'Simple.example.Mammal',
|
@@ -47,8 +48,9 @@ class Mammal extends Base {
|
|
47
48
|
}
|
48
49
|
}
|
49
50
|
Neo.setupClass(Mammal);
|
50
|
-
|
51
|
-
|
51
|
+
```
|
52
|
+
|
53
|
+
```javascript readonly
|
52
54
|
class Human extends Mammal {
|
53
55
|
static config = {
|
54
56
|
className: 'Simple.example.Human',
|
@@ -65,4 +67,4 @@ const myPerson = Neo.create(Human, {
|
|
65
67
|
myPerson.doSomething();
|
66
68
|
|
67
69
|
Neo.setupClass(Mammal);
|
68
|
-
|
70
|
+
```
|
@@ -157,18 +157,15 @@ After the script runs yous should see these files in the `app/earthquakes` direc
|
|
157
157
|
|
158
158
|
If you look in `neo-config.json` you should see this content. Note the `mainThreadAddons` block
|
159
159
|
— it reflects the add-ons you chose when you followed the instructions in the script.
|
160
|
-
|
160
|
+
```json
|
161
161
|
{
|
162
|
-
"appPath": "../../apps/earthquakes/app.mjs",
|
163
|
-
"basePath": "../../",
|
164
|
-
"environment": "development",
|
165
|
-
"mainPath": "../node_modules/neo.mjs/src/Main.mjs",
|
166
|
-
"mainThreadAddons": [
|
167
|
-
|
168
|
-
|
169
|
-
],
|
170
|
-
"workerBasePath": "../../node_modules/neo.mjs/src/worker/"
|
171
|
-
}</pre>
|
162
|
+
"appPath" : "../../apps/earthquakes/app.mjs",
|
163
|
+
"basePath" : "../../",
|
164
|
+
"environment" : "development",
|
165
|
+
"mainPath" : "../node_modules/neo.mjs/src/Main.mjs",
|
166
|
+
"mainThreadAddons": ["DragDrop", "Navigator", "Stylesheet"],
|
167
|
+
"workerBasePath" : "../../node_modules/neo.mjs/src/worker/"
|
168
|
+
}```
|
172
169
|
|
173
170
|
You're free to edit `neo-config.json` if you were to change your mind later about the theme or need for other add-ons.
|
174
171
|
|
@@ -187,7 +184,7 @@ later in the lab.
|
|
187
184
|
Use a code editor and look at `workspace/apps/earthquakes/src/view/MainView.mjs`. You'll see the
|
188
185
|
following class definition:
|
189
186
|
|
190
|
-
|
187
|
+
```javascript readonly
|
191
188
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
192
189
|
import Controller from './MainViewController.mjs';
|
193
190
|
import MainStateProvider from './MainStateProvider.mjs';
|
@@ -206,7 +203,7 @@ class MainView extends Base {
|
|
206
203
|
}
|
207
204
|
|
208
205
|
export default Neo.setupClass(MainView);
|
209
|
-
|
206
|
+
```
|
210
207
|
|
211
208
|
As you can see, `MainView extends Base`, and `Base` is a _container_ (`Neo.container.Base`).
|
212
209
|
A container is a component — it holds other components, specified in `items:[]`. There
|
@@ -223,7 +220,7 @@ that buttons have various configs, such as `text`, which is the button text, `ic
|
|
223
220
|
is typically a FontAwesome CSS class used to show an icon, and `handler`, which specifies
|
224
221
|
which method to run when the button is clicked. We'll use `text`.
|
225
222
|
|
226
|
-
|
223
|
+
```javascript readonly
|
227
224
|
|
228
225
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
229
226
|
import Button from '../../../node_modules/neo.mjs/src/button/Base.mjs';
|
@@ -247,7 +244,7 @@ class MainView extends Base {
|
|
247
244
|
}
|
248
245
|
|
249
246
|
export default Neo.setupClass(MainView);
|
250
|
-
|
247
|
+
```
|
251
248
|
|
252
249
|
|
253
250
|
When you run the app you'll see the single button.
|
@@ -271,12 +268,12 @@ for the classes you define.
|
|
271
268
|
|
272
269
|
Let's change the layout to arrange items vertically, with items aligned horizontally at the start.
|
273
270
|
|
274
|
-
|
271
|
+
```javascript readonly
|
275
272
|
layout: {
|
276
273
|
ntype: 'vbox',
|
277
274
|
align: 'start'
|
278
275
|
}
|
279
|
-
|
276
|
+
```
|
280
277
|
|
281
278
|
<img src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesSingleVoxStartButton.png" style="width:80%"/>
|
282
279
|
|
@@ -422,7 +419,7 @@ its methods. Let's try that out by adding a method.
|
|
422
419
|
|
423
420
|
Edit `apps/earthquakes/view/MainView.mjs` and add a method.
|
424
421
|
|
425
|
-
|
422
|
+
```javascript readonly
|
426
423
|
|
427
424
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
428
425
|
import Button from '../../../node_modules/neo.mjs/src/button/Base.mjs';
|
@@ -453,7 +450,7 @@ class MainView extends Base {
|
|
453
450
|
}
|
454
451
|
|
455
452
|
export default Neo.setupClass(MainView);
|
456
|
-
|
453
|
+
```
|
457
454
|
|
458
455
|
Save your changes.
|
459
456
|
|
@@ -494,7 +491,7 @@ At this point we have a application with minimal content. You also know how to d
|
|
494
491
|
|
495
492
|
Replace the button with a table by replacing `MainView.mjs` with the following content.
|
496
493
|
|
497
|
-
|
494
|
+
```javascript readonly
|
498
495
|
|
499
496
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
500
497
|
import Table from '../../../node_modules/neo.mjs/src/table/Container.mjs';
|
@@ -550,7 +547,7 @@ class MainView extends Base {
|
|
550
547
|
}
|
551
548
|
|
552
549
|
export default Neo.setupClass(MainView);
|
553
|
-
|
550
|
+
```
|
554
551
|
|
555
552
|
Save and refresh.
|
556
553
|
|
@@ -582,7 +579,7 @@ Let's review the code and see what it's doing.
|
|
582
579
|
A store is a collection of records. A record is described in the `model` and the model's `fields`.
|
583
580
|
Here's the config for the store.
|
584
581
|
|
585
|
-
|
582
|
+
```javascript readonly
|
586
583
|
{
|
587
584
|
module: Store,
|
588
585
|
model: {
|
@@ -599,10 +596,10 @@ Here's the config for the store.
|
|
599
596
|
responseRoot: "data",
|
600
597
|
autoLoad: true,
|
601
598
|
}
|
602
|
-
|
599
|
+
```
|
603
600
|
|
604
601
|
The feed looks like this.
|
605
|
-
|
602
|
+
```json readonly
|
606
603
|
{
|
607
604
|
"data": [{
|
608
605
|
"timestamp": "2024-09-29T16:45:14.000Z",
|
@@ -621,7 +618,7 @@ The feed looks like this.
|
|
621
618
|
}, ...
|
622
619
|
]
|
623
620
|
}
|
624
|
-
|
621
|
+
```
|
625
622
|
|
626
623
|
The store defines a `type` for the date field. There are a few pre-defined field types that convert
|
627
624
|
the value from the feed into what's stored in the store's record. The store specifies the URL for the
|
@@ -632,7 +629,7 @@ of items.
|
|
632
629
|
|
633
630
|
Tables have two key configs: `store` and `columns`. Here's the columns config:
|
634
631
|
|
635
|
-
|
632
|
+
```javascript readonly
|
636
633
|
columns: [{
|
637
634
|
dataField: "timestamp",
|
638
635
|
text: "Date",
|
@@ -646,7 +643,7 @@ columns: [{
|
|
646
643
|
align: "right",
|
647
644
|
renderer: (data) => data.value.toLocaleString(),
|
648
645
|
}]
|
649
|
-
|
646
|
+
```
|
650
647
|
|
651
648
|
By default, a column just runs `toString()` on the record property specified in the column's `dataField`.
|
652
649
|
You can also provide a `renderer`, which is a function you provide to format the value any way you'd like.
|
@@ -672,7 +669,7 @@ abstract, and it allows those classes to be tested in isolation.
|
|
672
669
|
|
673
670
|
Create a new file named `apps/earthquakes/view/earthquakes/Table.mjs` with this content.
|
674
671
|
|
675
|
-
|
672
|
+
```javascript readonly
|
676
673
|
import Base from '../../../../node_modules/neo.mjs/src/table/Container.mjs';
|
677
674
|
|
678
675
|
class Table extends Base {
|
@@ -698,7 +695,7 @@ class Table extends Base {
|
|
698
695
|
}
|
699
696
|
|
700
697
|
export default Neo.setupClass(Table);
|
701
|
-
|
698
|
+
```
|
702
699
|
|
703
700
|
</details>
|
704
701
|
|
@@ -735,7 +732,7 @@ You can confirm that an instance _was created_ by using the DevTools console and
|
|
735
732
|
<details>
|
736
733
|
<summary>Here's the code</summary>
|
737
734
|
|
738
|
-
|
735
|
+
```javascript readonly
|
739
736
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
740
737
|
import Controller from './MainViewController.mjs';
|
741
738
|
import EarthquakesTable from './earthquakes/Table.mjs';
|
@@ -775,7 +772,7 @@ static config = {
|
|
775
772
|
}
|
776
773
|
|
777
774
|
export default Neo.setupClass(MainView);
|
778
|
-
|
775
|
+
```
|
779
776
|
|
780
777
|
</details>
|
781
778
|
|
@@ -858,7 +855,7 @@ State Providers have two key configs: `data` and `stores`.
|
|
858
855
|
|
859
856
|
Add a `stores` property to the state provider config that holds a copy of the store.
|
860
857
|
|
861
|
-
|
858
|
+
```javascript readonly
|
862
859
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
863
860
|
import Controller from './MainViewController.mjs';
|
864
861
|
import EarthquakesTable from './earthquakes/Table.mjs';
|
@@ -939,8 +936,7 @@ class MainView extends Base {
|
|
939
936
|
}
|
940
937
|
|
941
938
|
export default Neo.setupClass(MainView);
|
942
|
-
|
943
|
-
</pre>
|
939
|
+
```
|
944
940
|
|
945
941
|
In the `stores` config we named the store _earthquakes_. We could have named it anything, like _foo_
|
946
942
|
or _myStore_. We're calling it _earthquakes_ simply because that seems like a good descriptive name
|
@@ -972,7 +968,7 @@ value is assigned to the table's `store` property.
|
|
972
968
|
|
973
969
|
Replace each table's `store` config with the binding.
|
974
970
|
|
975
|
-
|
971
|
+
```javascript readonly
|
976
972
|
|
977
973
|
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
978
974
|
import Controller from './MainViewController.mjs';
|
@@ -1025,7 +1021,7 @@ class MainView extends Base {
|
|
1025
1021
|
}
|
1026
1022
|
|
1027
1023
|
export default Neo.setupClass(MainView);
|
1028
|
-
|
1024
|
+
```
|
1029
1025
|
|
1030
1026
|
Save, refresh, and look at network traffic: you'll see a _single_ call to the web service.
|
1031
1027
|
|
@@ -1033,13 +1029,13 @@ Save, refresh, and look at network traffic: you'll see a _single_ call to the we
|
|
1033
1029
|
|
1034
1030
|
You can further prove we're using a shared instance by running these statements in the console.
|
1035
1031
|
|
1036
|
-
|
1032
|
+
```javascript readonly
|
1037
1033
|
a = Neo.findFirst({ntype:'earthquakes-main'}).stateProvider.stores.earthquakes;
|
1038
1034
|
b = Neo.find({ntype:'earthquakes-table'})[0].store;
|
1039
1035
|
c = Neo.find({ntype:'earthquakes-table'})[1].store;
|
1040
1036
|
|
1041
1037
|
(a === b) && (a === c) && (b === c) // true
|
1042
|
-
|
1038
|
+
```
|
1043
1039
|
|
1044
1040
|
</details>
|
1045
1041
|
|
@@ -1056,7 +1052,7 @@ Since the starter app already provides `MainStateProvider`, all we need to do is
|
|
1056
1052
|
|
1057
1053
|
Here's the resulting code you should place into `MainStateProvider.mjs`.
|
1058
1054
|
|
1059
|
-
|
1055
|
+
```javascript readonly
|
1060
1056
|
import StateProvider from '../../../node_modules/neo.mjs/src/state/Provider.mjs';
|
1061
1057
|
import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
|
1062
1058
|
|
@@ -1087,11 +1083,11 @@ class MainStateProvider extends StateProvider {
|
|
1087
1083
|
}
|
1088
1084
|
|
1089
1085
|
export default Neo.setupClass(MainStateProvider);
|
1090
|
-
|
1086
|
+
```
|
1091
1087
|
|
1092
1088
|
And you need to remove the `stores` config from the main view as follows.
|
1093
1089
|
|
1094
|
-
|
1090
|
+
```javascript readonly
|
1095
1091
|
import Container from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
1096
1092
|
import Controller from './MainViewController.mjs';
|
1097
1093
|
import EarthquakesTable from './earthquakes/Table.mjs';
|
@@ -1124,7 +1120,7 @@ class MainView extends Container {
|
|
1124
1120
|
}
|
1125
1121
|
|
1126
1122
|
export default Neo.setupClass(MainView);
|
1127
|
-
|
1123
|
+
```
|
1128
1124
|
|
1129
1125
|
The refactorings to have separate table and state provider classes means the code is more modular, more reusable,
|
1130
1126
|
and each class is simpler than using complex source files that try to configure every detail.
|
@@ -1188,7 +1184,7 @@ directory, but instead, move the files to their individual locations.
|
|
1188
1184
|
|
1189
1185
|
Edit `apps/earthquakes/neo-config.json` and add entries for the Google Maps add-on and the map key.
|
1190
1186
|
|
1191
|
-
|
1187
|
+
```json readonly
|
1192
1188
|
{
|
1193
1189
|
"appPath": "../../apps/earthquakes/app.mjs",
|
1194
1190
|
"basePath": "../../",
|
@@ -1196,6 +1192,7 @@ Edit `apps/earthquakes/neo-config.json` and add entries for the Google Maps add-
|
|
1196
1192
|
"mainPath": "../node_modules/neo.mjs/src/Main.mjs",
|
1197
1193
|
"mainThreadAddons": [
|
1198
1194
|
"DragDrop",
|
1195
|
+
"Navigator",
|
1199
1196
|
"WS/GoogleMaps",
|
1200
1197
|
"Stylesheet"
|
1201
1198
|
],
|
@@ -1203,7 +1200,7 @@ Edit `apps/earthquakes/neo-config.json` and add entries for the Google Maps add-
|
|
1203
1200
|
"themes" : ["neo-theme-neo-light"],
|
1204
1201
|
"workerBasePath": "../../node_modules/neo.mjs/src/worker/"
|
1205
1202
|
}
|
1206
|
-
|
1203
|
+
```
|
1207
1204
|
|
1208
1205
|
It's unusual to need to edit `neo-config.json`. The app theme is specified there, and so are main thread add-ons.
|
1209
1206
|
In our case, we're adding `WS/GoogleMaps` which in turn requires that we specify the map key. The `WS/`
|
@@ -1227,7 +1224,7 @@ lets us implement those via two properties:
|
|
1227
1224
|
|
1228
1225
|
Edit `apps/earthquakes/view/MainStateProvider.mjs` and modify `fields` as follows.
|
1229
1226
|
|
1230
|
-
|
1227
|
+
```javascript readonly
|
1231
1228
|
fields: [{
|
1232
1229
|
name: "location",
|
1233
1230
|
}, {
|
@@ -1242,7 +1239,7 @@ fields: [{
|
|
1242
1239
|
name: "position",
|
1243
1240
|
calculate: (data, field, item)=>({lat: item.latitude, lng: item.longitude})
|
1244
1241
|
}],
|
1245
|
-
|
1242
|
+
```
|
1246
1243
|
|
1247
1244
|
As you can see, _title_ is mapped to the existing feed value _location_, and _position_ is
|
1248
1245
|
calculated by returning an object with _lat_ and _lng_ set to the corresponding values from the feed.
|
@@ -1262,9 +1259,9 @@ Look at one of the items, and you should see that _title_ and _location_ are in
|
|
1262
1259
|
<summary>Use the Google Map Component</summary>
|
1263
1260
|
|
1264
1261
|
We're going to replace the top table with a Google Map. To do that we need to import the Google Maps component
|
1265
|
-
and show it
|
1262
|
+
and show it inplace of the top table. The map should be centered on Iceland.
|
1266
1263
|
|
1267
|
-
|
1264
|
+
```javascript readonly
|
1268
1265
|
{
|
1269
1266
|
module: GoogleMapsComponent,
|
1270
1267
|
flex: 1,
|
@@ -1274,11 +1271,11 @@ and show it implace of the top table. The map should be centered on Iceland. To
|
|
1274
1271
|
},
|
1275
1272
|
zoom: 6
|
1276
1273
|
}
|
1277
|
-
|
1274
|
+
```
|
1278
1275
|
|
1279
1276
|
If we replace the top table with the map, `view/MainView.mjs` ends up with this content.
|
1280
1277
|
|
1281
|
-
|
1278
|
+
```javascript readonly
|
1282
1279
|
|
1283
1280
|
import Container from '../container/Base.mjs';
|
1284
1281
|
import Controller from './MainViewController.mjs';
|
@@ -1318,7 +1315,7 @@ class MainView extends Container {
|
|
1318
1315
|
}
|
1319
1316
|
|
1320
1317
|
export default Neo.setupClass(MainView);
|
1321
|
-
|
1318
|
+
```
|
1322
1319
|
|
1323
1320
|
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/CenteredMap.png"></img>
|
1324
1321
|
|
@@ -1333,11 +1330,11 @@ export default Neo.setupClass(MainView);
|
|
1333
1330
|
|
1334
1331
|
Add this config to the map.
|
1335
1332
|
|
1336
|
-
|
1333
|
+
```javascript readonly
|
1337
1334
|
bind: {
|
1338
1335
|
markerStore: 'stores.earthquakes'
|
1339
1336
|
}
|
1340
|
-
|
1337
|
+
```
|
1341
1338
|
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/InitialMapWithMarkers.png"></img>
|
1342
1339
|
|
1343
1340
|
</details>
|
@@ -1365,13 +1362,13 @@ Table Views fire a select event, passing an object that contains a reference to
|
|
1365
1362
|
|
1366
1363
|
Add this table config:
|
1367
1364
|
|
1368
|
-
|
1365
|
+
```javascript readonly
|
1369
1366
|
viewConfig: {
|
1370
1367
|
listeners: {
|
1371
1368
|
select: (data) => console.log(data.record)
|
1372
1369
|
}
|
1373
1370
|
}
|
1374
|
-
|
1371
|
+
```
|
1375
1372
|
|
1376
1373
|
Save and refresh, then click on a table row. If you look at the debugger console you'll see the record being logged.
|
1377
1374
|
|
@@ -1391,11 +1388,11 @@ After changing the value you should immediately see it reflected in the table ro
|
|
1391
1388
|
|
1392
1389
|
Now add a `markerClick` listener to the Google Map.
|
1393
1390
|
|
1394
|
-
|
1391
|
+
```javascript readonly
|
1395
1392
|
listeners: {
|
1396
1393
|
markerClick: data => console.log(data.data.record)
|
1397
1394
|
}
|
1398
|
-
|
1395
|
+
```
|
1399
1396
|
|
1400
1397
|
Save, refresh, and confirm that you see the value logged when you click on a map marker.
|
1401
1398
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
In case you did not work with neo yet, but come from a more HTML driven ecosystem,
|
4
4
|
you could achieve the task in a similar way.
|
5
5
|
|
6
|
-
|
6
|
+
```javascript live-preview
|
7
7
|
import Component from '../component/Base.mjs';
|
8
8
|
import NeoArray from '../util/Array.mjs';
|
9
9
|
import VdomUtil from '../util/VDom.mjs';
|
@@ -110,13 +110,13 @@ class MainComponent extends Component {
|
|
110
110
|
}
|
111
111
|
|
112
112
|
MainComponent = Neo.setupClass(MainComponent);
|
113
|
-
|
113
|
+
```
|
114
114
|
|
115
115
|
## Neo Style
|
116
116
|
|
117
117
|
content
|
118
118
|
|
119
|
-
|
119
|
+
```javascript live-preview
|
120
120
|
import Container from '../container/Base.mjs';
|
121
121
|
import List from '../list/Base.mjs';
|
122
122
|
import Model from '../data/Model.mjs';
|
@@ -228,4 +228,4 @@ class MainContainer extends Container {
|
|
228
228
|
}
|
229
229
|
|
230
230
|
MainContainer = Neo.setupClass(MainContainer);
|
231
|
-
|
231
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name" : "neo.mjs",
|
3
|
-
"version" : "10.0.0-
|
3
|
+
"version" : "10.0.0-beta.1",
|
4
4
|
"description" : "Neo.mjs: The multi-threaded UI framework for building ultra-fast, desktop-like web applications with uncompromised responsiveness, inherent security, and a transpilation-free dev mode.",
|
5
5
|
"type" : "module",
|
6
6
|
"repository" : {
|
@@ -84,6 +84,18 @@
|
|
84
84
|
margin: 0.5em 0 0.7em 0;
|
85
85
|
}
|
86
86
|
|
87
|
+
pre code.language-text {
|
88
|
+
&:not(.hljs) {
|
89
|
+
background-color: #F8F8F8;
|
90
|
+
border : thin solid lightgray;
|
91
|
+
display : block;
|
92
|
+
font-size : 13px;
|
93
|
+
overflow-x : auto;
|
94
|
+
padding : 12px;
|
95
|
+
white-space : pre;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
87
99
|
pre[data-javascript] {
|
88
100
|
border : thin solid lightgray;
|
89
101
|
border-radius: 4px;
|