brew-js-react 0.1.2 → 0.1.5

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;
@@ -392,7 +395,7 @@ function createDialog(props) {
392
395
  }
393
396
 
394
397
  if (props.onRender) {
395
- external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.render(external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(props.onRender, extend({
398
+ 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({
396
399
  closeDialog: closeDialog
397
400
  }, props)), root);
398
401
  }
@@ -431,7 +434,7 @@ function Dialog(props) {
431
434
  (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
432
435
  return dialog.close;
433
436
  }, [dialog]);
434
- return external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.createPortal(props.children, dialog.root);
437
+ return /*#__PURE__*/external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.createPortal(props.children, dialog.root);
435
438
  }
436
439
  ;// CONCATENATED MODULE: ./tmp/brew-js/defaults.js
437
440
 
@@ -493,6 +496,35 @@ var waterpipe = __webpack_require__(43);
493
496
 
494
497
 
495
498
  var empty = Object.create(null);
499
+ var toPrimitive = typeof Symbol === 'function' && Symbol.toPrimitive;
500
+
501
+ function TString(toString) {
502
+ this.toString = toString;
503
+ }
504
+
505
+ if (toPrimitive) {
506
+ TString.prototype[toPrimitive] = function () {
507
+ return this.toString();
508
+ };
509
+ }
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
+
496
528
  function useLanguage() {
497
529
  return (0,external_zeta_dom_react_.useObservableProperty)(app_app, 'language');
498
530
  }
@@ -500,25 +532,22 @@ function makeTranslation(resources, defaultLang) {
500
532
  var re = new RegExp('^(' + Object.keys(resources[defaultLang]).join('|') + ')\\.');
501
533
  var cache = {};
502
534
 
503
- function getTranslation(prefix, name, data) {
535
+ function getTranslation(prefix, name, data, noEncode) {
504
536
  var str = ((resources[app_app.language] || empty)[prefix] || empty)[name] || ((resources[defaultLang] || empty)[prefix] || empty)[name] || '';
505
- return str && data !== undefined ? waterpipe(str, data) : str;
506
- }
507
537
 
508
- function createCallback(translate) {
509
- return extend(translate, {
510
- html: function html(id, data) {
511
- return {
512
- __html: translate(id, data)
513
- };
514
- }
515
- });
538
+ if (str && (!noEncode || data !== undefined)) {
539
+ return waterpipe(str, data, {
540
+ noEncode: noEncode
541
+ });
542
+ }
543
+
544
+ return str;
516
545
  }
517
546
 
518
- function translate(key, data) {
547
+ function translate(key, data, noEncode) {
519
548
  var prefix = re.test(key) ? RegExp.$1 : '';
520
549
  var name = prefix ? key.slice(RegExp.lastMatch.length) : key;
521
- return getTranslation(prefix, name, data) || key;
550
+ return getTranslation(prefix, name, data, noEncode) || key;
522
551
  }
523
552
 
524
553
  function useTranslation() {
@@ -528,9 +557,9 @@ function makeTranslation(resources, defaultLang) {
528
557
 
529
558
  if (prefix[0]) {
530
559
  var key = prefix.join(' ');
531
- t = cache[key] || (cache[key] = createCallback(function (key, data) {
560
+ t = cache[key] || (cache[key] = createCallback(function (key, data, noEncode) {
532
561
  return single(prefix, function (v) {
533
- return getTranslation(v, key, data);
562
+ return getTranslation(v, key, data, noEncode);
534
563
  }) || key;
535
564
  }));
536
565
  }
@@ -625,6 +654,8 @@ util_define(Mixin, {
625
654
 
626
655
 
627
656
 
657
+ var _ = createPrivateStore();
658
+
628
659
  function MixinRefImpl(mixin) {
629
660
  this.mixin = mixin;
630
661
  }
@@ -636,9 +667,12 @@ definePrototype(MixinRefImpl, {
636
667
  });
637
668
  function StatefulMixin() {
638
669
  Mixin.call(this);
639
- this.states = {};
640
- this.prefix = '';
641
- this.counter = 0;
670
+
671
+ _(this, {
672
+ states: {},
673
+ prefix: '',
674
+ counter: 0
675
+ });
642
676
  }
643
677
  definePrototype(StatefulMixin, Mixin, {
644
678
  get ref() {
@@ -648,17 +682,18 @@ definePrototype(StatefulMixin, Mixin, {
648
682
  },
649
683
 
650
684
  get state() {
651
- var self = this;
652
- var key = self.prefix + self.counter;
653
- return self.states[key] || (self.states[key] = self.initState());
685
+ var obj = _(this);
686
+
687
+ var key = obj.prefix + obj.counter;
688
+ return obj.states[key] || (obj.states[key] = this.initState());
654
689
  },
655
690
 
656
691
  reset: function reset() {
657
- this.counter = 0;
692
+ _(this).counter = 0;
658
693
  return this;
659
694
  },
660
695
  next: function next() {
661
- this.counter++;
696
+ _(this).counter++;
662
697
  return this;
663
698
  },
664
699
  getRef: function getRef() {
@@ -672,7 +707,7 @@ definePrototype(StatefulMixin, Mixin, {
672
707
  };
673
708
  },
674
709
  elements: function elements() {
675
- return values(this.states).map(function (v) {
710
+ return values(_(this).states).map(function (v) {
676
711
  return v.element;
677
712
  }).filter(function (v) {
678
713
  return v;
@@ -685,11 +720,15 @@ definePrototype(StatefulMixin, Mixin, {
685
720
  },
686
721
  initElement: function initElement(element, state) {},
687
722
  clone: function clone() {
688
- return inherit(Object.getPrototypeOf(this), {
689
- states: this.states,
723
+ var clone = inherit(Object.getPrototypeOf(this));
724
+
725
+ _(clone, {
726
+ states: _(this).states,
690
727
  prefix: randomId() + '.',
691
728
  counter: 0
692
729
  });
730
+
731
+ return clone;
693
732
  }
694
733
  });
695
734
  ;// CONCATENATED MODULE: ./src/mixins/ClassNameMixin.js
@@ -859,6 +898,7 @@ var FlyoutMixinSuper = ClassNameMixin.prototype;
859
898
  var flyoutMixinCounter = 0;
860
899
  function FlyoutMixin() {
861
900
  ClassNameMixin.call(this, ['open', 'closing', 'tweening-in', 'tweening-out']);
901
+ this.modal = false;
862
902
  this.isFlyoutOpened = false;
863
903
  this.animating = false;
864
904
  this.visible = false;
@@ -880,6 +920,8 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
880
920
  getCustomAttributes: function getCustomAttributes() {
881
921
  return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
882
922
  'is-flyout': ''
923
+ }, this.modal && {
924
+ 'is-modal': ''
883
925
  }, this.effects && {
884
926
  'animate-on': 'open',
885
927
  'animate-in': this.effects.join(' '),
@@ -926,6 +968,7 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
926
968
  toggle: this.toggle.ref.getMixin()
927
969
  });
928
970
  defineAliasProperty(mixin, 'isFlyoutOpened', this);
971
+ defineAliasProperty(mixin, 'modal', this);
929
972
  return mixin;
930
973
  },
931
974
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {
@@ -1071,11 +1114,16 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1071
1114
 
1072
1115
 
1073
1116
 
1117
+
1118
+ function extendSelf(options) {
1119
+ extend(this, options);
1120
+ }
1121
+
1074
1122
  function createUseFunction(ctor) {
1075
1123
  return function () {
1076
- return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1077
- return new ctor();
1078
- })[0].reset();
1124
+ var mixin = useMixin(ctor);
1125
+ (mixin.withOptions || extendSelf).apply(mixin, arguments);
1126
+ return mixin;
1079
1127
  };
1080
1128
  }
1081
1129
 
@@ -1085,8 +1133,11 @@ var useErrorHandlerMixin = createUseFunction(ErrorHandlerMixin);
1085
1133
  var useFlyoutMixin = createUseFunction(FlyoutMixin);
1086
1134
  var useFocusStateMixin = createUseFunction(FocusStateMixin);
1087
1135
  var useLoadingStateMixin = createUseFunction(LoadingStateMixin);
1088
- function useScrollableMixin(options) {
1089
- return createUseFunction(ScrollableMixin)().withOptions(options);
1136
+ var useScrollableMixin = createUseFunction(ScrollableMixin);
1137
+ function useMixin(ctor) {
1138
+ return (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1139
+ return new ctor();
1140
+ })[0].reset();
1090
1141
  }
1091
1142
  function useMixinRef(mixin) {
1092
1143
  return mixin.getMixin().reset();
@@ -1144,7 +1195,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
1144
1195
  });
1145
1196
  }
1146
1197
 
1147
- self.currentView = external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(V, {
1198
+ self.currentView = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(V, {
1148
1199
  key: app_app.route.view,
1149
1200
  rootProps: exclude(self.props, ['views']),
1150
1201
  onComponentLoaded: function onComponentLoaded(element) {
@@ -1156,7 +1207,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
1156
1207
  });
1157
1208
  }
1158
1209
 
1159
- return 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);
1210
+ 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);
1160
1211
  },
1161
1212
  getViewComponent: function getViewComponent() {
1162
1213
  var views = this.props.views;
@@ -1171,13 +1222,13 @@ function registerView(factory, routeParams) {
1171
1222
  var Component = function Component(props) {
1172
1223
  var childProps = exclude(props, ['rootProps', 'onComponentLoaded']);
1173
1224
  var Component = (0,external_zeta_dom_react_.useAsync)(factory)[0];
1174
- return external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement('div', extend({}, props.rootProps, {
1225
+ return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement('div', extend({}, props.rootProps, {
1175
1226
  ref: function ref(element) {
1176
1227
  if (element && Component) {
1177
1228
  (props.onComponentLoaded || noop)(element);
1178
1229
  }
1179
1230
  },
1180
- children: Component && external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(Component["default"], childProps)
1231
+ children: Component && /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(Component["default"], childProps)
1181
1232
  }));
1182
1233
  };
1183
1234
 
@@ -1192,7 +1243,7 @@ function renderView() {
1192
1243
  props = views.shift();
1193
1244
  }
1194
1245
 
1195
- return external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, extend({}, props, {
1246
+ return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, extend({}, props, {
1196
1247
  views: views
1197
1248
  }));
1198
1249
  }