@selectwin/kit 0.1.261 → 0.1.263
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/README.md +72 -0
- package/dist/SelectActionMenu.d.ts +7 -1
- package/dist/SelectActionMenu.js +14 -13
- package/dist/SelectBlockBuilder.d.ts +63 -0
- package/dist/SelectBlockBuilder.js +370 -0
- package/dist/SelectCalendar.d.ts +68 -4
- package/dist/SelectCalendar.js +449 -279
- package/dist/SelectChannelPreview.d.ts +34 -5
- package/dist/SelectChannelPreview.js +167 -73
- package/dist/SelectChartCard.d.ts +13 -0
- package/dist/SelectChartCard.js +50 -30
- package/dist/SelectCombobox.d.ts +5 -0
- package/dist/SelectCombobox.js +77 -61
- package/dist/SelectConversationContext.d.ts +30 -0
- package/dist/SelectConversationContext.js +141 -0
- package/dist/SelectDatePicker.d.ts +4 -0
- package/dist/SelectDatePicker.js +78 -62
- package/dist/SelectDateRangeField.d.ts +6 -1
- package/dist/SelectDateRangeField.js +9 -8
- package/dist/SelectField.d.ts +7 -3
- package/dist/SelectField.js +71 -70
- package/dist/SelectFilterBar.d.ts +9 -0
- package/dist/SelectFilterBar.js +301 -179
- package/dist/SelectFunnel.d.ts +12 -2
- package/dist/SelectFunnel.js +193 -63
- package/dist/SelectHorizontalBar.d.ts +11 -1
- package/dist/SelectHorizontalBar.js +86 -35
- package/dist/SelectHtmlFrame.d.ts +3 -1
- package/dist/SelectHtmlFrame.js +4 -4
- package/dist/SelectLocale.d.ts +146 -0
- package/dist/SelectLocale.js +363 -31
- package/dist/SelectMail.d.ts +80 -4
- package/dist/SelectMail.js +433 -300
- package/dist/SelectMailEditor.d.ts +35 -1
- package/dist/SelectMailEditor.js +347 -163
- package/dist/SelectNumberedList.d.ts +20 -2
- package/dist/SelectNumberedList.js +75 -17
- package/dist/SelectPopover.js +1 -0
- package/dist/SelectProgressBar.d.ts +22 -5
- package/dist/SelectProgressBar.js +70 -40
- package/dist/SelectRecordCard.d.ts +13 -4
- package/dist/SelectRecordCard.js +30 -8
- package/dist/SelectRuleBuilder.d.ts +52 -0
- package/dist/SelectRuleBuilder.js +157 -0
- package/dist/SelectSearchPreview.d.ts +35 -0
- package/dist/SelectSearchPreview.js +69 -0
- package/dist/SelectSegmented.d.ts +2 -0
- package/dist/SelectSegmented.js +1 -1
- package/dist/SelectSortable.d.ts +5 -1
- package/dist/SelectSparkBars.d.ts +5 -1
- package/dist/SelectSparkBars.js +65 -57
- package/dist/SelectSteps.d.ts +6 -0
- package/dist/SelectSteps.js +43 -10
- package/dist/SelectTabs.d.ts +16 -4
- package/dist/SelectTabs.js +95 -60
- package/dist/SelectTextarea.d.ts +1 -1
- package/dist/SelectVoiceNote.d.ts +6 -1
- package/dist/SelectVoiceNote.js +118 -106
- package/dist/chartUtils.d.ts +10 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.js +153 -149
- package/dist/style.css +1 -1
- 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
|
|
51
|
+
export declare const SelectMailEditor: import('react').ForwardRefExoticComponent<SelectMailEditorProps & import('react').RefAttributes<SelectMailEditorHandle>>;
|
package/dist/SelectMailEditor.js
CHANGED
|
@@ -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
|
|
3
|
-
import { SelectTooltip as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
9
|
-
function
|
|
10
|
-
return e.replace(/\r\n?/g, "\n").split(/\n{2,}/).filter((e, t) => e.length > 0 || t === 0).map((e) => `<p>${e ?
|
|
11
|
+
var p = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
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
|
|
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
|
|
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
|
|
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
|
|
36
|
-
return (typeof e.innerText == "string" && e.innerText !== "" ? e.innerText : e.textContent ?? "").replace(/
|
|
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
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
let e =
|
|
61
|
-
e &&
|
|
62
|
-
bold:
|
|
63
|
-
italic:
|
|
64
|
-
underline:
|
|
65
|
-
strikeThrough:
|
|
66
|
-
insertUnorderedList:
|
|
67
|
-
insertOrderedList:
|
|
68
|
-
quote: !!
|
|
69
|
-
link: !!
|
|
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
|
-
|
|
159
|
+
ce(() => {
|
|
73
160
|
let e = () => {
|
|
74
|
-
let e =
|
|
75
|
-
e && t && t.rangeCount && e.contains(t.getRangeAt(0).startContainer) &&
|
|
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
|
|
166
|
+
let X = (e, t) => {
|
|
80
167
|
var n;
|
|
81
|
-
(n =
|
|
82
|
-
},
|
|
83
|
-
let e =
|
|
84
|
-
e && (e.focus(),
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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(),
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
},
|
|
104
|
-
let e =
|
|
237
|
+
F.current && t && (t.removeAllRanges(), t.addRange(F.current));
|
|
238
|
+
}, Me = () => {
|
|
239
|
+
let e = fe(B);
|
|
105
240
|
if (!e) {
|
|
106
|
-
|
|
241
|
+
U("Use um endereço como https://site.com.br ou nome@empresa.com.");
|
|
107
242
|
return;
|
|
108
243
|
}
|
|
109
|
-
|
|
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
|
-
|
|
114
|
-
} else
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
}, Q = (e, t, n, r) => /* @__PURE__ */
|
|
248
|
+
m("insertHTML", `<a href="${p(e)}">${p(t)}</a> `);
|
|
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__ */
|
|
255
|
+
children: /* @__PURE__ */ d("button", {
|
|
121
256
|
type: "button",
|
|
122
|
-
className: `select-maileditor__tool${e &&
|
|
257
|
+
className: `select-maileditor__tool${e && L[e] ? " is-active" : ""}`,
|
|
123
258
|
"aria-label": t,
|
|
124
|
-
"aria-pressed": e ? !!
|
|
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
|
-
|
|
131
|
-
className:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Q("
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
className: "select-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
|
|
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 {
|
|
406
|
+
export { b as SelectMailEditor, fe as mailLinkHref, de as mailTextToHtml };
|
|
223
407
|
|
|
224
408
|
//# sourceMappingURL=SelectMailEditor.js.map
|