@mixd-id/web-scaffold 0.1.230406160 → 0.1.230406161

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.230406160",
4
+ "version": "0.1.230406161",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -235,11 +235,11 @@ export default{
235
235
  },
236
236
 
237
237
  isSelected(to){
238
- if(to){
238
+ /*if(to){
239
239
  this.$el.scrollIntoView({
240
240
  behavior: 'smooth',
241
241
  })
242
- }
242
+ }*/
243
243
  }
244
244
 
245
245
  },
@@ -4,7 +4,7 @@
4
4
  <div>
5
5
  <div class="grid grid-cols-2 gap-4">
6
6
 
7
- <div v-if="item.props.direction">
7
+ <div>
8
8
  <label class="text-text-400">Direction</label>
9
9
  <Dropdown v-for="(_, idx) in viewTypes"
10
10
  v-show="viewType === _.value"
@@ -18,7 +18,7 @@
18
18
  </Dropdown>
19
19
  </div>
20
20
 
21
- <div v-if="Array.isArray(item.props.gap)">
21
+ <div>
22
22
  <label class="text-text-400">Gap</label>
23
23
  <Dropdown v-for="(_, idx) in viewTypes"
24
24
  v-show="viewType === _.value"
@@ -38,50 +38,32 @@
38
38
  </Dropdown>
39
39
  </div>
40
40
 
41
- <div class="col-span-2 flex flex-col gap-4 hidden">
42
- <div>
43
- <label class="text-text-400">Columns</label>
44
- <ListItem :items="item.props.flexColumns">
45
- <template v-slot="{ item:obj, index }">
46
- <div class="flex flex-row gap-2 mb-1">
47
- <Dropdown v-for="(_, idx) in viewTypes"
48
- v-show="viewType === _.value"
49
- v-model="obj[idx]"
50
- class="w-[120px]"
51
- @change="$emit('change')">
52
- <option value="">Not Set</option>
53
- <option :value="`${viewType}basis-1/12`">1</option>
54
- <option :value="`${viewType}basis-2/12`">2</option>
55
- <option :value="`${viewType}basis-3/12`">3</option>
56
- <option :value="`${viewType}basis-4/12`">4</option>
57
- <option :value="`${viewType}basis-5/12`">5</option>
58
- <option :value="`${viewType}basis-6/12`">6</option>
59
- <option :value="`${viewType}basis-7/12`">7</option>
60
- <option :value="`${viewType}basis-8/12`">8</option>
61
- <option :value="`${viewType}basis-9/12`">9</option>
62
- <option :value="`${viewType}basis-10/12`">10</option>
63
- <option :value="`${viewType}basis-11/12`">11</option>
64
- <option :value="`${viewType}basis-full`">Full</option>
65
- </Dropdown>
66
- <button type="button" @click="item.props.flexColumns.splice(index, 1);$emit('change')()">Remove</button>
67
- </div>
68
- </template>
69
- </ListItem>
70
- <div class="text-center">
71
- <button type="button" class="p-3 text-primary" @click="item.props.flexColumns.push([ '', '' ])">Add Column</button>
72
- </div>
73
- </div>
41
+ <div>
42
+ <label class="text-text-400">Wrap</label>
43
+ <Dropdown v-for="(_, idx) in viewTypes"
44
+ v-show="viewType === _.value"
45
+ v-model="wrap[idx]"
46
+ class="w-[120px]"
47
+ @change="$emit('change')">
48
+ <option value="">Not Set</option>
49
+ <option :value="`${viewType}flex-wrap`">Wrap</option>
50
+ <option :value="`${viewType}flex-wrap-reverse`">Wrap reverse</option>
51
+ <option :value="`${viewType}flex-nowrap`">No wrap</option>
52
+ </Dropdown>
74
53
  </div>
75
54
 
76
55
  </div>
77
56
 
78
- <ComponentSetting :item="item"
79
- :view-type="viewType"
80
- :view-types="viewTypes"
81
- defaultDisplay="flex"
82
- @change="$emit('change')" />
57
+ <br />
58
+
83
59
  </div>
84
60
 
