From 8e6f4675a230da59c00336103e6075b943d5286c Mon Sep 17 00:00:00 2001 From: Laura Martinez Garcia Date: Thu, 30 May 2024 10:54:11 +0200 Subject: [PATCH 1/9] feat: migrate history-queries components --- .../components/clear-history-queries.vue | 97 +++---- .../components/history-queries-switch.vue | 97 +++---- .../components/history-queries.vue | 44 ++-- .../components/history-query.vue | 89 ++++--- .../history-queries/components/my-history.vue | 238 +++++++++--------- .../components/remove-history-query.vue | 65 +++-- 6 files changed, 343 insertions(+), 287 deletions(-) diff --git a/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue b/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue index dfa8de8c27..ea4a64350a 100644 --- a/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue +++ b/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue @@ -13,15 +13,12 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue b/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue index f32ea08109..7ea07c5739 100644 --- a/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue +++ b/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue @@ -3,14 +3,11 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/history-queries.vue b/packages/x-components/src/x-modules/history-queries/components/history-queries.vue index fd5fd310a5..6979a83cb6 100644 --- a/packages/x-components/src/x-modules/history-queries/components/history-queries.vue +++ b/packages/x-components/src/x-modules/history-queries/components/history-queries.vue @@ -47,13 +47,10 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/history-query.vue b/packages/x-components/src/x-modules/history-queries/components/history-query.vue index 05736a0649..98e897c1d7 100644 --- a/packages/x-components/src/x-modules/history-queries/components/history-query.vue +++ b/packages/x-components/src/x-modules/history-queries/components/history-query.vue @@ -7,7 +7,7 @@ @property {MouseEvent} event - The original mouse event --> import { HistoryQuery as HistoryQueryModel } from '@empathyco/x-types'; - import { Component, Mixins, Prop } from 'vue-property-decorator'; - import { Getter } from '../../../components/decorators/store.decorators'; - import Highlight from '../../../components/highlight.vue'; + import { computed, defineComponent, PropType } from 'vue'; import BaseSuggestion from '../../../components/suggestions/base-suggestion.vue'; - import { xComponentMixin } from '../../../components/x-component.mixin'; import { XEventsTypes } from '../../../wiring/events.types'; import { historyQueriesXModule } from '../x-module'; - import { dynamicPropsMixin } from '../../../components/dynamic-props.mixin'; + import { useGetter, useRegisterXModule } from '../../../composables/index'; import RemoveHistoryQuery from './remove-history-query.vue'; /** @@ -57,41 +54,57 @@ * * @public */ - @Component({ - mixins: [xComponentMixin(historyQueriesXModule)], - components: { Highlight, RemoveHistoryQuery, BaseSuggestion } - }) - export default class HistoryQuery extends Mixins( - dynamicPropsMixin(['removeButtonClass', 'suggestionClass']) - ) { - /** - * The history query suggestion to render. - * - * @public - */ - @Prop({ required: true }) - protected suggestion!: HistoryQueryModel; - - /** - * The normalized query of the history-queries module. - * - * @internal - */ - @Getter('historyQueries', 'normalizedQuery') - public query!: string; - - /** - * The list of events that are going to be emitted when the suggestion button is pressed. - * - * @internal - * @returns The {@link XEvent} to emit. - */ - protected get suggestionSelectedEvents(): Partial { + export default defineComponent({ + name: 'HistoryQuery', + xModule: historyQueriesXModule.name, + components: { RemoveHistoryQuery, BaseSuggestion }, + props: { + /** + * The history query suggestion to render. + * + * @public + */ + suggestion: { + type: Object as PropType, + required: true + }, + /** Class inherited by content element. */ + removeButtonClass: String, + /** Class inherited by content element. */ + suggestionClass: String + }, + emits: ['click'], + setup(props, { emit }) { + useRegisterXModule(historyQueriesXModule); + + /** + * The normalized query of the history-queries module. + * + * @internal + */ + const query = useGetter('historyQueries', ['normalizedQuery']).normalizedQuery; + + /** + * The list of events that are going to be emitted when the suggestion button is pressed. + * + * @internal + * @returns The {@link XEvent} to emit. + */ + const suggestionSelectedEvents = computed((): Partial => { + return { + UserSelectedAHistoryQuery: props.suggestion + }; + }); + + const clickHistoryQuery = () => emit('click', props.suggestion, event); + return { - UserSelectedAHistoryQuery: this.suggestion + query, + suggestionSelectedEvents, + clickHistoryQuery }; } - } + }); diff --git a/packages/x-components/src/x-modules/history-queries/components/my-history.vue b/packages/x-components/src/x-modules/history-queries/components/my-history.vue index 8f7135c2ec..c1a7c3fe4b 100644 --- a/packages/x-components/src/x-modules/history-queries/components/my-history.vue +++ b/packages/x-components/src/x-modules/history-queries/components/my-history.vue @@ -59,15 +59,13 @@ diff --git a/packages/_vue3-migration-test/src/x-modules/history-queries/index.ts b/packages/_vue3-migration-test/src/x-modules/history-queries/index.ts new file mode 100644 index 0000000000..07635cbbc8 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/history-queries/index.ts @@ -0,0 +1 @@ +export * from './components'; diff --git a/packages/_vue3-migration-test/src/x-modules/index.ts b/packages/_vue3-migration-test/src/x-modules/index.ts index f84c5d1a78..c8a11f0237 100644 --- a/packages/_vue3-migration-test/src/x-modules/index.ts +++ b/packages/_vue3-migration-test/src/x-modules/index.ts @@ -5,3 +5,4 @@ export * from './search'; export * from './search-box'; export { default as TestElementsList } from './test-elements-list.vue'; export * from './scroll'; +export * from './history-queries';