@selectwin/kit 0.1.262 → 0.1.264

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.
Files changed (65) hide show
  1. package/README.md +74 -0
  2. package/dist/SelectActionMenu.d.ts +7 -1
  3. package/dist/SelectActionMenu.js +14 -13
  4. package/dist/SelectBlockBuilder.d.ts +63 -0
  5. package/dist/SelectBlockBuilder.js +370 -0
  6. package/dist/SelectCalendar.d.ts +68 -4
  7. package/dist/SelectCalendar.js +449 -279
  8. package/dist/SelectChannelPreview.d.ts +34 -5
  9. package/dist/SelectChannelPreview.js +167 -73
  10. package/dist/SelectChartCard.d.ts +13 -0
  11. package/dist/SelectChartCard.js +50 -30
  12. package/dist/SelectCombobox.d.ts +5 -0
  13. package/dist/SelectCombobox.js +77 -61
  14. package/dist/SelectConversationContext.d.ts +30 -0
  15. package/dist/SelectConversationContext.js +141 -0
  16. package/dist/SelectDatePicker.d.ts +4 -0
  17. package/dist/SelectDatePicker.js +78 -62
  18. package/dist/SelectDateRangeField.d.ts +6 -1
  19. package/dist/SelectDateRangeField.js +9 -8
  20. package/dist/SelectField.d.ts +7 -3
  21. package/dist/SelectField.js +71 -70
  22. package/dist/SelectFilterBar.d.ts +9 -0
  23. package/dist/SelectFilterBar.js +301 -179
  24. package/dist/SelectFunnel.d.ts +12 -2
  25. package/dist/SelectFunnel.js +193 -63
  26. package/dist/SelectHorizontalBar.d.ts +11 -1
  27. package/dist/SelectHorizontalBar.js +86 -35
  28. package/dist/SelectHtmlFrame.d.ts +3 -1
  29. package/dist/SelectHtmlFrame.js +4 -4
  30. package/dist/SelectIconButton.d.ts +2 -1
  31. package/dist/SelectIconButton.js +1 -1
  32. package/dist/SelectLocale.d.ts +146 -0
  33. package/dist/SelectLocale.js +363 -31
  34. package/dist/SelectMail.d.ts +80 -4
  35. package/dist/SelectMail.js +433 -300
  36. package/dist/SelectMailEditor.d.ts +35 -1
  37. package/dist/SelectMailEditor.js +347 -163
  38. package/dist/SelectNumberedList.d.ts +20 -2
  39. package/dist/SelectNumberedList.js +75 -17
  40. package/dist/SelectPopover.js +31 -18
  41. package/dist/SelectProgressBar.d.ts +22 -5
  42. package/dist/SelectProgressBar.js +70 -40
  43. package/dist/SelectRecordCard.d.ts +13 -4
  44. package/dist/SelectRecordCard.js +30 -8
  45. package/dist/SelectRuleBuilder.d.ts +52 -0
  46. package/dist/SelectRuleBuilder.js +157 -0
  47. package/dist/SelectSearchPreview.d.ts +35 -0
  48. package/dist/SelectSearchPreview.js +69 -0
  49. package/dist/SelectSegmented.d.ts +2 -0
  50. package/dist/SelectSegmented.js +1 -1
  51. package/dist/SelectSortable.d.ts +5 -1
  52. package/dist/SelectSparkBars.d.ts +5 -1
  53. package/dist/SelectSparkBars.js +65 -57
  54. package/dist/SelectSteps.d.ts +6 -0
  55. package/dist/SelectSteps.js +43 -10
  56. package/dist/SelectTabs.d.ts +16 -4
  57. package/dist/SelectTabs.js +95 -60
  58. package/dist/SelectTextarea.d.ts +1 -1
  59. package/dist/SelectVoiceNote.d.ts +6 -1
  60. package/dist/SelectVoiceNote.js +118 -106
  61. package/dist/chartUtils.d.ts +10 -0
  62. package/dist/index.d.ts +18 -2
  63. package/dist/index.js +153 -149
  64. package/dist/style.css +1 -1
  65. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  /** Um texto (o modelo, o rascunho antigo) no HTML do editor: um parágrafo por bloco, as quebras simples como `<br>`. */
2
3
  export declare function mailTextToHtml(text: string): string;
3
4
  /**
@@ -5,6 +6,17 @@ export declare function mailTextToHtml(text: string): string;
5
6
  * Nada de `javascript:`, `data:` ou caminho relativo.
6
7
  */
7
8
  export declare function mailLinkHref(raw: string): string | null;
