Skip to content

Commit eb725fc

Browse files
fix(vue): update Stencil Vue output target (#30159)
This patch includes some necessary updates for `@stencil/vue-output-target@v0.9.0`: - we started to export Stencils helpers as runtime via `@stencil/vue-output-target/runtime` similar to what we did in React - this version requires some updates to Vue and TypeScript as well - adjustments related to that update
1 parent 0030be8 commit eb725fc

File tree

16 files changed

+857
-811
lines changed

16 files changed

+857
-811
lines changed

packages/angular/src/directives/proxies.ts

+85-85
Large diffs are not rendered by default.

packages/angular/standalone/src/directives/proxies.ts

+74-74
Large diffs are not rendered by default.

packages/vue/package-lock.json

+390-267
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vue/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
"@babel/types": "^7.18.4",
5353
"@ionic/eslint-config": "^0.3.0",
5454
"@ionic/prettier-config": "^2.0.0",
55+
"@rollup/plugin-node-resolve": "^16.0.0",
5556
"@rollup/plugin-typescript": "^11.1.5",
57+
"@stencil/vue-output-target": "0.9.4",
5658
"@typescript-eslint/eslint-plugin": "^5.48.2",
5759
"@typescript-eslint/parser": "^5.48.2",
5860
"change-case": "^4.1.1",
@@ -61,8 +63,8 @@
6163
"prettier": "^2.8.3",
6264
"rimraf": "^3.0.2",
6365
"rollup": "^4.2.0",
64-
"typescript": "^4.7.3",
65-
"vue": "3.2.47",
66+
"typescript": "^5.7.3",
67+
"vue": "3.4.38",
6668
"vue-router": "^4.0.16"
6769
},
6870
"dependencies": {

packages/vue/rollup.config.mjs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import resolve from '@rollup/plugin-node-resolve';
12
import typescript from '@rollup/plugin-typescript';
3+
24
const external = ['vue', 'vue-router'];
35

46
export default {
@@ -12,6 +14,13 @@ export default {
1214
sourcemap: true
1315
},
1416
],
15-
plugins: [typescript()],
16-
external: id => external.includes(id) || id.startsWith('@ionic/core') || id.startsWith('ionicons')
17+
plugins: [
18+
typescript(),
19+
resolve()
20+
],
21+
external: (
22+
id => external.includes(id) ||
23+
id.startsWith('@ionic/core') ||
24+
id.startsWith('ionicons')
25+
)
1726
};

