@lifesg/react-design-system 1.0.0-alpha.7 → 1.0.0-alpha.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/cjs/index.js +27 -26
- package/cjs/index.js.map +1 -1
- package/form/form-label.style.d.ts +1 -1
- package/form/index.js +156 -155
- package/form/index.js.map +1 -1
- package/index.js +27 -26
- package/index.js.map +1 -1
- package/input/index.js +4 -4
- package/input/index.js.map +1 -1
- package/input-group/index.js +17 -14
- package/input-group/index.js.map +1 -1
- package/input-group/input-group.style.d.ts +0 -1
- package/input-textarea/index.js +2 -2
- package/input-textarea/index.js.map +1 -1
- package/modal/index.d.ts +1 -1
- package/modal/index.js +15 -17
- package/modal/index.js.map +1 -1
- package/modal/modal.d.ts +1 -1
- package/modal/modal.styles.d.ts +1 -0
- package/modal/types.d.ts +2 -0
- package/navbar/index.js +1 -1
- package/navbar/index.js.map +1 -1
- package/overlay/index.js +1 -1
- package/overlay/index.js.map +1 -1
- package/package.json +1 -1
- package/popover/index.js +9 -11
- package/popover/index.js.map +1 -1
- package/timepicker/index.js +3 -3
- package/timepicker/index.js.map +1 -1
package/index.js
CHANGED
|
@@ -1059,7 +1059,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1059
1059
|
`,e.$disableTransition&&(t+=css`
|
|
1060
1060
|
transition: none;
|
|
1061
1061
|
`),t}}
|
|
1062
|
-
`,Overlay=({show:e=!1,rootId:t,onOverlayClick:r,children:i,backgroundOpacity:a,backgroundBlur:n=!0,disableTransition:s=!1,enableOverlayClick:o=!1,zIndex:l,id:h})=>{const[d,c]=useState(null),[p,u]=useState(),m=useRef(),f=useRef(null),g=i&&React__default.cloneElement(i,{ref:f}),y=h?`lifesg-ds-overlay-root-${h}`:"lifesg-ds-overlay-root";useEffect((()=>{if(e){const e=C();if(v(e),!e){const e=setTimeout((()=>{S("add")}),200);return()=>clearTimeout(e)}}else if(!m.current){const e=setTimeout((()=>{S("
|
|
1062
|
+
`,Overlay=({show:e=!1,rootId:t,onOverlayClick:r,children:i,backgroundOpacity:a,backgroundBlur:n=!0,disableTransition:s=!1,enableOverlayClick:o=!1,zIndex:l,id:h})=>{const[d,c]=useState(null),[p,u]=useState(),m=useRef(),f=useRef(null),g=i&&React__default.cloneElement(i,{ref:f}),y=h?`lifesg-ds-overlay-root-${h}`:"lifesg-ds-overlay-root";useEffect((()=>{if(e){const e=C();if(v(e),!e){const e=setTimeout((()=>{S("add")}),200);return()=>clearTimeout(e)}}else if(!m.current){const e=setTimeout((()=>{S("remove")}),200);return()=>clearTimeout(e)}}),[e]),useEffect((()=>{c(b());const e=C();return v(e),e||x(),()=>{S("remove")}}),[]);const v=e=>{m.current=e,u(e)},b=()=>document&&t?document.getElementById(t):document?document.body:null,C=()=>document.body.classList.contains(OVERLAY_OPEN_CLASSNAME),x=()=>{if(!document.getElementById(STYLESHEET_ID)){const e=document.createElement("style");e.id=STYLESHEET_ID;const t=document.documentElement.clientWidth,r=window.innerWidth-t;e.innerHTML=`\n\t\t\t\t.${OVERLAY_OPEN_CLASSNAME} {\n\t\t\t\t\toverflow: hidden;\n\t\t\t\t\tpadding-right: ${r}px !important;\n\t\t\t\t\t-ms-overflow-style: none;\n\t\t\t\t\tscrollbar-width: none;\n\t\t\t\t}\n\n\t\t\t\t.${OVERLAY_OPEN_CLASSNAME}::-webkit-scrollbar {\n\t\t\t\t\tdisplay: none;\n\t\t\t\t}\n\t\t\t`,document.body.appendChild(e)}},S=e=>{const t=document.body.classList.contains(OVERLAY_OPEN_CLASSNAME);"add"!==e||t?"remove"===e&&t&&document.body.classList.remove(OVERLAY_OPEN_CLASSNAME):document.body.classList.add(OVERLAY_OPEN_CLASSNAME)},_=e=>{e.preventDefault();const t=f.current?.firstChild;t&&t.contains(e.target)||r&&o&&r()};return d?ReactDOM.createPortal(jsx(Root,{id:y,"data-testid":y,$show:e,zIndex:l,$stacked:p,children:i&&jsx(Wrapper$b,{"data-testid":"overlay-wrapper",$show:e,$backgroundOpacity:a||(p?.5:.8),$backgroundBlur:n,$disableTransition:s,$enableOverlayClick:o,onClick:_,children:g})}),d):null},STYLESHEET_ID="lifesg-ds-overlay-stylesheet",OVERLAY_OPEN_CLASSNAME="lifesg-ds-overlay-open",visibilityStyle=(e,t)=>e?`\n\t\t\t${t}: 0;\n\t\t\topacity: 1;\n\t\t\ttransition: all 300ms cubic-bezier(0.21, 0.79, 0.53, 1);\n\t\t\ttransition-delay: 200ms;\n\t\t`:`\n\t\t${t}: -3%;\n\t\topacity: 0;\n\t\ttransition: all 300ms cubic-bezier(0.4, 0.34, 0.38, 1);\n\t`,Container$a=styled.div`
|
|
1063
1063
|
position: relative;
|
|
1064
1064
|
display: flex;
|
|
1065
1065
|
justify-content: center;
|
|
@@ -1069,16 +1069,14 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1069
1069
|
overflow: hidden;
|
|
1070
1070
|
${e=>visibilityStyle(e.show,e.animationFrom||"bottom")}
|
|
1071
1071
|
|
|
1072
|
-
${
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
`}
|
|
1081
|
-
`,Modal$1=({id:e="modal",show:t,animationFrom:r="bottom",children:i,enableOverlayClick:a=!0,rootComponentId:n,zIndex:s,onOverlayClick:o,...l})=>{const[h,d]=useState();useEffect((()=>(d(.01*window.innerHeight),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)})),[]);const c=()=>{const e=.01*window.innerHeight;d(e)};return jsx(Overlay,{"data-testid":`${e}-overlay`,show:t,enableOverlayClick:a,onOverlayClick:o,id:e,rootId:n,zIndex:s,children:jsx(Container$a,{show:t,animationFrom:r,"data-testid":e,verticalHeight:h,...l,children:i})})},Box=styled.div`
|
|
1072
|
+
${MediaQuery.MaxWidth.mobileL} {
|
|
1073
|
+
height: calc(
|
|
1074
|
+
${e=>e.verticalHeight?`${e.verticalHeight}px`:"1vh"} * 100
|
|
1075
|
+
);
|
|
1076
|
+
|
|
1077
|
+
top: ${e=>e.offsetTop||0}px;
|
|
1078
|
+
}
|
|
1079
|
+
`,Modal$1=({id:e="modal",show:t,animationFrom:r="bottom",children:i,enableOverlayClick:a=!0,rootComponentId:n,zIndex:s,onOverlayClick:o,dismissKeyboardOnShow:l=!0,...h})=>{const[d,c]=useState(),[p,u]=useState();useEffect((()=>window.visualViewport?(f(),window.visualViewport.addEventListener("resize",f),()=>{window.visualViewport.removeEventListener("resize",f)}):(m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)})),[]),useEffect((()=>{t&&l&&document.activeElement?.blur?.()}),[t]);const m=()=>{const e=.01*window.innerHeight;c(e)},f=()=>{const e=.01*window.visualViewport.height;c(e),u(window.visualViewport.offsetTop)};return jsx(Overlay,{"data-testid":`${e}-overlay`,show:t,enableOverlayClick:a,onOverlayClick:o,id:e,rootId:n,zIndex:s,children:jsx(Container$a,{show:t,animationFrom:r,"data-testid":e,verticalHeight:d,offsetTop:p,...h,children:i})})},Box=styled.div`
|
|
1082
1080
|
position: relative;
|
|
1083
1081
|
display: flex;
|
|
1084
1082
|
flex-direction: column;
|
|
@@ -1214,21 +1212,21 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1214
1212
|
color: ${Color.Validation.Red.Text};
|
|
1215
1213
|
margin-top: 0.5rem;
|
|
1216
1214
|
margin-bottom: 0;
|
|
1217
|
-
`,Subtitle=styled(Text.
|
|
1215
|
+
`,Subtitle=styled(Text.BodySmall)`
|
|
1218
1216
|
color: ${e=>e.disabled?Color.Neutral[4](e):Color.Neutral[3](e)};
|
|
1219
|
-
`,FormLabel=({children:e,addon:t,subtitle:r,"data-testid":i,...a})=>jsxs(Label$2,{...a,children:[e,t&&t.type&&("popover"===t.type?t&&jsx(PopoverAddon,{addon:t}):null),"string"==typeof r?jsx(Subtitle,{"data-testid":i?`${i}-subtitle`:"subtitle",...a,children:r}):r]}),Container$9=styled.div`
|
|
1217
|
+
`,FormLabel=({children:e,addon:t,subtitle:r,"data-testid":i,...a})=>jsxs(Label$2,{...a,children:[e,t&&t.type&&("popover"===t.type?t&&jsx(PopoverAddon,{addon:t}):null),"string"==typeof r?jsx(Subtitle,{as:"span","data-testid":i?`${i}-subtitle`:"subtitle",...a,children:r}):r]}),Container$9=styled.div`
|
|
1220
1218
|
display: flex;
|
|
1221
1219
|
flex-direction: column;
|
|
1222
1220
|
|
|
1223
1221
|
&:not(:last-child) {
|
|
1224
|
-
margin-bottom:
|
|
1222
|
+
margin-bottom: 2rem;
|
|
1225
1223
|
}
|
|
1226
1224
|
`,FormWrapper=({label:e,errorMessage:t,id:r,disabled:i,children:a,"data-error-testid":n})=>jsxs(Container$9,{children:[e&&jsx(FormLabel,"string"==typeof e?{htmlFor:`${r}-base`,"data-testid":r?`${r}-label`:"form-label",disabled:i,children:e}:{htmlFor:`${r}-base`,"data-testid":r?`${r}-label`:"form-label",disabled:i,...e}),a,t&&jsx(ErrorMessage,{weight:"semibold","data-testid":n||(r?`${r}-error-message`:"error-message"),children:t})]}),FormCustomField=({id:e="form-custom-field","data-error-testid":t,children:r,...i})=>jsx(FormWrapper,{id:e,"data-error-testid":t,...i,children:r}),FormDateInput=({label:e,errorMessage:t,id:r="form-date-input","data-error-testid":i,"data-testid":a,...n})=>jsx(FormWrapper,{id:r,label:e,errorMessage:t,"data-error-testid":i,disabled:n.disabled,children:jsx(DateInput,{id:`${r}-base`,"data-testid":a||r,error:!!t,...n})}),InputElement=styled.input`
|
|
1227
1225
|
${TextStyleHelper.getTextStyle("Body","regular")}
|
|
1228
1226
|
border: 1px solid ${Color.Neutral[5]};
|
|
1229
1227
|
border-radius: 4px;
|
|
1230
1228
|
display: block;
|
|
1231
|
-
padding: 0.2rem 1rem 0.3rem
|
|
1229
|
+
padding: 0.2rem 1rem 0.3rem; // Somehow the input text appears lower
|
|
1232
1230
|
height: 3rem;
|
|
1233
1231
|
width: 100%;
|
|
1234
1232
|
background: ${Color.Neutral[8]};
|
|
@@ -1260,7 +1258,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1260
1258
|
|
|
1261
1259
|
${e=>e.readOnly?css`
|
|
1262
1260
|
border: none;
|
|
1263
|
-
padding
|
|
1261
|
+
padding: 0.2rem 0 0.3rem;
|
|
1264
1262
|
background: transparent !important;
|
|
1265
1263
|
|
|
1266
1264
|
:focus,
|
|
@@ -1287,7 +1285,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1287
1285
|
box-shadow: inset 0 0 4px 1px rgba(221, 102, 102, 0.8);
|
|
1288
1286
|
}
|
|
1289
1287
|
`:void 0}
|
|
1290
|
-
`,Component$6=({value:e,spacing:t,type:r,error:i,disabled:a,onChange:n,...s},o)=>{const l=()=>"tel"===r&&t,h=e=>{const t=e.target,r=t.value,i=t.value.replace(/\s/g,"");t.value=i,n(e),t.value=r},d=e?(e=>e?l()?StringHelper.transformWithSpaces(e,t):e:"")(e):e;return jsx(InputElement,{"data-testid":"input",ref:o,disabled:a,value:d,error:i,onChange:n?e=>{l()?h(e):n(e)}:void 0,type:r
|
|
1288
|
+
`,Component$6=({value:e,spacing:t,type:r,error:i,disabled:a,onChange:n,...s},o)=>{const l=()=>"tel"===r&&t,h=e=>{const t=e.target,r=t.value,i=t.value.replace(/\s/g,"");t.value=i,n(e),t.value=r},d=e?(e=>e?l()?StringHelper.transformWithSpaces(e,t):e:"")(e):e;return jsx(InputElement,{"data-testid":"input",ref:o,disabled:a,value:d,error:i,onChange:n?e=>{l()?h(e):n(e)}:void 0,type:r,...s})},Input$2=React__default.forwardRef(Component$6),Component$5=(e,t)=>{const{label:r,errorMessage:i,id:a="form-field","data-error-testid":n,"data-testid":s,...o}=e;return jsx(FormWrapper,{id:a,label:r,errorMessage:i,disabled:o.disabled,"data-error-testid":n,children:jsx(Input$2,{id:`${a}-base`,"data-testid":s||a,ref:t,error:!!i,...o})})},FormInput=React__default.forwardRef(Component$5),Container$8=styled.div`
|
|
1291
1289
|
display: flex;
|
|
1292
1290
|
position: relative;
|
|
1293
1291
|
border: 1px solid ${Color.Neutral[5]};
|
|
@@ -1333,6 +1331,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1333
1331
|
// overwrite default styles
|
|
1334
1332
|
background: transparent;
|
|
1335
1333
|
border: none;
|
|
1334
|
+
|
|
1336
1335
|
:focus,
|
|
1337
1336
|
:active {
|
|
1338
1337
|
outline: none;
|
|
@@ -1340,12 +1339,14 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1340
1339
|
box-shadow: none;
|
|
1341
1340
|
}
|
|
1342
1341
|
|
|
1343
|
-
${e=>e.$
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1342
|
+
${e=>"right"===e.$position?css`
|
|
1343
|
+
:not(:only-child) {
|
|
1344
|
+
padding-right: 0;
|
|
1345
|
+
}
|
|
1347
1346
|
`:css`
|
|
1348
|
-
|
|
1347
|
+
:not(:only-child) {
|
|
1348
|
+
padding-left: 0;
|
|
1349
|
+
}
|
|
1349
1350
|
`}
|
|
1350
1351
|
`,AddOnContainer=styled.div`
|
|
1351
1352
|
position: relative;
|
|
@@ -1707,7 +1708,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1707
1708
|
margin: 1rem 1rem 1rem 0;
|
|
1708
1709
|
width: 1px;
|
|
1709
1710
|
background: ${Color.Neutral[5]};
|
|
1710
|
-
`,InputGroupListAddon=({addon:e,error:t,...r})=>{const{value:i,placeholder:a,options:n,enableSearch:s,searchFunction:o,searchPlaceholder:l,valueExtractor:h,listExtractor:d,displayValueExtractor:c,onSelectOption:p,onHideOptions:u,onShowOptions:m,"data-selector-testid":f}=e.attributes,[g,y]=useState(i),[v,b]=useState(!1),C=useRef(),x=useRef();useEffect((()=>{y(i)}),[i]),useEffect((()=>(document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)})),[]);const S=e=>{!e&&u&&u(),e&&m&&m()},_=e=>{if(!r.disabled){if(C&&C.current.contains(e.target))return;b(!1),S(!1)}},T=e=>{e.preventDefault(),r.disabled||(b(!v),S(!v))},$=(e,t)=>{y(e),b(!1),S(!1),x&&x.current.focus(),p&&p(e,t)};return jsx(Wrapper$9,{children:jsxs(ElementBoundary,{ref:C,disabled:r.disabled,error:t&&!v,expanded:v,children:[jsxs(DisplayContainer,{$expanded:v,children:[jsx(Selector,{ref:x,type:"button","data-testid":f||"addon-selector",onClick:T,children:jsxs(Fragment,{children:[jsxs(LabelContainer$1,{children:[a&&!g&&jsx(PlaceholderLabel,{children:a}),g&&jsx(ValueLabel,{"data-testid":"selector-label",children:c?c(g):h?h(g):g.toString()})]}),jsx(IconContainer,{$expanded:v,children:jsx(StyledIcon,{type:"chevron-down"})})]})}),jsx(Divider,{}),jsx(MainInput,{...r,"data-testid":r["data-testid"]||"input"})]}),n&&n.length>0?jsx(DropdownList,{listItems:n,onSelectItem:$,valueExtractor:h,listExtractor:d,visible:v,enableSearch:s,searchFunction:o,searchPlaceholder:l,"data-testid":"dropdown-list"}):null]})})},Component$3=({addon:e,error:t,...r},i)=>{const a=()=>jsx(Container$8,{disabled:r.disabled,$error:t,$readOnly:
|
|
1711
|
+
`,InputGroupListAddon=({addon:e,error:t,...r})=>{const{value:i,placeholder:a,options:n,enableSearch:s,searchFunction:o,searchPlaceholder:l,valueExtractor:h,listExtractor:d,displayValueExtractor:c,onSelectOption:p,onHideOptions:u,onShowOptions:m,"data-selector-testid":f}=e.attributes,[g,y]=useState(i),[v,b]=useState(!1),C=useRef(),x=useRef();useEffect((()=>{y(i)}),[i]),useEffect((()=>(document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)})),[]);const S=e=>{!e&&u&&u(),e&&m&&m()},_=e=>{if(!r.disabled){if(C&&C.current.contains(e.target))return;b(!1),S(!1)}},T=e=>{e.preventDefault(),r.disabled||(b(!v),S(!v))},$=(e,t)=>{y(e),b(!1),S(!1),x&&x.current.focus(),p&&p(e,t)};return jsx(Wrapper$9,{children:jsxs(ElementBoundary,{ref:C,disabled:r.disabled,error:t&&!v,expanded:v,children:[jsxs(DisplayContainer,{$expanded:v,children:[jsx(Selector,{ref:x,type:"button","data-testid":f||"addon-selector",onClick:T,children:jsxs(Fragment,{children:[jsxs(LabelContainer$1,{children:[a&&!g&&jsx(PlaceholderLabel,{children:a}),g&&jsx(ValueLabel,{"data-testid":"selector-label",children:c?c(g):h?h(g):g.toString()})]}),jsx(IconContainer,{$expanded:v,children:jsx(StyledIcon,{type:"chevron-down"})})]})}),jsx(Divider,{}),jsx(MainInput,{...r,"data-testid":r["data-testid"]||"input"})]}),n&&n.length>0?jsx(DropdownList,{listItems:n,onSelectItem:$,valueExtractor:h,listExtractor:d,visible:v,enableSearch:s,searchFunction:o,searchPlaceholder:l,"data-testid":"dropdown-list"}):null]})})},Component$3=({addon:e,error:t,...r},i)=>{const a=()=>jsx(Container$8,{disabled:r.disabled,$error:t,$readOnly:r.readOnly,"data-testid":r["data-testid"],children:jsx(MainInput,{ref:i,...r,"data-testid":"input"})});if(!e)return a();{const{type:i="label",position:n="left"}=e;switch(i){case"list":{const i=e.attributes;return i.options&&i.options.length>0?jsx(InputGroupListAddon,{addon:e,error:t,...r}):a()}case"custom":{const i=e.attributes;return i.children?jsxs(Container$8,{$error:t,disabled:r.disabled,$readOnly:r.readOnly,"data-testid":r["data-testid"],$position:n,children:[jsx(AddOnContainer,{"data-testid":"addon",disabled:r.disabled,$readOnly:r.readOnly,children:i.children}),jsx(MainInput,{...r,$position:n,"data-testid":"input"})]}):a()}default:{const i=e.attributes;return i.value?jsxs(Container$8,{disabled:r.disabled,$error:t,$readOnly:r.readOnly,"data-testid":r["data-testid"],$position:n,children:[jsx(AddOnContainer,{"data-testid":"addon",disabled:r.disabled,$readOnly:r.readOnly,children:i.value}),jsx(MainInput,{...r,$position:n,"data-testid":"input"})]}):a()}}}},InputGroup=React__default.forwardRef(Component$3),Component$2=(e,t)=>{const{label:r,errorMessage:i,id:a="form-field-group","data-error-testid":n,"data-testid":s,...o}=e;return jsx(FormWrapper,{id:a,label:r,errorMessage:i,disabled:o.disabled,"data-error-testid":n,children:jsx(InputGroup,{ref:t,id:`${a}-base`,"data-testid":s||a,error:!!i,...o})})},FormInputGroup=React__default.forwardRef(Component$2),InputSelectWrapper=({children:e,show:t,error:r,disabled:i,testId:a,onBlur:n})=>{const s=useRef(),o=useRef(t);useEffect((()=>(document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)})),[]),useEffect((()=>{o.current=t}),[t]);const l=e=>{if(!i){if(s&&s.current.contains(e.target))return;o.current&&n()}};return jsx(Wrapper$a,{children:jsx(ElementBoundary$1,{ref:s,error:r&&!t,disabled:i,expanded:t,"data-testid":a,children:e})})},InputMultiSelect=({selectedOptions:e,placeholder:t="Select",options:r,disabled:i,error:a,"data-testid":n,enableSearch:s=!1,searchFunction:o,searchPlaceholder:l,valueExtractor:h,listExtractor:d,onSelectOptions:c,listStyleWidth:p,onShowOptions:u,onHideOptions:m,onRetry:f,optionsLoadState:g="success",optionTruncationType:y="end",...v})=>{const[b,C]=useState(e||[]),[x,S]=useState(!1),_=useRef();useEffect((()=>{C(e||[])}),[e]);const T=(e,t)=>{const r=[...b],i=findIndex_1(b,(e=>(h?h(e):e)===t));i>-1?r.splice(i,1):r.push(e),C(r),E(!1),_&&_.current.focus(),c&&c(r)},$=()=>{x&&(S(!1),E(!1)),_&&_.current.focus()},w=()=>{b&&b.length>0?(C([]),c([])):(C(r),c(r))},E=e=>{!e&&m&&m(),e&&u&&u()};return jsxs(InputSelectWrapper,{show:x,error:a&&!x,disabled:i,testId:n,onBlur:()=>{S(!1),E(!1)},children:[jsx(Selector$1,{ref:_,type:"button","data-testid":"selector",onClick:e=>{e.preventDefault(),i||(S(!x),E(!x))},...v,children:jsxs(Fragment,{children:[jsx(LabelContainer$2,{children:b&&0!==b.length?jsx(ValueLabel$1,{children:b&&0!=b.length?`${b.length} selected`:t}):jsx(PlaceholderLabel$1,{truncateType:y,children:t})}),jsx(IconContainer$1,{expanded:x,children:jsx(StyledIcon$1,{type:"chevron-down"})})]})}),x&&jsx(Divider$1,{}),r&&r.length>0||f?jsx(DropdownList,{listItems:r,onSelectItem:T,onDismiss:$,valueExtractor:h,listExtractor:d,listStyleWidth:p,visible:x,enableSearch:s,searchFunction:o,searchPlaceholder:l,"data-testid":"dropdown-list",multiSelect:!0,selectedItems:b,onSelectAll:w,onRetry:f,itemsLoadState:g,itemTruncationType:y}):null]})},FormMultiSelect=({label:e,errorMessage:t,id:r="form-multi-select","data-error-testid":i,"data-testid":a,enableSearch:n=!1,...s})=>jsx(FormWrapper,{id:r,label:e,errorMessage:t,"data-error-testid":i,disabled:s.disabled,children:jsx(InputMultiSelect,{id:`${r}-base`,"data-testid":a||r,error:!!t,enableSearch:n,...s})}),InputSelect=({selectedOption:e,placeholder:t="Select",options:r,disabled:i,error:a,"data-testid":n,id:s,enableSearch:o=!1,searchFunction:l,searchPlaceholder:h,valueExtractor:d,valueToStringFunction:c,listExtractor:p,displayValueExtractor:u,onSelectOption:m,listStyleWidth:f,onShowOptions:g,onHideOptions:y,onRetry:v,optionsLoadState:b="success",optionTruncationType:C="end",...x})=>{const[S,_]=useState(e),[T,$]=useState(!1),w=useRef(),E=useRef();useEffect((()=>{_(e)}),[e]);const k=(e,t)=>{_(e),$(!1),M(!1),w&&w.current.focus(),m&&m(e,t)},A=()=>{T&&($(!1),M(!1)),w&&w.current.focus()},P=e=>{if("middle"===C){let t=0;return E&&E.current&&(t=E.current.getBoundingClientRect().width),StringHelper.truncateOneLine((e=>"string"==typeof e?e:c(e)||e.toString())(e),t,120,8)}return e},M=e=>{!e&&y&&y(),e&&g&&g()};return jsxs(InputSelectWrapper,{show:T,error:a&&!T,disabled:i,testId:n,onBlur:()=>{$(!1),M(!1)},children:[jsx(Selector$1,{ref:w,type:"button","data-testid":s||"selector",onClick:e=>{e.preventDefault(),i||($(!T),M(!T))},...x,children:jsxs(Fragment,{children:[jsx(LabelContainer$2,{ref:E,children:S?jsx(ValueLabel$1,{truncateType:C,children:P(u?u(S):d?d(S):S.toString())}):jsx(PlaceholderLabel$1,{truncateType:C,children:t})}),jsx(IconContainer$1,{expanded:T,children:jsx(StyledIcon$1,{type:"chevron-down"})})]})}),T&&jsx(Divider$1,{}),r&&r.length>0?jsx(DropdownList,{listItems:r,onSelectItem:k,onDismiss:A,valueExtractor:d,listExtractor:p,listStyleWidth:f,visible:T,enableSearch:o,searchPlaceholder:h,searchFunction:l,"data-testid":"dropdown-list",selectedItems:S?[S]:[],onRetry:v,itemsLoadState:b,itemTruncationType:C}):null]})},FormSelect=({label:e,errorMessage:t,id:r="form-select","data-error-testid":i,"data-testid":a,enableSearch:n=!1,...s})=>jsx(FormWrapper,{id:r,label:e,errorMessage:t,"data-error-testid":i,disabled:s.disabled,children:jsx(InputSelect,{id:`${r}-base`,"data-testid":a||r,error:!!t,enableSearch:n,...s})}),CounterLabel=styled(Text.H6)`
|
|
1711
1712
|
text-align: right;
|
|
1712
1713
|
|
|
1713
1714
|
${e=>{if(e.disabled)return css`
|
|
@@ -1737,12 +1738,12 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1737
1738
|
|
|
1738
1739
|
::placeholder,
|
|
1739
1740
|
::-webkit-input-placeholder {
|
|
1740
|
-
color: ${Color.Neutral[
|
|
1741
|
+
color: ${Color.Neutral[3]};
|
|
1741
1742
|
}
|
|
1742
1743
|
|
|
1743
1744
|
${e=>e.readOnly?css`
|
|
1744
1745
|
border: none;
|
|
1745
|
-
padding
|
|
1746
|
+
padding: 0.75rem 0;
|
|
1746
1747
|
background: transparent !important;
|
|
1747
1748
|
|
|
1748
1749
|
:focus,
|
|
@@ -1979,7 +1980,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.pr
|
|
|
1979
1980
|
${MediaQuery.MaxWidth.tablet} {
|
|
1980
1981
|
width: 50%;
|
|
1981
1982
|
}
|
|
1982
|
-
`;var EInputButtonName,EInputName,ETimePeriodToggleName;!function(e){e.HOUR_UP="hour-up",e.HOUR_DOWN="hour-down",e.MINUTE_UP="minute-up",e.MINUTE_DOWN="minute-down"}(EInputButtonName||(EInputButtonName={})),function(e){e.HOUR="hour",e.MINUTE="minute"}(EInputName||(EInputName={})),function(e){e.AM="am",e.PM="pm"}(ETimePeriodToggleName||(ETimePeriodToggleName={}));const TimepickerDropdown=({id:e,value:t,show:r,format:i,onChange:a,onCancel:n})=>{const s=TimepickerHelper.getTimeValues(i,t),[o,l]=useState(s.hour),[h,d]=useState(s.minute),[c,p]=useState(s.period),u=useRef(),m=useRef(),f=useResizeDetector();useEffect((()=>{if(r&&u.current&&u.current.focus(),r){const{hour:e,minute:r,period:a}=TimepickerHelper.getTimeValues(i,t);l(e),d(r),p(a)}}),[r,t,i]),useEffect((()=>{const e=u.current,t=m.current;return e&&e.addEventListener("keydown",g),t&&t.addEventListener("keydown",g),()=>{e&&e.removeEventListener("keydown",g),t&&t.removeEventListener("keydown",g)}}),[]);const g=e=>{["Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9","Tab","Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.code)||["Backspace","0","1","2","3","4","5","6","7","8","9"].includes(e.key)||e.preventDefault()},y=useCallback((e=>{switch(e.currentTarget.name){case EInputButtonName.MINUTE_UP:d(TimepickerHelper.updateMinutes(h,"add"));break;case EInputButtonName.MINUTE_DOWN:d(TimepickerHelper.updateMinutes(h,"minus"));break;case EInputButtonName.HOUR_UP:l(TimepickerHelper.updateHours(o,"add"));break;case EInputButtonName.HOUR_DOWN:l(TimepickerHelper.updateHours(o,"minus"))}}),[o,h]),v=e=>{e.target.select()},b=e=>{const t=e.target.value;switch(e.target.name){case EInputName.HOUR:t.length<=2&&l(t);break;case EInputName.MINUTE:t.length<=2&&d(t)}},C=e=>{const t=parseInt(e.target.value);if(!isNaN(t))switch(e.target.name){case EInputName.HOUR:{const r=t>23||t<0?s.hour:TimepickerHelper.convertHourTo12HourFormat(e.target.value);l(r);break}case EInputName.MINUTE:{const r=t>59||t<0?s.minute:e.target.value;d(StringHelper.padValue(r));break}}},x=e=>{switch(e.target.name){case ETimePeriodToggleName.AM:p("am");break;case ETimePeriodToggleName.PM:p("pm")}},S=t=>e?`${e}-${t}`:t,_=useSpring({height:r?f.height+32:0});return jsx(AnimatedDiv,{"data-testid":"animated-dropdown-wrapper",style:_,children:jsxs(Container$4,{ref:f.ref,"data-testid":S("timepicker-dropdown"),children:[jsxs(InputSection,{children:[jsxs(HourMinuteSection,{children:[jsxs(InputContainer,{children:[jsx(SwitchButton,{name:EInputButtonName.HOUR_UP,type:"button",tabIndex:-1,onClick:y,"data-testid":S("hour-increment-button"),children:jsx(Icon,{type:"chevron-up"})}),jsx(TimeInput,{type:"number",name:EInputName.HOUR,id:"hour",maxLength:2,pattern:"[0-9]{2}",ref:u,value:o,onFocus:v,onChange:b,onBlur:C,min:1,max:12,placeholder:"HH","data-testid":S("hour-input")}),jsx(SwitchButton,{name:EInputButtonName.HOUR_DOWN,type:"button",tabIndex:-1,onClick:y,"data-testid":S("hour-decrement-button"),children:jsx(Icon,{type:"chevron-down"})})]}),jsx(DividerLabel,{children:":"}),jsxs(InputContainer,{children:[jsx(SwitchButton,{name:EInputButtonName.MINUTE_UP,type:"button",tabIndex:-1,onClick:y,"data-testid":S("minute-increment-button"),children:jsx(Icon,{type:"chevron-up"})}),jsx(TimeInput,{type:"number",name:EInputName.MINUTE,id:"minute",maxLength:2,pattern:"[0-9]{2}",ref:m,value:h,onChange:b,onBlur:C,onFocus:v,min:0,max:59,placeholder:"MM","data-testid":S("minute-input")}),jsx(SwitchButton,{name:EInputButtonName.MINUTE_DOWN,type:"button",tabIndex:-1,onClick:y,"data-testid":S("minute-decrement-button"),children:jsx(Icon,{type:"chevron-down"})})]})]}),jsxs(TimePeriodSection,{children:[jsx(TimePeriodToggle,{checked:"am"===c,name:ETimePeriodToggleName.AM,type:"radio",onChange:x,"data-testid":S("am-toggle"),children:"AM"}),jsx(TimePeriodToggle,{checked:"pm"===c,name:ETimePeriodToggleName.PM,type:"radio",onChange:x,"data-testid":S("pm-toggle"),children:"PM"})]})]}),jsxs(ControlSection,{children:[jsx(ControlButton,{type:"button",styleType:"secondary",onClick:n,"data-testid":S("cancel-button"),children:"Cancel"}),jsx(ControlButton,{type:"button",onClick:()=>{let e;e="24hr"===i?TimepickerHelper.convertTo24HourFormat({hour:o,minute:h,period:c}):`${o}:${h}${c}`,a(e)},disabled:""===o||""===h,"data-testid":S("confirm-button"),children:"Confirm"})]})]})})},Wrapper$7=styled.div`
|
|
1983
|
+
`;var EInputButtonName,EInputName,ETimePeriodToggleName;!function(e){e.HOUR_UP="hour-up",e.HOUR_DOWN="hour-down",e.MINUTE_UP="minute-up",e.MINUTE_DOWN="minute-down"}(EInputButtonName||(EInputButtonName={})),function(e){e.HOUR="hour",e.MINUTE="minute"}(EInputName||(EInputName={})),function(e){e.AM="am",e.PM="pm"}(ETimePeriodToggleName||(ETimePeriodToggleName={}));const TimepickerDropdown=({id:e,value:t,show:r,format:i,onChange:a,onCancel:n})=>{const s=TimepickerHelper.getTimeValues(i,t),[o,l]=useState(s.hour),[h,d]=useState(s.minute),[c,p]=useState(s.period),u=useRef(),m=useRef(),f=useResizeDetector();useEffect((()=>{if(r&&u.current&&u.current.focus(),r){const{hour:e,minute:r,period:a}=TimepickerHelper.getTimeValues(i,t);l(e),d(r),p(a)}}),[r,t,i]),useEffect((()=>{const e=u.current,t=m.current;return e&&e.addEventListener("keydown",g),t&&t.addEventListener("keydown",g),()=>{e&&e.removeEventListener("keydown",g),t&&t.removeEventListener("keydown",g)}}),[]);const g=e=>{["Digit0","Digit1","Digit2","Digit3","Digit4","Digit5","Digit6","Digit7","Digit8","Digit9","Tab","Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.code)||["Backspace","0","1","2","3","4","5","6","7","8","9"].includes(e.key)||e.preventDefault()},y=useCallback((e=>{switch(e.currentTarget.name){case EInputButtonName.MINUTE_UP:d(TimepickerHelper.updateMinutes(h,"add"));break;case EInputButtonName.MINUTE_DOWN:d(TimepickerHelper.updateMinutes(h,"minus"));break;case EInputButtonName.HOUR_UP:l(TimepickerHelper.updateHours(o,"add"));break;case EInputButtonName.HOUR_DOWN:l(TimepickerHelper.updateHours(o,"minus"))}}),[o,h]),v=e=>{e.target.select()},b=e=>{const t=e.target.value;switch(e.target.name){case EInputName.HOUR:t.length<=2&&l(t);break;case EInputName.MINUTE:t.length<=2&&d(t)}},C=e=>{const t=parseInt(e.target.value);if(!isNaN(t))switch(e.target.name){case EInputName.HOUR:{const r=t>23||t<0?s.hour:TimepickerHelper.convertHourTo12HourFormat(e.target.value);l(r);break}case EInputName.MINUTE:{const r=t>59||t<0?s.minute:e.target.value;d(StringHelper.padValue(r));break}}},x=e=>{switch(e.target.name){case ETimePeriodToggleName.AM:p("am");break;case ETimePeriodToggleName.PM:p("pm")}},S=t=>e?`${e}-${t}`:t,_=useSpring({height:r?f.height+32:0});return jsx(AnimatedDiv,{"data-testid":"animated-dropdown-wrapper",style:_,children:jsxs(Container$4,{ref:f.ref,"data-testid":S("timepicker-dropdown"),children:[jsxs(InputSection,{children:[jsxs(HourMinuteSection,{children:[jsxs(InputContainer,{children:[jsx(SwitchButton,{"aria-label":"increase hour",name:EInputButtonName.HOUR_UP,type:"button",tabIndex:-1,onClick:y,"data-testid":S("hour-increment-button"),children:jsx(Icon,{type:"chevron-up"})}),jsx(TimeInput,{"aria-label":"hour",type:"number",name:EInputName.HOUR,id:"hour",maxLength:2,pattern:"[0-9]{2}",ref:u,value:o,onFocus:v,onChange:b,onBlur:C,min:1,max:12,placeholder:"HH","data-testid":S("hour-input")}),jsx(SwitchButton,{"aria-label":"decrease hour",name:EInputButtonName.HOUR_DOWN,type:"button",tabIndex:-1,onClick:y,"data-testid":S("hour-decrement-button"),children:jsx(Icon,{type:"chevron-down"})})]}),jsx(DividerLabel,{children:":"}),jsxs(InputContainer,{children:[jsx(SwitchButton,{"aria-label":"increase minute",name:EInputButtonName.MINUTE_UP,type:"button",tabIndex:-1,onClick:y,"data-testid":S("minute-increment-button"),children:jsx(Icon,{type:"chevron-up"})}),jsx(TimeInput,{"aria-label":"minute",type:"number",name:EInputName.MINUTE,id:"minute",maxLength:2,pattern:"[0-9]{2}",ref:m,value:h,onChange:b,onBlur:C,onFocus:v,min:0,max:59,placeholder:"MM","data-testid":S("minute-input")}),jsx(SwitchButton,{"aria-label":"decrease minute",name:EInputButtonName.MINUTE_DOWN,type:"button",tabIndex:-1,onClick:y,"data-testid":S("minute-decrement-button"),children:jsx(Icon,{type:"chevron-down"})})]})]}),jsxs(TimePeriodSection,{children:[jsx(TimePeriodToggle,{checked:"am"===c,name:ETimePeriodToggleName.AM,type:"radio",onChange:x,"data-testid":S("am-toggle"),"aria-label":"AM",children:"AM"}),jsx(TimePeriodToggle,{checked:"pm"===c,name:ETimePeriodToggleName.PM,type:"radio",onChange:x,"data-testid":S("pm-toggle"),"aria-label":"PM",children:"PM"})]})]}),jsxs(ControlSection,{children:[jsx(ControlButton,{"aria-label":"close selector",type:"button",styleType:"secondary",onClick:n,"data-testid":S("cancel-button"),children:"Cancel"}),jsx(ControlButton,{"aria-label":"confirm selection",type:"button",onClick:()=>{let e;e="24hr"===i?TimepickerHelper.convertTo24HourFormat({hour:o,minute:h,period:c}):`${o}:${h}${c}`,a(e)},disabled:""===o||""===h,"data-testid":S("confirm-button"),children:"Confirm"})]})]})})},Wrapper$7=styled.div`
|
|
1983
1984
|
position: relative;
|
|
1984
1985
|
`,InputSelectorElement=styled.input`
|
|
1985
1986
|
${TextStyleHelper.getTextStyle("Body","regular")}
|