9
+ /** 0.1.263: as fichas do editor — o nome de cada caminho, o padrão do dado no texto (padrão `SELECT_TOKEN_PATTERN`). */
10
+ export interface SelectMailEditorTokens {
11
+ labelOf: (path: string) => string;
12
+ pattern?: RegExp;
13
+ }
14
+ /** O que a `ref` do editor expõe (0.1.263). */
15
+ export interface SelectMailEditorHandle {
16
+ /** Põe a ficha do `caminho` no cursor (ou no fim) e devolve o foco ao editor. `raw` troca o `{caminho}` que vai no valor. */
17
+ insertToken: (path: string, raw?: string) => void;
18
+ focus: () => void;
19
+ }
8
20
  export interface SelectMailEditorProps {
9
21
  /** O HTML: o que o próprio editor entregou, ou `mailTextToHtml` de um texto. */
10
22
  value: string;
@@ -13,5 +25,27 @@ export interface SelectMailEditorProps {
13
25
  'aria-label'?: string;
14
26
  /** Na janela (`dock`) a área começa mais alta. */
15
27
  size?: 'inline' | 'dock';
28
+ /** 0.1.263: o cabeçalho da marca, em cima, fora da área que se edita (o logo ou o nome). */
29
+ header?: ReactNode;
30
+ /** 0.1.263: o rodapé legal, embaixo, fora da área que se edita. */
31
+ footer?: ReactNode;
32
+ /** 0.1.263: o automático — o rodapé leva o "Não quero mais receber estes e-mails", fixo (ou o texto dado). */
33
+ unsubscribe?: boolean | ReactNode;
34
+ /** 0.1.263: a cor da marca no filete do cabeçalho (padrão: o primário). */
35
+ brandColor?: string;
36
+ /** 0.1.263: a assinatura, embaixo do corpo, só para ler. */
37
+ signature?: ReactNode;
38
+ /** 0.1.263: as fichas das variáveis (`labelOf`, `pattern`). Sem elas, o `{caminho}` fica texto. */
39
+ tokens?: SelectMailEditorTokens | null;
40
+ /** 0.1.263: os caminhos que não existem mais (a ficha no tom do erro). */
41
+ invalidTokens?: readonly string[];
42
+ /** 0.1.263: a frase do erro, embaixo, com a moldura no vermelho ("A variável … não existe…"). */
43
+ error?: ReactNode;
44
+ /** 0.1.263: a moldura (a borda e o canto) sem o cabeçalho e o rodapé. Com eles, ela vem sozinha. */
45
+ framed?: boolean;
46
+ /** 0.1.263: onde fica a barra — `bottom` (o padrão, o de antes) ou `top` (em cima da moldura, como na prancha). */
47
+ toolbar?: 'bottom' | 'top';
48
+ /** 0.1.263: as ferramentas do app, no fim da barra ("Inserir variável", "Marca", "Assinatura"). */
49
+ tools?: ReactNode;
16
50
  }
17
- export declare function SelectMailEditor({ value, onChange, placeholder, 'aria-label': ariaLabel, size }: SelectMailEditorProps): import("react").JSX.Element;
51
+ export declare const SelectMailEditor: import('react').ForwardRefExoticComponent<SelectMailEditorProps & import('react').RefAttributes<SelectMailEditorHandle>>;
@@ -1,15 +1,18 @@
1
1
  /* empty css */
2
- import { ClearFormatIcon as e, LinkIcon as t, ListBulletIcon as n, ListNumberIcon as r, TextBoldIcon as i, TextItalicIcon as a, TextQuoteIcon as o, TextStrikeIcon as s, TextUnderlineIcon as c } from "./icons.js";
3
- import { SelectTooltip as l } from "./SelectTooltip.js";
4
- import { SelectPopover as u } from "./SelectPopover.js";
5
- import { useEffect as d, useLayoutEffect as f, useRef as p, useState as m } from "react";
6
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
2
+ import { ClearFormatIcon as e, LinkIcon as t, ListBulletIcon as n, ListNumberIcon as r, TextBoldIcon as i, TextItalicIcon as a, TextQuoteIcon as o, TextStrikeIcon as ee, TextUnderlineIcon as te, WarningIcon as ne } from "./icons.js";
3
+ import { SelectTooltip as re } from "./SelectTooltip.js";
4
+ import { useSelectMessages as ie } from "./SelectLocale.js";
5
+ import { SelectPopover as ae } from "./SelectPopover.js";
6
+ import { watchTrackOverflow as oe } from "./internal/scrollReveal.js";
7
+ import { SELECT_TOKEN_PATTERN as se } from "./SelectTokenTextarea.js";
8
+ import { forwardRef as s, useEffect as ce, useImperativeHandle as le, useLayoutEffect as c, useRef as l, useState as u } from "react";
9
+ import { Fragment as ue, jsx as d, jsxs as f } from "react/jsx-runtime";
7
10
  //#region src/SelectMailEditor.tsx
8
- var _ = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
9
- function v(e) {
10
- return e.replace(/\r\n?/g, "\n").split(/\n{2,}/).filter((e, t) => e.length > 0 || t === 0).map((e) => `<p>${e ? _(e).replace(/\n/g, "<br>") : "<br>"}</p>`).join("");
11
+ var p = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
12
+ function de(e) {
13
+ return e.replace(/\r\n?/g, "\n").split(/\n{2,}/).filter((e, t) => e.length > 0 || t === 0).map((e) => `<p>${e ? p(e).replace(/\n/g, "<br>") : "<br>"}</p>`).join("");
11
14
  }
12
- function y(e) {
15
+ function fe(e) {
13
16
  let t = e.trim();
14
17
  if (!t || /\s/.test(t)) return null;
15
18
  if (/^(https?:\/\/|mailto:)/i.test(t)) try {
@@ -20,22 +23,22 @@ function y(e) {
20
23
  }
21
24
  return /^[^@/:]+@[^@/:]+\.[a-z]{2,}$/i.test(t) ? `mailto:${t}` : /^[a-z0-9-]+(\.[a-z0-9-]+)+(\/\S*)?$/i.test(t) ? `https://${t}` : null;
22
25
  }
23
- function b(e, t) {
26
+ function m(e, t) {
24
27
  try {
25
28
  typeof document.execCommand == "function" && document.execCommand(e, !1, t);
26
29
  } catch {}
27
30
  }
28
- function x(e) {
31
+ function h(e) {
29
32
  try {
30
33
  return typeof document.queryCommandState == "function" && document.queryCommandState(e);
31
34
  } catch {
32
35
  return !1;
33
36
  }
34
37
  }
35
- function S(e) {
36
- return (typeof e.innerText == "string" && e.innerText !== "" ? e.innerText : e.textContent ?? "").replace(/ /g, " ").replace(/\n{3,}/g, "\n\n").trim();
38
+ function pe(e) {
39
+ return (typeof e.innerText == "string" && e.innerText !== "" ? e.innerText : e.textContent ?? "").replace(/ /g, " ").replace(/\n{3,}/g, "\n\n").trim();
37
40
  }
38
- function C(e, t) {
41
+ function g(e, t) {
39
42
  let n = document.getSelection(), r = n && n.rangeCount ? n.getRangeAt(0).startContainer : null;
40
43
  for (; r && r !== e;) {
41
44
  if (r instanceof HTMLElement && r.tagName.toLowerCase() === t) return r;
@@ -43,182 +46,363 @@ function C(e, t) {
43
46
  }
44
47
  return null;
45
48
  }
46
- function w({ value: v, onChange: w, placeholder: T, "aria-label": E = "Mensagem", size: D = "inline" }) {
47
- let O = p(null), k = p(null), A = p(null), [j, M] = m(!0), [N, P] = m({}), [F, I] = m(!1), [L, R] = m(""), [z, B] = m("");
48
- f(() => {
49
- let e = O.current;
50
- e && v !== k.current && (e.innerHTML = v, k.current = v, M(S(e) === "" && !e.querySelector("li, blockquote")));
51
- }, [v]);
52
- let V = () => {
53
- let e = O.current;
49
+ var _ = "select-token";
50
+ function v(e) {
51
+ return new RegExp(e.source, e.flags.includes("g") ? e.flags : e.flags + "g");
52
+ }
53
+ function me(e, t, n, r, i) {
54
+ let a = document.createElement("span");
55
+ return a.className = `${_}${r ? ` ${_}--invalid` : ""}`, a.setAttribute("contenteditable", "false"), a.dataset.token = t, a.dataset.raw = e, he(a, n, r, i), a;
56
+ }
57
+ function he(e, t, n, r) {
58
+ if (e.classList.toggle(`${_}--invalid`, n), e.textContent = t, n) {
59
+ let t = document.createElement("span");
60
+ t.className = "select-visually-hidden", t.textContent = ` (${r})`, e.appendChild(t);
61
+ }
62
+ }
63
+ function y(e, t, n) {
64
+ let r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT), i = [];
65
+ for (let e = r.nextNode(); e; e = r.nextNode()) e.parentElement && e.parentElement.closest(`.${_}`) || i.push(e);
66
+ let a = v(t);
67
+ for (let e of i) {
68
+ let t = e.nodeValue ?? "";
69
+ if (a.lastIndex = 0, !a.test(t)) continue;
70
+ a.lastIndex = 0;
71
+ let r = document.createDocumentFragment(), i = 0;
72
+ for (let e of t.matchAll(a)) {
73
+ let a = e.index ?? 0;
74
+ a > i && r.appendChild(document.createTextNode(t.slice(i, a))), r.appendChild(n(e[0], e[1] ?? "")), i = a + e[0].length;
75
+ }
76
+ i < t.length && r.appendChild(document.createTextNode(t.slice(i))), e.replaceWith(r);
77
+ }
78
+ }
79
+ function ge(e) {
80
+ if (!e.querySelector(`.${_}`)) return e.innerHTML;
81
+ let t = e.cloneNode(!0);
82
+ return t.querySelectorAll(`.${_}`).forEach((e) => e.replaceWith(document.createTextNode(e.dataset.raw ?? ""))), t.innerHTML;
83
+ }
84
+ function _e(e) {
85
+ let t = "", n = (e) => {
86
+ if (!t) return;
87
+ let n = t.length - t.replace(/\n+$/, "").length;
88
+ n < e && (t += "\n".repeat(e - n));
89
+ }, r = (e) => {
90
+ e.childNodes.forEach((e) => {
91
+ if (e.nodeType === Node.TEXT_NODE) {
92
+ t += (e.nodeValue ?? "").replace(/\n/g, " ");
93
+ return;
94
+ }
95
+ if (!(e instanceof HTMLElement)) return;
96
+ if (e.dataset.raw != null) {
97
+ t += e.dataset.raw;
98
+ return;
99
+ }
100
+ let i = e.tagName;
101
+ if (i === "BR") {
102
+ t += "\n";
103
+ return;
104
+ }
105
+ let a = i === "P" ? 2 : +!!/^(DIV|LI|UL|OL|BLOCKQUOTE|H[1-6])$/.test(i);
106
+ a && n(a), r(e), a && n(a);
107
+ });
108
+ };
109
+ return r(e), t.replace(/ /g, " ").replace(/\n{3,}/g, "\n\n").trim();
110
+ }
111
+ var b = s(function({ value: s, onChange: de, placeholder: v, "aria-label": b = "Mensagem", size: ve = "inline", header: x, footer: S, unsubscribe: C, brandColor: w, signature: T, tokens: E, invalidTokens: D, error: O, framed: ye, toolbar: k = "bottom", tools: A }, be) {
112
+ let j = ie().mailEditor, M = l(null), N = l(null), P = l(null), F = l(null), I = l(null), [xe, Se] = u(!0), [L, Ce] = u({}), [R, z] = u(!1), [B, V] = u(""), [H, U] = u(""), W = l(E);
113
+ W.current = E;
114
+ let we = (D ?? []).join("\0"), G = l(new Set(D ?? []));
115
+ G.current = new Set(D ?? []);
116
+ let K = l(j.missing);
117
+ K.current = j.missing;
118
+ let q = (e, t) => {
119
+ let n = W.current;
120
+ return me(e, t, n ? n.labelOf(t) : t, G.current.has(t), K.current);
121
+ }, Te = (e) => pe(e) === "" && !e.querySelector("li, blockquote, .select-token");
122
+ c(() => {
123
+ let e = M.current;
124
+ e && s !== P.current && (e.innerHTML = s, W.current && y(e, W.current.pattern ?? se, q), P.current = s, Se(Te(e)));
125
+ }, [s]), ce(() => {
126
+ let e = M.current, t = W.current;
127
+ e && t && e.querySelectorAll(`.${_}`).forEach((e) => {
128
+ let n = e.dataset.token ?? "";
129
+ he(e, t.labelOf(n), G.current.has(n), K.current);
130
+ });
131
+ }, [
132
+ E == null ? void 0 : E.labelOf,
133
+ we,
134
+ j.missing
135
+ ]), c(() => {
136
+ let e = N.current;
137
+ if (e) return oe(e, e.children);
138
+ }, [k, A]);
139
+ let J = () => {
140
+ let e = M.current;
54
141
  if (!e) return;
55
- let t = e.innerHTML;
56
- k.current = t;
57
- let n = S(e);
58
- M(n === "" && !e.querySelector("li, blockquote")), w(t, n);
59
- }, H = () => {
60
- let e = O.current;
61
- e && P({
62
- bold: x("bold"),
63
- italic: x("italic"),
64
- underline: x("underline"),
65
- strikeThrough: x("strikeThrough"),
66
- insertUnorderedList: x("insertUnorderedList"),
67
- insertOrderedList: x("insertOrderedList"),
68
- quote: !!C(e, "blockquote"),
69
- link: !!C(e, "a")
142
+ let t = W.current != null, n = t ? ge(e) : e.innerHTML;
143
+ P.current = n;
144
+ let r = t ? _e(e) : pe(e);
145
+ Se(Te(e)), de(n, r);
146
+ }, Y = () => {
147
+ let e = M.current;
148
+ e && Ce({
149
+ bold: h("bold"),
150
+ italic: h("italic"),
151
+ underline: h("underline"),
152
+ strikeThrough: h("strikeThrough"),
153
+ insertUnorderedList: h("insertUnorderedList"),
154
+ insertOrderedList: h("insertOrderedList"),
155
+ quote: !!g(e, "blockquote"),
156
+ link: !!g(e, "a")
70
157
  });
71
158
  };
72
- d(() => {
159
+ ce(() => {
73
160
  let e = () => {
74
- let e = O.current, t = document.getSelection();
75
- e && t && t.rangeCount && e.contains(t.getRangeAt(0).startContainer) && H();
161
+ let e = M.current, t = document.getSelection();
162
+ e && t && t.rangeCount && e.contains(t.getRangeAt(0).startContainer) && (I.current = t.getRangeAt(0).cloneRange(), Y());
76
163
  };
77
164
  return document.addEventListener("selectionchange", e), () => document.removeEventListener("selectionchange", e);
78
165
  }, []);
79
- let U = (e, t) => {
166
+ let X = (e, t) => {
80
167
  var n;
81
- (n = O.current) == null || n.focus(), b("defaultParagraphSeparator", "p"), b(e, t), V(), H();
82
- }, W = () => {
83
- let e = O.current;
84
- e && (e.focus(), U("formatBlock", C(e, "blockquote") ? "p" : "blockquote"));
85
- }, G = (e) => {
86
- e && (b("insertText", e), V());
87
- }, K = (e) => {
88
- e.preventDefault(), G(e.clipboardData.getData("text/plain"));
89
- }, q = (e) => {
168
+ (n = M.current) == null || n.focus(), m("defaultParagraphSeparator", "p"), m(e, t), J(), Y();
169
+ }, Ee = () => {
170
+ let e = M.current;
171
+ e && (e.focus(), X("formatBlock", g(e, "blockquote") ? "p" : "blockquote"));
172
+ }, De = (e) => {
173
+ let t = M.current;
174
+ if (!t || e.length === 0) return;
175
+ t.focus();
176
+ let n = document.getSelection(), r = I.current && t.contains(I.current.startContainer) ? I.current.cloneRange() : null;
177
+ if (!r) {
178
+ r = document.createRange();
179
+ let e = t.lastElementChild && /^(P|DIV)$/.test(t.lastElementChild.tagName) ? t.lastElementChild : t;
180
+ r.selectNodeContents(e), r.collapse(!1);
181
+ }
182
+ r.deleteContents();
183
+ let i = document.createDocumentFragment();
184
+ e.forEach((e) => i.appendChild(e));
185
+ let a = e[e.length - 1];
186
+ r.insertNode(i);
187
+ let o = document.createRange();
188
+ o.setStartAfter(a), o.collapse(!0), n == null || n.removeAllRanges(), n == null || n.addRange(o), I.current = o.cloneRange(), J();
189
+ }, Oe = (e) => {
190
+ if (!e) return;
191
+ let t = W.current;
192
+ if (t) {
193
+ var n;
194
+ let r = document.createElement("span");
195
+ e.replace(/\r\n?/g, "\n").split("\n").forEach((e, t) => {
196
+ t > 0 && r.appendChild(document.createElement("br")), e && r.appendChild(document.createTextNode(e));
197
+ }), y(r, t.pattern ?? se, q);
198
+ let i = document.getSelection();
199
+ i && i.rangeCount && (n = M.current) != null && n.contains(i.getRangeAt(0).startContainer) && (I.current = i.getRangeAt(0).cloneRange()), De([...r.childNodes]);
200
+ return;
201
+ }
202
+ m("insertText", e), J();
203
+ }, ke = (e) => {
204
+ e.preventDefault(), Oe(e.clipboardData.getData("text/plain"));
205
+ }, Ae = (e) => {
90
206
  var t;
91
- Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) ?? []).includes("Files") || (e.preventDefault(), G(e.dataTransfer.getData("text/plain")));
92
- }, J = () => {
93
- let e = O.current, t = document.getSelection();
94
- A.current = e && t && t.rangeCount && e.contains(t.getRangeAt(0).startContainer) ? t.getRangeAt(0).cloneRange() : null;
95
- let n = e ? C(e, "a") : null;
96
- R((n == null ? void 0 : n.getAttribute("href")) ?? ""), B(""), I(!0);
97
- }, Y = () => {
98
- let e = O.current;
207
+ Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) ?? []).includes("Files") || (e.preventDefault(), Oe(e.dataTransfer.getData("text/plain")));
208
+ };
209
+ le(be, () => ({
210
+ insertToken: (e, t) => {
211
+ De([q(t ?? `{${e}}`, e), document.createTextNode(" ")]), window.setTimeout(() => {
212
+ let e = M.current;
213
+ if (!e) return;
214
+ e.focus();
215
+ let t = I.current;
216
+ if (t && e.contains(t.startContainer)) {
217
+ let e = document.getSelection();
218
+ e == null || e.removeAllRanges(), e == null || e.addRange(t.cloneRange());
219
+ }
220
+ }, 0);
221
+ },
222
+ focus: () => {
223
+ var e;
224
+ return (e = M.current) == null ? void 0 : e.focus();
225
+ }
226
+ }));
227
+ let je = () => {
228
+ let e = M.current, t = document.getSelection();
229
+ F.current = e && t && t.rangeCount && e.contains(t.getRangeAt(0).startContainer) ? t.getRangeAt(0).cloneRange() : null;
230
+ let n = e ? g(e, "a") : null;
231
+ V((n == null ? void 0 : n.getAttribute("href")) ?? ""), U(""), z(!0);
232
+ }, Z = () => {
233
+ let e = M.current;
99
234
  if (!e) return;
100
235
  e.focus();
101
236
  let t = document.getSelection();
102
- A.current && t && (t.removeAllRanges(), t.addRange(A.current));
103
- }, X = () => {
104
- let e = y(L);
237
+ F.current && t && (t.removeAllRanges(), t.addRange(F.current));
238
+ }, Me = () => {
239
+ let e = fe(B);
105
240
  if (!e) {
106
- B("Use um endereço como https://site.com.br ou nome@empresa.com.");
241
+ U("Use um endereço como https://site.com.br ou nome@empresa.com.");
107
242
  return;
108
243
  }
109
- Y();
244
+ Z();
110
245
  let t = document.getSelection();
111
246
  if (!t || !t.rangeCount || t.getRangeAt(0).collapsed) {
112
247
  let t = e.replace(/^mailto:/i, "");
113
- b("insertHTML", `<a href="${_(e)}">${_(t)}</a>&nbsp;`);
114
- } else b("createLink", e);
115
- I(!1), V(), H();
116
- }, Z = () => {
117
- Y(), b("unlink"), I(!1), V(), H();
118
- }, Q = (e, t, n, r) => /* @__PURE__ */ h(l, {
248
+ m("insertHTML", `<a href="${p(e)}">${p(t)}</a>&nbsp;`);
249
+ } else m("createLink", e);
250
+ z(!1), J(), Y();
251
+ }, Ne = () => {
252
+ Z(), m("unlink"), z(!1), J(), Y();
253
+ }, Q = (e, t, n, r) => /* @__PURE__ */ d(re, {
119
254
  content: t,
120
- children: /* @__PURE__ */ h("button", {
255
+ children: /* @__PURE__ */ d("button", {
121
256
  type: "button",
122
- className: `select-maileditor__tool${e && N[e] ? " is-active" : ""}`,
257
+ className: `select-maileditor__tool${e && L[e] ? " is-active" : ""}`,
123
258
  "aria-label": t,
124
- "aria-pressed": e ? !!N[e] : void 0,
259
+ "aria-pressed": e ? !!L[e] : void 0,
125
260
  onMouseDown: (e) => e.preventDefault(),
126
261
  onClick: r,
127
262
  children: n
128
263
  })
129
- });
130
- return /* @__PURE__ */ g("div", {
131
- className: `select-maileditor select-maileditor--${D}`,
132
- children: [/* @__PURE__ */ h("div", {
133
- ref: O,
134
- className: `select-maileditor__area${j ? " is-empty" : ""}`,
135
- contentEditable: !0,
136
- suppressContentEditableWarning: !0,
137
- role: "textbox",
138
- "aria-multiline": "true",
139
- "aria-label": E,
140
- "data-placeholder": T,
141
- spellCheck: !0,
142
- onInput: V,
143
- onKeyUp: H,
144
- onMouseUp: H,
145
- onPaste: K,
146
- onDrop: q
147
- }), /* @__PURE__ */ g("div", {
148
- className: "select-maileditor__bar",
149
- role: "toolbar",
150
- "aria-label": "Formatação",
151
- children: [
152
- Q("bold", "Negrito", /* @__PURE__ */ h(i, {}), () => U("bold")),
153
- Q("italic", "Itálico", /* @__PURE__ */ h(a, {}), () => U("italic")),
154
- Q("underline", "Sublinhado", /* @__PURE__ */ h(c, {}), () => U("underline")),
155
- Q("strikeThrough", "Riscado", /* @__PURE__ */ h(s, {}), () => U("strikeThrough")),
156
- /* @__PURE__ */ h("span", {
157
- className: "select-maileditor__sep",
158
- "aria-hidden": "true"
159
- }),
160
- Q("insertUnorderedList", "Lista com marcadores", /* @__PURE__ */ h(n, {}), () => U("insertUnorderedList")),
161
- Q("insertOrderedList", "Lista numerada", /* @__PURE__ */ h(r, {}), () => U("insertOrderedList")),
162
- Q("quote", "Citação", /* @__PURE__ */ h(o, {}), W),
163
- /* @__PURE__ */ h("span", {
164
- className: "select-maileditor__sep",
165
- "aria-hidden": "true"
166
- }),
167
- /* @__PURE__ */ h(u, {
168
- active: F,
169
- onClose: () => I(!1),
170
- placement: "top-start",
171
- role: "dialog",
172
- activator: Q("link", N.link ? "Editar o link" : "Link", /* @__PURE__ */ h(t, {}), () => F ? I(!1) : J()),
173
- children: /* @__PURE__ */ g("form", {
174
- className: "select-maileditor__link",
175
- onSubmit: (e) => {
176
- e.preventDefault(), X();
177
- },
178
- children: [
179
- /* @__PURE__ */ g("label", {
180
- className: "select-maileditor__linklabel",
181
- children: [/* @__PURE__ */ h("span", { children: "Endereço do link" }), /* @__PURE__ */ h("input", {
182
- className: "select-maileditor__linkinput",
183
- value: L,
184
- onChange: (e) => {
185
- R(e.target.value), B("");
186
- },
187
- placeholder: "https://site.com.br",
188
- inputMode: "url",
189
- autoComplete: "off",
190
- autoFocus: !0
191
- })]
192
- }),
193
- z ? /* @__PURE__ */ h("span", {
194
- className: "select-maileditor__linkerror",
195
- role: "alert",
196
- children: z
197
- }) : null,
198
- /* @__PURE__ */ g("span", {
199
- className: "select-maileditor__linkactions",
200
- children: [N.link ? /* @__PURE__ */ h("button", {
201
- type: "button",
202
- className: "select-maileditor__linkbtn",
203
- onClick: Z,
204
- children: "Tirar o link"
205
- }) : null, /* @__PURE__ */ h("button", {
206
- type: "submit",
207
- className: "select-maileditor__linkbtn select-maileditor__linkbtn--primary",
208
- children: "Aplicar"
209
- })]
210
- })
211
- ]
212
- })
213
- }),
214
- Q(null, "Limpar a formatação", /* @__PURE__ */ h(e, {}), () => {
215
- U("removeFormat"), b("unlink"), V();
264
+ }), Pe = x != null && x !== !1, Fe = S != null && S !== !1 || C != null && C !== !1, Ie = T != null && T !== !1, $ = O != null && O !== !1, Le = ye ?? (Pe || Fe || Ie || $), Re = /* @__PURE__ */ f("div", {
265
+ ref: N,
266
+ className: "select-maileditor__bar",
267
+ role: "toolbar",
268
+ "aria-label": "Formatação",
269
+ children: [
270
+ Q("bold", "Negrito", /* @__PURE__ */ d(i, {}), () => X("bold")),
271
+ Q("italic", "Itálico", /* @__PURE__ */ d(a, {}), () => X("italic")),
272
+ Q("underline", "Sublinhado", /* @__PURE__ */ d(te, {}), () => X("underline")),
273
+ Q("strikeThrough", "Riscado", /* @__PURE__ */ d(ee, {}), () => X("strikeThrough")),
274
+ /* @__PURE__ */ d("span", {
275
+ className: "select-maileditor__sep",
276
+ "aria-hidden": "true"
277
+ }),
278
+ Q("insertUnorderedList", "Lista com marcadores", /* @__PURE__ */ d(n, {}), () => X("insertUnorderedList")),
279
+ Q("insertOrderedList", "Lista numerada", /* @__PURE__ */ d(r, {}), () => X("insertOrderedList")),
280
+ Q("quote", "Citação", /* @__PURE__ */ d(o, {}), Ee),
281
+ /* @__PURE__ */ d("span", {
282
+ className: "select-maileditor__sep",
283
+ "aria-hidden": "true"
284
+ }),
285
+ /* @__PURE__ */ d(ae, {
286
+ active: R,
287
+ onClose: () => z(!1),
288
+ placement: "top-start",
289
+ role: "dialog",
290
+ activator: Q("link", L.link ? "Editar o link" : "Link", /* @__PURE__ */ d(t, {}), () => R ? z(!1) : je()),
291
+ children: /* @__PURE__ */ f("form", {
292
+ className: "select-maileditor__link",
293
+ onSubmit: (e) => {
294
+ e.preventDefault(), Me();
295
+ },
296
+ children: [
297
+ /* @__PURE__ */ f("label", {
298
+ className: "select-maileditor__linklabel",
299
+ children: [/* @__PURE__ */ d("span", { children: "Endereço do link" }), /* @__PURE__ */ d("input", {
300
+ className: "select-maileditor__linkinput",
301
+ value: B,
302
+ onChange: (e) => {
303
+ V(e.target.value), U("");
304
+ },
305
+ placeholder: "https://site.com.br",
306
+ inputMode: "url",
307
+ autoComplete: "off",
308
+ autoFocus: !0
309
+ })]
310
+ }),
311
+ H ? /* @__PURE__ */ d("span", {
312
+ className: "select-maileditor__linkerror",
313
+ role: "alert",
314
+ children: H
315
+ }) : null,
316
+ /* @__PURE__ */ f("span", {
317
+ className: "select-maileditor__linkactions",
318
+ children: [L.link ? /* @__PURE__ */ d("button", {
319
+ type: "button",
320
+ className: "select-maileditor__linkbtn",
321
+ onClick: Ne,
322
+ children: "Tirar o link"
323
+ }) : null, /* @__PURE__ */ d("button", {
324
+ type: "submit",
325
+ className: "select-maileditor__linkbtn select-maileditor__linkbtn--primary",
326
+ children: "Aplicar"
327
+ })]
328
+ })
329
+ ]
216
330
  })
217
- ]
218
- })]
331
+ }),
332
+ Q(null, "Limpar a formatação", /* @__PURE__ */ d(e, {}), () => {
333
+ X("removeFormat"), m("unlink"), J();
334
+ }),
335
+ A != null && A !== !1 ? /* @__PURE__ */ f(ue, { children: [/* @__PURE__ */ d("span", {
336
+ className: "select-maileditor__sep",
337
+ "aria-hidden": "true"
338
+ }), /* @__PURE__ */ d("span", {
339
+ className: "select-maileditor__apptools",
340
+ children: A
341
+ })] }) : null
342
+ ]
343
+ }), ze = /* @__PURE__ */ d("div", {
344
+ ref: M,
345
+ className: `select-maileditor__area${xe ? " is-empty" : ""}`,
346
+ contentEditable: !0,
347
+ suppressContentEditableWarning: !0,
348
+ role: "textbox",
349
+ "aria-multiline": "true",
350
+ "aria-label": b,
351
+ "aria-invalid": $ || void 0,
352
+ "data-placeholder": v,
353
+ spellCheck: !0,
354
+ onInput: J,
355
+ onKeyUp: Y,
356
+ onMouseUp: Y,
357
+ onPaste: ke,
358
+ onDrop: Ae
219
359
  });
220
- }
360
+ return /* @__PURE__ */ f("div", {
361
+ className: `select-maileditor select-maileditor--${ve}${Le ? " select-maileditor--framed" : ""}${k === "top" ? " select-maileditor--bartop" : ""}${$ ? " is-invalid" : ""}`,
362
+ style: w ? { "--select-maileditor-brand": w } : void 0,
363
+ children: [
364
+ k === "top" ? Re : null,
365
+ /* @__PURE__ */ f("div", {
366
+ className: "select-maileditor__frame",
367
+ children: [
368
+ Pe ? /* @__PURE__ */ d("div", {
369
+ className: "select-maileditor__brandhead",
370
+ role: "group",
371
+ "aria-label": j.header,
372
+ children: x
373
+ }) : null,
374
+ ze,
375
+ Ie ? /* @__PURE__ */ d("div", {
376
+ className: "select-maileditor__signature",
377
+ role: "group",
378
+ "aria-label": j.signature,
379
+ children: T
380
+ }) : null,
381
+ Fe ? /* @__PURE__ */ f("div", {
382
+ className: "select-maileditor__brandfoot",
383
+ role: "group",
384
+ "aria-label": j.footer,
385
+ children: [S, C != null && C !== !1 ? /* @__PURE__ */ d("span", {
386
+ className: "select-maileditor__unsubscribe",
387
+ children: C === !0 ? j.unsubscribe : C
388
+ }) : null]
389
+ }) : null
390
+ ]
391
+ }),
392
+ k === "top" ? null : Re,
393
+ $ ? /* @__PURE__ */ f("div", {
394
+ className: "select-maileditor__error",
395
+ role: "alert",
396
+ children: [/* @__PURE__ */ d("span", {
397
+ className: "select-maileditor__erroricon",
398
+ "aria-hidden": "true",
399
+ children: /* @__PURE__ */ d(ne, {})
400
+ }), /* @__PURE__ */ d("span", { children: O })]
401
+ }) : null
402
+ ]
403
+ });
404
+ });
221
405
  //#endregion
222
- export { w as SelectMailEditor, y as mailLinkHref, v as mailTextToHtml };
406
+ export { b as SelectMailEditor, fe as mailLinkHref, de as mailTextToHtml };
223
407
 
224
408
  //# sourceMappingURL=SelectMailEditor.js.map