@cnc-ti/layout-basic 8.6.0 → 8.7.0

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
@@ -153,6 +153,20 @@ var Bell = createLucideIcon("Bell", [
153
153
  ["path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0", key: "qgo35s" }]
154
154
  ]);
155
155
 
156
+ // ../../node_modules/lucide-react/dist/esm/icons/calendar-days.js
157
+ var CalendarDays = createLucideIcon("CalendarDays", [
158
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
159
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
160
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
161
+ ["path", { d: "M3 10h18", key: "8toen8" }],
162
+ ["path", { d: "M8 14h.01", key: "6423bh" }],
163
+ ["path", { d: "M12 14h.01", key: "1etili" }],
164
+ ["path", { d: "M16 14h.01", key: "1gbofw" }],
165
+ ["path", { d: "M8 18h.01", key: "lrp35t" }],
166
+ ["path", { d: "M12 18h.01", key: "mhygvu" }],
167
+ ["path", { d: "M16 18h.01", key: "kzsmim" }]
168
+ ]);
169
+
156
170
  // ../../node_modules/lucide-react/dist/esm/icons/check.js
157
171
  var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
158
172
 
@@ -267,6 +281,18 @@ var Paperclip = createLucideIcon("Paperclip", [
267
281
  ]
268
282
  ]);
269
283
 
284
+ // ../../node_modules/lucide-react/dist/esm/icons/pencil.js
285
+ var Pencil = createLucideIcon("Pencil", [
286
+ [
287
+ "path",
288
+ {
289
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
290
+ key: "1a8usu"
291
+ }
292
+ ],
293
+ ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
294
+ ]);
295
+
270
296
  // ../../node_modules/lucide-react/dist/esm/icons/plus.js
271
297
  var Plus = createLucideIcon("Plus", [
272
298
  ["path", { d: "M5 12h14", key: "1ays0h" }],
@@ -6780,7 +6806,756 @@ function HeaderNotifications(props) {
6780
6806
  ] })
6781
6807
  ] });
6782
6808
  }
