@consumidor-positivo/aurora 0.0.147 → 0.0.149

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.
@@ -8,9 +8,9 @@ import { IconCheck } from "../icons/IconCheck/index.es.js";
8
8
  import { IconClock } from "../icons/IconClock/index.es.js";
9
9
  import { IconInfo } from "../icons/IconInfo/index.es.js";
10
10
  import { IconX } from "../icons/IconX/index.es.js";
11
+ import { h as COLOR_NEUTRAL_70, C as COLOR_SUCCESS_50, b as COLOR_ERROR_50, W as COLOR_WARNING_50, a1 as COLOR_INFO_50 } from "../../tokens-BwvPtuyb.js";
11
12
  import { Conditional } from "../Conditional/index.es.js";
12
13
  import { Text } from "../Text/index.es.js";
13
- import { h as COLOR_NEUTRAL_70, C as COLOR_SUCCESS_50, b as COLOR_ERROR_50, W as COLOR_WARNING_50, a1 as COLOR_INFO_50 } from "../../tokens-BwvPtuyb.js";
14
14
  import './styles.css';const Alert = ({
15
15
  showIcon = true,
16
16
  status = "info",
@@ -1,9 +1,9 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../index-CweZ_OcN.js";
3
- import "../../index-B9cLhrrb.js";
3
+ import "../../index-Cn20y-Ji.js";
4
4
  import "../Button/index.es.js";
5
5
  import "../PortalHolder/index.es.js";
6
- import { a } from "../../index-C9HFx59f.js";
6
+ import { a } from "../../index-piVJ4mle.js";
7
7
  export {
8
8
  a as DatepickerCalendar
9
9
  };
@@ -3,8 +3,8 @@ import "../../index-CweZ_OcN.js";
3
3
  import "../Icon/index.es.js";
4
4
  import "../icons/IconChevronLeft/index.es.js";
5
5
  import "../icons/IconChevronRight/index.es.js";
6
- import "../../index-BDy8i79S.js";
7
- import { C } from "../../index-B9cLhrrb.js";
6
+ import "../../index-CXayTd35.js";
7
+ import { C } from "../../index-Cn20y-Ji.js";
8
8
  export {
9
9
  C as CalendarHeader
10
10
  };
@@ -3,8 +3,8 @@ import $dbSRa$react__default, { useState, useEffect } from "react";
3
3
  import { c as classNames } from "../../index-CweZ_OcN.js";
4
4
  import "../Icon/index.es.js";
5
5
  import { IconCheck } from "../icons/IconCheck/index.es.js";
6
- import { F as Field } from "../../index-ZE6zszxw.js";
7
6
  import { n as COLOR_NEUTRAL_00 } from "../../tokens-BwvPtuyb.js";
7
+ import { F as Field } from "../../index-ZE6zszxw.js";
8
8
  import { Conditional } from "../Conditional/index.es.js";
9
9
  import { Text } from "../Text/index.es.js";
10
10
  import './styles.css';const CheckboxField = ({
@@ -1,13 +1,13 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { B as BREAKPOINT_MD, c as COLOR_NEUTRAL_40 } from "../../tokens-BwvPtuyb.js";
2
3
  import "../../index-CweZ_OcN.js";
3
4
  import "../Icon/index.es.js";
4
5
  import { IconCalendar } from "../icons/IconCalendar/index.es.js";
5
6
  import { InputField } from "../InputField/index.es.js";
6
- import { g as getDefaultDate, D as DDMMYYYY, a as DatepickerCalendar, A as AUCalendarDate } from "../../index-C9HFx59f.js";
7
+ import { g as getDefaultDate, D as DDMMYYYY, a as DatepickerCalendar, A as AUCalendarDate } from "../../index-piVJ4mle.js";
7
8
  import { useRef, useState, useMemo, useEffect } from "react";
8
9
  import { a as above } from "../../screen-DfYo7XQ_.js";
9
- import { u as useOutsideClick } from "../../index-BDy8i79S.js";
10
- import { B as BREAKPOINT_MD, c as COLOR_NEUTRAL_40 } from "../../tokens-BwvPtuyb.js";
10
+ import { u as useOutsideClick } from "../../index-CXayTd35.js";
11
11
  import './styles.css';function useDatepicker({
12
12
  value,
13
13
  defaultValue = "empty",
@@ -0,0 +1,9 @@
1
+
2
+ type ModalProps = {
3
+ isOpen: boolean;
4
+ onClose?: () => void;
5
+ headerContent?: React.ReactNode | string | JSX.Element | JSX.Element[];
6
+ content?: React.ReactNode | string | JSX.Element | JSX.Element[];
7
+ };
8
+ export declare const Modal: ({ isOpen, onClose, headerContent, content, }: ModalProps) => import("react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import "../Icon/index.es.js";
4
+ import { IconX } from "../icons/IconX/index.es.js";
5
+ import './styles.css';const Modal = ({
6
+ isOpen,
7
+ onClose,
8
+ headerContent,
9
+ content
10
+ }) => {
11
+ if (!isOpen) return null;
12
+ const modalClasses = classNames("au-modal", {
13
+ "au-modal--is-open": isOpen
14
+ });
15
+ return /* @__PURE__ */ jsx("div", { className: modalClasses, children: /* @__PURE__ */ jsxs("div", { className: "au-modal__container", children: [
16
+ /* @__PURE__ */ jsxs("div", { className: "au-modal__header", children: [
17
+ /* @__PURE__ */ jsx("div", { className: "au-modal__header-close", onClick: onClose, children: /* @__PURE__ */ jsx(IconX, {}) }),
18
+ headerContent
19
+ ] }),
20
+ /* @__PURE__ */ jsx("div", { className: "au-modal__content", children: content })
21
+ ] }) });
22
+ };
23
+ export {
24
+ Modal
25
+ };
26
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../../lib/components/Modal/index.tsx"],"sourcesContent":["import { IconX } from '@components/icons'\nimport classNames from 'classnames'\n\nimport './styles.scss'\n\ntype ModalProps = {\n isOpen: boolean\n onClose?: () => void\n headerContent?: React.ReactNode | string | JSX.Element | JSX.Element[]\n content?: React.ReactNode | string | JSX.Element | JSX.Element[]\n}\n\nexport const Modal = ({\n isOpen,\n onClose,\n headerContent,\n content,\n}: ModalProps) => {\n if (!isOpen) return null\n\n const modalClasses = classNames('au-modal', {\n 'au-modal--is-open': isOpen,\n })\n\n return (\n <div className={modalClasses}>\n <div className=\"au-modal__container\">\n <div className=\"au-modal__header\">\n <div className=\"au-modal__header-close\" onClick={onClose}>\n <IconX />\n </div>\n {headerContent}\n </div>\n <div className=\"au-modal__content\">{content}</div>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;AAYO,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAkB;AACZ,MAAA,CAAC,OAAe,QAAA;AAEd,QAAA,eAAe,WAAW,YAAY;AAAA,IAC1C,qBAAqB;AAAA,EAAA,CACtB;AAED,6BACG,OAAI,EAAA,WAAW,cACd,UAAC,qBAAA,OAAA,EAAI,WAAU,uBACb,UAAA;AAAA,IAAC,qBAAA,OAAA,EAAI,WAAU,oBACb,UAAA;AAAA,MAAA,oBAAC,SAAI,WAAU,0BAAyB,SAAS,SAC/C,UAAA,oBAAC,SAAM,EACT,CAAA;AAAA,MACC;AAAA,IAAA,GACH;AAAA,IACC,oBAAA,OAAA,EAAI,WAAU,qBAAqB,UAAQ,SAAA;AAAA,EAAA,EAC9C,CAAA,EACF,CAAA;AAEJ;"}
@@ -0,0 +1 @@
1
+ .au-modal{height:100vh;width:100vw;position:fixed;top:0;left:0;bottom:0;right:0;background-color:#16181dcc;opacity:0;visibility:hidden;pointer-events:none;transition:all .3s ease;z-index:5}@keyframes slideInY{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes slideInX{0%{transform:translate(100%)}to{transform:translate(0)}}.au-modal--is-open{opacity:1;visibility:visible;pointer-events:all}.au-modal--is-open .au-modal__container{animation:slideInY .3s ease forwards}@media (min-width: 600px){.au-modal--is-open .au-modal__container{animation:slideInX .3s ease forwards}}.au-modal__container{background-color:#fff;border-radius:16px 16px 0 0;padding:16px;width:100%;height:100%;max-height:90vh;position:fixed;z-index:6;bottom:0}@media (min-width: 600px){.au-modal__container{border-radius:16px 0 0 16px;box-shadow:0 24px 56px #7686ad14,0 12px 12px #0048db0a;top:0;right:0;margin:0;height:100vh;height:100dvh;max-width:414px;max-height:100vh}}.au-modal__header{position:relative}.au-modal__header-close{cursor:pointer;display:flex;justify-content:end;width:100%}.au-modal__content{height:calc(100% - 80px);overflow-y:auto}.au-modal__content::-webkit-scrollbar{width:16px}.au-modal__content::-webkit-scrollbar-track{background:#f4f7fb;border-radius:32px}.au-modal__content::-webkit-scrollbar-thumb{background:#0048db;border-radius:8px;border:4px solid #f4f7fb}.au-modal__content::-webkit-scrollbar-thumb:hover{background:#1737a4;transition:all .3s ease}
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment } from "react/jsx-runtime";
2
2
  import { a as above } from "../../screen-DfYo7XQ_.js";
3
- import { Portal } from "../Portal/index.es.js";
4
3
  import { B as BREAKPOINT_MD } from "../../tokens-BwvPtuyb.js";
4
+ import { Portal } from "../Portal/index.es.js";
5
5
  const PortalHolder = ({ withPortal, children }) => {
6
6
  const shouldUsePortal = !above(BREAKPOINT_MD) && withPortal;
7
7
  if (shouldUsePortal) return /* @__PURE__ */ jsx(Portal, { children });
@@ -4,7 +4,7 @@ import "../Icon/index.es.js";
4
4
  import "../icons/IconChevronDown/index.es.js";
5
5
  import "../icons/IconChevronLeft/index.es.js";
6
6
  import "../icons/IconX/index.es.js";
7
- import { S } from "../../index-BDy8i79S.js";
7
+ import { S } from "../../index-CXayTd35.js";
8
8
  export {
9
9
  S as Segment
10
10
  };
@@ -1,12 +1,18 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { createPortal } from "react-dom";
2
3
  import { c as classNames } from "../../index-CweZ_OcN.js";
3
4
  import "../Icon/index.es.js";
4
5
  import { IconCheck } from "../icons/IconCheck/index.es.js";
5
6
  import { IconChevronDown } from "../icons/IconChevronDown/index.es.js";
7
+ import { IconSearch } from "../icons/IconSearch/index.es.js";
6
8
  import { IconSlash } from "../icons/IconSlash/index.es.js";
9
+ import { Modal } from "../Modal/index.es.js";
10
+ import { Text } from "../Text/index.es.js";
11
+ import { Conditional } from "../Conditional/index.es.js";
12
+ import { c as COLOR_NEUTRAL_40 } from "../../tokens-BwvPtuyb.js";
7
13
  import { F as Field } from "../../index-ZE6zszxw.js";
8
14
  import { useState, useRef, useEffect } from "react";
9
- import './styles.css';const useSelectField = (options, initialValue, onChange, onBlur, disabled, register, autocomplete = false) => {
15
+ import './styles.css';const useSelectField = (options, initialValue, onChange, onBlur, disabled, register, autocomplete = false, fullScreenOptions = false) => {
10
16
  var _a;
11
17
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
12
18
  const [selectedOption, setSelectedOption] = useState({
@@ -21,7 +27,7 @@ import './styles.css';const useSelectField = (options, initialValue, onChange, o
21
27
  const selectElementRef = useRef(null);
22
28
  const [searchValue, setSearchValue] = useState("");
23
29
  const activeOptionRef = useRef(null);
24
- const filteredOptions = autocomplete ? options.filter(
30
+ const filteredOptions = autocomplete || fullScreenOptions ? options.filter(
25
31
  (option) => option.label.toLowerCase().includes(searchValue.toLowerCase())
26
32
  ) : options;
27
33
  useEffect(() => {
@@ -47,7 +53,8 @@ import './styles.css';const useSelectField = (options, initialValue, onChange, o
47
53
  }, [activeOptionIndex]);
48
54
  useEffect(() => {
49
55
  const handleClickOutside = (event) => {
50
- if (selectRef.current && !selectRef.current.contains(event.target)) {
56
+ const isClickedOutside = selectRef.current && !selectRef.current.contains(event.target) && activeOptionRef.current;
57
+ if (isClickedOutside) {
51
58
  setIsDropdownOpen(false);
52
59
  }
53
60
  };
@@ -144,8 +151,8 @@ import './styles.css';const useSelectField = (options, initialValue, onChange, o
144
151
  setSelectedOption({ value: option.value, label: option.label });
145
152
  }
146
153
  setActiveOptionIndex(null);
147
- setIsDropdownOpen(false);
148
154
  setSearchValue("");
155
+ setTimeout(() => setIsDropdownOpen(false), 500);
149
156
  if (onChange) {
150
157
  onChange(optionValue);
151
158
  }
@@ -177,6 +184,9 @@ import './styles.css';const useSelectField = (options, initialValue, onChange, o
177
184
  }, 200);
178
185
  }
179
186
  };
187
+ const onCloseOptions = () => {
188
+ setIsDropdownOpen(false);
189
+ };
180
190
  return {
181
191
  isDropdownOpen,
182
192
  selectRef,
@@ -194,7 +204,8 @@ import './styles.css';const useSelectField = (options, initialValue, onChange, o
194
204
  dropdownMaxHeight,
195
205
  selectedOption,
196
206
  setSelectedOption,
197
- handleOnBlur
207
+ handleOnBlur,
208
+ onCloseOptions
198
209
  };
199
210
  };
200
211
  const SelectField = ({
@@ -215,7 +226,8 @@ const SelectField = ({
215
226
  register,
216
227
  onBlur,
217
228
  autocomplete = false,
218
- EmptyText = "Nada encontrado"
229
+ EmptyText = "Nada encontrado",
230
+ fullScreenOptions = false
219
231
  }) => {
220
232
  const {
221
233
  isDropdownOpen,
@@ -232,7 +244,8 @@ const SelectField = ({
232
244
  selectedOption,
233
245
  handleInputChange,
234
246
  dropdownMaxHeight,
235
- handleOnBlur
247
+ handleOnBlur,
248
+ onCloseOptions
236
249
  } = useSelectField(
237
250
  options,
238
251
  value,
@@ -240,82 +253,184 @@ const SelectField = ({
240
253
  onBlur,
241
254
  disabled,
242
255
  register,
243
- autocomplete
256
+ autocomplete,
257
+ fullScreenOptions
244
258
  );
245
- const dropdownClasses = classNames("au-field__select", {
259
+ const selectClasses = classNames("au-field__select", {
246
260
  "au-field__select--disabled": disabled,
247
261
  "au-field__select--open": isDropdownOpen,
248
262
  "au-field__select--required": required,
249
263
  "au-field__select--error": error,
250
264
  [className]: className
251
265
  });
252
- return /* @__PURE__ */ jsxs(
253
- Field.Root,
254
- {
255
- style,
256
- customclass: className,
257
- error,
258
- disabled,
259
- children: [
260
- /* @__PURE__ */ jsx(
261
- Field.Label,
262
- {
263
- text: label,
264
- showOptionalLabel,
265
- required,
266
- error,
267
- disabled
268
- }
269
- ),
270
- /* @__PURE__ */ jsxs("div", { className: dropdownClasses, children: [
271
- /* @__PURE__ */ jsxs(
272
- "div",
266
+ const optionsClasses = classNames("au-field__select-options", {
267
+ "au-field__select-options--open": isDropdownOpen
268
+ });
269
+ const optionClasses = (option, index) => classNames("au-field__select-option", {
270
+ "au-field__select-option--highlighted": activeOptionIndex === index,
271
+ "au-field__select-option--selected": option.value === selectedOption.value,
272
+ "au-field__select-option--disabled": option.disabled
273
+ });
274
+ const fullScreenOptionClasses = (option, index) => classNames("au-field__fullscreen-options-select-option", {
275
+ "au-field__fullscreen-options-select-option--highlighted": activeOptionIndex === index,
276
+ "au-field__fullscreen-options-select-option--selected": option.value === selectedOption.value,
277
+ "au-field__fullscreen-options-select-option--disabled": option.disabled
278
+ });
279
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
280
+ /* @__PURE__ */ jsxs(
281
+ Field.Root,
282
+ {
283
+ style,
284
+ customclass: className,
285
+ error,
286
+ disabled,
287
+ children: [
288
+ /* @__PURE__ */ jsx(
289
+ Field.Label,
273
290
  {
274
- className: "au-field__select-wrapper",
275
- onClick: toggleDropdown,
276
- onKeyDown: onKeyDownDropdown,
277
- tabIndex: disabled ? -1 : 0,
278
- ref: selectRef,
279
- role: "combobox",
280
- "aria-haspopup": "listbox",
281
- "aria-expanded": isDropdownOpen,
282
- "aria-labelledby": "select-label",
283
- "aria-activedescendant": activeOptionIndex !== null && filteredOptions[activeOptionIndex] ? filteredOptions[activeOptionIndex].value : void 0,
284
- onBlur: handleOnBlur,
285
- children: [
286
- /* @__PURE__ */ jsx(
287
- "input",
291
+ text: label,
292
+ showOptionalLabel,
293
+ required,
294
+ error,
295
+ disabled
296
+ }
297
+ ),
298
+ /* @__PURE__ */ jsxs("div", { className: selectClasses, children: [
299
+ /* @__PURE__ */ jsxs(
300
+ "div",
301
+ {
302
+ className: "au-field__select-wrapper",
303
+ onClick: toggleDropdown,
304
+ onKeyDown: onKeyDownDropdown,
305
+ tabIndex: disabled ? -1 : 0,
306
+ ref: selectRef,
307
+ role: "combobox",
308
+ "aria-haspopup": "listbox",
309
+ "aria-expanded": isDropdownOpen,
310
+ "aria-labelledby": "select-label",
311
+ "aria-activedescendant": activeOptionIndex !== null && filteredOptions[activeOptionIndex] ? filteredOptions[activeOptionIndex].value : void 0,
312
+ onBlur: handleOnBlur,
313
+ children: [
314
+ /* @__PURE__ */ jsx(
315
+ "input",
316
+ {
317
+ className: "au-field__select-input",
318
+ value: searchValue || selectedOption.label,
319
+ placeholder: placeholder || "Selecionar...",
320
+ onChange: handleInputChange,
321
+ readOnly: !autocomplete,
322
+ disabled
323
+ }
324
+ ),
325
+ /* @__PURE__ */ jsx("div", { className: "au-field__select-icon", children: /* @__PURE__ */ jsx(IconChevronDown, {}) })
326
+ ]
327
+ }
328
+ ),
329
+ /* @__PURE__ */ jsx(
330
+ Conditional,
331
+ {
332
+ condition: !fullScreenOptions,
333
+ renderIf: /* @__PURE__ */ jsx(
334
+ "ul",
288
335
  {
289
- className: "au-field__select-input",
290
- value: searchValue || selectedOption.label,
291
- placeholder: placeholder || "Selecionar...",
292
- onChange: handleInputChange,
293
- readOnly: !autocomplete,
294
- disabled
336
+ className: optionsClasses,
337
+ role: "listbox",
338
+ "aria-live": "polite",
339
+ tabIndex: -1,
340
+ style: {
341
+ maxHeight: `${dropdownMaxHeight}px`,
342
+ overflowY: "auto"
343
+ },
344
+ children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("li", { className: "au-field__select-option au-field__select-option--empty", children: EmptyText }) : filteredOptions.map((option, index) => /* @__PURE__ */ jsxs(
345
+ "li",
346
+ {
347
+ className: optionClasses(option, index),
348
+ ref: activeOptionIndex === index ? activeOptionRef : null,
349
+ role: "option",
350
+ "aria-selected": option.value === selectedOption.value,
351
+ "aria-disabled": option.disabled,
352
+ onPointerUp: () => selectOption(option.value, option.disabled),
353
+ onMouseEnter: () => setActiveOptionIndex(index),
354
+ children: [
355
+ option.label,
356
+ option.disabled ? /* @__PURE__ */ jsx(IconSlash, {}) : option.value === selectedOption.value ? /* @__PURE__ */ jsx(IconCheck, {}) : null
357
+ ]
358
+ },
359
+ index
360
+ ))
295
361
  }
296
- ),
297
- /* @__PURE__ */ jsx("div", { className: "au-field__select-icon", children: /* @__PURE__ */ jsx(IconChevronDown, {}) })
298
- ]
362
+ )
363
+ }
364
+ ),
365
+ /* @__PURE__ */ jsx(
366
+ "select",
367
+ {
368
+ hidden: true,
369
+ disabled,
370
+ value: selectedOption.value,
371
+ onChange: (e) => selectOption(e.target.value),
372
+ ref: selectElementRef,
373
+ name,
374
+ children: options.map((option, index) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, index))
375
+ }
376
+ )
377
+ ] }),
378
+ /* @__PURE__ */ jsx(
379
+ Field.Message,
380
+ {
381
+ hasError: !!error,
382
+ errorMessage,
383
+ helpMessage
299
384
  }
300
- ),
385
+ )
386
+ ]
387
+ }
388
+ ),
389
+ /* @__PURE__ */ jsx(
390
+ Conditional,
391
+ {
392
+ condition: fullScreenOptions,
393
+ renderIf: /* @__PURE__ */ jsx(Fragment, { children: createPortal(
301
394
  /* @__PURE__ */ jsx(
302
- "ul",
395
+ Modal,
303
396
  {
304
- className: classNames("au-field__select-options", {
305
- "au-field__select-options--open": isDropdownOpen
306
- }),
307
- role: "listbox",
308
- "aria-live": "polite",
309
- tabIndex: -1,
310
- style: { maxHeight: `${dropdownMaxHeight}px`, overflowY: "auto" },
311
- children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("li", { className: "au-field__select-option au-field__select-option--empty", children: EmptyText }) : filteredOptions.map((option, index) => /* @__PURE__ */ jsxs(
397
+ isOpen: isDropdownOpen,
398
+ onClose: onCloseOptions,
399
+ headerContent: /* @__PURE__ */ jsxs("div", { children: [
400
+ /* @__PURE__ */ jsx(Text, { as: "label", variant: "heading-small", weight: "bold", children: label }),
401
+ /* @__PURE__ */ jsxs(
402
+ "div",
403
+ {
404
+ className: "au-field__fullscreen-options-select-search-bar",
405
+ onKeyDown: onKeyDownDropdown,
406
+ tabIndex: disabled ? -1 : 0,
407
+ ref: selectRef,
408
+ role: "combobox",
409
+ "aria-haspopup": "listbox",
410
+ "aria-expanded": isDropdownOpen,
411
+ "aria-labelledby": "select-label",
412
+ "aria-activedescendant": activeOptionIndex !== null && filteredOptions[activeOptionIndex] ? filteredOptions[activeOptionIndex].value : void 0,
413
+ onBlur: handleOnBlur,
414
+ children: [
415
+ /* @__PURE__ */ jsx(
416
+ "input",
417
+ {
418
+ className: "au-field__select-input",
419
+ value: searchValue || selectedOption.label,
420
+ placeholder: "Buscar",
421
+ onChange: handleInputChange,
422
+ disabled
423
+ }
424
+ ),
425
+ /* @__PURE__ */ jsx("div", { className: "au-field__select-icon", children: /* @__PURE__ */ jsx(IconSearch, { rawColor: COLOR_NEUTRAL_40 }) })
426
+ ]
427
+ }
428
+ )
429
+ ] }),
430
+ content: /* @__PURE__ */ jsx("div", { className: "au-field__fullscreen-options-select-options", children: filteredOptions.map((option, index) => /* @__PURE__ */ jsxs(
312
431
  "li",
313
432
  {
314
- className: classNames("au-field__select-option", {
315
- "au-field__select-option--highlighted": activeOptionIndex === index,
316
- "au-field__select-option--selected": option.value === selectedOption.value,
317
- "au-field__select-option--disabled": option.disabled
318
- }),
433
+ className: fullScreenOptionClasses(option, index),
319
434
  ref: activeOptionIndex === index ? activeOptionRef : null,
320
435
  role: "option",
321
436
  "aria-selected": option.value === selectedOption.value,
@@ -328,33 +443,14 @@ const SelectField = ({
328
443
  ]
329
444
  },
330
445
  index
331
- ))
446
+ )) })
332
447
  }
333
448
  ),
334
- /* @__PURE__ */ jsx(
335
- "select",
336
- {
337
- hidden: true,
338
- disabled,
339
- value: selectedOption.value,
340
- onChange: (e) => selectOption(e.target.value),
341
- ref: selectElementRef,
342
- name,
343
- children: options.map((option, index) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, index))
344
- }
345
- )
346
- ] }),
347
- /* @__PURE__ */ jsx(
348
- Field.Message,
349
- {
350
- hasError: !!error,
351
- errorMessage,
352
- helpMessage
353
- }
354
- )
355
- ]
356
- }
357
- );
449
+ document.body
450
+ ) })
451
+ }
452
+ )
453
+ ] });
358
454
  };
359
455
  export {
360
456
  SelectField
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../../../lib/components/form/SelectField/hook.ts","../../../lib/components/form/SelectField/index.tsx"],"sourcesContent":["import { useState, useRef, useEffect } from 'react'\nimport { OptionProps } from './types'\n\nexport const useSelectField = (\n options: OptionProps[],\n initialValue?: string,\n onChange?: (value: string) => void,\n onBlur?: React.FocusEventHandler,\n disabled?: boolean,\n register?: (instance: HTMLSelectElement | null) => void,\n autocomplete: boolean = false,\n) => {\n const [isDropdownOpen, setIsDropdownOpen] = useState(false)\n const [selectedOption, setSelectedOption] = useState<OptionProps>({\n value: initialValue || '',\n label: initialValue\n ? options.find((option) => option.value === initialValue)?.label || ''\n : '',\n })\n const [activeOptionIndex, setActiveOptionIndex] = useState<number | null>(\n null,\n )\n const [dropdownMaxHeight, setDropdownMaxHeight] = useState<number>(0)\n const selectRef = useRef<HTMLDivElement>(null)\n const selectElementRef = useRef<HTMLSelectElement>(null)\n const [searchValue, setSearchValue] = useState<string>('')\n const activeOptionRef = useRef<HTMLLIElement | null>(null)\n\n const filteredOptions = autocomplete\n ? options.filter((option) =>\n option.label.toLowerCase().includes(searchValue.toLowerCase()),\n )\n : options\n\n useEffect(() => {\n if (initialValue) {\n const option = options.find((option) => option.value === initialValue)\n if (option) {\n setSelectedOption({ value: option.value, label: option.label })\n }\n }\n }, [initialValue, options])\n\n useEffect(() => {\n if (register && selectElementRef.current) {\n register(selectElementRef.current)\n }\n }, [register])\n\n useEffect(() => {\n if (activeOptionRef.current) {\n activeOptionRef.current.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n })\n }\n }, [activeOptionIndex])\n\n useEffect(() => {\n const handleClickOutside = (event: PointerEvent) => {\n if (\n selectRef.current &&\n !selectRef.current.contains(event.target as Node)\n ) {\n setIsDropdownOpen(false)\n }\n }\n\n if (isDropdownOpen) {\n document.addEventListener('pointerup', handleClickOutside)\n } else {\n document.removeEventListener('pointerup', handleClickOutside)\n }\n\n return () => {\n document.removeEventListener('pointerup', handleClickOutside)\n }\n }, [isDropdownOpen])\n\n const toggleDropdown = () => {\n if (!isDropdownOpen && selectRef.current) {\n const { bottom } = selectRef.current.getBoundingClientRect()\n let totalPadding = 0\n let parentElement: HTMLElement | null = selectRef.current.parentElement\n\n while (parentElement) {\n const parentPaddingBottom = parseFloat(\n window.getComputedStyle(parentElement).paddingBottom || '0',\n )\n totalPadding += parentPaddingBottom\n parentElement = parentElement.parentElement\n }\n\n const availableSpaceBelow = window.innerHeight - bottom - totalPadding\n const minDropdownHeight = 212\n const calculatedHeight = Math.max(availableSpaceBelow, minDropdownHeight)\n\n setDropdownMaxHeight(calculatedHeight)\n }\n\n setIsDropdownOpen((prev) => {\n if (!prev) {\n const selectedIndex = options.findIndex(\n (option) => option.value === selectedOption.value,\n )\n setActiveOptionIndex(selectedIndex !== -1 ? selectedIndex : null)\n }\n return !prev\n })\n }\n\n const _findNextAvailableIndex = (\n currentIndex: number,\n direction: 'down' | 'up',\n ) => {\n const step = direction === 'down' ? 1 : -1\n let nextIndex =\n (currentIndex + step + filteredOptions.length) % filteredOptions.length\n\n while (filteredOptions[nextIndex]?.disabled) {\n nextIndex =\n (nextIndex + step + filteredOptions.length) % filteredOptions.length\n }\n\n return nextIndex\n }\n\n const onKeyDownDropdown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return\n\n const _actions: Record<string, () => void> = {\n Enter: () => {\n if (!isDropdownOpen) {\n toggleDropdown()\n return\n }\n if (\n activeOptionIndex !== null &&\n !filteredOptions[activeOptionIndex].disabled\n ) {\n e.preventDefault()\n selectOption(\n filteredOptions[activeOptionIndex].value,\n filteredOptions[activeOptionIndex].disabled,\n )\n }\n },\n ArrowDown: () => {\n e.preventDefault()\n setActiveOptionIndex((prev) =>\n _findNextAvailableIndex(prev !== null ? prev : -1, 'down'),\n )\n if (!isDropdownOpen) toggleDropdown()\n },\n ArrowUp: () => {\n e.preventDefault()\n setActiveOptionIndex((prev) =>\n _findNextAvailableIndex(\n prev !== null ? prev : filteredOptions.length,\n 'up',\n ),\n )\n if (!isDropdownOpen) toggleDropdown()\n },\n Escape: () => {\n setIsDropdownOpen(false)\n },\n }\n\n if (_actions[e.key]) {\n _actions[e.key]()\n }\n }\n\n const selectOption = (optionValue: string, optionDisabled?: boolean) => {\n if (optionDisabled) return\n\n const option = options.find((option) => option.value === optionValue)\n if (option) {\n setSelectedOption({ value: option.value, label: option.label })\n }\n\n setActiveOptionIndex(null)\n setIsDropdownOpen(false)\n setSearchValue('')\n if (onChange) {\n onChange(optionValue)\n }\n }\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n setSearchValue(value)\n\n if (onChange) {\n onChange(value)\n }\n\n if (value === '') {\n setSelectedOption({ value: '', label: '' })\n }\n\n if (!isDropdownOpen) {\n setIsDropdownOpen(true)\n }\n }\n\n const handleOnBlur = (event?: React.FocusEvent<Element>) => {\n if (onBlur) {\n setTimeout(() => {\n const getOptionByLabel = (label: string) =>\n options.find((option) => option.label === label)\n\n const elementValue = (event?.target as HTMLInputElement).value\n const selectedOptionFromElement = getOptionByLabel(elementValue)\n\n const targetValue = selectedOption?.value\n ? selectedOption\n : selectedOptionFromElement || { value: elementValue, label: '' }\n\n onBlur({\n ...event,\n target: targetValue,\n } as React.FocusEvent<Element> & {\n target: OptionProps\n })\n }, 200)\n }\n }\n\n return {\n isDropdownOpen,\n selectRef,\n activeOptionRef,\n selectElementRef,\n toggleDropdown,\n selectOption,\n onKeyDownDropdown,\n setActiveOptionIndex,\n activeOptionIndex,\n filteredOptions,\n searchValue,\n setSearchValue,\n handleInputChange,\n dropdownMaxHeight,\n selectedOption,\n setSelectedOption,\n handleOnBlur,\n }\n}\n","import classNames from 'classnames'\nimport { IconChevronDown, IconSlash, IconCheck } from '@components/icons'\nimport Field from '../Field'\nimport { SelectFieldProps } from './types'\nimport { useSelectField } from './hook'\nimport './styles.scss'\n\nexport const SelectField = ({\n label,\n options,\n showOptionalLabel,\n error,\n errorMessage,\n helpMessage,\n disabled,\n required,\n value,\n onChange,\n style,\n className,\n placeholder,\n name,\n register,\n onBlur,\n autocomplete = false,\n EmptyText = 'Nada encontrado',\n}: SelectFieldProps) => {\n const {\n isDropdownOpen,\n selectRef,\n selectElementRef,\n activeOptionRef,\n toggleDropdown,\n selectOption,\n onKeyDownDropdown,\n setActiveOptionIndex,\n activeOptionIndex,\n filteredOptions,\n searchValue,\n selectedOption,\n handleInputChange,\n dropdownMaxHeight,\n handleOnBlur\n } = useSelectField(\n options,\n value,\n onChange,\n onBlur,\n disabled,\n register,\n autocomplete,\n )\n\n const dropdownClasses = classNames('au-field__select', {\n 'au-field__select--disabled': disabled,\n 'au-field__select--open': isDropdownOpen,\n 'au-field__select--required': required,\n 'au-field__select--error': error,\n [className!]: className,\n })\n\n return (\n <Field.Root\n style={style}\n customclass={className}\n error={error}\n disabled={disabled}>\n <Field.Label\n text={label}\n showOptionalLabel={showOptionalLabel}\n required={required}\n error={error}\n disabled={disabled}\n />\n <div className={dropdownClasses}>\n <div\n className=\"au-field__select-wrapper\"\n onClick={toggleDropdown}\n onKeyDown={onKeyDownDropdown}\n tabIndex={disabled ? -1 : 0}\n ref={selectRef}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={isDropdownOpen}\n aria-labelledby=\"select-label\"\n aria-activedescendant={\n activeOptionIndex !== null && filteredOptions[activeOptionIndex]\n ? filteredOptions[activeOptionIndex].value\n : undefined\n }\n onBlur={handleOnBlur}>\n <input\n className=\"au-field__select-input\"\n value={searchValue || selectedOption.label}\n placeholder={placeholder || 'Selecionar...'}\n onChange={handleInputChange}\n readOnly={!autocomplete}\n disabled={disabled}\n />\n <div className=\"au-field__select-icon\">\n <IconChevronDown />\n </div>\n </div>\n <ul\n className={classNames('au-field__select-options', {\n 'au-field__select-options--open': isDropdownOpen,\n })}\n role=\"listbox\"\n aria-live=\"polite\"\n tabIndex={-1}\n style={{ maxHeight: `${dropdownMaxHeight}px`, overflowY: 'auto' }}>\n {filteredOptions.length === 0 ? (\n <li className=\"au-field__select-option au-field__select-option--empty\">\n {EmptyText}\n </li>\n ) : (\n filteredOptions.map((option, index) => (\n <li\n key={index}\n className={classNames('au-field__select-option', {\n 'au-field__select-option--highlighted':\n activeOptionIndex === index,\n 'au-field__select-option--selected':\n option.value === selectedOption.value,\n 'au-field__select-option--disabled': option.disabled,\n })}\n ref={activeOptionIndex === index ? activeOptionRef : null}\n role=\"option\"\n aria-selected={option.value === selectedOption.value}\n aria-disabled={option.disabled}\n onPointerUp={() => selectOption(option.value, option.disabled)}\n onMouseEnter={() => setActiveOptionIndex(index)}>\n {option.label}\n {option.disabled ? (\n <IconSlash />\n ) : option.value === selectedOption.value ? (\n <IconCheck />\n ) : null}\n </li>\n ))\n )}\n </ul>\n\n <select\n hidden\n disabled={disabled}\n value={selectedOption.value}\n onChange={(e) => selectOption(e.target.value)}\n ref={selectElementRef}\n name={name}>\n {options.map((option, index) => (\n <option key={index} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n <Field.Message\n hasError={!!error}\n errorMessage={errorMessage}\n helpMessage={helpMessage}\n />\n </Field.Root>\n )\n}\n"],"names":["option","_a"],"mappings":";;;;;;;;AAGa,MAAA,iBAAiB,CAC5B,SACA,cACA,UACA,QACA,UACA,UACA,eAAwB,UACrB;;AACH,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAC1D,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAsB;AAAA,IAChE,OAAO,gBAAgB;AAAA,IACvB,OAAO,iBACH,aAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,YAAY,MAAtD,mBAAyD,UAAS,KAClE;AAAA,EAAA,CACL;AACK,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD;AAAA,EAAA;AAEF,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAiB,CAAC;AAC9D,QAAA,YAAY,OAAuB,IAAI;AACvC,QAAA,mBAAmB,OAA0B,IAAI;AACvD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAiB,EAAE;AACnD,QAAA,kBAAkB,OAA6B,IAAI;AAEnD,QAAA,kBAAkB,eACpB,QAAQ;AAAA,IAAO,CAAC,WACd,OAAO,MAAM,YAAc,EAAA,SAAS,YAAY,aAAa;AAAA,EAE/D,IAAA;AAEJ,Y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AAO;AAAA,kBACtB,aAAa,MAAM,aAAa,OAAO,OAAO,OAAO,QAAQ;AAAA,kBAC7D,cAAc,MAAM,qBAAqB,KAAK;AAAA,kBAC7C,UAAA;AAAA,oBAAO,OAAA;AAAA,oBACP,OAAO,WACN,oBAAC,WAAU,CAAA,CAAA,IACT,OAAO,UAAU,eAAe,QACjC,oBAAA,WAAA,CAAA,CAAU,IACT;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAnBC;AAAA,cAAA,CAqBR;AAAA,YAAA;AAAA,UAEL;AAAA,UAEA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,QAAM;AAAA,cACN;AAAA,cACA,OAAO,eAAe;AAAA,cACtB,UAAU,CAAC,MAAM,aAAa,EAAE,OAAO,KAAK;AAAA,cAC5C,KAAK;AAAA,cACL;AAAA,cACC,UAAQ,QAAA,IAAI,CAAC,QAAQ,UACpB,oBAAC,UAAmB,EAAA,OAAO,OAAO,OAC/B,UAAO,OAAA,MAAA,GADG,KAEb,CACD;AAAA,YAAA;AAAA,UACH;AAAA,QAAA,GACF;AAAA,QACA;AAAA,UAAC,MAAM;AAAA,UAAN;AAAA,YACC,UAAU,CAAC,CAAC;AAAA,YACZ;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"index.es.js","sources":["../../../lib/components/form/SelectField/hook.ts","../../../lib/components/form/SelectField/index.tsx"],"sourcesContent":["import { useState, useRef, useEffect } from 'react'\nimport { OptionProps } from './types'\n\nexport const useSelectField = (\n options: OptionProps[],\n initialValue?: string,\n onChange?: (value: string) => void,\n onBlur?: React.FocusEventHandler,\n disabled?: boolean,\n register?: (instance: HTMLSelectElement | null) => void,\n autocomplete: boolean = false,\n fullScreenOptions: boolean = false,\n) => {\n const [isDropdownOpen, setIsDropdownOpen] = useState(false)\n const [selectedOption, setSelectedOption] = useState<OptionProps>({\n value: initialValue || '',\n label: initialValue\n ? options.find((option) => option.value === initialValue)?.label || ''\n : '',\n })\n const [activeOptionIndex, setActiveOptionIndex] = useState<number | null>(\n null,\n )\n const [dropdownMaxHeight, setDropdownMaxHeight] = useState<number>(0)\n const selectRef = useRef<HTMLDivElement>(null)\n const selectElementRef = useRef<HTMLSelectElement>(null)\n const [searchValue, setSearchValue] = useState<string>('')\n const activeOptionRef = useRef<HTMLLIElement | null>(null)\n\n const filteredOptions = autocomplete || fullScreenOptions\n ? options.filter((option) =>\n option.label.toLowerCase().includes(searchValue.toLowerCase()),\n )\n : options\n\n useEffect(() => {\n if (initialValue) {\n const option = options.find((option) => option.value === initialValue)\n if (option) {\n setSelectedOption({ value: option.value, label: option.label })\n }\n }\n }, [initialValue, options])\n\n useEffect(() => {\n if (register && selectElementRef.current) {\n register(selectElementRef.current)\n }\n }, [register])\n\n useEffect(() => {\n if (activeOptionRef.current) {\n activeOptionRef.current.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n })\n }\n }, [activeOptionIndex])\n\n useEffect(() => {\n const handleClickOutside = (event: PointerEvent) => {\n const isClickedOutside =\n selectRef.current &&\n !selectRef.current.contains(event.target as Node) &&\n activeOptionRef.current\n\n if (isClickedOutside) {\n setIsDropdownOpen(false)\n }\n }\n\n if (isDropdownOpen) {\n document.addEventListener('pointerup', handleClickOutside)\n } else {\n document.removeEventListener('pointerup', handleClickOutside)\n }\n\n return () => {\n document.removeEventListener('pointerup', handleClickOutside)\n }\n }, [isDropdownOpen])\n\n const toggleDropdown = () => {\n if (!isDropdownOpen && selectRef.current) {\n const { bottom } = selectRef.current.getBoundingClientRect()\n let totalPadding = 0\n let parentElement: HTMLElement | null = selectRef.current.parentElement\n\n while (parentElement) {\n const parentPaddingBottom = parseFloat(\n window.getComputedStyle(parentElement).paddingBottom || '0',\n )\n totalPadding += parentPaddingBottom\n parentElement = parentElement.parentElement\n }\n\n const availableSpaceBelow = window.innerHeight - bottom - totalPadding\n const minDropdownHeight = 212\n const calculatedHeight = Math.max(availableSpaceBelow, minDropdownHeight)\n\n setDropdownMaxHeight(calculatedHeight)\n }\n\n setIsDropdownOpen((prev) => {\n if (!prev) {\n const selectedIndex = options.findIndex(\n (option) => option.value === selectedOption.value,\n )\n setActiveOptionIndex(selectedIndex !== -1 ? selectedIndex : null)\n }\n return !prev\n })\n }\n\n const _findNextAvailableIndex = (\n currentIndex: number,\n direction: 'down' | 'up',\n ) => {\n const step = direction === 'down' ? 1 : -1\n let nextIndex =\n (currentIndex + step + filteredOptions.length) % filteredOptions.length\n\n while (filteredOptions[nextIndex]?.disabled) {\n nextIndex =\n (nextIndex + step + filteredOptions.length) % filteredOptions.length\n }\n\n return nextIndex\n }\n\n const onKeyDownDropdown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return\n\n const _actions: Record<string, () => void> = {\n Enter: () => {\n if (!isDropdownOpen) {\n toggleDropdown()\n return\n }\n if (\n activeOptionIndex !== null &&\n !filteredOptions[activeOptionIndex].disabled\n ) {\n e.preventDefault()\n selectOption(\n filteredOptions[activeOptionIndex].value,\n filteredOptions[activeOptionIndex].disabled,\n )\n }\n },\n ArrowDown: () => {\n e.preventDefault()\n setActiveOptionIndex((prev) =>\n _findNextAvailableIndex(prev !== null ? prev : -1, 'down'),\n )\n if (!isDropdownOpen) toggleDropdown()\n },\n ArrowUp: () => {\n e.preventDefault()\n setActiveOptionIndex((prev) =>\n _findNextAvailableIndex(\n prev !== null ? prev : filteredOptions.length,\n 'up',\n ),\n )\n if (!isDropdownOpen) toggleDropdown()\n },\n Escape: () => {\n setIsDropdownOpen(false)\n },\n }\n\n if (_actions[e.key]) {\n _actions[e.key]()\n }\n }\n\n const selectOption = (optionValue: string, optionDisabled?: boolean) => {\n if (optionDisabled) return\n\n const option = options.find((option) => option.value === optionValue)\n if (option) {\n setSelectedOption({ value: option.value, label: option.label })\n }\n\n setActiveOptionIndex(null)\n setSearchValue('')\n setTimeout(() => setIsDropdownOpen(false), 500)\n\n if (onChange) {\n onChange(optionValue)\n }\n }\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const value = e.target.value\n setSearchValue(value)\n\n if (onChange) {\n onChange(value)\n }\n\n if (value === '') {\n setSelectedOption({ value: '', label: '' })\n }\n\n if (!isDropdownOpen) {\n setIsDropdownOpen(true)\n }\n }\n\n const handleOnBlur = (event?: React.FocusEvent<Element>) => {\n if (onBlur) {\n setTimeout(() => {\n const getOptionByLabel = (label: string) =>\n options.find((option) => option.label === label)\n\n const elementValue = (event?.target as HTMLInputElement).value\n const selectedOptionFromElement = getOptionByLabel(elementValue)\n\n const targetValue = selectedOption?.value\n ? selectedOption\n : selectedOptionFromElement || { value: elementValue, label: '' }\n\n onBlur({\n ...event,\n target: targetValue,\n } as React.FocusEvent<Element> & {\n target: OptionProps\n })\n }, 200)\n }\n }\n\n const onCloseOptions = () => {\n setIsDropdownOpen(false)\n }\n\n return {\n isDropdownOpen,\n selectRef,\n activeOptionRef,\n selectElementRef,\n toggleDropdown,\n selectOption,\n onKeyDownDropdown,\n setActiveOptionIndex,\n activeOptionIndex,\n filteredOptions,\n searchValue,\n setSearchValue,\n handleInputChange,\n dropdownMaxHeight,\n selectedOption,\n setSelectedOption,\n handleOnBlur,\n onCloseOptions,\n }\n}\n","import { createPortal } from 'react-dom'\nimport classNames from 'classnames'\nimport {\n IconChevronDown,\n IconSlash,\n IconCheck,\n IconSearch,\n} from '@components/icons'\nimport { Modal } from '@components/Modal'\nimport { Text } from '@components/Text'\nimport { Conditional } from '@components/misc'\nimport { COLOR_NEUTRAL_40 } from '@core/tokens'\n\nimport Field from '../Field'\nimport { OptionProps, SelectFieldProps } from './types'\nimport { useSelectField } from './hook'\nimport './styles.scss'\n\nexport const SelectField = ({\n label,\n options,\n showOptionalLabel,\n error,\n errorMessage,\n helpMessage,\n disabled,\n required,\n value,\n onChange,\n style,\n className,\n placeholder,\n name,\n register,\n onBlur,\n autocomplete = false,\n EmptyText = 'Nada encontrado',\n fullScreenOptions = false,\n}: SelectFieldProps) => {\n const {\n isDropdownOpen,\n selectRef,\n selectElementRef,\n activeOptionRef,\n toggleDropdown,\n selectOption,\n onKeyDownDropdown,\n setActiveOptionIndex,\n activeOptionIndex,\n filteredOptions,\n searchValue,\n selectedOption,\n handleInputChange,\n dropdownMaxHeight,\n handleOnBlur,\n onCloseOptions\n } = useSelectField(\n options,\n value,\n onChange,\n onBlur,\n disabled,\n register,\n autocomplete,\n fullScreenOptions,\n )\n\n const selectClasses = classNames('au-field__select', {\n 'au-field__select--disabled': disabled,\n 'au-field__select--open': isDropdownOpen,\n 'au-field__select--required': required,\n 'au-field__select--error': error,\n [className!]: className,\n })\n\n const optionsClasses = classNames('au-field__select-options', {\n 'au-field__select-options--open': isDropdownOpen,\n })\n\n const optionClasses = (option: OptionProps, index: number) =>\n classNames('au-field__select-option', {\n 'au-field__select-option--highlighted': activeOptionIndex === index,\n 'au-field__select-option--selected':\n option.value === selectedOption.value,\n 'au-field__select-option--disabled': option.disabled,\n })\n\n const fullScreenOptionClasses = (option: OptionProps, index: number) =>\n classNames('au-field__fullscreen-options-select-option', {\n 'au-field__fullscreen-options-select-option--highlighted':\n activeOptionIndex === index,\n 'au-field__fullscreen-options-select-option--selected':\n option.value === selectedOption.value,\n 'au-field__fullscreen-options-select-option--disabled': option.disabled,\n })\n\n return (\n <>\n <Field.Root\n style={style}\n customclass={className}\n error={error}\n disabled={disabled}>\n <Field.Label\n text={label}\n showOptionalLabel={showOptionalLabel}\n required={required}\n error={error}\n disabled={disabled}\n />\n <div className={selectClasses}>\n <div\n className=\"au-field__select-wrapper\"\n onClick={toggleDropdown}\n onKeyDown={onKeyDownDropdown}\n tabIndex={disabled ? -1 : 0}\n ref={selectRef}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={isDropdownOpen}\n aria-labelledby=\"select-label\"\n aria-activedescendant={\n activeOptionIndex !== null && filteredOptions[activeOptionIndex]\n ? filteredOptions[activeOptionIndex].value\n : undefined\n }\n onBlur={handleOnBlur}>\n <input\n className=\"au-field__select-input\"\n value={searchValue || selectedOption.label}\n placeholder={placeholder || 'Selecionar...'}\n onChange={handleInputChange}\n readOnly={!autocomplete}\n disabled={disabled}\n />\n <div className=\"au-field__select-icon\">\n <IconChevronDown />\n </div>\n </div>\n <Conditional\n condition={!fullScreenOptions}\n renderIf={\n <ul\n className={optionsClasses}\n role=\"listbox\"\n aria-live=\"polite\"\n tabIndex={-1}\n style={{\n maxHeight: `${dropdownMaxHeight}px`,\n overflowY: 'auto',\n }}>\n {filteredOptions.length === 0 ? (\n <li className=\"au-field__select-option au-field__select-option--empty\">\n {EmptyText}\n </li>\n ) : (\n filteredOptions.map((option, index) => (\n <li\n key={index}\n className={optionClasses(option, index)}\n ref={activeOptionIndex === index ? activeOptionRef : null}\n role=\"option\"\n aria-selected={option.value === selectedOption.value}\n aria-disabled={option.disabled}\n onPointerUp={() =>\n selectOption(option.value, option.disabled)\n }\n onMouseEnter={() => setActiveOptionIndex(index)}>\n {option.label}\n {option.disabled ? (\n <IconSlash />\n ) : option.value === selectedOption.value ? (\n <IconCheck />\n ) : null}\n </li>\n ))\n )}\n </ul>\n }\n />\n\n <select\n hidden\n disabled={disabled}\n value={selectedOption.value}\n onChange={(e) => selectOption(e.target.value)}\n ref={selectElementRef}\n name={name}>\n {options.map((option, index) => (\n <option key={index} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n <Field.Message\n hasError={!!error}\n errorMessage={errorMessage}\n helpMessage={helpMessage}\n />\n </Field.Root>\n\n <Conditional\n condition={fullScreenOptions}\n renderIf={\n <>\n {createPortal(\n <Modal\n isOpen={isDropdownOpen}\n onClose={onCloseOptions}\n headerContent={\n <div>\n <Text as=\"label\" variant=\"heading-small\" weight=\"bold\">\n {label}\n </Text>\n <div\n className=\"au-field__fullscreen-options-select-search-bar\"\n onKeyDown={onKeyDownDropdown}\n tabIndex={disabled ? -1 : 0}\n ref={selectRef}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={isDropdownOpen}\n aria-labelledby=\"select-label\"\n aria-activedescendant={\n activeOptionIndex !== null &&\n filteredOptions[activeOptionIndex]\n ? filteredOptions[activeOptionIndex].value\n : undefined\n }\n onBlur={handleOnBlur}>\n <input\n className=\"au-field__select-input\"\n value={searchValue || selectedOption.label}\n placeholder={'Buscar'}\n onChange={handleInputChange}\n disabled={disabled}\n />\n <div className=\"au-field__select-icon\">\n <IconSearch rawColor={COLOR_NEUTRAL_40} />\n </div>\n </div>\n </div>\n }\n content={\n <div className=\"au-field__fullscreen-options-select-options\">\n {filteredOptions.map((option, index) => (\n <li\n key={index}\n className={fullScreenOptionClasses(option, index)}\n ref={\n activeOptionIndex === index ? activeOptionRef : null\n }\n role=\"option\"\n aria-selected={option.value === selectedOption.value}\n aria-disabled={option.disabled}\n onPointerUp={() =>\n selectOption(option.value, option.disabled)\n }\n onMouseEnter={() => setActiveOptionIndex(index)}>\n {option.label}\n {option.disabled ? (\n <IconSlash />\n ) : option.value === selectedOption.value ? (\n <IconCheck />\n ) : null}\n </li>\n ))}\n </div>\n }\n />,\n document.body,\n )}\n </>\n }\n />\n </>\n )\n}\n"],"names":["option","_a"],"mappings":";;;;;;;;;;;;;;AAGa,MAAA,iBAAiB,CAC5B,SACA,cACA,UACA,QACA,UACA,UACA,eAAwB,OACxB,oBAA6B,UAC1B;;AACH,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAC1D,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAsB;AAAA,IAChE,OAAO,gBAAgB;AAAA,IACvB,OAAO,iBACH,aAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,YAAY,MAAtD,mBAAyD,UAAS,KAClE;AAAA,EAAA,CACL;AACK,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD;AAAA,EAAA;AAEF,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAiB,CAAC;AAC9D,QAAA,YAAY,OAAuB,IAAI;AACvC,QAAA,mBAAmB,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