@elementor/editor-components 3.35.0-478 → 3.35.0-480

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 CHANGED
@@ -93,16 +93,18 @@ var apiClient = {
93
93
  componentId: componentId.toString()
94
94
  }
95
95
  }).then((res) => res.data.data),
96
- updateArchivedComponents: async (componentIds) => await (0, import_http_client.httpService)().post(
96
+ updateArchivedComponents: async (componentIds, status) => await (0, import_http_client.httpService)().post(
97
97
  `${BASE_URL}/archive`,
98
98
  {
99
- componentIds
99
+ componentIds,
100
+ status
100
101
  }
101
102
  ).then((res) => res.data.data),
102
- updateComponentTitle: (updatedComponentNames) => (0, import_http_client.httpService)().post(
103
+ updateComponentTitle: (updatedComponentNames, status) => (0, import_http_client.httpService)().post(
103
104
  `${BASE_URL}/update-titles`,
104
105
  {
105
- components: updatedComponentNames
106
+ components: updatedComponentNames,
107
+ status
106
108
  }
107
109
  ).then((res) => res.data.data),
108
110
  validate: async (payload) => await (0, import_http_client.httpService)().post(`${BASE_URL}/create-validate`, payload).then((res) => res.data)
@@ -1368,8 +1370,9 @@ function validatePropLabel(label, existingLabels, currentLabel) {
1368
1370
  var SIZE = "tiny";
1369
1371
  var DEFAULT_GROUP = { value: null, label: (0, import_i18n6.__)("Default", "elementor") };
1370
1372
  function OverridablePropForm({ onSubmit, groups, currentValue, existingLabels = [], sx }) {
1373
+ const selectGroups = groups?.length ? groups : [DEFAULT_GROUP];
1371
1374
  const [propLabel, setPropLabel] = (0, import_react3.useState)(currentValue?.label ?? null);
1372
- const [group, setGroup] = (0, import_react3.useState)(currentValue?.groupId ?? groups?.[0]?.value ?? null);
1375
+ const [group, setGroup] = (0, import_react3.useState)(currentValue?.groupId ?? selectGroups[0]?.value ?? null);
1373
1376
  const [error, setError] = (0, import_react3.useState)(null);
1374
1377
  const name = (0, import_i18n6.__)("Name", "elementor");
1375
1378
  const groupName = (0, import_i18n6.__)("Group Name", "elementor");
@@ -1425,14 +1428,13 @@ function OverridablePropForm({ onSubmit, groups, currentValue, existingLabels =
1425
1428
  onChange: (e) => setGroup(e.target.value),
1426
1429
  displayEmpty: true,
1427
1430
  renderValue: (selectedValue) => {
1428
- if (!selectedValue || selectedValue === "") {
1429
- const [firstGroup = DEFAULT_GROUP] = groups ?? [];
1430
- return firstGroup.label;
1431
+ if (!selectedValue) {
1432
+ return selectGroups[0].label;
1431
1433
  }
1432
- return groups?.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
1434
+ return selectGroups.find(({ value }) => value === selectedValue)?.label ?? selectedValue;
1433
1435
  }
1434
1436
  },
1435
- (groups ?? [DEFAULT_GROUP]).map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React3.createElement(import_editor_ui2.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
1437
+ selectGroups.map(({ label: groupLabel, ...props }) => /* @__PURE__ */ React3.createElement(import_editor_ui2.MenuListItem, { key: props.value, ...props, value: props.value ?? "" }, groupLabel))
1436
1438
  ))), /* @__PURE__ */ React3.createElement(import_ui3.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", mt: 1.5, py: 1, px: 1.5 }, /* @__PURE__ */ React3.createElement(
1437
1439
  import_ui3.Button,
1438
1440
  {
@@ -5031,6 +5033,21 @@ function updateElementComponentId(elementId, componentId) {
5031
5033
  });
5032
5034
  }
5033
5035
 
5036
+ // src/sync/publish-draft-components-in-page-before-save.ts
5037
+ var import_editor_documents12 = require("@elementor/editor-documents");
5038
+ async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
5039
+ if (status !== "publish") {
5040
+ return;
5041
+ }
5042
+ const documents = await getComponentDocuments(elements);
5043
+ const draftIds = [...documents.values()].filter(import_editor_documents12.isDocumentDirty).map((document) => document.id);
5044
+ if (draftIds.length === 0) {
5045
+ return;
5046
+ }
5047
+ await apiClient.updateStatuses(draftIds, "publish");
5048
+ draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
5049
+ }
5050
+
5034
5051
  // src/sync/set-component-overridable-props-settings-before-save.ts
5035
5052
  var import_store72 = require("@elementor/store");
5036
5053
  var setComponentOverridablePropsSettingsBeforeSave = ({
@@ -5054,13 +5071,13 @@ var failedNotification = (message) => ({
5054
5071
  message: `Failed to archive components: ${message}`,
5055
5072
  id: "failed-archived-components-notification"
5056
5073
  });
5057
- var updateArchivedComponentBeforeSave = async () => {
5074
+ var updateArchivedComponentBeforeSave = async (status) => {
5058
5075
  try {
5059
5076
  const archivedComponents = selectArchivedThisSession((0, import_store74.__getState)());
5060
5077
  if (!archivedComponents.length) {
5061
5078
  return;
5062
5079
  }
5063
- const result = await apiClient.updateArchivedComponents(archivedComponents);
5080
+ const result = await apiClient.updateArchivedComponents(archivedComponents, status);
5064
5081
  const failedIds = result.failedIds.join(", ");
5065
5082
  if (failedIds) {
5066
5083
  (0, import_editor_notifications5.notify)(failedNotification(failedIds));
@@ -5072,43 +5089,37 @@ var updateArchivedComponentBeforeSave = async () => {
5072
5089
 
5073
5090
  // src/sync/update-component-title-before-save.ts
5074
5091
  var import_store76 = require("@elementor/store");
5075
- var updateComponentTitleBeforeSave = async () => {
5092
+ var updateComponentTitleBeforeSave = async (status) => {
5076
5093
  const updatedComponentNames = selectUpdatedComponentNames((0, import_store76.__getState)());
5077
5094
  if (!updatedComponentNames.length) {
5078
5095
  return;
5079
5096
  }
5080
- const result = await apiClient.updateComponentTitle(updatedComponentNames);
5097
+ const result = await apiClient.updateComponentTitle(updatedComponentNames, status);
5081
5098
  if (result.failedIds.length === 0) {
5082
5099
  (0, import_store76.__dispatch)(slice.actions.cleanUpdatedComponentNames());
5083
5100
  }
5084
5101
  };
5085
5102
 
5086
- // src/sync/update-components-before-save.ts
5087
- var import_editor_documents12 = require("@elementor/editor-documents");
5088
- async function updateComponentsBeforeSave({ status, elements }) {
5089
- if (status !== "publish") {
5090
- return;
5091
- }
5092
- const documents = await getComponentDocuments(elements);
5093
- const draftIds = [...documents.values()].filter(import_editor_documents12.isDocumentDirty).map((document) => document.id);
5094
- if (draftIds.length === 0) {
5095
- return;
5096
- }
5097
- await apiClient.updateStatuses(draftIds, "publish");
5098
- draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
5099
- }
5100
-
5101
5103
  // src/sync/before-save.ts
5102
5104
  var beforeSave = ({ container, status }) => {
5103
5105
  const elements = container?.model.get("elements").toJSON?.() ?? [];
5104
5106
  return Promise.all([
5105
- updateArchivedComponentBeforeSave(),
5106
- createComponentsBeforeSave({ elements, status }),
5107
- updateComponentsBeforeSave({ elements, status }),
5108
- setComponentOverridablePropsSettingsBeforeSave({ container }),
5109
- updateComponentTitleBeforeSave()
5107
+ syncComponents({ elements, status }),
5108
+ setComponentOverridablePropsSettingsBeforeSave({ container })
5110
5109
  ]);
5111
5110
  };
5111
+ var syncComponents = async ({ elements, status }) => {
5112
+ await updateExistingComponentsBeforeSave({ elements, status });
5113
+ await createComponentsBeforeSave({ elements, status });
5114
+ };
5115
+ var updateExistingComponentsBeforeSave = async ({
5116
+ elements,
5117
+ status
5118
+ }) => {
5119
+ await updateComponentTitleBeforeSave(status);
5120
+ await updateArchivedComponentBeforeSave(status);
5121
+ await publishDraftComponentsInPageBeforeSave({ elements, status });
5122
+ };
5112
5123
 
5113
5124
  // src/sync/cleanup-overridable-props-on-delete.ts
5114
5125
  var import_editor_elements20 = require("@elementor/editor-elements");