diff --git a/packages/_vue3-migration-test/src/main.ts b/packages/_vue3-migration-test/src/main.ts index 58fdfd9f62..bf9c6ba6cb 100644 --- a/packages/_vue3-migration-test/src/main.ts +++ b/packages/_vue3-migration-test/src/main.ts @@ -4,6 +4,7 @@ import { createStore } from 'vuex'; import { xPlugin } from '../../x-components/src/plugins/x-plugin'; import App from './App.vue'; import router from './router'; +import { scrollXModule } from './x-modules/scroll/x-module'; // Warnings that cannot be solved in Vue 2 (a.k.a. breaking changes) are suppressed const VUE_COMPAT_MODE = Number(import.meta.env.VITE_VUE_COMPAT_MODE); @@ -30,5 +31,11 @@ const store = createStore({}); createApp(App as Component) .use(router) .use(store) - .use(xPlugin, { adapter, store }) + .use(xPlugin, { + adapter, + store, + __PRIVATE__xModules: { + scroll: scrollXModule + } + }) .mount('#app'); diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts index 436788fafc..a19f19f3a4 100644 --- a/packages/_vue3-migration-test/src/router.ts +++ b/packages/_vue3-migration-test/src/router.ts @@ -8,6 +8,7 @@ import { TestSortDropdown, TestSortList, TestSortPickerList, + TestScroll, TestBaseColumnPickerDropdown } from './'; @@ -22,6 +23,11 @@ const routes = [ name: 'Fade', component: TestFade }, + { + path: '/scroll', + name: 'Scroll', + component: TestScroll + }, { path: '/base-dropdown', name: 'BaseDropdown', diff --git a/packages/_vue3-migration-test/src/x-modules/index.ts b/packages/_vue3-migration-test/src/x-modules/index.ts index 5a2bdeb5b8..0778e03578 100644 --- a/packages/_vue3-migration-test/src/x-modules/index.ts +++ b/packages/_vue3-migration-test/src/x-modules/index.ts @@ -1 +1,2 @@ export * from './search'; +export * from './scroll'; diff --git a/packages/_vue3-migration-test/src/x-modules/scroll/index.ts b/packages/_vue3-migration-test/src/x-modules/scroll/index.ts new file mode 100644 index 0000000000..0a0c301dd9 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/scroll/index.ts @@ -0,0 +1,2 @@ +export { default as TestScroll } from './test-scroll.vue'; +export * from './x-module'; diff --git a/packages/_vue3-migration-test/src/x-modules/scroll/test-scroll.vue b/packages/_vue3-migration-test/src/x-modules/scroll/test-scroll.vue new file mode 100644 index 0000000000..8f74707be1 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/scroll/test-scroll.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/packages/_vue3-migration-test/src/x-modules/scroll/x-module.ts b/packages/_vue3-migration-test/src/x-modules/scroll/x-module.ts new file mode 100644 index 0000000000..8ecf56eab0 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/scroll/x-module.ts @@ -0,0 +1,10 @@ +import { PrivateXModuleOptions } from '../../../../x-components/src/plugins/x-plugin.types'; +import { ScrollXModule } from '../../../../x-components/src/x-modules/scroll/x-module'; + +export const scrollXModule: PrivateXModuleOptions = { + storeModule: { + state: { + pendingScrollTo: 'item-10' + } + } +}; diff --git a/packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts b/packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts index ba1c7f481a..c3bc5bf904 100644 --- a/packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts +++ b/packages/x-components/src/components/animations/__tests__/disable-animation-mixin.spec.ts @@ -1,14 +1,13 @@ import { mount, Wrapper } from '@vue/test-utils'; -import { Component, Prop } from 'vue-property-decorator'; +import { Component, Prop, Provide } from 'vue-property-decorator'; import Vue, { ComponentOptions, CreateElement, VNode } from 'vue'; import DisableAnimationMixin from '../disable-animation.mixin'; -import { XProvide } from '../../decorators/injection.decorators'; import { DISABLE_ANIMATIONS_KEY } from '../../decorators/injection.consts'; @Component class Provider extends Vue { @Prop() - @XProvide(DISABLE_ANIMATIONS_KEY) + @Provide(DISABLE_ANIMATIONS_KEY as string) public disableAnimation!: boolean; render(h: CreateElement): VNode { diff --git a/packages/x-components/src/components/animations/disable-animation.mixin.ts b/packages/x-components/src/components/animations/disable-animation.mixin.ts index a49e1c46ab..9581fa47cf 100644 --- a/packages/x-components/src/components/animations/disable-animation.mixin.ts +++ b/packages/x-components/src/components/animations/disable-animation.mixin.ts @@ -1,6 +1,5 @@ import Vue from 'vue'; -import { Component } from 'vue-property-decorator'; -import { XInject } from '../decorators/injection.decorators'; +import { Component, Inject } from 'vue-property-decorator'; import { DISABLE_ANIMATIONS_KEY } from '../decorators/injection.consts'; /** @@ -22,7 +21,7 @@ export default class DisableAnimationMixin extends Vue { * * @public */ - @XInject(DISABLE_ANIMATIONS_KEY) + @Inject({ from: DISABLE_ANIMATIONS_KEY as string, default: false }) public disableAnimation!: boolean; /** diff --git a/packages/x-components/src/components/layouts/multi-column-max-width-layout.vue b/packages/x-components/src/components/layouts/multi-column-max-width-layout.vue index 8eadb62fbb..9b55ef31c5 100644 --- a/packages/x-components/src/components/layouts/multi-column-max-width-layout.vue +++ b/packages/x-components/src/components/layouts/multi-column-max-width-layout.vue @@ -69,7 +69,7 @@ - +
diff --git a/packages/x-components/src/composables/use-state.ts b/packages/x-components/src/composables/use-state.ts index 55612eb464..e26c4c47da 100644 --- a/packages/x-components/src/composables/use-state.ts +++ b/packages/x-components/src/composables/use-state.ts @@ -19,7 +19,7 @@ export function useState< const store = useStore(); return paths.reduce>((stateDictionary, path) => { - stateDictionary[path] = computed(() => store.state.x[module]?.[path]); + stateDictionary[path] = computed(() => store?.state.x[module]?.[path]); return stateDictionary; }, {}); } diff --git a/packages/x-components/src/x-modules/scroll/components/main-scroll-item.vue b/packages/x-components/src/x-modules/scroll/components/main-scroll-item.vue index 9f67b2e50f..8c5c330016 100644 --- a/packages/x-components/src/x-modules/scroll/components/main-scroll-item.vue +++ b/packages/x-components/src/x-modules/scroll/components/main-scroll-item.vue @@ -1,15 +1,26 @@ diff --git a/packages/x-components/src/x-modules/scroll/components/main-scroll.vue b/packages/x-components/src/x-modules/scroll/components/main-scroll.vue index 9c9f970eb5..710a53b52f 100644 --- a/packages/x-components/src/x-modules/scroll/components/main-scroll.vue +++ b/packages/x-components/src/x-modules/scroll/components/main-scroll.vue @@ -1,19 +1,16 @@ diff --git a/packages/x-components/tests/unit/main-scroll.spec.ts b/packages/x-components/tests/unit/main-scroll.spec.ts index 802025c260..b3f99e43c7 100644 --- a/packages/x-components/tests/unit/main-scroll.spec.ts +++ b/packages/x-components/tests/unit/main-scroll.spec.ts @@ -24,7 +24,8 @@ function renderMainScroll({ useWindow, windowScrollingElement, template = ` - +
{ ...defaultParameters, template: ` -
+
{ userScrolledToElementSpy().should('have.been.calledWith', 'item-5'); userScrolledToElementSpy().should('not.have.been.calledWith', 'item-6'); /* By just scrolling 1 px down, as we require the 100% of the element to intersect to be - considered visible, the 5th element does no longer meet this condition. Therefore the 6th + considered visible, the 5th element does no longer meet this condition. Therefore, the 6th element is considered the first one. */ scrollBy(1); userScrolledToElementSpy().should('have.been.calledWith', 'item-6');