@elementor/editor-components 3.33.0-131 → 3.33.0-133
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 +167 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/components/components-item.tsx +93 -0
- package/src/components/components-list.tsx +66 -0
- package/src/components/components.tsx +12 -0
- package/src/components/loading-components.tsx +43 -0
- package/src/init.ts +2 -2
- package/src/components/components-tab.tsx +0 -62
package/dist/index.js
CHANGED
|
@@ -37,13 +37,17 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
// src/init.ts
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
39
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
40
|
-
var
|
|
40
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
41
41
|
|
|
42
|
-
// src/components/components
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// src/components/components.tsx
|
|
43
|
+
var React4 = __toESM(require("react"));
|
|
44
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
45
|
+
|
|
46
|
+
// src/components/components-list.tsx
|
|
47
|
+
var React3 = __toESM(require("react"));
|
|
48
|
+
var import_icons2 = require("@elementor/icons");
|
|
49
|
+
var import_ui3 = require("@elementor/ui");
|
|
50
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
47
51
|
|
|
48
52
|
// src/hooks/use-components.ts
|
|
49
53
|
var import_query = require("@elementor/query");
|
|
@@ -66,6 +70,14 @@ var useComponents = () => {
|
|
|
66
70
|
});
|
|
67
71
|
};
|
|
68
72
|
|
|
73
|
+
// src/components/components-item.tsx
|
|
74
|
+
var React = __toESM(require("react"));
|
|
75
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
76
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
77
|
+
var import_icons = require("@elementor/icons");
|
|
78
|
+
var import_ui = require("@elementor/ui");
|
|
79
|
+
var import_i18n = require("@wordpress/i18n");
|
|
80
|
+
|
|
69
81
|
// src/utils/get-container-for-new-element.ts
|
|
70
82
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
71
83
|
var getContainerForNewElement = () => {
|
|
@@ -125,36 +137,48 @@ var createComponentModel = (component) => {
|
|
|
125
137
|
};
|
|
126
138
|
};
|
|
127
139
|
|
|
128
|
-
// src/components/components-
|
|
129
|
-
function ComponentsTab() {
|
|
130
|
-
const { data: components } = useComponents();
|
|
131
|
-
return /* @__PURE__ */ React.createElement(import_ui.List, { sx: { display: "flex", flexDirection: "column", gap: 0.5, px: 2 } }, components?.map((component) => /* @__PURE__ */ React.createElement(ComponentItem, { key: component.id, component })));
|
|
132
|
-
}
|
|
140
|
+
// src/components/components-item.tsx
|
|
133
141
|
var ComponentItem = ({ component }) => {
|
|
134
|
-
const
|
|
142
|
+
const popupState = (0, import_ui.usePopupState)({
|
|
143
|
+
variant: "popover",
|
|
144
|
+
disableAutoFocus: true
|
|
145
|
+
});
|
|
135
146
|
const handleClick = () => {
|
|
136
|
-
addComponentToPage(
|
|
147
|
+
addComponentToPage(component);
|
|
137
148
|
};
|
|
138
|
-
return /* @__PURE__ */ React.createElement(import_ui.
|
|
139
|
-
import_ui.
|
|
149
|
+
return /* @__PURE__ */ React.createElement(import_ui.ListItemButton, { shape: "rounded", sx: { border: "solid 1px", borderColor: "divider", py: 0.5, px: 1 } }, /* @__PURE__ */ React.createElement(import_ui.Box, { sx: { display: "flex", width: "100%", alignItems: "center", gap: 1 }, onClick: handleClick }, /* @__PURE__ */ React.createElement(import_ui.ListItemIcon, { size: "tiny" }, /* @__PURE__ */ React.createElement(import_icons.EyeIcon, { fontSize: "tiny" })), /* @__PURE__ */ React.createElement(
|
|
150
|
+
import_ui.ListItemText,
|
|
151
|
+
{
|
|
152
|
+
primary: /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "caption", sx: { color: "text.primary" } }, component.name)
|
|
153
|
+
}
|
|
154
|
+
)), /* @__PURE__ */ React.createElement(import_ui.IconButton, { size: "tiny", "aria-label": "More actions", ...(0, import_ui.bindTrigger)(popupState) }, /* @__PURE__ */ React.createElement(import_icons.DotsVerticalIcon, { fontSize: "tiny" })), /* @__PURE__ */ React.createElement(
|
|
155
|
+
import_ui.Menu,
|
|
140
156
|
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
...(0, import_ui.bindMenu)(popupState),
|
|
158
|
+
anchorOrigin: {
|
|
159
|
+
vertical: "bottom",
|
|
160
|
+
horizontal: "right"
|
|
161
|
+
},
|
|
162
|
+
transformOrigin: {
|
|
163
|
+
vertical: "top",
|
|
164
|
+
horizontal: "right"
|
|
165
|
+
}
|
|
147
166
|
},
|
|
167
|
+
/* @__PURE__ */ React.createElement(import_editor_ui.MenuListItem, { sx: { minWidth: "160px" } }, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n.__)("Rename", "elementor"))),
|
|
148
168
|
/* @__PURE__ */ React.createElement(
|
|
149
|
-
|
|
169
|
+
import_editor_ui.MenuListItem,
|
|
150
170
|
{
|
|
151
|
-
|
|
152
|
-
|
|
171
|
+
onClick: () => {
|
|
172
|
+
popupState.close();
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
/* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n.__)("Delete", "elementor"))
|
|
153
176
|
)
|
|
154
177
|
));
|
|
155
178
|
};
|
|
156
|
-
var addComponentToPage = (
|
|
179
|
+
var addComponentToPage = (component) => {
|
|
157
180
|
const { container, options } = getContainerForNewElement();
|
|
181
|
+
const model = createComponentModel(component);
|
|
158
182
|
if (!container) {
|
|
159
183
|
throw new Error(`Can't find container to drop new component instance at`);
|
|
160
184
|
}
|
|
@@ -165,14 +189,104 @@ var addComponentToPage = (model) => {
|
|
|
165
189
|
});
|
|
166
190
|
};
|
|
167
191
|
|
|
168
|
-
// src/components/
|
|
192
|
+
// src/components/loading-components.tsx
|
|
169
193
|
var React2 = __toESM(require("react"));
|
|
194
|
+
var import_ui2 = require("@elementor/ui");
|
|
195
|
+
var ROWS_COUNT = 6;
|
|
196
|
+
var rows = Array.from({ length: ROWS_COUNT }, (_, index) => index);
|
|
197
|
+
var LoadingComponents = () => {
|
|
198
|
+
return /* @__PURE__ */ React2.createElement(
|
|
199
|
+
import_ui2.Stack,
|
|
200
|
+
{
|
|
201
|
+
"aria-label": "Loading components",
|
|
202
|
+
gap: 1,
|
|
203
|
+
sx: {
|
|
204
|
+
pointerEvents: "none",
|
|
205
|
+
position: "relative",
|
|
206
|
+
maxHeight: "300px",
|
|
207
|
+
overflow: "hidden",
|
|
208
|
+
"&:after": {
|
|
209
|
+
position: "absolute",
|
|
210
|
+
top: 0,
|
|
211
|
+
content: '""',
|
|
212
|
+
left: 0,
|
|
213
|
+
width: "100%",
|
|
214
|
+
height: "300px",
|
|
215
|
+
background: "linear-gradient(to top, white, transparent)",
|
|
216
|
+
pointerEvents: "none"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
rows.map((row) => /* @__PURE__ */ React2.createElement(
|
|
221
|
+
import_ui2.ListItemButton,
|
|
222
|
+
{
|
|
223
|
+
key: row,
|
|
224
|
+
sx: { border: "solid 1px", borderColor: "divider", py: 0.5, px: 1 },
|
|
225
|
+
shape: "rounded"
|
|
226
|
+
},
|
|
227
|
+
/* @__PURE__ */ React2.createElement(import_ui2.Box, { display: "flex", gap: 1, width: "100%" }, /* @__PURE__ */ React2.createElement(import_ui2.Skeleton, { variant: "text", width: "24px", height: "36px" }), /* @__PURE__ */ React2.createElement(import_ui2.Skeleton, { variant: "text", width: "100%", height: "36px" }))
|
|
228
|
+
))
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// src/components/components-list.tsx
|
|
233
|
+
function ComponentsList() {
|
|
234
|
+
const { data: components, isLoading } = useComponents();
|
|
235
|
+
if (isLoading) {
|
|
236
|
+
return /* @__PURE__ */ React3.createElement(LoadingComponents, null);
|
|
237
|
+
}
|
|
238
|
+
if (!components || components.length === 0) {
|
|
239
|
+
return /* @__PURE__ */ React3.createElement(EmptyState, null);
|
|
240
|
+
}
|
|
241
|
+
return /* @__PURE__ */ React3.createElement(import_ui3.List, { sx: { display: "flex", flexDirection: "column", gap: 0.5, px: 2 } }, components?.map((component) => /* @__PURE__ */ React3.createElement(ComponentItem, { key: component.id, component })));
|
|
242
|
+
}
|
|
243
|
+
var EmptyState = () => {
|
|
244
|
+
return /* @__PURE__ */ React3.createElement(
|
|
245
|
+
import_ui3.Stack,
|
|
246
|
+
{
|
|
247
|
+
alignItems: "center",
|
|
248
|
+
justifyContent: "center",
|
|
249
|
+
height: "100%",
|
|
250
|
+
sx: { px: 2.5, pt: 10 },
|
|
251
|
+
gap: 1.75,
|
|
252
|
+
overflow: "hidden"
|
|
253
|
+
},
|
|
254
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Icon, { fontSize: "large" }, /* @__PURE__ */ React3.createElement(import_icons2.EyeIcon, { fontSize: "large" })),
|
|
255
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, (0, import_i18n2.__)("Text that explains that there are no Components yet.", "elementor")),
|
|
256
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { variant: "caption", align: "center", color: "text.secondary" }, (0, import_i18n2.__)(
|
|
257
|
+
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
258
|
+
"elementor"
|
|
259
|
+
)),
|
|
260
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Divider, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
261
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "left", variant: "caption", color: "text.secondary" }, (0, import_i18n2.__)("To create a component, first design it, then choose one of three options:", "elementor")),
|
|
262
|
+
/* @__PURE__ */ React3.createElement(
|
|
263
|
+
import_ui3.Typography,
|
|
264
|
+
{
|
|
265
|
+
align: "left",
|
|
266
|
+
variant: "caption",
|
|
267
|
+
color: "text.secondary",
|
|
268
|
+
sx: { display: "flex", flexDirection: "column" }
|
|
269
|
+
},
|
|
270
|
+
/* @__PURE__ */ React3.createElement("span", null, (0, import_i18n2.__)("1. Right-click and select Create Component", "elementor")),
|
|
271
|
+
/* @__PURE__ */ React3.createElement("span", null, (0, import_i18n2.__)("2. Use the component icon in the Structure panel", "elementor")),
|
|
272
|
+
/* @__PURE__ */ React3.createElement("span", null, (0, import_i18n2.__)("3. Use the component icon in the Edit panel header", "elementor"))
|
|
273
|
+
)
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// src/components/components.tsx
|
|
278
|
+
var Components = () => {
|
|
279
|
+
return /* @__PURE__ */ React4.createElement(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React4.createElement(ComponentsList, null));
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// src/components/create-component-form/create-component-form.tsx
|
|
283
|
+
var React5 = __toESM(require("react"));
|
|
170
284
|
var import_react2 = require("react");
|
|
171
285
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
var
|
|
175
|
-
var
|
|
286
|
+
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
287
|
+
var import_icons3 = require("@elementor/icons");
|
|
288
|
+
var import_ui4 = require("@elementor/ui");
|
|
289
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
176
290
|
|
|
177
291
|
// src/hooks/use-create-component.ts
|
|
178
292
|
var import_query2 = require("@elementor/query");
|
|
@@ -235,16 +349,16 @@ var validateForm = (values, schema) => {
|
|
|
235
349
|
|
|
236
350
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
237
351
|
var import_schema = require("@elementor/schema");
|
|
238
|
-
var
|
|
352
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
239
353
|
var MIN_NAME_LENGTH = 2;
|
|
240
354
|
var MAX_NAME_LENGTH = 50;
|
|
241
355
|
var createBaseComponentSchema = (existingNames) => {
|
|
242
356
|
return import_schema.z.object({
|
|
243
357
|
componentName: import_schema.z.string().trim().max(
|
|
244
358
|
MAX_NAME_LENGTH,
|
|
245
|
-
(0,
|
|
359
|
+
(0, import_i18n3.__)("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
246
360
|
).refine((value) => !existingNames.includes(value), {
|
|
247
|
-
message: (0,
|
|
361
|
+
message: (0, import_i18n3.__)("Component name already exists", "elementor")
|
|
248
362
|
})
|
|
249
363
|
});
|
|
250
364
|
};
|
|
@@ -252,9 +366,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
252
366
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
253
367
|
return baseSchema.extend({
|
|
254
368
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
255
|
-
message: (0,
|
|
369
|
+
message: (0, import_i18n3.__)("Component name is required.", "elementor")
|
|
256
370
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
257
|
-
message: (0,
|
|
371
|
+
message: (0, import_i18n3.__)("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
258
372
|
})
|
|
259
373
|
});
|
|
260
374
|
};
|
|
@@ -297,13 +411,13 @@ function CreateComponentForm() {
|
|
|
297
411
|
setResultNotification({
|
|
298
412
|
show: true,
|
|
299
413
|
// Translators: %1$s: Component name, %2$s: Component ID
|
|
300
|
-
message: (0,
|
|
414
|
+
message: (0, import_i18n4.__)("Component saved successfully as: %1$s (ID: %2$s)", "elementor").replace("%1$s", values.componentName).replace("%2$s", result.component_id.toString()),
|
|
301
415
|
type: "success"
|
|
302
416
|
});
|
|
303
417
|
resetAndClosePopup();
|
|
304
418
|
},
|
|
305
419
|
onError: () => {
|
|
306
|
-
const errorMessage = (0,
|
|
420
|
+
const errorMessage = (0, import_i18n4.__)("Failed to save component. Please try again.", "elementor");
|
|
307
421
|
setResultNotification({
|
|
308
422
|
show: true,
|
|
309
423
|
message: errorMessage,
|
|
@@ -317,15 +431,15 @@ function CreateComponentForm() {
|
|
|
317
431
|
setElement(null);
|
|
318
432
|
setAnchorPosition(void 0);
|
|
319
433
|
};
|
|
320
|
-
return /* @__PURE__ */
|
|
321
|
-
|
|
434
|
+
return /* @__PURE__ */ React5.createElement(import_editor_ui3.ThemeProvider, null, /* @__PURE__ */ React5.createElement(
|
|
435
|
+
import_ui4.Popover,
|
|
322
436
|
{
|
|
323
437
|
open: element !== null,
|
|
324
438
|
onClose: resetAndClosePopup,
|
|
325
439
|
anchorReference: "anchorPosition",
|
|
326
440
|
anchorPosition
|
|
327
441
|
},
|
|
328
|
-
element !== null && /* @__PURE__ */
|
|
442
|
+
element !== null && /* @__PURE__ */ React5.createElement(
|
|
329
443
|
Form,
|
|
330
444
|
{
|
|
331
445
|
initialValues: { componentName: element.elementLabel },
|
|
@@ -334,8 +448,8 @@ function CreateComponentForm() {
|
|
|
334
448
|
closePopup: resetAndClosePopup
|
|
335
449
|
}
|
|
336
450
|
)
|
|
337
|
-
), /* @__PURE__ */
|
|
338
|
-
|
|
451
|
+
), /* @__PURE__ */ React5.createElement(import_ui4.Snackbar, { open: resultNotification?.show, onClose: () => setResultNotification(null) }, /* @__PURE__ */ React5.createElement(
|
|
452
|
+
import_ui4.Alert,
|
|
339
453
|
{
|
|
340
454
|
onClose: () => setResultNotification(null),
|
|
341
455
|
severity: resultNotification?.type,
|
|
@@ -370,8 +484,8 @@ var Form = ({
|
|
|
370
484
|
handleSave(parsedValues);
|
|
371
485
|
}
|
|
372
486
|
};
|
|
373
|
-
return /* @__PURE__ */
|
|
374
|
-
|
|
487
|
+
return /* @__PURE__ */ React5.createElement(import_ui4.Stack, { alignItems: "start", width: "268px" }, /* @__PURE__ */ React5.createElement(
|
|
488
|
+
import_ui4.Stack,
|
|
375
489
|
{
|
|
376
490
|
direction: "row",
|
|
377
491
|
alignItems: "center",
|
|
@@ -379,10 +493,10 @@ var Form = ({
|
|
|
379
493
|
px: 1.5,
|
|
380
494
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
381
495
|
},
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
), /* @__PURE__ */
|
|
385
|
-
|
|
496
|
+
/* @__PURE__ */ React5.createElement(import_icons3.StarIcon, { fontSize: FONT_SIZE }),
|
|
497
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, (0, import_i18n4.__)("Save as a component", "elementor"))
|
|
498
|
+
), /* @__PURE__ */ React5.createElement(import_ui4.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React5.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React5.createElement(import_ui4.FormLabel, { htmlFor: "component-name", size: "tiny" }, (0, import_i18n4.__)("Name", "elementor"))), /* @__PURE__ */ React5.createElement(import_ui4.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React5.createElement(
|
|
499
|
+
import_ui4.TextField,
|
|
386
500
|
{
|
|
387
501
|
id: "component-name",
|
|
388
502
|
size: FONT_SIZE,
|
|
@@ -393,8 +507,8 @@ var Form = ({
|
|
|
393
507
|
error: Boolean(errors.componentName),
|
|
394
508
|
helperText: errors.componentName
|
|
395
509
|
}
|
|
396
|
-
))), /* @__PURE__ */
|
|
397
|
-
|
|
510
|
+
))), /* @__PURE__ */ React5.createElement(import_ui4.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React5.createElement(import_ui4.Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" }, (0, import_i18n4.__)("Cancel", "elementor")), /* @__PURE__ */ React5.createElement(
|
|
511
|
+
import_ui4.Button,
|
|
398
512
|
{
|
|
399
513
|
onClick: handleSubmit,
|
|
400
514
|
disabled: isSubmitting || !isValid,
|
|
@@ -402,7 +516,7 @@ var Form = ({
|
|
|
402
516
|
color: "primary",
|
|
403
517
|
size: "small"
|
|
404
518
|
},
|
|
405
|
-
isSubmitting ? (0,
|
|
519
|
+
isSubmitting ? (0, import_i18n4.__)("Creating\u2026", "elementor") : (0, import_i18n4.__)("Create", "elementor")
|
|
406
520
|
)));
|
|
407
521
|
};
|
|
408
522
|
|
|
@@ -410,8 +524,8 @@ var Form = ({
|
|
|
410
524
|
function init() {
|
|
411
525
|
(0, import_editor_elements_panel.injectTab)({
|
|
412
526
|
id: "components",
|
|
413
|
-
label: (0,
|
|
414
|
-
component:
|
|
527
|
+
label: (0, import_i18n5.__)("Components", "elementor"),
|
|
528
|
+
component: Components
|
|
415
529
|
});
|
|
416
530
|
(0, import_editor.injectIntoTop)({
|
|
417
531
|
id: "create-component-popup",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/components-tab.tsx","../src/hooks/use-components.ts","../src/api.ts","../src/utils/get-container-for-new-element.ts","../src/components/create-component-form/utils/replace-element-with-component.ts","../src/components/create-component-form/create-component-form.tsx","../src/hooks/use-create-component.ts","../src/components/create-component-form/hooks/use-form.ts","../src/components/create-component-form/utils/component-form-schema.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoTop } from '@elementor/editor';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { __ } from '@wordpress/i18n';\n\nimport { ComponentsTab } from './components/components-tab';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\n\nexport function init() {\n\tinjectTab( {\n\t\tid: 'components',\n\t\tlabel: __( 'Components', 'elementor' ),\n\t\tcomponent: ComponentsTab,\n\t} );\n\n\tinjectIntoTop( {\n\t\tid: 'create-component-popup',\n\t\tcomponent: CreateComponentForm,\n\t} );\n}\n","import * as React from 'react';\nimport { endDragElementFromPanel, startDragElementFromPanel } from '@elementor/editor-canvas';\nimport { dropElement, type DropElementParams } from '@elementor/editor-elements';\nimport { List, ListItem, ListItemButton, ListItemText, Typography } from '@elementor/ui';\n\nimport { useComponents } from '../hooks/use-components';\nimport { type Component } from '../types';\nimport { getContainerForNewElement } from '../utils/get-container-for-new-element';\nimport { createComponentModel } from './create-component-form/utils/replace-element-with-component';\n\nexport function ComponentsTab() {\n\tconst { data: components } = useComponents();\n\n\treturn (\n\t\t<List sx={ { display: 'flex', flexDirection: 'column', gap: 0.5, px: 2 } }>\n\t\t\t{ components?.map( ( component ) => <ComponentItem key={ component.id } component={ component } /> ) }\n\t\t</List>\n\t);\n}\n\nconst ComponentItem = ( { component }: { component: Component } ) => {\n\tconst componentModel = createComponentModel( { id: component.id, name: component.name } );\n\n\tconst handleClick = () => {\n\t\taddComponentToPage( componentModel );\n\t};\n\n\treturn (\n\t\t<ListItem disablePadding>\n\t\t\t<ListItemButton\n\t\t\t\tsx={ { border: '1px solid', borderColor: 'divider', py: 0.5, px: 1 } }\n\t\t\t\tshape=\"rounded\"\n\t\t\t\tonClick={ handleClick }\n\t\t\t\tdraggable\n\t\t\t\tonDragStart={ () => startDragElementFromPanel( componentModel ) }\n\t\t\t\tonDragEnd={ endDragElementFromPanel }\n\t\t\t>\n\t\t\t\t<ListItemText\n\t\t\t\t\tprimary={\n\t\t\t\t\t\t<Typography variant=\"caption\" sx={ { color: 'text.primary' } }>\n\t\t\t\t\t\t\t{ component.name }\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</ListItemButton>\n\t\t</ListItem>\n\t);\n};\n\nconst addComponentToPage = ( model: DropElementParams[ 'model' ] ) => {\n\tconst { container, options } = getContainerForNewElement();\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Can't find container to drop new component instance at` );\n\t}\n\n\tdropElement( {\n\t\tcontainerId: container.id,\n\t\tmodel,\n\t\toptions: { ...options, useHistory: false, scrollIntoView: true },\n\t} );\n};\n","import { useQuery } from '@elementor/query';\n\nimport { apiClient } from '../api';\n\nexport const COMPONENTS_QUERY_KEY = 'components';\n\nexport const useComponents = () => {\n\treturn useQuery( {\n\t\tqueryKey: [ COMPONENTS_QUERY_KEY ],\n\t\tqueryFn: apiClient.get,\n\t\tstaleTime: Infinity,\n\t} );\n};\n","import { type V1ElementModelProps } from '@elementor/editor-elements';\nimport { type HttpResponse, httpService } from '@elementor/http-client';\n\nimport { type Component } from './types';\n\nconst BASE_URL = 'elementor/v1/components';\n\ntype CreateComponentPayload = {\n\tname: string;\n\tcontent: V1ElementModelProps[];\n};\n\ntype GetComponentResponse = Array< Component >;\n\nexport type CreateComponentResponse = {\n\tcomponent_id: number;\n};\n\nexport const apiClient = {\n\tget: () =>\n\t\thttpService()\n\t\t\t.get< HttpResponse< GetComponentResponse > >( `${ BASE_URL }` )\n\t\t\t.then( ( res ) => res.data.data ),\n\tcreate: ( payload: CreateComponentPayload ) =>\n\t\thttpService()\n\t\t\t.post< HttpResponse< CreateComponentResponse > >( `${ BASE_URL }`, payload )\n\t\t\t.then( ( res ) => res.data.data ),\n};\n","import {\n\tgetContainer,\n\tgetCurrentDocumentContainer,\n\tgetSelectedElements,\n\ttype V1Element,\n} from '@elementor/editor-elements';\n\nexport const getContainerForNewElement = (): { container: V1Element | null; options?: { at: number } } => {\n\tconst currentDocumentContainer = getCurrentDocumentContainer();\n\tconst selectedElement = getSelectedElementContainer();\n\n\tlet container, options;\n\n\tif ( selectedElement ) {\n\t\tswitch ( selectedElement.model.get( 'elType' ) ) {\n\t\t\tcase 'widget': {\n\t\t\t\tcontainer = selectedElement?.parent;\n\n\t\t\t\tconst selectedElIndex = selectedElement.view?._index ?? -1;\n\n\t\t\t\tif ( selectedElIndex > -1 ) {\n\t\t\t\t\toptions = { at: selectedElIndex + 1 };\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'section': {\n\t\t\t\tcontainer = selectedElement?.children?.[ 0 ];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tcontainer = selectedElement;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { container: container ?? currentDocumentContainer, options };\n};\n\nfunction getSelectedElementContainer() {\n\tconst selectedElements = getSelectedElements();\n\n\tif ( selectedElements.length !== 1 ) {\n\t\treturn undefined;\n\t}\n\n\treturn getContainer( selectedElements[ 0 ].id );\n}\n","import { replaceElement, type V1Element } from '@elementor/editor-elements';\nimport { numberPropTypeUtil } from '@elementor/editor-props';\n\nimport { type Component } from '../../../types';\n\nexport const replaceElementWithComponent = async ( element: V1Element, component: Component ) => {\n\treplaceElement( {\n\t\tcurrentElement: element,\n\t\tnewElement: createComponentModel( component ),\n\t\twithHistory: false,\n\t} );\n};\n\nexport const createComponentModel = ( component: Component ) => {\n\treturn {\n\t\telType: 'widget',\n\t\twidgetType: 'e-component',\n\t\tsettings: {\n\t\t\tcomponent_id: numberPropTypeUtil.create( component.id ),\n\t\t},\n\t\teditor_settings: {\n\t\t\ttitle: component.name,\n\t\t},\n\t};\n};\n","import * as React from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { getElementLabel, type V1Element } from '@elementor/editor-elements';\nimport { ThemeProvider } from '@elementor/editor-ui';\nimport { StarIcon } from '@elementor/icons';\nimport { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack, TextField, Typography } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type CreateComponentResponse } from '../../api';\nimport { useComponents } from '../../hooks/use-components';\nimport { useCreateComponentMutation } from '../../hooks/use-create-component';\nimport { type ComponentFormValues } from '../../types';\nimport { useForm } from './hooks/use-form';\nimport { createBaseComponentSchema, createSubmitComponentSchema } from './utils/component-form-schema';\nimport { replaceElementWithComponent } from './utils/replace-element-with-component';\n\ntype SaveAsComponentEventData = {\n\telement: V1Element;\n\tanchorPosition: { top: number; left: number };\n};\n\ntype ResultNotification = {\n\tshow: boolean;\n\tmessage: string;\n\ttype: 'success' | 'error';\n};\n\nexport function CreateComponentForm() {\n\tconst [ element, setElement ] = useState< {\n\t\telement: V1Element;\n\t\telementLabel: string;\n\t} | null >( null );\n\n\tconst [ anchorPosition, setAnchorPosition ] = useState< { top: number; left: number } >();\n\n\tconst [ resultNotification, setResultNotification ] = useState< ResultNotification | null >( null );\n\n\tconst { mutate: createComponent, isPending } = useCreateComponentMutation();\n\n\tuseEffect( () => {\n\t\tconst OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';\n\n\t\tconst openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {\n\t\t\tsetElement( { element: event.detail.element, elementLabel: getElementLabel( event.detail.element.id ) } );\n\t\t\tsetAnchorPosition( event.detail.anchorPosition );\n\t\t};\n\n\t\twindow.addEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\t\t};\n\t}, [] );\n\n\tconst handleSave = async ( values: ComponentFormValues ) => {\n\t\tif ( ! element ) {\n\t\t\tthrow new Error( `Can't save element as component: element not found` );\n\t\t}\n\n\t\tcreateComponent(\n\t\t\t{\n\t\t\t\tname: values.componentName,\n\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t},\n\t\t\t{\n\t\t\t\tonSuccess: ( result: CreateComponentResponse ) => {\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\tthrow new Error( `Can't replace element with component: element not found` );\n\t\t\t\t\t}\n\n\t\t\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\t\t\tid: result.component_id,\n\t\t\t\t\t\tname: values.componentName,\n\t\t\t\t\t} );\n\n\t\t\t\t\tsetResultNotification( {\n\t\t\t\t\t\tshow: true,\n\t\t\t\t\t\t// Translators: %1$s: Component name, %2$s: Component ID\n\t\t\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (ID: %2$s)', 'elementor' )\n\t\t\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t\t\t.replace( '%2$s', result.component_id.toString() ),\n\t\t\t\t\t\ttype: 'success',\n\t\t\t\t\t} );\n\n\t\t\t\t\tresetAndClosePopup();\n\t\t\t\t},\n\t\t\t\tonError: () => {\n\t\t\t\t\tconst errorMessage = __( 'Failed to save component. Please try again.', 'elementor' );\n\t\t\t\t\tsetResultNotification( {\n\t\t\t\t\t\tshow: true,\n\t\t\t\t\t\tmessage: errorMessage,\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t} );\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t};\n\n\tconst resetAndClosePopup = () => {\n\t\tsetElement( null );\n\t\tsetAnchorPosition( undefined );\n\t};\n\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<Popover\n\t\t\t\topen={ element !== null }\n\t\t\t\tonClose={ resetAndClosePopup }\n\t\t\t\tanchorReference=\"anchorPosition\"\n\t\t\t\tanchorPosition={ anchorPosition }\n\t\t\t>\n\t\t\t\t{ element !== null && (\n\t\t\t\t\t<Form\n\t\t\t\t\t\tinitialValues={ { componentName: element.elementLabel } }\n\t\t\t\t\t\thandleSave={ handleSave }\n\t\t\t\t\t\tisSubmitting={ isPending }\n\t\t\t\t\t\tclosePopup={ resetAndClosePopup }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Popover>\n\t\t\t<Snackbar open={ resultNotification?.show } onClose={ () => setResultNotification( null ) }>\n\t\t\t\t<Alert\n\t\t\t\t\tonClose={ () => setResultNotification( null ) }\n\t\t\t\t\tseverity={ resultNotification?.type }\n\t\t\t\t\tsx={ { width: '100%' } }\n\t\t\t\t>\n\t\t\t\t\t{ resultNotification?.message }\n\t\t\t\t</Alert>\n\t\t\t</Snackbar>\n\t\t</ThemeProvider>\n\t);\n}\n\nconst FONT_SIZE = 'tiny';\n\nconst Form = ( {\n\tinitialValues,\n\thandleSave,\n\tisSubmitting,\n\tclosePopup,\n}: {\n\tinitialValues: ComponentFormValues;\n\thandleSave: ( values: ComponentFormValues ) => void;\n\tisSubmitting: boolean;\n\tclosePopup: () => void;\n} ) => {\n\tconst { values, errors, isValid, handleChange, validateForm } = useForm< ComponentFormValues >( initialValues );\n\n\tconst { data: components } = useComponents();\n\n\tconst existingComponentNames = useMemo( () => {\n\t\treturn components?.map( ( component ) => component.name ) ?? [];\n\t}, [ components ] );\n\n\tconst changeValidationSchema = useMemo(\n\t\t() => createBaseComponentSchema( existingComponentNames ),\n\t\t[ existingComponentNames ]\n\t);\n\tconst submitValidationSchema = useMemo(\n\t\t() => createSubmitComponentSchema( existingComponentNames ),\n\t\t[ existingComponentNames ]\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst { success, parsedValues } = validateForm( submitValidationSchema );\n\n\t\tif ( success ) {\n\t\t\thandleSave( parsedValues );\n\t\t}\n\t};\n\n\treturn (\n\t\t<Stack alignItems=\"start\" width=\"268px\">\n\t\t\t<Stack\n\t\t\t\tdirection=\"row\"\n\t\t\t\talignItems=\"center\"\n\t\t\t\tpy={ 1 }\n\t\t\t\tpx={ 1.5 }\n\t\t\t\tsx={ { columnGap: 0.5, borderBottom: '1px solid', borderColor: 'divider', width: '100%' } }\n\t\t\t>\n\t\t\t\t<StarIcon fontSize={ FONT_SIZE } />\n\t\t\t\t<Typography variant=\"caption\" sx={ { color: 'text.primary', fontWeight: '500', lineHeight: 1 } }>\n\t\t\t\t\t{ __( 'Save as a component', 'elementor' ) }\n\t\t\t\t</Typography>\n\t\t\t</Stack>\n\t\t\t<Grid container gap={ 0.75 } alignItems=\"start\" p={ 1.5 }>\n\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t<FormLabel htmlFor={ 'component-name' } size=\"tiny\">\n\t\t\t\t\t\t{ __( 'Name', 'elementor' ) }\n\t\t\t\t\t</FormLabel>\n\t\t\t\t</Grid>\n\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t<TextField\n\t\t\t\t\t\tid={ 'component-name' }\n\t\t\t\t\t\tsize={ FONT_SIZE }\n\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\tvalue={ values.componentName }\n\t\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) =>\n\t\t\t\t\t\t\thandleChange( e, 'componentName', changeValidationSchema )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinputProps={ { style: { color: 'text.primary', fontWeight: '600' } } }\n\t\t\t\t\t\terror={ Boolean( errors.componentName ) }\n\t\t\t\t\t\thelperText={ errors.componentName }\n\t\t\t\t\t/>\n\t\t\t\t</Grid>\n\t\t\t</Grid>\n\t\t\t<Stack direction=\"row\" justifyContent=\"flex-end\" alignSelf=\"end\" py={ 1 } px={ 1.5 }>\n\t\t\t\t<Button onClick={ closePopup } disabled={ isSubmitting } color=\"secondary\" variant=\"text\" size=\"small\">\n\t\t\t\t\t{ __( 'Cancel', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\tdisabled={ isSubmitting || ! isValid }\n\t\t\t\t\tvariant=\"contained\"\n\t\t\t\t\tcolor=\"primary\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t>\n\t\t\t\t\t{ isSubmitting ? __( 'Creating…', 'elementor' ) : __( 'Create', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n};\n","import { useMutation, useQueryClient } from '@elementor/query';\n\nimport { apiClient } from '../api';\nimport { COMPONENTS_QUERY_KEY } from './use-components';\n\nexport const useCreateComponentMutation = () => {\n\tconst queryClient = useQueryClient();\n\n\treturn useMutation( {\n\t\tmutationFn: apiClient.create,\n\t\tonSuccess: () => queryClient.invalidateQueries( { queryKey: [ COMPONENTS_QUERY_KEY ] } ),\n\t} );\n};\n","import { useMemo, useState } from 'react';\nimport { type z } from '@elementor/schema';\n\nexport const useForm = < TValues extends Record< string, unknown > >( initialValues: TValues ) => {\n\tconst [ values, setValues ] = useState< TValues >( initialValues );\n\tconst [ errors, setErrors ] = useState< Partial< Record< keyof TValues, string > > >( {} );\n\n\tconst isValid = useMemo( () => {\n\t\treturn ! Object.values( errors ).some( ( error ) => error );\n\t}, [ errors ] );\n\n\tconst handleChange = (\n\t\te: React.ChangeEvent< HTMLInputElement >,\n\t\tfield: keyof TValues,\n\t\tvalidationSchema: z.ZodType< TValues >\n\t) => {\n\t\tconst updated = { ...values, [ field ]: e.target.value };\n\t\tsetValues( updated );\n\n\t\tconst { success, errors: validationErrors } = validateForm( updated, validationSchema );\n\n\t\tif ( ! success ) {\n\t\t\tsetErrors( validationErrors );\n\t\t} else {\n\t\t\tsetErrors( {} );\n\t\t}\n\t};\n\n\tconst validate = (\n\t\tvalidationSchema: z.ZodType< TValues >\n\t): { success: true; parsedValues: TValues } | { success: false; parsedValues?: never } => {\n\t\tconst { success, errors: validationErrors, parsedValues } = validateForm( values, validationSchema );\n\n\t\tif ( ! success ) {\n\t\t\tsetErrors( validationErrors );\n\t\t\treturn { success };\n\t\t}\n\t\tsetErrors( {} );\n\t\treturn { success, parsedValues };\n\t};\n\n\treturn {\n\t\tvalues,\n\t\terrors,\n\t\tisValid,\n\t\thandleChange,\n\t\tvalidateForm: validate,\n\t};\n};\n\nconst validateForm = < TValues extends Record< string, unknown > >(\n\tvalues: TValues,\n\tschema: z.ZodType< TValues >\n):\n\t| { success: false; parsedValues?: never; errors: Partial< Record< keyof TValues, string > > }\n\t| { success: true; parsedValues: TValues; errors?: never } => {\n\tconst result = schema.safeParse( values );\n\n\tif ( result.success ) {\n\t\treturn { success: true, parsedValues: result.data };\n\t}\n\n\tconst errors = {} as Partial< Record< keyof TValues, string > >;\n\n\t( Object.entries( result.error.formErrors.fieldErrors ) as Array< [ keyof TValues, string[] ] > ).forEach(\n\t\t( [ field, error ] ) => {\n\t\t\terrors[ field ] = error[ 0 ];\n\t\t}\n\t);\n\n\treturn { success: false, errors };\n};\n","import { z } from '@elementor/schema';\nimport { __ } from '@wordpress/i18n';\n\nconst MIN_NAME_LENGTH = 2;\nconst MAX_NAME_LENGTH = 50;\n\nexport const createBaseComponentSchema = ( existingNames: string[] ) => {\n\treturn z.object( {\n\t\tcomponentName: z\n\t\t\t.string()\n\t\t\t.trim()\n\t\t\t.max(\n\t\t\t\tMAX_NAME_LENGTH,\n\t\t\t\t__( 'Component name is too long. Please keep it under 50 characters.', 'elementor' )\n\t\t\t)\n\t\t\t.refine( ( value ) => ! existingNames.includes( value ), {\n\t\t\t\tmessage: __( 'Component name already exists', 'elementor' ),\n\t\t\t} ),\n\t} );\n};\n\nexport const createSubmitComponentSchema = ( existingNames: string[] ) => {\n\tconst baseSchema = createBaseComponentSchema( existingNames );\n\n\treturn baseSchema.extend( {\n\t\tcomponentName: baseSchema.shape.componentName\n\t\t\t.refine( ( value ) => value.length > 0, {\n\t\t\t\tmessage: __( 'Component name is required.', 'elementor' ),\n\t\t\t} )\n\t\t\t.refine( ( value ) => value.length >= MIN_NAME_LENGTH, {\n\t\t\t\tmessage: __( 'Component name is too short. Please enter at least 2 characters.', 'elementor' ),\n\t\t\t} ),\n\t} );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;AAC9B,mCAA0B;AAC1B,IAAAA,eAAmB;;;ACFnB,YAAuB;AACvB,2BAAmE;AACnE,IAAAC,0BAAoD;AACpD,gBAAyE;;;ACHzE,mBAAyB;;;ACCzB,yBAA+C;AAI/C,IAAM,WAAW;AAaV,IAAM,YAAY;AAAA,EACxB,KAAK,UACJ,gCAAY,EACV,IAA6C,GAAI,QAAS,EAAG,EAC7D,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC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AAM,gBAAe,YAAW,WAAU,OAAM,IAAK,GAAI,IAAK,OAC9E,qCAAC,qBAAO,SAAU,YAAa,UAAW,cAAe,OAAM,aAAY,SAAQ,QAAO,MAAK,eAC5F,iBAAI,UAAU,WAAY,CAC7B,GACA;AAAA,IAAC;AAAA;AAAA,MACA,SAAU;AAAA,MACV,UAAW,gBAAgB,CAAE;AAAA,MAC7B,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,MAAK;AAAA;AAAA,IAEH,mBAAe,iBAAI,kBAAa,WAAY,QAAI,iBAAI,UAAU,WAAY;AAAA,EAC7E,CACD,CACD;AAEF;;;ANvNO,SAAS,OAAO;AACtB,8CAAW;AAAA,IACV,IAAI;AAAA,IACJ,WAAO,iBAAI,cAAc,WAAY;AAAA,IACrC,WAAW;AAAA,EACZ,CAAE;AAEF,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["import_i18n","import_editor_elements","import_editor_elements","React","import_react","import_editor_elements","import_ui","import_i18n","import_query","validateForm"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/components.tsx","../src/components/components-list.tsx","../src/hooks/use-components.ts","../src/api.ts","../src/components/components-item.tsx","../src/utils/get-container-for-new-element.ts","../src/components/create-component-form/utils/replace-element-with-component.ts","../src/components/loading-components.tsx","../src/components/create-component-form/create-component-form.tsx","../src/hooks/use-create-component.ts","../src/components/create-component-form/hooks/use-form.ts","../src/components/create-component-form/utils/component-form-schema.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoTop } from '@elementor/editor';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { __ } from '@wordpress/i18n';\n\nimport { Components } from './components/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\n\nexport function init() {\n\tinjectTab( {\n\t\tid: 'components',\n\t\tlabel: __( 'Components', 'elementor' ),\n\t\tcomponent: Components,\n\t} );\n\n\tinjectIntoTop( {\n\t\tid: 'create-component-popup',\n\t\tcomponent: CreateComponentForm,\n\t} );\n}\n","import * as React from 'react';\nimport { ThemeProvider } from '@elementor/editor-ui';\n\nimport { ComponentsList } from './components-list';\n\nexport const Components = () => {\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<ComponentsList />\n\t\t</ThemeProvider>\n\t);\n};\n","import * as React from 'react';\nimport { EyeIcon } from '@elementor/icons';\nimport { Divider, Icon, List, Stack, Typography } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { useComponents } from '../hooks/use-components';\nimport { ComponentItem } from './components-item';\nimport { LoadingComponents } from './loading-components';\n\nexport function ComponentsList() {\n\tconst { data: components, isLoading } = useComponents();\n\n\tif ( isLoading ) {\n\t\treturn <LoadingComponents />;\n\t}\n\n\tif ( ! components || components.length === 0 ) {\n\t\treturn <EmptyState />;\n\t}\n\n\treturn (\n\t\t<List sx={ { display: 'flex', flexDirection: 'column', gap: 0.5, px: 2 } }>\n\t\t\t{ components?.map( ( component ) => <ComponentItem key={ component.id } component={ component } /> ) }\n\t\t</List>\n\t);\n}\n\nconst EmptyState = () => {\n\treturn (\n\t\t<Stack\n\t\t\talignItems=\"center\"\n\t\t\tjustifyContent=\"center\"\n\t\t\theight=\"100%\"\n\t\t\tsx={ { px: 2.5, pt: 10 } }\n\t\t\tgap={ 1.75 }\n\t\t\toverflow=\"hidden\"\n\t\t>\n\t\t\t<Icon fontSize=\"large\">\n\t\t\t\t<EyeIcon fontSize=\"large\" />\n\t\t\t</Icon>\n\t\t\t<Typography align=\"center\" variant=\"subtitle2\" color=\"text.secondary\" fontWeight=\"bold\">\n\t\t\t\t{ __( 'Text that explains that there are no Components yet.', 'elementor' ) }\n\t\t\t</Typography>\n\t\t\t<Typography variant=\"caption\" align=\"center\" color=\"text.secondary\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Once you have Components, this is where you can manage them—rearrange, duplicate, rename and delete irrelevant classes.',\n\t\t\t\t\t'elementor'\n\t\t\t\t) }\n\t\t\t</Typography>\n\t\t\t<Divider sx={ { width: '100%' } } color=\"text.secondary\" />\n\t\t\t<Typography align=\"left\" variant=\"caption\" color=\"text.secondary\">\n\t\t\t\t{ __( 'To create a component, first design it, then choose one of three options:', 'elementor' ) }\n\t\t\t</Typography>\n\t\t\t<Typography\n\t\t\t\talign=\"left\"\n\t\t\t\tvariant=\"caption\"\n\t\t\t\tcolor=\"text.secondary\"\n\t\t\t\tsx={ { display: 'flex', flexDirection: 'column' } }\n\t\t\t>\n\t\t\t\t<span>{ __( '1. Right-click and select Create Component', 'elementor' ) }</span>\n\t\t\t\t<span>{ __( '2. Use the component icon in the Structure panel', 'elementor' ) }</span>\n\t\t\t\t<span>{ __( '3. Use the component icon in the Edit panel header', 'elementor' ) }</span>\n\t\t\t</Typography>\n\t\t</Stack>\n\t);\n};\n","import { useQuery } from '@elementor/query';\n\nimport { apiClient } from '../api';\n\nexport const COMPONENTS_QUERY_KEY = 'components';\n\nexport const useComponents = () => {\n\treturn useQuery( {\n\t\tqueryKey: [ COMPONENTS_QUERY_KEY ],\n\t\tqueryFn: apiClient.get,\n\t\tstaleTime: Infinity,\n\t} );\n};\n","import { type V1ElementModelProps } from '@elementor/editor-elements';\nimport { type HttpResponse, httpService } from '@elementor/http-client';\n\nimport { type Component } from './types';\n\nconst BASE_URL = 'elementor/v1/components';\n\ntype CreateComponentPayload = {\n\tname: string;\n\tcontent: V1ElementModelProps[];\n};\n\ntype GetComponentResponse = Array< Component >;\n\nexport type CreateComponentResponse = {\n\tcomponent_id: number;\n};\n\nexport const apiClient = {\n\tget: () =>\n\t\thttpService()\n\t\t\t.get< HttpResponse< GetComponentResponse > >( `${ BASE_URL }` )\n\t\t\t.then( ( res ) => res.data.data ),\n\tcreate: ( payload: CreateComponentPayload ) =>\n\t\thttpService()\n\t\t\t.post< HttpResponse< CreateComponentResponse > >( `${ BASE_URL }`, payload )\n\t\t\t.then( ( res ) => res.data.data ),\n};\n","import * as React from 'react';\nimport { dropElement } from '@elementor/editor-elements';\nimport { MenuListItem } from '@elementor/editor-ui';\nimport { DotsVerticalIcon, EyeIcon } from '@elementor/icons';\nimport {\n\tbindMenu,\n\tbindTrigger,\n\tBox,\n\tIconButton,\n\tListItemButton,\n\tListItemIcon,\n\tListItemText,\n\tMenu,\n\tTypography,\n\tusePopupState,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type Component } from '../types';\nimport { getContainerForNewElement } from '../utils/get-container-for-new-element';\nimport { createComponentModel } from './create-component-form/utils/replace-element-with-component';\n\nexport const ComponentItem = ( { component }: { component: Component } ) => {\n\tconst popupState = usePopupState( {\n\t\tvariant: 'popover',\n\t\tdisableAutoFocus: true,\n\t} );\n\n\tconst handleClick = () => {\n\t\taddComponentToPage( component );\n\t};\n\n\treturn (\n\t\t<ListItemButton shape=\"rounded\" sx={ { border: 'solid 1px', borderColor: 'divider', py: 0.5, px: 1 } }>\n\t\t\t<Box sx={ { display: 'flex', width: '100%', alignItems: 'center', gap: 1 } } onClick={ handleClick }>\n\t\t\t\t<ListItemIcon size=\"tiny\">\n\t\t\t\t\t<EyeIcon fontSize=\"tiny\" />\n\t\t\t\t</ListItemIcon>\n\t\t\t\t<ListItemText\n\t\t\t\t\tprimary={\n\t\t\t\t\t\t<Typography variant=\"caption\" sx={ { color: 'text.primary' } }>\n\t\t\t\t\t\t\t{ component.name }\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</Box>\n\t\t\t<IconButton size=\"tiny\" aria-label=\"More actions\" { ...bindTrigger( popupState ) }>\n\t\t\t\t<DotsVerticalIcon fontSize=\"tiny\" />\n\t\t\t</IconButton>\n\t\t\t<Menu\n\t\t\t\t{ ...bindMenu( popupState ) }\n\t\t\t\tanchorOrigin={ {\n\t\t\t\t\tvertical: 'bottom',\n\t\t\t\t\thorizontal: 'right',\n\t\t\t\t} }\n\t\t\t\ttransformOrigin={ {\n\t\t\t\t\tvertical: 'top',\n\t\t\t\t\thorizontal: 'right',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<MenuListItem sx={ { minWidth: '160px' } }>\n\t\t\t\t\t<Typography variant=\"caption\" sx={ { color: 'text.primary' } }>\n\t\t\t\t\t\t{ __( 'Rename', 'elementor' ) }\n\t\t\t\t\t</Typography>\n\t\t\t\t</MenuListItem>\n\t\t\t\t<MenuListItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tpopupState.close();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Typography variant=\"caption\" sx={ { color: 'error.light' } }>\n\t\t\t\t\t\t{ __( 'Delete', 'elementor' ) }\n\t\t\t\t\t</Typography>\n\t\t\t\t</MenuListItem>\n\t\t\t</Menu>\n\t\t</ListItemButton>\n\t);\n};\n\nconst addComponentToPage = ( component: Component ) => {\n\tconst { container, options } = getContainerForNewElement();\n\tconst model = createComponentModel( component );\n\n\tif ( ! container ) {\n\t\tthrow new Error( `Can't find container to drop new component instance at` );\n\t}\n\n\tdropElement( {\n\t\tcontainerId: container.id,\n\t\tmodel,\n\t\toptions: { ...options, useHistory: false, scrollIntoView: true },\n\t} );\n};\n","import {\n\tgetContainer,\n\tgetCurrentDocumentContainer,\n\tgetSelectedElements,\n\ttype V1Element,\n} from '@elementor/editor-elements';\n\nexport const getContainerForNewElement = (): { container: V1Element | null; options?: { at: number } } => {\n\tconst currentDocumentContainer = getCurrentDocumentContainer();\n\tconst selectedElement = getSelectedElementContainer();\n\n\tlet container, options;\n\n\tif ( selectedElement ) {\n\t\tswitch ( selectedElement.model.get( 'elType' ) ) {\n\t\t\tcase 'widget': {\n\t\t\t\tcontainer = selectedElement?.parent;\n\n\t\t\t\tconst selectedElIndex = selectedElement.view?._index ?? -1;\n\n\t\t\t\tif ( selectedElIndex > -1 ) {\n\t\t\t\t\toptions = { at: selectedElIndex + 1 };\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'section': {\n\t\t\t\tcontainer = selectedElement?.children?.[ 0 ];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tcontainer = selectedElement;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { container: container ?? currentDocumentContainer, options };\n};\n\nfunction getSelectedElementContainer() {\n\tconst selectedElements = getSelectedElements();\n\n\tif ( selectedElements.length !== 1 ) {\n\t\treturn undefined;\n\t}\n\n\treturn getContainer( selectedElements[ 0 ].id );\n}\n","import { replaceElement, type V1Element } from '@elementor/editor-elements';\nimport { numberPropTypeUtil } from '@elementor/editor-props';\n\nimport { type Component } from '../../../types';\n\nexport const replaceElementWithComponent = async ( element: V1Element, component: Component ) => {\n\treplaceElement( {\n\t\tcurrentElement: element,\n\t\tnewElement: createComponentModel( component ),\n\t\twithHistory: false,\n\t} );\n};\n\nexport const createComponentModel = ( component: Component ) => {\n\treturn {\n\t\telType: 'widget',\n\t\twidgetType: 'e-component',\n\t\tsettings: {\n\t\t\tcomponent_id: numberPropTypeUtil.create( component.id ),\n\t\t},\n\t\teditor_settings: {\n\t\t\ttitle: component.name,\n\t\t},\n\t};\n};\n","import * as React from 'react';\nimport { Box, ListItemButton, Skeleton, Stack } from '@elementor/ui';\nconst ROWS_COUNT = 6;\n\nconst rows = Array.from( { length: ROWS_COUNT }, ( _, index ) => index );\n\nexport const LoadingComponents = () => {\n\treturn (\n\t\t<Stack\n\t\t\taria-label=\"Loading components\"\n\t\t\tgap={ 1 }\n\t\t\tsx={ {\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\tposition: 'relative',\n\t\t\t\tmaxHeight: '300px',\n\t\t\t\toverflow: 'hidden',\n\t\t\t\t'&:after': {\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\ttop: 0,\n\t\t\t\t\tcontent: '\"\"',\n\t\t\t\t\tleft: 0,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '300px',\n\t\t\t\t\tbackground: 'linear-gradient(to top, white, transparent)',\n\t\t\t\t\tpointerEvents: 'none',\n\t\t\t\t},\n\t\t\t} }\n\t\t>\n\t\t\t{ rows.map( ( row ) => (\n\t\t\t\t<ListItemButton\n\t\t\t\t\tkey={ row }\n\t\t\t\t\tsx={ { border: 'solid 1px', borderColor: 'divider', py: 0.5, px: 1 } }\n\t\t\t\t\tshape=\"rounded\"\n\t\t\t\t>\n\t\t\t\t\t<Box display=\"flex\" gap={ 1 } width=\"100%\">\n\t\t\t\t\t\t<Skeleton variant=\"text\" width={ '24px' } height={ '36px' } />\n\t\t\t\t\t\t<Skeleton variant=\"text\" width={ '100%' } height={ '36px' } />\n\t\t\t\t\t</Box>\n\t\t\t\t</ListItemButton>\n\t\t\t) ) }\n\t\t</Stack>\n\t);\n};\n","import * as React from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { getElementLabel, type V1Element } from '@elementor/editor-elements';\nimport { ThemeProvider } from '@elementor/editor-ui';\nimport { StarIcon } from '@elementor/icons';\nimport { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack, TextField, Typography } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { type CreateComponentResponse } from '../../api';\nimport { useComponents } from '../../hooks/use-components';\nimport { useCreateComponentMutation } from '../../hooks/use-create-component';\nimport { type ComponentFormValues } from '../../types';\nimport { useForm } from './hooks/use-form';\nimport { createBaseComponentSchema, createSubmitComponentSchema } from './utils/component-form-schema';\nimport { replaceElementWithComponent } from './utils/replace-element-with-component';\n\ntype SaveAsComponentEventData = {\n\telement: V1Element;\n\tanchorPosition: { top: number; left: number };\n};\n\ntype ResultNotification = {\n\tshow: boolean;\n\tmessage: string;\n\ttype: 'success' | 'error';\n};\n\nexport function CreateComponentForm() {\n\tconst [ element, setElement ] = useState< {\n\t\telement: V1Element;\n\t\telementLabel: string;\n\t} | null >( null );\n\n\tconst [ anchorPosition, setAnchorPosition ] = useState< { top: number; left: number } >();\n\n\tconst [ resultNotification, setResultNotification ] = useState< ResultNotification | null >( null );\n\n\tconst { mutate: createComponent, isPending } = useCreateComponentMutation();\n\n\tuseEffect( () => {\n\t\tconst OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';\n\n\t\tconst openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {\n\t\t\tsetElement( { element: event.detail.element, elementLabel: getElementLabel( event.detail.element.id ) } );\n\t\t\tsetAnchorPosition( event.detail.anchorPosition );\n\t\t};\n\n\t\twindow.addEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\t\t};\n\t}, [] );\n\n\tconst handleSave = async ( values: ComponentFormValues ) => {\n\t\tif ( ! element ) {\n\t\t\tthrow new Error( `Can't save element as component: element not found` );\n\t\t}\n\n\t\tcreateComponent(\n\t\t\t{\n\t\t\t\tname: values.componentName,\n\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t},\n\t\t\t{\n\t\t\t\tonSuccess: ( result: CreateComponentResponse ) => {\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\tthrow new Error( `Can't replace element with component: element not found` );\n\t\t\t\t\t}\n\n\t\t\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\t\t\tid: result.component_id,\n\t\t\t\t\t\tname: values.componentName,\n\t\t\t\t\t} );\n\n\t\t\t\t\tsetResultNotification( {\n\t\t\t\t\t\tshow: true,\n\t\t\t\t\t\t// Translators: %1$s: Component name, %2$s: Component ID\n\t\t\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (ID: %2$s)', 'elementor' )\n\t\t\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t\t\t.replace( '%2$s', result.component_id.toString() ),\n\t\t\t\t\t\ttype: 'success',\n\t\t\t\t\t} );\n\n\t\t\t\t\tresetAndClosePopup();\n\t\t\t\t},\n\t\t\t\tonError: () => {\n\t\t\t\t\tconst errorMessage = __( 'Failed to save component. Please try again.', 'elementor' );\n\t\t\t\t\tsetResultNotification( {\n\t\t\t\t\t\tshow: true,\n\t\t\t\t\t\tmessage: errorMessage,\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t} );\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t};\n\n\tconst resetAndClosePopup = () => {\n\t\tsetElement( null );\n\t\tsetAnchorPosition( undefined );\n\t};\n\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<Popover\n\t\t\t\topen={ element !== null }\n\t\t\t\tonClose={ resetAndClosePopup }\n\t\t\t\tanchorReference=\"anchorPosition\"\n\t\t\t\tanchorPosition={ anchorPosition }\n\t\t\t>\n\t\t\t\t{ element !== null && (\n\t\t\t\t\t<Form\n\t\t\t\t\t\tinitialValues={ { componentName: element.elementLabel } }\n\t\t\t\t\t\thandleSave={ handleSave }\n\t\t\t\t\t\tisSubmitting={ isPending }\n\t\t\t\t\t\tclosePopup={ resetAndClosePopup }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Popover>\n\t\t\t<Snackbar open={ resultNotification?.show } onClose={ () => setResultNotification( null ) }>\n\t\t\t\t<Alert\n\t\t\t\t\tonClose={ () => setResultNotification( null ) }\n\t\t\t\t\tseverity={ resultNotification?.type }\n\t\t\t\t\tsx={ { width: '100%' } }\n\t\t\t\t>\n\t\t\t\t\t{ resultNotification?.message }\n\t\t\t\t</Alert>\n\t\t\t</Snackbar>\n\t\t</ThemeProvider>\n\t);\n}\n\nconst FONT_SIZE = 'tiny';\n\nconst Form = ( {\n\tinitialValues,\n\thandleSave,\n\tisSubmitting,\n\tclosePopup,\n}: {\n\tinitialValues: ComponentFormValues;\n\thandleSave: ( values: ComponentFormValues ) => void;\n\tisSubmitting: boolean;\n\tclosePopup: () => void;\n} ) => {\n\tconst { values, errors, isValid, handleChange, validateForm } = useForm< ComponentFormValues >( initialValues );\n\n\tconst { data: components } = useComponents();\n\n\tconst existingComponentNames = useMemo( () => {\n\t\treturn components?.map( ( component ) => component.name ) ?? [];\n\t}, [ components ] );\n\n\tconst changeValidationSchema = useMemo(\n\t\t() => createBaseComponentSchema( existingComponentNames ),\n\t\t[ existingComponentNames ]\n\t);\n\tconst submitValidationSchema = useMemo(\n\t\t() => createSubmitComponentSchema( existingComponentNames ),\n\t\t[ existingComponentNames ]\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst { success, parsedValues } = validateForm( submitValidationSchema );\n\n\t\tif ( success ) {\n\t\t\thandleSave( parsedValues );\n\t\t}\n\t};\n\n\treturn (\n\t\t<Stack alignItems=\"start\" width=\"268px\">\n\t\t\t<Stack\n\t\t\t\tdirection=\"row\"\n\t\t\t\talignItems=\"center\"\n\t\t\t\tpy={ 1 }\n\t\t\t\tpx={ 1.5 }\n\t\t\t\tsx={ { columnGap: 0.5, borderBottom: '1px solid', borderColor: 'divider', width: '100%' } }\n\t\t\t>\n\t\t\t\t<StarIcon fontSize={ FONT_SIZE } />\n\t\t\t\t<Typography variant=\"caption\" sx={ { color: 'text.primary', fontWeight: '500', lineHeight: 1 } }>\n\t\t\t\t\t{ __( 'Save as a component', 'elementor' ) }\n\t\t\t\t</Typography>\n\t\t\t</Stack>\n\t\t\t<Grid container gap={ 0.75 } alignItems=\"start\" p={ 1.5 }>\n\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t<FormLabel htmlFor={ 'component-name' } size=\"tiny\">\n\t\t\t\t\t\t{ __( 'Name', 'elementor' ) }\n\t\t\t\t\t</FormLabel>\n\t\t\t\t</Grid>\n\t\t\t\t<Grid item xs={ 12 }>\n\t\t\t\t\t<TextField\n\t\t\t\t\t\tid={ 'component-name' }\n\t\t\t\t\t\tsize={ FONT_SIZE }\n\t\t\t\t\t\tfullWidth\n\t\t\t\t\t\tvalue={ values.componentName }\n\t\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) =>\n\t\t\t\t\t\t\thandleChange( e, 'componentName', changeValidationSchema )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinputProps={ { style: { color: 'text.primary', fontWeight: '600' } } }\n\t\t\t\t\t\terror={ Boolean( errors.componentName ) }\n\t\t\t\t\t\thelperText={ errors.componentName }\n\t\t\t\t\t/>\n\t\t\t\t</Grid>\n\t\t\t</Grid>\n\t\t\t<Stack direction=\"row\" justifyContent=\"flex-end\" alignSelf=\"end\" py={ 1 } px={ 1.5 }>\n\t\t\t\t<Button onClick={ closePopup } disabled={ isSubmitting } color=\"secondary\" variant=\"text\" size=\"small\">\n\t\t\t\t\t{ __( 'Cancel', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\tdisabled={ isSubmitting || ! isValid }\n\t\t\t\t\tvariant=\"contained\"\n\t\t\t\t\tcolor=\"primary\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t>\n\t\t\t\t\t{ isSubmitting ? __( 'Creating…', 'elementor' ) : __( 'Create', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n};\n","import { useMutation, useQueryClient } from '@elementor/query';\n\nimport { apiClient } from '../api';\nimport { COMPONENTS_QUERY_KEY } from './use-components';\n\nexport const useCreateComponentMutation = () => {\n\tconst queryClient = useQueryClient();\n\n\treturn useMutation( {\n\t\tmutationFn: apiClient.create,\n\t\tonSuccess: () => queryClient.invalidateQueries( { queryKey: [ COMPONENTS_QUERY_KEY ] } ),\n\t} );\n};\n","import { useMemo, useState } from 'react';\nimport { type z } from '@elementor/schema';\n\nexport const useForm = < TValues extends Record< string, unknown > >( initialValues: TValues ) => {\n\tconst [ values, setValues ] = useState< TValues >( initialValues );\n\tconst [ errors, setErrors ] = useState< Partial< Record< keyof TValues, string > > >( {} );\n\n\tconst isValid = useMemo( () => {\n\t\treturn ! Object.values( errors ).some( ( error ) => error );\n\t}, [ errors ] );\n\n\tconst handleChange = (\n\t\te: React.ChangeEvent< HTMLInputElement >,\n\t\tfield: keyof TValues,\n\t\tvalidationSchema: z.ZodType< TValues >\n\t) => {\n\t\tconst updated = { ...values, [ field ]: e.target.value };\n\t\tsetValues( updated );\n\n\t\tconst { success, errors: validationErrors } = validateForm( updated, validationSchema );\n\n\t\tif ( ! success ) {\n\t\t\tsetErrors( validationErrors );\n\t\t} else {\n\t\t\tsetErrors( {} );\n\t\t}\n\t};\n\n\tconst validate = (\n\t\tvalidationSchema: z.ZodType< TValues >\n\t): { success: true; parsedValues: TValues } | { success: false; parsedValues?: never } => {\n\t\tconst { success, errors: validationErrors, parsedValues } = validateForm( values, validationSchema );\n\n\t\tif ( ! success ) {\n\t\t\tsetErrors( validationErrors );\n\t\t\treturn { success };\n\t\t}\n\t\tsetErrors( {} );\n\t\treturn { success, parsedValues };\n\t};\n\n\treturn {\n\t\tvalues,\n\t\terrors,\n\t\tisValid,\n\t\thandleChange,\n\t\tvalidateForm: validate,\n\t};\n};\n\nconst validateForm = < TValues extends Record< string, unknown > >(\n\tvalues: TValues,\n\tschema: z.ZodType< TValues >\n):\n\t| { success: false; parsedValues?: never; errors: Partial< Record< keyof TValues, string > > }\n\t| { success: true; parsedValues: TValues; errors?: never } => {\n\tconst result = schema.safeParse( values );\n\n\tif ( result.success ) {\n\t\treturn { success: true, parsedValues: result.data };\n\t}\n\n\tconst errors = {} as Partial< Record< keyof TValues, string > >;\n\n\t( Object.entries( result.error.formErrors.fieldErrors ) as Array< [ keyof TValues, string[] ] > ).forEach(\n\t\t( [ field, error ] ) => {\n\t\t\terrors[ field ] = error[ 0 ];\n\t\t}\n\t);\n\n\treturn { success: false, errors };\n};\n","import { z } from '@elementor/schema';\nimport { __ } from '@wordpress/i18n';\n\nconst MIN_NAME_LENGTH = 2;\nconst MAX_NAME_LENGTH = 50;\n\nexport const createBaseComponentSchema = ( existingNames: string[] ) => {\n\treturn z.object( {\n\t\tcomponentName: z\n\t\t\t.string()\n\t\t\t.trim()\n\t\t\t.max(\n\t\t\t\tMAX_NAME_LENGTH,\n\t\t\t\t__( 'Component name is too long. Please keep it under 50 characters.', 'elementor' )\n\t\t\t)\n\t\t\t.refine( ( value ) => ! existingNames.includes( value ), {\n\t\t\t\tmessage: __( 'Component name already exists', 'elementor' ),\n\t\t\t} ),\n\t} );\n};\n\nexport const createSubmitComponentSchema = ( existingNames: string[] ) => {\n\tconst baseSchema = createBaseComponentSchema( existingNames );\n\n\treturn baseSchema.extend( {\n\t\tcomponentName: baseSchema.shape.componentName\n\t\t\t.refine( ( value ) => value.length > 0, {\n\t\t\t\tmessage: __( 'Component name is required.', 'elementor' ),\n\t\t\t} )\n\t\t\t.refine( ( value ) => value.length >= MIN_NAME_LENGTH, {\n\t\t\t\tmessage: __( 'Component name is too short. Please enter at least 2 characters.', 'elementor' ),\n\t\t\t} ),\n\t} );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;AAC9B,mCAA0B;AAC1B,IAAAA,eAAmB;;;ACFnB,IAAAC,SAAuB;AACvB,IAAAC,oBAA8B;;;ACD9B,IAAAC,SAAuB;AACvB,IAAAC,gBAAwB;AACxB,IAAAC,aAAuD;AACvD,IAAAC,eAAmB;;;ACHnB,mBAAyB;;;ACCzB,yBAA+C;AAI/C,IAAM,WAAW;AAaV,IAAM,YAAY;AAAA,EACxB,KAAK,UACJ,gCAAY,EACV,IAA6C,GAAI,QAAS,EAAG,EAC7D,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,QAAQ,CAAE,gBACT,gCAAY,EACV,KAAiD,GAAI,QAAS,IAAI,OAAQ,EAC1E,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AACnC;;;ADvBO,IAAM,uBAAuB;AAE7B,IAAM,gBAAgB,MAAM;AAClC,aAAO,uBAAU;AAAA,IAChB,UAAU,CAAE,oBAAqB;AAAA,IACjC,SAAS,UAAU;AAAA,IACnB,WAAW;AAAA,EACZ,CAAE;AACH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BAAgB,YAAY,MAAM,EAAE;AAAA,MACnE,OAAQ,QAAS,OAAO,aAAc;AAAA,MACtC,YAAa,OAAO;AAAA;AAAA,EACrB,CACD,CACD,GACA,qCAAC,oBAAM,WAAU,OAAM,gBAAe,YAAW,WAAU,OAAM,IAAK,GAAI,IAAK,OAC9E,qCAAC,qBAAO,SAAU,YAAa,UAAW,cAAe,OAAM,aAAY,SAAQ,QAAO,MAAK,eAC5F,iBAAI,UAAU,WAAY,CAC7B,GACA;AAAA,IAAC;AAAA;AAAA,MACA,SAAU;AAAA,MACV,UAAW,gBAAgB,CAAE;AAAA,MAC7B,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,MAAK;AAAA;AAAA,IAEH,mBAAe,iBAAI,kBAAa,WAAY,QAAI,iBAAI,UAAU,WAAY;AAAA,EAC7E,CACD,CACD;AAEF;;;ATvNO,SAAS,OAAO;AACtB,8CAAW;AAAA,IACV,IAAI;AAAA,IACJ,WAAO,iBAAI,cAAc,WAAY;AAAA,IACrC,WAAW;AAAA,EACZ,CAAE;AAEF,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["import_i18n","React","import_editor_ui","React","import_icons","import_ui","import_i18n","import_editor_elements","import_editor_elements","React","import_ui","React","import_react","import_editor_elements","import_editor_ui","import_icons","import_ui","import_i18n","import_query","import_i18n","validateForm"]}
|