brew-js-react 0.1.6 → 0.1.9

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,16 +1,24 @@
1
1
  (function webpackUniversalModuleDefinition(root, factory) {
2
2
  if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"));
3
+ module.exports = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"), require("jQuery"));
4
4
  else if(typeof define === 'function' && define.amd)
5
- define("brew-js-react", ["brew-js", "react", "react-dom", "zeta-dom", "zeta-dom-react", "waterpipe"], factory);
5
+ define("brew-js-react", ["brew-js", "react", "react-dom", "zeta-dom", "zeta-dom-react", "waterpipe", "jQuery"], factory);
6
6
  else if(typeof exports === 'object')
7
- exports["brew-js-react"] = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"));
7
+ exports["brew-js-react"] = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"), require("jQuery"));
8
8
  else
9
- root["brew-js-react"] = factory(root["brew"], root["React"], root["ReactDOM"], root["zeta"], root["zeta-dom-react"], root["waterpipe"]);
10
- })(self, function(__WEBPACK_EXTERNAL_MODULE__80__, __WEBPACK_EXTERNAL_MODULE__359__, __WEBPACK_EXTERNAL_MODULE__318__, __WEBPACK_EXTERNAL_MODULE__654__, __WEBPACK_EXTERNAL_MODULE__103__, __WEBPACK_EXTERNAL_MODULE__28__) {
9
+ root["brew-js-react"] = factory(root["brew"], root["React"], root["ReactDOM"], root["zeta"], root["zeta-dom-react"], root["waterpipe"], root["jQuery"]);
10
+ })(self, function(__WEBPACK_EXTERNAL_MODULE__80__, __WEBPACK_EXTERNAL_MODULE__359__, __WEBPACK_EXTERNAL_MODULE__318__, __WEBPACK_EXTERNAL_MODULE__654__, __WEBPACK_EXTERNAL_MODULE__103__, __WEBPACK_EXTERNAL_MODULE__28__, __WEBPACK_EXTERNAL_MODULE__145__) {
11
11
  return /******/ (() => { // webpackBootstrap
12
12
  /******/ var __webpack_modules__ = ({
13
13
 
14
+ /***/ 145:
15
+ /***/ ((module) => {
16
+
17
+ "use strict";
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__145__;
19
+
20
+ /***/ }),
21
+
14
22
  /***/ 28:
15
23
  /***/ ((module) => {
16
24
 
@@ -59,6 +67,19 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__654__;
59
67
 
60
68
  /***/ }),
61
69
 
70
+ /***/ 346:
71
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
72
+
73
+ /// <reference types="jq-scrollable" />
74
+ // @ts-nocheck
75
+
76
+ /** @type {JQueryStatic} */
77
+ var jQuery = window.jQuery || __webpack_require__(145);
78
+
79
+ module.exports = jQuery;
80
+
81
+ /***/ }),
82
+
62
83
  /***/ 43:
63
84
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64
85
 
@@ -148,6 +169,7 @@ __webpack_require__.d(src_namespaceObject, {
148
169
  "Dialog": () => (Dialog),
149
170
  "ErrorHandlerMixin": () => (ErrorHandlerMixin),
150
171
  "FlyoutMixin": () => (FlyoutMixin),
172
+ "FlyoutToggleMixin": () => (FlyoutToggleMixin),
151
173
  "FocusStateMixin": () => (FocusStateMixin),
152
174
  "LoadingStateMixin": () => (LoadingStateMixin),
153
175
  "Mixin": () => (Mixin),
@@ -227,10 +249,14 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
227
249
  combineFn = _lib$util.combineFn,
228
250
  executeOnce = _lib$util.executeOnce,
229
251
  createPrivateStore = _lib$util.createPrivateStore,
252
+ util_setTimeout = _lib$util.setTimeout,
230
253
  setTimeoutOnce = _lib$util.setTimeoutOnce,
254
+ util_setInterval = _lib$util.setInterval,
255
+ setIntervalSafe = _lib$util.setIntervalSafe,
231
256
  util_setImmediate = _lib$util.setImmediate,
232
257
  setImmediateOnce = _lib$util.setImmediateOnce,
233
258
  throwNotFunction = _lib$util.throwNotFunction,
259
+ errorWithCode = _lib$util.errorWithCode,
234
260
  keys = _lib$util.keys,
235
261
  values = _lib$util.values,
236
262
  util_hasOwnProperty = _lib$util.hasOwnProperty,
@@ -271,7 +297,6 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
271
297
  var domUtil_lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.util,
272
298
  domReady = domUtil_lib$util.domReady,
273
299
  tagName = domUtil_lib$util.tagName,
274
- domUtil_is = domUtil_lib$util.is,
275
300
  isVisible = domUtil_lib$util.isVisible,
276
301
  matchSelector = domUtil_lib$util.matchSelector,
277
302
  comparePosition = domUtil_lib$util.comparePosition,
@@ -298,11 +323,6 @@ var domUtil_lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_do
298
323
  getContentRect = domUtil_lib$util.getContentRect,
299
324
  scrollBy = domUtil_lib$util.scrollBy,
300
325
  scrollIntoView = domUtil_lib$util.scrollIntoView,
301
- createRange = domUtil_lib$util.createRange,
302
- rangeIntersects = domUtil_lib$util.rangeIntersects,
303
- rangeEquals = domUtil_lib$util.rangeEquals,
304
- rangeCovers = domUtil_lib$util.rangeCovers,
305
- compareRangePosition = domUtil_lib$util.compareRangePosition,
306
326
  makeSelection = domUtil_lib$util.makeSelection,
307
327
  getRect = domUtil_lib$util.getRect,
308
328
  getRects = domUtil_lib$util.getRects,
@@ -332,6 +352,7 @@ var _lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_z
332
352
  releaseModal = _lib$dom.releaseModal,
333
353
  retainFocus = _lib$dom.retainFocus,
334
354
  releaseFocus = _lib$dom.releaseFocus,
355
+ iterateFocusPath = _lib$dom.iterateFocusPath,
335
356
  dom_focus = _lib$dom.focus;
336
357
 
337
358
  ;// CONCATENATED MODULE: ./src/include/zeta-dom/dom.js
@@ -736,7 +757,27 @@ definePrototype(StatefulMixin, Mixin, {
736
757
 
737
758
 
738
759
 
760
+
739
761
  var ClassNameMixinSuper = StatefulMixin.prototype;
762
+
763
+ function checkState(self, element, state, isAsync) {
764
+ var classNames = state.classNames;
765
+ var prev = extend({}, classNames);
766
+ each(self.classNames, function (i, v) {
767
+ classNames[v] = element.classList.contains(v);
768
+ });
769
+
770
+ if (!equal(prev, classNames)) {
771
+ var cb = self.onClassNameUpdated.bind(self, element, prev, extend({}, classNames));
772
+
773
+ if (isAsync) {
774
+ setImmediate(cb);
775
+ } else {
776
+ cb();
777
+ }
778
+ }
779
+ }
780
+
740
781
  function ClassNameMixin(classNames) {
741
782
  StatefulMixin.call(this);
742
783
  this.classNames = classNames || [];
@@ -745,6 +786,16 @@ definePrototype(ClassNameMixin, StatefulMixin, {
745
786
  getClassNames: function getClassNames() {
746
787
  return [this.state.classNames];
747
788
  },
789
+ getRef: function getRef() {
790
+ var self = this;
791
+ var element = self.state.element;
792
+
793
+ if (element && containsOrEquals(root, element)) {
794
+ checkState(self, element, self.state, true);
795
+ }
796
+
797
+ return ClassNameMixinSuper.getRef.call(this);
798
+ },
748
799
  initState: function initState() {
749
800
  return {
750
801
  element: null,
@@ -755,14 +806,7 @@ definePrototype(ClassNameMixin, StatefulMixin, {
755
806
  var self = this;
756
807
  zeta_dom_dom.watchAttributes(element, ['class'], function (nodes) {
757
808
  if (nodes.includes(element)) {
758
- var prev = extend({}, state.classNames);
759
- each(self.classNames, function (i, v) {
760
- state.classNames[v] = element.classList.contains(v);
761
- });
762
-
763
- if (!equal(prev, state.classNames)) {
764
- self.onClassNameUpdated(element, prev, state.classNames);
765
- }
809
+ checkState(self, element, state);
766
810
  }
767
811
  });
768
812
  },
@@ -895,31 +939,34 @@ definePrototype(ErrorHandlerMixin, StatefulMixin, {
895
939
  });
896
940
  }
897
941
  });
898
- ;// CONCATENATED MODULE: ./src/mixins/FlyoutMixin.js
942
+ ;// CONCATENATED MODULE: ./src/mixins/FlyoutToggleMixin.js
899
943
 
900
944
 
901
-
902
- var FlyoutMixinSuper = ClassNameMixin.prototype;
903
- var flyoutMixinCounter = 0;
904
-
945
+ var FlyoutToggleMixinSuper = ClassNameMixin.prototype;
905
946
  function FlyoutToggleMixin(mixin) {
906
947
  ClassNameMixin.call(this, ['target-opened']);
907
948
  this.flyoutMixin = mixin;
908
949
  }
909
-
910
950
  definePrototype(FlyoutToggleMixin, ClassNameMixin, {
911
951
  getCustomAttributes: function getCustomAttributes() {
912
952
  var element = this.flyoutMixin.elements()[0];
913
- return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
953
+ return extend({}, FlyoutToggleMixinSuper.getCustomAttributes.call(this), {
914
954
  'toggle': element && '#' + element.id
915
955
  });
916
956
  },
917
957
  clone: function clone() {
918
- return extend(FlyoutMixinSuper.clone.call(this), {
958
+ return extend(FlyoutToggleMixinSuper.clone.call(this), {
919
959
  flyoutMixin: this.flyoutMixin
920
960
  });
921
961
  }
922
962
  });
963
+ ;// CONCATENATED MODULE: ./src/mixins/FlyoutMixin.js
964
+
965
+
966
+
967
+
968
+ var FlyoutMixinSuper = ClassNameMixin.prototype;
969
+ var flyoutMixinCounter = 0;
923
970
  function FlyoutMixin() {
924
971
  var self = this;
925
972
  ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
@@ -945,7 +992,8 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
945
992
  getCustomAttributes: function getCustomAttributes() {
946
993
  var self = this;
947
994
  return extend({}, FlyoutMixinSuper.getCustomAttributes.call(self), {
948
- 'is-flyout': ''
995
+ 'is-flyout': '',
996
+ 'swipe-dismiss': self.swipeToDismiss
949
997
  }, self.modal && {
950
998
  'is-modal': ''
951
999
  }, self.effects && {
@@ -1000,23 +1048,8 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1000
1048
  },
1001
1049
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {
1002
1050
  var self = this;
1003
-
1004
- var isAdded = function isAdded(v) {
1005
- return prevState[v] !== state[v] && state[v];
1006
- };
1007
-
1008
- var isRemoved = function isRemoved(v) {
1009
- return prevState[v] !== state[v] && !state[v];
1010
- };
1011
-
1012
- if (isAdded('open')) {
1013
- self.isFlyoutOpened = true;
1014
- self.visible = true;
1015
- } else if (isAdded('closing') || isAdded('tweening-out')) {
1016
- self.isFlyoutOpened = false;
1017
- } else if (isRemoved('open')) {
1018
- self.visible = false;
1019
- }
1051
+ self.visible = state.open;
1052
+ self.isFlyoutOpened = state.open && !state.closing && !state['tweening-out'];
1020
1053
  }
1021
1054
  });
1022
1055
  ;// CONCATENATED MODULE: ./src/mixins/FocusStateMixin.js
@@ -1081,17 +1114,21 @@ definePrototype(LoadingStateMixin, StatefulMixin, {
1081
1114
  }];
1082
1115
  }
1083
1116
  });
1117
+ // EXTERNAL MODULE: ./src/include/external/jquery.js
1118
+ var jquery = __webpack_require__(346);
1084
1119
  ;// CONCATENATED MODULE: ./src/mixins/ScrollableMixin.js
1085
1120
 
1086
1121
 
1087
1122
 
1088
1123
 
1124
+
1089
1125
  var ScrollableMixinSuper = ClassNameMixin.prototype;
1090
1126
  function ScrollableMixin() {
1091
1127
  var self = this;
1092
1128
  ClassNameMixin.call(self, ['scrollable-x', 'scrollable-x-l', 'scrollable-x-r', 'scrollable-y', 'scrollable-y-d', 'scrollable-y-u']);
1093
1129
  self.target = Mixin.scrollableTarget;
1094
1130
  self.pageIndex = 0;
1131
+ self.scrolling = false;
1095
1132
  }
1096
1133
  definePrototype(ScrollableMixin, ClassNameMixin, {
1097
1134
  withOptions: function withOptions(options) {
@@ -1114,11 +1151,19 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1114
1151
  },
1115
1152
  initElement: function initElement(element, state) {
1116
1153
  var self = this;
1117
- app_app.on(element, 'statechange', function (e) {
1118
- if ('pageIndex' in e.newValues) {
1119
- extend(self, {
1120
- pageIndex: e.newValues.pageIndex
1121
- });
1154
+ app_app.on(element, {
1155
+ statechange: function statechange(e) {
1156
+ if ('pageIndex' in e.newValues) {
1157
+ extend(self, {
1158
+ pageIndex: e.newValues.pageIndex
1159
+ });
1160
+ }
1161
+ },
1162
+ scrollStart: function scrollStart() {
1163
+ self.scrolling = true;
1164
+ },
1165
+ scrollStop: function scrollStop() {
1166
+ self.scrolling = false;
1122
1167
  }
1123
1168
  }, true);
1124
1169
  },
@@ -1128,6 +1173,12 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1128
1173
  return mixin;
1129
1174
  }
1130
1175
  });
1176
+ each('destroy enable disable setOptions refresh scrollPadding stop scrollLeft scrollTop scrollBy scrollTo scrollByPage scrollToPage scrollToElement', function (i, v) {
1177
+ defineHiddenProperty(ScrollableMixin.prototype, v, function () {
1178
+ var obj = jquery(this.elements());
1179
+ return obj.scrollable.apply(obj, [v].concat(makeArray(arguments)));
1180
+ });
1181
+ });
1131
1182
  ;// CONCATENATED MODULE: ./src/mixin.js
1132
1183
 
1133
1184
 
@@ -1143,6 +1194,7 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1143
1194
 
1144
1195
 
1145
1196
 
1197
+
1146
1198
  function extendSelf(options) {
1147
1199
  extend(this, options);
1148
1200
  }
@@ -1187,12 +1239,21 @@ var animateIn = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_bre
1187
1239
 
1188
1240
 
1189
1241
  var routeMap = new Map();
1242
+ var stateId;
1190
1243
 
1191
1244
  function ViewContainer() {
1192
1245
  /** @type {any} */
1193
1246
  var self = this;
1194
1247
  external_commonjs_react_commonjs2_react_amd_react_root_React_.Component.apply(self, arguments);
1195
1248
  self.mounted = false;
1249
+
1250
+ if (!stateId) {
1251
+ stateId = history.state;
1252
+ app_app.on('navigate', function () {
1253
+ stateId = history.state;
1254
+ });
1255
+ }
1256
+
1196
1257
  self.componentWillUnmount = app_app.on('navigate', function () {
1197
1258
  if (self.mounted && self.getViewComponent()) {
1198
1259
  self.forceUpdate();
@@ -1224,8 +1285,8 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
1224
1285
  }
1225
1286
 
1226
1287
  self.currentView = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(V, {
1227
- key: app_app.route.view,
1228
- rootProps: exclude(self.props, ['views']),
1288
+ key: routeMap.get(V).id,
1289
+ rootProps: self.props.rootProps,
1229
1290
  onComponentLoaded: function onComponentLoaded(element) {
1230
1291
  self.currentElement = element;
1231
1292
  util_setImmediate(function () {
@@ -1238,17 +1299,19 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
1238
1299
  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);
1239
1300
  },
1240
1301
  getViewComponent: function getViewComponent() {
1241
- var views = this.props.views;
1242
- return any(views, isViewMatched) || void redirectTo(views[0]);
1302
+ var props = this.props;
1303
+ return any(props.views, isViewMatched) || history.state === stateId && void redirectTo(props.defaultView);
1243
1304
  }
1244
1305
  });
1245
1306
  function isViewMatched(view) {
1246
1307
  var params = routeMap.get(view);
1247
- return !!params && equal(params, pick(app_app.route, keys(params)));
1308
+ return !!params && !any(params.matchers, function (v, i) {
1309
+ var value = app_app.route[i] || '';
1310
+ return isFunction(v) ? !v(value) : (v || '') !== value;
1311
+ });
1248
1312
  }
1249
1313
  function registerView(factory, routeParams) {
1250
1314
  var Component = function Component(props) {
1251
- var childProps = exclude(props, ['rootProps', 'onComponentLoaded']);
1252
1315
  var Component = (0,external_zeta_dom_react_.useAsync)(factory)[0];
1253
1316
  return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement('div', extend({}, props.rootProps, {
1254
1317
  ref: function ref(element) {
@@ -1256,27 +1319,41 @@ function registerView(factory, routeParams) {
1256
1319
  (props.onComponentLoaded || noop)(element);
1257
1320
  }
1258
1321
  },
1259
- children: Component && /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(Component["default"], childProps)
1322
+ children: Component && /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(Component["default"])
1260
1323
  }));
1261
1324
  };
1262
1325
 
1263
- routeMap.set(Component, routeParams);
1326
+ routeParams = extend({}, routeParams);
1327
+ each(routeParams, function (i, v) {
1328
+ if (v instanceof RegExp) {
1329
+ routeParams[i] = v.test.bind(v);
1330
+ }
1331
+ });
1332
+ routeMap.set(Component, {
1333
+ id: randomId(),
1334
+ matchCount: keys(routeParams).length,
1335
+ matchers: routeParams,
1336
+ params: pick(routeParams, function (v) {
1337
+ return typeof v === 'string';
1338
+ })
1339
+ });
1264
1340
  return Component;
1265
1341
  }
1266
1342
  function renderView() {
1267
1343
  var views = makeArray(arguments);
1268
- var props;
1269
-
1270
- if (views[0] && typeof views[0] !== 'function') {
1271
- props = views.shift();
1272
- }
1273
-
1274
- return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, extend({}, props, {
1275
- views: views
1276
- }));
1344
+ var rootProps = isFunction(views[0]) ? {} : views.shift();
1345
+ var defaultView = views[0];
1346
+ views.sort(function (a, b) {
1347
+ return (routeMap.get(b) || {}).matchCount - (routeMap.get(a) || {}).matchCount;
1348
+ });
1349
+ return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, {
1350
+ rootProps: rootProps,
1351
+ views: views,
1352
+ defaultView: defaultView
1353
+ });
1277
1354
  }
1278
1355
  function linkTo(view, params) {
1279
- return app_app.route.getPath(extend({}, app_app.route, params, routeMap.get(view)));
1356
+ return app_app.route.getPath(extend({}, app_app.route, params, (routeMap.get(view) || {}).params));
1280
1357
  }
1281
1358
  function navigateTo(view, params) {
1282
1359
  return app_app.navigate(linkTo(view, params));