@consumidor-positivo/aurora 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/astro/FeedbackPage/index.astro +2 -2
- package/astro/FileUpload/Preview/index.astro +33 -11
- package/astro/FileUpload/Root/index.astro +6 -5
- 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/FileUpload/Preview/index.d.ts +15 -4
- package/dist/components/FileUpload/Preview/index.es.js +18 -4
- package/dist/components/FileUpload/Preview/index.es.js.map +1 -1
- package/dist/components/FileUpload/Root/index.d.ts +2 -2
- package/dist/components/FileUpload/Root/index.es.js +2 -2
- package/dist/components/FileUpload/Root/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/components/styles/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,eAAe,CAAC;AAAA,EAC3B,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,eAAe;AACjB,MAAyB;AACvB,QAAM,UAAU,oBAAoB,MAAA,EAAQ,QAAQ,iBAAiB,EAAE,CAAC;AACxE,QAAM,OAAO,MAAM,IAAI;AACvB,QAAM,UAAU,gBAAgB,CAAC,eAAe,eAAe,EAAE,OAAO,OAAO,IAA4B,CAAA;AAE3G,QAAM,UAAU,WAAW,oBAAoB,0BAA0B,IAAI,IAAI;AAAA,IAC/E,CAAC,0BAA0B,IAAI,EAAE,GAAG,CAAC,CAAC;AAAA,IACtC,kCAAkC,QAAQ,SAAS;AAAA,IACnD,CAAC,SAAU,GAAG,CAAC,CAAC;AAAA,EAAA,CACjB;AAED,8BACG,WAAA,EAAQ,WAAW,SAAS,mBAAiB,SAAS,eAAa,YAClE,UAAA;AAAA,IAAA,oBAAC,OAAA,EAAI,WAAU,0BAAyB,eAAY,QAClD,UAAA,oBAAC,QAAA,EAAK,WAAU,iCACd,UAAA,oBAAC,MAAA,EAAK,MAAK,SAAA,CAAS,GACtB,GACF;AAAA,IACA,oBAAC,MAAA,EAAK,IAAI,SAAS,IAAI,SAAS,SAAQ,kBAAiB,QAAO,YAAW,WAAU,2BAClF,UAAA,OACH;AAAA,IACC,eACC,oBAAC,MAAA,EAAK,IAAG,KAAI,SAAQ,eAAc,OAAM,aAAY,WAAU,iCAC5D,UAAA,YAAA,CACH;AAAA,IAED,QAAQ,SAAS,KAChB,oBAAC,OAAA,EAAI,WAAU,6BACZ,UAAA,QAAQ,IAAI,CAAC,QAAQ,UAAU;AAC9B,YAAM,gBAAgB,WAAW,4BAA4B;AAAA,QAC3D,qCAAqC,UAAU;AAAA,QAC/C,uCAAuC,UAAU;AAAA,MAAA,CAClD;AACD,YAAM,aAAa,UAAU,IAAI,aAAa;AAC9C,aAAO,OAAO,OACZ;AAAA,QAAC;AAAA,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;"}
|
|
@@ -12,19 +12,30 @@ export type FileUploadPreviewProps = {
|
|
|
12
12
|
description?: string;
|
|
13
13
|
/** Mensagem de erro abaixo da linha, com o motivo e o próximo passo; liga o estado Error. Figma: Error Message, State=Error. */
|
|
14
14
|
error?: string;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Percentual do envio, de 0 a 100: a linha entra no estado Enviando, com a Percentage Bar abaixo
|
|
17
|
+
* (rótulo e percentual) e só o X de cancelar à direita; o link e a lixeira aparecem quando o envio
|
|
18
|
+
* termina. Figma: Show Progress.
|
|
19
|
+
*/
|
|
16
20
|
progress?: number;
|
|
21
|
+
/** Rótulo à esquerda da barra durante o envio. @default 'Enviando...' */
|
|
22
|
+
progressLabel?: string;
|
|
17
23
|
/** Troca o ícone padrão (paperclip, 20px). Figma: Switch Icon. */
|
|
18
24
|
icon?: ReactNode;
|
|
19
25
|
/** Esconde o quadro do ícone. Figma: Show Leading Icon=False. */
|
|
20
26
|
hideIcon?: boolean;
|
|
21
|
-
/** Link Button small à direita ("Ver"). Figma: Show Link. */
|
|
27
|
+
/** Link Button small à direita ("Ver"), só com o arquivo já enviado. Figma: Show Link. */
|
|
22
28
|
link?: FileUploadPreviewLink;
|
|
23
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Remove o arquivo enviado (lixeira) ou cancela o envio em andamento (X, enquanto há `progress`).
|
|
31
|
+
* Sem ele o botão some (Show Button=False).
|
|
32
|
+
*/
|
|
24
33
|
onRemove?: () => void;
|
|
25
34
|
/** `aria-label` do botão de remover. @default 'Remover arquivo' */
|
|
26
35
|
removeLabel?: string;
|
|
36
|
+
/** `aria-label` do botão de cancelar, durante o envio. @default 'Cancelar envio' */
|
|
37
|
+
cancelLabel?: string;
|
|
27
38
|
className?: string;
|
|
28
39
|
'data-testid'?: string;
|
|
29
40
|
};
|
|
30
|
-
export declare const FileUploadPreview: ({ name, description, error, progress, icon, hideIcon, link, onRemove, removeLabel, className, "data-testid": dataTestId, }: FileUploadPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare const FileUploadPreview: ({ name, description, error, progress, progressLabel, icon, hideIcon, link, onRemove, removeLabel, cancelLabel, className, "data-testid": dataTestId, }: FileUploadPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,21 +6,25 @@ import "react";
|
|
|
6
6
|
import "../../Icon/index.es.js";
|
|
7
7
|
import { IconPaperclip } from "../../icons/IconPaperclip/index.es.js";
|
|
8
8
|
import { IconTrash2 } from "../../icons/IconTrash2/index.es.js";
|
|
9
|
+
import { IconX } from "../../icons/IconX/index.es.js";
|
|
9
10
|
import '../../styles/styles.css';/* empty css */
|
|
10
11
|
const FileUploadPreview = ({
|
|
11
12
|
name,
|
|
12
13
|
description,
|
|
13
14
|
error,
|
|
14
15
|
progress,
|
|
16
|
+
progressLabel = "Enviando...",
|
|
15
17
|
icon,
|
|
16
18
|
hideIcon = false,
|
|
17
19
|
link,
|
|
18
20
|
onRemove,
|
|
19
21
|
removeLabel = "Remover arquivo",
|
|
22
|
+
cancelLabel = "Cancelar envio",
|
|
20
23
|
className,
|
|
21
24
|
"data-testid": dataTestId
|
|
22
25
|
}) => {
|
|
23
26
|
const hasProgress = progress !== void 0;
|
|
27
|
+
const showLink = !!link && !hasProgress;
|
|
24
28
|
const classes = classNames("au-file-upload-preview", {
|
|
25
29
|
"au-file-upload-preview--error": !!error,
|
|
26
30
|
"au-file-upload-preview--with-progress": hasProgress,
|
|
@@ -33,13 +37,23 @@ const FileUploadPreview = ({
|
|
|
33
37
|
/* @__PURE__ */ jsx("span", { className: "au-file-upload-preview__name", children: name }),
|
|
34
38
|
description && /* @__PURE__ */ jsx("span", { className: "au-file-upload-preview__description", children: description })
|
|
35
39
|
] }),
|
|
36
|
-
(
|
|
37
|
-
|
|
38
|
-
onRemove && /* @__PURE__ */ jsx("
|
|
40
|
+
(showLink || onRemove) && /* @__PURE__ */ jsxs("span", { className: "au-file-upload-preview__actions", children: [
|
|
41
|
+
showLink && (link.href ? /* @__PURE__ */ jsx(LinkButton, { as: "a", href: link.href, target: link.target, size: "small", className: "au-file-upload-preview__link", onClick: link.onClick, children: link.label }) : /* @__PURE__ */ jsx(LinkButton, { size: "small", className: "au-file-upload-preview__link", onClick: link.onClick, children: link.label })),
|
|
42
|
+
showLink && onRemove && /* @__PURE__ */ jsx("span", { className: "au-file-upload-preview__actions-divider", "aria-hidden": "true" }),
|
|
43
|
+
onRemove && /* @__PURE__ */ jsx(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
type: "button",
|
|
47
|
+
className: classNames("au-file-upload-preview__remove", { "au-file-upload-preview__remove--cancel": hasProgress }),
|
|
48
|
+
"aria-label": hasProgress ? cancelLabel : removeLabel,
|
|
49
|
+
onClick: onRemove,
|
|
50
|
+
children: hasProgress ? /* @__PURE__ */ jsx(IconX, {}) : /* @__PURE__ */ jsx(IconTrash2, {})
|
|
51
|
+
}
|
|
52
|
+
)
|
|
39
53
|
] })
|
|
40
54
|
] }),
|
|
41
55
|
error && /* @__PURE__ */ jsx("span", { className: "au-file-upload-preview__error", children: error }),
|
|
42
|
-
hasProgress && /* @__PURE__ */ jsx("div", { className: "au-file-upload-preview__progress", children: /* @__PURE__ */ jsx(ProgressBar, { percentage: progress, stepName:
|
|
56
|
+
hasProgress && /* @__PURE__ */ jsx("div", { className: "au-file-upload-preview__progress", children: /* @__PURE__ */ jsx(ProgressBar, { percentage: progress, stepName: progressLabel }) })
|
|
43
57
|
] });
|
|
44
58
|
};
|
|
45
59
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../lib/components/FileUpload/Preview/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { LinkButton } from '@components/LinkButton'\nimport { ProgressBar } from '@components/ProgressBar'\nimport { IconPaperclip, IconTrash2 } from '@components/icons'\nimport '../styles.scss'\n\nexport type FileUploadPreviewLink = {\n label: string\n href?: string\n target?: string\n onClick?: () => void\n}\n\nexport type FileUploadPreviewProps = {\n /** Nome do arquivo. Figma: File Name. */\n name: string\n /** Tamanho (\"1,2 MB\") ou status (\"Enviando... 30%\"). Figma: Description. */\n description?: string\n /** Mensagem de erro abaixo da linha, com o motivo e o próximo passo; liga o estado Error. Figma: Error Message, State=Error. */\n error?: string\n
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../lib/components/FileUpload/Preview/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { LinkButton } from '@components/LinkButton'\nimport { ProgressBar } from '@components/ProgressBar'\nimport { IconPaperclip, IconTrash2, IconX } from '@components/icons'\nimport '../styles.scss'\n\nexport type FileUploadPreviewLink = {\n label: string\n href?: string\n target?: string\n onClick?: () => void\n}\n\nexport type FileUploadPreviewProps = {\n /** Nome do arquivo. Figma: File Name. */\n name: string\n /** Tamanho (\"1,2 MB\") ou status (\"Enviando... 30%\"). Figma: Description. */\n description?: string\n /** Mensagem de erro abaixo da linha, com o motivo e o próximo passo; liga o estado Error. Figma: Error Message, State=Error. */\n error?: string\n /**\n * Percentual do envio, de 0 a 100: a linha entra no estado Enviando, com a Percentage Bar abaixo\n * (rótulo e percentual) e só o X de cancelar à direita; o link e a lixeira aparecem quando o envio\n * termina. Figma: Show Progress.\n */\n progress?: number\n /** Rótulo à esquerda da barra durante o envio. @default 'Enviando...' */\n progressLabel?: string\n /** Troca o ícone padrão (paperclip, 20px). Figma: Switch Icon. */\n icon?: ReactNode\n /** Esconde o quadro do ícone. Figma: Show Leading Icon=False. */\n hideIcon?: boolean\n /** Link Button small à direita (\"Ver\"), só com o arquivo já enviado. Figma: Show Link. */\n link?: FileUploadPreviewLink\n /**\n * Remove o arquivo enviado (lixeira) ou cancela o envio em andamento (X, enquanto há `progress`).\n * Sem ele o botão some (Show Button=False).\n */\n onRemove?: () => void\n /** `aria-label` do botão de remover. @default 'Remover arquivo' */\n removeLabel?: string\n /** `aria-label` do botão de cancelar, durante o envio. @default 'Cancelar envio' */\n cancelLabel?: string\n className?: string\n 'data-testid'?: string\n}\n\nexport const FileUploadPreview = ({\n name,\n description,\n error,\n progress,\n progressLabel = 'Enviando...',\n icon,\n hideIcon = false,\n link,\n onRemove,\n removeLabel = 'Remover arquivo',\n cancelLabel = 'Cancelar envio',\n className,\n 'data-testid': dataTestId,\n}: FileUploadPreviewProps) => {\n const hasProgress = progress !== undefined\n // While sending, the only action is to cancel: the link waits for the file.\n const showLink = !!link && !hasProgress\n const classes = classNames('au-file-upload-preview', {\n 'au-file-upload-preview--error': !!error,\n 'au-file-upload-preview--with-progress': hasProgress,\n [className!]: !!className,\n })\n\n return (\n <div className={classes} data-testid={dataTestId}>\n <div className=\"au-file-upload-preview__row\">\n {!hideIcon && (\n <span className=\"au-file-upload-preview__icon\" aria-hidden=\"true\">\n {icon ?? <IconPaperclip />}\n </span>\n )}\n <span className=\"au-file-upload-preview__text\">\n <span className=\"au-file-upload-preview__name\">{name}</span>\n {description && <span className=\"au-file-upload-preview__description\">{description}</span>}\n </span>\n {(showLink || onRemove) && (\n <span className=\"au-file-upload-preview__actions\">\n {showLink &&\n (link.href ? (\n <LinkButton as=\"a\" href={link.href} target={link.target} size=\"small\" className=\"au-file-upload-preview__link\" onClick={link.onClick}>\n {link.label}\n </LinkButton>\n ) : (\n <LinkButton size=\"small\" className=\"au-file-upload-preview__link\" onClick={link.onClick}>\n {link.label}\n </LinkButton>\n ))}\n {showLink && onRemove && <span className=\"au-file-upload-preview__actions-divider\" aria-hidden=\"true\" />}\n {onRemove && (\n <button\n type=\"button\"\n className={classNames('au-file-upload-preview__remove', { 'au-file-upload-preview__remove--cancel': hasProgress })}\n aria-label={hasProgress ? cancelLabel : removeLabel}\n onClick={onRemove}>\n {hasProgress ? <IconX /> : <IconTrash2 />}\n </button>\n )}\n </span>\n )}\n </div>\n {error && <span className=\"au-file-upload-preview__error\">{error}</span>}\n {hasProgress && (\n <div className=\"au-file-upload-preview__progress\">\n <ProgressBar percentage={progress} stepName={progressLabel} />\n </div>\n )}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;AAgDO,MAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,cAAc;AAAA,EACd;AAAA,EACA,eAAe;AACjB,MAA8B;AAC5B,QAAM,cAAc,aAAa;AAEjC,QAAM,WAAW,CAAC,CAAC,QAAQ,CAAC;AAC5B,QAAM,UAAU,WAAW,0BAA0B;AAAA,IACnD,iCAAiC,CAAC,CAAC;AAAA,IACnC,yCAAyC;AAAA,IACzC,CAAC,SAAU,GAAG,CAAC,CAAC;AAAA,EAAA,CACjB;AAED,SACE,qBAAC,OAAA,EAAI,WAAW,SAAS,eAAa,Y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AAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -16,8 +16,8 @@ export type FileUploadRootProps = {
|
|
|
16
16
|
/** Formatos aceitos e tamanho máximo, antes do envio. Sem ele o texto some (Show Helper Text=False). */
|
|
17
17
|
helperText?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Rótulo do botão Outlined
|
|
20
|
-
* é o
|
|
19
|
+
* Rótulo do botão Outlined do Only Button, com @default 'Anexar arquivo'. Ignorado no Drag & Drop:
|
|
20
|
+
* ali a área inteira é o controle e não há botão dentro dela.
|
|
21
21
|
*/
|
|
22
22
|
buttonLabel?: string;
|
|
23
23
|
/**
|
|
@@ -37,7 +37,7 @@ const FileUploadRoot = ({
|
|
|
37
37
|
const [dragging, setDragging] = useState(false);
|
|
38
38
|
const isDragDrop = type === "drag-drop";
|
|
39
39
|
const resolvedTitle = title ?? DEFAULT_TITLE[type];
|
|
40
|
-
const resolvedButtonLabel = isDragDrop ?
|
|
40
|
+
const resolvedButtonLabel = isDragDrop ? void 0 : buttonLabel ?? "Anexar arquivo";
|
|
41
41
|
const hasText = !hideTitle || !!helperText;
|
|
42
42
|
const classes = classNames("au-file-upload", `au-file-upload--type-${type}`, {
|
|
43
43
|
"au-file-upload--disabled": disabled,
|
|
@@ -115,7 +115,7 @@ const FileUploadRoot = ({
|
|
|
115
115
|
className: "au-file-upload__button",
|
|
116
116
|
onClick: openDialog,
|
|
117
117
|
children: [
|
|
118
|
-
|
|
118
|
+
/* @__PURE__ */ jsx(IconUpload, {}),
|
|
119
119
|
resolvedButtonLabel
|
|
120
120
|
]
|
|
121
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../lib/components/FileUpload/Root/index.tsx"],"sourcesContent":["import { ChangeEvent, DragEvent, ReactNode, useId, useRef, useState } from 'react'\nimport classNames from 'classnames'\nimport { Button } from '@components/Button'\nimport { IconUpload } from '@components/icons'\nimport '../styles.scss'\n\nexport type FileUploadType = 'drag-drop' | 'button'\n\nexport type FileUploadRootProps = {\n /**\n * Drag & Drop (área tracejada que aceita arrastar ou clicar, para telas em que anexar é a ação\n * principal) ou Only Button (título, texto de apoio e botão, para formulários e espaços curtos).\n * Figma: Type.\n */\n type?: FileUploadType\n /** Título da área. @default 'Arraste o arquivo ou clique aqui' no Drag & Drop, 'Anexar arquivo' no Only Button. Figma: Title. */\n title?: string\n /** Esconde o título quando o card ou a seção em volta já diz o que anexar. Figma: Show Title=False. */\n hideTitle?: boolean\n /** Título mostrado enquanto um arquivo é arrastado sobre a área. @default 'Solte o arquivo para enviar' */\n dropTitle?: string\n /** Formatos aceitos e tamanho máximo, antes do envio. Sem ele o texto some (Show Helper Text=False). */\n helperText?: string\n /**\n * Rótulo do botão Outlined
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../lib/components/FileUpload/Root/index.tsx"],"sourcesContent":["import { ChangeEvent, DragEvent, ReactNode, useId, useRef, useState } from 'react'\nimport classNames from 'classnames'\nimport { Button } from '@components/Button'\nimport { IconUpload } from '@components/icons'\nimport '../styles.scss'\n\nexport type FileUploadType = 'drag-drop' | 'button'\n\nexport type FileUploadRootProps = {\n /**\n * Drag & Drop (área tracejada que aceita arrastar ou clicar, para telas em que anexar é a ação\n * principal) ou Only Button (título, texto de apoio e botão, para formulários e espaços curtos).\n * Figma: Type.\n */\n type?: FileUploadType\n /** Título da área. @default 'Arraste o arquivo ou clique aqui' no Drag & Drop, 'Anexar arquivo' no Only Button. Figma: Title. */\n title?: string\n /** Esconde o título quando o card ou a seção em volta já diz o que anexar. Figma: Show Title=False. */\n hideTitle?: boolean\n /** Título mostrado enquanto um arquivo é arrastado sobre a área. @default 'Solte o arquivo para enviar' */\n dropTitle?: string\n /** Formatos aceitos e tamanho máximo, antes do envio. Sem ele o texto some (Show Helper Text=False). */\n helperText?: string\n /**\n * Rótulo do botão Outlined do Only Button, com @default 'Anexar arquivo'. Ignorado no Drag & Drop:\n * ali a área inteira é o controle e não há botão dentro dela.\n */\n buttonLabel?: string\n /**\n * `accept` do input de arquivo (`.png,.jpg,.pdf`). Filtra só o diálogo: um arquivo solto na área\n * chega ao `onChange` seja qual for o tipo, para o app recusar e explicar no Alert de erro abaixo\n * da área (\"Formato não aceito\"), como a spec pede. A validação de tipo e tamanho é do consumidor.\n */\n accept?: string\n multiple?: boolean\n disabled?: boolean\n name?: string\n id?: string\n /** Arquivos escolhidos no diálogo ou soltos na área; com `multiple` desligado, só o primeiro. */\n onChange?: (files: File[]) => void\n /** As linhas `FileUpload.Preview`, empilhadas logo abaixo da área com 8px entre elas. */\n children?: ReactNode\n className?: string\n 'data-testid'?: string\n}\n\nconst DEFAULT_TITLE: Record<FileUploadType, string> = {\n 'drag-drop': 'Arraste o arquivo ou clique aqui',\n button: 'Anexar arquivo',\n}\n\n/** Caps the picked or dropped files to the input's `multiple`. The Astro controller has a copy. */\nfunction _pickFiles(list: FileList | null, multiple: boolean): File[] {\n const files = Array.from(list ?? [])\n return multiple ? files : files.slice(0, 1)\n}\n\nexport const FileUploadRoot = ({\n type = 'drag-drop',\n title,\n hideTitle = false,\n dropTitle = 'Solte o arquivo para enviar',\n helperText,\n buttonLabel,\n accept,\n multiple = false,\n disabled = false,\n name,\n id,\n onChange,\n children,\n className,\n 'data-testid': dataTestId,\n}: FileUploadRootProps) => {\n const generatedId = `au-file-upload-${useId().replace(/[^a-zA-Z0-9]/g, '')}`\n const inputId = id ?? generatedId\n const inputRef = useRef<HTMLInputElement>(null)\n // Nested dragenter/dragleave pairs: the area is \"dragging\" while the count is above zero.\n const dragDepth = useRef(0)\n const [dragging, setDragging] = useState(false)\n\n const isDragDrop = type === 'drag-drop'\n const resolvedTitle = title ?? DEFAULT_TITLE[type]\n const resolvedButtonLabel = isDragDrop ? undefined : buttonLabel ?? 'Anexar arquivo'\n const hasText = !hideTitle || !!helperText\n\n const classes = classNames('au-file-upload', `au-file-upload--type-${type}`, {\n 'au-file-upload--disabled': disabled,\n 'au-file-upload--dragging': dragging,\n [className!]: !!className,\n })\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(_pickFiles(event.target.files, multiple))\n // Lets the same file be picked twice in a row.\n event.target.value = ''\n }\n\n const handleDragEnter = (event: DragEvent<HTMLDivElement>) => {\n if (disabled || !isDragDrop) return\n event.preventDefault()\n dragDepth.current += 1\n setDragging(true)\n }\n\n const handleDragOver = (event: DragEvent<HTMLDivElement>) => {\n if (disabled || !isDragDrop) return\n event.preventDefault()\n }\n\n const handleDragLeave = () => {\n if (disabled || !isDragDrop) return\n dragDepth.current = Math.max(0, dragDepth.current - 1)\n if (dragDepth.current === 0) setDragging(false)\n }\n\n const handleDrop = (event: DragEvent<HTMLDivElement>) => {\n if (disabled || !isDragDrop) return\n event.preventDefault()\n dragDepth.current = 0\n setDragging(false)\n onChange?.(_pickFiles(event.dataTransfer.files, multiple))\n }\n\n const openDialog = () => inputRef.current?.click()\n\n return (\n <div className={classes} data-testid={dataTestId}>\n <div\n className=\"au-file-upload__area\"\n onDragEnter={handleDragEnter}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={handleDrop}>\n <input\n ref={inputRef}\n className=\"au-file-upload__input\"\n type=\"file\"\n id={inputId}\n name={name}\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n // In the Only Button the button is the focusable control; the input stays out of the tab order.\n tabIndex={isDragDrop ? undefined : -1}\n aria-label={hideTitle ? resolvedTitle : undefined}\n aria-describedby={helperText ? `${inputId}-helper` : undefined}\n onChange={handleChange}\n />\n {isDragDrop && (\n <span className=\"au-file-upload__icon\" aria-hidden=\"true\">\n <IconUpload />\n </span>\n )}\n {hasText && (\n <span className=\"au-file-upload__text\">\n {!hideTitle && (\n <label htmlFor={inputId} className=\"au-file-upload__title\">\n {dragging ? dropTitle : resolvedTitle}\n </label>\n )}\n {helperText && (\n <span id={`${inputId}-helper`} className=\"au-file-upload__helper\">\n {helperText}\n </span>\n )}\n </span>\n )}\n {resolvedButtonLabel && (\n <Button\n type=\"outlined\"\n size=\"medium\"\n disabled={disabled}\n className=\"au-file-upload__button\"\n onClick={openDialog}>\n <IconUpload />\n {resolvedButtonLabel}\n </Button>\n )}\n </div>\n {children && <div className=\"au-file-upload__files\">{children}</div>}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;AA8CA,MAAM,gBAAgD;AAAA,EACpD,aAAa;AAAA,EACb,QAAQ;AACV;AAGA,SAAS,WAAW,MAAuB,UAA2B;AACpE,QAAM,QAAQ,MAAM,KAAK,QAAQ,CAAA,CAAE;AACnC,SAAO,WAAW,QAAQ,MAAM,MAAM,GAAG,CAAC;AAC5C;AAEO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,OAAO;AAAA,EACP;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AACjB,MAA2B;AACzB,QAAM,cAAc,kBAAkB,MAAA,EAAQ,QAAQ,iBAAiB,EAAE,CAAC;AAC1E,QAAM,UAAU,MAAM;AACtB,QAAM,WAAW,OAAyB,IAAI;AAE9C,QAAM,YAAY,OAAO,CAAC;AAC1B,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,QAAM,aAAa,SAAS;AAC5B,QAAM,gBAAgB,SAAS,cAAc,IAAI;AACjD,QAAM,sBAAsB,aAAa,SAAY,eAAe;AACpE,QAAM,UAAU,CAAC,aAAa,CAAC,CAAC;AAEhC,QAAM,UAAU,WAAW,kBAAkB,wBAAwB,IAAI,IAAI;AAAA,IAC3E,4BAA4B;AAAA,IAC5B,4BAA4B;AAAA,IAC5B,CAAC,SAAU,GAAG,CAAC,CAAC;AAAA,EAAA,CACjB;AAED,QAAM,eAAe,CAAC,UAAyC;AAC7D,yCAAW,WAAW,MAAM,OAAO,OAAO,QAAQ;AAElD,UAAM,OAAO,QAA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AA,CACd;AAAA,UAED,WACC,qBAAC,QAAA,EAAK,WAAU,wBACb,UAAA;AAAA,YAAA,CAAC,iCACC,SAAA,EAAM,SAAS,SAAS,WAAU,yBAChC,UAAA,WAAW,YAAY,cAAA,CAC1B;AAAA,YAED,kCACE,QAAA,EAAK,IAAI,GAAG,OAAO,WAAW,WAAU,0BACtC,UAAA,WAAA,CACH;AAAA,UAAA,GAEJ;AAAA,UAED,uBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,MAAK;AAAA,cACL;AAAA,cACA,WAAU;AAAA,cACV,SAAS;AAAA,cACT,UAAA;AAAA,gBAAA,oBAAC,YAAA,EAAW;AAAA,gBACX;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,IAGH,YAAY,oBAAC,OAAA,EAAI,WAAU,yBAAyB,SAAA,CAAS;AAAA,EAAA,GAChE;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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,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
|
+
{"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}>{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,qBAAC,OAAA,EAAI,WAAU,wBACZ,UAAA;AAAA,MAAA,eAAA;AAAA,MACA,YAAA;AAAA,MACA,gBAAA;AAAA,IAAgB,GACnB;AAAA,IACA,oBAAC,SAAA,EAAQ,OAAM,QAAA,CAAQ;AAAA,EAAA,GACzB;AAGF,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,eAAe;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
|
}
|