@elementor/editor-canvas 3.35.0-357 → 3.35.0-359
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/dist/index.d.mts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +37 -10
- package/dist/index.mjs +38 -15
- package/package.json +18 -18
- package/src/index.ts +2 -0
- package/src/renderers/__tests__/__snapshots__/create-styles-renderer.test.ts.snap +1 -1
- package/src/renderers/create-styles-renderer.ts +5 -15
- package/src/renderers/render-context.ts +35 -0
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,8 @@ import { V1Element, V1ElementConfig, V1ElementModelProps } from '@elementor/edit
|
|
|
2
2
|
import { TwingArrayLoader, TwingEnvironment } from '@elementor/twing';
|
|
3
3
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
4
4
|
import { Props, PropTypeKey, PropsSchema, AnyTransformable } from '@elementor/editor-props';
|
|
5
|
+
import * as _elementor_utils from '@elementor/utils';
|
|
6
|
+
import { StyleDefinitionState } from '@elementor/editor-styles';
|
|
5
7
|
|
|
6
8
|
declare const BREAKPOINTS_SCHEMA_URI = "elementor://breakpoints/list";
|
|
7
9
|
|
|
@@ -132,6 +134,17 @@ type ElementLegacyType = {
|
|
|
132
134
|
};
|
|
133
135
|
declare function registerElementType(type: string, elementTypeGenerator: ElementLegacyType[keyof ElementLegacyType]): void;
|
|
134
136
|
|
|
137
|
+
declare class RenderContext<TContext extends Record<string, unknown>> {
|
|
138
|
+
private key;
|
|
139
|
+
private context;
|
|
140
|
+
constructor(key: string, initialContext: TContext);
|
|
141
|
+
get(): TContext;
|
|
142
|
+
set(context: TContext): void;
|
|
143
|
+
update(updates: TContext): void;
|
|
144
|
+
delete(): void;
|
|
145
|
+
clear(): void;
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
type UnbrandedTransformer<TValue> = (value: TValue, options: {
|
|
136
149
|
key: string;
|
|
137
150
|
signal?: AbortSignal;
|
|
@@ -195,4 +208,37 @@ declare const DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
|
195
208
|
|
|
196
209
|
declare function createTransformer<TValue = never>(cb: TValue extends AnyTransformable ? 'Transformable values are invalid, use the actual value instead.' : UnbrandedTransformer<TValue>): Transformer<NoInfer<TValue>>;
|
|
197
210
|
|
|
198
|
-
|
|
211
|
+
declare const UnknownStyleTypeError: {
|
|
212
|
+
new ({ cause, context }?: {
|
|
213
|
+
cause?: _elementor_utils.ElementorErrorOptions["cause"];
|
|
214
|
+
context?: {
|
|
215
|
+
type: string;
|
|
216
|
+
} | undefined;
|
|
217
|
+
} | undefined): {
|
|
218
|
+
readonly context: _elementor_utils.ElementorErrorOptions["context"];
|
|
219
|
+
readonly code: _elementor_utils.ElementorErrorOptions["code"];
|
|
220
|
+
name: string;
|
|
221
|
+
message: string;
|
|
222
|
+
stack?: string;
|
|
223
|
+
cause?: unknown;
|
|
224
|
+
};
|
|
225
|
+
isError(error: unknown): error is Error;
|
|
226
|
+
};
|
|
227
|
+
declare const UnknownStyleStateError: {
|
|
228
|
+
new ({ cause, context }?: {
|
|
229
|
+
cause?: _elementor_utils.ElementorErrorOptions["cause"];
|
|
230
|
+
context?: {
|
|
231
|
+
state: StyleDefinitionState;
|
|
232
|
+
} | undefined;
|
|
233
|
+
} | undefined): {
|
|
234
|
+
readonly context: _elementor_utils.ElementorErrorOptions["context"];
|
|
235
|
+
readonly code: _elementor_utils.ElementorErrorOptions["code"];
|
|
236
|
+
name: string;
|
|
237
|
+
message: string;
|
|
238
|
+
stack?: string;
|
|
239
|
+
cause?: unknown;
|
|
240
|
+
};
|
|
241
|
+
isError(error: unknown): error is Error;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export { type AnyTransformer, BREAKPOINTS_SCHEMA_URI, type BackboneModel, type CreateTemplatedElementTypeOptions, DOCUMENT_STRUCTURE_URI, type ElementModel, ElementType, ElementView, type LegacyWindow, type PropsResolver, RenderContext, STYLE_SCHEMA_URI, UnknownStyleStateError, UnknownStyleTypeError, WIDGET_SCHEMA_URI, createPropsResolver, createTemplatedElementView, createTransformer, createTransformersRegistry, endDragElementFromPanel, getCanvasIframeDocument, init, registerElementType, settingsTransformersRegistry, startDragElementFromPanel, styleTransformersRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { V1Element, V1ElementConfig, V1ElementModelProps } from '@elementor/edit
|
|
|
2
2
|
import { TwingArrayLoader, TwingEnvironment } from '@elementor/twing';
|
|
3
3
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
4
4
|
import { Props, PropTypeKey, PropsSchema, AnyTransformable } from '@elementor/editor-props';
|
|
5
|
+
import * as _elementor_utils from '@elementor/utils';
|
|
6
|
+
import { StyleDefinitionState } from '@elementor/editor-styles';
|
|
5
7
|
|
|
6
8
|
declare const BREAKPOINTS_SCHEMA_URI = "elementor://breakpoints/list";
|
|
7
9
|
|
|
@@ -132,6 +134,17 @@ type ElementLegacyType = {
|
|
|
132
134
|
};
|
|
133
135
|
declare function registerElementType(type: string, elementTypeGenerator: ElementLegacyType[keyof ElementLegacyType]): void;
|
|
134
136
|
|
|
137
|
+
declare class RenderContext<TContext extends Record<string, unknown>> {
|
|
138
|
+
private key;
|
|
139
|
+
private context;
|
|
140
|
+
constructor(key: string, initialContext: TContext);
|
|
141
|
+
get(): TContext;
|
|
142
|
+
set(context: TContext): void;
|
|
143
|
+
update(updates: TContext): void;
|
|
144
|
+
delete(): void;
|
|
145
|
+
clear(): void;
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
type UnbrandedTransformer<TValue> = (value: TValue, options: {
|
|
136
149
|
key: string;
|
|
137
150
|
signal?: AbortSignal;
|
|
@@ -195,4 +208,37 @@ declare const DOCUMENT_STRUCTURE_URI = "elementor://document/structure";
|
|
|
195
208
|
|
|
196
209
|
declare function createTransformer<TValue = never>(cb: TValue extends AnyTransformable ? 'Transformable values are invalid, use the actual value instead.' : UnbrandedTransformer<TValue>): Transformer<NoInfer<TValue>>;
|
|
197
210
|
|
|
198
|
-
|
|
211
|
+
declare const UnknownStyleTypeError: {
|
|
212
|
+
new ({ cause, context }?: {
|
|
213
|
+
cause?: _elementor_utils.ElementorErrorOptions["cause"];
|
|
214
|
+
context?: {
|
|
215
|
+
type: string;
|
|
216
|
+
} | undefined;
|
|
217
|
+
} | undefined): {
|
|
218
|
+
readonly context: _elementor_utils.ElementorErrorOptions["context"];
|
|
219
|
+
readonly code: _elementor_utils.ElementorErrorOptions["code"];
|
|
220
|
+
name: string;
|
|
221
|
+
message: string;
|
|
222
|
+
stack?: string;
|
|
223
|
+
cause?: unknown;
|
|
224
|
+
};
|
|
225
|
+
isError(error: unknown): error is Error;
|
|
226
|
+
};
|
|
227
|
+
declare const UnknownStyleStateError: {
|
|
228
|
+
new ({ cause, context }?: {
|
|
229
|
+
cause?: _elementor_utils.ElementorErrorOptions["cause"];
|
|
230
|
+
context?: {
|
|
231
|
+
state: StyleDefinitionState;
|
|
232
|
+
} | undefined;
|
|
233
|
+
} | undefined): {
|
|
234
|
+
readonly context: _elementor_utils.ElementorErrorOptions["context"];
|
|
235
|
+
readonly code: _elementor_utils.ElementorErrorOptions["code"];
|
|
236
|
+
name: string;
|
|
237
|
+
message: string;
|
|
238
|
+
stack?: string;
|
|
239
|
+
cause?: unknown;
|
|
240
|
+
};
|
|
241
|
+
isError(error: unknown): error is Error;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export { type AnyTransformer, BREAKPOINTS_SCHEMA_URI, type BackboneModel, type CreateTemplatedElementTypeOptions, DOCUMENT_STRUCTURE_URI, type ElementModel, ElementType, ElementView, type LegacyWindow, type PropsResolver, RenderContext, STYLE_SCHEMA_URI, UnknownStyleStateError, UnknownStyleTypeError, WIDGET_SCHEMA_URI, createPropsResolver, createTemplatedElementView, createTransformer, createTransformersRegistry, endDragElementFromPanel, getCanvasIframeDocument, init, registerElementType, settingsTransformersRegistry, startDragElementFromPanel, styleTransformersRegistry };
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,10 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BREAKPOINTS_SCHEMA_URI: () => BREAKPOINTS_SCHEMA_URI,
|
|
34
34
|
DOCUMENT_STRUCTURE_URI: () => DOCUMENT_STRUCTURE_URI,
|
|
35
|
+
RenderContext: () => RenderContext,
|
|
35
36
|
STYLE_SCHEMA_URI: () => STYLE_SCHEMA_URI,
|
|
37
|
+
UnknownStyleStateError: () => UnknownStyleStateError,
|
|
38
|
+
UnknownStyleTypeError: () => UnknownStyleTypeError,
|
|
36
39
|
WIDGET_SCHEMA_URI: () => WIDGET_SCHEMA_URI,
|
|
37
40
|
createPropsResolver: () => createPropsResolver,
|
|
38
41
|
createTemplatedElementView: () => createTemplatedElementView,
|
|
@@ -861,16 +864,8 @@ function createStyleWrapper(value = "", wrapper) {
|
|
|
861
864
|
},
|
|
862
865
|
withPrefix: (prefix) => createStyleWrapper([prefix, value].filter(Boolean).join(" "), wrapper),
|
|
863
866
|
withState: (state) => {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
if ((0, import_editor_styles3.isClassState)(state)) {
|
|
868
|
-
return createStyleWrapper(`${value}.${state}`, wrapper);
|
|
869
|
-
}
|
|
870
|
-
if ((0, import_editor_styles3.isPseudoState)(state)) {
|
|
871
|
-
return createStyleWrapper(`${value}:${state}`, wrapper);
|
|
872
|
-
}
|
|
873
|
-
throw new UnknownStyleStateError({ context: { state } });
|
|
867
|
+
const selector = (0, import_editor_styles3.getSelectorWithState)(value, state);
|
|
868
|
+
return createStyleWrapper(selector, wrapper);
|
|
874
869
|
},
|
|
875
870
|
withMediaQuery: (breakpoint) => {
|
|
876
871
|
if (!breakpoint?.type) {
|
|
@@ -3506,6 +3501,35 @@ function init() {
|
|
|
3506
3501
|
);
|
|
3507
3502
|
}
|
|
3508
3503
|
|
|
3504
|
+
// src/renderers/render-context.ts
|
|
3505
|
+
var RenderContext = class {
|
|
3506
|
+
key;
|
|
3507
|
+
context = /* @__PURE__ */ new Map();
|
|
3508
|
+
constructor(key, initialContext) {
|
|
3509
|
+
this.key = key;
|
|
3510
|
+
this.context.set(this.key, initialContext);
|
|
3511
|
+
}
|
|
3512
|
+
get() {
|
|
3513
|
+
return this.context.get(this.key);
|
|
3514
|
+
}
|
|
3515
|
+
set(context) {
|
|
3516
|
+
this.context.set(this.key, context);
|
|
3517
|
+
}
|
|
3518
|
+
update(updates) {
|
|
3519
|
+
const currentContext = this.context.get(this.key);
|
|
3520
|
+
if (!currentContext) {
|
|
3521
|
+
return this.set(updates);
|
|
3522
|
+
}
|
|
3523
|
+
this.context.set(this.key, { ...currentContext, ...updates });
|
|
3524
|
+
}
|
|
3525
|
+
delete() {
|
|
3526
|
+
this.context.delete(this.key);
|
|
3527
|
+
}
|
|
3528
|
+
clear() {
|
|
3529
|
+
this.context.clear();
|
|
3530
|
+
}
|
|
3531
|
+
};
|
|
3532
|
+
|
|
3509
3533
|
// src/sync/drag-element-from-panel.ts
|
|
3510
3534
|
var startDragElementFromPanel = (props) => {
|
|
3511
3535
|
const channels = getElementorChannels();
|
|
@@ -3544,7 +3568,10 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
3544
3568
|
0 && (module.exports = {
|
|
3545
3569
|
BREAKPOINTS_SCHEMA_URI,
|
|
3546
3570
|
DOCUMENT_STRUCTURE_URI,
|
|
3571
|
+
RenderContext,
|
|
3547
3572
|
STYLE_SCHEMA_URI,
|
|
3573
|
+
UnknownStyleStateError,
|
|
3574
|
+
UnknownStyleTypeError,
|
|
3548
3575
|
WIDGET_SCHEMA_URI,
|
|
3549
3576
|
createPropsResolver,
|
|
3550
3577
|
createTemplatedElementView,
|
package/dist/index.mjs
CHANGED
|
@@ -587,7 +587,7 @@ function getLinkAttrs(el) {
|
|
|
587
587
|
// src/hooks/use-style-items.ts
|
|
588
588
|
import { useEffect as useEffect6, useMemo as useMemo4, useState as useState3 } from "react";
|
|
589
589
|
import { getBreakpoints } from "@elementor/editor-responsive";
|
|
590
|
-
import { isClassState
|
|
590
|
+
import { isClassState } from "@elementor/editor-styles";
|
|
591
591
|
import { stylesRepository as stylesRepository2 } from "@elementor/editor-styles-repository";
|
|
592
592
|
import { registerDataHook as registerDataHook2 } from "@elementor/editor-v1-adapters";
|
|
593
593
|
|
|
@@ -774,8 +774,7 @@ import { useBreakpointsMap } from "@elementor/editor-responsive";
|
|
|
774
774
|
|
|
775
775
|
// src/renderers/create-styles-renderer.ts
|
|
776
776
|
import {
|
|
777
|
-
|
|
778
|
-
isPseudoState
|
|
777
|
+
getSelectorWithState
|
|
779
778
|
} from "@elementor/editor-styles";
|
|
780
779
|
import { decodeString } from "@elementor/utils";
|
|
781
780
|
|
|
@@ -824,16 +823,8 @@ function createStyleWrapper(value = "", wrapper) {
|
|
|
824
823
|
},
|
|
825
824
|
withPrefix: (prefix) => createStyleWrapper([prefix, value].filter(Boolean).join(" "), wrapper),
|
|
826
825
|
withState: (state) => {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
if (isClassState(state)) {
|
|
831
|
-
return createStyleWrapper(`${value}.${state}`, wrapper);
|
|
832
|
-
}
|
|
833
|
-
if (isPseudoState(state)) {
|
|
834
|
-
return createStyleWrapper(`${value}:${state}`, wrapper);
|
|
835
|
-
}
|
|
836
|
-
throw new UnknownStyleStateError({ context: { state } });
|
|
826
|
+
const selector = getSelectorWithState(value, state);
|
|
827
|
+
return createStyleWrapper(selector, wrapper);
|
|
837
828
|
},
|
|
838
829
|
withMediaQuery: (breakpoint) => {
|
|
839
830
|
if (!breakpoint?.type) {
|
|
@@ -927,10 +918,10 @@ function sortByBreakpoint(breakpointsOrder) {
|
|
|
927
918
|
return ({ breakpoint: breakpointA }, { breakpoint: breakpointB }) => breakpointsOrder.indexOf(breakpointA) - breakpointsOrder.indexOf(breakpointB);
|
|
928
919
|
}
|
|
929
920
|
function sortByStateType({ state: stateA }, { state: stateB }) {
|
|
930
|
-
if (
|
|
921
|
+
if (isClassState(stateA) && !isClassState(stateB)) {
|
|
931
922
|
return -1;
|
|
932
923
|
}
|
|
933
|
-
if (!
|
|
924
|
+
if (!isClassState(stateA) && isClassState(stateB)) {
|
|
934
925
|
return 1;
|
|
935
926
|
}
|
|
936
927
|
return 0;
|
|
@@ -3501,6 +3492,35 @@ function init() {
|
|
|
3501
3492
|
);
|
|
3502
3493
|
}
|
|
3503
3494
|
|
|
3495
|
+
// src/renderers/render-context.ts
|
|
3496
|
+
var RenderContext = class {
|
|
3497
|
+
key;
|
|
3498
|
+
context = /* @__PURE__ */ new Map();
|
|
3499
|
+
constructor(key, initialContext) {
|
|
3500
|
+
this.key = key;
|
|
3501
|
+
this.context.set(this.key, initialContext);
|
|
3502
|
+
}
|
|
3503
|
+
get() {
|
|
3504
|
+
return this.context.get(this.key);
|
|
3505
|
+
}
|
|
3506
|
+
set(context) {
|
|
3507
|
+
this.context.set(this.key, context);
|
|
3508
|
+
}
|
|
3509
|
+
update(updates) {
|
|
3510
|
+
const currentContext = this.context.get(this.key);
|
|
3511
|
+
if (!currentContext) {
|
|
3512
|
+
return this.set(updates);
|
|
3513
|
+
}
|
|
3514
|
+
this.context.set(this.key, { ...currentContext, ...updates });
|
|
3515
|
+
}
|
|
3516
|
+
delete() {
|
|
3517
|
+
this.context.delete(this.key);
|
|
3518
|
+
}
|
|
3519
|
+
clear() {
|
|
3520
|
+
this.context.clear();
|
|
3521
|
+
}
|
|
3522
|
+
};
|
|
3523
|
+
|
|
3504
3524
|
// src/sync/drag-element-from-panel.ts
|
|
3505
3525
|
var startDragElementFromPanel = (props) => {
|
|
3506
3526
|
const channels = getElementorChannels();
|
|
@@ -3538,7 +3558,10 @@ var getLegacyPanelElementView = ({ settings, ...rest }) => {
|
|
|
3538
3558
|
export {
|
|
3539
3559
|
BREAKPOINTS_SCHEMA_URI,
|
|
3540
3560
|
DOCUMENT_STRUCTURE_URI,
|
|
3561
|
+
RenderContext,
|
|
3541
3562
|
STYLE_SCHEMA_URI,
|
|
3563
|
+
UnknownStyleStateError,
|
|
3564
|
+
UnknownStyleTypeError,
|
|
3542
3565
|
WIDGET_SCHEMA_URI,
|
|
3543
3566
|
createPropsResolver,
|
|
3544
3567
|
createTemplatedElementView,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "3.35.0-
|
|
4
|
+
"version": "3.35.0-359",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "3.35.0-
|
|
41
|
-
"@elementor/editor-controls": "3.35.0-
|
|
42
|
-
"@elementor/editor-documents": "3.35.0-
|
|
43
|
-
"@elementor/editor-elements": "3.35.0-
|
|
44
|
-
"@elementor/editor-interactions": "3.35.0-
|
|
45
|
-
"@elementor/editor-mcp": "3.35.0-
|
|
46
|
-
"@elementor/editor-notifications": "3.35.0-
|
|
47
|
-
"@elementor/editor-props": "3.35.0-
|
|
48
|
-
"@elementor/editor-responsive": "3.35.0-
|
|
49
|
-
"@elementor/editor-styles": "3.35.0-
|
|
50
|
-
"@elementor/editor-styles-repository": "3.35.0-
|
|
51
|
-
"@elementor/editor-ui": "3.35.0-
|
|
52
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
53
|
-
"@elementor/schema": "3.35.0-
|
|
54
|
-
"@elementor/twing": "3.35.0-
|
|
40
|
+
"@elementor/editor": "3.35.0-359",
|
|
41
|
+
"@elementor/editor-controls": "3.35.0-359",
|
|
42
|
+
"@elementor/editor-documents": "3.35.0-359",
|
|
43
|
+
"@elementor/editor-elements": "3.35.0-359",
|
|
44
|
+
"@elementor/editor-interactions": "3.35.0-359",
|
|
45
|
+
"@elementor/editor-mcp": "3.35.0-359",
|
|
46
|
+
"@elementor/editor-notifications": "3.35.0-359",
|
|
47
|
+
"@elementor/editor-props": "3.35.0-359",
|
|
48
|
+
"@elementor/editor-responsive": "3.35.0-359",
|
|
49
|
+
"@elementor/editor-styles": "3.35.0-359",
|
|
50
|
+
"@elementor/editor-styles-repository": "3.35.0-359",
|
|
51
|
+
"@elementor/editor-ui": "3.35.0-359",
|
|
52
|
+
"@elementor/editor-v1-adapters": "3.35.0-359",
|
|
53
|
+
"@elementor/schema": "3.35.0-359",
|
|
54
|
+
"@elementor/twing": "3.35.0-359",
|
|
55
55
|
"@elementor/ui": "1.36.17",
|
|
56
|
-
"@elementor/utils": "3.35.0-
|
|
57
|
-
"@elementor/wp-media": "3.35.0-
|
|
56
|
+
"@elementor/utils": "3.35.0-359",
|
|
57
|
+
"@elementor/wp-media": "3.35.0-359",
|
|
58
58
|
"@floating-ui/react": "^0.27.5",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0"
|
|
60
60
|
},
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export {
|
|
|
9
9
|
} from './legacy/create-templated-element-type';
|
|
10
10
|
export { registerElementType } from './legacy/init-legacy-views';
|
|
11
11
|
export * from './legacy/types';
|
|
12
|
+
export { RenderContext } from './renderers/render-context';
|
|
12
13
|
export { createPropsResolver, type PropsResolver } from './renderers/create-props-resolver';
|
|
13
14
|
export { settingsTransformersRegistry } from './settings-transformers-registry';
|
|
14
15
|
export { styleTransformersRegistry } from './style-transformers-registry';
|
|
@@ -20,3 +21,4 @@ export * from './legacy/types';
|
|
|
20
21
|
export { createTransformer } from './transformers/create-transformer';
|
|
21
22
|
export { createTransformersRegistry } from './transformers/create-transformers-registry';
|
|
22
23
|
export { type AnyTransformer } from './transformers/types';
|
|
24
|
+
export { UnknownStyleTypeError, UnknownStyleStateError } from './renderers/errors';
|
|
@@ -6,7 +6,7 @@ exports[`renderStyles should render styles 1`] = `
|
|
|
6
6
|
"breakpoint": "desktop",
|
|
7
7
|
"id": "test",
|
|
8
8
|
"state": null,
|
|
9
|
-
"value": ".test{font-size:10px;}.test:hover{font-size:20px;}@media(max-width:992px){.test{font-size:30px;}}@media(max-width:768px){.test:focus{font-size:40px;}}",
|
|
9
|
+
"value": ".test{font-size:10px;}.test:hover,.test:focus-visible{font-size:20px;}@media(max-width:992px){.test{font-size:30px;}}@media(max-width:768px){.test:focus{font-size:40px;}}",
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"breakpoint": "desktop",
|
|
@@ -2,8 +2,7 @@ import type { Props } from '@elementor/editor-props';
|
|
|
2
2
|
import { type Breakpoint, type BreakpointsMap } from '@elementor/editor-responsive';
|
|
3
3
|
import {
|
|
4
4
|
type CustomCss,
|
|
5
|
-
|
|
6
|
-
isPseudoState,
|
|
5
|
+
getSelectorWithState,
|
|
7
6
|
type StyleDefinition,
|
|
8
7
|
type StyleDefinitionState,
|
|
9
8
|
type StyleDefinitionType,
|
|
@@ -11,7 +10,7 @@ import {
|
|
|
11
10
|
import { decodeString } from '@elementor/utils';
|
|
12
11
|
|
|
13
12
|
import { type PropsResolver } from './create-props-resolver';
|
|
14
|
-
import {
|
|
13
|
+
import { UnknownStyleTypeError } from './errors';
|
|
15
14
|
|
|
16
15
|
export type StyleItem = {
|
|
17
16
|
id: string;
|
|
@@ -92,20 +91,11 @@ function createStyleWrapper( value: string = '', wrapper?: ( css: string ) => st
|
|
|
92
91
|
createStyleWrapper( [ prefix, value ].filter( Boolean ).join( ' ' ), wrapper ),
|
|
93
92
|
|
|
94
93
|
withState: ( state: StyleDefinitionState ) => {
|
|
95
|
-
|
|
96
|
-
return createStyleWrapper( value, wrapper );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if ( isClassState( state ) ) {
|
|
100
|
-
return createStyleWrapper( `${ value }.${ state }`, wrapper );
|
|
101
|
-
}
|
|
94
|
+
const selector = getSelectorWithState( value, state );
|
|
102
95
|
|
|
103
|
-
|
|
104
|
-
return createStyleWrapper( `${ value }:${ state }`, wrapper );
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
throw new UnknownStyleStateError( { context: { state } } );
|
|
96
|
+
return createStyleWrapper( selector, wrapper );
|
|
108
97
|
},
|
|
98
|
+
|
|
109
99
|
withMediaQuery: ( breakpoint: Breakpoint | null ) => {
|
|
110
100
|
if ( ! breakpoint?.type ) {
|
|
111
101
|
return createStyleWrapper( value, wrapper );
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class RenderContext< TContext extends Record< string, unknown > > {
|
|
2
|
+
private key: string;
|
|
3
|
+
private context = new Map< string, TContext >();
|
|
4
|
+
|
|
5
|
+
public constructor( key: string, initialContext: TContext ) {
|
|
6
|
+
this.key = key;
|
|
7
|
+
this.context.set( this.key, initialContext );
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public get(): TContext {
|
|
11
|
+
return this.context.get( this.key ) as TContext;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public set( context: TContext ) {
|
|
15
|
+
this.context.set( this.key, context );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public update( updates: TContext ) {
|
|
19
|
+
const currentContext = this.context.get( this.key );
|
|
20
|
+
|
|
21
|
+
if ( ! currentContext ) {
|
|
22
|
+
return this.set( updates );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.context.set( this.key, { ...currentContext, ...updates } );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public delete() {
|
|
29
|
+
this.context.delete( this.key );
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public clear() {
|
|
33
|
+
this.context.clear();
|
|
34
|
+
}
|
|
35
|
+
}
|