@elementor/editor-elements 4.3.0-1047 → 4.3.0-1049
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 +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/hooks/use-element-children.ts +17 -2
- package/src/index.ts +6 -1
package/dist/index.d.mts
CHANGED
|
@@ -293,7 +293,17 @@ type ElementModel = {
|
|
|
293
293
|
editorSettings: V1ElementEditorSettingsProps;
|
|
294
294
|
};
|
|
295
295
|
type ElementChildren = Record<string, ElementModel[]>;
|
|
296
|
-
|
|
296
|
+
type UseElementChildrenOptions = {
|
|
297
|
+
/**
|
|
298
|
+
* Let the element itself match a requested parent type. Off by default, because
|
|
299
|
+
* `findChildRecursive` only inspects descendants and existing callers rely on that: an element
|
|
300
|
+
* whose repeater items are its own direct children (e.g. `e-accordion` -> `e-accordion-item`)
|
|
301
|
+
* has no intermediate wrapper to look for, while one that keeps them in a sub-container
|
|
302
|
+
* (e.g. `e-tabs` -> `e-tabs-menu` -> `e-tab`) must not match itself.
|
|
303
|
+
*/
|
|
304
|
+
includeSelfAsParent?: boolean;
|
|
305
|
+
};
|
|
306
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>, { includeSelfAsParent }?: UseElementChildrenOptions): T;
|
|
297
307
|
|
|
298
308
|
declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
|
|
299
309
|
|
|
@@ -601,4 +611,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
601
611
|
}) => void;
|
|
602
612
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
603
613
|
|
|
604
|
-
export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, addModelToParent, bindSettingsReconcile, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
|
614
|
+
export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type UseElementChildrenOptions, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, addModelToParent, bindSettingsReconcile, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -293,7 +293,17 @@ type ElementModel = {
|
|
|
293
293
|
editorSettings: V1ElementEditorSettingsProps;
|
|
294
294
|
};
|
|
295
295
|
type ElementChildren = Record<string, ElementModel[]>;
|
|
296
|
-
|
|
296
|
+
type UseElementChildrenOptions = {
|
|
297
|
+
/**
|
|
298
|
+
* Let the element itself match a requested parent type. Off by default, because
|
|
299
|
+
* `findChildRecursive` only inspects descendants and existing callers rely on that: an element
|
|
300
|
+
* whose repeater items are its own direct children (e.g. `e-accordion` -> `e-accordion-item`)
|
|
301
|
+
* has no intermediate wrapper to look for, while one that keeps them in a sub-container
|
|
302
|
+
* (e.g. `e-tabs` -> `e-tabs-menu` -> `e-tab`) must not match itself.
|
|
303
|
+
*/
|
|
304
|
+
includeSelfAsParent?: boolean;
|
|
305
|
+
};
|
|
306
|
+
declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>, { includeSelfAsParent }?: UseElementChildrenOptions): T;
|
|
297
307
|
|
|
298
308
|
declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
|
|
299
309
|
|
|
@@ -601,4 +611,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
|
|
|
601
611
|
}) => void;
|
|
602
612
|
declare const playElementInteractions: (elementId: string, interactionId: string) => void;
|
|
603
613
|
|
|
604
|
-
export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, addModelToParent, bindSettingsReconcile, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
|
614
|
+
export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ChildDependenciesConfig, type ChildDependencyRule, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, DEFAULT_STYLE_CLASS_PREFIX, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementPosition, type ElementPositionKind, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type UseElementChildrenOptions, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, addModelToParent, bindSettingsReconcile, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, evaluateWhen, findChildRecursive, findModelInDocument, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getDefaultStyleTagFromPreviewElement, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementIcon, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementTitle, getElementType, getElements, getLinkInLinkRestriction, getPreviewElementDOM, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, parseDefaultStyleTagFromClassList, playElementInteractions, reconcileInitialChildren, removeElements, removeModelFromParent, replaceElement, resolveContainer, resolveInsertIndex, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
|
package/dist/index.js
CHANGED
|
@@ -369,7 +369,7 @@ function toElementModel({ model }) {
|
|
|
369
369
|
editorSettings: model.get("editor_settings") ?? {}
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
|
-
function useElementChildren(elementId, childrenTypes) {
|
|
372
|
+
function useElementChildren(elementId, childrenTypes, { includeSelfAsParent = false } = {}) {
|
|
373
373
|
return (0, import_editor_v1_adapters2.__privateUseListenTo)(
|
|
374
374
|
[
|
|
375
375
|
(0, import_editor_v1_adapters2.v1ReadyEvent)(),
|
|
@@ -385,7 +385,7 @@ function useElementChildren(elementId, childrenTypes) {
|
|
|
385
385
|
return {};
|
|
386
386
|
}
|
|
387
387
|
const elementChildren = Object.entries(childrenTypes).reduce((acc, [parentType, childType]) => {
|
|
388
|
-
const parent = findChildRecursive(model, (m) => m.get("elType") === parentType);
|
|
388
|
+
const parent = includeSelfAsParent && model.get("elType") === parentType ? { model } : findChildRecursive(model, (m) => m.get("elType") === parentType);
|
|
389
389
|
if (!parent) {
|
|
390
390
|
acc[childType] = [];
|
|
391
391
|
return acc;
|