@purr-react-styled-components/components.select 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { ISelectMenuProps } from '../_types';
3
+
4
+ export declare const SelectMenu: React.ForwardRefExoticComponent<ISelectMenuProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { ISelectProps } from '../_types';
3
+
4
+ export declare const Select: React.ForwardRefExoticComponent<ISelectProps & React.RefAttributes<HTMLSelectElement>>;
@@ -0,0 +1,29 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import h from "clsx";
3
+ import { memo as S, createElement as w, forwardRef as O, useMemo as y } from "react";
4
+ import { S as f } from "./index-D9skdafy.js";
5
+ const $ = S(({
6
+ value: t,
7
+ displayedValue: e,
8
+ label: r,
9
+ disabled: l,
10
+ htmlAttributes: m,
11
+ handleSelectOption: d
12
+ }) => /* @__PURE__ */ w(f.Option, { ...m, $selected: t === e, $disabled: l, key: t, className: h("select-option", t === e && "select-option--selected", l && "select-option--disabled"), onClick: d(t) }, r));
13
+ $.displayName = "SelectOption";
14
+ const N = O(({
15
+ options: t,
16
+ position: e,
17
+ isShowed: r,
18
+ currentValue: l,
19
+ optionGroupClassName: m,
20
+ htmlAttributes: d,
21
+ selectOption: a
22
+ }, b) => {
23
+ const u = y(() => t.map((c) => /* @__PURE__ */ s($, { value: c.value, displayedValue: l, label: c.label, disabled: !!c.disabled, htmlAttributes: c.htmlAttributes, handleSelectOption: a }, c.value)), [l, t, a]);
24
+ return /* @__PURE__ */ s(f.OptionGroup, { ...d, $position: e, $isShowed: r, ref: b, 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}`, r && "select-options--showed", m), children: u });
25
+ });
26
+ N.displayName = "SelectMenu";
27
+ export {
28
+ N as SelectMenu
29
+ };
@@ -0,0 +1 @@
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-DjXPDt7j.cjs"),S=s.memo(({value:t,displayedValue:e,label:r,disabled:l,htmlAttributes:d,handleSelectOption:a})=>s.createElement(n.Styled.Option,{...d,$selected:t===e,$disabled:l,key:t,className:m("select-option",t===e&&"select-option--selected",l&&"select-option--disabled"),onClick:a(t)},r));S.displayName="SelectOption";const b=s.forwardRef(({options:t,position:e,isShowed:r,currentValue:l,optionGroupClassName:d,htmlAttributes:a,selectOption:u},$)=>{const y=s.useMemo(()=>t.map(c=>h.jsx(S,{value:c.value,displayedValue:l,label:c.label,disabled:!!c.disabled,htmlAttributes:c.htmlAttributes,handleSelectOption:u},c.value)),[l,t,u]);return h.jsx(n.Styled.OptionGroup,{...a,$position:e,$isShowed:r,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}`,r&&"select-options--showed",d),children:y})});b.displayName="SelectMenu";exports.SelectMenu=b;
@@ -0,0 +1,35 @@
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
+ };
@@ -0,0 +1,51 @@
1
+ import { HTMLAttributes, MouseEvent, MouseEventHandler, ReactNode } from 'react';
2
+ import { FieldError } from 'react-hook-form';
3
+ import { IExtendable } from '@purr-core/utils.definitions';
4
+ import { IHelperTextProps } from '@purr-react-styled-components/components.helper-text';
5
+ import { ILabelProps } from '@purr-react-styled-components/components.label';
6
+ import { IPostAdornmentProps } from '@purr-react-styled-components/components.post-adornment';
7
+
8
+ export interface ISelectOption {
9
+ value: string;
10
+ label: ReactNode;
11
+ disabled?: boolean;
12
+ htmlAttributes?: HTMLAttributes<HTMLSpanElement> & IExtendable;
13
+ }
14
+ export interface ISelectOptionProps extends ISelectOption {
15
+ displayedValue?: string;
16
+ handleSelectOption: (value: string) => MouseEventHandler<HTMLSpanElement>;
17
+ }
18
+ export type TSelectVariant = "standard" | "outlined" | "filled";
19
+ export interface ISelectMenuProps {
20
+ options: ISelectOption[];
21
+ position: {
22
+ left: number;
23
+ top: number;
24
+ width: number;
25
+ height: number;
26
+ } | null;
27
+ isShowed: boolean;
28
+ currentValue?: string;
29
+ optionGroupClassName?: string;
30
+ htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
31
+ selectOption: (value: string) => MouseEventHandler<HTMLSpanElement>;
32
+ }
33
+ export interface ISelectProps {
34
+ optionGroupClassName?: string;
35
+ options: ISelectOption[];
36
+ value?: string;
37
+ variant?: TSelectVariant;
38
+ labelProps?: ILabelProps;
39
+ postAdornmentProps?: IPostAdornmentProps;
40
+ helperTextProps?: IHelperTextProps;
41
+ htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
42
+ menuHtmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
43
+ tabIndex?: number;
44
+ className?: string;
45
+ fullWidth?: boolean;
46
+ disabled?: boolean;
47
+ required?: boolean;
48
+ error?: FieldError;
49
+ isStandalone?: boolean;
50
+ onChange?: (value: string, e: MouseEvent<HTMLSpanElement>) => void;
51
+ }
@@ -0,0 +1,144 @@
1
+ import { jsx as n, jsxs as I } from "react/jsx-runtime";
2
+ import p from "clsx";
3
+ import { lazy as g, forwardRef as Y, useRef as B, useState as O, useMemo as $, Suspense as u, useCallback as J } from "react";
4
+ import { Portal as K } from "@purr-core/components.portal";
5
+ import Q from "@purr-core/hooks.block";
6
+ import U from "@purr-core/hooks.not-click-on-elements";
7
+ import X from "@purr-core/hooks.sync-state-with-props";
8
+ import d, { css as L } from "styled-components";
9
+ import { getVariantStyle as Z } from "@purr-react-styled-components/utils.helpers";
10
+ const q = (e) => e.$variant === "standard" ? L(["padding:0px 35px 0px 0px;"]) : L(["padding:0px 35px 0px 14px;"]), m = {
11
+ Container: d.div.withConfig({
12
+ displayName: "_style__Container",
13
+ componentId: "sc-1ikgo6d-0"
14
+ })(["position:relative;width:", ";min-width:210px;"], ({
15
+ $fullWidth: e
16
+ }) => e ? "100%" : "fit-content"),
17
+ Option: d.span.withConfig({
18
+ displayName: "_style__Option",
19
+ componentId: "sc-1ikgo6d-1"
20
+ })(["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;}'], ({
21
+ $selected: e,
22
+ $disabled: x
23
+ }) => x ? "#121212" : e ? "#90caf929" : "transparent", ({
24
+ $disabled: e
25
+ }) => e ? "#ffffff80" : "#ffffff"),
26
+ OptionGroup: d.div.withConfig({
27
+ displayName: "_style__OptionGroup",
28
+ componentId: "sc-1ikgo6d-2"
29
+ })(["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);"], ({
30
+ $isShowed: e
31
+ }) => e ? "block" : "none", ({
32
+ $position: e
33
+ }) => (e == null ? void 0 : e.top) || 0, ({
34
+ $position: e
35
+ }) => (e == null ? void 0 : e.left) || 0, ({
36
+ $position: e
37
+ }) => (e == null ? void 0 : e.width) || 0),
38
+ Box: d.div.withConfig({
39
+ displayName: "_style__Box",
40
+ componentId: "sc-1ikgo6d-3"
41
+ })(["transition:all 200ms ease-in-out;position:relative;width:", ";height:56px;border-radius:4px;cursor:", ";", ";"], ({
42
+ $fullWidth: e
43
+ }) => e ? "100%" : "210px", ({
44
+ $disabled: e
45
+ }) => e ? "not-allowed" : "pointer", Z),
46
+ InnerBox: d.span.withConfig({
47
+ displayName: "_style__InnerBox",
48
+ componentId: "sc-1ikgo6d-4"
49
+ })(["position:absolute;transition:all 200ms ease-in-out;box-sizing:border-box;width:100%;height:", ";line-height:", ";top:", ";left:0px;background-color:transparent;border:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:", ';font-family:"Verdana",sans-serif;font-size:16px;', ";&:focus-visible{outline:none;}"], ({
50
+ $hasLabel: e
51
+ }) => e ? "44px" : "56px", ({
52
+ $hasLabel: e
53
+ }) => e ? "44px" : "56px", ({
54
+ $hasLabel: e
55
+ }) => e ? "12px" : "0px", ({
56
+ $disabled: e
57
+ }) => e ? "#ffffff80" : "#ffffff", q),
58
+ FakeSelect: d.select.withConfig({
59
+ displayName: "_style__FakeSelect",
60
+ componentId: "sc-1ikgo6d-5"
61
+ })(["width:100%;height:100%;opacity:0;cursor:pointer;"]),
62
+ PostAdornmentContentWrapper: d.div.withConfig({
63
+ displayName: "_style__PostAdornmentContentWrapper",
64
+ componentId: "sc-1ikgo6d-6"
65
+ })(["display:flex;transition:all 350ms ease-in-out;width:20px;height:20px;color:", ";transform:", ";"], ({
66
+ $disabled: e
67
+ }) => e ? "#ffffff80" : "#ffffff", ({
68
+ $isShowed: e
69
+ }) => e ? "rotate(180deg)" : "none")
70
+ }, A = g(() => import("@purr-react-styled-components/components.helper-text").then((e) => ({
71
+ default: e.HelperText
72
+ }))), T = g(() => import("@purr-react-styled-components/components.icon").then((e) => ({
73
+ default: e.Icon
74
+ }))), P = g(() => import("@purr-react-styled-components/components.label").then((e) => ({
75
+ default: e.Label
76
+ }))), ee = g(() => import("@purr-react-styled-components/components.post-adornment").then((e) => ({
77
+ default: e.PostAdornment
78
+ }))), te = g(() => import("./_menu-BoZEsfHP.js").then((e) => ({
79
+ default: e.SelectMenu
80
+ }))), ne = (e, x = !0) => {
81
+ var o;
82
+ const t = (o = e.current) == null ? void 0 : o.getBoundingClientRect();
83
+ return {
84
+ left: (t == null ? void 0 : t.x) || 0,
85
+ top: ((t == null ? void 0 : t.y) || 0) + (x && (window == null ? void 0 : window.scrollY) || 0),
86
+ width: (t == null ? void 0 : t.width) || 0,
87
+ height: (t == null ? void 0 : t.height) || 0
88
+ };
89
+ }, ie = Y(({
90
+ optionGroupClassName: e,
91
+ options: x,
92
+ value: t,
93
+ variant: o = "standard",
94
+ labelProps: c,
95
+ postAdornmentProps: f,
96
+ helperTextProps: a,
97
+ className: z,
98
+ fullWidth: w = !1,
99
+ disabled: i = !1,
100
+ required: C = !1,
101
+ error: s = null,
102
+ isStandalone: R = !1,
103
+ tabIndex: V = -1,
104
+ menuHtmlAttributes: E,
105
+ htmlAttributes: F,
106
+ onChange: y
107
+ }, oe) => {
108
+ const k = B(null), N = B(null), [l, _] = O(!1), [W, M] = O(null), {
109
+ currentValue: S,
110
+ setCurrentValue: v
111
+ } = X(t, R);
112
+ U([k, N], () => {
113
+ l && _(!1);
114
+ });
115
+ const j = (h) => {
116
+ if (h.preventDefault(), !i) {
117
+ if (!l) {
118
+ const r = ne(k);
119
+ M({
120
+ ...r,
121
+ top: r.top + r.height
122
+ });
123
+ }
124
+ _((r) => !r);
125
+ }
126
+ }, G = Q(() => !!(i || l || S)), b = x.find((h) => h.value === S), H = $(() => /* @__PURE__ */ n(m.PostAdornmentContentWrapper, { $isShowed: l, $disabled: i, className: p("select-post-adornment-content", l && "select-post-adornment-content--showed", i && "select-post-adornment-content--disabled"), children: (f == null ? void 0 : f.children) ?? /* @__PURE__ */ n(u, { children: /* @__PURE__ */ n(T, { name: "chevron-down" }) }) }), [i, l, f == null ? void 0 : f.children]), D = J((h) => (r) => {
127
+ y == null || y(h, r), _(!1), v(h);
128
+ }, [y, v, _]);
129
+ return /* @__PURE__ */ I(m.Container, { ...F, $fullWidth: w, className: p("select", w && "select--fullWidth", z), children: [
130
+ /* @__PURE__ */ I(m.Box, { $variant: o, $disabled: i, $fullWidth: w, $isError: !!s, ref: k, onClick: j, tabIndex: V, className: p("select-box", w && "select-box--full-width", i && "select-box--disabled", !!s && "select-box--error", `select-box--variant-${o}`), children: [
131
+ /* @__PURE__ */ n(u, { children: !!(c != null && c.children) && /* @__PURE__ */ n(P, { ...c, required: C, disabled: i, variant: o, isLabelCollapsed: G, isFocused: l, isError: !!s }) }),
132
+ /* @__PURE__ */ n(m.FakeSelect, { required: C, disabled: i }),
133
+ /* @__PURE__ */ n(m.InnerBox, { $hasLabel: !!(c != null && c.children), $variant: o, $disabled: i, className: p("select-inner-box", `select-inner-box--variant-${o}`, !!(c != null && c.children) && "select-inner-box--hasLabel", i && "select-inner-box--disabled"), children: b == null ? void 0 : b.label }),
134
+ /* @__PURE__ */ n(u, { children: !!(f != null && f.children) && /* @__PURE__ */ n(ee, { ...f, variant: o, children: H }) }),
135
+ /* @__PURE__ */ n(u, { children: !!(a != null && a.children) && /* @__PURE__ */ n(A, { ...a, isError: !!s, variant: o, children: (s == null ? void 0 : s.message) ?? (a == null ? void 0 : a.children) ?? "" }) })
136
+ ] }),
137
+ /* @__PURE__ */ n(K, { className: p("portal-select", e), children: /* @__PURE__ */ n(u, { children: l && /* @__PURE__ */ n(te, { ref: N, options: x, position: W, isShowed: l, optionGroupClassName: e, currentValue: S, htmlAttributes: E, selectOption: D }) }) })
138
+ ] });
139
+ });
140
+ ie.displayName = "Select";
141
+ export {
142
+ m as S,
143
+ ie as a
144
+ };
@@ -0,0 +1 @@
1
+ "use strict";var G=Object.create;var N=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var J=(e,c,t,l)=>{if(c&&typeof c=="object"||typeof c=="function")for(let i of D(c))!$.call(e,i)&&i!==t&&N(e,i,{get:()=>c[i],enumerable:!(l=H(c,i))||l.enumerable});return e};var S=(e,c,t)=>(t=e!=null?G(Y(e)):{},J(c||!e||!e.__esModule?N(t,"default",{value:e,enumerable:!0}):t,e));const s=require("react/jsx-runtime"),g=require("clsx"),n=require("react"),K=require("@purr-core/components.portal"),Q=require("@purr-core/hooks.block"),U=require("@purr-core/hooks.not-click-on-elements"),X=require("@purr-core/hooks.sync-state-with-props"),r=require("styled-components"),Z=require("@purr-react-styled-components/utils.helpers"),A=e=>e.$variant==="standard"?r.css(["padding:0px 35px 0px 0px;"]):r.css(["padding:0px 35px 0px 14px;"]),p={Container:r.div.withConfig({displayName:"_style__Container",componentId:"sc-1ikgo6d-0"})(["position:relative;width:",";min-width:210px;"],({$fullWidth:e})=>e?"100%":"fit-content"),Option:r.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:c})=>c?"#121212":e?"#90caf929":"transparent",({$disabled:e})=>e?"#ffffff80":"#ffffff"),OptionGroup:r.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:r.div.withConfig({displayName:"_style__Box",componentId:"sc-1ikgo6d-3"})(["transition:all 200ms ease-in-out;position:relative;width:",";height:56px;border-radius:4px;cursor:",";",";"],({$fullWidth:e})=>e?"100%":"210px",({$disabled:e})=>e?"not-allowed":"pointer",Z.getVariantStyle),InnerBox:r.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;border:none;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",A),FakeSelect:r.select.withConfig({displayName:"_style__FakeSelect",componentId:"sc-1ikgo6d-5"})(["width:100%;height:100%;opacity:0;cursor:pointer;"]),PostAdornmentContentWrapper:r.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=n.lazy(()=>import("@purr-react-styled-components/components.helper-text").then(e=>({default:e.HelperText}))),P=n.lazy(()=>import("@purr-react-styled-components/components.icon").then(e=>({default:e.Icon}))),ee=n.lazy(()=>import("@purr-react-styled-components/components.label").then(e=>({default:e.Label}))),te=n.lazy(()=>import("@purr-react-styled-components/components.post-adornment").then(e=>({default:e.PostAdornment}))),ne=n.lazy(()=>Promise.resolve().then(()=>require("./_menu-C8lQ1g_y.cjs")).then(e=>({default:e.SelectMenu}))),ie=(e,c=!0)=>{var l;const t=(l=e.current)==null?void 0:l.getBoundingClientRect();return{left:(t==null?void 0:t.x)||0,top:((t==null?void 0:t.y)||0)+(c&&(window==null?void 0:window.scrollY)||0),width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0}},I=n.forwardRef(({optionGroupClassName:e,options:c,value:t,variant:l="standard",labelProps:i,postAdornmentProps:f,helperTextProps:d,className:q,fullWidth:w=!1,disabled:o=!1,required:b=!1,error:x=null,isStandalone:z=!1,tabIndex:B=-1,menuHtmlAttributes:O,htmlAttributes:R,onChange:m},se)=>{const _=n.useRef(null),v=n.useRef(null),[a,y]=n.useState(!1),[L,V]=n.useState(null),{currentValue:k,setCurrentValue:C}=X(t,z);U([_,v],()=>{a&&y(!1)});const E=h=>{if(h.preventDefault(),!o){if(!a){const u=ie(_);V({...u,top:u.top+u.height})}y(u=>!u)}},F=Q(()=>!!(o||a||k)),j=c.find(h=>h.value===k),W=n.useMemo(()=>s.jsx(p.PostAdornmentContentWrapper,{$isShowed:a,$disabled:o,className:g("select-post-adornment-content",a&&"select-post-adornment-content--showed",o&&"select-post-adornment-content--disabled"),children:(f==null?void 0:f.children)??s.jsx(n.Suspense,{children:s.jsx(P,{name:"chevron-down"})})}),[o,a,f==null?void 0:f.children]),M=n.useCallback(h=>u=>{m==null||m(h,u),y(!1),C(h)},[m,C,y]);return s.jsxs(p.Container,{...R,$fullWidth:w,className:g("select",w&&"select--fullWidth",q),children:[s.jsxs(p.Box,{$variant:l,$disabled:o,$fullWidth:w,$isError:!!x,ref:_,onClick:E,tabIndex:B,className:g("select-box",w&&"select-box--full-width",o&&"select-box--disabled",!!x&&"select-box--error",`select-box--variant-${l}`),children:[s.jsx(n.Suspense,{children:!!(i!=null&&i.children)&&s.jsx(ee,{...i,required:b,disabled:o,variant:l,isLabelCollapsed:F,isFocused:a,isError:!!x})}),s.jsx(p.FakeSelect,{required:b,disabled:o}),s.jsx(p.InnerBox,{$hasLabel:!!(i!=null&&i.children),$variant:l,$disabled:o,className:g("select-inner-box",`select-inner-box--variant-${l}`,!!(i!=null&&i.children)&&"select-inner-box--hasLabel",o&&"select-inner-box--disabled"),children:j==null?void 0:j.label}),s.jsx(n.Suspense,{children:!!(f!=null&&f.children)&&s.jsx(te,{...f,variant:l,children:W})}),s.jsx(n.Suspense,{children:!!(d!=null&&d.children)&&s.jsx(T,{...d,isError:!!x,variant:l,children:(x==null?void 0:x.message)??(d==null?void 0:d.children)??""})})]}),s.jsx(K.Portal,{className:g("portal-select",e),children:s.jsx(n.Suspense,{children:a&&s.jsx(ne,{ref:v,options:c,position:L,isShowed:a,optionGroupClassName:e,currentValue:k,htmlAttributes:O,selectOption:M})})})]})});I.displayName="Select";exports.Select=I;exports.Styled=p;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DjXPDt7j.cjs");exports.Select=e.Select;
@@ -0,0 +1,2 @@
1
+ export * from './_components';
2
+ export * from './_types';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { a as o } from "./index-D9skdafy.js";
2
+ export {
3
+ o as Select
4
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@purr-react-styled-components/components.select",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "peerDependencies": {
24
+ "typescript": "*",
25
+ "react": "*",
26
+ "styled-components": "*",
27
+ "clsx": "*",
28
+ "react-hook-form": "*",
29
+ "@purr-react-styled-components/components.helper-text": "0.0.1",
30
+ "@purr-react-styled-components/components.label": "0.0.1",
31
+ "@purr-react-styled-components/components.post-adornment": "0.0.1",
32
+ "@purr-react-styled-components/utils.helpers": "0.0.1",
33
+ "@purr-core/utils.definitions": "0.0.4",
34
+ "@purr-react-styled-components/components.icon": "0.0.1",
35
+ "@purr-core/components.portal": "0.0.1",
36
+ "@purr-core/hooks.block": "0.0.3",
37
+ "@purr-core/hooks.not-click-on-elements": "0.0.2",
38
+ "@purr-core/hooks.sync-state-with-props": "0.0.2"
39
+ },
40
+ "author": "@DinhThienPhuc",
41
+ "license": "ISC",
42
+ "description": "",
43
+ "sideEffects": false,
44
+ "scripts": {
45
+ "dev": "vite build --watch",
46
+ "build": "tsc && vite build",
47
+ "lint": "eslint . --ext ts,tsx --max-warnings 0"
48
+ }
49
+ }