@elementor/editor-styles-repository 0.8.3 → 0.8.5
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +20 -0
- package/dist/index.d.mts +48 -18
- package/dist/index.d.ts +48 -18
- package/dist/index.js +144 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -5
- package/src/__tests__/{elements-styles-provider.test.ts → document-elements-styles-provider.test.ts} +33 -21
- package/src/__tests__/element-base-styles-provider.test.ts +3 -3
- package/src/errors.ts +5 -0
- package/src/hooks/{use-create-actions-by-provider.ts → use-get-styles-repository-create-action.ts} +10 -3
- package/src/index.ts +11 -12
- package/src/init.ts +3 -3
- package/src/{elements-styles-provider.ts → providers/document-elements-styles-provider.ts} +29 -16
- package/src/{element-base-styles-provider.ts → providers/element-base-styles-provider.ts} +6 -10
- package/src/types.ts +33 -0
- package/src/utils/__tests__/create-styles-repository.test.ts +17 -93
- package/src/utils/__tests__/validate-style-label.test.ts +120 -0
- package/src/utils/create-styles-provider.ts +51 -0
- package/src/utils/create-styles-repository.ts +3 -58
- package/src/utils/is-elements-styles-provider.ts +5 -0
- package/src/utils/validate-style-label.ts +74 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @elementor/editor-styles-repository@0.8.
|
|
2
|
+
> @elementor/editor-styles-repository@0.8.5 build
|
|
3
3
|
> tsup --config=../../tsup.build.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m8.13 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m15.65 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 94ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.js [22m[32m10.08 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m16.50 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 102ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 9115ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.35 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.35 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @elementor/editor-styles-repository
|
|
2
2
|
|
|
3
|
+
## 0.8.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ca5d620: CSS class selector: Display validation error message
|
|
8
|
+
|
|
9
|
+
## 0.8.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 42c42ee: Remove side-effects
|
|
14
|
+
- 5fa575c: Fix when switching documents it removes all the previous document styles
|
|
15
|
+
- 64574e3: Refactor styles provider as a preparation for header/footer styles not being rendered
|
|
16
|
+
- Updated dependencies [5fa575c]
|
|
17
|
+
- Updated dependencies [fe0ab45]
|
|
18
|
+
- Updated dependencies [fd5251c]
|
|
19
|
+
- @elementor/editor-elements@0.8.1
|
|
20
|
+
- @elementor/editor-props@0.12.0
|
|
21
|
+
- @elementor/editor-styles@0.6.6
|
|
22
|
+
|
|
3
23
|
## 0.8.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3,32 +3,30 @@ import * as _elementor_editor_styles from '@elementor/editor-styles';
|
|
|
3
3
|
import { StyleDefinition, StyleDefinitionID, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
5
|
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
|
|
6
|
+
type Meta = Record<string, unknown>;
|
|
6
7
|
type UpdateActionPayload = MakeOptional<StyleDefinition, 'label' | 'variants' | 'type'>;
|
|
7
8
|
type UpdatePropsActionPayload = {
|
|
8
9
|
id: StyleDefinitionID;
|
|
9
10
|
meta: StyleDefinitionVariant['meta'];
|
|
10
11
|
props: Props;
|
|
11
12
|
};
|
|
12
|
-
type Meta = Record<string, unknown>;
|
|
13
13
|
type StylesProvider = {
|
|
14
|
-
|
|
14
|
+
getKey: () => string;
|
|
15
15
|
priority: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
subscribe: (callback: () => void) => () => void;
|
|
18
|
+
labels: {
|
|
19
|
+
singular: string | null;
|
|
20
|
+
plural: string | null;
|
|
21
|
+
};
|
|
16
22
|
actions: {
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
all: (meta?: Meta) => StyleDefinition[];
|
|
24
|
+
get: (id: StyleDefinitionID, meta?: Meta) => StyleDefinition | null;
|
|
19
25
|
create?: (label: StyleDefinition['label']) => StyleDefinitionID;
|
|
20
26
|
delete?: (id: StyleDefinitionID) => void;
|
|
21
|
-
setOrder?: (order: StyleDefinitionID[]) => void;
|
|
22
27
|
update?: (data: UpdateActionPayload) => void;
|
|
23
28
|
updateProps?: (args: UpdatePropsActionPayload, meta?: Meta) => void;
|
|
24
29
|
};
|
|
25
|
-
subscribe: (callback: () => void) => () => void;
|
|
26
|
-
labels?: {
|
|
27
|
-
singular: string;
|
|
28
|
-
plural: string;
|
|
29
|
-
};
|
|
30
|
-
reservedLabel?: string;
|
|
31
|
-
limit?: number;
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
declare const stylesRepository: {
|
|
@@ -37,19 +35,51 @@ declare const stylesRepository: {
|
|
|
37
35
|
subscribe: (cb: () => void) => () => void;
|
|
38
36
|
getProviders: () => StylesProvider[];
|
|
39
37
|
getProviderByKey: (key: string) => StylesProvider | undefined;
|
|
40
|
-
isLabelExist: (newLabel: string) => boolean;
|
|
41
|
-
isLabelValid: (newLabel: string) => boolean;
|
|
42
38
|
};
|
|
43
39
|
|
|
44
40
|
declare function useProviders(): StylesProvider[];
|
|
45
41
|
|
|
46
42
|
type CreateAction = Required<StylesProvider['actions']>['create'];
|
|
47
43
|
type CreateTuple = [StylesProvider, CreateAction];
|
|
48
|
-
declare function
|
|
44
|
+
declare function useGetStylesRepositoryCreateAction(): CreateTuple | null;
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
type ValidationEvent = 'inputChange' | 'create' | 'rename';
|
|
47
|
+
type ValidationResult = {
|
|
48
|
+
isValid: true;
|
|
49
|
+
errorMessage: null;
|
|
50
|
+
} | {
|
|
51
|
+
isValid: false;
|
|
52
|
+
errorMessage: string;
|
|
53
|
+
};
|
|
54
|
+
declare function validateStyleLabel(label: string, event: ValidationEvent | 'rename'): ValidationResult;
|
|
55
|
+
|
|
56
|
+
type CreateStylesProviderOptions = {
|
|
57
|
+
key: string | (() => string);
|
|
58
|
+
priority?: number;
|
|
59
|
+
limit?: number;
|
|
60
|
+
subscribe?: (callback: () => void) => () => void;
|
|
61
|
+
labels?: {
|
|
62
|
+
singular: string;
|
|
63
|
+
plural: string;
|
|
64
|
+
};
|
|
65
|
+
actions: {
|
|
66
|
+
all: StylesProvider['actions']['all'];
|
|
67
|
+
get: StylesProvider['actions']['get'];
|
|
68
|
+
create?: StylesProvider['actions']['create'];
|
|
69
|
+
delete?: StylesProvider['actions']['delete'];
|
|
70
|
+
update?: StylesProvider['actions']['update'];
|
|
71
|
+
updateProps?: StylesProvider['actions']['updateProps'];
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
declare function createStylesProvider({ key, priority, limit, subscribe, labels, actions, }: CreateStylesProviderOptions): StylesProvider;
|
|
75
|
+
|
|
76
|
+
declare function isElementsStylesProvider(key: string): boolean;
|
|
52
77
|
|
|
53
78
|
declare const ELEMENTS_BASE_STYLES_PROVIDER_KEY = "element-base-styles";
|
|
54
79
|
|
|
55
|
-
|
|
80
|
+
declare const ELEMENTS_STYLES_PROVIDER_KEY_PREFIX = "document-elements-";
|
|
81
|
+
declare const ELEMENTS_STYLES_RESERVED_LABEL = "local";
|
|
82
|
+
|
|
83
|
+
declare function init(): void;
|
|
84
|
+
|
|
85
|
+
export { type CreateStylesProviderOptions, ELEMENTS_BASE_STYLES_PROVIDER_KEY, ELEMENTS_STYLES_PROVIDER_KEY_PREFIX, ELEMENTS_STYLES_RESERVED_LABEL, type Meta, type StylesProvider, type UpdateActionPayload, type UpdatePropsActionPayload, createStylesProvider, init, isElementsStylesProvider, stylesRepository, useGetStylesRepositoryCreateAction, useProviders, validateStyleLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,32 +3,30 @@ import * as _elementor_editor_styles from '@elementor/editor-styles';
|
|
|
3
3
|
import { StyleDefinition, StyleDefinitionID, StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
5
|
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
|
|
6
|
+
type Meta = Record<string, unknown>;
|
|
6
7
|
type UpdateActionPayload = MakeOptional<StyleDefinition, 'label' | 'variants' | 'type'>;
|
|
7
8
|
type UpdatePropsActionPayload = {
|
|
8
9
|
id: StyleDefinitionID;
|
|
9
10
|
meta: StyleDefinitionVariant['meta'];
|
|
10
11
|
props: Props;
|
|
11
12
|
};
|
|
12
|
-
type Meta = Record<string, unknown>;
|
|
13
13
|
type StylesProvider = {
|
|
14
|
-
|
|
14
|
+
getKey: () => string;
|
|
15
15
|
priority: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
subscribe: (callback: () => void) => () => void;
|
|
18
|
+
labels: {
|
|
19
|
+
singular: string | null;
|
|
20
|
+
plural: string | null;
|
|
21
|
+
};
|
|
16
22
|
actions: {
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
all: (meta?: Meta) => StyleDefinition[];
|
|
24
|
+
get: (id: StyleDefinitionID, meta?: Meta) => StyleDefinition | null;
|
|
19
25
|
create?: (label: StyleDefinition['label']) => StyleDefinitionID;
|
|
20
26
|
delete?: (id: StyleDefinitionID) => void;
|
|
21
|
-
setOrder?: (order: StyleDefinitionID[]) => void;
|
|
22
27
|
update?: (data: UpdateActionPayload) => void;
|
|
23
28
|
updateProps?: (args: UpdatePropsActionPayload, meta?: Meta) => void;
|
|
24
29
|
};
|
|
25
|
-
subscribe: (callback: () => void) => () => void;
|
|
26
|
-
labels?: {
|
|
27
|
-
singular: string;
|
|
28
|
-
plural: string;
|
|
29
|
-
};
|
|
30
|
-
reservedLabel?: string;
|
|
31
|
-
limit?: number;
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
declare const stylesRepository: {
|
|
@@ -37,19 +35,51 @@ declare const stylesRepository: {
|
|
|
37
35
|
subscribe: (cb: () => void) => () => void;
|
|
38
36
|
getProviders: () => StylesProvider[];
|
|
39
37
|
getProviderByKey: (key: string) => StylesProvider | undefined;
|
|
40
|
-
isLabelExist: (newLabel: string) => boolean;
|
|
41
|
-
isLabelValid: (newLabel: string) => boolean;
|
|
42
38
|
};
|
|
43
39
|
|
|
44
40
|
declare function useProviders(): StylesProvider[];
|
|
45
41
|
|
|
46
42
|
type CreateAction = Required<StylesProvider['actions']>['create'];
|
|
47
43
|
type CreateTuple = [StylesProvider, CreateAction];
|
|
48
|
-
declare function
|
|
44
|
+
declare function useGetStylesRepositoryCreateAction(): CreateTuple | null;
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
type ValidationEvent = 'inputChange' | 'create' | 'rename';
|
|
47
|
+
type ValidationResult = {
|
|
48
|
+
isValid: true;
|
|
49
|
+
errorMessage: null;
|
|
50
|
+
} | {
|
|
51
|
+
isValid: false;
|
|
52
|
+
errorMessage: string;
|
|
53
|
+
};
|
|
54
|
+
declare function validateStyleLabel(label: string, event: ValidationEvent | 'rename'): ValidationResult;
|
|
55
|
+
|
|
56
|
+
type CreateStylesProviderOptions = {
|
|
57
|
+
key: string | (() => string);
|
|
58
|
+
priority?: number;
|
|
59
|
+
limit?: number;
|
|
60
|
+
subscribe?: (callback: () => void) => () => void;
|
|
61
|
+
labels?: {
|
|
62
|
+
singular: string;
|
|
63
|
+
plural: string;
|
|
64
|
+
};
|
|
65
|
+
actions: {
|
|
66
|
+
all: StylesProvider['actions']['all'];
|
|
67
|
+
get: StylesProvider['actions']['get'];
|
|
68
|
+
create?: StylesProvider['actions']['create'];
|
|
69
|
+
delete?: StylesProvider['actions']['delete'];
|
|
70
|
+
update?: StylesProvider['actions']['update'];
|
|
71
|
+
updateProps?: StylesProvider['actions']['updateProps'];
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
declare function createStylesProvider({ key, priority, limit, subscribe, labels, actions, }: CreateStylesProviderOptions): StylesProvider;
|
|
75
|
+
|
|
76
|
+
declare function isElementsStylesProvider(key: string): boolean;
|
|
52
77
|
|
|
53
78
|
declare const ELEMENTS_BASE_STYLES_PROVIDER_KEY = "element-base-styles";
|
|
54
79
|
|
|
55
|
-
|
|
80
|
+
declare const ELEMENTS_STYLES_PROVIDER_KEY_PREFIX = "document-elements-";
|
|
81
|
+
declare const ELEMENTS_STYLES_RESERVED_LABEL = "local";
|
|
82
|
+
|
|
83
|
+
declare function init(): void;
|
|
84
|
+
|
|
85
|
+
export { type CreateStylesProviderOptions, ELEMENTS_BASE_STYLES_PROVIDER_KEY, ELEMENTS_STYLES_PROVIDER_KEY_PREFIX, ELEMENTS_STYLES_RESERVED_LABEL, type Meta, type StylesProvider, type UpdateActionPayload, type UpdatePropsActionPayload, createStylesProvider, init, isElementsStylesProvider, stylesRepository, useGetStylesRepositoryCreateAction, useProviders, validateStyleLabel };
|
package/dist/index.js
CHANGED
|
@@ -21,16 +21,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ELEMENTS_BASE_STYLES_PROVIDER_KEY: () => ELEMENTS_BASE_STYLES_PROVIDER_KEY,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
ELEMENTS_STYLES_PROVIDER_KEY_PREFIX: () => ELEMENTS_STYLES_PROVIDER_KEY_PREFIX,
|
|
25
|
+
ELEMENTS_STYLES_RESERVED_LABEL: () => ELEMENTS_STYLES_RESERVED_LABEL,
|
|
26
|
+
createStylesProvider: () => createStylesProvider,
|
|
27
|
+
init: () => init,
|
|
28
|
+
isElementsStylesProvider: () => isElementsStylesProvider,
|
|
26
29
|
stylesRepository: () => stylesRepository,
|
|
27
|
-
|
|
28
|
-
useProviders: () => useProviders
|
|
30
|
+
useGetStylesRepositoryCreateAction: () => useGetStylesRepositoryCreateAction,
|
|
31
|
+
useProviders: () => useProviders,
|
|
32
|
+
validateStyleLabel: () => validateStyleLabel
|
|
29
33
|
});
|
|
30
34
|
module.exports = __toCommonJS(index_exports);
|
|
31
35
|
|
|
32
36
|
// src/utils/create-styles-repository.ts
|
|
33
|
-
var VALID_SELECTOR_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
34
37
|
var createStylesRepository = () => {
|
|
35
38
|
const providers = [];
|
|
36
39
|
const getProviders = () => {
|
|
@@ -40,7 +43,7 @@ var createStylesRepository = () => {
|
|
|
40
43
|
providers.push(provider);
|
|
41
44
|
};
|
|
42
45
|
const all = (meta = {}) => {
|
|
43
|
-
return getProviders().flatMap((provider) => provider.actions.
|
|
46
|
+
return getProviders().flatMap((provider) => provider.actions.all(meta));
|
|
44
47
|
};
|
|
45
48
|
const subscribe = (cb) => {
|
|
46
49
|
const unsubscribes = providers.map((provider) => {
|
|
@@ -51,28 +54,14 @@ var createStylesRepository = () => {
|
|
|
51
54
|
};
|
|
52
55
|
};
|
|
53
56
|
const getProviderByKey = (key) => {
|
|
54
|
-
return providers.find((provider) => provider.
|
|
57
|
+
return providers.find((provider) => provider.getKey() === key);
|
|
55
58
|
};
|
|
56
|
-
const isLabelExist = (newLabel) => {
|
|
57
|
-
const classes = all();
|
|
58
|
-
const reservedLabels = providers.map(({ reservedLabel }) => reservedLabel).filter(Boolean);
|
|
59
|
-
if (reservedLabels.includes(newLabel)) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
if (!classes?.length) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
return classes.some(({ label }) => label.toLowerCase() === newLabel.toLowerCase());
|
|
66
|
-
};
|
|
67
|
-
const isLabelValid = (newLabel) => VALID_SELECTOR_REGEX.test(newLabel);
|
|
68
59
|
return {
|
|
69
60
|
all,
|
|
70
61
|
register,
|
|
71
62
|
subscribe,
|
|
72
63
|
getProviders,
|
|
73
|
-
getProviderByKey
|
|
74
|
-
isLabelExist,
|
|
75
|
-
isLabelValid
|
|
64
|
+
getProviderByKey
|
|
76
65
|
};
|
|
77
66
|
};
|
|
78
67
|
|
|
@@ -87,20 +76,30 @@ function useProviders() {
|
|
|
87
76
|
return stylesRepository.getProviders();
|
|
88
77
|
}
|
|
89
78
|
|
|
90
|
-
// src/hooks/use-
|
|
79
|
+
// src/hooks/use-get-styles-repository-create-action.ts
|
|
91
80
|
var import_react2 = require("react");
|
|
92
|
-
function
|
|
81
|
+
function useGetStylesRepositoryCreateAction() {
|
|
93
82
|
return (0, import_react2.useMemo)(() => {
|
|
94
|
-
|
|
83
|
+
const createActions = stylesRepository.getProviders().map((provider) => {
|
|
95
84
|
if (!provider.actions.create) {
|
|
96
85
|
return null;
|
|
97
86
|
}
|
|
98
87
|
return [provider, provider.actions.create];
|
|
99
88
|
}).filter((item) => !!item);
|
|
89
|
+
if (createActions.length === 1) {
|
|
90
|
+
return createActions[0];
|
|
91
|
+
} else if (createActions.length === 0) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
throw new Error("Multiple providers with create action found in styles repository.");
|
|
100
95
|
}, []);
|
|
101
96
|
}
|
|
102
97
|
|
|
103
|
-
// src/
|
|
98
|
+
// src/utils/validate-style-label.ts
|
|
99
|
+
var import_schema = require("@elementor/schema");
|
|
100
|
+
var import_i18n = require("@wordpress/i18n");
|
|
101
|
+
|
|
102
|
+
// src/providers/document-elements-styles-provider.ts
|
|
104
103
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
105
104
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
106
105
|
|
|
@@ -110,22 +109,65 @@ var InvalidElementsStyleProviderMetaError = (0, import_utils.createError)({
|
|
|
110
109
|
code: "invalid_elements_style_provider_meta",
|
|
111
110
|
message: "Invalid elements style provider meta."
|
|
112
111
|
});
|
|
112
|
+
var ActiveDocumentMustExistError = (0, import_utils.createError)({
|
|
113
|
+
code: "active_document_must_exist",
|
|
114
|
+
message: "Active document must exist."
|
|
115
|
+
});
|
|
113
116
|
|
|
114
|
-
// src/
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
key
|
|
117
|
+
// src/utils/create-styles-provider.ts
|
|
118
|
+
var DEFAULT_LIMIT = 1e4;
|
|
119
|
+
var DEFAULT_PRIORITY = 10;
|
|
120
|
+
function createStylesProvider({
|
|
121
|
+
key,
|
|
122
|
+
priority = DEFAULT_PRIORITY,
|
|
123
|
+
limit = DEFAULT_LIMIT,
|
|
124
|
+
subscribe = () => () => {
|
|
125
|
+
},
|
|
126
|
+
labels,
|
|
127
|
+
actions
|
|
128
|
+
}) {
|
|
129
|
+
return {
|
|
130
|
+
getKey: typeof key === "string" ? () => key : key,
|
|
131
|
+
priority,
|
|
132
|
+
limit,
|
|
133
|
+
subscribe,
|
|
134
|
+
labels: {
|
|
135
|
+
singular: labels?.singular ?? null,
|
|
136
|
+
plural: labels?.plural ?? null
|
|
137
|
+
},
|
|
138
|
+
actions: {
|
|
139
|
+
all: actions.all,
|
|
140
|
+
get: actions.get,
|
|
141
|
+
create: actions.create,
|
|
142
|
+
delete: actions.delete,
|
|
143
|
+
update: actions.update,
|
|
144
|
+
updateProps: actions.updateProps
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/providers/document-elements-styles-provider.ts
|
|
150
|
+
var ELEMENTS_STYLES_PROVIDER_KEY_PREFIX = "document-elements-";
|
|
151
|
+
var ELEMENTS_STYLES_RESERVED_LABEL = "local";
|
|
152
|
+
var documentElementsStylesProvider = createStylesProvider({
|
|
153
|
+
key: () => {
|
|
154
|
+
const documentId = (0, import_editor_elements.getCurrentDocumentId)();
|
|
155
|
+
if (!documentId) {
|
|
156
|
+
throw new ActiveDocumentMustExistError();
|
|
157
|
+
}
|
|
158
|
+
return `${ELEMENTS_STYLES_PROVIDER_KEY_PREFIX}${documentId}`;
|
|
159
|
+
},
|
|
119
160
|
priority: 50,
|
|
161
|
+
subscribe: (cb) => (0, import_editor_v1_adapters.__privateListenTo)(import_editor_elements.styleRerenderEvents, cb),
|
|
120
162
|
actions: {
|
|
121
|
-
|
|
163
|
+
all: (meta = {}) => {
|
|
122
164
|
let elements = (0, import_editor_elements.getElements)();
|
|
123
165
|
if (isValidElementsMeta(meta)) {
|
|
124
166
|
elements = elements.filter((element) => element.id === meta.elementId);
|
|
125
167
|
}
|
|
126
168
|
return elements.flatMap((element) => Object.values(element.model.get("styles") ?? {}));
|
|
127
169
|
},
|
|
128
|
-
|
|
170
|
+
get: (id, meta = {}) => {
|
|
129
171
|
if (!isValidElementsMeta(meta)) {
|
|
130
172
|
throw new InvalidElementsStyleProviderMetaError({ context: { meta } });
|
|
131
173
|
}
|
|
@@ -143,52 +185,98 @@ var elementsStylesProvider = {
|
|
|
143
185
|
props: args.props
|
|
144
186
|
});
|
|
145
187
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
reservedLabel: LOCAL_STYLES_RESERVED_LABEL
|
|
149
|
-
};
|
|
188
|
+
}
|
|
189
|
+
});
|
|
150
190
|
function isValidElementsMeta(meta) {
|
|
151
191
|
return "elementId" in meta && typeof meta.elementId === "string" && !!meta.elementId;
|
|
152
192
|
}
|
|
153
193
|
|
|
154
|
-
// src/
|
|
194
|
+
// src/utils/validate-style-label.ts
|
|
195
|
+
var NO_START_DIGIT_REGEX = /^(|[^0-9].*)$/;
|
|
196
|
+
var NO_SPACES_REGEX = /^\S*$/;
|
|
197
|
+
var NO_SPECIAL_CHARS_REGEX = /^(|[a-zA-Z0-9_-]+)$/;
|
|
198
|
+
var NO_DOUBLE_HYPHEN_START_REGEX = /^(?!--).*/;
|
|
199
|
+
var NO_HYPHEN_DIGIT_START_REGEX = /^(?!-[0-9])/;
|
|
200
|
+
var NO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX = /^(?!.*(--|__)).*/;
|
|
201
|
+
var NO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX = /^(?![-_]).*(?<![-_])$/;
|
|
202
|
+
var RESERVED_CLASS_NAMES = ["container"];
|
|
203
|
+
var schema = import_schema.z.string().max(50, (0, import_i18n.__)("Class name is too long. Please keep it under 50 characters.", "elementor")).regex(NO_START_DIGIT_REGEX, (0, import_i18n.__)("Class names must start with a letter.", "elementor")).regex(NO_SPACES_REGEX, (0, import_i18n.__)("Class names can\u2019t contain spaces.", "elementor")).regex(
|
|
204
|
+
NO_SPECIAL_CHARS_REGEX,
|
|
205
|
+
(0, import_i18n.__)("Class names can only use letters, numbers, dashes (-), and underscores (_).", "elementor")
|
|
206
|
+
).regex(NO_DOUBLE_HYPHEN_START_REGEX, (0, import_i18n.__)("Double hyphens are reserved for custom properties.", "elementor")).regex(
|
|
207
|
+
NO_HYPHEN_DIGIT_START_REGEX,
|
|
208
|
+
(0, import_i18n.__)("Class names can\u2019t start with a hyphen followed by a number.", "elementor")
|
|
209
|
+
).regex(
|
|
210
|
+
NO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX,
|
|
211
|
+
(0, import_i18n.__)("Avoid using multiple dashes or underscores in a row.", "elementor")
|
|
212
|
+
).regex(
|
|
213
|
+
NO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX,
|
|
214
|
+
(0, import_i18n.__)("Class names can\u2019t start or end with a dash or underscore.", "elementor")
|
|
215
|
+
).refine((value) => !RESERVED_CLASS_NAMES.includes(value), {
|
|
216
|
+
message: (0, import_i18n.__)("This name is reserved and can\u2019t be used. Try something more specific.", "elementor")
|
|
217
|
+
});
|
|
218
|
+
function validateStyleLabel(label, event) {
|
|
219
|
+
const existingLabels = /* @__PURE__ */ new Set([
|
|
220
|
+
ELEMENTS_STYLES_RESERVED_LABEL,
|
|
221
|
+
...stylesRepository.all().map((styleDef) => styleDef.label.toLowerCase())
|
|
222
|
+
]);
|
|
223
|
+
const fullValidationEvent = ["create", "rename"].includes(event);
|
|
224
|
+
const result = schema.refine((value) => !(fullValidationEvent && value.length < 2), {
|
|
225
|
+
message: (0, import_i18n.__)("Class name is too short. Use at least 2 characters.", "elementor")
|
|
226
|
+
}).refine((value) => !(fullValidationEvent && existingLabels.has(value)), {
|
|
227
|
+
message: (0, import_i18n.__)("This class name already exists. Please choose a unique name.", "elementor")
|
|
228
|
+
}).safeParse(label.toLowerCase());
|
|
229
|
+
if (result.success) {
|
|
230
|
+
return {
|
|
231
|
+
isValid: true,
|
|
232
|
+
errorMessage: null
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
isValid: false,
|
|
237
|
+
errorMessage: result.error.format()._errors[0]
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/utils/is-elements-styles-provider.ts
|
|
242
|
+
function isElementsStylesProvider(key) {
|
|
243
|
+
return new RegExp(`^${ELEMENTS_STYLES_PROVIDER_KEY_PREFIX}\\d+$`).test(key);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/providers/element-base-styles-provider.ts
|
|
155
247
|
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
156
248
|
var ELEMENTS_BASE_STYLES_PROVIDER_KEY = "element-base-styles";
|
|
157
|
-
var elementBaseStylesProvider = {
|
|
249
|
+
var elementBaseStylesProvider = createStylesProvider({
|
|
158
250
|
key: ELEMENTS_BASE_STYLES_PROVIDER_KEY,
|
|
159
|
-
priority: 10,
|
|
160
251
|
actions: {
|
|
161
|
-
|
|
252
|
+
all() {
|
|
162
253
|
const widgetsCache = (0, import_editor_elements2.getWidgetsCache)();
|
|
163
254
|
return Object.values(widgetsCache ?? {}).flatMap(
|
|
164
255
|
(widget) => Object.values(widget.base_styles ?? {})
|
|
165
256
|
);
|
|
166
257
|
},
|
|
167
|
-
|
|
168
|
-
return this.
|
|
258
|
+
get(id) {
|
|
259
|
+
return this.all().find((style) => style.id === id) ?? null;
|
|
169
260
|
}
|
|
170
|
-
},
|
|
171
|
-
subscribe: () => {
|
|
172
|
-
return () => {
|
|
173
|
-
};
|
|
174
261
|
}
|
|
175
|
-
};
|
|
262
|
+
});
|
|
176
263
|
|
|
177
264
|
// src/init.ts
|
|
178
265
|
function init() {
|
|
179
|
-
stylesRepository.register(
|
|
266
|
+
stylesRepository.register(documentElementsStylesProvider);
|
|
180
267
|
stylesRepository.register(elementBaseStylesProvider);
|
|
181
268
|
}
|
|
182
|
-
|
|
183
|
-
// src/index.ts
|
|
184
|
-
init();
|
|
185
269
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
270
|
0 && (module.exports = {
|
|
187
271
|
ELEMENTS_BASE_STYLES_PROVIDER_KEY,
|
|
188
|
-
|
|
189
|
-
|
|
272
|
+
ELEMENTS_STYLES_PROVIDER_KEY_PREFIX,
|
|
273
|
+
ELEMENTS_STYLES_RESERVED_LABEL,
|
|
274
|
+
createStylesProvider,
|
|
275
|
+
init,
|
|
276
|
+
isElementsStylesProvider,
|
|
190
277
|
stylesRepository,
|
|
191
|
-
|
|
192
|
-
useProviders
|
|
278
|
+
useGetStylesRepositoryCreateAction,
|
|
279
|
+
useProviders,
|
|
280
|
+
validateStyleLabel
|
|
193
281
|
});
|
|
194
282
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/create-styles-repository.ts","../src/styles-repository.ts","../src/hooks/use-providers.ts","../src/hooks/use-create-actions-by-provider.ts","../src/elements-styles-provider.ts","../src/errors.ts","../src/element-base-styles-provider.ts","../src/init.ts"],"sourcesContent":["export {\n\ttype StylesProvider,\n\ttype UpdateActionPayload,\n\ttype Meta,\n\ttype UpdatePropsActionPayload,\n} from './utils/create-styles-repository';\n\nexport { stylesRepository } from './styles-repository';\nexport { useProviders } from './hooks/use-providers';\nexport { useCreateActionsByProvider } from './hooks/use-create-actions-by-provider';\n\nexport { ELEMENTS_STYLES_PROVIDER_KEY, LOCAL_STYLES_RESERVED_LABEL } from './elements-styles-provider';\nexport { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from './element-base-styles-provider';\n\nimport { init } from './init';\n\ninit();\n","import { type Props } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\ntype MakeOptional< T, K extends keyof T > = Omit< T, K > & Partial< T >;\n\nexport type UpdateActionPayload = MakeOptional< StyleDefinition, 'label' | 'variants' | 'type' >;\n\nexport type UpdatePropsActionPayload = {\n\tid: StyleDefinitionID;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: Props;\n};\n\nexport type Meta = Record< string, unknown >;\n\nexport type StylesProvider = {\n\tkey: string;\n\tpriority: number;\n\tactions: {\n\t\tget: ( meta?: Meta ) => StyleDefinition[];\n\t\tgetById: ( id: StyleDefinitionID, meta?: Meta ) => StyleDefinition | null;\n\t\tcreate?: ( label: StyleDefinition[ 'label' ] ) => StyleDefinitionID;\n\t\tdelete?: ( id: StyleDefinitionID ) => void;\n\t\tsetOrder?: ( order: StyleDefinitionID[] ) => void;\n\t\tupdate?: ( data: UpdateActionPayload ) => void;\n\t\tupdateProps?: ( args: UpdatePropsActionPayload, meta?: Meta ) => void;\n\t};\n\tsubscribe: ( callback: () => void ) => () => void;\n\tlabels?: {\n\t\tsingular: string;\n\t\tplural: string;\n\t};\n\treservedLabel?: string;\n\tlimit?: number;\n};\n\nconst VALID_SELECTOR_REGEX = /^[a-zA-Z0-9_-]+$/;\n\nexport const createStylesRepository = () => {\n\tconst providers: StylesProvider[] = [];\n\n\tconst getProviders = () => {\n\t\treturn providers.slice( 0 ).sort( ( a, b ) => ( a.priority > b.priority ? -1 : 1 ) );\n\t};\n\n\tconst register = ( provider: StylesProvider ) => {\n\t\tproviders.push( provider );\n\t};\n\n\tconst all = ( meta: Meta = {} ) => {\n\t\treturn getProviders().flatMap( ( provider ) => provider.actions.get( meta ) );\n\t};\n\n\tconst subscribe = ( cb: () => void ) => {\n\t\tconst unsubscribes = providers.map( ( provider ) => {\n\t\t\treturn provider.subscribe( cb );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribes.forEach( ( unsubscribe ) => unsubscribe() );\n\t\t};\n\t};\n\n\tconst getProviderByKey = ( key: string ) => {\n\t\treturn providers.find( ( provider ) => provider.key === key );\n\t};\n\n\tconst isLabelExist = ( newLabel: string ) => {\n\t\tconst classes = all();\n\t\tconst reservedLabels = providers.map( ( { reservedLabel } ) => reservedLabel ).filter( Boolean );\n\n\t\tif ( reservedLabels.includes( newLabel ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! classes?.length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn classes.some( ( { label } ) => label.toLowerCase() === newLabel.toLowerCase() );\n\t};\n\n\tconst isLabelValid = ( newLabel: string ) => VALID_SELECTOR_REGEX.test( newLabel );\n\n\treturn {\n\t\tall,\n\t\tregister,\n\t\tsubscribe,\n\t\tgetProviders,\n\t\tgetProviderByKey,\n\t\tisLabelExist,\n\t\tisLabelValid,\n\t};\n};\n","import { createStylesRepository } from './utils/create-styles-repository';\n\nexport const stylesRepository = createStylesRepository();\n","import { useEffect, useReducer } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\n\nexport function useProviders() {\n\tconst [ , rerender ] = useReducer( ( prev ) => ! prev, false );\n\n\tuseEffect( () => stylesRepository.subscribe( rerender ), [] );\n\n\treturn stylesRepository.getProviders();\n}\n","import { useMemo } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\nimport { type StylesProvider } from '../utils/create-styles-repository';\n\ntype CreateAction = Required< StylesProvider[ 'actions' ] >[ 'create' ];\ntype CreateTuple = [ StylesProvider, CreateAction ];\n\nexport function useCreateActionsByProvider() {\n\treturn useMemo( () => {\n\t\treturn stylesRepository\n\t\t\t.getProviders()\n\t\t\t.map< CreateTuple | null >( ( provider ) => {\n\t\t\t\tif ( ! provider.actions.create ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn [ provider, provider.actions.create ];\n\t\t\t} )\n\t\t\t.filter( ( item ) => !! item );\n\t}, [] );\n}\n","import { getElements, getElementStyles, styleRerenderEvents, updateElementStyle } from '@elementor/editor-elements';\nimport { __privateListenTo as listenTo } from '@elementor/editor-v1-adapters';\n\nimport { InvalidElementsStyleProviderMetaError } from './errors';\nimport { type StylesProvider } from './utils/create-styles-repository';\n\nexport const ELEMENTS_STYLES_PROVIDER_KEY = 'elements';\nexport const LOCAL_STYLES_RESERVED_LABEL = 'local';\n\nexport const elementsStylesProvider = {\n\tkey: ELEMENTS_STYLES_PROVIDER_KEY,\n\tpriority: 50,\n\tactions: {\n\t\tget: ( meta = {} ) => {\n\t\t\tlet elements = getElements();\n\n\t\t\tif ( isValidElementsMeta( meta ) ) {\n\t\t\t\telements = elements.filter( ( element ) => element.id === meta.elementId );\n\t\t\t}\n\n\t\t\treturn elements.flatMap( ( element ) => Object.values( element.model.get( 'styles' ) ?? {} ) );\n\t\t},\n\n\t\tgetById: ( id, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tconst styles = getElementStyles( meta.elementId ) ?? {};\n\n\t\t\treturn styles[ id ] ?? null;\n\t\t},\n\n\t\tupdateProps: ( args, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tupdateElementStyle( {\n\t\t\t\telementId: meta.elementId,\n\t\t\t\tstyleId: args.id,\n\t\t\t\tmeta: args.meta,\n\t\t\t\tprops: args.props,\n\t\t\t} );\n\t\t},\n\t},\n\tsubscribe: ( cb ) => listenTo( styleRerenderEvents, cb ),\n\treservedLabel: LOCAL_STYLES_RESERVED_LABEL,\n} satisfies StylesProvider;\n\ntype ElementsMeta = {\n\telementId: string;\n};\n\nfunction isValidElementsMeta( meta: Record< string, unknown > ): meta is ElementsMeta {\n\treturn 'elementId' in meta && typeof meta.elementId === 'string' && !! meta.elementId;\n}\n","import { createError } from '@elementor/utils';\n\nexport const InvalidElementsStyleProviderMetaError = createError< { meta: Record< string, unknown > } >( {\n\tcode: 'invalid_elements_style_provider_meta',\n\tmessage: 'Invalid elements style provider meta.',\n} );\n","import { getWidgetsCache } from '@elementor/editor-elements';\n\nimport { type StylesProvider } from './utils/create-styles-repository';\n\nexport const ELEMENTS_BASE_STYLES_PROVIDER_KEY = 'element-base-styles';\n\nexport const elementBaseStylesProvider: StylesProvider = {\n\tkey: ELEMENTS_BASE_STYLES_PROVIDER_KEY,\n\tpriority: 10,\n\tactions: {\n\t\tget() {\n\t\t\tconst widgetsCache = getWidgetsCache();\n\n\t\t\treturn Object.values( widgetsCache ?? {} ).flatMap( ( widget ) =>\n\t\t\t\tObject.values( widget.base_styles ?? {} )\n\t\t\t);\n\t\t},\n\n\t\tgetById( id ) {\n\t\t\treturn this.get().find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n\tsubscribe: () => {\n\t\treturn () => {};\n\t},\n};\n","import { elementBaseStylesProvider } from './element-base-styles-provider';\nimport { elementsStylesProvider } from './elements-styles-provider';\nimport { stylesRepository } from './styles-repository';\n\nexport function init() {\n\tstylesRepository.register( elementsStylesProvider );\n\tstylesRepository.register( elementBaseStylesProvider );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoCA,IAAM,uBAAuB;AAEtB,IAAM,yBAAyB,MAAM;AAC3C,QAAM,YAA8B,CAAC;AAErC,QAAM,eAAe,MAAM;AAC1B,WAAO,UAAU,MAAO,CAAE,EAAE,KAAM,CAAE,GAAG,MAAS,EAAE,WAAW,EAAE,WAAW,KAAK,CAAI;AAAA,EACpF;AAEA,QAAM,WAAW,CAAE,aAA8B;AAChD,cAAU,KAAM,QAAS;AAAA,EAC1B;AAEA,QAAM,MAAM,CAAE,OAAa,CAAC,MAAO;AAClC,WAAO,aAAa,EAAE,QAAS,CAAE,aAAc,SAAS,QAAQ,IAAK,IAAK,CAAE;AAAA,EAC7E;AAEA,QAAM,YAAY,CAAE,OAAoB;AACvC,UAAM,eAAe,UAAU,IAAK,CAAE,aAAc;AACnD,aAAO,SAAS,UAAW,EAAG;AAAA,IAC/B,CAAE;AAEF,WAAO,MAAM;AACZ,mBAAa,QAAS,CAAE,gBAAiB,YAAY,CAAE;AAAA,IACxD;AAAA,EACD;AAEA,QAAM,mBAAmB,CAAE,QAAiB;AAC3C,WAAO,UAAU,KAAM,CAAE,aAAc,SAAS,QAAQ,GAAI;AAAA,EAC7D;AAEA,QAAM,eAAe,CAAE,aAAsB;AAC5C,UAAM,UAAU,IAAI;AACpB,UAAM,iBAAiB,UAAU,IAAK,CAAE,EAAE,cAAc,MAAO,aAAc,EAAE,OAAQ,OAAQ;AAE/F,QAAK,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C,CAAE;AAAA,MACzC;AAAA,IACD;AAAA,IAEA,QAAS,IAAK;AACb,aAAO,KAAK,IAAI,EAAE,KAAM,CAAE,UAAW,MAAM,OAAO,EAAG,KAAK;AAAA,IAC3D;AAAA,EACD;AAAA,EACA,WAAW,MAAM;AAChB,WAAO,MAAM;AAAA,IAAC;AAAA,EACf;AACD;;;ACrBO,SAAS,OAAO;AACtB,mBAAiB,SAAU,sBAAuB;AAClD,mBAAiB,SAAU,yBAA0B;AACtD;;;ARSA,KAAK;","names":["import_react","listenTo","import_editor_elements"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/create-styles-repository.ts","../src/styles-repository.ts","../src/hooks/use-providers.ts","../src/hooks/use-get-styles-repository-create-action.ts","../src/utils/validate-style-label.ts","../src/providers/document-elements-styles-provider.ts","../src/errors.ts","../src/utils/create-styles-provider.ts","../src/utils/is-elements-styles-provider.ts","../src/providers/element-base-styles-provider.ts","../src/init.ts"],"sourcesContent":["export * from './types';\n\nexport { stylesRepository } from './styles-repository';\nexport { useProviders } from './hooks/use-providers';\nexport { useGetStylesRepositoryCreateAction } from './hooks/use-get-styles-repository-create-action';\nexport { validateStyleLabel } from './utils/validate-style-label';\nexport { createStylesProvider, type CreateStylesProviderOptions } from './utils/create-styles-provider';\nexport { isElementsStylesProvider } from './utils/is-elements-styles-provider';\n\nexport { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from './providers/element-base-styles-provider';\nexport {\n\tELEMENTS_STYLES_PROVIDER_KEY_PREFIX,\n\tELEMENTS_STYLES_RESERVED_LABEL,\n} from './providers/document-elements-styles-provider';\n\nexport { init } from './init';\n","import { type Meta, type StylesProvider } from '../types';\n\nexport const createStylesRepository = () => {\n\tconst providers: StylesProvider[] = [];\n\n\tconst getProviders = () => {\n\t\treturn providers.slice( 0 ).sort( ( a, b ) => ( a.priority > b.priority ? -1 : 1 ) );\n\t};\n\n\tconst register = ( provider: StylesProvider ) => {\n\t\tproviders.push( provider );\n\t};\n\n\tconst all = ( meta: Meta = {} ) => {\n\t\treturn getProviders().flatMap( ( provider ) => provider.actions.all( meta ) );\n\t};\n\n\tconst subscribe = ( cb: () => void ) => {\n\t\tconst unsubscribes = providers.map( ( provider ) => {\n\t\t\treturn provider.subscribe( cb );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribes.forEach( ( unsubscribe ) => unsubscribe() );\n\t\t};\n\t};\n\n\tconst getProviderByKey = ( key: string ) => {\n\t\treturn providers.find( ( provider ) => provider.getKey() === key );\n\t};\n\n\treturn {\n\t\tall,\n\t\tregister,\n\t\tsubscribe,\n\t\tgetProviders,\n\t\tgetProviderByKey,\n\t};\n};\n","import { createStylesRepository } from './utils/create-styles-repository';\n\nexport const stylesRepository = createStylesRepository();\n","import { useEffect, useReducer } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\n\nexport function useProviders() {\n\tconst [ , rerender ] = useReducer( ( prev ) => ! prev, false );\n\n\tuseEffect( () => stylesRepository.subscribe( rerender ), [] );\n\n\treturn stylesRepository.getProviders();\n}\n","import { useMemo } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\nimport { type StylesProvider } from '../types';\n\ntype CreateAction = Required< StylesProvider[ 'actions' ] >[ 'create' ];\ntype CreateTuple = [ StylesProvider, CreateAction ];\n\nexport function useGetStylesRepositoryCreateAction() {\n\treturn useMemo( () => {\n\t\tconst createActions = stylesRepository\n\t\t\t.getProviders()\n\t\t\t.map< CreateTuple | null >( ( provider ) => {\n\t\t\t\tif ( ! provider.actions.create ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn [ provider, provider.actions.create ];\n\t\t\t} )\n\t\t\t.filter( ( item ) => !! item );\n\n\t\tif ( createActions.length === 1 ) {\n\t\t\treturn createActions[ 0 ];\n\t\t} else if ( createActions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow new Error( 'Multiple providers with create action found in styles repository.' );\n\t}, [] );\n}\n","import { z } from '@elementor/schema';\nimport { __ } from '@wordpress/i18n';\n\nimport { ELEMENTS_STYLES_RESERVED_LABEL } from '../providers/document-elements-styles-provider';\nimport { stylesRepository } from '../styles-repository';\n\nconst NO_START_DIGIT_REGEX = /^(|[^0-9].*)$/;\nconst NO_SPACES_REGEX = /^\\S*$/;\nconst NO_SPECIAL_CHARS_REGEX = /^(|[a-zA-Z0-9_-]+)$/;\nconst NO_DOUBLE_HYPHEN_START_REGEX = /^(?!--).*/;\nconst NO_HYPHEN_DIGIT_START_REGEX = /^(?!-[0-9])/;\nconst NO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX = /^(?!.*(--|__)).*/;\nconst NO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX = /^(?![-_]).*(?<![-_])$/;\n\nconst RESERVED_CLASS_NAMES = [ 'container' ];\n\nconst schema = z\n\t.string()\n\t.max( 50, __( 'Class name is too long. Please keep it under 50 characters.', 'elementor' ) )\n\t.regex( NO_START_DIGIT_REGEX, __( 'Class names must start with a letter.', 'elementor' ) )\n\t.regex( NO_SPACES_REGEX, __( 'Class names can’t contain spaces.', 'elementor' ) )\n\t.regex(\n\t\tNO_SPECIAL_CHARS_REGEX,\n\t\t__( 'Class names can only use letters, numbers, dashes (-), and underscores (_).', 'elementor' )\n\t)\n\t.regex( NO_DOUBLE_HYPHEN_START_REGEX, __( 'Double hyphens are reserved for custom properties.', 'elementor' ) )\n\t.regex(\n\t\tNO_HYPHEN_DIGIT_START_REGEX,\n\t\t__( 'Class names can’t start with a hyphen followed by a number.', 'elementor' )\n\t)\n\t.regex(\n\t\tNO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX,\n\t\t__( 'Avoid using multiple dashes or underscores in a row.', 'elementor' )\n\t)\n\t.regex(\n\t\tNO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX,\n\t\t__( 'Class names can’t start or end with a dash or underscore.', 'elementor' )\n\t)\n\t.refine( ( value ) => ! RESERVED_CLASS_NAMES.includes( value ), {\n\t\tmessage: __( 'This name is reserved and can’t be used. Try something more specific.', 'elementor' ),\n\t} );\n\ntype ValidationEvent = 'inputChange' | 'create' | 'rename';\ntype ValidationResult = { isValid: true; errorMessage: null } | { isValid: false; errorMessage: string };\n\nexport function validateStyleLabel( label: string, event: ValidationEvent | 'rename' ): ValidationResult {\n\tconst existingLabels = new Set( [\n\t\tELEMENTS_STYLES_RESERVED_LABEL,\n\t\t...stylesRepository.all().map( ( styleDef ) => styleDef.label.toLowerCase() ),\n\t] );\n\n\tconst fullValidationEvent = [ 'create', 'rename' ].includes( event );\n\n\tconst result = schema\n\t\t.refine( ( value ) => ! ( fullValidationEvent && value.length < 2 ), {\n\t\t\tmessage: __( 'Class name is too short. Use at least 2 characters.', 'elementor' ),\n\t\t} )\n\t\t.refine( ( value ) => ! ( fullValidationEvent && existingLabels.has( value ) ), {\n\t\t\tmessage: __( 'This class name already exists. Please choose a unique name.', 'elementor' ),\n\t\t} )\n\t\t.safeParse( label.toLowerCase() );\n\n\tif ( result.success ) {\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\terrorMessage: null,\n\t\t};\n\t}\n\n\treturn {\n\t\tisValid: false,\n\t\terrorMessage: result.error.format()._errors[ 0 ],\n\t};\n}\n","import {\n\tgetCurrentDocumentId,\n\tgetElements,\n\tgetElementStyles,\n\tstyleRerenderEvents,\n\tupdateElementStyle,\n} from '@elementor/editor-elements';\nimport { __privateListenTo as listenTo } from '@elementor/editor-v1-adapters';\n\nimport { ActiveDocumentMustExistError, InvalidElementsStyleProviderMetaError } from '../errors';\nimport { createStylesProvider } from '../utils/create-styles-provider';\n\nexport const ELEMENTS_STYLES_PROVIDER_KEY_PREFIX = 'document-elements-';\nexport const ELEMENTS_STYLES_RESERVED_LABEL = 'local';\n\ntype ElementsMeta = {\n\telementId: string;\n};\n\nexport const documentElementsStylesProvider = createStylesProvider( {\n\tkey: () => {\n\t\tconst documentId = getCurrentDocumentId();\n\n\t\tif ( ! documentId ) {\n\t\t\tthrow new ActiveDocumentMustExistError();\n\t\t}\n\n\t\treturn `${ ELEMENTS_STYLES_PROVIDER_KEY_PREFIX }${ documentId }`;\n\t},\n\tpriority: 50,\n\tsubscribe: ( cb ) => listenTo( styleRerenderEvents, cb ),\n\tactions: {\n\t\tall: ( meta = {} ) => {\n\t\t\tlet elements = getElements();\n\n\t\t\tif ( isValidElementsMeta( meta ) ) {\n\t\t\t\telements = elements.filter( ( element ) => element.id === meta.elementId );\n\t\t\t}\n\n\t\t\treturn elements.flatMap( ( element ) => Object.values( element.model.get( 'styles' ) ?? {} ) );\n\t\t},\n\n\t\tget: ( id, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tconst styles = getElementStyles( meta.elementId ) ?? {};\n\n\t\t\treturn styles[ id ] ?? null;\n\t\t},\n\n\t\tupdateProps: ( args, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tupdateElementStyle( {\n\t\t\t\telementId: meta.elementId,\n\t\t\t\tstyleId: args.id,\n\t\t\t\tmeta: args.meta,\n\t\t\t\tprops: args.props,\n\t\t\t} );\n\t\t},\n\t},\n} );\n\nfunction isValidElementsMeta( meta: Record< string, unknown > ): meta is ElementsMeta {\n\treturn 'elementId' in meta && typeof meta.elementId === 'string' && !! meta.elementId;\n}\n","import { createError } from '@elementor/utils';\n\nexport const InvalidElementsStyleProviderMetaError = createError< { meta: Record< string, unknown > } >( {\n\tcode: 'invalid_elements_style_provider_meta',\n\tmessage: 'Invalid elements style provider meta.',\n} );\n\nexport const ActiveDocumentMustExistError = createError( {\n\tcode: 'active_document_must_exist',\n\tmessage: 'Active document must exist.',\n} );\n","import { type StylesProvider } from '../types';\n\nexport type CreateStylesProviderOptions = {\n\tkey: string | ( () => string );\n\tpriority?: number;\n\tlimit?: number;\n\tsubscribe?: ( callback: () => void ) => () => void;\n\tlabels?: {\n\t\tsingular: string;\n\t\tplural: string;\n\t};\n\tactions: {\n\t\tall: StylesProvider[ 'actions' ][ 'all' ];\n\t\tget: StylesProvider[ 'actions' ][ 'get' ];\n\t\tcreate?: StylesProvider[ 'actions' ][ 'create' ];\n\t\tdelete?: StylesProvider[ 'actions' ][ 'delete' ];\n\t\tupdate?: StylesProvider[ 'actions' ][ 'update' ];\n\t\tupdateProps?: StylesProvider[ 'actions' ][ 'updateProps' ];\n\t};\n};\n\nconst DEFAULT_LIMIT = 10000;\nconst DEFAULT_PRIORITY = 10;\n\nexport function createStylesProvider( {\n\tkey,\n\tpriority = DEFAULT_PRIORITY,\n\tlimit = DEFAULT_LIMIT,\n\tsubscribe = () => () => {},\n\tlabels,\n\tactions,\n}: CreateStylesProviderOptions ): StylesProvider {\n\treturn {\n\t\tgetKey: typeof key === 'string' ? () => key : key,\n\t\tpriority,\n\t\tlimit,\n\t\tsubscribe,\n\t\tlabels: {\n\t\t\tsingular: labels?.singular ?? null,\n\t\t\tplural: labels?.plural ?? null,\n\t\t},\n\t\tactions: {\n\t\t\tall: actions.all,\n\t\t\tget: actions.get,\n\t\t\tcreate: actions.create,\n\t\t\tdelete: actions.delete,\n\t\t\tupdate: actions.update,\n\t\t\tupdateProps: actions.updateProps,\n\t\t},\n\t};\n}\n","import { ELEMENTS_STYLES_PROVIDER_KEY_PREFIX } from '../providers/document-elements-styles-provider';\n\nexport function isElementsStylesProvider( key: string ) {\n\treturn new RegExp( `^${ ELEMENTS_STYLES_PROVIDER_KEY_PREFIX }\\\\d+$` ).test( key );\n}\n","import { getWidgetsCache } from '@elementor/editor-elements';\n\nimport { createStylesProvider } from '../utils/create-styles-provider';\n\nexport const ELEMENTS_BASE_STYLES_PROVIDER_KEY = 'element-base-styles';\n\nexport const elementBaseStylesProvider = createStylesProvider( {\n\tkey: ELEMENTS_BASE_STYLES_PROVIDER_KEY,\n\tactions: {\n\t\tall() {\n\t\t\tconst widgetsCache = getWidgetsCache();\n\n\t\t\treturn Object.values( widgetsCache ?? {} ).flatMap( ( widget ) =>\n\t\t\t\tObject.values( widget.base_styles ?? {} )\n\t\t\t);\n\t\t},\n\n\t\tget( id ) {\n\t\t\treturn this.all().find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n} );\n","import { documentElementsStylesProvider } from './providers/document-elements-styles-provider';\nimport { elementBaseStylesProvider } from './providers/element-base-styles-provider';\nimport { stylesRepository } from './styles-repository';\n\nexport function init() {\n\tstylesRepository.register( documentElementsStylesProvider );\n\tstylesRepository.register( elementBaseStylesProvider );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,yBAAyB,MAAM;AAC3C,QAAM,YAA8B,CAAC;AAErC,QAAM,eAAe,MAAM;AAC1B,WAAO,UAAU,MAAO,CAAE,EAAE,KAAM,CAAE,GAAG,MAAS,EAAE,WAAW,EAAE,WAAW,KAAK,CAAI;AAAA,EACpF;AAEA,QAAM,WAAW,CAAE,aAA8B;AAChD,cAAU,KAAM,QAAS;AAAA,EAC1B;AAEA,QAAM,MAAM,CAAE,OAAa,CAAC,MAAO;AAClC,WAAO,aAAa,EAAE,QAAS,CAAE,aAAc,SAAS,QAAQ,IAAK,IAAK,CAAE;AAAA,EAC7E;AAEA,QAAM,YAAY,CAAE,OAAoB;AACvC,UAAM,eAAe,UAAU,IAAK,CAAE,aAAc;AACnD,aAAO,SAAS,UAAW,EAAG;AAAA,IAC/B,CAAE;AAEF,WAAO,MAAM;AACZ,mBAAa,QAAS,CAAE,gBAAiB,YAAY,CAAE;AAAA,IACxD;AAAA,EACD;AAEA,QAAM,mBAAmB,CAAE,QAAiB;AAC3C,WAAO,UAAU,KAAM,CAAE,aAAc,SAAS,OAAO,MAAM,GAAI;AAAA,EAClE;AAEA,SAAO;AAAA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