@elementor/editor-interactions 4.0.0-650 → 4.0.0-660

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/index.d.mts CHANGED
@@ -34,6 +34,8 @@ type FieldProps<T = string> = {
34
34
  anchorRef?: RefObject<HTMLElement | null>;
35
35
  };
36
36
  type ReplayFieldProps = FieldProps<boolean>;
37
+ type RepeatFieldProps = FieldProps<string>;
38
+ type TimesFieldProps = FieldProps<number>;
37
39
  type DirectionFieldProps = FieldProps<string> & {
38
40
  interactionType: string;
39
41
  };
@@ -77,7 +79,7 @@ declare const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-int
77
79
 
78
80
  declare function init(): void;
79
81
 
80
- type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | 'start' | 'end' | 'customEffects';
82
+ type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'repeat' | 'times' | 'easing' | 'relativeTo' | 'start' | 'end' | 'customEffects';
81
83
  type InteractionsControlPropsMap = {
82
84
  trigger: FieldProps;
83
85
  effect: FieldProps;
@@ -87,6 +89,8 @@ type InteractionsControlPropsMap = {
87
89
  duration: FieldProps;
88
90
  delay: FieldProps;
89
91
  replay: ReplayFieldProps;
92
+ repeat: RepeatFieldProps;
93
+ times: TimesFieldProps;
90
94
  easing: FieldProps;
91
95
  relativeTo: FieldProps;
92
96
  start: FieldProps;
@@ -137,10 +141,12 @@ declare const createString: (value: string) => StringPropValue;
137
141
  declare const createNumber: (value: number) => NumberPropValue;
138
142
  declare const createTimingConfig: (duration: SizeStringValue, delay: SizeStringValue) => TimingConfigPropValue;
139
143
  declare const createBoolean: (value: boolean) => BooleanPropValue;
140
- declare const createConfig: ({ replay, easing, relativeTo, start, end, }: {
144
+ declare const createConfig: ({ replay, easing, relativeTo, repeat, times, start, end, }: {
141
145
  replay: boolean;
142
146
  easing?: string;
143
147
  relativeTo?: string;
148
+ repeat?: string;
149
+ times?: number;
144
150
  start?: SizeStringValue;
145
151
  end?: SizeStringValue;
146
152
  }) => ConfigPropValue;
@@ -148,7 +154,7 @@ declare const extractBoolean: (prop: BooleanPropValue | undefined, fallback?: bo
148
154
  declare const createExcludedBreakpoints: (breakpoints: string[]) => ExcludedBreakpointsPropValue;
149
155
  declare const createInteractionBreakpoints: (excluded: string[]) => InteractionBreakpointsPropValue;
150
156
  declare const extractExcludedBreakpoints: (breakpoints: InteractionBreakpointsPropValue | undefined) => string[];
151
- declare const createAnimationPreset: ({ effect, type, direction, duration, delay, replay, easing, relativeTo, start, end, customEffects, }: {
157
+ declare const createAnimationPreset: ({ effect, type, direction, duration, delay, replay, easing, relativeTo, repeat, times, start, end, customEffects, }: {
152
158
  effect: string;
153
159
  type: string;
154
160
  direction?: string;
@@ -157,11 +163,13 @@ declare const createAnimationPreset: ({ effect, type, direction, duration, delay
157
163
  replay: boolean;
158
164
  easing?: string;
159
165
  relativeTo?: string;
166
+ repeat?: string;
167
+ times?: number;
160
168
  start?: SizeStringValue;
161
169
  end?: SizeStringValue;
162
170
  customEffects?: PropValue;
163
171
  }) => AnimationPresetPropValue;
164
- declare const createInteractionItem: ({ trigger, effect, type, direction, duration, delay, interactionId, replay, easing, relativeTo, start, end, excludedBreakpoints, customEffects, }: {
172
+ declare const createInteractionItem: ({ trigger, effect, type, direction, duration, delay, interactionId, replay, easing, relativeTo, repeat, times, start, end, excludedBreakpoints, customEffects, }: {
165
173
  trigger?: string;
166
174
  effect?: string;
167
175
  type?: string;
@@ -172,6 +180,8 @@ declare const createInteractionItem: ({ trigger, effect, type, direction, durati
172
180
  replay?: boolean;
173
181
  easing?: string;
174
182
  relativeTo?: string;
183
+ repeat?: string;
184
+ times?: number;
175
185
  start?: number;
176
186
  end?: number;
177
187
  excludedBreakpoints?: string[];
package/dist/index.d.ts CHANGED
@@ -34,6 +34,8 @@ type FieldProps<T = string> = {
34
34
  anchorRef?: RefObject<HTMLElement | null>;
35
35
  };
36
36
  type ReplayFieldProps = FieldProps<boolean>;
37
+ type RepeatFieldProps = FieldProps<string>;
38
+ type TimesFieldProps = FieldProps<number>;
37
39
  type DirectionFieldProps = FieldProps<string> & {
38
40
  interactionType: string;
39
41
  };
@@ -77,7 +79,7 @@ declare const ELEMENTS_INTERACTIONS_PROVIDER_KEY_PREFIX = "document-elements-int
77
79
 
78
80
  declare function init(): void;
79
81
 
80
- type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'easing' | 'relativeTo' | 'start' | 'end' | 'customEffects';
82
+ type InteractionsControlType = 'trigger' | 'effect' | 'effectType' | 'direction' | 'duration' | 'delay' | 'replay' | 'repeat' | 'times' | 'easing' | 'relativeTo' | 'start' | 'end' | 'customEffects';
81
83
  type InteractionsControlPropsMap = {
82
84
  trigger: FieldProps;
83
85
  effect: FieldProps;
@@ -87,6 +89,8 @@ type InteractionsControlPropsMap = {
87
89
  duration: FieldProps;
88
90
  delay: FieldProps;
89
91
  replay: ReplayFieldProps;
92
+ repeat: RepeatFieldProps;
93
+ times: TimesFieldProps;
90
94
  easing: FieldProps;
91
95
  relativeTo: FieldProps;
92
96
  start: FieldProps;
@@ -137,10 +141,12 @@ declare const createString: (value: string) => StringPropValue;
137
141
  declare const createNumber: (value: number) => NumberPropValue;
138
142
  declare const createTimingConfig: (duration: SizeStringValue, delay: SizeStringValue) => TimingConfigPropValue;
139
143
  declare const createBoolean: (value: boolean) => BooleanPropValue;
140
- declare const createConfig: ({ replay, easing, relativeTo, start, end, }: {
144
+ declare const createConfig: ({ replay, easing, relativeTo, repeat, times, start, end, }: {
141
145
  replay: boolean;
142
146
  easing?: string;
143
147
  relativeTo?: string;
148
+ repeat?: string;
149
+ times?: number;
144
150
  start?: SizeStringValue;
145
151
  end?: SizeStringValue;
146
152
  }) => ConfigPropValue;
@@ -148,7 +154,7 @@ declare const extractBoolean: (prop: BooleanPropValue | undefined, fallback?: bo
148
154
  declare const createExcludedBreakpoints: (breakpoints: string[]) => ExcludedBreakpointsPropValue;
149
155
  declare const createInteractionBreakpoints: (excluded: string[]) => InteractionBreakpointsPropValue;
150
156
  declare const extractExcludedBreakpoints: (breakpoints: InteractionBreakpointsPropValue | undefined) => string[];
151
- declare const createAnimationPreset: ({ effect, type, direction, duration, delay, replay, easing, relativeTo, start, end, customEffects, }: {
157
+ declare const createAnimationPreset: ({ effect, type, direction, duration, delay, replay, easing, relativeTo, repeat, times, start, end, customEffects, }: {
152
158
  effect: string;
153
159
  type: string;
154
160
  direction?: string;
@@ -157,11 +163,13 @@ declare const createAnimationPreset: ({ effect, type, direction, duration, delay
157
163
  replay: boolean;
158
164
  easing?: string;
159
165
  relativeTo?: string;
166
+ repeat?: string;
167
+ times?: number;
160
168
  start?: SizeStringValue;
161
169
  end?: SizeStringValue;
162
170
  customEffects?: PropValue;
163
171
  }) => AnimationPresetPropValue;
164
- declare const createInteractionItem: ({ trigger, effect, type, direction, duration, delay, interactionId, replay, easing, relativeTo, start, end, excludedBreakpoints, customEffects, }: {
172
+ declare const createInteractionItem: ({ trigger, effect, type, direction, duration, delay, interactionId, replay, easing, relativeTo, repeat, times, start, end, excludedBreakpoints, customEffects, }: {
165
173
  trigger?: string;
166
174
  effect?: string;
167
175
  type?: string;
@@ -172,6 +180,8 @@ declare const createInteractionItem: ({ trigger, effect, type, direction, durati
172
180
  replay?: boolean;
173
181
  easing?: string;
174
182
  relativeTo?: string;
183
+ repeat?: string;
184
+ times?: number;
175
185
  start?: number;
176
186
  end?: number;
177
187
  excludedBreakpoints?: string[];
package/dist/index.js CHANGED
@@ -280,6 +280,8 @@ var createConfig = ({
280
280
  replay,
281
281
  easing = "easeIn",
282
282
  relativeTo = "",
283
+ repeat = "",
284
+ times = 1,
283
285
  start = 85,
284
286
  end = 15
285
287
  }) => ({
@@ -288,6 +290,8 @@ var createConfig = ({
288
290
  replay: createBoolean(replay),
289
291
  easing: createString(easing),
290
292
  relativeTo: createString(relativeTo),
293
+ repeat: createString(repeat),
294
+ times: createNumber(times),
291
295
  start: createSize(start, "%"),
292
296
  end: createSize(end, "%")
293
297
  }
@@ -323,6 +327,8 @@ var createAnimationPreset = ({
323
327
  replay = false,
324
328
  easing = "easeIn",
325
329
  relativeTo,
330
+ repeat,
331
+ times,
326
332
  start,
327
333
  end,
328
334
  customEffects
@@ -338,6 +344,8 @@ var createAnimationPreset = ({
338
344
  replay,
339
345
  easing,
340
346
  relativeTo,
347
+ repeat,
348
+ times,
341
349
  start,
342
350
  end
343
351
  })
@@ -354,6 +362,8 @@ var createInteractionItem = ({
354
362
  replay = false,
355
363
  easing = "easeIn",
356
364
  relativeTo,
365
+ repeat,
366
+ times,
357
367
  start,
358
368
  end,
359
369
  excludedBreakpoints,
@@ -372,6 +382,8 @@ var createInteractionItem = ({
372
382
  replay,
373
383
  easing,
374
384
  relativeTo,
385
+ repeat,
386
+ times,
375
387
  start,
376
388
  end,
377
389
  customEffects
@@ -544,6 +556,8 @@ var DEFAULT_VALUES = {
544
556
  replay: false,
545
557
  easing: "easeIn",
546
558
  relativeTo: "viewport",
559
+ repeat: "",
560
+ times: 1,
547
561
  start: 85,
548
562
  end: 15
549
563
  };
@@ -556,6 +570,8 @@ var controlVisibilityConfig = {
556
570
  relativeTo: (values) => values.trigger === "scrollOn",
557
571
  start: (values) => values.trigger === "scrollOn",
558
572
  end: (values) => values.trigger === "scrollOn",
573
+ repeat: (values) => values.trigger !== "scrollOn",
574
+ times: (values) => values.trigger !== "scrollOn" && values.repeat === "times",
559
575
  duration: (values) => {
560
576
  const isRelativeToVisible = values.trigger === "scrollOn";
561
577
  return !isRelativeToVisible;
@@ -565,6 +581,13 @@ var controlVisibilityConfig = {
565
581
  return !isRelativeToVisible;
566
582
  }
567
583
  };
584
+ function normalizeTimesValue(value, fallback) {
585
+ const numericValue = Number(value);
586
+ if (!Number.isFinite(numericValue)) {
587
+ return fallback;
588
+ }
589
+ return Math.max(1, Math.floor(numericValue));
590
+ }
568
591
  function useControlComponent(controlName, isVisible = true) {
569
592
  return (0, import_react5.useMemo)(() => {
570
593
  if (!isVisible) {
@@ -584,6 +607,9 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
584
607
  const replay = extractBoolean(interaction.animation.value.config?.value.replay, DEFAULT_VALUES.replay);
585
608
  const easing = extractString(interaction.animation.value.config?.value.easing, DEFAULT_VALUES.easing);
586
609
  const relativeTo = extractString(interaction.animation.value.config?.value.relativeTo, DEFAULT_VALUES.relativeTo);
610
+ const configValue = interaction.animation.value.config?.value;
611
+ const repeat = extractString(configValue?.repeat, DEFAULT_VALUES.repeat);
612
+ const times = normalizeTimesValue(configValue?.times?.value, DEFAULT_VALUES.times);
587
613
  const start = extractSize(interaction.animation.value.config?.value.start, DEFAULT_VALUES.start);
588
614
  const end = extractSize(interaction.animation.value.config?.value.end, DEFAULT_VALUES.end);
589
615
  const interactionValues = {
@@ -596,6 +622,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
596
622
  easing,
597
623
  replay,
598
624
  relativeTo,
625
+ repeat,
626
+ times,
599
627
  start,
600
628
  end,
601
629
  customEffects
@@ -618,6 +646,14 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
618
646
  controlVisibilityConfig.effectType(interactionValues)
619
647
  );
620
648
  const DirectionControl = useControlComponent("direction", controlVisibilityConfig.direction(interactionValues));
649
+ const RepeatControl = useControlComponent(
650
+ "repeat",
651
+ controlVisibilityConfig.repeat(interactionValues)
652
+ );
653
+ const TimesControl = useControlComponent(
654
+ "times",
655
+ controlVisibilityConfig.times(interactionValues)
656
+ );
621
657
  const EasingControl = useControlComponent("easing");
622
658
  const containerRef = (0, import_react5.useRef)(null);
623
659
  const updateInteraction = (updates) => {
@@ -641,6 +677,8 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
641
677
  replay: updates.replay ?? replay,
642
678
  easing: updates.easing ?? easing,
643
679
  relativeTo: updates.relativeTo ?? relativeTo,
680
+ repeat: updates.repeat ?? repeat,
681
+ times: updates.times ?? times,
644
682
  start: updates.start ?? start,
645
683
  end: updates.end ?? end,
646
684
  customEffects: updates.customEffects ?? customEffects
@@ -679,6 +717,14 @@ var InteractionDetails = ({ interaction, onChange, onPlayInteraction }) => {
679
717
  onChange: (v) => updateInteraction({ direction: v }),
680
718
  interactionType: type
681
719
  }
720
+ )), RepeatControl && /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("Repeat", "elementor") }, /* @__PURE__ */ React7.createElement(RepeatControl, { value: repeat, onChange: (v) => updateInteraction({ repeat: v }) })), TimesControl && /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("Times", "elementor") }, /* @__PURE__ */ React7.createElement(
721
+ TimesControl,
722
+ {
723
+ value: times,
724
+ onChange: (v) => updateInteraction({
725
+ times: normalizeTimesValue(v, DEFAULT_VALUES.times)
726
+ })
727
+ }
682
728
  )), controlVisibilityConfig.duration(interactionValues) && /* @__PURE__ */ React7.createElement(Field, { label: (0, import_i18n2.__)("Duration", "elementor") }, /* @__PURE__ */ React7.createElement(
683
729
  TimeFrameIndicator,
684
730
  {