@elementor/editor-styles 0.5.2 → 0.5.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @elementor/editor-styles
2
2
 
3
+ ## 0.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - b34f498: Fix global class styles not updating
8
+ - @elementor/editor-responsive@0.12.6
9
+
10
+ ## 0.5.3
11
+
12
+ ### Patch Changes
13
+
14
+ - a13a209: Refactor editor-elements to not use the commands
15
+ - Updated dependencies [f1a2ffb]
16
+ - @elementor/editor-props@0.8.0
17
+
3
18
  ## 0.5.2
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2,21 +2,21 @@ import * as _elementor_editor_props from '@elementor/editor-props';
2
2
  import { Props } from '@elementor/editor-props';
3
3
  import { BreakpointId } from '@elementor/editor-responsive';
4
4
 
5
- type StyleState = null | 'hover' | 'focus' | 'active' | 'visited' | 'disabled' | 'checked' | 'selected' | 'hidden' | 'visible';
6
- type StyleVariant = {
5
+ type StyleDefinitionState = null | 'hover' | 'focus' | 'active' | 'visited' | 'disabled' | 'checked' | 'selected' | 'hidden' | 'visible';
6
+ type StyleDefinitionVariant = {
7
7
  meta: {
8
8
  breakpoint: null | BreakpointId;
9
- state: StyleState;
9
+ state: StyleDefinitionState;
10
10
  };
11
11
  props: Props;
12
12
  };
13
- type StyleType = 'class';
13
+ type StyleDefinitionType = 'class';
14
14
  type StyleDefinitionID = string;
15
15
  type StyleDefinition = {
16
16
  id: StyleDefinitionID;
17
- variants: StyleVariant[];
17
+ variants: StyleDefinitionVariant[];
18
18
  label: string;
19
- type: StyleType;
19
+ type: StyleDefinitionType;
20
20
  };
21
21
  type StyleDefinitionsMap = Record<StyleDefinition['id'], StyleDefinition>;
22
22
 
@@ -24,4 +24,6 @@ declare function generateId(prefix?: string, existingIds?: string[]): string;
24
24
 
25
25
  declare const getStylesSchema: () => Record<string, _elementor_editor_props.PropType>;
26
26
 
27
- export { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionsMap, type StyleState, type StyleVariant, generateId, getStylesSchema };
27
+ declare function getVariantByMeta(style: StyleDefinition, meta: StyleDefinitionVariant['meta']): StyleDefinitionVariant | undefined;
28
+
29
+ export { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionState, type StyleDefinitionType, type StyleDefinitionVariant, type StyleDefinitionsMap, generateId, getStylesSchema, getVariantByMeta };
package/dist/index.d.ts CHANGED
@@ -2,21 +2,21 @@ import * as _elementor_editor_props from '@elementor/editor-props';
2
2
  import { Props } from '@elementor/editor-props';
3
3
  import { BreakpointId } from '@elementor/editor-responsive';
4
4
 
5
- type StyleState = null | 'hover' | 'focus' | 'active' | 'visited' | 'disabled' | 'checked' | 'selected' | 'hidden' | 'visible';
6
- type StyleVariant = {
5
+ type StyleDefinitionState = null | 'hover' | 'focus' | 'active' | 'visited' | 'disabled' | 'checked' | 'selected' | 'hidden' | 'visible';
6
+ type StyleDefinitionVariant = {
7
7
  meta: {
8
8
  breakpoint: null | BreakpointId;
9
- state: StyleState;
9
+ state: StyleDefinitionState;
10
10
  };
11
11
  props: Props;
12
12
  };
13
- type StyleType = 'class';
13
+ type StyleDefinitionType = 'class';
14
14
  type StyleDefinitionID = string;
15
15
  type StyleDefinition = {
16
16
  id: StyleDefinitionID;
17
- variants: StyleVariant[];
17
+ variants: StyleDefinitionVariant[];
18
18
  label: string;
19
- type: StyleType;
19
+ type: StyleDefinitionType;
20
20
  };
21
21
  type StyleDefinitionsMap = Record<StyleDefinition['id'], StyleDefinition>;
22
22
 
@@ -24,4 +24,6 @@ declare function generateId(prefix?: string, existingIds?: string[]): string;
24
24
 
25
25
  declare const getStylesSchema: () => Record<string, _elementor_editor_props.PropType>;
26
26
 
27
- export { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionsMap, type StyleState, type StyleVariant, generateId, getStylesSchema };
27
+ declare function getVariantByMeta(style: StyleDefinition, meta: StyleDefinitionVariant['meta']): StyleDefinitionVariant | undefined;
28
+
29
+ export { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionState, type StyleDefinitionType, type StyleDefinitionVariant, type StyleDefinitionsMap, generateId, getStylesSchema, getVariantByMeta };
package/dist/index.js CHANGED
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  generateId: () => generateId,
24
- getStylesSchema: () => getStylesSchema
24
+ getStylesSchema: () => getStylesSchema,
25
+ getVariantByMeta: () => getVariantByMeta
25
26
  });
