wave-ui 3.17.0 → 3.17.1
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wave-ui",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.1",
|
|
4
4
|
"description": "A UI framework for Vue.js 3 (and 2) with only the bright side. :sunny:",
|
|
5
5
|
"author": "Antoni Andre <antoniandre.web@gmail.com>",
|
|
6
6
|
"homepage": "https://antoniandre.github.io/wave-ui",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//- Else, when providing the items array or number through the items prop.
|
|
7
7
|
template(v-else-if="!isNaN(items) || (items || []).length")
|
|
8
8
|
w-accordion-item(
|
|
9
|
-
v-for="(accordionItem, i) in accordionItems"
|
|
9
|
+
v-for="(accordionItem, i) in state.accordionItems"
|
|
10
10
|
:key="i"
|
|
11
11
|
:class="itemClass"
|
|
12
12
|
:item="accordionItem"
|
|
@@ -81,17 +81,19 @@ export default {
|
|
|
81
81
|
itemClasses: objectifyClasses(this.itemClasses),
|
|
82
82
|
titleClasses: this.titleClasses,
|
|
83
83
|
contentClasses: this.contentClasses,
|
|
84
|
-
|
|
84
|
+
onItemToggle: this.onItemToggle,
|
|
85
85
|
onEndOfCollapse: this.onEndOfCollapse,
|
|
86
86
|
getOriginalItem: this.getOriginalItem,
|
|
87
87
|
options: this.$props,
|
|
88
|
-
registerItem: this.registerItem
|
|
88
|
+
registerItem: this.registerItem,
|
|
89
|
+
state: this.state
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
|
|
92
93
|
data: () => ({
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
state: {
|
|
95
|
+
accordionItems: []
|
|
96
|
+
}
|
|
95
97
|
}),
|
|
96
98
|
|
|
97
99
|
computed: {
|
|
@@ -127,21 +129,13 @@ export default {
|
|
|
127
129
|
},
|
|
128
130
|
|
|
129
131
|
methods: {
|
|
130
|
-
|
|
131
|
-
item._expanded =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (this.expandSingle) items.forEach(obj => obj._index !== item._index && (obj._expanded = false))
|
|
135
|
-
const expandedItems = items.map(item => item._expanded || false)
|
|
132
|
+
onItemToggle (item) {
|
|
133
|
+
if (this.expandSingle) this.state.accordionItems.forEach(obj => obj._index !== item._index && (obj._expanded = false))
|
|
134
|
+
const expandedItems = this.state.accordionItems.map(item => item._expanded || false)
|
|
135
|
+
console.log('toggling item', expandedItems)
|
|
136
136
|
this.$emit('update:modelValue', expandedItems)
|
|
137
137
|
this.$emit('input', expandedItems)
|
|
138
138
|
this.$emit('item-expand', { item, expanded: item._expanded })
|
|
139
|
-
|
|
140
|
-
// When a focused item moves in the page, the scrollTop is naturally updated by the browser.
|
|
141
|
-
// So if expandSingle is set to true, clicking on the next title of an open pane would shift the
|
|
142
|
-
// scrollTop unless unfocused while transitioning. #3.
|
|
143
|
-
e.target.blur()
|
|
144
|
-
setTimeout(() => e.target.focus(), 300)
|
|
145
139
|
},
|
|
146
140
|
|
|
147
141
|
onEndOfCollapse (item) {
|
|
@@ -150,18 +144,19 @@ export default {
|
|
|
150
144
|
|
|
151
145
|
// Return the original accordion item (so there is no `_index`, etc.).
|
|
152
146
|
getOriginalItem (item) {
|
|
153
|
-
return
|
|
147
|
+
return this.items[item._index]
|
|
154
148
|
},
|
|
155
149
|
|
|
156
150
|
updateItems () {
|
|
157
|
-
let items =
|
|
158
|
-
if (this.
|
|
159
|
-
|
|
151
|
+
let items = this.state.accordionItems
|
|
152
|
+
if (!this.accordionItemsProvided && this.items) {
|
|
153
|
+
items = (typeof this.items === 'number' ? Array(this.items).fill({}) : this.items) || []
|
|
154
|
+
}
|
|
160
155
|
|
|
161
|
-
this.accordionItems = items.map((item, _index) => ({
|
|
156
|
+
this.state.accordionItems = items.map((item, _index) => ({
|
|
162
157
|
...item,
|
|
163
158
|
_index,
|
|
164
|
-
_expanded: this.modelValue
|
|
159
|
+
_expanded: this.modelValue?.[_index] ?? false,
|
|
165
160
|
_disabled: !!item.disabled
|
|
166
161
|
}))
|
|
167
162
|
},
|
|
@@ -169,18 +164,20 @@ export default {
|
|
|
169
164
|
// Provide-injected in and used from w-accordion-item.
|
|
170
165
|
// Only when w-accordion-item is directly used outside of Wave UI.
|
|
171
166
|
registerItem (item) {
|
|
172
|
-
if (
|
|
173
|
-
item._index = this.
|
|
174
|
-
item._expanded = this.modelValue?.[item._index]
|
|
167
|
+
if (this.accordionItemsProvided) {
|
|
168
|
+
item._index = this.state.accordionItems.length
|
|
169
|
+
item._expanded = this.modelValue?.[item._index] ?? false
|
|
170
|
+
item._disabled = !!item.disabled
|
|
175
171
|
|
|
176
|
-
this.
|
|
177
|
-
this.updateItems()
|
|
172
|
+
this.state.accordionItems.push(item)
|
|
178
173
|
}
|
|
174
|
+
|
|
175
|
+
return item._index
|
|
179
176
|
}
|
|
180
177
|
},
|
|
181
178
|
|
|
182
179
|
created () {
|
|
183
|
-
this.updateItems()
|
|
180
|
+
if (!this.accordionItemsProvided && this.items) this.updateItems()
|
|
184
181
|
},
|
|
185
182
|
|
|
186
183
|
watch: {
|
|
@@ -188,7 +185,7 @@ export default {
|
|
|
188
185
|
this.updateItems()
|
|
189
186
|
},
|
|
190
187
|
items () {
|
|
191
|
-
this.updateItems()
|
|
188
|
+
// this.updateItems()
|
|
192
189
|
}
|
|
193
190
|
}
|
|
194
191
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
.w-accordion__item(:class="itemClasses" :aria-expanded="accordionItem._expanded ? 'true' : 'false'")
|
|
3
3
|
.w-accordion__item-title(
|
|
4
4
|
@click="!accordionItem._disabled && toggleItem(accordionItem, $event)"
|
|
5
|
-
@focus="$emit('focus',
|
|
5
|
+
@focus="$emit('focus', (accordionItem))"
|
|
6
6
|
@keypress.enter="!accordionItem._disabled && toggleItem(accordionItem, $event)"
|
|
7
7
|
:tabindex="!accordionItem._disabled && 0"
|
|
8
8
|
:class="titleClasses")
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
//- Title.
|
|
21
21
|
slot(
|
|
22
22
|
name="title"
|
|
23
|
-
:item="
|
|
23
|
+
:item="(accordionItem)"
|
|
24
24
|
:expanded="accordionItem._expanded"
|
|
25
25
|
:index="accordionItem._index + 1")
|
|
26
26
|
.grow(v-html="accordionItem[options.itemTitleKey]")
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
.w-accordion__item-content(v-if="accordionItem._expanded" :class="contentClasses")
|
|
38
38
|
slot(
|
|
39
39
|
name="content"
|
|
40
|
-
:item="
|
|
40
|
+
:item="(accordionItem)"
|
|
41
41
|
:expanded="accordionItem._expanded"
|
|
42
42
|
:index="accordionItem._index + 1")
|
|
43
43
|
div(v-html="accordionItem[options.itemContentKey]")
|
|
@@ -56,26 +56,30 @@ export default {
|
|
|
56
56
|
'itemClasses',
|
|
57
57
|
'titleClasses',
|
|
58
58
|
'contentClasses',
|
|
59
|
-
'
|
|
59
|
+
'onItemToggle',
|
|
60
60
|
'onEndOfCollapse',
|
|
61
61
|
'getOriginalItem',
|
|
62
|
-
'registerItem'
|
|
62
|
+
'registerItem',
|
|
63
|
+
'state'
|
|
63
64
|
],
|
|
64
65
|
|
|
65
66
|
emits: ['focus'],
|
|
66
67
|
|
|
67
68
|
data () {
|
|
68
69
|
return {
|
|
69
|
-
|
|
70
|
-
...(this.item || {}),
|
|
71
|
-
_index: this.item?._index ?? 0,
|
|
72
|
-
_expanded: this.item?._expanded || false,
|
|
73
|
-
_disabled: this.item?._disabled || false
|
|
74
|
-
}
|
|
70
|
+
accordionItemIndex: this.item?._index
|
|
75
71
|
}
|
|
76
72
|
},
|
|
77
73
|
|
|
78
74
|
computed: {
|
|
75
|
+
accordionItem: {
|
|
76
|
+
get () {
|
|
77
|
+
return this.state.accordionItems[this.accordionItemIndex] || {}
|
|
78
|
+
},
|
|
79
|
+
set () {
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
},
|
|
79
83
|
itemClass () {
|
|
80
84
|
return {
|
|
81
85
|
'w-accordion__item--expanded': this.accordionItem._expanded,
|
|
@@ -86,27 +90,46 @@ export default {
|
|
|
86
90
|
}
|
|
87
91
|
},
|
|
88
92
|
|
|
93
|
+
methods: {
|
|
94
|
+
toggleItem (item, e) {
|
|
95
|
+
item._expanded = !item._expanded
|
|
96
|
+
|
|
97
|
+
this.onItemToggle(item)
|
|
98
|
+
|
|
99
|
+
// When a focused item moves in the page, the scrollTop is naturally updated by the browser.
|
|
100
|
+
// So if expandSingle is set to true, clicking on the next title of an open pane would shift the
|
|
101
|
+
// scrollTop unless unfocused while transitioning. Issue #3.
|
|
102
|
+
e.target.blur()
|
|
103
|
+
setTimeout(() => e.target.focus(), 300)
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
89
107
|
created () {
|
|
90
108
|
// Register this item to the w-accordion component.
|
|
91
|
-
this.registerItem(
|
|
109
|
+
this.accordionItemIndex = this.registerItem({
|
|
110
|
+
_index: 0,
|
|
111
|
+
_expanded: false,
|
|
112
|
+
_disabled: false,
|
|
113
|
+
...(this.item || {})
|
|
114
|
+
})
|
|
92
115
|
}
|
|
93
116
|
}
|
|
94
117
|
</script>
|
|
95
118
|
|
|
96
119
|
<style lang="scss">
|
|
97
|
-
|
|
120
|
+
.w-accordion__item {position: relative;}
|
|
98
121
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
122
|
+
button.w-accordion__expand-icon {color: rgba(var(--w-base-color-rgb), 0.4);}
|
|
123
|
+
.w-accordion__expand-icon {
|
|
124
|
+
margin-right: $base-increment;
|
|
102
125
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
126
|
+
.w-accordion--rotate-icon & {@include default-transition;}
|
|
127
|
+
&--rotate90 {transform: rotate(-90deg);}
|
|
128
|
+
&--expanded {transform: rotate(-180deg);}
|
|
129
|
+
&--expanded.w-accordion__expand-icon--rotate90 {transform: rotate(0deg);}
|
|
107
130
|
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
.w-icon:before {font-size: 1.1em;}
|
|
132
|
+
}
|
|
110
133
|
|
|
111
134
|
.w-accordion__item-title {
|
|
112
135
|
position: relative;
|
|
@@ -145,5 +168,4 @@ export default {
|
|
|
145
168
|
.w-accordion__item-content {
|
|
146
169
|
padding: (2 * $base-increment) (3 * $base-increment);
|
|
147
170
|
}
|
|
148
|
-
|
|
149
171
|
</style>
|