@noction/vue-bezier 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +1 -2
  2. package/dist/vue-bezier.js +422 -0
  3. package/dist/web-types.json +551 -1
  4. package/package.json +28 -19
  5. package/src/components/Collapse/CollapseTransition.vue +19 -14
  6. package/src/components/Fade/FadeTransition.vue +19 -19
  7. package/src/components/Scale/ScaleTransition.vue +18 -33
  8. package/src/components/Slide/SlideXLeftTransition.vue +18 -29
  9. package/src/components/Slide/SlideXRightTransition.vue +18 -31
  10. package/src/components/Slide/SlideYDownTransition.vue +18 -31
  11. package/src/components/Slide/SlideYUpTransition.vue +18 -31
  12. package/src/components/Zoom/ZoomCenterTransition.vue +18 -19
  13. package/src/components/Zoom/ZoomUpTransition.vue +19 -31
  14. package/src/components/Zoom/ZoomXTransition.vue +18 -29
  15. package/src/components/Zoom/ZoomYTransition.vue +17 -30
  16. package/src/{composable → composables}/buildComponentType.ts +2 -1
  17. package/src/composables/index.ts +4 -0
  18. package/src/composables/useHooks.ts +110 -0
  19. package/src/main.ts +48 -0
  20. package/src/types/index.ts +53 -0
  21. package/dist/Collapse/CollapseTransition.vue.d.ts +0 -14
  22. package/dist/Fade/FadeTransition.vue.d.ts +0 -13
  23. package/dist/Scale/ScaleTransition.vue.d.ts +0 -26
  24. package/dist/Slide/SlideXLeftTransition.vue.d.ts +0 -22
  25. package/dist/Slide/SlideXRightTransition.vue.d.ts +0 -22
  26. package/dist/Slide/SlideYDownTransition.vue.d.ts +0 -22
  27. package/dist/Slide/SlideYUpTransition.vue.d.ts +0 -22
  28. package/dist/Zoom/ZoomCenterTransition.vue.d.ts +0 -13
  29. package/dist/Zoom/ZoomUpTransition.vue.d.ts +0 -22
  30. package/dist/Zoom/ZoomXTransition.vue.d.ts +0 -22
  31. package/dist/Zoom/ZoomYTransition.vue.d.ts +0 -22
  32. package/dist/composable/buildComponentType.d.ts +0 -3
  33. package/dist/composable/buildEmits.d.ts +0 -2
  34. package/dist/composable/buildHooks.d.ts +0 -7
  35. package/dist/composable/buildProps.d.ts +0 -48
  36. package/dist/composable/buildTag.d.ts +0 -2
  37. package/dist/composable/index.d.ts +0 -6
  38. package/dist/index.d.ts +0 -17
  39. package/dist/vue-bezier.mjs +0 -456
  40. package/dist/vue-bezier.umd.js +0 -1
  41. package/src/composable/buildEmits.ts +0 -7
  42. package/src/composable/buildHooks.ts +0 -92
  43. package/src/composable/buildProps.ts +0 -52
  44. package/src/composable/buildTag.ts +0 -1
  45. package/src/composable/index.ts +0 -7
  46. package/src/global-shim.d.ts +0 -1
  47. package/src/index.ts +0 -62
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  move-class="collapse-move"
7
7
  >
@@ -11,19 +11,24 @@
11
11
 
12
12
  <script setup lang="ts">
13
13
  import { BaseTransitionProps } from 'vue'
14
- import {
15
- buildComponentType,
16
- buildEmits,
17
- buildProps,
18
- buildTag
19
- } from '../../composable'
20
- import { leave, setAbsolutePosition, setStyles } from '../../composable/buildHooks'
21
-
22
- const props = defineProps(buildProps())
23
- const emit = defineEmits(buildEmits())
14
+ import { buildComponentType } from '../../composables'
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { getTimingValue, leave, setAbsolutePosition, setStyles } from '@/composables/useHooks'
17
+
18
+ const props = withDefaults(defineProps<ComponentProps>(), {
19
+ delay: 0,
20
+ duration: 300,
21
+ group: false,
22
+ origin: '',
23
+ styles: () => ({
24
+ animationFillMode: 'both',
25
+ animationTimingFunction: 'ease-out'
26
+ }),
27
+ tag: 'span'
28
+ })
29
+ const emit = defineEmits<ComponentEvents>()
24
30
 
