@litejs/ui 26.2.1 → 26.4.0

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/el/material.ui CHANGED
@@ -1,111 +1,5 @@
1
1
 
2
2
  %css
3
- .mat-Menu,
4
- .tooltip {
5
- border-radius: 2px;
6
- position: absolute;
7
- margin: 0;
8
- opacity: 0;
9
- transform: scale(0);
10
- transition: opacity .4s cubic-bezier(0, 0, .2, 1) 0s, transform .2s cubic-bezier(0, 0, .2, 1) 0s;
11
- }
12
- .tooltip {
13
- padding: 8px;
14
- color: #fff;
15
- background: #666;
16
- font-weight: 500;
17
- max-width: 90%;
18
- text-align: center;
19
- pointer-events: none;
20
- z-index: 8;
21
- }
22
- .tooltip[data-pos]:before {
23
- content: "";
24
- position: absolute;
25
- display: block;
26
- width: .4em;
27
- height: .4em;
28
- border: .4em solid transparent;
29
- border-left-color: #666;
30
- border-top-color: #666;
31
- }
32
- .tooltip[data-pos=top]:before {
33
- bottom: -.3em;
34
- left: -.3em;
35
- margin-left: 50%;
36
- transform: rotate(225deg);
37
- }
38
- .tooltip[data-pos=bottom]:before {
39
- top: -.3em;
40
- left: -.3em;
41
- margin-left: 50%;
42
- transform: rotate(45deg);
43
- }
44
- .tooltip[data-pos=right]:before {
45
- top: 50%;
46
- left: -.3em;
47
- margin-top: -.4em;
48
- transform: rotate(315deg);
49
- }
50
- .tooltip[data-pos=left]:before {
51
- top: -.3em;
52
- right: -.3em;
53
- margin-top: 50%;
54
- transform: rotate(135deg);
55
- }
56
- .mat-Menu {
57
- padding: 8px 0;
58
- color: #000;
59
- background: #fff;
60
- min-width: 124px;
61
- max-width: 100%;
62
- z-index: 7;
63
- }
64
- .mat-Menu-item {
65
- display: block;
66
- padding: 12px 16px;
67
- text-decoration: none;
68
- line-height: 24px;
69
- cursor: pointer;
70
- overflow: hidden;
71
- text-overflow: ellipsis;
72
- white-space: nowrap;
73
- }
74
- .mat-Menu-item:hover {
75
- background-color: #eee;
76
- }
77
- .mat-Menu-item[disabled] {
78
- color: #bdbdbd;
79
- background-color: transparent;
80
- cursor: auto;
81
- }
82
- .mat-Menu-item.is-divider {
83
- border-bottom: 1px solid #ddd;
84
- }
85
- .mat-Menu.is-visible,
86
- .tooltip.is-visible {
87
- transform: scale(1);
88
- opacity: 1;
89
- }
90
- .waves {
91
- position: relative;
92
- overflow: hidden;
93
- }
94
- .waves-ripple {
95
- position: absolute;
96
- border-radius: 50%;
97
- background-color: #000;
98
- opacity: 0;
99
- transform: scale(0);
100
- transition: opacity .6s cubic-bezier(0, 0, .2, 1) 0s, transform 0s cubic-bezier(0, 0, .2, 1) .6s;
101
- pointer-events: none;
102
- }
103
- .waves.is-active > .waves-ripple,
104
- .waves-ripple--play {
105
- opacity: .4;
106
- transform: scale(1);
107
- transition: opacity 1s cubic-bezier(0, 0, .2, 1) 0ms, transform .4s cubic-bezier(0, 0, .2, 1) 0ms;
108
- }
109
3
  .shadow-1 {
110
4
  box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
111
5
  }
@@ -193,172 +87,6 @@
193
87
  left: 25%;
194
88
  }
195
89
 
