@elementor/editor-props 0.18.0 → 3.32.0-21

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 (33) hide show
  1. package/CHANGELOG.md +0 -8
  2. package/dist/index.d.mts +10748 -3163
  3. package/dist/index.d.ts +10748 -3163
  4. package/dist/index.js +202 -149
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +193 -139
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +4 -4
  9. package/src/index.ts +1 -1
  10. package/src/prop-types/filter-prop-types/backdrop-filter.ts +6 -3
  11. package/src/prop-types/filter-prop-types/drop-shadow-filter.ts +11 -2
  12. package/src/prop-types/filter-prop-types/filter.ts +12 -21
  13. package/src/prop-types/flex.ts +15 -0
  14. package/src/prop-types/index.ts +6 -8
  15. package/src/prop-types/selection-size.ts +16 -0
  16. package/src/prop-types/size.ts +13 -1
  17. package/src/prop-types/transform-prop-types/move-transform.ts +2 -1
  18. package/src/prop-types/transform-prop-types/rotate-transform.ts +16 -0
  19. package/src/prop-types/transform-prop-types/scale-transform.ts +8 -5
  20. package/src/prop-types/transform-prop-types/skew-transform.ts +15 -0
  21. package/src/prop-types/transform-prop-types/transform.ts +8 -1
  22. package/src/prop-types/transform-prop-types/types.ts +8 -0
  23. package/src/types.ts +1 -4
  24. package/src/utils/create-prop-utils.ts +3 -2
  25. package/src/utils/prop-dependency-utils.ts +26 -16
  26. package/src/prop-types/filter-prop-types/blur-filter.ts +0 -8
  27. package/src/prop-types/filter-prop-types/brightness-filter.ts +0 -8
  28. package/src/prop-types/filter-prop-types/contrast-filter.ts +0 -8
  29. package/src/prop-types/filter-prop-types/grayscale-filter.ts +0 -8
  30. package/src/prop-types/filter-prop-types/hue-rotate-filter.ts +0 -8
  31. package/src/prop-types/filter-prop-types/invert-filter.ts +0 -8
  32. package/src/prop-types/filter-prop-types/saturate-filter.ts +0 -8
  33. package/src/prop-types/filter-prop-types/sepia-filter.ts +0 -8
@@ -1,22 +1,32 @@
1
- import { type Dependency, type DependencyTerm, type PropValue, type TransformablePropValue } from '../types';
1
+ import {
2
+ type Dependency,
3
+ type DependencyTerm,
4
+ type PropKey,
5
+ type PropValue,
6
+ type TransformablePropValue,
7
+ } from '../types';
8
+ import { isTransformable } from './is-transformable';
2
9
 
3
10
  type ParsedTerm = DependencyTerm;
4
11
 
5
12
  type Relation = Dependency[ 'relation' ];
6
13
 
