brew-js-react 0.2.2 → 0.2.3

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.
@@ -261,7 +261,7 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
261
261
  setImmediateOnce = _lib$util.setImmediateOnce,
262
262
  throwNotFunction = _lib$util.throwNotFunction,
263
263
  errorWithCode = _lib$util.errorWithCode,
264
- keys = _lib$util.keys,
264
+ util_keys = _lib$util.keys,
265
265
  values = _lib$util.values,
266
266
  util_hasOwnProperty = _lib$util.hasOwnProperty,
267
267
  getOwnPropertyDescriptors = _lib$util.getOwnPropertyDescriptors,
@@ -545,6 +545,7 @@ function ViewContainer() {
545
545
 
546
546
  self.componentWillUnmount = app_app.on('navigate', function () {
547
547
  if (self.mounted && self.getViewComponent()) {
548
+ self.isForceUpdate = true;
548
549
  self.forceUpdate();
549
550
  }
550
551
  });
@@ -609,9 +610,13 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
609
610
  self.currentPath = app_app.path;
610
611
  self.currentView = view;
611
612
  } else {
612
- app_app.emit('pageenter', self.currentElement, {
613
- pathname: app_app.path
614
- }, true);
613
+ if (self.isForceUpdate) {
614
+ self.isForceUpdate = false;
615
+ app_app.emit('pageenter', self.currentElement, {
616
+ pathname: app_app.path
617
+ }, true);
618
+ }
619
+
615
620
  resolve();
616
621
  }
617
622
 
@@ -620,9 +625,58 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
620
625
  },
621
626
  getViewComponent: function getViewComponent() {
622
627
  var props = this.props;
623
- return any(props.views, isViewMatched) || history.state === stateId && void redirectTo(props.defaultView);
628
+ var matched = any(props.views, isViewMatched) || props.defaultView;
629
+
630
+ if (history.state === stateId) {
631
+ // ensure the current path actually corresponds to the matched view
632
+ // when some views are not included in the list of allowed views
633
+ var targetPath = linkTo(matched, getCurrentParams(matched, true));
634
+
635
+ if (targetPath !== app_app.path) {
636
+ app_app.navigate(targetPath, true);
637
+ return;
638
+ }
639
+ }
640
+
641
+ return matched;
624
642
  }
625
643
  });
644
+
645
+ function getCurrentParams(view, includeAll) {
646
+ var state = routeMap.get(view);
647
+
648
+ if (!state.maxParams) {
649
+ var matched = map(app_app.routes, function (v) {
650
+ var route = app_app.parseRoute(v);
651
+ var matched = route.length && !any(state.matchers, function (v, i) {
652
+ var pos = route.params[i];
653
+ return (v ? !(pos >= 0) : pos < route.minLength) || !isFunction(v) && !route.match(i, v);
654
+ });
655
+ return matched ? route : null;
656
+ });
657
+
658
+ if (matched[1]) {
659
+ matched = grep(matched, function (v) {
660
+ return !any(v.params, function (v, i) {
661
+ return usedParams[i] && !state.matchers[i];
662
+ });
663
+ });
664
+ }
665
+
666
+ if (matched[0]) {
667
+ var last = matched.slice(-1)[0];
668
+ state.maxParams = util_keys(extend.apply(0, [{}].concat(matched.map(function (v) {
669
+ return v.params;
670
+ }))));
671
+ state.minParams = map(last.params, function (v, i) {
672
+ return state.params[i] || v >= last.minLength ? null : i;
673
+ });
674
+ }
675
+ }
676
+
677
+ return pick(app_app.route, includeAll ? state.maxParams : state.minParams);
678
+ }
679
+
626
680
  function useViewContainerState() {
627
681
  return external_commonjs_react_commonjs2_react_amd_react_root_React_.useContext(StateContext);
628
682
  }
@@ -658,7 +712,7 @@ function registerView(factory, routeParams) {
658
712
  });
