From 0ff979778343ab0a9ab320bc32ff137c6a55ca96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerardo=20V=C3=A1zquez?= Date: Mon, 6 Nov 2023 13:42:39 +0100 Subject: [PATCH 1/9] chore(deps): update x-components version (#359) --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index be504f3d..d8f4a40d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@empathyco/x-adapter": "^8.0.0-alpha.34", "@empathyco/x-adapter-platform": "^1.0.0-alpha.88", "@empathyco/x-archetype-utils": "^1.0.0-alpha.4", - "@empathyco/x-components": "^3.0.1-alpha.4", + "@empathyco/x-components": "^3.1.0-alpha.0", "@empathyco/x-deep-merge": "^1.3.0-alpha.34", "@empathyco/x-types": "^10.0.0-alpha.75", "@empathyco/x-utils": "^1.0.0-alpha.23", @@ -2208,9 +2208,9 @@ "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" }, "node_modules/@empathyco/x-components": { - "version": "3.0.1-alpha.4", - "resolved": "https://registry.npmjs.org/@empathyco/x-components/-/x-components-3.0.1-alpha.4.tgz", - "integrity": "sha512-N8O40mhdhlFgMC4TNXhLLm0fZD1NIJfAsSr8+OAbnccu3TCmpB1VqrAHwL+nZM4w4EaI5HvmCg1+9LoCBQ4btg==", + "version": "3.1.0-alpha.0", + "resolved": "https://registry.npmjs.org/@empathyco/x-components/-/x-components-3.1.0-alpha.0.tgz", + "integrity": "sha512-PG1oCGS2V8gxTBrsojYyMRDl/ia8pXD7uh0g7W7widnEsQ1RjkiiIGsrPlzDZGkOxUJTyKtNbxut65HEVRuztA==", "dependencies": { "@empathyco/x-adapter": "^8.0.1-alpha.0", "@empathyco/x-adapter-platform": "^1.0.1-alpha.0", diff --git a/package.json b/package.json index e8cc0caa..d7b54530 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@empathyco/x-adapter": "^8.0.0-alpha.34", "@empathyco/x-adapter-platform": "^1.0.0-alpha.88", "@empathyco/x-archetype-utils": "^1.0.0-alpha.4", - "@empathyco/x-components": "^3.0.1-alpha.4", + "@empathyco/x-components": "^3.1.0-alpha.0", "@empathyco/x-deep-merge": "^1.3.0-alpha.34", "@empathyco/x-types": "^10.0.0-alpha.75", "@empathyco/x-utils": "^1.0.0-alpha.23", From c87f6298996a75d3f11607224e6facc5e9e4360b Mon Sep 17 00:00:00 2001 From: anna condal Date: Tue, 7 Nov 2023 11:14:08 +0100 Subject: [PATCH 2/9] fix(layout): show SKU on desktop (#345) --------- Co-authored-by: Guillermo Cacheda --- src/components/predictive-layer/full-width-predictive.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/predictive-layer/full-width-predictive.vue b/src/components/predictive-layer/full-width-predictive.vue index fe8344d2..ac4cfc4b 100644 --- a/src/components/predictive-layer/full-width-predictive.vue +++ b/src/components/predictive-layer/full-width-predictive.vue @@ -6,7 +6,7 @@ :animation="empathizeAnimation" class="x-layout-item x-absolute x-z-[1] x-w-full x-bg-neutral-0 x-py-4" > - +
From 72b0c2beccc743df9f4bd37ecafa50db3d68fa5c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:38:49 +0100 Subject: [PATCH 3/9] chore(deps): update actions/setup-node action to v4 (#356) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/actions/install/action.yaml | 2 +- .github/workflows/build.yaml | 2 +- .github/workflows/pull-request.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/install/action.yaml b/.github/actions/install/action.yaml index dddd6d08..5ba7bfe2 100644 --- a/.github/actions/install/action.yaml +++ b/.github/actions/install/action.yaml @@ -4,7 +4,7 @@ description: Install dependencies, build and test project runs: using: 'composite' steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: '18' - name: Installing dependencies diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ca47dc76..ea889918 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,7 +12,7 @@ jobs: contents: read steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '18' - name: Install deps, build and test project diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a9872e40..d65b0c65 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -15,7 +15,7 @@ jobs: contents: read steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '18' - name: Install deps, build and test project From 7da6af24525d66e48364564c935392ef3ecb056e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:39:28 +0100 Subject: [PATCH 4/9] chore(deps): update actions/github-script action to v6 (#355) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d65b0c65..c567f17f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,7 +30,7 @@ jobs: cloudfront_distribution_id: ${{ secrets.CLOUDFRONT_ID_TEST }} cloudfront_invalidation_paths: '/preview/${{ github.event.number }}/*' - name: Adding comment to PR with preview link and validation results - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: github-token: ${{ secrets.SUPPORT_TOKEN }} script: | From 047941e1f59d3b8899d7248954ad7a5b6932f8b0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:40:20 +0100 Subject: [PATCH 5/9] chore(deps): update aws-actions/configure-aws-credentials action to v4 (#361) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/actions/deploy/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index f90e8cd3..72aff284 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -23,7 +23,7 @@ runs: using: 'composite' steps: - name: Configure AWS credentials from Websites account - uses: aws-actions/configure-aws-credentials@v3 + uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ inputs.aws_role }} aws-region: eu-west-1 From 2b3ba7df5dbcf82e2bf68057b204c4c153426691 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:49:38 +0100 Subject: [PATCH 6/9] chore(deps): update dependency @rollup/plugin-replace to v5 (#366) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 68 ++++++++++++++++++++++++++++++++++++++++++----- package.json | 2 +- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index d8f4a40d..9013854b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "@rollup/plugin-commonjs": "~21.0.1", "@rollup/plugin-json": "~4.1.0", "@rollup/plugin-node-resolve": "~13.1.3", - "@rollup/plugin-replace": "~3.0.1", + "@rollup/plugin-replace": "~5.0.0", "@types/autoprefixer": "~9.6.1", "@types/cypress-cucumber-preprocessor": "~4.0.1", "@types/jest": "~27.0.3", @@ -3558,16 +3558,70 @@ } }, "node_modules/@rollup/plugin-replace": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-3.0.1.tgz", - "integrity": "sha512-989J5oRzf3mm0pO/0djTijdfEh9U3n63BIXN5X7T4U9BP+fN4oxQ6DvDuBvFaHA6scaHQRclqmKQEkBhB7k7Hg==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.5.tgz", + "integrity": "sha512-rYO4fOi8lMaTg/z5Jb+hKnrHHVn8j2lwkqwyS4kTRhKyWOLf2wST2sWXr4WzWiTcoHTp2sTjqUbqIj2E39slKQ==", "dev": true, "dependencies": { - "@rollup/pluginutils": "^3.1.0", - "magic-string": "^0.25.7" + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" }, "peerDependencies": { - "rollup": "^1.20.0 || ^2.0.0" + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-replace/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@rollup/plugin-replace/node_modules/@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-replace/node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "node_modules/@rollup/plugin-replace/node_modules/magic-string": { + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" } }, "node_modules/@rollup/pluginutils": { diff --git a/package.json b/package.json index d7b54530..b96f17c2 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@rollup/plugin-commonjs": "~21.0.1", "@rollup/plugin-json": "~4.1.0", "@rollup/plugin-node-resolve": "~13.1.3", - "@rollup/plugin-replace": "~3.0.1", + "@rollup/plugin-replace": "~5.0.0", "@types/autoprefixer": "~9.6.1", "@types/cypress-cucumber-preprocessor": "~4.0.1", "@types/jest": "~27.0.3", From 09a9d64e8bbcbf3e8b6b1f56dc042a22a6a5aec9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:54:12 +0100 Subject: [PATCH 7/9] chore(deps): update dependency @rollup/plugin-json to v6 (#364) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 48 +++++++++++++++++++++++++++++++++++++++++------ package.json | 2 +- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9013854b..929f5a7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "@empathyco/x-tailwindcss": "^1.0.0-alpha.31", "@empathyco/x-translations": "^1.1.0-alpha.33", "@rollup/plugin-commonjs": "~21.0.1", - "@rollup/plugin-json": "~4.1.0", + "@rollup/plugin-json": "~6.0.0", "@rollup/plugin-node-resolve": "~13.1.3", "@rollup/plugin-replace": "~5.0.0", "@types/autoprefixer": "~9.6.1", @@ -3526,17 +3526,53 @@ } }, "node_modules/@rollup/plugin-json": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", - "integrity": "sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.0.1.tgz", + "integrity": "sha512-RgVfl5hWMkxN1h/uZj8FVESvPuBJ/uf6ly6GTj0GONnkfoBN5KC0MSz+PN2OLDgYXMhtG0mWpTrkiOjoxAIevw==", "dev": true, "dependencies": { - "@rollup/pluginutils": "^3.0.8" + "@rollup/pluginutils": "^5.0.1" + }, + "engines": { + "node": ">=14.0.0" }, "peerDependencies": { - "rollup": "^1.20.0 || ^2.0.0" + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } } }, + "node_modules/@rollup/plugin-json/node_modules/@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-json/node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/@rollup/plugin-node-resolve": { "version": "13.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.1.3.tgz", diff --git a/package.json b/package.json index b96f17c2..9b28127b 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@empathyco/x-tailwindcss": "^1.0.0-alpha.31", "@empathyco/x-translations": "^1.1.0-alpha.33", "@rollup/plugin-commonjs": "~21.0.1", - "@rollup/plugin-json": "~4.1.0", + "@rollup/plugin-json": "~6.0.0", "@rollup/plugin-node-resolve": "~13.1.3", "@rollup/plugin-replace": "~5.0.0", "@types/autoprefixer": "~9.6.1", From 4f4b6ae49369c3356b25eeb54cb3d30571413cd5 Mon Sep 17 00:00:00 2001 From: Guillermo Cacheda Date: Thu, 9 Nov 2023 15:03:56 +0100 Subject: [PATCH 8/9] fix: prevent empty HQ filters list to take space (#368) --- src/components/history-query-filters.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/history-query-filters.vue b/src/components/history-query-filters.vue index c46b3bde..7e8dfff7 100644 --- a/src/components/history-query-filters.vue +++ b/src/components/history-query-filters.vue @@ -1,7 +1,7 @@ From 3edebeabd0fd8b8718576e97664540f521e52084 Mon Sep 17 00:00:00 2001 From: anna condal Date: Mon, 13 Nov 2023 12:02:09 +0100 Subject: [PATCH 9/9] feat(experience-controls): Use XControls in NextQueries and Layout (#360) --------- Co-authored-by: Guillermo Cacheda --- public/snippet-script.js | 2 +- src/App.vue | 5 ---- src/adapter/adapter.ts | 6 ++-- src/components/column-picker.vue | 9 +++++- .../search/custom-semantic-queries.vue | 16 +++------- src/components/search/results/results.vue | 11 +++++-- .../use-experience-controls.composable.ts | 30 +++++++++++++++++++ src/composables/use-store.composable.ts | 16 ++++++++++ 8 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 src/composables/use-experience-controls.composable.ts create mode 100644 src/composables/use-store.composable.ts diff --git a/public/snippet-script.js b/public/snippet-script.js index d97d3bae..7cb25acd 100644 --- a/public/snippet-script.js +++ b/public/snippet-script.js @@ -82,7 +82,7 @@ window.initX = { { query: 'dress', title: 'Autumn dresses by Marni', - filters: ['brand:marni', 'collection:autumn - 2022'] + filters: ['brand:marni', 'categoryIds:12fad53d7'] }, { query: 'belted legging', diff --git a/src/App.vue b/src/App.vue index 0278d5b3..877f2a0b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,11 +61,6 @@ return this.snippetConfig.queriesPreview; } - @XProvide('experienceControls') - public get experienceControls(): QueryPreviewInfo[] | undefined { - return this.$store.state.x.experienceControls.controls; - } - @Watch('snippetConfig.uiLang') syncLang(uiLang: string): void { this.$setLocale(uiLang); diff --git a/src/adapter/adapter.ts b/src/adapter/adapter.ts index 225b2b9f..d83818b9 100644 --- a/src/adapter/adapter.ts +++ b/src/adapter/adapter.ts @@ -6,8 +6,7 @@ import { recommendationsRequestSchema, resultSchema, semanticQueriesRequestSchema, - experienceControlsResponseSchema, - PlatformExperienceControlsResponse + experienceControlsResponseSchema } from '@empathyco/x-adapter-platform'; import { ExperienceControlsResponse, @@ -63,9 +62,10 @@ semanticQueriesRequestSchema.$override< // eslint-disable-next-line @typescript-eslint/no-unsafe-call experienceControlsResponseSchema.$override< - PlatformExperienceControlsResponse, + Partial, Partial >({ + controls: ({ controls }) => controls, events: { SemanticQueriesConfigProvided: { maxItemsToRequest: 'controls.semanticQueries.numberOfCarousels', diff --git a/src/components/column-picker.vue b/src/components/column-picker.vue index f0aa012f..ca91a75e 100644 --- a/src/components/column-picker.vue +++ b/src/components/column-picker.vue @@ -24,6 +24,7 @@ Grid4ColIcon } from '@empathyco/x-components'; import { useDevice } from '../composables/use-device.composable'; + import { useExperienceControls } from '../composables/use-experience-controls.composable'; export default defineComponent({ components: { @@ -34,8 +35,14 @@ }, setup() { const { isMobile } = useDevice(); + const { getControlFromPath } = useExperienceControls(); + + const columns = computed(() => + isMobile.value ? [2, 1] : getControlFromPath('layout.columnSelector', [4, 2]) + ); + return { - values: computed(() => (isMobile.value ? [2, 1] : [4, 2])), + values: columns, icons: { 1: 'Grid1ColIcon', 2: 'Grid2ColIcon', 4: 'Grid4ColIcon' } }; } diff --git a/src/components/search/custom-semantic-queries.vue b/src/components/search/custom-semantic-queries.vue index e183ebed..efbdf4fd 100644 --- a/src/components/search/custom-semantic-queries.vue +++ b/src/components/search/custom-semantic-queries.vue @@ -41,12 +41,12 @@ diff --git a/src/composables/use-experience-controls.composable.ts b/src/composables/use-experience-controls.composable.ts new file mode 100644 index 00000000..28bf9f10 --- /dev/null +++ b/src/composables/use-experience-controls.composable.ts @@ -0,0 +1,30 @@ +import { computed, ComputedRef } from 'vue'; +import { getSafePropertyChain } from '@empathyco/x-utils'; +import { ExperienceControlsState } from '@empathyco/x-components/experience-controls'; +import { useStore } from './use-store.composable'; + +/** + * Given a controls' object property chain, gets the experience controls values from the response. + * A defaultValue can be set as a safeguard in case the controls response was empty. + * + * @returns An object containing the function to search for a configuration + * and set the experience controls property value. + */ +export const useExperienceControls = (): { + getControlFromPath: (path: string, defaultValue?: SomeType) => ComputedRef; +} => { + const experienceControls = (useStore('experienceControls') as ExperienceControlsState).controls; + + const getControlFromPath = ( + path: string, + defaultValue?: SomeType + ): ComputedRef => { + return computed(() => { + return getSafePropertyChain(experienceControls, path, defaultValue) as SomeType; + }); + }; + + return { + getControlFromPath + }; +}; diff --git a/src/composables/use-store.composable.ts b/src/composables/use-store.composable.ts new file mode 100644 index 00000000..943ef6e5 --- /dev/null +++ b/src/composables/use-store.composable.ts @@ -0,0 +1,16 @@ +// TODO: Change when useStore composable is added in x-components +import { getCurrentInstance } from 'vue'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { RootXStoreState, StatusState, XModuleName, XModulesTree } from '@empathyco/x-components'; + +/** + * Provides access to the global store object or to the specific store module if it's provided. + * + * @param storeModule - The {@link XModuleName}. + * @returns A state object. + */ +export function useStore(storeModule?: keyof XModulesTree): RootXStoreState | StatusState { + return storeModule + ? getCurrentInstance()!.proxy.$root.$store.state.x[storeModule] + : getCurrentInstance()!.proxy.$root.$store.state.x; +}