@elementor/editor-components 3.35.0-486 → 3.35.0-488
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.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/components/create-component-form/create-component-form.tsx +48 -13
package/dist/index.js
CHANGED
|
@@ -3220,23 +3220,18 @@ function countNestedElements(container) {
|
|
|
3220
3220
|
}
|
|
3221
3221
|
|
|
3222
3222
|
// src/components/create-component-form/create-component-form.tsx
|
|
3223
|
+
var MAX_COMPONENTS = 100;
|
|
3223
3224
|
function CreateComponentForm() {
|
|
3224
3225
|
const [element, setElement] = (0, import_react10.useState)(null);
|
|
3225
3226
|
const [anchorPosition, setAnchorPosition] = (0, import_react10.useState)();
|
|
3227
|
+
const { components } = useComponents();
|
|
3226
3228
|
const eventData = (0, import_react10.useRef)(null);
|
|
3227
3229
|
(0, import_react10.useEffect)(() => {
|
|
3228
3230
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
3229
3231
|
const openPopup = (event) => {
|
|
3230
|
-
const
|
|
3231
|
-
if (
|
|
3232
|
-
(0, import_editor_notifications3.notify)(
|
|
3233
|
-
type: "default",
|
|
3234
|
-
message: (0, import_i18n22.__)(
|
|
3235
|
-
"Components require atomic elements only. Remove widgets to create this component.",
|
|
3236
|
-
"elementor"
|
|
3237
|
-
),
|
|
3238
|
-
id: "non-atomic-element-save-blocked"
|
|
3239
|
-
});
|
|
3232
|
+
const { shouldOpen, notification } = shouldOpenForm(event.detail.element, components?.length ?? 0);
|
|
3233
|
+
if (!shouldOpen) {
|
|
3234
|
+
(0, import_editor_notifications3.notify)(notification);
|
|
3240
3235
|
return;
|
|
3241
3236
|
}
|
|
3242
3237
|
setElement({ element: event.detail.element, elementLabel: (0, import_editor_elements10.getElementLabel)(event.detail.element.id) });
|
|
@@ -3252,7 +3247,7 @@ function CreateComponentForm() {
|
|
|
3252
3247
|
return () => {
|
|
3253
3248
|
window.removeEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup);
|
|
3254
3249
|
};
|
|
3255
|
-
}, []);
|
|
3250
|
+
}, [components?.length]);
|
|
3256
3251
|
const handleSave = async (values) => {
|
|
3257
3252
|
try {
|
|
3258
3253
|
if (!element) {
|
|
@@ -3315,6 +3310,37 @@ function CreateComponentForm() {
|
|
|
3315
3310
|
)
|
|
3316
3311
|
));
|
|
3317
3312
|
}
|
|
3313
|
+
function shouldOpenForm(element, componentsCount) {
|
|
3314
|
+
const nonAtomicElements = findNonAtomicElementsInElement(element);
|
|
3315
|
+
if (nonAtomicElements.length > 0) {
|
|
3316
|
+
return {
|
|
3317
|
+
shouldOpen: false,
|
|
3318
|
+
notification: {
|
|
3319
|
+
type: "default",
|
|
3320
|
+
message: (0, import_i18n22.__)(
|
|
3321
|
+
"Components require atomic elements only. Remove widgets to create this component.",
|
|
3322
|
+
"elementor"
|
|
3323
|
+
),
|
|
3324
|
+
id: "non-atomic-element-save-blocked"
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
}
|
|
3328
|
+
if (componentsCount >= MAX_COMPONENTS) {
|
|
3329
|
+
return {
|
|
3330
|
+
shouldOpen: false,
|
|
3331
|
+
notification: {
|
|
3332
|
+
type: "default",
|
|
3333
|
+
/* translators: %s is the maximum number of components */
|
|
3334
|
+
message: (0, import_i18n22.__)(
|
|
3335
|
+
`You've reached the limit of %s components. Please remove an existing one to create a new component.`,
|
|
3336
|
+
"elementor"
|
|
3337
|
+
).replace("%s", MAX_COMPONENTS.toString()),
|
|
3338
|
+
id: "maximum-number-of-components-exceeded"
|
|
3339
|
+
}
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
return { shouldOpen: true, notification: null };
|
|
3343
|
+
}
|
|
3318
3344
|
var FONT_SIZE = "tiny";
|
|
3319
3345
|
var Form2 = ({
|
|
3320
3346
|
initialValues,
|