streamlit-nightly 1.53.2.dev20260202__py3-none-any.whl → 1.54.1.dev20260204__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.
- streamlit/commands/logo.py +6 -10
- streamlit/components/v2/component_path_utils.py +17 -29
- streamlit/config.py +4 -2
- streamlit/elements/arrow.py +66 -26
- streamlit/elements/lib/built_in_chart_utils.py +1 -1
- streamlit/elements/lib/column_config_utils.py +4 -4
- streamlit/elements/lib/options_selector_utils.py +4 -0
- streamlit/elements/lib/pandas_styler_utils.py +22 -22
- streamlit/elements/widgets/button_group.py +221 -86
- streamlit/elements/widgets/data_editor.py +9 -9
- streamlit/elements/widgets/radio.py +8 -4
- streamlit/hello/dataframe_demo.py +1 -1
- streamlit/path_security.py +98 -0
- streamlit/proto/ArrowData_pb2.py +5 -3
- streamlit/proto/ArrowData_pb2.pyi +44 -4
- streamlit/proto/ArrowNamedDataSet_pb2.py +4 -4
- streamlit/proto/ArrowNamedDataSet_pb2.pyi +3 -3
- streamlit/proto/ArrowVegaLiteChart_pb2.py +4 -4
- streamlit/proto/ArrowVegaLiteChart_pb2.pyi +3 -3
- streamlit/proto/ButtonGroup_pb2.py +8 -8
- streamlit/proto/ButtonGroup_pb2.pyi +9 -7
- streamlit/proto/Dataframe_pb2.py +31 -0
- streamlit/proto/{Arrow_pb2.pyi → Dataframe_pb2.pyi} +39 -102
- streamlit/proto/Element_pb2.py +5 -4
- streamlit/proto/Element_pb2.pyi +11 -10
- streamlit/proto/Table_pb2.py +29 -0
- streamlit/proto/Table_pb2.pyi +83 -0
- streamlit/runtime/app_session.py +9 -1
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +307 -307
- streamlit/static/static/js/{ErrorOutline.esm.CLuz0rSD.js → ErrorOutline.esm.DWBqsdHn.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.CO68LcnZ.js → FileDownload.esm.D5koxJhf.js} +1 -1
- streamlit/static/static/js/{FileHelper.DAXgY6Ug.js → FileHelper.kJKftfu4.js} +5 -5
- streamlit/static/static/js/{FormClearHelper.zxJ53Nym.js → FormClearHelper.CyGGPn10.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CCbg8esE.js → InputInstructions.oezYb8Lm.js} +1 -1
- streamlit/static/static/js/{Particles.BJw0A-zv.js → Particles.BIpBmEwi.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BrrHeAEh.js → ProgressBar.BRAS_FJc.js} +1 -1
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.DvPLy3zk.js → StreamlitSyntaxHighlighter.c2qcx-xG.js} +2 -2
- streamlit/static/static/js/{TableChart.esm.BawvAi5p.js → TableChart.esm.BuemQLVW.js} +1 -1
- streamlit/static/static/js/{Toolbar.CbpscbNb.js → Toolbar.mUe2Nmta.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.DA4S2HFP.js → WidgetLabelHelpIconInline.if89y2mu.js} +1 -1
- streamlit/static/static/js/{base-input.BKKl2eBF.js → base-input.AJ4KxBTh.js} +4 -4
- streamlit/static/static/js/{checkbox.CB43AKV4.js → checkbox.GY4JoJkM.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.jVwF96ey.js → createDownloadLinkElement.BWJh90jh.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CxQizSv7.js → data-grid-overlay-editor.C9AINtRf.js} +1 -1
- streamlit/static/static/js/{downloader.CKlIgsy5.js → downloader.BZY8OE4f.js} +1 -1
- streamlit/static/static/js/{embed.BhRb_2n8.js → embed.BjO7Ez0y.js} +1 -1
- streamlit/static/static/js/{es6.DPyfPmWm.js → es6.eb5oR8iN.js} +2 -2
- streamlit/static/static/js/{formatNumber.DtfMnnPx.js → formatNumber.CCeQsvJQ.js} +1 -1
- streamlit/static/static/js/{iconPosition.DkZAlu_k.js → iconPosition.D6eEnKvO.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.l5sQWLra.js → iframeResizer.contentWindow.DTsWJRTo.js} +1 -1
- streamlit/static/static/js/{index.rvbQETlC.js → index.B6l4FdUv.js} +1 -1
- streamlit/static/static/js/{index.BUlT_mOL.js → index.B7H2q9vo.js} +2 -2
- streamlit/static/static/js/{index.CsIENsKH.js → index.BDdmrM58.js} +1 -1
- streamlit/static/static/js/{index.e6Ry6-Ft.js → index.BMbQnwRD.js} +1 -1
- streamlit/static/static/js/{index.CL_icBXS.js → index.BQ5MOzHu.js} +1 -1
- streamlit/static/static/js/{index.Ccye_uLl.js → index.BSgo_bkv.js} +1 -1
- streamlit/static/static/js/{index.LjqoQCm5.js → index.BU5M9DsN.js} +1 -1
- streamlit/static/static/js/{index.Bc_FQ4Wb.js → index.BYIxnU34.js} +1 -1
- streamlit/static/static/js/{index.y0h42OXL.js → index.BZL2hIBz.js} +1 -1
- streamlit/static/static/js/{index.Dac9Jib-.js → index.BZVrJlnq.js} +1 -1
- streamlit/static/static/js/{index.BLD3tJ2C.js → index.Bd7QK46M.js} +1 -1
- streamlit/static/static/js/{index.Ck64OQhV.js → index.BfHA_i34.js} +1 -1
- streamlit/static/static/js/{index.BpCj2-sQ.js → index.Bgry-Ek_.js} +1 -1
- streamlit/static/static/js/{index.D83azq2w.js → index.Bi25zaXA.js} +1 -1
- streamlit/static/static/js/{index.Cwg8nWw5.js → index.Bj3M1xBC.js} +1 -1
- streamlit/static/static/js/{index.DmWUXdjc.js → index.Bjrvlqx5.js} +16 -16
- streamlit/static/static/js/index.BnOSeM5K.js +11 -0
- streamlit/static/static/js/index.BoL6J1jK.js +2 -0
- streamlit/static/static/js/{index.yHLCvUGh.js → index.BoORyxOa.js} +1 -1
- streamlit/static/static/js/{index.DiBeetOH.js → index.Bpd7GPeH.js} +1 -1
- streamlit/static/static/js/{index.BzO83wKm.js → index.BpeJX018.js} +1 -1
- streamlit/static/static/js/{index.C_19KWNs.js → index.BriH7JVk.js} +1 -1
- streamlit/static/static/js/{index.DjuMEZ6m.js → index.BwkeObMo.js} +1 -1
- streamlit/static/static/js/{index.CiS4giQ2.js → index.C0o85qmd.js} +1 -1
- streamlit/static/static/js/{index.L9pOjBEn.js → index.C7_wNJTH.js} +2 -2
- streamlit/static/static/js/{index.DzdPUxsx.js → index.CGZP_w9b.js} +1 -1
- streamlit/static/static/js/{index.DKoJr0Se.js → index.CGw52-0-.js} +1 -1
- streamlit/static/static/js/{index.6J1N4is3.js → index.CUvtJj0a.js} +1 -1
- streamlit/static/static/js/{index.CBbYMKZp.js → index.Cfx1ZHWt.js} +1 -1
- streamlit/static/static/js/{index.BAK0CG1Q.js → index.Chl2kALe.js} +1 -1
- streamlit/static/static/js/index.Crlx_wdE.js +1 -0
- streamlit/static/static/js/{index.WIMtx3m0.js → index.D9A-8ebQ.js} +1 -1
- streamlit/static/static/js/{index.y5HxPwg9.js → index.DBIoNOen.js} +21 -21
- streamlit/static/static/js/{index.AZ9T4EqJ.js → index.DMKTAe4F.js} +1 -1
- streamlit/static/static/js/{index.YutgmD9x.js → index.DNrpqKVt.js} +2 -2
- streamlit/static/static/js/{index.Y9wPTZIf.js → index.DSRvF_8e.js} +1 -1
- streamlit/static/static/js/{index.DZOGT9vX.js → index.DhB1m_xG.js} +1 -1
- streamlit/static/static/js/{index.DR6V0uBJ.js → index.DiES30vM.js} +1 -1
- streamlit/static/static/js/{index.CmbqbRMZ.js → index.DlJ4Y1xc.js} +1 -1
- streamlit/static/static/js/{index.FioS1Y9m.js → index.J61yByUR.js} +1 -1
- streamlit/static/static/js/{index.hnu9U-5g.js → index.JxDTXE8N.js} +1 -1
- streamlit/static/static/js/{index.CaU3Uv_L.js → index.KGr28TP8.js} +1 -1
- streamlit/static/static/js/{index.465nmxtO.js → index.Pgm3rRpH.js} +1 -1
- streamlit/static/static/js/{index.DpSc4e1j.js → index.XzcYOc9I.js} +1 -1
- streamlit/static/static/js/{index.OizPL4jg.js → index.Z_u7ZS4h.js} +1 -1
- streamlit/static/static/js/{index.CL7it7tU.js → index.hDg7x0Tp.js} +1 -1
- streamlit/static/static/js/{index.b_f-McZ5.js → index.k7p0hmaU.js} +1 -1
- streamlit/static/static/js/{index.CsEZTo6L.js → index.syoxWolF.js} +1 -1
- streamlit/static/static/js/{index.Q2t_iBn0.js → index.xZ651bTg.js} +1 -1
- streamlit/static/static/js/{input.CAtwSQ27.js → input.C-PwAMG6.js} +1 -1
- streamlit/static/static/js/{main.VeMVx6VI.js → main.fMmyxXOf.js} +1 -1
- streamlit/static/static/js/{memory.CxS_lIUn.js → memory.BG__eDEj.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CoqRgZW_.js → number-overlay-editor.C0n-91sR.js} +1 -1
- streamlit/static/static/js/{pandasStylerUtils.DGWgd5sM.js → pandasStylerUtils.BqWaUzvh.js} +1 -1
- streamlit/static/static/js/{sandbox.2mSqEau0.js → sandbox.CHhc-txg.js} +1 -1
- streamlit/static/static/js/{sprintfjs.CsoVVZ9k.js → sprintfjs.BlFBKfMf.js} +1 -1
- streamlit/static/static/js/{styled-components.BShfh7J8.js → styled-components.D5uOQqN2.js} +1 -1
- streamlit/static/static/js/{throttle.Fq1DQK4p.js → throttle.DlZC3xNA.js} +1 -1
- streamlit/static/static/js/{timepicker.DmyY-qtn.js → timepicker._TfRUaDL.js} +4 -4
- streamlit/static/static/js/{toConsumableArray.Dvd9AIqV.js → toConsumableArray.CZW4AmuW.js} +2 -2
- streamlit/static/static/js/uniqueId.CTTDAAaF.js +1 -0
- streamlit/static/static/js/useBasicWidgetState.Bx27912z.js +1 -0
- streamlit/static/static/js/{useIntlLocale.kdIj0ego.js → useIntlLocale.DsOvysl7.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.DkuG1C1S.js → useTextInputAutoExpand.C9g8px1W.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.-UI_JsjT.js → useUpdateUiValue.fF-Cntkp.js} +1 -1
- streamlit/static/static/js/{useWaveformController.C5PTwL6I.js → useWaveformController.C5EtFoJE.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.BREyS0pJ.js → withCalculatedWidth.CcvaXQb0.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.DYDiEOrW.js → withFullScreenWrapper.DP61hzLF.js} +1 -1
- streamlit/testing/v1/element_tree.py +20 -15
- streamlit/web/server/app_static_file_handler.py +9 -0
- streamlit/web/server/bidi_component_request_handler.py +4 -4
- streamlit/web/server/component_file_utils.py +14 -6
- streamlit/web/server/component_request_handler.py +2 -2
- streamlit/web/server/routes.py +14 -0
- streamlit/web/server/server.py +4 -0
- streamlit/web/server/starlette/starlette_app.py +7 -1
- streamlit/web/server/starlette/starlette_path_security_middleware.py +97 -0
- streamlit/web/server/starlette/starlette_routes.py +6 -3
- streamlit/web/server/starlette/starlette_static_routes.py +14 -4
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.54.1.dev20260204.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.54.1.dev20260204.dist-info}/RECORD +135 -131
- streamlit/proto/Arrow_pb2.py +0 -34
- streamlit/static/static/js/index.CAoX2tlo.js +0 -2
- streamlit/static/static/js/index.DDr-BLbJ.js +0 -1
- streamlit/static/static/js/index.DL_ywOgf.js +0 -11
- streamlit/static/static/js/uniqueId.CCajdEK8.js +0 -1
- streamlit/static/static/js/useBasicWidgetState.COLQ5AFB.js +0 -1
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.54.1.dev20260204.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.54.1.dev20260204.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.53.2.dev20260202.dist-info → streamlit_nightly-1.54.1.dev20260204.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as i,a3 as m,r as c,j as n,
|
|
1
|
+
import{z as i,a3 as m,r as c,j as n,bb as p}from"./index.DBIoNOen.js";import{P as d,R as f}from"./Particles.BIpBmEwi.js";const g=""+new URL("../media/balloon-0.Czj7AKwE.png",import.meta.url).href,B=""+new URL("../media/balloon-1.CNvFFrND.png",import.meta.url).href,h=""+new URL("../media/balloon-2.DTvC6B1t.png",import.meta.url).href,L=""+new URL("../media/balloon-3.CgSk4tbL.png",import.meta.url).href,u=""+new URL("../media/balloon-4.mbtFrzxf.png",import.meta.url).href,b=""+new URL("../media/balloon-5.CSwkUfRA.png",import.meta.url).href,t=300,e=121,s=20,x=80,A=1e3,_=m("from{transform:translateY(calc(100vh + ",t,"px));}to{transform:translateY(0);}"),I=i("img",{target:"e19msdho0"})(({theme:o})=>({position:"fixed",top:`${-t}px`,marginLeft:`${-e/2}px`,zIndex:o.zIndices.balloons,left:`${Math.random()*(x-s)+s}vw`,animationDelay:`${Math.random()*A}ms`,height:`${t}px`,width:`${e}px`,pointerEvents:"none",animationDuration:"750ms",animationName:_,animationTimingFunction:"ease-in",animationDirection:"normal",animationIterationCount:1,opacity:1})),M=30,l=[g,B,h,L,u,b],w=l.length,E=({particleType:o,resourceCrossOriginMode:r})=>{const a=l[o];return n(I,{src:a,crossOrigin:p(r,a)})},N=({scriptRunId:o})=>n(f,{children:n(d,{className:"stBalloons","data-testid":"stBalloons",scriptRunId:o,numParticleTypes:w,numParticles:M,ParticleComponent:E})}),P=c.memo(N);export{M as NUM_BALLOONS,P as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{J as P,r as u,V as ao,
|
|
2
|
-
//# sourceURL=${r}-${n}.js`,a=new Blob([s],{type:"text/javascript"}),i=URL.createObjectURL(a);return this.cache.set(n,i),{url:i,hash:n}}}const fe=new le,ge="events";function Ce(o){if(o.includes(N))throw new Error("Base component id must not contain the delimiter sequence");return`${ne}_${o}${N}${ge}`}const D=async({componentId:o,componentIdForWidgetMgr:e,componentName:r,data:n,formId:t,fragmentId:s,getWidgetValue:a,moduleUrl:i,parentElement:l,widgetMgr:d})=>{const f=await import(i);if(!f)throw new Error("JS module does not exist.");if(!f.default||typeof f.default!="function")throw new Error("JS module does not have a default export function.");const g=(b,p)=>{let h={};try{h={...a(),[b]:p}}catch(C){v.error(`Failed to get existing value for ${b}`,C),h={[b]:p}}d.setJsonValue({id:e,formId:t},h,{fromUi:!0},s)},c=(b,p)=>{if(t){v.warn("BidiComponent: setTriggerValue ignored inside st.form. Triggers are not allowed in forms; use setStateValue and form submit instead.");return}const h=Ce(e);d.setTriggerValue({id:h,formId:t},{fromUi:!0},s,{event:b,value:p})};return f.default({name:r,data:n,key:o,parentElement:l,setStateValue:g,setTriggerValue:c})},uo=({containerRef:o,setError:e,skip:r=!1})=>{const t=`st-bidi-component-${u.useMemo(()=>go(),[])}`,{componentName:s,data:a,formId:i,fragmentId:l,getWidgetValue:d,id:f,jsContent:g,jsSourcePath:c,theme:b,widgetMgr:p,componentRegistry:{getBidiComponentURL:h}}=U(k),C=u.useMemo(()=>{if(c)return h(s,c)},[s,c,h]),
|
|
1
|
+
import{J as P,r as u,V as ao,cw as W,cx as co,aN as io,l as lo,j as m,W as U,R as fo,cy as go,z as _,aO as V}from"./index.DBIoNOen.js";function Co(o,e,r,n){for(var t=-1,s=o==null?0:o.length;++t<s;)r=e(r,o[t],t,o);return r}function xo(o){return function(e){return o?.[e]}}var po={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ho=xo(po),mo=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,bo="\\u0300-\\u036f",So="\\ufe20-\\ufe2f",yo="\\u20d0-\\u20ff",Ro=bo+So+yo,Eo="["+Ro+"]",Fo=RegExp(Eo,"g");function wo(o){return o=P(o),o&&o.replace(mo,ho).replace(Fo,"")}var vo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ko(o){return o.match(vo)||[]}var Bo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function To(o){return Bo.test(o)}var H="\\ud800-\\udfff",zo="\\u0300-\\u036f",Ao="\\ufe20-\\ufe2f",Uo="\\u20d0-\\u20ff",Io=zo+Ao+Uo,J="\\u2700-\\u27bf",Z="a-z\\xdf-\\xf6\\xf8-\\xff",Oo="\\xac\\xb1\\xd7\\xf7",Wo="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Lo="\\u2000-\\u206f",Mo=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",G="A-Z\\xc0-\\xd6\\xd8-\\xde",jo="\\ufe0e\\ufe0f",Y=Oo+Wo+Lo+Mo,q="['’]",L="["+Y+"]",$o="["+Io+"]",K="\\d+",No="["+J+"]",X="["+Z+"]",Q="[^"+H+Y+K+J+Z+G+"]",Do="\\ud83c[\\udffb-\\udfff]",Po="(?:"+$o+"|"+Do+")",_o="[^"+H+"]",oo="(?:\\ud83c[\\udde6-\\uddff]){2}",eo="[\\ud800-\\udbff][\\udc00-\\udfff]",w="["+G+"]",Vo="\\u200d",M="(?:"+X+"|"+Q+")",Ho="(?:"+w+"|"+Q+")",j="(?:"+q+"(?:d|ll|m|re|s|t|ve))?",$="(?:"+q+"(?:D|LL|M|RE|S|T|VE))?",ro=Po+"?",to="["+jo+"]?",Jo="(?:"+Vo+"(?:"+[_o,oo,eo].join("|")+")"+to+ro+")*",Zo="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Go="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Yo=to+ro+Jo,qo="(?:"+[No,oo,eo].join("|")+")"+Yo,Ko=RegExp([w+"?"+X+"+"+j+"(?="+[L,w,"$"].join("|")+")",Ho+"+"+$+"(?="+[L,w+M,"$"].join("|")+")",w+"?"+M+"+"+j,w+"+"+$,Go,Zo,K,qo].join("|"),"g");function Xo(o){return o.match(Ko)||[]}function Qo(o,e,r){return o=P(o),e=e,e===void 0?To(o)?Xo(o):ko(o):o.match(e)||[]}var oe="['’]",ee=RegExp(oe,"g");function re(o){return function(e){return Co(Qo(wo(e).replace(ee,"")),o,"")}}var te=re(function(o,e,r){return o+(r?"-":"")+e.toLowerCase()});const k=u.createContext(null);k.displayName="BidiComponentContext";const v=ao.getLogger("BidiComponent"),N="__",z="__streamlit_arrow_ref__",ne="$$STREAMLIT_INTERNAL_KEY",se=(o,e)=>{if(o&&typeof o=="object"&&!Array.isArray(o)){if(typeof o[z]=="string"){const n=o[z],t=e[n];if(t)try{return W(t)}catch{return null}return null}const r={};for(const[n,t]of Object.entries(o))if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t[z]=="string"){const s=t[z],a=e[s];if(a)try{r[n]=W(a)}catch{r[n]=null}else r[n]=null}else r[n]=t;return r}return o},ue=({arrowBlobs:o,arrowData:e,bytes:r,data:n,json:t,mixedJson:s})=>{switch(n){case"json":return t?JSON.parse(t):null;case"arrowData":return e??null;case"bytes":return r??null;case"mixed":{if(s&&o){const a=JSON.parse(s),i={};return Object.entries(o).forEach(([l,d])=>{d?.data&&(i[l]=d.data)}),se(a,i)}return null}case"any":case void 0:return null;default:co(n)}},ae=(o,e="--st")=>{const r={};return Object.entries(o).forEach(([n,t])=>{const s=te(n),a=`${e}-${s}`;if(typeof t=="boolean"){r[a]=t?"1":"0";return}if(t==null){r[a]="unset";return}if(Array.isArray(t)){r[a]=t.join(",");return}if(typeof t=="number"||typeof t=="string"){r[a]=String(t);return}r[a]="unset"}),r},ce=o=>{const e=[o.fontSizes.h1FontSize,o.fontSizes.h2FontSize,o.fontSizes.h3FontSize,o.fontSizes.h4FontSize,o.fontSizes.h5FontSize,o.fontSizes.h6FontSize],r=[o.fontWeights.h1FontWeight,o.fontWeights.h2FontWeight,o.fontWeights.h3FontWeight,o.fontWeights.h4FontWeight,o.fontWeights.h5FontWeight,o.fontWeights.h6FontWeight];return{primaryColor:o.colors.primary,backgroundColor:o.colors.bgColor,secondaryBackgroundColor:o.colors.secondaryBg,textColor:o.colors.bodyText,linkColor:o.colors.link,linkUnderline:o.linkUnderline,headingFont:o.genericFonts.headingFont,codeFont:o.genericFonts.codeFont,baseRadius:o.radii.default,buttonRadius:o.radii.button,baseFontSize:typeof o.fontSizes.baseFontSize=="number"?`${o.fontSizes.baseFontSize}px`:String(o.fontSizes.baseFontSize),baseFontWeight:o.fontWeights.normal,codeFontWeight:o.fontWeights.code,codeFontSize:o.fontSizes.codeFontSize,headingFontSizes:e,headingFontSize1:e[0],headingFontSize2:e[1],headingFontSize3:e[2],headingFontSize4:e[3],headingFontSize5:e[4],headingFontSize6:e[5],headingFontWeights:r,headingFontWeight1:r[0],headingFontWeight2:r[1],headingFontWeight3:r[2],headingFontWeight4:r[3],headingFontWeight5:r[4],headingFontWeight6:r[5],borderColor:o.colors.borderColor,dataframeBorderColor:o.colors.dataframeBorderColor,dataframeHeaderBackgroundColor:o.colors.dataframeHeaderBackgroundColor,codeBackgroundColor:o.colors.codeBackgroundColor,font:o.genericFonts.bodyFont,chartCategoricalColors:o.colors.chartCategoricalColors,chartSequentialColors:o.colors.chartSequentialColors,chartDivergingColors:o.colors.chartDivergingColors,headingColor:o.colors.headingColor,borderColorLight:o.colors.borderColorLight,codeTextColor:o.colors.codeTextColor,widgetBorderColor:o.colors.widgetBorderColor||"transparent",redColor:o.colors.redColor,orangeColor:o.colors.orangeColor,yellowColor:o.colors.yellowColor,blueColor:o.colors.blueColor,greenColor:o.colors.greenColor,violetColor:o.colors.violetColor,grayColor:o.colors.grayColor,redBackgroundColor:o.colors.redBackgroundColor,orangeBackgroundColor:o.colors.orangeBackgroundColor,yellowBackgroundColor:o.colors.yellowBackgroundColor,blueBackgroundColor:o.colors.blueBackgroundColor,greenBackgroundColor:o.colors.greenBackgroundColor,violetBackgroundColor:o.colors.violetBackgroundColor,grayBackgroundColor:o.colors.grayBackgroundColor,redTextColor:o.colors.redTextColor,orangeTextColor:o.colors.orangeTextColor,yellowTextColor:o.colors.yellowTextColor,blueTextColor:o.colors.blueTextColor,greenTextColor:o.colors.greenTextColor,violetTextColor:o.colors.violetTextColor,grayTextColor:o.colors.grayTextColor}},ie=u.memo(({element:o,children:e,widgetMgr:r,fragmentId:n,componentRegistry:t})=>{const{arrowData:s,bytes:a,componentName:i,cssContent:l,cssSourcePath:d,data:f,htmlContent:g,id:c,jsContent:b,json:p,jsSourcePath:h,mixed:C}=o,R=u.useMemo(()=>({id:o.id,formId:o.formId}),[o.id,o.formId]),B=u.useCallback(()=>{const F=r.getJsonValue(R);if(!F)return{};try{return JSON.parse(F)}catch(I){const y=io(I);return v.warn("Failed to parse widget JSON value; returning empty object.",{widgetId:R.id,formId:R.formId,error:y.message}),{}}},[R,r]),T=u.useMemo(()=>ue({arrowBlobs:C?.arrowBlobs||void 0,arrowData:s?.data||void 0,bytes:a,data:f,json:p,mixedJson:C?.json||void 0}),[f,p,s?.data,a,C?.json,C?.arrowBlobs]),S=lo(),E=u.useMemo(()=>ce(S),[S]),x=u.useMemo(()=>({componentName:i,componentRegistry:t,cssContent:l?.trim(),cssSourcePath:d||void 0,data:T,fragmentId:n,getWidgetValue:B,htmlContent:g?.trim(),id:c,formId:o.formId||void 0,jsContent:b||void 0,jsSourcePath:h||void 0,theme:E,widgetMgr:r}),[i,t,l,d,n,B,g,c,o.formId,b,h,T,E,r]);return m(k.Provider,{value:x,children:e})}),no=(o,e)=>{if(o instanceof Error)return o;const r=e?`${e}: ${String(o)}`:String(o);return new Error(r)},A=(o,e,r)=>{const n=no(o,r);v.error(`BidiComponent Error: ${n.message}`,o),e(n)},de=(o,e)=>{try{const n=document.createRange().createContextualFragment(o);e.appendChild(n)}catch(r){v.warn("createContextualFragment failed, falling back to innerHTML",r),e.innerHTML=o}},so=({containerRef:o,setError:e,skip:r=!1})=>{const n=u.useRef(null),{htmlContent:t,cssContent:s,cssSourcePath:a,componentName:i,componentRegistry:{getBidiComponentURL:l}}=U(k),d=u.useMemo(()=>{if(a)return l(i,a)},[i,a,l]),f=fo(d);return u.useEffect(()=>{if(r)return;const g=o.current;if(g)try{if(n.current?.parentNode===g&&g.removeChild(n.current),n.current=document.createElement("div"),t){const c=document.createElement("div");de(t,c),n.current.appendChild(c)}if(s){const c=document.createElement("style");c.textContent=s,n.current.appendChild(c)}else if(d){const c=document.createElement("link");c.href=d,c.rel="stylesheet",f&&(c.crossOrigin=f),c.onerror=()=>{A(new Error(`Failed to load CSS from ${d}`),e)},n.current.appendChild(c)}g.appendChild(n.current)}catch(c){A(c,e,"Failed to process HTML/CSS content")}},[t,s,o,f,d,e,r]),n};class le{constructor(){this.hashSeed=2166136261,this.hashPrime=16777619,this.cache=new Map}computeHash(e){let r=this.hashSeed;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r>>>0,this.hashPrime)>>>0;return(r>>>0).toString(16)}getOrCreateUrlForJs(e,r){const n=this.computeHash(e),t=this.cache.get(n);if(t)return{url:t,hash:n};const s=`${e}
|
|
2
|
+
//# sourceURL=${r}-${n}.js`,a=new Blob([s],{type:"text/javascript"}),i=URL.createObjectURL(a);return this.cache.set(n,i),{url:i,hash:n}}}const fe=new le,ge="events";function Ce(o){if(o.includes(N))throw new Error("Base component id must not contain the delimiter sequence");return`${ne}_${o}${N}${ge}`}const D=async({componentId:o,componentIdForWidgetMgr:e,componentName:r,data:n,formId:t,fragmentId:s,getWidgetValue:a,moduleUrl:i,parentElement:l,widgetMgr:d})=>{const f=await import(i);if(!f)throw new Error("JS module does not exist.");if(!f.default||typeof f.default!="function")throw new Error("JS module does not have a default export function.");const g=(b,p)=>{let h={};try{h={...a(),[b]:p}}catch(C){v.error(`Failed to get existing value for ${b}`,C),h={[b]:p}}d.setJsonValue({id:e,formId:t},h,{fromUi:!0},s)},c=(b,p)=>{if(t){v.warn("BidiComponent: setTriggerValue ignored inside st.form. Triggers are not allowed in forms; use setStateValue and form submit instead.");return}const h=Ce(e);d.setTriggerValue({id:h,formId:t},{fromUi:!0},s,{event:b,value:p})};return f.default({name:r,data:n,key:o,parentElement:l,setStateValue:g,setTriggerValue:c})},uo=({containerRef:o,setError:e,skip:r=!1})=>{const t=`st-bidi-component-${u.useMemo(()=>go(),[])}`,{componentName:s,data:a,formId:i,fragmentId:l,getWidgetValue:d,id:f,jsContent:g,jsSourcePath:c,theme:b,widgetMgr:p,componentRegistry:{getBidiComponentURL:h}}=U(k),C=u.useMemo(()=>{if(c)return h(s,c)},[s,c,h]),R=u.useRef(),B=u.useRef(),T=u.useRef(!1);u.useEffect(()=>{const{current:S}=o;if(r||!g&&!C||!S)return;(async()=>{try{if(g){const{url:x}=fe.getOrCreateUrlForJs(g,`st-bidi-${s}`);R.current=await D({componentId:t,componentIdForWidgetMgr:f,componentName:s,data:a,formId:i,fragmentId:l,getWidgetValue:d,moduleUrl:x,parentElement:S,widgetMgr:p})}else if(C){const x=C;try{await new Promise((F,I)=>{const y=document.createElement("script");y.type="module",y.src=x,y.async=!0,y.onload=()=>F(),y.onerror=()=>I(new Error(`Failed to load script from ${C}`)),document.head.appendChild(y),B.current=y}),R.current=await D({componentId:t,componentIdForWidgetMgr:f,componentName:s,data:a,formId:i,fragmentId:l,getWidgetValue:d,moduleUrl:x,parentElement:S,widgetMgr:p})}catch(F){throw no(F,`Failed to load or execute script from ${C}`)}}}catch(x){T.current||A(x,e)}})()},[t,s,o,a,i,l,d,f,g,C,e,r,p,b]),u.useEffect(()=>()=>{T.current=!0;const S=R.current;S&&Promise.resolve(S).then(x=>{x?.()}).catch(x=>{v.error("Failed to run custom component cleanup",x)});const E=B.current;E?.parentNode&&E.parentNode.removeChild(E)},[])},xe=_("div",{target:"epzkg1s0"})(({cssCustomProperties:o})=>({...o,display:"contents"})),O=_("div",{target:"epzkg1s1"})({width:"100%",height:"100%"}),pe=u.memo(()=>{const o=u.useRef(null),e=u.useRef(null),[r,n]=u.useState(!1),[t,s]=u.useState(null),{id:a}=U(k);u.useEffect(()=>{if(o.current)try{if(o.current.shadowRoot){e.current=o.current.shadowRoot,n(!0);return}e.current=o.current.attachShadow({mode:"open"}),n(!0)}catch(l){A(l,s,"Failed to create shadow DOM")}},[a]);const i=!r||!!t;return so({containerRef:e,setError:s,skip:i}),uo({containerRef:e,setError:s,skip:i}),t?m(V,{name:"BidiComponent Error",message:t.message,stack:t.stack}):m(O,{ref:o,"data-testid":"stBidiComponentIsolated"})}),he=u.memo(()=>{const o=u.useRef(null),[e,r]=u.useState(null),n=!!e;return so({containerRef:o,setError:r,skip:n}),uo({containerRef:o,setError:r,skip:n}),e?m(V,{name:"BidiComponent Error",message:e.message,stack:e.stack}):m(O,{ref:o,"data-testid":"stBidiComponentRegular"})}),me=({children:o})=>{const{theme:e}=U(k),r=u.useMemo(()=>ae(e),[e]);return m(xe,{cssCustomProperties:r,children:o})},be=({element:o,widgetMgr:e,fragmentId:r,componentRegistry:n})=>{const{isolateStyles:t}=o;return m(ie,{element:o,widgetMgr:e,fragmentId:r,componentRegistry:n,children:m(O,{className:"stBidiComponent",children:m(me,{children:t?m(pe,{}):m(he,{})})})})},ye=u.memo(be);export{k as BidiComponentContext,ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as k,r as l,a6 as C,j as d,Y as _,a7 as c}from"./index.
|
|
1
|
+
import{z as k,r as l,a6 as C,j as d,Y as _,a7 as c}from"./index.DBIoNOen.js";import{u as R}from"./useBasicWidgetState.Bx27912z.js";import"./FormClearHelper.CyGGPn10.js";const x=k("div",{target:"e1xqjt520"})(({containerWidth:e})=>({width:e?"100%":"auto",minWidth:"fit-content"})),I=k("div",{target:"e1xqjt521"})(({theme:e})=>({display:"flex",flexWrap:"nowrap",gap:e.spacing.threeXS,minWidth:"fit-content"})),D=k("button",{target:"e1xqjt522"})(({theme:e,isSelected:t})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",padding:e.spacing.threeXS,margin:e.spacing.none,backgroundColor:e.colors.transparent,color:t?e.colors.bodyText:e.colors.fadedText60,border:"none",borderRadius:e.radii.button,cursor:"pointer",userSelect:"none",minHeight:"unset",flex:"0 0 fit-content","&:focus":{boxShadow:"none",outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},"&:hover:not(:disabled)":{color:e.colors.bodyText},"&:disabled":{color:t?e.colors.fadedText40:e.colors.fadedText10,cursor:"not-allowed",img:{opacity:.4}}})),f=[":material/thumb_up:",":material/thumb_down:"],B=[":material/sentiment_sad:",":material/sentiment_dissatisfied:",":material/sentiment_neutral:",":material/sentiment_satisfied:",":material/sentiment_very_satisfied:"],M=":material/star:",N=":material/star_filled:",F=5;function U(e){switch(e){case c.FeedbackType.FACES:return B.map((t,a)=>({icon:t,selectedIcon:t,value:a}));case c.FeedbackType.STARS:return Array.from({length:F},(t,a)=>({icon:M,selectedIcon:N,value:a}));default:return[{icon:f[0],selectedIcon:f[0],value:1},{icon:f[1],selectedIcon:f[1],value:0}]}}function W(e,t){switch(t){case c.FeedbackType.THUMBS:return e===1?"Thumbs up":"Thumbs down";case c.FeedbackType.FACES:return["Very dissatisfied","Dissatisfied","Neutral","Satisfied","Very satisfied"][e]??`Rating ${e+1}`;case c.FeedbackType.STARS:return`${e+1} out of ${F} stars`;default:return`Rating ${e+1}`}}function j(e,t,a){return t===null?!1:a===c.FeedbackType.STARS?e<=t:e===t}function E(e,t){const a=e.getStringValue(t);if(a!==void 0)return a===""?null:parseInt(a,10)}function L(e){return e.default??null}function O(e){return e.value??null}function $(e,t,a,b){const g=a.value===null?"":String(a.value);t.setStringValue(e,g,{fromUi:a.fromUi},b)}function q(e){const{disabled:t,element:a,fragmentId:b,widgetMgr:g,widthConfig:h}=e,{type:u}=a,[v,p]=R({getStateFromWidgetMgr:E,getDefaultStateFromProto:L,getCurrStateFromProto:O,updateWidgetMgrState:$,element:a,widgetMgr:g,fragmentId:b}),o=a.value??v,w=C(h),i=l.useMemo(()=>U(u),[u]),y=l.useRef([]),m=l.useCallback(n=>{p({value:o===n?null:n,fromUi:!0})},[o,p]),T=l.useCallback((n,r)=>{let s;switch(n.key){case"ArrowLeft":case"ArrowUp":n.preventDefault(),s=r>0?r-1:i.length-1;break;case"ArrowRight":case"ArrowDown":n.preventDefault(),s=r<i.length-1?r+1:0;break;case" ":case"Enter":n.preventDefault(),m(i[r].value);return;default:return}y.current[s]?.focus()},[i,m]);return d(x,{className:"stFeedback","data-testid":"stFeedback",containerWidth:w,children:d(I,{role:"radiogroup","aria-label":"Feedback rating",children:i.map((n,r)=>{const s=j(n.value,o,u),A=s?n.selectedIcon:n.icon;return d(D,{ref:S=>{y.current[r]=S},type:"button",role:"radio","aria-checked":o===n.value,"aria-label":W(n.value,u),tabIndex:o===n.value||o===null&&r===0?0:-1,disabled:t,isSelected:s,onClick:()=>m(n.value),onKeyDown:S=>T(S,r),"data-testid":s?"stFeedbackButtonActive":"stFeedbackButton",children:d(_,{iconValue:A,size:"lg"})},n.value)})})})}const K=l.memo(q);export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,E as G,_ as Y,z as
|
|
1
|
+
import{r as a,E as G,_ as Y,z as V,bk as C,e as h,n as J,V as dt,l as pt,k as ft,ab as mt,ac as k,o as B,j as d,p as bt,ad as ht,ae as gt,af as yt,Y as It,az as j}from"./index.DBIoNOen.js";import{I as Ct}from"./InputInstructions.oezYb8Lm.js";import{u as Tt}from"./useBasicWidgetState.Bx27912z.js";import{s as St}from"./sprintfjs.BlFBKfMf.js";import{u as wt}from"./uniqueId.CTTDAAaF.js";import{I as vt}from"./input.C-PwAMG6.js";import"./FormClearHelper.CyGGPn10.js";import"./base-input.AJ4KxBTh.js";var Q=a.forwardRef(function(t,e){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return a.createElement(G,Y({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),a.createElement("path",{d:"M0 3v2h8V3H0z"}))});Q.displayName="Minus";var Z=a.forwardRef(function(t,e){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return a.createElement(G,Y({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),a.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});Z.displayName="Plus";const xt=V("div",{target:"eaeic2i0"})(({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}}})),Dt=V("div",{target:"eaeic2i1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),K=V("button",{target:"eaeic2i2"})(({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"},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),kt=V("div",{target:"eaeic2i3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),Vt=dt.getLogger("NumberInput");function Nt(t){return h(t)||t===""?void 0:t}const tt=t=>{const e=t.toString();if(e.includes("e-")){const o=e.match(/(\d+(?:\.\d+)?)e-(\d+)/);if(o){const i=(o[1]?.split(".")[1]||"").length,n=parseInt(o[2],10);return i+n}return 0}return(e.split(".")[1]||"").length},_=({value:t,format:e,step:o,dataType:i})=>{if(h(t))return null;let n=Nt(e);if(h(n)&&J(o)&&i===C.DataType.FLOAT&&o!==0){const l=tt(o);l>0&&(n=`%0.${l}f`)}if(h(n))return t.toString();try{return St(n,t)}catch(l){return Vt.warn(`Error in sprintf(${n}, ${t}): ${l}`),String(t)}},Et=(t,e,o)=>h(t)?!1:t-e>=o,Rt=(t,e,o)=>h(t)?!1:t+e<=o,X=(t,e,o)=>{const i=tt(e);if(i===0)switch(o){case"add":return t+e;case"subtract":return t-e}const n=Math.pow(10,i),l=Math.round(t*n),p=Math.round(e*n);switch(o){case"add":return(l+p)/n;case"subtract":return(l-p)/n}},Ft=({step:t,dataType:e})=>t||(e===C.DataType.INT?1:.01);function q(t,e){return e.dataType===C.DataType.INT?t.getIntValue(e):t.getDoubleValue(e)}function Wt(t){return t.default??null}function zt(t){return t.value??t.default??null}function Bt(t,e,o,i){switch(t.dataType){case C.DataType.INT:e.setIntValue(t,o.value,{fromUi:o.fromUi},i);break;case C.DataType.FLOAT:e.setDoubleValue(t,o.value,{fromUi:o.fromUi},i);break;default:throw new Error("Invalid data type")}}const Lt=({disabled:t,element:e,widgetMgr:o,fragmentId:i})=>{const n=pt(),{dataType:l,formId:p,default:T,format:N,icon:E,min:g,max:y}=e,{width:L,elementRef:et}=ft(),c=a.useMemo(()=>Ft({step:e.step,dataType:e.dataType}),[e.step,e.dataType]),I=a.useCallback(r=>_({value:r,dataType:l,format:N,step:c}),[l,N,c]),[f,w]=a.useState(!1),[b,S]=a.useState(()=>{const r=q(o,e)??T??null;return _({value:r,dataType:l,format:N,step:c})}),[P,U]=Tt({getStateFromWidgetMgr:q,getDefaultStateFromProto:Wt,getCurrStateFromProto:zt,updateWidgetMgrState:Bt,element:e,widgetMgr:o,fragmentId:i,onFormCleared:a.useCallback(()=>{const r=T??null;w(!1),S(I(r))},[T,I])}),[A,H]=a.useState(!1),R=a.useRef(null),[$]=a.useState(()=>wt("number_input_")),M=mt({formId:p}),nt=M?o.allowFormEnterToSubmit(p):f,ot=A&&L>k(n.breakpoints.hideWidgetDetails);a.useEffect(()=>{f||S(I(P))},[P,f,I]);const m=a.useCallback(({value:r,fromUi:s})=>{if(J(r)&&(g>r||r>y)){R.current?.reportValidity();return}const D=r??T??null;U({value:D,fromUi:s}),w(!1),S(I(D))},[g,y,T,I,U]),rt=a.useCallback(()=>{H(!0)},[]);a.useEffect(()=>{const r=R.current;if(r){const s=D=>{D.preventDefault()};return r.addEventListener("wheel",s),()=>{r.removeEventListener("wheel",s)}}},[]);const F=h(e.default)&&!t,at=a.useCallback(r=>{const{value:s}=r.target;s===""?(w(!0),S(null)):(w(!0),S(s))},[]),u=a.useMemo(()=>{if(b===null||b==="")return null;if(e.dataType===C.DataType.INT){const s=parseInt(b,10);return isNaN(s)?null:s}const r=parseFloat(b);return isNaN(r)?null:r},[b,e.dataType]),v=Et(u,c,g),x=Rt(u,c,y),it=a.useCallback(()=>{f&&m({value:u,fromUi:!0}),H(!1)},[f,u,m]),W=a.useCallback(()=>{if(x){const r=X(u??g,c,"add");m({value:r,fromUi:!0})}},[u,g,c,x,m]),z=a.useCallback(()=>{if(v){const r=X(u??y,c,"subtract");m({value:r,fromUi:!0})}},[u,y,c,v,m]),st=a.useCallback(r=>{const{key:s}=r;switch(s){case"ArrowUp":r.preventDefault(),W();break;case"ArrowDown":r.preventDefault(),z();break}},[W,z]),lt=a.useCallback(r=>{r.key==="Enter"&&(f&&m({value:u,fromUi:!0}),o.allowFormEnterToSubmit(p)&&o.submitForm(p,i))},[f,u,m,o,p,i]),ct=k(n.iconSizes.lg)+2*k(n.spacing.twoXS),O=k(n.breakpoints.hideNumberInputControls),ut=E?O+ct:O;return B("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:et,children:[d(gt,{label:e.label,disabled:t,labelVisibility:bt(e.labelVisibility?.value),htmlFor:$,children:e.help&&d(ht,{content:e.help,label:e.label})}),B(xt,{className:A?"focused":"","data-testid":"stNumberInputContainer",children:[d(vt,{type:"number",inputRef:R,value:b??"",placeholder:e.placeholder,onBlur:it,onFocus:rt,onChange:at,onKeyPress:lt,onKeyDown:st,clearable:F,clearOnEscape:F,disabled:t,"aria-label":e.label,startEnhancer:e.icon&&d(It,{"data-testid":"stNumberInputIcon",iconValue:e.icon,size:"lg"}),id:$,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:n.colors.grayTextColor,padding:n.spacing.threeXS,height:n.sizes.clearIconSize,width:n.sizes.clearIconSize,":hover":{fill:n.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:c,min:g,max:y,type:"number",inputMode:""},style:{fontWeight:n.fontWeights.normal,lineHeight:n.lineHeights.inputWidget,paddingRight:n.spacing.sm,paddingLeft:n.spacing.md,paddingBottom:n.spacing.sm,paddingTop:n.spacing.sm,"::placeholder":{color:n.colors.fadedText60}}},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:E?n.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:n.iconSizes.lg,color:yt(E)?n.colors.fadedText60:"inherit"}}}}),L>ut&&B(Dt,{children:[d(K,{"data-testid":"stNumberInputStepDown",onClick:z,disabled:!v||t,tabIndex:-1,children:d(j,{content:Q,size:"xs",color:v?"inherit":n.colors.fadedText40})}),d(K,{"data-testid":"stNumberInputStepUp",onClick:W,disabled:!x||t,tabIndex:-1,children:d(j,{content:Z,size:"xs",color:x?"inherit":n.colors.fadedText40})})]})]}),ot&&d(kt,{clearable:F,children:d(Ct,{dirty:f,value:b??"",inForm:M,allowEnterToSubmit:nt})})]})},Kt=a.memo(Lt);export{Kt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as c,aj as e,c as t,r as n,B as l,j as a,u as C,a as x,D as L,d as S}from"./index.
|
|
1
|
+
import{z as c,aj as e,c as t,r as n,B as l,j as a,u as C,a as x,D as L,d as S}from"./index.DBIoNOen.js";import{m as $}from"./iconPosition.D6eEnKvO.js";function R(o,r){switch(o){case t.XSMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.sm}`,fontSize:r.fontSizes.sm};case t.SMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.md}`};case t.LARGE:return{padding:`${r.spacing.md} ${r.spacing.md}`};default:return{padding:`${r.spacing.xs} ${r.spacing.md}`}}}const f=c("a",{target:"e1hofpsd0"})(({containerWidth:o,size:r,theme:i})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,borderRadius:i.radii.button,minHeight:i.sizes.minElementHeight,margin:0,lineHeight:i.lineHeights.base,color:i.colors.primary,textDecoration:"none",width:o?"100%":"auto",userSelect:"none","&:visited":{color:i.colors.primary},"&:focus":{outline:"none"},"&:focus-visible":{boxShadow:i.shadows.focusRing},"&:hover":{textDecoration:"none"},"&:active":{textDecoration:"none"},...R(r,i)})),T=c(f,{target:"e1hofpsd1"})(({theme:o})=>({backgroundColor:o.colors.primary,color:o.colors.white,border:`${o.sizes.borderWidth} solid ${o.colors.primary}`,"&:hover, &:focus-visible":{backgroundColor:e(o.colors.primary,.15),borderColor:e(o.colors.primary,.15)},"&:active":{backgroundColor:o.colors.primary,borderColor:e(o.colors.primary,.15)},"&:visited:not(:active)":{color:o.colors.white},"&[disabled], &[disabled]:hover, &[disabled]:active, &[disabled]:visited":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),w=c(f,{target:"e1hofpsd2"})(({theme:o})=>({backgroundColor:o.colors.lightenedBg05,color:o.colors.bodyText,border:`${o.sizes.borderWidth} solid ${o.colors.borderColor}`,"&:visited":{color:o.colors.bodyText},"&:hover, &:focus-visible":{backgroundColor:o.colors.darkenedBgMix15},"&:active":{backgroundColor:o.colors.darkenedBgMix25},"&[disabled], &[disabled]:hover, &[disabled]:active":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),z=c(f,{target:"e1hofpsd3"})(({theme:o})=>({padding:o.spacing.none,backgroundColor:o.colors.transparent,color:o.colors.bodyText,border:"none","&:visited":{color:o.colors.bodyText},"&:hover, &:focus-visible":{color:o.colors.primary},"&:hover:not([disabled]), &:focus-visible:not([disabled])":{"span.stMarkdownColoredText":{color:"inherit !important"}},"&:active":{color:e(o.colors.primary,.25)},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),y=n.forwardRef(function({kind:r,size:i,disabled:s,children:d,autoFocus:u,href:b,rel:p,target:k,onClick:B},v){let g=T;return r===l.SECONDARY?g=w:r===l.TERTIARY&&(g=z),a(g,{ref:v,kind:r,size:i||t.MEDIUM,containerWidth:!0,disabled:s||!1,autoFocus:u||!1,href:b,target:k,rel:p,onClick:B,tabIndex:s?-1:0,"data-testid":`stBaseLinkButton-${r}`,children:d})});y.displayName="BaseLinkButton";const A=n.memo(y);function D(o){const{element:r}=o,i=r.shortcut?r.shortcut:void 0;let s=l.SECONDARY;r.type==="primary"?s=l.PRIMARY:r.type==="tertiary"&&(s=l.TERTIARY);const d=n.useRef(null),u=n.useCallback(()=>{r.disabled||d.current?.click()},[r.disabled]),b=n.useCallback(p=>{r.disabled&&p.preventDefault()},[r.disabled]);return C({shortcut:i,disabled:r.disabled,onActivate:u}),a(S,{className:"stLinkButton","data-testid":"stLinkButton",children:a(x,{help:r.help,containerWidth:!0,children:a(A,{ref:d,kind:s,size:t.SMALL,disabled:r.disabled,onClick:b,href:r.url,target:"_blank",rel:"noreferrer","aria-disabled":r.disabled,children:a(L,{icon:r.icon,iconPosition:$(r.iconPosition),label:r.label,shortcut:i})})})})}const I=n.memo(D);export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,l as $,aB as ht,L as gt,e as tt,o as mt,j as T,p as wt,ad as bt,ae as pt,ay as yt,ag as Dt,aA as Ot,P as xt,az as kt,q as St,m as Tt}from"./index.y5HxPwg9.js";import{h as P}from"./moment.C7qA8nIE.js";import{u as Mt}from"./useBasicWidgetState.COLQ5AFB.js";import{e as Ct,u as Yt,D as Wt,a as Et}from"./useIntlLocale.kdIj0ego.js";import{E as Pt}from"./ErrorOutline.esm.CLuz0rSD.js";import"./FormClearHelper.zxJ53Nym.js";import"./timepicker.DmyY-qtn.js";import"./input.CAtwSQ27.js";import"./base-input.BKKl2eBF.js";const et=6048e5,vt=864e5,X=Symbol.for("constructDateFrom");function O(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&X in e?e[X](t):e instanceof Date?new e.constructor(t):new Date(t)}function p(e,t){return O(t||e,e)}let Ft={};function I(){return Ft}function v(e,t){const r=I(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=p(e,t?.in),o=a.getDay(),i=(o<n?7:0)+o-n;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function F(e,t){return v(e,{...t,weekStartsOn:1})}function rt(e,t){const r=p(e,t?.in),n=r.getFullYear(),a=O(r,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const o=F(a),i=O(r,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const f=F(i);return r.getTime()>=o.getTime()?n+1:r.getTime()>=f.getTime()?n:n-1}function V(e){const t=p(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function It(e,...t){const r=O.bind(null,t.find(n=>typeof n=="object"));return t.map(r)}function j(e,t){const r=p(e,t?.in);return r.setHours(0,0,0,0),r}function Bt(e,t,r){const[n,a]=It(r?.in,e,t),o=j(n),i=j(a),f=+o-V(o),g=+i-V(i);return Math.round((f-g)/vt)}function Ht(e,t){const r=rt(e,t),n=O(e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),F(n)}function qt(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Lt(e){return!(!qt(e)&&typeof e!="number"||isNaN(+p(e)))}function Nt(e,t){const r=p(e,t?.in);return r.setFullYear(r.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Rt(e,t){const r=p(e,t?.in);return Bt(r,Nt(r))+1}function _t(e,t){const r=p(e,t?.in),n=+F(r)-+Ht(r);return Math.round(n/et)+1}function nt(e,t){const r=p(e,t?.in),n=r.getFullYear(),a=I(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=O(t?.in||e,0);i.setFullYear(n+1,0,o),i.setHours(0,0,0,0);const f=v(i,t),g=O(t?.in||e,0);g.setFullYear(n,0,o),g.setHours(0,0,0,0);const y=v(g,t);return+r>=+f?n+1:+r>=+y?n:n-1}function Gt(e,t){const r=I(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=nt(e,t),o=O(t?.in||e,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),v(o,t)}function Qt(e,t){const r=p(e,t?.in),n=+v(r,t)-+Gt(r,t);return Math.round(n/et)+1}function s(e,t){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}const D={y(e,t){const r=e.getFullYear(),n=r>0?r:1-r;return s(t==="yy"?n%100:n,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):s(r+1,2)},d(e,t){return s(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return s(e.getHours()%12||12,t.length)},H(e,t){return s(e.getHours(),t.length)},m(e,t){return s(e.getMinutes(),t.length)},s(e,t){return s(e.getSeconds(),t.length)},S(e,t){const r=t.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return s(a,t.length)}},M={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},z={G:function(e,t,r){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return D.y(e,t)},Y:function(e,t,r,n){const a=nt(e,n),o=a>0?a:1-a;if(t==="YY"){const i=o%100;return s(i,2)}return t==="Yo"?r.ordinalNumber(o,{unit:"year"}):s(o,t.length)},R:function(e,t){const r=rt(e);return s(r,t.length)},u:function(e,t){const r=e.getFullYear();return s(r,t.length)},Q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return s(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return s(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){const n=e.getMonth();switch(t){case"M":case"MM":return D.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return s(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){const a=Qt(e,n);return t==="wo"?r.ordinalNumber(a,{unit:"week"}):s(a,t.length)},I:function(e,t,r){const n=_t(e);return t==="Io"?r.ordinalNumber(n,{unit:"week"}):s(n,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):D.d(e,t)},D:function(e,t,r){const n=Rt(e);return t==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):s(n,t.length)},E:function(e,t,r){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return s(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return s(o,t.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const n=e.getDay(),a=n===0?7:n;switch(t){case"i":return String(a);case"ii":return s(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const n=e.getHours();let a;switch(n===12?a=M.noon:n===0?a=M.midnight:a=n/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const n=e.getHours();let a;switch(n>=17?a=M.evening:n>=12?a=M.afternoon:n>=4?a=M.morning:a=M.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return D.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):D.H(e,t)},K:function(e,t,r){const n=e.getHours()%12;return t==="Ko"?r.ordinalNumber(n,{unit:"hour"}):s(n,t.length)},k:function(e,t,r){let n=e.getHours();return n===0&&(n=24),t==="ko"?r.ordinalNumber(n,{unit:"hour"}):s(n,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):D.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):D.s(e,t)},S:function(e,t){return D.S(e,t)},X:function(e,t,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return Z(n);case"XXXX":case"XX":return k(n);case"XXXXX":case"XXX":default:return k(n,":")}},x:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"x":return Z(n);case"xxxx":case"xx":return k(n);case"xxxxx":case"xxx":default:return k(n,":")}},O:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+U(n,":");case"OOOO":default:return"GMT"+k(n,":")}},z:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+U(n,":");case"zzzz":default:return"GMT"+k(n,":")}},t:function(e,t,r){const n=Math.trunc(+e/1e3);return s(n,t.length)},T:function(e,t,r){return s(+e,t.length)}};function U(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+t+s(o,2)}function Z(e,t){return e%60===0?(e>0?"-":"+")+s(Math.abs(e)/60,2):k(e,t)}function k(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=s(Math.trunc(n/60),2),o=s(n%60,2);return r+a+t+o}const J=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},at=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},At=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return J(e,t);let o;switch(n){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",J(n,t)).replace("{{time}}",at(a,t))},$t={p:at,P:At},Xt=/^D+$/,Vt=/^Y+$/,jt=["D","DD","YY","YYYY"];function zt(e){return Xt.test(e)}function Ut(e){return Vt.test(e)}function Zt(e,t,r){const n=Jt(e,t,r);if(console.warn(n),jt.includes(e))throw new RangeError(n)}function Jt(e,t,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Kt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,te=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ee=/^'([^]*?)'?$/,re=/''/g,ne=/[a-zA-Z]/;function K(e,t,r){const n=I(),a=r?.locale??n.locale??Ct,o=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,f=p(e,r?.in);if(!Lt(f))throw new RangeError("Invalid time value");let g=t.match(te).map(u=>{const d=u[0];if(d==="p"||d==="P"){const c=$t[d];return c(u,a.formatLong)}return u}).join("").match(Kt).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:ae(u)};if(z[d])return{isToken:!0,value:u};if(d.match(ne))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});a.localize.preprocessor&&(g=a.localize.preprocessor(f,g));const y={firstWeekContainsDate:o,weekStartsOn:i,locale:a};return g.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!r?.useAdditionalWeekYearTokens&&Ut(d)||!r?.useAdditionalDayOfYearTokens&&zt(d))&&Zt(d,t,String(e));const c=z[d[0]];return c(f,d,a.localize,y)}).join("")}function ae(e){const t=e.match(ee);return t?t[1].replace(re,"'"):e}const B="YYYY/MM/DD";function H(e){return e.map(t=>new Date(t))}function oe(e){return e?e.map(t=>P(t).format(B)):[]}function se({disabled:e,element:t,widgetMgr:r,fragmentId:n}){const a=$(),o=h.useContext(ht),[i,f]=Mt({getStateFromWidgetMgr:ie,getDefaultStateFromProto:ce,getCurrStateFromProto:ue,updateWidgetMgrState:de,element:t,widgetMgr:r,fragmentId:n}),[g,y]=h.useState(!1),[u,d]=h.useState(null),{colors:c,fontSizes:q,fontWeights:it,lineHeights:Q,spacing:m,sizes:w}=$(),{locale:ct}=h.useContext(gt),C=Yt(ct),x=h.useMemo(()=>P(t.min,B).toDate(),[t.min]),S=h.useMemo(()=>st(t),[t]),ut=h.useMemo(()=>{if(!t.isRange)return!1;const l=P().subtract(2,"years").toDate();return x<l},[t.isRange,x]),dt=t.default.length===0&&!e,L=h.useMemo(()=>t.format.replaceAll(/[a-zA-Z]/g,"9"),[t.format]),Y=h.useMemo(()=>t.format.replaceAll("Y","y").replaceAll("D","d"),[t.format]),N=h.useMemo(()=>K(x,Y,{locale:C}),[x,Y,C]),R=h.useMemo(()=>S?K(S,Y,{locale:C}):"",[S,Y,C]),A=h.useCallback(l=>{if(!l)return null;if(t.isRange){const b=l==="End"?`before ${R}`:`after ${N}`;return`**Error**: ${l} date set outside allowed range. Please select a date ${b}.`}return`**Error**: Date set outside allowed range. Please select a date between ${N} and ${R}.`},[t.isRange,R,N]),ft=h.useCallback(({date:l})=>{if(d(null),tt(l)){f({value:[],fromUi:!0}),y(!0);return}const b=Array.isArray(l)?l.filter(_=>!!_).map(_=>G(_)):G(l),{errorType:W,newDates:E}=ot(b,x,S);W&&d(A(W)),f({value:E,fromUi:!0}),y(!E)},[f,A,d,x,S]),lt=h.useCallback(()=>{if(!g)return;const l=H(t.default);f({value:l,fromUi:!0}),y(!l)},[g,t,f]);return mt("div",{className:"stDateInput","data-testid":"stDateInput",children:[T(pt,{label:t.label,disabled:e,labelVisibility:wt(t.labelVisibility?.value),children:t.help&&T(bt,{content:t.help,label:t.label})}),T(Et,{locale:C,density:Wt.high,formatString:Y,mask:t.isRange?`${L} – ${L}`:L,placeholder:t.isRange?`${t.format} – ${t.format}`:t.format,disabled:e,onChange:ft,onClose:lt,quickSelect:ut,overrides:{Popover:{props:{ignoreBoundary:o,placement:yt.bottomLeft,overrides:{Body:{style:{marginTop:m.px}}}}},CalendarContainer:{style:{fontSize:q.sm,paddingRight:m.sm,paddingLeft:m.sm,paddingBottom:m.sm,paddingTop:m.sm}},Week:{style:{fontSize:q.sm}},Day:{style:({$pseudoHighlighted:l,$pseudoSelected:b,$selected:W,$isHovered:E})=>({fontSize:q.sm,lineHeight:Q.base,"::before":{backgroundColor:W||b||l||E?`${c.darkenedBgMix15} !important`:c.transparent},"::after":{borderColor:c.transparent},...Tt(a)&&E&&b&&!W?{color:c.secondaryBg}:{}})},PrevButton:{style:()=>({display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:c.transparent},":focus":{backgroundColor:c.transparent,outline:0}})},NextButton:{style:{display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:c.transparent},":focus":{backgroundColor:c.transparent,outline:0}}},Input:{props:{maskChar:null,endEnhancer:u&&T(Ot,{content:T(St,{source:u,allowHTML:!1}),placement:xt.TOP_RIGHT,error:!0,children:T(kt,{content:Pt,size:"lg"})}),overrides:{EndEnhancer:{style:{color:c.redTextColor,backgroundColor:c.transparent}},Root:{style:({$isFocused:l})=>{const b=Dt(c,l);return{borderLeftWidth:w.borderWidth,borderRightWidth:w.borderWidth,borderTopWidth:w.borderWidth,borderBottomWidth:w.borderWidth,paddingRight:m.twoXS,borderTopColor:b,borderRightColor:b,borderBottomColor:b,borderLeftColor:b,...u&&{backgroundColor:c.redBackgroundColor}}}},ClearIcon:{props:{overrides:{Svg:{style:{color:c.grayTextColor,padding:m.threeXS,height:w.clearIconSize,width:w.clearIconSize,":hover":{fill:c.bodyText}}}}}},InputContainer:{style:{backgroundColor:"transparent"}},Input:{style:{fontWeight:it.normal,paddingRight:m.sm,paddingLeft:m.md,paddingBottom:m.sm,paddingTop:m.sm,lineHeight:Q.inputWidget,"::placeholder":{color:c.fadedText60},...u&&{color:c.redTextColor}},props:{"data-testid":"stDateInputField"}}}}},QuickSelect:{props:{overrides:{ControlContainer:{style:{height:w.minElementHeight,borderLeftWidth:w.borderWidth,borderRightWidth:w.borderWidth,borderTopWidth:w.borderWidth,borderBottomWidth:w.borderWidth}}}}}},value:i,minDate:x,maxDate:S,range:t.isRange,clearable:dt})]})}function ie(e,t){const r=e.getStringArrayValue(t),n=r!==void 0?r:t.default||[];return H(n)}function ce(e){return H(e.default)??[]}function ue(e){return H(e.value)??[]}function de(e,t,r,n){const a=P(e.min,B).toDate(),o=st(e);let i=!0;const f=(r.value||[]).map(y=>G(y)),{errorType:g}=ot(f,a,o);g&&(i=!1),i&&t.setStringArrayValue(e,oe(r.value),{fromUi:r.fromUi},n)}function ot(e,t,r){const n=[];let a=null;return tt(e)?{errorType:null,newDates:[]}:(Array.isArray(e)?e.forEach(o=>{o&&(r&&o>r?a="End":o<t&&(a="Start"),n.push(o))}):e&&(r&&e>r?a="End":e<t&&(a="Start"),n.push(e)),{errorType:a,newDates:n})}function st(e){const t=e.max;return t&&t.length>0?P(t,B).toDate():void 0}function G(e){const t=new Date(e.getTime());return t.setHours(0,0,0,0),t}const De=h.memo(se);export{De as default};
|
|
1
|
+
import{r as h,l as $,aB as ht,L as gt,e as tt,o as mt,j as T,p as wt,ad as bt,ae as pt,ay as yt,ag as Dt,aA as Ot,P as xt,az as kt,q as St,m as Tt}from"./index.DBIoNOen.js";import{h as P}from"./moment.C7qA8nIE.js";import{u as Mt}from"./useBasicWidgetState.Bx27912z.js";import{e as Ct,u as Yt,D as Wt,a as Et}from"./useIntlLocale.DsOvysl7.js";import{E as Pt}from"./ErrorOutline.esm.DWBqsdHn.js";import"./FormClearHelper.CyGGPn10.js";import"./timepicker._TfRUaDL.js";import"./input.C-PwAMG6.js";import"./base-input.AJ4KxBTh.js";const et=6048e5,vt=864e5,X=Symbol.for("constructDateFrom");function O(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&X in e?e[X](t):e instanceof Date?new e.constructor(t):new Date(t)}function p(e,t){return O(t||e,e)}let Ft={};function I(){return Ft}function v(e,t){const r=I(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=p(e,t?.in),o=a.getDay(),i=(o<n?7:0)+o-n;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function F(e,t){return v(e,{...t,weekStartsOn:1})}function rt(e,t){const r=p(e,t?.in),n=r.getFullYear(),a=O(r,0);a.setFullYear(n+1,0,4),a.setHours(0,0,0,0);const o=F(a),i=O(r,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const f=F(i);return r.getTime()>=o.getTime()?n+1:r.getTime()>=f.getTime()?n:n-1}function V(e){const t=p(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function It(e,...t){const r=O.bind(null,t.find(n=>typeof n=="object"));return t.map(r)}function j(e,t){const r=p(e,t?.in);return r.setHours(0,0,0,0),r}function Bt(e,t,r){const[n,a]=It(r?.in,e,t),o=j(n),i=j(a),f=+o-V(o),g=+i-V(i);return Math.round((f-g)/vt)}function Ht(e,t){const r=rt(e,t),n=O(e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),F(n)}function qt(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Lt(e){return!(!qt(e)&&typeof e!="number"||isNaN(+p(e)))}function Nt(e,t){const r=p(e,t?.in);return r.setFullYear(r.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Rt(e,t){const r=p(e,t?.in);return Bt(r,Nt(r))+1}function _t(e,t){const r=p(e,t?.in),n=+F(r)-+Ht(r);return Math.round(n/et)+1}function nt(e,t){const r=p(e,t?.in),n=r.getFullYear(),a=I(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=O(t?.in||e,0);i.setFullYear(n+1,0,o),i.setHours(0,0,0,0);const f=v(i,t),g=O(t?.in||e,0);g.setFullYear(n,0,o),g.setHours(0,0,0,0);const y=v(g,t);return+r>=+f?n+1:+r>=+y?n:n-1}function Gt(e,t){const r=I(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=nt(e,t),o=O(t?.in||e,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),v(o,t)}function Qt(e,t){const r=p(e,t?.in),n=+v(r,t)-+Gt(r,t);return Math.round(n/et)+1}function s(e,t){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}const D={y(e,t){const r=e.getFullYear(),n=r>0?r:1-r;return s(t==="yy"?n%100:n,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):s(r+1,2)},d(e,t){return s(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return s(e.getHours()%12||12,t.length)},H(e,t){return s(e.getHours(),t.length)},m(e,t){return s(e.getMinutes(),t.length)},s(e,t){return s(e.getSeconds(),t.length)},S(e,t){const r=t.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return s(a,t.length)}},M={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},z={G:function(e,t,r){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return D.y(e,t)},Y:function(e,t,r,n){const a=nt(e,n),o=a>0?a:1-a;if(t==="YY"){const i=o%100;return s(i,2)}return t==="Yo"?r.ordinalNumber(o,{unit:"year"}):s(o,t.length)},R:function(e,t){const r=rt(e);return s(r,t.length)},u:function(e,t){const r=e.getFullYear();return s(r,t.length)},Q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return s(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return s(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){const n=e.getMonth();switch(t){case"M":case"MM":return D.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return s(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){const a=Qt(e,n);return t==="wo"?r.ordinalNumber(a,{unit:"week"}):s(a,t.length)},I:function(e,t,r){const n=_t(e);return t==="Io"?r.ordinalNumber(n,{unit:"week"}):s(n,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):D.d(e,t)},D:function(e,t,r){const n=Rt(e);return t==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):s(n,t.length)},E:function(e,t,r){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return s(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return s(o,t.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const n=e.getDay(),a=n===0?7:n;switch(t){case"i":return String(a);case"ii":return s(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const n=e.getHours();let a;switch(n===12?a=M.noon:n===0?a=M.midnight:a=n/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const n=e.getHours();let a;switch(n>=17?a=M.evening:n>=12?a=M.afternoon:n>=4?a=M.morning:a=M.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return D.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):D.H(e,t)},K:function(e,t,r){const n=e.getHours()%12;return t==="Ko"?r.ordinalNumber(n,{unit:"hour"}):s(n,t.length)},k:function(e,t,r){let n=e.getHours();return n===0&&(n=24),t==="ko"?r.ordinalNumber(n,{unit:"hour"}):s(n,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):D.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):D.s(e,t)},S:function(e,t){return D.S(e,t)},X:function(e,t,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return Z(n);case"XXXX":case"XX":return k(n);case"XXXXX":case"XXX":default:return k(n,":")}},x:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"x":return Z(n);case"xxxx":case"xx":return k(n);case"xxxxx":case"xxx":default:return k(n,":")}},O:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+U(n,":");case"OOOO":default:return"GMT"+k(n,":")}},z:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+U(n,":");case"zzzz":default:return"GMT"+k(n,":")}},t:function(e,t,r){const n=Math.trunc(+e/1e3);return s(n,t.length)},T:function(e,t,r){return s(+e,t.length)}};function U(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+t+s(o,2)}function Z(e,t){return e%60===0?(e>0?"-":"+")+s(Math.abs(e)/60,2):k(e,t)}function k(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=s(Math.trunc(n/60),2),o=s(n%60,2);return r+a+t+o}const J=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},at=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},At=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return J(e,t);let o;switch(n){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",J(n,t)).replace("{{time}}",at(a,t))},$t={p:at,P:At},Xt=/^D+$/,Vt=/^Y+$/,jt=["D","DD","YY","YYYY"];function zt(e){return Xt.test(e)}function Ut(e){return Vt.test(e)}function Zt(e,t,r){const n=Jt(e,t,r);if(console.warn(n),jt.includes(e))throw new RangeError(n)}function Jt(e,t,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Kt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,te=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ee=/^'([^]*?)'?$/,re=/''/g,ne=/[a-zA-Z]/;function K(e,t,r){const n=I(),a=r?.locale??n.locale??Ct,o=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,f=p(e,r?.in);if(!Lt(f))throw new RangeError("Invalid time value");let g=t.match(te).map(u=>{const d=u[0];if(d==="p"||d==="P"){const c=$t[d];return c(u,a.formatLong)}return u}).join("").match(Kt).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:ae(u)};if(z[d])return{isToken:!0,value:u};if(d.match(ne))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});a.localize.preprocessor&&(g=a.localize.preprocessor(f,g));const y={firstWeekContainsDate:o,weekStartsOn:i,locale:a};return g.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!r?.useAdditionalWeekYearTokens&&Ut(d)||!r?.useAdditionalDayOfYearTokens&&zt(d))&&Zt(d,t,String(e));const c=z[d[0]];return c(f,d,a.localize,y)}).join("")}function ae(e){const t=e.match(ee);return t?t[1].replace(re,"'"):e}const B="YYYY/MM/DD";function H(e){return e.map(t=>new Date(t))}function oe(e){return e?e.map(t=>P(t).format(B)):[]}function se({disabled:e,element:t,widgetMgr:r,fragmentId:n}){const a=$(),o=h.useContext(ht),[i,f]=Mt({getStateFromWidgetMgr:ie,getDefaultStateFromProto:ce,getCurrStateFromProto:ue,updateWidgetMgrState:de,element:t,widgetMgr:r,fragmentId:n}),[g,y]=h.useState(!1),[u,d]=h.useState(null),{colors:c,fontSizes:q,fontWeights:it,lineHeights:Q,spacing:m,sizes:w}=$(),{locale:ct}=h.useContext(gt),C=Yt(ct),x=h.useMemo(()=>P(t.min,B).toDate(),[t.min]),S=h.useMemo(()=>st(t),[t]),ut=h.useMemo(()=>{if(!t.isRange)return!1;const l=P().subtract(2,"years").toDate();return x<l},[t.isRange,x]),dt=t.default.length===0&&!e,L=h.useMemo(()=>t.format.replaceAll(/[a-zA-Z]/g,"9"),[t.format]),Y=h.useMemo(()=>t.format.replaceAll("Y","y").replaceAll("D","d"),[t.format]),N=h.useMemo(()=>K(x,Y,{locale:C}),[x,Y,C]),R=h.useMemo(()=>S?K(S,Y,{locale:C}):"",[S,Y,C]),A=h.useCallback(l=>{if(!l)return null;if(t.isRange){const b=l==="End"?`before ${R}`:`after ${N}`;return`**Error**: ${l} date set outside allowed range. Please select a date ${b}.`}return`**Error**: Date set outside allowed range. Please select a date between ${N} and ${R}.`},[t.isRange,R,N]),ft=h.useCallback(({date:l})=>{if(d(null),tt(l)){f({value:[],fromUi:!0}),y(!0);return}const b=Array.isArray(l)?l.filter(_=>!!_).map(_=>G(_)):G(l),{errorType:W,newDates:E}=ot(b,x,S);W&&d(A(W)),f({value:E,fromUi:!0}),y(!E)},[f,A,d,x,S]),lt=h.useCallback(()=>{if(!g)return;const l=H(t.default);f({value:l,fromUi:!0}),y(!l)},[g,t,f]);return mt("div",{className:"stDateInput","data-testid":"stDateInput",children:[T(pt,{label:t.label,disabled:e,labelVisibility:wt(t.labelVisibility?.value),children:t.help&&T(bt,{content:t.help,label:t.label})}),T(Et,{locale:C,density:Wt.high,formatString:Y,mask:t.isRange?`${L} – ${L}`:L,placeholder:t.isRange?`${t.format} – ${t.format}`:t.format,disabled:e,onChange:ft,onClose:lt,quickSelect:ut,overrides:{Popover:{props:{ignoreBoundary:o,placement:yt.bottomLeft,overrides:{Body:{style:{marginTop:m.px}}}}},CalendarContainer:{style:{fontSize:q.sm,paddingRight:m.sm,paddingLeft:m.sm,paddingBottom:m.sm,paddingTop:m.sm}},Week:{style:{fontSize:q.sm}},Day:{style:({$pseudoHighlighted:l,$pseudoSelected:b,$selected:W,$isHovered:E})=>({fontSize:q.sm,lineHeight:Q.base,"::before":{backgroundColor:W||b||l||E?`${c.darkenedBgMix15} !important`:c.transparent},"::after":{borderColor:c.transparent},...Tt(a)&&E&&b&&!W?{color:c.secondaryBg}:{}})},PrevButton:{style:()=>({display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:c.transparent},":focus":{backgroundColor:c.transparent,outline:0}})},NextButton:{style:{display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:c.transparent},":focus":{backgroundColor:c.transparent,outline:0}}},Input:{props:{maskChar:null,endEnhancer:u&&T(Ot,{content:T(St,{source:u,allowHTML:!1}),placement:xt.TOP_RIGHT,error:!0,children:T(kt,{content:Pt,size:"lg"})}),overrides:{EndEnhancer:{style:{color:c.redTextColor,backgroundColor:c.transparent}},Root:{style:({$isFocused:l})=>{const b=Dt(c,l);return{borderLeftWidth:w.borderWidth,borderRightWidth:w.borderWidth,borderTopWidth:w.borderWidth,borderBottomWidth:w.borderWidth,paddingRight:m.twoXS,borderTopColor:b,borderRightColor:b,borderBottomColor:b,borderLeftColor:b,...u&&{backgroundColor:c.redBackgroundColor}}}},ClearIcon:{props:{overrides:{Svg:{style:{color:c.grayTextColor,padding:m.threeXS,height:w.clearIconSize,width:w.clearIconSize,":hover":{fill:c.bodyText}}}}}},InputContainer:{style:{backgroundColor:"transparent"}},Input:{style:{fontWeight:it.normal,paddingRight:m.sm,paddingLeft:m.md,paddingBottom:m.sm,paddingTop:m.sm,lineHeight:Q.inputWidget,"::placeholder":{color:c.fadedText60},...u&&{color:c.redTextColor}},props:{"data-testid":"stDateInputField"}}}}},QuickSelect:{props:{overrides:{ControlContainer:{style:{height:w.minElementHeight,borderLeftWidth:w.borderWidth,borderRightWidth:w.borderWidth,borderTopWidth:w.borderWidth,borderBottomWidth:w.borderWidth}}}}}},value:i,minDate:x,maxDate:S,range:t.isRange,clearable:dt})]})}function ie(e,t){const r=e.getStringArrayValue(t),n=r!==void 0?r:t.default||[];return H(n)}function ce(e){return H(e.default)??[]}function ue(e){return H(e.value)??[]}function de(e,t,r,n){const a=P(e.min,B).toDate(),o=st(e);let i=!0;const f=(r.value||[]).map(y=>G(y)),{errorType:g}=ot(f,a,o);g&&(i=!1),i&&t.setStringArrayValue(e,oe(r.value),{fromUi:r.fromUi},n)}function ot(e,t,r){const n=[];let a=null;return tt(e)?{errorType:null,newDates:[]}:(Array.isArray(e)?e.forEach(o=>{o&&(r&&o>r?a="End":o<t&&(a="Start"),n.push(o))}):e&&(r&&e>r?a="End":e<t&&(a="Start"),n.push(e)),{errorType:a,newDates:n})}function st(e){const t=e.max;return t&&t.length>0?P(t,B).toDate():void 0}function G(e){const t=new Date(e.getTime());return t.setHours(0,0,0,0),t}const De=h.memo(se);export{De as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as c,a3 as l,r as i,j as a,
|
|
1
|
+
import{z as c,a3 as l,r as i,j as a,bb as p}from"./index.DBIoNOen.js";import{P as d,R as f}from"./Particles.BIpBmEwi.js";const g=""+new URL("../media/flake-0.DgWaVvm5.png",import.meta.url).href,u=""+new URL("../media/flake-1.B2r5AHMK.png",import.meta.url).href,E=""+new URL("../media/flake-2.BnWSExPC.png",import.meta.url).href,o=150,s=150,S=10,w=90,x=4e3,e=(t,n=0)=>Math.random()*(t-n)+n,_=()=>l(`from{transform:translateY(0)
|
|
2
2
|
rotateX(`,e(360),`deg)
|
|
3
3
|
rotateY(`,e(360),`deg)
|
|
4
4
|
rotateZ(`,e(360),"deg);}to{transform:translateY(calc(100vh + ",o,`px))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as
|
|
1
|
+
import{r as l,E as S,_ as z,b7 as o,m as D,b8 as j,z as c,b9 as H,aC as v,l as P,k as G,o as f,j as a,p as q,q as x,P as F,az as U,ba as X,ac as Y}from"./index.DBIoNOen.js";import{e as J,S as K,a as Q,b as Z}from"./embed.BjO7Ez0y.js";import{W as ee}from"./WidgetLabelHelpIconInline.if89y2mu.js";import{i as L,f as re}from"./formatNumber.CCeQsvJQ.js";import"./threshold.CUNQbqMA.js";import"./value.DaKxGC7O.js";import"./timer.BZio6gjG.js";import"./numbro.B9_PXfzp.js";import"./sprintfjs.BlFBKfMf.js";var A=l.forwardRef(function(e,r){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(S,z({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),l.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),l.createElement("path",{d:"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"}))});A.displayName="ArrowDownward";var h=l.forwardRef(function(e,r){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return l.createElement(S,z({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),l.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),l.createElement("path",{d:"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"}))});h.displayName="ArrowUpward";function k(e,r){switch(r){case o.MetricColor.RED:return e.colors.redColor;case o.MetricColor.GREEN:return e.colors.greenColor;case o.MetricColor.ORANGE:return e.colors.orangeColor;case o.MetricColor.YELLOW:return e.colors.yellowColor;case o.MetricColor.BLUE:return e.colors.blueColor;case o.MetricColor.VIOLET:return e.colors.violetColor;case o.MetricColor.PRIMARY:return e.colors.primary;default:return e.colors.grayColor}}function V(e,r){const t=D(e);switch(r){case o.MetricColor.RED:return e.colors.redBackgroundColor;case o.MetricColor.GREEN:return e.colors.greenBackgroundColor;case o.MetricColor.ORANGE:return e.colors.orangeBackgroundColor;case o.MetricColor.YELLOW:return e.colors.yellowBackgroundColor;case o.MetricColor.BLUE:return e.colors.blueBackgroundColor;case o.MetricColor.VIOLET:return e.colors.violetBackgroundColor;case o.MetricColor.PRIMARY:return j(e.colors.primary,t?.9:.7);default:return e.colors.grayBackgroundColor}}function oe(e,r){switch(r){case o.MetricColor.RED:return e.colors.redTextColor;case o.MetricColor.GREEN:return e.colors.greenTextColor;case o.MetricColor.ORANGE:return e.colors.orangeTextColor;case o.MetricColor.YELLOW:return e.colors.yellowTextColor;case o.MetricColor.BLUE:return e.colors.blueTextColor;case o.MetricColor.VIOLET:return e.colors.violetTextColor;case o.MetricColor.PRIMARY:return e.colors.primary;default:return e.colors.grayTextColor}}const te=c("div",{target:"e132k71j0"})(({theme:e,showBorder:r})=>({height:"100%",...r&&{border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,borderRadius:e.radii.default,overflow:"hidden"}})),ie=c("div",{target:"e132k71j1"})(({theme:e,showBorder:r})=>({...r&&{padding:`calc(${e.spacing.lg} - ${e.sizes.borderWidth})`}})),ae=c("div",{target:"e132k71j2"})(({theme:e,showBorder:r})=>({marginTop:r?void 0:e.spacing.lg,marginBottom:r?e.spacing.twoXL:void 0})),b=c("div",{target:"e132k71j3"})(({theme:e})=>({overflowWrap:"normal",textOverflow:"ellipsis",width:"100%",overflow:"hidden",whiteSpace:"nowrap",fontFamily:e.genericFonts.bodyFont,lineHeight:"normal",verticalAlign:"middle","& > div":{overflow:"hidden","& > p":{textOverflow:"ellipsis",overflow:"hidden"}}})),le=c(H,{target:"e132k71j4"})(({visibility:e})=>({marginBottom:0,display:e===v.Collapsed?"none":"grid",gridTemplateColumns:e===v.Collapsed?"initial":"auto 1fr",visibility:e===v.Hidden?"hidden":"visible"})),ne=c("div",{target:"e132k71j5"})(({theme:e})=>({fontSize:e.fontSizes.threeXL,color:e.colors.bodyText,paddingBottom:e.spacing.twoXS})),se=c("div",{target:"e132k71j6"})(({theme:e,metricColor:r,showArrow:t})=>({color:oe(e,r),backgroundColor:V(e,r),fontSize:e.fontSizes.sm,display:"inline-flex",flexDirection:"row",alignItems:"center",fontWeight:e.fontWeights.normal,borderRadius:e.radii.full,maxWidth:"100%",padding:`${e.spacing.threeXS} ${e.spacing.xs} ${e.spacing.threeXS} ${e.spacing.xs}`,...t&&{paddingLeft:e.spacing.twoXS}})),ce=1e3;function R(e,r){try{return re(Number(e),r)}catch{return e}}function de(e,r,t,i,p){const n=`metric_chart_${Math.random().toString(36).slice(2,10)}`,m=e.length===1?[e[0],e[0]]:e,s={$schema:"https://vega.github.io/schema/vega-lite/v5.json",width:Math.round(t),height:Math.round(Y("3.5rem")),data:{values:m.map((M,g)=>({x:g,y:M}))},layer:[{name:`${n}_mark`,mark:{type:"line",...r===o.ChartType.LINE&&{type:"line",strokeCap:"round",strokeWidth:i.sizes.metricStrokeWidth},...r===o.ChartType.BAR&&{type:"bar",cornerRadius:parseFloat(i.radii.full)},...r===o.ChartType.AREA&&{type:"area",color:V(i,p),opacity:1,line:{color:k(i,p),opacity:1,strokeWidth:i.sizes.metricStrokeWidth,strokeCap:"round"}}},encoding:{x:{field:"x",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}},y:{field:"y",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}}}},{name:`${n}_points`,mark:{type:"point",opacity:0},encoding:{x:{field:"x",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}},y:{field:"y",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}}},params:[{name:`${n}_hover_selection`,select:{type:"point",encodings:["x"],nearest:!0,on:e.length>ce?"mousemove{16}":"mousemove",clear:"mouseleave"}}]},{name:`${n}_highlighted_points`,transform:[{filter:{param:`${n}_hover_selection`,empty:!1}}],mark:{type:"point",filled:!0,size:65,tooltip:!0},encoding:{x:{field:"x",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}},y:{field:"y",type:"quantitative",axis:null,scale:{zero:!1,nice:!1}}}}],config:{view:{stroke:null},padding:{left:-3,right:-3,top:2,bottom:2},...r===o.ChartType.BAR&&{padding:{left:0,right:0,top:2,bottom:2}},mark:{tooltip:{content:"encoding"},color:k(i,p)}}};return s.config=Q(s.config,i),s}function ue({element:e}){const r=P(),t=l.useRef(null),{width:i,elementRef:p}=G(),{MetricDirection:C}=o,{body:n,label:m,delta:s,direction:M,color:g,labelVisibility:B,help:E,showBorder:w,chartData:d,chartType:T,format:y}=e,N=y&&L(n)?R(n,y):n,I=y&&s&&L(s)?R(s,y):s;let u=null;switch(M){case C.DOWN:u=A;break;case C.UP:u=h;break;case C.NONE:break}const W="0 threeXS 0 0",$=s!=="";return l.useEffect(()=>{if(d&&d.length>0&&t.current&&i>0){const O=de(d,T,i,r,g);J(t.current,O,{actions:!1,renderer:"svg",ast:!0,expr:Z,tooltip:{theme:"custom",formatTooltip:_=>`${_.y}`}})}},[d,g,r,i,T,t]),f(te,{className:"stMetric","data-testid":"stMetric",showBorder:w,children:[f(ie,{showBorder:w,children:[f(le,{"data-testid":"stMetricLabel",visibility:q(B?.value),children:[a(b,{children:a(x,{source:m,allowHTML:!1,isLabel:!0})}),E&&a(ee,{content:E,placement:F.TOP_RIGHT,label:m})]}),a(ne,{"data-testid":"stMetricValue",children:a(b,{children:a(x,{source:N,allowHTML:!1,isLabel:!0,inheritFont:!0})})}),$&&f(se,{"data-testid":"stMetricDelta",metricColor:g,showArrow:u!==null,children:[u&&a(U,{testid:u===h?"stMetricDeltaIcon-Up":"stMetricDeltaIcon-Down",content:u,size:"md",margin:W}),a(b,{children:a(x,{source:I,allowHTML:!1,isLabel:!0,inheritFont:!0})})]})]}),d&&d.length>0&&f("div",{ref:p,children:[a(X,{styles:[K]}),a(ae,{ref:t,"data-testid":"stMetricChart",showBorder:w})]})]})}const xe=l.memo(ue);export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,E as Q,_ as K,
|
|
1
|
+
import{r as i,E as Q,_ as K,bw as z,bx as k,l as Y,e as j,Q as Z,O as q,by as M,bz as _,bA as ee,bB as te,n as H,bC as J,V as G,W as ne,k as re,a6 as se,bD as oe,j as x,o as ae,ba as ie}from"./index.DBIoNOen.js";import{w as ce,E as le}from"./withFullScreenWrapper.DP61hzLF.js";import{a as P,S as U,T as ue}from"./Toolbar.mUe2Nmta.js";import{R as fe}from"./index.Bjrvlqx5.js";import{a as W,c as de,b as me,e as pe,t as he,S as ge,d as ye}from"./embed.BjO7Ez0y.js";import{u as Se}from"./FormClearHelper.CyGGPn10.js";import{T as be}from"./TableChart.esm.BuemQLVW.js";import"./moment.C7qA8nIE.js";import"./pandasStylerUtils.BqWaUzvh.js";import"./numbro.B9_PXfzp.js";import"./_baseIndexOf.BTknn6Gb.js";import"./index.8HslT92O.js";import"./main.fMmyxXOf.js";import"./throttle.DlZC3xNA.js";import"./toConsumableArray.CZW4AmuW.js";import"./formatNumber.CCeQsvJQ.js";import"./sprintfjs.BlFBKfMf.js";import"./formatMoment.C6Hwn6X5.js";import"./checkbox.GY4JoJkM.js";import"./createDownloadLinkElement.BWJh90jh.js";import"./FileDownload.esm.D5koxJhf.js";import"./_arrayIncludes.B19Iyn2B.js";import"./threshold.CUNQbqMA.js";import"./value.DaKxGC7O.js";import"./timer.BZio6gjG.js";var $=i.forwardRef(function(t,e){var s={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return i.createElement(Q,K({iconAttrs:s,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:e}),i.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),i.createElement("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7 10h2v7H7zm4-3h2v10h-2zm4 6h2v4h-2z"}))});$.displayName="InsertChart";function F(t,e){if(we(t,e),Array.isArray(t.layer))for(const s of t.layer)s&&typeof s=="object"&&F(s,e);for(const s of["vconcat","hconcat","concat"])if(Array.isArray(t[s]))for(const r of t[s])r&&typeof r=="object"&&F(r,e);("facet"in t||"repeat"in t)&&t.spec&&typeof t.spec=="object"&&F(t.spec,e)}function we(t,e){const s=t.encoding;if(!s)return;const r=s.color;if(!r)return;"value"in r&&z(r.value)&&(r.value=k(r.value,e));const c=r.scale;c&&Array.isArray(c.range)&&(c.range=c.range.map(o=>z(o)?k(o,e):o))}const Ce=20;function Ee(t){"params"in t&&"encoding"in t&&t.params.forEach(e=>{"select"in e&&(["interval","point"].includes(e.select)&&(e.select={type:e.select}),"type"in e.select&&e.select.type==="point"&&!("encodings"in e.select)&&j(e.select.encodings)&&(e.select.encodings=Object.keys(t.encoding)))})}const ve=(t,e,s,r,c,o,f,m)=>{const n=JSON.parse(t);if(typeof n.height=="number"&&n.height<=0&&delete n.height,typeof n.width=="number"&&n.width<=0&&delete n.width,r==="streamlit"?n.config=W(n.config,o):n.usermeta?.embedOptions?.theme==="streamlit"?(n.config=W(n.config,o),n.usermeta.embedOptions.theme=void 0):n.config=de(n.config,o),n.title&&(typeof n.title=="string"&&(n.title={text:n.title}),n.title.limit=n.title.limit??Math.max(f-40,0)),s&&m&&m>0&&(n.height=m),e&&f&&f>0&&(n.width=f,"vconcat"in n&&n.vconcat.forEach(a=>{a===null||typeof a!="object"||"hconcat"in a||"vconcat"in a||"concat"in a||"layer"in a||(a.width=f)})),n.padding||(n.padding={}),j(n.padding.bottom)&&(n.padding.bottom=Ce),n.datasets)throw new Error("Datasets should not be passed as part of the spec");return c.length>0&&Ee(n),F(n,o),n},Ne=(t,e,s,r,c)=>{const o=Y(),{id:f,formId:m,spec:n,data:a,datasets:l,vegaLiteTheme:d,selectionMode:u}=t,h=i.useMemo(()=>u,[JSON.stringify(u)]),y=i.useMemo(()=>ve(n,r,c,d,h,o,e,s),[n,r,c,d,h,o,e,s]);return{id:f,formId:m,vegaLiteTheme:d,spec:y,selectionMode:h,data:a,datasets:l,useContainerWidth:r}},Ae={DATAFRAME_INDEX:"(index)"};function De(t){return!t||t.dimensions.numDataRows===0?null:I(t)}function Ve(t){const e=L(t);if(j(e))return null;const s={};for(const[r,c]of Object.entries(e))s[r]=I(c);return s}function L(t){if(t?.length===0)return null;const e={};return t.forEach(s=>{if(!s)return;const r=s.hasName?s.name:null;e[r]=s.data}),e}function I(t,e=0){if(t.dimensions.numDataRows===0)return[];const s=[],{numDataRows:r,numDataColumns:c,numIndexColumns:o}=t.dimensions,f=t.columnTypes[0]??void 0,m=f?.type===Z.INDEX&&(q(f)||M(f)||_(f));for(let n=e;n<r;n++){const a={};if(m){const{content:l}=t.getCell(n,0);a[Ae.DATAFRAME_INDEX]=typeof l=="bigint"?Number(l):l}for(let l=0;l<c;l++){const d=l+o,{content:u,contentType:h}=t.getCell(n,d);if((u instanceof Date||typeof u=="number"&&Number.isFinite(u))&&(M(h)||_(h))&&!ee(h)){const y=new Date(u).getTimezoneOffset()*60*1e3;a[t.columnNames[0][d]]=u.valueOf()+y}else a[t.columnNames[0][d]]=typeof u=="bigint"?Number(u):u}s.push(a)}return s}const Oe=150,Te=G.getLogger("useVegaLiteSelections"),Re=(t,e,s)=>{const{id:r,formId:c,selectionMode:o}=t,f=i.useCallback(n=>{o.forEach(l=>{n.addSignalListener(l,te(Oe,(d,u)=>{const h=n.getState({data:(v,T)=>o.some(g=>`${g}_store`===v),recurse:!1});H(h)&&e.setElementState(r,"viewState",h);let y=u;"vlPoint"in u&&"or"in u.vlPoint&&(y=u.vlPoint.or);const A={id:r,formId:c},E=JSON.parse(e.getStringValue(A)||"{}"),N={selection:{...E?.selection||{},[d]:y||{}}};J(E,N)||e.setStringValue(A,JSON.stringify(N),{fromUi:!0},s)}))});const a=e.getElementState(r,"viewState");if(H(a))try{return n.setState(a)}catch(l){Te.warn("Failed to restore view state",l)}return n},[r,o,e,c,s]),m=i.useCallback(()=>{const n={selection:{}};o.forEach(u=>{n.selection[u]={}});const a={id:r,formId:c},l=e.getStringValue(a),d=l?JSON.parse(l):n;J(d,n)||e.setStringValue(a,JSON.stringify(n),{fromUi:!0},s)},[r,c,s,o,e]);return{maybeConfigureSelections:f,onFormCleared:m}},B="source",xe=G.getLogger("useVegaEmbed");function Fe(t,e,s){const r=i.useRef(null),c=i.useRef(null),o=i.useRef(B),f=i.useRef(null),m=i.useRef([]),n=i.useRef(null),a=i.useRef([]),[l,d]=i.useState(!1),{maybeConfigureSelections:u,onFormCleared:h}=Re(t,e,s);Se({widgetMgr:e,element:t,onFormCleared:h});const{data:y,datasets:A}=t;i.useEffect(()=>{n.current=y,a.current=A,r.current===null&&(f.current=y,m.current=A)},[y,A]);const E=i.useCallback(()=>{c.current&&c.current(),c.current=null,r.current=null},[]),N=i.useCallback(async(g,b)=>{if(g.current===null)throw new Error("Element missing.");d(!0);try{E();const w={ast:!0,expr:me,tooltip:{disableDefaultStyle:!0},defaultStyle:!1,forceActionsMenu:!0},{vgSpec:S,view:R,finalize:V}=await pe(g.current,b,w);r.current=u(R),c.current=V;const p=Ve(a.current),C=p?Object.keys(p):[];if(C.length===1){const[O]=C;o.current=O}else C.length===0&&S.data&&(o.current=B);const D=De(n.current);if(D&&r.current.insert(o.current,D),p)for(const[O,X]of Object.entries(p))r.current.insert(O,X);return await r.current.runAsync(),await r.current.resize().runAsync(),f.current=n.current,m.current=a.current,r.current}finally{d(!1)}},[E,u]),v=i.useCallback((g,b,w,S)=>{if(!S||S.dimensions.numDataRows===0){try{g.remove(b,he)}catch{}return}if(!w||w.dimensions.numDataRows===0){g.insert(b,I(S));return}S.hash!==w.hash&&(g.data(b,I(S)),xe.info(`Had to clear the ${b} dataset before inserting data through Vega view.`))},[]),T=i.useCallback(async(g,b)=>{if(r.current===null||l)return null;const w=f.current,S=m.current;(w||g)&&v(r.current,o.current,w,g);const R=L(S)??{},V=L(b)??{};for(const[p,C]of Object.entries(V)){const D=p||o.current,O=R[D];v(r.current,D,O,C)}for(const p of Object.keys(R))!Object.hasOwn(V,p)&&p!==o.current&&v(r.current,p,null,null);return await r.current?.resize().runAsync(),f.current=g,m.current=b,r.current},[v,l]);return{createView:N,updateView:T,finalizeView:E}}function Ie(t){try{const e=typeof t=="string"?JSON.parse(t):t;return!!(e.facet||e.encoding?.row||e.encoding?.column||e.encoding?.facet)}catch{return!1}}function Le(t){try{const e=typeof t=="string"?JSON.parse(t):t;return!("vconcat"in e)||!Array.isArray(e.vconcat)?!1:e.vconcat.some(s=>s!==null&&typeof s=="object"&&("hconcat"in s||"vconcat"in s||"concat"in s||"layer"in s))}catch{return!1}}const je=({disableFullscreenMode:t,element:e,fragmentId:s,widgetMgr:r,widthConfig:c,heightConfig:o})=>{const[f,m]=i.useState(!1),[n,a]=i.useState(!1),{expanded:l,height:d,width:u,expand:h,collapse:y}=ne(le),{width:A,height:E,elementRef:N}=re([f]),v=se(c)||e.useContainerWidth,T=oe(o),g=Ie(e.spec),b=Le(e.spec),w=Ne(e,g?u??0:A,(l?d:E)??0,l&&!b?!0:v,l?!0:T),{createView:S,updateView:R,finalizeView:V}=Fe(w,r,s),{data:p,datasets:C,spec:D}=w;if(i.useLayoutEffect(()=>(N.current!==null&&S(N,D),V),[S,V,D,u,d,f,N]),i.useEffect(()=>{R(p,C)},[p,C]),i.useEffect(()=>{p||C?.[0]?.data?a(!0):a(!1)},[p,C]),f){const O=d??(E>0?E:void 0);return x(fe,{data:p??C[0]?.data,height:O,width:c??void 0,customToolbarActions:[x(P,{label:"Show chart",icon:$,onClick:()=>{m(!1)}},"show-chart")]})}return ae(U,{height:T?l?d:"100%":d,useContainerWidth:l?!0:v,children:[x(ue,{target:U,isFullScreen:l,onExpand:h,onCollapse:y,disableFullscreenMode:t,children:n&&x(P,{label:"Show data",icon:be,onClick:()=>{m(!0)}})}),x(ie,{styles:[ge]}),x(ye,{"data-testid":"stVegaLiteChart",className:"stVegaLiteChart",useContainerWidth:v,useContainerHeight:T,ref:N})]})},ze=ce(je),ct=i.memo(ze);export{ge as StyledVegaLiteChartTooltips,W as applyStreamlitTheme,ct as default};
|