motion-v 0.8.1 → 0.9.0

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
@@ -8244,6 +8244,9 @@ class MotionState {
8244
8244
  // Initialize animation target values
8245
8245
  initTarget(initialVariantSource) {
8246
8246
  this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
8247
+ for (const key in this.baseTarget) {
8248
+ this.visualElement.setStaticValue(key, this.baseTarget[key]);
8249
+ }
8247
8250
  this.target = {};
8248
8251
  }
8249
8252
  // Get initial animation state
@@ -8280,15 +8283,6 @@ class MotionState {
8280
8283
  }
8281
8284
  this.visualElement.state = this;
8282
8285
  this.updateOptions();
8283
- if (typeof this.initial === "object") {
8284
- for (const key in this.initial) {
8285
- this.visualElement.setStaticValue(key, this.initial[key]);
8286
- }
8287
- } else if (typeof this.initial === "string" && this.options.variants) {
8288
- for (const key in this.options.variants[this.initial]) {
8289
- this.visualElement.setStaticValue(key, this.options.variants[this.initial][key]);
8290
- }
8291
- }
8292
8286
  this.featureManager.mount();
8293
8287
  if (!notAnimate && this.options.animate) {
8294
8288
  this.animateUpdates();
@@ -8384,7 +8378,7 @@ const [injectMotionConfig, provideMotionConfig] = createContext("MotionConfig");
8384
8378
  function useMotionConfig() {
8385
8379
  return injectMotionConfig(vue.computed(() => defaultConfig));
8386
8380
  }
8387
- const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8381
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
8388
8382
  ...{
8389
8383
  name: "Motion",
8390
8384
  inheritAttrs: false
@@ -8412,6 +8406,10 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8412
8406
  layoutRoot: { type: Boolean },
8413
8407
  "data-framer-portal-id": {},
8414
8408
  crossfade: { type: Boolean },
8409
+ onBeforeLayoutMeasure: { type: Function },
8410
+ onLayoutMeasure: { type: Function },
8411
+ onLayoutAnimationStart: { type: Function },
8412
+ onLayoutAnimationComplete: { type: Function },
8415
8413
  globalPressTarget: { type: Boolean },
8416
8414
  press: {},
8417
8415
  onPressStart: { type: Function },
@@ -8573,7 +8571,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8573
8571
  }
8574
8572
  });
8575
8573
  const componentCache = /* @__PURE__ */ new Map();
