Skip to content

Commit 65e1bfd

Browse files
committed
Demos: fix ts issues in TreeList React demos
1 parent ae8bc93 commit 65e1bfd

File tree

25 files changed

+136
-46
lines changed

25 files changed

+136
-46
lines changed

apps/demos/Demos/TreeList/AIColumns/React/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import React from 'react';
2+
23
import TreeList, {
34
Column,
45
Scrolling,
56
Paging,
67
AI,
78
} from 'devextreme-react/tree-list';
9+
import type { TreeListTypes } from 'devextreme-react/tree-list';
10+
811
import { employees } from './data.ts';
912
import { aiIntegration } from './service.ts';
13+
import type { Employee as EmployeeType } from './types.ts';
1014
import Employee from './Employee.tsx';
1115
import Status from './Status.tsx';
1216

13-
const onAIColumnRequestCreating = (e) => {
17+
const onAIColumnRequestCreating = (
18+
e: TreeListTypes.AIColumnRequestCreatingEvent<Partial<EmployeeType>>
19+
) => {
1420
e.data = e.data.map((item) => ({
1521
ID: item.ID,
1622
First_Name: item.First_Name,

apps/demos/Demos/TreeList/AIColumns/React/Employee.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
2+
23
import { type TreeListTypes } from 'devextreme-react/tree-list';
4+
35
import { type Employee } from './types';
46

57
export default function Employee(props: TreeListTypes.ColumnCellTemplateData<Employee>) {

apps/demos/Demos/TreeList/AIColumns/React/Status.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
2+
23
import { type TreeListTypes } from 'devextreme-react/tree-list';
4+
35
import { type Employee } from './types';
46

57
export default function Status(props: TreeListTypes.ColumnCellTemplateData<Employee>) {

apps/demos/Demos/TreeList/AIColumns/React/service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { type AIMessage } from './types';
2-
import {
3-
AIIntegration,
1+
import { AzureOpenAI } from 'openai';
2+
3+
import { AIIntegration } from 'devextreme-react/common/ai-integration';
4+
import type {
45
RequestParams,
56
Response,
67
} from 'devextreme-react/common/ai-integration';
7-
import { AzureOpenAI } from 'openai';
88
import notify from 'devextreme/ui/notify';
99

10+
import type { AIMessage } from './types.ts';
11+
1012
const AzureOpenAIConfig = {
1113
dangerouslyAllowBrowser: true,
1214
deployment: 'gpt-4o-mini',

apps/demos/Demos/TreeList/AIColumns/ReactJs/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { AIIntegration } from 'devextreme-react/common/ai-integration';
21
import { AzureOpenAI } from 'openai';
2+
import { AIIntegration } from 'devextreme-react/common/ai-integration';
33
import notify from 'devextreme/ui/notify';
44

55
const AzureOpenAIConfig = {

apps/demos/Demos/TreeList/FilterModes/React/App.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import React, { useState } from 'react';
2-
import {
3-
TreeList, Column, SearchPanel, type TreeListTypes,
4-
} from 'devextreme-react/tree-list';
2+
3+
import { TreeList, Column, SearchPanel } from 'devextreme-react/tree-list';
4+
import type { TreeListTypes } from 'devextreme-react/tree-list';
55
import SelectBox from 'devextreme-react/select-box';
6+
67
import { employees, filterLabel } from './data.ts';
78

8-
const filterModes = ['matchOnly', 'withAncestors', 'fullBranch'];
9+
const filterModes: TreeListTypes.TreeListFilterMode[] = ['matchOnly', 'withAncestors', 'fullBranch'];
910

1011
const App = () => {
1112
const [filterMode, setFilterMode] = useState<TreeListTypes.TreeListFilterMode>('matchOnly');
1213

1314
return (
14-
<React.Fragment>
15+
<>
1516
<TreeList
1617
id="employees"
1718
dataSource={employees}
@@ -56,7 +57,7 @@ const App = () => {
5657
</SelectBox>
5758
</div>
5859
</div>
59-
</React.Fragment>
60+
</>
6061
);
6162
};
6263

apps/demos/Demos/TreeList/FilterModes/ReactJs/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const filterModes = ['matchOnly', 'withAncestors', 'fullBranch'];
77
const App = () => {
88
const [filterMode, setFilterMode] = useState('matchOnly');
99
return (
10-
<React.Fragment>
10+
<>
1111
<TreeList
1212
id="employees"
1313
dataSource={employees}
@@ -60,7 +60,7 @@ const App = () => {
6060
></SelectBox>
6161
</div>
6262
</div>
63-
</React.Fragment>
63+
</>
6464
);
6565
};
6666
export default App;

apps/demos/Demos/TreeList/FixedAndStickyColumns/React/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
2+
23
import { TreeList, Column, ColumnFixing } from 'devextreme-react/tree-list';
3-
import { Employee, employees } from './data.ts';
4+
5+
import { employees } from './data.ts';
6+
import type { Employee } from './data.ts';
47

58
const calculateCellValue = (data: Employee) => [data.Title, data.FirstName, data.LastName].join(' ');
69

apps/demos/Demos/TreeList/FormEditing/React/App.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import React from 'react';
2+
23
import {
3-
TreeList, Editing, Column, ValidationRule, Lookup, Button, type TreeListTypes,
4+
TreeList,
5+
Editing,
6+
Column,
7+
ValidationRule,
8+
Lookup,
9+
Button,
410
} from 'devextreme-react/tree-list';
11+
import type { TreeListTypes } from 'devextreme-react/tree-list';
12+
513
import { employees } from './data.ts';
14+
import type { Employee } from './data.ts';
615

716
const expandedRowKeys = [1, 2, 3, 4, 5];
817

@@ -11,7 +20,7 @@ const lookupData = {
1120
sort: 'Full_Name',
1221
};
1322

14-
const allowDeleting = (e) => e.row.data.ID !== 1;
23+
const allowDeleting = (e: { row: TreeListTypes.Row<Employee> }) => e.row.data.ID !== 1;
1524

1625
const onEditorPreparing = (e: TreeListTypes.EditorPreparingEvent) => {
1726
if (e.dataField === 'Head_ID' && e.row.data.ID === 1) {

apps/demos/Demos/TreeList/FormEditing/React/data.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
export const employees = [{
1+
export interface Employee {
2+
ID: number;
3+
Head_ID: number;
4+
Full_Name: string;
5+
Prefix: string;
6+
Title: string;
7+
City: string;
8+
State: string;
9+
Email: string;
10+
Skype: string;
11+
Mobile_Phone: string;
12+
Birth_Date: string;
13+
Hire_Date: string;
14+
}
15+
16+
export const employees: Employee[] = [{
217
ID: 1,
318
Head_ID: 0,
419
Full_Name: 'John Heart',

0 commit comments

Comments
 (0)