@litejs/ui 21.8.0 → 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.
@@ -140,13 +140,11 @@
140
140
  }
141
141
  .btn:hover,
142
142
  .btn:focus {
143
- background-color: #eee;
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
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @version 21.8.0
2
+ * @version 21.11.0
3
3
  * @author Lauri Rooden <lauri@rooden.ee>
4
4
  * @license MIT License
5
5
  */
@@ -555,8 +555,7 @@
555
555
  for (k in obj) if (typeof obj[k] == "function" && ignore.indexOf(k) < 0) !function(k) {
556
556
  hooked.push(k, hasOwn.call(obj, k) && obj[k])
557
557
  obj[k] = function() {
558
- if (hooks === null) obj[k].apply(this, arguments)
559
- else hooks.push(k, arguments)
558
+ hooks.push(k, arguments)
560
559
  return obj
561
560
  }
562
561
  }(k)
@@ -1935,7 +1934,7 @@
1935
1934
  /*** kb ***/
1936
1935
  var kbMaps = []
1937
1936
  , kbMod = El.kbMod = iOS ? "metaKey" : "ctrlKey"
1938
- , kbKeys = {
1937
+ , kbMap = El.kbMap = {
1939
1938
  8: "backspace", 9: "tab",
1940
1939
  13: "enter", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
1941
1940
  20: "caps", 27: "esc",
@@ -1968,7 +1967,7 @@
1968
1967
  var c = e.keyCode || e.which
1969
1968
  , numpad = c > 95 && c < 106
1970
1969
  , code = numpad ? c - 48 : c
1971
- , key = kbKeys[code] || String.fromCharCode(code).toLowerCase() || code
1970
+ , key = kbMap[code] || String.fromCharCode(code).toLowerCase() || code
1972
1971
 
1973
1972
  // Otherwise IE backspace navigates back
1974
1973
  if (code == 8 && kbMaps[0].backspace) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litejs/ui",
3
- "version": "21.8.0",
3
+ "version": "21.11.0",
4
4
  "description": "UI engine for LiteJS full-stack framework",
5
5
  "license": "MIT",
6
6
  "author": "Lauri Rooden <lauri@rooden.ee>",
@@ -22,7 +22,7 @@
22
22
  "css"
23
23
  ],
24
24
  "litejs": {
25
- "build": "--out=test/index.html test/dev.html"
25
+ "build": "lj b --out=test/index.html test/dev.html"
26
26
  },
27
27
  "jshintConfig": {
28
28
  "asi": true,
package/polyfill/index.js CHANGED
@@ -21,6 +21,7 @@
21
21
 
22
22
  !function(window, Function) {
23
23
 
24
+ // Array#flat() - Chrome69, Edge79, Firefox62, Safari12
24
25
  // window.PointerEvent - Chrome55, Edge12, Firefox59, Safari13, IE11
25
26
  // navigator.sendBeacon - Chrome39, Edge14, Firefox31, Safari11.1
26
27
  // Object.fromEntries - Chrome73, Edge79, Firefox63, Safari12.1, Opera60, Node.js12.0.0
@@ -30,7 +31,6 @@
30
31
  , P = "prototype"
31
32
  , O = window
32
33
  , patched = (window.xhr || window)._p = []
33
- , aSlice = patched.slice
34
34
  , jsonRe = /[\x00-\x1f\x22\x5c]/g
35
35
  , JSONmap = {"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t",'"':'\\"',"\\":"\\\\"}
36
36
  , hasOwn = JSONmap.hasOwnProperty
@@ -88,6 +88,9 @@
88
88
  c: "touchcancel"
89
89
  }
90
90
 
91
+ // Missing PointerEvents with Scribble enable on Safari 14
92
+ // https://mikepk.com/2020/10/iOS-safari-scribble-bug/
93
+ // https://bugs.webkit.org/show_bug.cgi?id=217430
91
94
 
92
95
  if (!window.PointerEvent) {
93
96
  // IE10
@@ -161,7 +164,7 @@
161
164
  patch("escape", "return X(a)", esc("a", 0) != "a", esc)
162
165
 
163
166
  // Patch parameters support for setTimeout callback
164
- patch("setTimeout", (a = "var A=arguments;return O(X(a)&&A.length>2?a.apply.bind(a,null,S.call(A,2)):a,b)"), ie6789, isFn)
167
+ patch("setTimeout", (a = "return O(X(a)&&A.length>2?a.apply.bind(a,null,S.call(A,2)):a,b)"), ie6789, isFn)
165
168
  patch("setInterval", a, ie6789, isFn)
166
169
 
167
170
  function createStorage(name) {
@@ -261,21 +264,24 @@
261
264
  O = Date
262
265
  patch("d:now", a)
263
266
 
267
+ /*** toISOString ***/
264
268
  O = O[P]
265
269
  // IE8 toJSON does not return milliseconds
270
+ // ISO 8601 format is always 24 or 27 characters long,
271
+ // YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ
266
272
  patch("toISOString", patch("toJSON", [
267
- "return t.getUTCFullYear(", "Month()+1,'-'", "Date(),'-'",
268
- "Hours(),'T'", "Minutes(),':'", "Seconds(),':'", "Milliseconds(),'.')+'Z'"
269
- ].join(")+X(t.getUTC"), ie678, function(n, b){ return b + ("00" + n).slice((b !== ".")-3) }))
270
-
273
+ "a=t.getUTCFullYear();if(a!==a)throw RangeError('Invalid time');return(b=a<0?'-':a>9999?'+':'')+X(a<0?-a:a,'-',b?6:4", "Month()+1,'-'", "Date(),'T'",
274
+ "Hours(),':'", "Minutes(),':'", "Seconds(),'.'", "Milliseconds(),'Z',3)"
275
+ ].join(")+X(t.getUTC"), ie678, function(a, b, c){ return ("00000" + a).slice(-c || -2) + b }))
276
+ /**/
271
277
 
272
278
  O = Function[P]
273
279
  // Chrome7, FF4, IE9, Opera 11.60, Safari 5.1.4
274
- patch("bind", "b=S.call(arguments,1);c=function(){return t.apply(this instanceof c?this:a,b.concat(S.call(arguments)))};if(t[P])c[P]=t[P];return c")
280
+ patch("bind", "b=S.call(A,1);c=function(){return t.apply(this instanceof c?this:a,b.concat(S.call(arguments)))};if(t[P])c[P]=t[P];return c")
275
281
 
276
282
 
277
283
  O = Object
278
- patch("assign", "var k,i=1,A=arguments,l=A.length;for(;i<l;)if(t=A[i++])for(k in t)if(o.call(t,k))a[k]=t[k];return a")
284
+ patch("assign", "var k,i=1,l=A.length;for(;i<l;)if(t=A[i++])for(k in t)if(o.call(t,k))a[k]=t[k];return a")
279
285
  patch("create", "X[P]=a||Y;return new X", 0, nop, {
280
286
  // oKeys is undefined at this point
281
287
  constructor: oKeys, hasOwnProperty: oKeys, isPrototypeOf: oKeys, propertyIsEnumerable: oKeys,
@@ -298,6 +304,7 @@
298
304
  // TODO:2021-02-25:lauri:Accept iterable objects
299
305
  //patch("from", "a=S.call(a);return b?a.map(b,c):a")
300
306
  patch("from", "a=typeof a==='string'?a.split(''):b?a:S.call(a);return b?a.map(b,c):a")
307
+ patch("of", "return S.call(A)")
301
308
 
302
309
  O = O[P]
303
310
  a = "var l=t.length,o=[],i=-1;"
@@ -305,7 +312,7 @@
305
312
  patch("indexOf", a + "i+=b|0;while(++i<l)" + c)
306
313
  patch("lastIndexOf", a + "i=(b|0)||l;i>--l&&(i=l)||i<0&&(i+=l);++i;while(--i>-1)" + c)
307
314
 
308
- b = a + "if(arguments.length<2)b=t"
315
+ b = a + "if(A.length<2)b=t"
309
316
  c = "b=a.call(null,b,t[i],i,t);return b"
310
317
  patch("reduce", b + "[++i];while(++i<l)" + c)
311
318
  patch("reduceRight", b + "[--l];i=l;while(i--)" + c)
@@ -321,6 +328,7 @@
321
328
  patch("filter", b + "o.push(t[i])" + c)
322
329
  patch("some", b + "return!0;return!1")
323
330
 
331
+ patch("flat", "return a<1?S.call(t):(b=t.concat.apply([],t))&&a>1&&b.some(X)?b.flat(a-1):b", 0, isArr)
324
332
  //patch("entries", "a=this;b=-1;return{next:function(){c=a.length<=++b;return{done:c,value:c?void 0:a[b]}}}")
325
333
 
326
334
 
@@ -433,7 +441,7 @@
433
441
  var key = key_.split(":").pop()
434
442
  return !force && O[key] || (O[patched.push(key_), key] = (
435
443
  typeof src === "string" ?
436
- Function("o,O,P,S,F,X,Y", "return function(a,b,c){var t=this;" + src + "}")(hasOwn, O[key], P, aSlice, force, arg1, arg2) :
444
+ Function("o,O,P,S,F,X,Y", "return function(a,b,c){var t=this,A=arguments;" + src + "}")(hasOwn, O[key], P, patched.slice, force, arg1, arg2) :
437
445
  src || {}
438
446
  ))
439
447
  }
@@ -1,357 +0,0 @@
1
-
2
-
3
- %css
4
- .Select,
5
- .Select-box,
6
- .Select-edit {
7
- display: block;
8
- font-size: 14px;
9
- font-weight: 400;
10
- line-height: 30px;
11
- height: 30px;
12
- margin: 0;
13
- overflow: visible;
14
- }
15
- .Select-edit,
16
- .Select-edit:active,
17
- .Select-edit:focus {
18
- width: 100%;
19
- background: transparent;
20
- box-shadow: none;
21
- border: 0;
22
- pointer-events: none;
23
- }
24
- .Select-box {
25
- position: relative;
26
- border-radius: 4px;
27
- border: 1px solid #aaa;
28
- height: 32px;
29
- width: 100%;
30
- background: #fff;
31
- padding: 0 0px;
32
- overflow: hidden;
33
- }
34
- .Select-box:before {
35
- position: absolute;
36
- content: "▼";
37
- color: #999;
38
- right: 4px;
39
- pointer-events: none;
40
- }
41
- .Select-box:hover:before,
42
- .Select-box.is-active:before {
43
- color: #000;
44
- }
45
- .Select-box.is-open,
46
- .Select-box:focus {
47
- border-color: #257;
48
- outline: 0 none;
49
- box-shadow:
50
- 0 2px 5px rgba(0, 0, 0, .5) inset,
51
- 0 0 2px 2px #6ae;
52
- outline: 0 none;
53
- }
54
- .Select-box.is-open {
55
- height: auto;
56
- max-height: 80vh;
57
- z-index: 1;
58
- }
59
- .sm .Select-box.is-open {
60
- position: absolute;
61
- top: 10px;
62
- bottom: 10px;
63
- left: 10px;
64
- right: 10px;
65
- left: 0;
66
- width: 100vw;
67
- height: 100vh;
68
- }
69
- .Select-search,
70
- .Select-search:active,
71
- .Select-search:focus {
72
- display: block;
73
- width: 100%;
74
- box-shadow: none;
75
- }
76
- .Select-val {
77
- padding: 0px 8px;
78
- }
79
- .Select-val:hover {
80
- color: #fff;
81
- background: #3875d7;
82
- background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
83
- cursor: default;
84
- }
85
- .Cal {
86
- width: 240px;
87
- white-space: nowrap;
88
- overflow: hidden;
89
- }
90
- .Cal > table {
91
- width: 240px;
92
- height: 240px;
93
- text-align: center;
94
- display: inline-block;
95
- cursor: default;
96
- }
97
- .Cal.is-month > table {
98
- transform: translateX(-240px);
99
- }
100
- .Cal.is-year > table {
101
- transform: translateX(-480px);
102
- }
103
- .Cal-head {
104
- font-size: 1.4em;
105
- }
106
- .other,
107
- .weekNum,
108
- .weekday,
109
- .weekend {
110
- width: 30px;
111
- height: 30px;
112
- border-radius: 50%;
113
- padding: 0;
114
- }
115
- .monthname:hover,
116
- .yearnum:hover,
117
- td.other:hover,
118
- td.weekday:hover,
119
- td.weekend:hover {
120
- background: #ddd;
121
- }
122
- .Cal-year td.act,
123
- .Cal-month td.act,
124
- .Cal-day td.act {
125
- box-shadow: inset 0 0 20px #666;
126
- }
127
- .yearnum {
128
- border-radius: 4px;
129
- width: 48px;
130
- height: 35px;
131
- }
132
- .monthname {
133
- font-size: 1.4em;
134
- border-radius: 4px;
135
- width: 79px;
136
- height: 52.5px;
137
- }
138
- .other {
139
- color: #999;
140
- }
141
- .weekNum {
142
- font-size: .8em;
143
- color: #999;
144
- }
145
- .weekday {
146
- }
147
- .weekend {
148
- color: #e00;
149
- }
150
-
151
- %js
152
- var inFocus, defaults = {
153
- list: {
154
- },
155
- cal: {
156
- format: "LLL"
157
- },
158
- multi: {}
159
- }
160
- function Select(el, sub, opts, fill, clean) {
161
- console.log("Select", sub, opts)
162
- var child
163
- , box = el.firstChild
164
- , input = box.firstChild
165
- , kb = { enter: open }
166
- El.on(box, "click", open)
167
- function open() {
168
- if (child) return
169
- box.tabIndex = -1
170
- El.cls(box, "is-open")
171
- El.append(box, child = El("Select-" + sub))
172
- fill(child)
173
- El.render(child, El.scope(child, opts))
174
- }
175
- El.on(box, "focus", function(e) {
176
- inFocus = box
177
- El.addKb(kb, box)
178
- })
179
- El.on(box, "blur", blur, 0)
180
- el.val = function(val, valObj) {
181
- El.val(input, val)
182
- if (valObj !== void 0) input.valObject = valObj
183
- if (child) {
184
-
185
- }
186
- }
187
- opts.kill = kill
188
- opts.blur = blur
189
- function blur(e) {
190
- console.log("BLUR", e, box)
191
- if (child && e.key !== "Escape") return
192
- El.rmKb(kb)
193
- El.cls(box, "is-open", box.tabIndex = 0)
194
- setTimeout(_close, 1, e)
195
- }
196
- function _close(e) {
197
- if (!child) return
198
- try {
199
- var act = document.activeElement
200
- if (act == box || (act = act.parentNode) == box || act.parentNode == box) return
201
- } catch(e) {}
202
- kill()
203
- }
204
- function kill() {
205
- if (child) {
206
- clean()
207
- El.kill(child)
208
- child = null
209
- //box.blur()
210
- }
211
- }
212
- }
213
- El.bindings.SelectCal = function(el, opts) {
214
- Select(el, "cal", opts, function(child) {
215
- var scope = El.scope(child)
216
- , now = scope.now = new Date()
217
- set(0)
218
- El.on(child, "click", ".Cal-day td", function(e) {
219
- console.log("select", e, now)
220
- now.setDate(e.target.i)
221
- set(0)
222
- el.val(now.date(opts.format), now.getTime())
223
- })
224
- El.on(child, "click", ".Cal-month td", function(e) {
225
- now.setMonth(e.target.i)
226
- set(0)
227
- })
228
- El.on(child, "click", ".Cal-year td", function(e) {
229
- now.setFullYear(e.target.i)
230
- set(1)
231
- })
232
- function set(view) {
233
- var start = new Date(now).startOf("month")
234
- scope.day = now.getDate()
235
- scope.month = now.getMonth()
236
- scope.year = now.getFullYear()
237
- scope.yearStart = scope.year - scope.year%5 -20
238
- scope.dayOff = (1 - (start.getDay() || 7)) || - 7
239
- scope.week = start.date("W") - (scope.dayOff < -6 ? 1 : 0)
240
- start.setMonth(scope.month + 1, 0)
241
- scope.daysInMonth = start.getDate()
242
- start.setDate(0)
243
- scope.daysInLastMonth = start.getDate()
244
- View.emit("is", 0, child, "calView", view)
245
- console.log(scope)
246
- }
247
- }, function() {
248
- })
249
- }
250
- El.bindings.SelectList = function(el, opts) {
251
- var search
252
- Select(el, "list", opts, function(child) {
253
- search = child[0].firstChild
254
- El.on(search, "blur", opts.close)
255
- El.on(search, "change", filter)
256
- search.focus()
257
- El.addKb({
258
- bubble: 1,
259
- input: 1,
260
- up: function() {
261
- console.log("UP")
262
- },
263
- down: function() {
264
- console.log("DOWN")
265
- },
266
- enter: function() {
267
- console.log("ENTER")
268
-
269
- }
270
- }, child)
271
- }, function() {
272
- search = null
273
- })
274
- El.on(el, "click", ".Select-val", select)
275
- function select(e) {
276
- console.log("select", e)
277
- el.val(e.target.valueObj || e.target.textContent)
278
- opts.kill()
279
- }
280
- function filter() {
281
- }
282
- }
283
- El.bindings.SelectMulti = function(el, opts) {
284
- Select(el, "multi", opts, function() {
285
- }, function() {
286
- })
287
- }
288
-
289
- %el Select
290
- .Select
291
- .Select-box.anim[tabindex=0]
292
- input.Select-edit[tabindex=-1]
293
- %child
294
-
295
- %el Select-cal
296
- .m2.Cal
297
- ;is: data, "calView", ",1,month,2,year", data.calView || 0
298
- table[cellspacing=0].Cal-day.anim
299
- caption.Cal-head
300
- .btn.is-primary.left.bold
301
- ="<"
302
- ;on: "click", ""
303
- .btn.is-primary.right.bold
304
- =">"
305
- ;on: "click", ""
306
- span.m01
307
- ;txt: now.date("MMMM")
308
- ;on: "click", ["calView", 1], "is"
309
- span.m01
310
- ;txt: now.date("YYYY")
311
- ;on: "click", ["calView", 2], "is"
312
- tr
313
- th ;txt: "\xa0"
314
- th ;every:: [1, 2, 3, 4, 5, 6, 7]
315
- ;txt:: Date.names[item<7?item + 24 : 24]
316
- ;cls:: item <6?"weekday":"weekend"
317
- tr ;every:: [0,1,2,3,4,5]
318
- td.weekNum ;txt:: item + week
319
- td
320
- ;every:: [1, 2, 3, 4, 5, 6, 7]
321
- ;cls:: "act", (this.i = _super.item*7 + item + dayOff) == day
322
- ;cls:: this.i < 1 || this.i > daysInMonth ? "other" : item < 6 ? "weekday" : "weekend"
323
- ;txt:: this.i < 1 ? daysInLastMonth + this.i : this.i > daysInMonth ? this.i - daysInMonth : this.i
324
- table[cellspacing=0].Cal-month.anim
325
- caption.Cal-head
326
- ;txt: now.date("YYYY")
327
- ;on: "click", ["calView", 2], "is"
328
- tr.weekRow ;every: [0,1,2,3]
329
- td.monthname
330
- ;every:: [0, 1, 2]
331
- ;cls:: "act", (this.i = _super.item*3 + item) == month
332
- ;txt:: Date.names[this.i]
333
- table[cellspacing=0].Cal-year.anim
334
- caption.Cal-head
335
- span {yearStart} - {yearStart+29}
336
- ;on: "click", ["calView", 0], "is"
337
- tr.weekRow ;every: [0,1,2,3,4,5]
338
- td.yearnum
339
- ;every:: [0, 1, 2, 3, 4]
340
- ;cls:: "act", (this.i = _super.item*5 + item + yearStart) == year
341
- ;txt:: this.i
342
-
343
- %el Select-list
344
- div.m1
345
- input.Select-search[tabindex=-1]
346
- /.Select-clear.hand ×
347
- .scroll
348
- .Select-val {item.name||item.id}
349
- ;every: list
350
-
351
- %el Select-multi
352
- div.m1
353
- input.Select-search[tabindex=-1]
354
- /.Select-clear.hand ×
355
- div
356
- .Select-val item 1
357
- .Select-val item 2