@mixd-id/web-scaffold 0.1.230406126 → 0.1.230406128

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.230406126",
4
+ "version": "0.1.230406128",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -30,6 +30,7 @@ export default {
30
30
  type: [ String, Number ],
31
31
  default: "primary" // primary|secondary|outline, default:primary
32
32
  },
33
+
33
34
  },
34
35
 
35
36
  computed: {
@@ -46,6 +47,7 @@ export default {
46
47
  .filter(_ => _)
47
48
  .join(' ')
48
49
  },
50
+
49
51
  },
50
52
  }
51
53
  </script>
@@ -50,15 +50,19 @@
50
50
  export default{
51
51
 
52
52
  props: {
53
+
53
54
  state: Object,
55
+
54
56
  mode: {
55
57
  type: String,
56
58
  default: 'alert' // alert | confirm
57
59
  },
60
+
58
61
  text: {
59
62
  type: String,
60
63
  default: 'OK'
61
- }
64
+ },
65
+
62
66
  },
63
67
 
64
68
  computed: {
@@ -13,9 +13,13 @@ import { parseBoolean, uid } from "../utils/helpers.mjs"
13
13
  export default{
14
14
 
15
15
  props:{
16
- modelValue: [ String, Number, Boolean ],
16
+
17
+ modelValue: undefined,
18
+
17
19
  trueValue: undefined,
18
- falseValue: undefined
20
+
21
+ falseValue: undefined,
22
+
19
23
  },
20
24
 
21
25
  computed: {
@@ -86,4 +90,4 @@ export default{
86
90
  .switch>input:not(:checked) + label + * + *{
87
91
  @apply hidden;
88
92
  }
89
- </style>
93
+ </style>
package/src/index.js CHANGED
@@ -399,7 +399,6 @@ export default{
399
399
  app.component('Testimonial', defineAsyncComponent(() => import("./components/Testimonial.vue")))
400
400
  app.component('TextBlock', defineAsyncComponent(() => import("./components/TextBlock.vue")))
401
401
  app.component('TextEditor', defineAsyncComponent(() => import("./components/TextEditor.vue")))
402
- app.component('PaddingBox', defineAsyncComponent(() => import("./components/PaddingBox.vue")))
403
402
 
404
403
  app.component('WebPageBuilder', defineAsyncComponent(() => import("./widgets/WebPageBuilder.vue")))
405
404
  app.component('WebPageSelector', defineAsyncComponent(() => import("./widgets/WebPageSelector.vue")))
@@ -443,6 +442,9 @@ export default{
443
442
  app.component('ImageSetting', defineAsyncComponent(() => import("./widgets/ImageSetting.vue")))
444
443
  app.component('MarginSetting', defineAsyncComponent(() => import("./widgets/MarginSetting.vue")))
445
444
  app.component('PaddingSetting', defineAsyncComponent(() => import("./widgets/PaddingSetting.vue")))
445
+ app.component('Review', defineAsyncComponent(() => import("./widgets/Review.vue")))
446
+ app.component('ReviewItem', defineAsyncComponent(() => import("./widgets/ReviewItem.vue")))
447
+ app.component('ReviewSetting', defineAsyncComponent(() => import("./widgets/ReviewSetting.vue")))
446
448
  app.component('Share', defineAsyncComponent(() => import("./widgets/Share.vue")))
447
449
  app.component('ShareItem', defineAsyncComponent(() => import("./widgets/ShareItem.vue")))
448
450
  app.component('ShareSetting', defineAsyncComponent(() => import("./widgets/ShareSetting.vue")))
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <div :class="$style.review" v-if="items && items.rate && items.count && Array.isArray(items.reviews)">
3
+
4
+ <div>
5
+ <h3>{{ title }}</h3>
6
+ </div>
7
+
8
+ <div class="flex flex-col md:flex-row md:gap-12">
9
+ <div class="md:w-[25%]">
10
+
11
+ <div class="flex flex-col gap-4">
12
+ <div class="p-3 rounded-lg text-center flex flex-col items-center">
13
+ <div class="flex flex-row items-baseline">
14
+ <h4 class="text-9xl text-primary">{{ items.rate.toFixed(1) }}</h4>
15
+ <strong class="text-lg">/ 5.0</strong>
16
+ </div>
17
+ <div>
18
+ <label>Total: {{ items.count }} ulasan</label>
19
+ </div>
20
+ </div>
21
+
22
+ <div class="flex flex-col gap-2">
23
+ <div class="flex flex-row items-center gap-4" v-for="i in 5">
24
+ <div class="flex flex-row gap-1">
25
+ <svg width="19" height="19" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"/></svg>
26
+ <div>{{ i }}</div>
27
+ </div>
28
+ <div class="flex-1">
29
+ <div :class="$style.bar">
30
+ <div :style="barStyle(items.countByRate ? items.countByRate[i] : 0, items.count)"></div>
31
+ </div>
32
+ </div>
33
+ <div class="w-[2rem] text-right">{{ items.countByRate ? items.countByRate[i] : 0 }}</div>
34
+ </div>
35
+ </div>
36
+
37
+ </div>
38
+ </div>
39
+
40
+ <div class="md:flex-1 py-6 flex flex-col divide-y divide-gray-200">
41
+
42
+ <div v-for="review in items.reviews" class="py-4 flex flex-col gap-2">
43
+ <div class="flex flex-row gap-4">
44
+ <div class="flex-1 flex flex-col gap-2">
45
+ <div class="flex flex-row gap-1">
46
+ <div v-for="i in 5">
47
+ <svg v-if="review.rate >= i" width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"/></svg>
48
+ <svg v-else width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M528.1 171.5L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6zM388.6 312.3l23.7 138.4L288 385.4l-124.3 65.3 23.7-138.4-100.6-98 139-20.2 62.2-126 62.2 126 139 20.2-100.6 98z"/></svg>
49
+ </div>
50
+ </div>
51
+ <p>{{ review.details ?? review.text }}</p>
52
+ </div>
53
+ <div v-if="review.imageUrl">
54
+ <Image :src="imageSrc(review.imageUrl)" class="w-[80px] aspect-square rounded-lg" />
55
+ </div>
56
+ </div>
57
+ <div class="flex flex-row gap-2">
58
+ <small class="text-gray-400">{{ review.name }}</small>
59
+ <div class="text-gray-400">&bull;</div>
60
+ <small class="text-gray-400">{{ timeOf(review.createdAt) }}</small>
61
+ </div>
62
+ </div>
63
+
64
+ </div>
65
+ </div>
66
+
67
+ </div>
68
+ </template>
69
+
70
+ <script>
71
+
72
+ import { componentMixin } from "../mixin/component";
73
+ import dayjs from "dayjs";
74
+
75
+ export default{
76
+
77
+ mixins: [ componentMixin ],
78
+
79
+ props: {
80
+
81
+ title: String,
82
+
83
+ items: Object
84
+
85
+ },
86
+
87
+ methods: {
88
+
89
+ barStyle(count, totalCount){
90
+ count = count > totalCount ? totalCount : count
91
+ const width = Math.round(count / totalCount * 100) + '%'
92
+ return {
93
+ width
94
+ }
95
+ },
96
+
97
+ timeOf(date){
98
+ return dayjs(date).format('D MMM YYYY HH:mm')
99
+ },
100
+
101
+
102
+ imageSrc(url){
103
+ return import.meta.env.VITE_IMAGE_HOST + '/' + url
104
+ }
105
+
106
+ },
107
+
108
+ }
109
+
110
+ </script>
111
+
112
+ <style module>
113
+
114
+ .review{
115
+ @apply relative flex flex-col gap-4;
116
+ background-image: v-bind(bgImages[0]);
117
+ }
118
+
119
+ .bar{
120
+ @apply h-[1rem] bg-gray-100 rounded-lg;
121
+ @apply relative;
122
+ }
123
+ .bar>*{
124
+ @apply absolute top-0 left-0 h-full bg-primary rounded-lg;
125
+ }
126
+
127
+ @media screen(md){
128
+ .review{
129
+ background-image: v-bind(bgImages[1]);
130
+ }
131
+ }
132
+
133
+ </style>
@@ -0,0 +1,25 @@
1
+ <template>
2
+ <div class="flex-1 flex flex-row items-center gap-2">
3
+ {{ item.props.name ?? item.type }}
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+
9
+ export default{
10
+
11
+ props: {
12
+ item: Object
13
+ }
14
+
15
+ }
16
+
17
+ </script>
18
+
19
+ <style module>
20
+
21
+ .comp{
22
+
23
+ }
24
+
25
+ </style>
@@ -0,0 +1,192 @@
1
+ <template>
2
+ <div :class="$style.comp">
3
+
4
+ <div class="flex flex-col gap-1">
5
+ <label class="text-text-400">Title</label>
6
+ <Textbox v-model="item.props.title" maxlength="40" @keyup.enter="$emit('change')" placeholder="Title" />
7
+ </div>
8
+
9
+ <div class="flex flex-col gap-1">
10
+ <label class="text-text-400">Mode</label>
11
+ <Dropdown v-model="item.props.mode" @change="item.props.items = { reviews:[] }">
12
+ <option value="">Static</option>
13
+ <option value="dynamic">Dynamic</option>
14
+ </Dropdown>
15
+ <Textbox v-if="item.props.mode === 'dynamic'"
16
+ placeholder="Var" v-model="item.props.src"
17
+ @blur="$emit('change')"
18
+ @keyup.enter="$emit('change')" />
19
+ </div>
20
+
21
+ <div v-if="item.props.mode !== 'dynamic'">
22
+ <div class="flex flex-row gap-2">
23
+ <label class="flex-1 text-text-400">Reviews</label>
24
+ <button type="button" class="text-primary" @click="$refs.reviewModal.open({ item:{} })">Add Review</button>
25
+ </div>
26
+ <div class="mt-1">
27
+ <ListItem :items="items.reviews"
28
+ @reorder="(from, to) => { items.reviews.splice(to, 0, items.reviews.splice(from, 1)[0]); calcReview(); $emit('change') }">
29
+ <template v-slot="{ item, index }">
30
+ <div class="flex flex-row items-center gap-3 p-2">
31
+ <div data-reorder>
32
+ <svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
33
+ </div>
34
+ <div class="flex-1 cursor-pointer" @click="$refs.reviewModal.open({ item, index })">
35
+ <p class="line-clamp-1">
36
+ <span class="w-[19px] aspect-square rounded-full bg-primary text-white inline-flex items-center justify-center">
37
+ {{ item.rate }}
38
+ </span>
39
+ {{ item.text }}
40
+ </p>
41
+ </div>
42
+ <button type="button" @click="confirm($t('Remove this item?'), '', () => { items.reviews.splice(index, 1); calcReview(); $emit('change') })">
43
+ <svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"/></svg>
44
+ </button>
45
+ </div>
46
+ </template>
47
+ </ListItem>
48
+ </div>
49
+ </div>
50
+
51
+ <Modal ref="reviewModal" width="360" height="420">
52
+ <template v-slot:head>
53
+ <div class="relative p-6">
54
+ <h3>Review</h3>
55
+ <div class="absolute top-0 right-0 p-2">
56
+ <button type="button" class="p-2" @click="$refs.reviewModal.close()">
57
+ <svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
58
+ <path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
59
+ </svg>
60
+ </button>
61
+ </div>
62
+ </div>
63
+ </template>
64
+ <template v-slot:foot="{ context }">
65
+ <div class="p-6 flex flex-row gap-3">
66
+ <Button class="w-[100px]"
67
+ :state="!canSaveReview(context.item) ? -1 : 1"
68
+ @click="addReview(context.item, context.index); $refs.reviewModal.close()">
69
+ Add Review
70
+ </Button>
71
+ <Button class="w-[100px]" variant="secondary"
72
+ :state="!canSaveReview(context.item) ? -1 : 1"
73
+ @click="addReview(context.item, context.index); Object.assign(context, { item:{}, index:-1 })">
74
+ Add More
75
+ </Button>
76
+ </div>
77
+ </template>
78
+ <template #default="{ context }">
79
+ <div class="flex-1 p-6 flex flex-col gap-3">
80
+ <div>
81
+ <Dropdown v-model="context.item.rate" class="w-[120px]">
82
+ <option :value="5">5</option>
83
+ <option :value="4">4</option>
84
+ <option :value="3">3</option>
85
+ <option :value="2">2</option>
86
+ <option :value="1">1</option>
87
+ </Dropdown>
88
+ </div>
89
+ <div>
90
+ <Textbox v-model="context.item.text" class="flex-1" placeholder="Text"/>
91
+ </div>
92
+ <div class="flex flex-col gap-2">
93
+ <div class="flex flex-row gap-3">
94
+ <Textbox v-model="context.item.name" class="flex-1" placeholder="Nama"/>
95
+ <Datepicker mode="popup" v-model="context.item.date" class="w-[100px]" />
96
+ <Textbox v-model="context.item.time" class="w-[80px]" maxlength="5" />
97
+ </div>
98
+ </div>
99
+ <div>
100
+ <Image ref="currentReviewImage" :src="context.item.imageUrl"
101
+ class="w-[96px] aspect-square bg-text-50 rounded-lg"
102
+ :editable="true"
103
+ @click="$refs.currentReviewImage.edit()"
104
+ @change="(_, file) => context.item.imageUrl = file" />
105
+ </div>
106
+ </div>
107
+ </template>
108
+ </Modal>
109
+
110
+ <ComponentSetting :item="item"
111
+ :view-type="viewType"
112
+ :view-types="viewTypes"
113
+ defaultDisplay="flex"
114
+ @change="$emit('change')" />
115
+
116
+ </div>
117
+ </template>
118
+
119
+ <script>
120
+
121
+ import dayjs from "dayjs";
122
+
123
+ export default{
124
+
125
+ emits: [ 'change' ],
126
+
127
+ inject: [ 'confirm', 'socketEmit2' ],
128
+
129
+ methods: {
130
+
131
+ addReview(review, index){
132
+ review.createdAt = review.date + ' ' + review.time
133
+
134
+ if(index >= 0){
135
+ Object.assign(this.items.reviews[index], review)
136
+ }
137
+ else{
138
+ this.items.reviews.push(review)
139
+ }
140
+ this.calcReview()
141
+ this.$emit('change')
142
+ },
143
+
144
+ calcReview(){
145
+ this.items.count = this.items.reviews.length
146
+ this.items.rate = this.items.reviews.reduce((acc, cur) => acc + parseInt(cur.rate), 0) / this.items.count
147
+ },
148
+
149
+ save(){
150
+ this.$emit('save')
151
+ this.close()
152
+ },
153
+
154
+ canSaveReview(item){
155
+ const date = dayjs(item.date + ' ' + item.time)
156
+ return item.rate && item.text && item.name &&
157
+ date.format('YYYY-MM-DD') === item.date && date.format('HH:mm') === item.time
158
+ }
159
+
160
+ },
161
+
162
+ props: {
163
+
164
+ item: Object,
165
+
166
+ viewType: String,
167
+ viewTypes: Array,
168
+
169
+ },
170
+
171
+ computed: {
172
+
173
+ items(){
174
+ if(!this.item.props.items){
175
+ this.item.props.items = { reviews:[] }
176
+ }
177
+ return this.item.props.items
178
+ }
179
+
180
+ }
181
+
182
+ }
183
+
184
+ </script>
185
+
186
+ <style module>
187
+
188
+ .comp{
189
+ @apply flex flex-col gap-4;
190
+ }
191
+
192
+ </style>
@@ -1072,6 +1072,10 @@ export default{
1072
1072
  items:[], columns:[], variant:['variant1'],
1073
1073
  }},
1074
1074
 
1075
+ { type:'Review', name:'Review', group:'Widgets', props:{
1076
+ channels:[],
1077
+ }},
1078
+
1075
1079
  { type:'Share', name:'Share To', group:'Widgets', props:{
1076
1080
  channels:[],
1077
1081
  }},
@@ -1,134 +0,0 @@
1
- <template>
2
- <div :class="$style.comp">
3
- <div class="flex flex-row gap-1">
4
- <button v-if="types.includes(1)" type="button" @click="setType(1)">
5
- <svg width="12" height="12" class="fill-text" :class="{ 'fill-primary-500':type === 1 }" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm16 400c0 8.8-7.2 16-16 16H48c-8.8 0-16-7.2-16-16V80c0-8.8 7.2-16 16-16h352c8.8 0 16 7.2 16 16v352z"/></svg>
6
- </button>
7
- <button v-if="types.includes(2)" type="button" @click="setType(2)">
8
- <svg width="12" height="12" class="fill-text" :class="{ 'fill-primary-500':type === 2 }" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M120 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h72a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8H48a16 16 0 0 1-16-16V80a16 16 0 0 1 16-16h72a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8zm280 0h-72a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h72a16 16 0 0 1 16 16v352a16 16 0 0 1-16 16h-72a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h72a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48z"/></svg>
9
- </button>
10
- <button v-if="types.includes(4)" type="button" @click="setType(4)">
11
- <svg width="12" height="12" class="fill-text" :class="{ 'fill-primary-500':type === 4 }" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48H48C21.49 32 0 53.49 0 80zm240-16v176H32V80c0-8.837 7.163-16 16-16h192zM32 432V272h208v176H48c-8.837 0-16-7.163-16-16zm240 16V272h208v160c0 8.837-7.163 16-16 16H272zm208-208H272V64h192c8.837 0 16 7.163 16 16v160z"/></svg>
12
- </button>
13
- </div>
14
- <div class="grid gap-1" :class="type >= 4 ? 'grid-cols-4' : 'grid-cols-2'">
15
- <select v-if="type >= 1" :value="values[0]"
16
- @change="(e) => setValue(0, e.target.value)">
17
- <option v-for="obj in opts" :value="obj.value">{{ obj.text ?? obj.value }}</option>
18
- </select>
19
- <select v-if="type >= 2" :value="values[1]"
20
- @change="(e) => setValue(1, e.target.value)">
21
- <option v-for="obj in opts" :value="obj.value">{{ obj.text ?? obj.value }}</option>
22
- </select>
23
- <select v-if="type >= 4" :value="values[2]"
24
- @change="(e) => setValue(2, e.target.value)">
25
- <option v-for="obj in opts" :value="obj.value">{{ obj.text ?? obj.value }}</option>
26
- </select>
27
- <select v-if="type >= 4" :value="values[3]"
28
- @change="(e) => setValue(3, e.target.value)">
29
- <option v-for="obj in opts" :value="obj.value">{{ obj.text ?? obj.value }}</option>
30
- </select>
31
- </div>
32
- </div>
33
- </template>
34
-
35
- <script>
36
-
37
- export default{
38
-
39
- emits: [ 'change', 'update:modelValue' ],
40
-
41
- props: {
42
-
43
- modelValue: String,
44
-
45
- types: {
46
- type: Array,
47
- default: [ 1, 2, 4 ]
48
- },
49
-
50
- opts: {
51
- type: Array,
52
- default: [
53
- { text:'0', value:'' },
54
- { text:'1', value:'1' },
55
- { text:'2', value:'2' },
56
- { text:'3', value:'3' },
57
- { text:'4', value:'4' },
58
- { text:'5', value:'5' },
59
- { text:'6', value:'6' },
60
- { text:'7', value:'7' },
61
- { text:'8', value:'8' },
62
- ]
63
- }
64
-
65
- },
66
-
67
- methods: {
68
-
69
- setType(type){
70
- let v
71
- switch(type){
72
- case 1:
73
- v = [ this.values[0] ]
74
- break
75
- case 2:
76
- v = [ this.values[0], this.values[1] ?? '0' ]
77
- break
78
- case 4:
79
- v = [
80
- this.values[0],
81
- this.values[1] ?? '0',
82
- this.values[2] ?? '0',
83
- this.values[3] ?? '0'
84
- ]
85
- break
86
- }
87
-
88
- if(Array.isArray(v)){
89
- this.$emit('update:modelValue', v.join(','))
90
- this.$emit('change')
91
- }
92
- },
93
-
94
- setValue(idx, value){
95
- const v = [ ...this.values ]
96
- v[idx] = value
97
- this.$emit('update:modelValue', v.join(','))
98
- this.$emit('change')
99
- }
100
-
101
- },
102
-
103
- computed: {
104
-
105
- type(){
106
- return (this.modelValue ?? '').split(',').length
107
- },
108
-
109
- values(){
110
- return (this.modelValue ?? '').split(',')
111
- }
112
-
113
- }
114
-
115
- }
116
-
117
- </script>
118
-
119
- <style module>
120
-
121
- .comp{
122
- @apply flex flex-col gap-1;
123
- }
124
-
125
- .comp button{
126
- @apply border-[1px] border-text-200 bg-text-100 rounded-lg p-1 px-3;
127
- }
128
-
129
- .comp select{
130
- @apply appearance-none outline-none p-1 px-2 bg-transparent cursor-pointer w-full;
131
- @apply border-[1px] border-text-200 rounded-lg;
132
- }
133
-
134
- </style>