UNPKG

@lanaco/lnc-react-ui

Version:

React component library

34 lines (33 loc) 2.2 kB
"use strict";const i=require("react/jsx-runtime"),d=require("react"),f=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),k=require("./index-Cp66dWMi.cjs"),t=require("./utils-BK6B_Y9X.cjs"),q=require("./emotion-element-f0de968e.browser.esm-B7k6i6lC.cjs"),v=({theme:e,size:a})=>{var l=t.getSizeValueWithUnits(e,a);return` min-height: ${l}; max-height: ${l}; `},O=f.styled.input` ${e=>v(e)} ${e=>t.getComponentTypographyCss(e.theme,"Input",e.size,"enabled")} padding: 0.625rem 0.75rem 0.62rem 0.75rem; line-height: inherit; appearance: none; outline: none; display: inline-block; border-radius: 0.25rem; width: 100%; box-sizing: border-box; background-color: ${e=>t.getColorRgbaValue(e.theme,"Input",e.color,"enabled","background")}; border: 1px solid ${e=>t.getColorRgbaValue(e.theme,"Input",e.color,e.disabled===!0?"disabled":"enabled","border")}; border-radius: ${e=>t.getBorderRadiusValueWithUnits(e.theme,"regular")}; color: ${e=>t.getColorRgbaValue(e.theme,"Input",e.color,"enabled","text")}; &:disabled { /* ${e=>t.getDisabledStateCss(e.theme)}; */ ${e=>`background-color: ${t.getColorRgbaValue(e.theme,"Input",e.color,"disabled","background","backgroundOpacity")}; color: ${a=>t.getColorRgbaValue(a.theme,"Input",a.color,"disabled","text")};`} cursor: default; } &:focus:enabled { border: none; ${e=>e.readOnly!==!0?t.getOutlineCss(e.theme):""}; color: ${e=>t.getColorRgbaValue(e.theme,"Input","primary","enabled","text")}; border: 1px solid ${e=>t.getColorRgbaValue(e.theme,"Input","primary",e.disabled===!0?"disabled":"enabled","border")}; } `,S=d.forwardRef((e,a)=>{const{disabled:l,readOnly:b,defaultValue:c,value:o,debounceTime:g=0,onChange:n,className:m="",style:h={},size:C="small",color:$="primary",...y}=e,x=q.useTheme(),[V,s]=d.useState(o||c||"");d.useEffect(()=>{o!=null&&s(o)},[o]);const I=d.useCallback(k.debounce((r,u)=>R(r,u),g),[n]),R=(r,u)=>{n&&(n==null||n(r,u))},p=r=>{s(r.target.value),I(r,r.target.value)};return i.jsx(i.Fragment,{children:i.jsx(O,{type:"time",ref:a,onChange:p,disabled:l,readOnly:b,theme:x,color:$,size:C,className:m,style:h,value:V,...y})})});module.exports=S;