mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
1 line
3.3 KiB
JavaScript
1 line
3.3 KiB
JavaScript
(("undefined"!=typeof globalThis?globalThis:self).makoChunk_antd=("undefined"!=typeof globalThis?globalThis:self).makoChunk_antd||[]).push([["969fe4c3"],{f0cc8246:function(e,t,r){"use strict";var a=r("852bbaa9")._;r.d(t,"__esModule",{value:!0}),r.e(t,{ANT_DESIGN_NOT_SHOW_BANNER:function(){return S;},default:function(){return g;}});var l=r("777fffbe"),n=r("852bbaa9"),d=r("f19d2b93"),s=n._(r("5b220c3d")),i=r("92a444f6"),o=r("2190d124"),c=r("c5e2d900"),u=r("a9d1a279"),h=r("9c86e52a"),f=r("40d543ed"),m=l._(r("098b7512")),p=l._(r("91a66390")),b=l._(r("44bde013")),_=l._(r("714a8bde"));let y=s.default.lazy(()=>Promise.all([r.ensure("vendors_1"),r.ensure("7a33de8c")]).then(r.dr(a,r.bind(r,"7a33de8c")))),S="ANT_DESIGN_NOT_SHOW_BANNER";if("undefined"!=typeof window){let e=location.hash.slice(1);e.startsWith("components-")&&!document.querySelector(`#${e}`)&&(location.hash=`#${e.replace(/^components-/,"")}`);}let v=(e=[])=>e.map(e=>"dark"===e?u.theme.darkAlgorithm:"compact"===e?u.theme.compactAlgorithm:null).filter(Boolean);var g=()=>{let e=(0,h.useOutlet)(),{pathname:t}=(0,p.default)(),[r,a]=(0,h.useSearchParams)(),[{theme:l=[],direction:n,isMobile:S,bannerVisible:g=!1},k]=(0,m.default)({isMobile:!1,direction:"ltr",theme:[],bannerVisible:!1}),x=(0,s.useCallback)(e=>{k(t=>({...t,...e}));let t=r.toString(),l=r;Object.entries(e).forEach(([e,t])=>{if("direction"===e&&("rtl"===t?l.set("direction","rtl"):l.delete("direction")),"theme"===e){var r;l=(0,h.createSearchParams)({...l,theme:t.filter(e=>"light"!==e)}),null===(r=document.querySelector("html"))||void 0===r||r.setAttribute("data-prefers-color",t.includes("dark")?"dark":"light");}}),l.toString()!==t&&a(l);},[r,a]),T=()=>{x({isMobile:window.innerWidth<768});};(0,s.useEffect)(()=>{let e=r.getAll("theme");return k({theme:e,direction:"rtl"===r.get("direction")?"rtl":"ltr"}),document.documentElement.setAttribute("data-prefers-color",e.includes("dark")?"dark":"light"),T(),window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T);};},[]);let j=s.default.useMemo(()=>({direction:n,updateSiteConfig:x,theme:l,isMobile:S,bannerVisible:g}),[S,n,x,l,g]),N=s.default.useMemo(()=>({algorithm:v(l),token:{motion:!l.includes("motion-off")},cssVar:!0,hashed:!1}),[l]),[M]=s.default.useState(()=>(0,i.createCache)());(0,h.useServerInsertedHTML)(()=>{let e=(0,i.extractStyle)(M,{plain:!0,types:"style"});return(0,d.jsx)("style",{"data-type":"antd-cssinjs",dangerouslySetInnerHTML:{__html:e}});}),(0,h.useServerInsertedHTML)(()=>{let e=(0,i.extractStyle)(M,{plain:!0,types:["cssVar","token"]});return(0,d.jsx)("style",{"data-type":"antd-css-var","data-rc-order":"prepend","data-rc-priority":"-9999",dangerouslySetInnerHTML:{__html:e}});}),(0,h.useServerInsertedHTML)(()=>(0,d.jsx)("style",{"data-sandpack":"true",id:"sandpack",dangerouslySetInnerHTML:{__html:(0,c.getSandpackCssText)()}}));let L=t.startsWith("/~demos"),A=e;return L||(A=(0,d.jsxs)(u.App,{children:[e,(0,d.jsx)(s.Suspense,{children:(0,d.jsx)(y,{value:l,onChange:e=>x({theme:e})})})]})),(0,d.jsx)(f.DarkContext.Provider,{value:l.includes("dark"),children:(0,d.jsx)(i.StyleProvider,{cache:M,linters:[i.legacyNotSelectorLinter,i.parentSelectorLinter,i.NaNLinter],children:(0,d.jsx)(_.default.Provider,{value:j,children:(0,d.jsx)(b.default,{theme:N,children:(0,d.jsx)(o.HappyProvider,{disabled:!l.includes("happy-work"),children:A})})})})});};}}]); |