brew-js-react 0.2.6 → 0.2.7
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/dist/brew-js-react.js +15 -7
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +1 -1
- package/dist/brew-js-react.min.js.map +1 -1
- package/package.json +1 -1
- package/view.js +8 -6
package/view.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
import { useAsync } from "zeta-dom-react";
|
|
2
|
+
import { combineRef, useAsync } from "zeta-dom-react";
|
|
3
3
|
import dom from "./include/zeta-dom/dom.js";
|
|
4
4
|
import { notifyAsync } from "./include/zeta-dom/domLock.js";
|
|
5
|
-
import { any, combineFn, defineObservableProperty, definePrototype, each, exclude, extend, grep, isFunction, keys, makeArray, map, noop, pick, randomId, setImmediate, single, watch } from "./include/zeta-dom/util.js";
|
|
5
|
+
import { any, combineFn, defineObservableProperty, definePrototype, each, exclude, executeOnce, extend, grep, isFunction, keys, makeArray, map, noop, pick, randomId, setImmediate, single, watch } from "./include/zeta-dom/util.js";
|
|
6
6
|
import { animateIn, animateOut } from "./include/brew-js/anim.js";
|
|
7
7
|
import { removeQueryAndHash } from "./include/brew-js/util/path.js";
|
|
8
8
|
import { app } from "./app.js";
|
|
@@ -27,7 +27,8 @@ definePrototype(ViewContainer, React.Component, {
|
|
|
27
27
|
watch(app.route, function () {
|
|
28
28
|
self.setActive(self.getViewComponent() === self.currentViewComponent);
|
|
29
29
|
}),
|
|
30
|
-
app.on('beforepageload', function () {
|
|
30
|
+
app.on('beforepageload', function (e) {
|
|
31
|
+
self.waitFor = e.waitFor;
|
|
31
32
|
self.stateId = history.state;
|
|
32
33
|
self.forceUpdate();
|
|
33
34
|
})
|
|
@@ -72,7 +73,7 @@ definePrototype(ViewContainer, React.Component, {
|
|
|
72
73
|
React.createElement(ViewStateContainer, null,
|
|
73
74
|
React.createElement(V, {
|
|
74
75
|
rootProps: self.props.rootProps,
|
|
75
|
-
onComponentLoaded: function (element) {
|
|
76
|
+
onComponentLoaded: executeOnce(function (element) {
|
|
76
77
|
self.currentElement = element;
|
|
77
78
|
self.parentElement = element.parentElement;
|
|
78
79
|
setImmediate(function () {
|
|
@@ -80,7 +81,7 @@ definePrototype(ViewContainer, React.Component, {
|
|
|
80
81
|
animateIn(element, 'show');
|
|
81
82
|
app.emit('pageenter', element, { pathname: app.path }, true);
|
|
82
83
|
});
|
|
83
|
-
}
|
|
84
|
+
})
|
|
84
85
|
})));
|
|
85
86
|
extend(self, {
|
|
86
87
|
currentPath: app.path,
|
|
@@ -88,6 +89,7 @@ definePrototype(ViewContainer, React.Component, {
|
|
|
88
89
|
currentViewComponent: V,
|
|
89
90
|
setActive: defineObservableProperty(state, 'active', true, true)
|
|
90
91
|
});
|
|
92
|
+
(self.waitFor || noop)(promise);
|
|
91
93
|
notifyAsync(self.parentElement || root, promise);
|
|
92
94
|
}
|
|
93
95
|
var child = React.createElement(React.Fragment, null, self.prevView, self.currentView);
|
|
@@ -173,7 +175,7 @@ export function registerView(factory, routeParams) {
|
|
|
173
175
|
(props.onComponentLoaded || noop)(ref.current);
|
|
174
176
|
}
|
|
175
177
|
return React.createElement('div', extend({}, props.rootProps, {
|
|
176
|
-
ref: ref,
|
|
178
|
+
ref: combineRef(ref, state[1].elementRef),
|
|
177
179
|
children: state[0] && React.createElement(state[0].default)
|
|
178
180
|
}));
|
|
179
181
|
};
|