@mixd-id/web-scaffold 0.1.230406037 → 0.1.230406039
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 +1 -1
- package/src/components/Checkbox.vue +57 -51
- package/src/components/Countdown.vue +38 -27
- package/src/components/Radio.vue +37 -87
- package/src/utils/helpers.mjs +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="$style.comp">
|
|
3
|
-
<input :id="id" type="checkbox" :checked="
|
|
3
|
+
<input :id="id" type="checkbox" :checked="checked" @change="onChange" :disabled="isDisabled"/>
|
|
4
4
|
<label :for="id">
|
|
5
5
|
<div :class="$style.indicator">
|
|
6
6
|
<Transition name="checkbox">
|
|
7
|
-
<div v-if="
|
|
7
|
+
<div v-if="checked">
|
|
8
8
|
<svg width="14" height="14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
9
9
|
</div>
|
|
10
10
|
</Transition>
|
|
@@ -18,19 +18,14 @@
|
|
|
18
18
|
|
|
19
19
|
import { parseBoolean } from "../utils/helpers.mjs";
|
|
20
20
|
|
|
21
|
-
export default{
|
|
21
|
+
export default {
|
|
22
22
|
|
|
23
23
|
props:{
|
|
24
|
-
name: String,
|
|
25
|
-
checked: undefined,
|
|
26
|
-
value: undefined,
|
|
27
|
-
|
|
28
24
|
modelValue: undefined,
|
|
25
|
+
value: undefined,
|
|
29
26
|
trueValue: undefined,
|
|
30
27
|
falseValue: undefined,
|
|
31
|
-
|
|
32
|
-
customClass: String,
|
|
33
|
-
variant: String, // default
|
|
28
|
+
disabled: undefined
|
|
34
29
|
},
|
|
35
30
|
|
|
36
31
|
computed: {
|
|
@@ -39,28 +34,25 @@ export default{
|
|
|
39
34
|
return this.$style.comp + this.uniqid()
|
|
40
35
|
},
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const isArray = Array.isArray(this.modelValue)
|
|
37
|
+
isDisabled(){
|
|
38
|
+
return parseBoolean(this.disabled)
|
|
39
|
+
},
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
else if(this.trueValue){
|
|
53
|
-
checked = isArray ? this.modelValue.includes(this.trueValue) :
|
|
54
|
-
this.modelValue === this.trueValue
|
|
41
|
+
checked(){
|
|
42
|
+
if(this.value !== undefined){
|
|
43
|
+
if(Array.isArray(this.modelValue)){
|
|
44
|
+
return this.modelValue.includes(this.value)
|
|
55
45
|
}
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
else{
|
|
47
|
+
return this.value === this.modelValue
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
else if(this.trueValue && this.falseValue) {
|
|
51
|
+
return this.modelValue === this.trueValue
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return parseBoolean(this.modelValue)
|
|
55
|
+
}
|
|
64
56
|
}
|
|
65
57
|
|
|
66
58
|
},
|
|
@@ -69,30 +61,40 @@ export default{
|
|
|
69
61
|
|
|
70
62
|
onChange(e){
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
let value
|
|
65
|
+
|
|
66
|
+
if(this.value !== undefined){
|
|
67
|
+
if(Array.isArray(this.modelValue)){
|
|
68
|
+
if(e.target.checked){
|
|
69
|
+
this.modelValue.push(this.value)
|
|
70
|
+
this.modelValue.filter((value, index, self) => self.indexOf(value) === index)
|
|
71
|
+
}
|
|
72
|
+
else{
|
|
73
|
+
this.modelValue.splice(this.modelValue.indexOf(this.value), 1)
|
|
74
|
+
}
|
|
82
75
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if(this.value !== undefined) value = null
|
|
86
|
-
else if(this.falseValue) value = this.falseValue
|
|
87
|
-
else value = false
|
|
88
|
-
|
|
89
|
-
if(this.modelValue && Array.isArray(this.modelValue)){
|
|
90
|
-
value = this.modelValue.filter((v) => {
|
|
91
|
-
return v !== this.value ?? (this.falseValue ?? false)
|
|
92
|
-
})
|
|
76
|
+
else if(e.target.checked){
|
|
77
|
+
value = this.value
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
|
-
|
|
80
|
+
else if(this.trueValue !== undefined && this.falseValue !== undefined) {
|
|
81
|
+
if(Array.isArray(this.modelValue)){
|
|
82
|
+
if(e.target.checked){
|
|
83
|
+
this.modelValue.push(this.trueValue)
|
|
84
|
+
this.modelValue.filter((value, index, self) => self.indexOf(value) === index)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else{
|
|
88
|
+
value = e.target.checked ? this.trueValue : this.falseValue
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else{
|
|
92
|
+
value = e.target.checked
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if(value !== undefined){
|
|
96
|
+
this.$emit('update:modelValue', value)
|
|
97
|
+
}
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
}
|
|
@@ -118,13 +120,17 @@ export default{
|
|
|
118
120
|
.comp input{
|
|
119
121
|
@apply hidden;
|
|
120
122
|
}
|
|
123
|
+
.comp input[disabled] + label{
|
|
124
|
+
@apply opacity-70;
|
|
125
|
+
@apply cursor-not-allowed;
|
|
126
|
+
}
|
|
121
127
|
|
|
122
128
|
.indicator{
|
|
123
129
|
@apply w-[21px] h-[21px] border-[1px] rounded-lg border-text-200 bg-base-50;
|
|
124
130
|
@apply flex items-center justify-center overflow-hidden;
|
|
125
131
|
transition: border 300ms cubic-bezier(0.25, 1, 0.5, 1);
|
|
126
132
|
}
|
|
127
|
-
.comp:hover
|
|
133
|
+
.comp:hover input:not([disabled]) + label>.indicator{
|
|
128
134
|
@apply border-primary;
|
|
129
135
|
}
|
|
130
136
|
|
|
@@ -153,4 +159,4 @@ export default{
|
|
|
153
159
|
opacity: 0;
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
</style>
|
|
162
|
+
</style>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<div></div>
|
|
7
7
|
<div></div>
|
|
8
8
|
</div>
|
|
9
|
+
<div v-if="display >= 4" class="mr-2">hari</div>
|
|
9
10
|
|
|
10
11
|
<slot v-if="display >= 3 && $slots.hour" name="hour" :hour="hour"></slot>
|
|
11
12
|
<div ref="hour" v-else-if="display >= 3" :class="$style.lap">
|
|
@@ -34,8 +35,6 @@
|
|
|
34
35
|
|
|
35
36
|
<script>
|
|
36
37
|
|
|
37
|
-
import debounce from "lodash/debounce";
|
|
38
|
-
|
|
39
38
|
export default{
|
|
40
39
|
|
|
41
40
|
props: {
|
|
@@ -75,13 +74,13 @@ export default{
|
|
|
75
74
|
timeoutId: null,
|
|
76
75
|
beforeSecond: null,
|
|
77
76
|
afterSecond: null,
|
|
78
|
-
tick: false
|
|
77
|
+
tick: false,
|
|
78
|
+
state: [ 0, 0, 0, 0 ]
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
|
|
82
82
|
mounted() {
|
|
83
83
|
this.start()
|
|
84
|
-
|
|
85
84
|
if(this.$refs.second) this.$refs.second.addEventListener('transitionend', this.onSecondEnd)
|
|
86
85
|
if(this.$refs.minute) this.$refs.minute.addEventListener('transitionend', this.onMinuteEnd)
|
|
87
86
|
if(this.$refs.hour) this.$refs.hour.addEventListener('transitionend', this.onHourEnd)
|
|
@@ -90,32 +89,40 @@ export default{
|
|
|
90
89
|
|
|
91
90
|
methods: {
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
onDayEnd:function (e){
|
|
93
|
+
if(this.state[0] !== 1) return
|
|
94
|
+
this.$refs.day.insertBefore(this.$refs.day.childNodes[1], this.$refs.day.childNodes[0])
|
|
95
|
+
this.$refs.day.classList.remove(this.$style.tick)
|
|
96
|
+
this.$refs.day.childNodes[0].innerHTML = ''
|
|
97
|
+
this.state[0] = 0
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
onHourEnd: function (e){
|
|
101
|
+
if(this.state[1] !== 1) return
|
|
102
|
+
this.$refs.hour.insertBefore(this.$refs.hour.childNodes[1], this.$refs.hour.childNodes[0])
|
|
103
|
+
this.$refs.hour.classList.remove(this.$style.tick)
|
|
104
|
+
this.$refs.hour.childNodes[0].innerHTML = ''
|
|
105
|
+
this.state[1] = 0
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
onMinuteEnd: function (e){
|
|
109
|
+
if(this.state[2] !== 1) return
|
|
110
|
+
this.$refs.minute.insertBefore(this.$refs.minute.childNodes[1], this.$refs.minute.childNodes[0])
|
|
111
|
+
this.$refs.minute.classList.remove(this.$style.tick)
|
|
112
|
+
this.$refs.minute.childNodes[0].innerHTML = ''
|
|
113
|
+
this.state[2] = 0
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
onSecondEnd: function (e){
|
|
117
|
+
if(this.state[3] !== 1) return
|
|
94
118
|
this.$refs.second.insertBefore(this.$refs.second.childNodes[1], this.$refs.second.childNodes[0])
|
|
95
119
|
this.$refs.second.classList.remove(this.$style.tick)
|
|
96
120
|
this.$refs.second.childNodes[0].innerHTML = ''
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
onMinuteEnd: debounce(function (e){
|
|
100
|
-
this.$refs.minute.insertBefore(this.$refs.minute.childNodes[1], this.$refs.minute.childNodes[0])
|
|
101
|
-
this.$refs.minute.classList.remove(this.$style.tick)
|
|
102
|
-
this.$refs.minute.childNodes[0].innerHTML = ''
|
|
103
|
-
}, 100),
|
|
104
|
-
|
|
105
|
-
onHourEnd: debounce(function (e){
|
|
106
|
-
this.$refs.hour.insertBefore(this.$refs.hour.childNodes[1], this.$refs.hour.childNodes[0])
|
|
107
|
-
this.$refs.hour.classList.remove(this.$style.tick)
|
|
108
|
-
this.$refs.hour.childNodes[0].innerHTML = ''
|
|
109
|
-
}, 100),
|
|
110
|
-
|
|
111
|
-
onDayEnd: debounce(function (e){
|
|
112
|
-
this.$refs.day.insertBefore(this.$refs.day.childNodes[1], this.$refs.day.childNodes[0])
|
|
113
|
-
this.$refs.day.classList.remove(this.$style.tick)
|
|
114
|
-
this.$refs.day.childNodes[0].innerHTML = ''
|
|
115
|
-
}, 100),
|
|
121
|
+
this.state[3] = 0
|
|
122
|
+
},
|
|
116
123
|
|
|
117
124
|
setInitial(){
|
|
118
|
-
if(this.$refs.day) this.$refs.day.lastElementChild.innerHTML = '1
|
|
125
|
+
if(this.$refs.day) this.$refs.day.lastElementChild.innerHTML = '1'
|
|
119
126
|
if(this.$refs.hour) this.$refs.hour.lastElementChild.innerHTML = (Math.floor(this.timer / 3600) % 24).toString().padStart(2, '0')
|
|
120
127
|
if(this.$refs.minute) this.$refs.minute.lastElementChild.innerHTML = (Math.floor(this.timer / 60) % 60).toString().padStart(2, '0')
|
|
121
128
|
if(this.$refs.second) this.$refs.second.lastElementChild.innerHTML = (this.timer % 60).toString().padStart(2, '0')
|
|
@@ -141,7 +148,7 @@ export default{
|
|
|
141
148
|
|
|
142
149
|
watch: {
|
|
143
150
|
|
|
144
|
-
value(
|
|
151
|
+
value(){
|
|
145
152
|
this.start()
|
|
146
153
|
},
|
|
147
154
|
|
|
@@ -150,6 +157,7 @@ export default{
|
|
|
150
157
|
this.$refs.day.firstElementChild.innerHTML = to > 0 ? to + ' hari' : ''
|
|
151
158
|
this.$refs.day.lastElementChild.innerHTML = from + ' hari'
|
|
152
159
|
this.$refs.day.classList.add(this.$style.tick)
|
|
160
|
+
this.state[0] = 1
|
|
153
161
|
},
|
|
154
162
|
|
|
155
163
|
hour(to, from){
|
|
@@ -157,6 +165,7 @@ export default{
|
|
|
157
165
|
this.$refs.hour.firstElementChild.innerHTML = to
|
|
158
166
|
this.$refs.hour.lastElementChild.innerHTML = from
|
|
159
167
|
this.$refs.hour.classList.add(this.$style.tick)
|
|
168
|
+
this.state[1] = 1
|
|
160
169
|
},
|
|
161
170
|
|
|
162
171
|
minute(to, from){
|
|
@@ -164,6 +173,7 @@ export default{
|
|
|
164
173
|
this.$refs.minute.firstElementChild.innerHTML = to
|
|
165
174
|
this.$refs.minute.lastElementChild.innerHTML = from
|
|
166
175
|
this.$refs.minute.classList.add(this.$style.tick)
|
|
176
|
+
this.state[2] = 1
|
|
167
177
|
},
|
|
168
178
|
|
|
169
179
|
second(to, from){
|
|
@@ -171,6 +181,7 @@ export default{
|
|
|
171
181
|
this.$refs.second.firstElementChild.innerHTML = to
|
|
172
182
|
this.$refs.second.lastElementChild.innerHTML = from
|
|
173
183
|
this.$refs.second.classList.add(this.$style.tick)
|
|
184
|
+
this.state[3] = 1
|
|
174
185
|
}
|
|
175
186
|
}
|
|
176
187
|
|
|
@@ -210,4 +221,4 @@ export default{
|
|
|
210
221
|
transform: translate3d(0, 1.3rem, 0);
|
|
211
222
|
}
|
|
212
223
|
|
|
213
|
-
</style>
|
|
224
|
+
</style>
|
package/src/components/Radio.vue
CHANGED
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="$style.comp">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</div>
|
|
10
|
-
<slot></slot>
|
|
11
|
-
</label>
|
|
2
|
+
<div :class="$style.comp + (cChecked ? ' ' + $style.checked : '') + (isDisabled ? ' ' + $style.disabled : '')" @click="onChange">
|
|
3
|
+
<div :class="$style.indicator">
|
|
4
|
+
<div>
|
|
5
|
+
<svg width="14" height="14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
<slot></slot>
|
|
12
9
|
</div>
|
|
13
10
|
</template>
|
|
14
11
|
|
|
15
12
|
<script>
|
|
16
13
|
|
|
17
|
-
import {
|
|
14
|
+
import {parseBoolean} from "../utils/helpers.mjs";
|
|
18
15
|
|
|
19
16
|
export default{
|
|
20
17
|
|
|
21
18
|
props:{
|
|
22
|
-
|
|
19
|
+
name: String,
|
|
23
20
|
checked: undefined,
|
|
24
|
-
value: undefined,
|
|
25
|
-
|
|
26
21
|
modelValue: undefined,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
customClass: String,
|
|
31
|
-
variant: String, // default
|
|
22
|
+
value: undefined,
|
|
23
|
+
disabled: undefined
|
|
32
24
|
},
|
|
33
25
|
|
|
34
26
|
computed: {
|
|
@@ -37,58 +29,22 @@ export default{
|
|
|
37
29
|
return this.$style.comp + this.uniqid()
|
|
38
30
|
},
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
checked = this.trueValue === this.value
|
|
48
|
-
}
|
|
49
|
-
else{
|
|
50
|
-
checked = parseBoolean(this.modelValue)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else{
|
|
54
|
-
checked = !!this.checked
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return checked
|
|
58
|
-
}
|
|
32
|
+
isDisabled(){
|
|
33
|
+
return parseBoolean(this.disabled)
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
cChecked(){
|
|
37
|
+
return this.$props.checked === undefined ? this.modelValue === this.value : parseBoolean(this.checked)
|
|
38
|
+
}
|
|
59
39
|
|
|
60
40
|
},
|
|
61
41
|
|
|
62
42
|
methods: {
|
|
63
43
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
else if(this.trueValue) value = this.trueValue
|
|
69
|
-
else value = true
|
|
70
|
-
|
|
71
|
-
if(this.modelValue && Array.isArray(this.modelValue)){
|
|
72
|
-
value = [ ...this.modelValue, value ].filter((v, idx, arr) => {
|
|
73
|
-
return arr.indexOf(v) === idx
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else{
|
|
78
|
-
if(this.value) value = null
|
|
79
|
-
else if(this.falseValue) value = this.falseValue
|
|
80
|
-
else value = false
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if(this.modelValue && Array.isArray(this.modelValue)){
|
|
85
|
-
value = this.modelValue.filter((v) => {
|
|
86
|
-
return v !== this.value ?? (this.falseValue ?? false)
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
this.$emit('update:modelValue', value)
|
|
91
|
-
}
|
|
44
|
+
onChange(){
|
|
45
|
+
if(this.isDisabled) return
|
|
46
|
+
this.$emit('update:modelValue', this.value)
|
|
47
|
+
}
|
|
92
48
|
|
|
93
49
|
}
|
|
94
50
|
|
|
@@ -99,36 +55,30 @@ export default{
|
|
|
99
55
|
<style module>
|
|
100
56
|
|
|
101
57
|
.comp{
|
|
102
|
-
@apply h-[var(--h-cp)] flex items-center;
|
|
58
|
+
@apply h-[var(--h-cp)] flex items-center cursor-pointer;
|
|
59
|
+
@apply flex flex-row items-center gap-2
|
|
103
60
|
}
|
|
104
61
|
|
|
105
|
-
.comp
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.comp input{
|
|
110
|
-
@apply hidden;
|
|
62
|
+
.comp.checked .indicator>div{
|
|
63
|
+
transform: scale(1);
|
|
111
64
|
}
|
|
112
65
|
|
|
113
66
|
.indicator{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
.comp:hover .indicator{
|
|
119
|
-
@apply border-primary;
|
|
67
|
+
@apply w-[21px] h-[21px] border-[1px] rounded-full border-text-200 bg-base-50;
|
|
68
|
+
@apply flex items-center justify-center overflow-hidden;
|
|
69
|
+
transition: border 300ms cubic-bezier(0.25, 1, 0.5, 1);
|
|
120
70
|
}
|
|
121
|
-
|
|
122
71
|
.indicator>div{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
72
|
+
@apply w-[21px] h-[21px] flex rounded-full items-center justify-center bg-primary;
|
|
73
|
+
transition: all 300ms cubic-bezier(0.25, 1, 0.5, 1);
|
|
74
|
+
transform: scale(0);
|
|
126
75
|
}
|
|
127
76
|
.indicator>div>*{
|
|
128
|
-
|
|
77
|
+
@apply fill-white;
|
|
129
78
|
}
|
|
130
|
-
|
|
131
|
-
|
|
79
|
+
|
|
80
|
+
.comp:not(.disabled):hover .indicator{
|
|
81
|
+
@apply border-primary;
|
|
132
82
|
}
|
|
133
83
|
|
|
134
|
-
</style>
|
|
84
|
+
</style>
|
package/src/utils/helpers.mjs
CHANGED