@selectwin/kit 0.1.231 → 0.1.232

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 CHANGED
@@ -1,52 +1,58 @@
1
- # @selectwin/kit
2
-
3
- Design system da Selectwin — primitivos React, charts SVG (sem dependência de biblioteca de
4
- gráficos) e tokens CSS, theme-aware (light/dark).
5
-
6
- Uso interno da Selectwin. Publicado no npm para facilitar a distribuição entre os apps da casa;
7
- não há suporte, documentação pública nem garantia de estabilidade de API para terceiros.
8
-
9
- ## Uso
10
-
11
- ```bash
12
- npm i @selectwin/kit
13
- ```
14
-
15
- ```tsx
16
- import '@selectwin/kit/styles.css'; // tokens + estilos (uma vez, no root)
17
- import { SelectButton, SelectSection } from '@selectwin/kit';
18
- ```
19
-
20
- Idioma (0.1.187): os textos próprios do kit ("Página anterior", "Mais filtros", "Fechar"…) e os números que ele
21
- formata saem em português. Para inglês, envolva o app no `SelectLocaleProvider`:
22
-
23
- ```tsx
24
- import { SelectLocaleProvider } from '@selectwin/kit';
25
-
26
- <SelectLocaleProvider locale="en">{app}</SelectLocaleProvider>; // 'pt-BR' | 'en'
27
- ```
28
-
29
- A prop de texto do componente (`confirmLabel`, `noun`…) sempre ganha do dicionário.
30
-
31
- Tom corporativo (0.1.188; arredondado suave no botão desde a 0.1.192, em tudo desde a 0.1.193 e bem suave desde a
32
- 0.1.195): campo e botão com 1rem (`--select-radius`, `--select-radius-button`), card 1.5rem, caixa de dentro e menu
33
- 1rem, item de menu 0.75rem (`--select-radius-sm`); pílula só em selo. Rótulos de KPI
34
- e cabeçalho de tabela em caixa-alta espaçada. Nos gráficos, cor é situação: verde `--select-chart-paid` = pago, dourado
35
- `--select-chart-pending` (+ `-edge`) = pendente, `--select-chart-compare` = o período anterior, e os cinzas
36
- `--select-chart-ramp-1..4` para categoria. O app que quer o visual antigo sobrescreve esses tokens.
37
-
38
- O card mostra o dado; a explicação vai no tooltip (0.1.196). O "i" `help` está no `SelectSection`, no
39
- `SelectDataTable`, no `SelectChartCard`, no `SelectKpiCard`, no `SelectListCard`, em cada número do `SelectMiniStats` e
40
- em cada balde do `SelectBalanceCard`. Na `SelectShareBar`, cada faixa tem o seu tooltip, e a nota da parte vai em
41
- `tip`; o que o clique faz vai em `selectHint`/`clearHint`, no lugar da linha `hint`.
42
-
43
- Peer deps: **react**, **react-dom** (obrigatórios); **gsap** (opcional — só componentes animados),
44
- **react-router-dom** (opcional). Tematização = sobrescrever os tokens CSS `--select-*` / `--sw-*`.
45
-
46
- ## Build
47
-
48
- ```bash
49
- npm run build # → dist/index.js (o barril) + um módulo ESM por componente + dist/style.css + os .d.ts
50
- ```
51
-
52
- `npm publish` roda `prepublishOnly` (= build) e publica só `dist/` (sem sourcemaps).
1
+ # @selectwin/kit
2
+
3
+ Design system da Selectwin — primitivos React, charts SVG (sem dependência de biblioteca de
4
+ gráficos) e tokens CSS, theme-aware (light/dark).
5
+
6
+ Uso interno da Selectwin. Publicado no npm para facilitar a distribuição entre os apps da casa;
7
+ não há suporte, documentação pública nem garantia de estabilidade de API para terceiros.
8
+
9
+ ## Uso
10
+
11
+ ```bash
12
+ npm i @selectwin/kit
13
+ ```
14
+
15
+ ```tsx
16
+ import '@selectwin/kit/styles.css'; // tokens + estilos (uma vez, no root)
17
+ import { SelectButton, SelectSection } from '@selectwin/kit';
18
+ ```
19
+
20
+ Idioma (0.1.187): os textos próprios do kit ("Página anterior", "Mais filtros", "Fechar"…) e os números que ele
21
+ formata saem em português. Para inglês, envolva o app no `SelectLocaleProvider`:
22
+
23
+ ```tsx
24
+ import { SelectLocaleProvider } from '@selectwin/kit';
25
+
26
+ <SelectLocaleProvider locale="en">{app}</SelectLocaleProvider>; // 'pt-BR' | 'en'
27
+ ```
28
+
29
+ A prop de texto do componente (`confirmLabel`, `noun`…) sempre ganha do dicionário.
30
+
31
+ Tom corporativo (0.1.188; arredondado suave no botão desde a 0.1.192, em tudo desde a 0.1.193 e bem suave desde a
32
+ 0.1.195): campo e botão com 1rem (`--select-radius`, `--select-radius-button`), card 1.5rem, caixa de dentro e menu
33
+ 1rem, item de menu 0.75rem (`--select-radius-sm`); pílula só em selo. Rótulos de KPI
34
+ e cabeçalho de tabela em caixa-alta espaçada. Nos gráficos, cor é situação: verde `--select-chart-paid` = pago, dourado
35
+ `--select-chart-pending` (+ `-edge`) = pendente, `--select-chart-compare` = o período anterior, e os cinzas
36
+ `--select-chart-ramp-1..4` para categoria. O app que quer o visual antigo sobrescreve esses tokens.
37
+
38
+ O card mostra o dado; a explicação vai no tooltip (0.1.196). O "i" `help` está no `SelectSection`, no
39
+ `SelectDataTable`, no `SelectChartCard`, no `SelectKpiCard`, no `SelectListCard`, em cada número do `SelectMiniStats` e
40
+ em cada balde do `SelectBalanceCard`. Na `SelectShareBar`, cada faixa tem o seu tooltip, e a nota da parte vai em
41
+ `tip`; o que o clique faz vai em `selectHint`/`clearHint`, no lugar da linha `hint`.
42
+
43
+ O tutorial flutuante (0.1.232): o `SelectTutorial` é um cartão no canto de baixo à esquerda (o direito é do
44
+ `SelectAssistant`) que abre um vídeo curto, sempre no tema OPOSTO ao do painel, para se destacar — os tokens
45
+ `--select-tutorial-*`, invertidos no bloco do escuro. O vídeo expande para o centro da tela sem recomeçar, e o selo
46
+ "Visto" acende sozinho quando ele termina (`watched` manda, quando vem). Abrir, fechar de vez (`onDismiss`) e guardar o
47
+ que foi visto são de quem usa.
48
+
49
+ Peer deps: **react**, **react-dom** (obrigatórios); **gsap** (opcional — só componentes animados),
50
+ **react-router-dom** (opcional). Tematização = sobrescrever os tokens CSS `--select-*` / `--sw-*`.
51
+
52
+ ## Build
53
+
54
+ ```bash
55
+ npm run build # → dist/index.js (o barril) + um módulo ESM por componente + dist/style.css + os .d.ts
56
+ ```
57
+
58
+ `npm publish` roda `prepublishOnly` (= build) e publica só `dist/` (sem sourcemaps).
@@ -73,6 +73,15 @@ export interface SelectKitMessages {
73
73
  input: string;
74
74
  typing: string;
75
75
  };
