From 187d6bd78943da5f233ca90fa458c3d2fbff28fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Mich=C3=A1lek?= Date: Thu, 16 Jan 2025 16:13:07 +0100 Subject: [PATCH 1/3] feat(menu): add typedef component --- .eslintrc.js | 16 +++++++++++++++- packages/primevue/src/menu/Menu.d.ts | 6 +++--- .../src/menu/Menu.ts-playground.typedef.vue | 13 +++++++++++++ packages/primevue/src/menu/Menu.typedef.vue | 11 +++++++++++ packages/primevue/tsconfig.json | 2 +- 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 packages/primevue/src/menu/Menu.ts-playground.typedef.vue create mode 100644 packages/primevue/src/menu/Menu.typedef.vue diff --git a/.eslintrc.js b/.eslintrc.js index d002974d3b..aad5131ec5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -95,5 +95,19 @@ module.exports = { { blankLine: 'always', prev: '*', next: 'block-like' }, { blankLine: 'always', prev: ['import'], next: ['const', 'let', 'var'] } ] - } + }, + overrides: [ + { + files: ['*.typedef.vue'], + extends: ['plugin:vue/vue3-recommended', '@vue/eslint-config-typescript', 'plugin:@typescript-eslint/recommended-type-checked'], + parser: 'vue-eslint-parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + parser: '@typescript-eslint/parser', + project: ['tsconfig.lint.json'], + extraFileExtensions: ['.vue'] + } + } + ] }; diff --git a/packages/primevue/src/menu/Menu.d.ts b/packages/primevue/src/menu/Menu.d.ts index 87db222128..58a9c4ddef 100755 --- a/packages/primevue/src/menu/Menu.d.ts +++ b/packages/primevue/src/menu/Menu.d.ts @@ -7,7 +7,7 @@ * @module menu * */ -import type { DefineComponent, DesignToken, EmitFn, HintedString, PassThrough } from '@primevue/core'; +import type { DesignToken, EmitFn, HintedString, PassThrough } from '@primevue/core'; import type { ComponentHooks } from '@primevue/core/basecomponent'; import type { MenuItem } from 'primevue/menuitem'; import type { PassThroughOptions } from 'primevue/passthrough'; @@ -370,11 +370,11 @@ export interface MenuMethods { * @group Component * */ -declare const Menu: DefineComponent; +declare const Menu: typeof import('./Menu.typedef.vue')['default']; declare module 'vue' { export interface GlobalComponents { - Menu: DefineComponent; + Menu: typeof import('./Menu.typedef.vue')['default']; } } diff --git a/packages/primevue/src/menu/Menu.ts-playground.typedef.vue b/packages/primevue/src/menu/Menu.ts-playground.typedef.vue new file mode 100644 index 0000000000..a79b30c9d4 --- /dev/null +++ b/packages/primevue/src/menu/Menu.ts-playground.typedef.vue @@ -0,0 +1,13 @@ + + + diff --git a/packages/primevue/src/menu/Menu.typedef.vue b/packages/primevue/src/menu/Menu.typedef.vue new file mode 100644 index 0000000000..e6eaef6c31 --- /dev/null +++ b/packages/primevue/src/menu/Menu.typedef.vue @@ -0,0 +1,11 @@ + diff --git a/packages/primevue/tsconfig.json b/packages/primevue/tsconfig.json index 7646ae3984..9ac96befcb 100644 --- a/packages/primevue/tsconfig.json +++ b/packages/primevue/tsconfig.json @@ -21,6 +21,6 @@ "@primevue/icons/*": ["../../packages/icons/src/*"] } }, - "include": ["**/*.ts", "src/*"], + "include": ["**/*.ts", "src/*", "**/*.typedef.vue"], "exclude": ["node_modules", "dist"] } From e2267d93c2582cb31059e675a38f93561cb027ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Mich=C3=A1lek?= Date: Sat, 18 Jan 2025 16:59:32 +0100 Subject: [PATCH 2/3] feat(menu): use existing interfaces for typedef system --- packages/primevue/src/menu/Menu.d.ts | 14 +++++++------- .../src/menu/Menu.ts-playground.typedef.vue | 11 +++++++---- packages/primevue/src/menu/Menu.typedef.vue | 13 +++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/primevue/src/menu/Menu.d.ts b/packages/primevue/src/menu/Menu.d.ts index 58a9c4ddef..b75f1fbf73 100755 --- a/packages/primevue/src/menu/Menu.d.ts +++ b/packages/primevue/src/menu/Menu.d.ts @@ -191,11 +191,11 @@ export interface MenuRouterBindProps { /** * Defines valid properties in Menu component. */ -export interface MenuProps { +export interface MenuProps { /** * An array of menuitems. */ - model?: MenuItem[] | undefined; + model?: Item[] | undefined; /** * Defines if menu would displayed as a popup. * @defaultValue false @@ -252,7 +252,7 @@ export interface MenuProps { /** * Defines valid slots in Menu component. */ -export interface MenuSlots { +export interface MenuSlots { /** * Custom start template. */ @@ -269,7 +269,7 @@ export interface MenuSlots { /** * Menuitem instance */ - item: MenuItem; + item: Item; /** * Label property of the menuitem */ @@ -287,7 +287,7 @@ export interface MenuSlots { /** * Menuitem instance */ - item: MenuItem; + item: Item; /** * Style class of the item icon element. */ @@ -302,7 +302,7 @@ export interface MenuSlots { /** * Menuitem instance */ - item: MenuItem; + item: Item; }): VNode[]; /** * Custom submenu item template. @@ -312,7 +312,7 @@ export interface MenuSlots { /** * Menuitem instance */ - item: MenuItem; + item: Item; }): VNode[]; } diff --git a/packages/primevue/src/menu/Menu.ts-playground.typedef.vue b/packages/primevue/src/menu/Menu.ts-playground.typedef.vue index a79b30c9d4..f05b707f0d 100644 --- a/packages/primevue/src/menu/Menu.ts-playground.typedef.vue +++ b/packages/primevue/src/menu/Menu.ts-playground.typedef.vue @@ -1,13 +1,16 @@ diff --git a/packages/primevue/src/menu/Menu.typedef.vue b/packages/primevue/src/menu/Menu.typedef.vue index e6eaef6c31..9a897ab281 100644 --- a/packages/primevue/src/menu/Menu.typedef.vue +++ b/packages/primevue/src/menu/Menu.typedef.vue @@ -1,11 +1,8 @@ - From 5bb966f2e0fb6eb8cae4a637b5223fb5ed163ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Mich=C3=A1lek?= Date: Sat, 18 Jan 2025 17:11:23 +0100 Subject: [PATCH 3/3] feat(menu): add exposed methods to typedef component --- packages/primevue/src/menu/Menu.typedef.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/primevue/src/menu/Menu.typedef.vue b/packages/primevue/src/menu/Menu.typedef.vue index 9a897ab281..41b3a8951e 100644 --- a/packages/primevue/src/menu/Menu.typedef.vue +++ b/packages/primevue/src/menu/Menu.typedef.vue @@ -1,8 +1,9 @@