analytica-frontend-lib 1.2.16 → 1.2.18

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.
@@ -1064,6 +1064,101 @@ var CheckboxGroup = ({
1064
1064
  );
1065
1065
  };
1066
1066
 
1067
+ // src/components/AlertManager/useAlertForm.ts
1068
+ import { create } from "zustand";
1069
+ var initialState = {
1070
+ title: "",
1071
+ message: "",
1072
+ image: null,
1073
+ date: "",
1074
+ time: "",
1075
+ sendToday: false,
1076
+ sendCopyToEmail: false,
1077
+ recipientCategories: {}
1078
+ };
1079
+ var useAlertFormStore = create((set) => ({
1080
+ ...initialState,
1081
+ // Step 1 - Mensagem
1082
+ setTitle: (title) => set({ title }),
1083
+ setMessage: (message) => set({ message }),
1084
+ setImage: (image) => set({ image }),
1085
+ // Step 2 - Destinatários (Dinâmico)
1086
+ initializeCategory: (category) => set((state) => ({
1087
+ recipientCategories: {
1088
+ ...state.recipientCategories,
1089
+ [category.key]: {
1090
+ ...category,
1091
+ selectedIds: category.selectedIds || [],
1092
+ allSelected: category.allSelected || false
1093
+ }
1094
+ }
1095
+ })),
1096
+ updateCategoryItems: (key, items) => set((state) => {
1097
+ const base = state.recipientCategories[key] ?? {
1098
+ key,
1099
+ label: key,
1100
+ availableItems: [],
1101
+ selectedIds: [],
1102
+ allSelected: false
1103
+ };
1104
+ return {
1105
+ recipientCategories: {
1106
+ ...state.recipientCategories,
1107
+ [key]: { ...base, availableItems: items }
1108
+ }
1109
+ };
1110
+ }),
1111
+ updateCategorySelection: (key, selectedIds, allSelected) => set((state) => {
1112
+ const base = state.recipientCategories[key] ?? {
1113
+ key,
1114
+ label: key,
1115
+ availableItems: [],
1116
+ selectedIds: [],
1117
+ allSelected: false
1118
+ };
1119
+ return {
1120
+ recipientCategories: {
1121
+ ...state.recipientCategories,
1122
+ [key]: { ...base, selectedIds, allSelected }
1123
+ }
1124
+ };
1125
+ }),
1126
+ clearCategorySelection: (key) => set((state) => {
1127
+ const base = state.recipientCategories[key] ?? {
1128
+ key,
1129
+ label: key,
1130
+ availableItems: [],
1131
+ selectedIds: [],
1132
+ allSelected: false
1133
+ };
1134
+ return {
1135
+ recipientCategories: {
1136
+ ...state.recipientCategories,
1137
+ [key]: { ...base, selectedIds: [], allSelected: false }
1138
+ }
1139
+ };
1140
+ }),
1141
+ // Step 3 - Data de envio
1142
+ setDate: (date) => set({ date }),
1143
+ setTime: (time) => set({ time }),
1144
+ setSendToday: (sendToday) => {
1145
+ const now = /* @__PURE__ */ new Date();
1146
+ const year = now.getFullYear();
1147
+ const month = String(now.getMonth() + 1).padStart(2, "0");
1148
+ const day = String(now.getDate()).padStart(2, "0");
1149
+ const hours = String(now.getHours()).padStart(2, "0");
1150
+ const minutes = String(now.getMinutes()).padStart(2, "0");
1151
+ set({
1152
+ sendToday,
1153
+ date: `${year}-${month}-${day}`,
1154
+ time: `${hours}:${minutes}`
1155
+ });
1156
+ },
1157
+ setSendCopyToEmail: (sendCopyToEmail) => set({ sendCopyToEmail }),
1158
+ // Reset form
1159
+ resetForm: () => set(initialState)
1160
+ }));
1161
+
1067
1162
  // src/components/Modal/Modal.tsx