61
+ <ComponentSetting :item="item"
62
+ :view-type="viewType"
63
+ :view-types="viewTypes"
64
+ defaultDisplay="flex"
65
+ @change="$emit('change')" />
66
+
85
67
  </div>
86
68
  </template>
87
69
 
@@ -118,6 +100,13 @@ export default{
118
100
  this.item.props.gap = [ 'gap-2' ]
119
101
 
120
102
  return this.item.props.gap
103
+ },
104
+
105
+ wrap(){
106
+ if(!Array.isArray(this.item.props.wrap))
107
+ this.item.props.wrap = []
108
+
109
+ return this.item.props.wrap
121
110
  }
122
111
 
123
112
  }
@@ -6,14 +6,16 @@
6
6
 
7
7
  <div class="flex-1 flex flex-col overflow-y-auto">
8
8
 
9
- <div class="p-6 flex flex-row gap-4">
9
+ <div class="p-6 flex flex-row gap-4" @click="currentArea = 'header'">
10
10
  <button type="button" @click="$emit('close')">
11
11
  <svg width="18" height="18" class="fill-text" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M229.9 473.899l19.799-19.799c4.686-4.686 4.686-12.284 0-16.971L94.569 282H436c6.627 0 12-5.373 12-12v-28c0-6.627-5.373-12-12-12H94.569l155.13-155.13c4.686-4.686 4.686-12.284 0-16.971L229.9 38.101c-4.686-4.686-12.284-4.686-16.971 0L3.515 247.515c-4.686 4.686-4.686 12.284 0 16.971L212.929 473.9c4.686 4.686 12.284 4.686 16.971-.001z"/></svg>
12
12
  </button>
13
- <h4 class="whitespace-nowrap text-ellipsis overflow-hidden">{{ page.title }}</h4>
13
+ <div class="flex-1">
14
+ <h4 class="whitespace-nowrap text-ellipsis overflow-hidden">{{ page.title }}</h4>
15
+ </div>
14
16
  </div>
15
17
 
16
- <div class="flex flex-col items-center pb-6">
18
+ <div class="flex flex-col items-center pb-6" @click="currentArea = 'header'">
17
19
  <Tabs variant="button" :items="tabItems" v-model="store.tabIndex">
18
20
  <template #tab="{ item }">
19
21
  <div v-if="item.value === 1" v-tooltip="'Page Info'" class="p-1 px-2">
@@ -29,7 +31,7 @@
29
31
  </Tabs>
30
32
  </div>
31
33
 
32
- <div v-if="store.tabIndex === 1" class="flex flex-col gap-4 p-6">
34
+ <div v-if="store.tabIndex === 1" class="flex flex-col gap-4 p-6" @click="currentArea = 'pageinfo'">
33
35
 
34
36
  <div class="flex flex-row gap-4" v-if="!page.isSystem">
35
37
  <div class="flex flex-col gap-1">
@@ -104,7 +106,7 @@
104
106
  <div v-else-if="store.tabIndex === 2" class="flex-1 overflow-y-auto p-6 flex flex-col gap-6">
105
107
 
106
108
  <div>
107
- <div class="flex flex-row gap-2">
109
+ <div class="flex flex-row gap-2" @click="currentArea = 'layout'">
108
110
  <label class="flex-1 text-text-400">{{ $t('Layout')}}</label>
109
111
  <button type="button" class="text-primary" @click="store.layoutMode = !store.layoutMode">
110
112
  {{ store.layoutMode ? 'Hide Layout' : 'Show Layout' }}
@@ -144,13 +146,14 @@
144
146
  </div>
145
147
  </div>
146
148
 
147
- <div v-if="store.layoutMode && layout && useStyle" class="flex flex-row gap-2">
149
+ <div v-if="store.layoutMode && layout && useStyle" class="flex flex-row gap-2"
150
+ @click="currentArea = 'style'">
148
151
  <label class="flex-1 text-text-400">{{ $t('Style')}}</label>
149
152
  <button type="button" class="text-primary"
150
153
  @click="store.selectedComponent = [ 'style' ]">Edit Style</button>
151
154
  </div>
