brew-js-react 0.1.4 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
@@ -673,9 +676,10 @@ function StatefulMixin() {
673
676
  }
674
677
  definePrototype(StatefulMixin, Mixin, {
675
678
  get ref() {
676
- var state = this.state;
677
- this.next();
678
- 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()));
679
683
  },
680
684
 
681
685
  get state() {
@@ -732,7 +736,27 @@ definePrototype(StatefulMixin, Mixin, {
732
736
 
733
737
 
734
738
 
739
+
735
740
  var ClassNameMixinSuper = StatefulMixin.prototype;
741
+
742
+ function checkState(self, element, state, isAsync) {
743
+ var classNames = state.classNames;
744
+ var prev = extend({}, classNames);
745
+ each(self.classNames, function (i, v) {
746
+ classNames[v] = element.classList.contains(v);
747
+ });
748
+
749
+ if (!equal(prev, classNames)) {
750
+ var cb = self.onClassNameUpdated.bind(self, element, prev, extend({}, classNames));
751
+
752
+ if (isAsync) {
753
+ setImmediate(cb);
754
+ } else {
755
+ cb();
756
+ }
757
+ }
758
+ }
759
+
736
760
  function ClassNameMixin(classNames) {
737
761
  StatefulMixin.call(this);
738
762
  this.classNames = classNames || [];
@@ -741,6 +765,16 @@ definePrototype(ClassNameMixin, StatefulMixin, {
741
765
  getClassNames: function getClassNames() {
742
766
  return [this.state.classNames];
743
767
  },
768
+ getRef: function getRef() {
769
+ var self = this;
770
+ var element = self.state.element;
771
+
772
+ if (element && containsOrEquals(root, element)) {
773
+ checkState(self, element, self.state, true);
774
+ }
775
+
776
+ return ClassNameMixinSuper.getRef.call(this);
777
+ },
744
778
  initState: function initState() {
745
779
  return {
746
780
  element: null,
@@ -751,14 +785,7 @@ definePrototype(ClassNameMixin, StatefulMixin, {
751
785
  var self = this;
752
786
  zeta_dom_dom.watchAttributes(element, ['class'], function (nodes) {
753
787
  if (nodes.includes(element)) {
754
- var prev = extend({}, state.classNames);
755
- each(self.classNames, function (i, v) {
756
- state.classNames[v] = element.classList.contains(v);
757
- });
758
-
759
- if (!equal(prev, state.classNames)) {
760
- self.onClassNameUpdated(element, prev, state.classNames);
761
- }
788
+ checkState(self, element, state);
762
789
  }
763
790
  });
764
791
  },
@@ -778,23 +805,26 @@ function AnimateMixin() {
778
805
  }
779
806
  definePrototype(AnimateMixin, ClassNameMixin, {
780
807
  next: function next() {
781
- this.effects = undefined;
782
- this.trigger = undefined;
783
- return AnimateMixinSuper.next.call(this);
808
+ var self = this;
809
+ self.effects = undefined;
810
+ self.trigger = undefined;
811
+ return AnimateMixinSuper.next.call(self);
784
812
  },
785
813
  "with": function _with(props) {
786
- this.effects = props.effects;
787
- this.trigger = props.trigger;
788
- return this;
814
+ var self = this;
815
+ self.effects = props.effects;
816
+ self.trigger = props.trigger;
817
+ return self;
789
818
  },
790
819
  withEffects: function withEffects() {
791
820
  this.effects = makeArray(arguments);
792
821
  return this;
793
822
  },
794
823
  getCustomAttributes: function getCustomAttributes() {
795
- return extend({}, AnimateMixinSuper.getCustomAttributes.call(this), {
796
- 'animate-in': (this.effects || []).join(' '),
797
- 'animate-on': this.trigger || 'show'
824
+ var self = this;
825
+ return extend({}, AnimateMixinSuper.getCustomAttributes.call(self), {
826
+ 'animate-in': (self.effects || []).join(' '),
827
+ 'animate-on': self.trigger || 'show'
798
828
  });
799
829
  }
800
830
  });
@@ -818,9 +848,10 @@ definePrototype(AnimateSequenceItemMixin, ClassNameMixin, {
818
848
  var AnimateSequenceMixinSuper = AnimateMixin.prototype;
819
849
  var animateSequenceMixinCounter = 0;
820
850
  function AnimateSequenceMixin() {
821
- AnimateMixin.call(this);
822
- this.className = 'brew-anim-' + ++animateSequenceMixinCounter;
823
- this.item = new AnimateSequenceItemMixin(this.className);
851
+ var self = this;
852
+ AnimateMixin.call(self);
853
+ self.className = 'brew-anim-' + ++animateSequenceMixinCounter;
854
+ self.item = new AnimateSequenceItemMixin(self.className);
824
855
  }
825
856
  definePrototype(AnimateSequenceMixin, AnimateMixin, {
826
857
  reset: function reset() {
@@ -893,12 +924,33 @@ definePrototype(ErrorHandlerMixin, StatefulMixin, {
893
924
 
894
925
  var FlyoutMixinSuper = ClassNameMixin.prototype;
895
926
  var flyoutMixinCounter = 0;
927
+
928
+ function FlyoutToggleMixin(mixin) {
929
+ ClassNameMixin.call(this, ['target-opened']);
930
+ this.flyoutMixin = mixin;
931
+ }
932
+
933
+ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
934
+ getCustomAttributes: function getCustomAttributes() {
935
+ var element = this.flyoutMixin.elements()[0];
936
+ return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
937
+ 'toggle': element && '#' + element.id
938
+ });
939
+ },
940
+ clone: function clone() {
941
+ return extend(FlyoutMixinSuper.clone.call(this), {
942
+ flyoutMixin: this.flyoutMixin
943
+ });
944
+ }
945
+ });
896
946
  function FlyoutMixin() {
897
- ClassNameMixin.call(this, ['open', 'closing', 'tweening-in', 'tweening-out']);
898
- this.isFlyoutOpened = false;
899
- this.animating = false;
900
- this.visible = false;
901
- this.toggle = new ClassNameMixin(['target-opened']);
947
+ var self = this;
948
+ ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
949
+ self.modal = false;
950
+ self.isFlyoutOpened = false;
951
+ self.animating = false;
952
+ self.visible = false;
953
+ self.toggle = new FlyoutToggleMixin(self);
902
954
  }
903
955
  definePrototype(FlyoutMixin, ClassNameMixin, {
904
956
  reset: function reset() {
@@ -914,11 +966,15 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
914
966
  return this;
915
967
  },
916
968
  getCustomAttributes: function getCustomAttributes() {
917
- return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
918
- 'is-flyout': ''
919
- }, this.effects && {
969
+ var self = this;
970
+ return extend({}, FlyoutMixinSuper.getCustomAttributes.call(self), {
971
+ 'is-flyout': '',
972
+ 'swipe-dismiss': self.swipeToDismiss
973
+ }, self.modal && {
974
+ 'is-modal': ''
975
+ }, self.effects && {
920
976
  'animate-on': 'open',
921
- 'animate-in': this.effects.join(' '),
977
+ 'animate-in': self.effects.join(' '),
922
978
  'animate-out': ''
923
979
  });
924
980
  },
@@ -958,31 +1014,18 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
958
1014
  });
959
1015
  },
960
1016
  clone: function clone() {
961
- var mixin = extend(FlyoutMixinSuper.clone.call(this), {
962
- toggle: this.toggle.ref.getMixin()
1017
+ var self = this;
1018
+ var mixin = extend(FlyoutMixinSuper.clone.call(self), {
1019
+ toggle: self.toggle.ref.getMixin()
963
1020
  });
964
- defineAliasProperty(mixin, 'isFlyoutOpened', this);
1021
+ defineAliasProperty(mixin, 'isFlyoutOpened', self);
1022
+ defineAliasProperty(mixin, 'modal', self);
965
1023
  return mixin;
966
1024
  },
967
1025
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {
968
1026
  var self = this;
969
-
970
- var isAdded = function isAdded(v) {
971
- return prevState[v] !== state[v] && state[v];
972
- };
973
-
974
- var isRemoved = function isRemoved(v) {
975
- return prevState[v] !== state[v] && !state[v];
976
- };
977
-
978
- if (isAdded('open')) {
979
- self.isFlyoutOpened = true;
980
- self.visible = true;
981
- } else if (isAdded('closing') || isAdded('tweening-out')) {
982
- self.isFlyoutOpened = false;
983
- } else if (isRemoved('open')) {
984
- self.visible = false;
985
- }
1027
+ self.visible = state.open;
1028
+ self.isFlyoutOpened = state.open && !state.closing && !state['tweening-out'];
986
1029
  }
987
1030
  });
988
1031
  ;// CONCATENATED MODULE: ./src/mixins/FocusStateMixin.js
@@ -1054,9 +1097,10 @@ definePrototype(LoadingStateMixin, StatefulMixin, {
1054
1097
 
1055
1098
  var ScrollableMixinSuper = ClassNameMixin.prototype;
1056
1099
  function ScrollableMixin() {
1057
- ClassNameMixin.call(this, ['scrollable-x', 'scrollable-x-l', 'scrollable-x-r', 'scrollable-y', 'scrollable-y-d', 'scrollable-y-u']);
1058
- this.target = Mixin.scrollableTarget;
1059
- this.pageIndex = 0;
1100
+ var self = this;
1101
+ ClassNameMixin.call(self, ['scrollable-x', 'scrollable-x-l', 'scrollable-x-r', 'scrollable-y', 'scrollable-y-d', 'scrollable-y-u']);
1102
+ self.target = Mixin.scrollableTarget;
1103
+ self.pageIndex = 0;
1060
1104
  }
1061
1105
  definePrototype(ScrollableMixin, ClassNameMixin, {
1062
1106
  withOptions: function withOptions(options) {
@@ -1107,11 +1151,16 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1107
1151
 
1108
1152
 
1109
1153
 
1154
+
1155
+ function extendSelf(options) {
1156
+ extend(this, options);
1157
+ }
1158
+
1110
1159
  function createUseFunction(ctor) {
1111
1160
  return function () {
1112
- return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1113
- return new ctor();
1114
- })[0].reset();
1161
+ var mixin = useMixin(ctor);
1162
+ (mixin.withOptions || extendSelf).apply(mixin, arguments);
1163
+ return mixin;
1115
1164
  };
1116
1165
  }
1117
1166
 
@@ -1121,11 +1170,14 @@ var useErrorHandlerMixin = createUseFunction(ErrorHandlerMixin);
1121
1170
  var useFlyoutMixin = createUseFunction(FlyoutMixin);
1122
1171
  var useFocusStateMixin = createUseFunction(FocusStateMixin);
1123
1172
  var useLoadingStateMixin = createUseFunction(LoadingStateMixin);
1124
- function useScrollableMixin(options) {
1125
- return createUseFunction(ScrollableMixin)().withOptions(options);
1173
+ var useScrollableMixin = createUseFunction(ScrollableMixin);
1174
+ function useMixin(ctor) {
1175
+ return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1176
+ return new ctor();
1177
+ })[0].reset();
1126
1178
  }
1127
1179
  function useMixinRef(mixin) {
1128
- return mixin.getMixin().reset();
1180
+ return mixin && mixin.getMixin().reset();
1129
1181
  }
1130
1182
 
1131
1183
  ;// CONCATENATED MODULE: ./tmp/brew-js/anim.js