analytica-frontend-lib 1.3.72 → 1.3.73

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.
@@ -823,7 +823,7 @@ __export(AlertsManager_exports, {
823
823
  AlertsManager: () => AlertsManager
824
824
  });
825
825
  module.exports = __toCommonJS(AlertsManager_exports);
826
- var import_react21 = require("react");
826
+ var import_react22 = require("react");
827
827
 
828
828
  // src/index.ts
829
829
  init_Text();
@@ -6155,14 +6155,20 @@ function applyChainedAutoSelection(categories) {
6155
6155
  var import_phosphor_react13 = require("phosphor-react");
6156
6156
 
6157
6157
  // src/components/AlertManager/AlertSteps/MessageStep.tsx
6158
+ var import_react19 = require("react");
6158
6159
  var import_shallow = require("zustand/react/shallow");
6159
6160
  init_Input();
6160
6161
  init_TextArea();
6162
+ init_Text();
6161
6163
  var import_jsx_runtime25 = require("react/jsx-runtime");
6164
+ var ACCEPTED_IMAGE_EXTENSIONS = "image/jpeg,image/png,image/gif,image/webp,image/svg+xml,.jpg,.jpeg,.png,.gif,.webp,.svg";
6165
+ var MAX_IMAGE_SIZE_BYTES = 5 * 1024 * 1024;
6166
+ var MAX_IMAGE_SIZE_LABEL = "5MB";
6162
6167
  var MessageStep = ({
6163
6168
  labels,
6164
6169
  allowImageAttachment = true
6165
6170
  }) => {
6171
+ const [imageError, setImageError] = (0, import_react19.useState)(null);
6166
6172
  const { title, message, image, setTitle, setMessage, setImage } = useAlertFormStore(
6167
6173
  (0, import_shallow.useShallow)((state) => ({
6168
6174
  title: state.title,
@@ -6174,11 +6180,23 @@ var MessageStep = ({
6174
6180
  }))
6175
6181
  );
6176
6182
  const handleFileSelect = (file) => {
6183
+ setImageError(null);
6177
6184
  setImage(file);
6178
6185
  };
6179
6186
  const handleRemoveFile = () => {
6187
+ setImageError(null);
6180
6188
  setImage(null);
6181
6189
  };
6190
+ const handleTypeError = () => {
6191
+ setImageError(
6192
+ "Formato de imagem n\xE3o suportado. Use jpg, jpeg, png, gif, webp ou svg."
6193
+ );
6194
+ };
6195
+ const handleSizeError = () => {
6196
+ setImageError(
6197
+ `Imagem muito grande. O tamanho m\xE1ximo permitido \xE9 ${MAX_IMAGE_SIZE_LABEL}.`
6198
+ );
6199
+ };
6182
6200
  const isImageFile = image instanceof File;
6183
6201
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("section", { className: "flex flex-col gap-4", children: [
6184
6202
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -6202,19 +6220,26 @@ var MessageStep = ({
6202
6220
  onChange: (e) => setMessage(e.target.value)
6203
6221
  }
6204
6222
  ),
6205
- allowImageAttachment && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6206
- ImageUpload,
6207
- {
6208
- selectedFile: isImageFile ? image : null,
6209
- onFileSelect: handleFileSelect,
6210
- onRemoveFile: handleRemoveFile
6211
- }
6212
- )
6223
+ allowImageAttachment && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-2", children: [
6224
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6225
+ ImageUpload,
6226
+ {
6227
+ selectedFile: isImageFile ? image : null,
6228
+ onFileSelect: handleFileSelect,
6229
+ onRemoveFile: handleRemoveFile,
6230
+ accept: ACCEPTED_IMAGE_EXTENSIONS,
6231
+ maxSize: MAX_IMAGE_SIZE_BYTES,
6232
+ onTypeError: handleTypeError,
6233
+ onSizeError: handleSizeError
6234
+ }
6235
+ ),
6236
+ imageError && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Text_default, { size: "sm", className: "text-error-600", role: "alert", children: imageError })
6237
+ ] })
6213
6238
  ] });
