@mixd-id/web-scaffold 0.1.230406384 → 0.1.230406385

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.230406384",
4
+ "version": "0.1.230406385",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -14,6 +14,7 @@
14
14
  "./components/*": "./src/components/*",
15
15
  "./widgets/*": "./src/widgets/*",
16
16
  "./mixin/component": "./src/mixin/component.js",
17
+
17
18
  "./mixin/edit-mode": "./src/mixin/edit-mode.js",
18
19
  "./middleware/http/trim-string": "./src/middleware/http/trim-string.js",
19
20
  "./helpers": {
@@ -27,7 +27,6 @@
27
27
  </div>
28
28
 
29
29
  <div class="flex-1 flex flex-col relative">
30
- <div class="absolute bottom-0 left-0 w-[20px] h-[20px] z-10" @click="log(dataItems);log(sorts)"></div>
31
30
 
32
31
  <div class="flex-1 flex flex-col" :class="containerClass">
33
32
  <slot name="head"
@@ -597,6 +596,22 @@ export default{
597
596
  }
598
597
  },
599
598
 
599
+ sortItems(items){
600
+
601
+ if((this.sorts ?? []).length > 0){
602
+ return (items ?? []).sort((a, b) => {
603
+ return sortsFn(a, b, this.sorts, 0)
604
+ })
605
+ }
606
+ else if((this.preset.sorts ?? []).length > 0){
607
+ return (items ?? []).sort((a, b) => {
608
+ return sortsFn(a, b, this.preset.sorts, 0)
609
+ })
610
+ }
611
+ return items
612
+
613
+ },
614
+
600
615
  loadQueued(items){
601
616
  const key = items[0] && items[0].uid ? 'uid' : 'id'
602
617
 
@@ -605,10 +620,21 @@ export default{
605
620
  [key]: items.map(item => item[key])
606
621
  })
607
622
  .then(({ items:nextItems }) => {
608
- nextItems.forEach(item => this.$util.unshift(this.data.items, item, { highlight: true }))
609
623
 
610
624
  const destroyedItems = items.filter(_ => !nextItems.find(i => i[key] === _[key]))
611
625
  this.$util.remove(this.data.items, destroyedItems)
626
+
627
+ let currentFirstItem = this.dataItems[0]
628
+ const sortedItems = this.sortItems([
629
+ ...nextItems,
630
+ currentFirstItem
631
+ ]
632
+ .filter(_ => _))
633
+
634
+ for(let item of sortedItems){
635
+ if(item === currentFirstItem) break
636
+ this.$util.unshift(this.data.items, item, { highlight: true })
637
+ }
612
638
  })
613
639
  },
614
640
 
@@ -920,20 +946,7 @@ export default{
920
946
  },
921
947
 
922
948
  dataItems(){
923
-
924
- if((this.sorts ?? []).length > 0){
925
- return (this.data.items ?? []).sort((a, b) => {
926
- return sortsFn(a, b, this.sorts, 0)
927
- })
928
- }
929
- else if((this.preset.sorts ?? []).length > 0){
930
- return (this.data.items ?? []).sort((a, b) => {
931
- return sortsFn(a, b, this.preset.sorts, 0)
932
- })
933
- }
934
- else{
935
- return this.data.items ?? []
936
- }
949
+ return this.sortItems(this.data.items)
937
950
  },
938
951
 
939
952
  preset(){
@@ -319,6 +319,17 @@ function unslugAndCapitalize(slug) {
319
319
  .join(' ');
320
320
  }
321
321
 
322
+ function slugify(text) {
323
+ return text
324
+ .toString() // Ensure the input is a string
325
+ .normalize('NFD') // Normalize to decompose diacritic marks
326
+ .replace(/[\u0300-\u036f]/g, '') // Remove diacritic marks
327
+ .replace(/[^a-zA-Z0-9\s-]/g, '') // Remove special characters
328
+ .trim() // Trim leading/trailing spaces
329
+ .replace(/\s+/g, '-') // Replace spaces with dashes
330
+ .toLowerCase(); // Convert to lowercase
331
+ }
332
+
322
333
  const hexToRgb = (hex) => {
323
334
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
324
335
  return result ? {
@@ -393,7 +404,7 @@ const invokeAfterIdle = (callback, delay = 1300) => {
393
404
  const queueForLater = (params) => {
394
405
 
395
406
  const instance = {
396
- delay: 1500,
407
+ delay: 1200,
397
408
  ...params,
398
409
 
399
410
  items: [],
@@ -443,6 +454,7 @@ export {
443
454
  removeStyleFromTag,
444
455
  createFormData,
445
456
  unslugAndCapitalize,
457
+ slugify,
446
458
  applyDatasourceReplacer,
447
459
  strVars,
448
460
  invokeAfterIdle,