@elementor/editor-styles 0.2.0

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 ADDED
@@ -0,0 +1,19 @@
1
+ # @elementor/editor-styles
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6cf7ba1: Change controls naming
8
+ - e69bdae: Created the `editor-props` and `editor-styles` packages.
9
+
10
+ ### Patch Changes
11
+
12
+ - 2b28089: Add classes prop context to support global classes
13
+ - 036b439: Refactor styles context as preparation for global css classes
14
+ - Updated dependencies [9abdfaf]
15
+ - Updated dependencies [6cf7ba1]
16
+ - Updated dependencies [e69bdae]
17
+ - Updated dependencies [bf12c4d]
18
+ - @elementor/editor-responsive@0.12.2
19
+ - @elementor/editor-props@0.2.0
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # Editor Styles
2
+
3
+ > [!WARNING]
4
+ > This package is under development and not ready for production use.
@@ -0,0 +1,24 @@
1
+ import { Props } from '@elementor/editor-props';
2
+ import { BreakpointId } from '@elementor/editor-responsive';
3
+
4
+ type StyleState = null | 'hover' | 'focus' | 'active' | 'visited' | 'disabled' | 'checked' | 'selected' | 'hidden' | 'visible';
5
+ type StyleVariant = {
6
+ meta: {
7
+ breakpoint: null | BreakpointId;
8
+ state: StyleState;
9
+ };
10
+ props: Props;
11
+ };
12
+ type StyleType = 'class';
13
+ type StyleDefinitionID = string;
14
+ type StyleDefinition = {
15
+ id: StyleDefinitionID;
16
+ variants: StyleVariant[];
17
+ label?: string;
18
+ type: StyleType;
19
+ };
20
+ type StyleDefinitionsMap = Record<StyleDefinition['id'], StyleDefinition>;
21
+
22
+ declare function generateId(prefix?: string, existingIds?: string[]): string;
23
+
24
+ export { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionsMap, type StyleVariant, generateId };
@@ -0,0 +1,24 @@
1
+ import { Props } from '@elementor/editor-props';
2
+ import { BreakpointId } from '@elementor/editor-responsive';
3
+
4
+ type StyleState = null | 'hover' | 'focus' | 'active' | 'visited' | 'disabled' | 'checked' | 'selected' | 'hidden' | 'visible';
5
+ type StyleVariant = {
6
+ meta: {
7
+ breakpoint: null | BreakpointId;
8
+ state: StyleState;
9
+ };
10
+ props: Props;
11
+ };
12
+ type StyleType = 'class';
13
+ type StyleDefinitionID = string;
14
+ type StyleDefinition = {
15
+ id: StyleDefinitionID;
16
+ variants: StyleVariant[];
17
+ label?: string;
18
+ type: StyleType;
19
+ };
20
+ type StyleDefinitionsMap = Record<StyleDefinition['id'], StyleDefinition>;
21
+
22
+ declare function generateId(prefix?: string, existingIds?: string[]): string;
23
+
24
+ export { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionsMap, type StyleVariant, generateId };
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ generateId: () => generateId
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+
27
+ // src/generateId.ts
28
+ function generateId(prefix = "", existingIds = []) {
29
+ let id;
30
+ do {
31
+ id = prefix + Math.random().toString(16).slice(2, 9);
32
+ } while (existingIds.includes(id));
33
+ return id;
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ generateId
38
+ });
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/generateId.ts"],"sourcesContent":["// types\nexport * from './types';\n\n// utils\nexport { generateId } from './generateId';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;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;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ // src/generateId.ts
2
+ function generateId(prefix = "", existingIds = []) {
3
+ let id;
4
+ do {
5
+ id = prefix + Math.random().toString(16).slice(2, 9);
6
+ } while (existingIds.includes(id));
7
+ return id;
8
+ }
9
+ export {
10
+ generateId
11
+ };
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generateId.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"],"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;","names":[]}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@elementor/editor-styles",
3
+ "description": "This package contains the styles model for the Elementor editor",
4
+ "version": "0.2.0",
5
+ "private": false,
6
+ "author": "Elementor Team",
7
+ "homepage": "https://elementor.com/",
8
+ "license": "GPL-3.0-or-later",
9
+ "main": "dist/index.js",
10
+ "module": "dist/index.mjs",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.js"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/elementor/elementor-packages.git",
23
+ "directory": "packages/libs/editor-styles"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/elementor/elementor-packages/issues"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "README.md",
33
+ "CHANGELOG.md",
34
+ "/dist",
35
+ "/src",
36
+ "!**/__tests__"
37
+ ],
38
+ "scripts": {
39
+ "build": "tsup --config=../../tsup.build.ts",
40
+ "dev": "tsup --config=../../tsup.dev.ts"
41
+ },
42
+ "dependencies": {
43
+ "@elementor/editor-props": "^0.2.0",
44
+ "@elementor/editor-responsive": "^0.12.2"
45
+ }
46
+ }
@@ -0,0 +1,9 @@
1
+ export function generateId( prefix: string = '', existingIds: string[] = [] ) {
2
+ let id: string;
3
+
4
+ do {
5
+ id = prefix + Math.random().toString( 16 ).slice( 2, 9 );
6
+ } while ( existingIds.includes( id ) );
7
+
8
+ return id;
9
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ // types
2
+ export * from './types';
3
+
4
+ // utils
5
+ export { generateId } from './generateId';
package/src/types.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { Props } from '@elementor/editor-props';
2
+ import { BreakpointId } from '@elementor/editor-responsive';
3
+
4
+ type StyleState =
5
+ | null
6
+ | 'hover'
7
+ | 'focus'
8
+ | 'active'
9
+ | 'visited'
10
+ | 'disabled'
11
+ | 'checked'
12
+ | 'selected'
13
+ | 'hidden'
14
+ | 'visible';
15
+
16
+ export type StyleVariant = {
17
+ meta: {
18
+ breakpoint: null | BreakpointId;
19
+ state: StyleState;
20
+ };
21
+ props: Props;
22
+ };
23
+
24
+ type StyleType = 'class';
25
+
26
+ export type StyleDefinitionID = string;
27
+
28
+ export type StyleDefinition = {
29
+ id: StyleDefinitionID;
30
+ variants: StyleVariant[];
31
+ label?: string;
32
+ type: StyleType;
33
+ };
34
+
35
+ export type StyleDefinitionsMap = Record< StyleDefinition[ 'id' ], StyleDefinition >;