@kvdbil/components 12.4.2 → 13.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("react-select"),o=require("styled-components"),t=require("../../shared/constants.js"),a=require("../../theme.js"),l=require("../../typography/BodyText/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("react-select"),o=require("styled-components"),t=require("../../shared/constants.js"),a=require("../../theme.js"),l=require("../../typography/BodyText/index.js"),i=require("../FieldLabel.js");function d($){return $&&typeof $=="object"&&"default"in $?$:{default:$}}require("../../shared/media-queries.js");var n=d(e),s=d(r),u=d(o);const c=u.default.div`
|
|
2
2
|
font-family: ${({theme:$})=>$.typography.fontBaseFamily};
|
|
3
3
|
position: relative;
|
|
4
|
-
`,
|
|
4
|
+
`,m=$=>$&&{paddingLeft:"2.5rem"},f=$=>$&&{border:`1px solid ${a.default.colors.gray.light1}`,color:a.default.colors.gray.dark1,fill:a.default.colors.gray.light1},p=$=>$&&{border:`2px solid ${a.default.colors.error.dark}`},g=u.default.div`
|
|
5
5
|
position: absolute;
|
|
6
6
|
z-index: 1;
|
|
7
7
|
top: 0.5rem;
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
display: block;
|
|
19
19
|
margin-top: 0.25rem;
|
|
20
20
|
color: ${({hasError:$})=>$?a.default.colors.error.dark:a.default.colors.text.disabled};
|
|
21
|
-
`,b=u.default($=>
|
|
22
|
-
width: 0.
|
|
23
|
-
height: 0.
|
|
24
|
-
margin: 0
|
|
21
|
+
`,b=u.default($=>n.default.createElement("svg",{...$},n.default.createElement("symbol",{id:"icon-arrow",viewBox:"0 0 19 19"},n.default.createElement("path",{d:"M2.03039 7.95496L9.80856 15.7331C9.90619 15.8308 10.0645 15.8308 10.1621 15.7331L17.9403 7.95496L19.0009 9.01562L11.2228 16.7938C10.5394 17.4772 9.43132 17.4772 8.7479 16.7938L0.969727 9.01562L2.03039 7.95496Z"})),n.default.createElement("use",{xlinkHref:"#icon-arrow"})))`
|
|
22
|
+
width: 0.75rem;
|
|
23
|
+
height: 0.75rem;
|
|
24
|
+
margin: 0;
|
|
25
25
|
${$=>$.$isFocused&&`color: ${$.$theme.colors.text.dark}`}
|
|
26
26
|
${$=>$.$isDisabled&&`color: ${$.$theme.colors.gray.dark1}`}
|
|
27
27
|
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
transform: ${$=>$.$isMenuOpen?"rotate(-180deg)":"rotate(0deg)"};
|
|
37
37
|
|
|
38
38
|
transform-origin: 50% 60%;
|
|
39
|
-
`,
|
|
39
|
+
`,x=({selectProps:{menuIsOpen:$=!1},isFocused:B=!1,isDisabled:I})=>n.default.createElement(b,{$isDisabled:I,$isFocused:B,$isMenuOpen:$,$theme:a.default});function y({className:$,color:B="primary",forwardRef:I,hasError:v=!1,height:w,helperText:q,isDisabled:D=!1,onBlur:_=()=>null,onFocus:z=()=>null,onInputChange:A=()=>null,placeholder:H="",name:T,...S}){var j;const[L,E]=e.useState(!1),[W,P]=e.useState(""),O=({isSelected:k,isFocused:F,isDisabled:C})=>k?a.default.colors[B].main:C?a.default.colors.background.light:F?a.default.colors.background.gray:a.default.colors.background.light,M=((k,F)=>F?a.default.colors.error.main:k?a.default.colors.text.dark:a.default.colors.gray.light1)(L,v),N=Boolean(S.label)===!1;return n.default.createElement(c,{className:$},!N&&S.label&&n.default.createElement(i.Label,{htmlFor:T,height:w,isFocused:L,hasValue:Boolean(S.value||W),disabled:D,theme:a.default,hasError:v},S.label),S.prefix&&n.default.createElement(g,{isDisabled:D,isFocused:L},S.prefix),n.default.createElement(s.default,{...S,inputId:T,name:T,ref:I,isDisabled:D,onInputChange:(k,F)=>{A(k,F),P(k)},placeholder:H,onFocus:k=>{E(!0),z(k)},onBlur:k=>{E(!1),_(k)},styles:{control:k=>({...k,borderRadius:0,color:a.default.colors.text.dark,fontFamily:a.default.typography.fontBaseFamily,fontSize:"1rem",fontWeight:400,cursor:"pointer",padding:"0.7rem 0.5rem",backgroundColor:a.default.colors.background.light,borderColor:M,boxShadow:"none",minHeight:"3rem","&:hover":{borderColor:"none"},...f(D),...p(v),...m(Boolean(S.prefix))}),input:k=>({...k,height:"auto",margin:0,padding:0}),placeholder:k=>{const F={...k,fontSize:"1rem",lineHeight:"1.5rem",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",margin:0};return N?{...F,color:a.default.colors.text.dark,fontWeight:600}:{...F,display:L?"static":"none"}},singleValue:k=>({...k,maxWidth:"calc(100% - 3.3rem)",width:"calc(100% - 3.3rem)"}),menuList:k=>({...k,padding:"0.5rem 0",paddingBottom:"5rem",marginTop:0,border:`1px solid ${M}`,borderTop:"none",display:"flex",flexDirection:"column",gap:"0.5rem"}),menu:k=>({...k,borderRadius:0,boxShadow:"none",zIndex:5,padding:"0",marginTop:"-0.1rem"}),option:(k,{isSelected:F,isFocused:C,isDisabled:R})=>({...k,padding:"0.5rem",lineHeight:"1.5rem",fontSize:"1rem",fontWeight:400,cursor:R?"not-allowed":"pointer","&:hover":{background:O({isSelected:F,isFocused:!0,isDisabled:R})},background:O({isSelected:F,isFocused:C}),...m(Boolean(S.prefix))}),valueContainer:k=>({...k,position:"static",padding:w?w-1+"rem 0 ":0,height:w?"auto":"1.5rem"}),clearIndicator:k=>({...k,paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:"0.2rem"})},components:{IndicatorSeparator:()=>null,DropdownIndicator:x,...(j=S.components)!=null?j:{}}}),q&&n.default.createElement(h,{hasError:v},q))}exports.Select=y,exports.default=y;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import n,{useState as F}from"react";import
|
|
1
|
+
import n,{useState as F}from"react";import z from"react-select";import m from"styled-components";import{DEFAULT_TRANSITION_MS as w}from"../../shared/constants.js";import r from"../../theme.js";import{CaptionStyle as H}from"../../typography/BodyText/index.js";import{Label as O}from"../FieldLabel.js";import"../../shared/media-queries.js";const _=m.div`
|
|
2
2
|
font-family: ${({theme:e})=>e.typography.fontBaseFamily};
|
|
3
3
|
position: relative;
|
|
4
|
-
`,
|
|
4
|
+
`,S=e=>e&&{paddingLeft:"2.5rem"},A=e=>e&&{border:`1px solid ${r.colors.gray.light1}`,color:r.colors.gray.dark1,fill:r.colors.gray.light1},M=e=>e&&{border:`2px solid ${r.colors.error.dark}`},W=m.div`
|
|
5
5
|
position: absolute;
|
|
6
6
|
z-index: 1;
|
|
7
7
|
top: 0.5rem;
|
|
8
8
|
margin: 0.35rem 0.75rem;
|
|
9
9
|
|
|
10
10
|
fill: ${r.colors.gray.dark5};
|
|
11
|
-
transition: ${
|
|
11
|
+
transition: ${w};
|
|
12
12
|
|
|
13
13
|
${e=>e.isDisabled&&` fill: ${r.colors.gray.light1}; `}
|
|
14
14
|
|
|
15
15
|
${e=>e.isFocused&&` fill: ${e.theme.colors.text.dark}; `}
|
|
16
|
-
`,
|
|
17
|
-
${
|
|
16
|
+
`,V=m.span`
|
|
17
|
+
${H}
|
|
18
18
|
display: block;
|
|
19
19
|
margin-top: 0.25rem;
|
|
20
20
|
color: ${({hasError:e})=>e?r.colors.error.dark:r.colors.text.disabled};
|
|
21
21
|
`,N=e=>n.createElement("svg",{...e},n.createElement("symbol",{id:"icon-arrow",viewBox:"0 0 19 19"},n.createElement("path",{d:"M2.03039 7.95496L9.80856 15.7331C9.90619 15.8308 10.0645 15.8308 10.1621 15.7331L17.9403 7.95496L19.0009 9.01562L11.2228 16.7938C10.5394 17.4772 9.43132 17.4772 8.7479 16.7938L0.969727 9.01562L2.03039 7.95496Z"})),n.createElement("use",{xlinkHref:"#icon-arrow"})),P=m(N)`
|
|
22
|
-
width: 0.
|
|
23
|
-
height: 0.
|
|
24
|
-
margin: 0
|
|
22
|
+
width: 0.75rem;
|
|
23
|
+
height: 0.75rem;
|
|
24
|
+
margin: 0;
|
|
25
25
|
${e=>e.$isFocused&&`color: ${e.$theme.colors.text.dark}`}
|
|
26
26
|
${e=>e.$isDisabled&&`color: ${e.$theme.colors.gray.dark1}`}
|
|
27
27
|
|
|
@@ -31,9 +31,9 @@ import n,{useState as F}from"react";import _ from"react-select";import m from"st
|
|
|
31
31
|
stroke: currentColor;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
transition: transform ${
|
|
34
|
+
transition: transform ${w};
|
|
35
35
|
|
|
36
36
|
transform: ${e=>e.$isMenuOpen?"rotate(-180deg)":"rotate(0deg)"};
|
|
37
37
|
|
|
38
38
|
transform-origin: 50% 60%;
|
|
39
|
-
`,q=(e,a)=>a?r.colors.error.main:e?r.colors.text.dark:r.colors.gray.light1,U=({selectProps:{menuIsOpen:e=!1},isFocused:a=!1,isDisabled:u})=>n.createElement(P,{$isDisabled:u,$isFocused:a,$isMenuOpen:e,$theme:r});function
|
|
39
|
+
`,q=(e,a)=>a?r.colors.error.main:e?r.colors.text.dark:r.colors.gray.light1,U=({selectProps:{menuIsOpen:e=!1},isFocused:a=!1,isDisabled:u})=>n.createElement(P,{$isDisabled:u,$isFocused:a,$isMenuOpen:e,$theme:r});function C({className:e,color:a="primary",forwardRef:u,hasError:i=!1,height:s,helperText:p,isDisabled:d=!1,onBlur:B=()=>null,onFocus:L=()=>null,onInputChange:v=()=>null,placeholder:I="",name:g,...t}){var h;const[c,b]=F(!1),[E,T]=F(""),D=(o,l)=>{v(o,l),T(o)},y=({isSelected:o,isFocused:l,isDisabled:f})=>o?r.colors[a].main:f?r.colors.background.light:l?r.colors.background.gray:r.colors.background.light,R=o=>{b(!0),L(o)},j=o=>{b(!1),B(o)},x=q(c,i),$=Boolean(t.label)===!1;return n.createElement(_,{className:e},!$&&t.label&&n.createElement(O,{htmlFor:g,height:s,isFocused:c,hasValue:Boolean(t.value||E),disabled:d,theme:r,hasError:i},t.label),t.prefix&&n.createElement(W,{isDisabled:d,isFocused:c},t.prefix),n.createElement(z,{...t,inputId:g,name:g,ref:u,isDisabled:d,onInputChange:D,placeholder:I,onFocus:R,onBlur:j,styles:{control:o=>({...o,borderRadius:0,color:r.colors.text.dark,fontFamily:r.typography.fontBaseFamily,fontSize:"1rem",fontWeight:400,cursor:"pointer",padding:"0.7rem 0.5rem",backgroundColor:r.colors.background.light,borderColor:x,boxShadow:"none",minHeight:"3rem","&:hover":{borderColor:"none"},...A(d),...M(i),...S(Boolean(t.prefix))}),input:o=>({...o,height:"auto",margin:0,padding:0}),placeholder:o=>{const l={...o,fontSize:"1rem",lineHeight:"1.5rem",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",margin:0};return $?{...l,color:r.colors.text.dark,fontWeight:600}:{...l,display:c?"static":"none"}},singleValue:o=>({...o,maxWidth:"calc(100% - 3.3rem)",width:"calc(100% - 3.3rem)"}),menuList:o=>({...o,padding:"0.5rem 0",paddingBottom:"5rem",marginTop:0,border:`1px solid ${x}`,borderTop:"none",display:"flex",flexDirection:"column",gap:"0.5rem"}),menu:o=>({...o,borderRadius:0,boxShadow:"none",zIndex:5,padding:"0",marginTop:"-0.1rem"}),option:(o,{isSelected:l,isFocused:f,isDisabled:k})=>({...o,padding:"0.5rem",lineHeight:"1.5rem",fontSize:"1rem",fontWeight:400,cursor:k?"not-allowed":"pointer","&:hover":{background:y({isSelected:l,isFocused:!0,isDisabled:k})},background:y({isSelected:l,isFocused:f}),...S(Boolean(t.prefix))}),valueContainer:o=>({...o,position:"static",padding:s?`${s-1}rem 0 `:0,height:s?"auto":"1.5rem"}),clearIndicator:o=>({...o,paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:"0.2rem"})},components:{IndicatorSeparator:()=>null,DropdownIndicator:U,...(h=t.components)!=null?h:{}}}),p&&n.createElement(V,{hasError:i},p))}export{C as Select,C as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvdbil/components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react-collapse": ">= 5.0.1",
|
|
32
32
|
"react-day-picker": ">= 7.4.8",
|
|
33
33
|
"react-dom": ">= 17.0.0",
|
|
34
|
-
"react-select": "
|
|
34
|
+
"react-select": "5.7.3",
|
|
35
35
|
"react-transition-group": ">= 4.0.0",
|
|
36
36
|
"styled-components": ">= 5.1.17"
|
|
37
37
|
},
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"@types/react": "^16.9.49",
|
|
70
70
|
"@types/react-collapse": "^5.0.0",
|
|
71
71
|
"@types/react-dom": "^16.9.8",
|
|
72
|
-
"@types/react-select": "^3.0.22",
|
|
73
72
|
"@types/react-transition-group": "^4.4.0",
|
|
74
73
|
"@types/styled-components": "^5.1.13",
|
|
75
74
|
"@types/uuid": "^8.3.0",
|
|
@@ -97,7 +96,7 @@
|
|
|
97
96
|
"react-dom": "^17.0.2",
|
|
98
97
|
"react-is": "^16.13.1",
|
|
99
98
|
"react-scripts": "^4.0.3",
|
|
100
|
-
"react-select": "
|
|
99
|
+
"react-select": "5.7.3",
|
|
101
100
|
"react-select-event": "^5.3.0",
|
|
102
101
|
"react-transition-group": "^4.0.0",
|
|
103
102
|
"rollup": "^2.56.3",
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { ActionMeta, GroupBase, Props, SelectInstance, DropdownIndicatorProps as SelectDropdownIndicatorProps, OnChangeValue } from 'react-select';
|
|
3
3
|
import { Color } from '../../Types';
|
|
4
|
-
export interface DropdownIndicatorProps extends
|
|
5
|
-
selectProps: {
|
|
6
|
-
menuIsOpen?: boolean;
|
|
7
|
-
lol?: string;
|
|
8
|
-
};
|
|
4
|
+
export interface DropdownIndicatorProps extends SelectDropdownIndicatorProps {
|
|
9
5
|
isFocused: boolean;
|
|
10
6
|
isDisabled: boolean;
|
|
11
7
|
}
|
|
@@ -13,17 +9,17 @@ declare type OptionType = {
|
|
|
13
9
|
label: string | ReactNode;
|
|
14
10
|
value: string;
|
|
15
11
|
};
|
|
16
|
-
export interface SelectProps<Option
|
|
12
|
+
export interface SelectProps<Option = OptionType, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> extends Props<Option, IsMulti, Group> {
|
|
17
13
|
autoFocus?: boolean;
|
|
18
14
|
className?: string;
|
|
19
15
|
color?: Color;
|
|
20
|
-
forwardRef?: RefObject<
|
|
16
|
+
forwardRef?: RefObject<SelectInstance<Option, IsMulti, Group>>;
|
|
21
17
|
hasError?: boolean;
|
|
22
18
|
height?: number;
|
|
23
19
|
helperText?: string;
|
|
24
20
|
isDisabled?: boolean;
|
|
25
21
|
label?: string;
|
|
26
|
-
onChange(value:
|
|
22
|
+
onChange(value: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>): void;
|
|
27
23
|
placeholder?: string;
|
|
28
24
|
prefix?: ReactNode;
|
|
29
25
|
name: string;
|
|
@@ -52,5 +48,5 @@ export interface SelectProps<Option extends OptionType = OptionType, IsMulti ext
|
|
|
52
48
|
* );
|
|
53
49
|
* };
|
|
54
50
|
*/
|
|
55
|
-
export declare function Select<Option
|
|
51
|
+
export declare function Select<Option = OptionType, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ className, color, forwardRef, hasError, height, helperText, isDisabled, onBlur, onFocus, onInputChange, placeholder, name, ...props }: SelectProps<Option, IsMulti, Group>): JSX.Element;
|
|
56
52
|
export default Select;
|