@kvdbil/components 12.3.4 → 12.4.0
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.
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
border: 2px solid ${s.default.colors.gray.light2};
|
|
20
20
|
`,h=r.css`
|
|
21
21
|
background: ${s.default.colors.gray.light2};
|
|
22
|
+
z-index: 1;
|
|
22
23
|
`,p=c.default.div`
|
|
23
24
|
display: flex;
|
|
24
25
|
align-items: flex-start;
|
|
@@ -77,4 +78,4 @@
|
|
|
77
78
|
user-select: none;
|
|
78
79
|
color: ${({theme:m,isDisabled:y})=>y?m.colors.text.disabled:m.colors.text.dark};
|
|
79
80
|
margin-left: 0.5rem;
|
|
80
|
-
`,g=({name:m=o.generateNameHash("check-box"),isDisabled:y=!1,size:k="regular",checked:$=!1,color:v="secondary",label:j
|
|
81
|
+
`,g=({name:m=o.generateNameHash("check-box"),isDisabled:y=!1,size:k="regular",checked:$=!1,color:v="secondary",label:z,...j})=>d.default.createElement(p,null,d.default.createElement(x,{...j,type:"checkbox",checked:$,"data-validate":"checked",name:m,id:m,color:v,disabled:y,isDisabled:y,boxSize:k}),d.default.createElement(b,{size:k,color:v,isChecked:$,isDisabled:y},d.default.createElement(t.default,null)),z&&d.default.createElement(f,{as:"label",htmlFor:m,isDisabled:y},z));exports.CheckBox=g,exports.default=g;
|
|
@@ -10,13 +10,9 @@
|
|
|
10
10
|
fill: ${a.default.colors.gray.dark5};
|
|
11
11
|
transition: ${t.DEFAULT_TRANSITION_MS};
|
|
12
12
|
|
|
13
|
-
${$=>$.isDisabled&&`
|
|
14
|
-
fill: ${a.default.colors.gray.light1};
|
|
15
|
-
`}
|
|
13
|
+
${$=>$.isDisabled&&` fill: ${a.default.colors.gray.light1}; `}
|
|
16
14
|
|
|
17
|
-
${$=>$.isFocused&&`
|
|
18
|
-
fill: ${$.theme.colors.text.dark};
|
|
19
|
-
`}
|
|
15
|
+
${$=>$.isFocused&&` fill: ${$.theme.colors.text.dark}; `}
|
|
20
16
|
`,g=u.default.span`
|
|
21
17
|
${l.CaptionStyle}
|
|
22
18
|
display: block;
|
|
@@ -38,5 +34,6 @@
|
|
|
38
34
|
transition: transform ${t.DEFAULT_TRANSITION_MS};
|
|
39
35
|
|
|
40
36
|
transform: ${$=>$.$isMenuOpen?"rotate(-180deg)":"rotate(0deg)"};
|
|
37
|
+
|
|
41
38
|
transform-origin: 50% 60%;
|
|
42
|
-
`,y=({selectProps:{menuIsOpen:$=!1},isFocused:
|
|
39
|
+
`,y=({selectProps:{menuIsOpen:$=!1},isFocused:B=!1,isDisabled:C})=>s.default.createElement(b,{$isDisabled:C,$isFocused:B,$isMenuOpen:$,$theme:a.default});function x({className:$,color:B="primary",forwardRef:C,hasError:D=!1,height:E,helperText:T,isDisabled:I=!1,onBlur:_=()=>null,onFocus:R=()=>null,onInputChange:A=()=>null,placeholder:z="",name:w,...F}){var j;const[L,S]=e.useState(!1),[W,H]=e.useState(""),M=({isSelected:k,isFocused:v,isDisabled:q})=>k?a.default.colors[B].main:q?a.default.colors.background.light:v?a.default.colors.background.gray:a.default.colors.background.light,P=((k,v)=>v?a.default.colors.error.main:k?a.default.colors.text.dark:a.default.colors.gray.light1)(L,D),N=Boolean(F.label)===!1;return s.default.createElement(c,{className:$},!N&&F.label&&s.default.createElement(d.Label,{htmlFor:w,height:E,isFocused:L,hasValue:Boolean(F.value||W),disabled:I,theme:a.default,hasError:D},F.label),F.prefix&&s.default.createElement(h,{isDisabled:I,isFocused:L},F.prefix),s.default.createElement(n.default,{...F,inputId:w,name:w,ref:C,isDisabled:I,onInputChange:(k,v)=>{A(k,v),H(k)},placeholder:z,onFocus:k=>{S(!0),R(k)},onBlur:k=>{S(!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.75rem",backgroundColor:a.default.colors.background.light,borderColor:P,boxShadow:"none",minHeight:"3rem","&:hover":{borderColor:"none"},...m(I),...p(D),...f(Boolean(F.prefix))}),placeholder:k=>N?{...k,color:a.default.colors.text.dark,fontWeight:600}:{...k,display:L?"static":"none"},singleValue:k=>({...k,maxWidth:"calc(100% - 3.3rem)",width:"calc(100% - 3.3rem)"}),menuList:k=>({...k,padding:"8px 0"}),menu:k=>({...k,borderRadius:0,boxShadow:a.default.elevations.elevation2,zIndex:2,padding:"0"}),option:(k,{isSelected:v,isFocused:q,isDisabled:O})=>({...k,padding:"1rem",cursor:O?"not-allowed":"pointer","&:hover":{background:M({isSelected:v,isFocused:!0,isDisabled:O})},background:M({isSelected:v,isFocused:q}),...f(Boolean(F.prefix))}),valueContainer:k=>({...k,position:"static",padding:E?E-1+"rem 0 ":0,height:E?"auto":"21px"}),clearIndicator:k=>({...k,paddingTop:0,paddingBottom:0})},components:{IndicatorSeparator:()=>null,DropdownIndicator:y,...(j=F.components)!=null?j:{}}}),T&&s.default.createElement(g,{hasError:D},T))}exports.Select=x,exports.default=x;
|
|
@@ -29,11 +29,12 @@ import t from"react";import i,{css as r}from"styled-components";import m from"..
|
|
|
29
29
|
border: 2px solid ${s.colors[e].main};
|
|
30
30
|
`,$=r`
|
|
31
31
|
background: ${s.colors.gray.light2};
|
|
32
|
-
|
|
32
|
+
z-index: 1;
|
|
33
|
+
`,z=i.div`
|
|
33
34
|
display: flex;
|
|
34
35
|
align-items: flex-start;
|
|
35
36
|
box-sizing: border-box;
|
|
36
|
-
`,
|
|
37
|
+
`,v=i.input.attrs({type:"checkbox"})`
|
|
37
38
|
position: absolute;
|
|
38
39
|
appearance: none;
|
|
39
40
|
width: 100%;
|
|
@@ -77,4 +78,4 @@ import t from"react";import i,{css as r}from"styled-components";import m from"..
|
|
|
77
78
|
user-select: none;
|
|
78
79
|
color: ${({theme:e,isDisabled:o})=>o?e.colors.text.disabled:e.colors.text.dark};
|
|
79
80
|
margin-left: 0.5rem;
|
|
80
|
-
`,h=({name:e=x("check-box"),isDisabled:o=!1,size:c="regular",checked:n=!1,color:a="secondary",label:l,...p})=>t.createElement(
|
|
81
|
+
`,h=({name:e=x("check-box"),isDisabled:o=!1,size:c="regular",checked:n=!1,color:a="secondary",label:l,...p})=>t.createElement(z,null,t.createElement(v,{...p,type:"checkbox",checked:n,"data-validate":"checked",name:e,id:e,color:a,disabled:o,isDisabled:o,boxSize:c}),t.createElement(C,{size:c,color:a,isChecked:n,isDisabled:o},t.createElement(m,null)),l&&t.createElement(S,{as:"label",htmlFor:e,isDisabled:o},l));export{h as CheckBox,h as default};
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n,{useState as k}from"react";import _ from"react-select";import m from"styled-components";import{DEFAULT_TRANSITION_MS as F}from"../../shared/constants.js";import r from"../../theme.js";import{CaptionStyle as A}from"../../typography/BodyText/index.js";import{Label as M}from"../FieldLabel.js";import"../../shared/media-queries.js";const O=m.div`
|
|
2
2
|
font-family: ${({theme:e})=>e.typography.fontBaseFamily};
|
|
3
3
|
position: relative;
|
|
4
|
-
`,
|
|
4
|
+
`,C=e=>e&&{paddingLeft:"2.5rem"},z=e=>e&&{border:`1px solid ${r.colors.gray.light1}`,color:r.colors.gray.dark1,fill:r.colors.gray.light1},H=e=>e&&{border:`2px solid ${r.colors.error.dark}`},V=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: ${F};
|
|
12
12
|
|
|
13
|
-
${e=>e.isDisabled&&`
|
|
14
|
-
fill: ${r.colors.gray.light1};
|
|
15
|
-
`}
|
|
13
|
+
${e=>e.isDisabled&&` fill: ${r.colors.gray.light1}; `}
|
|
16
14
|
|
|
17
|
-
${e=>e.isFocused&&`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`,V=m.span`
|
|
21
|
-
${_}
|
|
15
|
+
${e=>e.isFocused&&` fill: ${e.theme.colors.text.dark}; `}
|
|
16
|
+
`,W=m.span`
|
|
17
|
+
${A}
|
|
22
18
|
display: block;
|
|
23
19
|
margin-top: 0.25rem;
|
|
24
20
|
color: ${({hasError:e})=>e?r.colors.error.dark:r.colors.text.disabled};
|
|
25
|
-
`,N=e=>
|
|
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)`
|
|
26
22
|
width: 0.8rem;
|
|
27
23
|
height: 0.8rem;
|
|
28
24
|
margin: 0 0.5rem;
|
|
@@ -35,8 +31,9 @@ import t,{useState as x}from"react";import T from"react-select";import m from"st
|
|
|
35
31
|
stroke: currentColor;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
transition: transform ${
|
|
34
|
+
transition: transform ${F};
|
|
39
35
|
|
|
40
36
|
transform: ${e=>e.$isMenuOpen?"rotate(-180deg)":"rotate(0deg)"};
|
|
37
|
+
|
|
41
38
|
transform-origin: 50% 60%;
|
|
42
|
-
`,
|
|
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 v({className:e,color:a="primary",forwardRef:u,hasError:i=!1,height:s,helperText:p,isDisabled:c=!1,onBlur:B=()=>null,onFocus:L=()=>null,onInputChange:S=()=>null,placeholder:w="",name:f,...t}){var h;const[d,b]=k(!1),[I,E]=k(""),D=(o,l)=>{S(o,l),E(o)},y=({isSelected:o,isFocused:l,isDisabled:g})=>o?r.colors[a].main:g?r.colors.background.light:l?r.colors.background.gray:r.colors.background.light,j=o=>{b(!0),L(o)},R=o=>{b(!1),B(o)},T=q(d,i),$=Boolean(t.label)===!1;return n.createElement(O,{className:e},!$&&t.label&&n.createElement(M,{htmlFor:f,height:s,isFocused:d,hasValue:Boolean(t.value||I),disabled:c,theme:r,hasError:i},t.label),t.prefix&&n.createElement(V,{isDisabled:c,isFocused:d},t.prefix),n.createElement(_,{...t,inputId:f,name:f,ref:u,isDisabled:c,onInputChange:D,placeholder:w,onFocus:j,onBlur:R,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.75rem",backgroundColor:r.colors.background.light,borderColor:T,boxShadow:"none",minHeight:"3rem","&:hover":{borderColor:"none"},...z(c),...H(i),...C(Boolean(t.prefix))}),placeholder:o=>$?{...o,color:r.colors.text.dark,fontWeight:600}:{...o,display:d?"static":"none"},singleValue:o=>({...o,maxWidth:"calc(100% - 3.3rem)",width:"calc(100% - 3.3rem)"}),menuList:o=>({...o,padding:"8px 0"}),menu:o=>({...o,borderRadius:0,boxShadow:r.elevations.elevation2,zIndex:2,padding:"0"}),option:(o,{isSelected:l,isFocused:g,isDisabled:x})=>({...o,padding:"1rem",cursor:x?"not-allowed":"pointer","&:hover":{background:y({isSelected:l,isFocused:!0,isDisabled:x})},background:y({isSelected:l,isFocused:g}),...C(Boolean(t.prefix))}),valueContainer:o=>({...o,position:"static",padding:s?`${s-1}rem 0 `:0,height:s?"auto":"21px"}),clearIndicator:o=>({...o,paddingTop:0,paddingBottom:0})},components:{IndicatorSeparator:()=>null,DropdownIndicator:U,...(h=t.components)!=null?h:{}}}),p&&n.createElement(W,{hasError:i},p))}export{v as Select,v as default};
|
package/package.json
CHANGED
|
@@ -9,28 +9,48 @@ export interface DropdownIndicatorProps extends IndicatorProps<OptionTypeBase, f
|
|
|
9
9
|
isFocused: boolean;
|
|
10
10
|
isDisabled: boolean;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* This component is a thin wrapper around react-select, as it handles a lot of functionality smoothly.
|
|
14
|
-
* Simply with our kvdbil styling applied to it.
|
|
15
|
-
**/
|
|
16
12
|
declare type OptionType = {
|
|
17
13
|
label: string | ReactNode;
|
|
18
14
|
value: string;
|
|
19
15
|
};
|
|
20
|
-
export interface SelectProps extends NamedProps<
|
|
16
|
+
export interface SelectProps<Option extends OptionType = OptionType, IsMulti extends boolean = false> extends NamedProps<Option, IsMulti> {
|
|
21
17
|
autoFocus?: boolean;
|
|
22
18
|
className?: string;
|
|
23
19
|
color?: Color;
|
|
24
|
-
forwardRef?: RefObject<ReactSelect<
|
|
20
|
+
forwardRef?: RefObject<ReactSelect<Option, IsMulti>>;
|
|
25
21
|
hasError?: boolean;
|
|
26
22
|
height?: number;
|
|
27
23
|
helperText?: string;
|
|
28
24
|
isDisabled?: boolean;
|
|
29
25
|
label?: string;
|
|
30
|
-
onChange(value: ValueType<
|
|
26
|
+
onChange(value: ValueType<Option, IsMulti>, actionMeta: ActionMeta<Option>): void;
|
|
31
27
|
placeholder?: string;
|
|
32
28
|
prefix?: ReactNode;
|
|
33
29
|
name: string;
|
|
34
30
|
}
|
|
35
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @description
|
|
33
|
+
* This component is a thin wrapper around react-select, as it handles a lot of functionality smoothly.
|
|
34
|
+
* Simply with our kvdbil styling applied to it.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Example on how to create a custom option type
|
|
38
|
+
*
|
|
39
|
+
* interface OptionType {
|
|
40
|
+
* label: string;
|
|
41
|
+
* value: number | string;
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* const Component = () => {
|
|
45
|
+
* const [value, setValue] = useState(args.value);
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <Select<OptionType>
|
|
49
|
+
* onChange={setValue}
|
|
50
|
+
* value={value}
|
|
51
|
+
* />
|
|
52
|
+
* );
|
|
53
|
+
* };
|
|
54
|
+
*/
|
|
55
|
+
export declare function Select<Option extends OptionType = OptionType, IsMulti extends boolean = false>({ className, color, forwardRef, hasError, height, helperText, isDisabled, onBlur, onFocus, onInputChange, placeholder, name, ...props }: SelectProps<Option, IsMulti>): JSX.Element;
|
|
36
56
|
export default Select;
|