Skip to content

Commit 1743a65

Browse files
fix some TS in vue Demos. Navigation
1 parent 0c417f3 commit 1743a65

File tree

151 files changed

+805
-500
lines changed

Some content is hidden

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

151 files changed

+805
-500
lines changed

apps/demos/Demos/Accordion/Overview/Vue/CustomItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
import { type CompanyData } from './data';
3434
3535
defineProps<{
36-
itemData?: CompanyData
36+
itemData: CompanyData
3737
}>();
3838
</script>

apps/demos/Demos/Accordion/Overview/Vue/CustomTitle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
import { type CompanyData } from './data';
66
77
defineProps<{
8-
itemData?: CompanyData
8+
itemData: CompanyData
99
}>();
1010
</script>

apps/demos/Demos/ActionSheet/PopoverMode/Vue/ContactItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
import { type ContactInfo } from './data';
1010
1111
defineProps<{
12-
itemData?: ContactInfo
12+
itemData: ContactInfo
1313
}>();
1414
</script>

apps/demos/Demos/CardView/CardTemplate/Vue/App.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
:vehicle="vehicle"
5858
:id="ID"
5959
:model="`${TrademarkName} ${Name}`"
60-
:price="fields?.find(f => f.column?.dataField === 'Price')?.text"
60+
:price="getPriceText(fields)"
6161
:category-name="CategoryName"
6262
:modification="Modification"
6363
:body-style-name="BodyStyleName"
@@ -90,13 +90,20 @@ import { DxCardView, DxColumn, DxHeaderFilter, DxSearchPanel, DxPaging } from 'd
9090
import { DxPopup, DxPosition } from 'devextreme-vue/popup';
9191
import LicenseInfo from './LicenseInfo.vue';
9292
import VehicleCard from './VehicleCard.vue';
93-
import { vehicles } from './data.ts';
93+
import { vehicles, type Vehicle } from './data.ts';
9494
import { ref } from 'vue';
9595
9696
const popupVisible = ref(false);
97-
const currentVehicle = ref(null);
97+
const currentVehicle = ref<Vehicle | undefined>();
9898
99-
function showInfo(vehicle) {
99+
function getPriceText(
100+
fields?: Array<{ column?: { dataField?: string }, text?: string }>,
101+
): string {
102+
const priceField = fields?.find((field) => field?.column?.dataField === 'Price');
103+
return priceField?.text || '';
104+
}
105+
106+
function showInfo(vehicle: Vehicle) {
100107
currentVehicle.value = vehicle;
101108
popupVisible.value = true;
102109
}

apps/demos/Demos/CardView/ColumnChooser/Vue/App.vue

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@
88
:data-source="['dragAndDrop', 'select']"
99
:input-attr="{ 'aria-label': 'Column Chooser Mode' }"
1010
:value="columnChooserMode"
11-
@value-changed="({ value }) => { columnChooserMode = value; }"
11+
@value-changed="onModeChanged"
1212
/>
1313
</div>
1414
<div className="option">
1515
<DxCheckBox
1616
text="Search Enabled"
1717
:value="searchEnabled"
18-
@value-changed="({ value }) => { searchEnabled = value; }"
18+
@value-changed="onSearchEnabledChanged"
1919
/>
2020
</div>
2121
<div className="option">
2222
<DxCheckBox
2323
text="Allow Select All"
2424
:value="allowSelectAll"
25-
@value-changed="({ value }) => { allowSelectAll = value; }"
25+
@value-changed="onAllowSelectAllChanged"
2626
:disabled="columnChooserMode !== 'select'"
2727
/>
2828
</div>
2929
<div className="option">
3030
<DxCheckBox
3131
text="Select By Click On Item"
3232
:value="selectByClick"
33-
@value-changed="({ value }) => { selectByClick = value; }"
33+
@value-changed="onSelectByClickChanged"
3434
:disabled="columnChooserMode !== 'select'"
3535
/>
3636
</div>
3737
<div className="option">
3838
<DxCheckBox
3939
text="Allow Column Reordering"
4040
:value="allowColumnReordering"
41-
@value-changed="({ value }) => { allowColumnReordering = value; }"
41+
@value-changed="onAllowColumnReorderingChanged"
4242
/>
4343
</div>
4444
</div>
@@ -104,8 +104,8 @@ import {
104104
DxCardView, DxColumn, DxCardCover, DxSearchPanel, DxColumnChooser,
105105
DxColumnChooserSearch, DxColumnChooserSelection,
106106
} from 'devextreme-vue/card-view';
107-
import { DxSelectBox } from 'devextreme-vue/select-box';
108-
import { DxCheckBox } from 'devextreme-vue/check-box';
107+
import { DxSelectBox, type DxSelectBoxTypes } from 'devextreme-vue/select-box';
108+
import { DxCheckBox, type DxCheckBoxTypes } from 'devextreme-vue/check-box';
109109
import { employees, type Employee } from './data.ts';
110110
111111
function altExpr({ First_Name, Last_Name }: Employee): string {
@@ -126,6 +126,26 @@ const allowSelectAll = ref(true);
126126
const selectByClick = ref(true);
127127
const allowColumnReordering = ref(false);
128128
129+
function onModeChanged(e: DxSelectBoxTypes.ValueChangedEvent) {
130+
columnChooserMode.value = e.value;
131+
}
132+
133+
function onSearchEnabledChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
134+
searchEnabled.value = e.value;
135+
}
136+
137+
function onAllowSelectAllChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
138+
allowSelectAll.value = e.value;
139+
}
140+
141+
function onSelectByClickChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
142+
selectByClick.value = e.value;
143+
}
144+
145+
function onAllowColumnReorderingChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
146+
allowColumnReordering.value = e.value;
147+
}
148+
129149
</script>
130150
<style>
131151
.options-panel {

apps/demos/Demos/CardView/ColumnHeaderFilter/Vue/App.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,25 @@ function getOrderDay(rowData: Order) {
7070
}
7171
7272
function calculateOrderDateFilterExpression(
73-
this: DxCardViewTypes.Column, value, selectedFilterOperations, target,
73+
this: DxCardViewTypes.Column,
74+
value: unknown,
75+
selectedFilterOperations: string | null,
76+
target: string,
7477
) {
7578
if (value === 'weekends') {
7679
return [[getOrderDay, '=', 0], 'or', [getOrderDay, '=', 6]];
7780
}
7881
return this.defaultCalculateFilterExpression(value, selectedFilterOperations, target) as any;
7982
}
8083
81-
function orderDateHeaderFilterDataSource(data) {
82-
data.dataSource.postProcess = function (results) {
84+
type HeaderFilterDataSourceArg = {
85+
dataSource: {
86+
postProcess: (results: Array<{ text: string; value: unknown }>) => Array<{ text: string; value: unknown }>;
87+
};
88+
};
89+
90+
function orderDateHeaderFilterDataSource(data: HeaderFilterDataSourceArg): void {
91+
data.dataSource.postProcess = function (results: Array<{ text: string; value: unknown }>) {
8392
results.push({
8493
text: 'Weekends',
8594
value: 'weekends',

apps/demos/Demos/CardView/DataValidation/Vue/App.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,27 @@ import {
173173
DxItem, DxSearchPanel, DxRequiredRule, DxEmailRule,
174174
DxAsyncRule, DxCustomRule,
175175
} from 'devextreme-vue/card-view';
176+
import { type ValidationCallbackData } from 'devextreme-vue/common';
176177
import 'devextreme-vue/text-area';
177178
import { employees, type Employee } from './data.ts';
178179
179-
function altExpr({ fullName }: Employee) {
180+
function altExpr({ fullName }: Employee): string {
180181
return `Photo of ${fullName}`;
181182
}
182183
183-
function imageExpr({ picture }: Employee) {
184+
function imageExpr({ picture }: Employee): string {
184185
return picture;
185186
}
186187
187-
function calculateFullName({ firstName, lastName }: Employee) {
188+
function calculateFullName({ firstName, lastName }: Employee): string {
188189
return `${firstName} ${lastName}`;
189190
}
190191
191192
const emailValidationUrl = 'https://js.devexpress.com/Demos/NetCore/RemoteValidation/CheckUniqueEmailAddress';
192193
193-
async function emailValidationCallback(params) {
194+
async function emailValidationCallback(
195+
params: ValidationCallbackData,
196+
): Promise<boolean> {
194197
const response = await fetch(emailValidationUrl, {
195198
method: 'POST',
196199
headers: {
@@ -207,7 +210,7 @@ async function emailValidationCallback(params) {
207210
return result;
208211
}
209212
210-
function hireDateValidationCallback(params) {
211-
return new Date(params.value) > new Date(params.data.birthDate);
212-
}
213+
const hireDateValidationCallback = (
214+
params: ValidationCallbackData,
215+
): boolean => new Date(params.value) > new Date(params.data.birthDate);
213216
</script>

apps/demos/Demos/CardView/DataValidation/Vue/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Employee {
1818
departmentID: number;
1919
department: string;
2020
status: string;
21-
notes: string;
21+
notes: string | null;
2222
pictureName: string;
2323
picture: string;
2424
}

apps/demos/Demos/CardView/FieldTemplate/Vue/Priority.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const props = defineProps<{
1616
const priority = computed(() =>
1717
priorities.find((p) => p.id === props.priorityID),
1818
);
19-
const priorityClassName = `task__priority task__priority--${priority.value.postfix}`;
19+
const priorityClassName = computed(() =>
20+
`task__priority task__priority--${priority.value?.postfix || ''}`
21+
);
2022
</script>
2123

2224
<style>

apps/demos/Demos/CardView/FieldTemplate/Vue/Progress.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
2-
<div className="task__progress">
3-
<DxProgressBar
4-
:value="value"
5-
:element-attr="{ 'aria-label': 'Progress Bar' }"
6-
:statusFormat="(_, value: number) => `${value}%`"
7-
/>
8-
</div>
2+
<div className="task__progress">
3+
<DxProgressBar
4+
:value="value"
5+
:element-attr="{ 'aria-label': 'Progress Bar' }"
6+
:statusFormat="statusFormat"
7+
/>
8+
</div>
99
</template>
1010

1111
<script setup lang="ts">
@@ -14,6 +14,8 @@ import { DxProgressBar } from 'devextreme-vue/progress-bar';
1414
const props = defineProps<{
1515
value: number,
1616
}>();
17+
18+
const statusFormat = (_: unknown, value: number) => `${value}%`;
1719
</script>
1820

1921
<style>

0 commit comments

Comments
 (0)