@gamepark/react-game 7.3.2 → 7.4.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.
Files changed (101) hide show
  1. package/dist/components/GameProvider/GameProvider.js +2 -3
  2. package/dist/components/GameProvider/GameProvider.js.map +1 -1
  3. package/dist/components/Header/HeaderText.d.ts +6 -1
  4. package/dist/components/Header/HeaderText.js +14 -5
  5. package/dist/components/Header/HeaderText.js.map +1 -1
  6. package/dist/components/JournalTabs/JournalTabs.js +1 -1
  7. package/dist/components/JournalTabs/JournalTabs.js.map +1 -1
  8. package/dist/components/LoadingScreen/LoadingScreen.js +5 -0
  9. package/dist/components/LoadingScreen/LoadingScreen.js.map +1 -1
  10. package/dist/components/material/DraggableMaterial.d.ts +12 -2
  11. package/dist/components/material/DraggableMaterial.js +47 -57
  12. package/dist/components/material/DraggableMaterial.js.map +1 -1
  13. package/dist/components/material/GameTable/DynamicItemsDisplay.js +53 -8
  14. package/dist/components/material/GameTable/DynamicItemsDisplay.js.map +1 -1
  15. package/dist/components/material/GameTable/GameMaterialDisplay.js +5 -2
  16. package/dist/components/material/GameTable/GameMaterialDisplay.js.map +1 -1
  17. package/dist/components/material/GameTable/GameTable.d.ts +1 -0
  18. package/dist/components/material/GameTable/GameTable.js +49 -18
  19. package/dist/components/material/GameTable/GameTable.js.map +1 -1
  20. package/dist/components/material/GameTable/GameTableNavigation.js +7 -0
  21. package/dist/components/material/GameTable/GameTableNavigation.js.map +1 -1
  22. package/dist/components/material/GameTable/ItemDisplay.js +4 -4
  23. package/dist/components/material/GameTable/ItemDisplay.js.map +1 -1
  24. package/dist/components/material/GameTable/StaticItemsDisplay.js +21 -6
  25. package/dist/components/material/GameTable/StaticItemsDisplay.js.map +1 -1
  26. package/dist/components/material/GameTable/focus/FocusProvider.js +11 -5
  27. package/dist/components/material/GameTable/focus/FocusProvider.js.map +1 -1
  28. package/dist/components/material/GameTable/focus/NoZoomFocusProvider.js +2 -2
  29. package/dist/components/material/GameTable/focus/NoZoomFocusProvider.js.map +1 -1
  30. package/dist/components/material/GameTable/focus/index.d.ts +1 -0
  31. package/dist/components/material/GameTable/focus/index.js +1 -0
  32. package/dist/components/material/GameTable/focus/index.js.map +1 -1
  33. package/dist/components/material/GameTable/index.d.ts +2 -0
  34. package/dist/components/material/GameTable/index.js +2 -0
  35. package/dist/components/material/GameTable/index.js.map +1 -1
  36. package/dist/components/material/MaterialDescription.d.ts +1 -1
  37. package/dist/components/material/MaterialDescription.js +10 -13
  38. package/dist/components/material/MaterialDescription.js.map +1 -1
  39. package/dist/components/material/animations/AnimationBuilder.d.ts +160 -0
  40. package/dist/components/material/animations/AnimationBuilder.js +287 -0
  41. package/dist/components/material/animations/AnimationBuilder.js.map +1 -0
  42. package/dist/components/material/animations/CreateItemAnimations.d.ts +4 -2
  43. package/dist/components/material/animations/CreateItemAnimations.js +91 -10
  44. package/dist/components/material/animations/CreateItemAnimations.js.map +1 -1
  45. package/dist/components/material/animations/DeleteItemAnimations.d.ts +4 -8
  46. package/dist/components/material/animations/DeleteItemAnimations.js +24 -14
  47. package/dist/components/material/animations/DeleteItemAnimations.js.map +1 -1
  48. package/dist/components/material/animations/DeleteItemAtOnceAnimations.d.ts +3 -1
  49. package/dist/components/material/animations/DeleteItemAtOnceAnimations.js +16 -4
  50. package/dist/components/material/animations/DeleteItemAtOnceAnimations.js.map +1 -1
  51. package/dist/components/material/animations/ItemAnimations.d.ts +46 -1
  52. package/dist/components/material/animations/ItemAnimations.js +155 -1
  53. package/dist/components/material/animations/ItemAnimations.js.map +1 -1
  54. package/dist/components/material/animations/MaterialAnimations.d.ts +2 -1
  55. package/dist/components/material/animations/MaterialAnimations.js +6 -6
  56. package/dist/components/material/animations/MaterialAnimations.js.map +1 -1
  57. package/dist/components/material/animations/MaterialGameAnimations.d.ts +94 -1
  58. package/dist/components/material/animations/MaterialGameAnimations.js +150 -2
  59. package/dist/components/material/animations/MaterialGameAnimations.js.map +1 -1
  60. package/dist/components/material/animations/MoveItemAnimations.d.ts +3 -1
  61. package/dist/components/material/animations/MoveItemAnimations.js +51 -7
  62. package/dist/components/material/animations/MoveItemAnimations.js.map +1 -1
  63. package/dist/components/material/animations/MoveItemAtOnceAnimations.d.ts +5 -2
  64. package/dist/components/material/animations/MoveItemAtOnceAnimations.js +57 -5
  65. package/dist/components/material/animations/MoveItemAtOnceAnimations.js.map +1 -1
  66. package/dist/components/material/animations/Trajectory.d.ts +132 -0
  67. package/dist/components/material/animations/Trajectory.js +87 -0
  68. package/dist/components/material/animations/Trajectory.js.map +1 -0
  69. package/dist/components/material/animations/index.d.ts +3 -0
  70. package/dist/components/material/animations/index.js +3 -0
  71. package/dist/components/material/animations/index.js.map +1 -1
  72. package/dist/hooks/index.d.ts +1 -0
  73. package/dist/hooks/index.js +1 -0
  74. package/dist/hooks/index.js.map +1 -1
  75. package/dist/hooks/useLegalMoves.js +2 -1
  76. package/dist/hooks/useLegalMoves.js.map +1 -1
  77. package/dist/hooks/useMaterialContextRef.d.ts +10 -0
  78. package/dist/hooks/useMaterialContextRef.js +12 -0
  79. package/dist/hooks/useMaterialContextRef.js.map +1 -0
  80. package/dist/hooks/usePlayerName.js +1 -1
  81. package/dist/hooks/usePlayerName.js.map +1 -1
  82. package/dist/hooks/useUndo.js +12 -3
  83. package/dist/hooks/useUndo.js.map +1 -1
  84. package/dist/locators/DeckLocator.d.ts +3 -1
  85. package/dist/locators/DeckLocator.js +6 -0
  86. package/dist/locators/DeckLocator.js.map +1 -1
  87. package/dist/locators/HandLocator.d.ts +1 -0
  88. package/dist/locators/HandLocator.js +3 -0
  89. package/dist/locators/HandLocator.js.map +1 -1
  90. package/dist/locators/ListLocator.d.ts +1 -0
  91. package/dist/locators/ListLocator.js +3 -0
  92. package/dist/locators/ListLocator.js.map +1 -1
  93. package/dist/locators/Locator.d.ts +39 -0
  94. package/dist/locators/Locator.js +74 -1
  95. package/dist/locators/Locator.js.map +1 -1
  96. package/dist/locators/PileLocator.d.ts +1 -0
  97. package/dist/locators/PileLocator.js +3 -0
  98. package/dist/locators/PileLocator.js.map +1 -1
  99. package/dist/utilities/translation.util.js +1 -1
  100. package/dist/utilities/translation.util.js.map +1 -1
  101. package/package.json +79 -78
