Skip to content

Commit 2e90b60

Browse files
Fix TS in Vue demos. Scheduler (#30888)
Co-authored-by: EugeniyKiyashko <[email protected]>
1 parent 83556ed commit 2e90b60

File tree

35 files changed

+194
-225
lines changed

35 files changed

+194
-225
lines changed

apps/demos/Demos/Menu/Overview/Vue/App.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { computed, ref } from 'vue';
5353
import DxMenu, { type DxMenuTypes } from 'devextreme-vue/menu';
5454
import DxCheckBox from 'devextreme-vue/check-box';
5555
import DxSelectBox from 'devextreme-vue/select-box';
56-
import service from './data.ts';
56+
import service, { type Product } from './data.ts';
5757
5858
const showSubmenuModes = [{
5959
name: 'onHover',
@@ -69,11 +69,11 @@ const showFirstSubmenuModes = computed(() => showSubmenuModes.find(
6969
));
7070
const orientation = ref<DxMenuTypes.Orientation>('horizontal');
7171
const hideSubmenuOnMouseLeave = ref(false);
72-
const currentProduct = ref(null);
72+
const currentProduct = ref<Product>();
7373
74-
function itemClick(e) {
75-
if (e.itemData.price) {
76-
currentProduct.value = e.itemData;
74+
function itemClick(e: DxMenuTypes.ItemClickEvent) {
75+
if (e.itemData?.price) {
76+
currentProduct.value = e.itemData as Product;
7777
}
7878
}
7979
</script>

apps/demos/Demos/Menu/Overview/Vue/data.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
const products = [{
1+
export interface Product {
2+
id: string;
3+
name: string;
4+
price?: number;
5+
icon?: string;
6+
disabled?: boolean;
7+
items?: Product[];
8+
}
9+
const products: Product[] = [{
210
id: '1',
311
name: 'Video Players',
412
items: [{

apps/demos/Demos/Menu/Scrolling/Vue/App.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ const products = ref(service.getProducts());
3131
const limitSubmenuHeight = ref(false);
3232
3333
function itemClick(e: DxMenuTypes.ItemClickEvent) {
34-
if (!e.itemData.items) {
35-
notify(`The "${e.itemData.text}" item was clicked`, 'success', 1500);
34+
if (!e.itemData?.items) {
35+
notify(`The "${e.itemData?.text}" item was clicked`, 'success', 1500);
3636
}
3737
}
3838
3939
function onSubmenuShowing({ submenuContainer }: DxMenuTypes.SubmenuShowingEvent) {
40-
submenuContainer.style.maxHeight = limitSubmenuHeight.value ? `${SUBMENU_HEIGHT}px` : '';
40+
if (submenuContainer) {
41+
submenuContainer.style.maxHeight = limitSubmenuHeight.value ? `${SUBMENU_HEIGHT}px` : '';
42+
}
4143
}
4244
</script>
4345
<style>

apps/demos/Demos/Pagination/Overview/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { computed, ref } from 'vue';
4242
import DxPagination from 'devextreme-vue/pagination';
4343
import { employees } from './data.ts';
4444
45-
const getPageEmployees = (pageIndex, pageSize) => {
45+
const getPageEmployees = (pageIndex: number, pageSize: number) => {
4646
return employees.slice((pageIndex - 1) * pageSize, pageIndex * pageSize);
4747
}
4848

apps/demos/Demos/PivotGrid/ChartIntegration/Vue/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { sales } from './data.ts';
4545
4646
const grid = ref<DxPivotGrid>();
4747
const chart = ref<DxChart>();
48-
const dataSource = {
48+
const dataSource: Record<string, any> = {
4949
fields: [{
5050
caption: 'Region',
5151
width: 120,
@@ -78,7 +78,7 @@ const dataSource = {
7878
}],
7979
store: sales,
8080
};
81-
const customizeTooltip = ({ seriesName, originalValue }) => {
81+
const customizeTooltip = ({ seriesName, originalValue }: Record<string, any>) => {
8282
const valueText = (seriesName.indexOf('Total') !== -1)
8383
? new Intl.NumberFormat('en-EN', { style: 'currency', currency: 'USD' }).format(originalValue)
8484
: originalValue;

apps/demos/Demos/PivotGrid/Customization/Vue/App.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ import DxPivotGrid, {
4747
DxFieldChooser,
4848
type DxPivotGridTypes,
4949
} from 'devextreme-vue/pivot-grid';
50+
import DxCheckBox, { type DxCheckBoxTypes } from 'devextreme-vue/check-box';
5051
import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
51-
import DxCheckBox from 'devextreme-vue/check-box';
5252
import { sales } from './data.ts';
5353
5454
const showTotalsPrior = ref<DxPivotGridTypes.PivotGridTotalDisplayMode>('none');
@@ -91,13 +91,13 @@ const dataSource = new PivotGridDataSource({
9191
store: sales,
9292
});
9393
94-
function onShowTotalsPriorChanged(data) {
94+
function onShowTotalsPriorChanged(data: DxCheckBoxTypes.ValueChangedEvent) {
9595
showTotalsPrior.value = data.value ? 'both' : 'none';
9696
}
97-
function onDataFieldAreaChanged(data) {
97+
function onDataFieldAreaChanged(data: DxCheckBoxTypes.ValueChangedEvent) {
9898
dataFieldArea.value = data.value ? 'row' : 'column';
9999
}
100-
function onRowHeaderLayoutChanged(data) {
100+
function onRowHeaderLayoutChanged(data: DxCheckBoxTypes.ValueChangedEvent) {
101101
rowHeaderLayout.value = data.value ? 'tree' : 'standard';
102102
}
103103
</script>

apps/demos/Demos/PivotGrid/DrillDown/Vue/App.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ const dataSource = new PivotGridDataSource({
8181
store: sales,
8282
});
8383
const dataGridRef = ref();
84-
const drillDownDataSource = ref<DataSource>(null);
84+
const drillDownDataSource = ref<DataSource>();
8585
const popupTitle = ref('');
8686
const popupVisible = ref(false);
8787
88-
function onCellClick(e: DxPivotGridTypes.CellClickEvent) {
89-
if (e.area === 'data') {
90-
const pivotGridDataSource = e.component.getDataSource();
91-
const rowPathLength = e.cell.rowPath.length;
92-
const rowPathName = e.cell.rowPath[rowPathLength - 1];
93-
drillDownDataSource.value = pivotGridDataSource.createDrillDownDataSource(e.cell);
88+
function onCellClick({ area, cell, component }: DxPivotGridTypes.CellClickEvent) {
89+
if (area === 'data' && cell?.rowPath) {
90+
const pivotGridDataSource = component.getDataSource();
91+
const rowPathLength = cell.rowPath.length;
92+
const rowPathName = cell.rowPath[rowPathLength - 1];
93+
drillDownDataSource.value = pivotGridDataSource.createDrillDownDataSource(cell);
9494
popupTitle.value = `${
9595
rowPathName || 'Total'
9696
} Drill Down Data`;

apps/demos/Demos/PivotGrid/ExcelJSCellCustomization/Vue/App.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { Workbook } from 'devextreme-exceljs-fork';
2727
// Our demo infrastructure requires us to use 'file-saver-es'.
2828
// We recommend that you use the official 'file-saver' package in your applications.
2929
import { saveAs } from 'file-saver-es';
30-
import { exportPivotGrid } from 'devextreme/excel_exporter';
30+
import { exportPivotGrid, type PivotGridCell } from 'devextreme-vue/common/export/excel';
3131
import { sales } from './data.ts';
3232
3333
interface ConditionalAppearance {
@@ -69,8 +69,8 @@ function onExporting(e: DxPivotGridTypes.ExportingEvent) {
6969
exportPivotGrid({
7070
component: e.component,
7171
worksheet,
72-
customizeCell: ({ pivotCell, excelCell }) => {
73-
if (isDataCell(pivotCell) || isTotalCell(pivotCell)) {
72+
customizeCell: ({ pivotCell, excelCell }: { pivotCell?: PivotGridCell, excelCell?: any }) => {
73+
if (pivotCell && (isDataCell(pivotCell) || isTotalCell(pivotCell))) {
7474
const appearance = getConditionalAppearance(pivotCell);
7575
Object.assign(excelCell, getExcelCellFormat(appearance));
7676
}
@@ -90,15 +90,15 @@ function onExporting(e: DxPivotGridTypes.ExportingEvent) {
9090
});
9191
}
9292
function onCellPrepared({ cell, cellElement }: DxPivotGridTypes.CellPreparedEvent) {
93-
if (isDataCell(cell) || isTotalCell(cell)) {
93+
if (cell && cellElement && (isDataCell(cell) || isTotalCell(cell))) {
9494
const appearance = getConditionalAppearance(cell);
9595
Object.assign(cellElement.style, getCssStyles(appearance));
9696
}
9797
}
98-
function isDataCell(cell) {
98+
function isDataCell(cell: DxPivotGridTypes.Cell) {
9999
return (cell.rowType === 'D' && cell.columnType === 'D');
100100
}
101-
function isTotalCell(cell) {
101+
function isTotalCell(cell: DxPivotGridTypes.Cell) {
102102
return (cell.type === 'T' || cell.type === 'GT' || cell.rowType === 'T' || cell.rowType === 'GT' || cell.columnType === 'T' || cell.columnType === 'GT');
103103
}
104104
function getExcelCellFormat({ fill, font, bold = false }: ConditionalAppearance) {
@@ -114,7 +114,7 @@ function getCssStyles({ fill, font, bold = false }: ConditionalAppearance) {
114114
'font-weight': bold ? 'bold' : undefined,
115115
};
116116
}
117-
function getConditionalAppearance(cell): ConditionalAppearance {
117+
function getConditionalAppearance(cell: DxPivotGridTypes.Cell): ConditionalAppearance {
118118
if (isTotalCell(cell)) {
119119
return { fill: 'F2F2F2', font: '3F3F3F', bold: true };
120120
}

apps/demos/Demos/PivotGrid/FieldPanel/Vue/App.vue

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ import { ref } from 'vue';
6666
import DxPivotGrid, {
6767
DxFieldChooser,
6868
DxFieldPanel,
69+
type DxPivotGridTypes,
6970
} from 'devextreme-vue/pivot-grid';
70-
import DxCheckBox from 'devextreme-vue/check-box';
71+
import DxCheckBox, { type DxCheckBoxTypes } from 'devextreme-vue/check-box';
7172
import PivotGridDataSource from 'devextreme/ui/pivot_grid/data_source';
7273
import { sales } from './data.ts';
7374
@@ -86,7 +87,7 @@ const gridDataSource = new PivotGridDataSource({
8687
dataField: 'city',
8788
width: 150,
8889
area: 'row',
89-
selector(data) {
90+
selector(data: Record<string, unknown>) {
9091
return `${data.city} (${data.country})`;
9192
},
9293
}, {
@@ -103,36 +104,34 @@ const gridDataSource = new PivotGridDataSource({
103104
store: sales,
104105
});
105106
106-
function OnShowColumnFieldsChanged(e) {
107+
function OnShowColumnFieldsChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
107108
showColumnFields.value = e.value;
108109
}
109-
function OnShowDataFieldsChanged(e) {
110+
function OnShowDataFieldsChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
110111
showDataFields.value = e.value;
111112
}
112-
function OnShowFilterFieldsChanged(e) {
113+
function OnShowFilterFieldsChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
113114
showFilterFields.value = e.value;
114115
}
115-
function OnShowRowFieldsChanged(e) {
116+
function OnShowRowFieldsChanged(e: DxCheckBoxTypes.ValueChangedEvent) {
116117
showRowFields.value = e.value;
117118
}
118-
function onContextMenuPreparing(e) {
119+
function onContextMenuPreparing(e: DxPivotGridTypes.ContextMenuPreparingEvent) {
119120
const dataSource = e.component.getDataSource();
120-
const sourceField = e.field;
121+
const sourceField: Record<string, any> | undefined = e.field;
121122
122123
if (sourceField) {
123124
if (!sourceField.groupName || sourceField.groupIndex === 0) {
124-
e.items.push({
125+
e.items?.push({
125126
text: 'Hide field',
126127
onItemClick() {
127128
let fieldIndex: number;
128129
129-
if (sourceField.groupName) {
130-
fieldIndex = dataSource
131-
.getAreaFields(sourceField.area, true)[sourceField.areaIndex]
132-
.index;
133-
} else {
134-
fieldIndex = sourceField.index;
135-
}
130+
const dataSourceField: Record<string, any> = sourceField.groupName
131+
? dataSource.getAreaFields(sourceField.area, true)[sourceField.areaIndex]
132+
: sourceField
133+
134+
fieldIndex = dataSourceField.index;
136135
137136
dataSource.field(fieldIndex, {
138137
area: null,
@@ -143,7 +142,7 @@ function onContextMenuPreparing(e) {
143142
}
144143
145144
if (sourceField.dataType === 'number') {
146-
const setSummaryType = function(args) {
145+
const setSummaryType = function(args: Record<string, any>) {
147146
dataSource.field(sourceField.index, {
148147
summaryType: args.itemData.value,
149148
});
@@ -152,7 +151,7 @@ function onContextMenuPreparing(e) {
152151
};
153152
const menuItems: Record<string, any>[] = [];
154153
155-
e.items.push({ text: 'Summary Type', items: menuItems });
154+
e.items?.push({ text: 'Summary Type', items: menuItems });
156155
157156
['Sum', 'Avg', 'Min', 'Max'].forEach((summaryType) => {
158157
const summaryTypeValue = summaryType.toLowerCase();
@@ -161,7 +160,7 @@ function onContextMenuPreparing(e) {
161160
text: summaryType,
162161
value: summaryType.toLowerCase(),
163162
onItemClick: setSummaryType,
164-
selected: e.field.summaryType === summaryTypeValue,
163+
selected: e.field?.summaryType === summaryTypeValue,
165164
});
166165
});
167166
}

apps/demos/Demos/PivotGrid/IntegratedFieldChooser/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
DxSelectBox,
4141
} from 'devextreme-vue/select-box';
4242
43-
const dataSource = {
43+
const dataSource: Record<string, any> = {
4444
fields: [
4545
{ dataField: '[Product].[Category]', area: 'row' },
4646
{

0 commit comments

Comments
 (0)