@noction/vue-bezier 1.0.5 → 1.0.7

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 +2 -3
  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
  enter-active-class="zoom-in-y"
6
6
  move-class="zoom-move"
7
7
  leave-active-class="zoom-out-y"
@@ -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(.55,0,.1,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'
15
+ import type { ComponentEvents, ComponentProps } from '@/types'
16
+ import { buildComponentType, useHooks } from '@/composables'
40
17
 
41
- const props = defineProps(buildProps(customProps))
42
- const emit = defineEmits(buildEmits())
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(.55,0,.1,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,4 +1,5 @@
1
+ import { ComponentProps } from '@/types'
1
2
  import { Component, Transition, TransitionGroup } from 'vue'
2
3
 
3
- export default (props): Component =>
4
+ export default (props: ComponentProps): Component =>
4
5
  props.group ? TransitionGroup : Transition
@@ -0,0 +1,4 @@
1
+ import buildComponentType from './buildComponentType'
2
+ import useHooks from './useHooks'
3
+
4
+ export { buildComponentType, useHooks }
@@ -0,0 +1,110 @@
1
+ import type { BaseTransitionProps, RendererElement } from 'vue'
2
+ import type { ComponentProps, NumberOrTimings } from '@/types'
3
+
4
+ function getTimingValue (timing: NumberOrTimings | undefined, key: 'enter' | 'leave'): number {
5
+ if (typeof timing === 'number') {
6
+ return timing
7
+ }
8
+
9
+ if (typeof timing === 'object' && timing !== null) {
10
+ return timing[key] ?? 0
11
+ }
12
+
13
+ return 0
14
+ }
15
+
16
+ function beforeEnter (props: ComponentProps, el: RendererElement) {
17
+ const enterDuration = getTimingValue(props.duration, 'enter')
18
+ const enterDelay = getTimingValue(props.delay, 'enter')
19
+
20
+ el.style.animationDuration = `${enterDuration}ms`
21
+ el.style.animationDelay = `${enterDelay}ms`
22
+
23
+ setStyles(props, el)
24
+ }
25
+
26
+ function beforeLeave (props: ComponentProps, el: RendererElement) {
27
+ const leaveDuration = getTimingValue(props.duration, 'leave')
28
+ const leaveDelay = getTimingValue(props.delay, 'leave')
29
+
30
+ el.style.animationDuration = `${leaveDuration}ms`
31
+ el.style.animationDelay = `${leaveDelay}ms`
32
+
33
+ setStyles(props, el)
34
+ }
35
+
36
+ function leave (props: ComponentProps, el: RendererElement, done: () => void) {
37
+ setAbsolutePosition(props, el)
38
+
39
+ const leaveDuration = getTimingValue(props.duration, 'leave')
40
+ const leaveDelay = getTimingValue(props.delay, 'leave')
41
+
42
+ setTimeout(done, leaveDuration + leaveDelay)
43
+ }
44
+
45
+ function cleanUpStyles (props: ComponentProps, el: RendererElement) {
46
+ if (props.styles) {
47
+ Object
48
+ .entries(props.styles)
49
+ .forEach(([key]) => {
50
+ if (key in el.style) {
51
+ el.style[key] = ''
52
+ }
53
+ })
54
+ }
55
+
56
+ el.style.animationDuration = ''
57
+ el.style.animationDelay = ''
58
+ }
59
+
60
+ function setStyles (props: ComponentProps, el: RendererElement) {
61
+ setTransformOrigin(props, el)
62
+
63
+ if (props.styles) {
64
+ Object
65
+ .entries(props.styles)
66
+ .forEach(([key, value]) => {
67
+ if (key in el.style) {
68
+ el.style[key] = value
69
+ }
70
+ })
71
+ }
72
+ }
73
+
74
+ function setAbsolutePosition (props: ComponentProps, el: RendererElement) {
75
+ if (props.group) el.style.position = 'absolute'
76
+ }
77
+
78
+ function setTransformOrigin (props: ComponentProps, el: RendererElement) {
79
+ if (props.origin) el.style.transformOrigin = props.origin
80
+ }
81
+
82
+ export default (props: ComponentProps, emit: any) => ({
83
+ onAfterEnter: (el: RendererElement) => {
84
+ cleanUpStyles(props, el)
85
+ emit('after-enter', el)
86
+ },
87
+ onAfterLeave: (el: RendererElement) => {
88
+ cleanUpStyles(props, el)
89
+ emit('after-leave', el)
90
+ },
91
+ onBeforeEnter: (el: RendererElement) => {
92
+ beforeEnter(props, el)
93
+ emit('before-enter', el)
94
+ },
95
+ onBeforeLeave: (el: RendererElement) => {
96
+ beforeLeave(props, el)
97
+ emit('before-leave', el)
98
+ },
99
+ onLeave: (el: RendererElement, done: () => void) => {
100
+ leave(props, el, done)
101
+ emit('leave', el, done)
102
+ }
103
+ })
104
+
105
+ export {
106
+ getTimingValue,
107
+ leave,
108
+ setAbsolutePosition,
109
+ setStyles
110
+ }
package/src/main.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { App } from 'vue'
2
+
3
+ import CollapseTransition from './components/Collapse/CollapseTransition.vue'
4
+
5
+ import FadeTransition from './components/Fade/FadeTransition.vue'
6
+
7
+ import ScaleTransition from './components/Scale/ScaleTransition.vue'
8
+
9
+ import SlideXLeftTransition from './components/Slide/SlideXLeftTransition.vue'
10
+ import SlideXRightTransition from './components/Slide/SlideXRightTransition.vue'
11
+ import SlideYDownTransition from './components/Slide/SlideYDownTransition.vue'
12
+ import SlideYUpTransition from './components/Slide/SlideYUpTransition.vue'
13
+
14
+ import ZoomCenterTransition from './components/Zoom/ZoomCenterTransition.vue'
15
+ import ZoomUpTransition from './components/Zoom/ZoomUpTransition.vue'
16
+ import ZoomXTransition from './components/Zoom/ZoomXTransition.vue'
17
+ import ZoomYTransition from './components/Zoom/ZoomYTransition.vue'
18
+
19
+ export const components = {
20
+ CollapseTransition,
21
+ FadeTransition,
22
+ ScaleTransition,
23
+ SlideXLeftTransition,
24
+ SlideXRightTransition,
25
+ SlideYDownTransition,
26
+ SlideYUpTransition,
27
+ ZoomCenterTransition,
28
+ ZoomUpTransition,
29
+ ZoomXTransition,
30
+ ZoomYTransition
31
+ }
32
+
33
+ export function install (app: App) {
34
+ // @ts-expect-error it's a custom flag
35
+ if (app.$_vueBezierInstalled) return
36
+ // @ts-expect-error it's a custom flag
37
+ app.$_vueBezierInstalled = true
38
+
39
+ Object
40
+ .entries(components)
41
+ .forEach(([key, component]) =>
42
+ app.component(key, component)
43
+ )
44
+ }
45
+
46
+ export default {
47
+ install
48
+ }
@@ -0,0 +1,53 @@
1
+ import { RendererElement } from 'vue'
2
+
3
+ export type ComponentEvents = {
4
+ 'after-enter': [el: RendererElement],
5
+ 'after-leave': [el: RendererElement],
6
+ 'before-enter': [el: RendererElement],
7
+ 'before-leave': [el: RendererElement],
8
+ 'leave': [el: RendererElement, done: () => void]
9
+ }
10
+
11
+ export type ComponentProps = {
12
+ /**
13
+ * Transition delay. Number for specifying the same delay for enter/leave transitions
14
+ * Object style {enter: 300, leave: 300} for specifying explicit durations for enter/leave
15
+ */
16
+ delay?: NumberOrTimings;
17
+
18
+ /**
19
+ * Transition duration. Number for specifying the same duration for enter/leave transitions
20
+ * Object style {enter: 300, leave: 300} for specifying explicit durations for enter/leave
21
+ */
22
+ duration?: NumberOrTimings;
23
+
24
+ /**
25
+ * Whether the component should be a `transition-group` component.
26
+ */
27
+ group?: boolean;
28
+
29
+ /**
30
+ * Transform origin property https://tympanus.net/codrops/css_reference/transform-origin/.
31
+ * Can be specified with styles as well, but it's shorter with this prop
32
+ */
33
+ origin?: string;
34
+
35
+ /**
36
+ * Element styles that are applied during transition. These styles are applied on @beforeEnter and @beforeLeave hooks
37
+ */
38
+ styles?: Styles;
39
+
40
+ /**
41
+ * Transition tag, in case the component is a `transition-group`
42
+ */
43
+ tag?: string;
44
+ }
45
+
46
+ type TransitionTimings = {
47
+ enter: number;
48
+ leave: number;
49
+ }
50
+
51
+ type Styles = Partial<CSSStyleDeclaration>;
52
+
53
+ export type NumberOrTimings = number | TransitionTimings;
@@ -1,14 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {
2
- props: {
3
- [x: string]: any;
4
- };
5
- emit: any;
6
- componentType: any;
7
- tag: any;
8
- hooks: import("vue").BaseTransitionProps<import("vue").RendererElement>;
9
- enterDuration: any;
10
- leaveDuration: any;
11
- transitionStyle: (duration: number) => string;
12
- durationInSeconds: any;
13
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
14
- export default _default;
@@ -1,13 +0,0 @@
1
- declare const _default: {
2
- setup(): {
3
- props: {
4
- [x: string]: any;
5
- };
6
- emit: any;
7
- componentType: any;
8
- tag: any;
9
- hooks: any;
10
- };
11
- inheritAttrs: boolean;
12
- };
13
- export default _default;
@@ -1,26 +0,0 @@
1
- export declare const customProps: {
2
- origin: {
3
- default: string;
4
- type: StringConstructor;
5
- };
6
- styles: {
7
- default: () => {
8
- animationFillMode: string;
9
- animationTimingFunction: string;
10
- };
11
- type: ObjectConstructor;
12
- };
13
- };
14
- declare const _default: {
15
- setup(): {
16
- props: {
17
- [x: string]: any;
18
- };
19
- emit: any;
20
- componentType: any;
21
- tag: any;
22
- hooks: any;
23
- };
24
- inheritAttrs: boolean;
25
- };
26
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,13 +0,0 @@
1
- declare const _default: {
2
- setup(): {
3
- props: {
4
- [x: string]: any;
5
- };
6
- emit: any;
7
- componentType: any;
8
- tag: any;
9
- hooks: any;
10
- };
11
- inheritAttrs: boolean;
12
- };
13
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,22 +0,0 @@
1
- export declare const customProps: {
2
- styles: {
3
- default: () => {
4
- animationFillMode: string;
5
- animationTimingFunction: string;
6
- };
7
- type: ObjectConstructor;
8
- };
9
- };
10
- declare const _default: {
11
- setup(): {
12
- props: {
13
- [x: string]: any;
14
- };
15
- emit: any;
16
- componentType: any;
17
- tag: any;
18
- hooks: any;
19
- };
20
- inheritAttrs: boolean;
21
- };
22
- export default _default;
@@ -1,3 +0,0 @@
1
- import { Component } from 'vue';
2
- declare const _default: (props: any) => Component;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: () => string[];
2
- export default _default;
@@ -1,7 +0,0 @@
1
- import { BaseTransitionProps, RendererElement } from 'vue';
2
- declare const leave: (props: any, el: RendererElement, done: () => void) => void;
3
- declare const setStyles: (props: any, el: RendererElement) => void;
4
- declare const setAbsolutePosition: (props: any, el: RendererElement) => void;
5
- declare const _default: (props: any, emit: any) => BaseTransitionProps;
6
- export default _default;
7
- export { leave, setAbsolutePosition, setStyles };
@@ -1,48 +0,0 @@
1
- declare const _default: (customProps?: Record<string, unknown>) => {
2
- /**
3
- * Transition delay. Number for specifying the same delay for enter/leave transitions
4
- * Object style {enter: 300, leave: 300} for specifying explicit durations for enter/leave
5
- */
6
- delay: {
7
- default: number;
8
- type: (ObjectConstructor | NumberConstructor)[];
9
- };
10
- /**
11
- * Transition duration. Number for specifying the same duration for enter/leave transitions
12
- * Object style {enter: 300, leave: 300} for specifying explicit durations for enter/leave
13
- */
14
- duration: {
15
- default: number;
16
- type: (ObjectConstructor | NumberConstructor)[];
17
- };
18
- /**
19
- * Whether the component should be a `transition-group` component.
20
- */
21
- group: BooleanConstructor;
22
- /**
23
- * Transform origin property https://tympanus.net/codrops/css_reference/transform-origin/.
24
- * Can be specified with styles as well but it's shorter with this prop
25
- */
26
- origin: {
27
- default: string;
28
- type: StringConstructor;
29
- };
30
- /**
31
- * Element styles that are applied during transition. These styles are applied on @beforeEnter and @beforeLeave hooks
32
- */
33
- styles: {
34
- default: () => {
35
- animationFillMode: string;
36
- animationTimingFunction: string;
37
- };
38
- type: ObjectConstructor;
39
- };
40
- /**
41
- * Transition tag, in case the component is a `transition-group`
42
- */
43
- tag: {
44
- default: string;
45
- type: StringConstructor;
46
- };
47
- };
48
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: (props: any) => any;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- import buildComponentType from './buildComponentType';
2
- import buildEmits from './buildEmits';
3
- import buildHooks from './buildHooks';
4
- import buildProps from './buildProps';
5
- import buildTag from './buildTag';
6
- export { buildComponentType, buildEmits, buildHooks, buildProps, buildTag };
package/dist/index.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import PrivateCollapseTransition from './components/Collapse/CollapseTransition.vue';
2
- import PrivateFadeTransition from './components/Fade/FadeTransition.vue';
3
- import PrivateScaleTransition from './components/Scale/ScaleTransition.vue';
4
- import PrivateSlideXLeftTransition from './components/Slide/SlideXLeftTransition.vue';
5
- import PrivateSlideXRightTransition from './components/Slide/SlideXRightTransition.vue';
6
- import PrivateSlideYDownTransition from './components/Slide/SlideYDownTransition.vue';
7
- import PrivateSlideYUpTransition from './components/Slide/SlideYUpTransition.vue';
8
- import PrivateZoomCenterTransition from './components/Zoom/ZoomCenterTransition.vue';
9
- import PrivateZoomUpTransition from './components/Zoom/ZoomUpTransition.vue';
10
- import PrivateZoomXTransition from './components/Zoom/ZoomXTransition.vue';
11
- import PrivateZoomYTransition from './components/Zoom/ZoomYTransition.vue';
12
- export { PrivateCollapseTransition as CollapseTransition, PrivateFadeTransition as FadeTransition, PrivateScaleTransition as ScaleTransition, PrivateSlideXLeftTransition as SlideXLeftTransition, PrivateSlideXRightTransition as SlideXRightTransition, PrivateSlideYDownTransition as SlideYDownTransition, PrivateSlideYUpTransition as SlideYUpTransition, PrivateZoomCenterTransition as ZoomCenterTransition, PrivateZoomUpTransition as ZoomUpTransition, PrivateZoomXTransition as ZoomXTransition, PrivateZoomYTransition as ZoomYTransition };
13
- export declare function install(app: any): void;
14
- declare const _default: {
15
- install: typeof install;
16
- };
17
- export default _default;