659
713
  routeMap.set(Component, {
660
714
  id: randomId(),
661
- matchCount: keys(routeParams).length,
715
+ matchCount: util_keys(routeParams).length,
662
716
  matchers: routeParams,
663
717
  params: pick(routeParams, function (v) {
664
718
  return typeof v === 'string';
@@ -680,19 +734,13 @@ function renderView() {
680
734
  });
681
735
  }
682
736
  function linkTo(view, params) {
683
- var viewParams = (routeMap.get(view) || {}).params;
684
- var newParams = {};
685
-
686
- for (var i in app_app.route) {
687
- if (viewParams && i in viewParams) {
688
- newParams[i] = viewParams[i];
689
- } else if (params && i in params) {
690
- newParams[i] = params[i];
691
- } else if (!usedParams[i]) {
692
- newParams[i] = app_app.route[i];
693
- }
737
+ var state = routeMap.get(view);
738
+
739
+ if (!state) {
740
+ return '/';
694
741
  }
695
742
 
743
+ var newParams = extend(getCurrentParams(view), params, state.params);
696
744
  return app_app.route.getPath(newParams);
697
745
  }
698
746
  function navigateTo(view, params) {
@@ -918,7 +966,10 @@ function makeTranslation(resources, defaultLang) {
918
966
  return {
919
967
  translate: cache[''],
920
968
  getTranslation: getTranslationCallback,
921
- useTranslation: useTranslation
969
+ useTranslation: useTranslation,
970
+ keys: function keys(prefix) {
971
+ return util_keys(resources[defaultLang][prefix] || empty);
972
+ }
922
973
  };
923
974
  }
924
975
  ;// CONCATENATED MODULE: ./src/mixins/StaticAttributeMixin.js
@@ -1068,10 +1119,11 @@ definePrototype(StatefulMixin, Mixin, {
1068
1119
  },
1069
1120
  initElement: function initElement(element, state) {},
1070
1121
  clone: function clone() {
1071
- var clone = inherit(Object.getPrototypeOf(this));
1122
+ var self = this;
1123
+ var clone = inherit(Object.getPrototypeOf(self), self);
1072
1124
 
1073
1125
  _(clone, {
1074
- states: _(this).states,
1126
+ states: _(self).states,
1075
1127
  prefix: randomId() + '.',
1076
1128
  counter: 0
1077
1129
  });
@@ -1143,11 +1195,6 @@ definePrototype(ClassNameMixin, StatefulMixin, {
1143
1195
  }
1144
1196
  });
1145
1197
  },
1146
- clone: function clone() {
1147
- return extend(ClassNameMixinSuper.clone.call(this), {
1148
- classNames: this.classNames
1149
- });
1150
- },
1151
1198
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {}
1152
1199
  });
1153
1200
  ;// CONCATENATED MODULE: ./src/mixins/AnimateMixin.js
@@ -1266,6 +1313,18 @@ definePrototype(ErrorHandlerMixin, StatefulMixin, {
1266
1313
  });
1267
1314
  }
1268
1315
  });
1316
+ ;// CONCATENATED MODULE: ./tmp/brew-js/var.js
1317
+
1318
+ var getVarScope = undefined.getVarScope,
1319
+ setVar = undefined.setVar,
1320
+ declareVar = undefined.declareVar,
1321
+ resetVar = undefined.resetVar,
1322
+ getVar = undefined.getVar,
1323
+ evaluate = undefined.evaluate,
1324
+ evalAttr = undefined.evalAttr;
1325
+
1326
+ ;// CONCATENATED MODULE: ./src/include/brew-js/var.js
1327
+
1269
1328
  ;// CONCATENATED MODULE: ./src/mixins/FlyoutToggleMixin.js
1270
1329
 
1271
1330
 
@@ -1275,16 +1334,17 @@ function FlyoutToggleMixin(mixin) {
1275
1334
  this.flyoutMixin = mixin;
1276
1335
  }
1277
1336
  definePrototype(FlyoutToggleMixin, ClassNameMixin, {
1337
+ open: function open(value) {
1338
+ return this.flyoutMixin.open(value);
1339
+ },
1340
+ close: function close(value) {
1341
+ return this.flyoutMixin.close(value);
1342
+ },
1278
1343
  getCustomAttributes: function getCustomAttributes() {
1279
1344
  var element = this.flyoutMixin.elements()[0];
1280
1345
  return extend({}, FlyoutToggleMixinSuper.getCustomAttributes.call(this), {
1281
1346
  'toggle': element && '#' + element.id
1282
1347
  });
1283
- },
1284
- clone: function clone() {
1285
- return extend(FlyoutToggleMixinSuper.clone.call(this), {
1286
- flyoutMixin: this.flyoutMixin
1287
- });
1288
1348
  }
1289
1349
  });
1290
1350
  ;// CONCATENATED MODULE: ./src/mixins/FlyoutMixin.js
@@ -1292,11 +1352,14 @@ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
1292
1352
 
1293
1353
 
1294
1354
 
1355
+
1356
+
1295
1357
  var FlyoutMixinSuper = ClassNameMixin.prototype;
1358
+ var varname = '__flyout' + randomId();
1296
1359
  var flyoutMixinCounter = 0;
1297
1360
  function FlyoutMixin() {
1298
1361
  var self = this;
1299
- ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
1362
+ ClassNameMixin.call(self, ['open', 'closing', 'visible', 'tweening-in', 'tweening-out']);
1300
1363
  self.modal = false;
1301
1364
  self.tabThrough = false;
1302
1365
  self.isFlyoutOpened = false;
@@ -1332,10 +1395,17 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1332
1395
  'animate-out': ''
1333
1396
  });
1334
1397
  },
1398
+ open: function open(value) {
1399
+ return openFlyout(this.elements()[0], kv(varname, value));
1400
+ },
1401
+ close: function close(value) {
1402
+ return closeFlyout(this.elements()[0], value);
1403
+ },
1335
1404
  onOpen: function onOpen(callback) {
1405
+ var element = this.elements()[0];
1336
1406
  return this.onToggleState(function (opened) {
1337
1407
  if (opened) {
1338
- return callback();
1408
+ return callback(getVar(element, varname));
1339
1409
  }
1340
1410
  });
1341
1411
  },
@@ -1351,6 +1421,7 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1351
1421
 
1352
1422
  if (!element.id) {
1353
1423
  element.id = 'flyout-' + ++flyoutMixinCounter;
1424
+ declareVar(element, varname, undefined);
1354
1425
  }
1355
1426
 
1356
1427
  app_app.on(element, {