@elementor/editor-controls 4.4.0-1142 → 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 CHANGED
@@ -6647,6 +6647,8 @@ var IconLibraryGrid = ({
6647
6647
 
6648
6648
  // src/controls/icon-library/icon-library-providers.ts
6649
6649
  var import_react54 = require("react");
6650
+ var import_query2 = require("@elementor/query");
6651
+ var PROVIDER_ICON_SVG_QUERY_KEY = "icon-library-provider-svg";
6650
6652
  var providers = /* @__PURE__ */ new Map();
6651
6653
  function registerIconLibraryProvider(provider) {
6652
6654
  providers.set(provider.id, provider);
@@ -6677,6 +6679,14 @@ async function resolveProviderIconSvg(library, iconValue, signal) {
6677
6679
  }
6678
6680
  return null;
6679
6681
  }
6682
+ function useProviderIconSvg(library, iconValue, enabled) {
6683
+ return (0, import_query2.useQuery)({
6684
+ queryKey: [PROVIDER_ICON_SVG_QUERY_KEY, library, iconValue],
6685
+ queryFn: ({ signal }) => resolveProviderIconSvg(library, iconValue, signal),
6686
+ enabled: enabled && Boolean(library && iconValue),
6687
+ staleTime: Infinity
6688
+ });
6689
+ }
6680
6690
 
6681
6691
  // src/controls/icon-library/icon-library-upload-action.tsx
6682
6692
  var React87 = __toESM(require("react"));
@@ -6835,10 +6845,10 @@ var SvgElementIcon = React89.forwardRef(
6835
6845
  );
6836
6846
 
6837
6847
  // src/controls/icon-library/use-font-awesome-7-catalog.ts
6838
- var import_query2 = require("@elementor/query");
6848
+ var import_query3 = require("@elementor/query");
6839
6849
  var FONT_AWESOME_7_CATALOG_QUERY_KEY = ["font-awesome-7-catalog"];
6840
6850
  function useFontAwesome7Catalog(enabled) {
6841
- return (0, import_query2.useQuery)({
6851
+ return (0, import_query3.useQuery)({
6842
6852
  queryKey: FONT_AWESOME_7_CATALOG_QUERY_KEY,
6843
6853
  queryFn: ({ signal }) => loadFontAwesome7Catalog(signal),
6844
6854
  enabled,
@@ -7142,17 +7152,37 @@ var SvgMediaPreview = ({ isFetching, src, iconClassName, iconLibrary }) => {
7142
7152
  const icons = [...fontAwesomeIcons, ...providerIcons];
7143
7153
  const selectedIcon = findFontAwesome7Icon(icons, iconClassName, iconLibrary);
7144
7154
  const isLoadingCatalog = shouldLoadIconCatalog && (isFontAwesomeLoading || isProviderLoading);
7145
- if (isFetching || isLoadingCatalog) {
7155
+ const { data: savedIconSvg, isLoading: isSavedIconLoading } = useProviderIconSvg(
7156
+ iconLibrary,
7157
+ iconClassName,
7158
+ shouldLoadIconCatalog && !isLoadingCatalog && !selectedIcon
7159
+ );
7160
+ if (isFetching || isLoadingCatalog || isSavedIconLoading) {
7146
7161
  return /* @__PURE__ */ React92.createElement(import_ui75.CircularProgress, { role: "progressbar" });
7147
7162
  }
7148
7163
  if (selectedIcon) {
7149
7164
  return /* @__PURE__ */ React92.createElement(IconPreview, { icon: selectedIcon });
7150
7165
  }
7166
+ if (savedIconSvg) {
7167
+ return /* @__PURE__ */ React92.createElement(IconPreview, { icon: toSvgMarkupIcon(savedIconSvg, iconLibrary, iconClassName) });
7168
+ }
7151
7169
  if (shouldLoadIconCatalog) {
7152
7170
  return /* @__PURE__ */ React92.createElement(IconPreviewPlaceholder, null);
7153
7171
  }
7154
7172
  return /* @__PURE__ */ React92.createElement(SvgPreview, { src });
7155
7173
  };
7174
+ var toSvgMarkupIcon = (svgMarkup, library, value) => ({
7175
+ id: `${library}:${value}`,
7176
+ label: value ?? "",
7177
+ library: library ?? "",
7178
+ value: value ?? "",
7179
+ name: value ?? "",
7180
+ aliases: [],
7181
+ width: 0,
7182
+ height: 0,
7183
+ paths: [],
7184
+ svgMarkup
7185
+ });
7156
7186
  var IconPreview = ({ icon }) => /* @__PURE__ */ React92.createElement(import_ui75.Box, { sx: { color: ICON_PREVIEW_COLOR } }, /* @__PURE__ */ React92.createElement(
7157
7187
  FontAwesomeGlyph,
7158
7188
  {