@consumidor-positivo/aurora 0.0.52 → 0.0.53

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.
@@ -0,0 +1,205 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useRef, useEffect } from "react";
3
+ import { aK as Field } from "../../tokens-N1zNCjKI.js";
4
+ import { c as classNames } from "../../index-CweZ_OcN.js";
5
+ import "../Icon/index.es.js";
6
+ import { IconCheck } from "../icons/IconCheck/index.es.js";
7
+ import { IconChevronDown } from "../icons/IconChevronDown/index.es.js";
8
+ import { IconSlash } from "../icons/IconSlash/index.es.js";
9
+ const useSelectField = (options, initialValue, onChange, disabled, register) => {
10
+ const [isDropdownOpen, setIsDropdownOpen] = useState(false);
11
+ const [currentValue, setCurrentValue] = useState(initialValue || "");
12
+ const [activeOptionIndex, setActiveOptionIndex] = useState(
13
+ null
14
+ );
15
+ const selectRef = useRef(null);
16
+ const selectElementRef = useRef(null);
17
+ useEffect(() => {
18
+ if (initialValue) {
19
+ setCurrentValue(initialValue);
20
+ }
21
+ }, [initialValue]);
22
+ useEffect(() => {
23
+ if (register && selectElementRef.current) {
24
+ register(selectElementRef.current);
25
+ }
26
+ }, [register]);
27
+ const toggleDropdown = () => {
28
+ setIsDropdownOpen((prev) => !prev);
29
+ setActiveOptionIndex(null);
30
+ if (selectRef.current) {
31
+ selectRef.current.focus();
32
+ }
33
+ };
34
+ const selectOption = (optionValue, optionDisabled) => {
35
+ if (optionDisabled) return;
36
+ setCurrentValue(optionValue);
37
+ setIsDropdownOpen(false);
38
+ if (onChange) {
39
+ onChange(optionValue);
40
+ }
41
+ };
42
+ const _findNextAvailableIndex = (currentIndex, direction) => {
43
+ var _a;
44
+ const step = direction === "down" ? 1 : -1;
45
+ let nextIndex = (currentIndex + step + options.length) % options.length;
46
+ while ((_a = options[nextIndex]) == null ? void 0 : _a.disabled) {
47
+ nextIndex = (nextIndex + step + options.length) % options.length;
48
+ }
49
+ return nextIndex;
50
+ };
51
+ const onKeyDownDropdown = (e) => {
52
+ if (disabled) return;
53
+ const _actions = {
54
+ Enter: () => {
55
+ if (!isDropdownOpen) {
56
+ toggleDropdown();
57
+ return;
58
+ }
59
+ if (activeOptionIndex !== null && !options[activeOptionIndex].disabled) {
60
+ e.preventDefault();
61
+ selectOption(
62
+ options[activeOptionIndex].value,
63
+ options[activeOptionIndex].disabled
64
+ );
65
+ }
66
+ },
67
+ ArrowDown: () => {
68
+ e.preventDefault();
69
+ setActiveOptionIndex(
70
+ (prev) => _findNextAvailableIndex(prev !== null ? prev : -1, "down")
71
+ );
72
+ if (!isDropdownOpen) toggleDropdown();
73
+ },
74
+ ArrowUp: () => {
75
+ e.preventDefault();
76
+ setActiveOptionIndex(
77
+ (prev) => _findNextAvailableIndex(prev !== null ? prev : options.length, "up")
78
+ );
79
+ if (!isDropdownOpen) toggleDropdown();
80
+ },
81
+ Escape: () => {
82
+ setIsDropdownOpen(false);
83
+ }
84
+ };
85
+ if (_actions[e.key]) {
86
+ _actions[e.key]();
87
+ }
88
+ };
89
+ return {
90
+ isDropdownOpen,
91
+ currentValue,
92
+ selectRef,
93
+ selectElementRef,
94
+ toggleDropdown,
95
+ selectOption,
96
+ onKeyDownDropdown,
97
+ setActiveOptionIndex,
98
+ activeOptionIndex
99
+ };
100
+ };
101
+ const SelectField = ({
102
+ label,
103
+ options,
104
+ optional,
105
+ disabled,
106
+ value,
107
+ onChange,
108
+ style,
109
+ className,
110
+ placeholder,
111
+ name,
112
+ register,
113
+ onBlur
114
+ }) => {
115
+ var _a;
116
+ const {
117
+ isDropdownOpen,
118
+ currentValue,
119
+ selectRef,
120
+ selectElementRef,
121
+ toggleDropdown,
122
+ selectOption,
123
+ onKeyDownDropdown,
124
+ setActiveOptionIndex,
125
+ activeOptionIndex
126
+ } = useSelectField(options, value, onChange, disabled, register);
127
+ const dropdownClasses = classNames("au-field__select", {
128
+ "au-field__select--disabled": disabled,
129
+ "au-field__select--open": isDropdownOpen,
130
+ [className]: className
131
+ });
132
+ return /* @__PURE__ */ jsxs(Field.Root, { style, customclass: className, disabled, children: [
133
+ /* @__PURE__ */ jsx(Field.Label, { text: label, optional, disabled }),
134
+ /* @__PURE__ */ jsxs("div", { className: dropdownClasses, children: [
135
+ /* @__PURE__ */ jsxs(
136
+ "div",
137
+ {
138
+ className: "au-field__select-wrapper",
139
+ onClick: toggleDropdown,
140
+ onKeyDown: onKeyDownDropdown,
141
+ tabIndex: disabled ? -1 : 0,
142
+ ref: selectRef,
143
+ role: "combobox",
144
+ "aria-haspopup": "listbox",
145
+ "aria-expanded": isDropdownOpen,
146
+ "aria-labelledby": "select-label",
147
+ "aria-activedescendant": activeOptionIndex !== null ? options[activeOptionIndex].value : void 0,
148
+ onBlur,
149
+ children: [
150
+ /* @__PURE__ */ jsx("div", { className: "au-field__select-display", children: ((_a = options.find((option) => option.value === currentValue)) == null ? void 0 : _a.label) || placeholder || "Selecionar..." }),
151
+ /* @__PURE__ */ jsx("div", { className: "au-field__select-icon", children: /* @__PURE__ */ jsx(IconChevronDown, {}) })
152
+ ]
153
+ }
154
+ ),
155
+ /* @__PURE__ */ jsx(
156
+ "ul",
157
+ {
158
+ className: classNames("au-field__select-options", {
159
+ "au-field__select-options--open": isDropdownOpen
160
+ }),
161
+ role: "listbox",
162
+ "aria-live": "polite",
163
+ tabIndex: -1,
164
+ children: options.map((option, index) => /* @__PURE__ */ jsxs(
165
+ "li",
166
+ {
167
+ className: classNames("au-field__select-option", {
168
+ "au-field__select-option--highlighted": activeOptionIndex === index,
169
+ "au-field__select-option--selected": option.value === currentValue,
170
+ "au-field__select-option--disabled": option.disabled
171
+ }),
172
+ role: "option",
173
+ "aria-selected": option.value === currentValue,
174
+ "aria-disabled": option.disabled,
175
+ onClick: () => selectOption(option.value, option.disabled),
176
+ onMouseEnter: () => setActiveOptionIndex(index),
177
+ children: [
178
+ option.label,
179
+ option.disabled ? /* @__PURE__ */ jsx(IconSlash, {}) : option.value === currentValue ? /* @__PURE__ */ jsx(IconCheck, {}) : null
180
+ ]
181
+ },
182
+ option.value
183
+ ))
184
+ }
185
+ ),
186
+ /* @__PURE__ */ jsx(
187
+ "select",
188
+ {
189
+ hidden: true,
190
+ disabled,
191
+ value: currentValue,
192
+ onChange: (e) => selectOption(e.target.value),
193
+ ref: selectElementRef,
194
+ name,
195
+ onBlur,
196
+ children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
197
+ }
198
+ )
199
+ ] })
200
+ ] });
201
+ };
202
+ export {
203
+ SelectField
204
+ };
205
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +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'\n\ntype OptionProps = {\n value: string\n disabled?: boolean\n}\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) => {\n const [isDropdownOpen, setIsDropdownOpen] = useState(false)\n const [currentValue, setCurrentValue] = useState<string>(initialValue || '')\n const [activeOptionIndex, setActiveOptionIndex] = useState<number | null>(\n null,\n )\n const selectRef = useRef<HTMLDivElement>(null)\n const selectElementRef = useRef<HTMLSelectElement>(null)\n\n useEffect(() => {\n if (initialValue) {\n setCurrentValue(initialValue)\n }\n }, [initialValue])\n\n useEffect(() => {\n if (register && selectElementRef.current) {\n register(selectElementRef.current)\n }\n }, [register])\n\n const toggleDropdown = () => {\n setIsDropdownOpen((prev) => !prev)\n setActiveOptionIndex(null)\n if (selectRef.current) {\n selectRef.current.focus()\n }\n }\n\n const selectOption = (optionValue: string, optionDisabled?: boolean) => {\n if (optionDisabled) return\n\n setCurrentValue(optionValue)\n setIsDropdownOpen(false)\n\n if (onChange) {\n onChange(optionValue)\n }\n }\n\n const _findNextAvailableIndex = (\n currentIndex: number,\n direction: 'down' | 'up',\n ) => {\n const step = direction === 'down' ? 1 : -1\n let nextIndex = (currentIndex + step + options.length) % options.length\n\n while (options[nextIndex]?.disabled) {\n nextIndex = (nextIndex + step + options.length) % options.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 !options[activeOptionIndex].disabled\n ) {\n e.preventDefault()\n selectOption(\n options[activeOptionIndex].value,\n options[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(prev !== null ? prev : options.length, 'up'),\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 return {\n isDropdownOpen,\n currentValue,\n selectRef,\n selectElementRef,\n toggleDropdown,\n selectOption,\n onKeyDownDropdown,\n setActiveOptionIndex,\n activeOptionIndex,\n }\n}\n","import { useSelectField } from './hook'\nimport Field from '../Field'\nimport classNames from 'classnames'\nimport { IconChevronDown, IconSlash, IconCheck } from '../../icons'\nimport './styles.scss'\n\ntype OptionProps = {\n value: string\n label: string\n disabled?: boolean\n}\n\ntype SelectFieldProps = React.HTMLAttributes<HTMLDivElement> & {\n label?: string\n options: OptionProps[]\n optional?: boolean\n placeholder?: string\n disabled?: boolean\n value?: string\n onChange?: (value: string) => void\n onBlur?: () => void\n name?: string\n register?: (instance: HTMLSelectElement | null) => void\n}\n\nexport const SelectField = ({\n label,\n options,\n optional,\n disabled,\n value,\n onChange,\n style,\n className,\n placeholder,\n name,\n register,\n onBlur,\n}: SelectFieldProps) => {\n const {\n isDropdownOpen,\n currentValue,\n selectRef,\n selectElementRef,\n toggleDropdown,\n selectOption,\n onKeyDownDropdown,\n setActiveOptionIndex,\n activeOptionIndex,\n } = useSelectField(options, value, onChange, disabled, register)\n\n const dropdownClasses = classNames('au-field__select', {\n 'au-field__select--disabled': disabled,\n 'au-field__select--open': isDropdownOpen,\n [className!]: className,\n })\n\n return (\n <Field.Root style={style} customclass={className} disabled={disabled}>\n <Field.Label text={label} optional={optional} disabled={disabled} />\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\n ? options[activeOptionIndex].value\n : undefined\n }\n onBlur={onBlur}>\n <div className=\"au-field__select-display\">\n {options.find((option) => option.value === currentValue)?.label ||\n placeholder ||\n 'Selecionar...'}\n </div>\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 {options.map((option, index) => (\n <li\n key={option.value}\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 === currentValue,\n 'au-field__select-option--disabled': option.disabled,\n })}\n role=\"option\"\n aria-selected={option.value === currentValue}\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 === currentValue ? (\n <IconCheck />\n ) : null}\n </li>\n ))}\n </ul>\n <select\n hidden\n disabled={disabled}\n value={currentValue}\n onChange={(e) => selectOption(e.target.value)}\n ref={selectElementRef}\n name={name}\n onBlur={onBlur}>\n {options.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n </Field.Root>\n )\n}\n"],"names":[],"mappings":";;;;;;;;AAOO,MAAM,iBAAiB,CAC5B,SACA,cACA,UACA,UACA,aACG;AACH,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAC1D,QAAM,CAAC,cAAc,eAAe,IAAI,SAAiB,gBAAgB,EAAE;AACrE,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD;AAAA,EAAA;AAEI,QAAA,YAAY,OAAuB,IAAI;AACvC,QAAA,mBAAmB,OAA0B,IAAI;AAEvD,YAAU,MAAM;AACd,QAAI,cAAc;AAChB,sBAAgB,YAAY;AAAA,IAC9B;AAAA,EAAA,GACC,CAAC,YAAY,CAAC;AAEjB,YAAU,MAAM;AACV,QAAA,YAAY,iBAAiB,SAAS;AACxC,eAAS,iBAAiB,OAAO;AAAA,IACnC;AAAA,EAAA,GACC,CAAC,QAAQ,CAAC;AAEb,QAAM,iBAAiB,MAAM;AACT,sBAAA,CAAC,SAAS,CAAC,IAAI;AACjC,yBAAqB,IAAI;AACzB,QAAI,UAAU,SAAS;AACrB,gBAAU,QAAQ;IACpB;AAAA,EAAA;AAGI,QAAA,eAAe,CAAC,aAAqB,mBAA6B;AACtE,QAAI,eAAgB;AAEpB,oBAAgB,WAAW;AAC3B,sBAAkB,KAAK;AAEvB,QAAI,UAAU;AACZ,eAAS,WAAW;AAAA,IACtB;AAAA,EAAA;AAGI,QAAA,0BAA0B,CAC9B,cACA,cACG;;AACG,UAAA,OAAO,cAAc,SAAS,IAAI;AACxC,QAAI,aAAa,eAAe,OAAO,QAAQ,UAAU,QAAQ;AAE1D,YAAA,aAAQ,SAAS,MAAjB,mBAAoB,UAAU;AACnC,mBAAa,YAAY,OAAO,QAAQ,UAAU,QAAQ;AAAA,IAC5D;AAEO,W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7C;AAAA,cACD,MAAK;AAAA,cACL,iBAAe,OAAO,UAAU;AAAA,cAChC,iBAAe,OAAO;AAAA,cACtB,SAAS,MAAM,aAAa,OAAO,OAAO,OAAO,QAAQ;AAAA,cACzD,cAAc,MAAM,qBAAqB,KAAK;AAAA,cAC7C,UAAA;AAAA,gBAAO,OAAA;AAAA,gBACP,OAAO,WACN,oBAAC,WAAU,CAAA,CAAA,IACT,OAAO,UAAU,eAClB,oBAAA,WAAA,CAAA,CAAU,IACT;AAAA,cAAA;AAAA,YAAA;AAAA,YAlBC,OAAO;AAAA,UAAA,CAoBf;AAAA,QAAA;AAAA,MACH;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,QAAM;AAAA,UACN;AAAA,UACA,OAAO;AAAA,UACP,UAAU,CAAC,MAAM,aAAa,EAAE,OAAO,KAAK;AAAA,UAC5C,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UACC,UAAQ,QAAA,IAAI,CAAC,WACX,oBAAA,UAAA,EAA0B,OAAO,OAAO,OACtC,UAAA,OAAO,MADG,GAAA,OAAO,KAEpB,CACD;AAAA,QAAA;AAAA,MACH;AAAA,IAAA,GACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ type OptionProps = {
3
+ value: string;
4
+ disabled?: boolean;
5
+ };
6
+ export declare const useSelectField: (options: OptionProps[], initialValue?: string, onChange?: ((value: string) => void) | undefined, disabled?: boolean, register?: ((instance: HTMLSelectElement | null) => void) | undefined) => {
7
+ isDropdownOpen: boolean;
8
+ currentValue: string;
9
+ selectRef: import('react').RefObject<HTMLDivElement>;
10
+ selectElementRef: import('react').RefObject<HTMLSelectElement>;
11
+ toggleDropdown: () => void;
12
+ selectOption: (optionValue: string, optionDisabled?: boolean) => void;
13
+ onKeyDownDropdown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
14
+ setActiveOptionIndex: import('react').Dispatch<import('react').SetStateAction<number | null>>;
15
+ activeOptionIndex: number | null;
16
+ };
17
+ export {};
@@ -0,0 +1,20 @@
1
+
2
+ type OptionProps = {
3
+ value: string;
4
+ label: string;
5
+ disabled?: boolean;
6
+ };
7
+ type SelectFieldProps = React.HTMLAttributes<HTMLDivElement> & {
8
+ label?: string;
9
+ options: OptionProps[];
10
+ optional?: boolean;
11
+ placeholder?: string;
12
+ disabled?: boolean;
13
+ value?: string;
14
+ onChange?: (value: string) => void;
15
+ onBlur?: () => void;
16
+ name?: string;
17
+ register?: (instance: HTMLSelectElement | null) => void;
18
+ };
19
+ export declare const SelectField: ({ label, options, optional, disabled, value, onChange, style, className, placeholder, name, register, onBlur, }: SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -1 +1 @@
1
- html{box-sizing:border-box;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}*,*:before,*:after{box-sizing:inherit;margin:0;padding:0}:focus{outline:none}body{font-family:"Source Sans 3",sans-serif;background-color:#fff}.au-field{cursor:pointer}.au-field__input{background-color:#fff;border:1px solid #454a54;border-radius:8px;box-sizing:border-box;font-size:16px;line-height:22px;padding:16px;height:56px;width:100%}.au-field__input:hover{border:1px solid #16181d}.au-field__input:focus{border-color:#0048db;outline:1px solid #0048db}.au-field:focus-within:not(.au-field--error) .au-field__header-label{color:#0048db}.au-field__header{display:flex;justify-content:space-between;align-items:center;padding-bottom:8px}.au-field__header-label{color:#454a54;cursor:pointer;font-size:14px;font-weight:600}.au-field__header-label--required{color:#991717}.au-field__header-icon span{font-size:14px;color:#454a54}.au-field__error-message{color:#991717;font-size:16px;font-weight:400;line-height:24px;padding-top:8px}.au-field--disabled{cursor:not-allowed}.au-field--disabled .au-field__input{background-color:#e2e4e9;border-color:#5e6573;color:#5e6573;cursor:not-allowed}.au-field--disabled .au-field__header-label{color:#5e6573;cursor:not-allowed}.au-field--error .au-field__input{background-color:#f5eff0;border-color:#991717}.au-field--error .au-field__input:focus{border-color:#0048db}.au-field--error .au-field__header-label{color:#991717}.au-field--success .au-field__input{animation:inputSuccess 2s forwards}.au-field--success .au-field__header-label{animation:labelSuccess 2s forwards}.au-field--success .au-field__header-icon .au-icon{animation:iconSucess 2s forwards}@keyframes inputSuccess{0%,70%{background-color:#f0fcf5;border-color:#10593b}}@keyframes labelSuccess{0%,70%{color:#10593b}}@keyframes iconSucess{0%,70%{opacity:1}to{opacity:0}}.au-token-field{max-width:max-content}.au-token-field__container{display:flex;gap:8px}.au-token-field__input{font-size:20px;text-align:center;padding:8px}.au-token-field__input[type=number]::-webkit-inner-spin-button,.au-token-field__input[type=number]::-webkit-outer-spin-button{display:none}.au-password-field__container{position:relative;height:56px}.au-password-field__input{position:absolute;padding:16px 92px 16px 16px}.au-password-field__btn{background-color:transparent;border:none;color:#0048db;cursor:pointer;font-family:"Source Sans 3",sans-serif;font-size:14px;font-weight:600;text-transform:uppercase;position:absolute;z-index:1;background-position-y:center;right:16px;height:56px}.au-password-field__btn:disabled{cursor:not-allowed}.au-checkbox{position:relative}.au-checkbox__holder{cursor:pointer;display:flex;gap:8px;align-items:start}.au-checkbox__input{position:absolute;opacity:0;width:0;height:0}.au-checkbox__input:checked~.au-checkbox__check{background-color:#0048db;border-color:#0048db}.au-checkbox__input:checked~.au-checkbox__check .au-icon svg{opacity:1}.au-checkbox__input:hover:not(:focus)~.au-checkbox__check{border-color:#0048db;outline:2px solid #F2F5FC}.au-checkbox__input:focus~.au-checkbox__check{box-shadow:0 0 0 1px #fff,0 0 0 3px #0048db}.au-checkbox__check{background-color:#fff;border:2px solid #454a54;border-radius:4px;height:24px;width:24px;transition:background-color .2s ease}.au-checkbox__check .au-icon svg{position:absolute;left:0;top:0;opacity:0;transition:opacity .2s ease}.au-checkbox__label{color:#454a54;font-family:"Source Sans 3",sans-serif;font-size:16px;line-height:24px;word-wrap:break-word;max-width:calc(100% - 32px)}.au-checkbox--error .au-checkbox__input:focus~.au-checkbox__check{box-shadow:0 0 0 1px #fff,0 0 0 3px #991717}.au-checkbox--disabled .au-checkbox__holder{cursor:not-allowed}.au-checkbox--disabled .au-checkbox__input:checked~.au-checkbox__check{background-color:#c4c9d4;border-color:#c4c9d4}.au-checkbox--disabled .au-checkbox__input:hover~.au-checkbox__check{border-color:#c4c9d4;outline:none}.au-checkbox--disabled .au-checkbox__check{border:2px solid #c4c9d4}.au-checkbox--disabled .au-checkbox__label{color:#c4c9d4}
1
+ html{box-sizing:border-box;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}*,*:before,*:after{box-sizing:inherit;margin:0;padding:0}:focus{outline:none}body{font-family:"Source Sans 3",sans-serif;background-color:#fff}.au-field{cursor:pointer}.au-field__input{background-color:#fff;border:1px solid #454a54;border-radius:8px;box-sizing:border-box;font-size:16px;line-height:22px;padding:16px;height:56px;width:100%}.au-field__input:hover{border:1px solid #16181d}.au-field__input:focus{border-color:#0048db;outline:1px solid #0048db}.au-field:focus-within:not(.au-field--error) .au-field__header-label{color:#0048db}.au-field__header{display:flex;justify-content:space-between;align-items:center;padding-bottom:8px}.au-field__header-label{color:#454a54;cursor:pointer;font-size:14px;font-weight:600}.au-field__header-label--required{color:#991717}.au-field__header-icon span{font-size:14px;color:#454a54}.au-field__error-message{color:#991717;font-size:16px;font-weight:400;line-height:24px;padding-top:8px}.au-field--disabled{cursor:not-allowed}.au-field--disabled .au-field__input{background-color:#e2e4e9;border-color:#5e6573;color:#5e6573;cursor:not-allowed}.au-field--disabled .au-field__header-label{color:#5e6573;cursor:not-allowed}.au-field--error .au-field__input{background-color:#f5eff0;border-color:#991717}.au-field--error .au-field__input:focus{border-color:#0048db}.au-field--error .au-field__header-label{color:#991717}.au-field--success .au-field__input{animation:inputSuccess 2s forwards}.au-field--success .au-field__header-label{animation:labelSuccess 2s forwards}.au-field--success .au-field__header-icon .au-icon{animation:iconSucess 2s forwards}@keyframes inputSuccess{0%,70%{background-color:#f0fcf5;border-color:#10593b}}@keyframes labelSuccess{0%,70%{color:#10593b}}@keyframes iconSucess{0%,70%{opacity:1}to{opacity:0}}.au-token-field{max-width:max-content}.au-token-field__container{display:flex;gap:8px}.au-token-field__input{font-size:20px;text-align:center;padding:8px}.au-token-field__input[type=number]::-webkit-inner-spin-button,.au-token-field__input[type=number]::-webkit-outer-spin-button{display:none}.au-field__select{position:relative;margin-bottom:1rem}.au-field__select-wrapper{display:flex;align-items:center;justify-content:space-between;width:100%;height:56px;padding:16px;background-color:#fff;border:1px solid #454a54;border-radius:8px;box-sizing:border-box;font-size:16px;line-height:22px}.au-field__select-wrapper:focus-within{border:2px solid #0048db}.au-field__select-icon{transition:transform .2s ease}.au-field__select-options{display:flex;flex-direction:column;width:100%;margin-top:16px;border:1px solid #0048db;background:#fff;border-radius:8px;overflow:hidden;cursor:auto;position:absolute;transform-origin:top left;transform:scaleY(0);opacity:0;visibility:hidden;transition:transform .2s,opacity .2s,visibility 0s .2s;z-index:1}.au-field__select-options--open{transform:scaleY(1);opacity:1;visibility:visible;transition:transform .2s,opacity .2s}.au-field__select-option{display:flex;justify-content:space-between;padding:16px 24px;cursor:pointer}.au-field__select-option:not(.au-field__select-option--selected):hover,.au-field__select-option--highlighted:not(.au-field__select-option--selected){background-color:#f6f7fa;color:#16181d}.au-field__select-option--selected{background-color:#0048db;color:#fff;font-weight:700}.au-field__select-option--selected .au-icon>svg{color:#fff}.au-field__select-option--disabled{pointer-events:none;cursor:not-allowed;background-color:#e2e4e9;color:#5e6573}.au-field__select-option--disabled .au-icon>svg{color:#5e6573}.au-field__select--open .au-field__select-wrapper{border:2px solid #0048db}.au-field__select--open .au-field__select-wrapper .au-field__select-icon{transform:rotate(180deg)}.au-field__select--disabled{pointer-events:none;cursor:not-allowed}.au-field__select--disabled .au-field__select-wrapper{background-color:#e2e4e9}.au-field__select--disabled .au-field__select-wrapper .au-icon>svg{color:#5e6573}.au-field:not(.au-field-error):has(.au-field__select--open) .au-field__header-label{color:#0048db}.au-field:not(.au-field-error):has(.au-field__select--open) .au-field__select-wrapper,.au-field:not(.au-field-error):has(.au-field__select--open) .au-field__select-wrapper:focus-within{border-width:1px}.au-password-field__container{position:relative;height:56px}.au-password-field__input{position:absolute;padding:16px 92px 16px 16px}.au-password-field__btn{background-color:transparent;border:none;color:#0048db;cursor:pointer;font-family:"Source Sans 3",sans-serif;font-size:14px;font-weight:600;text-transform:uppercase;position:absolute;z-index:1;background-position-y:center;right:16px;height:56px}.au-password-field__btn:disabled{cursor:not-allowed}.au-checkbox{position:relative}.au-checkbox__holder{cursor:pointer;display:flex;gap:8px;align-items:start}.au-checkbox__input{position:absolute;opacity:0;width:0;height:0}.au-checkbox__input:checked~.au-checkbox__check{background-color:#0048db;border-color:#0048db}.au-checkbox__input:checked~.au-checkbox__check .au-icon svg{opacity:1}.au-checkbox__input:hover:not(:focus)~.au-checkbox__check{border-color:#0048db;outline:2px solid #F2F5FC}.au-checkbox__input:focus~.au-checkbox__check{box-shadow:0 0 0 1px #fff,0 0 0 3px #0048db}.au-checkbox__check{background-color:#fff;border:2px solid #454a54;border-radius:4px;height:24px;width:24px;transition:background-color .2s ease}.au-checkbox__check .au-icon svg{position:absolute;left:0;top:0;opacity:0;transition:opacity .2s ease}.au-checkbox__label{color:#454a54;font-family:"Source Sans 3",sans-serif;font-size:16px;line-height:24px;word-wrap:break-word;max-width:calc(100% - 32px)}.au-checkbox--error .au-checkbox__input:focus~.au-checkbox__check{box-shadow:0 0 0 1px #fff,0 0 0 3px #991717}.au-checkbox--disabled .au-checkbox__holder{cursor:not-allowed}.au-checkbox--disabled .au-checkbox__input:checked~.au-checkbox__check{background-color:#c4c9d4;border-color:#c4c9d4}.au-checkbox--disabled .au-checkbox__input:hover~.au-checkbox__check{border-color:#c4c9d4;outline:none}.au-checkbox--disabled .au-checkbox__check{border:2px solid #c4c9d4}.au-checkbox--disabled .au-checkbox__label{color:#c4c9d4}
package/dist/main.d.ts CHANGED
@@ -11,6 +11,7 @@ export { Text } from './components/Text';
11
11
  export { Footer } from './components/Footer';
12
12
  export { InputField } from './components/form/InputField';
13
13
  export { TokenField } from './components/form/TokenField';
14
+ export { SelectField } from './components/form/SelectField';
14
15
  export { PasswordField } from './components/form/PasswordField';
15
16
  export { CheckboxField } from './components/form/CheckboxField';
16
17
  export { useDrawer } from './components/Drawer/hooks';
package/dist/main.es.js CHANGED
@@ -11,6 +11,7 @@ import { Text } from "./components/Text/index.es.js";
11
11
  import { Footer } from "./components/Footer/index.es.js";
12
12
  import { InputField } from "./components/InputField/index.es.js";
13
13
  import { TokenField } from "./components/TokenField/index.es.js";
14
+ import { SelectField } from "./components/SelectField/index.es.js";
14
15
  import { PasswordField } from "./components/PasswordField/index.es.js";
15
16
  import { CheckboxField } from "./components/CheckboxField/index.es.js";
16
17
  import { useState } from "react";
@@ -779,6 +780,7 @@ export {
779
780
  ac as SPACING_700,
780
781
  ad as SPACING_800,
781
782
  ae as SPACING_900,
783
+ SelectField,
782
784
  Text,
783
785
  TokenField,
784
786
  useDrawer
@@ -1 +1 @@
1
- {"version":3,"file":"main.es.js","sources":["../lib/components/Drawer/hooks.ts"],"sourcesContent":["import { useState } from 'react'\n\ntype UseDrawerProps = Record<string, boolean>\n\nexport function useDrawer(props: UseDrawerProps) {\n const [drawerOpen, setDrawerOpen] = useState<UseDrawerProps>(props)\n\n function handleOpenDrawer(name: string) {\n setDrawerOpen((prev) => {\n return {\n ...prev,\n [name]: !prev[name],\n }\n })\n }\n\n return {\n handleOpenDrawer,\n drawerOpen,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,UAAU,OAAuB;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAyB,KAAK;AAElE,WAAS,iBAAiB,MAAc;AACtC,kBAAc,CAAC,SAAS;AACf,aAAA;AAAA,QACL,GAAG;AAAA,QACH,CAAC,IAAI,GAAG,CAAC,KAAK,IAAI;AAAA,MAAA;AAAA,IACpB,CACD;AAAA,EACH;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"main.es.js","sources":["../lib/components/Drawer/hooks.ts"],"sourcesContent":["import { useState } from 'react'\n\ntype UseDrawerProps = Record<string, boolean>\n\nexport function useDrawer(props: UseDrawerProps) {\n const [drawerOpen, setDrawerOpen] = useState<UseDrawerProps>(props)\n\n function handleOpenDrawer(name: string) {\n setDrawerOpen((prev) => {\n return {\n ...prev,\n [name]: !prev[name],\n }\n })\n }\n\n return {\n handleOpenDrawer,\n drawerOpen,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,UAAU,OAAuB;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAyB,KAAK;AAElE,WAAS,iBAAiB,MAAc;AACtC,kBAAc,CAAC,SAAS;AACf,aAAA;AAAA,QACL,GAAG;AAAA,QACH,CAAC,IAAI,GAAG,CAAC,KAAK,IAAI;AAAA,MAAA;AAAA,IACpB,CACD;AAAA,EACH;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@consumidor-positivo/aurora",
3
3
  "private": false,
4
- "version": "0.0.52",
4
+ "version": "0.0.53",
5
5
  "type": "module",
6
6
  "main": "./dist/main.es.js",
7
7
  "modules": "./dist/main.es.js",