@joniguerini/lume 0.0.0-stage → 1.9.1

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.
Files changed (226) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +62 -2
  3. package/base.css +165 -0
  4. package/bin/lumeui.mjs +163 -0
  5. package/components/alert.css +156 -0
  6. package/components/banner.css +98 -0
  7. package/components/button.css +291 -0
  8. package/components/calendar.css +532 -0
  9. package/components/carousel.css +175 -0
  10. package/components/chart.css +813 -0
  11. package/components/chat.css +670 -0
  12. package/components/checkbox.css +212 -0
  13. package/components/chip.css +224 -0
  14. package/components/code.css +36 -0
  15. package/components/color-picker.css +192 -0
  16. package/components/command.css +148 -0
  17. package/components/content.css +211 -0
  18. package/components/editor.css +174 -0
  19. package/components/feedback.css +320 -0
  20. package/components/filters.css +103 -0
  21. package/components/form.css +455 -0
  22. package/components/image-viewer.css +237 -0
  23. package/components/layers.css +138 -0
  24. package/components/link.css +87 -0
  25. package/components/loading.css +260 -0
  26. package/components/menu.css +180 -0
  27. package/components/modal.css +209 -0
  28. package/components/navigation.css +507 -0
  29. package/components/notifications.css +186 -0
  30. package/components/number-field.css +52 -0
  31. package/components/otp.css +119 -0
  32. package/components/panel.css +208 -0
  33. package/components/picker.css +207 -0
  34. package/components/rating.css +143 -0
  35. package/components/resizable.css +173 -0
  36. package/components/scrollbar.css +110 -0
  37. package/components/select.css +477 -0
  38. package/components/shell.css +837 -0
  39. package/components/slider.css +189 -0
  40. package/components/sortable.css +287 -0
  41. package/components/surfaces.css +182 -0
  42. package/components/switch.css +115 -0
  43. package/components/table.css +228 -0
  44. package/components/tabs.css +190 -0
  45. package/components/tags.css +83 -0
  46. package/components/toast.css +164 -0
  47. package/components/toolbar.css +80 -0
  48. package/components/upload.css +181 -0
  49. package/ds.css +48 -0
  50. package/fonts/Geist-LICENSE.txt +92 -0
  51. package/fonts/Geist-Variable.woff2 +0 -0
  52. package/fonts/GeistSerif-Regular.woff2 +0 -0
  53. package/fonts/JetBrainsMono-LICENSE.txt +93 -0
  54. package/fonts/JetBrainsMono-Variable.woff2 +0 -0
  55. package/fonts.css +29 -0
  56. package/icons/icons.d.ts +5 -0
  57. package/icons/icons.js +266 -0
  58. package/js/back-to-top.d.ts +2 -0
  59. package/js/back-to-top.js +62 -0
  60. package/js/banner.js +87 -0
  61. package/js/calendar.d.ts +3 -0
  62. package/js/calendar.js +472 -0
  63. package/js/carousel.d.ts +2 -0
  64. package/js/carousel.js +258 -0
  65. package/js/charts/bar.js +361 -0
  66. package/js/charts/core.js +604 -0
  67. package/js/charts/donut.js +206 -0
  68. package/js/charts/figures.js +97 -0
  69. package/js/charts/heatmap.js +410 -0
  70. package/js/charts/line.js +268 -0
  71. package/js/charts/scatter.js +211 -0
  72. package/js/charts.d.ts +12 -0
  73. package/js/charts.js +27 -0
  74. package/js/code-block.d.ts +3 -0
  75. package/js/code-block.js +32 -0
  76. package/js/color-picker.d.ts +4 -0
  77. package/js/color-picker.js +448 -0
  78. package/js/command-palette.js +233 -0
  79. package/js/composer.js +573 -0
  80. package/js/context-menu.d.ts +2 -0
  81. package/js/context-menu.js +154 -0
  82. package/js/date-picker.d.ts +2 -0
  83. package/js/date-picker.js +430 -0
  84. package/js/drawer.js +48 -0
  85. package/js/editor.d.ts +5 -0
  86. package/js/editor.js +615 -0
  87. package/js/field-support.js +77 -0
  88. package/js/file-upload.d.ts +2 -0
  89. package/js/file-upload.js +230 -0
  90. package/js/filters.js +266 -0
  91. package/js/form.d.ts +2 -0
  92. package/js/form.js +409 -0
  93. package/js/i18n.d.ts +14 -0
  94. package/js/i18n.js +83 -0
  95. package/js/image-viewer.d.ts +4 -0
  96. package/js/image-viewer.js +275 -0
  97. package/js/menu.d.ts +4 -0
  98. package/js/menu.js +237 -0
  99. package/js/messages.js +908 -0
  100. package/js/modal.d.ts +7 -0
  101. package/js/modal.js +183 -0
  102. package/js/notifications.d.ts +4 -0
  103. package/js/notifications.js +204 -0
  104. package/js/number-field.d.ts +2 -0
  105. package/js/number-field.js +175 -0
  106. package/js/otp-field.d.ts +2 -0
  107. package/js/otp-field.js +107 -0
  108. package/js/pagination.d.ts +3 -0
  109. package/js/pagination.js +143 -0
  110. package/js/popover.d.ts +2 -0
  111. package/js/popover.js +155 -0
  112. package/js/progress-ring.js +48 -0
  113. package/js/rating.d.ts +3 -0
  114. package/js/rating.js +130 -0
  115. package/js/resizable.d.ts +2 -0
  116. package/js/resizable.js +311 -0
  117. package/js/scrollbar.d.ts +2 -0
  118. package/js/scrollbar.js +273 -0
  119. package/js/segmented.js +60 -0
  120. package/js/select.d.ts +3 -0
  121. package/js/select.js +784 -0
  122. package/js/shell.d.ts +6 -0
  123. package/js/shell.js +373 -0
  124. package/js/slider.d.ts +2 -0
  125. package/js/slider.js +89 -0
  126. package/js/sortable.d.ts +5 -0
  127. package/js/sortable.js +463 -0
  128. package/js/stepper.d.ts +2 -0
  129. package/js/stepper.js +72 -0
  130. package/js/tabs.js +99 -0
  131. package/js/tag-field.d.ts +2 -0
  132. package/js/tag-field.js +177 -0
  133. package/js/theme.d.ts +9 -0
  134. package/js/theme.js +114 -0
  135. package/js/time-picker.d.ts +2 -0
  136. package/js/time-picker.js +279 -0
  137. package/js/toast.d.ts +17 -0
  138. package/js/toast.js +171 -0
  139. package/js/toolbar.d.ts +2 -0
  140. package/js/toolbar.js +107 -0
  141. package/js/tooltip.d.ts +2 -0
  142. package/js/tooltip.js +208 -0
  143. package/js/tree.d.ts +2 -0
  144. package/js/tree.js +168 -0
  145. package/lume.css +11574 -0
  146. package/lume.d.ts +104 -0
  147. package/lume.js +67 -0
  148. package/package.json +66 -4
  149. package/react/Alert.d.ts +24 -0
  150. package/react/Alert.js +21 -0
  151. package/react/AppShell.d.ts +67 -0
  152. package/react/AppShell.js +94 -0
  153. package/react/Avatar.d.ts +39 -0
  154. package/react/Avatar.js +40 -0
  155. package/react/Badge.d.ts +17 -0
  156. package/react/Badge.js +10 -0
  157. package/react/Button.d.ts +32 -0
  158. package/react/Button.js +17 -0
  159. package/react/Calendar.d.ts +48 -0
  160. package/react/Calendar.js +67 -0
  161. package/react/Carousel.d.ts +30 -0
  162. package/react/Carousel.js +38 -0
  163. package/react/Charts.d.ts +186 -0
  164. package/react/Charts.js +58 -0
  165. package/react/Chip.d.ts +34 -0
  166. package/react/Chip.js +26 -0
  167. package/react/Choice.d.ts +72 -0
  168. package/react/Choice.js +51 -0
  169. package/react/ColorPicker.d.ts +43 -0
  170. package/react/ColorPicker.js +73 -0
  171. package/react/Content.d.ts +58 -0
  172. package/react/Content.js +42 -0
  173. package/react/Controls.d.ts +97 -0
  174. package/react/Controls.js +118 -0
  175. package/react/Editor.d.ts +28 -0
  176. package/react/Editor.js +57 -0
  177. package/react/Field.d.ts +90 -0
  178. package/react/Field.js +65 -0
  179. package/react/Form.d.ts +36 -0
  180. package/react/Form.js +45 -0
  181. package/react/Icon.d.ts +13 -0
  182. package/react/Icon.js +8 -0
  183. package/react/IconButton.d.ts +19 -0
  184. package/react/IconButton.js +12 -0
  185. package/react/ImageViewer.d.ts +20 -0
  186. package/react/ImageViewer.js +22 -0
  187. package/react/InlineAction.d.ts +15 -0
  188. package/react/InlineAction.js +12 -0
  189. package/react/Layers.d.ts +118 -0
  190. package/react/Layers.js +115 -0
  191. package/react/Link.d.ts +32 -0
  192. package/react/Link.js +26 -0
  193. package/react/Loading.d.ts +67 -0
  194. package/react/Loading.js +49 -0
  195. package/react/Navigation.d.ts +181 -0
  196. package/react/Navigation.js +197 -0
  197. package/react/Notices.d.ts +43 -0
  198. package/react/Notices.js +89 -0
  199. package/react/Panel.d.ts +57 -0
  200. package/react/Panel.js +33 -0
  201. package/react/Pickers.d.ts +83 -0
  202. package/react/Pickers.js +70 -0
  203. package/react/Rating.d.ts +39 -0
  204. package/react/Rating.js +41 -0
  205. package/react/Resizable.d.ts +44 -0
  206. package/react/Resizable.js +30 -0
  207. package/react/Select.d.ts +53 -0
  208. package/react/Select.js +79 -0
  209. package/react/Sortable.d.ts +52 -0
  210. package/react/Sortable.js +113 -0
  211. package/react/Table.d.ts +60 -0
  212. package/react/Table.js +34 -0
  213. package/react/Toolbar.d.ts +45 -0
  214. package/react/Toolbar.js +45 -0
  215. package/react/cx.d.ts +2 -0
  216. package/react/cx.js +5 -0
  217. package/react/icon-names.d.ts +1 -0
  218. package/react/icon-names.js +2 -0
  219. package/react/index.d.ts +42 -0
  220. package/react/index.js +52 -0
  221. package/react/useController.d.ts +8 -0
  222. package/react/useController.js +16 -0
  223. package/react/useLocale.d.ts +5 -0
  224. package/react/useLocale.js +15 -0
  225. package/tokens.css +739 -0
  226. package/tokens.js +4911 -0