196
- %js
197
- !function($ui) {
198
- var menuTarget, menuEl, tipTarget, tipEl, tick, wait
199
- , ripple = El(".waves-ripple")
200
- , html = document.documentElement
201
- El.near = near
202
- function near(source, target, x, y, margin) {
203
- var rect = target.getBoundingClientRect()
204
- , top = rect.top + El.scrollTop()
205
- , left = rect.left + El.scrollLeft()
206
- // svg elements dont have offsetWidth, IE8 does not have rect.width
207
- , width = rect.width || target.offsetWidth || 0
208
- , height = rect.height || target.offsetHeight || 0
209
- if (x == "left") {
210
- left -= source.offsetWidth + margin
211
- x = "150%"
212
- } else if (x == "left-start") {
213
- left -= margin
214
- x = "0%"
215
- } else if (x == "right") {
216
- left += width + margin
217
- x = "-50%"
218
- } else if (x == "right-end") {
219
- left += width + margin - source.offsetWidth
220
- x = "100%"
221
- } else {
222
- left += (width / 2) - (source.offsetWidth/2)
223
- x = "50%"
224
- }
225
- if (y == "top") {
226
- top -= margin + source.offsetHeight
227
- y = " 150%"
228
- } else if (y == "bottom") {
229
- top += height + margin
230
- y = " -50%"
231
- setTimeout(function(){
232
- //document.scrollingElement.scrollHeight
233
- var overflow = top + source.offsetHeight - El.scrollTop() - document.documentElement.offsetHeight
234
- if (overflow > 0) scrollBy({ top: overflow, left: 0, behavior: "smooth" })
235
- }, 400)
236
- } else {
237
- top += (height / 2) - (source.offsetHeight/2)
238
- y = " 50%"
239
- }
240
- El.css(source, {
241
- "transform-origin": x + y,
242
- top: (top < 0 ? 0 : top) + "px",
243
- left: (left < 0 ? 0 : left) + "px"
244
- })
245
- }
246
- El.on(html, "mouseover", onOver)
247
- El.on(window, "focusin", onOver)
248
- $ui.on("show", closeTooltip)
249
- function onOver(e) {
250
- var x, y, pos
251
- , target = e.target
252
- , text = El.get(target, "data-tooltip")
253
- , relTarg = e.relatedTarget || e.fromElement
254
- // without relTarg is event on click
255
- if (!relTarg && e.type !== "focusin" || target === tipTarget) return
256
- if (!text && tipTarget) {
257
- for (; target = target.parentNode; ) {
258
- if (target === tipTarget) return
259
- }
260
- }
261
- closeTooltip()
262
- if (!text) return
263
- tipEl = openVisible("pre.tooltip", tipTarget = target)
264
- pos = El.get(target, "data-tooltip-pos") || "top"
265
- El.txt(tipEl, text)
266
- if (pos === "left" || pos === "right") {
267
- x = pos
268
- } else {
269
- y = pos
270
- }
271
- El.set(tipEl, "data-pos", pos)
272
- near(tipEl, target, x, y, 6)
273
- }
274
- function openVisible(tag, target) {
275
- var el = typeof tag == "string" ? El(tag) : tag
276
- , scope = El.scope(el, target)
277
- scope.openTarget = target
278
- El.render(el)
279
- El.append(document.body, el)
280
- El.cls(el, "is-visible", 1, 5)
281
- return el
282
- }
283
- function closeVisible(el, delay) {
284
- if (el) {
285
- setTimeout(el.closeFn || El.kill.bind(El, el), 999)
286
- El.cls(el, "is-visible", 0, delay)
287
- }
288
- }
289
- function closeTooltip() {
290
- if (tipEl) {
291
- closeVisible(tipEl)
292
- tipTarget = tipEl = null
293
- }
294
- }
295
- function closeMenu(e) {
296
- if (e && e.target == menuTarget) return
297
- if (menuEl) {
298
- closeVisible(menuEl, 200)
299
- El.cls(menuTarget, "is-active", menuEl = menuTarget = null)
300
- }
301
- }
302
- $ui.on("ping", closeMenu)
303
- $ui.on("closeMenu", closeMenu)
304
- $ui.on("showMenu", function(e, target, menu, x, y, margin) {
305
- El.stop(e)
306
- var close = menuEl && menuTarget == target
307
- closeMenu()
308
- if (close) return
309
- menuEl = openVisible(menu, target)
310
- if (x == "mouse") {
311
- El.css(menuEl, {
312
- top: e.pageY + "px",
313
- left: e.pageX + "px"
314
- })
315
- } else {
316
- El.cls(menuTarget = target, "is-active")
317
- near(menuEl, target, x, y, margin)
318
- }
319
- if (menuEl.style.transform !== void 0) {
320
- El.cls(menuEl, "no-events")
321
- El.on(menuEl, "transitionend", function(e) {
322
- if (e.propertyName === "transform") El.cls(menuEl, "no-events", 0)
323
- })
324
- }
325
- })
326
- El.on(html, "click", closeMenu)
327
- El.on(html, "pointerdown", pointerdown)
328
- function pointerdown(e) {
329
- var target = e.target
330
- if (!El.hasClass(target, "waves") || target.disabled) return
331
- var rect = target.getBoundingClientRect()
332
- , fromMouse = !El.hasClass(target, "Checkbox-icon")
333
- , top = fromMouse ? e.clientY - rect.top : rect.height
334
- , left = fromMouse ? e.clientX - rect.left : rect.width
335
- , maxH = Math.max(top, target.offsetHeight - top)
336
- , maxW = Math.max(left, target.offsetWidth - left)
337
- , max = Math.sqrt(maxH * maxH + maxW * maxW)
338
- , size = (fromMouse ? 2 * max : max) + "px"
339
- El.css(ripple, {
340
- top: (top - max) + "px",
341
- left: (left - max) + "px",
342
- width: size,
343
- height: size
344
- })
345
- El.append(target, ripple)
346
- clearTimeout(tick)
347
- end()
348
- wait = 1
349
- tick = setTimeout(end, 800)
350
- El.one(html, "pointerup", end)
351
- ripple.offsetTop // force repaint
352
- El.cls(ripple, "waves-ripple--play")
353
- }
354
- function end() {
355
- if (!(wait--)) {
356
- El.cls(ripple, "waves-ripple--play", 0)
357
- }
358
- }
359
- }($ui)
360
-
361
-
362
90
  %el Checkbox
