neo.mjs 10.0.0-alpha.5 → 10.0.0-beta.2
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/colors/view/GridContainer.mjs +1 -1
- package/apps/covid/view/AttributionComponent.mjs +1 -1
- package/apps/covid/view/HeaderContainer.mjs +6 -6
- package/apps/covid/view/MainContainerController.mjs +5 -5
- package/apps/covid/view/TableContainerController.mjs +1 -1
- package/apps/covid/view/country/Gallery.mjs +13 -13
- package/apps/covid/view/country/Helix.mjs +13 -13
- package/apps/covid/view/country/HistoricalDataTable.mjs +1 -1
- package/apps/email/view/Viewport.mjs +2 -2
- package/apps/form/view/SideNavList.mjs +1 -1
- 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 +25 -26
- package/apps/portal/resources/data/examples_dist_prod.json +26 -27
- package/apps/portal/view/HeaderToolbar.mjs +3 -3
- package/apps/portal/view/about/Container.mjs +2 -2
- package/apps/portal/view/about/MemberContainer.mjs +3 -3
- package/apps/portal/view/blog/List.mjs +7 -7
- package/apps/portal/view/examples/List.mjs +4 -4
- package/apps/portal/view/home/ContentBox.mjs +2 -2
- package/apps/portal/view/home/FeatureSection.mjs +3 -3
- package/apps/portal/view/home/FooterContainer.mjs +7 -7
- package/apps/portal/view/home/parts/AfterMath.mjs +3 -3
- package/apps/portal/view/home/parts/MainNeo.mjs +3 -3
- package/apps/portal/view/home/parts/References.mjs +6 -6
- package/apps/portal/view/learn/ContentComponent.mjs +102 -111
- package/apps/portal/view/learn/PageSectionsContainer.mjs +1 -1
- package/apps/portal/view/learn/PageSectionsList.mjs +2 -2
- package/apps/portal/view/services/Component.mjs +16 -16
- package/apps/realworld/view/FooterComponent.mjs +1 -1
- package/apps/realworld/view/HeaderComponent.mjs +8 -8
- package/apps/realworld/view/HomeComponent.mjs +6 -6
- package/apps/realworld/view/article/CommentComponent.mjs +4 -4
- package/apps/realworld/view/article/Component.mjs +14 -14
- package/apps/realworld/view/article/CreateCommentComponent.mjs +3 -3
- package/apps/realworld/view/article/CreateComponent.mjs +3 -3
- package/apps/realworld/view/article/PreviewComponent.mjs +1 -1
- package/apps/realworld/view/article/TagListComponent.mjs +2 -2
- package/apps/realworld/view/user/ProfileComponent.mjs +8 -8
- package/apps/realworld/view/user/SettingsComponent.mjs +4 -4
- package/apps/realworld/view/user/SignUpComponent.mjs +4 -4
- package/apps/realworld2/view/FooterComponent.mjs +1 -1
- package/apps/realworld2/view/HomeContainer.mjs +3 -3
- package/apps/realworld2/view/article/DetailsContainer.mjs +1 -1
- package/apps/realworld2/view/article/PreviewComponent.mjs +7 -7
- package/apps/realworld2/view/article/TagListComponent.mjs +2 -2
- package/apps/realworld2/view/user/ProfileContainer.mjs +1 -1
- package/apps/route/view/center/CardAdministration.mjs +2 -2
- package/apps/route/view/center/CardAdministrationDenied.mjs +1 -1
- package/apps/route/view/center/CardContact.mjs +2 -2
- package/apps/route/view/center/CardHome.mjs +1 -1
- package/apps/route/view/center/CardSection1.mjs +1 -1
- package/apps/route/view/center/CardSection2.mjs +1 -1
- package/apps/sharedcovid/view/AttributionComponent.mjs +1 -1
- package/apps/sharedcovid/view/HeaderContainer.mjs +6 -6
- package/apps/sharedcovid/view/MainContainerController.mjs +5 -5
- package/apps/sharedcovid/view/TableContainerController.mjs +1 -1
- package/apps/sharedcovid/view/country/Gallery.mjs +13 -13
- package/apps/sharedcovid/view/country/Helix.mjs +13 -13
- package/apps/sharedcovid/view/country/HistoricalDataTable.mjs +1 -1
- package/apps/shareddialog/childapps/shareddialog2/view/MainContainer.mjs +1 -1
- package/apps/shareddialog/view/MainContainer.mjs +1 -1
- package/buildScripts/createApp.mjs +2 -2
- 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/Glossary.md +261 -0
- package/learn/UsingTheseTopics.md +2 -2
- package/learn/benefits/ConfigSystem.md +538 -28
- package/learn/benefits/Effort.md +47 -2
- package/learn/benefits/Features.md +50 -32
- package/learn/benefits/FormsEngine.md +68 -38
- package/learn/benefits/MultiWindow.md +33 -7
- package/learn/benefits/OffTheMainThread.md +2 -2
- package/learn/benefits/Quick.md +45 -12
- package/learn/benefits/RPCLayer.md +75 -0
- package/learn/benefits/Speed.md +16 -11
- 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 +26 -26
- package/learn/guides/ComponentsAndContainers.md +12 -12
- package/learn/guides/ConfigSystemDeepDive.md +280 -0
- package/learn/guides/CustomComponents.md +2 -2
- package/learn/guides/DeclarativeComponentTreesVsImperativeVdom.md +17 -17
- package/learn/guides/InstanceLifecycle.md +295 -1
- package/learn/guides/MainThreadAddons.md +475 -0
- package/learn/guides/PortalApp.md +2 -2
- package/learn/guides/StateProviders.md +12 -12
- package/learn/guides/WorkingWithVDom.md +14 -14
- 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/tree.json +52 -51
- package/learn/tutorials/Earthquakes.md +54 -57
- package/learn/tutorials/TodoList.md +4 -4
- package/package.json +2 -2
- package/resources/scss/src/apps/portal/learn/ContentComponent.scss +12 -0
- 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/table/{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/table/{View.scss → Body.scss} +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/Main.mjs +8 -7
- package/src/Neo.mjs +16 -2
- package/src/button/Base.mjs +2 -2
- package/src/calendar/view/SettingsContainer.mjs +2 -2
- package/src/calendar/view/YearComponent.mjs +9 -9
- package/src/calendar/view/calendars/ColorsList.mjs +1 -1
- package/src/calendar/view/calendars/List.mjs +1 -1
- package/src/calendar/view/month/Component.mjs +15 -15
- package/src/calendar/view/week/Component.mjs +12 -12
- package/src/calendar/view/week/EventDragZone.mjs +4 -4
- package/src/calendar/view/week/TimeAxisComponent.mjs +3 -3
- package/src/component/Base.mjs +17 -2
- package/src/component/Carousel.mjs +2 -2
- package/src/component/Chip.mjs +3 -3
- package/src/component/Circle.mjs +2 -2
- package/src/component/DateSelector.mjs +8 -8
- package/src/component/Helix.mjs +1 -1
- package/src/component/Label.mjs +3 -18
- package/src/component/Legend.mjs +3 -3
- package/src/component/MagicMoveText.mjs +6 -14
- package/src/component/Process.mjs +3 -3
- package/src/component/Progress.mjs +1 -1
- package/src/component/StatusBadge.mjs +2 -2
- package/src/component/Timer.mjs +2 -2
- package/src/component/Toast.mjs +5 -3
- package/src/container/AccordionItem.mjs +2 -2
- package/src/container/Base.mjs +1 -1
- package/src/core/Base.mjs +77 -14
- package/src/core/Util.mjs +14 -2
- package/src/date/DayViewComponent.mjs +2 -2
- package/src/date/SelectorContainer.mjs +1 -1
- package/src/draggable/grid/header/toolbar/SortZone.mjs +21 -21
- package/src/draggable/table/header/toolbar/SortZone.mjs +1 -1
- package/src/form/field/CheckBox.mjs +4 -4
- package/src/form/field/FileUpload.mjs +25 -39
- package/src/form/field/Range.mjs +1 -1
- package/src/form/field/Text.mjs +3 -3
- package/src/form/field/TextArea.mjs +2 -3
- package/src/grid/Body.mjs +8 -5
- package/src/grid/_export.mjs +1 -1
- package/src/list/Color.mjs +2 -2
- package/src/main/DeltaUpdates.mjs +157 -98
- package/src/main/addon/AmCharts.mjs +61 -84
- package/src/main/addon/Base.mjs +161 -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 +32 -64
- package/src/manager/ClassHierarchy.mjs +114 -0
- package/src/menu/List.mjs +1 -1
- package/src/plugin/Popover.mjs +2 -2
- package/src/sitemap/Component.mjs +1 -1
- package/src/table/{View.mjs → Body.mjs} +25 -22
- package/src/table/Container.mjs +43 -43
- package/src/table/_export.mjs +2 -2
- package/src/table/plugin/CellEditing.mjs +19 -19
- package/src/tooltip/Base.mjs +1 -6
- package/src/tree/Accordion.mjs +3 -3
- package/src/vdom/Helper.mjs +19 -22
- package/src/worker/App.mjs +1 -2
- package/src/worker/Base.mjs +7 -5
- package/src/worker/Canvas.mjs +2 -3
- package/src/worker/Data.mjs +5 -7
- package/src/worker/Task.mjs +2 -3
- package/src/worker/VDom.mjs +3 -4
- package/src/worker/mixin/RemoteMethodAccess.mjs +5 -2
- package/learn/guides/MainThreadAddonExample.md +0 -15
- package/learn/guides/MainThreadAddonIntro.md +0 -44
@@ -15,7 +15,7 @@ While 99% of Neo.mjs development happens at the Component Tree layer, creating c
|
|
15
15
|
Neo.mjs VDom nodes are plain JavaScript objects that represent DOM elements.
|
16
16
|
**Important**: VDom only contains structure, styling, content, and attributes - **never event listeners**.
|
17
17
|
|
18
|
-
```javascript
|
18
|
+
```javascript readonly
|
19
19
|
// Basic VDom node structure
|
20
20
|
{
|
21
21
|
tag : 'div', // HTML tag (default: 'div')
|
@@ -41,7 +41,7 @@ Neo.mjs VDom nodes are plain JavaScript objects that represent DOM elements.
|
|
41
41
|
|
42
42
|
Components define their internal DOM structure via the `vdom` config:
|
43
43
|
|
44
|
-
```javascript
|
44
|
+
```javascript readonly
|
45
45
|
import Component from './src/component/Base.mjs';
|
46
46
|
|
47
47
|
class CustomButton extends Component {
|
@@ -81,7 +81,7 @@ For a comprehensive deep dive into all aspects of DOM event handling in Neo.mjs
|
|
81
81
|
|
82
82
|
Here's a simple example of how an event handler defined via `domListeners` would interact with a component's VDom:
|
83
83
|
|
84
|
-
```javascript
|
84
|
+
```javascript readonly
|
85
85
|
import Component from './src/component/Base.mjs';
|
86
86
|
import VdomUtil from './src/util/Vdom.mjs'; // For accessing VDom nodes by flag
|
87
87
|
|
@@ -144,7 +144,7 @@ class InteractiveComponent extends Component {
|
|
144
144
|
|
145
145
|
The typical way to sync VDom changes to the DOM is through the component's `update()` method:
|
146
146
|
|
147
|
-
```javascript
|
147
|
+
```javascript readonly
|
148
148
|
import Component from './src/component/Base.mjs'; // Required import
|
149
149
|
|
150
150
|
class StandardComponent extends Component {
|
@@ -180,7 +180,7 @@ class StandardComponent extends Component {
|
|
180
180
|
For performance-critical scenarios, you can bypass the VDom worker's diffing engine and send manually crafted deltas
|
181
181
|
directly from the App Worker to the Main Thread. This offers precise control but requires careful manual delta construction.
|
182
182
|
|
183
|
-
```javascript
|
183
|
+
```javascript readonly
|
184
184
|
import Component from './src/component/Base.mjs'; // Required import
|
185
185
|
|
186
186
|
class AdvancedComponent extends Component {
|
@@ -240,7 +240,7 @@ class AdvancedComponent extends Component {
|
|
240
240
|
|
241
241
|
Flags provide efficient, direct access to specific VDom nodes within a component's `vdom` structure, avoiding the need for DOM queries.
|
242
242
|
|
243
|
-
```javascript
|
243
|
+
```javascript readonly
|
244
244
|
import Component from './src/component/Base.mjs';
|
245
245
|
import VdomUtil from './src/util/Vdom.mjs'; // Required import for VdomUtil
|
246
246
|
import NeoArray from './src/util/Array.mjs'; // Required import for NeoArray
|
@@ -304,7 +304,7 @@ class IconButton extends Component {
|
|
304
304
|
|
305
305
|
Build VDom structures programmatically, often in response to data changes. This is common for lists or complex, data-driven UI fragments.
|
306
306
|
|
307
|
-
```javascript
|
307
|
+
```javascript readonly
|
308
308
|
import Component from './src/component/Base.mjs'; // Required import
|
309
309
|
|
310
310
|
class DataList extends Component {
|
@@ -380,7 +380,7 @@ class DataList extends Component {
|
|
380
380
|
|
381
381
|
For sophisticated UI patterns like 3D visualizations or complex dynamic layouts, you might imperatively calculate and apply VDom properties or even use `Neo.applyDeltas()` for maximum performance.
|
382
382
|
|
383
|
-
```javascript
|
383
|
+
```javascript readonly
|
384
384
|
import Component from './src/component/Base.mjs'; // Base component class
|
385
385
|
|
386
386
|
class Helix extends Component {
|
@@ -452,7 +452,7 @@ class Helix extends Component {
|
|
452
452
|
|
453
453
|
### XSS Prevention
|
454
454
|
|
455
|
-
```javascript
|
455
|
+
```javascript readonly
|
456
456
|
import Component from './src/component/Base.mjs'; // Required import
|
457
457
|
// import DOMPurify from 'dompurify'; // Example for external sanitization library
|
458
458
|
|
@@ -499,7 +499,7 @@ this.update();
|
|
499
499
|
|
500
500
|
### 1. Batch VDom Updates
|
501
501
|
|
502
|
-
```javascript
|
502
|
+
```javascript readonly
|
503
503
|
import Component from './src/component/Base.mjs'; // Required import
|
504
504
|
import Neo from './src/Neo.mjs'; // Required import for Neo.applyDeltas
|
505
505
|
|
@@ -547,7 +547,7 @@ class PerformantComponent extends Component {
|
|
547
547
|
|
548
548
|
### 2. Efficient Event Delegation
|
549
549
|
|
550
|
-
```javascript
|
550
|
+
```javascript readonly
|
551
551
|
import Component from './src/component/Base.mjs'; // Required import
|
552
552
|
|
553
553
|
class EfficientEventComponent extends Component {
|
@@ -595,7 +595,7 @@ super.construct(config);
|
|
595
595
|
|
596
596
|
### 3. Memory Management
|
597
597
|
|
598
|
-
```javascript
|
598
|
+
```javascript readonly
|
599
599
|
import Component from './src/component/Base.mjs'; // Required import
|
600
600
|
|
601
601
|
class MemoryEfficientComponent extends Component {
|
@@ -632,7 +632,7 @@ class MemoryEfficientComponent extends Component {
|
|
632
632
|
|
633
633
|
Dynamically show or hide VDom nodes by setting their `removeDom` property. This is efficient as the VDom node remains in the tree, but its corresponding DOM element is removed/added from the document flow by the framework.
|
634
634
|
|
635
|
-
```javascript
|
635
|
+
```javascript readonly
|
636
636
|
import Component from './src/component/Base.mjs'; // Required import
|
637
637
|
import VdomUtil from './src/util/Vdom.mjs'; // Required import
|
638
638
|
|
@@ -673,7 +673,7 @@ class ConditionalComponent extends Component {
|
|
673
673
|
|
674
674
|
Programmatically create and update lists of VDom nodes, typically from data. This approach is highly efficient as the VDom diffing engine optimizes the DOM updates.
|
675
675
|
|
676
|
-
```javascript
|
676
|
+
```javascript readonly
|
677
677
|
import Component from './src/component/Base.mjs'; // Required import
|
678
678
|
|
679
679
|
class ListComponent extends Component {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
As you read in the <a href="#/learn/Events">Getting Started > Events</a> topic, components, stores, and many other objects fire events.
|
2
2
|
|
3
3
|
|
4
|
-
|
4
|
+
```javascript live-preview
|
5
5
|
import Container from '../container/Base.mjs';
|
6
6
|
import TextField from '../form/field/Text.mjs';
|
7
7
|
|
@@ -26,7 +26,7 @@ class MainView extends Container {
|
|
26
26
|
}
|
27
27
|
}
|
28
28
|
MainView = Neo.setupClass(MainView);
|
29
|
-
|
29
|
+
```
|
30
30
|
|
31
31
|
## Event listeners
|
32
32
|
|
@@ -35,7 +35,7 @@ MainView = Neo.setupClass(MainView);
|
|
35
35
|
The event listener function can be coded in-line. Normally you want event handlers to be in a view's
|
36
36
|
controller, but for very simple situation it can be convenient to use this syntax.
|
37
37
|
|
38
|
-
|
38
|
+
```javascript live-preview
|
39
39
|
import Container from '../container/Base.mjs';
|
40
40
|
import TextField from '../form/field/Text.mjs';
|
41
41
|
|
@@ -54,7 +54,7 @@ class MainView extends Container {
|
|
54
54
|
}
|
55
55
|
}
|
56
56
|
MainView = Neo.setupClass(MainView);
|
57
|
-
|
57
|
+
```
|
58
58
|
|
59
59
|
### As a view method
|
60
60
|
|
@@ -62,7 +62,7 @@ You can also use the `up.` qualifier to specify a method in the component's pare
|
|
62
62
|
in-line syntax you saw above, using the `up.` syntax might be convenient for simple classees,
|
63
63
|
or when you simply haven't gotten around to defining a view's controller.
|
64
64
|
|
65
|
-
|
65
|
+
```javascript live-preview
|
66
66
|
import Container from '../container/Base.mjs';
|
67
67
|
import TextField from '../form/field/Text.mjs';
|
68
68
|
|
@@ -84,7 +84,7 @@ class MainView extends Container {
|
|
84
84
|
}
|
85
85
|
}
|
86
86
|
MainView = Neo.setupClass(MainView);
|
87
|
-
|
87
|
+
```
|
88
88
|
|
89
89
|
### As a controller method
|
90
90
|
|
@@ -92,7 +92,7 @@ Despite the examples above, the most correct way of setting up event handlers is
|
|
92
92
|
Any view class can specify a controller — wWhen the view is created a controller instance is
|
93
93
|
also created.
|
94
94
|
|
95
|
-
|
95
|
+
```javascript live-preview
|
96
96
|
import Controller from '../controller/Component.mjs';
|
97
97
|
|
98
98
|
class MainViewController extends Controller {
|
@@ -125,7 +125,7 @@ class MainView extends Container {
|
|
125
125
|
}
|
126
126
|
}
|
127
127
|
MainView = Neo.setupClass(MainView);
|
128
|
-
|
128
|
+
```
|
129
129
|
|
130
130
|
## Adding listeners procedurally
|
131
131
|
|
@@ -134,7 +134,7 @@ a listener procedurally.
|
|
134
134
|
|
135
135
|
Any observable class has an `addListener` method, along with an easier-to-type version called `on`.
|
136
136
|
|
137
|
-
|
137
|
+
```javascript live-preview
|
138
138
|
import Controller from '../controller/Component.mjs';
|
139
139
|
|
140
140
|
class MainViewController extends Controller {
|
@@ -167,11 +167,11 @@ class MainView extends Container {
|
|
167
167
|
}
|
168
168
|
}
|
169
169
|
MainView = Neo.setupClass(MainView);
|
170
|
-
|
170
|
+
```
|
171
171
|
|
172
172
|
The method specified in `on()` doesn't have to be an arrow function; you can use a controller function.
|
173
173
|
|
174
|
-
|
174
|
+
```javascript live-preview
|
175
175
|
import Controller from '../controller/Component.mjs';
|
176
176
|
|
177
177
|
class MainViewController extends Controller {
|
@@ -208,7 +208,7 @@ class MainView extends Container {
|
|
208
208
|
}
|
209
209
|
}
|
210
210
|
MainView = Neo.setupClass(MainView);
|
211
|
-
|
211
|
+
```
|
212
212
|
|
213
213
|
## Events versus binding
|
214
214
|
|
@@ -241,7 +241,7 @@ will automatically be reflected in the view model.
|
|
241
241
|
To contrast syntax, and to illustrate the simplicity of a binding, let's look at two exmaples of updating a component
|
242
242
|
to reflect the value of a text field. THe first example uses events; the second uses bindings.
|
243
243
|
|
244
|
-
|
244
|
+
```javascript live-preview
|
245
245
|
import Component from '../component/Base.mjs';
|
246
246
|
import Container from '../container/Base.mjs';
|
247
247
|
import TextField from '../form/field/Text.mjs';
|
@@ -277,9 +277,9 @@ class MainView extends Container {
|
|
277
277
|
}
|
278
278
|
}
|
279
279
|
MainView = Neo.setupClass(MainView);
|
280
|
-
|
280
|
+
```
|
281
281
|
|
282
|
-
|
282
|
+
```javascript live-preview
|
283
283
|
import Component from '../component/Base.mjs';
|
284
284
|
import Container from '../container/Base.mjs';
|
285
285
|
import TextField from '../form/field/Text.mjs';
|
@@ -313,7 +313,7 @@ class MainView extends Container {
|
|
313
313
|
}
|
314
314
|
}
|
315
315
|
MainView = Neo.setupClass(MainView);
|
316
|
-
|
316
|
+
```
|
317
317
|
|
318
318
|
##How are events set up?
|
319
319
|
|
@@ -34,7 +34,7 @@ the class. If you add `console.log(this);`, the output is most likely not want y
|
|
34
34
|
For the second Button we are defining a non-bound function, in which case `this` will point
|
35
35
|
to the Component instance.
|
36
36
|
|
37
|
-
|
37
|
+
```javascript live-preview
|
38
38
|
import Container from '../container/Base.mjs';
|
39
39
|
|
40
40
|
class MainView extends Container {
|
@@ -62,7 +62,7 @@ class MainView extends Container {
|
|
62
62
|
}
|
63
63
|
}
|
64
64
|
MainView = Neo.setupClass(MainView);
|
65
|
-
|
65
|
+
```
|
66
66
|
|
67
67
|
### Handler inside the Component Tree
|
68
68
|
|
@@ -72,7 +72,7 @@ A good example would be `tab.header.Toolbar`, where clicking on a Button will ch
|
|
72
72
|
You can use string based listeners. In case the handler method lives within the parent tree (any level),
|
73
73
|
we need to prefix these listeners with `up.`.
|
74
74
|
|
75
|
-
|
75
|
+
```javascript live-preview
|
76
76
|
import Container from '../container/Base.mjs';
|
77
77
|
|
78
78
|
class MainView extends Container {
|
@@ -95,7 +95,7 @@ class MainView extends Container {
|
|
95
95
|
}
|
96
96
|
}
|
97
97
|
MainView = Neo.setupClass(MainView);
|
98
|
-
|
98
|
+
```
|
99
99
|
|
100
100
|
### Handler inside a ViewController
|
101
101
|
|
@@ -107,7 +107,7 @@ to find the closest match.
|
|
107
107
|
|
108
108
|
A good use case would be a form submit Button, where a click will trigger a communication to the backend.
|
109
109
|
|
110
|
-
|
110
|
+
```javascript live-preview
|
111
111
|
import Container from '../container/Base.mjs';
|
112
112
|
import Controller from '../controller/Component.mjs';
|
113
113
|
|
@@ -138,7 +138,7 @@ class MainView extends Container {
|
|
138
138
|
}
|
139
139
|
}
|
140
140
|
MainView = Neo.setupClass(MainView);
|
141
|
-
|
141
|
+
```
|
142
142
|
|
143
143
|
## Listener Options
|
144
144
|
|
@@ -146,7 +146,7 @@ MainView = Neo.setupClass(MainView);
|
|
146
146
|
|
147
147
|
We can further delegate listeners to specific DOM nodes within our Component:
|
148
148
|
|
149
|
-
|
149
|
+
```javascript live-preview
|
150
150
|
import Container from '../container/Base.mjs';
|
151
151
|
|
152
152
|
class MainView extends Container {
|
@@ -172,7 +172,7 @@ class MainView extends Container {
|
|
172
172
|
}
|
173
173
|
}
|
174
174
|
MainView = Neo.setupClass(MainView);
|
175
|
-
|
175
|
+
```
|
176
176
|
|
177
177
|
In case you click on the blue div, no console logs will appear.
|
178
178
|
They do, when clicking on the white inner div.
|
@@ -184,7 +184,7 @@ we will get logs when clicking on the blue div too.
|
|
184
184
|
|
185
185
|
We can prevent listeners from bubbling upwards:
|
186
186
|
|
187
|
-
|
187
|
+
```javascript live-preview
|
188
188
|
import Container from '../container/Base.mjs';
|
189
189
|
|
190
190
|
class MainView extends Container {
|
@@ -221,7 +221,7 @@ class MainView extends Container {
|
|
221
221
|
}
|
222
222
|
}
|
223
223
|
MainView = Neo.setupClass(MainView);
|
224
|
-
|
224
|
+
```
|
225
225
|
|
226
226
|
Clicking on the inner (white) div will only trigger the inner listener and you will get one log.
|
227
227
|
|
@@ -237,7 +237,7 @@ While we could just manually order the array inside the following example,
|
|
237
237
|
there can be use cases where multiple subscribers get added at run-time and developers
|
238
238
|
can not be sure about the adding order.
|
239
239
|
|
240
|
-
|
240
|
+
```javascript live-preview
|
241
241
|
import Container from '../container/Base.mjs';
|
242
242
|
|
243
243
|
class MainView extends Container {
|
@@ -257,7 +257,7 @@ class MainView extends Container {
|
|
257
257
|
}
|
258
258
|
}
|
259
259
|
MainView = Neo.setupClass(MainView);
|
260
|
-
|
260
|
+
```
|
261
261
|
|
262
262
|
Try it: In case you remove `priority: 2` inside the source view,
|
263
263
|
the order of the logs will change.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
Neo.mjs uses standard modular JavaScript, so you're free to use other class
|
2
2
|
features, like private members.
|
3
|
-
|
3
|
+
|
4
|
+
```javascript readonly
|
4
5
|
class Human extends Mammal {
|
5
6
|
static config = {
|
6
7
|
className: 'Simple.example.Human',
|
@@ -33,4 +34,4 @@ const myPerson = Neo.create(Human, {
|
|
33
34
|
});
|
34
35
|
|
35
36
|
myPerson.speak(true);
|
36
|
-
|
37
|
+
```
|
@@ -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
|
+
```
|