@purr-react-styled-components/components.select 0.0.2 → 0.0.4
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/_menu--48HzVTM.cjs +1 -0
- package/dist/_menu-BIoK4CXi.js +29 -0
- package/dist/index-D4NXEE_c.cjs +1 -0
- package/dist/{index-D9skdafy.js → index-DHVL3VhH.js} +56 -56
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +11 -11
- package/dist/_menu-BoZEsfHP.js +0 -29
- package/dist/_menu-C8lQ1g_y.cjs +0 -1
- package/dist/index-DjXPDt7j.cjs +0 -1
|
@@ -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-D4NXEE_c.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;
|
|
@@ -0,0 +1,29 @@
|
|
|
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-DHVL3VhH.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
|
+
};
|
|
@@ -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,s,t,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of D(s))!$.call(e,i)&&i!==t&&N(e,i,{get:()=>s[i],enumerable:!(l=H(s,i))||l.enumerable});return e};var _=(e,s,t)=>(t=e!=null?G(Y(e)):{},J(s||!e||!e.__esModule?N(t,"default",{value:e,enumerable:!0}):t,e));const c=require("react/jsx-runtime"),w=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"),d=require("styled-components"),Z=require("@purr-react-styled-components/utils.helpers"),A=e=>e.$variant==="standard"?d.css(["padding:0px 35px 0px 0px;"]):d.css(["padding:0px 35px 0px 14px;"]),p={Container:d.div.withConfig({displayName:"_style__Container",componentId:"sc-1ikgo6d-0"})(["position:relative;width:",";min-width:210px;"],({$fullWidth:e})=>e?"100%":"fit-content"),Option:d.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:s})=>s?"#121212":e?"#90caf929":"transparent",({$disabled:e})=>e?"#ffffff80":"#ffffff"),OptionGroup:d.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:d.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:d.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:d.select.withConfig({displayName:"_style__FakeSelect",componentId:"sc-1ikgo6d-5"})(["width:100%;height:100%;opacity:0;cursor:pointer;"]),PostAdornmentContentWrapper:d.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--48HzVTM.cjs")).then(e=>({default:e.SelectMenu}))),ie=(e,s=!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)+(s&&(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:s,value:t,variant:l="standard",labelProps:i,postAdornmentProps:f,helperTextProps:x,className:q,fullWidth:m=!1,disabled:o=!1,required:b=!1,error:u=null,isStandalone:z=!1,tabIndex:B=-1,menuHtmlAttributes:R,htmlAttributes:L,onChange:y},ce)=>{const k=n.useRef(null),v=n.useRef(null),[a,S]=n.useState(!1),[V,E]=n.useState(null),{currentValue:j,setCurrentValue:C}=X(t,z);U([k,v],()=>{a&&S(!1)});const F=g=>{if(g.preventDefault(),!o){if(!a){const h=ie(k);E({...h,top:h.top+h.height})}S(h=>!h)}},O=Q(()=>!!(o||a||j)),r=s.find(g=>g.value===j),W=n.useMemo(()=>c.jsx(p.PostAdornmentContentWrapper,{$isShowed:a,$disabled:o,className:w("select-post-adornment-content",a&&"select-post-adornment-content--showed",o&&"select-post-adornment-content--disabled"),children:(f==null?void 0:f.children)??c.jsx(n.Suspense,{children:c.jsx(P,{name:"chevron-down"})})}),[o,a,f==null?void 0:f.children]),M=n.useCallback(g=>h=>{y==null||y(g,h),S(!1),C(g)},[y,C,S]);return c.jsxs(p.Container,{...L,$fullWidth:m,className:w("select",m&&"select--fullWidth",q),children:[c.jsxs(p.Box,{$variant:l,$disabled:o,$fullWidth:m,$isError:!!u,ref:k,onClick:F,tabIndex:B,className:w("select-box",m&&"select-box--full-width",o&&"select-box--disabled",!!u&&"select-box--error",`select-box--variant-${l}`),children:[c.jsx(n.Suspense,{children:!!(i!=null&&i.children)&&c.jsx(ee,{...i,required:b,disabled:o,variant:l,isLabelCollapsed:O,isFocused:a,isError:!!u})}),c.jsx(p.FakeSelect,{required:b,disabled:o}),c.jsx(p.InnerBox,{$hasLabel:!!(i!=null&&i.children),$variant:l,$disabled:o,className:w("select-inner-box",`select-inner-box--variant-${l}`,!!(i!=null&&i.children)&&"select-inner-box--hasLabel",o&&"select-inner-box--disabled"),title:typeof(r==null?void 0:r.label)=="string"?r==null?void 0:r.label:void 0,children:r==null?void 0:r.label}),c.jsx(n.Suspense,{children:!!(f!=null&&f.children)&&c.jsx(te,{...f,variant:l,children:W})}),c.jsx(n.Suspense,{children:!!(x!=null&&x.children)&&c.jsx(T,{...x,isError:!!u,variant:l,children:(u==null?void 0:u.message)??(x==null?void 0:x.children)??""})})]}),c.jsx(K.Portal,{className:w("portal-select",e),children:c.jsx(n.Suspense,{children:a&&c.jsx(ne,{ref:v,options:s,position:V,isShowed:a,optionGroupClassName:e,currentValue:j,htmlAttributes:R,selectOption:M})})})]})});I.displayName="Select";exports.Select=I;exports.Styled=p;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { jsx as n, jsxs as I } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { lazy as
|
|
2
|
+
import m from "clsx";
|
|
3
|
+
import { lazy as w, forwardRef as Y, useRef as B, useState as L, useMemo as $, Suspense as p, useCallback as J } from "react";
|
|
4
4
|
import { Portal as K } from "@purr-core/components.portal";
|
|
5
5
|
import Q from "@purr-core/hooks.block";
|
|
6
6
|
import U from "@purr-core/hooks.not-click-on-elements";
|
|
7
7
|
import X from "@purr-core/hooks.sync-state-with-props";
|
|
8
|
-
import
|
|
8
|
+
import x, { css as z } from "styled-components";
|
|
9
9
|
import { getVariantStyle as Z } from "@purr-react-styled-components/utils.helpers";
|
|
10
|
-
const q = (e) => e.$variant === "standard" ?
|
|
11
|
-
Container:
|
|
10
|
+
const q = (e) => e.$variant === "standard" ? z(["padding:0px 35px 0px 0px;"]) : z(["padding:0px 35px 0px 14px;"]), g = {
|
|
11
|
+
Container: x.div.withConfig({
|
|
12
12
|
displayName: "_style__Container",
|
|
13
13
|
componentId: "sc-1ikgo6d-0"
|
|
14
14
|
})(["position:relative;width:", ";min-width:210px;"], ({
|
|
15
15
|
$fullWidth: e
|
|
16
16
|
}) => e ? "100%" : "fit-content"),
|
|
17
|
-
Option:
|
|
17
|
+
Option: x.span.withConfig({
|
|
18
18
|
displayName: "_style__Option",
|
|
19
19
|
componentId: "sc-1ikgo6d-1"
|
|
20
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
21
|
$selected: e,
|
|
22
|
-
$disabled:
|
|
23
|
-
}) =>
|
|
22
|
+
$disabled: h
|
|
23
|
+
}) => h ? "#121212" : e ? "#90caf929" : "transparent", ({
|
|
24
24
|
$disabled: e
|
|
25
25
|
}) => e ? "#ffffff80" : "#ffffff"),
|
|
26
|
-
OptionGroup:
|
|
26
|
+
OptionGroup: x.div.withConfig({
|
|
27
27
|
displayName: "_style__OptionGroup",
|
|
28
28
|
componentId: "sc-1ikgo6d-2"
|
|
29
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);"], ({
|
|
@@ -35,7 +35,7 @@ const q = (e) => e.$variant === "standard" ? L(["padding:0px 35px 0px 0px;"]) :
|
|
|
35
35
|
}) => (e == null ? void 0 : e.left) || 0, ({
|
|
36
36
|
$position: e
|
|
37
37
|
}) => (e == null ? void 0 : e.width) || 0),
|
|
38
|
-
Box:
|
|
38
|
+
Box: x.div.withConfig({
|
|
39
39
|
displayName: "_style__Box",
|
|
40
40
|
componentId: "sc-1ikgo6d-3"
|
|
41
41
|
})(["transition:all 200ms ease-in-out;position:relative;width:", ";height:56px;border-radius:4px;cursor:", ";", ";"], ({
|
|
@@ -43,7 +43,7 @@ const q = (e) => e.$variant === "standard" ? L(["padding:0px 35px 0px 0px;"]) :
|
|
|
43
43
|
}) => e ? "100%" : "210px", ({
|
|
44
44
|
$disabled: e
|
|
45
45
|
}) => e ? "not-allowed" : "pointer", Z),
|
|
46
|
-
InnerBox:
|
|
46
|
+
InnerBox: x.span.withConfig({
|
|
47
47
|
displayName: "_style__InnerBox",
|
|
48
48
|
componentId: "sc-1ikgo6d-4"
|
|
49
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;}"], ({
|
|
@@ -55,11 +55,11 @@ const q = (e) => e.$variant === "standard" ? L(["padding:0px 35px 0px 0px;"]) :
|
|
|
55
55
|
}) => e ? "12px" : "0px", ({
|
|
56
56
|
$disabled: e
|
|
57
57
|
}) => e ? "#ffffff80" : "#ffffff", q),
|
|
58
|
-
FakeSelect:
|
|
58
|
+
FakeSelect: x.select.withConfig({
|
|
59
59
|
displayName: "_style__FakeSelect",
|
|
60
60
|
componentId: "sc-1ikgo6d-5"
|
|
61
61
|
})(["width:100%;height:100%;opacity:0;cursor:pointer;"]),
|
|
62
|
-
PostAdornmentContentWrapper:
|
|
62
|
+
PostAdornmentContentWrapper: x.div.withConfig({
|
|
63
63
|
displayName: "_style__PostAdornmentContentWrapper",
|
|
64
64
|
componentId: "sc-1ikgo6d-6"
|
|
65
65
|
})(["display:flex;transition:all 350ms ease-in-out;width:20px;height:20px;color:", ";transform:", ";"], ({
|
|
@@ -67,78 +67,78 @@ const q = (e) => e.$variant === "standard" ? L(["padding:0px 35px 0px 0px;"]) :
|
|
|
67
67
|
}) => e ? "#ffffff80" : "#ffffff", ({
|
|
68
68
|
$isShowed: e
|
|
69
69
|
}) => e ? "rotate(180deg)" : "none")
|
|
70
|
-
}, A =
|
|
70
|
+
}, A = w(() => import("@purr-react-styled-components/components.helper-text").then((e) => ({
|
|
71
71
|
default: e.HelperText
|
|
72
|
-
}))), T =
|
|
72
|
+
}))), T = w(() => import("@purr-react-styled-components/components.icon").then((e) => ({
|
|
73
73
|
default: e.Icon
|
|
74
|
-
}))), P =
|
|
74
|
+
}))), P = w(() => import("@purr-react-styled-components/components.label").then((e) => ({
|
|
75
75
|
default: e.Label
|
|
76
|
-
}))), ee =
|
|
76
|
+
}))), ee = w(() => import("@purr-react-styled-components/components.post-adornment").then((e) => ({
|
|
77
77
|
default: e.PostAdornment
|
|
78
|
-
}))), te =
|
|
78
|
+
}))), te = w(() => import("./_menu-BIoK4CXi.js").then((e) => ({
|
|
79
79
|
default: e.SelectMenu
|
|
80
|
-
}))), ne = (e,
|
|
80
|
+
}))), ne = (e, h = !0) => {
|
|
81
81
|
var o;
|
|
82
82
|
const t = (o = e.current) == null ? void 0 : o.getBoundingClientRect();
|
|
83
83
|
return {
|
|
84
84
|
left: (t == null ? void 0 : t.x) || 0,
|
|
85
|
-
top: ((t == null ? void 0 : t.y) || 0) + (
|
|
85
|
+
top: ((t == null ? void 0 : t.y) || 0) + (h && (window == null ? void 0 : window.scrollY) || 0),
|
|
86
86
|
width: (t == null ? void 0 : t.width) || 0,
|
|
87
87
|
height: (t == null ? void 0 : t.height) || 0
|
|
88
88
|
};
|
|
89
89
|
}, ie = Y(({
|
|
90
90
|
optionGroupClassName: e,
|
|
91
|
-
options:
|
|
91
|
+
options: h,
|
|
92
92
|
value: t,
|
|
93
93
|
variant: o = "standard",
|
|
94
|
-
labelProps:
|
|
95
|
-
postAdornmentProps:
|
|
96
|
-
helperTextProps:
|
|
97
|
-
className:
|
|
98
|
-
fullWidth:
|
|
94
|
+
labelProps: f,
|
|
95
|
+
postAdornmentProps: c,
|
|
96
|
+
helperTextProps: r,
|
|
97
|
+
className: R,
|
|
98
|
+
fullWidth: y = !1,
|
|
99
99
|
disabled: i = !1,
|
|
100
|
-
required:
|
|
100
|
+
required: v = !1,
|
|
101
101
|
error: s = null,
|
|
102
|
-
isStandalone:
|
|
103
|
-
tabIndex:
|
|
104
|
-
menuHtmlAttributes:
|
|
105
|
-
htmlAttributes:
|
|
106
|
-
onChange:
|
|
102
|
+
isStandalone: V = !1,
|
|
103
|
+
tabIndex: E = -1,
|
|
104
|
+
menuHtmlAttributes: F,
|
|
105
|
+
htmlAttributes: O,
|
|
106
|
+
onChange: _
|
|
107
107
|
}, oe) => {
|
|
108
|
-
const
|
|
109
|
-
currentValue:
|
|
110
|
-
setCurrentValue:
|
|
111
|
-
} = X(t,
|
|
112
|
-
U([
|
|
113
|
-
l &&
|
|
108
|
+
const S = B(null), C = B(null), [l, k] = L(!1), [W, M] = L(null), {
|
|
109
|
+
currentValue: b,
|
|
110
|
+
setCurrentValue: N
|
|
111
|
+
} = X(t, V);
|
|
112
|
+
U([S, C], () => {
|
|
113
|
+
l && k(!1);
|
|
114
114
|
});
|
|
115
|
-
const j = (
|
|
116
|
-
if (
|
|
115
|
+
const j = (u) => {
|
|
116
|
+
if (u.preventDefault(), !i) {
|
|
117
117
|
if (!l) {
|
|
118
|
-
const
|
|
118
|
+
const d = ne(S);
|
|
119
119
|
M({
|
|
120
|
-
...
|
|
121
|
-
top:
|
|
120
|
+
...d,
|
|
121
|
+
top: d.top + d.height
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
k((d) => !d);
|
|
125
125
|
}
|
|
126
|
-
}, G = Q(() => !!(i || l ||
|
|
127
|
-
|
|
128
|
-
}, [
|
|
129
|
-
return /* @__PURE__ */ I(
|
|
130
|
-
/* @__PURE__ */ I(
|
|
131
|
-
/* @__PURE__ */ n(
|
|
132
|
-
/* @__PURE__ */ n(
|
|
133
|
-
/* @__PURE__ */ n(
|
|
134
|
-
/* @__PURE__ */ n(
|
|
135
|
-
/* @__PURE__ */ n(
|
|
126
|
+
}, G = Q(() => !!(i || l || b)), a = h.find((u) => u.value === b), H = $(() => /* @__PURE__ */ n(g.PostAdornmentContentWrapper, { $isShowed: l, $disabled: i, className: m("select-post-adornment-content", l && "select-post-adornment-content--showed", i && "select-post-adornment-content--disabled"), children: (c == null ? void 0 : c.children) ?? /* @__PURE__ */ n(p, { children: /* @__PURE__ */ n(T, { name: "chevron-down" }) }) }), [i, l, c == null ? void 0 : c.children]), D = J((u) => (d) => {
|
|
127
|
+
_ == null || _(u, d), k(!1), N(u);
|
|
128
|
+
}, [_, N, k]);
|
|
129
|
+
return /* @__PURE__ */ I(g.Container, { ...O, $fullWidth: y, className: m("select", y && "select--fullWidth", R), children: [
|
|
130
|
+
/* @__PURE__ */ I(g.Box, { $variant: o, $disabled: i, $fullWidth: y, $isError: !!s, ref: S, onClick: j, tabIndex: E, className: m("select-box", y && "select-box--full-width", i && "select-box--disabled", !!s && "select-box--error", `select-box--variant-${o}`), children: [
|
|
131
|
+
/* @__PURE__ */ n(p, { children: !!(f != null && f.children) && /* @__PURE__ */ n(P, { ...f, required: v, disabled: i, variant: o, isLabelCollapsed: G, isFocused: l, isError: !!s }) }),
|
|
132
|
+
/* @__PURE__ */ n(g.FakeSelect, { required: v, disabled: i }),
|
|
133
|
+
/* @__PURE__ */ n(g.InnerBox, { $hasLabel: !!(f != null && f.children), $variant: o, $disabled: i, className: m("select-inner-box", `select-inner-box--variant-${o}`, !!(f != null && f.children) && "select-inner-box--hasLabel", i && "select-inner-box--disabled"), title: typeof (a == null ? void 0 : a.label) == "string" ? a == null ? void 0 : a.label : void 0, children: a == null ? void 0 : a.label }),
|
|
134
|
+
/* @__PURE__ */ n(p, { children: !!(c != null && c.children) && /* @__PURE__ */ n(ee, { ...c, variant: o, children: H }) }),
|
|
135
|
+
/* @__PURE__ */ n(p, { children: !!(r != null && r.children) && /* @__PURE__ */ n(A, { ...r, isError: !!s, variant: o, children: (s == null ? void 0 : s.message) ?? (r == null ? void 0 : r.children) ?? "" }) })
|
|
136
136
|
] }),
|
|
137
|
-
/* @__PURE__ */ n(K, { className:
|
|
137
|
+
/* @__PURE__ */ n(K, { className: m("portal-select", e), children: /* @__PURE__ */ n(p, { children: l && /* @__PURE__ */ n(te, { ref: C, options: h, position: W, isShowed: l, optionGroupClassName: e, currentValue: b, htmlAttributes: F, selectOption: D }) }) })
|
|
138
138
|
] });
|
|
139
139
|
});
|
|
140
140
|
ie.displayName = "Select";
|
|
141
141
|
export {
|
|
142
|
-
|
|
142
|
+
g as S,
|
|
143
143
|
ie as a
|
|
144
144
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D4NXEE_c.cjs");exports.Select=e.Select;
|
package/dist/index.js
CHANGED
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.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"styled-components": "*",
|
|
27
27
|
"clsx": "*",
|
|
28
28
|
"react-hook-form": "*",
|
|
29
|
-
"@purr-react-styled-components/components.
|
|
30
|
-
"@purr-react-styled-components/components.
|
|
31
|
-
"@purr-react-styled-components/components.
|
|
32
|
-
"@purr-react-styled-components/utils.helpers": "0.0.
|
|
33
|
-
"@purr-core/utils.definitions": "0.0.
|
|
34
|
-
"@purr-react-styled-components/components.icon": "0.0.
|
|
35
|
-
"@purr-core/components.portal": "0.0.
|
|
36
|
-
"@purr-core/hooks.block": "0.0.
|
|
37
|
-
"@purr-core/hooks.not-click-on-elements": "0.0.
|
|
38
|
-
"@purr-core/hooks.sync-state-with-props": "0.0.
|
|
29
|
+
"@purr-react-styled-components/components.helper-text": "0.0.4",
|
|
30
|
+
"@purr-react-styled-components/components.label": "0.0.4",
|
|
31
|
+
"@purr-react-styled-components/components.post-adornment": "0.0.4",
|
|
32
|
+
"@purr-react-styled-components/utils.helpers": "0.0.4",
|
|
33
|
+
"@purr-core/utils.definitions": "0.0.7",
|
|
34
|
+
"@purr-react-styled-components/components.icon": "0.0.4",
|
|
35
|
+
"@purr-core/components.portal": "0.0.4",
|
|
36
|
+
"@purr-core/hooks.block": "0.0.6",
|
|
37
|
+
"@purr-core/hooks.not-click-on-elements": "0.0.5",
|
|
38
|
+
"@purr-core/hooks.sync-state-with-props": "0.0.5"
|
|
39
39
|
},
|
|
40
40
|
"author": "@DinhThienPhuc",
|
|
41
41
|
"license": "ISC",
|
package/dist/_menu-BoZEsfHP.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/_menu-C8lQ1g_y.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-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;
|
package/dist/index-DjXPDt7j.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|