brew-js-react 0.4.2 → 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 +120 -65
- 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/hooks.js +7 -6
- 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/ScrollableMixin.d.ts +3 -2
- package/mixins/ScrollableMixin.js +2 -0
- package/mixins/StatefulMixin.js +2 -2
- package/package.json +1 -1
- package/view.js +36 -17
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);
|
|
@@ -590,15 +603,17 @@ var setBaseUrl = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_br
|
|
|
590
603
|
|
|
591
604
|
|
|
592
605
|
|
|
606
|
+
var _ = createPrivateStore();
|
|
607
|
+
|
|
593
608
|
var root = zeta_dom_dom.root;
|
|
594
609
|
var routeMap = new Map();
|
|
595
610
|
var usedParams = {};
|
|
596
611
|
var sortedViews = [];
|
|
597
612
|
var emitter = new ZetaEventContainer();
|
|
598
|
-
var
|
|
599
|
-
container: root
|
|
600
|
-
active: true
|
|
613
|
+
var rootContext = freeze(extend(new ViewContext(null, null), {
|
|
614
|
+
container: root
|
|
601
615
|
}));
|
|
616
|
+
var StateContext = /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createContext(rootContext);
|
|
602
617
|
var errorView;
|
|
603
618
|
/** @type {Partial<Zeta.ZetaEventType<"beforepageload", Brew.RouterEventMap, Element>>} */
|
|
604
619
|
|
|
@@ -606,11 +621,25 @@ var view_event = {};
|
|
|
606
621
|
onAppInit(function () {
|
|
607
622
|
app_app.on('beforepageload', function (e) {
|
|
608
623
|
view_event = e;
|
|
624
|
+
|
|
625
|
+
_(rootContext).setPage(app_app.page);
|
|
609
626
|
});
|
|
610
627
|
});
|
|
611
628
|
|
|
612
|
-
function ViewContext(view) {
|
|
613
|
-
|
|
629
|
+
function ViewContext(view, page) {
|
|
630
|
+
var self = this;
|
|
631
|
+
defineOwnProperty(self, 'view', view, true);
|
|
632
|
+
|
|
633
|
+
_(self, {
|
|
634
|
+
setPage: defineObservableProperty(self, 'page', page, true),
|
|
635
|
+
setActive: defineObservableProperty(self, 'active', true, true)
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
watch(self, 'page', function (page, previousPage) {
|
|
639
|
+
emitter.emit('pagechange', self, {
|
|
640
|
+
previousPage: previousPage
|
|
641
|
+
});
|
|
642
|
+
});
|
|
614
643
|
}
|
|
615
644
|
|
|
616
645
|
definePrototype(ViewContext, {
|
|
@@ -676,31 +705,40 @@ function ViewContainer() {
|
|
|
676
705
|
this.stateId = history.state;
|
|
677
706
|
}
|
|
678
707
|
|
|
708
|
+
ViewContainer.contextType = StateContext;
|
|
679
709
|
definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react_root_React_.Component, {
|
|
680
710
|
componentDidMount: function componentDidMount() {
|
|
681
711
|
/** @type {any} */
|
|
682
712
|
var self = this;
|
|
683
713
|
self.componentWillUnmount = combineFn(watch(app_app.route, function () {
|
|
684
|
-
self.setActive(self.getViewComponent() === self.currentViewComponent);
|
|
714
|
+
(self.setActive || noop)(self.getViewComponent() === self.currentViewComponent);
|
|
685
715
|
}), app_app.on('beforepageload', function () {
|
|
686
716
|
self.stateId = history.state;
|
|
687
|
-
|
|
688
|
-
self.
|
|
717
|
+
|
|
718
|
+
if (self.context === rootContext || self.updateOnNext) {
|
|
719
|
+
view_event.waitFor(new Promise(function (resolve) {
|
|
720
|
+
self.onRender = resolve;
|
|
721
|
+
}));
|
|
722
|
+
self.updateView();
|
|
723
|
+
self.forceUpdate();
|
|
724
|
+
}
|
|
689
725
|
}));
|
|
690
726
|
},
|
|
691
727
|
render: function render() {
|
|
692
728
|
/** @type {any} */
|
|
693
729
|
var self = this;
|
|
694
730
|
|
|
695
|
-
if (history.state === self.stateId) {
|
|
731
|
+
if (history.state === self.stateId && self.context.active) {
|
|
696
732
|
self.updateView();
|
|
697
733
|
}
|
|
698
734
|
|
|
735
|
+
(self.onRender || noop)();
|
|
699
736
|
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);
|
|
700
737
|
},
|
|
701
738
|
updateView: function updateView() {
|
|
702
739
|
var self = this;
|
|
703
740
|
var V = self.getViewComponent();
|
|
741
|
+
self.updateOnNext = false;
|
|
704
742
|
|
|
705
743
|
if (V) {
|
|
706
744
|
// ensure the current path actually corresponds to the matched view
|
|
@@ -709,6 +747,8 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
709
747
|
|
|
710
748
|
if (targetPath !== removeQueryAndHash(app_app.path)) {
|
|
711
749
|
app_app.navigate(targetPath, true);
|
|
750
|
+
self.updateOnNext = true;
|
|
751
|
+
return;
|
|
712
752
|
}
|
|
713
753
|
}
|
|
714
754
|
|
|
@@ -728,6 +768,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
728
768
|
});
|
|
729
769
|
}
|
|
730
770
|
|
|
771
|
+
(self.cancelPrevious || noop)();
|
|
731
772
|
var onComponentLoaded;
|
|
732
773
|
var promise = new Promise(function (resolve) {
|
|
733
774
|
onComponentLoaded = resolve;
|
|
@@ -743,7 +784,7 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
743
784
|
});
|
|
744
785
|
notifyAsync(element, promise);
|
|
745
786
|
});
|
|
746
|
-
var state = new ViewContext(V);
|
|
787
|
+
var state = new ViewContext(V, app_app.page);
|
|
747
788
|
var viewProps = freeze({
|
|
748
789
|
navigationType: view_event.navigationType,
|
|
749
790
|
viewContext: state,
|
|
@@ -758,17 +799,11 @@ definePrototype(ViewContainer, external_commonjs_react_commonjs2_react_amd_react
|
|
|
758
799
|
onComponentLoaded: onComponentLoaded,
|
|
759
800
|
viewProps: viewProps
|
|
760
801
|
}))));
|
|
761
|
-
extend(self, {
|
|
802
|
+
extend(self, _(state), {
|
|
803
|
+
cancelPrevious: onComponentLoaded,
|
|
762
804
|
currentPath: app_app.path,
|
|
763
805
|
currentView: view,
|
|
764
|
-
currentViewComponent: V
|
|
765
|
-
setPage: defineObservableProperty(state, 'page', app_app.page, true),
|
|
766
|
-
setActive: defineObservableProperty(state, 'active', true, true)
|
|
767
|
-
});
|
|
768
|
-
watch(state, 'page', function (page, previousPage) {
|
|
769
|
-
emitter.emit('pagechange', state, {
|
|
770
|
-
previousPage: previousPage
|
|
771
|
-
});
|
|
806
|
+
currentViewComponent: V
|
|
772
807
|
});
|
|
773
808
|
(view_event.waitFor || noop)(promise);
|
|
774
809
|
}
|
|
@@ -846,6 +881,7 @@ function createViewComponent(factory) {
|
|
|
846
881
|
if (isThenable(children)) {
|
|
847
882
|
promise = children;
|
|
848
883
|
children = null;
|
|
884
|
+
catchAsync(promise);
|
|
849
885
|
}
|
|
850
886
|
|
|
851
887
|
var state = (0,external_zeta_dom_react_.useAsync)(function () {
|
|
@@ -994,10 +1030,11 @@ function useAppReadyState() {
|
|
|
994
1030
|
}
|
|
995
1031
|
function useRouteParam(name, defaultValue) {
|
|
996
1032
|
var container = useViewContext();
|
|
1033
|
+
var params = container.page.params;
|
|
997
1034
|
var route = app_app.route;
|
|
998
|
-
var value =
|
|
1035
|
+
var value = params[name] || '';
|
|
999
1036
|
var ref = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useRef)(value);
|
|
1000
|
-
var forceUpdate = (0,
|
|
1037
|
+
var forceUpdate = (0,external_zeta_dom_react_.useUpdateTrigger)();
|
|
1001
1038
|
(0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
|
|
1002
1039
|
var setValue = function setValue() {
|
|
1003
1040
|
var current = route[name] || '';
|
|
@@ -1005,7 +1042,7 @@ function useRouteParam(name, defaultValue) {
|
|
|
1005
1042
|
if (current !== ref.current) {
|
|
1006
1043
|
if (container.active) {
|
|
1007
1044
|
ref.current = current;
|
|
1008
|
-
forceUpdate(
|
|
1045
|
+
forceUpdate();
|
|
1009
1046
|
} else {
|
|
1010
1047
|
watch(container, 'active', setValue);
|
|
1011
1048
|
}
|
|
@@ -1025,8 +1062,8 @@ function useRouteParam(name, defaultValue) {
|
|
|
1025
1062
|
}, [name, defaultValue]);
|
|
1026
1063
|
ref.current = value;
|
|
1027
1064
|
|
|
1028
|
-
if (defaultValue
|
|
1029
|
-
app_app.navigate(route.getPath(extend({},
|
|
1065
|
+
if (defaultValue && container.active && (!value || name === 'remainingSegments' && value === '/')) {
|
|
1066
|
+
app_app.navigate(route.getPath(extend({}, params, kv(name, defaultValue))), true);
|
|
1030
1067
|
}
|
|
1031
1068
|
|
|
1032
1069
|
return value;
|
|
@@ -1284,7 +1321,7 @@ var observe_lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom
|
|
|
1284
1321
|
|
|
1285
1322
|
|
|
1286
1323
|
|
|
1287
|
-
var
|
|
1324
|
+
var StatefulMixin_ = createPrivateStore();
|
|
1288
1325
|
|
|
1289
1326
|
function MixinRefImpl(mixin) {
|
|
1290
1327
|
this.mixin = mixin;
|
|
@@ -1298,8 +1335,8 @@ definePrototype(MixinRefImpl, {
|
|
|
1298
1335
|
function StatefulMixin() {
|
|
1299
1336
|
Mixin.call(this);
|
|
1300
1337
|
|
|
1301
|
-
|
|
1302
|
-
elements: new
|
|
1338
|
+
StatefulMixin_(this, {
|
|
1339
|
+
elements: new WeakSet(),
|
|
1303
1340
|
flush: watch(this, false),
|
|
1304
1341
|
dispose: [],
|
|
1305
1342
|
states: {},
|
|
@@ -1316,18 +1353,18 @@ definePrototype(StatefulMixin, Mixin, {
|
|
|
1316
1353
|
},
|
|
1317
1354
|
|
|
1318
1355
|
get state() {
|
|
1319
|
-
var obj =
|
|
1356
|
+
var obj = StatefulMixin_(this);
|
|
1320
1357
|
|
|
1321
1358
|
var key = obj.prefix + obj.counter;
|
|
1322
1359
|
return obj.states[key] || (obj.states[key] = this.initState());
|
|
1323
1360
|
},
|
|
1324
1361
|
|
|
1325
1362
|
reset: function reset() {
|
|
1326
|
-
|
|
1363
|
+
StatefulMixin_(this).counter = 0;
|
|
1327
1364
|
return this;
|
|
1328
1365
|
},
|
|
1329
1366
|
next: function next() {
|
|
1330
|
-
|
|
1367
|
+
StatefulMixin_(this).counter++;
|
|
1331
1368
|
return this;
|
|
1332
1369
|
},
|
|
1333
1370
|
getRef: function getRef() {
|
|
@@ -1336,20 +1373,20 @@ definePrototype(StatefulMixin, Mixin, {
|
|
|
1336
1373
|
return function (current) {
|
|
1337
1374
|
state.element = current;
|
|
1338
1375
|
|
|
1339
|
-
if (current && setAdd(
|
|
1376
|
+
if (current && setAdd(StatefulMixin_(self).elements, current)) {
|
|
1340
1377
|
self.initElement(current, state);
|
|
1341
1378
|
}
|
|
1342
1379
|
};
|
|
1343
1380
|
},
|
|
1344
1381
|
elements: function elements() {
|
|
1345
|
-
return values(
|
|
1382
|
+
return values(StatefulMixin_(this).states).map(function (v) {
|
|
1346
1383
|
return v.element;
|
|
1347
1384
|
}).filter(function (v) {
|
|
1348
1385
|
return v;
|
|
1349
1386
|
});
|
|
1350
1387
|
},
|
|
1351
1388
|
onDispose: function onDispose(callback) {
|
|
1352
|
-
|
|
1389
|
+
StatefulMixin_(this).dispose.push(callback);
|
|
1353
1390
|
},
|
|
1354
1391
|
initState: function initState() {
|
|
1355
1392
|
return {
|
|
@@ -1361,7 +1398,7 @@ definePrototype(StatefulMixin, Mixin, {
|
|
|
1361
1398
|
var self = this;
|
|
1362
1399
|
var clone = inherit(Object.getPrototypeOf(self), self);
|
|
1363
1400
|
|
|
1364
|
-
|
|
1401
|
+
StatefulMixin_(clone, extend({}, StatefulMixin_(self), {
|
|
1365
1402
|
prefix: randomId() + '.',
|
|
1366
1403
|
counter: 0
|
|
1367
1404
|
}));
|
|
@@ -1369,12 +1406,12 @@ definePrototype(StatefulMixin, Mixin, {
|
|
|
1369
1406
|
return clone;
|
|
1370
1407
|
},
|
|
1371
1408
|
dispose: function dispose() {
|
|
1372
|
-
var state =
|
|
1409
|
+
var state = StatefulMixin_(this);
|
|
1373
1410
|
|
|
1374
1411
|
var states = state.states;
|
|
1375
1412
|
combineFn(state.dispose.splice(0))();
|
|
1376
1413
|
state.flush();
|
|
1377
|
-
state.elements
|
|
1414
|
+
state.elements = new WeakSet();
|
|
1378
1415
|
each(states, function (i, v) {
|
|
1379
1416
|
delete states[i];
|
|
1380
1417
|
});
|
|
@@ -1514,6 +1551,8 @@ definePrototype(AnimateSequenceMixin, AnimateMixin, {
|
|
|
1514
1551
|
;// CONCATENATED MODULE: ./src/mixins/FlyoutToggleMixin.js
|
|
1515
1552
|
|
|
1516
1553
|
|
|
1554
|
+
|
|
1555
|
+
|
|
1517
1556
|
var FlyoutToggleMixinSuper = ClassNameMixin.prototype;
|
|
1518
1557
|
function FlyoutToggleMixin(mixin) {
|
|
1519
1558
|
ClassNameMixin.call(this, ['target-opened']);
|
|
@@ -1526,11 +1565,12 @@ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
|
1526
1565
|
close: function close(value) {
|
|
1527
1566
|
return this.flyoutMixin.close(value);
|
|
1528
1567
|
},
|
|
1529
|
-
|
|
1530
|
-
var
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
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
|
+
}));
|
|
1534
1574
|
}
|
|
1535
1575
|
});
|
|
1536
1576
|
;// CONCATENATED MODULE: ./src/mixins/FlyoutMixin.js
|
|
@@ -1541,7 +1581,6 @@ definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
|
1541
1581
|
|
|
1542
1582
|
var FlyoutMixinSuper = ClassNameMixin.prototype;
|
|
1543
1583
|
var valueMap = new WeakMap();
|
|
1544
|
-
var flyoutMixinCounter = 0;
|
|
1545
1584
|
function FlyoutMixin() {
|
|
1546
1585
|
var self = this;
|
|
1547
1586
|
ClassNameMixin.call(self, ['open', 'closing', 'visible', 'tweening-in', 'tweening-out']);
|
|
@@ -1609,11 +1648,6 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1609
1648
|
initElement: function initElement(element, state) {
|
|
1610
1649
|
var self = this;
|
|
1611
1650
|
FlyoutMixinSuper.initElement.call(self, element, state);
|
|
1612
|
-
|
|
1613
|
-
if (!element.id) {
|
|
1614
|
-
element.id = 'flyout-' + ++flyoutMixinCounter;
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
1651
|
self.onDispose(app_app.on(element, {
|
|
1618
1652
|
animationstart: function animationstart() {
|
|
1619
1653
|
self.animating = true;
|
|
@@ -1622,11 +1656,6 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1622
1656
|
self.animating = false;
|
|
1623
1657
|
}
|
|
1624
1658
|
}, true));
|
|
1625
|
-
setImmediate(function () {
|
|
1626
|
-
each(self.toggle.elements(), function (i, v) {
|
|
1627
|
-
v.setAttribute('toggle', '#' + element.id);
|
|
1628
|
-
});
|
|
1629
|
-
});
|
|
1630
1659
|
},
|
|
1631
1660
|
clone: function clone() {
|
|
1632
1661
|
var self = this;
|
|
@@ -1653,23 +1682,47 @@ function FocusStateMixin() {
|
|
|
1653
1682
|
StatefulMixin.call(this);
|
|
1654
1683
|
}
|
|
1655
1684
|
definePrototype(FocusStateMixin, StatefulMixin, {
|
|
1685
|
+
"for": function _for(ref) {
|
|
1686
|
+
this.state.ref = ref;
|
|
1687
|
+
return this;
|
|
1688
|
+
},
|
|
1656
1689
|
initElement: function initElement(element, state) {
|
|
1657
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
|
+
|
|
1658
1701
|
this.onDispose(zeta_dom_dom.on(element, {
|
|
1659
1702
|
focusin: function focusin(e) {
|
|
1660
|
-
state.focused =
|
|
1703
|
+
state.focused = e.source;
|
|
1661
1704
|
setClass(element, 'focused', e.source);
|
|
1705
|
+
checkTarget(zeta_dom_dom.focus);
|
|
1662
1706
|
},
|
|
1663
1707
|
focusout: function focusout() {
|
|
1664
1708
|
state.focused = false;
|
|
1665
1709
|
setClass(element, 'focused', false);
|
|
1710
|
+
},
|
|
1711
|
+
focuschange: function focuschange() {
|
|
1712
|
+
checkTarget(zeta_dom_dom.blur, element);
|
|
1666
1713
|
}
|
|
1667
1714
|
}));
|
|
1668
1715
|
},
|
|
1669
1716
|
getClassNames: function getClassNames() {
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
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];
|
|
1673
1726
|
}
|
|
1674
1727
|
});
|
|
1675
1728
|
;// CONCATENATED MODULE: ./src/mixins/LoadingStateMixin.js
|
|
@@ -1741,6 +1794,8 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
|
|
|
1741
1794
|
'scroller-snap-page': options.paged,
|
|
1742
1795
|
'scroller-page': options.pagedItemSelector,
|
|
1743
1796
|
'scroller-state': 'pageIndex'
|
|
1797
|
+
}, options.persistScroll && {
|
|
1798
|
+
'persist-scroll': ''
|
|
1744
1799
|
});
|
|
1745
1800
|
},
|
|
1746
1801
|
onPageIndexChanged: function onPageIndexChanged(callback) {
|