@selectwin/kit 0.1.256 → 0.1.257
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 +13 -0
- package/dist/SelectConversationNote.d.ts +37 -0
- package/dist/SelectConversationNote.js +93 -0
- package/dist/SelectLocale.d.ts +6 -0
- package/dist/SelectLocale.js +12 -2
- package/dist/SelectMail.d.ts +17 -2
- package/dist/SelectMail.js +9 -6
- package/dist/SelectTriggerMenu.d.ts +77 -0
- package/dist/SelectTriggerMenu.js +98 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +146 -144
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,19 @@ tela, a barra e o trilho ficam parados e a página rola no invólucro do `Select
|
|
|
86
86
|
trilho, com a barra na borda do painel. O `scrollRef` do painel entrega o invólucro (para voltar ao topo na troca de
|
|
87
87
|
página), e o `fill` serve à página de altura cheia: a coluna da página tem a altura do invólucro e é uma coluna flex.
|
|
88
88
|
|
|
89
|
+
A nota interna e a lista do "/" e da "@" (0.1.257, o CRM sobre o Chat da SWMX; as pranchas O-Inbox e C-Mobile do
|
|
90
|
+
canvas do CRM): o `SelectConversationNote` é a nota entre as mensagens, do lado de quem responde, no fundo de aviso com a
|
|
91
|
+
borda tracejada, o cadeado e "Nota interna · só a equipe vê" em cima e, no pé, quem escreveu, a hora e quem foi avisado;
|
|
92
|
+
o `SelectMentionText` (com o `SelectMention` e o `selectMentionParts`) destaca cada "@nome" no começo de uma palavra, sem
|
|
93
|
+
pegar o e-mail; o `SelectNoteField` é a caixa do compositor no modo nota (o mesmo desenho, "Só a equipe vê · o contato
|
|
94
|
+
não" em cima e o campo do app por dentro), e o `SelectNoteDot`, o quadradinho do "Nota interna" no segmentado. O
|
|
95
|
+
`SelectTriggerMenu` é a lista que abre por um caractere, acima da caixa: o título, a dica do teclado, o atalho em código
|
|
96
|
+
(`code`) ou o avatar e o nome, o texto e de quem é, "Buscando…" e "Nada encontrado". O foco fica na caixa (o
|
|
97
|
+
`selectTriggerFieldProps` dá o `aria-controls` e o `aria-activedescendant`), e o teclado é do `useSelectTriggerMenu` (↑ ↓
|
|
98
|
+
dão a volta, Enter e Tab escolhem, Esc fecha). O `selectTriggerAt` acha o "/" ou a "@" no começo da palavra do cursor, e
|
|
99
|
+
o `selectReplaceTrigger` troca o gatilho e a busca pelo escolhido. Os tons: os do aviso, mais `--select-note-border`,
|
|
100
|
+
`--select-note-meta` e `--select-note-dot` (o claro e o escuro).
|
|
101
|
+
|
|
89
102
|
## Build
|
|
90
103
|
|
|
91
104
|
```bash
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface SelectConversationNoteProps {
|
|
3
|
+
/** O texto da nota (com as menções em destaque: `SelectMentionText`). */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Quem escreveu ("Você", "Marcos Vieira"). */
|
|
6
|
+
author?: ReactNode;
|
|
7
|
+
/** A hora ("10:59"). */
|
|
8
|
+
time?: ReactNode;
|
|
9
|
+
/** O que mais vai no pé ("Ricardo foi avisado"). */
|
|
10
|
+
meta?: ReactNode;
|
|
11
|
+
/** O rótulo de cima (padrão: "Nota interna · só a equipe vê"). */
|
|
12
|
+
label?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function SelectConversationNote({ children, author, time, meta, label }: SelectConversationNoteProps): import("react").JSX.Element;
|
|
15
|
+
/** A menção em destaque ("@Ricardo"): no texto da nota e onde mais o app a mostrar. */
|
|
16
|
+
export declare function SelectMention({ children }: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
/** O texto em pedaços: o texto puro e cada "@nome". */
|
|
20
|
+
export declare function selectMentionParts(text: string): Array<{
|
|
21
|
+
mention: boolean;
|
|
22
|
+
text: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** O texto com cada "@nome" em destaque (o resto, como veio: as quebras de linha ficam, no `pre-wrap` da conversa). */
|
|
25
|
+
export declare function SelectMentionText({ children }: {
|
|
26
|
+
children: string;
|
|
27
|
+
}): import("react").JSX.Element;
|
|
28
|
+
export interface SelectNoteFieldProps {
|
|
29
|
+
/** O campo de texto da nota (o do app; por dentro da caixa, ele fica sem borda e sem fundo). */
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/** O rótulo de cima (padrão: "Só a equipe vê · o contato não"). */
|
|
32
|
+
label?: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/** A caixa do compositor no modo nota: o fundo e a borda tracejada da nota, com o cadeado e o rótulo em cima. */
|
|
35
|
+
export declare function SelectNoteField({ children, label }: SelectNoteFieldProps): import("react").JSX.Element;
|
|
36
|
+
/** O quadradinho amarelo da nota (o "Nota interna" do segmentado). Só enfeite: o texto do lado diz o que é. */
|
|
37
|
+
export declare function SelectNoteDot(): import("react").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useSelectMessages as e } from "./SelectLocale.js";
|
|
2
|
+
import { Fragment as t } from "react";
|
|
3
|
+
import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
//#region src/SelectConversationNote.tsx
|
|
5
|
+
function a() {
|
|
6
|
+
return /* @__PURE__ */ r("svg", {
|
|
7
|
+
viewBox: "0 0 24 24",
|
|
8
|
+
width: "12",
|
|
9
|
+
height: "12",
|
|
10
|
+
fill: "none",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeWidth: "2",
|
|
13
|
+
strokeLinecap: "round",
|
|
14
|
+
strokeLinejoin: "round",
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
children: /* @__PURE__ */ r("path", { d: "M7 11V8a5 5 0 0 1 10 0v3M5.5 11h13v9h-13z" })
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function o({ children: n, author: o, time: s, meta: c, label: l }) {
|
|
20
|
+
let u = e().chat, d = [
|
|
21
|
+
o,
|
|
22
|
+
s,
|
|
23
|
+
c
|
|
24
|
+
].filter((e) => e != null && e !== "");
|
|
25
|
+
return /* @__PURE__ */ r("div", {
|
|
26
|
+
className: "select-convo__msg select-convo__msg--out select-convo__msg--note",
|
|
27
|
+
children: /* @__PURE__ */ i("div", {
|
|
28
|
+
className: "select-convo__note",
|
|
29
|
+
role: "note",
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ i("span", {
|
|
32
|
+
className: "select-convo__note-label",
|
|
33
|
+
children: [/* @__PURE__ */ r(a, {}), l ?? u.noteLabel]
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ r("div", {
|
|
36
|
+
className: "select-convo__text",
|
|
37
|
+
children: n
|
|
38
|
+
}),
|
|
39
|
+
d.length > 0 ? /* @__PURE__ */ r("span", {
|
|
40
|
+
className: "select-convo__note-meta",
|
|
41
|
+
children: d.map((e, n) => /* @__PURE__ */ i(t, { children: [n > 0 ? " · " : null, e] }, n))
|
|
42
|
+
}) : null
|
|
43
|
+
]
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function s({ children: e }) {
|
|
48
|
+
return /* @__PURE__ */ r("span", {
|
|
49
|
+
className: "select-mention",
|
|
50
|
+
children: e
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
var c = /(^|[^\p{L}\p{M}\p{N}_@.])(@[\p{L}\p{N}_](?:[\p{L}\p{M}\p{N}_.-]*[\p{L}\p{M}\p{N}_])?)/gu;
|
|
54
|
+
function l(e) {
|
|
55
|
+
let t = [], n = 0;
|
|
56
|
+
for (let r of e.matchAll(c)) {
|
|
57
|
+
let i = (r.index ?? 0) + (r[1] ?? "").length, a = r[2] ?? "";
|
|
58
|
+
i > n && t.push({
|
|
59
|
+
mention: !1,
|
|
60
|
+
text: e.slice(n, i)
|
|
61
|
+
}), t.push({
|
|
62
|
+
mention: !0,
|
|
63
|
+
text: a
|
|
64
|
+
}), n = i + a.length;
|
|
65
|
+
}
|
|
66
|
+
return n < e.length && t.push({
|
|
67
|
+
mention: !1,
|
|
68
|
+
text: e.slice(n)
|
|
69
|
+
}), t;
|
|
70
|
+
}
|
|
71
|
+
function u({ children: e }) {
|
|
72
|
+
return /* @__PURE__ */ r(n, { children: l(e).map((e, n) => e.mention ? /* @__PURE__ */ r(s, { children: e.text }, n) : /* @__PURE__ */ r(t, { children: e.text }, n)) });
|
|
73
|
+
}
|
|
74
|
+
function d({ children: t, label: n }) {
|
|
75
|
+
let o = e().chat;
|
|
76
|
+
return /* @__PURE__ */ i("div", {
|
|
77
|
+
className: "select-note-field",
|
|
78
|
+
children: [/* @__PURE__ */ i("span", {
|
|
79
|
+
className: "select-note-field__label",
|
|
80
|
+
children: [/* @__PURE__ */ r(a, {}), n ?? o.noteFieldLabel]
|
|
81
|
+
}), t]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function f() {
|
|
85
|
+
return /* @__PURE__ */ r("span", {
|
|
86
|
+
className: "select-note-dot",
|
|
87
|
+
"aria-hidden": "true"
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { o as SelectConversationNote, s as SelectMention, u as SelectMentionText, f as SelectNoteDot, d as SelectNoteField, l as selectMentionParts };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=SelectConversationNote.js.map
|
package/dist/SelectLocale.d.ts
CHANGED
|
@@ -191,6 +191,12 @@ export interface SelectKitMessages {
|
|
|
191
191
|
copied: string;
|
|
192
192
|
send: string;
|
|
193
193
|
record: string;
|
|
194
|
+
/** 0.1.257: a nota interna (SelectConversationNote, SelectNoteField) e a lista do "/" e da "@" (SelectTriggerMenu). */
|
|
195
|
+
noteLabel: string;
|
|
196
|
+
noteFieldLabel: string;
|
|
197
|
+
triggerHint: string;
|
|
198
|
+
triggerLoading: string;
|
|
199
|
+
triggerEmpty: string;
|
|
194
200
|
};
|
|
195
201
|
/** 0.1.223: a entrada — o nome de cada caixinha do código (SelectOtpInput) e a força da senha (SelectPasswordStrength). */
|
|
196
202
|
auth: {
|
package/dist/SelectLocale.js
CHANGED
|
@@ -201,7 +201,12 @@ var r = {
|
|
|
201
201
|
listOptions: "Opções da lista",
|
|
202
202
|
copied: "Copiado",
|
|
203
203
|
send: "Enviar",
|
|
204
|
-
record: "Gravar áudio"
|
|
204
|
+
record: "Gravar áudio",
|
|
205
|
+
noteLabel: "Nota interna · só a equipe vê",
|
|
206
|
+
noteFieldLabel: "Só a equipe vê · o contato não",
|
|
207
|
+
triggerHint: "↑ ↓ escolhe · Enter insere · Esc fecha",
|
|
208
|
+
triggerLoading: "Buscando…",
|
|
209
|
+
triggerEmpty: "Nada encontrado"
|
|
205
210
|
},
|
|
206
211
|
carousel: {
|
|
207
212
|
label: "Destaques",
|
|
@@ -454,7 +459,12 @@ var r = {
|
|
|
454
459
|
listOptions: "List options",
|
|
455
460
|
copied: "Copied",
|
|
456
461
|
send: "Send",
|
|
457
|
-
record: "Record audio"
|
|
462
|
+
record: "Record audio",
|
|
463
|
+
noteLabel: "Internal note · only the team sees it",
|
|
464
|
+
noteFieldLabel: "Only the team sees it · not the contact",
|
|
465
|
+
triggerHint: "↑ ↓ choose · Enter inserts · Esc closes",
|
|
466
|
+
triggerLoading: "Searching…",
|
|
467
|
+
triggerEmpty: "Nothing found"
|
|
458
468
|
},
|
|
459
469
|
carousel: {
|
|
460
470
|
label: "Highlights",
|
package/dist/SelectMail.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { KeyboardEvent, ReactNode, Ref, SyntheticEvent } from 'react';
|
|
2
2
|
import { attachmentExt } from './internal/fileKind';
|
|
3
3
|
export interface SelectMailAddress {
|
|
4
4
|
name: string | null;
|
|
@@ -241,7 +241,7 @@ export declare function SelectMailComposerInput({ value, onChange, placeholder,
|
|
|
241
241
|
maxLength?: number;
|
|
242
242
|
}): import("react").JSX.Element;
|
|
243
243
|
/** O corpo: texto, sem moldura, que cresce até um teto e rola. */
|
|
244
|
-
export declare function SelectMailComposerBody({ value, onChange, placeholder, rows, 'aria-label': ariaLabel, maxLength, onEnter, id, }: {
|
|
244
|
+
export declare function SelectMailComposerBody({ value, onChange, placeholder, rows, 'aria-label': ariaLabel, maxLength, onEnter, id, textareaRef, onKeyDown, onSelect, fieldProps, }: {
|
|
245
245
|
value: string;
|
|
246
246
|
onChange: (value: string) => void;
|
|
247
247
|
placeholder?: string;
|
|
@@ -254,6 +254,21 @@ export declare function SelectMailComposerBody({ value, onChange, placeholder, r
|
|
|
254
254
|
*/
|
|
255
255
|
onEnter?: () => void;
|
|
256
256
|
id?: string;
|
|
257
|
+
/** 0.1.257: a caixa de texto, para quem precisa do cursor (a lista do "/" e da "@", o `SelectTriggerMenu`). */
|
|
258
|
+
textareaRef?: Ref<HTMLTextAreaElement>;
|
|
259
|
+
/**
|
|
260
|
+
* 0.1.257: as teclas de quem usa, ANTES do Enter de enviar: a tecla em que ele chama `preventDefault` é dele (com a
|
|
261
|
+
* lista aberta, o Enter escolhe a opção e não envia).
|
|
262
|
+
*/
|
|
263
|
+
onKeyDown?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
264
|
+
/** 0.1.257: o cursor mudou de lugar (o clique, as setas): quem acompanha o gatilho relê. */
|
|
265
|
+
onSelect?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;
|
|
266
|
+
/** 0.1.257: as props da caixa que abre uma lista (`selectTriggerFieldProps`). */
|
|
267
|
+
fieldProps?: {
|
|
268
|
+
'aria-autocomplete'?: 'list';
|
|
269
|
+
'aria-controls'?: string;
|
|
270
|
+
'aria-activedescendant'?: string;
|
|
271
|
+
};
|
|
257
272
|
}): import("react").JSX.Element;
|
|
258
273
|
/** O clipe do rodapé (0.1.149): abre o seletor de arquivos do sistema. Escolher o mesmo arquivo de novo também vale. */
|
|
259
274
|
export declare function SelectMailAttachButton({ onFiles, accept, multiple, disabled, label, }: {
|
package/dist/SelectMail.js
CHANGED
|
@@ -583,19 +583,22 @@ function K({ value: e, onChange: t, placeholder: n, "aria-label": r, maxLength:
|
|
|
583
583
|
maxLength: i
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
|
-
function q({ value: e, onChange: t, placeholder: n, rows: r = 6, "aria-label": i, maxLength: a, onEnter: o, id: s }) {
|
|
587
|
-
let
|
|
586
|
+
function q({ value: e, onChange: t, placeholder: n, rows: r = 6, "aria-label": i, maxLength: a, onEnter: o, id: s, textareaRef: c, onKeyDown: l, onSelect: u, fieldProps: d }) {
|
|
587
|
+
let f = h().inbox;
|
|
588
588
|
return /* @__PURE__ */ w("textarea", {
|
|
589
|
+
...d,
|
|
590
|
+
ref: c,
|
|
589
591
|
id: s,
|
|
590
592
|
className: "select-mailcomposer__body",
|
|
591
593
|
value: e,
|
|
592
594
|
onChange: (e) => t(e.target.value),
|
|
593
|
-
onKeyDown:
|
|
594
|
-
e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), o());
|
|
595
|
-
}
|
|
595
|
+
onKeyDown: (e) => {
|
|
596
|
+
l == null || l(e), !e.defaultPrevented && o && e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), o());
|
|
597
|
+
},
|
|
598
|
+
onSelect: u,
|
|
596
599
|
placeholder: n,
|
|
597
600
|
rows: r,
|
|
598
|
-
"aria-label": i ??
|
|
601
|
+
"aria-label": i ?? f.message,
|
|
599
602
|
maxLength: a
|
|
600
603
|
});
|
|
601
604
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
export interface SelectTriggerMenuOption {
|
|
3
|
+
id: string;
|
|
4
|
+
/** O atalho ("/estorno") ou o nome ("Ricardo Santos"). */
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** O texto da resposta, ou o detalhe da pessoa ("Comercial · Disponível"). */
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
/** De quem é ("Minha", "Da equipe"), na pílula do fim. */
|
|
9
|
+
tag?: ReactNode;
|
|
10
|
+
/** O que vem antes do nome (o avatar da pessoa). */
|
|
11
|
+
leading?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface SelectTriggerMenuProps {
|
|
14
|
+
/** O id da lista (a caixa de texto aponta para ele). */
|
|
15
|
+
id: string;
|
|
16
|
+
/** O título ("Respostas prontas · o “/” abre"). */
|
|
17
|
+
title: ReactNode;
|
|
18
|
+
/** O nome da lista para o leitor de tela (padrão: o título, quando ele é texto). */
|
|
19
|
+
'aria-label'?: string;
|
|
20
|
+
options: readonly SelectTriggerMenuOption[];
|
|
21
|
+
/** A opção acesa (a do teclado: o `active` do `useSelectTriggerMenu`). */
|
|
22
|
+
active: number;
|
|
23
|
+
/** O mouse em cima de uma opção a acende. */
|
|
24
|
+
onActiveChange?: (index: number) => void;
|
|
25
|
+
/** Escolheu a opção (o clique, ou Enter e Tab pelo `useSelectTriggerMenu`). */
|
|
26
|
+
onPick: (index: number) => void;
|
|
27
|
+
/** O atalho em fonte de código, numa coluna (as respostas prontas); sem ele, o nome em texto (as pessoas). */
|
|
28
|
+
code?: boolean;
|
|
29
|
+
/** Buscando: "Buscando…" no lugar das opções. */
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
/** Nada achado (padrão: "Nada encontrado"). */
|
|
32
|
+
empty?: ReactNode;
|
|
33
|
+
/** A dica do teclado (padrão: "↑ ↓ escolhe · Enter insere · Esc fecha"). */
|
|
34
|
+
hint?: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/** O id de cada opção (o `aria-activedescendant` da caixa aponta para a acesa). */
|
|
37
|
+
export declare const selectTriggerOptionId: (listId: string, index: number) => string;
|
|
38
|
+
export declare function SelectTriggerMenu({ id, title, 'aria-label': ariaLabel, options, active, onActiveChange, onPick, code, loading, empty, hint, }: SelectTriggerMenuProps): import("react").JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* As props da caixa de texto que abre a lista: aponta para ela, diz que ela completa, e qual opção está acesa (o leitor
|
|
41
|
+
* de tela lê a opção sem o foco sair da caixa).
|
|
42
|
+
*/
|
|
43
|
+
export declare function selectTriggerFieldProps(listId: string, open: boolean, active: number, count: number): {
|
|
44
|
+
'aria-autocomplete': "list";
|
|
45
|
+
'aria-controls': string | undefined;
|
|
46
|
+
'aria-activedescendant': string | undefined;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* O teclado da lista, na caixa de texto: chame o `onKeyDown` dele antes do da caixa — quando ele devolve `true`, a tecla
|
|
50
|
+
* foi da lista (e o envio pelo Enter não acontece). A opção acesa volta para a primeira quando a lista abre ou muda.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useSelectTriggerMenu({ open, count, onPick, onClose, }: {
|
|
53
|
+
open: boolean;
|
|
54
|
+
count: number;
|
|
55
|
+
onPick: (index: number) => void;
|
|
56
|
+
onClose: () => void;
|
|
57
|
+
}): {
|
|
58
|
+
active: number;
|
|
59
|
+
setActive: import('react').Dispatch<import('react').SetStateAction<number>>;
|
|
60
|
+
onKeyDown: (event: KeyboardEvent<HTMLElement>) => boolean;
|
|
61
|
+
};
|
|
62
|
+
/** O gatilho no cursor: qual ("/" ou "@"), o que veio depois dele até o cursor, e onde ele começa no texto. */
|
|
63
|
+
export interface SelectTrigger {
|
|
64
|
+
trigger: string;
|
|
65
|
+
query: string;
|
|
66
|
+
start: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Acha o gatilho no cursor: a palavra em que o cursor está (do último espaço até ele) começa por um dos `triggers`. Só no
|
|
70
|
+
* começo da palavra — "http://x" e "joao@exemplo.com" não abrem a lista. Sem gatilho, `null`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function selectTriggerAt(text: string, caret: number, triggers: readonly string[]): SelectTrigger | null;
|
|
73
|
+
/** Troca o gatilho e a busca (de `start` até o cursor) pelo que foi escolhido; o cursor fica logo depois. */
|
|
74
|
+
export declare function selectReplaceTrigger(text: string, start: number, caret: number, insert: string): {
|
|
75
|
+
text: string;
|
|
76
|
+
caret: number;
|
|
77
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useSelectMessages as e } from "./SelectLocale.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
//#region src/SelectTriggerMenu.tsx
|
|
5
|
+
var a = (...e) => e.filter(Boolean).join(" "), o = (e, t) => `${e}-opt-${t}`;
|
|
6
|
+
function s({ id: t, title: n, "aria-label": s, options: c, active: l, onActiveChange: u, onPick: d, code: f = !1, loading: p = !1, empty: m, hint: h }) {
|
|
7
|
+
let g = e().chat, _ = s ?? (typeof n == "string" ? n : void 0), v = !p && c.length > 0;
|
|
8
|
+
return /* @__PURE__ */ i("div", {
|
|
9
|
+
className: "select-trigger-menu",
|
|
10
|
+
children: [
|
|
11
|
+
/* @__PURE__ */ i("div", {
|
|
12
|
+
className: "select-trigger-menu__head",
|
|
13
|
+
children: [/* @__PURE__ */ r("span", {
|
|
14
|
+
className: "select-trigger-menu__title",
|
|
15
|
+
children: n
|
|
16
|
+
}), /* @__PURE__ */ r("span", {
|
|
17
|
+
className: "select-trigger-menu__hint",
|
|
18
|
+
children: h ?? g.triggerHint
|
|
19
|
+
})]
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ r("div", {
|
|
22
|
+
className: "select-trigger-menu__list",
|
|
23
|
+
role: "listbox",
|
|
24
|
+
id: t,
|
|
25
|
+
"aria-label": _,
|
|
26
|
+
children: v ? c.map((e, n) => /* @__PURE__ */ i("div", {
|
|
27
|
+
id: o(t, n),
|
|
28
|
+
role: "option",
|
|
29
|
+
"aria-selected": n === l,
|
|
30
|
+
className: a("select-trigger-menu__option", f && "select-trigger-menu__option--code", n === l && "is-active"),
|
|
31
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
32
|
+
onMouseEnter: () => u == null ? void 0 : u(n),
|
|
33
|
+
onClick: () => d(n),
|
|
34
|
+
children: [
|
|
35
|
+
e.leading ? /* @__PURE__ */ r("span", {
|
|
36
|
+
className: "select-trigger-menu__leading",
|
|
37
|
+
children: e.leading
|
|
38
|
+
}) : null,
|
|
39
|
+
/* @__PURE__ */ r("span", {
|
|
40
|
+
className: "select-trigger-menu__label",
|
|
41
|
+
children: e.label
|
|
42
|
+
}),
|
|
43
|
+
e.description ? /* @__PURE__ */ r("span", {
|
|
44
|
+
className: "select-trigger-menu__desc",
|
|
45
|
+
children: e.description
|
|
46
|
+
}) : null,
|
|
47
|
+
e.tag ? /* @__PURE__ */ r("span", {
|
|
48
|
+
className: "select-trigger-menu__tag",
|
|
49
|
+
children: e.tag
|
|
50
|
+
}) : null
|
|
51
|
+
]
|
|
52
|
+
}, e.id)) : null
|
|
53
|
+
}),
|
|
54
|
+
v ? null : /* @__PURE__ */ r("div", {
|
|
55
|
+
className: "select-trigger-menu__note",
|
|
56
|
+
role: "status",
|
|
57
|
+
children: p ? g.triggerLoading : m ?? g.triggerEmpty
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function c(e, t, n, r) {
|
|
63
|
+
return {
|
|
64
|
+
"aria-autocomplete": "list",
|
|
65
|
+
"aria-controls": t ? e : void 0,
|
|
66
|
+
"aria-activedescendant": t && r > 0 ? o(e, Math.min(n, r - 1)) : void 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function l({ open: e, count: r, onPick: i, onClose: a }) {
|
|
70
|
+
let [o, s] = n(0);
|
|
71
|
+
return t(() => {
|
|
72
|
+
s(0);
|
|
73
|
+
}, [e, r]), {
|
|
74
|
+
active: Math.min(o, Math.max(0, r - 1)),
|
|
75
|
+
setActive: s,
|
|
76
|
+
onKeyDown: (t) => e ? t.key === "ArrowDown" || t.key === "ArrowUp" ? (t.preventDefault(), r > 0 && s((e) => (e + (t.key === "ArrowDown" ? 1 : r - 1)) % r), !0) : (t.key === "Enter" || t.key === "Tab") && !t.shiftKey && r > 0 ? (t.preventDefault(), i(Math.min(o, r - 1)), !0) : t.key === "Escape" && (t.preventDefault(), a(), !0) : !1
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function u(e, t, n) {
|
|
80
|
+
let r = Math.max(0, Math.min(t, e.length)), i = r;
|
|
81
|
+
for (; i > 0 && !/\s/.test(e[i - 1]);) --i;
|
|
82
|
+
let a = e.slice(i, r), o = n.find((e) => e.length > 0 && a.startsWith(e));
|
|
83
|
+
return o ? {
|
|
84
|
+
trigger: o,
|
|
85
|
+
query: a.slice(o.length),
|
|
86
|
+
start: i
|
|
87
|
+
} : null;
|
|
88
|
+
}
|
|
89
|
+
function d(e, t, n, r) {
|
|
90
|
+
return {
|
|
91
|
+
text: e.slice(0, t) + r + e.slice(n),
|
|
92
|
+
caret: t + r.length
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { s as SelectTriggerMenu, d as selectReplaceTrigger, u as selectTriggerAt, c as selectTriggerFieldProps, o as selectTriggerOptionId, l as useSelectTriggerMenu };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=SelectTriggerMenu.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,10 @@ export type { SelectHtmlFrameProps } from './SelectHtmlFrame';
|
|
|
107
107
|
export { SelectInbox, SelectInboxToolbar, SelectInboxEmpty, SelectInboxBanner, SelectMailboxStatus, SelectMailList, SelectMailListGroup, SelectMailListItem, SelectMailListSkeleton, SelectMailListNote, SelectMailReader, SelectMailMessage, SelectMailNotice, SelectMailAttachment, SelectLeadChip, SelectMailComposer, SelectMailComposerRow, SelectMailComposerInput, SelectMailComposerBody, SelectMailComposerFooter, SelectMailComposerAttachments, SelectMailAttachButton, SelectMailUpload, SelectRecipientInput, SelectTemplateMenu, attachmentExt, isMailAddress, mailName, } from './SelectMail';
|
|
108
108
|
export { SelectConversation, SelectConversationBubble, SelectConversationDay, SelectConversationEvent, SelectConversationMedia, SelectConversationNewer, SelectUnreadDivider, } from './SelectConversation';
|
|
109
109
|
export type { SelectConversationBubbleProps } from './SelectConversation';
|
|
110
|
+
export { SelectConversationNote, SelectMention, SelectMentionText, SelectNoteDot, SelectNoteField, selectMentionParts, } from './SelectConversationNote';
|
|
111
|
+
export type { SelectConversationNoteProps, SelectNoteFieldProps } from './SelectConversationNote';
|
|
112
|
+
export { SelectTriggerMenu, selectReplaceTrigger, selectTriggerAt, selectTriggerFieldProps, selectTriggerOptionId, useSelectTriggerMenu, } from './SelectTriggerMenu';
|
|
113
|
+
export type { SelectTrigger, SelectTriggerMenuOption, SelectTriggerMenuProps } from './SelectTriggerMenu';
|
|
110
114
|
export { SelectMessageTicks } from './SelectMessageTicks';
|
|
111
115
|
export type { SelectMessageStatus, SelectMessageTicksProps } from './SelectMessageTicks';
|
|
112
116
|
export { SelectConversationQuote } from './SelectConversationQuote';
|