@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.
- package/dist/nano-ui.css +1 -1
- package/dist/nano-ui.js +1 -1
- package/dist/nano-ui.js.map +1 -1
- package/dist/themes/dark.css +1 -1
- package/dist/themes/glossy.dark.css +1 -0
- package/dist/themes/glossy.light.css +1 -0
- package/dist/themes/light.css +1 -1
- package/package.json +1 -1
- package/src/button/src/button/button.jsx +12 -0
- package/src/button/src/button/button.scss +4 -1
- package/src/collapse/src/collapse-item/collapse-item.jsx +1 -1
- package/src/draggable/src/draglist/draglist.jsx +1 -1
- package/src/draggable/src/draglist-item/draglist-item.jsx +5 -2
- package/src/drawer/src/drawer/drawer.jsx +9 -3
- package/src/form/src/form/form.jsx +9 -4
- package/src/form/src/form-frame/form-frame.jsx +53 -21
- package/src/form/src/form-frame/form-frame.scss +7 -0
- package/src/form/src/form-group/form-group.jsx +31 -11
- package/src/form/src/form-item/form-item.jsx +9 -5
- package/src/info/src/info/info.jsx +1 -1
- package/src/modal/src/modal/modal.jsx +1 -1
- package/src/modal/src/modal/modal.scss +2 -2
- package/src/paginator/src/paginator/paginator.jsx +24 -29
- package/src/preview/index.js +2 -0
- package/src/preview/index.scss +1 -0
- package/src/preview/src/_tools/preview-handler.js +193 -0
- package/src/preview/src/_tools/preview-helper.js +142 -0
- package/src/preview/src/preview/preview.jsx +48 -115
- package/src/preview/src/preview/preview.scss +2 -1
- package/src/preview/src/preview-modal/preview-modal.jsx +156 -0
- package/src/preview/src/preview-modal/preview-modal.scss +56 -0
- package/src/preview/src/preview-video/preview-video.jsx +4 -60
- package/src/resizer/index.js +3 -1
- package/src/resizer/src/resizer/resizer-next.jsx +536 -0
- package/src/resizer/src/resizer/resizer.jsx +17 -11
- package/src/scrollbar/index.js +3 -1
- package/src/scrollbar/index.scss +1 -0
- package/src/scrollbar/src/scrollbar/scrollbar.scss +14 -8
- package/src/scrollbar/src/scrollbar-next/scrollbar-next.jsx +640 -0
- package/src/scrollbar/src/scrollbar-next/scrollbar-next.scss +148 -0
- package/src/select/src/select/select.jsx +12 -16
- package/src/select/src/select/select.scss +1 -1
- package/src/table/src/table/table.jsx +4 -7
- package/src/table/src/table/table.scss +15 -14
- package/src/table/src/table-cell/types/table-cell-image.jsx +9 -3
- package/src/table/src/table-column/table-column.jsx +11 -27
- package/src/table/src/table-filter/types/table-filter-datetime.jsx +1 -1
- package/src/tabs/src/tabs-item/tabs-item.jsx +1 -1
- package/src/tags/src/tags-item/tags-item.jsx +1 -2
- package/src/timepicker/src/timepicker-panel/timepicker-panel.jsx +15 -3
- package/src/timepicker/src/timepicker-panel/timepicker-panel.scss +2 -1
- package/src/virtualscroller/src/virtualscroller/virtualscroller.jsx +63 -30
- package/src/virtualscroller/src/virtualscroller/virtualscroller.scss +1 -0
- package/themes/glossy/button/index.scss +2 -0
- package/themes/glossy/button/src/button/button.scss +116 -0
- package/themes/glossy/button/src/button-group/button-group.scss +1 -0
- package/themes/glossy/index-dark.scss +3 -0
- package/themes/glossy/index-light.scss +3 -0
- package/themes/glossy/index.scss +43 -0
- package/themes/glossy/root/image/empty-default.svg +30 -0
- package/themes/glossy/root/image/empty-space.svg +34 -0
- package/themes/glossy/root/image/star-default.svg +10 -0
- package/themes/glossy/root/image/test.svg +1 -0
- package/themes/glossy/root/vars-dark.scss +234 -0
- package/themes/glossy/root/vars-light.scss +234 -0
- package/themes/glossy/root/vars.scss +233 -0
- package/themes/macos/button/src/button/button.scss +46 -8
- package/themes/macos/form/src/form-frame/form-frame.scss +2 -2
- package/themes/macos/index.scss +1 -0
- package/themes/macos/preview/index.scss +1 -0
- package/themes/macos/preview/src/preview-modal/preview-modal.scss +28 -0
- package/themes/macos/scrollbar/src/scrollbar/scrollbar.scss +1 -0
- package/themes/macos/table/src/table/table.scss +5 -0
|
@@ -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,
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
89
|
+
return this.mime || NPreviewHelper.getMime(this.tempFile);
|
|
98
90
|
},
|
|
99
91
|
|
|
100
92
|
thumbMime()
|
|
101
93
|
{
|
|
102
|
-
return this.
|
|
94
|
+
return this.mime || NPreviewHelper.getMime(this.tempThumb);
|
|
103
95
|
},
|
|
104
96
|
|
|
105
97
|
},
|
|
106
98
|
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
+
closeBox()
|
|
171
112
|
{
|
|
172
|
-
this.
|
|
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.
|
|
189
|
-
|
|
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'
|
|
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.
|
|
209
|
-
|
|
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
|
-
|
|
152
|
+
renderModal()
|
|
216
153
|
{
|
|
217
|
-
if ( ! this.
|
|
154
|
+
if ( ! this.preview ) {
|
|
218
155
|
return null;
|
|
219
156
|
}
|
|
220
157
|
|
|
221
|
-
let
|
|
222
|
-
|
|
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 (
|
|
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.
|
|
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('
|
|
192
|
+
{ [this.ctor('renderPreview')(), this.ctor('renderModal')()] }
|
|
260
193
|
</div>
|
|
261
194
|
);
|
|
262
195
|
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Any, Event, UUID } from "@kizmann/pico-js";
|
|
2
|
+
import { NPreviewHandler } from "../_tools/preview-handler.js";
|
|
3
|
+
import { NPreviewHelper } from "../_tools/preview-helper.js";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
|
|
7
|
+
name: 'NPreviewModal',
|
|
8
|
+
|
|
9
|
+
inject: {
|
|
10
|
+
|
|
11
|
+
NPreview: {
|
|
12
|
+
default: undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
props: {
|
|
18
|
+
|
|
19
|
+
file: {
|
|
20
|
+
default()
|
|
21
|
+
{
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
index: {
|
|
27
|
+
default()
|
|
28
|
+
{
|
|
29
|
+
return 0;
|
|
30
|
+
},
|
|
31
|
+
type: [Number, String]
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
group: {
|
|
35
|
+
default()
|
|
36
|
+
{
|
|
37
|
+
return UUID();
|
|
38
|
+
},
|
|
39
|
+
type: [String]
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
data()
|
|
45
|
+
{
|
|
46
|
+
return { uid: UUID(), visible: false };
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
watch: {
|
|
50
|
+
|
|
51
|
+
visible: function (value) {
|
|
52
|
+
if ( value ) {
|
|
53
|
+
this.NPreview.$emit('slide');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
mounted()
|
|
60
|
+
{
|
|
61
|
+
NPreviewHandler.create()
|
|
62
|
+
.append(this.$el);
|
|
63
|
+
|
|
64
|
+
NPreviewHandler.append(this);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
beforeUnmount()
|
|
68
|
+
{
|
|
69
|
+
this.$el.remove();
|
|
70
|
+
|
|
71
|
+
NPreviewHandler.remove(this);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
methods: {
|
|
75
|
+
|
|
76
|
+
openBox()
|
|
77
|
+
{
|
|
78
|
+
NPreviewHandler.open(this);
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
closeBox()
|
|
82
|
+
{
|
|
83
|
+
NPreviewHandler.close();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
renderPrev()
|
|
89
|
+
{
|
|
90
|
+
let prevProps = {
|
|
91
|
+
size: 'lg', square: true, icon: 'fa fa-angle-left'
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
prevProps['onClick'] = () => {
|
|
95
|
+
this.gotoPrev();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div class="n-preview__prev">
|
|
100
|
+
<NButton {...prevProps} />
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
renderNext()
|
|
106
|
+
{
|
|
107
|
+
let nextProps = {
|
|
108
|
+
size: 'lg', square: true, icon: 'fa fa-angle-right'
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
nextProps['onClick'] = () => {
|
|
112
|
+
this.gotoNext();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div class="n-preview__next">
|
|
117
|
+
<NButton {...nextProps} />
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
renderImage()
|
|
125
|
+
{
|
|
126
|
+
let classList = [
|
|
127
|
+
'n-preview-frame'
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
let mime = NPreviewHelper.getMime(this.file);
|
|
131
|
+
|
|
132
|
+
if ( mime === 'image' ) {
|
|
133
|
+
return (<NPreviewImage class={classList} src={this.file} />);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if ( mime === 'video' ) {
|
|
137
|
+
return (<NPreviewVideo class={classList} src={this.file} />);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let props = {
|
|
141
|
+
type: mime, showSrc: this.showSrc,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (<NPreviewPlain class={classList} src={this.file} {...props} />);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
render()
|
|
148
|
+
{
|
|
149
|
+
if ( ! this.visible ) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return this.ctor('renderImage')();
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
@import "../../../root/vars";
|
|
2
|
+
|
|
3
|
+
.n-preview-modal {
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
display: flex;
|
|
11
|
+
padding: 40px 80px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.n-preview-modal:not(.n-ready) {
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
opacity: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.n-preview-modal__close {
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
z-index: 100;
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 20px;
|
|
24
|
+
right: 20px;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
width: 40px;
|
|
29
|
+
height: 40px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.n-preview-modal .n-preview-frame {
|
|
33
|
+
background: transparent !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.n-preview-modal__prev,
|
|
37
|
+
.n-preview-modal__next {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
z-index: 500;
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 50%;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
width: 40px;
|
|
46
|
+
height: 40px;
|
|
47
|
+
transform: translateY(-50%);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.n-preview-modal__prev {
|
|
51
|
+
left: 20px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.n-preview-modal__next {
|
|
55
|
+
right: 20px;
|
|
56
|
+
}
|
|
@@ -1,58 +1,5 @@
|
|
|
1
1
|
import { Obj, Arr, Str, Any, Dom } from "@kizmann/pico-js";
|
|
2
|
-
|
|
3
|
-
window.resolveYoutube = function(url, fallback = null) {
|
|
4
|
-
|
|
5
|
-
if ( ! Any.isString(url) ) {
|
|
6
|
-
return fallback;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let host = url.match(/^https?:\/\/(www\.)?(youtube\.com|youtu\.be)/);
|
|
10
|
-
|
|
11
|
-
if ( ! host ) {
|
|
12
|
-
return fallback;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let id = url.match(/(\?v=.*?)(?=&|$)/);
|
|
16
|
-
|
|
17
|
-
if ( id && id.length === 2 ) {
|
|
18
|
-
return id[0].replace(/^\?v=/, '');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let path = url.match(/(\.be\/.*?)(?=\?|$)/);
|
|
22
|
-
|
|
23
|
-
if ( path && path.length === 2 ) {
|
|
24
|
-
return path[0].replace(/^\.be\//, '');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let frame = url.match(/(\/embed\/)(.*?$)/);
|
|
28
|
-
|
|
29
|
-
if ( frame && frame.length === 3 ) {
|
|
30
|
-
return frame[0].replace(/^\/embed\//, '');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return fallback;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
window.resolveVimeo = function(url, fallback = null) {
|
|
37
|
-
|
|
38
|
-
if ( ! Any.isString(url) ) {
|
|
39
|
-
return fallback;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let host = url.match(/^https?:\/\/(www\.|player\.)?vimeo\.com/);
|
|
43
|
-
|
|
44
|
-
if ( ! host ) {
|
|
45
|
-
return fallback;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let path = url.match(/(\/[0-9]+)(&|$)/);
|
|
49
|
-
|
|
50
|
-
if ( path && path.length === 3 ) {
|
|
51
|
-
return path[0].replace(/(^\/|&$)/, '');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return fallback;
|
|
55
|
-
}
|
|
2
|
+
import { NPreviewHelper } from "../_tools/preview-helper.js"
|
|
56
3
|
|
|
57
4
|
export default {
|
|
58
5
|
|
|
@@ -117,7 +64,7 @@ export default {
|
|
|
117
64
|
|
|
118
65
|
resolveYoutube()
|
|
119
66
|
{
|
|
120
|
-
let youtube =
|
|
67
|
+
let youtube = NPreviewHelper.getYoutubeKey(this.src);
|
|
121
68
|
|
|
122
69
|
if ( ! youtube ) {
|
|
123
70
|
return false;
|
|
@@ -132,7 +79,7 @@ export default {
|
|
|
132
79
|
|
|
133
80
|
resolveVimeo()
|
|
134
81
|
{
|
|
135
|
-
let vimeo =
|
|
82
|
+
let vimeo = NPreviewHelper.getVimeoKey(this.src);
|
|
136
83
|
|
|
137
84
|
if ( ! vimeo ) {
|
|
138
85
|
return false;
|
|
@@ -173,12 +120,9 @@ export default {
|
|
|
173
120
|
{
|
|
174
121
|
let src = Obj.get(this.src, 'name', this.src);
|
|
175
122
|
|
|
176
|
-
let extension = src.replace(/^.*?\.([^.?]+)(\?.*?)?$/,
|
|
177
|
-
'$1');
|
|
178
|
-
|
|
179
123
|
return (
|
|
180
124
|
<video width="320" height="240" controls>
|
|
181
|
-
<source src={this.tempSrc || this.src} type={
|
|
125
|
+
<source src={this.tempSrc || this.src} type={NPreviewHelper.getFullMime(src)} />
|
|
182
126
|
</video>
|
|
183
127
|
);
|
|
184
128
|
},
|
package/src/resizer/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Resizer from "./src/resizer/resizer.jsx";
|
|
2
|
+
import ResizerNext from "./src/resizer/resizer-next.jsx";
|
|
2
3
|
|
|
3
4
|
export default function (App) {
|
|
4
|
-
App.component(Resizer.name, Resizer);
|
|
5
|
+
// App.component(Resizer.name, Resizer);
|
|
6
|
+
App.component(ResizerNext.name, ResizerNext);
|
|
5
7
|
}
|