From eff7b8d92c54aece07061c2d8ce58507a56e7d01 Mon Sep 17 00:00:00 2001
From: Andrea Delgado <114981520+andreadlgdo@users.noreply.github.com>
Date: Wed, 19 Jun 2024 10:07:30 +0200
Subject: [PATCH 01/10] feat: migrate `facets provider` component to use
Composition API (#1523)
---
.../components/facets/facets-provider.vue | 189 +++++++++---------
1 file changed, 97 insertions(+), 92 deletions(-)
diff --git a/packages/x-components/src/x-modules/facets/components/facets/facets-provider.vue b/packages/x-components/src/x-modules/facets/components/facets/facets-provider.vue
index d34c8811eb..63ab6d9000 100644
--- a/packages/x-components/src/x-modules/facets/components/facets/facets-provider.vue
+++ b/packages/x-components/src/x-modules/facets/components/facets/facets-provider.vue
@@ -1,15 +1,12 @@
diff --git a/packages/_vue3-migration-test/src/x-modules/popular-searches/x-module.ts b/packages/_vue3-migration-test/src/x-modules/popular-searches/x-module.ts
new file mode 100644
index 0000000000..0aeaee7431
--- /dev/null
+++ b/packages/_vue3-migration-test/src/x-modules/popular-searches/x-module.ts
@@ -0,0 +1,16 @@
+import { PopularSearchesXModule } from '../../../../x-components/src/x-modules/popular-searches/x-module';
+import { PrivateXModuleOptions } from '../../../../x-components/src/plugins';
+import { createPopularSearch } from '../../../../x-components/src/__stubs__/popular-searches-stubs.factory';
+
+export const popularSearchesXModule: PrivateXModuleOptions = {
+ storeModule: {
+ state: {
+ popularSearches: ['patata', 'salchicón', 'pan', 'queso', 'leche', 'galletas'].map(query =>
+ createPopularSearch(query)
+ ),
+ config: {
+ hideSessionQueries: false
+ }
+ }
+ }
+};
diff --git a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts
index bb3c969a0c..23e2ec1da4 100644
--- a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts
+++ b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts
@@ -47,7 +47,7 @@ describe('testing plugin alias', () => {
status: {
identifierResults: 'initial', // It is already registered by the `identifierResultsXModule` import itself
nextQueries: 'initial', // It is already registered by the `nextQueriesXModule` import itself
- popularSearches: undefined,
+ popularSearches: 'initial', // It is already registered by the `popularSearchesXModule` import itself
querySuggestions: 'initial', // It is already registered by the `querySuggestionsXModule` import itself
recommendations: 'initial', // It is already registered by the `recommendationsXModule` import itself
relatedTags: 'initial', // It is already registered by the `relatedTagsXModule` import itself
diff --git a/packages/x-components/src/x-modules/popular-searches/components/popular-search.vue b/packages/x-components/src/x-modules/popular-searches/components/popular-search.vue
index b92927dc4a..1170ed2a2d 100644
--- a/packages/x-components/src/x-modules/popular-searches/components/popular-search.vue
+++ b/packages/x-components/src/x-modules/popular-searches/components/popular-search.vue
@@ -19,10 +19,8 @@
diff --git a/packages/x-components/src/x-modules/popular-searches/components/popular-searches.vue b/packages/x-components/src/x-modules/popular-searches/components/popular-searches.vue
index 066cf60297..c76a139d4a 100644
--- a/packages/x-components/src/x-modules/popular-searches/components/popular-searches.vue
+++ b/packages/x-components/src/x-modules/popular-searches/components/popular-searches.vue
@@ -32,13 +32,10 @@
diff --git a/packages/x-components/src/x-modules/popular-searches/x-module.ts b/packages/x-components/src/x-modules/popular-searches/x-module.ts
index b7abb3f6ff..7b75d9cb4a 100644
--- a/packages/x-components/src/x-modules/popular-searches/x-module.ts
+++ b/packages/x-components/src/x-modules/popular-searches/x-module.ts
@@ -1,4 +1,5 @@
import { XModule } from '../x-modules.types';
+import { XPlugin } from '../../plugins/x-plugin';
import { popularSearchesEmitters } from './store/emitters';
import { popularSearchesXStoreModule } from './store/module';
import { PopularSearchesXStoreModule } from './store/types';
@@ -23,3 +24,5 @@ export const popularSearchesXModule: PopularSearchesXModule = {
storeEmitters: popularSearchesEmitters,
wiring: popularSearchesWiring
};
+
+XPlugin.registerXModule(popularSearchesXModule);
From 78252873f6ca256899745dcbba70745c82b43cbe Mon Sep 17 00:00:00 2001
From: empathy/x
Date: Wed, 19 Jun 2024 17:31:18 +0000
Subject: [PATCH 04/10] chore(release): publish
- vue3-migration-test@1.0.0-alpha.33
- @empathyco/x-components@5.0.0-alpha.51
---
packages/_vue3-migration-test/CHANGELOG.md | 9 +++++++++
packages/_vue3-migration-test/package.json | 2 +-
packages/x-components/CHANGELOG.md | 9 +++++++++
packages/x-components/package.json | 2 +-
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/packages/_vue3-migration-test/CHANGELOG.md b/packages/_vue3-migration-test/CHANGELOG.md
index 953dbef7ba..8b93d30a7e 100644
--- a/packages/_vue3-migration-test/CHANGELOG.md
+++ b/packages/_vue3-migration-test/CHANGELOG.md
@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.0.0-alpha.33](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.32...vue3-migration-test@1.0.0-alpha.33) (2024-06-19)
+
+
+### Features
+
+* migrate popular-searches x-module (#1524) ([f79456d](https://github.com/empathyco/x/commit/f79456d4589b3f9dee5fd86fad9625b853dde267))
+
+
+
## [1.0.0-alpha.32](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.31...vue3-migration-test@1.0.0-alpha.32) (2024-06-18)
diff --git a/packages/_vue3-migration-test/package.json b/packages/_vue3-migration-test/package.json
index 681f02e6dd..5d08eda105 100644
--- a/packages/_vue3-migration-test/package.json
+++ b/packages/_vue3-migration-test/package.json
@@ -1,7 +1,7 @@
{
"name": "vue3-migration-test",
"private": "true",
- "version": "1.0.0-alpha.32",
+ "version": "1.0.0-alpha.33",
"scripts": {
"dev": "vite",
"preview": "vite preview",
diff --git a/packages/x-components/CHANGELOG.md b/packages/x-components/CHANGELOG.md
index 9e1193d64e..13a3dedb16 100644
--- a/packages/x-components/CHANGELOG.md
+++ b/packages/x-components/CHANGELOG.md
@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [5.0.0-alpha.51](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.50...@empathyco/x-components@5.0.0-alpha.51) (2024-06-19)
+
+
+### Features
+
+* migrate popular-searches x-module (#1524) ([f79456d](https://github.com/empathyco/x/commit/f79456d4589b3f9dee5fd86fad9625b853dde267))
+
+
+
## [5.0.0-alpha.50](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.49...@empathyco/x-components@5.0.0-alpha.50) (2024-06-19)
diff --git a/packages/x-components/package.json b/packages/x-components/package.json
index c6e192e1ec..a64b9ec266 100644
--- a/packages/x-components/package.json
+++ b/packages/x-components/package.json
@@ -1,6 +1,6 @@
{
"name": "@empathyco/x-components",
- "version": "5.0.0-alpha.50",
+ "version": "5.0.0-alpha.51",
"description": "Empathy X Components",
"author": "Empathy Systems Corporation S.L.",
"license": "Apache-2.0",
From 3eff0c7c9479abbebbda59e8cc538af6f55375e1 Mon Sep 17 00:00:00 2001
From: lauramargar <114984466+lauramargar@users.noreply.github.com>
Date: Thu, 20 Jun 2024 09:16:56 +0200
Subject: [PATCH 05/10] feat: migrate `QueryPreviewButton` component to
composition API (#1525)
---
.../components/query-preview-button.vue | 102 +++++++++---------
1 file changed, 53 insertions(+), 49 deletions(-)
diff --git a/packages/x-components/src/x-modules/queries-preview/components/query-preview-button.vue b/packages/x-components/src/x-modules/queries-preview/components/query-preview-button.vue
index 5a27b1e247..df8e415a37 100644
--- a/packages/x-components/src/x-modules/queries-preview/components/query-preview-button.vue
+++ b/packages/x-components/src/x-modules/queries-preview/components/query-preview-button.vue
@@ -13,14 +13,12 @@
From 79e2c9a42ad8c927b3976f8b8f3027f8764ace76 Mon Sep 17 00:00:00 2001
From: empathy/x
Date: Thu, 20 Jun 2024 07:32:11 +0000
Subject: [PATCH 06/10] chore(release): publish
- @empathyco/x-components@5.0.0-alpha.52
---
packages/x-components/CHANGELOG.md | 9 +++++++++
packages/x-components/package.json | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/packages/x-components/CHANGELOG.md b/packages/x-components/CHANGELOG.md
index 13a3dedb16..4f1152e099 100644
--- a/packages/x-components/CHANGELOG.md
+++ b/packages/x-components/CHANGELOG.md
@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [5.0.0-alpha.52](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.51...@empathyco/x-components@5.0.0-alpha.52) (2024-06-20)
+
+
+### Features
+
+* migrate `QueryPreviewButton` component to composition API (#1525) ([3eff0c7](https://github.com/empathyco/x/commit/3eff0c7c9479abbebbda59e8cc538af6f55375e1))
+
+
+
## [5.0.0-alpha.51](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.50...@empathyco/x-components@5.0.0-alpha.51) (2024-06-19)
diff --git a/packages/x-components/package.json b/packages/x-components/package.json
index a64b9ec266..ded2851221 100644
--- a/packages/x-components/package.json
+++ b/packages/x-components/package.json
@@ -1,6 +1,6 @@
{
"name": "@empathyco/x-components",
- "version": "5.0.0-alpha.51",
+ "version": "5.0.0-alpha.52",
"description": "Empathy X Components",
"author": "Empathy Systems Corporation S.L.",
"license": "Apache-2.0",
From d869f1886c11f74af8a6350033d7567385ad629d Mon Sep 17 00:00:00 2001
From: Diego Pascual
Date: Mon, 24 Jun 2024 12:24:31 +0200
Subject: [PATCH 07/10] feat(extra-params): migrate extra params and snippet
config extra params (#1531)
---
.../extra-params/test-extra-params.vue | 13 ++
.../src/components/index.ts | 1 +
packages/_vue3-migration-test/src/main.ts | 44 ++++---
packages/_vue3-migration-test/src/router.ts | 8 +-
.../x-modules/identifier-results/x-module.ts | 3 +-
.../components/__tests__/extra-params.spec.ts | 4 +-
.../extra-params/components/extra-params.vue | 62 ++++-----
.../snippet-config-extra-params.vue | 120 +++++++-----------
.../src/x-modules/extra-params/x-module.ts | 3 +
9 files changed, 128 insertions(+), 130 deletions(-)
create mode 100644 packages/_vue3-migration-test/src/components/extra-params/test-extra-params.vue
diff --git a/packages/_vue3-migration-test/src/components/extra-params/test-extra-params.vue b/packages/_vue3-migration-test/src/components/extra-params/test-extra-params.vue
new file mode 100644
index 0000000000..a7638946e6
--- /dev/null
+++ b/packages/_vue3-migration-test/src/components/extra-params/test-extra-params.vue
@@ -0,0 +1,13 @@
+
+
+ {{ params }}
+
+
diff --git a/packages/_vue3-migration-test/src/components/index.ts b/packages/_vue3-migration-test/src/components/index.ts
index 45c4690d74..66a0cf6ff6 100644
--- a/packages/_vue3-migration-test/src/components/index.ts
+++ b/packages/_vue3-migration-test/src/components/index.ts
@@ -14,3 +14,4 @@ export { default as TestBasePanel } from './panels/test-base-panel.vue';
export { default as TestBaseKeyboardNavigation } from './test-base-keyboard-navigation.vue';
export { default as TestBaseEventsModal } from './modals/test-base-events-modal.vue';
export { default as TestBaseIdModal } from './modals/test-base-id-modal.vue';
+export { default as TestExtraParams } from './extra-params/test-extra-params.vue';
diff --git a/packages/_vue3-migration-test/src/main.ts b/packages/_vue3-migration-test/src/main.ts
index 703dc7b3ad..80f0c05f47 100644
--- a/packages/_vue3-migration-test/src/main.ts
+++ b/packages/_vue3-migration-test/src/main.ts
@@ -1,15 +1,16 @@
import { QuerySuggestionsRequest, XComponentsAdapter } from '@empathyco/x-types';
import { Component, configureCompat, createApp } from 'vue';
import { createStore } from 'vuex';
-import { xPlugin } from '../../x-components/src/plugins/x-plugin';
import { getRelatedTagsStub } from '../../x-components/src/__stubs__/related-tags-stubs.factory';
import { getQuerySuggestionsStub } from '../../x-components/src/__stubs__/query-suggestions-stubs.factory';
import {
+ createResultStub,
getBannersStub,
getNextQueriesStub,
getPromotedsStub,
getResultsStub
} from '../../x-components/src/__stubs__/index';
+import { XInstaller } from '../../x-components/src/x-installer/x-installer/x-installer';
import App from './App.vue';
import router from './router';
import {
@@ -77,7 +78,11 @@ const adapter = {
promoteds: getPromotedsStub(),
banners: getBannersStub()
});
- })
+ }),
+ identifierResults: () =>
+ new Promise(resolve =>
+ resolve({ results: ['123A', '123B', '123C', '123D'].map(id => createResultStub(id)) })
+ )
} as unknown as XComponentsAdapter;
const store = createStore({});
@@ -85,19 +90,24 @@ const store = createStore({});
createApp(App as Component)
.use(router)
.use(store)
- .use(xPlugin, {
- adapter,
- store,
- __PRIVATE__xModules: {
- facets: facetsXModule,
- nextQueries: nextQueriesXModule,
- scroll: scrollXModule,
- search: searchXModule,
- queriesPreview: queriesPreviewXModule,
- semanticQueries: semanticQueriesXModule,
- recommendations: recommendationsXModule,
- popularSearches: popularSearchesXModule,
- identifierResults: identifierResultsXModule
- }
- })
.mount('#app');
+
+window.initX = {
+ instance: 'empathy',
+ lang: 'en'
+};
+new XInstaller({
+ adapter,
+ store,
+ __PRIVATE__xModules: {
+ facets: facetsXModule,
+ nextQueries: nextQueriesXModule,
+ scroll: scrollXModule,
+ search: searchXModule,
+ queriesPreview: queriesPreviewXModule,
+ semanticQueries: semanticQueriesXModule,
+ recommendations: recommendationsXModule,
+ identifierResults: identifierResultsXModule,
+ popularSearches: popularSearchesXModule
+ }
+}).init();
diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts
index 1e07419e15..da58d80ff3 100644
--- a/packages/_vue3-migration-test/src/router.ts
+++ b/packages/_vue3-migration-test/src/router.ts
@@ -39,7 +39,8 @@ import {
TestRecommendations,
TestPopularSearches,
TestNextQueries,
- TestIdentifierResults
+ TestIdentifierResults,
+ TestExtraParams
} from './';
const routes = [
@@ -242,6 +243,11 @@ const routes = [
path: '/identifier-results',
name: 'IdentifierResults',
component: TestIdentifierResults
+ },
+ {
+ path: '/snippet-config-extraparams',
+ name: 'SnippetConfigExtraparams',
+ component: TestExtraParams
}
];
diff --git a/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts b/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts
index 70ba15093a..d801729f7f 100644
--- a/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts
+++ b/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts
@@ -1,6 +1,5 @@
import { PrivateXModuleOptions } from '../../../../x-components/src/plugins/x-plugin.types';
import { IdentifierResultsXModule } from '../../../../x-components/src/x-modules/identifier-results/x-module';
-import { createResultStub } from '../../../../x-components/src/__stubs__/results-stubs.factory';
export const identifierResultsXModule: PrivateXModuleOptions = {
storeModule: {
@@ -11,7 +10,7 @@ export const identifierResultsXModule: PrivateXModuleOptions createResultStub(id)),
+ identifierResults: [],
origin: null,
query: 'test',
params: {},
diff --git a/packages/x-components/src/x-modules/extra-params/components/__tests__/extra-params.spec.ts b/packages/x-components/src/x-modules/extra-params/components/__tests__/extra-params.spec.ts
index 5376cdff4c..a226e19003 100644
--- a/packages/x-components/src/x-modules/extra-params/components/__tests__/extra-params.spec.ts
+++ b/packages/x-components/src/x-modules/extra-params/components/__tests__/extra-params.spec.ts
@@ -40,7 +40,7 @@ describe('testing extra params component', () => {
expect(extraParamsProvidedCallback).toHaveBeenCalledWith<[WirePayload>]>({
eventPayload: { warehouse: 1234 },
- metadata: { moduleName: 'extraParams', location: undefined, replaceable: true }
+ metadata: { moduleName: 'extraParams', location: 'none', replaceable: true }
});
expect(extraParamsProvidedCallback).toHaveBeenCalledTimes(1);
@@ -48,7 +48,7 @@ describe('testing extra params component', () => {
expect(extraParamsProvidedCallback).toHaveBeenCalledWith<[WirePayload>]>({
eventPayload: { warehouse: 5678 },
- metadata: { moduleName: 'extraParams', location: undefined, replaceable: true }
+ metadata: { moduleName: 'extraParams', location: 'none', replaceable: true }
});
expect(extraParamsProvidedCallback).toHaveBeenCalledTimes(2);
});
diff --git a/packages/x-components/src/x-modules/extra-params/components/extra-params.vue b/packages/x-components/src/x-modules/extra-params/components/extra-params.vue
index d24dc6301e..4d96cddc97 100644
--- a/packages/x-components/src/x-modules/extra-params/components/extra-params.vue
+++ b/packages/x-components/src/x-modules/extra-params/components/extra-params.vue
@@ -1,9 +1,9 @@
diff --git a/packages/x-components/src/x-modules/extra-params/components/snippet-config-extra-params.vue b/packages/x-components/src/x-modules/extra-params/components/snippet-config-extra-params.vue
index a6e86d798c..b62ed09319 100644
--- a/packages/x-components/src/x-modules/extra-params/components/snippet-config-extra-params.vue
+++ b/packages/x-components/src/x-modules/extra-params/components/snippet-config-extra-params.vue
@@ -4,87 +4,59 @@
diff --git a/packages/x-components/src/x-modules/extra-params/x-module.ts b/packages/x-components/src/x-modules/extra-params/x-module.ts
index 241efc6bd8..26033bcecc 100644
--- a/packages/x-components/src/x-modules/extra-params/x-module.ts
+++ b/packages/x-components/src/x-modules/extra-params/x-module.ts
@@ -1,4 +1,5 @@
import { XModule } from '../x-modules.types';
+import { XPlugin } from '../../plugins/index';
import { extraParamsEmitters } from './store/emitters';
import { extraParamsXStoreModule } from './store/module';
import { ExtraParamsXStoreModule } from './store/types';
@@ -23,3 +24,5 @@ export const extraParamsXModule: ExtraParamsXModule = {
storeEmitters: extraParamsEmitters,
wiring: extraParamsWiring
};
+
+XPlugin.registerXModule(extraParamsXModule);
From 042bc99775909735d68a5e62b5197a0e94973823 Mon Sep 17 00:00:00 2001
From: empathy/x
Date: Mon, 24 Jun 2024 10:39:46 +0000
Subject: [PATCH 08/10] chore(release): publish
- vue3-migration-test@1.0.0-alpha.34
- @empathyco/x-components@5.0.0-alpha.53
---
packages/_vue3-migration-test/CHANGELOG.md | 9 +++++++++
packages/_vue3-migration-test/package.json | 2 +-
packages/x-components/CHANGELOG.md | 9 +++++++++
packages/x-components/package.json | 2 +-
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/packages/_vue3-migration-test/CHANGELOG.md b/packages/_vue3-migration-test/CHANGELOG.md
index 8b93d30a7e..ab74c52fca 100644
--- a/packages/_vue3-migration-test/CHANGELOG.md
+++ b/packages/_vue3-migration-test/CHANGELOG.md
@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [1.0.0-alpha.34](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.33...vue3-migration-test@1.0.0-alpha.34) (2024-06-24)
+
+
+### Features
+
+* **extra-params:** migrate extra params and snippet config extra params (#1531) ([d869f18](https://github.com/empathyco/x/commit/d869f1886c11f74af8a6350033d7567385ad629d))
+
+
+
## [1.0.0-alpha.33](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.32...vue3-migration-test@1.0.0-alpha.33) (2024-06-19)
diff --git a/packages/_vue3-migration-test/package.json b/packages/_vue3-migration-test/package.json
index 5d08eda105..5a2556c1d6 100644
--- a/packages/_vue3-migration-test/package.json
+++ b/packages/_vue3-migration-test/package.json
@@ -1,7 +1,7 @@
{
"name": "vue3-migration-test",
"private": "true",
- "version": "1.0.0-alpha.33",
+ "version": "1.0.0-alpha.34",
"scripts": {
"dev": "vite",
"preview": "vite preview",
diff --git a/packages/x-components/CHANGELOG.md b/packages/x-components/CHANGELOG.md
index 4f1152e099..bec4abbcc5 100644
--- a/packages/x-components/CHANGELOG.md
+++ b/packages/x-components/CHANGELOG.md
@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+## [5.0.0-alpha.53](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.52...@empathyco/x-components@5.0.0-alpha.53) (2024-06-24)
+
+
+### Features
+
+* **extra-params:** migrate extra params and snippet config extra params (#1531) ([d869f18](https://github.com/empathyco/x/commit/d869f1886c11f74af8a6350033d7567385ad629d))
+
+
+
## [5.0.0-alpha.52](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.51...@empathyco/x-components@5.0.0-alpha.52) (2024-06-20)
diff --git a/packages/x-components/package.json b/packages/x-components/package.json
index ded2851221..db1c781c94 100644
--- a/packages/x-components/package.json
+++ b/packages/x-components/package.json
@@ -1,6 +1,6 @@
{
"name": "@empathyco/x-components",
- "version": "5.0.0-alpha.52",
+ "version": "5.0.0-alpha.53",
"description": "Empathy X Components",
"author": "Empathy Systems Corporation S.L.",
"license": "Apache-2.0",
From f498d3fba5d294391dcfca47f9724558e98f50f0 Mon Sep 17 00:00:00 2001
From: alvarodE <72568818+alvarodE@users.noreply.github.com>
Date: Mon, 24 Jun 2024 17:31:33 +0200
Subject: [PATCH 09/10] feat: replace DisableAnimationMixin by
useDisableAnimation composable (#1469)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Víctor CG
---
.../src/components/animations/index.ts | 1 +
.../animations/test-fade-and-slide.vue | 11 +
packages/_vue3-migration-test/src/main.ts | 3 +-
packages/_vue3-migration-test/src/router.ts | 6 +
....spec.ts => use-disable-animation.spec.ts} | 48 +-
.../components/animations/collapse-height.vue | 3 +-
.../components/animations/collapse-width.vue | 3 +-
.../src/components/animations/cross-fade.vue | 3 +-
.../animations/disable-animation.mixin.ts | 36 -
.../components/animations/fade-and-slide.vue | 59 +-
.../src/components/animations/index.ts | 2 +-
.../animations/staggered-fade-and-slide.vue | 64 +-
.../staggering-transition-group.vue | 727 +++++++++---------
.../animations/use-disable-animation.ts | 26 +
14 files changed, 484 insertions(+), 508 deletions(-)
create mode 100644 packages/_vue3-migration-test/src/components/animations/test-fade-and-slide.vue
rename packages/x-components/src/components/animations/__tests__/{disable-animation-mixin.spec.ts => use-disable-animation.spec.ts} (60%)
delete mode 100644 packages/x-components/src/components/animations/disable-animation.mixin.ts
create mode 100644 packages/x-components/src/components/animations/use-disable-animation.ts
diff --git a/packages/_vue3-migration-test/src/components/animations/index.ts b/packages/_vue3-migration-test/src/components/animations/index.ts
index 4d2c00cf2b..f1ee0800dd 100644
--- a/packages/_vue3-migration-test/src/components/animations/index.ts
+++ b/packages/_vue3-migration-test/src/components/animations/index.ts
@@ -3,3 +3,4 @@ export { default as TestCollapseHeight } from './test-collapse-height.vue';
export { default as TestCollapseWidth } from './test-collapse-width.vue';
export { default as TestCrossFade } from './test-cross-fade.vue';
export { default as TestFade } from './test-fade.vue';
+export { default as TestFadeAndSlide } from './test-fade-and-slide.vue';
diff --git a/packages/_vue3-migration-test/src/components/animations/test-fade-and-slide.vue b/packages/_vue3-migration-test/src/components/animations/test-fade-and-slide.vue
new file mode 100644
index 0000000000..8553f4e244
--- /dev/null
+++ b/packages/_vue3-migration-test/src/components/animations/test-fade-and-slide.vue
@@ -0,0 +1,11 @@
+
+
+ Element to animate
+ Element to animate
+ Element to animate
+
+
+
+
diff --git a/packages/_vue3-migration-test/src/main.ts b/packages/_vue3-migration-test/src/main.ts
index 80f0c05f47..fe773026db 100644
--- a/packages/_vue3-migration-test/src/main.ts
+++ b/packages/_vue3-migration-test/src/main.ts
@@ -40,8 +40,7 @@ if (VUE_COMPAT_MODE === 2) {
INSTANCE_LISTENERS: 'suppress-warning',
INSTANCE_ATTRS_CLASS_STYLE: 'suppress-warning',
RENDER_FUNCTION: false,
- COMPONENT_V_MODEL: false,
- WATCH_ARRAY: false
+ COMPONENT_V_MODEL: false
});
}
diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts
index da58d80ff3..e9a253de77 100644
--- a/packages/_vue3-migration-test/src/router.ts
+++ b/packages/_vue3-migration-test/src/router.ts
@@ -11,6 +11,7 @@ import {
TestElementsList,
TestFacets,
TestFade,
+ TestFadeAndSlide,
TestScroll,
TestSortDropdown,
TestSortList,
@@ -74,6 +75,11 @@ const routes = [
name: 'BaseModal',
component: TestBaseModal
},
+ {
+ path: '/fade-and-slide',
+ name: 'FadeAndSlide',
+ component: TestFadeAndSlide
+ },
{
path: '/base-dropdown',
name: 'BaseDropdown',
diff --git a/packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts b/packages/x-components/src/components/animations/__tests__/use-disable-animation.spec.ts
similarity index 60%
rename from packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts
rename to packages/x-components/src/components/animations/__tests__/use-disable-animation.spec.ts
index c3bc5bf904..91a642a215 100644
--- a/packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts
+++ b/packages/x-components/src/components/animations/__tests__/use-disable-animation.spec.ts
@@ -1,36 +1,33 @@
-import { mount, Wrapper } from '@vue/test-utils';
-import { Component, Prop, Provide } from 'vue-property-decorator';
-import Vue, { ComponentOptions, CreateElement, VNode } from 'vue';
-import DisableAnimationMixin from '../disable-animation.mixin';
+import { mount } from '@vue/test-utils';
+import { defineComponent, provide, ref } from 'vue';
import { DISABLE_ANIMATIONS_KEY } from '../../decorators/injection.consts';
+import { useDisableAnimation } from '../use-disable-animation';
-@Component
-class Provider extends Vue {
- @Prop()
- @Provide(DISABLE_ANIMATIONS_KEY as string)
- public disableAnimation!: boolean;
-
- render(h: CreateElement): VNode {
+const Provider = defineComponent({
+ props: {
+ disableAnimation: Boolean
+ },
+ setup(props) {
+ provide(DISABLE_ANIMATIONS_KEY as string, ref(props.disableAnimation));
+ },
+ render(h) {
return this.$slots.default?.[0] ?? h();
}
-}
+});
/**
* Animation component.
*/
-const Animation: ComponentOptions = {
- mixins: [DisableAnimationMixin],
+const Animation = defineComponent({
+ setup() {
+ return useDisableAnimation('x-animation');
+ },
template: `
Animation
- `,
- data() {
- return {
- animationName: 'x-animation'
- };
- }
-};
+ `
+});
/**
* Function that returns an Animation wrapper.
@@ -38,9 +35,7 @@ const Animation: ComponentOptions = {
* @param disableAnimation - Flag to disable the animation.
* @returns Animation wrapper.
*/
-function renderDisableAnimation({
- disableAnimation = true
-}: DisableAnimationOptions = {}): DisableAnimationAPI {
+function renderDisableAnimation({ disableAnimation = true }: DisableAnimationOptions = {}) {
const wrapper = mount({
template: `
@@ -78,8 +73,3 @@ interface DisableAnimationOptions {
/** Flag to disable the animation. */
disableAnimation?: boolean;
}
-
-interface DisableAnimationAPI {
- /** The wrapper of the mounted component. */
- wrapper: Wrapper;
-}
diff --git a/packages/x-components/src/components/animations/collapse-height.vue b/packages/x-components/src/components/animations/collapse-height.vue
index 9ded2cfd63..7c512b4871 100644
--- a/packages/x-components/src/components/animations/collapse-height.vue
+++ b/packages/x-components/src/components/animations/collapse-height.vue
@@ -1,11 +1,12 @@
+
diff --git a/packages/x-components/src/components/animations/collapse-width.vue b/packages/x-components/src/components/animations/collapse-width.vue
index 0d9a408d26..ca59254b75 100644
--- a/packages/x-components/src/components/animations/collapse-width.vue
+++ b/packages/x-components/src/components/animations/collapse-width.vue
@@ -1,11 +1,12 @@
+
diff --git a/packages/x-components/src/components/animations/cross-fade.vue b/packages/x-components/src/components/animations/cross-fade.vue
index 1bece28416..f61f14c711 100644
--- a/packages/x-components/src/components/animations/cross-fade.vue
+++ b/packages/x-components/src/components/animations/cross-fade.vue
@@ -1,5 +1,6 @@
-
+
+
diff --git a/packages/x-components/src/components/animations/disable-animation.mixin.ts b/packages/x-components/src/components/animations/disable-animation.mixin.ts
deleted file mode 100644
index 9581fa47cf..0000000000
--- a/packages/x-components/src/components/animations/disable-animation.mixin.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import Vue from 'vue';
-import { Component, Inject } from 'vue-property-decorator';
-import { DISABLE_ANIMATIONS_KEY } from '../decorators/injection.consts';
-
-/**
- * Mixin to ease disabling animations.
- *
- * @public
- */
-@Component
-export default class DisableAnimationMixin extends Vue {
- /**
- * The name of the animation.
- *
- * @public
- */
- protected animationName!: string;
-
- /**
- * Flag to disable the animation.
- *
- * @public
- */
- @Inject({ from: DISABLE_ANIMATIONS_KEY as string, default: false })
- public disableAnimation!: boolean;
-
- /**
- * The animation's name based on the {@link DisableAnimationMixin.disableAnimation} flag.
- *
- * @returns The animation name.
- * @internal
- */
- protected get name(): string {
- return this.disableAnimation ? '__no-animation__' : this.animationName;
- }
-}
diff --git a/packages/x-components/src/components/animations/fade-and-slide.vue b/packages/x-components/src/components/animations/fade-and-slide.vue
index 727d14dd87..9dbdb13c21 100644
--- a/packages/x-components/src/components/animations/fade-and-slide.vue
+++ b/packages/x-components/src/components/animations/fade-and-slide.vue
@@ -1,10 +1,11 @@
+
@@ -13,9 +14,8 @@