152
155
 
153
- <div v-if="store.layoutMode && layout">
156
+ <div v-if="store.layoutMode && layout" @click="currentArea = 'headers'">
154
157
  <div class="flex flex-row gap-2">
155
158
  <label class="flex-1 text-text-400">{{ $t('Header')}}</label>
156
159
  <button type="button" class="text-primary"
@@ -170,7 +173,7 @@
170
173
  </TreeView>
171
174
  </div>
172
175
 
173
- <div v-if="store.layoutMode && layout">
176
+ <div v-if="store.layoutMode && layout" @click="currentArea = 'footers'">
174
177
  <div class="flex flex-row gap-2">
175
178
  <label class="flex-1 text-text-400">{{ $t('Footer')}}</label>
176
179
  <button type="button" class="text-primary"
@@ -190,7 +193,7 @@
190
193
  </TreeView>
191
194
  </div>
192
195
 
193
- <div>
196
+ <div @click="currentArea = 'components'">
194
197
  <div class="flex flex-row gap-4">
195
198
  <label class="flex-1 text-text-400">{{ $t('Components')}}</label>
196
199
  <button type="button" class="text-primary"
@@ -216,7 +219,7 @@
216
219
 
217
220
  </div>
218
221
 
219
- <div v-else-if="store.tabIndex === 3" class="flex-1">
222
+ <div v-else-if="store.tabIndex === 3" class="flex-1" @click="currentArea = 'datasource'">
220
223
 
221
224
  <div class="p-6 flex flex-col gap-2">
222
225
  <div v-for="(ds, index) in page.datasource"
@@ -249,7 +252,7 @@
249
252
 
250
253
  </div>
251
254
 
252
- <div class="flex-1 flex flex-col bg-base-400">
255
+ <div class="flex-1 flex flex-col bg-base-400" @click="currentArea = 'preview'">
253
256
 
254
257
  <div class="p-3 sticky top-0 flex justify-center gap-4 bg-base-400 dark:bg-base-300 border-b-[1px] border-text-50">
255
258
  <div class="flex-1 flex flex-row gap-4 items-center">
@@ -312,6 +315,7 @@
312
315
  </div>
313
316
 
314
317
  <div v-if="currentItem" class="flex flex-col bg-base-400 dark:bg-base-300"
318
+ @click="currentArea = 'properties'"
315
319
  :style="section3Style">
316
320
 
317
321
  <div class="px-6 pt-6 pb-4 bg-base-300 flex flex-col">
