@selectwin/kit 0.1.256 → 0.1.258
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 +57 -0
- package/dist/SelectActionList.d.ts +5 -0
- package/dist/SelectActionList.js +55 -39
- package/dist/SelectAppFrame.d.ts +8 -2
- package/dist/SelectAppFrame.js +124 -119
- package/dist/SelectAvatarGroup.d.ts +31 -0
- package/dist/SelectAvatarGroup.js +39 -0
- package/dist/SelectBadge.d.ts +1 -1
- package/dist/SelectChannelPreview.d.ts +15 -5
- package/dist/SelectChannelPreview.js +94 -54
- package/dist/SelectConversationNote.d.ts +37 -0
- package/dist/SelectConversationNote.js +93 -0
- package/dist/SelectFieldset.d.ts +14 -0
- package/dist/SelectFieldset.js +27 -0
- package/dist/SelectFilterBar.d.ts +6 -1
- package/dist/SelectFilterBar.js +153 -123
- package/dist/SelectImageUploadField.d.ts +5 -3
- package/dist/SelectImageUploadField.js +26 -26
- package/dist/SelectKanban.d.ts +13 -1
- package/dist/SelectKanban.js +72 -50
- package/dist/SelectLocale.d.ts +40 -0
- package/dist/SelectLocale.js +560 -511
- package/dist/SelectMail.d.ts +17 -2
- package/dist/SelectMail.js +9 -6
- package/dist/SelectModal.d.ts +10 -4
- package/dist/SelectModal.js +158 -137
- package/dist/SelectSegmented.d.ts +7 -0
- package/dist/SelectSegmented.js +51 -43
- package/dist/SelectSideNav.d.ts +2 -1
- package/dist/SelectSideNav.js +156 -135
- package/dist/SelectSortable.d.ts +47 -1
- package/dist/SelectSortable.js +138 -19
- package/dist/SelectSteps.d.ts +3 -0
- package/dist/SelectSteps.js +42 -31
- package/dist/SelectTimeline.d.ts +4 -0
- package/dist/SelectTimeline.js +20 -9
- package/dist/SelectTriggerMenu.d.ts +77 -0
- package/dist/SelectTriggerMenu.js +98 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +186 -182
- package/dist/internal/navCount.d.ts +21 -0
- package/dist/internal/navCount.js +27 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectSortable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, FocusEvent, KeyboardEvent, PointerEvent, ReactNode } from 'react';
|
|
2
2
|
type SelectSortableItemOwnProps = {
|
|
3
3
|
/** O item que está sendo arrastado: sobe por cima dos outros, com sombra. */
|
|
4
4
|
dragging?: boolean;
|
|
@@ -25,4 +25,50 @@ export declare const SelectDragHandle: import('react').ForwardRefExoticComponent
|
|
|
25
25
|
export declare function SelectDragPreview({ children }: {
|
|
26
26
|
children?: ReactNode;
|
|
27
27
|
}): import("react").JSX.Element;
|
|
28
|
+
/** 0.1.258: a lista com o item de `from` no lugar `to` (a conta do arrasto e a de quem grava). PURA. */
|
|
29
|
+
export declare function selectSortableOrder<T>(items: readonly T[], from: number, to: number): T[];
|
|
30
|
+
export interface SelectSortableOptions {
|
|
31
|
+
/** Os ids na ordem de agora. */
|
|
32
|
+
ids: readonly string[];
|
|
33
|
+
/** O item de `from` vai para `to` (a tela grava; `selectSortableOrder` faz a conta). */
|
|
34
|
+
onMove: (from: number, to: number) => void;
|
|
35
|
+
/** O nome do item, para a alça e o leitor de tela ("Nome"). Padrão: "item 2". */
|
|
36
|
+
getLabel?: (id: string, index: number) => string;
|
|
37
|
+
/** O eixo da lista: `y` (o padrão, as setas para cima e para baixo) ou `x` (para os lados). */
|
|
38
|
+
axis?: 'y' | 'x';
|
|
39
|
+
/** Nada se move (o só para ler). */
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** O que o `handle(id)` devolve: as props do `SelectDragHandle`. */
|
|
43
|
+
export interface SelectSortableHandleProps {
|
|
44
|
+
ref: (el: HTMLButtonElement | null) => void;
|
|
45
|
+
label: string;
|
|
46
|
+
dragging: boolean;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
'aria-describedby': string;
|
|
49
|
+
'aria-pressed': boolean;
|
|
50
|
+
onPointerDown: (event: PointerEvent<HTMLButtonElement>) => void;
|
|
51
|
+
onPointerMove: (event: PointerEvent<HTMLButtonElement>) => void;
|
|
52
|
+
onPointerUp: (event: PointerEvent<HTMLButtonElement>) => void;
|
|
53
|
+
onPointerCancel: (event: PointerEvent<HTMLButtonElement>) => void;
|
|
54
|
+
onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
55
|
+
onBlur: (event: FocusEvent<HTMLButtonElement>) => void;
|
|
56
|
+
}
|
|
57
|
+
/** O que o `item(id)` devolve: as props do `SelectSortableItem`. */
|
|
58
|
+
export interface SelectSortableItemBinding {
|
|
59
|
+
ref: (el: HTMLDivElement | null) => void;
|
|
60
|
+
dragging: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface SelectSortable {
|
|
63
|
+
/** Os ids na ordem da prévia (com o item no lugar novo enquanto se move): desenhe nesta ordem. */
|
|
64
|
+
order: string[];
|
|
65
|
+
/** O id do item que se move agora, ou `null`. */
|
|
66
|
+
active: string | null;
|
|
67
|
+
item: (id: string) => SelectSortableItemBinding;
|
|
68
|
+
handle: (id: string) => SelectSortableHandleProps;
|
|
69
|
+
/** As instruções e a região que fala: desenhe uma vez, perto da lista. */
|
|
70
|
+
live: ReactNode;
|
|
71
|
+
}
|
|
72
|
+
/** 0.1.258: a lista que se ordena pelo ponteiro (o mouse e o dedo) e pelo teclado, com os avisos ao leitor de tela. */
|
|
73
|
+
export declare function useSelectSortable({ ids, onMove, getLabel, axis, disabled }: SelectSortableOptions): SelectSortable;
|
|
28
74
|
export {};
|
package/dist/SelectSortable.js
CHANGED
|
@@ -1,31 +1,150 @@
|
|
|
1
1
|
import { GripIcon as e } from "./icons.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useSelectMessages as t } from "./SelectLocale.js";
|
|
3
|
+
import { forwardRef as n, useId as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
4
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
5
|
//#region src/SelectSortable.tsx
|
|
5
|
-
var
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
ref:
|
|
8
|
-
...
|
|
9
|
-
className: `select-sortitem${e && !t ? " is-dragging" : ""}${t ? " is-ghost" : ""}${
|
|
6
|
+
var u = n(function({ dragging: e = !1, ghost: t = !1, className: n, ...r }, i) {
|
|
7
|
+
return /* @__PURE__ */ c("div", {
|
|
8
|
+
ref: i,
|
|
9
|
+
...r,
|
|
10
|
+
className: `select-sortitem${e && !t ? " is-dragging" : ""}${t ? " is-ghost" : ""}${n ? " " + n : ""}`
|
|
10
11
|
});
|
|
11
|
-
}),
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
ref:
|
|
12
|
+
}), d = n(function({ dragging: t = !1, variant: n = "inline", label: r = "Arrastar para reordenar", className: i, ...a }, o) {
|
|
13
|
+
return /* @__PURE__ */ c("button", {
|
|
14
|
+
ref: o,
|
|
14
15
|
type: "button",
|
|
15
|
-
"aria-label":
|
|
16
|
-
title:
|
|
17
|
-
...
|
|
18
|
-
className: `select-draghandle${
|
|
19
|
-
children: /* @__PURE__ */
|
|
16
|
+
"aria-label": r,
|
|
17
|
+
title: r,
|
|
18
|
+
...a,
|
|
19
|
+
className: `select-draghandle${n === "floating" ? " select-draghandle--floating" : ""}${t ? " is-dragging" : ""}${i ? " " + i : ""}`,
|
|
20
|
+
children: /* @__PURE__ */ c(e, {})
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
|
-
function
|
|
23
|
-
return /* @__PURE__ */
|
|
23
|
+
function f({ children: t }) {
|
|
24
|
+
return /* @__PURE__ */ l("span", {
|
|
24
25
|
className: "select-dragpreview",
|
|
25
|
-
children: [/* @__PURE__ */
|
|
26
|
+
children: [/* @__PURE__ */ c(e, {}), t]
|
|
26
27
|
});
|
|
27
28
|
}
|
|
29
|
+
function p(e, t, n) {
|
|
30
|
+
let r = e.slice();
|
|
31
|
+
if (t === n || t < 0 || t >= r.length) return r;
|
|
32
|
+
let [i] = r.splice(t, 1);
|
|
33
|
+
return r.splice(Math.max(0, Math.min(n, r.length)), 0, i), r;
|
|
34
|
+
}
|
|
35
|
+
function m({ ids: e, onMove: n, getLabel: u, axis: d = "y", disabled: f = !1 }) {
|
|
36
|
+
let m = t().sortable, h = r(), g = a(/* @__PURE__ */ new Map()), _ = a(/* @__PURE__ */ new Map()), v = a([]), y = a(null), [b, x] = o(null), [S, C] = o("");
|
|
37
|
+
i(() => {
|
|
38
|
+
let e = y.current;
|
|
39
|
+
if (!e) return;
|
|
40
|
+
y.current = null;
|
|
41
|
+
let t = _.current.get(e);
|
|
42
|
+
t && document.activeElement !== t && t.focus({ preventScroll: !0 });
|
|
43
|
+
});
|
|
44
|
+
let w = e.length, T = b ? e.indexOf(b.id) : -1, E = b && T >= 0 ? b : null, D = E ? p(e, T, E.to) : e.slice(), O = (t) => {
|
|
45
|
+
let n = e.indexOf(t);
|
|
46
|
+
return (u == null ? void 0 : u(t, n)) ?? m.item(n + 1);
|
|
47
|
+
}, k = (e) => {
|
|
48
|
+
if (!E) {
|
|
49
|
+
x(null);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let t = O(E.id);
|
|
53
|
+
x(null), E.by === "keyboard" && (y.current = E.id), e && E.to !== T ? (n(T, E.to), C(m.dropped(t, E.to + 1, w))) : e ? E.by === "keyboard" && C(m.dropped(t, T + 1, w)) : C(m.canceled(t, T + 1));
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
order: D,
|
|
57
|
+
active: (E == null ? void 0 : E.id) ?? null,
|
|
58
|
+
item: (e) => ({
|
|
59
|
+
ref: (t) => {
|
|
60
|
+
t ? g.current.set(e, t) : g.current.delete(e);
|
|
61
|
+
},
|
|
62
|
+
dragging: (E == null ? void 0 : E.id) === e
|
|
63
|
+
}),
|
|
64
|
+
handle: (t) => {
|
|
65
|
+
let n = e.indexOf(t), r = (E == null ? void 0 : E.id) === t, i = r && (E == null ? void 0 : E.by) === "keyboard";
|
|
66
|
+
return {
|
|
67
|
+
ref: (e) => {
|
|
68
|
+
e ? _.current.set(t, e) : _.current.delete(t);
|
|
69
|
+
},
|
|
70
|
+
label: m.handle(O(t)),
|
|
71
|
+
dragging: r,
|
|
72
|
+
...f ? { disabled: !0 } : {},
|
|
73
|
+
"aria-describedby": h,
|
|
74
|
+
"aria-pressed": i,
|
|
75
|
+
onPointerDown: (r) => {
|
|
76
|
+
if (!(f || r.button !== 0 || E)) {
|
|
77
|
+
try {
|
|
78
|
+
var i, a;
|
|
79
|
+
(i = (a = r.currentTarget).setPointerCapture) == null || i.call(a, r.pointerId);
|
|
80
|
+
} catch {}
|
|
81
|
+
v.current = e.map((e) => {
|
|
82
|
+
var t;
|
|
83
|
+
let n = (t = g.current.get(e)) == null ? void 0 : t.getBoundingClientRect();
|
|
84
|
+
return n ? d === "y" ? n.top + n.height / 2 : n.left + n.width / 2 : 0;
|
|
85
|
+
}), x({
|
|
86
|
+
id: t,
|
|
87
|
+
to: n,
|
|
88
|
+
by: "pointer"
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
onPointerMove: (e) => {
|
|
93
|
+
if (!r || (E == null ? void 0 : E.by) !== "pointer") return;
|
|
94
|
+
let t = d === "y" ? e.clientY : e.clientX, n = v.current.filter((e, n) => n !== T && e < t).length;
|
|
95
|
+
n !== E.to && x({
|
|
96
|
+
...E,
|
|
97
|
+
to: n
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
onPointerUp: () => {
|
|
101
|
+
r && (E == null ? void 0 : E.by) === "pointer" && k(!0);
|
|
102
|
+
},
|
|
103
|
+
onPointerCancel: () => {
|
|
104
|
+
r && (E == null ? void 0 : E.by) === "pointer" && k(!1);
|
|
105
|
+
},
|
|
106
|
+
onKeyDown: (e) => {
|
|
107
|
+
if (f) return;
|
|
108
|
+
if (e.key === " " || e.key === "Enter") {
|
|
109
|
+
e.preventDefault(), i ? k(!0) : E || (x({
|
|
110
|
+
id: t,
|
|
111
|
+
to: n,
|
|
112
|
+
by: "keyboard"
|
|
113
|
+
}), C(m.grabbed(O(t), n + 1, w)));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!i || !E) return;
|
|
117
|
+
if (e.key === "Escape") {
|
|
118
|
+
e.preventDefault(), k(!1);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let r = d === "y" ? e.key === "ArrowUp" : e.key === "ArrowLeft", a = d === "y" ? e.key === "ArrowDown" : e.key === "ArrowRight";
|
|
122
|
+
if (!r && !a) return;
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
let o = Math.max(0, Math.min(w - 1, E.to + (a ? 1 : -1)));
|
|
125
|
+
o !== E.to && (y.current = t, x({
|
|
126
|
+
...E,
|
|
127
|
+
to: o
|
|
128
|
+
}), C(m.moved(O(t), o + 1, w)));
|
|
129
|
+
},
|
|
130
|
+
onBlur: () => {
|
|
131
|
+
i && y.current !== t && k(!1);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
live: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
|
|
136
|
+
id: h,
|
|
137
|
+
className: "select-visually-hidden",
|
|
138
|
+
children: m.instructions
|
|
139
|
+
}), /* @__PURE__ */ c("span", {
|
|
140
|
+
className: "select-visually-hidden",
|
|
141
|
+
"aria-live": "assertive",
|
|
142
|
+
"aria-atomic": "true",
|
|
143
|
+
children: S
|
|
144
|
+
})] })
|
|
145
|
+
};
|
|
146
|
+
}
|
|
28
147
|
//#endregion
|
|
29
|
-
export {
|
|
148
|
+
export { d as SelectDragHandle, f as SelectDragPreview, u as SelectSortableItem, p as selectSortableOrder, m as useSelectSortable };
|
|
30
149
|
|
|
31
150
|
//# sourceMappingURL=SelectSortable.js.map
|
package/dist/SelectSteps.d.ts
CHANGED
|
@@ -4,11 +4,14 @@ export type SelectStepState = 'done' | 'current' | 'error' | 'pending';
|
|
|
4
4
|
/**
|
|
5
5
|
* Um passo: só o rótulo, ou rótulo + descrição (a descrição só aparece na vertical) + o
|
|
6
6
|
* `state`, que vence o que sai do `current` (antes = feito, ele = atual, depois = pendente).
|
|
7
|
+
* 0.1.258: `locked` (o cadeado: a etapa automática) e `lockedLabel` (o que o leitor de tela ouve; padrão "automática").
|
|
7
8
|
*/
|
|
8
9
|
export type SelectStepItem = string | {
|
|
9
10
|
label: string;
|
|
10
11
|
description?: string;
|
|
11
12
|
state?: SelectStepState;
|
|
13
|
+
locked?: boolean;
|
|
14
|
+
lockedLabel?: string;
|
|
12
15
|
};
|
|
13
16
|
type SelectStepsOwnProps = {
|
|
14
17
|
steps: SelectStepItem[];
|
package/dist/SelectSteps.js
CHANGED
|
@@ -1,62 +1,73 @@
|
|
|
1
|
-
import { CheckIcon as e } from "./icons.js";
|
|
2
|
-
import { useSelectMessages as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Fragment as
|
|
1
|
+
import { CheckIcon as e, LockIcon as t } from "./icons.js";
|
|
2
|
+
import { useSelectMessages as n } from "./SelectLocale.js";
|
|
3
|
+
import { forwardRef as r } from "react";
|
|
4
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
5
|
//#region src/SelectSteps.tsx
|
|
6
|
-
var
|
|
7
|
-
let
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
-
ref:
|
|
10
|
-
...
|
|
11
|
-
className: `select-steps${
|
|
12
|
-
children:
|
|
13
|
-
let
|
|
6
|
+
var s = r(function({ steps: r, current: s, onSelect: c, orientation: l = "horizontal", connected: u = !1, className: d, ...f }, p) {
|
|
7
|
+
let m = n(), h = l === "vertical";
|
|
8
|
+
return /* @__PURE__ */ a("ol", {
|
|
9
|
+
ref: p,
|
|
10
|
+
...f,
|
|
11
|
+
className: `select-steps${h ? " select-steps--vertical" : ""}${u && !h ? " select-steps--connected" : ""}${d ? " " + d : ""}`,
|
|
12
|
+
children: r.map((n, r) => {
|
|
13
|
+
let l = typeof n == "string" ? { label: n } : n, u = l.state ?? (r < s ? "done" : r === s ? "current" : "pending"), d = !!c && r !== s && (u === "done" || u === "error"), f = /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("span", {
|
|
14
14
|
className: "select-steps__num",
|
|
15
15
|
"aria-hidden": "true",
|
|
16
|
-
children:
|
|
17
|
-
|
|
16
|
+
children: [u === "done" ? /* @__PURE__ */ a(e, {}) : u === "error" ? "!" : r + 1, l.locked ? /* @__PURE__ */ a("span", {
|
|
17
|
+
className: "select-steps__lock",
|
|
18
|
+
children: /* @__PURE__ */ a(t, {})
|
|
19
|
+
}) : null]
|
|
20
|
+
}), /* @__PURE__ */ o("span", {
|
|
18
21
|
className: "select-steps__text",
|
|
19
22
|
children: [
|
|
20
|
-
/* @__PURE__ */
|
|
23
|
+
/* @__PURE__ */ a("span", {
|
|
21
24
|
className: "select-steps__label",
|
|
22
|
-
children:
|
|
25
|
+
children: l.label
|
|
23
26
|
}),
|
|
24
|
-
l
|
|
27
|
+
l.locked && /* @__PURE__ */ o("span", {
|
|
25
28
|
className: "select-steps__sr",
|
|
26
29
|
children: [
|
|
27
30
|
"(",
|
|
28
|
-
|
|
31
|
+
l.lockedLabel ?? m.lock.label,
|
|
29
32
|
")"
|
|
30
33
|
]
|
|
31
34
|
}),
|
|
32
|
-
|
|
35
|
+
u === "error" && /* @__PURE__ */ o("span", {
|
|
33
36
|
className: "select-steps__sr",
|
|
34
37
|
children: [
|
|
35
38
|
"(",
|
|
36
|
-
|
|
39
|
+
m.common.needsAttention,
|
|
37
40
|
")"
|
|
38
41
|
]
|
|
39
42
|
}),
|
|
40
|
-
|
|
43
|
+
u === "done" && /* @__PURE__ */ o("span", {
|
|
44
|
+
className: "select-steps__sr",
|
|
45
|
+
children: [
|
|
46
|
+
"(",
|
|
47
|
+
m.common.done,
|
|
48
|
+
")"
|
|
49
|
+
]
|
|
50
|
+
}),
|
|
51
|
+
h && l.description && /* @__PURE__ */ a("span", {
|
|
41
52
|
className: "select-steps__desc",
|
|
42
|
-
children:
|
|
53
|
+
children: l.description
|
|
43
54
|
})
|
|
44
55
|
]
|
|
45
56
|
})] });
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
className: `select-steps__step select-steps__step--${
|
|
48
|
-
"aria-current":
|
|
49
|
-
children:
|
|
57
|
+
return /* @__PURE__ */ a("li", {
|
|
58
|
+
className: `select-steps__step select-steps__step--${u === "pending" ? "todo" : u}`,
|
|
59
|
+
"aria-current": u === "current" ? "step" : void 0,
|
|
60
|
+
children: d ? /* @__PURE__ */ a("button", {
|
|
50
61
|
type: "button",
|
|
51
62
|
className: "select-steps__btn",
|
|
52
|
-
onClick: () =>
|
|
53
|
-
children:
|
|
54
|
-
}) :
|
|
55
|
-
},
|
|
63
|
+
onClick: () => c(r),
|
|
64
|
+
children: f
|
|
65
|
+
}) : f
|
|
66
|
+
}, r);
|
|
56
67
|
})
|
|
57
68
|
});
|
|
58
69
|
});
|
|
59
70
|
//#endregion
|
|
60
|
-
export {
|
|
71
|
+
export { s as SelectSteps };
|
|
61
72
|
|
|
62
73
|
//# sourceMappingURL=SelectSteps.js.map
|
package/dist/SelectTimeline.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export interface SelectTimelineItem {
|
|
|
8
8
|
tone?: SelectTimelineTone;
|
|
9
9
|
/** Selo ao lado do título. */
|
|
10
10
|
badge?: ReactNode;
|
|
11
|
+
/** 0.1.258: o ícone do marcador (o tipo do evento), no lugar do ponto, no tom do evento. */
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
/** 0.1.258: o tipo do evento para o leitor de tela, antes do título ("Ligação"). O ícone fica fora da leitura. */
|
|
14
|
+
iconLabel?: string;
|
|
11
15
|
}
|
|
12
16
|
type SelectTimelineOwnProps = {
|
|
13
17
|
items: SelectTimelineItem[];
|
package/dist/SelectTimeline.js
CHANGED
|
@@ -19,22 +19,26 @@ var r = {
|
|
|
19
19
|
let f = {
|
|
20
20
|
"--tl-final": r[e.length ? ((d = e[0]) == null ? void 0 : d.tone) ?? "default" : "default"],
|
|
21
21
|
...c
|
|
22
|
-
}, p = a === "each", m = o === "start";
|
|
22
|
+
}, p = a === "each", m = o === "start", h = e.some((e) => e.icon != null && e.icon !== !1);
|
|
23
23
|
return /* @__PURE__ */ t("ul", {
|
|
24
24
|
ref: u,
|
|
25
25
|
...l,
|
|
26
|
-
className: `select-timeline${p ? " select-timeline--each" : ""}${m ? " select-timeline--timestart" : ""}${s ? " " + s : ""}`,
|
|
26
|
+
className: `select-timeline${p ? " select-timeline--each" : ""}${m ? " select-timeline--timestart" : ""}${h ? " select-timeline--icons" : ""}${s ? " " + s : ""}`,
|
|
27
27
|
style: f,
|
|
28
28
|
children: e.map((e, r) => {
|
|
29
|
-
let a = !p && r === 0, o = p ? { "--tl-dot": i[e.tone ?? "default"] } : void 0;
|
|
29
|
+
let a = !p && r === 0, o = p ? { "--tl-dot": i[e.tone ?? "default"] } : void 0, s = e.icon != null && e.icon !== !1;
|
|
30
30
|
return /* @__PURE__ */ n("li", {
|
|
31
|
-
className: "select-timeline__item"
|
|
31
|
+
className: `select-timeline__item${s ? " select-timeline__item--icon" : ""}`,
|
|
32
32
|
children: [
|
|
33
33
|
m && e.timestamp != null && /* @__PURE__ */ t("span", {
|
|
34
34
|
className: "select-timeline__when",
|
|
35
35
|
children: e.timestamp
|
|
36
36
|
}),
|
|
37
|
-
/* @__PURE__ */ t("span", {
|
|
37
|
+
s ? /* @__PURE__ */ t("span", {
|
|
38
|
+
className: `select-timeline__marker select-timeline__marker--${e.tone ?? "default"}`,
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
children: e.icon
|
|
41
|
+
}) : /* @__PURE__ */ t("span", {
|
|
38
42
|
className: `select-timeline__dot${a ? " select-timeline__dot--final" : ""}${p ? " select-timeline__dot--toned" : ""}`,
|
|
39
43
|
style: o,
|
|
40
44
|
"aria-hidden": "true"
|
|
@@ -46,10 +50,17 @@ var r = {
|
|
|
46
50
|
className: "select-timeline__head",
|
|
47
51
|
children: [/* @__PURE__ */ n("span", {
|
|
48
52
|
className: "select-timeline__title",
|
|
49
|
-
children: [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
children: [
|
|
54
|
+
e.iconLabel ? /* @__PURE__ */ t("span", {
|
|
55
|
+
className: "select-visually-hidden",
|
|
56
|
+
children: `${e.iconLabel}: `
|
|
57
|
+
}) : null,
|
|
58
|
+
e.title,
|
|
59
|
+
e.badge != null && /* @__PURE__ */ t("span", {
|
|
60
|
+
className: "select-timeline__badge",
|
|
61
|
+
children: e.badge
|
|
62
|
+
})
|
|
63
|
+
]
|
|
53
64
|
}), !m && e.timestamp != null && /* @__PURE__ */ t("span", {
|
|
54
65
|
className: "select-timeline__time",
|
|
55
66
|
children: e.timestamp
|
|
@@ -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
|
@@ -57,6 +57,13 @@ export { SelectText } from './SelectText';
|
|
|
57
57
|
export { SelectBox, SelectStack, SelectInline, SelectGrid } from './SelectLayout';
|
|
58
58
|
export { SelectScrollArea } from './SelectScrollArea';
|
|
59
59
|
export type { SelectScrollAreaProps, SelectScrollAreaElement, SelectScrollAxis } from './SelectScrollArea';
|
|
60
|
+
export { SelectAvatarGroup } from './SelectAvatarGroup';
|
|
61
|
+
export type { SelectAvatarGroupProps, SelectAvatarGroupPerson } from './SelectAvatarGroup';
|
|
62
|
+
export { SelectFieldset } from './SelectFieldset';
|
|
63
|
+
export type { SelectFieldsetProps } from './SelectFieldset';
|
|
64
|
+
export type { SelectNavCount } from './internal/navCount';
|
|
65
|
+
export { useSelectSortable, selectSortableOrder } from './SelectSortable';
|
|
66
|
+
export type { SelectSortable, SelectSortableOptions, SelectSortableHandleProps, SelectSortableItemBinding } from './SelectSortable';
|
|
60
67
|
export { SelectPage, SelectPageBackProvider, SelectPageHeader } from './SelectPage';
|
|
61
68
|
export { SelectFormLayout } from './SelectFormLayout';
|
|
62
69
|
export { SelectSkeleton } from './SelectSkeleton';
|
|
@@ -107,6 +114,10 @@ export type { SelectHtmlFrameProps } from './SelectHtmlFrame';
|
|
|
107
114
|
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
115
|
export { SelectConversation, SelectConversationBubble, SelectConversationDay, SelectConversationEvent, SelectConversationMedia, SelectConversationNewer, SelectUnreadDivider, } from './SelectConversation';
|
|
109
116
|
export type { SelectConversationBubbleProps } from './SelectConversation';
|
|
117
|
+
export { SelectConversationNote, SelectMention, SelectMentionText, SelectNoteDot, SelectNoteField, selectMentionParts, } from './SelectConversationNote';
|
|
118
|
+
export type { SelectConversationNoteProps, SelectNoteFieldProps } from './SelectConversationNote';
|
|
119
|
+
export { SelectTriggerMenu, selectReplaceTrigger, selectTriggerAt, selectTriggerFieldProps, selectTriggerOptionId, useSelectTriggerMenu, } from './SelectTriggerMenu';
|
|
120
|
+
export type { SelectTrigger, SelectTriggerMenuOption, SelectTriggerMenuProps } from './SelectTriggerMenu';
|
|
110
121
|
export { SelectMessageTicks } from './SelectMessageTicks';
|
|
111
122
|
export type { SelectMessageStatus, SelectMessageTicksProps } from './SelectMessageTicks';
|
|
112
123
|
export { SelectConversationQuote } from './SelectConversationQuote';
|