@elementor/editor-editing-panel 4.2.0-878 → 4.2.0-879
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 +53 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +24 -24
- package/src/components/style-sections/layout-section/grid-size-field.tsx +54 -101
- package/src/components/style-sections/layout-section/utils/grid-track-value.ts +113 -0
package/dist/index.js
CHANGED
|
@@ -4221,15 +4221,17 @@ var GridJustifyItemsField = () => /* @__PURE__ */ React50.createElement(StylesFi
|
|
|
4221
4221
|
var React51 = __toESM(require("react"));
|
|
4222
4222
|
var import_react27 = require("react");
|
|
4223
4223
|
var import_editor_controls26 = require("@elementor/editor-controls");
|
|
4224
|
-
var import_editor_props14 = require("@elementor/editor-props");
|
|
4225
4224
|
var import_ui30 = require("@elementor/ui");
|
|
4226
4225
|
var import_i18n29 = require("@wordpress/i18n");
|
|
4226
|
+
|
|
4227
|
+
// src/components/style-sections/layout-section/utils/grid-track-value.ts
|
|
4228
|
+
var import_editor_props14 = require("@elementor/editor-props");
|
|
4227
4229
|
var FR = "fr";
|
|
4228
4230
|
var CUSTOM2 = "custom";
|
|
4229
4231
|
var UNITS = [FR, CUSTOM2];
|
|
4230
4232
|
var EMPTY = { kind: "empty" };
|
|
4231
4233
|
var REPEAT_FR_PATTERN = /^repeat\(\s*(\d+)\s*,\s*1fr\s*\)$/;
|
|
4232
|
-
var
|
|
4234
|
+
var parseString = (css) => {
|
|
4233
4235
|
if (!css) {
|
|
4234
4236
|
return EMPTY;
|
|
4235
4237
|
}
|
|
@@ -4240,6 +4242,29 @@ var parseCss = (css) => {
|
|
|
4240
4242
|
}
|
|
4241
4243
|
return { kind: "custom", raw: css };
|
|
4242
4244
|
};
|
|
4245
|
+
var parseGridTrackSize = (size) => {
|
|
4246
|
+
if (!size) {
|
|
4247
|
+
return EMPTY;
|
|
4248
|
+
}
|
|
4249
|
+
if (size.unit === FR) {
|
|
4250
|
+
const n = Number(size.size);
|
|
4251
|
+
return Number.isFinite(n) && n >= 1 ? { kind: "fr", count: Math.trunc(n) } : EMPTY;
|
|
4252
|
+
}
|
|
4253
|
+
const raw = String(size.size ?? "");
|
|
4254
|
+
return raw === "" ? EMPTY : { kind: "custom", raw };
|
|
4255
|
+
};
|
|
4256
|
+
var parseValue = (value) => {
|
|
4257
|
+
if (!value) {
|
|
4258
|
+
return EMPTY;
|
|
4259
|
+
}
|
|
4260
|
+
if (import_editor_props14.gridTrackSizePropTypeUtil.isValid(value)) {
|
|
4261
|
+
return parseGridTrackSize(import_editor_props14.gridTrackSizePropTypeUtil.extract(value));
|
|
4262
|
+
}
|
|
4263
|
+
if (import_editor_props14.stringPropTypeUtil.isValid(value)) {
|
|
4264
|
+
return parseString(import_editor_props14.stringPropTypeUtil.extract(value));
|
|
4265
|
+
}
|
|
4266
|
+
return EMPTY;
|
|
4267
|
+
};
|
|
4243
4268
|
var fromSizeInput = (v) => {
|
|
4244
4269
|
if (v.size === "" || Number.isNaN(v.size)) {
|
|
4245
4270
|
return EMPTY;
|
|
@@ -4250,14 +4275,14 @@ var fromSizeInput = (v) => {
|
|
|
4250
4275
|
}
|
|
4251
4276
|
return { kind: "custom", raw: String(v.size) };
|
|
4252
4277
|
};
|
|
4253
|
-
var
|
|
4278
|
+
var toPropValue = (v) => {
|
|
4254
4279
|
switch (v.kind) {
|
|
4255
4280
|
case "empty":
|
|
4256
4281
|
return null;
|
|
4257
4282
|
case "fr":
|
|
4258
|
-
return
|
|
4283
|
+
return import_editor_props14.gridTrackSizePropTypeUtil.create({ size: v.count, unit: FR });
|
|
4259
4284
|
case "custom":
|
|
4260
|
-
return v.raw;
|
|
4285
|
+
return import_editor_props14.gridTrackSizePropTypeUtil.create({ size: v.raw, unit: CUSTOM2 });
|
|
4261
4286
|
}
|
|
4262
4287
|
};
|
|
4263
4288
|
var toSizeInput = (v, fallbackUnit = FR) => {
|
|
@@ -4289,15 +4314,32 @@ var unitOf = (v, fallback = FR) => {
|
|
|
4289
4314
|
}
|
|
4290
4315
|
return fallback;
|
|
4291
4316
|
};
|
|
4292
|
-
|
|
4317
|
+
|
|
4318
|
+
// src/components/style-sections/layout-section/grid-size-field.tsx
|
|
4319
|
+
var SizeFieldWrapper = ({ children }) => /* @__PURE__ */ React51.createElement(import_editor_controls26.ControlActions, null, children);
|
|
4320
|
+
var GridTrackSizeInput = (0, import_editor_controls26.createControl)((props) => /* @__PURE__ */ React51.createElement(
|
|
4321
|
+
import_editor_controls26.SizeComponent,
|
|
4322
|
+
{
|
|
4323
|
+
units: UNITS,
|
|
4324
|
+
value: props.value,
|
|
4325
|
+
placeholder: props.placeholder,
|
|
4326
|
+
defaultUnit: FR,
|
|
4327
|
+
setValue: props.setValue,
|
|
4328
|
+
onBlur: () => {
|
|
4329
|
+
},
|
|
4330
|
+
min: 1,
|
|
4331
|
+
anchorRef: props.anchorRef,
|
|
4332
|
+
SizeFieldWrapper
|
|
4333
|
+
}
|
|
4334
|
+
));
|
|
4293
4335
|
var GridTrackFieldContent = ({ cssProp, label }) => {
|
|
4294
4336
|
const { value, setValue } = useStylesField(cssProp, {
|
|
4295
4337
|
history: { propDisplayName: label }
|
|
4296
4338
|
});
|
|
4297
4339
|
const { placeholder: inheritedPlaceholder } = (0, import_editor_controls26.useBoundProp)();
|
|
4298
4340
|
const anchorRef = (0, import_react27.useRef)(null);
|
|
4299
|
-
const local =
|
|
4300
|
-
const inherited =
|
|
4341
|
+
const local = parseValue(value);
|
|
4342
|
+
const inherited = parseValue(inheritedPlaceholder);
|
|
4301
4343
|
const displayValue = local.kind !== "empty" ? toSizeInput(local) : toSizeInput(EMPTY, unitOf(inherited));
|
|
4302
4344
|
const placeholder = toPlaceholder(inherited);
|
|
4303
4345
|
const handleChange = (raw) => {
|
|
@@ -4305,24 +4347,19 @@ var GridTrackFieldContent = ({ cssProp, label }) => {
|
|
|
4305
4347
|
if (next.kind === "empty" && local.kind !== "empty" && raw.unit !== unitOf(local)) {
|
|
4306
4348
|
return;
|
|
4307
4349
|
}
|
|
4308
|
-
|
|
4309
|
-
setValue(css === null ? null : { $$type: "string", value: css });
|
|
4350
|
+
setValue(toPropValue(next));
|
|
4310
4351
|
};
|
|
4311
4352
|
return /* @__PURE__ */ React51.createElement(StylesFieldLayout, { label, direction: "column" }, /* @__PURE__ */ React51.createElement("div", { ref: anchorRef }, /* @__PURE__ */ React51.createElement(
|
|
4312
|
-
|
|
4353
|
+
GridTrackSizeInput,
|
|
4313
4354
|
{
|
|
4314
|
-
units: UNITS,
|
|
4315
4355
|
value: displayValue,
|
|
4316
4356
|
placeholder,
|
|
4317
|
-
defaultUnit: FR,
|
|
4318
4357
|
setValue: handleChange,
|
|
4319
|
-
onBlur: () => {
|
|
4320
|
-
},
|
|
4321
|
-
min: 1,
|
|
4322
4358
|
anchorRef
|
|
4323
4359
|
}
|
|
4324
4360
|
)));
|
|
4325
4361
|
};
|
|
4362
|
+
var GridTrackField = ({ cssProp, label }) => /* @__PURE__ */ React51.createElement(UiProviders, null, /* @__PURE__ */ React51.createElement(StylesField, { bind: cssProp, propDisplayName: label }, /* @__PURE__ */ React51.createElement(GridTrackFieldContent, { cssProp, label })));
|
|
4326
4363
|
var GridSizeFields = () => /* @__PURE__ */ React51.createElement(import_ui30.Grid, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React51.createElement(import_ui30.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React51.createElement(GridTrackField, { cssProp: "grid-template-columns", label: (0, import_i18n29.__)("Columns", "elementor") })), /* @__PURE__ */ React51.createElement(import_ui30.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React51.createElement(GridTrackField, { cssProp: "grid-template-rows", label: (0, import_i18n29.__)("Rows", "elementor") })));
|
|
4327
4364
|
|
|
4328
4365
|
// src/components/style-sections/layout-section/grid-span-field.tsx
|