@elementor/editor-elements 3.33.0-278 → 3.33.0-280

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
@@ -142,7 +142,7 @@ type ElementModel = {
142
142
  id: string;
143
143
  };
144
144
  type ElementChildren = Record<string, ElementModel[]>;
145
- declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: (keyof T & string)[]): T;
145
+ declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>): T;
146
146
 
147
147
  declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
148
148
 
package/dist/index.d.ts CHANGED
@@ -142,7 +142,7 @@ type ElementModel = {
142
142
  id: string;
143
143
  };
144
144
  type ElementChildren = Record<string, ElementModel[]>;
145
- declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: (keyof T & string)[]): T;
145
+ declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>): T;
146
146
 
147
147
  declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
148
148
 
package/dist/index.js CHANGED
@@ -100,16 +100,14 @@ function useElementChildren(elementId, childrenTypes) {
100
100
  ],
101
101
  () => {
102
102
  const container = getContainer(elementId);
103
- const elementChildren = childrenTypes.reduce((acc, type) => {
104
- acc[type] = [];
103
+ const elementChildren = Object.entries(childrenTypes).reduce((acc, [parentType, childType]) => {
104
+ const parent = container?.children?.findRecursive?.(
105
+ ({ model }) => model.get("elType") === parentType
106
+ );
107
+ const children = parent?.children ?? [];
108
+ acc[childType] = children.filter(({ model }) => model.get("elType") === childType).map(({ id }) => ({ id }));
105
109
  return acc;
106
110
  }, {});
107
- container?.children?.forEachRecursive?.(({ model, id }) => {
108
- const elType = model.get("elType");
109
- if (elType && elType in elementChildren) {
110
- elementChildren[elType].push({ id });
111
- }
112
- });
113
111
  return elementChildren;
114
112
  },
115
113
  [elementId]