@elementor/editor-components 4.0.0-675 → 4.0.0-677

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
@@ -17,10 +17,28 @@ import { createTransformer } from "@elementor/editor-canvas";
17
17
  import { __getState as getState } from "@elementor/store";
18
18
 
19
19
  // src/store/store.ts
20
+ import { __createSelector as createSelector, __useSelector as useSelector } from "@elementor/store";
21
+
22
+ // src/store/store-types.ts
23
+ var initialState = {
24
+ data: [],
25
+ unpublishedData: [],
26
+ loadStatus: "idle",
27
+ styles: {},
28
+ createdThisSession: [],
29
+ archivedThisSession: [],
30
+ path: [],
31
+ currentComponentId: null,
32
+ updatedComponentNames: {},
33
+ sanitized: {}
34
+ };
35
+ var SLICE_NAME = "components";
36
+
37
+ // src/store/extensible-slice.ts
20
38
  import {
21
- __createSelector as createSelector,
39
+ __createAction as createAction,
22
40
  __createSlice as createSlice,
23
- __useSelector as useSelector
41
+ __dispatch as dispatch
24
42
  } from "@elementor/store";
25
43
 
26
44
  // src/store/thunks.ts
@@ -86,21 +104,24 @@ var loadComponents = createAsyncThunk("components/load", async () => {
86
104
  return response;
87
105
  });
88
106
 
