@funhub/platform 0.1.79 → 0.1.81
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import r from"../../../../assets/icons/right_arrow.mjs";import i from"../../../../assets/images/marquee.mjs";import a from"./marquee.module.mjs";import{defaultMarqueePeriod as o}from"./schema.mjs";import{useEffect as s,useMemo as c,useRef as l,useState as u}from"react";import{X as d}from"lucide-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{useTranslations as m}from"next-intl";import{useRouter as h}from"next/navigation";const g=[];function _(e
|
|
2
|
+
"use client";import{Image as e}from"../../../ui/image.mjs";import{Box as t}from"../../../ui/box.mjs";import{Text as n}from"../../../ui/text.mjs";import r from"../../../../assets/icons/right_arrow.mjs";import i from"../../../../assets/images/marquee.mjs";import a from"./marquee.module.mjs";import{defaultMarqueePeriod as o}from"./schema.mjs";import{useEffect as s,useMemo as c,useRef as l,useState as u}from"react";import{X as d}from"lucide-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{useTranslations as m}from"next-intl";import{useRouter as h}from"next/navigation";const g=[];function _(e,t=20){let n=Array.from(e);return n.length<=t?e:`${n.slice(0,t).join(``)}...`}function v(e){let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t^(e.codePointAt(n)??0);return(t>>>0).toString(36)}function y(e,t){return e?t===`once`?!0:new Date(e).toLocaleDateString()===new Date().toLocaleDateString():!1}function b(e){let t=localStorage.getItem(e);if(!t)return{};try{return JSON.parse(t)}catch{let e=Number(t);return Number.isNaN(e)?{}:{closedAt:e}}}function x(e,t){localStorage.setItem(e,JSON.stringify(t))}function S(e,t){return t===`once`?y(e.closedAt,t)||y(e.displayedAt,t):!!e.closedAt}function C(C){let w=m(`components.biz.business.marquee`),{contents:T=g,click:E,close:D,displayStrategy:O,mode:k=`renderer`}=C,A=k===`editor`,j=h(),[M,N]=u(!0),[P,F]=u(!1),[I,L]=u(0),R=l(null);s(()=>{F(!0)},[]);let z=c(()=>{let e=O?.period??o,t=e.start,n=e.end;if(!t&&!n)return!0;let r=Date.now(),i=t?new Date(t).getTime():0,a=n?new Date(n).getTime():2**53-1;return r>=i&&r<=a},[O?.period]),B=c(()=>(T??[]).map(e=>({...e,text:_(String(e?.text??``))})).filter(e=>!!e.text),[T]),V=c(()=>{let e=O?.period??o;return`marquee_state_${v(JSON.stringify({rule:O?.rule??``,start:e.start??``,end:e.end??``,clickEnabled:E?.enabled??!1,clickLink:E?.link??``,items:B.map(e=>({text:e.text??``,link:e.link??``}))}))}`},[E?.enabled,E?.link,O?.period,O?.rule,B]);if(s(()=>{N(!0)},[V]),s(()=>()=>{R.current!=null&&(window.clearTimeout(R.current),R.current=null)},[]),s(()=>{L(0)},[B.length]),s(()=>{if(!(!P||A||!O?.rule||B.length===0)){if(S(b(V),O.rule)){N(!1);return}N(!0)}},[O?.rule,A,P,B.length,V]),s(()=>{if(R.current!=null&&(window.clearTimeout(R.current),R.current=null),!(!P||A||!O?.rule||!M||!z||B.length===0))return()=>{R.current!=null&&(window.clearTimeout(R.current),R.current=null)}},[O?.rule,A,P,z,M,B.length,V]),!A&&(!P||!M||!z)||B.length===0)return null;let H=B[I%B.length],U=E?.enabled===!0,W=E?.link||H.link,G=U&&!!W,K=D?.enabled===!0;function q(){!O?.rule||B.length===0||x(V,{...b(V),closedAt:Date.now()})}let J=e=>{e.stopPropagation(),N(!1),q()},Y=()=>{A||G&&W&&(N(!1),q(),j.push(W))},X=()=>{if(!(A||!M)){if(O?.rule===`once`){let e=b(V);if(y(e.displayedAt,`once`)||e.closedAt)return;x(V,{...e,displayedAt:Date.now()}),N(!1);return}B.length<=1||L(e=>(e+1)%B.length)}},Z=A?a[`marquee-item-paused`]:O?.rule===`once`||B.length>1?a[`marquee-item-once`]:a[`marquee-item-loop`];return f(t,{className:A?`px-3 py-2 w-full bg-bg1 pointer-events-none`:`px-3 py-2 w-full bg-bg1`,children:p(t,{className:`pl-[2px] pr-[12px] py-[2px] flex items-center w-full cursor-pointer relative rounded-[8px] overflow-hidden ${a[`marquee-shell`]}`,onClick:Y,children:[f(t,{className:`relative shrink-0 w-[36px] h-[36px] mr-[4px]`,children:f(e,{src:typeof i==`string`?i:i.src,alt:w(`noticeAlt`),fill:!0,className:`object-cover`,unoptimized:!0})}),f(t,{className:`flex-1 overflow-hidden relative h-[22px] ml-1`,children:f(t,{className:`absolute inset-y-0 left-0 flex items-center whitespace-nowrap ${Z}`,onAnimationEnd:X,children:f(n,{className:`inline-block text-[14px] text-[#f59e0b] leading-[22px] font-medium`,children:H.text})},`marquee-item-${I}`)}),p(t,{className:`flex items-center gap-[12px] shrink-0 ml-[4px]`,children:[G&&f(r,{className:`w-[16px] h-[16px] text-[#f59e0b]`}),K&&f(t,{className:`opacity-30 hover:opacity-100 transition-opacity`,onClick:J,children:f(d,{className:`w-[12px] h-[12px] text-[#F59E0B]`})})]})]})})}export{C as MarqueeClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Box as e}from"../../../ui/box.mjs";import{Text as t}from"../../../ui/text.mjs";import n from"../../../../assets/icons/refresh.mjs";import{useMemo as r,useState as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{usePathname as s,useRouter as c,useSearchParams as l}from"next/navigation";const u=[];function d(
|
|
2
|
+
"use client";import{Box as e}from"../../../ui/box.mjs";import{Text as t}from"../../../ui/text.mjs";import n from"../../../../assets/icons/refresh.mjs";import{useMemo as r,useState as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{usePathname as s,useRouter as c,useSearchParams as l}from"next/navigation";const u=[];function d(e,t){if(e.length<=t)return[...e];let n=[...e];for(let e=0;e<t;e++){let t=e+Math.floor(Math.random()*(n.length-e));[n[e],n[t]]=[n[t],n[e]]}return n.slice(0,t)}function f(f){let{title:p,items:m=u,onItemClick:h,mode:g=`renderer`}=f,_=g===`editor`,v=c(),y=s(),b=l(),[x,S]=i(0),C=r(()=>d(m,6),[m,x]);if(m.length===0)return null;let w=e=>{e.stopPropagation(),S(e=>e+1)},T=e=>{if(h){h(e);return}let t=new URLSearchParams(b.toString());t.set(`q`,e);let n=y.includes(`/search-result`)?y:`/search-result`;v.push(`${n}?${t.toString()}`)};return o(e,{className:`bg-bg1 p-3 flex flex-col gap-3 w-full${_?` pointer-events-none`:``}`,children:[o(e,{className:`flex items-center justify-between w-full`,children:[a(t,{className:`text-[18px] font-bold text-text1 leading-[26px]`,children:p}),o(e,{className:`flex items-center gap-1 cursor-pointer active:opacity-70 transition-opacity`,onClick:w,children:[a(t,{className:`text-[14px] text-text3 leading-[22px]`,children:`换一批`}),a(n,{className:`w-3 h-3 text-text3`})]})]}),a(e,{className:`grid grid-cols-2 gap-x-1 gap-y-1 w-full`,children:C.map((n,r)=>a(e,{className:`flex items-center h-[32px] cursor-pointer active:opacity-70 transition-opacity overflow-hidden`,onClick:()=>T(n.label),children:a(t,{className:`text-[14px] text-text1 leading-[22px] truncate w-full`,children:n.label})},`${x}-${r}`))})]})}export{f as TextRecommendClient};
|
|
@@ -6,7 +6,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
6
6
|
//#region components/ui/badge.d.ts
|
|
7
7
|
/** badgeVariants 工具定义。 */
|
|
8
8
|
declare const badgeVariants: (props?: ({
|
|
9
|
-
variant?: "default" | "
|
|
9
|
+
variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
|
|
10
10
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
11
|
/** Badge 组件。 */
|
|
12
12
|
declare function Badge({
|
|
@@ -7,8 +7,8 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
7
7
|
//#region components/ui/button.d.ts
|
|
8
8
|
/** buttonVariants 工具定义。 */
|
|
9
9
|
declare const buttonVariants: (props?: ({
|
|
10
|
-
variant?: "default" | "
|
|
11
|
-
size?: "default" | "
|
|
10
|
+
variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
|
|
11
|
+
size?: "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
12
12
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
13
13
|
/** Button 组件属性。 */
|
|
14
14
|
type ButtonProps = Button.Props & VariantProps<typeof buttonVariants> & {
|