packages/vue/scripts/copy-overlays.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function generateOverlays() {
3737
let componentImports = [];
3838
let componentDefinitions = [];
3939

40-
components.forEach(component => {
40+
components.sort((a, b) => a.tag.localeCompare(b.tag)).forEach(component => {
4141
const docsBlock = getDocsBlock(component.tag);
4242
const props = getPropsFromDocsBlock(docsBlock);
4343

@@ -57,13 +57,12 @@ export const ${component.name} = /*@__PURE__*/ defineOverlayContainer<JSX.${comp
5757
* Changes made to this file will be overwritten on build.
5858
*/
5959
60-
import {
60+
import type {
6161
JSX,
6262
} from '@ionic/core/components';
63-
6463
${componentImports.join('\n')}
6564
66-
import { defineOverlayContainer } from '../vue-component-lib/overlays';
65+
import { defineOverlayContainer } from '../utils/overlays';
6766
${componentDefinitions.join('')}
6867
`;
6968

packages/vue/src/components/IonApp.ts

+18-14
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ import type { VNode } from "vue";
33
import { h, defineComponent, shallowRef } from "vue";
44

55
const userComponents = shallowRef([]);
6-
export const IonApp = /*@__PURE__*/ defineComponent((_, { attrs, slots }) => {
7-
defineCustomElement();
8-
return () => {
9-
return h(
10-
"ion-app",
11-
{
12-
...attrs,
13-
},
14-
[slots.default && slots.default(), ...userComponents.value]
15-
);
16-
};
17-
});
18-
19-
IonApp.name = "IonApp";
6+
export const IonApp = /*@__PURE__*/ defineComponent(
7+
(_, { attrs, slots }) => {
8+
defineCustomElement();
9+
return () => {
10+
return h(
11+
"ion-app",
12+
{
13+
name: "IonApp",
14+
...attrs,
15+
},
16+
[slots.default && slots.default(), ...userComponents.value]
17+
);
18+
};
19+
},
20+
{
21+
name: "IonApp",
22+
}
23+
);
2024

2125
/**
2226
* When rendering user components inside of

packages/vue/src/components/IonBackButton.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export const IonBackButton = /*@__PURE__*/ defineComponent(
3434
slots.default && slots.default()
3535
);
3636
};
37+
},
38+
{
39+
name: "IonBackButton",
3740
}
3841
);
39-
40-
IonBackButton.name = "IonBackButton";

packages/vue/src/components/IonNav.ts

+50-48
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,56 @@ import { defineComponent, h, shallowRef } from "vue";
44

55
import { VueDelegate } from "../framework-delegate";
66

7-
export const IonNav = /*@__PURE__*/ defineComponent((props) => {
8-
defineCustomElement();
9-
const views = shallowRef([]);
7+
export const IonNav = /*@__PURE__*/ defineComponent(
8+
(props) => {
9+
defineCustomElement();
10+
const views = shallowRef([]);
1011

11-
/**
12-
* Allows us to create the component
13-
* within the Vue application context.
14-
*/
15-
const addView = (component: VNode) =>
16-
(views.value = [...views.value, component]);
17-
const removeView = (component: VNode) =>
18-
(views.value = views.value.filter((cmp) => cmp !== component));
12+
/**
13+
* Allows us to create the component
14+
* within the Vue application context.
15+
*/
16+
const addView = (component: VNode) =>
17+
(views.value = [...views.value, component]);
18+
const removeView = (component: VNode) =>
19+
(views.value = views.value.filter((cmp) => cmp !== component));
1920

20-
const delegate = VueDelegate(addView, removeView);
21-
return () => {
22-
return h("ion-nav", { ...props, delegate }, views.value);
23-
};
24-
});
25-
26-
IonNav.name = "IonNav";
27-
28-
/**
29-
* The default values follow what is defined at
30-
* https://ionicframework.com/docs/api/nav#properties
31-
* otherwise the default values on the Web Component
32-
* may be overridden. For example, if the default animated value
33-
* is not `true` below, then Vue would default the prop to `false`
34-
* which would override the Web Component default of `true`.
35-
*/
36-
IonNav.props = {
37-
animated: {
38-
type: Boolean,
39-
default: true,
40-
},
41-
animation: {
42-
type: Function,
43-
default: undefined,
44-
},
45-
root: {
46-
type: [Function, Object, String],
47-
default: undefined,
48-
},
49-
rootParams: {
50-
type: Object,
51-
default: undefined,
52-
},
53-
swipeGesture: {
54-
type: Boolean,
55-
default: undefined,
21+
const delegate = VueDelegate(addView, removeView);
22+
return () => {
23+
return h("ion-nav", { ...props, delegate }, views.value);
24+
};
5625
},
57-
};
26+
{
27+
name: "IonNav",
28+
/**
29+
* The default values follow what is defined at
30+
* https://ionicframework.com/docs/api/nav#properties
31+
* otherwise the default values on the Web Component
32+
* may be overridden. For example, if the default animated value
33+
* is not `true` below, then Vue would default the prop to `false`
34+
* which would override the Web Component default of `true`.
35+
*/
36+
props: {
37+
animated: {
38+
type: Boolean,
39+
default: true,
40+
},
41+
animation: {
42+
type: Function,
43+
default: undefined,
44+
},
45+
root: {
46+
type: [Function, Object, String],
47+
default: undefined,
48+
},
49+
rootParams: {
50+
type: Object,
51+
default: undefined,
52+
},
53+
swipeGesture: {
54+
type: Boolean,
55+
default: undefined,
56+
},
57+
},
58+
}
59+
);

packages/vue/src/components/IonRouterOutlet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const IonRouterOutlet = /*@__PURE__*/ defineComponent({
4444
let previousMatchedRouteRef: Ref | undefined;
4545
let previousMatchedPath: string | undefined;
4646

47-
provide(viewDepthKey, depth + 1);
47+
provide(viewDepthKey, (depth + 1) as 0);
4848
provide(matchedRouteKey, matchedRouteRef);
4949

5050
const ionRouterOutlet = ref();

packages/vue/src/components/IonTabBar.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const IonTabBar = defineComponent({
4343
data() {
4444
return {
4545
tabState: {
46-
activeTab: undefined,
46+
activeTab: undefined as string | undefined,
4747
tabs: {},
4848
/**
4949
* Passing this prop to each tab button
@@ -52,7 +52,7 @@ export const IonTabBar = defineComponent({
5252
*/
5353
hasRouterOutlet: false,
5454
},
55-
tabVnodes: [],
55+
tabVnodes: [] as VNode[],
5656
/* eslint-disable @typescript-eslint/no-empty-function */
5757
_tabsWillChange: { type: Function, default: () => {} },
5858
_tabsDidChange: { type: Function, default: () => {} },

packages/vue/src/components/Overlays.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,30 @@
33
* Changes made to this file will be overwritten on build.
44
*/
55

6-
import {
6+
import type {
77
JSX,
88
} from '@ionic/core/components';
9-
109
import { defineCustomElement as defineIonActionSheetCustomElement } from '@ionic/core/components/ion-action-sheet.js'
1110
import { defineCustomElement as defineIonAlertCustomElement } from '@ionic/core/components/ion-alert.js'
1211
import { defineCustomElement as defineIonLoadingCustomElement } from '@ionic/core/components/ion-loading.js'
13-
import { defineCustomElement as defineIonPickerLegacyCustomElement } from '@ionic/core/components/ion-picker-legacy.js'
14-
import { defineCustomElement as defineIonToastCustomElement } from '@ionic/core/components/ion-toast.js'
1512
import { defineCustomElement as defineIonModalCustomElement } from '@ionic/core/components/ion-modal.js'
13+
import { defineCustomElement as defineIonPickerLegacyCustomElement } from '@ionic/core/components/ion-picker-legacy.js'
1614
import { defineCustomElement as defineIonPopoverCustomElement } from '@ionic/core/components/ion-popover.js'
15+
import { defineCustomElement as defineIonToastCustomElement } from '@ionic/core/components/ion-toast.js'
1716

18-
import { defineOverlayContainer } from '../vue-component-lib/overlays';
17+
import { defineOverlayContainer } from '../utils/overlays';
1918

2019
export const IonActionSheet = /*@__PURE__*/ defineOverlayContainer<JSX.IonActionSheet>('ion-action-sheet', defineIonActionSheetCustomElement, ['animated', 'backdropDismiss', 'buttons', 'cssClass', 'enterAnimation', 'header', 'htmlAttributes', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'subHeader', 'translucent', 'trigger']);
2120

2221
export const IonAlert = /*@__PURE__*/ defineOverlayContainer<JSX.IonAlert>('ion-alert', defineIonAlertCustomElement, ['animated', 'backdropDismiss', 'buttons', 'cssClass', 'enterAnimation', 'header', 'htmlAttributes', 'inputs', 'isOpen', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'subHeader', 'translucent', 'trigger']);
2322

2423
export const IonLoading = /*@__PURE__*/ defineOverlayContainer<JSX.IonLoading>('ion-loading', defineIonLoadingCustomElement, ['animated', 'backdropDismiss', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'isOpen', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'showBackdrop', 'spinner', 'translucent', 'trigger']);
2524

26-
export const IonPickerLegacy = /*@__PURE__*/ defineOverlayContainer<JSX.IonPickerLegacy>('ion-picker-legacy', defineIonPickerLegacyCustomElement, ['animated', 'backdropDismiss', 'buttons', 'columns', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'showBackdrop', 'trigger']);
27-
28-
export const IonToast = /*@__PURE__*/ defineOverlayContainer<JSX.IonToast>('ion-toast', defineIonToastCustomElement, ['animated', 'buttons', 'color', 'cssClass', 'duration', 'enterAnimation', 'header', 'htmlAttributes', 'icon', 'isOpen', 'keyboardClose', 'layout', 'leaveAnimation', 'message', 'mode', 'position', 'positionAnchor', 'swipeGesture', 'translucent', 'trigger']);
29-
3025
export const IonModal = /*@__PURE__*/ defineOverlayContainer<JSX.IonModal>('ion-modal', defineIonModalCustomElement, ['animated', 'backdropBreakpoint', 'backdropDismiss', 'breakpoints', 'canDismiss', 'enterAnimation', 'focusTrap', 'handle', 'handleBehavior', 'htmlAttributes', 'initialBreakpoint', 'isOpen', 'keepContentsMounted', 'keyboardClose', 'leaveAnimation', 'mode', 'presentingElement', 'showBackdrop', 'trigger'], true);
3126

27+
export const IonPickerLegacy = /*@__PURE__*/ defineOverlayContainer<JSX.IonPickerLegacy>('ion-picker-legacy', defineIonPickerLegacyCustomElement, ['animated', 'backdropDismiss', 'buttons', 'columns', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'showBackdrop', 'trigger']);
28+
3229
export const IonPopover = /*@__PURE__*/ defineOverlayContainer<JSX.IonPopover>('ion-popover', defineIonPopoverCustomElement, ['alignment', 'animated', 'arrow', 'backdropDismiss', 'component', 'componentProps', 'dismissOnSelect', 'enterAnimation', 'event', 'focusTrap', 'htmlAttributes', 'isOpen', 'keepContentsMounted', 'keyboardClose', 'leaveAnimation', 'mode', 'reference', 'showBackdrop', 'side', 'size', 'translucent', 'trigger', 'triggerAction']);
3330

31+
export const IonToast = /*@__PURE__*/ defineOverlayContainer<JSX.IonToast>('ion-toast', defineIonToastCustomElement, ['animated', 'buttons', 'color', 'cssClass', 'duration', 'enterAnimation', 'header', 'htmlAttributes', 'icon', 'isOpen', 'keyboardClose', 'layout', 'leaveAnimation', 'message', 'mode', 'position', 'positionAnchor', 'swipeGesture', 'translucent', 'trigger']);
32+

0 commit comments

Comments
 (0)