neo.mjs 8.14.0 → 8.14.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/apps/ServiceWorker.mjs +2 -2
- package/apps/portal/index.html +1 -1
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/resources/data/deck/learnneo/pages/gettingstarted/ComponentModels.md +8 -7
- package/resources/scss/src/draggable/grid/header/toolbar/SortZone.scss +4 -4
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Base.mjs +1 -1
- package/src/draggable/grid/header/toolbar/SortZone.mjs +52 -28
package/apps/ServiceWorker.mjs
CHANGED
package/apps/portal/index.html
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Neo has a feature that allows shared, bindable, data.
|
2
2
|
|
3
|
-
A
|
3
|
+
A _state provider_ — `Neo.state.Provider` — instance holds properties that
|
4
4
|
can be bound to component properties.
|
5
5
|
|
6
6
|
<pre data-neo>
|
@@ -12,7 +12,7 @@ class MainView extends Container {
|
|
12
12
|
static config = {
|
13
13
|
className: 'GS.data1.MainView',
|
14
14
|
|
15
|
-
|
15
|
+
stateProvider: {
|
16
16
|
data: {
|
17
17
|
foo: 'Hi there!'
|
18
18
|
}
|
@@ -83,7 +83,7 @@ class MainView extends Container {
|
|
83
83
|
static config = {
|
84
84
|
className: 'GS.data2.MainView',
|
85
85
|
|
86
|
-
|
86
|
+
stateProvider: {
|
87
87
|
data: {
|
88
88
|
foo: 'parent'
|
89
89
|
}
|
@@ -95,8 +95,9 @@ class MainView extends Container {
|
|
95
95
|
module: MyPanel
|
96
96
|
}, {
|
97
97
|
module: MyPanel,
|
98
|
-
// You wouldn't normally configure a
|
99
|
-
|
98
|
+
// You wouldn't normally configure a state provider.
|
99
|
+
// We're doing it here to illustrate state provider scope.
|
100
|
+
stateProvider: {
|
100
101
|
data: {
|
101
102
|
foo: 'child'
|
102
103
|
}
|
@@ -109,7 +110,7 @@ MainView = Neo.setupClass(MainView);
|
|
109
110
|
</pre>
|
110
111
|
|
111
112
|
In this case, the main view has three child items of type `MyPanel`, each containing a label.
|
112
|
-
The main view has a
|
113
|
+
The main view has a state provider with a `foo` property, and the third child has its own state provider with a `foo` property.
|
113
114
|
|
114
115
|
<img width="75%" src="https://s3.amazonaws.com/mjs.neo.learning.images/gettingStarted/vm/VisualHierarchyFooShadowed.png"></img>
|
115
116
|
|
@@ -124,5 +125,5 @@ because the third copy of `MyPanel` has its own view model with the `foo` proper
|
|
124
125
|
|
125
126
|
## Conclusion
|
126
127
|
|
127
|
-
The Neo.mjs
|
128
|
+
The Neo.mjs state provider and binding approach is simple and powerful. It gives you easy control
|
128
129
|
over the scope of a value, which means you can share properties as globally or narrowly as needed.
|
@@ -14,6 +14,10 @@
|
|
14
14
|
.neo-dragproxy {
|
15
15
|
.neo-grid-container {
|
16
16
|
border: none;
|
17
|
+
|
18
|
+
* {
|
19
|
+
scrollbar-width: none;
|
20
|
+
}
|
17
21
|
}
|
18
22
|
|
19
23
|
.neo-grid-header-toolbar {
|
@@ -23,10 +27,6 @@
|
|
23
27
|
border-right: 1px solid var(--grid-container-border-color);
|
24
28
|
}
|
25
29
|
}
|
26
|
-
|
27
|
-
.neo-grid-row {
|
28
|
-
position: unset;
|
29
|
-
}
|
30
30
|
}
|
31
31
|
|
32
32
|
.neo-grid-header-toolbar {
|
package/src/DefaultConfig.mjs
CHANGED
@@ -262,12 +262,12 @@ const DefaultConfig = {
|
|
262
262
|
useVdomWorker: true,
|
263
263
|
/**
|
264
264
|
* buildScripts/injectPackageVersion.mjs will update this value
|
265
|
-
* @default '8.14.
|
265
|
+
* @default '8.14.2'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '8.14.
|
270
|
+
version: '8.14.2'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
package/src/component/Base.mjs
CHANGED
@@ -2300,7 +2300,7 @@ class Component extends Base {
|
|
2300
2300
|
// Verify that the critical rendering path => CSS files for the new tree is in place
|
2301
2301
|
if (currentWorker.countLoadingThemeFiles !== 0) {
|
2302
2302
|
currentWorker.on('themeFilesLoaded', function() {
|
2303
|
-
me.render(mount)
|
2303
|
+
!me.mounted && me.render(mount)
|
2304
2304
|
}, me, {once: true});
|
2305
2305
|
|
2306
2306
|
return
|
@@ -19,7 +19,7 @@ class SortZone extends BaseSortZone {
|
|
19
19
|
*/
|
20
20
|
ntype: 'grid-header-toolbar-sortzone',
|
21
21
|
/**
|
22
|
-
* @member {String|null} itemMargin=
|
22
|
+
* @member {String|null} itemMargin='1px'
|
23
23
|
* @protected
|
24
24
|
*/
|
25
25
|
itemMargin: '1px',
|
@@ -52,28 +52,29 @@ class SortZone extends BaseSortZone {
|
|
52
52
|
return await super.createDragProxy(data, createComponent)
|
53
53
|
}
|
54
54
|
|
55
|
-
let me
|
56
|
-
grid
|
57
|
-
{view}
|
58
|
-
gridRows
|
59
|
-
columnIndex
|
60
|
-
{dataField}
|
61
|
-
cells
|
62
|
-
rows
|
63
|
-
config
|
64
|
-
rect
|
55
|
+
let me = this,
|
56
|
+
grid = me.owner.parent,
|
57
|
+
{view} = grid,
|
58
|
+
gridRows = view.getVdomRoot().cn,
|
59
|
+
columnIndex = me.dragElement['aria-colindex'] - 1,
|
60
|
+
{dataField} = view.columnPositions[columnIndex],
|
61
|
+
cells = view.getColumnCells(dataField),
|
62
|
+
rows = [],
|
63
|
+
config = await super.createDragProxy(data, false),
|
64
|
+
rect = await grid.getDomRect(),
|
65
|
+
viewWrapperId = Neo.getId('grid-view-wrapper'),
|
65
66
|
row;
|
66
67
|
|
67
68
|
config.cls = ['neo-grid-wrapper', me.owner.getTheme()];
|
68
69
|
|
69
|
-
config.style.height = rect.height
|
70
|
+
config.style.height = `${rect.height - 2}px`; // minus border-bottom & border-top
|
70
71
|
|
71
72
|
cells.forEach((cell, index) => {
|
72
|
-
row = VdomUtil.clone({
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
};
|
73
|
+
row = VdomUtil.clone({ // clone to remove ids
|
74
|
+
cls : gridRows[index].cls,
|
75
|
+
cn : [cell],
|
76
|
+
style: gridRows[index].style
|
77
|
+
});
|
77
78
|
|
78
79
|
delete row.cn[0].style.left;
|
79
80
|
|
@@ -84,10 +85,24 @@ class SortZone extends BaseSortZone {
|
|
84
85
|
{cn: [
|
85
86
|
{cls: ['neo-grid-container'], cn: [
|
86
87
|
{...config.vdom, cls: ['neo-grid-header-toolbar', 'neo-toolbar']},
|
87
|
-
{cls: ['neo-grid-view'], cn:
|
88
|
+
{cls: ['neo-grid-view-wrapper'], id: viewWrapperId, cn: [
|
89
|
+
{cls: ['neo-grid-view'], cn: rows},
|
90
|
+
{cls: ['neo-grid-scrollbar'], style: {height: view.vdom.cn[1].height}}
|
91
|
+
]}
|
88
92
|
]}
|
89
93
|
]};
|
90
94
|
|
95
|
+
config.listeners = {
|
96
|
+
mounted() {
|
97
|
+
Neo.main.DomAccess.scrollTo({
|
98
|
+
direction: 'top',
|
99
|
+
id : viewWrapperId,
|
100
|
+
value : view.scrollPosition.y,
|
101
|
+
windowId : this.windowId
|
102
|
+
})
|
103
|
+
}
|
104
|
+
};
|
105
|
+
|
91
106
|
if (createComponent) {
|
92
107
|
return me.dragProxy = Neo.create(config)
|
93
108
|
}
|
@@ -154,31 +169,40 @@ class SortZone extends BaseSortZone {
|
|
154
169
|
* @param {Number} index2
|
155
170
|
*/
|
156
171
|
switchItems(index1, index2) {
|
172
|
+
super.switchItems(index1, index2);
|
173
|
+
|
157
174
|
if (this.moveColumnContent) {
|
158
|
-
let
|
175
|
+
let me = this,
|
176
|
+
{itemRects} = me,
|
177
|
+
{view} = me.owner.parent,
|
159
178
|
columnPositions = view._columnPositions, // no clone
|
160
179
|
column1Cells = view.getColumnCells(columnPositions[index1].dataField),
|
161
|
-
column2Cells = view.getColumnCells(columnPositions[index2].dataField)
|
162
|
-
x;
|
180
|
+
column2Cells = view.getColumnCells(columnPositions[index2].dataField);
|
163
181
|
|
164
|
-
|
165
|
-
|
166
|
-
|
182
|
+
Object.assign(columnPositions[index1], {
|
183
|
+
width: itemRects[index2].width,
|
184
|
+
x : itemRects[index2].x + 1
|
185
|
+
});
|
186
|
+
|
187
|
+
Object.assign(columnPositions[index2], {
|
188
|
+
width: itemRects[index1].width,
|
189
|
+
x : itemRects[index1].x + 1
|
190
|
+
});
|
167
191
|
|
168
192
|
NeoArray.move(columnPositions, index1, index2);
|
169
193
|
|
170
194
|
column1Cells.forEach(node => {
|
171
|
-
node.style.left
|
195
|
+
node.style.left = columnPositions[index2].x + 'px';
|
196
|
+
node.style.width = columnPositions[index2].width + 'px'
|
172
197
|
});
|
173
198
|
|
174
199
|
column2Cells.forEach(node => {
|
175
|
-
node.style.left
|
200
|
+
node.style.left = columnPositions[index1].x + 'px';
|
201
|
+
node.style.width = columnPositions[index1].width + 'px'
|
176
202
|
});
|
177
203
|
|
178
204
|
view.update()
|
179
205
|
}
|
180
|
-
|
181
|
-
super.switchItems(index1, index2);
|
182
206
|
}
|
183
207
|
}
|
184
208
|
|