brd-ui-kit 0.1.64 → 0.1.65
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/components/contact-input/contact-input.d.ts +1 -0
- package/dist/components-contact-input-contact-input.cjs +6 -6
- package/dist/components-contact-input-contact-input.cjs.map +1 -1
- package/dist/components-contact-input-contact-input.js +28 -28
- package/dist/components-contact-input-contact-input.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ type BaseProps = {
|
|
|
14
14
|
field?: string;
|
|
15
15
|
container?: string;
|
|
16
16
|
};
|
|
17
|
+
onTypeChange?: (type: TypesChange) => void;
|
|
17
18
|
};
|
|
18
19
|
type InputFieldProps = BaseProps & React.ComponentPropsWithRef<"input">;
|
|
19
20
|
export declare const ContactInput: (props: InputFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./brd-ui-kit.css');const r=require("react/jsx-runtime");;/* empty css */const c=require("./lib-utils.cjs");require("class-variance-authority");const l=require("react");require("./components-ui-badge-badge.styles.cjs");const
|
|
2
|
-
${s(
|
|
3
|
-
${s(
|
|
4
|
-
border`,ref:a,children:
|
|
5
|
-
${
|
|
6
|
-
${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./brd-ui-kit.css');const r=require("react/jsx-runtime");;/* empty css */const c=require("./lib-utils.cjs");require("class-variance-authority");const l=require("react");require("./components-ui-badge-badge.styles.cjs");const v=require("./components-ui-button-button.cjs");require("./components-ui-button-button.styles.cjs");require("./components-ui-card-card.cjs");require("./components-ui-checkbox-checkbox.cjs");const p=require("./components-ui-icon-icon.cjs");require("./components-ui-combobox-combobox.cjs");require("./components-ui-dialog-dialog.cjs");require("./components-ui-label-label.cjs");require("./components-ui-separator-separator.cjs");require("./components-ui-field-field.styles.cjs");require("./components-ui-input-input.styles.cjs");require("./components-ui-textarea-textarea.cjs");require("./components-ui-input-group-input-group.styles.cjs");require("./components-ui-navigation-item-navigation-item.styles.cjs");require("./components-ui-navigation-menu-navigation-menu.styles.cjs");require("./components-ui-pagination-pagination.cjs");require("./components-ui-progress-progress.cjs");require("./components-ui-radio-group-radio-group.cjs");require("./components-ui-switch-switch.cjs");require("./components-ui-table-table.cjs");require("./components-ui-tabs-tabs.cjs");require("./components-ui-tooltip-tooltip.cjs");require("./components-ui-typography-typography.styles.cjs");const w=require("./hooks-usePopupControls.cjs");require("lucide-react");require("./components-app-pagination-app-pagination.styles.cjs");require("./components-app-sidebar-app-sidebar.styles.cjs");const C=require("./components-input-field-input-field.cjs");require("./components-select-field-select-field.cjs");require("./lodash-kqhtUJfz.cjs");require("./chart-CgVfpT_X.cjs");require("./index-DGxwh2Ms.cjs");require("./index-fTTv8YY8.cjs");const f=[{label:"Мобильный",icon:"phone"},{label:"Telegram",icon:"telegram"},{label:"WhatsApp",icon:"whats-app"},{label:"Max",icon:"max"},{label:"E-mail",icon:"mail"}],s=t=>{switch(t){case"max":return{viewBox:"0 0 16 16",bgColor:"bg-[linear-gradient(135deg,#9933DD_0%,#2831B9_50%,#44CCFF_100%)]"};case"telegram":return{viewBox:"0 0 17 17",bgColor:"bg-[#289AD2]"};case"whats-app":return{viewBox:"0 0 18 18",bgColor:"bg-[#00C202]",textColor:"text-[#00C202]"};default:return{viewBox:"0 0 24 24"}}},y=t=>{const[n,m]=l.useState("phone"),{isOpened:o,openPopup:d,closePopup:u}=w.usePopupControls(),a=l.useRef(null);l.useEffect(()=>{const e=i=>{a.current&&!a.current.contains(i.target)&&u()};return o&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[o,u]);const q=e=>{switch(e){case"phone":return"+7 (999) 999-99-99";case"telegram":return"@username";case"whats-app":return"+7 (999) 999-99-99";case"max":return"ID пользователя Max";case"mail":return"example@mail.com";default:return"Введите значение"}},x=e=>()=>{m(e),t.onTypeChange?.(e),u()};return r.jsxs("div",{className:c.cn("relative",t.classes?.container),children:[r.jsx(C.InputField,{...t,date:[{id:"0",position:"inline-start",component:r.jsx(p.Icon,{type:n,classes:{wrapper:c.cn(`flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]
|
|
2
|
+
${s(n).bgColor??"bg-primary-inverse-hover-bg"}
|
|
3
|
+
${s(n).textColor??"text-primary-inverse-text"}`)},viewBox:s(n).viewBox})},{id:"1",position:"inline-end",component:r.jsx(p.Icon,{type:o?"chevron-up":"chevron",className:"cursor-pointer",onClick:d})}],placeholder:q(n)}),o&&r.jsx("div",{className:`border-inp-hover-border absolute my-2 flex w-full flex-col rounded-xl
|
|
4
|
+
border`,ref:a,children:f.map(({label:e,icon:i})=>{const{bgColor:h,textColor:b,viewBox:g}=s(i);return r.jsxs(v.Button,{variant:"ghost",className:"flex w-full justify-start",type:"button",onClick:x(i),children:[r.jsx(p.Icon,{type:i,className:"text-primary-inverse-text",classes:{wrapper:c.cn(`flex h-5.5 w-5.5 items-center justify-center rounded-sm
|
|
5
|
+
${h??"bg-primary-inverse-hover-bg"}
|
|
6
|
+
${b??"text-primary-inverse-text"}`)},viewBox:g}),e]},e)})})]})};exports.ContactInput=y;
|
|
7
7
|
//# sourceMappingURL=components-contact-input-contact-input.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-contact-input-contact-input.cjs","sources":["../src/constants/contact-input.ts","../src/components/contact-input/contact-input.tsx"],"sourcesContent":["import type { TOption } from \"@/components/contact-input/contact-input\";\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};\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 ContactInput = (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 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 absolute my-2 flex w-full flex-col rounded-xl\n 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 ContactInputProps };\n"],"names":["OPTIONS","iconStyles","icon","ContactInput","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":"w3DAEO,MAAMA,EAAqB,CAChC,CACE,MAAO,YACP,KAAM,OAAA,EAER,CACE,MAAO,WACP,KAAM,UAAA,EAER,CACE,MAAO,WACP,KAAM,WAAA,EAER,CACE,MAAO,MACP,KAAM,KAAA,EAER,CACE,MAAO,SACP,KAAM,MAAA,CAEV,
|
|
1
|
+
{"version":3,"file":"components-contact-input-contact-input.cjs","sources":["../src/constants/contact-input.ts","../src/components/contact-input/contact-input.tsx"],"sourcesContent":["import type { TOption } from \"@/components/contact-input/contact-input\";\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 ContactInput = (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 absolute my-2 flex w-full flex-col rounded-xl\n 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 ContactInputProps };\n"],"names":["OPTIONS","iconStyles","icon","ContactInput","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":"w3DAEO,MAAMA,EAAqB,CAChC,CACE,MAAO,YACP,KAAM,OAAA,EAER,CACE,MAAO,WACP,KAAM,UAAA,EAER,CACE,MAAO,WACP,KAAM,WAAA,EAER,CACE,MAAO,MACP,KAAM,KAAA,EAER,CACE,MAAO,SACP,KAAM,MAAA,CAEV,ECOMC,EAAcC,GAAoB,CACtC,OAAQA,EAAA,CACN,IAAK,MACH,MAAO,CACL,QAAS,YACT,QAAS,kEAAA,EAGb,IAAK,WACH,MAAO,CACL,QAAS,YACT,QAAS,cAAA,EAGb,IAAK,YACH,MAAO,CACL,QAAS,YACT,QAAS,eACT,UAAW,gBAAA,EAGf,QACE,MAAO,CACL,QAAS,WAAA,CACX,CAEN,EAEaC,EAAgBC,GAA2B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAsB,OAAO,EAC/C,CAAE,SAAAC,EAAU,UAAAC,EAAW,WAAAC,CAAA,EAAeC,EAAAA,iBAAA,EACtCC,EAAaC,EAAAA,OAAuB,IAAI,EAE9CC,EA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AAC,CAAE,MAAAY,EAAO,KAAAtB,KAAW,CAChC,KAAM,CAAE,QAAAuB,EAAS,UAAAC,EAAW,QAAAC,CAAA,EAAY1B,EAAWC,CAAI,EAEvD,OACEiB,EAAAA,KAACS,EAAAA,OAAA,CAEC,QAAQ,QACR,UAAU,4BACV,KAAK,SACL,QAASV,EAAiBhB,CAAI,EAE9B,SAAA,CAAAmB,EAAAA,IAACE,EAAAA,KAAA,CACC,KAAMrB,EACN,UAAU,4BACV,QAAS,CACP,QAASkB,EAAAA,GACP;AAAA,wBACEK,GAAW,6BAA6B;AAAA,wBACxCC,GAAa,2BAA2B,EAAA,CAC5C,EAEF,QAAAC,CAAA,CAAA,EAGDH,CAAA,CAAA,EAnBIA,CAAA,CAsBX,CAAC,CAAA,CAAA,CACH,EAEJ,CAEJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as c, jsx as
|
|
1
|
+
import { jsxs as c, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import './brd-ui-kit.css';/* empty css */
|
|
3
|
-
import { cn as
|
|
3
|
+
import { cn as s } from "./lib-utils.js";
|
|
4
4
|
import "class-variance-authority";
|
|
5
5
|
import { useState as b, useRef as w, useEffect as C } from "react";
|
|
6
6
|
import "./components-ui-badge-badge.styles.js";
|
|
@@ -58,8 +58,8 @@ const j = [
|
|
|
58
58
|
label: "E-mail",
|
|
59
59
|
icon: "mail"
|
|
60
60
|
}
|
|
61
|
-
], p = (
|
|
62
|
-
switch (
|
|
61
|
+
], p = (r) => {
|
|
62
|
+
switch (r) {
|
|
63
63
|
case "max":
|
|
64
64
|
return {
|
|
65
65
|
viewBox: "0 0 16 16",
|
|
@@ -81,11 +81,11 @@ const j = [
|
|
|
81
81
|
viewBox: "0 0 24 24"
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
}, ce = (
|
|
85
|
-
const [
|
|
84
|
+
}, ce = (r) => {
|
|
85
|
+
const [t, u] = b("phone"), { isOpened: n, openPopup: d, closePopup: m } = B(), a = w(null);
|
|
86
86
|
C(() => {
|
|
87
|
-
const e = (
|
|
88
|
-
|
|
87
|
+
const e = (o) => {
|
|
88
|
+
a.current && !a.current.contains(o.target) && m();
|
|
89
89
|
};
|
|
90
90
|
return n && document.addEventListener("mousedown", e), () => {
|
|
91
91
|
document.removeEventListener("mousedown", e);
|
|
@@ -107,36 +107,36 @@ const j = [
|
|
|
107
107
|
return "Введите значение";
|
|
108
108
|
}
|
|
109
109
|
}, f = (e) => () => {
|
|
110
|
-
u(e), m();
|
|
110
|
+
u(e), r.onTypeChange?.(e), m();
|
|
111
111
|
};
|
|
112
|
-
return /* @__PURE__ */ c("div", { className:
|
|
113
|
-
/* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ c("div", { className: s("relative", r.classes?.container), children: [
|
|
113
|
+
/* @__PURE__ */ i(
|
|
114
114
|
N,
|
|
115
115
|
{
|
|
116
|
-
...
|
|
116
|
+
...r,
|
|
117
117
|
date: [
|
|
118
118
|
{
|
|
119
119
|
id: "0",
|
|
120
120
|
position: "inline-start",
|
|
121
|
-
component: /* @__PURE__ */
|
|
121
|
+
component: /* @__PURE__ */ i(
|
|
122
122
|
l,
|
|
123
123
|
{
|
|
124
|
-
type:
|
|
124
|
+
type: t,
|
|
125
125
|
classes: {
|
|
126
|
-
wrapper:
|
|
126
|
+
wrapper: s(
|
|
127
127
|
`flex h-5.5 w-5.5 items-center justify-center rounded-sm p-[3.5px]
|
|
128
|
-
${p(
|
|
129
|
-
${p(
|
|
128
|
+
${p(t).bgColor ?? "bg-primary-inverse-hover-bg"}
|
|
129
|
+
${p(t).textColor ?? "text-primary-inverse-text"}`
|
|
130
130
|
)
|
|
131
131
|
},
|
|
132
|
-
viewBox: p(
|
|
132
|
+
viewBox: p(t).viewBox
|
|
133
133
|
}
|
|
134
134
|
)
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
id: "1",
|
|
138
138
|
position: "inline-end",
|
|
139
|
-
component: /* @__PURE__ */
|
|
139
|
+
component: /* @__PURE__ */ i(
|
|
140
140
|
l,
|
|
141
141
|
{
|
|
142
142
|
type: n ? "chevron-up" : "chevron",
|
|
@@ -146,32 +146,32 @@ const j = [
|
|
|
146
146
|
)
|
|
147
147
|
}
|
|
148
148
|
],
|
|
149
|
-
placeholder: x(
|
|
149
|
+
placeholder: x(t)
|
|
150
150
|
}
|
|
151
151
|
),
|
|
152
|
-
n && /* @__PURE__ */
|
|
152
|
+
n && /* @__PURE__ */ i(
|
|
153
153
|
"div",
|
|
154
154
|
{
|
|
155
155
|
className: `border-inp-hover-border absolute my-2 flex w-full flex-col rounded-xl
|
|
156
156
|
border`,
|
|
157
|
-
ref:
|
|
158
|
-
children: j.map(({ label: e, icon:
|
|
159
|
-
const { bgColor: h, textColor: v, viewBox: g } = p(
|
|
157
|
+
ref: a,
|
|
158
|
+
children: j.map(({ label: e, icon: o }) => {
|
|
159
|
+
const { bgColor: h, textColor: v, viewBox: g } = p(o);
|
|
160
160
|
return /* @__PURE__ */ c(
|
|
161
161
|
y,
|
|
162
162
|
{
|
|
163
163
|
variant: "ghost",
|
|
164
164
|
className: "flex w-full justify-start",
|
|
165
165
|
type: "button",
|
|
166
|
-
onClick: f(
|
|
166
|
+
onClick: f(o),
|
|
167
167
|
children: [
|
|
168
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ i(
|
|
169
169
|
l,
|
|
170
170
|
{
|
|
171
|
-
type:
|
|
171
|
+
type: o,
|
|
172
172
|
className: "text-primary-inverse-text",
|
|
173
173
|
classes: {
|
|
174
|
-
wrapper:
|
|
174
|
+
wrapper: s(
|
|
175
175
|
`flex h-5.5 w-5.5 items-center justify-center rounded-sm
|
|
176
176
|
${h ?? "bg-primary-inverse-hover-bg"}
|
|
177
177
|
${v ?? "text-primary-inverse-text"}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-contact-input-contact-input.js","sources":["../src/constants/contact-input.ts","../src/components/contact-input/contact-input.tsx"],"sourcesContent":["import type { TOption } from \"@/components/contact-input/contact-input\";\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};\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 ContactInput = (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 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 absolute my-2 flex w-full flex-col rounded-xl\n 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 ContactInputProps };\n"],"names":["OPTIONS","iconStyles","icon","ContactInput","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,
|
|
1
|
+
{"version":3,"file":"components-contact-input-contact-input.js","sources":["../src/constants/contact-input.ts","../src/components/contact-input/contact-input.tsx"],"sourcesContent":["import type { TOption } from \"@/components/contact-input/contact-input\";\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 ContactInput = (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 absolute my-2 flex w-full flex-col rounded-xl\n 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 ContactInputProps };\n"],"names":["OPTIONS","iconStyles","icon","ContactInput","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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