Skip to content

Commit d590842

Browse files
diegopfvictorcg88joseacabanerosalbertjcuaclauramargar
authored
feat: update x-components and related packages to vue 3 (#1644)
Co-authored-by: Víctor CG <[email protected]> Co-authored-by: Jose Antonio Cabañeros <[email protected]> Co-authored-by: Alberto Monedero Martín <[email protected]> Co-authored-by: lauramargar <[email protected]> Co-authored-by: acondal <[email protected]>
1 parent 5415b6b commit d590842

File tree

399 files changed

+9389
-14664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

399 files changed

+9389
-14664
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
**/tests/e2e/videos/
1111
**/tests/e2e/screenshots/
12+
**/tests/e2e/downloads/
1213

1314
# local env files
1415
.env.local

packages/_vue3-migration-test/CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.0.0-alpha.51](https://github.com/empathyco/x/compare/[email protected]@1.0.0-alpha.51) (2024-09-05)
7+
8+
9+
### Bug Fixes
10+
11+
* **list-components:** fix list components, migrate infinite-scroll directive and deprecated layouts (#1576) ([4b57f19](https://github.com/empathyco/x/commit/4b57f19be601220a4dc6874dc1d5efa8fdbcf991))
12+
13+
14+
### Code Refactoring
15+
16+
* **animation-factory:** fix Vue3 breaking changes (#1579) ([f915731](https://github.com/empathyco/x/commit/f915731cc8ea662a2066fee054f47885ee2154a9))
17+
* **base-switch:** decommission of value prop (#1589) ([35968eb](https://github.com/empathyco/x/commit/35968ebb69634984e867b03221d373efe4af96c8))
18+
* **base-switch:** migrate component to vue3 (#1588) ([875a6e2](https://github.com/empathyco/x/commit/875a6e2638885498396db362753550857ec8d7e2))
19+
* **staggered-fade-and-slide:** use Vue native staggered transition (#1578) ([79e136f](https://github.com/empathyco/x/commit/79e136f04b0b75ddea77c464b8f5ea0ed6602eb1))
20+
21+
22+
623
## [1.0.0-alpha.50](https://github.com/empathyco/x/compare/[email protected]@1.0.0-alpha.50) (2024-07-23)
724

825

packages/_vue3-migration-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue3-migration-test",
33
"private": "true",
4-
"version": "1.0.0-alpha.50",
4+
"version": "1.0.0-alpha.51",
55
"scripts": {
66
"dev": "vite",
77
"preview": "vite preview",

packages/_vue3-migration-test/src/components/animations/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export { default as TestCrossFade } from './test-cross-fade.vue';
55
export { default as TestFade } from './test-fade.vue';
66
export { default as TestFadeAndSlide } from './test-fade-and-slide.vue';
77
export { default as TestAnimationFactory } from './test-animation-factory.vue';
8+
export { default as TestStaggeredFadeAndSlide } from './test-staggered-fade-and-slide.vue';

packages/_vue3-migration-test/src/components/animations/test-animation-factory.vue

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
11
<template>
22
<div class="animate-modal">
3-
<p>
4-
BREAKING Vue3: `h()` hyperscript doesn't support rendering `'transition'` using strings.
5-
Instead, replace it by `Transition` component of Vue 3 itself `import { Transition } from
6-
'vue'`.
7-
<br />
8-
<a href="https://github.com/vuejs/core/issues/826#issuecomment-598207464">
9-
https://github.com/vuejs/core/issues/826#issuecomment-598207464
10-
</a>
11-
<br />
12-
<a href="https://github.com/vuejs/test-utils/issues/471#issuecomment-804477181">
13-
https://github.com/vuejs/test-utils/issues/471#issuecomment-804477181
14-
</a>
15-
</p>
16-
<p>
17-
BREAKING Vue3: Review Transition Class Change. Replace instances of `.v-enter` to
18-
`.v-enter-from` Replace instances of `.v-leave` to `.v-leave-from`.
19-
<br />
20-
<a href="https://v3-migration.vuejs.org/breaking-changes/transition.html">
21-
https://v3-migration.vuejs.org/breaking-changes/transition.html
22-
</a>
23-
</p>
24-
<p>
25-
BREAKING Vue3: VNodes now have a flat props structure.
26-
<br />
27-
<a
28-
href="https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#vnode-props-format"
29-
>
30-
https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#vnode-props-format
31-
</a>
32-
</p>
333
<button @click="openWithClipPath">Open modal with CLIP PATH animation</button>
344
<button @click="openWithScale">Open modal with SCALE animation</button>
355
<button @click="openWithTranslate">Open modal with TRANSLATE animation</button>
@@ -49,34 +19,37 @@
4919
</template>
5020

5121
<script setup lang="ts">
52-
import { ref, shallowRef } from 'vue';
22+
import { nextTick, ref, shallowRef } from 'vue';
5323
import BaseModal from '../../../../x-components/src/components/modals/base-modal.vue';
5424
import { animateClipPath } from '../../../../x-components/src/components/animations/animate-clip-path/animate-clip-path.factory';
5525
import { animateScale } from '../../../../x-components/src/components/animations/animate-scale/animate-scale.factory';
5626
import { animateTranslate } from '../../../../x-components/src/components/animations/animate-translate/animate-translate.factory';
5727
58-
const clipPathAnimation = animateClipPath('bottom');
28+
const clipPathAnimation = animateClipPath('left');
5929
const scaleAnimation = animateScale('bottom');
60-
const translateAnimation = animateTranslate('bottom');
30+
const translateAnimation = animateTranslate('right');
6131
62-
const currentAnimation = shallowRef(clipPathAnimation);
32+
const currentAnimation = shallowRef(scaleAnimation);
6333
const open = ref(false);
6434
6535
/** Open modal with ClipPath animation. */
66-
function openWithClipPath() {
36+
async function openWithClipPath() {
6737
currentAnimation.value = clipPathAnimation;
38+
await nextTick();
6839
open.value = true;
6940
}
7041
7142
/** Open modal with Scale animation. */
72-
function openWithScale() {
43+
async function openWithScale() {
7344
currentAnimation.value = scaleAnimation;
45+
await nextTick();
7446
open.value = true;
7547
}
7648
7749
/** Open modal with Translate animation. */
78-
function openWithTranslate() {
50+
async function openWithTranslate() {
7951
currentAnimation.value = translateAnimation;
52+
await nextTick();
8053
open.value = true;
8154
}
8255
</script>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<h1>Dinamic content:</h1>
3+
<button @click="insert">Insert at random index</button>
4+
<button @click="reset">Reset</button>
5+
6+
<StaggeredFadeAndSlide :stagger="500">
7+
<li v-for="item in items" :key="item.id">
8+
{{ item.id }} - {{ item.name }}
9+
<button @click="remove(item)">x</button>
10+
</li>
11+
</StaggeredFadeAndSlide>
12+
13+
<br />
14+
<h1>Animation as prop</h1>
15+
<BaseSuggestions :suggestions="suggestions" :animation="StaggeredFadeAndSlide" :stagger="50">
16+
<template #default="{ suggestion }">
17+
<span>{{ suggestion.query }}</span>
18+
</template>
19+
</BaseSuggestions>
20+
21+
<br />
22+
<h1>Static content:</h1>
23+
<StaggeredFadeAndSlide :stagger="50">
24+
<li key="1">Element to animate</li>
25+
<li key="2">Element to animate</li>
26+
<li key="3">Element to animate</li>
27+
</StaggeredFadeAndSlide>
28+
</template>
29+
30+
<script setup lang="ts">
31+
import { ref } from 'vue';
32+
import StaggeredFadeAndSlide from '../../../../x-components/src/components/animations/staggered-fade-and-slide.vue';
33+
import BaseSuggestions from '../../../../x-components/src/components/suggestions/base-suggestions.vue';
34+
import {
35+
getQuerySuggestionsStub,
36+
createResultStub,
37+
getResultsStub
38+
} from '../../../../x-components/src/__stubs__';
39+
const suggestions = getQuerySuggestionsStub('chip', 5);
40+
const getInitialItems = () => getResultsStub(5);
41+
const items = ref(getInitialItems());
42+
let id = items.value.length + 1;
43+
/**
44+
* Insert a new item at a random index.
45+
*/
46+
function insert() {
47+
const i = Math.round(Math.random() * items.value.length);
48+
items.value.splice(i, 0, createResultStub(`Product ${id++}`));
49+
}
50+
/**
51+
* Reset the list of items.
52+
*/
53+
function reset() {
54+
items.value = getInitialItems();
55+
id = items.value.length + 1;
56+
}
57+
/**
58+
* Remove an item from the list.
59+
*
60+
* @param item - The item to remove.
61+
*/
62+
function remove(item: any) {
63+
const i = items.value.indexOf(item);
64+
if (i > -1) {
65+
items.value.splice(i, 1);
66+
}
67+
}
68+
</script>

packages/_vue3-migration-test/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export { default as TestBaseDropdown } from './test-base-dropdown.vue';
66
export { default as TestBaseEventButton } from './test-base-event-button.vue';
77
export { default as TestBaseVariableColumnGrid } from './test-base-variable-column-grid.vue';
88
export { default as TestSlidingPanel } from './test-sliding-panel.vue';
9-
export { default as TestUseLayouts } from './test-use-layouts.vue';
109
export { default as TestBaseSuggestions } from './suggestions/test-base-suggestions.vue';
1110
export { default as TestHighlight } from './test-highlight.vue';
1211
export { default as TestBaseResultImages } from './result/test-base-result-images.vue';
@@ -20,3 +19,4 @@ export { default as TestTagging } from './tagging/test-tagging.vue';
2019
export { default as TestRenderlessExtraParam } from './extra-params/test-renderless-extra-param.vue';
2120
export { default as TestIcons } from './icons/test-icons.vue';
2221
export { default as TestDisplayEmitter } from './test-display-emitter.vue';
22+
export { default as TestBaseSwitch } from './test-base-switch.vue';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<p>Using props and events:</p>
3+
<BaseSwitch @change="value = !value" :modelValue="value" />
4+
{{ value }}
5+
<br />
6+
<p>Using the `v-model` directive:</p>
7+
<BaseSwitch v-model="value2" />
8+
{{ value2 }}
9+
</template>
10+
11+
<script setup lang="ts">
12+
import { ref } from 'vue';
13+
14+
import BaseSwitch from '../../../x-components/src/components/base-switch.vue';
15+
16+
const value = ref(true);
17+
const value2 = ref(true);
18+
</script>

packages/_vue3-migration-test/src/components/test-use-layouts.vue

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/_vue3-migration-test/src/router.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
TestSearchBox,
2323
TestBaseVariableColumnGrid,
2424
TestEmpathize,
25-
TestUseLayouts,
2625
TestSlidingPanel,
2726
TestBaseSuggestions,
2827
TestHighlight,
@@ -50,7 +49,9 @@ import {
5049
TestRenderlessExtraParam,
5150
TestAnimationFactory,
5251
TestIcons,
53-
TestDisplayEmitter
52+
TestDisplayEmitter,
53+
TestBaseSwitch,
54+
TestStaggeredFadeAndSlide
5455
} from './';
5556

5657
const routes = [
@@ -174,11 +175,6 @@ const routes = [
174175
name: 'BaseVariableColumnGrid',
175176
component: TestBaseVariableColumnGrid
176177
},
177-
{
178-
path: '/test-use-layouts',
179-
name: 'UseLayouts',
180-
component: TestUseLayouts
181-
},
182178
{
183179
path: '/base-suggestions',
184180
name: 'BaseSuggestions',
@@ -308,6 +304,16 @@ const routes = [
308304
path: '/display-emitter',
309305
name: 'DisplayEmitter',
310306
component: TestDisplayEmitter
307+
},
308+
{
309+
path: '/base-switch',
310+
name: 'BaseSwitch',
311+
component: TestBaseSwitch
312+
},
313+
{
314+
path: '/staggered-fade-and-slide',
315+
name: 'StaggeredFadeAndSlide',
316+
component: TestStaggeredFadeAndSlide
311317
}
312318
];
313319

0 commit comments

Comments
 (0)