@neatui/nuxt 1.0.7 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/nuxt",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "NeatUI component library for Nuxt 3",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -3,7 +3,7 @@
3
3
  <div :class="listClass" :style="listStyle" am-view-item="list">
4
4
  <slot name="list" :mode="mode"></slot>
5
5
  </div>
6
- <div :class="itemClass" :style="itemStyle" am-view-item="item" ref="itemRef" v-if="view === 'iteming' || view === 'listing' || view === 'item'">
6
+ <div v-if="view === 'iteming' || view === 'listing' || view === 'item'" ref="itemRef" :class="itemClass" :style="itemStyle" am-view-item="item">
7
7
  <div class="iroute-view-dark" @click="cancel"></div>
8
8
  <div class="iroute-view-body" :style="mode === 'preview' || mode === 'pop-up' ? '' : 'width: 100%;'">
9
9
  <slot name="item" :mode="mode"></slot>
@@ -64,17 +64,17 @@
64
64
  );
65
65
  };
66
66
  };
67
- provide('onlist', evs('list', 'item'));
68
- provide('onitem', evs('item', 'list'));
69
67
 
70
68
  const init = ref(0);
71
69
  const view = ref('');
72
70
  const anim = (e: any) => {
73
71
  if (
74
72
  e.animationName === 'am-show-default' ||
73
+ e.animationName === 'am-show-window' ||
75
74
  e.animationName === 'am-show-preview' ||
76
75
  e.animationName === 'am-show-pop-up' ||
77
76
  e.animationName === 'am-hide-default' ||
77
+ e.animationName === 'am-hide-window' ||
78
78
  e.animationName === 'am-hide-preview' ||
79
79
  e.animationName === 'am-hide-pop-up'
80
80
  ) {
@@ -93,12 +93,17 @@
93
93
  }
94
94
  };
95
95
 
96
- watch(() => route.query[props.queryName], a);
97
- a();
96
+ if (import.meta.client) {
97
+ provide('onlist', evs('list', 'item'));
98
+ provide('onitem', evs('item', 'list'));
99
+ watch(() => route.query[props.queryName], a);
100
+ a();
101
+ }
98
102
 
99
103
  // 取消
100
- const cancel = ({ target }: any = {}) => {
104
+ const cancel = () => {
101
105
  const _query = { ...route.query };
106
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
102
107
  delete _query[props.queryName];
103
108
  router.push({ path: route.path, query: _query });
104
109
  };
@@ -172,27 +177,27 @@
172
177
  }
173
178
  }
