brew-js-react 0.5.2 → 0.5.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.
package/dialog.js CHANGED
@@ -2,7 +2,7 @@ import { createElement, useEffect, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
3
  import ReactDOMClient from "./include/external/react-dom-client.js";
4
4
  import { either, extend, makeAsync, noop, pick, pipe, resolve } from "./include/zeta-dom/util.js";
5
- import { containsOrEquals, removeNode, setClass } from "./include/zeta-dom/domUtil.js";
5
+ import { containsOrEquals, removeNode } from "./include/zeta-dom/domUtil.js";
6
6
  import dom from "./include/zeta-dom/dom.js";
7
7
  import { lock, notifyAsync, preventLeave, subscribeAsync } from "./include/zeta-dom/domLock.js";
8
8
  import { closeFlyout, openFlyout } from "./include/brew-js/domAction.js";
@@ -27,14 +27,9 @@ export function createDialog(props) {
27
27
  if (props.onRender) {
28
28
  reactRoot.unmount();
29
29
  }
30
- },
31
- asyncStart: function () {
32
- setClass(root, 'loading', true);
33
- },
34
- asyncEnd: function () {
35
- setClass(root, 'loading', false);
36
30
  }
37
31
  });
32
+ root.setAttribute('loading-class', '');
38
33
  subscribeAsync(root, true);
39
34
 
40
35
  return {
@@ -1,4 +1,4 @@
1
- /*! brew-js-react v0.5.2 | (c) misonou | https://misonou.github.io */
1
+ /*! brew-js-react v0.5.3 | (c) misonou | https://misonou.github.io */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("brew-js"), require("react"), require("react-dom"), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"), require("jquery"));
@@ -413,6 +413,7 @@ var domLock_lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom
413
413
  cancelLock = domLock_lib$dom.cancelLock,
414
414
  subscribeAsync = domLock_lib$dom.subscribeAsync,
415
415
  notifyAsync = domLock_lib$dom.notifyAsync,
416
+ runAsync = domLock_lib$dom.runAsync,
416
417
  preventLeave = domLock_lib$dom.preventLeave;
417
418
 
418
419
  ;// CONCATENATED MODULE: ./tmp/brew-js/domAction.js
@@ -455,14 +456,9 @@ function createDialog(props) {
455
456
  if (props.onRender) {
456
457
  reactRoot.unmount();
457
458
  }
458
- },
459
- asyncStart: function asyncStart() {
460
- setClass(root, 'loading', true);
461
- },
462
- asyncEnd: function asyncEnd() {
463
- setClass(root, 'loading', false);
464
459
  }
465
460
  });
461
+ root.setAttribute('loading-class', '');
466
462
  subscribeAsync(root, true);