@@ -514,46 +518,85 @@ export default{
514
518
 
515
519
  methods: {
516
520
 
517
- addComponent({ type, items, isLayout }){
521
+ addComponent({ type, items, isLayout }){
518
522
 
519
- let obj = this.availableComponents.find((_) => _.type === type)
520
- obj = JSON.parse(JSON.stringify(obj))
523
+ let obj = this.availableComponents.find((_) => _.type === type)
524
+ obj = JSON.parse(JSON.stringify(obj))
521
525
 
522
- Object.assign(obj.props, {
523
- enabled: true
524
- })
526
+ Object.assign(obj.props, {
527
+ enabled: true
528
+ })
525
529
 
526
- obj.uid = md5(obj.type + Math.random())
530
+ obj.uid = md5(obj.type + Math.random())
527
531
 
528
- items.push(obj)
532
+ items.push(obj)
529
533
 
530
- this.store.selectedComponent = [ obj.uid ]
534
+ this.store.selectedComponent = [ obj.uid ]
531
535
 
532
- this.$refs.webPageComponentSelector.close()
536
+ this.$refs.webPageComponentSelector.close()
533
537
 
534
538
  isLayout ? this.saveLayout() : this.save()
535
- },
539
+ },
536
540
 
537
- addDatasource(datasource){
541
+ addDatasource(datasource){
538
542
 
539
- if(!Array.isArray(this.page.datasource)){
540
- this.page.datasource = []
541
- }
543
+ if(!Array.isArray(this.page.datasource)){
544
+ this.page.datasource = []
545
+ }
542
546
 
543
- this.page.datasource.push(datasource)
547
+ this.page.datasource.push(datasource)
544
548
 
545
- this.save()
546
- },
549
+ this.save()
550
+ },
547
551
 
548
- removeDatasource(index){
549
- this.confirm({
550
- title:this.$t('Remove this item?'),
551
- onConfirm: () => {
552
- this.page.datasource.splice(index, 1)
553
- this.save()
554
- }
555
- })
556
- },
552
+ createLayout(layout){
553
+ this.page.layoutId = layout.id
554
+ this.save()
555
+ },
556
+
557
+ createComponentInstance(component){
558
+
559
+ const compUid = '_' + component.uid.substring(0, 4) + ' '
560
+
561
+ const instance = {
562
+ type: component.type,
563
+ uid: component.uid,
564
+
565
+ class: compUid + this.compClasses.map(key => {
566
+ return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
567
+ })
568
+ .filter(_ => _)
569
+ .join(' '),
570
+
571
+ containerClass: this.containerClasses.map(key => {
572
+ return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
573
+ })
574
+ .filter(_ => _)
575
+ .join(' '),
576
+
577
+ itemClass: this.itemClasses.map(key => {
578
+ return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
579
+ })
580
+ .filter(_ => _)
581
+ .join(' ')
582
+ }
583
+
584
+ for(let key in component.props){
585
+ if(!this.compClasses.includes(key) && ![ 'enabled' ].includes(key)){
586
+ instance[key] = component.props[key]
587
+ }
588
+ }
589
+
590
+ if(Array.isArray(component.items)){
591
+ instance.items = component.items.map((_) => this.createComponentInstance(_))
592
+ }
593
+
594
+ if(component.props && Array.isArray(component.props.items)){
595
+ instance.items = component.props.items
596
+ }
597
+
598
+ return instance
599
+ },
557
600
 
558
601
  copy(){
559
602
  if(!this.currentItem) return
@@ -616,6 +659,88 @@ export default{
616
659
  })
617
660
  },
618
661
 
662
+ onHooks(model, event, items){
663
+ if(model === 'page' && event === 'update'){
664
+ items.forEach((item) => {
665
+ if(item.id === this.page.id){
666
+ Object.assign(this.page, item)
667
+ //this.reloadIframe()
668
+ }
669
+ })
670
+ }
671
+ },
672
+
673
+ onMessage(event){
674
+
675
+ const { uid, type, value } = event.data ?? {}
676
+
677
+ let comp
678
+ let compType
679
+ if(uid){
680
+ comp = this.findCompByUid(uid, this.page.components)
681
+ if(!comp){
682
+ comp = this.findCompByUid(uid, this.layout.headers)
683
+ if(!comp){
684
+ comp = this.findCompByUid(uid, this.layout.footers)
685
+ if(comp){
686
+ compType = 'footers'
687
+ }
688
+ }
689
+ else{
690
+ compType = 'headers'
691
+ }
692
+ }
693
+ else{
694
+ compType = 'components'
695
+ }
696
+ }
697
+
698
+ switch(type){
699
+
700
+ case 'setProp':
701
+ if(comp){
702
+ Object.assign(comp.props, value)
703
+ compType === 'components' ? this.save(false) : this.saveLayout(false)
704
+ }
705
+ break
706
+
707
+ case 'setSubAction':
708
+ if(this.$refs.settingComponent && this.$refs.settingComponent.setSubAction)
709
+ this.$refs.settingComponent.setSubAction(value)
710
+ break
711
+
712
+ case 'component-click':
713
+ this.select(uid)
714
+ break
715
+ }
716
+ },
717
+
718
+ onPostMessageToIframe(uid, data){
719
+ this.$refs.iframe.contentWindow.postMessage({ uid, data }, '*')
720
+ },
721
+
722
+ onSave(reload){
723
+ if([ 'headers', 'footers', 'style' ].includes(this.store.selectedComponent[1])){
724
+ this.saveLayout(reload)
725
+ }
726
+ else{
727
+ this.save(reload)
728
+ }
729
+ },
730
+
731
+ postIframe(data){
732
+ return new Promise((resolve, reject) => {
733
+ const handleResponse = (e) => {
734
+ window.removeEventListener('message', handleResponse)
735
+ resolve(e.data)
736
+ }
737
+
738
+ window.addEventListener('message', handleResponse)
739
+
740
+ this.$refs.iframe.contentWindow.postMessage(data, '*')
741
+ })
742
+ },
743
+
619
744
  reloadIframe(){
620
745
  if(this.$refs.iframe && this.$refs.iframe.contentWindow){
621
746
  this.$refs.iframe.contentWindow.postMessage({
@@ -624,18 +749,15 @@ export default{
624
749
  }
625
750
  },
626
751
 
627
- postIframe(data){
628
- return new Promise((resolve, reject) => {
629
- const handleResponse = (e) => {
630
- window.removeEventListener('message', handleResponse)
631
- resolve(e.data)
632
- }
633
-
634
- window.addEventListener('message', handleResponse)
635
-
636
- this.$refs.iframe.contentWindow.postMessage(data, '*')
637
- })
638
- },
752
+ removeDatasource(index){
753
+ this.confirm({
754
+ title:this.$t('Remove this item?'),
755
+ onConfirm: () => {
756
+ this.page.datasource.splice(index, 1)
757
+ this.save()
758
+ }
759
+ })
760
+ },
639
761
 
640
762
  resize(){
641
763
 
@@ -726,64 +848,6 @@ export default{
726
848
  }
727
849
  },
728
850
 
729
- onSave(reload){
730
- if([ 'headers', 'footers', 'style' ].includes(this.store.selectedComponent[1])){
731
- this.saveLayout(reload)
732
- }
733
- else{
734
- this.save(reload)
735
- }
736
- },
737
-
738
- createLayout(layout){
739
- this.page.layoutId = layout.id
740
- this.save()
741
- },
742
-
743
- createComponentInstance(component){
744
-
745
- const compUid = '_' + component.uid.substring(0, 4) + ' '
746
-
747
- const instance = {
748
- type: component.type,
749
- uid: component.uid,
750
-
751
- class: compUid + this.compClasses.map(key => {
752
- return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
753
- })
754
- .filter(_ => _)
755
- .join(' '),
756
-
757
- containerClass: this.containerClasses.map(key => {
758
- return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
759
- })
760
- .filter(_ => _)
761
- .join(' '),
762
-
763
- itemClass: this.itemClasses.map(key => {
764
- return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
765
- })
766
- .filter(_ => _)
767
- .join(' ')
768
- }
769
-
770
- for(let key in component.props){
771
- if(!this.compClasses.includes(key) && ![ 'enabled' ].includes(key)){
772
- instance[key] = component.props[key]
773
- }
774
- }
775
-
776
- if(Array.isArray(component.items)){
777
- instance.items = component.items.map((_) => this.createComponentInstance(_))
778
- }
779
-
780
- if(component.props && Array.isArray(component.props.items)){
781
- instance.items = component.props.items
782
- }
783
-
784
- return instance
785
- },
786
-
787
851
  save: throttle(function(reload = true){
788
852
 
789
853
  if(!this.page.instances || typeof this.page.instances !== 'object' || Array.isArray(this.page.instances))
@@ -862,66 +926,6 @@ export default{
862
926
  .catch((err) => this.toast(err))
863
927
  },
864
928
 
865
- onHooks(model, event, items){
866
- if(model === 'page' && event === 'update'){
867
- items.forEach((item) => {
868
- if(item.id === this.page.id){
869
- Object.assign(this.page, item)
870
- //this.reloadIframe()
871
- }
872
- })
873
- }
874
- },
875
-
876
- onPostMessageToIframe(uid, data){
877
- this.$refs.iframe.contentWindow.postMessage({ uid, data }, '*')
878
- },
879
-
880
- onMessage(event){
881
-
882
- const { uid, type, value } = event.data ?? {}
883
-
884
- let comp
885
- let compType
886
- if(uid){
887
- comp = this.findCompByUid(uid, this.page.components)
888
- if(!comp){
889
- comp = this.findCompByUid(uid, this.layout.headers)
890
- if(!comp){
891
- comp = this.findCompByUid(uid, this.layout.footers)
892
- if(comp){
893
- compType = 'footers'
894
- }
895
- }
896
- else{
897
- compType = 'headers'
898
- }
899
- }
900
- else{
901
- compType = 'components'
902
- }
903
- }
904
-
905
- switch(type){
906
-
907
- case 'setProp':
908
- if(comp){
909
- Object.assign(comp.props, value)
910
- compType === 'components' ? this.save(false) : this.saveLayout(false)
911
- }
912
- break
913
-
914
- case 'setSubAction':
915
- if(this.$refs.settingComponent && this.$refs.settingComponent.setSubAction)
916
- this.$refs.settingComponent.setSubAction(value)
917
- break
918
-
919
- case 'component-click':
920
- this.select(uid)
921
- break
922
- }
923
- },
924
-
925
929
  remove(item){
926
930
  this.confirm(this.$t('Remove this item?'), {
927
931
  onConfirm: () => {
@@ -933,6 +937,15 @@ export default{
933
937
  })
934
938
  },
935
939
 
940
+ select(uid){
941
+ this.store.selectedComponent = [ uid ]
942
+
943
+ this.$refs.iframe.contentWindow.postMessage({
944
+ action: 'select',
945
+ uid
946
+ }, '*')
947
+ },
948
+
936
949
  setUid(item){
937
950
  item.uid = md5(Math.random())
938
951
 
@@ -1011,12 +1024,16 @@ export default{
1011
1024
  }, 500, { leading:true }),
1012
1025
 
1013
1026
  onKeyDown(e){
1014
- if(e.keyCode === 67 && (e.metaKey || e.ctrlKey)){
1015
- //this.copy()
1016
- }
1017
- else if(e.keyCode === 86 && (e.metaKey || e.ctrlKey)){
1018
- //this.paste(e)
1019
- }
1027
+
1028
+ if([ 'components' ].includes(this.currentArea)){
1029
+ if(e.keyCode === 67 && (e.metaKey || e.ctrlKey)){
1030
+ this.copy()
1031
+ }
1032
+ else if(e.keyCode === 86 && (e.metaKey || e.ctrlKey)){
1033
+ this.paste(e)
1034
+ }
1035
+ }
1036
+
1020
1037
  /*else if(e.keyCode === 8){
1021
1038
  if(this.currentItem){
1022
1039
  this.remove(this.currentItem)
@@ -1024,15 +1041,6 @@ export default{
1024
1041
  }*/
1025
1042
  },
1026
1043
 
1027
- select(uid){
1028
- this.store.selectedComponent = [ uid ]
1029
-
1030
- this.$refs.iframe.contentWindow.postMessage({
1031
- action: 'select',
1032
- uid
1033
- }, '*')
1034
- }
1035
-
1036
1044
  },
1037
1045
 
1038
1046
  computed: {
@@ -1246,6 +1254,7 @@ export default{
1246
1254
  { type:'Box', name:'Box', props:{ title:'Untitled Box' }, group:'Components' },
1247
1255
 
1248
1256
  ],
1257
+ currentArea: null,
1249
1258
  iframeStyle: {},
1250
1259
  iframeSrc: '',
1251
1260
  host: null,
@@ -1267,14 +1276,13 @@ export default{
1267
1276
 
1268
1277
  currentComponentItems: null,
1269
1278
 
1270
-
1271
1279
  compClasses: [
1272
1280
  'aspectRatio',
1273
1281
  'bdSize', 'bdColor', 'bdRadius', 'bdStyle',
1274
1282
  'bgColors', 'bgSize', 'bgPosition', 'bgRepeat',
1275
1283
  'gap',
1276
1284
  'padding', 'margin',
1277
- 'direction', 'columns', 'display',
1285
+ 'direction', 'columns', 'display', 'wrap',
1278
1286
  'width', 'minWidth', 'maxWidth',
1279
1287
  'height', 'minHeight', 'maxHeight',
1280
1288
  'fontFamily', 'fontSize', 'fontWeight', 'textColor', 'lineHeight', 'overflow',