@consumidor-positivo/aurora 3.1.0 → 3.2.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/astro/FeedbackPage/index.astro +2 -2
- package/astro/ListRow/index.astro +32 -36
- package/astro/Logo/ac/BadgeWhiteStroke.astro +1 -0
- package/astro/Logo/cp/BadgeWhiteStroke.astro +1 -1
- package/astro/SearchBar/index.astro +72 -24
- package/dist/{BadgeWhite-CkZPPGmT.js → BadgeWhite-BjdKCzB3.js} +3 -2
- package/dist/{BadgeWhite-CkZPPGmT.js.map → BadgeWhite-BjdKCzB3.js.map} +1 -1
- package/dist/components/DropdownItem/styles.css +1 -1
- package/dist/components/FeedbackPage/index.es.js +2 -2
- package/dist/components/FeedbackPage/index.es.js.map +1 -1
- package/dist/components/ListRow/index.es.js +4 -7
- package/dist/components/ListRow/index.es.js.map +1 -1
- package/dist/components/ListRow/styles.css +1 -1
- package/dist/components/Logo/index.es.js +1 -1
- package/dist/components/SearchBar/hooks.d.ts +8 -2
- package/dist/components/SearchBar/index.d.ts +1 -1
- package/dist/components/SearchBar/index.es.js +23 -6
- package/dist/components/SearchBar/index.es.js.map +1 -1
- package/dist/components/SearchBar/styles.css +1 -1
- package/dist/components/SearchBar/types.d.ts +6 -0
- package/dist/components/SectionApp/styles.css +1 -1
- package/dist/main.es.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-dropdown-item{display:flex;align-items:center;gap:12px;min-height:54px;padding:16px;box-sizing:border-box;background-color:#fff;color:#454a54;font-family:"Source Sans 3",sans-serif;font-size:14px;font-weight:400;line-height:22px;list-style:none;cursor:pointer;-webkit-user-select:none;user-select:none}.au-dropdown-item__leading,.au-dropdown-item__trailing{display:flex;flex:0 0 auto;width:20px;height:20px;align-items:center;justify-content:center}.au-dropdown-item__leading .au-icon,.au-dropdown-item__leading .au-icon>svg,.au-dropdown-item__trailing .au-icon,.au-dropdown-item__trailing .au-icon>svg{color:inherit}.au-dropdown-item__content{display:flex;flex:1 1 auto;flex-direction:column;min-width:0}.au-dropdown-item__label,.au-dropdown-item__description{display:block}.au-dropdown-item__leading .au-checkbox__holder{gap:0}.au-dropdown-item__leading .au-checkbox__label{display:none}.au-dropdown-item--with-description .au-dropdown-item__label{font-weight:600}.au-dropdown-item--type-item:not(.au-dropdown-item--disabled):not(.au-dropdown-item--state-loading):not(.au-dropdown-item--state-skeleton):not(.au-dropdown-item--state-empty):hover{background-color:#f6f7fa}.au-dropdown-item--type-item:not(.au-dropdown-item--disabled):not(.au-dropdown-item--state-loading):not(.au-dropdown-item--state-skeleton):not(.au-dropdown-item--state-empty):active{background-color:#e2e4e9}.au-dropdown-item--focused{box-shadow:inset 0 0 0 2px #0048db}.au-dropdown-item--selected{background-color:#f2f5fc;color:#0048db}.au-dropdown-item--selected .au-dropdown-item__label{font-weight:600}.au-dropdown-item--with-checkbox.au-dropdown-item--selected{background-color:#fff;color:#454a54}.au-dropdown-item--with-checkbox.au-dropdown-item--selected .au-dropdown-item__label{font-weight:400}.au-dropdown-item--with-checkbox.au-dropdown-item--with-description.au-dropdown-item--selected .au-dropdown-item__label{font-weight:600}.au-dropdown-item--disabled{color:#c4c9d4;cursor:not-allowed}.au-dropdown-item--type-category{min-height:
|
|
1
|
+
.au-dropdown-item{display:flex;align-items:center;gap:12px;min-height:54px;padding:16px;box-sizing:border-box;background-color:#fff;color:#454a54;font-family:"Source Sans 3",sans-serif;font-size:14px;font-weight:400;line-height:22px;list-style:none;cursor:pointer;-webkit-user-select:none;user-select:none}.au-dropdown-item__leading,.au-dropdown-item__trailing{display:flex;flex:0 0 auto;width:20px;height:20px;align-items:center;justify-content:center}.au-dropdown-item__leading .au-icon,.au-dropdown-item__leading .au-icon>svg,.au-dropdown-item__trailing .au-icon,.au-dropdown-item__trailing .au-icon>svg{color:inherit}.au-dropdown-item__content{display:flex;flex:1 1 auto;flex-direction:column;min-width:0}.au-dropdown-item__label,.au-dropdown-item__description{display:block}.au-dropdown-item__leading .au-checkbox{pointer-events:none}.au-dropdown-item__leading .au-checkbox__holder{gap:0}.au-dropdown-item__leading .au-checkbox__label{display:none}.au-dropdown-item--with-description .au-dropdown-item__label{font-weight:600}.au-dropdown-item--type-item:not(.au-dropdown-item--disabled):not(.au-dropdown-item--state-loading):not(.au-dropdown-item--state-skeleton):not(.au-dropdown-item--state-empty):hover{background-color:#f6f7fa}.au-dropdown-item--type-item:not(.au-dropdown-item--disabled):not(.au-dropdown-item--state-loading):not(.au-dropdown-item--state-skeleton):not(.au-dropdown-item--state-empty):active{background-color:#e2e4e9}.au-dropdown-item--focused{box-shadow:inset 0 0 0 2px #0048db}.au-dropdown-item--selected{background-color:#f2f5fc;color:#0048db}.au-dropdown-item--selected .au-dropdown-item__label{font-weight:600}.au-dropdown-item--with-checkbox.au-dropdown-item--selected{background-color:#fff;color:#454a54}.au-dropdown-item--with-checkbox.au-dropdown-item--selected .au-dropdown-item__label{font-weight:400}.au-dropdown-item--with-checkbox.au-dropdown-item--with-description.au-dropdown-item--selected .au-dropdown-item__label{font-weight:600}.au-dropdown-item--disabled{color:#c4c9d4;cursor:not-allowed}.au-dropdown-item--type-category{min-height:39px;padding:12px 12px 8px;border-top:1px solid #e2e4e9;color:#5e6573;font-size:12px;line-height:19px;cursor:default}.au-dropdown-item--type-category:first-child{border-top:0}.au-dropdown-item--state-loading,.au-dropdown-item--state-skeleton{cursor:default}.au-dropdown-item--state-empty{color:#5e6573;cursor:default}
|
|
@@ -5,12 +5,12 @@ import { Button } from "../Button/index.es.js";
|
|
|
5
5
|
import { Text } from "../Text/index.es.js";
|
|
6
6
|
import "../Icon/index.es.js";
|
|
7
7
|
import { IconAlertOctagon } from "../icons/IconAlertOctagon/index.es.js";
|
|
8
|
+
import { IconAlertTriangle } from "../icons/IconAlertTriangle/index.es.js";
|
|
8
9
|
import { IconCheckCircle } from "../icons/IconCheckCircle/index.es.js";
|
|
9
|
-
import { IconRefreshCw } from "../icons/IconRefreshCw/index.es.js";
|
|
10
10
|
import './styles.css';const ICONS = {
|
|
11
11
|
error: IconAlertOctagon,
|
|
12
12
|
success: IconCheckCircle,
|
|
13
|
-
warning:
|
|
13
|
+
warning: IconAlertTriangle
|
|
14
14
|
};
|
|
15
15
|
const FeedbackPage = ({
|
|
16
16
|
type = "error",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../lib/components/FeedbackPage/index.tsx"],"sourcesContent":["import { useId } from 'react'\nimport classNames from 'classnames'\nimport { Button } from '@components/Button'\nimport { Text } from '@components/Text'\nimport { IconAlertOctagon,
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../lib/components/FeedbackPage/index.tsx"],"sourcesContent":["import { useId } from 'react'\nimport classNames from 'classnames'\nimport { Button } from '@components/Button'\nimport { Text } from '@components/Text'\nimport { IconAlertOctagon, IconAlertTriangle, IconCheckCircle } from '@components/icons'\nimport './styles.scss'\n\nexport type FeedbackPageType = 'error' | 'success' | 'warning'\nexport type FeedbackPageSize = 'mobile' | 'desktop'\n\nexport type FeedbackPageAction = {\n label: string\n onClick?: () => void\n /** Com `href`, o botão sai como link (`<a>`). */\n href?: string\n target?: string\n}\n\nexport type FeedbackPageProps = {\n /** Error (falhou), Success (deu certo) ou Warning (pede atenção ou espera). Figma: Feedback Page, Type. */\n type?: FeedbackPageType\n title: string\n description?: string\n /** Primeiro botão, Outlined: a ação que resolve. Sem ele a tela sai sem botões (Show Buttons=False). */\n primaryAction?: FeedbackPageAction\n /** Segundo botão, Ghost: o caminho de volta. Só aparece junto do primeiro (Only 1 Button=False o desliga). */\n secondaryAction?: FeedbackPageAction\n /** Força o layout Mobile (botões empilhados) ou Desktop (lado a lado). Sem ela, segue o breakpoint de 1024px. Figma: Size. */\n size?: FeedbackPageSize\n /** Tag do título. @default 'h1' */\n titleAs?: 'h1' | 'h2' | 'h3'\n className?: string\n 'data-testid'?: string\n}\n\nconst ICONS = {\n error: IconAlertOctagon,\n success: IconCheckCircle,\n warning: IconAlertTriangle,\n}\n\nexport const FeedbackPage = ({\n type = 'error',\n title,\n description,\n primaryAction,\n secondaryAction,\n size,\n titleAs = 'h1',\n className,\n 'data-testid': dataTestId,\n}: FeedbackPageProps) => {\n const titleId = `au-feedback-page-${useId().replace(/[^a-zA-Z0-9]/g, '')}-title`\n const Icon = ICONS[type]\n const actions = primaryAction ? [primaryAction, secondaryAction].filter(Boolean) as FeedbackPageAction[] : []\n\n const classes = classNames('au-feedback-page', `au-feedback-page--type-${type}`, {\n [`au-feedback-page--size-${size}`]: !!size,\n 'au-feedback-page--with-actions': actions.length > 0,\n [className!]: !!className,\n })\n\n return (\n <section className={classes} aria-labelledby={titleId} data-testid={dataTestId}>\n <div className=\"au-feedback-page__icon\" aria-hidden=\"true\">\n <span className=\"au-feedback-page__icon-circle\">\n <Icon size=\"medium\" />\n </span>\n </div>\n <Text as={titleAs} id={titleId} variant=\"heading-medium\" weight=\"semibold\" className=\"au-feedback-page__title\">\n {title}\n </Text>\n {description && (\n <Text as=\"p\" variant=\"body-medium\" color=\"secondary\" className=\"au-feedback-page__description\">\n {description}\n </Text>\n )}\n {actions.length > 0 && (\n <div className=\"au-feedback-page__actions\">\n {actions.map((action, index) => {\n const actionClasses = classNames('au-feedback-page__action', {\n 'au-feedback-page__action--primary': index === 0,\n 'au-feedback-page__action--secondary': index === 1,\n })\n const buttonType = index === 0 ? 'outlined' : 'ghost'\n return action.href ? (\n <Button\n key={index}\n as=\"a\"\n href={action.href}\n target={action.target}\n type={buttonType}\n size=\"medium\"\n className={actionClasses}\n onClick={action.onClick}>\n {action.label}\n </Button>\n ) : (\n <Button key={index} type={buttonType} size=\"medium\" className={actionClasses} onClick={action.onClick}>\n {action.label}\n </Button>\n )\n })}\n </div>\n )}\n </section>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;AAmCA,MAAM,QAAQ;AAAA,EACZ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACX;AAEO,MAAM,eA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AA,QAAA;AAAA,UAEC,IAAG;AAAA,UACH,MAAM,OAAO;AAAA,UACb,QAAQ,OAAO;AAAA,UACf,MAAM;AAAA,UACN,MAAK;AAAA,UACL,WAAW;AAAA,UACX,SAAS,OAAO;AAAA,UACf,UAAA,OAAO;AAAA,QAAA;AAAA,QARH;AAAA,MAAA,IAWP,oBAAC,QAAA,EAAmB,MAAM,YAAY,MAAK,UAAS,WAAW,eAAe,SAAS,OAAO,SAC3F,UAAA,OAAO,SADG,KAEb;AAAA,IAEJ,CAAC,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -52,7 +52,7 @@ const ListRow = (props) => {
|
|
|
52
52
|
if (!leading) return null;
|
|
53
53
|
if (skeleton) {
|
|
54
54
|
return /* @__PURE__ */ jsxs("div", { className: `au-list-row__leading au-list-row__leading--${leading}`, children: [
|
|
55
|
-
leading === "icon" && /* @__PURE__ */ jsx(Skeleton, {
|
|
55
|
+
leading === "icon" && /* @__PURE__ */ jsx(Skeleton, { width: 20, height: 20 }),
|
|
56
56
|
leading === "partner" && /* @__PURE__ */ jsx(Skeleton, { shape: "square", width: 40, height: 40 }),
|
|
57
57
|
leading === "radio" && /* @__PURE__ */ jsx(Skeleton, { shape: "circle", width: 20, height: 20 }),
|
|
58
58
|
leading === "trackline" && /* @__PURE__ */ jsx(Skeleton, { shape: "circle", width: 24, height: 24 })
|
|
@@ -75,8 +75,8 @@ const ListRow = (props) => {
|
|
|
75
75
|
const _renderMain = () => {
|
|
76
76
|
if (skeleton) {
|
|
77
77
|
return /* @__PURE__ */ jsxs("div", { className: "au-list-row__main", children: [
|
|
78
|
-
/* @__PURE__ */ jsx(Skeleton, { width:
|
|
79
|
-
|
|
78
|
+
twoLines && /* @__PURE__ */ jsx(Skeleton, { width: 104, height: 22 }),
|
|
79
|
+
/* @__PURE__ */ jsx(Skeleton, { width: 160, height: 22 })
|
|
80
80
|
] });
|
|
81
81
|
}
|
|
82
82
|
return /* @__PURE__ */ jsxs("div", { className: "au-list-row__main", children: [
|
|
@@ -85,10 +85,7 @@ const ListRow = (props) => {
|
|
|
85
85
|
] });
|
|
86
86
|
};
|
|
87
87
|
const _renderTrailing = () => {
|
|
88
|
-
if (!hasTrailing) return null;
|
|
89
|
-
if (skeleton) {
|
|
90
|
-
return /* @__PURE__ */ jsx("div", { className: "au-list-row__trailing", children: /* @__PURE__ */ jsx(Skeleton, { width: 56, height: 16 }) });
|
|
91
|
-
}
|
|
88
|
+
if (!hasTrailing || skeleton) return null;
|
|
92
89
|
return /* @__PURE__ */ jsxs("div", { className: "au-list-row__trailing", children: [
|
|
93
90
|
hasSecondary && /* @__PURE__ */ jsxs("span", { className: "au-list-row__secondary", children: [
|
|
94
91
|
secondaryLabel && /* @__PURE__ */ jsx("span", { className: "au-list-row__secondary-label", children: secondaryLabel }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../lib/components/ListRow/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { BadgeState, BadgeStateProps } from '@components/BadgeState'\nimport { Divider } from '@components/Divider'\nimport { LinkButton } from '@components/LinkButton'\nimport { Skeleton } from '@components/Skeleton'\nimport { Switch, SwitchProps } from '@components/Switch'\nimport { IconCheck, IconChevronRight } from '@components/icons'\nimport { RadioFieldProps } from '../form/Radio/types'\nimport { RadioField } from '../form/Radio/Field'\nimport './styles.scss'\n\nexport type ListRowContent = 'upward' | 'downward'\n\nexport type ListRowTrackline = {\n /** Number (etapa numerada), Check (etapa concluída) ou Badge State (etapa com status). Figma: Track line. */\n marker?: 'number' | 'check' | 'badge'\n /** Número da etapa, no marcador Number. */\n number?: number\n /** Status do BadgeState, no marcador Badge State. */\n status?: BadgeStateProps['status']\n /** Última etapa: sem o traço (Dash) que liga à próxima. */\n last?: boolean\n}\n\nexport type ListRowLink = {\n label: string\n onClick?: () => void\n href?: string\n target?: string\n}\n\nexport type ListRowBadge = {\n status: BadgeStateProps['status']\n text: string\n variant?: BadgeStateProps['variant']\n}\n\nexport type ListRowProps = {\n label: string\n /** Segunda linha (Multiple line no Figma). Sem ela a linha tem 56px; com ela, 80px. */\n description?: string\n /** Para cima (label em destaque, padrão) ou para baixo (label pequeno em cima, valor em destaque embaixo). Figma: Downward Content. */\n content?: ListRowContent\n /** Leading com ícone: ícone 20px num quadrado de 44px. */\n icon?: ReactNode\n /** Leading com parceiro: a thumb do parceiro, recortada em 40x40 com raio 8. */\n partner?: ReactNode\n /** Leading com seleção: o `Radio.Field` da lib, sem label (a linha é o label). */\n radio?: Omit<RadioFieldProps, 'label' | 'direction' | 'type'>\n /** Leading com trackline: marcador ligado à próxima etapa por um traço. */\n trackline?: ListRowTrackline\n /** Trailing com conteúdo secundário: rótulo alinhado à direita. */\n secondaryLabel?: string\n /** Segunda linha do conteúdo secundário. */\n secondaryDescription?: string\n /** Trailing com link: um `LinkButton` small. */\n link?: ListRowLink\n /** Trailing com badge: um `BadgeState`. */\n badge?: ListRowBadge\n /** Trailing com ícone: o chevron que indica que a linha leva a outra tela. */\n chevron?: boolean\n /** Trailing com toggle: o `Switch` da lib, sem label (passe `aria-label`). */\n toggle?: Omit<SwitchProps, 'label' | 'description' | 'textDirection' | 'fullWidth'>\n /** Estado de carregamento, com o mesmo leading e o mesmo número de linhas do conteúdo final. Figma: Skeleton. */\n skeleton?: boolean\n /** A linha inteira leva a outra tela: a raiz vira um `<a>` (`as` é ignorado). Ignorado com `skeleton`. */\n href?: string\n target?: string\n /** A linha inteira é clicável: vira um botão (`role=\"button\"`). Não combine com link, toggle ou radio. Ignorado com `skeleton`. */\n onClick?: () => void\n /** Tag da raiz. @default 'div' */\n as?: 'div' | 'li'\n className?: string\n 'data-testid'?: string\n}\n\nconst _leadingType = ({ icon, partner, radio, trackline }: ListRowProps) =>\n trackline ? 'trackline' : radio ? 'radio' : partner ? 'partner' : icon ? 'icon' : null\n\nexport const ListRow = (props: ListRowProps) => {\n const {\n label,\n description,\n content = 'upward',\n icon,\n partner,\n radio,\n trackline,\n secondaryLabel,\n secondaryDescription,\n link,\n badge,\n chevron = false,\n toggle,\n skeleton = false,\n href,\n target,\n onClick,\n as = 'div',\n className,\n 'data-testid': dataTestId,\n } = props\n\n const leading = _leadingType(props)\n const hasSecondary = !!secondaryLabel || !!secondaryDescription\n const hasTrailing = hasSecondary || !!link || !!badge || chevron || !!toggle\n const twoLines = !!description\n // The skeleton is `aria-hidden`, so it is never a link or a button: a\n // focusable element inside a hidden tree fails WCAG 4.1.2.\n const clickable = (!!href || !!onClick) && !skeleton\n\n const classes = classNames('au-list-row', `au-list-row--content-${content}`, {\n 'au-list-row--two-lines': twoLines,\n [`au-list-row--leading-${leading}`]: !!leading,\n 'au-list-row--with-trailing': hasTrailing,\n 'au-list-row--skeleton': skeleton,\n 'au-list-row--clickable': clickable,\n 'au-list-row--trackline-last': !!trackline?.last,\n [className!]: !!className,\n })\n\n const _renderLeading = () => {\n if (!leading) return null\n if (skeleton) {\n return (\n <div className={`au-list-row__leading au-list-row__leading--${leading}`}>\n {leading === 'icon' && <Skeleton shape=\"square\" width={44} height={44} />}\n {leading === 'partner' && <Skeleton shape=\"square\" width={40} height={40} />}\n {leading === 'radio' && <Skeleton shape=\"circle\" width={20} height={20} />}\n {leading === 'trackline' && <Skeleton shape=\"circle\" width={24} height={24} />}\n </div>\n )\n }\n return (\n <div className={`au-list-row__leading au-list-row__leading--${leading}`}>\n {leading === 'icon' && (\n <span className=\"au-list-row__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {leading === 'partner' && <span className=\"au-list-row__partner\">{partner}</span>}\n {leading === 'radio' && <RadioField {...radio} />}\n {leading === 'trackline' && (\n <span className=\"au-list-row__trackline\">\n <span className={`au-list-row__marker au-list-row__marker--${trackline!.marker ?? 'number'}`}>\n {(trackline!.marker ?? 'number') === 'number' && trackline!.number}\n {trackline!.marker === 'check' && <IconCheck size=\"small\" />}\n {trackline!.marker === 'badge' && <BadgeState status={trackline!.status ?? 'info'} iconOnly />}\n </span>\n {!trackline!.last && <span className=\"au-list-row__dash\" aria-hidden=\"true\" />}\n </span>\n )}\n </div>\n )\n }\n\n const _renderMain = () => {\n if (skeleton) {\n return (\n <div className=\"au-list-row__main\">\n <Skeleton width={160} height={16} />\n {twoLines && <Skeleton width={104} height={14} />}\n </div>\n )\n }\n return (\n <div className=\"au-list-row__main\">\n <span className=\"au-list-row__label\">{label}</span>\n {description && <span className=\"au-list-row__description\">{description}</span>}\n </div>\n )\n }\n\n const _renderTrailing = () => {\n if (!hasTrailing) return null\n if (skeleton) {\n return (\n <div className=\"au-list-row__trailing\">\n <Skeleton width={56} height={16} />\n </div>\n )\n }\n return (\n <div className=\"au-list-row__trailing\">\n {hasSecondary && (\n <span className=\"au-list-row__secondary\">\n {secondaryLabel && <span className=\"au-list-row__secondary-label\">{secondaryLabel}</span>}\n {secondaryDescription && (\n <span className=\"au-list-row__secondary-description\">{secondaryDescription}</span>\n )}\n </span>\n )}\n {link &&\n (link.href ? (\n <LinkButton as=\"a\" href={link.href} target={link.target} size=\"small\" className=\"au-list-row__link\">\n {link.label}\n </LinkButton>\n ) : (\n <LinkButton size=\"small\" className=\"au-list-row__link\" onClick={link.onClick}>\n {link.label}\n </LinkButton>\n ))}\n {badge && <BadgeState status={badge.status} text={badge.text} variant={badge.variant} />}\n {toggle && <Switch {...toggle} />}\n {chevron && (\n <span className=\"au-list-row__chevron\" aria-hidden=\"true\">\n <IconChevronRight />\n </span>\n )}\n </div>\n )\n }\n\n const inner = (\n <>\n <Divider width=\"small\" />\n <div className=\"au-list-row__content\">\n {_renderLeading()}\n {_renderMain()}\n {_renderTrailing()}\n </div>\n <Divider width=\"small\" />\n </>\n )\n\n const shared = {\n className: classes,\n 'data-testid': dataTestId,\n 'aria-busy': skeleton || undefined,\n 'aria-hidden': skeleton || undefined,\n }\n\n // With `href` the root is the link itself (wrap it in your own `li`).\n if (href && clickable) {\n return (\n <a {...shared} href={href} target={target}>\n {inner}\n </a>\n )\n }\n\n const Tag = as\n if (onClick && clickable) {\n const handleKeyDown = (event: React.KeyboardEvent) => {\n // Only keys pressed on the row itself: a key on an inner control (the\n // toggle, the radio, the link) bubbles up here and must keep its own\n // default, so Space still flips the toggle instead of firing the row.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onClick()\n }\n }\n return (\n <Tag {...shared} role=\"button\" tabIndex={0} onClick={onClick} onKeyDown={handleKeyDown}>\n {inner}\n </Tag>\n )\n }\n\n return <Tag {...shared}>{inner}</Tag>\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA6EA,MAAM,eAAe,CAAC,EAAE,MAAM,SAAS,OAAO,UAAA,MAC5C,YAAY,cAAc,QAAQ,UAAU,UAAU,YAAY,OAAO,SAAS;AAE7E,MAAM,UAAU,CAAC,UAAwB;AAC9C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA,eAAe;AAAA,EAAA,IACb;AAEJ,QAAM,UAAU,aAAa,KAAK;AAClC,QAAM,eAAe,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAC3C,QAAM,cAAc,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC;AACtE,QAAM,WAAW,CAAC,CAAC;AAGnB,QAAM,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC;AAE5C,QAAM,UAAU,WAAW,eAAe,wBAAwB,OAAO,IAAI;AAAA,IAC3E,0BAA0B;AAAA,IAC1B,CAAC,wBAAwB,OAAO,EAAE,GAAG,CAAC,CAAC;AAAA,IACvC,8BAA8B;AAAA,IAC9B,yBAAyB;AAAA,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S,UAAA,OAAM;AACjC;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../lib/components/ListRow/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { BadgeState, BadgeStateProps } from '@components/BadgeState'\nimport { Divider } from '@components/Divider'\nimport { LinkButton } from '@components/LinkButton'\nimport { Skeleton } from '@components/Skeleton'\nimport { Switch, SwitchProps } from '@components/Switch'\nimport { IconCheck, IconChevronRight } from '@components/icons'\nimport { RadioFieldProps } from '../form/Radio/types'\nimport { RadioField } from '../form/Radio/Field'\nimport './styles.scss'\n\nexport type ListRowContent = 'upward' | 'downward'\n\nexport type ListRowTrackline = {\n /** Number (etapa numerada), Check (etapa concluída) ou Badge State (etapa com status). Figma: Track line. */\n marker?: 'number' | 'check' | 'badge'\n /** Número da etapa, no marcador Number. */\n number?: number\n /** Status do BadgeState, no marcador Badge State. */\n status?: BadgeStateProps['status']\n /** Última etapa: sem o traço (Dash) que liga à próxima. */\n last?: boolean\n}\n\nexport type ListRowLink = {\n label: string\n onClick?: () => void\n href?: string\n target?: string\n}\n\nexport type ListRowBadge = {\n status: BadgeStateProps['status']\n text: string\n variant?: BadgeStateProps['variant']\n}\n\nexport type ListRowProps = {\n label: string\n /** Segunda linha (Multiple line no Figma). Sem ela a linha tem 56px; com ela, 80px. */\n description?: string\n /** Para cima (label em destaque, padrão) ou para baixo (label pequeno em cima, valor em destaque embaixo). Figma: Downward Content. */\n content?: ListRowContent\n /** Leading com ícone: ícone 20px num quadrado de 44px. */\n icon?: ReactNode\n /** Leading com parceiro: a thumb do parceiro, recortada em 40x40 com raio 8. */\n partner?: ReactNode\n /** Leading com seleção: o `Radio.Field` da lib, sem label (a linha é o label). */\n radio?: Omit<RadioFieldProps, 'label' | 'direction' | 'type'>\n /** Leading com trackline: marcador ligado à próxima etapa por um traço. */\n trackline?: ListRowTrackline\n /** Trailing com conteúdo secundário: rótulo alinhado à direita. */\n secondaryLabel?: string\n /** Segunda linha do conteúdo secundário. */\n secondaryDescription?: string\n /** Trailing com link: um `LinkButton` small. */\n link?: ListRowLink\n /** Trailing com badge: um `BadgeState`. */\n badge?: ListRowBadge\n /** Trailing com ícone: o chevron que indica que a linha leva a outra tela. */\n chevron?: boolean\n /** Trailing com toggle: o `Switch` da lib, sem label (passe `aria-label`). */\n toggle?: Omit<SwitchProps, 'label' | 'description' | 'textDirection' | 'fullWidth'>\n /** Estado de carregamento, com o mesmo leading e o mesmo número de linhas do conteúdo final. Figma: Skeleton. */\n skeleton?: boolean\n /** A linha inteira leva a outra tela: a raiz vira um `<a>` (`as` é ignorado). Ignorado com `skeleton`. */\n href?: string\n target?: string\n /** A linha inteira é clicável: vira um botão (`role=\"button\"`). Não combine com link, toggle ou radio. Ignorado com `skeleton`. */\n onClick?: () => void\n /** Tag da raiz. @default 'div' */\n as?: 'div' | 'li'\n className?: string\n 'data-testid'?: string\n}\n\nconst _leadingType = ({ icon, partner, radio, trackline }: ListRowProps) =>\n trackline ? 'trackline' : radio ? 'radio' : partner ? 'partner' : icon ? 'icon' : null\n\nexport const ListRow = (props: ListRowProps) => {\n const {\n label,\n description,\n content = 'upward',\n icon,\n partner,\n radio,\n trackline,\n secondaryLabel,\n secondaryDescription,\n link,\n badge,\n chevron = false,\n toggle,\n skeleton = false,\n href,\n target,\n onClick,\n as = 'div',\n className,\n 'data-testid': dataTestId,\n } = props\n\n const leading = _leadingType(props)\n const hasSecondary = !!secondaryLabel || !!secondaryDescription\n const hasTrailing = hasSecondary || !!link || !!badge || chevron || !!toggle\n const twoLines = !!description\n // The skeleton is `aria-hidden`, so it is never a link or a button: a\n // focusable element inside a hidden tree fails WCAG 4.1.2.\n const clickable = (!!href || !!onClick) && !skeleton\n\n const classes = classNames('au-list-row', `au-list-row--content-${content}`, {\n 'au-list-row--two-lines': twoLines,\n [`au-list-row--leading-${leading}`]: !!leading,\n 'au-list-row--with-trailing': hasTrailing,\n 'au-list-row--skeleton': skeleton,\n 'au-list-row--clickable': clickable,\n 'au-list-row--trackline-last': !!trackline?.last,\n [className!]: !!className,\n })\n\n const _renderLeading = () => {\n if (!leading) return null\n if (skeleton) {\n return (\n <div className={`au-list-row__leading au-list-row__leading--${leading}`}>\n {leading === 'icon' && <Skeleton width={20} height={20} />}\n {leading === 'partner' && <Skeleton shape=\"square\" width={40} height={40} />}\n {leading === 'radio' && <Skeleton shape=\"circle\" width={20} height={20} />}\n {leading === 'trackline' && <Skeleton shape=\"circle\" width={24} height={24} />}\n </div>\n )\n }\n return (\n <div className={`au-list-row__leading au-list-row__leading--${leading}`}>\n {leading === 'icon' && (\n <span className=\"au-list-row__icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {leading === 'partner' && <span className=\"au-list-row__partner\">{partner}</span>}\n {leading === 'radio' && <RadioField {...radio} />}\n {leading === 'trackline' && (\n <span className=\"au-list-row__trackline\">\n <span className={`au-list-row__marker au-list-row__marker--${trackline!.marker ?? 'number'}`}>\n {(trackline!.marker ?? 'number') === 'number' && trackline!.number}\n {trackline!.marker === 'check' && <IconCheck size=\"small\" />}\n {trackline!.marker === 'badge' && <BadgeState status={trackline!.status ?? 'info'} iconOnly />}\n </span>\n {!trackline!.last && <span className=\"au-list-row__dash\" aria-hidden=\"true\" />}\n </span>\n )}\n </div>\n )\n }\n\n const _renderMain = () => {\n if (skeleton) {\n return (\n <div className=\"au-list-row__main\">\n {twoLines && <Skeleton width={104} height={22} />}\n <Skeleton width={160} height={22} />\n </div>\n )\n }\n return (\n <div className=\"au-list-row__main\">\n <span className=\"au-list-row__label\">{label}</span>\n {description && <span className=\"au-list-row__description\">{description}</span>}\n </div>\n )\n }\n\n // The skeleton has no trailing: only the leading and the text lines load.\n const _renderTrailing = () => {\n if (!hasTrailing || skeleton) return null\n return (\n <div className=\"au-list-row__trailing\">\n {hasSecondary && (\n <span className=\"au-list-row__secondary\">\n {secondaryLabel && <span className=\"au-list-row__secondary-label\">{secondaryLabel}</span>}\n {secondaryDescription && (\n <span className=\"au-list-row__secondary-description\">{secondaryDescription}</span>\n )}\n </span>\n )}\n {link &&\n (link.href ? (\n <LinkButton as=\"a\" href={link.href} target={link.target} size=\"small\" className=\"au-list-row__link\">\n {link.label}\n </LinkButton>\n ) : (\n <LinkButton size=\"small\" className=\"au-list-row__link\" onClick={link.onClick}>\n {link.label}\n </LinkButton>\n ))}\n {badge && <BadgeState status={badge.status} text={badge.text} variant={badge.variant} />}\n {toggle && <Switch {...toggle} />}\n {chevron && (\n <span className=\"au-list-row__chevron\" aria-hidden=\"true\">\n <IconChevronRight />\n </span>\n )}\n </div>\n )\n }\n\n const inner = (\n <>\n <Divider width=\"small\" />\n <div className=\"au-list-row__content\">\n {_renderLeading()}\n {_renderMain()}\n {_renderTrailing()}\n </div>\n <Divider width=\"small\" />\n </>\n )\n\n const shared = {\n className: classes,\n 'data-testid': dataTestId,\n 'aria-busy': skeleton || undefined,\n 'aria-hidden': skeleton || undefined,\n }\n\n // With `href` the root is the link itself (wrap it in your own `li`).\n if (href && clickable) {\n return (\n <a {...shared} href={href} target={target}>\n {inner}\n </a>\n )\n }\n\n const Tag = as\n if (onClick && clickable) {\n const handleKeyDown = (event: React.KeyboardEvent) => {\n // Only keys pressed on the row itself: a key on an inner control (the\n // toggle, the radio, the link) bubbles up here and must keep its own\n // default, so Space still flips the toggle instead of firing the row.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onClick()\n }\n }\n return (\n <Tag {...shared} role=\"button\" tabIndex={0} onClick={onClick} onKeyDown={handleKeyDown}>\n {inner}\n </Tag>\n )\n }\n\n return <Tag {...shared}>{inner}</Tag>\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA6EA,MAAM,eAAe,CAAC,EAAE,MAAM,SAAS,OAAO,UAAA,MAC5C,YAAY,cAAc,QAAQ,UAAU,UAAU,YAAY,OAAO,SAAS;AAE7E,MAAM,UAAU,CAAC,UAAwB;AAC9C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA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e;AAAA,IACf,aAAa,YAAY;AAAA,IACzB,eAAe,YAAY;AAAA,EAAA;AAI7B,MAAI,QAAQ,WAAW;AACrB,+BACG,KAAA,EAAG,GAAG,QAAQ,MAAY,QACxB,UAAA,OACH;AAAA,EAEJ;AAEA,QAAM,MAAM;AACZ,MAAI,WAAW,WAAW;AACxB,UAAM,gBAAgB,CAAC,UAA+B;AAIpD,UAAI,MAAM,WAAW,MAAM,cAAe;AAC1C,UAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;AAC9C,cAAM,eAAA;AACN,gBAAA;AAAA,MACF;AAAA,IACF;AACA,WACE,oBAAC,KAAA,EAAK,GAAG,QAAQ,MAAK,UAAS,UAAU,GAAG,SAAkB,WAAW,eACtE,UAAA,MAAA,CACH;AAAA,EAEJ;AAEA,SAAO,oBAAC,KAAA,EAAK,GAAG,QAAS,UAAA,OAAM;AACjC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-list-row{display:block;width:100%;box-sizing:border-box;background-color:#fff;color:#16181d;font-family:"Source Sans 3",sans-serif;text-align:start;text-decoration:none}.au-list-row+.au-list-row>.au-divider:first-child{display:none}.au-list-row__content{display:flex;align-items:center;gap:16px;padding:16px 24px;box-sizing:border-box;min-height:56px}.au-list-row--two-lines .au-list-row__content{min-height:80px}.au-list-row__leading{display:flex;flex:none;align-items:center;align-self:stretch}.au-list-row__icon{display:flex;align-items:center;justify-content:center;width:44px;height:44px;padding:12px;box-sizing:border-box;border-radius:6px;background-color:#f6f7fa;color:#16181d}.au-list-row__icon .au-icon,.au-list-row__icon .au-icon>svg{width:20px;height:20px;color:inherit}.au-list-row__partner{display:flex;width:40px;height:40px;overflow:hidden;border-radius:8px}.au-list-row__partner img{display:block;width:100%;height:100%;object-fit:cover}.au-list-row__leading .au-radio-field{gap:0}.au-list-row__leading .au-radio-field__label{display:none}.au-list-row__trackline{position:relative;display:flex;align-items:center;align-self:stretch;width:24px;justify-content:center}.au-list-row__marker{display:flex;flex:none;align-items:center;justify-content:center;width:24px;height:24px;border-radius:999px;background-color:#f6f7fa;color:#454a54;font-size:12px;font-weight:600;line-height:16px;z-index:1}.au-list-row__marker--check{background-color:#e5fff0;color:#10593b}.au-list-row__marker--badge{background:none}.au-list-row__marker .au-icon,.au-list-row__marker .au-icon>svg{color:inherit}.au-list-row__dash{position:absolute;top:50%;bottom:-16px;left:50%;border-left:1px
|
|
1
|
+
.au-list-row{display:block;width:100%;box-sizing:border-box;background-color:#fff;color:#16181d;font-family:"Source Sans 3",sans-serif;text-align:start;text-decoration:none}.au-list-row+.au-list-row>.au-divider:first-child{display:none}.au-list-row__content{display:flex;align-items:center;gap:16px;padding:16px 24px;box-sizing:border-box;min-height:56px}.au-list-row--two-lines .au-list-row__content{min-height:80px}.au-list-row__leading{display:flex;flex:none;align-items:center;align-self:stretch}.au-list-row__icon{display:flex;align-items:center;justify-content:center;width:44px;height:44px;padding:12px;box-sizing:border-box;border-radius:6px;background-color:#f6f7fa;color:#16181d}.au-list-row__icon .au-icon,.au-list-row__icon .au-icon>svg{width:20px;height:20px;color:inherit}.au-list-row__partner{display:flex;width:40px;height:40px;overflow:hidden;border-radius:8px}.au-list-row__partner img{display:block;width:100%;height:100%;object-fit:cover}.au-list-row__leading .au-radio-field{gap:0}.au-list-row__leading .au-radio-field__label{display:none}.au-list-row--leading-trackline>.au-divider{visibility:hidden}.au-list-row__trackline{position:relative;display:flex;align-items:center;align-self:stretch;width:24px;justify-content:center}.au-list-row__marker{display:flex;flex:none;align-items:center;justify-content:center;width:24px;height:24px;border-radius:999px;background-color:#f6f7fa;color:#454a54;font-size:12px;font-weight:600;line-height:16px;z-index:1}.au-list-row__marker--check{background-color:#e5fff0;color:#10593b}.au-list-row__marker--badge{background:none}.au-list-row__marker--badge .au-badgeState{width:24px;height:24px;padding:5px;box-sizing:border-box;border-radius:999px}.au-list-row__marker .au-icon,.au-list-row__marker .au-icon>svg{color:inherit}.au-list-row__dash{position:absolute;top:50%;bottom:-17px;left:50%;border-left:1px solid #c4c9d4}.au-list-row+.au-list-row--leading-trackline .au-list-row__trackline:before{content:"";position:absolute;top:-16px;bottom:50%;left:50%;border-left:1px solid #c4c9d4}.au-list-row__main{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;min-width:0}.au-list-row__label{display:block;font-size:16px;font-weight:600;line-height:24px;color:#16181d}.au-list-row__description{display:block;font-size:14px;font-weight:400;line-height:22px;color:#5e6573}.au-list-row--content-downward .au-list-row__label{font-size:14px;font-weight:400;line-height:22px;color:#5e6573}.au-list-row--content-downward .au-list-row__description{font-size:16px;font-weight:600;line-height:24px;color:#16181d}.au-list-row__trailing{display:flex;flex:none;align-items:center;gap:16px}.au-list-row__secondary{display:flex;flex-direction:column;gap:2px;text-align:end;font-size:14px;font-weight:400;line-height:22px;color:#c4c9d4}.au-list-row__secondary-label,.au-list-row__secondary-description{display:block}.au-list-row .au-list-row__link{min-height:48px;padding:0 16px;margin:-13px -16px}.au-list-row__leading--icon .au-skeleton,.au-list-row__main .au-skeleton{border-radius:4px}.au-list-row__chevron{display:flex;color:#0048db}.au-list-row__chevron .au-icon,.au-list-row__chevron .au-icon>svg{color:inherit}.au-list-row--clickable{cursor:pointer}.au-list-row--clickable:hover{background-color:#f6f7fa}.au-list-row--clickable:focus-visible{outline:2px solid #0048db;outline-offset:-2px}.au-list-row--skeleton{pointer-events:none}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s } from "../../BadgeWhite-
|
|
1
|
+
import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s } from "../../BadgeWhite-BjdKCzB3.js";
|
|
2
2
|
export {
|
|
3
3
|
L as LogoBadgeFullWhiteAC,
|
|
4
4
|
a as LogoBadgeWhiteAC,
|
|
@@ -9,13 +9,19 @@ export type SearchBarRow = {
|
|
|
9
9
|
option: SearchBarOption;
|
|
10
10
|
index: number;
|
|
11
11
|
};
|
|
12
|
+
export declare const matchesSearch: (label: string, value: string) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The `filter` mode (Figma: Sync): keeps the options whose label contains the
|
|
15
|
+
* typed text and drops the groups left empty. An empty text keeps everything.
|
|
16
|
+
*/
|
|
17
|
+
export declare const filterSearchBarOptions: (options: Array<SearchBarOption | SearchBarGroup>, value: string) => (SearchBarOption | SearchBarGroup)[];
|
|
12
18
|
/**
|
|
13
19
|
* Flattens `options` (loose options and titled groups) into the rows the list
|
|
14
20
|
* renders. `index` counts only the options, which is what the keyboard walks.
|
|
15
21
|
*/
|
|
16
22
|
export declare const getSearchBarRows: (options: Array<SearchBarOption | SearchBarGroup>) => SearchBarRow[];
|
|
17
|
-
type UseSearchBarArgs = Pick<SearchBarProps, 'value' | 'defaultValue' | 'options' | 'loading' | 'emptyText' | 'disabled' | 'onChange' | 'onSearch' | 'onSelect' | 'onClear'>;
|
|
18
|
-
export declare const useSearchBar: ({ value, defaultValue, options, loading, emptyText, disabled, onChange, onSearch, onSelect, onClear, }: UseSearchBarArgs) => {
|
|
23
|
+
type UseSearchBarArgs = Pick<SearchBarProps, 'value' | 'defaultValue' | 'options' | 'filter' | 'loading' | 'emptyText' | 'disabled' | 'onChange' | 'onSearch' | 'onSelect' | 'onClear'>;
|
|
24
|
+
export declare const useSearchBar: ({ value, defaultValue, options, filter, loading, emptyText, disabled, onChange, onSearch, onSelect, onClear, }: UseSearchBarArgs) => {
|
|
19
25
|
value: string;
|
|
20
26
|
rows: SearchBarRow[];
|
|
21
27
|
isOpen: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SearchBarProps } from './types';
|
|
2
2
|
export type { SearchBarProps, SearchBarOption, SearchBarGroup } from './types';
|
|
3
|
-
export declare const SearchBar: ({ label, placeholder, value, defaultValue, options, loading, emptyText, disabled, id, name, className, style, onChange, onSearch, onSelect, onClear, "data-testid": dataTestId, }: SearchBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const SearchBar: ({ label, placeholder, value, defaultValue, options, filter, loading, emptyText, disabled, id, name, className, style, onChange, onSearch, onSelect, onClear, "data-testid": dataTestId, }: SearchBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,6 +8,21 @@ import { DropdownItem } from "../DropdownItem/index.es.js";
|
|
|
8
8
|
import { Spinner } from "../Spinner/index.es.js";
|
|
9
9
|
import Field from "../form/Field/index.es.js";
|
|
10
10
|
import './styles.css';const _isGroup = (entry) => "category" in entry;
|
|
11
|
+
const _normalize = (text) => text.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
12
|
+
const matchesSearch = (label, value) => _normalize(label).includes(_normalize(value));
|
|
13
|
+
const filterSearchBarOptions = (options, value) => {
|
|
14
|
+
if (value === "") return options;
|
|
15
|
+
const filtered = [];
|
|
16
|
+
options.forEach((entry) => {
|
|
17
|
+
if (_isGroup(entry)) {
|
|
18
|
+
const matching = entry.options.filter((option) => matchesSearch(option.label, value));
|
|
19
|
+
if (matching.length > 0) filtered.push({ ...entry, options: matching });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (matchesSearch(entry.label, value)) filtered.push(entry);
|
|
23
|
+
});
|
|
24
|
+
return filtered;
|
|
25
|
+
};
|
|
11
26
|
const getSearchBarRows = (options) => {
|
|
12
27
|
const rows = [];
|
|
13
28
|
let index = 0;
|
|
@@ -29,6 +44,7 @@ const useSearchBar = ({
|
|
|
29
44
|
value,
|
|
30
45
|
defaultValue = "",
|
|
31
46
|
options = [],
|
|
47
|
+
filter = false,
|
|
32
48
|
loading = false,
|
|
33
49
|
emptyText = "",
|
|
34
50
|
disabled = false,
|
|
@@ -45,7 +61,7 @@ const useSearchBar = ({
|
|
|
45
61
|
const listRef = useRef(null);
|
|
46
62
|
const isControlled = value !== void 0;
|
|
47
63
|
const currentValue = isControlled ? value : internalValue;
|
|
48
|
-
const rows = getSearchBarRows(options);
|
|
64
|
+
const rows = getSearchBarRows(filter ? filterSearchBarOptions(options, currentValue) : options);
|
|
49
65
|
const selectable = rows.filter(
|
|
50
66
|
(row) => row.kind === "option" && !row.option.disabled
|
|
51
67
|
);
|
|
@@ -164,6 +180,7 @@ const SearchBar = ({
|
|
|
164
180
|
value,
|
|
165
181
|
defaultValue,
|
|
166
182
|
options = [],
|
|
183
|
+
filter = false,
|
|
167
184
|
loading = false,
|
|
168
185
|
emptyText = "Nenhum resultado",
|
|
169
186
|
disabled = false,
|
|
@@ -199,10 +216,11 @@ const SearchBar = ({
|
|
|
199
216
|
handleKeyDown,
|
|
200
217
|
handleListMouseDown,
|
|
201
218
|
handleListMouseMove
|
|
202
|
-
} = useSearchBar({ value, defaultValue, options, loading, emptyText, disabled, onChange, onSearch, onSelect, onClear });
|
|
219
|
+
} = useSearchBar({ value, defaultValue, options, filter, loading, emptyText, disabled, onChange, onSearch, onSelect, onClear });
|
|
203
220
|
const rootClasses = classNames("au-search-bar", {
|
|
204
221
|
"au-search-bar--open": isOpen,
|
|
205
|
-
|
|
222
|
+
// Disabled keeps the search icon: the spec has no Filled state with the X there.
|
|
223
|
+
"au-search-bar--filled": currentValue !== "" && !disabled,
|
|
206
224
|
"au-search-bar--loading": loading,
|
|
207
225
|
[className]: !!className
|
|
208
226
|
});
|
|
@@ -213,17 +231,16 @@ const SearchBar = ({
|
|
|
213
231
|
if (loading) {
|
|
214
232
|
return /* @__PURE__ */ jsx("div", { className: "au-search-bar__action au-search-bar__action--loading", children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
215
233
|
}
|
|
216
|
-
if (currentValue !== "") {
|
|
234
|
+
if (currentValue !== "" && !disabled) {
|
|
217
235
|
return /* @__PURE__ */ jsx(
|
|
218
236
|
"button",
|
|
219
237
|
{
|
|
220
238
|
type: "button",
|
|
221
239
|
className: "au-search-bar__action au-search-bar__action--clear",
|
|
222
240
|
"aria-label": "Limpar busca",
|
|
223
|
-
disabled,
|
|
224
241
|
onMouseDown: handleListMouseDown,
|
|
225
242
|
onClick: clear,
|
|
226
|
-
children: /* @__PURE__ */ jsx(IconX, {
|
|
243
|
+
children: /* @__PURE__ */ jsx(IconX, {})
|
|
227
244
|
}
|
|
228
245
|
);
|
|
229
246
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../lib/components/SearchBar/hooks.ts","../../../lib/components/SearchBar/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { SearchBarGroup, SearchBarOption, SearchBarProps } from './types'\n\nexport type SearchBarRow =\n | { kind: 'category'; key: string; label: string }\n | { kind: 'option'; key: string; option: SearchBarOption; index: number }\n\nconst _isGroup = (entry: SearchBarOption | SearchBarGroup): entry is SearchBarGroup =>\n 'category' in entry\n\n/**\n * Flattens `options` (loose options and titled groups) into the rows the list\n * renders. `index` counts only the options, which is what the keyboard walks.\n */\nexport const getSearchBarRows = (options: Array<SearchBarOption | SearchBarGroup>) => {\n const rows: SearchBarRow[] = []\n let index = 0\n options.forEach((entry, position) => {\n if (_isGroup(entry)) {\n rows.push({ kind: 'category', key: `category-${position}`, label: entry.category })\n entry.options.forEach((option) => {\n rows.push({ kind: 'option', key: `option-${index}`, option, index })\n index += 1\n })\n return\n }\n rows.push({ kind: 'option', key: `option-${index}`, option: entry, index })\n index += 1\n })\n return rows\n}\n\ntype UseSearchBarArgs = Pick<\n SearchBarProps,\n 'value' | 'defaultValue' | 'options' | 'loading' | 'emptyText' | 'disabled' | 'onChange' | 'onSearch' | 'onSelect' | 'onClear'\n>\n\nexport const useSearchBar = ({\n value,\n defaultValue = '',\n options = [],\n loading = false,\n emptyText = '',\n disabled = false,\n onChange,\n onSearch,\n onSelect,\n onClear,\n}: UseSearchBarArgs) => {\n const [internalValue, setInternalValue] = useState(defaultValue)\n const [focused, setFocused] = useState(false)\n // Escape closes the list until the person types or navigates again.\n const [dismissed, setDismissed] = useState(false)\n const [activeIndex, setActiveIndex] = useState<number | null>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const listRef = useRef<HTMLUListElement>(null)\n\n const isControlled = value !== undefined\n const currentValue = isControlled ? value : internalValue\n\n const rows = getSearchBarRows(options)\n const selectable = rows.filter(\n (row): row is Extract<SearchBarRow, { kind: 'option' }> =>\n row.kind === 'option' && !row.option.disabled,\n )\n const showEmpty = !loading && rows.length === 0 && currentValue !== '' && !!emptyText\n const hasContent = loading || rows.length > 0 || showEmpty\n const isOpen = focused && !dismissed && !disabled && hasContent\n\n // New rows (or the skeletons): the keyboard highlight restarts, so\n // `aria-activedescendant` never points at a row that is gone.\n const rowsKey = rows.map((row) => (row.kind === 'option' ? `${row.key}:${row.option.value}` : row.key)).join('|')\n useEffect(() => {\n setActiveIndex(null)\n }, [loading, rowsKey])\n\n // Scroll the row the keyboard reached into view.\n useEffect(() => {\n if (activeIndex === null || !listRef.current) return\n listRef.current\n .querySelector<HTMLElement>('.au-dropdown-item--focused')\n ?.scrollIntoView({ block: 'nearest' })\n }, [activeIndex])\n\n const _setValue = (next: string) => {\n if (!isControlled) setInternalValue(next)\n onChange?.(next)\n }\n\n const _moveActive = (direction: 'down' | 'up') => {\n if (loading || selectable.length === 0) return\n const positions = selectable.map((row) => row.index)\n const current = activeIndex === null ? -1 : positions.indexOf(activeIndex)\n const step = direction === 'down' ? 1 : -1\n const start = current === -1 && direction === 'up' ? positions.length : current\n const next = (start + step + positions.length) % positions.length\n setActiveIndex(positions[next])\n }\n\n const selectOption = (option: SearchBarOption) => {\n if (option.disabled) return\n _setValue(option.label)\n onSelect?.(option)\n setActiveIndex(null)\n setDismissed(true)\n }\n\n const clear = () => {\n _setValue('')\n onClear?.()\n setActiveIndex(null)\n setDismissed(false)\n inputRef.current?.focus()\n }\n\n const search = () => {\n onSearch?.(currentValue)\n inputRef.current?.focus()\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n _setValue(event.target.value)\n setActiveIndex(null)\n setDismissed(false)\n }\n\n const handleFocus = () => setFocused(true)\n\n const handleBlur = () => {\n setFocused(false)\n setActiveIndex(null)\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled) return\n const _actions: Record<string, () => void> = {\n ArrowDown: () => {\n event.preventDefault()\n setDismissed(false)\n _moveActive('down')\n },\n ArrowUp: () => {\n event.preventDefault()\n setDismissed(false)\n _moveActive('up')\n },\n Enter: () => {\n const active = activeIndex === null ? undefined : selectable.find((row) => row.index === activeIndex)\n if (isOpen && active) {\n event.preventDefault()\n selectOption(active.option)\n return\n }\n onSearch?.(currentValue)\n },\n Escape: () => {\n // Always prevented: Chrome clears a `type=\"search\"` field on Escape.\n event.preventDefault()\n if (!isOpen) return\n setDismissed(true)\n setActiveIndex(null)\n },\n }\n // Own keys only: `event.key` could otherwise reach a prototype member.\n if (Object.prototype.hasOwnProperty.call(_actions, event.key)) _actions[event.key]()\n }\n\n // The list never takes the focus from the field: a click on a row selects\n // it with the field still focused, and moving the mouse drops the keyboard\n // highlight so only one row reads as the current one.\n const handleListMouseDown = (event: React.MouseEvent) => event.preventDefault()\n const handleListMouseMove = () => {\n if (activeIndex !== null) setActiveIndex(null)\n }\n\n return {\n value: currentValue,\n rows,\n isOpen,\n showEmpty,\n activeIndex,\n inputRef,\n listRef,\n selectOption,\n clear,\n search,\n handleChange,\n handleFocus,\n handleBlur,\n handleKeyDown,\n handleListMouseDown,\n handleListMouseMove,\n }\n}\n","import { useId } from 'react'\nimport classNames from 'classnames'\nimport { IconSearch, IconX } from '@components/icons'\nimport { DropdownItem } from '@components/DropdownItem'\nimport { Spinner } from '@components/Spinner'\nimport Field from '../form/Field'\nimport { SearchBarProps } from './types'\nimport { useSearchBar } from './hooks'\nimport './styles.scss'\n\nexport type { SearchBarProps, SearchBarOption, SearchBarGroup } from './types'\n\nexport const SearchBar = ({\n label,\n placeholder = 'Buscar',\n value,\n defaultValue,\n options = [],\n loading = false,\n emptyText = 'Nenhum resultado',\n disabled = false,\n id,\n name,\n className,\n style,\n onChange,\n onSearch,\n onSelect,\n onClear,\n 'data-testid': dataTestId,\n}: SearchBarProps) => {\n const generatedId = useId().replace(/[^a-zA-Z0-9]/g, '')\n const inputId = id ?? `au-search-bar-${generatedId}`\n const labelId = `${inputId}-label`\n const listId = `${inputId}-listbox`\n const optionId = (index: number) => `${inputId}-option-${index}`\n\n const {\n value: currentValue,\n rows,\n isOpen,\n showEmpty,\n activeIndex,\n inputRef,\n listRef,\n selectOption,\n clear,\n search,\n handleChange,\n handleFocus,\n handleBlur,\n handleKeyDown,\n handleListMouseDown,\n handleListMouseMove,\n } = useSearchBar({ value, defaultValue, options, loading, emptyText, disabled, onChange, onSearch, onSelect, onClear })\n\n const rootClasses = classNames('au-search-bar', {\n 'au-search-bar--open': isOpen,\n 'au-search-bar--filled': currentValue !== '',\n 'au-search-bar--loading': loading,\n [className!]: !!className,\n })\n\n const listClasses = classNames('au-search-bar__results', {\n 'au-search-bar__results--open': isOpen,\n })\n\n const _renderAction = () => {\n if (loading) {\n return (\n <div className=\"au-search-bar__action au-search-bar__action--loading\">\n <Spinner />\n </div>\n )\n }\n if (currentValue !== '') {\n return (\n <button\n type=\"button\"\n className=\"au-search-bar__action au-search-bar__action--clear\"\n aria-label=\"Limpar busca\"\n disabled={disabled}\n onMouseDown={handleListMouseDown}\n onClick={clear}>\n <IconX size=\"medium\" />\n </button>\n )\n }\n return (\n <button\n type=\"button\"\n className=\"au-search-bar__action au-search-bar__action--search\"\n aria-label=\"Buscar\"\n disabled={disabled}\n onMouseDown={handleListMouseDown}\n onClick={search}>\n <IconSearch />\n </button>\n )\n }\n\n const _renderRows = () => {\n if (loading) {\n return [0, 1, 2].map((index) => <DropdownItem key={`skeleton-${index}`} label=\"\" state=\"skeleton\" />)\n }\n if (showEmpty) {\n return <DropdownItem label={emptyText} state=\"empty\" />\n }\n return rows.map((row) =>\n row.kind === 'category' ? (\n <DropdownItem key={row.key} type=\"category\" label={row.label} />\n ) : (\n <DropdownItem\n key={row.key}\n id={optionId(row.index)}\n label={row.option.label}\n description={row.option.description}\n disabled={row.option.disabled}\n selected={row.option.selected}\n focused={activeIndex === row.index}\n data-value={row.option.value}\n onClick={() => selectOption(row.option)}\n />\n ),\n )\n }\n\n return (\n <Field.Root style={style} customclass={rootClasses} disabled={disabled}>\n <Field.Label text={label} id={inputId} labelId={labelId} disabled={disabled} showOptionalLabel={false} />\n <div className=\"au-search-bar__control\">\n <input\n ref={inputRef}\n className=\"au-field__input au-search-bar__input\"\n type=\"search\"\n role=\"combobox\"\n id={inputId}\n name={name}\n value={currentValue}\n placeholder={placeholder}\n disabled={disabled}\n autoComplete=\"off\"\n enterKeyHint=\"search\"\n aria-autocomplete=\"list\"\n aria-expanded={isOpen}\n aria-controls={listId}\n aria-label={label ? undefined : placeholder}\n aria-activedescendant={activeIndex === null ? undefined : optionId(activeIndex)}\n data-testid={dataTestId}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n />\n {_renderAction()}\n </div>\n <ul\n ref={listRef}\n id={listId}\n className={listClasses}\n role=\"listbox\"\n aria-labelledby={label ? labelId : undefined}\n aria-label={label ? undefined : 'Resultados da busca'}\n aria-busy={loading || undefined}\n tabIndex={-1}\n onMouseDown={handleListMouseDown}\n onMouseMove={handleListMouseMove}>\n {_renderRows()}\n </ul>\n </Field.Root>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,WAAW,CAAC,UAChB,cAAc;AAMT,MAAM,mBAAmB,CAAC,YAAqD;AACpF,QAAM,OAAuB,CAAA;AAC7B,MAAI,QAAQ;AACZ,UAAQ,QAAQ,CAAC,OAAO,aAAa;AACnC,QAAI,SAAS,KAAK,GAAG;AACnB,WAAK,KAAK,EAAE,MAAM,YAAY,KAAK,YAAY,QAAQ,IAAI,OAAO,MAAM,SAAA,CAAU;AAClF,YAAM,QAAQ,QAAQ,CAAC,WAAW;AAChC,aAAK,KAAK,EAAE,MAAM,UAAU,KAAK,UAAU,KAAK,IAAI,QAAQ,MAAA,CAAO;AACnE,iBAAS;AAAA,MACX,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,UACf,iBAAe;AAAA,UACf,cAAY,QAAQ,SAAY;AAAA,UAChC,yBAAuB,gBAAgB,OAAO,SAAY,SAAS,WAAW;AAAA,UAC9E,eAAa;AAAA,UACb,UAAU;AAAA,UACV,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,WAAW;AAAA,QAAA;AAAA,MAAA;AAAA,MAEZ,cAAA;AAAA,IAAc,GACjB;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,IAAI;AAAA,QACJ,WAAW;AAAA,QACX,MAAK;AAAA,QACL,mBAAiB,QAAQ,UAAU;AAAA,QACnC,cAAY,QAAQ,SAAY;AAAA,QAChC,aAAW,WAAW;AAAA,QACtB,UAAU;AAAA,QACV,aAAa;AAAA,QACb,aAAa;AAAA,QACZ,UAAA,YAAA;AAAA,MAAY;AAAA,IAAA;AAAA,EACf,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../lib/components/SearchBar/hooks.ts","../../../lib/components/SearchBar/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { SearchBarGroup, SearchBarOption, SearchBarProps } from './types'\n\nexport type SearchBarRow =\n | { kind: 'category'; key: string; label: string }\n | { kind: 'option'; key: string; option: SearchBarOption; index: number }\n\nconst _isGroup = (entry: SearchBarOption | SearchBarGroup): entry is SearchBarGroup =>\n 'category' in entry\n\n/** Lowercase and without accents, so \"credito\" finds \"Crédito\". The Astro controller has a copy. */\nconst _normalize = (text: string) => text.toLowerCase().normalize('NFD').replace(/[\\u0300-\\u036f]/g, '')\n\nexport const matchesSearch = (label: string, value: string) => _normalize(label).includes(_normalize(value))\n\n/**\n * The `filter` mode (Figma: Sync): keeps the options whose label contains the\n * typed text and drops the groups left empty. An empty text keeps everything.\n */\nexport const filterSearchBarOptions = (options: Array<SearchBarOption | SearchBarGroup>, value: string) => {\n if (value === '') return options\n const filtered: Array<SearchBarOption | SearchBarGroup> = []\n options.forEach((entry) => {\n if (_isGroup(entry)) {\n const matching = entry.options.filter((option) => matchesSearch(option.label, value))\n if (matching.length > 0) filtered.push({ ...entry, options: matching })\n return\n }\n if (matchesSearch(entry.label, value)) filtered.push(entry)\n })\n return filtered\n}\n\n/**\n * Flattens `options` (loose options and titled groups) into the rows the list\n * renders. `index` counts only the options, which is what the keyboard walks.\n */\nexport const getSearchBarRows = (options: Array<SearchBarOption | SearchBarGroup>) => {\n const rows: SearchBarRow[] = []\n let index = 0\n options.forEach((entry, position) => {\n if (_isGroup(entry)) {\n rows.push({ kind: 'category', key: `category-${position}`, label: entry.category })\n entry.options.forEach((option) => {\n rows.push({ kind: 'option', key: `option-${index}`, option, index })\n index += 1\n })\n return\n }\n rows.push({ kind: 'option', key: `option-${index}`, option: entry, index })\n index += 1\n })\n return rows\n}\n\ntype UseSearchBarArgs = Pick<\n SearchBarProps,\n 'value' | 'defaultValue' | 'options' | 'filter' | 'loading' | 'emptyText' | 'disabled' | 'onChange' | 'onSearch' | 'onSelect' | 'onClear'\n>\n\nexport const useSearchBar = ({\n value,\n defaultValue = '',\n options = [],\n filter = false,\n loading = false,\n emptyText = '',\n disabled = false,\n onChange,\n onSearch,\n onSelect,\n onClear,\n}: UseSearchBarArgs) => {\n const [internalValue, setInternalValue] = useState(defaultValue)\n const [focused, setFocused] = useState(false)\n // Escape closes the list until the person types or navigates again.\n const [dismissed, setDismissed] = useState(false)\n const [activeIndex, setActiveIndex] = useState<number | null>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const listRef = useRef<HTMLUListElement>(null)\n\n const isControlled = value !== undefined\n const currentValue = isControlled ? value : internalValue\n\n const rows = getSearchBarRows(filter ? filterSearchBarOptions(options, currentValue) : options)\n const selectable = rows.filter(\n (row): row is Extract<SearchBarRow, { kind: 'option' }> =>\n row.kind === 'option' && !row.option.disabled,\n )\n const showEmpty = !loading && rows.length === 0 && currentValue !== '' && !!emptyText\n const hasContent = loading || rows.length > 0 || showEmpty\n const isOpen = focused && !dismissed && !disabled && hasContent\n\n // New rows (or the skeletons): the keyboard highlight restarts, so\n // `aria-activedescendant` never points at a row that is gone.\n const rowsKey = rows.map((row) => (row.kind === 'option' ? `${row.key}:${row.option.value}` : row.key)).join('|')\n useEffect(() => {\n setActiveIndex(null)\n }, [loading, rowsKey])\n\n // Scroll the row the keyboard reached into view.\n useEffect(() => {\n if (activeIndex === null || !listRef.current) return\n listRef.current\n .querySelector<HTMLElement>('.au-dropdown-item--focused')\n ?.scrollIntoView({ block: 'nearest' })\n }, [activeIndex])\n\n const _setValue = (next: string) => {\n if (!isControlled) setInternalValue(next)\n onChange?.(next)\n }\n\n const _moveActive = (direction: 'down' | 'up') => {\n if (loading || selectable.length === 0) return\n const positions = selectable.map((row) => row.index)\n const current = activeIndex === null ? -1 : positions.indexOf(activeIndex)\n const step = direction === 'down' ? 1 : -1\n const start = current === -1 && direction === 'up' ? positions.length : current\n const next = (start + step + positions.length) % positions.length\n setActiveIndex(positions[next])\n }\n\n const selectOption = (option: SearchBarOption) => {\n if (option.disabled) return\n _setValue(option.label)\n onSelect?.(option)\n setActiveIndex(null)\n setDismissed(true)\n }\n\n const clear = () => {\n _setValue('')\n onClear?.()\n setActiveIndex(null)\n setDismissed(false)\n inputRef.current?.focus()\n }\n\n const search = () => {\n onSearch?.(currentValue)\n inputRef.current?.focus()\n }\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n _setValue(event.target.value)\n setActiveIndex(null)\n setDismissed(false)\n }\n\n const handleFocus = () => setFocused(true)\n\n const handleBlur = () => {\n setFocused(false)\n setActiveIndex(null)\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled) return\n const _actions: Record<string, () => void> = {\n ArrowDown: () => {\n event.preventDefault()\n setDismissed(false)\n _moveActive('down')\n },\n ArrowUp: () => {\n event.preventDefault()\n setDismissed(false)\n _moveActive('up')\n },\n Enter: () => {\n const active = activeIndex === null ? undefined : selectable.find((row) => row.index === activeIndex)\n if (isOpen && active) {\n event.preventDefault()\n selectOption(active.option)\n return\n }\n onSearch?.(currentValue)\n },\n Escape: () => {\n // Always prevented: Chrome clears a `type=\"search\"` field on Escape.\n event.preventDefault()\n if (!isOpen) return\n setDismissed(true)\n setActiveIndex(null)\n },\n }\n // Own keys only: `event.key` could otherwise reach a prototype member.\n if (Object.prototype.hasOwnProperty.call(_actions, event.key)) _actions[event.key]()\n }\n\n // The list never takes the focus from the field: a click on a row selects\n // it with the field still focused, and moving the mouse drops the keyboard\n // highlight so only one row reads as the current one.\n const handleListMouseDown = (event: React.MouseEvent) => event.preventDefault()\n const handleListMouseMove = () => {\n if (activeIndex !== null) setActiveIndex(null)\n }\n\n return {\n value: currentValue,\n rows,\n isOpen,\n showEmpty,\n activeIndex,\n inputRef,\n listRef,\n selectOption,\n clear,\n search,\n handleChange,\n handleFocus,\n handleBlur,\n handleKeyDown,\n handleListMouseDown,\n handleListMouseMove,\n }\n}\n","import { useId } from 'react'\nimport classNames from 'classnames'\nimport { IconSearch, IconX } from '@components/icons'\nimport { DropdownItem } from '@components/DropdownItem'\nimport { Spinner } from '@components/Spinner'\nimport Field from '../form/Field'\nimport { SearchBarProps } from './types'\nimport { useSearchBar } from './hooks'\nimport './styles.scss'\n\nexport type { SearchBarProps, SearchBarOption, SearchBarGroup } from './types'\n\nexport const SearchBar = ({\n label,\n placeholder = 'Buscar',\n value,\n defaultValue,\n options = [],\n filter = false,\n loading = false,\n emptyText = 'Nenhum resultado',\n disabled = false,\n id,\n name,\n className,\n style,\n onChange,\n onSearch,\n onSelect,\n onClear,\n 'data-testid': dataTestId,\n}: SearchBarProps) => {\n const generatedId = useId().replace(/[^a-zA-Z0-9]/g, '')\n const inputId = id ?? `au-search-bar-${generatedId}`\n const labelId = `${inputId}-label`\n const listId = `${inputId}-listbox`\n const optionId = (index: number) => `${inputId}-option-${index}`\n\n const {\n value: currentValue,\n rows,\n isOpen,\n showEmpty,\n activeIndex,\n inputRef,\n listRef,\n selectOption,\n clear,\n search,\n handleChange,\n handleFocus,\n handleBlur,\n handleKeyDown,\n handleListMouseDown,\n handleListMouseMove,\n } = useSearchBar({ value, defaultValue, options, filter, loading, emptyText, disabled, onChange, onSearch, onSelect, onClear })\n\n const rootClasses = classNames('au-search-bar', {\n 'au-search-bar--open': isOpen,\n // Disabled keeps the search icon: the spec has no Filled state with the X there.\n 'au-search-bar--filled': currentValue !== '' && !disabled,\n 'au-search-bar--loading': loading,\n [className!]: !!className,\n })\n\n const listClasses = classNames('au-search-bar__results', {\n 'au-search-bar__results--open': isOpen,\n })\n\n const _renderAction = () => {\n if (loading) {\n return (\n <div className=\"au-search-bar__action au-search-bar__action--loading\">\n <Spinner />\n </div>\n )\n }\n if (currentValue !== '' && !disabled) {\n return (\n <button\n type=\"button\"\n className=\"au-search-bar__action au-search-bar__action--clear\"\n aria-label=\"Limpar busca\"\n onMouseDown={handleListMouseDown}\n onClick={clear}>\n <IconX />\n </button>\n )\n }\n return (\n <button\n type=\"button\"\n className=\"au-search-bar__action au-search-bar__action--search\"\n aria-label=\"Buscar\"\n disabled={disabled}\n onMouseDown={handleListMouseDown}\n onClick={search}>\n <IconSearch />\n </button>\n )\n }\n\n const _renderRows = () => {\n if (loading) {\n return [0, 1, 2].map((index) => <DropdownItem key={`skeleton-${index}`} label=\"\" state=\"skeleton\" />)\n }\n if (showEmpty) {\n return <DropdownItem label={emptyText} state=\"empty\" />\n }\n return rows.map((row) =>\n row.kind === 'category' ? (\n <DropdownItem key={row.key} type=\"category\" label={row.label} />\n ) : (\n <DropdownItem\n key={row.key}\n id={optionId(row.index)}\n label={row.option.label}\n description={row.option.description}\n disabled={row.option.disabled}\n selected={row.option.selected}\n focused={activeIndex === row.index}\n data-value={row.option.value}\n onClick={() => selectOption(row.option)}\n />\n ),\n )\n }\n\n return (\n <Field.Root style={style} customclass={rootClasses} disabled={disabled}>\n <Field.Label text={label} id={inputId} labelId={labelId} disabled={disabled} showOptionalLabel={false} />\n <div className=\"au-search-bar__control\">\n <input\n ref={inputRef}\n className=\"au-field__input au-search-bar__input\"\n type=\"search\"\n role=\"combobox\"\n id={inputId}\n name={name}\n value={currentValue}\n placeholder={placeholder}\n disabled={disabled}\n autoComplete=\"off\"\n enterKeyHint=\"search\"\n aria-autocomplete=\"list\"\n aria-expanded={isOpen}\n aria-controls={listId}\n aria-label={label ? undefined : placeholder}\n aria-activedescendant={activeIndex === null ? undefined : optionId(activeIndex)}\n data-testid={dataTestId}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n />\n {_renderAction()}\n </div>\n <ul\n ref={listRef}\n id={listId}\n className={listClasses}\n role=\"listbox\"\n aria-labelledby={label ? labelId : undefined}\n aria-label={label ? undefined : 'Resultados da busca'}\n aria-busy={loading || undefined}\n tabIndex={-1}\n onMouseDown={handleListMouseDown}\n onMouseMove={handleListMouseMove}>\n {_renderRows()}\n </ul>\n </Field.Root>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,WAAW,CAAC,UAChB,cAAc;AAGhB,MAAM,aAAa,CAAC,SAAiB,KAAK,YAAA,EAAc,UAAU,KAAK,EAAE,QAAQ,oBAAoB,EAAE;AAEhG,MAAM,gBAAgB,CAAC,OAAe,UAAkB,WAAW,KAAK,EAAE,SAAS,WAAW,KAAK,CAAC;AAMpG,MAAM,yBAAyB,CAAC,SAAkD,UAAkB;AACzG,MAAI,UAAU,GAAI,QAAO;AACzB,QAAM,WAAoD,CAAA;AAC1D,UAAQ,QAAQ,CAAC,UAAU;AACzB,QAAI,SAAS,KAAK,GAAG;AACnB,YAAM,WAAW,MAAM,QAAQ,OAAO,CAAC,WAAW,cAAc,OAAO,OAAO,KAAK,CAAC;AACpF,UAAI,SAAS,SAAS,EAAG,UAAS,KAAK,EAAE,GAAG,OAAO,SAAS,UAAU;AACtE;AAAA,IACF;AACA,QAAI,cAAc,MAAM,OAAO,KAAK,EAAG,UAAS,KAAK,KAAK;AAAA,EAC5D,CAAC;AACD,SA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AGN;AAEA,8BACG,MAAM,MAAN,EAAW,OAAc,aAAa,aAAa,UAClD,UAAA;AAAA,IAAA,oBAAC,MAAM,OAAN,EAAY,MAAM,OAAO,IAAI,SAAS,SAAkB,UAAoB,mBAAmB,MAAA,CAAO;AAAA,IACvG,qBAAC,OAAA,EAAI,WAAU,0BACb,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,KAAK;AAAA,UACL,WAAU;AAAA,UACV,MAAK;AAAA,UACL,MAAK;AAAA,UACL,IAAI;AAAA,UACJ;AAAA,UACA,OAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA,cAAa;AAAA,UACb,cAAa;AAAA,UACb,qBAAkB;AAAA,UAClB,iBAAe;AAAA,UACf,iBAAe;AAAA,UACf,cAAY,QAAQ,SAAY;AAAA,UAChC,yBAAuB,gBAAgB,OAAO,SAAY,SAAS,WAAW;AAAA,UAC9E,eAAa;AAAA,UACb,UAAU;AAAA,UACV,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,WAAW;AAAA,QAAA;AAAA,MAAA;AAAA,MAEZ,cAAA;AAAA,IAAc,GACjB;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,IAAI;AAAA,QACJ,WAAW;AAAA,QACX,MAAK;AAAA,QACL,mBAAiB,QAAQ,UAAU;AAAA,QACnC,cAAY,QAAQ,SAAY;AAAA,QAChC,aAAW,WAAW;AAAA,QACtB,UAAU;AAAA,QACV,aAAa;AAAA,QACb,aAAa;AAAA,QACZ,UAAA,YAAA;AAAA,MAAY;AAAA,IAAA;AAAA,EACf,GACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-search-bar,.au-search-bar__control{position:relative}.au-search-bar .au-search-bar__input{padding-right:52px;border-color:#e2e4e9;line-height:24px;color:#16181d;-moz-appearance:none;appearance:none;-webkit-appearance:none}.au-search-bar .au-search-bar__input::-webkit-search-decoration,.au-search-bar .au-search-bar__input::-webkit-search-cancel-button,.au-search-bar .au-search-bar__input::-webkit-search-results-button,.au-search-bar .au-search-bar__input::-webkit-search-results-decoration{display:none;-webkit-appearance:none}.au-search-bar .au-search-bar__input::placeholder{color:#5e6573}.au-search-bar .au-search-bar__input:hover{border-color:#454a54}.au-search-bar .au-search-bar__input:focus{border-color:#0048db;outline:none}.au-search-bar .au-search-bar__input:active:not(:disabled){border-color:#0048db;outline:1px solid #0048db}.au-search-bar.au-field--disabled .au-search-bar__input{border-color:#5e6573}.au-search-bar--filled .au-search-bar__input{padding-right:56px}.au-search-bar__action{position:absolute;right:16px;top:50%;display:flex;width:20px;height:20px;padding:0;align-items:center;justify-content:center;border:0;border-radius:999px;background:none;color:#0048db;transform:translateY(-50%);cursor:pointer}.au-search-bar__action .au-icon,.au-search-bar__action .au-icon>svg{color:inherit}.au-search-bar__action:focus-visible{outline:2px solid #0048db;outline-offset:2px}.au-search-bar__action:disabled{color:#5e6573;cursor:not-allowed}.au-search-bar__action--clear{right:8px;width:40px;height:40px;padding:
|
|
1
|
+
.au-search-bar,.au-search-bar__control{position:relative}.au-search-bar .au-search-bar__input{padding-right:52px;border-color:#e2e4e9;line-height:24px;color:#16181d;-moz-appearance:none;appearance:none;-webkit-appearance:none}.au-search-bar .au-search-bar__input::-webkit-search-decoration,.au-search-bar .au-search-bar__input::-webkit-search-cancel-button,.au-search-bar .au-search-bar__input::-webkit-search-results-button,.au-search-bar .au-search-bar__input::-webkit-search-results-decoration{display:none;-webkit-appearance:none}.au-search-bar .au-search-bar__input::placeholder{color:#5e6573}.au-search-bar .au-search-bar__input:hover{border-color:#454a54}.au-search-bar .au-search-bar__input:focus{border-color:#0048db;outline:none}.au-search-bar .au-search-bar__input:active:not(:disabled){border-color:#0048db;outline:1px solid #0048db}.au-search-bar.au-field--disabled .au-search-bar__input{border-color:#5e6573}.au-search-bar--filled .au-search-bar__input{padding-right:56px}.au-search-bar__action{position:absolute;right:16px;top:50%;display:flex;width:20px;height:20px;padding:0;align-items:center;justify-content:center;border:0;border-radius:999px;background:none;color:#0048db;transform:translateY(-50%);cursor:pointer}.au-search-bar__action .au-icon,.au-search-bar__action .au-icon>svg{color:inherit}.au-search-bar__action:focus-visible{outline:2px solid #0048db;outline-offset:2px}.au-search-bar__action:disabled{color:#5e6573;cursor:not-allowed}.au-search-bar__action--clear{right:8px;width:40px;height:40px;padding:10px;color:#16181d;transition:background-color .3s ease}.au-search-bar__action--clear:hover,.au-search-bar__action--clear:focus-visible{background-color:#f2f5fc}.au-search-bar__action--clear:active{background-color:#dce8ff}.au-search-bar__action--loading{cursor:default}.au-search-bar__results{position:absolute;left:0;right:0;z-index:1;max-height:218px;margin:16px 0 0;padding:0;box-sizing:border-box;overflow-y:auto;list-style:none;background:#fff;border:1px solid #0048db;border-radius:8px;transform-origin:top left;transform:scaleY(0);opacity:0;visibility:hidden;transition:transform .2s,opacity .2s,visibility 0s .2s;scrollbar-width:thin;scrollbar-color:#16181d transparent}.au-search-bar__results::-webkit-scrollbar{width:12px}.au-search-bar__results::-webkit-scrollbar-thumb{background-color:#16181d;background-clip:padding-box;border:4px solid transparent;border-radius:8px}.au-search-bar__results::-webkit-scrollbar-track{background-color:transparent}.au-search-bar__results--open{transform:scaleY(1);opacity:1;visibility:visible;transition:transform .2s,opacity .2s}
|
|
@@ -21,6 +21,12 @@ export type SearchBarProps = {
|
|
|
21
21
|
defaultValue?: string;
|
|
22
22
|
/** Resultados da busca, soltos ou em grupos com título. A lista abre com o campo em foco. */
|
|
23
23
|
options?: Array<SearchBarOption | SearchBarGroup>;
|
|
24
|
+
/**
|
|
25
|
+
* Filtra `options` pelo texto digitado no próprio componente, a cada letra, sem acento e sem
|
|
26
|
+
* diferenciar maiúsculas (Figma: Sync). Grupo que fica sem opção some. Com o campo vazio a lista
|
|
27
|
+
* sai inteira. Desligado, quem filtra é o app (busca assíncrona, com `loading`).
|
|
28
|
+
*/
|
|
29
|
+
filter?: boolean;
|
|
24
30
|
/** Spinner no lugar do ícone e lista de skeletons enquanto os resultados chegam (Figma: Loading). */
|
|
25
31
|
loading?: boolean;
|
|
26
32
|
/** Linha mostrada quando há texto e nenhum resultado (Figma: No Results). Vazio desliga. @default 'Nenhum resultado' */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-section-app{display:flex;flex-direction:column;width:100%;box-sizing:border-box;background-color:#fff;font-family:"Source Sans 3",sans-serif;text-align:start}.au-section-app__content{display:flex;flex-direction:column;align-items:flex-start;gap:24px;padding:32px 24px 0;box-sizing:border-box}.au-section-app__logo{display:flex;align-items:center;justify-content:center;width:40px;height:40px;overflow:hidden;border-radius:11.25px;background-color:#0048db;color:#fff}.au-section-app__logo img,.au-section-app__logo svg{display:block;width:100%;height:100%}.au-section-app__text{display:flex;flex-direction:column;gap:16px}.au-section-app__title{margin:0;color:#16181d}.au-section-app__description{margin:0;color:#454a54}.au-section-app__actions{display:flex;flex-direction:column;gap:24px}.au-section-app__stores{display:flex;flex-wrap:wrap;gap:8px}.au-section-app__store{display:block;width:133px;height:42px}.au-section-app__store img{display:block;width:100%;height:100%;object-fit:contain}.au-section-app__store:hover{opacity:.6}.au-section-app__actions-divider,.au-section-app__qr{display:none}.au-section-app__actions-divider{width:0;height:48px;border-left:1px solid #e2e4e9}.au-section-app__qr{align-items:center;gap:8px}.au-section-app__qr-image{display:block;flex:none;width:74px;height:74px}.au-section-app__qr-text{margin:0;max-width:180px;color:#454a54}.au-section-app__list{display:flex;flex-direction:column;gap:16px;margin:0;padding:0;list-style:none}.au-section-app__item{display:flex;align-items:flex-start;gap:16px}.au-section-app__marker{display:flex;flex:none;align-items:center;justify-content:center;width:24px;height:24px;border-radius:999px;background-color:#f6f7fa;color:#454a54;font-size:14px;font-weight:600;line-height:22px}.au-section-app__marker .au-icon,.au-section-app__marker .au-icon>svg{color:#0048db}.au-section-app__item-text{font-size:14px;font-weight:400;line-height:22px;color:#454a54}.au-section-app__image-area{display:flex;padding:24px;box-sizing:border-box}.au-section-app__image{display:flex;align-items:center;justify-content:center;width:272px;max-width:100%;
|
|
1
|
+
.au-section-app{display:flex;flex-direction:column;width:100%;box-sizing:border-box;background-color:#fff;font-family:"Source Sans 3",sans-serif;text-align:start}.au-section-app__content{display:flex;flex-direction:column;align-items:flex-start;gap:24px;padding:32px 24px 0;box-sizing:border-box}.au-section-app__logo{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:6px;box-sizing:border-box;overflow:hidden;border-radius:11.25px;background-color:#0048db;color:#fff}.au-section-app__logo img,.au-section-app__logo svg{display:block;width:100%;height:100%}.au-section-app__logo .au-logo{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.au-section-app__text{display:flex;flex-direction:column;gap:16px}.au-section-app__title{margin:0;color:#16181d}.au-section-app__description{margin:0;color:#454a54}.au-section-app__actions{display:flex;flex-direction:column;gap:24px}.au-section-app__stores{display:flex;flex-wrap:wrap;gap:8px}.au-section-app__store{display:block;width:133px;height:42px}.au-section-app__store img{display:block;width:100%;height:100%;object-fit:contain}.au-section-app__store:hover{opacity:.6}.au-section-app__actions-divider,.au-section-app__qr{display:none}.au-section-app__actions-divider{width:0;height:48px;border-left:1px solid #e2e4e9}.au-section-app__qr{align-items:center;gap:8px}.au-section-app__qr-image{display:block;flex:none;width:74px;height:74px}.au-section-app__qr-text{margin:0;max-width:180px;color:#454a54}.au-section-app__list{display:flex;flex-direction:column;gap:16px;margin:0;padding:0;list-style:none}.au-section-app__item{display:flex;align-items:flex-start;gap:16px}.au-section-app__marker{display:flex;flex:none;align-items:center;justify-content:center;width:24px;height:24px;border-radius:999px;background-color:#f6f7fa;color:#454a54;font-size:14px;font-weight:600;line-height:22px}.au-section-app__marker .au-icon,.au-section-app__marker .au-icon>svg{color:#0048db}.au-section-app__item-text{font-size:14px;font-weight:400;line-height:22px;color:#454a54}.au-section-app__image-area{display:flex;padding:24px;box-sizing:border-box}.au-section-app__image{display:flex;align-items:center;justify-content:center;width:272px;max-width:100%;aspect-ratio:272/368;padding:8px;box-sizing:border-box;overflow:hidden;border:1px solid #e2e4e9;border-radius:8px;background-color:#f6f7fa}.au-section-app__image img,.au-section-app__image svg{display:block;width:100%;height:auto}.au-section-app__image picture{display:contents}.au-section-app__image--filled{aspect-ratio:auto;padding:0;border:0;border-radius:0;background:none}.au-section-app--size-desktop{flex-direction:row;align-items:stretch;gap:24px}.au-section-app--size-desktop .au-section-app__content{flex:1 1 717px;min-width:0;max-width:717px;padding:64px 32px 64px 83px}.au-section-app--size-desktop .au-section-app__actions{flex-direction:row;align-items:center}.au-section-app--size-desktop .au-section-app__actions-divider{display:block}.au-section-app--size-desktop .au-section-app__qr{display:flex}.au-section-app--size-desktop .au-section-app__image-area{flex:1 1 649px;min-width:0;align-items:center;justify-content:center;padding:64px 83px 64px 32px}.au-section-app--size-desktop .au-section-app__image{width:534px;aspect-ratio:534/446}@media(min-width:1024px){.au-section-app:not(.au-section-app--size-mobile){flex-direction:row;align-items:stretch;gap:24px}.au-section-app:not(.au-section-app--size-mobile) .au-section-app__content{flex:1 1 717px;min-width:0;max-width:717px;padding:64px 32px 64px 83px}.au-section-app:not(.au-section-app--size-mobile) .au-section-app__actions{flex-direction:row;align-items:center}.au-section-app:not(.au-section-app--size-mobile) .au-section-app__actions-divider{display:block}.au-section-app:not(.au-section-app--size-mobile) .au-section-app__qr{display:flex}.au-section-app:not(.au-section-app--size-mobile) .au-section-app__image-area{flex:1 1 649px;min-width:0;align-items:center;justify-content:center;padding:64px 83px 64px 32px}.au-section-app:not(.au-section-app--size-mobile) .au-section-app__image{width:534px;aspect-ratio:534/446}}
|
package/dist/main.es.js
CHANGED
|
@@ -54,7 +54,7 @@ import { Breadcrumb } from "./components/Breadcrumb/index.es.js";
|
|
|
54
54
|
import { Accordion } from "./components/Accordion/index.es.js";
|
|
55
55
|
import { Carousel } from "./components/Carousel/index.es.js";
|
|
56
56
|
import { useState } from "react";
|
|
57
|
-
import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s } from "./BadgeWhite-
|
|
57
|
+
import { L, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s } from "./BadgeWhite-BjdKCzB3.js";
|
|
58
58
|
import { IconActivity } from "./components/icons/IconActivity/index.es.js";
|
|
59
59
|
import { IconAi } from "./components/icons/IconAi/index.es.js";
|
|
60
60
|
import { IconAiBox } from "./components/icons/IconAiBox/index.es.js";
|