@elementor/editor-controls 4.4.0-1141 → 4.4.0-1143
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 +56 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
- package/src/controls/icon-library/icon-library-providers.ts +12 -0
- package/src/controls/svg-media-overlay.tsx +2 -1
- package/src/controls/svg-media-preview.tsx +24 -2
package/dist/index.mjs
CHANGED
|
@@ -6611,6 +6611,8 @@ var IconLibraryGrid = ({
|
|
|
6611
6611
|
|
|
6612
6612
|
// src/controls/icon-library/icon-library-providers.ts
|
|
6613
6613
|
import { useState as useState20 } from "react";
|
|
6614
|
+
import { useQuery as useQuery2 } from "@elementor/query";
|
|
6615
|
+
var PROVIDER_ICON_SVG_QUERY_KEY = "icon-library-provider-svg";
|
|
6614
6616
|
var providers = /* @__PURE__ */ new Map();
|
|
6615
6617
|
function registerIconLibraryProvider(provider) {
|
|
6616
6618
|
providers.set(provider.id, provider);
|
|
@@ -6641,6 +6643,14 @@ async function resolveProviderIconSvg(library, iconValue, signal) {
|
|
|
6641
6643
|
}
|
|
6642
6644
|
return null;
|
|
6643
6645
|
}
|
|
6646
|
+
function useProviderIconSvg(library, iconValue, enabled) {
|
|
6647
|
+
return useQuery2({
|
|
6648
|
+
queryKey: [PROVIDER_ICON_SVG_QUERY_KEY, library, iconValue],
|
|
6649
|
+
queryFn: ({ signal }) => resolveProviderIconSvg(library, iconValue, signal),
|
|
6650
|
+
enabled: enabled && Boolean(library && iconValue),
|
|
6651
|
+
staleTime: Infinity
|
|
6652
|
+
});
|
|
6653
|
+
}
|
|
6644
6654
|
|
|
6645
6655
|
// src/controls/icon-library/icon-library-upload-action.tsx
|
|
6646
6656
|
import * as React87 from "react";
|
|
@@ -6799,10 +6809,10 @@ var SvgElementIcon = React89.forwardRef(
|
|
|
6799
6809
|
);
|
|
6800
6810
|
|
|
6801
6811
|
// src/controls/icon-library/use-font-awesome-7-catalog.ts
|
|
6802
|
-
import { useQuery as
|
|
6812
|
+
import { useQuery as useQuery3 } from "@elementor/query";
|
|
6803
6813
|
var FONT_AWESOME_7_CATALOG_QUERY_KEY = ["font-awesome-7-catalog"];
|
|
6804
6814
|
function useFontAwesome7Catalog(enabled) {
|
|
6805
|
-
return
|
|
6815
|
+
return useQuery3({
|
|
6806
6816
|
queryKey: FONT_AWESOME_7_CATALOG_QUERY_KEY,
|
|
6807
6817
|
queryFn: ({ signal }) => loadFontAwesome7Catalog(signal),
|
|
6808
6818
|
enabled,
|
|
@@ -7035,8 +7045,9 @@ function createIconPropValue(icon, library) {
|
|
|
7035
7045
|
|
|
7036
7046
|
// src/controls/svg-media-overlay.tsx
|
|
7037
7047
|
import * as React91 from "react";
|
|
7048
|
+
import { ThemeProvider } from "@elementor/editor-ui";
|
|
7038
7049
|
import { LibraryIcon as LibraryIcon3 } from "@elementor/icons";
|
|
7039
|
-
import { Box as Box22, Button as Button6, Stack as Stack17,
|
|
7050
|
+
import { Box as Box22, Button as Button6, Stack as Stack17, Typography as Typography11 } from "@elementor/ui";
|
|
7040
7051
|
import { __ as __39 } from "@wordpress/i18n";
|
|
7041
7052
|
var SVG_MEDIA_CONTROL_CONTAINER_TEST_ID = "svg-media-control-container";
|
|
7042
7053
|
var SVG_MEDIA_ACTION_GROUP_TEST_ID = "svg-media-action-group";
|
|
@@ -7105,17 +7116,37 @@ var SvgMediaPreview = ({ isFetching, src, iconClassName, iconLibrary }) => {
|
|
|
7105
7116
|
const icons = [...fontAwesomeIcons, ...providerIcons];
|
|
7106
7117
|
const selectedIcon = findFontAwesome7Icon(icons, iconClassName, iconLibrary);
|
|
7107
7118
|
const isLoadingCatalog = shouldLoadIconCatalog && (isFontAwesomeLoading || isProviderLoading);
|
|
7108
|
-
|
|
7119
|
+
const { data: savedIconSvg, isLoading: isSavedIconLoading } = useProviderIconSvg(
|
|
7120
|
+
iconLibrary,
|
|
7121
|
+
iconClassName,
|
|
7122
|
+
shouldLoadIconCatalog && !isLoadingCatalog && !selectedIcon
|
|
7123
|
+
);
|
|
7124
|
+
if (isFetching || isLoadingCatalog || isSavedIconLoading) {
|
|
7109
7125
|
return /* @__PURE__ */ React92.createElement(CircularProgress4, { role: "progressbar" });
|
|
7110
7126
|
}
|
|
7111
7127
|
if (selectedIcon) {
|
|
7112
7128
|
return /* @__PURE__ */ React92.createElement(IconPreview, { icon: selectedIcon });
|
|
7113
7129
|
}
|
|
7130
|
+
if (savedIconSvg) {
|
|
7131
|
+
return /* @__PURE__ */ React92.createElement(IconPreview, { icon: toSvgMarkupIcon(savedIconSvg, iconLibrary, iconClassName) });
|
|
7132
|
+
}
|
|
7114
7133
|
if (shouldLoadIconCatalog) {
|
|
7115
7134
|
return /* @__PURE__ */ React92.createElement(IconPreviewPlaceholder, null);
|
|
7116
7135
|
}
|
|
7117
7136
|
return /* @__PURE__ */ React92.createElement(SvgPreview, { src });
|
|
7118
7137
|
};
|
|
7138
|
+
var toSvgMarkupIcon = (svgMarkup, library, value) => ({
|
|
7139
|
+
id: `${library}:${value}`,
|
|
7140
|
+
label: value ?? "",
|
|
7141
|
+
library: library ?? "",
|
|
7142
|
+
value: value ?? "",
|
|
7143
|
+
name: value ?? "",
|
|
7144
|
+
aliases: [],
|
|
7145
|
+
width: 0,
|
|
7146
|
+
height: 0,
|
|
7147
|
+
paths: [],
|
|
7148
|
+
svgMarkup
|
|
7149
|
+
});
|
|
7119
7150
|
var IconPreview = ({ icon }) => /* @__PURE__ */ React92.createElement(Box23, { sx: { color: ICON_PREVIEW_COLOR } }, /* @__PURE__ */ React92.createElement(
|
|
7120
7151
|
FontAwesomeGlyph,
|
|
7121
7152
|
{
|