@litejs/ui 21.3.1 → 21.11.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/README.md +20 -13
- package/binding/_default.js +4 -3
- package/component/Slider.tpl +27 -42
- package/component/confirm.tpl +15 -21
- package/component/form1.tpl +1 -3
- package/css/base.css +4 -5
- package/css/contrast.css +58 -0
- package/css/font-mono.css +7 -0
- package/css/font-native.css +17 -4
- package/css/font-numbers.css +8 -0
- package/framekiller.js +8 -0
- package/index.js +63 -322
- package/load.js +22 -9
- package/package.json +3 -5
- package/pointer.js +9 -5
- package/polyfill/index.js +70 -30
- package/svg.js +4 -4
package/README.md
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
[LiteJS]: https://
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
1
|
+
[LiteJS]: https://github.com/litejs/litejs
|
|
2
|
+
[UI]: https://github.com/litejs/ui
|
|
3
|
+
[CLI]: https://github.com/litejs/cli
|
|
4
|
+
[Quick-Start]: https://github.com/litejs/litejs/wiki/Quick-Start
|
|
5
5
|
|
|
6
6
|
[size]: https://packagephobia.now.sh/badge?p=@litejs/ui
|
|
7
7
|
[size-src]: https://packagephobia.now.sh/result?p=@litejs/ui
|
|
8
|
+
[wiki]: https://github.com/litejs/ui/wiki
|
|
8
9
|
|
|
9
|
-
LiteJS UI – [![size][size]][size-src]
|
|
10
|
-
=========
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
[LiteJS][] full-stack framework is split into three main packages by designated install location:
|
|
12
|
+
|
|
13
|
+
- **[litejs][LiteJS]** - Server and core libraries installed as `dependencies`
|
|
14
|
+
- **[@litejs/ui][UI]** - UI engine installed as `devDependencies` and bundled into your app
|
|
15
|
+
- **[@litejs/cli][CLI]** - Command line tool installed as global package (or as `devDependencies`)
|
|
16
|
+
|
|
17
|
+
> Build your first [LiteJS][] app with in 5 minute [Quick Start Guide][Quick-Start].
|
|
13
18
|
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
LiteJS UI – [![size][size]][size-src]
|
|
21
|
+
=========
|
|
22
|
+
|
|
23
|
+
UI engine for [LiteJS][] full-stack framework.
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
See [LiteJS wiki][] for more.
|
|
25
|
+
> See [wiki][] for more.
|
|
19
26
|
|
|
20
27
|
|
|
21
28
|
## External links
|
|
22
29
|
|
|
23
|
-
[GitHub repo]
|
|
24
|
-
[npm package]
|
|
30
|
+
[GitHub repo](https://github.com/litejs/ui) |
|
|
31
|
+
[npm package](https://npmjs.org/package/@litejs/ui)
|
|
25
32
|
|
|
26
33
|
|
|
27
34
|
## Licence
|
|
28
35
|
|
|
29
|
-
Copyright (c) 2013-
|
|
36
|
+
Copyright (c) 2013-2021 Lauri Rooden <lauri@rooden.ee>
|
|
30
37
|
[The MIT License](http://lauri.rooden.ee/mit-license.txt)
|
|
31
38
|
|
|
32
39
|
|
package/binding/_default.js
CHANGED
|
@@ -125,9 +125,10 @@
|
|
|
125
125
|
model = scope.model
|
|
126
126
|
}
|
|
127
127
|
if (model && path) {
|
|
128
|
-
match = i18n.pick(state
|
|
129
|
-
|
|
130
|
-
El.cls(node,
|
|
128
|
+
match = i18n.pick(state !== match ? state : model.get(path), list)
|
|
129
|
+
path += "-" + list
|
|
130
|
+
El.cls(node, node["_is-" + path], 0)
|
|
131
|
+
El.cls(node, node["_is-" + path] = match && "is-" + match)
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
|
package/component/Slider.tpl
CHANGED
|
@@ -144,21 +144,6 @@
|
|
|
144
144
|
%js
|
|
145
145
|
var on = El.on
|
|
146
146
|
, off = El.off
|
|
147
|
-
El.bindings.SliderVal = function(el, model, path, range) {
|
|
148
|
-
if (range) {
|
|
149
|
-
El.attr(el, "range", range)
|
|
150
|
-
}
|
|
151
|
-
if (path) {
|
|
152
|
-
if (path.charAt(0)!=="/") path = "/" + path.replace(/\./g, "/")
|
|
153
|
-
model.on("change:" + path, set)
|
|
154
|
-
setTimeout(function(){
|
|
155
|
-
set(model.get(path))
|
|
156
|
-
}, 10)
|
|
157
|
-
}
|
|
158
|
-
function set(val) {
|
|
159
|
-
el.set(parseFloat(val) || 0)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
147
|
El.bindings.SliderInit = function(el) {
|
|
163
148
|
var knobLen, offset, px, drag, min, max, step, minPx, maxPx, value
|
|
164
149
|
, vert = El.hasClass(el, "is-vertical")
|
|
@@ -167,9 +152,11 @@
|
|
|
167
152
|
, knob = fill.lastChild
|
|
168
153
|
, emit = El.emit.bind(el, el, "change").rate(500, true)
|
|
169
154
|
on(window, "blur", stop)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
155
|
+
on(el, "pointerdown", start)
|
|
156
|
+
el.val = set
|
|
157
|
+
setTimeout(function() { set(value||0) }, 10)
|
|
158
|
+
function load() {
|
|
159
|
+
var attr = vert ? "offsetHeight" : "offsetWidth"
|
|
173
160
|
, range = (El.attr(el, "range") || "").split(/[^+\-\d.]/) // min:max:step:margin
|
|
174
161
|
min = +(range[0] || 0)
|
|
175
162
|
max = +(range[1] || 100)
|
|
@@ -178,13 +165,15 @@
|
|
|
178
165
|
minPx = 0
|
|
179
166
|
maxPx = track[attr] - knobLen - knobLen
|
|
180
167
|
px = maxPx / (max - min)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
168
|
+
}
|
|
169
|
+
function start(e) {
|
|
170
|
+
drag = true
|
|
171
|
+
load()
|
|
172
|
+
var tmp = el.getBoundingClientRect()
|
|
173
|
+
offset = (vert ? tmp.top + maxPx + El.scrollTop() + knobLen : tmp.left + El.scrollLeft()) + knobLen
|
|
174
|
+
tmp = offset - e.clientX + (value-min||0)*px
|
|
175
|
+
if (tmp < knobLen && tmp > -knobLen) offset -= tmp
|
|
176
|
+
if (track.childNodes.length > 1) {
|
|
188
177
|
fill = track.firstChild
|
|
189
178
|
var next
|
|
190
179
|
, x = maxPx
|
|
@@ -207,24 +196,21 @@
|
|
|
207
196
|
if (range[3]) minPx += px * range[3]
|
|
208
197
|
}
|
|
209
198
|
}
|
|
210
|
-
}
|
|
211
|
-
function start(e) {
|
|
212
|
-
drag = true
|
|
213
|
-
load(e)
|
|
214
199
|
move(e)
|
|
215
200
|
listen(on)
|
|
216
201
|
}
|
|
217
202
|
function move(e) {
|
|
218
203
|
var diff = vert ? offset - e.pageY : e.pageX - offset
|
|
219
204
|
diff = (diff > maxPx ? maxPx : (diff < minPx ? minPx : diff))
|
|
220
|
-
|
|
205
|
+
set((diff / px) + min, e, diff)
|
|
221
206
|
return Event.stop(e)
|
|
222
207
|
}
|
|
223
208
|
function stop(e) {
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
209
|
+
if (drag) {
|
|
210
|
+
drag = false
|
|
211
|
+
listen(off)
|
|
212
|
+
set(value)
|
|
213
|
+
}
|
|
228
214
|
}
|
|
229
215
|
function listen(on) {
|
|
230
216
|
El.cls(fill, "anim", !drag)
|
|
@@ -232,22 +218,21 @@
|
|
|
232
218
|
on(document, "pointerup", stop)
|
|
233
219
|
on(document, "pointermove", move)
|
|
234
220
|
}
|
|
235
|
-
|
|
236
|
-
|
|
221
|
+
function set(val, e, pos) {
|
|
222
|
+
load()
|
|
237
223
|
val = (val < min ? min : val > max ? max : val).step(step)
|
|
224
|
+
if (value !== void 0 && (!drag || pos !== void 0)) {
|
|
225
|
+
El.css(fill, vert ? "height" : "width", ((pos || (val-min)*px)+knobLen) + "px", 0)
|
|
226
|
+
}
|
|
238
227
|
if (value !== val) {
|
|
239
228
|
el.value = value = val
|
|
240
229
|
if (drag && e) emit(e)
|
|
241
230
|
var format = El.attr(el, "format")
|
|
242
|
-
El.attr(knob, "data-val", format ? format
|
|
243
|
-
}
|
|
244
|
-
if (!drag || pos !== void 0) {
|
|
245
|
-
fill.style[vert ? "height" : "width"] = ((pos || (value-min)*px)+knobLen) + "px"
|
|
231
|
+
El.attr(knob, "data-val", format ? _(format, {val:val}) : val)
|
|
246
232
|
}
|
|
247
233
|
}
|
|
248
|
-
on(el, "pointerdown", start)
|
|
249
234
|
}
|
|
250
|
-
El.bindings.SliderInit.once =
|
|
235
|
+
El.bindings.SliderInit.once = 1
|
|
251
236
|
|
|
252
237
|
%el Slider
|
|
253
238
|
button.Slider.reset ;SliderInit
|
package/component/confirm.tpl
CHANGED
|
@@ -4,31 +4,25 @@
|
|
|
4
4
|
z-index: 9;
|
|
5
5
|
}
|
|
6
6
|
.Confirm-bg {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
backdrop-filter: blur(5px);
|
|
8
|
+
background-color: rgba(0, 0, 0, .6);
|
|
9
9
|
}
|
|
10
10
|
.Confirm-content {
|
|
11
11
|
position: absolute;
|
|
12
12
|
left: 0;
|
|
13
13
|
right: 0;
|
|
14
14
|
margin: 0 auto;
|
|
15
|
-
top:
|
|
15
|
+
top: 4%;
|
|
16
16
|
width: 400px;
|
|
17
17
|
background-color: #fff;
|
|
18
18
|
box-shadow: 0 2px 10px 2px rgba(255,255,255,.5);
|
|
19
|
-
animation: .2s cubic-bezier(.2, -.3, .8, 0) reverse Confirm--blur;
|
|
20
19
|
}
|
|
21
20
|
.sm .Confirm-content {
|
|
22
|
-
width:
|
|
21
|
+
width: 94%;
|
|
23
22
|
}
|
|
24
23
|
.Confirm--blur {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@keyframes Confirm--blur {
|
|
28
|
-
to {
|
|
29
|
-
filter: blur(4px);
|
|
30
|
-
transform: scale(.9);
|
|
31
|
-
}
|
|
24
|
+
transform: scale(.85);
|
|
25
|
+
transform-origin: 50% 100vh;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
// reverse animation: x1, y1, x2, y2 -> (1 - x2), (1 - y2), (1 - x1), (1 - y1)
|
|
@@ -75,6 +69,7 @@
|
|
|
75
69
|
, scope = El.scope(el, El.data)
|
|
76
70
|
, kbMap = {}
|
|
77
71
|
, body = document.body
|
|
72
|
+
, blurEl = body.lastChild
|
|
78
73
|
Object.assign(scope, opts)
|
|
79
74
|
scope.title = title || "Confirm?"
|
|
80
75
|
if (!scope.actions) scope.actions = [
|
|
@@ -84,7 +79,8 @@
|
|
|
84
79
|
if (typeof a == "string") a = scope.actions[i-1] = {title:a,action:a}
|
|
85
80
|
if (a.key) kbMap[a.key] = resolve.bind(el, el, a.action)
|
|
86
81
|
}
|
|
87
|
-
El.cls(
|
|
82
|
+
El.cls(blurEl, "Confirm--blur")
|
|
83
|
+
El.cls(el.lastChild, "Confirm--blur", 0, 1)
|
|
88
84
|
El.append(body, el)
|
|
89
85
|
El.render(el, scope)
|
|
90
86
|
if (scope.code) {
|
|
@@ -115,10 +111,8 @@
|
|
|
115
111
|
}
|
|
116
112
|
function resolve(e, key) {
|
|
117
113
|
if (el) {
|
|
118
|
-
El.
|
|
119
|
-
El.
|
|
120
|
-
El.cls(body.lastChild, "Confirm--blur", 0)
|
|
121
|
-
el = null
|
|
114
|
+
El.kill(el, "transparent")
|
|
115
|
+
El.cls(blurEl, "Confirm--blur", el = 0)
|
|
122
116
|
var action = key || El.attr(this, "data-action")
|
|
123
117
|
if (action && next) {
|
|
124
118
|
if (typeof next === "function") next(action, code)
|
|
@@ -132,11 +126,11 @@
|
|
|
132
126
|
})
|
|
133
127
|
|
|
134
128
|
%el Confirm
|
|
135
|
-
.Confirm.max.fix
|
|
129
|
+
.Confirm.max.fix.anim
|
|
136
130
|
.Confirm-bg.max.abs
|
|
137
|
-
.Confirm-content.grid.p2
|
|
138
|
-
.col.ts3 ;txt:: _(title)
|
|
139
|
-
.col.js-body ;txt:: _(body)
|
|
131
|
+
.Confirm-content.Confirm--blur.grid.p2.anim
|
|
132
|
+
.col.ts3 ;txt:: _(title, map)
|
|
133
|
+
.col.js-body ;txt:: _(body, map)
|
|
140
134
|
.row.js-numpad
|
|
141
135
|
;if: code
|
|
142
136
|
;each: num in [1,2,3,4,5,6,7,8,9,"CLEAR",0]
|
package/component/form1.tpl
CHANGED
|
@@ -140,13 +140,11 @@
|
|
|
140
140
|
}
|
|
141
141
|
.btn:hover,
|
|
142
142
|
.btn:focus {
|
|
143
|
-
|
|
144
|
-
color: #333;
|
|
143
|
+
filter: brightness(1.3) saturate(1.2);
|
|
145
144
|
text-decoration: none;
|
|
146
145
|
}
|
|
147
146
|
.btn:active,
|
|
148
147
|
.btn.is-active {
|
|
149
|
-
background-color: #ccc;
|
|
150
148
|
box-shadow: inset 0 0 8px rgba(0, 0, 0, .5);
|
|
151
149
|
}
|
|
152
150
|
|
package/css/base.css
CHANGED
|
@@ -194,7 +194,6 @@ button,
|
|
|
194
194
|
.btn,
|
|
195
195
|
.nowrap,
|
|
196
196
|
.ellipsis {
|
|
197
|
-
overflow: hidden;
|
|
198
197
|
text-overflow: ellipsis;
|
|
199
198
|
white-space: nowrap;
|
|
200
199
|
}
|
|
@@ -207,10 +206,10 @@ button,
|
|
|
207
206
|
.anim,
|
|
208
207
|
.anim:after,
|
|
209
208
|
.anim:before {
|
|
210
|
-
-webkit-transition: all .
|
|
211
|
-
-moz-transition: all .
|
|
212
|
-
-o-transition: all .
|
|
213
|
-
transition: all .
|
|
209
|
+
-webkit-transition: all .25s cubic-bezier(0, 0, .2, 1) 0s;
|
|
210
|
+
-moz-transition: all .25s cubic-bezier(0, 0, .2, 1) 0s;
|
|
211
|
+
-o-transition: all .25s cubic-bezier(0, 0, .2, 1) 0s;
|
|
212
|
+
transition: all .25s cubic-bezier(0, 0, .2, 1) 0s;
|
|
214
213
|
|
|
215
214
|
-webkit-transform: translate3d(0, 0, 0); /* 1 */
|
|
216
215
|
transform: translate3d(0, 0, 0);
|
package/css/contrast.css
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 1. IE10 from Windows 7 and legacy Microsoft Edge
|
|
4
|
+
* Microsoft Edge79 supports the new standards
|
|
5
|
+
* 2. As with all other keywords, these names are ASCII case-insensitive.
|
|
6
|
+
* They are shown here with mixed capitalization for legibility.
|
|
7
|
+
* 3. Use transparent outline instead of removing it,
|
|
8
|
+
* in forced color modes, you'll get a visual outline,
|
|
9
|
+
* as the color will be overridden by the system colors.
|
|
10
|
+
*
|
|
11
|
+
* https://drafts.csswg.org/css-color-4/#css-system-colors
|
|
12
|
+
* https://www.a11yproject.com/posts/2020-01-23-operating-system-and-browser-accessibility-display-modes/
|
|
13
|
+
* https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/
|
|
14
|
+
*
|
|
15
|
+
* Internet Explorer and legacy Microsoft Edge | New Microsoft Edge and web standards
|
|
16
|
+
* @media (-ms-high-contrast: active) {} | @media (forced-colors: active) {}
|
|
17
|
+
* @media (-ms-high-contrast: black-on-white) {} | @media (forced-colors: active) and (prefers-color-scheme: light) {}
|
|
18
|
+
* @media (-ms-high-contrast: white-on-black) {} | @media (forced-colors: active) and (prefers-color-scheme: dark) {}
|
|
19
|
+
* -ms-high-contrast-adjust: none; | forced-color-adjust: none;
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
@media (-ms-high-contrast: active), (forced-colors: active) {
|
|
23
|
+
.preserveOriginalColors {
|
|
24
|
+
-ms-high-contrast-adjust: none; /* 1 */
|
|
25
|
+
forced-color-adjust: none;
|
|
26
|
+
}
|
|
27
|
+
.useSystemColors {
|
|
28
|
+
background-color: Window; /* 1 */
|
|
29
|
+
background-color: Canvas; /* 2 */
|
|
30
|
+
border-color: -ms-hotlight; /* 1 */
|
|
31
|
+
border-color: LinkText;
|
|
32
|
+
color: WindowText; /* 1 */
|
|
33
|
+
color: CanvasText;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
@media (prefers-color-scheme: dark) {
|
|
37
|
+
body {
|
|
38
|
+
background-color: #000;
|
|
39
|
+
color: #fff;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
@media (inverted-colors: inverted) {
|
|
43
|
+
img,
|
|
44
|
+
video {
|
|
45
|
+
filter: invert(100%);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
@media (prefers-reduced-motion: reduce) {
|
|
49
|
+
.anim {
|
|
50
|
+
animation: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:focus {
|
|
55
|
+
outline: 2px solid transparent; /* 3 */
|
|
56
|
+
box-shadow: 0 0 10px 2px rgba(0, 0, 0, .8);
|
|
57
|
+
}
|
|
58
|
+
|
package/css/font-native.css
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
/**
|
|
3
|
+
* https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/
|
|
4
|
+
*
|
|
5
|
+
* - Segoe UI before system-ui (system-ui is Microsoft YaHei UI in Win10 in Simplified Chinese)
|
|
6
|
+
*/
|
|
7
|
+
|
|
2
8
|
body {
|
|
3
|
-
/* https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/ */
|
|
4
9
|
font-family:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
"Segoe UI",
|
|
11
|
+
system-ui,
|
|
12
|
+
-apple-system,
|
|
13
|
+
Oxygen, /* KDE */
|
|
14
|
+
Cantarell, /* GNOME */
|
|
15
|
+
Ubuntu,
|
|
16
|
+
Roboto,
|
|
17
|
+
"Droid Sans",
|
|
18
|
+
"Helvetica Neue", /* macOS versions < 10.11 */
|
|
19
|
+
sans-serif;
|
|
20
|
+
/* Apple Color Emoji, Segoe UI Emoji; */
|
|
8
21
|
}
|
|
9
22
|
|
package/framekiller.js
ADDED