89
- // src/store/store.ts
90
- var initialState = {
91
- data: [],
92
- unpublishedData: [],
93
- loadStatus: "idle",
94
- styles: {},
95
- createdThisSession: [],
96
- archivedThisSession: [],
97
- path: [],
98
- currentComponentId: null,
99
- updatedComponentNames: {},
100
- sanitized: {}
101
- };
102
- var SLICE_NAME = "components";
103
- var slice = createSlice({
107
+ // src/store/extensible-slice.ts
108
+ var extraReducersMap = /* @__PURE__ */ new Map();
109
+ function registerComponentsReducer(name, reducer) {
110
+ extraReducersMap.set(`${SLICE_NAME}/${name}`, reducer);
111
+ }
112
+ function createComponentsAction(name) {
113
+ const action = createAction(`${SLICE_NAME}/${name}`);
114
+ return {
115
+ action,
116
+ register(reducer) {
117
+ registerComponentsReducer(name, reducer);
118
+ },
119
+ dispatch(payload) {
120
+ dispatch(action(payload));
121
+ }
122
+ };
123
+ }
124
+ var baseSlice = createSlice({
104
125
  name: SLICE_NAME,
105
126
  initialState,
106
127
  reducers: {
@@ -197,6 +218,21 @@ var slice = createSlice({
197
218
  });
198
219
  }
199
220
  });
221
+ var slice = {
222
+ ...baseSlice,
223
+ reducer(state, action) {
224
+ const nextState = baseSlice.reducer(state, action);
225
+ const extraReducer = extraReducersMap.get(action.type);
226
+ if (!extraReducer || !nextState) {
227
+ return nextState;
228
+ }
229
+ const clonedState = structuredClone(nextState);
230
+ extraReducer(clonedState, action);
231
+ return clonedState;
232
+ }
233
+ };
234
+
235
+ // src/store/store.ts
200
236
  var selectData = (state) => state[SLICE_NAME].data;
201
237
  var selectArchivedThisSession = (state) => state[SLICE_NAME].archivedThisSession;
202
238
  var selectLoadStatus = (state) => state[SLICE_NAME].loadStatus;
@@ -875,7 +911,7 @@ import { __ as __8 } from "@wordpress/i18n";
875
911
  // src/utils/detach-component-instance/detach-component-instance.ts
876
912
  import { getContainer, replaceElement } from "@elementor/editor-elements";
877
913
  import { undoable } from "@elementor/editor-v1-adapters";
878
- import { __dispatch as dispatch, __getState as getState3 } from "@elementor/store";
914
+ import { __dispatch as dispatch2, __getState as getState3 } from "@elementor/store";
879
915
  import { __ as __7 } from "@wordpress/i18n";
880
916
 
881
917
  // src/prop-types/component-instance-overrides-prop-type.ts
@@ -1198,7 +1234,7 @@ async function detachComponentInstance({
1198
1234
  });
1199
1235
  const currentComponentId = selectCurrentComponentId(getState3());
1200
1236
  if (currentComponentId && currentComponentId === editedComponentOnDetach && overridablePropsBeforeDetach) {
1201
- dispatch(
1237
+ dispatch2(
1202
1238
  slice.actions.setOverridableProps({
1203
1239
  componentId: currentComponentId,
1204
1240
  overridableProps: overridablePropsBeforeDetach
@@ -1445,40 +1481,40 @@ function getOverrideValue(overrideProp) {
1445
1481
  }
1446
1482
 
1447
1483
  // src/store/dispatchers.ts
1448
- import { __dispatch as dispatch2, __getStore as getStore } from "@elementor/store";
1484
+ import { __dispatch as dispatch3, __getStore as getStore } from "@elementor/store";
1449
1485
  function safeDispatch() {
1450
1486
  return getStore()?.dispatch;
1451
1487
  }
1452
1488
  var componentsActions = {
1453
1489
  add(components) {
1454
- dispatch2(slice.actions.add(components));
1490
+ dispatch3(slice.actions.add(components));
1455
1491
  },
1456
1492
  load(components) {
1457
- dispatch2(slice.actions.load(components));
1493
+ dispatch3(slice.actions.load(components));
1458
1494
  },
1459
1495
  addUnpublished(component) {
1460
- dispatch2(slice.actions.addUnpublished(component));
1496
+ dispatch3(slice.actions.addUnpublished(component));
1461
1497
  },
1462
1498
  removeUnpublished(uids) {
1463
- dispatch2(slice.actions.removeUnpublished(uids));
1499
+ dispatch3(slice.actions.removeUnpublished(uids));
1464
1500
  },
1465
1501
  resetUnpublished() {
1466
- dispatch2(slice.actions.resetUnpublished());
1502
+ dispatch3(slice.actions.resetUnpublished());
1467
1503
  },
1468
1504
  removeStyles(id) {
1469
- dispatch2(slice.actions.removeStyles({ id }));
1505
+ dispatch3(slice.actions.removeStyles({ id }));
1470
1506
  },
1471
1507
  addStyles(styles) {
1472
- dispatch2(slice.actions.addStyles(styles));
1508
+ dispatch3(slice.actions.addStyles(styles));
1473
1509
  },
1474
1510
  addCreatedThisSession(uid) {
1475
- dispatch2(slice.actions.addCreatedThisSession(uid));
1511
+ dispatch3(slice.actions.addCreatedThisSession(uid));
1476
1512
  },
1477
1513
  removeCreatedThisSession(uid) {
1478
- dispatch2(slice.actions.removeCreatedThisSession(uid));
1514
+ dispatch3(slice.actions.removeCreatedThisSession(uid));
1479
1515
  },
1480
1516
  archive(componentId) {
1481
- dispatch2(slice.actions.archive(componentId));
1517
+ dispatch3(slice.actions.archive(componentId));
1482
1518
  },
1483
1519
  setCurrentComponentId(id) {
1484
1520
  safeDispatch()?.(slice.actions.setCurrentComponentId(id));
@@ -1487,19 +1523,19 @@ var componentsActions = {
1487
1523
  safeDispatch()?.(slice.actions.setPath(path));
1488
1524
  },
1489
1525
  setOverridableProps(componentId, overridableProps) {
1490
- dispatch2(slice.actions.setOverridableProps({ componentId, overridableProps }));
1526
+ dispatch3(slice.actions.setOverridableProps({ componentId, overridableProps }));
1491
1527
  },
1492
1528
  rename(componentUid, name) {
1493
- dispatch2(slice.actions.rename({ componentUid, name }));
1529
+ dispatch3(slice.actions.rename({ componentUid, name }));
1494
1530
  },
1495
1531
  cleanUpdatedComponentNames() {
1496
- dispatch2(slice.actions.cleanUpdatedComponentNames());
1532
+ dispatch3(slice.actions.cleanUpdatedComponentNames());
1497
1533
  },
1498
1534
  updateComponentSanitizedAttribute(componentId, attribute) {
1499
- dispatch2(slice.actions.updateComponentSanitizedAttribute({ componentId, attribute }));
1535
+ dispatch3(slice.actions.updateComponentSanitizedAttribute({ componentId, attribute }));
1500
1536
  },
1501
1537
  resetSanitizedComponents() {
1502
- dispatch2(slice.actions.resetSanitizedComponents());
1538
+ dispatch3(slice.actions.resetSanitizedComponents());
1503
1539
  }
1504
1540
  };
1505
1541
 
@@ -1531,6 +1567,9 @@ var componentsSelectors = {
1531
1567
  getArchivedThisSession() {
1532
1568
  return selectArchivedThisSession(getState4());
1533
1569
  },
1570
+ getCreatedThisSession() {
1571
+ return selectCreatedThisSession(getState4());
1572
+ },
1534
1573
  getComponents() {
1535
1574
  return selectComponents(getState4());
1536
1575
  },
@@ -2167,7 +2206,7 @@ async function getDocumentsMap(ids, cache) {
2167
2206
  }
2168
2207
 
2169
2208
  // src/store/actions/load-components-overridable-props.ts
2170
- import { __dispatch as dispatch3, __getState as getState6 } from "@elementor/store";
2209
+ import { __dispatch as dispatch4, __getState as getState6 } from "@elementor/store";
2171
2210
  function loadComponentsOverridableProps(componentIds) {
2172
2211
  if (!componentIds.length) {
2173
2212
  return;
@@ -2183,7 +2222,7 @@ async function loadComponentOverrides(componentId) {
2183
2222
  if (!overridableProps) {
2184
2223
  return;
2185
2224
  }
2186
- dispatch3(
2225
+ dispatch4(
2187
2226
  slice.actions.setOverridableProps({
2188
2227
  componentId,
2189
2228
  overridableProps
@@ -2192,7 +2231,7 @@ async function loadComponentOverrides(componentId) {
2192
2231
  }
2193
2232
 
2194
2233
  // src/store/actions/load-components-styles.ts
2195
- import { __dispatch as dispatch4, __getState as getState7 } from "@elementor/store";
2234
+ import { __dispatch as dispatch5, __getState as getState7 } from "@elementor/store";
2196
2235
  function loadComponentsStyles(documents) {
2197
2236
  if (!documents.size) {
2198
2237
  return;
@@ -2208,7 +2247,7 @@ function addStyles(documents) {
2208
2247
  const styles = Object.fromEntries(
2209
2248
  [...documents.entries()].map(([id, document]) => [id, extractStylesFromDocument(document)])
2210
2249
  );
2211
- dispatch4(slice.actions.addStyles(styles));
2250
+ dispatch5(slice.actions.addStyles(styles));
2212
2251
  }
2213
2252
  function extractStylesFromDocument(document) {
2214
2253
  if (!document.elements?.length) {
@@ -2626,10 +2665,10 @@ function createComponentModel() {
2626
2665
 
2627
2666
  // src/populate-store.ts
2628
2667
  import { useEffect as useEffect2 } from "react";
2629
- import { __dispatch as dispatch5 } from "@elementor/store";
2668
+ import { __dispatch as dispatch6 } from "@elementor/store";
2630
2669
  function PopulateStore() {
2631
2670
  useEffect2(() => {
2632
- dispatch5(loadComponents());
2671
+ dispatch6(loadComponents());
2633
2672
  }, []);
2634
2673
  return null;
2635
2674
  }
@@ -2762,10 +2801,10 @@ function blockCircularPaste(args) {
2762
2801
  }
2763
2802
 
2764
2803
  // src/store/actions/remove-component-styles.ts
2765
- import { __dispatch as dispatch6 } from "@elementor/store";
2804
+ import { __dispatch as dispatch7 } from "@elementor/store";
2766
2805
  function removeComponentStyles(id) {
2767
2806
  apiClient.invalidateComponentConfigCache(id);
2768
- dispatch6(slice.actions.removeStyles({ id }));
2807
+ dispatch7(slice.actions.removeStyles({ id }));
2769
2808
  }
2770
2809
 
2771
2810
  // src/store/components-styles-provider.ts
@@ -2932,6 +2971,7 @@ export {
2932
2971
  componentOverridablePropTypeUtil,
2933
2972
  componentsActions,
2934
2973
  componentsSelectors,
2974
+ createComponentsAction,
2935
2975
  filterValidOverridableProps,
2936
2976
  getContainerByOriginId,
2937
2977
  getOverridableProp,
@@ -2941,6 +2981,7 @@ export {
2941
2981
  loadComponentsAssets,
2942
2982
  onElementDrop,
2943
2983
  publishDraftComponentsInPageBeforeSave,
2984
+ registerComponentsReducer,
2944
2985
  resolveOverridePropValue,
2945
2986
  selectOverridableProps,
2946
2987
  selectPath,