brew-js-react 0.5.5 → 0.5.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/brew.d.ts +9 -0
- package/dist/brew-js-react.js +196 -84
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +2 -2
- package/dist/brew-js-react.min.js.map +1 -1
- package/hooks.d.ts +22 -0
- package/hooks.js +58 -3
- package/mixins/FlyoutMixin.d.ts +6 -0
- package/mixins/FlyoutMixin.js +16 -15
- package/mixins/FlyoutToggleMixin.d.ts +17 -0
- package/mixins/FlyoutToggleMixin.js +23 -3
- package/mixins/StatefulMixin.js +1 -0
- package/package.json +3 -3
- package/view.d.ts +20 -0
- package/view.js +41 -33
package/brew.d.ts
ADDED
package/dist/brew-js-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! brew-js-react v0.5.
|
|
1
|
+
/*! brew-js-react v0.5.7 | (c) misonou | https://misonou.github.io */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("zeta-dom"), require("react"), require("react-dom"), require("brew-js"), require("zeta-dom-react"), require("waterpipe"), require("jquery"));
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
exports["brew-js-react"] = factory(require("zeta-dom"), require("react"), require("react-dom"), require("brew-js"), require("zeta-dom-react"), require("waterpipe"), require("jquery"));
|
|
9
9
|
else
|
|
10
10
|
root["brew"] = root["brew"] || {}, root["brew"]["react"] = factory(root["zeta"], root["React"], root["ReactDOM"], root["brew"], root["zeta"]["react"], root["waterpipe"], root["jQuery"]);
|
|
11
|
-
})(self, (__WEBPACK_EXTERNAL_MODULE__231__, __WEBPACK_EXTERNAL_MODULE__12__,
|
|
11
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__231__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__33__, __WEBPACK_EXTERNAL_MODULE__760__, __WEBPACK_EXTERNAL_MODULE__402__, __WEBPACK_EXTERNAL_MODULE__87__, __WEBPACK_EXTERNAL_MODULE__914__) => {
|
|
12
12
|
return /******/ (() => { // webpackBootstrap
|
|
13
13
|
/******/ var __webpack_modules__ = ({
|
|
14
14
|
|
|
@@ -28,11 +28,11 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__760__;
|
|
|
28
28
|
|
|
29
29
|
/***/ }),
|
|
30
30
|
|
|
31
|
-
/***/
|
|
31
|
+
/***/ 914:
|
|
32
32
|
/***/ ((module) => {
|
|
33
33
|
|
|
34
34
|
"use strict";
|
|
35
|
-
module.exports =
|
|
35
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__914__;
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
38
38
|
|
|
@@ -44,11 +44,11 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
|
|
|
44
44
|
|
|
45
45
|
/***/ }),
|
|
46
46
|
|
|
47
|
-
/***/
|
|
47
|
+
/***/ 33:
|
|
48
48
|
/***/ ((module) => {
|
|
49
49
|
|
|
50
50
|
"use strict";
|
|
51
|
-
module.exports =
|
|
51
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__33__;
|
|
52
52
|
|
|
53
53
|
/***/ }),
|
|
54
54
|
|
|
@@ -71,7 +71,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__402__;
|
|
|
71
71
|
/***/ 621:
|
|
72
72
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
73
73
|
|
|
74
|
-
var ReactDOM = __webpack_require__(
|
|
74
|
+
var ReactDOM = __webpack_require__(33);
|
|
75
75
|
var ReactDOMClient;
|
|
76
76
|
|
|
77
77
|
if (ReactDOM.createRoot) {
|
|
@@ -205,6 +205,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
205
205
|
useLoadingStateMixin: () => (/* reexport */ useLoadingStateMixin),
|
|
206
206
|
useMixin: () => (/* reexport */ useMixin),
|
|
207
207
|
useMixinRef: () => (/* reexport */ useMixinRef),
|
|
208
|
+
useQueryParam: () => (/* reexport */ useQueryParam),
|
|
208
209
|
useRouteParam: () => (/* reexport */ useRouteParam),
|
|
209
210
|
useRouteState: () => (/* reexport */ useRouteState),
|
|
210
211
|
useScrollIntoViewMixin: () => (/* reexport */ useScrollIntoViewMixin),
|
|
@@ -250,6 +251,7 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
|
|
|
250
251
|
makeArray = _lib$util.makeArray,
|
|
251
252
|
makeAsync = _lib$util.makeAsync,
|
|
252
253
|
map = _lib$util.map,
|
|
254
|
+
mapObject = _lib$util.mapObject,
|
|
253
255
|
noop = _lib$util.noop,
|
|
254
256
|
pick = _lib$util.pick,
|
|
255
257
|
pipe = _lib$util.pipe,
|
|
@@ -263,10 +265,22 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
|
|
|
263
265
|
watch = _lib$util.watch,
|
|
264
266
|
watchable = _lib$util.watchable;
|
|
265
267
|
|
|
266
|
-
// EXTERNAL MODULE: external {"commonjs":"react","commonjs2":"react","amd":"react","root":
|
|
268
|
+
// EXTERNAL MODULE: external {"commonjs":"react","commonjs2":"react","amd":"react","root":"React"}
|
|
267
269
|
var external_commonjs_react_commonjs2_react_amd_react_root_React_ = __webpack_require__(12);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
;// CONCATENATED MODULE: ./|umd|/react.js
|
|
271
|
+
|
|
272
|
+
var Component = external_commonjs_react_commonjs2_react_amd_react_root_React_.Component,
|
|
273
|
+
Fragment = external_commonjs_react_commonjs2_react_amd_react_root_React_.Fragment,
|
|
274
|
+
createContext = external_commonjs_react_commonjs2_react_amd_react_root_React_.createContext,
|
|
275
|
+
createElement = external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement,
|
|
276
|
+
useContext = external_commonjs_react_commonjs2_react_amd_react_root_React_.useContext,
|
|
277
|
+
useEffect = external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect,
|
|
278
|
+
useMemo = external_commonjs_react_commonjs2_react_amd_react_root_React_.useMemo,
|
|
279
|
+
useRef = external_commonjs_react_commonjs2_react_amd_react_root_React_.useRef,
|
|
280
|
+
useState = external_commonjs_react_commonjs2_react_amd_react_root_React_.useState;
|
|
281
|
+
|
|
282
|
+
// EXTERNAL MODULE: external {"commonjs":"react-dom","commonjs2":"react-dom","amd":"react-dom","root":"ReactDOM"}
|
|
283
|
+
var external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_ = __webpack_require__(33);
|
|
270
284
|
// EXTERNAL MODULE: ./node_modules/@misonou/react-dom-client/fallback.js
|
|
271
285
|
var fallback = __webpack_require__(621);
|
|
272
286
|
;// CONCATENATED MODULE: ./|umd|/zeta-dom/domUtil.js
|
|
@@ -295,7 +309,6 @@ var external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_ = __webpa
|
|
|
295
309
|
;// CONCATENATED MODULE: ./|umd|/brew-js/domAction.js
|
|
296
310
|
|
|
297
311
|
var closeFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.closeFlyout,
|
|
298
|
-
isFlyoutOpen = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.isFlyoutOpen,
|
|
299
312
|
openFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.openFlyout,
|
|
300
313
|
toggleFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.toggleFlyout;
|
|
301
314
|
|
|
@@ -353,9 +366,9 @@ function createDialog(props) {
|
|
|
353
366
|
return promise.then(_closeDialog);
|
|
354
367
|
}
|
|
355
368
|
});
|
|
356
|
-
var content = /*#__PURE__*/
|
|
369
|
+
var content = /*#__PURE__*/createElement(props.onRender, dialogProps);
|
|
357
370
|
if (props.wrapper) {
|
|
358
|
-
content = /*#__PURE__*/
|
|
371
|
+
content = /*#__PURE__*/createElement(props.wrapper, dialogProps, content);
|
|
359
372
|
}
|
|
360
373
|
reactRoot.render(content);
|
|
361
374
|
}
|
|
@@ -376,12 +389,12 @@ function createDialog(props) {
|
|
|
376
389
|
* @param {import("./dialog").DialogProps} props
|
|
377
390
|
*/
|
|
378
391
|
function Dialog(props) {
|
|
379
|
-
var _props =
|
|
380
|
-
var dialog =
|
|
392
|
+
var _props = useState({})[0];
|
|
393
|
+
var dialog = useState(function () {
|
|
381
394
|
return createDialog(_props);
|
|
382
395
|
})[0];
|
|
383
396
|
extend(_props, props);
|
|
384
|
-
|
|
397
|
+
useEffect(function () {
|
|
385
398
|
var opened = containsOrEquals(zeta_dom_dom.root, dialog.root);
|
|
386
399
|
if (either(opened, _props.isOpen)) {
|
|
387
400
|
if (!opened) {
|
|
@@ -391,17 +404,37 @@ function Dialog(props) {
|
|
|
391
404
|
}
|
|
392
405
|
}
|
|
393
406
|
}, [_props.isOpen]);
|
|
394
|
-
|
|
407
|
+
useEffect(function () {
|
|
395
408
|
return dialog.close;
|
|
396
409
|
}, [dialog]);
|
|
397
410
|
return /*#__PURE__*/external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.createPortal(props.children, dialog.root);
|
|
398
411
|
}
|
|
399
412
|
// EXTERNAL MODULE: external {"commonjs":"zeta-dom-react","commonjs2":"zeta-dom-react","amd":"zeta-dom-react","root":["zeta","react"]}
|
|
400
413
|
var external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_ = __webpack_require__(402);
|
|
414
|
+
;// CONCATENATED MODULE: ./|umd|/zeta-dom-react.js
|
|
415
|
+
|
|
416
|
+
var ViewStateProvider = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.ViewStateProvider,
|
|
417
|
+
classNames = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.classNames,
|
|
418
|
+
useAsync = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useAsync,
|
|
419
|
+
useMemoizedFunction = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useMemoizedFunction,
|
|
420
|
+
useObservableProperty = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useObservableProperty,
|
|
421
|
+
useSingleton = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useSingleton,
|
|
422
|
+
useUpdateTrigger = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useUpdateTrigger;
|
|
423
|
+
|
|
401
424
|
;// CONCATENATED MODULE: ./|umd|/zeta-dom/events.js
|
|
402
425
|
|
|
403
426
|
var EventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.EventContainer;
|
|
404
427
|
|
|
428
|
+
;// CONCATENATED MODULE: ./|umd|/brew-js/util/common.js
|
|
429
|
+
|
|
430
|
+
var getQueryParam = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.getQueryParam,
|
|
431
|
+
setQueryParam = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.setQueryParam;
|
|
432
|
+
|
|
433
|
+
;// CONCATENATED MODULE: ./|umd|/brew-js/util/path.js
|
|
434
|
+
|
|
435
|
+
var parsePath = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.parsePath,
|
|
436
|
+
removeQueryAndHash = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.removeQueryAndHash;
|
|
437
|
+
|
|
405
438
|
;// CONCATENATED MODULE: ./|umd|/brew-js/app.js
|
|
406
439
|
|
|
407
440
|
/* harmony default export */ const app = ((/* unused pure expression or super */ null && (lib)));
|
|
@@ -433,10 +466,6 @@ brew_js_defaults.react = true;
|
|
|
433
466
|
var animateIn = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.animateIn,
|
|
434
467
|
animateOut = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.animateOut;
|
|
435
468
|
|
|
436
|
-
;// CONCATENATED MODULE: ./|umd|/brew-js/util/path.js
|
|
437
|
-
|
|
438
|
-
var removeQueryAndHash = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.removeQueryAndHash;
|
|
439
|
-
|
|
440
469
|
;// CONCATENATED MODULE: ./src/view.js
|
|
441
470
|
|
|
442
471
|
|
|
@@ -458,7 +487,7 @@ var rootContext = freeze(extend(new ViewContext(), {
|
|
|
458
487
|
container: root
|
|
459
488
|
}));
|
|
460
489
|
var rootState = _(rootContext);
|
|
461
|
-
var StateContext = /*#__PURE__*/
|
|
490
|
+
var StateContext = /*#__PURE__*/createContext(rootContext);
|
|
462
491
|
var errorView;
|
|
463
492
|
/** @type {Partial<Zeta.ZetaEventType<"beforepageload", Brew.RouterEventMap, Element>>} */
|
|
464
493
|
var view_event = {};
|
|
@@ -497,7 +526,10 @@ function ViewContext(view, page, parent) {
|
|
|
497
526
|
});
|
|
498
527
|
watch(self, 'page', function (page, previousPage) {
|
|
499
528
|
emitter.emit('pagechange', self, {
|
|
500
|
-
|
|
529
|
+
page: page,
|
|
530
|
+
previousPage: previousPage,
|
|
531
|
+
navigationType: view_event.navigationType,
|
|
532
|
+
waitFor: view_event.waitFor
|
|
501
533
|
});
|
|
502
534
|
});
|
|
503
535
|
}
|
|
@@ -512,11 +544,11 @@ definePrototype(ViewContext, {
|
|
|
512
544
|
}
|
|
513
545
|
});
|
|
514
546
|
function ErrorBoundary() {
|
|
515
|
-
|
|
547
|
+
Component.apply(this, arguments);
|
|
516
548
|
this.state = {};
|
|
517
549
|
}
|
|
518
550
|
ErrorBoundary.contextType = StateContext;
|
|
519
|
-
definePrototype(ErrorBoundary,
|
|
551
|
+
definePrototype(ErrorBoundary, Component, {
|
|
520
552
|
componentDidCatch: function componentDidCatch(error) {
|
|
521
553
|
var self = this;
|
|
522
554
|
if (errorView && !self.state.error) {
|
|
@@ -531,6 +563,8 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
|
|
|
531
563
|
error: error
|
|
532
564
|
}, true);
|
|
533
565
|
});
|
|
566
|
+
// ensure promise sent to beforepageload event is resolved
|
|
567
|
+
self.props.onComponentLoaded();
|
|
534
568
|
}
|
|
535
569
|
},
|
|
536
570
|
render: function render() {
|
|
@@ -542,12 +576,12 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
|
|
|
542
576
|
};
|
|
543
577
|
var onComponentLoaded = self.props.onComponentLoaded;
|
|
544
578
|
if (props.error) {
|
|
545
|
-
return /*#__PURE__*/
|
|
579
|
+
return /*#__PURE__*/createElement(errorView, {
|
|
546
580
|
onComponentLoaded: onComponentLoaded,
|
|
547
581
|
viewProps: props
|
|
548
582
|
});
|
|
549
583
|
}
|
|
550
|
-
return /*#__PURE__*/
|
|
584
|
+
return /*#__PURE__*/createElement(props.view, {
|
|
551
585
|
onComponentLoaded: onComponentLoaded,
|
|
552
586
|
viewProps: self.props.viewProps
|
|
553
587
|
});
|
|
@@ -559,10 +593,10 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
|
|
|
559
593
|
}
|
|
560
594
|
});
|
|
561
595
|
function ViewContainer() {
|
|
562
|
-
|
|
596
|
+
Component.apply(this, arguments);
|
|
563
597
|
}
|
|
564
598
|
ViewContainer.contextType = StateContext;
|
|
565
|
-
definePrototype(ViewContainer,
|
|
599
|
+
definePrototype(ViewContainer, Component, {
|
|
566
600
|
setActive: noop,
|
|
567
601
|
componentDidMount: function componentDidMount() {
|
|
568
602
|
var self = this;
|
|
@@ -590,7 +624,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
590
624
|
self.updateView();
|
|
591
625
|
}
|
|
592
626
|
(self.onRender || noop)();
|
|
593
|
-
return /*#__PURE__*/
|
|
627
|
+
return /*#__PURE__*/createElement(Fragment, null, self.prevView, self.currentView);
|
|
594
628
|
},
|
|
595
629
|
updateView: function updateView() {
|
|
596
630
|
var self = this;
|
|
@@ -599,7 +633,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
599
633
|
if (V && (viewChanged || !(self.children || '')[0])) {
|
|
600
634
|
// ensure the current path actually corresponds to the matched view
|
|
601
635
|
// when some views are not included in the list of allowed views
|
|
602
|
-
var targetPath = resolvePath(V,
|
|
636
|
+
var targetPath = resolvePath(V, app_app.route);
|
|
603
637
|
if (targetPath !== removeQueryAndHash(app_app.path)) {
|
|
604
638
|
app_app.navigate(targetPath, true);
|
|
605
639
|
return;
|
|
@@ -620,7 +654,8 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
620
654
|
unmountView = function unmountView() {
|
|
621
655
|
self.prevView = self.currentView;
|
|
622
656
|
app_app.emit('pageleave', element, {
|
|
623
|
-
pathname: state.page.path
|
|
657
|
+
pathname: state.page.path,
|
|
658
|
+
view: V
|
|
624
659
|
}, true);
|
|
625
660
|
animateOut(element, 'show').then(function () {
|
|
626
661
|
self.prevView = undefined;
|
|
@@ -629,7 +664,8 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
629
664
|
};
|
|
630
665
|
animateIn(element, 'show', '[brew-view]', true);
|
|
631
666
|
app_app.emit('pageenter', element, {
|
|
632
|
-
pathname: state.page.path
|
|
667
|
+
pathname: state.page.path,
|
|
668
|
+
view: V
|
|
633
669
|
}, true);
|
|
634
670
|
}
|
|
635
671
|
});
|
|
@@ -640,13 +676,13 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
640
676
|
viewContext: state,
|
|
641
677
|
viewData: view_event.data || {}
|
|
642
678
|
});
|
|
643
|
-
var view = /*#__PURE__*/
|
|
679
|
+
var view = /*#__PURE__*/createElement(StateContext.Provider, {
|
|
644
680
|
key: routeMap.get(V).id,
|
|
645
681
|
value: state
|
|
646
|
-
}, /*#__PURE__*/
|
|
682
|
+
}, /*#__PURE__*/createElement(ViewStateContainer, null, /*#__PURE__*/createElement('div', extend({}, self.props.rootProps, {
|
|
647
683
|
ref: initElement,
|
|
648
684
|
'brew-view': ''
|
|
649
|
-
}), /*#__PURE__*/
|
|
685
|
+
}), /*#__PURE__*/createElement(ErrorBoundary, {
|
|
650
686
|
onComponentLoaded: onComponentLoaded,
|
|
651
687
|
viewProps: viewProps
|
|
652
688
|
}))));
|
|
@@ -670,7 +706,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
670
706
|
return any(props.views, isViewMatched) || props.defaultView;
|
|
671
707
|
}
|
|
672
708
|
});
|
|
673
|
-
function getCurrentParams(view,
|
|
709
|
+
function getCurrentParams(view, params) {
|
|
674
710
|
var state = routeMap.get(view);
|
|
675
711
|
if (!state.maxParams) {
|
|
676
712
|
var matchers = exclude(state.matchers, ['remainingSegments']);
|
|
@@ -701,7 +737,7 @@ function getCurrentParams(view, includeAll, params) {
|
|
|
701
737
|
});
|
|
702
738
|
}
|
|
703
739
|
}
|
|
704
|
-
return pick(
|
|
740
|
+
return extend(pick(app_app.route, state.minParams), params && pick(params, state.maxParams), state.params);
|
|
705
741
|
}
|
|
706
742
|
function sortViews(a, b) {
|
|
707
743
|
return (routeMap.get(b) || {}).matchCount - (routeMap.get(a) || {}).matchCount;
|
|
@@ -716,8 +752,8 @@ function matchViewParams(view, route) {
|
|
|
716
752
|
function createViewComponent(factory) {
|
|
717
753
|
var promise;
|
|
718
754
|
throwNotFunction(factory);
|
|
719
|
-
if (factory.prototype instanceof
|
|
720
|
-
factory =
|
|
755
|
+
if (factory.prototype instanceof Component) {
|
|
756
|
+
factory = createElement.bind(null, factory);
|
|
721
757
|
}
|
|
722
758
|
return function fn(props) {
|
|
723
759
|
var viewProps = props.viewProps;
|
|
@@ -727,22 +763,25 @@ function createViewComponent(factory) {
|
|
|
727
763
|
children = null;
|
|
728
764
|
catchAsync(promise);
|
|
729
765
|
}
|
|
730
|
-
var state =
|
|
766
|
+
var state = useAsync(function () {
|
|
731
767
|
return promise.then(function (s) {
|
|
732
|
-
return /*#__PURE__*/
|
|
768
|
+
return /*#__PURE__*/createElement(s["default"], viewProps);
|
|
733
769
|
});
|
|
734
770
|
}, !!promise)[1];
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (
|
|
738
|
-
|
|
771
|
+
var loaded = !promise || !state.loading;
|
|
772
|
+
useEffect(function () {
|
|
773
|
+
if (loaded) {
|
|
774
|
+
setImmediate(props.onComponentLoaded);
|
|
739
775
|
}
|
|
776
|
+
}, [loaded]);
|
|
777
|
+
if (state.error) {
|
|
778
|
+
throw state.error;
|
|
740
779
|
}
|
|
741
|
-
return children || state.value || /*#__PURE__*/
|
|
780
|
+
return children || state.value || /*#__PURE__*/createElement(Fragment);
|
|
742
781
|
};
|
|
743
782
|
}
|
|
744
783
|
function useViewContext() {
|
|
745
|
-
return
|
|
784
|
+
return useContext(StateContext);
|
|
746
785
|
}
|
|
747
786
|
function isViewMatched(view) {
|
|
748
787
|
return matchViewParams(view, app_app.route);
|
|
@@ -796,19 +835,17 @@ function renderView() {
|
|
|
796
835
|
}
|
|
797
836
|
});
|
|
798
837
|
views.sort(sortViews);
|
|
799
|
-
return /*#__PURE__*/
|
|
838
|
+
return /*#__PURE__*/createElement(ViewContainer, {
|
|
800
839
|
rootProps: rootProps,
|
|
801
840
|
views: views,
|
|
802
841
|
defaultView: defaultView
|
|
803
842
|
});
|
|
804
843
|
}
|
|
805
844
|
function resolvePath(view, params) {
|
|
806
|
-
|
|
807
|
-
if (!state) {
|
|
845
|
+
if (!routeMap.has(view)) {
|
|
808
846
|
return '/';
|
|
809
847
|
}
|
|
810
|
-
|
|
811
|
-
return app_app.route.getPath(newParams);
|
|
848
|
+
return app_app.route.getPath(getCurrentParams(view, params));
|
|
812
849
|
}
|
|
813
850
|
function linkTo(view, params) {
|
|
814
851
|
return app_app.toHref(resolvePath(view, params));
|
|
@@ -827,6 +864,8 @@ function redirectTo(view, params, data) {
|
|
|
827
864
|
|
|
828
865
|
|
|
829
866
|
|
|
867
|
+
|
|
868
|
+
|
|
830
869
|
var hooks_emitter = new EventContainer();
|
|
831
870
|
function getCurrentStates() {
|
|
832
871
|
return app_app.historyStorage.current;
|
|
@@ -874,7 +913,7 @@ function updateViewState(state, key, store) {
|
|
|
874
913
|
}
|
|
875
914
|
function useViewContextWithEffect(callback, deps) {
|
|
876
915
|
var container = useViewContext();
|
|
877
|
-
|
|
916
|
+
useEffect(function () {
|
|
878
917
|
return app_app.on('beforepageload popstate', function () {
|
|
879
918
|
if (container.active) {
|
|
880
919
|
callback(getCurrentStates());
|
|
@@ -887,7 +926,7 @@ function useAppReady() {
|
|
|
887
926
|
return useAppReadyState().ready;
|
|
888
927
|
}
|
|
889
928
|
function useAppReadyState() {
|
|
890
|
-
var readyState =
|
|
929
|
+
var readyState = useObservableProperty(app_app, 'readyState');
|
|
891
930
|
return {
|
|
892
931
|
ready: readyState === 'ready',
|
|
893
932
|
error: readyState === 'error'
|
|
@@ -897,9 +936,9 @@ function useRouteParam(name, defaultValue) {
|
|
|
897
936
|
var container = useViewContext();
|
|
898
937
|
var params = container.page.params;
|
|
899
938
|
var value = params[name] || '';
|
|
900
|
-
var ref =
|
|
901
|
-
var forceUpdate =
|
|
902
|
-
|
|
939
|
+
var ref = useRef(value);
|
|
940
|
+
var forceUpdate = useUpdateTrigger();
|
|
941
|
+
useEffect(function () {
|
|
903
942
|
var setValue = function setValue() {
|
|
904
943
|
var current = container.page.params[name] || '';
|
|
905
944
|
if (current !== ref.current) {
|
|
@@ -918,7 +957,7 @@ function useRouteParam(name, defaultValue) {
|
|
|
918
957
|
}
|
|
919
958
|
function useRouteState(key, defaultValue, snapshotOnUpdate) {
|
|
920
959
|
var cur = getCurrentStates();
|
|
921
|
-
var state =
|
|
960
|
+
var state = useState(cur && cur.has(key) ? cur.get(key) : defaultValue);
|
|
922
961
|
var container = useViewContextWithEffect(function (cur) {
|
|
923
962
|
state[1](function (oldValue) {
|
|
924
963
|
return cur.has(key) ? cur.get(key) : (cur.set(key, oldValue), oldValue);
|
|
@@ -932,14 +971,66 @@ function useRouteState(key, defaultValue, snapshotOnUpdate) {
|
|
|
932
971
|
}
|
|
933
972
|
return state;
|
|
934
973
|
}
|
|
974
|
+
function useQueryParam(key, value, snapshotOnUpdate) {
|
|
975
|
+
if (isPlainObject(key)) {
|
|
976
|
+
snapshotOnUpdate = value;
|
|
977
|
+
value = key;
|
|
978
|
+
key = false;
|
|
979
|
+
}
|
|
980
|
+
var container = useViewContext();
|
|
981
|
+
var getParams = function getParams() {
|
|
982
|
+
return mapObject(key === false ? value : kv(key, value), function (v, i) {
|
|
983
|
+
return getQueryParam(i, app_app.path) || v || '';
|
|
984
|
+
});
|
|
985
|
+
};
|
|
986
|
+
var state = useState([]);
|
|
987
|
+
useMemo(function () {
|
|
988
|
+
state[0].splice(0, 2, getParams());
|
|
989
|
+
}, [key]);
|
|
990
|
+
var current = state[0][0];
|
|
991
|
+
var trackChanges = function trackChanges(values) {
|
|
992
|
+
if (!equal(values, current)) {
|
|
993
|
+
extend(current, values);
|
|
994
|
+
state[1]([current]);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
var setParams = useMemoizedFunction(function (values) {
|
|
998
|
+
if (key !== false) {
|
|
999
|
+
values = kv(key, isFunction(values) ? values(current[key]) : values);
|
|
1000
|
+
} else if (isFunction(values)) {
|
|
1001
|
+
values = values(extend({}, current));
|
|
1002
|
+
}
|
|
1003
|
+
if (container.active) {
|
|
1004
|
+
var url = parsePath(app_app.path);
|
|
1005
|
+
var search = util_keys(values).reduce(function (v, i) {
|
|
1006
|
+
return values[i] !== current[i] ? setQueryParam(i, values[i] || null, v) : v;
|
|
1007
|
+
}, url.search);
|
|
1008
|
+
if (search !== url.search) {
|
|
1009
|
+
if (snapshotOnUpdate) {
|
|
1010
|
+
app_app.snapshot();
|
|
1011
|
+
}
|
|
1012
|
+
catchAsync(app_app.navigate(search + url.hash, true));
|
|
1013
|
+
trackChanges(getParams());
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
useEffect(function () {
|
|
1018
|
+
return app_app.watch('path', function () {
|
|
1019
|
+
if (container.active) {
|
|
1020
|
+
trackChanges(getParams());
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
}, [key]);
|
|
1024
|
+
return [key !== false ? current[key] : state[0][1] || (state[0][1] = freeze(extend({}, current))), setParams];
|
|
1025
|
+
}
|
|
935
1026
|
function ViewStateContainer(props) {
|
|
936
|
-
var cache =
|
|
1027
|
+
var cache = useState({})[0];
|
|
937
1028
|
var container = useViewContextWithEffect(function (cur) {
|
|
938
1029
|
each(cache, function (i, v) {
|
|
939
1030
|
updateViewState(v, v.key, cur);
|
|
940
1031
|
});
|
|
941
1032
|
}, []);
|
|
942
|
-
var provider =
|
|
1033
|
+
var provider = useState(function () {
|
|
943
1034
|
return {
|
|
944
1035
|
getState: function getState(uniqueId, key) {
|
|
945
1036
|
var state = cache[uniqueId];
|
|
@@ -952,7 +1043,7 @@ function ViewStateContainer(props) {
|
|
|
952
1043
|
}
|
|
953
1044
|
};
|
|
954
1045
|
})[0];
|
|
955
|
-
return /*#__PURE__*/
|
|
1046
|
+
return /*#__PURE__*/createElement(ViewStateProvider, {
|
|
956
1047
|
value: provider
|
|
957
1048
|
}, props.children);
|
|
958
1049
|
}
|
|
@@ -990,7 +1081,7 @@ function createCallback(translate) {
|
|
|
990
1081
|
});
|
|
991
1082
|
}
|
|
992
1083
|
function useLanguage() {
|
|
993
|
-
return
|
|
1084
|
+
return useObservableProperty(app_app, 'language');
|
|
994
1085
|
}
|
|
995
1086
|
function makeTranslation(resources, defaultLang) {
|
|
996
1087
|
var re = new RegExp('^(' + Object.keys(resources[defaultLang]).join('|') + ')\\.');
|
|
@@ -1112,7 +1203,7 @@ util_define(Mixin, {
|
|
|
1112
1203
|
});
|
|
1113
1204
|
extend(props, {
|
|
1114
1205
|
ref: combineFn(refs),
|
|
1115
|
-
className:
|
|
1206
|
+
className: classNames.apply(null, args)
|
|
1116
1207
|
});
|
|
1117
1208
|
each(mixins, function (i, v) {
|
|
1118
1209
|
v.next();
|
|
@@ -1141,6 +1232,7 @@ definePrototype(MixinRefImpl, {
|
|
|
1141
1232
|
function StatefulMixin() {
|
|
1142
1233
|
Mixin.call(this);
|
|
1143
1234
|
StatefulMixin_(this, {
|
|
1235
|
+
pending: {},
|
|
1144
1236
|
elements: new Set(),
|
|
1145
1237
|
states: new WeakMap(),
|
|
1146
1238
|
flush: watch(this, false),
|
|
@@ -1307,8 +1399,8 @@ definePrototype(AnimateSequenceItemMixin, ClassNameMixin, {
|
|
|
1307
1399
|
return [this.className].concat(AnimateSequenceItemMixinSuper.getClassNames.call(this));
|
|
1308
1400
|
}
|
|
1309
1401
|
});
|
|
1310
|
-
// EXTERNAL MODULE: external {"commonjs":"jquery","commonjs2":"jquery","amd":"jquery","root":
|
|
1311
|
-
var external_commonjs_jquery_commonjs2_jquery_amd_jquery_root_jQuery_ = __webpack_require__(
|
|
1402
|
+
// EXTERNAL MODULE: external {"commonjs":"jquery","commonjs2":"jquery","amd":"jquery","root":"jQuery"}
|
|
1403
|
+
var external_commonjs_jquery_commonjs2_jquery_amd_jquery_root_jQuery_ = __webpack_require__(914);
|
|
1312
1404
|
;// CONCATENATED MODULE: ./src/mixins/AnimateSequenceMixin.js
|
|
1313
1405
|
|
|
1314
1406
|
|
|
@@ -1372,24 +1464,43 @@ definePrototype(ClassNameToggleMixin, StatefulMixin, {
|
|
|
1372
1464
|
|
|
1373
1465
|
|
|
1374
1466
|
|
|
1375
|
-
|
|
1376
1467
|
var FlyoutToggleMixinSuper = ClassNameMixin.prototype;
|
|
1377
1468
|
function FlyoutToggleMixin(mixin) {
|
|
1378
1469
|
ClassNameMixin.call(this, ['target-opened']);
|
|
1379
1470
|
this.flyoutMixin = mixin;
|
|
1380
1471
|
}
|
|
1472
|
+
function triggerFlyoutAction(self, state, trigger, action, args) {
|
|
1473
|
+
if ((state.trigger || 'click') === trigger) {
|
|
1474
|
+
action.apply(self, args);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1381
1477
|
definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
1478
|
+
on: function on(trigger) {
|
|
1479
|
+
this.state.trigger = trigger;
|
|
1480
|
+
return this;
|
|
1481
|
+
},
|
|
1382
1482
|
open: function open(value, source) {
|
|
1383
1483
|
return this.flyoutMixin.open(value, source);
|
|
1384
1484
|
},
|
|
1385
1485
|
close: function close(value) {
|
|
1386
1486
|
return this.flyoutMixin.close(value);
|
|
1387
1487
|
},
|
|
1488
|
+
toggle: function toggle(source) {
|
|
1489
|
+
return this.flyoutMixin.toggleSelf(source);
|
|
1490
|
+
},
|
|
1388
1491
|
initElement: function initElement(element, state) {
|
|
1389
1492
|
var self = this;
|
|
1390
1493
|
FlyoutToggleMixinSuper.initElement.call(self, element, state);
|
|
1391
|
-
self.onDispose(zeta_dom_dom.on(element,
|
|
1392
|
-
|
|
1494
|
+
self.onDispose(zeta_dom_dom.on(element, {
|
|
1495
|
+
focusin: function focusin() {
|
|
1496
|
+
triggerFlyoutAction(self, state, 'focus', self.open, [null, zeta_dom_dom.activeElement]);
|
|
1497
|
+
},
|
|
1498
|
+
focusout: function focusout() {
|
|
1499
|
+
triggerFlyoutAction(self, state, 'focus', self.close, []);
|
|
1500
|
+
},
|
|
1501
|
+
click: function click() {
|
|
1502
|
+
triggerFlyoutAction(self, state, 'click', self.toggle, [element]);
|
|
1503
|
+
}
|
|
1393
1504
|
}));
|
|
1394
1505
|
}
|
|
1395
1506
|
});
|
|
@@ -1450,15 +1561,14 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1450
1561
|
});
|
|
1451
1562
|
},
|
|
1452
1563
|
open: function open(value, source) {
|
|
1453
|
-
|
|
1454
|
-
if (!isFlyoutOpen(element)) {
|
|
1455
|
-
valueMap.set(element, value);
|
|
1456
|
-
}
|
|
1457
|
-
return openFlyout(element, source, this.getOptions());
|
|
1564
|
+
return openFlyout(this.elements()[0], value, source, this.getOptions());
|
|
1458
1565
|
},
|
|
1459
1566
|
close: function close(value) {
|
|
1460
1567
|
return closeFlyout(this.elements()[0], value);
|
|
1461
1568
|
},
|
|
1569
|
+
toggleSelf: function toggleSelf(source) {
|
|
1570
|
+
return toggleFlyout(this.elements()[0], source, this.getOptions());
|
|
1571
|
+
},
|
|
1462
1572
|
onOpen: function onOpen(callback) {
|
|
1463
1573
|
var element = this.elements()[0];
|
|
1464
1574
|
return this.onToggleState(function (opened) {
|
|
@@ -1477,6 +1587,17 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1477
1587
|
var self = this;
|
|
1478
1588
|
FlyoutMixinSuper.initElement.call(self, element, state);
|
|
1479
1589
|
self.onDispose(app_app.on(element, {
|
|
1590
|
+
flyoutshow: function flyoutshow(e) {
|
|
1591
|
+
valueMap.set(element, e.data);
|
|
1592
|
+
self.isFlyoutOpened = true;
|
|
1593
|
+
self.visible = true;
|
|
1594
|
+
},
|
|
1595
|
+
flyoutclose: function flyoutclose() {
|
|
1596
|
+
self.isFlyoutOpened = false;
|
|
1597
|
+
},
|
|
1598
|
+
flyouthide: function flyouthide() {
|
|
1599
|
+
self.visible = false;
|
|
1600
|
+
},
|
|
1480
1601
|
animationstart: function animationstart() {
|
|
1481
1602
|
self.animating = true;
|
|
1482
1603
|
},
|
|
@@ -1484,15 +1605,6 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1484
1605
|
self.animating = false;
|
|
1485
1606
|
}
|
|
1486
1607
|
}, true));
|
|
1487
|
-
},
|
|
1488
|
-
onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {
|
|
1489
|
-
var self = this;
|
|
1490
|
-
var isFlyoutOpened = isFlyoutOpen(element);
|
|
1491
|
-
if (!isFlyoutOpened) {
|
|
1492
|
-
valueMap["delete"](element);
|
|
1493
|
-
}
|
|
1494
|
-
self.visible = state.open;
|
|
1495
|
-
self.isFlyoutOpened = isFlyoutOpened;
|
|
1496
1608
|
}
|
|
1497
1609
|
});
|
|
1498
1610
|
;// CONCATENATED MODULE: ./src/mixins/FocusStateMixin.js
|
|
@@ -1692,7 +1804,7 @@ var useScrollableMixin = /*#__PURE__*/createUseFunction(ScrollableMixin);
|
|
|
1692
1804
|
var useScrollIntoViewMixin = /*#__PURE__*/createUseFunction(ScrollIntoViewMixin);
|
|
1693
1805
|
var useUnmanagedClassNameMixin = /*#__PURE__*/createUseFunction(UnmanagedClassNameMixin);
|
|
1694
1806
|
function useMixin(ctor) {
|
|
1695
|
-
return
|
|
1807
|
+
return useSingleton(function () {
|
|
1696
1808
|
return new ctor();
|
|
1697
1809
|
}).reset();
|
|
1698
1810
|
}
|