brew-js-react 0.2.1 → 0.2.4

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/dialog.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
- import { always, either, extend, noop } from "./include/zeta-dom/util.js";
3
+ import { always, catchAsync, either, extend, noop, pipe, resolve } from "./include/zeta-dom/util.js";
4
4
  import { containsOrEquals, removeNode } from "./include/zeta-dom/domUtil.js";
5
5
  import dom from "./include/zeta-dom/dom.js";
6
+ import { lock } from "./include/zeta-dom/domLock.js";
6
7
  import { closeFlyout, openFlyout } from "./include/brew-js/domAction.js";
7
8
 
8
9
  /**
@@ -42,14 +43,19 @@ export function createDialog(props) {
42
43
  dom.setModal(root);
43
44
  }
44
45
  if (props.onRender) {
45
- ReactDOM.render(React.createElement(props.onRender, extend({ closeDialog }, props)), root);
46
+ var dialogProps = extend({}, props, {
47
+ closeDialog: function (value) {
48
+ var promise = resolve((props.onCommit || pipe)(value));
49
+ catchAsync(lock(dom.activeElement, promise));
50
+ promise.then(closeDialog);
51
+ }
52
+ });
53
+ ReactDOM.render(React.createElement(props.onRender, dialogProps), root);
46
54
  }
47
-
48
55
  promise = openFlyout(root);
49
56
  always(promise, function () {
50
57
  promise = null;
51
58
  });
52
- promise.then(props.onCommit);
53
59
  (props.onOpen || noop)(root);
54
60
  return promise;
55
61
  }
@@ -181,6 +181,7 @@ __webpack_require__.d(src_namespaceObject, {
181
181
  "isViewMatched": () => (isViewMatched),
182
182
  "linkTo": () => (linkTo),
183
183
  "makeTranslation": () => (makeTranslation),
184
+ "matchView": () => (matchView),
184
185
  "navigateTo": () => (navigateTo),
185
186
  "redirectTo": () => (redirectTo),
186
187
  "registerView": () => (registerView),
@@ -261,7 +262,7 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
261
262
  setImmediateOnce = _lib$util.setImmediateOnce,
262
263
  throwNotFunction = _lib$util.throwNotFunction,
263
264
  errorWithCode = _lib$util.errorWithCode,
264
- keys = _lib$util.keys,
265
+ util_keys = _lib$util.keys,
265
266
  values = _lib$util.values,
266
267
  util_hasOwnProperty = _lib$util.hasOwnProperty,
267
268
  getOwnPropertyDescriptors = _lib$util.getOwnPropertyDescriptors,
@@ -276,6 +277,7 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
276
277
  watchOnce = _lib$util.watchOnce,
277
278
  watchable = _lib$util.watchable,
278
279
  inherit = _lib$util.inherit,
280
+ freeze = _lib$util.freeze,
279
281
  deepFreeze = _lib$util.deepFreeze,
280
282
  iequal = _lib$util.iequal,
281
283
  randomId = _lib$util.randomId,
@@ -363,6 +365,17 @@ var _lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_z
363
365
 
364
366
 
365
367
  /* harmony default export */ const zeta_dom_dom = (dom);
368
+ ;// CONCATENATED MODULE: ./tmp/zeta-dom/domLock.js
369
+
370
+ var domLock_lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.dom,
371
+ lock = domLock_lib$dom.lock,
372
+ locked = domLock_lib$dom.locked,
373
+ cancelLock = domLock_lib$dom.cancelLock,
374
+ notifyAsync = domLock_lib$dom.notifyAsync,
375
+ preventLeave = domLock_lib$dom.preventLeave;
376
+
377
+ ;// CONCATENATED MODULE: ./src/include/zeta-dom/domLock.js
378
+
366
379
  ;// CONCATENATED MODULE: ./tmp/brew-js/domAction.js
367
380
 
368
381
  var addAsyncAction = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.addAsyncAction,
@@ -378,6 +391,7 @@ var addAsyncAction = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_roo
378
391
 
379
392
 
380
393
 
394
+
381
395
  /**
382
396
  * @param {Partial<import("./dialog").DialogOptions<any>>} props
383
397
  */
