@elementor/editor-components 3.35.0-418 → 3.35.0-420

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.mjs CHANGED
@@ -20,7 +20,7 @@ import { __registerSlice as registerSlice } from "@elementor/store";
20
20
  import { __ as __26 } from "@wordpress/i18n";
21
21
 
22
22
  // src/component-instance-transformer.ts
23
- import { createTransformer, RenderContext } from "@elementor/editor-canvas";
23
+ import { createTransformer } from "@elementor/editor-canvas";
24
24
  import { __getState as getState } from "@elementor/store";
25
25
 
26
26
  // src/store/store.ts
@@ -283,9 +283,6 @@ var invalidateComponentDocumentData = (id2) => {
283
283
  };
284
284
 
285
285
  // src/component-instance-transformer.ts
286
- var componentInstanceContext = new RenderContext("component-instance", {
287
- overrides: {}
288
- });
289
286
  var componentInstanceTransformer = createTransformer(
290
287
  async ({
291
288
  component_id: id2,
@@ -315,7 +312,7 @@ var componentInstanceTransformer = createTransformer(
315
312
  import { createTransformer as createTransformer2, settingsTransformersRegistry } from "@elementor/editor-canvas";
316
313
  var componentOverridableTransformer = createTransformer2(
317
314
  (value, options) => {
318
- const { overrides } = componentInstanceContext.get();
315
+ const { overrides } = options.renderContext ?? {};
319
316
  const overrideValue = overrides?.[value.override_key];
320
317
  if (overrideValue) {
321
318
  const isOverride = isOriginValueOverride(value.origin_value);
@@ -1818,13 +1815,41 @@ function createComponentView(options) {
1818
1815
  return class extends createTemplatedElementView(options) {
1819
1816
  legacyWindow = window;
1820
1817
  eventsManagerConfig = this.legacyWindow.elementorCommon.eventsManager.config;
1818
+ #componentRenderContext;
1821
1819
  isComponentCurrentlyEdited() {
1822
1820
  const currentDocument = getCurrentDocument();
1823
1821
  return currentDocument?.id === this.getComponentId();
1824
1822
  }
1823
+ getRenderContext() {
1824
+ const namespaceKey = this.getNamespaceKey();
1825
+ const parentContext = this._parent?.getRenderContext?.();
1826
+ const parentComponentContext = parentContext?.[namespaceKey];
1827
+ if (!this.#componentRenderContext) {
1828
+ return parentContext;
1829
+ }
1830
+ const ownOverrides = this.#componentRenderContext.overrides ?? {};
1831
+ const parentOverrides = parentComponentContext?.overrides ?? {};
1832
+ return {
1833
+ ...parentContext,
1834
+ [namespaceKey]: {
1835
+ overrides: {
1836
+ ...parentOverrides,
1837
+ ...ownOverrides
1838
+ }
1839
+ }
1840
+ };
1841
+ }
1842
+ getResolverRenderContext() {
1843
+ const namespaceKey = this.getNamespaceKey();
1844
+ const context = this.getRenderContext();
1845
+ return context?.[namespaceKey];
1846
+ }
1825
1847
  afterSettingsResolve(settings) {
1826
1848
  const componentInstance = settings.component_instance;
1827
1849
  if (componentInstance) {
1850
+ this.#componentRenderContext = {
1851
+ overrides: componentInstance.overrides ?? {}
1852
+ };
1828
1853
  this.collection = this.legacyWindow.elementor.createBackboneElementsCollection(
1829
1854
  componentInstance.elements
1830
1855
  );
@@ -2178,8 +2203,8 @@ function getSelectedElementContainer() {
2178
2203
 
2179
2204
  // src/components/create-component-form/utils/replace-element-with-component.ts
2180
2205
  import { replaceElement } from "@elementor/editor-elements";
2181
- var replaceElementWithComponent = (element, component) => {
2182
- replaceElement({
2206
+ var replaceElementWithComponent = async (element, component) => {
2207
+ return await replaceElement({
2183
2208
  currentElement: element,
2184
2209
  newElement: createComponentModel2(component),
2185
2210
  withHistory: false
@@ -2542,6 +2567,7 @@ import { getElementLabel } from "@elementor/editor-elements";
2542
2567
  import { notify as notify2 } from "@elementor/editor-notifications";
2543
2568
  import { Form as FormElement, ThemeProvider as ThemeProvider3 } from "@elementor/editor-ui";
2544
2569
  import { StarIcon } from "@elementor/icons";
2570
+ import { __getState as getState15 } from "@elementor/store";
2545
2571
  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";
2546
2572
  import { __ as __18 } from "@wordpress/i18n";
2547
2573
 
@@ -2663,7 +2689,7 @@ function findNonAtomicElementsInElement(element) {
2663
2689
  import { __privateRunCommand as runCommand3 } from "@elementor/editor-v1-adapters";
2664
2690
  import { __dispatch as dispatch11 } from "@elementor/store";
2665
2691
  import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
2666
- function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
2692
+ async function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
2667
2693
  const generatedUid = uid ?? generateUniqueId3("component");
2668
2694
  const componentBase = { uid: generatedUid, name, overridableProps };
2669
2695
  dispatch11(
@@ -2673,15 +2699,15 @@ function createUnpublishedComponent(name, element, eventData, overridableProps,
2673
2699
  })
2674
2700
  );
2675
2701
  dispatch11(slice.actions.addCreatedThisSession(generatedUid));
2676
- replaceElementWithComponent(element, componentBase);
2702
+ const componentInstance = await replaceElementWithComponent(element, componentBase);
2677
2703
  trackComponentEvent({
2678
2704
  action: "created",
2679
2705
  component_uid: generatedUid,
2680
2706
  component_name: name,
2681
2707
  ...eventData
2682
2708
  });
2683
- runCommand3("document/save/auto");
2684
- return generatedUid;
2709
+ await runCommand3("document/save/auto");
2710
+ return { uid: generatedUid, instanceId: componentInstance.id };
2685
2711
  }
2686
2712
 
2687
2713
  // src/components/create-component-form/hooks/use-form.ts
@@ -2796,12 +2822,22 @@ function CreateComponentForm() {
2796
2822
  window.removeEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup);
2797
2823
  };
2798
2824
  }, []);
2799
- const handleSave = (values) => {
2825
+ const handleSave = async (values) => {
2800
2826
  try {
2801
2827
  if (!element) {
2802
2828
  throw new Error(`Can't save element as component: element not found`);
2803
2829
  }
2804
- const uid = createUnpublishedComponent(values.componentName, element.element, eventData.current);
2830
+ const { uid, instanceId } = await createUnpublishedComponent(
2831
+ values.componentName,
2832
+ element.element,
2833
+ eventData.current
2834
+ );
2835
+ const publishedComponentId = selectComponentByUid(getState15(), uid)?.id;
2836
+ if (publishedComponentId) {
2837
+ switchToComponent(publishedComponentId, instanceId);
2838
+ } else {
2839
+ throw new Error("Failed to find published component");
2840
+ }
2805
2841
  setResultNotification({
2806
2842
  show: true,
2807
2843
  // Translators: %1$s: Component name, %2$s: Component UID
@@ -3361,9 +3397,9 @@ function getControlsByBind(controls) {
3361
3397
  }
3362
3398
 
3363
3399
  // src/store/actions/update-overridable-prop.ts
3364
- import { __dispatch as dispatch12, __getState as getState15 } from "@elementor/store";
3400
+ import { __dispatch as dispatch12, __getState as getState16 } from "@elementor/store";
3365
3401
  function updateOverridableProp(componentId, propValue, originPropFields) {
3366
- const overridableProps = selectOverridableProps(getState15(), componentId);
3402
+ const overridableProps = selectOverridableProps(getState16(), componentId);
3367
3403
  if (!overridableProps) {
3368
3404
  return;
3369
3405
  }
@@ -3675,7 +3711,7 @@ import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Po
3675
3711
  import { __ as __24 } from "@wordpress/i18n";
3676
3712
 
3677
3713
  // src/store/actions/set-overridable-prop.ts
3678
- import { __dispatch as dispatch13, __getState as getState16 } from "@elementor/store";
3714
+ import { __dispatch as dispatch13, __getState as getState17 } from "@elementor/store";
3679
3715
  import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
3680
3716
  function setOverridableProp({
3681
3717
  componentId,
@@ -3689,7 +3725,7 @@ function setOverridableProp({
3689
3725
  originValue,
3690
3726
  originPropFields
3691
3727
  }) {
3692
- const overridableProps = selectOverridableProps(getState16(), componentId);
3728
+ const overridableProps = selectOverridableProps(getState17(), componentId);
3693
3729
  if (!overridableProps) {
3694
3730
  return;
3695
3731
  }
@@ -3809,12 +3845,12 @@ var Indicator2 = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @_
3809
3845
  )));
3810
3846
 
3811
3847
  // src/components/overridable-props/utils/get-overridable-prop.ts
3812
- import { __getState as getState17 } from "@elementor/store";
3848
+ import { __getState as getState18 } from "@elementor/store";
3813
3849
  function getOverridableProp({
3814
3850
  componentId,
3815
3851
  overrideKey
3816
3852
  }) {
3817
- const overridableProps = selectOverridableProps(getState17(), componentId);
3853
+ const overridableProps = selectOverridableProps(getState18(), componentId);
3818
3854
  if (!overridableProps) {
3819
3855
  return void 0;
3820
3856
  }
@@ -4336,7 +4372,7 @@ function PopulateStore() {
4336
4372
  import { getAllDescendants as getAllDescendants3 } from "@elementor/editor-elements";
4337
4373
  import { notify as notify3 } from "@elementor/editor-notifications";
4338
4374
  import { blockCommand as blockCommand2 } from "@elementor/editor-v1-adapters";
4339
- import { __getState as getState18 } from "@elementor/store";
4375
+ import { __getState as getState19 } from "@elementor/store";
4340
4376
  import { __ as __25 } from "@wordpress/i18n";
4341
4377
  var COMPONENT_TYPE = "e-component";
4342
4378
  var COMPONENT_CIRCULAR_NESTING_ALERT = {
@@ -4362,7 +4398,7 @@ function wouldCreateCircularNesting(componentIdToAdd) {
4362
4398
  if (componentIdToAdd === void 0) {
4363
4399
  return false;
4364
4400
  }
4365
- const state = getState18();
4401
+ const state = getState19();
4366
4402
  const currentComponentId = selectCurrentComponentId(state);
4367
4403
  const path = selectPath(state);
4368
4404
  if (currentComponentId === null) {
@@ -4468,7 +4504,7 @@ function removeComponentStyles(id2) {
4468
4504
 
4469
4505
  // src/store/components-styles-provider.ts
4470
4506
  import { createStylesProvider } from "@elementor/editor-styles-repository";
4471
- import { __getState as getState19, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
4507
+ import { __getState as getState20, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
4472
4508
  var componentsStylesProvider = createStylesProvider({
4473
4509
  key: "components-styles",
4474
4510
  priority: 100,
@@ -4480,22 +4516,22 @@ var componentsStylesProvider = createStylesProvider({
4480
4516
  ),
4481
4517
  actions: {
4482
4518
  all: () => {
4483
- return selectFlatStyles(getState19());
4519
+ return selectFlatStyles(getState20());
4484
4520
  },
4485
4521
  get: (id2) => {
4486
- return selectFlatStyles(getState19()).find((style) => style.id === id2) ?? null;
4522
+ return selectFlatStyles(getState20()).find((style) => style.id === id2) ?? null;
4487
4523
  }
4488
4524
  }
4489
4525
  });
4490
4526
 
4491
4527
  // src/sync/create-components-before-save.ts
4492
4528
  import { updateElementSettings as updateElementSettings3 } from "@elementor/editor-elements";
4493
- import { __dispatch as dispatch16, __getState as getState20 } from "@elementor/store";
4529
+ import { __dispatch as dispatch16, __getState as getState21 } from "@elementor/store";
4494
4530
  async function createComponentsBeforeSave({
4495
4531
  elements,
4496
4532
  status
4497
4533
  }) {
4498
- const unpublishedComponents = selectUnpublishedComponents(getState20());
4534
+ const unpublishedComponents = selectUnpublishedComponents(getState21());
4499
4535
  if (!unpublishedComponents.length) {
4500
4536
  return;
4501
4537
  }
@@ -4572,7 +4608,7 @@ function updateElementComponentId(elementId, componentId) {
4572
4608
  }
4573
4609
 
4574
4610
  // src/sync/set-component-overridable-props-settings-before-save.ts
4575
- import { __getState as getState21 } from "@elementor/store";
4611
+ import { __getState as getState22 } from "@elementor/store";
4576
4612
  var setComponentOverridablePropsSettingsBeforeSave = ({
4577
4613
  container
4578
4614
  }) => {
@@ -4580,7 +4616,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
4580
4616
  if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
4581
4617
  return;
4582
4618
  }
4583
- const overridableProps = selectOverridableProps(getState21(), currentDocument.id);
4619
+ const overridableProps = selectOverridableProps(getState22(), currentDocument.id);
4584
4620
  if (overridableProps) {
4585
4621
  container.settings.set("overridable_props", overridableProps);
4586
4622
  }
@@ -4588,7 +4624,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
4588
4624
 
4589
4625
  // src/sync/update-archived-component-before-save.ts
4590
4626
  import { notify as notify4 } from "@elementor/editor-notifications";
4591
- import { __getState as getState22 } from "@elementor/store";
4627
+ import { __getState as getState23 } from "@elementor/store";
4592
4628
  var failedNotification = (message) => ({
4593
4629
  type: "error",
4594
4630
  message: `Failed to archive components: ${message}`,
@@ -4601,7 +4637,7 @@ var successNotification = (message) => ({
4601
4637
  });
4602
4638
  var updateArchivedComponentBeforeSave = async () => {
4603
4639
  try {
4604
- const archivedComponents = selectArchivedComponents(getState22());
4640
+ const archivedComponents = selectArchivedComponents(getState23());
4605
4641
  if (!archivedComponents.length) {
4606
4642
  return;
4607
4643
  }
@@ -4622,9 +4658,9 @@ var updateArchivedComponentBeforeSave = async () => {
4622
4658
  };
4623
4659
 
4624
4660
  // src/sync/update-component-title-before-save.ts
4625
- import { __dispatch as dispatch17, __getState as getState23 } from "@elementor/store";
4661
+ import { __dispatch as dispatch17, __getState as getState24 } from "@elementor/store";
4626
4662
  var updateComponentTitleBeforeSave = async () => {
4627
- const updatedComponentNames = selectUpdatedComponentNames(getState23());
4663
+ const updatedComponentNames = selectUpdatedComponentNames(getState24());
4628
4664
  if (!updatedComponentNames.length) {
4629
4665
  return;
4630
4666
  }