@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.
Files changed (32) hide show
  1. package/astro/FeedbackPage/index.astro +2 -2
  2. package/astro/FileUpload/Preview/index.astro +33 -11
  3. package/astro/FileUpload/Root/index.astro +6 -5
  4. package/astro/ListRow/index.astro +32 -36
  5. package/astro/Logo/ac/BadgeWhiteStroke.astro +1 -0
  6. package/astro/Logo/cp/BadgeWhiteStroke.astro +1 -1
  7. package/astro/SearchBar/index.astro +72 -24
  8. package/dist/{BadgeWhite-CkZPPGmT.js → BadgeWhite-BjdKCzB3.js} +3 -2
  9. package/dist/{BadgeWhite-CkZPPGmT.js.map → BadgeWhite-BjdKCzB3.js.map} +1 -1
  10. package/dist/components/DropdownItem/styles.css +1 -1
  11. package/dist/components/FeedbackPage/index.es.js +2 -2
  12. package/dist/components/FeedbackPage/index.es.js.map +1 -1
  13. package/dist/components/FileUpload/Preview/index.d.ts +15 -4
  14. package/dist/components/FileUpload/Preview/index.es.js +18 -4
  15. package/dist/components/FileUpload/Preview/index.es.js.map +1 -1
  16. package/dist/components/FileUpload/Root/index.d.ts +2 -2
  17. package/dist/components/FileUpload/Root/index.es.js +2 -2
  18. package/dist/components/FileUpload/Root/index.es.js.map +1 -1
  19. package/dist/components/ListRow/index.es.js +4 -7
  20. package/dist/components/ListRow/index.es.js.map +1 -1
  21. package/dist/components/ListRow/styles.css +1 -1
  22. package/dist/components/Logo/index.es.js +1 -1
  23. package/dist/components/SearchBar/hooks.d.ts +8 -2
  24. package/dist/components/SearchBar/index.d.ts +1 -1
  25. package/dist/components/SearchBar/index.es.js +23 -6
  26. package/dist/components/SearchBar/index.es.js.map +1 -1
  27. package/dist/components/SearchBar/styles.css +1 -1
  28. package/dist/components/SearchBar/types.d.ts +6 -0
  29. package/dist/components/SectionApp/styles.css +1 -1
  30. package/dist/components/styles/styles.css +1 -1
  31. package/dist/main.es.js +1 -1
  32. package/package.json +1 -1
@@ -3,8 +3,8 @@ import type { HTMLAttributes } from 'astro/types'
3
3
  import Button from '../Button/index.astro'
4
4
  import Text from '../Text/index.astro'
5
5
  import IconAlertOctagon from '../icons/default/IconAlertOctagon.astro'
6
+ import IconAlertTriangle from '../icons/default/IconAlertTriangle.astro'
6
7
  import IconCheckCircle from '../icons/default/IconCheckCircle.astro'
7
- import IconRefreshCw from '../icons/default/IconRefreshCw.astro'
8
8
  import '../../dist/components/FeedbackPage/styles.css'
9
9
 
10
10
  export type FeedbackPageType = 'error' | 'success' | 'warning'
