@elementor/editor-variables 4.1.0-785 → 4.1.0-787
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.js +66 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/variables-repeater-item-slot.tsx +26 -3
- package/src/hooks/use-prop-variables.ts +10 -1
- package/src/repeater-injections.ts +18 -1
- package/src/utils/size-value.ts +30 -0
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var import_editor = require("@elementor/editor");
|
|
|
47
47
|
var import_editor_controls18 = require("@elementor/editor-controls");
|
|
48
48
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
49
49
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
50
|
-
var
|
|
50
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
51
51
|
var import_menus = require("@elementor/menus");
|
|
52
52
|
|
|
53
53
|
// src/components/global-styles-import-listener.tsx
|
|
@@ -999,6 +999,9 @@ var hasVariable = (key) => {
|
|
|
999
999
|
return getVariables()[key] !== void 0;
|
|
1000
1000
|
};
|
|
1001
1001
|
var useVariable = (key) => {
|
|
1002
|
+
return getVariable(key);
|
|
1003
|
+
};
|
|
1004
|
+
function getVariable(key) {
|
|
1002
1005
|
const variables = getVariables();
|
|
1003
1006
|
if (!variables?.[key]) {
|
|
1004
1007
|
return null;
|
|
@@ -1007,7 +1010,7 @@ var useVariable = (key) => {
|
|
|
1007
1010
|
...variables[key],
|
|
1008
1011
|
key
|
|
1009
1012
|
};
|
|
1010
|
-
}
|
|
1013
|
+
}
|
|
1011
1014
|
var useFilteredVariables = (searchValue, propTypeKey) => {
|
|
1012
1015
|
const baseVariables = usePropVariables(propTypeKey);
|
|
1013
1016
|
const typeFilteredVariables = useVariableSelectionFilter(baseVariables);
|
|
@@ -4175,14 +4178,45 @@ function convertToCssVariables(variables) {
|
|
|
4175
4178
|
|
|
4176
4179
|
// src/repeater-injections.ts
|
|
4177
4180
|
var import_editor_controls17 = require("@elementor/editor-controls");
|
|
4178
|
-
var
|
|
4181
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
4179
4182
|
|
|
4180
4183
|
// src/components/variables-repeater-item-slot.tsx
|
|
4181
4184
|
var React39 = __toESM(require("react"));
|
|
4185
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
4186
|
+
|
|
4187
|
+
// src/utils/size-value.ts
|
|
4188
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
4189
|
+
|
|
4190
|
+
// src/prop-types/custom-size-variable-prop-type.ts
|
|
4182
4191
|
var import_editor_props6 = require("@elementor/editor-props");
|
|
4192
|
+
var import_schema5 = require("@elementor/schema");
|
|
4193
|
+
var customSizeVariablePropTypeUtil = (0, import_editor_props6.createPropUtils)("global-custom-size-variable", import_schema5.z.string());
|
|
4194
|
+
|
|
4195
|
+
// src/utils/size-value.ts
|
|
4196
|
+
var DEFAULT_UNIT = "px";
|
|
4197
|
+
var CUSTOM_SIZE_LABEL = "fx";
|
|
4198
|
+
function sizeValue(value) {
|
|
4199
|
+
if (sizeVariablePropTypeUtil.isValid(value) || customSizeVariablePropTypeUtil.isValid(value)) {
|
|
4200
|
+
const variable = getVariable(value?.value);
|
|
4201
|
+
return variable?.value;
|
|
4202
|
+
}
|
|
4203
|
+
if (import_editor_props7.sizePropTypeUtil.isValid(value)) {
|
|
4204
|
+
const { size, unit } = value.value;
|
|
4205
|
+
if ("custom" !== unit) {
|
|
4206
|
+
return `${size ?? 0}${unit ?? DEFAULT_UNIT}`;
|
|
4207
|
+
}
|
|
4208
|
+
if (!size) {
|
|
4209
|
+
return CUSTOM_SIZE_LABEL;
|
|
4210
|
+
}
|
|
4211
|
+
return size;
|
|
4212
|
+
}
|
|
4213
|
+
return "";
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4216
|
+
// src/components/variables-repeater-item-slot.tsx
|
|
4183
4217
|
var useColorVariable = (value) => {
|
|
4184
4218
|
const variableId = value?.value?.color?.value;
|
|
4185
|
-
return
|
|
4219
|
+
return getVariable(variableId || "");
|
|
4186
4220
|
};
|
|
4187
4221
|
var BackgroundRepeaterColorIndicator = ({ value }) => {
|
|
4188
4222
|
const colorVariable = useColorVariable(value);
|
|
@@ -4196,11 +4230,23 @@ var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
|
4196
4230
|
const colorVariable = useColorVariable(value);
|
|
4197
4231
|
return /* @__PURE__ */ React39.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
4198
4232
|
};
|
|
4233
|
+
var BoxShadowRepeaterLabel = ({ value }) => {
|
|
4234
|
+
const shadowPropValue = import_editor_props8.shadowPropTypeUtil.extract(value) || {};
|
|
4235
|
+
const labels = [];
|
|
4236
|
+
for (const key of ["hOffset", "vOffset", "blur", "spread"]) {
|
|
4237
|
+
const rendered = sizeValue(shadowPropValue[key]);
|
|
4238
|
+
if (rendered) {
|
|
4239
|
+
labels.push(rendered);
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
const positionLabel = shadowPropValue.position?.value || "outset";
|
|
4243
|
+
return /* @__PURE__ */ React39.createElement("span", { style: { textTransform: "capitalize" } }, positionLabel, ": ", labels.join(" "));
|
|
4244
|
+
};
|
|
4199
4245
|
var TransitionsSizeVariableLabel = ({ value: prop }) => {
|
|
4200
4246
|
let label = "";
|
|
4201
4247
|
const variableId = prop?.value?.size?.value || "";
|
|
4202
|
-
const variable =
|
|
4203
|
-
if (variable &&
|
|
4248
|
+
const variable = getVariable(variableId);
|
|
4249
|
+
if (variable && import_editor_props8.selectionSizePropTypeUtil.isValid(prop)) {
|
|
4204
4250
|
const selection = prop.value?.selection?.value?.key?.value;
|
|
4205
4251
|
if (selection) {
|
|
4206
4252
|
label += `${selection}: `;
|
|
@@ -4210,11 +4256,6 @@ var TransitionsSizeVariableLabel = ({ value: prop }) => {
|
|
|
4210
4256
|
return /* @__PURE__ */ React39.createElement("span", null, label);
|
|
4211
4257
|
};
|
|
4212
4258
|
|
|
4213
|
-
// src/prop-types/custom-size-variable-prop-type.ts
|
|
4214
|
-
var import_editor_props7 = require("@elementor/editor-props");
|
|
4215
|
-
var import_schema5 = require("@elementor/schema");
|
|
4216
|
-
var customSizeVariablePropTypeUtil = (0, import_editor_props7.createPropUtils)("global-custom-size-variable", import_schema5.z.string());
|
|
4217
|
-
|
|
4218
4259
|
// src/repeater-injections.ts
|
|
4219
4260
|
function registerRepeaterInjections() {
|
|
4220
4261
|
backgroundOverlayRepeaterInjections();
|
|
@@ -4226,14 +4267,14 @@ var backgroundOverlayRepeaterInjections = () => {
|
|
|
4226
4267
|
id: "color-variables-background-icon",
|
|
4227
4268
|
component: BackgroundRepeaterColorIndicator,
|
|
4228
4269
|
condition: ({ value }) => {
|
|
4229
|
-
return hasAssignedColorVariable(
|
|
4270
|
+
return hasAssignedColorVariable(import_editor_props9.backgroundColorOverlayPropTypeUtil.extract(value)?.color);
|
|
4230
4271
|
}
|
|
4231
4272
|
});
|
|
4232
4273
|
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4233
4274
|
id: "color-variables-label",
|
|
4234
4275
|
component: BackgroundRepeaterLabel,
|
|
4235
4276
|
condition: ({ value }) => {
|
|
4236
|
-
return hasAssignedColorVariable(
|
|
4277
|
+
return hasAssignedColorVariable(import_editor_props9.backgroundColorOverlayPropTypeUtil.extract(value)?.color);
|
|
4237
4278
|
}
|
|
4238
4279
|
});
|
|
4239
4280
|
};
|
|
@@ -4242,7 +4283,16 @@ var boxShadowRepeaterInjections = () => {
|
|
|
4242
4283
|
id: "color-variables-box-shadow-icon",
|
|
4243
4284
|
component: BoxShadowRepeaterColorIndicator,
|
|
4244
4285
|
condition: ({ value }) => {
|
|
4245
|
-
|
|
4286
|
+
const { color } = import_editor_props9.shadowPropTypeUtil.extract(value) || {};
|
|
4287
|
+
return hasAssignedColorVariable(color);
|
|
4288
|
+
}
|
|
4289
|
+
});
|
|
4290
|
+
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4291
|
+
id: "color-variables-box-shadow-label",
|
|
4292
|
+
component: BoxShadowRepeaterLabel,
|
|
4293
|
+
condition: ({ value }) => {
|
|
4294
|
+
const { hOffset, vOffset, blur, spread } = import_editor_props9.shadowPropTypeUtil.extract(value) || {};
|
|
4295
|
+
return hasAssignedSizeVariable(hOffset) || hasAssignedSizeVariable(vOffset) || hasAssignedSizeVariable(blur) || hasAssignedSizeVariable(spread);
|
|
4246
4296
|
}
|
|
4247
4297
|
});
|
|
4248
4298
|
};
|
|
@@ -4251,7 +4301,7 @@ var transitionsRepeaterInjections = () => {
|
|
|
4251
4301
|
id: "transition-size-variables-label",
|
|
4252
4302
|
component: TransitionsSizeVariableLabel,
|
|
4253
4303
|
condition: ({ value }) => {
|
|
4254
|
-
return hasAssignedSizeVariable(
|
|
4304
|
+
return hasAssignedSizeVariable(import_editor_props9.selectionSizePropTypeUtil.extract(value)?.size);
|
|
4255
4305
|
}
|
|
4256
4306
|
});
|
|
4257
4307
|
};
|
|
@@ -4312,7 +4362,7 @@ function init() {
|
|
|
4312
4362
|
(0, import_editor_panels2.__registerPanel)(panel);
|
|
4313
4363
|
}
|
|
4314
4364
|
function hasVariableAssigned(value) {
|
|
4315
|
-
if ((0,
|
|
4365
|
+
if ((0, import_editor_props10.isTransformable)(value)) {
|
|
4316
4366
|
return hasVariableType(value.$$type);
|
|
4317
4367
|
}
|
|
4318
4368
|
return false;
|