76
+ /** 0.1.232: o SelectTutorial. */
77
+ tutorial: {
78
+ dismiss: string;
79
+ expand: string;
80
+ shrink: string;
81
+ watched: string;
82
+ /** O nome do cartão e do vídeo grande quando o título não é texto. */
83
+ video: string;
84
+ };
76
85
  chipInput: {
77
86
  limit: (max: string) => string;
78
87
  };
@@ -70,6 +70,13 @@ var r = {
70
70
  input: "Sua pergunta",
71
71
  typing: "Escrevendo…"
72
72
  },
73
+ tutorial: {
74
+ dismiss: "Fechar o tutorial",
75
+ expand: "Expandir o vídeo",
76
+ shrink: "Reduzir",
77
+ watched: "Visto",
78
+ video: "Vídeo do tutorial"
79
+ },
73
80
  chipInput: { limit: (e) => `Limite de ${e} atingido.` },
74
81
  factStrip: {
75
82
  done: "feito",
@@ -235,6 +242,13 @@ var r = {
235
242
  input: "Your question",
236
243
  typing: "Typing…"
237
244
  },
245
+ tutorial: {
246
+ dismiss: "Close the tutorial",
247
+ expand: "Expand the video",
248
+ shrink: "Shrink",
249
+ watched: "Watched",
250
+ video: "Tutorial video"
251
+ },
238
252
  chipInput: { limit: (e) => `Limit of ${e} reached.` },
239
253
  factStrip: {
240
254
  done: "done",
@@ -0,0 +1,48 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SelectTutorialVideo {
3
+ src: string;
4
+ /** A imagem de capa, antes do play. */
5
+ poster?: string;
6
+ /** O tipo do arquivo (`video/mp4`): o navegador escolhe sem baixar. */
7
+ type?: string;
8
+ /** As legendas, em WebVTT. */
9
+ captions?: {
10
+ src: string;
11
+ srcLang?: string;
12
+ label?: string;
13
+ };
14
+ }
15
+ export interface SelectTutorialProps {
16
+ /** A linha de cima ("Tutorial · Primeiros passos"). */
17
+ kicker?: ReactNode;
18
+ title: ReactNode;
19
+ /** O texto sob o vídeo. */
20
+ description?: ReactNode;
21
+ /** O vídeo (com os controles do navegador). */
22
+ video?: SelectTutorialVideo;
23
+ /** Outro conteúdo no lugar do vídeo (uma imagem, um player embutido), na mesma moldura 16:9. */
24
+ media?: ReactNode;
25
+ /** O selo da aula, no canto do vídeo ("Aula 01"). */
26
+ badge?: ReactNode;
27
+ /** Já assistido: o selo "Visto". Sem a prop, ele acende sozinho quando o vídeo termina. */
28
+ watched?: boolean;
29
+ /** O vídeo terminou — para quem chama guardar que foi visto. */
30
+ onEnded?: () => void;
31
+ /** Aberto (controlado). Sem ele, o cartão guarda o próprio estado, a partir de `defaultOpen`. */
32
+ open?: boolean;
33
+ defaultOpen?: boolean;
34
+ onOpenChange?: (open: boolean) => void;
35
+ /** O "X" do cartão fechado: quem chama tira o cartão (e guarda que foi fechado). Sem ele, não há "X". */
36
+ onDismiss?: () => void;
37
+ /** O canto de baixo: `left` (padrão) ou `right`. */
38
+ side?: 'left' | 'right';
39
+ /** `viewport` (padrão) prende à janela do navegador; `container`, ao ancestral posicionado. */
40
+ anchor?: 'viewport' | 'container';
41
+ /** Nomes acessíveis — o padrão vem do idioma do kit. */
42
+ dismissLabel?: string;
43
+ expandLabel?: string;
44
+ shrinkLabel?: string;
45
+ watchedLabel?: string;
46
+ className?: string;
47
+ }
48
+ export declare function SelectTutorial({ kicker, title, description, video, media, badge, watched, onEnded, open: openProp, defaultOpen, onOpenChange, onDismiss, side, anchor, dismissLabel: dismissLabelProp, expandLabel: expandLabelProp, shrinkLabel: shrinkLabelProp, watchedLabel: watchedLabelProp, className, }: SelectTutorialProps): import("react").JSX.Element;
@@ -0,0 +1,184 @@
1
+ /* empty css */
2
+ import { CheckIcon as e, ChevronDownIcon as t, CloseIcon as n, ExpandIcon as r, PlayIcon as ee, ShrinkIcon as te } from "./icons.js";
3
+ import { useSelectMessages as i } from "./SelectLocale.js";
4
+ import { useFocusTrap as a } from "./internal/useFocusTrap.js";
5
+ import { inertProps as o } from "./internal/inert.js";
6
+ import { useEffect as s, useId as ne, useRef as c, useState as l } from "react";
7
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
8
+ //#region src/SelectTutorial.tsx
9
+ function f(e) {
10
+ try {
11
+ e && !e.paused && e.pause();
12
+ } catch {}
13
+ }
14
+ function p({ kicker: p, title: m, description: h, video: g, media: _, badge: v, watched: y, onEnded: b, open: x, defaultOpen: S = !1, onOpenChange: C, onDismiss: w, side: T = "left", anchor: E = "viewport", dismissLabel: D, expandLabel: O, shrinkLabel: k, watchedLabel: A, className: j }) {
15
+ let M = i(), N = D ?? M.tutorial.dismiss, P = O ?? M.tutorial.expand, F = k ?? M.tutorial.shrink, I = A ?? M.tutorial.watched, [L, R] = l(S), z = x ?? L, B = (e) => {
16
+ x === void 0 && R(e), C == null || C(e);
17
+ }, [V, H] = l(!1), [U, W] = l(!1), G = y ?? U, K = ne(), q = c(null), J = c(null), Y = c(null), X = c(null), re = g != null || _ != null;
18
+ a(V, Y), s(() => {
19
+ z || (H(!1), f(X.current));
20
+ }, [z]), s(() => () => f(X.current), []);
21
+ let Z = c(!1);
22
+ s(() => {
23
+ var e;
24
+ !V && Z.current && (Z.current = !1, (e = J.current) == null || e.focus());
25
+ }, [V]);
26
+ let Q = () => {
27
+ Z.current = !0, H(!1);
28
+ }, ie = (e) => {
29
+ if (e.key === "Escape") {
30
+ if (V) e.stopPropagation(), Q();
31
+ else if (z) {
32
+ var t;
33
+ e.stopPropagation(), B(!1), (t = q.current) == null || t.focus();
34
+ }
35
+ }
36
+ }, ae = () => {
37
+ f(X.current), w == null || w();
38
+ }, $ = typeof m == "string" ? m : M.tutorial.video;
39
+ return /* @__PURE__ */ d("div", {
40
+ className: "select-tutorial" + (T === "right" ? " select-tutorial--right" : "") + (E === "container" ? " select-tutorial--container" : "") + (z ? " is-open" : "") + (V ? " is-theater" : "") + (j ? " " + j : ""),
41
+ onKeyDown: ie,
42
+ children: [V && /* @__PURE__ */ u("div", {
43
+ className: "select-tutorial__scrim",
44
+ "aria-hidden": "true",
45
+ onClick: Q
46
+ }), /* @__PURE__ */ d("section", {
47
+ className: "select-tutorial__card",
48
+ "aria-label": $,
49
+ children: [/* @__PURE__ */ d("div", {
50
+ className: "select-tutorial__head",
51
+ children: [/* @__PURE__ */ d("button", {
52
+ ref: q,
53
+ type: "button",
54
+ className: "select-tutorial__toggle",
55
+ "aria-expanded": z,
56
+ "aria-controls": K,
57
+ onClick: () => B(!z),
58
+ children: [
59
+ /* @__PURE__ */ u("span", {
60
+ className: "select-tutorial__play",
61
+ "aria-hidden": "true",
62
+ children: /* @__PURE__ */ u(ee, {})
63
+ }),
64
+ /* @__PURE__ */ d("span", {
65
+ className: "select-tutorial__heading",
66
+ children: [p != null && /* @__PURE__ */ u("span", {
67
+ className: "select-tutorial__kicker",
68
+ children: p
69
+ }), /* @__PURE__ */ u("span", {
70
+ className: "select-tutorial__title",
71
+ children: m
72
+ })]
73
+ }),
74
+ /* @__PURE__ */ u("span", {
75
+ className: "select-tutorial__chevron",
76
+ "aria-hidden": "true",
77
+ children: /* @__PURE__ */ u(t, {})
78
+ })
79
+ ]
80
+ }), w && !z && /* @__PURE__ */ u("button", {
81
+ type: "button",
82
+ className: "select-tutorial__dismiss",
83
+ onClick: ae,
84
+ "aria-label": N,
85
+ title: N,
86
+ children: /* @__PURE__ */ u(n, {})
87
+ })]
88
+ }), /* @__PURE__ */ u("div", {
89
+ id: K,
90
+ className: "select-tutorial__body",
91
+ ...o(!z),
92
+ children: /* @__PURE__ */ u("div", {
93
+ className: "select-tutorial__inner",
94
+ children: /* @__PURE__ */ d("div", {
95
+ className: "select-tutorial__content",
96
+ children: [re && /* @__PURE__ */ u("div", {
97
+ className: "select-tutorial__slot",
98
+ children: /* @__PURE__ */ d("div", {
99
+ ref: Y,
100
+ className: "select-tutorial__stage" + (V ? " is-theater" : ""),
101
+ role: V ? "dialog" : void 0,
102
+ "aria-modal": V ? !0 : void 0,
103
+ "aria-label": V ? $ : void 0,
104
+ tabIndex: V ? -1 : void 0,
105
+ children: [V && /* @__PURE__ */ d("div", {
106
+ className: "select-tutorial__theaterhead",
107
+ children: [/* @__PURE__ */ d("span", {
108
+ className: "select-tutorial__heading",
109
+ children: [p != null && /* @__PURE__ */ u("span", {
110
+ className: "select-tutorial__kicker",
111
+ children: p
112
+ }), /* @__PURE__ */ u("span", {
113
+ className: "select-tutorial__title",
114
+ children: m
115
+ })]
116
+ }), /* @__PURE__ */ d("button", {
117
+ type: "button",
118
+ className: "select-tutorial__shrink",
119
+ onClick: Q,
120
+ children: [/* @__PURE__ */ u(te, {}), F]
121
+ })]
122
+ }), /* @__PURE__ */ d("div", {
123
+ className: "select-tutorial__screen",
124
+ children: [
125
+ g ? /* @__PURE__ */ d("video", {
126
+ ref: X,
127
+ controls: !0,
128
+ playsInline: !0,
129
+ preload: "metadata",
130
+ poster: g.poster,
131
+ onEnded: () => {
132
+ W(!0), b == null || b();
133
+ },
134
+ children: [/* @__PURE__ */ u("source", {
135
+ src: g.src,
136
+ type: g.type
137
+ }), g.captions && /* @__PURE__ */ u("track", {
138
+ kind: "captions",
139
+ src: g.captions.src,
140
+ srcLang: g.captions.srcLang ?? "pt-BR",
141
+ label: g.captions.label,
142
+ default: !0
143
+ })]
144
+ }) : _,
145
+ (v != null || G) && /* @__PURE__ */ d("span", {
146
+ className: "select-tutorial__chips",
147
+ children: [v != null && /* @__PURE__ */ u("span", {
148
+ className: "select-tutorial__chip",
149
+ children: v
150
+ }), G && /* @__PURE__ */ d("span", {
151
+ className: "select-tutorial__chip select-tutorial__chip--seen",
152
+ children: [/* @__PURE__ */ u(e, {}), I]
153
+ })]
154
+ }),
155
+ !V && /* @__PURE__ */ u("button", {
156
+ ref: J,
157
+ type: "button",
158
+ className: "select-tutorial__expand",
159
+ onClick: () => H(!0),
160
+ "aria-label": P,
161
+ title: P,
162
+ children: /* @__PURE__ */ u("span", {
163
+ className: "select-tutorial__expandmark",
164
+ "aria-hidden": "true",
165
+ children: /* @__PURE__ */ u(r, {})
166
+ })
167
+ })
168
+ ]
169
+ })]
170
+ })
171
+ }), h != null && /* @__PURE__ */ u("p", {
172
+ className: "select-tutorial__desc",
173
+ children: h
174
+ })]
175
+ })
176
+ })
177
+ })]
178
+ })]
179
+ });
180
+ }
181
+ //#endregion
182
+ export { p as SelectTutorial };
183
+
184
+ //# sourceMappingURL=SelectTutorial.js.map
package/dist/icons.d.ts CHANGED
@@ -156,6 +156,10 @@ export declare function PaletteIcon(): import("react").JSX.Element;
156
156
  /** Duas barras (Iconsax pause) — pausar uma cobrança recorrente. */
157
157
  /** Tocar (0.1.220): o triângulo, o par do `PauseIcon` (o botão de passar sozinho do SelectCarousel). */
158
158
  export declare function PlayIcon(): import("react").JSX.Element;
159
+ /** Expandir (0.1.232): os quatro cantos com as setas para fora — o vídeo do SelectTutorial vai ao centro, grande. */
160
+ export declare function ExpandIcon(): import("react").JSX.Element;
161
+ /** Reduzir (0.1.232): o par do `ExpandIcon`, as setas para dentro. */
162
+ export declare function ShrinkIcon(): import("react").JSX.Element;
159
163
  export declare function PauseIcon(): import("react").JSX.Element;
160
164
  /** Seta voltando em volta (Iconsax arrow-rotate-left) — o ESTORNO: o dinheiro que volta. Não é o
161
165
  * `RefreshIcon` (recarregar), que desenha o mesmo gesto para "de novo". */