@elementor/editor-components 4.0.0 → 4.0.2
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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +22 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/api.ts +8 -7
- package/src/store/actions/load-components-overridable-props.ts +5 -22
- package/src/store/extensible-slice.ts +19 -0
package/dist/index.mjs
CHANGED
|
@@ -76,11 +76,12 @@ var apiClient = {
|
|
|
76
76
|
unlockComponent: async (componentId) => await httpService().post(`${BASE_URL}/unlock`, {
|
|
77
77
|
componentId
|
|
78
78
|
}).then((res) => res.data),
|
|
79
|
-
getOverridableProps: async (
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
getOverridableProps: async (componentIds) => await httpService().get(
|
|
80
|
+
`${BASE_URL}/overridable-props`,
|
|
81
|
+
{
|
|
82
|
+
params: { "componentIds[]": componentIds }
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
).then((res) => res.data),
|
|
84
85
|
updateArchivedComponents: async (componentIds, status) => await httpService().post(
|
|
85
86
|
`${BASE_URL}/archive`,
|
|
86
87
|
{
|
|
@@ -180,6 +181,18 @@ var baseSlice = createSlice({
|
|
|
180
181
|
}
|
|
181
182
|
component.overridableProps = payload.overridableProps;
|
|
182
183
|
},
|
|
184
|
+
loadOverridableProps: (state, { payload }) => {
|
|
185
|
+
const componentIds = Object.keys(payload);
|
|
186
|
+
componentIds.forEach((id) => {
|
|
187
|
+
const componentId = Number(id);
|
|
188
|
+
const overridableProps = payload[componentId];
|
|
189
|
+
const component = state.data.find((comp) => comp.id === componentId);
|
|
190
|
+
if (!component || !overridableProps) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
component.overridableProps = overridableProps;
|
|
194
|
+
});
|
|
195
|
+
},
|
|
183
196
|
rename: (state, { payload }) => {
|
|
184
197
|
const component = state.data.find((comp) => comp.uid === payload.componentUid);
|
|
185
198
|
if (!component) {
|
|
@@ -2365,27 +2378,13 @@ async function getDocumentsMap(ids, cache) {
|
|
|
2365
2378
|
|
|
2366
2379
|
// src/store/actions/load-components-overridable-props.ts
|
|
2367
2380
|
import { __dispatch as dispatch4, __getState as getState6 } from "@elementor/store";
|
|
2368
|
-
function loadComponentsOverridableProps(componentIds) {
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
}
|
|
2372
|
-
return Promise.all(componentIds.map(loadComponentOverrides));
|
|
2373
|
-
}
|
|
2374
|
-
async function loadComponentOverrides(componentId) {
|
|
2375
|
-
const isOverridablePropsLoaded = selectIsOverridablePropsLoaded(getState6(), componentId);
|
|
2376
|
-
if (isOverridablePropsLoaded) {
|
|
2381
|
+
async function loadComponentsOverridableProps(componentIds) {
|
|
2382
|
+
const unloadedIds = componentIds.filter((id) => !selectIsOverridablePropsLoaded(getState6(), id));
|
|
2383
|
+
if (!unloadedIds.length) {
|
|
2377
2384
|
return;
|
|
2378
2385
|
}
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
return;
|
|
2382
|
-
}
|
|
2383
|
-
dispatch4(
|
|
2384
|
-
slice.actions.setOverridableProps({
|
|
2385
|
-
componentId,
|
|
2386
|
-
overridableProps
|
|
2387
|
-
})
|
|
2388
|
-
);
|
|
2386
|
+
const { data } = await apiClient.getOverridableProps(unloadedIds);
|
|
2387
|
+
dispatch4(slice.actions.loadOverridableProps(data));
|
|
2389
2388
|
}
|
|
2390
2389
|
|
|
2391
2390
|
// src/store/actions/load-components-styles.ts
|