@mixd-id/web-scaffold 0.1.230406233 → 0.1.230406235

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406233",
4
+ "version": "0.1.230406235",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -51,7 +51,7 @@ export default{
51
51
 
52
52
  gap: {
53
53
  type: [ String ],
54
- default: 'gap-6'
54
+ default: 'gap-0'
55
55
  },
56
56
 
57
57
  items: Array,
@@ -232,9 +232,16 @@ export default{
232
232
  this.resize()
233
233
  },
234
234
 
235
- items(to){
236
- this.resize()
237
- },
235
+ items: {
236
+ deep: true,
237
+ handler(to, from){
238
+ if((to ?? []).length !== (from ?? []).length){
239
+ this.scrollTop = 0
240
+ }
241
+
242
+ this.resize()
243
+ }
244
+ },
238
245
 
239
246
  }
240
247
 
@@ -210,10 +210,14 @@ export default{
210
210
 
211
211
  items: {
212
212
  deep: true,
213
- handler(){
214
- this.resize()
213
+ handler(to, from){
214
+ if((to ?? []).length !== (from ?? []).length){
215
+ this.scrollTop = 0
216
+ }
217
+
218
+ this.resize()
215
219
  }
216
- }
220
+ },
217
221
 
218
222
  }
219
223
 
@@ -241,11 +245,11 @@ export default{
241
245
  }
242
246
 
243
247
  .item:hover{
244
- @apply bg-primary-50;
248
+ @apply bg-text-50;
245
249
  }
246
250
 
247
251
  .item.trSelected{
248
- @apply bg-primary-100;
252
+ @apply bg-text-100;
249
253
  }
250
254
 
251
255
  .highlight{
@@ -405,7 +405,11 @@ export default{
405
405
 
406
406
  items: {
407
407
  deep: true,
408
- handler(){
408
+ handler(to, from){
409
+ if((to ?? []).length !== (from ?? []).length){
410
+ this.scrollTop = 0
411
+ }
412
+
409
413
  this.resize()
410
414
  }
411
415
  },
package/src/index.js CHANGED
@@ -2,6 +2,7 @@ import {defineAsyncComponent, ref} from "vue"
2
2
  import {observeInit} from './utils/helpers.mjs'
3
3
  import throttle from "lodash/throttle"
4
4
  import dayjs from "dayjs";
5
+ import groupBy from "lodash/groupBy";
5
6
 
6
7
  let _UNIQID = 0
7
8
  const uniqid = (additionalKey = '') => {
@@ -184,13 +185,35 @@ const util = {
184
185
  window.addEventListener('mouseup', onMouseUp)
185
186
  },
186
187
 
187
- push: (arr, item, opt = { key:"id" }) => {
188
- const index = arr.findIndex((_) => _[opt.key] === item[opt.key])
189
- if(index >= 0){
190
- Object.assign(arr[index], item)
188
+ push: (arr, items, opt = { key:"id" }) => {
189
+ if(!Array.isArray(arr)) return
190
+ if(!Array.isArray(items)) items = [ items ]
191
+
192
+ for(let item of items){
193
+ if(!item) continue
194
+
195
+ const index = arr.findIndex((_) => _[opt.key] === item[opt.key])
196
+ if(index >= 0){
197
+ Object.assign(arr[index], item)
198
+ }
199
+ else{
200
+ arr.push(item)
201
+ }
191
202
  }
192
- else{
193
- arr.push(item)
203
+ },
204
+
205
+ remove: (arr, sliced, opt = { key:'id' }) => {
206
+ if(!Array.isArray(arr)) return
207
+ if(!Array.isArray(sliced)) sliced = [ sliced ]
208
+
209
+ sliced = groupBy(sliced, opt.key)
210
+
211
+ for(let i = arr.length - 1 ; i >= 0 ; i--){
212
+ if(!arr[i]) continue
213
+
214
+ if(arr[i][opt.key] in sliced){
215
+ arr.splice(i, 1)
216
+ }
194
217
  }
195
218
  },
196
219