motion-v 0.13.0 → 0.13.1-alpha.1

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/cjs/index.js CHANGED
@@ -758,7 +758,7 @@ const createUnitType$1 = (unit) => ({
758
758
  });
759
759
  const degrees = /* @__PURE__ */ createUnitType$1("deg");
760
760
  const percent$1 = /* @__PURE__ */ createUnitType$1("%");
761
- const px = /* @__PURE__ */ createUnitType$1("px");
761
+ const px$1 = /* @__PURE__ */ createUnitType$1("px");
762
762
  const vh = /* @__PURE__ */ createUnitType$1("vh");
763
763
  const vw = /* @__PURE__ */ createUnitType$1("vw");
764
764
  const progressPercentage = {
@@ -889,40 +889,40 @@ const filter = {
889
889
  };
890
890
  const browserNumberValueTypes = {
891
891
  // Border props
892
- borderWidth: px,
893
- borderTopWidth: px,
894
- borderRightWidth: px,
895
- borderBottomWidth: px,
896
- borderLeftWidth: px,
897
- borderRadius: px,
898
- radius: px,
899
- borderTopLeftRadius: px,
900
- borderTopRightRadius: px,
901
- borderBottomRightRadius: px,
902
- borderBottomLeftRadius: px,
892
+ borderWidth: px$1,
893
+ borderTopWidth: px$1,
894
+ borderRightWidth: px$1,
895
+ borderBottomWidth: px$1,
896
+ borderLeftWidth: px$1,
897
+ borderRadius: px$1,
898
+ radius: px$1,
899
+ borderTopLeftRadius: px$1,
900
+ borderTopRightRadius: px$1,
901
+ borderBottomRightRadius: px$1,
902
+ borderBottomLeftRadius: px$1,
903
903
  // Positioning props
904
- width: px,
905
- maxWidth: px,
906
- height: px,
907
- maxHeight: px,
908
- top: px,
909
- right: px,
910
- bottom: px,
911
- left: px,
904
+ width: px$1,
905
+ maxWidth: px$1,
906
+ height: px$1,
907
+ maxHeight: px$1,
908
+ top: px$1,
909
+ right: px$1,
910
+ bottom: px$1,
911
+ left: px$1,
912
912
  // Spacing props
913
- padding: px,
914
- paddingTop: px,
915
- paddingRight: px,
916
- paddingBottom: px,
917
- paddingLeft: px,
918
- margin: px,
919
- marginTop: px,
920
- marginRight: px,
921
- marginBottom: px,
922
- marginLeft: px,
913
+ padding: px$1,
914
+ paddingTop: px$1,
915
+ paddingRight: px$1,
916
+ paddingBottom: px$1,
917
+ paddingLeft: px$1,
918
+ margin: px$1,
919
+ marginTop: px$1,
920
+ marginRight: px$1,
921
+ marginBottom: px$1,
922
+ marginLeft: px$1,
923
923
  // Misc
924
- backgroundPositionX: px,
925
- backgroundPositionY: px
924
+ backgroundPositionX: px$1,
925
+ backgroundPositionY: px$1
926
926
  };
927
927
  const transformValueTypes = {
928
928
  rotate: degrees,
@@ -936,19 +936,19 @@ const transformValueTypes = {
936
936
  skew: degrees,
937
937
  skewX: degrees,
938
938
  skewY: degrees,
939
- distance: px,
940
- translateX: px,
941
- translateY: px,
942
- translateZ: px,
943
- x: px,
944
- y: px,
945
- z: px,
946
- perspective: px,
947
- transformPerspective: px,
939
+ distance: px$1,
940
+ translateX: px$1,
941
+ translateY: px$1,
942
+ translateZ: px$1,
943
+ x: px$1,
944
+ y: px$1,
945
+ z: px$1,
946
+ perspective: px$1,
947
+ transformPerspective: px$1,
948
948
  opacity: alpha,
949
949
  originX: progressPercentage,
950
950
  originY: progressPercentage,
951
- originZ: px
951
+ originZ: px$1
952
952
  };
953
953
  const int = {
954
954
  ...number,
@@ -958,7 +958,7 @@ const numberValueTypes = {
958
958
  ...browserNumberValueTypes,
959
959
  ...transformValueTypes,
960
960
  zIndex: int,
961
- size: px,
961
+ size: px$1,
962
962
  // SVG
963
963
  fillOpacity: alpha,
964
964
  strokeOpacity: alpha,
@@ -1083,7 +1083,7 @@ const readTransformValue = (instance, name) => {
1083
1083
  function convertTransformToNumber(value) {
1084
1084
  return parseFloat(value.trim());
1085
1085
  }
1086
- const isNumOrPxType = (v) => v === number || v === px;
1086
+ const isNumOrPxType = (v) => v === number || v === px$1;
1087
1087
  const transformKeys = /* @__PURE__ */ new Set(["x", "y", "z"]);
1088
1088
  const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
1089
1089
  function removeNonTranslationalTransform(visualElement) {
@@ -1279,7 +1279,7 @@ const auto = {
1279
1279
  test: (v) => v === "auto",
1280
1280
  parse: (v) => v
1281
1281
  };
1282
- const dimensionValueTypes = [number, px, percent$1, degrees, vw, vh, auto];
1282
+ const dimensionValueTypes = [number, px$1, percent$1, degrees, vw, vh, auto];
1283
1283
  const findDimensionValueType = (v) => dimensionValueTypes.find(testValueType(v));
1284
1284
  class DOMKeyframesResolver extends KeyframeResolver {
1285
1285
  constructor(unresolvedKeyframes, onComplete, name, motionValue, element) {
@@ -3093,16 +3093,16 @@ const camelKeys = {
3093
3093
  offset: "strokeDashoffset",
3094
3094
  array: "strokeDasharray"
3095
3095
  };
3096
- function buildSVGPath(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
3096
+ function buildSVGPath$1(attrs, length, spacing = 1, offset = 0, useDashCase = true) {
3097
3097
  attrs.pathLength = 1;
3098
3098
  const keys2 = useDashCase ? dashKeys : camelKeys;
3099
- attrs[keys2.offset] = px.transform(-offset);
3100
- const pathLength = px.transform(length);
3101
- const pathSpacing = px.transform(spacing);
3099
+ attrs[keys2.offset] = px$1.transform(-offset);
3100
+ const pathLength = px$1.transform(length);
3101
+ const pathSpacing = px$1.transform(spacing);
3102
3102
  attrs[keys2.array] = `${pathLength} ${pathSpacing}`;
3103
3103
  }
3104
3104
  function calcOrigin$1(origin, offset, size) {
3105
- return typeof origin === "string" ? origin : px.transform(offset + size * origin);
3105
+ return typeof origin === "string" ? origin : px$1.transform(offset + size * origin);
3106
3106
  }
3107
3107
  function calcSVGTransformOrigin(dimensions, originX, originY) {
3108
3108
  const pxOriginX = calcOrigin$1(originX, dimensions.x, dimensions.width);
@@ -3146,7 +3146,7 @@ function buildSVGAttrs(state2, {
3146
3146
  if (attrScale !== void 0)
3147
3147
  attrs.scale = attrScale;
3148
3148
  if (pathLength !== void 0) {
3149
- buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
3149
+ buildSVGPath$1(attrs, pathLength, pathSpacing, pathOffset, false);
3150
3150
  }
3151
3151
  }
3152
3152
  const camelCaseAttributes = /* @__PURE__ */ new Set([
@@ -4478,6 +4478,15 @@ const transformResetValue = {
4478
4478
  y: 0,
4479
4479
  z: 0
4480
4480
  };
4481
+ function createUnitType(unit) {
4482
+ return {
4483
+ test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
4484
+ parse: parseFloat,
4485
+ transform: (v) => `${v}${unit}`
4486
+ };
4487
+ }
4488
+ const percent = /* @__PURE__ */ createUnitType("%");
4489
+ const px = /* @__PURE__ */ createUnitType("px");
4481
4490
  const style = {
4482
4491
  get: (element, name) => {
4483
4492
  let value = isCssVar(name) ? element.style.getPropertyValue(name) : getComputedStyle(element)[name];
@@ -4537,15 +4546,12 @@ const SVG_STYLE_TO_ATTRIBUTES = {
4537
4546
  cy: true,
4538
4547
  r: true,
4539
4548
  d: true,
4540
- x: true,
4541
- y: true,
4542
4549
  x1: true,
4543
4550
  y1: true,
4544
4551
  x2: true,
4545
4552
  y2: true,
4546
4553
  points: true,
4547
4554
  pathLength: true,
4548
- transform: true,
4549
4555
  viewBox: true,
4550
4556
  width: true,
4551
4557
  height: true,
@@ -4569,19 +4575,31 @@ const SVG_STYLE_TO_ATTRIBUTES = {
4569
4575
  letterSpacing: true,
4570
4576
  vectorEffect: true
4571
4577
  };
4578
+ function buildSVGPath(attrs, length, spacing = 1, offset = 0) {
4579
+ attrs.pathLength = 1;
4580
+ attrs["stroke-dashoffset"] = px.transform(-offset);
4581
+ const pathLength = px.transform(length);
4582
+ const pathSpacing = px.transform(spacing);
4583
+ attrs["stroke-dasharray"] = `${pathLength} ${pathSpacing}`;
4584
+ }
4572
4585
  function convertSvgStyleToAttributes(keyframes2) {
4573
4586
  const attributes = {};
4574
4587
  const styleProps = {};
4588
+ let shouldBuildPath = false;
4575
4589
  for (const key in keyframes2) {
4576
4590
  if (key in SVG_STYLE_TO_ATTRIBUTES) {
4577
- const attrKey = SVG_STYLE_TO_ATTRIBUTES[key];
4578
- const attrName = typeof attrKey === "string" ? attrKey : key;
4591
+ if (key === "pathLength") {
4592
+ shouldBuildPath = true;
4593
+ }
4579
4594
  const value = keyframes2[key];
4580
- attributes[attrName] = isMotionValue(value) ? value.get() : value;
4595
+ attributes[key] = isMotionValue(value) ? value.get() : value;
4581
4596
  } else {
4582
4597
  styleProps[key] = keyframes2[key];
4583
4598
  }
4584
4599
  }
4600
+ if (shouldBuildPath) {
4601
+ buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
4602
+ }
4585
4603
  return {
4586
4604
  attributes,
4587
4605
  style: styleProps
@@ -5136,14 +5154,6 @@ function createBox() {
5136
5154
  function eachAxis$1(callback) {
5137
5155
  return [callback("x"), callback("y")];
5138
5156
  }
5139
- function createUnitType(unit) {
5140
- return {
5141
- test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
5142
- parse: parseFloat,
5143
- transform: (v) => `${v}${unit}`
5144
- };
5145
- }
5146
- const percent = /* @__PURE__ */ createUnitType("%");
5147
5157
  function isWillChangeMotionValue(value) {
5148
5158
  return Boolean(isMotionValue(value) && value.add);
5149
5159
  }
@@ -5664,7 +5674,7 @@ const correctBorderRadius = {
5664
5674
  if (!node.target)
5665
5675
  return latest;
5666
5676
  if (typeof latest === "string") {
5667
- if (px.test(latest)) {
5677
+ if (px$1.test(latest)) {
5668
5678
  latest = parseFloat(latest);
5669
5679
  } else {
5670
5680
  return latest;
@@ -5862,7 +5872,7 @@ function resolveMotionValue(value) {
5862
5872
  const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
5863
5873
  const numBorders = borders.length;
5864
5874
  const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
5865
- const isPx = (value) => typeof value === "number" || px.test(value);
5875
+ const isPx = (value) => typeof value === "number" || px$1.test(value);
5866
5876
  function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
5867
5877
  if (shouldCrossfadeOpacity) {
5868
5878
  target.opacity = mixNumber$2(
@@ -7952,9 +7962,12 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7952
7962
  ...isSVG ? {} : state2.visualElement.latestValues
7953
7963
  };
7954
7964
  if (isSVG) {
7955
- const { attributes, style: style2 } = convertSvgStyleToAttributes(state2.isMounted() ? state2.target : state2.baseTarget);
7965
+ const { attributes, style: style2 } = convertSvgStyleToAttributes({
7966
+ ...state2.isMounted() ? state2.target : state2.baseTarget,
7967
+ ...styleProps
7968
+ });
7956
7969
  Object.assign(attrsProps, attributes);
7957
- Object.assign(styleProps, style2);
7970
+ styleProps = style2;
7958
7971
  }
7959
7972
  if (props.drag && props.dragListener !== false) {
7960
7973
  Object.assign(styleProps, {
@@ -7964,10 +7977,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7964
7977
  touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7965
7978
  });
7966
7979
  }
7967
- styleProps = createStyles({
7968
- ...styleProps,
7969
- ...props.style
7970
- });
7980
+ styleProps = createStyles(styleProps);
7971
7981
  attrsProps.style = styleProps;
7972
7982
  return attrsProps;
7973
7983
  }
@@ -8396,9 +8406,10 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8396
8406
  });
8397
8407
  const attrs = vue.useAttrs();
8398
8408
  function bindProps() {
8409
+ const { axis: axis2, values, "onUpdate:values": onUpdateValues, ...rest } = props;
8399
8410
  return {
8400
8411
  ...attrs,
8401
- ...props
8412
+ ...rest
8402
8413
  };
8403
8414
  }
8404
8415
  return (_ctx, _cache) => {
@@ -8717,9 +8728,10 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8717
8728
  const { axis, registerItem, updateOrder } = context || {};
8718
8729
  const attrs = vue.useAttrs();
8719
8730
  function bindProps() {
8731
+ const { value, ...rest } = props;
8720
8732
  return {
8721
8733
  ...attrs,
8722
- ...props,
8734
+ ...rest,
8723
8735
  style: {
8724
8736
  ...style2.value,
8725
8737
  x: point2.x,
@@ -190,9 +190,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
190
190
  ...isSVG ? {} : state.visualElement.latestValues
191
191
  };
192
192
  if (isSVG) {
193
- const { attributes, style } = convertSvgStyleToAttributes(state.isMounted() ? state.target : state.baseTarget);
193
+ const { attributes, style } = convertSvgStyleToAttributes({
194
+ ...state.isMounted() ? state.target : state.baseTarget,
195
+ ...styleProps
196
+ });
194
197
  Object.assign(attrsProps, attributes);
195
- Object.assign(styleProps, style);
198
+ styleProps = style;
196
199
  }
197
200
  if (props.drag && props.dragListener !== false) {
198
201
  Object.assign(styleProps, {
@@ -202,10 +205,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
202
205
  touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
203
206
  });
204
207
  }
205
- styleProps = createStyles({
206
- ...styleProps,
207
- ...props.style
208
- });
208
+ styleProps = createStyles(styleProps);
209
209
  attrsProps.style = styleProps;
210
210
  return attrsProps;
211
211
  }
@@ -1,6 +1,6 @@
1
1
  import { MotionProps } from '../motion';
2
- import { ElementType } from '../../types';
3
- export interface GroupProps<T extends ElementType, K = unknown, V = unknown> extends MotionProps<T, K> {
2
+ import { AsTag } from '../../types';
3
+ export interface GroupProps<T extends AsTag, K, V> extends MotionProps<T, K> {
4
4
  /**
5
5
  * The axis to reorder along. By default, items will be draggable on this axis.
6
6
  * To make draggable on both axes, set `<Reorder.Item drag />`
@@ -34,38 +34,20 @@ export interface GroupProps<T extends ElementType, K = unknown, V = unknown> ext
34
34
  */
35
35
  'values': V[];
36
36
  }
37
- declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<GroupProps<keyof import('vue').IntrinsicElementAttributes, unknown, unknown>>, {
38
- as: string;
39
- axis: string;
40
- }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<GroupProps<keyof import('vue').IntrinsicElementAttributes, unknown, unknown>>, {
41
- as: string;
42
- axis: string;
43
- }>>>, {
44
- as: keyof import('vue').IntrinsicElementAttributes;
45
- axis: "x" | "y";
46
- }, {}>, {
47
- default?(_: {}): any;
48
- }>;
49
- export default _default;
50
- type __VLS_WithDefaults<P, D> = {
51
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
52
- default: D[K];
53
- }> : P[K];
54
- };
55
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
56
- type __VLS_TypePropsToOption<T> = {
57
- [K in keyof T]-?: {} extends Pick<T, K> ? {
58
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
59
- } : {
60
- type: import('vue').PropType<T[K]>;
61
- required: true;
62
- };
63
- };
64
- type __VLS_WithTemplateSlots<T, S> = T & {
65
- new (): {
66
- $slots: S;
37
+ declare const _default: <T, K, V>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
38
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{}>>, never>, never> & GroupProps<AsTag, K, V>> & import('vue').PublicProps;
39
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
40
+ attrs: any;
41
+ slots: {
42
+ default?(_: {}): any;
67
43
  };
44
+ emit: {};
45
+ }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
46
+ [key: string]: any;
47
+ }> & {
48
+ __ctx?: Awaited<typeof __VLS_setup>;
68
49
  };
50
+ export default _default;
69
51
  type __VLS_PrettifyLocal<T> = {
70
52
  [K in keyof T]: T[K];
71
53
  } & {};
@@ -119,9 +119,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
119
119
  });
120
120
  const attrs = useAttrs();
121
121
  function bindProps() {
122
+ const { axis: axis2, values, "onUpdate:values": onUpdateValues, ...rest } = props;
122
123
  return {
123
124
  ...attrs,
124
- ...props
125
+ ...rest
125
126
  };
126
127
  }
127
128
  return (_ctx, _cache) => {
@@ -96,9 +96,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
96
96
  const { axis, registerItem, updateOrder } = context || {};
97
97
  const attrs = useAttrs();
98
98
  function bindProps() {
99
+ const { value, ...rest } = props;
99
100
  return {
100
101
  ...attrs,
101
- ...props,
102
+ ...rest,
102
103
  style: {
103
104
  ...style.value,
104
105
  x: point.x,