brew-js-react 0.4.3 → 0.4.4
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.d.ts +1 -1
- package/dialog.js +22 -10
- package/dist/brew-js-react.js +60 -31
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +2 -2
- package/dist/brew-js-react.min.js.map +1 -1
- package/mixins/FlyoutMixin.js +1 -10
- package/mixins/FlyoutToggleMixin.js +9 -6
- package/mixins/FocusStateMixin.d.ts +12 -1
- package/mixins/FocusStateMixin.js +23 -2
- package/mixins/StatefulMixin.js +2 -2
- package/package.json +1 -1
package/dialog.d.ts
CHANGED
package/dialog.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
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
|
-
import { always,
|
|
5
|
-
import { containsOrEquals, removeNode } from "./include/zeta-dom/domUtil.js";
|
|
4
|
+
import { always, either, extend, makeAsync, noop, pipe, setImmediate } from "./include/zeta-dom/util.js";
|
|
5
|
+
import { containsOrEquals, removeNode, setClass } from "./include/zeta-dom/domUtil.js";
|
|
6
6
|
import dom from "./include/zeta-dom/dom.js";
|
|
7
|
-
import { lock, preventLeave } from "./include/zeta-dom/domLock.js";
|
|
7
|
+
import { lock, notifyAsync, preventLeave, subscribeAsync } from "./include/zeta-dom/domLock.js";
|
|
8
8
|
import { closeFlyout, openFlyout } from "./include/brew-js/domAction.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -16,13 +16,22 @@ export function createDialog(props) {
|
|
|
16
16
|
var closeDialog = closeFlyout.bind(0, root);
|
|
17
17
|
var promise;
|
|
18
18
|
|
|
19
|
-
dom.on(root,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
dom.on(root, {
|
|
20
|
+
flyouthide: function () {
|
|
21
|
+
removeNode(root);
|
|
22
|
+
(props.onClose || noop)(root);
|
|
23
|
+
if (props.onRender) {
|
|
24
|
+
reactRoot.unmount();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
asyncStart: function () {
|
|
28
|
+
setClass(root, 'loading', true);
|
|
29
|
+
},
|
|
30
|
+
asyncEnd: function () {
|
|
31
|
+
setClass(root, 'loading', false);
|
|
24
32
|
}
|
|
25
33
|
});
|
|
34
|
+
subscribeAsync(root);
|
|
26
35
|
|
|
27
36
|
return {
|
|
28
37
|
root: root,
|
|
@@ -42,8 +51,8 @@ export function createDialog(props) {
|
|
|
42
51
|
var dialogProps = extend({}, props, {
|
|
43
52
|
closeDialog: function (value) {
|
|
44
53
|
var promise = makeAsync(props.onCommit || pipe)(value);
|
|
45
|
-
|
|
46
|
-
promise.then(closeDialog
|
|
54
|
+
notifyAsync(dom.activeElement, promise);
|
|
55
|
+
return promise.then(closeDialog);
|
|
47
56
|
}
|
|
48
57
|
});
|
|
49
58
|
var content = createElement(props.onRender, dialogProps);
|
|
@@ -51,6 +60,9 @@ export function createDialog(props) {
|
|
|
51
60
|
content = createElement(props.wrapper, dialogProps, content);
|
|
52
61
|
}
|
|
53
62
|
reactRoot.render(content);
|
|
63
|
+
setImmediate(function () {
|
|
64
|
+
dom.focus(root);
|
|
65
|
+
});
|
|
54
66
|
}
|
|
55
67
|
promise = openFlyout(root);
|
|
56
68
|
if (props.preventLeave) {
|
package/dist/brew-js-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! brew-js-react v0.4.
|
|
1
|
+
/*! brew-js-react v0.4.4 | (c) misonou | https://hackmd.io/@misonou/brew-js-react */
|
|
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"), (function webpackLoadOptionalExternalModule() { try { return require("react-dom/client"); } catch(e) {} }()), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"), require("jQuery"));
|
|
@@ -402,7 +402,8 @@ var _lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_z
|
|
|
402
402
|
retainFocus = _lib$dom.retainFocus,
|
|
403
403
|
releaseFocus = _lib$dom.releaseFocus,
|
|
404
404
|
iterateFocusPath = _lib$dom.iterateFocusPath,
|
|
405
|
-
dom_focus = _lib$dom.focus
|
|
405
|
+
dom_focus = _lib$dom.focus,
|
|
406
|
+
dom_blur = _lib$dom.blur;
|
|
406
407
|
|
|
407
408
|
;// CONCATENATED MODULE: ./src/include/zeta-dom/dom.js
|
|
408
409
|
|
|
@@ -444,14 +445,23 @@ function createDialog(props) {
|
|
|
444
445
|
var _closeDialog = closeFlyout.bind(0, root);
|
|
445
446
|
|
|
446
447
|
var promise;
|
|
447
|
-
zeta_dom_dom.on(root,
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
zeta_dom_dom.on(root, {
|
|
449
|
+
flyouthide: function flyouthide() {
|
|
450
|
+
removeNode(root);
|
|
451
|
+
(props.onClose || noop)(root);
|
|
450
452
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
+
if (props.onRender) {
|
|
454
|
+
reactRoot.unmount();
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
asyncStart: function asyncStart() {
|
|
458
|
+
setClass(root, 'loading', true);
|
|
459
|
+
},
|
|
460
|
+
asyncEnd: function asyncEnd() {
|
|
461
|
+
setClass(root, 'loading', false);
|
|
453
462
|
}
|
|
454
463
|
});
|
|
464
|
+
subscribeAsync(root);
|
|
455
465
|
return {
|
|
456
466
|
root: root,
|
|
457
467
|
close: _closeDialog,
|
|
@@ -473,8 +483,8 @@ function createDialog(props) {
|
|
|
473
483
|
var dialogProps = extend({}, props, {
|
|
474
484
|
closeDialog: function closeDialog(value) {
|
|
475
485
|
var promise = makeAsync(props.onCommit || pipe)(value);
|
|
476
|
-
|
|
477
|
-
promise.then(_closeDialog
|
|
486
|
+
notifyAsync(zeta_dom_dom.activeElement, promise);
|
|
487
|
+
return promise.then(_closeDialog);
|
|
478
488
|
}
|
|
479
489
|
});
|
|
480
490
|
var content = /*#__PURE__*/(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement)(props.onRender, dialogProps);
|
|
@@ -484,6 +494,9 @@ function createDialog(props) {
|
|
|
484
494
|
}
|
|
485
495
|
|
|
486
496
|
reactRoot.render(content);
|
|
497
|
+
setImmediate(function () {
|
|
498
|
+
zeta_dom_dom.focus(root);
|
|
499
|
+
});
|
|
487
500
|
}
|
|
488
501
|
|
|
489
502
|
promise = openFlyout(root);
|
|
@@ -1323,7 +1336,7 @@ function StatefulMixin() {
|
|
|
1323
1336
|
Mixin.call(this);
|
|
1324
1337
|
|
|
1325
1338
|
StatefulMixin_(this, {
|
|
1326
|
-
elements: new
|
|
1339
|
+
elements: new WeakSet(),
|
|
1327
1340
|
flush: watch(this, false),
|
|
1328
1341
|
dispose: [],
|
|
1329
1342
|
states: {},
|
|
@@ -1398,7 +1411,7 @@ definePrototype(StatefulMixin, Mixin, {
|
|
|
1398
1411
|
var states = state.states;
|
|
1399
1412
|
combineFn(state.dispose.splice(0))();
|
|
1400
1413
|
state.flush();
|
|
1401
|
-
state.elements
|
|
1414
|
+
state.elements = new WeakSet();
|
|
1402
1415
|
each(states, function (i, v) {
|
|
1403
1416
|
delete states[i];
|
|
1404
1417
|
});
|
|
@@ -1538,6 +1551,8 @@ definePrototype(AnimateSequenceMixin, AnimateMixin, {
|
|
|
1538
1551
|
;// CONCATENATED MODULE: ./src/mixins/FlyoutToggleMixin.js
|
|
1539
1552
|
|
|
1540
1553
|
|
|
1554
|
+
|
|
1555
|
+
|
|
1541
1556
|
var FlyoutToggleMixinSuper = ClassNameMixin.prototype;
|
|
1542
1557
|
function FlyoutToggleMixin(mixin) {
|
|
1543
1558
|
ClassNameMixin.call(this, ['target-opened']);
|
|
@@ -1550,11 +1565,12 @@ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
|
1550
1565
|
close: function close(value) {
|
|
1551
1566
|
return this.flyoutMixin.close(value);
|
|
1552
1567
|
},
|
|
1553
|
-
|
|
1554
|
-
var
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1568
|
+
initElement: function initElement(element, state) {
|
|
1569
|
+
var self = this;
|
|
1570
|
+
FlyoutToggleMixinSuper.initElement.call(self, element, state);
|
|
1571
|
+
self.onDispose(zeta_dom_dom.on(element, 'click', function () {
|
|
1572
|
+
openFlyout(self.flyoutMixin.elements()[0], null, element, true);
|
|
1573
|
+
}));
|
|
1558
1574
|
}
|
|
1559
1575
|
});
|
|
1560
1576
|
;// CONCATENATED MODULE: ./src/mixins/FlyoutMixin.js
|
|
@@ -1565,7 +1581,6 @@ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
|
1565
1581
|
|
|
1566
1582
|
var FlyoutMixinSuper = ClassNameMixin.prototype;
|
|
1567
1583
|
var valueMap = new WeakMap();
|
|
1568
|
-
var flyoutMixinCounter = 0;
|
|
1569
1584
|
function FlyoutMixin() {
|
|
1570
1585
|
var self = this;
|
|
1571
1586
|
ClassNameMixin.call(self, ['open', 'closing', 'visible', 'tweening-in', 'tweening-out']);
|
|
@@ -1633,11 +1648,6 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1633
1648
|
initElement: function initElement(element, state) {
|
|
1634
1649
|
var self = this;
|
|
1635
1650
|
FlyoutMixinSuper.initElement.call(self, element, state);
|
|
1636
|
-
|
|
1637
|
-
if (!element.id) {
|
|
1638
|
-
element.id = 'flyout-' + ++flyoutMixinCounter;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
1651
|
self.onDispose(app_app.on(element, {
|
|
1642
1652
|
animationstart: function animationstart() {
|
|
1643
1653
|
self.animating = true;
|
|
@@ -1646,11 +1656,6 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1646
1656
|
self.animating = false;
|
|
1647
1657
|
}
|
|
1648
1658
|
}, true));
|
|
1649
|
-
setImmediate(function () {
|
|
1650
|
-
each(self.toggle.elements(), function (i, v) {
|
|
1651
|
-
v.setAttribute('toggle', '#' + element.id);
|
|
1652
|
-
});
|
|
1653
|
-
});
|
|
1654
1659
|
},
|
|
1655
1660
|
clone: function clone() {
|
|
1656
1661
|
var self = this;
|
|
@@ -1677,23 +1682,47 @@ function FocusStateMixin() {
|
|
|
1677
1682
|
StatefulMixin.call(this);
|
|
1678
1683
|
}
|
|
1679
1684
|
definePrototype(FocusStateMixin, StatefulMixin, {
|
|
1685
|
+
"for": function _for(ref) {
|
|
1686
|
+
this.state.ref = ref;
|
|
1687
|
+
return this;
|
|
1688
|
+
},
|
|
1680
1689
|
initElement: function initElement(element, state) {
|
|
1681
1690
|
FocusStateMixinSuper.initElement.call(this, element, state);
|
|
1691
|
+
|
|
1692
|
+
var checkTarget = function checkTarget(callback, arg) {
|
|
1693
|
+
var ref = state.ref;
|
|
1694
|
+
var target = ref && (typeof ref === 'string' ? element.querySelector(ref) : ref.current);
|
|
1695
|
+
|
|
1696
|
+
if (target && !zeta_dom_dom.focused(target)) {
|
|
1697
|
+
callback(arg || target);
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1682
1701
|
this.onDispose(zeta_dom_dom.on(element, {
|
|
1683
1702
|
focusin: function focusin(e) {
|
|
1684
|
-
state.focused =
|
|
1703
|
+
state.focused = e.source;
|
|
1685
1704
|
setClass(element, 'focused', e.source);
|
|
1705
|
+
checkTarget(zeta_dom_dom.focus);
|
|
1686
1706
|
},
|
|
1687
1707
|
focusout: function focusout() {
|
|
1688
1708
|
state.focused = false;
|
|
1689
1709
|
setClass(element, 'focused', false);
|
|
1710
|
+
},
|
|
1711
|
+
focuschange: function focuschange() {
|
|
1712
|
+
checkTarget(zeta_dom_dom.blur, element);
|
|
1690
1713
|
}
|
|
1691
1714
|
}));
|
|
1692
1715
|
},
|
|
1693
1716
|
getClassNames: function getClassNames() {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1717
|
+
var classes = {};
|
|
1718
|
+
var focused = this.state.focused;
|
|
1719
|
+
|
|
1720
|
+
if (focused) {
|
|
1721
|
+
classes.focused = true;
|
|
1722
|
+
classes['focused-' + focused] = true;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
return [classes];
|
|
1697
1726
|
}
|
|
1698
1727
|
});
|
|
1699
1728
|
;// CONCATENATED MODULE: ./src/mixins/LoadingStateMixin.js
|