6214
6239
  };
6215
6240
 
6216
6241
  // src/components/AlertManager/AlertSteps/RecipientsStep.tsx
6217
- var import_react19 = require("react");
6242
+ var import_react20 = require("react");
6218
6243
  var import_jsx_runtime26 = require("react/jsx-runtime");
6219
6244
  var RecipientsStep = ({
6220
6245
  categories,
@@ -6222,7 +6247,7 @@ var RecipientsStep = ({
6222
6247
  onCategoriesChange
6223
6248
  }) => {
6224
6249
  const { recipientCategories, initializeCategory } = useAlertFormStore();
6225
- (0, import_react19.useEffect)(() => {
6250
+ (0, import_react20.useEffect)(() => {
6226
6251
  for (const category of categories) {
6227
6252
  const existingCategory = recipientCategories[category.key];
6228
6253
  if (!existingCategory) {
@@ -6252,7 +6277,7 @@ var RecipientsStep = ({
6252
6277
  onCategoriesChange(updatedCategories);
6253
6278
  }
6254
6279
  };
6255
- const syncedCategories = (0, import_react19.useMemo)(() => {
6280
+ const syncedCategories = (0, import_react20.useMemo)(() => {
6256
6281
  return categories.map((category) => {
6257
6282
  const storeCategory = recipientCategories[category.key];
6258
6283
  if (storeCategory) {
@@ -6337,13 +6362,13 @@ var DateStep = ({
6337
6362
  };
6338
6363
 
6339
6364
  // src/components/AlertManager/AlertSteps/PreviewStep.tsx
6340
- var import_react20 = require("react");
6365
+ var import_react21 = require("react");
6341
6366
  var import_jsx_runtime28 = require("react/jsx-runtime");
6342
6367
  var PreviewStep = ({ imageLink, defaultImage }) => {
6343
6368
  const title = useAlertFormStore((state) => state.title);
6344
6369
  const message = useAlertFormStore((state) => state.message);
6345
6370
  const image = useAlertFormStore((state) => state.image);
6346
- const imageUrl = (0, import_react20.useMemo)(() => {
6371
+ const imageUrl = (0, import_react21.useMemo)(() => {
6347
6372
  if (globalThis.window === void 0) {
6348
6373
  return void 0;
6349
6374
  }
@@ -6355,7 +6380,7 @@ var PreviewStep = ({ imageLink, defaultImage }) => {
6355
6380
  }
6356
6381
  return void 0;
6357
6382
  }, [image]);
6358
- (0, import_react20.useEffect)(() => {
6383
+ (0, import_react21.useEffect)(() => {
6359
6384
  return () => {
6360
6385
  if (globalThis.window !== void 0 && imageUrl && image instanceof File) {
6361
6386
  URL.revokeObjectURL(imageUrl);
@@ -6462,29 +6487,29 @@ var AlertsManager = ({
6462
6487
  imageLink,
6463
6488
  defaultImage
6464
6489
  }) => {
6465
- const [isModalOpen, setIsModalOpen] = (0, import_react21.useState)(isOpen);
6466
- const [currentStep, setCurrentStep] = (0, import_react21.useState)(0);
6467
- const [completedSteps, setCompletedSteps] = (0, import_react21.useState)([]);
6468
- const [categories, setCategories] = (0, import_react21.useState)(config.categories);
6469
- const formData = (0, import_react21.useSyncExternalStore)(
6490
+ const [isModalOpen, setIsModalOpen] = (0, import_react22.useState)(isOpen);
6491
+ const [currentStep, setCurrentStep] = (0, import_react22.useState)(0);
6492
+ const [completedSteps, setCompletedSteps] = (0, import_react22.useState)([]);
6493
+ const [categories, setCategories] = (0, import_react22.useState)(config.categories);
6494
+ const formData = (0, import_react22.useSyncExternalStore)(
6470
6495
  useAlertFormStore.subscribe,
6471
6496
  useAlertFormStore.getState
6472
6497
  );
6473
- (0, import_react21.useEffect)(() => {
6498
+ (0, import_react22.useEffect)(() => {
6474
6499
  setIsModalOpen(isOpen);
6475
6500
  }, [isOpen]);
6476
- const categoriesInitializedRef = (0, import_react21.useRef)(false);
6501
+ const categoriesInitializedRef = (0, import_react22.useRef)(false);
6477
6502
  const { labels, behavior, steps: customSteps } = config;
6478
6503
  const { handleCategoriesChange: baseHandleCategoriesChange } = useDynamicStudentFetching(setCategories, {
6479
6504
  fetchStudentsByFilters: behavior?.fetchStudentsByFilters
6480
6505
  });
6481
- const handleCategoriesChange = (0, import_react21.useCallback)(
6506
+ const handleCategoriesChange = (0, import_react22.useCallback)(
6482
6507
  async (updatedCategories) => {
6483
6508
  await baseHandleCategoriesChange(updatedCategories);
6484
6509
  },
6485
6510
  [baseHandleCategoriesChange]
6486
6511
  );
6487
- (0, import_react21.useEffect)(() => {
6512
+ (0, import_react22.useEffect)(() => {
6488
6513
  if (isModalOpen && config.categories.length > 0 && !categoriesInitializedRef.current) {
6489
6514
  const autoSelectedCategories = applyChainedAutoSelection(
6490
6515
  config.categories
@@ -6499,7 +6524,7 @@ var AlertsManager = ({
6499
6524
  applyChainedAutoSelection,
6500
6525
  handleCategoriesChange
6501
6526
  ]);
6502
- (0, import_react21.useEffect)(() => {
6527
+ (0, import_react22.useEffect)(() => {
6503
6528
  if (!isModalOpen) {
6504
6529
  categoriesInitializedRef.current = false;
6505
6530
  }
@@ -6531,7 +6556,7 @@ var AlertsManager = ({
6531
6556
  setIsModalOpen(false);
6532
6557
  onClose?.();
6533
6558
  };
6534
- const isCurrentStepValid2 = (0, import_react21.useCallback)(() => {
6559
+ const isCurrentStepValid2 = (0, import_react22.useCallback)(() => {
6535
6560
  return isCurrentStepValid(
6536
6561
  currentStep,
6537
6562
  formData,
@@ -6539,10 +6564,10 @@ var AlertsManager = ({
6539
6564
  customSteps
6540
6565
  );
6541
6566
  }, [currentStep, categories, customSteps, formData]);
6542
- const canFinish2 = (0, import_react21.useCallback)(() => {
6567
+ const canFinish2 = (0, import_react22.useCallback)(() => {
6543
6568
  return canFinish(formData, categories);
6544
6569
  }, [categories, formData]);
6545
- const handleNext2 = (0, import_react21.useCallback)(() => {
6570
+ const handleNext2 = (0, import_react22.useCallback)(() => {
6546
6571
  const result = handleNext({
6547
6572
  currentStep,
6548
6573
  steps,
@@ -6566,7 +6591,7 @@ var AlertsManager = ({
6566
6591
  setCurrentStep,
6567
6592
  formData
6568
6593
  ]);
6569
- const handlePrevious = (0, import_react21.useCallback)(() => {
6594
+ const handlePrevious = (0, import_react22.useCallback)(() => {
6570
6595
  if (currentStep > 0) {
6571
6596
  setCurrentStep(currentStep - 1);
6572
6597
  }
@@ -6616,7 +6641,7 @@ var AlertsManager = ({
6616
6641
  return { ...step, state: "pending" };
6617
6642
  }
6618
6643
  );
6619
- const currentStepContent = (0, import_react21.useMemo)(() => {
6644
+ const currentStepContent = (0, import_react22.useMemo)(() => {
6620
6645
  if (customSteps?.[currentStep]?.component) {
6621
6646
  const CustomComponent = customSteps[currentStep].component;
6622
6647
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(StepWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CustomComponent, { onNext: handleNext2, onPrevious: handlePrevious }) });