26
27
  module.exports = __toCommonJS(index_exports);
27
28
 
@@ -44,9 +45,17 @@ var getStylesSchema = () => {
44
45
  const styleSchema = config?.atomic?.styles_schema ?? {};
45
46
  return styleSchema;
46
47
  };
48
+
49
+ // src/utils/get-variant-by-meta.ts
50
+ function getVariantByMeta(style, meta) {
51
+ return style.variants.find((variant) => {
52
+ return variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;
53
+ });
54
+ }
47
55
  // Annotate the CommonJS export names for ESM import in node:
48
56
  0 && (module.exports = {
49
57
  generateId,
50
- getStylesSchema
58
+ getStylesSchema,
59
+ getVariantByMeta
51
60
  });
52
61
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/generate-id.ts","../src/utils/get-styles-schema.ts"],"sourcesContent":["// types\nexport * from './types';\n\n// utils\nexport { generateId } from './utils/generate-id';\nexport { getStylesSchema } from './utils/get-styles-schema';\n","export function generateId( prefix: string = '', existingIds: string[] = [] ) {\n\tlet id: string;\n\n\tdo {\n\t\tid = prefix + Math.random().toString( 16 ).slice( 2, 9 );\n\t} while ( existingIds.includes( id ) );\n\n\treturn id;\n}\n","import { type ExtendedWindow } from './types';\n\nconst getElementorConfig = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.config ?? {};\n};\n\nexport const getStylesSchema = () => {\n\tconst config = getElementorConfig();\n\tconst styleSchema = config?.atomic?.styles_schema ?? {};\n\n\treturn styleSchema;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,WAAY,SAAiB,IAAI,cAAwB,CAAC,GAAI;AAC7E,MAAI;AAEJ,KAAG;AACF,SAAK,SAAS,KAAK,OAAO,EAAE,SAAU,EAAG,EAAE,MAAO,GAAG,CAAE;AAAA,EACxD,SAAU,YAAY,SAAU,EAAG;AAEnC,SAAO;AACR;;;ACNA,IAAM,qBAAqB,MAAM;AAChC,QAAM,iBAAiB;AAEvB,SAAO,eAAe,WAAW,UAAU,CAAC;AAC7C;AAEO,IAAM,kBAAkB,MAAM;AACpC,QAAM,SAAS,mBAAmB;AAClC,QAAM,cAAc,QAAQ,QAAQ,iBAAiB,CAAC;AAEtD,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/generate-id.ts","../src/utils/get-styles-schema.ts","../src/utils/get-variant-by-meta.ts"],"sourcesContent":["// types\nexport * from './types';\n\n// utils\nexport { generateId } from './utils/generate-id';\nexport { getStylesSchema } from './utils/get-styles-schema';\nexport { getVariantByMeta } from './utils/get-variant-by-meta';\n","export function generateId( prefix: string = '', existingIds: string[] = [] ) {\n\tlet id: string;\n\n\tdo {\n\t\tid = prefix + Math.random().toString( 16 ).slice( 2, 9 );\n\t} while ( existingIds.includes( id ) );\n\n\treturn id;\n}\n","import { type ExtendedWindow } from './types';\n\nconst getElementorConfig = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.config ?? {};\n};\n\nexport const getStylesSchema = () => {\n\tconst config = getElementorConfig();\n\tconst styleSchema = config?.atomic?.styles_schema ?? {};\n\n\treturn styleSchema;\n};\n","import { type StyleDefinition, type StyleDefinitionVariant } from '../types';\n\nexport function getVariantByMeta( style: StyleDefinition, meta: StyleDefinitionVariant[ 'meta' ] ) {\n\treturn style.variants.find( ( variant ) => {\n\t\treturn variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,WAAY,SAAiB,IAAI,cAAwB,CAAC,GAAI;AAC7E,MAAI;AAEJ,KAAG;AACF,SAAK,SAAS,KAAK,OAAO,EAAE,SAAU,EAAG,EAAE,MAAO,GAAG,CAAE;AAAA,EACxD,SAAU,YAAY,SAAU,EAAG;AAEnC,SAAO;AACR;;;ACNA,IAAM,qBAAqB,MAAM;AAChC,QAAM,iBAAiB;AAEvB,SAAO,eAAe,WAAW,UAAU,CAAC;AAC7C;AAEO,IAAM,kBAAkB,MAAM;AACpC,QAAM,SAAS,mBAAmB;AAClC,QAAM,cAAc,QAAQ,QAAQ,iBAAiB,CAAC;AAEtD,SAAO;AACR;;;ACXO,SAAS,iBAAkB,OAAwB,MAAyC;AAClG,SAAO,MAAM,SAAS,KAAM,CAAE,YAAa;AAC1C,WAAO,QAAQ,KAAK,eAAe,KAAK,cAAc,QAAQ,KAAK,UAAU,KAAK;AAAA,EACnF,CAAE;AACH;","names":[]}
package/dist/index.mjs CHANGED
@@ -17,8 +17,16 @@ var getStylesSchema = () => {
17
17
  const styleSchema = config?.atomic?.styles_schema ?? {};
18
18
  return styleSchema;
19
19
  };
