kwant-ui 3.51.0-dev.4 → 3.51.0-dev.5

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.
@@ -3,7 +3,10 @@ import { TooltipComponent } from '../Tooltip/types';
3
3
  type Period = 'AM' | 'PM';
4
4
  type Format = '12' | '24';
5
5
  export interface TimePickerProps {
6
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
6
+ onChange?: (value: {
7
+ time: string;
8
+ period?: Period;
9
+ }) => void;
7
10
  onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
8
11
  disabled?: boolean;
9
12
  required?: boolean;
package/dist/index.es.js CHANGED
@@ -4726,7 +4726,7 @@ object-assign
4726
4726
  font-size: 1rem;
4727
4727
  font-weight: 500;
4728
4728
  color: ${e=>e.theme.primary.primary90};
4729
- `,OT=[{label:"AM",value:"AM"},{label:"PM",value:"PM"}];function zT({label:r,disabled:a=!1,tooltipContent:c,tooltipPosition:l,format:i="12",onChange:o,onBlur:s,value:h="00:00",required:v,id:p,period:g="AM",onlyHours:m=!1}){const[d,f]=u(m?h.split(":")[0]||"00":h),[_,b]=u(!1),[x,y]=u(g??"AM"),M="24"===i,E=w((e,t)=>{const n=M?23:12,r=M?0:1;return{hours:Math.min(Math.max(e,r),n),minutes:Math.min(Math.max(t,0),59)}},[M]);return t(n,{children:[t(Ke,{color:a?V.grey.grey400:V.grey.grey900,children:[v&&e(We,{disabled:a,children:"*"}),r,c&&e(Ge,{children:e(we,{tooltipContent:()=>c,position:l,offset:"10px",top:"8px",children:e(nt,{icon:"info",width:16,height:16,fill:V.grey.grey400})})})]}),t(wT,{children:[t(xT,{onlyHours:m,children:[e(bT,{id:p,type:"text",value:d,onChange:e=>{let t=e.target.value,n=!1;if(m){const r=e.target.value.replace(/[^\d]/g,"").slice(0,2);if(r.length<=2){const e=parseInt(r);(""===r||e>=(M?0:1)&&e<=(M?24:12))&&(f(r),t=r+":00",n=!0)}}else{let r=e.target.value.replace(/[^\d:]/g,"");if(/^\d{2}$/.test(r)&&(r+=":"),r.length<=5){const[e=""]=r.split(":");e.length<=2&&(f(r),t=r,n=!0)}}if(n&&o){const n={...e,target:{...e.target,value:t}};o(n)}},onBlur:e=>{if(m){const e=parseInt(d)||(M?0:1),t=M?24:12,n=M?0:1,r=Math.min(Math.max(e,n),t).toString().padStart(2,"0");f(r)}else{const[e="",t=""]=d.split(":"),n=parseInt(e)||(M?0:1),r=parseInt(t)||0,{hours:a,minutes:c}=E(n,r),l=`${a.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`;f(l)}s&&s(e)},placeholder:m?"00":"00:00",disabled:a,format:i,onlyHours:m}),m&&t(n,{children:[e(yT,{children:":"}),e(MT,{children:"00"})]})]}),!M&&t(ET,{children:[t(HT,{onClick:()=>{b(!_)},children:[e(PT,{children:x}),e(wr,{isOpened:_,children:xr})]}),e(ln,{opened:_,data:OT,width:"80px",offsetRight:"0px",offsetTop:"50px",isDynamicOptionPosition:!0,selectedValue:x,onClose:()=>b(!1),onSelect:e=>{"AM"!==e?.value&&"PM"!==e?.value||y(e.value)},showScrollbar:!1,searchable:!1})]})]})]})}const ZT=r.div`
4729
+ `,OT=[{label:"AM",value:"AM"},{label:"PM",value:"PM"}];function zT({label:r,disabled:a=!1,tooltipContent:c,tooltipPosition:l,format:i="12",onChange:o,onBlur:s,value:h="00:00",required:v,id:p,period:g="AM",onlyHours:m=!1}){const[d,f]=u(m?h.split(":")[0]||"00":h),[_,b]=u(!1),[x,y]=u(g??"AM"),M="24"===i,E=w((e,t)=>{const n=M?23:12,r=M?0:1;return{hours:Math.min(Math.max(e,r),n),minutes:Math.min(Math.max(t,0),59)}},[M]);return t(n,{children:[t(Ke,{color:a?V.grey.grey400:V.grey.grey900,children:[v&&e(We,{disabled:a,children:"*"}),r,c&&e(Ge,{children:e(we,{tooltipContent:()=>c,position:l,offset:"10px",top:"8px",children:e(nt,{icon:"info",width:16,height:16,fill:V.grey.grey400})})})]}),t(wT,{children:[t(xT,{onlyHours:m,children:[e(bT,{id:p,type:"text",value:d,onChange:e=>{let t=e.target.value,n=!1;if(m){const r=e.target.value.replace(/[^\d]/g,"").slice(0,2);if(r.length<=2){const e=parseInt(r);(""===r||e>=(M?0:1)&&e<=(M?23:12))&&(f(r),t=r,n=!0)}}else{let r=e.target.value.replace(/[^\d:]/g,"");if(/^\d{2}$/.test(r)&&(r+=":"),r.length<=5){const[e="",a=""]=r.split(":");if(e.length<=2){const c=parseInt(e)||0;(""===e||c>=(M?0:1)&&c<=(M?23:12))&&(""===a||a.length<=2&&parseInt(a)<=59)&&(f(r),t=r,n=!0)}}}if(n&&o){const e={time:t};M||(e.period=x),o(e)}},onBlur:e=>{if(m){const e=parseInt(d)||(M?0:1),t=M?23:12,n=M?0:1,r=Math.min(Math.max(e,n),t).toString().padStart(2,"0");f(r)}else{const[e="",t=""]=d.split(":"),n=parseInt(e)||(M?0:1),r=parseInt(t)||0,{hours:a,minutes:c}=E(n,r),l=`${a.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`;f(l)}s&&s(e)},placeholder:m?"00":"00:00",disabled:a,format:i,onlyHours:m}),m&&t(n,{children:[e(yT,{children:":"}),e(MT,{children:"00"})]})]}),!M&&t(ET,{children:[t(HT,{onClick:()=>{b(!_)},children:[e(PT,{children:x}),e(wr,{isOpened:_,children:xr})]}),e(ln,{opened:_,data:OT,width:"80px",offsetRight:"0px",offsetTop:"50px",isDynamicOptionPosition:!0,selectedValue:x,onClose:()=>b(!1),onSelect:e=>{if(("AM"===e?.value||"PM"===e?.value)&&(y(e.value),o)){const t={time:d};M||(t.period=e.value),o(t)}},showScrollbar:!1,searchable:!1})]})]})]})}const ZT=r.div`
4730
4730
  display: flex;
4731
4731
  align-items: center;
4732
4732
  justify-content: center;