@elementor/editor-controls 3.33.0-150 → 3.33.0-151

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
@@ -3426,7 +3426,7 @@ var ConditionalControlInfotip = React63.forwardRef(
3426
3426
  sx: { width: 300, px: 1.5, py: 2 },
3427
3427
  ...alertProps
3428
3428
  },
3429
- /* @__PURE__ */ React63.createElement(import_ui48.Box, { sx: { flexDirection: "column", display: "flex" } }, /* @__PURE__ */ React63.createElement(import_ui48.AlertTitle, null, title), /* @__PURE__ */ React63.createElement(import_ui48.Box, null, description))
3429
+ /* @__PURE__ */ React63.createElement(import_ui48.Box, { sx: { flexDirection: "column", display: "flex", gap: 0.5 } }, /* @__PURE__ */ React63.createElement(import_ui48.AlertTitle, null, title), /* @__PURE__ */ React63.createElement(import_ui48.Box, null, description))
3430
3430
  )
3431
3431
  },
3432
3432
  children
@@ -3653,6 +3653,7 @@ var AspectRatioControl = createControl(({ label }) => {
3653
3653
  // src/controls/svg-media-control.tsx
3654
3654
  var React68 = __toESM(require("react"));
3655
3655
  var import_react34 = require("react");
3656
+ var import_editor_current_user = require("@elementor/editor-current-user");
3656
3657
  var import_editor_props28 = require("@elementor/editor-props");
3657
3658
  var import_icons17 = require("@elementor/icons");
3658
3659
  var import_ui54 = require("@elementor/ui");
@@ -3662,7 +3663,6 @@ var import_i18n27 = require("@wordpress/i18n");
3662
3663
  // src/components/enable-unfiltered-modal.tsx
3663
3664
  var React67 = __toESM(require("react"));
3664
3665
  var import_react33 = require("react");
3665
- var import_editor_current_user = require("@elementor/editor-current-user");
3666
3666
  var import_ui53 = require("@elementor/ui");
3667
3667
  var import_i18n26 = require("@wordpress/i18n");
3668
3668
  var ADMIN_TITLE_TEXT = (0, import_i18n26.__)("Enable Unfiltered Uploads", "elementor");
@@ -3670,11 +3670,6 @@ var ADMIN_CONTENT_TEXT = (0, import_i18n26.__)(
3670
3670
  "Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.",
3671
3671
  "elementor"
3672
3672
  );
3673
- var NON_ADMIN_TITLE_TEXT = (0, import_i18n26.__)("Sorry, you can't upload that file yet", "elementor");
3674
- var NON_ADMIN_CONTENT_TEXT = (0, import_i18n26.__)(
3675
- "This is because this file type may pose a security risk. To upload them anyway, ask the site administrator to enable unfiltered file uploads.",
3676
- "elementor"
3677
- );
3678
3673
  var ADMIN_FAILED_CONTENT_TEXT_PT1 = (0, import_i18n26.__)("Failed to enable unfiltered files upload.", "elementor");
3679
3674
  var ADMIN_FAILED_CONTENT_TEXT_PT2 = (0, import_i18n26.__)(
3680
3675
  "You can try again, if the problem persists, please contact support.",
@@ -3683,9 +3678,7 @@ var ADMIN_FAILED_CONTENT_TEXT_PT2 = (0, import_i18n26.__)(
3683
3678
  var WAIT_FOR_CLOSE_TIMEOUT_MS = 300;
3684
3679
  var EnableUnfilteredModal = (props) => {
3685
3680
  const { mutateAsync, isPending } = useUpdateUnfilteredFilesUpload();
3686
- const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
3687
3681
  const [isError, setIsError] = (0, import_react33.useState)(false);
3688
- const canManageOptions = canUser("manage_options");
3689
3682
  const onClose = (enabled) => {
3690
3683
  props.onClose(enabled);
3691
3684
  setTimeout(() => setIsError(false), WAIT_FOR_CLOSE_TIMEOUT_MS);
@@ -3703,7 +3696,7 @@ var EnableUnfilteredModal = (props) => {
3703
3696
  }
3704
3697
  };
3705
3698
  const dialogProps = { ...props, isPending, handleEnable, isError, onClose };
3706
- return canManageOptions ? /* @__PURE__ */ React67.createElement(AdminDialog, { ...dialogProps }) : /* @__PURE__ */ React67.createElement(NonAdminDialog, { ...dialogProps });
3699
+ return /* @__PURE__ */ React67.createElement(AdminDialog, { ...dialogProps });
3707
3700
  };
3708
3701
  var AdminDialog = ({ open, onClose, handleEnable, isPending, isError }) => /* @__PURE__ */ React67.createElement(import_ui53.Dialog, { open, maxWidth: "sm", onClose: () => onClose(false) }, /* @__PURE__ */ React67.createElement(import_ui53.DialogHeader, { logo: false }, /* @__PURE__ */ React67.createElement(import_ui53.DialogTitle, null, ADMIN_TITLE_TEXT)), /* @__PURE__ */ React67.createElement(import_ui53.Divider, null), /* @__PURE__ */ React67.createElement(import_ui53.DialogContent, null, /* @__PURE__ */ React67.createElement(import_ui53.DialogContentText, null, isError ? /* @__PURE__ */ React67.createElement(React67.Fragment, null, ADMIN_FAILED_CONTENT_TEXT_PT1, " ", /* @__PURE__ */ React67.createElement("br", null), " ", ADMIN_FAILED_CONTENT_TEXT_PT2) : ADMIN_CONTENT_TEXT)), /* @__PURE__ */ React67.createElement(import_ui53.DialogActions, null, /* @__PURE__ */ React67.createElement(import_ui53.Button, { size: "medium", color: "secondary", onClick: () => onClose(false) }, (0, import_i18n26.__)("Cancel", "elementor")), /* @__PURE__ */ React67.createElement(
3709
3702
  import_ui53.Button,
@@ -3716,7 +3709,6 @@ var AdminDialog = ({ open, onClose, handleEnable, isPending, isError }) => /* @_
3716
3709
  },
3717
3710
  isPending ? /* @__PURE__ */ React67.createElement(import_ui53.CircularProgress, { size: 24 }) : (0, import_i18n26.__)("Enable", "elementor")
3718
3711
  )));
3719
- var NonAdminDialog = ({ open, onClose }) => /* @__PURE__ */ React67.createElement(import_ui53.Dialog, { open, maxWidth: "sm", onClose: () => onClose(false) }, /* @__PURE__ */ React67.createElement(import_ui53.DialogHeader, { logo: false }, /* @__PURE__ */ React67.createElement(import_ui53.DialogTitle, null, NON_ADMIN_TITLE_TEXT)), /* @__PURE__ */ React67.createElement(import_ui53.Divider, null), /* @__PURE__ */ React67.createElement(import_ui53.DialogContent, null, /* @__PURE__ */ React67.createElement(import_ui53.DialogContentText, null, NON_ADMIN_CONTENT_TEXT)), /* @__PURE__ */ React67.createElement(import_ui53.DialogActions, null, /* @__PURE__ */ React67.createElement(import_ui53.Button, { size: "medium", onClick: () => onClose(false), variant: "contained", color: "primary" }, (0, import_i18n26.__)("Got it", "elementor"))));
3720
3712
 
3721
3713
  // src/controls/svg-media-control.tsx
3722
3714
  var TILE_SIZE = 8;
@@ -3750,6 +3742,8 @@ var SvgMediaControl = createControl(() => {
3750
3742
  const src = attachment?.url ?? url?.value ?? null;
3751
3743
  const { data: allowSvgUpload } = useUnfilteredFilesUpload();
3752
3744
  const [unfilteredModalOpenState, setUnfilteredModalOpenState] = (0, import_react34.useState)(false);
3745
+ const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
3746
+ const canManageOptions = canUser("manage_options");
3753
3747
  const { open } = (0, import_wp_media2.useWpMediaFrame)({
3754
3748
  mediaTypes: ["svg"],
3755
3749
  multiple: false,
@@ -3777,6 +3771,11 @@ var SvgMediaControl = createControl(() => {
3777
3771
  open(openOptions);
3778
3772
  }
3779
3773
  };
3774
+ const infotipProps = {
3775
+ title: (0, import_i18n27.__)("Sorry, you can't upload that file yet.", "elementor"),
3776
+ description: /* @__PURE__ */ React68.createElement(React68.Fragment, null, (0, import_i18n27.__)("To upload them anyway, ask the site administrator to enable unfiltered", "elementor"), /* @__PURE__ */ React68.createElement("br", null), (0, import_i18n27.__)("file uploads.", "elementor")),
3777
+ isEnabled: !canManageOptions
3778
+ };
3780
3779
  return /* @__PURE__ */ React68.createElement(import_ui54.Stack, { gap: 1 }, /* @__PURE__ */ React68.createElement(EnableUnfilteredModal, { open: unfilteredModalOpenState, onClose: onCloseUnfilteredModal }), /* @__PURE__ */ React68.createElement(ControlActions, null, /* @__PURE__ */ React68.createElement(StyledCard, { variant: "outlined" }, /* @__PURE__ */ React68.createElement(StyledCardMediaContainer, null, isFetching ? /* @__PURE__ */ React68.createElement(import_ui54.CircularProgress, { role: "progressbar" }) : /* @__PURE__ */ React68.createElement(
3781
3780
  import_ui54.CardMedia,
3782
3781
  {
@@ -3803,17 +3802,18 @@ var SvgMediaControl = createControl(() => {
3803
3802
  onClick: () => handleClick(MODE_BROWSE)
3804
3803
  },
3805
3804
  (0, import_i18n27.__)("Select SVG", "elementor")
3806
- ), /* @__PURE__ */ React68.createElement(
3805
+ ), /* @__PURE__ */ React68.createElement(ConditionalControlInfotip, { ...infotipProps }, /* @__PURE__ */ React68.createElement("span", null, /* @__PURE__ */ React68.createElement(import_ui54.ThemeProvider, { colorScheme: canManageOptions ? "light" : "dark" }, /* @__PURE__ */ React68.createElement(
3807
3806
  import_ui54.Button,
3808
3807
  {
3809
3808
  size: "tiny",
3810
3809
  variant: "text",
3811
3810
  color: "inherit",
3812
3811
  startIcon: /* @__PURE__ */ React68.createElement(import_icons17.UploadIcon, null),
3813
- onClick: () => handleClick(MODE_UPLOAD)
3812
+ disabled: canManageOptions ? false : true,
3813
+ onClick: () => canManageOptions && handleClick(MODE_UPLOAD)
3814
3814
  },
3815
3815
  (0, import_i18n27.__)("Upload", "elementor")
3816
- ))
3816
+ )))))
3817
3817
  ))));
3818
3818
  });
3819
3819