@elementor/editor-components 4.2.0-946 → 4.2.0-beta2

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.d.mts CHANGED
@@ -1306,6 +1306,12 @@ declare const slice: typeof baseSlice;
1306
1306
 
1307
1307
  type ComponentsSlice = SliceState<typeof slice>;
1308
1308
 
1309
+ declare const selectComponentByUid: (state: ComponentsSlice, componentUid: string) => PublishedComponent | UnpublishedComponent | undefined;
1310
+ declare const selectCreatedThisSession: ((state: ComponentsSlice) => string[]) & reselect.OutputSelectorFields<(args_0: string[]) => string[], {
1311
+ clearCache: () => void;
1312
+ }> & {
1313
+ clearCache: () => void;
1314
+ };
1309
1315
  declare const selectOverridableProps: ((state: ComponentsSlice, componentId: number) => OverridableProps | undefined) & reselect.OutputSelectorFields<(args_0: PublishedComponent | undefined) => OverridableProps | undefined, {
1310
1316
  clearCache: () => void;
1311
1317
  }> & {
@@ -1404,14 +1410,18 @@ declare const resolveOverridePropValue: (originalPropValue: ComponentInstanceOve
1404
1410
 
1405
1411
  declare function switchToComponent(componentId: number, componentInstanceId?: string | null, element?: HTMLElement | null): Promise<void>;
1406
1412
 
1407
- type Source = 'user' | 'mcp_tool' | 'system';
1413
+ type ExecutedBy = 'user' | 'mcp_tool' | 'system';
1414
+ /** @deprecated since 4.2.1 - use `ExecutedBy` instead */
1415
+ type Source = ExecutedBy;
1408
1416
  type ComponentEventData = Record<string, unknown> & {
1409
1417
  action: 'createClicked' | 'created' | 'createCancelled' | 'instanceAdded' | 'edited' | 'propertyExposed' | 'propertyRemoved' | 'propertiesPanelOpened' | 'propertiesGroupCreated' | 'detached';
1410
- source: Source;
1418
+ executedBy?: ExecutedBy;
1419
+ /** @deprecated since 4.2.1 - use `executedBy` instead */
1420
+ source?: Source;
1411
1421
  };
1412
- declare const trackComponentEvent: ({ action, source, ...data }: ComponentEventData) => void;
1422
+ declare const trackComponentEvent: ({ action, source, executedBy, ...data }: ComponentEventData) => void;
1413
1423
  declare const onElementDrop: (_args: unknown, element: V1Element) => void;
1414
1424
 
1415
1425
  declare const getComponentDocumentData: (id: number) => Promise<Document | null>;
1416
1426
 
1417
- export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type UnpublishedComponent, type UpdatedComponentName, apiClient, componentInstanceOverridePropTypeUtil, componentInstanceOverridesPropTypeUtil, componentInstancePropTypeUtil, componentOverridablePropTypeUtil, componentsActions, componentsSelectors, createComponentsAction, filterValidOverridableProps, getComponentDocumentData, getContainerByOriginId, getOverridableProp, getPropTypeForComponentOverride, init, isComponentInstance, loadComponentsAssets, onElementDrop, publishDraftComponentsInPageBeforeSave, registerComponentsReducer, resolveOverridePropValue, selectOverridableProps, selectPath, slice, switchToComponent, trackComponentEvent, updateOverridableProp, useComponentInstanceElement, useComponents, useComponentsPermissions, useCurrentComponent, useCurrentComponentId, useFilteredComponents, useInstancePanelData, useIsSanitizedComponent, useOverridablePropValue, useOverridableProps, useSanitizeOverridableProps };
1427
+ export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExecutedBy, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type UnpublishedComponent, type UpdatedComponentName, apiClient, componentInstanceOverridePropTypeUtil, componentInstanceOverridesPropTypeUtil, componentInstancePropTypeUtil, componentOverridablePropTypeUtil, componentsActions, componentsSelectors, createComponentsAction, filterValidOverridableProps, getComponentDocumentData, getContainerByOriginId, getOverridableProp, getPropTypeForComponentOverride, init, isComponentInstance, loadComponentsAssets, onElementDrop, publishDraftComponentsInPageBeforeSave, registerComponentsReducer, resolveOverridePropValue, selectComponentByUid, selectCreatedThisSession, selectOverridableProps, selectPath, slice, switchToComponent, trackComponentEvent, updateOverridableProp, useComponentInstanceElement, useComponents, useComponentsPermissions, useCurrentComponent, useCurrentComponentId, useFilteredComponents, useInstancePanelData, useIsSanitizedComponent, useOverridablePropValue, useOverridableProps, useSanitizeOverridableProps };
package/dist/index.d.ts CHANGED
@@ -1306,6 +1306,12 @@ declare const slice: typeof baseSlice;
1306
1306
 
1307
1307
  type ComponentsSlice = SliceState<typeof slice>;
