brd-ui-kit 0.1.68 → 0.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brd-ui-kit.css +1 -1
- package/dist/components/input-contact/input-contact.d.ts +6 -5
- package/dist/components-input-contact-input-contact.cjs +7 -5
- package/dist/components-input-contact-input-contact.cjs.map +1 -1
- package/dist/components-input-contact-input-contact.js +93 -55
- package/dist/components-input-contact-input-contact.js.map +1 -1
- package/dist/components-input-phone-input-phone.cjs +6 -6
- package/dist/components-input-phone-input-phone.cjs.map +1 -1
- package/dist/components-input-phone-input-phone.js +24 -17
- package/dist/components-input-phone-input-phone.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import './brd-ui-kit.css';/* empty css */
|
|
3
|
-
import { cn as
|
|
3
|
+
import { cn as m } from "./lib-utils.js";
|
|
4
4
|
import "class-variance-authority";
|
|
5
|
-
import { useState as
|
|
5
|
+
import { useState as C, useRef as y, useEffect as B } from "react";
|
|
6
6
|
import "./components-ui-badge-badge.styles.js";
|
|
7
|
-
import { Button as
|
|
7
|
+
import { Button as P } from "./components-ui-button-button.js";
|
|
8
8
|
import "./components-ui-button-button.styles.js";
|
|
9
9
|
import "./components-ui-card-card.js";
|
|
10
10
|
import "./components-ui-checkbox-checkbox.js";
|
|
11
|
-
import { Icon as
|
|
11
|
+
import { Icon as s } from "./components-ui-icon-icon.js";
|
|
12
12
|
import "./components-ui-combobox-combobox.js";
|
|
13
13
|
import "./components-ui-dialog-dialog.js";
|
|
14
14
|
import "./components-ui-label-label.js";
|
|
@@ -27,18 +27,18 @@ import "./components-ui-table-table.js";
|
|
|
27
27
|
import "./components-ui-tabs-tabs.js";
|
|
28
28
|
import "./components-ui-tooltip-tooltip.js";
|
|
29
29
|
import "./components-ui-typography-typography.styles.js";
|
|
30
|
-
import { usePopupControls as
|
|
30
|
+
import { usePopupControls as N } from "./hooks-usePopupControls.js";
|
|
31
31
|
import "lucide-react";
|
|
32
32
|
import "./components-app-pagination-app-pagination.styles.js";
|
|
33
33
|
import "./components-app-sidebar-app-sidebar.styles.js";
|
|
34
|
-
import { InputField as
|
|
34
|
+
import { InputField as j } from "./components-input-field-input-field.js";
|
|
35
35
|
import "./components-select-field-select-field.js";
|
|
36
36
|
import "./lodash-FemA_LCk.js";
|
|
37
37
|
import "./chart-D15EtNmb.js";
|
|
38
38
|
import "./index-C4iHL8Gs.js";
|
|
39
39
|
import "./index-C6N9aMq_.js";
|
|
40
|
-
import "./components-input-phone-input-phone.js";
|
|
41
|
-
const
|
|
40
|
+
import { InputPhone as I } from "./components-input-phone-input-phone.js";
|
|
41
|
+
const $ = [
|
|
42
42
|
{
|
|
43
43
|
label: "Мобильный",
|
|
44
44
|
icon: "phone"
|
|
@@ -59,8 +59,8 @@ const j = [
|
|
|
59
59
|
label: "E-mail",
|
|
60
60
|
icon: "mail"
|
|
61
61
|
}
|
|
62
|
-
],
|
|
63
|
-
switch (
|
|
62
|
+
], o = (i) => {
|
|
63
|
+
switch (i) {
|
|
64
64
|
case "max":
|
|
65
65
|
return {
|
|
66
66
|
viewBox: "0 0 16 16",
|
|
@@ -82,18 +82,18 @@ const j = [
|
|
|
82
82
|
viewBox: "0 0 24 24"
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
},
|
|
86
|
-
const [
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
85
|
+
}, he = (i) => {
|
|
86
|
+
const { inputProps: x, inputPhoneProps: h } = i, [e, v] = C("phone"), { isOpened: n, openPopup: c, closePopup: a } = N(), l = y(null);
|
|
87
|
+
B(() => {
|
|
88
|
+
const r = (p) => {
|
|
89
|
+
l.current && !l.current.contains(p.target) && a();
|
|
90
90
|
};
|
|
91
|
-
return n && document.addEventListener("mousedown",
|
|
92
|
-
document.removeEventListener("mousedown",
|
|
91
|
+
return n && document.addEventListener("mousedown", r), () => {
|
|
92
|
+
document.removeEventListener("mousedown", r);
|
|
93
93
|
};
|
|
94
|
-
}, [n,
|
|
95
|
-
const
|
|
96
|
-
switch (
|
|
94
|
+
}, [n, a]);
|
|
95
|
+
const u = (r) => {
|
|
96
|
+
switch (r) {
|
|
97
97
|
case "phone":
|
|
98
98
|
return "+7 (999) 999-99-99";
|
|
99
99
|
case "telegram":
|
|
@@ -107,84 +107,122 @@ const j = [
|
|
|
107
107
|
default:
|
|
108
108
|
return "Введите значение";
|
|
109
109
|
}
|
|
110
|
-
}, f = (
|
|
111
|
-
|
|
110
|
+
}, f = (r) => () => {
|
|
111
|
+
v(r), i.onTypeChange?.(r), a();
|
|
112
112
|
};
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
-
|
|
113
|
+
return /* @__PURE__ */ d("div", { className: m("relative", i.classes?.container), children: [
|
|
114
|
+
["telegram", "max", "mail"].includes(e) ? /* @__PURE__ */ t(
|
|
115
|
+
j,
|
|
116
116
|
{
|
|
117
|
-
...
|
|
117
|
+
...x,
|
|
118
118
|
date: [
|
|
119
119
|
{
|
|
120
120
|
id: "0",
|
|
121
121
|
position: "inline-start",
|
|
122
|
-
component: /* @__PURE__ */
|
|
123
|
-
|
|
122
|
+
component: /* @__PURE__ */ t(
|
|
123
|
+
s,
|
|
124
124
|
{
|
|
125
|
-
type:
|
|
125
|
+
type: e,
|
|
126
126
|
classes: {
|
|
127
|
-
wrapper:
|
|
127
|
+
wrapper: m(
|
|
128
128
|
`flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
${o(e).bgColor ?? "bg-primary-inverse-hover-bg"}
|
|
130
|
+
${o(e).textColor ?? "text-primary-inverse-text"}`
|
|
131
131
|
)
|
|
132
132
|
},
|
|
133
|
-
viewBox:
|
|
133
|
+
viewBox: o(e).viewBox
|
|
134
134
|
}
|
|
135
135
|
)
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
id: "1",
|
|
139
139
|
position: "inline-end",
|
|
140
|
-
component: /* @__PURE__ */
|
|
141
|
-
|
|
140
|
+
component: /* @__PURE__ */ t(
|
|
141
|
+
s,
|
|
142
142
|
{
|
|
143
143
|
type: n ? "chevron-up" : "chevron",
|
|
144
144
|
className: "cursor-pointer",
|
|
145
|
-
onClick:
|
|
145
|
+
onClick: c
|
|
146
146
|
}
|
|
147
147
|
)
|
|
148
148
|
}
|
|
149
149
|
],
|
|
150
|
-
placeholder:
|
|
150
|
+
placeholder: u(e)
|
|
151
|
+
}
|
|
152
|
+
) : /* @__PURE__ */ t(
|
|
153
|
+
I,
|
|
154
|
+
{
|
|
155
|
+
...h,
|
|
156
|
+
date: [
|
|
157
|
+
{
|
|
158
|
+
id: "0",
|
|
159
|
+
position: "inline-start",
|
|
160
|
+
component: /* @__PURE__ */ t(
|
|
161
|
+
s,
|
|
162
|
+
{
|
|
163
|
+
type: e,
|
|
164
|
+
classes: {
|
|
165
|
+
wrapper: m(
|
|
166
|
+
`flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]
|
|
167
|
+
${o(e).bgColor ?? "bg-primary-inverse-hover-bg"}
|
|
168
|
+
${o(e).textColor ?? "text-primary-inverse-text"}`
|
|
169
|
+
)
|
|
170
|
+
},
|
|
171
|
+
viewBox: o(e).viewBox
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "1",
|
|
177
|
+
position: "inline-end",
|
|
178
|
+
component: /* @__PURE__ */ t(
|
|
179
|
+
s,
|
|
180
|
+
{
|
|
181
|
+
type: n ? "chevron-up" : "chevron",
|
|
182
|
+
className: "cursor-pointer",
|
|
183
|
+
onClick: c
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
placeholder: u(e)
|
|
151
189
|
}
|
|
152
190
|
),
|
|
153
|
-
n && /* @__PURE__ */
|
|
191
|
+
n && /* @__PURE__ */ t(
|
|
154
192
|
"div",
|
|
155
193
|
{
|
|
156
194
|
className: `border-inp-hover-border bg-primary-bg absolute my-2 flex w-full
|
|
157
195
|
flex-col rounded-xl border`,
|
|
158
|
-
ref:
|
|
159
|
-
children:
|
|
160
|
-
const { bgColor:
|
|
161
|
-
return /* @__PURE__ */
|
|
162
|
-
|
|
196
|
+
ref: l,
|
|
197
|
+
children: $.map(({ label: r, icon: p }) => {
|
|
198
|
+
const { bgColor: g, textColor: b, viewBox: w } = o(p);
|
|
199
|
+
return /* @__PURE__ */ d(
|
|
200
|
+
P,
|
|
163
201
|
{
|
|
164
202
|
variant: "ghost",
|
|
165
203
|
className: "flex w-full justify-start",
|
|
166
204
|
type: "button",
|
|
167
|
-
onClick: f(
|
|
205
|
+
onClick: f(p),
|
|
168
206
|
children: [
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
|
|
207
|
+
/* @__PURE__ */ t(
|
|
208
|
+
s,
|
|
171
209
|
{
|
|
172
|
-
type:
|
|
210
|
+
type: p,
|
|
173
211
|
className: "text-primary-inverse-text",
|
|
174
212
|
classes: {
|
|
175
|
-
wrapper:
|
|
213
|
+
wrapper: m(
|
|
176
214
|
`flex h-5.5 w-5.5 items-center justify-center rounded-sm
|
|
177
|
-
${
|
|
178
|
-
${
|
|
215
|
+
${g ?? "bg-primary-inverse-hover-bg"}
|
|
216
|
+
${b ?? "text-primary-inverse-text"}`
|
|
179
217
|
)
|
|
180
218
|
},
|
|
181
|
-
viewBox:
|
|
219
|
+
viewBox: w
|
|
182
220
|
}
|
|
183
221
|
),
|
|
184
|
-
|
|
222
|
+
r
|
|
185
223
|
]
|
|
186
224
|
},
|
|
187
|
-
|
|
225
|
+
r
|
|
188
226
|
);
|
|
189
227
|
})
|
|
190
228
|
}
|
|
@@ -192,6 +230,6 @@ const j = [
|
|
|
192
230
|
] });
|
|
193
231
|
};
|
|
194
232
|
export {
|
|
195
|
-
|
|
233
|
+
he as InputContact
|
|
196
234
|
};
|
|
197
235
|
//# sourceMappingURL=components-input-contact-input-contact.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-input-contact-input-contact.js","sources":["../src/constants/contact-input.ts","../src/components/input-contact/input-contact.tsx"],"sourcesContent":["import type { TOption } from \"@/components/input-contact/input-contact\";\n\nexport const OPTIONS: TOption[] = [\n {\n label: \"Мобильный\",\n icon: \"phone\",\n },\n {\n label: \"Telegram\",\n icon: \"telegram\",\n },\n {\n label: \"WhatsApp\",\n icon: \"whats-app\",\n },\n {\n label: \"Max\",\n icon: \"max\",\n },\n {\n label: \"E-mail\",\n icon: \"mail\",\n },\n];\n","import { OPTIONS } from \"@/constants/contact-input\";\nimport { Button, Icon, InputField, cn, usePopupControls, type IconTypes } from \"@/index\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport type TOption = {\n label: string;\n icon: TypesChange;\n};\n\ntype TypesChange = Extract<\n IconTypes,\n \"telegram\" | \"whats-app\" | \"max\" | \"phone\" | \"mail\"\n>;\n\ntype BaseProps = {\n isValid?: boolean;\n label?: string;\n description?: string;\n classes?: {\n fieldset?: string;\n fieldgroup?: string;\n field?: string;\n container?: string;\n };\n onTypeChange?: (type: TypesChange) => void;\n};\n\ntype InputFieldProps = BaseProps & React.ComponentPropsWithRef<\"input\">;\n\n// TODO: заменить цвета\nconst iconStyles = (icon: IconTypes) => {\n switch (icon) {\n case \"max\":\n return {\n viewBox: \"0 0 16 16\",\n bgColor: \"bg-[linear-gradient(135deg,#9933DD_0%,#2831B9_50%,#44CCFF_100%)]\",\n };\n\n case \"telegram\":\n return {\n viewBox: \"0 0 17 17\",\n bgColor: \"bg-[#289AD2]\",\n };\n\n case \"whats-app\":\n return {\n viewBox: \"0 0 18 18\",\n bgColor: \"bg-[#00C202]\",\n textColor: \"text-[#00C202]\",\n };\n\n default:\n return {\n viewBox: \"0 0 24 24\",\n };\n }\n};\n\nexport const InputContact = (props: InputFieldProps) => {\n const [type, setType] = useState<TypesChange>(\"phone\");\n const { isOpened, openPopup, closePopup } = usePopupControls();\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) {\n closePopup();\n }\n };\n\n if (isOpened) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isOpened, closePopup]);\n\n const getPlaceholder = (type: TypesChange): string => {\n switch (type) {\n case \"phone\":\n return \"+7 (999) 999-99-99\";\n case \"telegram\":\n return \"@username\";\n case \"whats-app\":\n return \"+7 (999) 999-99-99\";\n case \"max\":\n return \"ID пользователя Max\";\n case \"mail\":\n return \"example@mail.com\";\n default:\n return \"Введите значение\";\n }\n };\n\n const handleTypeChange = (type: TypesChange) => {\n return () => {\n setType(type);\n props.onTypeChange?.(type);\n closePopup();\n };\n };\n\n return (\n <div className={cn(\"relative\", props.classes?.container)}>\n <InputField\n {...props}\n date={[\n {\n id: \"0\",\n position: \"inline-start\",\n component: (\n <Icon\n type={type}\n classes={{\n wrapper: cn(\n `flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]\n ${iconStyles(type).bgColor ?? \"bg-primary-inverse-hover-bg\"}\n ${iconStyles(type).textColor ?? \"text-primary-inverse-text\"}`,\n ),\n }}\n viewBox={iconStyles(type).viewBox}\n />\n ),\n },\n {\n id: \"1\",\n position: \"inline-end\",\n component: (\n <Icon\n type={isOpened ? \"chevron-up\" : \"chevron\"}\n className=\"cursor-pointer\"\n onClick={openPopup}\n />\n ),\n },\n ]}\n placeholder={getPlaceholder(type)}\n />\n\n {isOpened && (\n <div\n className=\"border-inp-hover-border bg-primary-bg absolute my-2 flex w-full\n flex-col rounded-xl border\"\n ref={wrapperRef}\n >\n {OPTIONS.map(({ label, icon }) => {\n const { bgColor, textColor, viewBox } = iconStyles(icon);\n\n return (\n <Button\n key={label}\n variant=\"ghost\"\n className=\"flex w-full justify-start\"\n type=\"button\"\n onClick={handleTypeChange(icon)}\n >\n <Icon\n type={icon}\n className=\"text-primary-inverse-text\"\n classes={{\n wrapper: cn(\n `flex h-5.5 w-5.5 items-center justify-center rounded-sm\n ${bgColor ?? \"bg-primary-inverse-hover-bg\"}\n ${textColor ?? \"text-primary-inverse-text\"}`,\n ),\n }}\n viewBox={viewBox}\n />\n\n {label}\n </Button>\n );\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport type { InputFieldProps as InputContactProps, TypesChange };\n"],"names":["OPTIONS","iconStyles","icon","InputContact","props","type","setType","useState","isOpened","openPopup","closePopup","usePopupControls","wrapperRef","useRef","useEffect","handleClickOutside","event","getPlaceholder","handleTypeChange","jsxs","cn","jsx","InputField","Icon","label","bgColor","textColor","viewBox","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,IAAqB;AAAA,EAChC;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAEV,GCOMC,IAAa,CAACC,MAAoB;AACtC,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IAGb,KAAK;AACH,aAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IAGb,KAAK;AACH,aAAO;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,QACT,WAAW;AAAA,MAAA;AAAA,IAGf;AACE,aAAO;AAAA,QACL,SAAS;AAAA,MAAA;AA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-input-contact-input-contact.js","sources":["../src/constants/contact-input.ts","../src/components/input-contact/input-contact.tsx"],"sourcesContent":["import type { TOption } from \"@/components/input-contact/input-contact\";\n\nexport const OPTIONS: TOption[] = [\n {\n label: \"Мобильный\",\n icon: \"phone\",\n },\n {\n label: \"Telegram\",\n icon: \"telegram\",\n },\n {\n label: \"WhatsApp\",\n icon: \"whats-app\",\n },\n {\n label: \"Max\",\n icon: \"max\",\n },\n {\n label: \"E-mail\",\n icon: \"mail\",\n },\n];\n","import { OPTIONS } from \"@/constants/contact-input\";\nimport {\n Button,\n Icon,\n InputField,\n InputPhone,\n cn,\n usePopupControls,\n type IconTypes,\n type InputPhoneProps,\n} from \"@/index\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport type TOption = {\n label: string;\n icon: TypesChange;\n};\n\ntype TypesChange = Extract<\n IconTypes,\n \"telegram\" | \"whats-app\" | \"max\" | \"phone\" | \"mail\"\n>;\n\ntype Props = {\n isValid?: boolean;\n label?: string;\n description?: string;\n classes?: {\n fieldset?: string;\n fieldgroup?: string;\n field?: string;\n container?: string;\n };\n onTypeChange?: (type: TypesChange) => void;\n inputProps: React.ComponentPropsWithRef<\"input\">;\n inputPhoneProps: InputPhoneProps;\n};\n\n// TODO: заменить цвета\nconst iconStyles = (icon: IconTypes) => {\n switch (icon) {\n case \"max\":\n return {\n viewBox: \"0 0 16 16\",\n bgColor: \"bg-[linear-gradient(135deg,#9933DD_0%,#2831B9_50%,#44CCFF_100%)]\",\n };\n\n case \"telegram\":\n return {\n viewBox: \"0 0 17 17\",\n bgColor: \"bg-[#289AD2]\",\n };\n\n case \"whats-app\":\n return {\n viewBox: \"0 0 18 18\",\n bgColor: \"bg-[#00C202]\",\n textColor: \"text-[#00C202]\",\n };\n\n default:\n return {\n viewBox: \"0 0 24 24\",\n };\n }\n};\n\nexport const InputContact = (props: Props) => {\n const { inputProps, inputPhoneProps } = props;\n\n const [type, setType] = useState<TypesChange>(\"phone\");\n const { isOpened, openPopup, closePopup } = usePopupControls();\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) {\n closePopup();\n }\n };\n\n if (isOpened) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isOpened, closePopup]);\n\n const getPlaceholder = (type: TypesChange): string => {\n switch (type) {\n case \"phone\":\n return \"+7 (999) 999-99-99\";\n case \"telegram\":\n return \"@username\";\n case \"whats-app\":\n return \"+7 (999) 999-99-99\";\n case \"max\":\n return \"ID пользователя Max\";\n case \"mail\":\n return \"example@mail.com\";\n default:\n return \"Введите значение\";\n }\n };\n\n const handleTypeChange = (type: TypesChange) => {\n return () => {\n setType(type);\n props.onTypeChange?.(type);\n closePopup();\n };\n };\n\n return (\n <div className={cn(\"relative\", props.classes?.container)}>\n {[\"telegram\", \"max\", \"mail\"].includes(type) ? (\n <InputField\n {...inputProps}\n date={[\n {\n id: \"0\",\n position: \"inline-start\",\n component: (\n <Icon\n type={type}\n classes={{\n wrapper: cn(\n `flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]\n ${iconStyles(type).bgColor ?? \"bg-primary-inverse-hover-bg\"}\n ${iconStyles(type).textColor ?? \"text-primary-inverse-text\"}`,\n ),\n }}\n viewBox={iconStyles(type).viewBox}\n />\n ),\n },\n {\n id: \"1\",\n position: \"inline-end\",\n component: (\n <Icon\n type={isOpened ? \"chevron-up\" : \"chevron\"}\n className=\"cursor-pointer\"\n onClick={openPopup}\n />\n ),\n },\n ]}\n placeholder={getPlaceholder(type)}\n />\n ) : (\n <InputPhone\n {...inputPhoneProps}\n date={[\n {\n id: \"0\",\n position: \"inline-start\",\n component: (\n <Icon\n type={type}\n classes={{\n wrapper: cn(\n `flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]\n ${iconStyles(type).bgColor ?? \"bg-primary-inverse-hover-bg\"}\n ${iconStyles(type).textColor ?? \"text-primary-inverse-text\"}`,\n ),\n }}\n viewBox={iconStyles(type).viewBox}\n />\n ),\n },\n {\n id: \"1\",\n position: \"inline-end\",\n component: (\n <Icon\n type={isOpened ? \"chevron-up\" : \"chevron\"}\n className=\"cursor-pointer\"\n onClick={openPopup}\n />\n ),\n },\n ]}\n placeholder={getPlaceholder(type)}\n />\n )}\n\n {isOpened && (\n <div\n className=\"border-inp-hover-border bg-primary-bg absolute my-2 flex w-full\n flex-col rounded-xl border\"\n ref={wrapperRef}\n >\n {OPTIONS.map(({ label, icon }) => {\n const { bgColor, textColor, viewBox } = iconStyles(icon);\n\n return (\n <Button\n key={label}\n variant=\"ghost\"\n className=\"flex w-full justify-start\"\n type=\"button\"\n onClick={handleTypeChange(icon)}\n >\n <Icon\n type={icon}\n className=\"text-primary-inverse-text\"\n classes={{\n wrapper: cn(\n `flex h-5.5 w-5.5 items-center justify-center rounded-sm\n ${bgColor ?? \"bg-primary-inverse-hover-bg\"}\n ${textColor ?? \"text-primary-inverse-text\"}`,\n ),\n }}\n viewBox={viewBox}\n />\n\n {label}\n </Button>\n );\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport type { Props as InputContactProps, TypesChange };\n"],"names":["OPTIONS","iconStyles","icon","InputContact","props","inputProps","inputPhoneProps","type","setType","useState","isOpened","openPopup","closePopup","usePopupControls","wrapperRef","useRef","useEffect","handleClickOutside","event","getPlaceholder","handleTypeChange","jsxs","cn","jsx","InputField","Icon","InputPhone","label","bgColor","textColor","viewBox","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,IAAqB;AAAA,EAChC;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER;AAAA,I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