@litejs/ui 25.5.0 → 26.2.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 CHANGED
@@ -13,18 +13,30 @@ used on heavy-traffic websites since 2006.
13
13
 
14
14
  - Dependency-free, weighs around 25kB (+8kB polyfills for old browsers).
15
15
  - Written in ES5, compatible with all browsers (including IE5.5).
16
- - No transpiling/compiling/bundling headache, just write a working code.
16
+ Works seamlessly in ESM projects too.
17
+ - No transpiling/compiling/bundling headache, just write working code.
18
+
19
+ Includes templates, view routing, data binding, i18n, keyboard shortcuts, and touch gestures.
17
20
 
18
21
  For usage instructions, see [Quick-Start](https://github.com/litejs/litejs/wiki/Quick-Start) guide
19
22
  and [wiki](https://github.com/litejs/ui/wiki).
20
23
 
24
+ ## Examples
25
+
26
+ - [Simplest example](https://litejs.github.io/ui/simplest.html) —
27
+ [source](/litejs/ui/blob/main/test/html/simplest.html)
28
+ - [Built-in routing](https://litejs.github.io/ui/routed.html) —
29
+ [source](/litejs/ui/blob/main/test/html/routed.html)
30
+ - [Full SVG SPA](https://litejs.github.io/ui/svg-spa.html) —
31
+ [source](/litejs/ui/blob/main/test/html/svg-spa.html)
32
+
21
33
 
22
34
  ## Contributing
23
35
 
24
36
  Follow [Coding Style Guide](https://github.com/litejs/litejs/wiki/Style-Guide),
25
37
  run tests `npm install; npm test`.
26
38
 
27
- > Copyright (c) 2006-2024 Lauri Rooden <lauri@rooden.ee>
39
+ > Copyright (c) 2006-2026 Lauri Rooden <lauri@rooden.ee>
28
40
  [MIT License](https://litejs.com/MIT-LICENSE.txt) |
29
41
  [GitHub repo](https://github.com/litejs/ui) |
30
42
  [npm package](https://npmjs.org/package/@litejs/ui) |
package/css/anim.css CHANGED
@@ -1,20 +1,13 @@
1
1
 
2
- /**
3
- * 1. Trigger GPU acceleration.
4
- * Remove first flicker on iphone.
5
- */
6
2
 
7
3
  .anim,
8
4
  .anim:after,
9
5
  .anim:before {
10
- -webkit-transition: all .2s cubic-bezier(0, 0, .2, 1) 0s;
11
- -moz-transition: all .2s cubic-bezier(0, 0, .2, 1) 0s;
12
- -o-transition: all .2s cubic-bezier(0, 0, .2, 1) 0s;
13
- transition: all .2s cubic-bezier(0, 0, .2, 1) 0s;
6
+ transition: all .2s;
14
7
 
15
- -webkit-transform: translate3d(0, 0, 0); /* 1 */
16
- transform: translate3d(0, 0, 0);
17
- -webkit-perspective: 1000;
18
- perspective: 1000;
8
+ /* Trigger GPU acceleration. Remove first flicker on iphone. */
9
+ transform: translate3d(0, 0, 0);
10
+
11
+ perspective: 1000;
19
12
  }
20
13
 
package/css/base.css CHANGED
@@ -1,40 +1,21 @@
1
1
 
2
- /**
3
- * 1. Do not adjusts the text size automatically.
4
- * IE Phone note - If the viewport is set using <meta> element,
5
- * the value of the CSS text-size-adjust property is ignored.
6
- * Webkit bug - If -webkit-text-size-adjust is explicitely set to none,
7
- * Webkit-based desktop browsers, like Chrome or Safari,
8
- * instead of ignoring the property, will prevent the user to zoom in or out the Web page.
9
- * See Bug 56543, Bug 163359, and Bug 84186.
10
- * 2. IE for Windows Phone 8.1 supports "-webkit-text-size-adjust" as an alias for "-ms-text-size-adjust".
11
- * 3. Firefox<29, iOS<4, Android<4 need vendor prefixes.
12
- * 4. Disable double-tap gestures to remove 350 millisecond delay before single taps.
13
- * 5. Improve scroll performance by stop the paint on scroll.
14
- * Fix position: fixed in most Android 2.2–2.3 browsers
15
- * http://benfrain.com/easy-css-fix-fixed-positioning-android-2-2-2-3/
16
- */
2
+
17
3
 
18
4
  *, *:before, *:after {
19
5
  color: inherit;
20
- -webkit-box-sizing: inherit; /* 3 */
21
- -moz-box-sizing: inherit;
22
- box-sizing: inherit;
23
- -webkit-backface-visibility: inherit;
24
- backface-visibility: inherit;
6
+ box-sizing: inherit;
7
+ backface-visibility: inherit;
25
8
  }
26
9
 
27
10
  html {
28
- -webkit-text-size-adjust: 100%; /* 1 */
29
- -ms-text-size-adjust: 100%; /* 2 */
30
- -webkit-font-smoothing: antialiased;
31
- -webkit-box-sizing: border-box; /* 3 */
32
- -moz-box-sizing: border-box;
33
- box-sizing: border-box;
34
- touch-action: manipulation; /* 4 */
35
- -webkit-backface-visibility: hidden; /* 5 */
36
- backface-visibility: hidden;
37
- text-rendering: optimizeLegibility;
11
+ /* 62.5% sets 1em = 10px (16px × 0.625) */
12
+ font-size: 62.5%;
13
+
14
+ /* Use IE4 superior box model */
15
+ box-sizing: border-box;
16
+
17
+ /* Improve scroll performance by stop the paint on scroll */
18
+ backface-visibility: hidden;
38
19
  }
39
20
 
40
21
  html,
@@ -64,16 +45,10 @@ label,
64
45
  pointer-events: none;
65
46
  }
66
47
 
67
- button {
68
- /* Fix extra padding issue in IE6/7 */
69
- width: auto;
70
- overflow: visible;
71
- }
72
-
73
48
  b,
74
49
  strong,
75
50
  th {
76
- /* Firefox default {font-weight:bolder} does not render well with some fonts (Helvetica Neue on macs). */
51
+ /* Firefox's default 'bolder' looks bad with some fonts (Helvetica Neue on macs). */
77
52
  font-weight: bold;
78
53
  }
79
54
 
@@ -89,142 +64,31 @@ video {
89
64
  vertical-align: top;
90
65
  }
91
66
 
92
- /**
93
- * 1. tables still need cellspacing="0" in the markup
94
- * 2. Restores the normal text size
95
- * @see http://code.stephenmorley.org/html-and-css/fixing-browsers-broken-monospace-font-handling/
96
- */
97
67
 
98
68
  table {
69
+ /* tables still need cellspacing="0" in the markup */
99
70
  border-collapse: collapse;
100
- border-spacing: 0; /* 1 */
71
+ border-spacing: 0;
101
72
  }
102
73
 
103
74
  code,
104
75
  kbd,
105
76
  pre,
106
77
  samp {
107
- font-family: monospace, monospace; /* 2 */
78
+ /* Fix monospace bug in browsers that may ignore first one */
79
+ font-family: monospace, monospace;
108
80
  font-size: 1em;
109
81
  }
110
82
 
111
83
  textarea {
112
- resize: vertical;
84
+ resize: both;
113
85
  }
114
86
 
115
87
  button,
116
- [draggable=true],
117
88
  .btn,
118
- .no-select {
119
- -webkit-user-select: none;
120
- -khtml-user-select: none;
121
- -moz-user-select: none;
122
- -ms-user-select: none;
123
- -o-user-select: none;
124
- user-select: none;
125
- }
126
-
89
+ .no-select,
127
90
  [draggable=true] {
128
- -webkit-user-drag: element;
129
- -khtml-user-drag: element;
130
- user-drag: element;
131
- }
132
-
133
-
134
- /**
135
- * Global Classes
136
- * --------------
137
- */
138
-
139
- .max-height {
140
- height: auto !important;
141
- height: 100%;
142
- min-height: 100%;
143
- }
144
-
145
- .sm .sm-hide,
146
- .md .md-hide,
147
- .lg .lg-hide,
148
- .hide-empty:empty,
149
- .hide {
150
- display: none !important;
151
- visibility: hidden;
152
- }
153
- .transparent {
154
- opacity: 0 !important;
155
- filter: alpha(opacity=0) !important;
156
- }
157
- .abs {
158
- position: absolute;
159
- }
160
- .absr {
161
- position: absolute;
162
- top: 0px;
163
- right: 0px;
164
- }
165
- .fix {
166
- position: absolute;
167
- position: fixed;
168
- }
169
- .rel {
170
- position: relative;
171
- height: 100%;
172
- }
173
- .max {
174
- top: 0px;
175
- left: 0px;
176
- width: 100%;
177
- height: 100%;
178
- overflow: hidden;
179
- }
180
-
181
-
182
- /* establishes a new block formatting context */
183
- .block {
184
- overflow: hidden;
185
- }
186
-
187
- .btn,
188
- .no-wrap,
189
- .ellipsis {
190
- text-overflow: ellipsis;
191
- white-space: nowrap;
192
- }
193
-
194
- .sm .sm-left,
195
- .md .md-left,
196
- .lg .lg-left,
197
- .left {
198
- float: left;
199
- }
200
-
201
- .sm .sm-right,
202
- .md .md-right,
203
- .lg .lg-right,
204
- .right {
205
- float: right !important;
206
- }
207
-
208
- .sm .sm-t-left,
209
- .md .md-t-left,
210
- .lg .md-t-left,
211
- .lg .lg-t-left,
212
- .t-left {
213
- text-align: left;
214
- }
215
- .sm .sm-t-center,
216
- .md .md-t-center,
217
- .lg .md-t-center,
218
- .lg .lg-t-center,
219
- .t-center {
220
- text-align: center;
221
- }
222
- .sm .sm-t-right,
223
- .md .md-t-right,
224
- .lg .md-t-right,
225
- .lg .lg-t-right,
226
- .t-right {
227
- text-align: right;
91
+ user-select: none;
228
92
  }
229
93
 
230
94
 
package/css/global.css ADDED
@@ -0,0 +1,99 @@
1
+
2
+
3
+ /**
4
+ * Global Classes
5
+ * --------------
6
+ */
7
+
8
+ .max-height {
9
+ height: auto !important;
10
+ height: 100%;
11
+ min-height: 100%;
12
+ }
13
+
14
+ .sm .sm-hide,
15
+ .md .md-hide,
16
+ .lg .lg-hide,
17
+ .hide-empty:empty,
18
+ .hide {
19
+ display: none !important;
20
+ visibility: hidden;
21
+ }
22
+ .transparent {
23
+ opacity: 0 !important;
24
+ filter: alpha(opacity=0) !important;
25
+ }
26
+ .abs {
27
+ position: absolute;
28
+ }
29
+ .absr {
30
+ position: absolute;
31
+ top: 0px;
32
+ right: 0px;
33
+ }
34
+ .fix {
35
+ position: absolute;
36
+ position: fixed;
37
+ }
38
+ .rel {
39
+ position: relative;
40
+ height: 100%;
41
+ }
42
+ .max {
43
+ top: 0px;
44
+ left: 0px;
45
+ width: 100%;
46
+ height: 100%;
47
+ overflow: hidden;
48
+ }
49
+
50
+
51
+ /* establishes a new block formatting context */
52
+ .block {
53
+ overflow: hidden;
54
+ }
55
+
56
+ .btn,
57
+ .no-wrap,
58
+ .ellipsis {
59
+ text-overflow: ellipsis;
60
+ white-space: nowrap;
61
+ }
62
+
63
+ .sm .sm-left,
64
+ .md .md-left,
65
+ .lg .lg-left,
66
+ .left {
67
+ float: left;
68
+ }
69
+
70
+ .sm .sm-right,
71
+ .md .md-right,
72
+ .lg .lg-right,
73
+ .right {
74
+ float: right !important;
75
+ }
76
+
77
+ .sm .sm-t-left,
78
+ .md .md-t-left,
79
+ .lg .md-t-left,
80
+ .lg .lg-t-left,
81
+ .t-left {
82
+ text-align: left;
83
+ }
84
+ .sm .sm-t-center,
85
+ .md .md-t-center,
86
+ .lg .md-t-center,
87
+ .lg .lg-t-center,
88
+ .t-center {
89
+ text-align: center;
90
+ }
91
+ .sm .sm-t-right,
92
+ .md .md-t-right,
93
+ .lg .md-t-right,
94
+ .lg .lg-t-right,
95
+ .t-right {
96
+ text-align: right;
97
+ }
98
+
99
+
package/load.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /*! litejs.com/MIT-LICENSE.txt */
3
3
 
4
- /* global location */
4
+ /* global document, location */
5
5
 
6
6
  // With initial congestion window set to 2 and 1452 bytes of data in a segment.
7
7
  // - 1 round trip to get 2904 bytes, Initial Window (IW) = 2
@@ -18,47 +18,45 @@
18
18
  // xhr("PUT", url).send(null) Works in all major browsers
19
19
 
20
20
 
21
- !function(window, Function) {
22
- var initTime = xhr._t = +new Date()
23
- , rewrite = {
21
+ !function(window) {
22
+ var rewrite = {
24
23
  //!{loadRewrite}
25
24
  }
26
- // Move setTimeout from window.prototype to window object for future patching in IE9.
27
- , setTimeout_ = window.setTimeout = setTimeout
28
- /*** debug ***/
29
- // Expose xhr._c for testing.
30
- , loaded = xhr._c = {}
31
- /*/
32
- , loaded = {}
33
- /**/
34
-
35
- /*** activex ***/
36
- // XMLHttpRequest in IE7-8 do not accept PATCH, use ActiveX.
37
- // IE disallows adding custom properties to ActiveX objects and read/write readystatechange after send().
38
- , XMLHttpRequest = +"\v1" && window.XMLHttpRequest || Function("return new ActiveXObject('Microsoft.XMLHTTP')")
25
+ /*** log ***/
26
+ , initTime = xhr._t = +new Date()
39
27
  /**/
28
+ // Expose xhr._c for testing.
29
+ , loaded = /*** debug ***/ xhr._c = /**/ {}
40
30
 
31
+ /*** ie9 ***/
32
+ , Fn = Function
33
+ , nop = Fn()
41
34
  , execScript =
42
35
  // IE5-10, Chrome1-12
43
36
  window.execScript ||
44
- /*** inject ***/
45
37
  // THANKS: Juriy Zaytsev - Global eval [http://perfectionkills.com/global-eval-what-are-the-options/]
46
38
  // In case of local execution `e('eval')` returns undefined
47
- Function("e,eval", "try{return e('eval')}catch(e){}")(eval) ||
48
- Function("a", "var d=document,b=d.body,s=d.createElement('script');s.text=a;b.removeChild(b.insertBefore(s,b.firstChild))")
49
- /*/
50
- eval
51
- /**/
52
- , nop = Function()
39
+ Fn("e,eval", "try{return e('eval')}catch(e){}")(eval) ||
40
+ Fn("a", "var d=document,b=d.body,s=d.createElement('script');s.text=a;b.appendChild(s)")
41
+
42
+ // Move setTimeout from window.prototype to window object for future patching in IE9.
43
+ , setTimeout_ = window.setTimeout = setTimeout
53
44
 
54
- /*** reuse ***/
55
45
  // XHR memory leak mitigation
56
46
  , xhrs = []
47
+
48
+ // XMLHttpRequest in IE7-8 do not accept PATCH, use ActiveX.
49
+ // IE disallows adding custom properties to ActiveX objects and read/write readystatechange after send().
50
+ , XMLHttpRequest = +"\v1" && window.XMLHttpRequest || Fn("return new ActiveXObject('Microsoft.XMLHTTP')")
51
+ /*/
52
+ , execScript = eval
53
+ , setTimeout_ = setTimeout
57
54
  /**/
58
55
 
56
+ /*** log ***/
59
57
  , unsentLog = xhr._l = []
60
- /*** onerror ***/
61
58
  , lastError
59
+ // load.js is expected to be the first script to run and no prior window.onerror exists.
62
60
  , onerror = window.onerror = function(message, file, line, col, error) {
63
61
  // Do not send multiple copies of the same error.
64
62
  // file = document.currentScript.src || import.meta.url
@@ -68,26 +66,35 @@
68
66
  , col || (window.event || unsentLog).errorCharacter || "?"
69
67
  , message
70
68
  ].join(":")
71
- )) log("e", lastError, (error && (error.stack || error.stacktrace) || "-") + "\n" + location)
69
+ )) log("e", lastError, [error && (error.stack || error.stacktrace) || "-", "" + location])
70
+ }
71
+ , log = xhr.log = function(type, msg, extra) {
72
+ if (unsentLog.push([new Date() - initTime, type].concat(msg, extra || [])) < 2) sendLog()
73
+ function sendLog() {
74
+ setTimeout_(xhr.sendLog || sendLog, 1307)
75
+ }
72
76
  }
73
- /*/
74
- , onerror = nop
75
77
  /**/
76
78
 
77
- xhr.log = log
78
- function log(type, msg, extra) {
79
- if (unsentLog.push([ new Date() - initTime, type, msg, extra ]) < 2) sendLog()
80
- }
81
79
 
82
- function sendLog() {
83
- setTimeout_(xhr.sendLog || sendLog, 1307)
80
+ /*** theme ***/
81
+ , savedTheme
82
+ , ALT_THEME = "dark"
83
+ try {
84
+ savedTheme = window.localStorage.theme
85
+ } catch(e){}
86
+ if (ALT_THEME == (
87
+ savedTheme ||
88
+ (savedTheme = window.matchMedia) && savedTheme("(prefers-color-scheme:dark)").matches && ALT_THEME
89
+ )) {
90
+ document.documentElement.className = "is-" + ALT_THEME
84
91
  }
85
-
86
- // next === true is for sync call
92
+ /**/
87
93
 
88
94
  window.xhr = xhr
95
+ // next === true is for sync call
89
96
  function xhr(method, url, next, attr1, attr2) {
90
- var req = /*** reuse ***/ xhrs.pop() || /**/ new XMLHttpRequest()
97
+ var req = /*** ie9 ***/ xhrs.pop() || /**/ new XMLHttpRequest()
91
98
 
92
99
  // To be able to reuse the XHR object properly,
93
100
  // use the open method first and set onreadystatechange later.
@@ -160,9 +167,12 @@
160
167
  attr1,
161
168
  attr2
162
169
  )
170
+ /*** ie9 ***/
171
+ // ActiveXObject does not accept `null` for onreadystatechange
163
172
  req.onreadystatechange = next = nop
164
- /*** reuse ***/
165
173
  xhrs.push(req)
174
+ /*/
175
+ req.onreadystatechange = next = null
166
176
  /**/
167
177
  }
168
178
  }
@@ -193,7 +203,7 @@
193
203
 
194
204
  function cb(err, str, fileName, filePos) {
195
205
  loaded[fileName] = 2
196
- res[filePos] = err ? (onerror(err, fileName), "") : str
206
+ res[filePos] = err ? (/*** log ***/ onerror(err, fileName),/**/ "") : str
197
207
  exec()
198
208
  }
199
209
  function exec() {
@@ -205,20 +215,19 @@
205
215
  var execResult = (xhr[files[pos].replace(/[^?]+\.|\?.*/g, "")] || execScript)(res[pos], files[pos])
206
216
  if (execResult && execResult.then) {
207
217
  res[pos] = 0
208
- return execResult.then(function() {
209
- res[pos] = ""
210
- exec()
211
- })
218
+ return execResult.then(advanceExec, advanceExec)
212
219
  }
213
220
  } catch(e) {
221
+ /*** log ***/
214
222
  onerror(e, files[pos])
223
+ /**/
215
224
  }
216
225
  res[pos] = ""
217
226
  }
218
227
  }
219
228
  if (res[pos] === "" || !files[pos]) {
220
229
  if (++pos < len) exec()
221
- /*** inject ***/
230
+ /*** ie9 ***/
222
231
  // inject can be async
223
232
  else if (pos === len && execScript !== eval) setTimeout_(exec, 1)
224
233
  /**/
@@ -230,6 +239,11 @@
230
239
  }
231
240
  }
232
241
  }
242
+ function advanceExec(err) {
243
+ if (err) onerror(err, files[pos])
244
+ res[pos] = ""
245
+ exec()
246
+ }
233
247
  }
234
248
 
235
249
  load([
@@ -237,5 +251,4 @@
237
251
  ])
238
252
  /**/
239
253
 
240
- }(this, Function) // jshint ignore:line
241
-
254
+ }(this) // jshint ignore:line
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litejs/ui",
3
- "version": "25.5.0",
3
+ "version": "26.2.0",
4
4
  "description": "UI engine for LiteJS full-stack framework",
5
5
  "license": "MIT",
6
6
  "author": "Lauri Rooden <lauri@rooden.ee>",
@@ -24,9 +24,9 @@
24
24
  "lj-extract-lang": "./bin/extract-lang.js"
25
25
  },
26
26
  "scripts": {
27
- "test": "lj t"
27
+ "test": "lj t test/index.js"
28
28
  },
29
29
  "devDependencies": {
30
- "@litejs/cli": "25.5.0"
30
+ "@litejs/cli": "26.2.1"
31
31
  }
32
32
  }