neo.mjs 8.8.0 → 8.9.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/apps/ServiceWorker.mjs +2 -2
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/grid/nestedRecordFields/Viewport.mjs +3 -3
- package/examples/grid/nestedRecordFields/neo-config.json +2 -1
- package/examples/table/nestedRecordFields/Viewport.mjs +3 -3
- package/examples/table/nestedRecordFields/neo-config.json +2 -1
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Base.mjs +53 -5
- package/src/container/Base.mjs +16 -0
- package/src/dialog/Base.mjs +14 -2
package/apps/ServiceWorker.mjs
CHANGED
@@ -33,8 +33,8 @@ class Viewport extends BaseViewport {
|
|
33
33
|
|
34
34
|
items: ['->', {
|
35
35
|
handler: 'up.onSwitchThemeButtonClick',
|
36
|
-
iconCls: 'fas fa-
|
37
|
-
text : '
|
36
|
+
iconCls: 'fas fa-sun',
|
37
|
+
text : 'Light Theme'
|
38
38
|
}]
|
39
39
|
}, {
|
40
40
|
module: GridContainer,
|
@@ -133,7 +133,7 @@ class Viewport extends BaseViewport {
|
|
133
133
|
onSwitchThemeButtonClick(data) {
|
134
134
|
let me = this,
|
135
135
|
button = data.component,
|
136
|
-
isDarkTheme = me.theme
|
136
|
+
isDarkTheme = me.theme !== 'neo-theme-light',
|
137
137
|
theme = isDarkTheme ? 'neo-theme-light' : 'neo-theme-dark';
|
138
138
|
|
139
139
|
button.set({
|
@@ -3,5 +3,6 @@
|
|
3
3
|
"basePath" : "../../../",
|
4
4
|
"environment" : "development",
|
5
5
|
"mainPath" : "./Main.mjs",
|
6
|
-
"mainThreadAddons": ["DragDrop", "Navigator", "ResizeObserver", "Stylesheet"]
|
6
|
+
"mainThreadAddons": ["DragDrop", "Navigator", "ResizeObserver", "Stylesheet"],
|
7
|
+
"themes" : ["neo-theme-dark", "neo-theme-light"]
|
7
8
|
}
|
@@ -33,8 +33,8 @@ class Viewport extends BaseViewport {
|
|
33
33
|
|
34
34
|
items: ['->', {
|
35
35
|
handler: 'up.onSwitchThemeButtonClick',
|
36
|
-
iconCls: 'fas fa-
|
37
|
-
text : '
|
36
|
+
iconCls: 'fas fa-sun',
|
37
|
+
text : 'Light Theme'
|
38
38
|
}]
|
39
39
|
}, {
|
40
40
|
module: TableContainer,
|
@@ -129,7 +129,7 @@ class Viewport extends BaseViewport {
|
|
129
129
|
onSwitchThemeButtonClick(data) {
|
130
130
|
let me = this,
|
131
131
|
button = data.component,
|
132
|
-
isDarkTheme = me.theme
|
132
|
+
isDarkTheme = me.theme !== 'neo-theme-light',
|
133
133
|
theme = isDarkTheme ? 'neo-theme-light' : 'neo-theme-dark';
|
134
134
|
|
135
135
|
button.set({
|
package/package.json
CHANGED
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.
|
265
|
+
* @default '8.9.1'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '8.
|
270
|
+
version: '8.9.1'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
package/src/component/Base.mjs
CHANGED
@@ -970,12 +970,24 @@ class Component extends Base {
|
|
970
970
|
*/
|
971
971
|
afterSetTheme(value, oldValue) {
|
972
972
|
if (value || oldValue !== undefined) {
|
973
|
-
let
|
973
|
+
let me = this,
|
974
|
+
{cls} = me,
|
975
|
+
needsUpdate = false;
|
974
976
|
|
975
|
-
|
976
|
-
|
977
|
+
if (oldValue && cls.includes(oldValue)) {
|
978
|
+
NeoArray.remove(cls, oldValue);
|
979
|
+
needsUpdate = true
|
980
|
+
}
|
977
981
|
|
978
|
-
|
982
|
+
// We do not need to add a DOM based CSS selector, in case the theme is already inherited
|
983
|
+
if (value !== me.parent?.theme) {
|
984
|
+
value && NeoArray.add(cls, value);
|
985
|
+
needsUpdate = true
|
986
|
+
}
|
987
|
+
|
988
|
+
if (needsUpdate) {
|
989
|
+
me.cls = cls
|
990
|
+
}
|
979
991
|
}
|
980
992
|
}
|
981
993
|
|
@@ -1672,7 +1684,7 @@ class Component extends Base {
|
|
1672
1684
|
* Convenience shortcut
|
1673
1685
|
* @param {String[]|String} id=this.id
|
1674
1686
|
* @param {String} appName=this.appName
|
1675
|
-
* @returns {Promise<Neo.util.Rectangle>}
|
1687
|
+
* @returns {Promise<Neo.util.Rectangle||Neo.util.Rectangle[]>}
|
1676
1688
|
*/
|
1677
1689
|
async getDomRect(id=this.id, appName=this.appName) {
|
1678
1690
|
let result = await Neo.main.DomAccess.getBoundingClientRect({appName, id, windowId: this.windowId});
|
@@ -1684,6 +1696,42 @@ class Component extends Base {
|
|
1684
1696
|
return Rectangle.clone(result)
|
1685
1697
|
}
|
1686
1698
|
|
1699
|
+
/**
|
1700
|
+
* In case you are sure a DOMRect exists, use getDomRect()
|
1701
|
+
* Otherwise you can wait for it using this method.
|
1702
|
+
* @example:
|
1703
|
+
* await this.render(true);
|
1704
|
+
* await this.waitForDomRect();
|
1705
|
+
* @param {Object} opts
|
1706
|
+
* @param {String} opts.appName=this.appName
|
1707
|
+
* @param {Number} opts.attempts=10 Reruns in case the rect height or width equals 0
|
1708
|
+
* @param {Number} opts.delay=50 Time in ms before checking again
|
1709
|
+
* @param {String[]|String} opts.id=this.id
|
1710
|
+
* @returns {Promise<Neo.util.Rectangle||Neo.util.Rectangle[]>}
|
1711
|
+
*/
|
1712
|
+
async waitForDomRect({appName=this.appName, attempts=10, delay=50, id=this.id}) {
|
1713
|
+
let me = this,
|
1714
|
+
result = await me.getDomRect(id, appName),
|
1715
|
+
reRun = false;
|
1716
|
+
|
1717
|
+
if (Array.isArray(result)) {
|
1718
|
+
result.forEach(rect => {
|
1719
|
+
if (rect.height < 1 || rect.width < 1) {
|
1720
|
+
reRun = true
|
1721
|
+
}
|
1722
|
+
})
|
1723
|
+
} else if (result.height < 1 || result.width < 1) {
|
1724
|
+
reRun = true
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
if (reRun && attempts > 0) {
|
1728
|
+
await me.timeout(delay);
|
1729
|
+
return await me.waitForDomRect({appName, attempts: attempts-1, delay, id})
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
return result
|
1733
|
+
}
|
1734
|
+
|
1687
1735
|
/**
|
1688
1736
|
* Honors different item roots for mount / render OPs
|
1689
1737
|
* @returns {String}
|
package/src/container/Base.mjs
CHANGED
@@ -216,6 +216,22 @@ class Container extends Component {
|
|
216
216
|
}
|
217
217
|
}
|
218
218
|
|
219
|
+
/**
|
220
|
+
* Triggered after the theme config got changed
|
221
|
+
* @param {String|null} value
|
222
|
+
* @param {String|null} oldValue
|
223
|
+
* @protected
|
224
|
+
*/
|
225
|
+
afterSetTheme(value, oldValue) {
|
226
|
+
super.afterSetTheme(value, oldValue);
|
227
|
+
|
228
|
+
value && this.items?.forEach(item => {
|
229
|
+
if (!Neo.isString(item)) {
|
230
|
+
item.theme = value
|
231
|
+
}
|
232
|
+
})
|
233
|
+
}
|
234
|
+
|
219
235
|
/**
|
220
236
|
* Triggered after the windowId config got changed
|
221
237
|
* @param {Number|null} value
|
package/src/dialog/Base.mjs
CHANGED
@@ -411,11 +411,23 @@ class Dialog extends Panel {
|
|
411
411
|
|
412
412
|
rect = await me.getDomRect(me.animateTargetId);
|
413
413
|
|
414
|
+
if (style.left || style.top) {
|
415
|
+
let tempStyle = {...style};
|
416
|
+
|
417
|
+
// Ensure that the initial mounting happens outside the visible area
|
418
|
+
delete style.left;
|
419
|
+
delete style.top;
|
420
|
+
|
421
|
+
me.style = style;
|
422
|
+
|
423
|
+
// Silent update & ensure that a given starting position won't get lost
|
424
|
+
me._style = style = tempStyle
|
425
|
+
}
|
426
|
+
|
414
427
|
// rendered outside the visible area
|
415
428
|
await me.render(true);
|
416
|
-
await me.timeout(150);
|
417
429
|
|
418
|
-
let [dialogRect, bodyRect] = await me.
|
430
|
+
let [dialogRect, bodyRect] = await me.waitForDomRect({id: [me.id, 'document.body']});
|
419
431
|
|
420
432
|
// Move to cover the animation target
|
421
433
|
await Neo.applyDeltas(appName, {
|