174
179
  &[am-view='list'] {
175
- & > [am-view-item~='list'] {
180
+ [am-view-item~='list'] {
176
181
  flex-direction: column;
177
182
  display: flex;
178
183
  animation: am-show-default 0.35s ease both;
179
184
  }
180
185
  }
181
186
  &[am-view='listing'] {
182
- & > [am-view-item~='item'] {
187
+ [am-view-item~='item'] {
183
188
  flex-direction: column;
184
189
  display: flex;
185
190
  animation: am-hide-default 0.3s ease-in-out both;
186
191
  }
187
192
  }
188
193
  &[am-view='item'] {
189
- & > [am-view-item~='item'] {
194
+ [am-view-item~='item'] {
190
195
  display: flex;
191
196
  animation: am-show-default 0.35s ease both;
192
197
  }
193
198
  }
194
199
  &[am-view='iteming'] {
195
- & > [am-view-item~='list'] {
200
+ [am-view-item~='list'] {
196
201
  display: flex;
197
202
  animation: am-hide-default 0.3s ease-in-out both;
198
203
  }
@@ -259,14 +264,14 @@
259
264
  }
260
265
  &[am-view='list'],
261
266
  &[am-view='listing'] {
262
- & > [am-view-item~='item'] {
267
+ [am-view-item~='item'] {
263
268
  display: flex;
264
269
  animation: am-hide-preview 0.5s ease-in-out both;
265
270
  }
266
271
  }
267
272
  &[am-view='item'],
268
273
  &[am-view='iteming'] {
269
- & > [am-view-item~='item'] {
274
+ [am-view-item~='item'] {
270
275
  display: flex;
271
276
  animation: am-show-preview 0.5s ease both;
272
277
  }
@@ -353,7 +358,7 @@
353
358
  }
354
359
  &[am-view='list'],
355
360
  &[am-view='listing'] {
356
- & > [am-view-item~='item'] {
361
+ [am-view-item~='item'] {
357
362
  display: flex;
358
363
  opacity: 0;
359
364
  & > * {
@@ -363,7 +368,7 @@
363
368
  }
364
369
  &[am-view='item'],
365
370
  &[am-view='iteming'] {
366
- & > [am-view-item~='item'] {
371
+ [am-view-item~='item'] {
367
372
  display: flex;
368
373
  opacity: 1;
369
374
  & > * {
@@ -372,4 +377,73 @@
372
377
  }
373
378
  }
374
379
  }
380
+
381
+ // 窗口模式
382
+ [am-view][am-mode~='window'] {
383
+ overflow: hidden;
384
+
385
+ @keyframes am-show-default {
386
+ 0% {
387
+ opacity: 0;
388
+ transform: translate3d(1em, 0, 0);
389
+ }
390
+ 100% {
391
+ opacity: 1;
392
+ transform: translate3d(0, 0, 0);
393
+ }
394
+ }
395
+ @keyframes am-hide-default {
396
+ 0% {
397
+ opacity: 1;
398
+ transform: translate3d(0, 0, 0);
399
+ }
400
+ 100% {
401
+ opacity: 0;
402
+ transform: translate3d(1em, 0, 0);
403
+ }
404
+ }
405
+
406
+ &[view-full~='1'] {
407
+ position: fixed;
408
+ width: 100%;
409
+ height: 100%;
410
+ left: 0;
411
+ top: 0;
412
+ z-index: 15;
413
+ }
414
+
415
+ [am-view-item] {
416
+ display: none;
417
+
418
+ &[am-view-item~='row'] {
419
+ flex-direction: row !important;
420
+ }
421
+ }
422
+ &[am-view='list'] {
423
+ [am-view-item~='list'] {
424
+ flex-direction: column;
425
+ display: flex;
426
+ animation: am-show-default 0s ease both;
427
+ }
428
+ }
429
+ &[am-view='listing'] {
430
+ [am-view-item~='item'] {
431
+ flex-direction: column;
432
+ display: flex;
433
+ animation: am-hide-default 0s ease-in-out both;
434
+ }
435
+ }
436
+ &[am-view='item'] {
437
+ [am-view-item~='item'] {
438
+ display: flex;
439
+ animation: am-show-default 0s ease both;
440
+ }
441
+ }
442
+ &[am-view='iteming'] {
443
+ [am-view-item~='list'] {
444
+ display: flex;
445
+ animation: am-hide-default 0s ease-in-out both;
446
+ }
447
+ }
448
+ }
375
449
  </style>
@@ -1,4 +1,5 @@
1
- import { Layer, LayerById } from './LayerView';
1
+ import Layer from './LayerView/Layer.vue';
2
+ import LayerById from './LayerView/index';
2
3
  import Icon from './Icon.vue';
3
4
  import IFollowView from './IFollowView.vue';
4
5
  import IPickerView from './IPickerView.vue';
@@ -103,8 +103,10 @@
103
103
 
104
104
  const ph = ref(0);
105
105
  onMounted(() => {
106
- const side = document.getElementById('side-layerloader');
107
- ph.value = side?.clientHeight || 0;
106
+ if (import.meta.client) {
107
+ const side = document.getElementById('side-layerloader');
108
+ ph.value = side?.clientHeight || 0;
109
+ }
108
110
  });
109
111
 
110
112
  // 计算路径
@@ -131,18 +133,20 @@
131
133
  unfoldActivePath(props.data, newActive);
132
134
 
133
135
  nextTick(() => {
134
- const el = document.getElementById(`LID${newActive.replace(/\./g, '')}`);
135
- if (el && !store.isMouseInLayer) {
136
- scrollto({
137
- el: '#side-layerloader',
138
- to: {
139
- y: el,
140
- },
141
- offset: {
142
- y: -(ph.value / 2.5),
143
- },
144
- time: 600,
145
- });
136
+ if (import.meta.client) {
137
+ const el = document.getElementById(`LID${newActive.replace(/\./g, '')}`);
138
+ if (el && !store.isMouseInLayer) {
139
+ scrollto({
140
+ el: '#side-layerloader',
141
+ to: {
142
+ y: el,
143
+ },
144
+ offset: {
145
+ y: -(ph.value / 2.5),
146
+ },
147
+ time: 600,
148
+ });
149
+ }
146
150
  }
147
151
  });
148
152
  },
@@ -108,7 +108,7 @@
108
108
  watch(
109
109
  () => props.limit,
110
110
  () => {
111
- const _cache = JSON.parse(localStorage.getItem(`${state.name}_limit`) || '{}');
111
+ const _cache = import.meta.client ? JSON.parse(localStorage.getItem(`${state.name}_limit`) || '{}') : {};
112
112
  state.limit = deepcopy(props.limit)?.map((item: any) => {
113
113
  if (_cache[item.field] && Object.prototype.hasOwnProperty.call(_cache[item.field], '_close')) {
114
114
  item._close = Number(_cache[item.field]?._close);
@@ -159,7 +159,7 @@
159
159
  }
160
160
  }
161
161
  });
162
- localStorage.setItem(`${state.name}_limit`, JSON.stringify(_limit));
162
+ if (import.meta.client) localStorage.setItem(`${state.name}_limit`, JSON.stringify(_limit));
163
163
  },
164
164
  { deep: true },
165
165
  );
@@ -70,8 +70,10 @@
70
70
 
71
71
  const ph = ref(0);
72
72
  onMounted(() => {
73
- const side = document.getElementById('side-layerloader');
74
- ph.value = side?.clientHeight || 0;
73
+ if (import.meta.client) {
74
+ const side = document.getElementById('side-layerloader');
75
+ ph.value = side?.clientHeight || 0;
76
+ }
75
77
  });
76
78
 
77
79
  // 计算路径
@@ -264,7 +264,7 @@
264
264
  watch(
265
265
  () => props.table,
266
266
  () => {
267
- const _cache = JSON.parse(localStorage.getItem(`${name}_table`) || '{}');
267
+ const _cache = import.meta.client ? JSON.parse(localStorage.getItem(`${name}_table`) || '{}') : {};
268
268
  state.__last = 0;
269
269
  state.table = deepcopy(props.table || [])
270
270
  ?.map((col: TableColumn, idx: number) => {
@@ -340,7 +340,7 @@
340
340
  state.__last = idx;
341
341
  }
342
342
  });
343
- localStorage.setItem(`${name}_table`, JSON.stringify(_table));
343
+ if (import.meta.client) localStorage.setItem(`${name}_table`, JSON.stringify(_table));
344
344
  },
345
345
  { deep: true },
346
346
  );
@@ -38,7 +38,7 @@
38
38
  const props: any = defineProps({
39
39
  area: {
40
40
  type: [Object, HTMLElement],
41
- default: () => (typeof document !== 'undefined' ? document.body : null),
41
+ default: () => (import.meta.client ? document.body : null),
42
42
  },
43
43
  data: {
44
44
  type: Object,
@@ -128,7 +128,7 @@
128
128
  );
129
129
 
130
130
  const fScrollToField = (path: any) => {
131
- if (typeof document === 'undefined') return;
131
+ if (!import.meta.client) return;
132
132
  const dom = document.querySelector(path);
133
133
  if (dom) {
134
134
  scrollTo({
@@ -210,12 +210,14 @@
210
210
  const size = (size: any) => {
211
211
  emits('update:modelValue', { ...props.modelValue, ...{ [props.defined.pageSize || 'pageSize']: size } });
212
212
  emits('size', size);
213
- window.localStorage.setItem(state.id, `${size}`);
213
+ if (import.meta.client) window.localStorage.setItem(state.id, `${size}`);
214
214
  };
215
215
 
216
216
  // 缓存
217
- const cache = window.localStorage.getItem(state.id);
218
- if (cache) {
219
- size(Number(cache));
217
+ if (import.meta.client) {
218
+ const cache = window.localStorage.getItem(state.id);
219
+ if (cache) {
220
+ size(Number(cache));
221
+ }
220
222
  }
221
223
  </script>
@@ -216,6 +216,6 @@
216
216
  const size = (size: any) => {
217
217
  emits('update:modelValue', { ...props.modelValue, ...{ pageSize: size } });
218
218
  emits('size', size);
219
- window.localStorage.setItem(state.id, `${size}`);
219
+ if (import.meta.client) window.localStorage.setItem(state.id, `${size}`);
220
220
  };
221
221
  </script>