@@ -0,0 +1,48 @@
1
+ export type CalendarView = 'month' | 'week' | 'day';
2
+ export interface CalendarEvent {
3
+ id: string;
4
+ title: string;
5
+ start: Date;
6
+ /** Fim exclusivo: 9:00 às 10:00 termina em 10:00; dia todo, à meia-noite do dia seguinte. */
7
+ end: Date;
8
+ allDay?: boolean;
9
+ tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'danger';
10
+ }
11
+ export interface CalendarProps {
12
+ events: CalendarEvent[];
13
+ view: CalendarView;
14
+ /** O dia em foco. */
15
+ date: Date;
16
+ /** Visão ou dia mudaram por dentro (setas, Hoje, seletor de visão). */
17
+ onChange: (state: {
18
+ view: CalendarView;
19
+ date: Date;
20
+ }) => void;
21
+ onEventClick?: (event: CalendarEvent) => void;
22
+ /** Clique num dia. Padrão: abre a visão do dia. */
23
+ onDateClick?: (date: Date) => void;
24
+ /** As visões do seletor. Padrão: as três. */
25
+ views?: CalendarView[];
26
+ /** 0 domingo, 1 segunda. Padrão: o do idioma. */
27
+ weekStartsOn?: 0 | 1;
28
+ /** A grade de horas abre nesta hora. Padrão: 8. */
29
+ scrollToHour?: number;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Mês, semana e dia, com eventos, teclado e o idioma do Lume.
34
+ * https://lumeui.dev/#/componentes/calendario
35
+ */
36
+ export declare function Calendar({ events, view, date, onChange, onEventClick, onDateClick, views, weekStartsOn, scrollToHour, className }: CalendarProps): import("react").JSX.Element;
37
+ export interface CodeBlockProps {
38
+ /** O código, como texto. */
39
+ code: string;
40
+ /** Letra menor, para trechos curtos ao lado de texto. */
41
+ small?: boolean;
42
+ className?: string;
43
+ }
44
+ /**
45
+ * Código com o botão de copiar (e o aviso de copiado).
46
+ * https://lumeui.dev/#/componentes/bloco-de-codigo
47
+ */
48
+ export declare function CodeBlock({ code, small, className }: CodeBlockProps): import("react").JSX.Element;
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from 'react';
4
+ import { createCalendar } from '../js/calendar.js';
5
+ import { mountCodeBlocks } from '../js/code-block.js';
6
+ import { msg } from '../js/i18n.js';
7
+ import { Icon } from './Icon.js';
8
+ import { useLocale } from './useLocale.js';
9
+ import { useLatest, stableKey, defined } from './useController.js';
10
+ import { cx } from './cx.js';
11
+ /**
12
+ * Mês, semana e dia, com eventos, teclado e o idioma do Lume.
13
+ * https://lumeui.dev/#/componentes/calendario
14
+ */
15
+ export function Calendar({ events, view, date, onChange, onEventClick, onDateClick, views, weekStartsOn, scrollToHour, className }) {
16
+ const root = useRef(null);
17
+ const api = useRef(null);
18
+ const change = useLatest(onChange);
19
+ const clickEvent = useLatest(onEventClick);
20
+ const clickDate = useLatest(onDateClick);
21
+ const latest = useLatest({ events, view, date });
22
+ useEffect(() => {
23
+ const c = createCalendar(root.current, defined({
24
+ ...latest.current,
25
+ views,
26
+ weekStartsOn,
27
+ scrollToHour,
28
+ onChange: (s) => change.current(s),
29
+ onEventClick: (e) => clickEvent.current?.(e),
30
+ onDateClick: onDateClick ? (d) => clickDate.current?.(d) : undefined,
31
+ }));
32
+ api.current = c;
33
+ return () => {
34
+ c.destroy();
35
+ root.current?.replaceChildren();
36
+ api.current = null;
37
+ };
38
+ // eslint-disable-next-line react-hooks/exhaustive-deps
39
+ }, [stableKey(views), weekStartsOn, scrollToHour, Boolean(onDateClick)]);
40
+ const eventsKey = stableKey(events);
41
+ useEffect(() => {
42
+ api.current?.setEvents(events);
43
+ // eslint-disable-next-line react-hooks/exhaustive-deps
44
+ }, [eventsKey]);
45
+ useEffect(() => {
46
+ if (api.current && api.current.view !== view)
47
+ api.current.setView(view);
48
+ }, [view]);
49
+ const day = date.toDateString();
50
+ useEffect(() => {
51
+ if (api.current && api.current.date.toDateString() !== day)
52
+ api.current.setDate(date);
53
+ // eslint-disable-next-line react-hooks/exhaustive-deps
54
+ }, [day]);
55
+ return _jsx("div", { ref: root, className: className });
56
+ }
57
+ /**
58
+ * Código com o botão de copiar (e o aviso de copiado).
59
+ * https://lumeui.dev/#/componentes/bloco-de-codigo
60
+ */
61
+ export function CodeBlock({ code, small, className }) {
62
+ useLocale();
63
+ const root = useRef(null);
64
+ useEffect(() => mountCodeBlocks(root.current), []);
65
+ const label = msg('code.copy');
66
+ return (_jsxs("div", { ref: root, className: cx('ds-code-block', className), children: [_jsx("pre", { className: cx('ds-code', small && 'ds-code--sm'), children: _jsx("code", { children: code }) }), _jsx("button", { type: "button", className: "ds-icon-btn ds-icon-btn--sm ds-icon-btn--muted ds-code-block__copy", "data-code-copy": true, "aria-label": label, "data-ds-tooltip": label, children: _jsx(Icon, { name: "copy", size: 16 }) })] }));
67
+ }
@@ -0,0 +1,30 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface CarouselProps {
3
+ /** Cada filho vira um slide. */
4
+ children: ReactNode;
5
+ /** Nome do carrossel para o leitor de tela (“Destaques”). */
6
+ label: string;
7
+ /** Quantos aparecem de uma vez. Para mudar por largura de tela, deixe vazio e use --ds-carousel-per-view no CSS. */
8
+ perView?: number;
9
+ /** Deixa a ponta do próximo à vista. */
10
+ peek?: boolean;
11
+ /** Depois do último volta ao primeiro. */
12
+ loop?: boolean;
13
+ /** Milissegundos entre um slide e outro; sempre com botão de pausa. */
14
+ autoplay?: number;
15
+ dots?: boolean;
16
+ count?: boolean;
17
+ /** O slide atual, a partir de 0. Com onChange, o carrossel acompanha o estado. */
18
+ index?: number;
19
+ onChange?: (index: number) => void;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * Destaques e galerias que passam um por vez, com setas, pontos, teclado e arrastar.
24
+ * <Carousel label="Destaques" loop>
25
+ * <article className="ds-carousel__card">…</article>
26
+ * <article className="ds-carousel__card">…</article>
27
+ * </Carousel>
28
+ * https://lumeui.dev/#/componentes/carrossel
29
+ */
30
+ export declare function Carousel({ children, label, perView, peek, loop, autoplay, dots, count, index, onChange, className }: CarouselProps): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Children, useEffect, useRef } from 'react';
4
+ import { createCarousel } from '../js/carousel.js';
5
+ import { useLatest, defined } from './useController.js';
6
+ import { cx } from './cx.js';
7
+ /**
8
+ * Destaques e galerias que passam um por vez, com setas, pontos, teclado e arrastar.
9
+ * <Carousel label="Destaques" loop>
10
+ * <article className="ds-carousel__card">…</article>
11
+ * <article className="ds-carousel__card">…</article>
12
+ * </Carousel>
13
+ * https://lumeui.dev/#/componentes/carrossel
14
+ */
15
+ export function Carousel({ children, label, perView, peek, loop, autoplay, dots, count, index, onChange, className }) {
16
+ const root = useRef(null);
17
+ const api = useRef(null);
18
+ const change = useLatest(onChange);
19
+ const start = useLatest(index);
20
+ const slides = Children.toArray(children);
21
+ useEffect(() => {
22
+ const c = createCarousel(root.current, defined({ loop, autoplay, dots, count, onChange: (i) => change.current?.(i) }));
23
+ if (start.current)
24
+ c.goTo(start.current);
25
+ api.current = c;
26
+ return () => {
27
+ c.destroy();
28
+ api.current = null;
29
+ };
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ }, [slides.length, loop, autoplay, dots, count]);
32
+ useEffect(() => {
33
+ if (index !== undefined && api.current && api.current.index !== index)
34
+ api.current.goTo(index);
35
+ }, [index]);
36
+ const style = perView ? { '--ds-carousel-per-view': perView } : undefined;
37
+ return (_jsx("section", { ref: root, className: cx('ds-carousel', peek && 'ds-carousel--peek', className), "aria-label": label, style: style, children: _jsx("div", { className: "ds-carousel__viewport", children: slides.map((child, i) => (_jsx("div", { className: "ds-carousel__slide", children: child }, child.key ?? i))) }) }));
38
+ }
@@ -0,0 +1,186 @@
1
+ type Format = string | ((value: number) => string);
2
+ /** Opções que todo gráfico aceita. */
3
+ export interface ChartBase {
4
+ title?: string;
5
+ subtitle?: string;
6
+ /** Nome para leitores de tela, quando não há título. */
7
+ label?: string;
8
+ /** 'number', 'currency', 'percent', 'compact', 'currency-compact'… ou uma função. */
9
+ format?: Format;
10
+ /** Formato do eixo, quando difere do tooltip. */
11
+ axisFormat?: Format;
12
+ height?: number;
13
+ /** Superfície de cartão em volta. */
14
+ card?: boolean;
15
+ /** Botão de ver como tabela. Padrão: sim. */
16
+ table?: boolean;
17
+ /** Linhas apagadas enquanto os dados chegam. */
18
+ loading?: boolean;
19
+ className?: string;
20
+ }
21
+ export interface Series {
22
+ name: string;
23
+ values: Array<number | null>;
24
+ color?: string;
25
+ /** Linha de contexto, em cinza (período anterior). */
26
+ muted?: boolean;
27
+ }
28
+ export interface BarChartProps extends ChartBase {
29
+ categories: string[];
30
+ series: Series[];
31
+ orientation?: 'vertical' | 'horizontal';
32
+ layout?: 'grouped' | 'stacked' | 'percent';
33
+ labels?: 'auto' | 'none' | 'all' | 'max' | 'last';
34
+ /** Índice da categoria em destaque; o resto fica cinza. */
35
+ highlight?: number;
36
+ /** Acima e abaixo de zero nas cores divergentes. */
37
+ diverging?: boolean;
38
+ /** Categorias em sequência (funil) numa rampa de um tom. */
39
+ ordinal?: boolean;
40
+ }
41
+ /** Colunas e barras. https://lumeui.dev/#/graficos/barras */
42
+ export declare const BarChart: (props: BarChartProps) => import("react").JSX.Element;
43
+ export interface LineChartProps extends ChartBase {
44
+ categories: string[];
45
+ series: Series[];
46
+ area?: boolean;
47
+ stacked?: boolean;
48
+ curve?: 'linear' | 'smooth';
49
+ markers?: 'end' | 'none' | 'all';
50
+ endLabels?: boolean;
51
+ highlight?: number;
52
+ /** Linha tracejada de meta ou limite. */
53
+ target?: {
54
+ value: number;
55
+ label?: string;
56
+ };
57
+ zero?: boolean;
58
+ }
59
+ /** Linhas e áreas. Um eixo só. https://lumeui.dev/#/graficos/linhas */
60
+ export declare const LineChart: (props: LineChartProps) => import("react").JSX.Element;
61
+ export interface DonutChartProps extends ChartBase {
62
+ items: Array<{
63
+ name: string;
64
+ value: number;
65
+ color?: string;
66
+ }>;
67
+ center?: 'total' | {
68
+ value: string | number;
69
+ label?: string;
70
+ } | false;
71
+ centerLabel?: string;
72
+ /** Da enésima fatia em diante, tudo vira "Outros". Padrão: 6. */
73
+ maxSegments?: number;
74
+ size?: number;
75
+ thickness?: number;
76
+ }
77
+ /** Parte do todo, até 6 fatias. https://lumeui.dev/#/graficos/rosca */
78
+ export declare const DonutChart: (props: DonutChartProps) => import("react").JSX.Element;
79
+ export interface HeatmapProps extends ChartBase {
80
+ rows: string[];
81
+ columns: string[];
82
+ /** values[linha][coluna]; null = sem dado. */
83
+ values: Array<Array<number | null>>;
84
+ scale?: 'sequential' | 'diverging';
85
+ steps?: 5 | 7;
86
+ domain?: [number, number];
87
+ center?: number;
88
+ valueLabel?: string;
89
+ cellHeight?: number;
90
+ scaleLabels?: [string, string];
91
+ }
92
+ /** Matriz de intensidade. https://lumeui.dev/#/graficos/heatmap */
93
+ export declare const Heatmap: (props: HeatmapProps) => import("react").JSX.Element;
94
+ export interface CalendarHeatmapProps extends ChartBase {
95
+ /** O primeiro dia, em ISO ('2025-11-02'). */
96
+ start: string;
97
+ /** Um valor por dia. */
98
+ values: Array<number | null>;
99
+ valueLabel?: string;
100
+ }
101
+ /** Um ano em quadradinhos, como o de contribuições. https://lumeui.dev/#/graficos/heatmap */
102
+ export declare const CalendarHeatmap: (props: CalendarHeatmapProps) => import("react").JSX.Element;
103
+ interface Axis {
104
+ label?: string;
105
+ format?: Format;
106
+ zero?: boolean;
107
+ reference?: number;
108
+ referenceLabel?: string;
109
+ }
110
+ export interface ScatterChartProps extends ChartBase {
111
+ series: Array<{
112
+ name: string;
113
+ color?: string;
114
+ points: Array<{
115
+ x: number;
116
+ y: number;
117
+ size?: number;
118
+ label?: string;
119
+ }>;
120
+ }>;
121
+ x?: Axis;
122
+ y?: Axis;
123
+ /** Com size nos pontos, vira bolhas. */
124
+ size?: {
125
+ label?: string;
126
+ format?: Format;
127
+ range?: [number, number];
128
+ };
129
+ }
130
+ /** Dispersão e bolhas, até 3 séries. https://lumeui.dev/#/graficos/dispersao */
131
+ export declare const ScatterChart: (props: ScatterChartProps) => import("react").JSX.Element;
132
+ export interface StatTileProps {
133
+ label: string;
134
+ value: number;
135
+ format?: Format;
136
+ /** Variação, em fração (0.124 = 12,4%). */
137
+ delta?: number;
138
+ deltaFormat?: Format;
139
+ deltaLabel?: string;
140
+ /** Subir é bom (up), cair é bom (down) ou neutro (none). */
141
+ good?: 'up' | 'down' | 'none';
142
+ /** Sparkline embaixo. */
143
+ trend?: number[];
144
+ trendLabel?: string;
145
+ /** Valor maior, para o número principal da tela. */
146
+ hero?: boolean;
147
+ href?: string;
148
+ className?: string;
149
+ }
150
+ /** O número com rótulo, variação e tendência. https://lumeui.dev/#/graficos/indicadores */
151
+ export declare function StatTile(props: StatTileProps): import("react").JSX.Element;
152
+ export interface SparklineProps {
153
+ values: number[];
154
+ width?: number;
155
+ height?: number;
156
+ /** Para leitores de tela ("Receita nos últimos 12 meses"). */
157
+ label?: string;
158
+ area?: boolean;
159
+ curve?: 'linear' | 'smooth';
160
+ color?: string;
161
+ /** 'last' (padrão) marca o ponto atual; 'none' tira a marca. */
162
+ highlight?: 'last' | 'none';
163
+ domain?: [number, number];
164
+ className?: string;
165
+ }
166
+ /** Linha de tendência sem eixos. https://lumeui.dev/#/graficos/indicadores */
167
+ export declare function Sparkline({ values, ...options }: SparklineProps): import("react").JSX.Element;
168
+ export interface MeterProps {
169
+ label: string;
170
+ value: number;
171
+ max?: number;
172
+ min?: number;
173
+ format?: Format;
174
+ /** Frações do máximo em que vira alerta e perigo. */
175
+ thresholds?: {
176
+ warning?: number;
177
+ danger?: number;
178
+ };
179
+ tone?: 'brand' | 'warning' | 'danger';
180
+ caption?: string;
181
+ size?: 'sm' | 'md';
182
+ className?: string;
183
+ }
184
+ /** Uma razão contra um limite (armazenamento, cota). https://lumeui.dev/#/graficos/indicadores */
185
+ export declare function Meter(props: MeterProps): import("react").JSX.Element;
186
+ export {};
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from 'react';
4
+ import { createBarChart, createLineChart, createDonutChart, createHeatmap, createCalendarHeatmap, createScatterChart, sparklineHtml, statTileHtml, meterHtml, } from '../js/charts.js';
5
+ import { useLocale } from './useLocale.js';
6
+ import { stableKey, defined } from './useController.js';
7
+ /** Liga um gráfico do Lume a um <div> e atualiza quando as opções mudam (pelo conteúdo, não pela referência). */
8
+ function useChart(create, { loading, className, ...options }) {
9
+ useLocale();
10
+ const host = useRef(null);
11
+ const chart = useRef(null);
12
+ const latest = useRef(options);
13
+ latest.current = options;
14
+ useEffect(() => {
15
+ const c = create(host.current, defined({ ...latest.current, className }));
16
+ chart.current = c;
17
+ return () => {
18
+ c.destroy();
19
+ chart.current = null;
20
+ };
21
+ // eslint-disable-next-line react-hooks/exhaustive-deps
22
+ }, [className]);
23
+ const key = stableKey(options);
24
+ useEffect(() => {
25
+ chart.current?.update(defined({ ...latest.current, className }));
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, [key]);
28
+ useEffect(() => {
29
+ chart.current?.setLoading(Boolean(loading));
30
+ }, [loading]);
31
+ return _jsx("div", { ref: host });
32
+ }
33
+ /** Colunas e barras. https://lumeui.dev/#/graficos/barras */
34
+ export const BarChart = (props) => useChart(createBarChart, props);
35
+ /** Linhas e áreas. Um eixo só. https://lumeui.dev/#/graficos/linhas */
36
+ export const LineChart = (props) => useChart(createLineChart, props);
37
+ /** Parte do todo, até 6 fatias. https://lumeui.dev/#/graficos/rosca */
38
+ export const DonutChart = (props) => useChart(createDonutChart, props);
39
+ /** Matriz de intensidade. https://lumeui.dev/#/graficos/heatmap */
40
+ export const Heatmap = (props) => useChart(createHeatmap, props);
41
+ /** Um ano em quadradinhos, como o de contribuições. https://lumeui.dev/#/graficos/heatmap */
42
+ export const CalendarHeatmap = (props) => useChart(createCalendarHeatmap, props);
43
+ /** Dispersão e bolhas, até 3 séries. https://lumeui.dev/#/graficos/dispersao */
44
+ export const ScatterChart = (props) => useChart(createScatterChart, props);
45
+ /** O número com rótulo, variação e tendência. https://lumeui.dev/#/graficos/indicadores */
46
+ export function StatTile(props) {
47
+ useLocale();
48
+ return _jsx("div", { style: { display: 'contents' }, dangerouslySetInnerHTML: { __html: statTileHtml(defined({ ...props })) } });
49
+ }
50
+ /** Linha de tendência sem eixos. https://lumeui.dev/#/graficos/indicadores */
51
+ export function Sparkline({ values, ...options }) {
52
+ return _jsx("span", { style: { display: 'contents' }, dangerouslySetInnerHTML: { __html: sparklineHtml(values, defined(options)) } });
53
+ }
54
+ /** Uma razão contra um limite (armazenamento, cota). https://lumeui.dev/#/graficos/indicadores */
55
+ export function Meter(props) {
56
+ useLocale();
57
+ return _jsx("div", { style: { display: 'contents' }, dangerouslySetInnerHTML: { __html: meterHtml(defined({ ...props })) } });
58
+ }
@@ -0,0 +1,34 @@
1
+ import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from 'react';
2
+ import { type IconName } from './Icon.js';
3
+ export interface ChipProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ /** Filtro: ligado ou desligado. Ligado, mostra o ✓. Deixe vazio num chip que não é filtro. */
5
+ pressed?: boolean;
6
+ /** Ícone antes do texto (em seletores, o do critério). */
7
+ icon?: IconName;
8
+ /** Mostra a seta: o chip abre um menu (Seletor). Use com aria-haspopup e aria-expanded. */
9
+ chevron?: boolean;
10
+ /** Padrão: md (36 px). */
11
+ size?: 'sm' | 'md';
12
+ }
13
+ /**
14
+ * Pílula com contorno para filtrar e escolher. Filtro: passe pressed e troque no onClick.
15
+ * https://lumeui.dev/#/componentes/chip
16
+ */
17
+ export declare const Chip: import("react").ForwardRefExoticComponent<ChipProps & import("react").RefAttributes<HTMLButtonElement>>;
18
+ export interface RemovableChipProps extends HTMLAttributes<HTMLSpanElement> {
19
+ /** O que a pessoa adicionou. */
20
+ children: ReactNode;
21
+ /** Chamado pelo × . */
22
+ onRemove: () => void;
23
+ /** Rótulo do × para leitores de tela. Padrão: "Remover" + o texto, no idioma do Lume. */
24
+ removeLabel?: string;
25
+ size?: 'sm' | 'md';
26
+ }
27
+ /** Chip que mostra algo adicionado e deixa tirar. Em lista, use dentro de ChipGroup com role="list". */
28
+ export declare function RemovableChip({ children, onRemove, removeLabel, size, className, ...rest }: RemovableChipProps): import("react").JSX.Element;
29
+ export interface ChipGroupProps extends HTMLAttributes<HTMLDivElement> {
30
+ /** O nome do grupo para leitores de tela ("Plataformas"). */
31
+ label: string;
32
+ }
33
+ /** Agrupa chips com o espaçamento certo. Filtros: role="group" (padrão). */
34
+ export declare function ChipGroup({ label, role, className, ...rest }: ChipGroupProps): import("react").JSX.Element;
package/react/Chip.js ADDED
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { Icon } from './Icon.js';
5
+ import { msg } from '../js/i18n.js';
6
+ import { useLocale } from './useLocale.js';
7
+ import { cx } from './cx.js';
8
+ /**
9
+ * Pílula com contorno para filtrar e escolher. Filtro: passe pressed e troque no onClick.
10
+ * https://lumeui.dev/#/componentes/chip
11
+ */
12
+ export const Chip = forwardRef(function Chip({ pressed, icon, chevron, size = 'md', className, type = 'button', children, ...rest }, ref) {
13
+ const sm = size === 'sm';
14
+ return (_jsxs("button", { ref: ref, type: type, "aria-pressed": pressed, className: cx('ds-chip', sm && 'ds-chip--sm', className), ...rest, children: [pressed !== undefined && (_jsx("span", { className: "ds-chip__check", children: _jsx(Icon, { name: "check", size: 14 }) })), icon && _jsx("span", { className: "ds-chip__icon", children: _jsx(Icon, { name: icon, size: sm ? 14 : 16 }) }), children, chevron && _jsx("span", { className: "ds-chip__chevron", children: _jsx(Icon, { name: "chevron-down", size: 14 }) })] }));
15
+ });
16
+ /** Chip que mostra algo adicionado e deixa tirar. Em lista, use dentro de ChipGroup com role="list". */
17
+ export function RemovableChip({ children, onRemove, removeLabel, size = 'md', className, ...rest }) {
18
+ useLocale();
19
+ const sm = size === 'sm';
20
+ const label = removeLabel ?? msg('common.remove', typeof children === 'string' ? children : '').trim();
21
+ return (_jsxs("span", { className: cx('ds-chip', 'ds-chip--removable', sm && 'ds-chip--sm', className), ...rest, children: [children, _jsx("button", { type: "button", className: "ds-chip__remove", "aria-label": label, onClick: onRemove, children: _jsx(Icon, { name: "x", size: sm ? 12 : 14 }) })] }));
22
+ }
23
+ /** Agrupa chips com o espaçamento certo. Filtros: role="group" (padrão). */
24
+ export function ChipGroup({ label, role = 'group', className, ...rest }) {
25
+ return _jsx("div", { role: role, "aria-label": label, className: cx('ds-chip-group', className), ...rest });
26
+ }
@@ -0,0 +1,72 @@
1
+ import { type InputHTMLAttributes, type ReactNode } from 'react';
2
+ type NativeInput = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'>;
3
+ interface ChoiceText {
4
+ /** O texto da opção. Sem ele, passe aria-label. */
5
+ label?: ReactNode;
6
+ /** Uma linha de explicação abaixo do rótulo. */
7
+ description?: ReactNode;
8
+ }
9
+ export interface CheckboxProps extends NativeInput, ChoiceText {
10
+ /** "Alguns marcados": o traço no lugar do ✓, para o "marcar todos" de uma lista. */
11
+ indeterminate?: boolean;
12
+ }
13
+ /**
14
+ * Marca uma opção que vale sozinha, para enviar depois. Efeito imediato é Switch.
15
+ * https://lumeui.dev/#/componentes/checkbox-radio
16
+ */
17
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxProps & import("react").RefAttributes<HTMLInputElement>>;
18
+ export interface RadioProps extends NativeInput, ChoiceText {
19
+ }
20
+ /** Uma opção entre várias, exatamente uma. Use dentro de RadioGroup ou com o mesmo name. */
21
+ export declare const Radio: import("react").ForwardRefExoticComponent<RadioProps & import("react").RefAttributes<HTMLInputElement>>;
22
+ export interface SwitchProps extends NativeInput, ChoiceText {
23
+ /** Padrão: md. */
24
+ size?: 'sm' | 'md';
25
+ /** O switch depois do texto, para listas de ajustes. */
26
+ end?: boolean;
27
+ }
28
+ /**
29
+ * Liga e desliga com efeito imediato. Para marcar e enviar depois, use Checkbox.
30
+ * https://lumeui.dev/#/componentes/switch
31
+ */
32
+ export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<HTMLInputElement>>;
33
+ export interface ChoiceGroupProps {
34
+ /** A pergunta do grupo. */
35
+ legend: ReactNode;
36
+ hint?: ReactNode;
37
+ error?: ReactNode;
38
+ /** As opções lado a lado, para poucas opções curtas. */
39
+ inline?: boolean;
40
+ /** Para a validação do Form: pelo menos N marcados. */
41
+ min?: number;
42
+ className?: string;
43
+ children: ReactNode;
44
+ }
45
+ /** Agrupa checkboxes ou radios com uma pergunta, dica e erro. */
46
+ export declare function ChoiceGroup({ legend, hint, error, inline, min, className, children }: ChoiceGroupProps): import("react").JSX.Element;
47
+ export interface ChoiceOption {
48
+ value: string;
49
+ label: ReactNode;
50
+ description?: ReactNode;
51
+ disabled?: boolean;
52
+ }
53
+ interface GroupBase extends Omit<ChoiceGroupProps, 'children'> {
54
+ options: ChoiceOption[];
55
+ /** name dos inputs, para o envio do formulário. */
56
+ name: string;
57
+ required?: boolean;
58
+ disabled?: boolean;
59
+ }
60
+ export interface RadioGroupProps extends GroupBase {
61
+ value: string | null;
62
+ onChange: (value: string) => void;
63
+ }
64
+ /** Radios a partir de uma lista, com o valor controlado. */
65
+ export declare function RadioGroup({ options, name, value, onChange, required, disabled, ...group }: RadioGroupProps): import("react").JSX.Element;
66
+ export interface CheckboxGroupProps extends GroupBase {
67
+ value: string[];
68
+ onChange: (value: string[]) => void;
69
+ }
70
+ /** Checkboxes a partir de uma lista; o valor é a lista dos marcados, na ordem das opções. */
71
+ export declare function CheckboxGroup({ options, name, value, onChange, required, disabled, ...group }: CheckboxGroupProps): import("react").JSX.Element;
72
+ export {};
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
4
+ import { Icon } from './Icon.js';
5
+ import { useSafeId } from './useController.js';
6
+ import { cx } from './cx.js';
7
+ function Text({ label, description }) {
8
+ if (!label && !description)
9
+ return null;
10
+ return (_jsxs("span", { className: "ds-choice__text", children: [label && _jsx("span", { className: "ds-choice__label", children: label }), description && _jsx("span", { className: "ds-choice__description", children: description })] }));
11
+ }
12
+ /**
13
+ * Marca uma opção que vale sozinha, para enviar depois. Efeito imediato é Switch.
14
+ * https://lumeui.dev/#/componentes/checkbox-radio
15
+ */
16
+ export const Checkbox = forwardRef(function Checkbox({ label, description, indeterminate = false, className, ...rest }, ref) {
17
+ const inner = useRef(null);
18
+ useImperativeHandle(ref, () => inner.current);
19
+ useEffect(() => {
20
+ if (inner.current)
21
+ inner.current.indeterminate = indeterminate;
22
+ }, [indeterminate]);
23
+ const Tag = label || description ? 'label' : 'span';
24
+ return (_jsxs(Tag, { className: cx('ds-checkbox', className), children: [_jsx("input", { ref: inner, type: "checkbox", className: "ds-checkbox__input", ...rest }), _jsx(Text, { label: label, description: description })] }));
25
+ });
26
+ /** Uma opção entre várias, exatamente uma. Use dentro de RadioGroup ou com o mesmo name. */
27
+ export const Radio = forwardRef(function Radio({ label, description, className, ...rest }, ref) {
28
+ return (_jsxs("label", { className: cx('ds-radio', className), children: [_jsx("input", { ref: ref, type: "radio", className: "ds-radio__input", ...rest }), _jsx(Text, { label: label, description: description })] }));
29
+ });
30
+ /**
31
+ * Liga e desliga com efeito imediato. Para marcar e enviar depois, use Checkbox.
32
+ * https://lumeui.dev/#/componentes/switch
33
+ */
34
+ export const Switch = forwardRef(function Switch({ label, description, size = 'md', end, className, ...rest }, ref) {
35
+ return (_jsxs("label", { className: cx('ds-switch', size === 'sm' && 'ds-switch--sm', end && 'ds-switch--end', className), children: [_jsx("input", { ref: ref, type: "checkbox", role: "switch", className: "ds-switch__input", ...rest }), _jsx(Text, { label: label, description: description })] }));
36
+ });
37
+ /** Agrupa checkboxes ou radios com uma pergunta, dica e erro. */
38
+ export function ChoiceGroup({ legend, hint, error, inline, min, className, children }) {
39
+ const id = useSafeId('g');
40
+ const describedBy = error ? `${id}-error` : hint ? `${id}-hint` : undefined;
41
+ return (_jsxs("fieldset", { className: cx('ds-choice-group', inline && 'ds-choice-group--inline', className), "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, "data-min": min, children: [_jsx("legend", { className: "ds-choice-group__legend", children: legend }), _jsx("div", { className: "ds-choice-group__items", children: children }), hint && !error && _jsx("p", { className: "ds-choice-group__hint", id: `${id}-hint`, children: hint }), error && (_jsxs("p", { className: "ds-choice-group__error", id: `${id}-error`, children: [_jsx(Icon, { name: "alert-circle", size: 16 }), _jsx("span", { children: error })] }))] }));
42
+ }
43
+ /** Radios a partir de uma lista, com o valor controlado. */
44
+ export function RadioGroup({ options, name, value, onChange, required, disabled, ...group }) {
45
+ return (_jsx(ChoiceGroup, { ...group, children: options.map((o) => (_jsx(Radio, { name: name, value: o.value, label: o.label, description: o.description, checked: value === o.value, disabled: disabled || o.disabled, required: required, onChange: () => onChange(o.value) }, o.value))) }));
46
+ }
47
+ /** Checkboxes a partir de uma lista; o valor é a lista dos marcados, na ordem das opções. */
48
+ export function CheckboxGroup({ options, name, value, onChange, required, disabled, ...group }) {
49
+ const toggle = (v, on) => onChange(options.map((o) => o.value).filter((x) => (x === v ? on : value.includes(x))));
50
+ return (_jsx(ChoiceGroup, { ...group, children: options.map((o) => (_jsx(Checkbox, { name: name, value: o.value, label: o.label, description: o.description, checked: value.includes(o.value), disabled: disabled || o.disabled, required: required && value.length === 0, onChange: (e) => toggle(o.value, e.target.checked) }, o.value))) }));
51
+ }
@@ -0,0 +1,43 @@
1
+ import { type FieldSize } from './Field.js';
2
+ export type ColorSwatch = string | {
3
+ value: string;
4
+ label?: string;
5
+ };
6
+ export interface ColorPickerProps {
7
+ /** Hexadecimal (#rrggbb). */
8
+ value: string;
9
+ /** A cada mudança, inclusive enquanto arrasta (como o Slider). */
10
+ onChange: (hex: string) => void;
11
+ /** Ao soltar, ao escolher uma amostra ou ao confirmar o hexadecimal: bom para salvar. */
12
+ onCommit?: (hex: string) => void;
13
+ /** Amostras embaixo; sem label, o nome é o hexadecimal. */
14
+ swatches?: ColorSwatch[];
15
+ className?: string;
16
+ }
17
+ /**
18
+ * Seletor de cor solto: área de saturação e brilho, matiz, hexadecimal e amostras.
19
+ * <ColorPicker value={cor} onChange={setCor} swatches={['#c97b63', '#3b82f6']} />
20
+ * https://lumeui.dev/#/componentes/seletor-de-cor
21
+ */
22
+ export declare function ColorPicker({ value, onChange, onCommit, swatches, className }: ColorPickerProps): import("react").JSX.Element;
23
+ export interface ColorFieldProps {
24
+ /** Hexadecimal (#rrggbb), ou null sem cor. */
25
+ value: string | null;
26
+ onChange: (hex: string | null) => void;
27
+ swatches?: ColorSwatch[];
28
+ /** name do valor no formulário (vai num input oculto). */
29
+ name?: string;
30
+ id?: string;
31
+ placeholder?: string;
32
+ disabled?: boolean;
33
+ required?: boolean;
34
+ size?: FieldSize;
35
+ 'aria-describedby'?: string;
36
+ 'aria-label'?: string;
37
+ }
38
+ /**
39
+ * Campo de cor: a amostra no começo abre o seletor num painel, e o hexadecimal dá para digitar.
40
+ * <ColorField id="marca" value={cor} onChange={setCor} swatches={paleta} />
41
+ * https://lumeui.dev/#/componentes/seletor-de-cor
42
+ */
43
+ export declare function ColorField({ value, onChange, swatches, name, size, ...rest }: ColorFieldProps): import("react").JSX.Element;