@elementor/editor-components 3.35.0-378 → 3.35.0-380
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 +1482 -562
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1421 -485
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -21
- package/src/components/component-panel-header/component-badge.tsx +30 -22
- package/src/components/component-panel-header/component-panel-header.tsx +21 -1
- package/src/components/component-properties-panel/component-properties-panel-content.tsx +165 -0
- package/src/components/component-properties-panel/component-properties-panel.tsx +51 -0
- package/src/components/component-properties-panel/properties-empty-state.tsx +44 -0
- package/src/components/component-properties-panel/properties-group.tsx +191 -0
- package/src/components/component-properties-panel/property-item.tsx +121 -0
- package/src/components/component-properties-panel/sortable.tsx +92 -0
- package/src/components/component-properties-panel/use-current-editable-item.ts +74 -0
- package/src/components/component-properties-panel/utils/generate-unique-label.ts +21 -0
- package/src/components/component-properties-panel/utils/validate-group-label.ts +24 -0
- package/src/components/components-tab/component-introduction.tsx +68 -0
- package/src/components/instance-editing-panel/instance-editing-panel.tsx +1 -1
- package/src/components/overridable-props/overridable-prop-form.tsx +7 -4
- package/src/init.ts +3 -0
- package/src/store/actions/add-overridable-group.ts +47 -0
- package/src/store/actions/delete-overridable-group.ts +38 -0
- package/src/store/actions/delete-overridable-prop.ts +56 -0
- package/src/store/actions/rename-overridable-group.ts +39 -0
- package/src/store/actions/reorder-group-props.ts +43 -0
- package/src/store/actions/reorder-overridable-groups.ts +30 -0
- package/src/store/actions/set-overridable-prop.ts +21 -126
- package/src/store/actions/update-overridable-prop.ts +58 -0
- package/src/store/utils/groups-transformers.ts +185 -0
package/dist/index.js
CHANGED
|
@@ -37,13 +37,14 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
// src/init.ts
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
39
|
var import_editor_canvas8 = require("@elementor/editor-canvas");
|
|
40
|
-
var
|
|
41
|
-
var
|
|
40
|
+
var import_editor_documents12 = require("@elementor/editor-documents");
|
|
41
|
+
var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
|
|
42
42
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
43
|
+
var import_editor_panels4 = require("@elementor/editor-panels");
|
|
43
44
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
44
45
|
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
45
|
-
var
|
|
46
|
-
var
|
|
46
|
+
var import_store64 = require("@elementor/store");
|
|
47
|
+
var import_i18n24 = require("@wordpress/i18n");
|
|
47
48
|
|
|
48
49
|
// src/component-instance-transformer.ts
|
|
49
50
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
@@ -59,10 +60,10 @@ var import_store = require("@elementor/store");
|
|
|
59
60
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
60
61
|
var import_http_client = require("@elementor/http-client");
|
|
61
62
|
var BASE_URL = "elementor/v1/components";
|
|
62
|
-
var getParams = (
|
|
63
|
+
var getParams = (id2) => ({
|
|
63
64
|
action: "get_document_config",
|
|
64
|
-
unique_id: `document-config-${
|
|
65
|
-
data: { id }
|
|
65
|
+
unique_id: `document-config-${id2}`,
|
|
66
|
+
data: { id: id2 }
|
|
66
67
|
});
|
|
67
68
|
var apiClient = {
|
|
68
69
|
get: () => (0, import_http_client.httpService)().get(`${BASE_URL}`).then((res) => res.data.data),
|
|
@@ -71,8 +72,8 @@ var apiClient = {
|
|
|
71
72
|
ids,
|
|
72
73
|
status
|
|
73
74
|
}),
|
|
74
|
-
getComponentConfig: (
|
|
75
|
-
invalidateComponentConfigCache: (
|
|
75
|
+
getComponentConfig: (id2) => import_editor_v1_adapters.ajax.load(getParams(id2)),
|
|
76
|
+
invalidateComponentConfigCache: (id2) => import_editor_v1_adapters.ajax.invalidateCache(getParams(id2)),
|
|
76
77
|
getComponentLockStatus: async (componentId) => await (0, import_http_client.httpService)().get(`${BASE_URL}/lock-status`, {
|
|
77
78
|
params: {
|
|
78
79
|
componentId
|
|
@@ -255,17 +256,17 @@ var selectArchivedComponents = (0, import_store2.__createSelector)(
|
|
|
255
256
|
|
|
256
257
|
// src/utils/component-document-data.ts
|
|
257
258
|
var import_editor_documents = require("@elementor/editor-documents");
|
|
258
|
-
var getComponentDocumentData = async (
|
|
259
|
+
var getComponentDocumentData = async (id2) => {
|
|
259
260
|
const documentManager = (0, import_editor_documents.getV1DocumentsManager)();
|
|
260
261
|
try {
|
|
261
|
-
return await documentManager.request(
|
|
262
|
+
return await documentManager.request(id2);
|
|
262
263
|
} catch {
|
|
263
264
|
return null;
|
|
264
265
|
}
|
|
265
266
|
};
|
|
266
|
-
var invalidateComponentDocumentData = (
|
|
267
|
+
var invalidateComponentDocumentData = (id2) => {
|
|
267
268
|
const documentManager = (0, import_editor_documents.getV1DocumentsManager)();
|
|
268
|
-
documentManager.invalidateCache(
|
|
269
|
+
documentManager.invalidateCache(id2);
|
|
269
270
|
};
|
|
270
271
|
|
|
271
272
|
// src/component-instance-transformer.ts
|
|
@@ -274,11 +275,11 @@ var componentInstanceContext = new import_editor_canvas.RenderContext("component
|
|
|
274
275
|
});
|
|
275
276
|
var componentInstanceTransformer = (0, import_editor_canvas.createTransformer)(
|
|
276
277
|
async ({
|
|
277
|
-
component_id:
|
|
278
|
+
component_id: id2,
|
|
278
279
|
overrides: overridesValue
|
|
279
280
|
}) => {
|
|
280
281
|
const unpublishedComponents = selectUnpublishedComponents((0, import_store3.__getState)());
|
|
281
|
-
const unpublishedComponent = unpublishedComponents.find(({ uid }) => uid ===
|
|
282
|
+
const unpublishedComponent = unpublishedComponents.find(({ uid }) => uid === id2);
|
|
282
283
|
const overrides = overridesValue?.reduce((acc, override) => ({ ...acc, ...override }), {});
|
|
283
284
|
if (unpublishedComponent) {
|
|
284
285
|
return {
|
|
@@ -286,10 +287,10 @@ var componentInstanceTransformer = (0, import_editor_canvas.createTransformer)(
|
|
|
286
287
|
overrides
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
|
-
if (typeof
|
|
290
|
-
throw new Error(`Component ID "${
|
|
290
|
+
if (typeof id2 !== "number") {
|
|
291
|
+
throw new Error(`Component ID "${id2}" not valid.`);
|
|
291
292
|
}
|
|
292
|
-
const data = await getComponentDocumentData(
|
|
293
|
+
const data = await getComponentDocumentData(id2);
|
|
293
294
|
return {
|
|
294
295
|
elements: data?.elements ?? [],
|
|
295
296
|
overrides
|
|
@@ -339,11 +340,12 @@ var componentOverrideTransformer = (0, import_editor_canvas3.createTransformer)(
|
|
|
339
340
|
});
|
|
340
341
|
|
|
341
342
|
// src/components/component-panel-header/component-panel-header.tsx
|
|
342
|
-
var
|
|
343
|
-
var
|
|
344
|
-
var
|
|
345
|
-
var
|
|
346
|
-
var
|
|
343
|
+
var React10 = __toESM(require("react"));
|
|
344
|
+
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
345
|
+
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
346
|
+
var import_icons7 = require("@elementor/icons");
|
|
347
|
+
var import_ui10 = require("@elementor/ui");
|
|
348
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
347
349
|
|
|
348
350
|
// src/hooks/use-navigate-back.ts
|
|
349
351
|
var import_react = require("react");
|
|
@@ -376,29 +378,1078 @@ function useNavigateBack() {
|
|
|
376
378
|
}, [path, documentsManager]);
|
|
377
379
|
}
|
|
378
380
|
|
|
379
|
-
// src/components/component-panel
|
|
381
|
+
// src/components/component-properties-panel/component-properties-panel.tsx
|
|
382
|
+
var React7 = __toESM(require("react"));
|
|
383
|
+
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
384
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
385
|
+
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
386
|
+
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
387
|
+
var import_ui7 = require("@elementor/ui");
|
|
388
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
389
|
+
|
|
390
|
+
// src/components/component-properties-panel/component-properties-panel-content.tsx
|
|
391
|
+
var React6 = __toESM(require("react"));
|
|
392
|
+
var import_react4 = require("react");
|
|
393
|
+
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
394
|
+
var import_editor_panels = require("@elementor/editor-panels");
|
|
395
|
+
var import_icons5 = require("@elementor/icons");
|
|
396
|
+
var import_ui6 = require("@elementor/ui");
|
|
397
|
+
var import_utils2 = require("@elementor/utils");
|
|
398
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
399
|
+
|
|
400
|
+
// src/store/actions/add-overridable-group.ts
|
|
401
|
+
var import_store7 = require("@elementor/store");
|
|
402
|
+
function addOverridableGroup({
|
|
403
|
+
componentId,
|
|
404
|
+
groupId,
|
|
405
|
+
label
|
|
406
|
+
}) {
|
|
407
|
+
const overridableProps = selectOverridableProps((0, import_store7.__getState)(), componentId);
|
|
408
|
+
if (!overridableProps) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
const newGroup = {
|
|
412
|
+
id: groupId,
|
|
413
|
+
label,
|
|
414
|
+
props: []
|
|
415
|
+
};
|
|
416
|
+
(0, import_store7.__dispatch)(
|
|
417
|
+
slice.actions.setOverridableProps({
|
|
418
|
+
componentId,
|
|
419
|
+
overridableProps: {
|
|
420
|
+
...overridableProps,
|
|
421
|
+
groups: {
|
|
422
|
+
...overridableProps.groups,
|
|
423
|
+
items: {
|
|
424
|
+
...overridableProps.groups.items,
|
|
425
|
+
[groupId]: newGroup
|
|
426
|
+
},
|
|
427
|
+
order: [groupId, ...overridableProps.groups.order]
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
})
|
|
431
|
+
);
|
|
432
|
+
return newGroup;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/store/actions/delete-overridable-group.ts
|
|
436
|
+
var import_store9 = require("@elementor/store");
|
|
437
|
+
|
|
438
|
+
// src/store/utils/groups-transformers.ts
|
|
439
|
+
var import_utils = require("@elementor/utils");
|
|
440
|
+
var import_i18n = require("@wordpress/i18n");
|
|
441
|
+
function removePropFromAllGroups(groups, propKey) {
|
|
442
|
+
return {
|
|
443
|
+
...groups,
|
|
444
|
+
items: Object.fromEntries(
|
|
445
|
+
Object.entries(groups.items).map(([groupId, group]) => [
|
|
446
|
+
groupId,
|
|
447
|
+
{
|
|
448
|
+
...group,
|
|
449
|
+
props: group.props.filter((p) => p !== propKey)
|
|
450
|
+
}
|
|
451
|
+
])
|
|
452
|
+
)
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function addPropToGroup(groups, groupId, propKey) {
|
|
456
|
+
const group = groups.items[groupId];
|
|
457
|
+
if (!group) {
|
|
458
|
+
return groups;
|
|
459
|
+
}
|
|
460
|
+
if (group.props.includes(propKey)) {
|
|
461
|
+
return groups;
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
...groups,
|
|
465
|
+
items: {
|
|
466
|
+
...groups.items,
|
|
467
|
+
[groupId]: {
|
|
468
|
+
...group,
|
|
469
|
+
props: [...group.props, propKey]
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function movePropBetweenGroups(groups, propKey, fromGroupId, toGroupId) {
|
|
475
|
+
if (fromGroupId === toGroupId) {
|
|
476
|
+
return groups;
|
|
477
|
+
}
|
|
478
|
+
const withoutProp = removePropFromGroup(groups, fromGroupId, propKey);
|
|
479
|
+
return addPropToGroup(withoutProp, toGroupId, propKey);
|
|
480
|
+
}
|
|
481
|
+
function removePropFromGroup(groups, groupId, propKey) {
|
|
482
|
+
const group = groups.items[groupId];
|
|
483
|
+
if (!group) {
|
|
484
|
+
return groups;
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
...groups,
|
|
488
|
+
items: {
|
|
489
|
+
...groups.items,
|
|
490
|
+
[groupId]: {
|
|
491
|
+
...group,
|
|
492
|
+
props: group.props.filter((p) => p !== propKey)
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function resolveOrCreateGroup(groups, requestedGroupId) {
|
|
498
|
+
if (requestedGroupId && groups.items[requestedGroupId]) {
|
|
499
|
+
return { groups, groupId: requestedGroupId };
|
|
500
|
+
}
|
|
501
|
+
if (!requestedGroupId && groups.order.length > 0) {
|
|
502
|
+
return { groups, groupId: groups.order[0] };
|
|
503
|
+
}
|
|
504
|
+
return createGroup(groups, requestedGroupId);
|
|
505
|
+
}
|
|
506
|
+
function createGroup(groups, groupId, label) {
|
|
507
|
+
const newGroupId = groupId || (0, import_utils.generateUniqueId)("group");
|
|
508
|
+
const newLabel = label || (0, import_i18n.__)("Default", "elementor");
|
|
509
|
+
return {
|
|
510
|
+
groups: {
|
|
511
|
+
...groups,
|
|
512
|
+
items: {
|
|
513
|
+
...groups.items,
|
|
514
|
+
[newGroupId]: {
|
|
515
|
+
id: newGroupId,
|
|
516
|
+
label: newLabel,
|
|
517
|
+
props: []
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
order: [...groups.order, newGroupId]
|
|
521
|
+
},
|
|
522
|
+
groupId: newGroupId
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function removePropsFromState(overridableProps, propsToRemove) {
|
|
526
|
+
const overrideKeysToRemove = propsToRemove.map((prop) => prop.overrideKey);
|
|
527
|
+
const remainingProps = Object.fromEntries(
|
|
528
|
+
Object.entries(overridableProps.props).filter(([, prop]) => !propsToRemove.includes(prop))
|
|
529
|
+
);
|
|
530
|
+
const updatedGroupItems = Object.fromEntries(
|
|
531
|
+
Object.entries(overridableProps.groups.items).map(
|
|
532
|
+
([groupId, group]) => [
|
|
533
|
+
groupId,
|
|
534
|
+
{
|
|
535
|
+
...group,
|
|
536
|
+
props: group.props.filter((prop) => !overrideKeysToRemove.includes(prop))
|
|
537
|
+
}
|
|
538
|
+
]
|
|
539
|
+
)
|
|
540
|
+
);
|
|
541
|
+
return {
|
|
542
|
+
props: remainingProps,
|
|
543
|
+
groups: {
|
|
544
|
+
items: updatedGroupItems,
|
|
545
|
+
order: overridableProps.groups.order.filter((groupId) => !overrideKeysToRemove.includes(groupId))
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function ensureGroupInOrder(groups, groupId) {
|
|
550
|
+
if (groups.order.includes(groupId)) {
|
|
551
|
+
return groups;
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
...groups,
|
|
555
|
+
order: [...groups.order, groupId]
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
function deleteGroup(groups, groupId) {
|
|
559
|
+
const { [groupId]: removed, ...remainingItems } = groups.items;
|
|
560
|
+
return {
|
|
561
|
+
items: remainingItems,
|
|
562
|
+
order: groups.order.filter((id2) => id2 !== groupId)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function renameGroup(groups, groupId, newLabel) {
|
|
566
|
+
const group = groups.items[groupId];
|
|
567
|
+
if (!group) {
|
|
568
|
+
return groups;
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
...groups,
|
|
572
|
+
items: {
|
|
573
|
+
...groups.items,
|
|
574
|
+
[groupId]: {
|
|
575
|
+
...group,
|
|
576
|
+
label: newLabel
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// src/store/actions/delete-overridable-group.ts
|
|
583
|
+
function deleteOverridableGroup({ componentId, groupId }) {
|
|
584
|
+
const overridableProps = selectOverridableProps((0, import_store9.__getState)(), componentId);
|
|
585
|
+
if (!overridableProps) {
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
const group = overridableProps.groups.items[groupId];
|
|
589
|
+
if (!group || group.props.length > 0) {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
const updatedGroups = deleteGroup(overridableProps.groups, groupId);
|
|
593
|
+
(0, import_store9.__dispatch)(
|
|
594
|
+
slice.actions.setOverridableProps({
|
|
595
|
+
componentId,
|
|
596
|
+
overridableProps: {
|
|
597
|
+
...overridableProps,
|
|
598
|
+
groups: updatedGroups
|
|
599
|
+
}
|
|
600
|
+
})
|
|
601
|
+
);
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// src/store/actions/delete-overridable-prop.ts
|
|
606
|
+
var import_editor_elements = require("@elementor/editor-elements");
|
|
607
|
+
var import_store11 = require("@elementor/store");
|
|
608
|
+
function deleteOverridableProp({ componentId, propKey }) {
|
|
609
|
+
const overridableProps = selectOverridableProps((0, import_store11.__getState)(), componentId);
|
|
610
|
+
if (!overridableProps) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const prop = overridableProps.props[propKey];
|
|
614
|
+
if (!prop) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
revertElementSetting(prop.elementId, prop.propKey, prop.originValue);
|
|
618
|
+
const { [propKey]: removedProp, ...remainingProps } = overridableProps.props;
|
|
619
|
+
const updatedGroups = removePropFromAllGroups(overridableProps.groups, propKey);
|
|
620
|
+
(0, import_store11.__dispatch)(
|
|
621
|
+
slice.actions.setOverridableProps({
|
|
622
|
+
componentId,
|
|
623
|
+
overridableProps: {
|
|
624
|
+
...overridableProps,
|
|
625
|
+
props: remainingProps,
|
|
626
|
+
groups: updatedGroups
|
|
627
|
+
}
|
|
628
|
+
})
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
function revertElementSetting(elementId, settingKey, originValue) {
|
|
632
|
+
const container = (0, import_editor_elements.getContainer)(elementId);
|
|
633
|
+
if (!container) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
(0, import_editor_elements.updateElementSettings)({
|
|
637
|
+
id: elementId,
|
|
638
|
+
props: { [settingKey]: originValue ?? null },
|
|
639
|
+
withHistory: false
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// src/store/actions/reorder-group-props.ts
|
|
644
|
+
var import_store13 = require("@elementor/store");
|
|
645
|
+
function reorderGroupProps({ componentId, groupId, newPropsOrder }) {
|
|
646
|
+
const overridableProps = selectOverridableProps((0, import_store13.__getState)(), componentId);
|
|
647
|
+
if (!overridableProps) {
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
const group = overridableProps.groups.items[groupId];
|
|
651
|
+
if (!group) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
(0, import_store13.__dispatch)(
|
|
655
|
+
slice.actions.setOverridableProps({
|
|
656
|
+
componentId,
|
|
657
|
+
overridableProps: {
|
|
658
|
+
...overridableProps,
|
|
659
|
+
groups: {
|
|
660
|
+
...overridableProps.groups,
|
|
661
|
+
items: {
|
|
662
|
+
...overridableProps.groups.items,
|
|
663
|
+
[groupId]: {
|
|
664
|
+
...group,
|
|
665
|
+
props: newPropsOrder
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
})
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// src/store/actions/reorder-overridable-groups.ts
|
|
675
|
+
var import_store15 = require("@elementor/store");
|
|
676
|
+
function reorderOverridableGroups({ componentId, newOrder }) {
|
|
677
|
+
const overridableProps = selectOverridableProps((0, import_store15.__getState)(), componentId);
|
|
678
|
+
if (!overridableProps) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
(0, import_store15.__dispatch)(
|
|
682
|
+
slice.actions.setOverridableProps({
|
|
683
|
+
componentId,
|
|
684
|
+
overridableProps: {
|
|
685
|
+
...overridableProps,
|
|
686
|
+
groups: {
|
|
687
|
+
...overridableProps.groups,
|
|
688
|
+
order: newOrder
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
})
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// src/store/actions/update-overridable-prop.ts
|
|
696
|
+
var import_store17 = require("@elementor/store");
|
|
697
|
+
function updateOverridableProp({
|
|
698
|
+
componentId,
|
|
699
|
+
propKey,
|
|
700
|
+
label,
|
|
701
|
+
groupId
|
|
702
|
+
}) {
|
|
703
|
+
const overridableProps = selectOverridableProps((0, import_store17.__getState)(), componentId);
|
|
704
|
+
if (!overridableProps) {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
const prop = overridableProps.props[propKey];
|
|
708
|
+
if (!prop) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const oldGroupId = prop.groupId;
|
|
712
|
+
const newGroupId = groupId ?? oldGroupId;
|
|
713
|
+
const updatedProp = {
|
|
714
|
+
...prop,
|
|
715
|
+
label,
|
|
716
|
+
groupId: newGroupId
|
|
717
|
+
};
|
|
718
|
+
const updatedGroups = movePropBetweenGroups(overridableProps.groups, propKey, oldGroupId, newGroupId);
|
|
719
|
+
(0, import_store17.__dispatch)(
|
|
720
|
+
slice.actions.setOverridableProps({
|
|
721
|
+
componentId,
|
|
722
|
+
overridableProps: {
|
|
723
|
+
...overridableProps,
|
|
724
|
+
props: {
|
|
725
|
+
...overridableProps.props,
|
|
726
|
+
[propKey]: updatedProp
|
|
727
|
+
},
|
|
728
|
+
groups: updatedGroups
|
|
729
|
+
}
|
|
730
|
+
})
|
|
731
|
+
);
|
|
732
|
+
return updatedProp;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// src/components/component-panel-header/use-overridable-props.ts
|
|
736
|
+
var import_store19 = require("@elementor/store");
|
|
737
|
+
function useOverridableProps(componentId) {
|
|
738
|
+
return (0, import_store19.__useSelector)((state) => {
|
|
739
|
+
if (!componentId) {
|
|
740
|
+
return void 0;
|
|
741
|
+
}
|
|
742
|
+
return selectOverridableProps(state, componentId);
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// src/components/component-properties-panel/properties-empty-state.tsx
|
|
380
747
|
var React = __toESM(require("react"));
|
|
381
|
-
var import_react2 = require("react");
|
|
382
748
|
var import_icons = require("@elementor/icons");
|
|
383
749
|
var import_ui = require("@elementor/ui");
|
|
384
|
-
var
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
const isFirstOverride = prevCount === 0 && overridesCount === 1;
|
|
750
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
751
|
+
var LEARN_MORE_URL = "https://go.elementor.com/tbd/";
|
|
752
|
+
function PropertiesEmptyState() {
|
|
388
753
|
return /* @__PURE__ */ React.createElement(
|
|
389
|
-
|
|
754
|
+
import_ui.Stack,
|
|
390
755
|
{
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
756
|
+
alignItems: "center",
|
|
757
|
+
justifyContent: "flex-start",
|
|
758
|
+
height: "100%",
|
|
759
|
+
color: "text.secondary",
|
|
760
|
+
sx: { px: 2.5, pt: 10, pb: 5.5 },
|
|
761
|
+
gap: 1
|
|
397
762
|
},
|
|
398
|
-
/* @__PURE__ */ React.createElement(
|
|
763
|
+
/* @__PURE__ */ React.createElement(import_icons.ComponentPropListIcon, { fontSize: "large" }),
|
|
764
|
+
/* @__PURE__ */ React.createElement(import_ui.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n2.__)("Add your first property", "elementor")),
|
|
765
|
+
/* @__PURE__ */ React.createElement(import_ui.Typography, { align: "center", variant: "caption" }, (0, import_i18n2.__)("Make instances flexible while keeping design synced.", "elementor")),
|
|
766
|
+
/* @__PURE__ */ React.createElement(import_ui.Typography, { align: "center", variant: "caption" }, (0, import_i18n2.__)("Select any element, then click + next to a setting to expose it.", "elementor")),
|
|
767
|
+
/* @__PURE__ */ React.createElement(
|
|
768
|
+
import_ui.Link,
|
|
769
|
+
{
|
|
770
|
+
variant: "caption",
|
|
771
|
+
color: "secondary",
|
|
772
|
+
href: LEARN_MORE_URL,
|
|
773
|
+
target: "_blank",
|
|
774
|
+
rel: "noopener noreferrer",
|
|
775
|
+
sx: { textDecorationLine: "underline" }
|
|
776
|
+
},
|
|
777
|
+
(0, import_i18n2.__)("Learn more", "elementor")
|
|
778
|
+
)
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// src/components/component-properties-panel/properties-group.tsx
|
|
783
|
+
var React5 = __toESM(require("react"));
|
|
784
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
785
|
+
var import_icons4 = require("@elementor/icons");
|
|
786
|
+
var import_ui5 = require("@elementor/ui");
|
|
787
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
788
|
+
|
|
789
|
+
// src/components/component-properties-panel/property-item.tsx
|
|
790
|
+
var React4 = __toESM(require("react"));
|
|
791
|
+
var import_editor_elements2 = require("@elementor/editor-elements");
|
|
792
|
+
var import_icons3 = require("@elementor/icons");
|
|
793
|
+
var import_ui4 = require("@elementor/ui");
|
|
794
|
+
|
|
795
|
+
// src/components/overridable-props/overridable-prop-form.tsx
|
|
796
|
+
var React2 = __toESM(require("react"));
|
|
797
|
+
var import_react2 = require("react");
|
|
798
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
799
|
+
var import_ui2 = require("@elementor/ui");
|
|
800
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
801
|
+
var SIZE = "tiny";
|
|
802
|
+
var DEFAULT_GROUP = { value: null, label: (0, import_i18n3.__)("Default", "elementor") };
|
|
803
|
+
function OverridablePropForm({ onSubmit, groups, currentValue, sx }) {
|
|
804
|
+
const [propLabel, setPropLabel] = (0, import_react2.useState)(currentValue?.label ?? null);
|
|
805
|
+
const [group, setGroup] = (0, import_react2.useState)(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
806
|
+
const name = (0, import_i18n3.__)("Name", "elementor");
|
|
807
|
+
const groupName = (0, import_i18n3.__)("Group Name", "elementor");
|
|
808
|
+
const isCreate = currentValue === void 0;
|
|
809
|
+
const title = isCreate ? (0, import_i18n3.__)("Create new property", "elementor") : (0, import_i18n3.__)("Update property", "elementor");
|
|
810
|
+
const ctaLabel = isCreate ? (0, import_i18n3.__)("Create", "elementor") : (0, import_i18n3.__)("Update", "elementor");
|
|
811
|
+
return /* @__PURE__ */ React2.createElement(import_editor_ui.Form, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React2.createElement(import_ui2.Stack, { alignItems: "start", sx: { width: "268px", ...sx } }, /* @__PURE__ */ React2.createElement(
|
|
812
|
+
import_ui2.Stack,
|
|
813
|
+
{
|
|
814
|
+
direction: "row",
|
|
815
|
+
alignItems: "center",
|
|
816
|
+
py: 1,
|
|
817
|
+
px: 1.5,
|
|
818
|
+
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
819
|
+
},
|
|
820
|
+
/* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
821
|
+
), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui2.FormLabel, { size: "tiny" }, name)), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
822
|
+
import_ui2.TextField,
|
|
823
|
+
{
|
|
824
|
+
name,
|
|
825
|
+
size: SIZE,
|
|
826
|
+
fullWidth: true,
|
|
827
|
+
placeholder: (0, import_i18n3.__)("Enter value", "elementor"),
|
|
828
|
+
value: propLabel ?? "",
|
|
829
|
+
onChange: (e) => setPropLabel(e.target.value)
|
|
830
|
+
}
|
|
831
|
+
))), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(import_ui2.FormLabel, { size: "tiny" }, groupName)), /* @__PURE__ */ React2.createElement(import_ui2.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
832
|
+
import_ui2.Select,
|
|
833
|
+
{
|
|
834
|
+
name: groupName,
|
|
835
|
+
size: SIZE,
|
|
836
|
+
fullWidth: true,
|
|
837
|
+
value: group ?? null,
|
|
838
|
+
onChange: (e) => setGroup(e.target.value),
|
|
839
|
+
displayEmpty: true,
|
|
840
|
+
renderValue: (selectedValue) => {
|
|
841
|
+
if (!selectedValue || selectedValue === "") {
|
|
842
|
+
const [firstGroup = DEFAULT_GROUP] = groups ?? [];
|
|
843
|
+
return firstGroup.label;
|
|
844
|
+
}
|
|
845
|
+
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React2.createElement(import_editor_ui.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
849
|
+
))), /* @__PURE__ */ React2.createElement(import_ui2.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React2.createElement(import_ui2.Button, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// src/components/component-properties-panel/sortable.tsx
|
|
853
|
+
var React3 = __toESM(require("react"));
|
|
854
|
+
var import_icons2 = require("@elementor/icons");
|
|
855
|
+
var import_ui3 = require("@elementor/ui");
|
|
856
|
+
var SortableProvider = (props) => /* @__PURE__ */ React3.createElement(import_ui3.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
857
|
+
var SortableTrigger = ({ triggerClassName, ...props }) => /* @__PURE__ */ React3.createElement(
|
|
858
|
+
StyledSortableTrigger,
|
|
859
|
+
{
|
|
860
|
+
...props,
|
|
861
|
+
role: "button",
|
|
862
|
+
className: `sortable-trigger ${triggerClassName ?? ""}`.trim(),
|
|
863
|
+
"aria-label": "sort"
|
|
864
|
+
},
|
|
865
|
+
/* @__PURE__ */ React3.createElement(import_icons2.GripVerticalIcon, { fontSize: "tiny" })
|
|
866
|
+
);
|
|
867
|
+
var SortableItem = ({ children, id: id2 }) => /* @__PURE__ */ React3.createElement(
|
|
868
|
+
import_ui3.UnstableSortableItem,
|
|
869
|
+
{
|
|
870
|
+
id: id2,
|
|
871
|
+
render: ({
|
|
872
|
+
itemProps,
|
|
873
|
+
isDragged,
|
|
874
|
+
triggerProps,
|
|
875
|
+
itemStyle,
|
|
876
|
+
triggerStyle,
|
|
877
|
+
dropIndicationStyle,
|
|
878
|
+
showDropIndication,
|
|
879
|
+
isDragOverlay,
|
|
880
|
+
isDragPlaceholder
|
|
881
|
+
}) => /* @__PURE__ */ React3.createElement(
|
|
882
|
+
import_ui3.Box,
|
|
883
|
+
{
|
|
884
|
+
...itemProps,
|
|
885
|
+
style: itemStyle,
|
|
886
|
+
component: "div",
|
|
887
|
+
role: "listitem",
|
|
888
|
+
sx: {
|
|
889
|
+
backgroundColor: isDragOverlay ? "background.paper" : void 0
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
children({
|
|
893
|
+
isDragged,
|
|
894
|
+
isDragPlaceholder,
|
|
895
|
+
triggerProps,
|
|
896
|
+
triggerStyle
|
|
897
|
+
}),
|
|
898
|
+
showDropIndication && /* @__PURE__ */ React3.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
899
|
+
)
|
|
900
|
+
}
|
|
901
|
+
);
|
|
902
|
+
var StyledSortableTrigger = (0, import_ui3.styled)("div")(({ theme }) => ({
|
|
903
|
+
position: "absolute",
|
|
904
|
+
left: 0,
|
|
905
|
+
top: "50%",
|
|
906
|
+
transform: `translate( -${theme.spacing(1.5)}, -50% )`,
|
|
907
|
+
color: theme.palette.action.active,
|
|
908
|
+
cursor: "grab"
|
|
909
|
+
}));
|
|
910
|
+
var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
|
|
911
|
+
width: 100%;
|
|
912
|
+
height: 1px;
|
|
913
|
+
background-color: ${({ theme }) => theme.palette.text.primary};
|
|
914
|
+
`;
|
|
915
|
+
|
|
916
|
+
// src/components/component-properties-panel/property-item.tsx
|
|
917
|
+
function PropertyItem({
|
|
918
|
+
prop,
|
|
919
|
+
sortableTriggerProps,
|
|
920
|
+
isDragPlaceholder,
|
|
921
|
+
groups,
|
|
922
|
+
onDelete,
|
|
923
|
+
onUpdate
|
|
924
|
+
}) {
|
|
925
|
+
const popoverState = (0, import_ui4.usePopupState)({
|
|
926
|
+
variant: "popover"
|
|
927
|
+
});
|
|
928
|
+
const icon = getElementIcon(prop);
|
|
929
|
+
const popoverProps = (0, import_ui4.bindPopover)(popoverState);
|
|
930
|
+
const handleSubmit = (data) => {
|
|
931
|
+
onUpdate(data);
|
|
932
|
+
popoverState.close();
|
|
933
|
+
};
|
|
934
|
+
const handleDelete = (event) => {
|
|
935
|
+
event.stopPropagation();
|
|
936
|
+
onDelete(prop.overrideKey);
|
|
937
|
+
};
|
|
938
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
|
|
939
|
+
import_ui4.Box,
|
|
940
|
+
{
|
|
941
|
+
...(0, import_ui4.bindTrigger)(popoverState),
|
|
942
|
+
sx: {
|
|
943
|
+
position: "relative",
|
|
944
|
+
pl: 0.5,
|
|
945
|
+
pr: 1,
|
|
946
|
+
py: 0.25,
|
|
947
|
+
minHeight: 28,
|
|
948
|
+
borderRadius: 1,
|
|
949
|
+
border: "1px solid",
|
|
950
|
+
borderColor: "divider",
|
|
951
|
+
display: "flex",
|
|
952
|
+
alignItems: "center",
|
|
953
|
+
gap: 0.5,
|
|
954
|
+
opacity: isDragPlaceholder ? 0.5 : 1,
|
|
955
|
+
cursor: "pointer",
|
|
956
|
+
"&:hover": {
|
|
957
|
+
backgroundColor: "action.hover"
|
|
958
|
+
},
|
|
959
|
+
"&:hover .sortable-trigger": {
|
|
960
|
+
visibility: "visible"
|
|
961
|
+
},
|
|
962
|
+
"& .sortable-trigger": {
|
|
963
|
+
visibility: "hidden"
|
|
964
|
+
},
|
|
965
|
+
"&:hover .delete-button": {
|
|
966
|
+
visibility: "visible"
|
|
967
|
+
},
|
|
968
|
+
"& .delete-button": {
|
|
969
|
+
visibility: "hidden"
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
/* @__PURE__ */ React4.createElement(SortableTrigger, { ...sortableTriggerProps }),
|
|
974
|
+
/* @__PURE__ */ React4.createElement(
|
|
975
|
+
import_ui4.Box,
|
|
976
|
+
{
|
|
977
|
+
sx: { display: "flex", alignItems: "center", color: "text.primary", fontSize: 12, padding: 0.25 }
|
|
978
|
+
},
|
|
979
|
+
/* @__PURE__ */ React4.createElement("i", { className: icon })
|
|
980
|
+
),
|
|
981
|
+
/* @__PURE__ */ React4.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary", flexGrow: 1, fontSize: 10 } }, prop.label),
|
|
982
|
+
/* @__PURE__ */ React4.createElement(import_ui4.IconButton, { size: "tiny", onClick: handleDelete, "aria-label": "Delete property", sx: { p: 0.25 } }, /* @__PURE__ */ React4.createElement(import_icons3.XIcon, { fontSize: "tiny" }))
|
|
983
|
+
), /* @__PURE__ */ React4.createElement(
|
|
984
|
+
import_ui4.Popover,
|
|
985
|
+
{
|
|
986
|
+
...popoverProps,
|
|
987
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
988
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
989
|
+
PaperProps: { sx: { width: popoverState.anchorEl?.getBoundingClientRect().width } }
|
|
990
|
+
},
|
|
991
|
+
/* @__PURE__ */ React4.createElement(
|
|
992
|
+
OverridablePropForm,
|
|
993
|
+
{
|
|
994
|
+
onSubmit: handleSubmit,
|
|
995
|
+
currentValue: prop,
|
|
996
|
+
groups,
|
|
997
|
+
sx: { width: "100%" }
|
|
998
|
+
}
|
|
999
|
+
)
|
|
1000
|
+
));
|
|
1001
|
+
}
|
|
1002
|
+
function getElementIcon(prop) {
|
|
1003
|
+
const elType = prop.elType === "widget" ? prop.widgetType : prop.elType;
|
|
1004
|
+
const widgetsCache = (0, import_editor_elements2.getWidgetsCache)();
|
|
1005
|
+
if (!widgetsCache) {
|
|
1006
|
+
return "eicon-apps";
|
|
1007
|
+
}
|
|
1008
|
+
const widgetConfig = widgetsCache[elType];
|
|
1009
|
+
return widgetConfig?.icon || "eicon-apps";
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/components/component-properties-panel/properties-group.tsx
|
|
1013
|
+
function PropertiesGroup({
|
|
1014
|
+
group,
|
|
1015
|
+
props,
|
|
1016
|
+
allGroups,
|
|
1017
|
+
sortableTriggerProps,
|
|
1018
|
+
isDragPlaceholder,
|
|
1019
|
+
onPropsReorder,
|
|
1020
|
+
onPropertyDelete,
|
|
1021
|
+
onPropertyUpdate,
|
|
1022
|
+
onGroupDelete,
|
|
1023
|
+
editableLabelProps
|
|
1024
|
+
}) {
|
|
1025
|
+
const groupProps = group.props.map((propId) => props[propId]).filter((prop) => Boolean(prop));
|
|
1026
|
+
const popupState = (0, import_ui5.usePopupState)({
|
|
1027
|
+
variant: "popover",
|
|
1028
|
+
disableAutoFocus: true
|
|
1029
|
+
});
|
|
1030
|
+
const { editableRef, isEditing, error, getEditableProps, setEditingGroupId, editingGroupId } = editableLabelProps;
|
|
1031
|
+
const hasProperties = group.props.length > 0;
|
|
1032
|
+
const isThisGroupEditing = isEditing && editingGroupId === group.id;
|
|
1033
|
+
const handleRenameClick = () => {
|
|
1034
|
+
popupState.close();
|
|
1035
|
+
setEditingGroupId(group.id);
|
|
1036
|
+
};
|
|
1037
|
+
const handleDeleteClick = () => {
|
|
1038
|
+
popupState.close();
|
|
1039
|
+
onGroupDelete(group.id);
|
|
1040
|
+
};
|
|
1041
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1042
|
+
import_ui5.Box,
|
|
1043
|
+
{
|
|
1044
|
+
sx: {
|
|
1045
|
+
opacity: isDragPlaceholder ? 0.5 : 1
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
/* @__PURE__ */ React5.createElement(import_ui5.Stack, { gap: 1 }, /* @__PURE__ */ React5.createElement(
|
|
1049
|
+
import_ui5.Box,
|
|
1050
|
+
{
|
|
1051
|
+
className: "group-header",
|
|
1052
|
+
sx: {
|
|
1053
|
+
position: "relative",
|
|
1054
|
+
"&:hover .group-sortable-trigger": {
|
|
1055
|
+
visibility: "visible"
|
|
1056
|
+
},
|
|
1057
|
+
"& .group-sortable-trigger": {
|
|
1058
|
+
visibility: "hidden"
|
|
1059
|
+
},
|
|
1060
|
+
"&:hover .group-menu": {
|
|
1061
|
+
visibility: "visible"
|
|
1062
|
+
},
|
|
1063
|
+
"& .group-menu": {
|
|
1064
|
+
visibility: "hidden"
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
/* @__PURE__ */ React5.createElement(SortableTrigger, { triggerClassName: "group-sortable-trigger", ...sortableTriggerProps }),
|
|
1069
|
+
/* @__PURE__ */ React5.createElement(import_ui5.Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 2 }, isThisGroupEditing ? /* @__PURE__ */ React5.createElement(
|
|
1070
|
+
import_ui5.Box,
|
|
1071
|
+
{
|
|
1072
|
+
sx: {
|
|
1073
|
+
flex: 1,
|
|
1074
|
+
height: 28,
|
|
1075
|
+
display: "flex",
|
|
1076
|
+
alignItems: "center",
|
|
1077
|
+
border: 2,
|
|
1078
|
+
borderColor: "text.secondary",
|
|
1079
|
+
borderRadius: 1,
|
|
1080
|
+
pl: 0.5
|
|
1081
|
+
}
|
|
1082
|
+
},
|
|
1083
|
+
/* @__PURE__ */ React5.createElement(
|
|
1084
|
+
import_editor_ui2.EditableField,
|
|
1085
|
+
{
|
|
1086
|
+
ref: editableRef,
|
|
1087
|
+
as: import_ui5.Typography,
|
|
1088
|
+
variant: "caption",
|
|
1089
|
+
error: error ?? void 0,
|
|
1090
|
+
sx: { color: "text.primary", fontWeight: 400, lineHeight: 1.66 },
|
|
1091
|
+
...getEditableProps()
|
|
1092
|
+
}
|
|
1093
|
+
)
|
|
1094
|
+
) : /* @__PURE__ */ React5.createElement(
|
|
1095
|
+
import_ui5.Typography,
|
|
1096
|
+
{
|
|
1097
|
+
variant: "caption",
|
|
1098
|
+
sx: { color: "text.primary", fontWeight: 400, lineHeight: 1.66 }
|
|
1099
|
+
},
|
|
1100
|
+
group.label
|
|
1101
|
+
), /* @__PURE__ */ React5.createElement(
|
|
1102
|
+
import_ui5.IconButton,
|
|
1103
|
+
{
|
|
1104
|
+
className: "group-menu",
|
|
1105
|
+
size: "tiny",
|
|
1106
|
+
sx: { p: 0.25, visibility: isThisGroupEditing ? "visible" : void 0 },
|
|
1107
|
+
"aria-label": (0, import_i18n4.__)("Group actions", "elementor"),
|
|
1108
|
+
...(0, import_ui5.bindTrigger)(popupState)
|
|
1109
|
+
},
|
|
1110
|
+
/* @__PURE__ */ React5.createElement(import_icons4.DotsVerticalIcon, { fontSize: "tiny" })
|
|
1111
|
+
))
|
|
1112
|
+
), /* @__PURE__ */ React5.createElement(import_ui5.List, { sx: { p: 0, display: "flex", flexDirection: "column", gap: 1 } }, /* @__PURE__ */ React5.createElement(SortableProvider, { value: group.props, onChange: onPropsReorder }, groupProps.map((prop) => /* @__PURE__ */ React5.createElement(SortableItem, { key: prop.overrideKey, id: prop.overrideKey }, ({ triggerProps, triggerStyle, isDragPlaceholder: isItemDragPlaceholder }) => /* @__PURE__ */ React5.createElement(
|
|
1113
|
+
PropertyItem,
|
|
1114
|
+
{
|
|
1115
|
+
prop,
|
|
1116
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle },
|
|
1117
|
+
isDragPlaceholder: isItemDragPlaceholder,
|
|
1118
|
+
groups: allGroups,
|
|
1119
|
+
onDelete: onPropertyDelete,
|
|
1120
|
+
onUpdate: (data) => onPropertyUpdate(prop.overrideKey, data)
|
|
1121
|
+
}
|
|
1122
|
+
)))))),
|
|
1123
|
+
/* @__PURE__ */ React5.createElement(
|
|
1124
|
+
import_ui5.Menu,
|
|
1125
|
+
{
|
|
1126
|
+
...(0, import_ui5.bindMenu)(popupState),
|
|
1127
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1128
|
+
transformOrigin: { vertical: "top", horizontal: "right" }
|
|
1129
|
+
},
|
|
1130
|
+
/* @__PURE__ */ React5.createElement(import_editor_ui2.MenuListItem, { sx: { minWidth: "160px" }, onClick: handleRenameClick }, /* @__PURE__ */ React5.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n4.__)("Rename", "elementor"))),
|
|
1131
|
+
/* @__PURE__ */ React5.createElement(
|
|
1132
|
+
import_ui5.Tooltip,
|
|
1133
|
+
{
|
|
1134
|
+
title: hasProperties ? (0, import_i18n4.__)("To delete the group, first remove all the properties", "elementor") : "",
|
|
1135
|
+
placement: "right"
|
|
1136
|
+
},
|
|
1137
|
+
/* @__PURE__ */ React5.createElement("span", null, /* @__PURE__ */ React5.createElement(import_editor_ui2.MenuListItem, { onClick: handleDeleteClick, disabled: hasProperties }, /* @__PURE__ */ React5.createElement(
|
|
1138
|
+
import_ui5.Typography,
|
|
1139
|
+
{
|
|
1140
|
+
variant: "caption",
|
|
1141
|
+
sx: { color: hasProperties ? "text.disabled" : "error.light" }
|
|
1142
|
+
},
|
|
1143
|
+
(0, import_i18n4.__)("Delete", "elementor")
|
|
1144
|
+
)))
|
|
1145
|
+
)
|
|
1146
|
+
)
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// src/components/component-properties-panel/use-current-editable-item.ts
|
|
1151
|
+
var import_react3 = require("react");
|
|
1152
|
+
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
1153
|
+
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
1154
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
1155
|
+
|
|
1156
|
+
// src/store/actions/rename-overridable-group.ts
|
|
1157
|
+
var import_store21 = require("@elementor/store");
|
|
1158
|
+
function renameOverridableGroup({ componentId, groupId, label }) {
|
|
1159
|
+
const overridableProps = selectOverridableProps((0, import_store21.__getState)(), componentId);
|
|
1160
|
+
if (!overridableProps) {
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1163
|
+
const group = overridableProps.groups.items[groupId];
|
|
1164
|
+
if (!group) {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
const updatedGroups = renameGroup(overridableProps.groups, groupId, label);
|
|
1168
|
+
(0, import_store21.__dispatch)(
|
|
1169
|
+
slice.actions.setOverridableProps({
|
|
1170
|
+
componentId,
|
|
1171
|
+
overridableProps: {
|
|
1172
|
+
...overridableProps,
|
|
1173
|
+
groups: updatedGroups
|
|
1174
|
+
}
|
|
1175
|
+
})
|
|
1176
|
+
);
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/components/component-properties-panel/utils/validate-group-label.ts
|
|
1181
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
1182
|
+
var ERROR_MESSAGES = {
|
|
1183
|
+
EMPTY_NAME: (0, import_i18n5.__)("Group name is required", "elementor"),
|
|
1184
|
+
DUPLICATE_NAME: (0, import_i18n5.__)("Group name already exists", "elementor")
|
|
1185
|
+
};
|
|
1186
|
+
function validateGroupLabel(label, existingGroups) {
|
|
1187
|
+
const trimmedLabel = label.trim();
|
|
1188
|
+
if (!trimmedLabel) {
|
|
1189
|
+
return ERROR_MESSAGES.EMPTY_NAME;
|
|
1190
|
+
}
|
|
1191
|
+
const isDuplicate = Object.values(existingGroups).some((group) => group.label === trimmedLabel);
|
|
1192
|
+
if (isDuplicate) {
|
|
1193
|
+
return ERROR_MESSAGES.DUPLICATE_NAME;
|
|
1194
|
+
}
|
|
1195
|
+
return "";
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// src/components/component-properties-panel/use-current-editable-item.ts
|
|
1199
|
+
function useCurrentEditableItem() {
|
|
1200
|
+
const [editingGroupId, setEditingGroupId] = (0, import_react3.useState)(null);
|
|
1201
|
+
const currentComponentId = useCurrentComponentId();
|
|
1202
|
+
const overridableProps = useOverridableProps(currentComponentId);
|
|
1203
|
+
const allGroupsRecord = overridableProps?.groups?.items ?? {};
|
|
1204
|
+
const currentGroup = editingGroupId ? allGroupsRecord[editingGroupId] : null;
|
|
1205
|
+
const validateLabel = (newLabel) => {
|
|
1206
|
+
const otherGroups = Object.fromEntries(
|
|
1207
|
+
Object.entries(allGroupsRecord).filter(([id2]) => id2 !== editingGroupId)
|
|
1208
|
+
);
|
|
1209
|
+
return validateGroupLabel(newLabel, otherGroups) || null;
|
|
1210
|
+
};
|
|
1211
|
+
const handleSubmit = (newLabel) => {
|
|
1212
|
+
if (!editingGroupId || !currentComponentId) {
|
|
1213
|
+
throw new Error((0, import_i18n6.__)("Group ID or component ID is missing", "elementor"));
|
|
1214
|
+
}
|
|
1215
|
+
renameOverridableGroup({
|
|
1216
|
+
componentId: currentComponentId,
|
|
1217
|
+
groupId: editingGroupId,
|
|
1218
|
+
label: newLabel
|
|
1219
|
+
});
|
|
1220
|
+
(0, import_editor_documents3.setDocumentModifiedStatus)(true);
|
|
1221
|
+
};
|
|
1222
|
+
const {
|
|
1223
|
+
ref: editableRef,
|
|
1224
|
+
openEditMode,
|
|
1225
|
+
isEditing,
|
|
1226
|
+
error,
|
|
1227
|
+
getProps: getEditableProps
|
|
1228
|
+
} = (0, import_editor_ui3.useEditable)({
|
|
1229
|
+
value: currentGroup?.label ?? "",
|
|
1230
|
+
onSubmit: handleSubmit,
|
|
1231
|
+
validation: validateLabel
|
|
1232
|
+
});
|
|
1233
|
+
return {
|
|
1234
|
+
editableRef,
|
|
1235
|
+
isEditing,
|
|
1236
|
+
error,
|
|
1237
|
+
getEditableProps,
|
|
1238
|
+
setEditingGroupId: (groupId) => {
|
|
1239
|
+
setEditingGroupId(groupId);
|
|
1240
|
+
openEditMode();
|
|
1241
|
+
},
|
|
1242
|
+
editingGroupId
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// src/components/component-properties-panel/utils/generate-unique-label.ts
|
|
1247
|
+
var DEFAULT_NEW_GROUP_LABEL = "New group";
|
|
1248
|
+
function generateUniqueLabel(groups) {
|
|
1249
|
+
const existingLabels = new Set(groups.map((group) => group.label));
|
|
1250
|
+
if (!existingLabels.has(DEFAULT_NEW_GROUP_LABEL)) {
|
|
1251
|
+
return DEFAULT_NEW_GROUP_LABEL;
|
|
1252
|
+
}
|
|
1253
|
+
let index = 1;
|
|
1254
|
+
let newLabel = `${DEFAULT_NEW_GROUP_LABEL}-${index}`;
|
|
1255
|
+
while (existingLabels.has(newLabel)) {
|
|
1256
|
+
index++;
|
|
1257
|
+
newLabel = `${DEFAULT_NEW_GROUP_LABEL}-${index}`;
|
|
1258
|
+
}
|
|
1259
|
+
return newLabel;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// src/components/component-properties-panel/component-properties-panel-content.tsx
|
|
1263
|
+
function ComponentPropertiesPanelContent({ onClose }) {
|
|
1264
|
+
const currentComponentId = useCurrentComponentId();
|
|
1265
|
+
const overridableProps = useOverridableProps(currentComponentId);
|
|
1266
|
+
const [isAddingGroup, setIsAddingGroup] = (0, import_react4.useState)(false);
|
|
1267
|
+
const groupLabelEditable = useCurrentEditableItem();
|
|
1268
|
+
const groups = (0, import_react4.useMemo)(() => {
|
|
1269
|
+
if (!overridableProps) {
|
|
1270
|
+
return [];
|
|
1271
|
+
}
|
|
1272
|
+
return overridableProps.groups.order.map((groupId) => overridableProps.groups.items[groupId] ?? null).filter(Boolean);
|
|
1273
|
+
}, [overridableProps]);
|
|
1274
|
+
const allGroupsForSelect = (0, import_react4.useMemo)(
|
|
1275
|
+
() => groups.map((group) => ({ value: group.id, label: group.label })),
|
|
1276
|
+
[groups]
|
|
1277
|
+
);
|
|
1278
|
+
if (!currentComponentId || !overridableProps) {
|
|
1279
|
+
return null;
|
|
1280
|
+
}
|
|
1281
|
+
const hasGroups = groups.length > 0;
|
|
1282
|
+
const showEmptyState = !hasGroups && !isAddingGroup;
|
|
1283
|
+
const groupIds = overridableProps.groups.order;
|
|
1284
|
+
const handleAddGroupClick = () => {
|
|
1285
|
+
if (isAddingGroup) {
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
const newGroupId = (0, import_utils2.generateUniqueId)("group");
|
|
1289
|
+
const newLabel = generateUniqueLabel(groups);
|
|
1290
|
+
addOverridableGroup({ componentId: currentComponentId, groupId: newGroupId, label: newLabel });
|
|
1291
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
1292
|
+
setIsAddingGroup(false);
|
|
1293
|
+
groupLabelEditable.setEditingGroupId(newGroupId);
|
|
1294
|
+
};
|
|
1295
|
+
const handleGroupsReorder = (newOrder) => {
|
|
1296
|
+
reorderOverridableGroups({ componentId: currentComponentId, newOrder });
|
|
1297
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
1298
|
+
};
|
|
1299
|
+
const handlePropsReorder = (groupId, newPropsOrder) => {
|
|
1300
|
+
reorderGroupProps({ componentId: currentComponentId, groupId, newPropsOrder });
|
|
1301
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
1302
|
+
};
|
|
1303
|
+
const handlePropertyDelete = (propKey) => {
|
|
1304
|
+
deleteOverridableProp({ componentId: currentComponentId, propKey });
|
|
1305
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
1306
|
+
};
|
|
1307
|
+
const handlePropertyUpdate = (propKey, data) => {
|
|
1308
|
+
updateOverridableProp({
|
|
1309
|
+
componentId: currentComponentId,
|
|
1310
|
+
propKey,
|
|
1311
|
+
label: data.label,
|
|
1312
|
+
groupId: data.group
|
|
1313
|
+
});
|
|
1314
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
1315
|
+
};
|
|
1316
|
+
const handleGroupDelete = (groupId) => {
|
|
1317
|
+
deleteOverridableGroup({ componentId: currentComponentId, groupId });
|
|
1318
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
1319
|
+
};
|
|
1320
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeader, { sx: { justifyContent: "start", pl: 1.5, pr: 1, py: 1 } }, /* @__PURE__ */ React6.createElement(import_ui6.Stack, { direction: "row", alignItems: "center", gap: 0.5, flexGrow: 1 }, /* @__PURE__ */ React6.createElement(import_icons5.ComponentPropListIcon, { fontSize: "tiny" }), /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeaderTitle, { variant: "subtitle2" }, (0, import_i18n7.__)("Component properties", "elementor"))), !showEmptyState && /* @__PURE__ */ React6.createElement(import_ui6.Tooltip, { title: (0, import_i18n7.__)("Add new group", "elementor") }, /* @__PURE__ */ React6.createElement(
|
|
1321
|
+
import_ui6.IconButton,
|
|
1322
|
+
{
|
|
1323
|
+
size: "tiny",
|
|
1324
|
+
"aria-label": (0, import_i18n7.__)("Add new group", "elementor"),
|
|
1325
|
+
onClick: handleAddGroupClick
|
|
1326
|
+
},
|
|
1327
|
+
/* @__PURE__ */ React6.createElement(import_icons5.FolderPlusIcon, { fontSize: "tiny" })
|
|
1328
|
+
)), /* @__PURE__ */ React6.createElement(import_ui6.Tooltip, { title: (0, import_i18n7.__)("Close panel", "elementor") }, /* @__PURE__ */ React6.createElement(import_ui6.IconButton, { size: "tiny", "aria-label": (0, import_i18n7.__)("Close panel", "elementor"), onClick: onClose }, /* @__PURE__ */ React6.createElement(import_icons5.XIcon, { fontSize: "tiny" })))), /* @__PURE__ */ React6.createElement(import_ui6.Divider, null), /* @__PURE__ */ React6.createElement(import_editor_panels.PanelBody, null, showEmptyState ? /* @__PURE__ */ React6.createElement(PropertiesEmptyState, null) : /* @__PURE__ */ React6.createElement(import_ui6.List, { sx: { p: 2, display: "flex", flexDirection: "column", gap: 2 } }, /* @__PURE__ */ React6.createElement(SortableProvider, { value: groupIds, onChange: handleGroupsReorder }, groups.map((group) => /* @__PURE__ */ React6.createElement(SortableItem, { key: group.id, id: group.id }, ({ triggerProps, triggerStyle, isDragPlaceholder }) => /* @__PURE__ */ React6.createElement(
|
|
1329
|
+
PropertiesGroup,
|
|
1330
|
+
{
|
|
1331
|
+
group,
|
|
1332
|
+
props: overridableProps.props,
|
|
1333
|
+
allGroups: allGroupsForSelect,
|
|
1334
|
+
allGroupsRecord: overridableProps.groups.items,
|
|
1335
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle },
|
|
1336
|
+
isDragPlaceholder,
|
|
1337
|
+
setIsAddingGroup,
|
|
1338
|
+
onPropsReorder: (newOrder) => handlePropsReorder(group.id, newOrder),
|
|
1339
|
+
onPropertyDelete: handlePropertyDelete,
|
|
1340
|
+
onPropertyUpdate: handlePropertyUpdate,
|
|
1341
|
+
editableLabelProps: groupLabelEditable,
|
|
1342
|
+
onGroupDelete: handleGroupDelete
|
|
1343
|
+
}
|
|
1344
|
+
)))))));
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// src/components/component-properties-panel/component-properties-panel.tsx
|
|
1348
|
+
var id = "component-properties-panel";
|
|
1349
|
+
var { panel, usePanelActions } = (0, import_editor_panels2.__createPanel)({
|
|
1350
|
+
id,
|
|
1351
|
+
component: ComponentPropertiesPanel
|
|
1352
|
+
});
|
|
1353
|
+
function ComponentPropertiesPanel() {
|
|
1354
|
+
const { element, elementType } = (0, import_editor_elements3.useSelectedElement)();
|
|
1355
|
+
const { close: closePanel } = usePanelActions();
|
|
1356
|
+
const { open: openEditingPanel } = (0, import_editor_editing_panel.usePanelActions)();
|
|
1357
|
+
if (!element || !elementType) {
|
|
1358
|
+
return null;
|
|
1359
|
+
}
|
|
1360
|
+
return /* @__PURE__ */ React7.createElement(import_editor_ui4.ThemeProvider, null, /* @__PURE__ */ React7.createElement(import_ui7.ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(import_editor_editing_panel.ElementProvider, { element, elementType }, /* @__PURE__ */ React7.createElement(import_editor_panels2.Panel, null, /* @__PURE__ */ React7.createElement(
|
|
1361
|
+
ComponentPropertiesPanelContent,
|
|
1362
|
+
{
|
|
1363
|
+
onClose: () => {
|
|
1364
|
+
closePanel();
|
|
1365
|
+
openEditingPanel();
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
)))));
|
|
1369
|
+
}
|
|
1370
|
+
var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(import_ui7.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(import_ui7.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, (0, import_i18n8.__)("Something went wrong", "elementor"))));
|
|
1371
|
+
|
|
1372
|
+
// src/components/components-tab/component-introduction.tsx
|
|
1373
|
+
var React8 = __toESM(require("react"));
|
|
1374
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
1375
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
1376
|
+
var import_ui8 = require("@elementor/ui");
|
|
1377
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
1378
|
+
var ComponentIntroduction = ({
|
|
1379
|
+
anchorRef,
|
|
1380
|
+
shouldShowIntroduction,
|
|
1381
|
+
onClose
|
|
1382
|
+
}) => {
|
|
1383
|
+
if (!anchorRef.current || !shouldShowIntroduction) {
|
|
1384
|
+
return null;
|
|
1385
|
+
}
|
|
1386
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1387
|
+
import_ui8.Popover,
|
|
1388
|
+
{
|
|
1389
|
+
anchorEl: anchorRef.current,
|
|
1390
|
+
open: shouldShowIntroduction,
|
|
1391
|
+
anchorOrigin: {
|
|
1392
|
+
vertical: "top",
|
|
1393
|
+
horizontal: "right"
|
|
1394
|
+
},
|
|
1395
|
+
transformOrigin: {
|
|
1396
|
+
vertical: "top",
|
|
1397
|
+
horizontal: -30
|
|
1398
|
+
},
|
|
1399
|
+
onClose
|
|
1400
|
+
},
|
|
1401
|
+
/* @__PURE__ */ React8.createElement(import_ui8.Box, { sx: { width: "296px" } }, /* @__PURE__ */ React8.createElement(import_editor_ui5.PopoverHeader, { title: (0, import_i18n9.__)("Add your first property", "elementor"), onClose }), /* @__PURE__ */ React8.createElement(
|
|
1402
|
+
import_ui8.Image,
|
|
1403
|
+
{
|
|
1404
|
+
sx: { width: "296px", height: "160px" },
|
|
1405
|
+
src: "https://assets.elementor.com/packages/v1/images/components-properties-intro.png",
|
|
1406
|
+
alt: ""
|
|
1407
|
+
}
|
|
1408
|
+
), /* @__PURE__ */ React8.createElement(import_editor_controls.PopoverContent, null, /* @__PURE__ */ React8.createElement(import_ui8.Stack, { gap: 1, sx: { p: 2 } }, /* @__PURE__ */ React8.createElement(import_ui8.Typography, { variant: "body2" }, (0, import_i18n9.__)("Properties make instances flexible.", "elementor")), /* @__PURE__ */ React8.createElement(import_ui8.Typography, { variant: "body2" }, (0, import_i18n9.__)(
|
|
1409
|
+
"Click next to any setting you want users to customize - like text, images, or links.",
|
|
1410
|
+
"elementor"
|
|
1411
|
+
)), /* @__PURE__ */ React8.createElement(import_ui8.Typography, { variant: "body2" }, (0, import_i18n9.__)(
|
|
1412
|
+
"Your properties will appear in the Properties panel, where you can organize and manage them anytime.",
|
|
1413
|
+
"elementor"
|
|
1414
|
+
)), /* @__PURE__ */ React8.createElement(import_ui8.Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end" }, /* @__PURE__ */ React8.createElement(import_ui8.Button, { size: "medium", variant: "contained", onClick: onClose }, (0, import_i18n9.__)("Got it", "elementor"))))))
|
|
399
1415
|
);
|
|
400
1416
|
};
|
|
401
|
-
|
|
1417
|
+
|
|
1418
|
+
// src/components/component-panel-header/component-badge.tsx
|
|
1419
|
+
var React9 = __toESM(require("react"));
|
|
1420
|
+
var import_react5 = require("react");
|
|
1421
|
+
var import_icons6 = require("@elementor/icons");
|
|
1422
|
+
var import_ui9 = require("@elementor/ui");
|
|
1423
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
1424
|
+
var ComponentsBadge = React9.forwardRef(
|
|
1425
|
+
({ overridesCount, onClick }, ref) => {
|
|
1426
|
+
const prevCount = usePrevious(overridesCount);
|
|
1427
|
+
const isFirstOverride = prevCount === 0 && overridesCount === 1;
|
|
1428
|
+
return /* @__PURE__ */ React9.createElement(
|
|
1429
|
+
StyledBadge,
|
|
1430
|
+
{
|
|
1431
|
+
ref,
|
|
1432
|
+
color: "primary",
|
|
1433
|
+
key: overridesCount,
|
|
1434
|
+
invisible: overridesCount === 0,
|
|
1435
|
+
animate: isFirstOverride,
|
|
1436
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
1437
|
+
badgeContent: /* @__PURE__ */ React9.createElement(import_ui9.Box, { sx: { animation: !isFirstOverride ? `${slideUp} 300ms ease-out` : "none" } }, overridesCount)
|
|
1438
|
+
},
|
|
1439
|
+
/* @__PURE__ */ React9.createElement(
|
|
1440
|
+
import_ui9.ToggleButton,
|
|
1441
|
+
{
|
|
1442
|
+
value: "overrides",
|
|
1443
|
+
size: "tiny",
|
|
1444
|
+
onClick,
|
|
1445
|
+
"aria-label": (0, import_i18n10.__)("View overrides", "elementor")
|
|
1446
|
+
},
|
|
1447
|
+
/* @__PURE__ */ React9.createElement(import_icons6.ComponentPropListIcon, { fontSize: "tiny" })
|
|
1448
|
+
)
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
);
|
|
1452
|
+
var StyledBadge = (0, import_ui9.styled)(import_ui9.Badge, { shouldForwardProp: (prop) => prop !== "animate" })(
|
|
402
1453
|
({ theme, animate }) => ({
|
|
403
1454
|
"& .MuiBadge-badge": {
|
|
404
1455
|
minWidth: theme.spacing(2),
|
|
@@ -411,88 +1462,93 @@ var StyledBadge = (0, import_ui.styled)(import_ui.Badge, { shouldForwardProp: (p
|
|
|
411
1462
|
})
|
|
412
1463
|
);
|
|
413
1464
|
function usePrevious(value) {
|
|
414
|
-
const ref = (0,
|
|
415
|
-
(0,
|
|
1465
|
+
const ref = (0, import_react5.useRef)(value);
|
|
1466
|
+
(0, import_react5.useEffect)(() => {
|
|
416
1467
|
ref.current = value;
|
|
417
1468
|
}, [value]);
|
|
418
1469
|
return ref.current;
|
|
419
1470
|
}
|
|
420
|
-
var bounceIn =
|
|
1471
|
+
var bounceIn = import_ui9.keyframes`
|
|
421
1472
|
0% { transform: scale(0) translate(50%, 50%); opacity: 0; }
|
|
422
1473
|
70% { transform: scale(1.1) translate(50%, -50%); opacity: 1; }
|
|
423
1474
|
100% { transform: scale(1) translate(50%, -50%); opacity: 1; }
|
|
424
1475
|
`;
|
|
425
|
-
var slideUp =
|
|
1476
|
+
var slideUp = import_ui9.keyframes`
|
|
426
1477
|
from { transform: translateY(100%); opacity: 0; }
|
|
427
1478
|
to { transform: translateY(0); opacity: 1; }
|
|
428
1479
|
`;
|
|
429
1480
|
|
|
430
|
-
// src/components/component-panel-header/use-overridable-props.ts
|
|
431
|
-
var import_store7 = require("@elementor/store");
|
|
432
|
-
function useOverridableProps(componentId) {
|
|
433
|
-
return (0, import_store7.__useSelector)((state) => {
|
|
434
|
-
if (!componentId) {
|
|
435
|
-
return void 0;
|
|
436
|
-
}
|
|
437
|
-
return selectOverridableProps(state, componentId);
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
|
|
441
1481
|
// src/components/component-panel-header/component-panel-header.tsx
|
|
1482
|
+
var MESSAGE_KEY = "components-properties-introduction";
|
|
442
1483
|
var ComponentPanelHeader = () => {
|
|
443
1484
|
const currentComponentId = useCurrentComponentId();
|
|
444
1485
|
const overridableProps = useOverridableProps(currentComponentId);
|
|
445
1486
|
const onBack = useNavigateBack();
|
|
446
1487
|
const componentName = getComponentName();
|
|
1488
|
+
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user.useSuppressedMessage)(MESSAGE_KEY);
|
|
1489
|
+
const [shouldShowIntroduction, setShouldShowIntroduction] = React10.useState(!isMessageSuppressed);
|
|
1490
|
+
const { open: openPropertiesPanel } = usePanelActions();
|
|
447
1491
|
const overridesCount = overridableProps ? Object.keys(overridableProps.props).length : 0;
|
|
1492
|
+
const anchorRef = React10.useRef(null);
|
|
448
1493
|
if (!currentComponentId) {
|
|
449
1494
|
return null;
|
|
450
1495
|
}
|
|
451
|
-
|
|
452
|
-
|
|
1496
|
+
const handleCloseIntroduction = () => {
|
|
1497
|
+
suppressMessage();
|
|
1498
|
+
setShouldShowIntroduction(false);
|
|
1499
|
+
};
|
|
1500
|
+
return /* @__PURE__ */ React10.createElement(import_ui10.Box, null, /* @__PURE__ */ React10.createElement(
|
|
1501
|
+
import_ui10.Stack,
|
|
453
1502
|
{
|
|
454
1503
|
direction: "row",
|
|
455
1504
|
alignItems: "center",
|
|
456
1505
|
justifyContent: "space-between",
|
|
457
1506
|
sx: { height: 48, pl: 1.5, pr: 2, py: 1 }
|
|
458
1507
|
},
|
|
459
|
-
/* @__PURE__ */
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
), /* @__PURE__ */
|
|
1508
|
+
/* @__PURE__ */ React10.createElement(import_ui10.Stack, { direction: "row", alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui10.Tooltip, { title: (0, import_i18n11.__)("Back", "elementor") }, /* @__PURE__ */ React10.createElement(import_ui10.IconButton, { size: "tiny", onClick: onBack, "aria-label": (0, import_i18n11.__)("Back", "elementor") }, /* @__PURE__ */ React10.createElement(import_icons7.ArrowLeftIcon, { fontSize: "tiny" }))), /* @__PURE__ */ React10.createElement(import_ui10.Stack, { direction: "row", alignItems: "center", gap: 0.5 }, /* @__PURE__ */ React10.createElement(import_icons7.ComponentsFilledIcon, { fontSize: "tiny", stroke: "currentColor" }), /* @__PURE__ */ React10.createElement(import_ui10.Typography, { variant: "caption", sx: { fontWeight: 500 } }, componentName))),
|
|
1509
|
+
/* @__PURE__ */ React10.createElement(ComponentsBadge, { overridesCount, ref: anchorRef, onClick: openPropertiesPanel })
|
|
1510
|
+
), /* @__PURE__ */ React10.createElement(import_ui10.Divider, null), /* @__PURE__ */ React10.createElement(
|
|
1511
|
+
ComponentIntroduction,
|
|
1512
|
+
{
|
|
1513
|
+
anchorRef,
|
|
1514
|
+
shouldShowIntroduction,
|
|
1515
|
+
onClose: handleCloseIntroduction
|
|
1516
|
+
}
|
|
1517
|
+
));
|
|
462
1518
|
};
|
|
463
1519
|
function getComponentName() {
|
|
464
|
-
const documentsManager = (0,
|
|
1520
|
+
const documentsManager = (0, import_editor_documents5.getV1DocumentsManager)();
|
|
465
1521
|
const currentDocument = documentsManager.getCurrent();
|
|
466
1522
|
return currentDocument?.container?.settings?.get("post_title") ?? "";
|
|
467
1523
|
}
|
|
468
1524
|
|
|
469
1525
|
// src/components/components-tab/components.tsx
|
|
470
|
-
var
|
|
471
|
-
var
|
|
1526
|
+
var React16 = __toESM(require("react"));
|
|
1527
|
+
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
472
1528
|
|
|
473
1529
|
// src/components/components-tab/component-search.tsx
|
|
474
|
-
var
|
|
475
|
-
var
|
|
476
|
-
var
|
|
477
|
-
var
|
|
1530
|
+
var React12 = __toESM(require("react"));
|
|
1531
|
+
var import_icons8 = require("@elementor/icons");
|
|
1532
|
+
var import_ui11 = require("@elementor/ui");
|
|
1533
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
478
1534
|
|
|
479
1535
|
// src/components/components-tab/search-provider.tsx
|
|
480
|
-
var
|
|
481
|
-
var
|
|
482
|
-
var
|
|
483
|
-
var SearchContext = (0,
|
|
1536
|
+
var React11 = __toESM(require("react"));
|
|
1537
|
+
var import_react6 = require("react");
|
|
1538
|
+
var import_utils3 = require("@elementor/utils");
|
|
1539
|
+
var SearchContext = (0, import_react6.createContext)(void 0);
|
|
484
1540
|
var SearchProvider = ({
|
|
485
1541
|
children,
|
|
486
1542
|
localStorageKey
|
|
487
1543
|
}) => {
|
|
488
|
-
const { debouncedValue, handleChange, inputValue } = (0,
|
|
1544
|
+
const { debouncedValue, handleChange, inputValue } = (0, import_utils3.useSearchState)({ localStorageKey });
|
|
489
1545
|
const clearSearch = () => {
|
|
490
1546
|
handleChange("");
|
|
491
1547
|
};
|
|
492
|
-
return /* @__PURE__ */
|
|
1548
|
+
return /* @__PURE__ */ React11.createElement(SearchContext.Provider, { value: { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }, children);
|
|
493
1549
|
};
|
|
494
1550
|
var useSearch = () => {
|
|
495
|
-
const context = (0,
|
|
1551
|
+
const context = (0, import_react6.useContext)(SearchContext);
|
|
496
1552
|
if (!context) {
|
|
497
1553
|
throw new Error("useSearch must be used within a SearchProvider");
|
|
498
1554
|
}
|
|
@@ -502,69 +1558,69 @@ var useSearch = () => {
|
|
|
502
1558
|
// src/components/components-tab/component-search.tsx
|
|
503
1559
|
var ComponentSearch = () => {
|
|
504
1560
|
const { inputValue, handleChange } = useSearch();
|
|
505
|
-
return /* @__PURE__ */
|
|
506
|
-
|
|
1561
|
+
return /* @__PURE__ */ React12.createElement(import_ui11.Stack, { direction: "row", gap: 0.5, sx: { width: "100%", px: 2, py: 1.5 } }, /* @__PURE__ */ React12.createElement(import_ui11.Box, { sx: { flexGrow: 1 } }, /* @__PURE__ */ React12.createElement(
|
|
1562
|
+
import_ui11.TextField,
|
|
507
1563
|
{
|
|
508
1564
|
role: "search",
|
|
509
1565
|
fullWidth: true,
|
|
510
1566
|
size: "tiny",
|
|
511
1567
|
value: inputValue,
|
|
512
|
-
placeholder: (0,
|
|
1568
|
+
placeholder: (0, import_i18n12.__)("Search", "elementor"),
|
|
513
1569
|
onChange: (e) => handleChange(e.target.value),
|
|
514
1570
|
InputProps: {
|
|
515
|
-
startAdornment: /* @__PURE__ */
|
|
1571
|
+
startAdornment: /* @__PURE__ */ React12.createElement(import_ui11.InputAdornment, { position: "start" }, /* @__PURE__ */ React12.createElement(import_icons8.SearchIcon, { fontSize: "tiny" }))
|
|
516
1572
|
}
|
|
517
1573
|
}
|
|
518
1574
|
)));
|
|
519
1575
|
};
|
|
520
1576
|
|
|
521
1577
|
// src/components/components-tab/components-list.tsx
|
|
522
|
-
var
|
|
523
|
-
var
|
|
524
|
-
var
|
|
525
|
-
var
|
|
1578
|
+
var React15 = __toESM(require("react"));
|
|
1579
|
+
var import_icons10 = require("@elementor/icons");
|
|
1580
|
+
var import_ui14 = require("@elementor/ui");
|
|
1581
|
+
var import_i18n15 = require("@wordpress/i18n");
|
|
526
1582
|
|
|
527
1583
|
// src/hooks/use-components.ts
|
|
528
|
-
var
|
|
1584
|
+
var import_store26 = require("@elementor/store");
|
|
529
1585
|
var useComponents = () => {
|
|
530
|
-
const components = (0,
|
|
531
|
-
const isLoading = (0,
|
|
1586
|
+
const components = (0, import_store26.__useSelector)(selectComponents);
|
|
1587
|
+
const isLoading = (0, import_store26.__useSelector)(selectLoadIsPending);
|
|
532
1588
|
return { components, isLoading };
|
|
533
1589
|
};
|
|
534
1590
|
|
|
535
1591
|
// src/components/components-tab/components-item.tsx
|
|
536
|
-
var
|
|
1592
|
+
var React13 = __toESM(require("react"));
|
|
537
1593
|
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
538
|
-
var
|
|
539
|
-
var
|
|
540
|
-
var
|
|
541
|
-
var
|
|
542
|
-
var
|
|
1594
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
1595
|
+
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
1596
|
+
var import_icons9 = require("@elementor/icons");
|
|
1597
|
+
var import_ui12 = require("@elementor/ui");
|
|
1598
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
543
1599
|
|
|
544
1600
|
// src/store/actions/archive-component.ts
|
|
545
|
-
var
|
|
546
|
-
var
|
|
1601
|
+
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
1602
|
+
var import_store28 = require("@elementor/store");
|
|
547
1603
|
var archiveComponent = (componentId) => {
|
|
548
|
-
const store = (0,
|
|
549
|
-
const
|
|
550
|
-
if (!
|
|
1604
|
+
const store = (0, import_store28.__getStore)();
|
|
1605
|
+
const dispatch16 = store?.dispatch;
|
|
1606
|
+
if (!dispatch16) {
|
|
551
1607
|
return;
|
|
552
1608
|
}
|
|
553
|
-
|
|
554
|
-
(0,
|
|
1609
|
+
dispatch16(slice.actions.archive(componentId));
|
|
1610
|
+
(0, import_editor_documents6.setDocumentModifiedStatus)(true);
|
|
555
1611
|
};
|
|
556
1612
|
|
|
557
1613
|
// src/store/actions/load-components-assets.ts
|
|
558
|
-
var
|
|
1614
|
+
var import_editor_documents8 = require("@elementor/editor-documents");
|
|
559
1615
|
|
|
560
1616
|
// src/create-component-type.ts
|
|
561
1617
|
var import_editor_canvas4 = require("@elementor/editor-canvas");
|
|
562
|
-
var
|
|
563
|
-
var
|
|
1618
|
+
var import_editor_documents7 = require("@elementor/editor-documents");
|
|
1619
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
564
1620
|
|
|
565
1621
|
// src/utils/tracking.ts
|
|
566
1622
|
var import_mixpanel = require("@elementor/mixpanel");
|
|
567
|
-
var
|
|
1623
|
+
var import_store30 = require("@elementor/store");
|
|
568
1624
|
var trackComponentEvent = ({ action, ...data }) => {
|
|
569
1625
|
const { dispatchEvent, config } = (0, import_mixpanel.getMixpanel)();
|
|
570
1626
|
if (!config?.names?.components?.[action]) {
|
|
@@ -581,7 +1637,7 @@ var onElementDrop = (_args, element) => {
|
|
|
581
1637
|
const componentName = editorSettings?.title;
|
|
582
1638
|
const componentUID = editorSettings?.component_uid;
|
|
583
1639
|
const instanceId = element.id;
|
|
584
|
-
const createdThisSession = selectCreatedThisSession((0,
|
|
1640
|
+
const createdThisSession = selectCreatedThisSession((0, import_store30.__getState)());
|
|
585
1641
|
const isSameSessionReuse = componentUID && createdThisSession.includes(componentUID);
|
|
586
1642
|
const eventsManagerConfig = window.elementorCommon.eventsManager.config;
|
|
587
1643
|
const { locations, secondaryLocations } = eventsManagerConfig;
|
|
@@ -629,7 +1685,7 @@ function createComponentView(options) {
|
|
|
629
1685
|
legacyWindow = window;
|
|
630
1686
|
eventsManagerConfig = this.legacyWindow.elementorCommon.eventsManager.config;
|
|
631
1687
|
isComponentCurrentlyEdited() {
|
|
632
|
-
const currentDocument = (0,
|
|
1688
|
+
const currentDocument = (0, import_editor_documents7.getCurrentDocument)();
|
|
633
1689
|
return currentDocument?.id === this.getComponentId();
|
|
634
1690
|
}
|
|
635
1691
|
afterSettingsResolve(settings) {
|
|
@@ -680,7 +1736,7 @@ function createComponentView(options) {
|
|
|
680
1736
|
action: {
|
|
681
1737
|
name: "edit component",
|
|
682
1738
|
icon: "eicon-edit",
|
|
683
|
-
title: () => (0,
|
|
1739
|
+
title: () => (0, import_i18n13.__)("Edit Component", "elementor"),
|
|
684
1740
|
isEnabled: () => true,
|
|
685
1741
|
callback: (_, eventData) => this.editComponent(eventData)
|
|
686
1742
|
}
|
|
@@ -775,7 +1831,7 @@ var getComponentIds = async (elements) => {
|
|
|
775
1831
|
};
|
|
776
1832
|
|
|
777
1833
|
// src/store/actions/load-components-overridable-props.ts
|
|
778
|
-
var
|
|
1834
|
+
var import_store32 = require("@elementor/store");
|
|
779
1835
|
function loadComponentsOverridableProps(componentIds) {
|
|
780
1836
|
if (!componentIds.length) {
|
|
781
1837
|
return;
|
|
@@ -783,7 +1839,7 @@ function loadComponentsOverridableProps(componentIds) {
|
|
|
783
1839
|
componentIds.forEach(loadComponentOverrides);
|
|
784
1840
|
}
|
|
785
1841
|
async function loadComponentOverrides(componentId) {
|
|
786
|
-
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded((0,
|
|
1842
|
+
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded((0, import_store32.__getState)(), componentId);
|
|
787
1843
|
if (isOverridablePropsLoaded) {
|
|
788
1844
|
return;
|
|
789
1845
|
}
|
|
@@ -791,7 +1847,7 @@ async function loadComponentOverrides(componentId) {
|
|
|
791
1847
|
if (!overridableProps) {
|
|
792
1848
|
return;
|
|
793
1849
|
}
|
|
794
|
-
(0,
|
|
1850
|
+
(0, import_store32.__dispatch)(
|
|
795
1851
|
slice.actions.setOverridableProps({
|
|
796
1852
|
componentId,
|
|
797
1853
|
overridableProps
|
|
@@ -800,13 +1856,13 @@ async function loadComponentOverrides(componentId) {
|
|
|
800
1856
|
}
|
|
801
1857
|
|
|
802
1858
|
// src/store/actions/load-components-styles.ts
|
|
803
|
-
var
|
|
1859
|
+
var import_store34 = require("@elementor/store");
|
|
804
1860
|
async function loadComponentsStyles(componentIds) {
|
|
805
1861
|
if (!componentIds.length) {
|
|
806
1862
|
return;
|
|
807
1863
|
}
|
|
808
|
-
const knownComponents = selectStyles((0,
|
|
809
|
-
const unknownComponentIds = componentIds.filter((
|
|
1864
|
+
const knownComponents = selectStyles((0, import_store34.__getState)());
|
|
1865
|
+
const unknownComponentIds = componentIds.filter((id2) => !knownComponents[id2]);
|
|
810
1866
|
if (!unknownComponentIds.length) {
|
|
811
1867
|
return;
|
|
812
1868
|
}
|
|
@@ -817,13 +1873,13 @@ async function addComponentStyles(ids) {
|
|
|
817
1873
|
addStyles(newComponents);
|
|
818
1874
|
}
|
|
819
1875
|
async function loadStyles(ids) {
|
|
820
|
-
return Promise.all(ids.map(async (
|
|
1876
|
+
return Promise.all(ids.map(async (id2) => [id2, await apiClient.getComponentConfig(id2)]));
|
|
821
1877
|
}
|
|
822
1878
|
function addStyles(data) {
|
|
823
1879
|
const styles = Object.fromEntries(
|
|
824
1880
|
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
825
1881
|
);
|
|
826
|
-
(0,
|
|
1882
|
+
(0, import_store34.__dispatch)(slice.actions.addStyles(styles));
|
|
827
1883
|
}
|
|
828
1884
|
function extractStyles(element) {
|
|
829
1885
|
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
@@ -842,16 +1898,16 @@ async function updateDocumentState(componentIds) {
|
|
|
842
1898
|
const components = (await Promise.all(componentIds.map(getComponentDocumentData))).filter(
|
|
843
1899
|
(document) => !!document
|
|
844
1900
|
);
|
|
845
|
-
const isDrafted = components.some(
|
|
1901
|
+
const isDrafted = components.some(import_editor_documents8.isDocumentDirty);
|
|
846
1902
|
if (isDrafted) {
|
|
847
|
-
(0,
|
|
1903
|
+
(0, import_editor_documents8.setDocumentModifiedStatus)(true);
|
|
848
1904
|
}
|
|
849
1905
|
}
|
|
850
1906
|
|
|
851
1907
|
// src/utils/get-container-for-new-element.ts
|
|
852
|
-
var
|
|
1908
|
+
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
853
1909
|
var getContainerForNewElement = () => {
|
|
854
|
-
const currentDocumentContainer = (0,
|
|
1910
|
+
const currentDocumentContainer = (0, import_editor_elements4.getCurrentDocumentContainer)();
|
|
855
1911
|
const selectedElement = getSelectedElementContainer();
|
|
856
1912
|
let container, options;
|
|
857
1913
|
if (selectedElement) {
|
|
@@ -877,17 +1933,17 @@ var getContainerForNewElement = () => {
|
|
|
877
1933
|
return { container: container ?? currentDocumentContainer, options };
|
|
878
1934
|
};
|
|
879
1935
|
function getSelectedElementContainer() {
|
|
880
|
-
const selectedElements = (0,
|
|
1936
|
+
const selectedElements = (0, import_editor_elements4.getSelectedElements)();
|
|
881
1937
|
if (selectedElements.length !== 1) {
|
|
882
1938
|
return void 0;
|
|
883
1939
|
}
|
|
884
|
-
return (0,
|
|
1940
|
+
return (0, import_editor_elements4.getContainer)(selectedElements[0].id);
|
|
885
1941
|
}
|
|
886
1942
|
|
|
887
1943
|
// src/components/create-component-form/utils/replace-element-with-component.ts
|
|
888
|
-
var
|
|
1944
|
+
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
889
1945
|
var replaceElementWithComponent = (element, component) => {
|
|
890
|
-
(0,
|
|
1946
|
+
(0, import_editor_elements5.replaceElement)({
|
|
891
1947
|
currentElement: element,
|
|
892
1948
|
newElement: createComponentModel(component),
|
|
893
1949
|
withHistory: false
|
|
@@ -919,7 +1975,7 @@ var createComponentModel = (component) => {
|
|
|
919
1975
|
// src/components/components-tab/components-item.tsx
|
|
920
1976
|
var ComponentItem = ({ component }) => {
|
|
921
1977
|
const componentModel = createComponentModel(component);
|
|
922
|
-
const popupState = (0,
|
|
1978
|
+
const popupState = (0, import_ui12.usePopupState)({
|
|
923
1979
|
variant: "popover",
|
|
924
1980
|
disableAutoFocus: true
|
|
925
1981
|
});
|
|
@@ -937,8 +1993,8 @@ var ComponentItem = ({ component }) => {
|
|
|
937
1993
|
}
|
|
938
1994
|
archiveComponent(component.id);
|
|
939
1995
|
};
|
|
940
|
-
return /* @__PURE__ */
|
|
941
|
-
|
|
1996
|
+
return /* @__PURE__ */ React13.createElement(import_ui12.Stack, null, /* @__PURE__ */ React13.createElement(
|
|
1997
|
+
import_ui12.ListItemButton,
|
|
942
1998
|
{
|
|
943
1999
|
draggable: true,
|
|
944
2000
|
onDragStart: () => (0, import_editor_canvas5.startDragElementFromPanel)(componentModel),
|
|
@@ -955,8 +2011,8 @@ var ComponentItem = ({ component }) => {
|
|
|
955
2011
|
gap: 1
|
|
956
2012
|
}
|
|
957
2013
|
},
|
|
958
|
-
/* @__PURE__ */
|
|
959
|
-
|
|
2014
|
+
/* @__PURE__ */ React13.createElement(
|
|
2015
|
+
import_ui12.Box,
|
|
960
2016
|
{
|
|
961
2017
|
onClick: handleClick,
|
|
962
2018
|
sx: {
|
|
@@ -967,22 +2023,22 @@ var ComponentItem = ({ component }) => {
|
|
|
967
2023
|
flexGrow: 1
|
|
968
2024
|
}
|
|
969
2025
|
},
|
|
970
|
-
/* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
|
|
2026
|
+
/* @__PURE__ */ React13.createElement(import_ui12.ListItemIcon, { size: "tiny" }, /* @__PURE__ */ React13.createElement(import_icons9.ComponentsIcon, { fontSize: "tiny" })),
|
|
2027
|
+
/* @__PURE__ */ React13.createElement(import_ui12.Box, { display: "flex", flex: 1, minWidth: 0, flexGrow: 1 }, /* @__PURE__ */ React13.createElement(
|
|
2028
|
+
import_editor_ui6.EllipsisWithTooltip,
|
|
973
2029
|
{
|
|
974
2030
|
title: component.name,
|
|
975
|
-
as:
|
|
2031
|
+
as: import_ui12.Typography,
|
|
976
2032
|
variant: "caption",
|
|
977
2033
|
color: "text.primary"
|
|
978
2034
|
}
|
|
979
2035
|
))
|
|
980
2036
|
),
|
|
981
|
-
/* @__PURE__ */
|
|
982
|
-
), /* @__PURE__ */
|
|
983
|
-
|
|
2037
|
+
/* @__PURE__ */ React13.createElement(import_ui12.IconButton, { size: "tiny", ...(0, import_ui12.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React13.createElement(import_icons9.DotsVerticalIcon, { fontSize: "tiny" }))
|
|
2038
|
+
), /* @__PURE__ */ React13.createElement(
|
|
2039
|
+
import_ui12.Menu,
|
|
984
2040
|
{
|
|
985
|
-
...(0,
|
|
2041
|
+
...(0, import_ui12.bindMenu)(popupState),
|
|
986
2042
|
anchorOrigin: {
|
|
987
2043
|
vertical: "bottom",
|
|
988
2044
|
horizontal: "right"
|
|
@@ -992,7 +2048,7 @@ var ComponentItem = ({ component }) => {
|
|
|
992
2048
|
horizontal: "right"
|
|
993
2049
|
}
|
|
994
2050
|
},
|
|
995
|
-
/* @__PURE__ */
|
|
2051
|
+
/* @__PURE__ */ React13.createElement(import_editor_ui6.MenuListItem, { sx: { minWidth: "160px" }, onClick: handleArchiveClick }, (0, import_i18n14.__)("Archive", "elementor"))
|
|
996
2052
|
));
|
|
997
2053
|
};
|
|
998
2054
|
var addComponentToPage = (model) => {
|
|
@@ -1001,7 +2057,7 @@ var addComponentToPage = (model) => {
|
|
|
1001
2057
|
throw new Error(`Can't find container to drop new component instance at`);
|
|
1002
2058
|
}
|
|
1003
2059
|
loadComponentsAssets([model]);
|
|
1004
|
-
(0,
|
|
2060
|
+
(0, import_editor_elements6.dropElement)({
|
|
1005
2061
|
containerId: container.id,
|
|
1006
2062
|
model,
|
|
1007
2063
|
options: { ...options, useHistory: false, scrollIntoView: true }
|
|
@@ -1009,13 +2065,13 @@ var addComponentToPage = (model) => {
|
|
|
1009
2065
|
};
|
|
1010
2066
|
|
|
1011
2067
|
// src/components/components-tab/loading-components.tsx
|
|
1012
|
-
var
|
|
1013
|
-
var
|
|
2068
|
+
var React14 = __toESM(require("react"));
|
|
2069
|
+
var import_ui13 = require("@elementor/ui");
|
|
1014
2070
|
var ROWS_COUNT = 6;
|
|
1015
2071
|
var rows = Array.from({ length: ROWS_COUNT }, (_, index) => index);
|
|
1016
2072
|
var LoadingComponents = () => {
|
|
1017
|
-
return /* @__PURE__ */
|
|
1018
|
-
|
|
2073
|
+
return /* @__PURE__ */ React14.createElement(
|
|
2074
|
+
import_ui13.Stack,
|
|
1019
2075
|
{
|
|
1020
2076
|
"aria-label": "Loading components",
|
|
1021
2077
|
gap: 1,
|
|
@@ -1036,14 +2092,14 @@ var LoadingComponents = () => {
|
|
|
1036
2092
|
}
|
|
1037
2093
|
}
|
|
1038
2094
|
},
|
|
1039
|
-
rows.map((row) => /* @__PURE__ */
|
|
1040
|
-
|
|
2095
|
+
rows.map((row) => /* @__PURE__ */ React14.createElement(
|
|
2096
|
+
import_ui13.ListItemButton,
|
|
1041
2097
|
{
|
|
1042
2098
|
key: row,
|
|
1043
2099
|
sx: { border: "solid 1px", borderColor: "divider", py: 0.5, px: 1 },
|
|
1044
2100
|
shape: "rounded"
|
|
1045
2101
|
},
|
|
1046
|
-
/* @__PURE__ */
|
|
2102
|
+
/* @__PURE__ */ React14.createElement(import_ui13.Box, { display: "flex", gap: 1, width: "100%" }, /* @__PURE__ */ React14.createElement(import_ui13.Skeleton, { variant: "text", width: "24px", height: "36px" }), /* @__PURE__ */ React14.createElement(import_ui13.Skeleton, { variant: "text", width: "100%", height: "36px" }))
|
|
1047
2103
|
))
|
|
1048
2104
|
);
|
|
1049
2105
|
};
|
|
@@ -1052,20 +2108,20 @@ var LoadingComponents = () => {
|
|
|
1052
2108
|
function ComponentsList() {
|
|
1053
2109
|
const { components, isLoading, searchValue } = useFilteredComponents();
|
|
1054
2110
|
if (isLoading) {
|
|
1055
|
-
return /* @__PURE__ */
|
|
2111
|
+
return /* @__PURE__ */ React15.createElement(LoadingComponents, null);
|
|
1056
2112
|
}
|
|
1057
2113
|
const isEmpty = !components || components.length === 0;
|
|
1058
2114
|
if (isEmpty) {
|
|
1059
2115
|
if (searchValue.length > 0) {
|
|
1060
|
-
return /* @__PURE__ */
|
|
2116
|
+
return /* @__PURE__ */ React15.createElement(EmptySearchResult, null);
|
|
1061
2117
|
}
|
|
1062
|
-
return /* @__PURE__ */
|
|
2118
|
+
return /* @__PURE__ */ React15.createElement(EmptyState, null);
|
|
1063
2119
|
}
|
|
1064
|
-
return /* @__PURE__ */
|
|
2120
|
+
return /* @__PURE__ */ React15.createElement(import_ui14.List, { sx: { display: "flex", flexDirection: "column", gap: 1, px: 2 } }, components.map((component) => /* @__PURE__ */ React15.createElement(ComponentItem, { key: component.uid, component })));
|
|
1065
2121
|
}
|
|
1066
2122
|
var EmptyState = () => {
|
|
1067
|
-
return /* @__PURE__ */
|
|
1068
|
-
|
|
2123
|
+
return /* @__PURE__ */ React15.createElement(
|
|
2124
|
+
import_ui14.Stack,
|
|
1069
2125
|
{
|
|
1070
2126
|
alignItems: "center",
|
|
1071
2127
|
justifyContent: "center",
|
|
@@ -1074,32 +2130,32 @@ var EmptyState = () => {
|
|
|
1074
2130
|
gap: 1.75,
|
|
1075
2131
|
overflow: "hidden"
|
|
1076
2132
|
},
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
/* @__PURE__ */
|
|
2133
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Icon, { fontSize: "large" }, /* @__PURE__ */ React15.createElement(import_icons10.EyeIcon, { fontSize: "large" })),
|
|
2134
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Typography, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, (0, import_i18n15.__)("Text that explains that there are no Components yet.", "elementor")),
|
|
2135
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Typography, { variant: "caption", align: "center", color: "text.secondary" }, (0, import_i18n15.__)(
|
|
1080
2136
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
1081
2137
|
"elementor"
|
|
1082
2138
|
)),
|
|
1083
|
-
/* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */
|
|
1085
|
-
/* @__PURE__ */
|
|
1086
|
-
|
|
2139
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Divider, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
2140
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Typography, { align: "left", variant: "caption", color: "text.secondary" }, (0, import_i18n15.__)("To create a component, first design it, then choose one of three options:", "elementor")),
|
|
2141
|
+
/* @__PURE__ */ React15.createElement(
|
|
2142
|
+
import_ui14.Typography,
|
|
1087
2143
|
{
|
|
1088
2144
|
align: "left",
|
|
1089
2145
|
variant: "caption",
|
|
1090
2146
|
color: "text.secondary",
|
|
1091
2147
|
sx: { display: "flex", flexDirection: "column" }
|
|
1092
2148
|
},
|
|
1093
|
-
/* @__PURE__ */
|
|
1094
|
-
/* @__PURE__ */
|
|
1095
|
-
/* @__PURE__ */
|
|
2149
|
+
/* @__PURE__ */ React15.createElement("span", null, (0, import_i18n15.__)("1. Right-click and select Create Component", "elementor")),
|
|
2150
|
+
/* @__PURE__ */ React15.createElement("span", null, (0, import_i18n15.__)("2. Use the component icon in the Structure panel", "elementor")),
|
|
2151
|
+
/* @__PURE__ */ React15.createElement("span", null, (0, import_i18n15.__)("3. Use the component icon in the Edit panel header", "elementor"))
|
|
1096
2152
|
)
|
|
1097
2153
|
);
|
|
1098
2154
|
};
|
|
1099
2155
|
var EmptySearchResult = () => {
|
|
1100
2156
|
const { searchValue, clearSearch } = useSearch();
|
|
1101
|
-
return /* @__PURE__ */
|
|
1102
|
-
|
|
2157
|
+
return /* @__PURE__ */ React15.createElement(
|
|
2158
|
+
import_ui14.Stack,
|
|
1103
2159
|
{
|
|
1104
2160
|
color: "text.secondary",
|
|
1105
2161
|
pt: 5,
|
|
@@ -1108,17 +2164,17 @@ var EmptySearchResult = () => {
|
|
|
1108
2164
|
overflow: "hidden",
|
|
1109
2165
|
justifySelf: "center"
|
|
1110
2166
|
},
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
/* @__PURE__ */
|
|
1113
|
-
|
|
2167
|
+
/* @__PURE__ */ React15.createElement(import_icons10.ComponentsIcon, null),
|
|
2168
|
+
/* @__PURE__ */ React15.createElement(
|
|
2169
|
+
import_ui14.Box,
|
|
1114
2170
|
{
|
|
1115
2171
|
sx: {
|
|
1116
2172
|
width: "100%"
|
|
1117
2173
|
}
|
|
1118
2174
|
},
|
|
1119
|
-
/* @__PURE__ */
|
|
1120
|
-
searchValue && /* @__PURE__ */
|
|
1121
|
-
|
|
2175
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Typography, { align: "center", variant: "subtitle2", color: "inherit" }, (0, import_i18n15.__)("Sorry, nothing matched", "elementor")),
|
|
2176
|
+
searchValue && /* @__PURE__ */ React15.createElement(
|
|
2177
|
+
import_ui14.Typography,
|
|
1122
2178
|
{
|
|
1123
2179
|
variant: "subtitle2",
|
|
1124
2180
|
color: "inherit",
|
|
@@ -1128,8 +2184,8 @@ var EmptySearchResult = () => {
|
|
|
1128
2184
|
justifyContent: "center"
|
|
1129
2185
|
}
|
|
1130
2186
|
},
|
|
1131
|
-
/* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
2187
|
+
/* @__PURE__ */ React15.createElement("span", null, "\u201C"),
|
|
2188
|
+
/* @__PURE__ */ React15.createElement(
|
|
1133
2189
|
"span",
|
|
1134
2190
|
{
|
|
1135
2191
|
style: {
|
|
@@ -1140,11 +2196,11 @@ var EmptySearchResult = () => {
|
|
|
1140
2196
|
},
|
|
1141
2197
|
searchValue
|
|
1142
2198
|
),
|
|
1143
|
-
/* @__PURE__ */
|
|
2199
|
+
/* @__PURE__ */ React15.createElement("span", null, "\u201D.")
|
|
1144
2200
|
)
|
|
1145
2201
|
),
|
|
1146
|
-
/* @__PURE__ */
|
|
1147
|
-
/* @__PURE__ */
|
|
2202
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Typography, { align: "center", variant: "caption", color: "inherit" }, (0, import_i18n15.__)("Try something else.", "elementor")),
|
|
2203
|
+
/* @__PURE__ */ React15.createElement(import_ui14.Typography, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React15.createElement(import_ui14.Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, (0, import_i18n15.__)("Clear & try again", "elementor")))
|
|
1148
2204
|
);
|
|
1149
2205
|
};
|
|
1150
2206
|
var useFilteredComponents = () => {
|
|
@@ -1161,35 +2217,35 @@ var useFilteredComponents = () => {
|
|
|
1161
2217
|
|
|
1162
2218
|
// src/components/components-tab/components.tsx
|
|
1163
2219
|
var Components = () => {
|
|
1164
|
-
return /* @__PURE__ */
|
|
2220
|
+
return /* @__PURE__ */ React16.createElement(import_editor_ui7.ThemeProvider, null, /* @__PURE__ */ React16.createElement(SearchProvider, { localStorageKey: "elementor-components-search" }, /* @__PURE__ */ React16.createElement(ComponentSearch, null), /* @__PURE__ */ React16.createElement(ComponentsList, null)));
|
|
1165
2221
|
};
|
|
1166
2222
|
|
|
1167
2223
|
// src/components/consts.ts
|
|
1168
2224
|
var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
1169
2225
|
|
|
1170
2226
|
// src/components/create-component-form/create-component-form.tsx
|
|
1171
|
-
var
|
|
1172
|
-
var
|
|
1173
|
-
var
|
|
1174
|
-
var
|
|
1175
|
-
var
|
|
1176
|
-
var
|
|
1177
|
-
var
|
|
2227
|
+
var React17 = __toESM(require("react"));
|
|
2228
|
+
var import_react8 = require("react");
|
|
2229
|
+
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
2230
|
+
var import_editor_ui8 = require("@elementor/editor-ui");
|
|
2231
|
+
var import_icons11 = require("@elementor/icons");
|
|
2232
|
+
var import_ui15 = require("@elementor/ui");
|
|
2233
|
+
var import_i18n17 = require("@wordpress/i18n");
|
|
1178
2234
|
|
|
1179
2235
|
// src/store/actions/create-unpublished-component.ts
|
|
1180
2236
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
1181
|
-
var
|
|
1182
|
-
var
|
|
2237
|
+
var import_store36 = require("@elementor/store");
|
|
2238
|
+
var import_utils4 = require("@elementor/utils");
|
|
1183
2239
|
function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
|
|
1184
|
-
const generatedUid = uid ?? (0,
|
|
2240
|
+
const generatedUid = uid ?? (0, import_utils4.generateUniqueId)("component");
|
|
1185
2241
|
const componentBase = { uid: generatedUid, name, overridableProps };
|
|
1186
|
-
(0,
|
|
2242
|
+
(0, import_store36.__dispatch)(
|
|
1187
2243
|
slice.actions.addUnpublished({
|
|
1188
2244
|
...componentBase,
|
|
1189
2245
|
elements: [element]
|
|
1190
2246
|
})
|
|
1191
2247
|
);
|
|
1192
|
-
(0,
|
|
2248
|
+
(0, import_store36.__dispatch)(slice.actions.addCreatedThisSession(generatedUid));
|
|
1193
2249
|
replaceElementWithComponent(element, componentBase);
|
|
1194
2250
|
trackComponentEvent({
|
|
1195
2251
|
action: "created",
|
|
@@ -1202,11 +2258,11 @@ function createUnpublishedComponent(name, element, eventData, overridableProps,
|
|
|
1202
2258
|
}
|
|
1203
2259
|
|
|
1204
2260
|
// src/components/create-component-form/hooks/use-form.ts
|
|
1205
|
-
var
|
|
2261
|
+
var import_react7 = require("react");
|
|
1206
2262
|
var useForm = (initialValues) => {
|
|
1207
|
-
const [values, setValues] = (0,
|
|
1208
|
-
const [errors, setErrors] = (0,
|
|
1209
|
-
const isValid = (0,
|
|
2263
|
+
const [values, setValues] = (0, import_react7.useState)(initialValues);
|
|
2264
|
+
const [errors, setErrors] = (0, import_react7.useState)({});
|
|
2265
|
+
const isValid = (0, import_react7.useMemo)(() => {
|
|
1210
2266
|
return !Object.values(errors).some((error) => error);
|
|
1211
2267
|
}, [errors]);
|
|
1212
2268
|
const handleChange = (e, field, validationSchema) => {
|
|
@@ -1252,16 +2308,16 @@ var validateForm = (values, schema) => {
|
|
|
1252
2308
|
|
|
1253
2309
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
1254
2310
|
var import_schema = require("@elementor/schema");
|
|
1255
|
-
var
|
|
2311
|
+
var import_i18n16 = require("@wordpress/i18n");
|
|
1256
2312
|
var MIN_NAME_LENGTH = 2;
|
|
1257
2313
|
var MAX_NAME_LENGTH = 50;
|
|
1258
2314
|
var createBaseComponentSchema = (existingNames) => {
|
|
1259
2315
|
return import_schema.z.object({
|
|
1260
2316
|
componentName: import_schema.z.string().trim().max(
|
|
1261
2317
|
MAX_NAME_LENGTH,
|
|
1262
|
-
(0,
|
|
2318
|
+
(0, import_i18n16.__)("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
1263
2319
|
).refine((value) => !existingNames.includes(value), {
|
|
1264
|
-
message: (0,
|
|
2320
|
+
message: (0, import_i18n16.__)("Component name already exists", "elementor")
|
|
1265
2321
|
})
|
|
1266
2322
|
});
|
|
1267
2323
|
};
|
|
@@ -1269,9 +2325,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
1269
2325
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
1270
2326
|
return baseSchema.extend({
|
|
1271
2327
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
1272
|
-
message: (0,
|
|
2328
|
+
message: (0, import_i18n16.__)("Component name is required.", "elementor")
|
|
1273
2329
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
1274
|
-
message: (0,
|
|
2330
|
+
message: (0, import_i18n16.__)("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
1275
2331
|
})
|
|
1276
2332
|
});
|
|
1277
2333
|
};
|
|
@@ -1307,14 +2363,14 @@ function countNestedElements(container) {
|
|
|
1307
2363
|
|
|
1308
2364
|
// src/components/create-component-form/create-component-form.tsx
|
|
1309
2365
|
function CreateComponentForm() {
|
|
1310
|
-
const [element, setElement] = (0,
|
|
1311
|
-
const [anchorPosition, setAnchorPosition] = (0,
|
|
1312
|
-
const [resultNotification, setResultNotification] = (0,
|
|
1313
|
-
const eventData = (0,
|
|
1314
|
-
(0,
|
|
2366
|
+
const [element, setElement] = (0, import_react8.useState)(null);
|
|
2367
|
+
const [anchorPosition, setAnchorPosition] = (0, import_react8.useState)();
|
|
2368
|
+
const [resultNotification, setResultNotification] = (0, import_react8.useState)(null);
|
|
2369
|
+
const eventData = (0, import_react8.useRef)(null);
|
|
2370
|
+
(0, import_react8.useEffect)(() => {
|
|
1315
2371
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
1316
2372
|
const openPopup = (event) => {
|
|
1317
|
-
setElement({ element: event.detail.element, elementLabel: (0,
|
|
2373
|
+
setElement({ element: event.detail.element, elementLabel: (0, import_editor_elements7.getElementLabel)(event.detail.element.id) });
|
|
1318
2374
|
setAnchorPosition(event.detail.anchorPosition);
|
|
1319
2375
|
eventData.current = getComponentEventData(event.detail.element, event.detail.options);
|
|
1320
2376
|
trackComponentEvent({
|
|
@@ -1336,12 +2392,12 @@ function CreateComponentForm() {
|
|
|
1336
2392
|
setResultNotification({
|
|
1337
2393
|
show: true,
|
|
1338
2394
|
// Translators: %1$s: Component name, %2$s: Component UID
|
|
1339
|
-
message: (0,
|
|
2395
|
+
message: (0, import_i18n17.__)("Component saved successfully as: %1$s (UID: %2$s)", "elementor").replace("%1$s", values.componentName).replace("%2$s", uid),
|
|
1340
2396
|
type: "success"
|
|
1341
2397
|
});
|
|
1342
2398
|
resetAndClosePopup();
|
|
1343
2399
|
} catch {
|
|
1344
|
-
const errorMessage = (0,
|
|
2400
|
+
const errorMessage = (0, import_i18n17.__)("Failed to save component. Please try again.", "elementor");
|
|
1345
2401
|
setResultNotification({
|
|
1346
2402
|
show: true,
|
|
1347
2403
|
message: errorMessage,
|
|
@@ -1360,24 +2416,24 @@ function CreateComponentForm() {
|
|
|
1360
2416
|
...eventData.current
|
|
1361
2417
|
});
|
|
1362
2418
|
};
|
|
1363
|
-
return /* @__PURE__ */
|
|
1364
|
-
|
|
2419
|
+
return /* @__PURE__ */ React17.createElement(import_editor_ui8.ThemeProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2420
|
+
import_ui15.Popover,
|
|
1365
2421
|
{
|
|
1366
2422
|
open: element !== null,
|
|
1367
2423
|
onClose: cancelSave,
|
|
1368
2424
|
anchorReference: "anchorPosition",
|
|
1369
2425
|
anchorPosition
|
|
1370
2426
|
},
|
|
1371
|
-
element !== null && /* @__PURE__ */
|
|
1372
|
-
|
|
2427
|
+
element !== null && /* @__PURE__ */ React17.createElement(
|
|
2428
|
+
Form2,
|
|
1373
2429
|
{
|
|
1374
2430
|
initialValues: { componentName: element.elementLabel },
|
|
1375
2431
|
handleSave,
|
|
1376
2432
|
closePopup: cancelSave
|
|
1377
2433
|
}
|
|
1378
2434
|
)
|
|
1379
|
-
), /* @__PURE__ */
|
|
1380
|
-
|
|
2435
|
+
), /* @__PURE__ */ React17.createElement(import_ui15.Snackbar, { open: resultNotification?.show, onClose: () => setResultNotification(null) }, /* @__PURE__ */ React17.createElement(
|
|
2436
|
+
import_ui15.Alert,
|
|
1381
2437
|
{
|
|
1382
2438
|
onClose: () => setResultNotification(null),
|
|
1383
2439
|
severity: resultNotification?.type,
|
|
@@ -1387,21 +2443,21 @@ function CreateComponentForm() {
|
|
|
1387
2443
|
)));
|
|
1388
2444
|
}
|
|
1389
2445
|
var FONT_SIZE = "tiny";
|
|
1390
|
-
var
|
|
2446
|
+
var Form2 = ({
|
|
1391
2447
|
initialValues,
|
|
1392
2448
|
handleSave,
|
|
1393
2449
|
closePopup
|
|
1394
2450
|
}) => {
|
|
1395
2451
|
const { values, errors, isValid, handleChange, validateForm: validateForm2 } = useForm(initialValues);
|
|
1396
2452
|
const { components } = useComponents();
|
|
1397
|
-
const existingComponentNames = (0,
|
|
2453
|
+
const existingComponentNames = (0, import_react8.useMemo)(() => {
|
|
1398
2454
|
return components?.map((component) => component.name) ?? [];
|
|
1399
2455
|
}, [components]);
|
|
1400
|
-
const changeValidationSchema = (0,
|
|
2456
|
+
const changeValidationSchema = (0, import_react8.useMemo)(
|
|
1401
2457
|
() => createBaseComponentSchema(existingComponentNames),
|
|
1402
2458
|
[existingComponentNames]
|
|
1403
2459
|
);
|
|
1404
|
-
const submitValidationSchema = (0,
|
|
2460
|
+
const submitValidationSchema = (0, import_react8.useMemo)(
|
|
1405
2461
|
() => createSubmitComponentSchema(existingComponentNames),
|
|
1406
2462
|
[existingComponentNames]
|
|
1407
2463
|
);
|
|
@@ -1412,14 +2468,14 @@ var Form = ({
|
|
|
1412
2468
|
}
|
|
1413
2469
|
};
|
|
1414
2470
|
const texts = {
|
|
1415
|
-
heading: (0,
|
|
1416
|
-
name: (0,
|
|
1417
|
-
cancel: (0,
|
|
1418
|
-
create: (0,
|
|
2471
|
+
heading: (0, import_i18n17.__)("Save as a component", "elementor"),
|
|
2472
|
+
name: (0, import_i18n17.__)("Name", "elementor"),
|
|
2473
|
+
cancel: (0, import_i18n17.__)("Cancel", "elementor"),
|
|
2474
|
+
create: (0, import_i18n17.__)("Create", "elementor")
|
|
1419
2475
|
};
|
|
1420
2476
|
const nameInputId = "component-name";
|
|
1421
|
-
return /* @__PURE__ */
|
|
1422
|
-
|
|
2477
|
+
return /* @__PURE__ */ React17.createElement(import_editor_ui8.Form, { onSubmit: handleSubmit }, /* @__PURE__ */ React17.createElement(import_ui15.Stack, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React17.createElement(
|
|
2478
|
+
import_ui15.Stack,
|
|
1423
2479
|
{
|
|
1424
2480
|
direction: "row",
|
|
1425
2481
|
alignItems: "center",
|
|
@@ -1427,10 +2483,10 @@ var Form = ({
|
|
|
1427
2483
|
px: 1.5,
|
|
1428
2484
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
1429
2485
|
},
|
|
1430
|
-
/* @__PURE__ */
|
|
1431
|
-
/* @__PURE__ */
|
|
1432
|
-
), /* @__PURE__ */
|
|
1433
|
-
|
|
2486
|
+
/* @__PURE__ */ React17.createElement(import_icons11.StarIcon, { fontSize: FONT_SIZE }),
|
|
2487
|
+
/* @__PURE__ */ React17.createElement(import_ui15.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, texts.heading)
|
|
2488
|
+
), /* @__PURE__ */ React17.createElement(import_ui15.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React17.createElement(import_ui15.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React17.createElement(import_ui15.FormLabel, { htmlFor: nameInputId, size: "tiny" }, texts.name)), /* @__PURE__ */ React17.createElement(import_ui15.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React17.createElement(
|
|
2489
|
+
import_ui15.TextField,
|
|
1434
2490
|
{
|
|
1435
2491
|
id: nameInputId,
|
|
1436
2492
|
size: FONT_SIZE,
|
|
@@ -1441,37 +2497,37 @@ var Form = ({
|
|
|
1441
2497
|
error: Boolean(errors.componentName),
|
|
1442
2498
|
helperText: errors.componentName
|
|
1443
2499
|
}
|
|
1444
|
-
))), /* @__PURE__ */
|
|
2500
|
+
))), /* @__PURE__ */ React17.createElement(import_ui15.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React17.createElement(import_ui15.Button, { onClick: closePopup, color: "secondary", variant: "text", size: "small" }, texts.cancel), /* @__PURE__ */ React17.createElement(import_ui15.Button, { type: "submit", disabled: !isValid, variant: "contained", color: "primary", size: "small" }, texts.create))));
|
|
1445
2501
|
};
|
|
1446
2502
|
|
|
1447
2503
|
// src/components/edit-component/edit-component.tsx
|
|
1448
|
-
var
|
|
1449
|
-
var
|
|
1450
|
-
var
|
|
2504
|
+
var React19 = __toESM(require("react"));
|
|
2505
|
+
var import_react11 = require("react");
|
|
2506
|
+
var import_editor_documents10 = require("@elementor/editor-documents");
|
|
1451
2507
|
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
1452
|
-
var
|
|
1453
|
-
var
|
|
2508
|
+
var import_store40 = require("@elementor/store");
|
|
2509
|
+
var import_utils6 = require("@elementor/utils");
|
|
1454
2510
|
|
|
1455
2511
|
// src/store/actions/update-current-component.ts
|
|
1456
|
-
var
|
|
1457
|
-
var
|
|
2512
|
+
var import_editor_documents9 = require("@elementor/editor-documents");
|
|
2513
|
+
var import_store38 = require("@elementor/store");
|
|
1458
2514
|
function updateCurrentComponent({
|
|
1459
2515
|
path,
|
|
1460
2516
|
currentComponentId
|
|
1461
2517
|
}) {
|
|
1462
|
-
const
|
|
1463
|
-
if (!
|
|
2518
|
+
const dispatch16 = (0, import_store38.__getStore)()?.dispatch;
|
|
2519
|
+
if (!dispatch16) {
|
|
1464
2520
|
return;
|
|
1465
2521
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
2522
|
+
dispatch16(slice.actions.setPath(path));
|
|
2523
|
+
dispatch16(slice.actions.setCurrentComponentId(currentComponentId));
|
|
1468
2524
|
}
|
|
1469
2525
|
|
|
1470
2526
|
// src/components/edit-component/component-modal.tsx
|
|
1471
|
-
var
|
|
1472
|
-
var
|
|
2527
|
+
var React18 = __toESM(require("react"));
|
|
2528
|
+
var import_react10 = require("react");
|
|
1473
2529
|
var import_react_dom = require("react-dom");
|
|
1474
|
-
var
|
|
2530
|
+
var import_i18n18 = require("@wordpress/i18n");
|
|
1475
2531
|
|
|
1476
2532
|
// src/hooks/use-canvas-document.ts
|
|
1477
2533
|
var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
@@ -1481,11 +2537,11 @@ function useCanvasDocument() {
|
|
|
1481
2537
|
}
|
|
1482
2538
|
|
|
1483
2539
|
// src/hooks/use-element-rect.ts
|
|
1484
|
-
var
|
|
1485
|
-
var
|
|
2540
|
+
var import_react9 = require("react");
|
|
2541
|
+
var import_utils5 = require("@elementor/utils");
|
|
1486
2542
|
function useElementRect(element) {
|
|
1487
|
-
const [rect, setRect] = (0,
|
|
1488
|
-
const onChange = (0,
|
|
2543
|
+
const [rect, setRect] = (0, import_react9.useState)(new DOMRect(0, 0, 0, 0));
|
|
2544
|
+
const onChange = (0, import_utils5.throttle)(
|
|
1489
2545
|
() => {
|
|
1490
2546
|
setRect(element?.getBoundingClientRect() ?? new DOMRect(0, 0, 0, 0));
|
|
1491
2547
|
},
|
|
@@ -1495,7 +2551,7 @@ function useElementRect(element) {
|
|
|
1495
2551
|
useScrollListener({ element, onChange });
|
|
1496
2552
|
useResizeListener({ element, onChange });
|
|
1497
2553
|
useMutationsListener({ element, onChange });
|
|
1498
|
-
(0,
|
|
2554
|
+
(0, import_react9.useEffect)(
|
|
1499
2555
|
() => () => {
|
|
1500
2556
|
onChange.cancel();
|
|
1501
2557
|
},
|
|
@@ -1504,7 +2560,7 @@ function useElementRect(element) {
|
|
|
1504
2560
|
return rect;
|
|
1505
2561
|
}
|
|
1506
2562
|
function useScrollListener({ element, onChange }) {
|
|
1507
|
-
(0,
|
|
2563
|
+
(0, import_react9.useEffect)(() => {
|
|
1508
2564
|
if (!element) {
|
|
1509
2565
|
return;
|
|
1510
2566
|
}
|
|
@@ -1516,7 +2572,7 @@ function useScrollListener({ element, onChange }) {
|
|
|
1516
2572
|
}, [element, onChange]);
|
|
1517
2573
|
}
|
|
1518
2574
|
function useResizeListener({ element, onChange }) {
|
|
1519
|
-
(0,
|
|
2575
|
+
(0, import_react9.useEffect)(() => {
|
|
1520
2576
|
if (!element) {
|
|
1521
2577
|
return;
|
|
1522
2578
|
}
|
|
@@ -1531,7 +2587,7 @@ function useResizeListener({ element, onChange }) {
|
|
|
1531
2587
|
}, [element, onChange]);
|
|
1532
2588
|
}
|
|
1533
2589
|
function useMutationsListener({ element, onChange }) {
|
|
1534
|
-
(0,
|
|
2590
|
+
(0, import_react9.useEffect)(() => {
|
|
1535
2591
|
if (!element) {
|
|
1536
2592
|
return;
|
|
1537
2593
|
}
|
|
@@ -1546,7 +2602,7 @@ function useMutationsListener({ element, onChange }) {
|
|
|
1546
2602
|
// src/components/edit-component/component-modal.tsx
|
|
1547
2603
|
function ComponentModal({ element, onClose }) {
|
|
1548
2604
|
const canvasDocument = useCanvasDocument();
|
|
1549
|
-
(0,
|
|
2605
|
+
(0, import_react10.useEffect)(() => {
|
|
1550
2606
|
const handleEsc = (event) => {
|
|
1551
2607
|
if (event.key === "Escape") {
|
|
1552
2608
|
onClose();
|
|
@@ -1561,7 +2617,7 @@ function ComponentModal({ element, onClose }) {
|
|
|
1561
2617
|
return null;
|
|
1562
2618
|
}
|
|
1563
2619
|
return (0, import_react_dom.createPortal)(
|
|
1564
|
-
/* @__PURE__ */
|
|
2620
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(BlockEditPage, null), /* @__PURE__ */ React18.createElement(Backdrop, { canvas: canvasDocument, element, onClose })),
|
|
1565
2621
|
canvasDocument.body
|
|
1566
2622
|
);
|
|
1567
2623
|
}
|
|
@@ -1585,7 +2641,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
1585
2641
|
onClose();
|
|
1586
2642
|
}
|
|
1587
2643
|
};
|
|
1588
|
-
return /* @__PURE__ */
|
|
2644
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1589
2645
|
"div",
|
|
1590
2646
|
{
|
|
1591
2647
|
style: backdropStyle,
|
|
@@ -1593,7 +2649,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
1593
2649
|
onKeyDown: handleKeyDown,
|
|
1594
2650
|
role: "button",
|
|
1595
2651
|
tabIndex: 0,
|
|
1596
|
-
"aria-label": (0,
|
|
2652
|
+
"aria-label": (0, import_i18n18.__)("Exit component editing mode", "elementor")
|
|
1597
2653
|
}
|
|
1598
2654
|
);
|
|
1599
2655
|
}
|
|
@@ -1643,7 +2699,7 @@ function BlockEditPage() {
|
|
|
1643
2699
|
}
|
|
1644
2700
|
}
|
|
1645
2701
|
`;
|
|
1646
|
-
return /* @__PURE__ */
|
|
2702
|
+
return /* @__PURE__ */ React18.createElement("style", { "data-e-style-id": "e-block-v3-document-handles-styles" }, blockV3DocumentHandlesStyles);
|
|
1647
2703
|
}
|
|
1648
2704
|
|
|
1649
2705
|
// src/components/edit-component/edit-component.tsx
|
|
@@ -1651,18 +2707,18 @@ function EditComponent() {
|
|
|
1651
2707
|
const currentComponentId = useCurrentComponentId();
|
|
1652
2708
|
useHandleDocumentSwitches();
|
|
1653
2709
|
const navigateBack = useNavigateBack();
|
|
1654
|
-
const onClose = (0,
|
|
2710
|
+
const onClose = (0, import_utils6.throttle)(navigateBack, 100);
|
|
1655
2711
|
const elementDom = getComponentDOMElement(currentComponentId ?? void 0);
|
|
1656
2712
|
if (!elementDom) {
|
|
1657
2713
|
return null;
|
|
1658
2714
|
}
|
|
1659
|
-
return /* @__PURE__ */
|
|
2715
|
+
return /* @__PURE__ */ React19.createElement(ComponentModal, { element: elementDom, onClose });
|
|
1660
2716
|
}
|
|
1661
2717
|
function useHandleDocumentSwitches() {
|
|
1662
|
-
const documentsManager = (0,
|
|
2718
|
+
const documentsManager = (0, import_editor_documents10.getV1DocumentsManager)();
|
|
1663
2719
|
const currentComponentId = useCurrentComponentId();
|
|
1664
|
-
const path = (0,
|
|
1665
|
-
(0,
|
|
2720
|
+
const path = (0, import_store40.__useSelector)(selectPath);
|
|
2721
|
+
(0, import_react11.useEffect)(() => {
|
|
1666
2722
|
return (0, import_editor_v1_adapters5.__privateListenTo)((0, import_editor_v1_adapters5.commandEndEvent)("editor/documents/open"), () => {
|
|
1667
2723
|
const nextDocument = documentsManager.getCurrent();
|
|
1668
2724
|
if (nextDocument.id === currentComponentId) {
|
|
@@ -1696,12 +2752,12 @@ function getUpdatedComponentPath(path, nextDocument) {
|
|
|
1696
2752
|
}
|
|
1697
2753
|
];
|
|
1698
2754
|
}
|
|
1699
|
-
function getComponentDOMElement(
|
|
1700
|
-
if (!
|
|
2755
|
+
function getComponentDOMElement(id2) {
|
|
2756
|
+
if (!id2) {
|
|
1701
2757
|
return null;
|
|
1702
2758
|
}
|
|
1703
|
-
const documentsManager = (0,
|
|
1704
|
-
const currentComponent = documentsManager.get(
|
|
2759
|
+
const documentsManager = (0, import_editor_documents10.getV1DocumentsManager)();
|
|
2760
|
+
const currentComponent = documentsManager.get(id2);
|
|
1705
2761
|
const widget = currentComponent?.container;
|
|
1706
2762
|
const container = widget?.view?.el?.children?.[0] ?? null;
|
|
1707
2763
|
const elementDom = container?.children[0];
|
|
@@ -1709,33 +2765,33 @@ function getComponentDOMElement(id) {
|
|
|
1709
2765
|
}
|
|
1710
2766
|
|
|
1711
2767
|
// src/components/in-edit-mode.tsx
|
|
1712
|
-
var
|
|
1713
|
-
var
|
|
1714
|
-
var
|
|
1715
|
-
var
|
|
1716
|
-
var
|
|
2768
|
+
var React20 = __toESM(require("react"));
|
|
2769
|
+
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
2770
|
+
var import_icons12 = require("@elementor/icons");
|
|
2771
|
+
var import_ui16 = require("@elementor/ui");
|
|
2772
|
+
var import_i18n19 = require("@wordpress/i18n");
|
|
1717
2773
|
var openEditModeDialog = (lockedBy) => {
|
|
1718
|
-
(0,
|
|
1719
|
-
component: /* @__PURE__ */
|
|
2774
|
+
(0, import_editor_ui9.openDialog)({
|
|
2775
|
+
component: /* @__PURE__ */ React20.createElement(EditModeDialog, { lockedBy })
|
|
1720
2776
|
});
|
|
1721
2777
|
};
|
|
1722
2778
|
var EditModeDialog = ({ lockedBy }) => {
|
|
1723
|
-
const content = (0,
|
|
1724
|
-
return /* @__PURE__ */
|
|
2779
|
+
const content = (0, import_i18n19.__)("%s is currently editing this document", "elementor").replace("%s", lockedBy);
|
|
2780
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(import_ui16.DialogHeader, { logo: false }, /* @__PURE__ */ React20.createElement(import_ui16.Box, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React20.createElement(import_ui16.Icon, { color: "secondary" }, /* @__PURE__ */ React20.createElement(import_icons12.InfoCircleFilledIcon, { fontSize: "medium" })), /* @__PURE__ */ React20.createElement(import_ui16.Typography, { variant: "subtitle1" }, content))), /* @__PURE__ */ React20.createElement(import_ui16.DialogContent, null, /* @__PURE__ */ React20.createElement(import_ui16.Stack, { spacing: 2, direction: "column" }, /* @__PURE__ */ React20.createElement(import_ui16.Typography, { variant: "body2" }, (0, import_i18n19.__)(
|
|
1725
2781
|
"You can wait for them to finish or reach out to coordinate your changes together.",
|
|
1726
2782
|
"elementor"
|
|
1727
|
-
)), /* @__PURE__ */
|
|
2783
|
+
)), /* @__PURE__ */ React20.createElement(import_ui16.DialogActions, null, /* @__PURE__ */ React20.createElement(import_ui16.Button, { color: "secondary", variant: "contained", onClick: import_editor_ui9.closeDialog }, (0, import_i18n19.__)("Close", "elementor"))))));
|
|
1728
2784
|
};
|
|
1729
2785
|
|
|
1730
2786
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
1731
|
-
var
|
|
1732
|
-
var
|
|
1733
|
-
var
|
|
1734
|
-
var
|
|
1735
|
-
var
|
|
1736
|
-
var
|
|
1737
|
-
var
|
|
1738
|
-
var
|
|
2787
|
+
var React23 = __toESM(require("react"));
|
|
2788
|
+
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
2789
|
+
var import_editor_elements8 = require("@elementor/editor-elements");
|
|
2790
|
+
var import_editor_panels3 = require("@elementor/editor-panels");
|
|
2791
|
+
var import_icons14 = require("@elementor/icons");
|
|
2792
|
+
var import_store42 = require("@elementor/store");
|
|
2793
|
+
var import_ui19 = require("@elementor/ui");
|
|
2794
|
+
var import_i18n21 = require("@wordpress/i18n");
|
|
1739
2795
|
|
|
1740
2796
|
// src/prop-types/component-instance-prop-type.ts
|
|
1741
2797
|
var import_editor_props3 = require("@elementor/editor-props");
|
|
@@ -1776,13 +2832,13 @@ var componentInstancePropTypeUtil = (0, import_editor_props3.createPropUtils)(
|
|
|
1776
2832
|
);
|
|
1777
2833
|
|
|
1778
2834
|
// src/components/instance-editing-panel/empty-state.tsx
|
|
1779
|
-
var
|
|
1780
|
-
var
|
|
1781
|
-
var
|
|
1782
|
-
var
|
|
2835
|
+
var React21 = __toESM(require("react"));
|
|
2836
|
+
var import_icons13 = require("@elementor/icons");
|
|
2837
|
+
var import_ui17 = require("@elementor/ui");
|
|
2838
|
+
var import_i18n20 = require("@wordpress/i18n");
|
|
1783
2839
|
var EmptyState2 = ({ onEditComponent }) => {
|
|
1784
|
-
return /* @__PURE__ */
|
|
1785
|
-
|
|
2840
|
+
return /* @__PURE__ */ React21.createElement(
|
|
2841
|
+
import_ui17.Stack,
|
|
1786
2842
|
{
|
|
1787
2843
|
alignItems: "center",
|
|
1788
2844
|
justifyContent: "start",
|
|
@@ -1791,33 +2847,33 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
1791
2847
|
sx: { p: 2.5, pt: 8, pb: 5.5, mt: 1 },
|
|
1792
2848
|
gap: 1.5
|
|
1793
2849
|
},
|
|
1794
|
-
/* @__PURE__ */
|
|
1795
|
-
/* @__PURE__ */
|
|
1796
|
-
/* @__PURE__ */
|
|
2850
|
+
/* @__PURE__ */ React21.createElement(import_icons13.ComponentPropListIcon, { fontSize: "large" }),
|
|
2851
|
+
/* @__PURE__ */ React21.createElement(import_ui17.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n20.__)("No properties yet", "elementor")),
|
|
2852
|
+
/* @__PURE__ */ React21.createElement(import_ui17.Typography, { align: "center", variant: "caption", maxWidth: "170px" }, (0, import_i18n20.__)(
|
|
1797
2853
|
"Edit the component to add properties, manage them or update the design across all instances.",
|
|
1798
2854
|
"elementor"
|
|
1799
2855
|
)),
|
|
1800
|
-
/* @__PURE__ */
|
|
2856
|
+
/* @__PURE__ */ React21.createElement(import_ui17.Button, { variant: "outlined", color: "secondary", size: "small", sx: { mt: 1 }, onClick: onEditComponent }, /* @__PURE__ */ React21.createElement(import_icons13.PencilIcon, { fontSize: "small" }), (0, import_i18n20.__)("Edit component", "elementor"))
|
|
1801
2857
|
);
|
|
1802
2858
|
};
|
|
1803
2859
|
|
|
1804
2860
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
1805
|
-
var
|
|
1806
|
-
var
|
|
1807
|
-
var
|
|
1808
|
-
var
|
|
1809
|
-
var
|
|
2861
|
+
var React22 = __toESM(require("react"));
|
|
2862
|
+
var import_react12 = require("react");
|
|
2863
|
+
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
2864
|
+
var import_editor_ui10 = require("@elementor/editor-ui");
|
|
2865
|
+
var import_ui18 = require("@elementor/ui");
|
|
1810
2866
|
function OverridePropsGroup({ group, props }) {
|
|
1811
|
-
const [isOpen, setIsOpen] = (0,
|
|
2867
|
+
const [isOpen, setIsOpen] = (0, import_editor_editing_panel2.useStateByElement)(group.id, true);
|
|
1812
2868
|
const handleClick = () => {
|
|
1813
2869
|
setIsOpen(!isOpen);
|
|
1814
2870
|
};
|
|
1815
|
-
const
|
|
1816
|
-
const labelId = `label-${
|
|
1817
|
-
const contentId = `content-${
|
|
2871
|
+
const id2 = (0, import_react12.useId)();
|
|
2872
|
+
const labelId = `label-${id2}`;
|
|
2873
|
+
const contentId = `content-${id2}`;
|
|
1818
2874
|
const title = group.label;
|
|
1819
|
-
return /* @__PURE__ */
|
|
1820
|
-
|
|
2875
|
+
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement(
|
|
2876
|
+
import_ui18.ListItemButton,
|
|
1821
2877
|
{
|
|
1822
2878
|
id: labelId,
|
|
1823
2879
|
"aria-controls": contentId,
|
|
@@ -1826,45 +2882,45 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1826
2882
|
p: 0,
|
|
1827
2883
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
1828
2884
|
},
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
|
|
2885
|
+
/* @__PURE__ */ React22.createElement(import_ui18.Stack, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React22.createElement(
|
|
2886
|
+
import_ui18.ListItemText,
|
|
1831
2887
|
{
|
|
1832
2888
|
secondary: title,
|
|
1833
2889
|
secondaryTypographyProps: { color: "text.primary", variant: "caption", fontWeight: "bold" },
|
|
1834
2890
|
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
1835
2891
|
}
|
|
1836
2892
|
)),
|
|
1837
|
-
/* @__PURE__ */
|
|
1838
|
-
), /* @__PURE__ */
|
|
2893
|
+
/* @__PURE__ */ React22.createElement(import_editor_ui10.CollapseIcon, { open: isOpen, color: "secondary", fontSize: "tiny" })
|
|
2894
|
+
), /* @__PURE__ */ React22.createElement(import_ui18.Collapse, { id: contentId, "aria-labelledby": labelId, in: isOpen, timeout: "auto" }, /* @__PURE__ */ React22.createElement(import_ui18.Stack, { direction: "column", gap: 1, p: 2 }, group.props.map((propId) => (
|
|
1839
2895
|
// TODO: Render actual controls
|
|
1840
|
-
/* @__PURE__ */
|
|
2896
|
+
/* @__PURE__ */ React22.createElement("pre", { key: propId }, JSON.stringify(props[propId], null, 2))
|
|
1841
2897
|
)))));
|
|
1842
2898
|
}
|
|
1843
2899
|
|
|
1844
2900
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
1845
2901
|
function InstanceEditingPanel() {
|
|
1846
|
-
const { element } = (0,
|
|
1847
|
-
const settings = (0,
|
|
1848
|
-
const componentId =
|
|
1849
|
-
const component = componentId ? selectComponent((0,
|
|
1850
|
-
const overridableProps = componentId ? selectOverridableProps((0,
|
|
1851
|
-
const componentInstanceId = (0,
|
|
2902
|
+
const { element } = (0, import_editor_editing_panel3.useElement)();
|
|
2903
|
+
const settings = (0, import_editor_elements8.useElementSetting)(element.id, "component_instance");
|
|
2904
|
+
const componentId = componentInstancePropTypeUtil.extract(settings)?.component_id?.value;
|
|
2905
|
+
const component = componentId ? selectComponent((0, import_store42.__getState)(), componentId) : null;
|
|
2906
|
+
const overridableProps = componentId ? selectOverridableProps((0, import_store42.__getState)(), componentId) : null;
|
|
2907
|
+
const componentInstanceId = (0, import_editor_elements8.useSelectedElement)()?.element?.id ?? null;
|
|
1852
2908
|
if (!componentId || !overridableProps || !component) {
|
|
1853
2909
|
return null;
|
|
1854
2910
|
}
|
|
1855
|
-
const panelTitle = (0,
|
|
2911
|
+
const panelTitle = (0, import_i18n21.__)("Edit %s", "elementor").replace("%s", component.name);
|
|
1856
2912
|
const handleEditComponent = () => switchToComponent(componentId, componentInstanceId);
|
|
1857
2913
|
const groups = overridableProps.groups.order.map(
|
|
1858
2914
|
(groupId) => overridableProps.groups.items[groupId] ? overridableProps.groups.items[groupId] : null
|
|
1859
2915
|
).filter(Boolean);
|
|
1860
2916
|
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
1861
|
-
return /* @__PURE__ */
|
|
2917
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(import_editor_panels3.PanelHeader, { sx: { justifyContent: "start", px: 2 } }, /* @__PURE__ */ React23.createElement(import_ui19.Stack, { direction: "row", alignContent: "space-between", flexGrow: 1 }, /* @__PURE__ */ React23.createElement(import_ui19.Stack, { direction: "row", alignItems: "center", justifyContent: "start", gap: 1, flexGrow: 1 }, /* @__PURE__ */ React23.createElement(import_icons14.ComponentsIcon, { fontSize: "small", sx: { color: "text.tertiary" } }), /* @__PURE__ */ React23.createElement(import_editor_panels3.PanelHeaderTitle, null, component.name)), /* @__PURE__ */ React23.createElement(import_ui19.Tooltip, { title: panelTitle }, /* @__PURE__ */ React23.createElement(import_ui19.IconButton, { size: "tiny", onClick: handleEditComponent, "aria-label": panelTitle }, /* @__PURE__ */ React23.createElement(import_icons14.PencilIcon, { fontSize: "tiny" }))))), /* @__PURE__ */ React23.createElement(import_editor_panels3.PanelBody, null, isEmpty ? /* @__PURE__ */ React23.createElement(EmptyState2, { onEditComponent: handleEditComponent }) : /* @__PURE__ */ React23.createElement(import_ui19.Stack, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React23.createElement(OverridePropsGroup, { key: group.id, group, props: overridableProps.props })))));
|
|
1862
2918
|
}
|
|
1863
2919
|
|
|
1864
2920
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
1865
|
-
var
|
|
1866
|
-
var
|
|
1867
|
-
var
|
|
2921
|
+
var React25 = __toESM(require("react"));
|
|
2922
|
+
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
2923
|
+
var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
|
|
1868
2924
|
|
|
1869
2925
|
// src/prop-types/component-overridable-prop-type.ts
|
|
1870
2926
|
var import_editor_props4 = require("@elementor/editor-props");
|
|
@@ -1881,18 +2937,18 @@ var componentOverridablePropTypeUtil = (0, import_editor_props4.createPropUtils)
|
|
|
1881
2937
|
);
|
|
1882
2938
|
|
|
1883
2939
|
// src/provider/overridable-prop-context.tsx
|
|
1884
|
-
var
|
|
1885
|
-
var
|
|
1886
|
-
var OverridablePropContext = (0,
|
|
2940
|
+
var React24 = __toESM(require("react"));
|
|
2941
|
+
var import_react13 = require("react");
|
|
2942
|
+
var OverridablePropContext = (0, import_react13.createContext)(null);
|
|
1887
2943
|
function OverridablePropProvider({ children, ...props }) {
|
|
1888
|
-
return /* @__PURE__ */
|
|
2944
|
+
return /* @__PURE__ */ React24.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
1889
2945
|
}
|
|
1890
|
-
var useOverridablePropValue = () => (0,
|
|
2946
|
+
var useOverridablePropValue = () => (0, import_react13.useContext)(OverridablePropContext)?.value;
|
|
1891
2947
|
|
|
1892
2948
|
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
1893
|
-
var
|
|
2949
|
+
var import_store44 = require("@elementor/store");
|
|
1894
2950
|
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
1895
|
-
const overridableProps = selectOverridableProps((0,
|
|
2951
|
+
const overridableProps = selectOverridableProps((0, import_store44.__getState)(), componentId);
|
|
1896
2952
|
if (!overridableProps) {
|
|
1897
2953
|
return;
|
|
1898
2954
|
}
|
|
@@ -1910,7 +2966,7 @@ function updateOverridablePropOriginValue(componentId, propValue) {
|
|
|
1910
2966
|
}
|
|
1911
2967
|
}
|
|
1912
2968
|
};
|
|
1913
|
-
(0,
|
|
2969
|
+
(0, import_store44.__dispatch)(
|
|
1914
2970
|
slice.actions.setOverridableProps({
|
|
1915
2971
|
componentId,
|
|
1916
2972
|
overridableProps: newOverridableProps
|
|
@@ -1923,8 +2979,8 @@ function OverridablePropControl({
|
|
|
1923
2979
|
OriginalControl,
|
|
1924
2980
|
...props
|
|
1925
2981
|
}) {
|
|
1926
|
-
const { elementType } = (0,
|
|
1927
|
-
const { value, bind, setValue, placeholder, ...propContext } = (0,
|
|
2982
|
+
const { elementType } = (0, import_editor_editing_panel4.useElement)();
|
|
2983
|
+
const { value, bind, setValue, placeholder, ...propContext } = (0, import_editor_controls2.useBoundProp)(componentOverridablePropTypeUtil);
|
|
1928
2984
|
const componentId = useCurrentComponentId();
|
|
1929
2985
|
if (!componentId) {
|
|
1930
2986
|
return null;
|
|
@@ -1940,14 +2996,14 @@ function OverridablePropControl({
|
|
|
1940
2996
|
setValue(propValue);
|
|
1941
2997
|
updateOverridablePropOriginValue(componentId, propValue);
|
|
1942
2998
|
};
|
|
1943
|
-
const propType = (0,
|
|
2999
|
+
const propType = (0, import_editor_editing_panel4.createTopLevelObjectType)({
|
|
1944
3000
|
schema: {
|
|
1945
3001
|
[bind]: elementType.propsSchema[bind]
|
|
1946
3002
|
}
|
|
1947
3003
|
});
|
|
1948
3004
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
1949
|
-
return /* @__PURE__ */
|
|
1950
|
-
|
|
3005
|
+
return /* @__PURE__ */ React25.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React25.createElement(
|
|
3006
|
+
import_editor_controls2.PropProvider,
|
|
1951
3007
|
{
|
|
1952
3008
|
...propContext,
|
|
1953
3009
|
propType,
|
|
@@ -1955,23 +3011,22 @@ function OverridablePropControl({
|
|
|
1955
3011
|
value: { [bind]: value.origin_value },
|
|
1956
3012
|
placeholder: objectPlaceholder
|
|
1957
3013
|
},
|
|
1958
|
-
/* @__PURE__ */
|
|
3014
|
+
/* @__PURE__ */ React25.createElement(import_editor_controls2.PropKeyProvider, { bind }, /* @__PURE__ */ React25.createElement(import_editor_controls2.ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React25.createElement(OriginalControl, { ...props })))
|
|
1959
3015
|
));
|
|
1960
3016
|
}
|
|
1961
3017
|
|
|
1962
3018
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1963
|
-
var
|
|
1964
|
-
var
|
|
1965
|
-
var
|
|
1966
|
-
var
|
|
1967
|
-
var
|
|
1968
|
-
var
|
|
1969
|
-
var
|
|
3019
|
+
var React27 = __toESM(require("react"));
|
|
3020
|
+
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
3021
|
+
var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
|
|
3022
|
+
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3023
|
+
var import_store51 = require("@elementor/store");
|
|
3024
|
+
var import_ui21 = require("@elementor/ui");
|
|
3025
|
+
var import_i18n23 = require("@wordpress/i18n");
|
|
1970
3026
|
|
|
1971
3027
|
// src/store/actions/set-overridable-prop.ts
|
|
1972
|
-
var
|
|
1973
|
-
var
|
|
1974
|
-
var import_i18n13 = require("@wordpress/i18n");
|
|
3028
|
+
var import_store47 = require("@elementor/store");
|
|
3029
|
+
var import_utils7 = require("@elementor/utils");
|
|
1975
3030
|
function setOverridableProp({
|
|
1976
3031
|
componentId,
|
|
1977
3032
|
overrideKey,
|
|
@@ -1983,7 +3038,7 @@ function setOverridableProp({
|
|
|
1983
3038
|
widgetType,
|
|
1984
3039
|
originValue
|
|
1985
3040
|
}) {
|
|
1986
|
-
const overridableProps = selectOverridableProps((0,
|
|
3041
|
+
const overridableProps = selectOverridableProps((0, import_store47.__getState)(), componentId);
|
|
1987
3042
|
if (!overridableProps) {
|
|
1988
3043
|
return;
|
|
1989
3044
|
}
|
|
@@ -1991,13 +3046,12 @@ function setOverridableProp({
|
|
|
1991
3046
|
const duplicatedTargetProps = Object.values(overridableProps.props).filter(
|
|
1992
3047
|
(prop) => prop.elementId === elementId && prop.propKey === propKey && prop !== existingOverridableProp
|
|
1993
3048
|
);
|
|
1994
|
-
const {
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
groupId || existingOverridableProp?.groupId
|
|
3049
|
+
const { groups: groupsAfterResolve, groupId: currentGroupId } = resolveOrCreateGroup(
|
|
3050
|
+
overridableProps.groups,
|
|
3051
|
+
groupId || existingOverridableProp?.groupId || void 0
|
|
1998
3052
|
);
|
|
1999
3053
|
const overridableProp = {
|
|
2000
|
-
overrideKey: existingOverridableProp?.overrideKey || (0,
|
|
3054
|
+
overrideKey: existingOverridableProp?.overrideKey || (0, import_utils7.generateUniqueId)("prop"),
|
|
2001
3055
|
label,
|
|
2002
3056
|
elementId,
|
|
2003
3057
|
propKey,
|
|
@@ -2006,31 +3060,21 @@ function setOverridableProp({
|
|
|
2006
3060
|
originValue,
|
|
2007
3061
|
groupId: currentGroupId
|
|
2008
3062
|
};
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
});
|
|
3063
|
+
const stateAfterRemovingDuplicates = removePropsFromState(
|
|
3064
|
+
{ ...overridableProps, groups: groupsAfterResolve },
|
|
3065
|
+
duplicatedTargetProps
|
|
3066
|
+
);
|
|
2014
3067
|
const props = {
|
|
2015
|
-
...
|
|
3068
|
+
...stateAfterRemovingDuplicates.props,
|
|
2016
3069
|
[overridableProp.overrideKey]: overridableProp
|
|
2017
3070
|
};
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
...groupsWithoutDuplicates.items,
|
|
2021
|
-
[currentGroupId]: getGroupWithProp(groupsWithoutDuplicates, currentGroupId, overridableProp)
|
|
2022
|
-
},
|
|
2023
|
-
order: groupsWithoutDuplicates.order.includes(currentGroupId) ? groupsWithoutDuplicates.order : [...groupsWithoutDuplicates.order, currentGroupId]
|
|
2024
|
-
};
|
|
3071
|
+
let groups = addPropToGroup(stateAfterRemovingDuplicates.groups, currentGroupId, overridableProp.overrideKey);
|
|
3072
|
+
groups = ensureGroupInOrder(groups, currentGroupId);
|
|
2025
3073
|
const isChangingGroups = existingOverridableProp && existingOverridableProp.groupId !== currentGroupId;
|
|
2026
3074
|
if (isChangingGroups) {
|
|
2027
|
-
groups
|
|
2028
|
-
groupsWithoutDuplicates,
|
|
2029
|
-
existingOverridableProp.groupId,
|
|
2030
|
-
overridableProp
|
|
2031
|
-
);
|
|
3075
|
+
groups = removePropFromGroup(groups, existingOverridableProp.groupId, overridableProp.overrideKey);
|
|
2032
3076
|
}
|
|
2033
|
-
(0,
|
|
3077
|
+
(0, import_store47.__dispatch)(
|
|
2034
3078
|
slice.actions.setOverridableProps({
|
|
2035
3079
|
componentId,
|
|
2036
3080
|
overridableProps: {
|
|
@@ -2041,83 +3085,15 @@ function setOverridableProp({
|
|
|
2041
3085
|
);
|
|
2042
3086
|
return overridableProp;
|
|
2043
3087
|
}
|
|
2044
|
-
function getUpdatedGroups(groups, groupId) {
|
|
2045
|
-
if (!groupId) {
|
|
2046
|
-
if (groups.order.length > 0) {
|
|
2047
|
-
return { groups, currentGroupId: groups.order[0] };
|
|
2048
|
-
}
|
|
2049
|
-
return addNewGroup(groups);
|
|
2050
|
-
}
|
|
2051
|
-
if (!groups.items[groupId]) {
|
|
2052
|
-
return addNewGroup(groups, groupId);
|
|
2053
|
-
}
|
|
2054
|
-
return { groups, currentGroupId: groupId };
|
|
2055
|
-
}
|
|
2056
|
-
function addNewGroup(groups, groupId) {
|
|
2057
|
-
const currentGroupId = groupId || (0, import_utils5.generateUniqueId)("group");
|
|
2058
|
-
const updatedGroups = {
|
|
2059
|
-
...groups,
|
|
2060
|
-
items: {
|
|
2061
|
-
...groups.items,
|
|
2062
|
-
[currentGroupId]: {
|
|
2063
|
-
id: currentGroupId,
|
|
2064
|
-
label: (0, import_i18n13.__)("Default", "elementor"),
|
|
2065
|
-
props: []
|
|
2066
|
-
}
|
|
2067
|
-
},
|
|
2068
|
-
order: [...groups.order, currentGroupId]
|
|
2069
|
-
};
|
|
2070
|
-
return { groups: updatedGroups, currentGroupId };
|
|
2071
|
-
}
|
|
2072
|
-
function getGroupWithProp(groups, groupId, overridableProp) {
|
|
2073
|
-
const group = { ...groups.items[groupId] };
|
|
2074
|
-
if (!group.props.includes(overridableProp.overrideKey)) {
|
|
2075
|
-
group.props = [...group.props, overridableProp.overrideKey];
|
|
2076
|
-
}
|
|
2077
|
-
return group;
|
|
2078
|
-
}
|
|
2079
|
-
function getGroupWithoutProp(groups, groupId, overridableProp) {
|
|
2080
|
-
const group = { ...groups.items[groupId] };
|
|
2081
|
-
if (group) {
|
|
2082
|
-
group.props = group.props.filter((key) => key !== overridableProp.overrideKey);
|
|
2083
|
-
}
|
|
2084
|
-
return group;
|
|
2085
|
-
}
|
|
2086
|
-
function removeProps({
|
|
2087
|
-
props,
|
|
2088
|
-
groups,
|
|
2089
|
-
propsToRemove
|
|
2090
|
-
}) {
|
|
2091
|
-
const allProps = Object.fromEntries(
|
|
2092
|
-
Object.entries(props).filter(([, prop]) => !propsToRemove.includes(prop))
|
|
2093
|
-
);
|
|
2094
|
-
const overrideKeysToRemove = propsToRemove.map((prop) => prop.overrideKey);
|
|
2095
|
-
const allGroupItems = Object.fromEntries(
|
|
2096
|
-
Object.entries(groups.items).map(([groupId, group]) => [
|
|
2097
|
-
groupId,
|
|
2098
|
-
{
|
|
2099
|
-
...group,
|
|
2100
|
-
props: group.props.filter((prop) => !overrideKeysToRemove.includes(prop))
|
|
2101
|
-
}
|
|
2102
|
-
])
|
|
2103
|
-
);
|
|
2104
|
-
return {
|
|
2105
|
-
props: allProps,
|
|
2106
|
-
groups: {
|
|
2107
|
-
items: allGroupItems,
|
|
2108
|
-
order: groups.order.filter((groupId) => !overrideKeysToRemove.includes(groupId))
|
|
2109
|
-
}
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
3088
|
|
|
2113
3089
|
// src/components/overridable-props/indicator.tsx
|
|
2114
|
-
var
|
|
2115
|
-
var
|
|
2116
|
-
var
|
|
2117
|
-
var
|
|
2118
|
-
var
|
|
2119
|
-
var
|
|
2120
|
-
var IconContainer = (0,
|
|
3090
|
+
var React26 = __toESM(require("react"));
|
|
3091
|
+
var import_react14 = require("react");
|
|
3092
|
+
var import_icons15 = require("@elementor/icons");
|
|
3093
|
+
var import_ui20 = require("@elementor/ui");
|
|
3094
|
+
var import_i18n22 = require("@wordpress/i18n");
|
|
3095
|
+
var SIZE2 = "tiny";
|
|
3096
|
+
var IconContainer = (0, import_ui20.styled)(import_ui20.Box)`
|
|
2121
3097
|
pointer-events: none;
|
|
2122
3098
|
opacity: 0;
|
|
2123
3099
|
transition: opacity 0.2s ease-in-out;
|
|
@@ -2134,7 +3110,7 @@ var IconContainer = (0, import_ui12.styled)(import_ui12.Box)`
|
|
|
2134
3110
|
stroke-width: 2px;
|
|
2135
3111
|
}
|
|
2136
3112
|
`;
|
|
2137
|
-
var Content = (0,
|
|
3113
|
+
var Content = (0, import_ui20.styled)(import_ui20.Box)`
|
|
2138
3114
|
position: relative;
|
|
2139
3115
|
display: flex;
|
|
2140
3116
|
align-items: center;
|
|
@@ -2171,79 +3147,22 @@ var Content = (0, import_ui12.styled)(import_ui12.Box)`
|
|
|
2171
3147
|
}
|
|
2172
3148
|
}
|
|
2173
3149
|
`;
|
|
2174
|
-
var Indicator = (0,
|
|
3150
|
+
var Indicator = (0, import_react14.forwardRef)(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React26.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React26.createElement(
|
|
2175
3151
|
IconContainer,
|
|
2176
3152
|
{
|
|
2177
3153
|
className: "icon",
|
|
2178
|
-
"aria-label": isOverridable ? (0,
|
|
3154
|
+
"aria-label": isOverridable ? (0, import_i18n22.__)("Overridable property", "elementor") : (0, import_i18n22.__)("Make prop overridable", "elementor")
|
|
2179
3155
|
},
|
|
2180
|
-
isOverridable ? /* @__PURE__ */
|
|
3156
|
+
isOverridable ? /* @__PURE__ */ React26.createElement(import_icons15.CheckIcon, { fontSize: SIZE2 }) : /* @__PURE__ */ React26.createElement(import_icons15.PlusIcon, { fontSize: SIZE2 })
|
|
2181
3157
|
)));
|
|
2182
3158
|
|
|
2183
|
-
// src/components/overridable-props/overridable-prop-form.tsx
|
|
2184
|
-
var React19 = __toESM(require("react"));
|
|
2185
|
-
var import_react12 = require("react");
|
|
2186
|
-
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2187
|
-
var import_ui13 = require("@elementor/ui");
|
|
2188
|
-
var import_i18n15 = require("@wordpress/i18n");
|
|
2189
|
-
var SIZE2 = "tiny";
|
|
2190
|
-
var DEFAULT_GROUP = { value: null, label: (0, import_i18n15.__)("Default", "elementor") };
|
|
2191
|
-
function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
2192
|
-
const [propLabel, setPropLabel] = (0, import_react12.useState)(currentValue?.label ?? null);
|
|
2193
|
-
const [group, setGroup] = (0, import_react12.useState)(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
2194
|
-
const name = (0, import_i18n15.__)("Name", "elementor");
|
|
2195
|
-
const groupName = (0, import_i18n15.__)("Group Name", "elementor");
|
|
2196
|
-
const isCreate = currentValue === void 0;
|
|
2197
|
-
const title = isCreate ? (0, import_i18n15.__)("Create new property", "elementor") : (0, import_i18n15.__)("Update property", "elementor");
|
|
2198
|
-
const ctaLabel = isCreate ? (0, import_i18n15.__)("Create", "elementor") : (0, import_i18n15.__)("Update", "elementor");
|
|
2199
|
-
return /* @__PURE__ */ React19.createElement(import_editor_ui6.Form, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React19.createElement(import_ui13.Stack, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React19.createElement(
|
|
2200
|
-
import_ui13.Stack,
|
|
2201
|
-
{
|
|
2202
|
-
direction: "row",
|
|
2203
|
-
alignItems: "center",
|
|
2204
|
-
py: 1,
|
|
2205
|
-
px: 1.5,
|
|
2206
|
-
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
2207
|
-
},
|
|
2208
|
-
/* @__PURE__ */ React19.createElement(import_ui13.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
2209
|
-
), /* @__PURE__ */ React19.createElement(import_ui13.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React19.createElement(import_ui13.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(import_ui13.FormLabel, { size: "tiny" }, name)), /* @__PURE__ */ React19.createElement(import_ui13.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(
|
|
2210
|
-
import_ui13.TextField,
|
|
2211
|
-
{
|
|
2212
|
-
name,
|
|
2213
|
-
size: SIZE2,
|
|
2214
|
-
fullWidth: true,
|
|
2215
|
-
placeholder: (0, import_i18n15.__)("Enter value", "elementor"),
|
|
2216
|
-
value: propLabel ?? "",
|
|
2217
|
-
onChange: (e) => setPropLabel(e.target.value)
|
|
2218
|
-
}
|
|
2219
|
-
))), /* @__PURE__ */ React19.createElement(import_ui13.Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React19.createElement(import_ui13.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(import_ui13.FormLabel, { size: "tiny" }, groupName)), /* @__PURE__ */ React19.createElement(import_ui13.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(
|
|
2220
|
-
import_ui13.Select,
|
|
2221
|
-
{
|
|
2222
|
-
name: groupName,
|
|
2223
|
-
size: SIZE2,
|
|
2224
|
-
fullWidth: true,
|
|
2225
|
-
value: group ?? null,
|
|
2226
|
-
onChange: setGroup,
|
|
2227
|
-
displayEmpty: true,
|
|
2228
|
-
renderValue: (selectedValue) => {
|
|
2229
|
-
if (!selectedValue || selectedValue === "") {
|
|
2230
|
-
const [firstGroup = DEFAULT_GROUP] = groups ?? [];
|
|
2231
|
-
return firstGroup.label;
|
|
2232
|
-
}
|
|
2233
|
-
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
2234
|
-
}
|
|
2235
|
-
},
|
|
2236
|
-
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React19.createElement(import_editor_ui6.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
2237
|
-
))), /* @__PURE__ */ React19.createElement(import_ui13.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React19.createElement(import_ui13.Button, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
3159
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
2241
|
-
var
|
|
3160
|
+
var import_store49 = require("@elementor/store");
|
|
2242
3161
|
function getOverridableProp({
|
|
2243
3162
|
componentId,
|
|
2244
3163
|
overrideKey
|
|
2245
3164
|
}) {
|
|
2246
|
-
const overridableProps = selectOverridableProps((0,
|
|
3165
|
+
const overridableProps = selectOverridableProps((0, import_store49.__getState)(), componentId);
|
|
2247
3166
|
if (!overridableProps) {
|
|
2248
3167
|
return void 0;
|
|
2249
3168
|
}
|
|
@@ -2253,31 +3172,31 @@ function getOverridableProp({
|
|
|
2253
3172
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
2254
3173
|
var FORBIDDEN_KEYS = ["_cssid", "attributes"];
|
|
2255
3174
|
function OverridablePropIndicator() {
|
|
2256
|
-
const { bind } = (0,
|
|
3175
|
+
const { bind } = (0, import_editor_controls3.useBoundProp)();
|
|
2257
3176
|
const componentId = useCurrentComponentId();
|
|
2258
3177
|
if (!isPropAllowed(bind) || !componentId) {
|
|
2259
3178
|
return null;
|
|
2260
3179
|
}
|
|
2261
|
-
const overridableProps = selectOverridableProps((0,
|
|
2262
|
-
return /* @__PURE__ */
|
|
3180
|
+
const overridableProps = selectOverridableProps((0, import_store51.__getState)(), componentId);
|
|
3181
|
+
return /* @__PURE__ */ React27.createElement(Content2, { componentId, overridableProps });
|
|
2263
3182
|
}
|
|
2264
3183
|
function Content2({ componentId, overridableProps }) {
|
|
2265
3184
|
const {
|
|
2266
3185
|
element: { id: elementId },
|
|
2267
3186
|
elementType
|
|
2268
|
-
} = (0,
|
|
2269
|
-
const { value, bind, propType } = (0,
|
|
3187
|
+
} = (0, import_editor_editing_panel5.useElement)();
|
|
3188
|
+
const { value, bind, propType } = (0, import_editor_controls3.useBoundProp)();
|
|
2270
3189
|
const contextOverridableValue = useOverridablePropValue();
|
|
2271
|
-
const { value: boundPropOverridableValue, setValue: setOverridableValue } = (0,
|
|
3190
|
+
const { value: boundPropOverridableValue, setValue: setOverridableValue } = (0, import_editor_controls3.useBoundProp)(
|
|
2272
3191
|
componentOverridablePropTypeUtil
|
|
2273
3192
|
);
|
|
2274
3193
|
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
2275
|
-
const popupState = (0,
|
|
3194
|
+
const popupState = (0, import_ui21.usePopupState)({
|
|
2276
3195
|
variant: "popover"
|
|
2277
3196
|
});
|
|
2278
|
-
const triggerProps = (0,
|
|
2279
|
-
const popoverProps = (0,
|
|
2280
|
-
const { elType } = (0,
|
|
3197
|
+
const triggerProps = (0, import_ui21.bindTrigger)(popupState);
|
|
3198
|
+
const popoverProps = (0, import_ui21.bindPopover)(popupState);
|
|
3199
|
+
const { elType } = (0, import_editor_elements9.getWidgetsCache)()?.[elementType.key] ?? { elType: "widget" };
|
|
2281
3200
|
const handleSubmit = ({ label, group }) => {
|
|
2282
3201
|
const originValue = !overridableValue ? value ?? propType.default : overridableValue?.origin_value ?? {};
|
|
2283
3202
|
const overridablePropConfig = setOverridableProp({
|
|
@@ -2300,8 +3219,8 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2300
3219
|
popupState.close();
|
|
2301
3220
|
};
|
|
2302
3221
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
2303
|
-
return /* @__PURE__ */
|
|
2304
|
-
|
|
3222
|
+
return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(import_ui21.Tooltip, { placement: "top", title: (0, import_i18n23.__)("Override Property", "elementor") }, /* @__PURE__ */ React27.createElement(Indicator, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React27.createElement(
|
|
3223
|
+
import_ui21.Popover,
|
|
2305
3224
|
{
|
|
2306
3225
|
disableScrollLock: true,
|
|
2307
3226
|
anchorOrigin: {
|
|
@@ -2317,7 +3236,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2317
3236
|
},
|
|
2318
3237
|
...popoverProps
|
|
2319
3238
|
},
|
|
2320
|
-
/* @__PURE__ */
|
|
3239
|
+
/* @__PURE__ */ React27.createElement(
|
|
2321
3240
|
OverridablePropForm,
|
|
2322
3241
|
{
|
|
2323
3242
|
onSubmit: handleSubmit,
|
|
@@ -2339,11 +3258,11 @@ var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
|
2339
3258
|
|
|
2340
3259
|
// src/mcp/save-as-component-tool.ts
|
|
2341
3260
|
var import_editor_canvas7 = require("@elementor/editor-canvas");
|
|
2342
|
-
var
|
|
3261
|
+
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
2343
3262
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2344
3263
|
var import_http_client2 = require("@elementor/http-client");
|
|
2345
3264
|
var import_schema6 = require("@elementor/schema");
|
|
2346
|
-
var
|
|
3265
|
+
var import_utils8 = require("@elementor/utils");
|
|
2347
3266
|
var InputSchema = {
|
|
2348
3267
|
element_id: import_schema6.z.string().describe(
|
|
2349
3268
|
'The unique identifier of the element to save as a component. Use the "list-elements" tool to find available element IDs in the current document.'
|
|
@@ -2366,7 +3285,7 @@ var OutputSchema = {
|
|
|
2366
3285
|
message: import_schema6.z.string().optional().describe("Additional information about the operation result"),
|
|
2367
3286
|
component_uid: import_schema6.z.string().optional().describe("The unique identifier of the newly created component (only present on success)")
|
|
2368
3287
|
};
|
|
2369
|
-
var
|
|
3288
|
+
var ERROR_MESSAGES2 = {
|
|
2370
3289
|
ELEMENT_NOT_FOUND: "Element not found. Use 'list-elements' to get valid element IDs.",
|
|
2371
3290
|
ELEMENT_NOT_ONE_OF_TYPES: (validTypes) => `Element is not one of the following types: ${validTypes.join(", ")}`,
|
|
2372
3291
|
ELEMENT_IS_LOCKED: "Cannot save a locked element as a component."
|
|
@@ -2374,23 +3293,23 @@ var ERROR_MESSAGES = {
|
|
|
2374
3293
|
var handleSaveAsComponent = async (params) => {
|
|
2375
3294
|
const { element_id: elementId, component_name: componentName, overridable_props: overridablePropsInput } = params;
|
|
2376
3295
|
const validElementTypes = getValidElementTypes();
|
|
2377
|
-
const container = (0,
|
|
3296
|
+
const container = (0, import_editor_elements10.getContainer)(elementId);
|
|
2378
3297
|
if (!container) {
|
|
2379
|
-
throw new Error(
|
|
3298
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_NOT_FOUND);
|
|
2380
3299
|
}
|
|
2381
3300
|
const elType = container.model.get("elType");
|
|
2382
3301
|
if (!validElementTypes.includes(elType)) {
|
|
2383
|
-
throw new Error(
|
|
3302
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_NOT_ONE_OF_TYPES(validElementTypes));
|
|
2384
3303
|
}
|
|
2385
3304
|
const element = container.model.toJSON({ remove: ["default"] });
|
|
2386
3305
|
if (element?.isLocked) {
|
|
2387
|
-
throw new Error(
|
|
3306
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_IS_LOCKED);
|
|
2388
3307
|
}
|
|
2389
3308
|
const overridableProps = overridablePropsInput ? enrichOverridableProps(overridablePropsInput, element) : void 0;
|
|
2390
3309
|
if (overridableProps) {
|
|
2391
3310
|
updateElementDataWithOverridableProps(element, overridableProps);
|
|
2392
3311
|
}
|
|
2393
|
-
const uid = (0,
|
|
3312
|
+
const uid = (0, import_utils8.generateUniqueId)("component");
|
|
2394
3313
|
try {
|
|
2395
3314
|
await apiClient.validate({
|
|
2396
3315
|
items: [
|
|
@@ -2412,7 +3331,7 @@ var handleSaveAsComponent = async (params) => {
|
|
|
2412
3331
|
};
|
|
2413
3332
|
function enrichOverridableProps(input, rootElement) {
|
|
2414
3333
|
const enrichedProps = {};
|
|
2415
|
-
const defaultGroupId = (0,
|
|
3334
|
+
const defaultGroupId = (0, import_utils8.generateUniqueId)("group");
|
|
2416
3335
|
Object.entries(input.props).forEach(([, prop]) => {
|
|
2417
3336
|
const { elementId, propKey } = prop;
|
|
2418
3337
|
const element = findElementById(rootElement, elementId);
|
|
@@ -2421,7 +3340,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
2421
3340
|
}
|
|
2422
3341
|
const elType = element.elType;
|
|
2423
3342
|
const widgetType = element.widgetType || element.elType;
|
|
2424
|
-
const elementType = (0,
|
|
3343
|
+
const elementType = (0, import_editor_elements10.getElementType)(widgetType);
|
|
2425
3344
|
if (!elementType) {
|
|
2426
3345
|
throw new Error(
|
|
2427
3346
|
`Element type "${widgetType}" is not atomic or does not have a settings schema. Cannot expose property "${propKey}" for element "${elementId}".`
|
|
@@ -2433,7 +3352,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
2433
3352
|
`Property "${propKey}" does not exist in element "${elementId}" (type: ${widgetType}). Available properties: ${availableProps}`
|
|
2434
3353
|
);
|
|
2435
3354
|
}
|
|
2436
|
-
const overrideKey = (0,
|
|
3355
|
+
const overrideKey = (0, import_utils8.generateUniqueId)("prop");
|
|
2437
3356
|
const originValue = element.settings?.[propKey] ? element.settings[propKey] : elementType.propsSchema[propKey].default ?? null;
|
|
2438
3357
|
const label = generateLabel(propKey);
|
|
2439
3358
|
enrichedProps[overrideKey] = {
|
|
@@ -2491,11 +3410,11 @@ function findElementById(root, targetId) {
|
|
|
2491
3410
|
return null;
|
|
2492
3411
|
}
|
|
2493
3412
|
function generateLabel(propKey) {
|
|
2494
|
-
const uniqueId = (0,
|
|
3413
|
+
const uniqueId = (0, import_utils8.generateUniqueId)("prop");
|
|
2495
3414
|
return `${uniqueId} - ${propKey}`;
|
|
2496
3415
|
}
|
|
2497
3416
|
function getValidElementTypes() {
|
|
2498
|
-
const types = (0,
|
|
3417
|
+
const types = (0, import_editor_elements10.getWidgetsCache)();
|
|
2499
3418
|
if (!types) {
|
|
2500
3419
|
return [];
|
|
2501
3420
|
}
|
|
@@ -2667,29 +3586,29 @@ function initMcp() {
|
|
|
2667
3586
|
}
|
|
2668
3587
|
|
|
2669
3588
|
// src/populate-store.ts
|
|
2670
|
-
var
|
|
2671
|
-
var
|
|
3589
|
+
var import_react15 = require("react");
|
|
3590
|
+
var import_store53 = require("@elementor/store");
|
|
2672
3591
|
function PopulateStore() {
|
|
2673
|
-
(0,
|
|
2674
|
-
(0,
|
|
3592
|
+
(0, import_react15.useEffect)(() => {
|
|
3593
|
+
(0, import_store53.__dispatch)(loadComponents());
|
|
2675
3594
|
}, []);
|
|
2676
3595
|
return null;
|
|
2677
3596
|
}
|
|
2678
3597
|
|
|
2679
3598
|
// src/store/actions/remove-component-styles.ts
|
|
2680
|
-
var
|
|
2681
|
-
function removeComponentStyles(
|
|
2682
|
-
apiClient.invalidateComponentConfigCache(
|
|
2683
|
-
(0,
|
|
3599
|
+
var import_store54 = require("@elementor/store");
|
|
3600
|
+
function removeComponentStyles(id2) {
|
|
3601
|
+
apiClient.invalidateComponentConfigCache(id2);
|
|
3602
|
+
(0, import_store54.__dispatch)(slice.actions.removeStyles({ id: id2 }));
|
|
2684
3603
|
}
|
|
2685
3604
|
|
|
2686
3605
|
// src/store/components-styles-provider.ts
|
|
2687
3606
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
2688
|
-
var
|
|
3607
|
+
var import_store56 = require("@elementor/store");
|
|
2689
3608
|
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
2690
3609
|
key: "components-styles",
|
|
2691
3610
|
priority: 100,
|
|
2692
|
-
subscribe: (cb) => (0,
|
|
3611
|
+
subscribe: (cb) => (0, import_store56.__subscribeWithSelector)(
|
|
2693
3612
|
(state) => state[SLICE_NAME],
|
|
2694
3613
|
() => {
|
|
2695
3614
|
cb();
|
|
@@ -2697,29 +3616,29 @@ var componentsStylesProvider = (0, import_editor_styles_repository.createStylesP
|
|
|
2697
3616
|
),
|
|
2698
3617
|
actions: {
|
|
2699
3618
|
all: () => {
|
|
2700
|
-
return selectFlatStyles((0,
|
|
3619
|
+
return selectFlatStyles((0, import_store56.__getState)());
|
|
2701
3620
|
},
|
|
2702
|
-
get: (
|
|
2703
|
-
return selectFlatStyles((0,
|
|
3621
|
+
get: (id2) => {
|
|
3622
|
+
return selectFlatStyles((0, import_store56.__getState)()).find((style) => style.id === id2) ?? null;
|
|
2704
3623
|
}
|
|
2705
3624
|
}
|
|
2706
3625
|
});
|
|
2707
3626
|
|
|
2708
3627
|
// src/sync/create-components-before-save.ts
|
|
2709
|
-
var
|
|
2710
|
-
var
|
|
3628
|
+
var import_editor_elements11 = require("@elementor/editor-elements");
|
|
3629
|
+
var import_store58 = require("@elementor/store");
|
|
2711
3630
|
async function createComponentsBeforeSave({
|
|
2712
3631
|
elements,
|
|
2713
3632
|
status
|
|
2714
3633
|
}) {
|
|
2715
|
-
const unpublishedComponents = selectUnpublishedComponents((0,
|
|
3634
|
+
const unpublishedComponents = selectUnpublishedComponents((0, import_store58.__getState)());
|
|
2716
3635
|
if (!unpublishedComponents.length) {
|
|
2717
3636
|
return;
|
|
2718
3637
|
}
|
|
2719
3638
|
try {
|
|
2720
3639
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
2721
3640
|
updateComponentInstances(elements, uidToComponentId);
|
|
2722
|
-
(0,
|
|
3641
|
+
(0, import_store58.__dispatch)(
|
|
2723
3642
|
slice.actions.add(
|
|
2724
3643
|
unpublishedComponents.map((component) => ({
|
|
2725
3644
|
id: uidToComponentId.get(component.uid),
|
|
@@ -2729,7 +3648,7 @@ async function createComponentsBeforeSave({
|
|
|
2729
3648
|
}))
|
|
2730
3649
|
)
|
|
2731
3650
|
);
|
|
2732
|
-
(0,
|
|
3651
|
+
(0, import_store58.__dispatch)(slice.actions.resetUnpublished());
|
|
2733
3652
|
} catch (error) {
|
|
2734
3653
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
2735
3654
|
}
|
|
@@ -2771,7 +3690,7 @@ function shouldUpdateElement(element, uidToComponentId) {
|
|
|
2771
3690
|
return { shouldUpdate: false, newComponentId: null };
|
|
2772
3691
|
}
|
|
2773
3692
|
function updateElementComponentId(elementId, componentId) {
|
|
2774
|
-
(0,
|
|
3693
|
+
(0, import_editor_elements11.updateElementSettings)({
|
|
2775
3694
|
id: elementId,
|
|
2776
3695
|
props: {
|
|
2777
3696
|
component_instance: {
|
|
@@ -2786,7 +3705,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
2786
3705
|
}
|
|
2787
3706
|
|
|
2788
3707
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
2789
|
-
var
|
|
3708
|
+
var import_store60 = require("@elementor/store");
|
|
2790
3709
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
2791
3710
|
container
|
|
2792
3711
|
}) => {
|
|
@@ -2794,7 +3713,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2794
3713
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
2795
3714
|
return;
|
|
2796
3715
|
}
|
|
2797
|
-
const overridableProps = selectOverridableProps((0,
|
|
3716
|
+
const overridableProps = selectOverridableProps((0, import_store60.__getState)(), currentDocument.id);
|
|
2798
3717
|
if (overridableProps) {
|
|
2799
3718
|
container.settings.set("overridable_props", overridableProps);
|
|
2800
3719
|
}
|
|
@@ -2802,7 +3721,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2802
3721
|
|
|
2803
3722
|
// src/sync/update-archived-component-before-save.ts
|
|
2804
3723
|
var import_editor_notifications = require("@elementor/editor-notifications");
|
|
2805
|
-
var
|
|
3724
|
+
var import_store62 = require("@elementor/store");
|
|
2806
3725
|
var failedNotification = (message) => ({
|
|
2807
3726
|
type: "error",
|
|
2808
3727
|
message: `Failed to archive components: ${message}`,
|
|
@@ -2815,7 +3734,7 @@ var successNotification = (message) => ({
|
|
|
2815
3734
|
});
|
|
2816
3735
|
var updateArchivedComponentBeforeSave = async () => {
|
|
2817
3736
|
try {
|
|
2818
|
-
const archivedComponents = selectArchivedComponents((0,
|
|
3737
|
+
const archivedComponents = selectArchivedComponents((0, import_store62.__getState)());
|
|
2819
3738
|
if (!archivedComponents.length) {
|
|
2820
3739
|
return;
|
|
2821
3740
|
}
|
|
@@ -2836,19 +3755,19 @@ var updateArchivedComponentBeforeSave = async () => {
|
|
|
2836
3755
|
};
|
|
2837
3756
|
|
|
2838
3757
|
// src/sync/update-components-before-save.ts
|
|
2839
|
-
var
|
|
3758
|
+
var import_editor_documents11 = require("@elementor/editor-documents");
|
|
2840
3759
|
async function updateComponentsBeforeSave({ status, elements }) {
|
|
2841
3760
|
if (status !== "publish") {
|
|
2842
3761
|
return;
|
|
2843
3762
|
}
|
|
2844
3763
|
const componentIds = await getComponentIds(elements);
|
|
2845
3764
|
const componentDocumentData = await Promise.all(componentIds.map(getComponentDocumentData));
|
|
2846
|
-
const draftIds = componentDocumentData.filter((document) => !!document).filter(
|
|
3765
|
+
const draftIds = componentDocumentData.filter((document) => !!document).filter(import_editor_documents11.isDocumentDirty).map((document) => document.id);
|
|
2847
3766
|
if (draftIds.length === 0) {
|
|
2848
3767
|
return;
|
|
2849
3768
|
}
|
|
2850
3769
|
await apiClient.updateStatuses(draftIds, "publish");
|
|
2851
|
-
draftIds.forEach((
|
|
3770
|
+
draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
|
|
2852
3771
|
}
|
|
2853
3772
|
|
|
2854
3773
|
// src/sync/before-save.ts
|
|
@@ -2865,13 +3784,14 @@ var beforeSave = ({ container, status }) => {
|
|
|
2865
3784
|
// src/init.ts
|
|
2866
3785
|
function init() {
|
|
2867
3786
|
import_editor_styles_repository2.stylesRepository.register(componentsStylesProvider);
|
|
2868
|
-
(0,
|
|
3787
|
+
(0, import_store64.__registerSlice)(slice);
|
|
3788
|
+
(0, import_editor_panels4.__registerPanel)(panel);
|
|
2869
3789
|
(0, import_editor_canvas8.registerElementType)(
|
|
2870
3790
|
TYPE,
|
|
2871
3791
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
2872
3792
|
);
|
|
2873
3793
|
(0, import_editor_v1_adapters6.registerDataHook)("dependency", "editor/documents/close", (args) => {
|
|
2874
|
-
const document = (0,
|
|
3794
|
+
const document = (0, import_editor_documents12.getV1CurrentDocument)();
|
|
2875
3795
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
2876
3796
|
args.mode = "autosave";
|
|
2877
3797
|
}
|
|
@@ -2881,7 +3801,7 @@ function init() {
|
|
|
2881
3801
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
2882
3802
|
(0, import_editor_elements_panel.injectTab)({
|
|
2883
3803
|
id: "components",
|
|
2884
|
-
label: (0,
|
|
3804
|
+
label: (0, import_i18n24.__)("Components", "elementor"),
|
|
2885
3805
|
component: Components
|
|
2886
3806
|
});
|
|
2887
3807
|
(0, import_editor.injectIntoTop)({
|
|
@@ -2896,28 +3816,28 @@ function init() {
|
|
|
2896
3816
|
id: "edit-component",
|
|
2897
3817
|
component: EditComponent
|
|
2898
3818
|
});
|
|
2899
|
-
(0,
|
|
3819
|
+
(0, import_editor_editing_panel6.injectIntoPanelHeaderTop)({
|
|
2900
3820
|
id: "component-panel-header",
|
|
2901
3821
|
component: ComponentPanelHeader
|
|
2902
3822
|
});
|
|
2903
3823
|
(0, import_editor_v1_adapters6.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
2904
|
-
const { id, config } = (0,
|
|
2905
|
-
if (
|
|
2906
|
-
removeComponentStyles(
|
|
3824
|
+
const { id: id2, config } = (0, import_editor_documents12.getV1CurrentDocument)();
|
|
3825
|
+
if (id2) {
|
|
3826
|
+
removeComponentStyles(id2);
|
|
2907
3827
|
}
|
|
2908
3828
|
await loadComponentsAssets(config?.elements ?? []);
|
|
2909
3829
|
});
|
|
2910
|
-
(0,
|
|
2911
|
-
fieldType:
|
|
3830
|
+
(0, import_editor_editing_panel6.registerFieldIndicator)({
|
|
3831
|
+
fieldType: import_editor_editing_panel6.FIELD_TYPE.SETTINGS,
|
|
2912
3832
|
id: "component-overridable-prop",
|
|
2913
3833
|
priority: 1,
|
|
2914
3834
|
indicator: OverridablePropIndicator
|
|
2915
3835
|
});
|
|
2916
|
-
(0,
|
|
3836
|
+
(0, import_editor_editing_panel6.registerControlReplacement)({
|
|
2917
3837
|
component: OverridablePropControl,
|
|
2918
3838
|
condition: ({ value }) => componentOverridablePropTypeUtil.isValid(value)
|
|
2919
3839
|
});
|
|
2920
|
-
(0,
|
|
3840
|
+
(0, import_editor_editing_panel6.registerEditingPanelReplacement)({
|
|
2921
3841
|
id: "component-instance-edit-panel",
|
|
2922
3842
|
condition: (_, elementType) => elementType.key === "e-component",
|
|
2923
3843
|
component: InstanceEditingPanel
|