brew-js-react 0.5.6 → 0.6.0

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.
@@ -1,4 +1,4 @@
1
- /*! brew-js-react v0.5.6 | (c) misonou | https://misonou.github.io */
1
+ /*! brew-js-react v0.6.0 | (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__, __WEBPACK_EXTERNAL_MODULE__311__, __WEBPACK_EXTERNAL_MODULE__760__, __WEBPACK_EXTERNAL_MODULE__402__, __WEBPACK_EXTERNAL_MODULE__87__, __WEBPACK_EXTERNAL_MODULE__942__) => {
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
- /***/ 942:
31
+ /***/ 914:
32
32
  /***/ ((module) => {
33
33
 
34
34
  "use strict";
35
- module.exports = __WEBPACK_EXTERNAL_MODULE__942__;
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
- /***/ 311:
47
+ /***/ 33:
48
48
  /***/ ((module) => {
49
49
 
50
50
  "use strict";
51
- module.exports = __WEBPACK_EXTERNAL_MODULE__311__;
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__(311);
74
+ var ReactDOM = __webpack_require__(33);
75
75
  var ReactDOMClient;
76
76
 
77
77
  if (ReactDOM.createRoot) {
@@ -249,12 +249,10 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
249
249
  util_keys = _lib$util.keys,
250
250
  kv = _lib$util.kv,
251
251
  makeArray = _lib$util.makeArray,
252
- makeAsync = _lib$util.makeAsync,
253
252
  map = _lib$util.map,
254
253
  mapObject = _lib$util.mapObject,
255
254
  noop = _lib$util.noop,
256
255
  pick = _lib$util.pick,
257
- pipe = _lib$util.pipe,
258
256
  randomId = _lib$util.randomId,
259
257
  resolve = _lib$util.resolve,
260
258
  resolveAll = _lib$util.resolveAll,
@@ -262,13 +260,26 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
262
260
  setImmediateOnce = _lib$util.setImmediateOnce,
263
261
  single = _lib$util.single,
264
262
  throwNotFunction = _lib$util.throwNotFunction,
263
+ _throws = _lib$util["throws"],
265
264
  watch = _lib$util.watch,
266
265
  watchable = _lib$util.watchable;
267
266
 
268
- // EXTERNAL MODULE: external {"commonjs":"react","commonjs2":"react","amd":"react","root":["React"]}
267
+ // EXTERNAL MODULE: external {"commonjs":"react","commonjs2":"react","amd":"react","root":"React"}
269
268
  var external_commonjs_react_commonjs2_react_amd_react_root_React_ = __webpack_require__(12);
270
- // EXTERNAL MODULE: external {"commonjs":"react-dom","commonjs2":"react-dom","amd":"react-dom","root":["ReactDOM"]}
271
- var external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_ = __webpack_require__(311);
269
+ ;// CONCATENATED MODULE: ./|umd|/react.js
270
+
271
+ var Component = external_commonjs_react_commonjs2_react_amd_react_root_React_.Component,
272
+ Fragment = external_commonjs_react_commonjs2_react_amd_react_root_React_.Fragment,
273
+ createContext = external_commonjs_react_commonjs2_react_amd_react_root_React_.createContext,
274
+ createElement = external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement,
275
+ useContext = external_commonjs_react_commonjs2_react_amd_react_root_React_.useContext,
276
+ useEffect = external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect,
277
+ useMemo = external_commonjs_react_commonjs2_react_amd_react_root_React_.useMemo,
278
+ useRef = external_commonjs_react_commonjs2_react_amd_react_root_React_.useRef,
279
+ useState = external_commonjs_react_commonjs2_react_amd_react_root_React_.useState;
280
+
281
+ // EXTERNAL MODULE: external {"commonjs":"react-dom","commonjs2":"react-dom","amd":"react-dom","root":"ReactDOM"}
282
+ var external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_ = __webpack_require__(33);
272
283
  // EXTERNAL MODULE: ./node_modules/@misonou/react-dom-client/fallback.js
273
284
  var fallback = __webpack_require__(621);
274
285
  ;// CONCATENATED MODULE: ./|umd|/zeta-dom/domUtil.js
@@ -284,12 +295,15 @@ var domUtil_lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_do
284
295
 
285
296
  var dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.dom;
286
297
  /* harmony default export */ const zeta_dom_dom = (dom);
298
+ var reportError = dom.reportError;
299
+
287
300
  ;// CONCATENATED MODULE: ./|umd|/zeta-dom/domLock.js
288
301
 
289
302
  var _lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.dom,
290
303
  lock = _lib$dom.lock,
291
304
  notifyAsync = _lib$dom.notifyAsync,
292
305
  preventLeave = _lib$dom.preventLeave,
306
+ runAsync = _lib$dom.runAsync,
293
307
  subscribeAsync = _lib$dom.subscribeAsync;
294
308
 
295
309
  // EXTERNAL MODULE: external {"commonjs":"brew-js","commonjs2":"brew-js","amd":"brew-js","root":"brew"}
@@ -316,7 +330,7 @@ var closeFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_b
316
330
  function createDialog(props) {
317
331
  var root = document.createElement('div');
318
332
  var reactRoot = fallback.createRoot(root);
319
- var _closeDialog = closeFlyout.bind(0, root);
333
+ var closeDialog = closeFlyout.bind(0, root);
320
334
  var promise;
321
335
  zeta_dom_dom.on(root, {
322
336
  flyoutshow: function flyoutshow() {
@@ -335,7 +349,7 @@ function createDialog(props) {
335
349
  subscribeAsync(root, true);
336
350
  return {
337
351
  root: root,
338
- close: _closeDialog,
352
+ close: closeDialog,
339
353
  open: function open() {
340
354
  if (promise) {
341
355
  return promise;
@@ -348,15 +362,13 @@ function createDialog(props) {
348
362
  }
349
363
  if (props.onRender) {
350
364
  var dialogProps = extend({}, props, {
351
- closeDialog: function closeDialog(value) {
352
- var promise = makeAsync(props.onCommit || pipe)(value);
353
- notifyAsync(zeta_dom_dom.activeElement, promise);
354
- return promise.then(_closeDialog);
355
- }
365
+ closeDialog: props.onCommit ? function (value) {
366
+ return runAsync(zeta_dom_dom.activeElement, props.onCommit.bind(this, value)).then(closeDialog);
367
+ } : closeDialog
356
368
  });
357
- var content = /*#__PURE__*/(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement)(props.onRender, dialogProps);
369
+ var content = /*#__PURE__*/createElement(props.onRender, dialogProps);
358
370
  if (props.wrapper) {
359
- content = /*#__PURE__*/(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement)(props.wrapper, dialogProps, content);
371
+ content = /*#__PURE__*/createElement(props.wrapper, dialogProps, content);
360
372
  }
361
373
  reactRoot.render(content);
362
374
  }
@@ -377,12 +389,12 @@ function createDialog(props) {
377
389
  * @param {import("./dialog").DialogProps} props
378
390
  */
379
391
  function Dialog(props) {
380
- var _props = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)({})[0];
381
- var dialog = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
392
+ var _props = useState({})[0];
393
+ var dialog = useState(function () {
382
394
  return createDialog(_props);
383
395
  })[0];
384
396
  extend(_props, props);
385
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
397
+ useEffect(function () {
386
398
  var opened = containsOrEquals(zeta_dom_dom.root, dialog.root);
387
399
  if (either(opened, _props.isOpen)) {
388
400
  if (!opened) {
@@ -392,13 +404,23 @@ function Dialog(props) {
392
404
  }
393
405
  }
394
406
  }, [_props.isOpen]);
395
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
407
+ useEffect(function () {
396
408
  return dialog.close;
397
409
  }, [dialog]);
398
410
  return /*#__PURE__*/external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.createPortal(props.children, dialog.root);
399
411
  }
400
412
  // EXTERNAL MODULE: external {"commonjs":"zeta-dom-react","commonjs2":"zeta-dom-react","amd":"zeta-dom-react","root":["zeta","react"]}
401
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
+ useValueTrigger = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useValueTrigger;
423
+
402
424
  ;// CONCATENATED MODULE: ./|umd|/zeta-dom/events.js
403
425
 
404
426
  var EventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.EventContainer;
@@ -465,7 +487,7 @@ var rootContext = freeze(extend(new ViewContext(), {
465
487
  container: root
466
488
  }));
467
489
  var rootState = _(rootContext);
468
- var StateContext = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createContext(rootContext);
490
+ var StateContext = /*#__PURE__*/createContext(rootContext);
469
491
  var errorView;
470
492
  /** @type {Partial<Zeta.ZetaEventType<"beforepageload", Brew.RouterEventMap, Element>>} */
471
493
  var view_event = {};
@@ -504,14 +526,17 @@ function ViewContext(view, page, parent) {
504
526
  });
505
527
  watch(self, 'page', function (page, previousPage) {
506
528
  emitter.emit('pagechange', self, {
507
- previousPage: previousPage
529
+ page: page,
530
+ previousPage: previousPage,
531
+ navigationType: view_event.navigationType,
532
+ waitFor: view_event.waitFor
508
533
  });
509
534
  });
510
535
  }
511
536
  definePrototype(ViewContext, {
512
537
  getChildren: function getChildren() {
513
538
  return map(_(this).children, function (v) {
514
- return v.currentState;
539
+ return v.currentContext;
515
540
  });
516
541
  },
517
542
  on: function on(event, handler) {
@@ -519,11 +544,11 @@ definePrototype(ViewContext, {
519
544
  }
520
545
  });
521
546
  function ErrorBoundary() {
522
- external_commonjs_react_commonjs2_react_amd_react_root_React_.Component.apply(this, arguments);
547
+ Component.apply(this, arguments);
523
548
  this.state = {};
524
549
  }
525
550
  ErrorBoundary.contextType = StateContext;
526
- definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react_root_React_.Component, {
551
+ definePrototype(ErrorBoundary, Component, {
527
552
  componentDidCatch: function componentDidCatch(error) {
528
553
  var self = this;
529
554
  if (errorView && !self.state.error) {
@@ -534,9 +559,7 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
534
559
  // emit error in next tick as ref callback may yet to be invoked
535
560
  // if error is thrown synchronously in first render
536
561
  setImmediate(function () {
537
- zeta_dom_dom.emit('error', self.context.container, {
538
- error: error
539
- }, true);
562
+ reportError(error, self.context.container);
540
563
  });
541
564
  // ensure promise sent to beforepageload event is resolved
542
565
  self.props.onComponentLoaded();
@@ -551,12 +574,12 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
551
574
  };
552
575
  var onComponentLoaded = self.props.onComponentLoaded;
553
576
  if (props.error) {
554
- return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(errorView, {
577
+ return /*#__PURE__*/createElement(errorView, {
555
578
  onComponentLoaded: onComponentLoaded,
556
579
  viewProps: props
557
580
  });
558
581
  }
559
- return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(props.view, {
582
+ return /*#__PURE__*/createElement(props.view, {
560
583
  onComponentLoaded: onComponentLoaded,
561
584
  viewProps: self.props.viewProps
562
585
  });
@@ -568,10 +591,10 @@ definePrototype(ErrorBoundary, external_commonjs_react_commonjs2_react_amd_react
568
591
  }
569
592
  });
570
593
  function ViewContainer() {
571
- external_commonjs_react_commonjs2_react_amd_react_root_React_.Component.apply(this, arguments);
594
+ Component.apply(this, arguments);
572
595
  }
573
596
  ViewContainer.contextType = StateContext;
574
- definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react_root_React_.Component, {
597
+ definePrototype(ViewContainer, Component, {
575
598
  setActive: noop,
576
599
  componentDidMount: function componentDidMount() {
577
600
  var self = this;
@@ -584,7 +607,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
584
607
  arrRemove(parent, self);
585
608
  unwatch();
586
609
  setImmediate(function () {
587
- if (self.unmountView && !self.currentState.active) {
610
+ if (self.unmountView && !self.currentContext.active) {
588
611
  self.unmountView();
589
612
  }
590
613
  });
@@ -599,7 +622,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
599
622
  self.updateView();
600
623
  }
601
624
  (self.onRender || noop)();
602
- return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(external_commonjs_react_commonjs2_react_amd_react_root_React_.Fragment, null, self.prevView, self.currentView);
625
+ return /*#__PURE__*/createElement(Fragment, null, self.prevView, self.currentView);
603
626
  },
604
627
  updateView: function updateView() {
605
628
  var self = this;
@@ -616,20 +639,21 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
616
639
  }
617
640
  if (V && viewChanged) {
618
641
  (self.unmountView || noop)(true);
619
- var state = new ViewContext(V, app_app.page, self.context);
642
+ var context = new ViewContext(V, app_app.page, self.context);
643
+ var state = routeMap.get(V);
620
644
  var onComponentLoaded;
621
645
  var promise = new Promise(function (resolve) {
622
646
  onComponentLoaded = resolve;
623
647
  });
624
648
  var unmountView = onComponentLoaded;
625
649
  var initElement = executeOnce(function (element) {
626
- state.container = element;
650
+ context.container = element;
627
651
  promise.then(function () {
628
- if (self.currentState === state) {
652
+ if (self.currentContext === context) {
629
653
  unmountView = function unmountView() {
630
654
  self.prevView = self.currentView;
631
655
  app_app.emit('pageleave', element, {
632
- pathname: state.page.path,
656
+ pathname: context.page.path,
633
657
  view: V
634
658
  }, true);
635
659
  animateOut(element, 'show').then(function () {
@@ -639,39 +663,41 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
639
663
  };
640
664
  animateIn(element, 'show', '[brew-view]', true);
641
665
  app_app.emit('pageenter', element, {
642
- pathname: state.page.path,
666
+ pathname: context.page.path,
643
667
  view: V
644
668
  }, true);
645
669
  }
646
670
  });
647
671
  notifyAsync(element, promise);
648
672
  });
649
- var viewProps = freeze({
650
- navigationType: view_event.navigationType,
651
- viewContext: state,
652
- viewData: view_event.data || {}
653
- });
654
- var view = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(StateContext.Provider, {
655
- key: routeMap.get(V).id,
656
- value: state
657
- }, /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewStateContainer, null, /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement('div', extend({}, self.props.rootProps, {
673
+ var viewProps = function viewProps() {
674
+ return freeze({
675
+ navigationType: view_event.navigationType,
676
+ viewContext: context,
677
+ viewData: context.page.data || {}
678
+ });
679
+ };
680
+ var view = /*#__PURE__*/createElement(StateContext.Provider, {
681
+ key: state.id,
682
+ value: context
683
+ }, /*#__PURE__*/createElement(ViewStateContainer, null, /*#__PURE__*/createElement('div', extend({}, self.props.rootProps, {
658
684
  ref: initElement,
659
685
  'brew-view': ''
660
- }), /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ErrorBoundary, {
686
+ }), /*#__PURE__*/createElement(ErrorBoundary, {
661
687
  onComponentLoaded: onComponentLoaded,
662
688
  viewProps: viewProps
663
689
  }))));
664
- extend(self, _(state), {
665
- currentState: state,
690
+ extend(self, _(context), {
691
+ currentContext: context,
666
692
  currentView: view,
667
693
  currentViewComponent: V,
668
694
  unmountView: executeOnce(function () {
669
695
  self.setActive(false);
670
- routeMap.get(V).rendered--;
696
+ state.rendered--;
671
697
  unmountView();
672
698
  })
673
699
  });
674
- routeMap.get(V).rendered++;
700
+ state.rendered++;
675
701
  (view_event.waitFor || noop)(promise);
676
702
  }
677
703
  (self.setPage || noop)(app_app.page);
@@ -727,24 +753,29 @@ function matchViewParams(view, route) {
727
753
  function createViewComponent(factory) {
728
754
  var promise;
729
755
  throwNotFunction(factory);
730
- if (factory.prototype instanceof external_commonjs_react_commonjs2_react_amd_react_root_React_.Component) {
731
- factory = external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement.bind(null, factory);
756
+ if (factory.prototype instanceof Component) {
757
+ factory = createElement.bind(null, factory);
732
758
  }
733
759
  return function fn(props) {
734
- var viewProps = props.viewProps;
735
- var children = !promise && factory(viewProps);
760
+ var viewContext = useContext(StateContext);
761
+ var viewProps = useState(props.viewProps);
762
+ var children = !promise && factory(viewProps[0]);
736
763
  if (isThenable(children)) {
737
764
  promise = children;
738
765
  children = null;
739
766
  catchAsync(promise);
740
767
  }
741
- var state = (0,external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useAsync)(function () {
742
- return promise.then(function (s) {
743
- return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(s["default"], viewProps);
744
- });
768
+ var state = useAsync(function () {
769
+ return promise;
745
770
  }, !!promise)[1];
746
771
  var loaded = !promise || !state.loading;
747
- external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect(function () {
772
+ useEffect(function () {
773
+ // listen to property directly so that it is invoked after pagechange event handlers in actual component
774
+ return watch(viewContext, 'page', function () {
775
+ viewProps[1](props.viewProps);
776
+ });
777
+ }, []);
778
+ useEffect(function () {
748
779
  if (loaded) {
749
780
  setImmediate(props.onComponentLoaded);
750
781
  }
@@ -752,11 +783,11 @@ function createViewComponent(factory) {
752
783
  if (state.error) {
753
784
  throw state.error;
754
785
  }
755
- return children || state.value || /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(external_commonjs_react_commonjs2_react_amd_react_root_React_.Fragment);
786
+ return children || (state.value ? /*#__PURE__*/createElement(state.value["default"], viewProps[0]) : null);
756
787
  };
757
788
  }
758
789
  function useViewContext() {
759
- return external_commonjs_react_commonjs2_react_amd_react_root_React_.useContext(StateContext);
790
+ return useContext(StateContext);
760
791
  }
761
792
  function isViewMatched(view) {
762
793
  return matchViewParams(view, app_app.route);
@@ -810,7 +841,7 @@ function renderView() {
810
841
  }
811
842
  });
812
843
  views.sort(sortViews);
813
- return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, {
844
+ return /*#__PURE__*/createElement(ViewContainer, {
814
845
  rootProps: rootProps,
815
846
  views: views,
816
847
  defaultView: defaultView
@@ -888,7 +919,7 @@ function updateViewState(state, key, store) {
888
919
  }
889
920
  function useViewContextWithEffect(callback, deps) {
890
921
  var container = useViewContext();
891
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
922
+ useEffect(function () {
892
923
  return app_app.on('beforepageload popstate', function () {
893
924
  if (container.active) {
894
925
  callback(getCurrentStates());
@@ -901,7 +932,7 @@ function useAppReady() {
901
932
  return useAppReadyState().ready;
902
933
  }
903
934
  function useAppReadyState() {
904
- var readyState = (0,external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useObservableProperty)(app_app, 'readyState');
935
+ var readyState = useObservableProperty(app_app, 'readyState');
905
936
  return {
906
937
  ready: readyState === 'ready',
907
938
  error: readyState === 'error'
@@ -911,20 +942,15 @@ function useRouteParam(name, defaultValue) {
911
942
  var container = useViewContext();
912
943
  var params = container.page.params;
913
944
  var value = params[name] || '';
914
- var ref = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useRef)(value);
915
- var forceUpdate = (0,external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useUpdateTrigger)();
916
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
945
+ var notifyChange = useValueTrigger(value);
946
+ useEffect(function () {
917
947
  var setValue = function setValue() {
918
- var current = container.page.params[name] || '';
919
- if (current !== ref.current) {
920
- forceUpdate();
921
- }
948
+ notifyChange(container.page.params[name] || '');
922
949
  };
923
950
  // route parameter might be changed after state initialization and before useEffect hook is called
924
951
  setValue();
925
952
  return container.on('pagechange', setValue);
926
953
  }, [name]);
927
- ref.current = value;
928
954
  if (defaultValue && container.active && (!value || name === 'remainingSegments' && value === '/')) {
929
955
  app_app.navigate(app_app.route.getPath(extend({}, params, kv(name, defaultValue))), true);
930
956
  }
@@ -932,7 +958,7 @@ function useRouteParam(name, defaultValue) {
932
958
  }
933
959
  function useRouteState(key, defaultValue, snapshotOnUpdate) {
934
960
  var cur = getCurrentStates();
935
- var state = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(cur && cur.has(key) ? cur.get(key) : defaultValue);
961
+ var state = useState(cur && cur.has(key) ? cur.get(key) : defaultValue);
936
962
  var container = useViewContextWithEffect(function (cur) {
937
963
  state[1](function (oldValue) {
938
964
  return cur.has(key) ? cur.get(key) : (cur.set(key, oldValue), oldValue);
@@ -954,22 +980,20 @@ function useQueryParam(key, value, snapshotOnUpdate) {
954
980
  }
955
981
  var container = useViewContext();
956
982
  var getParams = function getParams() {
957
- return mapObject(key === false ? value : kv(key, value), function (v, i) {
983
+ return freeze(mapObject(key === false ? value : kv(key, value), function (v, i) {
958
984
  return getQueryParam(i, app_app.path) || v || '';
959
- });
985
+ }));
960
986
  };
961
- var state = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)([]);
962
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useMemo)(function () {
963
- state[0].splice(0, 2, getParams());
987
+ var ref = useRef({});
988
+ useMemo(function () {
989
+ ref.current = getParams();
964
990
  }, [key]);
965
- var current = state[0][0];
966
- var trackChanges = function trackChanges(values) {
967
- if (!equal(values, current)) {
968
- extend(current, values);
969
- state[1]([current]);
970
- }
971
- };
972
- var setParams = (0,external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useMemoizedFunction)(function (values) {
991
+ var current = ref.current;
992
+ var notifyChange = useValueTrigger(current, function (current, params) {
993
+ return equal(current, params) || !(ref.current = params);
994
+ });
995
+ var setParams = useMemoizedFunction(function (values) {
996
+ var current = ref.current;
973
997
  if (key !== false) {
974
998
  values = kv(key, isFunction(values) ? values(current[key]) : values);
975
999
  } else if (isFunction(values)) {
@@ -984,28 +1008,28 @@ function useQueryParam(key, value, snapshotOnUpdate) {
984
1008
  if (snapshotOnUpdate) {
985
1009
  app_app.snapshot();
986
1010
  }
987
- catchAsync(app_app.navigate(search + url.hash, true));
988
- trackChanges(getParams());
1011
+ catchAsync(app_app.navigate((search || '?') + url.hash, true));
1012
+ notifyChange(getParams());
989
1013
  }
990
1014
  }
991
1015
  });
992
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
1016
+ useEffect(function () {
993
1017
  return app_app.watch('path', function () {
994
1018
  if (container.active) {
995
- trackChanges(getParams());
1019
+ notifyChange(getParams());
996
1020
  }
997
1021
  });
998
1022
  }, [key]);
999
- return [key !== false ? current[key] : state[0][1] || (state[0][1] = freeze(extend({}, current))), setParams];
1023
+ return [key !== false ? current[key] : current, setParams];
1000
1024
  }
1001
1025
  function ViewStateContainer(props) {
1002
- var cache = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)({})[0];
1026
+ var cache = useState({})[0];
1003
1027
  var container = useViewContextWithEffect(function (cur) {
1004
1028
  each(cache, function (i, v) {
1005
1029
  updateViewState(v, v.key, cur);
1006
1030
  });
1007
1031
  }, []);
1008
- var provider = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1032
+ var provider = useState(function () {
1009
1033
  return {
1010
1034
  getState: function getState(uniqueId, key) {
1011
1035
  var state = cache[uniqueId];
@@ -1018,7 +1042,7 @@ function ViewStateContainer(props) {
1018
1042
  }
1019
1043
  };
1020
1044
  })[0];
1021
- return /*#__PURE__*/(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement)(external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.ViewStateProvider, {
1045
+ return /*#__PURE__*/createElement(ViewStateProvider, {
1022
1046
  value: provider
1023
1047
  }, props.children);
1024
1048
  }
@@ -1056,7 +1080,7 @@ function createCallback(translate) {
1056
1080
  });
1057
1081
  }
1058
1082
  function useLanguage() {
1059
- return (0,external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useObservableProperty)(app_app, 'language');
1083
+ return useObservableProperty(app_app, 'language');
1060
1084
  }
1061
1085
  function makeTranslation(resources, defaultLang) {
1062
1086
  var re = new RegExp('^(' + Object.keys(resources[defaultLang]).join('|') + ')\\.');
@@ -1178,7 +1202,7 @@ util_define(Mixin, {
1178
1202
  });
1179
1203
  extend(props, {
1180
1204
  ref: combineFn(refs),
1181
- className: external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.classNames.apply(null, args)
1205
+ className: classNames.apply(null, args)
1182
1206
  });
1183
1207
  each(mixins, function (i, v) {
1184
1208
  v.next();
@@ -1196,6 +1220,22 @@ var observe_lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom
1196
1220
 
1197
1221
 
1198
1222
  var StatefulMixin_ = createPrivateStore();
1223
+ var unmounted = new Set();
1224
+ function disposeUnmountedStates() {
1225
+ each(unmounted, function (i, v) {
1226
+ combineFn(StatefulMixin_(v).splice(0))();
1227
+ });
1228
+ unmounted.clear();
1229
+ }
1230
+ function MixinState(parent, element) {
1231
+ StatefulMixin_(this, [parent["delete"].bind(parent, element)]);
1232
+ parent.set(element, this);
1233
+ }
1234
+ definePrototype(MixinState, {
1235
+ onDispose: function onDispose(callback) {
1236
+ StatefulMixin_(this).push(throwNotFunction(callback));
1237
+ }
1238
+ });
1199
1239
  function MixinRefImpl(mixin) {
1200
1240
  this.mixin = mixin;
1201
1241
  }
@@ -1207,8 +1247,9 @@ definePrototype(MixinRefImpl, {
1207
1247
  function StatefulMixin() {
1208
1248
  Mixin.call(this);
1209
1249
  StatefulMixin_(this, {
1210
- elements: new Set(),
1211
- states: new WeakMap(),
1250
+ pending: {},
1251
+ elements: [],
1252
+ states: new Map(),
1212
1253
  flush: watch(this, false),
1213
1254
  dispose: []
1214
1255
  });
@@ -1233,36 +1274,37 @@ definePrototype(StatefulMixin, Mixin, {
1233
1274
  var self = this;
1234
1275
  var obj = StatefulMixin_(self);
1235
1276
  var newState = obj.pending;
1236
- var state;
1277
+ var element, state;
1237
1278
  return function (current) {
1238
1279
  if (current) {
1239
- state = obj.states.get(current) || extend(self.initState(), newState);
1240
- if (state.element !== current) {
1241
- state.element = current;
1242
- self.initElement(current, state);
1243
- obj.states.set(current, state);
1280
+ element = current;
1281
+ state = obj.states.get(element) || new MixinState(obj.states, element);
1282
+ obj.elements.push(element);
1283
+ if (!state.element) {
1284
+ self.initElement(element, extend(state, self.initState(), newState, {
1285
+ element: element
1286
+ }));
1244
1287
  } else if (util_keys(newState)[0]) {
1245
- self.mergeState(current, state, newState);
1288
+ self.mergeState(element, state, newState);
1246
1289
  }
1247
- self.onLayoutEffect(current, state);
1248
- obj.elements.add(current);
1290
+ self.onLayoutEffect(element, state);
1291
+ unmounted["delete"](state);
1249
1292
  } else if (state) {
1250
- var prev = state.element;
1251
- self.onBeforeUpdate(prev, state);
1252
- obj.elements["delete"](prev);
1293
+ unmounted.add(state);
1294
+ self.onBeforeUpdate(element, state);
1295
+ arrRemove(obj.elements, element);
1253
1296
  }
1297
+ setImmediateOnce(disposeUnmountedStates);
1254
1298
  };
1255
1299
  },
1256
1300
  elements: function elements() {
1257
- return map(StatefulMixin_(this).elements, pipe);
1301
+ return StatefulMixin_(this).elements.slice();
1258
1302
  },
1259
1303
  onDispose: function onDispose(callback) {
1260
1304
  StatefulMixin_(this).dispose.push(callback);
1261
1305
  },
1262
1306
  initState: function initState() {
1263
- return {
1264
- element: null
1265
- };
1307
+ return {};
1266
1308
  },
1267
1309
  initElement: function initElement(element, state) {},
1268
1310
  mergeState: function mergeState(element, state, newState) {
@@ -1275,9 +1317,12 @@ definePrototype(StatefulMixin, Mixin, {
1275
1317
  },
1276
1318
  dispose: function dispose() {
1277
1319
  var state = StatefulMixin_(this);
1320
+ each(state.states, function (i, v) {
1321
+ unmounted.add(v);
1322
+ });
1323
+ setImmediateOnce(disposeUnmountedStates);
1278
1324
  combineFn(state.dispose.splice(0))();
1279
1325
  state.flush();
1280
- state.states = {};
1281
1326
  state.pending = {};
1282
1327
  }
1283
1328
  });
@@ -1302,18 +1347,13 @@ function ClassNameMixin(classNames) {
1302
1347
  this.classNames = classNames || [];
1303
1348
  }
1304
1349
  definePrototype(ClassNameMixin, StatefulMixin, {
1305
- initState: function initState() {
1306
- return {
1307
- element: null,
1308
- classNames: fill(this.classNames, false)
1309
- };
1310
- },
1311
1350
  initElement: function initElement(element, state) {
1312
1351
  var self = this;
1352
+ state.classNames = fill(self.classNames, false);
1313
1353
  checkState(self, element, state);
1314
- watchOwnAttributes(element, 'class', function () {
1354
+ state.onDispose(watchOwnAttributes(element, 'class', function () {
1315
1355
  checkState(self, element, state, true);
1316
- });
1356
+ }).dispose);
1317
1357
  },
1318
1358
  onLayoutEffect: function onLayoutEffect(element, state) {
1319
1359
  setClass(element, state.classNames);
@@ -1373,8 +1413,8 @@ definePrototype(AnimateSequenceItemMixin, ClassNameMixin, {
1373
1413
  return [this.className].concat(AnimateSequenceItemMixinSuper.getClassNames.call(this));
1374
1414
  }
1375
1415
  });
1376
- // EXTERNAL MODULE: external {"commonjs":"jquery","commonjs2":"jquery","amd":"jquery","root":["jQuery"]}
1377
- var external_commonjs_jquery_commonjs2_jquery_amd_jquery_root_jQuery_ = __webpack_require__(942);
1416
+ // EXTERNAL MODULE: external {"commonjs":"jquery","commonjs2":"jquery","amd":"jquery","root":"jQuery"}
1417
+ var external_commonjs_jquery_commonjs2_jquery_amd_jquery_root_jQuery_ = __webpack_require__(914);
1378
1418
  ;// CONCATENATED MODULE: ./src/mixins/AnimateSequenceMixin.js
1379
1419
 
1380
1420
 
@@ -1406,9 +1446,9 @@ definePrototype(AnimateSequenceMixin, AnimateMixin, {
1406
1446
  var self = this;
1407
1447
  AnimateSequenceMixinSuper.initElement.call(self, element, state);
1408
1448
  if (self.selector) {
1409
- self.onDispose(watchElements(element, self.selector, function (addedNodes) {
1449
+ state.onDispose(watchElements(element, self.selector, function (addedNodes) {
1410
1450
  external_commonjs_jquery_commonjs2_jquery_amd_jquery_root_jQuery_(addedNodes).attr('is-animate-sequence', '');
1411
- }));
1451
+ }).dispose);
1412
1452
  }
1413
1453
  }
1414
1454
  });
@@ -1438,24 +1478,43 @@ definePrototype(ClassNameToggleMixin, StatefulMixin, {
1438
1478
 
1439
1479
 
1440
1480
 
1441
-
1442
1481
  var FlyoutToggleMixinSuper = ClassNameMixin.prototype;
1443
1482
  function FlyoutToggleMixin(mixin) {
1444
1483
  ClassNameMixin.call(this, ['target-opened']);
1445
1484
  this.flyoutMixin = mixin;
1446
1485
  }
1486
+ function triggerFlyoutAction(self, state, trigger, action, args) {
1487
+ if ((state.trigger || 'click') === trigger) {
1488
+ action.apply(self, args);
1489
+ }
1490
+ }
1447
1491
  definePrototype(FlyoutToggleMixin, ClassNameMixin, {
1492
+ on: function on(trigger) {
1493
+ this.state.trigger = trigger;
1494
+ return this;
1495
+ },
1448
1496
  open: function open(value, source) {
1449
1497
  return this.flyoutMixin.open(value, source);
1450
1498
  },
1451
1499
  close: function close(value) {
1452
1500
  return this.flyoutMixin.close(value);
1453
1501
  },
1502
+ toggle: function toggle(source) {
1503
+ return this.flyoutMixin.toggleSelf(source);
1504
+ },
1454
1505
  initElement: function initElement(element, state) {
1455
1506
  var self = this;
1456
1507
  FlyoutToggleMixinSuper.initElement.call(self, element, state);
1457
- self.onDispose(zeta_dom_dom.on(element, 'click', function () {
1458
- toggleFlyout(self.flyoutMixin.elements()[0], element, self.flyoutMixin.getOptions());
1508
+ state.onDispose(zeta_dom_dom.on(element, {
1509
+ focusin: function focusin() {
1510
+ triggerFlyoutAction(self, state, 'focus', self.open, [null, zeta_dom_dom.activeElement]);
1511
+ },
1512
+ focusout: function focusout() {
1513
+ triggerFlyoutAction(self, state, 'focus', self.close, []);
1514
+ },
1515
+ click: function click() {
1516
+ triggerFlyoutAction(self, state, 'click', self.toggle, [element]);
1517
+ }
1459
1518
  }));
1460
1519
  }
1461
1520
  });
@@ -1484,6 +1543,9 @@ function FlyoutMixin() {
1484
1543
  });
1485
1544
  }
1486
1545
  definePrototype(FlyoutMixin, ClassNameMixin, {
1546
+ get element() {
1547
+ return this.elements()[0] || null;
1548
+ },
1487
1549
  getOptions: function getOptions() {
1488
1550
  var self = this;
1489
1551
  var options = pick(self, ['closeOnBlur']);
@@ -1516,16 +1578,18 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1516
1578
  });
1517
1579
  },
1518
1580
  open: function open(value, source) {
1519
- return openFlyout(this.elements()[0], value, source, this.getOptions());
1581
+ return openFlyout(this.element, value, source, this.getOptions());
1520
1582
  },
1521
1583
  close: function close(value) {
1522
- return closeFlyout(this.elements()[0], value);
1584
+ return closeFlyout(this.element, value);
1585
+ },
1586
+ toggleSelf: function toggleSelf(source) {
1587
+ return toggleFlyout(this.element, source, this.getOptions());
1523
1588
  },
1524
1589
  onOpen: function onOpen(callback) {
1525
- var element = this.elements()[0];
1526
1590
  return this.onToggleState(function (opened) {
1527
1591
  if (opened) {
1528
- return callback(valueMap.get(element));
1592
+ callback(valueMap.get(this.element));
1529
1593
  }
1530
1594
  });
1531
1595
  },
@@ -1537,8 +1601,11 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1537
1601
  },
1538
1602
  initElement: function initElement(element, state) {
1539
1603
  var self = this;
1604
+ if (self.elements()[1]) {
1605
+ _throws('FlyoutMixin only supports single element');
1606
+ }
1540
1607
  FlyoutMixinSuper.initElement.call(self, element, state);
1541
- self.onDispose(app_app.on(element, {
1608
+ state.onDispose(app_app.on(element, {
1542
1609
  flyoutshow: function flyoutshow(e) {
1543
1610
  valueMap.set(element, e.data);
1544
1611
  self.isFlyoutOpened = true;
@@ -1582,7 +1649,7 @@ definePrototype(FocusStateMixin, StatefulMixin, {
1582
1649
  callback(arg || target);
1583
1650
  }
1584
1651
  };
1585
- this.onDispose(zeta_dom_dom.on(element, {
1652
+ state.onDispose(zeta_dom_dom.on(element, {
1586
1653
  focusin: function focusin(e) {
1587
1654
  state.focused = e.source;
1588
1655
  setClass(element, 'focused', e.source);
@@ -1621,7 +1688,7 @@ definePrototype(LoadingStateMixin, ClassNameMixin, {
1621
1688
  var self = this;
1622
1689
  LoadingStateMixinSuper.initElement.call(self, element, state);
1623
1690
  getDirectiveComponent(element).enableLoadingClass = true;
1624
- self.onDispose(subscribeAsync(element, function (loading) {
1691
+ state.onDispose(subscribeAsync(element, function (loading) {
1625
1692
  self.loading = loading || !!any(self.elements(), function (v) {
1626
1693
  return v !== element && getClass(v, 'loading') === true;
1627
1694
  });
@@ -1643,6 +1710,13 @@ function ScrollableMixin() {
1643
1710
  self.scrolling = false;
1644
1711
  }
1645
1712
  definePrototype(ScrollableMixin, ClassNameMixin, {
1713
+ get element() {
1714
+ return this.elements()[0] || null;
1715
+ },
1716
+ get contentElement() {
1717
+ var element = this.element;
1718
+ return element && getDirectiveComponent(element).scrollable.scrollTarget;
1719
+ },
1646
1720
  withOptions: function withOptions(options) {
1647
1721
  this.options = options;
1648
1722
  return this;
@@ -1663,8 +1737,11 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1663
1737
  },
1664
1738
  initElement: function initElement(element, state) {
1665
1739
  var self = this;
1740
+ if (self.elements()[1]) {
1741
+ _throws('ScrollableMixin only supports single element');
1742
+ }
1666
1743
  ScrollableMixinSuper.initElement.call(self, element, state);
1667
- self.onDispose(app_app.on(element, {
1744
+ state.onDispose(app_app.on(element, {
1668
1745
  scrollIndexChange: function scrollIndexChange(e) {
1669
1746
  self.pageIndex = e.newIndex;
1670
1747
  },
@@ -1679,7 +1756,7 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1679
1756
  });
1680
1757
  each('destroy enable disable setOptions setStickyPosition refresh scrollPadding stop scrollLeft scrollTop scrollBy scrollTo scrollByPage scrollToPage scrollToElement', function (i, v) {
1681
1758
  defineHiddenProperty(ScrollableMixin.prototype, v, function () {
1682
- var obj = getDirectiveComponent(this.elements()[0]);
1759
+ var obj = getDirectiveComponent(this.element);
1683
1760
  return obj.scrollable[v].apply(null, arguments);
1684
1761
  });
1685
1762
  });
@@ -1756,7 +1833,7 @@ var useScrollableMixin = /*#__PURE__*/createUseFunction(ScrollableMixin);
1756
1833
  var useScrollIntoViewMixin = /*#__PURE__*/createUseFunction(ScrollIntoViewMixin);
1757
1834
  var useUnmanagedClassNameMixin = /*#__PURE__*/createUseFunction(UnmanagedClassNameMixin);
1758
1835
  function useMixin(ctor) {
1759
- return (0,external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useSingleton)(function () {
1836
+ return useSingleton(function () {
1760
1837
  return new ctor();
1761
1838
  }).reset();
1762
1839
  }