@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.mjs CHANGED
@@ -979,6 +979,9 @@ var hasVariable = (key) => {
979
979
  return getVariables()[key] !== void 0;
980
980
  };
981
981
  var useVariable = (key) => {
982
+ return getVariable(key);
983
+ };
984
+ function getVariable(key) {
982
985
  const variables = getVariables();
983
986
  if (!variables?.[key]) {
984
987
  return null;
@@ -987,7 +990,7 @@ var useVariable = (key) => {
987
990
  ...variables[key],
988
991
  key
989
992
  };
990
- };
993
+ }
991
994
  var useFilteredVariables = (searchValue, propTypeKey) => {
992
995
  const baseVariables = usePropVariables(propTypeKey);
993
996
  const typeFilteredVariables = useVariableSelectionFilter(baseVariables);
@@ -4185,17 +4188,49 @@ import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from "@elemen
4185
4188
  import {
4186
4189
  backgroundColorOverlayPropTypeUtil,
4187
4190
  selectionSizePropTypeUtil as selectionSizePropTypeUtil2,
4188
- shadowPropTypeUtil
4191
+ shadowPropTypeUtil as shadowPropTypeUtil2
4189
4192
  } from "@elementor/editor-props";
4190
4193
 
4191
4194
  // src/components/variables-repeater-item-slot.tsx
4192
4195
  import * as React39 from "react";
4193
4196
  import {
4194
- selectionSizePropTypeUtil
4197
+ selectionSizePropTypeUtil,
4198
+ shadowPropTypeUtil
4195
4199
  } from "@elementor/editor-props";
4200
+
4201
+ // src/utils/size-value.ts
4202
+ import { sizePropTypeUtil as sizePropTypeUtil2 } from "@elementor/editor-props";
4203
+
4204
+ // src/prop-types/custom-size-variable-prop-type.ts
4205
+ import { createPropUtils as createPropUtils4 } from "@elementor/editor-props";
4206
+ import { z as z5 } from "@elementor/schema";
4207
+ var customSizeVariablePropTypeUtil = createPropUtils4("global-custom-size-variable", z5.string());
4208
+
4209
+ // src/utils/size-value.ts
4210
+ var DEFAULT_UNIT = "px";
4211
+ var CUSTOM_SIZE_LABEL = "fx";
4212
+ function sizeValue(value) {
4213
+ if (sizeVariablePropTypeUtil.isValid(value) || customSizeVariablePropTypeUtil.isValid(value)) {
4214
+ const variable = getVariable(value?.value);
4215
+ return variable?.value;
4216
+ }
4217
+ if (sizePropTypeUtil2.isValid(value)) {
4218
+ const { size, unit } = value.value;
4219
+ if ("custom" !== unit) {
4220
+ return `${size ?? 0}${unit ?? DEFAULT_UNIT}`;
4221
+ }
4222
+ if (!size) {
4223
+ return CUSTOM_SIZE_LABEL;
4224
+ }
4225
+ return size;
4226
+ }
4227
+ return "";
4228
+ }
4229
+
4230
+ // src/components/variables-repeater-item-slot.tsx
4196
4231
  var useColorVariable = (value) => {
4197
4232
  const variableId = value?.value?.color?.value;
4198
- return useVariable(variableId || "");
4233
+ return getVariable(variableId || "");
4199
4234
  };
4200
4235
  var BackgroundRepeaterColorIndicator = ({ value }) => {
4201
4236
  const colorVariable = useColorVariable(value);
@@ -4209,10 +4244,22 @@ var BoxShadowRepeaterColorIndicator = ({ value }) => {
4209
4244
  const colorVariable = useColorVariable(value);
4210
4245
  return /* @__PURE__ */ React39.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
4211
4246
  };
4247
+ var BoxShadowRepeaterLabel = ({ value }) => {
4248
+ const shadowPropValue = shadowPropTypeUtil.extract(value) || {};
4249
+ const labels = [];
4250
+ for (const key of ["hOffset", "vOffset", "blur", "spread"]) {
4251
+ const rendered = sizeValue(shadowPropValue[key]);
4252
+ if (rendered) {
4253
+ labels.push(rendered);
4254
+ }
4255
+ }
4256
+ const positionLabel = shadowPropValue.position?.value || "outset";
4257
+ return /* @__PURE__ */ React39.createElement("span", { style: { textTransform: "capitalize" } }, positionLabel, ": ", labels.join(" "));
4258
+ };
4212
4259
  var TransitionsSizeVariableLabel = ({ value: prop }) => {
4213
4260
  let label = "";
4214
4261
  const variableId = prop?.value?.size?.value || "";
4215
- const variable = useVariable(variableId);
4262
+ const variable = getVariable(variableId);
4216
4263
  if (variable && selectionSizePropTypeUtil.isValid(prop)) {
4217
4264
  const selection = prop.value?.selection?.value?.key?.value;
4218
4265
  if (selection) {
@@ -4223,11 +4270,6 @@ var TransitionsSizeVariableLabel = ({ value: prop }) => {
4223
4270
  return /* @__PURE__ */ React39.createElement("span", null, label);
4224
4271
  };
4225
4272
 
4226
- // src/prop-types/custom-size-variable-prop-type.ts
4227
- import { createPropUtils as createPropUtils4 } from "@elementor/editor-props";
4228
- import { z as z5 } from "@elementor/schema";
4229
- var customSizeVariablePropTypeUtil = createPropUtils4("global-custom-size-variable", z5.string());
4230
-
4231
4273
  // src/repeater-injections.ts
4232
4274
  function registerRepeaterInjections() {
4233
4275
  backgroundOverlayRepeaterInjections();
@@ -4255,7 +4297,16 @@ var boxShadowRepeaterInjections = () => {
4255
4297
  id: "color-variables-box-shadow-icon",
4256
4298
  component: BoxShadowRepeaterColorIndicator,
4257
4299
  condition: ({ value }) => {
4258
- return hasAssignedColorVariable(shadowPropTypeUtil.extract(value)?.color);
4300
+ const { color } = shadowPropTypeUtil2.extract(value) || {};
4301
+ return hasAssignedColorVariable(color);
4302
+ }
4303
+ });
4304
+ injectIntoRepeaterItemLabel({
4305
+ id: "color-variables-box-shadow-label",
4306
+ component: BoxShadowRepeaterLabel,
4307
+ condition: ({ value }) => {
4308
+ const { hOffset, vOffset, blur, spread } = shadowPropTypeUtil2.extract(value) || {};
4309
+ return hasAssignedSizeVariable(hOffset) || hasAssignedSizeVariable(vOffset) || hasAssignedSizeVariable(blur) || hasAssignedSizeVariable(spread);
4259
4310
  }
4260
4311
  });
4261
4312
  };