20
+
21
+ // src/utils/get-variant-by-meta.ts
22
+ function getVariantByMeta(style, meta) {
23
+ return style.variants.find((variant) => {
24
+ return variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;
25
+ });
26
+ }
20
27
  export {
21
28
  generateId,
22
- getStylesSchema
29
+ getStylesSchema,
30
+ getVariantByMeta
23
31
  };
24
32
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/generate-id.ts","../src/utils/get-styles-schema.ts"],"sourcesContent":["export function generateId( prefix: string = '', existingIds: string[] = [] ) {\n\tlet id: string;\n\n\tdo {\n\t\tid = prefix + Math.random().toString( 16 ).slice( 2, 9 );\n\t} while ( existingIds.includes( id ) );\n\n\treturn id;\n}\n","import { type ExtendedWindow } from './types';\n\nconst getElementorConfig = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.config ?? {};\n};\n\nexport const getStylesSchema = () => {\n\tconst config = getElementorConfig();\n\tconst styleSchema = config?.atomic?.styles_schema ?? {};\n\n\treturn styleSchema;\n};\n"],"mappings":";AAAO,SAAS,WAAY,SAAiB,IAAI,cAAwB,CAAC,GAAI;AAC7E,MAAI;AAEJ,KAAG;AACF,SAAK,SAAS,KAAK,OAAO,EAAE,SAAU,EAAG,EAAE,MAAO,GAAG,CAAE;AAAA,EACxD,SAAU,YAAY,SAAU,EAAG;AAEnC,SAAO;AACR;;;ACNA,IAAM,qBAAqB,MAAM;AAChC,QAAM,iBAAiB;AAEvB,SAAO,eAAe,WAAW,UAAU,CAAC;AAC7C;AAEO,IAAM,kBAAkB,MAAM;AACpC,QAAM,SAAS,mBAAmB;AAClC,QAAM,cAAc,QAAQ,QAAQ,iBAAiB,CAAC;AAEtD,SAAO;AACR;","names":[]}
1
+ {"version":3,"sources":["../src/utils/generate-id.ts","../src/utils/get-styles-schema.ts","../src/utils/get-variant-by-meta.ts"],"sourcesContent":["export function generateId( prefix: string = '', existingIds: string[] = [] ) {\n\tlet id: string;\n\n\tdo {\n\t\tid = prefix + Math.random().toString( 16 ).slice( 2, 9 );\n\t} while ( existingIds.includes( id ) );\n\n\treturn id;\n}\n","import { type ExtendedWindow } from './types';\n\nconst getElementorConfig = () => {\n\tconst extendedWindow = window as unknown as ExtendedWindow;\n\n\treturn extendedWindow.elementor?.config ?? {};\n};\n\nexport const getStylesSchema = () => {\n\tconst config = getElementorConfig();\n\tconst styleSchema = config?.atomic?.styles_schema ?? {};\n\n\treturn styleSchema;\n};\n","import { type StyleDefinition, type StyleDefinitionVariant } from '../types';\n\nexport function getVariantByMeta( style: StyleDefinition, meta: StyleDefinitionVariant[ 'meta' ] ) {\n\treturn style.variants.find( ( variant ) => {\n\t\treturn variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;\n\t} );\n}\n"],"mappings":";AAAO,SAAS,WAAY,SAAiB,IAAI,cAAwB,CAAC,GAAI;AAC7E,MAAI;AAEJ,KAAG;AACF,SAAK,SAAS,KAAK,OAAO,EAAE,SAAU,EAAG,EAAE,MAAO,GAAG,CAAE;AAAA,EACxD,SAAU,YAAY,SAAU,EAAG;AAEnC,SAAO;AACR;;;ACNA,IAAM,qBAAqB,MAAM;AAChC,QAAM,iBAAiB;AAEvB,SAAO,eAAe,WAAW,UAAU,CAAC;AAC7C;AAEO,IAAM,kBAAkB,MAAM;AACpC,QAAM,SAAS,mBAAmB;AAClC,QAAM,cAAc,QAAQ,QAAQ,iBAAiB,CAAC;AAEtD,SAAO;AACR;;;ACXO,SAAS,iBAAkB,OAAwB,MAAyC;AAClG,SAAO,MAAM,SAAS,KAAM,CAAE,YAAa;AAC1C,WAAO,QAAQ,KAAK,eAAe,KAAK,cAAc,QAAQ,KAAK,UAAU,KAAK;AAAA,EACnF,CAAE;AACH;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-styles",
3
3
  "description": "This package contains the styles model for the Elementor editor",
4
- "version": "0.5.2",
4
+ "version": "0.5.4",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,7 +40,7 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-props": "0.7.1",
44
- "@elementor/editor-responsive": "0.12.5"
43
+ "@elementor/editor-props": "0.8.0",
44
+ "@elementor/editor-responsive": "0.12.6"
45
45
  }
