webcake-ui-kit 1.1.6 → 1.1.8
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/input/input.css +4 -4
- package/src/components/select/Select.vue +12 -5
- package/src/components/select/select.css +4 -4
- package/src/components/select-option/SelectOption.vue +1 -1
- package/src/components/slider/Slider.vue +42 -14
- package/src/components/tabs/Tabs.vue +29 -5
- package/src/components/tabs/tabs.css +3 -0
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/* Size — paddings, gaps, heights, typography. Inner field inherits typography. */
|
|
16
16
|
.ui-input--size-md {
|
|
17
|
-
|
|
17
|
+
height: 36px;
|
|
18
18
|
gap: var(--spacing-xs);
|
|
19
19
|
padding: var(--spacing-7p5) var(--spacing-sm);
|
|
20
20
|
font-size: var(--paragraph-small-font-size);
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.ui-input--size-lg {
|
|
26
|
-
|
|
26
|
+
height: 40px;
|
|
27
27
|
gap: var(--spacing-sm);
|
|
28
28
|
padding: var(--spacing-9p5) var(--spacing-md);
|
|
29
29
|
font-size: var(--paragraph-small-font-size);
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.ui-input--size-sm {
|
|
35
|
-
|
|
35
|
+
height: 32px;
|
|
36
36
|
gap: var(--spacing-6);
|
|
37
37
|
padding: var(--spacing-5p5) var(--spacing-xs);
|
|
38
38
|
font-size: var(--paragraph-small-font-size);
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
.ui-input--size-xs {
|
|
44
|
-
|
|
44
|
+
height: 28px;
|
|
45
45
|
gap: var(--spacing-2xs);
|
|
46
46
|
padding: var(--spacing-6);
|
|
47
47
|
font-size: var(--paragraph-mini-font-size);
|
|
@@ -89,6 +89,9 @@ export default {
|
|
|
89
89
|
type: String,
|
|
90
90
|
default: ''
|
|
91
91
|
},
|
|
92
|
+
modelValue: {
|
|
93
|
+
default: null
|
|
94
|
+
},
|
|
92
95
|
options: {
|
|
93
96
|
type: Array,
|
|
94
97
|
default: () => []
|
|
@@ -119,7 +122,7 @@ export default {
|
|
|
119
122
|
}
|
|
120
123
|
},
|
|
121
124
|
|
|
122
|
-
emits: ['change'],
|
|
125
|
+
emits: ['change', 'update:modelValue'],
|
|
123
126
|
|
|
124
127
|
data() {
|
|
125
128
|
return {
|
|
@@ -129,6 +132,9 @@ export default {
|
|
|
129
132
|
},
|
|
130
133
|
|
|
131
134
|
computed: {
|
|
135
|
+
effectiveValue() {
|
|
136
|
+
return this.modelValue !== null ? this.modelValue : this.value
|
|
137
|
+
},
|
|
132
138
|
normalizedOptions() {
|
|
133
139
|
return this.options.map(opt =>
|
|
134
140
|
typeof opt === 'string'
|
|
@@ -137,10 +143,10 @@ export default {
|
|
|
137
143
|
)
|
|
138
144
|
},
|
|
139
145
|
selectedLabel() {
|
|
140
|
-
if (!this.
|
|
141
|
-
if (this.labelCache[this.
|
|
142
|
-
const opt = this.normalizedOptions.find(o => o.value === this.
|
|
143
|
-
return opt ? opt.label : this.
|
|
146
|
+
if (!this.effectiveValue) return ''
|
|
147
|
+
if (this.labelCache[this.effectiveValue]) return this.labelCache[this.effectiveValue]
|
|
148
|
+
const opt = this.normalizedOptions.find(o => o.value === this.effectiveValue)
|
|
149
|
+
return opt ? opt.label : this.effectiveValue
|
|
144
150
|
},
|
|
145
151
|
hasIconSlot() {
|
|
146
152
|
return !!((this.$scopedSlots && this.$scopedSlots['icon']) || this.$slots['icon'])
|
|
@@ -159,6 +165,7 @@ export default {
|
|
|
159
165
|
},
|
|
160
166
|
select(val) {
|
|
161
167
|
this.$emit('change', val)
|
|
168
|
+
this.$emit('update:modelValue', val)
|
|
162
169
|
this.isOpen = false
|
|
163
170
|
},
|
|
164
171
|
registerOption(value, label) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
align-items: center;
|
|
5
5
|
gap: var(--spacing-xs);
|
|
6
|
-
|
|
6
|
+
height: 36px;
|
|
7
7
|
width: 100%;
|
|
8
8
|
padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-sm);
|
|
9
9
|
border: 1px solid var(--border-primary);
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
|
|
113
113
|
/* — sizes — */
|
|
114
114
|
.ui-select--lg {
|
|
115
|
-
|
|
115
|
+
height: 40px;
|
|
116
116
|
padding: var(--spacing-10) var(--spacing-xs) var(--spacing-10) var(--spacing-md);
|
|
117
117
|
gap: var(--spacing-sm);
|
|
118
118
|
}
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
/* default size is the base — no extra rules needed */
|
|
125
125
|
|
|
126
126
|
.ui-select--sm {
|
|
127
|
-
|
|
127
|
+
height: 32px;
|
|
128
128
|
padding: var(--spacing-6) var(--spacing-xs);
|
|
129
129
|
gap: var(--spacing-6);
|
|
130
130
|
}
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
.ui-select--xs {
|
|
137
|
-
|
|
137
|
+
height: 28px;
|
|
138
138
|
padding: var(--spacing-2xs) var(--spacing-6);
|
|
139
139
|
gap: var(--spacing-2xs);
|
|
140
140
|
border-radius: var(--rounded-lg);
|
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
|
|
58
58
|
computed: {
|
|
59
59
|
isSelected() {
|
|
60
|
-
return !!(this.select && this.select.
|
|
60
|
+
return !!(this.select && this.select.effectiveValue !== undefined && this.select.effectiveValue === this.value)
|
|
61
61
|
},
|
|
62
62
|
isDisabled() {
|
|
63
63
|
return this.disabled || !!(this.select && this.select.disabled)
|
|
@@ -61,8 +61,15 @@
|
|
|
61
61
|
<script>
|
|
62
62
|
export default {
|
|
63
63
|
name: 'Slider',
|
|
64
|
+
|
|
65
|
+
model: {
|
|
66
|
+
prop: 'value',
|
|
67
|
+
event: 'input'
|
|
68
|
+
},
|
|
69
|
+
|
|
64
70
|
props: {
|
|
65
|
-
value: { type: Number, default: 50 },
|
|
71
|
+
value: { type: [Number, Array], default: 50 },
|
|
72
|
+
modelValue: { default: null },
|
|
66
73
|
rangeValue: {
|
|
67
74
|
type: Array,
|
|
68
75
|
default: function () {
|
|
@@ -82,12 +89,17 @@ export default {
|
|
|
82
89
|
},
|
|
83
90
|
disabled: { type: Boolean, default: false }
|
|
84
91
|
},
|
|
85
|
-
|
|
92
|
+
|
|
93
|
+
emits: ['change', 'input', 'update:modelValue'],
|
|
94
|
+
|
|
86
95
|
data: function () {
|
|
96
|
+
var mv = this.modelValue !== null ? this.modelValue : this.value
|
|
97
|
+
var singleInit = typeof mv === 'number' ? mv : 50
|
|
98
|
+
var rangeInit = Array.isArray(mv) ? mv : Array.isArray(this.rangeValue) ? this.rangeValue : [25, 75]
|
|
87
99
|
return {
|
|
88
|
-
localValue:
|
|
89
|
-
localRangeMin:
|
|
90
|
-
localRangeMax:
|
|
100
|
+
localValue: singleInit,
|
|
101
|
+
localRangeMin: rangeInit[0],
|
|
102
|
+
localRangeMax: rangeInit[1],
|
|
91
103
|
dragging: null,
|
|
92
104
|
boundMouseMove: null,
|
|
93
105
|
boundMouseUp: null,
|
|
@@ -95,9 +107,21 @@ export default {
|
|
|
95
107
|
boundTouchEnd: null
|
|
96
108
|
}
|
|
97
109
|
},
|
|
110
|
+
|
|
98
111
|
watch: {
|
|
99
112
|
value: function (v) {
|
|
100
|
-
this.localValue = v
|
|
113
|
+
if (typeof v === 'number') this.localValue = v
|
|
114
|
+
else if (Array.isArray(v)) {
|
|
115
|
+
this.localRangeMin = v[0]
|
|
116
|
+
this.localRangeMax = v[1]
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
modelValue: function (v) {
|
|
120
|
+
if (typeof v === 'number') this.localValue = v
|
|
121
|
+
else if (Array.isArray(v)) {
|
|
122
|
+
this.localRangeMin = v[0]
|
|
123
|
+
this.localRangeMax = v[1]
|
|
124
|
+
}
|
|
101
125
|
},
|
|
102
126
|
rangeValue: function (v) {
|
|
103
127
|
if (Array.isArray(v)) {
|
|
@@ -191,19 +215,23 @@ export default {
|
|
|
191
215
|
document.removeEventListener('touchend', this.boundTouchEnd)
|
|
192
216
|
},
|
|
193
217
|
applyValue: function (which, val) {
|
|
218
|
+
var arr
|
|
194
219
|
if (which === 'single') {
|
|
195
220
|
this.localValue = val
|
|
196
221
|
this.$emit('input', val)
|
|
222
|
+
this.$emit('update:modelValue', val)
|
|
197
223
|
this.$emit('change', val)
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this
|
|
202
|
-
} else
|
|
203
|
-
|
|
204
|
-
this.localRangeMax = this.snap(newMax)
|
|
205
|
-
this.$emit('change', [this.localRangeMin, this.localRangeMax])
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
if (which === 'min') {
|
|
227
|
+
this.localRangeMin = this.snap(Math.min(val, this.localRangeMax - this.step))
|
|
228
|
+
} else {
|
|
229
|
+
this.localRangeMax = this.snap(Math.max(val, this.localRangeMin + this.step))
|
|
206
230
|
}
|
|
231
|
+
arr = [this.localRangeMin, this.localRangeMax]
|
|
232
|
+
this.$emit('input', arr)
|
|
233
|
+
this.$emit('update:modelValue', arr)
|
|
234
|
+
this.$emit('change', arr)
|
|
207
235
|
},
|
|
208
236
|
onTrackClick: function (event) {
|
|
209
237
|
if (this.disabled) return
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
type="button"
|
|
7
7
|
class="ui-tabs__item"
|
|
8
8
|
:class="{
|
|
9
|
-
'ui-tabs__item--active': tab.value ===
|
|
9
|
+
'ui-tabs__item--active': tab.value === effectiveValue,
|
|
10
10
|
'ui-tabs__item--disabled': tab.disabled,
|
|
11
|
-
'ui-tabs__item--stretch': stretchItems
|
|
11
|
+
'ui-tabs__item--stretch': stretchItems,
|
|
12
|
+
'ui-tabs__item--allow-deselect': allowDeselect
|
|
12
13
|
}"
|
|
13
14
|
:disabled="tab.disabled || undefined"
|
|
14
15
|
@click="select(tab.value)"
|
|
@@ -31,8 +32,15 @@
|
|
|
31
32
|
<script>
|
|
32
33
|
export default {
|
|
33
34
|
name: 'Tabs',
|
|
35
|
+
|
|
36
|
+
model: {
|
|
37
|
+
prop: 'value',
|
|
38
|
+
event: 'input'
|
|
39
|
+
},
|
|
40
|
+
|
|
34
41
|
props: {
|
|
35
42
|
value: { type: [String, Number], default: null },
|
|
43
|
+
modelValue: { default: null },
|
|
36
44
|
tabs: {
|
|
37
45
|
type: Array,
|
|
38
46
|
default: function () {
|
|
@@ -49,13 +57,29 @@ export default {
|
|
|
49
57
|
stretchItems: {
|
|
50
58
|
type: Boolean,
|
|
51
59
|
default: () => false
|
|
60
|
+
},
|
|
61
|
+
allowDeselect: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: () => false
|
|
52
64
|
}
|
|
53
65
|
},
|
|
54
|
-
emits: ['input', 'change'],
|
|
66
|
+
emits: ['input', 'change', 'update:modelValue'],
|
|
67
|
+
|
|
68
|
+
computed: {
|
|
69
|
+
effectiveValue: function () {
|
|
70
|
+
return this.modelValue !== null ? this.modelValue : this.value
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
55
74
|
methods: {
|
|
56
|
-
select: function (
|
|
57
|
-
|
|
75
|
+
select: function (value) {
|
|
76
|
+
let val = value
|
|
77
|
+
if (!this.allowDeselect && val == this.effectiveValue) return
|
|
78
|
+
if (this.allowDeselect && val == this.effectiveValue) {
|
|
79
|
+
val = undefined
|
|
80
|
+
}
|
|
58
81
|
this.$emit('input', val)
|
|
82
|
+
this.$emit('update:modelValue', val)
|
|
59
83
|
this.$emit('change', val)
|
|
60
84
|
}
|
|
61
85
|
}
|