8576
- const motion = new Proxy(_sfc_main$3, {
8574
+ const motion = new Proxy(_sfc_main$5, {
8577
8575
  get(target, prop) {
8578
8576
  if (typeof prop === "symbol")
8579
8577
  return target[prop];
@@ -8585,7 +8583,7 @@ const motion = new Proxy(_sfc_main$3, {
8585
8583
  name: `motion.${component.$name}`,
8586
8584
  setup(_, { attrs, slots }) {
8587
8585
  return () => {
8588
- return vue.h(_sfc_main$3, {
8586
+ return vue.h(_sfc_main$5, {
8589
8587
  ...attrs,
8590
8588
  as: component,
8591
8589
  asChild: false
@@ -8601,7 +8599,7 @@ const motion = new Proxy(_sfc_main$3, {
8601
8599
  name: `motion.${prop}`,
8602
8600
  setup(_, { attrs, slots }) {
8603
8601
  return () => {
8604
- return vue.h(_sfc_main$3, {
8602
+ return vue.h(_sfc_main$5, {
8605
8603
  ...attrs,
8606
8604
  as: prop,
8607
8605
  asChild: false
@@ -8665,7 +8663,7 @@ function usePopLayout(props) {
8665
8663
  styles
8666
8664
  };
8667
8665
  }
8668
- const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8666
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
8669
8667
  ...{
8670
8668
  name: "AnimatePresence",
8671
8669
  inheritAttrs: true
@@ -8763,7 +8761,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8763
8761
  };
8764
8762
  }
8765
8763
  });
8766
- const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8764
+ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8767
8765
  ...{
8768
8766
  name: "MotionConfig",
8769
8767
  inheritAttrs: false
@@ -8788,82 +8786,163 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8788
8786
  };
8789
8787
  }
8790
8788
  });
8791
- function useForceUpdate() {
8792
- const key = vue.ref(0);
8793
- function forceUpdate() {
8794
- key.value++;
8795
- }
8796
- return [forceUpdate, key];
8797
- }
8798
- function notify(node) {
8799
- return !node.isLayoutDirty && node.willUpdate(false);
8800
- }
8801
- function nodeGroup() {
8802
- const nodes = /* @__PURE__ */ new Set();
8803
- const subscriptions = /* @__PURE__ */ new WeakMap();
8804
- const dirtyAll = () => nodes.forEach(notify);
8805
- return {
8806
- add: (node) => {
8807
- nodes.add(node);
8808
- subscriptions.set(
8809
- node,
8810
- node.addEventListener("willUpdate", dirtyAll)
8811
- );
8812
- },
8813
- remove: (node) => {
8814
- nodes.delete(node);
8815
- const unsubscribe = subscriptions.get(node);
8816
- if (unsubscribe) {
8817
- unsubscribe();
8818
- subscriptions.delete(node);
8819
- }
8820
- },
8821
- dirty: dirtyAll
8822
- };
8823
- }
8824
- function useLayoutGroupProvider(props) {
8825
- const parentGroup = injectLayoutGroup(null);
8826
- const [forceRender, key] = useForceUpdate();
8827
- const context = {
8828
- id: getGroupId(props, parentGroup),
8829
- group: getGroup(props, parentGroup),
8830
- forceRender,
8831
- key
8832
- };
8833
- provideLayoutGroup(context);
8834
- return context;
8835
- }
8836
- function useLayoutGroup() {
8837
- const { forceRender } = injectLayoutGroup({ forceRender: () => {
8838
- } });
8839
- return { forceRender };
8840
- }
8841
- function getGroupId(props, parentGroup) {
8842
- const shouldInherit = props.inherit === true || props.inherit === "id";
8843
- const parentId = parentGroup == null ? void 0 : parentGroup.id;
8844
- if (shouldInherit && parentId) {
8845
- return props.id ? `${parentId}-${props.id}` : parentId;
8846
- }
8847
- return props.id;
8848
- }
8849
- function getGroup(props, parentGroup) {
8850
- const shouldInherit = props.inherit === true || props.inherit === "group";
8851
- return shouldInherit ? (parentGroup == null ? void 0 : parentGroup.group) || nodeGroup() : nodeGroup();
8789
+ const [useReorderContext, reorderContextProvider] = createContext("ReorderContext");
8790
+ function compareMin(a, b) {
8791
+ return a.layout.min - b.layout.min;
8792
+ }
8793
+ function getValue(item) {
8794
+ return item.value;
8795
+ }
8796
+ function checkReorder(order2, value, offset, velocity) {
8797
+ if (!velocity)
8798
+ return order2;
8799
+ const index = order2.findIndex((item2) => item2.value === value);
8800
+ if (index === -1)
8801
+ return order2;
8802
+ const nextOffset = velocity > 0 ? 1 : -1;
8803
+ const nextItem = order2[index + nextOffset];
8804
+ if (!nextItem)
8805
+ return order2;
8806
+ const item = order2[index];
8807
+ const nextLayout = nextItem.layout;
8808
+ const nextItemCenter = mixNumber(nextLayout.min, nextLayout.max, 0.5);
8809
+ if (nextOffset === 1 && item.layout.max + offset > nextItemCenter || nextOffset === -1 && item.layout.min + offset < nextItemCenter) {
8810
+ return moveItem(order2, index, index + nextOffset);
8811
+ }
8812
+ return order2;
8813
+ }
8814
+ function moveItem([...arr], fromIndex, toIndex) {
8815
+ const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
8816
+ if (startIndex >= 0 && startIndex < arr.length) {
8817
+ const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
8818
+ const [item] = arr.splice(fromIndex, 1);
8819
+ arr.splice(endIndex, 0, item);
8820
+ }
8821
+ return arr;
8822
+ }
8823
+ function useDefaultMotionValue(value, defaultValue = 0) {
8824
+ return isMotionValue(value) ? value : motionValue(defaultValue);
8852
8825
  }
8853
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
8854
- __name: "LayoutGroup",
8826
+ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8827
+ ...{
8828
+ name: "ReorderGroup",
8829
+ inheritAttrs: false
8830
+ },
8831
+ __name: "Group",
8855
8832
  props: {
8856
- id: {},
8857
- inherit: { type: [Boolean, String] }
8833
+ axis: { default: "y" },
8834
+ "onUpdate:values": {},
8835
+ values: {},
8836
+ as: { default: "ul" },
8837
+ asChild: { type: Boolean },
8838
+ whileDrag: {},
8839
+ custom: {},
8840
+ initial: { type: [String, Object, Boolean] },
8841
+ animate: {},
8842
+ exit: {},
8843
+ variants: {},
8844
+ style: {},
8845
+ transformTemplate: {},
8846
+ transition: {},
8847
+ layoutGroup: {},
8848
+ motionConfig: {},
8849
+ onAnimationComplete: {},
8850
+ onUpdate: {},
8851
+ layout: { type: [Boolean, String] },
8852
+ layoutId: {},
8853
+ layoutScroll: { type: Boolean },
8854
+ layoutRoot: { type: Boolean },
8855
+ "data-framer-portal-id": {},
8856
+ crossfade: { type: Boolean },
8857
+ onBeforeLayoutMeasure: {},
8858
+ onLayoutMeasure: {},
8859
+ onLayoutAnimationStart: {},
8860
+ onLayoutAnimationComplete: {},
8861
+ globalPressTarget: { type: Boolean },
8862
+ press: {},
8863
+ onPressStart: {},
8864
+ onPress: {},
8865
+ onPressCancel: {},
8866
+ hover: {},
8867
+ onHoverStart: {},
8868
+ onHoverEnd: {},
8869
+ inViewOptions: {},
8870
+ inView: {},
8871
+ onViewportEnter: {},
8872
+ onViewportLeave: {},
8873
+ drag: { type: [Boolean, String] },
8874
+ dragSnapToOrigin: { type: Boolean },
8875
+ dragDirectionLock: { type: Boolean },
8876
+ dragPropagation: { type: Boolean },
8877
+ dragConstraints: { type: [Boolean, Object] },
8878
+ dragElastic: { type: [Boolean, Number, Object] },
8879
+ dragMomentum: { type: Boolean },
8880
+ dragTransition: {},
8881
+ dragListener: { type: Boolean },
8882
+ dragControls: {},
8883
+ onDragStart: {},
8884
+ onDragEnd: {},
8885
+ onDrag: {},
8886
+ onDirectionLock: {},
8887
+ onDragTransitionEnd: {},
8888
+ onMeasureDragConstraints: {},
8889
+ onPanSessionStart: {},
8890
+ onPanStart: {},
8891
+ onPan: {},
8892
+ onPanEnd: {},
8893
+ focus: {},
8894
+ onFocus: {},
8895
+ onBlur: {}
8858
8896
  },
8859
8897
  setup(__props) {
8860
8898
  const props = __props;
8861
- const { forceRender, key } = useLayoutGroupProvider(props);
8899
+ const { axis } = vue.toRefs(props);
8900
+ const order2 = [];
8901
+ let isReordering = false;
8902
+ function warning2() {
8903
+ heyListen.invariant(Boolean(props.values), "Reorder.Group must be provided a values prop");
8904
+ }
8905
+ vue.onUpdated(() => {
8906
+ isReordering = false;
8907
+ });
8908
+ reorderContextProvider({
8909
+ axis,
8910
+ registerItem: (value, layout) => {
8911
+ const idx = order2.findIndex((entry) => value === entry.value);
8912
+ if (idx !== -1) {
8913
+ order2[idx].layout = layout[axis.value];
8914
+ } else {
8915
+ order2.push({ value, layout: layout[axis.value] });
8916
+ }
8917
+ order2.sort(compareMin);
8918
+ },
8919
+ updateOrder: (item, offset, velocity) => {
8920
+ if (isReordering)
8921
+ return;
8922
+ const newOrder = checkReorder(order2, item, offset, velocity);
8923
+ if (order2 !== newOrder) {
8924
+ isReordering = true;
8925
+ props["onUpdate:values"](
8926
+ newOrder.map(getValue).filter((value) => props.values.includes(value))
8927
+ );
8928
+ }
8929
+ }
8930
+ });
8931
+ const attrs = vue.useAttrs();
8932
+ function bindProps() {
8933
+ return {
8934
+ ...attrs,
8935
+ ...props
8936
+ };
8937
+ }
8862
8938
  return (_ctx, _cache) => {
8863
- return vue.renderSlot(_ctx.$slots, "default", {
8864
- renderKey: vue.unref(key),
8865
- forceRender: vue.unref(forceRender)
8866
- });
8939
+ return vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$5), vue.normalizeProps(vue.guardReactiveProps(bindProps())), {
8940
+ default: vue.withCtx(() => [
8941
+ vue.renderSlot(_ctx.$slots, "default"),
8942
+ vue.createTextVNode(" " + vue.toDisplayString(warning2()), 1)
8943
+ ]),
8944
+ _: 3
8945
+ }, 16);
8867
8946
  };
8868
8947
  }
8869
8948
  });
@@ -9067,12 +9146,221 @@ function useVelocity(value) {
9067
9146
  });
9068
9147
  return velocity;
9069
9148
  }
9149
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
9150
+ ...{
9151
+ name: "ReorderItem",
9152
+ inheritAttrs: false
9153
+ },
9154
+ __name: "Item",
9155
+ props: {
9156
+ value: {},
9157
+ layout: { type: [Boolean, String], default: true },
9158
+ as: { default: "li" },
9159
+ asChild: { type: Boolean },
9160
+ whileDrag: { default: void 0 },
9161
+ custom: {},
9162
+ initial: { type: [String, Object, Boolean], default: void 0 },
9163
+ animate: { default: void 0 },
9164
+ exit: {},
9165
+ variants: {},
9166
+ style: {},
9167
+ transformTemplate: {},
9168
+ transition: {},
9169
+ layoutGroup: {},
9170
+ motionConfig: {},
9171
+ onAnimationComplete: {},
9172
+ onUpdate: {},
9173
+ layoutId: { default: void 0 },
9174
+ layoutScroll: { type: Boolean, default: false },
9175
+ layoutRoot: { type: Boolean, default: false },
9176
+ "data-framer-portal-id": {},
9177
+ crossfade: { type: Boolean, default: true },
9178
+ onBeforeLayoutMeasure: {},
9179
+ onLayoutMeasure: {},
9180
+ onLayoutAnimationStart: {},
9181
+ onLayoutAnimationComplete: {},
9182
+ globalPressTarget: { type: Boolean },
9183
+ press: {},
9184
+ onPressStart: {},
9185
+ onPress: {},
9186
+ onPressCancel: {},
9187
+ hover: { default: void 0 },
9188
+ onHoverStart: {},
9189
+ onHoverEnd: {},
9190
+ inViewOptions: {},
9191
+ inView: { default: void 0 },
9192
+ onViewportEnter: {},
9193
+ onViewportLeave: {},
9194
+ drag: { type: [Boolean, String] },
9195
+ dragSnapToOrigin: { type: Boolean },
9196
+ dragDirectionLock: { type: Boolean },
9197
+ dragPropagation: { type: Boolean },
9198
+ dragConstraints: { type: [Boolean, Object] },
9199
+ dragElastic: { type: [Boolean, Number, Object], default: 0.5 },
9200
+ dragMomentum: { type: Boolean, default: true },
9201
+ dragTransition: {},
9202
+ dragListener: { type: Boolean, default: true },
9203
+ dragControls: {},
9204
+ onDragStart: {},
9205
+ onDragEnd: {},
9206
+ onDrag: {},
9207
+ onDirectionLock: {},
9208
+ onDragTransitionEnd: {},
9209
+ onMeasureDragConstraints: {},
9210
+ onPanSessionStart: {},
9211
+ onPanStart: {},
9212
+ onPan: {},
9213
+ onPanEnd: {},
9214
+ focus: {},
9215
+ onFocus: {},
9216
+ onBlur: {}
9217
+ },
9218
+ setup(__props) {
9219
+ var _a, _b;
9220
+ const props = __props;
9221
+ const { style: style2 } = vue.toRefs(props);
9222
+ const context = useReorderContext(null);
9223
+ const point2 = {
9224
+ x: useDefaultMotionValue((_a = style2.value) == null ? void 0 : _a.x),
9225
+ y: useDefaultMotionValue((_b = style2.value) == null ? void 0 : _b.y)
9226
+ };
9227
+ const zIndex = useTransform([point2.x, point2.y], ([latestX, latestY]) => latestX || latestY ? 1 : "unset");
9228
+ function warning2() {
9229
+ heyListen.invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
9230
+ }
9231
+ const { axis, registerItem, updateOrder } = context || {};
9232
+ const attrs = vue.useAttrs();
9233
+ function bindProps() {
9234
+ return {
9235
+ ...attrs,
9236
+ ...props,
9237
+ style: {
9238
+ ...style2.value,
9239
+ x: point2.x,
9240
+ y: point2.y,
9241
+ zIndex
9242
+ }
9243
+ };
9244
+ }
9245
+ const drag = vue.computed(() => {
9246
+ if (props.drag) {
9247
+ return props.drag;
9248
+ }
9249
+ return axis.value;
9250
+ });
9251
+ return (_ctx, _cache) => {
9252
+ return vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$5), vue.mergeProps(bindProps(), {
9253
+ drag: drag.value,
9254
+ "drag-snap-to-origin": true,
9255
+ onDrag: _cache[0] || (_cache[0] = (event, gesturePoint) => {
9256
+ const { velocity } = gesturePoint;
9257
+ velocity[vue.unref(axis)] && vue.unref(updateOrder)(_ctx.value, point2[vue.unref(axis)].get(), velocity[vue.unref(axis)]);
9258
+ _ctx.onDrag && _ctx.onDrag(event, gesturePoint);
9259
+ }),
9260
+ onLayoutMeasure: _cache[1] || (_cache[1] = (measured) => vue.unref(registerItem)(_ctx.value, measured))
9261
+ }), {
9262
+ default: vue.withCtx(() => [
9263
+ vue.renderSlot(_ctx.$slots, "default"),
9264
+ vue.createTextVNode(" " + vue.toDisplayString(warning2()), 1)
9265
+ ]),
9266
+ _: 3
9267
+ }, 16, ["drag"]);
9268
+ };
9269
+ }
9270
+ });
9271
+ const ReorderGroup = _sfc_main$2;
9272
+ const ReorderItem = _sfc_main$1;
9273
+ const Reorder = {
9274
+ Group: ReorderGroup,
9275
+ Item: ReorderItem
9276
+ };
9277
+ function useForceUpdate() {
9278
+ const key = vue.ref(0);
9279
+ function forceUpdate() {
9280
+ key.value++;
9281
+ }
9282
+ return [forceUpdate, key];
9283
+ }
9284
+ function notify(node) {
9285
+ return !node.isLayoutDirty && node.willUpdate(false);
9286
+ }
9287
+ function nodeGroup() {
9288
+ const nodes = /* @__PURE__ */ new Set();
9289
+ const subscriptions = /* @__PURE__ */ new WeakMap();
9290
+ const dirtyAll = () => nodes.forEach(notify);
9291
+ return {
9292
+ add: (node) => {
9293
+ nodes.add(node);
9294
+ subscriptions.set(
9295
+ node,
9296
+ node.addEventListener("willUpdate", dirtyAll)
9297
+ );
9298
+ },
9299
+ remove: (node) => {
9300
+ nodes.delete(node);
9301
+ const unsubscribe = subscriptions.get(node);
9302
+ if (unsubscribe) {
9303
+ unsubscribe();
9304
+ subscriptions.delete(node);
9305
+ }
9306
+ },
9307
+ dirty: dirtyAll
9308
+ };
9309
+ }
9310
+ function useLayoutGroupProvider(props) {
9311
+ const parentGroup = injectLayoutGroup(null);
9312
+ const [forceRender, key] = useForceUpdate();
9313
+ const context = {
9314
+ id: getGroupId(props, parentGroup),
9315
+ group: getGroup(props, parentGroup),
9316
+ forceRender,
9317
+ key
9318
+ };
9319
+ provideLayoutGroup(context);
9320
+ return context;
9321
+ }
9322
+ function useLayoutGroup() {
9323
+ const { forceRender } = injectLayoutGroup({ forceRender: () => {
9324
+ } });
9325
+ return { forceRender };
9326
+ }
9327
+ function getGroupId(props, parentGroup) {
9328
+ const shouldInherit = props.inherit === true || props.inherit === "id";
9329
+ const parentId = parentGroup == null ? void 0 : parentGroup.id;
9330
+ if (shouldInherit && parentId) {
9331
+ return props.id ? `${parentId}-${props.id}` : parentId;
9332
+ }
9333
+ return props.id;
9334
+ }
9335
+ function getGroup(props, parentGroup) {
9336
+ const shouldInherit = props.inherit === true || props.inherit === "group";
9337
+ return shouldInherit ? (parentGroup == null ? void 0 : parentGroup.group) || nodeGroup() : nodeGroup();
9338
+ }
9339
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
9340
+ __name: "LayoutGroup",
9341
+ props: {
9342
+ id: {},
9343
+ inherit: { type: [Boolean, String] }
9344
+ },
9345
+ setup(__props) {
9346
+ const props = __props;
9347
+ const { forceRender, key } = useLayoutGroupProvider(props);
9348
+ return (_ctx, _cache) => {
9349
+ return vue.renderSlot(_ctx.$slots, "default", {
9350
+ renderKey: vue.unref(key),
9351
+ forceRender: vue.unref(forceRender)
9352
+ });
9353
+ };
9354
+ }
9355
+ });
9070
9356
  const components = {
9071
9357
  motion: [
9072
9358
  "Motion",
9073
9359
  "AnimatePresence",
9074
9360
  "LayoutGroup",
9075
- "MotionConfig"
9361
+ "MotionConfig",
9362
+ "ReorderGroup",
9363
+ "ReorderItem"
9076
9364
  ]
9077
9365
  };
9078
9366
  const utilities = {
@@ -9249,11 +9537,14 @@ class DragControls {
9249
9537
  }
9250
9538
  const createDragControls = () => new DragControls();
9251
9539
  const useDragControls = createDragControls;
9252
- exports.AnimatePresence = _sfc_main$2;
9540
+ exports.AnimatePresence = _sfc_main$4;
9253
9541
  exports.LayoutGroup = _sfc_main;
9254
- exports.Motion = _sfc_main$3;
9255
- exports.MotionConfig = _sfc_main$1;
9542
+ exports.Motion = _sfc_main$5;
9543
+ exports.MotionConfig = _sfc_main$3;
9256
9544
  exports.MotionValue = MotionValue;
9545
+ exports.Reorder = Reorder;
9546
+ exports.ReorderGroup = ReorderGroup;
9547
+ exports.ReorderItem = ReorderItem;
9257
9548
  exports.animate = animate;
9258
9549
  exports.animateMini = animateMini;
9259
9550
  exports.anticipate = anticipate;
@@ -6,7 +6,6 @@ export interface NodeGroup {
6
6
  add: (node: IProjectionNode) => void;
7
7
  remove: (node: IProjectionNode) => void;
8
8
  dirty: VoidFunction;
9
- didUpdate: VoidFunction;
10
9
  }
11
10
  export interface LayoutGroupState {
12
11
  id?: string;
@@ -1,3 +1,4 @@
1
1
  export { Motion, motion, type MotionProps } from './motion';
2
2
  export * from './animate-presence';
3
3
  export * from './motion-config';
4
+ export * from './reorder';
@@ -35,6 +35,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
35
35
  layoutRoot: { type: Boolean },
36
36
  "data-framer-portal-id": {},
37
37
  crossfade: { type: Boolean },
38
+ onBeforeLayoutMeasure: { type: Function },
39
+ onLayoutMeasure: { type: Function },
40
+ onLayoutAnimationStart: { type: Function },
41
+ onLayoutAnimationComplete: { type: Function },
38
42
  globalPressTarget: { type: Boolean },
39
43
  press: {},
40
44
  onPressStart: { type: Function },
@@ -0,0 +1,71 @@
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> {
4
+ /**
5
+ * The axis to reorder along. By default, items will be draggable on this axis.
6
+ * To make draggable on both axes, set `<Reorder.Item drag />`
7
+ *
8
+ * @public
9
+ */
10
+ 'axis'?: 'x' | 'y';
11
+ /**
12
+ * A callback to fire with the new value order. For instance, if the values
13
+ * are provided as a state from `useState`, this could be the set state function.
14
+ *
15
+ * @public
16
+ */
17
+ 'onUpdate:values'?: (newOrder: V[]) => void;
18
+ /**
19
+ * The latest values state.
20
+ *
21
+ * ```jsx
22
+ * function Component() {
23
+ * const [items, setItems] = useState([0, 1, 2])
24
+ *
25
+ * return (
26
+ * <Reorder.Group values={items} onReorder={setItems}>
27
+ * {items.map((item) => <Reorder.Item key={item} value={item} />)}
28
+ * </Reorder.Group>
29
+ * )
30
+ * }
31
+ * ```
32
+ *
33
+ * @public
34
+ */
35
+ 'values': V[];
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;
67
+ };
68
+ };
69
+ type __VLS_PrettifyLocal<T> = {
70
+ [K in keyof T]: T[K];
71
+ } & {};
@@ -0,0 +1,131 @@
1
+ import { defineComponent, toRefs, onUpdated, useAttrs, openBlock, createBlock, unref, normalizeProps, guardReactiveProps, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
2
+ import { invariant } from "hey-listen";
3
+ import { reorderContextProvider } from "./context.mjs";
4
+ import { compareMin, checkReorder, getValue } from "./utils.mjs";
5
+ import _sfc_main$1 from "../motion/Motion.vue.mjs";
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ ...{
8
+ name: "ReorderGroup",
9
+ inheritAttrs: false
10
+ },
11
+ __name: "Group",
12
+ props: {
13
+ axis: { default: "y" },
14
+ "onUpdate:values": {},
15
+ values: {},
16
+ as: { default: "ul" },
17
+ asChild: { type: Boolean },
18
+ whileDrag: {},
19
+ custom: {},
20
+ initial: { type: [String, Object, Boolean] },
21
+ animate: {},
22
+ exit: {},
23
+ variants: {},
24
+ style: {},
25
+ transformTemplate: {},
26
+ transition: {},
27
+ layoutGroup: {},
28
+ motionConfig: {},
29
+ onAnimationComplete: {},
30
+ onUpdate: {},
31
+ layout: { type: [Boolean, String] },
32
+ layoutId: {},
33
+ layoutScroll: { type: Boolean },
34
+ layoutRoot: { type: Boolean },
35
+ "data-framer-portal-id": {},
36
+ crossfade: { type: Boolean },
37
+ onBeforeLayoutMeasure: {},
38
+ onLayoutMeasure: {},
39
+ onLayoutAnimationStart: {},
40
+ onLayoutAnimationComplete: {},
41
+ globalPressTarget: { type: Boolean },
42
+ press: {},
43
+ onPressStart: {},
44
+ onPress: {},
45
+ onPressCancel: {},
46
+ hover: {},
47
+ onHoverStart: {},
48
+ onHoverEnd: {},
49
+ inViewOptions: {},
50
+ inView: {},
51
+ onViewportEnter: {},
52
+ onViewportLeave: {},
53
+ drag: { type: [Boolean, String] },
54
+ dragSnapToOrigin: { type: Boolean },
55
+ dragDirectionLock: { type: Boolean },
56
+ dragPropagation: { type: Boolean },
57
+ dragConstraints: { type: [Boolean, Object] },
58
+ dragElastic: { type: [Boolean, Number, Object] },
59
+ dragMomentum: { type: Boolean },
60
+ dragTransition: {},
61
+ dragListener: { type: Boolean },
62
+ dragControls: {},
63
+ onDragStart: {},
64
+ onDragEnd: {},
65
+ onDrag: {},
66
+ onDirectionLock: {},
67
+ onDragTransitionEnd: {},
68
+ onMeasureDragConstraints: {},
69
+ onPanSessionStart: {},
70
+ onPanStart: {},
71
+ onPan: {},
72
+ onPanEnd: {},
73
+ focus: {},
74
+ onFocus: {},
75
+ onBlur: {}
76
+ },
77
+ setup(__props) {
78
+ const props = __props;
79
+ const { axis } = toRefs(props);
80
+ const order = [];
81
+ let isReordering = false;
82
+ function warning() {
83
+ invariant(Boolean(props.values), "Reorder.Group must be provided a values prop");
84
+ }
85
+ onUpdated(() => {
86
+ isReordering = false;
87
+ });
88
+ reorderContextProvider({
89
+ axis,
90
+ registerItem: (value, layout) => {
91
+ const idx = order.findIndex((entry) => value === entry.value);
92
+ if (idx !== -1) {
93
+ order[idx].layout = layout[axis.value];
94
+ } else {
95
+ order.push({ value, layout: layout[axis.value] });
96
+ }
97
+ order.sort(compareMin);
98
+ },
99
+ updateOrder: (item, offset, velocity) => {
100
+ if (isReordering)
101
+ return;
102
+ const newOrder = checkReorder(order, item, offset, velocity);
103
+ if (order !== newOrder) {
104
+ isReordering = true;
105
+ props["onUpdate:values"](
106
+ newOrder.map(getValue).filter((value) => props.values.includes(value))
107
+ );
108
+ }
109
+ }
110
+ });
111
+ const attrs = useAttrs();
112
+ function bindProps() {
113
+ return {
114
+ ...attrs,
115
+ ...props
116
+ };
117
+ }
118
+ return (_ctx, _cache) => {
119
+ return openBlock(), createBlock(unref(_sfc_main$1), normalizeProps(guardReactiveProps(bindProps())), {
120
+ default: withCtx(() => [
121
+ renderSlot(_ctx.$slots, "default"),
122
+ createTextVNode(" " + toDisplayString(warning()), 1)
123
+ ]),
124
+ _: 3
125
+ }, 16);
126
+ };
127
+ }
128
+ });
129
+ export {
130
+ _sfc_main as default
131
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./Group.vue.mjs";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,88 @@
1
+ import { MotionProps } from '../motion';
2
+ import { ElementType } from '../../types';
3
+ export interface GroupItemProps<T extends ElementType, K = unknown, V = unknown> extends MotionProps<T, K> {
4
+ /**
5
+ * The value in the list that this component represents.
6
+ *
7
+ * @public
8
+ */
9
+ value: V;
10
+ /**
11
+ * A subset of layout options primarily used to disable layout="size"
12
+ *
13
+ * @public
14
+ * @default true
15
+ */
16
+ layout?: true | 'position';
17
+ }
18
+ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<GroupItemProps<keyof import('vue').IntrinsicElementAttributes, unknown, unknown>>, {
19
+ layout: boolean;
20
+ as: ElementType;
21
+ initial: any;
22
+ animate: any;
23
+ hover: any;
24
+ inView: any;
25
+ layoutId: any;
26
+ layoutScroll: boolean;
27
+ layoutRoot: boolean;
28
+ dragListener: boolean;
29
+ dragElastic: number;
30
+ dragMomentum: boolean;
31
+ whileDrag: any;
32
+ crossfade: boolean;
33
+ }>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<GroupItemProps<keyof import('vue').IntrinsicElementAttributes, unknown, unknown>>, {
34
+ layout: boolean;
35
+ as: ElementType;
36
+ initial: any;
37
+ animate: any;
38
+ hover: any;
39
+ inView: any;
40
+ layoutId: any;
41
+ layoutScroll: boolean;
42
+ layoutRoot: boolean;
43
+ dragListener: boolean;
44
+ dragElastic: number;
45
+ dragMomentum: boolean;
46
+ whileDrag: any;
47
+ crossfade: boolean;
48
+ }>>>, {
49
+ layout: true | "position";
50
+ layoutId: string;
51
+ layoutScroll: boolean;
52
+ layoutRoot: boolean;
53
+ crossfade: boolean;
54
+ initial: string | import('../../types').Variant | boolean;
55
+ animate: string | import('../../types').Variant | import('../../animation/types').AnimationControls;
56
+ inView: string | import('../../types').Variant;
57
+ hover: string | import('../../types').Variant;
58
+ whileDrag: import('../../types').Options["whileDrag"];
59
+ dragElastic: number;
60
+ dragMomentum: boolean;
61
+ dragListener: boolean;
62
+ as: keyof import('vue').IntrinsicElementAttributes;
63
+ }, {}>, {
64
+ default?(_: {}): any;
65
+ }>;
66
+ export default _default;
67
+ type __VLS_WithDefaults<P, D> = {
68
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
69
+ default: D[K];
70
+ }> : P[K];
71
+ };
72
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
73
+ type __VLS_TypePropsToOption<T> = {
74
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
75
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
76
+ } : {
77
+ type: import('vue').PropType<T[K]>;
78
+ required: true;
79
+ };
80
+ };
81
+ type __VLS_WithTemplateSlots<T, S> = T & {
82
+ new (): {
83
+ $slots: S;
84
+ };
85
+ };
86
+ type __VLS_PrettifyLocal<T> = {
87
+ [K in keyof T]: T[K];
88
+ } & {};
@@ -0,0 +1,131 @@
1
+ import { defineComponent, toRefs, useAttrs, computed, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
2
+ import { useReorderContext } from "./context.mjs";
3
+ import { useDefaultMotionValue } from "./utils.mjs";
4
+ import { invariant } from "hey-listen";
5
+ import { useTransform } from "../../value/use-transform.mjs";
6
+ import _sfc_main$1 from "../motion/Motion.vue.mjs";
7
+ const _sfc_main = /* @__PURE__ */ defineComponent({
8
+ ...{
9
+ name: "ReorderItem",
10
+ inheritAttrs: false
11
+ },
12
+ __name: "Item",
13
+ props: {
14
+ value: {},
15
+ layout: { type: [Boolean, String], default: true },
16
+ as: { default: "li" },
17
+ asChild: { type: Boolean },
18
+ whileDrag: { default: void 0 },
19
+ custom: {},
20
+ initial: { type: [String, Object, Boolean], default: void 0 },
21
+ animate: { default: void 0 },
22
+ exit: {},
23
+ variants: {},
24
+ style: {},
25
+ transformTemplate: {},
26
+ transition: {},
27
+ layoutGroup: {},
28
+ motionConfig: {},
29
+ onAnimationComplete: {},
30
+ onUpdate: {},
31
+ layoutId: { default: void 0 },
32
+ layoutScroll: { type: Boolean, default: false },
33
+ layoutRoot: { type: Boolean, default: false },
34
+ "data-framer-portal-id": {},
35
+ crossfade: { type: Boolean, default: true },
36
+ onBeforeLayoutMeasure: {},
37
+ onLayoutMeasure: {},
38
+ onLayoutAnimationStart: {},
39
+ onLayoutAnimationComplete: {},
40
+ globalPressTarget: { type: Boolean },
41
+ press: {},
42
+ onPressStart: {},
43
+ onPress: {},
44
+ onPressCancel: {},
45
+ hover: { default: void 0 },
46
+ onHoverStart: {},
47
+ onHoverEnd: {},
48
+ inViewOptions: {},
49
+ inView: { default: void 0 },
50
+ onViewportEnter: {},
51
+ onViewportLeave: {},
52
+ drag: { type: [Boolean, String] },
53
+ dragSnapToOrigin: { type: Boolean },
54
+ dragDirectionLock: { type: Boolean },
55
+ dragPropagation: { type: Boolean },
56
+ dragConstraints: { type: [Boolean, Object] },
57
+ dragElastic: { type: [Boolean, Number, Object], default: 0.5 },
58
+ dragMomentum: { type: Boolean, default: true },
59
+ dragTransition: {},
60
+ dragListener: { type: Boolean, default: true },
61
+ dragControls: {},
62
+ onDragStart: {},
63
+ onDragEnd: {},
64
+ onDrag: {},
65
+ onDirectionLock: {},
66
+ onDragTransitionEnd: {},
67
+ onMeasureDragConstraints: {},
68
+ onPanSessionStart: {},
69
+ onPanStart: {},
70
+ onPan: {},
71
+ onPanEnd: {},
72
+ focus: {},
73
+ onFocus: {},
74
+ onBlur: {}
75
+ },
76
+ setup(__props) {
77
+ var _a, _b;
78
+ const props = __props;
79
+ const { style } = toRefs(props);
80
+ const context = useReorderContext(null);
81
+ const point = {
82
+ x: useDefaultMotionValue((_a = style.value) == null ? void 0 : _a.x),
83
+ y: useDefaultMotionValue((_b = style.value) == null ? void 0 : _b.y)
84
+ };
85
+ const zIndex = useTransform([point.x, point.y], ([latestX, latestY]) => latestX || latestY ? 1 : "unset");
86
+ function warning() {
87
+ invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
88
+ }
89
+ const { axis, registerItem, updateOrder } = context || {};
90
+ const attrs = useAttrs();
91
+ function bindProps() {
92
+ return {
93
+ ...attrs,
94
+ ...props,
95
+ style: {
96
+ ...style.value,
97
+ x: point.x,
98
+ y: point.y,
99
+ zIndex
100
+ }
101
+ };
102
+ }
103
+ const drag = computed(() => {
104
+ if (props.drag) {
105
+ return props.drag;
106
+ }
107
+ return axis.value;
108
+ });
109
+ return (_ctx, _cache) => {
110
+ return openBlock(), createBlock(unref(_sfc_main$1), mergeProps(bindProps(), {
111
+ drag: drag.value,
112
+ "drag-snap-to-origin": true,
113
+ onDrag: _cache[0] || (_cache[0] = (event, gesturePoint) => {
114
+ const { velocity } = gesturePoint;
115
+ velocity[unref(axis)] && unref(updateOrder)(_ctx.value, point[unref(axis)].get(), velocity[unref(axis)]);
116
+ _ctx.onDrag && _ctx.onDrag(event, gesturePoint);
117
+ }),
118
+ onLayoutMeasure: _cache[1] || (_cache[1] = (measured) => unref(registerItem)(_ctx.value, measured))
119
+ }), {
120
+ default: withCtx(() => [
121
+ renderSlot(_ctx.$slots, "default"),
122
+ createTextVNode(" " + toDisplayString(warning()), 1)
123
+ ]),
124
+ _: 3
125
+ }, 16, ["drag"]);
126
+ };
127
+ }
128
+ });
129
+ export {
130
+ _sfc_main as default
131
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./Item.vue.mjs";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,8 @@
1
+ import { Box } from 'framer-motion';
2
+ import { Ref } from 'vue';
3
+ export interface ReorderContextProps<T> {
4
+ axis?: Ref<'x' | 'y'>;
5
+ registerItem?: (item: T, layout: Box) => void;
6
+ updateOrder?: (item: T, offset: number, velocity: number) => void;
7
+ }
8
+ export declare const useReorderContext: <T extends ReorderContextProps<any> = ReorderContextProps<any>>(fallback?: T) => T extends null ? ReorderContextProps<any> : ReorderContextProps<any>, reorderContextProvider: (contextValue: ReorderContextProps<any>) => ReorderContextProps<any>;
@@ -0,0 +1,6 @@
1
+ import { createContext } from "../../utils/createContext.mjs";
2
+ const [useReorderContext, reorderContextProvider] = createContext("ReorderContext");
3
+ export {
4
+ reorderContextProvider,
5
+ useReorderContext
6
+ };
@@ -0,0 +1,13 @@
1
+ import { DefineSetupFnComponent, IntrinsicElementAttributes } from 'vue';
2
+ import { GroupProps } from './Group';
3
+ import { GroupItemProps } from './Item';
4
+ import { ElementType, SVGAttributesWithMotionValues, SetMotionValueType } from '../../types';
5
+ type IntrinsicElementAttributesAsMotionValues = SetMotionValueType<IntrinsicElementAttributes, keyof SVGAttributesWithMotionValues>;
6
+ type ItemProps<T extends ElementType = 'li'> = GroupItemProps<T, unknown, unknown> & IntrinsicElementAttributesAsMotionValues[T];
7
+ export declare const ReorderGroup: DefineSetupFnComponent<GroupProps<ElementType, any, any>>;
8
+ export declare const ReorderItem: DefineSetupFnComponent<ItemProps<ElementType>>;
9
+ export declare const Reorder: {
10
+ Group: DefineSetupFnComponent<GroupProps<keyof IntrinsicElementAttributes, any, any>>;
11
+ Item: DefineSetupFnComponent<ItemProps<keyof IntrinsicElementAttributes>>;
12
+ };
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import _sfc_main from "./Group.vue.mjs";
2
+ import _sfc_main$1 from "./Item.vue.mjs";
3
+ const ReorderGroup = _sfc_main;
4
+ const ReorderItem = _sfc_main$1;
5
+ const Reorder = {
6
+ Group: ReorderGroup,
7
+ Item: ReorderItem
8
+ };
9
+ export {
10
+ Reorder,
11
+ ReorderGroup,
12
+ ReorderItem
13
+ };
@@ -0,0 +1,5 @@
1
+ import { Axis } from 'framer-motion';
2
+ export interface ItemData<T> {
3
+ value: T;
4
+ layout: Axis;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { ItemData } from './types';
2
+ export declare function compareMin<V>(a: ItemData<V>, b: ItemData<V>): number;
3
+ export declare function getValue<V>(item: ItemData<V>): V;
4
+ export declare function checkReorder<T>(order: ItemData<T>[], value: T, offset: number, velocity: number): ItemData<T>[];
5
+ export declare function moveItem<T>([...arr]: T[], fromIndex: number, toIndex: number): T[];
6
+ export declare function useDefaultMotionValue(value: any, defaultValue?: number): import('framer-motion/dom').MotionValue<any>;
@@ -0,0 +1,46 @@
1
+ import { mixNumber } from "../../utils/mix/number.mjs";
2
+ import { motionValue } from "../../external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/value/index.mjs";
3
+ import { isMotionValue } from "../../utils/motion-value.mjs";
4
+ function compareMin(a, b) {
5
+ return a.layout.min - b.layout.min;
6
+ }
7
+ function getValue(item) {
8
+ return item.value;
9
+ }
10
+ function checkReorder(order, value, offset, velocity) {
11
+ if (!velocity)
12
+ return order;
13
+ const index = order.findIndex((item2) => item2.value === value);
14
+ if (index === -1)
15
+ return order;
16
+ const nextOffset = velocity > 0 ? 1 : -1;
17
+ const nextItem = order[index + nextOffset];
18
+ if (!nextItem)
19
+ return order;
20
+ const item = order[index];
21
+ const nextLayout = nextItem.layout;
22
+ const nextItemCenter = mixNumber(nextLayout.min, nextLayout.max, 0.5);
23
+ if (nextOffset === 1 && item.layout.max + offset > nextItemCenter || nextOffset === -1 && item.layout.min + offset < nextItemCenter) {
24
+ return moveItem(order, index, index + nextOffset);
25
+ }
26
+ return order;
27
+ }
28
+ function moveItem([...arr], fromIndex, toIndex) {
29
+ const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
30
+ if (startIndex >= 0 && startIndex < arr.length) {
31
+ const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
32
+ const [item] = arr.splice(fromIndex, 1);
33
+ arr.splice(endIndex, 0, item);
34
+ }
35
+ return arr;
36
+ }
37
+ function useDefaultMotionValue(value, defaultValue = 0) {
38
+ return isMotionValue(value) ? value : motionValue(defaultValue);
39
+ }
40
+ export {
41
+ checkReorder,
42
+ compareMin,
43
+ getValue,
44
+ moveItem,
45
+ useDefaultMotionValue
46
+ };
@@ -3,7 +3,9 @@ const components = {
3
3
  "Motion",
4
4
  "AnimatePresence",
5
5
  "LayoutGroup",
6
- "MotionConfig"
6
+ "MotionConfig",
7
+ "ReorderGroup",
8
+ "ReorderItem"
7
9
  ]
8
10
  };
9
11
  const utilities = {
@@ -1,4 +1,17 @@
1
- export interface LayoutOptions {
1
+ import { Box } from 'framer-motion';
2
+ export interface LayoutLifecycles {
3
+ onBeforeLayoutMeasure?: (box: Box) => void;
4
+ onLayoutMeasure?: (box: Box, prevBox: Box) => void;
5
+ /**
6
+ * @internal
7
+ */
8
+ onLayoutAnimationStart?: () => void;
9
+ /**
10
+ * @internal
11
+ */
12
+ onLayoutAnimationComplete?: () => void;
13
+ }
14
+ export interface LayoutOptions extends LayoutLifecycles {
2
15
  'layout'?: boolean | 'position' | 'size' | 'preserve-aspect';
3
16
  'layoutId'?: string;
4
17
  'layoutScroll'?: boolean;
package/dist/es/index.mjs CHANGED
@@ -41,6 +41,7 @@ import { cancelSync, sync } from "./external/.pnpm/framer-motion@11.16.6/externa
41
41
  import { cancelFrame, frame, frameData, frameSteps } from "./external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/frameloop/frame.mjs";
42
42
  import { motion } from "./components/motion/NameSpace.mjs";
43
43
  import { provideMotionConfig, useMotionConfig } from "./components/motion-config/context.mjs";
44
+ import { Reorder, ReorderGroup, ReorderItem } from "./components/reorder/index.mjs";
44
45
  import { useComputed } from "./value/use-computed.mjs";
45
46
  import { useCombineMotionValues } from "./value/use-combine-values.mjs";
46
47
  import { useTransform } from "./value/use-transform.mjs";
@@ -64,6 +65,9 @@ export {
64
65
  default3 as Motion,
65
66
  default5 as MotionConfig,
66
67
  MotionValue,
68
+ Reorder,
69
+ ReorderGroup,
70
+ ReorderItem,
67
71
  animate,
68
72
  animateMini,
69
73
  anticipate,
@@ -68,6 +68,9 @@ class MotionState {
68
68
  // Initialize animation target values
69
69
  initTarget(initialVariantSource) {
70
70
  this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
71
+ for (const key in this.baseTarget) {
72
+ this.visualElement.setStaticValue(key, this.baseTarget[key]);
73
+ }
71
74
  this.target = {};
72
75
  }
73
76
  // Get initial animation state
@@ -104,15 +107,6 @@ class MotionState {
104
107
  }
105
108
  this.visualElement.state = this;
106
109
  this.updateOptions();
107
- if (typeof this.initial === "object") {
108
- for (const key in this.initial) {
109
- this.visualElement.setStaticValue(key, this.initial[key]);
110
- }
111
- } else if (typeof this.initial === "string" && this.options.variants) {
112
- for (const key in this.options.variants[this.initial]) {
113
- this.visualElement.setStaticValue(key, this.options.variants[this.initial][key]);
114
- }
115
- }
116
110
  this.featureManager.mount();
117
111
  if (!notAnimate && this.options.animate) {
118
112
  this.animateUpdates();
@@ -1,3 +1,3 @@
1
1
  import { Ref } from 'vue';
2
2
  import { Options } from '../types/state';
3
- export declare function useInView<T extends Element = any>(domRef: Ref<T>, options?: Options['inViewOptions'] | Ref<Options['inViewOptions']>): Ref<boolean>;
3
+ export declare function useInView<T extends Element = any>(domRef: Ref<T | null>, options?: Options['inViewOptions'] | Ref<Options['inViewOptions']>): Ref<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -68,6 +68,7 @@
68
68
  "@vue/test-utils": "^2.4.5",
69
69
  "happy-dom": "^16.0.1",
70
70
  "jsdom": "^24.0.0",
71
+ "rimraf": "^6.0.1",
71
72
  "vite": "^5.4.8",
72
73
  "vite-plugin-dts": "^4.2.4",
73
74
  "vitest": "^1.4.0",
@@ -75,7 +76,7 @@
75
76
  },
76
77
  "scripts": {
77
78
  "dev": "vite build --watch",
78
- "build": "rm -rf dist && vite build",
79
+ "build": "rimraf dist && vite build",
79
80
  "test": "vitest --dom",
80
81
  "coverage": "vitest run --coverage",
81
82
  "pub:release": "pnpm publish --access public"