@@ -8,10 +8,12 @@ import { transformItem } from './transformItem.util';
8
8
  export class DeleteItemAnimations extends ItemAnimations {
9
9
  duration;
10
10
  droppedItemDuration;
11
- constructor(duration = 1, droppedItemDuration = 0.2) {
11
+ trajectory;
12
+ constructor(duration = 1, droppedItemDuration = 0.2, trajectory) {
12
13
  super();
13
14
  this.duration = duration;
14
15
  this.droppedItemDuration = droppedItemDuration;
16
+ this.trajectory = trajectory;
15
17
  }
16
18
  getPreDuration(move, context) {
17
19
  const potentialDroppedItem = { type: move.itemType, index: move.itemIndex };
@@ -28,10 +30,7 @@ export class DeleteItemAnimations extends ItemAnimations {
28
30
  const stockItem = getFirstStockItem(context);
29
31
  const stockTransforms = getFirstStockItemTransforms(context);
30
32
  if (stockItem && stockTransforms.length) {
31
- const originTransforms = toSingleRotation(transformItem(context));
32
33
  const targetTransforms = toSingleRotation(stockTransforms);
33
- toClosestRotations(originTransforms, targetTransforms);
34
- const item = getItemFromContext(context);
35
34
  const currentOrigin = context.locators[item.location.type]?.getLocationOrigin(item.location, context) ?? defaultOrigin;
36
35
  const futureOrigin = context.locators[stockItem.location.type]?.getLocationOrigin(stockItem.location, context) ?? defaultOrigin;
37
36
  if (currentOrigin.x !== futureOrigin.x) {
@@ -40,9 +39,27 @@ export class DeleteItemAnimations extends ItemAnimations {
40
39
  if (currentOrigin.y !== futureOrigin.y) {
41
40
  targetTransforms.unshift(`translateY(${getOriginDeltaPosition(boundaries.yMin, boundaries.yMax, futureOrigin.y, currentOrigin.y)}em)`);
42
41
  }
43
- const animationKeyframes = this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
44
- const description = context.material[context.type];
45
- return description?.getAnimationCss(animationKeyframes, animation.duration);
42
+ // For dropped items, only specify the target keyframe (no origin) so CSS animates from the current visual position.
43
+ if (isDroppedItem(context)) {
44
+ const animationKeyframes = this.getKeyframesToDestination(targetTransforms.join(' '), animation, context);
45
+ const description = context.material[context.type];
46
+ return description?.getAnimationCss(animationKeyframes, animation.duration);
47
+ }
48
+ const originTransforms = toSingleRotation(transformItem(context));
49
+ toClosestRotations(originTransforms, targetTransforms);
50
+ // Check if trajectory is configured
51
+ const contextWithTrajectory = context;
52
+ const trajectory = this.trajectory ?? contextWithTrajectory.trajectory;
53
+ if (trajectory) {
54
+ const trajectoryContext = { ...context, trajectory };
55
+ const animationKeyframes = this.getTrajectoryKeyframes(originTransforms, targetTransforms, animation, trajectoryContext);
56
+ return this.getAnimationCssWithTrajectory(animationKeyframes, animation.duration, trajectory.easing, trajectory.elevation);
57
+ }
58
+ else {
59
+ const animationKeyframes = this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
60
+ const description = context.material[context.type];
61
+ return description?.getAnimationCss(animationKeyframes, animation.duration);
62
+ }
46
63
  }
47
64
  else {
48
65
  const fadeout = keyframes `
@@ -53,12 +70,5 @@ export class DeleteItemAnimations extends ItemAnimations {
53
70
  return css `animation: ${fadeout} ${animation.duration}s ease-in-out forwards`;
54
71
  }
55
72
  }
56
- getKeyframesToDestination(destination, _animation, _context) {
57
- return keyframes `
58
- to {
59
- transform: ${destination};
60
- }
61
- `;
62
- }
63
73
  }
64
74
  //# sourceMappingURL=DeleteItemAnimations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteItemAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/DeleteItemAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,SAAS,EAAS,MAAM,gBAAgB,CAAA;AAGrE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAe,MAAM,mBAAmB,CAAA;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,iBAA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CAAC,CAAA;YACjI,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAClD,OAAO,WAAW,EAAE,eAAe,CAAC,kBAAkB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;QAC7E,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,SAAS,CAAA;;;;OAIxB,CAAA;YACD,OAAO,GAAG,CAAA,cAAc,OAAO,IAAI,SAAS,CAAC,QAAQ,wBAAwB,CAAA;QAC/E,CAAC;IACH,CAAC;IAES,yBAAyB,CAAC,WAAmB,EAAE,UAAwC,EAAE,QAA8B;QAC/H,OAAO,SAAS,CAAA;;qBAEC,WAAW;;KAE3B,CAAA;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"DeleteItemAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/DeleteItemAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,SAAS,EAAS,MAAM,gBAAgB,CAAA;AAGrE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAe,MAAM,mBAAmB,CAAA;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA;AACnG,OAAO,EAAE,cAAc,EAA6B,MAAM,kBAAkB,CAAA;AAE5E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,MAAM,OAAO,oBACX,SAAQ,cAAuB;IAGnB;IACA;IACA;IAHZ,YACY,WAAW,CAAC,EACZ,sBAAsB,GAAG,EACzB,UAAgC;QAE1C,KAAK,EAAE,CAAA;QAJG,aAAQ,GAAR,QAAQ,CAAI;QACZ,wBAAmB,GAAnB,mBAAmB,CAAM;QACzB,eAAU,GAAV,UA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AM,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;gBACxH,OAAO,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,EAAE,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;YAC5H,CAAC;iBAAM,CAAC;gBACN,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;gBACjI,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAClD,OAAO,WAAW,EAAE,eAAe,CAAC,kBAAkB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC7E,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,SAAS,CAAA;;;;OAIxB,CAAA;YACD,OAAO,GAAG,CAAA,cAAc,OAAO,IAAI,SAAS,CAAC,QAAQ,wBAAwB,CAAA;QAC/E,CAAC;IACH,CAAC;CACF"}
@@ -3,9 +3,11 @@ import { Animation } from '@gamepark/react-client';
3
3
  import { DeleteItemsAtOnce } from '@gamepark/rules-api';
4
4
  import { ItemContext } from '../../../locators';
5
5
  import { ItemAnimations } from './ItemAnimations';
6
+ import { Trajectory } from './Trajectory';
6
7
  export declare class DeleteItemAtOnceAnimations<P extends number = number, M extends number = number, L extends number = number> extends ItemAnimations<P, M, L> {
7
8
  protected duration: number;
8
- constructor(duration?: number);
9
+ protected trajectory?: Trajectory<P, M, L> | undefined;
10
+ constructor(duration?: number, trajectory?: Trajectory<P, M, L> | undefined);
9
11
  getPreDuration(): number;
10
12
  getItemAnimation(context: ItemContext<P, M, L>, animation: Animation<DeleteItemsAtOnce<M>>): Interpolation<Theme>;
11
13
  getMovedItemAnimation(context: ItemContext<P, M, L>, animation: Animation<DeleteItemsAtOnce<M>>): Interpolation<Theme>;
@@ -5,9 +5,11 @@ import { toClosestRotations, toSingleRotation } from './rotations.utils';
5
5
  import { transformItem } from './transformItem.util';
6
6
  export class DeleteItemAtOnceAnimations extends ItemAnimations {
7
7
  duration;
8
- constructor(duration = 1) {
8
+ trajectory;
9
+ constructor(duration = 1, trajectory) {
9
10
  super();
10
11
  this.duration = duration;
12
+ this.trajectory = trajectory;
11
13
  }
12
14
  getPreDuration() {
13
15
  return this.duration;
@@ -23,9 +25,19 @@ export class DeleteItemAtOnceAnimations extends ItemAnimations {
23
25
  const originTransforms = toSingleRotation(transformItem(context));
24
26
  const targetTransforms = toSingleRotation(stockTransforms);
25
27
  toClosestRotations(originTransforms, targetTransforms);
26
- const animationKeyframes = this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
27
- const description = context.material[context.type];
28
- return description?.getAnimationCss(animationKeyframes, animation.duration);
28
+ // Check if trajectory is configured
29
+ const contextWithTrajectory = context;
30
+ const trajectory = this.trajectory ?? contextWithTrajectory.trajectory;
31
+ if (trajectory) {
32
+ const trajectoryContext = { ...context, trajectory };
33
+ const animationKeyframes = this.getTrajectoryKeyframes(originTransforms, targetTransforms, animation, trajectoryContext);
34
+ return this.getAnimationCssWithTrajectory(animationKeyframes, animation.duration, trajectory.easing, trajectory.elevation);
35
+ }
36
+ else {
37
+ const animationKeyframes = this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
38
+ const description = context.material[context.type];
39
+ return description?.getAnimationCss(animationKeyframes, animation.duration);
40
+ }
29
41
  }
30
42
  else {
31
43
  const fadeout = keyframes `
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteItemAtOnceAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/DeleteItemAtOnceAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,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,QAAQ,CAAC,CAAA;YAC7E,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,SAAS,CAAA;;;;OAIxB,CAAA;YACD,OAAO,GAAG,CAAA,cAAc,OAAO,IAAI,SAAS,CAAC,QAAQ,wBAAwB,CAAA;QAC/E,CAAC;IACH,CAAC;CACF"}
@@ -1,16 +1,61 @@
1
- import { Interpolation, Theme } from '@emotion/react';
1
+ import { Interpolation, keyframes, Theme } from '@emotion/react';
2
2
  import { Animation, Animations } from '@gamepark/react-client';
3
3
  import { DisplayedItem, GridBoundaries, ItemMove, MaterialGame, MaterialMove } from '@gamepark/rules-api';
4
4
  import { ItemContext, MaterialContext } from '../../../locators';
5
5
  import { MaterialGameAnimationContext } from './MaterialGameAnimations';
6
+ import { ElevationConfig, Trajectory } from './Trajectory';
7
+ /**
8
+ * Extended ItemContext that includes trajectory configuration.
9
+ */
10
+ export type ItemContextWithTrajectory<P extends number = number, M extends number = number, L extends number = number> = ItemContext<P, M, L> & {
11
+ trajectory?: Trajectory<P, M, L>;
12
+ };
6
13
  export declare class ItemAnimations<P extends number = number, M extends number = number, L extends number = number> extends Animations<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> {
7
14
  getItemAnimation(_context: ItemContext<P, M, L>, _animation: Animation<MaterialMove<P, M, L>>, _boundaries: GridBoundaries): Interpolation<Theme>;
8
15
  getMaterialContext({ Rules, game, material, locators, playerId }: MaterialGameAnimationContext<P, M, L>): MaterialContext<P, M, L>;
9
16
  getItemContext(context: MaterialGameAnimationContext<P, M, L>, item: Omit<DisplayedItem<M>, 'displayIndex'>): Omit<ItemContext<P, M, L>, 'displayIndex'>;
17
+ /**
18
+ * Generate simple from/to keyframes (legacy method).
19
+ */
10
20
  protected getTransformKeyframes(origin: string, destination: string, _animation: Animation<ItemMove<P, M, L>>, _context: ItemContext<P, M, L>): {
11
21
  name: string;
12
22
  styles: string;
13
23
  anim: 1;
14
24
  toString: () => string;
15
25
  } & string;
26
+ /**
27
+ * Generate keyframes with only a destination (no origin).
28
+ * CSS will animate from the element's current visual state.
29
+ * Used for dropped items where the drag transform is not available in the animation context.
30
+ */
31
+ protected getKeyframesToDestination(destination: string, _animation: Animation<ItemMove<P, M, L>>, _context: ItemContext<P, M, L>): {
32
+ name: string;
33
+ styles: string;
34
+ anim: 1;
35
+ toString: () => string;
36
+ } & string;
37
+ /**
38
+ * Generate keyframes with integrated elevation and optional waypoints.
39
+ * The elevation is prepended to the transform chain so it operates in world coordinates.
40
+ *
41
+ * @param originTransforms Array of CSS transforms for the starting position
42
+ * @param targetTransforms Array of CSS transforms for the ending position
43
+ * @param animation The animation context
44
+ * @param context The item context (may include trajectory configuration)
45
+ */
46
+ protected getTrajectoryKeyframes(originTransforms: string[], targetTransforms: string[], animation: Animation<ItemMove<P, M, L>>, context: ItemContextWithTrajectory<P, M, L>): {
47
+ name: string;
48
+ styles: string;
49
+ anim: 1;
50
+ toString: () => string;
51
+ } & string;
52
+ /**
53
+ * Generate animation CSS with elevation on the parent div and position on the child div.
54
+ *
55
+ * @param animationKeyframes The generated keyframes for position (child div)
56
+ * @param duration Animation duration in seconds
57
+ * @param easing CSS easing function
58
+ * @param elevationConfig Elevation configuration for the parent div arc
59
+ */
60
+ protected getAnimationCssWithTrajectory(animationKeyframes: ReturnType<typeof keyframes>, duration: number, easing?: string, elevationConfig?: ElevationConfig | false): Interpolation<Theme>;
16
61
  }
@@ -1,5 +1,7 @@
1
- import { keyframes } from '@emotion/react';
1
+ import { css, keyframes } from '@emotion/react';
2
2
  import { Animations } from '@gamepark/react-client';
3
+ import { getItemFromContext } from '../../../locators';
4
+ import { defaultElevation, extractTranslation, getElevationKeyframes, interpolateCoordinate } from './Trajectory';
3
5
  export class ItemAnimations extends Animations {
4
6
  getItemAnimation(_context, _animation, _boundaries) {
5
7
  return;
@@ -10,6 +12,9 @@ export class ItemAnimations extends Animations {
10
12
  getItemContext(context, item) {
11
13
  return { ...this.getMaterialContext(context), ...item };
12
14
  }
15
+ /**
16
+ * Generate simple from/to keyframes (legacy method).
17
+ */
13
18
  getTransformKeyframes(origin, destination, _animation, _context) {
14
19
  return keyframes `
15
20
  from {
@@ -20,5 +25,154 @@ export class ItemAnimations extends Animations {
20
25
  }
21
26
  `;
22
27
  }
28
+ /**
29
+ * Generate keyframes with only a destination (no origin).
30
+ * CSS will animate from the element's current visual state.
31
+ * Used for dropped items where the drag transform is not available in the animation context.
32
+ */
33
+ getKeyframesToDestination(destination, _animation, _context) {
34
+ return keyframes `
35
+ to {
36
+ transform: ${destination};
37
+ }
38
+ `;
39
+ }
40
+ /**
41
+ * Generate keyframes with integrated elevation and optional waypoints.
42
+ * The elevation is prepended to the transform chain so it operates in world coordinates.
43
+ *
44
+ * @param originTransforms Array of CSS transforms for the starting position
45
+ * @param targetTransforms Array of CSS transforms for the ending position
46
+ * @param animation The animation context
47
+ * @param context The item context (may include trajectory configuration)
48
+ */
49
+ getTrajectoryKeyframes(originTransforms, targetTransforms, animation, context) {
50
+ const waypoints = context.trajectory?.waypoints ?? [];
51
+ // If no waypoints, use simple keyframes
52
+ if (waypoints.length === 0) {
53
+ return this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
54
+ }
55
+ // Collect all time points
56
+ const timePoints = new Set([0, 1]);
57
+ // Add waypoint times
58
+ waypoints.forEach(w => timePoints.add(w.at));
59
+ const sortedTimes = [...timePoints].sort((a, b) => a - b);
60
+ // Extract coordinates for interpolation
61
+ const originCoords = extractTranslation(originTransforms);
62
+ const targetCoords = extractTranslation(targetTransforms);
63
+ // Build keyframes
64
+ const frames = [];
65
+ for (const t of sortedTimes) {
66
+ // Find if there's a waypoint at this time
67
+ const waypoint = waypoints.find(w => Math.abs(w.at - t) < 0.001);
68
+ // Calculate base interpolated position
69
+ let x = interpolateCoordinate(originCoords.x, targetCoords.x, t);
70
+ let y = interpolateCoordinate(originCoords.y, targetCoords.y, t);
71
+ let z = interpolateCoordinate(originCoords.z, targetCoords.z, t);
72
+ // Apply waypoint modifications
73
+ if (waypoint) {
74
+ if (waypoint.offset) {
75
+ x += waypoint.offset.x ?? 0;
76
+ y += waypoint.offset.y ?? 0;
77
+ z += waypoint.offset.z ?? 0;
78
+ }
79
+ if (waypoint.coordinates) {
80
+ x = waypoint.coordinates.x ?? x;
81
+ y = waypoint.coordinates.y ?? y;
82
+ z = waypoint.coordinates.z ?? z;
83
+ }
84
+ }
85
+ // Build transform string
86
+ const transforms = [];
87
+ // Handle locator waypoints: use full transforms from the locator
88
+ if (waypoint?.locator !== undefined) {
89
+ const locator = waypoint.locator;
90
+ const resolvedLocation = typeof waypoint.location === 'function'
91
+ ? waypoint.location(getItemFromContext(context))
92
+ : waypoint.location;
93
+ const location = { ...resolvedLocation };
94
+ const fakeItem = { location };
95
+ const locatorTransforms = locator.placeItem(fakeItem, context);
96
+ transforms.push('translate(-50%, -50%)');
97
+ transforms.push(...locatorTransforms);
98
+ }
99
+ else if (t === 0 && !waypoint) {
100
+ transforms.push(...originTransforms);
101
+ }
102
+ else if (t === 1 && !waypoint) {
103
+ transforms.push(...targetTransforms);
104
+ }
105
+ else {
106
+ // Build interpolated transforms
107
+ transforms.push('translate(-50%, -50%)');
108
+ transforms.push(`translate3d(${x}em, ${y}em, ${z}em)`);
109
+ // Interpolate rotation if present
110
+ const originRotation = extractRotation(originTransforms);
111
+ const targetRotation = extractRotation(targetTransforms);
112
+ if (originRotation !== undefined || targetRotation !== undefined) {
113
+ const rotation = interpolateCoordinate(originRotation ?? 0, targetRotation ?? 0, t);
114
+ if (rotation !== 0) {
115
+ transforms.push(`rotateZ(${rotation}deg)`);
116
+ }
117
+ }
118
+ }
119
+ const percent = Math.round(t * 100);
120
+ const transformString = transforms.join(' ');
121
+ // Add easing for this segment if specified in waypoint
122
+ const easing = waypoint?.easing;
123
+ if (easing && t < 1) {
124
+ frames.push(`${percent}% { transform: ${transformString}; animation-timing-function: ${easing}; }`);
125
+ }
126
+ else {
127
+ frames.push(`${percent}% { transform: ${transformString}; }`);
128
+ }
129
+ }
130
+ return keyframes `${frames.join('\n')}`;
131
+ }
132
+ /**
133
+ * Generate animation CSS with elevation on the parent div and position on the child div.
134
+ *
135
+ * @param animationKeyframes The generated keyframes for position (child div)
136
+ * @param duration Animation duration in seconds
137
+ * @param easing CSS easing function
138
+ * @param elevationConfig Elevation configuration for the parent div arc
139
+ */
140
+ getAnimationCssWithTrajectory(animationKeyframes, duration, easing = 'ease-in-out', elevationConfig) {
141
+ if (elevationConfig !== false) {
142
+ const resolvedElevation = elevationConfig ?? defaultElevation;
143
+ const elevationArc = getElevationKeyframes(resolvedElevation);
144
+ return css `
145
+ animation: ${elevationArc} ${duration}s ease-in-out forwards;
146
+ > * {
147
+ animation: ${animationKeyframes} ${duration}s ${easing} forwards;
148
+ }
149
+ `;
150
+ }
151
+ return css `
152
+ > * {
153
+ animation: ${animationKeyframes} ${duration}s ${easing} forwards;
154
+ }
155
+ `;
156
+ }
157
+ }
158
+ /**
159
+ * Extract rotation value from transform array.
160
+ * @param transforms Array of CSS transform strings
161
+ * @returns Rotation in degrees, or undefined if no rotation found
162
+ */
163
+ function extractRotation(transforms) {
164
+ for (const transform of transforms) {
165
+ const rotateZMatch = transform.match(/rotateZ\(\s*([-\d.]+)(deg|rad|turn)?\s*\)/);
166
+ if (rotateZMatch) {
167
+ const value = parseFloat(rotateZMatch[1]);
168
+ const unit = rotateZMatch[2] || 'deg';
169
+ if (unit === 'rad')
170
+ return value * (180 / Math.PI);
171
+ if (unit === 'turn')
172
+ return value * 360;
173
+ return value;
174
+ }
175
+ }
176
+ return undefined;
23
177
  }
24
178
  //# sourceMappingURL=ItemAnimations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ItemAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/ItemAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAS,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAa,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAK9D,MAAM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EAChD,QAAgB,EAChB,SAAiB,aAAa,EAC9B,eAAyC;QAEzC,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;YAC9B,MAAM,iBAAiB,GAAG,eAAe,IAAI,gBAAgB,CAAA;YAC7D,MAAM,YAAY,GAAG,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;YAC7D,OAAO,GAAG,CAAA;qBACK,YAAY,IAAI,QAAQ;;uBAEtB,kBAAkB,IAAI,QAAQ,KAAK,MAAM;;OAEzD,CAAA;QACH,CAAC;QACD,OAAO,GAAG,CAAA;;qBAEO,kBAAkB,IAAI,QAAQ,KAAK,MAAM;;KAEzD,CAAA;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,UAAoB;IAC3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;QACjF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;YACzC,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,KAAK,CAAA;YACrC,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAA;YAClD,IAAI,IAAI,KAAK,MAAM;gBAAE,OAAO,KAAK,GAAG,GAAG,CAAA;YACvC,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -5,9 +5,10 @@ import { ItemContext, Locator } from '../../../locators';
5
5
  import { MaterialDescription } from '../MaterialDescription';
6
6
  import { ItemAnimations } from './ItemAnimations';
7
7
  import { MaterialGameAnimationContext } from './MaterialGameAnimations';
8
+ import { Trajectory } from './Trajectory';
8
9
  export declare class MaterialAnimations<P extends number = number, M extends number = number, L extends number = number> extends Animations<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> {
9
10
  protected readonly animations: Partial<Record<ItemMoveType, ItemAnimations<P, M, L>>>;
10
- constructor(duration?: number, droppedItemDuration?: number);
11
+ constructor(duration?: number, droppedItemDuration?: number, trajectory?: Trajectory<P, M, L>);
11
12
  getDuration(move: ItemMove<P, M, L>, context: MaterialGameAnimationContext<P, M, L>): number;
12
13
  getItemAnimation(context: ItemContext<P, M, L>, animation: Animation<MaterialMove<P, M, L>>, boundaries: GridBoundaries): Interpolation<Theme>;
13
14
  }
@@ -9,14 +9,14 @@ import { RollItemAnimations } from './RollItemAnimations';
9
9
  import { ShuffleAnimations } from './ShuffleAnimations';
10
10
  export class MaterialAnimations extends Animations {
11
11
  animations;
12
- constructor(duration = 1, droppedItemDuration = 0.2) {
12
+ constructor(duration = 1, droppedItemDuration = 0.2, trajectory) {
13
13
  super();
14
14
  this.animations = {
15
- [ItemMoveType.Create]: new CreateItemAnimations(duration),
16
- [ItemMoveType.Move]: new MoveItemAnimations(duration, droppedItemDuration),
17
- [ItemMoveType.MoveAtOnce]: new MoveItemAtOnceAnimations(duration),
18
- [ItemMoveType.Delete]: new DeleteItemAnimations(duration, droppedItemDuration),
19
- [ItemMoveType.DeleteAtOnce]: new DeleteItemAtOnceAnimations(duration),
15
+ [ItemMoveType.Create]: new CreateItemAnimations(duration, trajectory),
16
+ [ItemMoveType.Move]: new MoveItemAnimations(duration, droppedItemDuration, trajectory),
17
+ [ItemMoveType.MoveAtOnce]: new MoveItemAtOnceAnimations(duration, trajectory),
18
+ [ItemMoveType.Delete]: new DeleteItemAnimations(duration, droppedItemDuration, trajectory),
19
+ [ItemMoveType.DeleteAtOnce]: new DeleteItemAtOnceAnimations(duration, trajectory),
20
20
  [ItemMoveType.Shuffle]: new ShuffleAnimations(0),
21
21
  [ItemMoveType.Roll]: new RollItemAnimations(duration)
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialAnimations.js","sourceRoot":"","sources":["../../../../src/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,kBAAkB,CAAC,QAAQ,CAAC;SACtD,CAAA;IACH,CAAC;IAED,WAAW,CAAC,IAAuB,EAAE,OAA8C;QACjF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IACpE,CAAC;IAED,gBAAgB,CAAC,OAA6B,EAAE,SAA2C,EAAE,UAA0B;QACrH,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,QAAQ;YAAE,OAAM;QACrD,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,CAAA;IAC/F,CAAC;CACF"}
1
+ {"version":3,"file":"MaterialAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/MaterialAnimations.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAA4B,YAAY,EAA6C,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGjI,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,MAAM,OAAO,kBACX,SAAQ,UAA2D;IAEhD,UAAU,CAAwD;IAErF,YAAY,QAAQ,GAAG,CAAC,EAAE,mBAAmB,GAAG,GAAG,EAAE,UAAgC;QACnF,KA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ction } from '@gamepark/react-client';
3
- import { GridBoundaries, MaterialGame, MaterialMove } from '@gamepark/rules-api';
3
+ import { GridBoundaries, ItemMove, MaterialGame, MaterialMove } from '@gamepark/rules-api';
4
4
  import { ItemContext, MaterialContext } from '../../../locators';
5
5
  import { GameContext } from '../../GameProvider';
6
6
  import { MaterialSoundConfig } from '../sound';
7
+ import { AnimationBuilder, AnimationPredicate } from './AnimationBuilder';
7
8
  import { ItemAnimations } from './ItemAnimations';
8
9
  export type MaterialGameAnimationContext<P extends number = number, M extends number = number, L extends number = number> = AnimationContext<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> & Omit<GameContext<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P, M, L>, 'game'>;
9
10
  export type MaterialAnimationContext<P extends number = number, M extends number = number, L extends number = number> = MaterialContext<P, M, L> & {
10
11
  action: DisplayedAction<MaterialMove<P, M, L>, P>;
11
12
  };
12
13
  export declare class MaterialGameAnimations<P extends number = number, M extends number = number, L extends number = number> extends Animations<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> {
14
+ /** @internal Animation configurations from the legacy .when() API */
13
15
  readonly animationConfigs: AnimationConfig<P, M, L>[];
16
+ /** @internal Animation builders from the new .configure() API */
17
+ readonly animationBuilders: AnimationBuilder<P, M, L>[];
18
+ /** @internal Default animation configuration */
14
19
  defaultAnimationConfig: AnimationConfig<P, M, L>;
20
+ /** @internal Default animation builder for new API */
21
+ private _defaultBuilder;
22
+ /**
23
+ * @deprecated Use configure() instead for the new trajectory API.
24
+ * Create a new animation configuration with filter chain.
25
+ */
15
26
  when(): AnimationConfig<P, M, L>;
27
+ /**
28
+ * Configure animations for moves matching a predicate.
29
+ * @param predicate Function to determine if this configuration applies
30
+ * @returns AnimationBuilder for fluent configuration
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * animations.configure(and(isRule(RuleId.PlayCard), isMyMove()))
35
+ * .duration(800)
36
+ * .arc(15)
37
+ * ```
38
+ */
39
+ configure(predicate: AnimationPredicate<P, M, L>): AnimationBuilder<P, M, L>;
40
+ /**
41
+ * Configure animations for moves during a specific rule.
42
+ * @param ruleId The rule ID to match
43
+ * @returns AnimationBuilder for fluent configuration
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * animations.forRule(RuleId.PlayCard)
48
+ * .duration(600)
49
+ * .via(LocationType.TableCenter)
50
+ * ```
51
+ */
52
+ forRule(ruleId: number): AnimationBuilder<P, M, L>;
53
+ /**
54
+ * Configure animations for a specific item move type.
55
+ * @param moveType The item move type to match (Create, Move, Delete, etc.)
56
+ * @returns AnimationBuilder for fluent configuration
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * animations.forMove(ItemMoveType.Move)
61
+ * .duration(500)
62
+ * .arc(12)
63
+ * ```
64
+ */
65
+ forMove(moveType: ItemMove<P, M, L>['type']): AnimationBuilder<P, M, L>;
66
+ /**
67
+ * Configure animations for a specific material type.
68
+ * @param materialType The material type to match
69
+ * @returns AnimationBuilder for fluent configuration
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * animations.forMaterial(MaterialType.Card)
74
+ * .duration(400)
75
+ * .flat() // No arc for cards
76
+ * ```
77
+ */
78
+ forMaterial(materialType: M): AnimationBuilder<P, M, L>;
79
+ /**
80
+ * Configure default animations (applies to all moves not matched by other configurations).
81
+ * @returns AnimationBuilder for fluent configuration
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * animations.defaults()
86
+ * .duration(600)
87
+ * .arc({ height: 8, peak: 0.4 })
88
+ * ```
89
+ */
90
+ defaults(): AnimationBuilder<P, M, L>;
16
91
  getDuration(move: MaterialMove<P, M, L>, context: MaterialGameAnimationContext<P, M, L>): number;
92
+ /**
93
+ * Find matching animation builder from new API.
94
+ * @internal
95
+ */
96
+ getAnimationBuilder(move: MaterialMove<P, M, L>, context: MaterialAnimationContext<P, M, L>): AnimationBuilder<P, M, L> | undefined;
97
+ /**
98
+ * Find matching animation config from legacy API.
99
+ * @internal
100
+ */
17
101
  getAnimationConfig(move: MaterialMove<P, M, L>, context: MaterialAnimationContext<P, M, L>): AnimationConfig<P, M, L>;
102
+ /**
103
+ * Get item animation CSS, checking both new and legacy APIs.
104
+ * @internal
105
+ */
106
+ getItemAnimation(context: ItemContext<P, M, L>, animation: Animation<MaterialMove<P, M, L>>, action: DisplayedAction<MaterialMove<P, M, L>, P>, boundaries: GridBoundaries): Interpolation<Theme>;
18
107
  getSounds(): string[];
19
108
  pauseNextConsequenceAnimation(move: MaterialMove<P, M, L>, _context: AnimationContext<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P>): boolean;
20
109
  }
110
+ /**
111
+ * @deprecated Use AnimationBuilder with the new configure() API instead.
112
+ * Legacy animation configuration class for backward compatibility.
113
+ */
21
114
  declare class AnimationConfig<P extends number = number, M extends number = number, L extends number = number> extends ItemAnimations<P, M, L> {
22
115
  filters: ((move: MaterialMove<P, M, L>, context: MaterialAnimationContext<P, M, L>) => boolean)[];
23
116
  d?: number;