@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/pointer.js CHANGED
@@ -33,7 +33,7 @@
33
33
  if (len === 1) {
34
34
  if (e) {
35
35
  firstEl = e.currentTarget || e.target
36
- if (El.matches(e.target, "INPUT,TEXTAREA,SELECT,.no-drag")) return
36
+ if (e.button === 2 || El.matches(e.target, "INPUT,TEXTAREA,SELECT,.no-drag")) return
37
37
  } else {
38
38
  e = pointers[0]
39
39
  }
@@ -67,11 +67,15 @@
67
67
  El.emit(firstEl, "pan", e, firstPos, firstEl)
68
68
  if (!firstPos.cancel) {
69
69
  if (firstEl.getBBox) {
70
- firstEl.setAttributeNS(null, "x", firstPos.leftPos)
71
- firstEl.setAttributeNS(null, "y", firstPos.topPos)
70
+ El.attr(firstEl, {
71
+ x: firstPos.leftPos,
72
+ y: firstPos.topPos
73
+ }, 0)
72
74
  } else {
73
- firstEl.style.left = firstPos.leftPos + "px"
74
- firstEl.style.top = firstPos.topPos + "px"
75
+ El.css(firstEl, {
76
+ left: firstPos.leftPos + "px",
77
+ top: firstPos.topPos + "px"
78
+ }, 0)
75
79
  }
76
80
  }
77
81
  }
package/polyfill/index.js CHANGED
@@ -2,34 +2,54 @@
2
2
  /* litejs.com/MIT-LICENSE.txt */
3
3
 
4
4
 
5
+ // IE5 does not support
6
+ // - Array#push/pop
7
+ // - Function#call
8
+ // - encodeURIComponent
9
+ // - RegExp lookahead /(?=a)/ and non-greedy modifiers /a+?/
10
+ // - if ("key" in map) and hasOwnProperty
11
+
12
+ // IE5.5-IE7 Patched: 41
13
+ // Event, pointer, setTimeout, setInterval, sessionStorage, localStorage, requestAnimationFrame, cancelAnimationFrame, console, JSON, matchMedia, performance, p:now, timing, d:now, toJSON, toISOString, bind, assign, create, entries, keys, values, toString, isArray, from, indexOf, lastIndexOf, reduce, reduceRight, every, forEach, map, filter, some, trim, sendBeacon, matches, closest, querySelector, querySelectorAll
14
+ // IE8 Patched: 38
15
+ // Event, pointer, setTimeout, setInterval, requestAnimationFrame, cancelAnimationFrame, console, matchMedia, performance, p:now, timing, d:now, toJSON, toISOString, bind, assign, create, entries, keys, values, toString, isArray, from, indexOf, lastIndexOf, reduce, reduceRight, every, forEach, map, filter, some, trim, sendBeacon, matches, closest, querySelector, querySelectorAll
16
+ // IE10 Patched: 9
17
+ // Event, pointer:MS, assign, entries, values, from, sendBeacon, matches, closest
18
+ // IE11 Patched: 8
19
+ // Event, assign, entries, values, from, sendBeacon, matches, closest
20
+
5
21
 
