@purr-react-styled-components/components.select 0.0.7 → 0.0.9
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/index.cjs +82 -1
- package/dist/{_types.d.ts → index.d.cts} +10 -6
- package/dist/index.d.ts +51 -2
- package/dist/index.js +82 -4
- package/package.json +11 -9
- package/dist/_components/_menu.d.ts +0 -4
- package/dist/_components/_option.d.ts +0 -4
- package/dist/_components/index.d.ts +0 -4
- package/dist/_menu-M55fIE1j.cjs +0 -1
- package/dist/_menu-Oax72zVV.js +0 -29
- package/dist/_style.d.ts +0 -35
- package/dist/index-CPWuXrMI.js +0 -133
- package/dist/index-Du2pJQ-t.cjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';var c=require('styled-components'),utils_helpers=require('@purr-react-styled-components/utils.helpers'),x=require('clsx'),n=require('react'),components_portal=require('@purr-core/components.portal'),re=require('@purr-core/hooks.not-click-on-elements'),se=require('@purr-core/hooks.sync-state-with-props');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var c__default=/*#__PURE__*/_interopDefault(c);var x__default=/*#__PURE__*/_interopDefault(x);var n__default=/*#__PURE__*/_interopDefault(n);var re__default=/*#__PURE__*/_interopDefault(re);var se__default=/*#__PURE__*/_interopDefault(se);var _=Object.defineProperty;var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var J=(e,t)=>{for(var o in t)_(e,o,{get:t[o],enumerable:true});};var Q,r,b=w(()=>{Q=e=>e.$variant==="standard"?c.css`
|
|
2
|
+
padding: 0px 35px 0px 0px;
|
|
3
|
+
`:c.css`
|
|
4
|
+
padding: 0px 35px 0px 14px;
|
|
5
|
+
`,r={Container:c__default.default.div`
|
|
6
|
+
position: relative;
|
|
7
|
+
width: ${({$fullWidth:e})=>e?"100%":"fit-content"};
|
|
8
|
+
min-width: 210px;
|
|
9
|
+
`,Option:c__default.default.span`
|
|
10
|
+
display: block;
|
|
11
|
+
transition: all 200ms ease-in-out;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
padding: 0px 14px;
|
|
14
|
+
height: 36px;
|
|
15
|
+
line-height: 36px;
|
|
16
|
+
background-color: ${({$selected:e,$disabled:t})=>t?"#121212":e?"#90caf929":"transparent"};
|
|
17
|
+
color: ${({$disabled:e})=>e?"#ffffff80":"#ffffff"};
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
text-overflow: ellipsis;
|
|
21
|
+
font-family: "Verdana", sans-serif;
|
|
22
|
+
font-size: 16px;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background-color: #ffffff14;
|
|
26
|
+
}
|
|
27
|
+
`,OptionGroup:c__default.default.div`
|
|
28
|
+
position: absolute;
|
|
29
|
+
display: ${({$isShowed:e})=>e?"block":"none"};
|
|
30
|
+
top: ${({$position:e})=>e?.top||0}px;
|
|
31
|
+
left: ${({$position:e})=>e?.left||0}px;
|
|
32
|
+
width: ${({$position:e})=>e?.width||0}px;
|
|
33
|
+
padding: 6px 0px;
|
|
34
|
+
z-index: 999;
|
|
35
|
+
background-color: rgb(18, 18, 18);
|
|
36
|
+
min-width: 120px;
|
|
37
|
+
border-radius: 4px;
|
|
38
|
+
box-shadow:
|
|
39
|
+
rgb(0 0 0 / 20%) 0px 5px 5px -3px,
|
|
40
|
+
rgb(0 0 0 / 14%) 0px 8px 10px 1px,
|
|
41
|
+
rgb(0 0 0 / 12%) 0px 3px 14px 2px;
|
|
42
|
+
background-image: linear-gradient(#ffffff1f, #ffffff1f);
|
|
43
|
+
`,Box:c__default.default.div`
|
|
44
|
+
transition: all 200ms ease-in-out;
|
|
45
|
+
position: relative;
|
|
46
|
+
width: ${({$fullWidth:e})=>e?"100%":"210px"};
|
|
47
|
+
height: 56px;
|
|
48
|
+
${utils_helpers.getVariantStyle};
|
|
49
|
+
`,InnerBox:c__default.default.span`
|
|
50
|
+
position: absolute;
|
|
51
|
+
transition: all 200ms ease-in-out;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: ${({$hasLabel:e})=>e?"44px":"56px"};
|
|
55
|
+
line-height: ${({$hasLabel:e})=>e?"44px":"56px"};
|
|
56
|
+
top: ${({$hasLabel:e})=>e?"12px":"0px"};
|
|
57
|
+
left: 0px;
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
text-overflow: ellipsis;
|
|
62
|
+
color: ${({$disabled:e})=>e?"#ffffff80":"#ffffff"};
|
|
63
|
+
font-family: "Verdana", sans-serif;
|
|
64
|
+
font-size: 16px;
|
|
65
|
+
${Q};
|
|
66
|
+
|
|
67
|
+
&:focus-visible {
|
|
68
|
+
outline: none;
|
|
69
|
+
}
|
|
70
|
+
`,FakeSelect:c__default.default.select`
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
opacity: 0;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
`,PostAdornmentContentWrapper:c__default.default.div`
|
|
76
|
+
display: flex;
|
|
77
|
+
transition: all 350ms ease-in-out;
|
|
78
|
+
width: 20px;
|
|
79
|
+
height: 20px;
|
|
80
|
+
color: ${({$disabled:e})=>e?"#ffffff80":"#ffffff"};
|
|
81
|
+
transform: ${({$isShowed:e})=>e?"rotate(180deg)":"none"};
|
|
82
|
+
`};});var y,C=w(()=>{b();y=n.memo(({value:e,displayedValue:t,label:o,disabled:l,htmlAttributes:s,handleSelectOption:u})=>n__default.default.createElement(r.Option,{...s,$selected:e===t,$disabled:l,key:e,className:x__default.default("select-option",e===t&&"select-option--selected",l&&"select-option--disabled"),onClick:u(e),title:typeof o=="string"?o:void 0},o));y.displayName="SelectOption";});var L={};J(L,{SelectMenu:()=>T});var T,H=w(()=>{b();C();T=n.forwardRef(({options:e,position:t,isShowed:o,currentValue:l,optionGroupClassName:s,htmlAttributes:u,selectOption:a},i)=>{let $=n.useMemo(()=>e.map(p=>n__default.default.createElement(y,{key:p.value,value:p.value,displayedValue:l,label:p.label,disabled:!!p.disabled,htmlAttributes:p.htmlAttributes,handleSelectOption:a})),[l,e,a]);return n__default.default.createElement(r.OptionGroup,{...u,$position:t,$isShowed:o,ref:i,className:x__default.default("select-options",!!t?.top&&`select-options--position-top-${t.top}`,!!t?.left&&`select-options--position-left-${t.left}`,!!t?.height&&`select-options--position-height-${t.height}`,!!t?.width&&`select-options--position-width-${t.width}`,o&&"select-options--showed",s)},$)});T.displayName="SelectMenu";});b();var pe=n.lazy(()=>import('@purr-react-styled-components/components.icon').then(e=>({default:e.Icon}))),ae=n.lazy(()=>import('@purr-react-styled-components/components.post-adornment').then(e=>({default:e.PostAdornment}))),fe=n.lazy(()=>Promise.resolve().then(()=>(H(),L)).then(e=>({default:e.SelectMenu}))),de=(e,t=true)=>{let o=e.current?.getBoundingClientRect();return {left:o?.x||0,top:(o?.y||0)+(t&&window?.scrollY||0),width:o?.width||0,height:o?.height||0}},ce=n.forwardRef(({optionGroupClassName:e,options:t,value:o,variant:l="standard",postAdornmentProps:s,className:u,fullWidth:a=false,disabled:i=false,required:$=false,error:p=null,isStandalone:A=false,tabIndex:W=-1,menuHtmlAttributes:z,htmlAttributes:D,onChange:M},me)=>{let S=n.useRef(null),P=n.useRef(null),[f,h]=n.useState(false),[G,j]=n.useState(null),{currentValue:k,setCurrentValue:I}=se__default.default(o,A);re__default.default([S,P],()=>{f&&h(false);});let F=m=>{if(m.preventDefault(),!i){if(!f){let d=de(S);j({...d,top:d.top+d.height});}h(d=>!d);}},g=t.find(m=>m.value===k),q=n.useMemo(()=>n__default.default.createElement(r.PostAdornmentContentWrapper,{$isShowed:f,$disabled:i,className:x__default.default("select-post-adornment-content",f&&"select-post-adornment-content--showed",i&&"select-post-adornment-content--disabled")},s?.children??n__default.default.createElement(n.Suspense,null,n__default.default.createElement(pe,{name:"chevron-down"}))),[i,f,s?.children]),Y=n.useCallback(m=>d=>{M?.(m,d),h(false),I(m);},[M,I,h]);return n__default.default.createElement(r.Container,{...D,$fullWidth:a,className:x__default.default("select",a&&"select--fullWidth",u)},n__default.default.createElement(r.Box,{$variant:l,$disabled:i,$fullWidth:a,$isError:!!p,ref:S,onClick:F,tabIndex:W,className:x__default.default("select-box",a&&"select-box--full-width",i&&"select-box--disabled",!!p&&"select-box--error",`select-box--variant-${l}`)},n__default.default.createElement(r.FakeSelect,{required:$,disabled:i}),n__default.default.createElement(r.InnerBox,{$hasLabel:true,$variant:l,$disabled:i,className:x__default.default("select-inner-box",`select-inner-box--variant-${l}`,i&&"select-inner-box--disabled"),title:typeof g?.label=="string"?g?.label:void 0},g?.label),n__default.default.createElement(n.Suspense,null,!!s?.children&&n__default.default.createElement(ae,{...s,variant:l},q))),n__default.default.createElement(components_portal.Portal,{className:x__default.default("portal-select",e)},n__default.default.createElement(n.Suspense,null,f&&n__default.default.createElement(fe,{ref:P,options:t,position:G,isShowed:f,optionGroupClassName:e,currentValue:k,htmlAttributes:z,selectOption:Y}))))});ce.displayName="Select";exports.Select=ce;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { HTMLAttributes, MouseEvent, MouseEventHandler
|
|
1
|
+
import React, { ReactNode, HTMLAttributes, MouseEvent, MouseEventHandler } from 'react';
|
|
2
2
|
import { FieldError } from 'react-hook-form';
|
|
3
3
|
import { IExtendable } from '@purr-core/utils.definitions';
|
|
4
4
|
import { IPostAdornmentProps } from '@purr-react-styled-components/components.post-adornment';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface ISelectOption {
|
|
7
7
|
value: string;
|
|
8
8
|
label: ReactNode;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
htmlAttributes?: HTMLAttributes<HTMLSpanElement> & IExtendable;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface ISelectOptionProps extends ISelectOption {
|
|
13
13
|
displayedValue?: string;
|
|
14
14
|
handleSelectOption: (value: string) => MouseEventHandler<HTMLSpanElement>;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
type TSelectVariant = "standard" | "outlined" | "filled";
|
|
17
|
+
interface ISelectMenuProps {
|
|
18
18
|
options: ISelectOption[];
|
|
19
19
|
position: {
|
|
20
20
|
left: number;
|
|
@@ -28,7 +28,7 @@ export interface ISelectMenuProps {
|
|
|
28
28
|
htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
|
|
29
29
|
selectOption: (value: string) => MouseEventHandler<HTMLSpanElement>;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
interface ISelectProps {
|
|
32
32
|
optionGroupClassName?: string;
|
|
33
33
|
options: ISelectOption[];
|
|
34
34
|
value?: string;
|
|
@@ -45,3 +45,7 @@ export interface ISelectProps {
|
|
|
45
45
|
isStandalone?: boolean;
|
|
46
46
|
onChange?: (value: string, e: MouseEvent<HTMLSpanElement>) => void;
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
declare const Select: React.ForwardRefExoticComponent<ISelectProps & React.RefAttributes<HTMLSelectElement>>;
|
|
50
|
+
|
|
51
|
+
export { type ISelectMenuProps, type ISelectOption, type ISelectOptionProps, type ISelectProps, Select, type TSelectVariant };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode, HTMLAttributes, MouseEvent, MouseEventHandler } from 'react';
|
|
2
|
+
import { FieldError } from 'react-hook-form';
|
|
3
|
+
import { IExtendable } from '@purr-core/utils.definitions';
|
|
4
|
+
import { IPostAdornmentProps } from '@purr-react-styled-components/components.post-adornment';
|
|
5
|
+
|
|
6
|
+
interface ISelectOption {
|
|
7
|
+
value: string;
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
htmlAttributes?: HTMLAttributes<HTMLSpanElement> & IExtendable;
|
|
11
|
+
}
|
|
12
|
+
interface ISelectOptionProps extends ISelectOption {
|
|
13
|
+
displayedValue?: string;
|
|
14
|
+
handleSelectOption: (value: string) => MouseEventHandler<HTMLSpanElement>;
|
|
15
|
+
}
|
|
16
|
+
type TSelectVariant = "standard" | "outlined" | "filled";
|
|
17
|
+
interface ISelectMenuProps {
|
|
18
|
+
options: ISelectOption[];
|
|
19
|
+
position: {
|
|
20
|
+
left: number;
|
|
21
|
+
top: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
} | null;
|
|
25
|
+
isShowed: boolean;
|
|
26
|
+
currentValue?: string;
|
|
27
|
+
optionGroupClassName?: string;
|
|
28
|
+
htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
|
|
29
|
+
selectOption: (value: string) => MouseEventHandler<HTMLSpanElement>;
|
|
30
|
+
}
|
|
31
|
+
interface ISelectProps {
|
|
32
|
+
optionGroupClassName?: string;
|
|
33
|
+
options: ISelectOption[];
|
|
34
|
+
value?: string;
|
|
35
|
+
variant?: TSelectVariant;
|
|
36
|
+
postAdornmentProps?: IPostAdornmentProps;
|
|
37
|
+
htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
|
|
38
|
+
menuHtmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
|
|
39
|
+
tabIndex?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
fullWidth?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
error?: FieldError;
|
|
45
|
+
isStandalone?: boolean;
|
|
46
|
+
onChange?: (value: string, e: MouseEvent<HTMLSpanElement>) => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare const Select: React.ForwardRefExoticComponent<ISelectProps & React.RefAttributes<HTMLSelectElement>>;
|
|
50
|
+
|
|
51
|
+
export { type ISelectMenuProps, type ISelectOption, type ISelectOptionProps, type ISelectProps, Select, type TSelectVariant };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import c,{css}from'styled-components';import {getVariantStyle}from'@purr-react-styled-components/utils.helpers';import x from'clsx';import n,{lazy,forwardRef,useRef,useState,useMemo,Suspense,useCallback,memo}from'react';import {Portal}from'@purr-core/components.portal';import re from'@purr-core/hooks.not-click-on-elements';import se from'@purr-core/hooks.sync-state-with-props';var _=Object.defineProperty;var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var J=(e,t)=>{for(var o in t)_(e,o,{get:t[o],enumerable:true});};var Q,r,b=w(()=>{Q=e=>e.$variant==="standard"?css`
|
|
2
|
+
padding: 0px 35px 0px 0px;
|
|
3
|
+
`:css`
|
|
4
|
+
padding: 0px 35px 0px 14px;
|
|
5
|
+
`,r={Container:c.div`
|
|
6
|
+
position: relative;
|
|
7
|
+
width: ${({$fullWidth:e})=>e?"100%":"fit-content"};
|
|
8
|
+
min-width: 210px;
|
|
9
|
+
`,Option:c.span`
|
|
10
|
+
display: block;
|
|
11
|
+
transition: all 200ms ease-in-out;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
padding: 0px 14px;
|
|
14
|
+
height: 36px;
|
|
15
|
+
line-height: 36px;
|
|
16
|
+
background-color: ${({$selected:e,$disabled:t})=>t?"#121212":e?"#90caf929":"transparent"};
|
|
17
|
+
color: ${({$disabled:e})=>e?"#ffffff80":"#ffffff"};
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
text-overflow: ellipsis;
|
|
21
|
+
font-family: "Verdana", sans-serif;
|
|
22
|
+
font-size: 16px;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background-color: #ffffff14;
|
|
26
|
+
}
|
|
27
|
+
`,OptionGroup:c.div`
|
|
28
|
+
position: absolute;
|
|
29
|
+
display: ${({$isShowed:e})=>e?"block":"none"};
|
|
30
|
+
top: ${({$position:e})=>e?.top||0}px;
|
|
31
|
+
left: ${({$position:e})=>e?.left||0}px;
|
|
32
|
+
width: ${({$position:e})=>e?.width||0}px;
|
|
33
|
+
padding: 6px 0px;
|
|
34
|
+
z-index: 999;
|
|
35
|
+
background-color: rgb(18, 18, 18);
|
|
36
|
+
min-width: 120px;
|
|
37
|
+
border-radius: 4px;
|
|
38
|
+
box-shadow:
|
|
39
|
+
rgb(0 0 0 / 20%) 0px 5px 5px -3px,
|
|
40
|
+
rgb(0 0 0 / 14%) 0px 8px 10px 1px,
|
|
41
|
+
rgb(0 0 0 / 12%) 0px 3px 14px 2px;
|
|
42
|
+
background-image: linear-gradient(#ffffff1f, #ffffff1f);
|
|
43
|
+
`,Box:c.div`
|
|
44
|
+
transition: all 200ms ease-in-out;
|
|
45
|
+
position: relative;
|
|
46
|
+
width: ${({$fullWidth:e})=>e?"100%":"210px"};
|
|
47
|
+
height: 56px;
|
|
48
|
+
${getVariantStyle};
|
|
49
|
+
`,InnerBox:c.span`
|
|
50
|
+
position: absolute;
|
|
51
|
+
transition: all 200ms ease-in-out;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: ${({$hasLabel:e})=>e?"44px":"56px"};
|
|
55
|
+
line-height: ${({$hasLabel:e})=>e?"44px":"56px"};
|
|
56
|
+
top: ${({$hasLabel:e})=>e?"12px":"0px"};
|
|
57
|
+
left: 0px;
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
text-overflow: ellipsis;
|
|
62
|
+
color: ${({$disabled:e})=>e?"#ffffff80":"#ffffff"};
|
|
63
|
+
font-family: "Verdana", sans-serif;
|
|
64
|
+
font-size: 16px;
|
|
65
|
+
${Q};
|
|
66
|
+
|
|
67
|
+
&:focus-visible {
|
|
68
|
+
outline: none;
|
|
69
|
+
}
|
|
70
|
+
`,FakeSelect:c.select`
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
opacity: 0;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
`,PostAdornmentContentWrapper:c.div`
|
|
76
|
+
display: flex;
|
|
77
|
+
transition: all 350ms ease-in-out;
|
|
78
|
+
width: 20px;
|
|
79
|
+
height: 20px;
|
|
80
|
+
color: ${({$disabled:e})=>e?"#ffffff80":"#ffffff"};
|
|
81
|
+
transform: ${({$isShowed:e})=>e?"rotate(180deg)":"none"};
|
|
82
|
+
`};});var y,C=w(()=>{b();y=memo(({value:e,displayedValue:t,label:o,disabled:l,htmlAttributes:s,handleSelectOption:u})=>n.createElement(r.Option,{...s,$selected:e===t,$disabled:l,key:e,className:x("select-option",e===t&&"select-option--selected",l&&"select-option--disabled"),onClick:u(e),title:typeof o=="string"?o:void 0},o));y.displayName="SelectOption";});var L={};J(L,{SelectMenu:()=>T});var T,H=w(()=>{b();C();T=forwardRef(({options:e,position:t,isShowed:o,currentValue:l,optionGroupClassName:s,htmlAttributes:u,selectOption:a},i)=>{let $=useMemo(()=>e.map(p=>n.createElement(y,{key:p.value,value:p.value,displayedValue:l,label:p.label,disabled:!!p.disabled,htmlAttributes:p.htmlAttributes,handleSelectOption:a})),[l,e,a]);return n.createElement(r.OptionGroup,{...u,$position:t,$isShowed:o,ref:i,className:x("select-options",!!t?.top&&`select-options--position-top-${t.top}`,!!t?.left&&`select-options--position-left-${t.left}`,!!t?.height&&`select-options--position-height-${t.height}`,!!t?.width&&`select-options--position-width-${t.width}`,o&&"select-options--showed",s)},$)});T.displayName="SelectMenu";});b();var pe=lazy(()=>import('@purr-react-styled-components/components.icon').then(e=>({default:e.Icon}))),ae=lazy(()=>import('@purr-react-styled-components/components.post-adornment').then(e=>({default:e.PostAdornment}))),fe=lazy(()=>Promise.resolve().then(()=>(H(),L)).then(e=>({default:e.SelectMenu}))),de=(e,t=true)=>{let o=e.current?.getBoundingClientRect();return {left:o?.x||0,top:(o?.y||0)+(t&&window?.scrollY||0),width:o?.width||0,height:o?.height||0}},ce=forwardRef(({optionGroupClassName:e,options:t,value:o,variant:l="standard",postAdornmentProps:s,className:u,fullWidth:a=false,disabled:i=false,required:$=false,error:p=null,isStandalone:A=false,tabIndex:W=-1,menuHtmlAttributes:z,htmlAttributes:D,onChange:M},me)=>{let S=useRef(null),P=useRef(null),[f,h]=useState(false),[G,j]=useState(null),{currentValue:k,setCurrentValue:I}=se(o,A);re([S,P],()=>{f&&h(false);});let F=m=>{if(m.preventDefault(),!i){if(!f){let d=de(S);j({...d,top:d.top+d.height});}h(d=>!d);}},g=t.find(m=>m.value===k),q=useMemo(()=>n.createElement(r.PostAdornmentContentWrapper,{$isShowed:f,$disabled:i,className:x("select-post-adornment-content",f&&"select-post-adornment-content--showed",i&&"select-post-adornment-content--disabled")},s?.children??n.createElement(Suspense,null,n.createElement(pe,{name:"chevron-down"}))),[i,f,s?.children]),Y=useCallback(m=>d=>{M?.(m,d),h(false),I(m);},[M,I,h]);return n.createElement(r.Container,{...D,$fullWidth:a,className:x("select",a&&"select--fullWidth",u)},n.createElement(r.Box,{$variant:l,$disabled:i,$fullWidth:a,$isError:!!p,ref:S,onClick:F,tabIndex:W,className:x("select-box",a&&"select-box--full-width",i&&"select-box--disabled",!!p&&"select-box--error",`select-box--variant-${l}`)},n.createElement(r.FakeSelect,{required:$,disabled:i}),n.createElement(r.InnerBox,{$hasLabel:true,$variant:l,$disabled:i,className:x("select-inner-box",`select-inner-box--variant-${l}`,i&&"select-inner-box--disabled"),title:typeof g?.label=="string"?g?.label:void 0},g?.label),n.createElement(Suspense,null,!!s?.children&&n.createElement(ae,{...s,variant:l},q))),n.createElement(Portal,{className:x("portal-select",e)},n.createElement(Suspense,null,f&&n.createElement(fe,{ref:P,options:t,position:G,isShowed:f,optionGroupClassName:e,currentValue:k,htmlAttributes:z,selectOption:Y}))))});ce.displayName="Select";export{ce as Select};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purr-react-styled-components/components.select",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"styled-components": "*",
|
|
27
27
|
"clsx": "*",
|
|
28
28
|
"react-hook-form": "*",
|
|
29
|
-
"@purr-react-styled-components/components.post-adornment": "0.0.
|
|
30
|
-
"@purr-react-styled-components/utils.helpers": "0.0.
|
|
31
|
-
"@purr-core/utils.definitions": "0.0.
|
|
32
|
-
"@purr-
|
|
33
|
-
"@purr-core/
|
|
34
|
-
"@purr-core/hooks.
|
|
35
|
-
"@purr-core/hooks.
|
|
36
|
-
"@purr-
|
|
29
|
+
"@purr-react-styled-components/components.post-adornment": "0.0.9",
|
|
30
|
+
"@purr-react-styled-components/utils.helpers": "0.0.8",
|
|
31
|
+
"@purr-core/utils.definitions": "0.0.12",
|
|
32
|
+
"@purr-react-styled-components/components.icon": "0.0.9",
|
|
33
|
+
"@purr-core/components.portal": "0.0.9",
|
|
34
|
+
"@purr-core/hooks.block": "0.0.11",
|
|
35
|
+
"@purr-core/hooks.not-click-on-elements": "0.0.9",
|
|
36
|
+
"@purr-core/hooks.sync-state-with-props": "0.0.9"
|
|
37
37
|
},
|
|
38
38
|
"author": "@DinhThienPhuc",
|
|
39
39
|
"license": "ISC",
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "vite build --watch",
|
|
44
44
|
"build": "tsc && vite build",
|
|
45
|
+
"build:vite": "tsc && vite build",
|
|
46
|
+
"build:tsup": "tsup",
|
|
45
47
|
"lint": "eslint . --ext ts,tsx --max-warnings 0"
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { ISelectOptionProps } from '../_types';
|
|
3
|
-
|
|
4
|
-
export declare const SelectOption: React.MemoExoticComponent<({ value, displayedValue, label, disabled, htmlAttributes, handleSelectOption, }: ISelectOptionProps) => React.JSX.Element>;
|
package/dist/_menu-M55fIE1j.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("clsx"),s=require("react"),n=require("./index-Du2pJQ-t.cjs"),S=s.memo(({value:t,displayedValue:e,label:l,disabled:c,htmlAttributes:d,handleSelectOption:a})=>s.createElement(n.Styled.Option,{...d,$selected:t===e,$disabled:c,key:t,className:m("select-option",t===e&&"select-option--selected",c&&"select-option--disabled"),onClick:a(t),title:typeof l=="string"?l:void 0},l));S.displayName="SelectOption";const y=s.forwardRef(({options:t,position:e,isShowed:l,currentValue:c,optionGroupClassName:d,htmlAttributes:a,selectOption:u},$)=>{const b=s.useMemo(()=>t.map(r=>h.jsx(S,{value:r.value,displayedValue:c,label:r.label,disabled:!!r.disabled,htmlAttributes:r.htmlAttributes,handleSelectOption:u},r.value)),[c,t,u]);return h.jsx(n.Styled.OptionGroup,{...a,$position:e,$isShowed:l,ref:$,className:m("select-options",!!(e!=null&&e.top)&&`select-options--position-top-${e.top}`,!!(e!=null&&e.left)&&`select-options--position-left-${e.left}`,!!(e!=null&&e.height)&&`select-options--position-height-${e.height}`,!!(e!=null&&e.width)&&`select-options--position-width-${e.width}`,l&&"select-options--showed",d),children:b})});y.displayName="SelectMenu";exports.SelectMenu=y;
|
package/dist/_menu-Oax72zVV.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import h from "clsx";
|
|
3
|
-
import { memo as b, createElement as w, forwardRef as y, useMemo as O } from "react";
|
|
4
|
-
import { S as f } from "./index-CPWuXrMI.js";
|
|
5
|
-
const $ = b(({
|
|
6
|
-
value: t,
|
|
7
|
-
displayedValue: e,
|
|
8
|
-
label: l,
|
|
9
|
-
disabled: c,
|
|
10
|
-
htmlAttributes: d,
|
|
11
|
-
handleSelectOption: m
|
|
12
|
-
}) => /* @__PURE__ */ w(f.Option, { ...d, $selected: t === e, $disabled: c, key: t, className: h("select-option", t === e && "select-option--selected", c && "select-option--disabled"), onClick: m(t), title: typeof l == "string" ? l : void 0 }, l));
|
|
13
|
-
$.displayName = "SelectOption";
|
|
14
|
-
const g = y(({
|
|
15
|
-
options: t,
|
|
16
|
-
position: e,
|
|
17
|
-
isShowed: l,
|
|
18
|
-
currentValue: c,
|
|
19
|
-
optionGroupClassName: d,
|
|
20
|
-
htmlAttributes: m,
|
|
21
|
-
selectOption: s
|
|
22
|
-
}, u) => {
|
|
23
|
-
const S = O(() => t.map((r) => /* @__PURE__ */ a($, { value: r.value, displayedValue: c, label: r.label, disabled: !!r.disabled, htmlAttributes: r.htmlAttributes, handleSelectOption: s }, r.value)), [c, t, s]);
|
|
24
|
-
return /* @__PURE__ */ a(f.OptionGroup, { ...m, $position: e, $isShowed: l, ref: u, className: h("select-options", !!(e != null && e.top) && `select-options--position-top-${e.top}`, !!(e != null && e.left) && `select-options--position-left-${e.left}`, !!(e != null && e.height) && `select-options--position-height-${e.height}`, !!(e != null && e.width) && `select-options--position-width-${e.width}`, l && "select-options--showed", d), children: S });
|
|
25
|
-
});
|
|
26
|
-
g.displayName = "SelectMenu";
|
|
27
|
-
export {
|
|
28
|
-
g as SelectMenu
|
|
29
|
-
};
|
package/dist/_style.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { TSelectVariant } from './_types';
|
|
2
|
-
|
|
3
|
-
export declare const Styled: {
|
|
4
|
-
Container: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
5
|
-
$fullWidth: boolean;
|
|
6
|
-
}>> & string;
|
|
7
|
-
Option: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
8
|
-
$selected: boolean;
|
|
9
|
-
$disabled?: boolean;
|
|
10
|
-
}>> & string;
|
|
11
|
-
OptionGroup: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
12
|
-
$isShowed: boolean;
|
|
13
|
-
$position: {
|
|
14
|
-
left: number;
|
|
15
|
-
top: number;
|
|
16
|
-
width: number;
|
|
17
|
-
} | null;
|
|
18
|
-
}>> & string;
|
|
19
|
-
Box: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
20
|
-
$fullWidth: boolean;
|
|
21
|
-
$disabled: boolean;
|
|
22
|
-
$variant: TSelectVariant;
|
|
23
|
-
$isError: boolean;
|
|
24
|
-
}>> & string;
|
|
25
|
-
InnerBox: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
26
|
-
$hasLabel: boolean;
|
|
27
|
-
$variant: TSelectVariant;
|
|
28
|
-
$disabled: boolean;
|
|
29
|
-
}>> & string;
|
|
30
|
-
FakeSelect: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, never>> & string;
|
|
31
|
-
PostAdornmentContentWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
32
|
-
$isShowed: boolean;
|
|
33
|
-
$disabled?: boolean;
|
|
34
|
-
}>> & string;
|
|
35
|
-
};
|
package/dist/index-CPWuXrMI.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { jsx as i, jsxs as v } from "react/jsx-runtime";
|
|
2
|
-
import p from "clsx";
|
|
3
|
-
import { lazy as b, forwardRef as L, useRef as N, useState as C, useMemo as D, Suspense as w, useCallback as Y } from "react";
|
|
4
|
-
import { Portal as $ } from "@purr-core/components.portal";
|
|
5
|
-
import q from "@purr-core/hooks.not-click-on-elements";
|
|
6
|
-
import H from "@purr-core/hooks.sync-state-with-props";
|
|
7
|
-
import c, { css as I } from "styled-components";
|
|
8
|
-
import { getVariantStyle as J } from "@purr-react-styled-components/utils.helpers";
|
|
9
|
-
const K = (e) => e.$variant === "standard" ? I(["padding:0px 35px 0px 0px;"]) : I(["padding:0px 35px 0px 14px;"]), x = {
|
|
10
|
-
Container: c.div.withConfig({
|
|
11
|
-
displayName: "_style__Container",
|
|
12
|
-
componentId: "sc-1ikgo6d-0"
|
|
13
|
-
})(["position:relative;width:", ";min-width:210px;"], ({
|
|
14
|
-
$fullWidth: e
|
|
15
|
-
}) => e ? "100%" : "fit-content"),
|
|
16
|
-
Option: c.span.withConfig({
|
|
17
|
-
displayName: "_style__Option",
|
|
18
|
-
componentId: "sc-1ikgo6d-1"
|
|
19
|
-
})(["display:block;transition:all 200ms ease-in-out;cursor:pointer;padding:0px 14px;height:36px;line-height:36px;background-color:", ";color:", ';overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-family:"Verdana",sans-serif;font-size:16px;&:hover{background-color:#ffffff14;}'], ({
|
|
20
|
-
$selected: e,
|
|
21
|
-
$disabled: s
|
|
22
|
-
}) => s ? "#121212" : e ? "#90caf929" : "transparent", ({
|
|
23
|
-
$disabled: e
|
|
24
|
-
}) => e ? "#ffffff80" : "#ffffff"),
|
|
25
|
-
OptionGroup: c.div.withConfig({
|
|
26
|
-
displayName: "_style__OptionGroup",
|
|
27
|
-
componentId: "sc-1ikgo6d-2"
|
|
28
|
-
})(["position:absolute;display:", ";top:", "px;left:", "px;width:", "px;padding:6px 0px;z-index:999;background-color:rgb(18,18,18);min-width:120px;border-radius:4px;box-shadow:rgb(0 0 0 / 20%) 0px 5px 5px -3px,rgb(0 0 0 / 14%) 0px 8px 10px 1px,rgb(0 0 0 / 12%) 0px 3px 14px 2px;background-image:linear-gradient(#ffffff1f,#ffffff1f);"], ({
|
|
29
|
-
$isShowed: e
|
|
30
|
-
}) => e ? "block" : "none", ({
|
|
31
|
-
$position: e
|
|
32
|
-
}) => (e == null ? void 0 : e.top) || 0, ({
|
|
33
|
-
$position: e
|
|
34
|
-
}) => (e == null ? void 0 : e.left) || 0, ({
|
|
35
|
-
$position: e
|
|
36
|
-
}) => (e == null ? void 0 : e.width) || 0),
|
|
37
|
-
Box: c.div.withConfig({
|
|
38
|
-
displayName: "_style__Box",
|
|
39
|
-
componentId: "sc-1ikgo6d-3"
|
|
40
|
-
})(["transition:all 200ms ease-in-out;position:relative;width:", ";height:56px;", ";"], ({
|
|
41
|
-
$fullWidth: e
|
|
42
|
-
}) => e ? "100%" : "210px", J),
|
|
43
|
-
InnerBox: c.span.withConfig({
|
|
44
|
-
displayName: "_style__InnerBox",
|
|
45
|
-
componentId: "sc-1ikgo6d-4"
|
|
46
|
-
})(["position:absolute;transition:all 200ms ease-in-out;box-sizing:border-box;width:100%;height:", ";line-height:", ";top:", ";left:0px;background-color:transparent;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:", ';font-family:"Verdana",sans-serif;font-size:16px;', ";&:focus-visible{outline:none;}"], ({
|
|
47
|
-
$hasLabel: e
|
|
48
|
-
}) => e ? "44px" : "56px", ({
|
|
49
|
-
$hasLabel: e
|
|
50
|
-
}) => e ? "44px" : "56px", ({
|
|
51
|
-
$hasLabel: e
|
|
52
|
-
}) => e ? "12px" : "0px", ({
|
|
53
|
-
$disabled: e
|
|
54
|
-
}) => e ? "#ffffff80" : "#ffffff", K),
|
|
55
|
-
FakeSelect: c.select.withConfig({
|
|
56
|
-
displayName: "_style__FakeSelect",
|
|
57
|
-
componentId: "sc-1ikgo6d-5"
|
|
58
|
-
})(["width:100%;height:100%;opacity:0;cursor:pointer;"]),
|
|
59
|
-
PostAdornmentContentWrapper: c.div.withConfig({
|
|
60
|
-
displayName: "_style__PostAdornmentContentWrapper",
|
|
61
|
-
componentId: "sc-1ikgo6d-6"
|
|
62
|
-
})(["display:flex;transition:all 350ms ease-in-out;width:20px;height:20px;color:", ";transform:", ";"], ({
|
|
63
|
-
$disabled: e
|
|
64
|
-
}) => e ? "#ffffff80" : "#ffffff", ({
|
|
65
|
-
$isShowed: e
|
|
66
|
-
}) => e ? "rotate(180deg)" : "none")
|
|
67
|
-
}, Q = b(() => import("@purr-react-styled-components/components.icon").then((e) => ({
|
|
68
|
-
default: e.Icon
|
|
69
|
-
}))), T = b(() => import("@purr-react-styled-components/components.post-adornment").then((e) => ({
|
|
70
|
-
default: e.PostAdornment
|
|
71
|
-
}))), U = b(() => import("./_menu-Oax72zVV.js").then((e) => ({
|
|
72
|
-
default: e.SelectMenu
|
|
73
|
-
}))), X = (e, s = !0) => {
|
|
74
|
-
var r;
|
|
75
|
-
const t = (r = e.current) == null ? void 0 : r.getBoundingClientRect();
|
|
76
|
-
return {
|
|
77
|
-
left: (t == null ? void 0 : t.x) || 0,
|
|
78
|
-
top: ((t == null ? void 0 : t.y) || 0) + (s && (window == null ? void 0 : window.scrollY) || 0),
|
|
79
|
-
width: (t == null ? void 0 : t.width) || 0,
|
|
80
|
-
height: (t == null ? void 0 : t.height) || 0
|
|
81
|
-
};
|
|
82
|
-
}, Z = L(({
|
|
83
|
-
optionGroupClassName: e,
|
|
84
|
-
options: s,
|
|
85
|
-
value: t,
|
|
86
|
-
variant: r = "standard",
|
|
87
|
-
postAdornmentProps: n,
|
|
88
|
-
className: B,
|
|
89
|
-
fullWidth: h = !1,
|
|
90
|
-
disabled: o = !1,
|
|
91
|
-
required: z = !1,
|
|
92
|
-
error: y = null,
|
|
93
|
-
isStandalone: R = !1,
|
|
94
|
-
tabIndex: V = -1,
|
|
95
|
-
menuHtmlAttributes: O,
|
|
96
|
-
htmlAttributes: W,
|
|
97
|
-
onChange: m
|
|
98
|
-
}, P) => {
|
|
99
|
-
const g = N(null), _ = N(null), [f, u] = C(!1), [F, M] = C(null), {
|
|
100
|
-
currentValue: k,
|
|
101
|
-
setCurrentValue: S
|
|
102
|
-
} = H(t, R);
|
|
103
|
-
q([g, _], () => {
|
|
104
|
-
f && u(!1);
|
|
105
|
-
});
|
|
106
|
-
const j = (d) => {
|
|
107
|
-
if (d.preventDefault(), !o) {
|
|
108
|
-
if (!f) {
|
|
109
|
-
const a = X(g);
|
|
110
|
-
M({
|
|
111
|
-
...a,
|
|
112
|
-
top: a.top + a.height
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
u((a) => !a);
|
|
116
|
-
}
|
|
117
|
-
}, l = s.find((d) => d.value === k), E = D(() => /* @__PURE__ */ i(x.PostAdornmentContentWrapper, { $isShowed: f, $disabled: o, className: p("select-post-adornment-content", f && "select-post-adornment-content--showed", o && "select-post-adornment-content--disabled"), children: (n == null ? void 0 : n.children) ?? /* @__PURE__ */ i(w, { children: /* @__PURE__ */ i(Q, { name: "chevron-down" }) }) }), [o, f, n == null ? void 0 : n.children]), G = Y((d) => (a) => {
|
|
118
|
-
m == null || m(d, a), u(!1), S(d);
|
|
119
|
-
}, [m, S, u]);
|
|
120
|
-
return /* @__PURE__ */ v(x.Container, { ...W, $fullWidth: h, className: p("select", h && "select--fullWidth", B), children: [
|
|
121
|
-
/* @__PURE__ */ v(x.Box, { $variant: r, $disabled: o, $fullWidth: h, $isError: !!y, ref: g, onClick: j, tabIndex: V, className: p("select-box", h && "select-box--full-width", o && "select-box--disabled", !!y && "select-box--error", `select-box--variant-${r}`), children: [
|
|
122
|
-
/* @__PURE__ */ i(x.FakeSelect, { required: z, disabled: o }),
|
|
123
|
-
/* @__PURE__ */ i(x.InnerBox, { $hasLabel: !0, $variant: r, $disabled: o, className: p("select-inner-box", `select-inner-box--variant-${r}`, o && "select-inner-box--disabled"), title: typeof (l == null ? void 0 : l.label) == "string" ? l == null ? void 0 : l.label : void 0, children: l == null ? void 0 : l.label }),
|
|
124
|
-
/* @__PURE__ */ i(w, { children: !!(n != null && n.children) && /* @__PURE__ */ i(T, { ...n, variant: r, children: E }) })
|
|
125
|
-
] }),
|
|
126
|
-
/* @__PURE__ */ i($, { className: p("portal-select", e), children: /* @__PURE__ */ i(w, { children: f && /* @__PURE__ */ i(U, { ref: _, options: s, position: F, isShowed: f, optionGroupClassName: e, currentValue: k, htmlAttributes: O, selectOption: G }) }) })
|
|
127
|
-
] });
|
|
128
|
-
});
|
|
129
|
-
Z.displayName = "Select";
|
|
130
|
-
export {
|
|
131
|
-
x as S,
|
|
132
|
-
Z as a
|
|
133
|
-
};
|
package/dist/index-Du2pJQ-t.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var M=Object.create;var k=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var Y=(e,i,t,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of G(i))!D.call(e,n)&&n!==t&&k(e,n,{get:()=>i[n],enumerable:!(o=E(i,n))||o.enumerable});return e};var v=(e,i,t)=>(t=e!=null?M(L(e)):{},Y(i||!e||!e.__esModule?k(t,"default",{value:e,enumerable:!0}):t,e));const s=require("react/jsx-runtime"),h=require("clsx"),l=require("react"),$=require("@purr-core/components.portal"),H=require("@purr-core/hooks.not-click-on-elements"),J=require("@purr-core/hooks.sync-state-with-props"),a=require("styled-components"),K=require("@purr-react-styled-components/utils.helpers"),Q=e=>e.$variant==="standard"?a.css(["padding:0px 35px 0px 0px;"]):a.css(["padding:0px 35px 0px 14px;"]),p={Container:a.div.withConfig({displayName:"_style__Container",componentId:"sc-1ikgo6d-0"})(["position:relative;width:",";min-width:210px;"],({$fullWidth:e})=>e?"100%":"fit-content"),Option:a.span.withConfig({displayName:"_style__Option",componentId:"sc-1ikgo6d-1"})(["display:block;transition:all 200ms ease-in-out;cursor:pointer;padding:0px 14px;height:36px;line-height:36px;background-color:",";color:",';overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-family:"Verdana",sans-serif;font-size:16px;&:hover{background-color:#ffffff14;}'],({$selected:e,$disabled:i})=>i?"#121212":e?"#90caf929":"transparent",({$disabled:e})=>e?"#ffffff80":"#ffffff"),OptionGroup:a.div.withConfig({displayName:"_style__OptionGroup",componentId:"sc-1ikgo6d-2"})(["position:absolute;display:",";top:","px;left:","px;width:","px;padding:6px 0px;z-index:999;background-color:rgb(18,18,18);min-width:120px;border-radius:4px;box-shadow:rgb(0 0 0 / 20%) 0px 5px 5px -3px,rgb(0 0 0 / 14%) 0px 8px 10px 1px,rgb(0 0 0 / 12%) 0px 3px 14px 2px;background-image:linear-gradient(#ffffff1f,#ffffff1f);"],({$isShowed:e})=>e?"block":"none",({$position:e})=>(e==null?void 0:e.top)||0,({$position:e})=>(e==null?void 0:e.left)||0,({$position:e})=>(e==null?void 0:e.width)||0),Box:a.div.withConfig({displayName:"_style__Box",componentId:"sc-1ikgo6d-3"})(["transition:all 200ms ease-in-out;position:relative;width:",";height:56px;",";"],({$fullWidth:e})=>e?"100%":"210px",K.getVariantStyle),InnerBox:a.span.withConfig({displayName:"_style__InnerBox",componentId:"sc-1ikgo6d-4"})(["position:absolute;transition:all 200ms ease-in-out;box-sizing:border-box;width:100%;height:",";line-height:",";top:",";left:0px;background-color:transparent;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:",';font-family:"Verdana",sans-serif;font-size:16px;',";&:focus-visible{outline:none;}"],({$hasLabel:e})=>e?"44px":"56px",({$hasLabel:e})=>e?"44px":"56px",({$hasLabel:e})=>e?"12px":"0px",({$disabled:e})=>e?"#ffffff80":"#ffffff",Q),FakeSelect:a.select.withConfig({displayName:"_style__FakeSelect",componentId:"sc-1ikgo6d-5"})(["width:100%;height:100%;opacity:0;cursor:pointer;"]),PostAdornmentContentWrapper:a.div.withConfig({displayName:"_style__PostAdornmentContentWrapper",componentId:"sc-1ikgo6d-6"})(["display:flex;transition:all 350ms ease-in-out;width:20px;height:20px;color:",";transform:",";"],({$disabled:e})=>e?"#ffffff80":"#ffffff",({$isShowed:e})=>e?"rotate(180deg)":"none")},T=l.lazy(()=>import("@purr-react-styled-components/components.icon").then(e=>({default:e.Icon}))),U=l.lazy(()=>import("@purr-react-styled-components/components.post-adornment").then(e=>({default:e.PostAdornment}))),X=l.lazy(()=>Promise.resolve().then(()=>require("./_menu-M55fIE1j.cjs")).then(e=>({default:e.SelectMenu}))),Z=(e,i=!0)=>{var o;const t=(o=e.current)==null?void 0:o.getBoundingClientRect();return{left:(t==null?void 0:t.x)||0,top:((t==null?void 0:t.y)||0)+(i&&(window==null?void 0:window.scrollY)||0),width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0}},N=l.forwardRef(({optionGroupClassName:e,options:i,value:t,variant:o="standard",postAdornmentProps:n,className:j,fullWidth:u=!1,disabled:r=!1,required:C=!1,error:y=null,isStandalone:I=!1,tabIndex:q=-1,menuHtmlAttributes:B,htmlAttributes:z,onChange:g},P)=>{const m=l.useRef(null),b=l.useRef(null),[f,w]=l.useState(!1),[R,V]=l.useState(null),{currentValue:_,setCurrentValue:S}=J(t,I);H([m,b],()=>{f&&w(!1)});const O=d=>{if(d.preventDefault(),!r){if(!f){const x=Z(m);V({...x,top:x.top+x.height})}w(x=>!x)}},c=i.find(d=>d.value===_),W=l.useMemo(()=>s.jsx(p.PostAdornmentContentWrapper,{$isShowed:f,$disabled:r,className:h("select-post-adornment-content",f&&"select-post-adornment-content--showed",r&&"select-post-adornment-content--disabled"),children:(n==null?void 0:n.children)??s.jsx(l.Suspense,{children:s.jsx(T,{name:"chevron-down"})})}),[r,f,n==null?void 0:n.children]),F=l.useCallback(d=>x=>{g==null||g(d,x),w(!1),S(d)},[g,S,w]);return s.jsxs(p.Container,{...z,$fullWidth:u,className:h("select",u&&"select--fullWidth",j),children:[s.jsxs(p.Box,{$variant:o,$disabled:r,$fullWidth:u,$isError:!!y,ref:m,onClick:O,tabIndex:q,className:h("select-box",u&&"select-box--full-width",r&&"select-box--disabled",!!y&&"select-box--error",`select-box--variant-${o}`),children:[s.jsx(p.FakeSelect,{required:C,disabled:r}),s.jsx(p.InnerBox,{$hasLabel:!0,$variant:o,$disabled:r,className:h("select-inner-box",`select-inner-box--variant-${o}`,r&&"select-inner-box--disabled"),title:typeof(c==null?void 0:c.label)=="string"?c==null?void 0:c.label:void 0,children:c==null?void 0:c.label}),s.jsx(l.Suspense,{children:!!(n!=null&&n.children)&&s.jsx(U,{...n,variant:o,children:W})})]}),s.jsx($.Portal,{className:h("portal-select",e),children:s.jsx(l.Suspense,{children:f&&s.jsx(X,{ref:b,options:i,position:R,isShowed:f,optionGroupClassName:e,currentValue:_,htmlAttributes:B,selectOption:F})})})]})});N.displayName="Select";exports.Select=N;exports.Styled=p;
|