@elementor/editor-variables 3.35.0-440 → 3.35.0-442
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +47 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/fields/label-field.tsx +4 -1
- package/src/components/variable-creation.tsx +10 -1
- package/src/components/variable-edit.tsx +10 -1
- package/src/components/variable-restore.tsx +10 -1
- package/src/components/variables-manager/variables-manager-create-menu.tsx +16 -23
- package/src/renderers/style-variables-renderer.tsx +5 -2
- package/src/variables-registry/create-variable-type-registry.ts +8 -1
- package/src/sync/get-canvas-iframe-document.ts +0 -7
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { PropType } from '@elementor/editor-props';
|
|
|
3
3
|
import { z } from '@elementor/schema';
|
|
4
4
|
import * as _elementor_editor_canvas from '@elementor/editor-canvas';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { RefObject } from 'react';
|
|
6
|
+
import { RefObject, KeyboardEvent } from 'react';
|
|
7
7
|
import * as _mui_material from '@mui/material';
|
|
8
8
|
|
|
9
9
|
declare function init(): void;
|
|
@@ -105,6 +105,7 @@ type ValueFieldProps = {
|
|
|
105
105
|
message: string;
|
|
106
106
|
};
|
|
107
107
|
ref?: RefObject<HTMLElement | null>;
|
|
108
|
+
onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
declare const registerVariableType: ({ key, icon, startIcon, valueField, propTypeUtil, variableType, defaultValue, selectionFilter, valueTransformer, styleTransformer, fallbackPropTypeUtil, isCompatible, emptyState, }: {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { PropType } from '@elementor/editor-props';
|
|
|
3
3
|
import { z } from '@elementor/schema';
|
|
4
4
|
import * as _elementor_editor_canvas from '@elementor/editor-canvas';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { RefObject } from 'react';
|
|
6
|
+
import { RefObject, KeyboardEvent } from 'react';
|
|
7
7
|
import * as _mui_material from '@mui/material';
|
|
8
8
|
|
|
9
9
|
declare function init(): void;
|
|
@@ -105,6 +105,7 @@ type ValueFieldProps = {
|
|
|
105
105
|
message: string;
|
|
106
106
|
};
|
|
107
107
|
ref?: RefObject<HTMLElement | null>;
|
|
108
|
+
onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
declare const registerVariableType: ({ key, icon, startIcon, valueField, propTypeUtil, variableType, defaultValue, selectionFilter, valueTransformer, styleTransformer, fallbackPropTypeUtil, isCompatible, emptyState, }: {
|
package/dist/index.js
CHANGED
|
@@ -1151,6 +1151,9 @@ var MenuOption = ({
|
|
|
1151
1151
|
const isDisabled = !userQuotaPermissions.canAdd();
|
|
1152
1152
|
const handleClick = () => {
|
|
1153
1153
|
if (isDisabled) {
|
|
1154
|
+
if (!isPopoverOpen) {
|
|
1155
|
+
setIsPopoverOpen(true);
|
|
1156
|
+
}
|
|
1154
1157
|
return;
|
|
1155
1158
|
}
|
|
1156
1159
|
const defaultName = getDefaultName(variables, config.key, config.variableType);
|
|
@@ -1168,34 +1171,19 @@ var MenuOption = ({
|
|
|
1168
1171
|
(0, import_i18n7.__)("Upgrade to continue creating and editing %s variables.", "elementor"),
|
|
1169
1172
|
config.variableType
|
|
1170
1173
|
);
|
|
1171
|
-
return /* @__PURE__ */ React6.createElement(import_ui6.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor:
|
|
1172
|
-
|
|
1174
|
+
return /* @__PURE__ */ React6.createElement(import_ui6.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0, import_react6.createElement)(config.icon, { fontSize: SIZE, color: isDisabled ? "disabled" : "action" }), /* @__PURE__ */ React6.createElement(import_ui6.Typography, { variant: "caption", color: isDisabled ? "text.disabled" : "text.primary" }, displayName), isDisabled && /* @__PURE__ */ React6.createElement(
|
|
1175
|
+
import_editor_ui2.PromotionPopover,
|
|
1173
1176
|
{
|
|
1174
|
-
|
|
1175
|
-
|
|
1177
|
+
open: isPopoverOpen,
|
|
1178
|
+
title,
|
|
1179
|
+
content,
|
|
1180
|
+
ctaText: (0, import_i18n7.__)("Upgrade now", "elementor"),
|
|
1181
|
+
ctaUrl: `https://go.elementor.com/go-pro-manager-${config.variableType}-variable/`,
|
|
1182
|
+
onClose: () => {
|
|
1183
|
+
setIsPopoverOpen(false);
|
|
1176
1184
|
}
|
|
1177
1185
|
},
|
|
1178
|
-
/* @__PURE__ */ React6.createElement(
|
|
1179
|
-
import_editor_ui2.PromotionPopover,
|
|
1180
|
-
{
|
|
1181
|
-
open: isPopoverOpen,
|
|
1182
|
-
title,
|
|
1183
|
-
content,
|
|
1184
|
-
ctaText: (0, import_i18n7.__)("Upgrade now", "elementor"),
|
|
1185
|
-
ctaUrl: `https://go.elementor.com/go-pro-manager-${config.variableType}-variable/`,
|
|
1186
|
-
onClose: () => {
|
|
1187
|
-
setIsPopoverOpen(false);
|
|
1188
|
-
}
|
|
1189
|
-
},
|
|
1190
|
-
/* @__PURE__ */ React6.createElement(
|
|
1191
|
-
import_editor_ui2.PromotionChip,
|
|
1192
|
-
{
|
|
1193
|
-
onClick: () => {
|
|
1194
|
-
setIsPopoverOpen(true);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
)
|
|
1198
|
-
)
|
|
1186
|
+
/* @__PURE__ */ React6.createElement(import_editor_ui2.PromotionChip, null)
|
|
1199
1187
|
));
|
|
1200
1188
|
};
|
|
1201
1189
|
var getDefaultName = (variables, type, baseName) => {
|
|
@@ -1242,7 +1230,8 @@ var LabelField = ({
|
|
|
1242
1230
|
focusOnShow = false,
|
|
1243
1231
|
selectOnShow = false,
|
|
1244
1232
|
showWarningInfotip = false,
|
|
1245
|
-
variables
|
|
1233
|
+
variables,
|
|
1234
|
+
onKeyDown
|
|
1246
1235
|
}) => {
|
|
1247
1236
|
const [label, setLabel] = (0, import_react7.useState)(value);
|
|
1248
1237
|
const [errorMessage, setErrorMessage] = (0, import_react7.useState)("");
|
|
@@ -1272,7 +1261,8 @@ var LabelField = ({
|
|
|
1272
1261
|
inputProps: {
|
|
1273
1262
|
maxLength: VARIABLE_LABEL_MAX_LENGTH,
|
|
1274
1263
|
...selectOnShow && { onFocus: (e) => e.target.select() },
|
|
1275
|
-
"aria-label": "Name"
|
|
1264
|
+
"aria-label": "Name",
|
|
1265
|
+
onKeyDown
|
|
1276
1266
|
},
|
|
1277
1267
|
autoFocus: focusOnShow
|
|
1278
1268
|
}
|
|
@@ -2192,6 +2182,12 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2192
2182
|
return !!errorMessage;
|
|
2193
2183
|
};
|
|
2194
2184
|
const isSubmitDisabled = hasEmptyFields() || hasErrors();
|
|
2185
|
+
const handleKeyDown = (event) => {
|
|
2186
|
+
if (event.key === "Enter" && !isSubmitDisabled) {
|
|
2187
|
+
event.preventDefault();
|
|
2188
|
+
handleCreateAndTrack();
|
|
2189
|
+
}
|
|
2190
|
+
};
|
|
2195
2191
|
return /* @__PURE__ */ React15.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React15.createElement(
|
|
2196
2192
|
import_editor_ui6.PopoverHeader,
|
|
2197
2193
|
{
|
|
@@ -2222,7 +2218,8 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2222
2218
|
value: label,
|
|
2223
2219
|
message: errorMsg
|
|
2224
2220
|
});
|
|
2225
|
-
}
|
|
2221
|
+
},
|
|
2222
|
+
onKeyDown: handleKeyDown
|
|
2226
2223
|
}
|
|
2227
2224
|
)
|
|
2228
2225
|
), ValueField && /* @__PURE__ */ React15.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n10.__)("Value", "elementor") }, /* @__PURE__ */ React15.createElement(import_ui15.Typography, { variant: "h5", id: "variable-value-wrapper" }, /* @__PURE__ */ React15.createElement(
|
|
@@ -2236,7 +2233,8 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2236
2233
|
setValueFieldError("");
|
|
2237
2234
|
},
|
|
2238
2235
|
onValidationChange: setValueFieldError,
|
|
2239
|
-
propType
|
|
2236
|
+
propType,
|
|
2237
|
+
onKeyDown: handleKeyDown
|
|
2240
2238
|
}
|
|
2241
2239
|
))), errorMessage && /* @__PURE__ */ React15.createElement(import_ui15.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React15.createElement(import_ui15.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React15.createElement(
|
|
2242
2240
|
import_ui15.Button,
|
|
@@ -2402,6 +2400,12 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2402
2400
|
return !!errorMessage;
|
|
2403
2401
|
};
|
|
2404
2402
|
const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
|
|
2403
|
+
const handleKeyDown = (event) => {
|
|
2404
|
+
if (event.key === "Enter" && !isSubmitDisabled) {
|
|
2405
|
+
event.preventDefault();
|
|
2406
|
+
handleUpdate();
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2405
2409
|
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(import_editor_editing_panel3.PopoverBody, { height: "auto" }, /* @__PURE__ */ React17.createElement(
|
|
2406
2410
|
import_editor_ui7.PopoverHeader,
|
|
2407
2411
|
{
|
|
@@ -2441,7 +2445,8 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2441
2445
|
value: label,
|
|
2442
2446
|
message: errorMsg
|
|
2443
2447
|
});
|
|
2444
|
-
}
|
|
2448
|
+
},
|
|
2449
|
+
onKeyDown: handleKeyDown
|
|
2445
2450
|
}
|
|
2446
2451
|
)
|
|
2447
2452
|
), ValueField && /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n12.__)("Value", "elementor") }, /* @__PURE__ */ React17.createElement(import_ui17.Typography, { variant: "h5" }, /* @__PURE__ */ React17.createElement(
|
|
@@ -2455,6 +2460,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2455
2460
|
setErrorMessage("");
|
|
2456
2461
|
setValueFieldError("");
|
|
2457
2462
|
},
|
|
2463
|
+
onKeyDown: handleKeyDown,
|
|
2458
2464
|
onValidationChange: setValueFieldError,
|
|
2459
2465
|
propType
|
|
2460
2466
|
}
|
|
@@ -2961,6 +2967,12 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
2961
2967
|
return !!errorMessage;
|
|
2962
2968
|
};
|
|
2963
2969
|
const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
|
|
2970
|
+
const handleKeyDown = (event) => {
|
|
2971
|
+
if (event.key === "Enter" && !isSubmitDisabled) {
|
|
2972
|
+
event.preventDefault();
|
|
2973
|
+
handleRestore();
|
|
2974
|
+
}
|
|
2975
|
+
};
|
|
2964
2976
|
return /* @__PURE__ */ React23.createElement(PopoverContentRefContextProvider, null, /* @__PURE__ */ React23.createElement(import_editor_editing_panel5.PopoverBody, { height: "auto" }, /* @__PURE__ */ React23.createElement(
|
|
2965
2977
|
import_editor_ui10.PopoverHeader,
|
|
2966
2978
|
{
|
|
@@ -2991,7 +3003,8 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
2991
3003
|
value: label,
|
|
2992
3004
|
message: errorMsg
|
|
2993
3005
|
});
|
|
2994
|
-
}
|
|
3006
|
+
},
|
|
3007
|
+
onKeyDown: handleKeyDown
|
|
2995
3008
|
}
|
|
2996
3009
|
)
|
|
2997
3010
|
), ValueField && /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n16.__)("Value", "elementor") }, /* @__PURE__ */ React23.createElement(import_ui23.Typography, { variant: "h5" }, /* @__PURE__ */ React23.createElement(
|
|
@@ -3006,7 +3019,8 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3006
3019
|
setValueFieldError("");
|
|
3007
3020
|
},
|
|
3008
3021
|
onValidationChange: setValueFieldError,
|
|
3009
|
-
propType
|
|
3022
|
+
propType,
|
|
3023
|
+
onKeyDown: handleKeyDown
|
|
3010
3024
|
}
|
|
3011
3025
|
))), errorMessage && /* @__PURE__ */ React23.createElement(import_ui23.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React23.createElement(import_ui23.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React23.createElement(import_ui23.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleRestore }, (0, import_i18n16.__)("Restore", "elementor")))));
|
|
3012
3026
|
};
|
|
@@ -3809,14 +3823,6 @@ var React36 = __toESM(require("react"));
|
|
|
3809
3823
|
var import_react25 = require("react");
|
|
3810
3824
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
3811
3825
|
var import_ui33 = require("@elementor/ui");
|
|
3812
|
-
|
|
3813
|
-
// src/sync/get-canvas-iframe-document.ts
|
|
3814
|
-
function getCanvasIframeDocument() {
|
|
3815
|
-
const extendedWindow = window;
|
|
3816
|
-
return extendedWindow.elementor?.$preview?.[0]?.contentDocument;
|
|
3817
|
-
}
|
|
3818
|
-
|
|
3819
|
-
// src/renderers/style-variables-renderer.tsx
|
|
3820
3826
|
var VARIABLES_WRAPPER = "body";
|
|
3821
3827
|
function StyleVariablesRenderer() {
|
|
3822
3828
|
const container = usePortalContainer();
|
|
@@ -3830,7 +3836,7 @@ function StyleVariablesRenderer() {
|
|
|
3830
3836
|
return /* @__PURE__ */ React36.createElement(import_ui33.Portal, { container }, /* @__PURE__ */ React36.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
3831
3837
|
}
|
|
3832
3838
|
function usePortalContainer() {
|
|
3833
|
-
return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
3839
|
+
return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters3.getCanvasIframeDocument)()?.head);
|
|
3834
3840
|
}
|
|
3835
3841
|
function useStyleVariables() {
|
|
3836
3842
|
const [variables, setVariables] = (0, import_react25.useState)({});
|