@kizmann/nano-ui 1.0.14 → 1.1.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.
Files changed (73) hide show
  1. package/dist/nano-ui.css +1 -1
  2. package/dist/nano-ui.js +1 -1
  3. package/dist/nano-ui.js.map +1 -1
  4. package/dist/themes/dark.css +1 -1
  5. package/dist/themes/glossy.dark.css +1 -0
  6. package/dist/themes/glossy.light.css +1 -0
  7. package/dist/themes/light.css +1 -1
  8. package/package.json +1 -1
  9. package/src/button/src/button/button.jsx +12 -0
  10. package/src/button/src/button/button.scss +4 -1
  11. package/src/collapse/src/collapse-item/collapse-item.jsx +1 -1
  12. package/src/draggable/src/draglist/draglist.jsx +1 -1
  13. package/src/draggable/src/draglist-item/draglist-item.jsx +5 -2
  14. package/src/drawer/src/drawer/drawer.jsx +9 -3
  15. package/src/form/src/form/form.jsx +9 -4
  16. package/src/form/src/form-frame/form-frame.jsx +53 -21
  17. package/src/form/src/form-frame/form-frame.scss +7 -0
  18. package/src/form/src/form-group/form-group.jsx +31 -11
  19. package/src/form/src/form-item/form-item.jsx +9 -5
  20. package/src/info/src/info/info.jsx +1 -1
  21. package/src/modal/src/modal/modal.jsx +1 -1
  22. package/src/modal/src/modal/modal.scss +2 -2
  23. package/src/paginator/src/paginator/paginator.jsx +24 -29
  24. package/src/preview/index.js +2 -0
  25. package/src/preview/index.scss +1 -0
  26. package/src/preview/src/_tools/preview-handler.js +193 -0
  27. package/src/preview/src/_tools/preview-helper.js +142 -0
  28. package/src/preview/src/preview/preview.jsx +48 -115
  29. package/src/preview/src/preview/preview.scss +2 -1
  30. package/src/preview/src/preview-modal/preview-modal.jsx +156 -0
  31. package/src/preview/src/preview-modal/preview-modal.scss +56 -0
  32. package/src/preview/src/preview-video/preview-video.jsx +4 -60
  33. package/src/resizer/index.js +3 -1
  34. package/src/resizer/src/resizer/resizer-next.jsx +536 -0
  35. package/src/resizer/src/resizer/resizer.jsx +17 -11
  36. package/src/scrollbar/index.js +3 -1
  37. package/src/scrollbar/index.scss +1 -0
  38. package/src/scrollbar/src/scrollbar/scrollbar.scss +14 -8
  39. package/src/scrollbar/src/scrollbar-next/scrollbar-next.jsx +640 -0
  40. package/src/scrollbar/src/scrollbar-next/scrollbar-next.scss +148 -0
  41. package/src/select/src/select/select.jsx +12 -16
  42. package/src/select/src/select/select.scss +1 -1
  43. package/src/table/src/table/table.jsx +4 -7
  44. package/src/table/src/table/table.scss +15 -14
  45. package/src/table/src/table-cell/types/table-cell-image.jsx +9 -3
  46. package/src/table/src/table-column/table-column.jsx +11 -27
  47. package/src/table/src/table-filter/types/table-filter-datetime.jsx +1 -1
  48. package/src/tabs/src/tabs-item/tabs-item.jsx +1 -1
  49. package/src/tags/src/tags-item/tags-item.jsx +1 -2
  50. package/src/timepicker/src/timepicker-panel/timepicker-panel.jsx +15 -3
  51. package/src/timepicker/src/timepicker-panel/timepicker-panel.scss +2 -1
  52. package/src/virtualscroller/src/virtualscroller/virtualscroller.jsx +63 -30
  53. package/src/virtualscroller/src/virtualscroller/virtualscroller.scss +1 -0
  54. package/themes/glossy/button/index.scss +2 -0
  55. package/themes/glossy/button/src/button/button.scss +116 -0
  56. package/themes/glossy/button/src/button-group/button-group.scss +1 -0
  57. package/themes/glossy/index-dark.scss +3 -0
  58. package/themes/glossy/index-light.scss +3 -0
  59. package/themes/glossy/index.scss +43 -0
  60. package/themes/glossy/root/image/empty-default.svg +30 -0
  61. package/themes/glossy/root/image/empty-space.svg +34 -0
  62. package/themes/glossy/root/image/star-default.svg +10 -0
  63. package/themes/glossy/root/image/test.svg +1 -0
  64. package/themes/glossy/root/vars-dark.scss +234 -0
  65. package/themes/glossy/root/vars-light.scss +234 -0
  66. package/themes/glossy/root/vars.scss +233 -0
  67. package/themes/macos/button/src/button/button.scss +46 -8
  68. package/themes/macos/form/src/form-frame/form-frame.scss +2 -2
  69. package/themes/macos/index.scss +1 -0
  70. package/themes/macos/preview/index.scss +1 -0
  71. package/themes/macos/preview/src/preview-modal/preview-modal.scss +28 -0
  72. package/themes/macos/scrollbar/src/scrollbar/scrollbar.scss +1 -0
  73. package/themes/macos/table/src/table/table.scss +5 -0