467
463
  return {
468
464
  root: root,
@@ -1272,9 +1268,9 @@ function makeTranslation(resources, defaultLang) {
1272
1268
  ;// CONCATENATED MODULE: ./src/mixins/StaticAttributeMixin.js
1273
1269
 
1274
1270
 
1275
- function StaticAttributeMixin(attributes) {
1271
+ function StaticAttributeMixin(name, value) {
1276
1272
  Mixin.call(this);
1277
- this.attributes = attributes || {};
1273
+ this.attributes = isPlainObject(name) || kv(name, value || '');
1278
1274
  }
1279
1275
  definePrototype(StaticAttributeMixin, Mixin, {
1280
1276
  getCustomAttributes: function getCustomAttributes() {
@@ -1305,9 +1301,11 @@ definePrototype(Mixin, {
1305
1301
  watchable(Mixin.prototype);
1306
1302
  util_define(Mixin, {
1307
1303
  get scrollableTarget() {
1308
- return new StaticAttributeMixin({
1309
- 'scrollable-target': ''
1310
- });
1304
+ return new StaticAttributeMixin('scrollable-target');
1305
+ },
1306
+
1307
+ get tabRoot() {
1308
+ return new StaticAttributeMixin('tab-root');
1311
1309
  },
1312
1310
 
1313
1311
  use: function use() {
@@ -1424,8 +1422,10 @@ definePrototype(StatefulMixin, Mixin, {
1424
1422
 
1425
1423
  self.onLayoutEffect(current, state);
1426
1424
  obj.elements.add(current);
1427
- } else {
1428
- obj.elements["delete"](state.element);
1425
+ } else if (state) {
1426
+ var prev = state.element;
1427
+ self.onBeforeUpdate(prev, state);
1428
+ obj.elements["delete"](prev);
1429
1429
  }
1430
1430
  };
1431
1431
  },
@@ -1445,6 +1445,7 @@ definePrototype(StatefulMixin, Mixin, {
1445
1445
  extend(state, newState);
1446
1446
  },
1447
1447
  onLayoutEffect: function onLayoutEffect(element, state) {},
1448
+ onBeforeUpdate: function onBeforeUpdate(element, state) {},
1448
1449
  clone: function clone() {
1449
1450
  return this;
1450
1451
  },
@@ -1470,7 +1471,8 @@ function checkState(self, element, state, fireEvent) {
1470
1471
  classNames[i] = element.classList.contains(i);
1471
1472
  });
1472
1473
 
1473
- if (fireEvent && !equal(prev, classNames)) {
1474
+ if (fireEvent && !equal(state.prev || prev, classNames)) {
1475
+ state.prev = prev;
1474
1476
  self.onClassNameUpdated(element, prev, extend({}, classNames));
1475
1477
  }
1476
1478
  }
@@ -1496,6 +1498,9 @@ definePrototype(ClassNameMixin, StatefulMixin, {
1496
1498
  onLayoutEffect: function onLayoutEffect(element, state) {
1497
1499
  setClass(element, state.classNames);
1498
1500
  },
1501
+ onBeforeUpdate: function onBeforeUpdate(element, state) {
1502
+ checkState(this, element, state);
1503
+ },
1499
1504
  onClassNameUpdated: function onClassNameUpdated(element, prevState, state) {}
1500
1505
  });
1501
1506
  ;// CONCATENATED MODULE: ./src/mixins/AnimateMixin.js
@@ -1524,7 +1529,7 @@ definePrototype(AnimateMixin, ClassNameMixin, {
1524
1529
  },
1525
1530
  getCustomAttributes: function getCustomAttributes() {
1526
1531
  var self = this;
1527
- return extend({}, AnimateMixinSuper.getCustomAttributes.call(self), {
1532
+ return extend(AnimateMixinSuper.getCustomAttributes.call(self), {
1528
1533
  'animate-in': (self.effects || []).join(' '),
1529
1534
  'animate-on': self.trigger || 'show'
1530
1535
  });
@@ -1540,7 +1545,7 @@ function AnimateSequenceItemMixin(className) {
1540
1545
  }
1541
1546
  definePrototype(AnimateSequenceItemMixin, ClassNameMixin, {
1542
1547
  getCustomAttributes: function getCustomAttributes() {
1543
- return extend({}, AnimateSequenceItemMixinSuper.getCustomAttributes.call(this), {
1548
+ return extend(AnimateSequenceItemMixinSuper.getCustomAttributes.call(this), {
1544
1549
  'is-animate-sequence': ''
1545
1550
  });
1546
1551
  },
@@ -1575,7 +1580,7 @@ definePrototype(AnimateSequenceMixin, AnimateMixin, {
1575
1580
  },
1576
1581
  getCustomAttributes: function getCustomAttributes() {
1577
1582
  var self = this;
1578
- return extend({}, AnimateSequenceMixinSuper.getCustomAttributes.call(self), {
1583
+ return extend(AnimateSequenceMixinSuper.getCustomAttributes.call(self), {
1579
1584
  'animate-in': null,
1580
1585
  'animate-sequence-type': (self.effects || []).join(' '),
1581
1586
  'animate-sequence': self.selector || '.' + self.className
@@ -1683,7 +1688,7 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
1683
1688
  },
1684
1689
  getCustomAttributes: function getCustomAttributes() {
1685
1690
  var self = this;
1686
- return extend({}, FlyoutMixinSuper.getCustomAttributes.call(self), {
1691
+ return extend(FlyoutMixinSuper.getCustomAttributes.call(self), {
1687
1692
  'is-flyout': '',
1688
1693
  'swipe-dismiss': self.swipeToDismiss
1689
1694
  }, self.modal && {
@@ -1781,32 +1786,35 @@ definePrototype(FocusStateMixin, StatefulMixin, {
1781
1786
  setClass(element, 'focused', state.focused);
1782
1787
  }
1783
1788
  });
1789
+ ;// CONCATENATED MODULE: ./tmp/brew-js/directive.js
1790
+
1791
+ var getDirectiveComponent = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.getDirectiveComponent,
1792
+ registerSimpleDirective = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.registerSimpleDirective,
1793
+ registerDirective = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.registerDirective;
1794
+
1784
1795
  ;// CONCATENATED MODULE: ./src/mixins/LoadingStateMixin.js
1785
1796
 
1786
1797
 
1787
1798
 
1788
1799
 
1789
- var LoadingStateMixinSuper = StatefulMixin.prototype;
1800
+
1801
+ var LoadingStateMixinSuper = ClassNameMixin.prototype;
1790
1802
  function LoadingStateMixin() {
1791
- StatefulMixin.call(this);
1803
+ ClassNameMixin.call(this, ['loading', 'loading-complete']);
1804
+ this.loading = false;
1792
1805
  }
1793
- definePrototype(LoadingStateMixin, StatefulMixin, {
1806
+ definePrototype(LoadingStateMixin, ClassNameMixin, {
1794
1807
  initElement: function initElement(element, state) {
1795
- LoadingStateMixinSuper.initElement.call(this, element, state);
1796
- this.onDispose(subscribeAsync(element, function (loading) {
1797
- state.loading = loading;
1798
- setClass(element, 'loading', loading);
1808
+ var self = this;
1809
+ LoadingStateMixinSuper.initElement.call(self, element, state);
1810
+ getDirectiveComponent(element).enableLoadingClass = true;
1811
+ self.onDispose(subscribeAsync(element, function (loading) {
1812
+ self.loading = loading || !!any(self.elements(), function (v) {
1813
+ return v !== element && getClass(v, 'loading') === true;
1814
+ });
1799
1815
  }));
1800
- },
1801
- onLayoutEffect: function onLayoutEffect(element, state) {
1802
- setClass(element, 'loading', state.loading);
1803
1816
  }
1804
1817
  });
1805
- ;// CONCATENATED MODULE: ./tmp/brew-js/directive.js
1806
-
1807
- var getDirectiveComponent = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.getDirectiveComponent,
1808
- registerDirective = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.registerDirective;
1809
-
1810
1818
  ;// CONCATENATED MODULE: ./src/mixins/ScrollableMixin.js
1811
1819
 
1812
1820
 
@@ -1828,7 +1836,7 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
1828
1836
  },
1829
1837
  getCustomAttributes: function getCustomAttributes() {
1830
1838
  var options = this.options || {};
1831
- return extend({}, ScrollableMixinSuper.getCustomAttributes.call(this), {
1839
+ return extend(ScrollableMixinSuper.getCustomAttributes.call(this), {
1832
1840
  'scrollable': [options.direction || 'both', options.handle || 'auto'].join(' ')
1833
1841
  }, options.pagedItemSelector && {
1834
1842
  'scroller-snap-page': options.paged,