Skip to content

Commit f1624d4

Browse files
authored
refactor(components): DLT-3160 standardize v-model event handling (#1201)
1 parent df3bd74 commit f1624d4

60 files changed

Lines changed: 174 additions & 352 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/dialtone-documentation/docs/components/banner.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Banners are a type of notice and so you can use the following [Notice](notice.md
4141
```vue demo-only
4242
<dt-stack direction="row" gap="200">
4343
<dt-select-menu :show-label="false" label="Style" :options="bannerOptions" v-model="selectedKind" />
44-
<dt-checkbox value="important" @input="toggleImportant">Important</dt-checkbox>
44+
<dt-checkbox value="important" @update:model-value="toggleImportant">Important</dt-checkbox>
4545
<dt-button @click="toggleBanner('example-kind')">Toggle Example</dt-button>
4646
</dt-stack>
4747
```
@@ -139,8 +139,8 @@ function toggleBanner (id) {
139139
}
140140
}
141141

142-
function toggleImportant () {
143-
important.value = !important.value;
142+
function toggleImportant (checked) {
143+
important.value = checked;
144144
}
145145

146146
function closeBanner () {

apps/dialtone-documentation/docs/components/combobox-multi-select.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ storybook: https://dialtone.dialpad.com/vue/?path=/story/components-combobox-mul
1414
<dt-combobox-multi-select
1515
label="Label Text"
1616
:selected-items="selectedItems"
17-
@input="onComboboxInput"
17+
@update:model-value="onComboboxInput"
1818
@select="onComboboxSelect"
1919
@remove="onComboboxRemove"
2020
>
@@ -40,7 +40,7 @@ storybook: https://dialtone.dialpad.com/vue/?path=/story/components-combobox-mul
4040
ref="comboboxMultiSelect"
4141
label="Label Text"
4242
:selected-items="selectedItems"
43-
@input="onInput"
43+
@update:model-value="onInput"
4444
@select="onSelect"
4545
@remove="onRemove"
4646
>
@@ -94,7 +94,7 @@ Adds validation for max selection. Make sure to provide the following props:
9494
:selected-items="maxSelectedItems"
9595
:max-selected="2"
9696
:max-selected-message="[{ message: 'More than 2 selected', type: 'critical' }]"
97-
@input="onMaxSelectInput"
97+
@update:model-value="onMaxSelectInput"
9898
@select="onMaxSelectSelect"
9999
@remove="onMaxSelectRemove"
100100
@max-selected="onMaxSelected"
@@ -124,7 +124,7 @@ Adds validation for max selection. Make sure to provide the following props:
124124
:selected-items="selectedItems"
125125
:max-selected="2"
126126
:max-selected-message="[{ message: 'More than 2 selected', type: 'critical' }]"
127-
@input="onInput"
127+
@update:model-value="onInput"
128128
@select="onSelect"
129129
@remove="onRemove"
130130
@max-selected="onMaxSelected"

apps/dialtone-documentation/docs/components/combobox-with-popover.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ storybook: https://dialtone.dialpad.com/vue/?path=/story/components-combobox-wit
2020
v-model="inputValue"
2121
placeholder="Select one or start typing"
2222
v-bind="inputProps"
23-
@input="onInput"
23+
@update:model-value="onInput"
2424
/>
2525
</template>
2626
<template #list="{ listProps }">
@@ -85,7 +85,7 @@ You can add header and footer content to the popover using the `header` and `foo
8585
v-model="inputValueHeaderFooter"
8686
placeholder="Select one or start typing"
8787
v-bind="inputProps"
88-
@input="onInput"
88+
@update:model-value="onInput"
8989
/>
9090
</template>
9191
<template #list="{ listProps }">

apps/dialtone-documentation/docs/components/filter-pill.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ The label updates to show the selected option, and a clear button resets to the
364364
:key="filter.name"
365365
:label="filter.name"
366366
:value="filter.name"
367-
@input="$event => selectedConversationType = $event"
367+
@update:model-value="$event => selectedConversationType = $event"
368368
/>
369369
</dt-radio-group>
370370
</template>

apps/dialtone-documentation/docs/components/input-group.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787
// update provided value if injected
8888
this.setGroupValue(value);
8989

90-
this.$emit('input', value);
90+
this.$emit('update:modelValue', value);
9191
}
9292
},
9393
},

apps/dialtone-documentation/docs/components/radio-group.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ The event handler is only needed if you need to do additional processing. The v-
8585
v-model="selectedFruits"
8686
name="fruits-radio-group"
8787
legend="Fruits"
88-
@input="onInput"
88+
@update:model-value="onInput"
8989
>
9090
<dt-radio value="pear">Pear</dt-radio>
9191
<dt-radio value="kiwi">Kiwi</dt-radio>

apps/dialtone-documentation/docs/components/select-menu.md

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ A select is normally paired with a label, but there are times when it can be use
5858
]"
5959
label="Default"
6060
:model-value="modelValue"
61-
@input="onInput"
62-
@change="onChange"
61+
@update:model-value="onInput"
6362
/>
6463
<dt-select-menu
6564
:options="[
@@ -71,8 +70,7 @@ A select is normally paired with a label, but there are times when it can be use
7170
label="Disabled"
7271
disabled
7372
:model-value="modelValue"
74-
@input="onInput"
75-
@change="onChange"
73+
@update:model-value="onInput"
7674
/>
7775
```
7876

@@ -91,8 +89,7 @@ A select is normally paired with a label, but there are times when it can be use
9189
label="Label"
9290
description="Optional description text"
9391
:model-value="modelValue"
94-
@input="onInput"
95-
@change="onChange"
92+
@update:model-value="onInput"
9693
/>
9794
```
9895

@@ -126,8 +123,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
126123
:messages="[{ message: `Critical validation message`, type: `critical` }]"
127124
label="Label"
128125
:model-value="modelValue"
129-
@input="onInput"
130-
@change="onChange"
126+
@update:model-value="onInput"
131127
/>
132128
<dt-select-menu
133129
:options="[
@@ -139,8 +135,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
139135
:messages="[{ message: `Positive validation message`, type: `positive` }]"
140136
label="Label"
141137
:model-value="modelValue"
142-
@input="onInput"
143-
@change="onChange"
138+
@update:model-value="onInput"
144139
/>
145140
<dt-select-menu
146141
:options="[
@@ -152,8 +147,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
152147
:messages="[{ message: `Warning validation message`, type: `warning` }]"
153148
label="Label"
154149
:model-value="modelValue"
155-
@input="onInput"
156-
@change="onChange"
150+
@update:model-value="onInput"
157151
/>
158152
```
159153

@@ -188,8 +182,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
188182
:messages="[{ message: `Critical validation message`, type: `critical` }]"
189183
label="Label"
190184
:model-value="modelValue"
191-
@input="onInput"
192-
@change="onChange"
185+
@update:model-value="onInput"
193186
:show-messages="false"
194187
/>
195188
<dt-select-menu
@@ -202,8 +195,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
202195
:messages="[{ message: `Positive validation message`, type: `positive` }]"
203196
label="Label"
204197
:model-value="modelValue"
205-
@input="onInput"
206-
@change="onChange"
198+
@update:model-value="onInput"
207199
:show-messages="false"
208200
/>
209201
<dt-select-menu
@@ -216,8 +208,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
216208
:messages="[{ message: `Warning validation message`, type: `warning` }]"
217209
label="Label"
218210
:model-value="modelValue"
219-
@input="onInput"
220-
@change="onChange"
211+
@update:model-value="onInput"
221212
:show-messages="false"
222213
/>
223214
```
@@ -239,8 +230,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
239230
{ value: `3`, label: `Option 3` },
240231
]"
241232
:model-value="modelValue"
242-
@input="onInput"
243-
@change="onChange"
233+
@update:model-value="onInput"
244234
>
245235
<template #label>
246236
<div>Slotted label</div>
@@ -265,8 +255,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
265255
{ value: `3`, label: `Option 3` },
266256
]"
267257
:model-value="modelValue"
268-
@input="onInput"
269-
@change="onChange"
258+
@update:model-value="onInput"
270259
>
271260
<template #description>
272261
<div>Slotted description</div>
@@ -288,8 +277,7 @@ Provides feedback to the user based on their interaction, or lack thereof, with
288277
<!-- @code -->
289278
<dt-select-menu
290279
:model-value="modelValue"
291-
@input="onInput"
292-
@change="onChange"
280+
@update:model-value="onInput"
293281
>
294282
<template #default>
295283
<option
@@ -326,8 +314,7 @@ We offer different sizes for instances in which the interface requires a smaller
326314
label="Label"
327315
:size="100|200|300|400|500"
328316
:model-value="modelValue"
329-
@input="onInput"
330-
@change="onChange"
317+
@update:model-value="onInput"
331318
/>
332319
```
333320

apps/dialtone-documentation/docs/components/toast.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ keywords: ["notification", "snackbar", "alert", "message", "d-toast", "DtToast",
1818
<div class="d-fl-grow1">
1919
<dt-select-menu :show-label="false" label="Style" :options="toastOptions" v-model="selectedKind" />
2020
</div>
21-
<dt-checkbox value="important" @input="toggleImportant">Important</dt-checkbox>
21+
<dt-checkbox value="important" @update:model-value="toggleImportant">Important</dt-checkbox>
2222
<dt-button @click="toggleToast">Toggle Example</dt-button>
2323
</dt-stack>
2424
<!-- @code -->
@@ -162,8 +162,8 @@ const updateOpen = (value) => {
162162
if (!value) showDurationToast.value = false;
163163
};
164164

165-
function toggleImportant () {
166-
important.value = !important.value;
165+
function toggleImportant (checked) {
166+
important.value = checked;
167167
}
168168
function togglePinned () {
169169
pinned.value = !pinned.value;

apps/dialtone-documentation/docs/components/toggle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ disabled states. However, if a label default slot is not used with `DtToggle`
9999

100100
The button element should capture keyboard focus as long as it is not disabled (`disabled` prop is `true`).
101101
`ENTER` key will
102-
emit a **change** event with the current value of the toggle and will change its internal `checked` state.
102+
emit an **update:modelValue** event with the current value of the toggle and will change its internal `checked` state.
103103

104104
<script setup>
105105
import { ref } from 'vue'

packages/dialtone-vue/common/mixins/input_group.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ export const InputGroupMixin = {
120120

121121
emits: [
122122
/**
123-
* Native input event
123+
* Event fired to sync the modelValue prop with the parent component
124124
*
125-
* @event input
126-
* @type {KeyboardEvent}
125+
* @event update:modelValue
126+
* @type {String | Number | Boolean | Object}
127127
*/
128-
'input',
128+
'update:modelValue',
129129
],
130130

131131
data () {
@@ -168,7 +168,7 @@ export const InputGroupMixin = {
168168
*/
169169
setGroupValue (newValue) {
170170
this.internalValue = newValue;
171-
this.$emit('input', newValue);
171+
this.$emit('update:modelValue', newValue);
172172
},
173173
},
174174

0 commit comments

Comments
 (0)