streamlit-nightly 1.45.2.dev20250606__py3-none-any.whl → 1.45.2.dev20250609__py3-none-any.whl

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.
Files changed (80) hide show
  1. streamlit/commands/execution_control.py +1 -0
  2. streamlit/elements/code.py +2 -2
  3. streamlit/elements/lib/pandas_styler_utils.py +9 -1
  4. streamlit/elements/map.py +5 -25
  5. streamlit/runtime/scriptrunner/script_runner.py +2 -0
  6. streamlit/static/index.html +1 -1
  7. streamlit/static/manifest.json +218 -218
  8. streamlit/static/static/js/{ErrorOutline.esm.BPlheRUg.js → ErrorOutline.esm.DPSvnAZl.js} +1 -1
  9. streamlit/static/static/js/{FileDownload.esm.DBPvJlIO.js → FileDownload.esm.Dq4gf5Ma.js} +1 -1
  10. streamlit/static/static/js/{FileHelper.D7hqm1rs.js → FileHelper.CGlOwDmI.js} +1 -1
  11. streamlit/static/static/js/{FormClearHelper.CiuGPbiw.js → FormClearHelper.Bzr0lxz8.js} +1 -1
  12. streamlit/static/static/js/{Hooks.i-LEuQVS.js → Hooks.XjcePFDz.js} +1 -1
  13. streamlit/static/static/js/{InputInstructions.DiyV2lfI.js → InputInstructions.B4r5deJK.js} +1 -1
  14. streamlit/static/static/js/{ProgressBar.DsZbmX1F.js → ProgressBar.BpLfvKEk.js} +1 -1
  15. streamlit/static/static/js/{RenderInPortalIfExists.BMEXbaG1.js → RenderInPortalIfExists.s9TJxze4.js} +1 -1
  16. streamlit/static/static/js/{Toolbar.DOqF9PKk.js → Toolbar.CpN1Y8Ph.js} +1 -1
  17. streamlit/static/static/js/{base-input.BYC-_bsx.js → base-input.BJ4xTy-v.js} +1 -1
  18. streamlit/static/static/js/{checkbox.DnegvBUn.js → checkbox.DE-YA6Ye.js} +1 -1
  19. streamlit/static/static/js/{createSuper.Dcf6Du3v.js → createSuper.HyIBMcPl.js} +1 -1
  20. streamlit/static/static/js/{data-grid-overlay-editor.ODa6iMNd.js → data-grid-overlay-editor.BmMK_3hp.js} +1 -1
  21. streamlit/static/static/js/{downloader.CUFbUoPx.js → downloader.Cx_bgHAi.js} +1 -1
  22. streamlit/static/static/js/{es6.BX8MS_9G.js → es6.CQlJWXgz.js} +2 -2
  23. streamlit/static/static/js/{iframeResizer.contentWindow.Bu7_8x8S.js → iframeResizer.contentWindow.YSe-ULR9.js} +1 -1
  24. streamlit/static/static/js/{index.D9XODeBi.js → index.2tjJrlKf.js} +1 -1
  25. streamlit/static/static/js/{index.6U8xZd9t.js → index.4DOWGwr3.js} +1 -1
  26. streamlit/static/static/js/{index.C1Ax3fWo.js → index.B4zNurye.js} +1 -1
  27. streamlit/static/static/js/{index.D3prumL7.js → index.BF7WGy0A.js} +1 -1
  28. streamlit/static/static/js/{index.Ctp7gmwv.js → index.BJrS5MAH.js} +1 -1
  29. streamlit/static/static/js/{index.BTofb2AK.js → index.BPnusRc_.js} +1 -1
  30. streamlit/static/static/js/{index.DZvJRRXE.js → index.BXcwjtgF.js} +6 -6
  31. streamlit/static/static/js/{index.CxgTbOOW.js → index.B_FFd4-h.js} +1 -1
  32. streamlit/static/static/js/{index.ClhWXWt6.js → index.Br_6W7Ok.js} +1 -1
  33. streamlit/static/static/js/{index.BSvv4neZ.js → index.Brb2rwe5.js} +1 -1
  34. streamlit/static/static/js/{index.UEvOImwt.js → index.Bu00INAj.js} +1 -1
  35. streamlit/static/static/js/{index.DT_2un9f.js → index.C-vuyKHe.js} +12 -12
  36. streamlit/static/static/js/{index.BSLU45nm.js → index.C4K_J-xT.js} +1 -1
  37. streamlit/static/static/js/{index.DoOOYKo6.js → index.CRqlHLrY.js} +1 -1
  38. streamlit/static/static/js/{index.CfYt2tbH.js → index.CW7dpSHW.js} +1 -1
  39. streamlit/static/static/js/{index.5kO-eVzI.js → index.CYOKgsAX.js} +1 -1
  40. streamlit/static/static/js/{index.BRC4CPJr.js → index.C_c8e-5A.js} +1 -1
  41. streamlit/static/static/js/{index.CzjTnGFD.js → index.CcXxnSCT.js} +1 -1
  42. streamlit/static/static/js/{index.cClaHld2.js → index.Ch9d9jgn.js} +1 -1
  43. streamlit/static/static/js/{index.BaPm_YQ4.js → index.Cp05GLXV.js} +1 -1
  44. streamlit/static/static/js/{index.DK6Kov-Y.js → index.Cpqc7tRy.js} +1 -1
  45. streamlit/static/static/js/{index.Dupfq6Y_.js → index.CuDJY4WR.js} +1 -1
  46. streamlit/static/static/js/{index.BpQQaYsH.js → index.CxRHV8UN.js} +1 -1
  47. streamlit/static/static/js/{index.ChqQHZSD.js → index.CzBLcg5Y.js} +1 -1
  48. streamlit/static/static/js/{index.Bf7OiFUq.js → index.DHK750uA.js} +1 -1
  49. streamlit/static/static/js/{index.CF1yxAvR.js → index.DK0XGBKq.js} +1 -1
  50. streamlit/static/static/js/{index.C35iYNLZ.js → index.DKGPAEFz.js} +20 -20
  51. streamlit/static/static/js/{index.HnTahnXx.js → index.DT7-7fMk.js} +11 -11
  52. streamlit/static/static/js/{index.kmRXFfH8.js → index.Dn_0PWc5.js} +1 -1
  53. streamlit/static/static/js/{index.htD_aLlM.js → index.DtG6Z3MJ.js} +1 -1
  54. streamlit/static/static/js/{index.1wqJoatM.js → index.DwQ4wXWh.js} +1 -1
  55. streamlit/static/static/js/{index.D45QkWY6.js → index.DxpoRtMm.js} +1 -1
  56. streamlit/static/static/js/{index.C5MN-1yU.js → index.ErO4BalD.js} +1 -1
  57. streamlit/static/static/js/{index.pJ5b-MCg.js → index.SdjZDfiz.js} +1 -1
  58. streamlit/static/static/js/{index.x6To5k1N.js → index.TltPE7XP.js} +1 -1
  59. streamlit/static/static/js/{index.-reZVx4t.js → index.bnbHIlia.js} +1 -1
  60. streamlit/static/static/js/{index.CF6QAdiF.js → index.paoSwA79.js} +1 -1
  61. streamlit/static/static/js/{input.BbTx2QYD.js → input.aAklmoZJ.js} +1 -1
  62. streamlit/static/static/js/{memory.B6iT9_rU.js → memory.2F8FWva7.js} +1 -1
  63. streamlit/static/static/js/{mergeWith.DixCnRNB.js → mergeWith.Y1UWKEuM.js} +1 -1
  64. streamlit/static/static/js/{number-overlay-editor.Q7y8nwGm.js → number-overlay-editor.Bje9ferA.js} +1 -1
  65. streamlit/static/static/js/{possibleConstructorReturn.BIBtSx1r.js → possibleConstructorReturn.CFo__Sc1.js} +1 -1
  66. streamlit/static/static/js/{sandbox.C2ZPzr_l.js → sandbox.CXYFQ0n9.js} +1 -1
  67. streamlit/static/static/js/{textarea.BMQ_ba_z.js → textarea.CpyUweiS.js} +1 -1
  68. streamlit/static/static/js/{timepicker.dDYgD4FB.js → timepicker.DGJQS8FC.js} +1 -1
  69. streamlit/static/static/js/{toConsumableArray.D25TFALF.js → toConsumableArray.Coqsx-A_.js} +1 -1
  70. streamlit/static/static/js/{uniqueId.D0Y_FD3n.js → uniqueId.YqFJqzby.js} +1 -1
  71. streamlit/static/static/js/{useBasicWidgetState.mCO15TrK.js → useBasicWidgetState.DmT-fPrJ.js} +1 -1
  72. streamlit/static/static/js/{useOnInputChange.D2L-eHJs.js → useOnInputChange.ahkIk-J7.js} +1 -1
  73. streamlit/static/static/js/{withFullScreenWrapper.D8Fqz3rF.js → withFullScreenWrapper.CQYaVcKq.js} +1 -1
  74. streamlit/watcher/local_sources_watcher.py +11 -3
  75. {streamlit_nightly-1.45.2.dev20250606.dist-info → streamlit_nightly-1.45.2.dev20250609.dist-info}/METADATA +1 -1
  76. {streamlit_nightly-1.45.2.dev20250606.dist-info → streamlit_nightly-1.45.2.dev20250609.dist-info}/RECORD +80 -80
  77. {streamlit_nightly-1.45.2.dev20250606.data → streamlit_nightly-1.45.2.dev20250609.data}/scripts/streamlit.cmd +0 -0
  78. {streamlit_nightly-1.45.2.dev20250606.dist-info → streamlit_nightly-1.45.2.dev20250609.dist-info}/WHEEL +0 -0
  79. {streamlit_nightly-1.45.2.dev20250606.dist-info → streamlit_nightly-1.45.2.dev20250609.dist-info}/entry_points.txt +0 -0
  80. {streamlit_nightly-1.45.2.dev20250606.dist-info → streamlit_nightly-1.45.2.dev20250609.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
1
- import{n as c,r as C,aD as S,C as p,j as i,aC as E,l as y}from"./index.HnTahnXx.js";import{w as L,E as W}from"./withFullScreenWrapper.D8Fqz3rF.js";import{S as h,T as v}from"./Toolbar.DOqF9PKk.js";const b=c("div",{target:"evl31sl0"})(({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:"fit-content"})),T=c("div",{target:"evl31sl1"})(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0,">img":{borderRadius:e.radii.default}})),F=c("div",{target:"evl31sl2"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS})),j=y.getLogger("ImageList");function D({element:e,endpoints:g,disableFullscreenMode:u}){const{expanded:s,width:w,height:l,expand:x,collapse:f}=S(W),m=w||0;let o;const r=e.width;if([-1,-3,-4].includes(r))o=void 0;else if([-2,-5].includes(r))o=m;else if(r>0)o=r;else throw Error(`Invalid image width: ${r}`);const t={};l&&s?(t.maxHeight=l,t.objectFit="contain",t.width="100%"):(t.width=o??"100%",t.maxWidth="100%");const I=n=>{const a=n.currentTarget.src;j.error(`Client Error: Image source error - ${a}`),g.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",a)};return p(h,{width:m,height:l,useContainerWidth:s,topCentered:!0,children:[i(v,{target:h,isFullScreen:s,onExpand:x,onCollapse:f,disableFullscreenMode:u}),i(b,{className:"stImage","data-testid":"stImage",children:e.imgs.map((n,a)=>{const d=n;return p(T,{"data-testid":"stImageContainer",children:[i("img",{style:t,src:g.buildMediaURL(d.url),alt:a.toString(),onError:I}),d.caption&&i(F,{"data-testid":"stImageCaption",style:t,children:i(E,{source:d.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]},a)})})]})}const G=L(D),$=C.memo(G);export{$ as default};
1
+ import{n as c,r as C,aD as S,C as p,j as i,aC as E,l as y}from"./index.DT7-7fMk.js";import{w as L,E as W}from"./withFullScreenWrapper.CQYaVcKq.js";import{S as h,T as v}from"./Toolbar.CpN1Y8Ph.js";const b=c("div",{target:"evl31sl0"})(({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:"fit-content"})),T=c("div",{target:"evl31sl1"})(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0,">img":{borderRadius:e.radii.default}})),F=c("div",{target:"evl31sl2"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS})),j=y.getLogger("ImageList");function D({element:e,endpoints:g,disableFullscreenMode:u}){const{expanded:s,width:w,height:l,expand:x,collapse:f}=S(W),m=w||0;let o;const r=e.width;if([-1,-3,-4].includes(r))o=void 0;else if([-2,-5].includes(r))o=m;else if(r>0)o=r;else throw Error(`Invalid image width: ${r}`);const t={};l&&s?(t.maxHeight=l,t.objectFit="contain",t.width="100%"):(t.width=o??"100%",t.maxWidth="100%");const I=n=>{const a=n.currentTarget.src;j.error(`Client Error: Image source error - ${a}`),g.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",a)};return p(h,{width:m,height:l,useContainerWidth:s,topCentered:!0,children:[i(v,{target:h,isFullScreen:s,onExpand:x,onCollapse:f,disableFullscreenMode:u}),i(b,{className:"stImage","data-testid":"stImage",children:e.imgs.map((n,a)=>{const d=n;return p(T,{"data-testid":"stImageContainer",children:[i("img",{style:t,src:g.buildMediaURL(d.url),alt:a.toString(),onError:I}),d.caption&&i(F,{"data-testid":"stImageCaption",style:t,children:i(E,{source:d.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]},a)})})]})}const G=L(D),$=C.memo(G);export{$ as default};
@@ -1 +1 @@
1
- import{r,E as Q,_ as Y,cz as y,M as m,O as Z,l as mt,n as D,z as gt,bd as ht,cp as It,H as q,C as F,j as c,bo as yt,bC as Ct,bp as Tt,b5 as wt,bq as St,D as vt,bl as K}from"./index.HnTahnXx.js";import{u as Vt}from"./uniqueId.D0Y_FD3n.js";import{u as kt}from"./FormClearHelper.CiuGPbiw.js";import{I as Rt}from"./InputInstructions.DiyV2lfI.js";import{s as xt}from"./sprintf.D7DtBTRn.js";import{I as Dt}from"./input.BbTx2QYD.js";import"./base-input.BYC-_bsx.js";var tt=r.forwardRef(function(t,e){var a={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(Q,Y({iconAttrs:a,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),r.createElement("path",{d:"M0 3v2h8V3H0z"}))});tt.displayName="Minus";var et=r.forwardRef(function(t,e){var a={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(Q,Y({iconAttrs:a,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),r.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});et.displayName="Plus";const Et=mt.getLogger("NumberInput");function Nt(t){return m(t)||t===""?void 0:t}const W=({value:t,format:e,step:a,dataType:b})=>{if(m(t))return null;let o=Nt(e);if(m(o)&&Z(a)){const d=a.toString();b===y.DataType.FLOAT&&a!==0&&d.includes(".")&&(o=`%0.${d.split(".")[1].length}f`)}if(m(o))return t.toString();try{return xt.sprintf(o,t)}catch(d){return Et.warn(`Error in sprintf(${o}, ${t}): ${d}`),String(t)}},zt=(t,e,a)=>m(t)?!1:t-e>=a,Ft=(t,e,a)=>m(t)?!1:t+e<=a,Wt=t=>(t.element.dataType===y.DataType.INT?t.widgetMgr.getIntValue(t.element):t.widgetMgr.getDoubleValue(t.element))??t.element.default??null,M=({step:t,dataType:e})=>t||(e===y.DataType.INT?1:.01),Bt=D("div",{target:"e4u2kar0"})(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor??t.colors.secondaryBg,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}})),Lt=D("div",{target:"e4u2kar1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),J=D("button",{target:"e4u2kar2"})(({theme:t})=>({margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:t.sizes.numberInputControlsWidth,justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:last-of-type":{borderTopRightRadius:t.radii.default,borderBottomRightRadius:t.radii.default},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),Ht=D("div",{target:"e4u2kar3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),Pt=({disabled:t,element:e,widgetMgr:a,fragmentId:b})=>{var X;const o=gt(),{dataType:d,id:S,formId:p,default:B,format:L,icon:C,min:g,max:h}=e,[H,ot]=ht(),[s,rt]=r.useState(()=>M(e)),P=Wt({element:e,widgetMgr:a}),[I,T]=r.useState(!1),[l,w]=r.useState(P),[U,v]=r.useState(()=>W({value:P,...e,step:s})),[A,$]=r.useState(!1),V=r.useRef(null),O=r.useRef(Vt("number_input_")),k=zt(l,s,g),R=Ft(l,s,h),j=It({formId:p}),nt=j?a.allowFormEnterToSubmit(p):I,at=A&&H>o.breakpoints.hideWidgetDetails;r.useEffect(()=>{rt(M({step:e.step,dataType:e.dataType}))},[e.dataType,e.step]);const u=r.useCallback(({value:n,source:i})=>{var f;if(Z(n)&&(g>n||n>h))(f=V.current)==null||f.reportValidity();else{const x=n??B??null;switch(d){case y.DataType.INT:a.setIntValue({id:S,formId:p},x,i,b);break;case y.DataType.FLOAT:a.setDoubleValue({id:S,formId:p},x,i,b);break;default:throw new Error("Invalid data type")}T(!1),w(x),v(W({value:x,dataType:d,format:L,step:s}))}},[g,h,V,a,b,s,d,S,p,B,L]),st=r.useCallback(()=>{I&&u({value:l,source:{fromUi:!0}}),$(!1)},[I,l,u]),it=r.useCallback(()=>{$(!0)},[]),_=r.useCallback(()=>{const{value:n}=e;e.setValue=!1,w(n??null),v(W({value:n??null,...e,step:s})),u({value:n??null,source:{fromUi:!1}})},[e,s,u]);r.useEffect(()=>{e.setValue?_():u({value:l,source:{fromUi:!1}});const n=V.current;if(n){const i=f=>{f.preventDefault()};return n.addEventListener("wheel",i),()=>{n.removeEventListener("wheel",i)}}},[]),e.setValue&&_();const E=m(e.default)&&!t,lt=r.useCallback(()=>{const n=e.default??null;w(n),u({value:n,source:{fromUi:!0}})},[e]);kt({element:e,widgetMgr:a,onFormCleared:lt});const ct=n=>{const{value:i}=n.target;if(i==="")T(!0),w(null),v(null);else{let f;e.dataType===y.DataType.INT?f=parseInt(i,10):f=parseFloat(i),T(!0),w(f),v(i)}},N=r.useCallback(()=>{R&&(T(!0),u({value:(l??g)+s,source:{fromUi:!0}}))},[l,g,s,R]),z=r.useCallback(()=>{k&&(T(!0),u({value:(l??h)-s,source:{fromUi:!0}}))},[l,h,s,k]),ut=r.useCallback(n=>{const{key:i}=n;switch(i){case"ArrowUp":n.preventDefault(),N();break;case"ArrowDown":n.preventDefault(),z();break}},[N,z]),dt=r.useCallback(n=>{n.key==="Enter"&&(I&&u({value:l,source:{fromUi:!0}}),a.allowFormEnterToSubmit(p)&&a.submitForm(p,b))},[I,l,u,a,p,b]),G=C==null?void 0:C.startsWith(":material"),pt=G?"lg":"base",ft=q(o.iconSizes.lg)+2*q(o.spacing.twoXS),bt=C?o.breakpoints.hideNumberInputControls+ft:o.breakpoints.hideNumberInputControls;return F("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:ot,children:[c(St,{label:e.label,disabled:t,labelVisibility:yt((X=e.labelVisibility)==null?void 0:X.value),htmlFor:O.current,children:e.help&&c(Ct,{children:c(Tt,{content:e.help,placement:wt.TOP_RIGHT})})}),F(Bt,{className:A?"focused":"","data-testid":"stNumberInputContainer",children:[c(Dt,{type:"number",inputRef:V,value:U??"",placeholder:e.placeholder,onBlur:st,onFocus:it,onChange:ct,onKeyPress:dt,onKeyDown:ut,clearable:E,clearOnEscape:E,disabled:t,"aria-label":e.label,startEnhancer:e.icon&&c(vt,{"data-testid":"stNumberInputIcon",iconValue:e.icon,size:pt}),id:O.current,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:o.colors.darkGray,padding:o.spacing.threeXS,height:o.sizes.clearIconSize,width:o.sizes.clearIconSize,":hover":{fill:o.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:s,min:g,max:h,type:"number",inputMode:""},style:{lineHeight:o.lineHeights.inputWidget,paddingRight:o.spacing.sm,paddingLeft:o.spacing.md,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0,paddingRight:0,paddingLeft:C?o.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:o.iconSizes.lg,color:G?o.colors.fadedText60:"inherit"}}}}),H>bt&&F(Lt,{children:[c(J,{"data-testid":"stNumberInputStepDown",onClick:z,disabled:!k||t,tabIndex:-1,children:c(K,{content:tt,size:"xs",color:k?"inherit":o.colors.disabled})}),c(J,{"data-testid":"stNumberInputStepUp",onClick:N,disabled:!R||t,tabIndex:-1,children:c(K,{content:et,size:"xs",color:R?"inherit":o.colors.disabled})})]})]}),at&&c(Ht,{clearable:E,children:c(Rt,{dirty:I,value:U??"",inForm:j,allowEnterToSubmit:nt})})]})},Xt=r.memo(Pt);export{Xt as default};
1
+ import{r,E as Q,_ as Y,cz as y,M as m,O as Z,l as mt,n as D,z as gt,bd as ht,cp as It,H as q,C as F,j as c,bo as yt,bC as Ct,bp as Tt,b5 as wt,bq as St,D as vt,bl as K}from"./index.DT7-7fMk.js";import{u as Vt}from"./uniqueId.YqFJqzby.js";import{u as kt}from"./FormClearHelper.Bzr0lxz8.js";import{I as Rt}from"./InputInstructions.B4r5deJK.js";import{s as xt}from"./sprintf.D7DtBTRn.js";import{I as Dt}from"./input.aAklmoZJ.js";import"./base-input.BJ4xTy-v.js";var tt=r.forwardRef(function(t,e){var a={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(Q,Y({iconAttrs:a,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),r.createElement("path",{d:"M0 3v2h8V3H0z"}))});tt.displayName="Minus";var et=r.forwardRef(function(t,e){var a={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(Q,Y({iconAttrs:a,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),r.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});et.displayName="Plus";const Et=mt.getLogger("NumberInput");function Nt(t){return m(t)||t===""?void 0:t}const W=({value:t,format:e,step:a,dataType:b})=>{if(m(t))return null;let o=Nt(e);if(m(o)&&Z(a)){const d=a.toString();b===y.DataType.FLOAT&&a!==0&&d.includes(".")&&(o=`%0.${d.split(".")[1].length}f`)}if(m(o))return t.toString();try{return xt.sprintf(o,t)}catch(d){return Et.warn(`Error in sprintf(${o}, ${t}): ${d}`),String(t)}},zt=(t,e,a)=>m(t)?!1:t-e>=a,Ft=(t,e,a)=>m(t)?!1:t+e<=a,Wt=t=>(t.element.dataType===y.DataType.INT?t.widgetMgr.getIntValue(t.element):t.widgetMgr.getDoubleValue(t.element))??t.element.default??null,M=({step:t,dataType:e})=>t||(e===y.DataType.INT?1:.01),Bt=D("div",{target:"e4u2kar0"})(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor??t.colors.secondaryBg,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}})),Lt=D("div",{target:"e4u2kar1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),J=D("button",{target:"e4u2kar2"})(({theme:t})=>({margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:t.sizes.numberInputControlsWidth,justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:last-of-type":{borderTopRightRadius:t.radii.default,borderBottomRightRadius:t.radii.default},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),Ht=D("div",{target:"e4u2kar3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),Pt=({disabled:t,element:e,widgetMgr:a,fragmentId:b})=>{var X;const o=gt(),{dataType:d,id:S,formId:p,default:B,format:L,icon:C,min:g,max:h}=e,[H,ot]=ht(),[s,rt]=r.useState(()=>M(e)),P=Wt({element:e,widgetMgr:a}),[I,T]=r.useState(!1),[l,w]=r.useState(P),[U,v]=r.useState(()=>W({value:P,...e,step:s})),[A,$]=r.useState(!1),V=r.useRef(null),O=r.useRef(Vt("number_input_")),k=zt(l,s,g),R=Ft(l,s,h),j=It({formId:p}),nt=j?a.allowFormEnterToSubmit(p):I,at=A&&H>o.breakpoints.hideWidgetDetails;r.useEffect(()=>{rt(M({step:e.step,dataType:e.dataType}))},[e.dataType,e.step]);const u=r.useCallback(({value:n,source:i})=>{var f;if(Z(n)&&(g>n||n>h))(f=V.current)==null||f.reportValidity();else{const x=n??B??null;switch(d){case y.DataType.INT:a.setIntValue({id:S,formId:p},x,i,b);break;case y.DataType.FLOAT:a.setDoubleValue({id:S,formId:p},x,i,b);break;default:throw new Error("Invalid data type")}T(!1),w(x),v(W({value:x,dataType:d,format:L,step:s}))}},[g,h,V,a,b,s,d,S,p,B,L]),st=r.useCallback(()=>{I&&u({value:l,source:{fromUi:!0}}),$(!1)},[I,l,u]),it=r.useCallback(()=>{$(!0)},[]),_=r.useCallback(()=>{const{value:n}=e;e.setValue=!1,w(n??null),v(W({value:n??null,...e,step:s})),u({value:n??null,source:{fromUi:!1}})},[e,s,u]);r.useEffect(()=>{e.setValue?_():u({value:l,source:{fromUi:!1}});const n=V.current;if(n){const i=f=>{f.preventDefault()};return n.addEventListener("wheel",i),()=>{n.removeEventListener("wheel",i)}}},[]),e.setValue&&_();const E=m(e.default)&&!t,lt=r.useCallback(()=>{const n=e.default??null;w(n),u({value:n,source:{fromUi:!0}})},[e]);kt({element:e,widgetMgr:a,onFormCleared:lt});const ct=n=>{const{value:i}=n.target;if(i==="")T(!0),w(null),v(null);else{let f;e.dataType===y.DataType.INT?f=parseInt(i,10):f=parseFloat(i),T(!0),w(f),v(i)}},N=r.useCallback(()=>{R&&(T(!0),u({value:(l??g)+s,source:{fromUi:!0}}))},[l,g,s,R]),z=r.useCallback(()=>{k&&(T(!0),u({value:(l??h)-s,source:{fromUi:!0}}))},[l,h,s,k]),ut=r.useCallback(n=>{const{key:i}=n;switch(i){case"ArrowUp":n.preventDefault(),N();break;case"ArrowDown":n.preventDefault(),z();break}},[N,z]),dt=r.useCallback(n=>{n.key==="Enter"&&(I&&u({value:l,source:{fromUi:!0}}),a.allowFormEnterToSubmit(p)&&a.submitForm(p,b))},[I,l,u,a,p,b]),G=C==null?void 0:C.startsWith(":material"),pt=G?"lg":"base",ft=q(o.iconSizes.lg)+2*q(o.spacing.twoXS),bt=C?o.breakpoints.hideNumberInputControls+ft:o.breakpoints.hideNumberInputControls;return F("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:ot,children:[c(St,{label:e.label,disabled:t,labelVisibility:yt((X=e.labelVisibility)==null?void 0:X.value),htmlFor:O.current,children:e.help&&c(Ct,{children:c(Tt,{content:e.help,placement:wt.TOP_RIGHT})})}),F(Bt,{className:A?"focused":"","data-testid":"stNumberInputContainer",children:[c(Dt,{type:"number",inputRef:V,value:U??"",placeholder:e.placeholder,onBlur:st,onFocus:it,onChange:ct,onKeyPress:dt,onKeyDown:ut,clearable:E,clearOnEscape:E,disabled:t,"aria-label":e.label,startEnhancer:e.icon&&c(vt,{"data-testid":"stNumberInputIcon",iconValue:e.icon,size:pt}),id:O.current,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:o.colors.darkGray,padding:o.spacing.threeXS,height:o.sizes.clearIconSize,width:o.sizes.clearIconSize,":hover":{fill:o.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:s,min:g,max:h,type:"number",inputMode:""},style:{lineHeight:o.lineHeights.inputWidget,paddingRight:o.spacing.sm,paddingLeft:o.spacing.md,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0,paddingRight:0,paddingLeft:C?o.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:o.iconSizes.lg,color:G?o.colors.fadedText60:"inherit"}}}}),H>bt&&F(Lt,{children:[c(J,{"data-testid":"stNumberInputStepDown",onClick:z,disabled:!k||t,tabIndex:-1,children:c(K,{content:tt,size:"xs",color:k?"inherit":o.colors.disabled})}),c(J,{"data-testid":"stNumberInputStepUp",onClick:N,disabled:!R||t,tabIndex:-1,children:c(K,{content:et,size:"xs",color:R?"inherit":o.colors.disabled})})]})]}),at&&c(Ht,{clearable:E,children:c(Rt,{dirty:I,value:U??"",inForm:j,allowEnterToSubmit:nt})})]})},Xt=r.memo(Pt);export{Xt as default};