@elementor/editor-editing-panel 4.2.0-877 → 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.mjs
CHANGED
|
@@ -4295,16 +4295,21 @@ var GridJustifyItemsField = () => /* @__PURE__ */ React50.createElement(StylesFi
|
|
|
4295
4295
|
// src/components/style-sections/layout-section/grid-size-field.tsx
|
|
4296
4296
|
import * as React51 from "react";
|
|
4297
4297
|
import { useRef as useRef8 } from "react";
|
|
4298
|
-
import { SizeComponent, useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
|
|
4299
|
-
import { stringPropTypeUtil as stringPropTypeUtil3 } from "@elementor/editor-props";
|
|
4298
|
+
import { ControlActions, createControl, SizeComponent, useBoundProp as useBoundProp4 } from "@elementor/editor-controls";
|
|
4300
4299
|
import { Grid as Grid4 } from "@elementor/ui";
|
|
4301
4300
|
import { __ as __29 } from "@wordpress/i18n";
|
|
4301
|
+
|
|
4302
|
+
// src/components/style-sections/layout-section/utils/grid-track-value.ts
|
|
4303
|
+
import {
|
|
4304
|
+
gridTrackSizePropTypeUtil,
|
|
4305
|
+
stringPropTypeUtil as stringPropTypeUtil3
|
|
4306
|
+
} from "@elementor/editor-props";
|
|
4302
4307
|
var FR = "fr";
|
|
4303
4308
|
var CUSTOM2 = "custom";
|
|
4304
4309
|
var UNITS = [FR, CUSTOM2];
|
|
4305
4310
|
var EMPTY = { kind: "empty" };
|
|
4306
4311
|
var REPEAT_FR_PATTERN = /^repeat\(\s*(\d+)\s*,\s*1fr\s*\)$/;
|
|
4307
|
-
var
|
|
4312
|
+
var parseString = (css) => {
|
|
4308
4313
|
if (!css) {
|
|
4309
4314
|
return EMPTY;
|
|
4310
4315
|
}
|
|
@@ -4315,6 +4320,29 @@ var parseCss = (css) => {
|
|
|
4315
4320
|
}
|
|
4316
4321
|
return { kind: "custom", raw: css };
|
|
4317
4322
|
};
|
|
4323
|
+
var parseGridTrackSize = (size) => {
|
|
4324
|
+
if (!size) {
|
|
4325
|
+
return EMPTY;
|
|
4326
|
+
}
|
|
4327
|
+
if (size.unit === FR) {
|
|
4328
|
+
const n = Number(size.size);
|
|
4329
|
+
return Number.isFinite(n) && n >= 1 ? { kind: "fr", count: Math.trunc(n) } : EMPTY;
|
|
4330
|
+
}
|
|
4331
|
+
const raw = String(size.size ?? "");
|
|
4332
|
+
return raw === "" ? EMPTY : { kind: "custom", raw };
|
|
4333
|
+
};
|
|
4334
|
+
var parseValue = (value) => {
|
|
4335
|
+
if (!value) {
|
|
4336
|
+
return EMPTY;
|
|
4337
|
+
}
|
|
4338
|
+
if (gridTrackSizePropTypeUtil.isValid(value)) {
|
|
4339
|
+
return parseGridTrackSize(gridTrackSizePropTypeUtil.extract(value));
|
|
4340
|
+
}
|
|
4341
|
+
if (stringPropTypeUtil3.isValid(value)) {
|
|
4342
|
+
return parseString(stringPropTypeUtil3.extract(value));
|
|
4343
|
+
}
|
|
4344
|
+
return EMPTY;
|
|
4345
|
+
};
|
|
4318
4346
|
var fromSizeInput = (v) => {
|
|
4319
4347
|
if (v.size === "" || Number.isNaN(v.size)) {
|
|
4320
4348
|
return EMPTY;
|
|
@@ -4325,14 +4353,14 @@ var fromSizeInput = (v) => {
|
|
|
4325
4353
|
}
|
|
4326
4354
|
return { kind: "custom", raw: String(v.size) };
|
|
4327
4355
|
};
|
|
4328
|
-
var
|
|
4356
|
+
var toPropValue = (v) => {
|
|
4329
4357
|
switch (v.kind) {
|
|
4330
4358
|
case "empty":
|
|
4331
4359
|
return null;
|
|
4332
4360
|
case "fr":
|
|
4333
|
-
return
|
|
4361
|
+
return gridTrackSizePropTypeUtil.create({ size: v.count, unit: FR });
|
|
4334
4362
|
case "custom":
|
|
4335
|
-
return v.raw;
|
|
4363
|
+
return gridTrackSizePropTypeUtil.create({ size: v.raw, unit: CUSTOM2 });
|
|
4336
4364
|
}
|
|
4337
4365
|
};
|
|
4338
4366
|
var toSizeInput = (v, fallbackUnit = FR) => {
|
|
@@ -4364,15 +4392,32 @@ var unitOf = (v, fallback = FR) => {
|
|
|
4364
4392
|
}
|
|
4365
4393
|
return fallback;
|
|
4366
4394
|
};
|
|
4367
|
-
|
|
4395
|
+
|
|
4396
|
+
// src/components/style-sections/layout-section/grid-size-field.tsx
|
|
4397
|
+
var SizeFieldWrapper = ({ children }) => /* @__PURE__ */ React51.createElement(ControlActions, null, children);
|
|
4398
|
+
var GridTrackSizeInput = createControl((props) => /* @__PURE__ */ React51.createElement(
|
|
4399
|
+
SizeComponent,
|
|
4400
|
+
{
|
|
4401
|
+
units: UNITS,
|
|
4402
|
+
value: props.value,
|
|
4403
|
+
placeholder: props.placeholder,
|
|
4404
|
+
defaultUnit: FR,
|
|
4405
|
+
setValue: props.setValue,
|
|
4406
|
+
onBlur: () => {
|
|
4407
|
+
},
|
|
4408
|
+
min: 1,
|
|
4409
|
+
anchorRef: props.anchorRef,
|
|
4410
|
+
SizeFieldWrapper
|
|
4411
|
+
}
|
|
4412
|
+
));
|
|
4368
4413
|
var GridTrackFieldContent = ({ cssProp, label }) => {
|
|
4369
4414
|
const { value, setValue } = useStylesField(cssProp, {
|
|
4370
4415
|
history: { propDisplayName: label }
|
|
4371
4416
|
});
|
|
4372
4417
|
const { placeholder: inheritedPlaceholder } = useBoundProp4();
|
|
4373
4418
|
const anchorRef = useRef8(null);
|
|
4374
|
-
const local =
|
|
4375
|
-
const inherited =
|
|
4419
|
+
const local = parseValue(value);
|
|
4420
|
+
const inherited = parseValue(inheritedPlaceholder);
|
|
4376
4421
|
const displayValue = local.kind !== "empty" ? toSizeInput(local) : toSizeInput(EMPTY, unitOf(inherited));
|
|
4377
4422
|
const placeholder = toPlaceholder(inherited);
|
|
4378
4423
|
const handleChange = (raw) => {
|
|
@@ -4380,24 +4425,19 @@ var GridTrackFieldContent = ({ cssProp, label }) => {
|
|
|
4380
4425
|
if (next.kind === "empty" && local.kind !== "empty" && raw.unit !== unitOf(local)) {
|
|
4381
4426
|
return;
|
|
4382
4427
|
}
|
|
4383
|
-
|
|
4384
|
-
setValue(css === null ? null : { $$type: "string", value: css });
|
|
4428
|
+
setValue(toPropValue(next));
|
|
4385
4429
|
};
|
|
4386
4430
|
return /* @__PURE__ */ React51.createElement(StylesFieldLayout, { label, direction: "column" }, /* @__PURE__ */ React51.createElement("div", { ref: anchorRef }, /* @__PURE__ */ React51.createElement(
|
|
4387
|
-
|
|
4431
|
+
GridTrackSizeInput,
|
|
4388
4432
|
{
|
|
4389
|
-
units: UNITS,
|
|
4390
4433
|
value: displayValue,
|
|
4391
4434
|
placeholder,
|
|
4392
|
-
defaultUnit: FR,
|
|
4393
4435
|
setValue: handleChange,
|
|
4394
|
-
onBlur: () => {
|
|
4395
|
-
},
|
|
4396
|
-
min: 1,
|
|
4397
4436
|
anchorRef
|
|
4398
4437
|
}
|
|
4399
4438
|
)));
|
|
4400
4439
|
};
|
|
4440
|
+
var GridTrackField = ({ cssProp, label }) => /* @__PURE__ */ React51.createElement(UiProviders, null, /* @__PURE__ */ React51.createElement(StylesField, { bind: cssProp, propDisplayName: label }, /* @__PURE__ */ React51.createElement(GridTrackFieldContent, { cssProp, label })));
|
|
4401
4441
|
var GridSizeFields = () => /* @__PURE__ */ React51.createElement(Grid4, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React51.createElement(Grid4, { item: true, xs: 6 }, /* @__PURE__ */ React51.createElement(GridTrackField, { cssProp: "grid-template-columns", label: __29("Columns", "elementor") })), /* @__PURE__ */ React51.createElement(Grid4, { item: true, xs: 6 }, /* @__PURE__ */ React51.createElement(GridTrackField, { cssProp: "grid-template-rows", label: __29("Rows", "elementor") })));
|
|
4402
4442
|
|
|
4403
4443
|
// src/components/style-sections/layout-section/grid-span-field.tsx
|