@joniguerini/lume 0.0.0-stage → 1.9.0

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,181 @@
1
+ import { type ReactNode, type RefObject } from 'react';
2
+ import { type IconName } from './Icon.js';
3
+ export type MenuOption = {
4
+ value: string;
5
+ label: string;
6
+ icon?: IconName;
7
+ swatch?: string;
8
+ shortcut?: string;
9
+ tone?: 'danger';
10
+ disabled?: boolean;
11
+ } | {
12
+ type: 'separator';
13
+ } | {
14
+ type: 'group';
15
+ label: string;
16
+ };
17
+ export interface MenuProps {
18
+ /** O botão, chip ou botão de ícone que abre o menu (useRef no gatilho). */
19
+ triggerRef: RefObject<HTMLElement | null>;
20
+ options: MenuOption[];
21
+ /** radio (padrão): escolhe um valor, que ganha a marca; action: dispara comandos. */
22
+ mode?: 'radio' | 'action';
23
+ /** O valor escolhido, no modo radio. */
24
+ value?: string;
25
+ onChange: (value: string) => void;
26
+ /** Título pequeno no topo da lista. */
27
+ label?: string;
28
+ /** Lista longa vira grade: no máximo N itens por coluna. */
29
+ maxRows?: number;
30
+ /** Cada grupo abre uma coluna. */
31
+ sectionColumns?: boolean;
32
+ }
33
+ /**
34
+ * Menu ligado a um gatilho. Não desenha nada: o gatilho é seu, e a lista abre no lugar certo.
35
+ * const ref = useRef(null);
36
+ * <Chip ref={ref} chevron>Recentes</Chip>
37
+ * <Menu triggerRef={ref} options={…} value={ordem} onChange={setOrdem} />
38
+ * https://lumeui.dev/#/componentes/menu
39
+ */
40
+ export declare function Menu({ triggerRef, options, mode, value, onChange, label, maxRows, sectionColumns }: MenuProps): null;
41
+ export interface TabItem {
42
+ id: string;
43
+ label: ReactNode;
44
+ icon?: IconName;
45
+ disabled?: boolean;
46
+ /** O conteúdo do painel. */
47
+ content: ReactNode;
48
+ }
49
+ export interface TabsProps {
50
+ items: TabItem[];
51
+ value: string;
52
+ onChange: (id: string) => void;
53
+ /** Nome do conjunto para leitores de tela. */
54
+ label: string;
55
+ /** underline (padrão) ou segmented. */
56
+ look?: 'underline' | 'segmented';
57
+ size?: 'sm' | 'md';
58
+ /** As abas dividem a largura toda. */
59
+ fill?: boolean;
60
+ className?: string;
61
+ }
62
+ /**
63
+ * Abas no padrão ARIA (tablist, tab, tabpanel), com setas, Home e End.
64
+ * https://lumeui.dev/#/componentes/abas
65
+ */
66
+ export declare function Tabs({ items, value, onChange, label, look, size, fill, className }: TabsProps): import("react").JSX.Element;
67
+ export interface SegmentedOption {
68
+ value: string;
69
+ label: ReactNode;
70
+ icon?: IconName;
71
+ disabled?: boolean;
72
+ }
73
+ export interface SegmentedControlProps {
74
+ options: SegmentedOption[];
75
+ value: string;
76
+ onChange: (value: string) => void;
77
+ /** Nome do grupo para leitores de tela ("Visão"). */
78
+ label: string;
79
+ className?: string;
80
+ }
81
+ /**
82
+ * Poucas opções lado a lado, uma escolhida, com efeito na hora. As setas trocam a opção.
83
+ * https://lumeui.dev/#/componentes/controle-segmentado
84
+ */
85
+ export declare function SegmentedControl({ options, value, onChange, label, className }: SegmentedControlProps): import("react").JSX.Element;
86
+ export interface PaginationProps {
87
+ /** Total de itens. */
88
+ total: number;
89
+ page: number;
90
+ pageSize: number;
91
+ onChange: (state: {
92
+ page: number;
93
+ pageSize: number;
94
+ }) => void;
95
+ /** Mostra o seletor de itens por página. */
96
+ pageSizes?: number[];
97
+ /** Páginas de cada lado da atual. Padrão: 1. */
98
+ siblings?: number;
99
+ /** Vira links de verdade: (page) => `?pagina=${page}`. */
100
+ hrefFor?: (page: number) => string;
101
+ /** Nome para leitores de tela. */
102
+ label?: string;
103
+ className?: string;
104
+ }
105
+ /**
106
+ * Páginas de uma lista, com total e itens por página. Em telas estreitas, vira "3 de 25".
107
+ * https://lumeui.dev/#/componentes/paginacao
108
+ */
109
+ export declare function Pagination({ total, page, pageSize, onChange, pageSizes, siblings, hrefFor, label, className }: PaginationProps): import("react").JSX.Element;
110
+ export interface StepperProps {
111
+ steps: Array<{
112
+ label: string;
113
+ description?: string;
114
+ }>;
115
+ /** A etapa atual, a partir de 0. */
116
+ current: number;
117
+ /** Com onChange, as etapas feitas viram botões para voltar. */
118
+ onChange?: (index: number) => void;
119
+ vertical?: boolean;
120
+ className?: string;
121
+ }
122
+ /**
123
+ * As etapas de um fluxo e onde a pessoa está.
124
+ * https://lumeui.dev/#/componentes/stepper
125
+ */
126
+ export declare function Stepper({ steps, current, onChange, vertical, className }: StepperProps): import("react").JSX.Element;
127
+ export interface AccordionItem {
128
+ id: string;
129
+ title: ReactNode;
130
+ content: ReactNode;
131
+ }
132
+ export interface AccordionProps {
133
+ items: AccordionItem[];
134
+ /** Os abertos no começo. */
135
+ defaultOpen?: string[];
136
+ /** Abrir um fecha os outros. */
137
+ single?: boolean;
138
+ /** Cada item é um cartão. */
139
+ card?: boolean;
140
+ className?: string;
141
+ }
142
+ /**
143
+ * Perguntas e seções que abrem e fecham, sobre <details> nativo.
144
+ * https://lumeui.dev/#/componentes/acordeao
145
+ */
146
+ export declare function Accordion({ items, defaultOpen, single, card, className }: AccordionProps): import("react").JSX.Element;
147
+ export interface TreeItem {
148
+ id: string;
149
+ label: string;
150
+ icon?: IconName;
151
+ children?: TreeItem[];
152
+ }
153
+ export interface TreeProps {
154
+ items: TreeItem[];
155
+ /** Nome para leitores de tela ("Arquivos"). */
156
+ label: string;
157
+ /** Os ids abertos no começo. */
158
+ defaultExpanded?: string[];
159
+ selected?: string | null;
160
+ onSelect?: (item: TreeItem) => void;
161
+ onToggle?: (item: TreeItem, open: boolean) => void;
162
+ className?: string;
163
+ }
164
+ /**
165
+ * Pastas e níveis aninhados, com teclado (setas, Home/End, letras).
166
+ * https://lumeui.dev/#/componentes/arvore
167
+ */
168
+ export declare function Tree({ items, label, defaultExpanded, selected, onSelect, onToggle, className }: TreeProps): import("react").JSX.Element;
169
+ /** Liga a barra de rolagem sobreposta do Lume no app inteiro. Chame uma vez, no componente de cima. */
170
+ export declare function useScrollbars(): void;
171
+ export interface BackToTopProps {
172
+ /** A área que rola. */
173
+ scrollerRef: RefObject<HTMLElement | null>;
174
+ /** Px rolados para o botão aparecer. Padrão: uma tela da própria área. */
175
+ threshold?: number;
176
+ }
177
+ /**
178
+ * Botão que aparece depois de uma tela de rolagem e volta ao começo, preso ao canto da área.
179
+ * https://lumeui.dev/#/componentes/voltar-ao-topo
180
+ */
181
+ export declare function BackToTop({ scrollerRef, threshold }: BackToTopProps): null;
@@ -0,0 +1,197 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from 'react';
4
+ import { createMenu } from '../js/menu.js';
5
+ import { createPagination } from '../js/pagination.js';
6
+ import { createStepper } from '../js/stepper.js';
7
+ import { createTree } from '../js/tree.js';
8
+ import { createBackToTop } from '../js/back-to-top.js';
9
+ import { initScrollbars } from '../js/scrollbar.js';
10
+ import { Icon } from './Icon.js';
11
+ import { useLatest, stableKey, defined, useSafeId } from './useController.js';
12
+ import { cx } from './cx.js';
13
+ /**
14
+ * Menu ligado a um gatilho. Não desenha nada: o gatilho é seu, e a lista abre no lugar certo.
15
+ * const ref = useRef(null);
16
+ * <Chip ref={ref} chevron>Recentes</Chip>
17
+ * <Menu triggerRef={ref} options={…} value={ordem} onChange={setOrdem} />
18
+ * https://lumeui.dev/#/componentes/menu
19
+ */
20
+ export function Menu({ triggerRef, options, mode, value, onChange, label, maxRows, sectionColumns }) {
21
+ const change = useLatest(onChange);
22
+ const api = useRef(null);
23
+ useEffect(() => {
24
+ if (!triggerRef.current)
25
+ return;
26
+ const c = createMenu(triggerRef.current, defined({ options, mode, value, label, maxRows, sectionColumns, onChange: (v) => change.current(v) }));
27
+ api.current = c;
28
+ return () => {
29
+ c.destroy();
30
+ api.current = null;
31
+ };
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ }, [triggerRef, stableKey(options), mode, label, maxRows, sectionColumns]);
34
+ useEffect(() => {
35
+ if (api.current && value !== undefined && api.current.value !== value)
36
+ api.current.setValue(value);
37
+ }, [value]);
38
+ return null;
39
+ }
40
+ /**
41
+ * Abas no padrão ARIA (tablist, tab, tabpanel), com setas, Home e End.
42
+ * https://lumeui.dev/#/componentes/abas
43
+ */
44
+ export function Tabs({ items, value, onChange, label, look = 'underline', size = 'md', fill, className }) {
45
+ const id = useSafeId('tabs');
46
+ const list = useRef(null);
47
+ const enabled = items.filter((t) => !t.disabled);
48
+ const onKey = (event) => {
49
+ const at = enabled.findIndex((t) => t.id === value);
50
+ const next = { ArrowRight: at + 1, ArrowLeft: at - 1, Home: 0, End: enabled.length - 1 }[event.key];
51
+ if (next === undefined)
52
+ return;
53
+ event.preventDefault();
54
+ const tab = enabled[(next + enabled.length) % enabled.length];
55
+ onChange(tab.id);
56
+ list.current?.querySelector(`#${id}-tab-${tab.id}`)?.focus();
57
+ };
58
+ return (_jsxs("div", { className: cx('ds-tabs', look === 'segmented' && 'ds-tabs--segmented', size === 'sm' && 'ds-tabs--sm', fill && 'ds-tabs--fill', className), children: [_jsx("div", { ref: list, className: "ds-tabs__list", role: "tablist", "aria-label": label, onKeyDown: onKey, children: items.map((t) => (_jsxs("button", { type: "button", className: "ds-tabs__tab", role: "tab", id: `${id}-tab-${t.id}`, "aria-controls": `${id}-panel-${t.id}`, "aria-selected": t.id === value, tabIndex: t.id === value ? 0 : -1, disabled: t.disabled, onClick: () => onChange(t.id), children: [t.icon && _jsx(Icon, { name: t.icon, size: 16 }), t.label] }, t.id))) }), items.map((t) => (_jsx("div", { className: "ds-tabs__panel", role: "tabpanel", id: `${id}-panel-${t.id}`, "aria-labelledby": `${id}-tab-${t.id}`, tabIndex: 0, hidden: t.id !== value, children: t.id === value && t.content }, t.id)))] }));
59
+ }
60
+ /**
61
+ * Poucas opções lado a lado, uma escolhida, com efeito na hora. As setas trocam a opção.
62
+ * https://lumeui.dev/#/componentes/controle-segmentado
63
+ */
64
+ export function SegmentedControl({ options, value, onChange, label, className }) {
65
+ const root = useRef(null);
66
+ const onKey = (event) => {
67
+ const delta = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }[event.key];
68
+ if (!delta)
69
+ return;
70
+ event.preventDefault();
71
+ const list = options.filter((o) => !o.disabled);
72
+ const at = list.findIndex((o) => o.value === value);
73
+ const next = list[(at + delta + list.length) % list.length];
74
+ onChange(next.value);
75
+ root.current?.querySelector(`[data-value="${CSS.escape(next.value)}"]`)?.focus();
76
+ };
77
+ return (_jsx("div", { ref: root, className: cx('ds-segmented', className), role: "radiogroup", "aria-label": label, onKeyDown: onKey, children: options.map((o) => (_jsxs("button", { type: "button", className: "ds-segmented__item", role: "radio", "data-value": o.value, "aria-checked": o.value === value, tabIndex: o.value === value ? 0 : -1, disabled: o.disabled, onClick: () => onChange(o.value), children: [o.icon && _jsx(Icon, { name: o.icon, size: 16 }), o.label] }, o.value))) }));
78
+ }
79
+ /**
80
+ * Páginas de uma lista, com total e itens por página. Em telas estreitas, vira "3 de 25".
81
+ * https://lumeui.dev/#/componentes/paginacao
82
+ */
83
+ export function Pagination({ total, page, pageSize, onChange, pageSizes, siblings, hrefFor, label, className }) {
84
+ const root = useRef(null);
85
+ const api = useRef(null);
86
+ const change = useLatest(onChange);
87
+ const href = useLatest(hrefFor);
88
+ useEffect(() => {
89
+ const c = createPagination(root.current, defined({
90
+ total, page, pageSize, pageSizes, siblings,
91
+ hrefFor: hrefFor ? (p) => href.current(p) : undefined,
92
+ onChange: (s) => change.current(s),
93
+ }));
94
+ api.current = c;
95
+ return () => {
96
+ c.destroy();
97
+ api.current = null;
98
+ };
99
+ // eslint-disable-next-line react-hooks/exhaustive-deps
100
+ }, [pageSize, stableKey(pageSizes), siblings, Boolean(hrefFor)]);
101
+ useEffect(() => {
102
+ if (api.current && api.current.page !== page)
103
+ api.current.setPage(page);
104
+ }, [page]);
105
+ useEffect(() => {
106
+ api.current?.setTotal(total);
107
+ }, [total]);
108
+ return _jsx("nav", { ref: root, className: cx('ds-pagination', className), "aria-label": label });
109
+ }
110
+ /**
111
+ * As etapas de um fluxo e onde a pessoa está.
112
+ * https://lumeui.dev/#/componentes/stepper
113
+ */
114
+ export function Stepper({ steps, current, onChange, vertical, className }) {
115
+ const root = useRef(null);
116
+ const api = useRef(null);
117
+ const change = useLatest(onChange);
118
+ const latest = useLatest(current);
119
+ useEffect(() => {
120
+ const c = createStepper(root.current, { steps, current: latest.current, clickable: Boolean(change.current), onChange: (i) => change.current?.(i) });
121
+ api.current = c;
122
+ return () => {
123
+ c.destroy();
124
+ root.current?.replaceChildren();
125
+ api.current = null;
126
+ };
127
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
+ }, [stableKey(steps), Boolean(onChange)]);
129
+ useEffect(() => {
130
+ if (api.current && api.current.current !== current)
131
+ api.current.setCurrent(current);
132
+ }, [current]);
133
+ return _jsx("ol", { ref: root, className: cx('ds-stepper', vertical && 'ds-stepper--vertical', className) });
134
+ }
135
+ /**
136
+ * Perguntas e seções que abrem e fecham, sobre <details> nativo.
137
+ * https://lumeui.dev/#/componentes/acordeao
138
+ */
139
+ export function Accordion({ items, defaultOpen = [], single, card, className }) {
140
+ const name = useSafeId('acc');
141
+ return (_jsx("div", { className: cx('ds-accordion', card && 'ds-accordion--card', className), children: items.map((item) => (_jsxs("details", { className: "ds-accordion__item", name: single ? name : undefined, open: defaultOpen.includes(item.id) || undefined, children: [_jsxs("summary", { className: "ds-accordion__head", children: [_jsx("span", { children: item.title }), _jsx(Icon, { name: "chevron-down", size: 18 })] }), _jsx("div", { className: "ds-accordion__body", children: item.content })] }, item.id))) }));
142
+ }
143
+ /**
144
+ * Pastas e níveis aninhados, com teclado (setas, Home/End, letras).
145
+ * https://lumeui.dev/#/componentes/arvore
146
+ */
147
+ export function Tree({ items, label, defaultExpanded, selected, onSelect, onToggle, className }) {
148
+ const root = useRef(null);
149
+ const api = useRef(null);
150
+ const pick = useLatest(onSelect);
151
+ const toggle = useLatest(onToggle);
152
+ const latest = useLatest({ items, selected });
153
+ useEffect(() => {
154
+ const c = createTree(root.current, defined({
155
+ items: latest.current.items,
156
+ expanded: defaultExpanded,
157
+ selected: latest.current.selected ?? undefined,
158
+ onSelect: (item) => pick.current?.(item),
159
+ onToggle: (item, open) => toggle.current?.(item, open),
160
+ }));
161
+ api.current = c;
162
+ return () => {
163
+ c.destroy();
164
+ root.current?.replaceChildren();
165
+ api.current = null;
166
+ };
167
+ // eslint-disable-next-line react-hooks/exhaustive-deps
168
+ }, []);
169
+ const key = stableKey(items);
170
+ useEffect(() => {
171
+ api.current?.setItems(items);
172
+ // eslint-disable-next-line react-hooks/exhaustive-deps
173
+ }, [key]);
174
+ useEffect(() => {
175
+ if (api.current && selected && api.current.selected !== selected)
176
+ api.current.select(selected);
177
+ }, [selected]);
178
+ return _jsx("div", { ref: root, className: cx('ds-tree', className), "aria-label": label });
179
+ }
180
+ /* ───────── Barra de rolagem e voltar ao topo ───────── */
181
+ /** Liga a barra de rolagem sobreposta do Lume no app inteiro. Chame uma vez, no componente de cima. */
182
+ export function useScrollbars() {
183
+ useEffect(() => initScrollbars(), []);
184
+ }
185
+ /**
186
+ * Botão que aparece depois de uma tela de rolagem e volta ao começo, preso ao canto da área.
187
+ * https://lumeui.dev/#/componentes/voltar-ao-topo
188
+ */
189
+ export function BackToTop({ scrollerRef, threshold }) {
190
+ useEffect(() => {
191
+ if (!scrollerRef.current)
192
+ return;
193
+ const c = createBackToTop(scrollerRef.current, defined({ threshold }));
194
+ return () => c.destroy();
195
+ }, [scrollerRef, threshold]);
196
+ return null;
197
+ }
@@ -0,0 +1,43 @@
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
+ import { type NotificationItem } from '../js/notifications.js';
3
+ import { type IconName } from './Icon.js';
4
+ export type BannerTone = 'neutral' | 'brand' | 'info' | 'warning' | 'danger';
5
+ export interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
6
+ /** Padrão: neutral. brand para novidade; warning e danger para o que afeta todo mundo. */
7
+ tone?: BannerTone;
8
+ /** O começo em negrito (“Lume 0.35”). */
9
+ title?: ReactNode;
10
+ /** A frase, e no máximo um link (use <Link>). */
11
+ children: ReactNode;
12
+ icon?: IconName;
13
+ /** Mostra o × . Com id, lembra no navegador que este anúncio foi fechado (a mesma chave de createBanner). */
14
+ closable?: boolean;
15
+ id?: string;
16
+ /** Colado nas bordas, no topo do app. */
17
+ flush?: boolean;
18
+ onClose?: () => void;
19
+ }
20
+ /**
21
+ * Faixa no topo do app com um recado para todo mundo.
22
+ * <Banner tone="brand" title="Lume 0.35" id="lume-0.35" closable>Banner e central. <Link href="/novidades">Ver</Link></Banner>
23
+ * https://lumeui.dev/#/componentes/banner-de-anuncio
24
+ */
25
+ export declare function Banner({ tone, title, children, icon, closable, id, flush, onClose, className, ...rest }: BannerProps): import("react").JSX.Element | null;
26
+ export type { NotificationItem };
27
+ export interface NotificationCenterProps {
28
+ /** As notificações, da mais nova para a mais antiga. Ids novos que chegarem são anunciados ao leitor de tela. */
29
+ items: NotificationItem[];
30
+ /** Mudou o que está lido (clique num item ou “Marcar todas”). Guarde no seu estado. */
31
+ onChange?: (items: NotificationItem[], unread: number) => void;
32
+ onSelect?: (item: NotificationItem) => void;
33
+ placement?: 'bottom' | 'top' | 'left' | 'right';
34
+ align?: 'start' | 'center' | 'end';
35
+ className?: string;
36
+ }
37
+ /**
38
+ * O sino com o número das não lidas, que abre a lista.
39
+ * const [items, setItems] = useState(lista);
40
+ * <NotificationCenter items={items} onChange={setItems} />
41
+ * https://lumeui.dev/#/componentes/central-de-notificacoes
42
+ */
43
+ export declare function NotificationCenter({ items, onChange, onSelect, placement, align, className }: NotificationCenterProps): import("react").JSX.Element;
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { createNotificationCenter } from '../js/notifications.js';
5
+ import { msg } from '../js/i18n.js';
6
+ import { Icon } from './Icon.js';
7
+ import { useLatest, defined } from './useController.js';
8
+ import { useLocale } from './useLocale.js';
9
+ import { cx } from './cx.js';
10
+ const TONE_ICON = { neutral: 'info', brand: 'megaphone', info: 'info', warning: 'alert-triangle', danger: 'alert-circle' };
11
+ const KEY = 'ds-banner:';
12
+ /**
13
+ * Faixa no topo do app com um recado para todo mundo.
14
+ * <Banner tone="brand" title="Lume 0.35" id="lume-0.35" closable>Banner e central. <Link href="/novidades">Ver</Link></Banner>
15
+ * https://lumeui.dev/#/componentes/banner-de-anuncio
16
+ */
17
+ export function Banner({ tone = 'neutral', title, children, icon, closable, id, flush, onClose, className, ...rest }) {
18
+ useLocale();
19
+ const [open, setOpen] = useState(true);
20
+ useEffect(() => {
21
+ if (!id || !closable)
22
+ return;
23
+ try {
24
+ if (localStorage.getItem(KEY + id))
25
+ setOpen(false);
26
+ }
27
+ catch {
28
+ /* sem armazenamento */
29
+ }
30
+ }, [id, closable]);
31
+ if (!open)
32
+ return null;
33
+ const close = () => {
34
+ setOpen(false);
35
+ if (id) {
36
+ try {
37
+ localStorage.setItem(KEY + id, '1');
38
+ }
39
+ catch {
40
+ /* sem armazenamento */
41
+ }
42
+ }
43
+ onClose?.();
44
+ };
45
+ return (_jsxs("div", { className: cx('ds-banner', tone !== 'neutral' && `ds-banner--${tone}`, flush && 'ds-banner--flush', className), role: "region", "aria-label": msg('banner.label'), ...rest, children: [_jsx("span", { className: "ds-banner__icon", children: _jsx(Icon, { name: icon ?? TONE_ICON[tone], size: 18 }) }), _jsxs("p", { className: "ds-banner__text", children: [title != null && _jsx("strong", { children: title }), children] }), closable && (_jsx("button", { type: "button", className: "ds-icon-btn ds-icon-btn--sm ds-icon-btn--muted ds-banner__close", "aria-label": msg('banner.close'), onClick: close, children: _jsx(Icon, { name: "x", size: 16 }) }))] }));
46
+ }
47
+ /**
48
+ * O sino com o número das não lidas, que abre a lista.
49
+ * const [items, setItems] = useState(lista);
50
+ * <NotificationCenter items={items} onChange={setItems} />
51
+ * https://lumeui.dev/#/componentes/central-de-notificacoes
52
+ */
53
+ export function NotificationCenter({ items, onChange, onSelect, placement, align, className }) {
54
+ useLocale();
55
+ const button = useRef(null);
56
+ const api = useRef(null);
57
+ const change = useLatest(onChange);
58
+ const select = useLatest(onSelect);
59
+ const start = useLatest(items);
60
+ const [unread, setUnread] = useState(() => items.filter((i) => !i.read).length);
61
+ useEffect(() => {
62
+ const center = createNotificationCenter(button.current, defined({
63
+ items: start.current,
64
+ badge: false,
65
+ placement,
66
+ align,
67
+ onChange: (next, n) => {
68
+ setUnread(n);
69
+ change.current?.(next, n);
70
+ },
71
+ onSelect: (item) => select.current?.(item),
72
+ }));
73
+ api.current = center;
74
+ return () => {
75
+ center.destroy();
76
+ api.current = null;
77
+ };
78
+ }, [placement, align, start, change, select]);
79
+ const first = useRef(true);
80
+ useEffect(() => {
81
+ setUnread(items.filter((i) => !i.read).length);
82
+ if (first.current) {
83
+ first.current = false;
84
+ return;
85
+ }
86
+ api.current?.setItems(items, { announce: true });
87
+ }, [items]);
88
+ return (_jsx("span", { style: { display: 'contents' }, children: _jsxs("button", { ref: button, type: "button", className: cx('ds-icon-btn', 'ds-notify-trigger', className), children: [_jsx(Icon, { name: "bell", size: 20 }), unread > 0 && _jsx("span", { className: "ds-notify-trigger__count", "aria-hidden": "true", children: unread > 99 ? '99+' : unread })] }) }));
89
+ }
@@ -0,0 +1,57 @@
1
+ import { type AnchorHTMLAttributes, type HTMLAttributes, type ReactNode } from 'react';
2
+ export interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
3
+ /** Título curto. */
4
+ title?: ReactNode;
5
+ /** Uma ou duas linhas sobre o conteúdo. */
6
+ text?: ReactNode;
7
+ }
8
+ /**
9
+ * Superfície simples para agrupar um assunto. Para um cabeçalho com ações, use o Painel.
10
+ * https://lumeui.dev/#/componentes/card
11
+ */
12
+ export declare function Card({ title, text, className, children, ...rest }: CardProps): import("react").JSX.Element;
13
+ export interface CardLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'title'> {
14
+ title?: ReactNode;
15
+ text?: ReactNode;
16
+ }
17
+ /** O card inteiro é um link: o contorno reforça no hover. Um destino só; sem botões dentro. */
18
+ export declare function CardLink({ title, text, className, children, ...rest }: CardLinkProps): import("react").JSX.Element;
19
+ export interface PanelProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
20
+ /** O tipo do conteúdo, pequeno e apagado: "Roteiro", "Pedido". */
21
+ eyebrow?: ReactNode;
22
+ /** O assunto. Um por painel; dá nome ao painel para leitores de tela. */
23
+ title?: ReactNode;
24
+ /** Botões de ícone à direita do título (fechar, duplicar). */
25
+ actions?: ReactNode;
26
+ /** Ação secundária abaixo das ações ("Exemplos"). */
27
+ aside?: ReactNode;
28
+ /** Barra de controles entre o cabeçalho e o corpo (chips, PanelSpacer, PanelMeta). */
29
+ toolbar?: ReactNode;
30
+ /** Rodapé com a ação principal. */
31
+ footer?: ReactNode;
32
+ /** compact: menos respiro; flat: sem contorno, dentro de outra superfície; hero: título maior. */
33
+ variant?: 'default' | 'compact' | 'flat' | 'hero';
34
+ /** Nível do título. Padrão: 2. */
35
+ titleLevel?: 2 | 3 | 4;
36
+ }
37
+ /**
38
+ * Superfície principal de conteúdo, com cabeçalho, barra, corpo e rodapé sempre na mesma ordem.
39
+ * https://lumeui.dev/#/componentes/painel
40
+ */
41
+ export declare function Panel({ eyebrow, title, actions, aside, toolbar, footer, variant, titleLevel, className, children, ...rest }: PanelProps): import("react").JSX.Element;
42
+ /** Empurra o que vem depois para a direita, na barra do painel. */
43
+ export declare const PanelSpacer: () => import("react").JSX.Element;
44
+ /** Informação pequena na barra do painel ("~3 min"). */
45
+ export declare const PanelMeta: ({ children }: {
46
+ children: ReactNode;
47
+ }) => import("react").JSX.Element;
48
+ export interface SectionProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
49
+ /** O carimbo antes do título ("00"). */
50
+ stamp?: ReactNode;
51
+ /** Título pequeno da seção. */
52
+ title: ReactNode;
53
+ /** Ações inline da seção ("Na cena +"). */
54
+ actions?: ReactNode;
55
+ }
56
+ /** Seção de leitura dentro do painel: "00 · Abertura" e o texto. */
57
+ export declare function Section({ stamp, title, actions, className, children, ...rest }: SectionProps): import("react").JSX.Element;
package/react/Panel.js ADDED
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useSafeId } from './useController.js';
4
+ import { cx } from './cx.js';
5
+ /**
6
+ * Superfície simples para agrupar um assunto. Para um cabeçalho com ações, use o Painel.
7
+ * https://lumeui.dev/#/componentes/card
8
+ */
9
+ export function Card({ title, text, className, children, ...rest }) {
10
+ return (_jsxs("div", { className: cx('ds-card', className), ...rest, children: [title && _jsx("p", { className: "ds-card__title", children: title }), text && _jsx("p", { className: "ds-card__text", children: text }), children] }));
11
+ }
12
+ /** O card inteiro é um link: o contorno reforça no hover. Um destino só; sem botões dentro. */
13
+ export function CardLink({ title, text, className, children, ...rest }) {
14
+ return (_jsxs("a", { className: cx('ds-card', 'ds-card--link', className), ...rest, children: [title && _jsx("p", { className: "ds-card__title", children: title }), text && _jsx("p", { className: "ds-card__text", children: text }), children] }));
15
+ }
16
+ /**
17
+ * Superfície principal de conteúdo, com cabeçalho, barra, corpo e rodapé sempre na mesma ordem.
18
+ * https://lumeui.dev/#/componentes/painel
19
+ */
20
+ export function Panel({ eyebrow, title, actions, aside, toolbar, footer, variant = 'default', titleLevel = 2, className, children, ...rest }) {
21
+ const id = useSafeId('p');
22
+ const Heading = `h${titleLevel}`;
23
+ const hasHeader = eyebrow || title || actions || aside;
24
+ return (_jsxs("article", { className: cx('ds-panel', variant !== 'default' && `ds-panel--${variant}`, className), "aria-labelledby": title ? id : undefined, ...rest, children: [hasHeader && (_jsxs("header", { className: "ds-panel__header", children: [_jsxs("div", { children: [eyebrow && _jsx("p", { className: "ds-panel__eyebrow", children: eyebrow }), title && _jsx(Heading, { className: "ds-panel__title", id: id, children: title })] }), actions && _jsx("div", { className: "ds-panel__actions", children: actions }), aside && _jsx("div", { className: "ds-panel__aside", children: aside })] })), toolbar && _jsx("div", { className: "ds-panel__toolbar", children: toolbar }), children && _jsx("div", { className: "ds-panel__body", children: children }), footer && _jsx("footer", { className: "ds-panel__footer", children: footer })] }));
25
+ }
26
+ /** Empurra o que vem depois para a direita, na barra do painel. */
27
+ export const PanelSpacer = () => _jsx("span", { className: "ds-panel__spacer" });
28
+ /** Informação pequena na barra do painel ("~3 min"). */
29
+ export const PanelMeta = ({ children }) => _jsx("span", { className: "ds-panel__meta", children: children });
30
+ /** Seção de leitura dentro do painel: "00 · Abertura" e o texto. */
31
+ export function Section({ stamp, title, actions, className, children, ...rest }) {
32
+ return (_jsxs("section", { className: cx('ds-section', className), ...rest, children: [_jsxs("p", { className: "ds-section__head", children: [stamp !== undefined && _jsx("span", { className: "ds-section__stamp", children: stamp }), _jsx("span", { children: title })] }), typeof children === 'string' ? _jsx("p", { className: "ds-section__text", children: children }) : children, actions && _jsx("div", { className: "ds-section__actions", children: actions })] }));
33
+ }