7
- export function shouldApplyEffect( { relation, terms }: Dependency, values: PropValue ): boolean {
8
- if ( ! terms.length ) {
9
- return false;
14
+ export function isDependencyMet( dependency: Dependency | undefined, values: PropValue ): boolean {
15
+ if ( ! dependency?.terms.length ) {
16
+ return true;
10
17
  }
11
18
 
19
+ const { relation, terms } = dependency;
12
20
  const method = getRelationMethod( relation );
13
21
 
14
22
  return terms[ method ]( ( term: ParsedTerm | Dependency ) =>
15
- isDependency( term ) ? shouldApplyEffect( term, values ) : evaluateTerm( term, getValue( term.path, values ) )
23
+ isDependency( term )
24
+ ? isDependencyMet( term, values )
25
+ : evaluateTerm( term, extractValue( term.path, values )?.value )
16
26
  );
17
27
  }
18
28
 
19
- export function evaluateTerm( term: DependencyTerm, actualValue: PropValue ) {
29
+ export function evaluateTerm( term: DependencyTerm, actualValue: unknown ) {
20
30
  const { value: valueToCompare, operator } = term;
21
31
 
22
32
  switch ( operator ) {
@@ -45,7 +55,7 @@ export function evaluateTerm( term: DependencyTerm, actualValue: PropValue ) {
45
55
  return false;
46
56
  }
47
57
 
48
- return valueToCompare.includes( actualValue ) === ( 'in' === operator );
58
+ return valueToCompare.includes( actualValue as never ) === ( 'in' === operator );
49
59
 
50
60
  case 'contains':
51
61
  case 'ncontains':
@@ -65,11 +75,11 @@ export function evaluateTerm( term: DependencyTerm, actualValue: PropValue ) {
65
75
  return ( 'exists' === operator ) === evaluation;
66
76
 
67
77
  default:
68
- return false;
78
+ return true;
69
79
  }
70
80
  }
71
81
 
72
- function isNumber( value: PropValue ): value is number {
82
+ function isNumber( value: unknown ): value is number {
73
83
  return typeof value === 'number' && ! isNaN( value );
74
84
  }
75
85
 
@@ -86,14 +96,14 @@ function getRelationMethod( relation: Relation ) {
86
96
  }
87
97
  }
88
98
 
89
- function getValue( path: string[], elementValues: PropValue ): PropValue | null {
90
- return path.reduce( ( acc, key ) => {
91
- return 'object' === typeof acc && acc !== null && key in acc
92
- ? ( ( acc[ key as keyof typeof acc ] as TransformablePropValue< string > )?.value as PropValue )
93
- : null;
94
- }, elementValues );
99
+ export function extractValue( path: string[], elementValues: PropValue ): TransformablePropValue< PropKey > | null {
100
+ return path.reduce( ( acc, key, index ) => {
101
+ const value = acc?.[ key as keyof typeof acc ] as PropValue | null;
102
+
103
+ return index !== path.length - 1 && isTransformable( value ) ? value.value ?? null : value;
104
+ }, elementValues ) as TransformablePropValue< PropKey >;
95
105
  }
96
106
 
97
- function isDependency( term: DependencyTerm | Dependency ): term is Dependency {
107
+ export function isDependency( term: DependencyTerm | Dependency ): term is Dependency {
98
108
  return 'relation' in term;
99
109
  }
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const blurFilterPropTypeUtil = createPropUtils( 'blur', unknownChildrenSchema );
7
-
8
- export type BlurFilterPropValue = z.infer< typeof blurFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const brightnessFilterPropTypeUtil = createPropUtils( 'brightness', unknownChildrenSchema );
7
-
8
- export type BrightnessFilterPropValue = z.infer< typeof brightnessFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const contrastFilterPropTypeUtil = createPropUtils( 'contrast', unknownChildrenSchema );
7
-
8
- export type ContrastFilterPropValue = z.infer< typeof contrastFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const grayscaleFilterPropTypeUtil = createPropUtils( 'grayscale', unknownChildrenSchema );
7
-
8
- export type GrayscaleFilterPropValue = z.infer< typeof grayscaleFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const hueRotateFilterPropTypeUtil = createPropUtils( 'hue-rotate', unknownChildrenSchema );
7
-
8
- export type HueRotateFilterPropValue = z.infer< typeof hueRotateFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const invertFilterPropTypeUtil = createPropUtils( 'invert', unknownChildrenSchema );
7
-
8
- export type InvertFilterPropValue = z.infer< typeof invertFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const saturateFilterPropTypeUtil = createPropUtils( 'saturate', unknownChildrenSchema );
7
-
8
- export type SaturateFilterPropValue = z.infer< typeof saturateFilterPropTypeUtil.schema >;
@@ -1,8 +0,0 @@
1
- import { type z } from '@elementor/schema';
2
-
3
- import { createPropUtils } from '../../utils/create-prop-utils';
4
- import { unknownChildrenSchema } from '../utils';
5
-
6
- export const sepiaFilterPropTypeUtil = createPropUtils( 'sepia', unknownChildrenSchema );
7
-
8
- export type SepiaFilterPropValue = z.infer< typeof sepiaFilterPropTypeUtil.schema >;