@@ -42,7 +42,7 @@ export type Props = HTMLAttributes<'section'> & {
42
42
  const ICONS = {
43
43
  error: IconAlertOctagon,
44
44
  success: IconCheckCircle,
45
- warning: IconRefreshCw,
45
+ warning: IconAlertTriangle,
46
46
  }
47
47
 
48
48
  const {
@@ -4,6 +4,7 @@ import LinkButton from '../../LinkButton/index.astro'
4
4
  import ProgressBar from '../../ProgressBar/index.astro'
5
5
  import IconPaperclip from '../../icons/default/IconPaperclip.astro'
6
6
  import IconTrash2 from '../../icons/default/IconTrash2.astro'
7
+ import IconX from '../../icons/default/IconX.astro'
7
8
  import '../../../dist/components/styles/styles.css'
8
9
 
9
10
  export type FileUploadPreviewLink = {
@@ -14,8 +15,9 @@ export type FileUploadPreviewLink = {
14
15
 
15
16
  /**
16
17
  * Same markup as the React `FileUpload.Preview`. `icon` is the `icon` slot.
17
- * `onRemove` has no counterpart: `removable` renders the remove button, which
18
- * carries `data-au-file-upload="remove"` for the page's own `<script>`; the
18
+ * `onRemove` has no counterpart: `removable` renders the remove button (the
19
+ * cancel X while there is `progress`), which carries
20
+ * `data-au-file-upload="remove"` for the page's own `<script>`; the
19
21
  * link has no `onClick` either, so give it an `href` or listen on
20
22
  * `.au-file-upload-preview__link`. Every other HTML attribute lands on the
21
23
  * root `div`.
@@ -27,16 +29,27 @@ export type Props = HTMLAttributes<'div'> & {
27
29
  description?: string
28
30
  /** Mensagem de erro abaixo da linha, com o motivo e o próximo passo; liga o estado Error. Figma: Error Message, State=Error. */
29
31
  error?: string
30
- /** Percentual do envio, de 0 a 100; mostra a Percentage Bar abaixo da linha. Figma: Show Progress. */
32
+ /**
33
+ * Percentual do envio, de 0 a 100: a linha entra no estado Enviando, com a Percentage Bar abaixo
34
+ * (rótulo e percentual) e só o X de cancelar à direita; o link e a lixeira aparecem quando o envio
35
+ * termina. Figma: Show Progress.
36
+ */
31
37
  progress?: number
38
+ /** Rótulo à esquerda da barra durante o envio. */
39
+ progressLabel?: string
32
40
  /** Esconde o quadro do ícone. Figma: Show Leading Icon=False. */
33
41
  hideIcon?: boolean
34
- /** Link Button small à direita ("Ver"). Figma: Show Link. */
42
+ /** Link Button small à direita ("Ver"), só com o arquivo já enviado. Figma: Show Link. */
35
43
  link?: FileUploadPreviewLink
36
- /** Mostra o botão de remover (Ghost, ícone, 40x40). Figma: Show Button. */
44
+ /**
45
+ * Mostra o botão de remover o arquivo enviado (lixeira) ou de cancelar o envio em andamento (X,
46
+ * enquanto há `progress`). Figma: Show Button.
47
+ */
37
48
  removable?: boolean
38
49
  /** `aria-label` do botão de remover. */
39
50
  removeLabel?: string
51
+ /** `aria-label` do botão de cancelar, durante o envio. */
52
+ cancelLabel?: string
40
53
  }
41
54
 
42
55
  const {
@@ -44,15 +57,19 @@ const {
44
57
  description,
45
58
  error,
46
59
  progress,
60
+ progressLabel = 'Enviando...',
47
61
  hideIcon = false,
48
62
  link,
49
63
  removable = false,
50
64
  removeLabel = 'Remover arquivo',
65
+ cancelLabel = 'Cancelar envio',
51
66
  class: className,
52
67
  ...rest
53
68
  } = Astro.props
54
69
 
55
70
  const hasProgress = progress !== undefined
71
+ // While sending, the only action is to cancel: the link waits for the file.
72
+ const showLink = !!link && !hasProgress
56
73
  const hasCustomIcon = Astro.slots.has('icon')
57
74
  ---
58
75
 
@@ -77,14 +94,19 @@ const hasCustomIcon = Astro.slots.has('icon')
77
94
  {description && <span class="au-file-upload-preview__description">{description}</span>}
78
95
  </span>
79
96
  {
80
- (link || removable) && (
97
+ (showLink || removable) && (
81
98
  <span class="au-file-upload-preview__actions">
82
- {link && (
83
- <LinkButton as={link.href ? 'a' : 'button'} href={link.href} target={link.target} size="small" class="au-file-upload-preview__link">{link.label}</LinkButton>
99
+ {showLink && (
100
+ <LinkButton as={link!.href ? 'a' : 'button'} href={link!.href} target={link!.target} size="small" class="au-file-upload-preview__link">{link!.label}</LinkButton>
84
101
  )}
102
+ {showLink && removable && <span class="au-file-upload-preview__actions-divider" aria-hidden="true" />}
85
103
  {removable && (
86
- <button type="button" class="au-file-upload-preview__remove" aria-label={removeLabel} data-au-file-upload="remove">
87
- <IconTrash2 />
104
+ <button
105
+ type="button"
106
+ class:list={['au-file-upload-preview__remove', hasProgress && 'au-file-upload-preview__remove--cancel']}
107
+ aria-label={hasProgress ? cancelLabel : removeLabel}
108
+ data-au-file-upload="remove">
109
+ {hasProgress ? <IconX /> : <IconTrash2 />}
88
110
  </button>
89
111
  )}
90
112
  </span>
@@ -95,7 +117,7 @@ const hasCustomIcon = Astro.slots.has('icon')
95
117
  {
96
118
  hasProgress && (
97
119
  <div class="au-file-upload-preview__progress">
98
- <ProgressBar percentage={progress} stepName={`Envio de ${name}`} showDescription={false} />
120
+ <ProgressBar percentage={progress} stepName={progressLabel} />
99
121
  </div>
100
122
  )
101
123
  }
@@ -11,7 +11,8 @@ export type FileUploadType = 'drag-drop' | 'button'
11
11
  * the root emits `au:fileuploadchange` (`detail: { files: File[] }`) when
12
12
  * files are picked in the dialog or dropped on the area, and the native
13
13
  * `change` of the input still fires for the dialog. `children` is the
14
- * default slot (the `FileUpload.Preview` rows). The `data-drop-title` on the
14
+ * default slot (the `FileUpload.Preview` rows). The Only Button's button
15
+ * opens the dialog through the controller; the Drag & Drop has no button. The `data-drop-title` on the
15
16
  * root is wiring for the controller, which removes it when it starts. Every
16
17
  * other HTML attribute lands on the root `div`.
17
18
  */
@@ -31,8 +32,8 @@ export type Props = HTMLAttributes<'div'> & {
31
32
  /** Formatos aceitos e tamanho máximo, antes do envio. Sem ele o texto some (Show Helper Text=False). */
32
33
  helperText?: string
33
34
  /**
34
- * Rótulo do botão Outlined. No Drag & Drop o botão só aparece com ele (Show Button); no Only Button
35
- * é o botão principal ('Anexar arquivo' por padrão).
35
+ * Rótulo do botão Outlined do Only Button ('Anexar arquivo' por padrão). Ignorado no Drag & Drop:
36
+ * ali a área inteira é o controle e não há botão dentro dela.
36
37
  */
37
38
  buttonLabel?: string
38
39
  /**
@@ -71,7 +72,7 @@ const {
71
72
  const inputId = id ?? `au-file-upload-${crypto.randomUUID().slice(0, 8)}`
72
73
  const isDragDrop = type === 'drag-drop'
73
74
  const resolvedTitle = title ?? DEFAULT_TITLE[type]
74
- const resolvedButtonLabel = isDragDrop ? buttonLabel : buttonLabel ?? 'Anexar arquivo'
75
+ const resolvedButtonLabel = isDragDrop ? undefined : buttonLabel ?? 'Anexar arquivo'
75
76
  const hasText = !hideTitle || !!helperText
76
77
  const hasFiles = Astro.slots.has('default')
77
78
  ---
@@ -118,7 +119,7 @@ const hasFiles = Astro.slots.has('default')
118
119
  {
119
120
  resolvedButtonLabel && (
120
121
  <Button type="outlined" size="medium" disabled={disabled} class="au-file-upload__button">
121
- {!isDragDrop && <IconUpload />}
122
+ <IconUpload />
122
123
  {resolvedButtonLabel}
123
124
  </Button>
124
125
  )
@@ -150,7 +150,7 @@ const Tag = clickable ? 'a' : as
150
150
  <div class={`au-list-row__leading au-list-row__leading--${leading}`}>
151
151
  {skeleton ? (
152
152
  <Fragment>
153
- {leading === 'icon' && <Skeleton shape="square" width={44} height={44} />}
153
+ {leading === 'icon' && <Skeleton width={20} height={20} />}
154
154
  {leading === 'partner' && <Skeleton shape="square" width={40} height={40} />}
155
155
  {leading === 'radio' && <Skeleton shape="circle" width={20} height={20} />}
156
156
  {leading === 'trackline' && <Skeleton shape="circle" width={24} height={24} />}
@@ -187,8 +187,8 @@ const Tag = clickable ? 'a' : as
187
187
  {
188
188
  skeleton ? (
189
189
  <Fragment>
190
- <Skeleton width={160} height={16} />
191
- {twoLines && <Skeleton width={104} height={14} />}
190
+ {twoLines && <Skeleton width={104} height={22} />}
191
+ <Skeleton width={160} height={22} />
192
192
  </Fragment>
193
193
  ) : (
194
194
  <Fragment>
@@ -199,40 +199,36 @@ const Tag = clickable ? 'a' : as
199
199
  }
200
200
  </div>
201
201
  {
202
- hasTrailing && (
202
+ hasTrailing && !skeleton && (
203
203
  <div class="au-list-row__trailing">
204
- {skeleton ? (
205
- <Skeleton width={56} height={16} />
206
- ) : (
207
- <Fragment>
208
- {hasSecondary && (
209
- <span class="au-list-row__secondary">
210
- {secondaryLabel && <span class="au-list-row__secondary-label">{secondaryLabel}</span>}
211
- {secondaryDescription && (
212
- <span class="au-list-row__secondary-description">{secondaryDescription}</span>
213
- )}
214
- </span>
215
- )}
216
- {link && (
217
- <LinkButton
218
- as={link.href ? 'a' : 'button'}
219
- href={link.href}
220
- target={link.target}
221
- size="small"
222
- class="au-list-row__link"
223
- data-au-list-row="link">
224
- {link.label}
225
- </LinkButton>
226
- )}
227
- {badge && <BadgeState status={badge.status} text={badge.text} variant={badge.variant} />}
228
- {toggle && <Switch {...toggle} />}
229
- {chevron && (
230
- <span class="au-list-row__chevron" aria-hidden="true">
231
- <IconChevronRight />
232
- </span>
233
- )}
234
- </Fragment>
235
- )}
204
+ <Fragment>
205
+ {hasSecondary && (
206
+ <span class="au-list-row__secondary">
207
+ {secondaryLabel && <span class="au-list-row__secondary-label">{secondaryLabel}</span>}
208
+ {secondaryDescription && (
209
+ <span class="au-list-row__secondary-description">{secondaryDescription}</span>
210
+ )}
211
+ </span>
212
+ )}
213
+ {link && (
214
+ <LinkButton
215
+ as={link.href ? 'a' : 'button'}
216
+ href={link.href}
217
+ target={link.target}
218
+ size="small"
219
+ class="au-list-row__link"
220
+ data-au-list-row="link">
221
+ {link.label}
222
+ </LinkButton>
223
+ )}
224
+ {badge && <BadgeState status={badge.status} text={badge.text} variant={badge.variant} />}
225
+ {toggle && <Switch {...toggle} />}
226
+ {chevron && (
227
+ <span class="au-list-row__chevron" aria-hidden="true">
228
+ <IconChevronRight />
229
+ </span>
230
+ )}
231
+ </Fragment>
236
232
  </div>
237
233
  )
238
234
  }
@@ -10,6 +10,7 @@ export type Props = HTMLAttributes<'div'>
10
10
  xmlns="http://www.w3.org/2000/svg"
11
11
  width="21"
12
12
  height="16"
13
+ viewBox="0 0 21 16"
13
14
  fill="none">
14
15
  <path
15
16
  fill="#fff"
@@ -6,5 +6,5 @@ export type Props = HTMLAttributes<'div'>
6
6
  ---
7
7
 
8
8
  <Logo label="Consumidor Positivo" {...Astro.props}>
9
- <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="none"><path fill="#fff" d="M6.216 4.08C6.216 2.061 7.794.6 9.725.6c1.93 0 3.508 1.462 3.508 3.48 0 2.016-1.552 3.519-3.522 3.519-1.97 0-3.496-1.476-3.496-3.52Z"/><path fill="#0048DB" d="M9.712 6.729c-1.527 0-2.636-1.115-2.636-2.65 0-1.534 1.138-2.61 2.648-2.61 1.51 0 2.648 1.122 2.648 2.61 0 1.489-1.12 2.65-2.661 2.65Z"/><path fill="#fff" d="M20.018 6.84a4.66 4.66 0 0 0-3.334-1.394c-1.26 0-2.444.495-3.334 1.393l-3.487 3.524-1.168-1.18A4.76 4.76 0 0 0 5.29 7.759c-1.809 0-3.431 1.03-4.235 2.69a4.456 4.456 0 0 0-.37 1.121 4.83 4.83 0 0 0 .957 3.92c.136.17.642.687.774.822l3.335 3.369A5.748 5.748 0 0 0 9.863 21.4a5.767 5.767 0 0 0 3.836-1.456.931.931 0 0 0 .114-.095l6.149-6.214c.91-.918 1.42-2.11 1.437-3.356a4.756 4.756 0 0 0-1.38-3.439h-.001Z"/><path fill="#04D98C" d="m9.863 11.593.522-.528 3.573-3.61a3.83 3.83 0 0 1 5.45 0 3.891 3.891 0 0 1 1.128 2.81c-.014 1.037-.46 2.02-1.185 2.753l-1.357 1.372-.002.002-4.06 4.102-.57.575-.16.162-.011.004a4.926 4.926 0 0 1-6.833-.17l-3.335-3.369.23.042c1.51.279 2.873-.396 3.962-1.489l2.648-2.657Z"/><path fill="#0048DB" d="M2.386 14.918a4.789 4.789 0 0 0 4.265-1.336l2.6-2.609-1.166-1.177A3.929 3.929 0 0 0 5.29 8.627c-1.38 0-2.75.73-3.462 2.203a3.61 3.61 0 0 0-.297.902c-.221 1.176-.015 2.238.692 3.123.02.025.05.042.081.048l.082.015h.001Z"/></svg>
9
+ <svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none"><path fill="#fff" d="M6.216 4.08C6.216 2.061 7.794.6 9.725.6c1.93 0 3.508 1.462 3.508 3.48 0 2.016-1.552 3.519-3.522 3.519-1.97 0-3.496-1.476-3.496-3.52Z"/><path fill="#0048DB" d="M9.712 6.729c-1.527 0-2.636-1.115-2.636-2.65 0-1.534 1.138-2.61 2.648-2.61 1.51 0 2.648 1.122 2.648 2.61 0 1.489-1.12 2.65-2.661 2.65Z"/><path fill="#fff" d="M20.018 6.84a4.66 4.66 0 0 0-3.334-1.394c-1.26 0-2.444.495-3.334 1.393l-3.487 3.524-1.168-1.18A4.76 4.76 0 0 0 5.29 7.759c-1.809 0-3.431 1.03-4.235 2.69a4.456 4.456 0 0 0-.37 1.121 4.83 4.83 0 0 0 .957 3.92c.136.17.642.687.774.822l3.335 3.369A5.748 5.748 0 0 0 9.863 21.4a5.767 5.767 0 0 0 3.836-1.456.931.931 0 0 0 .114-.095l6.149-6.214c.91-.918 1.42-2.11 1.437-3.356a4.756 4.756 0 0 0-1.38-3.439h-.001Z"/><path fill="#04D98C" d="m9.863 11.593.522-.528 3.573-3.61a3.83 3.83 0 0 1 5.45 0 3.891 3.891 0 0 1 1.128 2.81c-.014 1.037-.46 2.02-1.185 2.753l-1.357 1.372-.002.002-4.06 4.102-.57.575-.16.162-.011.004a4.926 4.926 0 0 1-6.833-.17l-3.335-3.369.23.042c1.51.279 2.873-.396 3.962-1.489l2.648-2.657Z"/><path fill="#0048DB" d="M2.386 14.918a4.789 4.789 0 0 0 4.265-1.336l2.6-2.609-1.166-1.177A3.929 3.929 0 0 0 5.29 8.627c-1.38 0-2.75.73-3.462 2.203a3.61 3.61 0 0 0-.297.902c-.221 1.176-.015 2.238.692 3.123.02.025.05.042.081.048l.082.015h.001Z"/></svg>
10
10
  </Logo>
@@ -32,7 +32,10 @@ export type SearchBarGroup = {
32
32
  * a virtual focus (`aria-activedescendant`), Enter picks the highlighted
33
33
  * option or searches, a click on a row picks it without blurring the field.
34
34
  *
35
- * Differences from React: `value` is the initial text; `onChange` becomes
35
+ * Differences from React: `value` is the initial text; `filter` filters the
36
+ * rows of the markup (the controller keeps every row it found and shows the
37
+ * ones whose label matches the text, dropping categories left empty, so the
38
+ * rows come back as the text shrinks); `onChange` becomes
36
39
  * `au:searchchange` (`detail.value`), `onSearch` becomes `au:search`
37
40
  * (`detail.value`), `onSelect` becomes `au:searchselect` (`detail.value`,
38
41
  * `detail.label`) and `onClear` becomes `au:searchclear`, all bubbling from
@@ -52,6 +55,12 @@ export type Props = Omit<HTMLAttributes<'div'>, 'style' | 'placeholder'> & {
52
55
  value?: string
53
56
  /** Resultados da busca, soltos ou em grupos com título. A lista abre com o campo em foco. */
54
57
  options?: Array<SearchBarOption | SearchBarGroup>
58
+ /**
59
+ * Filtra as linhas pelo texto digitado no próprio componente, a cada letra, sem acento e sem
60
+ * diferenciar maiúsculas (Figma: Sync). Grupo que fica sem opção some. Com o campo vazio a lista
61
+ * sai inteira. Desligado, quem filtra é a página (busca assíncrona, com `au:searchcontrol`).
62
+ */
63
+ filter?: boolean
55
64
  /** Spinner no lugar do ícone e lista de skeletons enquanto os resultados chegam (Figma: Loading). */
56
65
  loading?: boolean
57
66
  /** Linha mostrada quando há texto e nenhum resultado (Figma: No Results). Vazio desliga. */
@@ -68,6 +77,7 @@ const {
68
77
  placeholder = 'Buscar',
69
78
  value = '',
70
79
  options = [],
80
+ filter = false,
71
81
  loading = false,
72
82
  emptyText = 'Nenhum resultado',
73
83
  disabled = false,
@@ -109,10 +119,11 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
109
119
 
110
120
  <FieldRoot
111
121
  style={style}
112
- class:list={['au-search-bar', value !== '' && 'au-search-bar--filled', loading && 'au-search-bar--loading', className]}
122
+ class:list={['au-search-bar', value !== '' && !disabled && 'au-search-bar--filled', loading && 'au-search-bar--loading', className]}
113
123
  disabled={disabled}
114
124
  data-element="au-search-bar"
115
125
  data-au-search-empty-text={emptyText}
126
+ data-au-search-filter={filter ? '' : undefined}
116
127
  {...rest}>
117
128
  <FieldLabel text={label} id={inputId} labelId={labelId} disabled={disabled} showOptionalLabel={false} />
118
129
  <div class="au-search-bar__control">
@@ -138,9 +149,9 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
138
149
  <div class="au-search-bar__action au-search-bar__action--loading">
139
150
  <Spinner />
140
151
  </div>
141
- ) : value !== '' ? (
142
- <button type="button" class="au-search-bar__action au-search-bar__action--clear" aria-label="Limpar busca" disabled={disabled}>
143
- <IconX size="medium" />
152
+ ) : value !== '' && !disabled ? (
153
+ <button type="button" class="au-search-bar__action au-search-bar__action--clear" aria-label="Limpar busca">
154
+ <IconX />
144
155
  </button>
145
156
  ) : (
146
157
  <button type="button" class="au-search-bar__action au-search-bar__action--search" aria-label="Buscar" disabled={disabled}>
@@ -185,8 +196,8 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
185
196
  <div class="au-search-bar__action au-search-bar__action--loading">
186
197
  <Spinner />
187
198
  </div>
188
- <button type="button" class="au-search-bar__action au-search-bar__action--clear" aria-label="Limpar busca" disabled={disabled}>
189
- <IconX size="medium" />
199
+ <button type="button" class="au-search-bar__action au-search-bar__action--clear" aria-label="Limpar busca">
200
+ <IconX />
190
201
  </button>
191
202
  <button type="button" class="au-search-bar__action au-search-bar__action--search" aria-label="Buscar" disabled={disabled}>
192
203
  <IconSearch />
@@ -203,6 +214,11 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
203
214
 
204
215
  const ITEM_CLASS = 'au-dropdown-item'
205
216
  const FOCUSED_CLASS = 'au-dropdown-item--focused'
217
+ const CATEGORY_CLASS = 'au-dropdown-item--type-category'
218
+
219
+ // Copy of `matchesSearch` in `lib/components/SearchBar/hooks.ts`.
220
+ const normalize = (text: string) => text.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')
221
+ const matchesSearch = (label: string, value: string) => normalize(label).includes(normalize(value))
206
222
 
207
223
  elementController('au-search-bar', ({ root, query, on, emit }) => {
208
224
  const inputEl = query<HTMLInputElement>('.au-search-bar__input')
@@ -223,6 +239,8 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
223
239
  // Controller settings only; React's root carries no such attribute.
224
240
  const emptyText = root.dataset.auSearchEmptyText ?? ''
225
241
  root.removeAttribute('data-au-search-empty-text')
242
+ const filter = root.hasAttribute('data-au-search-filter')
243
+ root.removeAttribute('data-au-search-filter')
226
244
 
227
245
  const inputId = input.id
228
246
  const disabled = input.disabled
@@ -246,36 +264,64 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
246
264
  let dismissed = false
247
265
  let activeIndex: number | null = null
248
266
  let optionNodes: HTMLElement[] = []
267
+ // What the controller itself last put in the list: the same children
268
+ // again means the page did not touch the rows.
269
+ let lastRendered: HTMLElement[] | null = null
249
270
  // Rows the page swaps in while the list is static.
250
271
  const observer = new MutationObserver(() => render())
251
272
 
252
- // The rows the page put in the list. Only controller-owned rows in the
253
- // list (skeletons, the empty row) means the options are the stored ones;
254
- // an empty list means the page cleared them.
273
+ // The rows the page put in the list. Children equal to the last render
274
+ // (the filtered subset, the skeletons, the empty row) mean the options
275
+ // are the stored ones; anything else is the page's new rows, or the page
276
+ // clearing them.
255
277
  function readOptions() {
256
278
  const children = Array.from(list.children) as HTMLElement[]
257
- if (children.length === 0 || children.some((child) => !owned.has(child))) {
258
- const next = children.filter((child) => !owned.has(child))
259
- const changed = next.length !== optionNodes.length || next.some((node, index) => node !== optionNodes[index])
260
- optionNodes = next
261
- // New rows, like new React `options`: the keyboard highlight restarts.
262
- if (changed) activeIndex = null
279
+ if (lastRendered && children.length === lastRendered.length && children.every((child, index) => child === lastRendered![index])) return
280
+ const next = children.filter((child) => !owned.has(child))
281
+ const changed = next.length !== optionNodes.length || next.some((node, index) => node !== optionNodes[index])
282
+ optionNodes = next
283
+ // New rows, like new React `options`: the keyboard highlight restarts.
284
+ if (changed) activeIndex = null
285
+ }
286
+
287
+ const isOption = (node: HTMLElement) => node.getAttribute('role') === 'option' && !node.classList.contains('au-dropdown-item--state-empty')
288
+ const labelOf = (node: HTMLElement) => node.querySelector('.au-dropdown-item__label')?.textContent ?? ''
289
+
290
+ // The rows to show: with `filter` and text, the options whose label
291
+ // matches and the categories that still have one below them, as
292
+ // `filterSearchBarOptions` in the React hook.
293
+ const visible = () => {
294
+ if (!filter || input.value === '') return optionNodes
295
+ const kept: HTMLElement[] = []
296
+ let category: HTMLElement | null = null
297
+ for (const node of optionNodes) {
298
+ if (node.classList.contains(CATEGORY_CLASS)) {
299
+ category = node
300
+ continue
301
+ }
302
+ if (isOption(node) && !matchesSearch(labelOf(node), input.value)) continue
303
+ if (category) {
304
+ kept.push(category)
305
+ category = null
306
+ }
307
+ kept.push(node)
263
308
  }
309
+ return kept
264
310
  }
265
311
 
266
312
  // The option rows, in order: the `index` React keys them by.
267
- const options = () => optionNodes.filter((node) => node.getAttribute('role') === 'option' && !node.classList.contains('au-dropdown-item--state-empty'))
313
+ const options = () => visible().filter(isOption)
268
314
  const selectable = () => options().filter((node) => node.getAttribute('aria-disabled') !== 'true')
269
315
 
270
- const showEmpty = () => !loading && optionNodes.length === 0 && input.value !== '' && !!emptyText
271
- const isOpen = () => focused && !dismissed && !disabled && (loading || optionNodes.length > 0 || showEmpty())
316
+ const showEmpty = () => !loading && visible().length === 0 && input.value !== '' && !!emptyText
317
+ const isOpen = () => focused && !dismissed && !disabled && (loading || visible().length > 0 || showEmpty())
272
318
 
273
319
  function render() {
274
320
  readOptions()
275
321
  const open = isOpen()
276
322
 
277
323
  root.classList.toggle('au-search-bar--open', open)
278
- root.classList.toggle('au-search-bar--filled', input.value !== '')
324
+ root.classList.toggle('au-search-bar--filled', input.value !== '' && !disabled)
279
325
  root.classList.toggle('au-search-bar--loading', loading)
280
326
  list.classList.toggle('au-search-bar__results--open', open)
281
327
  if (loading) list.setAttribute('aria-busy', 'true')
@@ -285,15 +331,16 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
285
331
  else input.setAttribute('aria-activedescendant', optionId(activeIndex))
286
332
 
287
333
  // The action at the right: spinner, clear or search.
288
- const action = loading ? loadingAction : input.value !== '' ? clearAction : searchAction
334
+ // Disabled keeps the search icon: the spec has no Filled state with the X there.
335
+ const action = loading ? loadingAction : input.value !== '' && !disabled ? clearAction : searchAction
289
336
  const current = (Array.from(control.children) as HTMLElement[]).find((child) => actions.has(child))
290
337
  if (current !== action) {
291
338
  if (current) current.replaceWith(action)
292
339
  else control.appendChild(action)
293
340
  }
294
341
 
295
- // The rows: skeletons, the empty row, or the options.
296
- const desired = loading ? skeletonNodes : showEmpty() ? [emptyNode] : optionNodes
342
+ // The rows: skeletons, the empty row, or the (filtered) options.
343
+ const desired = loading ? skeletonNodes : showEmpty() ? [emptyNode] : visible()
297
344
  options().forEach((node, index) => {
298
345
  node.id = optionId(index)
299
346
  node.classList.toggle(FOCUSED_CLASS, activeIndex === index)
@@ -304,6 +351,7 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
304
351
  // The controller's own swap is not a change made by the page.
305
352
  observer.takeRecords()
306
353
  }
354
+ lastRendered = desired
307
355
 
308
356
  // The `[activeIndex]` effect: scroll the highlighted row into view.
309
357
  if (activeIndex !== null) list.querySelector<HTMLElement>(`.${FOCUSED_CLASS}`)?.scrollIntoView({ block: 'nearest' })
@@ -326,7 +374,7 @@ const showEmpty = !loading && rows.length === 0 && value !== '' && !!emptyText
326
374
 
327
375
  function selectOption(node: HTMLElement) {
328
376
  if (node.getAttribute('aria-disabled') === 'true') return
329
- const label = node.querySelector('.au-dropdown-item__label')?.textContent ?? ''
377
+ const label = labelOf(node)
330
378
  setValue(label)
331
379
  emit('au:searchselect', { value: node.dataset.value ?? label, label })
332
380
  activeIndex = null
@@ -606,7 +606,7 @@ const LogoTertiaryWhiteAC = ({ "data-testid": dataTestId }) => {
606
606
  ) });
607
607
  };
608
608
  const LogoBadgeWhiteStrokeCP = ({ "data-testid": dataTestId }) => {
609
- return /* @__PURE__ */ jsx(Logo, { label: "Consumidor Positivo", "data-testid": dataTestId, children: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "22", height: "22", fill: "none", children: [
609
+ return /* @__PURE__ */ jsx(Logo, { label: "Consumidor Positivo", "data-testid": dataTestId, children: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", children: [
610
610
  /* @__PURE__ */ jsx("path", { fill: "#fff", d: "M6.216 4.08C6.216 2.061 7.794.6 9.725.6c1.93 0 3.508 1.462 3.508 3.48 0 2.016-1.552 3.519-3.522 3.519-1.97 0-3.496-1.476-3.496-3.52Z" }),
611
611
  /* @__PURE__ */ jsx("path", { fill: "#0048DB", d: "M9.712 6.729c-1.527 0-2.636-1.115-2.636-2.65 0-1.534 1.138-2.61 2.648-2.61 1.51 0 2.648 1.122 2.648 2.61 0 1.489-1.12 2.65-2.661 2.65Z" }),
612
612
  /* @__PURE__ */ jsx("path", { fill: "#fff", d: "M20.018 6.84a4.66 4.66 0 0 0-3.334-1.394c-1.26 0-2.444.495-3.334 1.393l-3.487 3.524-1.168-1.18A4.76 4.76 0 0 0 5.29 7.759c-1.809 0-3.431 1.03-4.235 2.69a4.456 4.456 0 0 0-.37 1.121 4.83 4.83 0 0 0 .957 3.92c.136.17.642.687.774.822l3.335 3.369A5.748 5.748 0 0 0 9.863 21.4a5.767 5.767 0 0 0 3.836-1.456.931.931 0 0 0 .114-.095l6.149-6.214c.91-.918 1.42-2.11 1.437-3.356a4.756 4.756 0 0 0-1.38-3.439h-.001Z" }),
@@ -621,6 +621,7 @@ const LogoBadgeWhiteStrokeAC = ({ "data-testid": dataTestId }) => {
621
621
  xmlns: "http://www.w3.org/2000/svg",
622
622
  width: "21",
623
623
  height: "16",
624
+ viewBox: "0 0 21 16",
624
625
  fill: "none",
625
626
  children: [
626
627
  /* @__PURE__ */ jsx(
@@ -743,4 +744,4 @@ export {
743
744
  LogoTertiaryAC as r,
744
745
  LogoTertiaryWhiteAC as s
745
746
  };
746
- //# sourceMappingURL=BadgeWhite-CkZPPGmT.js.map
747
+ //# sourceMappingURL=BadgeWhite-BjdKCzB3.js.map