@elementor/editor-interactions 4.1.0-775 → 4.1.0-776

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-interactions",
3
- "version": "4.1.0-775",
3
+ "version": "4.1.0-776",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,19 +39,19 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor-controls": "4.1.0-775",
43
- "@elementor/editor-elements": "4.1.0-775",
44
- "@elementor/editor-mcp": "4.1.0-775",
45
- "@elementor/editor-props": "4.1.0-775",
46
- "@elementor/editor-responsive": "4.1.0-775",
47
- "@elementor/editor-ui": "4.1.0-775",
48
- "@elementor/editor-v1-adapters": "4.1.0-775",
42
+ "@elementor/editor-controls": "4.1.0-776",
43
+ "@elementor/editor-elements": "4.1.0-776",
44
+ "@elementor/editor-mcp": "4.1.0-776",
45
+ "@elementor/editor-props": "4.1.0-776",
46
+ "@elementor/editor-responsive": "4.1.0-776",
47
+ "@elementor/editor-ui": "4.1.0-776",
48
+ "@elementor/editor-v1-adapters": "4.1.0-776",
49
49
  "@elementor/icons": "^1.68.0",
50
- "@elementor/schema": "4.1.0-775",
51
- "@elementor/session": "4.1.0-775",
50
+ "@elementor/schema": "4.1.0-776",
51
+ "@elementor/session": "4.1.0-776",
52
52
  "@elementor/ui": "1.37.5",
53
- "@elementor/utils": "4.1.0-775",
54
- "@elementor/events": "4.1.0-775",
53
+ "@elementor/utils": "4.1.0-776",
54
+ "@elementor/events": "4.1.0-776",
55
55
  "@wordpress/i18n": "^5.13.0"
56
56
  },
57
57
  "peerDependencies": {
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
- import { useCallback, useRef } from 'react';
3
- import { SizeComponent, type Unit } from '@elementor/editor-controls';
2
+ import { type FocusEvent, useCallback } from 'react';
3
+ import { SizeComponent } from '@elementor/editor-controls';
4
4
  import { type SizePropValue } from '@elementor/editor-props';
5
5
 
6
6
  import { DEFAULT_TIME_UNIT, TIME_UNITS } from '../../configs/time-constants';
7
7
  import { type FieldProps, type SizeStringValue } from '../../types';
8
8
  import { formatSizeValue, parseSizeValue } from '../../utils/size-transform-utils';
9
- import { convertTimeUnit } from '../../utils/time-conversion';
10
9
 
11
10
  export function TimeFrameIndicator( {
12
11
  value,
@@ -14,32 +13,17 @@ export function TimeFrameIndicator( {
14
13
  defaultValue,
15
14
  }: FieldProps & { defaultValue: SizeStringValue } ) {
16
15
  const sizeValue = parseSizeValue( value as SizeStringValue, TIME_UNITS, defaultValue, DEFAULT_TIME_UNIT );
17
- const prevUnitRef = useRef< Unit >( sizeValue.unit as Unit );
18
16
 
19
- const setValue = useCallback(
17
+ const handleChange = useCallback(
20
18
  ( size: SizePropValue[ 'value' ] ) => {
21
- const unitChanged = prevUnitRef.current !== size.unit;
22
-
23
- if ( unitChanged ) {
24
- const fromUnit = prevUnitRef.current;
25
- const toUnit = size.unit as Unit;
26
-
27
- size.size = convertTimeUnit( Number( size.size ), fromUnit, toUnit );
28
- prevUnitRef.current = toUnit;
29
- }
30
-
31
19
  onChange( formatSizeValue( size ) as string );
32
20
  },
33
21
  [ onChange ]
34
22
  );
35
23
 
36
- const handleChange = ( newValue: SizePropValue[ 'value' ] ) => {
37
- setValue( newValue );
38
- };
39
-
40
- const handleBlur = () => {
41
- if ( ! sizeValue.size ) {
42
- setValue( parseSizeValue( defaultValue, TIME_UNITS, undefined, DEFAULT_TIME_UNIT ) );
24
+ const handleBlur = ( event: FocusEvent< HTMLInputElement > ) => {
25
+ if ( ! event.target.value ) {
26
+ handleChange( parseSizeValue( defaultValue, TIME_UNITS, undefined, DEFAULT_TIME_UNIT ) );
43
27
  }
44
28
  };
45
29
 
package/src/index.ts CHANGED
@@ -40,7 +40,6 @@ export {
40
40
 
41
41
  export { generateTempInteractionId, isTempId } from './utils/temp-id-utils';
42
42
  export { resolveDirection } from './utils/resolve-direction';
43
- export { convertTimeUnit } from './utils/time-conversion';
44
43
  export { parseSizeValue, formatSizeValue } from './utils/size-transform-utils';
45
44
  export { useElementInteractions } from './hooks/use-element-interactions';
46
45
  export {
@@ -1,11 +0,0 @@
1
- import { type Unit } from '@elementor/editor-controls';
2
-
3
- type TimeUnit = Extract< Unit, 'ms' | 's' >;
4
- const UNIT_TO_MS: Record< TimeUnit, number > = {
5
- ms: 1,
6
- s: 1000,
7
- };
8
-
9
- export const convertTimeUnit = ( value: number, from: Unit, to: Unit ): number => {
10
- return ( value * UNIT_TO_MS[ from as TimeUnit ] ) / UNIT_TO_MS[ to as TimeUnit ];
11
- };