@elementor/editor-components 3.33.0-208 → 3.33.0-210
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 +14 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/api.ts +6 -5
- package/src/component-id-transformer.ts +1 -1
- package/src/components/create-component-form/create-component-form.tsx +1 -1
- package/src/store/store.ts +2 -20
- package/src/store/thunks.ts +2 -10
- package/src/utils/before-save.ts +13 -8
- package/src/hooks/use-create-component.ts +0 -22
package/dist/index.js
CHANGED
|
@@ -71,13 +71,6 @@ var apiClient = {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
// src/store/thunks.ts
|
|
74
|
-
var createComponent = (0, import_store.__createAsyncThunk)(
|
|
75
|
-
"components/create",
|
|
76
|
-
async (payload) => {
|
|
77
|
-
const response = await apiClient.create(payload);
|
|
78
|
-
return { ...response, name: payload.name };
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
74
|
var loadComponents = (0, import_store.__createAsyncThunk)("components/load", async () => {
|
|
82
75
|
const response = await apiClient.get();
|
|
83
76
|
return response;
|
|
@@ -88,7 +81,6 @@ var initialState = {
|
|
|
88
81
|
data: [],
|
|
89
82
|
unpublishedData: [],
|
|
90
83
|
loadStatus: "idle",
|
|
91
|
-
createStatus: "idle",
|
|
92
84
|
styles: {}
|
|
93
85
|
};
|
|
94
86
|
var SLICE_NAME = "components";
|
|
@@ -131,24 +123,10 @@ var slice = (0, import_store2.__createSlice)({
|
|
|
131
123
|
builder.addCase(loadComponents.rejected, (state) => {
|
|
132
124
|
state.loadStatus = "error";
|
|
133
125
|
});
|
|
134
|
-
builder.addCase(createComponent.fulfilled, (state, { payload, meta }) => {
|
|
135
|
-
state.createStatus = "idle";
|
|
136
|
-
state.data.push({
|
|
137
|
-
id: payload.component_id,
|
|
138
|
-
name: meta.arg.name
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
builder.addCase(createComponent.pending, (state) => {
|
|
142
|
-
state.createStatus = "pending";
|
|
143
|
-
});
|
|
144
|
-
builder.addCase(createComponent.rejected, (state) => {
|
|
145
|
-
state.createStatus = "error";
|
|
146
|
-
});
|
|
147
126
|
}
|
|
148
127
|
});
|
|
149
128
|
var selectData = (state) => state[SLICE_NAME].data;
|
|
150
129
|
var selectLoadStatus = (state) => state[SLICE_NAME].loadStatus;
|
|
151
|
-
var selectCreateStatus = (state) => state[SLICE_NAME].createStatus;
|
|
152
130
|
var selectStylesDefinitions = (state) => state[SLICE_NAME].styles ?? {};
|
|
153
131
|
var selectUnpublishedData = (state) => state[SLICE_NAME].unpublishedData;
|
|
154
132
|
var selectComponents = (0, import_store2.__createSelector)(
|
|
@@ -165,8 +143,6 @@ var selectUnpublishedComponents = (0, import_store2.__createSelector)(
|
|
|
165
143
|
);
|
|
166
144
|
var selectLoadIsPending = (0, import_store2.__createSelector)(selectLoadStatus, (status) => status === "pending");
|
|
167
145
|
var selectLoadIsError = (0, import_store2.__createSelector)(selectLoadStatus, (status) => status === "error");
|
|
168
|
-
var selectCreateIsPending = (0, import_store2.__createSelector)(selectCreateStatus, (status) => status === "pending");
|
|
169
|
-
var selectCreateIsError = (0, import_store2.__createSelector)(selectCreateStatus, (status) => status === "error");
|
|
170
146
|
var selectStyles = (state) => state[SLICE_NAME].styles ?? {};
|
|
171
147
|
var selectFlatStyles = (0, import_store2.__createSelector)(selectStylesDefinitions, (data) => Object.values(data).flat());
|
|
172
148
|
|
|
@@ -175,7 +151,7 @@ var componentIdTransformer = (0, import_editor_canvas.createTransformer)(async (
|
|
|
175
151
|
const unpublishedComponents = selectUnpublishedComponents((0, import_store3.__getState)());
|
|
176
152
|
const unpublishedComponent = unpublishedComponents.find((component) => component.id === id);
|
|
177
153
|
if (unpublishedComponent) {
|
|
178
|
-
return structuredClone(unpublishedComponent.
|
|
154
|
+
return structuredClone(unpublishedComponent.elements);
|
|
179
155
|
}
|
|
180
156
|
const extendedWindow = window;
|
|
181
157
|
const documentManager = extendedWindow.elementor?.documents;
|
|
@@ -623,7 +599,7 @@ function CreateComponentForm() {
|
|
|
623
599
|
slice.actions.addUnpublished({
|
|
624
600
|
id: tempId,
|
|
625
601
|
name: values.componentName,
|
|
626
|
-
|
|
602
|
+
elements: [element.element.model.toJSON({ remove: ["default"] })]
|
|
627
603
|
})
|
|
628
604
|
);
|
|
629
605
|
replaceElementWithComponent(element.element, {
|
|
@@ -936,14 +912,19 @@ var beforeSave = async ({ container, status }) => {
|
|
|
936
912
|
}
|
|
937
913
|
};
|
|
938
914
|
async function createComponents(components, status) {
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
915
|
+
const response = await apiClient.create({
|
|
916
|
+
status,
|
|
917
|
+
items: components.map((component) => ({
|
|
918
|
+
temp_id: component.id,
|
|
919
|
+
title: component.name,
|
|
920
|
+
elements: component.elements
|
|
921
|
+
}))
|
|
922
|
+
});
|
|
923
|
+
const map = /* @__PURE__ */ new Map();
|
|
924
|
+
Object.entries(response).forEach(([key, value]) => {
|
|
925
|
+
map.set(Number(key), value);
|
|
944
926
|
});
|
|
945
|
-
|
|
946
|
-
return tempIdToComponentId;
|
|
927
|
+
return map;
|
|
947
928
|
}
|
|
948
929
|
function updateComponentInstances(elements, tempIdToComponentId) {
|
|
949
930
|
elements.forEach((element) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/component-id-transformer.ts","../src/store/store.ts","../src/store/thunks.ts","../src/api.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/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/components/create-component-form/hooks/use-form.ts","../src/components/create-component-form/utils/component-form-schema.ts","../src/create-component-type.ts","../src/populate-store.ts","../src/store/components-styles-provider.ts","../src/store/load-components-styles.ts","../src/utils/get-component-ids.ts","../src/store/remove-component-styles.ts","../src/utils/before-save.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { registerElementType, settingsTransformersRegistry } from '@elementor/editor-canvas';\nimport { getV1CurrentDocument } from '@elementor/editor-documents';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { stylesRepository } from '@elementor/editor-styles-repository';\nimport { __privateListenTo as listenTo, commandStartEvent, registerDataHook } from '@elementor/editor-v1-adapters';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { componentIdTransformer } from './component-id-transformer';\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { createComponentType, TYPE } from './create-component-type';\nimport { PopulateStore } from './populate-store';\nimport { componentsStylesProvider } from './store/components-styles-provider';\nimport { loadComponentsStyles } from './store/load-components-styles';\nimport { removeComponentStyles } from './store/remove-component-styles';\nimport { slice } from './store/store';\nimport { type Element, type ExtendedWindow } from './types';\nimport { beforeSave } from './utils/before-save';\n\nconst COMPONENT_DOCUMENT_TYPE = 'elementor_component';\n\nexport function init() {\n\tstylesRepository.register( componentsStylesProvider );\n\tregisterSlice( slice );\n\tregisterElementType( TYPE, createComponentType );\n\tregisterDataHook( 'dependency', 'editor/documents/close', ( args ) => {\n\t\tconst document = getV1CurrentDocument();\n\t\tif ( document.config.type === COMPONENT_DOCUMENT_TYPE ) {\n\t\t\targs.mode = 'autosave';\n\t\t}\n\t\treturn true;\n\t} );\n\n\t( window as unknown as ExtendedWindow ).elementorCommon.__beforeSave = beforeSave;\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\tlistenTo( commandStartEvent( 'editor/documents/attach-preview' ), () => {\n\t\tconst { id, config } = getV1CurrentDocument();\n\n\t\tif ( id ) {\n\t\t\tremoveComponentStyles( id );\n\t\t}\n\n\t\tloadComponentsStyles( ( config?.elements as Element[] ) ?? [] );\n\t} );\n\n\tsettingsTransformersRegistry.register( 'component-id', componentIdTransformer );\n}\n","import { createTransformer } from '@elementor/editor-canvas';\nimport { __getState as getState } from '@elementor/store';\n\nimport { selectUnpublishedComponents } from './store/store';\n\ntype ComponentIdTransformerWindow = Window & {\n\telementor?: {\n\t\tdocuments?: {\n\t\t\trequest: ( id: number ) => Promise< { elements?: unknown[] } >;\n\t\t};\n\t};\n};\n\nexport const componentIdTransformer = createTransformer( async ( id: number ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tconst unpublishedComponent = unpublishedComponents.find( ( component ) => component.id === id );\n\tif ( unpublishedComponent ) {\n\t\treturn structuredClone( unpublishedComponent.content );\n\t}\n\n\tconst extendedWindow = window as unknown as ComponentIdTransformerWindow;\n\n\tconst documentManager = extendedWindow.elementor?.documents;\n\n\tif ( ! documentManager ) {\n\t\tthrow new Error( 'Elementor documents manager not found' );\n\t}\n\n\tconst data = await documentManager.request( id );\n\n\treturn data.elements ?? [];\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { type Component, type ComponentId, type StylesDefinition } from '../types';\nimport { createComponent, loadComponents } from './thunks';\n\ntype GetComponentResponse = Component[];\n\nexport type UnpublishedComponent = Component & {\n\tcontent: V1ElementData[];\n};\n\ntype Status = 'idle' | 'pending' | 'error';\n\ntype ComponentsState = {\n\tdata: Component[];\n\tunpublishedData: UnpublishedComponent[];\n\tloadStatus: Status;\n\tcreateStatus: Status;\n\tstyles: StylesDefinition;\n};\n\ntype ComponentsSlice = SliceState< typeof slice >;\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tunpublishedData: [],\n\tloadStatus: 'idle',\n\tcreateStatus: 'idle',\n\tstyles: {},\n};\n\nexport const SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload }: PayloadAction< Component | Component[] > ) => {\n\t\t\tif ( Array.isArray( payload ) ) {\n\t\t\t\tstate.data = [ ...state.data, ...payload ];\n\t\t\t} else {\n\t\t\t\tstate.data.unshift( payload );\n\t\t\t}\n\t\t},\n\t\tload: ( state, { payload }: PayloadAction< Component[] > ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t\taddUnpublished: ( state, { payload } ) => {\n\t\t\tstate.unpublishedData.unshift( payload );\n\t\t},\n\t\tresetUnpublished: ( state ) => {\n\t\t\tstate.unpublishedData = [];\n\t\t},\n\t\tremoveStyles( state, { payload }: PayloadAction< { id: ComponentId } > ) {\n\t\t\tconst { [ payload.id ]: _, ...rest } = state.styles;\n\n\t\t\tstate.styles = rest;\n\t\t},\n\t\taddStyles: ( state, { payload } ) => {\n\t\t\tstate.styles = { ...state.styles, ...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: ComponentsSlice ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].loadStatus;\nconst selectCreateStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].createStatus;\nconst selectStylesDefinitions = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nconst selectUnpublishedData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].unpublishedData;\n\nexport const selectComponents = createSelector(\n\tselectData,\n\tselectUnpublishedData,\n\t( data: Component[], unpublishedData: UnpublishedComponent[] ) => [\n\t\t...unpublishedData.map( ( item ) => ( { id: item.id, name: item.name } ) ),\n\t\t...data,\n\t]\n);\nexport const selectUnpublishedComponents = createSelector(\n\tselectUnpublishedData,\n\t( unpublishedData: UnpublishedComponent[] ) => unpublishedData\n);\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' );\nexport const selectStyles = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nexport const selectFlatStyles = createSelector( selectStylesDefinitions, ( data ) => Object.values( data ).flat() );\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 V1ElementData } from '@elementor/editor-elements';\nimport { ajax } from '@elementor/editor-v1-adapters';\nimport { type HttpResponse, httpService } from '@elementor/http-client';\n\nimport { type Component, type DocumentStatus } from './types';\n\nconst BASE_URL = 'elementor/v1/components';\n\nexport type CreateComponentPayload = {\n\tname: string;\n\tcontent: V1ElementData[];\n\tstatus: DocumentStatus;\n};\n\ntype GetComponentResponse = Array< Component >;\n\nexport type CreateComponentResponse = {\n\tcomponent_id: number;\n};\n\nexport const getParams = ( id: number ) => ( {\n\taction: 'get_document_config',\n\tunique_id: `document-config-${ id }`,\n\tdata: { id },\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\tgetComponentConfig: ( id: number ) => ajax.load< { id: number }, V1ElementData >( getParams( id ) ),\n\tinvalidateComponentConfigCache: ( id: number ) => ajax.invalidateCache< { id: number } >( getParams( id ) ),\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/store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\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';\n\nimport { type Component } from '../../../types';\n\nexport const replaceElementWithComponent = ( 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: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: component.id,\n\t\t\t},\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 { __useDispatch as useDispatch } from '@elementor/store';\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 { slice } from '../../store/store';\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 dispatch = useDispatch();\n\n\tuseEffect( () => {\n\t\tconst OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';\n\n\t\tconst openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {\n\t\t\tsetElement( { element: event.detail.element, elementLabel: getElementLabel( event.detail.element.id ) } );\n\t\t\tsetAnchorPosition( event.detail.anchorPosition );\n\t\t};\n\n\t\twindow.addEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\t\t};\n\t}, [] );\n\n\tconst handleSave = async ( values: ComponentFormValues ) => {\n\t\ttry {\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't save element as component: element not found` );\n\t\t\t}\n\n\t\t\tconst tempId = generateTempId();\n\n\t\t\tdispatch(\n\t\t\t\tslice.actions.addUnpublished( {\n\t\t\t\t\tid: tempId,\n\t\t\t\t\tname: values.componentName,\n\t\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: tempId,\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 temp ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (temp ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', tempId.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\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\tclosePopup,\n}: {\n\tinitialValues: ComponentFormValues;\n\thandleSave: ( values: ComponentFormValues ) => void;\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 } 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={ ! 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{ __( 'Create', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n};\n\nexport const generateTempId = () => {\n\treturn Date.now() + Math.floor( Math.random() * 1000000 );\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 {\n\ttype CreateTemplatedElementTypeOptions,\n\tcreateTemplatedElementView,\n\ttype ElementType,\n\ttype ElementView,\n\ttype LegacyWindow,\n} from '@elementor/editor-canvas';\nimport { type NumberPropValue } from '@elementor/editor-props';\nimport { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nexport const TYPE = 'e-component';\n\nexport function createComponentType( options: CreateTemplatedElementTypeOptions ): typeof ElementType {\n\tconst legacyWindow = window as unknown as LegacyWindow;\n\n\treturn class extends legacyWindow.elementor.modules.elements.types.Widget {\n\t\tgetType() {\n\t\t\treturn options.type;\n\t\t}\n\n\t\tgetView() {\n\t\t\treturn createComponentView( options );\n\t\t}\n\t};\n}\n\nfunction createComponentView( options: CreateTemplatedElementTypeOptions ): typeof ElementView {\n\treturn class extends createTemplatedElementView( options ) {\n\t\tlegacyWindow = window as unknown as LegacyWindow;\n\n\t\tafterSettingsResolve( settings: { [ key: string ]: unknown } ) {\n\t\t\tif ( settings.component ) {\n\t\t\t\tthis.collection = this.legacyWindow.elementor.createBackboneElementsCollection( settings.component );\n\n\t\t\t\tsettings.component = '<template data-children-placeholder></template>';\n\t\t\t}\n\n\t\t\treturn settings;\n\t\t}\n\n\t\tattachBuffer( collectionView: this, buffer: DocumentFragment ): void {\n\t\t\tconst childrenPlaceholder = collectionView.$el.find( '[data-children-placeholder]' ).get( 0 );\n\n\t\t\tif ( ! childrenPlaceholder ) {\n\t\t\t\tsuper.attachBuffer( collectionView, buffer );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tchildrenPlaceholder.replaceWith( buffer );\n\t\t}\n\n\t\tgetComponentId() {\n\t\t\treturn this.options?.model?.get( 'settings' )?.get( 'component' ) as NumberPropValue;\n\t\t}\n\n\t\tgetContextMenuGroups() {\n\t\t\tconst filteredGroups = super.getContextMenuGroups().filter( ( group ) => group.name !== 'save' );\n\t\t\tconst componentId = this.getComponentId()?.value;\n\n\t\t\tif ( ! componentId ) {\n\t\t\t\treturn filteredGroups;\n\t\t\t}\n\n\t\t\tconst newGroup = {\n\t\t\t\tname: 'edit component',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'edit component',\n\t\t\t\t\t\ticon: 'eicon-edit',\n\t\t\t\t\t\ttitle: () => __( 'Edit Component', 'elementor' ),\n\t\t\t\t\t\tisEnabled: () => true,\n\t\t\t\t\t\tcallback: () => this.switchDocument(),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t\treturn [ ...filteredGroups, newGroup ];\n\t\t}\n\n\t\tswitchDocument() {\n\t\t\trunCommand( 'editor/documents/switch', {\n\t\t\t\tid: this.getComponentId().value,\n\t\t\t\tselector: `[data-id=\"${ this.model.get( 'id' ) }\"]`,\n\t\t\t\tmode: 'autosave',\n\t\t\t} );\n\t\t}\n\n\t\tui() {\n\t\t\treturn {\n\t\t\t\t...super.ui(),\n\t\t\t\tdoubleClick: '.e-component:not(:has(.elementor-edit-area))',\n\t\t\t};\n\t\t}\n\n\t\tevents() {\n\t\t\treturn {\n\t\t\t\t...super.events(),\n\t\t\t\t'dblclick @ui.doubleClick': this.switchDocument,\n\t\t\t};\n\t\t}\n\t};\n}\n","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './store/thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n","import { createStylesProvider } from '@elementor/editor-styles-repository';\nimport { __getState as getState, __subscribeWithSelector as subscribeWithSelector } from '@elementor/store';\n\nimport { selectFlatStyles, SLICE_NAME } from './store';\n\nexport const componentsStylesProvider = createStylesProvider( {\n\tkey: 'components-styles',\n\tpriority: 100,\n\tsubscribe: ( cb ) =>\n\t\tsubscribeWithSelector(\n\t\t\t( state ) => state[ SLICE_NAME ],\n\t\t\t() => {\n\t\t\t\tcb();\n\t\t\t}\n\t\t),\n\tactions: {\n\t\tall: () => {\n\t\t\treturn selectFlatStyles( getState() );\n\t\t},\n\t\tget: ( id ) => {\n\t\t\treturn selectFlatStyles( getState() ).find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { type StyleDefinition } from '@elementor/editor-styles';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { type ComponentId, type Element } from '../types';\nimport { getComponentIds } from '../utils/get-component-ids';\nimport { selectStyles, slice } from './store';\n\nexport async function loadComponentsStyles( elements: Element[] ) {\n\tconst componentIds = Array.from( new Set( getComponentIds( elements ) ) );\n\n\tif ( ! componentIds.length ) {\n\t\treturn;\n\t}\n\n\tconst knownComponents = selectStyles( getState() );\n\tconst unknownComponentIds = componentIds.filter( ( id ) => ! knownComponents[ id ] );\n\n\tif ( ! unknownComponentIds.length ) {\n\t\treturn;\n\t}\n\n\taddComponentStyles( unknownComponentIds );\n}\n\nasync function addComponentStyles( ids: ComponentId[] ) {\n\tconst newComponents = await loadStyles( ids );\n\n\taddStyles( newComponents );\n\n\tObject.values( newComponents ).forEach( ( [ , data ] ) => {\n\t\tloadComponentsStyles( data.elements as Element[] );\n\t} );\n}\n\nasync function loadStyles( ids: number[] ): Promise< [ number, V1ElementData ][] > {\n\treturn Promise.all( ids.map( async ( id ) => [ id, await apiClient.getComponentConfig( id ) ] ) );\n}\n\nfunction addStyles( data: ( readonly [ ComponentId, V1ElementData ] )[] ) {\n\tconst styles = Object.fromEntries(\n\t\tdata.map( ( [ componentId, componentData ] ) => [ componentId, extractStyles( componentData ) ] )\n\t);\n\n\tdispatch( slice.actions.addStyles( styles ) );\n}\n\nfunction extractStyles( element: V1ElementData ): Array< StyleDefinition > {\n\treturn [ ...Object.values( element.styles ?? {} ), ...( element.elements ?? [] ).flatMap( extractStyles ) ];\n}\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { isTransformable } from '@elementor/editor-props';\n\nexport const getComponentIds = ( elements: V1ElementData[] ) => {\n\treturn elements.flatMap( ( element ) => {\n\t\tconst ids: number[] = [];\n\n\t\tconst type = element.widgetType || element.elType;\n\n\t\tif ( type === 'e-component' && element.settings?.component && isTransformable( element.settings?.component ) ) {\n\t\t\tids.push( element.settings.component.value );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tids.push( ...getComponentIds( element.elements ) );\n\t\t}\n\n\t\treturn ids;\n\t} );\n};\n","import { __dispatch as dispatch } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { slice } from './store';\n\nexport function removeComponentStyles( id: number ) {\n\tapiClient.invalidateComponentConfigCache( id );\n\tdispatch( slice.actions.removeStyles( { id } ) );\n}\n","import { updateElementSettings, type V1ElementData } from '@elementor/editor-elements';\nimport { type TransformablePropValue } from '@elementor/editor-props';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { selectUnpublishedComponents, slice, type UnpublishedComponent } from '../store/store';\nimport { type DocumentStatus } from '../types';\n\ntype Container = {\n\tmodel: {\n\t\tget: ( key: 'elements' ) => {\n\t\t\ttoJSON: () => V1ElementData[];\n\t\t};\n\t};\n};\n\nexport const beforeSave = async ( { container, status }: { container: Container; status: DocumentStatus } ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tif ( ! unpublishedComponents.length ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst tempIdToComponentId = await createComponents( unpublishedComponents, status );\n\n\t\tconst elements = container.model.get( 'elements' ).toJSON();\n\t\tupdateComponentInstances( elements, tempIdToComponentId );\n\n\t\tdispatch(\n\t\t\tslice.actions.add(\n\t\t\t\tunpublishedComponents.map( ( component ) => ( {\n\t\t\t\t\tid: tempIdToComponentId.get( component.id ) as number,\n\t\t\t\t\tname: component.name,\n\t\t\t\t} ) )\n\t\t\t)\n\t\t);\n\t\tdispatch( slice.actions.resetUnpublished() );\n\t} catch ( error ) {\n\t\tthrow new Error( `Failed to publish components and update component instances: ${ error }` );\n\t}\n};\n\nasync function createComponents(\n\tcomponents: UnpublishedComponent[],\n\tstatus: DocumentStatus\n): Promise< Map< number, number > > {\n\tconst tempIdToComponentId = new Map< number, number >();\n\n\tconst promises = components.map( ( component ) => {\n\t\treturn apiClient.create( { name: component.name, content: component.content, status } ).then( ( response ) => {\n\t\t\ttempIdToComponentId.set( component.id, response.component_id );\n\t\t} );\n\t} );\n\n\tawait Promise.all( promises );\n\n\treturn tempIdToComponentId;\n}\n\nfunction updateComponentInstances( elements: V1ElementData[], tempIdToComponentId: Map< number, number > ): void {\n\telements.forEach( ( element ) => {\n\t\tconst { shouldUpdate, newComponentId } = shouldUpdateElement( element, tempIdToComponentId );\n\t\tif ( shouldUpdate ) {\n\t\t\tupdateElementComponentId( element.id, newComponentId );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tupdateComponentInstances( element.elements, tempIdToComponentId );\n\t\t}\n\t} );\n}\n\nfunction shouldUpdateElement(\n\telement: V1ElementData,\n\ttempIdToComponentId: Map< number, number >\n): { shouldUpdate: true; newComponentId: number } | { shouldUpdate: false; newComponentId: null } {\n\tif ( element.widgetType === 'e-component' ) {\n\t\tconst currentComponentId = ( element.settings?.component as TransformablePropValue< 'component-id', number > )\n\t\t\t?.value;\n\t\tif ( currentComponentId && tempIdToComponentId.has( currentComponentId ) ) {\n\t\t\treturn { shouldUpdate: true, newComponentId: tempIdToComponentId.get( currentComponentId ) as number };\n\t\t}\n\t}\n\treturn { shouldUpdate: false, newComponentId: null };\n}\n\nfunction updateElementComponentId( elementId: string, componentId: number ): void {\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\tcomponent: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: componentId,\n\t\t\t},\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA+C;AAC/C,IAAAA,wBAAkE;AAClE,8BAAqC;AACrC,mCAA0B;AAC1B,IAAAC,mCAAiC;AACjC,IAAAC,6BAAmF;AACnF,IAAAC,iBAAiD;AACjD,IAAAC,eAAmB;;;ACPnB,2BAAkC;AAClC,IAAAC,gBAAuC;;;ACAvC,IAAAC,gBAKO;;;ACNP,mBAAuD;;;ACCvD,gCAAqB;AACrB,yBAA+C;AAI/C,IAAM,WAAW;AAcV,IAAM,YAAY,CAAE,QAAkB;AAAA,EAC5C,QAAQ;AAAA,EACR,WAAW,mBAAoB,EAAG;AAAA,EAClC,MAAM,EAAE,GAAG;AACZ;AAEO,IAAM,YAAY;AAAA,EACxB,KAAK,UACJ,gCAAY,EACV,IAA6C,GAAI,QAAS,EAAG,EAC7D,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,QAAQ,CAAE,gBACT,gCAAY,EACV,KAAiD,GAAI,QAAS,IAAI,OAAQ,EAC1E,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,oBAAoB,CAAE,OAAgB,+BAAK,KAAuC,UAAW,EAAG,CAAE;AAAA,EAClG,gCAAgC,CAAE,OAAgB,+BAAK,gBAAmC,UAAW,EAAG,CAAE;AAC3G;;;ADjCA,IAAM,sBAAkB,aAAAC;AAAA,EACvB;AAAA,EACA,OAAQ,YAAqC;AAC5C,UAAM,WAAW,MAAM,UAAU,OAAQ,OAAQ;AACjD,WAAO,EAAE,GAAG,U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8CAAqB;AAE5C,QAAK,IAAK;AACT,4BAAuB,EAAG;AAAA,IAC3B;AAEA,yBAAwB,QAAQ,YAA2B,CAAC,CAAE;AAAA,EAC/D,CAAE;AAEF,qDAA6B,SAAU,gBAAgB,sBAAuB;AAC/E;","names":["import_editor_canvas","import_editor_styles_repository","import_editor_v1_adapters","import_store","import_i18n","import_store","import_store","createAsyncThunk","createSlice","createSelector","getState","React","React","React","import_icons","import_ui","import_i18n","import_store","useSelector","React","import_editor_canvas","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_store","import_ui","import_i18n","import_react","import_i18n","dispatch","useDispatch","validateForm","import_editor_canvas","import_editor_v1_adapters","import_i18n","runCommand","import_react","import_store","dispatch","import_store","subscribeWithSelector","getState","import_store","getState","dispatch","import_store","dispatch","import_editor_elements","import_store","getState","dispatch","registerSlice","listenTo"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/component-id-transformer.ts","../src/store/store.ts","../src/store/thunks.ts","../src/api.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/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/components/create-component-form/hooks/use-form.ts","../src/components/create-component-form/utils/component-form-schema.ts","../src/create-component-type.ts","../src/populate-store.ts","../src/store/components-styles-provider.ts","../src/store/load-components-styles.ts","../src/utils/get-component-ids.ts","../src/store/remove-component-styles.ts","../src/utils/before-save.ts"],"sourcesContent":["export { init } from './init';\n","import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { registerElementType, settingsTransformersRegistry } from '@elementor/editor-canvas';\nimport { getV1CurrentDocument } from '@elementor/editor-documents';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { stylesRepository } from '@elementor/editor-styles-repository';\nimport { __privateListenTo as listenTo, commandStartEvent, registerDataHook } from '@elementor/editor-v1-adapters';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { componentIdTransformer } from './component-id-transformer';\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { createComponentType, TYPE } from './create-component-type';\nimport { PopulateStore } from './populate-store';\nimport { componentsStylesProvider } from './store/components-styles-provider';\nimport { loadComponentsStyles } from './store/load-components-styles';\nimport { removeComponentStyles } from './store/remove-component-styles';\nimport { slice } from './store/store';\nimport { type Element, type ExtendedWindow } from './types';\nimport { beforeSave } from './utils/before-save';\n\nconst COMPONENT_DOCUMENT_TYPE = 'elementor_component';\n\nexport function init() {\n\tstylesRepository.register( componentsStylesProvider );\n\tregisterSlice( slice );\n\tregisterElementType( TYPE, createComponentType );\n\tregisterDataHook( 'dependency', 'editor/documents/close', ( args ) => {\n\t\tconst document = getV1CurrentDocument();\n\t\tif ( document.config.type === COMPONENT_DOCUMENT_TYPE ) {\n\t\t\targs.mode = 'autosave';\n\t\t}\n\t\treturn true;\n\t} );\n\n\t( window as unknown as ExtendedWindow ).elementorCommon.__beforeSave = beforeSave;\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\tlistenTo( commandStartEvent( 'editor/documents/attach-preview' ), () => {\n\t\tconst { id, config } = getV1CurrentDocument();\n\n\t\tif ( id ) {\n\t\t\tremoveComponentStyles( id );\n\t\t}\n\n\t\tloadComponentsStyles( ( config?.elements as Element[] ) ?? [] );\n\t} );\n\n\tsettingsTransformersRegistry.register( 'component-id', componentIdTransformer );\n}\n","import { createTransformer } from '@elementor/editor-canvas';\nimport { __getState as getState } from '@elementor/store';\n\nimport { selectUnpublishedComponents } from './store/store';\n\ntype ComponentIdTransformerWindow = Window & {\n\telementor?: {\n\t\tdocuments?: {\n\t\t\trequest: ( id: number ) => Promise< { elements?: unknown[] } >;\n\t\t};\n\t};\n};\n\nexport const componentIdTransformer = createTransformer( async ( id: number ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tconst unpublishedComponent = unpublishedComponents.find( ( component ) => component.id === id );\n\tif ( unpublishedComponent ) {\n\t\treturn structuredClone( unpublishedComponent.elements );\n\t}\n\n\tconst extendedWindow = window as unknown as ComponentIdTransformerWindow;\n\n\tconst documentManager = extendedWindow.elementor?.documents;\n\n\tif ( ! documentManager ) {\n\t\tthrow new Error( 'Elementor documents manager not found' );\n\t}\n\n\tconst data = await documentManager.request( id );\n\n\treturn data.elements ?? [];\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { type Component, type ComponentId, type StylesDefinition } from '../types';\nimport { loadComponents } from './thunks';\n\ntype GetComponentResponse = Component[];\n\nexport type UnpublishedComponent = Component & {\n\telements: V1ElementData[];\n};\n\ntype Status = 'idle' | 'pending' | 'error';\n\ntype ComponentsState = {\n\tdata: Component[];\n\tunpublishedData: UnpublishedComponent[];\n\tloadStatus: Status;\n\tstyles: StylesDefinition;\n};\n\ntype ComponentsSlice = SliceState< typeof slice >;\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tunpublishedData: [],\n\tloadStatus: 'idle',\n\tstyles: {},\n};\n\nexport const SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload }: PayloadAction< Component | Component[] > ) => {\n\t\t\tif ( Array.isArray( payload ) ) {\n\t\t\t\tstate.data = [ ...state.data, ...payload ];\n\t\t\t} else {\n\t\t\t\tstate.data.unshift( payload );\n\t\t\t}\n\t\t},\n\t\tload: ( state, { payload }: PayloadAction< Component[] > ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t\taddUnpublished: ( state, { payload } ) => {\n\t\t\tstate.unpublishedData.unshift( payload );\n\t\t},\n\t\tresetUnpublished: ( state ) => {\n\t\t\tstate.unpublishedData = [];\n\t\t},\n\t\tremoveStyles( state, { payload }: PayloadAction< { id: ComponentId } > ) {\n\t\t\tconst { [ payload.id ]: _, ...rest } = state.styles;\n\n\t\t\tstate.styles = rest;\n\t\t},\n\t\taddStyles: ( state, { payload } ) => {\n\t\t\tstate.styles = { ...state.styles, ...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},\n} );\n\nconst selectData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].loadStatus;\nconst selectStylesDefinitions = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nconst selectUnpublishedData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].unpublishedData;\n\nexport const selectComponents = createSelector(\n\tselectData,\n\tselectUnpublishedData,\n\t( data: Component[], unpublishedData: UnpublishedComponent[] ) => [\n\t\t...unpublishedData.map( ( item ) => ( { id: item.id, name: item.name } ) ),\n\t\t...data,\n\t]\n);\nexport const selectUnpublishedComponents = createSelector(\n\tselectUnpublishedData,\n\t( unpublishedData: UnpublishedComponent[] ) => unpublishedData\n);\nexport const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );\nexport const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );\nexport const selectStyles = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nexport const selectFlatStyles = createSelector( selectStylesDefinitions, ( data ) => Object.values( data ).flat() );\n","import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';\n\nimport { apiClient } from '../api';\n\nconst loadComponents = createAsyncThunk( 'components/load', async () => {\n\tconst response = await apiClient.get();\n\treturn response;\n} );\n\nexport { loadComponents };\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { ajax } from '@elementor/editor-v1-adapters';\nimport { type HttpResponse, httpService } from '@elementor/http-client';\n\nimport { type Component, type DocumentStatus } from './types';\n\nconst BASE_URL = 'elementor/v1/components';\n\nexport type CreateComponentPayload = {\n\tstatus: DocumentStatus;\n\titems: Array< {\n\t\ttemp_id: number;\n\t\ttitle: string;\n\t\telements: V1ElementData[];\n\t} >;\n};\n\ntype GetComponentResponse = Array< Component >;\n\nexport type CreateComponentResponse = Record< number, number >;\n\nexport const getParams = ( id: number ) => ( {\n\taction: 'get_document_config',\n\tunique_id: `document-config-${ id }`,\n\tdata: { id },\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\tgetComponentConfig: ( id: number ) => ajax.load< { id: number }, V1ElementData >( getParams( id ) ),\n\tinvalidateComponentConfigCache: ( id: number ) => ajax.invalidateCache< { id: number } >( getParams( id ) ),\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/store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\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';\n\nimport { type Component } from '../../../types';\n\nexport const replaceElementWithComponent = ( 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: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: component.id,\n\t\t\t},\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 { __useDispatch as useDispatch } from '@elementor/store';\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 { slice } from '../../store/store';\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 dispatch = useDispatch();\n\n\tuseEffect( () => {\n\t\tconst OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';\n\n\t\tconst openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {\n\t\t\tsetElement( { element: event.detail.element, elementLabel: getElementLabel( event.detail.element.id ) } );\n\t\t\tsetAnchorPosition( event.detail.anchorPosition );\n\t\t};\n\n\t\twindow.addEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\t\t};\n\t}, [] );\n\n\tconst handleSave = async ( values: ComponentFormValues ) => {\n\t\ttry {\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't save element as component: element not found` );\n\t\t\t}\n\n\t\t\tconst tempId = generateTempId();\n\n\t\t\tdispatch(\n\t\t\t\tslice.actions.addUnpublished( {\n\t\t\t\t\tid: tempId,\n\t\t\t\t\tname: values.componentName,\n\t\t\t\t\telements: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: tempId,\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 temp ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (temp ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', tempId.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\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\tclosePopup,\n}: {\n\tinitialValues: ComponentFormValues;\n\thandleSave: ( values: ComponentFormValues ) => void;\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 } 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={ ! 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{ __( 'Create', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n};\n\nexport const generateTempId = () => {\n\treturn Date.now() + Math.floor( Math.random() * 1000000 );\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 {\n\ttype CreateTemplatedElementTypeOptions,\n\tcreateTemplatedElementView,\n\ttype ElementType,\n\ttype ElementView,\n\ttype LegacyWindow,\n} from '@elementor/editor-canvas';\nimport { type NumberPropValue } from '@elementor/editor-props';\nimport { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nexport const TYPE = 'e-component';\n\nexport function createComponentType( options: CreateTemplatedElementTypeOptions ): typeof ElementType {\n\tconst legacyWindow = window as unknown as LegacyWindow;\n\n\treturn class extends legacyWindow.elementor.modules.elements.types.Widget {\n\t\tgetType() {\n\t\t\treturn options.type;\n\t\t}\n\n\t\tgetView() {\n\t\t\treturn createComponentView( options );\n\t\t}\n\t};\n}\n\nfunction createComponentView( options: CreateTemplatedElementTypeOptions ): typeof ElementView {\n\treturn class extends createTemplatedElementView( options ) {\n\t\tlegacyWindow = window as unknown as LegacyWindow;\n\n\t\tafterSettingsResolve( settings: { [ key: string ]: unknown } ) {\n\t\t\tif ( settings.component ) {\n\t\t\t\tthis.collection = this.legacyWindow.elementor.createBackboneElementsCollection( settings.component );\n\n\t\t\t\tsettings.component = '<template data-children-placeholder></template>';\n\t\t\t}\n\n\t\t\treturn settings;\n\t\t}\n\n\t\tattachBuffer( collectionView: this, buffer: DocumentFragment ): void {\n\t\t\tconst childrenPlaceholder = collectionView.$el.find( '[data-children-placeholder]' ).get( 0 );\n\n\t\t\tif ( ! childrenPlaceholder ) {\n\t\t\t\tsuper.attachBuffer( collectionView, buffer );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tchildrenPlaceholder.replaceWith( buffer );\n\t\t}\n\n\t\tgetComponentId() {\n\t\t\treturn this.options?.model?.get( 'settings' )?.get( 'component' ) as NumberPropValue;\n\t\t}\n\n\t\tgetContextMenuGroups() {\n\t\t\tconst filteredGroups = super.getContextMenuGroups().filter( ( group ) => group.name !== 'save' );\n\t\t\tconst componentId = this.getComponentId()?.value;\n\n\t\t\tif ( ! componentId ) {\n\t\t\t\treturn filteredGroups;\n\t\t\t}\n\n\t\t\tconst newGroup = {\n\t\t\t\tname: 'edit component',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'edit component',\n\t\t\t\t\t\ticon: 'eicon-edit',\n\t\t\t\t\t\ttitle: () => __( 'Edit Component', 'elementor' ),\n\t\t\t\t\t\tisEnabled: () => true,\n\t\t\t\t\t\tcallback: () => this.switchDocument(),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t\treturn [ ...filteredGroups, newGroup ];\n\t\t}\n\n\t\tswitchDocument() {\n\t\t\trunCommand( 'editor/documents/switch', {\n\t\t\t\tid: this.getComponentId().value,\n\t\t\t\tselector: `[data-id=\"${ this.model.get( 'id' ) }\"]`,\n\t\t\t\tmode: 'autosave',\n\t\t\t} );\n\t\t}\n\n\t\tui() {\n\t\t\treturn {\n\t\t\t\t...super.ui(),\n\t\t\t\tdoubleClick: '.e-component:not(:has(.elementor-edit-area))',\n\t\t\t};\n\t\t}\n\n\t\tevents() {\n\t\t\treturn {\n\t\t\t\t...super.events(),\n\t\t\t\t'dblclick @ui.doubleClick': this.switchDocument,\n\t\t\t};\n\t\t}\n\t};\n}\n","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './store/thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n","import { createStylesProvider } from '@elementor/editor-styles-repository';\nimport { __getState as getState, __subscribeWithSelector as subscribeWithSelector } from '@elementor/store';\n\nimport { selectFlatStyles, SLICE_NAME } from './store';\n\nexport const componentsStylesProvider = createStylesProvider( {\n\tkey: 'components-styles',\n\tpriority: 100,\n\tsubscribe: ( cb ) =>\n\t\tsubscribeWithSelector(\n\t\t\t( state ) => state[ SLICE_NAME ],\n\t\t\t() => {\n\t\t\t\tcb();\n\t\t\t}\n\t\t),\n\tactions: {\n\t\tall: () => {\n\t\t\treturn selectFlatStyles( getState() );\n\t\t},\n\t\tget: ( id ) => {\n\t\t\treturn selectFlatStyles( getState() ).find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { type StyleDefinition } from '@elementor/editor-styles';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { type ComponentId, type Element } from '../types';\nimport { getComponentIds } from '../utils/get-component-ids';\nimport { selectStyles, slice } from './store';\n\nexport async function loadComponentsStyles( elements: Element[] ) {\n\tconst componentIds = Array.from( new Set( getComponentIds( elements ) ) );\n\n\tif ( ! componentIds.length ) {\n\t\treturn;\n\t}\n\n\tconst knownComponents = selectStyles( getState() );\n\tconst unknownComponentIds = componentIds.filter( ( id ) => ! knownComponents[ id ] );\n\n\tif ( ! unknownComponentIds.length ) {\n\t\treturn;\n\t}\n\n\taddComponentStyles( unknownComponentIds );\n}\n\nasync function addComponentStyles( ids: ComponentId[] ) {\n\tconst newComponents = await loadStyles( ids );\n\n\taddStyles( newComponents );\n\n\tObject.values( newComponents ).forEach( ( [ , data ] ) => {\n\t\tloadComponentsStyles( data.elements as Element[] );\n\t} );\n}\n\nasync function loadStyles( ids: number[] ): Promise< [ number, V1ElementData ][] > {\n\treturn Promise.all( ids.map( async ( id ) => [ id, await apiClient.getComponentConfig( id ) ] ) );\n}\n\nfunction addStyles( data: ( readonly [ ComponentId, V1ElementData ] )[] ) {\n\tconst styles = Object.fromEntries(\n\t\tdata.map( ( [ componentId, componentData ] ) => [ componentId, extractStyles( componentData ) ] )\n\t);\n\n\tdispatch( slice.actions.addStyles( styles ) );\n}\n\nfunction extractStyles( element: V1ElementData ): Array< StyleDefinition > {\n\treturn [ ...Object.values( element.styles ?? {} ), ...( element.elements ?? [] ).flatMap( extractStyles ) ];\n}\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { isTransformable } from '@elementor/editor-props';\n\nexport const getComponentIds = ( elements: V1ElementData[] ) => {\n\treturn elements.flatMap( ( element ) => {\n\t\tconst ids: number[] = [];\n\n\t\tconst type = element.widgetType || element.elType;\n\n\t\tif ( type === 'e-component' && element.settings?.component && isTransformable( element.settings?.component ) ) {\n\t\t\tids.push( element.settings.component.value );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tids.push( ...getComponentIds( element.elements ) );\n\t\t}\n\n\t\treturn ids;\n\t} );\n};\n","import { __dispatch as dispatch } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { slice } from './store';\n\nexport function removeComponentStyles( id: number ) {\n\tapiClient.invalidateComponentConfigCache( id );\n\tdispatch( slice.actions.removeStyles( { id } ) );\n}\n","import { updateElementSettings, type V1ElementData } from '@elementor/editor-elements';\nimport { type TransformablePropValue } from '@elementor/editor-props';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { selectUnpublishedComponents, slice, type UnpublishedComponent } from '../store/store';\nimport { type DocumentStatus } from '../types';\n\ntype Container = {\n\tmodel: {\n\t\tget: ( key: 'elements' ) => {\n\t\t\ttoJSON: () => V1ElementData[];\n\t\t};\n\t};\n};\n\nexport const beforeSave = async ( { container, status }: { container: Container; status: DocumentStatus } ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tif ( ! unpublishedComponents.length ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst tempIdToComponentId = await createComponents( unpublishedComponents, status );\n\n\t\tconst elements = container.model.get( 'elements' ).toJSON();\n\t\tupdateComponentInstances( elements, tempIdToComponentId );\n\n\t\tdispatch(\n\t\t\tslice.actions.add(\n\t\t\t\tunpublishedComponents.map( ( component ) => ( {\n\t\t\t\t\tid: tempIdToComponentId.get( component.id ) as number,\n\t\t\t\t\tname: component.name,\n\t\t\t\t} ) )\n\t\t\t)\n\t\t);\n\t\tdispatch( slice.actions.resetUnpublished() );\n\t} catch ( error ) {\n\t\tthrow new Error( `Failed to publish components and update component instances: ${ error }` );\n\t}\n};\n\nasync function createComponents(\n\tcomponents: UnpublishedComponent[],\n\tstatus: DocumentStatus\n): Promise< Map< number, number > > {\n\tconst response = await apiClient.create( {\n\t\tstatus,\n\t\titems: components.map( ( component ) => ( {\n\t\t\ttemp_id: component.id,\n\t\t\ttitle: component.name,\n\t\t\telements: component.elements,\n\t\t} ) ),\n\t} );\n\n\tconst map = new Map< number, number >();\n\n\tObject.entries( response ).forEach( ( [ key, value ] ) => {\n\t\tmap.set( Number( key ), value );\n\t} );\n\n\treturn map;\n}\n\nfunction updateComponentInstances( elements: V1ElementData[], tempIdToComponentId: Map< number, number > ): void {\n\telements.forEach( ( element ) => {\n\t\tconst { shouldUpdate, newComponentId } = shouldUpdateElement( element, tempIdToComponentId );\n\t\tif ( shouldUpdate ) {\n\t\t\tupdateElementComponentId( element.id, newComponentId );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tupdateComponentInstances( element.elements, tempIdToComponentId );\n\t\t}\n\t} );\n}\n\nfunction shouldUpdateElement(\n\telement: V1ElementData,\n\ttempIdToComponentId: Map< number, number >\n): { shouldUpdate: true; newComponentId: number } | { shouldUpdate: false; newComponentId: null } {\n\tif ( element.widgetType === 'e-component' ) {\n\t\tconst currentComponentId = ( element.settings?.component as TransformablePropValue< 'component-id', number > )\n\t\t\t?.value;\n\t\tif ( currentComponentId && tempIdToComponentId.has( currentComponentId ) ) {\n\t\t\treturn { shouldUpdate: true, newComponentId: tempIdToComponentId.get( currentComponentId ) as number };\n\t\t}\n\t}\n\treturn { shouldUpdate: false, newComponentId: null };\n}\n\nfunction updateElementComponentId( elementId: string, componentId: number ): void {\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\tcomponent: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: componentId,\n\t\t\t},\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA+C;AAC/C,IAAAA,wBAAkE;AAClE,8BAAqC;AACrC,mCAA0B;AAC1B,IAAAC,mCAAiC;AACjC,IAAAC,6BAAmF;AACnF,IAAAC,iBAAiD;AACjD,IAAAC,eAAmB;;;ACPnB,2BAAkC;AAClC,IAAAC,gBAAuC;;;ACAvC,IAAAC,gBAKO;;;ACNP,mBAAuD;;;ACCvD,gCAAqB;AACrB,yBAA+C;AAI/C,IAAM,WAAW;AAeV,IAAM,YAAY,CAAE,QAAkB;AAAA,EAC5C,QAAQ;AAAA,EACR,WAAW,mBAAoB,EAAG;AAAA,EAClC,MAAM,EAAE,GAAG;AACZ;AAEO,IAAM,YAAY;AAAA,EACxB,KAAK,UACJ,gCAAY,EACV,IAA6C,GAAI,QAAS,EAAG,EAC7D,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,QAAQ,CAAE,gBACT,gCAAY,EACV,KAAiD,GAAI,QAAS,IAAI,OAAQ,EAC1E,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,oBAAoB,CAAE,OA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AA,IACtB,IAAI;AAAA,IACJ,OAAO;AAAA,MACN,WAAW;AAAA,QACV,QAAQ;AAAA,QACR,OAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA,aAAa;AAAA,EACd,CAAE;AACH;;;AvBlFA,IAAM,0BAA0B;AAEzB,SAAS,OAAO;AACtB,oDAAiB,SAAU,wBAAyB;AACpD,qBAAAC,iBAAe,KAAM;AACrB,iDAAqB,MAAM,mBAAoB;AAC/C,mDAAkB,cAAc,0BAA0B,CAAE,SAAU;AACrE,UAAM,eAAW,8CAAqB;AACtC,QAAK,SAAS,OAAO,SAAS,yBAA0B;AACvD,WAAK,OAAO;AAAA,IACb;AACA,WAAO;AAAA,EACR,CAAE;AAEF,EAAE,OAAsC,gBAAgB,eAAe;AAEvE,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;AAEF,iCAAAC,uBAAU,8CAAmB,iCAAkC,GAAG,MAAM;AACvE,UAAM,EAAE,IAAI,OAAO,QAAI,8CAAqB;AAE5C,QAAK,IAAK;AACT,4BAAuB,EAAG;AAAA,IAC3B;AAEA,yBAAwB,QAAQ,YAA2B,CAAC,CAAE;AAAA,EAC/D,CAAE;AAEF,qDAA6B,SAAU,gBAAgB,sBAAuB;AAC/E;","names":["import_editor_canvas","import_editor_styles_repository","import_editor_v1_adapters","import_store","import_i18n","import_store","import_store","createAsyncThunk","createSlice","createSelector","getState","React","React","React","import_icons","import_ui","import_i18n","import_store","useSelector","React","import_editor_canvas","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_store","import_ui","import_i18n","import_react","import_i18n","dispatch","useDispatch","validateForm","import_editor_canvas","import_editor_v1_adapters","import_i18n","runCommand","import_react","import_store","dispatch","import_store","subscribeWithSelector","getState","import_store","getState","dispatch","import_store","dispatch","import_editor_elements","import_store","getState","dispatch","registerSlice","listenTo"]}
|
package/dist/index.mjs
CHANGED
|
@@ -38,13 +38,6 @@ var apiClient = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
// src/store/thunks.ts
|
|
41
|
-
var createComponent = createAsyncThunk(
|
|
42
|
-
"components/create",
|
|
43
|
-
async (payload) => {
|
|
44
|
-
const response = await apiClient.create(payload);
|
|
45
|
-
return { ...response, name: payload.name };
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
41
|
var loadComponents = createAsyncThunk("components/load", async () => {
|
|
49
42
|
const response = await apiClient.get();
|
|
50
43
|
return response;
|
|
@@ -55,7 +48,6 @@ var initialState = {
|
|
|
55
48
|
data: [],
|
|
56
49
|
unpublishedData: [],
|
|
57
50
|
loadStatus: "idle",
|
|
58
|
-
createStatus: "idle",
|
|
59
51
|
styles: {}
|
|
60
52
|
};
|
|
61
53
|
var SLICE_NAME = "components";
|
|
@@ -98,24 +90,10 @@ var slice = createSlice({
|
|
|
98
90
|
builder.addCase(loadComponents.rejected, (state) => {
|
|
99
91
|
state.loadStatus = "error";
|
|
100
92
|
});
|
|
101
|
-
builder.addCase(createComponent.fulfilled, (state, { payload, meta }) => {
|
|
102
|
-
state.createStatus = "idle";
|
|
103
|
-
state.data.push({
|
|
104
|
-
id: payload.component_id,
|
|
105
|
-
name: meta.arg.name
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
builder.addCase(createComponent.pending, (state) => {
|
|
109
|
-
state.createStatus = "pending";
|
|
110
|
-
});
|
|
111
|
-
builder.addCase(createComponent.rejected, (state) => {
|
|
112
|
-
state.createStatus = "error";
|
|
113
|
-
});
|
|
114
93
|
}
|
|
115
94
|
});
|
|
116
95
|
var selectData = (state) => state[SLICE_NAME].data;
|
|
117
96
|
var selectLoadStatus = (state) => state[SLICE_NAME].loadStatus;
|
|
118
|
-
var selectCreateStatus = (state) => state[SLICE_NAME].createStatus;
|
|
119
97
|
var selectStylesDefinitions = (state) => state[SLICE_NAME].styles ?? {};
|
|
120
98
|
var selectUnpublishedData = (state) => state[SLICE_NAME].unpublishedData;
|
|
121
99
|
var selectComponents = createSelector(
|
|
@@ -132,8 +110,6 @@ var selectUnpublishedComponents = createSelector(
|
|
|
132
110
|
);
|
|
133
111
|
var selectLoadIsPending = createSelector(selectLoadStatus, (status) => status === "pending");
|
|
134
112
|
var selectLoadIsError = createSelector(selectLoadStatus, (status) => status === "error");
|
|
135
|
-
var selectCreateIsPending = createSelector(selectCreateStatus, (status) => status === "pending");
|
|
136
|
-
var selectCreateIsError = createSelector(selectCreateStatus, (status) => status === "error");
|
|
137
113
|
var selectStyles = (state) => state[SLICE_NAME].styles ?? {};
|
|
138
114
|
var selectFlatStyles = createSelector(selectStylesDefinitions, (data) => Object.values(data).flat());
|
|
139
115
|
|
|
@@ -142,7 +118,7 @@ var componentIdTransformer = createTransformer(async (id) => {
|
|
|
142
118
|
const unpublishedComponents = selectUnpublishedComponents(getState());
|
|
143
119
|
const unpublishedComponent = unpublishedComponents.find((component) => component.id === id);
|
|
144
120
|
if (unpublishedComponent) {
|
|
145
|
-
return structuredClone(unpublishedComponent.
|
|
121
|
+
return structuredClone(unpublishedComponent.elements);
|
|
146
122
|
}
|
|
147
123
|
const extendedWindow = window;
|
|
148
124
|
const documentManager = extendedWindow.elementor?.documents;
|
|
@@ -594,7 +570,7 @@ function CreateComponentForm() {
|
|
|
594
570
|
slice.actions.addUnpublished({
|
|
595
571
|
id: tempId,
|
|
596
572
|
name: values.componentName,
|
|
597
|
-
|
|
573
|
+
elements: [element.element.model.toJSON({ remove: ["default"] })]
|
|
598
574
|
})
|
|
599
575
|
);
|
|
600
576
|
replaceElementWithComponent(element.element, {
|
|
@@ -909,14 +885,19 @@ var beforeSave = async ({ container, status }) => {
|
|
|
909
885
|
}
|
|
910
886
|
};
|
|
911
887
|
async function createComponents(components, status) {
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
888
|
+
const response = await apiClient.create({
|
|
889
|
+
status,
|
|
890
|
+
items: components.map((component) => ({
|
|
891
|
+
temp_id: component.id,
|
|
892
|
+
title: component.name,
|
|
893
|
+
elements: component.elements
|
|
894
|
+
}))
|
|
895
|
+
});
|
|
896
|
+
const map = /* @__PURE__ */ new Map();
|
|
897
|
+
Object.entries(response).forEach(([key, value]) => {
|
|
898
|
+
map.set(Number(key), value);
|
|
917
899
|
});
|
|
918
|
-
|
|
919
|
-
return tempIdToComponentId;
|
|
900
|
+
return map;
|
|
920
901
|
}
|
|
921
902
|
function updateComponentInstances(elements, tempIdToComponentId) {
|
|
922
903
|
elements.forEach((element) => {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts","../src/component-id-transformer.ts","../src/store/store.ts","../src/store/thunks.ts","../src/api.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/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/components/create-component-form/hooks/use-form.ts","../src/components/create-component-form/utils/component-form-schema.ts","../src/create-component-type.ts","../src/populate-store.ts","../src/store/components-styles-provider.ts","../src/store/load-components-styles.ts","../src/utils/get-component-ids.ts","../src/store/remove-component-styles.ts","../src/utils/before-save.ts"],"sourcesContent":["import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { registerElementType, settingsTransformersRegistry } from '@elementor/editor-canvas';\nimport { getV1CurrentDocument } from '@elementor/editor-documents';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { stylesRepository } from '@elementor/editor-styles-repository';\nimport { __privateListenTo as listenTo, commandStartEvent, registerDataHook } from '@elementor/editor-v1-adapters';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { componentIdTransformer } from './component-id-transformer';\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { createComponentType, TYPE } from './create-component-type';\nimport { PopulateStore } from './populate-store';\nimport { componentsStylesProvider } from './store/components-styles-provider';\nimport { loadComponentsStyles } from './store/load-components-styles';\nimport { removeComponentStyles } from './store/remove-component-styles';\nimport { slice } from './store/store';\nimport { type Element, type ExtendedWindow } from './types';\nimport { beforeSave } from './utils/before-save';\n\nconst COMPONENT_DOCUMENT_TYPE = 'elementor_component';\n\nexport function init() {\n\tstylesRepository.register( componentsStylesProvider );\n\tregisterSlice( slice );\n\tregisterElementType( TYPE, createComponentType );\n\tregisterDataHook( 'dependency', 'editor/documents/close', ( args ) => {\n\t\tconst document = getV1CurrentDocument();\n\t\tif ( document.config.type === COMPONENT_DOCUMENT_TYPE ) {\n\t\t\targs.mode = 'autosave';\n\t\t}\n\t\treturn true;\n\t} );\n\n\t( window as unknown as ExtendedWindow ).elementorCommon.__beforeSave = beforeSave;\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\tlistenTo( commandStartEvent( 'editor/documents/attach-preview' ), () => {\n\t\tconst { id, config } = getV1CurrentDocument();\n\n\t\tif ( id ) {\n\t\t\tremoveComponentStyles( id );\n\t\t}\n\n\t\tloadComponentsStyles( ( config?.elements as Element[] ) ?? [] );\n\t} );\n\n\tsettingsTransformersRegistry.register( 'component-id', componentIdTransformer );\n}\n","import { createTransformer } from '@elementor/editor-canvas';\nimport { __getState as getState } from '@elementor/store';\n\nimport { selectUnpublishedComponents } from './store/store';\n\ntype ComponentIdTransformerWindow = Window & {\n\telementor?: {\n\t\tdocuments?: {\n\t\t\trequest: ( id: number ) => Promise< { elements?: unknown[] } >;\n\t\t};\n\t};\n};\n\nexport const componentIdTransformer = createTransformer( async ( id: number ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tconst unpublishedComponent = unpublishedComponents.find( ( component ) => component.id === id );\n\tif ( unpublishedComponent ) {\n\t\treturn structuredClone( unpublishedComponent.content );\n\t}\n\n\tconst extendedWindow = window as unknown as ComponentIdTransformerWindow;\n\n\tconst documentManager = extendedWindow.elementor?.documents;\n\n\tif ( ! documentManager ) {\n\t\tthrow new Error( 'Elementor documents manager not found' );\n\t}\n\n\tconst data = await documentManager.request( id );\n\n\treturn data.elements ?? [];\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { type Component, type ComponentId, type StylesDefinition } from '../types';\nimport { createComponent, loadComponents } from './thunks';\n\ntype GetComponentResponse = Component[];\n\nexport type UnpublishedComponent = Component & {\n\tcontent: V1ElementData[];\n};\n\ntype Status = 'idle' | 'pending' | 'error';\n\ntype ComponentsState = {\n\tdata: Component[];\n\tunpublishedData: UnpublishedComponent[];\n\tloadStatus: Status;\n\tcreateStatus: Status;\n\tstyles: StylesDefinition;\n};\n\ntype ComponentsSlice = SliceState< typeof slice >;\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tunpublishedData: [],\n\tloadStatus: 'idle',\n\tcreateStatus: 'idle',\n\tstyles: {},\n};\n\nexport const SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload }: PayloadAction< Component | Component[] > ) => {\n\t\t\tif ( Array.isArray( payload ) ) {\n\t\t\t\tstate.data = [ ...state.data, ...payload ];\n\t\t\t} else {\n\t\t\t\tstate.data.unshift( payload );\n\t\t\t}\n\t\t},\n\t\tload: ( state, { payload }: PayloadAction< Component[] > ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t\taddUnpublished: ( state, { payload } ) => {\n\t\t\tstate.unpublishedData.unshift( payload );\n\t\t},\n\t\tresetUnpublished: ( state ) => {\n\t\t\tstate.unpublishedData = [];\n\t\t},\n\t\tremoveStyles( state, { payload }: PayloadAction< { id: ComponentId } > ) {\n\t\t\tconst { [ payload.id ]: _, ...rest } = state.styles;\n\n\t\t\tstate.styles = rest;\n\t\t},\n\t\taddStyles: ( state, { payload } ) => {\n\t\t\tstate.styles = { ...state.styles, ...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: ComponentsSlice ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].loadStatus;\nconst selectCreateStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].createStatus;\nconst selectStylesDefinitions = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nconst selectUnpublishedData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].unpublishedData;\n\nexport const selectComponents = createSelector(\n\tselectData,\n\tselectUnpublishedData,\n\t( data: Component[], unpublishedData: UnpublishedComponent[] ) => [\n\t\t...unpublishedData.map( ( item ) => ( { id: item.id, name: item.name } ) ),\n\t\t...data,\n\t]\n);\nexport const selectUnpublishedComponents = createSelector(\n\tselectUnpublishedData,\n\t( unpublishedData: UnpublishedComponent[] ) => unpublishedData\n);\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' );\nexport const selectStyles = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nexport const selectFlatStyles = createSelector( selectStylesDefinitions, ( data ) => Object.values( data ).flat() );\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 V1ElementData } from '@elementor/editor-elements';\nimport { ajax } from '@elementor/editor-v1-adapters';\nimport { type HttpResponse, httpService } from '@elementor/http-client';\n\nimport { type Component, type DocumentStatus } from './types';\n\nconst BASE_URL = 'elementor/v1/components';\n\nexport type CreateComponentPayload = {\n\tname: string;\n\tcontent: V1ElementData[];\n\tstatus: DocumentStatus;\n};\n\ntype GetComponentResponse = Array< Component >;\n\nexport type CreateComponentResponse = {\n\tcomponent_id: number;\n};\n\nexport const getParams = ( id: number ) => ( {\n\taction: 'get_document_config',\n\tunique_id: `document-config-${ id }`,\n\tdata: { id },\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\tgetComponentConfig: ( id: number ) => ajax.load< { id: number }, V1ElementData >( getParams( id ) ),\n\tinvalidateComponentConfigCache: ( id: number ) => ajax.invalidateCache< { id: number } >( getParams( id ) ),\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/store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\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';\n\nimport { type Component } from '../../../types';\n\nexport const replaceElementWithComponent = ( 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: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: component.id,\n\t\t\t},\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 { __useDispatch as useDispatch } from '@elementor/store';\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 { slice } from '../../store/store';\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 dispatch = useDispatch();\n\n\tuseEffect( () => {\n\t\tconst OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';\n\n\t\tconst openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {\n\t\t\tsetElement( { element: event.detail.element, elementLabel: getElementLabel( event.detail.element.id ) } );\n\t\t\tsetAnchorPosition( event.detail.anchorPosition );\n\t\t};\n\n\t\twindow.addEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\t\t};\n\t}, [] );\n\n\tconst handleSave = async ( values: ComponentFormValues ) => {\n\t\ttry {\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't save element as component: element not found` );\n\t\t\t}\n\n\t\t\tconst tempId = generateTempId();\n\n\t\t\tdispatch(\n\t\t\t\tslice.actions.addUnpublished( {\n\t\t\t\t\tid: tempId,\n\t\t\t\t\tname: values.componentName,\n\t\t\t\t\tcontent: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: tempId,\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 temp ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (temp ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', tempId.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\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\tclosePopup,\n}: {\n\tinitialValues: ComponentFormValues;\n\thandleSave: ( values: ComponentFormValues ) => void;\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 } 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={ ! 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{ __( 'Create', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n};\n\nexport const generateTempId = () => {\n\treturn Date.now() + Math.floor( Math.random() * 1000000 );\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 {\n\ttype CreateTemplatedElementTypeOptions,\n\tcreateTemplatedElementView,\n\ttype ElementType,\n\ttype ElementView,\n\ttype LegacyWindow,\n} from '@elementor/editor-canvas';\nimport { type NumberPropValue } from '@elementor/editor-props';\nimport { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nexport const TYPE = 'e-component';\n\nexport function createComponentType( options: CreateTemplatedElementTypeOptions ): typeof ElementType {\n\tconst legacyWindow = window as unknown as LegacyWindow;\n\n\treturn class extends legacyWindow.elementor.modules.elements.types.Widget {\n\t\tgetType() {\n\t\t\treturn options.type;\n\t\t}\n\n\t\tgetView() {\n\t\t\treturn createComponentView( options );\n\t\t}\n\t};\n}\n\nfunction createComponentView( options: CreateTemplatedElementTypeOptions ): typeof ElementView {\n\treturn class extends createTemplatedElementView( options ) {\n\t\tlegacyWindow = window as unknown as LegacyWindow;\n\n\t\tafterSettingsResolve( settings: { [ key: string ]: unknown } ) {\n\t\t\tif ( settings.component ) {\n\t\t\t\tthis.collection = this.legacyWindow.elementor.createBackboneElementsCollection( settings.component );\n\n\t\t\t\tsettings.component = '<template data-children-placeholder></template>';\n\t\t\t}\n\n\t\t\treturn settings;\n\t\t}\n\n\t\tattachBuffer( collectionView: this, buffer: DocumentFragment ): void {\n\t\t\tconst childrenPlaceholder = collectionView.$el.find( '[data-children-placeholder]' ).get( 0 );\n\n\t\t\tif ( ! childrenPlaceholder ) {\n\t\t\t\tsuper.attachBuffer( collectionView, buffer );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tchildrenPlaceholder.replaceWith( buffer );\n\t\t}\n\n\t\tgetComponentId() {\n\t\t\treturn this.options?.model?.get( 'settings' )?.get( 'component' ) as NumberPropValue;\n\t\t}\n\n\t\tgetContextMenuGroups() {\n\t\t\tconst filteredGroups = super.getContextMenuGroups().filter( ( group ) => group.name !== 'save' );\n\t\t\tconst componentId = this.getComponentId()?.value;\n\n\t\t\tif ( ! componentId ) {\n\t\t\t\treturn filteredGroups;\n\t\t\t}\n\n\t\t\tconst newGroup = {\n\t\t\t\tname: 'edit component',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'edit component',\n\t\t\t\t\t\ticon: 'eicon-edit',\n\t\t\t\t\t\ttitle: () => __( 'Edit Component', 'elementor' ),\n\t\t\t\t\t\tisEnabled: () => true,\n\t\t\t\t\t\tcallback: () => this.switchDocument(),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t\treturn [ ...filteredGroups, newGroup ];\n\t\t}\n\n\t\tswitchDocument() {\n\t\t\trunCommand( 'editor/documents/switch', {\n\t\t\t\tid: this.getComponentId().value,\n\t\t\t\tselector: `[data-id=\"${ this.model.get( 'id' ) }\"]`,\n\t\t\t\tmode: 'autosave',\n\t\t\t} );\n\t\t}\n\n\t\tui() {\n\t\t\treturn {\n\t\t\t\t...super.ui(),\n\t\t\t\tdoubleClick: '.e-component:not(:has(.elementor-edit-area))',\n\t\t\t};\n\t\t}\n\n\t\tevents() {\n\t\t\treturn {\n\t\t\t\t...super.events(),\n\t\t\t\t'dblclick @ui.doubleClick': this.switchDocument,\n\t\t\t};\n\t\t}\n\t};\n}\n","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './store/thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n","import { createStylesProvider } from '@elementor/editor-styles-repository';\nimport { __getState as getState, __subscribeWithSelector as subscribeWithSelector } from '@elementor/store';\n\nimport { selectFlatStyles, SLICE_NAME } from './store';\n\nexport const componentsStylesProvider = createStylesProvider( {\n\tkey: 'components-styles',\n\tpriority: 100,\n\tsubscribe: ( cb ) =>\n\t\tsubscribeWithSelector(\n\t\t\t( state ) => state[ SLICE_NAME ],\n\t\t\t() => {\n\t\t\t\tcb();\n\t\t\t}\n\t\t),\n\tactions: {\n\t\tall: () => {\n\t\t\treturn selectFlatStyles( getState() );\n\t\t},\n\t\tget: ( id ) => {\n\t\t\treturn selectFlatStyles( getState() ).find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { type StyleDefinition } from '@elementor/editor-styles';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { type ComponentId, type Element } from '../types';\nimport { getComponentIds } from '../utils/get-component-ids';\nimport { selectStyles, slice } from './store';\n\nexport async function loadComponentsStyles( elements: Element[] ) {\n\tconst componentIds = Array.from( new Set( getComponentIds( elements ) ) );\n\n\tif ( ! componentIds.length ) {\n\t\treturn;\n\t}\n\n\tconst knownComponents = selectStyles( getState() );\n\tconst unknownComponentIds = componentIds.filter( ( id ) => ! knownComponents[ id ] );\n\n\tif ( ! unknownComponentIds.length ) {\n\t\treturn;\n\t}\n\n\taddComponentStyles( unknownComponentIds );\n}\n\nasync function addComponentStyles( ids: ComponentId[] ) {\n\tconst newComponents = await loadStyles( ids );\n\n\taddStyles( newComponents );\n\n\tObject.values( newComponents ).forEach( ( [ , data ] ) => {\n\t\tloadComponentsStyles( data.elements as Element[] );\n\t} );\n}\n\nasync function loadStyles( ids: number[] ): Promise< [ number, V1ElementData ][] > {\n\treturn Promise.all( ids.map( async ( id ) => [ id, await apiClient.getComponentConfig( id ) ] ) );\n}\n\nfunction addStyles( data: ( readonly [ ComponentId, V1ElementData ] )[] ) {\n\tconst styles = Object.fromEntries(\n\t\tdata.map( ( [ componentId, componentData ] ) => [ componentId, extractStyles( componentData ) ] )\n\t);\n\n\tdispatch( slice.actions.addStyles( styles ) );\n}\n\nfunction extractStyles( element: V1ElementData ): Array< StyleDefinition > {\n\treturn [ ...Object.values( element.styles ?? {} ), ...( element.elements ?? [] ).flatMap( extractStyles ) ];\n}\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { isTransformable } from '@elementor/editor-props';\n\nexport const getComponentIds = ( elements: V1ElementData[] ) => {\n\treturn elements.flatMap( ( element ) => {\n\t\tconst ids: number[] = [];\n\n\t\tconst type = element.widgetType || element.elType;\n\n\t\tif ( type === 'e-component' && element.settings?.component && isTransformable( element.settings?.component ) ) {\n\t\t\tids.push( element.settings.component.value );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tids.push( ...getComponentIds( element.elements ) );\n\t\t}\n\n\t\treturn ids;\n\t} );\n};\n","import { __dispatch as dispatch } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { slice } from './store';\n\nexport function removeComponentStyles( id: number ) {\n\tapiClient.invalidateComponentConfigCache( id );\n\tdispatch( slice.actions.removeStyles( { id } ) );\n}\n","import { updateElementSettings, type V1ElementData } from '@elementor/editor-elements';\nimport { type TransformablePropValue } from '@elementor/editor-props';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { selectUnpublishedComponents, slice, type UnpublishedComponent } from '../store/store';\nimport { type DocumentStatus } from '../types';\n\ntype Container = {\n\tmodel: {\n\t\tget: ( key: 'elements' ) => {\n\t\t\ttoJSON: () => V1ElementData[];\n\t\t};\n\t};\n};\n\nexport const beforeSave = async ( { container, status }: { container: Container; status: DocumentStatus } ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tif ( ! unpublishedComponents.length ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst tempIdToComponentId = await createComponents( unpublishedComponents, status );\n\n\t\tconst elements = container.model.get( 'elements' ).toJSON();\n\t\tupdateComponentInstances( elements, tempIdToComponentId );\n\n\t\tdispatch(\n\t\t\tslice.actions.add(\n\t\t\t\tunpublishedComponents.map( ( component ) => ( {\n\t\t\t\t\tid: tempIdToComponentId.get( component.id ) as number,\n\t\t\t\t\tname: component.name,\n\t\t\t\t} ) )\n\t\t\t)\n\t\t);\n\t\tdispatch( slice.actions.resetUnpublished() );\n\t} catch ( error ) {\n\t\tthrow new Error( `Failed to publish components and update component instances: ${ error }` );\n\t}\n};\n\nasync function createComponents(\n\tcomponents: UnpublishedComponent[],\n\tstatus: DocumentStatus\n): Promise< Map< number, number > > {\n\tconst tempIdToComponentId = new Map< number, number >();\n\n\tconst promises = components.map( ( component ) => {\n\t\treturn apiClient.create( { name: component.name, content: component.content, status } ).then( ( response ) => {\n\t\t\ttempIdToComponentId.set( component.id, response.component_id );\n\t\t} );\n\t} );\n\n\tawait Promise.all( promises );\n\n\treturn tempIdToComponentId;\n}\n\nfunction updateComponentInstances( elements: V1ElementData[], tempIdToComponentId: Map< number, number > ): void {\n\telements.forEach( ( element ) => {\n\t\tconst { shouldUpdate, newComponentId } = shouldUpdateElement( element, tempIdToComponentId );\n\t\tif ( shouldUpdate ) {\n\t\t\tupdateElementComponentId( element.id, newComponentId );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tupdateComponentInstances( element.elements, tempIdToComponentId );\n\t\t}\n\t} );\n}\n\nfunction shouldUpdateElement(\n\telement: V1ElementData,\n\ttempIdToComponentId: Map< number, number >\n): { shouldUpdate: true; newComponentId: number } | { shouldUpdate: false; newComponentId: null } {\n\tif ( element.widgetType === 'e-component' ) {\n\t\tconst currentComponentId = ( element.settings?.component as TransformablePropValue< 'component-id', number > )\n\t\t\t?.value;\n\t\tif ( currentComponentId && tempIdToComponentId.has( currentComponentId ) ) {\n\t\t\treturn { shouldUpdate: true, newComponentId: tempIdToComponentId.get( currentComponentId ) as number };\n\t\t}\n\t}\n\treturn { shouldUpdate: false, newComponentId: null };\n}\n\nfunction updateElementComponentId( elementId: string, componentId: number ): void {\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\tcomponent: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: componentId,\n\t\t\t},\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,qBAAqB,oCAAoC;AAClE,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB,UAAU,mBAAmB,wBAAwB;A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,MAAM;AACvE,UAAM,EAAE,IAAI,OAAO,IAAI,qBAAqB;AAE5C,QAAK,IAAK;AACT,4BAAuB,EAAG;AAAA,IAC3B;AAEA,yBAAwB,QAAQ,YAA2B,CAAC,CAAE;AAAA,EAC/D,CAAE;AAEF,+BAA6B,SAAU,gBAAgB,sBAAuB;AAC/E;","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","__","__","useState","dispatch","__","ThemeProvider","validateForm","useMemo","Stack","Typography","TextField","__","useEffect","useEffect","getState","getState","dispatch","getState","getState","dispatch","dispatch","dispatch","dispatch","getState","getState","dispatch","__"]}
|
|
1
|
+
{"version":3,"sources":["../src/init.ts","../src/component-id-transformer.ts","../src/store/store.ts","../src/store/thunks.ts","../src/api.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/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/components/create-component-form/hooks/use-form.ts","../src/components/create-component-form/utils/component-form-schema.ts","../src/create-component-type.ts","../src/populate-store.ts","../src/store/components-styles-provider.ts","../src/store/load-components-styles.ts","../src/utils/get-component-ids.ts","../src/store/remove-component-styles.ts","../src/utils/before-save.ts"],"sourcesContent":["import { injectIntoLogic, injectIntoTop } from '@elementor/editor';\nimport { registerElementType, settingsTransformersRegistry } from '@elementor/editor-canvas';\nimport { getV1CurrentDocument } from '@elementor/editor-documents';\nimport { injectTab } from '@elementor/editor-elements-panel';\nimport { stylesRepository } from '@elementor/editor-styles-repository';\nimport { __privateListenTo as listenTo, commandStartEvent, registerDataHook } from '@elementor/editor-v1-adapters';\nimport { __registerSlice as registerSlice } from '@elementor/store';\nimport { __ } from '@wordpress/i18n';\n\nimport { componentIdTransformer } from './component-id-transformer';\nimport { Components } from './components/components-tab/components';\nimport { CreateComponentForm } from './components/create-component-form/create-component-form';\nimport { createComponentType, TYPE } from './create-component-type';\nimport { PopulateStore } from './populate-store';\nimport { componentsStylesProvider } from './store/components-styles-provider';\nimport { loadComponentsStyles } from './store/load-components-styles';\nimport { removeComponentStyles } from './store/remove-component-styles';\nimport { slice } from './store/store';\nimport { type Element, type ExtendedWindow } from './types';\nimport { beforeSave } from './utils/before-save';\n\nconst COMPONENT_DOCUMENT_TYPE = 'elementor_component';\n\nexport function init() {\n\tstylesRepository.register( componentsStylesProvider );\n\tregisterSlice( slice );\n\tregisterElementType( TYPE, createComponentType );\n\tregisterDataHook( 'dependency', 'editor/documents/close', ( args ) => {\n\t\tconst document = getV1CurrentDocument();\n\t\tif ( document.config.type === COMPONENT_DOCUMENT_TYPE ) {\n\t\t\targs.mode = 'autosave';\n\t\t}\n\t\treturn true;\n\t} );\n\n\t( window as unknown as ExtendedWindow ).elementorCommon.__beforeSave = beforeSave;\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\tlistenTo( commandStartEvent( 'editor/documents/attach-preview' ), () => {\n\t\tconst { id, config } = getV1CurrentDocument();\n\n\t\tif ( id ) {\n\t\t\tremoveComponentStyles( id );\n\t\t}\n\n\t\tloadComponentsStyles( ( config?.elements as Element[] ) ?? [] );\n\t} );\n\n\tsettingsTransformersRegistry.register( 'component-id', componentIdTransformer );\n}\n","import { createTransformer } from '@elementor/editor-canvas';\nimport { __getState as getState } from '@elementor/store';\n\nimport { selectUnpublishedComponents } from './store/store';\n\ntype ComponentIdTransformerWindow = Window & {\n\telementor?: {\n\t\tdocuments?: {\n\t\t\trequest: ( id: number ) => Promise< { elements?: unknown[] } >;\n\t\t};\n\t};\n};\n\nexport const componentIdTransformer = createTransformer( async ( id: number ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tconst unpublishedComponent = unpublishedComponents.find( ( component ) => component.id === id );\n\tif ( unpublishedComponent ) {\n\t\treturn structuredClone( unpublishedComponent.elements );\n\t}\n\n\tconst extendedWindow = window as unknown as ComponentIdTransformerWindow;\n\n\tconst documentManager = extendedWindow.elementor?.documents;\n\n\tif ( ! documentManager ) {\n\t\tthrow new Error( 'Elementor documents manager not found' );\n\t}\n\n\tconst data = await documentManager.request( id );\n\n\treturn data.elements ?? [];\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport {\n\t__createSelector as createSelector,\n\t__createSlice as createSlice,\n\ttype PayloadAction,\n\ttype SliceState,\n} from '@elementor/store';\n\nimport { type Component, type ComponentId, type StylesDefinition } from '../types';\nimport { loadComponents } from './thunks';\n\ntype GetComponentResponse = Component[];\n\nexport type UnpublishedComponent = Component & {\n\telements: V1ElementData[];\n};\n\ntype Status = 'idle' | 'pending' | 'error';\n\ntype ComponentsState = {\n\tdata: Component[];\n\tunpublishedData: UnpublishedComponent[];\n\tloadStatus: Status;\n\tstyles: StylesDefinition;\n};\n\ntype ComponentsSlice = SliceState< typeof slice >;\n\nexport const initialState: ComponentsState = {\n\tdata: [],\n\tunpublishedData: [],\n\tloadStatus: 'idle',\n\tstyles: {},\n};\n\nexport const SLICE_NAME = 'components';\nexport const slice = createSlice( {\n\tname: SLICE_NAME,\n\tinitialState,\n\treducers: {\n\t\tadd: ( state, { payload }: PayloadAction< Component | Component[] > ) => {\n\t\t\tif ( Array.isArray( payload ) ) {\n\t\t\t\tstate.data = [ ...state.data, ...payload ];\n\t\t\t} else {\n\t\t\t\tstate.data.unshift( payload );\n\t\t\t}\n\t\t},\n\t\tload: ( state, { payload }: PayloadAction< Component[] > ) => {\n\t\t\tstate.data = payload;\n\t\t},\n\t\taddUnpublished: ( state, { payload } ) => {\n\t\t\tstate.unpublishedData.unshift( payload );\n\t\t},\n\t\tresetUnpublished: ( state ) => {\n\t\t\tstate.unpublishedData = [];\n\t\t},\n\t\tremoveStyles( state, { payload }: PayloadAction< { id: ComponentId } > ) {\n\t\t\tconst { [ payload.id ]: _, ...rest } = state.styles;\n\n\t\t\tstate.styles = rest;\n\t\t},\n\t\taddStyles: ( state, { payload } ) => {\n\t\t\tstate.styles = { ...state.styles, ...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},\n} );\n\nconst selectData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].data;\nconst selectLoadStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].loadStatus;\nconst selectStylesDefinitions = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nconst selectUnpublishedData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].unpublishedData;\n\nexport const selectComponents = createSelector(\n\tselectData,\n\tselectUnpublishedData,\n\t( data: Component[], unpublishedData: UnpublishedComponent[] ) => [\n\t\t...unpublishedData.map( ( item ) => ( { id: item.id, name: item.name } ) ),\n\t\t...data,\n\t]\n);\nexport const selectUnpublishedComponents = createSelector(\n\tselectUnpublishedData,\n\t( unpublishedData: UnpublishedComponent[] ) => unpublishedData\n);\nexport const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );\nexport const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );\nexport const selectStyles = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};\nexport const selectFlatStyles = createSelector( selectStylesDefinitions, ( data ) => Object.values( data ).flat() );\n","import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';\n\nimport { apiClient } from '../api';\n\nconst loadComponents = createAsyncThunk( 'components/load', async () => {\n\tconst response = await apiClient.get();\n\treturn response;\n} );\n\nexport { loadComponents };\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { ajax } from '@elementor/editor-v1-adapters';\nimport { type HttpResponse, httpService } from '@elementor/http-client';\n\nimport { type Component, type DocumentStatus } from './types';\n\nconst BASE_URL = 'elementor/v1/components';\n\nexport type CreateComponentPayload = {\n\tstatus: DocumentStatus;\n\titems: Array< {\n\t\ttemp_id: number;\n\t\ttitle: string;\n\t\telements: V1ElementData[];\n\t} >;\n};\n\ntype GetComponentResponse = Array< Component >;\n\nexport type CreateComponentResponse = Record< number, number >;\n\nexport const getParams = ( id: number ) => ( {\n\taction: 'get_document_config',\n\tunique_id: `document-config-${ id }`,\n\tdata: { id },\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\tgetComponentConfig: ( id: number ) => ajax.load< { id: number }, V1ElementData >( getParams( id ) ),\n\tinvalidateComponentConfigCache: ( id: number ) => ajax.invalidateCache< { id: number } >( getParams( id ) ),\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/store';\n\nexport const useComponents = () => {\n\tconst components = useSelector( selectComponents );\n\tconst isLoading = useSelector( selectLoadIsPending );\n\n\treturn { components, isLoading };\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';\n\nimport { type Component } from '../../../types';\n\nexport const replaceElementWithComponent = ( 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: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: component.id,\n\t\t\t},\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 { __useDispatch as useDispatch } from '@elementor/store';\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 { slice } from '../../store/store';\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 dispatch = useDispatch();\n\n\tuseEffect( () => {\n\t\tconst OPEN_SAVE_AS_COMPONENT_FORM_EVENT = 'elementor/editor/open-save-as-component-form';\n\n\t\tconst openPopup = ( event: CustomEvent< SaveAsComponentEventData > ) => {\n\t\t\tsetElement( { element: event.detail.element, elementLabel: getElementLabel( event.detail.element.id ) } );\n\t\t\tsetAnchorPosition( event.detail.anchorPosition );\n\t\t};\n\n\t\twindow.addEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup as EventListener );\n\t\t};\n\t}, [] );\n\n\tconst handleSave = async ( values: ComponentFormValues ) => {\n\t\ttry {\n\t\t\tif ( ! element ) {\n\t\t\t\tthrow new Error( `Can't save element as component: element not found` );\n\t\t\t}\n\n\t\t\tconst tempId = generateTempId();\n\n\t\t\tdispatch(\n\t\t\t\tslice.actions.addUnpublished( {\n\t\t\t\t\tid: tempId,\n\t\t\t\t\tname: values.componentName,\n\t\t\t\t\telements: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\treplaceElementWithComponent( element.element, {\n\t\t\t\tid: tempId,\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 temp ID\n\t\t\t\tmessage: __( 'Component saved successfully as: %1$s (temp ID: %2$s)', 'elementor' )\n\t\t\t\t\t.replace( '%1$s', values.componentName )\n\t\t\t\t\t.replace( '%2$s', tempId.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\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\tclosePopup,\n}: {\n\tinitialValues: ComponentFormValues;\n\thandleSave: ( values: ComponentFormValues ) => void;\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 } 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={ ! 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{ __( 'Create', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n};\n\nexport const generateTempId = () => {\n\treturn Date.now() + Math.floor( Math.random() * 1000000 );\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 {\n\ttype CreateTemplatedElementTypeOptions,\n\tcreateTemplatedElementView,\n\ttype ElementType,\n\ttype ElementView,\n\ttype LegacyWindow,\n} from '@elementor/editor-canvas';\nimport { type NumberPropValue } from '@elementor/editor-props';\nimport { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';\nimport { __ } from '@wordpress/i18n';\n\nexport const TYPE = 'e-component';\n\nexport function createComponentType( options: CreateTemplatedElementTypeOptions ): typeof ElementType {\n\tconst legacyWindow = window as unknown as LegacyWindow;\n\n\treturn class extends legacyWindow.elementor.modules.elements.types.Widget {\n\t\tgetType() {\n\t\t\treturn options.type;\n\t\t}\n\n\t\tgetView() {\n\t\t\treturn createComponentView( options );\n\t\t}\n\t};\n}\n\nfunction createComponentView( options: CreateTemplatedElementTypeOptions ): typeof ElementView {\n\treturn class extends createTemplatedElementView( options ) {\n\t\tlegacyWindow = window as unknown as LegacyWindow;\n\n\t\tafterSettingsResolve( settings: { [ key: string ]: unknown } ) {\n\t\t\tif ( settings.component ) {\n\t\t\t\tthis.collection = this.legacyWindow.elementor.createBackboneElementsCollection( settings.component );\n\n\t\t\t\tsettings.component = '<template data-children-placeholder></template>';\n\t\t\t}\n\n\t\t\treturn settings;\n\t\t}\n\n\t\tattachBuffer( collectionView: this, buffer: DocumentFragment ): void {\n\t\t\tconst childrenPlaceholder = collectionView.$el.find( '[data-children-placeholder]' ).get( 0 );\n\n\t\t\tif ( ! childrenPlaceholder ) {\n\t\t\t\tsuper.attachBuffer( collectionView, buffer );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tchildrenPlaceholder.replaceWith( buffer );\n\t\t}\n\n\t\tgetComponentId() {\n\t\t\treturn this.options?.model?.get( 'settings' )?.get( 'component' ) as NumberPropValue;\n\t\t}\n\n\t\tgetContextMenuGroups() {\n\t\t\tconst filteredGroups = super.getContextMenuGroups().filter( ( group ) => group.name !== 'save' );\n\t\t\tconst componentId = this.getComponentId()?.value;\n\n\t\t\tif ( ! componentId ) {\n\t\t\t\treturn filteredGroups;\n\t\t\t}\n\n\t\t\tconst newGroup = {\n\t\t\t\tname: 'edit component',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'edit component',\n\t\t\t\t\t\ticon: 'eicon-edit',\n\t\t\t\t\t\ttitle: () => __( 'Edit Component', 'elementor' ),\n\t\t\t\t\t\tisEnabled: () => true,\n\t\t\t\t\t\tcallback: () => this.switchDocument(),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t\treturn [ ...filteredGroups, newGroup ];\n\t\t}\n\n\t\tswitchDocument() {\n\t\t\trunCommand( 'editor/documents/switch', {\n\t\t\t\tid: this.getComponentId().value,\n\t\t\t\tselector: `[data-id=\"${ this.model.get( 'id' ) }\"]`,\n\t\t\t\tmode: 'autosave',\n\t\t\t} );\n\t\t}\n\n\t\tui() {\n\t\t\treturn {\n\t\t\t\t...super.ui(),\n\t\t\t\tdoubleClick: '.e-component:not(:has(.elementor-edit-area))',\n\t\t\t};\n\t\t}\n\n\t\tevents() {\n\t\t\treturn {\n\t\t\t\t...super.events(),\n\t\t\t\t'dblclick @ui.doubleClick': this.switchDocument,\n\t\t\t};\n\t\t}\n\t};\n}\n","import { useEffect } from 'react';\nimport { __dispatch as dispatch } from '@elementor/store';\n\nimport { loadComponents } from './store/thunks';\n\nexport function PopulateStore() {\n\tuseEffect( () => {\n\t\tdispatch( loadComponents() );\n\t}, [] );\n\n\treturn null;\n}\n","import { createStylesProvider } from '@elementor/editor-styles-repository';\nimport { __getState as getState, __subscribeWithSelector as subscribeWithSelector } from '@elementor/store';\n\nimport { selectFlatStyles, SLICE_NAME } from './store';\n\nexport const componentsStylesProvider = createStylesProvider( {\n\tkey: 'components-styles',\n\tpriority: 100,\n\tsubscribe: ( cb ) =>\n\t\tsubscribeWithSelector(\n\t\t\t( state ) => state[ SLICE_NAME ],\n\t\t\t() => {\n\t\t\t\tcb();\n\t\t\t}\n\t\t),\n\tactions: {\n\t\tall: () => {\n\t\t\treturn selectFlatStyles( getState() );\n\t\t},\n\t\tget: ( id ) => {\n\t\t\treturn selectFlatStyles( getState() ).find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n} );\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { type StyleDefinition } from '@elementor/editor-styles';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { type ComponentId, type Element } from '../types';\nimport { getComponentIds } from '../utils/get-component-ids';\nimport { selectStyles, slice } from './store';\n\nexport async function loadComponentsStyles( elements: Element[] ) {\n\tconst componentIds = Array.from( new Set( getComponentIds( elements ) ) );\n\n\tif ( ! componentIds.length ) {\n\t\treturn;\n\t}\n\n\tconst knownComponents = selectStyles( getState() );\n\tconst unknownComponentIds = componentIds.filter( ( id ) => ! knownComponents[ id ] );\n\n\tif ( ! unknownComponentIds.length ) {\n\t\treturn;\n\t}\n\n\taddComponentStyles( unknownComponentIds );\n}\n\nasync function addComponentStyles( ids: ComponentId[] ) {\n\tconst newComponents = await loadStyles( ids );\n\n\taddStyles( newComponents );\n\n\tObject.values( newComponents ).forEach( ( [ , data ] ) => {\n\t\tloadComponentsStyles( data.elements as Element[] );\n\t} );\n}\n\nasync function loadStyles( ids: number[] ): Promise< [ number, V1ElementData ][] > {\n\treturn Promise.all( ids.map( async ( id ) => [ id, await apiClient.getComponentConfig( id ) ] ) );\n}\n\nfunction addStyles( data: ( readonly [ ComponentId, V1ElementData ] )[] ) {\n\tconst styles = Object.fromEntries(\n\t\tdata.map( ( [ componentId, componentData ] ) => [ componentId, extractStyles( componentData ) ] )\n\t);\n\n\tdispatch( slice.actions.addStyles( styles ) );\n}\n\nfunction extractStyles( element: V1ElementData ): Array< StyleDefinition > {\n\treturn [ ...Object.values( element.styles ?? {} ), ...( element.elements ?? [] ).flatMap( extractStyles ) ];\n}\n","import { type V1ElementData } from '@elementor/editor-elements';\nimport { isTransformable } from '@elementor/editor-props';\n\nexport const getComponentIds = ( elements: V1ElementData[] ) => {\n\treturn elements.flatMap( ( element ) => {\n\t\tconst ids: number[] = [];\n\n\t\tconst type = element.widgetType || element.elType;\n\n\t\tif ( type === 'e-component' && element.settings?.component && isTransformable( element.settings?.component ) ) {\n\t\t\tids.push( element.settings.component.value );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tids.push( ...getComponentIds( element.elements ) );\n\t\t}\n\n\t\treturn ids;\n\t} );\n};\n","import { __dispatch as dispatch } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { slice } from './store';\n\nexport function removeComponentStyles( id: number ) {\n\tapiClient.invalidateComponentConfigCache( id );\n\tdispatch( slice.actions.removeStyles( { id } ) );\n}\n","import { updateElementSettings, type V1ElementData } from '@elementor/editor-elements';\nimport { type TransformablePropValue } from '@elementor/editor-props';\nimport { __dispatch as dispatch, __getState as getState } from '@elementor/store';\n\nimport { apiClient } from '../api';\nimport { selectUnpublishedComponents, slice, type UnpublishedComponent } from '../store/store';\nimport { type DocumentStatus } from '../types';\n\ntype Container = {\n\tmodel: {\n\t\tget: ( key: 'elements' ) => {\n\t\t\ttoJSON: () => V1ElementData[];\n\t\t};\n\t};\n};\n\nexport const beforeSave = async ( { container, status }: { container: Container; status: DocumentStatus } ) => {\n\tconst unpublishedComponents = selectUnpublishedComponents( getState() );\n\n\tif ( ! unpublishedComponents.length ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst tempIdToComponentId = await createComponents( unpublishedComponents, status );\n\n\t\tconst elements = container.model.get( 'elements' ).toJSON();\n\t\tupdateComponentInstances( elements, tempIdToComponentId );\n\n\t\tdispatch(\n\t\t\tslice.actions.add(\n\t\t\t\tunpublishedComponents.map( ( component ) => ( {\n\t\t\t\t\tid: tempIdToComponentId.get( component.id ) as number,\n\t\t\t\t\tname: component.name,\n\t\t\t\t} ) )\n\t\t\t)\n\t\t);\n\t\tdispatch( slice.actions.resetUnpublished() );\n\t} catch ( error ) {\n\t\tthrow new Error( `Failed to publish components and update component instances: ${ error }` );\n\t}\n};\n\nasync function createComponents(\n\tcomponents: UnpublishedComponent[],\n\tstatus: DocumentStatus\n): Promise< Map< number, number > > {\n\tconst response = await apiClient.create( {\n\t\tstatus,\n\t\titems: components.map( ( component ) => ( {\n\t\t\ttemp_id: component.id,\n\t\t\ttitle: component.name,\n\t\t\telements: component.elements,\n\t\t} ) ),\n\t} );\n\n\tconst map = new Map< number, number >();\n\n\tObject.entries( response ).forEach( ( [ key, value ] ) => {\n\t\tmap.set( Number( key ), value );\n\t} );\n\n\treturn map;\n}\n\nfunction updateComponentInstances( elements: V1ElementData[], tempIdToComponentId: Map< number, number > ): void {\n\telements.forEach( ( element ) => {\n\t\tconst { shouldUpdate, newComponentId } = shouldUpdateElement( element, tempIdToComponentId );\n\t\tif ( shouldUpdate ) {\n\t\t\tupdateElementComponentId( element.id, newComponentId );\n\t\t}\n\n\t\tif ( element.elements ) {\n\t\t\tupdateComponentInstances( element.elements, tempIdToComponentId );\n\t\t}\n\t} );\n}\n\nfunction shouldUpdateElement(\n\telement: V1ElementData,\n\ttempIdToComponentId: Map< number, number >\n): { shouldUpdate: true; newComponentId: number } | { shouldUpdate: false; newComponentId: null } {\n\tif ( element.widgetType === 'e-component' ) {\n\t\tconst currentComponentId = ( element.settings?.component as TransformablePropValue< 'component-id', number > )\n\t\t\t?.value;\n\t\tif ( currentComponentId && tempIdToComponentId.has( currentComponentId ) ) {\n\t\t\treturn { shouldUpdate: true, newComponentId: tempIdToComponentId.get( currentComponentId ) as number };\n\t\t}\n\t}\n\treturn { shouldUpdate: false, newComponentId: null };\n}\n\nfunction updateElementComponentId( elementId: string, componentId: number ): void {\n\tupdateElementSettings( {\n\t\tid: elementId,\n\t\tprops: {\n\t\t\tcomponent: {\n\t\t\t\t$$type: 'component-id',\n\t\t\t\tvalue: componentId,\n\t\t\t},\n\t\t},\n\t\twithHistory: false,\n\t} );\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,qBAAqB,oCAAoC;AAClE,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB,UAAU,mBAAmB,wBAAwB;AACnF,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,MAAAA,WAAU;;;ACPnB,SAAS,yBAAyB;AAClC,SAAS,cAAc,gBAAgB;;;ACAvC;AAAA,EACC,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,OAGX;;;ACNP,SAAS,sBAAsB,wBAAwB;;;ACCvD,SAAS,YAAY;AACrB,SAA4B,mBAAmB;AAI/C,IAAM,WAAW;AAeV,IAAM,YAAY,CAAE,QAAkB;AAAA,EAC5C,QAAQ;AAAA,EACR,WAAW,mBAAoB,EAAG;AAAA,EAClC,MAAM,EAAE,GAAG;AACZ;AAEO,IAAM,YAAY;AAAA,EACxB,KAAK,MACJ,YAAY,EACV,IAA6C,GAAI,QAAS,EAAG,EAC7D,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,QAAQ,CAAE,YACT,YAAY,EACV,KAAiD,GAAI,QAAS,IAAI,OAAQ,EAC1E,KAAM,CAAE,QAAS,IAAI,KAAK,IAAK;AAAA,EAClC,oBAAoB,CAAE,OAAgB,KAAK,KAAuC,UAAW,EAAG,CAAE;AAAA,EAClG,gCA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YAA2B,CAAC,CAAE;AAAA,EAC/D,CAAE;AAEF,+BAA6B,SAAU,gBAAgB,sBAAuB;AAC/E;","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","__","__","useState","dispatch","__","ThemeProvider","validateForm","useMemo","Stack","Typography","TextField","__","useEffect","useEffect","getState","getState","dispatch","getState","getState","dispatch","dispatch","dispatch","dispatch","getState","getState","dispatch","__"]}
|
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-210",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor": "3.33.0-
|
|
44
|
-
"@elementor/editor-canvas": "3.33.0-
|
|
45
|
-
"@elementor/editor-documents": "3.33.0-
|
|
46
|
-
"@elementor/editor-elements": "3.33.0-
|
|
47
|
-
"@elementor/editor-elements-panel": "3.33.0-
|
|
48
|
-
"@elementor/editor-props": "3.33.0-
|
|
49
|
-
"@elementor/editor-styles-repository": "3.33.0-
|
|
50
|
-
"@elementor/editor-ui": "3.33.0-
|
|
51
|
-
"@elementor/editor-v1-adapters": "3.33.0-
|
|
52
|
-
"@elementor/http-client": "3.33.0-
|
|
43
|
+
"@elementor/editor": "3.33.0-210",
|
|
44
|
+
"@elementor/editor-canvas": "3.33.0-210",
|
|
45
|
+
"@elementor/editor-documents": "3.33.0-210",
|
|
46
|
+
"@elementor/editor-elements": "3.33.0-210",
|
|
47
|
+
"@elementor/editor-elements-panel": "3.33.0-210",
|
|
48
|
+
"@elementor/editor-props": "3.33.0-210",
|
|
49
|
+
"@elementor/editor-styles-repository": "3.33.0-210",
|
|
50
|
+
"@elementor/editor-ui": "3.33.0-210",
|
|
51
|
+
"@elementor/editor-v1-adapters": "3.33.0-210",
|
|
52
|
+
"@elementor/http-client": "3.33.0-210",
|
|
53
53
|
"@elementor/icons": "1.53.0",
|
|
54
|
-
"@elementor/query": "3.33.0-
|
|
55
|
-
"@elementor/schema": "3.33.0-
|
|
56
|
-
"@elementor/store": "3.33.0-
|
|
54
|
+
"@elementor/query": "3.33.0-210",
|
|
55
|
+
"@elementor/schema": "3.33.0-210",
|
|
56
|
+
"@elementor/store": "3.33.0-210",
|
|
57
57
|
"@elementor/ui": "1.36.15",
|
|
58
|
-
"@elementor/utils": "3.33.0-
|
|
58
|
+
"@elementor/utils": "3.33.0-210",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
package/src/api.ts
CHANGED
|
@@ -7,16 +7,17 @@ import { type Component, type DocumentStatus } from './types';
|
|
|
7
7
|
const BASE_URL = 'elementor/v1/components';
|
|
8
8
|
|
|
9
9
|
export type CreateComponentPayload = {
|
|
10
|
-
name: string;
|
|
11
|
-
content: V1ElementData[];
|
|
12
10
|
status: DocumentStatus;
|
|
11
|
+
items: Array< {
|
|
12
|
+
temp_id: number;
|
|
13
|
+
title: string;
|
|
14
|
+
elements: V1ElementData[];
|
|
15
|
+
} >;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
type GetComponentResponse = Array< Component >;
|
|
16
19
|
|
|
17
|
-
export type CreateComponentResponse =
|
|
18
|
-
component_id: number;
|
|
19
|
-
};
|
|
20
|
+
export type CreateComponentResponse = Record< number, number >;
|
|
20
21
|
|
|
21
22
|
export const getParams = ( id: number ) => ( {
|
|
22
23
|
action: 'get_document_config',
|
|
@@ -16,7 +16,7 @@ export const componentIdTransformer = createTransformer( async ( id: number ) =>
|
|
|
16
16
|
|
|
17
17
|
const unpublishedComponent = unpublishedComponents.find( ( component ) => component.id === id );
|
|
18
18
|
if ( unpublishedComponent ) {
|
|
19
|
-
return structuredClone( unpublishedComponent.
|
|
19
|
+
return structuredClone( unpublishedComponent.elements );
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const extendedWindow = window as unknown as ComponentIdTransformerWindow;
|
|
@@ -64,7 +64,7 @@ export function CreateComponentForm() {
|
|
|
64
64
|
slice.actions.addUnpublished( {
|
|
65
65
|
id: tempId,
|
|
66
66
|
name: values.componentName,
|
|
67
|
-
|
|
67
|
+
elements: [ element.element.model.toJSON( { remove: [ 'default' ] } ) ],
|
|
68
68
|
} )
|
|
69
69
|
);
|
|
70
70
|
|
package/src/store/store.ts
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
} from '@elementor/store';
|
|
8
8
|
|
|
9
9
|
import { type Component, type ComponentId, type StylesDefinition } from '../types';
|
|
10
|
-
import {
|
|
10
|
+
import { loadComponents } from './thunks';
|
|
11
11
|
|
|
12
12
|
type GetComponentResponse = Component[];
|
|
13
13
|
|
|
14
14
|
export type UnpublishedComponent = Component & {
|
|
15
|
-
|
|
15
|
+
elements: V1ElementData[];
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
type Status = 'idle' | 'pending' | 'error';
|
|
@@ -21,7 +21,6 @@ type ComponentsState = {
|
|
|
21
21
|
data: Component[];
|
|
22
22
|
unpublishedData: UnpublishedComponent[];
|
|
23
23
|
loadStatus: Status;
|
|
24
|
-
createStatus: Status;
|
|
25
24
|
styles: StylesDefinition;
|
|
26
25
|
};
|
|
27
26
|
|
|
@@ -31,7 +30,6 @@ export const initialState: ComponentsState = {
|
|
|
31
30
|
data: [],
|
|
32
31
|
unpublishedData: [],
|
|
33
32
|
loadStatus: 'idle',
|
|
34
|
-
createStatus: 'idle',
|
|
35
33
|
styles: {},
|
|
36
34
|
};
|
|
37
35
|
|
|
@@ -76,25 +74,11 @@ export const slice = createSlice( {
|
|
|
76
74
|
builder.addCase( loadComponents.rejected, ( state ) => {
|
|
77
75
|
state.loadStatus = 'error';
|
|
78
76
|
} );
|
|
79
|
-
builder.addCase( createComponent.fulfilled, ( state, { payload, meta } ) => {
|
|
80
|
-
state.createStatus = 'idle';
|
|
81
|
-
state.data.push( {
|
|
82
|
-
id: payload.component_id,
|
|
83
|
-
name: meta.arg.name,
|
|
84
|
-
} );
|
|
85
|
-
} );
|
|
86
|
-
builder.addCase( createComponent.pending, ( state ) => {
|
|
87
|
-
state.createStatus = 'pending';
|
|
88
|
-
} );
|
|
89
|
-
builder.addCase( createComponent.rejected, ( state ) => {
|
|
90
|
-
state.createStatus = 'error';
|
|
91
|
-
} );
|
|
92
77
|
},
|
|
93
78
|
} );
|
|
94
79
|
|
|
95
80
|
const selectData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].data;
|
|
96
81
|
const selectLoadStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].loadStatus;
|
|
97
|
-
const selectCreateStatus = ( state: ComponentsSlice ) => state[ SLICE_NAME ].createStatus;
|
|
98
82
|
const selectStylesDefinitions = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};
|
|
99
83
|
const selectUnpublishedData = ( state: ComponentsSlice ) => state[ SLICE_NAME ].unpublishedData;
|
|
100
84
|
|
|
@@ -112,7 +96,5 @@ export const selectUnpublishedComponents = createSelector(
|
|
|
112
96
|
);
|
|
113
97
|
export const selectLoadIsPending = createSelector( selectLoadStatus, ( status ) => status === 'pending' );
|
|
114
98
|
export const selectLoadIsError = createSelector( selectLoadStatus, ( status ) => status === 'error' );
|
|
115
|
-
export const selectCreateIsPending = createSelector( selectCreateStatus, ( status ) => status === 'pending' );
|
|
116
|
-
export const selectCreateIsError = createSelector( selectCreateStatus, ( status ) => status === 'error' );
|
|
117
99
|
export const selectStyles = ( state: ComponentsSlice ) => state[ SLICE_NAME ].styles ?? {};
|
|
118
100
|
export const selectFlatStyles = createSelector( selectStylesDefinitions, ( data ) => Object.values( data ).flat() );
|
package/src/store/thunks.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { __createAsyncThunk as createAsyncThunk } from '@elementor/store';
|
|
2
2
|
|
|
3
|
-
import { apiClient
|
|
4
|
-
|
|
5
|
-
const createComponent = createAsyncThunk< CreateComponentResponse, CreateComponentPayload >(
|
|
6
|
-
'components/create',
|
|
7
|
-
async ( payload: CreateComponentPayload ) => {
|
|
8
|
-
const response = await apiClient.create( payload );
|
|
9
|
-
return { ...response, name: payload.name };
|
|
10
|
-
}
|
|
11
|
-
);
|
|
3
|
+
import { apiClient } from '../api';
|
|
12
4
|
|
|
13
5
|
const loadComponents = createAsyncThunk( 'components/load', async () => {
|
|
14
6
|
const response = await apiClient.get();
|
|
15
7
|
return response;
|
|
16
8
|
} );
|
|
17
9
|
|
|
18
|
-
export {
|
|
10
|
+
export { loadComponents };
|
package/src/utils/before-save.ts
CHANGED
|
@@ -45,17 +45,22 @@ async function createComponents(
|
|
|
45
45
|
components: UnpublishedComponent[],
|
|
46
46
|
status: DocumentStatus
|
|
47
47
|
): Promise< Map< number, number > > {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const response = await apiClient.create( {
|
|
49
|
+
status,
|
|
50
|
+
items: components.map( ( component ) => ( {
|
|
51
|
+
temp_id: component.id,
|
|
52
|
+
title: component.name,
|
|
53
|
+
elements: component.elements,
|
|
54
|
+
} ) ),
|
|
54
55
|
} );
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
const map = new Map< number, number >();
|
|
58
|
+
|
|
59
|
+
Object.entries( response ).forEach( ( [ key, value ] ) => {
|
|
60
|
+
map.set( Number( key ), value );
|
|
61
|
+
} );
|
|
57
62
|
|
|
58
|
-
return
|
|
63
|
+
return map;
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
function updateComponentInstances( elements: V1ElementData[], tempIdToComponentId: Map< number, number > ): void {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { __useDispatch as useDispatch, __useSelector as useSelector, type AnyAction } from '@elementor/store';
|
|
2
|
-
|
|
3
|
-
import { type CreateComponentPayload } from '../api';
|
|
4
|
-
import { selectCreateIsError, selectCreateIsPending } from '../store/store';
|
|
5
|
-
import { createComponent } from '../store/thunks';
|
|
6
|
-
|
|
7
|
-
export const useCreateComponent = () => {
|
|
8
|
-
const dispatch = useDispatch();
|
|
9
|
-
const isPending = useSelector( selectCreateIsPending );
|
|
10
|
-
const isError = useSelector( selectCreateIsError );
|
|
11
|
-
|
|
12
|
-
const createComponentAction = async ( payload: CreateComponentPayload ) => {
|
|
13
|
-
const result = await dispatch( createComponent( payload ) as unknown as AnyAction );
|
|
14
|
-
return result.payload;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
createComponent: createComponentAction,
|
|
19
|
-
isPending,
|
|
20
|
-
isError,
|
|
21
|
-
};
|
|
22
|
-
};
|