@litejs/ui 24.0.0-rc.6 → 24.5.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
@@ -20,7 +20,7 @@ See [wiki][] for more information.
20
20
 
21
21
  ## Licence
22
22
 
23
- Copyright (c) 2006-2023 Lauri Rooden <lauri@rooden.ee>
23
+ Copyright (c) 2006-2024 Lauri Rooden <lauri@rooden.ee>
24
24
  [MIT License](https://litejs.com/MIT-LICENSE.txt) |
25
25
  [GitHub repo](https://github.com/litejs/ui) |
26
26
  [npm package](https://npmjs.org/package/@litejs/ui) |
@@ -3,22 +3,12 @@
3
3
 
4
4
 
5
5
 
6
- /* global El */
7
- !function(bindings, window) {
8
- bindings.persist = bindingPersist
9
-
10
- function bindingPersist(el, _key, surviveReboot) {
11
- var stor = (surviveReboot ? "local" : "session") + "Storage"
12
- , key = _key || el.id || el.name
13
- , value = window[stor].getItem(key)
14
-
15
- if (value) {
16
- El.val(el, value)
17
- }
18
- El.on(el, "keyup change blur", function() {
19
- window[stor].setItem(key, El.val(el))
20
- })
21
- }
22
- bindingPersist.once = bindingPersist
23
- }(El.bindings, window) // jshint ignore:line
6
+ /* global El, window */
7
+ El.$b.persist = function bindingPersist(el, key, surviveReboot) {
8
+ var stor = window[(surviveReboot ? "local" : "session") + "Storage"]
9
+ El.val(el, stor[key = key || el.id || el.name] || "")
10
+ El.on(el, "keyup change blur", function() {
11
+ stor[key] = El.val(el)
12
+ })
13
+ }
24
14
 
package/binding/sticky.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // .sticky { position: sticky; top: -1px; }
3
3
  // .sticky.is-stuck { color: red; }
4
4
 
5
- /* global El */
6
- El.bindings.sticky = function sticky(el) {
5
+ /* global El, IntersectionObserver */
6
+ El.$b.sticky = function sticky(el) {
7
7
  ;(sticky._ob || (sticky._ob = new IntersectionObserver(function(entries) {
8
8
  entries.forEach(function(entry) {
9
9
  El.cls(entry.target, "is-stuck", entry.intersectionRatio < 1)
@@ -12,6 +12,4 @@ El.bindings.sticky = function sticky(el) {
12
12
  El.cls(el, "sticky")
13
13
  }
14
14
 
15
- El.bindings.sticky.once = 1
16
-
17
15
 
package/binding/svg.js CHANGED
@@ -85,7 +85,7 @@
85
85
  bindings.svgToLast = function(el) {
86
86
  El.on(el, "mouseover", function() {
87
87
  if (!svgToLastActive || el != el.parentNode.lastChild) {
88
- El.cls(svgToLastActive, "line-active", 0)
88
+ El.cls(svgToLastActive, "is-active", 0)
89
89
  El.append(el.parentNode, el)
90
90
  El.cls(el, "is-active", svgToLastActive = el)
91
91
  }
@@ -93,5 +93,5 @@
93
93
  }
94
94
  bindings.svgToLast.once =
95
95
  bindings.initChart.once = 1
96
- }(this.SVGElement, document, El.bindings) // jshint ignore:line
96
+ }(this.SVGElement, document, El.$b) // jshint ignore:line
97
97
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  /* global El, window */
3
- El.bindings.topFloat = function(el, offset) {
3
+ El.$b.topFloat = function(el, offset) {
4
4
  var h = el.offsetHeight + offset
5
5
  , lastAbs = 0
6
6
  , lastTop = 0
@@ -32,6 +32,5 @@ El.bindings.topFloat = function(el, offset) {
32
32
  })
33
33
  }
34
34
 
35
- El.bindings.topFloat.once = 1
36
35
 
37
36
 
package/css/base.css CHANGED
@@ -35,6 +35,7 @@ html {
35
35
  touch-action: manipulation; /* 4 */
36
36
  -webkit-backface-visibility: hidden; /* 5 */
37
37
  backface-visibility: hidden;
38
+ text-rendering: optimizeLegibility;
38
39
  }
39
40
 
40
41
  html,
package/css/form.css CHANGED
@@ -87,13 +87,13 @@ option:disabled,
87
87
  textarea:disabled,
88
88
  select:disabled {
89
89
  opacity: .6;
90
- font-style: italic;
90
+ font-style: italic;
91
91
  box-shadow: none;
92
92
  cursor: not-allowed;
93
93
  }
94
94
  input[readonly] {
95
95
  opacity: .6;
96
- font-style: italic;
96
+ font-style: italic;
97
97
  }
98
98
 
99
99
  input.Toggle {
@@ -122,14 +122,14 @@ input.Toggle:after {
122
122
  top: -4px;
123
123
  transition: all .25s cubic-bezier(0, 0, .2, 1) 0s;
124
124
  box-shadow:
125
- 2px 2px 8px rgba(255, 255, 255, .3) inset,
126
- 0 1px 5px rgba(0, 0, 0, 1);
125
+ 2px 2px 8px rgba(255, 255, 255, .3) inset,
126
+ 0 1px 5px rgba(0, 0, 0, 1);
127
127
  }
128
128
  input.Toggle:focus:after {
129
129
  box-shadow:
130
- 2px 2px 8px rgba(255, 255, 255, .3) inset,
131
- 0 1px 5px rgba(0, 0, 0, 1),
132
- 0 0 0 12px rgb(255, 255, 255, .2);
130
+ 2px 2px 8px rgba(255, 255, 255, .3) inset,
131
+ 0 1px 5px rgba(0, 0, 0, 1),
132
+ 0 0 0 12px rgb(255, 255, 255, .2);
133
133
  }
134
134
  input.Toggle:checked:after {
135
135
  background-color: #00a651;
@@ -170,10 +170,10 @@ input.Toggle:checked:active:after {
170
170
 
171
171
  :focus {
172
172
  outline: 0;
173
- box-shadow: 0 0 6px -1px inset, 0 0 6px 1px;
173
+ box-shadow: 0 0 6px -1px inset, 0 0 6px 1px;
174
174
  }
175
175
  :focus:not(:focus-visible) {
176
- box-shadow: 0;
176
+ box-shadow: 0;
177
177
  }
178
178
 
179
179
  .btn:active,
@@ -181,7 +181,7 @@ button:active,
181
181
  select:active,
182
182
  textarea:active,
183
183
  input:active {
184
- box-shadow: 0 0 8px 1px inset, 0 0 8px 2px;
184
+ box-shadow: 0 0 8px 1px inset, 0 0 8px 2px;
185
185
  }
186
186
  input, textarea, select {
187
187
  background: #eee;
@@ -194,25 +194,25 @@ input[type=submit] {
194
194
  background: #aaa;
195
195
  }
196
196
  ::file-selector-button {
197
- box-shadow: 0 0 26px -5px inset;
197
+ box-shadow: 0 0 26px -5px inset;
198
198
  }
199
199
  :focus::file-selector-button {
200
200
  }
201
201
 
202
202
  input.Toggle:after {
203
- background-color: #666;
204
- box-shadow:
205
- 2px 2px 8px rgba(255, 255, 255, .3) inset,
206
- 0 1px 5px rgba(0, 0, 0, 1);
203
+ background-color: #666;
204
+ box-shadow:
205
+ 2px 2px 8px rgba(255, 255, 255, .3) inset,
206
+ 0 1px 5px rgba(0, 0, 0, 1);
207
207
  }
208
208
  input.Toggle:focus:after {
209
- box-shadow:
210
- 2px 2px 8px rgba(255, 255, 255, .3) inset,
211
- 0 1px 5px rgba(0, 0, 0, 1),
212
- 0 0 0 12px rgb(0, 0, 0, .2);
209
+ box-shadow:
210
+ 2px 2px 8px rgba(255, 255, 255, .3) inset,
211
+ 0 1px 5px rgba(0, 0, 0, 1),
212
+ 0 0 0 12px rgb(0, 0, 0, .2);
213
213
  }
214
214
  input.Toggle:checked:after {
215
- background-color: #00a651;
215
+ background-color: #00a651;
216
216
  }
217
217
  /**/
218
218
 
package/el/Slider.tpl CHANGED
@@ -14,12 +14,12 @@
14
14
  width: 4px;
15
15
  height: 100%;
16
16
  }
17
- .is-vertical > .Slider-track > .Slider-fill {
17
+ .is-vertical > * > .Slider-fill {
18
18
  top: auto;
19
19
  bottom: 0;
20
20
  width: 4px;
21
21
  }
22
- .is-vertical > .Slider-track > .Slider-fill > .Slider-knob {
22
+ .is-vertical > * > * > .Slider-knob {
23
23
  margin: -10px -8px 0 0;
24
24
  }
25
25
  .Slider-track {
@@ -31,10 +31,10 @@
31
31
  height: 4px;
32
32
  border-radius: 2px;
33
33
  overflow: visible;
34
- background: #666;
34
+ background: #999;
35
35
  }
36
36
  .Slider-fill {
37
- background: rgba(255,255,255,.57);
37
+ background: rgba(0,0,0,.5);
38
38
  }
39
39
  .Slider-knob,
40
40
  .Toggle-knob {
@@ -43,6 +43,7 @@
43
43
  height: 20px;
44
44
  border-radius: 50%;
45
45
  box-shadow:
46
+ 0 0 0 0 rgb(0, 0, 0, .2),
46
47
  0 1px 4px rgba(0, 0, 0, .2);
47
48
  }
48
49
  .Slider-knob {
@@ -52,9 +53,10 @@
52
53
  background: #f5f5f5;
53
54
  background-color: rgb(245, 245, 245);
54
55
  }
55
- .Slider-knob:hover,
56
- .Slider-knob:focus,
57
- :hover>.Toggle-knob {
56
+ :hover > * > * > .Slider-knob,
57
+ :focus > * > * > .Slider-knob,
58
+ :focus > .Toggle-knob,
59
+ :hover > .Toggle-knob {
58
60
  box-shadow:
59
61
  0 0 0 8px rgb(0, 0, 0, .2),
60
62
  0 1px 4px rgba(0, 0, 0, .3);
@@ -64,6 +66,7 @@
64
66
  0 0 0 12px rgb(0, 0, 0, .2),
65
67
  0 1px 5px 5px rgba(0, 0, 0, .3);
66
68
  }
69
+ /* value bubble */
67
70
  .Slider-knob.is-active:before,
68
71
  .Slider-knob.is-active:after {
69
72
  position: absolute;
@@ -144,8 +147,8 @@
144
147
  %js
145
148
  var on = El.on
146
149
  , off = El.off
147
- El.bindings.SliderInit = function(el) {
148
- var knobLen, offset, px, drag, min, max, step, minPx, maxPx, value
150
+ El.$b.SliderInit = function(el) {
151
+ var attr, range, knobLen, offset, px, drag, min, max, step, minPx, maxPx, value
149
152
  , vert = El.hasClass(el, "is-vertical")
150
153
  , track = el.firstChild
151
154
  , fill = track.firstChild
@@ -156,8 +159,8 @@
156
159
  el.val = set
157
160
  setTimeout(function() { set(value||0) }, 10)
158
161
  function load() {
159
- var attr = vert ? "offsetHeight" : "offsetWidth"
160
- , range = (El.attr(el, "range") || "").split(/[^+\-\d.]/) // min:max:step:margin
162
+ attr = vert ? "offsetHeight" : "offsetWidth"
163
+ range = (El.get(el, "range") || "").split(/[^+\-\d.]/) // min:max:step:margin
161
164
  min = +(range[0] || 0)
162
165
  max = +(range[1] || 100)
163
166
  step = +(range[2] || 1)
@@ -227,21 +230,20 @@
227
230
  if (value !== val) {
228
231
  el.value = value = val
229
232
  if (drag && e) emit(e)
230
- var format = El.attr(el, "format")
231
- El.attr(knob, "data-val", format ? _(format, {val:val}) : val)
233
+ var format = El.get(el, "format")
234
+ El.set(knob, "data-val", format ? _(format, {val:val}) : val)
232
235
  }
233
236
  }
234
237
  }
235
- El.bindings.SliderInit.once = 1
236
238
 
237
239
  %el Slider
238
- button.Slider.reset ;SliderInit
240
+ button.Slider.reset ;SliderInit!
239
241
  .Slider-track
240
242
  .Slider-fill.abs.anim
241
243
  .Slider-knob.anim[tabindex=0]
242
244
 
243
245
  /%el Slider2
244
- / button.Slider.reset ;SliderInit
246
+ / button.Slider.reset ;SliderInit!
245
247
  / .Slider-track
246
248
  / .Slider-fill.abs.anim
247
249
  / .Slider-knob.anim[tabindex=0]
@@ -249,7 +251,7 @@
249
251
  / .Slider-knob.anim[tabindex=0]
250
252
  /
251
253
  /%el Slider3
252
- / button.Slider.reset ;SliderInit
254
+ / button.Slider.reset ;SliderInit!
253
255
  / .Slider-track
254
256
  / .Slider-fill.abs.anim
255
257
  / .Slider-knob.anim[tabindex=0]
package/el/dialog.ui CHANGED
@@ -68,7 +68,7 @@
68
68
  var sound, vibrate
69
69
  , code = ""
70
70
  , el = El("Modal")
71
- , scope = Object.assign(El.scope(el, El.data), opts)
71
+ , scope = Object.assign(El.scope(el, el), opts)
72
72
  , kbMap = {}
73
73
  , body = document.body
74
74
  , blurEl = $(scope.blur) || $ui.root.lastChild
@@ -112,7 +112,7 @@
112
112
  }
113
113
  function resolve(e, key) {
114
114
  if (el) {
115
- var action = key || El.attr(this, "data-action")
115
+ var action = key || El.get(this, "data-action")
116
116
  , result = {
117
117
  code: code,
118
118
  input: El.val($(".js-input", el)),
@@ -156,7 +156,7 @@
156
156
  ;txt!_(action.title)
157
157
  ;class!"w" + (12/actions.length)
158
158
  ;nop: this.focus()
159
- ;attr: "data-action", action.action
159
+ ;set: "data-action", action.action
160
160
  ;class!"is-" + action.action, action.action
161
161
 
162
162
  %el Modal
@@ -167,7 +167,7 @@
167
167
  ;if: input
168
168
  .col>input.field.js-input
169
169
  .row
170
- ;if: data.inputMd!=null
170
+ ;if: $d.inputMd!=null
171
171
  .col
172
172
  textarea.field.js-inputMd
173
173
  @keyup [this.parentNode.nextSibling.nextSibling], "renderMd"
package/el/form.ui CHANGED
@@ -206,7 +206,7 @@ Form-ro
206
206
 
207
207
  %el Form-enum
208
208
  Form-row
209
- select.field ;each:val in data["enum"]
209
+ select.field ;each:val in $d["enum"]
210
210
  option
211
211
  ;val:: val
212
212
  = _("" + val)
@@ -217,7 +217,7 @@ Form-ro
217
217
  %el Form-list
218
218
  Form-row
219
219
  select.field
220
- ;list: api(resourceCollection.format(data.params, data)), required ? 0 : [""], value
220
+ ;list: api(resourceCollection.format(params, $d)), required ? 0 : [""], value
221
221
  option
222
222
  ;val:: item.id
223
223
  ;txt:: _(item.name)
@@ -235,16 +235,16 @@ Form-row>span
235
235
  = _(description)
236
236
  .js-items.cf
237
237
  a.btn.right
238
- ;if: !data.noAdd
239
- ;txt: _(data.name + ".Add")
240
- @click: data.add
238
+ ;if: !$d.noAdd
239
+ ;txt: _($d.name + ".Add")
240
+ @click: $d.add
241
241
 
242
242
  %el Form-array-item
243
243
  .input.p3.m2b.cf.js-del
244
244
  a.right.Form-del.hand ×
245
- ;if: !data.noAdd
246
- ;attr:: "data-tooltip", _("Delete")
247
- @click: data.del
245
+ ;if !$d.noAdd
246
+ ;set "data-tooltip", _("Delete")
247
+ @click $d.del
248
248
  b
249
249
  ;if: title
250
250
  ;txt: title
package/el/material.tpl CHANGED
@@ -248,7 +248,7 @@
248
248
  function onOver(e) {
249
249
  var x, y, pos
250
250
  , target = e.target
251
- , text = El.attr(target, "data-tooltip")
251
+ , text = El.get(target, "data-tooltip")
252
252
  , relTarg = e.relatedTarget || e.fromElement
253
253
  // without relTarg is event on click
254
254
  if (!relTarg && e.type !== "focusin" || target === tipTarget) return
@@ -260,19 +260,19 @@
260
260
  closeTooltip()
261
261
  if (!text) return
262
262
  tipEl = openVisible("pre.tooltip", tipTarget = target)
263
- pos = El.attr(target, "data-tooltip-pos") || "top"
263
+ pos = El.get(target, "data-tooltip-pos") || "top"
264
264
  El.txt(tipEl, text)
265
265
  if (pos === "left" || pos === "right") {
266
266
  x = pos
267
267
  } else {
268
268
  y = pos
269
269
  }
270
- El.attr(tipEl, "data-pos", pos)
270
+ El.set(tipEl, "data-pos", pos)
271
271
  near(tipEl, target, x, y, 6)
272
272
  }
273
273
  function openVisible(tag, target) {
274
274
  var el = typeof tag == "string" ? El(tag) : tag
275
- , scope = El.scope(el, El.scope(target))
275
+ , scope = El.scope(el, target)
276
276
  scope.openTarget = target
277
277
  El.render(el)
278
278
  El.append(document.body, el)
@@ -313,7 +313,7 @@
313
313
  })
314
314
  } else {
315
315
  El.cls(menuTarget = target, "is-active")
316
- near(menuEl, target, x, y, 4)
316
+ near(menuEl, target, x, y, margin)
317
317
  }
318
318
  if (menuEl.style.transform !== void 0) {
319
319
  El.cls(menuEl, "no-events")