@elementor/editor-components 3.33.0-179 → 3.33.0-181
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 +29 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/components/components-tab/components-item.tsx +2 -49
package/dist/index.js
CHANGED
|
@@ -38,11 +38,11 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
39
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
40
40
|
var import_store8 = require("@elementor/store");
|
|
41
|
-
var
|
|
41
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
42
42
|
|
|
43
43
|
// src/components/components-tab/components.tsx
|
|
44
44
|
var React6 = __toESM(require("react"));
|
|
45
|
-
var
|
|
45
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
46
46
|
|
|
47
47
|
// src/components/components-tab/component-search.tsx
|
|
48
48
|
var React2 = __toESM(require("react"));
|
|
@@ -96,7 +96,7 @@ var ComponentSearch = () => {
|
|
|
96
96
|
var React5 = __toESM(require("react"));
|
|
97
97
|
var import_icons3 = require("@elementor/icons");
|
|
98
98
|
var import_ui4 = require("@elementor/ui");
|
|
99
|
-
var
|
|
99
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
100
100
|
|
|
101
101
|
// src/hooks/use-components.ts
|
|
102
102
|
var import_store3 = require("@elementor/store");
|
|
@@ -192,10 +192,8 @@ var useComponents = () => {
|
|
|
192
192
|
var React3 = __toESM(require("react"));
|
|
193
193
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
194
194
|
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
195
|
-
var import_editor_ui = require("@elementor/editor-ui");
|
|
196
195
|
var import_icons2 = require("@elementor/icons");
|
|
197
196
|
var import_ui2 = require("@elementor/ui");
|
|
198
|
-
var import_i18n2 = require("@wordpress/i18n");
|
|
199
197
|
|
|
200
198
|
// src/utils/get-container-for-new-element.ts
|
|
201
199
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
@@ -259,10 +257,6 @@ var createComponentModel = (component) => {
|
|
|
259
257
|
// src/components/components-tab/components-item.tsx
|
|
260
258
|
var ComponentItem = ({ component }) => {
|
|
261
259
|
const componentModel = createComponentModel({ id: component.id, name: component.name });
|
|
262
|
-
const popupState = (0, import_ui2.usePopupState)({
|
|
263
|
-
variant: "popover",
|
|
264
|
-
disableAutoFocus: true
|
|
265
|
-
});
|
|
266
260
|
const handleClick = () => {
|
|
267
261
|
addComponentToPage(componentModel);
|
|
268
262
|
};
|
|
@@ -280,32 +274,7 @@ var ComponentItem = ({ component }) => {
|
|
|
280
274
|
{
|
|
281
275
|
primary: /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "text.primary" } }, component.name)
|
|
282
276
|
}
|
|
283
|
-
))
|
|
284
|
-
/* @__PURE__ */ React3.createElement(import_ui2.IconButton, { size: "tiny", "aria-label": "More actions", ...(0, import_ui2.bindTrigger)(popupState) }, /* @__PURE__ */ React3.createElement(import_icons2.DotsVerticalIcon, { fontSize: "tiny" })),
|
|
285
|
-
/* @__PURE__ */ React3.createElement(
|
|
286
|
-
import_ui2.Menu,
|
|
287
|
-
{
|
|
288
|
-
...(0, import_ui2.bindMenu)(popupState),
|
|
289
|
-
anchorOrigin: {
|
|
290
|
-
vertical: "bottom",
|
|
291
|
-
horizontal: "right"
|
|
292
|
-
},
|
|
293
|
-
transformOrigin: {
|
|
294
|
-
vertical: "top",
|
|
295
|
-
horizontal: "right"
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
/* @__PURE__ */ React3.createElement(import_editor_ui.MenuListItem, { sx: { minWidth: "160px" } }, /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n2.__)("Rename", "elementor"))),
|
|
299
|
-
/* @__PURE__ */ React3.createElement(
|
|
300
|
-
import_editor_ui.MenuListItem,
|
|
301
|
-
{
|
|
302
|
-
onClick: () => {
|
|
303
|
-
popupState.close();
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
/* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n2.__)("Delete", "elementor"))
|
|
307
|
-
)
|
|
308
|
-
)
|
|
277
|
+
))
|
|
309
278
|
);
|
|
310
279
|
};
|
|
311
280
|
var addComponentToPage = (model) => {
|
|
@@ -387,13 +356,13 @@ var EmptyState = () => {
|
|
|
387
356
|
overflow: "hidden"
|
|
388
357
|
},
|
|
389
358
|
/* @__PURE__ */ React5.createElement(import_ui4.Icon, { fontSize: "large" }, /* @__PURE__ */ React5.createElement(import_icons3.EyeIcon, { fontSize: "large" })),
|
|
390
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, (0,
|
|
391
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", align: "center", color: "text.secondary" }, (0,
|
|
359
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, (0, import_i18n2.__)("Text that explains that there are no Components yet.", "elementor")),
|
|
360
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", align: "center", color: "text.secondary" }, (0, import_i18n2.__)(
|
|
392
361
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
393
362
|
"elementor"
|
|
394
363
|
)),
|
|
395
364
|
/* @__PURE__ */ React5.createElement(import_ui4.Divider, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
396
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "left", variant: "caption", color: "text.secondary" }, (0,
|
|
365
|
+
/* @__PURE__ */ React5.createElement(import_ui4.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")),
|
|
397
366
|
/* @__PURE__ */ React5.createElement(
|
|
398
367
|
import_ui4.Typography,
|
|
399
368
|
{
|
|
@@ -402,9 +371,9 @@ var EmptyState = () => {
|
|
|
402
371
|
color: "text.secondary",
|
|
403
372
|
sx: { display: "flex", flexDirection: "column" }
|
|
404
373
|
},
|
|
405
|
-
/* @__PURE__ */ React5.createElement("span", null, (0,
|
|
406
|
-
/* @__PURE__ */ React5.createElement("span", null, (0,
|
|
407
|
-
/* @__PURE__ */ React5.createElement("span", null, (0,
|
|
374
|
+
/* @__PURE__ */ React5.createElement("span", null, (0, import_i18n2.__)("1. Right-click and select Create Component", "elementor")),
|
|
375
|
+
/* @__PURE__ */ React5.createElement("span", null, (0, import_i18n2.__)("2. Use the component icon in the Structure panel", "elementor")),
|
|
376
|
+
/* @__PURE__ */ React5.createElement("span", null, (0, import_i18n2.__)("3. Use the component icon in the Edit panel header", "elementor"))
|
|
408
377
|
)
|
|
409
378
|
);
|
|
410
379
|
};
|
|
@@ -428,7 +397,7 @@ var EmptySearchResult = () => {
|
|
|
428
397
|
width: "100%"
|
|
429
398
|
}
|
|
430
399
|
},
|
|
431
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "inherit" }, (0,
|
|
400
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "inherit" }, (0, import_i18n2.__)("Sorry, nothing matched", "elementor")),
|
|
432
401
|
searchValue && /* @__PURE__ */ React5.createElement(
|
|
433
402
|
import_ui4.Typography,
|
|
434
403
|
{
|
|
@@ -455,8 +424,8 @@ var EmptySearchResult = () => {
|
|
|
455
424
|
/* @__PURE__ */ React5.createElement("span", null, "\u201D.")
|
|
456
425
|
)
|
|
457
426
|
),
|
|
458
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, (0,
|
|
459
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React5.createElement(import_ui4.Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, (0,
|
|
427
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, (0, import_i18n2.__)("Try something else.", "elementor")),
|
|
428
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React5.createElement(import_ui4.Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, (0, import_i18n2.__)("Clear & try again", "elementor")))
|
|
460
429
|
);
|
|
461
430
|
};
|
|
462
431
|
var useFilteredComponents = () => {
|
|
@@ -473,17 +442,17 @@ var useFilteredComponents = () => {
|
|
|
473
442
|
|
|
474
443
|
// src/components/components-tab/components.tsx
|
|
475
444
|
var Components = () => {
|
|
476
|
-
return /* @__PURE__ */ React6.createElement(
|
|
445
|
+
return /* @__PURE__ */ React6.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React6.createElement(SearchProvider, { localStorageKey: "elementor-components-search" }, /* @__PURE__ */ React6.createElement(ComponentSearch, null), /* @__PURE__ */ React6.createElement(ComponentsList, null)));
|
|
477
446
|
};
|
|
478
447
|
|
|
479
448
|
// src/components/create-component-form/create-component-form.tsx
|
|
480
449
|
var React7 = __toESM(require("react"));
|
|
481
450
|
var import_react3 = require("react");
|
|
482
451
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
483
|
-
var
|
|
452
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
484
453
|
var import_icons4 = require("@elementor/icons");
|
|
485
454
|
var import_ui5 = require("@elementor/ui");
|
|
486
|
-
var
|
|
455
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
487
456
|
|
|
488
457
|
// src/hooks/use-create-component.ts
|
|
489
458
|
var import_store5 = require("@elementor/store");
|
|
@@ -553,16 +522,16 @@ var validateForm = (values, schema) => {
|
|
|
553
522
|
|
|
554
523
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
555
524
|
var import_schema = require("@elementor/schema");
|
|
556
|
-
var
|
|
525
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
557
526
|
var MIN_NAME_LENGTH = 2;
|
|
558
527
|
var MAX_NAME_LENGTH = 50;
|
|
559
528
|
var createBaseComponentSchema = (existingNames) => {
|
|
560
529
|
return import_schema.z.object({
|
|
561
530
|
componentName: import_schema.z.string().trim().max(
|
|
562
531
|
MAX_NAME_LENGTH,
|
|
563
|
-
(0,
|
|
532
|
+
(0, import_i18n3.__)("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
564
533
|
).refine((value) => !existingNames.includes(value), {
|
|
565
|
-
message: (0,
|
|
534
|
+
message: (0, import_i18n3.__)("Component name already exists", "elementor")
|
|
566
535
|
})
|
|
567
536
|
});
|
|
568
537
|
};
|
|
@@ -570,9 +539,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
570
539
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
571
540
|
return baseSchema.extend({
|
|
572
541
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
573
|
-
message: (0,
|
|
542
|
+
message: (0, import_i18n3.__)("Component name is required.", "elementor")
|
|
574
543
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
575
|
-
message: (0,
|
|
544
|
+
message: (0, import_i18n3.__)("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
576
545
|
})
|
|
577
546
|
});
|
|
578
547
|
};
|
|
@@ -613,12 +582,12 @@ function CreateComponentForm() {
|
|
|
613
582
|
setResultNotification({
|
|
614
583
|
show: true,
|
|
615
584
|
// Translators: %1$s: Component name, %2$s: Component ID
|
|
616
|
-
message: (0,
|
|
585
|
+
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()),
|
|
617
586
|
type: "success"
|
|
618
587
|
});
|
|
619
588
|
resetAndClosePopup();
|
|
620
589
|
} catch {
|
|
621
|
-
const errorMessage = (0,
|
|
590
|
+
const errorMessage = (0, import_i18n4.__)("Failed to save component. Please try again.", "elementor");
|
|
622
591
|
setResultNotification({
|
|
623
592
|
show: true,
|
|
624
593
|
message: errorMessage,
|
|
@@ -630,7 +599,7 @@ function CreateComponentForm() {
|
|
|
630
599
|
setElement(null);
|
|
631
600
|
setAnchorPosition(void 0);
|
|
632
601
|
};
|
|
633
|
-
return /* @__PURE__ */ React7.createElement(
|
|
602
|
+
return /* @__PURE__ */ React7.createElement(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React7.createElement(
|
|
634
603
|
import_ui5.Popover,
|
|
635
604
|
{
|
|
636
605
|
open: element !== null,
|
|
@@ -693,8 +662,8 @@ var Form = ({
|
|
|
693
662
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
694
663
|
},
|
|
695
664
|
/* @__PURE__ */ React7.createElement(import_icons4.StarIcon, { fontSize: FONT_SIZE }),
|
|
696
|
-
/* @__PURE__ */ React7.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, (0,
|
|
697
|
-
), /* @__PURE__ */ React7.createElement(import_ui5.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(import_ui5.FormLabel, { htmlFor: "component-name", size: "tiny" }, (0,
|
|
665
|
+
/* @__PURE__ */ React7.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, (0, import_i18n4.__)("Save as a component", "elementor"))
|
|
666
|
+
), /* @__PURE__ */ React7.createElement(import_ui5.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(import_ui5.FormLabel, { htmlFor: "component-name", size: "tiny" }, (0, import_i18n4.__)("Name", "elementor"))), /* @__PURE__ */ React7.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(
|
|
698
667
|
import_ui5.TextField,
|
|
699
668
|
{
|
|
700
669
|
id: "component-name",
|
|
@@ -706,7 +675,7 @@ var Form = ({
|
|
|
706
675
|
error: Boolean(errors.componentName),
|
|
707
676
|
helperText: errors.componentName
|
|
708
677
|
}
|
|
709
|
-
))), /* @__PURE__ */ React7.createElement(import_ui5.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" }, (0,
|
|
678
|
+
))), /* @__PURE__ */ React7.createElement(import_ui5.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" }, (0, import_i18n4.__)("Cancel", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
710
679
|
import_ui5.Button,
|
|
711
680
|
{
|
|
712
681
|
onClick: handleSubmit,
|
|
@@ -715,7 +684,7 @@ var Form = ({
|
|
|
715
684
|
color: "primary",
|
|
716
685
|
size: "small"
|
|
717
686
|
},
|
|
718
|
-
isSubmitting ? (0,
|
|
687
|
+
isSubmitting ? (0, import_i18n4.__)("Creating\u2026", "elementor") : (0, import_i18n4.__)("Create", "elementor")
|
|
719
688
|
)));
|
|
720
689
|
};
|
|
721
690
|
|
|
@@ -734,7 +703,7 @@ function init() {
|
|
|
734
703
|
(0, import_store8.__registerSlice)(slice);
|
|
735
704
|
(0, import_editor_elements_panel.injectTab)({
|
|
736
705
|
id: "components",
|
|
737
|
-
label: (0,
|
|
706
|
+
label: (0, import_i18n5.__)("Components", "elementor"),
|
|
738
707
|
component: Components
|
|
739
708
|
});
|
|
740
709
|
(0, import_editor.injectIntoTop)({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/components-tab/components.tsx","../src/components/components-tab/component-search.tsx","../src/components/components-tab/search-provider.tsx","../src/components/components-tab/components-list.tsx","../src/hooks/use-components.ts","../src/store.ts","../src/thunks.ts","../src/api.ts","../src/components/components-tab/components-item.tsx","../src/utils/get-container-for-new-element.ts","../src/components/create-component-form/utils/replace-element-with-component.ts","../src/components/components-tab/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","../src/populate-store.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { PopulateStore } from './populate-store';\nimport { slice } from './store';\n\nexport function init() {\n\tregisterSlice( slice );\n\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\tinjectIntoLogic( {\n\t\tid: 'components-populate-store',\n\t\tcomponent: PopulateStore,\n\t} );\n}\n","import * as React from 'react';\nimport { ThemeProvider } from '@elementor/editor-ui';\n\nimport { ComponentSearch } from './component-search';\nimport { ComponentsList } from './components-list';\nimport { SearchProvider } from './search-provider';\n\nexport const Components = () => {\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<SearchProvider localStorageKey=\"elementor-components-search\">\n\t\t\t\t<ComponentSearch />\n\t\t\t\t<ComponentsList />\n\t\t\t</SearchProvider>\n\t\t</ThemeProvider>\n\t);\n};\n","import * as React from 'react';\nimport { SearchIcon } from '@elementor/icons';\nimport { Box, InputAdornment, Stack, TextField } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { useSearch } from './search-provider';\n\nexport const ComponentSearch = () => {\n\tconst { inputValue, handleChange } = useSearch();\n\n\treturn (\n\t\t<Stack direction=\"row\" gap={ 0.5 } sx={ { width: '100%', px: 2, py: 1.5 } }>\n\t\t\t<Box sx={ { flexGrow: 1 } }>\n\t\t\t\t<TextField\n\t\t\t\t\trole={ 'search' }\n\t\t\t\t\tfullWidth\n\t\t\t\t\tsize={ 'tiny' }\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tplaceholder={ __( 'Search', 'elementor' ) }\n\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => handleChange( e.target.value ) }\n\t\t\t\t\tInputProps={ {\n\t\t\t\t\t\tstartAdornment: (\n\t\t\t\t\t\t\t<InputAdornment position=\"start\">\n\t\t\t\t\t\t\t\t<SearchIcon fontSize={ 'tiny' } />\n\t\t\t\t\t\t\t</InputAdornment>\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</Box>\n\t\t</Stack>\n\t);\n};\n","import * as React from 'react';\nimport { createContext, useContext } from 'react';\nimport { useSearchState, type UseSearchStateResult } from '@elementor/utils';\n\ntype SearchContextType = Pick< UseSearchStateResult, 'handleChange' | 'inputValue' > & {\n\tsearchValue: UseSearchStateResult[ 'debouncedValue' ];\n\tclearSearch: () => void;\n};\n\nconst SearchContext = createContext< SearchContextType | undefined >( undefined );\n\nexport const SearchProvider = ( {\n\tchildren,\n\tlocalStorageKey,\n}: {\n\tchildren: React.ReactNode;\n\tlocalStorageKey: string;\n} ) => {\n\tconst { debouncedValue, handleChange, inputValue } = useSearchState( { localStorageKey } );\n\n\tconst clearSearch = () => {\n\t\thandleChange( '' );\n\t};\n\n\treturn (\n\t\t<SearchContext.Provider value={ { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }>\n\t\t\t{ children }\n\t\t</SearchContext.Provider>\n\t);\n};\n\nexport const useSearch = () => {\n\tconst context = useContext( SearchContext );\n\tif ( ! context ) {\n\t\tthrow new Error( 'useSearch must be used within a SearchProvider' );\n\t}\n\treturn context;\n};\n","import * as React from 'react';\nimport { ComponentsIcon, EyeIcon } from '@elementor/icons';\nimport { Box, Divider, Icon, Link, 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';\nimport { useSearch } from './search-provider';\n\nexport function ComponentsList() {\n\tconst { components, isLoading, searchValue } = useFilteredComponents();\n\n\tif ( isLoading ) {\n\t\treturn <LoadingComponents />;\n\t}\n\tconst isEmpty = ! components || components.length === 0;\n\tif ( isEmpty ) {\n\t\tif ( searchValue.length > 0 ) {\n\t\t\treturn <EmptySearchResult />;\n\t\t}\n\t\treturn <EmptyState />;\n\t}\n\n\treturn (\n\t\t<List sx={ { display: 'flex', flexDirection: 'column', gap: 1, px: 2 } }>\n\t\t\t{ components.map( ( component ) => (\n\t\t\t\t<ComponentItem key={ component.id } component={ component } />\n\t\t\t) ) }\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\nconst EmptySearchResult = () => {\n\tconst { searchValue, clearSearch } = useSearch();\n\treturn (\n\t\t<Stack\n\t\t\tcolor={ 'text.secondary' }\n\t\t\tpt={ 5 }\n\t\t\talignItems=\"center\"\n\t\t\tgap={ 1 }\n\t\t\toverflow={ 'hidden' }\n\t\t\tjustifySelf={ 'center' }\n\t\t>\n\t\t\t<ComponentsIcon />\n\t\t\t<Box\n\t\t\t\tsx={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Typography align=\"center\" variant=\"subtitle2\" color=\"inherit\">\n\t\t\t\t\t{ __( 'Sorry, nothing matched', 'elementor' ) }\n\t\t\t\t</Typography>\n\t\t\t\t{ searchValue && (\n\t\t\t\t\t<Typography\n\t\t\t\t\t\tvariant=\"subtitle2\"\n\t\t\t\t\t\tcolor=\"inherit\"\n\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>“</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: '80%',\n\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ searchValue }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span>”.</span>\n\t\t\t\t\t</Typography>\n\t\t\t\t) }\n\t\t\t</Box>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t{ __( 'Try something else.', 'elementor' ) }\n\t\t\t</Typography>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t<Link color=\"secondary\" variant=\"caption\" component=\"button\" onClick={ clearSearch }>\n\t\t\t\t\t{ __( 'Clear & try again', 'elementor' ) }\n\t\t\t\t</Link>\n\t\t\t</Typography>\n\t\t</Stack>\n\t);\n};\n\nconst useFilteredComponents = () => {\n\tconst { components, isLoading } = useComponents();\n\tconst { searchValue } = useSearch();\n\n\treturn {\n\t\tcomponents: components.filter( ( component ) =>\n\t\t\tcomponent.name.toLowerCase().includes( searchValue.toLowerCase() )\n\t\t),\n\t\tisLoading,\n\t\tsearchValue,\n\t};\n};\n","import { __useSelector as useSelector } from '@elementor/store';\n\nimport { selectComponents, selectLoadIsPending } from '../store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\n};\n","import {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { createComponent, loadComponents } from './thunks';\nimport { type Component } from './types';\n\ntype GetComponentResponse = Component[];\n\ntype Status = 'idle' | 'pending' | 'error';\nexport type ComponentsState = {\n\tdata: Component[];\n\tloadStatus: Status;\n\tcreateStatus: Status;\n};\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tloadStatus: 'idle',\n\tcreateStatus: 'idle',\n};\n\nconst SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload } ) => {\n\t\t\tstate.data.push( payload );\n\t\t},\n\t\tload: ( state, { payload } ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t},\n\textraReducers: ( builder ) => {\n\t\tbuilder.addCase( loadComponents.fulfilled, ( state, { payload }: PayloadAction< GetComponentResponse > ) => {\n\t\t\tstate.data = payload;\n\t\t\tstate.loadStatus = 'idle';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.pending, ( state ) => {\n\t\t\tstate.loadStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.rejected, ( state ) => {\n\t\t\tstate.loadStatus = 'error';\n\t\t} );\n\t\tbuilder.addCase( createComponent.fulfilled, ( state, { payload, meta } ) => {\n\t\t\tstate.createStatus = 'idle';\n\t\t\tstate.data.push( {\n\t\t\t\tid: payload.component_id,\n\t\t\t\tname: meta.arg.name,\n\t\t\t} );\n\t\t} );\n\t\tbuilder.addCase( createComponent.pending, ( state ) => {\n\t\t\tstate.createStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( createComponent.rejected, ( state ) => {\n\t\t\tstate.createStatus = 'error';\n\t\t} );\n\t},\n} );\n\nconst selectData = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].loadStatus;\nconst selectCreateStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].createStatus;\n\nexport const selectComponents = createSelector( selectData, ( data: Component[] ) => data );\nexport const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );\nexport const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );\nexport const selectCreateIsPending = createSelector( selectCreateStatus, ( status ) => status === 'pending' );\nexport const selectCreateIsError = createSelector( selectCreateStatus, ( status ) => status === 'error' );\n","import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';\n\nimport { apiClient, type CreateComponentPayload, type CreateComponentResponse } from './api';\n\nconst createComponent = createAsyncThunk< CreateComponentResponse, CreateComponentPayload >(\n\t'components/create',\n\tasync ( payload: CreateComponentPayload ) => {\n\t\tconst response = await apiClient.create( payload );\n\t\treturn { ...response, name: payload.name };\n\t}\n);\n\nconst loadComponents = createAsyncThunk( 'components/load', async () => {\n\tconst response = await apiClient.get();\n\treturn response;\n} );\n\nexport { createComponent, loadComponents };\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\nexport type 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 { endDragElementFromPanel, startDragElementFromPanel } from '@elementor/editor-canvas';\nimport { dropElement, type DropElementParams } from '@elementor/editor-elements';\nimport { MenuListItem } from '@elementor/editor-ui';\nimport { ComponentsIcon, DotsVerticalIcon } 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 componentModel = createComponentModel( { id: component.id, name: component.name } );\n\n\tconst popupState = usePopupState( {\n\t\tvariant: 'popover',\n\t\tdisableAutoFocus: true,\n\t} );\n\n\tconst handleClick = () => {\n\t\taddComponentToPage( componentModel );\n\t};\n\n\treturn (\n\t\t<ListItemButton\n\t\t\tdraggable\n\t\t\tonDragStart={ () => startDragElementFromPanel( componentModel ) }\n\t\t\tonDragEnd={ endDragElementFromPanel }\n\t\t\tshape=\"rounded\"\n\t\t\tsx={ { border: 'solid 1px', borderColor: 'divider', py: 0.5, px: 1 } }\n\t\t>\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<ComponentsIcon 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 = ( 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 {\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 { useComponents } from '../../hooks/use-components';\nimport { useCreateComponent } 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 { createComponent, isPending } = useCreateComponent();\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\ttry {\n\t\t\tconst result = await createComponent( {\n\t\t\t\tname: values.componentName,\n\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t} );\n\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't replace element with component: element not found` );\n\t\t\t}\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: result.component_id,\n\t\t\t\tname: values.componentName,\n\t\t\t} );\n\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\t// Translators: %1$s: Component name, %2$s: Component ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', result.component_id.toString() ),\n\t\t\t\ttype: 'success',\n\t\t\t} );\n\n\t\t\tresetAndClosePopup();\n\t\t} catch {\n\t\t\tconst errorMessage = __( 'Failed to save component. Please try again.', 'elementor' );\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\tmessage: errorMessage,\n\t\t\t\ttype: 'error',\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 { 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 { __useDispatch as useDispatch, __useSelector as useSelector, type AnyAction } from '@elementor/store';\n\nimport { type CreateComponentPayload } from '../api';\nimport { selectCreateIsError, selectCreateIsPending } from '../store';\nimport { createComponent } from '../thunks';\n\nexport const useCreateComponent = () => {\n\tconst dispatch = useDispatch();\n\tconst isPending = useSelector( selectCreateIsPending );\n\tconst isError = useSelector( selectCreateIsError );\n\n\tconst createComponentAction = async ( payload: CreateComponentPayload ) => {\n\t\tconst result = await dispatch( createComponent( payload ) as unknown as AnyAction );\n\t\treturn result.payload;\n\t};\n\n\treturn {\n\t\tcreateComponent: createComponentAction,\n\t\tisPending,\n\t\tisError,\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","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA+C;AAC/C,mCAA0B;AAC1B,IAAAA,gBAAiD;AACjD,IAAAC,eAAmB;;;ACHnB,IAAAC,SAAuB;AACvB,IAAAC,oBAA8B;;;ACD9B,IAAAC,SAAuB;AACvB,mBAA2B;AAC3B,gBAAsD;AACtD,kBAAmB;;;ACHnB,YAAuB;AACvB,mBAA0C;AAC1C,mBAA0D;AAO1D,IAAM,oBAAgB,4BAAgD,MAAU;AAEzE,IAAM,iBAAiB,CAAE;AAAA,EAC/B;AAAA,EACA;AACD,MAGO;AACN,QAAM,EAAE,gBAAgB,cAAc,WAAW,QAAI,6BAAgB,EAAE,gBAAgB,CAAE;AAEzF,QAAM,cAAc,MAAM;AACzB,iBAAc,EAAG;AAAA,EAClB;AAEA,SACC,oCAAC,cAAc,UAAd,EAAuB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OAAO,gBAAgB,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;;;AIxNA,IAAAC,gBAA0B;AAC1B,IAAAC,gBAAuC;AAIhC,SAAS,gBAAgB;AAC/B,+BAAW,MAAM;AAChB,sBAAAC,YAAU,eAAe,CAAE;AAAA,EAC5B,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;;;AjBDO,SAAS,OAAO;AACtB,oBAAAC,iBAAe,KAAM;AAErB,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;AAEF,qCAAiB;AAAA,IAChB,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["import_store","import_i18n","React","import_editor_ui","React","React","import_icons","import_ui","import_i18n","import_store","import_store","createAsyncThunk","createSlice","createSelector","useSelector","React","import_editor_elements","import_icons","import_ui","import_i18n","import_editor_elements","React","import_ui","React","import_react","import_editor_elements","import_editor_ui","import_icons","import_ui","import_i18n","import_store","dispatch","useDispatch","useSelector","import_react","import_i18n","createComponent","validateForm","import_react","import_store","dispatch","registerSlice"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/components-tab/components.tsx","../src/components/components-tab/component-search.tsx","../src/components/components-tab/search-provider.tsx","../src/components/components-tab/components-list.tsx","../src/hooks/use-components.ts","../src/store.ts","../src/thunks.ts","../src/api.ts","../src/components/components-tab/components-item.tsx","../src/utils/get-container-for-new-element.ts","../src/components/create-component-form/utils/replace-element-with-component.ts","../src/components/components-tab/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","../src/populate-store.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { PopulateStore } from './populate-store';\nimport { slice } from './store';\n\nexport function init() {\n\tregisterSlice( slice );\n\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\tinjectIntoLogic( {\n\t\tid: 'components-populate-store',\n\t\tcomponent: PopulateStore,\n\t} );\n}\n","import * as React from 'react';\nimport { ThemeProvider } from '@elementor/editor-ui';\n\nimport { ComponentSearch } from './component-search';\nimport { ComponentsList } from './components-list';\nimport { SearchProvider } from './search-provider';\n\nexport const Components = () => {\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<SearchProvider localStorageKey=\"elementor-components-search\">\n\t\t\t\t<ComponentSearch />\n\t\t\t\t<ComponentsList />\n\t\t\t</SearchProvider>\n\t\t</ThemeProvider>\n\t);\n};\n","import * as React from 'react';\nimport { SearchIcon } from '@elementor/icons';\nimport { Box, InputAdornment, Stack, TextField } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { useSearch } from './search-provider';\n\nexport const ComponentSearch = () => {\n\tconst { inputValue, handleChange } = useSearch();\n\n\treturn (\n\t\t<Stack direction=\"row\" gap={ 0.5 } sx={ { width: '100%', px: 2, py: 1.5 } }>\n\t\t\t<Box sx={ { flexGrow: 1 } }>\n\t\t\t\t<TextField\n\t\t\t\t\trole={ 'search' }\n\t\t\t\t\tfullWidth\n\t\t\t\t\tsize={ 'tiny' }\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tplaceholder={ __( 'Search', 'elementor' ) }\n\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => handleChange( e.target.value ) }\n\t\t\t\t\tInputProps={ {\n\t\t\t\t\t\tstartAdornment: (\n\t\t\t\t\t\t\t<InputAdornment position=\"start\">\n\t\t\t\t\t\t\t\t<SearchIcon fontSize={ 'tiny' } />\n\t\t\t\t\t\t\t</InputAdornment>\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</Box>\n\t\t</Stack>\n\t);\n};\n","import * as React from 'react';\nimport { createContext, useContext } from 'react';\nimport { useSearchState, type UseSearchStateResult } from '@elementor/utils';\n\ntype SearchContextType = Pick< UseSearchStateResult, 'handleChange' | 'inputValue' > & {\n\tsearchValue: UseSearchStateResult[ 'debouncedValue' ];\n\tclearSearch: () => void;\n};\n\nconst SearchContext = createContext< SearchContextType | undefined >( undefined );\n\nexport const SearchProvider = ( {\n\tchildren,\n\tlocalStorageKey,\n}: {\n\tchildren: React.ReactNode;\n\tlocalStorageKey: string;\n} ) => {\n\tconst { debouncedValue, handleChange, inputValue } = useSearchState( { localStorageKey } );\n\n\tconst clearSearch = () => {\n\t\thandleChange( '' );\n\t};\n\n\treturn (\n\t\t<SearchContext.Provider value={ { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }>\n\t\t\t{ children }\n\t\t</SearchContext.Provider>\n\t);\n};\n\nexport const useSearch = () => {\n\tconst context = useContext( SearchContext );\n\tif ( ! context ) {\n\t\tthrow new Error( 'useSearch must be used within a SearchProvider' );\n\t}\n\treturn context;\n};\n","import * as React from 'react';\nimport { ComponentsIcon, EyeIcon } from '@elementor/icons';\nimport { Box, Divider, Icon, Link, 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';\nimport { useSearch } from './search-provider';\n\nexport function ComponentsList() {\n\tconst { components, isLoading, searchValue } = useFilteredComponents();\n\n\tif ( isLoading ) {\n\t\treturn <LoadingComponents />;\n\t}\n\tconst isEmpty = ! components || components.length === 0;\n\tif ( isEmpty ) {\n\t\tif ( searchValue.length > 0 ) {\n\t\t\treturn <EmptySearchResult />;\n\t\t}\n\t\treturn <EmptyState />;\n\t}\n\n\treturn (\n\t\t<List sx={ { display: 'flex', flexDirection: 'column', gap: 1, px: 2 } }>\n\t\t\t{ components.map( ( component ) => (\n\t\t\t\t<ComponentItem key={ component.id } component={ component } />\n\t\t\t) ) }\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\nconst EmptySearchResult = () => {\n\tconst { searchValue, clearSearch } = useSearch();\n\treturn (\n\t\t<Stack\n\t\t\tcolor={ 'text.secondary' }\n\t\t\tpt={ 5 }\n\t\t\talignItems=\"center\"\n\t\t\tgap={ 1 }\n\t\t\toverflow={ 'hidden' }\n\t\t\tjustifySelf={ 'center' }\n\t\t>\n\t\t\t<ComponentsIcon />\n\t\t\t<Box\n\t\t\t\tsx={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Typography align=\"center\" variant=\"subtitle2\" color=\"inherit\">\n\t\t\t\t\t{ __( 'Sorry, nothing matched', 'elementor' ) }\n\t\t\t\t</Typography>\n\t\t\t\t{ searchValue && (\n\t\t\t\t\t<Typography\n\t\t\t\t\t\tvariant=\"subtitle2\"\n\t\t\t\t\t\tcolor=\"inherit\"\n\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>“</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: '80%',\n\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ searchValue }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span>”.</span>\n\t\t\t\t\t</Typography>\n\t\t\t\t) }\n\t\t\t</Box>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t{ __( 'Try something else.', 'elementor' ) }\n\t\t\t</Typography>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t<Link color=\"secondary\" variant=\"caption\" component=\"button\" onClick={ clearSearch }>\n\t\t\t\t\t{ __( 'Clear & try again', 'elementor' ) }\n\t\t\t\t</Link>\n\t\t\t</Typography>\n\t\t</Stack>\n\t);\n};\n\nconst useFilteredComponents = () => {\n\tconst { components, isLoading } = useComponents();\n\tconst { searchValue } = useSearch();\n\n\treturn {\n\t\tcomponents: components.filter( ( component ) =>\n\t\t\tcomponent.name.toLowerCase().includes( searchValue.toLowerCase() )\n\t\t),\n\t\tisLoading,\n\t\tsearchValue,\n\t};\n};\n","import { __useSelector as useSelector } from '@elementor/store';\n\nimport { selectComponents, selectLoadIsPending } from '../store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\n};\n","import {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { createComponent, loadComponents } from './thunks';\nimport { type Component } from './types';\n\ntype GetComponentResponse = Component[];\n\ntype Status = 'idle' | 'pending' | 'error';\nexport type ComponentsState = {\n\tdata: Component[];\n\tloadStatus: Status;\n\tcreateStatus: Status;\n};\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tloadStatus: 'idle',\n\tcreateStatus: 'idle',\n};\n\nconst SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload } ) => {\n\t\t\tstate.data.push( payload );\n\t\t},\n\t\tload: ( state, { payload } ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t},\n\textraReducers: ( builder ) => {\n\t\tbuilder.addCase( loadComponents.fulfilled, ( state, { payload }: PayloadAction< GetComponentResponse > ) => {\n\t\t\tstate.data = payload;\n\t\t\tstate.loadStatus = 'idle';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.pending, ( state ) => {\n\t\t\tstate.loadStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.rejected, ( state ) => {\n\t\t\tstate.loadStatus = 'error';\n\t\t} );\n\t\tbuilder.addCase( createComponent.fulfilled, ( state, { payload, meta } ) => {\n\t\t\tstate.createStatus = 'idle';\n\t\t\tstate.data.push( {\n\t\t\t\tid: payload.component_id,\n\t\t\t\tname: meta.arg.name,\n\t\t\t} );\n\t\t} );\n\t\tbuilder.addCase( createComponent.pending, ( state ) => {\n\t\t\tstate.createStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( createComponent.rejected, ( state ) => {\n\t\t\tstate.createStatus = 'error';\n\t\t} );\n\t},\n} );\n\nconst selectData = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].loadStatus;\nconst selectCreateStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].createStatus;\n\nexport const selectComponents = createSelector( selectData, ( data: Component[] ) => data );\nexport const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );\nexport const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );\nexport const selectCreateIsPending = createSelector( selectCreateStatus, ( status ) => status === 'pending' );\nexport const selectCreateIsError = createSelector( selectCreateStatus, ( status ) => status === 'error' );\n","import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';\n\nimport { apiClient, type CreateComponentPayload, type CreateComponentResponse } from './api';\n\nconst createComponent = createAsyncThunk< CreateComponentResponse, CreateComponentPayload >(\n\t'components/create',\n\tasync ( payload: CreateComponentPayload ) => {\n\t\tconst response = await apiClient.create( payload );\n\t\treturn { ...response, name: payload.name };\n\t}\n);\n\nconst loadComponents = createAsyncThunk( 'components/load', async () => {\n\tconst response = await apiClient.get();\n\treturn response;\n} );\n\nexport { createComponent, loadComponents };\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\nexport type 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 { endDragElementFromPanel, startDragElementFromPanel } from '@elementor/editor-canvas';\nimport { dropElement, type DropElementParams } from '@elementor/editor-elements';\nimport { ComponentsIcon } from '@elementor/icons';\nimport { Box, ListItemButton, ListItemIcon, ListItemText, Typography } from '@elementor/ui';\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 componentModel = createComponentModel( { id: component.id, name: component.name } );\n\n\tconst handleClick = () => {\n\t\taddComponentToPage( componentModel );\n\t};\n\n\treturn (\n\t\t<ListItemButton\n\t\t\tdraggable\n\t\t\tonDragStart={ () => startDragElementFromPanel( componentModel ) }\n\t\t\tonDragEnd={ endDragElementFromPanel }\n\t\t\tshape=\"rounded\"\n\t\t\tsx={ { border: 'solid 1px', borderColor: 'divider', py: 0.5, px: 1 } }\n\t\t>\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<ComponentsIcon 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</ListItemButton>\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 {\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 { useComponents } from '../../hooks/use-components';\nimport { useCreateComponent } 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 { createComponent, isPending } = useCreateComponent();\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\ttry {\n\t\t\tconst result = await createComponent( {\n\t\t\t\tname: values.componentName,\n\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t} );\n\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't replace element with component: element not found` );\n\t\t\t}\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: result.component_id,\n\t\t\t\tname: values.componentName,\n\t\t\t} );\n\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\t// Translators: %1$s: Component name, %2$s: Component ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', result.component_id.toString() ),\n\t\t\t\ttype: 'success',\n\t\t\t} );\n\n\t\t\tresetAndClosePopup();\n\t\t} catch {\n\t\t\tconst errorMessage = __( 'Failed to save component. Please try again.', 'elementor' );\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\tmessage: errorMessage,\n\t\t\t\ttype: 'error',\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 { 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 { __useDispatch as useDispatch, __useSelector as useSelector, type AnyAction } from '@elementor/store';\n\nimport { type CreateComponentPayload } from '../api';\nimport { selectCreateIsError, selectCreateIsPending } from '../store';\nimport { createComponent } from '../thunks';\n\nexport const useCreateComponent = () => {\n\tconst dispatch = useDispatch();\n\tconst isPending = useSelector( selectCreateIsPending );\n\tconst isError = useSelector( selectCreateIsError );\n\n\tconst createComponentAction = async ( payload: CreateComponentPayload ) => {\n\t\tconst result = await dispatch( createComponent( payload ) as unknown as AnyAction );\n\t\treturn result.payload;\n\t};\n\n\treturn {\n\t\tcreateComponent: createComponentAction,\n\t\tisPending,\n\t\tisError,\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","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA+C;AAC/C,mCAA0B;AAC1B,IAAAA,gBAAiD;AACjD,IAAAC,eAAmB;;;ACHnB,IAAAC,SAAuB;AACvB,uBAA8B;;;ACD9B,IAAAC,SAAuB;AACvB,mBAA2B;AAC3B,gBAAsD;AACtD,kBAAmB;;;ACHnB,YAAuB;AACvB,mBAA0C;AAC1C,mBAA0D;AAO1D,IAAM,oBAAgB,4BAAgD,MAAU;AAEzE,IAAM,iBAAiB,CAAE;AAAA,EAC/B;AAAA,EACA;AACD,MAGO;AACN,QAAM,EAAE,gBAAgB,cAAc,WAAW,QAAI,6BAAgB,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,EAC5B,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;;;AjBDO,SAAS,OAAO;AACtB,oBAAAC,iBAAe,KAAM;AAErB,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;AAEF,qCAAiB;AAAA,IAChB,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["import_store","import_i18n","React","React","React","import_icons","import_ui","import_i18n","import_store","import_store","createAsyncThunk","createSlice","createSelector","useSelector","React","import_editor_elements","import_icons","import_ui","import_editor_elements","React","import_ui","React","import_react","import_editor_elements","import_editor_ui","import_icons","import_ui","import_i18n","import_store","dispatch","useDispatch","useSelector","import_react","import_i18n","createComponent","validateForm","import_react","import_store","dispatch","registerSlice"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { injectIntoLogic, injectIntoTop } from "@elementor/editor";
|
|
3
3
|
import { injectTab } from "@elementor/editor-elements-panel";
|
|
4
4
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
5
|
-
import { __ as
|
|
5
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
6
6
|
|
|
7
7
|
// src/components/components-tab/components.tsx
|
|
8
8
|
import * as React6 from "react";
|
|
@@ -60,7 +60,7 @@ var ComponentSearch = () => {
|
|
|
60
60
|
import * as React5 from "react";
|
|
61
61
|
import { ComponentsIcon as ComponentsIcon2, EyeIcon } from "@elementor/icons";
|
|
62
62
|
import { Box as Box4, Divider, Icon, Link, List, Stack as Stack3, Typography as Typography2 } from "@elementor/ui";
|
|
63
|
-
import { __ as
|
|
63
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
64
64
|
|
|
65
65
|
// src/hooks/use-components.ts
|
|
66
66
|
import { __useSelector as useSelector } from "@elementor/store";
|
|
@@ -159,21 +159,8 @@ var useComponents = () => {
|
|
|
159
159
|
import * as React3 from "react";
|
|
160
160
|
import { endDragElementFromPanel, startDragElementFromPanel } from "@elementor/editor-canvas";
|
|
161
161
|
import { dropElement } from "@elementor/editor-elements";
|
|
162
|
-
import {
|
|
163
|
-
import {
|
|
164
|
-
import {
|
|
165
|
-
bindMenu,
|
|
166
|
-
bindTrigger,
|
|
167
|
-
Box as Box2,
|
|
168
|
-
IconButton,
|
|
169
|
-
ListItemButton,
|
|
170
|
-
ListItemIcon,
|
|
171
|
-
ListItemText,
|
|
172
|
-
Menu,
|
|
173
|
-
Typography,
|
|
174
|
-
usePopupState
|
|
175
|
-
} from "@elementor/ui";
|
|
176
|
-
import { __ as __2 } from "@wordpress/i18n";
|
|
162
|
+
import { ComponentsIcon } from "@elementor/icons";
|
|
163
|
+
import { Box as Box2, ListItemButton, ListItemIcon, ListItemText, Typography } from "@elementor/ui";
|
|
177
164
|
|
|
178
165
|
// src/utils/get-container-for-new-element.ts
|
|
179
166
|
import {
|
|
@@ -241,10 +228,6 @@ var createComponentModel = (component) => {
|
|
|
241
228
|
// src/components/components-tab/components-item.tsx
|
|
242
229
|
var ComponentItem = ({ component }) => {
|
|
243
230
|
const componentModel = createComponentModel({ id: component.id, name: component.name });
|
|
244
|
-
const popupState = usePopupState({
|
|
245
|
-
variant: "popover",
|
|
246
|
-
disableAutoFocus: true
|
|
247
|
-
});
|
|
248
231
|
const handleClick = () => {
|
|
249
232
|
addComponentToPage(componentModel);
|
|
250
233
|
};
|
|
@@ -262,32 +245,7 @@ var ComponentItem = ({ component }) => {
|
|
|
262
245
|
{
|
|
263
246
|
primary: /* @__PURE__ */ React3.createElement(Typography, { variant: "caption", sx: { color: "text.primary" } }, component.name)
|
|
264
247
|
}
|
|
265
|
-
))
|
|
266
|
-
/* @__PURE__ */ React3.createElement(IconButton, { size: "tiny", "aria-label": "More actions", ...bindTrigger(popupState) }, /* @__PURE__ */ React3.createElement(DotsVerticalIcon, { fontSize: "tiny" })),
|
|
267
|
-
/* @__PURE__ */ React3.createElement(
|
|
268
|
-
Menu,
|
|
269
|
-
{
|
|
270
|
-
...bindMenu(popupState),
|
|
271
|
-
anchorOrigin: {
|
|
272
|
-
vertical: "bottom",
|
|
273
|
-
horizontal: "right"
|
|
274
|
-
},
|
|
275
|
-
transformOrigin: {
|
|
276
|
-
vertical: "top",
|
|
277
|
-
horizontal: "right"
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
/* @__PURE__ */ React3.createElement(MenuListItem, { sx: { minWidth: "160px" } }, /* @__PURE__ */ React3.createElement(Typography, { variant: "caption", sx: { color: "text.primary" } }, __2("Rename", "elementor"))),
|
|
281
|
-
/* @__PURE__ */ React3.createElement(
|
|
282
|
-
MenuListItem,
|
|
283
|
-
{
|
|
284
|
-
onClick: () => {
|
|
285
|
-
popupState.close();
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
/* @__PURE__ */ React3.createElement(Typography, { variant: "caption", sx: { color: "error.light" } }, __2("Delete", "elementor"))
|
|
289
|
-
)
|
|
290
|
-
)
|
|
248
|
+
))
|
|
291
249
|
);
|
|
292
250
|
};
|
|
293
251
|
var addComponentToPage = (model) => {
|
|
@@ -369,13 +327,13 @@ var EmptyState = () => {
|
|
|
369
327
|
overflow: "hidden"
|
|
370
328
|
},
|
|
371
329
|
/* @__PURE__ */ React5.createElement(Icon, { fontSize: "large" }, /* @__PURE__ */ React5.createElement(EyeIcon, { fontSize: "large" })),
|
|
372
|
-
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" },
|
|
373
|
-
/* @__PURE__ */ React5.createElement(Typography2, { variant: "caption", align: "center", color: "text.secondary" },
|
|
330
|
+
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, __2("Text that explains that there are no Components yet.", "elementor")),
|
|
331
|
+
/* @__PURE__ */ React5.createElement(Typography2, { variant: "caption", align: "center", color: "text.secondary" }, __2(
|
|
374
332
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
375
333
|
"elementor"
|
|
376
334
|
)),
|
|
377
335
|
/* @__PURE__ */ React5.createElement(Divider, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
378
|
-
/* @__PURE__ */ React5.createElement(Typography2, { align: "left", variant: "caption", color: "text.secondary" },
|
|
336
|
+
/* @__PURE__ */ React5.createElement(Typography2, { align: "left", variant: "caption", color: "text.secondary" }, __2("To create a component, first design it, then choose one of three options:", "elementor")),
|
|
379
337
|
/* @__PURE__ */ React5.createElement(
|
|
380
338
|
Typography2,
|
|
381
339
|
{
|
|
@@ -384,9 +342,9 @@ var EmptyState = () => {
|
|
|
384
342
|
color: "text.secondary",
|
|
385
343
|
sx: { display: "flex", flexDirection: "column" }
|
|
386
344
|
},
|
|
387
|
-
/* @__PURE__ */ React5.createElement("span", null,
|
|
388
|
-
/* @__PURE__ */ React5.createElement("span", null,
|
|
389
|
-
/* @__PURE__ */ React5.createElement("span", null,
|
|
345
|
+
/* @__PURE__ */ React5.createElement("span", null, __2("1. Right-click and select Create Component", "elementor")),
|
|
346
|
+
/* @__PURE__ */ React5.createElement("span", null, __2("2. Use the component icon in the Structure panel", "elementor")),
|
|
347
|
+
/* @__PURE__ */ React5.createElement("span", null, __2("3. Use the component icon in the Edit panel header", "elementor"))
|
|
390
348
|
)
|
|
391
349
|
);
|
|
392
350
|
};
|
|
@@ -410,7 +368,7 @@ var EmptySearchResult = () => {
|
|
|
410
368
|
width: "100%"
|
|
411
369
|
}
|
|
412
370
|
},
|
|
413
|
-
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "subtitle2", color: "inherit" },
|
|
371
|
+
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "subtitle2", color: "inherit" }, __2("Sorry, nothing matched", "elementor")),
|
|
414
372
|
searchValue && /* @__PURE__ */ React5.createElement(
|
|
415
373
|
Typography2,
|
|
416
374
|
{
|
|
@@ -437,8 +395,8 @@ var EmptySearchResult = () => {
|
|
|
437
395
|
/* @__PURE__ */ React5.createElement("span", null, "\u201D.")
|
|
438
396
|
)
|
|
439
397
|
),
|
|
440
|
-
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "caption", color: "inherit" },
|
|
441
|
-
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React5.createElement(Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch },
|
|
398
|
+
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "caption", color: "inherit" }, __2("Try something else.", "elementor")),
|
|
399
|
+
/* @__PURE__ */ React5.createElement(Typography2, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React5.createElement(Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, __2("Clear & try again", "elementor")))
|
|
442
400
|
);
|
|
443
401
|
};
|
|
444
402
|
var useFilteredComponents = () => {
|
|
@@ -465,7 +423,7 @@ import { getElementLabel } from "@elementor/editor-elements";
|
|
|
465
423
|
import { ThemeProvider as ThemeProvider2 } from "@elementor/editor-ui";
|
|
466
424
|
import { StarIcon } from "@elementor/icons";
|
|
467
425
|
import { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack as Stack4, TextField as TextField2, Typography as Typography3 } from "@elementor/ui";
|
|
468
|
-
import { __ as
|
|
426
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
469
427
|
|
|
470
428
|
// src/hooks/use-create-component.ts
|
|
471
429
|
import { __useDispatch as useDispatch, __useSelector as useSelector2 } from "@elementor/store";
|
|
@@ -535,16 +493,16 @@ var validateForm = (values, schema) => {
|
|
|
535
493
|
|
|
536
494
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
537
495
|
import { z } from "@elementor/schema";
|
|
538
|
-
import { __ as
|
|
496
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
539
497
|
var MIN_NAME_LENGTH = 2;
|
|
540
498
|
var MAX_NAME_LENGTH = 50;
|
|
541
499
|
var createBaseComponentSchema = (existingNames) => {
|
|
542
500
|
return z.object({
|
|
543
501
|
componentName: z.string().trim().max(
|
|
544
502
|
MAX_NAME_LENGTH,
|
|
545
|
-
|
|
503
|
+
__3("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
546
504
|
).refine((value) => !existingNames.includes(value), {
|
|
547
|
-
message:
|
|
505
|
+
message: __3("Component name already exists", "elementor")
|
|
548
506
|
})
|
|
549
507
|
});
|
|
550
508
|
};
|
|
@@ -552,9 +510,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
552
510
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
553
511
|
return baseSchema.extend({
|
|
554
512
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
555
|
-
message:
|
|
513
|
+
message: __3("Component name is required.", "elementor")
|
|
556
514
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
557
|
-
message:
|
|
515
|
+
message: __3("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
558
516
|
})
|
|
559
517
|
});
|
|
560
518
|
};
|
|
@@ -595,12 +553,12 @@ function CreateComponentForm() {
|
|
|
595
553
|
setResultNotification({
|
|
596
554
|
show: true,
|
|
597
555
|
// Translators: %1$s: Component name, %2$s: Component ID
|
|
598
|
-
message:
|
|
556
|
+
message: __4("Component saved successfully as: %1$s (ID: %2$s)", "elementor").replace("%1$s", values.componentName).replace("%2$s", result.component_id.toString()),
|
|
599
557
|
type: "success"
|
|
600
558
|
});
|
|
601
559
|
resetAndClosePopup();
|
|
602
560
|
} catch {
|
|
603
|
-
const errorMessage =
|
|
561
|
+
const errorMessage = __4("Failed to save component. Please try again.", "elementor");
|
|
604
562
|
setResultNotification({
|
|
605
563
|
show: true,
|
|
606
564
|
message: errorMessage,
|
|
@@ -675,8 +633,8 @@ var Form = ({
|
|
|
675
633
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
676
634
|
},
|
|
677
635
|
/* @__PURE__ */ React7.createElement(StarIcon, { fontSize: FONT_SIZE }),
|
|
678
|
-
/* @__PURE__ */ React7.createElement(Typography3, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } },
|
|
679
|
-
), /* @__PURE__ */ React7.createElement(Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React7.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(FormLabel, { htmlFor: "component-name", size: "tiny" },
|
|
636
|
+
/* @__PURE__ */ React7.createElement(Typography3, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, __4("Save as a component", "elementor"))
|
|
637
|
+
), /* @__PURE__ */ React7.createElement(Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React7.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(FormLabel, { htmlFor: "component-name", size: "tiny" }, __4("Name", "elementor"))), /* @__PURE__ */ React7.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(
|
|
680
638
|
TextField2,
|
|
681
639
|
{
|
|
682
640
|
id: "component-name",
|
|
@@ -688,7 +646,7 @@ var Form = ({
|
|
|
688
646
|
error: Boolean(errors.componentName),
|
|
689
647
|
helperText: errors.componentName
|
|
690
648
|
}
|
|
691
|
-
))), /* @__PURE__ */ React7.createElement(Stack4, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React7.createElement(Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" },
|
|
649
|
+
))), /* @__PURE__ */ React7.createElement(Stack4, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React7.createElement(Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" }, __4("Cancel", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
692
650
|
Button,
|
|
693
651
|
{
|
|
694
652
|
onClick: handleSubmit,
|
|
@@ -697,7 +655,7 @@ var Form = ({
|
|
|
697
655
|
color: "primary",
|
|
698
656
|
size: "small"
|
|
699
657
|
},
|
|
700
|
-
isSubmitting ?
|
|
658
|
+
isSubmitting ? __4("Creating\u2026", "elementor") : __4("Create", "elementor")
|
|
701
659
|
)));
|
|
702
660
|
};
|
|
703
661
|
|
|
@@ -716,7 +674,7 @@ function init() {
|
|
|
716
674
|
registerSlice(slice);
|
|
717
675
|
injectTab({
|
|
718
676
|
id: "components",
|
|
719
|
-
label:
|
|
677
|
+
label: __5("Components", "elementor"),
|
|
720
678
|
component: Components
|
|
721
679
|
});
|
|
722
680
|
injectIntoTop({
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts","../src/components/components-tab/components.tsx","../src/components/components-tab/component-search.tsx","../src/components/components-tab/search-provider.tsx","../src/components/components-tab/components-list.tsx","../src/hooks/use-components.ts","../src/store.ts","../src/thunks.ts","../src/api.ts","../src/components/components-tab/components-item.tsx","../src/utils/get-container-for-new-element.ts","../src/components/create-component-form/utils/replace-element-with-component.ts","../src/components/components-tab/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","../src/populate-store.ts"],"sourcesContent":["import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { PopulateStore } from './populate-store';\nimport { slice } from './store';\n\nexport function init() {\n\tregisterSlice( slice );\n\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\tinjectIntoLogic( {\n\t\tid: 'components-populate-store',\n\t\tcomponent: PopulateStore,\n\t} );\n}\n","import * as React from 'react';\nimport { ThemeProvider } from '@elementor/editor-ui';\n\nimport { ComponentSearch } from './component-search';\nimport { ComponentsList } from './components-list';\nimport { SearchProvider } from './search-provider';\n\nexport const Components = () => {\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<SearchProvider localStorageKey=\"elementor-components-search\">\n\t\t\t\t<ComponentSearch />\n\t\t\t\t<ComponentsList />\n\t\t\t</SearchProvider>\n\t\t</ThemeProvider>\n\t);\n};\n","import * as React from 'react';\nimport { SearchIcon } from '@elementor/icons';\nimport { Box, InputAdornment, Stack, TextField } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { useSearch } from './search-provider';\n\nexport const ComponentSearch = () => {\n\tconst { inputValue, handleChange } = useSearch();\n\n\treturn (\n\t\t<Stack direction=\"row\" gap={ 0.5 } sx={ { width: '100%', px: 2, py: 1.5 } }>\n\t\t\t<Box sx={ { flexGrow: 1 } }>\n\t\t\t\t<TextField\n\t\t\t\t\trole={ 'search' }\n\t\t\t\t\tfullWidth\n\t\t\t\t\tsize={ 'tiny' }\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tplaceholder={ __( 'Search', 'elementor' ) }\n\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => handleChange( e.target.value ) }\n\t\t\t\t\tInputProps={ {\n\t\t\t\t\t\tstartAdornment: (\n\t\t\t\t\t\t\t<InputAdornment position=\"start\">\n\t\t\t\t\t\t\t\t<SearchIcon fontSize={ 'tiny' } />\n\t\t\t\t\t\t\t</InputAdornment>\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</Box>\n\t\t</Stack>\n\t);\n};\n","import * as React from 'react';\nimport { createContext, useContext } from 'react';\nimport { useSearchState, type UseSearchStateResult } from '@elementor/utils';\n\ntype SearchContextType = Pick< UseSearchStateResult, 'handleChange' | 'inputValue' > & {\n\tsearchValue: UseSearchStateResult[ 'debouncedValue' ];\n\tclearSearch: () => void;\n};\n\nconst SearchContext = createContext< SearchContextType | undefined >( undefined );\n\nexport const SearchProvider = ( {\n\tchildren,\n\tlocalStorageKey,\n}: {\n\tchildren: React.ReactNode;\n\tlocalStorageKey: string;\n} ) => {\n\tconst { debouncedValue, handleChange, inputValue } = useSearchState( { localStorageKey } );\n\n\tconst clearSearch = () => {\n\t\thandleChange( '' );\n\t};\n\n\treturn (\n\t\t<SearchContext.Provider value={ { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }>\n\t\t\t{ children }\n\t\t</SearchContext.Provider>\n\t);\n};\n\nexport const useSearch = () => {\n\tconst context = useContext( SearchContext );\n\tif ( ! context ) {\n\t\tthrow new Error( 'useSearch must be used within a SearchProvider' );\n\t}\n\treturn context;\n};\n","import * as React from 'react';\nimport { ComponentsIcon, EyeIcon } from '@elementor/icons';\nimport { Box, Divider, Icon, Link, 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';\nimport { useSearch } from './search-provider';\n\nexport function ComponentsList() {\n\tconst { components, isLoading, searchValue } = useFilteredComponents();\n\n\tif ( isLoading ) {\n\t\treturn <LoadingComponents />;\n\t}\n\tconst isEmpty = ! components || components.length === 0;\n\tif ( isEmpty ) {\n\t\tif ( searchValue.length > 0 ) {\n\t\t\treturn <EmptySearchResult />;\n\t\t}\n\t\treturn <EmptyState />;\n\t}\n\n\treturn (\n\t\t<List sx={ { display: 'flex', flexDirection: 'column', gap: 1, px: 2 } }>\n\t\t\t{ components.map( ( component ) => (\n\t\t\t\t<ComponentItem key={ component.id } component={ component } />\n\t\t\t) ) }\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\nconst EmptySearchResult = () => {\n\tconst { searchValue, clearSearch } = useSearch();\n\treturn (\n\t\t<Stack\n\t\t\tcolor={ 'text.secondary' }\n\t\t\tpt={ 5 }\n\t\t\talignItems=\"center\"\n\t\t\tgap={ 1 }\n\t\t\toverflow={ 'hidden' }\n\t\t\tjustifySelf={ 'center' }\n\t\t>\n\t\t\t<ComponentsIcon />\n\t\t\t<Box\n\t\t\t\tsx={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Typography align=\"center\" variant=\"subtitle2\" color=\"inherit\">\n\t\t\t\t\t{ __( 'Sorry, nothing matched', 'elementor' ) }\n\t\t\t\t</Typography>\n\t\t\t\t{ searchValue && (\n\t\t\t\t\t<Typography\n\t\t\t\t\t\tvariant=\"subtitle2\"\n\t\t\t\t\t\tcolor=\"inherit\"\n\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>“</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: '80%',\n\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ searchValue }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span>”.</span>\n\t\t\t\t\t</Typography>\n\t\t\t\t) }\n\t\t\t</Box>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t{ __( 'Try something else.', 'elementor' ) }\n\t\t\t</Typography>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t<Link color=\"secondary\" variant=\"caption\" component=\"button\" onClick={ clearSearch }>\n\t\t\t\t\t{ __( 'Clear & try again', 'elementor' ) }\n\t\t\t\t</Link>\n\t\t\t</Typography>\n\t\t</Stack>\n\t);\n};\n\nconst useFilteredComponents = () => {\n\tconst { components, isLoading } = useComponents();\n\tconst { searchValue } = useSearch();\n\n\treturn {\n\t\tcomponents: components.filter( ( component ) =>\n\t\t\tcomponent.name.toLowerCase().includes( searchValue.toLowerCase() )\n\t\t),\n\t\tisLoading,\n\t\tsearchValue,\n\t};\n};\n","import { __useSelector as useSelector } from '@elementor/store';\n\nimport { selectComponents, selectLoadIsPending } from '../store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\n};\n","import {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { createComponent, loadComponents } from './thunks';\nimport { type Component } from './types';\n\ntype GetComponentResponse = Component[];\n\ntype Status = 'idle' | 'pending' | 'error';\nexport type ComponentsState = {\n\tdata: Component[];\n\tloadStatus: Status;\n\tcreateStatus: Status;\n};\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tloadStatus: 'idle',\n\tcreateStatus: 'idle',\n};\n\nconst SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload } ) => {\n\t\t\tstate.data.push( payload );\n\t\t},\n\t\tload: ( state, { payload } ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t},\n\textraReducers: ( builder ) => {\n\t\tbuilder.addCase( loadComponents.fulfilled, ( state, { payload }: PayloadAction< GetComponentResponse > ) => {\n\t\t\tstate.data = payload;\n\t\t\tstate.loadStatus = 'idle';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.pending, ( state ) => {\n\t\t\tstate.loadStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.rejected, ( state ) => {\n\t\t\tstate.loadStatus = 'error';\n\t\t} );\n\t\tbuilder.addCase( createComponent.fulfilled, ( state, { payload, meta } ) => {\n\t\t\tstate.createStatus = 'idle';\n\t\t\tstate.data.push( {\n\t\t\t\tid: payload.component_id,\n\t\t\t\tname: meta.arg.name,\n\t\t\t} );\n\t\t} );\n\t\tbuilder.addCase( createComponent.pending, ( state ) => {\n\t\t\tstate.createStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( createComponent.rejected, ( state ) => {\n\t\t\tstate.createStatus = 'error';\n\t\t} );\n\t},\n} );\n\nconst selectData = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].loadStatus;\nconst selectCreateStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].createStatus;\n\nexport const selectComponents = createSelector( selectData, ( data: Component[] ) => data );\nexport const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );\nexport const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );\nexport const selectCreateIsPending = createSelector( selectCreateStatus, ( status ) => status === 'pending' );\nexport const selectCreateIsError = createSelector( selectCreateStatus, ( status ) => status === 'error' );\n","import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';\n\nimport { apiClient, type CreateComponentPayload, type CreateComponentResponse } from './api';\n\nconst createComponent = createAsyncThunk< CreateComponentResponse, CreateComponentPayload >(\n\t'components/create',\n\tasync ( payload: CreateComponentPayload ) => {\n\t\tconst response = await apiClient.create( payload );\n\t\treturn { ...response, name: payload.name };\n\t}\n);\n\nconst loadComponents = createAsyncThunk( 'components/load', async () => {\n\tconst response = await apiClient.get();\n\treturn response;\n} );\n\nexport { createComponent, loadComponents };\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\nexport type 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 { endDragElementFromPanel, startDragElementFromPanel } from '@elementor/editor-canvas';\nimport { dropElement, type DropElementParams } from '@elementor/editor-elements';\nimport { MenuListItem } from '@elementor/editor-ui';\nimport { ComponentsIcon, DotsVerticalIcon } 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 componentModel = createComponentModel( { id: component.id, name: component.name } );\n\n\tconst popupState = usePopupState( {\n\t\tvariant: 'popover',\n\t\tdisableAutoFocus: true,\n\t} );\n\n\tconst handleClick = () => {\n\t\taddComponentToPage( componentModel );\n\t};\n\n\treturn (\n\t\t<ListItemButton\n\t\t\tdraggable\n\t\t\tonDragStart={ () => startDragElementFromPanel( componentModel ) }\n\t\t\tonDragEnd={ endDragElementFromPanel }\n\t\t\tshape=\"rounded\"\n\t\t\tsx={ { border: 'solid 1px', borderColor: 'divider', py: 0.5, px: 1 } }\n\t\t>\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<ComponentsIcon 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 = ( 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 {\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 { useComponents } from '../../hooks/use-components';\nimport { useCreateComponent } 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 { createComponent, isPending } = useCreateComponent();\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\ttry {\n\t\t\tconst result = await createComponent( {\n\t\t\t\tname: values.componentName,\n\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t} );\n\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't replace element with component: element not found` );\n\t\t\t}\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: result.component_id,\n\t\t\t\tname: values.componentName,\n\t\t\t} );\n\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\t// Translators: %1$s: Component name, %2$s: Component ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', result.component_id.toString() ),\n\t\t\t\ttype: 'success',\n\t\t\t} );\n\n\t\t\tresetAndClosePopup();\n\t\t} catch {\n\t\t\tconst errorMessage = __( 'Failed to save component. Please try again.', 'elementor' );\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\tmessage: errorMessage,\n\t\t\t\ttype: 'error',\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 { 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 { __useDispatch as useDispatch, __useSelector as useSelector, type AnyAction } from '@elementor/store';\n\nimport { type CreateComponentPayload } from '../api';\nimport { selectCreateIsError, selectCreateIsPending } from '../store';\nimport { createComponent } from '../thunks';\n\nexport const useCreateComponent = () => {\n\tconst dispatch = useDispatch();\n\tconst isPending = useSelector( selectCreateIsPending );\n\tconst isError = useSelector( selectCreateIsError );\n\n\tconst createComponentAction = async ( payload: CreateComponentPayload ) => {\n\t\tconst result = await dispatch( createComponent( payload ) as unknown as AnyAction );\n\t\treturn result.payload;\n\t};\n\n\treturn {\n\t\tcreateComponent: createComponentAction,\n\t\tisPending,\n\t\tisError,\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","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,MAAAA,WAAU;;;ACHnB,YAAYC,YAAW;AACvB,SAAS,qBAAqB;;;ACD9B,YAAYC,YAAW;AACvB,SAAS,kBAAkB;A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;AAAA,MAC7B,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,MAAK;AAAA;AAAA,IAEH,eAAeA,IAAI,kBAAa,WAAY,IAAIA,IAAI,UAAU,WAAY;AAAA,EAC7E,CACD,CACD;AAEF;;;AIxNA,SAAS,aAAAO,kBAAiB;AAC1B,SAAS,cAAc,gBAAgB;AAIhC,SAAS,gBAAgB;AAC/B,EAAAC,WAAW,MAAM;AAChB,aAAU,eAAe,CAAE;AAAA,EAC5B,GAAG,CAAC,CAAE;AAEN,SAAO;AACR;;;AjBDO,SAAS,OAAO;AACtB,gBAAe,KAAM;AAErB,YAAW;AAAA,IACV,IAAI;AAAA,IACJ,OAAOC,IAAI,cAAc,WAAY;AAAA,IACrC,WAAW;AAAA,EACZ,CAAE;AAEF,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AAEF,kBAAiB;AAAA,IAChB,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["__","React","React","React","ComponentsIcon","Box","Stack","Typography","__","React","Box","__","Box","__","React","Box","ListItemButton","Stack","Stack","Typography","__","ComponentsIcon","Box","React","useMemo","useState","ThemeProvider","Stack","TextField","Typography","__","useSelector","dispatch","useSelector","__","useState","createComponent","__","ThemeProvider","validateForm","useMemo","Stack","Typography","TextField","useEffect","useEffect","__"]}
|
|
1
|
+
{"version":3,"sources":["../src/init.ts","../src/components/components-tab/components.tsx","../src/components/components-tab/component-search.tsx","../src/components/components-tab/search-provider.tsx","../src/components/components-tab/components-list.tsx","../src/hooks/use-components.ts","../src/store.ts","../src/thunks.ts","../src/api.ts","../src/components/components-tab/components-item.tsx","../src/utils/get-container-for-new-element.ts","../src/components/create-component-form/utils/replace-element-with-component.ts","../src/components/components-tab/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","../src/populate-store.ts"],"sourcesContent":["import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { PopulateStore } from './populate-store';\nimport { slice } from './store';\n\nexport function init() {\n\tregisterSlice( slice );\n\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\tinjectIntoLogic( {\n\t\tid: 'components-populate-store',\n\t\tcomponent: PopulateStore,\n\t} );\n}\n","import * as React from 'react';\nimport { ThemeProvider } from '@elementor/editor-ui';\n\nimport { ComponentSearch } from './component-search';\nimport { ComponentsList } from './components-list';\nimport { SearchProvider } from './search-provider';\n\nexport const Components = () => {\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<SearchProvider localStorageKey=\"elementor-components-search\">\n\t\t\t\t<ComponentSearch />\n\t\t\t\t<ComponentsList />\n\t\t\t</SearchProvider>\n\t\t</ThemeProvider>\n\t);\n};\n","import * as React from 'react';\nimport { SearchIcon } from '@elementor/icons';\nimport { Box, InputAdornment, Stack, TextField } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\nimport { useSearch } from './search-provider';\n\nexport const ComponentSearch = () => {\n\tconst { inputValue, handleChange } = useSearch();\n\n\treturn (\n\t\t<Stack direction=\"row\" gap={ 0.5 } sx={ { width: '100%', px: 2, py: 1.5 } }>\n\t\t\t<Box sx={ { flexGrow: 1 } }>\n\t\t\t\t<TextField\n\t\t\t\t\trole={ 'search' }\n\t\t\t\t\tfullWidth\n\t\t\t\t\tsize={ 'tiny' }\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tplaceholder={ __( 'Search', 'elementor' ) }\n\t\t\t\t\tonChange={ ( e: React.ChangeEvent< HTMLInputElement > ) => handleChange( e.target.value ) }\n\t\t\t\t\tInputProps={ {\n\t\t\t\t\t\tstartAdornment: (\n\t\t\t\t\t\t\t<InputAdornment position=\"start\">\n\t\t\t\t\t\t\t\t<SearchIcon fontSize={ 'tiny' } />\n\t\t\t\t\t\t\t</InputAdornment>\n\t\t\t\t\t\t),\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</Box>\n\t\t</Stack>\n\t);\n};\n","import * as React from 'react';\nimport { createContext, useContext } from 'react';\nimport { useSearchState, type UseSearchStateResult } from '@elementor/utils';\n\ntype SearchContextType = Pick< UseSearchStateResult, 'handleChange' | 'inputValue' > & {\n\tsearchValue: UseSearchStateResult[ 'debouncedValue' ];\n\tclearSearch: () => void;\n};\n\nconst SearchContext = createContext< SearchContextType | undefined >( undefined );\n\nexport const SearchProvider = ( {\n\tchildren,\n\tlocalStorageKey,\n}: {\n\tchildren: React.ReactNode;\n\tlocalStorageKey: string;\n} ) => {\n\tconst { debouncedValue, handleChange, inputValue } = useSearchState( { localStorageKey } );\n\n\tconst clearSearch = () => {\n\t\thandleChange( '' );\n\t};\n\n\treturn (\n\t\t<SearchContext.Provider value={ { handleChange, clearSearch, searchValue: debouncedValue, inputValue } }>\n\t\t\t{ children }\n\t\t</SearchContext.Provider>\n\t);\n};\n\nexport const useSearch = () => {\n\tconst context = useContext( SearchContext );\n\tif ( ! context ) {\n\t\tthrow new Error( 'useSearch must be used within a SearchProvider' );\n\t}\n\treturn context;\n};\n","import * as React from 'react';\nimport { ComponentsIcon, EyeIcon } from '@elementor/icons';\nimport { Box, Divider, Icon, Link, 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';\nimport { useSearch } from './search-provider';\n\nexport function ComponentsList() {\n\tconst { components, isLoading, searchValue } = useFilteredComponents();\n\n\tif ( isLoading ) {\n\t\treturn <LoadingComponents />;\n\t}\n\tconst isEmpty = ! components || components.length === 0;\n\tif ( isEmpty ) {\n\t\tif ( searchValue.length > 0 ) {\n\t\t\treturn <EmptySearchResult />;\n\t\t}\n\t\treturn <EmptyState />;\n\t}\n\n\treturn (\n\t\t<List sx={ { display: 'flex', flexDirection: 'column', gap: 1, px: 2 } }>\n\t\t\t{ components.map( ( component ) => (\n\t\t\t\t<ComponentItem key={ component.id } component={ component } />\n\t\t\t) ) }\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\nconst EmptySearchResult = () => {\n\tconst { searchValue, clearSearch } = useSearch();\n\treturn (\n\t\t<Stack\n\t\t\tcolor={ 'text.secondary' }\n\t\t\tpt={ 5 }\n\t\t\talignItems=\"center\"\n\t\t\tgap={ 1 }\n\t\t\toverflow={ 'hidden' }\n\t\t\tjustifySelf={ 'center' }\n\t\t>\n\t\t\t<ComponentsIcon />\n\t\t\t<Box\n\t\t\t\tsx={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Typography align=\"center\" variant=\"subtitle2\" color=\"inherit\">\n\t\t\t\t\t{ __( 'Sorry, nothing matched', 'elementor' ) }\n\t\t\t\t</Typography>\n\t\t\t\t{ searchValue && (\n\t\t\t\t\t<Typography\n\t\t\t\t\t\tvariant=\"subtitle2\"\n\t\t\t\t\t\tcolor=\"inherit\"\n\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span>“</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tmaxWidth: '80%',\n\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ searchValue }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span>”.</span>\n\t\t\t\t\t</Typography>\n\t\t\t\t) }\n\t\t\t</Box>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t{ __( 'Try something else.', 'elementor' ) }\n\t\t\t</Typography>\n\t\t\t<Typography align=\"center\" variant=\"caption\" color=\"inherit\">\n\t\t\t\t<Link color=\"secondary\" variant=\"caption\" component=\"button\" onClick={ clearSearch }>\n\t\t\t\t\t{ __( 'Clear & try again', 'elementor' ) }\n\t\t\t\t</Link>\n\t\t\t</Typography>\n\t\t</Stack>\n\t);\n};\n\nconst useFilteredComponents = () => {\n\tconst { components, isLoading } = useComponents();\n\tconst { searchValue } = useSearch();\n\n\treturn {\n\t\tcomponents: components.filter( ( component ) =>\n\t\t\tcomponent.name.toLowerCase().includes( searchValue.toLowerCase() )\n\t\t),\n\t\tisLoading,\n\t\tsearchValue,\n\t};\n};\n","import { __useSelector as useSelector } from '@elementor/store';\n\nimport { selectComponents, selectLoadIsPending } from '../store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\n};\n","import {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { createComponent, loadComponents } from './thunks';\nimport { type Component } from './types';\n\ntype GetComponentResponse = Component[];\n\ntype Status = 'idle' | 'pending' | 'error';\nexport type ComponentsState = {\n\tdata: Component[];\n\tloadStatus: Status;\n\tcreateStatus: Status;\n};\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tloadStatus: 'idle',\n\tcreateStatus: 'idle',\n};\n\nconst SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload } ) => {\n\t\t\tstate.data.push( payload );\n\t\t},\n\t\tload: ( state, { payload } ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t},\n\textraReducers: ( builder ) => {\n\t\tbuilder.addCase( loadComponents.fulfilled, ( state, { payload }: PayloadAction< GetComponentResponse > ) => {\n\t\t\tstate.data = payload;\n\t\t\tstate.loadStatus = 'idle';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.pending, ( state ) => {\n\t\t\tstate.loadStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( loadComponents.rejected, ( state ) => {\n\t\t\tstate.loadStatus = 'error';\n\t\t} );\n\t\tbuilder.addCase( createComponent.fulfilled, ( state, { payload, meta } ) => {\n\t\t\tstate.createStatus = 'idle';\n\t\t\tstate.data.push( {\n\t\t\t\tid: payload.component_id,\n\t\t\t\tname: meta.arg.name,\n\t\t\t} );\n\t\t} );\n\t\tbuilder.addCase( createComponent.pending, ( state ) => {\n\t\t\tstate.createStatus = 'pending';\n\t\t} );\n\t\tbuilder.addCase( createComponent.rejected, ( state ) => {\n\t\t\tstate.createStatus = 'error';\n\t\t} );\n\t},\n} );\n\nconst selectData = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].loadStatus;\nconst selectCreateStatus = ( state: SliceState< typeof slice > ) => state[ SLICE_NAME ].createStatus;\n\nexport const selectComponents = createSelector( selectData, ( data: Component[] ) => data );\nexport const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );\nexport const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );\nexport const selectCreateIsPending = createSelector( selectCreateStatus, ( status ) => status === 'pending' );\nexport const selectCreateIsError = createSelector( selectCreateStatus, ( status ) => status === 'error' );\n","import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';\n\nimport { apiClient, type CreateComponentPayload, type CreateComponentResponse } from './api';\n\nconst createComponent = createAsyncThunk< CreateComponentResponse, CreateComponentPayload >(\n\t'components/create',\n\tasync ( payload: CreateComponentPayload ) => {\n\t\tconst response = await apiClient.create( payload );\n\t\treturn { ...response, name: payload.name };\n\t}\n);\n\nconst loadComponents = createAsyncThunk( 'components/load', async () => {\n\tconst response = await apiClient.get();\n\treturn response;\n} );\n\nexport { createComponent, loadComponents };\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\nexport type 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 { endDragElementFromPanel, startDragElementFromPanel } from '@elementor/editor-canvas';\nimport { dropElement, type DropElementParams } from '@elementor/editor-elements';\nimport { ComponentsIcon } from '@elementor/icons';\nimport { Box, ListItemButton, ListItemIcon, ListItemText, Typography } from '@elementor/ui';\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 componentModel = createComponentModel( { id: component.id, name: component.name } );\n\n\tconst handleClick = () => {\n\t\taddComponentToPage( componentModel );\n\t};\n\n\treturn (\n\t\t<ListItemButton\n\t\t\tdraggable\n\t\t\tonDragStart={ () => startDragElementFromPanel( componentModel ) }\n\t\t\tonDragEnd={ endDragElementFromPanel }\n\t\t\tshape=\"rounded\"\n\t\t\tsx={ { border: 'solid 1px', borderColor: 'divider', py: 0.5, px: 1 } }\n\t\t>\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<ComponentsIcon 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</ListItemButton>\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 {\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 { useComponents } from '../../hooks/use-components';\nimport { useCreateComponent } 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 { createComponent, isPending } = useCreateComponent();\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\ttry {\n\t\t\tconst result = await createComponent( {\n\t\t\t\tname: values.componentName,\n\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t} );\n\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't replace element with component: element not found` );\n\t\t\t}\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: result.component_id,\n\t\t\t\tname: values.componentName,\n\t\t\t} );\n\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\t// Translators: %1$s: Component name, %2$s: Component ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', result.component_id.toString() ),\n\t\t\t\ttype: 'success',\n\t\t\t} );\n\n\t\t\tresetAndClosePopup();\n\t\t} catch {\n\t\t\tconst errorMessage = __( 'Failed to save component. Please try again.', 'elementor' );\n\t\t\tsetResultNotification( {\n\t\t\t\tshow: true,\n\t\t\t\tmessage: errorMessage,\n\t\t\t\ttype: 'error',\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 { 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 { __useDispatch as useDispatch, __useSelector as useSelector, type AnyAction } from '@elementor/store';\n\nimport { type CreateComponentPayload } from '../api';\nimport { selectCreateIsError, selectCreateIsPending } from '../store';\nimport { createComponent } from '../thunks';\n\nexport const useCreateComponent = () => {\n\tconst dispatch = useDispatch();\n\tconst isPending = useSelector( selectCreateIsPending );\n\tconst isError = useSelector( selectCreateIsError );\n\n\tconst createComponentAction = async ( payload: CreateComponentPayload ) => {\n\t\tconst result = await dispatch( createComponent( payload ) as unknown as AnyAction );\n\t\treturn result.payload;\n\t};\n\n\treturn {\n\t\tcreateComponent: createComponentAction,\n\t\tisPending,\n\t\tisError,\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","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,MAAAA,WAAU;;;ACHnB,YAAYC,YAAW;AACvB,SAAS,qBAAqB;;;ACD9B,YAAYC,YAAW;AACvB,SAAS,kBAAkB;AAC3B,SAAS,KAAK,gBAAgB,OAAO,iBAAiB;AACtD,SAAS,UAAU;;;ACHnB,YAAY,WAAW;AACvB,SAAS,eAAe,kBAAkB;AAC1C,SAAS,sBAAiD;AAO1D,IAAM,gBAAgB,cAAgD,MAAU;AAEzE,IAAM,iBAAiB,CAAE;AAAA,EAC/B;AAAA,EACA;AACD,MAGO;AACN,QAAM,EAAE,gBAAgB,cAAc,WAAW,IAAI,eAAgB,EAAE,gBAAgB,CAAE;AAEzF,QAAM,cAAc,MAAM;AACzB,iBAAc,EAAG;AAAA,EAClB;AAEA,SACC,oCAAC,cAAc,UAAd,EAAuB,OAAQ,EAAE,cAAc,aAAa,aAAa,gBAAgB,WAAW,KAClG,QACH;AAEF;AAEO,IAAM,YAAY,MAAM;AAC9B,QAAM,UAAU,WAAY,aAAc;AAC1C,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI,MAAO,gDAAiD;AAAA,EACnE;AACA,SAAO;AACR;;;AD9BO,IAAM,kBAAkB,MAAM;AACpC,QAAM,EAAE,YAAY,aAAa,IAAI,UAAU;AAE/C,SACC,qCAAC,SA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EN,SAAO;AACR;;;AjBDO,SAAS,OAAO;AACtB,gBAAe,KAAM;AAErB,YAAW;AAAA,IACV,IAAI;AAAA,IACJ,OAAOC,IAAI,cAAc,WAAY;AAAA,IACrC,WAAW;AAAA,EACZ,CAAE;AAEF,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AAEF,kBAAiB;AAAA,IAChB,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["__","React","React","React","ComponentsIcon","Box","Stack","Typography","__","React","Box","Box","React","Box","ListItemButton","Stack","Stack","Typography","__","ComponentsIcon","Box","React","useMemo","useState","ThemeProvider","Stack","TextField","Typography","__","useSelector","dispatch","useSelector","__","useState","createComponent","__","ThemeProvider","validateForm","useMemo","Stack","Typography","TextField","useEffect","useEffect","__"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-components",
|
|
3
3
|
"description": "Elementor editor components",
|
|
4
|
-
"version": "3.33.0-
|
|
4
|
+
"version": "3.33.0-181",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/store": "3.33.0-
|
|
44
|
-
"@elementor/editor": "3.33.0-
|
|
45
|
-
"@elementor/utils": "3.33.0-
|
|
46
|
-
"@elementor/editor-canvas": "3.33.0-
|
|
47
|
-
"@elementor/editor-elements": "3.33.0-
|
|
48
|
-
"@elementor/editor-elements-panel": "3.33.0-
|
|
49
|
-
"@elementor/editor-props": "3.33.0-
|
|
50
|
-
"@elementor/editor-ui": "3.33.0-
|
|
51
|
-
"@elementor/http-client": "3.33.0-
|
|
43
|
+
"@elementor/store": "3.33.0-181",
|
|
44
|
+
"@elementor/editor": "3.33.0-181",
|
|
45
|
+
"@elementor/utils": "3.33.0-181",
|
|
46
|
+
"@elementor/editor-canvas": "3.33.0-181",
|
|
47
|
+
"@elementor/editor-elements": "3.33.0-181",
|
|
48
|
+
"@elementor/editor-elements-panel": "3.33.0-181",
|
|
49
|
+
"@elementor/editor-props": "3.33.0-181",
|
|
50
|
+
"@elementor/editor-ui": "3.33.0-181",
|
|
51
|
+
"@elementor/http-client": "3.33.0-181",
|
|
52
52
|
"@elementor/icons": "1.53.0",
|
|
53
|
-
"@elementor/query": "3.33.0-
|
|
54
|
-
"@elementor/schema": "3.33.0-
|
|
53
|
+
"@elementor/query": "3.33.0-181",
|
|
54
|
+
"@elementor/schema": "3.33.0-181",
|
|
55
55
|
"@elementor/ui": "1.36.14",
|
|
56
56
|
"@wordpress/i18n": "^5.13.0"
|
|
57
57
|
},
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { endDragElementFromPanel, startDragElementFromPanel } from '@elementor/editor-canvas';
|
|
3
3
|
import { dropElement, type DropElementParams } from '@elementor/editor-elements';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
bindMenu,
|
|
8
|
-
bindTrigger,
|
|
9
|
-
Box,
|
|
10
|
-
IconButton,
|
|
11
|
-
ListItemButton,
|
|
12
|
-
ListItemIcon,
|
|
13
|
-
ListItemText,
|
|
14
|
-
Menu,
|
|
15
|
-
Typography,
|
|
16
|
-
usePopupState,
|
|
17
|
-
} from '@elementor/ui';
|
|
18
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { ComponentsIcon } from '@elementor/icons';
|
|
5
|
+
import { Box, ListItemButton, ListItemIcon, ListItemText, Typography } from '@elementor/ui';
|
|
19
6
|
|
|
20
7
|
import { type Component } from '../../types';
|
|
21
8
|
import { getContainerForNewElement } from '../../utils/get-container-for-new-element';
|
|
@@ -24,11 +11,6 @@ import { createComponentModel } from '../create-component-form/utils/replace-ele
|
|
|
24
11
|
export const ComponentItem = ( { component }: { component: Component } ) => {
|
|
25
12
|
const componentModel = createComponentModel( { id: component.id, name: component.name } );
|
|
26
13
|
|
|
27
|
-
const popupState = usePopupState( {
|
|
28
|
-
variant: 'popover',
|
|
29
|
-
disableAutoFocus: true,
|
|
30
|
-
} );
|
|
31
|
-
|
|
32
14
|
const handleClick = () => {
|
|
33
15
|
addComponentToPage( componentModel );
|
|
34
16
|
};
|
|
@@ -53,35 +35,6 @@ export const ComponentItem = ( { component }: { component: Component } ) => {
|
|
|
53
35
|
}
|
|
54
36
|
/>
|
|
55
37
|
</Box>
|
|
56
|
-
<IconButton size="tiny" aria-label="More actions" { ...bindTrigger( popupState ) }>
|
|
57
|
-
<DotsVerticalIcon fontSize="tiny" />
|
|
58
|
-
</IconButton>
|
|
59
|
-
<Menu
|
|
60
|
-
{ ...bindMenu( popupState ) }
|
|
61
|
-
anchorOrigin={ {
|
|
62
|
-
vertical: 'bottom',
|
|
63
|
-
horizontal: 'right',
|
|
64
|
-
} }
|
|
65
|
-
transformOrigin={ {
|
|
66
|
-
vertical: 'top',
|
|
67
|
-
horizontal: 'right',
|
|
68
|
-
} }
|
|
69
|
-
>
|
|
70
|
-
<MenuListItem sx={ { minWidth: '160px' } }>
|
|
71
|
-
<Typography variant="caption" sx={ { color: 'text.primary' } }>
|
|
72
|
-
{ __( 'Rename', 'elementor' ) }
|
|
73
|
-
</Typography>
|
|
74
|
-
</MenuListItem>
|
|
75
|
-
<MenuListItem
|
|
76
|
-
onClick={ () => {
|
|
77
|
-
popupState.close();
|
|
78
|
-
} }
|
|
79
|
-
>
|
|
80
|
-
<Typography variant="caption" sx={ { color: 'error.light' } }>
|
|
81
|
-
{ __( 'Delete', 'elementor' ) }
|
|
82
|
-
</Typography>
|
|
83
|
-
</MenuListItem>
|
|
84
|
-
</Menu>
|
|
85
38
|
</ListItemButton>
|
|
86
39
|
);
|
|
87
40
|
};
|