@kizmann/nano-ui 1.0.15 → 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 (62) 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.scss +4 -1
  10. package/src/collapse/src/collapse-item/collapse-item.jsx +1 -1
  11. package/src/draggable/src/draglist/draglist.jsx +1 -1
  12. package/src/draggable/src/draglist-item/draglist-item.jsx +5 -2
  13. package/src/info/src/info/info.jsx +1 -1
  14. package/src/modal/src/modal/modal.jsx +1 -1
  15. package/src/modal/src/modal/modal.scss +2 -2
  16. package/src/paginator/src/paginator/paginator.jsx +24 -29
  17. package/src/preview/index.js +2 -0
  18. package/src/preview/index.scss +1 -0
  19. package/src/preview/src/_tools/preview-handler.js +193 -0
  20. package/src/preview/src/_tools/preview-helper.js +142 -0
  21. package/src/preview/src/preview/preview.jsx +48 -115
  22. package/src/preview/src/preview/preview.scss +2 -1
  23. package/src/preview/src/preview-modal/preview-modal.jsx +156 -0
  24. package/src/preview/src/preview-modal/preview-modal.scss +56 -0
  25. package/src/preview/src/preview-video/preview-video.jsx +4 -60
  26. package/src/resizer/index.js +3 -1
  27. package/src/resizer/src/resizer/resizer-next.jsx +536 -0
  28. package/src/scrollbar/index.js +3 -1
  29. package/src/scrollbar/index.scss +1 -0
  30. package/src/scrollbar/src/scrollbar/scrollbar.scss +14 -8
  31. package/src/scrollbar/src/scrollbar-next/scrollbar-next.jsx +640 -0
  32. package/src/scrollbar/src/scrollbar-next/scrollbar-next.scss +148 -0
  33. package/src/select/src/select/select.jsx +12 -16
  34. package/src/select/src/select/select.scss +1 -1
  35. package/src/table/src/table/table.jsx +4 -7
  36. package/src/table/src/table/table.scss +15 -14
  37. package/src/table/src/table-cell/types/table-cell-image.jsx +9 -3
  38. package/src/table/src/table-column/table-column.jsx +10 -26
  39. package/src/tabs/src/tabs-item/tabs-item.jsx +1 -1
  40. package/src/tags/src/tags-item/tags-item.jsx +1 -2
  41. package/src/timepicker/src/timepicker-panel/timepicker-panel.jsx +15 -3
  42. package/src/timepicker/src/timepicker-panel/timepicker-panel.scss +2 -1
  43. package/src/virtualscroller/src/virtualscroller/virtualscroller.jsx +63 -30
  44. package/src/virtualscroller/src/virtualscroller/virtualscroller.scss +1 -0
  45. package/themes/glossy/button/index.scss +2 -0
  46. package/themes/glossy/button/src/button/button.scss +116 -0
  47. package/themes/glossy/button/src/button-group/button-group.scss +1 -0
  48. package/themes/glossy/index-dark.scss +3 -0
  49. package/themes/glossy/index-light.scss +3 -0
  50. package/themes/glossy/index.scss +43 -0
  51. package/themes/glossy/root/image/empty-default.svg +30 -0
  52. package/themes/glossy/root/image/empty-space.svg +34 -0
  53. package/themes/glossy/root/image/star-default.svg +10 -0
  54. package/themes/glossy/root/image/test.svg +1 -0
  55. package/themes/glossy/root/vars-dark.scss +234 -0
  56. package/themes/glossy/root/vars-light.scss +234 -0
  57. package/themes/glossy/root/vars.scss +233 -0
  58. package/themes/macos/index.scss +1 -0
  59. package/themes/macos/preview/index.scss +1 -0
  60. package/themes/macos/preview/src/preview-modal/preview-modal.scss +28 -0
  61. package/themes/macos/scrollbar/src/scrollbar/scrollbar.scss +1 -0
  62. package/themes/macos/table/src/table/table.scss +5 -0
@@ -1,4 +1,5 @@
1
1
  @import "./src/preview/preview";
2
+ @import "./src/preview-modal/preview-modal";
2
3
  @import "./src/preview-plain/preview-plain";
3
4
  @import "./src/preview-image/preview-image";
4
5
  @import "./src/preview-video/preview-video";
