@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.mjs
CHANGED
|
@@ -13,10 +13,11 @@ import {
|
|
|
13
13
|
registerFieldIndicator
|
|
14
14
|
} from "@elementor/editor-editing-panel";
|
|
15
15
|
import { injectTab } from "@elementor/editor-elements-panel";
|
|
16
|
+
import { __registerPanel as registerPanel } from "@elementor/editor-panels";
|
|
16
17
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
17
18
|
import { registerDataHook } from "@elementor/editor-v1-adapters";
|
|
18
19
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
19
|
-
import { __ as
|
|
20
|
+
import { __ as __24 } from "@wordpress/i18n";
|
|
20
21
|
|
|
21
22
|
// src/component-instance-transformer.ts
|
|
22
23
|
import { createTransformer, RenderContext } from "@elementor/editor-canvas";
|
|
@@ -36,10 +37,10 @@ import { __createAsyncThunk as createAsyncThunk } from "@elementor/store";
|
|
|
36
37
|
import { ajax } from "@elementor/editor-v1-adapters";
|
|
37
38
|
import { httpService } from "@elementor/http-client";
|
|
38
39
|
var BASE_URL = "elementor/v1/components";
|
|
39
|
-
var getParams = (
|
|
40
|
+
var getParams = (id2) => ({
|
|
40
41
|
action: "get_document_config",
|
|
41
|
-
unique_id: `document-config-${
|
|
42
|
-
data: { id }
|
|
42
|
+
unique_id: `document-config-${id2}`,
|
|
43
|
+
data: { id: id2 }
|
|
43
44
|
});
|
|
44
45
|
var apiClient = {
|
|
45
46
|
get: () => httpService().get(`${BASE_URL}`).then((res) => res.data.data),
|
|
@@ -48,8 +49,8 @@ var apiClient = {
|
|
|
48
49
|
ids,
|
|
49
50
|
status
|
|
50
51
|
}),
|
|
51
|
-
getComponentConfig: (
|
|
52
|
-
invalidateComponentConfigCache: (
|
|
52
|
+
getComponentConfig: (id2) => ajax.load(getParams(id2)),
|
|
53
|
+
invalidateComponentConfigCache: (id2) => ajax.invalidateCache(getParams(id2)),
|
|
53
54
|
getComponentLockStatus: async (componentId) => await httpService().get(`${BASE_URL}/lock-status`, {
|
|
54
55
|
params: {
|
|
55
56
|
componentId
|
|
@@ -232,17 +233,17 @@ var selectArchivedComponents = createSelector(
|
|
|
232
233
|
|
|
233
234
|
// src/utils/component-document-data.ts
|
|
234
235
|
import { getV1DocumentsManager } from "@elementor/editor-documents";
|
|
235
|
-
var getComponentDocumentData = async (
|
|
236
|
+
var getComponentDocumentData = async (id2) => {
|
|
236
237
|
const documentManager = getV1DocumentsManager();
|
|
237
238
|
try {
|
|
238
|
-
return await documentManager.request(
|
|
239
|
+
return await documentManager.request(id2);
|
|
239
240
|
} catch {
|
|
240
241
|
return null;
|
|
241
242
|
}
|
|
242
243
|
};
|
|
243
|
-
var invalidateComponentDocumentData = (
|
|
244
|
+
var invalidateComponentDocumentData = (id2) => {
|
|
244
245
|
const documentManager = getV1DocumentsManager();
|
|
245
|
-
documentManager.invalidateCache(
|
|
246
|
+
documentManager.invalidateCache(id2);
|
|
246
247
|
};
|
|
247
248
|
|
|
248
249
|
// src/component-instance-transformer.ts
|
|
@@ -251,11 +252,11 @@ var componentInstanceContext = new RenderContext("component-instance", {
|
|
|
251
252
|
});
|
|
252
253
|
var componentInstanceTransformer = createTransformer(
|
|
253
254
|
async ({
|
|
254
|
-
component_id:
|
|
255
|
+
component_id: id2,
|
|
255
256
|
overrides: overridesValue
|
|
256
257
|
}) => {
|
|
257
258
|
const unpublishedComponents = selectUnpublishedComponents(getState());
|
|
258
|
-
const unpublishedComponent = unpublishedComponents.find(({ uid }) => uid ===
|
|
259
|
+
const unpublishedComponent = unpublishedComponents.find(({ uid }) => uid === id2);
|
|
259
260
|
const overrides = overridesValue?.reduce((acc, override) => ({ ...acc, ...override }), {});
|
|
260
261
|
if (unpublishedComponent) {
|
|
261
262
|
return {
|
|
@@ -263,10 +264,10 @@ var componentInstanceTransformer = createTransformer(
|
|
|
263
264
|
overrides
|
|
264
265
|
};
|
|
265
266
|
}
|
|
266
|
-
if (typeof
|
|
267
|
-
throw new Error(`Component ID "${
|
|
267
|
+
if (typeof id2 !== "number") {
|
|
268
|
+
throw new Error(`Component ID "${id2}" not valid.`);
|
|
268
269
|
}
|
|
269
|
-
const data = await getComponentDocumentData(
|
|
270
|
+
const data = await getComponentDocumentData(id2);
|
|
270
271
|
return {
|
|
271
272
|
elements: data?.elements ?? [],
|
|
272
273
|
overrides
|
|
@@ -316,11 +317,12 @@ var componentOverrideTransformer = createTransformer3((override) => {
|
|
|
316
317
|
});
|
|
317
318
|
|
|
318
319
|
// src/components/component-panel-header/component-panel-header.tsx
|
|
319
|
-
import * as
|
|
320
|
+
import * as React10 from "react";
|
|
321
|
+
import { useSuppressedMessage } from "@elementor/editor-current-user";
|
|
320
322
|
import { getV1DocumentsManager as getV1DocumentsManager3 } from "@elementor/editor-documents";
|
|
321
323
|
import { ArrowLeftIcon, ComponentsFilledIcon } from "@elementor/icons";
|
|
322
|
-
import { Box as
|
|
323
|
-
import { __ as
|
|
324
|
+
import { Box as Box7, Divider as Divider2, IconButton as IconButton4, Stack as Stack6, Tooltip as Tooltip3, Typography as Typography6 } from "@elementor/ui";
|
|
325
|
+
import { __ as __11 } from "@wordpress/i18n";
|
|
324
326
|
|
|
325
327
|
// src/hooks/use-navigate-back.ts
|
|
326
328
|
import { useCallback } from "react";
|
|
@@ -339,43 +341,1108 @@ function switchToComponent(componentId, componentInstanceId) {
|
|
|
339
341
|
});
|
|
340
342
|
}
|
|
341
343
|
|
|
342
|
-
// src/hooks/use-navigate-back.ts
|
|
343
|
-
function useNavigateBack() {
|
|
344
|
-
const path = useSelector2(selectPath);
|
|
345
|
-
const documentsManager = getV1DocumentsManager2();
|
|
346
|
-
return useCallback(() => {
|
|
347
|
-
const { componentId: prevComponentId, instanceId: prevComponentInstanceId } = path.at(-2) ?? {};
|
|
348
|
-
if (prevComponentId && prevComponentInstanceId) {
|
|
349
|
-
switchToComponent(prevComponentId, prevComponentInstanceId);
|
|
344
|
+
// src/hooks/use-navigate-back.ts
|
|
345
|
+
function useNavigateBack() {
|
|
346
|
+
const path = useSelector2(selectPath);
|
|
347
|
+
const documentsManager = getV1DocumentsManager2();
|
|
348
|
+
return useCallback(() => {
|
|
349
|
+
const { componentId: prevComponentId, instanceId: prevComponentInstanceId } = path.at(-2) ?? {};
|
|
350
|
+
if (prevComponentId && prevComponentInstanceId) {
|
|
351
|
+
switchToComponent(prevComponentId, prevComponentInstanceId);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
switchToComponent(documentsManager.getInitialId());
|
|
355
|
+
}, [path, documentsManager]);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/components/component-properties-panel/component-properties-panel.tsx
|
|
359
|
+
import * as React7 from "react";
|
|
360
|
+
import { ElementProvider, usePanelActions as useEditingPanelActions } from "@elementor/editor-editing-panel";
|
|
361
|
+
import { useSelectedElement } from "@elementor/editor-elements";
|
|
362
|
+
import { __createPanel as createPanel, Panel } from "@elementor/editor-panels";
|
|
363
|
+
import { ThemeProvider } from "@elementor/editor-ui";
|
|
364
|
+
import { Alert, Box as Box4, ErrorBoundary } from "@elementor/ui";
|
|
365
|
+
import { __ as __8 } from "@wordpress/i18n";
|
|
366
|
+
|
|
367
|
+
// src/components/component-properties-panel/component-properties-panel-content.tsx
|
|
368
|
+
import * as React6 from "react";
|
|
369
|
+
import { useMemo, useState as useState3 } from "react";
|
|
370
|
+
import { setDocumentModifiedStatus as setDocumentModifiedStatus2 } from "@elementor/editor-documents";
|
|
371
|
+
import { PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
|
|
372
|
+
import { ComponentPropListIcon as ComponentPropListIcon2, FolderPlusIcon, XIcon as XIcon2 } from "@elementor/icons";
|
|
373
|
+
import { Divider, IconButton as IconButton3, List as List2, Stack as Stack4, Tooltip as Tooltip2 } from "@elementor/ui";
|
|
374
|
+
import { generateUniqueId as generateUniqueId2 } from "@elementor/utils";
|
|
375
|
+
import { __ as __7 } from "@wordpress/i18n";
|
|
376
|
+
|
|
377
|
+
// src/store/actions/add-overridable-group.ts
|
|
378
|
+
import { __dispatch as dispatch, __getState as getState2 } from "@elementor/store";
|
|
379
|
+
function addOverridableGroup({
|
|
380
|
+
componentId,
|
|
381
|
+
groupId,
|
|
382
|
+
label
|
|
383
|
+
}) {
|
|
384
|
+
const overridableProps = selectOverridableProps(getState2(), componentId);
|
|
385
|
+
if (!overridableProps) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const newGroup = {
|
|
389
|
+
id: groupId,
|
|
390
|
+
label,
|
|
391
|
+
props: []
|
|
392
|
+
};
|
|
393
|
+
dispatch(
|
|
394
|
+
slice.actions.setOverridableProps({
|
|
395
|
+
componentId,
|
|
396
|
+
overridableProps: {
|
|
397
|
+
...overridableProps,
|
|
398
|
+
groups: {
|
|
399
|
+
...overridableProps.groups,
|
|
400
|
+
items: {
|
|
401
|
+
...overridableProps.groups.items,
|
|
402
|
+
[groupId]: newGroup
|
|
403
|
+
},
|
|
404
|
+
order: [groupId, ...overridableProps.groups.order]
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
})
|
|
408
|
+
);
|
|
409
|
+
return newGroup;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/store/actions/delete-overridable-group.ts
|
|
413
|
+
import { __dispatch as dispatch2, __getState as getState3 } from "@elementor/store";
|
|
414
|
+
|
|
415
|
+
// src/store/utils/groups-transformers.ts
|
|
416
|
+
import { generateUniqueId } from "@elementor/utils";
|
|
417
|
+
import { __ } from "@wordpress/i18n";
|
|
418
|
+
function removePropFromAllGroups(groups, propKey) {
|
|
419
|
+
return {
|
|
420
|
+
...groups,
|
|
421
|
+
items: Object.fromEntries(
|
|
422
|
+
Object.entries(groups.items).map(([groupId, group]) => [
|
|
423
|
+
groupId,
|
|
424
|
+
{
|
|
425
|
+
...group,
|
|
426
|
+
props: group.props.filter((p) => p !== propKey)
|
|
427
|
+
}
|
|
428
|
+
])
|
|
429
|
+
)
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function addPropToGroup(groups, groupId, propKey) {
|
|
433
|
+
const group = groups.items[groupId];
|
|
434
|
+
if (!group) {
|
|
435
|
+
return groups;
|
|
436
|
+
}
|
|
437
|
+
if (group.props.includes(propKey)) {
|
|
438
|
+
return groups;
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
...groups,
|
|
442
|
+
items: {
|
|
443
|
+
...groups.items,
|
|
444
|
+
[groupId]: {
|
|
445
|
+
...group,
|
|
446
|
+
props: [...group.props, propKey]
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function movePropBetweenGroups(groups, propKey, fromGroupId, toGroupId) {
|
|
452
|
+
if (fromGroupId === toGroupId) {
|
|
453
|
+
return groups;
|
|
454
|
+
}
|
|
455
|
+
const withoutProp = removePropFromGroup(groups, fromGroupId, propKey);
|
|
456
|
+
return addPropToGroup(withoutProp, toGroupId, propKey);
|
|
457
|
+
}
|
|
458
|
+
function removePropFromGroup(groups, groupId, propKey) {
|
|
459
|
+
const group = groups.items[groupId];
|
|
460
|
+
if (!group) {
|
|
461
|
+
return groups;
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
...groups,
|
|
465
|
+
items: {
|
|
466
|
+
...groups.items,
|
|
467
|
+
[groupId]: {
|
|
468
|
+
...group,
|
|
469
|
+
props: group.props.filter((p) => p !== propKey)
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function resolveOrCreateGroup(groups, requestedGroupId) {
|
|
475
|
+
if (requestedGroupId && groups.items[requestedGroupId]) {
|
|
476
|
+
return { groups, groupId: requestedGroupId };
|
|
477
|
+
}
|
|
478
|
+
if (!requestedGroupId && groups.order.length > 0) {
|
|
479
|
+
return { groups, groupId: groups.order[0] };
|
|
480
|
+
}
|
|
481
|
+
return createGroup(groups, requestedGroupId);
|
|
482
|
+
}
|
|
483
|
+
function createGroup(groups, groupId, label) {
|
|
484
|
+
const newGroupId = groupId || generateUniqueId("group");
|
|
485
|
+
const newLabel = label || __("Default", "elementor");
|
|
486
|
+
return {
|
|
487
|
+
groups: {
|
|
488
|
+
...groups,
|
|
489
|
+
items: {
|
|
490
|
+
...groups.items,
|
|
491
|
+
[newGroupId]: {
|
|
492
|
+
id: newGroupId,
|
|
493
|
+
label: newLabel,
|
|
494
|
+
props: []
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
order: [...groups.order, newGroupId]
|
|
498
|
+
},
|
|
499
|
+
groupId: newGroupId
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function removePropsFromState(overridableProps, propsToRemove) {
|
|
503
|
+
const overrideKeysToRemove = propsToRemove.map((prop) => prop.overrideKey);
|
|
504
|
+
const remainingProps = Object.fromEntries(
|
|
505
|
+
Object.entries(overridableProps.props).filter(([, prop]) => !propsToRemove.includes(prop))
|
|
506
|
+
);
|
|
507
|
+
const updatedGroupItems = Object.fromEntries(
|
|
508
|
+
Object.entries(overridableProps.groups.items).map(
|
|
509
|
+
([groupId, group]) => [
|
|
510
|
+
groupId,
|
|
511
|
+
{
|
|
512
|
+
...group,
|
|
513
|
+
props: group.props.filter((prop) => !overrideKeysToRemove.includes(prop))
|
|
514
|
+
}
|
|
515
|
+
]
|
|
516
|
+
)
|
|
517
|
+
);
|
|
518
|
+
return {
|
|
519
|
+
props: remainingProps,
|
|
520
|
+
groups: {
|
|
521
|
+
items: updatedGroupItems,
|
|
522
|
+
order: overridableProps.groups.order.filter((groupId) => !overrideKeysToRemove.includes(groupId))
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
function ensureGroupInOrder(groups, groupId) {
|
|
527
|
+
if (groups.order.includes(groupId)) {
|
|
528
|
+
return groups;
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
...groups,
|
|
532
|
+
order: [...groups.order, groupId]
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function deleteGroup(groups, groupId) {
|
|
536
|
+
const { [groupId]: removed, ...remainingItems } = groups.items;
|
|
537
|
+
return {
|
|
538
|
+
items: remainingItems,
|
|
539
|
+
order: groups.order.filter((id2) => id2 !== groupId)
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function renameGroup(groups, groupId, newLabel) {
|
|
543
|
+
const group = groups.items[groupId];
|
|
544
|
+
if (!group) {
|
|
545
|
+
return groups;
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
...groups,
|
|
549
|
+
items: {
|
|
550
|
+
...groups.items,
|
|
551
|
+
[groupId]: {
|
|
552
|
+
...group,
|
|
553
|
+
label: newLabel
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// src/store/actions/delete-overridable-group.ts
|
|
560
|
+
function deleteOverridableGroup({ componentId, groupId }) {
|
|
561
|
+
const overridableProps = selectOverridableProps(getState3(), componentId);
|
|
562
|
+
if (!overridableProps) {
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
const group = overridableProps.groups.items[groupId];
|
|
566
|
+
if (!group || group.props.length > 0) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const updatedGroups = deleteGroup(overridableProps.groups, groupId);
|
|
570
|
+
dispatch2(
|
|
571
|
+
slice.actions.setOverridableProps({
|
|
572
|
+
componentId,
|
|
573
|
+
overridableProps: {
|
|
574
|
+
...overridableProps,
|
|
575
|
+
groups: updatedGroups
|
|
576
|
+
}
|
|
577
|
+
})
|
|
578
|
+
);
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// src/store/actions/delete-overridable-prop.ts
|
|
583
|
+
import { getContainer, updateElementSettings } from "@elementor/editor-elements";
|
|
584
|
+
import { __dispatch as dispatch3, __getState as getState4 } from "@elementor/store";
|
|
585
|
+
function deleteOverridableProp({ componentId, propKey }) {
|
|
586
|
+
const overridableProps = selectOverridableProps(getState4(), componentId);
|
|
587
|
+
if (!overridableProps) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const prop = overridableProps.props[propKey];
|
|
591
|
+
if (!prop) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
revertElementSetting(prop.elementId, prop.propKey, prop.originValue);
|
|
595
|
+
const { [propKey]: removedProp, ...remainingProps } = overridableProps.props;
|
|
596
|
+
const updatedGroups = removePropFromAllGroups(overridableProps.groups, propKey);
|
|
597
|
+
dispatch3(
|
|
598
|
+
slice.actions.setOverridableProps({
|
|
599
|
+
componentId,
|
|
600
|
+
overridableProps: {
|
|
601
|
+
...overridableProps,
|
|
602
|
+
props: remainingProps,
|
|
603
|
+
groups: updatedGroups
|
|
604
|
+
}
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
function revertElementSetting(elementId, settingKey, originValue) {
|
|
609
|
+
const container = getContainer(elementId);
|
|
610
|
+
if (!container) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
updateElementSettings({
|
|
614
|
+
id: elementId,
|
|
615
|
+
props: { [settingKey]: originValue ?? null },
|
|
616
|
+
withHistory: false
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// src/store/actions/reorder-group-props.ts
|
|
621
|
+
import { __dispatch as dispatch4, __getState as getState5 } from "@elementor/store";
|
|
622
|
+
function reorderGroupProps({ componentId, groupId, newPropsOrder }) {
|
|
623
|
+
const overridableProps = selectOverridableProps(getState5(), componentId);
|
|
624
|
+
if (!overridableProps) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const group = overridableProps.groups.items[groupId];
|
|
628
|
+
if (!group) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
dispatch4(
|
|
632
|
+
slice.actions.setOverridableProps({
|
|
633
|
+
componentId,
|
|
634
|
+
overridableProps: {
|
|
635
|
+
...overridableProps,
|
|
636
|
+
groups: {
|
|
637
|
+
...overridableProps.groups,
|
|
638
|
+
items: {
|
|
639
|
+
...overridableProps.groups.items,
|
|
640
|
+
[groupId]: {
|
|
641
|
+
...group,
|
|
642
|
+
props: newPropsOrder
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
})
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// src/store/actions/reorder-overridable-groups.ts
|
|
652
|
+
import { __dispatch as dispatch5, __getState as getState6 } from "@elementor/store";
|
|
653
|
+
function reorderOverridableGroups({ componentId, newOrder }) {
|
|
654
|
+
const overridableProps = selectOverridableProps(getState6(), componentId);
|
|
655
|
+
if (!overridableProps) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
dispatch5(
|
|
659
|
+
slice.actions.setOverridableProps({
|
|
660
|
+
componentId,
|
|
661
|
+
overridableProps: {
|
|
662
|
+
...overridableProps,
|
|
663
|
+
groups: {
|
|
664
|
+
...overridableProps.groups,
|
|
665
|
+
order: newOrder
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
})
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// src/store/actions/update-overridable-prop.ts
|
|
673
|
+
import { __dispatch as dispatch6, __getState as getState7 } from "@elementor/store";
|
|
674
|
+
function updateOverridableProp({
|
|
675
|
+
componentId,
|
|
676
|
+
propKey,
|
|
677
|
+
label,
|
|
678
|
+
groupId
|
|
679
|
+
}) {
|
|
680
|
+
const overridableProps = selectOverridableProps(getState7(), componentId);
|
|
681
|
+
if (!overridableProps) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const prop = overridableProps.props[propKey];
|
|
685
|
+
if (!prop) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const oldGroupId = prop.groupId;
|
|
689
|
+
const newGroupId = groupId ?? oldGroupId;
|
|
690
|
+
const updatedProp = {
|
|
691
|
+
...prop,
|
|
692
|
+
label,
|
|
693
|
+
groupId: newGroupId
|
|
694
|
+
};
|
|
695
|
+
const updatedGroups = movePropBetweenGroups(overridableProps.groups, propKey, oldGroupId, newGroupId);
|
|
696
|
+
dispatch6(
|
|
697
|
+
slice.actions.setOverridableProps({
|
|
698
|
+
componentId,
|
|
699
|
+
overridableProps: {
|
|
700
|
+
...overridableProps,
|
|
701
|
+
props: {
|
|
702
|
+
...overridableProps.props,
|
|
703
|
+
[propKey]: updatedProp
|
|
704
|
+
},
|
|
705
|
+
groups: updatedGroups
|
|
706
|
+
}
|
|
707
|
+
})
|
|
708
|
+
);
|
|
709
|
+
return updatedProp;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/components/component-panel-header/use-overridable-props.ts
|
|
713
|
+
import { __useSelector as useSelector3 } from "@elementor/store";
|
|
714
|
+
function useOverridableProps(componentId) {
|
|
715
|
+
return useSelector3((state) => {
|
|
716
|
+
if (!componentId) {
|
|
717
|
+
return void 0;
|
|
718
|
+
}
|
|
719
|
+
return selectOverridableProps(state, componentId);
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// src/components/component-properties-panel/properties-empty-state.tsx
|
|
724
|
+
import * as React from "react";
|
|
725
|
+
import { ComponentPropListIcon } from "@elementor/icons";
|
|
726
|
+
import { Link, Stack, Typography } from "@elementor/ui";
|
|
727
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
728
|
+
var LEARN_MORE_URL = "https://go.elementor.com/tbd/";
|
|
729
|
+
function PropertiesEmptyState() {
|
|
730
|
+
return /* @__PURE__ */ React.createElement(
|
|
731
|
+
Stack,
|
|
732
|
+
{
|
|
733
|
+
alignItems: "center",
|
|
734
|
+
justifyContent: "flex-start",
|
|
735
|
+
height: "100%",
|
|
736
|
+
color: "text.secondary",
|
|
737
|
+
sx: { px: 2.5, pt: 10, pb: 5.5 },
|
|
738
|
+
gap: 1
|
|
739
|
+
},
|
|
740
|
+
/* @__PURE__ */ React.createElement(ComponentPropListIcon, { fontSize: "large" }),
|
|
741
|
+
/* @__PURE__ */ React.createElement(Typography, { align: "center", variant: "subtitle2" }, __2("Add your first property", "elementor")),
|
|
742
|
+
/* @__PURE__ */ React.createElement(Typography, { align: "center", variant: "caption" }, __2("Make instances flexible while keeping design synced.", "elementor")),
|
|
743
|
+
/* @__PURE__ */ React.createElement(Typography, { align: "center", variant: "caption" }, __2("Select any element, then click + next to a setting to expose it.", "elementor")),
|
|
744
|
+
/* @__PURE__ */ React.createElement(
|
|
745
|
+
Link,
|
|
746
|
+
{
|
|
747
|
+
variant: "caption",
|
|
748
|
+
color: "secondary",
|
|
749
|
+
href: LEARN_MORE_URL,
|
|
750
|
+
target: "_blank",
|
|
751
|
+
rel: "noopener noreferrer",
|
|
752
|
+
sx: { textDecorationLine: "underline" }
|
|
753
|
+
},
|
|
754
|
+
__2("Learn more", "elementor")
|
|
755
|
+
)
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/components/component-properties-panel/properties-group.tsx
|
|
760
|
+
import * as React5 from "react";
|
|
761
|
+
import { EditableField, MenuListItem as MenuListItem2 } from "@elementor/editor-ui";
|
|
762
|
+
import { DotsVerticalIcon } from "@elementor/icons";
|
|
763
|
+
import {
|
|
764
|
+
bindMenu,
|
|
765
|
+
bindTrigger as bindTrigger2,
|
|
766
|
+
Box as Box3,
|
|
767
|
+
IconButton as IconButton2,
|
|
768
|
+
List,
|
|
769
|
+
Menu,
|
|
770
|
+
Stack as Stack3,
|
|
771
|
+
Tooltip,
|
|
772
|
+
Typography as Typography4,
|
|
773
|
+
usePopupState as usePopupState2
|
|
774
|
+
} from "@elementor/ui";
|
|
775
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
776
|
+
|
|
777
|
+
// src/components/component-properties-panel/property-item.tsx
|
|
778
|
+
import * as React4 from "react";
|
|
779
|
+
import { getWidgetsCache } from "@elementor/editor-elements";
|
|
780
|
+
import { XIcon } from "@elementor/icons";
|
|
781
|
+
import { bindPopover, bindTrigger, Box as Box2, IconButton, Popover, Typography as Typography3, usePopupState } from "@elementor/ui";
|
|
782
|
+
|
|
783
|
+
// src/components/overridable-props/overridable-prop-form.tsx
|
|
784
|
+
import * as React2 from "react";
|
|
785
|
+
import { useState } from "react";
|
|
786
|
+
import { Form, MenuListItem } from "@elementor/editor-ui";
|
|
787
|
+
import { Button, FormLabel, Grid, Select, Stack as Stack2, TextField, Typography as Typography2 } from "@elementor/ui";
|
|
788
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
789
|
+
var SIZE = "tiny";
|
|
790
|
+
var DEFAULT_GROUP = { value: null, label: __3("Default", "elementor") };
|
|
791
|
+
function OverridablePropForm({ onSubmit, groups, currentValue, sx }) {
|
|
792
|
+
const [propLabel, setPropLabel] = useState(currentValue?.label ?? null);
|
|
793
|
+
const [group, setGroup] = useState(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
794
|
+
const name = __3("Name", "elementor");
|
|
795
|
+
const groupName = __3("Group Name", "elementor");
|
|
796
|
+
const isCreate = currentValue === void 0;
|
|
797
|
+
const title = isCreate ? __3("Create new property", "elementor") : __3("Update property", "elementor");
|
|
798
|
+
const ctaLabel = isCreate ? __3("Create", "elementor") : __3("Update", "elementor");
|
|
799
|
+
return /* @__PURE__ */ React2.createElement(Form, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React2.createElement(Stack2, { alignItems: "start", sx: { width: "268px", ...sx } }, /* @__PURE__ */ React2.createElement(
|
|
800
|
+
Stack2,
|
|
801
|
+
{
|
|
802
|
+
direction: "row",
|
|
803
|
+
alignItems: "center",
|
|
804
|
+
py: 1,
|
|
805
|
+
px: 1.5,
|
|
806
|
+
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
807
|
+
},
|
|
808
|
+
/* @__PURE__ */ React2.createElement(Typography2, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
809
|
+
), /* @__PURE__ */ React2.createElement(Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(FormLabel, { size: "tiny" }, name)), /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
810
|
+
TextField,
|
|
811
|
+
{
|
|
812
|
+
name,
|
|
813
|
+
size: SIZE,
|
|
814
|
+
fullWidth: true,
|
|
815
|
+
placeholder: __3("Enter value", "elementor"),
|
|
816
|
+
value: propLabel ?? "",
|
|
817
|
+
onChange: (e) => setPropLabel(e.target.value)
|
|
818
|
+
}
|
|
819
|
+
))), /* @__PURE__ */ React2.createElement(Grid, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(FormLabel, { size: "tiny" }, groupName)), /* @__PURE__ */ React2.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React2.createElement(
|
|
820
|
+
Select,
|
|
821
|
+
{
|
|
822
|
+
name: groupName,
|
|
823
|
+
size: SIZE,
|
|
824
|
+
fullWidth: true,
|
|
825
|
+
value: group ?? null,
|
|
826
|
+
onChange: (e) => setGroup(e.target.value),
|
|
827
|
+
displayEmpty: true,
|
|
828
|
+
renderValue: (selectedValue) => {
|
|
829
|
+
if (!selectedValue || selectedValue === "") {
|
|
830
|
+
const [firstGroup = DEFAULT_GROUP] = groups ?? [];
|
|
831
|
+
return firstGroup.label;
|
|
832
|
+
}
|
|
833
|
+
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React2.createElement(MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
837
|
+
))), /* @__PURE__ */ React2.createElement(Stack2, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React2.createElement(Button, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// src/components/component-properties-panel/sortable.tsx
|
|
841
|
+
import * as React3 from "react";
|
|
842
|
+
import { GripVerticalIcon } from "@elementor/icons";
|
|
843
|
+
import {
|
|
844
|
+
Box,
|
|
845
|
+
styled,
|
|
846
|
+
UnstableSortableItem,
|
|
847
|
+
UnstableSortableProvider
|
|
848
|
+
} from "@elementor/ui";
|
|
849
|
+
var SortableProvider = (props) => /* @__PURE__ */ React3.createElement(UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
850
|
+
var SortableTrigger = ({ triggerClassName, ...props }) => /* @__PURE__ */ React3.createElement(
|
|
851
|
+
StyledSortableTrigger,
|
|
852
|
+
{
|
|
853
|
+
...props,
|
|
854
|
+
role: "button",
|
|
855
|
+
className: `sortable-trigger ${triggerClassName ?? ""}`.trim(),
|
|
856
|
+
"aria-label": "sort"
|
|
857
|
+
},
|
|
858
|
+
/* @__PURE__ */ React3.createElement(GripVerticalIcon, { fontSize: "tiny" })
|
|
859
|
+
);
|
|
860
|
+
var SortableItem = ({ children, id: id2 }) => /* @__PURE__ */ React3.createElement(
|
|
861
|
+
UnstableSortableItem,
|
|
862
|
+
{
|
|
863
|
+
id: id2,
|
|
864
|
+
render: ({
|
|
865
|
+
itemProps,
|
|
866
|
+
isDragged,
|
|
867
|
+
triggerProps,
|
|
868
|
+
itemStyle,
|
|
869
|
+
triggerStyle,
|
|
870
|
+
dropIndicationStyle,
|
|
871
|
+
showDropIndication,
|
|
872
|
+
isDragOverlay,
|
|
873
|
+
isDragPlaceholder
|
|
874
|
+
}) => /* @__PURE__ */ React3.createElement(
|
|
875
|
+
Box,
|
|
876
|
+
{
|
|
877
|
+
...itemProps,
|
|
878
|
+
style: itemStyle,
|
|
879
|
+
component: "div",
|
|
880
|
+
role: "listitem",
|
|
881
|
+
sx: {
|
|
882
|
+
backgroundColor: isDragOverlay ? "background.paper" : void 0
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
children({
|
|
886
|
+
isDragged,
|
|
887
|
+
isDragPlaceholder,
|
|
888
|
+
triggerProps,
|
|
889
|
+
triggerStyle
|
|
890
|
+
}),
|
|
891
|
+
showDropIndication && /* @__PURE__ */ React3.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
892
|
+
)
|
|
893
|
+
}
|
|
894
|
+
);
|
|
895
|
+
var StyledSortableTrigger = styled("div")(({ theme }) => ({
|
|
896
|
+
position: "absolute",
|
|
897
|
+
left: 0,
|
|
898
|
+
top: "50%",
|
|
899
|
+
transform: `translate( -${theme.spacing(1.5)}, -50% )`,
|
|
900
|
+
color: theme.palette.action.active,
|
|
901
|
+
cursor: "grab"
|
|
902
|
+
}));
|
|
903
|
+
var SortableItemIndicator = styled(Box)`
|
|
904
|
+
width: 100%;
|
|
905
|
+
height: 1px;
|
|
906
|
+
background-color: ${({ theme }) => theme.palette.text.primary};
|
|
907
|
+
`;
|
|
908
|
+
|
|
909
|
+
// src/components/component-properties-panel/property-item.tsx
|
|
910
|
+
function PropertyItem({
|
|
911
|
+
prop,
|
|
912
|
+
sortableTriggerProps,
|
|
913
|
+
isDragPlaceholder,
|
|
914
|
+
groups,
|
|
915
|
+
onDelete,
|
|
916
|
+
onUpdate
|
|
917
|
+
}) {
|
|
918
|
+
const popoverState = usePopupState({
|
|
919
|
+
variant: "popover"
|
|
920
|
+
});
|
|
921
|
+
const icon = getElementIcon(prop);
|
|
922
|
+
const popoverProps = bindPopover(popoverState);
|
|
923
|
+
const handleSubmit = (data) => {
|
|
924
|
+
onUpdate(data);
|
|
925
|
+
popoverState.close();
|
|
926
|
+
};
|
|
927
|
+
const handleDelete = (event) => {
|
|
928
|
+
event.stopPropagation();
|
|
929
|
+
onDelete(prop.overrideKey);
|
|
930
|
+
};
|
|
931
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
|
|
932
|
+
Box2,
|
|
933
|
+
{
|
|
934
|
+
...bindTrigger(popoverState),
|
|
935
|
+
sx: {
|
|
936
|
+
position: "relative",
|
|
937
|
+
pl: 0.5,
|
|
938
|
+
pr: 1,
|
|
939
|
+
py: 0.25,
|
|
940
|
+
minHeight: 28,
|
|
941
|
+
borderRadius: 1,
|
|
942
|
+
border: "1px solid",
|
|
943
|
+
borderColor: "divider",
|
|
944
|
+
display: "flex",
|
|
945
|
+
alignItems: "center",
|
|
946
|
+
gap: 0.5,
|
|
947
|
+
opacity: isDragPlaceholder ? 0.5 : 1,
|
|
948
|
+
cursor: "pointer",
|
|
949
|
+
"&:hover": {
|
|
950
|
+
backgroundColor: "action.hover"
|
|
951
|
+
},
|
|
952
|
+
"&:hover .sortable-trigger": {
|
|
953
|
+
visibility: "visible"
|
|
954
|
+
},
|
|
955
|
+
"& .sortable-trigger": {
|
|
956
|
+
visibility: "hidden"
|
|
957
|
+
},
|
|
958
|
+
"&:hover .delete-button": {
|
|
959
|
+
visibility: "visible"
|
|
960
|
+
},
|
|
961
|
+
"& .delete-button": {
|
|
962
|
+
visibility: "hidden"
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
/* @__PURE__ */ React4.createElement(SortableTrigger, { ...sortableTriggerProps }),
|
|
967
|
+
/* @__PURE__ */ React4.createElement(
|
|
968
|
+
Box2,
|
|
969
|
+
{
|
|
970
|
+
sx: { display: "flex", alignItems: "center", color: "text.primary", fontSize: 12, padding: 0.25 }
|
|
971
|
+
},
|
|
972
|
+
/* @__PURE__ */ React4.createElement("i", { className: icon })
|
|
973
|
+
),
|
|
974
|
+
/* @__PURE__ */ React4.createElement(Typography3, { variant: "caption", sx: { color: "text.primary", flexGrow: 1, fontSize: 10 } }, prop.label),
|
|
975
|
+
/* @__PURE__ */ React4.createElement(IconButton, { size: "tiny", onClick: handleDelete, "aria-label": "Delete property", sx: { p: 0.25 } }, /* @__PURE__ */ React4.createElement(XIcon, { fontSize: "tiny" }))
|
|
976
|
+
), /* @__PURE__ */ React4.createElement(
|
|
977
|
+
Popover,
|
|
978
|
+
{
|
|
979
|
+
...popoverProps,
|
|
980
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
981
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
982
|
+
PaperProps: { sx: { width: popoverState.anchorEl?.getBoundingClientRect().width } }
|
|
983
|
+
},
|
|
984
|
+
/* @__PURE__ */ React4.createElement(
|
|
985
|
+
OverridablePropForm,
|
|
986
|
+
{
|
|
987
|
+
onSubmit: handleSubmit,
|
|
988
|
+
currentValue: prop,
|
|
989
|
+
groups,
|
|
990
|
+
sx: { width: "100%" }
|
|
991
|
+
}
|
|
992
|
+
)
|
|
993
|
+
));
|
|
994
|
+
}
|
|
995
|
+
function getElementIcon(prop) {
|
|
996
|
+
const elType = prop.elType === "widget" ? prop.widgetType : prop.elType;
|
|
997
|
+
const widgetsCache = getWidgetsCache();
|
|
998
|
+
if (!widgetsCache) {
|
|
999
|
+
return "eicon-apps";
|
|
1000
|
+
}
|
|
1001
|
+
const widgetConfig = widgetsCache[elType];
|
|
1002
|
+
return widgetConfig?.icon || "eicon-apps";
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// src/components/component-properties-panel/properties-group.tsx
|
|
1006
|
+
function PropertiesGroup({
|
|
1007
|
+
group,
|
|
1008
|
+
props,
|
|
1009
|
+
allGroups,
|
|
1010
|
+
sortableTriggerProps,
|
|
1011
|
+
isDragPlaceholder,
|
|
1012
|
+
onPropsReorder,
|
|
1013
|
+
onPropertyDelete,
|
|
1014
|
+
onPropertyUpdate,
|
|
1015
|
+
onGroupDelete,
|
|
1016
|
+
editableLabelProps
|
|
1017
|
+
}) {
|
|
1018
|
+
const groupProps = group.props.map((propId) => props[propId]).filter((prop) => Boolean(prop));
|
|
1019
|
+
const popupState = usePopupState2({
|
|
1020
|
+
variant: "popover",
|
|
1021
|
+
disableAutoFocus: true
|
|
1022
|
+
});
|
|
1023
|
+
const { editableRef, isEditing, error, getEditableProps, setEditingGroupId, editingGroupId } = editableLabelProps;
|
|
1024
|
+
const hasProperties = group.props.length > 0;
|
|
1025
|
+
const isThisGroupEditing = isEditing && editingGroupId === group.id;
|
|
1026
|
+
const handleRenameClick = () => {
|
|
1027
|
+
popupState.close();
|
|
1028
|
+
setEditingGroupId(group.id);
|
|
1029
|
+
};
|
|
1030
|
+
const handleDeleteClick = () => {
|
|
1031
|
+
popupState.close();
|
|
1032
|
+
onGroupDelete(group.id);
|
|
1033
|
+
};
|
|
1034
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1035
|
+
Box3,
|
|
1036
|
+
{
|
|
1037
|
+
sx: {
|
|
1038
|
+
opacity: isDragPlaceholder ? 0.5 : 1
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
/* @__PURE__ */ React5.createElement(Stack3, { gap: 1 }, /* @__PURE__ */ React5.createElement(
|
|
1042
|
+
Box3,
|
|
1043
|
+
{
|
|
1044
|
+
className: "group-header",
|
|
1045
|
+
sx: {
|
|
1046
|
+
position: "relative",
|
|
1047
|
+
"&:hover .group-sortable-trigger": {
|
|
1048
|
+
visibility: "visible"
|
|
1049
|
+
},
|
|
1050
|
+
"& .group-sortable-trigger": {
|
|
1051
|
+
visibility: "hidden"
|
|
1052
|
+
},
|
|
1053
|
+
"&:hover .group-menu": {
|
|
1054
|
+
visibility: "visible"
|
|
1055
|
+
},
|
|
1056
|
+
"& .group-menu": {
|
|
1057
|
+
visibility: "hidden"
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
1061
|
+
/* @__PURE__ */ React5.createElement(SortableTrigger, { triggerClassName: "group-sortable-trigger", ...sortableTriggerProps }),
|
|
1062
|
+
/* @__PURE__ */ React5.createElement(Stack3, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 2 }, isThisGroupEditing ? /* @__PURE__ */ React5.createElement(
|
|
1063
|
+
Box3,
|
|
1064
|
+
{
|
|
1065
|
+
sx: {
|
|
1066
|
+
flex: 1,
|
|
1067
|
+
height: 28,
|
|
1068
|
+
display: "flex",
|
|
1069
|
+
alignItems: "center",
|
|
1070
|
+
border: 2,
|
|
1071
|
+
borderColor: "text.secondary",
|
|
1072
|
+
borderRadius: 1,
|
|
1073
|
+
pl: 0.5
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
/* @__PURE__ */ React5.createElement(
|
|
1077
|
+
EditableField,
|
|
1078
|
+
{
|
|
1079
|
+
ref: editableRef,
|
|
1080
|
+
as: Typography4,
|
|
1081
|
+
variant: "caption",
|
|
1082
|
+
error: error ?? void 0,
|
|
1083
|
+
sx: { color: "text.primary", fontWeight: 400, lineHeight: 1.66 },
|
|
1084
|
+
...getEditableProps()
|
|
1085
|
+
}
|
|
1086
|
+
)
|
|
1087
|
+
) : /* @__PURE__ */ React5.createElement(
|
|
1088
|
+
Typography4,
|
|
1089
|
+
{
|
|
1090
|
+
variant: "caption",
|
|
1091
|
+
sx: { color: "text.primary", fontWeight: 400, lineHeight: 1.66 }
|
|
1092
|
+
},
|
|
1093
|
+
group.label
|
|
1094
|
+
), /* @__PURE__ */ React5.createElement(
|
|
1095
|
+
IconButton2,
|
|
1096
|
+
{
|
|
1097
|
+
className: "group-menu",
|
|
1098
|
+
size: "tiny",
|
|
1099
|
+
sx: { p: 0.25, visibility: isThisGroupEditing ? "visible" : void 0 },
|
|
1100
|
+
"aria-label": __4("Group actions", "elementor"),
|
|
1101
|
+
...bindTrigger2(popupState)
|
|
1102
|
+
},
|
|
1103
|
+
/* @__PURE__ */ React5.createElement(DotsVerticalIcon, { fontSize: "tiny" })
|
|
1104
|
+
))
|
|
1105
|
+
), /* @__PURE__ */ React5.createElement(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(
|
|
1106
|
+
PropertyItem,
|
|
1107
|
+
{
|
|
1108
|
+
prop,
|
|
1109
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle },
|
|
1110
|
+
isDragPlaceholder: isItemDragPlaceholder,
|
|
1111
|
+
groups: allGroups,
|
|
1112
|
+
onDelete: onPropertyDelete,
|
|
1113
|
+
onUpdate: (data) => onPropertyUpdate(prop.overrideKey, data)
|
|
1114
|
+
}
|
|
1115
|
+
)))))),
|
|
1116
|
+
/* @__PURE__ */ React5.createElement(
|
|
1117
|
+
Menu,
|
|
1118
|
+
{
|
|
1119
|
+
...bindMenu(popupState),
|
|
1120
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
1121
|
+
transformOrigin: { vertical: "top", horizontal: "right" }
|
|
1122
|
+
},
|
|
1123
|
+
/* @__PURE__ */ React5.createElement(MenuListItem2, { sx: { minWidth: "160px" }, onClick: handleRenameClick }, /* @__PURE__ */ React5.createElement(Typography4, { variant: "caption", sx: { color: "text.primary" } }, __4("Rename", "elementor"))),
|
|
1124
|
+
/* @__PURE__ */ React5.createElement(
|
|
1125
|
+
Tooltip,
|
|
1126
|
+
{
|
|
1127
|
+
title: hasProperties ? __4("To delete the group, first remove all the properties", "elementor") : "",
|
|
1128
|
+
placement: "right"
|
|
1129
|
+
},
|
|
1130
|
+
/* @__PURE__ */ React5.createElement("span", null, /* @__PURE__ */ React5.createElement(MenuListItem2, { onClick: handleDeleteClick, disabled: hasProperties }, /* @__PURE__ */ React5.createElement(
|
|
1131
|
+
Typography4,
|
|
1132
|
+
{
|
|
1133
|
+
variant: "caption",
|
|
1134
|
+
sx: { color: hasProperties ? "text.disabled" : "error.light" }
|
|
1135
|
+
},
|
|
1136
|
+
__4("Delete", "elementor")
|
|
1137
|
+
)))
|
|
1138
|
+
)
|
|
1139
|
+
)
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// src/components/component-properties-panel/use-current-editable-item.ts
|
|
1144
|
+
import { useState as useState2 } from "react";
|
|
1145
|
+
import { setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
1146
|
+
import { useEditable } from "@elementor/editor-ui";
|
|
1147
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
1148
|
+
|
|
1149
|
+
// src/store/actions/rename-overridable-group.ts
|
|
1150
|
+
import { __dispatch as dispatch7, __getState as getState8 } from "@elementor/store";
|
|
1151
|
+
function renameOverridableGroup({ componentId, groupId, label }) {
|
|
1152
|
+
const overridableProps = selectOverridableProps(getState8(), componentId);
|
|
1153
|
+
if (!overridableProps) {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
const group = overridableProps.groups.items[groupId];
|
|
1157
|
+
if (!group) {
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
const updatedGroups = renameGroup(overridableProps.groups, groupId, label);
|
|
1161
|
+
dispatch7(
|
|
1162
|
+
slice.actions.setOverridableProps({
|
|
1163
|
+
componentId,
|
|
1164
|
+
overridableProps: {
|
|
1165
|
+
...overridableProps,
|
|
1166
|
+
groups: updatedGroups
|
|
1167
|
+
}
|
|
1168
|
+
})
|
|
1169
|
+
);
|
|
1170
|
+
return true;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// src/components/component-properties-panel/utils/validate-group-label.ts
|
|
1174
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
1175
|
+
var ERROR_MESSAGES = {
|
|
1176
|
+
EMPTY_NAME: __5("Group name is required", "elementor"),
|
|
1177
|
+
DUPLICATE_NAME: __5("Group name already exists", "elementor")
|
|
1178
|
+
};
|
|
1179
|
+
function validateGroupLabel(label, existingGroups) {
|
|
1180
|
+
const trimmedLabel = label.trim();
|
|
1181
|
+
if (!trimmedLabel) {
|
|
1182
|
+
return ERROR_MESSAGES.EMPTY_NAME;
|
|
1183
|
+
}
|
|
1184
|
+
const isDuplicate = Object.values(existingGroups).some((group) => group.label === trimmedLabel);
|
|
1185
|
+
if (isDuplicate) {
|
|
1186
|
+
return ERROR_MESSAGES.DUPLICATE_NAME;
|
|
1187
|
+
}
|
|
1188
|
+
return "";
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
// src/components/component-properties-panel/use-current-editable-item.ts
|
|
1192
|
+
function useCurrentEditableItem() {
|
|
1193
|
+
const [editingGroupId, setEditingGroupId] = useState2(null);
|
|
1194
|
+
const currentComponentId = useCurrentComponentId();
|
|
1195
|
+
const overridableProps = useOverridableProps(currentComponentId);
|
|
1196
|
+
const allGroupsRecord = overridableProps?.groups?.items ?? {};
|
|
1197
|
+
const currentGroup = editingGroupId ? allGroupsRecord[editingGroupId] : null;
|
|
1198
|
+
const validateLabel = (newLabel) => {
|
|
1199
|
+
const otherGroups = Object.fromEntries(
|
|
1200
|
+
Object.entries(allGroupsRecord).filter(([id2]) => id2 !== editingGroupId)
|
|
1201
|
+
);
|
|
1202
|
+
return validateGroupLabel(newLabel, otherGroups) || null;
|
|
1203
|
+
};
|
|
1204
|
+
const handleSubmit = (newLabel) => {
|
|
1205
|
+
if (!editingGroupId || !currentComponentId) {
|
|
1206
|
+
throw new Error(__6("Group ID or component ID is missing", "elementor"));
|
|
1207
|
+
}
|
|
1208
|
+
renameOverridableGroup({
|
|
1209
|
+
componentId: currentComponentId,
|
|
1210
|
+
groupId: editingGroupId,
|
|
1211
|
+
label: newLabel
|
|
1212
|
+
});
|
|
1213
|
+
setDocumentModifiedStatus(true);
|
|
1214
|
+
};
|
|
1215
|
+
const {
|
|
1216
|
+
ref: editableRef,
|
|
1217
|
+
openEditMode,
|
|
1218
|
+
isEditing,
|
|
1219
|
+
error,
|
|
1220
|
+
getProps: getEditableProps
|
|
1221
|
+
} = useEditable({
|
|
1222
|
+
value: currentGroup?.label ?? "",
|
|
1223
|
+
onSubmit: handleSubmit,
|
|
1224
|
+
validation: validateLabel
|
|
1225
|
+
});
|
|
1226
|
+
return {
|
|
1227
|
+
editableRef,
|
|
1228
|
+
isEditing,
|
|
1229
|
+
error,
|
|
1230
|
+
getEditableProps,
|
|
1231
|
+
setEditingGroupId: (groupId) => {
|
|
1232
|
+
setEditingGroupId(groupId);
|
|
1233
|
+
openEditMode();
|
|
1234
|
+
},
|
|
1235
|
+
editingGroupId
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// src/components/component-properties-panel/utils/generate-unique-label.ts
|
|
1240
|
+
var DEFAULT_NEW_GROUP_LABEL = "New group";
|
|
1241
|
+
function generateUniqueLabel(groups) {
|
|
1242
|
+
const existingLabels = new Set(groups.map((group) => group.label));
|
|
1243
|
+
if (!existingLabels.has(DEFAULT_NEW_GROUP_LABEL)) {
|
|
1244
|
+
return DEFAULT_NEW_GROUP_LABEL;
|
|
1245
|
+
}
|
|
1246
|
+
let index = 1;
|
|
1247
|
+
let newLabel = `${DEFAULT_NEW_GROUP_LABEL}-${index}`;
|
|
1248
|
+
while (existingLabels.has(newLabel)) {
|
|
1249
|
+
index++;
|
|
1250
|
+
newLabel = `${DEFAULT_NEW_GROUP_LABEL}-${index}`;
|
|
1251
|
+
}
|
|
1252
|
+
return newLabel;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
// src/components/component-properties-panel/component-properties-panel-content.tsx
|
|
1256
|
+
function ComponentPropertiesPanelContent({ onClose }) {
|
|
1257
|
+
const currentComponentId = useCurrentComponentId();
|
|
1258
|
+
const overridableProps = useOverridableProps(currentComponentId);
|
|
1259
|
+
const [isAddingGroup, setIsAddingGroup] = useState3(false);
|
|
1260
|
+
const groupLabelEditable = useCurrentEditableItem();
|
|
1261
|
+
const groups = useMemo(() => {
|
|
1262
|
+
if (!overridableProps) {
|
|
1263
|
+
return [];
|
|
1264
|
+
}
|
|
1265
|
+
return overridableProps.groups.order.map((groupId) => overridableProps.groups.items[groupId] ?? null).filter(Boolean);
|
|
1266
|
+
}, [overridableProps]);
|
|
1267
|
+
const allGroupsForSelect = useMemo(
|
|
1268
|
+
() => groups.map((group) => ({ value: group.id, label: group.label })),
|
|
1269
|
+
[groups]
|
|
1270
|
+
);
|
|
1271
|
+
if (!currentComponentId || !overridableProps) {
|
|
1272
|
+
return null;
|
|
1273
|
+
}
|
|
1274
|
+
const hasGroups = groups.length > 0;
|
|
1275
|
+
const showEmptyState = !hasGroups && !isAddingGroup;
|
|
1276
|
+
const groupIds = overridableProps.groups.order;
|
|
1277
|
+
const handleAddGroupClick = () => {
|
|
1278
|
+
if (isAddingGroup) {
|
|
350
1279
|
return;
|
|
351
1280
|
}
|
|
352
|
-
|
|
353
|
-
|
|
1281
|
+
const newGroupId = generateUniqueId2("group");
|
|
1282
|
+
const newLabel = generateUniqueLabel(groups);
|
|
1283
|
+
addOverridableGroup({ componentId: currentComponentId, groupId: newGroupId, label: newLabel });
|
|
1284
|
+
setDocumentModifiedStatus2(true);
|
|
1285
|
+
setIsAddingGroup(false);
|
|
1286
|
+
groupLabelEditable.setEditingGroupId(newGroupId);
|
|
1287
|
+
};
|
|
1288
|
+
const handleGroupsReorder = (newOrder) => {
|
|
1289
|
+
reorderOverridableGroups({ componentId: currentComponentId, newOrder });
|
|
1290
|
+
setDocumentModifiedStatus2(true);
|
|
1291
|
+
};
|
|
1292
|
+
const handlePropsReorder = (groupId, newPropsOrder) => {
|
|
1293
|
+
reorderGroupProps({ componentId: currentComponentId, groupId, newPropsOrder });
|
|
1294
|
+
setDocumentModifiedStatus2(true);
|
|
1295
|
+
};
|
|
1296
|
+
const handlePropertyDelete = (propKey) => {
|
|
1297
|
+
deleteOverridableProp({ componentId: currentComponentId, propKey });
|
|
1298
|
+
setDocumentModifiedStatus2(true);
|
|
1299
|
+
};
|
|
1300
|
+
const handlePropertyUpdate = (propKey, data) => {
|
|
1301
|
+
updateOverridableProp({
|
|
1302
|
+
componentId: currentComponentId,
|
|
1303
|
+
propKey,
|
|
1304
|
+
label: data.label,
|
|
1305
|
+
groupId: data.group
|
|
1306
|
+
});
|
|
1307
|
+
setDocumentModifiedStatus2(true);
|
|
1308
|
+
};
|
|
1309
|
+
const handleGroupDelete = (groupId) => {
|
|
1310
|
+
deleteOverridableGroup({ componentId: currentComponentId, groupId });
|
|
1311
|
+
setDocumentModifiedStatus2(true);
|
|
1312
|
+
};
|
|
1313
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(PanelHeader, { sx: { justifyContent: "start", pl: 1.5, pr: 1, py: 1 } }, /* @__PURE__ */ React6.createElement(Stack4, { direction: "row", alignItems: "center", gap: 0.5, flexGrow: 1 }, /* @__PURE__ */ React6.createElement(ComponentPropListIcon2, { fontSize: "tiny" }), /* @__PURE__ */ React6.createElement(PanelHeaderTitle, { variant: "subtitle2" }, __7("Component properties", "elementor"))), !showEmptyState && /* @__PURE__ */ React6.createElement(Tooltip2, { title: __7("Add new group", "elementor") }, /* @__PURE__ */ React6.createElement(
|
|
1314
|
+
IconButton3,
|
|
1315
|
+
{
|
|
1316
|
+
size: "tiny",
|
|
1317
|
+
"aria-label": __7("Add new group", "elementor"),
|
|
1318
|
+
onClick: handleAddGroupClick
|
|
1319
|
+
},
|
|
1320
|
+
/* @__PURE__ */ React6.createElement(FolderPlusIcon, { fontSize: "tiny" })
|
|
1321
|
+
)), /* @__PURE__ */ React6.createElement(Tooltip2, { title: __7("Close panel", "elementor") }, /* @__PURE__ */ React6.createElement(IconButton3, { size: "tiny", "aria-label": __7("Close panel", "elementor"), onClick: onClose }, /* @__PURE__ */ React6.createElement(XIcon2, { fontSize: "tiny" })))), /* @__PURE__ */ React6.createElement(Divider, null), /* @__PURE__ */ React6.createElement(PanelBody, null, showEmptyState ? /* @__PURE__ */ React6.createElement(PropertiesEmptyState, null) : /* @__PURE__ */ React6.createElement(List2, { 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(
|
|
1322
|
+
PropertiesGroup,
|
|
1323
|
+
{
|
|
1324
|
+
group,
|
|
1325
|
+
props: overridableProps.props,
|
|
1326
|
+
allGroups: allGroupsForSelect,
|
|
1327
|
+
allGroupsRecord: overridableProps.groups.items,
|
|
1328
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle },
|
|
1329
|
+
isDragPlaceholder,
|
|
1330
|
+
setIsAddingGroup,
|
|
1331
|
+
onPropsReorder: (newOrder) => handlePropsReorder(group.id, newOrder),
|
|
1332
|
+
onPropertyDelete: handlePropertyDelete,
|
|
1333
|
+
onPropertyUpdate: handlePropertyUpdate,
|
|
1334
|
+
editableLabelProps: groupLabelEditable,
|
|
1335
|
+
onGroupDelete: handleGroupDelete
|
|
1336
|
+
}
|
|
1337
|
+
)))))));
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// src/components/component-properties-panel/component-properties-panel.tsx
|
|
1341
|
+
var id = "component-properties-panel";
|
|
1342
|
+
var { panel, usePanelActions } = createPanel({
|
|
1343
|
+
id,
|
|
1344
|
+
component: ComponentPropertiesPanel
|
|
1345
|
+
});
|
|
1346
|
+
function ComponentPropertiesPanel() {
|
|
1347
|
+
const { element, elementType } = useSelectedElement();
|
|
1348
|
+
const { close: closePanel } = usePanelActions();
|
|
1349
|
+
const { open: openEditingPanel } = useEditingPanelActions();
|
|
1350
|
+
if (!element || !elementType) {
|
|
1351
|
+
return null;
|
|
1352
|
+
}
|
|
1353
|
+
return /* @__PURE__ */ React7.createElement(ThemeProvider, null, /* @__PURE__ */ React7.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(ElementProvider, { element, elementType }, /* @__PURE__ */ React7.createElement(Panel, null, /* @__PURE__ */ React7.createElement(
|
|
1354
|
+
ComponentPropertiesPanelContent,
|
|
1355
|
+
{
|
|
1356
|
+
onClose: () => {
|
|
1357
|
+
closePanel();
|
|
1358
|
+
openEditingPanel();
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
)))));
|
|
354
1362
|
}
|
|
1363
|
+
var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, __8("Something went wrong", "elementor"))));
|
|
355
1364
|
|
|
356
|
-
// src/components/
|
|
357
|
-
import * as
|
|
358
|
-
import {
|
|
359
|
-
import {
|
|
360
|
-
import {
|
|
361
|
-
import { __ } from "@wordpress/i18n";
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
1365
|
+
// src/components/components-tab/component-introduction.tsx
|
|
1366
|
+
import * as React8 from "react";
|
|
1367
|
+
import { PopoverContent } from "@elementor/editor-controls";
|
|
1368
|
+
import { PopoverHeader } from "@elementor/editor-ui";
|
|
1369
|
+
import { Box as Box5, Button as Button2, Image, Popover as Popover2, Stack as Stack5, Typography as Typography5 } from "@elementor/ui";
|
|
1370
|
+
import { __ as __9 } from "@wordpress/i18n";
|
|
1371
|
+
var ComponentIntroduction = ({
|
|
1372
|
+
anchorRef,
|
|
1373
|
+
shouldShowIntroduction,
|
|
1374
|
+
onClose
|
|
1375
|
+
}) => {
|
|
1376
|
+
if (!anchorRef.current || !shouldShowIntroduction) {
|
|
1377
|
+
return null;
|
|
1378
|
+
}
|
|
1379
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1380
|
+
Popover2,
|
|
367
1381
|
{
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
1382
|
+
anchorEl: anchorRef.current,
|
|
1383
|
+
open: shouldShowIntroduction,
|
|
1384
|
+
anchorOrigin: {
|
|
1385
|
+
vertical: "top",
|
|
1386
|
+
horizontal: "right"
|
|
1387
|
+
},
|
|
1388
|
+
transformOrigin: {
|
|
1389
|
+
vertical: "top",
|
|
1390
|
+
horizontal: -30
|
|
1391
|
+
},
|
|
1392
|
+
onClose
|
|
374
1393
|
},
|
|
375
|
-
/* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ React8.createElement(Box5, { sx: { width: "296px" } }, /* @__PURE__ */ React8.createElement(PopoverHeader, { title: __9("Add your first property", "elementor"), onClose }), /* @__PURE__ */ React8.createElement(
|
|
1395
|
+
Image,
|
|
1396
|
+
{
|
|
1397
|
+
sx: { width: "296px", height: "160px" },
|
|
1398
|
+
src: "https://assets.elementor.com/packages/v1/images/components-properties-intro.png",
|
|
1399
|
+
alt: ""
|
|
1400
|
+
}
|
|
1401
|
+
), /* @__PURE__ */ React8.createElement(PopoverContent, null, /* @__PURE__ */ React8.createElement(Stack5, { gap: 1, sx: { p: 2 } }, /* @__PURE__ */ React8.createElement(Typography5, { variant: "body2" }, __9("Properties make instances flexible.", "elementor")), /* @__PURE__ */ React8.createElement(Typography5, { variant: "body2" }, __9(
|
|
1402
|
+
"Click next to any setting you want users to customize - like text, images, or links.",
|
|
1403
|
+
"elementor"
|
|
1404
|
+
)), /* @__PURE__ */ React8.createElement(Typography5, { variant: "body2" }, __9(
|
|
1405
|
+
"Your properties will appear in the Properties panel, where you can organize and manage them anytime.",
|
|
1406
|
+
"elementor"
|
|
1407
|
+
)), /* @__PURE__ */ React8.createElement(Stack5, { direction: "row", alignItems: "center", justifyContent: "flex-end" }, /* @__PURE__ */ React8.createElement(Button2, { size: "medium", variant: "contained", onClick: onClose }, __9("Got it", "elementor"))))))
|
|
376
1408
|
);
|
|
377
1409
|
};
|
|
378
|
-
|
|
1410
|
+
|
|
1411
|
+
// src/components/component-panel-header/component-badge.tsx
|
|
1412
|
+
import * as React9 from "react";
|
|
1413
|
+
import { useEffect, useRef } from "react";
|
|
1414
|
+
import { ComponentPropListIcon as ComponentPropListIcon3 } from "@elementor/icons";
|
|
1415
|
+
import { Badge, Box as Box6, keyframes, styled as styled2, ToggleButton } from "@elementor/ui";
|
|
1416
|
+
import { __ as __10 } from "@wordpress/i18n";
|
|
1417
|
+
var ComponentsBadge = React9.forwardRef(
|
|
1418
|
+
({ overridesCount, onClick }, ref) => {
|
|
1419
|
+
const prevCount = usePrevious(overridesCount);
|
|
1420
|
+
const isFirstOverride = prevCount === 0 && overridesCount === 1;
|
|
1421
|
+
return /* @__PURE__ */ React9.createElement(
|
|
1422
|
+
StyledBadge,
|
|
1423
|
+
{
|
|
1424
|
+
ref,
|
|
1425
|
+
color: "primary",
|
|
1426
|
+
key: overridesCount,
|
|
1427
|
+
invisible: overridesCount === 0,
|
|
1428
|
+
animate: isFirstOverride,
|
|
1429
|
+
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
1430
|
+
badgeContent: /* @__PURE__ */ React9.createElement(Box6, { sx: { animation: !isFirstOverride ? `${slideUp} 300ms ease-out` : "none" } }, overridesCount)
|
|
1431
|
+
},
|
|
1432
|
+
/* @__PURE__ */ React9.createElement(
|
|
1433
|
+
ToggleButton,
|
|
1434
|
+
{
|
|
1435
|
+
value: "overrides",
|
|
1436
|
+
size: "tiny",
|
|
1437
|
+
onClick,
|
|
1438
|
+
"aria-label": __10("View overrides", "elementor")
|
|
1439
|
+
},
|
|
1440
|
+
/* @__PURE__ */ React9.createElement(ComponentPropListIcon3, { fontSize: "tiny" })
|
|
1441
|
+
)
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
);
|
|
1445
|
+
var StyledBadge = styled2(Badge, { shouldForwardProp: (prop) => prop !== "animate" })(
|
|
379
1446
|
({ theme, animate }) => ({
|
|
380
1447
|
"& .MuiBadge-badge": {
|
|
381
1448
|
minWidth: theme.spacing(2),
|
|
@@ -404,38 +1471,43 @@ var slideUp = keyframes`
|
|
|
404
1471
|
to { transform: translateY(0); opacity: 1; }
|
|
405
1472
|
`;
|
|
406
1473
|
|
|
407
|
-
// src/components/component-panel-header/use-overridable-props.ts
|
|
408
|
-
import { __useSelector as useSelector3 } from "@elementor/store";
|
|
409
|
-
function useOverridableProps(componentId) {
|
|
410
|
-
return useSelector3((state) => {
|
|
411
|
-
if (!componentId) {
|
|
412
|
-
return void 0;
|
|
413
|
-
}
|
|
414
|
-
return selectOverridableProps(state, componentId);
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
|
|
418
1474
|
// src/components/component-panel-header/component-panel-header.tsx
|
|
1475
|
+
var MESSAGE_KEY = "components-properties-introduction";
|
|
419
1476
|
var ComponentPanelHeader = () => {
|
|
420
1477
|
const currentComponentId = useCurrentComponentId();
|
|
421
1478
|
const overridableProps = useOverridableProps(currentComponentId);
|
|
422
1479
|
const onBack = useNavigateBack();
|
|
423
1480
|
const componentName = getComponentName();
|
|
1481
|
+
const [isMessageSuppressed, suppressMessage] = useSuppressedMessage(MESSAGE_KEY);
|
|
1482
|
+
const [shouldShowIntroduction, setShouldShowIntroduction] = React10.useState(!isMessageSuppressed);
|
|
1483
|
+
const { open: openPropertiesPanel } = usePanelActions();
|
|
424
1484
|
const overridesCount = overridableProps ? Object.keys(overridableProps.props).length : 0;
|
|
1485
|
+
const anchorRef = React10.useRef(null);
|
|
425
1486
|
if (!currentComponentId) {
|
|
426
1487
|
return null;
|
|
427
1488
|
}
|
|
428
|
-
|
|
429
|
-
|
|
1489
|
+
const handleCloseIntroduction = () => {
|
|
1490
|
+
suppressMessage();
|
|
1491
|
+
setShouldShowIntroduction(false);
|
|
1492
|
+
};
|
|
1493
|
+
return /* @__PURE__ */ React10.createElement(Box7, null, /* @__PURE__ */ React10.createElement(
|
|
1494
|
+
Stack6,
|
|
430
1495
|
{
|
|
431
1496
|
direction: "row",
|
|
432
1497
|
alignItems: "center",
|
|
433
1498
|
justifyContent: "space-between",
|
|
434
1499
|
sx: { height: 48, pl: 1.5, pr: 2, py: 1 }
|
|
435
1500
|
},
|
|
436
|
-
/* @__PURE__ */
|
|
437
|
-
/* @__PURE__ */
|
|
438
|
-
), /* @__PURE__ */
|
|
1501
|
+
/* @__PURE__ */ React10.createElement(Stack6, { direction: "row", alignItems: "center" }, /* @__PURE__ */ React10.createElement(Tooltip3, { title: __11("Back", "elementor") }, /* @__PURE__ */ React10.createElement(IconButton4, { size: "tiny", onClick: onBack, "aria-label": __11("Back", "elementor") }, /* @__PURE__ */ React10.createElement(ArrowLeftIcon, { fontSize: "tiny" }))), /* @__PURE__ */ React10.createElement(Stack6, { direction: "row", alignItems: "center", gap: 0.5 }, /* @__PURE__ */ React10.createElement(ComponentsFilledIcon, { fontSize: "tiny", stroke: "currentColor" }), /* @__PURE__ */ React10.createElement(Typography6, { variant: "caption", sx: { fontWeight: 500 } }, componentName))),
|
|
1502
|
+
/* @__PURE__ */ React10.createElement(ComponentsBadge, { overridesCount, ref: anchorRef, onClick: openPropertiesPanel })
|
|
1503
|
+
), /* @__PURE__ */ React10.createElement(Divider2, null), /* @__PURE__ */ React10.createElement(
|
|
1504
|
+
ComponentIntroduction,
|
|
1505
|
+
{
|
|
1506
|
+
anchorRef,
|
|
1507
|
+
shouldShowIntroduction,
|
|
1508
|
+
onClose: handleCloseIntroduction
|
|
1509
|
+
}
|
|
1510
|
+
));
|
|
439
1511
|
};
|
|
440
1512
|
function getComponentName() {
|
|
441
1513
|
const documentsManager = getV1DocumentsManager3();
|
|
@@ -444,17 +1516,17 @@ function getComponentName() {
|
|
|
444
1516
|
}
|
|
445
1517
|
|
|
446
1518
|
// src/components/components-tab/components.tsx
|
|
447
|
-
import * as
|
|
448
|
-
import { ThemeProvider } from "@elementor/editor-ui";
|
|
1519
|
+
import * as React16 from "react";
|
|
1520
|
+
import { ThemeProvider as ThemeProvider2 } from "@elementor/editor-ui";
|
|
449
1521
|
|
|
450
1522
|
// src/components/components-tab/component-search.tsx
|
|
451
|
-
import * as
|
|
1523
|
+
import * as React12 from "react";
|
|
452
1524
|
import { SearchIcon } from "@elementor/icons";
|
|
453
|
-
import { Box as
|
|
454
|
-
import { __ as
|
|
1525
|
+
import { Box as Box8, InputAdornment, Stack as Stack7, TextField as TextField2 } from "@elementor/ui";
|
|
1526
|
+
import { __ as __12 } from "@wordpress/i18n";
|
|
455
1527
|
|
|
456
1528
|
// src/components/components-tab/search-provider.tsx
|
|
457
|
-
import * as
|
|
1529
|
+
import * as React11 from "react";
|
|
458
1530
|
import { createContext, useContext } from "react";
|
|
459
1531
|
import { useSearchState } from "@elementor/utils";
|
|
460
1532
|
var SearchContext = createContext(void 0);
|
|
@@ -466,7 +1538,7 @@ var SearchProvider = ({
|
|
|
466
1538
|
const clearSearch = () => {
|
|
467
1539
|
handleChange("");
|
|
468
1540
|
};
|
|
469
|
-
return /* @__PURE__ */
|
|
1541
|
+
return /* @__PURE__ */ React11.createElement(SearchContext.Provider, { value: { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }, children);
|
|
470
1542
|
};
|
|
471
1543
|
var useSearch = () => {
|
|
472
1544
|
const context = useContext(SearchContext);
|
|
@@ -479,27 +1551,27 @@ var useSearch = () => {
|
|
|
479
1551
|
// src/components/components-tab/component-search.tsx
|
|
480
1552
|
var ComponentSearch = () => {
|
|
481
1553
|
const { inputValue, handleChange } = useSearch();
|
|
482
|
-
return /* @__PURE__ */
|
|
483
|
-
|
|
1554
|
+
return /* @__PURE__ */ React12.createElement(Stack7, { direction: "row", gap: 0.5, sx: { width: "100%", px: 2, py: 1.5 } }, /* @__PURE__ */ React12.createElement(Box8, { sx: { flexGrow: 1 } }, /* @__PURE__ */ React12.createElement(
|
|
1555
|
+
TextField2,
|
|
484
1556
|
{
|
|
485
1557
|
role: "search",
|
|
486
1558
|
fullWidth: true,
|
|
487
1559
|
size: "tiny",
|
|
488
1560
|
value: inputValue,
|
|
489
|
-
placeholder:
|
|
1561
|
+
placeholder: __12("Search", "elementor"),
|
|
490
1562
|
onChange: (e) => handleChange(e.target.value),
|
|
491
1563
|
InputProps: {
|
|
492
|
-
startAdornment: /* @__PURE__ */
|
|
1564
|
+
startAdornment: /* @__PURE__ */ React12.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React12.createElement(SearchIcon, { fontSize: "tiny" }))
|
|
493
1565
|
}
|
|
494
1566
|
}
|
|
495
1567
|
)));
|
|
496
1568
|
};
|
|
497
1569
|
|
|
498
1570
|
// src/components/components-tab/components-list.tsx
|
|
499
|
-
import * as
|
|
1571
|
+
import * as React15 from "react";
|
|
500
1572
|
import { ComponentsIcon as ComponentsIcon2, EyeIcon } from "@elementor/icons";
|
|
501
|
-
import { Box as
|
|
502
|
-
import { __ as
|
|
1573
|
+
import { Box as Box11, Divider as Divider3, Icon, Link as Link2, List as List3, Stack as Stack10, Typography as Typography8 } from "@elementor/ui";
|
|
1574
|
+
import { __ as __15 } from "@wordpress/i18n";
|
|
503
1575
|
|
|
504
1576
|
// src/hooks/use-components.ts
|
|
505
1577
|
import { __useSelector as useSelector4 } from "@elementor/store";
|
|
@@ -510,51 +1582,51 @@ var useComponents = () => {
|
|
|
510
1582
|
};
|
|
511
1583
|
|
|
512
1584
|
// src/components/components-tab/components-item.tsx
|
|
513
|
-
import * as
|
|
1585
|
+
import * as React13 from "react";
|
|
514
1586
|
import { endDragElementFromPanel, startDragElementFromPanel } from "@elementor/editor-canvas";
|
|
515
1587
|
import { dropElement } from "@elementor/editor-elements";
|
|
516
|
-
import { EllipsisWithTooltip, MenuListItem } from "@elementor/editor-ui";
|
|
517
|
-
import { ComponentsIcon, DotsVerticalIcon } from "@elementor/icons";
|
|
1588
|
+
import { EllipsisWithTooltip, MenuListItem as MenuListItem3 } from "@elementor/editor-ui";
|
|
1589
|
+
import { ComponentsIcon, DotsVerticalIcon as DotsVerticalIcon2 } from "@elementor/icons";
|
|
518
1590
|
import {
|
|
519
|
-
bindMenu,
|
|
520
|
-
bindTrigger,
|
|
521
|
-
Box as
|
|
522
|
-
IconButton as
|
|
1591
|
+
bindMenu as bindMenu2,
|
|
1592
|
+
bindTrigger as bindTrigger3,
|
|
1593
|
+
Box as Box9,
|
|
1594
|
+
IconButton as IconButton5,
|
|
523
1595
|
ListItemButton,
|
|
524
1596
|
ListItemIcon,
|
|
525
|
-
Menu,
|
|
526
|
-
Stack as
|
|
527
|
-
Typography as
|
|
528
|
-
usePopupState
|
|
1597
|
+
Menu as Menu2,
|
|
1598
|
+
Stack as Stack8,
|
|
1599
|
+
Typography as Typography7,
|
|
1600
|
+
usePopupState as usePopupState3
|
|
529
1601
|
} from "@elementor/ui";
|
|
530
|
-
import { __ as
|
|
1602
|
+
import { __ as __14 } from "@wordpress/i18n";
|
|
531
1603
|
|
|
532
1604
|
// src/store/actions/archive-component.ts
|
|
533
|
-
import { setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
1605
|
+
import { setDocumentModifiedStatus as setDocumentModifiedStatus3 } from "@elementor/editor-documents";
|
|
534
1606
|
import { __getStore as getStore } from "@elementor/store";
|
|
535
1607
|
var archiveComponent = (componentId) => {
|
|
536
1608
|
const store = getStore();
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
1609
|
+
const dispatch16 = store?.dispatch;
|
|
1610
|
+
if (!dispatch16) {
|
|
539
1611
|
return;
|
|
540
1612
|
}
|
|
541
|
-
|
|
542
|
-
|
|
1613
|
+
dispatch16(slice.actions.archive(componentId));
|
|
1614
|
+
setDocumentModifiedStatus3(true);
|
|
543
1615
|
};
|
|
544
1616
|
|
|
545
1617
|
// src/store/actions/load-components-assets.ts
|
|
546
|
-
import { isDocumentDirty, setDocumentModifiedStatus as
|
|
1618
|
+
import { isDocumentDirty, setDocumentModifiedStatus as setDocumentModifiedStatus4 } from "@elementor/editor-documents";
|
|
547
1619
|
|
|
548
1620
|
// src/create-component-type.ts
|
|
549
1621
|
import {
|
|
550
1622
|
createTemplatedElementView
|
|
551
1623
|
} from "@elementor/editor-canvas";
|
|
552
1624
|
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
553
|
-
import { __ as
|
|
1625
|
+
import { __ as __13 } from "@wordpress/i18n";
|
|
554
1626
|
|
|
555
1627
|
// src/utils/tracking.ts
|
|
556
1628
|
import { getMixpanel } from "@elementor/mixpanel";
|
|
557
|
-
import { __getState as
|
|
1629
|
+
import { __getState as getState9 } from "@elementor/store";
|
|
558
1630
|
var trackComponentEvent = ({ action, ...data }) => {
|
|
559
1631
|
const { dispatchEvent, config } = getMixpanel();
|
|
560
1632
|
if (!config?.names?.components?.[action]) {
|
|
@@ -571,7 +1643,7 @@ var onElementDrop = (_args, element) => {
|
|
|
571
1643
|
const componentName = editorSettings?.title;
|
|
572
1644
|
const componentUID = editorSettings?.component_uid;
|
|
573
1645
|
const instanceId = element.id;
|
|
574
|
-
const createdThisSession = selectCreatedThisSession(
|
|
1646
|
+
const createdThisSession = selectCreatedThisSession(getState9());
|
|
575
1647
|
const isSameSessionReuse = componentUID && createdThisSession.includes(componentUID);
|
|
576
1648
|
const eventsManagerConfig = window.elementorCommon.eventsManager.config;
|
|
577
1649
|
const { locations, secondaryLocations } = eventsManagerConfig;
|
|
@@ -670,7 +1742,7 @@ function createComponentView(options) {
|
|
|
670
1742
|
action: {
|
|
671
1743
|
name: "edit component",
|
|
672
1744
|
icon: "eicon-edit",
|
|
673
|
-
title: () =>
|
|
1745
|
+
title: () => __13("Edit Component", "elementor"),
|
|
674
1746
|
isEnabled: () => true,
|
|
675
1747
|
callback: (_, eventData) => this.editComponent(eventData)
|
|
676
1748
|
}
|
|
@@ -765,7 +1837,7 @@ var getComponentIds = async (elements) => {
|
|
|
765
1837
|
};
|
|
766
1838
|
|
|
767
1839
|
// src/store/actions/load-components-overridable-props.ts
|
|
768
|
-
import { __dispatch as
|
|
1840
|
+
import { __dispatch as dispatch8, __getState as getState10 } from "@elementor/store";
|
|
769
1841
|
function loadComponentsOverridableProps(componentIds) {
|
|
770
1842
|
if (!componentIds.length) {
|
|
771
1843
|
return;
|
|
@@ -773,7 +1845,7 @@ function loadComponentsOverridableProps(componentIds) {
|
|
|
773
1845
|
componentIds.forEach(loadComponentOverrides);
|
|
774
1846
|
}
|
|
775
1847
|
async function loadComponentOverrides(componentId) {
|
|
776
|
-
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(
|
|
1848
|
+
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(getState10(), componentId);
|
|
777
1849
|
if (isOverridablePropsLoaded) {
|
|
778
1850
|
return;
|
|
779
1851
|
}
|
|
@@ -781,7 +1853,7 @@ async function loadComponentOverrides(componentId) {
|
|
|
781
1853
|
if (!overridableProps) {
|
|
782
1854
|
return;
|
|
783
1855
|
}
|
|
784
|
-
|
|
1856
|
+
dispatch8(
|
|
785
1857
|
slice.actions.setOverridableProps({
|
|
786
1858
|
componentId,
|
|
787
1859
|
overridableProps
|
|
@@ -790,13 +1862,13 @@ async function loadComponentOverrides(componentId) {
|
|
|
790
1862
|
}
|
|
791
1863
|
|
|
792
1864
|
// src/store/actions/load-components-styles.ts
|
|
793
|
-
import { __dispatch as
|
|
1865
|
+
import { __dispatch as dispatch9, __getState as getState11 } from "@elementor/store";
|
|
794
1866
|
async function loadComponentsStyles(componentIds) {
|
|
795
1867
|
if (!componentIds.length) {
|
|
796
1868
|
return;
|
|
797
1869
|
}
|
|
798
|
-
const knownComponents = selectStyles(
|
|
799
|
-
const unknownComponentIds = componentIds.filter((
|
|
1870
|
+
const knownComponents = selectStyles(getState11());
|
|
1871
|
+
const unknownComponentIds = componentIds.filter((id2) => !knownComponents[id2]);
|
|
800
1872
|
if (!unknownComponentIds.length) {
|
|
801
1873
|
return;
|
|
802
1874
|
}
|
|
@@ -807,13 +1879,13 @@ async function addComponentStyles(ids) {
|
|
|
807
1879
|
addStyles(newComponents);
|
|
808
1880
|
}
|
|
809
1881
|
async function loadStyles(ids) {
|
|
810
|
-
return Promise.all(ids.map(async (
|
|
1882
|
+
return Promise.all(ids.map(async (id2) => [id2, await apiClient.getComponentConfig(id2)]));
|
|
811
1883
|
}
|
|
812
1884
|
function addStyles(data) {
|
|
813
1885
|
const styles = Object.fromEntries(
|
|
814
1886
|
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
815
1887
|
);
|
|
816
|
-
|
|
1888
|
+
dispatch9(slice.actions.addStyles(styles));
|
|
817
1889
|
}
|
|
818
1890
|
function extractStyles(element) {
|
|
819
1891
|
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
@@ -834,13 +1906,13 @@ async function updateDocumentState(componentIds) {
|
|
|
834
1906
|
);
|
|
835
1907
|
const isDrafted = components.some(isDocumentDirty);
|
|
836
1908
|
if (isDrafted) {
|
|
837
|
-
|
|
1909
|
+
setDocumentModifiedStatus4(true);
|
|
838
1910
|
}
|
|
839
1911
|
}
|
|
840
1912
|
|
|
841
1913
|
// src/utils/get-container-for-new-element.ts
|
|
842
1914
|
import {
|
|
843
|
-
getContainer,
|
|
1915
|
+
getContainer as getContainer2,
|
|
844
1916
|
getCurrentDocumentContainer,
|
|
845
1917
|
getSelectedElements
|
|
846
1918
|
} from "@elementor/editor-elements";
|
|
@@ -875,7 +1947,7 @@ function getSelectedElementContainer() {
|
|
|
875
1947
|
if (selectedElements.length !== 1) {
|
|
876
1948
|
return void 0;
|
|
877
1949
|
}
|
|
878
|
-
return
|
|
1950
|
+
return getContainer2(selectedElements[0].id);
|
|
879
1951
|
}
|
|
880
1952
|
|
|
881
1953
|
// src/components/create-component-form/utils/replace-element-with-component.ts
|
|
@@ -913,7 +1985,7 @@ var createComponentModel = (component) => {
|
|
|
913
1985
|
// src/components/components-tab/components-item.tsx
|
|
914
1986
|
var ComponentItem = ({ component }) => {
|
|
915
1987
|
const componentModel = createComponentModel(component);
|
|
916
|
-
const popupState =
|
|
1988
|
+
const popupState = usePopupState3({
|
|
917
1989
|
variant: "popover",
|
|
918
1990
|
disableAutoFocus: true
|
|
919
1991
|
});
|
|
@@ -931,7 +2003,7 @@ var ComponentItem = ({ component }) => {
|
|
|
931
2003
|
}
|
|
932
2004
|
archiveComponent(component.id);
|
|
933
2005
|
};
|
|
934
|
-
return /* @__PURE__ */
|
|
2006
|
+
return /* @__PURE__ */ React13.createElement(Stack8, null, /* @__PURE__ */ React13.createElement(
|
|
935
2007
|
ListItemButton,
|
|
936
2008
|
{
|
|
937
2009
|
draggable: true,
|
|
@@ -949,8 +2021,8 @@ var ComponentItem = ({ component }) => {
|
|
|
949
2021
|
gap: 1
|
|
950
2022
|
}
|
|
951
2023
|
},
|
|
952
|
-
/* @__PURE__ */
|
|
953
|
-
|
|
2024
|
+
/* @__PURE__ */ React13.createElement(
|
|
2025
|
+
Box9,
|
|
954
2026
|
{
|
|
955
2027
|
onClick: handleClick,
|
|
956
2028
|
sx: {
|
|
@@ -961,22 +2033,22 @@ var ComponentItem = ({ component }) => {
|
|
|
961
2033
|
flexGrow: 1
|
|
962
2034
|
}
|
|
963
2035
|
},
|
|
964
|
-
/* @__PURE__ */
|
|
965
|
-
/* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ React13.createElement(ListItemIcon, { size: "tiny" }, /* @__PURE__ */ React13.createElement(ComponentsIcon, { fontSize: "tiny" })),
|
|
2037
|
+
/* @__PURE__ */ React13.createElement(Box9, { display: "flex", flex: 1, minWidth: 0, flexGrow: 1 }, /* @__PURE__ */ React13.createElement(
|
|
966
2038
|
EllipsisWithTooltip,
|
|
967
2039
|
{
|
|
968
2040
|
title: component.name,
|
|
969
|
-
as:
|
|
2041
|
+
as: Typography7,
|
|
970
2042
|
variant: "caption",
|
|
971
2043
|
color: "text.primary"
|
|
972
2044
|
}
|
|
973
2045
|
))
|
|
974
2046
|
),
|
|
975
|
-
/* @__PURE__ */
|
|
976
|
-
), /* @__PURE__ */
|
|
977
|
-
|
|
2047
|
+
/* @__PURE__ */ React13.createElement(IconButton5, { size: "tiny", ...bindTrigger3(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React13.createElement(DotsVerticalIcon2, { fontSize: "tiny" }))
|
|
2048
|
+
), /* @__PURE__ */ React13.createElement(
|
|
2049
|
+
Menu2,
|
|
978
2050
|
{
|
|
979
|
-
...
|
|
2051
|
+
...bindMenu2(popupState),
|
|
980
2052
|
anchorOrigin: {
|
|
981
2053
|
vertical: "bottom",
|
|
982
2054
|
horizontal: "right"
|
|
@@ -986,7 +2058,7 @@ var ComponentItem = ({ component }) => {
|
|
|
986
2058
|
horizontal: "right"
|
|
987
2059
|
}
|
|
988
2060
|
},
|
|
989
|
-
/* @__PURE__ */
|
|
2061
|
+
/* @__PURE__ */ React13.createElement(MenuListItem3, { sx: { minWidth: "160px" }, onClick: handleArchiveClick }, __14("Archive", "elementor"))
|
|
990
2062
|
));
|
|
991
2063
|
};
|
|
992
2064
|
var addComponentToPage = (model) => {
|
|
@@ -1003,13 +2075,13 @@ var addComponentToPage = (model) => {
|
|
|
1003
2075
|
};
|
|
1004
2076
|
|
|
1005
2077
|
// src/components/components-tab/loading-components.tsx
|
|
1006
|
-
import * as
|
|
1007
|
-
import { Box as
|
|
2078
|
+
import * as React14 from "react";
|
|
2079
|
+
import { Box as Box10, ListItemButton as ListItemButton2, Skeleton, Stack as Stack9 } from "@elementor/ui";
|
|
1008
2080
|
var ROWS_COUNT = 6;
|
|
1009
2081
|
var rows = Array.from({ length: ROWS_COUNT }, (_, index) => index);
|
|
1010
2082
|
var LoadingComponents = () => {
|
|
1011
|
-
return /* @__PURE__ */
|
|
1012
|
-
|
|
2083
|
+
return /* @__PURE__ */ React14.createElement(
|
|
2084
|
+
Stack9,
|
|
1013
2085
|
{
|
|
1014
2086
|
"aria-label": "Loading components",
|
|
1015
2087
|
gap: 1,
|
|
@@ -1030,14 +2102,14 @@ var LoadingComponents = () => {
|
|
|
1030
2102
|
}
|
|
1031
2103
|
}
|
|
1032
2104
|
},
|
|
1033
|
-
rows.map((row) => /* @__PURE__ */
|
|
2105
|
+
rows.map((row) => /* @__PURE__ */ React14.createElement(
|
|
1034
2106
|
ListItemButton2,
|
|
1035
2107
|
{
|
|
1036
2108
|
key: row,
|
|
1037
2109
|
sx: { border: "solid 1px", borderColor: "divider", py: 0.5, px: 1 },
|
|
1038
2110
|
shape: "rounded"
|
|
1039
2111
|
},
|
|
1040
|
-
/* @__PURE__ */
|
|
2112
|
+
/* @__PURE__ */ React14.createElement(Box10, { display: "flex", gap: 1, width: "100%" }, /* @__PURE__ */ React14.createElement(Skeleton, { variant: "text", width: "24px", height: "36px" }), /* @__PURE__ */ React14.createElement(Skeleton, { variant: "text", width: "100%", height: "36px" }))
|
|
1041
2113
|
))
|
|
1042
2114
|
);
|
|
1043
2115
|
};
|
|
@@ -1046,20 +2118,20 @@ var LoadingComponents = () => {
|
|
|
1046
2118
|
function ComponentsList() {
|
|
1047
2119
|
const { components, isLoading, searchValue } = useFilteredComponents();
|
|
1048
2120
|
if (isLoading) {
|
|
1049
|
-
return /* @__PURE__ */
|
|
2121
|
+
return /* @__PURE__ */ React15.createElement(LoadingComponents, null);
|
|
1050
2122
|
}
|
|
1051
2123
|
const isEmpty = !components || components.length === 0;
|
|
1052
2124
|
if (isEmpty) {
|
|
1053
2125
|
if (searchValue.length > 0) {
|
|
1054
|
-
return /* @__PURE__ */
|
|
2126
|
+
return /* @__PURE__ */ React15.createElement(EmptySearchResult, null);
|
|
1055
2127
|
}
|
|
1056
|
-
return /* @__PURE__ */
|
|
2128
|
+
return /* @__PURE__ */ React15.createElement(EmptyState, null);
|
|
1057
2129
|
}
|
|
1058
|
-
return /* @__PURE__ */
|
|
2130
|
+
return /* @__PURE__ */ React15.createElement(List3, { sx: { display: "flex", flexDirection: "column", gap: 1, px: 2 } }, components.map((component) => /* @__PURE__ */ React15.createElement(ComponentItem, { key: component.uid, component })));
|
|
1059
2131
|
}
|
|
1060
2132
|
var EmptyState = () => {
|
|
1061
|
-
return /* @__PURE__ */
|
|
1062
|
-
|
|
2133
|
+
return /* @__PURE__ */ React15.createElement(
|
|
2134
|
+
Stack10,
|
|
1063
2135
|
{
|
|
1064
2136
|
alignItems: "center",
|
|
1065
2137
|
justifyContent: "center",
|
|
@@ -1068,32 +2140,32 @@ var EmptyState = () => {
|
|
|
1068
2140
|
gap: 1.75,
|
|
1069
2141
|
overflow: "hidden"
|
|
1070
2142
|
},
|
|
1071
|
-
/* @__PURE__ */
|
|
1072
|
-
/* @__PURE__ */
|
|
1073
|
-
/* @__PURE__ */
|
|
2143
|
+
/* @__PURE__ */ React15.createElement(Icon, { fontSize: "large" }, /* @__PURE__ */ React15.createElement(EyeIcon, { fontSize: "large" })),
|
|
2144
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, __15("Text that explains that there are no Components yet.", "elementor")),
|
|
2145
|
+
/* @__PURE__ */ React15.createElement(Typography8, { variant: "caption", align: "center", color: "text.secondary" }, __15(
|
|
1074
2146
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
1075
2147
|
"elementor"
|
|
1076
2148
|
)),
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
/* @__PURE__ */
|
|
1080
|
-
|
|
2149
|
+
/* @__PURE__ */ React15.createElement(Divider3, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
2150
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "left", variant: "caption", color: "text.secondary" }, __15("To create a component, first design it, then choose one of three options:", "elementor")),
|
|
2151
|
+
/* @__PURE__ */ React15.createElement(
|
|
2152
|
+
Typography8,
|
|
1081
2153
|
{
|
|
1082
2154
|
align: "left",
|
|
1083
2155
|
variant: "caption",
|
|
1084
2156
|
color: "text.secondary",
|
|
1085
2157
|
sx: { display: "flex", flexDirection: "column" }
|
|
1086
2158
|
},
|
|
1087
|
-
/* @__PURE__ */
|
|
1088
|
-
/* @__PURE__ */
|
|
1089
|
-
/* @__PURE__ */
|
|
2159
|
+
/* @__PURE__ */ React15.createElement("span", null, __15("1. Right-click and select Create Component", "elementor")),
|
|
2160
|
+
/* @__PURE__ */ React15.createElement("span", null, __15("2. Use the component icon in the Structure panel", "elementor")),
|
|
2161
|
+
/* @__PURE__ */ React15.createElement("span", null, __15("3. Use the component icon in the Edit panel header", "elementor"))
|
|
1090
2162
|
)
|
|
1091
2163
|
);
|
|
1092
2164
|
};
|
|
1093
2165
|
var EmptySearchResult = () => {
|
|
1094
2166
|
const { searchValue, clearSearch } = useSearch();
|
|
1095
|
-
return /* @__PURE__ */
|
|
1096
|
-
|
|
2167
|
+
return /* @__PURE__ */ React15.createElement(
|
|
2168
|
+
Stack10,
|
|
1097
2169
|
{
|
|
1098
2170
|
color: "text.secondary",
|
|
1099
2171
|
pt: 5,
|
|
@@ -1102,17 +2174,17 @@ var EmptySearchResult = () => {
|
|
|
1102
2174
|
overflow: "hidden",
|
|
1103
2175
|
justifySelf: "center"
|
|
1104
2176
|
},
|
|
1105
|
-
/* @__PURE__ */
|
|
1106
|
-
/* @__PURE__ */
|
|
1107
|
-
|
|
2177
|
+
/* @__PURE__ */ React15.createElement(ComponentsIcon2, null),
|
|
2178
|
+
/* @__PURE__ */ React15.createElement(
|
|
2179
|
+
Box11,
|
|
1108
2180
|
{
|
|
1109
2181
|
sx: {
|
|
1110
2182
|
width: "100%"
|
|
1111
2183
|
}
|
|
1112
2184
|
},
|
|
1113
|
-
/* @__PURE__ */
|
|
1114
|
-
searchValue && /* @__PURE__ */
|
|
1115
|
-
|
|
2185
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "inherit" }, __15("Sorry, nothing matched", "elementor")),
|
|
2186
|
+
searchValue && /* @__PURE__ */ React15.createElement(
|
|
2187
|
+
Typography8,
|
|
1116
2188
|
{
|
|
1117
2189
|
variant: "subtitle2",
|
|
1118
2190
|
color: "inherit",
|
|
@@ -1122,8 +2194,8 @@ var EmptySearchResult = () => {
|
|
|
1122
2194
|
justifyContent: "center"
|
|
1123
2195
|
}
|
|
1124
2196
|
},
|
|
1125
|
-
/* @__PURE__ */
|
|
1126
|
-
/* @__PURE__ */
|
|
2197
|
+
/* @__PURE__ */ React15.createElement("span", null, "\u201C"),
|
|
2198
|
+
/* @__PURE__ */ React15.createElement(
|
|
1127
2199
|
"span",
|
|
1128
2200
|
{
|
|
1129
2201
|
style: {
|
|
@@ -1134,11 +2206,11 @@ var EmptySearchResult = () => {
|
|
|
1134
2206
|
},
|
|
1135
2207
|
searchValue
|
|
1136
2208
|
),
|
|
1137
|
-
/* @__PURE__ */
|
|
2209
|
+
/* @__PURE__ */ React15.createElement("span", null, "\u201D.")
|
|
1138
2210
|
)
|
|
1139
2211
|
),
|
|
1140
|
-
/* @__PURE__ */
|
|
1141
|
-
/* @__PURE__ */
|
|
2212
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "caption", color: "inherit" }, __15("Try something else.", "elementor")),
|
|
2213
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React15.createElement(Link2, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, __15("Clear & try again", "elementor")))
|
|
1142
2214
|
);
|
|
1143
2215
|
};
|
|
1144
2216
|
var useFilteredComponents = () => {
|
|
@@ -1155,35 +2227,35 @@ var useFilteredComponents = () => {
|
|
|
1155
2227
|
|
|
1156
2228
|
// src/components/components-tab/components.tsx
|
|
1157
2229
|
var Components = () => {
|
|
1158
|
-
return /* @__PURE__ */
|
|
2230
|
+
return /* @__PURE__ */ React16.createElement(ThemeProvider2, null, /* @__PURE__ */ React16.createElement(SearchProvider, { localStorageKey: "elementor-components-search" }, /* @__PURE__ */ React16.createElement(ComponentSearch, null), /* @__PURE__ */ React16.createElement(ComponentsList, null)));
|
|
1159
2231
|
};
|
|
1160
2232
|
|
|
1161
2233
|
// src/components/consts.ts
|
|
1162
2234
|
var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
1163
2235
|
|
|
1164
2236
|
// src/components/create-component-form/create-component-form.tsx
|
|
1165
|
-
import * as
|
|
1166
|
-
import { useEffect as useEffect2, useMemo as
|
|
2237
|
+
import * as React17 from "react";
|
|
2238
|
+
import { useEffect as useEffect2, useMemo as useMemo3, useRef as useRef3, useState as useState6 } from "react";
|
|
1167
2239
|
import { getElementLabel } from "@elementor/editor-elements";
|
|
1168
|
-
import { Form as FormElement, ThemeProvider as
|
|
2240
|
+
import { Form as FormElement, ThemeProvider as ThemeProvider3 } from "@elementor/editor-ui";
|
|
1169
2241
|
import { StarIcon } from "@elementor/icons";
|
|
1170
|
-
import { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack as
|
|
1171
|
-
import { __ as
|
|
2242
|
+
import { Alert as Alert2, Button as Button3, FormLabel as FormLabel2, Grid as Grid2, Popover as Popover3, Snackbar, Stack as Stack11, TextField as TextField3, Typography as Typography9 } from "@elementor/ui";
|
|
2243
|
+
import { __ as __17 } from "@wordpress/i18n";
|
|
1172
2244
|
|
|
1173
2245
|
// src/store/actions/create-unpublished-component.ts
|
|
1174
2246
|
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
1175
|
-
import { __dispatch as
|
|
1176
|
-
import { generateUniqueId } from "@elementor/utils";
|
|
2247
|
+
import { __dispatch as dispatch10 } from "@elementor/store";
|
|
2248
|
+
import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
|
|
1177
2249
|
function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
|
|
1178
|
-
const generatedUid = uid ??
|
|
2250
|
+
const generatedUid = uid ?? generateUniqueId3("component");
|
|
1179
2251
|
const componentBase = { uid: generatedUid, name, overridableProps };
|
|
1180
|
-
|
|
2252
|
+
dispatch10(
|
|
1181
2253
|
slice.actions.addUnpublished({
|
|
1182
2254
|
...componentBase,
|
|
1183
2255
|
elements: [element]
|
|
1184
2256
|
})
|
|
1185
2257
|
);
|
|
1186
|
-
|
|
2258
|
+
dispatch10(slice.actions.addCreatedThisSession(generatedUid));
|
|
1187
2259
|
replaceElementWithComponent(element, componentBase);
|
|
1188
2260
|
trackComponentEvent({
|
|
1189
2261
|
action: "created",
|
|
@@ -1196,11 +2268,11 @@ function createUnpublishedComponent(name, element, eventData, overridableProps,
|
|
|
1196
2268
|
}
|
|
1197
2269
|
|
|
1198
2270
|
// src/components/create-component-form/hooks/use-form.ts
|
|
1199
|
-
import { useMemo, useState } from "react";
|
|
2271
|
+
import { useMemo as useMemo2, useState as useState5 } from "react";
|
|
1200
2272
|
var useForm = (initialValues) => {
|
|
1201
|
-
const [values, setValues] =
|
|
1202
|
-
const [errors, setErrors] =
|
|
1203
|
-
const isValid =
|
|
2273
|
+
const [values, setValues] = useState5(initialValues);
|
|
2274
|
+
const [errors, setErrors] = useState5({});
|
|
2275
|
+
const isValid = useMemo2(() => {
|
|
1204
2276
|
return !Object.values(errors).some((error) => error);
|
|
1205
2277
|
}, [errors]);
|
|
1206
2278
|
const handleChange = (e, field, validationSchema) => {
|
|
@@ -1246,16 +2318,16 @@ var validateForm = (values, schema) => {
|
|
|
1246
2318
|
|
|
1247
2319
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
1248
2320
|
import { z } from "@elementor/schema";
|
|
1249
|
-
import { __ as
|
|
2321
|
+
import { __ as __16 } from "@wordpress/i18n";
|
|
1250
2322
|
var MIN_NAME_LENGTH = 2;
|
|
1251
2323
|
var MAX_NAME_LENGTH = 50;
|
|
1252
2324
|
var createBaseComponentSchema = (existingNames) => {
|
|
1253
2325
|
return z.object({
|
|
1254
2326
|
componentName: z.string().trim().max(
|
|
1255
2327
|
MAX_NAME_LENGTH,
|
|
1256
|
-
|
|
2328
|
+
__16("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
1257
2329
|
).refine((value) => !existingNames.includes(value), {
|
|
1258
|
-
message:
|
|
2330
|
+
message: __16("Component name already exists", "elementor")
|
|
1259
2331
|
})
|
|
1260
2332
|
});
|
|
1261
2333
|
};
|
|
@@ -1263,9 +2335,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
1263
2335
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
1264
2336
|
return baseSchema.extend({
|
|
1265
2337
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
1266
|
-
message:
|
|
2338
|
+
message: __16("Component name is required.", "elementor")
|
|
1267
2339
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
1268
|
-
message:
|
|
2340
|
+
message: __16("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
1269
2341
|
})
|
|
1270
2342
|
});
|
|
1271
2343
|
};
|
|
@@ -1301,10 +2373,10 @@ function countNestedElements(container) {
|
|
|
1301
2373
|
|
|
1302
2374
|
// src/components/create-component-form/create-component-form.tsx
|
|
1303
2375
|
function CreateComponentForm() {
|
|
1304
|
-
const [element, setElement] =
|
|
1305
|
-
const [anchorPosition, setAnchorPosition] =
|
|
1306
|
-
const [resultNotification, setResultNotification] =
|
|
1307
|
-
const eventData =
|
|
2376
|
+
const [element, setElement] = useState6(null);
|
|
2377
|
+
const [anchorPosition, setAnchorPosition] = useState6();
|
|
2378
|
+
const [resultNotification, setResultNotification] = useState6(null);
|
|
2379
|
+
const eventData = useRef3(null);
|
|
1308
2380
|
useEffect2(() => {
|
|
1309
2381
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
1310
2382
|
const openPopup = (event) => {
|
|
@@ -1330,12 +2402,12 @@ function CreateComponentForm() {
|
|
|
1330
2402
|
setResultNotification({
|
|
1331
2403
|
show: true,
|
|
1332
2404
|
// Translators: %1$s: Component name, %2$s: Component UID
|
|
1333
|
-
message:
|
|
2405
|
+
message: __17("Component saved successfully as: %1$s (UID: %2$s)", "elementor").replace("%1$s", values.componentName).replace("%2$s", uid),
|
|
1334
2406
|
type: "success"
|
|
1335
2407
|
});
|
|
1336
2408
|
resetAndClosePopup();
|
|
1337
2409
|
} catch {
|
|
1338
|
-
const errorMessage =
|
|
2410
|
+
const errorMessage = __17("Failed to save component. Please try again.", "elementor");
|
|
1339
2411
|
setResultNotification({
|
|
1340
2412
|
show: true,
|
|
1341
2413
|
message: errorMessage,
|
|
@@ -1354,24 +2426,24 @@ function CreateComponentForm() {
|
|
|
1354
2426
|
...eventData.current
|
|
1355
2427
|
});
|
|
1356
2428
|
};
|
|
1357
|
-
return /* @__PURE__ */
|
|
1358
|
-
|
|
2429
|
+
return /* @__PURE__ */ React17.createElement(ThemeProvider3, null, /* @__PURE__ */ React17.createElement(
|
|
2430
|
+
Popover3,
|
|
1359
2431
|
{
|
|
1360
2432
|
open: element !== null,
|
|
1361
2433
|
onClose: cancelSave,
|
|
1362
2434
|
anchorReference: "anchorPosition",
|
|
1363
2435
|
anchorPosition
|
|
1364
2436
|
},
|
|
1365
|
-
element !== null && /* @__PURE__ */
|
|
1366
|
-
|
|
2437
|
+
element !== null && /* @__PURE__ */ React17.createElement(
|
|
2438
|
+
Form2,
|
|
1367
2439
|
{
|
|
1368
2440
|
initialValues: { componentName: element.elementLabel },
|
|
1369
2441
|
handleSave,
|
|
1370
2442
|
closePopup: cancelSave
|
|
1371
2443
|
}
|
|
1372
2444
|
)
|
|
1373
|
-
), /* @__PURE__ */
|
|
1374
|
-
|
|
2445
|
+
), /* @__PURE__ */ React17.createElement(Snackbar, { open: resultNotification?.show, onClose: () => setResultNotification(null) }, /* @__PURE__ */ React17.createElement(
|
|
2446
|
+
Alert2,
|
|
1375
2447
|
{
|
|
1376
2448
|
onClose: () => setResultNotification(null),
|
|
1377
2449
|
severity: resultNotification?.type,
|
|
@@ -1381,21 +2453,21 @@ function CreateComponentForm() {
|
|
|
1381
2453
|
)));
|
|
1382
2454
|
}
|
|
1383
2455
|
var FONT_SIZE = "tiny";
|
|
1384
|
-
var
|
|
2456
|
+
var Form2 = ({
|
|
1385
2457
|
initialValues,
|
|
1386
2458
|
handleSave,
|
|
1387
2459
|
closePopup
|
|
1388
2460
|
}) => {
|
|
1389
2461
|
const { values, errors, isValid, handleChange, validateForm: validateForm2 } = useForm(initialValues);
|
|
1390
2462
|
const { components } = useComponents();
|
|
1391
|
-
const existingComponentNames =
|
|
2463
|
+
const existingComponentNames = useMemo3(() => {
|
|
1392
2464
|
return components?.map((component) => component.name) ?? [];
|
|
1393
2465
|
}, [components]);
|
|
1394
|
-
const changeValidationSchema =
|
|
2466
|
+
const changeValidationSchema = useMemo3(
|
|
1395
2467
|
() => createBaseComponentSchema(existingComponentNames),
|
|
1396
2468
|
[existingComponentNames]
|
|
1397
2469
|
);
|
|
1398
|
-
const submitValidationSchema =
|
|
2470
|
+
const submitValidationSchema = useMemo3(
|
|
1399
2471
|
() => createSubmitComponentSchema(existingComponentNames),
|
|
1400
2472
|
[existingComponentNames]
|
|
1401
2473
|
);
|
|
@@ -1406,14 +2478,14 @@ var Form = ({
|
|
|
1406
2478
|
}
|
|
1407
2479
|
};
|
|
1408
2480
|
const texts = {
|
|
1409
|
-
heading:
|
|
1410
|
-
name:
|
|
1411
|
-
cancel:
|
|
1412
|
-
create:
|
|
2481
|
+
heading: __17("Save as a component", "elementor"),
|
|
2482
|
+
name: __17("Name", "elementor"),
|
|
2483
|
+
cancel: __17("Cancel", "elementor"),
|
|
2484
|
+
create: __17("Create", "elementor")
|
|
1413
2485
|
};
|
|
1414
2486
|
const nameInputId = "component-name";
|
|
1415
|
-
return /* @__PURE__ */
|
|
1416
|
-
|
|
2487
|
+
return /* @__PURE__ */ React17.createElement(FormElement, { onSubmit: handleSubmit }, /* @__PURE__ */ React17.createElement(Stack11, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React17.createElement(
|
|
2488
|
+
Stack11,
|
|
1417
2489
|
{
|
|
1418
2490
|
direction: "row",
|
|
1419
2491
|
alignItems: "center",
|
|
@@ -1421,10 +2493,10 @@ var Form = ({
|
|
|
1421
2493
|
px: 1.5,
|
|
1422
2494
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
1423
2495
|
},
|
|
1424
|
-
/* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
), /* @__PURE__ */
|
|
1427
|
-
|
|
2496
|
+
/* @__PURE__ */ React17.createElement(StarIcon, { fontSize: FONT_SIZE }),
|
|
2497
|
+
/* @__PURE__ */ React17.createElement(Typography9, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, texts.heading)
|
|
2498
|
+
), /* @__PURE__ */ React17.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React17.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React17.createElement(FormLabel2, { htmlFor: nameInputId, size: "tiny" }, texts.name)), /* @__PURE__ */ React17.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React17.createElement(
|
|
2499
|
+
TextField3,
|
|
1428
2500
|
{
|
|
1429
2501
|
id: nameInputId,
|
|
1430
2502
|
size: FONT_SIZE,
|
|
@@ -1435,11 +2507,11 @@ var Form = ({
|
|
|
1435
2507
|
error: Boolean(errors.componentName),
|
|
1436
2508
|
helperText: errors.componentName
|
|
1437
2509
|
}
|
|
1438
|
-
))), /* @__PURE__ */
|
|
2510
|
+
))), /* @__PURE__ */ React17.createElement(Stack11, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React17.createElement(Button3, { onClick: closePopup, color: "secondary", variant: "text", size: "small" }, texts.cancel), /* @__PURE__ */ React17.createElement(Button3, { type: "submit", disabled: !isValid, variant: "contained", color: "primary", size: "small" }, texts.create))));
|
|
1439
2511
|
};
|
|
1440
2512
|
|
|
1441
2513
|
// src/components/edit-component/edit-component.tsx
|
|
1442
|
-
import * as
|
|
2514
|
+
import * as React19 from "react";
|
|
1443
2515
|
import { useEffect as useEffect5 } from "react";
|
|
1444
2516
|
import { getV1DocumentsManager as getV1DocumentsManager4 } from "@elementor/editor-documents";
|
|
1445
2517
|
import { __privateListenTo as listenTo, commandEndEvent as commandEndEvent2 } from "@elementor/editor-v1-adapters";
|
|
@@ -1447,25 +2519,25 @@ import { __useSelector as useSelector5 } from "@elementor/store";
|
|
|
1447
2519
|
import { throttle as throttle2 } from "@elementor/utils";
|
|
1448
2520
|
|
|
1449
2521
|
// src/store/actions/update-current-component.ts
|
|
1450
|
-
import { setDocumentModifiedStatus as
|
|
2522
|
+
import { setDocumentModifiedStatus as setDocumentModifiedStatus5 } from "@elementor/editor-documents";
|
|
1451
2523
|
import { __getStore as getStore2 } from "@elementor/store";
|
|
1452
2524
|
function updateCurrentComponent({
|
|
1453
2525
|
path,
|
|
1454
2526
|
currentComponentId
|
|
1455
2527
|
}) {
|
|
1456
|
-
const
|
|
1457
|
-
if (!
|
|
2528
|
+
const dispatch16 = getStore2()?.dispatch;
|
|
2529
|
+
if (!dispatch16) {
|
|
1458
2530
|
return;
|
|
1459
2531
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
2532
|
+
dispatch16(slice.actions.setPath(path));
|
|
2533
|
+
dispatch16(slice.actions.setCurrentComponentId(currentComponentId));
|
|
1462
2534
|
}
|
|
1463
2535
|
|
|
1464
2536
|
// src/components/edit-component/component-modal.tsx
|
|
1465
|
-
import * as
|
|
2537
|
+
import * as React18 from "react";
|
|
1466
2538
|
import { useEffect as useEffect4 } from "react";
|
|
1467
2539
|
import { createPortal } from "react-dom";
|
|
1468
|
-
import { __ as
|
|
2540
|
+
import { __ as __18 } from "@wordpress/i18n";
|
|
1469
2541
|
|
|
1470
2542
|
// src/hooks/use-canvas-document.ts
|
|
1471
2543
|
import { getCanvasIframeDocument } from "@elementor/editor-canvas";
|
|
@@ -1475,10 +2547,10 @@ function useCanvasDocument() {
|
|
|
1475
2547
|
}
|
|
1476
2548
|
|
|
1477
2549
|
// src/hooks/use-element-rect.ts
|
|
1478
|
-
import { useEffect as useEffect3, useState as
|
|
2550
|
+
import { useEffect as useEffect3, useState as useState7 } from "react";
|
|
1479
2551
|
import { throttle } from "@elementor/utils";
|
|
1480
2552
|
function useElementRect(element) {
|
|
1481
|
-
const [rect, setRect] =
|
|
2553
|
+
const [rect, setRect] = useState7(new DOMRect(0, 0, 0, 0));
|
|
1482
2554
|
const onChange = throttle(
|
|
1483
2555
|
() => {
|
|
1484
2556
|
setRect(element?.getBoundingClientRect() ?? new DOMRect(0, 0, 0, 0));
|
|
@@ -1555,7 +2627,7 @@ function ComponentModal({ element, onClose }) {
|
|
|
1555
2627
|
return null;
|
|
1556
2628
|
}
|
|
1557
2629
|
return createPortal(
|
|
1558
|
-
/* @__PURE__ */
|
|
2630
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(BlockEditPage, null), /* @__PURE__ */ React18.createElement(Backdrop, { canvas: canvasDocument, element, onClose })),
|
|
1559
2631
|
canvasDocument.body
|
|
1560
2632
|
);
|
|
1561
2633
|
}
|
|
@@ -1579,7 +2651,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
1579
2651
|
onClose();
|
|
1580
2652
|
}
|
|
1581
2653
|
};
|
|
1582
|
-
return /* @__PURE__ */
|
|
2654
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1583
2655
|
"div",
|
|
1584
2656
|
{
|
|
1585
2657
|
style: backdropStyle,
|
|
@@ -1587,7 +2659,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
1587
2659
|
onKeyDown: handleKeyDown,
|
|
1588
2660
|
role: "button",
|
|
1589
2661
|
tabIndex: 0,
|
|
1590
|
-
"aria-label":
|
|
2662
|
+
"aria-label": __18("Exit component editing mode", "elementor")
|
|
1591
2663
|
}
|
|
1592
2664
|
);
|
|
1593
2665
|
}
|
|
@@ -1637,7 +2709,7 @@ function BlockEditPage() {
|
|
|
1637
2709
|
}
|
|
1638
2710
|
}
|
|
1639
2711
|
`;
|
|
1640
|
-
return /* @__PURE__ */
|
|
2712
|
+
return /* @__PURE__ */ React18.createElement("style", { "data-e-style-id": "e-block-v3-document-handles-styles" }, blockV3DocumentHandlesStyles);
|
|
1641
2713
|
}
|
|
1642
2714
|
|
|
1643
2715
|
// src/components/edit-component/edit-component.tsx
|
|
@@ -1650,7 +2722,7 @@ function EditComponent() {
|
|
|
1650
2722
|
if (!elementDom) {
|
|
1651
2723
|
return null;
|
|
1652
2724
|
}
|
|
1653
|
-
return /* @__PURE__ */
|
|
2725
|
+
return /* @__PURE__ */ React19.createElement(ComponentModal, { element: elementDom, onClose });
|
|
1654
2726
|
}
|
|
1655
2727
|
function useHandleDocumentSwitches() {
|
|
1656
2728
|
const documentsManager = getV1DocumentsManager4();
|
|
@@ -1690,12 +2762,12 @@ function getUpdatedComponentPath(path, nextDocument) {
|
|
|
1690
2762
|
}
|
|
1691
2763
|
];
|
|
1692
2764
|
}
|
|
1693
|
-
function getComponentDOMElement(
|
|
1694
|
-
if (!
|
|
2765
|
+
function getComponentDOMElement(id2) {
|
|
2766
|
+
if (!id2) {
|
|
1695
2767
|
return null;
|
|
1696
2768
|
}
|
|
1697
2769
|
const documentsManager = getV1DocumentsManager4();
|
|
1698
|
-
const currentComponent = documentsManager.get(
|
|
2770
|
+
const currentComponent = documentsManager.get(id2);
|
|
1699
2771
|
const widget = currentComponent?.container;
|
|
1700
2772
|
const container = widget?.view?.el?.children?.[0] ?? null;
|
|
1701
2773
|
const elementDom = container?.children[0];
|
|
@@ -1703,33 +2775,33 @@ function getComponentDOMElement(id) {
|
|
|
1703
2775
|
}
|
|
1704
2776
|
|
|
1705
2777
|
// src/components/in-edit-mode.tsx
|
|
1706
|
-
import * as
|
|
2778
|
+
import * as React20 from "react";
|
|
1707
2779
|
import { closeDialog, openDialog } from "@elementor/editor-ui";
|
|
1708
2780
|
import { InfoCircleFilledIcon } from "@elementor/icons";
|
|
1709
|
-
import { Box as
|
|
1710
|
-
import { __ as
|
|
2781
|
+
import { Box as Box12, Button as Button4, DialogActions, DialogContent, DialogHeader, Icon as Icon2, Stack as Stack12, Typography as Typography10 } from "@elementor/ui";
|
|
2782
|
+
import { __ as __19 } from "@wordpress/i18n";
|
|
1711
2783
|
var openEditModeDialog = (lockedBy) => {
|
|
1712
2784
|
openDialog({
|
|
1713
|
-
component: /* @__PURE__ */
|
|
2785
|
+
component: /* @__PURE__ */ React20.createElement(EditModeDialog, { lockedBy })
|
|
1714
2786
|
});
|
|
1715
2787
|
};
|
|
1716
2788
|
var EditModeDialog = ({ lockedBy }) => {
|
|
1717
|
-
const content =
|
|
1718
|
-
return /* @__PURE__ */
|
|
2789
|
+
const content = __19("%s is currently editing this document", "elementor").replace("%s", lockedBy);
|
|
2790
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(DialogHeader, { logo: false }, /* @__PURE__ */ React20.createElement(Box12, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React20.createElement(Icon2, { color: "secondary" }, /* @__PURE__ */ React20.createElement(InfoCircleFilledIcon, { fontSize: "medium" })), /* @__PURE__ */ React20.createElement(Typography10, { variant: "subtitle1" }, content))), /* @__PURE__ */ React20.createElement(DialogContent, null, /* @__PURE__ */ React20.createElement(Stack12, { spacing: 2, direction: "column" }, /* @__PURE__ */ React20.createElement(Typography10, { variant: "body2" }, __19(
|
|
1719
2791
|
"You can wait for them to finish or reach out to coordinate your changes together.",
|
|
1720
2792
|
"elementor"
|
|
1721
|
-
)), /* @__PURE__ */
|
|
2793
|
+
)), /* @__PURE__ */ React20.createElement(DialogActions, null, /* @__PURE__ */ React20.createElement(Button4, { color: "secondary", variant: "contained", onClick: closeDialog }, __19("Close", "elementor"))))));
|
|
1722
2794
|
};
|
|
1723
2795
|
|
|
1724
2796
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
1725
|
-
import * as
|
|
2797
|
+
import * as React23 from "react";
|
|
1726
2798
|
import { useElement } from "@elementor/editor-editing-panel";
|
|
1727
|
-
import { useElementSetting, useSelectedElement } from "@elementor/editor-elements";
|
|
1728
|
-
import { PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
|
|
2799
|
+
import { useElementSetting, useSelectedElement as useSelectedElement2 } from "@elementor/editor-elements";
|
|
2800
|
+
import { PanelBody as PanelBody2, PanelHeader as PanelHeader2, PanelHeaderTitle as PanelHeaderTitle2 } from "@elementor/editor-panels";
|
|
1729
2801
|
import { ComponentsIcon as ComponentsIcon3, PencilIcon as PencilIcon2 } from "@elementor/icons";
|
|
1730
|
-
import { __getState as
|
|
1731
|
-
import { IconButton as
|
|
1732
|
-
import { __ as
|
|
2802
|
+
import { __getState as getState12 } from "@elementor/store";
|
|
2803
|
+
import { IconButton as IconButton6, Stack as Stack15, Tooltip as Tooltip4 } from "@elementor/ui";
|
|
2804
|
+
import { __ as __21 } from "@wordpress/i18n";
|
|
1733
2805
|
|
|
1734
2806
|
// src/prop-types/component-instance-prop-type.ts
|
|
1735
2807
|
import { createPropUtils as createPropUtils3, numberPropTypeUtil } from "@elementor/editor-props";
|
|
@@ -1770,13 +2842,13 @@ var componentInstancePropTypeUtil = createPropUtils3(
|
|
|
1770
2842
|
);
|
|
1771
2843
|
|
|
1772
2844
|
// src/components/instance-editing-panel/empty-state.tsx
|
|
1773
|
-
import * as
|
|
1774
|
-
import { ComponentPropListIcon as
|
|
1775
|
-
import { Button as
|
|
1776
|
-
import { __ as
|
|
2845
|
+
import * as React21 from "react";
|
|
2846
|
+
import { ComponentPropListIcon as ComponentPropListIcon4, PencilIcon } from "@elementor/icons";
|
|
2847
|
+
import { Button as Button5, Stack as Stack13, Typography as Typography11 } from "@elementor/ui";
|
|
2848
|
+
import { __ as __20 } from "@wordpress/i18n";
|
|
1777
2849
|
var EmptyState2 = ({ onEditComponent }) => {
|
|
1778
|
-
return /* @__PURE__ */
|
|
1779
|
-
|
|
2850
|
+
return /* @__PURE__ */ React21.createElement(
|
|
2851
|
+
Stack13,
|
|
1780
2852
|
{
|
|
1781
2853
|
alignItems: "center",
|
|
1782
2854
|
justifyContent: "start",
|
|
@@ -1785,32 +2857,32 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
1785
2857
|
sx: { p: 2.5, pt: 8, pb: 5.5, mt: 1 },
|
|
1786
2858
|
gap: 1.5
|
|
1787
2859
|
},
|
|
1788
|
-
/* @__PURE__ */
|
|
1789
|
-
/* @__PURE__ */
|
|
1790
|
-
/* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ React21.createElement(ComponentPropListIcon4, { fontSize: "large" }),
|
|
2861
|
+
/* @__PURE__ */ React21.createElement(Typography11, { align: "center", variant: "subtitle2" }, __20("No properties yet", "elementor")),
|
|
2862
|
+
/* @__PURE__ */ React21.createElement(Typography11, { align: "center", variant: "caption", maxWidth: "170px" }, __20(
|
|
1791
2863
|
"Edit the component to add properties, manage them or update the design across all instances.",
|
|
1792
2864
|
"elementor"
|
|
1793
2865
|
)),
|
|
1794
|
-
/* @__PURE__ */
|
|
2866
|
+
/* @__PURE__ */ React21.createElement(Button5, { variant: "outlined", color: "secondary", size: "small", sx: { mt: 1 }, onClick: onEditComponent }, /* @__PURE__ */ React21.createElement(PencilIcon, { fontSize: "small" }), __20("Edit component", "elementor"))
|
|
1795
2867
|
);
|
|
1796
2868
|
};
|
|
1797
2869
|
|
|
1798
2870
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
1799
|
-
import * as
|
|
2871
|
+
import * as React22 from "react";
|
|
1800
2872
|
import { useId } from "react";
|
|
1801
2873
|
import { useStateByElement } from "@elementor/editor-editing-panel";
|
|
1802
2874
|
import { CollapseIcon } from "@elementor/editor-ui";
|
|
1803
|
-
import { Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as
|
|
2875
|
+
import { Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as Stack14 } from "@elementor/ui";
|
|
1804
2876
|
function OverridePropsGroup({ group, props }) {
|
|
1805
2877
|
const [isOpen, setIsOpen] = useStateByElement(group.id, true);
|
|
1806
2878
|
const handleClick = () => {
|
|
1807
2879
|
setIsOpen(!isOpen);
|
|
1808
2880
|
};
|
|
1809
|
-
const
|
|
1810
|
-
const labelId = `label-${
|
|
1811
|
-
const contentId = `content-${
|
|
2881
|
+
const id2 = useId();
|
|
2882
|
+
const labelId = `label-${id2}`;
|
|
2883
|
+
const contentId = `content-${id2}`;
|
|
1812
2884
|
const title = group.label;
|
|
1813
|
-
return /* @__PURE__ */
|
|
2885
|
+
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement(
|
|
1814
2886
|
ListItemButton3,
|
|
1815
2887
|
{
|
|
1816
2888
|
id: labelId,
|
|
@@ -1820,7 +2892,7 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1820
2892
|
p: 0,
|
|
1821
2893
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
1822
2894
|
},
|
|
1823
|
-
/* @__PURE__ */
|
|
2895
|
+
/* @__PURE__ */ React22.createElement(Stack14, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React22.createElement(
|
|
1824
2896
|
ListItemText,
|
|
1825
2897
|
{
|
|
1826
2898
|
secondary: title,
|
|
@@ -1828,10 +2900,10 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1828
2900
|
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
1829
2901
|
}
|
|
1830
2902
|
)),
|
|
1831
|
-
/* @__PURE__ */
|
|
1832
|
-
), /* @__PURE__ */
|
|
2903
|
+
/* @__PURE__ */ React22.createElement(CollapseIcon, { open: isOpen, color: "secondary", fontSize: "tiny" })
|
|
2904
|
+
), /* @__PURE__ */ React22.createElement(Collapse, { id: contentId, "aria-labelledby": labelId, in: isOpen, timeout: "auto" }, /* @__PURE__ */ React22.createElement(Stack14, { direction: "column", gap: 1, p: 2 }, group.props.map((propId) => (
|
|
1833
2905
|
// TODO: Render actual controls
|
|
1834
|
-
/* @__PURE__ */
|
|
2906
|
+
/* @__PURE__ */ React22.createElement("pre", { key: propId }, JSON.stringify(props[propId], null, 2))
|
|
1835
2907
|
)))));
|
|
1836
2908
|
}
|
|
1837
2909
|
|
|
@@ -1839,24 +2911,24 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1839
2911
|
function InstanceEditingPanel() {
|
|
1840
2912
|
const { element } = useElement();
|
|
1841
2913
|
const settings = useElementSetting(element.id, "component_instance");
|
|
1842
|
-
const componentId =
|
|
1843
|
-
const component = componentId ? selectComponent(
|
|
1844
|
-
const overridableProps = componentId ? selectOverridableProps(
|
|
1845
|
-
const componentInstanceId =
|
|
2914
|
+
const componentId = componentInstancePropTypeUtil.extract(settings)?.component_id?.value;
|
|
2915
|
+
const component = componentId ? selectComponent(getState12(), componentId) : null;
|
|
2916
|
+
const overridableProps = componentId ? selectOverridableProps(getState12(), componentId) : null;
|
|
2917
|
+
const componentInstanceId = useSelectedElement2()?.element?.id ?? null;
|
|
1846
2918
|
if (!componentId || !overridableProps || !component) {
|
|
1847
2919
|
return null;
|
|
1848
2920
|
}
|
|
1849
|
-
const panelTitle =
|
|
2921
|
+
const panelTitle = __21("Edit %s", "elementor").replace("%s", component.name);
|
|
1850
2922
|
const handleEditComponent = () => switchToComponent(componentId, componentInstanceId);
|
|
1851
2923
|
const groups = overridableProps.groups.order.map(
|
|
1852
2924
|
(groupId) => overridableProps.groups.items[groupId] ? overridableProps.groups.items[groupId] : null
|
|
1853
2925
|
).filter(Boolean);
|
|
1854
2926
|
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
1855
|
-
return /* @__PURE__ */
|
|
2927
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(PanelHeader2, { sx: { justifyContent: "start", px: 2 } }, /* @__PURE__ */ React23.createElement(Stack15, { direction: "row", alignContent: "space-between", flexGrow: 1 }, /* @__PURE__ */ React23.createElement(Stack15, { direction: "row", alignItems: "center", justifyContent: "start", gap: 1, flexGrow: 1 }, /* @__PURE__ */ React23.createElement(ComponentsIcon3, { fontSize: "small", sx: { color: "text.tertiary" } }), /* @__PURE__ */ React23.createElement(PanelHeaderTitle2, null, component.name)), /* @__PURE__ */ React23.createElement(Tooltip4, { title: panelTitle }, /* @__PURE__ */ React23.createElement(IconButton6, { size: "tiny", onClick: handleEditComponent, "aria-label": panelTitle }, /* @__PURE__ */ React23.createElement(PencilIcon2, { fontSize: "tiny" }))))), /* @__PURE__ */ React23.createElement(PanelBody2, null, isEmpty ? /* @__PURE__ */ React23.createElement(EmptyState2, { onEditComponent: handleEditComponent }) : /* @__PURE__ */ React23.createElement(Stack15, { direction: "column", alignItems: "stretch" }, groups.map((group) => /* @__PURE__ */ React23.createElement(OverridePropsGroup, { key: group.id, group, props: overridableProps.props })))));
|
|
1856
2928
|
}
|
|
1857
2929
|
|
|
1858
2930
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
1859
|
-
import * as
|
|
2931
|
+
import * as React25 from "react";
|
|
1860
2932
|
import { ControlReplacementsProvider, PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
1861
2933
|
import { createTopLevelObjectType, useElement as useElement2 } from "@elementor/editor-editing-panel";
|
|
1862
2934
|
|
|
@@ -1875,18 +2947,18 @@ var componentOverridablePropTypeUtil = createPropUtils4(
|
|
|
1875
2947
|
);
|
|
1876
2948
|
|
|
1877
2949
|
// src/provider/overridable-prop-context.tsx
|
|
1878
|
-
import * as
|
|
2950
|
+
import * as React24 from "react";
|
|
1879
2951
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1880
2952
|
var OverridablePropContext = createContext2(null);
|
|
1881
2953
|
function OverridablePropProvider({ children, ...props }) {
|
|
1882
|
-
return /* @__PURE__ */
|
|
2954
|
+
return /* @__PURE__ */ React24.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
1883
2955
|
}
|
|
1884
2956
|
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
1885
2957
|
|
|
1886
2958
|
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
1887
|
-
import { __dispatch as
|
|
2959
|
+
import { __dispatch as dispatch11, __getState as getState13 } from "@elementor/store";
|
|
1888
2960
|
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
1889
|
-
const overridableProps = selectOverridableProps(
|
|
2961
|
+
const overridableProps = selectOverridableProps(getState13(), componentId);
|
|
1890
2962
|
if (!overridableProps) {
|
|
1891
2963
|
return;
|
|
1892
2964
|
}
|
|
@@ -1904,7 +2976,7 @@ function updateOverridablePropOriginValue(componentId, propValue) {
|
|
|
1904
2976
|
}
|
|
1905
2977
|
}
|
|
1906
2978
|
};
|
|
1907
|
-
|
|
2979
|
+
dispatch11(
|
|
1908
2980
|
slice.actions.setOverridableProps({
|
|
1909
2981
|
componentId,
|
|
1910
2982
|
overridableProps: newOverridableProps
|
|
@@ -1940,7 +3012,7 @@ function OverridablePropControl({
|
|
|
1940
3012
|
}
|
|
1941
3013
|
});
|
|
1942
3014
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
1943
|
-
return /* @__PURE__ */
|
|
3015
|
+
return /* @__PURE__ */ React25.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React25.createElement(
|
|
1944
3016
|
PropProvider,
|
|
1945
3017
|
{
|
|
1946
3018
|
...propContext,
|
|
@@ -1949,23 +3021,22 @@ function OverridablePropControl({
|
|
|
1949
3021
|
value: { [bind]: value.origin_value },
|
|
1950
3022
|
placeholder: objectPlaceholder
|
|
1951
3023
|
},
|
|
1952
|
-
/* @__PURE__ */
|
|
3024
|
+
/* @__PURE__ */ React25.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React25.createElement(ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React25.createElement(OriginalControl, { ...props })))
|
|
1953
3025
|
));
|
|
1954
3026
|
}
|
|
1955
3027
|
|
|
1956
3028
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
1957
|
-
import * as
|
|
3029
|
+
import * as React27 from "react";
|
|
1958
3030
|
import { useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
1959
3031
|
import { useElement as useElement3 } from "@elementor/editor-editing-panel";
|
|
1960
|
-
import { getWidgetsCache } from "@elementor/editor-elements";
|
|
1961
|
-
import { __getState as
|
|
1962
|
-
import { bindPopover, bindTrigger as
|
|
1963
|
-
import { __ as
|
|
3032
|
+
import { getWidgetsCache as getWidgetsCache2 } from "@elementor/editor-elements";
|
|
3033
|
+
import { __getState as getState16 } from "@elementor/store";
|
|
3034
|
+
import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Popover4, Tooltip as Tooltip5, usePopupState as usePopupState4 } from "@elementor/ui";
|
|
3035
|
+
import { __ as __23 } from "@wordpress/i18n";
|
|
1964
3036
|
|
|
1965
3037
|
// src/store/actions/set-overridable-prop.ts
|
|
1966
|
-
import { __dispatch as
|
|
1967
|
-
import { generateUniqueId as
|
|
1968
|
-
import { __ as __13 } from "@wordpress/i18n";
|
|
3038
|
+
import { __dispatch as dispatch12, __getState as getState14 } from "@elementor/store";
|
|
3039
|
+
import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
|
|
1969
3040
|
function setOverridableProp({
|
|
1970
3041
|
componentId,
|
|
1971
3042
|
overrideKey,
|
|
@@ -1977,7 +3048,7 @@ function setOverridableProp({
|
|
|
1977
3048
|
widgetType,
|
|
1978
3049
|
originValue
|
|
1979
3050
|
}) {
|
|
1980
|
-
const overridableProps = selectOverridableProps(
|
|
3051
|
+
const overridableProps = selectOverridableProps(getState14(), componentId);
|
|
1981
3052
|
if (!overridableProps) {
|
|
1982
3053
|
return;
|
|
1983
3054
|
}
|
|
@@ -1985,13 +3056,12 @@ function setOverridableProp({
|
|
|
1985
3056
|
const duplicatedTargetProps = Object.values(overridableProps.props).filter(
|
|
1986
3057
|
(prop) => prop.elementId === elementId && prop.propKey === propKey && prop !== existingOverridableProp
|
|
1987
3058
|
);
|
|
1988
|
-
const {
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
groupId || existingOverridableProp?.groupId
|
|
3059
|
+
const { groups: groupsAfterResolve, groupId: currentGroupId } = resolveOrCreateGroup(
|
|
3060
|
+
overridableProps.groups,
|
|
3061
|
+
groupId || existingOverridableProp?.groupId || void 0
|
|
1992
3062
|
);
|
|
1993
3063
|
const overridableProp = {
|
|
1994
|
-
overrideKey: existingOverridableProp?.overrideKey ||
|
|
3064
|
+
overrideKey: existingOverridableProp?.overrideKey || generateUniqueId4("prop"),
|
|
1995
3065
|
label,
|
|
1996
3066
|
elementId,
|
|
1997
3067
|
propKey,
|
|
@@ -2000,31 +3070,21 @@ function setOverridableProp({
|
|
|
2000
3070
|
originValue,
|
|
2001
3071
|
groupId: currentGroupId
|
|
2002
3072
|
};
|
|
2003
|
-
const
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
});
|
|
3073
|
+
const stateAfterRemovingDuplicates = removePropsFromState(
|
|
3074
|
+
{ ...overridableProps, groups: groupsAfterResolve },
|
|
3075
|
+
duplicatedTargetProps
|
|
3076
|
+
);
|
|
2008
3077
|
const props = {
|
|
2009
|
-
...
|
|
3078
|
+
...stateAfterRemovingDuplicates.props,
|
|
2010
3079
|
[overridableProp.overrideKey]: overridableProp
|
|
2011
3080
|
};
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
...groupsWithoutDuplicates.items,
|
|
2015
|
-
[currentGroupId]: getGroupWithProp(groupsWithoutDuplicates, currentGroupId, overridableProp)
|
|
2016
|
-
},
|
|
2017
|
-
order: groupsWithoutDuplicates.order.includes(currentGroupId) ? groupsWithoutDuplicates.order : [...groupsWithoutDuplicates.order, currentGroupId]
|
|
2018
|
-
};
|
|
3081
|
+
let groups = addPropToGroup(stateAfterRemovingDuplicates.groups, currentGroupId, overridableProp.overrideKey);
|
|
3082
|
+
groups = ensureGroupInOrder(groups, currentGroupId);
|
|
2019
3083
|
const isChangingGroups = existingOverridableProp && existingOverridableProp.groupId !== currentGroupId;
|
|
2020
3084
|
if (isChangingGroups) {
|
|
2021
|
-
groups
|
|
2022
|
-
groupsWithoutDuplicates,
|
|
2023
|
-
existingOverridableProp.groupId,
|
|
2024
|
-
overridableProp
|
|
2025
|
-
);
|
|
3085
|
+
groups = removePropFromGroup(groups, existingOverridableProp.groupId, overridableProp.overrideKey);
|
|
2026
3086
|
}
|
|
2027
|
-
|
|
3087
|
+
dispatch12(
|
|
2028
3088
|
slice.actions.setOverridableProps({
|
|
2029
3089
|
componentId,
|
|
2030
3090
|
overridableProps: {
|
|
@@ -2035,83 +3095,15 @@ function setOverridableProp({
|
|
|
2035
3095
|
);
|
|
2036
3096
|
return overridableProp;
|
|
2037
3097
|
}
|
|
2038
|
-
function getUpdatedGroups(groups, groupId) {
|
|
2039
|
-
if (!groupId) {
|
|
2040
|
-
if (groups.order.length > 0) {
|
|
2041
|
-
return { groups, currentGroupId: groups.order[0] };
|
|
2042
|
-
}
|
|
2043
|
-
return addNewGroup(groups);
|
|
2044
|
-
}
|
|
2045
|
-
if (!groups.items[groupId]) {
|
|
2046
|
-
return addNewGroup(groups, groupId);
|
|
2047
|
-
}
|
|
2048
|
-
return { groups, currentGroupId: groupId };
|
|
2049
|
-
}
|
|
2050
|
-
function addNewGroup(groups, groupId) {
|
|
2051
|
-
const currentGroupId = groupId || generateUniqueId2("group");
|
|
2052
|
-
const updatedGroups = {
|
|
2053
|
-
...groups,
|
|
2054
|
-
items: {
|
|
2055
|
-
...groups.items,
|
|
2056
|
-
[currentGroupId]: {
|
|
2057
|
-
id: currentGroupId,
|
|
2058
|
-
label: __13("Default", "elementor"),
|
|
2059
|
-
props: []
|
|
2060
|
-
}
|
|
2061
|
-
},
|
|
2062
|
-
order: [...groups.order, currentGroupId]
|
|
2063
|
-
};
|
|
2064
|
-
return { groups: updatedGroups, currentGroupId };
|
|
2065
|
-
}
|
|
2066
|
-
function getGroupWithProp(groups, groupId, overridableProp) {
|
|
2067
|
-
const group = { ...groups.items[groupId] };
|
|
2068
|
-
if (!group.props.includes(overridableProp.overrideKey)) {
|
|
2069
|
-
group.props = [...group.props, overridableProp.overrideKey];
|
|
2070
|
-
}
|
|
2071
|
-
return group;
|
|
2072
|
-
}
|
|
2073
|
-
function getGroupWithoutProp(groups, groupId, overridableProp) {
|
|
2074
|
-
const group = { ...groups.items[groupId] };
|
|
2075
|
-
if (group) {
|
|
2076
|
-
group.props = group.props.filter((key) => key !== overridableProp.overrideKey);
|
|
2077
|
-
}
|
|
2078
|
-
return group;
|
|
2079
|
-
}
|
|
2080
|
-
function removeProps({
|
|
2081
|
-
props,
|
|
2082
|
-
groups,
|
|
2083
|
-
propsToRemove
|
|
2084
|
-
}) {
|
|
2085
|
-
const allProps = Object.fromEntries(
|
|
2086
|
-
Object.entries(props).filter(([, prop]) => !propsToRemove.includes(prop))
|
|
2087
|
-
);
|
|
2088
|
-
const overrideKeysToRemove = propsToRemove.map((prop) => prop.overrideKey);
|
|
2089
|
-
const allGroupItems = Object.fromEntries(
|
|
2090
|
-
Object.entries(groups.items).map(([groupId, group]) => [
|
|
2091
|
-
groupId,
|
|
2092
|
-
{
|
|
2093
|
-
...group,
|
|
2094
|
-
props: group.props.filter((prop) => !overrideKeysToRemove.includes(prop))
|
|
2095
|
-
}
|
|
2096
|
-
])
|
|
2097
|
-
);
|
|
2098
|
-
return {
|
|
2099
|
-
props: allProps,
|
|
2100
|
-
groups: {
|
|
2101
|
-
items: allGroupItems,
|
|
2102
|
-
order: groups.order.filter((groupId) => !overrideKeysToRemove.includes(groupId))
|
|
2103
|
-
}
|
|
2104
|
-
};
|
|
2105
|
-
}
|
|
2106
3098
|
|
|
2107
3099
|
// src/components/overridable-props/indicator.tsx
|
|
2108
|
-
import * as
|
|
2109
|
-
import { forwardRef } from "react";
|
|
3100
|
+
import * as React26 from "react";
|
|
3101
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
2110
3102
|
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
2111
|
-
import { Box as
|
|
2112
|
-
import { __ as
|
|
2113
|
-
var
|
|
2114
|
-
var IconContainer =
|
|
3103
|
+
import { Box as Box13, styled as styled3 } from "@elementor/ui";
|
|
3104
|
+
import { __ as __22 } from "@wordpress/i18n";
|
|
3105
|
+
var SIZE2 = "tiny";
|
|
3106
|
+
var IconContainer = styled3(Box13)`
|
|
2115
3107
|
pointer-events: none;
|
|
2116
3108
|
opacity: 0;
|
|
2117
3109
|
transition: opacity 0.2s ease-in-out;
|
|
@@ -2128,7 +3120,7 @@ var IconContainer = styled2(Box8)`
|
|
|
2128
3120
|
stroke-width: 2px;
|
|
2129
3121
|
}
|
|
2130
3122
|
`;
|
|
2131
|
-
var Content =
|
|
3123
|
+
var Content = styled3(Box13)`
|
|
2132
3124
|
position: relative;
|
|
2133
3125
|
display: flex;
|
|
2134
3126
|
align-items: center;
|
|
@@ -2165,79 +3157,22 @@ var Content = styled2(Box8)`
|
|
|
2165
3157
|
}
|
|
2166
3158
|
}
|
|
2167
3159
|
`;
|
|
2168
|
-
var Indicator =
|
|
3160
|
+
var Indicator = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React26.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React26.createElement(
|
|
2169
3161
|
IconContainer,
|
|
2170
3162
|
{
|
|
2171
3163
|
className: "icon",
|
|
2172
|
-
"aria-label": isOverridable ?
|
|
3164
|
+
"aria-label": isOverridable ? __22("Overridable property", "elementor") : __22("Make prop overridable", "elementor")
|
|
2173
3165
|
},
|
|
2174
|
-
isOverridable ? /* @__PURE__ */
|
|
3166
|
+
isOverridable ? /* @__PURE__ */ React26.createElement(CheckIcon, { fontSize: SIZE2 }) : /* @__PURE__ */ React26.createElement(PlusIcon, { fontSize: SIZE2 })
|
|
2175
3167
|
)));
|
|
2176
3168
|
|
|
2177
|
-
// src/components/overridable-props/overridable-prop-form.tsx
|
|
2178
|
-
import * as React19 from "react";
|
|
2179
|
-
import { useState as useState4 } from "react";
|
|
2180
|
-
import { Form as Form2, MenuListItem as MenuListItem2 } from "@elementor/editor-ui";
|
|
2181
|
-
import { Button as Button4, FormLabel as FormLabel2, Grid as Grid2, Select, Stack as Stack11, TextField as TextField3, Typography as Typography7 } from "@elementor/ui";
|
|
2182
|
-
import { __ as __15 } from "@wordpress/i18n";
|
|
2183
|
-
var SIZE2 = "tiny";
|
|
2184
|
-
var DEFAULT_GROUP = { value: null, label: __15("Default", "elementor") };
|
|
2185
|
-
function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
2186
|
-
const [propLabel, setPropLabel] = useState4(currentValue?.label ?? null);
|
|
2187
|
-
const [group, setGroup] = useState4(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
2188
|
-
const name = __15("Name", "elementor");
|
|
2189
|
-
const groupName = __15("Group Name", "elementor");
|
|
2190
|
-
const isCreate = currentValue === void 0;
|
|
2191
|
-
const title = isCreate ? __15("Create new property", "elementor") : __15("Update property", "elementor");
|
|
2192
|
-
const ctaLabel = isCreate ? __15("Create", "elementor") : __15("Update", "elementor");
|
|
2193
|
-
return /* @__PURE__ */ React19.createElement(Form2, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React19.createElement(Stack11, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React19.createElement(
|
|
2194
|
-
Stack11,
|
|
2195
|
-
{
|
|
2196
|
-
direction: "row",
|
|
2197
|
-
alignItems: "center",
|
|
2198
|
-
py: 1,
|
|
2199
|
-
px: 1.5,
|
|
2200
|
-
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
2201
|
-
},
|
|
2202
|
-
/* @__PURE__ */ React19.createElement(Typography7, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
2203
|
-
), /* @__PURE__ */ React19.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(FormLabel2, { size: "tiny" }, name)), /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(
|
|
2204
|
-
TextField3,
|
|
2205
|
-
{
|
|
2206
|
-
name,
|
|
2207
|
-
size: SIZE2,
|
|
2208
|
-
fullWidth: true,
|
|
2209
|
-
placeholder: __15("Enter value", "elementor"),
|
|
2210
|
-
value: propLabel ?? "",
|
|
2211
|
-
onChange: (e) => setPropLabel(e.target.value)
|
|
2212
|
-
}
|
|
2213
|
-
))), /* @__PURE__ */ React19.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(FormLabel2, { size: "tiny" }, groupName)), /* @__PURE__ */ React19.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React19.createElement(
|
|
2214
|
-
Select,
|
|
2215
|
-
{
|
|
2216
|
-
name: groupName,
|
|
2217
|
-
size: SIZE2,
|
|
2218
|
-
fullWidth: true,
|
|
2219
|
-
value: group ?? null,
|
|
2220
|
-
onChange: setGroup,
|
|
2221
|
-
displayEmpty: true,
|
|
2222
|
-
renderValue: (selectedValue) => {
|
|
2223
|
-
if (!selectedValue || selectedValue === "") {
|
|
2224
|
-
const [firstGroup = DEFAULT_GROUP] = groups ?? [];
|
|
2225
|
-
return firstGroup.label;
|
|
2226
|
-
}
|
|
2227
|
-
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
2228
|
-
}
|
|
2229
|
-
},
|
|
2230
|
-
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React19.createElement(MenuListItem2, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
2231
|
-
))), /* @__PURE__ */ React19.createElement(Stack11, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React19.createElement(Button4, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
2232
|
-
}
|
|
2233
|
-
|
|
2234
3169
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
2235
|
-
import { __getState as
|
|
3170
|
+
import { __getState as getState15 } from "@elementor/store";
|
|
2236
3171
|
function getOverridableProp({
|
|
2237
3172
|
componentId,
|
|
2238
3173
|
overrideKey
|
|
2239
3174
|
}) {
|
|
2240
|
-
const overridableProps = selectOverridableProps(
|
|
3175
|
+
const overridableProps = selectOverridableProps(getState15(), componentId);
|
|
2241
3176
|
if (!overridableProps) {
|
|
2242
3177
|
return void 0;
|
|
2243
3178
|
}
|
|
@@ -2252,8 +3187,8 @@ function OverridablePropIndicator() {
|
|
|
2252
3187
|
if (!isPropAllowed(bind) || !componentId) {
|
|
2253
3188
|
return null;
|
|
2254
3189
|
}
|
|
2255
|
-
const overridableProps = selectOverridableProps(
|
|
2256
|
-
return /* @__PURE__ */
|
|
3190
|
+
const overridableProps = selectOverridableProps(getState16(), componentId);
|
|
3191
|
+
return /* @__PURE__ */ React27.createElement(Content2, { componentId, overridableProps });
|
|
2257
3192
|
}
|
|
2258
3193
|
function Content2({ componentId, overridableProps }) {
|
|
2259
3194
|
const {
|
|
@@ -2266,12 +3201,12 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2266
3201
|
componentOverridablePropTypeUtil
|
|
2267
3202
|
);
|
|
2268
3203
|
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
2269
|
-
const popupState =
|
|
3204
|
+
const popupState = usePopupState4({
|
|
2270
3205
|
variant: "popover"
|
|
2271
3206
|
});
|
|
2272
|
-
const triggerProps =
|
|
2273
|
-
const popoverProps =
|
|
2274
|
-
const { elType } =
|
|
3207
|
+
const triggerProps = bindTrigger4(popupState);
|
|
3208
|
+
const popoverProps = bindPopover2(popupState);
|
|
3209
|
+
const { elType } = getWidgetsCache2()?.[elementType.key] ?? { elType: "widget" };
|
|
2275
3210
|
const handleSubmit = ({ label, group }) => {
|
|
2276
3211
|
const originValue = !overridableValue ? value ?? propType.default : overridableValue?.origin_value ?? {};
|
|
2277
3212
|
const overridablePropConfig = setOverridableProp({
|
|
@@ -2294,8 +3229,8 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2294
3229
|
popupState.close();
|
|
2295
3230
|
};
|
|
2296
3231
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
2297
|
-
return /* @__PURE__ */
|
|
2298
|
-
|
|
3232
|
+
return /* @__PURE__ */ React27.createElement(React27.Fragment, null, /* @__PURE__ */ React27.createElement(Tooltip5, { placement: "top", title: __23("Override Property", "elementor") }, /* @__PURE__ */ React27.createElement(Indicator, { ...triggerProps, isOpen: !!popoverProps.open, isOverridable: !!overridableValue })), /* @__PURE__ */ React27.createElement(
|
|
3233
|
+
Popover4,
|
|
2299
3234
|
{
|
|
2300
3235
|
disableScrollLock: true,
|
|
2301
3236
|
anchorOrigin: {
|
|
@@ -2311,7 +3246,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2311
3246
|
},
|
|
2312
3247
|
...popoverProps
|
|
2313
3248
|
},
|
|
2314
|
-
/* @__PURE__ */
|
|
3249
|
+
/* @__PURE__ */ React27.createElement(
|
|
2315
3250
|
OverridablePropForm,
|
|
2316
3251
|
{
|
|
2317
3252
|
onSubmit: handleSubmit,
|
|
@@ -2333,11 +3268,11 @@ import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
|
|
|
2333
3268
|
|
|
2334
3269
|
// src/mcp/save-as-component-tool.ts
|
|
2335
3270
|
import { DOCUMENT_STRUCTURE_URI, WIDGET_SCHEMA_URI } from "@elementor/editor-canvas";
|
|
2336
|
-
import { getContainer as
|
|
3271
|
+
import { getContainer as getContainer3, getElementType, getWidgetsCache as getWidgetsCache3 } from "@elementor/editor-elements";
|
|
2337
3272
|
import { getMCPByDomain, toolPrompts } from "@elementor/editor-mcp";
|
|
2338
3273
|
import { AxiosError } from "@elementor/http-client";
|
|
2339
3274
|
import { z as z6 } from "@elementor/schema";
|
|
2340
|
-
import { generateUniqueId as
|
|
3275
|
+
import { generateUniqueId as generateUniqueId5 } from "@elementor/utils";
|
|
2341
3276
|
var InputSchema = {
|
|
2342
3277
|
element_id: z6.string().describe(
|
|
2343
3278
|
'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.'
|
|
@@ -2360,7 +3295,7 @@ var OutputSchema = {
|
|
|
2360
3295
|
message: z6.string().optional().describe("Additional information about the operation result"),
|
|
2361
3296
|
component_uid: z6.string().optional().describe("The unique identifier of the newly created component (only present on success)")
|
|
2362
3297
|
};
|
|
2363
|
-
var
|
|
3298
|
+
var ERROR_MESSAGES2 = {
|
|
2364
3299
|
ELEMENT_NOT_FOUND: "Element not found. Use 'list-elements' to get valid element IDs.",
|
|
2365
3300
|
ELEMENT_NOT_ONE_OF_TYPES: (validTypes) => `Element is not one of the following types: ${validTypes.join(", ")}`,
|
|
2366
3301
|
ELEMENT_IS_LOCKED: "Cannot save a locked element as a component."
|
|
@@ -2368,23 +3303,23 @@ var ERROR_MESSAGES = {
|
|
|
2368
3303
|
var handleSaveAsComponent = async (params) => {
|
|
2369
3304
|
const { element_id: elementId, component_name: componentName, overridable_props: overridablePropsInput } = params;
|
|
2370
3305
|
const validElementTypes = getValidElementTypes();
|
|
2371
|
-
const container =
|
|
3306
|
+
const container = getContainer3(elementId);
|
|
2372
3307
|
if (!container) {
|
|
2373
|
-
throw new Error(
|
|
3308
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_NOT_FOUND);
|
|
2374
3309
|
}
|
|
2375
3310
|
const elType = container.model.get("elType");
|
|
2376
3311
|
if (!validElementTypes.includes(elType)) {
|
|
2377
|
-
throw new Error(
|
|
3312
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_NOT_ONE_OF_TYPES(validElementTypes));
|
|
2378
3313
|
}
|
|
2379
3314
|
const element = container.model.toJSON({ remove: ["default"] });
|
|
2380
3315
|
if (element?.isLocked) {
|
|
2381
|
-
throw new Error(
|
|
3316
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_IS_LOCKED);
|
|
2382
3317
|
}
|
|
2383
3318
|
const overridableProps = overridablePropsInput ? enrichOverridableProps(overridablePropsInput, element) : void 0;
|
|
2384
3319
|
if (overridableProps) {
|
|
2385
3320
|
updateElementDataWithOverridableProps(element, overridableProps);
|
|
2386
3321
|
}
|
|
2387
|
-
const uid =
|
|
3322
|
+
const uid = generateUniqueId5("component");
|
|
2388
3323
|
try {
|
|
2389
3324
|
await apiClient.validate({
|
|
2390
3325
|
items: [
|
|
@@ -2406,7 +3341,7 @@ var handleSaveAsComponent = async (params) => {
|
|
|
2406
3341
|
};
|
|
2407
3342
|
function enrichOverridableProps(input, rootElement) {
|
|
2408
3343
|
const enrichedProps = {};
|
|
2409
|
-
const defaultGroupId =
|
|
3344
|
+
const defaultGroupId = generateUniqueId5("group");
|
|
2410
3345
|
Object.entries(input.props).forEach(([, prop]) => {
|
|
2411
3346
|
const { elementId, propKey } = prop;
|
|
2412
3347
|
const element = findElementById(rootElement, elementId);
|
|
@@ -2427,7 +3362,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
2427
3362
|
`Property "${propKey}" does not exist in element "${elementId}" (type: ${widgetType}). Available properties: ${availableProps}`
|
|
2428
3363
|
);
|
|
2429
3364
|
}
|
|
2430
|
-
const overrideKey =
|
|
3365
|
+
const overrideKey = generateUniqueId5("prop");
|
|
2431
3366
|
const originValue = element.settings?.[propKey] ? element.settings[propKey] : elementType.propsSchema[propKey].default ?? null;
|
|
2432
3367
|
const label = generateLabel(propKey);
|
|
2433
3368
|
enrichedProps[overrideKey] = {
|
|
@@ -2485,11 +3420,11 @@ function findElementById(root, targetId) {
|
|
|
2485
3420
|
return null;
|
|
2486
3421
|
}
|
|
2487
3422
|
function generateLabel(propKey) {
|
|
2488
|
-
const uniqueId =
|
|
3423
|
+
const uniqueId = generateUniqueId5("prop");
|
|
2489
3424
|
return `${uniqueId} - ${propKey}`;
|
|
2490
3425
|
}
|
|
2491
3426
|
function getValidElementTypes() {
|
|
2492
|
-
const types =
|
|
3427
|
+
const types = getWidgetsCache3();
|
|
2493
3428
|
if (!types) {
|
|
2494
3429
|
return [];
|
|
2495
3430
|
}
|
|
@@ -2662,24 +3597,24 @@ function initMcp() {
|
|
|
2662
3597
|
|
|
2663
3598
|
// src/populate-store.ts
|
|
2664
3599
|
import { useEffect as useEffect6 } from "react";
|
|
2665
|
-
import { __dispatch as
|
|
3600
|
+
import { __dispatch as dispatch13 } from "@elementor/store";
|
|
2666
3601
|
function PopulateStore() {
|
|
2667
3602
|
useEffect6(() => {
|
|
2668
|
-
|
|
3603
|
+
dispatch13(loadComponents());
|
|
2669
3604
|
}, []);
|
|
2670
3605
|
return null;
|
|
2671
3606
|
}
|
|
2672
3607
|
|
|
2673
3608
|
// src/store/actions/remove-component-styles.ts
|
|
2674
|
-
import { __dispatch as
|
|
2675
|
-
function removeComponentStyles(
|
|
2676
|
-
apiClient.invalidateComponentConfigCache(
|
|
2677
|
-
|
|
3609
|
+
import { __dispatch as dispatch14 } from "@elementor/store";
|
|
3610
|
+
function removeComponentStyles(id2) {
|
|
3611
|
+
apiClient.invalidateComponentConfigCache(id2);
|
|
3612
|
+
dispatch14(slice.actions.removeStyles({ id: id2 }));
|
|
2678
3613
|
}
|
|
2679
3614
|
|
|
2680
3615
|
// src/store/components-styles-provider.ts
|
|
2681
3616
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
2682
|
-
import { __getState as
|
|
3617
|
+
import { __getState as getState17, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
2683
3618
|
var componentsStylesProvider = createStylesProvider({
|
|
2684
3619
|
key: "components-styles",
|
|
2685
3620
|
priority: 100,
|
|
@@ -2691,29 +3626,29 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
2691
3626
|
),
|
|
2692
3627
|
actions: {
|
|
2693
3628
|
all: () => {
|
|
2694
|
-
return selectFlatStyles(
|
|
3629
|
+
return selectFlatStyles(getState17());
|
|
2695
3630
|
},
|
|
2696
|
-
get: (
|
|
2697
|
-
return selectFlatStyles(
|
|
3631
|
+
get: (id2) => {
|
|
3632
|
+
return selectFlatStyles(getState17()).find((style) => style.id === id2) ?? null;
|
|
2698
3633
|
}
|
|
2699
3634
|
}
|
|
2700
3635
|
});
|
|
2701
3636
|
|
|
2702
3637
|
// src/sync/create-components-before-save.ts
|
|
2703
|
-
import { updateElementSettings } from "@elementor/editor-elements";
|
|
2704
|
-
import { __dispatch as
|
|
3638
|
+
import { updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
3639
|
+
import { __dispatch as dispatch15, __getState as getState18 } from "@elementor/store";
|
|
2705
3640
|
async function createComponentsBeforeSave({
|
|
2706
3641
|
elements,
|
|
2707
3642
|
status
|
|
2708
3643
|
}) {
|
|
2709
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
3644
|
+
const unpublishedComponents = selectUnpublishedComponents(getState18());
|
|
2710
3645
|
if (!unpublishedComponents.length) {
|
|
2711
3646
|
return;
|
|
2712
3647
|
}
|
|
2713
3648
|
try {
|
|
2714
3649
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
2715
3650
|
updateComponentInstances(elements, uidToComponentId);
|
|
2716
|
-
|
|
3651
|
+
dispatch15(
|
|
2717
3652
|
slice.actions.add(
|
|
2718
3653
|
unpublishedComponents.map((component) => ({
|
|
2719
3654
|
id: uidToComponentId.get(component.uid),
|
|
@@ -2723,7 +3658,7 @@ async function createComponentsBeforeSave({
|
|
|
2723
3658
|
}))
|
|
2724
3659
|
)
|
|
2725
3660
|
);
|
|
2726
|
-
|
|
3661
|
+
dispatch15(slice.actions.resetUnpublished());
|
|
2727
3662
|
} catch (error) {
|
|
2728
3663
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
2729
3664
|
}
|
|
@@ -2765,7 +3700,7 @@ function shouldUpdateElement(element, uidToComponentId) {
|
|
|
2765
3700
|
return { shouldUpdate: false, newComponentId: null };
|
|
2766
3701
|
}
|
|
2767
3702
|
function updateElementComponentId(elementId, componentId) {
|
|
2768
|
-
|
|
3703
|
+
updateElementSettings2({
|
|
2769
3704
|
id: elementId,
|
|
2770
3705
|
props: {
|
|
2771
3706
|
component_instance: {
|
|
@@ -2780,7 +3715,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
2780
3715
|
}
|
|
2781
3716
|
|
|
2782
3717
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
2783
|
-
import { __getState as
|
|
3718
|
+
import { __getState as getState19 } from "@elementor/store";
|
|
2784
3719
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
2785
3720
|
container
|
|
2786
3721
|
}) => {
|
|
@@ -2788,7 +3723,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2788
3723
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
2789
3724
|
return;
|
|
2790
3725
|
}
|
|
2791
|
-
const overridableProps = selectOverridableProps(
|
|
3726
|
+
const overridableProps = selectOverridableProps(getState19(), currentDocument.id);
|
|
2792
3727
|
if (overridableProps) {
|
|
2793
3728
|
container.settings.set("overridable_props", overridableProps);
|
|
2794
3729
|
}
|
|
@@ -2796,7 +3731,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2796
3731
|
|
|
2797
3732
|
// src/sync/update-archived-component-before-save.ts
|
|
2798
3733
|
import { notify } from "@elementor/editor-notifications";
|
|
2799
|
-
import { __getState as
|
|
3734
|
+
import { __getState as getState20 } from "@elementor/store";
|
|
2800
3735
|
var failedNotification = (message) => ({
|
|
2801
3736
|
type: "error",
|
|
2802
3737
|
message: `Failed to archive components: ${message}`,
|
|
@@ -2809,7 +3744,7 @@ var successNotification = (message) => ({
|
|
|
2809
3744
|
});
|
|
2810
3745
|
var updateArchivedComponentBeforeSave = async () => {
|
|
2811
3746
|
try {
|
|
2812
|
-
const archivedComponents = selectArchivedComponents(
|
|
3747
|
+
const archivedComponents = selectArchivedComponents(getState20());
|
|
2813
3748
|
if (!archivedComponents.length) {
|
|
2814
3749
|
return;
|
|
2815
3750
|
}
|
|
@@ -2842,7 +3777,7 @@ async function updateComponentsBeforeSave({ status, elements }) {
|
|
|
2842
3777
|
return;
|
|
2843
3778
|
}
|
|
2844
3779
|
await apiClient.updateStatuses(draftIds, "publish");
|
|
2845
|
-
draftIds.forEach((
|
|
3780
|
+
draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
|
|
2846
3781
|
}
|
|
2847
3782
|
|
|
2848
3783
|
// src/sync/before-save.ts
|
|
@@ -2860,6 +3795,7 @@ var beforeSave = ({ container, status }) => {
|
|
|
2860
3795
|
function init() {
|
|
2861
3796
|
stylesRepository.register(componentsStylesProvider);
|
|
2862
3797
|
registerSlice(slice);
|
|
3798
|
+
registerPanel(panel);
|
|
2863
3799
|
registerElementType(
|
|
2864
3800
|
TYPE,
|
|
2865
3801
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
@@ -2875,7 +3811,7 @@ function init() {
|
|
|
2875
3811
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
2876
3812
|
injectTab({
|
|
2877
3813
|
id: "components",
|
|
2878
|
-
label:
|
|
3814
|
+
label: __24("Components", "elementor"),
|
|
2879
3815
|
component: Components
|
|
2880
3816
|
});
|
|
2881
3817
|
injectIntoTop({
|
|
@@ -2895,9 +3831,9 @@ function init() {
|
|
|
2895
3831
|
component: ComponentPanelHeader
|
|
2896
3832
|
});
|
|
2897
3833
|
registerDataHook("after", "editor/documents/attach-preview", async () => {
|
|
2898
|
-
const { id, config } = getV1CurrentDocument();
|
|
2899
|
-
if (
|
|
2900
|
-
removeComponentStyles(
|
|
3834
|
+
const { id: id2, config } = getV1CurrentDocument();
|
|
3835
|
+
if (id2) {
|
|
3836
|
+
removeComponentStyles(id2);
|
|
2901
3837
|
}
|
|
2902
3838
|
await loadComponentsAssets(config?.elements ?? []);
|
|
2903
3839
|
});
|