Files
ambersplace.net/cohost-archive/static/preact-components-pages-search.ac004064c527357a1664.js

2 lines
12 KiB
JavaScript

"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[379,9629],{2735:function(e,t,o){o.d(t,{Qj:function(){return S},zx:function(){return N}});var r=o(65443),l=o.n(r),n=o(94159),a=o(6285);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},c.apply(this,arguments)}const s=a.z.enum(["pill","roundrect","authn"]),i=a.z.enum(["cherry","strawberry","mango","not-black","red","green","accent","secondary","authn-primary","authn-other"]),u=(a.z.object({buttonStyle:s,color:i,className:a.z.string().optional()}),l()("bg-notWhite","hover:text-notWhite")),d=l()("font-atkinson","font-bold","rounded-full","border-2"),m=l()("body-2","rounded-lg"),g=l()("flex","h-12","items-center","justify-center","rounded-lg","px-6","text-lg"),b=l()("border-cherry","hover:bg-cherry","text-cherry","active:bg-cherry-600","active:border-cherry-600","disabled:text-cherry-300","disabled:border-cherry-300","focus:outline-cherry","focus:ring-cherry",u),f=l()("border-strawberry","hover:bg-strawberry","text-strawberry","active:bg-strawberry-600","active:border-strawberry-600","disabled:text-strawberry-300","disabled:border-strawberry-300","focus:outline-strawberry","focus:ring-strawberry",u),p=l()("border-red","hover:bg-red","text-red","active:bg-red-600","active:border-red-600","disabled:text-red-300","disabled:border-red-300","focus:outline-red",u),h=l()("border-green","hover:bg-green","text-green","active:bg-green-600","active:border-green-600","disabled:text-green-300","disabled:border-green-300","focus:outline-green",u),w=l()("border-mango","hover:bg-mango","text-mango","bg-notBlack","hover:text-notBlack"),y=l()("border-notBlack","hover:bg-notBlack","text-notBlack","focus:outline-notBlack","focus:ring-notBlack",u),x=l()("border-accent","text-accent","bg-foreground","hover:bg-accent","hover:text-text"),v=l()("bg-secondary","text-notWhite","dark:text-notBlack","hover:bg-secondary-600"),j=l()("bg-foreground","text-text","hover:bg-foreground-600","active:bg-foreground-700","disabled:bg-foreground-200"),k=l()("border-2","border-foreground","text-foreground","hover:bg-longan-200"),E=e=>l()("leading-none","align-middle","py-2","px-4","no-select",e.className,{[d]:"pill"===e.buttonStyle,[m]:"roundrect"===e.buttonStyle,[g]:"authn"===e.buttonStyle,[b]:"cherry"===e.color,[f]:"strawberry"===e.color,[w]:"mango"===e.color,[y]:"not-black"===e.color,[p]:"red"===e.color,[x]:"accent"===e.color,[h]:"green"===e.color,[v]:"secondary"===e.color,[j]:"authn-primary"===e.color,[k]:"authn-other"===e.color}),N=n.forwardRef((({buttonStyle:e,color:t,className:o,...r},l)=>{const a=E({buttonStyle:e,color:t,className:o,...r});return n.createElement("button",c({},r,{className:a,ref:l}),r.children)}));N.displayName="Button";const S=n.forwardRef((({buttonStyle:e,color:t,...o},r)=>{const l=E({buttonStyle:e,color:t,...o});return n.createElement("a",c({},o,{className:l,ref:r}),o.children)}));S.displayName="LinkButton"},81511:function(e,t,o){o.r(t),o.d(t,{FollowRequestsContext:function(){return r}});const r=(0,o(94159).createContext)({onAction:()=>{}})},17538:function(e,t,o){o.r(t),o.d(t,{SearchPage:function(){return d}});var r=o(12093),l=o(94159),n=o(90275),a=o(60824),c=o(59605),s=o(80752),i=o(21351),u=o(20616);const d=()=>l.createElement("main",{className:"w-full pt-16"},l.createElement("div",{className:"container mx-auto grid grid-cols-1 gap-16 lg:grid-cols-4"},l.createElement(u.w3,null),l.createElement("section",{className:"col-span-1 flex flex-col gap-12 lg:col-span-2"},l.createElement("div",{className:"rounded-lg bg-notWhite p-3 text-notBlack"},l.createElement(l.Suspense,null,l.createElement(m,null)))))),m=()=>{const[e,t]=(0,a.lr)(),[o,u]=(0,l.useState)((()=>e.get("q")??"")),[d,m]=(0,l.useState)((()=>o)),[,g]=(0,l.useTransition)(),b=(0,c.cI)(d,{}),f=(0,c.dm)(d),p=(0,l.useCallback)((e=>{const o=e.currentTarget.value;u(o),g((()=>{m(o),t({q:o},{replace:!0})}))}),[t]);return l.createElement(l.Fragment,null,l.createElement(n.ql,{title:`search: ${o}`}),l.createElement("div",{className:"flex flex-col gap-4"},l.createElement("h1",{className:"h2"},"search"),l.createElement("form",{method:"get",onSubmit:e=>e.preventDefault()},l.createElement("input",{type:"text",name:"q",placeholder:"search for pages and tags!",className:"w-full",value:o,onChange:p})),!d||d.length<3?l.createElement("p",{className:"h5"},"enter a query to see results!"):null,d&&d.length>=3?l.createElement(l.Fragment,null,l.createElement("div",{className:"mt-4"},l.createElement("h2",{className:"h5"},"pages"),l.createElement("div",{className:"flex w-full flex-col gap-4"},b.projects?.length?b.projects?.map((e=>l.createElement(s.t,{project:e,key:e.projectId}))):l.createElement("p",{className:"h6"},"No pages found!"))),l.createElement("hr",{className:"my-4"}),l.createElement("div",null,l.createElement("h2",{className:"h5"},"tags"),f.suggestions?.result.length?l.createElement("div",{className:"mt-4 flex flex-col gap-2"},f.suggestions?.result?.map((e=>l.createElement("div",{key:e.content,className:"flex flex-row justify-between gap-3"},l.createElement("a",{href:r.ZP.public.tags({tagSlug:e.content}).toString(),className:"underline before:content-['#']"},e.content),l.createElement(i.zS,{tagName:e.content}))))):l.createElement("p",{className:"h6"},"No tags found!"))):null))};t.default=d},64499:function(e,t,o){o.d(t,{e:function(){return b}});var r=o(71860),l=o(70769),n=o(6285);let a=function(e){return e[e.NotFollowing=0]="NotFollowing",e[e.FollowRequested=1]="FollowRequested",e[e.Following=2]="Following",e}({});n.z.nativeEnum(a);var c=o(94159),s=o(51028),i=o(8227),u=o(2735),d=o(12093),m=o(21281),g=o(91045);const b=e=>c.createElement(c.Suspense,null,c.createElement(f,e)),f=({project:e,onFollow:t,color:o})=>{const n=(0,i.Pc)(),b=r.S.useContext(),f=r.S.projects.followingState.useQuery({projectHandle:e.handle},{suspense:!0}),p=(0,m.Z3)().get("ssrUrl"),h=(0,c.useCallback)((o=>({onMutate:async()=>{await b.projects.followingState.cancel({projectHandle:e.handle});const t=b.projects.followingState.getData({projectHandle:e.handle});return b.projects.followingState.setData({projectHandle:e.handle},{readerToProject:o}),{previousState:t}},onError:(t,o,r)=>{b.projects.followingState.setData({projectHandle:e.handle},r?.previousState)},onSettled:async()=>{await b.projects.followingState.invalidate({projectHandle:e.handle})},onSuccess:e=>{t&&t(e.followingState)}})),[t,e.handle,b.projects.followingState]),w=r.S.relationships.createFollowRequest.useMutation({...h(e.privacy===l.WL.Private?a.FollowRequested:a.Following)}),y=r.S.relationships.unfollow.useMutation({...h(a.NotFollowing)}),x=r.S.relationships.declineOrCancelFollowRequest.useMutation({...h(a.NotFollowing)}),{t:v}=(0,s.$G)(),j=f.data?.readerToProject??null,[k,E]=(0,c.useState)(!1),N=(0,c.useCallback)((async()=>{if(!n.projectId)return;const t={fromProjectId:n.projectId,toProjectId:e.projectId};switch(j){case a.FollowRequested:await x.mutateAsync(t);break;case a.NotFollowing:await w.mutateAsync(t);break;case a.Following:E(!0);break;case null:return}}),[x,w,j,e.projectId,n.projectId]),S=(0,c.useCallback)((async()=>{if(!n.projectId)return;const t={fromProjectId:n.projectId,toProjectId:e.projectId};await y.mutateAsync(t),E(!1)}),[e.projectId,n.projectId,y]);let I="unknown";if(n.loggedIn)if(j===a.Following)I=v("client:page.unfollow-button","unfollow");else if(j===a.NotFollowing)I=e.privacy===l.WL.Private?v("client:page.follow-request-button","send follow request"):v("client:page.follow-button","follow");else{if(j!==a.FollowRequested)return null;I=v("client:page.cancel-follow-request-button","cancel follow request")}else I=v("common:login");return n.loggedIn?c.createElement(c.Fragment,null,c.createElement(g.w,{isOpen:k,title:v("client:unfollow-page.confirm-title","Unfollow this page?"),body:v("client:unfollow-page.confirm-body","Are you sure you want to unfollow this page?"),confirm:{label:v("common:unfollow","unfollow")},cancel:{label:v("common:cancel","cancel")},onConfirm:S,onCancel:()=>E(!1)}),c.createElement(u.zx,{buttonStyle:"pill",color:o,onClick:N},I)):c.createElement(u.Qj,{buttonStyle:"pill",color:o,href:d.ZP.public.login({originalUrl:p}).toString()},I)}},80752:function(e,t,o){o.d(t,{t:function(){return g}});var r=o(94159),l=o(83052),n=o(64499),a=o(71860),c=o(81511),s=o(51028),i=o(8227),u=o(2735);const d=({requester:e})=>{const{t:t}=(0,s.$G)(),o=(0,i.Pc)(),{onAction:l}=(0,r.useContext)(c.FollowRequestsContext),n=a.S.useContext(),d=t=>({onSettled:async()=>{l(e.projectId,t),await n.relationships.countFollowRequests.invalidate(),await n.posts.profilePosts.invalidate()}}),m=a.S.relationships.acceptFollowRequest.useMutation(d("accept")),g=(0,r.useCallback)((async()=>{o.projectId&&await m.mutateAsync({fromProjectId:e.projectId,toProjectId:o.projectId})}),[m,e.projectId,o.projectId]),b=a.S.relationships.declineOrCancelFollowRequest.useMutation(d("decline")),f=(0,r.useCallback)((async()=>{o.projectId&&await b.mutateAsync({fromProjectId:e.projectId,toProjectId:o.projectId})}),[b,e.projectId,o.projectId]);return r.createElement("div",{className:"flex flex-row justify-center gap-2"},r.createElement(u.zx,{buttonStyle:"pill",color:"green",onClick:g},t("server:relationships.accept-follow-request-button-text-short","accept")),r.createElement(u.zx,{buttonStyle:"pill",color:"red",onClick:f},t("server:relationships.decline-follow-request-button-text-short","decline")))};var m=o(51540);const g=({project:e,isFollowRequest:t=!1})=>r.createElement("div",{className:"flex flex-row items-center gap-1"},r.createElement(m.t,{project:e}),r.createElement("div",{className:"min-w-0 flex-shrink justify-center gap-0 lg:flex-row"},r.createElement("div",{className:"items-left flex flex-shrink flex-row gap-1 lg:flex-col"},r.createElement(l.H,{project:e})),r.createElement("p",null,e.dek)),r.createElement("div",{className:"flex-grow"}),t?r.createElement(d,{requester:e}):r.createElement(n.e,{project:e,color:"cherry"}))},21351:function(e,t,o){o.d(t,{zS:function(){return d}});var r=o(71860),l=o(94159),n=o(51028),a=o(8227),c=o(2735),s=o(98074),i=o(15867),u=o(95024);const d=({tagName:e,className:t})=>{const{loggedIn:o}=(0,a.Pc)(),s=r.S.useContext(),{data:i,isFetched:u}=r.S.bookmarks.tags.isBookmarked.useQuery({tagName:e},{enabled:o}),{t:d}=(0,n.$G)(),m=i?d("common:unbookmark-tag","unbookmark this tag"):d("common:bookmark-tag","bookmark this tag"),g=r.S.bookmarks.tags.create.useMutation({onSettled:()=>Promise.all([s.bookmarks.tags.isBookmarked.invalidate({tagName:e}),s.bookmarks.tags.list.invalidate()])}),b=r.S.bookmarks.tags.delete.useMutation({onSettled:()=>Promise.all([s.bookmarks.tags.isBookmarked.invalidate({tagName:e}),s.bookmarks.tags.list.invalidate()])}),f=(0,l.useCallback)((()=>{i?b.mutate({tagName:e}):g.mutate({tagName:e})}),[i,b,e,g]);return o?u?l.createElement(c.zx,{className:t,buttonStyle:"roundrect",color:"secondary",onClick:f},m):l.createElement(c.zx,{className:t,buttonStyle:"roundrect",color:"secondary",disabled:!0},d("common:loading")):null};t.ZP=({tagName:e,synonymsAndRelatedTags:t,modalSuggestionDialogRef:o})=>{const r=(0,s.rA)(),n=(0,a.Pc)(),c=(0,u.useFlag)(i.T.Enum["tag-relation-request-ui"]),m=t.filter((t=>"synonym"===t.relationship&&t.content.toLowerCase()!==e.toLowerCase()));return l.createElement("div",{"data-theme":r.current,className:"co-themed-box mb-12 items-center"},n.loggedIn?l.createElement(d,{tagName:e,className:"mb-4"}):null,l.createElement("h4",{className:"h4 flex-1 text-bgText"},"#",e),l.createElement("div",{className:"flex flex-row flex-wrap"},m.length>0?l.createElement("h6",{className:"h6 pr-3 text-bgText"},"also:"," ",m.map((e=>`#${e.content}`)).join(", ")):null,n.loggedIn&&c?l.createElement("button",{className:"h6 co-link-button-disabled underline",onClick:()=>o.current?.open()},"suggest tag synonym"):null))}}}]);
//# sourceMappingURL=preact-components-pages-search.ac004064c527357a1664.js.map