Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation: Transfer demos to TS #2825

Merged
merged 32 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0af2bd3
Typestat config created + files renamed
ivanblinov2k17 Sep 6, 2023
a6e95c7
Enhance types with typestat
ivanblinov2k17 Sep 6, 2023
d66739b
Improve typings + add missing @types/react-dom package
ivanblinov2k17 Sep 7, 2023
4e6d107
Typings improvments
ivanblinov2k17 Sep 13, 2023
9a5e59c
fix cannot use jsx components in vscode
ivanblinov2k17 Sep 13, 2023
8d718b9
Types improv + tsconf changes to remove component is not tsx problem
ivanblinov2k17 Sep 14, 2023
249269c
Merge remote-tracking branch 'DevExtreme/23_2' into ts-navigation
ivanblinov2k17 Sep 14, 2023
ad123e2
Check tsc version on CI
ivanblinov2k17 Sep 14, 2023
b624d3b
Revert printing tsc version on CI
ivanblinov2k17 Sep 14, 2023
6d48643
Revert TSConfig changes
ivanblinov2k17 Sep 14, 2023
51a4869
Generate JS from ts
ivanblinov2k17 Sep 14, 2023
71c90e9
Revert bad js generation result for DateBox and DateRangeBox
ivanblinov2k17 Sep 14, 2023
aafc163
Fix sysemJs index.js import to tsx in index.html
ivanblinov2k17 Sep 14, 2023
a02ab86
Final TS enhansments
ivanblinov2k17 Sep 15, 2023
c6c4145
generate js
ivanblinov2k17 Sep 15, 2023
5aa81e3
Exclude Vue from ts config because it's polluting react JSX with wron…
ivanblinov2k17 Sep 15, 2023
53f55ce
Revert excluding vue from ts
ivanblinov2k17 Sep 15, 2023
47e97a7
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Sep 26, 2023
223f334
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Sep 27, 2023
be8b1b4
Update ts for tabs demos (merge)
ivanblinov2k17 Sep 27, 2023
aafa521
Fix minor errors
ivanblinov2k17 Sep 28, 2023
573ef9f
Missed extension in tabpanel
ivanblinov2k17 Sep 28, 2023
39f86ad
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Sep 29, 2023
7a573fa
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Oct 2, 2023
8fd51fa
Drawer: navigationList fix file extension
ivanblinov2k17 Oct 2, 2023
63addb4
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Nov 8, 2023
e3d6b49
Fix generate-js
ivanblinov2k17 Nov 9, 2023
e619400
Fix missing merge changes
ivanblinov2k17 Nov 9, 2023
282da3e
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Nov 9, 2023
294a4e1
Fix styles generation
ivanblinov2k17 Nov 10, 2023
1d425f1
Merge branch '23_2' into ts-navigation
ivanblinov2k17 Nov 13, 2023
6e65eb5
generate js
ivanblinov2k17 Nov 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import Accordion from 'devextreme-react/accordion';
import CheckBox from 'devextreme-react/check-box';
import TagBox from 'devextreme-react/tag-box';
import Slider, { Tooltip, Label } from 'devextreme-react/slider';
import Accordion, { AccordionTypes } from 'devextreme-react/accordion';
import CheckBox, { CheckBoxTypes } from 'devextreme-react/check-box';
import TagBox, { TagBoxTypes } from 'devextreme-react/tag-box';
import Slider, { Tooltip, Label, SliderTypes } from 'devextreme-react/slider';

import service from './data.js';
import CustomTitle from './CustomTitle.js';
import CustomItem from './CustomItem.js';
import service from './data.ts';
import CustomTitle from './CustomTitle.tsx';
import CustomItem from './CustomItem.tsx';

