@elementor/editor-controls 4.4.0-1142 → 4.4.0-1144

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.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 useQuery2 } from "@elementor/query";
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 useQuery2({
6815
+ return useQuery3({
6806
6816
  queryKey: FONT_AWESOME_7_CATALOG_QUERY_KEY,
6807
6817
  queryFn: ({ signal }) => loadFontAwesome7Catalog(signal),
6808
6818
  enabled,
@@ -7106,17 +7116,37 @@ var SvgMediaPreview = ({ isFetching, src, iconClassName, iconLibrary }) => {
7106
7116
  const icons = [...fontAwesomeIcons, ...providerIcons];
7107
7117
  const selectedIcon = findFontAwesome7Icon(icons, iconClassName, iconLibrary);
7108
7118
  const isLoadingCatalog = shouldLoadIconCatalog && (isFontAwesomeLoading || isProviderLoading);
7109
- if (isFetching || isLoadingCatalog) {
7119
+ const { data: savedIconSvg, isLoading: isSavedIconLoading } = useProviderIconSvg(
7120
+ iconLibrary,
7121
+ iconClassName,
7122
+ shouldLoadIconCatalog && !isLoadingCatalog && !selectedIcon
7123
+ );
7124
+ if (isFetching || isLoadingCatalog || isSavedIconLoading) {
7110
7125
  return /* @__PURE__ */ React92.createElement(CircularProgress4, { role: "progressbar" });
7111
7126
  }
7112
7127
  if (selectedIcon) {
7113
7128
  return /* @__PURE__ */ React92.createElement(IconPreview, { icon: selectedIcon });
7114
7129
  }
7130
+ if (savedIconSvg) {
7131
+ return /* @__PURE__ */ React92.createElement(IconPreview, { icon: toSvgMarkupIcon(savedIconSvg, iconLibrary, iconClassName) });
7132
+ }
7115
7133
  if (shouldLoadIconCatalog) {
7116
7134
  return /* @__PURE__ */ React92.createElement(IconPreviewPlaceholder, null);
7117
7135
  }
7118
7136
  return /* @__PURE__ */ React92.createElement(SvgPreview, { src });
7119
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
+ });
7120
7150
  var IconPreview = ({ icon }) => /* @__PURE__ */ React92.createElement(Box23, { sx: { color: ICON_PREVIEW_COLOR } }, /* @__PURE__ */ React92.createElement(
7121
7151
  FontAwesomeGlyph,
7122
7152
  {
@@ -7953,7 +7983,11 @@ var getGradientValue = (value) => {
7953
7983
  ({ value: { color, offset } }) => offset ? `${color.value} ${offset.value ?? 0}%` : `${color.value}`
7954
7984
  )?.join(",");
7955
7985
  if (gradient.type.value === "linear") {
7956
- return `linear-gradient(${gradient.angle.value}deg, ${stops})`;
7986
+ const angle = gradient.angle?.value;
7987
+ if (typeof angle !== "number") {
7988
+ return `linear-gradient(${stops})`;
7989
+ }
7990
+ return `linear-gradient(${angle}deg, ${stops})`;
7957
7991
  }
7958
7992
  return `radial-gradient(circle at ${gradient.positions.value}, ${stops})`;
7959
7993
  };