25
31
  const componentType = buildComponentType(props)
26
- const tag = buildTag(props)
27
32
 
28
33
  const hooks: BaseTransitionProps = {
29
34
  onAfterEnter (el) {
@@ -44,7 +49,7 @@ const hooks: BaseTransitionProps = {
44
49
  emit('after-leave', el)
45
50
  },
46
51
  onBeforeEnter (el) {
47
- const enterDuration = props.duration?.enter ?? props.duration ?? 0
52
+ const enterDuration = getTimingValue(props.duration, 'enter')
48
53
 
49
54
  el.style.transition = transitionStyle(enterDuration)
50
55
 
@@ -91,7 +96,7 @@ const hooks: BaseTransitionProps = {
91
96
  el.style.overflow = 'hidden'
92
97
  },
93
98
  onLeave (el, done: () => void) {
94
- const leaveDuration = props.duration.leave ?? props.duration ?? 0
99
+ const leaveDuration = getTimingValue(props.duration, 'leave')
95
100
 
96
101
  if (el.scrollHeight !== 0) {
97
102
  // for safari: add class after set height, or it will jump to zero height suddenly, weired
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  enter-active-class="fade-in"
6
6
  move-class="fade-move"
7
7
  leave-active-class="fade-out"
@@ -11,27 +11,27 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export default {
16
- inheritAttrs: false
17
- }
18
- </script>
19
-
20
14
  <script setup lang="ts">
21
- import {
22
- buildComponentType,
23
- buildEmits,
24
- buildHooks,
25
- buildProps,
26
- buildTag
27
- } from '../../composable'
28
-
29
- const props = defineProps(buildProps())
30
- const emit = defineEmits(buildEmits())
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
17
+
18
+ defineOptions({ inheritAttrs: false })
19
+
20
+ const props = withDefaults(defineProps<ComponentProps>(), {
21
+ delay: 0,
22
+ duration: 300,
23
+ group: false,
24
+ origin: '',
25
+ styles: () => ({
26
+ animationFillMode: 'both',
27
+ animationTimingFunction: 'ease-out'
28
+ }),
29
+ tag: 'span'
30
+ })
31
+ const emit = defineEmits<ComponentEvents>()
31
32
 
32
33
  const componentType = buildComponentType(props)
33
- const tag = buildTag(props)
34
- const hooks = buildHooks(props, emit)
34
+ const hooks = useHooks(props, emit)
35
35
 
36
36
  </script>
37
37
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  enter-active-class="scale-in"
7
7
  move-class="scale-move"
@@ -11,43 +11,28 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export const customProps = {
16
- origin: {
17
- default: 'top left',
18
- type: String
19
- },
20
- styles: {
21
- default: () => {
22
- return {
23
- animationFillMode: 'both',
24
- animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
25
- }
26
- },
27
- type: Object
28
- }
29
- }
14
+ <script setup lang="ts">
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
30
17
 
31
- export default {
32
- inheritAttrs: false
33
- }
34
- </script>
18
+ defineOptions({ inheritAttrs: false })
35
19
 
36
- <script setup lang="ts">
37
- import {
38
- buildComponentType,
39
- buildEmits,
40
- buildHooks,
41
- buildProps,
42
- buildTag
43
- } from '../../composable'
20
+ const props = withDefaults(defineProps<ComponentProps>(), {
21
+ delay: 0,
22
+ duration: 300,
23
+ group: false,
24
+ origin: 'top left',
25
+ styles: () => ({
26
+ animationFillMode: 'both',
27
+ animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
28
+ }),
29
+ tag: 'span'
30
+ })
44
31
 
45
- const props = defineProps(buildProps(customProps))
46
- const emit = defineEmits(buildEmits())
32
+ const emit = defineEmits<ComponentEvents>()
47
33
 
48
34
  const componentType = buildComponentType(props)
49
- const tag = buildTag(props)
50
- const hooks = buildHooks(props, emit)
35
+ const hooks = useHooks(props, emit)
51
36
 
52
37
  </script>
53
38
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  enter-active-class="slide-x-left-in"
7
7
  move-class="slide-move"
@@ -11,39 +11,28 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export const customProps = {
16
- styles: {
17
- default: () => {
18
- return {
19
- animationFillMode: 'both',
20
- animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
21
- }
22
- },
23
- type: Object
24
- }
25
- }
14
+ <script setup lang="ts">
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
26
17
 
27
- export default {
28
- inheritAttrs: false
29
- }
30
- </script>
18
+ defineOptions({ inheritAttrs: false })
31
19
 
32
- <script setup lang="ts">
33
- import {
34
- buildComponentType,
35
- buildEmits,
36
- buildHooks,
37
- buildProps,
38
- buildTag
39
- } from '../../composable'
20
+ const props = withDefaults(defineProps<ComponentProps>(), {
21
+ delay: 0,
22
+ duration: 300,
23
+ group: false,
24
+ origin: '',
25
+ styles: () => ({
26
+ animationFillMode: 'both',
27
+ animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
28
+ }),
29
+ tag: 'span'
30
+ })
40
31
 
41
- const props = defineProps(buildProps(customProps))
42
- const emit = defineEmits(buildEmits())
32
+ const emit = defineEmits<ComponentEvents>()
43
33
 
44
34
  const componentType = buildComponentType(props)
45
- const tag = buildTag(props)
46
- const hooks = buildHooks(props, emit)
35
+ const hooks = useHooks(props, emit)
47
36
 
48
37
  </script>
49
38
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  enter-active-class="slide-x-right-in"
7
7
  move-class="slide-move"
@@ -11,39 +11,26 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export const customProps = {
16
- styles: {
17
- default: () => {
18
- return {
19
- animationFillMode: 'both',
20
- animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
21
- }
22
- },
23
- type: Object
24
- }
25
- }
26
-
27
- export default {
28
- inheritAttrs: false
29
- }
30
- </script>
31
-
32
14
  <script setup lang="ts">
33
- import {
34
- buildComponentType,
35
- buildEmits,
36
- buildHooks,
37
- buildProps,
38
- buildTag
39
- } from '../../composable'
40
-
41
- const props = defineProps(buildProps(customProps))
42
- const emit = defineEmits(buildEmits())
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
17
+
18
+ defineOptions({ inheritAttrs: false })
19
+ const props = withDefaults(defineProps<ComponentProps>(), {
20
+ delay: 0,
21
+ duration: 300,
22
+ group: false,
23
+ origin: '',
24
+ styles: () => ({
25
+ animationFillMode: 'both',
26
+ animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
27
+ }),
28
+ tag: 'span'
29
+ })
30
+ const emit = defineEmits<ComponentEvents>()
43
31
 
44
32
  const componentType = buildComponentType(props)
45
- const tag = buildTag(props)
46
- const hooks = buildHooks(props, emit)
33
+ const hooks = useHooks(props, emit)
47
34
 
48
35
  </script>
49
36
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  enter-active-class="slide-y-down-in"
7
7
  leave-active-class="slide-y-down-out"
@@ -10,39 +10,26 @@
10
10
  </component>
11
11
  </template>
12
12
 
13
- <script lang="ts">
14
- export const customProps = {
15
- styles: {
16
- default: () => {
17
- return {
18
- animationFillMode: 'both',
19
- animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
20
- }
21
- },
22
- type: Object
23
- }
24
- }
25
-
26
- export default {
27
- inheritAttrs: false
28
- }
29
- </script>
30
-
31
13
  <script setup lang="ts">
32
- import {
33
- buildComponentType,
34
- buildEmits,
35
- buildHooks,
36
- buildProps,
37
- buildTag
38
- } from '../../composable'
39
-
40
- const props = defineProps(buildProps(customProps))
41
- const emit = defineEmits(buildEmits())
14
+ import type { ComponentEvents, ComponentProps } from '@/types'
15
+ import { buildComponentType, useHooks } from '@/composables'
16
+
17
+ defineOptions({ inheritAttrs: false })
18
+ const props = withDefaults(defineProps<ComponentProps>(), {
19
+ delay: 0,
20
+ duration: 300,
21
+ group: false,
22
+ origin: '',
23
+ styles: () => ({
24
+ animationFillMode: 'both',
25
+ animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
26
+ }),
27
+ tag: 'span'
28
+ })
29
+ const emit = defineEmits<ComponentEvents>()
42
30
 
43
31
  const componentType = buildComponentType(props)
44
- const tag = buildTag(props)
45
- const hooks = buildHooks(props, emit)
32
+ const hooks = useHooks(props, emit)
46
33
 
47
34
  </script>
48
35
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  type="animation"
6
6
  v-bind="{ ...$attrs, ...hooks }"
7
7
  enter-active-class="slide-y-in"
@@ -12,39 +12,26 @@
12
12
  </component>
13
13
  </template>
14
14
 
15
- <script lang="ts">
16
- export const customProps = {
17
- styles: {
18
- default: () => {
19
- return {
20
- animationFillMode: 'both',
21
- animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
22
- }
23
- },
24
- type: Object
25
- }
26
- }
27
-
28
- export default {
29
- inheritAttrs: false
30
- }
31
- </script>
32
-
33
15
  <script setup lang="ts">
34
- import {
35
- buildComponentType,
36
- buildEmits,
37
- buildHooks,
38
- buildProps,
39
- buildTag
40
- } from '../../composable'
41
-
42
- const props = defineProps(buildProps(customProps))
43
- const emit = defineEmits(buildEmits())
16
+ import type { ComponentEvents, ComponentProps } from '@/types'
17
+ import { buildComponentType, useHooks } from '@/composables'
18
+
19
+ defineOptions({ inheritAttrs: false })
20
+ const props = withDefaults(defineProps<ComponentProps>(), {
21
+ delay: 0,
22
+ duration: 300,
23
+ group: false,
24
+ origin: '',
25
+ styles: () => ({
26
+ animationFillMode: 'both',
27
+ animationTimingFunction: 'cubic-bezier(.25,.8,.50,1)'
28
+ }),
29
+ tag: 'span'
30
+ })
31
+ const emit = defineEmits<ComponentEvents>()
44
32
 
45
33
  const componentType = buildComponentType(props)
46
- const tag = buildTag(props)
47
- const hooks = buildHooks(props, emit)
34
+ const hooks = useHooks(props, emit)
48
35
 
49
36
  </script>
50
37
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  enter-active-class="zoom-in"
7
7
  move-class="zoom-move"
@@ -11,27 +11,26 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export default {
16
- inheritAttrs: false
17
- }
18
- </script>
19
-
20
14
  <script setup lang="ts">
21
- import {
22
- buildComponentType,
23
- buildEmits,
24
- buildHooks,
25
- buildProps,
26
- buildTag
27
- } from '../../composable'
28
-
29
- const props = defineProps(buildProps())
30
- const emit = defineEmits(buildEmits())
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
17
+
18
+ defineOptions({ inheritAttrs: false })
19
+ const props = withDefaults(defineProps<ComponentProps>(), {
20
+ delay: 0,
21
+ duration: 300,
22
+ group: false,
23
+ origin: '',
24
+ styles: () => ({
25
+ animationFillMode: 'both',
26
+ animationTimingFunction: 'ease-out'
27
+ }),
28
+ tag: 'span'
29
+ })
30
+ const emit = defineEmits<ComponentEvents>()
31
31
 
32
32
  const componentType = buildComponentType(props)
33
- const tag = buildTag(props)
34
- const hooks = buildHooks(props, emit)
33
+ const hooks = useHooks(props, emit)
35
34
 
36
35
  </script>
37
36
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  v-bind="{ ...$attrs, ...hooks }"
6
6
  enter-active-class="zoom-in-up"
7
7
  move-class="zoom-move"
@@ -11,39 +11,27 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export const customProps = {
16
- styles: {
17
- default: () => {
18
- return {
19
- animationFillMode: 'both',
20
- animationTimingFunction: 'ease-out'
21
- }
22
- },
23
- type: Object
24
- }
25
- }
26
-
27
- export default {
28
- inheritAttrs: false
29
- }
30
- </script>
31
-
32
14
  <script setup lang="ts">
33
- import {
34
- buildComponentType,
35
- buildEmits,
36
- buildHooks,
37
- buildProps,
38
- buildTag
39
- } from '../../composable'
40
-
41
- const props = defineProps(buildProps(customProps))
42
- const emit = defineEmits(buildEmits())
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
17
+
18
+ defineOptions({ inheritAttrs: false })
19
+
20
+ const props = withDefaults(defineProps<ComponentProps>(), {
21
+ delay: 0,
22
+ duration: 300,
23
+ group: false,
24
+ origin: '',
25
+ styles: () => ({
26
+ animationFillMode: 'both',
27
+ animationTimingFunction: 'ease-out'
28
+ }),
29
+ tag: 'span'
30
+ })
31
+ const emit = defineEmits<ComponentEvents>()
43
32
 
44
33
  const componentType = buildComponentType(props)
45
- const tag = buildTag(props)
46
- const hooks = buildHooks(props, emit)
34
+ const hooks = useHooks(props, emit)
47
35
 
48
36
  </script>
49
37
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <component
3
3
  :is="componentType"
4
- :tag="tag"
4
+ :tag="props.tag"
5
5
  enter-active-class="zoom-in-x"
6
6
  move-class="zoom-move"
7
7
  leave-active-class="zoom-out-x"
@@ -11,39 +11,28 @@
11
11
  </component>
12
12
  </template>
13
13
 
14
- <script lang="ts">
15
- export const customProps = {
16
- styles: {
17
- default: () => {
18
- return {
19
- animationFillMode: 'both',
20
- animationTimingFunction: 'cubic-bezier(.55,0,.1,1)'
21
- }
22
- },
23
- type: Object
24
- }
25
- }
14
+ <script setup lang="ts">
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
26
17
 
27
- export default {
28
- inheritAttrs: false
29
- }
30
- </script>
18
+ defineOptions({ inheritAttrs: false })
31
19
 
32
- <script setup lang="ts">
33
- import {
34
- buildComponentType,
35
- buildEmits,
36
- buildHooks,
37
- buildProps,
38
- buildTag
39
- } from '../../composable'
20
+ const props = withDefaults(defineProps<ComponentProps>(), {
21
+ delay: 0,
22
+ duration: 300,
23
+ group: false,
24
+ origin: '',
25
+ styles: () => ({
26
+ animationFillMode: 'both',
27
+ animationTimingFunction: 'cubic-bezier(.55,0,.1,1)'
28
+ }),
29
+ tag: 'span'
30
+ })
40
31
 
41
- const props = defineProps(buildProps(customProps))
42
- const emit = defineEmits(buildEmits())
32
+ const emit = defineEmits<ComponentEvents>()
43
33
 
44
34
  const componentType = buildComponentType(props)
45
- const tag = buildTag(props)
46
- const hooks = buildHooks(props, emit)
35
+ const hooks = useHooks(props, emit)
47
36
 
48
37
  </script>
49
38