@elementor/editor-components 3.35.0-485 → 3.35.0-487
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.mjs
CHANGED
|
@@ -3236,23 +3236,18 @@ function countNestedElements(container) {
|
|
|
3236
3236
|
}
|
|
3237
3237
|
|
|
3238
3238
|
// src/components/create-component-form/create-component-form.tsx
|
|
3239
|
+
var MAX_COMPONENTS = 100;
|
|
3239
3240
|
function CreateComponentForm() {
|
|
3240
3241
|
const [element, setElement] = useState8(null);
|
|
3241
3242
|
const [anchorPosition, setAnchorPosition] = useState8();
|
|
3243
|
+
const { components } = useComponents();
|
|
3242
3244
|
const eventData = useRef5(null);
|
|
3243
3245
|
useEffect2(() => {
|
|
3244
3246
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
3245
3247
|
const openPopup = (event) => {
|
|
3246
|
-
const
|
|
3247
|
-
if (
|
|
3248
|
-
notify3(
|
|
3249
|
-
type: "default",
|
|
3250
|
-
message: __22(
|
|
3251
|
-
"Components require atomic elements only. Remove widgets to create this component.",
|
|
3252
|
-
"elementor"
|
|
3253
|
-
),
|
|
3254
|
-
id: "non-atomic-element-save-blocked"
|
|
3255
|
-
});
|
|
3248
|
+
const { shouldOpen, notification } = shouldOpenForm(event.detail.element, components?.length ?? 0);
|
|
3249
|
+
if (!shouldOpen) {
|
|
3250
|
+
notify3(notification);
|
|
3256
3251
|
return;
|
|
3257
3252
|
}
|
|
3258
3253
|
setElement({ element: event.detail.element, elementLabel: getElementLabel(event.detail.element.id) });
|
|
@@ -3268,7 +3263,7 @@ function CreateComponentForm() {
|
|
|
3268
3263
|
return () => {
|
|
3269
3264
|
window.removeEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup);
|
|
3270
3265
|
};
|
|
3271
|
-
}, []);
|
|
3266
|
+
}, [components?.length]);
|
|
3272
3267
|
const handleSave = async (values) => {
|
|
3273
3268
|
try {
|
|
3274
3269
|
if (!element) {
|
|
@@ -3331,6 +3326,37 @@ function CreateComponentForm() {
|
|
|
3331
3326
|
)
|
|
3332
3327
|
));
|
|
3333
3328
|
}
|
|
3329
|
+
function shouldOpenForm(element, componentsCount) {
|
|
3330
|
+
const nonAtomicElements = findNonAtomicElementsInElement(element);
|
|
3331
|
+
if (nonAtomicElements.length > 0) {
|
|
3332
|
+
return {
|
|
3333
|
+
shouldOpen: false,
|
|
3334
|
+
notification: {
|
|
3335
|
+
type: "default",
|
|
3336
|
+
message: __22(
|
|
3337
|
+
"Components require atomic elements only. Remove widgets to create this component.",
|
|
3338
|
+
"elementor"
|
|
3339
|
+
),
|
|
3340
|
+
id: "non-atomic-element-save-blocked"
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
}
|
|
3344
|
+
if (componentsCount >= MAX_COMPONENTS) {
|
|
3345
|
+
return {
|
|
3346
|
+
shouldOpen: false,
|
|
3347
|
+
notification: {
|
|
3348
|
+
type: "default",
|
|
3349
|
+
/* translators: %s is the maximum number of components */
|
|
3350
|
+
message: __22(
|
|
3351
|
+
`You've reached the limit of %s components. Please remove an existing one to create a new component.`,
|
|
3352
|
+
"elementor"
|
|
3353
|
+
).replace("%s", MAX_COMPONENTS.toString()),
|
|
3354
|
+
id: "maximum-number-of-components-exceeded"
|
|
3355
|
+
}
|
|
3356
|
+
};
|
|
3357
|
+
}
|
|
3358
|
+
return { shouldOpen: true, notification: null };
|
|
3359
|
+
}
|
|
3334
3360
|
var FONT_SIZE = "tiny";
|
|
3335
3361
|
var Form2 = ({
|
|
3336
3362
|
initialValues,
|