@@ -0,0 +1,193 @@
1
+ import { Any, Arr, Obj, Dom } from "@kizmann/pico-js";
2
+
3
+ window.NPreviewCacheGroups = {};
4
+
5
+ export class NPreviewHandler
6
+ {
7
+ current = null;
8
+
9
+ static append(item)
10
+ {
11
+ if ( !window.NPreviewCacheGroups[item.group] ) {
12
+ window.NPreviewCacheGroups[item.group] = {};
13
+ }
14
+
15
+ window.NPreviewCacheGroups[item.group][item.uid] = item;
16
+ }
17
+
18
+ static remove(item)
19
+ {
20
+ delete window.NPreviewCacheGroups[item.group][item.uid];
21
+ }
22
+
23
+ static get(group)
24
+ {
25
+ if ( !window.NPreviewCacheGroups[group] ) {
26
+ window.NPreviewCacheGroups[group] = {};
27
+ }
28
+
29
+ return Arr.sort(window.NPreviewCacheGroups[group], 'index');
30
+ }
31
+
32
+ static next()
33
+ {
34
+ if ( ! Any.isObject(this.current) ) {
35
+ return null;
36
+ }
37
+
38
+ let items = NPreviewHandler.get(this.current.group);
39
+
40
+ let index = Arr.findIndex(items, {
41
+ uid: this.current.uid
42
+ });
43
+
44
+ let next = Arr.first(items);
45
+
46
+ if ( items.length > index + 1 ) {
47
+ next = Arr.get(items, index + 1);
48
+ }
49
+
50
+ return NPreviewHandler.switch(next);
51
+ }
52
+
53
+ static prev()
54
+ {
55
+ if ( ! Any.isObject(this.current) ) {
56
+ return null;
57
+ }
58
+
59
+ let items = NPreviewHandler.get(this.current.group);
60
+
61
+ let index = Arr.findIndex(items, {
62
+ uid: this.current.uid
63
+ });
64
+
65
+ let prev = Arr.last(items);
66
+
67
+ if ( 0 <= index - 1 ) {
68
+ prev = Arr.get(items, index - 1);
69
+ }
70
+
71
+ return NPreviewHandler.switch(prev);
72
+ }
73
+
74
+ static create()
75
+ {
76
+ el = Dom.find('.n-preview-modal');
77
+
78
+ if ( el.length() ) {
79
+ return el;
80
+ }
81
+
82
+ let el = Dom.make('div', {
83
+ classList: 'n-preview-modal'
84
+ });
85
+
86
+ el.attr('data-preview', 'nano');
87
+
88
+ let close = Dom.make('div', {
89
+ classList: 'n-preview-modal__close',
90
+ innerHTML: `<i class="${nano.Icons.times}"></i>`
91
+ });
92
+
93
+ close.on('click', () => {
94
+ NPreviewHandler.close()
95
+ });
96
+
97
+ close.appendTo(el);
98
+
99
+ let prev = Dom.make('div', {
100
+ classList: 'n-preview-modal__prev',
101
+ innerHTML: `<i class="${nano.Icons.angleLeft}"></i>`
102
+ });
103
+
104
+ prev.on('click', () => {
105
+ NPreviewHandler.prev()
106
+ });
107
+
108
+ prev.appendTo(el);
109
+
110
+ let next = Dom.make('div', {
111
+ classList: 'n-preview-modal__next',
112
+ innerHTML: `<i class="${nano.Icons.angleRight}"></i>`
113
+ });
114
+
115
+ next.on('click', () => {
116
+ NPreviewHandler.next()
117
+ });
118
+
119
+ next.appendTo(el);
120
+
121
+ el.appendTo(document.body);
122
+
123
+ return el;
124
+ }
125
+
126
+ static open(item)
127
+ {
128
+ let el = NPreviewHandler.create();
129
+
130
+ el.css({
131
+ 'z-index': window.zIndex++
132
+ });
133
+
134
+ let keydownFn = (e) => {
135
+
136
+ if ( e.keyCode === 27 ) {
137
+ return NPreviewHandler.close();
138
+ }
139
+
140
+ if ( e.keyCode === 37 ) {
141
+ return NPreviewHandler.prev();
142
+ }
143
+
144
+ if ( e.keyCode === 39 ) {
145
+ return NPreviewHandler.next();
146
+ }
147
+
148
+ }
149
+
150
+ Dom.find(window).on('keydown', keydownFn, {
151
+ uid: 'n-preview-modal'
152
+ });
153
+
154
+ NPreviewHandler.switch(item);
155
+
156
+ el.addClass('n-ready');
157
+ }
158
+
159
+ static close()
160
+ {
161
+ let el = NPreviewHandler.create();
162
+
163
+ Dom.find(window).off('keydown', null, {
164
+ uid: 'n-preview-modal'
165
+ });
166
+
167
+ NPreviewHandler.switch(null);
168
+
169
+ el.removeClass('n-ready');
170
+ }
171
+
172
+ static switch(item)
173
+ {
174
+ if ( Any.isObject(this.current) ) {
175
+ Obj.set(this.current, 'visible', false);
176
+ }
177
+
178
+ this.current = item;
179
+
180
+ if ( Any.isObject(this.current) ) {
181
+ Obj.set(this.current, 'visible', true);
182
+ }
183
+
184
+ return item;
185
+ }
186
+
187
+ }
188
+
189
+ export default { NPreviewHandler }
190
+
191
+ if ( ! window.NPreviewHandler ) {
192
+ window.NPreviewHandler = NPreviewHandler;
193
+ }
@@ -0,0 +1,142 @@
1
+ import { Any, Arr, Dom, Obj } from "@kizmann/pico-js";
2
+
3
+ window.NPreviewMimes = {
4
+ image: [
5
+ 'jpg', 'jpeg', 'gif', 'svg', 'png', 'bmp'
6
+ ],
7
+ video: [
8
+ 'mp4', 'webm', 'mov'
9
+ ],
10
+ audio: [
11
+ 'mp3', 'aac',
12
+ ],
13
+ font: [
14
+ 'woff', 'ttf', 'otf'
15
+ ],
16
+ text: [
17
+ 'csv', 'txt', 'html'
18
+ ],
19
+ application: [
20
+ 'pdf', 'doc', 'xls'
21
+ ]
22
+ };
23
+
24
+ export class NPreviewHelper
25
+ {
26
+ static getExtension(source, fallback = 'plain')
27
+ {
28
+ let extension = source.replace(/^.*?\.([^.?]+)(\?.*?)?$/,
29
+ '$1');
30
+
31
+ if ( Any.isEmpty(extension) ) {
32
+ return fallback;
33
+ }
34
+
35
+ return extension;
36
+ }
37
+
38
+ static getMime(source, fallback = 'text')
39
+ {
40
+ let file = Obj.get(source, 'name', source);
41
+
42
+ if ( Any.isEmpty(file) ) {
43
+ return fallback;
44
+ }
45
+
46
+ let extension = NPreviewHelper.getExtension(file);
47
+
48
+ if ( NPreviewHelper.getYoutubeKey(file) ) {
49
+ return 'video';
50
+ }
51
+
52
+ if ( NPreviewHelper.getVimeoKey(file) ) {
53
+ return 'video';
54
+ }
55
+
56
+ Obj.each(window.NPreviewMimes, (exts, key) => {
57
+ if ( Arr.has(exts, extension) ) fallback = key;
58
+ });
59
+
60
+ return fallback;
61
+ }
62
+
63
+ static getFullMime(source, fallback = 'text/plain')
64
+ {
65
+ let file = Obj.get(source, 'name', source);
66
+
67
+ if ( Any.isEmpty(file) ) {
68
+ return fallback;
69
+ }
70
+
71
+ if ( NPreviewHelper.getYoutubeKey(source) ) {
72
+ return 'video/youtube';
73
+ }
74
+
75
+ if ( NPreviewHelper.getVimeoKey(source) ) {
76
+ return 'video/vimeo';
77
+ }
78
+
79
+ return NPreviewHelper.getMime(file) + '/' + NPreviewHelper.getExtension(file);
80
+ }
81
+
82
+ static getVimeoKey(source, fallback = null)
83
+ {
84
+ if ( ! Any.isString(source) ) {
85
+ return fallback;
86
+ }
87
+
88
+ let host = source.match(/^https?:\/\/(www\.|player\.)?vimeo\.com/);
89
+
90
+ if ( ! host ) {
91
+ return fallback;
92
+ }
93
+
94
+ let path = source.match(/(\/[0-9]+)(&|$)/);
95
+
96
+ if ( path && path.length === 3 ) {
97
+ return path[0].replace(/(^\/|&$)/, '');
98
+ }
99
+
100
+ return fallback;
101
+ }
102
+
103
+ static getYoutubeKey(source, fallback)
104
+ {
105
+ if ( ! Any.isString(source) ) {
106
+ return fallback;
107
+ }
108
+
109
+ let host = source.match(/^https?:\/\/(www\.)?(youtube\.com|youtu\.be)/);
110
+
111
+ if ( ! host ) {
112
+ return fallback;
113
+ }
114
+
115
+ let id = source.match(/(\?v=.*?)(?=&|$)/);
116
+
117
+ if ( id && id.length === 2 ) {
118
+ return id[0].replace(/^\?v=/, '');
119
+ }
120
+
121
+ let path = source.match(/(\.be\/.*?)(?=\?|$)/);
122
+
123
+ if ( path && path.length === 2 ) {
124
+ return path[0].replace(/^\.be\//, '');
125
+ }
126
+
127
+ let frame = source.match(/(\/embed\/)(.*?$)/);
128
+
129
+ if ( frame && frame.length === 3 ) {
130
+ return frame[0].replace(/^\/embed\//, '');
131
+ }
132
+
133
+ return fallback;
134
+ }
135
+
136
+ }
137
+
138
+ export default { NPreviewHelper }
139
+
140
+ if ( ! window.NPreviewHelper ) {
141
+ window.NPreviewHelper = NPreviewHelper;
142
+ }
@@ -1,22 +1,6 @@
1
- import { Obj, Arr, Any, Dom } from "@kizmann/pico-js";
2
-
3
- const fileMap = {
4
- image: [
5
- 'jpg', 'jpeg', 'gif', 'svg', 'png'
6
- ],
7
- video: [
8
- 'mp4', 'webm', 'mov'
9
- ],
10
- font: [
11
- 'woff', 'ttf', 'otf'
12
- ],
13
- text: [
14
- 'csv', 'txt', 'html'
15
- ],
16
- application: [
17
- 'pdf', 'doc', 'xls'
18
- ]
19
- }
1
+ import { UUID, Obj, Arr, Any, Event } from "@kizmann/pico-js";
2
+ import { NPreviewHandler } from "../_tools/preview-handler.js"
3
+ import { NPreviewHelper } from "../_tools/preview-helper.js"
20
4
 
21
5
  export default {
22
6
 
@@ -38,6 +22,22 @@ export default {
38
22
  }
39
23
  },
40
24
 
25
+ index: {
26
+ default()
27
+ {
28
+ return 0;
29
+ },
30
+ type: [Number, String]
31
+ },
32
+
33
+ group: {
34
+ default()
35
+ {
36
+ return UUID();
37
+ },
38
+ type: [String]
39
+ },
40
+
41
41
  fit: {
42
42
  default()
43
43
  {
@@ -51,7 +51,7 @@ export default {
51
51
  {
52
52
  return null;
53
53
  },
54
- typre: [String]
54
+ type: [String]
55
55
  },
56
56
 
57
57
  preview: {
@@ -59,7 +59,7 @@ export default {
59
59
  {
60
60
  return true;
61
61
  },
62
- typre: [Boolean]
62
+ type: [Boolean]
63
63
  },
64
64
 
65
65
  showSrc: {
@@ -67,15 +67,7 @@ export default {
67
67
  {
68
68
  return true;
69
69
  },
70
- typre: [Boolean]
71
- },
72
-
73
- map: {
74
- default()
75
- {
76
- return fileMap;
77
- },
78
- type: [Object]
70
+ type: [Boolean]
79
71
  }
80
72
 
81
73
  },
@@ -94,82 +86,31 @@ export default {
94
86
 
95
87
  fileMime()
96
88
  {
97
- return this.getFileMime();
89
+ return this.mime || NPreviewHelper.getMime(this.tempFile);
98
90
  },
99
91
 
100
92
  thumbMime()
101
93
  {
102
- return this.getThumbMime();
94
+ return this.mime || NPreviewHelper.getMime(this.tempThumb);
103
95
  },
104
96
 
105
97
  },
106
98
 
107
- data()
99
+ provide()
108
100
  {
109
- return {
110
- lightbox: false, load: false
111
- };
101
+ return { NPreview: this };
112
102
  },
113
103
 
114
104
  methods: {
115
105
 
116
- getFileMime(fallback = null)
117
- {
118
- let file = Obj.get(this.tempFile, 'name',
119
- this.tempFile);
120
-
121
- if ( Any.isEmpty(file) ) {
122
- return fallback;
123
- }
124
-
125
- let extension = file.replace(/^.*?\.([^.?]+)(\?.*?)?$/,
126
- '$1');
127
-
128
- Obj.each(this.map, (exts, key) => {
129
- if ( Arr.has(exts, extension) ) fallback = key;
130
- });
131
-
132
- if ( window.resolveVimeo(file) ) {
133
- fallback = 'video';
134
- }
135
-
136
- if ( window.resolveYoutube(file) ) {
137
- fallback = 'video';
138
- }
139
-
140
- if ( Any.isString(this.mime) ) {
141
- fallback = this.mime;
142
- }
143
-
144
- return fallback;
145
- },
146
-
147
- getThumbMime(fallback = null)
106
+ openBox()
148
107
  {
149
- if ( Any.isString(this.mime) ) {
150
- return this.mime;
151
- }
152
-
153
- let file = Obj.get(this.tempThumb, 'name',
154
- this.tempThumb);
155
-
156
- if ( Any.isEmpty(file) ) {
157
- return fallback;
158
- }
159
-
160
- let extension = file.replace(/^.*?\.([^.?]+)(\?.*?)?$/,
161
- '$1');
162
-
163
- Obj.each(this.map, (exts, key) => {
164
- if ( Arr.has(exts, extension) ) fallback = key;
165
- });
166
-
167
- return fallback;
108
+ this.$refs.modal.openBox();
168
109
  },
169
110
 
170
- showLightbox()
111
+ closeBox()
171
112
  {
172
- this.lightbox = true;
113
+ this.$refs.modal.closeBox();
173
114
  },
174
115
 
175
116
  },
@@ -185,50 +126,42 @@ export default {
185
126
  }
186
127
 
187
128
  let props = {
188
- type: this.thumbMime,
189
- showSrc: false,
190
- }
129
+ type: this.fileMime, showSrc: false,
130
+ };
191
131
 
192
132
  return (<NPreviewPlain src={this.tempThumb} {...props} />);
193
133
  },
194
134
 
195
135
  renderFull()
196
136
  {
197
- let isObject = Any.isObject(this.tempFile);
198
-
199
137
  if ( this.fileMime === 'image' ) {
200
- return (<NPreviewImage src={this.tempFile} />);
138
+ return (<NPreviewImage class={classList} src={this.tempFile} />);
201
139
  }
202
140
 
203
- if ( this.fileMime === 'video' && ! isObject ) {
204
- return (<NPreviewVideo src={this.tempFile} />);
141
+ if ( this.fileMime === 'video' ) {
142
+ return (<NPreviewVideo class={classList} src={this.tempFile} />);
205
143
  }
206
144
 
207
145
  let props = {
208
- type: this.thumbMime,
209
- showSrc: this.showSrc,
210
- }
146
+ type: this.fileMime, showSrc: this.showSrc,
147
+ };
211
148
 
212
- return (<NPreviewPlain src={this.tempFile} {...props} />);
149
+ return (<NPreviewPlain class={classList} src={this.tempFile} {...props} />);
213
150
  },
214
151
 
215
- renderLightbox()
152
+ renderModal()
216
153
  {
217
- if ( ! this.lightbox || ! this.preview ) {
154
+ if ( ! this.preview ) {
218
155
  return null;
219
156
  }
220
157
 
221
- let slots = {
222
- raw: this.ctor('renderFull')
223
- }
224
-
225
- let props = {
226
- type: 'preview',
227
- width: '80%',
228
- height: '90%',
229
- }
158
+ let modalProps = {
159
+ index: this.index, group: this.group, file: this.tempFile, showSrc: this.showSrc
160
+ };
230
161
 
231
- return (<NModal vModel={this.lightbox} {...props} v-slots={slots} />);
162
+ return (
163
+ <NPreviewModal ref="modal" {...modalProps} />
164
+ );
232
165
  },
233
166
 
234
167
  render()
@@ -249,14 +182,14 @@ export default {
249
182
  let props = {};
250
183
 
251
184
  if ( this.preview ) {
252
- props.onClick = this.showLightbox;
185
+ props.onClick = () => this.openBox();
253
186
  }
254
187
 
255
188
  let key = btoa(this.tempThumb);
256
189
 
257
190
  return (
258
191
  <div key={key} class={classList} {...props}>
259
- { [this.ctor('renderPreview')(), this.ctor('renderLightbox')()] }
192
+ { [this.ctor('renderPreview')(), this.ctor('renderModal')()] }
260
193
  </div>
261
194
  );
262
195
  }
@@ -11,4 +11,5 @@
11
11
 
12
12
  .n-preview--contain img {
13
13
  object-fit: contain !important;
14
- }
14
+ }
15
+