motion-v 0.13.1-alpha.0 → 0.13.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];
@@ -4566,19 +4575,27 @@ const SVG_STYLE_TO_ATTRIBUTES = {
4566
4575
  letterSpacing: true,
4567
4576
  vectorEffect: true
4568
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
+ }
4569
4585
  function convertSvgStyleToAttributes(keyframes2) {
4570
4586
  const attributes = {};
4571
4587
  const styleProps = {};
4572
4588
  for (const key in keyframes2) {
4573
4589
  if (key in SVG_STYLE_TO_ATTRIBUTES) {
4574
- const attrKey = SVG_STYLE_TO_ATTRIBUTES[key];
4575
- const attrName = typeof attrKey === "string" ? attrKey : key;
4576
4590
  const value = keyframes2[key];
4577
- attributes[attrName] = isMotionValue(value) ? value.get() : value;
4591
+ attributes[key] = isMotionValue(value) ? value.get() : value;
4578
4592
  } else {
4579
4593
  styleProps[key] = keyframes2[key];
4580
4594
  }
4581
4595
  }
4596
+ if (attributes.pathLength) {
4597
+ buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
4598
+ }
4582
4599
  return {
4583
4600
  attributes,
4584
4601
  style: styleProps
@@ -5133,14 +5150,6 @@ function createBox() {
5133
5150
  function eachAxis$1(callback) {
5134
5151
  return [callback("x"), callback("y")];
5135
5152
  }
5136
- function createUnitType(unit) {
5137
- return {
5138
- test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
5139
- parse: parseFloat,
5140
- transform: (v) => `${v}${unit}`
5141
- };
5142
- }
5143
- const percent = /* @__PURE__ */ createUnitType("%");
5144
5153
  function isWillChangeMotionValue(value) {
5145
5154
  return Boolean(isMotionValue(value) && value.add);
5146
5155
  }
@@ -5661,7 +5670,7 @@ const correctBorderRadius = {
5661
5670
  if (!node.target)
5662
5671
  return latest;
5663
5672
  if (typeof latest === "string") {
5664
- if (px.test(latest)) {
5673
+ if (px$1.test(latest)) {
5665
5674
  latest = parseFloat(latest);
5666
5675
  } else {
5667
5676
  return latest;
@@ -5859,7 +5868,7 @@ function resolveMotionValue(value) {
5859
5868
  const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
5860
5869
  const numBorders = borders.length;
5861
5870
  const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
5862
- const isPx = (value) => typeof value === "number" || px.test(value);
5871
+ const isPx = (value) => typeof value === "number" || px$1.test(value);
5863
5872
  function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
5864
5873
  if (shouldCrossfadeOpacity) {
5865
5874
  target.opacity = mixNumber$2(
@@ -7964,8 +7973,7 @@ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
7964
7973
  touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
7965
7974
  });
7966
7975
  }
7967
- styleProps = createStyles(styleProps);
7968
- attrsProps.style = styleProps;
7976
+ attrsProps.style = createStyles(styleProps);
7969
7977
  return attrsProps;
7970
7978
  }
7971
7979
  const PrimitiveRef = vue.ref();
@@ -205,8 +205,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
205
205
  touchAction: props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`
206
206
  });
207
207
  }
208
- styleProps = createStyles(styleProps);
209
- attrsProps.style = styleProps;
208
+ attrsProps.style = createStyles(styleProps);
210
209
  return attrsProps;
211
210
  }
212
211
  const PrimitiveRef = ref();
@@ -1,5 +1,6 @@
1
1
  import { isNumber, isCssVar } from "./utils.mjs";
2
2
  import { isTransform, transformAlias, transformDefinitions, buildTransformTemplate } from "./transform.mjs";
3
+ import { px } from "../value/types/numbers/units.mjs";
3
4
  import { isMotionValue } from "../utils/motion-value.mjs";
4
5
  const style = {
5
6
  get: (element, name) => {
@@ -89,19 +90,27 @@ const SVG_STYLE_TO_ATTRIBUTES = {
89
90
  letterSpacing: true,
90
91
  vectorEffect: true
91
92
  };
93
+ function buildSVGPath(attrs, length, spacing = 1, offset = 0) {
94
+ attrs.pathLength = 1;
95
+ attrs["stroke-dashoffset"] = px.transform(-offset);
96
+ const pathLength = px.transform(length);
97
+ const pathSpacing = px.transform(spacing);
98
+ attrs["stroke-dasharray"] = `${pathLength} ${pathSpacing}`;
99
+ }
92
100
  function convertSvgStyleToAttributes(keyframes) {
93
101
  const attributes = {};
94
102
  const styleProps = {};
95
103
  for (const key in keyframes) {
96
104
  if (key in SVG_STYLE_TO_ATTRIBUTES) {
97
- const attrKey = SVG_STYLE_TO_ATTRIBUTES[key];
98
- const attrName = typeof attrKey === "string" ? attrKey : key;
99
105
  const value = keyframes[key];
100
- attributes[attrName] = isMotionValue(value) ? value.get() : value;
106
+ attributes[key] = isMotionValue(value) ? value.get() : value;
101
107
  } else {
102
108
  styleProps[key] = keyframes[key];
103
109
  }
104
110
  }
111
+ if (attributes.pathLength) {
112
+ buildSVGPath(attributes, attributes.pathLength, attributes.pathSpacing, attributes.pathOffset);
113
+ }
105
114
  return {
106
115
  attributes,
107
116
  style: styleProps
@@ -6,6 +6,8 @@ function createUnitType(unit) {
6
6
  };
7
7
  }
8
8
  const percent = /* @__PURE__ */ createUnitType("%");
9
+ const px = /* @__PURE__ */ createUnitType("px");
9
10
  export {
10
- percent
11
+ percent,
12
+ px
11
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.13.1-alpha.0",
3
+ "version": "0.13.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",