@leafer-in/state 1.0.2 → 1.0.3
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/state.cjs +288 -61
- package/dist/state.esm.js +289 -63
- package/dist/state.esm.min.js +1 -1
- package/dist/state.js +292 -63
- package/dist/state.min.cjs +1 -1
- package/dist/state.min.js +1 -1
- package/package.json +4 -4
- package/src/check.ts +35 -0
- package/src/decorator.ts +20 -0
- package/src/event.ts +8 -8
- package/src/helper.ts +12 -11
- package/src/index.ts +68 -14
- package/src/set.ts +32 -27
- package/src/style.ts +136 -0
- package/src/unset.ts +19 -30
- package/types/index.d.ts +6 -1
package/dist/state.esm.js
CHANGED
|
@@ -1,92 +1,314 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decorateLeafAttr, attr, State } from '@leafer-ui/draw';
|
|
2
|
+
import { MathHelper, State as State$1, isNull, PointerEvent, UI, dataType } from '@leafer-ui/core';
|
|
2
3
|
|
|
3
|
-
function
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function stateType(defaultValue, styleName) {
|
|
5
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
6
|
+
set(value) {
|
|
7
|
+
this.__setAttr(key, value);
|
|
8
|
+
this.waitLeafer(() => styleName ? State.setStyleName(this, styleName, value) : State.set(this, value));
|
|
9
|
+
}
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
function stateStyleType(defaultValue) {
|
|
13
|
+
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
14
|
+
set(value) {
|
|
15
|
+
this.__setAttr(key, value);
|
|
16
|
+
this.__layout.stateStyleChanged = true;
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function findParentButton(leaf, button) {
|
|
22
|
+
if (button && button !== true)
|
|
23
|
+
return button;
|
|
24
|
+
if (!leaf.button) {
|
|
25
|
+
let { parent } = leaf;
|
|
26
|
+
for (let i = 0; i < 2; i++) {
|
|
27
|
+
if (parent) {
|
|
28
|
+
if (parent.button)
|
|
29
|
+
return parent;
|
|
30
|
+
parent = parent.parent;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
11
33
|
}
|
|
34
|
+
return null;
|
|
12
35
|
}
|
|
13
36
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
function setStyle(leaf, style) {
|
|
38
|
+
if (typeof style !== 'object')
|
|
39
|
+
style = undefined;
|
|
40
|
+
updateStyle(leaf, style, 'in');
|
|
41
|
+
}
|
|
42
|
+
function unsetStyle(leaf, style) {
|
|
43
|
+
const { normalStyle } = leaf;
|
|
44
|
+
if (typeof style !== 'object')
|
|
45
|
+
style = undefined;
|
|
46
|
+
if (normalStyle) {
|
|
47
|
+
if (!style)
|
|
48
|
+
style = normalStyle;
|
|
49
|
+
updateStyle(leaf, style, 'out');
|
|
19
50
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
51
|
+
}
|
|
52
|
+
const emprtyStyle = {};
|
|
53
|
+
function updateStyle(leaf, style, type) {
|
|
54
|
+
const { normalStyle } = leaf;
|
|
55
|
+
if (!style)
|
|
56
|
+
style = emprtyStyle;
|
|
57
|
+
if (style.scale) {
|
|
58
|
+
MathHelper.assignScale(style, style.scale);
|
|
59
|
+
delete style.scale;
|
|
60
|
+
}
|
|
61
|
+
if (style === emprtyStyle || !State$1.canAnimate)
|
|
62
|
+
type = null;
|
|
63
|
+
let transition = type ? getTransition(type, style, leaf) : false;
|
|
64
|
+
const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
|
|
65
|
+
leaf.killAnimate('transition');
|
|
66
|
+
if (normalStyle)
|
|
67
|
+
leaf.set(normalStyle, true);
|
|
68
|
+
const statesStyle = getStyle(leaf);
|
|
69
|
+
if (statesStyle) {
|
|
70
|
+
const { animation } = statesStyle;
|
|
71
|
+
if (animation) {
|
|
72
|
+
const animate = leaf.animate(animation, undefined, 'animation', true);
|
|
73
|
+
Object.assign(statesStyle, animate.endingStyle);
|
|
74
|
+
if (type !== 'in' || style.animation !== animation)
|
|
75
|
+
animate.kill();
|
|
76
|
+
else
|
|
77
|
+
transition = false;
|
|
78
|
+
delete statesStyle.animation;
|
|
31
79
|
}
|
|
80
|
+
leaf.normalStyle = filterStyle(statesStyle, leaf);
|
|
81
|
+
leaf.set(statesStyle, true);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
leaf.normalStyle = undefined;
|
|
32
85
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
leaf.
|
|
36
|
-
leaf.
|
|
86
|
+
if (transition) {
|
|
87
|
+
const toStyle = filterStyle(fromStyle, leaf);
|
|
88
|
+
leaf.set(fromStyle, true);
|
|
89
|
+
leaf.animate([fromStyle, toStyle], transition, 'transition', true);
|
|
37
90
|
}
|
|
91
|
+
leaf.__layout.stateStyleChanged = false;
|
|
38
92
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
93
|
+
function getStyle(leaf) {
|
|
94
|
+
let exist;
|
|
95
|
+
const style = {}, { state } = leaf, button = findParentButton(leaf);
|
|
96
|
+
const stateStyle = state && leaf.states[state];
|
|
97
|
+
if (stateStyle && State$1.isState(state, leaf, button))
|
|
98
|
+
exist = assign(style, stateStyle);
|
|
99
|
+
const selectedStyle = style.selectedStyle || leaf.selectedStyle;
|
|
100
|
+
if (selectedStyle && State$1.isSelected(leaf, button))
|
|
101
|
+
exist = assign(style, selectedStyle);
|
|
102
|
+
if (State$1.isDisabled(leaf, button)) {
|
|
103
|
+
const disabledStyle = style.disabledStyle || leaf.disabledStyle;
|
|
104
|
+
if (disabledStyle)
|
|
105
|
+
exist = assign(style, disabledStyle);
|
|
51
106
|
}
|
|
52
107
|
else {
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
108
|
+
const focusStyle = style.focusStyle || leaf.focusStyle;
|
|
109
|
+
if (focusStyle && State$1.isFocus(leaf, button))
|
|
110
|
+
exist = assign(style, focusStyle);
|
|
111
|
+
const hoverStyle = style.hoverStyle || leaf.hoverStyle;
|
|
112
|
+
if (hoverStyle && State$1.isHover(leaf, button))
|
|
113
|
+
exist = assign(style, hoverStyle);
|
|
114
|
+
const pressStyle = style.pressStyle || leaf.pressStyle;
|
|
115
|
+
if (pressStyle && State$1.isPress(leaf, button))
|
|
116
|
+
exist = assign(style, pressStyle);
|
|
117
|
+
}
|
|
118
|
+
return exist ? style : undefined;
|
|
119
|
+
}
|
|
120
|
+
function filterStyle(style, data, addStyle, useAnimateExcludes) {
|
|
121
|
+
const to = addStyle ? style : {}, forStyle = addStyle || style;
|
|
122
|
+
for (let key in forStyle) {
|
|
123
|
+
if (useAnimateExcludes) {
|
|
124
|
+
if (!State$1.animateExcludes[key])
|
|
125
|
+
to[key] = data[key];
|
|
59
126
|
}
|
|
60
|
-
else
|
|
61
|
-
|
|
127
|
+
else
|
|
128
|
+
to[key] = data[key];
|
|
129
|
+
}
|
|
130
|
+
return to;
|
|
131
|
+
}
|
|
132
|
+
function filterAnimateStyle(style, data, addStyle) {
|
|
133
|
+
return filterStyle(style, data, addStyle, true);
|
|
134
|
+
}
|
|
135
|
+
function getFromStyle(leaf, style) {
|
|
136
|
+
const fromStyle = filterAnimateStyle(style, leaf), animate = leaf.animate();
|
|
137
|
+
if (animate)
|
|
138
|
+
filterAnimateStyle(fromStyle, leaf, animate.fromStyle);
|
|
139
|
+
return fromStyle;
|
|
140
|
+
}
|
|
141
|
+
function getTransition(type, style, data) {
|
|
142
|
+
let name = type === 'in' ? 'transition' : 'transitionOut';
|
|
143
|
+
if (type === 'out' && isNull(data[name]) && isNull(style[name]))
|
|
144
|
+
name = 'transition';
|
|
145
|
+
return isNull(style[name]) ? data[name] : style[name];
|
|
146
|
+
}
|
|
147
|
+
function assign(style, stateStyle) {
|
|
148
|
+
Object.assign(style, stateStyle);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function setPointerState(leaf, stateName) {
|
|
153
|
+
const style = leaf[stateName];
|
|
154
|
+
if (style)
|
|
155
|
+
setStyle(leaf, style);
|
|
156
|
+
if (leaf.button)
|
|
157
|
+
setChildrenState(leaf.children, stateName);
|
|
158
|
+
}
|
|
159
|
+
function setState(leaf, stateName, stateStyle) {
|
|
160
|
+
if (!stateStyle)
|
|
161
|
+
stateStyle = leaf.states[stateName];
|
|
162
|
+
setStyle(leaf, stateStyle);
|
|
163
|
+
if (leaf.button)
|
|
164
|
+
setChildrenState(leaf.children, null, stateName);
|
|
165
|
+
}
|
|
166
|
+
function setChildrenState(children, stateType, state) {
|
|
167
|
+
if (!children)
|
|
168
|
+
return;
|
|
169
|
+
let leaf, update;
|
|
170
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
171
|
+
leaf = children[i];
|
|
172
|
+
if (stateType) {
|
|
173
|
+
update = true;
|
|
174
|
+
switch (stateType) {
|
|
175
|
+
case 'hoverStyle':
|
|
176
|
+
if (State$1.isHover(leaf))
|
|
177
|
+
update = false;
|
|
178
|
+
break;
|
|
179
|
+
case 'pressStyle':
|
|
180
|
+
if (State$1.isPress(leaf))
|
|
181
|
+
update = false;
|
|
182
|
+
break;
|
|
183
|
+
case 'focusStyle':
|
|
184
|
+
if (State$1.isFocus(leaf))
|
|
185
|
+
update = false;
|
|
186
|
+
}
|
|
187
|
+
if (update)
|
|
188
|
+
setPointerState(leaf, stateType);
|
|
62
189
|
}
|
|
190
|
+
else if (state)
|
|
191
|
+
setState(leaf, state);
|
|
192
|
+
if (leaf.isBranch)
|
|
193
|
+
setChildrenState(leaf.children, stateType, state);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function unsetPointerState(leaf, stateName) {
|
|
198
|
+
const style = leaf[stateName];
|
|
199
|
+
if (style)
|
|
200
|
+
unsetStyle(leaf, style);
|
|
201
|
+
if (leaf.button)
|
|
202
|
+
unsetChildrenState(leaf.children, stateName);
|
|
203
|
+
}
|
|
204
|
+
function unsetState(leaf, stateName, stateStyle) {
|
|
205
|
+
unsetStyle(leaf, stateStyle);
|
|
206
|
+
if (leaf.button)
|
|
207
|
+
unsetChildrenState(leaf.children, null, stateName);
|
|
208
|
+
}
|
|
209
|
+
function unsetChildrenState(children, stateType, state) {
|
|
210
|
+
if (!children)
|
|
211
|
+
return;
|
|
212
|
+
let leaf;
|
|
213
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
214
|
+
leaf = children[i];
|
|
215
|
+
if (stateType)
|
|
216
|
+
unsetPointerState(leaf, stateType);
|
|
217
|
+
else if (state)
|
|
218
|
+
unsetState(leaf, state);
|
|
219
|
+
if (leaf.isBranch)
|
|
220
|
+
unsetChildrenState(leaf.children, stateType, state);
|
|
63
221
|
}
|
|
64
222
|
}
|
|
65
223
|
|
|
66
224
|
function updateEventStyle(leaf, eventType) {
|
|
67
225
|
switch (eventType) {
|
|
68
226
|
case PointerEvent.ENTER:
|
|
69
|
-
|
|
227
|
+
setPointerState(leaf, 'hoverStyle');
|
|
70
228
|
break;
|
|
71
229
|
case PointerEvent.LEAVE:
|
|
72
|
-
|
|
230
|
+
unsetPointerState(leaf, 'hoverStyle');
|
|
73
231
|
break;
|
|
74
232
|
case PointerEvent.DOWN:
|
|
75
|
-
|
|
233
|
+
setPointerState(leaf, 'pressStyle');
|
|
76
234
|
break;
|
|
77
235
|
case PointerEvent.UP:
|
|
78
|
-
|
|
236
|
+
unsetPointerState(leaf, 'pressStyle');
|
|
79
237
|
break;
|
|
80
238
|
}
|
|
81
239
|
}
|
|
82
240
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
241
|
+
function checkPointerState(fnName, leaf, button) {
|
|
242
|
+
let find;
|
|
243
|
+
const interaction = leaf.leafer ? leaf.leafer.interaction : null;
|
|
244
|
+
if (interaction) {
|
|
245
|
+
find = interaction[fnName](leaf);
|
|
246
|
+
if (!find && button) {
|
|
247
|
+
const parentButton = findParentButton(leaf, button);
|
|
248
|
+
if (parentButton)
|
|
249
|
+
find = interaction[fnName](parentButton);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return find;
|
|
253
|
+
}
|
|
254
|
+
function checkFixedState(attrName, leaf, button) {
|
|
255
|
+
let find = leaf[attrName];
|
|
256
|
+
if (!find && button) {
|
|
257
|
+
const parentButton = findParentButton(leaf, button);
|
|
258
|
+
if (parentButton)
|
|
259
|
+
find = parentButton[attrName];
|
|
260
|
+
}
|
|
261
|
+
return find;
|
|
262
|
+
}
|
|
263
|
+
function checkState(stateName, leaf, button) {
|
|
264
|
+
let find = leaf.states[stateName];
|
|
265
|
+
if (!find && button) {
|
|
266
|
+
const parentButton = findParentButton(leaf, button);
|
|
267
|
+
if (parentButton)
|
|
268
|
+
find = parentButton.states[stateName];
|
|
269
|
+
}
|
|
270
|
+
return !!find;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
State$1.animateExcludes = {
|
|
274
|
+
animation: 1,
|
|
275
|
+
animationOut: 1,
|
|
276
|
+
transition: 1,
|
|
277
|
+
transitionOut: 1,
|
|
278
|
+
states: 1,
|
|
279
|
+
state: 1,
|
|
280
|
+
normalStyle: 1,
|
|
281
|
+
hoverStyle: 1,
|
|
282
|
+
pressStyle: 1,
|
|
283
|
+
focusStyle: 1,
|
|
284
|
+
selectedStyle: 1,
|
|
285
|
+
disabledStyle: 1
|
|
286
|
+
};
|
|
287
|
+
State$1.isState = function (state, leaf, button) { return checkState(state, leaf, button); };
|
|
288
|
+
State$1.isSelected = function (leaf, button) { return checkFixedState('selected', leaf, button); };
|
|
289
|
+
State$1.isDisabled = function (leaf, button) { return checkFixedState('disabled', leaf, button); };
|
|
290
|
+
State$1.isFocus = function (leaf, button) { return checkPointerState('isFocus', leaf, button); };
|
|
291
|
+
State$1.isHover = function (leaf, button) { return checkPointerState('isHover', leaf, button); };
|
|
292
|
+
State$1.isPress = function (leaf, button) { return checkPointerState('isPress', leaf, button); };
|
|
293
|
+
State$1.isDrag = function (leaf, button) { return checkPointerState('isDrag', leaf, button); };
|
|
294
|
+
State$1.setStyleName = function (leaf, stateType, value) { value ? setState(leaf, stateType, leaf[stateType]) : unsetState(leaf, stateType, leaf[stateType]); };
|
|
295
|
+
State$1.set = function (leaf, stateName) { const style = leaf.states[stateName]; style ? setState(leaf, stateName, style) : unsetState(leaf, stateName, style); };
|
|
296
|
+
State$1.getStyle = getStyle;
|
|
297
|
+
State$1.updateStyle = updateStyle;
|
|
298
|
+
State$1.updateEventStyle = updateEventStyle;
|
|
299
|
+
const ui = UI.prototype;
|
|
300
|
+
stateType(false, 'selectedStyle')(ui, 'selected');
|
|
301
|
+
stateType(false, 'disabledStyle')(ui, 'disabled');
|
|
302
|
+
stateStyleType({})(ui, 'states');
|
|
303
|
+
stateType('')(ui, 'state');
|
|
304
|
+
dataType()(ui, 'normalStyle');
|
|
305
|
+
stateStyleType()(ui, 'hoverStyle');
|
|
306
|
+
stateStyleType()(ui, 'pressStyle');
|
|
307
|
+
stateStyleType()(ui, 'focusStyle');
|
|
308
|
+
stateStyleType()(ui, 'selectedStyle');
|
|
309
|
+
stateStyleType()(ui, 'disabledStyle');
|
|
310
|
+
dataType(false)(ui, 'button');
|
|
311
|
+
ui.focus = function (value = true) {
|
|
90
312
|
this.waitLeafer(() => {
|
|
91
313
|
let { focusData } = this.app.interaction;
|
|
92
314
|
if (value) {
|
|
@@ -94,10 +316,14 @@ UI.prototype.focus = function (value = true) {
|
|
|
94
316
|
focusData.focus(false);
|
|
95
317
|
focusData = this;
|
|
96
318
|
}
|
|
97
|
-
else
|
|
319
|
+
else
|
|
98
320
|
focusData = null;
|
|
99
|
-
}
|
|
100
321
|
this.app.interaction.focusData = focusData;
|
|
101
|
-
|
|
322
|
+
value ? setPointerState(this, 'focusStyle') : unsetPointerState(this, 'focusStyle');
|
|
102
323
|
});
|
|
103
324
|
};
|
|
325
|
+
ui.updateState = function () {
|
|
326
|
+
State$1.updateStyle(this, undefined, 'in');
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export { stateStyleType, stateType };
|
package/dist/state.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{decorateLeafAttr as t,attr as e,State as n}from"@leafer-ui/draw";import{MathHelper as s,State as i,isNull as o,PointerEvent as l,UI as r,dataType as a}from"@leafer-ui/core";function c(s,i){return t(s,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>i?n.setStyleName(this,i,e):n.set(this,e)))}})))}function u(n){return t(n,(t=>e({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function f(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function S(t,e){"object"!=typeof e&&(e=void 0),h(t,e,"in")}function y(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),h(t,e,"out"))}const d={};function h(t,e,n){const{normalStyle:l}=t;e||(e=d),e.scale&&(s.assignScale(e,e.scale),delete e.scale),e!==d&&i.canAnimate||(n=null);let r=!!n&&function(t,e,n){let s="in"===t?"transition":"transitionOut";"out"===t&&o(n[s])&&o(e[s])&&(s="transition");return o(e[s])?n[s]:e[s]}(n,e,t);const a=r?function(t,e){const n=p(e,t),s=t.animate();s&&p(n,t,s.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),l&&t.set(l,!0);const c=m(t);if(c){const{animation:s}=c;if(s){const i=t.animate(s,void 0,"animation",!0);Object.assign(c,i.endingStyle),"in"!==n||e.animation!==s?i.kill():r=!1,delete c.animation}t.normalStyle=b(c,t),t.set(c,!0)}else t.normalStyle=void 0;if(r){const e=b(a,t);t.set(a,!0),t.animate([a,e],r,"transition",!0)}t.__layout.stateStyleChanged=!1}function m(t){let e;const n={},{state:s}=t,o=f(t),l=s&&t.states[s];l&&i.isState(s,t,o)&&(e=v(n,l));const r=n.selectedStyle||t.selectedStyle;if(r&&i.isSelected(t,o)&&(e=v(n,r)),i.isDisabled(t,o)){const s=n.disabledStyle||t.disabledStyle;s&&(e=v(n,s))}else{const s=n.focusStyle||t.focusStyle;s&&i.isFocus(t,o)&&(e=v(n,s));const l=n.hoverStyle||t.hoverStyle;l&&i.isHover(t,o)&&(e=v(n,l));const r=n.pressStyle||t.pressStyle;r&&i.isPress(t,o)&&(e=v(n,r))}return e?n:void 0}function b(t,e,n,s){const o=n?t:{},l=n||t;for(let t in l)s&&i.animateExcludes[t]||(o[t]=e[t]);return o}function p(t,e,n){return b(t,e,n,!0)}function v(t,e){return Object.assign(t,e),!0}function g(t,e){const n=t[e];n&&S(t,n),t.button&&k(t.children,e)}function _(t,e,n){n||(n=t.states[e]),S(t,n),t.button&&k(t.children,null,e)}function k(t,e,n){if(!t)return;let s,o;for(let l=0,r=t.length;l<r;l++){if(s=t[l],e){switch(o=!0,e){case"hoverStyle":i.isHover(s)&&(o=!1);break;case"pressStyle":i.isPress(s)&&(o=!1);break;case"focusStyle":i.isFocus(s)&&(o=!1)}o&&g(s,e)}else n&&_(s,n);s.isBranch&&k(s.children,e,n)}}function D(t,e){const n=t[e];n&&y(t,n),t.button&&O(t.children,e)}function E(t,e,n){y(t,n),t.button&&O(t.children,null,e)}function O(t,e,n){if(!t)return;let s;for(let i=0,o=t.length;i<o;i++)s=t[i],e?D(s,e):n&&E(s,n),s.isBranch&&O(s.children,e,n)}function w(t,e,n){let s;const i=e.leafer?e.leafer.interaction:null;if(i&&(s=i[t](e),!s&&n)){const o=f(e,n);o&&(s=i[t](o))}return s}function A(t,e,n){let s=e[t];if(!s&&n){const i=f(e,n);i&&(s=i[t])}return s}i.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},i.isState=function(t,e,n){return function(t,e,n){let s=e.states[t];if(!s&&n){const i=f(e,n);i&&(s=i.states[t])}return!!s}(t,e,n)},i.isSelected=function(t,e){return A("selected",t,e)},i.isDisabled=function(t,e){return A("disabled",t,e)},i.isFocus=function(t,e){return w("isFocus",t,e)},i.isHover=function(t,e){return w("isHover",t,e)},i.isPress=function(t,e){return w("isPress",t,e)},i.isDrag=function(t,e){return w("isDrag",t,e)},i.setStyleName=function(t,e,n){n?_(t,e,t[e]):E(t,e,t[e])},i.set=function(t,e){const n=t.states[e];n?_(t,e,n):E(t,e,n)},i.getStyle=m,i.updateStyle=h,i.updateEventStyle=function(t,e){switch(e){case l.ENTER:g(t,"hoverStyle");break;case l.LEAVE:D(t,"hoverStyle");break;case l.DOWN:g(t,"pressStyle");break;case l.UP:D(t,"pressStyle")}};const P=r.prototype;c(!1,"selectedStyle")(P,"selected"),c(!1,"disabledStyle")(P,"disabled"),u({})(P,"states"),c("")(P,"state"),a()(P,"normalStyle"),u()(P,"hoverStyle"),u()(P,"pressStyle"),u()(P,"focusStyle"),u()(P,"selectedStyle"),u()(P,"disabledStyle"),a(!1)(P,"button"),P.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?g(this,"focusStyle"):D(this,"focusStyle")}))},P.updateState=function(){i.updateStyle(this,void 0,"in")};export{u as stateStyleType,c as stateType};
|