363
91
  label.Checkbox
364
92
  input[type=checkbox].hide
@@ -424,5 +152,3 @@
424
152
  %el MenuBtn
425
153
  button[type=button].MenuBtn.reset.noselect
426
154
  .MenuBtn-x.anim
427
-
428
-
package/el/menu.ui ADDED
@@ -0,0 +1,213 @@
1
+
2
+ %css
3
+ .Menu,
4
+ .Tooltip {
5
+ border-radius: 2px;
6
+ position: absolute;
7
+ margin: 0;
8
+ opacity: 0;
9
+ transform: scale(0);
10
+ transition: opacity .4s cubic-bezier(0, 0, .2, 1) 0s, transform .2s cubic-bezier(0, 0, .2, 1) 0s;
11
+ }
12
+ .Tooltip {
13
+ padding: 8px;
14
+ color: #fff;
15
+ background: #666;
16
+ font-weight: 500;
17
+ max-width: 90%;
18
+ text-align: center;
19
+ z-index: 8;
20
+ }
21
+ .Tooltip[data-pos]:before {
22
+ content: "";
23
+ position: absolute;
24
+ display: block;
25
+ width: .4em;
26
+ height: .4em;
27
+ border: .4em solid transparent;
28
+ border-left-color: #666;
29
+ border-top-color: #666;
30
+ }
31
+ .Tooltip[data-pos=top]:before {
32
+ bottom: -.3em;
33
+ left: -.3em;
34
+ margin-left: 50%;
35
+ transform: rotate(225deg);
36
+ }
37
+ .Tooltip[data-pos=bottom]:before {
38
+ top: -.3em;
39
+ left: -.3em;
40
+ margin-left: 50%;
41
+ transform: rotate(45deg);
42
+ }
43
+ .Tooltip[data-pos=right]:before {
44
+ top: 50%;
45
+ left: -.3em;
46
+ margin-top: -.4em;
47
+ transform: rotate(315deg);
48
+ }
49
+ .Tooltip[data-pos=left]:before {
50
+ top: -.3em;
51
+ right: -.3em;
52
+ margin-top: 50%;
53
+ transform: rotate(135deg);
54
+ }
55
+ .Menu {
56
+ padding: 8px 0;
57
+ color: #000;
58
+ background: #fff;
59
+ min-width: 124px;
60
+ max-width: 100%;
61
+ z-index: 7;
62
+ }
63
+ .Menu-item {
64
+ display: block;
65
+ padding: 12px 16px;
66
+ text-decoration: none;
67
+ line-height: 24px;
68
+ cursor: pointer;
69
+ overflow: hidden;
70
+ text-overflow: ellipsis;
71
+ white-space: nowrap;
72
+ }
73
+ .Menu-item:hover {
74
+ background-color: #eee;
75
+ }
76
+ .Menu-item[disabled] {
77
+ color: #bdbdbd;
78
+ background-color: transparent;
79
+ cursor: auto;
80
+ }
81
+ .Menu-item.is-divider {
82
+ border-bottom: 1px solid #ddd;
83
+ }
84
+ .Menu.is-visible,
85
+ .Tooltip.is-visible {
86
+ transform: scale(1);
87
+ opacity: 1;
88
+ }
89
+
90
+ %js
91
+ !function($ui) {
92
+ var menuTarget, menuEl, tipTarget, tipEl
93
+ , html = document.documentElement
94
+ El.near = near
95
+ function near(source, target, x, y, margin) {
96
+ var rect = target.getBoundingClientRect()
97
+ , top = rect.top + El.scrollTop()
98
+ , left = rect.left + El.scrollLeft()
99
+ // svg elements dont have offsetWidth, IE8 does not have rect.width
100
+ , width = rect.width || target.offsetWidth || 0
101
+ , height = rect.height || target.offsetHeight || 0
102
+ if (x == "left") {
103
+ left -= source.offsetWidth + margin
104
+ x = "150%"
105
+ } else if (x == "left-start") {
106
+ left -= margin
107
+ x = "0%"
108
+ } else if (x == "right") {
109
+ left += width + margin
110
+ x = "-50%"
111
+ } else if (x == "right-end") {
112
+ left += width + margin - source.offsetWidth
113
+ x = "100%"
114
+ } else {
115
+ left += (width / 2) - (source.offsetWidth/2)
116
+ x = "50%"
117
+ }
118
+ if (y == "top") {
119
+ top -= margin + source.offsetHeight
120
+ y = " 150%"
121
+ } else if (y == "bottom") {
122
+ top += height + margin
123
+ y = " -50%"
124
+ setTimeout(function() {
125
+ var overflow = top + source.offsetHeight - El.scrollTop() - html.offsetHeight
126
+ if (overflow > 0) scrollBy({ top: overflow, left: 0, behavior: "smooth" })
127
+ }, 400)
128
+ } else {
129
+ top += (height / 2) - (source.offsetHeight/2)
130
+ y = " 50%"
131
+ }
132
+ El.css(source, {
133
+ "transform-origin": x + y,
134
+ top: (top < 0 ? 0 : top) + "px",
135
+ left: (left < 0 ? 0 : left) + "px"
136
+ })
137
+ }
138
+ El.on(html, "mouseover focusin", function(e) {
139
+ var x, y, pos
140
+ , target = e.target
141
+ , text = El.get(target, "data-tooltip")
142
+ if (!e.relatedTarget && e.type !== "focusin" || target === tipTarget) return
143
+ if (!text && tipTarget) {
144
+ if (tipEl && tipEl.contains(target)) return
145
+ for (; target = target.parentNode; ) {
146
+ if (target === tipTarget) return
147
+ }
148
+ }
149
+ closeTooltip()
150
+ if (!text) return
151
+ tipEl = openVisible("pre.Tooltip", tipTarget = target)
152
+ pos = El.get(target, "data-tooltip-pos") || "top"
153
+ El.txt(tipEl, text)
154
+ if (pos === "left" || pos === "right") {
155
+ x = pos
156
+ } else {
157
+ y = pos
158
+ }
159
+ El.set(tipEl, "data-pos", pos)
160
+ near(tipEl, target, x, y, 6)
161
+ })
162
+ $ui.on("show", closeTooltip)
163
+ function openVisible(tag, target) {
164
+ var el = typeof tag == "string" ? El(tag) : tag
165
+ , scope = El.scope(el, target)
166
+ scope.openTarget = target
167
+ El.render(el)
168
+ El.append(document.body, el)
169
+ El.cls(el, "is-visible", 1, 5)
170
+ return el
171
+ }
172
+ function closeVisible(el, delay) {
173
+ if (el) {
174
+ El.kill(el, null, 999)
175
+ El.cls(el, "is-visible", 0, delay)
176
+ }
177
+ }
178
+ function closeTooltip() {
179
+ if (tipEl) {
180
+ closeVisible(tipEl)
181
+ tipTarget = tipEl = null
182
+ }
183
+ }
184
+ function menuClose(e) {
185
+ if (e && e.target == menuTarget) return
186
+ if (menuEl) {
187
+ closeVisible(menuEl, 200)
188
+ El.cls(menuTarget, "is-active", menuEl = menuTarget = null)
189
+ }
190
+ }
191
+ $ui.on("ping,menuClose", menuClose)
192
+ $ui.on("menu", function(e, target, menu, x, y, margin) {
193
+ El.stop(e)
194
+ var close = menuEl && menuTarget == target
195
+ menuClose()
196
+ if (close) return
197
+ menuEl = openVisible(menu, target)
198
+ if (x == "mouse") {
199
+ El.css(menuEl, {
200
+ top: e.pageY + "px",
201
+ left: e.pageX + "px"
202
+ })
203
+ } else {
204
+ El.cls(menuTarget = target, "is-active")
205
+ near(menuEl, target, x, y, margin)
206
+ }
207
+ El.cls(menuEl, "no-events")
208
+ El.on(menuEl, "transitionend", function(e) {
209
+ if (e.propertyName === "transform") El.cls(menuEl, "no-events", 0)
210
+ })
211
+ })
212
+ El.on(html, "click", menuClose)
213
+ }($ui)
package/el/ripple.ui ADDED
@@ -0,0 +1,56 @@
1
+
2
+ %css
3
+ .waves {
4
+ position: relative;
5
+ overflow: hidden;
6
+ }
7
+ .waves-ripple {
8
+ position: absolute;
9
+ border-radius: 50%;
10
+ background-color: #000;
11
+ opacity: 0;
12
+ transform: scale(0);
13
+ transition: opacity .6s cubic-bezier(0, 0, .2, 1) 0s, transform 0s cubic-bezier(0, 0, .2, 1) .6s;
14
+ pointer-events: none;
15
+ }
16
+ .waves-ripple--play {
17
+ opacity: .4;
18
+ transform: scale(1);
19
+ transition: opacity 1s cubic-bezier(0, 0, .2, 1) 0ms, transform .4s cubic-bezier(0, 0, .2, 1) 0ms;
20
+ }
21
+
22
+ %js
23
+ !function() {
24
+ var tick, wait
25
+ , ripple = El(".waves-ripple")
26
+ , html = document.documentElement
27
+ El.on(html, "pointerdown", function(e) {
28
+ var target = e.target
29
+ if (!El.hasClass(target, "waves") || target.disabled) return
30
+ var rect = target.getBoundingClientRect()
31
+ , top = e.clientY - rect.top
32
+ , left = e.clientX - rect.left
33
+ , maxH = Math.max(top, target.offsetHeight - top)
34
+ , maxW = Math.max(left, target.offsetWidth - left)
35
+ , max = 2 * Math.sqrt(maxH * maxH + maxW * maxW)
36
+ El.css(ripple, {
37
+ top: (top - max / 2) + "px",
38
+ left: (left - max / 2) + "px",
39
+ width: max + "px",
40
+ height: max + "px"
41
+ })
42
+ El.append(target, ripple)
43
+ clearTimeout(tick)
44
+ end()
45
+ wait = 1
46
+ tick = setTimeout(end, 600)
47
+ El.one(html, "pointerup", end)
48
+ ripple.offsetTop // force repaint
49
+ El.cls(ripple, "waves-ripple--play")
50
+ })
51
+ function end() {
52
+ if (!(wait--)) {
53
+ El.cls(ripple, "waves-ripple--play", 0)
54
+ }
55
+ }
56
+ }()