6809
+
6810
+ // src/alertas/alertas.tsx
6811
+ import * as React32 from "react";
6812
+
6813
+ // src/alertas/formulario-alerta.tsx
6814
+ import * as React30 from "react";
6815
+
6816
+ // src/alertas/date-utils.ts
6817
+ function obterHojeDataHoraIsoLocal() {
6818
+ const hoje = /* @__PURE__ */ new Date();
6819
+ const ano = hoje.getFullYear();
6820
+ const mes = String(hoje.getMonth() + 1).padStart(2, "0");
6821
+ const dia = String(hoje.getDate()).padStart(2, "0");
6822
+ const horas = String(hoje.getHours()).padStart(2, "0");
6823
+ const minutos = String(hoje.getMinutes()).padStart(2, "0");
6824
+ return `${ano}-${mes}-${dia}T${horas}:${minutos}`;
6825
+ }
6826
+ function datetimeLocalParaIsoComOffset(valorInput) {
6827
+ if (!valorInput) return valorInput;
6828
+ const data = new Date(valorInput);
6829
+ if (isNaN(data.getTime())) return valorInput;
6830
+ const offsetMinutos = data.getTimezoneOffset();
6831
+ const sinal = offsetMinutos <= 0 ? "+" : "-";
6832
+ const absOffset = Math.abs(offsetMinutos);
6833
+ const offsetHoras = String(Math.floor(absOffset / 60)).padStart(2, "0");
6834
+ const offsetMins = String(absOffset % 60).padStart(2, "0");
6835
+ const ano = data.getFullYear();
6836
+ const mes = String(data.getMonth() + 1).padStart(2, "0");
6837
+ const dia = String(data.getDate()).padStart(2, "0");
6838
+ const horas = String(data.getHours()).padStart(2, "0");
6839
+ const minutos = String(data.getMinutes()).padStart(2, "0");
6840
+ return `${ano}-${mes}-${dia}T${horas}:${minutos}:00${sinal}${offsetHoras}:${offsetMins}`;
6841
+ }
6842
+ function formatarDataParaExibicao(iso) {
6843
+ if (!iso) return "";
6844
+ const dataObj = new Date(iso);
6845
+ if (isNaN(dataObj.getTime())) return "";
6846
+ const dia = String(dataObj.getDate()).padStart(2, "0");
6847
+ const mes = String(dataObj.getMonth() + 1).padStart(2, "0");
6848
+ const ano = dataObj.getFullYear();
6849
+ const horas = String(dataObj.getHours()).padStart(2, "0");
6850
+ const minutos = String(dataObj.getMinutes()).padStart(2, "0");
6851
+ return `${dia}/${mes}/${ano} \xE0s ${horas}:${minutos}`;
6852
+ }
6853
+
6854
+ // src/alertas/formulario-alerta.tsx
6855
+ import { jsx as jsx43, jsxs as jsxs34 } from "react/jsx-runtime";
6856
+ var FORM_VAZIO = {
6857
+ titulo: "",
6858
+ dataReferencia: "",
6859
+ lembrarNoDia: true,
6860
+ diasAntes: "",
6861
+ alertasDiasAntes: [],
6862
+ novoAlertaDiasAntes: "",
6863
+ mensagem: "",
6864
+ enviarEmail: false
6865
+ };
6866
+ function normalizarAlertasDiasAntes(values) {
6867
+ const alertas = [...values.alertasDiasAntes];
6868
+ if (values.novoAlertaDiasAntes.trim()) {
6869
+ alertas.push(values.novoAlertaDiasAntes.trim());
6870
+ }
6871
+ return Array.from(new Set(alertas.map(Number))).sort((a, b) => a - b);
6872
+ }
6873
+ function construirPayload(values) {
6874
+ const alertasNumericos = normalizarAlertasDiasAntes(values);
6875
+ const diasAntes = alertasNumericos.length ? Math.max(...alertasNumericos) : values.diasAntes.trim() ? Number(values.diasAntes) : 0;
6876
+ return {
6877
+ titulo: values.titulo.trim(),
6878
+ dataReferencia: datetimeLocalParaIsoComOffset(values.dataReferencia),
6879
+ lembrarNoDia: values.lembrarNoDia,
6880
+ diasAntes,
6881
+ alertasDiasAntes: alertasNumericos,
6882
+ mensagem: values.mensagem.trim() || void 0,
6883
+ enviarEmail: values.enviarEmail
6884
+ };
6885
+ }
6886
+ function preencherFormDoAlerta(alerta) {
6887
+ const alertasDiasAntes = alerta.alertasDiasAntes && alerta.alertasDiasAntes.length > 0 ? alerta.alertasDiasAntes.map(String) : alerta.diasAntes > 0 ? [String(alerta.diasAntes)] : [];
6888
+ const dataObj = new Date(alerta.dataReferencia);
6889
+ const formatada = isNaN(dataObj.getTime()) ? "" : (() => {
6890
+ const ano = dataObj.getFullYear();
6891
+ const mes = String(dataObj.getMonth() + 1).padStart(2, "0");
6892
+ const dia = String(dataObj.getDate()).padStart(2, "0");
6893
+ const horas = String(dataObj.getHours()).padStart(2, "0");
6894
+ const minutos = String(dataObj.getMinutes()).padStart(2, "0");
6895
+ return `${ano}-${mes}-${dia}T${horas}:${minutos}`;
6896
+ })();
6897
+ return {
6898
+ titulo: alerta.titulo,
6899
+ dataReferencia: formatada,
6900
+ lembrarNoDia: alerta.lembrarNoDia ?? alerta.diasAntes === 0,
6901
+ diasAntes: alerta.diasAntes ? String(alerta.diasAntes) : "",
6902
+ alertasDiasAntes,
6903
+ novoAlertaDiasAntes: "",
6904
+ mensagem: alerta.mensagem ?? "",
6905
+ enviarEmail: alerta.enviarEmail ?? false
6906
+ };
6907
+ }
6908
+ function validarForm(values) {
6909
+ if (!values.titulo.trim()) return "Informe o titulo do alerta";
6910
+ if (!values.dataReferencia) return "Informe a data do alerta";
6911
+ if (new Date(values.dataReferencia) < /* @__PURE__ */ new Date()) {
6912
+ return "Informe uma data e hora igual ou posterior ao momento atual";
6913
+ }
6914
+ if (values.diasAntes.trim() && values.diasAntes !== "0") {
6915
+ const diasAntes = Number(values.diasAntes);
6916
+ if (!Number.isInteger(diasAntes) || diasAntes < 0) {
6917
+ return "Informe uma quantidade de dias maior ou igual a zero";
6918
+ }
6919
+ }
6920
+ if (values.novoAlertaDiasAntes.trim()) {
6921
+ const novoAlerta = Number(values.novoAlertaDiasAntes);
6922
+ if (!Number.isInteger(novoAlerta) || novoAlerta <= 0) {
6923
+ return "Informe uma quantidade de dias maior que zero";
6924
+ }
6925
+ }
6926
+ return "";
6927
+ }
6928
+ function OpcaoAlerta({ checked, label, onChange }) {
6929
+ return /* @__PURE__ */ jsxs34("label", { className: "alerta-opcao", children: [
6930
+ /* @__PURE__ */ jsx43(
6931
+ "input",
6932
+ {
6933
+ type: "checkbox",
6934
+ checked,
6935
+ onChange: (e) => onChange(e.target.checked),
6936
+ className: "alerta-checkbox"
6937
+ }
6938
+ ),
6939
+ label
6940
+ ] });
6941
+ }
6942
+ function FormularioAlerta({
6943
+ alertaEmEdicao,
6944
+ isSaving = false,
6945
+ onSalvar,
6946
+ onCancelar
6947
+ }) {
6948
+ const [values, setValues] = React30.useState(
6949
+ () => alertaEmEdicao ? preencherFormDoAlerta(alertaEmEdicao) : FORM_VAZIO
6950
+ );
6951
+ const [erro, setErro] = React30.useState("");
6952
+ const [hojeDataHoraIso, setHojeDataHoraIso] = React30.useState("");
6953
+ React30.useEffect(() => {
6954
+ setHojeDataHoraIso(obterHojeDataHoraIsoLocal());
6955
+ }, []);
6956
+ React30.useEffect(() => {
6957
+ setValues(alertaEmEdicao ? preencherFormDoAlerta(alertaEmEdicao) : FORM_VAZIO);
6958
+ setErro("");
6959
+ }, [alertaEmEdicao]);
6960
+ const setField = (campo, valor) => {
6961
+ setErro("");
6962
+ setValues((prev) => ({ ...prev, [campo]: valor }));
6963
+ };
6964
+ const toggleLembrarNoDia = (checked) => {
6965
+ setErro("");
6966
+ setValues((prev) => ({ ...prev, lembrarNoDia: checked }));
6967
+ };
6968
+ const toggleAlertaDiasAntes = (dias, checked) => {
6969
+ setErro("");
6970
+ setValues((prev) => {
6971
+ const valor = String(dias);
6972
+ const alertas = new Set(prev.alertasDiasAntes);
6973
+ if (checked) alertas.add(valor);
6974
+ else alertas.delete(valor);
6975
+ const alertasDiasAntes = Array.from(alertas).sort(
6976
+ (a, b) => Number(a) - Number(b)
6977
+ );
6978
+ return {
6979
+ ...prev,
6980
+ alertasDiasAntes,
6981
+ diasAntes: alertasDiasAntes.length > 0 ? String(Math.max(...alertasDiasAntes.map(Number))) : ""
6982
+ };
6983
+ });
6984
+ };
6985
+ const adicionarAlertaDiasAntes = () => {
6986
+ const valor = values.novoAlertaDiasAntes.trim();
6987
+ const dias = Number(valor);
6988
+ if (!Number.isInteger(dias) || dias <= 0) {
6989
+ setErro("Informe uma quantidade de dias maior que zero");
6990
+ return;
6991
+ }
6992
+ setErro("");
6993
+ setValues((prev) => {
6994
+ const alertas = new Set(prev.alertasDiasAntes);
6995
+ alertas.add(String(dias));
6996
+ const alertasDiasAntes = Array.from(alertas).sort(
6997
+ (a, b) => Number(a) - Number(b)
6998
+ );
6999
+ return {
7000
+ ...prev,
7001
+ diasAntes: String(Math.max(...alertasDiasAntes.map(Number))),
7002
+ novoAlertaDiasAntes: "",
7003
+ alertasDiasAntes
7004
+ };
7005
+ });
7006
+ };
7007
+ const removerAlertaDiasAntes = (valor) => {
7008
+ setValues((prev) => {
7009
+ const alertasDiasAntes = prev.alertasDiasAntes.filter((item) => item !== valor);
7010
+ return {
7011
+ ...prev,
7012
+ alertasDiasAntes,
7013
+ diasAntes: alertasDiasAntes.length > 0 ? String(Math.max(...alertasDiasAntes.map(Number))) : ""
7014
+ };
7015
+ });
7016
+ };
7017
+ const handleSalvar = () => {
7018
+ const mensagemErro = validarForm(values);
7019
+ if (mensagemErro) {
7020
+ setErro(mensagemErro);
7021
+ return;
7022
+ }
7023
+ onSalvar(construirPayload(values));
7024
+ };
7025
+ const alertasPersonalizados = values.alertasDiasAntes.filter(
7026
+ (d) => !["2", "7", "15", "30"].includes(d)
7027
+ );
7028
+ return /* @__PURE__ */ jsxs34("section", { className: "alerta-form-section", children: [
7029
+ /* @__PURE__ */ jsx43("div", { className: "alerta-form-header", children: /* @__PURE__ */ jsx43("h2", { className: "alerta-form-titulo", children: alertaEmEdicao ? "Editar alerta" : "Novo alerta" }) }),
7030
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-form-grid", children: [
7031
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-campo", children: [
7032
+ /* @__PURE__ */ jsxs34("label", { htmlFor: "alerta-titulo", className: "alerta-label", children: [
7033
+ "Titulo ",
7034
+ /* @__PURE__ */ jsx43("span", { className: "alerta-obrigatorio", children: "*" })
7035
+ ] }),
7036
+ /* @__PURE__ */ jsx43(
7037
+ "input",
7038
+ {
7039
+ id: "alerta-titulo",
7040
+ type: "text",
7041
+ value: values.titulo,
7042
+ onChange: (e) => setField("titulo", e.target.value),
7043
+ placeholder: "Informe o titulo do alerta",
7044
+ className: "alerta-input"
7045
+ }
7046
+ )
7047
+ ] }),
7048
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-campo alerta-campo--data", children: [
7049
+ /* @__PURE__ */ jsxs34("label", { htmlFor: "alerta-data", className: "alerta-label", children: [
7050
+ "Data e Hora ",
7051
+ /* @__PURE__ */ jsx43("span", { className: "alerta-obrigatorio", children: "*" })
7052
+ ] }),
7053
+ /* @__PURE__ */ jsx43(
7054
+ "input",
7055
+ {
7056
+ id: "alerta-data",
7057
+ type: "datetime-local",
7058
+ min: hojeDataHoraIso,
7059
+ value: values.dataReferencia,
7060
+ onChange: (e) => setField("dataReferencia", e.target.value),
7061
+ className: "alerta-input alerta-input--sm"
7062
+ }
7063
+ )
7064
+ ] }),
7065
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-campo", children: [
7066
+ /* @__PURE__ */ jsx43("span", { className: "alerta-label", children: "Notifica\xE7\xF5es" }),
7067
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-notif-container", children: [
7068
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-notif-col", children: [
7069
+ /* @__PURE__ */ jsx43(
7070
+ OpcaoAlerta,
7071
+ {
7072
+ checked: values.lembrarNoDia,
7073
+ label: "Alertar no dia",
7074
+ onChange: toggleLembrarNoDia
7075
+ }
7076
+ ),
7077
+ /* @__PURE__ */ jsx43(
7078
+ OpcaoAlerta,
7079
+ {
7080
+ checked: values.alertasDiasAntes.includes("2"),
7081
+ label: "2 dias antes",
7082
+ onChange: (c) => toggleAlertaDiasAntes(2, c)
7083
+ }
7084
+ ),
7085
+ /* @__PURE__ */ jsx43(
7086
+ OpcaoAlerta,
7087
+ {
7088
+ checked: values.alertasDiasAntes.includes("7"),
7089
+ label: "1 semana antes",
7090
+ onChange: (c) => toggleAlertaDiasAntes(7, c)
7091
+ }
7092
+ )
7093
+ ] }),
7094
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-notif-col", children: [
7095
+ /* @__PURE__ */ jsx43(
7096
+ OpcaoAlerta,
7097
+ {
7098
+ checked: values.alertasDiasAntes.includes("15"),
7099
+ label: "15 dias antes",
7100
+ onChange: (c) => toggleAlertaDiasAntes(15, c)
7101
+ }
7102
+ ),
7103
+ /* @__PURE__ */ jsx43(
7104
+ OpcaoAlerta,
7105
+ {
7106
+ checked: values.alertasDiasAntes.includes("30"),
7107
+ label: "1 m\xEAs antes",
7108
+ onChange: (c) => toggleAlertaDiasAntes(30, c)
7109
+ }
7110
+ ),
7111
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-notif-personalizado", children: [
7112
+ /* @__PURE__ */ jsx43(
7113
+ "input",
7114
+ {
7115
+ id: "alerta-dias",
7116
+ type: "number",
7117
+ min: 1,
7118
+ step: 1,
7119
+ value: values.novoAlertaDiasAntes,
7120
+ onChange: (e) => setField("novoAlertaDiasAntes", e.target.value),
7121
+ onKeyDown: (e) => {
7122
+ if (e.key === "Enter") {
7123
+ e.preventDefault();
7124
+ adicionarAlertaDiasAntes();
7125
+ }
7126
+ },
7127
+ placeholder: "Dias",
7128
+ className: "alerta-input alerta-input--dias"
7129
+ }
7130
+ ),
7131
+ /* @__PURE__ */ jsxs34(
7132
+ "button",
7133
+ {
7134
+ type: "button",
7135
+ onClick: adicionarAlertaDiasAntes,
7136
+ className: "alerta-btn alerta-btn--outline",
7137
+ children: [
7138
+ /* @__PURE__ */ jsx43(Plus, { size: 16 }),
7139
+ "Adicionar"
7140
+ ]
7141
+ }
7142
+ )
7143
+ ] })
7144
+ ] }),
7145
+ alertasPersonalizados.length > 0 && /* @__PURE__ */ jsx43("div", { className: "alerta-tags", children: alertasPersonalizados.map((dias) => /* @__PURE__ */ jsxs34("span", { className: "alerta-tag", children: [
7146
+ dias,
7147
+ " dia",
7148
+ Number(dias) > 1 ? "s" : "",
7149
+ " antes",
7150
+ /* @__PURE__ */ jsx43(
7151
+ "button",
7152
+ {
7153
+ type: "button",
7154
+ onClick: () => removerAlertaDiasAntes(dias),
7155
+ "aria-label": `Remover alerta de ${dias} dias antes`,
7156
+ className: "alerta-tag-remover",
7157
+ children: /* @__PURE__ */ jsx43(X, { size: 14 })
7158
+ }
7159
+ )
7160
+ ] }, dias)) })
7161
+ ] })
7162
+ ] }),
7163
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-campo", children: [
7164
+ /* @__PURE__ */ jsx43("label", { htmlFor: "alerta-mensagem", className: "alerta-label", children: "Mensagem" }),
7165
+ /* @__PURE__ */ jsx43(
7166
+ "textarea",
7167
+ {
7168
+ id: "alerta-mensagem",
7169
+ value: values.mensagem,
7170
+ onChange: (e) => setField("mensagem", e.target.value),
7171
+ placeholder: "Informe a mensagem do alerta",
7172
+ rows: 3,
7173
+ className: "alerta-textarea"
7174
+ }
7175
+ )
7176
+ ] }),
7177
+ /* @__PURE__ */ jsx43("div", { className: "alerta-campo", children: /* @__PURE__ */ jsx43(
7178
+ OpcaoAlerta,
7179
+ {
7180
+ checked: values.enviarEmail,
7181
+ label: "Enviar tamb\xE9m por e-mail",
7182
+ onChange: (checked) => setField("enviarEmail", checked)
7183
+ }
7184
+ ) }),
7185
+ erro && /* @__PURE__ */ jsx43("div", { className: "alerta-erro", children: erro }),
7186
+ /* @__PURE__ */ jsxs34("div", { className: "alerta-form-acoes", children: [
7187
+ /* @__PURE__ */ jsx43(
7188
+ "button",
7189
+ {
7190
+ type: "button",
7191
+ onClick: onCancelar,
7192
+ className: "alerta-btn alerta-btn--secundario",
7193
+ children: "Cancelar"
7194
+ }
7195
+ ),
7196
+ /* @__PURE__ */ jsxs34(
7197
+ "button",
7198
+ {
7199
+ type: "button",
7200
+ onClick: handleSalvar,
7201
+ disabled: isSaving,
7202
+ className: "alerta-btn alerta-btn--primario",
7203
+ children: [
7204
+ /* @__PURE__ */ jsx43(Plus, { size: 16 }),
7205
+ isSaving ? "Salvando..." : alertaEmEdicao ? "Atualizar alerta" : "Adicionar alerta"
7206
+ ]
7207
+ }
7208
+ )
7209
+ ] })
7210
+ ] })
7211
+ ] });
7212
+ }
7213
+
7214
+ // src/alertas/alerta-item.tsx
7215
+ import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
7216
+ function AlertaItem({
7217
+ alerta,
7218
+ disabled = false,
7219
+ selecionado = false,
7220
+ onEditar,
7221
+ onConcluir,
7222
+ onExcluir
7223
+ }) {
7224
+ const concluido = alerta.status === "CONCLUIDO";
7225
+ const cancelado = alerta.status === "CANCELADO";
7226
+ const podeAlterar = !concluido && !cancelado;
7227
+ const statusLabel = concluido ? "Concluido" : cancelado ? "Cancelado" : "Pendente";
7228
+ const descricaoAlertas = [
7229
+ alerta.lembrarNoDia ?? alerta.diasAntes === 0 ? "no dia" : null,
7230
+ ...alerta.alertasDiasAntes && alerta.alertasDiasAntes.length > 0 ? alerta.alertasDiasAntes.map(
7231
+ (dias) => `${dias} dia${dias > 1 ? "s" : ""} antes`
7232
+ ) : alerta.diasAntes > 0 ? [`${alerta.diasAntes} dia${alerta.diasAntes > 1 ? "s" : ""} antes`] : []
7233
+ ].filter(Boolean).join(", ");
7234
+ return /* @__PURE__ */ jsx44(
7235
+ "article",
7236
+ {
7237
+ className: [
7238
+ "alerta-item",
7239
+ selecionado ? "alerta-item--selecionado" : "",
7240
+ concluido ? "alerta-item--concluido" : "",
7241
+ cancelado ? "alerta-item--cancelado" : ""
7242
+ ].filter(Boolean).join(" "),
7243
+ children: /* @__PURE__ */ jsxs35("div", { className: "alerta-item-corpo", children: [
7244
+ /* @__PURE__ */ jsxs35("div", { className: "alerta-item-info", children: [
7245
+ /* @__PURE__ */ jsxs35("div", { className: "alerta-item-topo", children: [
7246
+ /* @__PURE__ */ jsx44("h3", { className: "alerta-item-titulo", children: alerta.titulo }),
7247
+ /* @__PURE__ */ jsx44("span", { className: `alerta-status alerta-status--${statusLabel.toLowerCase()}`, children: statusLabel })
7248
+ ] }),
7249
+ alerta.mensagem && /* @__PURE__ */ jsx44("p", { className: "alerta-item-mensagem", children: alerta.mensagem }),
7250
+ /* @__PURE__ */ jsxs35("div", { className: "alerta-item-meta", children: [
7251
+ /* @__PURE__ */ jsxs35("span", { className: "alerta-item-meta-linha", children: [
7252
+ /* @__PURE__ */ jsx44(CalendarDays, { size: 14 }),
7253
+ "Data ",
7254
+ formatarDataParaExibicao(alerta.dataReferencia)
7255
+ ] }),
7256
+ /* @__PURE__ */ jsxs35("span", { className: "alerta-item-meta-linha", children: [
7257
+ /* @__PURE__ */ jsx44(Bell, { size: 14 }),
7258
+ "Notifica\xE7\xF5es: ",
7259
+ descricaoAlertas || "\u2014"
7260
+ ] }),
7261
+ alerta.enviarEmail && /* @__PURE__ */ jsxs35("span", { className: "alerta-item-meta-linha alerta-item-email-ativo", children: [
7262
+ /* @__PURE__ */ jsx44("span", { className: "alerta-dot" }),
7263
+ "Notifica\xE7\xE3o por e-mail ativa"
7264
+ ] }),
7265
+ cancelado && alerta.motivoCancelamento && /* @__PURE__ */ jsxs35("span", { className: "alerta-item-meta-linha", children: [
7266
+ /* @__PURE__ */ jsx44(X, { size: 14 }),
7267
+ "Cancelado automaticamente: ",
7268
+ alerta.motivoCancelamento
7269
+ ] })
7270
+ ] })
7271
+ ] }),
7272
+ /* @__PURE__ */ jsxs35("div", { className: "alerta-item-acoes", children: [
7273
+ /* @__PURE__ */ jsx44(
7274
+ "button",
7275
+ {
7276
+ type: "button",
7277
+ onClick: onEditar,
7278
+ disabled: disabled || !podeAlterar,
7279
+ title: "Editar alerta",
7280
+ className: "alerta-btn-icone",
7281
+ children: /* @__PURE__ */ jsx44(Pencil, { size: 16 })
7282
+ }
7283
+ ),
7284
+ podeAlterar && /* @__PURE__ */ jsx44(
7285
+ "button",
7286
+ {
7287
+ type: "button",
7288
+ onClick: onConcluir,
7289
+ disabled,
7290
+ title: "Concluir alerta",
7291
+ className: "alerta-btn-icone alerta-btn-icone--sucesso",
7292
+ children: /* @__PURE__ */ jsx44(Check, { size: 16 })
7293
+ }
7294
+ ),
7295
+ /* @__PURE__ */ jsx44(
7296
+ "button",
7297
+ {
7298
+ type: "button",
7299
+ onClick: onExcluir,
7300
+ disabled,
7301
+ title: "Excluir alerta",
7302
+ className: "alerta-btn-icone alerta-btn-icone--perigo",
7303
+ children: /* @__PURE__ */ jsx44(Trash2, { size: 16 })
7304
+ }
7305
+ )
7306
+ ] })
7307
+ ] })
7308
+ }
7309
+ );
7310
+ }
7311
+
7312
+ // src/alertas/usar-alertas.ts
7313
+ import * as React31 from "react";
7314
+
7315
+ // src/alertas/cliente.ts
7316
+ var ErroAlertas = class _ErroAlertas extends Error {
7317
+ status;
7318
+ constructor(mensagem, status) {
7319
+ super(mensagem);
7320
+ this.name = "ErroAlertas";
7321
+ this.status = status;
7322
+ Object.setPrototypeOf(this, _ErroAlertas.prototype);
7323
+ }
7324
+ };
7325
+ async function buscarAlertas({
7326
+ baseUrl,
7327
+ sistema,
7328
+ email,
7329
+ fetchFn = fetch,
7330
+ signal,
7331
+ eventoId
7332
+ }) {
7333
+ const params = new URLSearchParams({ sistema, email });
7334
+ if (eventoId !== void 0) params.set("eventoId", String(eventoId));
7335
+ const url = `${normalizarBaseUrl(baseUrl)}/notificacoes?${params.toString()}`;
7336
+ const resposta = await fetchFn(url, {
7337
+ method: "GET",
7338
+ headers: { Accept: "application/json" },
7339
+ signal
7340
+ });
7341
+ if (!resposta.ok) {
7342
+ throw new ErroAlertas(`Falha ao buscar alertas`, resposta.status);
7343
+ }
7344
+ return await resposta.json();
7345
+ }
7346
+
7347
+ // src/alertas/usar-alertas.ts
7348
+ function foiAbortado2(erro) {
7349
+ return erro?.name === "AbortError";
7350
+ }
7351
+ function usarAlertas({
7352
+ baseUrl,
7353
+ sistema,
7354
+ email,
7355
+ fetchFn,
7356
+ eventoId,
7357
+ habilitado = true,
7358
+ onErro
7359
+ }) {
7360
+ const [alertas, setAlertas] = React31.useState([]);
7361
+ const [carregando, setCarregando] = React31.useState(habilitado);
7362
+ const controladorRef = React31.useRef(null);
7363
+ const jaCarregouRef = React31.useRef(false);
7364
+ const onErroRef = React31.useRef(onErro);
7365
+ const fetchFnRef = React31.useRef(fetchFn);
7366
+ React31.useEffect(() => {
7367
+ onErroRef.current = onErro;
7368
+ }, [onErro]);
7369
+ React31.useEffect(() => {
7370
+ fetchFnRef.current = fetchFn;
7371
+ }, [fetchFn]);
7372
+ const pronto = baseUrl !== void 0 && sistema !== void 0 && email !== void 0;
7373
+ const atualizar = React31.useCallback(() => {
7374
+ if (!habilitado || !pronto) return;
7375
+ controladorRef.current?.abort();
7376
+ const controlador = new AbortController();
7377
+ controladorRef.current = controlador;
7378
+ void (async () => {
7379
+ try {
7380
+ const lista = await buscarAlertas({
7381
+ baseUrl,
7382
+ sistema,
7383
+ email,
7384
+ fetchFn: fetchFnRef.current,
7385
+ eventoId,
7386
+ signal: controlador.signal
7387
+ });
7388
+ if (controlador.signal.aborted) return;
7389
+ setAlertas(lista);
7390
+ } catch (erro) {
7391
+ if (controlador.signal.aborted || foiAbortado2(erro)) return;
7392
+ onErroRef.current?.(erro);
7393
+ } finally {
7394
+ if (!controlador.signal.aborted) {
7395
+ jaCarregouRef.current = true;
7396
+ setCarregando(false);
7397
+ }
7398
+ }
7399
+ })();
7400
+ }, [baseUrl, sistema, email, eventoId, habilitado, pronto]);
7401
+ React31.useEffect(() => {
7402
+ if (!habilitado || !pronto) {
7403
+ setCarregando(false);
7404
+ return;
7405
+ }
7406
+ if (!jaCarregouRef.current) setCarregando(true);
7407
+ atualizar();
7408
+ return () => controladorRef.current?.abort();
7409
+ }, [atualizar, habilitado, pronto]);
7410
+ return {
7411
+ alertas,
7412
+ carregando,
7413
+ atualizar
7414
+ };
7415
+ }
7416
+
7417
+ // src/alertas/alertas.tsx
7418
+ import { jsx as jsx45, jsxs as jsxs36 } from "react/jsx-runtime";
7419
+ function Alertas({
7420
+ alertas: alertasProps = [],
7421
+ isLoading = false,
7422
+ isSaving = false,
7423
+ isRemovendo = false,
7424
+ podeCriar = true,
7425
+ onCriar,
7426
+ onAtualizar,
7427
+ onConcluir,
7428
+ onExcluir,
7429
+ baseUrl = URL_PADRAO_NOTIFICACOES,
7430
+ sistema,
7431
+ email,
7432
+ fetchFn,
7433
+ eventoId,
7434
+ onErro
7435
+ }) {
7436
+ const [formAberto, setFormAberto] = React32.useState(false);
7437
+ const [alertaEmEdicao, setAlertaEmEdicao] = React32.useState(null);
7438
+ const [salvandoLocal, setSalvandoLocal] = React32.useState(false);
7439
+ const [removendoLocal, setRemovendoLocal] = React32.useState(false);
7440
+ const conectado = Boolean(sistema && email);
7441
+ const remoto = usarAlertas({
7442
+ baseUrl,
7443
+ sistema,
7444
+ email,
7445
+ fetchFn,
7446
+ eventoId,
7447
+ habilitado: conectado,
7448
+ onErro
7449
+ });
7450
+ const alertas = conectado ? remoto.alertas : alertasProps;
7451
+ const carregando = conectado ? remoto.carregando : isLoading;
7452
+ const salvando = salvandoLocal || isSaving;
7453
+ const removendo = removendoLocal || isRemovendo;
7454
+ const resetForm = () => {
7455
+ setFormAberto(false);
7456
+ setAlertaEmEdicao(null);
7457
+ };
7458
+ const abrirNovoAlerta = () => {
7459
+ setAlertaEmEdicao(null);
7460
+ setFormAberto(true);
7461
+ };
7462
+ const abrirEdicao = (alerta) => {
7463
+ setAlertaEmEdicao(alerta);
7464
+ setFormAberto(true);
7465
+ };
7466
+ const handleSalvar = async (payload) => {
7467
+ setSalvandoLocal(true);
7468
+ try {
7469
+ if (alertaEmEdicao) {
7470
+ await onAtualizar?.(alertaEmEdicao.id, payload);
7471
+ } else {
7472
+ await onCriar?.(payload);
7473
+ }
7474
+ if (conectado) remoto.atualizar();
7475
+ resetForm();
7476
+ } catch (err) {
7477
+ console.error("Erro ao salvar alerta:", err);
7478
+ onErro?.(err);
7479
+ } finally {
7480
+ setSalvandoLocal(false);
7481
+ }
7482
+ };
7483
+ const handleConcluir = async (alertaId) => {
7484
+ setRemovendoLocal(true);
7485
+ try {
7486
+ await onConcluir?.(alertaId);
7487
+ if (conectado) remoto.atualizar();
7488
+ } catch (err) {
7489
+ console.error("Erro ao concluir alerta:", err);
7490
+ onErro?.(err);
7491
+ } finally {
7492
+ setRemovendoLocal(false);
7493
+ }
7494
+ };
7495
+ const handleExcluir = (alerta) => {
7496
+ if (!window.confirm(`Tem certeza que deseja excluir o alerta "${alerta.titulo}"?`)) return;
7497
+ void (async () => {
7498
+ setRemovendoLocal(true);
7499
+ try {
7500
+ await onExcluir?.(alerta);
7501
+ if (conectado) remoto.atualizar();
7502
+ } catch (err) {
7503
+ console.error("Erro ao excluir alerta:", err);
7504
+ onErro?.(err);
7505
+ } finally {
7506
+ setRemovendoLocal(false);
7507
+ }
7508
+ })();
7509
+ };
7510
+ return /* @__PURE__ */ jsxs36("div", { className: "alertas-container", children: [
7511
+ !formAberto && podeCriar && /* @__PURE__ */ jsx45("div", { className: "alertas-nova-acao", children: /* @__PURE__ */ jsxs36(
7512
+ "button",
7513
+ {
7514
+ type: "button",
7515
+ onClick: abrirNovoAlerta,
7516
+ className: "alerta-btn alerta-btn--primario",
7517
+ children: [
7518
+ /* @__PURE__ */ jsx45(Plus, { size: 16 }),
7519
+ "Novo alerta"
7520
+ ]
7521
+ }
7522
+ ) }),
7523
+ formAberto && /* @__PURE__ */ jsx45(
7524
+ FormularioAlerta,
7525
+ {
7526
+ alertaEmEdicao,
7527
+ isSaving: salvando,
7528
+ onSalvar: handleSalvar,
7529
+ onCancelar: resetForm
7530
+ }
7531
+ ),
7532
+ /* @__PURE__ */ jsxs36("section", { className: "alertas-lista-section", children: [
7533
+ /* @__PURE__ */ jsx45("div", { className: "alertas-lista-header", children: /* @__PURE__ */ jsxs36("h2", { className: "alertas-lista-titulo", children: [
7534
+ "Alertas cadastrados (",
7535
+ alertas.length,
7536
+ ")"
7537
+ ] }) }),
7538
+ carregando ? /* @__PURE__ */ jsx45("div", { className: "alertas-estado", children: "Carregando alertas..." }) : alertas.length === 0 ? /* @__PURE__ */ jsxs36("div", { className: "alertas-vazio", children: [
7539
+ /* @__PURE__ */ jsx45(Bell, { size: 32, className: "alertas-vazio-icone" }),
7540
+ /* @__PURE__ */ jsx45("p", { className: "alertas-vazio-texto", children: "Nenhum alerta cadastrado." })
7541
+ ] }) : /* @__PURE__ */ jsx45("div", { className: "alertas-lista", children: alertas.map((alerta) => /* @__PURE__ */ jsx45(
7542
+ AlertaItem,
7543
+ {
7544
+ alerta,
7545
+ disabled: removendo,
7546
+ selecionado: alertaEmEdicao?.id === alerta.id,
7547
+ onEditar: () => abrirEdicao(alerta),
7548
+ onConcluir: () => handleConcluir(alerta.id),
7549
+ onExcluir: () => handleExcluir(alerta)
7550
+ },
7551
+ alerta.id
7552
+ )) })
7553
+ ] })
7554
+ ] });
7555
+ }
6783
7556
  export {
7557
+ AlertaItem,
7558
+ Alertas,
6784
7559
  AplicationsHeader,
6785
7560
  AppsMenu,
6786
7561
  Avatar,
@@ -6848,10 +7623,12 @@ export {
6848
7623
  DropdownMenuSubTrigger,
6849
7624
  DropdownMenuTrigger,
6850
7625
  EmptyState,
7626
+ ErroAlertas,
6851
7627
  ErroNotificacoes,
6852
7628
  FileList,
6853
7629
  FileUpload,
6854
7630
  Filter,
7631
+ FormularioAlerta,
6855
7632
  Header,
6856
7633
  HeaderContainer,
6857
7634
  HeaderNotifications,
@@ -6904,14 +7681,17 @@ export {
6904
7681
  URL_PADRAO_NOTIFICACOES,
6905
7682
  availableApps,
6906
7683
  buildMonthDays,
7684
+ buscarAlertas,
6907
7685
  buttonVariants,
6908
7686
  formatDayAriaLabel,
6909
7687
  formatFileSize,
6910
7688
  formatMonthYear,
6911
7689
  isSameDay,
6912
7690
  isToday,
7691
+ normalizarBaseUrl,
6913
7692
  toDateKey,
6914
7693
  toLocalNoon,
7694
+ usarAlertas,
6915
7695
  useDrawer,
6916
7696
  validateFiles
6917
7697
  };
@@ -6973,6 +7753,14 @@ lucide-react/dist/esm/icons/bell.js:
6973
7753
  * See the LICENSE file in the root directory of this source tree.
6974
7754
  *)
6975
7755
 
7756
+ lucide-react/dist/esm/icons/calendar-days.js:
7757
+ (**
7758
+ * @license lucide-react v0.453.0 - ISC
7759
+ *
7760
+ * This source code is licensed under the ISC license.
7761
+ * See the LICENSE file in the root directory of this source tree.
7762
+ *)
7763
+
6976
7764
  lucide-react/dist/esm/icons/check.js:
6977
7765
  (**
6978
7766
  * @license lucide-react v0.453.0 - ISC
@@ -7109,6 +7897,14 @@ lucide-react/dist/esm/icons/paperclip.js:
7109
7897
  * See the LICENSE file in the root directory of this source tree.
7110
7898
  *)
7111
7899
 
7900
+ lucide-react/dist/esm/icons/pencil.js:
7901
+ (**
7902
+ * @license lucide-react v0.453.0 - ISC
7903
+ *
7904
+ * This source code is licensed under the ISC license.
7905
+ * See the LICENSE file in the root directory of this source tree.
7906
+ *)
7907
+
7112
7908
  lucide-react/dist/esm/icons/plus.js:
7113
7909
  (**
7114
7910
  * @license lucide-react v0.453.0 - ISC