brew-js-react 0.1.3 → 0.1.6

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.
@@ -170,6 +170,7 @@ __webpack_require__.d(src_namespaceObject, {
170
170
  "useFocusStateMixin": () => (useFocusStateMixin),
171
171
  "useLanguage": () => (useLanguage),
172
172
  "useLoadingStateMixin": () => (useLoadingStateMixin),
173
+ "useMixin": () => (useMixin),
173
174
  "useMixinRef": () => (useMixinRef),
174
175
  "useRouteParam": () => (useRouteParam),
175
176
  "useScrollableMixin": () => (useScrollableMixin)
@@ -182,6 +183,7 @@ var external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_ = __webpa
182
183
  var _defaultExport = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_;
183
184
  /* harmony default export */ const app = (_defaultExport);
184
185
  var install = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.install,
186
+ addExtension = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.addExtension,
185
187
  addDetect = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.addDetect;
186
188
 
187
189
  ;// CONCATENATED MODULE: ./src/include/brew-js/app.js
@@ -327,6 +329,7 @@ var _lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_z
327
329
  focusable = _lib$dom.focusable,
328
330
  focused = _lib$dom.focused,
329
331
  setModal = _lib$dom.setModal,
332
+ releaseModal = _lib$dom.releaseModal,
330
333
  retainFocus = _lib$dom.retainFocus,
331
334
  releaseFocus = _lib$dom.releaseFocus,
332
335
  dom_focus = _lib$dom.focus;
@@ -505,6 +508,23 @@ if (toPrimitive) {
505
508
  };
506
509
  }
507
510
 
511
+ function createCallback(translate) {
512
+ var callback = function callback(key, data) {
513
+ return translate(key, data, true);
514
+ };
515
+
516
+ return extend(callback, {
517
+ html: function html(id, data) {
518
+ return {
519
+ __html: translate(id, data)
520
+ };
521
+ },
522
+ lazy: function lazy(id, data) {
523
+ return new TString(translate.bind(0, id, data, true));
524
+ }
525
+ });
526
+ }
527
+
508
528
  function useLanguage() {
509
529
  return (0,external_zeta_dom_react_.useObservableProperty)(app_app, 'language');
510
530
  }
@@ -512,28 +532,22 @@ function makeTranslation(resources, defaultLang) {
512
532
  var re = new RegExp('^(' + Object.keys(resources[defaultLang]).join('|') + ')\\.');
513
533
  var cache = {};
514
534
 
515
- function getTranslation(prefix, name, data) {
535
+ function getTranslation(prefix, name, data, noEncode) {
516
536
  var str = ((resources[app_app.language] || empty)[prefix] || empty)[name] || ((resources[defaultLang] || empty)[prefix] || empty)[name] || '';
517
- return str && data !== undefined ? waterpipe(str, data) : str;
518
- }
519
537
 
520
- function createCallback(translate) {
521
- return extend(translate, {
522
- html: function html(id, data) {
523
- return {
524
- __html: translate(id, data)
525
- };
526
- },
527
- lazy: function lazy(id, data) {
528
- return new TString(this.bind(0, id, data));
529
- }
530
- });
538
+ if (str && (!noEncode || data !== undefined)) {
539
+ return waterpipe(str, data, {
540
+ noEncode: noEncode
541
+ });
542
+ }
543
+
544
+ return str;
531
545
  }
532
546
 
533
- function translate(key, data) {
547
+ function translate(key, data, noEncode) {
534
548
  var prefix = re.test(key) ? RegExp.$1 : '';
535
549
  var name = prefix ? key.slice(RegExp.lastMatch.length) : key;
536
- return getTranslation(prefix, name, data) || key;
550
+ return getTranslation(prefix, name, data, noEncode) || key;
537
551
  }
538
552
 
539
553
  function useTranslation() {
@@ -543,9 +557,9 @@ function makeTranslation(resources, defaultLang) {
543
557
 
544
558
  if (prefix[0]) {
545
559
  var key = prefix.join(' ');
546
- t = cache[key] || (cache[key] = createCallback(function (key, data) {
560
+ t = cache[key] || (cache[key] = createCallback(function (key, data, noEncode) {
547
561
  return single(prefix, function (v) {
548
- return getTranslation(v, key, data);
562
+ return getTranslation(v, key, data, noEncode);
549
563
  }) || key;
550
564
  }));
551
565
  }
@@ -640,6 +654,8 @@ util_define(Mixin, {
640
654
 
641
655
 
642
656
 
657
+ var _ = createPrivateStore();
658
+
643
659
  function MixinRefImpl(mixin) {
644
660
  this.mixin = mixin;
645
661
  }
@@ -651,29 +667,34 @@ definePrototype(MixinRefImpl, {
651
667
  });
652
668
  function StatefulMixin() {
653
669
  Mixin.call(this);
654
- this.states = {};
655
- this.prefix = '';
656
- this.counter = 0;
670
+
671
+ _(this, {
672
+ states: {},
673
+ prefix: '',
674
+ counter: 0
675
+ });
657
676
  }
658
677
  definePrototype(StatefulMixin, Mixin, {
659
678
  get ref() {
660
- var state = this.state;
661
- this.next();
662
- return state.ref || (state.ref = new MixinRefImpl(this.clone()));
679
+ var self = this;
680
+ var state = self.state;
681
+ self.next();
682
+ return state.ref || (state.ref = new MixinRefImpl(self.clone()));
663
683
  },
664
684
 
665
685
  get state() {
666
- var self = this;
667
- var key = self.prefix + self.counter;
668
- return self.states[key] || (self.states[key] = self.initState());
686
+ var obj = _(this);
687
+
688
+ var key = obj.prefix + obj.counter;
689
+ return obj.states[key] || (obj.states[key] = this.initState());
669
690
  },
670
691
 
671
692
  reset: function reset() {
672
- this.counter = 0;
693
+ _(this).counter = 0;
673
694
  return this;
674
695
  },
675
696
  next: function next() {
676
- this.counter++;
697
+ _(this).counter++;
677
698
  return this;
678
699
  },
679
700
  getRef: function getRef() {
@@ -687,7 +708,7 @@ definePrototype(StatefulMixin, Mixin, {
687
708
  };
688
709
  },
689
710
  elements: function elements() {
690
- return values(this.states).map(function (v) {
711
+ return values(_(this).states).map(function (v) {
691
712
  return v.element;
692
713
  }).filter(function (v) {
693
714
  return v;
@@ -700,11 +721,15 @@ definePrototype(StatefulMixin, Mixin, {
700
721
  },
701
722
  initElement: function initElement(element, state) {},
702
723
  clone: function clone() {
703
- return inherit(Object.getPrototypeOf(this), {
704
- states: this.states,
724
+ var clone = inherit(Object.getPrototypeOf(this));
725
+
726
+ _(clone, {
727
+ states: _(this).states,
705
728
  prefix: randomId() + '.',
706
729
  counter: 0
707
730
  });
731
+
732
+ return clone;
708
733
  }
709
734
  });
710
735
  ;// CONCATENATED MODULE: ./src/mixins/ClassNameMixin.js
@@ -757,23 +782,26 @@ function AnimateMixin() {
757
782
  }
758
783
  definePrototype(AnimateMixin, ClassNameMixin, {
759
784
  next: function next() {
760
- this.effects = undefined;
761
- this.trigger = undefined;
762
- return AnimateMixinSuper.next.call(this);
785
+ var self = this;
786
+ self.effects = undefined;
787
+ self.trigger = undefined;
788
+ return AnimateMixinSuper.next.call(self);
763
789
  },
764
790
  "with": function _with(props) {
765
- this.effects = props.effects;
766
- this.trigger = props.trigger;
767
- return this;
791
+ var self = this;
792
+ self.effects = props.effects;
793
+ self.trigger = props.trigger;
794
+ return self;
768
795
  },
769
796
  withEffects: function withEffects() {
770
797
  this.effects = makeArray(arguments);
771
798
  return this;
772
799
  },
773
800
  getCustomAttributes: function getCustomAttributes() {
774
- return extend({}, AnimateMixinSuper.getCustomAttributes.call(this), {
775
- 'animate-in': (this.effects || []).join(' '),
776
- 'animate-on': this.trigger || 'show'
801
+ var self = this;
802
+ return extend({}, AnimateMixinSuper.getCustomAttributes.call(self), {
803
+ 'animate-in': (self.effects || []).join(' '),
804
+ 'animate-on': self.trigger || 'show'
777
805
  });
778
806
  }
779
807
  });
@@ -797,9 +825,10 @@ definePrototype(AnimateSequenceItemMixin, ClassNameMixin, {
797
825
  var AnimateSequenceMixinSuper = AnimateMixin.prototype;
798
826
  var animateSequenceMixinCounter = 0;
799
827
  function AnimateSequenceMixin() {
800
- AnimateMixin.call(this);
801
- this.className = 'brew-anim-' + ++animateSequenceMixinCounter;
802
- this.item = new AnimateSequenceItemMixin(this.className);
828
+ var self = this;
829
+ AnimateMixin.call(self);
830
+ self.className = 'brew-anim-' + ++animateSequenceMixinCounter;
831
+ self.item = new AnimateSequenceItemMixin(self.className);
803
832
  }
804
833
  definePrototype(AnimateSequenceMixin, AnimateMixin, {
805
834
  reset: function reset() {
@@ -872,12 +901,33 @@ definePrototype(ErrorHandlerMixin, StatefulMixin, {
872
901
 
873
902
  var FlyoutMixinSuper = ClassNameMixin.prototype;
874
903
  var flyoutMixinCounter = 0;
904
+
905
+ function FlyoutToggleMixin(mixin) {
906
+ ClassNameMixin.call(this, ['target-opened']);
907
+ this.flyoutMixin = mixin;
908
+ }
909
+
910
+ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
911
+ getCustomAttributes: function getCustomAttributes() {
912
+ var element = this.flyoutMixin.elements()[0];
913
+ return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
914
+ 'toggle': element && '#' + element.id
915
+ });
916
+ },
917
+ clone: function clone() {
918
+ return extend(FlyoutMixinSuper.clone.call(this), {
919
+ flyoutMixin: this.flyoutMixin
920
+ });
921
+ }
922
+ });
875
923
  function FlyoutMixin() {
876
- ClassNameMixin.call(this, ['open', 'closing', 'tweening-in', 'tweening-out']);
877
- this.isFlyoutOpened = false;
878
- this.animating = false;
879
- this.visible = false;
880
- this.toggle = new ClassNameMixin(['target-opened']);
924
+ var self = this;
925
+ ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
926
+ self.modal = false;
927
+ self.isFlyoutOpened = false;
928
+ self.animating = false;
929
+ self.visible = false;
930
+ self.toggle = new FlyoutToggleMixin(self);
881
931
  }
882
932
  definePrototype(FlyoutMixin, ClassNameMixin, {
883
933
  reset: function reset() {
@@ -893,11 +943,14 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
893
943
  return this;
894
944
  },
895
945
  getCustomAttributes: function getCustomAttributes() {
896
- return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
946
+ var self = this;
947
+ return extend({}, FlyoutMixinSuper.getCustomAttributes.call(self), {
897
948
  'is-flyout': ''
898
- }, this.effects && {
949
+ }, self.modal && {
950
+ 'is-modal': ''
951
+ }, self.effects && {
899
952
  'animate-on': 'open',
900
- 'animate-in': this.effects.join(' '),
953
+ 'animate-in': self.effects.join(' '),
901
954
  'animate-out': ''
902
955
  });
903
956
  },
@@ -937,10 +990,12 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
937
990
  });
938
991
  },
939
992
  clone: function clone() {
940
- var mixin = extend(FlyoutMixinSuper.clone.call(this), {
941
- toggle: this.toggle.ref.getMixin()
993
+ var self = this;
994
+ var mixin = extend(FlyoutMixinSuper.clone.call(self), {
995
+ toggle: self.toggle.ref.getMixin()
942
996
  });
943
- defineAliasProperty(mixin, 'isFlyoutOpened', this);
997
+ defineAliasProperty(mixin, 'isFlyoutOpened', self);
998
+ defineAliasProperty(mixin, 'modal', self);
944
999
  return mixin;
945
1000
  },
946
1001
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {
@@ -1033,9 +1088,10 @@ definePrototype(LoadingStateMixin, StatefulMixin, {
1033
1088
 
1034
1089
  var ScrollableMixinSuper = ClassNameMixin.prototype;
1035
1090
  function ScrollableMixin() {
1036
- ClassNameMixin.call(this, ['scrollable-x', 'scrollable-x-l', 'scrollable-x-r', 'scrollable-y', 'scrollable-y-d', 'scrollable-y-u']);
1037
- this.target = Mixin.scrollableTarget;
1038
- this.pageIndex = 0;
1091
+ var self = this;
1092
+ ClassNameMixin.call(self, ['scrollable-x', 'scrollable-x-l', 'scrollable-x-r', 'scrollable-y', 'scrollable-y-d', 'scrollable-y-u']);
1093
+ self.target = Mixin.scrollableTarget;
1094
+ self.pageIndex = 0;
1039
1095
  }
1040
1096
  definePrototype(ScrollableMixin, ClassNameMixin, {
1041
1097
  withOptions: function withOptions(options) {
@@ -1086,11 +1142,16 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1086
1142
 
1087
1143
 
1088
1144
 
1145
+
1146
+ function extendSelf(options) {
1147
+ extend(this, options);
1148
+ }
1149
+
1089
1150
  function createUseFunction(ctor) {
1090
1151
  return function () {
1091
- return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1092
- return new ctor();
1093
- })[0].reset();
1152
+ var mixin = useMixin(ctor);
1153
+ (mixin.withOptions || extendSelf).apply(mixin, arguments);
1154
+ return mixin;
1094
1155
  };
1095
1156
  }
1096
1157
 
@@ -1100,11 +1161,14 @@ var useErrorHandlerMixin = createUseFunction(ErrorHandlerMixin);
1100
1161
  var useFlyoutMixin = createUseFunction(FlyoutMixin);
1101
1162
  var useFocusStateMixin = createUseFunction(FocusStateMixin);
1102
1163
  var useLoadingStateMixin = createUseFunction(LoadingStateMixin);
1103
- function useScrollableMixin(options) {
1104
- return createUseFunction(ScrollableMixin)().withOptions(options);
1164
+ var useScrollableMixin = createUseFunction(ScrollableMixin);
1165
+ function useMixin(ctor) {
1166
+ return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1167
+ return new ctor();
1168
+ })[0].reset();
1105
1169
  }
1106
1170
  function useMixinRef(mixin) {
1107
- return mixin.getMixin().reset();
1171
+ return mixin && mixin.getMixin().reset();
1108
1172
  }
1109
1173
 
1110
1174
  ;// CONCATENATED MODULE: ./tmp/brew-js/anim.js