Skip to content

Commit

Permalink
Refactor devextreme-vue for support TS in IDE (#27993)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodDayForSurf authored Sep 25, 2024
1 parent 147725a commit 78ac6d6
Show file tree
Hide file tree
Showing 90 changed files with 9,095 additions and 2,459 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"axe-core": "4.10.0",
"cheerio": "1.0.0-rc.10",
"codelyzer": "6.0.2",
"devextreme-internal-tools": "16.0.0-beta.3",
"devextreme-internal-tools": "16.0.0-beta.4",
"http-server": "14.1.1",
"husky": "8.0.3",
"jest": "29.7.0",
Expand Down
20 changes: 18 additions & 2 deletions packages/devextreme-vue/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ module.exports = {
generatedComponentsDir: './src',
coreComponentsDir: './src/core',
indexFileName: './src/index.ts',
baseComponent: './core/index',
configComponent: './core/index',
componentGeneratorTplConfig: {
createComponentFn: {
name: 'defineComponent',
path: 'vue',
},
prepareComponentConfigFn: {
name: 'prepareComponentConfig',
path: './core/index',
},
prepareExtensionComponentConfigFn: {
name: 'prepareExtensionComponentConfig',
path: './core/index',
},
prepareConfigurationComponentConfigFn: {
name: 'prepareConfigurationComponentConfig',
path: './core/index',
},
},
widgetsPackage: 'devextreme'
};
3 changes: 1 addition & 2 deletions packages/devextreme-vue/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ gulp.task(GENERATE,
(done) => {
generateVueComponents(
JSON.parse(fs.readFileSync(config.metadataPath).toString()),
config.baseComponent,
config.configComponent,
config.componentGeneratorTplConfig,
{
componentsDir: config.generatedComponentsDir,
indexFileName: config.indexFileName
Expand Down
24 changes: 18 additions & 6 deletions packages/devextreme-vue/src/accordion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export { ExplicitTypes } from "devextreme/ui/accordion";
import Accordion, { Properties } from "devextreme/ui/accordion";
import { createComponent } from "./core/index";
import { createConfigurationComponent } from "./core/index";
import { defineComponent } from "vue";
import { prepareComponentConfig } from "./core/index";
import { prepareConfigurationComponentConfig } from "./core/index";

type AccessibleOptions = Pick<Properties,
"accessKey" |
Expand Down Expand Up @@ -47,7 +48,8 @@ type AccessibleOptions = Pick<Properties,
interface DxAccordion extends AccessibleOptions {
readonly instance?: Accordion;
}
const DxAccordion = createComponent({

const componentConfig = {
props: {
accessKey: String,
activeStateEnabled: Boolean,
Expand Down Expand Up @@ -142,9 +144,14 @@ const DxAccordion = createComponent({
item: { isCollectionItem: true, optionName: "items" }
};
}
});
};

prepareComponentConfig(componentConfig);

const DxAccordion = defineComponent(componentConfig);


const DxItem = createConfigurationComponent({
const DxItemConfig = {
emits: {
"update:isActive": null,
"update:hoveredElement": null,
Expand All @@ -167,7 +174,12 @@ const DxItem = createConfigurationComponent({
titleTemplate: {},
visible: Boolean
}
});
};

prepareConfigurationComponentConfig(DxItemConfig);

const DxItem = defineComponent(DxItemConfig);

(DxItem as any).$_optionName = "items";
(DxItem as any).$_isCollectionItem = true;

Expand Down
24 changes: 18 additions & 6 deletions packages/devextreme-vue/src/action-sheet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export { ExplicitTypes } from "devextreme/ui/action_sheet";
import ActionSheet, { Properties } from "devextreme/ui/action_sheet";
import { createComponent } from "./core/index";
import { createConfigurationComponent } from "./core/index";
import { defineComponent } from "vue";
import { prepareComponentConfig } from "./core/index";
import { prepareConfigurationComponentConfig } from "./core/index";

type AccessibleOptions = Pick<Properties,
"cancelText" |
Expand Down Expand Up @@ -36,7 +37,8 @@ type AccessibleOptions = Pick<Properties,
interface DxActionSheet extends AccessibleOptions {
readonly instance?: ActionSheet;
}
const DxActionSheet = createComponent({

const componentConfig = {
props: {
cancelText: String,
dataSource: {},
Expand Down Expand Up @@ -109,9 +111,14 @@ const DxActionSheet = createComponent({
item: { isCollectionItem: true, optionName: "items" }
};
}
});
};

prepareComponentConfig(componentConfig);

const DxActionSheet = defineComponent(componentConfig);


const DxItem = createConfigurationComponent({
const DxItemConfig = {
emits: {
"update:isActive": null,
"update:hoveredElement": null,
Expand All @@ -132,7 +139,12 @@ const DxItem = createConfigurationComponent({
text: String,
type: String
}
});
};

prepareConfigurationComponentConfig(DxItemConfig);

const DxItem = defineComponent(DxItemConfig);

(DxItem as any).$_optionName = "items";
(DxItem as any).$_isCollectionItem = true;

Expand Down
Loading

0 comments on commit 78ac6d6

Please sign in to comment.