@@ -387,7 +401,7 @@ function createDialog(props) {
387
401
  var closing = false;
388
402
  var promise;
389
403
 
390
- function closeDialog(value) {
404
+ function _closeDialog(value) {
391
405
  if (!closing) {
392
406
  closing = true;
393
407
  closeFlyout(root, value).then(function () {
@@ -404,7 +418,7 @@ function createDialog(props) {
404
418
 
405
419
  return {
406
420
  root: root,
407
- close: closeDialog,
421
+ close: _closeDialog,
408
422
  open: function open() {
409
423
  if (promise) {
410
424
  return promise;
@@ -420,16 +434,20 @@ function createDialog(props) {
420
434
  }
421
435
 
422
436
  if (props.onRender) {
423
- external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.render( /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(props.onRender, extend({
424
- closeDialog: closeDialog
425
- }, props)), root);
437
+ var dialogProps = extend({}, props, {
438
+ closeDialog: function closeDialog(value) {
439
+ var promise = resolve((props.onCommit || pipe)(value));
440
+ catchAsync(lock(zeta_dom_dom.activeElement, promise));
441
+ promise.then(_closeDialog);
442
+ }
443
+ });
444
+ external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.render( /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(props.onRender, dialogProps), root);
426
445
  }
427
446
 
428
447
  promise = openFlyout(root);
429
448
  always(promise, function () {
430
449
  promise = null;
431
450
  });
432
- promise.then(props.onCommit);
433
451
  (props.onOpen || noop)(root);
434
452
  return promise;
435
453
  }
@@ -463,6 +481,12 @@ function Dialog(props) {
463
481
  }
464
482
  // EXTERNAL MODULE: external "zeta-dom-react"
465
483
  var external_zeta_dom_react_ = __webpack_require__(103);
484
+ ;// CONCATENATED MODULE: ./tmp/zeta-dom/events.js
485
+
486
+ var ZetaEventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.EventContainer;
487
+
488
+ ;// CONCATENATED MODULE: ./src/include/zeta-dom/events.js
489
+
466
490
  ;// CONCATENATED MODULE: ./tmp/brew-js/defaults.js
467
491
 
468
492
  var defaults_defaultExport = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.defaults;
@@ -481,17 +505,6 @@ install('react', function (app_) {
481
505
  app_app = app_;
482
506
  });
483
507
  brew_js_defaults.react = true;
484
- ;// CONCATENATED MODULE: ./tmp/zeta-dom/domLock.js
485
-
486
- var domLock_lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.dom,
487
- lock = domLock_lib$dom.lock,
488
- locked = domLock_lib$dom.locked,
489
- cancelLock = domLock_lib$dom.cancelLock,
490
- notifyAsync = domLock_lib$dom.notifyAsync,
491
- preventLeave = domLock_lib$dom.preventLeave;
492
-
493
- ;// CONCATENATED MODULE: ./src/include/zeta-dom/domLock.js
494
-
495
508
  ;// CONCATENATED MODULE: ./tmp/brew-js/anim.js
496
509
 
497
510
  var animateIn = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.animateIn,
@@ -513,6 +526,7 @@ var animateIn = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_bre
513
526
  var view_root = zeta_dom_dom.root;
514
527
  var routeMap = new Map();
515
528
  var usedParams = {};
529
+ var sortedViews = [];
516
530
  var StateContext = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createContext(Object.freeze({
517
531
  active: true
518
532
  }));
@@ -533,6 +547,7 @@ function ViewContainer() {
533
547
 
534
548
  self.componentWillUnmount = app_app.on('navigate', function () {
535
549
  if (self.mounted && self.getViewComponent()) {
550
+ self.isForceUpdate = true;
536
551
  self.forceUpdate();
537
552
  }
538
553
  });
@@ -560,11 +575,14 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
560
575
  self.currentViewComponent = V;
561
576
 
562
577
  if (self.currentView && self.currentElement) {
578
+ var prevPath = self.currentPath;
579
+ var prevElement = self.currentElement;
563
580
  self.prevView = self.currentView;
564
- self.prevElement = self.currentElement;
565
581
  self.currentElement = undefined;
566
- animateOut(self.prevElement, 'show').then(function () {
567
- self.prevElement = undefined;
582
+ app_app.emit('pageleave', prevElement, {
583
+ pathname: prevPath
584
+ }, true);
585
+ animateOut(prevElement, 'show').then(function () {
568
586
  self.prevView = undefined;
569
587
  self.forceUpdate();
570
588
  });
@@ -572,7 +590,9 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
572
590
 
573
591
  var providerProps = {
574
592
  key: routeMap.get(V).id,
575
- value: {}
593
+ value: {
594
+ view: V
595
+ }
576
596
  };
577
597
  var view = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(StateContext.Provider, providerProps, /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewStateContainer, null, /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(V, {
578
598
  rootProps: self.props.rootProps,
@@ -581,15 +601,26 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
581
601
  self.parentElement = element.parentElement;
582
602
  util_setImmediate(function () {
583
603
  resolve();
584
- return animateIn(element, 'show');
604
+ animateIn(element, 'show');
605
+ app_app.emit('pageenter', element, {
606
+ pathname: app_app.path
607
+ }, true);
585
608
  });
586
609
  }
587
610
  })));
588
611
  defineGetterProperty(providerProps.value, 'active', function () {
589
612
  return self.currentView === view;
590
613
  });
614
+ self.currentPath = app_app.path;
591
615
  self.currentView = view;
592
616
  } else {
617
+ if (self.isForceUpdate) {
618
+ self.isForceUpdate = false;
619
+ app_app.emit('pageenter', self.currentElement, {
620
+ pathname: app_app.path
621
+ }, true);
622
+ }
623
+
593
624
  resolve();
594
625
  }
595
626
 
@@ -598,19 +629,90 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
598
629
  },
599
630
  getViewComponent: function getViewComponent() {
600
631
  var props = this.props;
601
- return any(props.views, isViewMatched) || history.state === stateId && void redirectTo(props.defaultView);
632
+ var matched = any(props.views, isViewMatched) || props.defaultView;
633
+
634
+ if (history.state === stateId) {
635
+ // ensure the current path actually corresponds to the matched view
636
+ // when some views are not included in the list of allowed views
637
+ var targetPath = linkTo(matched, getCurrentParams(matched, true));
638
+
639
+ if (targetPath !== app_app.path) {
640
+ app_app.navigate(targetPath, true);
641
+ }
642
+ }
643
+
644
+ return matched;
602
645
  }
603
646
  });
604
- function useViewContainerState() {
605
- return external_commonjs_react_commonjs2_react_amd_react_root_React_.useContext(StateContext);
647
+
648
+ function getCurrentParams(view, includeAll, params) {
649
+ var state = routeMap.get(view);
650
+
651
+ if (!state.maxParams) {
652
+ var matchers = exclude(state.matchers, ['remainingSegments']);
653
+ var matched = map(app_app.routes, function (v) {
654
+ var route = app_app.parseRoute(v);
655
+ var matched = route.length && !any(matchers, function (v, i) {
656
+ var pos = route.params[i];
657
+ return (v ? !(pos >= 0) : pos < route.minLength) || !isFunction(v) && !route.match(i, v);
658
+ });
659
+ return matched ? route : null;
660
+ });
661
+
662
+ if (matched[1]) {
663
+ matched = grep(matched, function (v) {
664
+ return !single(v.params, function (v, i) {
665
+ return usedParams[i] && !matchers[i];
666
+ });
667
+ });
668
+ }
669
+
670
+ if (matched[0]) {
671
+ var last = matched.slice(-1)[0];
672
+ state.maxParams = util_keys(extend.apply(0, [{}].concat(matched.map(function (v) {
673
+ return v.params;
674
+ }))));
675
+ state.minParams = map(last.params, function (v, i) {
676
+ return state.params[i] || v >= last.minLength ? null : i;
677
+ });
678
+ }
679
+ }
680
+
681
+ return pick(params || app_app.route, includeAll ? state.maxParams : state.minParams);
606
682
  }
607
- function isViewMatched(view) {
683
+
684
+ function sortViews(a, b) {
685
+ return (routeMap.get(b) || {}).matchCount - (routeMap.get(a) || {}).matchCount;
686
+ }
687
+
688
+ function matchViewParams(view, route) {
608
689
  var params = routeMap.get(view);
609
- return !!params && false === any(params.matchers, function (v, i) {
610
- var value = app_app.route[i] || '';
690
+ return !!params && !single(params.matchers, function (v, i) {
691
+ var value = route[i] || '';
611
692
  return isFunction(v) ? !v(value) : (v || '') !== value;
612
693
  });
613
694
  }
695
+
696
+ function useViewContainerState() {
697
+ return external_commonjs_react_commonjs2_react_amd_react_root_React_.useContext(StateContext);
698
+ }
699
+ function isViewMatched(view) {
700
+ return matchViewParams(view, app_app.route);
701
+ }
702
+ function matchView(path, views) {
703
+ var route = app_app.route;
704
+
705
+ if (typeof path === 'string') {
706
+ route = route.parse(path);
707
+ } else {
708
+ views = path;
709
+ }
710
+
711
+ views = views ? makeArray(views).sort(sortViews) : sortedViews;
712
+ return any(views, function (v) {
713
+ return matchViewParams(v, route);
714
+ }) || undefined;
715
+ }
614
716
  function registerView(factory, routeParams) {
615
717
  var Component = function Component(props) {
616
718
  var state = (0,external_zeta_dom_react_.useAsync)(factory);
@@ -636,21 +738,21 @@ function registerView(factory, routeParams) {
636
738
  });
637
739
  routeMap.set(Component, {
638
740
  id: randomId(),
639
- matchCount: keys(routeParams).length,
741
+ matchCount: util_keys(routeParams).length,
640
742
  matchers: routeParams,
641
743
  params: pick(routeParams, function (v) {
642
744
  return typeof v === 'string';
643
745
  })
644
746
  });
747
+ sortedViews.push(Component);
748
+ sortedViews.sort(sortViews);
645
749
  return Component;
646
750
  }
647
751
  function renderView() {
648
752
  var views = makeArray(arguments);
649
753
  var rootProps = isFunction(views[0]) ? {} : views.shift();
650
754
  var defaultView = views[0];
651
- views.sort(function (a, b) {
652
- return (routeMap.get(b) || {}).matchCount - (routeMap.get(a) || {}).matchCount;
653
- });
755
+ views.sort(sortViews);
654
756
  return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, {
655
757
  rootProps: rootProps,
656
758
  views: views,
@@ -658,19 +760,13 @@ function renderView() {
658
760
  });
659
761
  }
660
762
  function linkTo(view, params) {
661
- var viewParams = (routeMap.get(view) || {}).params;
662
- var newParams = {};
663
-
664
- for (var i in app_app.route) {
665
- if (viewParams && i in viewParams) {
666
- newParams[i] = viewParams[i];
667
- } else if (params && i in params) {
668
- newParams[i] = params[i];
669
- } else if (!usedParams[i]) {
670
- newParams[i] = app_app.route[i];
671
- }
763
+ var state = routeMap.get(view);
764
+
765
+ if (!state) {
766
+ return '/';
672
767
  }
673
768
 
769
+ var newParams = extend(getCurrentParams(view), getCurrentParams(view, true, params), state.params);
674
770
  return app_app.route.getPath(newParams);
675
771
  }
676
772
  function navigateTo(view, params) {
@@ -685,12 +781,32 @@ function redirectTo(view, params) {
685
781
 
686
782
 
687
783
 
784
+
785
+ var emitter = new ZetaEventContainer();
688
786
  var states = {};
689
787
 
690
788
  function getCurrentStates() {
691
789
  return states[history.state] || (states[history.state] = {});
692
790
  }
693
791
 
792
+ function ViewState(value) {
793
+ this.value = value;
794
+ }
795
+
796
+ definePrototype(ViewState, {
797
+ get: function get() {
798
+ return this.value;
799
+ },
800
+ set: function set(value) {
801
+ this.value = value;
802
+ },
803
+ onPopState: function onPopState(callback) {
804
+ throwNotFunction(callback);
805
+ return emitter.add(this, 'popstate', function (e) {
806
+ callback.call(this, e.newValue);
807
+ });
808
+ }
809
+ });
694
810
  function useAppReady() {
695
811
  var sReady = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(false);
696
812
  var ready = sReady[0],
@@ -705,32 +821,37 @@ function useAppReady() {
705
821
  function useRouteParam(name, defaultValue) {
706
822
  var container = useViewContainerState();
707
823
  var route = app_app.route;
708
- var sValue = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(route[name]);
709
- var value = sValue[0],
710
- setValue = sValue[1];
824
+ var value = route[name] || '';
825
+ var ref = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useRef)(value);
826
+ var forceUpdate = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)()[1];
711
827
  (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
712
- var current = route[name]; // route parameter might be changed after state initialization and before useEffect hook is called
828
+ var setValue = function setValue() {
829
+ var current = route[name] || '';
830
+
831
+ if (container.active && current !== ref.current) {
832
+ ref.current = current;
833
+ forceUpdate({});
834
+ }
835
+ }; // route parameter might be changed after state initialization and before useEffect hook is called
836
+
713
837
 
714
- setValue(current);
838
+ setValue();
715
839
 
716
840
  if (name in route) {
717
- return route.watch(name, function (value) {
718
- util_setImmediate(function () {
719
- if (container.active) {
720
- setValue(value);
721
- }
722
- });
841
+ return route.watch(name, function () {
842
+ setImmediateOnce(setValue);
723
843
  });
724
844
  }
725
845
 
726
846
  console.error('Route parameter ' + name + ' does not exist');
727
847
  }, [name, defaultValue]);
848
+ ref.current = value;
728
849
 
729
850
  if (!value && defaultValue !== undefined) {
730
851
  app_app.navigate(route.getPath(extend({}, route, kv(name, defaultValue))), true);
731
852
  }
732
853
 
733
- return value || '';
854
+ return value;
734
855
  }
735
856
  function useRouteState(key, defaultValue) {
736
857
  var container = useViewContainerState();
@@ -750,17 +871,23 @@ function ViewStateContainer(props) {
750
871
  return {
751
872
  getState: function getState(uniqueId, key) {
752
873
  var cur = getCurrentStates();
753
- var state = cache[uniqueId] || (cache[uniqueId] = {
754
- value: cur[key] && cur[key].value,
755
- get: function get() {
756
- return state.value;
757
- },
758
- set: function set(value) {
759
- state.value = value;
760
- }
761
- });
874
+ var state = cache[uniqueId] || (cache[uniqueId] = new ViewState(cur[key] && cur[key].value));
762
875
 
763
876
  if (container.active) {
877
+ var stateId = state.stateId;
878
+
879
+ if (stateId && stateId !== history.state) {
880
+ var newValue = cur[key] && cur[key].value;
881
+ emitter.emit('popstate', state, {
882
+ newValue: newValue
883
+ }); // detach value in previous history state from current one
884
+
885
+ var previous = new ViewState(state.value);
886
+ states[stateId][key] = previous;
887
+ state.value = newValue;
888
+ }
889
+
890
+ state.stateId = history.state;
764
891
  cur[key] = state;
765
892
  }
766
893
 
@@ -865,7 +992,10 @@ function makeTranslation(resources, defaultLang) {
865
992
  return {
866
993
  translate: cache[''],
867
994
  getTranslation: getTranslationCallback,
868
- useTranslation: useTranslation
995
+ useTranslation: useTranslation,
996
+ keys: function keys(prefix) {
997
+ return util_keys(resources[defaultLang][prefix] || empty);
998
+ }
869
999
  };
870
1000
  }
871
1001
  ;// CONCATENATED MODULE: ./src/mixins/StaticAttributeMixin.js
@@ -895,7 +1025,8 @@ definePrototype(Mixin, {
895
1025
  },
896
1026
  getCustomAttributes: function getCustomAttributes() {
897
1027
  return {};
898
- }
1028
+ },
1029
+ dispose: function dispose() {}
899
1030
  });
900
1031
  watchable(Mixin.prototype);
901
1032
  util_define(Mixin, {
@@ -1014,15 +1145,23 @@ definePrototype(StatefulMixin, Mixin, {
1014
1145
  },
1015
1146
  initElement: function initElement(element, state) {},
1016
1147
  clone: function clone() {
1017
- var clone = inherit(Object.getPrototypeOf(this));
1148
+ var self = this;
1149
+ var clone = inherit(Object.getPrototypeOf(self), self);
1018
1150
 
1019
1151
  _(clone, {
1020
- states: _(this).states,
1152
+ states: _(self).states,
1021
1153
  prefix: randomId() + '.',
1022
1154
  counter: 0
1023
1155
  });
1024
1156
 
1025
1157
  return clone;
1158
+ },
1159
+ dispose: function dispose() {
1160
+ var states = _(this).states;
1161
+
1162
+ each(states, function (i, v) {
1163
+ delete states[i];
1164
+ });
1026
1165
  }
1027
1166
  });
1028
1167
  ;// CONCATENATED MODULE: ./src/mixins/ClassNameMixin.js
@@ -1082,11 +1221,6 @@ definePrototype(ClassNameMixin, StatefulMixin, {
1082
1221
  }
1083
1222
  });
1084
1223
  },
1085
- clone: function clone() {
1086
- return extend(ClassNameMixinSuper.clone.call(this), {
1087
- classNames: this.classNames
1088
- });
1089
- },
1090
1224
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {}
1091
1225
  });
1092
1226
  ;// CONCATENATED MODULE: ./src/mixins/AnimateMixin.js
@@ -1162,19 +1296,13 @@ definePrototype(AnimateSequenceMixin, AnimateMixin, {
1162
1296
  });
1163
1297
  }
1164
1298
  });
1165
- ;// CONCATENATED MODULE: ./tmp/zeta-dom/events.js
1166
-
1167
- var ZetaEventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.EventContainer;
1168
-
1169
- ;// CONCATENATED MODULE: ./src/include/zeta-dom/events.js
1170
-
1171
1299
  ;// CONCATENATED MODULE: ./src/mixins/ErrorHandlerMixin.js
1172
1300
 
1173
1301
 
1174
1302
 
1175
1303
 
1176
1304
  var ErrorHandlerMixinSuper = StatefulMixin.prototype;
1177
- var emitter = new ZetaEventContainer();
1305
+ var ErrorHandlerMixin_emitter = new ZetaEventContainer();
1178
1306
 
1179
1307
  function isErrorMatched(filter, error) {
1180
1308
  if (isFunction(filter)) {
@@ -1194,7 +1322,7 @@ definePrototype(ErrorHandlerMixin, StatefulMixin, {
1194
1322
  filter = null;
1195
1323
  }
1196
1324
 
1197
- return emitter.add(this, filter ? 'error' : 'default', function (e) {
1325
+ return ErrorHandlerMixin_emitter.add(this, filter ? 'error' : 'default', function (e) {
1198
1326
  if (!filter || isErrorMatched(filter, e.error)) {
1199
1327
  return callback(e.error);
1200
1328
  }
@@ -1207,10 +1335,22 @@ definePrototype(ErrorHandlerMixin, StatefulMixin, {
1207
1335
  var data = {
1208
1336
  error: e.error
1209
1337
  };
1210
- return emitter.emit('error', self, data) || emitter.emit('default', self, data);
1338
+ return ErrorHandlerMixin_emitter.emit('error', self, data) || ErrorHandlerMixin_emitter.emit('default', self, data);
1211
1339
  });
1212
1340
  }
1213
1341
  });
1342
+ ;// CONCATENATED MODULE: ./tmp/brew-js/var.js
1343
+
1344
+ var getVarScope = undefined.getVarScope,
1345
+ setVar = undefined.setVar,
1346
+ declareVar = undefined.declareVar,
1347
+ resetVar = undefined.resetVar,
1348
+ getVar = undefined.getVar,
1349
+ evaluate = undefined.evaluate,
1350
+ evalAttr = undefined.evalAttr;
1351
+
1352
+ ;// CONCATENATED MODULE: ./src/include/brew-js/var.js
1353
+
1214
1354
  ;// CONCATENATED MODULE: ./src/mixins/FlyoutToggleMixin.js
1215
1355
 
1216
1356
 
@@ -1220,16 +1360,17 @@ function FlyoutToggleMixin(mixin) {
1220
1360
  this.flyoutMixin = mixin;
1221
1361
  }
1222
1362
  definePrototype(FlyoutToggleMixin, ClassNameMixin, {
1363
+ open: function open(value) {
1364
+ return this.flyoutMixin.open(value);
1365
+ },
1366
+ close: function close(value) {
1367
+ return this.flyoutMixin.close(value);
1368
+ },
1223
1369
  getCustomAttributes: function getCustomAttributes() {
1224
1370
  var element = this.flyoutMixin.elements()[0];
1225
1371
  return extend({}, FlyoutToggleMixinSuper.getCustomAttributes.call(this), {
1226
1372
  'toggle': element && '#' + element.id
1227
1373
  });
1228
- },
1229
- clone: function clone() {
1230
- return extend(FlyoutToggleMixinSuper.clone.call(this), {
1231
- flyoutMixin: this.flyoutMixin
1232
- });
1233
1374
  }
1234
1375
  });
1235
1376
  ;// CONCATENATED MODULE: ./src/mixins/FlyoutMixin.js
@@ -1237,12 +1378,16 @@ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
1237
1378
 
1238
1379
 
1239
1380
 
1381
+
1382
+
1240
1383
  var FlyoutMixinSuper = ClassNameMixin.prototype;
1384
+ var varname = '__flyout' + randomId();
1241
1385
  var flyoutMixinCounter = 0;
1242
1386
  function FlyoutMixin() {
1243
1387
  var self = this;
1244
- ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
1388
+ ClassNameMixin.call(self, ['open', 'closing', 'visible', 'tweening-in', 'tweening-out']);
1245
1389
  self.modal = false;
1390
+ self.tabThrough = false;
1246
1391
  self.isFlyoutOpened = false;
1247
1392
  self.animating = false;
1248
1393
  self.visible = false;
@@ -1268,16 +1413,25 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1268
1413
  'swipe-dismiss': self.swipeToDismiss
1269
1414
  }, self.modal && {
1270
1415
  'is-modal': ''
1416
+ }, self.tabThrough && {
1417
+ 'tab-through': ''
1271
1418
  }, self.effects && {
1272
1419
  'animate-on': 'open',
1273
1420
  'animate-in': self.effects.join(' '),
1274
1421
  'animate-out': ''
1275
1422
  });
1276
1423
  },
1424
+ open: function open(value) {
1425
+ return openFlyout(this.elements()[0], kv(varname, value));
1426
+ },
1427
+ close: function close(value) {
1428
+ return closeFlyout(this.elements()[0], value);
1429
+ },
1277
1430
  onOpen: function onOpen(callback) {
1431
+ var element = this.elements()[0];
1278
1432
  return this.onToggleState(function (opened) {
1279
1433
  if (opened) {
1280
- return callback();
1434
+ return callback(getVar(element, varname));
1281
1435
  }
1282
1436
  });
1283
1437
  },
@@ -1293,6 +1447,7 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1293
1447
 
1294
1448
  if (!element.id) {
1295
1449
  element.id = 'flyout-' + ++flyoutMixinCounter;
1450
+ declareVar(element, varname, undefined);
1296
1451
  }
1297
1452
 
1298
1453
  app_app.on(element, {
@@ -1337,9 +1492,9 @@ definePrototype(FocusStateMixin, StatefulMixin, {
1337
1492
  initElement: function initElement(element, state) {
1338
1493
  FocusStateMixinSuper.initElement.call(this, element, state);
1339
1494
  zeta_dom_dom.on(element, {
1340
- focusin: function focusin() {
1495
+ focusin: function focusin(e) {
1341
1496
  state.focused = true;
1342
- setClass(element, 'focused', true);
1497
+ setClass(element, 'focused', e.source);
1343
1498
  },
1344
1499
  focusout: function focusout() {
1345
1500
  state.focused = false;
@@ -1487,9 +1642,13 @@ var useFocusStateMixin = createUseFunction(FocusStateMixin);
1487
1642
  var useLoadingStateMixin = createUseFunction(LoadingStateMixin);
1488
1643
  var useScrollableMixin = createUseFunction(ScrollableMixin);
1489
1644
  function useMixin(ctor) {
1490
- return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1645
+ var mixin = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1491
1646
  return new ctor();
1492
1647
  })[0].reset();
1648
+ (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
1649
+ return mixin.dispose.bind(mixin);
1650
+ }, []);
1651
+ return mixin;
1493
1652
  }
1494
1653
  function useMixinRef(mixin) {
1495
1654
  return mixin && mixin.getMixin().reset();