1308
1308
 
1309
+ declare const selectComponentByUid: (state: ComponentsSlice, componentUid: string) => PublishedComponent | UnpublishedComponent | undefined;
1310
+ declare const selectCreatedThisSession: ((state: ComponentsSlice) => string[]) & reselect.OutputSelectorFields<(args_0: string[]) => string[], {
1311
+ clearCache: () => void;
1312
+ }> & {
1313
+ clearCache: () => void;
1314
+ };
1309
1315
  declare const selectOverridableProps: ((state: ComponentsSlice, componentId: number) => OverridableProps | undefined) & reselect.OutputSelectorFields<(args_0: PublishedComponent | undefined) => OverridableProps | undefined, {
1310
1316
  clearCache: () => void;
1311
1317
  }> & {
@@ -1404,14 +1410,18 @@ declare const resolveOverridePropValue: (originalPropValue: ComponentInstanceOve
1404
1410
 
1405
1411
  declare function switchToComponent(componentId: number, componentInstanceId?: string | null, element?: HTMLElement | null): Promise<void>;
1406
1412
 
1407
- type Source = 'user' | 'mcp_tool' | 'system';
1413
+ type ExecutedBy = 'user' | 'mcp_tool' | 'system';
1414
+ /** @deprecated since 4.2.1 - use `ExecutedBy` instead */
1415
+ type Source = ExecutedBy;
1408
1416
  type ComponentEventData = Record<string, unknown> & {
1409
1417
  action: 'createClicked' | 'created' | 'createCancelled' | 'instanceAdded' | 'edited' | 'propertyExposed' | 'propertyRemoved' | 'propertiesPanelOpened' | 'propertiesGroupCreated' | 'detached';
1410
- source: Source;
1418
+ executedBy?: ExecutedBy;
1419
+ /** @deprecated since 4.2.1 - use `executedBy` instead */
1420
+ source?: Source;
1411
1421
  };
1412
- declare const trackComponentEvent: ({ action, source, ...data }: ComponentEventData) => void;
1422
+ declare const trackComponentEvent: ({ action, source, executedBy, ...data }: ComponentEventData) => void;
1413
1423
  declare const onElementDrop: (_args: unknown, element: V1Element) => void;
1414
1424
 
1415
1425
  declare const getComponentDocumentData: (id: number) => Promise<Document | null>;
1416
1426
 
1417
- export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type UnpublishedComponent, type UpdatedComponentName, apiClient, componentInstanceOverridePropTypeUtil, componentInstanceOverridesPropTypeUtil, componentInstancePropTypeUtil, componentOverridablePropTypeUtil, componentsActions, componentsSelectors, createComponentsAction, filterValidOverridableProps, getComponentDocumentData, getContainerByOriginId, getOverridableProp, getPropTypeForComponentOverride, init, isComponentInstance, loadComponentsAssets, onElementDrop, publishDraftComponentsInPageBeforeSave, registerComponentsReducer, resolveOverridePropValue, selectOverridableProps, selectPath, slice, switchToComponent, trackComponentEvent, updateOverridableProp, useComponentInstanceElement, useComponents, useComponentsPermissions, useCurrentComponent, useCurrentComponentId, useFilteredComponents, useInstancePanelData, useIsSanitizedComponent, useOverridablePropValue, useOverridableProps, useSanitizeOverridableProps };
1427
+ export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExecutedBy, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type UnpublishedComponent, type UpdatedComponentName, apiClient, componentInstanceOverridePropTypeUtil, componentInstanceOverridesPropTypeUtil, componentInstancePropTypeUtil, componentOverridablePropTypeUtil, componentsActions, componentsSelectors, createComponentsAction, filterValidOverridableProps, getComponentDocumentData, getContainerByOriginId, getOverridableProp, getPropTypeForComponentOverride, init, isComponentInstance, loadComponentsAssets, onElementDrop, publishDraftComponentsInPageBeforeSave, registerComponentsReducer, resolveOverridePropValue, selectComponentByUid, selectCreatedThisSession, selectOverridableProps, selectPath, slice, switchToComponent, trackComponentEvent, updateOverridableProp, useComponentInstanceElement, useComponents, useComponentsPermissions, useCurrentComponent, useCurrentComponentId, useFilteredComponents, useInstancePanelData, useIsSanitizedComponent, useOverridablePropValue, useOverridableProps, useSanitizeOverridableProps };
package/dist/index.js CHANGED
@@ -66,6 +66,8 @@ __export(index_exports, {
66
66
  publishDraftComponentsInPageBeforeSave: () => publishDraftComponentsInPageBeforeSave,
67
67
  registerComponentsReducer: () => registerComponentsReducer,
68
68
  resolveOverridePropValue: () => resolveOverridePropValue,
69
+ selectComponentByUid: () => selectComponentByUid,
70
+ selectCreatedThisSession: () => selectCreatedThisSession,
69
71
  selectOverridableProps: () => selectOverridableProps,
70
72
  selectPath: () => selectPath,
71
73
  slice: () => slice,
@@ -1182,8 +1184,8 @@ var componentInstancePropTypeUtil = (0, import_editor_props4.createPropUtils)(
1182
1184
  var import_events = require("@elementor/events");
1183
1185
  var import_store8 = require("@elementor/store");
1184
1186
  var FEATURE_NAME = "Components";
1185
- var trackComponentEvent = ({ action, source, ...data }) => {
1186
- if (source === "system") {
1187
+ var trackComponentEvent = ({ action, source, executedBy, ...data }) => {
1188
+ if (source === "system" || executedBy === "system") {
1187
1189
  return;
1188
1190
  }
1189
1191
  const { dispatchEvent, config } = (0, import_events.getMixpanel)();
@@ -1191,7 +1193,7 @@ var trackComponentEvent = ({ action, source, ...data }) => {
1191
1193
  return;
1192
1194
  }
1193
1195
  const name = config.names.components[action];
1194
- dispatchEvent?.(name, { ...data, source, "Feature name": FEATURE_NAME });
1196
+ dispatchEvent?.(name, { ...data, executed_by: executedBy ?? source, "Feature name": FEATURE_NAME });
1195
1197
  };
1196
1198
  var onElementDrop = (_args, element) => {
1197
1199
  if (!(element?.model?.get("widgetType") === "e-component")) {
@@ -1207,7 +1209,7 @@ var onElementDrop = (_args, element) => {
1207
1209
  const { locations, secondaryLocations } = eventsManagerConfig;
1208
1210
  trackComponentEvent({
1209
1211
  action: "instanceAdded",
1210
- source: "user",
1212
+ executedBy: "user",
1211
1213
  instance_id: instanceId,
1212
1214
  component_uid: componentUID,
1213
1215
  component_name: componentName,
@@ -1431,7 +1433,7 @@ async function detachComponentInstance({
1431
1433
  const componentUid = selectComponent((0, import_store10.__getState)(), componentId)?.uid;
1432
1434
  trackComponentEvent({
1433
1435
  action: "detached",
1434
- source: "user",
1436
+ executedBy: "user",
1435
1437
  component_uid: componentUid,
1436
1438
  instance_id: instanceId,
1437
1439
  location: trackingInfo.location,
@@ -2560,7 +2562,7 @@ async function getComponentDocuments({
2560
2562
  }
2561
2563
  async function getComponentIds(elements, cache, isRecursive) {
2562
2564
  const results = await Promise.all(
2563
- elements.map(async ({ widgetType, elType, elements: childElements, settings }) => {
2565
+ elements.filter(Boolean).map(async ({ widgetType, elType, elements: childElements, settings }) => {
2564
2566
  const ids = [];
2565
2567
  if (isComponentInstance({ widgetType, elType })) {
2566
2568
  const componentId = settings?.component_instance?.value?.component_id.value;
@@ -2611,6 +2613,9 @@ async function loadComponentsOverridableProps(componentIds) {
2611
2613
 
2612
2614
  // src/store/actions/load-components-assets.ts
2613
2615
  async function loadComponentsAssets(elements) {
2616
+ if (!elements.length) {
2617
+ return;
2618
+ }
2614
2619
  const documents = await getComponentDocuments({ elements, isRecursive: false });
2615
2620
  updateDocumentState(documents);
2616
2621
  documents.forEach((document2, id) => {
@@ -2929,7 +2934,7 @@ function createComponentView(options) {
2929
2934
  const editorSettings = this.model.get("editor_settings");
2930
2935
  trackComponentEvent({
2931
2936
  action: "edited",
2932
- source: "user",
2937
+ executedBy: "user",
2933
2938
  component_uid: editorSettings?.component_uid,
2934
2939
  component_name: editorSettings?.title,
2935
2940
  location,
@@ -3266,8 +3271,12 @@ function initLoadComponentDataAfterInstanceAdded() {
3266
3271
  });
3267
3272
  }
3268
3273
  function load(result) {
3274
+ if (!result) {
3275
+ return;
3276
+ }
3269
3277
  const containers = Array.isArray(result) ? result : [result];
3270
- loadComponentsAssets(containers.map((container) => container.model.toJSON()));
3278
+ const elements = containers.map((container) => container.model?.toJSON()).filter((element) => !!element);
3279
+ loadComponentsAssets(elements);
3271
3280
  }
3272
3281
 
3273
3282
  // src/init.ts
@@ -3356,6 +3365,8 @@ function init() {
3356
3365
  publishDraftComponentsInPageBeforeSave,
3357
3366
  registerComponentsReducer,
3358
3367
  resolveOverridePropValue,
3368
+ selectComponentByUid,
3369
+ selectCreatedThisSession,
3359
3370
  selectOverridableProps,
3360
3371
  selectPath,
3361
3372
  slice,