@@ -0,0 +1,640 @@
1
+ import { Arr, Obj, Dom, Any, Str, Event, UUID } from "@kizmann/pico-js";
2
+
3
+ export default {
4
+
5
+ name: 'NScrollbar',
6
+
7
+ provide()
8
+ {
9
+ return {
10
+ NScrollbar: this
11
+ };
12
+ },
13
+
14
+ props: {
15
+
16
+ options: {
17
+ default()
18
+ {
19
+ return {};
20
+ },
21
+ type: [Object]
22
+ },
23
+
24
+ relative: {
25
+ default()
26
+ {
27
+ return false;
28
+ },
29
+ type: [Boolean]
30
+ },
31
+
32
+ fixture: {
33
+ default()
34
+ {
35
+ return false;
36
+ },
37
+ type: [Boolean]
38
+ },
39
+
40
+ allowNative: {
41
+ default()
42
+ {
43
+ return false;
44
+ },
45
+ type: [Boolean]
46
+ },
47
+
48
+ overflowY: {
49
+ default()
50
+ {
51
+ return true;
52
+ },
53
+ type: [Boolean]
54
+ },
55
+
56
+ overflowX: {
57
+ default()
58
+ {
59
+ return true;
60
+ },
61
+ type: [Boolean]
62
+ },
63
+
64
+ offsetY: {
65
+ default()
66
+ {
67
+ return 10;
68
+ },
69
+ type: [Number]
70
+ },
71
+
72
+ offsetX: {
73
+ default()
74
+ {
75
+ return 10;
76
+ },
77
+ type: [Number]
78
+ },
79
+
80
+ framerate: {
81
+ default()
82
+ {
83
+ return 24;
84
+ },
85
+ type: [Number]
86
+ },
87
+
88
+ wrapClass: {
89
+ default()
90
+ {
91
+ return 'n-scrollbar__wrap';
92
+ }
93
+ }
94
+
95
+ },
96
+
97
+ computed: {
98
+
99
+ touch()
100
+ {
101
+ return !!('ontouchstart' in window ||
102
+ navigator.msMaxTouchPoints);
103
+ },
104
+
105
+ mousedown()
106
+ {
107
+ return this.touch ? 'touchstart' :
108
+ 'mousedown';
109
+ },
110
+
111
+ mousemove()
112
+ {
113
+ return this.touch ? 'touchmove' :
114
+ 'mousemove';
115
+ },
116
+
117
+ mouseup()
118
+ {
119
+ return this.touch ? 'touchend' :
120
+ 'mouseup';
121
+ }
122
+
123
+ },
124
+
125
+ data()
126
+ {
127
+ return {
128
+ uid: UUID(), init: false, native: false, height: 0, width: 0
129
+ };
130
+ },
131
+
132
+ beforeMount()
133
+ {
134
+ this.adaptScrollBehavior();
135
+ },
136
+
137
+ mounted()
138
+ {
139
+ this.observer = new ResizeObserver(() => {
140
+ this.getWrapperSizeDebounced();
141
+ });
142
+
143
+ this.observer.observe(this.$el);
144
+
145
+ if ( this.$refs.wrapper ) {
146
+ this.observer.observe(this.$refs.wrapper);
147
+ }
148
+
149
+ Event.bind('NScrollbar:resize',
150
+ this.onResize, this._.uid);
151
+
152
+ Event.bind('NResizer:moved',
153
+ this.getWrapperSizeDebounced, this._.uid);
154
+
155
+ let passive = {
156
+ passive: true, uid: this._.uid
157
+ };
158
+
159
+ Dom.find(this.$refs.content).on('scroll',
160
+ this.onScroll, passive);
161
+ },
162
+
163
+
164
+ beforeUnmount()
165
+ {
166
+ this.observer.disconnect();
167
+
168
+ Event.unbind('NScrollbar:resize',
169
+ this._.uid);
170
+
171
+ Event.unbind('NResizer:moved',
172
+ this._.uid);
173
+
174
+ let passive = {
175
+ passive: true, uid: this._.uid
176
+ };
177
+
178
+ Dom.find(this.$el).off('scroll',
179
+ null, passive);
180
+ },
181
+
182
+ methods: {
183
+
184
+ getWrapperSizeDebounced()
185
+ {
186
+ let now = this.$refs.wrapper.getBoundingClientRect();
187
+
188
+ if ( Any.isEqual(this.last || {}, now) ) {
189
+ return;
190
+ }
191
+
192
+ this.last = now;
193
+
194
+ clearInterval(this.interval);
195
+
196
+ this.interval = setTimeout(() => {
197
+ this.getWrapperSize();
198
+ }, 5);
199
+ },
200
+
201
+ getWrapperSize()
202
+ {
203
+ let [width, height] = [0, 0];
204
+
205
+ Dom.find(this.$refs.spacer).actual(() => {
206
+ [width, height] = [
207
+ Math.round(this.$refs.wrapper.getBoundingClientRect().width),
208
+ Math.round(this.$refs.wrapper.getBoundingClientRect().height)
209
+ ];
210
+ });
211
+
212
+ if ( width === this.width && height === this.height ) {
213
+ return;
214
+ }
215
+
216
+ [this.width, this.height] = [
217
+ width, height
218
+ ];
219
+
220
+ if ( width === 0 || height === 0 ) {
221
+ return;
222
+ }
223
+
224
+ let styles = {
225
+ //
226
+ };
227
+
228
+ if ( this.width ) {
229
+ styles.width = this.width + 'px';
230
+ }
231
+
232
+ if ( this.height ) {
233
+ styles.height = this.height + 'px';
234
+ }
235
+
236
+ Dom.find(this.$refs.spacer).css(styles);
237
+
238
+ this.adaptScrollHeight();
239
+ this.adaptScrollWidth();
240
+
241
+ let [frameWidth, frameHeight] = [
242
+ Dom.find(this.$el).width(), Dom.find(this.$el).height()
243
+ ];
244
+
245
+ this.$emit('sizechange', frameWidth, frameHeight, this.$el);
246
+ },
247
+
248
+ scrollTo(x = 0, y = 0, delay = 0)
249
+ {
250
+ if ( Any.isEmpty(delay) ) {
251
+ return this.scrollTo(x, y);
252
+ }
253
+
254
+ Any.delay(() => this.onScrollTo(x, y), delay);
255
+ },
256
+
257
+ onScrollTo(x = 0, y = 0)
258
+ {
259
+ this.$refs.content.scrollTop = y;
260
+ this.$refs.content.scrollLeft = x;
261
+
262
+ // if ( this.$refs.content.scrollTop != y || this.$refs.content.scrollLeft != x ) {
263
+ // setTimeout(() => this.onScrollTo(x, y), 5);
264
+ // }
265
+ },
266
+
267
+ scrollIntoView(selector, delay = 0, padding = 0)
268
+ {
269
+ Any.delay(() => this.onScrollIntoView(selector, padding), delay);
270
+ },
271
+
272
+ onScrollIntoView(selector, padding = 0)
273
+ {
274
+ let $el = Dom.find(this.$el).find(selector);
275
+
276
+ let scrollTop = this.$refs.content
277
+ .scrollTop;
278
+
279
+ let outerHeight = this.$refs.content.clientHeight;
280
+
281
+ let offsetTop = $el.offsetTop(this.$el);
282
+
283
+ if ( offsetTop < scrollTop ) {
284
+ this.$refs.content.scrollTop = offsetTop - padding;
285
+ }
286
+
287
+ if ( offsetTop + $el.height() >= scrollTop + outerHeight ) {
288
+ this.$refs.content.scrollTop = offsetTop - outerHeight + $el.height() + padding;
289
+ }
290
+
291
+ let scrollLeft = this.$refs.content
292
+ .scrollLeft;
293
+
294
+ let outerWidth = this.$refs.content.clientWidth;
295
+
296
+ let offsetLeft = $el.offsetLeft(this.$el);
297
+
298
+ if ( offsetLeft < scrollLeft ) {
299
+ this.$refs.content.scrollLeft = offsetLeft - padding;
300
+ }
301
+
302
+ if ( offsetLeft + $el.width() >= scrollLeft + outerWidth ) {
303
+ this.$refs.content.scrollLeft = offsetLeft - outerWidth + $el.width() + padding;
304
+ }
305
+ },
306
+
307
+ adaptScrollBehavior()
308
+ {
309
+ let $dom = Dom.make('div', { classList: ['n-scrollbar-test'] })
310
+ .appendTo(document.body).get(0);
311
+
312
+ Dom.make('div').appendTo($dom);
313
+
314
+ this.native = $dom.clientWidth === $dom.offsetWidth ||
315
+ $dom.clientHeight === $dom.offsetHeight;
316
+
317
+ $dom.remove();
318
+ },
319
+
320
+ adaptScrollHeight()
321
+ {
322
+ if ( this.native && this.allowNative ) {
323
+ return;
324
+ }
325
+
326
+ let [innerHeight, outerHeight] = [
327
+ this.height || 0, this.$el.clientHeight || 0
328
+ ];
329
+
330
+ let compare = [
331
+ outerHeight === this.outerHeight,
332
+ innerHeight === this.innerHeight
333
+ ];
334
+
335
+ if ( !Arr.has(compare, false) ) {
336
+ return;
337
+ }
338
+
339
+ this.outerHeight = outerHeight;
340
+ this.innerHeight = innerHeight;
341
+
342
+ let height = (outerHeight / innerHeight)
343
+ * outerHeight;
344
+
345
+ let barHeight = Math.max(height, 50);
346
+
347
+ let maxHeight = Math.ceil((outerHeight / innerHeight) *
348
+ (innerHeight - outerHeight));
349
+
350
+ this.heightRatio = (maxHeight - (barHeight - height)
351
+ - this.offsetY) / maxHeight;
352
+
353
+ Dom.find(this.$refs.vbar).css({
354
+ height: (this.barHeight = Math.ceil(barHeight)) + 'px'
355
+ });
356
+
357
+ let hasVtrack = outerHeight && outerHeight < innerHeight;
358
+
359
+ if ( hasVtrack ) {
360
+ Dom.find(this.$el).addClass('has-vtrack');
361
+ }
362
+
363
+ if ( !hasVtrack ) {
364
+ Dom.find(this.$el).removeClass('has-vtrack');
365
+ }
366
+
367
+ this.adaptScrollPosition();
368
+ },
369
+
370
+ adaptScrollWidth()
371
+ {
372
+ if ( this.native && this.allowNative ) {
373
+ return;
374
+ }
375
+
376
+ let [innerWidth, outerWidth] = [
377
+ this.width || 0, this.$el.clientWidth || 0
378
+ ];
379
+
380
+ let compare = [
381
+ outerWidth === this.outerWidth,
382
+ innerWidth === this.innerWidth
383
+ ];
384
+
385
+ if ( !Arr.has(compare, false) ) {
386
+ return;
387
+ }
388
+
389
+ this.outerWidth = outerWidth;
390
+ this.innerWidth = innerWidth;
391
+
392
+ let width = (outerWidth / innerWidth)
393
+ * outerWidth;
394
+
395
+ let barWidth = Math.max(width, 50);
396
+
397
+ let maxWidth = Math.ceil((outerWidth / innerWidth) *
398
+ (innerWidth - outerWidth));
399
+
400
+ this.widthRatio = (maxWidth - (barWidth - width)
401
+ - this.offsetX) / maxWidth;
402
+
403
+ Dom.find(this.$refs.hbar).css({
404
+ width: (this.barWidth = Math.ceil(barWidth)) + 'px'
405
+ });
406
+
407
+ let hasHtrack = outerWidth && outerWidth < innerWidth;
408
+
409
+ if ( hasHtrack ) {
410
+ Dom.find(this.$el).addClass('has-htrack');
411
+ }
412
+
413
+ if ( !hasHtrack ) {
414
+ Dom.find(this.$el).removeClass('has-htrack');
415
+ }
416
+
417
+ this.adaptScrollPosition();
418
+ },
419
+
420
+ adaptScrollPosition(scroll = {})
421
+ {
422
+ if ( this.native && this.allowNative ) {
423
+ return;
424
+ }
425
+
426
+ if ( !scroll.top ) {
427
+ scroll.top = this.$refs.content.scrollTop;
428
+ }
429
+
430
+ if ( !scroll.left ) {
431
+ scroll.left = this.$refs.content.scrollLeft;
432
+ }
433
+
434
+ let vbarTop = Math.ceil((this.outerHeight / this.innerHeight) *
435
+ scroll.top * this.heightRatio) || 0;
436
+
437
+ if ( !this.vbarTop || vbarTop !== this.vbarTop ) {
438
+
439
+ Dom.find(this.$refs.vbar).css({
440
+ transform: `translateY(${vbarTop}px) translateZ(0)`
441
+ });
442
+
443
+ this.vbarTop = vbarTop;
444
+ }
445
+
446
+ let hbarLeft = Math.ceil((this.outerWidth / this.innerWidth) *
447
+ scroll.left * this.widthRatio) || 0;
448
+
449
+ if ( !this.hbarLeft || hbarLeft !== this.hbarLeft ) {
450
+
451
+ Dom.find(this.$refs.hbar).css({
452
+ transform: `translateX(${hbarLeft}px) translateZ(0)`
453
+ });
454
+
455
+ this.hbarLeft = hbarLeft;
456
+ }
457
+ },
458
+
459
+ onScroll()
460
+ {
461
+ let scroll = {
462
+ top: this.$refs.content.scrollTop,
463
+ left: this.$refs.content.scrollLeft
464
+ };
465
+
466
+ this.$nextTick().then(() => {
467
+ this.$emit('scrollupdate', scroll.top, scroll.left);
468
+ });
469
+
470
+ this.adaptScrollPosition(scroll);
471
+ },
472
+
473
+ getTouchEvent(event)
474
+ {
475
+ if ( !this.touch ) {
476
+ return event;
477
+ }
478
+
479
+ return event.touches[0] || event.changedTouches[0];
480
+ },
481
+
482
+ onVbarMousedown(event)
483
+ {
484
+ if ( !Arr.has([0, 1], event.which) ) {
485
+ return;
486
+ }
487
+
488
+ event.stopPropagation();
489
+
490
+ Dom.find(document).on(this.mousemove,
491
+ this.onVbarMousemove, this._.uid);
492
+
493
+ Dom.find(document).on(this.mouseup,
494
+ this.onVbarMouseup, this._.uid);
495
+
496
+ this.scrollTop = this.$refs.content
497
+ .scrollTop;
498
+
499
+ this.clientY = this.getTouchEvent(event)
500
+ .clientY;
501
+
502
+ Dom.find(this.$refs.vbar).addClass('is-active');
503
+ },
504
+
505
+ onVbarMousemove(event)
506
+ {
507
+ let clientY = this.getTouchEvent(event)
508
+ .clientY;
509
+
510
+ let top = (this.outerHeight / this.innerHeight) *
511
+ this.scrollTop * this.heightRatio;
512
+
513
+ let offset = (clientY - this.clientY) + top;
514
+
515
+ let height = (this.outerHeight -
516
+ this.barHeight - this.offsetY);
517
+
518
+ this.$refs.content.scrollTop = offset / height *
519
+ (this.innerHeight - this.outerHeight);
520
+ },
521
+
522
+ onVbarMouseup(event)
523
+ {
524
+ Dom.find(document).off(this.mousemove,
525
+ null, this._.uid);
526
+
527
+ Dom.find(document).off(this.mouseup,
528
+ null, this._.uid);
529
+
530
+ Dom.find(this.$refs.vbar).removeClass('is-active');
531
+ },
532
+
533
+ onHbarMousedown(event)
534
+ {
535
+ if ( !Arr.has([0, 1], event.which) ) {
536
+ return;
537
+ }
538
+
539
+ event.stopPropagation();
540
+
541
+ Dom.find(document).on(this.mousemove,
542
+ this.onHbarMousemove, this._.uid);
543
+
544
+ Dom.find(document).on(this.mouseup,
545
+ this.onHbarMouseup, this._.uid);
546
+
547
+ this.scrollLeft = this.$refs.content
548
+ .scrollLeft;
549
+
550
+ this.clientX = this.getTouchEvent(event)
551
+ .clientX;
552
+
553
+ Dom.find(this.$refs.hbar).addClass('is-active');
554
+ },
555
+
556
+ onHbarMousemove(event)
557
+ {
558
+ let clientX = this.getTouchEvent(event)
559
+ .clientX;
560
+
561
+ let left = (this.outerWidth / this.innerWidth) *
562
+ this.scrollLeft * this.widthRatio;
563
+
564
+ let offset = (clientX - this.clientX) + left;
565
+
566
+ let width = (this.outerWidth -
567
+ this.barWidth - this.offsetX);
568
+
569
+ this.$refs.content.scrollLeft = offset / width *
570
+ (this.innerWidth - this.outerWidth);
571
+ },
572
+
573
+ onHbarMouseup(event)
574
+ {
575
+ Dom.find(document).off(this.mousemove,
576
+ null, this._.uid);
577
+
578
+ Dom.find(document).off(this.mouseup,
579
+ null, this._.uid);
580
+
581
+ Dom.find(this.$refs.hbar).removeClass('is-active');
582
+ },
583
+
584
+ },
585
+
586
+ render()
587
+ {
588
+ let classList = [
589
+ 'n-scrollbar'
590
+ ];
591
+
592
+ if ( this.native ) {
593
+ classList.push('n-scrollbar--native');
594
+ }
595
+
596
+ if ( !this.allowNative ) {
597
+ classList.push('n-scrollbar--forced');
598
+ }
599
+
600
+ if ( this.touch ) {
601
+ classList.push('n-scrollbar--touch');
602
+ }
603
+
604
+ if ( window.WIN ) {
605
+ classList.push('n-windows');
606
+ }
607
+
608
+ if ( this.overflowY ) {
609
+ classList.push('n-overflow-y');
610
+ }
611
+
612
+ if ( this.overflowX ) {
613
+ classList.push('n-overflow-x');
614
+ }
615
+
616
+ let vbarProps = {
617
+ ['on' + Str.ucfirst(this.mousedown)]: this.onVbarMousedown
618
+ };
619
+
620
+ let hbarProps = {
621
+ ['on' + Str.ucfirst(this.mousedown)]: this.onHbarMousedown
622
+ };
623
+
624
+ return (
625
+ <div class={classList} {...Obj.except(this.$attrs, ['class'])}>
626
+ <div class="n-scrollbar-content" ref="content">
627
+ <div ref="wrapper" class={this.wrapClass}>
628
+ {this.$slots.default && this.$slots.default()}
629
+ </div>
630
+ </div>
631
+ <div class="n-scrollbar-spacer" ref="spacer">
632
+ { /* Adapt inner height */}
633
+ </div>
634
+ <div ref="hbar" class="n-scrollbar-h" {...hbarProps}></div>
635
+ <div ref="vbar" class="n-scrollbar-v" {...vbarProps}></div>
636
+ </div>
637
+ );
638
+ }
639
+
640
+ }