const companyLabel = { 'aria-label': 'Company' };
const companies = service.getCompanies();
Expand All @@ -17,7 +17,7 @@ const App = () => {
const [collapsible, setCollapsible] = React.useState(false);
const [animationDuration, setAnimationDuration] = React.useState(300);

const selectionChanged = React.useCallback((e) => {
const selectionChanged = React.useCallback((e: AccordionTypes.SelectionChangedEvent) => {
let newItems = [...selectedItems];
e.removedItems.forEach((item) => {
const index = newItems.indexOf(item);
Expand All @@ -31,19 +31,19 @@ const App = () => {
setSelectedItems(newItems);
}, [selectedItems, setSelectedItems]);

const selectedItemsChanged = React.useCallback((e) => {
const selectedItemsChanged = React.useCallback((e: TagBoxTypes.ValueChangedEvent) => {
setSelectedItems(e.value);
}, [setSelectedItems]);

const multipleChanged = React.useCallback((e) => {
const multipleChanged = React.useCallback((e: CheckBoxTypes.ValueChangedEvent) => {
setMultiple(e.value);
}, [setMultiple]);

const collapsibleChanged = React.useCallback((e) => {
const collapsibleChanged = React.useCallback((e: CheckBoxTypes.ValueChangedEvent) => {
setCollapsible(e.value);
}, [setCollapsible]);

const animationDurationChanged = React.useCallback((e) => {
const animationDurationChanged = React.useCallback((e: SliderTypes.ValueChangedEvent) => {
setAnimationDuration(e.value);
}, [setAnimationDuration]);

Expand Down
2 changes: 1 addition & 1 deletion JSDemos/Demos/Accordion/Overview/React/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script src="../../../../../node_modules/systemjs/dist/system.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript">
System.import("./index.js");
System.import("./index.tsx");
</script>
</head>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';

import App from './App.js';
import App from './App.tsx';

ReactDOM.render(
<App />,
Expand Down
116 changes: 116 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import React from 'react';
import Accordion from 'devextreme-react/accordion';
import CheckBox from 'devextreme-react/check-box';
import TagBox from 'devextreme-react/tag-box';
import Slider, { Tooltip, Label } from 'devextreme-react/slider';
import service from './data.js';
import CustomTitle from './CustomTitle.js';
import CustomItem from './CustomItem.js';

const companyLabel = { 'aria-label': 'Company' };
const companies = service.getCompanies();
const App = () => {
const [selectedItems, setSelectedItems] = React.useState([companies[0]]);
const [multiple, setMultiple] = React.useState(false);
const [collapsible, setCollapsible] = React.useState(false);
const [animationDuration, setAnimationDuration] = React.useState(300);
const selectionChanged = React.useCallback(
(e) => {
let newItems = [...selectedItems];
e.removedItems.forEach((item) => {
const index = newItems.indexOf(item);
if (index >= 0) {
newItems.splice(index, 1);
}
});
if (e.addedItems.length) {
newItems = [...newItems, ...e.addedItems];
}
setSelectedItems(newItems);
},
[selectedItems, setSelectedItems],
);
const selectedItemsChanged = React.useCallback(
(e) => {
setSelectedItems(e.value);
},
[setSelectedItems],
);
const multipleChanged = React.useCallback(
(e) => {
setMultiple(e.value);
},
[setMultiple],
);
const collapsibleChanged = React.useCallback(
(e) => {
setCollapsible(e.value);
},
[setCollapsible],
);
const animationDurationChanged = React.useCallback(
(e) => {
setAnimationDuration(e.value);
},
[setAnimationDuration],
);
return (
<div id="accordion">
<Accordion
dataSource={companies}
collapsible={collapsible}
multiple={multiple}
animationDuration={animationDuration}
selectedItems={selectedItems}
onSelectionChanged={selectionChanged}
itemTitleRender={CustomTitle}
itemRender={CustomItem}
id="accordion-container"
/>
<div className="options">
<div className="caption">Options</div>
<div className="option">
<CheckBox
text="Multiple enabled"
value={multiple}
onValueChanged={multipleChanged}
/>
</div>
<div className="option">
<CheckBox
text="Collapsible enabled"
value={collapsible}
onValueChanged={collapsibleChanged}
/>
</div>
<div className="option">
<span>Animation duration</span>
<Slider
min={0}
max={1000}
value={animationDuration}
onValueChanged={animationDurationChanged}
>
<Tooltip
enabled={true}
position="bottom"
/>
<Label visible={true} />
</Slider>
</div>
<div className="option">
<span className="caption">Selected Items</span>
<TagBox
dataSource={companies}
displayExpr="CompanyName"
value={selectedItems}
inputAttr={companyLabel}
onValueChanged={selectedItemsChanged}
disabled={!multiple}
/>
</div>
</div>
</div>
);
};
export default App;
34 changes: 34 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/CustomItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

export default function CustomItem(data) {
return (
<div>
<div>
<p>
<b>{data.City} </b>(<span>{data.State}</span>)
</p>
<p>
<span>{data.Zipcode} </span>
<span>{data.Address}</span>
</p>
</div>
<div>
<p>
Phone: <b>{data.Phone}</b>
</p>
<p>
Fax: <b>{data.Fax}</b>
</p>
<p>
Website:{' '}
<a

Check warning

Code scanning / CodeQL

Potentially unsafe external link Medium

External links without noopener/noreferrer are a potential security risk.
href={data.Website}
target="_blank"
>
{data.Website}
</a>
</p>
</div>
</div>
);
}
5 changes: 5 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/CustomTitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export default function CustomTitle(data) {
return <div className="header">{data.CompanyName}</div>;
}
51 changes: 51 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const companies = [
{
ID: 1,
CompanyName: 'Super Mart of the West',
Address: '702 SW 8th Street',
City: 'Bentonville',
State: 'Arkansas',
Zipcode: 72716,
Phone: '(800) 555-2797',
Fax: '(800) 555-2171',
Website: 'http://www.nowebsitesupermart.com',
},
{
ID: 2,
CompanyName: 'Electronics Depot',
Address: '2455 Paces Ferry Road NW',
City: 'Atlanta',
State: 'Georgia',
Zipcode: 30339,
Phone: '(800) 595-3232',
Fax: '(800) 595-3231',
Website: 'http://www.nowebsitedepot.com',
},
{
ID: 3,
CompanyName: 'K&S Music',
Address: '1000 Nicllet Mall',
City: 'Minneapolis',
State: 'Minnesota',
Zipcode: 55403,
Phone: '(612) 304-6073',
Fax: '(612) 304-6074',
Website: 'http://www.nowebsitemusic.com',
},
{
ID: 4,
CompanyName: "Tom's Club",
Address: '999 Lake Drive',
City: 'Issaquah',
State: 'Washington',
Zipcode: 98027,
Phone: '(800) 955-2292',
Fax: '(800) 955-2293',
Website: 'http://www.nowebsitetomsclub.com',
},
];
export default {
getCompanies() {
return companies;
},
};
44 changes: 44 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>DevExtreme Demo</title>
<meta
http-equiv="X-UA-Compatible"
content="IE=edge"
/>
<meta
http-equiv="Content-Type"
content="text/html; charset=utf-8"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0"
/>
<link
rel="stylesheet"
type="text/css"
href="../../../../../node_modules/devextreme-dist/css/dx.light.css"
/>
<link
rel="stylesheet"
type="text/css"
href="styles.css"
/>

<script src="../../../../../node_modules/core-js/client/shim.min.js"></script>
<script src="../../../../../node_modules/systemjs/dist/system.js"></script>
<script
type="text/javascript"
src="config.js"
></script>
<script type="text/javascript">
System.import("./index.js");
</script>
</head>

<body class="dx-viewport">
<div class="demo-container">
<div id="app"></div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';

ReactDOM.render(<App />, document.getElementById('app'));
52 changes: 52 additions & 0 deletions JSDemos/Demos/Accordion/Overview/ReactJs/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#accordion {
height: 700px;
}

#accordion .header {
font-size: 20px;
}

#accordion .header,
#accordion p {
margin: 0;
}

#accordion-container {
margin-right: 400px;
}

.dx-theme-material #accordion .dx-accordion-item-title {
display: flex;
}

.dx-theme-material #accordion .header {
align-self: center;
}

.options {
padding: 20px;
position: absolute;
bottom: 0;
right: 0;
width: 340px;
top: 0;
background-color: rgba(191, 191, 191, 0.15);
}

.options > .caption {
font-weight: 500;
font-size: 18px;
}

.option {
margin-top: 10px;
}

.option > .caption {
margin-top: 10px;
display: inline-block;
}

.option > .dx-tagbox {
margin-top: 2px;
}
Loading
Loading