@elementor/editor-variables 3.32.0-64 → 3.32.0-66
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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +251 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/components/ui/mismatch-variable-alert.tsx +57 -0
- package/src/components/ui/tags/mismatch-tag.tsx +37 -0
- package/src/components/ui/variable/mismatch-variable.tsx +91 -0
- package/src/controls/variable-control.tsx +13 -3
- package/src/variables-registry/create-variable-type-registry.ts +15 -1
package/dist/index.mjs
CHANGED
|
@@ -392,11 +392,22 @@ function createVariableTypeRegistry() {
|
|
|
392
392
|
variableType,
|
|
393
393
|
selectionFilter,
|
|
394
394
|
valueTransformer,
|
|
395
|
-
fallbackPropTypeUtil
|
|
395
|
+
fallbackPropTypeUtil,
|
|
396
|
+
isCompatible
|
|
396
397
|
}) => {
|
|
397
398
|
if (variableTypes[propTypeUtil.key]) {
|
|
398
399
|
throw new Error(`Variable with key "${propTypeUtil.key}" is already registered.`);
|
|
399
400
|
}
|
|
401
|
+
if (!isCompatible) {
|
|
402
|
+
isCompatible = (propType, variable) => {
|
|
403
|
+
if ("union" === propType.kind) {
|
|
404
|
+
if (variable.type in propType.prop_types) {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return false;
|
|
409
|
+
};
|
|
410
|
+
}
|
|
400
411
|
variableTypes[propTypeUtil.key] = {
|
|
401
412
|
icon,
|
|
402
413
|
startIcon,
|
|
@@ -405,7 +416,8 @@ function createVariableTypeRegistry() {
|
|
|
405
416
|
variableType,
|
|
406
417
|
selectionFilter,
|
|
407
418
|
valueTransformer,
|
|
408
|
-
fallbackPropTypeUtil
|
|
419
|
+
fallbackPropTypeUtil,
|
|
420
|
+
isCompatible
|
|
409
421
|
};
|
|
410
422
|
registerTransformer(propTypeUtil.key);
|
|
411
423
|
registerInheritanceTransformer(propTypeUtil.key);
|
|
@@ -865,8 +877,8 @@ var usePreventUnload = (isDirty) => {
|
|
|
865
877
|
};
|
|
866
878
|
|
|
867
879
|
// src/controls/variable-control.tsx
|
|
868
|
-
import * as
|
|
869
|
-
import { useBoundProp as
|
|
880
|
+
import * as React32 from "react";
|
|
881
|
+
import { useBoundProp as useBoundProp11 } from "@elementor/editor-controls";
|
|
870
882
|
|
|
871
883
|
// src/components/ui/variable/assigned-variable.tsx
|
|
872
884
|
import { useId as useId2, useRef } from "react";
|
|
@@ -2061,19 +2073,29 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
2061
2073
|
)));
|
|
2062
2074
|
};
|
|
2063
2075
|
|
|
2064
|
-
// src/components/ui/variable/
|
|
2076
|
+
// src/components/ui/variable/mismatch-variable.tsx
|
|
2065
2077
|
import * as React28 from "react";
|
|
2066
|
-
import { useState as useState12 } from "react";
|
|
2078
|
+
import { useId as useId4, useRef as useRef3, useState as useState12 } from "react";
|
|
2067
2079
|
import { useBoundProp as useBoundProp9 } from "@elementor/editor-controls";
|
|
2068
|
-
import { Backdrop as Backdrop2, Infotip as Infotip2 } from "@elementor/ui";
|
|
2069
|
-
import { __ as __20 } from "@wordpress/i18n";
|
|
2080
|
+
import { Backdrop as Backdrop2, bindPopover as bindPopover3, Box as Box9, Infotip as Infotip2, Popover as Popover3, usePopupState as usePopupState4 } from "@elementor/ui";
|
|
2070
2081
|
|
|
2071
|
-
// src/components/ui/
|
|
2082
|
+
// src/components/ui/mismatch-variable-alert.tsx
|
|
2072
2083
|
import * as React26 from "react";
|
|
2073
2084
|
import { useSectionWidth as useSectionWidth2 } from "@elementor/editor-editing-panel";
|
|
2074
2085
|
import { Alert as Alert3, AlertAction as AlertAction2, AlertTitle as AlertTitle2, ClickAwayListener as ClickAwayListener3 } from "@elementor/ui";
|
|
2075
2086
|
import { __ as __19 } from "@wordpress/i18n";
|
|
2076
|
-
var
|
|
2087
|
+
var i18n = {
|
|
2088
|
+
title: __19("Variable has changed", "elementor"),
|
|
2089
|
+
message: __19(
|
|
2090
|
+
`This variable is no longer compatible with this property. You can clear it or select a different one.`,
|
|
2091
|
+
"elementor"
|
|
2092
|
+
),
|
|
2093
|
+
buttons: {
|
|
2094
|
+
clear: __19("Clear", "elementor"),
|
|
2095
|
+
select: __19("Select variable", "elementor")
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
2077
2099
|
const sectionWidth = useSectionWidth2();
|
|
2078
2100
|
return /* @__PURE__ */ React26.createElement(ClickAwayListener3, { onClickAway: onClose }, /* @__PURE__ */ React26.createElement(
|
|
2079
2101
|
Alert3,
|
|
@@ -2081,22 +2103,23 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
2081
2103
|
variant: "standard",
|
|
2082
2104
|
severity: "warning",
|
|
2083
2105
|
onClose,
|
|
2084
|
-
action: /* @__PURE__ */ React26.createElement(React26.Fragment, null, onClear && /* @__PURE__ */ React26.createElement(AlertAction2, { variant: "contained", onClick: onClear },
|
|
2085
|
-
sx: {
|
|
2106
|
+
action: /* @__PURE__ */ React26.createElement(React26.Fragment, null, onClear && /* @__PURE__ */ React26.createElement(AlertAction2, { variant: "contained", onClick: onClear }, i18n.buttons.clear), triggerSelect && /* @__PURE__ */ React26.createElement(AlertAction2, { variant: "outlined", onClick: triggerSelect }, i18n.buttons.select)),
|
|
2107
|
+
sx: {
|
|
2108
|
+
width: sectionWidth,
|
|
2109
|
+
minWidth: 300
|
|
2110
|
+
}
|
|
2086
2111
|
},
|
|
2087
|
-
/* @__PURE__ */ React26.createElement(AlertTitle2, null,
|
|
2088
|
-
|
|
2089
|
-
"It may have been deleted. Try clearing this field and select a different value or variable.",
|
|
2090
|
-
"elementor"
|
|
2091
|
-
)
|
|
2112
|
+
/* @__PURE__ */ React26.createElement(AlertTitle2, null, i18n.title),
|
|
2113
|
+
i18n.message
|
|
2092
2114
|
));
|
|
2093
2115
|
};
|
|
2094
2116
|
|
|
2095
|
-
// src/components/ui/tags/
|
|
2117
|
+
// src/components/ui/tags/mismatch-tag.tsx
|
|
2096
2118
|
import * as React27 from "react";
|
|
2097
2119
|
import { AlertTriangleFilledIcon as AlertTriangleFilledIcon3 } from "@elementor/icons";
|
|
2098
|
-
import { Chip as Chip2 } from "@elementor/ui";
|
|
2099
|
-
|
|
2120
|
+
import { Box as Box8, Chip as Chip2, Tooltip as Tooltip3, Typography as Typography9 } from "@elementor/ui";
|
|
2121
|
+
import { __ as __20 } from "@wordpress/i18n";
|
|
2122
|
+
var MismatchTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
2100
2123
|
return /* @__PURE__ */ React27.createElement(
|
|
2101
2124
|
Chip2,
|
|
2102
2125
|
{
|
|
@@ -2107,6 +2130,136 @@ var MissingTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
|
2107
2130
|
variant: "standard",
|
|
2108
2131
|
onClick,
|
|
2109
2132
|
icon: /* @__PURE__ */ React27.createElement(AlertTriangleFilledIcon3, null),
|
|
2133
|
+
label: /* @__PURE__ */ React27.createElement(Tooltip3, { title: label, placement: "top" }, /* @__PURE__ */ React27.createElement(Box8, { sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React27.createElement(Typography9, { variant: "caption", noWrap: true }, label), /* @__PURE__ */ React27.createElement(Typography9, { variant: "caption", noWrap: true, sx: { textOverflow: "initial", overflow: "visible" } }, "(", __20("changed", "elementor"), ")"))),
|
|
2134
|
+
sx: {
|
|
2135
|
+
height: (theme) => theme.spacing(3.5),
|
|
2136
|
+
borderRadius: (theme) => theme.spacing(1),
|
|
2137
|
+
justifyContent: "flex-start",
|
|
2138
|
+
width: "100%"
|
|
2139
|
+
},
|
|
2140
|
+
...props
|
|
2141
|
+
}
|
|
2142
|
+
);
|
|
2143
|
+
});
|
|
2144
|
+
|
|
2145
|
+
// src/components/ui/variable/mismatch-variable.tsx
|
|
2146
|
+
var MismatchVariable = ({ variable }) => {
|
|
2147
|
+
const { setValue } = useBoundProp9();
|
|
2148
|
+
const anchorRef = useRef3(null);
|
|
2149
|
+
const popupId = useId4();
|
|
2150
|
+
const popupState = usePopupState4({
|
|
2151
|
+
variant: "popover",
|
|
2152
|
+
popupId: `elementor-variables-list-${popupId}`
|
|
2153
|
+
});
|
|
2154
|
+
const [infotipVisible, setInfotipVisible] = useState12(false);
|
|
2155
|
+
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
2156
|
+
const closeInfotip = () => setInfotipVisible(false);
|
|
2157
|
+
const triggerSelect = () => {
|
|
2158
|
+
closeInfotip();
|
|
2159
|
+
popupState.setAnchorEl(anchorRef.current);
|
|
2160
|
+
popupState.open();
|
|
2161
|
+
};
|
|
2162
|
+
const clearValue = () => {
|
|
2163
|
+
closeInfotip();
|
|
2164
|
+
setValue(null);
|
|
2165
|
+
};
|
|
2166
|
+
return /* @__PURE__ */ React28.createElement(Box9, { ref: anchorRef }, infotipVisible && /* @__PURE__ */ React28.createElement(Backdrop2, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React28.createElement(
|
|
2167
|
+
Infotip2,
|
|
2168
|
+
{
|
|
2169
|
+
color: "warning",
|
|
2170
|
+
placement: "right-start",
|
|
2171
|
+
open: infotipVisible,
|
|
2172
|
+
disableHoverListener: true,
|
|
2173
|
+
onClose: closeInfotip,
|
|
2174
|
+
content: /* @__PURE__ */ React28.createElement(
|
|
2175
|
+
MismatchVariableAlert,
|
|
2176
|
+
{
|
|
2177
|
+
onClose: closeInfotip,
|
|
2178
|
+
onClear: clearValue,
|
|
2179
|
+
triggerSelect
|
|
2180
|
+
}
|
|
2181
|
+
),
|
|
2182
|
+
slotProps: {
|
|
2183
|
+
popper: {
|
|
2184
|
+
modifiers: [
|
|
2185
|
+
{
|
|
2186
|
+
name: "offset",
|
|
2187
|
+
options: { offset: [0, 24] }
|
|
2188
|
+
}
|
|
2189
|
+
]
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
},
|
|
2193
|
+
/* @__PURE__ */ React28.createElement(MismatchTag, { label: variable.label, onClick: toggleInfotip })
|
|
2194
|
+
), /* @__PURE__ */ React28.createElement(
|
|
2195
|
+
Popover3,
|
|
2196
|
+
{
|
|
2197
|
+
disableScrollLock: true,
|
|
2198
|
+
anchorEl: anchorRef.current,
|
|
2199
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
2200
|
+
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
2201
|
+
PaperProps: {
|
|
2202
|
+
sx: { my: 1 }
|
|
2203
|
+
},
|
|
2204
|
+
...bindPopover3(popupState)
|
|
2205
|
+
},
|
|
2206
|
+
/* @__PURE__ */ React28.createElement(
|
|
2207
|
+
VariableSelectionPopover,
|
|
2208
|
+
{
|
|
2209
|
+
selectedVariable: variable,
|
|
2210
|
+
closePopover: popupState.close,
|
|
2211
|
+
propTypeKey: variable.type
|
|
2212
|
+
}
|
|
2213
|
+
)
|
|
2214
|
+
));
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
// src/components/ui/variable/missing-variable.tsx
|
|
2218
|
+
import * as React31 from "react";
|
|
2219
|
+
import { useState as useState13 } from "react";
|
|
2220
|
+
import { useBoundProp as useBoundProp10 } from "@elementor/editor-controls";
|
|
2221
|
+
import { Backdrop as Backdrop3, Infotip as Infotip3 } from "@elementor/ui";
|
|
2222
|
+
import { __ as __22 } from "@wordpress/i18n";
|
|
2223
|
+
|
|
2224
|
+
// src/components/ui/missing-variable-alert.tsx
|
|
2225
|
+
import * as React29 from "react";
|
|
2226
|
+
import { useSectionWidth as useSectionWidth3 } from "@elementor/editor-editing-panel";
|
|
2227
|
+
import { Alert as Alert4, AlertAction as AlertAction3, AlertTitle as AlertTitle3, ClickAwayListener as ClickAwayListener4 } from "@elementor/ui";
|
|
2228
|
+
import { __ as __21 } from "@wordpress/i18n";
|
|
2229
|
+
var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
2230
|
+
const sectionWidth = useSectionWidth3();
|
|
2231
|
+
return /* @__PURE__ */ React29.createElement(ClickAwayListener4, { onClickAway: onClose }, /* @__PURE__ */ React29.createElement(
|
|
2232
|
+
Alert4,
|
|
2233
|
+
{
|
|
2234
|
+
variant: "standard",
|
|
2235
|
+
severity: "warning",
|
|
2236
|
+
onClose,
|
|
2237
|
+
action: /* @__PURE__ */ React29.createElement(React29.Fragment, null, onClear && /* @__PURE__ */ React29.createElement(AlertAction3, { variant: "contained", onClick: onClear }, __21("Clear", "elementor"))),
|
|
2238
|
+
sx: { width: sectionWidth }
|
|
2239
|
+
},
|
|
2240
|
+
/* @__PURE__ */ React29.createElement(AlertTitle3, null, __21("This variable is missing", "elementor")),
|
|
2241
|
+
__21(
|
|
2242
|
+
"It may have been deleted. Try clearing this field and select a different value or variable.",
|
|
2243
|
+
"elementor"
|
|
2244
|
+
)
|
|
2245
|
+
));
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
// src/components/ui/tags/missing-tag.tsx
|
|
2249
|
+
import * as React30 from "react";
|
|
2250
|
+
import { AlertTriangleFilledIcon as AlertTriangleFilledIcon4 } from "@elementor/icons";
|
|
2251
|
+
import { Chip as Chip3 } from "@elementor/ui";
|
|
2252
|
+
var MissingTag = React30.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
2253
|
+
return /* @__PURE__ */ React30.createElement(
|
|
2254
|
+
Chip3,
|
|
2255
|
+
{
|
|
2256
|
+
ref,
|
|
2257
|
+
size: "tiny",
|
|
2258
|
+
color: "warning",
|
|
2259
|
+
shape: "rounded",
|
|
2260
|
+
variant: "standard",
|
|
2261
|
+
onClick,
|
|
2262
|
+
icon: /* @__PURE__ */ React30.createElement(AlertTriangleFilledIcon4, null),
|
|
2110
2263
|
label,
|
|
2111
2264
|
sx: {
|
|
2112
2265
|
height: (theme) => theme.spacing(3.5),
|
|
@@ -2121,20 +2274,20 @@ var MissingTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
|
2121
2274
|
|
|
2122
2275
|
// src/components/ui/variable/missing-variable.tsx
|
|
2123
2276
|
var MissingVariable = () => {
|
|
2124
|
-
const { setValue } =
|
|
2125
|
-
const [infotipVisible, setInfotipVisible] =
|
|
2277
|
+
const { setValue } = useBoundProp10();
|
|
2278
|
+
const [infotipVisible, setInfotipVisible] = useState13(false);
|
|
2126
2279
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
2127
2280
|
const closeInfotip = () => setInfotipVisible(false);
|
|
2128
2281
|
const clearValue = () => setValue(null);
|
|
2129
|
-
return /* @__PURE__ */
|
|
2130
|
-
|
|
2282
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, infotipVisible && /* @__PURE__ */ React31.createElement(Backdrop3, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React31.createElement(
|
|
2283
|
+
Infotip3,
|
|
2131
2284
|
{
|
|
2132
2285
|
color: "warning",
|
|
2133
2286
|
placement: "right-start",
|
|
2134
2287
|
open: infotipVisible,
|
|
2135
2288
|
disableHoverListener: true,
|
|
2136
2289
|
onClose: closeInfotip,
|
|
2137
|
-
content: /* @__PURE__ */
|
|
2290
|
+
content: /* @__PURE__ */ React31.createElement(MissingVariableAlert, { onClose: closeInfotip, onClear: clearValue }),
|
|
2138
2291
|
slotProps: {
|
|
2139
2292
|
popper: {
|
|
2140
2293
|
modifiers: [
|
|
@@ -2146,42 +2299,47 @@ var MissingVariable = () => {
|
|
|
2146
2299
|
}
|
|
2147
2300
|
}
|
|
2148
2301
|
},
|
|
2149
|
-
/* @__PURE__ */
|
|
2302
|
+
/* @__PURE__ */ React31.createElement(MissingTag, { label: __22("Missing variable", "elementor"), onClick: toggleInfotip })
|
|
2150
2303
|
));
|
|
2151
2304
|
};
|
|
2152
2305
|
|
|
2153
2306
|
// src/controls/variable-control.tsx
|
|
2154
2307
|
var VariableControl = () => {
|
|
2155
|
-
const boundProp =
|
|
2156
|
-
const
|
|
2308
|
+
const boundProp = useBoundProp11();
|
|
2309
|
+
const boundPropValue = boundProp.value;
|
|
2310
|
+
const assignedVariable = useVariable(boundPropValue?.value);
|
|
2157
2311
|
if (!assignedVariable) {
|
|
2158
|
-
return /* @__PURE__ */
|
|
2312
|
+
return /* @__PURE__ */ React32.createElement(MissingVariable, null);
|
|
2159
2313
|
}
|
|
2160
|
-
const { $$type: propTypeKey } =
|
|
2314
|
+
const { $$type: propTypeKey } = boundPropValue;
|
|
2161
2315
|
if (assignedVariable?.deleted) {
|
|
2162
|
-
return /* @__PURE__ */
|
|
2316
|
+
return /* @__PURE__ */ React32.createElement(DeletedVariable, { variable: assignedVariable, propTypeKey });
|
|
2163
2317
|
}
|
|
2164
|
-
|
|
2318
|
+
const { isCompatible } = getVariableType(assignedVariable.type);
|
|
2319
|
+
if (isCompatible && !isCompatible(boundProp?.propType, assignedVariable)) {
|
|
2320
|
+
return /* @__PURE__ */ React32.createElement(MismatchVariable, { variable: assignedVariable });
|
|
2321
|
+
}
|
|
2322
|
+
return /* @__PURE__ */ React32.createElement(AssignedVariable, { variable: assignedVariable, propTypeKey });
|
|
2165
2323
|
};
|
|
2166
2324
|
|
|
2167
2325
|
// src/hooks/use-prop-variable-action.tsx
|
|
2168
|
-
import * as
|
|
2169
|
-
import { useBoundProp as
|
|
2326
|
+
import * as React33 from "react";
|
|
2327
|
+
import { useBoundProp as useBoundProp12 } from "@elementor/editor-editing-panel";
|
|
2170
2328
|
import { ColorFilterIcon as ColorFilterIcon4 } from "@elementor/icons";
|
|
2171
|
-
import { __ as
|
|
2329
|
+
import { __ as __23 } from "@wordpress/i18n";
|
|
2172
2330
|
var usePropVariableAction = () => {
|
|
2173
|
-
const { propType, path } =
|
|
2331
|
+
const { propType, path } = useBoundProp12();
|
|
2174
2332
|
const variable = resolveVariableFromPropType(propType);
|
|
2175
2333
|
return {
|
|
2176
2334
|
visible: Boolean(variable),
|
|
2177
2335
|
icon: ColorFilterIcon4,
|
|
2178
|
-
title:
|
|
2336
|
+
title: __23("Variables", "elementor"),
|
|
2179
2337
|
content: ({ close: closePopover }) => {
|
|
2180
2338
|
if (!variable) {
|
|
2181
2339
|
return null;
|
|
2182
2340
|
}
|
|
2183
2341
|
trackOpenVariablePopover(path, variable.variableType);
|
|
2184
|
-
return /* @__PURE__ */
|
|
2342
|
+
return /* @__PURE__ */ React33.createElement(VariableSelectionPopover, { closePopover, propTypeKey: variable.propTypeUtil.key });
|
|
2185
2343
|
}
|
|
2186
2344
|
};
|
|
2187
2345
|
};
|
|
@@ -2206,18 +2364,18 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
2206
2364
|
};
|
|
2207
2365
|
|
|
2208
2366
|
// src/register-variable-types.tsx
|
|
2209
|
-
import * as
|
|
2367
|
+
import * as React36 from "react";
|
|
2210
2368
|
import { colorPropTypeUtil, stringPropTypeUtil } from "@elementor/editor-props";
|
|
2211
2369
|
import { BrushIcon, TextIcon as TextIcon2 } from "@elementor/icons";
|
|
2212
2370
|
|
|
2213
2371
|
// src/components/fields/color-field.tsx
|
|
2214
|
-
import * as
|
|
2215
|
-
import { useRef as
|
|
2372
|
+
import * as React34 from "react";
|
|
2373
|
+
import { useRef as useRef4, useState as useState14 } from "react";
|
|
2216
2374
|
import { UnstableColorField } from "@elementor/ui";
|
|
2217
2375
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
2218
|
-
const [color, setColor] =
|
|
2219
|
-
const [errorMessage, setErrorMessage] =
|
|
2220
|
-
const defaultRef =
|
|
2376
|
+
const [color, setColor] = useState14(value);
|
|
2377
|
+
const [errorMessage, setErrorMessage] = useState14("");
|
|
2378
|
+
const defaultRef = useRef4(null);
|
|
2221
2379
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
2222
2380
|
const handleChange = (newValue) => {
|
|
2223
2381
|
setColor(newValue);
|
|
@@ -2226,7 +2384,7 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
2226
2384
|
onValidationChange?.(errorMsg);
|
|
2227
2385
|
onChange(errorMsg ? "" : newValue);
|
|
2228
2386
|
};
|
|
2229
|
-
return /* @__PURE__ */
|
|
2387
|
+
return /* @__PURE__ */ React34.createElement(
|
|
2230
2388
|
UnstableColorField,
|
|
2231
2389
|
{
|
|
2232
2390
|
size: "tiny",
|
|
@@ -2246,21 +2404,21 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
2246
2404
|
};
|
|
2247
2405
|
|
|
2248
2406
|
// src/components/fields/font-field.tsx
|
|
2249
|
-
import * as
|
|
2250
|
-
import { useId as
|
|
2407
|
+
import * as React35 from "react";
|
|
2408
|
+
import { useId as useId5, useRef as useRef5, useState as useState15 } from "react";
|
|
2251
2409
|
import { enqueueFont as enqueueFont2, ItemSelector } from "@elementor/editor-controls";
|
|
2252
|
-
import { useFontFamilies, useSectionWidth as
|
|
2410
|
+
import { useFontFamilies, useSectionWidth as useSectionWidth4 } from "@elementor/editor-editing-panel";
|
|
2253
2411
|
import { ChevronDownIcon, TextIcon } from "@elementor/icons";
|
|
2254
|
-
import { bindPopover as
|
|
2255
|
-
import { __ as
|
|
2412
|
+
import { bindPopover as bindPopover4, bindTrigger as bindTrigger3, Popover as Popover4, UnstableTag, usePopupState as usePopupState5 } from "@elementor/ui";
|
|
2413
|
+
import { __ as __24 } from "@wordpress/i18n";
|
|
2256
2414
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
2257
|
-
const [fontFamily, setFontFamily] =
|
|
2258
|
-
const defaultRef =
|
|
2415
|
+
const [fontFamily, setFontFamily] = useState15(value);
|
|
2416
|
+
const defaultRef = useRef5(null);
|
|
2259
2417
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
2260
|
-
const fontPopoverState =
|
|
2418
|
+
const fontPopoverState = usePopupState5({ variant: "popover" });
|
|
2261
2419
|
const fontFamilies = useFontFamilies();
|
|
2262
|
-
const sectionWidth =
|
|
2263
|
-
const mapFontSubs =
|
|
2420
|
+
const sectionWidth = useSectionWidth4();
|
|
2421
|
+
const mapFontSubs = React35.useMemo(() => {
|
|
2264
2422
|
return fontFamilies.map(({ label, fonts }) => ({
|
|
2265
2423
|
label,
|
|
2266
2424
|
items: fonts
|
|
@@ -2276,28 +2434,28 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
2276
2434
|
handleChange(newFontFamily);
|
|
2277
2435
|
fontPopoverState.close();
|
|
2278
2436
|
};
|
|
2279
|
-
const id2 =
|
|
2280
|
-
return /* @__PURE__ */
|
|
2437
|
+
const id2 = useId5();
|
|
2438
|
+
return /* @__PURE__ */ React35.createElement(React35.Fragment, null, /* @__PURE__ */ React35.createElement(
|
|
2281
2439
|
UnstableTag,
|
|
2282
2440
|
{
|
|
2283
2441
|
id: id2,
|
|
2284
2442
|
variant: "outlined",
|
|
2285
2443
|
label: fontFamily,
|
|
2286
|
-
endIcon: /* @__PURE__ */
|
|
2444
|
+
endIcon: /* @__PURE__ */ React35.createElement(ChevronDownIcon, { fontSize: "tiny" }),
|
|
2287
2445
|
...bindTrigger3(fontPopoverState),
|
|
2288
2446
|
fullWidth: true
|
|
2289
2447
|
}
|
|
2290
|
-
), /* @__PURE__ */
|
|
2291
|
-
|
|
2448
|
+
), /* @__PURE__ */ React35.createElement(
|
|
2449
|
+
Popover4,
|
|
2292
2450
|
{
|
|
2293
2451
|
disablePortal: true,
|
|
2294
2452
|
disableScrollLock: true,
|
|
2295
2453
|
anchorEl: anchorRef,
|
|
2296
2454
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
2297
2455
|
transformOrigin: { vertical: "top", horizontal: -28 },
|
|
2298
|
-
...
|
|
2456
|
+
...bindPopover4(fontPopoverState)
|
|
2299
2457
|
},
|
|
2300
|
-
/* @__PURE__ */
|
|
2458
|
+
/* @__PURE__ */ React35.createElement(
|
|
2301
2459
|
ItemSelector,
|
|
2302
2460
|
{
|
|
2303
2461
|
itemsList: mapFontSubs,
|
|
@@ -2305,7 +2463,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
2305
2463
|
onItemChange: handleFontFamilyChange,
|
|
2306
2464
|
onClose: fontPopoverState.close,
|
|
2307
2465
|
sectionWidth,
|
|
2308
|
-
title:
|
|
2466
|
+
title: __24("Font Family", "elementor"),
|
|
2309
2467
|
itemStyle: (item) => ({ fontFamily: item.value }),
|
|
2310
2468
|
onDebounce: enqueueFont2,
|
|
2311
2469
|
icon: TextIcon
|
|
@@ -2322,7 +2480,7 @@ function registerVariableTypes() {
|
|
|
2322
2480
|
propTypeUtil: colorVariablePropTypeUtil,
|
|
2323
2481
|
fallbackPropTypeUtil: colorPropTypeUtil,
|
|
2324
2482
|
variableType: "color",
|
|
2325
|
-
startIcon: ({ value }) => /* @__PURE__ */
|
|
2483
|
+
startIcon: ({ value }) => /* @__PURE__ */ React36.createElement(ColorIndicator, { size: "inherit", component: "span", value })
|
|
2326
2484
|
});
|
|
2327
2485
|
registerVariableType({
|
|
2328
2486
|
valueField: FontField,
|
|
@@ -2334,8 +2492,8 @@ function registerVariableTypes() {
|
|
|
2334
2492
|
}
|
|
2335
2493
|
|
|
2336
2494
|
// src/renderers/style-variables-renderer.tsx
|
|
2337
|
-
import * as
|
|
2338
|
-
import { useEffect as useEffect3, useState as
|
|
2495
|
+
import * as React37 from "react";
|
|
2496
|
+
import { useEffect as useEffect3, useState as useState16 } from "react";
|
|
2339
2497
|
import { __privateUseListenTo as useListenTo, commandEndEvent } from "@elementor/editor-v1-adapters";
|
|
2340
2498
|
import { Portal } from "@elementor/ui";
|
|
2341
2499
|
|
|
@@ -2356,13 +2514,13 @@ function StyleVariablesRenderer() {
|
|
|
2356
2514
|
}
|
|
2357
2515
|
const cssVariables = convertToCssVariables(styleVariables);
|
|
2358
2516
|
const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
|
|
2359
|
-
return /* @__PURE__ */
|
|
2517
|
+
return /* @__PURE__ */ React37.createElement(Portal, { container }, /* @__PURE__ */ React37.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
2360
2518
|
}
|
|
2361
2519
|
function usePortalContainer() {
|
|
2362
2520
|
return useListenTo(commandEndEvent("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
|
|
2363
2521
|
}
|
|
2364
2522
|
function useStyleVariables() {
|
|
2365
|
-
const [variables, setVariables] =
|
|
2523
|
+
const [variables, setVariables] = useState16({});
|
|
2366
2524
|
useEffect3(() => {
|
|
2367
2525
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
2368
2526
|
return () => {
|
|
@@ -2386,22 +2544,22 @@ import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from "@elemen
|
|
|
2386
2544
|
import { backgroundColorOverlayPropTypeUtil, shadowPropTypeUtil } from "@elementor/editor-props";
|
|
2387
2545
|
|
|
2388
2546
|
// src/components/variables-repeater-item-slot.tsx
|
|
2389
|
-
import * as
|
|
2547
|
+
import * as React38 from "react";
|
|
2390
2548
|
var useColorVariable = (value) => {
|
|
2391
2549
|
const variableId = value?.value?.color?.value;
|
|
2392
2550
|
return useVariable(variableId || "");
|
|
2393
2551
|
};
|
|
2394
2552
|
var BackgroundRepeaterColorIndicator = ({ value }) => {
|
|
2395
2553
|
const colorVariable = useColorVariable(value);
|
|
2396
|
-
return /* @__PURE__ */
|
|
2554
|
+
return /* @__PURE__ */ React38.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
2397
2555
|
};
|
|
2398
2556
|
var BackgroundRepeaterLabel = ({ value }) => {
|
|
2399
2557
|
const colorVariable = useColorVariable(value);
|
|
2400
|
-
return /* @__PURE__ */
|
|
2558
|
+
return /* @__PURE__ */ React38.createElement("span", null, colorVariable?.label);
|
|
2401
2559
|
};
|
|
2402
2560
|
var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
2403
2561
|
const colorVariable = useColorVariable(value);
|
|
2404
|
-
return /* @__PURE__ */
|
|
2562
|
+
return /* @__PURE__ */ React38.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
2405
2563
|
};
|
|
2406
2564
|
|
|
2407
2565
|
// src/repeater-injections.ts
|