Skip to content

Commit 9fe1a85

Browse files
Merge branch '25_2' into 25_2_demos_vue_ts_editors
2 parents 0b15ffb + 876d89f commit 9fe1a85

File tree

48 files changed

+341
-624
lines changed

Some content is hidden

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

48 files changed

+341
-624
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<dx-tree-view
22
[dataSource]="dataSource"
33
dataStructure="plain"
4-
keyExpr="Id"
5-
displayExpr="Name"
4+
keyExpr="ID"
5+
displayExpr="Text"
66
parentIdExpr="CategoryId"
77
hasItemsExpr="IsGroup"
8+
[rootValue]="null"
89
[virtualModeEnabled]="true"
910
></dx-tree-view>

apps/demos/Demos/TreeView/VirtualMode/Angular/app/app.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NgModule, Component, enableProdMode } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
33
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
44
import { DxTreeViewModule } from 'devextreme-angular';
5-
import { DataSource, ODataStore } from 'devextreme-angular/common/data';
5+
import * as AspNetData from 'devextreme-aspnet-data-nojquery';
66

77
if (!/localhost/.test(document.location.host)) {
88
enableProdMode();
@@ -19,11 +19,9 @@ if (window && window.config?.packageConfigPaths) {
1919
templateUrl: `.${modulePrefix}/app.component.html`,
2020
})
2121
export class AppComponent {
22-
dataSource = new DataSource({
23-
store: new ODataStore({
24-
version: 2,
25-
url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/HierarchicalItems',
26-
}),
22+
dataSource = AspNetData.createStore({
23+
loadUrl: 'https://js.devexpress.com/Demos/NetCore/api/TreeViewPlainData',
24+
key: 'ID',
2725
});
2826
}
2927

apps/demos/Demos/TreeView/VirtualMode/React/App.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import React from 'react';
22
import TreeView from 'devextreme-react/tree-view';
33

4-
import { DataSource, ODataStore } from 'devextreme-react/common/data';
4+
import AspNetData from 'devextreme-aspnet-data-nojquery';
55

6-
const dataSource = new DataSource({
7-
store: new ODataStore({
8-
version: 2,
9-
url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/HierarchicalItems',
10-
}),
6+
const dataSource = AspNetData.createStore({
7+
loadUrl: 'https://js.devexpress.com/Demos/NetCore/api/TreeViewPlainData',
8+
key: 'ID',
119
});
1210
const App = () => (
1311
<React.Fragment>
1412
<TreeView
1513
dataSource={dataSource}
1614
dataStructure="plain"
17-
keyExpr="Id"
18-
displayExpr="Name"
15+
keyExpr="ID"
16+
displayExpr="Text"
1917
parentIdExpr="CategoryId"
2018
hasItemsExpr="IsGroup"
2119
virtualModeEnabled={true}
20+
rootValue={null}
2221
/>
2322
</React.Fragment>
2423
);

apps/demos/Demos/TreeView/VirtualMode/ReactJs/App.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
import React from 'react';
22
import TreeView from 'devextreme-react/tree-view';
3-
import { DataSource, ODataStore } from 'devextreme-react/common/data';
3+
import AspNetData from 'devextreme-aspnet-data-nojquery';
44

5-
const dataSource = new DataSource({
6-
store: new ODataStore({
7-
version: 2,
8-
url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/HierarchicalItems',
9-
}),
5+
const dataSource = AspNetData.createStore({
6+
loadUrl: 'https://js.devexpress.com/Demos/NetCore/api/TreeViewPlainData',
7+
key: 'ID',
108
});
119
const App = () => (
1210
<React.Fragment>
1311
<TreeView
1412
dataSource={dataSource}
1513
dataStructure="plain"
16-
keyExpr="Id"
17-
displayExpr="Name"
14+
keyExpr="ID"
15+
displayExpr="Text"
1816
parentIdExpr="CategoryId"
1917
hasItemsExpr="IsGroup"
2018
virtualModeEnabled={true}
19+
rootValue={null}
2120
/>
2221
</React.Fragment>
2322
);

apps/demos/Demos/TreeView/VirtualMode/Vue/App.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44
:data-source="dataSource"
55
:virtual-mode-enabled="true"
66
data-structure="plain"
7-
key-expr="Id"
8-
display-expr="Name"
7+
key-expr="ID"
8+
display-expr="Text"
99
parent-id-expr="CategoryId"
1010
has-items-expr="IsGroup"
11+
:root-value="null"
1112
/>
1213
</div>
1314
</template>
1415
<script setup lang="ts">
15-
import { DataSource, ODataStore } from 'devextreme-vue/common/data';
1616
import DxTreeView from 'devextreme-vue/tree-view';
17+
import { createStore } from 'devextreme-aspnet-data-nojquery';
1718
18-
const dataSource = new DataSource({
19-
store: new ODataStore({
20-
version: 2,
21-
url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/HierarchicalItems',
22-
}),
19+
const dataSource = createStore({
20+
loadUrl: 'https://js.devexpress.com/Demos/NetCore/api/TreeViewPlainData',
21+
key: 'ID',
2322
});
2423
</script>

apps/demos/Demos/TreeView/VirtualMode/jQuery/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<script src="../../../../node_modules/jquery/dist/jquery.min.js"></script>
99
<link rel="stylesheet" type="text/css" href="../../../../node_modules/devextreme-dist/css/dx.light.css" />
1010
<script src="../../../../node_modules/devextreme-dist/js/dx.all.js"></script>
11+
<script src="../../../../node_modules/devextreme-aspnet-data/js/dx.aspnet.data.js"></script>
1112
<script src="data.js"></script>
1213
<script src="index.js"></script>
1314
</head>
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
$(() => {
22
$('#simple-treeview').dxTreeView({
3-
dataSource: new DevExpress.data.DataSource({
4-
store: new DevExpress.data.ODataStore({
5-
version: 2,
6-
url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/HierarchicalItems',
7-
}),
3+
dataSource: DevExpress.data.AspNet.createStore({
4+
loadUrl: 'https://js.devexpress.com/Demos/NetCore/api/TreeViewPlainData',
5+
key: 'ID',
86
}),
97
dataStructure: 'plain',
10-
keyExpr: 'Id',
11-
displayExpr: 'Name',
8+
keyExpr: 'ID',
9+
displayExpr: 'Text',
1210
parentIdExpr: 'CategoryId',
1311
hasItemsExpr: 'IsGroup',
1412
virtualModeEnabled: true,
13+
rootValue: null,
1514
});
1615
});

apps/demos/menuMeta.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5738,6 +5738,10 @@
57385738
"Title": "Virtual Mode",
57395739
"Name": "VirtualMode",
57405740
"Widget": "TreeView",
5741+
"Modules": "devextreme-aspnet-data-nojquery",
5742+
"MvcAdditionalFiles": [
5743+
"/Controllers/ApiControllers/TreeViewPlainDataController.cs"
5744+
],
57415745
"DemoType": "Web"
57425746
}
57435747
]
1.25 KB
Loading
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { ClientFunction } from 'testcafe';
2+
import url from '../../helpers/getPageUrl';
3+
4+
fixture.disablePageReloads`Shadow DOM - Adopted DX css styles`
5+
.page(url(__dirname, '../container.html'));
6+
7+
const dxWidgetHostStyles = '.dx-widget-shadow { font-size: 20px; }';
8+
const dxWidgetShadowStyles = '.dx-widget-shadow { font-size: 40px; }';
9+
10+
const setupShadowDomTest = (copyStylesToShadowDom) => ClientFunction((copyStyles) => {
11+
if (!copyStyles) {
12+
(window as any).DevExpress.config({ copyStylesToShadowDom: copyStyles });
13+
}
14+
15+
const container = document.createElement('div');
16+
container.id = 'shadow-host';
17+
document.body.appendChild(container);
18+
19+
const hostStyleElement = document.createElement('style');
20+
hostStyleElement.innerHTML = dxWidgetHostStyles;
21+
document.head.appendChild(hostStyleElement);
22+
23+
const shadowRoot = container.attachShadow({ mode: 'open' });
24+
25+
const shadowStyleElement = shadowRoot.ownerDocument.createElement('style');
26+
shadowStyleElement.innerHTML = dxWidgetShadowStyles;
27+
shadowRoot.appendChild(shadowStyleElement);
28+
29+
const shadowContainerElement = document.createElement('div');
30+
shadowContainerElement.id = 'shadow-container';
31+
shadowRoot.appendChild(shadowContainerElement);
32+
33+
(window as any).testShadowRoot = shadowRoot;
34+
35+
// eslint-disable-next-line new-cap, no-new
36+
new (window as any).DevExpress.ui.dxButton(shadowContainerElement, {
37+
text: 'Test button',
38+
});
39+
}, {
40+
dependencies: {
41+
dxWidgetHostStyles,
42+
dxWidgetShadowStyles,
43+
},
44+
})(copyStylesToShadowDom);
45+
46+
const getAdoptedStyleSheets = ClientFunction(() => {
47+
const shadowRoot = (window as any).testShadowRoot;
48+
const { adoptedStyleSheets } = shadowRoot;
49+
50+
const results: { [key: string]: string[] | null } = {
51+
firstSheetRules: null,
52+
secondSheetRules: null,
53+
};
54+
55+
if (adoptedStyleSheets.length > 1) {
56+
results.firstSheetRules = Array
57+
.from(adoptedStyleSheets[0].cssRules).map((rule) => (rule as CSSRule).cssText);
58+
59+
results.secondSheetRules = Array
60+
.from(adoptedStyleSheets[1].cssRules).map((rule) => (rule as CSSRule).cssText);
61+
}
62+
63+
return results;
64+
});
65+
66+
test('Copies DX css styles from the host to the shadow root when rendering a DX widget', async (t) => {
67+
await setupShadowDomTest(true);
68+
69+
const { firstSheetRules, secondSheetRules } = await getAdoptedStyleSheets();
70+
71+
const hasHostStyle = firstSheetRules?.some((rule) => rule === dxWidgetHostStyles);
72+
await t.expect(hasHostStyle).ok('First adopted stylesheet contains host styles');
73+
74+
const hasShadowStyle = secondSheetRules?.some((rule) => rule === dxWidgetShadowStyles);
75+
await t.expect(hasShadowStyle).ok('Second adopted stylesheet contains shadow styles');
76+
});
77+
78+
test('Does not copy DX css styles when copyStylesToShadowDom is disabled', async (t) => {
79+
await setupShadowDomTest(false);
80+
81+
const { firstSheetRules, secondSheetRules } = await getAdoptedStyleSheets();
82+
await t.expect(firstSheetRules === null && secondSheetRules === null)
83+
.ok('No adopted stylesheets should be created when copyStylesToShadowDom is disabled');
84+
});

0 commit comments

Comments
 (0)