6
22
  !function(window, Function) {
23
+
24
+ // Array#flat() - Chrome69, Edge79, Firefox62, Safari12
7
25
  // window.PointerEvent - Chrome55, Edge12, Firefox59, Safari13, IE11
8
26
  // navigator.sendBeacon - Chrome39, Edge14, Firefox31, Safari11.1
9
27
  // Object.fromEntries - Chrome73, Edge79, Firefox63, Safari12.1, Opera60, Node.js12.0.0
10
28
  // queueMicrotask - Chrome71, Edge79, Firefox69, Safari12.1
11
29
 
12
30
  var isArr, oKeys
13
- , a, b, c
14
- // JScript engine in IE<9 does not recognize vertical tabulation character
15
- , ie678 = !+"\v1"
16
31
  , P = "prototype"
17
32
  , O = window
18
- , patched = (window.xhr || window)._patched = []
19
- , aSlice = patched.slice
33
+ , patched = (window.xhr || window)._p = []
20
34
  , jsonRe = /[\x00-\x1f\x22\x5c]/g
21
35
  , JSONmap = {"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t",'"':'\\"',"\\":"\\\\"}
22
36
  , hasOwn = JSONmap.hasOwnProperty
23
37
  , esc = escape
24
38
  , document = patch("document", {body:{}})
25
39
  , navigator = patch("navigator")
40
+ // JScript engine in IE<9 does not recognize vertical tabulation character
41
+ // The documentMode is an IE only property, supported from IE8
42
+ , a = document.documentMode | 0, b, c
43
+ , ie678 = !+"\v1" && a < 9
44
+ , ie6789 = ie678 || a == 9
45
+ , ie67 = ie678 && a < 8
26
46
  , EV = "Event"
27
47
  , Event = patch(
28
48
  EV,
29
49
  "c=F.createEventObject(event),b=c.buttons=c.button;c.button=b==1?0:b==4?1:b;c.preventDefault=X;c.stopPropagation=Y;c.target=c.srcElement;c.type=a;return c",
30
50
  !isFn(O[EV]) && document,
31
- function(){ event.returnValue = false },
32
- function(){ event.cancelBubble = event.cancel = true }
51
+ Function("event.returnValue=!1"),
52
+ Function("event.cancelBubble=event.cancel=!0")
33
53
  )
34
54
  , wheelDiff = 120
35
55
  , fixEv = Event.fixEv = {
@@ -68,6 +88,9 @@
68
88
  c: "touchcancel"
69
89
  }
70
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
71
94
 
72
95
  if (!window.PointerEvent) {
73
96
  // IE10
@@ -140,6 +163,10 @@
140
163
  // https://bugzilla.mozilla.org/show_bug.cgi?id=666448
141
164
  patch("escape", "return X(a)", esc("a", 0) != "a", esc)
142
165
 
166
+ // Patch parameters support for setTimeout callback
167
+ patch("setTimeout", (a = "return O(X(a)&&A.length>2?a.apply.bind(a,null,S.call(A,2)):a,b)"), ie6789, isFn)
168
+ patch("setInterval", a, ie6789, isFn)
169
+
143
170
  function createStorage(name) {
144
171
  try {
145
172
  // FF4-beta with dom.storage.enabled=false throws for accessing windows.localStorage
@@ -198,6 +225,8 @@
198
225
  // window.msRequestAnimationFrame || // IE 10 PP2+
199
226
  patch("cancelAnimationFrame", "clearTimeout(a)")
200
227
 
228
+ // IE8 has console, however, the console object does not exist if the console is not opened.
229
+ patch("console", {log: nop, error: nop})
201
230
 
202
231
 
203
232
  function jsonFn(str) {
@@ -224,29 +253,36 @@
224
253
  }
225
254
  })
226
255
 
256
+ /*** ie9 ***/
257
+ patch("matchMedia", "b=a||'all';return{media:b,matches:X?X.matchMedium(b):!1,addEventListener:Y}", 0, window.styleMedia || window.media, nop)
258
+ /**/
259
+
227
260
  O = patch("performance")
228
- patch("now", (a = "return+new Date") + "-X", 0, new Date())
261
+ patch("p:now", (a = "return+new Date") + "-X", 0, new Date())
229
262
  patch("timing")
230
263
 
231
264
  O = Date
232
- patch("now", a)
265
+ patch("d:now", a)
233
266
 
267
+ /*** toISOString ***/
234
268
  O = O[P]
235
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
236
272
  patch("toISOString", patch("toJSON", [
237
- "return this.getUTCFullYear(", "Month()+1,'-'", "Date(),'-'",
238
- "Hours(),'T'", "Minutes(),':'", "Seconds(),':'", "Milliseconds(),'.')+'Z'"
239
- ].join(")+X(this.getUTC"), ie678, function(n, b){ return b + ("00" + n).slice((b !== ".")-3) }))
240
-
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
+ /**/
241
277
 
242
278
  O = Function[P]
243
279
  // Chrome7, FF4, IE9, Opera 11.60, Safari 5.1.4
244
- patch("bind", "var t=this;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")
245
281
 
246
282
 
247
283
  O = Object
248
- patch("assign", "var t,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")
249
- patch("create", "X[P]=a||Y;return new X", 0, function(){}, {
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")
285
+ patch("create", "X[P]=a||Y;return new X", 0, nop, {
250
286
  // oKeys is undefined at this point
251
287
  constructor: oKeys, hasOwnProperty: oKeys, isPrototypeOf: oKeys, propertyIsEnumerable: oKeys,
252
288
  toLocaleString: oKeys, toString: oKeys, valueOf: oKeys
@@ -258,21 +294,25 @@
258
294
  patch("values", a + "a[b]" + b)
259
295
  //patch("fromEntries", "for(a=a.entries(),c={};!(b=a.next()).done;c[b[0]]=b[1]" + b)
260
296
 
261
- a = O[P].toString
297
+ a = O[P][b = "toString"]
298
+ O = Error[P]
299
+ // in IE8 Error("1") creates {description: "", message: "", name: "Error", number: 1}
300
+ patch(b, "a=t.message||t.number;return a?X+': '+a:X", Error(1) != "Error: 1", "Error")
262
301
  O = Array
263
302
  isArr = patch("isArray", "return X.call(a)==='[object Array]'", 0, a)
264
303
 
265
304
  // TODO:2021-02-25:lauri:Accept iterable objects
266
305
  //patch("from", "a=S.call(a);return b?a.map(b,c):a")
267
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)")
268
308
 
269
309
  O = O[P]
270
- a = "var t=this,l=t.length,o=[],i=-1;"
310
+ a = "var l=t.length,o=[],i=-1;"
271
311
  c = "if(t[i]===a)return i;return -1"
272
312
  patch("indexOf", a + "i+=b|0;while(++i<l)" + c)
273
313
  patch("lastIndexOf", a + "i=(b|0)||l;i>--l&&(i=l)||i<0&&(i+=l);++i;while(--i>-1)" + c)
274
314
 
275
- b = a + "if(arguments.length<2)b=t"
315
+ b = a + "if(A.length<2)b=t"
276
316
  c = "b=a.call(null,b,t[i],i,t);return b"
277
317
  patch("reduce", b + "[++i];while(++i<l)" + c)
278
318
  patch("reduceRight", b + "[--l];i=l;while(i--)" + c)
@@ -288,11 +328,12 @@
288
328
  patch("filter", b + "o.push(t[i])" + c)
289
329
  patch("some", b + "return!0;return!1")
290
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)
291
332
  //patch("entries", "a=this;b=-1;return{next:function(){c=a.length<=++b;return{done:c,value:c?void 0:a[b]}}}")
292
333
 
293
334
 
294
335
  O = String[P]
295
- patch("trim", "return this.replace(/^\\s+|\\s+$/g,'')")
336
+ patch("trim", "return t.replace(/^\\s+|\\s+$/g,'')")
296
337
 
297
338
 
298
339
  O = navigator
@@ -323,12 +364,12 @@
323
364
  "~": "~a.split(/\\s+/).indexOf(v)",
324
365
  "*": "~a.indexOf(v)"
325
366
  }
326
- , matches = patch("matches", "return!!X(a)(this)", 0, selectorFn)
327
- , closest = patch("closest", "return X(this,'parentNode',a,1)", 0, walk)
367
+ , matches = patch("matches", "return!!X(a)(t)", 0, selectorFn)
368
+ , closest = patch("closest", "return X(t,'parentNode',a,1)", 0, walk)
328
369
 
329
370
  // Note: querySelector in IE8 supports only CSS 2.1 selectors
330
- patch("querySelector", (a = "return X(this,a,") + "1)", ie678, find)
331
- patch("querySelectorAll", a + "0)", ie678, find)
371
+ patch((b="querySelector"), (a = "return X(t,a,") + "1)", ie678, find)
372
+ patch(b + "All", a + "0)", ie678, find)
332
373
  //patch("addEventListener", function(ev, fn) { })
333
374
  //patch("removeEventListener")
334
375
 
@@ -383,9 +424,6 @@
383
424
  // ie6789
384
425
  // The documentMode is an IE only property, supported from IE8.
385
426
  if (ie678 || document.documentMode <= 9) {
386
- // Patch parameters support for setTimeout callback
387
- patch("setTimeout", (a = "var A=arguments;return O(X(a)&&A.length>2?a.apply.bind(a,null,S.call(A,2)):a,b)"), 1, isFn)
388
- patch("setInterval", a, 1, isFn)
389
427
  try {
390
428
  // Remove background image flickers on hover in IE6
391
429
  // You could also use CSS
@@ -397,11 +435,13 @@
397
435
  function isFn(f) {
398
436
  return typeof f === "function"
399
437
  }
438
+ function nop() {}
400
439
 
401
- function patch(key, src, force, arg1, arg2) {
402
- return !force && O[key] || (O[patched.push(key), key] = (
440
+ function patch(key_, src, force, arg1, arg2) {
441
+ var key = key_.split(":").pop()
442
+ return !force && O[key] || (O[patched.push(key_), key] = (
403
443
  typeof src === "string" ?
404
- Function("o,O,P,S,F,X,Y", "return function(a,b,c){" + 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) :
405
445
  src || {}
406
446
  ))
407
447
  }
package/svg.js CHANGED
@@ -20,11 +20,11 @@
20
20
  ).replace(/\w+/g, populateSvgElements)
21
21
 
22
22
  //http://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle
23
- function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
24
- var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0
23
+ function polarToCartesian(centerX, centerY, radius, angle/*InDegrees*/) {
24
+ angle/*InRadians*/ = (angle - 90) * Math.PI / 180.0
25
25
  return {
26
- x: centerX + (radius * Math.cos(angleInRadians)),
27
- y: centerY + (radius * Math.sin(angleInRadians))
26
+ x: centerX + (radius * Math.cos(angle)),
27
+ y: centerY + (radius * Math.sin(angle))
28
28
  }
29
29
  }
30
30
  function describeArc(x, y, radius, startAngle, endAngle) {