@elementor/editor-components 3.33.0-299 → 3.33.0-300
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 +196 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +183 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -16
- package/src/components/overridable-props/indicator.tsx +81 -0
- package/src/components/overridable-props/overridable-prop-indicator.tsx +95 -0
- package/src/init.ts +9 -0
- package/src/prop-types/component-overridable-prop-type.ts +15 -0
- package/src/store/store.ts +6 -0
- package/src/types.ts +27 -1
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
registerElementType,
|
|
5
5
|
settingsTransformersRegistry as settingsTransformersRegistry2
|
|
6
6
|
} from "@elementor/editor-canvas";
|
|
7
|
-
import { getV1CurrentDocument } from "@elementor/editor-documents";
|
|
7
|
+
import { getV1CurrentDocument as getV1CurrentDocument2 } from "@elementor/editor-documents";
|
|
8
|
+
import { FIELD_TYPE, registerFieldIndicator } from "@elementor/editor-editing-panel";
|
|
8
9
|
import { injectTab } from "@elementor/editor-elements-panel";
|
|
9
10
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
10
11
|
import { __privateListenTo as listenTo2, commandStartEvent, registerDataHook } from "@elementor/editor-v1-adapters";
|
|
11
12
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
12
|
-
import { __ as
|
|
13
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
13
14
|
|
|
14
15
|
// src/component-instance-transformer.ts
|
|
15
16
|
import { createTransformer } from "@elementor/editor-canvas";
|
|
@@ -125,6 +126,7 @@ var selectLoadStatus = (state) => state[SLICE_NAME].loadStatus;
|
|
|
125
126
|
var selectStylesDefinitions = (state) => state[SLICE_NAME].styles ?? {};
|
|
126
127
|
var selectUnpublishedData = (state) => state[SLICE_NAME].unpublishedData;
|
|
127
128
|
var getCreatedThisSession = (state) => state[SLICE_NAME].createdThisSession;
|
|
129
|
+
var selectComponent = (state, componentId) => state[SLICE_NAME].data.find((component) => component.id === componentId);
|
|
128
130
|
var selectComponents = createSelector(
|
|
129
131
|
selectData,
|
|
130
132
|
selectUnpublishedData,
|
|
@@ -145,6 +147,10 @@ var selectCreatedThisSession = createSelector(
|
|
|
145
147
|
getCreatedThisSession,
|
|
146
148
|
(createdThisSession) => createdThisSession
|
|
147
149
|
);
|
|
150
|
+
var selectOverridableProps = createSelector(
|
|
151
|
+
selectComponent,
|
|
152
|
+
(component) => component?.overridableProps
|
|
153
|
+
);
|
|
148
154
|
|
|
149
155
|
// src/utils/component-document-data.ts
|
|
150
156
|
var getComponentDocumentData = async (id) => {
|
|
@@ -1198,13 +1204,172 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
1198
1204
|
)), /* @__PURE__ */ React10.createElement(DialogActions, null, /* @__PURE__ */ React10.createElement(Button2, { color: "secondary", variant: "contained", onClick: closeDialog }, __6("Close", "elementor"))))));
|
|
1199
1205
|
};
|
|
1200
1206
|
|
|
1207
|
+
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1208
|
+
import * as React12 from "react";
|
|
1209
|
+
import { useBoundProp } from "@elementor/editor-controls";
|
|
1210
|
+
import { getV1CurrentDocument } from "@elementor/editor-documents";
|
|
1211
|
+
import { useElement } from "@elementor/editor-editing-panel";
|
|
1212
|
+
import { __getState as getState4 } from "@elementor/store";
|
|
1213
|
+
import { bindPopover, bindTrigger, Popover as Popover2, Tooltip, usePopupState } from "@elementor/ui";
|
|
1214
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
1215
|
+
|
|
1216
|
+
// src/prop-types/component-overridable-prop-type.ts
|
|
1217
|
+
import { createPropUtils } from "@elementor/editor-props";
|
|
1218
|
+
import { z as z2 } from "@elementor/schema";
|
|
1219
|
+
var componentOverridablePropTypeUtil = createPropUtils(
|
|
1220
|
+
"overridable",
|
|
1221
|
+
z2.object({
|
|
1222
|
+
override_key: z2.string(),
|
|
1223
|
+
default_value: z2.object({
|
|
1224
|
+
$$type: z2.string(),
|
|
1225
|
+
value: z2.unknown()
|
|
1226
|
+
}).nullable()
|
|
1227
|
+
})
|
|
1228
|
+
);
|
|
1229
|
+
|
|
1230
|
+
// src/components/overridable-props/indicator.tsx
|
|
1231
|
+
import * as React11 from "react";
|
|
1232
|
+
import { forwardRef } from "react";
|
|
1233
|
+
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
1234
|
+
import { Box as Box6, styled } from "@elementor/ui";
|
|
1235
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
1236
|
+
var SIZE = "tiny";
|
|
1237
|
+
var IconContainer = styled(Box6)`
|
|
1238
|
+
pointer-events: none;
|
|
1239
|
+
opacity: 0;
|
|
1240
|
+
transition: opacity 0.2s ease-in-out;
|
|
1241
|
+
|
|
1242
|
+
& > svg {
|
|
1243
|
+
position: absolute;
|
|
1244
|
+
top: 50%;
|
|
1245
|
+
left: 50%;
|
|
1246
|
+
transform: translate( -50%, -50% );
|
|
1247
|
+
width: 10px;
|
|
1248
|
+
height: 10px;
|
|
1249
|
+
fill: ${({ theme }) => theme.palette.primary.contrastText};
|
|
1250
|
+
stroke: ${({ theme }) => theme.palette.primary.contrastText};
|
|
1251
|
+
stroke-width: 2px;
|
|
1252
|
+
}
|
|
1253
|
+
`;
|
|
1254
|
+
var Content = styled(Box6)`
|
|
1255
|
+
position: relative;
|
|
1256
|
+
display: flex;
|
|
1257
|
+
align-items: center;
|
|
1258
|
+
justify-content: center;
|
|
1259
|
+
cursor: pointer;
|
|
1260
|
+
width: 16px;
|
|
1261
|
+
height: 16px;
|
|
1262
|
+
margin-inline: ${({ theme }) => theme.spacing(0.5)};
|
|
1263
|
+
|
|
1264
|
+
&:before {
|
|
1265
|
+
content: '';
|
|
1266
|
+
display: block;
|
|
1267
|
+
position: absolute;
|
|
1268
|
+
top: 50%;
|
|
1269
|
+
left: 50%;
|
|
1270
|
+
transform: translate( -50%, -50% ) rotate( 45deg );
|
|
1271
|
+
width: 5px;
|
|
1272
|
+
height: 5px;
|
|
1273
|
+
border-radius: 1px;
|
|
1274
|
+
background-color: ${({ theme }) => theme.palette.primary.main};
|
|
1275
|
+
transition: all 0.1s ease-in-out;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
&:hover,
|
|
1279
|
+
&.enlarged {
|
|
1280
|
+
&:before {
|
|
1281
|
+
width: 12px;
|
|
1282
|
+
height: 12px;
|
|
1283
|
+
border-radius: 2px;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
.icon {
|
|
1287
|
+
opacity: 1;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
`;
|
|
1291
|
+
var Indicator = forwardRef(({ triggerProps, isOpen, isOverridable }, ref) => /* @__PURE__ */ React11.createElement(Content, { ref, ...triggerProps, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React11.createElement(
|
|
1292
|
+
IconContainer,
|
|
1293
|
+
{
|
|
1294
|
+
className: "icon",
|
|
1295
|
+
"aria-label": isOverridable ? __7("Overridable property", "elementor") : __7("Make prop overridable", "elementor")
|
|
1296
|
+
},
|
|
1297
|
+
isOverridable ? /* @__PURE__ */ React11.createElement(CheckIcon, { fontSize: SIZE }) : /* @__PURE__ */ React11.createElement(PlusIcon, { fontSize: SIZE })
|
|
1298
|
+
)));
|
|
1299
|
+
|
|
1300
|
+
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1301
|
+
var FORBIDDEN_KEYS = ["_cssid", "attributes"];
|
|
1302
|
+
function OverridablePropIndicator() {
|
|
1303
|
+
const { bind, value } = useBoundProp();
|
|
1304
|
+
const currentDocument = getV1CurrentDocument();
|
|
1305
|
+
if (currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE || !currentDocument.id) {
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
if (!isPropAllowed(bind)) {
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
const overridableProps = selectOverridableProps(getState4(), currentDocument.id);
|
|
1312
|
+
const isOverridable = componentOverridablePropTypeUtil.isValid(value);
|
|
1313
|
+
return /* @__PURE__ */ React12.createElement(
|
|
1314
|
+
Content2,
|
|
1315
|
+
{
|
|
1316
|
+
componentId: currentDocument.id,
|
|
1317
|
+
isOverridable,
|
|
1318
|
+
overridableProps
|
|
1319
|
+
}
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
function Content2({ isOverridable, overridableProps }) {
|
|
1323
|
+
const {
|
|
1324
|
+
element: { id: elementId }
|
|
1325
|
+
} = useElement();
|
|
1326
|
+
const { bind } = useBoundProp();
|
|
1327
|
+
const popupState = usePopupState({
|
|
1328
|
+
variant: "popover"
|
|
1329
|
+
});
|
|
1330
|
+
const triggerProps = bindTrigger(popupState);
|
|
1331
|
+
const popoverProps = bindPopover(popupState);
|
|
1332
|
+
const overridableConfig = Object.values(overridableProps?.props ?? {}).find(
|
|
1333
|
+
(prop) => prop.elementId === elementId && prop.propKey === bind
|
|
1334
|
+
);
|
|
1335
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(Tooltip, { placement: "top", title: __8("Override Property", "elementor") }, /* @__PURE__ */ React12.createElement(
|
|
1336
|
+
Indicator,
|
|
1337
|
+
{
|
|
1338
|
+
triggerProps,
|
|
1339
|
+
isOpen: !!popoverProps.open,
|
|
1340
|
+
isOverridable
|
|
1341
|
+
}
|
|
1342
|
+
)), /* @__PURE__ */ React12.createElement(
|
|
1343
|
+
Popover2,
|
|
1344
|
+
{
|
|
1345
|
+
disableScrollLock: true,
|
|
1346
|
+
anchorOrigin: {
|
|
1347
|
+
vertical: "bottom",
|
|
1348
|
+
horizontal: "right"
|
|
1349
|
+
},
|
|
1350
|
+
transformOrigin: {
|
|
1351
|
+
vertical: "top",
|
|
1352
|
+
horizontal: "right"
|
|
1353
|
+
},
|
|
1354
|
+
PaperProps: {
|
|
1355
|
+
sx: { my: 2.5 }
|
|
1356
|
+
},
|
|
1357
|
+
...popoverProps
|
|
1358
|
+
},
|
|
1359
|
+
JSON.stringify(overridableConfig)
|
|
1360
|
+
));
|
|
1361
|
+
}
|
|
1362
|
+
function isPropAllowed(bind) {
|
|
1363
|
+
return !FORBIDDEN_KEYS.includes(bind);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1201
1366
|
// src/create-component-type.ts
|
|
1202
1367
|
import {
|
|
1203
1368
|
createTemplatedElementView
|
|
1204
1369
|
} from "@elementor/editor-canvas";
|
|
1205
1370
|
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
1206
1371
|
import { __privateRunCommand as runCommand3 } from "@elementor/editor-v1-adapters";
|
|
1207
|
-
import { __ as
|
|
1372
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
1208
1373
|
var TYPE = "e-component";
|
|
1209
1374
|
function createComponentType(options) {
|
|
1210
1375
|
const legacyWindow = window;
|
|
@@ -1263,7 +1428,7 @@ function createComponentView(options) {
|
|
|
1263
1428
|
{
|
|
1264
1429
|
name: "edit component",
|
|
1265
1430
|
icon: "eicon-edit",
|
|
1266
|
-
title: () =>
|
|
1431
|
+
title: () => __9("Edit Component", "elementor"),
|
|
1267
1432
|
isEnabled: () => true,
|
|
1268
1433
|
callback: (_, eventData) => this.editComponent(eventData)
|
|
1269
1434
|
}
|
|
@@ -1350,7 +1515,7 @@ function PopulateStore() {
|
|
|
1350
1515
|
|
|
1351
1516
|
// src/store/components-styles-provider.ts
|
|
1352
1517
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
1353
|
-
import { __getState as
|
|
1518
|
+
import { __getState as getState5, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
1354
1519
|
var componentsStylesProvider = createStylesProvider({
|
|
1355
1520
|
key: "components-styles",
|
|
1356
1521
|
priority: 100,
|
|
@@ -1362,10 +1527,10 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
1362
1527
|
),
|
|
1363
1528
|
actions: {
|
|
1364
1529
|
all: () => {
|
|
1365
|
-
return selectFlatStyles(
|
|
1530
|
+
return selectFlatStyles(getState5());
|
|
1366
1531
|
},
|
|
1367
1532
|
get: (id) => {
|
|
1368
|
-
return selectFlatStyles(
|
|
1533
|
+
return selectFlatStyles(getState5()).find((style) => style.id === id) ?? null;
|
|
1369
1534
|
}
|
|
1370
1535
|
}
|
|
1371
1536
|
});
|
|
@@ -1379,12 +1544,12 @@ function removeComponentStyles(id) {
|
|
|
1379
1544
|
|
|
1380
1545
|
// src/sync/create-components-before-save.ts
|
|
1381
1546
|
import { updateElementSettings } from "@elementor/editor-elements";
|
|
1382
|
-
import { __dispatch as dispatch5, __getState as
|
|
1547
|
+
import { __dispatch as dispatch5, __getState as getState6 } from "@elementor/store";
|
|
1383
1548
|
async function createComponentsBeforeSave({
|
|
1384
1549
|
container,
|
|
1385
1550
|
status
|
|
1386
1551
|
}) {
|
|
1387
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
1552
|
+
const unpublishedComponents = selectUnpublishedComponents(getState6());
|
|
1388
1553
|
if (!unpublishedComponents.length) {
|
|
1389
1554
|
return;
|
|
1390
1555
|
}
|
|
@@ -1493,7 +1658,7 @@ function init() {
|
|
|
1493
1658
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
1494
1659
|
);
|
|
1495
1660
|
registerDataHook("dependency", "editor/documents/close", (args) => {
|
|
1496
|
-
const document =
|
|
1661
|
+
const document = getV1CurrentDocument2();
|
|
1497
1662
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE2) {
|
|
1498
1663
|
args.mode = "autosave";
|
|
1499
1664
|
}
|
|
@@ -1503,7 +1668,7 @@ function init() {
|
|
|
1503
1668
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
1504
1669
|
injectTab({
|
|
1505
1670
|
id: "components",
|
|
1506
|
-
label:
|
|
1671
|
+
label: __10("Components", "elementor"),
|
|
1507
1672
|
component: Components
|
|
1508
1673
|
});
|
|
1509
1674
|
injectIntoTop({
|
|
@@ -1519,12 +1684,18 @@ function init() {
|
|
|
1519
1684
|
component: EditComponent
|
|
1520
1685
|
});
|
|
1521
1686
|
listenTo2(commandStartEvent("editor/documents/attach-preview"), () => {
|
|
1522
|
-
const { id, config } =
|
|
1687
|
+
const { id, config } = getV1CurrentDocument2();
|
|
1523
1688
|
if (id) {
|
|
1524
1689
|
removeComponentStyles(id);
|
|
1525
1690
|
}
|
|
1526
1691
|
loadComponentsStyles(config?.elements ?? []);
|
|
1527
1692
|
});
|
|
1693
|
+
registerFieldIndicator({
|
|
1694
|
+
fieldType: FIELD_TYPE.SETTINGS,
|
|
1695
|
+
id: "component-overridable-prop",
|
|
1696
|
+
priority: 1,
|
|
1697
|
+
indicator: OverridablePropIndicator
|
|
1698
|
+
});
|
|
1528
1699
|
settingsTransformersRegistry2.register("component-instance", componentInstanceTransformer);
|
|
1529
1700
|
settingsTransformersRegistry2.register("overridable", componentOverridableTransformer);
|
|
1530
1701
|
}
|