@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
@@ -63,7 +63,7 @@ export default {
63
63
 
64
64
  data()
65
65
  {
66
- return { search: '' };
66
+ return { search: '', star: '', block: false };
67
67
  },
68
68
 
69
69
  mounted()
@@ -75,10 +75,48 @@ export default {
75
75
  this.$nextTick(() => {
76
76
  this.onScrollEvent();
77
77
  });
78
+
79
+ this.onMoveEvent();
78
80
  },
79
81
 
80
82
  methods: {
81
83
 
84
+ applyStar(id, block = false)
85
+ {
86
+ if ( this.block ) {
87
+ return;
88
+ }
89
+
90
+ this.block = block;
91
+
92
+ if ( ! Any.isEmpty(this.timeout) ) {
93
+ clearTimeout(this.timeout);
94
+ }
95
+
96
+ if ( block ) {
97
+ this.star = id;
98
+ }
99
+
100
+ this.timeout = setTimeout(() => {
101
+ this.star = id; this.block = false;
102
+ }, 500);
103
+ },
104
+
105
+ onMoveEvent()
106
+ {
107
+ Dom.find(window).on('mousemove', Any.debounce(e => {
108
+
109
+ let el = Dom.find(e.target).closest('[data-group-key]');
110
+
111
+ if ( Any.isEmpty(el) ) {
112
+ return;
113
+ }
114
+
115
+ this.applyStar(Dom.find(el).attr('data-group-key'), true);
116
+
117
+ }, 100));
118
+ },
119
+
82
120
  onScrollEvent()
83
121
  {
84
122
  Dom.find(this.$el).find('[data-menu-key]').each((el) => {
@@ -107,12 +145,7 @@ export default {
107
145
  this.$refs.menu.scrollIntoView(selector)
108
146
  });
109
147
 
110
- let star = {
111
- el: el, attr: Dom.find(el).attr('data-group-key')
112
- };
113
-
114
- Dom.find(`[data-menu-key="${star.attr}"]`)
115
- .addClass('is-star');
148
+ this.applyStar(Dom.find(el).attr('data-group-key'), false);
116
149
  },
117
150
 
118
151
  onSearchInput()
@@ -127,7 +160,12 @@ export default {
127
160
  }
128
161
 
129
162
  let groups = Arr.filter(this.NForm.groups, (group) => {
130
- return Str.lower(group.label).indexOf(search) !== -1;
163
+
164
+ let labels = Arr.extract(group.items, 'label')
165
+ .join("\n");
166
+
167
+ return Str.lower(group.label + "\n" + labels)
168
+ .indexOf(search) !== -1;
131
169
  });
132
170
 
133
171
  Arr.each(groups, (group) => {
@@ -147,20 +185,10 @@ export default {
147
185
  item.openGroup();
148
186
  }
149
187
 
150
- if ( ! Any.isEmpty(this.timeout) ) {
151
- clearTimeout(this.timeout);
188
+ if ( this.star !== item.key ) {
189
+ this.applyStar(item.key, true);
152
190
  }
153
191
 
154
- Dom.find('[data-group-key]').removeClass('on-search');
155
-
156
- this.timeout = setTimeout(() => {
157
- Dom.find(selector).removeClass('on-search');
158
- }, 4000);
159
-
160
- this.$nextTick(() => {
161
- Dom.find(selector).addClass('on-search');
162
- });
163
-
164
192
  this.$refs.body.scrollIntoView(selector, 0, 100);
165
193
  }
166
194
 
@@ -214,7 +242,11 @@ export default {
214
242
  let classList = [
215
243
  'n-form-frame__menu',
216
244
  'n-form-frame__menu--' + item.type
217
- ]
245
+ ];
246
+
247
+ if ( this.star === item.key ) {
248
+ classList.push('is-star');
249
+ }
218
250
 
219
251
  return (
220
252
  <a class={classList} data-menu-key={item.key} {...buttonProps}>
@@ -57,6 +57,13 @@
57
57
  .n-form-frame__menu i {
58
58
  flex: 0 0 auto;
59
59
  text-align: center;
60
+ transition: opacity 0.3s;
61
+ opacity: 0.7;
62
+ }
63
+
64
+ .n-form-frame__menu.on-search i,
65
+ .n-form-frame__menu.is-visible i {
66
+ opacity: 1;
60
67
  }
61
68
 
62
69
  .n-form-frame__menu span {
@@ -1,4 +1,4 @@
1
- import { UUID } from "@kizmann/pico-js";
1
+ import { Arr, UUID } from "@kizmann/pico-js";
2
2
 
3
3
  export default {
4
4
 
@@ -107,27 +107,32 @@ export default {
107
107
 
108
108
  },
109
109
 
110
+ data()
111
+ {
112
+ return {
113
+ uid: UUID(), tempValue: this.modelValue, items: []
114
+ };
115
+ },
116
+
117
+ provide()
118
+ {
119
+ return { NFormGroup: this };
120
+ },
121
+
110
122
  mounted()
111
123
  {
112
124
  if ( this.NForm ) {
113
- this.NForm.registerGroup(this);
125
+ this.NForm.appendGroup(this);
114
126
  }
115
127
  },
116
128
 
117
129
  unmounted()
118
130
  {
119
131
  if ( this.NForm ) {
120
- this.NForm.unregisterGroup(this);
132
+ this.NForm.removeGroup(this);
121
133
  }
122
134
  },
123
135
 
124
- data()
125
- {
126
- return {
127
- tempValue: this.modelValue
128
- };
129
- },
130
-
131
136
  watch: {
132
137
 
133
138
  modelValue(value)
@@ -141,6 +146,21 @@ export default {
141
146
 
142
147
  methods: {
143
148
 
149
+ getItems()
150
+ {
151
+ return this.items;
152
+ },
153
+
154
+ appendItem(item)
155
+ {
156
+ this.items[item.uid] = item;
157
+ },
158
+
159
+ removeItem(item)
160
+ {
161
+ delete this.items[item.uid];
162
+ },
163
+
144
164
  toggleGroup()
145
165
  {
146
166
  this.$emit('update:modelValue', this.tempValue = ! this.tempValue);
@@ -154,7 +174,7 @@ export default {
154
174
  closeGroup()
155
175
  {
156
176
  this.$emit('update:modelValue', this.tempValue = true);
157
- }
177
+ },
158
178
 
159
179
  },
160
180
 
@@ -6,11 +6,15 @@ export default {
6
6
 
7
7
  inject: {
8
8
 
9
+ NTabs: {
10
+ default: undefined
11
+ },
12
+
9
13
  NForm: {
10
14
  default: undefined
11
15
  },
12
16
 
13
- NTabs: {
17
+ NFormGroup: {
14
18
  default: undefined
15
19
  },
16
20
 
@@ -175,8 +179,8 @@ export default {
175
179
 
176
180
  beforeMount()
177
181
  {
178
- if ( this.NForm ) {
179
- this.NForm.addItem(this);
182
+ if ( this.NFormGroup ) {
183
+ this.NFormGroup.appendItem(this);
180
184
  }
181
185
  },
182
186
 
@@ -189,8 +193,8 @@ export default {
189
193
 
190
194
  beforeUnmount()
191
195
  {
192
- if ( this.NForm ) {
193
- this.NForm.removeItem(this);
196
+ if ( this.NFormGroup ) {
197
+ this.NFormGroup.removeItem(this);
194
198
  }
195
199
  },
196
200
 
@@ -93,7 +93,7 @@ export default {
93
93
  {
94
94
  Any.delay(() => {
95
95
  if ( this.$refs.scrollbar ) {
96
- this.$refs.scrollbar.adaptHeight();
96
+ // this.$refs.scrollbar.adaptHeight();
97
97
  }
98
98
  }, 500);
99
99
  },
@@ -408,7 +408,7 @@ export default {
408
408
  'n-modal',
409
409
  'n-modal--' + this.size,
410
410
  'n-modal--' + this.type,
411
- 'n-modal--' + this.position
411
+ 'n-modal--' + this.position,
412
412
  ];
413
413
 
414
414
  if ( this.tempValue ) {
@@ -27,7 +27,7 @@
27
27
  transition: opacity 0.5s ease-in-out;
28
28
  }
29
29
 
30
- .n-modal:not(.n-ready) .n-modal__backdrop {
30
+ .n-modal:not(.n-ready,.n-loop) .n-modal__backdrop {
31
31
  opacity: 0;
32
32
  }
33
33
 
@@ -47,7 +47,7 @@
47
47
  transition: opacity 0.2s 0.1s ease-out, transform 0.2s 0.1s ease-out;
48
48
  }
49
49
 
50
- .n-modal:not(.n-ready) .n-modal__frame {
50
+ .n-modal:not(.n-ready,.n-loop) .n-modal__frame {
51
51
  opacity: 0;
52
52
  transform: translateY(20px);
53
53
  }
@@ -95,7 +95,6 @@ export default {
95
95
  },
96
96
 
97
97
 
98
-
99
98
  methods: {
100
99
 
101
100
  forcePage(page)
@@ -175,11 +174,11 @@ export default {
175
174
  renderLimit()
176
175
  {
177
176
  let props = {
178
- modelValue: this.tempLimit,
179
- size: this.size,
180
- type: this.type,
181
- optionsValue: '$value.value',
182
- optionsLabel: '$value.label',
177
+ modelValue: this.tempLimit,
178
+ size: this.size,
179
+ type: this.type,
180
+ optionsValue: '$value.value',
181
+ optionsLabel: '$value.label',
183
182
  };
184
183
 
185
184
  props.options = Arr.each(this.limitOptions, (limit) => {
@@ -201,7 +200,7 @@ export default {
201
200
  {
202
201
  return (
203
202
  <div class="n-paginator__count">
204
- { this.choice('No items|Total :count item|Total :count items', this.total) }
203
+ {this.choice('No items|Total :count item|Total :count items', this.total)}
205
204
  </div>
206
205
  );
207
206
  },
@@ -210,7 +209,7 @@ export default {
210
209
  {
211
210
  return (
212
211
  <div class="n-paginator__spacer">
213
- { /* Nothing :( */ }
212
+ { /* Nothing :( */}
214
213
  </div>
215
214
  );
216
215
  },
@@ -218,28 +217,24 @@ export default {
218
217
  renderGoto()
219
218
  {
220
219
  if ( this.pageOptions.length > 500 ) {
221
- return null;
220
+ // return null;
222
221
  }
223
222
 
224
223
  let props = {
225
- modelValue: this.tempPage,
226
- size: this.size,
227
- type: this.type,
228
- undefinedText: '?',
229
- optionsValue: '$value.value',
230
- optionsLabel: '$value.label',
224
+ modelValue: this.tempPage,
225
+ size: this.size,
226
+ type: this.type,
227
+ undefinedText: '?',
228
+ lazy: true,
229
+ options: this.pageOptions,
230
+ optionsValue: '$value',
231
+ optionsLabel: '$value',
231
232
  };
232
233
 
233
- props.options = Arr.reduce(this.pageOptions, (merge, index) => {
234
- return Arr.push(merge, {
235
- value: index, label: index
236
- });
237
- }, []);
238
-
239
234
  props['onUpdate:modelValue'] = this.onPageInput;
240
235
 
241
236
  return (
242
- <div class="n-paginator__goto">
237
+ <div class="n-paginator__goto" key={'paginate' + this.pageOptions.length}>
243
238
  <NSelect {...props} />
244
239
  </div>
245
240
  );
@@ -369,7 +364,7 @@ export default {
369
364
  };
370
365
 
371
366
  return (
372
- <NButton {...props}>{ current }</NButton>
367
+ <NButton {...props}>{current}</NButton>
373
368
  );
374
369
  },
375
370
 
@@ -381,18 +376,18 @@ export default {
381
376
 
382
377
  return (
383
378
  <div class="n-paginator__pages">
384
- { this.ctor('renderFirst')() }
385
- { this.ctor('renderPrev')() }
386
- { ...pages }
387
- { this.ctor('renderNext')() }
388
- { this.ctor('renderLast')() }
379
+ {this.ctor('renderFirst')()}
380
+ {this.ctor('renderPrev')()}
381
+ {...pages}
382
+ {this.ctor('renderNext')()}
383
+ {this.ctor('renderLast')()}
389
384
  </div>
390
385
  );
391
386
  },
392
387
 
393
388
  renderSlot(view)
394
389
  {
395
- let renderFunction = this.ctor('render' +
390
+ let renderFunction = this.ctor('render' +
396
391
  Str.ucfirst(view));
397
392
 
398
393
  if ( Any.isFunction(renderFunction) ) {
@@ -2,9 +2,11 @@ import Preview from "./src/preview/preview.jsx";
2
2
  import PreviewPlain from "./src/preview-plain/preview-plain.jsx";
3
3
  import PreviewImage from "./src/preview-image/preview-image.jsx";
4
4
  import PreviewVideo from "./src/preview-video/preview-video.jsx";
5
+ import PreviewModal from "./src/preview-modal/preview-modal.jsx";
5
6
 
6
7
  export default function (App) {
7
8
  App.component(Preview.name, Preview);
9
+ App.component(PreviewModal.name, PreviewModal);
8
10
  App.component(PreviewPlain.name, PreviewPlain);
9
11
  App.component(PreviewImage.name, PreviewImage);
10
12
  App.component(PreviewVideo.name, PreviewVideo);
@@ -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
+ }