@selectwin/kit 0.1.226 → 0.1.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SelectAppBar.d.ts +62 -0
- package/dist/SelectAppBar.js +136 -0
- package/dist/SelectAppFrame.d.ts +95 -0
- package/dist/SelectAppFrame.js +280 -0
- package/dist/SelectAppSearch.d.ts +34 -0
- package/dist/SelectAppSearch.js +192 -0
- package/dist/SelectLocale.d.ts +28 -0
- package/dist/SelectLocale.js +50 -0
- package/dist/SelectWorkspaceSwitcher.d.ts +5 -0
- package/dist/SelectWorkspaceSwitcher.js +11 -11
- package/dist/index.d.ts +6 -0
- package/dist/index.js +153 -150
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
export interface SelectAppBarProps extends Omit<ComponentPropsWithoutRef<'header'>, 'children'> {
|
|
3
|
+
/** O início: o logo é um link para ele, com este nome para o leitor de tela. */
|
|
4
|
+
home: {
|
|
5
|
+
to: string;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
/** O logo (a marca clara, a barra é escura). */
|
|
9
|
+
logo: ReactNode;
|
|
10
|
+
/** O botão do menu do celular (abaixo de 1024 px): abre a gaveta com as seções. */
|
|
11
|
+
menu?: {
|
|
12
|
+
expanded: boolean;
|
|
13
|
+
controls?: string;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
/** As páginas da seção aberta (`SelectAppPages`): a segunda linha da barra no celular. */
|
|
18
|
+
pages?: ReactNode;
|
|
19
|
+
/** A busca (`SelectAppSearch`): no centro, no computador; o ícone, no celular. */
|
|
20
|
+
search?: ReactNode;
|
|
21
|
+
/** As ferramentas à direita: os botões redondos e a conta. */
|
|
22
|
+
tools?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export declare const SelectAppBar: import('react').ForwardRefExoticComponent<SelectAppBarProps & import('react').RefAttributes<HTMLElement>>;
|
|
25
|
+
export interface SelectAppBarButtonProps extends Omit<ComponentPropsWithoutRef<'button'>, 'aria-label'> {
|
|
26
|
+
/** O nome do botão (só ícone): vai no leitor de tela e na dica. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** A dica com o nome, no mouse e no foco do teclado (padrão: sim). */
|
|
29
|
+
tooltip?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Um botão redondo da barra, só com o ícone (o tema, o menu do celular, a busca no celular). */
|
|
32
|
+
export declare const SelectAppBarButton: import('react').ForwardRefExoticComponent<SelectAppBarButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
export interface SelectAppBarAccountProps extends Omit<ComponentPropsWithoutRef<'button'>, 'children' | 'name'> {
|
|
34
|
+
/** A foto ou as iniciais (o `SelectAvatar`). */
|
|
35
|
+
avatar: ReactNode;
|
|
36
|
+
/** O nome de quem entrou (a partir de 768 px). */
|
|
37
|
+
name: ReactNode;
|
|
38
|
+
/** A linha de baixo: o papel. */
|
|
39
|
+
detail?: ReactNode;
|
|
40
|
+
/** O que o leitor de tela diz antes do nome ("Conta de"). */
|
|
41
|
+
srPrefix?: string;
|
|
42
|
+
}
|
|
43
|
+
/** A pílula da conta, à direita da barra: o avatar, o nome e o papel, e a seta. É o gatilho do menu da conta. */
|
|
44
|
+
export declare const SelectAppBarAccount: import('react').ForwardRefExoticComponent<SelectAppBarAccountProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
export interface SelectAppPage {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
to: string;
|
|
49
|
+
icon?: ReactNode;
|
|
50
|
+
/** A página aberta: `page`; a seção aberta que tem as páginas noutro menu (o menu da Operação): `true`. */
|
|
51
|
+
current?: 'page' | 'true';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* As PÁGINAS da seção aberta, na segunda linha da barra do celular: o ícone e o nome, a aberta em branco com a onda
|
|
55
|
+
* embaixo. A linha rola de lado (o esmaecido na borda diz que há mais) e a aberta fica à vista. A seção sem páginas
|
|
56
|
+
* mostra só ela: a barra sempre diz onde a pessoa está. Trocar de seção (`section`) remonta a linha, que entra num fade.
|
|
57
|
+
*/
|
|
58
|
+
export declare function SelectAppPages({ label, pages, section }: {
|
|
59
|
+
label?: string;
|
|
60
|
+
pages: readonly SelectAppPage[];
|
|
61
|
+
section?: string;
|
|
62
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ChevronDownIcon as e, MenuIcon as t } from "./icons.js";
|
|
2
|
+
import { SelectTooltip as n } from "./SelectTooltip.js";
|
|
3
|
+
import { useSelectMessages as r } from "./SelectLocale.js";
|
|
4
|
+
import { forwardRef as i, useEffect as a, useRef as o } from "react";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { Link as l } from "react-router-dom";
|
|
7
|
+
//#region src/SelectAppBar.tsx
|
|
8
|
+
var u = (...e) => e.filter(Boolean).join(" "), d = i(function({ home: e, logo: n, menu: i, pages: a, search: o, tools: d, className: p, ...m }, h) {
|
|
9
|
+
let g = r().appFrame;
|
|
10
|
+
return /* @__PURE__ */ s("header", {
|
|
11
|
+
ref: h,
|
|
12
|
+
...m,
|
|
13
|
+
className: u("select-appbar", p),
|
|
14
|
+
children: /* @__PURE__ */ c("div", {
|
|
15
|
+
className: "select-appbar__row",
|
|
16
|
+
children: [
|
|
17
|
+
i && /* @__PURE__ */ s(f, {
|
|
18
|
+
className: "select-appbar__menu",
|
|
19
|
+
label: i.label ?? g.menuOpen,
|
|
20
|
+
tooltip: !1,
|
|
21
|
+
"aria-haspopup": "dialog",
|
|
22
|
+
"aria-expanded": i.expanded,
|
|
23
|
+
"aria-controls": i.controls,
|
|
24
|
+
onClick: i.onClick,
|
|
25
|
+
children: /* @__PURE__ */ s(t, {})
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ s(l, {
|
|
28
|
+
to: e.to,
|
|
29
|
+
className: "select-appbar__home",
|
|
30
|
+
"aria-label": e.label,
|
|
31
|
+
children: n
|
|
32
|
+
}),
|
|
33
|
+
a,
|
|
34
|
+
o,
|
|
35
|
+
d != null && /* @__PURE__ */ s("div", {
|
|
36
|
+
className: "select-appbar__tools",
|
|
37
|
+
children: d
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}), f = i(function({ label: e, tooltip: t = !0, className: r, children: i, ...a }, o) {
|
|
43
|
+
let c = /* @__PURE__ */ s("button", {
|
|
44
|
+
ref: o,
|
|
45
|
+
type: "button",
|
|
46
|
+
...a,
|
|
47
|
+
"aria-label": e,
|
|
48
|
+
className: u("select-appbar__btn", r),
|
|
49
|
+
children: i
|
|
50
|
+
});
|
|
51
|
+
return t ? /* @__PURE__ */ s(n, {
|
|
52
|
+
content: e,
|
|
53
|
+
placement: "bottom",
|
|
54
|
+
children: c
|
|
55
|
+
}) : c;
|
|
56
|
+
}), p = i(function({ avatar: t, name: n, detail: r, srPrefix: i, className: a, ...o }, l) {
|
|
57
|
+
return /* @__PURE__ */ c("button", {
|
|
58
|
+
ref: l,
|
|
59
|
+
type: "button",
|
|
60
|
+
...o,
|
|
61
|
+
className: u("select-appbar__account", a),
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ s("span", {
|
|
64
|
+
className: "select-appbar__account-avatar",
|
|
65
|
+
children: t
|
|
66
|
+
}),
|
|
67
|
+
i ? /* @__PURE__ */ s("span", {
|
|
68
|
+
className: "select-visually-hidden",
|
|
69
|
+
children: i
|
|
70
|
+
}) : null,
|
|
71
|
+
/* @__PURE__ */ c("span", {
|
|
72
|
+
className: "select-appbar__account-text",
|
|
73
|
+
children: [/* @__PURE__ */ s("span", {
|
|
74
|
+
className: "select-appbar__account-name",
|
|
75
|
+
children: n
|
|
76
|
+
}), r != null && r !== "" ? /* @__PURE__ */ s("span", {
|
|
77
|
+
className: "select-appbar__account-detail",
|
|
78
|
+
children: r
|
|
79
|
+
}) : null]
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ s("span", {
|
|
82
|
+
className: "select-appbar__account-chevron",
|
|
83
|
+
"aria-hidden": "true",
|
|
84
|
+
children: /* @__PURE__ */ s(e, {})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
function m() {
|
|
90
|
+
return /* @__PURE__ */ s("svg", {
|
|
91
|
+
className: "select-appbar__wave",
|
|
92
|
+
viewBox: "0 0 148 13",
|
|
93
|
+
"aria-hidden": "true",
|
|
94
|
+
focusable: "false",
|
|
95
|
+
children: /* @__PURE__ */ s("path", { d: "M0 13C44 13 52 1 74 1S104 13 148 13Z" })
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function h({ label: e, pages: t, section: n }) {
|
|
99
|
+
var r;
|
|
100
|
+
let i = o(null), u = (r = t.find((e) => e.current)) == null ? void 0 : r.id;
|
|
101
|
+
return a(() => {
|
|
102
|
+
var e, t;
|
|
103
|
+
(e = i.current) == null || (e = e.querySelector("[aria-current]")) == null || (t = e.scrollIntoView) == null || t.call(e, {
|
|
104
|
+
block: "nearest",
|
|
105
|
+
inline: "nearest"
|
|
106
|
+
});
|
|
107
|
+
}, [u]), t.length === 0 ? /* @__PURE__ */ s("div", { className: "select-appbar__pages" }) : /* @__PURE__ */ s("nav", {
|
|
108
|
+
ref: i,
|
|
109
|
+
"aria-label": e,
|
|
110
|
+
className: "select-appbar__pages",
|
|
111
|
+
children: /* @__PURE__ */ s("div", {
|
|
112
|
+
className: "select-appbar__pagesrow",
|
|
113
|
+
children: t.map((e) => /* @__PURE__ */ c(l, {
|
|
114
|
+
to: e.to,
|
|
115
|
+
className: "select-appbar__page",
|
|
116
|
+
"aria-current": e.current,
|
|
117
|
+
children: [
|
|
118
|
+
e.icon != null && /* @__PURE__ */ s("span", {
|
|
119
|
+
className: "select-appbar__pageicon",
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
children: e.icon
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ s("span", {
|
|
124
|
+
className: "select-appbar__pagelabel",
|
|
125
|
+
children: e.label
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ s(m, {})
|
|
128
|
+
]
|
|
129
|
+
}, e.id))
|
|
130
|
+
}, n)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { d as SelectAppBar, p as SelectAppBarAccount, f as SelectAppBarButton, h as SelectAppPages };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=SelectAppBar.js.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import { SelectKitMessages } from './SelectLocale';
|
|
3
|
+
export interface SelectAppFrameProps extends ComponentPropsWithoutRef<'div'> {
|
|
4
|
+
/** O "Pular para o conteúdo": o primeiro Tab da página leva direto à coluna dela. */
|
|
5
|
+
skip?: {
|
|
6
|
+
to: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** O fundo escuro de toda a tela (o da barra: o painel claro sobe dele) e o atalho para o conteúdo. */
|
|
11
|
+
export declare function SelectAppFrame({ skip, className, children, ...rest }: SelectAppFrameProps): import("react").JSX.Element;
|
|
12
|
+
export interface SelectAppPanelProps extends ComponentPropsWithoutRef<'div'> {
|
|
13
|
+
/** O trilho das seções (`SelectAppRail`): no computador, numa coluna à esquerda; abaixo de 1024 px, some. */
|
|
14
|
+
rail?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/** O painel claro de cantos redondos, embaixo da barra: o trilho e a página. */
|
|
17
|
+
export declare function SelectAppPanel({ rail, className, children, ...rest }: SelectAppPanelProps): import("react").JSX.Element;
|
|
18
|
+
export interface SelectAppMainProps extends ComponentPropsWithoutRef<'main'> {
|
|
19
|
+
/**
|
|
20
|
+
* Um menu lateral da área (a Operação, com as páginas em grupos): uma coluna ao lado do conteúdo, embaixo do cabeçalho
|
|
21
|
+
* da página (o `<header>` da página ocupa a linha de cima de ponta a ponta). Abaixo de 1024 px, some.
|
|
22
|
+
*/
|
|
23
|
+
aside?: ReactNode;
|
|
24
|
+
/** O que fica no lugar do `aside` abaixo de 1024 px (um seletor das mesmas páginas), logo depois do cabeçalho. */
|
|
25
|
+
asideCompact?: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A coluna da página: a largura máxima, o respiro e o espaço embaixo para o botão do canto. Recebe o foco a cada
|
|
29
|
+
* navegação (`tabIndex={-1}` + `focus()` do app): quem usa leitor de tela ouve a página nova. O conteúdo novo entra num
|
|
30
|
+
* fade curto.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SelectAppMain: import('react').ForwardRefExoticComponent<SelectAppMainProps & import('react').RefAttributes<HTMLElement>>;
|
|
33
|
+
export interface SelectAppRailPage {
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
to: string;
|
|
37
|
+
/** A página aberta. */
|
|
38
|
+
current?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface SelectAppRailItem {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
/** O destino da seção (a primeira página dela). */
|
|
44
|
+
to: string;
|
|
45
|
+
icon?: ReactNode;
|
|
46
|
+
/** A seção aberta (o círculo fica nela). */
|
|
47
|
+
active?: boolean;
|
|
48
|
+
/** As páginas da seção: embaixo dela (expandido) ou num painel ao lado (recolhido). */
|
|
49
|
+
pages?: readonly SelectAppRailPage[];
|
|
50
|
+
}
|
|
51
|
+
export interface SelectAppRailProps {
|
|
52
|
+
/** O nome do menu para o leitor de tela ("Seções"). */
|
|
53
|
+
label: string;
|
|
54
|
+
/** Expandido (o nome e as páginas) ou recolhido (só os ícones). */
|
|
55
|
+
wide: boolean;
|
|
56
|
+
onToggle: () => void;
|
|
57
|
+
/** A pílula de cima: as seções. */
|
|
58
|
+
items: readonly SelectAppRailItem[];
|
|
59
|
+
/** A pílula de baixo (as configurações): o painel dela abre para cima. */
|
|
60
|
+
bottom?: readonly SelectAppRailItem[];
|
|
61
|
+
/** A tecla que alterna, fora de um campo de texto (padrão `[`; `false` desliga). */
|
|
62
|
+
shortcutKey?: string | false;
|
|
63
|
+
/** O ícone do botão do topo (padrão: o do menu). */
|
|
64
|
+
toggleIcon?: ReactNode;
|
|
65
|
+
/** Os textos, por cima dos do kit (`appFrame.rail`). */
|
|
66
|
+
messages?: Partial<SelectKitMessages['appFrame']['rail']>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* O TRILHO das seções, à esquerda do painel (o `AppRail` do `dashboard-web`): o botão do topo alterna o modo; as seções
|
|
70
|
+
* numa pílula; a de baixo (`bottom`) em outra, embaixo. Expandido, a seção aberta abre as páginas sozinha (e troca quando
|
|
71
|
+
* a rota troca de seção); recolhido, o painel das páginas fecha ao trocar de rota, ao clicar fora e no Esc.
|
|
72
|
+
*/
|
|
73
|
+
export declare function SelectAppRail({ label, wide, onToggle, items, bottom, shortcutKey, toggleIcon, messages }: SelectAppRailProps): import("react").JSX.Element;
|
|
74
|
+
export interface SelectAppDrawerProps {
|
|
75
|
+
id?: string;
|
|
76
|
+
open: boolean;
|
|
77
|
+
onClose: () => void;
|
|
78
|
+
/** O nome do menu para o leitor de tela. */
|
|
79
|
+
label: string;
|
|
80
|
+
/** A marca no topo da gaveta (ela cobre a barra). */
|
|
81
|
+
logo?: ReactNode;
|
|
82
|
+
/** O nome do botão de fechar (padrão: o do kit). */
|
|
83
|
+
closeLabel?: string;
|
|
84
|
+
/** O ícone do fechar (padrão: o do kit), para o app que tem o próprio jogo de ícones. */
|
|
85
|
+
closeIcon?: ReactNode;
|
|
86
|
+
/** A caixa de contexto embaixo da marca (a organização e o trocador de workspace). */
|
|
87
|
+
context?: ReactNode;
|
|
88
|
+
/** As seções (o `SelectSideNav`). */
|
|
89
|
+
children?: ReactNode;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* O MENU do celular: um `<dialog>` modal à esquerda, com a marca e o fechar, a caixa de contexto e as seções. O Esc e o
|
|
93
|
+
* clique fora fecham; o navegador devolve o foco a quem abriu.
|
|
94
|
+
*/
|
|
95
|
+
export declare function SelectAppDrawer({ id, open, onClose, label, logo, closeLabel, closeIcon, context, children }: SelectAppDrawerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { ChevronDownIcon as e, CloseIcon as t, MenuIcon as n } from "./icons.js";
|
|
2
|
+
import { useSelectMessages as r } from "./SelectLocale.js";
|
|
3
|
+
import { SelectIconButton as i } from "./SelectIconButton.js";
|
|
4
|
+
import { forwardRef as a, useEffect as o, useLayoutEffect as s, useRef as c, useState as l } from "react";
|
|
5
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
|
+
import { Link as p } from "react-router-dom";
|
|
7
|
+
//#region src/SelectAppFrame.tsx
|
|
8
|
+
var m = (...e) => e.filter(Boolean).join(" ");
|
|
9
|
+
function h({ skip: e, className: t, children: n, ...r }) {
|
|
10
|
+
return /* @__PURE__ */ f("div", {
|
|
11
|
+
...r,
|
|
12
|
+
className: m("select-appframe", t),
|
|
13
|
+
children: [e && /* @__PURE__ */ d("a", {
|
|
14
|
+
href: e.to,
|
|
15
|
+
className: "select-appframe__skip",
|
|
16
|
+
children: e.label
|
|
17
|
+
}), n]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function g({ rail: e, className: t, children: n, ...r }) {
|
|
21
|
+
return /* @__PURE__ */ f("div", {
|
|
22
|
+
...r,
|
|
23
|
+
className: m("select-appframe__panel", t),
|
|
24
|
+
children: [e, n]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var _ = a(function({ aside: e, asideCompact: t, className: n, children: r, ...i }, a) {
|
|
28
|
+
let o = e != null || t != null;
|
|
29
|
+
return /* @__PURE__ */ f("main", {
|
|
30
|
+
ref: a,
|
|
31
|
+
...i,
|
|
32
|
+
className: m("select-appframe__main", o && "select-appframe__main--aside", n),
|
|
33
|
+
children: [o && /* @__PURE__ */ f("div", {
|
|
34
|
+
className: "select-appframe__aside",
|
|
35
|
+
children: [e != null && /* @__PURE__ */ d("div", {
|
|
36
|
+
className: "select-appframe__asidenav",
|
|
37
|
+
children: e
|
|
38
|
+
}), t != null && /* @__PURE__ */ d("div", {
|
|
39
|
+
className: "select-appframe__asidecompact",
|
|
40
|
+
children: t
|
|
41
|
+
})]
|
|
42
|
+
}), r]
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
function v({ pages: e, onPick: t }) {
|
|
46
|
+
return /* @__PURE__ */ d(u, { children: e.map((e) => /* @__PURE__ */ d(p, {
|
|
47
|
+
to: e.to,
|
|
48
|
+
className: m("select-apprail__page", e.current && "is-active"),
|
|
49
|
+
"aria-current": e.current ? "page" : void 0,
|
|
50
|
+
onClick: t,
|
|
51
|
+
children: e.label
|
|
52
|
+
}, e.id)) });
|
|
53
|
+
}
|
|
54
|
+
function y({ items: t, wide: n, open: r, setOpen: i, flyout: a, setFlyout: l, up: u = !1, t: h }) {
|
|
55
|
+
var g, _;
|
|
56
|
+
let y = t.findIndex((e) => e.active), b = c(0);
|
|
57
|
+
y >= 0 && (b.current = y);
|
|
58
|
+
let x = n ? t.findIndex((e) => {
|
|
59
|
+
var t;
|
|
60
|
+
return e.id === r && (((t = e.pages) == null ? void 0 : t.length) ?? 0) > 0;
|
|
61
|
+
}) : -1, S = x >= 0 && x < b.current ? ((g = t[x].pages) == null ? void 0 : g.length) ?? 0 : 0, C = c(null), w = c(null), T = (_ = t.flatMap((e) => e.pages ?? []).find((e) => e.current)) == null ? void 0 : _.id;
|
|
62
|
+
return s(() => {
|
|
63
|
+
let e = w.current;
|
|
64
|
+
e && (e.style.setProperty("--rail-i", String(b.current)), e.style.setProperty("--rail-pn", String(S)), e.style.setProperty("--rail-pb", S > 0 ? "1" : "0"));
|
|
65
|
+
}), o(() => {
|
|
66
|
+
var e, t;
|
|
67
|
+
n && ((e = C.current) == null || (e = e.querySelector(".select-apprail__page[aria-current=\"page\"]")) == null || (t = e.scrollIntoView) == null || t.call(e, { block: "nearest" }));
|
|
68
|
+
}, [
|
|
69
|
+
T,
|
|
70
|
+
r,
|
|
71
|
+
n
|
|
72
|
+
]), /* @__PURE__ */ f("div", {
|
|
73
|
+
ref: C,
|
|
74
|
+
className: m("select-apprail__pill", n && "is-wide"),
|
|
75
|
+
children: [/* @__PURE__ */ d("span", {
|
|
76
|
+
ref: w,
|
|
77
|
+
className: m("select-apprail__ind", y >= 0 && "is-on"),
|
|
78
|
+
"aria-hidden": "true"
|
|
79
|
+
}), t.map((t) => {
|
|
80
|
+
let o = t.pages ?? [], s = o.length > 0, c = n && s && r === t.id, g = !n && s && a === t.id;
|
|
81
|
+
return /* @__PURE__ */ f("div", {
|
|
82
|
+
className: "select-apprail__slot",
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ f(p, {
|
|
85
|
+
to: t.to,
|
|
86
|
+
className: m("select-apprail__btn", t.active && "is-active"),
|
|
87
|
+
"aria-label": t.label,
|
|
88
|
+
"aria-current": t.active ? "true" : void 0,
|
|
89
|
+
"aria-expanded": s ? c || g : void 0,
|
|
90
|
+
onClick: (e) => {
|
|
91
|
+
if (!s) {
|
|
92
|
+
l(null);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!n) {
|
|
96
|
+
e.preventDefault(), l(g ? null : t.id);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
c && t.active && e.preventDefault(), i(c ? null : t.id);
|
|
100
|
+
},
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ d("span", {
|
|
103
|
+
className: "select-apprail__icon",
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
children: t.icon
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ d("span", {
|
|
108
|
+
className: "select-apprail__label",
|
|
109
|
+
"aria-hidden": "true",
|
|
110
|
+
children: t.label
|
|
111
|
+
}),
|
|
112
|
+
s && /* @__PURE__ */ d("span", {
|
|
113
|
+
className: m("select-apprail__chev", c && "is-open"),
|
|
114
|
+
"aria-hidden": "true",
|
|
115
|
+
children: /* @__PURE__ */ d(e, {})
|
|
116
|
+
}),
|
|
117
|
+
!n && !g && /* @__PURE__ */ f("span", {
|
|
118
|
+
className: "select-apprail__tip",
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
children: [/* @__PURE__ */ d("span", {
|
|
121
|
+
className: "select-apprail__name",
|
|
122
|
+
children: t.label
|
|
123
|
+
}), s && /* @__PURE__ */ d("span", {
|
|
124
|
+
className: "select-apprail__hint",
|
|
125
|
+
children: h.seePages
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
g && /* @__PURE__ */ f("div", {
|
|
131
|
+
className: m("select-apprail__fly", u && "select-apprail__fly--up"),
|
|
132
|
+
role: "group",
|
|
133
|
+
"aria-label": h.sectionPages(t.label),
|
|
134
|
+
children: [/* @__PURE__ */ d("span", {
|
|
135
|
+
className: "select-apprail__flytitle",
|
|
136
|
+
children: t.label
|
|
137
|
+
}), /* @__PURE__ */ d(v, {
|
|
138
|
+
pages: o,
|
|
139
|
+
onPick: () => l(null)
|
|
140
|
+
})]
|
|
141
|
+
}),
|
|
142
|
+
s && /* @__PURE__ */ d("div", {
|
|
143
|
+
className: m("select-apprail__pagesw", c && "is-open"),
|
|
144
|
+
children: /* @__PURE__ */ d("div", {
|
|
145
|
+
className: "select-apprail__pagesclip",
|
|
146
|
+
children: /* @__PURE__ */ d("div", {
|
|
147
|
+
className: "select-apprail__pages",
|
|
148
|
+
role: "group",
|
|
149
|
+
"aria-label": h.sectionPages(t.label),
|
|
150
|
+
children: /* @__PURE__ */ d(v, { pages: o })
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}, t.id);
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function b({ label: e, wide: t, onToggle: i, items: a, bottom: s = [], shortcutKey: u = "[", toggleIcon: p, messages: h }) {
|
|
160
|
+
var g, _;
|
|
161
|
+
let v = {
|
|
162
|
+
...r().appFrame.rail,
|
|
163
|
+
...h
|
|
164
|
+
}, b = [...a, ...s], x = ((g = b.find((e) => e.active)) == null ? void 0 : g.id) ?? null, S = ((_ = b.flatMap((e) => e.pages ?? []).find((e) => e.current)) == null ? void 0 : _.id) ?? null, [C, w] = l(x);
|
|
165
|
+
o(() => w(x), [x]);
|
|
166
|
+
let [T, E] = l(null), D = c(null);
|
|
167
|
+
o(() => E(null), [
|
|
168
|
+
x,
|
|
169
|
+
S,
|
|
170
|
+
t
|
|
171
|
+
]), o(() => {
|
|
172
|
+
if (!T) return;
|
|
173
|
+
let e = (e) => {
|
|
174
|
+
var t;
|
|
175
|
+
(t = D.current) != null && t.contains(e.target) || E(null);
|
|
176
|
+
}, t = (e) => {
|
|
177
|
+
e.key === "Escape" && E(null);
|
|
178
|
+
};
|
|
179
|
+
return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), () => {
|
|
180
|
+
document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t);
|
|
181
|
+
};
|
|
182
|
+
}, [T]);
|
|
183
|
+
let O = c(i);
|
|
184
|
+
O.current = i, o(() => {
|
|
185
|
+
if (!u) return;
|
|
186
|
+
let e = (e) => {
|
|
187
|
+
if (e.key !== u || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
188
|
+
let t = e.target;
|
|
189
|
+
t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) || O.current();
|
|
190
|
+
};
|
|
191
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
192
|
+
}, [u]);
|
|
193
|
+
let k = t ? v.collapse : v.expand, A = (e, n = !1) => /* @__PURE__ */ d(y, {
|
|
194
|
+
items: e,
|
|
195
|
+
wide: t,
|
|
196
|
+
open: C,
|
|
197
|
+
setOpen: w,
|
|
198
|
+
flyout: T,
|
|
199
|
+
setFlyout: E,
|
|
200
|
+
up: n,
|
|
201
|
+
t: v
|
|
202
|
+
});
|
|
203
|
+
return /* @__PURE__ */ f("nav", {
|
|
204
|
+
ref: D,
|
|
205
|
+
"aria-label": e,
|
|
206
|
+
className: m("select-apprail", t && "is-wide"),
|
|
207
|
+
children: [/* @__PURE__ */ f("div", {
|
|
208
|
+
className: "select-apprail__top",
|
|
209
|
+
children: [/* @__PURE__ */ f("button", {
|
|
210
|
+
type: "button",
|
|
211
|
+
className: "select-apprail__toggle",
|
|
212
|
+
"aria-expanded": t,
|
|
213
|
+
"aria-label": k,
|
|
214
|
+
onClick: i,
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ d("span", {
|
|
217
|
+
className: "select-apprail__icon",
|
|
218
|
+
"aria-hidden": "true",
|
|
219
|
+
children: p ?? /* @__PURE__ */ d(n, {})
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ d("span", {
|
|
222
|
+
className: "select-apprail__label",
|
|
223
|
+
"aria-hidden": "true",
|
|
224
|
+
children: k
|
|
225
|
+
}),
|
|
226
|
+
u && /* @__PURE__ */ d("kbd", {
|
|
227
|
+
className: "select-apprail__kbd",
|
|
228
|
+
"aria-hidden": "true",
|
|
229
|
+
children: u
|
|
230
|
+
}),
|
|
231
|
+
!t && /* @__PURE__ */ d("span", {
|
|
232
|
+
className: "select-apprail__tip",
|
|
233
|
+
"aria-hidden": "true",
|
|
234
|
+
children: /* @__PURE__ */ d("span", {
|
|
235
|
+
className: "select-apprail__name",
|
|
236
|
+
children: u ? v.shortcut(k, u) : k
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
]
|
|
240
|
+
}), a.length > 0 && A(a)]
|
|
241
|
+
}), s.length > 0 && A(s, !0)]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function x({ id: e, open: n, onClose: a, label: s, logo: l, closeLabel: u, closeIcon: p, context: m, children: h }) {
|
|
245
|
+
let g = r().appFrame, _ = c(null);
|
|
246
|
+
return o(() => {
|
|
247
|
+
var e, t;
|
|
248
|
+
let r = _.current;
|
|
249
|
+
r && (n && !r.open ? (e = r.showModal) == null || e.call(r) : !n && r.open && ((t = r.close) == null || t.call(r)));
|
|
250
|
+
}, [n]), /* @__PURE__ */ d("dialog", {
|
|
251
|
+
ref: _,
|
|
252
|
+
id: e,
|
|
253
|
+
"aria-label": s,
|
|
254
|
+
className: "select-appdrawer",
|
|
255
|
+
onClose: a,
|
|
256
|
+
onClick: (e) => e.target === e.currentTarget && a(),
|
|
257
|
+
children: /* @__PURE__ */ f("div", {
|
|
258
|
+
className: "select-appdrawer__box",
|
|
259
|
+
children: [
|
|
260
|
+
/* @__PURE__ */ f("div", {
|
|
261
|
+
className: "select-appdrawer__head",
|
|
262
|
+
children: [l, /* @__PURE__ */ d(i, {
|
|
263
|
+
label: u ?? g.drawerClose,
|
|
264
|
+
icon: p ?? /* @__PURE__ */ d(t, {}),
|
|
265
|
+
onClick: a
|
|
266
|
+
})]
|
|
267
|
+
}),
|
|
268
|
+
m != null && /* @__PURE__ */ d("div", {
|
|
269
|
+
className: "select-appdrawer__context",
|
|
270
|
+
children: m
|
|
271
|
+
}),
|
|
272
|
+
h
|
|
273
|
+
]
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { x as SelectAppDrawer, h as SelectAppFrame, _ as SelectAppMain, g as SelectAppPanel, b as SelectAppRail };
|
|
279
|
+
|
|
280
|
+
//# sourceMappingURL=SelectAppFrame.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SelectKitMessages } from './SelectLocale';
|
|
3
|
+
export interface SelectAppSearchItem {
|
|
4
|
+
/** Único em toda a lista (vira o id da opção). */
|
|
5
|
+
key: string;
|
|
6
|
+
title: string;
|
|
7
|
+
/** A linha de baixo: o que é (Página, Ação, Workspace) ou de onde é. */
|
|
8
|
+
sub?: string;
|
|
9
|
+
/** Um valor à direita (o valor de uma venda). */
|
|
10
|
+
meta?: string;
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** O título em fonte mono (um identificador colado). */
|
|
13
|
+
mono?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SelectAppSearchGroup<T extends SelectAppSearchItem = SelectAppSearchItem> {
|
|
16
|
+
title: string;
|
|
17
|
+
items: readonly T[];
|
|
18
|
+
}
|
|
19
|
+
export interface SelectAppSearchProps<T extends SelectAppSearchItem> {
|
|
20
|
+
query: string;
|
|
21
|
+
onQueryChange: (query: string) => void;
|
|
22
|
+
/** Os resultados do texto de agora (sem texto: as ações rápidas e os atalhos). Grupo vazio não aparece. */
|
|
23
|
+
groups: readonly SelectAppSearchGroup<T>[];
|
|
24
|
+
/** O escolhido (clique ou Enter). O kit fecha o painel e limpa o campo depois. */
|
|
25
|
+
onSelect: (item: T) => void;
|
|
26
|
+
/** A busca de fora ainda vem: "Buscando…" embaixo dos grupos. */
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
/** ⌘K / Ctrl K abre de qualquer tela (padrão: sim). */
|
|
29
|
+
shortcut?: boolean;
|
|
30
|
+
/** Os textos, por cima dos do kit (`appFrame.search`). */
|
|
31
|
+
messages?: Partial<SelectKitMessages['appFrame']['search']>;
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function SelectAppSearch<T extends SelectAppSearchItem>({ query, onQueryChange, groups: allGroups, onSelect, loading, shortcut, messages, className, }: SelectAppSearchProps<T>): import("react").JSX.Element;
|