1068
1163
  import { useEffect as useEffect2, useId as useId2 } from "react";
1069
1164
  import { X as X2 } from "phosphor-react";
@@ -1331,9 +1426,6 @@ var Divider = ({
1331
1426
  };
1332
1427
  var Divider_default = Divider;
1333
1428
 
1334
- // src/assets/img/notification.png
1335
- var notification_default = "../notification-TD7ZFRLL.png";
1336
-
1337
1429
  // src/components/TextArea/TextArea.tsx
1338
1430
  import {
1339
1431
  forwardRef as forwardRef3,
@@ -1686,7 +1778,7 @@ import {
1686
1778
  cloneElement,
1687
1779
  useState as useState7
1688
1780
  } from "react";
1689
- import { create as create2, useStore } from "zustand";
1781
+ import { create as create3, useStore } from "zustand";
1690
1782
 
1691
1783
  // src/components/ThemeToggle/ThemeToggle.tsx
1692
1784
  import { Moon, Sun } from "phosphor-react";
@@ -1696,7 +1788,7 @@ import { useState as useState6, useEffect as useEffect4 } from "react";
1696
1788
  import { useEffect as useEffect3 } from "react";
1697
1789
 
1698
1790
  // src/store/themeStore.ts
1699
- import { create } from "zustand";
1791
+ import { create as create2 } from "zustand";
1700
1792
  import { devtools, persist } from "zustand/middleware";
1701
1793
  var applyThemeToDOM = (mode) => {
1702
1794
  const htmlElement = document.documentElement;
@@ -1730,7 +1822,7 @@ var saveOriginalTheme = () => {
1730
1822
  htmlElement.setAttribute("data-original-theme", currentTheme);
1731
1823
  }
1732
1824
  };
1733
- var useThemeStore = create()(
1825
+ var useThemeStore = create2()(
1734
1826
  devtools(
1735
1827
  persist(
1736
1828
  (set, get) => ({
@@ -1884,7 +1976,7 @@ var ThemeToggle = ({
1884
1976
  // src/components/DropdownMenu/DropdownMenu.tsx
1885
1977
  import { Fragment, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
1886
1978
  function createDropdownStore() {
1887
- return create2((set) => ({
1979
+ return create3((set) => ({
1888
1980
  open: false,
1889
1981
  setOpen: (open) => set({ open })
1890
1982
  }));
@@ -5200,10 +5292,10 @@ import {
5200
5292
  useRef as useRef6,
5201
5293
  useState as useState11
5202
5294
  } from "react";
5203
- import { create as create3 } from "zustand";
5295
+ import { create as create4 } from "zustand";
5204
5296
  import { jsx as jsx23 } from "react/jsx-runtime";
5205
5297
  function createAccordionGroupStore(type, initialValue, collapsible) {
5206
- return create3((set, get) => ({
5298
+ return create4((set, get) => ({
5207
5299
  type,
5208
5300
  value: initialValue,
5209
5301
  collapsible,
@@ -5349,101 +5441,6 @@ AccordionGroup.displayName = "AccordionGroup";
5349
5441
  // src/components/AlertManager/AlertsManager.tsx
5350
5442
  import { CaretLeft, CaretRight as CaretRight4, PaperPlaneTilt } from "phosphor-react";
5351
5443
 
5352
- // src/components/AlertManager/useAlertForm.ts
5353
- import { create as create4 } from "zustand";
5354
- var initialState = {
5355
- title: "",
5356
- message: "",
5357
- image: null,
5358
- date: "",
5359
- time: "",
5360
- sendToday: false,
5361
- sendCopyToEmail: false,
5362
- recipientCategories: {}
5363
- };
5364
- var useAlertFormStore = create4((set) => ({
5365
- ...initialState,
5366
- // Step 1 - Mensagem
5367
- setTitle: (title) => set({ title }),
5368
- setMessage: (message) => set({ message }),
5369
- setImage: (image) => set({ image }),
5370
- // Step 2 - Destinatários (Dinâmico)
5371
- initializeCategory: (category) => set((state) => ({
5372
- recipientCategories: {
5373
- ...state.recipientCategories,
5374
- [category.key]: {
5375
- ...category,
5376
- selectedIds: category.selectedIds || [],
5377
- allSelected: category.allSelected || false
5378
- }
5379
- }
5380
- })),
5381
- updateCategoryItems: (key, items) => set((state) => {
5382
- const base = state.recipientCategories[key] ?? {
5383
- key,
5384
- label: key,
5385
- availableItems: [],
5386
- selectedIds: [],
5387
- allSelected: false
5388
- };
5389
- return {
5390
- recipientCategories: {
5391
- ...state.recipientCategories,
5392
- [key]: { ...base, availableItems: items }
5393
- }
5394
- };
5395
- }),
5396
- updateCategorySelection: (key, selectedIds, allSelected) => set((state) => {
5397
- const base = state.recipientCategories[key] ?? {
5398
- key,
5399
- label: key,
5400
- availableItems: [],
5401
- selectedIds: [],
5402
- allSelected: false
5403
- };
5404
- return {
5405
- recipientCategories: {
5406
- ...state.recipientCategories,
5407
- [key]: { ...base, selectedIds, allSelected }
5408
- }
5409
- };
5410
- }),
5411
- clearCategorySelection: (key) => set((state) => {
5412
- const base = state.recipientCategories[key] ?? {
5413
- key,
5414
- label: key,
5415
- availableItems: [],
5416
- selectedIds: [],
5417
- allSelected: false
5418
- };
5419
- return {
5420
- recipientCategories: {
5421
- ...state.recipientCategories,
5422
- [key]: { ...base, selectedIds: [], allSelected: false }
5423
- }
5424
- };
5425
- }),
5426
- // Step 3 - Data de envio
5427
- setDate: (date) => set({ date }),
5428
- setTime: (time) => set({ time }),
5429
- setSendToday: (sendToday) => {
5430
- const now = /* @__PURE__ */ new Date();
5431
- const year = now.getFullYear();
5432
- const month = String(now.getMonth() + 1).padStart(2, "0");
5433
- const day = String(now.getDate()).padStart(2, "0");
5434
- const hours = String(now.getHours()).padStart(2, "0");
5435
- const minutes = String(now.getMinutes()).padStart(2, "0");
5436
- set({
5437
- sendToday,
5438
- date: `${year}-${month}-${day}`,
5439
- time: `${hours}:${minutes}`
5440
- });
5441
- },
5442
- setSendCopyToEmail: (sendCopyToEmail) => set({ sendCopyToEmail }),
5443
- // Reset form
5444
- resetForm: () => set(initialState)
5445
- }));
5446
-
5447
5444
  // src/components/AlertManager/AlertSteps/MessageStep.tsx
5448
5445
  import { useShallow } from "zustand/react/shallow";
5449
5446
  import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
@@ -5467,6 +5464,7 @@ var MessageStep = ({
5467
5464
  const handleRemoveFile = () => {
5468
5465
  setImage(null);
5469
5466
  };
5467
+ const isImageFile = image instanceof File;
5470
5468
  return /* @__PURE__ */ jsxs19("section", { className: "flex flex-col gap-4", children: [
5471
5469
  /* @__PURE__ */ jsx24(
5472
5470
  Input_default,
@@ -5492,7 +5490,7 @@ var MessageStep = ({
5492
5490
  allowImageAttachment && /* @__PURE__ */ jsx24(
5493
5491
  ImageUpload,
5494
5492
  {
5495
- selectedFile: image,
5493
+ selectedFile: isImageFile ? image : null,
5496
5494
  onFileSelect: handleFileSelect,
5497
5495
  onRemoveFile: handleRemoveFile
5498
5496
  }
@@ -5696,7 +5694,7 @@ var DateStep = ({
5696
5694
  // src/components/AlertManager/AlertSteps/PreviewStep.tsx
5697
5695
  import { useMemo as useMemo5, useEffect as useEffect11 } from "react";
5698
5696
  import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
5699
- var PreviewStep = () => {
5697
+ var PreviewStep = ({ imageLink, defaultImage }) => {
5700
5698
  const title = useAlertFormStore((state) => state.title);
5701
5699
  const message = useAlertFormStore((state) => state.message);
5702
5700
  const image = useAlertFormStore((state) => state.image);
@@ -5707,17 +5705,21 @@ var PreviewStep = () => {
5707
5705
  if (image instanceof File) {
5708
5706
  return globalThis.window.URL.createObjectURL(image);
5709
5707
  }
5708
+ if (typeof image === "string") {
5709
+ return image;
5710
+ }
5710
5711
  return void 0;
5711
5712
  }, [image]);
5712
5713
  useEffect11(() => {
5713
5714
  return () => {
5714
- if (imageUrl && globalThis.window !== void 0) {
5715
+ if (globalThis.window !== void 0 && imageUrl && image instanceof File) {
5715
5716
  URL.revokeObjectURL(imageUrl);
5716
5717
  }
5717
5718
  };
5718
- }, [imageUrl]);
5719
+ }, [imageUrl, image]);
5720
+ const finalImageUrl = imageLink || imageUrl || defaultImage || void 0;
5719
5721
  return /* @__PURE__ */ jsx27("section", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxs22("div", { className: "bg-background-50 px-5 py-6 flex flex-col items-center gap-4 rounded-xl", children: [
5720
- /* @__PURE__ */ jsx27("img", { src: imageUrl || notification_default, alt: title || "Imagem do alerta" }),
5722
+ finalImageUrl && /* @__PURE__ */ jsx27("img", { src: finalImageUrl, alt: title || "Imagem do alerta" }),
5721
5723
  /* @__PURE__ */ jsxs22("div", { className: "flex flex-col items-center text-center gap-3", children: [
5722
5724
  /* @__PURE__ */ jsx27(Text_default, { size: "lg", weight: "semibold", children: title || "Nenhum T\xEDtulo de Alerta" }),
5723
5725
  /* @__PURE__ */ jsx27(Text_default, { size: "sm", weight: "normal", className: "text-text-500", children: message || "Aqui aparecer\xE1 a mensagem do alerta definido pelo usu\xE1rio" })
@@ -5811,7 +5813,9 @@ var StepWrapper = ({ children }) => /* @__PURE__ */ jsx28("div", { children });
5811
5813
  var AlertsManager = ({
5812
5814
  config,
5813
5815
  isOpen = false,
5814
- onClose
5816
+ onClose,
5817
+ imageLink,
5818
+ defaultImage
5815
5819
  }) => {
5816
5820
  const [isModalOpen, setIsModalOpen] = useState13(isOpen);
5817
5821
  const [currentStep, setCurrentStep] = useState13(0);
@@ -5970,7 +5974,7 @@ var AlertsManager = ({
5970
5974
  }
5971
5975
  ) });
5972
5976
  case 3:
5973
- return /* @__PURE__ */ jsx28(StepWrapper, { children: /* @__PURE__ */ jsx28(PreviewStep, {}) });
5977
+ return /* @__PURE__ */ jsx28(StepWrapper, { children: /* @__PURE__ */ jsx28(PreviewStep, { imageLink, defaultImage }) });
5974
5978
  default:
5975
5979
  return null;
5976
5980
  }
@@ -5981,7 +5985,9 @@ var AlertsManager = ({
5981
5985
  labels,
5982
5986
  behavior,
5983
5987
  handleNext2,
5984
- handlePrevious
5988
+ handlePrevious,
5989
+ imageLink,
5990
+ defaultImage
5985
5991
  ]);
5986
5992
  const isFirstStep = currentStep === 0;
5987
5993
  const isLastStep = currentStep === steps.length - 1;