46
46
  }
package/src/index.ts CHANGED
@@ -4,3 +4,4 @@ export * from './types';
4
4
  // utils
5
5
  export { generateId } from './utils/generate-id';
6
6
  export { getStylesSchema } from './utils/get-styles-schema';
7
+ export { getVariantByMeta } from './utils/get-variant-by-meta';
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type Props } from '@elementor/editor-props';
2
2
  import { type BreakpointId } from '@elementor/editor-responsive';
3
3
 
4
- export type StyleState =
4
+ export type StyleDefinitionState =
5
5
  | null
6
6
  | 'hover'
7
7
  | 'focus'
@@ -13,23 +13,23 @@ export type StyleState =
13
13
  | 'hidden'
14
14
  | 'visible';
15
15
 
16
- export type StyleVariant = {
16
+ export type StyleDefinitionVariant = {
17
17
  meta: {
18
18
  breakpoint: null | BreakpointId;
19
- state: StyleState;
19
+ state: StyleDefinitionState;
20
20
  };
21
21
  props: Props;
22
22
  };
23
23
 
24
- type StyleType = 'class';
24
+ export type StyleDefinitionType = 'class';
25
25
 
26
26
  export type StyleDefinitionID = string;
27
27
 
28
28
  export type StyleDefinition = {
29
29
  id: StyleDefinitionID;
30
- variants: StyleVariant[];
30
+ variants: StyleDefinitionVariant[];
31
31
  label: string;
32
- type: StyleType;
32
+ type: StyleDefinitionType;
33
33
  };
34
34
 
35
35
  export type StyleDefinitionsMap = Record< StyleDefinition[ 'id' ], StyleDefinition >;
@@ -0,0 +1,7 @@
1
+ import { type StyleDefinition, type StyleDefinitionVariant } from '../types';
2
+
3
+ export function getVariantByMeta( style: StyleDefinition, meta: StyleDefinitionVariant[ 'meta' ] ) {
4
+ return style.variants.find( ( variant ) => {
5
+ return variant.meta.breakpoint === meta.breakpoint && variant.meta.state === meta.state;
6
+ } );
7
+ }