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.
@@ -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
- }, self.modal && {
53
- 'is-modal': ''
54
- }, self.effects && {
55
- 'animate-on': 'open',
56
- 'animate-in': self.effects.join(' '),
57
- 'animate-out': ''
58
- });
59
- },
60
- onOpen: function (callback) {
61
- return this.onToggleState(function (opened) {
62
- if (opened) {
63
- return callback();
64
- }
65
- });
66
- },
67
- onToggleState: function (callback) {
68
- return this.watch('isFlyoutOpened', callback);
69
- },
70
- onVisibilityChanged: function (callback) {
71
- return this.watch('visible', callback);
72
- },
73
- initElement: function (element, state) {
74
- var self = this;
75
- FlyoutMixinSuper.initElement.call(self, element, state);
76
- if (!element.id) {
77
- element.id = 'flyout-' + (++flyoutMixinCounter);
78
- }
79
- app.on(element, {
80
- animationstart: function () {
81
- self.animating = true;
82
- },
83
- animationcomplete: function () {
84
- self.animating = false;
85
- },
86
- }, true);
87
- setImmediate(function () {
88
- each(self.toggle.elements(), function (i, v) {
89
- v.setAttribute('toggle', '#' + element.id);
90
- });
91
- });
92
- },
93
- clone: function () {
94
- var self = this;
95
- var mixin = extend(FlyoutMixinSuper.clone.call(self), {
96
- toggle: self.toggle.ref.getMixin()
97
- });
98
- defineAliasProperty(mixin, 'isFlyoutOpened', self);
99
- defineAliasProperty(mixin, 'modal', self);
100
- return mixin;
101
- },
102
- onClassNameUpdated: function (element, prevState, state) {
103
- var self = this;
104
- var isAdded = function (v) {
105
- return prevState[v] !== state[v] && state[v];
106
- };
107
- var isRemoved = function (v) {
108
- return prevState[v] !== state[v] && !state[v];
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
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brew-js-react",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "index.js",