analytica-frontend-lib 1.4.59 → 1.4.60

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
@@ -5694,6 +5694,7 @@ function ImageUpload({
5694
5694
  var import_react10 = require("react");
5695
5695
  var import_phosphor_react5 = require("phosphor-react");
5696
5696
  init_Text();
5697
+ init_Button();
5697
5698
  init_utils();
5698
5699
  var import_jsx_runtime19 = require("react/jsx-runtime");
5699
5700
  var FILE_TYPE_CONFIG = {
@@ -5731,6 +5732,7 @@ function FileDropzone({
5731
5732
  actionText = "Clique aqui",
5732
5733
  placeholder,
5733
5734
  changeText,
5735
+ changeButtonText = "Trocar",
5734
5736
  disabled = false,
5735
5737
  required = false,
5736
5738
  className,
@@ -5839,6 +5841,14 @@ function FileDropzone({
5839
5841
  onRemoveFile?.();
5840
5842
  }
5841
5843
  };
5844
+ const handleChangeClick = (e) => {
5845
+ e.preventDefault();
5846
+ e.stopPropagation();
5847
+ if (!disabled) {
5848
+ fileInputRef.current?.click();
5849
+ }
5850
+ };
5851
+ const fileName = selectedFile?.name || (fileUrl ? "Arquivo carregado" : "");
5842
5852
  const getBorderClasses = () => {
5843
5853
  if (hasError) {
5844
5854
  return disabled ? "border-indicator-error" : "border-indicator-error hover:border-indicator-error";
@@ -5853,38 +5863,64 @@ function FileDropzone({
5853
5863
  getBorderClasses(),
5854
5864
  disabled && "cursor-not-allowed opacity-50"
5855
5865
  );
5866
+ const isImagePreview = fileType === "image" && showPreview && Boolean(displayUrl);
5867
+ const imageCardClasses = cn(
5868
+ "flex flex-col items-center justify-center gap-3 p-6 rounded-lg bg-background-100",
5869
+ hasError && "border-2 border-indicator-error",
5870
+ disabled && "opacity-50"
5871
+ );
5856
5872
  const getAriaDescribedBy = () => {
5857
5873
  if (errorMessage) return `${inputId}-error`;
5858
5874
  if (helperText) return `${inputId}-helper`;
5859
5875
  return void 0;
5860
5876
  };
5877
+ const renderImagePreview = () => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
5878
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5879
+ "img",
5880
+ {
5881
+ src: displayUrl ?? void 0,
5882
+ alt: "Preview do arquivo",
5883
+ className: cn("max-w-full rounded-lg object-contain", previewMaxHeight)
5884
+ }
5885
+ ),
5886
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2 rounded-full border border-border-200 bg-background px-3 py-1.5", children: [
5887
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react5.Paperclip, { size: 16, className: "text-text-600" }),
5888
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text_default, { size: "sm", className: "text-text-700 max-w-[200px] truncate", children: fileName }),
5889
+ onRemoveFile && !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5890
+ Button_default,
5891
+ {
5892
+ variant: "raw",
5893
+ type: "button",
5894
+ onClick: handleRemove,
5895
+ className: "p-0.5 rounded-full hover:bg-error-100 transition-colors",
5896
+ "aria-label": "Remover arquivo",
5897
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react5.X, { size: 14, className: "text-indicator-error" })
5898
+ }
5899
+ )
5900
+ ] }),
5901
+ !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5902
+ Button_default,
5903
+ {
5904
+ variant: "outline",
5905
+ action: "primary",
5906
+ size: "small",
5907
+ iconLeft: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react5.PencilSimple, { size: 16 }),
5908
+ onClick: handleChangeClick,
5909
+ children: changeButtonText
5910
+ }
5911
+ )
5912
+ ] });
5861
5913
  const renderFilePreview = () => {
5862
- if (fileType === "image" && showPreview && displayUrl) {
5863
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col items-center gap-2", children: [
5864
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5865
- "img",
5866
- {
5867
- src: displayUrl,
5868
- alt: "Preview do arquivo",
5869
- className: cn(
5870
- "max-w-full rounded-lg object-cover",
5871
- previewMaxHeight
5872
- )
5873
- }
5874
- ),
5875
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text_default, { size: "xs", className: "text-text-500", children: defaultChangeText })
5876
- ] });
5877
- }
5878
5914
  if (hasFile) {
5879
- const fileName = selectedFile?.name || (fileUrl ? "Arquivo carregado" : "");
5880
5915
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
5881
5916
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex items-center justify-center w-12 h-12 rounded-full bg-success-100", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react5.CheckCircle, { size: 28, className: "text-success-600", weight: "fill" }) }),
5882
5917
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
5883
5918
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IconComponent, { size: 20, className: "text-text-600" }),
5884
5919
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text_default, { size: "sm", className: "text-text-700 max-w-[200px] truncate", children: fileName }),
5885
5920
  onRemoveFile && !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5886
- "button",
5921
+ Button_default,
5887
5922
  {
5923
+ variant: "raw",
5888
5924
  type: "button",
5889
5925
  onClick: handleRemove,
5890
5926
  className: "p-1 rounded-full hover:bg-error-100 transition-colors",
@@ -5918,31 +5954,40 @@ function FileDropzone({
5918
5954
  ]
5919
5955
  }
5920
5956
  ),
5921
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
5957
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5958
+ "input",
5959
+ {
5960
+ ref: fileInputRef,
5961
+ id: inputId,
5962
+ type: "file",
5963
+ accept,
5964
+ onChange: handleFileChange,
5965
+ className: "hidden",
5966
+ disabled,
5967
+ "aria-invalid": hasError,
5968
+ "aria-describedby": getAriaDescribedBy()
5969
+ }
5970
+ ),
5971
+ isImagePreview ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5972
+ "div",
5973
+ {
5974
+ className: imageCardClasses,
5975
+ onDragEnter: handleDragEnter,
5976
+ onDragLeave: handleDragLeave,
5977
+ onDragOver: handleDragOver,
5978
+ onDrop: handleDrop,
5979
+ children: renderImagePreview()
5980
+ }
5981
+ ) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5922
5982
  "label",
5923
5983
  {
5984
+ htmlFor: inputId,
5924
5985
  className: dropzoneClasses,
5925
5986
  onDragEnter: handleDragEnter,
5926
5987
  onDragLeave: handleDragLeave,
5927
5988
  onDragOver: handleDragOver,
5928
5989
  onDrop: handleDrop,
5929
- children: [
5930
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5931
- "input",
5932
- {
5933
- ref: fileInputRef,
5934
- id: inputId,
5935
- type: "file",
5936
- accept,
5937
- onChange: handleFileChange,
5938
- className: "hidden",
5939
- disabled,
5940
- "aria-invalid": hasError,
5941
- "aria-describedby": getAriaDescribedBy()
5942
- }
5943
- ),
5944
- renderFilePreview()
5945
- ]
5990
+ children: renderFilePreview()
5946
5991
  }
5947
5992
  ),
5948
5993
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mt-1", children: [