@elementor/editor-components 3.35.0-379 → 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 +1419 -564
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1365 -494
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/component-panel-header/component-badge.tsx +8 -3
- package/src/components/component-panel-header/component-panel-header.tsx +5 -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/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,50 +317,1057 @@ 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";
|
|
320
321
|
import { useSuppressedMessage } from "@elementor/editor-current-user";
|
|
321
322
|
import { getV1DocumentsManager as getV1DocumentsManager3 } from "@elementor/editor-documents";
|
|
322
323
|
import { ArrowLeftIcon, ComponentsFilledIcon } from "@elementor/icons";
|
|
323
|
-
import { Box as
|
|
324
|
-
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";
|
|
325
326
|
|
|
326
327
|
// src/hooks/use-navigate-back.ts
|
|
327
328
|
import { useCallback } from "react";
|
|
328
329
|
import { getV1DocumentsManager as getV1DocumentsManager2 } from "@elementor/editor-documents";
|
|
329
330
|
import { __useSelector as useSelector2 } from "@elementor/store";
|
|
330
331
|
|
|
331
|
-
// src/utils/switch-to-component.ts
|
|
332
|
-
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
333
|
-
function switchToComponent(componentId, componentInstanceId) {
|
|
334
|
-
runCommand("editor/documents/switch", {
|
|
335
|
-
id: componentId,
|
|
336
|
-
selector: componentInstanceId ? `[data-id="${componentInstanceId}"]` : void 0,
|
|
337
|
-
mode: "autosave",
|
|
338
|
-
setAsInitial: false,
|
|
339
|
-
shouldScroll: false
|
|
332
|
+
// src/utils/switch-to-component.ts
|
|
333
|
+
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
334
|
+
function switchToComponent(componentId, componentInstanceId) {
|
|
335
|
+
runCommand("editor/documents/switch", {
|
|
336
|
+
id: componentId,
|
|
337
|
+
selector: componentInstanceId ? `[data-id="${componentInstanceId}"]` : void 0,
|
|
338
|
+
mode: "autosave",
|
|
339
|
+
setAsInitial: false,
|
|
340
|
+
shouldScroll: false
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
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
|
|
340
1225
|
});
|
|
1226
|
+
return {
|
|
1227
|
+
editableRef,
|
|
1228
|
+
isEditing,
|
|
1229
|
+
error,
|
|
1230
|
+
getEditableProps,
|
|
1231
|
+
setEditingGroupId: (groupId) => {
|
|
1232
|
+
setEditingGroupId(groupId);
|
|
1233
|
+
openEditMode();
|
|
1234
|
+
},
|
|
1235
|
+
editingGroupId
|
|
1236
|
+
};
|
|
341
1237
|
}
|
|
342
1238
|
|
|
343
|
-
// src/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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) {
|
|
351
1279
|
return;
|
|
352
1280
|
}
|
|
353
|
-
|
|
354
|
-
|
|
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
|
+
)))));
|
|
355
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"))));
|
|
356
1364
|
|
|
357
1365
|
// src/components/components-tab/component-introduction.tsx
|
|
358
|
-
import * as
|
|
1366
|
+
import * as React8 from "react";
|
|
359
1367
|
import { PopoverContent } from "@elementor/editor-controls";
|
|
360
1368
|
import { PopoverHeader } from "@elementor/editor-ui";
|
|
361
|
-
import { Box, Button, Image, Popover, Stack, Typography } from "@elementor/ui";
|
|
362
|
-
import { __ } from "@wordpress/i18n";
|
|
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";
|
|
363
1371
|
var ComponentIntroduction = ({
|
|
364
1372
|
anchorRef,
|
|
365
1373
|
shouldShowIntroduction,
|
|
@@ -368,8 +1376,8 @@ var ComponentIntroduction = ({
|
|
|
368
1376
|
if (!anchorRef.current || !shouldShowIntroduction) {
|
|
369
1377
|
return null;
|
|
370
1378
|
}
|
|
371
|
-
return /* @__PURE__ */
|
|
372
|
-
|
|
1379
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1380
|
+
Popover2,
|
|
373
1381
|
{
|
|
374
1382
|
anchorEl: anchorRef.current,
|
|
375
1383
|
open: shouldShowIntroduction,
|
|
@@ -383,34 +1391,34 @@ var ComponentIntroduction = ({
|
|
|
383
1391
|
},
|
|
384
1392
|
onClose
|
|
385
1393
|
},
|
|
386
|
-
/* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ React8.createElement(Box5, { sx: { width: "296px" } }, /* @__PURE__ */ React8.createElement(PopoverHeader, { title: __9("Add your first property", "elementor"), onClose }), /* @__PURE__ */ React8.createElement(
|
|
387
1395
|
Image,
|
|
388
1396
|
{
|
|
389
1397
|
sx: { width: "296px", height: "160px" },
|
|
390
1398
|
src: "https://assets.elementor.com/packages/v1/images/components-properties-intro.png",
|
|
391
1399
|
alt: ""
|
|
392
1400
|
}
|
|
393
|
-
), /* @__PURE__ */
|
|
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(
|
|
394
1402
|
"Click next to any setting you want users to customize - like text, images, or links.",
|
|
395
1403
|
"elementor"
|
|
396
|
-
)), /* @__PURE__ */
|
|
1404
|
+
)), /* @__PURE__ */ React8.createElement(Typography5, { variant: "body2" }, __9(
|
|
397
1405
|
"Your properties will appear in the Properties panel, where you can organize and manage them anytime.",
|
|
398
1406
|
"elementor"
|
|
399
|
-
)), /* @__PURE__ */
|
|
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"))))))
|
|
400
1408
|
);
|
|
401
1409
|
};
|
|
402
1410
|
|
|
403
1411
|
// src/components/component-panel-header/component-badge.tsx
|
|
404
|
-
import * as
|
|
1412
|
+
import * as React9 from "react";
|
|
405
1413
|
import { useEffect, useRef } from "react";
|
|
406
|
-
import { ComponentPropListIcon } from "@elementor/icons";
|
|
407
|
-
import { Badge, Box as
|
|
408
|
-
import { __ as
|
|
409
|
-
var ComponentsBadge =
|
|
410
|
-
({ overridesCount }, ref) => {
|
|
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) => {
|
|
411
1419
|
const prevCount = usePrevious(overridesCount);
|
|
412
1420
|
const isFirstOverride = prevCount === 0 && overridesCount === 1;
|
|
413
|
-
return /* @__PURE__ */
|
|
1421
|
+
return /* @__PURE__ */ React9.createElement(
|
|
414
1422
|
StyledBadge,
|
|
415
1423
|
{
|
|
416
1424
|
ref,
|
|
@@ -419,13 +1427,22 @@ var ComponentsBadge = React2.forwardRef(
|
|
|
419
1427
|
invisible: overridesCount === 0,
|
|
420
1428
|
animate: isFirstOverride,
|
|
421
1429
|
anchorOrigin: { vertical: "top", horizontal: "right" },
|
|
422
|
-
badgeContent: /* @__PURE__ */
|
|
1430
|
+
badgeContent: /* @__PURE__ */ React9.createElement(Box6, { sx: { animation: !isFirstOverride ? `${slideUp} 300ms ease-out` : "none" } }, overridesCount)
|
|
423
1431
|
},
|
|
424
|
-
/* @__PURE__ */
|
|
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
|
+
)
|
|
425
1442
|
);
|
|
426
1443
|
}
|
|
427
1444
|
);
|
|
428
|
-
var StyledBadge =
|
|
1445
|
+
var StyledBadge = styled2(Badge, { shouldForwardProp: (prop) => prop !== "animate" })(
|
|
429
1446
|
({ theme, animate }) => ({
|
|
430
1447
|
"& .MuiBadge-badge": {
|
|
431
1448
|
minWidth: theme.spacing(2),
|
|
@@ -454,17 +1471,6 @@ var slideUp = keyframes`
|
|
|
454
1471
|
to { transform: translateY(0); opacity: 1; }
|
|
455
1472
|
`;
|
|
456
1473
|
|
|
457
|
-
// src/components/component-panel-header/use-overridable-props.ts
|
|
458
|
-
import { __useSelector as useSelector3 } from "@elementor/store";
|
|
459
|
-
function useOverridableProps(componentId) {
|
|
460
|
-
return useSelector3((state) => {
|
|
461
|
-
if (!componentId) {
|
|
462
|
-
return void 0;
|
|
463
|
-
}
|
|
464
|
-
return selectOverridableProps(state, componentId);
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
|
|
468
1474
|
// src/components/component-panel-header/component-panel-header.tsx
|
|
469
1475
|
var MESSAGE_KEY = "components-properties-introduction";
|
|
470
1476
|
var ComponentPanelHeader = () => {
|
|
@@ -473,9 +1479,10 @@ var ComponentPanelHeader = () => {
|
|
|
473
1479
|
const onBack = useNavigateBack();
|
|
474
1480
|
const componentName = getComponentName();
|
|
475
1481
|
const [isMessageSuppressed, suppressMessage] = useSuppressedMessage(MESSAGE_KEY);
|
|
476
|
-
const [shouldShowIntroduction, setShouldShowIntroduction] =
|
|
1482
|
+
const [shouldShowIntroduction, setShouldShowIntroduction] = React10.useState(!isMessageSuppressed);
|
|
1483
|
+
const { open: openPropertiesPanel } = usePanelActions();
|
|
477
1484
|
const overridesCount = overridableProps ? Object.keys(overridableProps.props).length : 0;
|
|
478
|
-
const anchorRef =
|
|
1485
|
+
const anchorRef = React10.useRef(null);
|
|
479
1486
|
if (!currentComponentId) {
|
|
480
1487
|
return null;
|
|
481
1488
|
}
|
|
@@ -483,17 +1490,17 @@ var ComponentPanelHeader = () => {
|
|
|
483
1490
|
suppressMessage();
|
|
484
1491
|
setShouldShowIntroduction(false);
|
|
485
1492
|
};
|
|
486
|
-
return /* @__PURE__ */
|
|
487
|
-
|
|
1493
|
+
return /* @__PURE__ */ React10.createElement(Box7, null, /* @__PURE__ */ React10.createElement(
|
|
1494
|
+
Stack6,
|
|
488
1495
|
{
|
|
489
1496
|
direction: "row",
|
|
490
1497
|
alignItems: "center",
|
|
491
1498
|
justifyContent: "space-between",
|
|
492
1499
|
sx: { height: 48, pl: 1.5, pr: 2, py: 1 }
|
|
493
1500
|
},
|
|
494
|
-
/* @__PURE__ */
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
-
), /* @__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(
|
|
497
1504
|
ComponentIntroduction,
|
|
498
1505
|
{
|
|
499
1506
|
anchorRef,
|
|
@@ -509,17 +1516,17 @@ function getComponentName() {
|
|
|
509
1516
|
}
|
|
510
1517
|
|
|
511
1518
|
// src/components/components-tab/components.tsx
|
|
512
|
-
import * as
|
|
513
|
-
import { ThemeProvider } from "@elementor/editor-ui";
|
|
1519
|
+
import * as React16 from "react";
|
|
1520
|
+
import { ThemeProvider as ThemeProvider2 } from "@elementor/editor-ui";
|
|
514
1521
|
|
|
515
1522
|
// src/components/components-tab/component-search.tsx
|
|
516
|
-
import * as
|
|
1523
|
+
import * as React12 from "react";
|
|
517
1524
|
import { SearchIcon } from "@elementor/icons";
|
|
518
|
-
import { Box as
|
|
519
|
-
import { __ as
|
|
1525
|
+
import { Box as Box8, InputAdornment, Stack as Stack7, TextField as TextField2 } from "@elementor/ui";
|
|
1526
|
+
import { __ as __12 } from "@wordpress/i18n";
|
|
520
1527
|
|
|
521
1528
|
// src/components/components-tab/search-provider.tsx
|
|
522
|
-
import * as
|
|
1529
|
+
import * as React11 from "react";
|
|
523
1530
|
import { createContext, useContext } from "react";
|
|
524
1531
|
import { useSearchState } from "@elementor/utils";
|
|
525
1532
|
var SearchContext = createContext(void 0);
|
|
@@ -531,7 +1538,7 @@ var SearchProvider = ({
|
|
|
531
1538
|
const clearSearch = () => {
|
|
532
1539
|
handleChange("");
|
|
533
1540
|
};
|
|
534
|
-
return /* @__PURE__ */
|
|
1541
|
+
return /* @__PURE__ */ React11.createElement(SearchContext.Provider, { value: { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }, children);
|
|
535
1542
|
};
|
|
536
1543
|
var useSearch = () => {
|
|
537
1544
|
const context = useContext(SearchContext);
|
|
@@ -544,27 +1551,27 @@ var useSearch = () => {
|
|
|
544
1551
|
// src/components/components-tab/component-search.tsx
|
|
545
1552
|
var ComponentSearch = () => {
|
|
546
1553
|
const { inputValue, handleChange } = useSearch();
|
|
547
|
-
return /* @__PURE__ */
|
|
548
|
-
|
|
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,
|
|
549
1556
|
{
|
|
550
1557
|
role: "search",
|
|
551
1558
|
fullWidth: true,
|
|
552
1559
|
size: "tiny",
|
|
553
1560
|
value: inputValue,
|
|
554
|
-
placeholder:
|
|
1561
|
+
placeholder: __12("Search", "elementor"),
|
|
555
1562
|
onChange: (e) => handleChange(e.target.value),
|
|
556
1563
|
InputProps: {
|
|
557
|
-
startAdornment: /* @__PURE__ */
|
|
1564
|
+
startAdornment: /* @__PURE__ */ React12.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React12.createElement(SearchIcon, { fontSize: "tiny" }))
|
|
558
1565
|
}
|
|
559
1566
|
}
|
|
560
1567
|
)));
|
|
561
1568
|
};
|
|
562
1569
|
|
|
563
1570
|
// src/components/components-tab/components-list.tsx
|
|
564
|
-
import * as
|
|
1571
|
+
import * as React15 from "react";
|
|
565
1572
|
import { ComponentsIcon as ComponentsIcon2, EyeIcon } from "@elementor/icons";
|
|
566
|
-
import { Box as
|
|
567
|
-
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";
|
|
568
1575
|
|
|
569
1576
|
// src/hooks/use-components.ts
|
|
570
1577
|
import { __useSelector as useSelector4 } from "@elementor/store";
|
|
@@ -575,51 +1582,51 @@ var useComponents = () => {
|
|
|
575
1582
|
};
|
|
576
1583
|
|
|
577
1584
|
// src/components/components-tab/components-item.tsx
|
|
578
|
-
import * as
|
|
1585
|
+
import * as React13 from "react";
|
|
579
1586
|
import { endDragElementFromPanel, startDragElementFromPanel } from "@elementor/editor-canvas";
|
|
580
1587
|
import { dropElement } from "@elementor/editor-elements";
|
|
581
|
-
import { EllipsisWithTooltip, MenuListItem } from "@elementor/editor-ui";
|
|
582
|
-
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";
|
|
583
1590
|
import {
|
|
584
|
-
bindMenu,
|
|
585
|
-
bindTrigger,
|
|
586
|
-
Box as
|
|
587
|
-
IconButton as
|
|
1591
|
+
bindMenu as bindMenu2,
|
|
1592
|
+
bindTrigger as bindTrigger3,
|
|
1593
|
+
Box as Box9,
|
|
1594
|
+
IconButton as IconButton5,
|
|
588
1595
|
ListItemButton,
|
|
589
1596
|
ListItemIcon,
|
|
590
|
-
Menu,
|
|
591
|
-
Stack as
|
|
592
|
-
Typography as
|
|
593
|
-
usePopupState
|
|
1597
|
+
Menu as Menu2,
|
|
1598
|
+
Stack as Stack8,
|
|
1599
|
+
Typography as Typography7,
|
|
1600
|
+
usePopupState as usePopupState3
|
|
594
1601
|
} from "@elementor/ui";
|
|
595
|
-
import { __ as
|
|
1602
|
+
import { __ as __14 } from "@wordpress/i18n";
|
|
596
1603
|
|
|
597
1604
|
// src/store/actions/archive-component.ts
|
|
598
|
-
import { setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
1605
|
+
import { setDocumentModifiedStatus as setDocumentModifiedStatus3 } from "@elementor/editor-documents";
|
|
599
1606
|
import { __getStore as getStore } from "@elementor/store";
|
|
600
1607
|
var archiveComponent = (componentId) => {
|
|
601
1608
|
const store = getStore();
|
|
602
|
-
const
|
|
603
|
-
if (!
|
|
1609
|
+
const dispatch16 = store?.dispatch;
|
|
1610
|
+
if (!dispatch16) {
|
|
604
1611
|
return;
|
|
605
1612
|
}
|
|
606
|
-
|
|
607
|
-
|
|
1613
|
+
dispatch16(slice.actions.archive(componentId));
|
|
1614
|
+
setDocumentModifiedStatus3(true);
|
|
608
1615
|
};
|
|
609
1616
|
|
|
610
1617
|
// src/store/actions/load-components-assets.ts
|
|
611
|
-
import { isDocumentDirty, setDocumentModifiedStatus as
|
|
1618
|
+
import { isDocumentDirty, setDocumentModifiedStatus as setDocumentModifiedStatus4 } from "@elementor/editor-documents";
|
|
612
1619
|
|
|
613
1620
|
// src/create-component-type.ts
|
|
614
1621
|
import {
|
|
615
1622
|
createTemplatedElementView
|
|
616
1623
|
} from "@elementor/editor-canvas";
|
|
617
1624
|
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
618
|
-
import { __ as
|
|
1625
|
+
import { __ as __13 } from "@wordpress/i18n";
|
|
619
1626
|
|
|
620
1627
|
// src/utils/tracking.ts
|
|
621
1628
|
import { getMixpanel } from "@elementor/mixpanel";
|
|
622
|
-
import { __getState as
|
|
1629
|
+
import { __getState as getState9 } from "@elementor/store";
|
|
623
1630
|
var trackComponentEvent = ({ action, ...data }) => {
|
|
624
1631
|
const { dispatchEvent, config } = getMixpanel();
|
|
625
1632
|
if (!config?.names?.components?.[action]) {
|
|
@@ -636,7 +1643,7 @@ var onElementDrop = (_args, element) => {
|
|
|
636
1643
|
const componentName = editorSettings?.title;
|
|
637
1644
|
const componentUID = editorSettings?.component_uid;
|
|
638
1645
|
const instanceId = element.id;
|
|
639
|
-
const createdThisSession = selectCreatedThisSession(
|
|
1646
|
+
const createdThisSession = selectCreatedThisSession(getState9());
|
|
640
1647
|
const isSameSessionReuse = componentUID && createdThisSession.includes(componentUID);
|
|
641
1648
|
const eventsManagerConfig = window.elementorCommon.eventsManager.config;
|
|
642
1649
|
const { locations, secondaryLocations } = eventsManagerConfig;
|
|
@@ -735,7 +1742,7 @@ function createComponentView(options) {
|
|
|
735
1742
|
action: {
|
|
736
1743
|
name: "edit component",
|
|
737
1744
|
icon: "eicon-edit",
|
|
738
|
-
title: () =>
|
|
1745
|
+
title: () => __13("Edit Component", "elementor"),
|
|
739
1746
|
isEnabled: () => true,
|
|
740
1747
|
callback: (_, eventData) => this.editComponent(eventData)
|
|
741
1748
|
}
|
|
@@ -830,7 +1837,7 @@ var getComponentIds = async (elements) => {
|
|
|
830
1837
|
};
|
|
831
1838
|
|
|
832
1839
|
// src/store/actions/load-components-overridable-props.ts
|
|
833
|
-
import { __dispatch as
|
|
1840
|
+
import { __dispatch as dispatch8, __getState as getState10 } from "@elementor/store";
|
|
834
1841
|
function loadComponentsOverridableProps(componentIds) {
|
|
835
1842
|
if (!componentIds.length) {
|
|
836
1843
|
return;
|
|
@@ -838,7 +1845,7 @@ function loadComponentsOverridableProps(componentIds) {
|
|
|
838
1845
|
componentIds.forEach(loadComponentOverrides);
|
|
839
1846
|
}
|
|
840
1847
|
async function loadComponentOverrides(componentId) {
|
|
841
|
-
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(
|
|
1848
|
+
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(getState10(), componentId);
|
|
842
1849
|
if (isOverridablePropsLoaded) {
|
|
843
1850
|
return;
|
|
844
1851
|
}
|
|
@@ -846,7 +1853,7 @@ async function loadComponentOverrides(componentId) {
|
|
|
846
1853
|
if (!overridableProps) {
|
|
847
1854
|
return;
|
|
848
1855
|
}
|
|
849
|
-
|
|
1856
|
+
dispatch8(
|
|
850
1857
|
slice.actions.setOverridableProps({
|
|
851
1858
|
componentId,
|
|
852
1859
|
overridableProps
|
|
@@ -855,13 +1862,13 @@ async function loadComponentOverrides(componentId) {
|
|
|
855
1862
|
}
|
|
856
1863
|
|
|
857
1864
|
// src/store/actions/load-components-styles.ts
|
|
858
|
-
import { __dispatch as
|
|
1865
|
+
import { __dispatch as dispatch9, __getState as getState11 } from "@elementor/store";
|
|
859
1866
|
async function loadComponentsStyles(componentIds) {
|
|
860
1867
|
if (!componentIds.length) {
|
|
861
1868
|
return;
|
|
862
1869
|
}
|
|
863
|
-
const knownComponents = selectStyles(
|
|
864
|
-
const unknownComponentIds = componentIds.filter((
|
|
1870
|
+
const knownComponents = selectStyles(getState11());
|
|
1871
|
+
const unknownComponentIds = componentIds.filter((id2) => !knownComponents[id2]);
|
|
865
1872
|
if (!unknownComponentIds.length) {
|
|
866
1873
|
return;
|
|
867
1874
|
}
|
|
@@ -872,13 +1879,13 @@ async function addComponentStyles(ids) {
|
|
|
872
1879
|
addStyles(newComponents);
|
|
873
1880
|
}
|
|
874
1881
|
async function loadStyles(ids) {
|
|
875
|
-
return Promise.all(ids.map(async (
|
|
1882
|
+
return Promise.all(ids.map(async (id2) => [id2, await apiClient.getComponentConfig(id2)]));
|
|
876
1883
|
}
|
|
877
1884
|
function addStyles(data) {
|
|
878
1885
|
const styles = Object.fromEntries(
|
|
879
1886
|
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
880
1887
|
);
|
|
881
|
-
|
|
1888
|
+
dispatch9(slice.actions.addStyles(styles));
|
|
882
1889
|
}
|
|
883
1890
|
function extractStyles(element) {
|
|
884
1891
|
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
@@ -899,13 +1906,13 @@ async function updateDocumentState(componentIds) {
|
|
|
899
1906
|
);
|
|
900
1907
|
const isDrafted = components.some(isDocumentDirty);
|
|
901
1908
|
if (isDrafted) {
|
|
902
|
-
|
|
1909
|
+
setDocumentModifiedStatus4(true);
|
|
903
1910
|
}
|
|
904
1911
|
}
|
|
905
1912
|
|
|
906
1913
|
// src/utils/get-container-for-new-element.ts
|
|
907
1914
|
import {
|
|
908
|
-
getContainer,
|
|
1915
|
+
getContainer as getContainer2,
|
|
909
1916
|
getCurrentDocumentContainer,
|
|
910
1917
|
getSelectedElements
|
|
911
1918
|
} from "@elementor/editor-elements";
|
|
@@ -940,7 +1947,7 @@ function getSelectedElementContainer() {
|
|
|
940
1947
|
if (selectedElements.length !== 1) {
|
|
941
1948
|
return void 0;
|
|
942
1949
|
}
|
|
943
|
-
return
|
|
1950
|
+
return getContainer2(selectedElements[0].id);
|
|
944
1951
|
}
|
|
945
1952
|
|
|
946
1953
|
// src/components/create-component-form/utils/replace-element-with-component.ts
|
|
@@ -978,7 +1985,7 @@ var createComponentModel = (component) => {
|
|
|
978
1985
|
// src/components/components-tab/components-item.tsx
|
|
979
1986
|
var ComponentItem = ({ component }) => {
|
|
980
1987
|
const componentModel = createComponentModel(component);
|
|
981
|
-
const popupState =
|
|
1988
|
+
const popupState = usePopupState3({
|
|
982
1989
|
variant: "popover",
|
|
983
1990
|
disableAutoFocus: true
|
|
984
1991
|
});
|
|
@@ -996,7 +2003,7 @@ var ComponentItem = ({ component }) => {
|
|
|
996
2003
|
}
|
|
997
2004
|
archiveComponent(component.id);
|
|
998
2005
|
};
|
|
999
|
-
return /* @__PURE__ */
|
|
2006
|
+
return /* @__PURE__ */ React13.createElement(Stack8, null, /* @__PURE__ */ React13.createElement(
|
|
1000
2007
|
ListItemButton,
|
|
1001
2008
|
{
|
|
1002
2009
|
draggable: true,
|
|
@@ -1014,8 +2021,8 @@ var ComponentItem = ({ component }) => {
|
|
|
1014
2021
|
gap: 1
|
|
1015
2022
|
}
|
|
1016
2023
|
},
|
|
1017
|
-
/* @__PURE__ */
|
|
1018
|
-
|
|
2024
|
+
/* @__PURE__ */ React13.createElement(
|
|
2025
|
+
Box9,
|
|
1019
2026
|
{
|
|
1020
2027
|
onClick: handleClick,
|
|
1021
2028
|
sx: {
|
|
@@ -1026,22 +2033,22 @@ var ComponentItem = ({ component }) => {
|
|
|
1026
2033
|
flexGrow: 1
|
|
1027
2034
|
}
|
|
1028
2035
|
},
|
|
1029
|
-
/* @__PURE__ */
|
|
1030
|
-
/* @__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(
|
|
1031
2038
|
EllipsisWithTooltip,
|
|
1032
2039
|
{
|
|
1033
2040
|
title: component.name,
|
|
1034
|
-
as:
|
|
2041
|
+
as: Typography7,
|
|
1035
2042
|
variant: "caption",
|
|
1036
2043
|
color: "text.primary"
|
|
1037
2044
|
}
|
|
1038
2045
|
))
|
|
1039
2046
|
),
|
|
1040
|
-
/* @__PURE__ */
|
|
1041
|
-
), /* @__PURE__ */
|
|
1042
|
-
|
|
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,
|
|
1043
2050
|
{
|
|
1044
|
-
...
|
|
2051
|
+
...bindMenu2(popupState),
|
|
1045
2052
|
anchorOrigin: {
|
|
1046
2053
|
vertical: "bottom",
|
|
1047
2054
|
horizontal: "right"
|
|
@@ -1051,7 +2058,7 @@ var ComponentItem = ({ component }) => {
|
|
|
1051
2058
|
horizontal: "right"
|
|
1052
2059
|
}
|
|
1053
2060
|
},
|
|
1054
|
-
/* @__PURE__ */
|
|
2061
|
+
/* @__PURE__ */ React13.createElement(MenuListItem3, { sx: { minWidth: "160px" }, onClick: handleArchiveClick }, __14("Archive", "elementor"))
|
|
1055
2062
|
));
|
|
1056
2063
|
};
|
|
1057
2064
|
var addComponentToPage = (model) => {
|
|
@@ -1068,13 +2075,13 @@ var addComponentToPage = (model) => {
|
|
|
1068
2075
|
};
|
|
1069
2076
|
|
|
1070
2077
|
// src/components/components-tab/loading-components.tsx
|
|
1071
|
-
import * as
|
|
1072
|
-
import { Box as
|
|
2078
|
+
import * as React14 from "react";
|
|
2079
|
+
import { Box as Box10, ListItemButton as ListItemButton2, Skeleton, Stack as Stack9 } from "@elementor/ui";
|
|
1073
2080
|
var ROWS_COUNT = 6;
|
|
1074
2081
|
var rows = Array.from({ length: ROWS_COUNT }, (_, index) => index);
|
|
1075
2082
|
var LoadingComponents = () => {
|
|
1076
|
-
return /* @__PURE__ */
|
|
1077
|
-
|
|
2083
|
+
return /* @__PURE__ */ React14.createElement(
|
|
2084
|
+
Stack9,
|
|
1078
2085
|
{
|
|
1079
2086
|
"aria-label": "Loading components",
|
|
1080
2087
|
gap: 1,
|
|
@@ -1095,14 +2102,14 @@ var LoadingComponents = () => {
|
|
|
1095
2102
|
}
|
|
1096
2103
|
}
|
|
1097
2104
|
},
|
|
1098
|
-
rows.map((row) => /* @__PURE__ */
|
|
2105
|
+
rows.map((row) => /* @__PURE__ */ React14.createElement(
|
|
1099
2106
|
ListItemButton2,
|
|
1100
2107
|
{
|
|
1101
2108
|
key: row,
|
|
1102
2109
|
sx: { border: "solid 1px", borderColor: "divider", py: 0.5, px: 1 },
|
|
1103
2110
|
shape: "rounded"
|
|
1104
2111
|
},
|
|
1105
|
-
/* @__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" }))
|
|
1106
2113
|
))
|
|
1107
2114
|
);
|
|
1108
2115
|
};
|
|
@@ -1111,20 +2118,20 @@ var LoadingComponents = () => {
|
|
|
1111
2118
|
function ComponentsList() {
|
|
1112
2119
|
const { components, isLoading, searchValue } = useFilteredComponents();
|
|
1113
2120
|
if (isLoading) {
|
|
1114
|
-
return /* @__PURE__ */
|
|
2121
|
+
return /* @__PURE__ */ React15.createElement(LoadingComponents, null);
|
|
1115
2122
|
}
|
|
1116
2123
|
const isEmpty = !components || components.length === 0;
|
|
1117
2124
|
if (isEmpty) {
|
|
1118
2125
|
if (searchValue.length > 0) {
|
|
1119
|
-
return /* @__PURE__ */
|
|
2126
|
+
return /* @__PURE__ */ React15.createElement(EmptySearchResult, null);
|
|
1120
2127
|
}
|
|
1121
|
-
return /* @__PURE__ */
|
|
2128
|
+
return /* @__PURE__ */ React15.createElement(EmptyState, null);
|
|
1122
2129
|
}
|
|
1123
|
-
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 })));
|
|
1124
2131
|
}
|
|
1125
2132
|
var EmptyState = () => {
|
|
1126
|
-
return /* @__PURE__ */
|
|
1127
|
-
|
|
2133
|
+
return /* @__PURE__ */ React15.createElement(
|
|
2134
|
+
Stack10,
|
|
1128
2135
|
{
|
|
1129
2136
|
alignItems: "center",
|
|
1130
2137
|
justifyContent: "center",
|
|
@@ -1133,32 +2140,32 @@ var EmptyState = () => {
|
|
|
1133
2140
|
gap: 1.75,
|
|
1134
2141
|
overflow: "hidden"
|
|
1135
2142
|
},
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
1138
|
-
/* @__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(
|
|
1139
2146
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
1140
2147
|
"elementor"
|
|
1141
2148
|
)),
|
|
1142
|
-
/* @__PURE__ */
|
|
1143
|
-
/* @__PURE__ */
|
|
1144
|
-
/* @__PURE__ */
|
|
1145
|
-
|
|
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,
|
|
1146
2153
|
{
|
|
1147
2154
|
align: "left",
|
|
1148
2155
|
variant: "caption",
|
|
1149
2156
|
color: "text.secondary",
|
|
1150
2157
|
sx: { display: "flex", flexDirection: "column" }
|
|
1151
2158
|
},
|
|
1152
|
-
/* @__PURE__ */
|
|
1153
|
-
/* @__PURE__ */
|
|
1154
|
-
/* @__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"))
|
|
1155
2162
|
)
|
|
1156
2163
|
);
|
|
1157
2164
|
};
|
|
1158
2165
|
var EmptySearchResult = () => {
|
|
1159
2166
|
const { searchValue, clearSearch } = useSearch();
|
|
1160
|
-
return /* @__PURE__ */
|
|
1161
|
-
|
|
2167
|
+
return /* @__PURE__ */ React15.createElement(
|
|
2168
|
+
Stack10,
|
|
1162
2169
|
{
|
|
1163
2170
|
color: "text.secondary",
|
|
1164
2171
|
pt: 5,
|
|
@@ -1167,17 +2174,17 @@ var EmptySearchResult = () => {
|
|
|
1167
2174
|
overflow: "hidden",
|
|
1168
2175
|
justifySelf: "center"
|
|
1169
2176
|
},
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
|
|
2177
|
+
/* @__PURE__ */ React15.createElement(ComponentsIcon2, null),
|
|
2178
|
+
/* @__PURE__ */ React15.createElement(
|
|
2179
|
+
Box11,
|
|
1173
2180
|
{
|
|
1174
2181
|
sx: {
|
|
1175
2182
|
width: "100%"
|
|
1176
2183
|
}
|
|
1177
2184
|
},
|
|
1178
|
-
/* @__PURE__ */
|
|
1179
|
-
searchValue && /* @__PURE__ */
|
|
1180
|
-
|
|
2185
|
+
/* @__PURE__ */ React15.createElement(Typography8, { align: "center", variant: "subtitle2", color: "inherit" }, __15("Sorry, nothing matched", "elementor")),
|
|
2186
|
+
searchValue && /* @__PURE__ */ React15.createElement(
|
|
2187
|
+
Typography8,
|
|
1181
2188
|
{
|
|
1182
2189
|
variant: "subtitle2",
|
|
1183
2190
|
color: "inherit",
|
|
@@ -1187,8 +2194,8 @@ var EmptySearchResult = () => {
|
|
|
1187
2194
|
justifyContent: "center"
|
|
1188
2195
|
}
|
|
1189
2196
|
},
|
|
1190
|
-
/* @__PURE__ */
|
|
1191
|
-
/* @__PURE__ */
|
|
2197
|
+
/* @__PURE__ */ React15.createElement("span", null, "\u201C"),
|
|
2198
|
+
/* @__PURE__ */ React15.createElement(
|
|
1192
2199
|
"span",
|
|
1193
2200
|
{
|
|
1194
2201
|
style: {
|
|
@@ -1199,11 +2206,11 @@ var EmptySearchResult = () => {
|
|
|
1199
2206
|
},
|
|
1200
2207
|
searchValue
|
|
1201
2208
|
),
|
|
1202
|
-
/* @__PURE__ */
|
|
2209
|
+
/* @__PURE__ */ React15.createElement("span", null, "\u201D.")
|
|
1203
2210
|
)
|
|
1204
2211
|
),
|
|
1205
|
-
/* @__PURE__ */
|
|
1206
|
-
/* @__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")))
|
|
1207
2214
|
);
|
|
1208
2215
|
};
|
|
1209
2216
|
var useFilteredComponents = () => {
|
|
@@ -1220,35 +2227,35 @@ var useFilteredComponents = () => {
|
|
|
1220
2227
|
|
|
1221
2228
|
// src/components/components-tab/components.tsx
|
|
1222
2229
|
var Components = () => {
|
|
1223
|
-
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)));
|
|
1224
2231
|
};
|
|
1225
2232
|
|
|
1226
2233
|
// src/components/consts.ts
|
|
1227
2234
|
var COMPONENT_DOCUMENT_TYPE = "elementor_component";
|
|
1228
2235
|
|
|
1229
2236
|
// src/components/create-component-form/create-component-form.tsx
|
|
1230
|
-
import * as
|
|
1231
|
-
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";
|
|
1232
2239
|
import { getElementLabel } from "@elementor/editor-elements";
|
|
1233
|
-
import { Form as FormElement, ThemeProvider as
|
|
2240
|
+
import { Form as FormElement, ThemeProvider as ThemeProvider3 } from "@elementor/editor-ui";
|
|
1234
2241
|
import { StarIcon } from "@elementor/icons";
|
|
1235
|
-
import { Alert, Button as
|
|
1236
|
-
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";
|
|
1237
2244
|
|
|
1238
2245
|
// src/store/actions/create-unpublished-component.ts
|
|
1239
2246
|
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
1240
|
-
import { __dispatch as
|
|
1241
|
-
import { generateUniqueId } from "@elementor/utils";
|
|
2247
|
+
import { __dispatch as dispatch10 } from "@elementor/store";
|
|
2248
|
+
import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
|
|
1242
2249
|
function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
|
|
1243
|
-
const generatedUid = uid ??
|
|
2250
|
+
const generatedUid = uid ?? generateUniqueId3("component");
|
|
1244
2251
|
const componentBase = { uid: generatedUid, name, overridableProps };
|
|
1245
|
-
|
|
2252
|
+
dispatch10(
|
|
1246
2253
|
slice.actions.addUnpublished({
|
|
1247
2254
|
...componentBase,
|
|
1248
2255
|
elements: [element]
|
|
1249
2256
|
})
|
|
1250
2257
|
);
|
|
1251
|
-
|
|
2258
|
+
dispatch10(slice.actions.addCreatedThisSession(generatedUid));
|
|
1252
2259
|
replaceElementWithComponent(element, componentBase);
|
|
1253
2260
|
trackComponentEvent({
|
|
1254
2261
|
action: "created",
|
|
@@ -1261,11 +2268,11 @@ function createUnpublishedComponent(name, element, eventData, overridableProps,
|
|
|
1261
2268
|
}
|
|
1262
2269
|
|
|
1263
2270
|
// src/components/create-component-form/hooks/use-form.ts
|
|
1264
|
-
import { useMemo, useState as
|
|
2271
|
+
import { useMemo as useMemo2, useState as useState5 } from "react";
|
|
1265
2272
|
var useForm = (initialValues) => {
|
|
1266
|
-
const [values, setValues] =
|
|
1267
|
-
const [errors, setErrors] =
|
|
1268
|
-
const isValid =
|
|
2273
|
+
const [values, setValues] = useState5(initialValues);
|
|
2274
|
+
const [errors, setErrors] = useState5({});
|
|
2275
|
+
const isValid = useMemo2(() => {
|
|
1269
2276
|
return !Object.values(errors).some((error) => error);
|
|
1270
2277
|
}, [errors]);
|
|
1271
2278
|
const handleChange = (e, field, validationSchema) => {
|
|
@@ -1311,16 +2318,16 @@ var validateForm = (values, schema) => {
|
|
|
1311
2318
|
|
|
1312
2319
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
1313
2320
|
import { z } from "@elementor/schema";
|
|
1314
|
-
import { __ as
|
|
2321
|
+
import { __ as __16 } from "@wordpress/i18n";
|
|
1315
2322
|
var MIN_NAME_LENGTH = 2;
|
|
1316
2323
|
var MAX_NAME_LENGTH = 50;
|
|
1317
2324
|
var createBaseComponentSchema = (existingNames) => {
|
|
1318
2325
|
return z.object({
|
|
1319
2326
|
componentName: z.string().trim().max(
|
|
1320
2327
|
MAX_NAME_LENGTH,
|
|
1321
|
-
|
|
2328
|
+
__16("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
1322
2329
|
).refine((value) => !existingNames.includes(value), {
|
|
1323
|
-
message:
|
|
2330
|
+
message: __16("Component name already exists", "elementor")
|
|
1324
2331
|
})
|
|
1325
2332
|
});
|
|
1326
2333
|
};
|
|
@@ -1328,9 +2335,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
1328
2335
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
1329
2336
|
return baseSchema.extend({
|
|
1330
2337
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
1331
|
-
message:
|
|
2338
|
+
message: __16("Component name is required.", "elementor")
|
|
1332
2339
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
1333
|
-
message:
|
|
2340
|
+
message: __16("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
1334
2341
|
})
|
|
1335
2342
|
});
|
|
1336
2343
|
};
|
|
@@ -1366,9 +2373,9 @@ function countNestedElements(container) {
|
|
|
1366
2373
|
|
|
1367
2374
|
// src/components/create-component-form/create-component-form.tsx
|
|
1368
2375
|
function CreateComponentForm() {
|
|
1369
|
-
const [element, setElement] =
|
|
1370
|
-
const [anchorPosition, setAnchorPosition] =
|
|
1371
|
-
const [resultNotification, setResultNotification] =
|
|
2376
|
+
const [element, setElement] = useState6(null);
|
|
2377
|
+
const [anchorPosition, setAnchorPosition] = useState6();
|
|
2378
|
+
const [resultNotification, setResultNotification] = useState6(null);
|
|
1372
2379
|
const eventData = useRef3(null);
|
|
1373
2380
|
useEffect2(() => {
|
|
1374
2381
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
@@ -1395,12 +2402,12 @@ function CreateComponentForm() {
|
|
|
1395
2402
|
setResultNotification({
|
|
1396
2403
|
show: true,
|
|
1397
2404
|
// Translators: %1$s: Component name, %2$s: Component UID
|
|
1398
|
-
message:
|
|
2405
|
+
message: __17("Component saved successfully as: %1$s (UID: %2$s)", "elementor").replace("%1$s", values.componentName).replace("%2$s", uid),
|
|
1399
2406
|
type: "success"
|
|
1400
2407
|
});
|
|
1401
2408
|
resetAndClosePopup();
|
|
1402
2409
|
} catch {
|
|
1403
|
-
const errorMessage =
|
|
2410
|
+
const errorMessage = __17("Failed to save component. Please try again.", "elementor");
|
|
1404
2411
|
setResultNotification({
|
|
1405
2412
|
show: true,
|
|
1406
2413
|
message: errorMessage,
|
|
@@ -1419,24 +2426,24 @@ function CreateComponentForm() {
|
|
|
1419
2426
|
...eventData.current
|
|
1420
2427
|
});
|
|
1421
2428
|
};
|
|
1422
|
-
return /* @__PURE__ */
|
|
1423
|
-
|
|
2429
|
+
return /* @__PURE__ */ React17.createElement(ThemeProvider3, null, /* @__PURE__ */ React17.createElement(
|
|
2430
|
+
Popover3,
|
|
1424
2431
|
{
|
|
1425
2432
|
open: element !== null,
|
|
1426
2433
|
onClose: cancelSave,
|
|
1427
2434
|
anchorReference: "anchorPosition",
|
|
1428
2435
|
anchorPosition
|
|
1429
2436
|
},
|
|
1430
|
-
element !== null && /* @__PURE__ */
|
|
1431
|
-
|
|
2437
|
+
element !== null && /* @__PURE__ */ React17.createElement(
|
|
2438
|
+
Form2,
|
|
1432
2439
|
{
|
|
1433
2440
|
initialValues: { componentName: element.elementLabel },
|
|
1434
2441
|
handleSave,
|
|
1435
2442
|
closePopup: cancelSave
|
|
1436
2443
|
}
|
|
1437
2444
|
)
|
|
1438
|
-
), /* @__PURE__ */
|
|
1439
|
-
|
|
2445
|
+
), /* @__PURE__ */ React17.createElement(Snackbar, { open: resultNotification?.show, onClose: () => setResultNotification(null) }, /* @__PURE__ */ React17.createElement(
|
|
2446
|
+
Alert2,
|
|
1440
2447
|
{
|
|
1441
2448
|
onClose: () => setResultNotification(null),
|
|
1442
2449
|
severity: resultNotification?.type,
|
|
@@ -1446,21 +2453,21 @@ function CreateComponentForm() {
|
|
|
1446
2453
|
)));
|
|
1447
2454
|
}
|
|
1448
2455
|
var FONT_SIZE = "tiny";
|
|
1449
|
-
var
|
|
2456
|
+
var Form2 = ({
|
|
1450
2457
|
initialValues,
|
|
1451
2458
|
handleSave,
|
|
1452
2459
|
closePopup
|
|
1453
2460
|
}) => {
|
|
1454
2461
|
const { values, errors, isValid, handleChange, validateForm: validateForm2 } = useForm(initialValues);
|
|
1455
2462
|
const { components } = useComponents();
|
|
1456
|
-
const existingComponentNames =
|
|
2463
|
+
const existingComponentNames = useMemo3(() => {
|
|
1457
2464
|
return components?.map((component) => component.name) ?? [];
|
|
1458
2465
|
}, [components]);
|
|
1459
|
-
const changeValidationSchema =
|
|
2466
|
+
const changeValidationSchema = useMemo3(
|
|
1460
2467
|
() => createBaseComponentSchema(existingComponentNames),
|
|
1461
2468
|
[existingComponentNames]
|
|
1462
2469
|
);
|
|
1463
|
-
const submitValidationSchema =
|
|
2470
|
+
const submitValidationSchema = useMemo3(
|
|
1464
2471
|
() => createSubmitComponentSchema(existingComponentNames),
|
|
1465
2472
|
[existingComponentNames]
|
|
1466
2473
|
);
|
|
@@ -1471,14 +2478,14 @@ var Form = ({
|
|
|
1471
2478
|
}
|
|
1472
2479
|
};
|
|
1473
2480
|
const texts = {
|
|
1474
|
-
heading:
|
|
1475
|
-
name:
|
|
1476
|
-
cancel:
|
|
1477
|
-
create:
|
|
2481
|
+
heading: __17("Save as a component", "elementor"),
|
|
2482
|
+
name: __17("Name", "elementor"),
|
|
2483
|
+
cancel: __17("Cancel", "elementor"),
|
|
2484
|
+
create: __17("Create", "elementor")
|
|
1478
2485
|
};
|
|
1479
2486
|
const nameInputId = "component-name";
|
|
1480
|
-
return /* @__PURE__ */
|
|
1481
|
-
|
|
2487
|
+
return /* @__PURE__ */ React17.createElement(FormElement, { onSubmit: handleSubmit }, /* @__PURE__ */ React17.createElement(Stack11, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React17.createElement(
|
|
2488
|
+
Stack11,
|
|
1482
2489
|
{
|
|
1483
2490
|
direction: "row",
|
|
1484
2491
|
alignItems: "center",
|
|
@@ -1486,10 +2493,10 @@ var Form = ({
|
|
|
1486
2493
|
px: 1.5,
|
|
1487
2494
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
1488
2495
|
},
|
|
1489
|
-
/* @__PURE__ */
|
|
1490
|
-
/* @__PURE__ */
|
|
1491
|
-
), /* @__PURE__ */
|
|
1492
|
-
|
|
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,
|
|
1493
2500
|
{
|
|
1494
2501
|
id: nameInputId,
|
|
1495
2502
|
size: FONT_SIZE,
|
|
@@ -1500,11 +2507,11 @@ var Form = ({
|
|
|
1500
2507
|
error: Boolean(errors.componentName),
|
|
1501
2508
|
helperText: errors.componentName
|
|
1502
2509
|
}
|
|
1503
|
-
))), /* @__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))));
|
|
1504
2511
|
};
|
|
1505
2512
|
|
|
1506
2513
|
// src/components/edit-component/edit-component.tsx
|
|
1507
|
-
import * as
|
|
2514
|
+
import * as React19 from "react";
|
|
1508
2515
|
import { useEffect as useEffect5 } from "react";
|
|
1509
2516
|
import { getV1DocumentsManager as getV1DocumentsManager4 } from "@elementor/editor-documents";
|
|
1510
2517
|
import { __privateListenTo as listenTo, commandEndEvent as commandEndEvent2 } from "@elementor/editor-v1-adapters";
|
|
@@ -1512,25 +2519,25 @@ import { __useSelector as useSelector5 } from "@elementor/store";
|
|
|
1512
2519
|
import { throttle as throttle2 } from "@elementor/utils";
|
|
1513
2520
|
|
|
1514
2521
|
// src/store/actions/update-current-component.ts
|
|
1515
|
-
import { setDocumentModifiedStatus as
|
|
2522
|
+
import { setDocumentModifiedStatus as setDocumentModifiedStatus5 } from "@elementor/editor-documents";
|
|
1516
2523
|
import { __getStore as getStore2 } from "@elementor/store";
|
|
1517
2524
|
function updateCurrentComponent({
|
|
1518
2525
|
path,
|
|
1519
2526
|
currentComponentId
|
|
1520
2527
|
}) {
|
|
1521
|
-
const
|
|
1522
|
-
if (!
|
|
2528
|
+
const dispatch16 = getStore2()?.dispatch;
|
|
2529
|
+
if (!dispatch16) {
|
|
1523
2530
|
return;
|
|
1524
2531
|
}
|
|
1525
|
-
|
|
1526
|
-
|
|
2532
|
+
dispatch16(slice.actions.setPath(path));
|
|
2533
|
+
dispatch16(slice.actions.setCurrentComponentId(currentComponentId));
|
|
1527
2534
|
}
|
|
1528
2535
|
|
|
1529
2536
|
// src/components/edit-component/component-modal.tsx
|
|
1530
|
-
import * as
|
|
2537
|
+
import * as React18 from "react";
|
|
1531
2538
|
import { useEffect as useEffect4 } from "react";
|
|
1532
2539
|
import { createPortal } from "react-dom";
|
|
1533
|
-
import { __ as
|
|
2540
|
+
import { __ as __18 } from "@wordpress/i18n";
|
|
1534
2541
|
|
|
1535
2542
|
// src/hooks/use-canvas-document.ts
|
|
1536
2543
|
import { getCanvasIframeDocument } from "@elementor/editor-canvas";
|
|
@@ -1540,10 +2547,10 @@ function useCanvasDocument() {
|
|
|
1540
2547
|
}
|
|
1541
2548
|
|
|
1542
2549
|
// src/hooks/use-element-rect.ts
|
|
1543
|
-
import { useEffect as useEffect3, useState as
|
|
2550
|
+
import { useEffect as useEffect3, useState as useState7 } from "react";
|
|
1544
2551
|
import { throttle } from "@elementor/utils";
|
|
1545
2552
|
function useElementRect(element) {
|
|
1546
|
-
const [rect, setRect] =
|
|
2553
|
+
const [rect, setRect] = useState7(new DOMRect(0, 0, 0, 0));
|
|
1547
2554
|
const onChange = throttle(
|
|
1548
2555
|
() => {
|
|
1549
2556
|
setRect(element?.getBoundingClientRect() ?? new DOMRect(0, 0, 0, 0));
|
|
@@ -1620,7 +2627,7 @@ function ComponentModal({ element, onClose }) {
|
|
|
1620
2627
|
return null;
|
|
1621
2628
|
}
|
|
1622
2629
|
return createPortal(
|
|
1623
|
-
/* @__PURE__ */
|
|
2630
|
+
/* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(BlockEditPage, null), /* @__PURE__ */ React18.createElement(Backdrop, { canvas: canvasDocument, element, onClose })),
|
|
1624
2631
|
canvasDocument.body
|
|
1625
2632
|
);
|
|
1626
2633
|
}
|
|
@@ -1644,7 +2651,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
1644
2651
|
onClose();
|
|
1645
2652
|
}
|
|
1646
2653
|
};
|
|
1647
|
-
return /* @__PURE__ */
|
|
2654
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1648
2655
|
"div",
|
|
1649
2656
|
{
|
|
1650
2657
|
style: backdropStyle,
|
|
@@ -1652,7 +2659,7 @@ function Backdrop({ canvas, element, onClose }) {
|
|
|
1652
2659
|
onKeyDown: handleKeyDown,
|
|
1653
2660
|
role: "button",
|
|
1654
2661
|
tabIndex: 0,
|
|
1655
|
-
"aria-label":
|
|
2662
|
+
"aria-label": __18("Exit component editing mode", "elementor")
|
|
1656
2663
|
}
|
|
1657
2664
|
);
|
|
1658
2665
|
}
|
|
@@ -1702,7 +2709,7 @@ function BlockEditPage() {
|
|
|
1702
2709
|
}
|
|
1703
2710
|
}
|
|
1704
2711
|
`;
|
|
1705
|
-
return /* @__PURE__ */
|
|
2712
|
+
return /* @__PURE__ */ React18.createElement("style", { "data-e-style-id": "e-block-v3-document-handles-styles" }, blockV3DocumentHandlesStyles);
|
|
1706
2713
|
}
|
|
1707
2714
|
|
|
1708
2715
|
// src/components/edit-component/edit-component.tsx
|
|
@@ -1715,7 +2722,7 @@ function EditComponent() {
|
|
|
1715
2722
|
if (!elementDom) {
|
|
1716
2723
|
return null;
|
|
1717
2724
|
}
|
|
1718
|
-
return /* @__PURE__ */
|
|
2725
|
+
return /* @__PURE__ */ React19.createElement(ComponentModal, { element: elementDom, onClose });
|
|
1719
2726
|
}
|
|
1720
2727
|
function useHandleDocumentSwitches() {
|
|
1721
2728
|
const documentsManager = getV1DocumentsManager4();
|
|
@@ -1755,12 +2762,12 @@ function getUpdatedComponentPath(path, nextDocument) {
|
|
|
1755
2762
|
}
|
|
1756
2763
|
];
|
|
1757
2764
|
}
|
|
1758
|
-
function getComponentDOMElement(
|
|
1759
|
-
if (!
|
|
2765
|
+
function getComponentDOMElement(id2) {
|
|
2766
|
+
if (!id2) {
|
|
1760
2767
|
return null;
|
|
1761
2768
|
}
|
|
1762
2769
|
const documentsManager = getV1DocumentsManager4();
|
|
1763
|
-
const currentComponent = documentsManager.get(
|
|
2770
|
+
const currentComponent = documentsManager.get(id2);
|
|
1764
2771
|
const widget = currentComponent?.container;
|
|
1765
2772
|
const container = widget?.view?.el?.children?.[0] ?? null;
|
|
1766
2773
|
const elementDom = container?.children[0];
|
|
@@ -1768,33 +2775,33 @@ function getComponentDOMElement(id) {
|
|
|
1768
2775
|
}
|
|
1769
2776
|
|
|
1770
2777
|
// src/components/in-edit-mode.tsx
|
|
1771
|
-
import * as
|
|
2778
|
+
import * as React20 from "react";
|
|
1772
2779
|
import { closeDialog, openDialog } from "@elementor/editor-ui";
|
|
1773
2780
|
import { InfoCircleFilledIcon } from "@elementor/icons";
|
|
1774
|
-
import { Box as
|
|
1775
|
-
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";
|
|
1776
2783
|
var openEditModeDialog = (lockedBy) => {
|
|
1777
2784
|
openDialog({
|
|
1778
|
-
component: /* @__PURE__ */
|
|
2785
|
+
component: /* @__PURE__ */ React20.createElement(EditModeDialog, { lockedBy })
|
|
1779
2786
|
});
|
|
1780
2787
|
};
|
|
1781
2788
|
var EditModeDialog = ({ lockedBy }) => {
|
|
1782
|
-
const content =
|
|
1783
|
-
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(
|
|
1784
2791
|
"You can wait for them to finish or reach out to coordinate your changes together.",
|
|
1785
2792
|
"elementor"
|
|
1786
|
-
)), /* @__PURE__ */
|
|
2793
|
+
)), /* @__PURE__ */ React20.createElement(DialogActions, null, /* @__PURE__ */ React20.createElement(Button4, { color: "secondary", variant: "contained", onClick: closeDialog }, __19("Close", "elementor"))))));
|
|
1787
2794
|
};
|
|
1788
2795
|
|
|
1789
2796
|
// src/components/instance-editing-panel/instance-editing-panel.tsx
|
|
1790
|
-
import * as
|
|
2797
|
+
import * as React23 from "react";
|
|
1791
2798
|
import { useElement } from "@elementor/editor-editing-panel";
|
|
1792
|
-
import { useElementSetting, useSelectedElement } from "@elementor/editor-elements";
|
|
1793
|
-
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";
|
|
1794
2801
|
import { ComponentsIcon as ComponentsIcon3, PencilIcon as PencilIcon2 } from "@elementor/icons";
|
|
1795
|
-
import { __getState as
|
|
1796
|
-
import { IconButton as
|
|
1797
|
-
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";
|
|
1798
2805
|
|
|
1799
2806
|
// src/prop-types/component-instance-prop-type.ts
|
|
1800
2807
|
import { createPropUtils as createPropUtils3, numberPropTypeUtil } from "@elementor/editor-props";
|
|
@@ -1835,13 +2842,13 @@ var componentInstancePropTypeUtil = createPropUtils3(
|
|
|
1835
2842
|
);
|
|
1836
2843
|
|
|
1837
2844
|
// src/components/instance-editing-panel/empty-state.tsx
|
|
1838
|
-
import * as
|
|
1839
|
-
import { ComponentPropListIcon as
|
|
1840
|
-
import { Button as
|
|
1841
|
-
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";
|
|
1842
2849
|
var EmptyState2 = ({ onEditComponent }) => {
|
|
1843
|
-
return /* @__PURE__ */
|
|
1844
|
-
|
|
2850
|
+
return /* @__PURE__ */ React21.createElement(
|
|
2851
|
+
Stack13,
|
|
1845
2852
|
{
|
|
1846
2853
|
alignItems: "center",
|
|
1847
2854
|
justifyContent: "start",
|
|
@@ -1850,32 +2857,32 @@ var EmptyState2 = ({ onEditComponent }) => {
|
|
|
1850
2857
|
sx: { p: 2.5, pt: 8, pb: 5.5, mt: 1 },
|
|
1851
2858
|
gap: 1.5
|
|
1852
2859
|
},
|
|
1853
|
-
/* @__PURE__ */
|
|
1854
|
-
/* @__PURE__ */
|
|
1855
|
-
/* @__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(
|
|
1856
2863
|
"Edit the component to add properties, manage them or update the design across all instances.",
|
|
1857
2864
|
"elementor"
|
|
1858
2865
|
)),
|
|
1859
|
-
/* @__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"))
|
|
1860
2867
|
);
|
|
1861
2868
|
};
|
|
1862
2869
|
|
|
1863
2870
|
// src/components/instance-editing-panel/override-props-group.tsx
|
|
1864
|
-
import * as
|
|
2871
|
+
import * as React22 from "react";
|
|
1865
2872
|
import { useId } from "react";
|
|
1866
2873
|
import { useStateByElement } from "@elementor/editor-editing-panel";
|
|
1867
2874
|
import { CollapseIcon } from "@elementor/editor-ui";
|
|
1868
|
-
import { Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as
|
|
2875
|
+
import { Collapse, ListItemButton as ListItemButton3, ListItemText, Stack as Stack14 } from "@elementor/ui";
|
|
1869
2876
|
function OverridePropsGroup({ group, props }) {
|
|
1870
2877
|
const [isOpen, setIsOpen] = useStateByElement(group.id, true);
|
|
1871
2878
|
const handleClick = () => {
|
|
1872
2879
|
setIsOpen(!isOpen);
|
|
1873
2880
|
};
|
|
1874
|
-
const
|
|
1875
|
-
const labelId = `label-${
|
|
1876
|
-
const contentId = `content-${
|
|
2881
|
+
const id2 = useId();
|
|
2882
|
+
const labelId = `label-${id2}`;
|
|
2883
|
+
const contentId = `content-${id2}`;
|
|
1877
2884
|
const title = group.label;
|
|
1878
|
-
return /* @__PURE__ */
|
|
2885
|
+
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement(
|
|
1879
2886
|
ListItemButton3,
|
|
1880
2887
|
{
|
|
1881
2888
|
id: labelId,
|
|
@@ -1885,7 +2892,7 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1885
2892
|
p: 0,
|
|
1886
2893
|
sx: { "&:hover": { backgroundColor: "transparent" } }
|
|
1887
2894
|
},
|
|
1888
|
-
/* @__PURE__ */
|
|
2895
|
+
/* @__PURE__ */ React22.createElement(Stack14, { direction: "row", alignItems: "center", justifyItems: "start", flexGrow: 1, gap: 0.5 }, /* @__PURE__ */ React22.createElement(
|
|
1889
2896
|
ListItemText,
|
|
1890
2897
|
{
|
|
1891
2898
|
secondary: title,
|
|
@@ -1893,10 +2900,10 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1893
2900
|
sx: { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 }
|
|
1894
2901
|
}
|
|
1895
2902
|
)),
|
|
1896
|
-
/* @__PURE__ */
|
|
1897
|
-
), /* @__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) => (
|
|
1898
2905
|
// TODO: Render actual controls
|
|
1899
|
-
/* @__PURE__ */
|
|
2906
|
+
/* @__PURE__ */ React22.createElement("pre", { key: propId }, JSON.stringify(props[propId], null, 2))
|
|
1900
2907
|
)))));
|
|
1901
2908
|
}
|
|
1902
2909
|
|
|
@@ -1904,24 +2911,24 @@ function OverridePropsGroup({ group, props }) {
|
|
|
1904
2911
|
function InstanceEditingPanel() {
|
|
1905
2912
|
const { element } = useElement();
|
|
1906
2913
|
const settings = useElementSetting(element.id, "component_instance");
|
|
1907
|
-
const componentId =
|
|
1908
|
-
const component = componentId ? selectComponent(
|
|
1909
|
-
const overridableProps = componentId ? selectOverridableProps(
|
|
1910
|
-
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;
|
|
1911
2918
|
if (!componentId || !overridableProps || !component) {
|
|
1912
2919
|
return null;
|
|
1913
2920
|
}
|
|
1914
|
-
const panelTitle =
|
|
2921
|
+
const panelTitle = __21("Edit %s", "elementor").replace("%s", component.name);
|
|
1915
2922
|
const handleEditComponent = () => switchToComponent(componentId, componentInstanceId);
|
|
1916
2923
|
const groups = overridableProps.groups.order.map(
|
|
1917
2924
|
(groupId) => overridableProps.groups.items[groupId] ? overridableProps.groups.items[groupId] : null
|
|
1918
2925
|
).filter(Boolean);
|
|
1919
2926
|
const isEmpty = groups.length === 0 || Object.keys(overridableProps.props).length === 0;
|
|
1920
|
-
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 })))));
|
|
1921
2928
|
}
|
|
1922
2929
|
|
|
1923
2930
|
// src/components/overridable-props/overridable-prop-control.tsx
|
|
1924
|
-
import * as
|
|
2931
|
+
import * as React25 from "react";
|
|
1925
2932
|
import { ControlReplacementsProvider, PropKeyProvider, PropProvider, useBoundProp } from "@elementor/editor-controls";
|
|
1926
2933
|
import { createTopLevelObjectType, useElement as useElement2 } from "@elementor/editor-editing-panel";
|
|
1927
2934
|
|
|
@@ -1940,18 +2947,18 @@ var componentOverridablePropTypeUtil = createPropUtils4(
|
|
|
1940
2947
|
);
|
|
1941
2948
|
|
|
1942
2949
|
// src/provider/overridable-prop-context.tsx
|
|
1943
|
-
import * as
|
|
2950
|
+
import * as React24 from "react";
|
|
1944
2951
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1945
2952
|
var OverridablePropContext = createContext2(null);
|
|
1946
2953
|
function OverridablePropProvider({ children, ...props }) {
|
|
1947
|
-
return /* @__PURE__ */
|
|
2954
|
+
return /* @__PURE__ */ React24.createElement(OverridablePropContext.Provider, { value: props }, children);
|
|
1948
2955
|
}
|
|
1949
2956
|
var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
|
|
1950
2957
|
|
|
1951
2958
|
// src/store/actions/update-overridable-prop-origin-value.ts
|
|
1952
|
-
import { __dispatch as
|
|
2959
|
+
import { __dispatch as dispatch11, __getState as getState13 } from "@elementor/store";
|
|
1953
2960
|
function updateOverridablePropOriginValue(componentId, propValue) {
|
|
1954
|
-
const overridableProps = selectOverridableProps(
|
|
2961
|
+
const overridableProps = selectOverridableProps(getState13(), componentId);
|
|
1955
2962
|
if (!overridableProps) {
|
|
1956
2963
|
return;
|
|
1957
2964
|
}
|
|
@@ -1969,7 +2976,7 @@ function updateOverridablePropOriginValue(componentId, propValue) {
|
|
|
1969
2976
|
}
|
|
1970
2977
|
}
|
|
1971
2978
|
};
|
|
1972
|
-
|
|
2979
|
+
dispatch11(
|
|
1973
2980
|
slice.actions.setOverridableProps({
|
|
1974
2981
|
componentId,
|
|
1975
2982
|
overridableProps: newOverridableProps
|
|
@@ -2005,7 +3012,7 @@ function OverridablePropControl({
|
|
|
2005
3012
|
}
|
|
2006
3013
|
});
|
|
2007
3014
|
const objectPlaceholder = placeholder ? { [bind]: placeholder } : void 0;
|
|
2008
|
-
return /* @__PURE__ */
|
|
3015
|
+
return /* @__PURE__ */ React25.createElement(OverridablePropProvider, { value }, /* @__PURE__ */ React25.createElement(
|
|
2009
3016
|
PropProvider,
|
|
2010
3017
|
{
|
|
2011
3018
|
...propContext,
|
|
@@ -2014,23 +3021,22 @@ function OverridablePropControl({
|
|
|
2014
3021
|
value: { [bind]: value.origin_value },
|
|
2015
3022
|
placeholder: objectPlaceholder
|
|
2016
3023
|
},
|
|
2017
|
-
/* @__PURE__ */
|
|
3024
|
+
/* @__PURE__ */ React25.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React25.createElement(ControlReplacementsProvider, { replacements: [] }, /* @__PURE__ */ React25.createElement(OriginalControl, { ...props })))
|
|
2018
3025
|
));
|
|
2019
3026
|
}
|
|
2020
3027
|
|
|
2021
3028
|
// src/components/overridable-props/overridable-prop-indicator.tsx
|
|
2022
|
-
import * as
|
|
3029
|
+
import * as React27 from "react";
|
|
2023
3030
|
import { useBoundProp as useBoundProp2 } from "@elementor/editor-controls";
|
|
2024
3031
|
import { useElement as useElement3 } from "@elementor/editor-editing-panel";
|
|
2025
|
-
import { getWidgetsCache } from "@elementor/editor-elements";
|
|
2026
|
-
import { __getState as
|
|
2027
|
-
import { bindPopover, bindTrigger as
|
|
2028
|
-
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";
|
|
2029
3036
|
|
|
2030
3037
|
// src/store/actions/set-overridable-prop.ts
|
|
2031
|
-
import { __dispatch as
|
|
2032
|
-
import { generateUniqueId as
|
|
2033
|
-
import { __ as __14 } from "@wordpress/i18n";
|
|
3038
|
+
import { __dispatch as dispatch12, __getState as getState14 } from "@elementor/store";
|
|
3039
|
+
import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
|
|
2034
3040
|
function setOverridableProp({
|
|
2035
3041
|
componentId,
|
|
2036
3042
|
overrideKey,
|
|
@@ -2042,7 +3048,7 @@ function setOverridableProp({
|
|
|
2042
3048
|
widgetType,
|
|
2043
3049
|
originValue
|
|
2044
3050
|
}) {
|
|
2045
|
-
const overridableProps = selectOverridableProps(
|
|
3051
|
+
const overridableProps = selectOverridableProps(getState14(), componentId);
|
|
2046
3052
|
if (!overridableProps) {
|
|
2047
3053
|
return;
|
|
2048
3054
|
}
|
|
@@ -2050,13 +3056,12 @@ function setOverridableProp({
|
|
|
2050
3056
|
const duplicatedTargetProps = Object.values(overridableProps.props).filter(
|
|
2051
3057
|
(prop) => prop.elementId === elementId && prop.propKey === propKey && prop !== existingOverridableProp
|
|
2052
3058
|
);
|
|
2053
|
-
const {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
groupId || existingOverridableProp?.groupId
|
|
3059
|
+
const { groups: groupsAfterResolve, groupId: currentGroupId } = resolveOrCreateGroup(
|
|
3060
|
+
overridableProps.groups,
|
|
3061
|
+
groupId || existingOverridableProp?.groupId || void 0
|
|
2057
3062
|
);
|
|
2058
3063
|
const overridableProp = {
|
|
2059
|
-
overrideKey: existingOverridableProp?.overrideKey ||
|
|
3064
|
+
overrideKey: existingOverridableProp?.overrideKey || generateUniqueId4("prop"),
|
|
2060
3065
|
label,
|
|
2061
3066
|
elementId,
|
|
2062
3067
|
propKey,
|
|
@@ -2065,31 +3070,21 @@ function setOverridableProp({
|
|
|
2065
3070
|
originValue,
|
|
2066
3071
|
groupId: currentGroupId
|
|
2067
3072
|
};
|
|
2068
|
-
const
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
});
|
|
3073
|
+
const stateAfterRemovingDuplicates = removePropsFromState(
|
|
3074
|
+
{ ...overridableProps, groups: groupsAfterResolve },
|
|
3075
|
+
duplicatedTargetProps
|
|
3076
|
+
);
|
|
2073
3077
|
const props = {
|
|
2074
|
-
...
|
|
3078
|
+
...stateAfterRemovingDuplicates.props,
|
|
2075
3079
|
[overridableProp.overrideKey]: overridableProp
|
|
2076
3080
|
};
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
...groupsWithoutDuplicates.items,
|
|
2080
|
-
[currentGroupId]: getGroupWithProp(groupsWithoutDuplicates, currentGroupId, overridableProp)
|
|
2081
|
-
},
|
|
2082
|
-
order: groupsWithoutDuplicates.order.includes(currentGroupId) ? groupsWithoutDuplicates.order : [...groupsWithoutDuplicates.order, currentGroupId]
|
|
2083
|
-
};
|
|
3081
|
+
let groups = addPropToGroup(stateAfterRemovingDuplicates.groups, currentGroupId, overridableProp.overrideKey);
|
|
3082
|
+
groups = ensureGroupInOrder(groups, currentGroupId);
|
|
2084
3083
|
const isChangingGroups = existingOverridableProp && existingOverridableProp.groupId !== currentGroupId;
|
|
2085
3084
|
if (isChangingGroups) {
|
|
2086
|
-
groups
|
|
2087
|
-
groupsWithoutDuplicates,
|
|
2088
|
-
existingOverridableProp.groupId,
|
|
2089
|
-
overridableProp
|
|
2090
|
-
);
|
|
3085
|
+
groups = removePropFromGroup(groups, existingOverridableProp.groupId, overridableProp.overrideKey);
|
|
2091
3086
|
}
|
|
2092
|
-
|
|
3087
|
+
dispatch12(
|
|
2093
3088
|
slice.actions.setOverridableProps({
|
|
2094
3089
|
componentId,
|
|
2095
3090
|
overridableProps: {
|
|
@@ -2100,83 +3095,15 @@ function setOverridableProp({
|
|
|
2100
3095
|
);
|
|
2101
3096
|
return overridableProp;
|
|
2102
3097
|
}
|
|
2103
|
-
function getUpdatedGroups(groups, groupId) {
|
|
2104
|
-
if (!groupId) {
|
|
2105
|
-
if (groups.order.length > 0) {
|
|
2106
|
-
return { groups, currentGroupId: groups.order[0] };
|
|
2107
|
-
}
|
|
2108
|
-
return addNewGroup(groups);
|
|
2109
|
-
}
|
|
2110
|
-
if (!groups.items[groupId]) {
|
|
2111
|
-
return addNewGroup(groups, groupId);
|
|
2112
|
-
}
|
|
2113
|
-
return { groups, currentGroupId: groupId };
|
|
2114
|
-
}
|
|
2115
|
-
function addNewGroup(groups, groupId) {
|
|
2116
|
-
const currentGroupId = groupId || generateUniqueId2("group");
|
|
2117
|
-
const updatedGroups = {
|
|
2118
|
-
...groups,
|
|
2119
|
-
items: {
|
|
2120
|
-
...groups.items,
|
|
2121
|
-
[currentGroupId]: {
|
|
2122
|
-
id: currentGroupId,
|
|
2123
|
-
label: __14("Default", "elementor"),
|
|
2124
|
-
props: []
|
|
2125
|
-
}
|
|
2126
|
-
},
|
|
2127
|
-
order: [...groups.order, currentGroupId]
|
|
2128
|
-
};
|
|
2129
|
-
return { groups: updatedGroups, currentGroupId };
|
|
2130
|
-
}
|
|
2131
|
-
function getGroupWithProp(groups, groupId, overridableProp) {
|
|
2132
|
-
const group = { ...groups.items[groupId] };
|
|
2133
|
-
if (!group.props.includes(overridableProp.overrideKey)) {
|
|
2134
|
-
group.props = [...group.props, overridableProp.overrideKey];
|
|
2135
|
-
}
|
|
2136
|
-
return group;
|
|
2137
|
-
}
|
|
2138
|
-
function getGroupWithoutProp(groups, groupId, overridableProp) {
|
|
2139
|
-
const group = { ...groups.items[groupId] };
|
|
2140
|
-
if (group) {
|
|
2141
|
-
group.props = group.props.filter((key) => key !== overridableProp.overrideKey);
|
|
2142
|
-
}
|
|
2143
|
-
return group;
|
|
2144
|
-
}
|
|
2145
|
-
function removeProps({
|
|
2146
|
-
props,
|
|
2147
|
-
groups,
|
|
2148
|
-
propsToRemove
|
|
2149
|
-
}) {
|
|
2150
|
-
const allProps = Object.fromEntries(
|
|
2151
|
-
Object.entries(props).filter(([, prop]) => !propsToRemove.includes(prop))
|
|
2152
|
-
);
|
|
2153
|
-
const overrideKeysToRemove = propsToRemove.map((prop) => prop.overrideKey);
|
|
2154
|
-
const allGroupItems = Object.fromEntries(
|
|
2155
|
-
Object.entries(groups.items).map(([groupId, group]) => [
|
|
2156
|
-
groupId,
|
|
2157
|
-
{
|
|
2158
|
-
...group,
|
|
2159
|
-
props: group.props.filter((prop) => !overrideKeysToRemove.includes(prop))
|
|
2160
|
-
}
|
|
2161
|
-
])
|
|
2162
|
-
);
|
|
2163
|
-
return {
|
|
2164
|
-
props: allProps,
|
|
2165
|
-
groups: {
|
|
2166
|
-
items: allGroupItems,
|
|
2167
|
-
order: groups.order.filter((groupId) => !overrideKeysToRemove.includes(groupId))
|
|
2168
|
-
}
|
|
2169
|
-
};
|
|
2170
|
-
}
|
|
2171
3098
|
|
|
2172
3099
|
// src/components/overridable-props/indicator.tsx
|
|
2173
|
-
import * as
|
|
3100
|
+
import * as React26 from "react";
|
|
2174
3101
|
import { forwardRef as forwardRef2 } from "react";
|
|
2175
3102
|
import { CheckIcon, PlusIcon } from "@elementor/icons";
|
|
2176
|
-
import { Box as
|
|
2177
|
-
import { __ as
|
|
2178
|
-
var
|
|
2179
|
-
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)`
|
|
2180
3107
|
pointer-events: none;
|
|
2181
3108
|
opacity: 0;
|
|
2182
3109
|
transition: opacity 0.2s ease-in-out;
|
|
@@ -2193,7 +3120,7 @@ var IconContainer = styled2(Box9)`
|
|
|
2193
3120
|
stroke-width: 2px;
|
|
2194
3121
|
}
|
|
2195
3122
|
`;
|
|
2196
|
-
var Content =
|
|
3123
|
+
var Content = styled3(Box13)`
|
|
2197
3124
|
position: relative;
|
|
2198
3125
|
display: flex;
|
|
2199
3126
|
align-items: center;
|
|
@@ -2230,79 +3157,22 @@ var Content = styled2(Box9)`
|
|
|
2230
3157
|
}
|
|
2231
3158
|
}
|
|
2232
3159
|
`;
|
|
2233
|
-
var Indicator = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */
|
|
3160
|
+
var Indicator = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @__PURE__ */ React26.createElement(Content, { ref, ...props, className: isOpen || isOverridable ? "enlarged" : "" }, /* @__PURE__ */ React26.createElement(
|
|
2234
3161
|
IconContainer,
|
|
2235
3162
|
{
|
|
2236
3163
|
className: "icon",
|
|
2237
|
-
"aria-label": isOverridable ?
|
|
3164
|
+
"aria-label": isOverridable ? __22("Overridable property", "elementor") : __22("Make prop overridable", "elementor")
|
|
2238
3165
|
},
|
|
2239
|
-
isOverridable ? /* @__PURE__ */
|
|
3166
|
+
isOverridable ? /* @__PURE__ */ React26.createElement(CheckIcon, { fontSize: SIZE2 }) : /* @__PURE__ */ React26.createElement(PlusIcon, { fontSize: SIZE2 })
|
|
2240
3167
|
)));
|
|
2241
3168
|
|
|
2242
|
-
// src/components/overridable-props/overridable-prop-form.tsx
|
|
2243
|
-
import * as React20 from "react";
|
|
2244
|
-
import { useState as useState5 } from "react";
|
|
2245
|
-
import { Form as Form2, MenuListItem as MenuListItem2 } from "@elementor/editor-ui";
|
|
2246
|
-
import { Button as Button5, FormLabel as FormLabel2, Grid as Grid2, Select, Stack as Stack12, TextField as TextField3, Typography as Typography8 } from "@elementor/ui";
|
|
2247
|
-
import { __ as __16 } from "@wordpress/i18n";
|
|
2248
|
-
var SIZE2 = "tiny";
|
|
2249
|
-
var DEFAULT_GROUP = { value: null, label: __16("Default", "elementor") };
|
|
2250
|
-
function OverridablePropForm({ onSubmit, groups, currentValue }) {
|
|
2251
|
-
const [propLabel, setPropLabel] = useState5(currentValue?.label ?? null);
|
|
2252
|
-
const [group, setGroup] = useState5(currentValue?.groupId ?? groups?.[0]?.value ?? null);
|
|
2253
|
-
const name = __16("Name", "elementor");
|
|
2254
|
-
const groupName = __16("Group Name", "elementor");
|
|
2255
|
-
const isCreate = currentValue === void 0;
|
|
2256
|
-
const title = isCreate ? __16("Create new property", "elementor") : __16("Update property", "elementor");
|
|
2257
|
-
const ctaLabel = isCreate ? __16("Create", "elementor") : __16("Update", "elementor");
|
|
2258
|
-
return /* @__PURE__ */ React20.createElement(Form2, { onSubmit: () => onSubmit({ label: propLabel ?? "", group }) }, /* @__PURE__ */ React20.createElement(Stack12, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React20.createElement(
|
|
2259
|
-
Stack12,
|
|
2260
|
-
{
|
|
2261
|
-
direction: "row",
|
|
2262
|
-
alignItems: "center",
|
|
2263
|
-
py: 1,
|
|
2264
|
-
px: 1.5,
|
|
2265
|
-
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%", mb: 1.5 }
|
|
2266
|
-
},
|
|
2267
|
-
/* @__PURE__ */ React20.createElement(Typography8, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, title)
|
|
2268
|
-
), /* @__PURE__ */ React20.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React20.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React20.createElement(FormLabel2, { size: "tiny" }, name)), /* @__PURE__ */ React20.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React20.createElement(
|
|
2269
|
-
TextField3,
|
|
2270
|
-
{
|
|
2271
|
-
name,
|
|
2272
|
-
size: SIZE2,
|
|
2273
|
-
fullWidth: true,
|
|
2274
|
-
placeholder: __16("Enter value", "elementor"),
|
|
2275
|
-
value: propLabel ?? "",
|
|
2276
|
-
onChange: (e) => setPropLabel(e.target.value)
|
|
2277
|
-
}
|
|
2278
|
-
))), /* @__PURE__ */ React20.createElement(Grid2, { container: true, gap: 0.75, alignItems: "start", px: 1.5, mb: 1.5 }, /* @__PURE__ */ React20.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React20.createElement(FormLabel2, { size: "tiny" }, groupName)), /* @__PURE__ */ React20.createElement(Grid2, { item: true, xs: 12 }, /* @__PURE__ */ React20.createElement(
|
|
2279
|
-
Select,
|
|
2280
|
-
{
|
|
2281
|
-
name: groupName,
|
|
2282
|
-
size: SIZE2,
|
|
2283
|
-
fullWidth: true,
|
|
2284
|
-
value: group ?? null,
|
|
2285
|
-
onChange: setGroup,
|
|
2286
|
-
displayEmpty: true,
|
|
2287
|
-
renderValue: (selectedValue) => {
|
|
2288
|
-
if (!selectedValue || selectedValue === "") {
|
|
2289
|
-
const [firstGroup = DEFAULT_GROUP] = groups ?? [];
|
|
2290
|
-
return firstGroup.label;
|
|
2291
|
-
}
|
|
2292
|
-
return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
|
|
2293
|
-
}
|
|
2294
|
-
},
|
|
2295
|
-
(groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React20.createElement(MenuListItem2, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
|
|
2296
|
-
))), /* @__PURE__ */ React20.createElement(Stack12, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React20.createElement(Button5, { type: "submit", disabled: !propLabel, variant: "contained", color: "primary", size: "small" }, ctaLabel))));
|
|
2297
|
-
}
|
|
2298
|
-
|
|
2299
3169
|
// src/components/overridable-props/utils/get-overridable-prop.ts
|
|
2300
|
-
import { __getState as
|
|
3170
|
+
import { __getState as getState15 } from "@elementor/store";
|
|
2301
3171
|
function getOverridableProp({
|
|
2302
3172
|
componentId,
|
|
2303
3173
|
overrideKey
|
|
2304
3174
|
}) {
|
|
2305
|
-
const overridableProps = selectOverridableProps(
|
|
3175
|
+
const overridableProps = selectOverridableProps(getState15(), componentId);
|
|
2306
3176
|
if (!overridableProps) {
|
|
2307
3177
|
return void 0;
|
|
2308
3178
|
}
|
|
@@ -2317,8 +3187,8 @@ function OverridablePropIndicator() {
|
|
|
2317
3187
|
if (!isPropAllowed(bind) || !componentId) {
|
|
2318
3188
|
return null;
|
|
2319
3189
|
}
|
|
2320
|
-
const overridableProps = selectOverridableProps(
|
|
2321
|
-
return /* @__PURE__ */
|
|
3190
|
+
const overridableProps = selectOverridableProps(getState16(), componentId);
|
|
3191
|
+
return /* @__PURE__ */ React27.createElement(Content2, { componentId, overridableProps });
|
|
2322
3192
|
}
|
|
2323
3193
|
function Content2({ componentId, overridableProps }) {
|
|
2324
3194
|
const {
|
|
@@ -2331,12 +3201,12 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2331
3201
|
componentOverridablePropTypeUtil
|
|
2332
3202
|
);
|
|
2333
3203
|
const overridableValue = boundPropOverridableValue ?? contextOverridableValue;
|
|
2334
|
-
const popupState =
|
|
3204
|
+
const popupState = usePopupState4({
|
|
2335
3205
|
variant: "popover"
|
|
2336
3206
|
});
|
|
2337
|
-
const triggerProps =
|
|
2338
|
-
const popoverProps =
|
|
2339
|
-
const { elType } =
|
|
3207
|
+
const triggerProps = bindTrigger4(popupState);
|
|
3208
|
+
const popoverProps = bindPopover2(popupState);
|
|
3209
|
+
const { elType } = getWidgetsCache2()?.[elementType.key] ?? { elType: "widget" };
|
|
2340
3210
|
const handleSubmit = ({ label, group }) => {
|
|
2341
3211
|
const originValue = !overridableValue ? value ?? propType.default : overridableValue?.origin_value ?? {};
|
|
2342
3212
|
const overridablePropConfig = setOverridableProp({
|
|
@@ -2359,8 +3229,8 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2359
3229
|
popupState.close();
|
|
2360
3230
|
};
|
|
2361
3231
|
const overridableConfig = overridableValue ? getOverridableProp({ componentId, overrideKey: overridableValue.override_key }) : void 0;
|
|
2362
|
-
return /* @__PURE__ */
|
|
2363
|
-
|
|
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,
|
|
2364
3234
|
{
|
|
2365
3235
|
disableScrollLock: true,
|
|
2366
3236
|
anchorOrigin: {
|
|
@@ -2376,7 +3246,7 @@ function Content2({ componentId, overridableProps }) {
|
|
|
2376
3246
|
},
|
|
2377
3247
|
...popoverProps
|
|
2378
3248
|
},
|
|
2379
|
-
/* @__PURE__ */
|
|
3249
|
+
/* @__PURE__ */ React27.createElement(
|
|
2380
3250
|
OverridablePropForm,
|
|
2381
3251
|
{
|
|
2382
3252
|
onSubmit: handleSubmit,
|
|
@@ -2398,11 +3268,11 @@ import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
|
|
|
2398
3268
|
|
|
2399
3269
|
// src/mcp/save-as-component-tool.ts
|
|
2400
3270
|
import { DOCUMENT_STRUCTURE_URI, WIDGET_SCHEMA_URI } from "@elementor/editor-canvas";
|
|
2401
|
-
import { getContainer as
|
|
3271
|
+
import { getContainer as getContainer3, getElementType, getWidgetsCache as getWidgetsCache3 } from "@elementor/editor-elements";
|
|
2402
3272
|
import { getMCPByDomain, toolPrompts } from "@elementor/editor-mcp";
|
|
2403
3273
|
import { AxiosError } from "@elementor/http-client";
|
|
2404
3274
|
import { z as z6 } from "@elementor/schema";
|
|
2405
|
-
import { generateUniqueId as
|
|
3275
|
+
import { generateUniqueId as generateUniqueId5 } from "@elementor/utils";
|
|
2406
3276
|
var InputSchema = {
|
|
2407
3277
|
element_id: z6.string().describe(
|
|
2408
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.'
|
|
@@ -2425,7 +3295,7 @@ var OutputSchema = {
|
|
|
2425
3295
|
message: z6.string().optional().describe("Additional information about the operation result"),
|
|
2426
3296
|
component_uid: z6.string().optional().describe("The unique identifier of the newly created component (only present on success)")
|
|
2427
3297
|
};
|
|
2428
|
-
var
|
|
3298
|
+
var ERROR_MESSAGES2 = {
|
|
2429
3299
|
ELEMENT_NOT_FOUND: "Element not found. Use 'list-elements' to get valid element IDs.",
|
|
2430
3300
|
ELEMENT_NOT_ONE_OF_TYPES: (validTypes) => `Element is not one of the following types: ${validTypes.join(", ")}`,
|
|
2431
3301
|
ELEMENT_IS_LOCKED: "Cannot save a locked element as a component."
|
|
@@ -2433,23 +3303,23 @@ var ERROR_MESSAGES = {
|
|
|
2433
3303
|
var handleSaveAsComponent = async (params) => {
|
|
2434
3304
|
const { element_id: elementId, component_name: componentName, overridable_props: overridablePropsInput } = params;
|
|
2435
3305
|
const validElementTypes = getValidElementTypes();
|
|
2436
|
-
const container =
|
|
3306
|
+
const container = getContainer3(elementId);
|
|
2437
3307
|
if (!container) {
|
|
2438
|
-
throw new Error(
|
|
3308
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_NOT_FOUND);
|
|
2439
3309
|
}
|
|
2440
3310
|
const elType = container.model.get("elType");
|
|
2441
3311
|
if (!validElementTypes.includes(elType)) {
|
|
2442
|
-
throw new Error(
|
|
3312
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_NOT_ONE_OF_TYPES(validElementTypes));
|
|
2443
3313
|
}
|
|
2444
3314
|
const element = container.model.toJSON({ remove: ["default"] });
|
|
2445
3315
|
if (element?.isLocked) {
|
|
2446
|
-
throw new Error(
|
|
3316
|
+
throw new Error(ERROR_MESSAGES2.ELEMENT_IS_LOCKED);
|
|
2447
3317
|
}
|
|
2448
3318
|
const overridableProps = overridablePropsInput ? enrichOverridableProps(overridablePropsInput, element) : void 0;
|
|
2449
3319
|
if (overridableProps) {
|
|
2450
3320
|
updateElementDataWithOverridableProps(element, overridableProps);
|
|
2451
3321
|
}
|
|
2452
|
-
const uid =
|
|
3322
|
+
const uid = generateUniqueId5("component");
|
|
2453
3323
|
try {
|
|
2454
3324
|
await apiClient.validate({
|
|
2455
3325
|
items: [
|
|
@@ -2471,7 +3341,7 @@ var handleSaveAsComponent = async (params) => {
|
|
|
2471
3341
|
};
|
|
2472
3342
|
function enrichOverridableProps(input, rootElement) {
|
|
2473
3343
|
const enrichedProps = {};
|
|
2474
|
-
const defaultGroupId =
|
|
3344
|
+
const defaultGroupId = generateUniqueId5("group");
|
|
2475
3345
|
Object.entries(input.props).forEach(([, prop]) => {
|
|
2476
3346
|
const { elementId, propKey } = prop;
|
|
2477
3347
|
const element = findElementById(rootElement, elementId);
|
|
@@ -2492,7 +3362,7 @@ function enrichOverridableProps(input, rootElement) {
|
|
|
2492
3362
|
`Property "${propKey}" does not exist in element "${elementId}" (type: ${widgetType}). Available properties: ${availableProps}`
|
|
2493
3363
|
);
|
|
2494
3364
|
}
|
|
2495
|
-
const overrideKey =
|
|
3365
|
+
const overrideKey = generateUniqueId5("prop");
|
|
2496
3366
|
const originValue = element.settings?.[propKey] ? element.settings[propKey] : elementType.propsSchema[propKey].default ?? null;
|
|
2497
3367
|
const label = generateLabel(propKey);
|
|
2498
3368
|
enrichedProps[overrideKey] = {
|
|
@@ -2550,11 +3420,11 @@ function findElementById(root, targetId) {
|
|
|
2550
3420
|
return null;
|
|
2551
3421
|
}
|
|
2552
3422
|
function generateLabel(propKey) {
|
|
2553
|
-
const uniqueId =
|
|
3423
|
+
const uniqueId = generateUniqueId5("prop");
|
|
2554
3424
|
return `${uniqueId} - ${propKey}`;
|
|
2555
3425
|
}
|
|
2556
3426
|
function getValidElementTypes() {
|
|
2557
|
-
const types =
|
|
3427
|
+
const types = getWidgetsCache3();
|
|
2558
3428
|
if (!types) {
|
|
2559
3429
|
return [];
|
|
2560
3430
|
}
|
|
@@ -2727,24 +3597,24 @@ function initMcp() {
|
|
|
2727
3597
|
|
|
2728
3598
|
// src/populate-store.ts
|
|
2729
3599
|
import { useEffect as useEffect6 } from "react";
|
|
2730
|
-
import { __dispatch as
|
|
3600
|
+
import { __dispatch as dispatch13 } from "@elementor/store";
|
|
2731
3601
|
function PopulateStore() {
|
|
2732
3602
|
useEffect6(() => {
|
|
2733
|
-
|
|
3603
|
+
dispatch13(loadComponents());
|
|
2734
3604
|
}, []);
|
|
2735
3605
|
return null;
|
|
2736
3606
|
}
|
|
2737
3607
|
|
|
2738
3608
|
// src/store/actions/remove-component-styles.ts
|
|
2739
|
-
import { __dispatch as
|
|
2740
|
-
function removeComponentStyles(
|
|
2741
|
-
apiClient.invalidateComponentConfigCache(
|
|
2742
|
-
|
|
3609
|
+
import { __dispatch as dispatch14 } from "@elementor/store";
|
|
3610
|
+
function removeComponentStyles(id2) {
|
|
3611
|
+
apiClient.invalidateComponentConfigCache(id2);
|
|
3612
|
+
dispatch14(slice.actions.removeStyles({ id: id2 }));
|
|
2743
3613
|
}
|
|
2744
3614
|
|
|
2745
3615
|
// src/store/components-styles-provider.ts
|
|
2746
3616
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
2747
|
-
import { __getState as
|
|
3617
|
+
import { __getState as getState17, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
2748
3618
|
var componentsStylesProvider = createStylesProvider({
|
|
2749
3619
|
key: "components-styles",
|
|
2750
3620
|
priority: 100,
|
|
@@ -2756,29 +3626,29 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
2756
3626
|
),
|
|
2757
3627
|
actions: {
|
|
2758
3628
|
all: () => {
|
|
2759
|
-
return selectFlatStyles(
|
|
3629
|
+
return selectFlatStyles(getState17());
|
|
2760
3630
|
},
|
|
2761
|
-
get: (
|
|
2762
|
-
return selectFlatStyles(
|
|
3631
|
+
get: (id2) => {
|
|
3632
|
+
return selectFlatStyles(getState17()).find((style) => style.id === id2) ?? null;
|
|
2763
3633
|
}
|
|
2764
3634
|
}
|
|
2765
3635
|
});
|
|
2766
3636
|
|
|
2767
3637
|
// src/sync/create-components-before-save.ts
|
|
2768
|
-
import { updateElementSettings } from "@elementor/editor-elements";
|
|
2769
|
-
import { __dispatch as
|
|
3638
|
+
import { updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
3639
|
+
import { __dispatch as dispatch15, __getState as getState18 } from "@elementor/store";
|
|
2770
3640
|
async function createComponentsBeforeSave({
|
|
2771
3641
|
elements,
|
|
2772
3642
|
status
|
|
2773
3643
|
}) {
|
|
2774
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
3644
|
+
const unpublishedComponents = selectUnpublishedComponents(getState18());
|
|
2775
3645
|
if (!unpublishedComponents.length) {
|
|
2776
3646
|
return;
|
|
2777
3647
|
}
|
|
2778
3648
|
try {
|
|
2779
3649
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
2780
3650
|
updateComponentInstances(elements, uidToComponentId);
|
|
2781
|
-
|
|
3651
|
+
dispatch15(
|
|
2782
3652
|
slice.actions.add(
|
|
2783
3653
|
unpublishedComponents.map((component) => ({
|
|
2784
3654
|
id: uidToComponentId.get(component.uid),
|
|
@@ -2788,7 +3658,7 @@ async function createComponentsBeforeSave({
|
|
|
2788
3658
|
}))
|
|
2789
3659
|
)
|
|
2790
3660
|
);
|
|
2791
|
-
|
|
3661
|
+
dispatch15(slice.actions.resetUnpublished());
|
|
2792
3662
|
} catch (error) {
|
|
2793
3663
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
2794
3664
|
}
|
|
@@ -2830,7 +3700,7 @@ function shouldUpdateElement(element, uidToComponentId) {
|
|
|
2830
3700
|
return { shouldUpdate: false, newComponentId: null };
|
|
2831
3701
|
}
|
|
2832
3702
|
function updateElementComponentId(elementId, componentId) {
|
|
2833
|
-
|
|
3703
|
+
updateElementSettings2({
|
|
2834
3704
|
id: elementId,
|
|
2835
3705
|
props: {
|
|
2836
3706
|
component_instance: {
|
|
@@ -2845,7 +3715,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
2845
3715
|
}
|
|
2846
3716
|
|
|
2847
3717
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
2848
|
-
import { __getState as
|
|
3718
|
+
import { __getState as getState19 } from "@elementor/store";
|
|
2849
3719
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
2850
3720
|
container
|
|
2851
3721
|
}) => {
|
|
@@ -2853,7 +3723,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2853
3723
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
2854
3724
|
return;
|
|
2855
3725
|
}
|
|
2856
|
-
const overridableProps = selectOverridableProps(
|
|
3726
|
+
const overridableProps = selectOverridableProps(getState19(), currentDocument.id);
|
|
2857
3727
|
if (overridableProps) {
|
|
2858
3728
|
container.settings.set("overridable_props", overridableProps);
|
|
2859
3729
|
}
|
|
@@ -2861,7 +3731,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
2861
3731
|
|
|
2862
3732
|
// src/sync/update-archived-component-before-save.ts
|
|
2863
3733
|
import { notify } from "@elementor/editor-notifications";
|
|
2864
|
-
import { __getState as
|
|
3734
|
+
import { __getState as getState20 } from "@elementor/store";
|
|
2865
3735
|
var failedNotification = (message) => ({
|
|
2866
3736
|
type: "error",
|
|
2867
3737
|
message: `Failed to archive components: ${message}`,
|
|
@@ -2874,7 +3744,7 @@ var successNotification = (message) => ({
|
|
|
2874
3744
|
});
|
|
2875
3745
|
var updateArchivedComponentBeforeSave = async () => {
|
|
2876
3746
|
try {
|
|
2877
|
-
const archivedComponents = selectArchivedComponents(
|
|
3747
|
+
const archivedComponents = selectArchivedComponents(getState20());
|
|
2878
3748
|
if (!archivedComponents.length) {
|
|
2879
3749
|
return;
|
|
2880
3750
|
}
|
|
@@ -2907,7 +3777,7 @@ async function updateComponentsBeforeSave({ status, elements }) {
|
|
|
2907
3777
|
return;
|
|
2908
3778
|
}
|
|
2909
3779
|
await apiClient.updateStatuses(draftIds, "publish");
|
|
2910
|
-
draftIds.forEach((
|
|
3780
|
+
draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
|
|
2911
3781
|
}
|
|
2912
3782
|
|
|
2913
3783
|
// src/sync/before-save.ts
|
|
@@ -2925,6 +3795,7 @@ var beforeSave = ({ container, status }) => {
|
|
|
2925
3795
|
function init() {
|
|
2926
3796
|
stylesRepository.register(componentsStylesProvider);
|
|
2927
3797
|
registerSlice(slice);
|
|
3798
|
+
registerPanel(panel);
|
|
2928
3799
|
registerElementType(
|
|
2929
3800
|
TYPE,
|
|
2930
3801
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
@@ -2940,7 +3811,7 @@ function init() {
|
|
|
2940
3811
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
2941
3812
|
injectTab({
|
|
2942
3813
|
id: "components",
|
|
2943
|
-
label:
|
|
3814
|
+
label: __24("Components", "elementor"),
|
|
2944
3815
|
component: Components
|
|
2945
3816
|
});
|
|
2946
3817
|
injectIntoTop({
|
|
@@ -2960,9 +3831,9 @@ function init() {
|
|
|
2960
3831
|
component: ComponentPanelHeader
|
|
2961
3832
|
});
|
|
2962
3833
|
registerDataHook("after", "editor/documents/attach-preview", async () => {
|
|
2963
|
-
const { id, config } = getV1CurrentDocument();
|
|
2964
|
-
if (
|
|
2965
|
-
removeComponentStyles(
|
|
3834
|
+
const { id: id2, config } = getV1CurrentDocument();
|
|
3835
|
+
if (id2) {
|
|
3836
|
+
removeComponentStyles(id2);
|
|
2966
3837
|
}
|
|
2967
3838
|
await loadComponentsAssets(config?.elements ?? []);
|
|
2968
3839
|
});
|