wave-ui 3.16.2 → 3.17.0
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/dist/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.css +1 -1
- package/dist/wave-ui.es.js +1449 -1348
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +11 -11
- package/src/wave-ui/components/index.js +2 -1
- package/src/wave-ui/components/w-accordion/index.vue +205 -0
- package/src/wave-ui/components/w-accordion/item.vue +149 -0
- package/src/wave-ui/components/w-dialog.vue +2 -2
- package/src/wave-ui/components/w-drawer.vue +2 -2
- package/src/wave-ui/components/w-form.vue +11 -11
- package/src/wave-ui/components/w-menu.vue +2 -2
- package/src/wave-ui/components/w-overlay.vue +2 -2
- package/src/wave-ui/components/w-tabs/index.vue +12 -6
- package/src/wave-ui/components/w-accordion.vue +0 -231
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
<template lang="pug">
|
|
2
|
-
.w-accordion(:class="accordionClasses")
|
|
3
|
-
.w-accordion__item(
|
|
4
|
-
v-for="(item, i) in accordionItems"
|
|
5
|
-
:key="i"
|
|
6
|
-
:class="itemClasses(item)"
|
|
7
|
-
:aria-expanded="item._expanded ? 'true' : 'false'")
|
|
8
|
-
.w-accordion__item-title(
|
|
9
|
-
@click="!item._disabled && toggleItem(item, $event)"
|
|
10
|
-
@focus="$emit('focus', getOriginalItem(item))"
|
|
11
|
-
@keypress.enter="!item._disabled && toggleItem(item, $event)"
|
|
12
|
-
:tabindex="!item._disabled && 0"
|
|
13
|
-
:class="titleClass")
|
|
14
|
-
//- Expand icon on left.
|
|
15
|
-
w-button.w-accordion__expand-icon(
|
|
16
|
-
v-if="expandIcon && !expandIconRight"
|
|
17
|
-
:icon="(item._expanded && collapseIcon) || expandIcon"
|
|
18
|
-
:icon-props="expandIconProps"
|
|
19
|
-
:disabled="item._disabled || null"
|
|
20
|
-
:tabindex="-1"
|
|
21
|
-
text
|
|
22
|
-
@keypress.stop
|
|
23
|
-
@click.stop="!item._disabled && toggleItem(item, $event)"
|
|
24
|
-
:class="{ 'w-accordion__expand-icon--expanded': item._expanded, 'w-accordion__expand-icon--rotate90': expandIconRotate90 }")
|
|
25
|
-
//- Title.
|
|
26
|
-
slot(
|
|
27
|
-
v-if="$slots[`item-title.${item.id || i + 1}`]"
|
|
28
|
-
:name="`item-title.${item.id || i + 1}`"
|
|
29
|
-
:item="getOriginalItem(item)"
|
|
30
|
-
:expanded="item._expanded" :index="i + 1")
|
|
31
|
-
slot(v-else name="item-title" :item="getOriginalItem(item)" :expanded="item._expanded" :index="i + 1")
|
|
32
|
-
div.grow(v-html="item[itemTitleKey]")
|
|
33
|
-
//- Expand icon on right.
|
|
34
|
-
w-button.w-accordion__expand-icon(
|
|
35
|
-
v-if="expandIcon && expandIconRight"
|
|
36
|
-
:icon="(item._expanded && collapseIcon) || expandIcon"
|
|
37
|
-
text
|
|
38
|
-
@keypress.stop
|
|
39
|
-
@click.stop="!item._disabled && toggleItem(item, $event)"
|
|
40
|
-
:class="{ 'w-accordion__expand-icon--expanded': item._expanded, 'w-accordion__expand-icon--rotate90': expandIconRotate90 }")
|
|
41
|
-
//- Content.
|
|
42
|
-
w-transition-expand(
|
|
43
|
-
y
|
|
44
|
-
@after-leave="onEndOfCollapse(item)"
|
|
45
|
-
:duration="duration")
|
|
46
|
-
.w-accordion__item-content(
|
|
47
|
-
v-if="item._expanded"
|
|
48
|
-
:class="contentClass")
|
|
49
|
-
slot(
|
|
50
|
-
v-if="$slots[`item-content.${item.id || i + 1}`]"
|
|
51
|
-
:name="`item-content.${item.id || i + 1}`"
|
|
52
|
-
:item="getOriginalItem(item)"
|
|
53
|
-
:expanded="item._expanded"
|
|
54
|
-
:index="i + 1")
|
|
55
|
-
slot(
|
|
56
|
-
v-else
|
|
57
|
-
name="item-content"
|
|
58
|
-
:item="getOriginalItem(item)"
|
|
59
|
-
:expanded="item._expanded"
|
|
60
|
-
:index="i + 1")
|
|
61
|
-
div(v-html="item[itemContentKey]")
|
|
62
|
-
</template>
|
|
63
|
-
|
|
64
|
-
<script>
|
|
65
|
-
export default {
|
|
66
|
-
name: 'w-accordion',
|
|
67
|
-
|
|
68
|
-
props: {
|
|
69
|
-
modelValue: { type: Array },
|
|
70
|
-
color: { type: String },
|
|
71
|
-
bgColor: { type: String },
|
|
72
|
-
items: { type: [Array, Number], required: true },
|
|
73
|
-
itemColorKey: { type: String, default: 'color' }, // Support a different color per item.
|
|
74
|
-
itemTitleKey: { type: String, default: 'title' },
|
|
75
|
-
itemContentKey: { type: String, default: 'content' },
|
|
76
|
-
itemClass: { type: String },
|
|
77
|
-
titleClass: { type: String },
|
|
78
|
-
contentClass: { type: String },
|
|
79
|
-
expandIcon: { type: [String, Boolean], default: 'wi-triangle-down' },
|
|
80
|
-
expandIconRight: { type: Boolean },
|
|
81
|
-
expandIconRotate90: { type: Boolean },
|
|
82
|
-
expandIconProps: { type: Object, default: () => ({}) },
|
|
83
|
-
expandSingle: { type: Boolean },
|
|
84
|
-
collapseIcon: { type: String },
|
|
85
|
-
shadow: { type: Boolean },
|
|
86
|
-
duration: { type: Number, default: 250 },
|
|
87
|
-
dark: { type: Boolean },
|
|
88
|
-
light: { type: Boolean }
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
emits: ['input', 'update:modelValue', 'focus', 'item-expand', 'item-collapsed'],
|
|
92
|
-
|
|
93
|
-
data: () => ({
|
|
94
|
-
accordionItems: []
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
computed: {
|
|
98
|
-
accordionClasses () {
|
|
99
|
-
return {
|
|
100
|
-
[this.color]: this.color,
|
|
101
|
-
[`${this.bgColor}--bg`]: this.bgColor,
|
|
102
|
-
'w-accordion--dark': this.dark,
|
|
103
|
-
'w-accordion--light': this.light,
|
|
104
|
-
'w-accordion--shadow': this.shadow,
|
|
105
|
-
'w-accordion--no-icon': !this.expandIcon && !this.collapseIcon,
|
|
106
|
-
'w-accordion--icon-right': this.expandIcon && this.expandIconRight,
|
|
107
|
-
'w-accordion--rotate-icon': this.expandIcon && !this.collapseIcon
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
methods: {
|
|
113
|
-
toggleItem (item, e) {
|
|
114
|
-
item._expanded = !item._expanded
|
|
115
|
-
if (this.expandSingle) this.accordionItems.forEach(obj => obj._index !== item._index && (obj._expanded = false))
|
|
116
|
-
const expandedItems = this.accordionItems.map(item => item._expanded || false)
|
|
117
|
-
this.$emit('update:modelValue', expandedItems)
|
|
118
|
-
this.$emit('input', expandedItems)
|
|
119
|
-
this.$emit('item-expand', { item, expanded: item._expanded })
|
|
120
|
-
|
|
121
|
-
// When a focused item moves in the page, the scrollTop is naturally updated by the browser.
|
|
122
|
-
// So if expandSingle is set to true, clicking on the next title of an open pane would shift the
|
|
123
|
-
// scrollTop unless unfocused while transitioning. #3.
|
|
124
|
-
e.target.blur()
|
|
125
|
-
setTimeout(() => e.target.focus(), 300)
|
|
126
|
-
},
|
|
127
|
-
onEndOfCollapse (item) {
|
|
128
|
-
this.$emit('item-collapsed', { item, expanded: item._expanded })
|
|
129
|
-
},
|
|
130
|
-
// Return the original accordion item (so there is no `_index`, etc.).
|
|
131
|
-
getOriginalItem (item) {
|
|
132
|
-
return this.items[item._index]
|
|
133
|
-
},
|
|
134
|
-
itemClasses (item) {
|
|
135
|
-
return {
|
|
136
|
-
[this.itemClass]: this.itemClass || null,
|
|
137
|
-
'w-accordion__item--expanded': item._expanded,
|
|
138
|
-
'w-accordion__item--disabled': item._disabled,
|
|
139
|
-
[item[this.itemColorKey]]: item[this.itemColorKey]
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
updateItems () {
|
|
143
|
-
const items = typeof this.items === 'number' ? Array(this.items).fill({}) : this.items || []
|
|
144
|
-
this.accordionItems = items.map((item, _index) => ({
|
|
145
|
-
...item,
|
|
146
|
-
_index,
|
|
147
|
-
_expanded: this.modelValue && this.modelValue[_index],
|
|
148
|
-
_disabled: !!item.disabled
|
|
149
|
-
}))
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
created () {
|
|
154
|
-
this.updateItems()
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
watch: {
|
|
158
|
-
modelValue () {
|
|
159
|
-
this.updateItems()
|
|
160
|
-
},
|
|
161
|
-
items: {
|
|
162
|
-
handler () {
|
|
163
|
-
this.updateItems()
|
|
164
|
-
},
|
|
165
|
-
deep: true
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
</script>
|
|
170
|
-
|
|
171
|
-
<style lang="scss">
|
|
172
|
-
.w-accordion {
|
|
173
|
-
z-index: 1;
|
|
174
|
-
|
|
175
|
-
@include themeable;
|
|
176
|
-
|
|
177
|
-
&--shadow {box-shadow: $box-shadow;}
|
|
178
|
-
|
|
179
|
-
&__item {position: relative;}
|
|
180
|
-
|
|
181
|
-
button.w-accordion__expand-icon {color: rgba(var(--w-base-color-rgb), 0.4);}
|
|
182
|
-
&__expand-icon {
|
|
183
|
-
margin-right: $base-increment;
|
|
184
|
-
|
|
185
|
-
.w-accordion--rotate-icon & {@include default-transition;}
|
|
186
|
-
&--rotate90 {transform: rotate(-90deg);}
|
|
187
|
-
&--expanded {transform: rotate(-180deg);}
|
|
188
|
-
&--expanded.w-accordion__expand-icon--rotate90 {transform: rotate(0deg);}
|
|
189
|
-
|
|
190
|
-
.w-icon:before {font-size: 1.1em;}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
&__item-title {
|
|
194
|
-
position: relative;
|
|
195
|
-
display: flex;
|
|
196
|
-
align-items: center;
|
|
197
|
-
font-size: round(1.2 * $base-font-size);
|
|
198
|
-
padding: 1 * $base-increment;
|
|
199
|
-
user-select: none;
|
|
200
|
-
cursor: pointer;
|
|
201
|
-
border-top: $border;
|
|
202
|
-
-webkit-tap-highlight-color: transparent;
|
|
203
|
-
|
|
204
|
-
.w-accordion__item--disabled & {
|
|
205
|
-
cursor: not-allowed;
|
|
206
|
-
opacity: 0.6;
|
|
207
|
-
-webkit-tap-highlight-color: transparent;
|
|
208
|
-
}
|
|
209
|
-
.w-accordion--no-icon &, .w-accordion--icon-right & {padding-left: 3 * $base-increment;}
|
|
210
|
-
|
|
211
|
-
.w-accordion__item:first-child & {border-top-color: transparent;}
|
|
212
|
-
|
|
213
|
-
&:before {
|
|
214
|
-
content: '';
|
|
215
|
-
position: absolute;
|
|
216
|
-
inset: 0;
|
|
217
|
-
background-color: currentColor;
|
|
218
|
-
opacity: 0;
|
|
219
|
-
transition: $fast-transition-duration;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
&:focus:before, &:hover:before {opacity: 0.03;}
|
|
223
|
-
&:active:before {opacity: 0.05;}
|
|
224
|
-
.w-accordion__item--disabled &:before {display: none;}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
&__item-content {
|
|
228
|
-
padding: (2 * $base-increment) (3 * $base-increment);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
</style>
|