Skip to content
This repository was archived by the owner on Jan 9, 2022. It is now read-only.

Commit e877c1b

Browse files
committed
feat: upgrade
1 parent 47f9573 commit e877c1b

File tree

9 files changed

+85
-31
lines changed

9 files changed

+85
-31
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"build": "vue-tsc --noEmit && vite build",
77
"serve": "vite preview"
88
},
9-
"files": ["dist"],
9+
"files": [
10+
"dist"
11+
],
1012
"main": "./dist/gitart-vue-dialog.umd.js",
1113
"module": "./dist/gitart-vue-dialog.es.js",
1214
"exports": {
@@ -16,6 +18,7 @@
1618
}
1719
},
1820
"dependencies": {
21+
"@vueuse/core": "^5.1.3",
1922
"body-scroll-lock": "^4.0.0-beta.0",
2023
"vue": "^3.0.5"
2124
},

src/gitart-vue-dialog/components/GDialog.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<Teleport to="body">
44
<GDialogOverlay
55
@click="onClickOutside"
6-
:value="isActive"
6+
:active="isActive"
7+
:deactivating="deactivating"
78
:activeZIndex="activeZIndex"
89
/>
910

@@ -91,7 +92,7 @@ export default defineComponent({
9192
}
9293
};
9394
94-
const { activatedOnce, active: isActive } = useLazyActivation(
95+
const { activatedOnce, active: isActive, deactivating } = useLazyActivation(
9596
computed(() => props.modelValue)
9697
);
9798
@@ -119,6 +120,7 @@ export default defineComponent({
119120
activatedOnce,
120121
activeZIndex,
121122
isActive,
123+
deactivating,
122124
classes,
123125
styles,
124126
frame,

src/gitart-vue-dialog/components/GDialogOverlay.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<Transition name="fade">
3-
<template v-if="value">
3+
<template v-if="active">
44
<div :class="classes" :style="styles" @click="onClick" />
55
</template>
66
</Transition>
@@ -12,7 +12,12 @@ import { computed, defineComponent } from '@vue/runtime-core';
1212
export default defineComponent({
1313
name: 'GDialogOverlay',
1414
props: {
15-
value: {
15+
active: {
16+
type: Boolean,
17+
required: true,
18+
},
19+
20+
deactivating: {
1621
type: Boolean,
1722
required: true,
1823
},
@@ -33,7 +38,7 @@ export default defineComponent({
3338
const classes = computed(() => [
3439
'q-dialog-overlay',
3540
{
36-
'q-dialog-overlay--active': props.value,
41+
'q-dialog-overlay--active': props.active && !props.deactivating,
3742
},
3843
]);
3944
@@ -76,7 +81,7 @@ export default defineComponent({
7681
}
7782
7883
&-leave-active {
79-
transition: all 20.2s cubic-bezier(1, 0.5, 0.8, 1);
84+
transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
8085
}
8186
8287
&-enter-from,

src/gitart-vue-dialog/composable/lazyActivation.js renamed to src/gitart-vue-dialog/composable/lazyActivation.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
import { Ref } from 'vue';
2+
13
import { nextTick, ref, watch } from 'vue';
24

3-
export const useLazyActivation = baseState => {
5+
export const useLazyActivation = (baseState: Ref<boolean>) => {
46
const activatedOnce = ref(baseState.value);
57
const active = ref(baseState.value);
8+
const deactivating = ref(false)
69

710
watch(
811
() => baseState.value,
912
value => {
13+
if(!value){
14+
deactivating.value = true
15+
nextTick(() => {
16+
active.value = value;
17+
deactivating.value = false
18+
});
19+
20+
return;
21+
}
22+
1023
if (activatedOnce.value) {
1124
active.value = value;
1225
return;
@@ -22,5 +35,6 @@ export const useLazyActivation = baseState => {
2235
return {
2336
activatedOnce,
2437
active,
38+
deactivating,
2539
};
2640
};

src/gitart-vue-dialog/composable/stackable.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import { Ref, ComputedRef } from 'vue';
33

44
import { computed } from 'vue';
5-
import { getZIndex } from '../helper';
5+
6+
// helpers
7+
import { getZIndex } from '@/gitart-vue-dialog/helper';
68

79
interface IUseStackableParams {
810
activeElSelector: string;

src/gitart-vue-dialog/composable/widthStyle.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { computed } from 'vue';
2+
3+
// helpers
4+
import { convertToUnit } from '@/gitart-vue-dialog/helper';
5+
6+
export interface WidthProps {
7+
maxWidth?: number | string;
8+
width?: number | string;
9+
}
10+
11+
export const useWidthStyle = (props: WidthProps) => {
12+
const widthStyles = computed(() => {
13+
return {
14+
maxWidth:
15+
props.maxWidth === 'none'
16+
? undefined
17+
: convertToUnit(props.maxWidth),
18+
19+
width:
20+
props.width === 'auto'
21+
? undefined
22+
: convertToUnit(props.width),
23+
};
24+
});
25+
26+
return {
27+
widthStyles,
28+
};
29+
};

src/gitart-vue-dialog/helper/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const windowWidthWithoutScrollbar = () => {
2727
* @param {string} unit
2828
* @returns {string | undefined}
2929
*/
30-
const convertToUnit = (str, unit = 'px') => {
30+
export const convertToUnit = (str, unit = 'px') => {
3131
if (str == null || str === '') {
3232
return undefined;
3333
} else if (isNaN(+str)) {

yarn.lock

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@
114114
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.1.4.tgz#c14c461ec42ea2c1556e86f60b0354341d91adc3"
115115
integrity sha512-6O45kZAmkLvzGLToBxEz4lR2W6kXohCtebV2UxjH9GXjd8X9AhEn68FN9eNanFtWNzvgw1hqd6HkPRVQalqf7Q==
116116

117+
"@vueuse/core@^5.1.3":
118+
version "5.1.3"
119+
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-5.1.3.tgz#a9edda9202513423a27fbac896dd7bc918d1ac6c"
120+
integrity sha512-5CmF/epSo9L1Obz3A37UJOpDdno0BDw46zyXq0DHgvzEwL6gPb9GgJZcy4Hm5YSjQYIeQPo35uO8qsZyIjEZog==
121+
dependencies:
122+
"@vueuse/shared" "5.1.3"
123+
vue-demi "*"
124+
125+
126+
version "5.1.3"
127+
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-5.1.3.tgz#11faa3a1a2b4d3dc41eac7a825900a8894efe95e"
128+
integrity sha512-p8n/69QMtSsLN5rri9c3sN5QJJXWA7cm9chgo3DowTBRYLBni1I9kGY2nz299Tur6XEFuf+63E5TvMTJVJeHHw==
129+
dependencies:
130+
vue-demi "*"
131+
117132
anymatch@~3.1.2:
118133
version "3.1.2"
119134
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"
@@ -708,6 +723,11 @@ vite@^2.4.0:
708723
optionalDependencies:
709724
fsevents "~2.3.2"
710725

726+
vue-demi@*:
727+
version "0.10.1"
728+
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.10.1.tgz#229b81395510f02f4ee255344557a12cc0120930"
729+
integrity sha512-L6Oi+BvmMv6YXvqv5rJNCFHEKSVu7llpWWJczqmAQYOdmPPw5PNYoz1KKS//Fxhi+4QP64dsPjtmvnYGo1jemA==
730+
711731
vue-tsc@^0.0.24:
712732
version "0.0.24"
713733
resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.0.24.tgz#0cd90db679f53ea1694254b8663fdb3d624a0872"

0 commit comments

Comments
 (0)