brew-js-react 0.4.3 → 0.4.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.
- package/dialog.d.ts +1 -1
- package/dialog.js +22 -10
- package/dist/brew-js-react.js +68 -55
- 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/LoadingStateMixin.js +4 -15
- package/mixins/ScrollableMixin.js +5 -9
- package/mixins/StatefulMixin.js +2 -2
- package/package.json +3 -3
|
@@ -10,20 +10,41 @@ export default function FocusStateMixin() {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
definePrototype(FocusStateMixin, StatefulMixin, {
|
|
13
|
+
for: function (ref) {
|
|
14
|
+
this.state.ref = ref;
|
|
15
|
+
return this;
|
|
16
|
+
},
|
|
13
17
|
initElement: function (element, state) {
|
|
14
18
|
FocusStateMixinSuper.initElement.call(this, element, state);
|
|
19
|
+
var checkTarget = function (callback, arg) {
|
|
20
|
+
var ref = state.ref;
|
|
21
|
+
var target = ref && (typeof ref === 'string' ? element.querySelector(ref) : ref.current);
|
|
22
|
+
if (target && !dom.focused(target)) {
|
|
23
|
+
callback(arg || target);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
15
26
|
this.onDispose(dom.on(element, {
|
|
16
27
|
focusin: function (e) {
|
|
17
|
-
state.focused =
|
|
28
|
+
state.focused = e.source;
|
|
18
29
|
setClass(element, 'focused', e.source);
|
|
30
|
+
checkTarget(dom.focus);
|
|
19
31
|
},
|
|
20
32
|
focusout: function () {
|
|
21
33
|
state.focused = false;
|
|
22
34
|
setClass(element, 'focused', false);
|
|
35
|
+
},
|
|
36
|
+
focuschange: function () {
|
|
37
|
+
checkTarget(dom.blur, element);
|
|
23
38
|
}
|
|
24
39
|
}));
|
|
25
40
|
},
|
|
26
41
|
getClassNames: function () {
|
|
27
|
-
|
|
42
|
+
var classes = {};
|
|
43
|
+
var focused = this.state.focused;
|
|
44
|
+
if (focused) {
|
|
45
|
+
classes.focused = true;
|
|
46
|
+
classes['focused-' + focused] = true;
|
|
47
|
+
}
|
|
48
|
+
return [classes];
|
|
28
49
|
}
|
|
29
50
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { definePrototype } from "../include/zeta-dom/util.js";
|
|
2
2
|
import { setClass } from "../include/zeta-dom/domUtil.js";
|
|
3
|
-
import {
|
|
3
|
+
import { subscribeAsync } from "../include/zeta-dom/domLock.js";
|
|
4
4
|
import dom from "../include/zeta-dom/dom.js";
|
|
5
5
|
import StatefulMixin from "./StatefulMixin.js";
|
|
6
6
|
|
|
@@ -13,20 +13,9 @@ export default function LoadingStateMixin() {
|
|
|
13
13
|
definePrototype(LoadingStateMixin, StatefulMixin, {
|
|
14
14
|
initElement: function (element, state) {
|
|
15
15
|
LoadingStateMixinSuper.initElement.call(this, element, state);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
state.loading = true;
|
|
20
|
-
setClass(element, 'loading', true);
|
|
21
|
-
},
|
|
22
|
-
asyncEnd: function () {
|
|
23
|
-
state.loading = false;
|
|
24
|
-
setClass(element, 'loading', false);
|
|
25
|
-
},
|
|
26
|
-
cancelled: function () {
|
|
27
|
-
state.loading = false;
|
|
28
|
-
setClass(element, 'loading', false);
|
|
29
|
-
}
|
|
16
|
+
this.onDispose(subscribeAsync(element, function (loading) {
|
|
17
|
+
state.loading = loading;
|
|
18
|
+
setClass(element, 'loading', loading);
|
|
30
19
|
}));
|
|
31
20
|
},
|
|
32
21
|
getClassNames: function () {
|
|
@@ -23,11 +23,9 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
|
|
|
23
23
|
var options = this.options || {};
|
|
24
24
|
return extend({}, ScrollableMixinSuper.getCustomAttributes.call(this), {
|
|
25
25
|
'scrollable': [options.direction || 'both', options.handle || 'auto'].join(' '),
|
|
26
|
-
}, options.
|
|
27
|
-
'var': '{ pageIndex: 0 }',
|
|
26
|
+
}, options.pagedItemSelector && {
|
|
28
27
|
'scroller-snap-page': options.paged,
|
|
29
28
|
'scroller-page': options.pagedItemSelector,
|
|
30
|
-
'scroller-state': 'pageIndex'
|
|
31
29
|
}, options.persistScroll && {
|
|
32
30
|
'persist-scroll': ''
|
|
33
31
|
});
|
|
@@ -38,15 +36,13 @@ definePrototype(ScrollableMixin, ClassNameMixin, {
|
|
|
38
36
|
initElement: function (element, state) {
|
|
39
37
|
var self = this;
|
|
40
38
|
self.onDispose(app.on(element, {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
extend(self, { pageIndex: e.newValues.pageIndex });
|
|
44
|
-
}
|
|
39
|
+
scrollIndexChange: function (e) {
|
|
40
|
+
self.pageIndex = e.newIndex;
|
|
45
41
|
},
|
|
46
|
-
scrollStart: function() {
|
|
42
|
+
scrollStart: function () {
|
|
47
43
|
self.scrolling = true;
|
|
48
44
|
},
|
|
49
|
-
scrollStop: function() {
|
|
45
|
+
scrollStop: function () {
|
|
50
46
|
self.scrolling = false;
|
|
51
47
|
}
|
|
52
48
|
}, true));
|
package/mixins/StatefulMixin.js
CHANGED
|
@@ -16,7 +16,7 @@ definePrototype(MixinRefImpl, {
|
|
|
16
16
|
export default function StatefulMixin() {
|
|
17
17
|
Mixin.call(this);
|
|
18
18
|
_(this, {
|
|
19
|
-
elements: new
|
|
19
|
+
elements: new WeakSet(),
|
|
20
20
|
flush: watch(this, false),
|
|
21
21
|
dispose: [],
|
|
22
22
|
states: {},
|
|
@@ -84,7 +84,7 @@ definePrototype(StatefulMixin, Mixin, {
|
|
|
84
84
|
var states = state.states;
|
|
85
85
|
combineFn(state.dispose.splice(0))();
|
|
86
86
|
state.flush();
|
|
87
|
-
state.elements
|
|
87
|
+
state.elements = new WeakSet();
|
|
88
88
|
each(states, function (i, v) {
|
|
89
89
|
delete states[i];
|
|
90
90
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brew-js-react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"repository": "github:misonou/brew-js-react",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@misonou/react-dom-client": "^1.0.3",
|
|
16
|
-
"brew-js": ">=0.5.
|
|
16
|
+
"brew-js": ">=0.5.6",
|
|
17
17
|
"waterpipe": "^2.5.0",
|
|
18
|
-
"zeta-dom": ">=0.3
|
|
18
|
+
"zeta-dom": ">=0.4.3",
|
|
19
19
|
"zeta-dom-react": ">=0.4.6"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|