@joniguerini/lume 1.9.2 → 1.11.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.
- package/README.md +3 -3
- package/components/button.css +49 -0
- package/components/form.css +92 -0
- package/components/loading.css +8 -1
- package/components/menu.css +13 -0
- package/components/shell.css +25 -0
- package/components/toast.css +36 -0
- package/js/command-palette.js +6 -2
- package/js/currency-field.d.ts +4 -0
- package/js/currency-field.js +130 -0
- package/js/menu.js +8 -3
- package/js/messages.js +12 -0
- package/js/password-field.d.ts +2 -0
- package/js/password-field.js +68 -0
- package/js/search-field.d.ts +2 -0
- package/js/search-field.js +115 -0
- package/js/shell.js +7 -3
- package/js/toast.d.ts +3 -1
- package/js/toast.js +7 -3
- package/lume.css +224 -2
- package/lume.d.ts +3 -0
- package/lume.js +3 -0
- package/package.json +2 -2
- package/react/Alert.d.ts +3 -2
- package/react/Alert.js +4 -3
- package/react/AppShell.d.ts +2 -0
- package/react/Button.d.ts +30 -1
- package/react/Button.js +23 -3
- package/react/Charts.d.ts +4 -0
- package/react/EmptyState.d.ts +25 -0
- package/react/EmptyState.js +11 -0
- package/react/Field.d.ts +59 -1
- package/react/Field.js +92 -3
- package/react/Navigation.d.ts +13 -3
- package/react/Navigation.js +6 -6
- package/react/index.d.ts +3 -2
- package/react/index.js +3 -2
package/react/Button.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useRef } from 'react';
|
|
4
4
|
import { Icon } from './Icon.js';
|
|
5
|
+
import { Menu } from './Navigation.js';
|
|
6
|
+
import { msg } from '../js/i18n.js';
|
|
7
|
+
import { useLocale } from './useLocale.js';
|
|
5
8
|
import { cx } from './cx.js';
|
|
6
9
|
const classes = ({ variant = 'secondary', size = 'md', pill, block }, className) => cx('ds-btn', `ds-btn--${variant}`, size !== 'md' && `ds-btn--${size}`, pill && 'ds-btn--pill', block && 'ds-btn--block', className);
|
|
7
10
|
/**
|
|
8
11
|
* Dispara uma ação. Rótulo começa com verbo: "Salvar alterações", não "OK".
|
|
9
12
|
* https://lumeui.dev/#/componentes/botao
|
|
10
13
|
*/
|
|
11
|
-
export const Button = forwardRef(function Button({ variant, size, icon, iconEnd, pill, block, busy, className, type = 'button', children, ...rest }, ref) {
|
|
12
|
-
return (_jsxs("button", { ref: ref, type: type,
|
|
14
|
+
export const Button = forwardRef(function Button({ variant, size, icon, iconEnd, pill, block, busy, className, type = 'button', children, onClick, ...rest }, ref) {
|
|
15
|
+
return (_jsxs("button", { ref: ref, type: type, className: classes({ variant, size, pill, block }, className), ...rest, "aria-busy": busy || undefined, "aria-disabled": busy || rest['aria-disabled'] || undefined, onClick: (event) => {
|
|
16
|
+
// ocupado: nada de segundo envio (o Enter num campo também chega aqui como clique no botão de envio)
|
|
17
|
+
if (busy) {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
onClick?.(event);
|
|
22
|
+
}, children: [busy ? _jsx("span", { className: "ds-spinner ds-spinner--sm", "aria-hidden": "true" }) : icon && _jsx(Icon, { name: icon }), children, iconEnd && _jsx(Icon, { name: iconEnd })] }));
|
|
13
23
|
});
|
|
14
24
|
/** O mesmo visual do Botão, para navegar: vira um link (<a>), com o teclado e o leitor de tela de um link. */
|
|
15
25
|
export const ButtonLink = forwardRef(function ButtonLink({ variant, size, icon, iconEnd, pill, block, className, children, ...rest }, ref) {
|
|
16
26
|
return (_jsxs("a", { ref: ref, className: classes({ variant, size, pill, block }, className), ...rest, children: [icon && _jsx(Icon, { name: icon }), children, iconEnd && _jsx(Icon, { name: iconEnd })] }));
|
|
17
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* A ação principal e, colada nela, a seta com as alternativas ("Novo atendimento ▾").
|
|
30
|
+
* https://lumeui.dev/#/componentes/botao-dividido
|
|
31
|
+
*/
|
|
32
|
+
export function SplitButton({ label, icon, onClick, options, onSelect, menuLabel, variant = 'primary', size = 'md', disabled, busy, className, }) {
|
|
33
|
+
useLocale();
|
|
34
|
+
const arrow = useRef(null);
|
|
35
|
+
const name = menuLabel ?? msg('split.more');
|
|
36
|
+
return (_jsxs("div", { className: cx('ds-split-button', className), children: [_jsx(Button, { variant: variant, size: size, icon: icon, disabled: disabled, busy: busy, onClick: onClick, children: label }), _jsx("button", { ref: arrow, type: "button", className: classes({ variant, size }, 'ds-split-button__menu'), "aria-label": name, disabled: disabled || busy, children: _jsx(Icon, { name: "chevron-down", size: size === 'sm' ? 16 : 18 }) }), _jsx(Menu, { triggerRef: arrow, options: options, mode: "action", label: name, hideLabel: true, onChange: onSelect })] }));
|
|
37
|
+
}
|
package/react/Charts.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface BarChartProps extends ChartBase {
|
|
|
37
37
|
diverging?: boolean;
|
|
38
38
|
/** Categorias em sequência (funil) numa rampa de um tom. */
|
|
39
39
|
ordinal?: boolean;
|
|
40
|
+
/** O título da dica de cada categoria, quando o eixo usa uma forma curta ("Jan" no eixo, "Janeiro de 2026" na dica). */
|
|
41
|
+
tooltipLabels?: string[];
|
|
40
42
|
}
|
|
41
43
|
/** Colunas e barras. https://lumeui.dev/#/graficos/barras */
|
|
42
44
|
export declare const BarChart: (props: BarChartProps) => import("react").JSX.Element;
|
|
@@ -55,6 +57,8 @@ export interface LineChartProps extends ChartBase {
|
|
|
55
57
|
label?: string;
|
|
56
58
|
};
|
|
57
59
|
zero?: boolean;
|
|
60
|
+
/** O título da dica de cada categoria, quando o eixo usa uma forma curta. */
|
|
61
|
+
tooltipLabels?: string[];
|
|
58
62
|
}
|
|
59
63
|
/** Linhas e áreas. Um eixo só. https://lumeui.dev/#/graficos/linhas */
|
|
60
64
|
export declare const LineChart: (props: LineChartProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { type IconName } from './Icon.js';
|
|
3
|
+
export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
4
|
+
/** O ícone do assunto. Padrão: inbox. */
|
|
5
|
+
icon?: IconName;
|
|
6
|
+
/** Diz o que falta, sem culpa: "Nenhum cliente ainda". */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** Por que está vazio ou o que acontece depois. */
|
|
9
|
+
description?: ReactNode;
|
|
10
|
+
/** O próximo passo: um botão principal e, se precisar, um secundário. */
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
/** Linha pequena no fim (código do erro, hora). */
|
|
13
|
+
meta?: ReactNode;
|
|
14
|
+
/** danger para erro, warning para atenção (offline), muted para ícone neutro, loading para o ícone girando. */
|
|
15
|
+
tone?: 'danger' | 'warning' | 'muted' | 'loading';
|
|
16
|
+
/** page (padrão) para a página ou a lista inteira; compact dentro de um painel; inline numa linha de tabela. */
|
|
17
|
+
size?: 'page' | 'compact' | 'inline';
|
|
18
|
+
/** Sem contorno nem fundo, quando já está dentro de um cartão. */
|
|
19
|
+
plain?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Estado vazio: o que falta, por quê e o próximo passo. Anunciado sem interromper (role="status").
|
|
23
|
+
* https://lumeui.dev/#/componentes/estado-vazio
|
|
24
|
+
*/
|
|
25
|
+
export declare function EmptyState({ icon, title, description, actions, meta, tone, size, plain, className, role, ...rest }: EmptyStateProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Icon } from './Icon.js';
|
|
4
|
+
import { cx } from './cx.js';
|
|
5
|
+
/**
|
|
6
|
+
* Estado vazio: o que falta, por quê e o próximo passo. Anunciado sem interromper (role="status").
|
|
7
|
+
* https://lumeui.dev/#/componentes/estado-vazio
|
|
8
|
+
*/
|
|
9
|
+
export function EmptyState({ icon = 'inbox', title, description, actions, meta, tone, size = 'page', plain, className, role = 'status', ...rest }) {
|
|
10
|
+
return (_jsxs("div", { className: cx('ds-empty', size !== 'page' && `ds-empty--${size}`, plain && 'ds-empty--plain', tone && `ds-empty--${tone}`, className), role: role, ...rest, children: [_jsx("span", { className: "ds-empty__icon", children: _jsx(Icon, { name: icon }) }), _jsx("p", { className: "ds-empty__title", children: title }), description && _jsx("p", { className: "ds-empty__description", children: description }), actions && _jsx("div", { className: "ds-empty__actions", children: actions }), meta && _jsx("p", { className: "ds-empty__meta", children: meta })] }));
|
|
11
|
+
}
|
package/react/Field.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { type InputHTMLAttributes, type ReactNode, type TextareaHTMLAttributes }
|
|
|
2
2
|
import { type IconName } from './Icon.js';
|
|
3
3
|
export type FieldSize = 'sm' | 'md' | 'lg';
|
|
4
4
|
interface FieldContextValue {
|
|
5
|
-
id:
|
|
5
|
+
/** Sem id dentro de um FieldGroup: cada controle do grupo leva o próprio. */
|
|
6
|
+
id?: string;
|
|
6
7
|
describedBy?: string;
|
|
7
8
|
invalid: boolean;
|
|
8
9
|
}
|
|
@@ -87,4 +88,61 @@ export interface TextFieldProps extends Omit<InputProps, 'children'> {
|
|
|
87
88
|
* https://lumeui.dev/#/componentes/campo-de-texto
|
|
88
89
|
*/
|
|
89
90
|
export declare const TextField: import("react").ForwardRefExoticComponent<TextFieldProps & import("react").RefAttributes<HTMLInputElement & HTMLTextAreaElement>>;
|
|
91
|
+
export interface FieldGroupProps {
|
|
92
|
+
/** O nome do grupo ("Quando"). Cada controle de dentro leva o próprio aria-label ("Data", "Início"). */
|
|
93
|
+
label: ReactNode;
|
|
94
|
+
/** Uma linha logo abaixo. Some quando há erro. */
|
|
95
|
+
hint?: ReactNode;
|
|
96
|
+
/** A mensagem de erro do grupo. Liga aria-invalid nos controles de dentro. */
|
|
97
|
+
error?: ReactNode;
|
|
98
|
+
optional?: boolean;
|
|
99
|
+
/** Os controles dividem a linha por igual (nome e sobrenome). Padrão: o primeiro ocupa o dobro dos outros. */
|
|
100
|
+
even?: boolean;
|
|
101
|
+
/** Base dos ids do rótulo e da mensagem. Padrão: um gerado. */
|
|
102
|
+
id?: string;
|
|
103
|
+
className?: string;
|
|
104
|
+
children: ReactNode;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Um rótulo, uma dica e um erro para vários controles lado a lado (data e dois horários).
|
|
108
|
+
* O grupo tem role="group" e o nome do rótulo; cada controle mantém o próprio id e lê a dica e o erro sozinho.
|
|
109
|
+
* https://lumeui.dev/#/componentes/grupo-de-campos
|
|
110
|
+
*/
|
|
111
|
+
export declare function FieldGroup({ label, hint, error, optional, even, id, className, children }: FieldGroupProps): import("react").JSX.Element;
|
|
112
|
+
export interface PasswordFieldProps extends Omit<InputProps, 'type' | 'action' | 'affix'> {
|
|
113
|
+
/** Padrão: current-password. Em criar conta e trocar senha, use new-password. */
|
|
114
|
+
autoComplete?: 'current-password' | 'new-password';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Senha com o botão de mostrar e esconder dentro do campo (aria-pressed; o foco fica no campo).
|
|
118
|
+
* https://lumeui.dev/#/componentes/campo-de-senha
|
|
119
|
+
*/
|
|
120
|
+
export declare const PasswordField: import("react").ForwardRefExoticComponent<PasswordFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
121
|
+
export interface SearchFieldProps extends Omit<InputProps, 'type' | 'value' | 'onChange' | 'action' | 'icon'> {
|
|
122
|
+
value: string;
|
|
123
|
+
onChange: (value: string) => void;
|
|
124
|
+
/** Uma tecla sem modificador que leva o foco ao campo de qualquer lugar ("/"). Aparece no campo vazio. */
|
|
125
|
+
shortcut?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Busca: a lupa, o × quando há texto, Esc que limpa e o atalho opcional. Dê um aria-label ("Buscar clientes")
|
|
129
|
+
* ou ponha dentro de um Field.
|
|
130
|
+
* https://lumeui.dev/#/componentes/campo-de-busca
|
|
131
|
+
*/
|
|
132
|
+
export declare const SearchField: import("react").ForwardRefExoticComponent<SearchFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
133
|
+
export interface CurrencyFieldProps extends Omit<InputProps, 'value' | 'onChange' | 'affix' | 'type' | 'inputMode' | 'defaultValue'> {
|
|
134
|
+
value: number | null;
|
|
135
|
+
/** Quando o valor se firma: ao sair do campo ou com Enter. */
|
|
136
|
+
onChange: (value: number | null) => void;
|
|
137
|
+
/** Código ISO 4217. Padrão: BRL. */
|
|
138
|
+
currency?: string;
|
|
139
|
+
min?: number;
|
|
140
|
+
max?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Dinheiro: digita-se livre e, ao sair do campo, o valor volta formatado no idioma, com o símbolo fixo.
|
|
144
|
+
* O formulário recebe o número puro (1290.5) pelo name.
|
|
145
|
+
* https://lumeui.dev/#/componentes/campo-de-dinheiro
|
|
146
|
+
*/
|
|
147
|
+
export declare const CurrencyField: import("react").ForwardRefExoticComponent<CurrencyFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
90
148
|
export {};
|
package/react/Field.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, forwardRef, useContext, useState, } from 'react';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
4
|
import { Icon } from './Icon.js';
|
|
5
|
+
import { Kbd } from './Content.js';
|
|
5
6
|
import { msg } from '../js/i18n.js';
|
|
7
|
+
import { createCurrencyField } from '../js/currency-field.js';
|
|
6
8
|
import { useLocale } from './useLocale.js';
|
|
7
|
-
import { useSafeId } from './useController.js';
|
|
9
|
+
import { useSafeId, useLatest, defined } from './useController.js';
|
|
8
10
|
import { cx } from './cx.js';
|
|
9
11
|
const FieldContext = createContext(null);
|
|
10
12
|
/** O id, a descrição (dica ou erro) e o estado de erro do Field em volta. Para controles próprios dentro de um Field. */
|
|
@@ -63,3 +65,90 @@ export const TextField = forwardRef(function TextField({ label, hint, error, opt
|
|
|
63
65
|
const { size, icon, affix, action, type, ...common } = rest;
|
|
64
66
|
return (_jsx(Field, { label: label, hint: hint, error: error, optional: optional, count: count, id: id, className: className, children: multiline ? (_jsx(Textarea, { ref: ref, rows: rows, maxLength: maxLength, onChange: change, ...common })) : (_jsx(Input, { ref: ref, size: size, icon: icon, affix: affix, type: type, maxLength: maxLength, onChange: change, action: action ?? (onClear && length > 0 ? _jsx(FieldAction, { icon: "x", label: msg('form.clear'), onClick: onClear }) : undefined), ...common })) }));
|
|
65
67
|
});
|
|
68
|
+
/**
|
|
69
|
+
* Um rótulo, uma dica e um erro para vários controles lado a lado (data e dois horários).
|
|
70
|
+
* O grupo tem role="group" e o nome do rótulo; cada controle mantém o próprio id e lê a dica e o erro sozinho.
|
|
71
|
+
* https://lumeui.dev/#/componentes/grupo-de-campos
|
|
72
|
+
*/
|
|
73
|
+
export function FieldGroup({ label, hint, error, optional, even, id, className, children }) {
|
|
74
|
+
useLocale();
|
|
75
|
+
const auto = useSafeId('fg');
|
|
76
|
+
const groupId = id ?? auto;
|
|
77
|
+
const invalid = Boolean(error);
|
|
78
|
+
const describedBy = invalid ? `${groupId}-error` : hint ? `${groupId}-hint` : undefined;
|
|
79
|
+
return (_jsx(FieldContext.Provider, { value: { id: undefined, describedBy, invalid }, children: _jsxs("div", { className: cx('ds-form-field ds-field-group', even && 'ds-field-group--even', className), role: "group", "aria-labelledby": `${groupId}-label`, children: [_jsxs("span", { className: "ds-form-field__label", id: `${groupId}-label`, children: [label, optional && _jsx("span", { className: "ds-form-field__optional", children: msg('form.optional') })] }), _jsx("div", { className: "ds-field-group__controls", children: children }), (invalid || hint) && (_jsx("div", { className: "ds-form-field__footer", children: invalid ? (_jsxs("p", { className: "ds-form-field__error", id: `${groupId}-error`, children: [_jsx(Icon, { name: "alert-circle", size: 16 }), _jsx("span", { children: error })] })) : (_jsx("p", { className: "ds-form-field__hint", id: `${groupId}-hint`, children: hint })) }))] }) }));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Senha com o botão de mostrar e esconder dentro do campo (aria-pressed; o foco fica no campo).
|
|
83
|
+
* https://lumeui.dev/#/componentes/campo-de-senha
|
|
84
|
+
*/
|
|
85
|
+
export const PasswordField = forwardRef(function PasswordField({ autoComplete = 'current-password', disabled, ...rest }, ref) {
|
|
86
|
+
useLocale();
|
|
87
|
+
const [visible, setVisible] = useState(false);
|
|
88
|
+
return (_jsx(Input, { ref: ref, ...rest, disabled: disabled, type: visible ? 'text' : 'password', autoComplete: autoComplete, action: _jsx("button", { type: "button", className: "ds-icon-btn ds-icon-btn--sm ds-icon-btn--muted ds-field__action", "aria-label": msg('password.show'), "aria-pressed": visible, disabled: disabled, onPointerDown: (event) => event.preventDefault(), onClick: () => setVisible((v) => !v), children: _jsx(Icon, { name: visible ? 'eye-off' : 'eye', size: 16 }) }) }));
|
|
89
|
+
});
|
|
90
|
+
const typing = (target) => target instanceof HTMLElement && (target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName));
|
|
91
|
+
/**
|
|
92
|
+
* Busca: a lupa, o × quando há texto, Esc que limpa e o atalho opcional. Dê um aria-label ("Buscar clientes")
|
|
93
|
+
* ou ponha dentro de um Field.
|
|
94
|
+
* https://lumeui.dev/#/componentes/campo-de-busca
|
|
95
|
+
*/
|
|
96
|
+
export const SearchField = forwardRef(function SearchField({ value, onChange, shortcut, onKeyDown, disabled, className, placeholder, ...rest }, ref) {
|
|
97
|
+
useLocale();
|
|
98
|
+
const input = useRef(null);
|
|
99
|
+
useImperativeHandle(ref, () => input.current, []);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!shortcut)
|
|
102
|
+
return;
|
|
103
|
+
const onKey = (event) => {
|
|
104
|
+
if (event.key !== shortcut || event.metaKey || event.ctrlKey || event.altKey || event.defaultPrevented || typing(event.target))
|
|
105
|
+
return;
|
|
106
|
+
const el = input.current;
|
|
107
|
+
if (!el || el.disabled || el.getClientRects().length === 0)
|
|
108
|
+
return;
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
el.focus();
|
|
111
|
+
el.select();
|
|
112
|
+
};
|
|
113
|
+
document.addEventListener('keydown', onKey);
|
|
114
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
115
|
+
}, [shortcut]);
|
|
116
|
+
const clear = () => {
|
|
117
|
+
onChange('');
|
|
118
|
+
input.current?.focus();
|
|
119
|
+
};
|
|
120
|
+
return (_jsx(Input, { ref: input, ...rest, type: "search", icon: "search", className: cx('ds-search', className), placeholder: placeholder ?? msg('common.search'), disabled: disabled, value: value, "aria-keyshortcuts": shortcut, onChange: (event) => onChange(event.target.value), onKeyDown: (event) => {
|
|
121
|
+
if (event.key === 'Escape' && value) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
onChange('');
|
|
125
|
+
}
|
|
126
|
+
onKeyDown?.(event);
|
|
127
|
+
}, action: value && !disabled ? (_jsx(FieldAction, { icon: "x", label: msg('search.clear'), onClick: clear })) : shortcut ? (_jsx(Kbd, { className: "ds-search__kbd", "aria-hidden": "true", children: shortcut })) : undefined }));
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* Dinheiro: digita-se livre e, ao sair do campo, o valor volta formatado no idioma, com o símbolo fixo.
|
|
131
|
+
* O formulário recebe o número puro (1290.5) pelo name.
|
|
132
|
+
* https://lumeui.dev/#/componentes/campo-de-dinheiro
|
|
133
|
+
*/
|
|
134
|
+
export const CurrencyField = forwardRef(function CurrencyField({ value, onChange, currency = 'BRL', min, max, name, ...rest }, ref) {
|
|
135
|
+
const input = useRef(null);
|
|
136
|
+
useImperativeHandle(ref, () => input.current, []);
|
|
137
|
+
const api = useRef(null);
|
|
138
|
+
const emit = useLatest(onChange);
|
|
139
|
+
const latest = useLatest(value);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
const c = createCurrencyField(input.current, defined({ currency, min, max, value: latest.current, onChange: (v) => emit.current(v) }));
|
|
142
|
+
api.current = c;
|
|
143
|
+
return () => {
|
|
144
|
+
c.destroy();
|
|
145
|
+
api.current = null;
|
|
146
|
+
};
|
|
147
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
148
|
+
}, [currency, min, max]);
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
if (api.current && api.current.value !== value)
|
|
151
|
+
api.current.setValue(value);
|
|
152
|
+
}, [value]);
|
|
153
|
+
return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: input, ...rest }), name && _jsx("input", { type: "hidden", name: name, value: value ?? '' })] }));
|
|
154
|
+
});
|
package/react/Navigation.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type MenuOption = {
|
|
|
6
6
|
icon?: IconName;
|
|
7
7
|
swatch?: string;
|
|
8
8
|
shortcut?: string;
|
|
9
|
+
/** Texto curto à direita, como uma contagem. */
|
|
10
|
+
meta?: string | number;
|
|
9
11
|
tone?: 'danger';
|
|
10
12
|
disabled?: boolean;
|
|
11
13
|
} | {
|
|
@@ -23,8 +25,10 @@ export interface MenuProps {
|
|
|
23
25
|
/** O valor escolhido, no modo radio. */
|
|
24
26
|
value?: string;
|
|
25
27
|
onChange: (value: string) => void;
|
|
26
|
-
/** Título pequeno no topo da lista. */
|
|
28
|
+
/** Título pequeno no topo da lista e nome do menu. */
|
|
27
29
|
label?: string;
|
|
30
|
+
/** Esconde o título: label fica só para o leitor de tela (menus de ações de uma linha). */
|
|
31
|
+
hideLabel?: boolean;
|
|
28
32
|
/** Lista longa vira grade: no máximo N itens por coluna. */
|
|
29
33
|
maxRows?: number;
|
|
30
34
|
/** Cada grupo abre uma coluna. */
|
|
@@ -37,11 +41,13 @@ export interface MenuProps {
|
|
|
37
41
|
* <Menu triggerRef={ref} options={…} value={ordem} onChange={setOrdem} />
|
|
38
42
|
* https://lumeui.dev/#/componentes/menu
|
|
39
43
|
*/
|
|
40
|
-
export declare function Menu({ triggerRef, options, mode, value, onChange, label, maxRows, sectionColumns }: MenuProps): null;
|
|
44
|
+
export declare function Menu({ triggerRef, options, mode, value, onChange, label, hideLabel, maxRows, sectionColumns }: MenuProps): null;
|
|
41
45
|
export interface TabItem {
|
|
42
46
|
id: string;
|
|
43
47
|
label: ReactNode;
|
|
44
48
|
icon?: IconName;
|
|
49
|
+
/** Contagem ao lado do rótulo ("Prontuário 8"). */
|
|
50
|
+
count?: number | string;
|
|
45
51
|
disabled?: boolean;
|
|
46
52
|
/** O conteúdo do painel. */
|
|
47
53
|
content: ReactNode;
|
|
@@ -76,13 +82,17 @@ export interface SegmentedControlProps {
|
|
|
76
82
|
onChange: (value: string) => void;
|
|
77
83
|
/** Nome do grupo para leitores de tela ("Visão"). */
|
|
78
84
|
label: string;
|
|
85
|
+
/** sm (32 px) para barras densas; md (36 px, padrão); lg (40 px) alinha com campos e botões médios. */
|
|
86
|
+
size?: 'sm' | 'md' | 'lg';
|
|
87
|
+
/** Ocupa a largura toda, com as opções dividindo o espaço por igual (como fill nas Abas). */
|
|
88
|
+
fill?: boolean;
|
|
79
89
|
className?: string;
|
|
80
90
|
}
|
|
81
91
|
/**
|
|
82
92
|
* Poucas opções lado a lado, uma escolhida, com efeito na hora. As setas trocam a opção.
|
|
83
93
|
* https://lumeui.dev/#/componentes/controle-segmentado
|
|
84
94
|
*/
|
|
85
|
-
export declare function SegmentedControl({ options, value, onChange, label, className }: SegmentedControlProps): import("react").JSX.Element;
|
|
95
|
+
export declare function SegmentedControl({ options, value, onChange, label, size, fill, className }: SegmentedControlProps): import("react").JSX.Element;
|
|
86
96
|
export interface PaginationProps {
|
|
87
97
|
/** Total de itens. */
|
|
88
98
|
total: number;
|
package/react/Navigation.js
CHANGED
|
@@ -17,20 +17,20 @@ import { cx } from './cx.js';
|
|
|
17
17
|
* <Menu triggerRef={ref} options={…} value={ordem} onChange={setOrdem} />
|
|
18
18
|
* https://lumeui.dev/#/componentes/menu
|
|
19
19
|
*/
|
|
20
|
-
export function Menu({ triggerRef, options, mode, value, onChange, label, maxRows, sectionColumns }) {
|
|
20
|
+
export function Menu({ triggerRef, options, mode, value, onChange, label, hideLabel, maxRows, sectionColumns }) {
|
|
21
21
|
const change = useLatest(onChange);
|
|
22
22
|
const api = useRef(null);
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
if (!triggerRef.current)
|
|
25
25
|
return;
|
|
26
|
-
const c = createMenu(triggerRef.current, defined({ options, mode, value, label, maxRows, sectionColumns, onChange: (v) => change.current(v) }));
|
|
26
|
+
const c = createMenu(triggerRef.current, defined({ options, mode, value, label, hideLabel, maxRows, sectionColumns, onChange: (v) => change.current(v) }));
|
|
27
27
|
api.current = c;
|
|
28
28
|
return () => {
|
|
29
29
|
c.destroy();
|
|
30
30
|
api.current = null;
|
|
31
31
|
};
|
|
32
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
}, [triggerRef, stableKey(options), mode, label, maxRows, sectionColumns]);
|
|
33
|
+
}, [triggerRef, stableKey(options), mode, label, hideLabel, maxRows, sectionColumns]);
|
|
34
34
|
useEffect(() => {
|
|
35
35
|
if (api.current && value !== undefined && api.current.value !== value)
|
|
36
36
|
api.current.setValue(value);
|
|
@@ -55,13 +55,13 @@ export function Tabs({ items, value, onChange, label, look = 'underline', size =
|
|
|
55
55
|
onChange(tab.id);
|
|
56
56
|
list.current?.querySelector(`#${id}-tab-${tab.id}`)?.focus();
|
|
57
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)))] }));
|
|
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.count !== undefined && t.count !== null && _jsx("span", { className: "ds-tabs__count", children: t.count })] }, 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
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Poucas opções lado a lado, uma escolhida, com efeito na hora. As setas trocam a opção.
|
|
62
62
|
* https://lumeui.dev/#/componentes/controle-segmentado
|
|
63
63
|
*/
|
|
64
|
-
export function SegmentedControl({ options, value, onChange, label, className }) {
|
|
64
|
+
export function SegmentedControl({ options, value, onChange, label, size = 'md', fill, className }) {
|
|
65
65
|
const root = useRef(null);
|
|
66
66
|
const onKey = (event) => {
|
|
67
67
|
const delta = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }[event.key];
|
|
@@ -74,7 +74,7 @@ export function SegmentedControl({ options, value, onChange, label, className })
|
|
|
74
74
|
onChange(next.value);
|
|
75
75
|
root.current?.querySelector(`[data-value="${CSS.escape(next.value)}"]`)?.focus();
|
|
76
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))) }));
|
|
77
|
+
return (_jsx("div", { ref: root, className: cx('ds-segmented', size !== 'md' && `ds-segmented--${size}`, fill && 'ds-segmented--fill', 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
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Páginas de uma lista, com total e itens por página. Em telas estreitas, vira "3 de 25".
|
package/react/index.d.ts
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
export { cx } from './cx.js';
|
|
7
7
|
export { useLocale } from './useLocale.js';
|
|
8
8
|
export { Icon, type IconName, type IconProps } from './Icon.js';
|
|
9
|
-
export { Button, ButtonLink, type ButtonProps, type ButtonLinkProps, type ButtonVariant, type ButtonSize } from './Button.js';
|
|
9
|
+
export { Button, ButtonLink, SplitButton, type ButtonProps, type ButtonLinkProps, type ButtonVariant, type ButtonSize, type SplitButtonProps } from './Button.js';
|
|
10
10
|
export { IconButton, type IconButtonProps } from './IconButton.js';
|
|
11
11
|
export { InlineAction, type InlineActionProps } from './InlineAction.js';
|
|
12
12
|
export { Link, Divider, type LinkProps, type DividerProps } from './Link.js';
|
|
13
13
|
export { Chip, RemovableChip, ChipGroup, type ChipProps, type RemovableChipProps, type ChipGroupProps } from './Chip.js';
|
|
14
14
|
export { Badge, type BadgeProps, type Tone } from './Badge.js';
|
|
15
15
|
export { Alert, type AlertProps, type AlertTone } from './Alert.js';
|
|
16
|
+
export { EmptyState, type EmptyStateProps } from './EmptyState.js';
|
|
16
17
|
export { Banner, NotificationCenter, type BannerProps, type BannerTone, type NotificationCenterProps, type NotificationItem } from './Notices.js';
|
|
17
18
|
export { ImageGallery, openImageViewer, type ImageGalleryProps, type GalleryImage, type ViewerImage } from './ImageViewer.js';
|
|
18
19
|
export { SortableList, Kanban, type SortableListProps, type SortableItem, type KanbanProps, type KanbanColumn } from './Sortable.js';
|
|
@@ -21,7 +22,7 @@ export { Progress, ProgressRing, Spinner, Skeleton, type ProgressProps, type Pro
|
|
|
21
22
|
export { Card, CardLink, Panel, PanelSpacer, PanelMeta, Section, type CardProps, type CardLinkProps, type PanelProps, type SectionProps } from './Panel.js';
|
|
22
23
|
export { Avatar, AvatarGroup, avatarTone, initials, type AvatarProps, type AvatarGroupProps, type AvatarTone, type AvatarStatus, type AvatarSize } from './Avatar.js';
|
|
23
24
|
export { Kbd, DescriptionList, Timeline, Breadcrumb, type KbdProps, type DescriptionListProps, type TimelineProps, type TimelineItem, type BreadcrumbProps, type BreadcrumbItem, } from './Content.js';
|
|
24
|
-
export { Field, Input, Textarea, TextField, FieldAction, useField, type FieldProps, type InputProps, type TextareaProps, type TextFieldProps, type FieldActionProps, type FieldSize } from './Field.js';
|
|
25
|
+
export { Field, Input, Textarea, TextField, FieldAction, FieldGroup, PasswordField, SearchField, CurrencyField, useField, type FieldProps, type InputProps, type TextareaProps, type TextFieldProps, type FieldActionProps, type FieldSize, type FieldGroupProps, type PasswordFieldProps, type SearchFieldProps, type CurrencyFieldProps, } from './Field.js';
|
|
25
26
|
export { Select, type SelectProps, type SelectOption, type SelectGroup } from './Select.js';
|
|
26
27
|
export { Checkbox, Radio, Switch, ChoiceGroup, RadioGroup, CheckboxGroup, type CheckboxProps, type RadioProps, type SwitchProps, type ChoiceGroupProps, type RadioGroupProps, type CheckboxGroupProps, type ChoiceOption, } from './Choice.js';
|
|
27
28
|
export { DatePicker, TimePicker, NumberField, TagField, type DatePickerProps, type DateRange, type TimePickerProps, type NumberFieldProps, type TagFieldProps, } from './Pickers.js';
|
package/react/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { cx } from './cx.js';
|
|
|
8
8
|
export { useLocale } from './useLocale.js';
|
|
9
9
|
export { Icon } from './Icon.js';
|
|
10
10
|
// Ações
|
|
11
|
-
export { Button, ButtonLink } from './Button.js';
|
|
11
|
+
export { Button, ButtonLink, SplitButton } from './Button.js';
|
|
12
12
|
export { IconButton } from './IconButton.js';
|
|
13
13
|
export { InlineAction } from './InlineAction.js';
|
|
14
14
|
export { Link, Divider } from './Link.js';
|
|
@@ -16,6 +16,7 @@ export { Chip, RemovableChip, ChipGroup } from './Chip.js';
|
|
|
16
16
|
// Feedback e carregamento
|
|
17
17
|
export { Badge } from './Badge.js';
|
|
18
18
|
export { Alert } from './Alert.js';
|
|
19
|
+
export { EmptyState } from './EmptyState.js';
|
|
19
20
|
export { Banner, NotificationCenter } from './Notices.js';
|
|
20
21
|
export { ImageGallery, openImageViewer } from './ImageViewer.js';
|
|
21
22
|
export { SortableList, Kanban } from './Sortable.js';
|
|
@@ -26,7 +27,7 @@ export { Card, CardLink, Panel, PanelSpacer, PanelMeta, Section } from './Panel.
|
|
|
26
27
|
export { Avatar, AvatarGroup, avatarTone, initials } from './Avatar.js';
|
|
27
28
|
export { Kbd, DescriptionList, Timeline, Breadcrumb, } from './Content.js';
|
|
28
29
|
// Formulários
|
|
29
|
-
export { Field, Input, Textarea, TextField, FieldAction, useField } from './Field.js';
|
|
30
|
+
export { Field, Input, Textarea, TextField, FieldAction, FieldGroup, PasswordField, SearchField, CurrencyField, useField, } from './Field.js';
|
|
30
31
|
export { Select } from './Select.js';
|
|
31
32
|
export { Checkbox, Radio, Switch, ChoiceGroup, RadioGroup, CheckboxGroup, } from './Choice.js';
|
|
32
33
|
export { DatePicker, TimePicker, NumberField, TagField, } from './Pickers.js';
|