brew-js-react 0.1.6 → 0.1.7
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/dist/brew-js-react.js +35 -26
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +1 -1
- package/dist/brew-js-react.min.js.map +1 -1
- package/mixins/ClassNameMixin.js +26 -7
- package/mixins/FlyoutMixin.d.ts +1 -0
- package/mixins/FlyoutMixin.js +108 -119
- package/package.json +1 -1
package/mixins/FlyoutMixin.js
CHANGED
|
@@ -1,119 +1,108 @@
|
|
|
1
|
-
import { defineAliasProperty, definePrototype, each, extend, makeArray } from "../include/zeta-dom/util.js";
|
|
2
|
-
import { app } from "../app.js";
|
|
3
|
-
import ClassNameMixin from "./ClassNameMixin.js";
|
|
4
|
-
|
|
5
|
-
const FlyoutMixinSuper = ClassNameMixin.prototype;
|
|
6
|
-
var flyoutMixinCounter = 0;
|
|
7
|
-
|
|
8
|
-
function FlyoutToggleMixin(mixin) {
|
|
9
|
-
ClassNameMixin.call(this, ['target-opened']);
|
|
10
|
-
this.flyoutMixin = mixin;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
14
|
-
getCustomAttributes: function () {
|
|
15
|
-
var element = this.flyoutMixin.elements()[0];
|
|
16
|
-
return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
|
|
17
|
-
'toggle': element && ('#' + element.id)
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
clone: function () {
|
|
21
|
-
return extend(FlyoutMixinSuper.clone.call(this), { flyoutMixin: this.flyoutMixin });
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export default function FlyoutMixin() {
|
|
26
|
-
var self = this;
|
|
27
|
-
ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
|
|
28
|
-
self.modal = false;
|
|
29
|
-
self.isFlyoutOpened = false;
|
|
30
|
-
self.animating = false;
|
|
31
|
-
self.visible = false;
|
|
32
|
-
self.toggle = new FlyoutToggleMixin(self);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
36
|
-
reset: function () {
|
|
37
|
-
this.toggle.reset();
|
|
38
|
-
return FlyoutMixinSuper.reset.call(this);
|
|
39
|
-
},
|
|
40
|
-
next: function () {
|
|
41
|
-
this.effects = undefined;
|
|
42
|
-
return FlyoutMixinSuper.next.call(this);
|
|
43
|
-
},
|
|
44
|
-
withEffects: function () {
|
|
45
|
-
this.effects = makeArray(arguments);
|
|
46
|
-
return this;
|
|
47
|
-
},
|
|
48
|
-
getCustomAttributes: function () {
|
|
49
|
-
var self = this;
|
|
50
|
-
return extend({}, FlyoutMixinSuper.getCustomAttributes.call(self), {
|
|
51
|
-
'is-flyout': ''
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'animate-
|
|
57
|
-
'animate-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
defineAliasProperty(mixin, '
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
if (isAdded('open')) {
|
|
111
|
-
self.isFlyoutOpened = true;
|
|
112
|
-
self.visible = true;
|
|
113
|
-
} else if (isAdded('closing') || isAdded('tweening-out')) {
|
|
114
|
-
self.isFlyoutOpened = false;
|
|
115
|
-
} else if (isRemoved('open')) {
|
|
116
|
-
self.visible = false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
1
|
+
import { defineAliasProperty, definePrototype, each, extend, makeArray } from "../include/zeta-dom/util.js";
|
|
2
|
+
import { app } from "../app.js";
|
|
3
|
+
import ClassNameMixin from "./ClassNameMixin.js";
|
|
4
|
+
|
|
5
|
+
const FlyoutMixinSuper = ClassNameMixin.prototype;
|
|
6
|
+
var flyoutMixinCounter = 0;
|
|
7
|
+
|
|
8
|
+
function FlyoutToggleMixin(mixin) {
|
|
9
|
+
ClassNameMixin.call(this, ['target-opened']);
|
|
10
|
+
this.flyoutMixin = mixin;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
definePrototype(FlyoutToggleMixin, ClassNameMixin, {
|
|
14
|
+
getCustomAttributes: function () {
|
|
15
|
+
var element = this.flyoutMixin.elements()[0];
|
|
16
|
+
return extend({}, FlyoutMixinSuper.getCustomAttributes.call(this), {
|
|
17
|
+
'toggle': element && ('#' + element.id)
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
clone: function () {
|
|
21
|
+
return extend(FlyoutMixinSuper.clone.call(this), { flyoutMixin: this.flyoutMixin });
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export default function FlyoutMixin() {
|
|
26
|
+
var self = this;
|
|
27
|
+
ClassNameMixin.call(self, ['open', 'closing', 'tweening-in', 'tweening-out']);
|
|
28
|
+
self.modal = false;
|
|
29
|
+
self.isFlyoutOpened = false;
|
|
30
|
+
self.animating = false;
|
|
31
|
+
self.visible = false;
|
|
32
|
+
self.toggle = new FlyoutToggleMixin(self);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
36
|
+
reset: function () {
|
|
37
|
+
this.toggle.reset();
|
|
38
|
+
return FlyoutMixinSuper.reset.call(this);
|
|
39
|
+
},
|
|
40
|
+
next: function () {
|
|
41
|
+
this.effects = undefined;
|
|
42
|
+
return FlyoutMixinSuper.next.call(this);
|
|
43
|
+
},
|
|
44
|
+
withEffects: function () {
|
|
45
|
+
this.effects = makeArray(arguments);
|
|
46
|
+
return this;
|
|
47
|
+
},
|
|
48
|
+
getCustomAttributes: function () {
|
|
49
|
+
var self = this;
|
|
50
|
+
return extend({}, FlyoutMixinSuper.getCustomAttributes.call(self), {
|
|
51
|
+
'is-flyout': '',
|
|
52
|
+
'swipe-dismiss': self.swipeToDismiss
|
|
53
|
+
}, self.modal && {
|
|
54
|
+
'is-modal': ''
|
|
55
|
+
}, self.effects && {
|
|
56
|
+
'animate-on': 'open',
|
|
57
|
+
'animate-in': self.effects.join(' '),
|
|
58
|
+
'animate-out': ''
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
onOpen: function (callback) {
|
|
62
|
+
return this.onToggleState(function (opened) {
|
|
63
|
+
if (opened) {
|
|
64
|
+
return callback();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onToggleState: function (callback) {
|
|
69
|
+
return this.watch('isFlyoutOpened', callback);
|
|
70
|
+
},
|
|
71
|
+
onVisibilityChanged: function (callback) {
|
|
72
|
+
return this.watch('visible', callback);
|
|
73
|
+
},
|
|
74
|
+
initElement: function (element, state) {
|
|
75
|
+
var self = this;
|
|
76
|
+
FlyoutMixinSuper.initElement.call(self, element, state);
|
|
77
|
+
if (!element.id) {
|
|
78
|
+
element.id = 'flyout-' + (++flyoutMixinCounter);
|
|
79
|
+
}
|
|
80
|
+
app.on(element, {
|
|
81
|
+
animationstart: function () {
|
|
82
|
+
self.animating = true;
|
|
83
|
+
},
|
|
84
|
+
animationcomplete: function () {
|
|
85
|
+
self.animating = false;
|
|
86
|
+
},
|
|
87
|
+
}, true);
|
|
88
|
+
setImmediate(function () {
|
|
89
|
+
each(self.toggle.elements(), function (i, v) {
|
|
90
|
+
v.setAttribute('toggle', '#' + element.id);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
clone: function () {
|
|
95
|
+
var self = this;
|
|
96
|
+
var mixin = extend(FlyoutMixinSuper.clone.call(self), {
|
|
97
|
+
toggle: self.toggle.ref.getMixin()
|
|
98
|
+
});
|
|
99
|
+
defineAliasProperty(mixin, 'isFlyoutOpened', self);
|
|
100
|
+
defineAliasProperty(mixin, 'modal', self);
|
|
101
|
+
return mixin;
|
|
102
|
+
},
|
|
103
|
+
onClassNameUpdated: function (element, prevState, state) {
|
|
104
|
+
var self = this;
|
|
105
|
+
self.visible = state.open;
|
|
106
|
+
self.isFlyoutOpened = state.open && !state.closing && !state['tweening-out'];
|
|
107
|
+
}
|
|
108
|
+
});
|