@consumidor-positivo/aurora 0.0.86 → 0.0.88

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.
@@ -5,8 +5,8 @@ import { IconAlertOctagon } from "../icons/IconAlertOctagon/index.es.js";
5
5
  import { IconAlertTriangle } from "../icons/IconAlertTriangle/index.es.js";
6
6
  import { IconCheck } from "../icons/IconCheck/index.es.js";
7
7
  import { IconInfo } from "../icons/IconInfo/index.es.js";
8
+ import { C as COLOR_SUCCESS_50, a as COLOR_ERROR_50, V as COLOR_WARNING_50, a0 as COLOR_INFO_50 } from "../../tokens-DEqeZ57l.js";
8
9
  import { Conditional } from "../Conditional/index.es.js";
9
- import { C as COLOR_SUCCESS_50, a as COLOR_ERROR_50, V as COLOR_WARNING_50, a0 as COLOR_INFO_50 } from "../../tokens-DGTtjw-_.js";
10
10
  import './styles.css';const Alert = ({
11
11
  status = "info",
12
12
  type = 1,
@@ -1,9 +1,9 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../index-CweZ_OcN.js";
3
- import "../../index-C8RdzVRj.js";
3
+ import "../../index-C63hcch2.js";
4
4
  import "../Button/index.es.js";
5
5
  import "../PortalHolder/index.es.js";
6
- import { a } from "../../index-CK85YRoz.js";
6
+ import { a } from "../../index-h_Ql1Vzn.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-CP-KKFUb.js";
7
- import { C } from "../../index-C8RdzVRj.js";
6
+ import "../../index--3ScUApr.js";
7
+ import { C } from "../../index-C63hcch2.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 { m as COLOR_NEUTRAL_00 } from "../../tokens-DEqeZ57l.js";
6
7
  import { F as Field } from "../../index-DfksciAR.js";
7
- import { m as COLOR_NEUTRAL_00 } from "../../tokens-DGTtjw-_.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, b as COLOR_NEUTRAL_40 } from "../../tokens-DEqeZ57l.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-CK85YRoz.js";
7
+ import { g as getDefaultDate, D as DDMMYYYY, a as DatepickerCalendar, A as AUCalendarDate } from "../../index-h_Ql1Vzn.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-CP-KKFUb.js";
10
- import { B as BREAKPOINT_MD, b as COLOR_NEUTRAL_40 } from "../../tokens-DGTtjw-_.js";
10
+ import { u as useOutsideClick } from "../../index--3ScUApr.js";
11
11
  import './styles.css';function useDatepicker({
12
12
  value,
13
13
  defaultValue = "empty",
@@ -1 +1 @@
1
- .au-footer{background-color:#fff;border-top:1px solid #e2e4e9;padding-block:48px}@media (min-width: 1024px){.au-footer{padding-block:64px}}.au-footer__container{width:100%;max-width:1240px;margin:0 auto;padding:0 24px}@media (min-width: 1024px){.au-footer__container{padding:0 16px}}.au-footer__container{display:flex;flex-direction:column;gap:48px}.au-footer__top{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #e2e4e9;padding-bottom:40px}@media (min-width: 1024px){.au-footer__top{padding-bottom:48px}}.au-footer__top-logos{display:flex;gap:24px;align-items:center}.au-footer__top-divider{display:none}@media (min-width: 1024px){.au-footer__top-divider{display:block;width:1px;height:60px;background-color:#e2e4e9}}.au-footer__top-certificates{display:none}@media (min-width: 1024px){.au-footer__top-certificates{display:flex;flex-wrap:wrap;align-items:center;gap:33px;margin-right:8px}}.au-footer__top-social{display:none}@media (min-width: 1024px){.au-footer__top-social{display:flex;flex-direction:column;gap:16px}}.au-footer__top-social-links{display:none}@media (min-width: 1024px){.au-footer__top-social-links{display:flex;align-items:center;gap:16px}.au-footer__top-social-links svg{cursor:pointer}.au-footer__top-social-links svg:hover{opacity:.7}}.au-footer__content{display:flex;flex-direction:column;gap:32px;border-bottom:1px solid #e2e4e9;padding-bottom:48px}@media (min-width: 1024px){.au-footer__content{display:none}}.au-footer__content-certificates{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:32px 0px}@media (min-width: 1024px){.au-footer__content-certificates{display:none}}.au-footer__content-notes{display:flex}@media (min-width: 1024px){.au-footer__content-notes{display:none}}.au-footer__content-social{display:flex;flex-direction:column;gap:16px}@media (min-width: 1024px){.au-footer__content-social{display:none}}.au-footer__content-social-links{display:flex;align-items:center;gap:16px}.au-footer__content-social-links svg{cursor:pointer}.au-footer__content-social-links svg:hover{opacity:.7}.au-footer__bottom{display:flex;align-items:center;justify-content:center;text-align:center}.au-footer-full{background-color:#fff;border-top:1px solid #e2e4e9;padding-block:48px}@media (min-width: 1024px){.au-footer-full{padding-block:64px}}.au-footer-full__container{width:100%;max-width:1240px;margin:0 auto;padding:0 24px}@media (min-width: 1024px){.au-footer-full__container{padding:0 16px}}.au-footer-full__container{gap:48px;display:flex;flex-direction:column}.au-footer-full__logo{display:flex;align-items:center}.au-footer-full__links{display:flex;flex-direction:column;gap:32px}@media (min-width: 1024px){.au-footer-full__links{flex-direction:row;justify-content:space-between}}.au-footer-full__links--is-clickable{cursor:pointer}.au-footer-full__links--is-clickable:hover{opacity:.6}.au-footer-full__links-category{max-width:272px;display:flex;flex-direction:column;gap:16px}.au-footer-full__links-socials{display:flex;align-items:center;gap:16px}.au-footer-full__bottom{display:flex;flex-direction:column;justify-content:space-between;align-items:center;border-top:1px solid #e2e4e9;padding-top:40px;gap:48px}@media (min-width: 1024px){.au-footer-full__bottom{flex-direction:row;padding-top:48px}}.au-footer-full__bottom-certificates{display:flex;align-items:center;flex-direction:row;width:100%;justify-content:space-between;flex-wrap:wrap;gap:32px 0px}@media (min-width: 1024px){.au-footer-full__bottom-certificates{justify-content:start;flex-wrap:nowrap;gap:32px}}.au-footer-full__bottom-side{display:flex;width:100%;flex-direction:column;align-items:center;border-top:1px solid #e2e4e9;text-align:center}@media (min-width: 1024px){.au-footer-full__bottom-side{border-top:0;text-align:right;align-items:flex-end}}.au-footer-full__stores{display:flex;gap:13px;padding-top:48px}@media (min-width: 1024px){.au-footer-full__stores{gap:16px;padding-top:0}}.au-footer-full__stores-logo{cursor:pointer;width:129px}@media (min-width: 1024px){.au-footer-full__stores-logo{width:117px}}.au-footer-full__stores-logo--is-clickable{cursor:pointer}.au-footer-full__stores-logo--is-clickable:hover{opacity:.6}.au-footer-full__copyrights{padding-top:48px}@media (min-width: 1024px){.au-footer-full__copyrights{padding-top:16px}}
1
+ .au-footer{background-color:#fff;border-top:1px solid #e2e4e9;padding-block:48px}@media (min-width: 1024px){.au-footer{padding-block:64px}}.au-footer__container{width:100%;max-width:1232px;margin:0 auto;padding:0 24px}@media (min-width: 1024px){.au-footer__container{padding:0 16px}}.au-footer__container{display:flex;flex-direction:column;gap:48px}.au-footer__top{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #e2e4e9;padding-bottom:40px}@media (min-width: 1024px){.au-footer__top{padding-bottom:48px}}.au-footer__top-logos{display:flex;gap:24px;align-items:center}.au-footer__top-divider{display:none}@media (min-width: 1024px){.au-footer__top-divider{display:block;width:1px;height:60px;background-color:#e2e4e9}}.au-footer__top-certificates{display:none}@media (min-width: 1024px){.au-footer__top-certificates{display:flex;flex-wrap:wrap;align-items:center;gap:33px;margin-right:8px}}.au-footer__top-social{display:none}@media (min-width: 1024px){.au-footer__top-social{display:flex;flex-direction:column;gap:16px}}.au-footer__top-social-links{display:none}@media (min-width: 1024px){.au-footer__top-social-links{display:flex;align-items:center;gap:16px}.au-footer__top-social-links svg{cursor:pointer}.au-footer__top-social-links svg:hover{opacity:.7}}.au-footer__content{display:flex;flex-direction:column;gap:32px;border-bottom:1px solid #e2e4e9;padding-bottom:48px}@media (min-width: 1024px){.au-footer__content{display:none}}.au-footer__content-certificates{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:32px 0px}@media (min-width: 1024px){.au-footer__content-certificates{display:none}}.au-footer__content-notes{display:flex}@media (min-width: 1024px){.au-footer__content-notes{display:none}}.au-footer__content-social{display:flex;flex-direction:column;gap:16px}@media (min-width: 1024px){.au-footer__content-social{display:none}}.au-footer__content-social-links{display:flex;align-items:center;gap:16px}.au-footer__content-social-links svg{cursor:pointer}.au-footer__content-social-links svg:hover{opacity:.7}.au-footer__bottom{display:flex;align-items:center;justify-content:center;text-align:center}.au-footer-full{background-color:#fff;border-top:1px solid #e2e4e9;padding-block:48px}@media (min-width: 1024px){.au-footer-full{padding-block:64px}}.au-footer-full__container{width:100%;max-width:1232px;margin:0 auto;padding:0 24px}@media (min-width: 1024px){.au-footer-full__container{padding:0 16px}}.au-footer-full__container{gap:48px;display:flex;flex-direction:column}.au-footer-full__logo{display:flex;align-items:center}.au-footer-full__links{display:flex;flex-direction:column;gap:32px}@media (min-width: 1024px){.au-footer-full__links{flex-direction:row;justify-content:space-between}}.au-footer-full__links--is-clickable{cursor:pointer}.au-footer-full__links--is-clickable:hover{opacity:.6}.au-footer-full__links-category{max-width:272px;display:flex;flex-direction:column;gap:16px}.au-footer-full__links-socials{display:flex;align-items:center;gap:16px}.au-footer-full__bottom{display:flex;flex-direction:column;justify-content:space-between;align-items:center;border-top:1px solid #e2e4e9;padding-top:40px;gap:48px}@media (min-width: 1024px){.au-footer-full__bottom{flex-direction:row;padding-top:48px}}.au-footer-full__bottom-certificates{display:flex;align-items:center;flex-direction:row;width:100%;justify-content:space-between;flex-wrap:wrap;gap:32px 0px}@media (min-width: 1024px){.au-footer-full__bottom-certificates{justify-content:start;flex-wrap:nowrap;gap:32px}}.au-footer-full__bottom-side{display:flex;width:100%;flex-direction:column;align-items:center;border-top:1px solid #e2e4e9;text-align:center}@media (min-width: 1024px){.au-footer-full__bottom-side{border-top:0;text-align:right;align-items:flex-end}}.au-footer-full__stores{display:flex;gap:13px;padding-top:48px}@media (min-width: 1024px){.au-footer-full__stores{gap:16px;padding-top:0}}.au-footer-full__stores-logo{cursor:pointer;width:129px}@media (min-width: 1024px){.au-footer-full__stores-logo{width:117px}}.au-footer-full__stores-logo--is-clickable{cursor:pointer}.au-footer-full__stores-logo--is-clickable:hover{opacity:.6}.au-footer-full__copyrights{padding-top:48px}@media (min-width: 1024px){.au-footer-full__copyrights{padding-top:16px}}
@@ -1 +1 @@
1
- .au-header{height:80px;padding:16px 0;border-bottom:1px solid #e2e4e9;background-color:#fff}.au-header--fixed{position:fixed;top:0;left:0;width:100%;z-index:5}.au-header--static{position:relative}.au-header__container{width:100%;max-width:1240px;margin:0 auto;padding:0 24px}@media (min-width: 1024px){.au-header__container{padding:0 16px}}.au-header__container{height:100%;display:flex;justify-content:space-between;align-items:center;gap:16px}.au-header__logo{display:flex;align-items:center}.au-header__logo .au-text{padding-left:16px;margin-left:16px;border-left:1px solid #e2e4e9}.au-header__logo--mobile{display:block}@media (min-width: 1024px){.au-header__logo--mobile{display:none}}.au-header__logo--desktop{display:none}@media (min-width: 1024px){.au-header__logo--desktop{display:block}}.au-header__link,.au-header__button{cursor:pointer}.au-header__badges{display:flex;align-items:center}.au-header__badges>*+*{padding-left:16px;margin-left:16px;position:relative}.au-header__badges>*+*:before{content:"";height:24px;width:1px;background-color:#e2e4e9;position:absolute;left:0;top:calc(50% - 12px)}.au-header__badges .au-logo{max-width:56px}.au-header__badges .au-logo img{width:100%}.au-header__navigation{display:flex}.au-header__navigation>*+*{margin-left:24px}.au-header__navbar{color:#16181d;display:none}@media (min-width: 1024px){.au-header__navbar{display:flex;align-items:center;gap:40px}}.au-header__navbar-link{cursor:pointer;text-decoration:none}.au-header__navbar-link--is-dropdown{position:relative;display:flex;align-items:center;justify-content:center;gap:8px}.au-header__navbar-link--is-dropdown>.au-icon{transition:transform .3s ease}.au-header__navbar-link--is-dropdown:hover>.au-icon,.au-header__navbar-link--is-dropdown:focus>.au-icon{transform:rotate(-180deg)}.au-header__navbar-link--is-dropdown:hover .au-header__dropdown,.au-header__navbar-link--is-dropdown:focus .au-header__dropdown{opacity:1;visibility:visible;transform:translateY(10px)}.au-header__navbar-link--is-active,.au-header__navbar-link:hover,.au-header__navbar-link:focus{font-weight:700;letter-spacing:-.6px}.au-header__navbar-link:hover,.au-header__navbar-link:focus{color:#16181d}.au-header__navbar-link--is-active{color:#0048db}.au-header__navbar-link--is-active:hover,.au-header__navbar-link--is-active:focus{color:#0048db}.au-header__dropdown{background-color:#fff;border-radius:16px;border:1px solid #e2e4e9;box-shadow:0 2px 8px #a9b1c514,0 4px 4px #0048db0a;max-width:230px;min-width:230px;position:absolute;z-index:2;top:100%;width:100%;left:0;opacity:.2;visibility:hidden;transition:opacity .3s ease,transform .2s linear,visibility .3s ease;transform:translateY(20px)}.au-header__dropdown-link{display:inline-block;padding:16px 24px;width:100%;display:flex;text-decoration:none;justify-content:space-between}.au-header__dropdown-link--is-active,.au-header__dropdown-link:hover,.au-header__dropdown-link:focus{font-weight:700;letter-spacing:-.6px}.au-header__dropdown-link--is-active{color:#0048db;background-color:#fafbff;border-top:1px solid #e2e4e9}.au-header__actions{display:flex;align-items:center;gap:16px}@media (min-width: 1024px){.au-header__actions--divider{border-left:1px solid #e2e4e9;padding-left:24px;margin-left:24px}}.au-header__profile{display:flex;align-items:center;gap:32px}.au-header__profile-notifications{cursor:pointer}.au-header__profile-menu{display:none;align-items:center;gap:8px;cursor:pointer}@media (min-width: 1024px){.au-header__profile-menu{display:flex}}.au-header__profile-menu-mobile{display:block;cursor:pointer}@media (min-width: 1024px){.au-header__profile-menu-mobile{display:none}}.au-header__profile-letters{display:flex;align-items:center;justify-content:center;border-radius:50%;width:40px;height:40px;background-color:#9abcff;font-weight:500;font-family:Lexend Deca,sans-serif;color:#16181d;font-size:16px;text-transform:uppercase}.au-header__hamburger{cursor:pointer}@media (min-width: 1024px){.au-header__hamburger{display:none}}
1
+ .au-header{height:80px;padding:16px 0;border-bottom:1px solid #e2e4e9;background-color:#fff}.au-header--fixed{position:fixed;top:0;left:0;width:100%;z-index:5}.au-header--static{position:relative}.au-header__container{width:100%;max-width:1232px;margin:0 auto;padding:0 24px}@media (min-width: 1024px){.au-header__container{padding:0 16px}}.au-header__container{height:100%;display:flex;justify-content:space-between;align-items:center;gap:16px}.au-header__logo{display:flex;align-items:center}.au-header__logo .au-text{padding-left:16px;margin-left:16px;border-left:1px solid #e2e4e9}.au-header__logo--mobile{display:block}@media (min-width: 1024px){.au-header__logo--mobile{display:none}}.au-header__logo--desktop{display:none}@media (min-width: 1024px){.au-header__logo--desktop{display:block}}.au-header__link,.au-header__button{cursor:pointer}.au-header__badges{display:flex;align-items:center}.au-header__badges>*+*{padding-left:16px;margin-left:16px;position:relative}.au-header__badges>*+*:before{content:"";height:24px;width:1px;background-color:#e2e4e9;position:absolute;left:0;top:calc(50% - 12px)}.au-header__badges .au-logo{max-width:56px}.au-header__badges .au-logo img{width:100%}.au-header__navigation{display:flex}.au-header__navigation>*+*{margin-left:24px}.au-header__navbar{color:#16181d;display:none}@media (min-width: 1024px){.au-header__navbar{display:flex;align-items:center;gap:40px}}.au-header__navbar-link{cursor:pointer;text-decoration:none}.au-header__navbar-link--is-dropdown{position:relative;display:flex;align-items:center;justify-content:center;gap:8px}.au-header__navbar-link--is-dropdown>.au-icon{transition:transform .3s ease}.au-header__navbar-link--is-dropdown:hover>.au-icon,.au-header__navbar-link--is-dropdown:focus>.au-icon{transform:rotate(-180deg)}.au-header__navbar-link--is-dropdown:hover .au-header__dropdown,.au-header__navbar-link--is-dropdown:focus .au-header__dropdown{opacity:1;visibility:visible;transform:translateY(10px)}.au-header__navbar-link--is-active,.au-header__navbar-link:hover,.au-header__navbar-link:focus{font-weight:700;letter-spacing:-.6px}.au-header__navbar-link:hover,.au-header__navbar-link:focus{color:#16181d}.au-header__navbar-link--is-active{color:#0048db}.au-header__navbar-link--is-active:hover,.au-header__navbar-link--is-active:focus{color:#0048db}.au-header__dropdown{background-color:#fff;border-radius:16px;border:1px solid #e2e4e9;box-shadow:0 2px 8px #a9b1c514,0 4px 4px #0048db0a;max-width:230px;min-width:230px;position:absolute;z-index:2;top:100%;width:100%;left:0;opacity:.2;visibility:hidden;transition:opacity .3s ease,transform .2s linear,visibility .3s ease;transform:translateY(20px)}.au-header__dropdown-link{display:inline-block;padding:16px 24px;width:100%;display:flex;text-decoration:none;justify-content:space-between}.au-header__dropdown-link--is-active,.au-header__dropdown-link:hover,.au-header__dropdown-link:focus{font-weight:700;letter-spacing:-.6px}.au-header__dropdown-link--is-active{color:#0048db;background-color:#fafbff;border-top:1px solid #e2e4e9}.au-header__actions{display:flex;align-items:center;gap:16px}@media (min-width: 1024px){.au-header__actions--divider{border-left:1px solid #e2e4e9;padding-left:24px;margin-left:24px}}.au-header__profile{display:flex;align-items:center;gap:32px}.au-header__profile-notifications{cursor:pointer}.au-header__profile-menu{display:none;align-items:center;gap:8px;cursor:pointer}@media (min-width: 1024px){.au-header__profile-menu{display:flex}}.au-header__profile-menu-mobile{display:block;cursor:pointer}@media (min-width: 1024px){.au-header__profile-menu-mobile{display:none}}.au-header__profile-letters{display:flex;align-items:center;justify-content:center;border-radius:50%;width:40px;height:40px;background-color:#9abcff;font-weight:500;font-family:Lexend Deca,sans-serif;color:#16181d;font-size:16px;text-transform:uppercase}.au-header__hamburger{cursor:pointer}@media (min-width: 1024px){.au-header__hamburger{display:none}}
@@ -4,7 +4,7 @@ import "../Icon/index.es.js";
4
4
  import { IconAlertOctagon } from "../icons/IconAlertOctagon/index.es.js";
5
5
  import { IconCheck } from "../icons/IconCheck/index.es.js";
6
6
  import { IconSlash } from "../icons/IconSlash/index.es.js";
7
- import { C as COLOR_SUCCESS_50, a as COLOR_ERROR_50, b as COLOR_NEUTRAL_40 } from "../../tokens-DGTtjw-_.js";
7
+ import { C as COLOR_SUCCESS_50, a as COLOR_ERROR_50, b as COLOR_NEUTRAL_40 } from "../../tokens-DEqeZ57l.js";
8
8
  const FieldLabel = ({
9
9
  id,
10
10
  text,
@@ -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 { B as BREAKPOINT_MD } from "../../tokens-DEqeZ57l.js";
3
4
  import { Portal } from "../Portal/index.es.js";
4
- import { B as BREAKPOINT_MD } from "../../tokens-DGTtjw-_.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-CP-KKFUb.js";
7
+ import { S } from "../../index--3ScUApr.js";
8
8
  export {
9
9
  S as Segment
10
10
  };
@@ -292,7 +292,7 @@ const SelectField = ({
292
292
  role: "option",
293
293
  "aria-selected": option.value === selectedOption.value,
294
294
  "aria-disabled": option.disabled,
295
- onClick: () => selectOption(option.value, option.disabled),
295
+ onPointerUp: () => selectOption(option.value, option.disabled),
296
296
  onMouseEnter: () => setActiveOptionIndex(index),
297
297
  children: [
298
298
  option.label,
@@ -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 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 (value === '') {\n setSelectedOption({ value: '', label: '' })\n }\n\n if (!isDropdownOpen) {\n setIsDropdownOpen(true)\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 }\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 optional,\n error,\n errorMessage,\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 } = useSelectField(options, value, onChange, disabled, register, autocomplete)\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 optional={optional}\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={onBlur}>\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 onClick={() => 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 onBlur={onBlur}>\n {options.map((option, index) => (\n <option key={index} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n <Field.ErrorMessage hasError={!!error} message={errorMessage} />\n </Field.Root>\n )\n}\n"],"names":["option","_a"],"mappings":";;;;;;;;AAGa,MAAA,iBAAiB,CAC5B,SACA,cACA,UACA,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,YAAU,MAAM;AACd,QAAI,cAAc;AAChB,YAAM,SAAS,QAAQ,KAAK,CAACA,YAAWA,QAAO,UAAU,YAAY;AACrE,UAAI,QAAQ;AACV,0BAAkB,EAAE,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;AAAA,MAChE;AAAA,IACF;AAAA,EAAA,GACC,CAAC,cAAc,OAAO,CAAC;AAE1B,YAAU,MAAM;AACV,QAAA,YAAY,iBAAiB,SAAS;AACxC,eAAS,iBAAiB,OAAO;AAAA,IACnC;AAAA,EA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","../../../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 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 (value === '') {\n setSelectedOption({ value: '', label: '' })\n }\n\n if (!isDropdownOpen) {\n setIsDropdownOpen(true)\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 }\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 optional,\n error,\n errorMessage,\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 } = useSelectField(options, value, onChange, disabled, register, autocomplete)\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 optional={optional}\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={onBlur}>\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 onBlur={onBlur}>\n {options.map((option, index) => (\n <option key={index} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n <Field.ErrorMessage hasError={!!error} message={errorMessage} />\n </Field.Root>\n )\n}\n"],"names":["option","_a"],"mappings":";;;;;;;;AAGa,MAAA,iBAAiB,CAC5B,SACA,cACA,UACA,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,YAAU,MAAM;AACd,QAAI,cAAc;AAChB,YAAM,SAAS,QAAQ,KAAK,CAACA,YAAWA,QAAO,UAAU,YAAY;AACrE,UAAI,QAAQ;AACV,0BAAkB,EAAE,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;AAAA,MAChE;AAAA,IACF;AAAA,EAAA,GACC,CAAC,cAAc,OAAO,CAAC;AAE1B,YAAU,MAAM;AACV,QAAA,YAAY,iBAAiB,SAAS;AACxC,eAAS,iBAAiB,OAAO;AAAA,IACn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px";
72
72
  export declare const BREAKPOINT_MD = "600px";
73
73
  export declare const BREAKPOINT_LG = "1024px";
74
74
  export declare const BREAKPOINT_XLG = "1920px";
75
- export declare const CONTAINER_SIZE = "1240px";
75
+ export declare const CONTAINER_SIZE = "1232px";
76
76
  export declare const OPACITY_00 = "0.05";
77
77
  export declare const OPACITY_10 = "0.2";
78
78
  export declare const OPACITY_20 = "0.4";
@@ -5,8 +5,8 @@ import { IconChevronDown } from "./components/icons/IconChevronDown/index.es.js"
5
5
  import { IconChevronLeft } from "./components/icons/IconChevronLeft/index.es.js";
6
6
  import { IconX } from "./components/icons/IconX/index.es.js";
7
7
  import { useState, useRef, useEffect } from "react";
8
+ import { B as BREAKPOINT_MD } from "./tokens-DEqeZ57l.js";
8
9
  import { a as above } from "./screen-DfYo7XQ_.js";
9
- import { B as BREAKPOINT_MD } from "./tokens-DGTtjw-_.js";
10
10
  import './components/index/styles3.css';function useOutsideClick({
11
11
  rootEl,
12
12
  breakpoint,
@@ -138,4 +138,4 @@ export {
138
138
  Segment as S,
139
139
  useOutsideClick as u
140
140
  };
141
- //# sourceMappingURL=index-CP-KKFUb.js.map
141
+ //# sourceMappingURL=index--3ScUApr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CP-KKFUb.js","sources":["../lib/core/hooks/useOutsideClick.ts","../lib/components/form/Datepicker/Segment/hook.ts","../lib/components/form/Datepicker/Segment/index.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { above } from '../utils/screen'\n\ntype UseOutsideClickProps = {\n rootEl: React.RefObject<HTMLDivElement>\n breakpoint?: string\n onLoseFocusCB: () => void\n}\n\nexport function useOutsideClick({\n rootEl,\n breakpoint,\n onLoseFocusCB,\n}: UseOutsideClickProps) {\n const [setupListener, setSetupListener] = useState(false)\n\n function listenOutsideClick() {\n if (breakpoint && !above(breakpoint)) return\n document.addEventListener('mousedown', handleLoseFocus)\n setSetupListener(true)\n }\n\n function clearOutsideClickListenner() {\n if (setupListener) {\n document.removeEventListener('mousedown', handleLoseFocus)\n setSetupListener(false)\n }\n }\n\n function handleLoseFocus(ev: MouseEvent | FocusEvent) {\n if (!rootEl.current) return\n\n const clickedOutside = !rootEl.current.contains(ev.target as Node)\n\n if (clickedOutside) {\n onLoseFocusCB()\n clearOutsideClickListenner()\n }\n }\n\n return {\n listenOutsideClick,\n }\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { BREAKPOINT_MD } from '@core/tokens'\nimport { useOutsideClick } from '@core/hooks/useOutsideClick'\n\nimport { SegmentItem } from '../types'\n\ntype UseSegmentProps = {\n options: SegmentItem[]\n currentValue: string | number\n onSelect: (option: SegmentItem) => void\n}\n\nexport function useSegment({\n options,\n currentValue,\n onSelect,\n}: UseSegmentProps) {\n const [isListOpen, setIsListOpen] = useState(false)\n const rootEl = useRef<HTMLDivElement>(null)\n const selectedItem = useRef<HTMLLIElement>(null)\n const currentItem = options.find((item) => item.value === currentValue)\n const { listenOutsideClick } = useOutsideClick({\n rootEl,\n breakpoint: BREAKPOINT_MD,\n onLoseFocusCB: closeList,\n })\n\n useEffect(() => {\n if (selectedItem.current && isListOpen) {\n selectedItem.current.scrollIntoView({ block: 'center', inline: 'center' })\n }\n }, [isListOpen])\n\n function openList() {\n setIsListOpen(true)\n listenOutsideClick()\n }\n\n function closeList() {\n setIsListOpen(false)\n }\n\n function handleSelectItem(option: SegmentItem) {\n onSelect(option)\n setIsListOpen(false)\n }\n\n return {\n openList,\n closeList,\n isListOpen,\n rootEl,\n currentItem,\n handleSelectItem,\n selectedItem,\n }\n}\n","import classNames from 'classnames'\nimport { IconChevronDown, IconChevronLeft, IconX } from '@components/icons'\n\nimport { useSegment } from './hook'\nimport { SegmentItem } from '../types'\nimport './styles.scss'\n\ntype SegmentProps = {\n mobileTitle: string\n options: SegmentItem[]\n onSelect: (option: SegmentItem) => void\n currentValue: string | number\n minValue?: Date\n maxValue?: Date\n}\n\nexport const Segment = ({\n currentValue,\n options,\n mobileTitle,\n onSelect,\n}: SegmentProps) => {\n const {\n rootEl,\n isListOpen,\n openList,\n closeList,\n currentItem,\n handleSelectItem,\n selectedItem,\n } = useSegment({\n options,\n currentValue,\n onSelect,\n })\n\n return (\n <div\n ref={rootEl}\n tabIndex={0}\n className={classNames('au-datepicker__segment', {\n 'au-datepicker__segment--open': isListOpen,\n })}>\n <div className=\"au-datepicker__segment-input\" onClick={openList}>\n {currentItem?.label}\n <IconChevronDown />\n </div>\n <div className=\"au-datepicker__segment-list-holder\">\n <div className=\"au-datepicker__segment-list-header\">\n <div onClick={closeList}>\n <IconChevronLeft />\n </div>\n <h4 className=\"au-datepicker__segment-title\">{mobileTitle}</h4>\n <div onClick={closeList}>\n <IconX />\n </div>\n </div>\n <ul className=\"au-datepicker__segment-list\">\n {options.map((option, idx) => {\n const isSelectedItem = option.value === currentValue\n return (\n <li\n key={`au-datepicker-segment-li-${option.value}-${idx}`}\n onClick={() => handleSelectItem(option)}\n ref={isSelectedItem ? selectedItem : null}\n className={classNames('au-datepicker__segment-list-item', {\n 'au-datepicker__segment-list-item--active': isSelectedItem,\n })}>\n {option.label}\n </li>\n )\n })}\n </ul>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;AASO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AAExD,WAAS,qBAAqB;AAC5B,QAAI,cAAc,CAAC,MAAM,UAAU,EAAG;AAC7B,aAAA,iBAAiB,aAAa,eAAe;AACtD,qBAAiB,IAAI;AAAA,EACvB;AAEA,WAAS,6BAA6B;AACpC,QAAI,eAAe;AACR,eAAA,oBAAoB,aAAa,eAAe;AACzD,uBAAiB,KAAK;AAAA,IACxB;AAAA,EACF;AAEA,WAAS,gBAAgB,IAA6B;AAChD,QAAA,CAAC,OAAO,QAAS;AAErB,UAAM,iBAAiB,CAAC,OAAO,QAAQ,SAAS,GAAG,MAAc;AAEjE,QAAI,gBAAg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AAA,MACD,UAAA;AAAA,QAAA,qBAAC,OAAI,EAAA,WAAU,gCAA+B,SAAS,UACpD,UAAA;AAAA,UAAa,2CAAA;AAAA,8BACb,iBAAgB,EAAA;AAAA,QAAA,GACnB;AAAA,QACA,qBAAC,OAAI,EAAA,WAAU,sCACb,UAAA;AAAA,UAAC,qBAAA,OAAA,EAAI,WAAU,sCACb,UAAA;AAAA,YAAA,oBAAC,OAAI,EAAA,SAAS,WACZ,UAAA,oBAAC,kBAAgB,CAAA,GACnB;AAAA,YACC,oBAAA,MAAA,EAAG,WAAU,gCAAgC,UAAY,aAAA;AAAA,gCACzD,OAAI,EAAA,SAAS,WACZ,UAAA,oBAAC,QAAM,CAAA,GACT;AAAA,UAAA,GACF;AAAA,UACA,oBAAC,QAAG,WAAU,+BACX,kBAAQ,IAAI,CAAC,QAAQ,QAAQ;AACtB,kBAAA,iBAAiB,OAAO,UAAU;AAEtC,mBAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,SAAS,MAAM,iBAAiB,MAAM;AAAA,gBACtC,KAAK,iBAAiB,eAAe;AAAA,gBACrC,WAAW,WAAW,oCAAoC;AAAA,kBACxD,4CAA4C;AAAA,gBAAA,CAC7C;AAAA,gBACA,UAAO,OAAA;AAAA,cAAA;AAAA,cANH,4BAA4B,OAAO,KAAK,IAAI,GAAG;AAAA,YAAA;AAAA,UASzD,CAAA,GACH;AAAA,QAAA,GACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"index--3ScUApr.js","sources":["../lib/core/hooks/useOutsideClick.ts","../lib/components/form/Datepicker/Segment/hook.ts","../lib/components/form/Datepicker/Segment/index.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { above } from '../utils/screen'\n\ntype UseOutsideClickProps = {\n rootEl: React.RefObject<HTMLDivElement>\n breakpoint?: string\n onLoseFocusCB: () => void\n}\n\nexport function useOutsideClick({\n rootEl,\n breakpoint,\n onLoseFocusCB,\n}: UseOutsideClickProps) {\n const [setupListener, setSetupListener] = useState(false)\n\n function listenOutsideClick() {\n if (breakpoint && !above(breakpoint)) return\n document.addEventListener('mousedown', handleLoseFocus)\n setSetupListener(true)\n }\n\n function clearOutsideClickListenner() {\n if (setupListener) {\n document.removeEventListener('mousedown', handleLoseFocus)\n setSetupListener(false)\n }\n }\n\n function handleLoseFocus(ev: MouseEvent | FocusEvent) {\n if (!rootEl.current) return\n\n const clickedOutside = !rootEl.current.contains(ev.target as Node)\n\n if (clickedOutside) {\n onLoseFocusCB()\n clearOutsideClickListenner()\n }\n }\n\n return {\n listenOutsideClick,\n }\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { BREAKPOINT_MD } from '@core/tokens'\nimport { useOutsideClick } from '@core/hooks/useOutsideClick'\n\nimport { SegmentItem } from '../types'\n\ntype UseSegmentProps = {\n options: SegmentItem[]\n currentValue: string | number\n onSelect: (option: SegmentItem) => void\n}\n\nexport function useSegment({\n options,\n currentValue,\n onSelect,\n}: UseSegmentProps) {\n const [isListOpen, setIsListOpen] = useState(false)\n const rootEl = useRef<HTMLDivElement>(null)\n const selectedItem = useRef<HTMLLIElement>(null)\n const currentItem = options.find((item) => item.value === currentValue)\n const { listenOutsideClick } = useOutsideClick({\n rootEl,\n breakpoint: BREAKPOINT_MD,\n onLoseFocusCB: closeList,\n })\n\n useEffect(() => {\n if (selectedItem.current && isListOpen) {\n selectedItem.current.scrollIntoView({ block: 'center', inline: 'center' })\n }\n }, [isListOpen])\n\n function openList() {\n setIsListOpen(true)\n listenOutsideClick()\n }\n\n function closeList() {\n setIsListOpen(false)\n }\n\n function handleSelectItem(option: SegmentItem) {\n onSelect(option)\n setIsListOpen(false)\n }\n\n return {\n openList,\n closeList,\n isListOpen,\n rootEl,\n currentItem,\n handleSelectItem,\n selectedItem,\n }\n}\n","import classNames from 'classnames'\nimport { IconChevronDown, IconChevronLeft, IconX } from '@components/icons'\n\nimport { useSegment } from './hook'\nimport { SegmentItem } from '../types'\nimport './styles.scss'\n\ntype SegmentProps = {\n mobileTitle: string\n options: SegmentItem[]\n onSelect: (option: SegmentItem) => void\n currentValue: string | number\n minValue?: Date\n maxValue?: Date\n}\n\nexport const Segment = ({\n currentValue,\n options,\n mobileTitle,\n onSelect,\n}: SegmentProps) => {\n const {\n rootEl,\n isListOpen,\n openList,\n closeList,\n currentItem,\n handleSelectItem,\n selectedItem,\n } = useSegment({\n options,\n currentValue,\n onSelect,\n })\n\n return (\n <div\n ref={rootEl}\n tabIndex={0}\n className={classNames('au-datepicker__segment', {\n 'au-datepicker__segment--open': isListOpen,\n })}>\n <div className=\"au-datepicker__segment-input\" onClick={openList}>\n {currentItem?.label}\n <IconChevronDown />\n </div>\n <div className=\"au-datepicker__segment-list-holder\">\n <div className=\"au-datepicker__segment-list-header\">\n <div onClick={closeList}>\n <IconChevronLeft />\n </div>\n <h4 className=\"au-datepicker__segment-title\">{mobileTitle}</h4>\n <div onClick={closeList}>\n <IconX />\n </div>\n </div>\n <ul className=\"au-datepicker__segment-list\">\n {options.map((option, idx) => {\n const isSelectedItem = option.value === currentValue\n return (\n <li\n key={`au-datepicker-segment-li-${option.value}-${idx}`}\n onClick={() => handleSelectItem(option)}\n ref={isSelectedItem ? selectedItem : null}\n className={classNames('au-datepicker__segment-list-item', {\n 'au-datepicker__segment-list-item--active': isSelectedItem,\n })}>\n {option.label}\n </li>\n )\n })}\n </ul>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;AASO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AAExD,WAAS,qBAAqB;AAC5B,QAAI,cAAc,CAAC,MAAM,UAAU,EAAG;AAC7B,aAAA,iBAAiB,aAAa,eAAe;AACtD,qBAAiB,IAAI;AAAA,EACvB;AAEA,WAAS,6BAA6B;AACpC,QAAI,eAAe;AACR,eAAA,oBAAoB,aAAa,eAAe;AACzD,uB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AAAA,IACA;AAAA,EAAA,CACD;AAGC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW,WAAW,0BAA0B;AAAA,QAC9C,gCAAgC;AAAA,MAAA,CACjC;AAAA,MACD,UAAA;AAAA,QAAA,qBAAC,OAAI,EAAA,WAAU,gCAA+B,SAAS,UACpD,UAAA;AAAA,UAAa,2CAAA;AAAA,8BACb,iBAAgB,EAAA;AAAA,QAAA,GACnB;AAAA,QACA,qBAAC,OAAI,EAAA,WAAU,sCACb,UAAA;AAAA,UAAC,qBAAA,OAAA,EAAI,WAAU,sCACb,UAAA;AAAA,YAAA,oBAAC,OAAI,EAAA,SAAS,WACZ,UAAA,oBAAC,kBAAgB,CAAA,GACnB;AAAA,YACC,oBAAA,MAAA,EAAG,WAAU,gCAAgC,UAAY,aAAA;AAAA,gCACzD,OAAI,EAAA,SAAS,WACZ,UAAA,oBAAC,QAAM,CAAA,GACT;AAAA,UAAA,GACF;AAAA,UACA,oBAAC,QAAG,WAAU,+BACX,kBAAQ,IAAI,CAAC,QAAQ,QAAQ;AACtB,kBAAA,iBAAiB,OAAO,UAAU;AAEtC,mBAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,SAAS,MAAM,iBAAiB,MAAM;AAAA,gBACtC,KAAK,iBAAiB,eAAe;AAAA,gBACrC,WAAW,WAAW,oCAAoC;AAAA,kBACxD,4CAA4C;AAAA,gBAAA,CAC7C;AAAA,gBACA,UAAO,OAAA;AAAA,cAAA;AAAA,cANH,4BAA4B,OAAO,KAAK,IAAI,GAAG;AAAA,YAAA;AAAA,UASzD,CAAA,GACH;AAAA,QAAA,GACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -3,7 +3,7 @@ import "./index-CweZ_OcN.js";
3
3
  import "./components/Icon/index.es.js";
4
4
  import { IconChevronLeft } from "./components/icons/IconChevronLeft/index.es.js";
5
5
  import { IconChevronRight } from "./components/icons/IconChevronRight/index.es.js";
6
- import { S as Segment } from "./index-CP-KKFUb.js";
6
+ import { S as Segment } from "./index--3ScUApr.js";
7
7
  import $dbSRa$react__default, { createContext, useContext, useState, useRef, useCallback, useEffect, useMemo, forwardRef } from "react";
8
8
  import "react-dom";
9
9
  createContext(null);
@@ -5686,4 +5686,4 @@ export {
5686
5686
  $dfd62f934fc76fed$export$e11f8ba65d857bff as e,
5687
5687
  $dfd62f934fc76fed$export$5d847498420df57b as f
5688
5688
  };
5689
- //# sourceMappingURL=index-C8RdzVRj.js.map
5689
+ //# sourceMappingURL=index-C63hcch2.js.map