@cnc-ti/layout-basic 8.6.0 → 8.8.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,769 @@ 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
+ filtros
7333
+ }) {
7334
+ const params = new URLSearchParams({ sistema, email });
7335
+ if (eventoId !== void 0) params.set("eventoId", String(eventoId));
7336
+ for (const [chave, valor] of Object.entries(filtros ?? {})) {
7337
+ if (valor !== void 0 && valor !== null && valor !== "") params.set(chave, String(valor));
7338
+ }
7339
+ const url = `${normalizarBaseUrl(baseUrl)}/notificacoes?${params.toString()}`;
7340
+ const resposta = await fetchFn(url, {
7341
+ method: "GET",
7342
+ headers: { Accept: "application/json" },
7343
+ signal
7344
+ });
7345
+ if (!resposta.ok) {
7346
+ throw new ErroAlertas(`Falha ao buscar alertas`, resposta.status);
7347
+ }
7348
+ return await resposta.json();
7349
+ }
7350
+
7351
+ // src/alertas/usar-alertas.ts
7352
+ function foiAbortado2(erro) {
7353
+ return erro?.name === "AbortError";
7354
+ }
7355
+ function usarAlertas({
7356
+ baseUrl,
7357
+ sistema,
7358
+ email,
7359
+ fetchFn,
7360
+ eventoId,
7361
+ filtros,
7362
+ habilitado = true,
7363
+ onErro
7364
+ }) {
7365
+ const [alertas, setAlertas] = React31.useState([]);
7366
+ const [carregando, setCarregando] = React31.useState(habilitado);
7367
+ const controladorRef = React31.useRef(null);
7368
+ const jaCarregouRef = React31.useRef(false);
7369
+ const onErroRef = React31.useRef(onErro);
7370
+ const fetchFnRef = React31.useRef(fetchFn);
7371
+ const filtrosRef = React31.useRef(filtros);
7372
+ React31.useEffect(() => {
7373
+ onErroRef.current = onErro;
7374
+ }, [onErro]);
7375
+ React31.useEffect(() => {
7376
+ fetchFnRef.current = fetchFn;
7377
+ }, [fetchFn]);
7378
+ React31.useEffect(() => {
7379
+ filtrosRef.current = filtros;
7380
+ }, [filtros]);
7381
+ const pronto = baseUrl !== void 0 && sistema !== void 0 && email !== void 0;
7382
+ const filtrosChave = filtros ? JSON.stringify(filtros) : "";
7383
+ const atualizar = React31.useCallback(() => {
7384
+ if (!habilitado || !pronto) return;
7385
+ controladorRef.current?.abort();
7386
+ const controlador = new AbortController();
7387
+ controladorRef.current = controlador;
7388
+ void (async () => {
7389
+ try {
7390
+ const lista = await buscarAlertas({
7391
+ baseUrl,
7392
+ sistema,
7393
+ email,
7394
+ fetchFn: fetchFnRef.current,
7395
+ eventoId,
7396
+ filtros: filtrosRef.current,
7397
+ signal: controlador.signal
7398
+ });
7399
+ if (controlador.signal.aborted) return;
7400
+ setAlertas(lista);
7401
+ } catch (erro) {
7402
+ if (controlador.signal.aborted || foiAbortado2(erro)) return;
7403
+ onErroRef.current?.(erro);
7404
+ } finally {
7405
+ if (!controlador.signal.aborted) {
7406
+ jaCarregouRef.current = true;
7407
+ setCarregando(false);
7408
+ }
7409
+ }
7410
+ })();
7411
+ }, [baseUrl, sistema, email, eventoId, filtrosChave, habilitado, pronto]);
7412
+ React31.useEffect(() => {
7413
+ if (!habilitado || !pronto) {
7414
+ setCarregando(false);
7415
+ return;
7416
+ }
7417
+ if (!jaCarregouRef.current) setCarregando(true);
7418
+ atualizar();
7419
+ return () => controladorRef.current?.abort();
7420
+ }, [atualizar, habilitado, pronto]);
7421
+ return {
7422
+ alertas,
7423
+ carregando,
7424
+ atualizar
7425
+ };
7426
+ }
7427
+
7428
+ // src/alertas/alertas.tsx
7429
+ import { jsx as jsx45, jsxs as jsxs36 } from "react/jsx-runtime";
7430
+ function Alertas({
7431
+ alertas: alertasProps = [],
7432
+ isLoading = false,
7433
+ isSaving = false,
7434
+ isRemovendo = false,
7435
+ podeCriar = true,
7436
+ onCriar,
7437
+ onAtualizar,
7438
+ onConcluir,
7439
+ onExcluir,
7440
+ baseUrl = URL_PADRAO_NOTIFICACOES,
7441
+ sistema,
7442
+ email,
7443
+ fetchFn,
7444
+ eventoId,
7445
+ filtros,
7446
+ onErro
7447
+ }) {
7448
+ const [formAberto, setFormAberto] = React32.useState(false);
7449
+ const [alertaEmEdicao, setAlertaEmEdicao] = React32.useState(null);
7450
+ const [salvandoLocal, setSalvandoLocal] = React32.useState(false);
7451
+ const [removendoLocal, setRemovendoLocal] = React32.useState(false);
7452
+ const conectado = Boolean(sistema && email);
7453
+ const remoto = usarAlertas({
7454
+ baseUrl,
7455
+ sistema,
7456
+ email,
7457
+ fetchFn,
7458
+ eventoId,
7459
+ filtros,
7460
+ habilitado: conectado,
7461
+ onErro
7462
+ });
7463
+ const alertas = conectado ? remoto.alertas : alertasProps;
7464
+ const carregando = conectado ? remoto.carregando : isLoading;
7465
+ const salvando = salvandoLocal || isSaving;
7466
+ const removendo = removendoLocal || isRemovendo;
7467
+ const resetForm = () => {
7468
+ setFormAberto(false);
7469
+ setAlertaEmEdicao(null);
7470
+ };
7471
+ const abrirNovoAlerta = () => {
7472
+ setAlertaEmEdicao(null);
7473
+ setFormAberto(true);
7474
+ };
7475
+ const abrirEdicao = (alerta) => {
7476
+ setAlertaEmEdicao(alerta);
7477
+ setFormAberto(true);
7478
+ };
7479
+ const handleSalvar = async (payload) => {
7480
+ setSalvandoLocal(true);
7481
+ try {
7482
+ if (alertaEmEdicao) {
7483
+ await onAtualizar?.(alertaEmEdicao.id, payload);
7484
+ } else {
7485
+ await onCriar?.(payload);
7486
+ }
7487
+ if (conectado) remoto.atualizar();
7488
+ resetForm();
7489
+ } catch (err) {
7490
+ console.error("Erro ao salvar alerta:", err);
7491
+ onErro?.(err);
7492
+ } finally {
7493
+ setSalvandoLocal(false);
7494
+ }
7495
+ };
7496
+ const handleConcluir = async (alertaId) => {
7497
+ setRemovendoLocal(true);
7498
+ try {
7499
+ await onConcluir?.(alertaId);
7500
+ if (conectado) remoto.atualizar();
7501
+ } catch (err) {
7502
+ console.error("Erro ao concluir alerta:", err);
7503
+ onErro?.(err);
7504
+ } finally {
7505
+ setRemovendoLocal(false);
7506
+ }
7507
+ };
7508
+ const handleExcluir = (alerta) => {
7509
+ if (!window.confirm(`Tem certeza que deseja excluir o alerta "${alerta.titulo}"?`)) return;
7510
+ void (async () => {
7511
+ setRemovendoLocal(true);
7512
+ try {
7513
+ await onExcluir?.(alerta);
7514
+ if (conectado) remoto.atualizar();
7515
+ } catch (err) {
7516
+ console.error("Erro ao excluir alerta:", err);
7517
+ onErro?.(err);
7518
+ } finally {
7519
+ setRemovendoLocal(false);
7520
+ }
7521
+ })();
7522
+ };
7523
+ return /* @__PURE__ */ jsxs36("div", { className: "alertas-container", children: [
7524
+ !formAberto && podeCriar && /* @__PURE__ */ jsx45("div", { className: "alertas-nova-acao", children: /* @__PURE__ */ jsxs36(
7525
+ "button",
7526
+ {
7527
+ type: "button",
7528
+ onClick: abrirNovoAlerta,
7529
+ className: "alerta-btn alerta-btn--primario",
7530
+ children: [
7531
+ /* @__PURE__ */ jsx45(Plus, { size: 16 }),
7532
+ "Novo alerta"
7533
+ ]
7534
+ }
7535
+ ) }),
7536
+ formAberto && /* @__PURE__ */ jsx45(
7537
+ FormularioAlerta,
7538
+ {
7539
+ alertaEmEdicao,
7540
+ isSaving: salvando,
7541
+ onSalvar: handleSalvar,
7542
+ onCancelar: resetForm
7543
+ }
7544
+ ),
7545
+ /* @__PURE__ */ jsxs36("section", { className: "alertas-lista-section", children: [
7546
+ /* @__PURE__ */ jsx45("div", { className: "alertas-lista-header", children: /* @__PURE__ */ jsxs36("h2", { className: "alertas-lista-titulo", children: [
7547
+ "Alertas cadastrados (",
7548
+ alertas.length,
7549
+ ")"
7550
+ ] }) }),
7551
+ carregando ? /* @__PURE__ */ jsx45("div", { className: "alertas-estado", children: "Carregando alertas..." }) : alertas.length === 0 ? /* @__PURE__ */ jsxs36("div", { className: "alertas-vazio", children: [
7552
+ /* @__PURE__ */ jsx45(Bell, { size: 32, className: "alertas-vazio-icone" }),
7553
+ /* @__PURE__ */ jsx45("p", { className: "alertas-vazio-texto", children: "Nenhum alerta cadastrado." })
7554
+ ] }) : /* @__PURE__ */ jsx45("div", { className: "alertas-lista", children: alertas.map((alerta) => /* @__PURE__ */ jsx45(
7555
+ AlertaItem,
7556
+ {
7557
+ alerta,
7558
+ disabled: removendo,
7559
+ selecionado: alertaEmEdicao?.id === alerta.id,
7560
+ onEditar: () => abrirEdicao(alerta),
7561
+ onConcluir: () => handleConcluir(alerta.id),
7562
+ onExcluir: () => handleExcluir(alerta)
7563
+ },
7564
+ alerta.id
7565
+ )) })
7566
+ ] })
7567
+ ] });
7568
+ }
6783
7569
  export {
7570
+ AlertaItem,
7571
+ Alertas,
6784
7572
  AplicationsHeader,
6785
7573
  AppsMenu,
6786
7574
  Avatar,
@@ -6848,10 +7636,12 @@ export {
6848
7636
  DropdownMenuSubTrigger,
6849
7637
  DropdownMenuTrigger,
6850
7638
  EmptyState,
7639
+ ErroAlertas,
6851
7640
  ErroNotificacoes,
6852
7641
  FileList,
6853
7642
  FileUpload,
6854
7643
  Filter,
7644
+ FormularioAlerta,
6855
7645
  Header,
6856
7646
  HeaderContainer,
6857
7647
  HeaderNotifications,
@@ -6904,14 +7694,17 @@ export {
6904
7694
  URL_PADRAO_NOTIFICACOES,
6905
7695
  availableApps,
6906
7696
  buildMonthDays,
7697
+ buscarAlertas,
6907
7698
  buttonVariants,
6908
7699
  formatDayAriaLabel,
6909
7700
  formatFileSize,
6910
7701
  formatMonthYear,
6911
7702
  isSameDay,
6912
7703
  isToday,
7704
+ normalizarBaseUrl,
6913
7705
  toDateKey,
6914
7706
  toLocalNoon,
7707
+ usarAlertas,
6915
7708
  useDrawer,
6916
7709
  validateFiles
6917
7710
  };
@@ -6973,6 +7766,14 @@ lucide-react/dist/esm/icons/bell.js:
6973
7766
  * See the LICENSE file in the root directory of this source tree.
6974
7767
  *)
6975
7768
 
7769
+ lucide-react/dist/esm/icons/calendar-days.js:
7770
+ (**
7771
+ * @license lucide-react v0.453.0 - ISC
7772
+ *
7773
+ * This source code is licensed under the ISC license.
7774
+ * See the LICENSE file in the root directory of this source tree.
7775
+ *)
7776
+
6976
7777
  lucide-react/dist/esm/icons/check.js:
6977
7778
  (**
6978
7779
  * @license lucide-react v0.453.0 - ISC
@@ -7109,6 +7910,14 @@ lucide-react/dist/esm/icons/paperclip.js:
7109
7910
  * See the LICENSE file in the root directory of this source tree.
7110
7911
  *)
7111
7912
 
7913
+ lucide-react/dist/esm/icons/pencil.js:
7914
+ (**
7915
+ * @license lucide-react v0.453.0 - ISC
7916
+ *
7917
+ * This source code is licensed under the ISC license.
7918
+ * See the LICENSE file in the root directory of this source tree.
7919
+ *)
7920
+
7112
7921
  lucide-react/dist/esm/icons/plus.js:
7113
7922
  (**
7114
7923
  * @license lucide-react v0.453.0 - ISC