@litejs/ui 22.8.0 → 22.12.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.
@@ -0,0 +1,25 @@
1
+
2
+ /* https://www.tpgi.com/short-note-on-making-your-mark-more-accessible/ */
3
+
4
+ @media screen and (-ms-high-contrast: active) {
5
+ mark {
6
+ color: HighlightText;
7
+ background-color: Highlight;
8
+ }
9
+ }
10
+
11
+ mark::before, mark::after {
12
+ content:" [highlight start] ";
13
+ clip-path: inset(100%);
14
+ clip: rect(1px, 1px, 1px, 1px);
15
+ height: 1px;
16
+ width: 1px;
17
+ overflow: hidden;
18
+ position: absolute;
19
+ white-space: nowrap;
20
+ }
21
+
22
+ mark::after {
23
+ content:" [highlight end] ";
24
+ }
25
+
@@ -0,0 +1,19 @@
1
+
2
+ @media (prefers-color-scheme: dark) {
3
+ .day.dark-scheme { background: #333; color: white; }
4
+ .night.dark-scheme { background: black; color: #ddd; }
5
+ }
6
+
7
+ @media (prefers-contrast: more) {
8
+ .contrast { outline: 2px solid black; }
9
+ }
10
+
11
+ @media screen and (prefers-reduced-motion: reduce), (update: slow) {
12
+ * {
13
+ animation-duration: 0.001ms !important;
14
+ /* Hat tip Nick/cssremedy (https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/#comment-1700170) */
15
+ animation-iteration-count: 1 !important;
16
+ transition-duration: 0.001ms !important;
17
+ }
18
+ }
19
+
package/css/print.css ADDED
@@ -0,0 +1,33 @@
1
+
2
+ /*
3
+ * Ensure you use dark text on a white background
4
+ * Use Borders Instead of Background Colors
5
+ */
6
+
7
+
8
+ @media print {
9
+ table, img, svg {
10
+ break-inside: avoid;
11
+ }
12
+ img.dark {
13
+ filter: invert(100%) hue-rotate(180deg) brightness(120%) contrast(150%);
14
+ }
15
+
16
+ /* Not all printers will print in color, add some other style that isn’t too disruptive. */
17
+ mark {
18
+ border: 1pt dotted #000;
19
+ }
20
+ q:after {
21
+ content: " (Source: " attr(cite) ")";
22
+ }
23
+ a {
24
+ color: #000;
25
+ }
26
+ p a {
27
+ word-wrap: break-word;
28
+ }
29
+ p a[href^="https://"]:after, a[href^="https://"]:after {
30
+ content: " (" attr(href) ")";
31
+ }
32
+ }
33
+
@@ -0,0 +1,10 @@
1
+ .striped45 {
2
+ background-color: currentColor;
3
+ background-image: repeating-linear-gradient(
4
+ 45deg,
5
+ rgba(255, 255, 255, .5),
6
+ rgba(255, 255, 255, .5) 4px,
7
+ transparent 4px,
8
+ transparent 8px
9
+ );
10
+ }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @version 22.8.0
2
+ * @version 22.12.0
3
3
  * @author Lauri Rooden <lauri@rooden.ee>
4
4
  * @license MIT License
5
5
  */
@@ -329,10 +329,9 @@
329
329
  var undef
330
330
  , P = "prototype"
331
331
  , A = Array[P]
332
- , F = Function[P]
333
332
  , S = String[P]
334
333
  , N = Number[P]
335
- , slice = F.call.bind(A.slice)
334
+ , slice = Function[P].call.bind(A.slice)
336
335
  , fns = {}
337
336
  , hasOwn = fns.hasOwnProperty
338
337
  , fnRe = /('|")(?:\\?.)*?\1|\/(?:\\?.)+?\/[gim]*|\b(?:false|in|new|null|this|true|typeof|void|function|var|if|else|return)\b|\.\w+|\w+:/g
@@ -383,6 +382,13 @@
383
382
  return this.indexOf(item) < 0 && this.push(item)
384
383
  }
385
384
 
385
+ A.pluck = function(name) {
386
+ for (var arr = this, i = arr.length, out = []; i--; ) {
387
+ out[i] = arr[i][name]
388
+ }
389
+ return out
390
+ }
391
+
386
392
  // THANKS: Oliver Steele - Functional Javascript [http://www.osteele.com/sources/javascript/functional/]
387
393
  function Fn(expr /*, scope, mask1, ..maskN */) {
388
394
  var args = []
@@ -433,21 +439,6 @@
433
439
  return "" + this
434
440
  }
435
441
 
436
- S.safe = function() {
437
- return this
438
- .replace(/&/g, "&amp;")
439
- .replace(/</g, "&lt;")
440
- .replace(/>/g, "&gt;")
441
- .replace(/\"/g, "&quot;")
442
- }
443
-
444
- S.capitalize = function() {
445
- return this.charAt(0).toUpperCase() + this.slice(1)
446
- }
447
-
448
- S.lower = S.toLowerCase
449
- S.upper = S.toUpperCase
450
-
451
442
  N.step = function(a, add) {
452
443
  var x = ("" + a).split(".")
453
444
  , steps = this / a
@@ -461,57 +452,6 @@
461
452
  })
462
453
  }
463
454
 
464
- N.scale = words([1000, 1000, 1000], ["","k","M","G"], {"default": "{n}{u}"})
465
-
466
- S.scale = function() {
467
- return this.replace(numbersRe, function(num) {
468
- return (+num).scale()
469
- })
470
- }
471
-
472
- S.pick = N.pick = function() {
473
- var val = this + "="
474
- for (var s, a = arguments, i = 0, len = a.length; i < len;) {
475
- s = a[i++]
476
- if (s.indexOf(val) == 0) {
477
- s = s.slice(val.length)
478
- i = len
479
- }
480
- }
481
- return s.replace("#", this)
482
- }
483
-
484
- S.plural = N.plural = function() {
485
- // Plural-Forms: nplurals=2; plural=n != 1;
486
- // http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#Plural-forms
487
- return arguments[ +Fn("n->" + (String.plural || "n!=1"))( parseFloat(this) ) ].replace("#", this)
488
- }
489
-
490
- A.pluck = function(name) {
491
- for (var arr = this, i = arr.length, out = []; i--; ) {
492
- out[i] = arr[i][name]
493
- }
494
- return out
495
- }
496
-
497
- function words(steps, units, strings, overflow) {
498
- return function(input) {
499
- var n = +(arguments.length ? input : this)
500
- , i = 0
501
- , s = strings || {"default": "{n} {u}{s}"}
502
-
503
- for (; n>=steps[i]; ) {
504
- n /= steps[i++]
505
- }
506
- if (i == steps.length && overflow) {
507
- return overflow(this)
508
- }
509
- i = units[i]
510
- return (s[n < 2 ? i : i + "s"] || s["default"]).format({n: n, u: i, s: n < 2 ? "" : "s"})
511
- }
512
- }
513
- Fn.words = words
514
-
515
455
  function wait(fn) {
516
456
  var pending = 1
517
457
  function resume() {
@@ -1139,14 +1079,10 @@
1139
1079
  * <input id="12" class="nice class" type="checkbox" checked="checked" disabled="disabled" data-lang="en">
1140
1080
  */
1141
1081
 
1142
- function isObject(obj) {
1143
- return obj && obj.constructor === Object
1144
- }
1145
-
1146
1082
  window.El = El
1147
1083
 
1148
1084
  function El(name) {
1149
- if (typeof name != "string") {
1085
+ if (!isString(name)) {
1150
1086
  return new ElWrap(name)
1151
1087
  }
1152
1088
  var el, pres
@@ -1267,8 +1203,6 @@
1267
1203
  , checkbox = type === "checkbox" || type === "radio"
1268
1204
 
1269
1205
  if (el.tagName === "FORM") {
1270
- opts = {}
1271
-
1272
1206
  // Disabled controls do not receive focus,
1273
1207
  // are skipped in tabbing navigation, cannot be successfully posted.
1274
1208
  //
@@ -1277,15 +1211,11 @@
1277
1211
  //
1278
1212
  // Read-only checkboxes can be changed by the user
1279
1213
 
1280
- for (; input = el.elements[i++]; ) if (!input.disabled && (key = input.name || input.id)) {
1214
+ for (opts = {}; input = el.elements[i++]; ) if (!input.disabled && (key = input.name || input.id)) {
1281
1215
  value = valFn(input)
1282
1216
  if (value !== UNDEF) {
1283
1217
  step = opts
1284
- key.replace(/\[(.*?)\]/g, function(_, _key, offset) {
1285
- if (step == opts) key = key.slice(0, offset)
1286
- step = step[key] || (step[key] = step[key] === null || _key && +_key != _key ? {} : [])
1287
- key = _key
1288
- })
1218
+ key.replace(/\[(.*?)\]/g, replacer)
1289
1219
  step[key || step.length] = value
1290
1220
  }
1291
1221
  }
@@ -1324,17 +1254,22 @@
1324
1254
  return checkbox && !el.checked ?
1325
1255
  (type === "radio" ? UNDEF : null) :
1326
1256
  el.valObject !== UNDEF ? el.valObject : el.value
1257
+
1258
+ function replacer(_, _key, offset) {
1259
+ if (step == opts) key = key.slice(0, offset)
1260
+ step = step[key] || (step[key] = step[key] === null || _key && +_key != _key ? {} : [])
1261
+ key = _key
1262
+ }
1327
1263
  }
1328
1264
 
1329
1265
  function append(el, child, before) {
1330
1266
  if (!el.nodeType) {
1331
1267
  return el.append ? el.append(child, before) : el
1332
1268
  }
1333
- var fragment
1269
+ var fragment, tmp
1334
1270
  , i = 0
1335
- , tmp = typeof child
1336
1271
  if (child) {
1337
- if (tmp === "string" || tmp === "number") child = document.createTextNode(child)
1272
+ if (isString(child) || isNumber(child)) child = document.createTextNode(child)
1338
1273
  else if ( !("nodeType" in child) && "length" in child ) {
1339
1274
  // document.createDocumentFragment is unsupported in IE5.5
1340
1275
  // fragment = "createDocumentFragment" in document ? document.createDocumentFragment() : El("div")
@@ -1359,7 +1294,7 @@
1359
1294
  /**/
1360
1295
  tmp.insertBefore(child,
1361
1296
  (before === true ? tmp.firstChild :
1362
- typeof before === "number" ? tmp.childNodes[
1297
+ isNumber(before) ? tmp.childNodes[
1363
1298
  before < 0 ? tmp.childNodes.length - before - 2 : before
1364
1299
  ] : before) || null
1365
1300
  )
@@ -1424,7 +1359,7 @@
1424
1359
  function hasClass(el, name) {
1425
1360
  var current = el.className || ""
1426
1361
 
1427
- if (typeof current !== "string") {
1362
+ if (!isString(current)) {
1428
1363
  current = el.getAttribute("class") || ""
1429
1364
  }
1430
1365
 
@@ -1433,7 +1368,7 @@
1433
1368
 
1434
1369
  function cls(el, name, set) {
1435
1370
  var current = el.className || ""
1436
- , useAttr = typeof current !== "string"
1371
+ , useAttr = !isString(current)
1437
1372
 
1438
1373
  if (useAttr) {
1439
1374
  current = el.getAttribute("class") || ""
@@ -1512,14 +1447,14 @@
1512
1447
 
1513
1448
  function bindingOn(el, events, selector, data, handler, delay) {
1514
1449
  var argi = arguments.length
1515
- if (argi == 3 || argi == 4 && typeof data === "number") {
1450
+ if (argi == 3 || argi == 4 && isNumber(data)) {
1516
1451
  delay = data
1517
1452
  handler = selector
1518
1453
  selector = data = null
1519
- } else if (argi == 4 || argi == 5 && typeof handler === "number") {
1454
+ } else if (argi == 4 || argi == 5 && isNumber(handler)) {
1520
1455
  delay = handler
1521
1456
  handler = data
1522
- if (typeof selector === "string") {
1457
+ if (isString(selector)) {
1523
1458
  data = null
1524
1459
  } else {
1525
1460
  data = selector
@@ -1531,7 +1466,7 @@
1531
1466
  return
1532
1467
  }
1533
1468
  var fn = (
1534
- typeof handler === "string" ? function(e) {
1469
+ isString(handler) ? function(e) {
1535
1470
  var target = selector ? El.closest(e.target, selector) : el
1536
1471
  if (target) View.emit.apply(View, [handler, e, target].concat(data))
1537
1472
  } :
@@ -1947,7 +1882,7 @@
1947
1882
  map.bubble
1948
1883
  ););
1949
1884
  if (fn) {
1950
- typeof fn === "string" ? View.emit(fn, e, chr, el) : fn(e, chr, el)
1885
+ isString(fn) ? View.emit(fn, e, chr, el) : fn(e, chr, el)
1951
1886
  }
1952
1887
  }
1953
1888
 
@@ -2048,4 +1983,16 @@
2048
1983
  wrapper[P].constructor = wrapper
2049
1984
  return wrapper
2050
1985
  }
1986
+
1987
+ function isNumber(num) {
1988
+ return typeof num === "number"
1989
+ }
1990
+
1991
+ function isObject(obj) {
1992
+ return !!obj && obj.constructor === Object
1993
+ }
1994
+
1995
+ function isString(str) {
1996
+ return typeof str === "string"
1997
+ }
2051
1998
  }(window, document, Object, Event, "prototype")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litejs/ui",
3
- "version": "22.8.0",
3
+ "version": "22.12.0",
4
4
  "description": "UI engine for LiteJS full-stack framework",
5
5
  "license": "MIT",
6
6
  "author": "Lauri Rooden <lauri@rooden.ee>",
package/polyfill/index.js CHANGED
@@ -308,8 +308,10 @@
308
308
 
309
309
  O = O[P]
310
310
  a = "var l=t.length,o=[],i=-1;"
311
+ b = "i+=b|0;while(++i<l)"
311
312
  c = "if(t[i]===a)return i;return -1"
312
- patch("indexOf", a + "i+=b|0;while(++i<l)" + c)
313
+ patch("includes", a + b + "if(t[i]===a||(a!==a&&t[i]!==t[i]))return!0;return!1")
314
+ patch("indexOf", a + b + c)
313
315
  patch("lastIndexOf", a + "i=(b|0)||l;i>--l&&(i=l)||i<0&&(i+=l);++i;while(--i>-1)" + c)
314
316
 
315
317
  b = a + "if(A.length<2)b=t"