Skip to content

Commit 3cbebbd

Browse files
authored
feat(vue): support for showModal (#1872)
1 parent 813b9ce commit 3cbebbd

24 files changed

+1122
-1300
lines changed

.changeset/quick-seas-notice.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@siemens/ix-vue': minor
3+
---
4+
5+
add support for showModal
6+
7+
Fixes #1771

packages/vue-test-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"@vitejs/plugin-vue": "^4.6.2",
31+
"@vitejs/plugin-vue-jsx": "^4.1.2",
3132
"typescript": "^4.9.5",
3233
"vite": "^4.5.14",
3334
"vue-tsc": "^1.8.27"

packages/vue-test-app/src/Root.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<script setup lang="ts">
1111
import { computed, ref } from 'vue';
1212
13+
import { IxApplicationContext } from "@siemens/ix-vue"
14+
15+
1316
import App from './App.vue';
1417
import AboutAndLegal from './preview-examples/about-and-legal.vue';
1518
import ActionCard from './preview-examples/action-card.vue';
@@ -471,6 +474,8 @@ const currentView = computed(() => {
471474
</script>
472475

473476
<template>
474-
<component :is="currentView"></component>
477+
<IxApplicationContext>
478+
<component :is="currentView"></component>
479+
</IxApplicationContext>
475480
</template>
476481
import layoutAutoVue from './preview-examples/layout-auto.vue';

packages/vue-test-app/src/preview-examples/modal-sizes.vue

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
* LICENSE file in the root directory of this source tree.
88
-->
99

10-
<script setup lang="ts">
10+
<script setup lang="tsx">
1111
import { IxModalSize } from '@siemens/ix';
12-
import { IxButton, IxModal } from '@siemens/ix-vue';
13-
import { ref } from 'vue';
12+
import { IxButton, Modal, ModalSlotProps, showModal } from '@siemens/ix-vue';
1413
1514
const sizes: IxModalSize[] = [
1615
'360',
@@ -21,17 +20,20 @@ const sizes: IxModalSize[] = [
2120
'full-width',
2221
'full-screen',
2322
];
24-
const currentSize = ref<IxModalSize | undefined>(undefined);
25-
const show = ref(false);
2623
2724
const open = (size: IxModalSize) => {
28-
currentSize.value = size;
29-
show.value = true;
25+
showModal({
26+
size,
27+
content:
28+
<Modal>
29+
{
30+
({ closeModal }: ModalSlotProps) => <IxButton onClick={closeModal}> Modal with size {size} </IxButton>
31+
}
32+
</Modal>
33+
});
3034
};
3135
32-
const closeModal = () => {
33-
show.value = false;
34-
};
36+
3537
</script>
3638

3739
<style scoped src="./modal-sizes.css"></style>
@@ -42,8 +44,4 @@ const closeModal = () => {
4244
Show modal size {{ size }}
4345
</IxButton>
4446
</div>
45-
46-
<IxModal v-if="show && currentSize" :size="currentSize" @close="show = false">
47-
<IxButton @click="closeModal"> Modal with size {{ currentSize }} </IxButton>
48-
</IxModal>
4947
</template>

packages/vue-test-app/src/preview-examples/modal.vue

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,35 @@
77
* LICENSE file in the root directory of this source tree.
88
-->
99

10-
<script setup lang="ts">
10+
<script setup lang="tsx">
1111
import {
12-
HTMLRefElement,
1312
IxButton,
14-
IxModal,
1513
IxModalHeader,
1614
IxModalContent,
1715
IxModalFooter,
16+
Modal,
17+
ModalSlotProps,
18+
showModal
1819
} from '@siemens/ix-vue';
19-
import { ref } from 'vue';
2020
21-
const modalRef = ref<HTMLRefElement<HTMLIxModalElement>>();
22-
const close = () => {
23-
modalRef.value?.$el.closeModal('close payload!');
24-
show.value = false;
25-
};
26-
const dismiss = () => {
27-
modalRef.value?.$el.dismissModal('dismiss payload');
28-
show.value = false;
29-
};
21+
function show() {
22+
showModal({
23+
content: <Modal>{
24+
({ closeModal, dismissModal }: ModalSlotProps) => [
25+
<IxModalHeader>Message headline</IxModalHeader>,
26+
<IxModalContent>Message text lorem ipsum</IxModalContent>,
27+
<IxModalFooter>
28+
<IxButton outline onClick={() => dismissModal()}>Cancel</IxButton>
29+
<IxButton onClick={() => closeModal()}>OK</IxButton>
30+
</IxModalFooter>
31+
]
32+
}
33+
</Modal >
34+
})
35+
}
3036
31-
const show = ref(false);
3237
</script>
3338

3439
<template>
35-
<IxButton @click="show = true">Show modal</IxButton>
36-
<IxDialog ref="modalRef" v-if="show">
37-
<IxModalHeader onclose="dismiss()">Message headline</IxModalHeader>
38-
<IxModalContent>Message text lorem ipsum</IxModalContent>
39-
<IxModalFooter>
40-
<IxButton outline @click="dismiss()"> Cancel </IxButton>
41-
<IxButton @click="close()">OK</IxButton>
42-
</IxModalFooter>
43-
</IxDialog>
40+
<IxButton @click="show()">Show modal</IxButton>
4441
</template>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
/// <reference types="vite/client" />
2+
3+
export {};
4+
declare module 'vue' {
5+
interface ComponentCustomProps {
6+
onClick?: (...args: any[]) => void;
7+
}
8+
}

packages/vue-test-app/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"moduleResolution": "Node",
77
"strict": true,
88
"jsx": "preserve",
9+
"jsxImportSource": "vue",
910
"resolveJsonModule": true,
1011
"isolatedModules": true,
1112
"esModuleInterop": true,

packages/vue-test-app/vite.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import vue from '@vitejs/plugin-vue';
11+
import vueJsx from '@vitejs/plugin-vue-jsx';
1112
import { defineConfig } from 'vite';
1213
import path from 'path';
1314
import fs from 'fs';
@@ -33,6 +34,11 @@ export default defineConfig(() => {
3334
});
3435

3536
return {
36-
plugins: [vue()],
37+
plugins: [
38+
vue(),
39+
vueJsx({
40+
include: ['src/preview-examples/modal*.vue'],
41+
}),
42+
],
3743
};
3844
});

packages/vue/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dist"
2222
],
2323
"scripts": {
24-
"build": "pnpm clean && rollup --config rollup.config.mjs",
24+
"build": "pnpm clean && vite build && vue-tsc --declaration --emitDeclarationOnly --outDir dist",
2525
"clean": "rimraf dist",
2626
"lint": "eslint src"
2727
},
@@ -30,17 +30,18 @@
3030
"@stencil/vue-output-target": "^0.10.7"
3131
},
3232
"devDependencies": {
33-
"@rollup/plugin-typescript": "^8.5.0",
3433
"@siemens/ix": "workspace:*",
3534
"@typescript-eslint/eslint-plugin": "^5.62.0",
3635
"@typescript-eslint/parser": "^5.62.0",
3736
"eslint": "~8.21.0",
3837
"eslint-config-ix": "workspace:*",
3938
"eslint-plugin-vue": "^9.27.0",
4039
"rimraf": "^3.0.2",
41-
"rollup": "^2.79.1",
42-
"typescript": "^4.9.5",
43-
"vue": "^3.4.34"
40+
"typescript": "^5.8.3",
41+
"vue": "^3.4.34",
42+
"vite": "^6.3.5",
43+
"vue-tsc": "^2.2.10",
44+
"@vitejs/plugin-vue": "^5.2.3"
4445
},
4546
"peerDependencies": {
4647
"@siemens/ix-icons": "^3.0.0",

packages/vue/rollup.config.mjs

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

0 commit comments

Comments
 (0)