@plexui/vue 0.39.3 → 0.39.5
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.
- package/dist/es/components/Dialog/Dialog.js +2 -1
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +8 -2
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Transition/TransitionGroup.js +11 -2
- package/dist/es/components/Transition/TransitionGroup.js.map +1 -1
- package/dist/es/components/Transition/shared.js +6 -0
- package/dist/es/components/Transition/shared.js.map +1 -1
- package/dist/types/components/Transition/TransitionGroup.d.ts +14 -2
- package/dist/types/components/Transition/shared.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import { defineComponent, h, onBeforeUnmount, onErrorCaptured, onMounted, ref, watch, } from "vue";
|
|
3
|
+
import { prefersReducedMotion } from "../../lib/helpers.js";
|
|
3
4
|
import getDisableAnimations from "./getDisableAnimations.js";
|
|
4
5
|
import { flattenChildren, isPlaceholder, useChildList } from "./childList.js";
|
|
5
6
|
import { useTransitionChild } from "./useTransitionChild.js";
|
|
@@ -107,6 +108,11 @@ export const TransitionGroup = defineComponent({
|
|
|
107
108
|
transitionId: String,
|
|
108
109
|
/** Determines the amount of time that the enter state is applied during mounting */
|
|
109
110
|
enterDuration: { type: Number, default: 0 },
|
|
111
|
+
/**
|
|
112
|
+
* The enter time with reduced motion, in place of `enterDuration`: for an overlay
|
|
113
|
+
* whose styles fade it in over a time of its own then (a Dialog, a Menu).
|
|
114
|
+
*/
|
|
115
|
+
reducedMotionEnterDuration: Number,
|
|
110
116
|
/** Determines the amount of time that the exit state is applied before unmounting */
|
|
111
117
|
exitDuration: { type: Number, default: 0 },
|
|
112
118
|
/** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */
|
|
@@ -117,7 +123,8 @@ export const TransitionGroup = defineComponent({
|
|
|
117
123
|
disableAnimations: { type: Boolean, default: () => getDisableAnimations() },
|
|
118
124
|
/**
|
|
119
125
|
* For overlays: an exiting child is `inert`, out of the tab order and of hit
|
|
120
|
-
* testing, and with reduced motion it leaves without waiting for `exitDuration`.
|
|
126
|
+
* testing, and with reduced motion it leaves without waiting for `exitDuration`. It
|
|
127
|
+
* still waits out `enterDuration`: with reduced motion an overlay fades in over it.
|
|
121
128
|
*/
|
|
122
129
|
overlay: Boolean,
|
|
123
130
|
/** Determines how new children are added to the children array */
|
|
@@ -163,7 +170,9 @@ export const TransitionGroup = defineComponent({
|
|
|
163
170
|
transitionId: props.transitionId,
|
|
164
171
|
styleValue: style,
|
|
165
172
|
shouldRender: child.shouldRender,
|
|
166
|
-
enterDuration: props.
|
|
173
|
+
enterDuration: props.reducedMotionEnterDuration !== undefined && prefersReducedMotion()
|
|
174
|
+
? props.reducedMotionEnterDuration
|
|
175
|
+
: props.enterDuration,
|
|
167
176
|
exitDuration: props.exitDuration,
|
|
168
177
|
overlay: props.overlay,
|
|
169
178
|
removeChild: () => children.remove(child.key),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,eAAe,EACf,CAAC,EACD,eAAe,EACf,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,GAIN,MAAM,KAAK,CAAA;AACZ,OAAO,oBAAoB,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAO/E,MAAM,YAAY,GAAG,QAAkD,CAAA;AAEvE,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,E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AK,CAAC,CAC3C,CACF,CAAA;YACH,CAAC;YAED,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAClC,CAAC,CACC,oBAAoB,EACpB;gBACE,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;gBACpD,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,SAAS;gBACT,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,UAAU,EAAE,KAAK;gBACjB,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC7C,SAAS;aACV,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CACjC,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onErrorCaptured,\n onMounted,\n ref,\n watch,\n type PropType,\n type StyleValue,\n type VNode,\n} from \"vue\"\nimport getDisableAnimations from \"./getDisableAnimations.js\"\nimport { flattenChildren, isPlaceholder, useChildList } from \"./childList.js\"\nimport type { InsertMethod, TransitionGroupChildCallback, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { useTransitionChild } from \"./useTransitionChild.js\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\n\n// Port of packages/ui/src/components/Transition/TransitionGroup.tsx. Same\n// wrappers, data attributes and timings, so the shared CSS animates both.\n\ntype Tag = \"div\" | \"span\"\n\nconst callbackProp = Function as PropType<TransitionGroupChildCallback>\n\nconst TransitionGroupChildInner = defineComponent({\n name: \"TransitionGroupChildInner\",\n props: {\n as: { type: String as PropType<Tag>, required: true },\n className: String,\n transitionId: String,\n styleValue: [String, Object, Array] as PropType<StyleValue>,\n preventMountTransition: Boolean,\n shouldRender: { type: Boolean, required: true },\n enterDuration: { type: Number, required: true },\n exitDuration: { type: Number, required: true },\n overlay: Boolean,\n removeChild: { type: Function as PropType<() => void>, required: true },\n callbacks: Object as PropType<TransitionGroupChildCallbacks>,\n },\n setup(props, { slots }) {\n const element = ref<HTMLElement | null>(null)\n const state = useTransitionChild(props, () => element.value)\n\n // An exiting child stays mounted with live slots, where React renders its\n // last element: state cleared along with the close must not throw here\n onErrorCaptured(() => (props.shouldRender ? undefined : false))\n\n return () =>\n h(\n props.as,\n {\n \"ref\": element,\n \"class\": clsx(props.className, s.TransitionGroupChild),\n \"data-transition-id\": props.transitionId,\n \"style\": props.styleValue,\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n \"inert\": props.overlay && state.exit ? \"\" : undefined,\n },\n slots.default?.(),\n )\n },\n})\n\n/**\n * Delays mounting a child by `enterMountDelay` ms, except on the initial\n * (prevented) mount. Like usehooks-ts' useTimeout, a changed delay restarts\n * the pending timer; removing the delay while pending leaves it unmounted.\n */\nexport const useMountDelay = (getProps: () => { preventMountTransition?: boolean; enterMountDelay?: number }) => {\n const delay = () => {\n const { preventMountTransition, enterMountDelay } = getProps()\n return !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n }\n const mounted = ref(delay() == null)\n let timeout: number | undefined\n\n onMounted(() => {\n watch(\n delay,\n (mountDelay) => {\n clearTimeout(timeout)\n if (!mounted.value && mountDelay != null) {\n timeout = window.setTimeout(() => (mounted.value = true), mountDelay)\n }\n },\n { immediate: true },\n )\n })\n onBeforeUnmount(() => clearTimeout(timeout))\n return mounted\n}\n\nconst TransitionGroupChild = defineComponent({\n name: \"TransitionGroupChild\",\n inheritAttrs: false,\n props: {\n preventMountTransition: Boolean,\n enterMountDelay: Number,\n },\n setup(props, { attrs, slots }) {\n const mounted = useMountDelay(() => props)\n return () =>\n mounted.value\n ? h(TransitionGroupChildInner, { ...attrs, preventMountTransition: props.preventMountTransition } as never, slots)\n : null\n },\n})\n\n// With `disableAnimations`, React wraps the children through `Children.map`,\n// which keys each wrapper by its child's key and a `false` child's wrapper by\n// its position. A reordered child moves with its wrapper (keeping its DOM and\n// state), and a `false` child turning into an element (or back) gets a new\n// wrapper. Placeholders take a symbol per position, which no child key can\n// equal.\nconst placeholderKeys: symbol[] = []\nconst wrapperKey = (vnode: VNode, index: number): PropertyKey => {\n if (!isPlaceholder(vnode)) return vnode.key!\n return (placeholderKeys[index] ??= Symbol(`placeholder-${index}`))\n}\n\n/**\n * Wraps each keyed child in a `<span>` (or `<div>`) that carries\n * `data-entering` / `data-exiting` state while it mounts and unmounts.\n *\n * A `false` slot child (a comment vnode) mirrors React's `Children.map`\n * over `false`: with `disableAnimations` it still renders an empty wrapper.\n * Leave the slot out entirely to render nothing.\n */\nexport const TransitionGroup = defineComponent({\n name: \"TransitionGroup\",\n inheritAttrs: false,\n props: {\n /** Determines the tag used by wrapping elements */\n as: { type: String as PropType<Tag>, default: \"span\" },\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId: String,\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration: { type: Number, default: 0 },\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration: { type: Number, default: 0 },\n /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */\n preventInitialTransition: { type: Boolean, default: true },\n /** Delay in MS to wait before mounting a child. Unset for no delay (default). */\n enterMountDelay: Number,\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations: { type: Boolean, default: () => getDisableAnimations() },\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it leaves without waiting for `exitDuration`.\n */\n overlay: Boolean,\n /** Determines how new children are added to the children array */\n insertMethod: { type: String as PropType<InsertMethod>, default: \"append\" },\n /** Called when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: callbackProp,\n /** Called when an enter animation starts */\n onEnterActive: callbackProp,\n /** Called when an enter animation completes */\n onEnterComplete: callbackProp,\n /** Called when an exit animation is staged */\n onExit: callbackProp,\n /** Called when an exit animation starts */\n onExitActive: callbackProp,\n /** Called when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: callbackProp,\n },\n setup(props, { slots, attrs }) {\n const children = useChildList(\"TransitionGroup\")\n // Read at call time, so callers can swap handlers between renders\n const callbacks: TransitionGroupChildCallbacks = {\n onEnter: (el) => props.onEnter?.(el),\n onEnterActive: (el) => props.onEnterActive?.(el),\n onEnterComplete: (el) => props.onEnterComplete?.(el),\n onExit: (el) => props.onExit?.(el),\n onExitActive: (el) => props.onExitActive?.(el),\n onExitComplete: (el) => props.onExitComplete?.(el),\n }\n\n return () => {\n const slotChildren: VNode[] = flattenChildren(slots.default?.() ?? [])\n const className = attrs.class as string | undefined\n const style = attrs.style as StyleValue | undefined\n const renderChildren = children.next(\n children.keyedChildren(slotChildren),\n props.insertMethod,\n props.preventInitialTransition,\n )\n\n if (props.disableAnimations) {\n return slotChildren.map((vnode, index) =>\n h(\n props.as,\n { \"key\": wrapperKey(vnode, index), \"class\": className, style, \"data-transition-id\": props.transitionId },\n isPlaceholder(vnode) ? undefined : [vnode],\n ),\n )\n }\n\n return renderChildren.map((child) =>\n h(\n TransitionGroupChild,\n {\n key: child.key,\n preventMountTransition: child.preventMountTransition,\n enterMountDelay: props.enterMountDelay,\n as: props.as,\n className,\n transitionId: props.transitionId,\n styleValue: style,\n shouldRender: child.shouldRender,\n enterDuration: props.enterDuration,\n exitDuration: props.exitDuration,\n overlay: props.overlay,\n removeChild: () => children.remove(child.key),\n callbacks,\n },\n { default: () => [child.vnode] },\n ),\n )\n }\n },\n})\n\nexport type TransitionGroupProps = InstanceType<typeof TransitionGroup>[\"$props\"]\n"]}
|
|
1
|
+
{"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,eAAe,EACf,CAAC,EACD,eAAe,EACf,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,GAIN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,oBAAoB,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAO/E,MAAM,YAAY,GAAG,QAAkD,CAAA;AAEvE,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE;QACL,EAAE,EAAE,EAAE,IAAI,EAAE,MAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACrD,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAyB;QAC3D,sBAAsB,EAAE,OAAO;QAC/B,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC/C,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC/C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC9C,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAgC,EAAE,Q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B;oBAClC,CAAC,CAAC,KAAK,CAAC,aAAa;gBACzB,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC7C,SAAS;aACV,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CACjC,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onErrorCaptured,\n onMounted,\n ref,\n watch,\n type PropType,\n type StyleValue,\n type VNode,\n} from \"vue\"\nimport { prefersReducedMotion } from \"../../lib/helpers.js\"\nimport getDisableAnimations from \"./getDisableAnimations.js\"\nimport { flattenChildren, isPlaceholder, useChildList } from \"./childList.js\"\nimport type { InsertMethod, TransitionGroupChildCallback, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { useTransitionChild } from \"./useTransitionChild.js\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\n\n// Port of packages/ui/src/components/Transition/TransitionGroup.tsx. Same\n// wrappers, data attributes and timings, so the shared CSS animates both.\n\ntype Tag = \"div\" | \"span\"\n\nconst callbackProp = Function as PropType<TransitionGroupChildCallback>\n\nconst TransitionGroupChildInner = defineComponent({\n name: \"TransitionGroupChildInner\",\n props: {\n as: { type: String as PropType<Tag>, required: true },\n className: String,\n transitionId: String,\n styleValue: [String, Object, Array] as PropType<StyleValue>,\n preventMountTransition: Boolean,\n shouldRender: { type: Boolean, required: true },\n enterDuration: { type: Number, required: true },\n exitDuration: { type: Number, required: true },\n overlay: Boolean,\n removeChild: { type: Function as PropType<() => void>, required: true },\n callbacks: Object as PropType<TransitionGroupChildCallbacks>,\n },\n setup(props, { slots }) {\n const element = ref<HTMLElement | null>(null)\n const state = useTransitionChild(props, () => element.value)\n\n // An exiting child stays mounted with live slots, where React renders its\n // last element: state cleared along with the close must not throw here\n onErrorCaptured(() => (props.shouldRender ? undefined : false))\n\n return () =>\n h(\n props.as,\n {\n \"ref\": element,\n \"class\": clsx(props.className, s.TransitionGroupChild),\n \"data-transition-id\": props.transitionId,\n \"style\": props.styleValue,\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n \"inert\": props.overlay && state.exit ? \"\" : undefined,\n },\n slots.default?.(),\n )\n },\n})\n\n/**\n * Delays mounting a child by `enterMountDelay` ms, except on the initial\n * (prevented) mount. Like usehooks-ts' useTimeout, a changed delay restarts\n * the pending timer; removing the delay while pending leaves it unmounted.\n */\nexport const useMountDelay = (getProps: () => { preventMountTransition?: boolean; enterMountDelay?: number }) => {\n const delay = () => {\n const { preventMountTransition, enterMountDelay } = getProps()\n return !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n }\n const mounted = ref(delay() == null)\n let timeout: number | undefined\n\n onMounted(() => {\n watch(\n delay,\n (mountDelay) => {\n clearTimeout(timeout)\n if (!mounted.value && mountDelay != null) {\n timeout = window.setTimeout(() => (mounted.value = true), mountDelay)\n }\n },\n { immediate: true },\n )\n })\n onBeforeUnmount(() => clearTimeout(timeout))\n return mounted\n}\n\nconst TransitionGroupChild = defineComponent({\n name: \"TransitionGroupChild\",\n inheritAttrs: false,\n props: {\n preventMountTransition: Boolean,\n enterMountDelay: Number,\n },\n setup(props, { attrs, slots }) {\n const mounted = useMountDelay(() => props)\n return () =>\n mounted.value\n ? h(TransitionGroupChildInner, { ...attrs, preventMountTransition: props.preventMountTransition } as never, slots)\n : null\n },\n})\n\n// With `disableAnimations`, React wraps the children through `Children.map`,\n// which keys each wrapper by its child's key and a `false` child's wrapper by\n// its position. A reordered child moves with its wrapper (keeping its DOM and\n// state), and a `false` child turning into an element (or back) gets a new\n// wrapper. Placeholders take a symbol per position, which no child key can\n// equal.\nconst placeholderKeys: symbol[] = []\nconst wrapperKey = (vnode: VNode, index: number): PropertyKey => {\n if (!isPlaceholder(vnode)) return vnode.key!\n return (placeholderKeys[index] ??= Symbol(`placeholder-${index}`))\n}\n\n/**\n * Wraps each keyed child in a `<span>` (or `<div>`) that carries\n * `data-entering` / `data-exiting` state while it mounts and unmounts.\n *\n * A `false` slot child (a comment vnode) mirrors React's `Children.map`\n * over `false`: with `disableAnimations` it still renders an empty wrapper.\n * Leave the slot out entirely to render nothing.\n */\nexport const TransitionGroup = defineComponent({\n name: \"TransitionGroup\",\n inheritAttrs: false,\n props: {\n /** Determines the tag used by wrapping elements */\n as: { type: String as PropType<Tag>, default: \"span\" },\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId: String,\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration: { type: Number, default: 0 },\n /**\n * The enter time with reduced motion, in place of `enterDuration`: for an overlay\n * whose styles fade it in over a time of its own then (a Dialog, a Menu).\n */\n reducedMotionEnterDuration: Number,\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration: { type: Number, default: 0 },\n /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */\n preventInitialTransition: { type: Boolean, default: true },\n /** Delay in MS to wait before mounting a child. Unset for no delay (default). */\n enterMountDelay: Number,\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations: { type: Boolean, default: () => getDisableAnimations() },\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it leaves without waiting for `exitDuration`. It\n * still waits out `enterDuration`: with reduced motion an overlay fades in over it.\n */\n overlay: Boolean,\n /** Determines how new children are added to the children array */\n insertMethod: { type: String as PropType<InsertMethod>, default: \"append\" },\n /** Called when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: callbackProp,\n /** Called when an enter animation starts */\n onEnterActive: callbackProp,\n /** Called when an enter animation completes */\n onEnterComplete: callbackProp,\n /** Called when an exit animation is staged */\n onExit: callbackProp,\n /** Called when an exit animation starts */\n onExitActive: callbackProp,\n /** Called when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: callbackProp,\n },\n setup(props, { slots, attrs }) {\n const children = useChildList(\"TransitionGroup\")\n // Read at call time, so callers can swap handlers between renders\n const callbacks: TransitionGroupChildCallbacks = {\n onEnter: (el) => props.onEnter?.(el),\n onEnterActive: (el) => props.onEnterActive?.(el),\n onEnterComplete: (el) => props.onEnterComplete?.(el),\n onExit: (el) => props.onExit?.(el),\n onExitActive: (el) => props.onExitActive?.(el),\n onExitComplete: (el) => props.onExitComplete?.(el),\n }\n\n return () => {\n const slotChildren: VNode[] = flattenChildren(slots.default?.() ?? [])\n const className = attrs.class as string | undefined\n const style = attrs.style as StyleValue | undefined\n const renderChildren = children.next(\n children.keyedChildren(slotChildren),\n props.insertMethod,\n props.preventInitialTransition,\n )\n\n if (props.disableAnimations) {\n return slotChildren.map((vnode, index) =>\n h(\n props.as,\n { \"key\": wrapperKey(vnode, index), \"class\": className, style, \"data-transition-id\": props.transitionId },\n isPlaceholder(vnode) ? undefined : [vnode],\n ),\n )\n }\n\n return renderChildren.map((child) =>\n h(\n TransitionGroupChild,\n {\n key: child.key,\n preventMountTransition: child.preventMountTransition,\n enterMountDelay: props.enterMountDelay,\n as: props.as,\n className,\n transitionId: props.transitionId,\n styleValue: style,\n shouldRender: child.shouldRender,\n enterDuration:\n props.reducedMotionEnterDuration !== undefined && prefersReducedMotion()\n ? props.reducedMotionEnterDuration\n : props.enterDuration,\n exitDuration: props.exitDuration,\n overlay: props.overlay,\n removeChild: () => children.remove(child.key),\n callbacks,\n },\n { default: () => [child.vnode] },\n ),\n )\n }\n },\n})\n\nexport type TransitionGroupProps = InstanceType<typeof TransitionGroup>[\"$props\"]\n"]}
|
|
@@ -6,6 +6,12 @@ export const overlayTiming = { enterDuration: 250, exitDuration: 150 };
|
|
|
6
6
|
export const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 };
|
|
7
7
|
/** A submenu: it opens after a hover delay of its own, so it shows at once */
|
|
8
8
|
export const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 };
|
|
9
|
+
/**
|
|
10
|
+
* With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2
|
|
11
|
+
* simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These
|
|
12
|
+
* match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.
|
|
13
|
+
*/
|
|
14
|
+
export const reducedMotionEnter = { dialog: 350, menu: 500 };
|
|
9
15
|
/**
|
|
10
16
|
* An overlay stays a dismissable layer through its exit. A press on its trigger
|
|
11
17
|
* turns it around, and the layer must not count that press as outside and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD;AAuDnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AACtE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAC3E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD;AAuDnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AACtE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAC3E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAC3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,OAAO;QACL,UAAU,EAAE;YACV,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;YACD,aAAa,EAAE,GAAG,EAAE;gBAClB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;YACD,cAAc,EAAE,GAAG,EAAE;gBACnB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;SACF;QACD,iBAAiB,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,IAAI,OAAO;gBAAE,KAAK,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["// Types and helpers shared by the Vue transition components. Mirrors\n// packages/ui/src/components/Transition/shared.ts.\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n/** The element a transition callback receives (HTML or SVG) */\nexport type TransitionElement = HTMLElement | SVGElement\n\nexport type TransitionGroupChildCallback = (element: TransitionElement) => void\n\n/** Lifecycle hooks, called with the transitioning element (same moments as React's `onEnter`...). */\nexport type TransitionGroupChildCallbacks = {\n onEnter?: TransitionGroupChildCallback\n onEnterActive?: TransitionGroupChildCallback\n onEnterComplete?: TransitionGroupChildCallback\n onExit?: TransitionGroupChildCallback\n onExitActive?: TransitionGroupChildCallback\n onExitComplete?: TransitionGroupChildCallback\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\n// Overlay timers, in step with the `--motion-*` tokens\nexport const overlayTiming = { enterDuration: 250, exitDuration: 150 }\n/** A panel that crosses the screen: a sheet or a side panel */\nexport const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 }\n/** A submenu: it opens after a hover delay of its own, so it shows at once */\nexport const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 }\n/**\n * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2\n * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These\n * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.\n */\nexport const reducedMotionEnter = { dialog: 350, menu: 500 }\n\n/**\n * An overlay stays a dismissable layer through its exit. A press on its trigger\n * turns it around, and the layer must not count that press as outside and\n * close it again: pass `transition` to the TransitionGroup and\n * `onInteractOutside` to the layer.\n */\nexport const createExitGuard = () => {\n let exiting = false\n return {\n transition: {\n onExit: () => {\n exiting = true\n },\n onEnterActive: () => {\n exiting = false\n },\n onExitComplete: () => {\n exiting = false\n },\n },\n onInteractOutside: (event: Event) => {\n if (exiting) event.preventDefault()\n },\n }\n}\n"]}
|
|
@@ -31,6 +31,11 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
|
|
|
31
31
|
type: NumberConstructor;
|
|
32
32
|
default: number;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* The enter time with reduced motion, in place of `enterDuration`: for an overlay
|
|
36
|
+
* whose styles fade it in over a time of its own then (a Dialog, a Menu).
|
|
37
|
+
*/
|
|
38
|
+
reducedMotionEnterDuration: NumberConstructor;
|
|
34
39
|
/** Determines the amount of time that the exit state is applied before unmounting */
|
|
35
40
|
exitDuration: {
|
|
36
41
|
type: NumberConstructor;
|
|
@@ -50,7 +55,8 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
|
|
|
50
55
|
};
|
|
51
56
|
/**
|
|
52
57
|
* For overlays: an exiting child is `inert`, out of the tab order and of hit
|
|
53
|
-
* testing, and with reduced motion it leaves without waiting for `exitDuration`.
|
|
58
|
+
* testing, and with reduced motion it leaves without waiting for `exitDuration`. It
|
|
59
|
+
* still waits out `enterDuration`: with reduced motion an overlay fades in over it.
|
|
54
60
|
*/
|
|
55
61
|
overlay: BooleanConstructor;
|
|
56
62
|
/** Determines how new children are added to the children array */
|
|
@@ -85,6 +91,11 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
|
|
|
85
91
|
type: NumberConstructor;
|
|
86
92
|
default: number;
|
|
87
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* The enter time with reduced motion, in place of `enterDuration`: for an overlay
|
|
96
|
+
* whose styles fade it in over a time of its own then (a Dialog, a Menu).
|
|
97
|
+
*/
|
|
98
|
+
reducedMotionEnterDuration: NumberConstructor;
|
|
88
99
|
/** Determines the amount of time that the exit state is applied before unmounting */
|
|
89
100
|
exitDuration: {
|
|
90
101
|
type: NumberConstructor;
|
|
@@ -104,7 +115,8 @@ export declare const TransitionGroup: import("vue").DefineComponent<import("vue"
|
|
|
104
115
|
};
|
|
105
116
|
/**
|
|
106
117
|
* For overlays: an exiting child is `inert`, out of the tab order and of hit
|
|
107
|
-
* testing, and with reduced motion it leaves without waiting for `exitDuration`.
|
|
118
|
+
* testing, and with reduced motion it leaves without waiting for `exitDuration`. It
|
|
119
|
+
* still waits out `enterDuration`: with reduced motion an overlay fades in over it.
|
|
108
120
|
*/
|
|
109
121
|
overlay: BooleanConstructor;
|
|
110
122
|
/** Determines how new children are added to the children array */
|
|
@@ -48,6 +48,15 @@ export declare const overlayTimingQuick: {
|
|
|
48
48
|
enterDuration: number;
|
|
49
49
|
exitDuration: number;
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2
|
|
53
|
+
* simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These
|
|
54
|
+
* match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.
|
|
55
|
+
*/
|
|
56
|
+
export declare const reducedMotionEnter: {
|
|
57
|
+
dialog: number;
|
|
58
|
+
menu: number;
|
|
59
|
+
};
|
|
51
60
|
/**
|
|
52
61
|
* An overlay stays a dismissable layer through its exit. A press on its trigger
|
|
53
62
|
* turns it around, and the layer must not count that press as outside and
|