@nice2dev/social 0.1.0 → 1.0.2

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
- # Changelog
1
+ # @nice2dev/social — Changelog
2
+
3
+ ## [0.2.0] — 2026-03-25
4
+
5
+ ### Added (FAZA 7.6)
6
+
7
+ - **CommentThread** — threaded comments with replies, reactions, timestamps
8
+ - **RatingStars** — star rating with half-star support
9
+ - **ActivityFeed** — activity timeline with filters
10
+ - **TagCloud** — weighted tag cloud with click filtering
11
+ - **UserList** — user list with search, roles, status indicators
12
+ - **WikiEditor** — collaborative wiki with Markdown support
13
+ - **UserProfile** — profile card with avatar, stats, actions
14
+ - **FollowButton** — follow/unfollow with count
15
+ - 7 unit tests
16
+
17
+ ---
18
+
19
+ ## [0.1.0] — 2025-06-01
20
+
21
+ Initial beta scaffolding.
2
22
 
3
23
  All notable changes to **@nice2dev/social** will be documented in this file.
4
24
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),O=l.forwardRef(function(T,E){const{comments:m,currentUserId:n,onSubmit:o,onEdit:h,onDelete:p,onReact:r,readOnly:y=!1,maxDepth:S=4,reactions:C=["👍","❤️","😂","😮","😢"],placeholder:j="Write a comment…",className:b,style:k}=T,[x,s]=l.useState(""),[u,f]=l.useState(null),[t,i]=l.useState(""),[c,a]=l.useState(null),[g,M]=l.useState(""),L=new Map;for(const d of m){const I=d.parentId??"__root__";L.has(I)||L.set(I,[]),L.get(I).push(d)}const R=l.useCallback(()=>{!x.trim()||!o||(o(x.trim()),s(""))},[x,o]),P=l.useCallback(()=>{!t.trim()||!o||!u||(o(t.trim(),u),i(""),f(null))},[t,u,o]),w=l.useCallback(()=>{!c||!g.trim()||!h||(h(c,g.trim()),a(null),M(""))},[c,g,h]),$=(d,I)=>{const F=n&&d.authorId===n,_=L.get(d.id)??[];return e.jsxs("div",{className:"nice-comments__item",style:{marginLeft:I*24},children:[e.jsxs("div",{className:"nice-comments__header",children:[d.authorAvatarUrl&&e.jsx("img",{src:d.authorAvatarUrl,alt:"",className:"nice-comments__avatar"}),e.jsx("strong",{className:"nice-comments__author",children:d.authorName}),e.jsx("time",{className:"nice-comments__time",children:d.createdAt}),d.isEdited&&e.jsx("span",{className:"nice-comments__edited",children:"(edited)"})]}),c===d.id?e.jsxs("div",{className:"nice-comments__edit-form",children:[e.jsx("textarea",{value:g,onChange:N=>M(N.target.value)}),e.jsx("button",{onClick:w,children:"Save"}),e.jsx("button",{onClick:()=>a(null),children:"Cancel"})]}):e.jsx("p",{className:"nice-comments__content",children:d.isDeleted?e.jsx("em",{children:"Comment deleted"}):d.content}),!d.isDeleted&&d.reactions&&e.jsx("div",{className:"nice-comments__reactions",children:Object.entries(d.reactions).map(([N,v])=>e.jsxs("button",{className:"nice-comments__reaction",onClick:()=>r==null?void 0:r(d.id,N),children:[N," ",v]},N))}),!d.isDeleted&&!y&&e.jsxs("div",{className:"nice-comments__actions",children:[r&&C.map(N=>e.jsx("button",{onClick:()=>r(d.id,N),title:N,children:N},N)),I<S&&e.jsx("button",{onClick:()=>{f(d.id),i("")},children:"Reply"}),F&&h&&e.jsx("button",{onClick:()=>{a(d.id),M(d.content)},children:"Edit"}),F&&p&&e.jsx("button",{onClick:()=>p(d.id),children:"Delete"})]}),u===d.id&&e.jsxs("div",{className:"nice-comments__reply-form",children:[e.jsx("textarea",{value:t,onChange:N=>i(N.target.value),placeholder:"Write a reply…"}),e.jsx("button",{onClick:P,disabled:!t.trim(),children:"Send"}),e.jsx("button",{onClick:()=>f(null),children:"Cancel"})]}),_.map(N=>$(N,I+1))]},d.id)},D=L.get("__root__")??[];return e.jsxs("div",{ref:E,className:`nice-comments ${b??""}`,style:k,children:[!y&&e.jsxs("div",{className:"nice-comments__new",children:[e.jsx("textarea",{value:x,onChange:d=>s(d.target.value),placeholder:j}),e.jsx("button",{onClick:R,disabled:!x.trim(),children:"Post"})]}),D.length===0?e.jsx("p",{className:"nice-comments__empty",children:"No comments yet."}):D.map(d=>$(d,0))]})}),z="☆",B="★",K="♡",H="♥",q=l.forwardRef(function(T,E){const{value:m,max:n=5,mode:o="stars",aggregation:h,onChange:p,readOnly:r=!1,size:y="md",showValue:S=!1,label:C,emojiSet:j=["😢","😕","😐","🙂","😍"],className:b,style:k}=T,[x,s]=l.useState(null),u=x!==null?x+1:m??0,f=l.useCallback(c=>{r||!p||p(c+1)},[r,p]),t=()=>{const c=[];for(let a=0;a<n;a++){const g=a<u;let M;o==="emoji"?M=j[a]??j[j.length-1]:o==="hearts"?M=g?H:K:o==="thumbs"?M=g?"👍":"👎":M=g?B:z,c.push(e.jsx("span",{className:`nice-ratings__symbol ${g?"nice-ratings__symbol--active":""}`,onClick:()=>f(a),onMouseEnter:()=>!r&&s(a),onMouseLeave:()=>!r&&s(null),role:r?void 0:"button",tabIndex:r?void 0:0,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&f(a)},children:M},a))}return c},i=()=>e.jsxs("div",{className:"nice-ratings__numeric",children:[e.jsx("input",{type:"number",min:0,max:n,step:.5,value:m??0,onChange:c=>p==null?void 0:p(parseFloat(c.target.value)||0),readOnly:r,className:"nice-ratings__numeric-input"}),e.jsxs("span",{className:"nice-ratings__numeric-max",children:["/ ",n]})]});return e.jsxs("div",{ref:E,className:`nice-ratings nice-ratings--${y} nice-ratings--${o} ${r?"nice-ratings--readonly":""} ${b??""}`,style:k,children:[C&&e.jsx("span",{className:"nice-ratings__label",children:C}),e.jsxs("div",{className:"nice-ratings__body",children:[o==="numeric"?i():t(),S&&o!=="numeric"&&e.jsxs("span",{className:"nice-ratings__value",children:[u," / ",n]})]}),h&&e.jsxs("div",{className:"nice-ratings__aggregation",children:[e.jsx("span",{className:"nice-ratings__avg",children:h.average.toFixed(1)}),e.jsxs("span",{className:"nice-ratings__count",children:["(",h.count," ratings)"]}),h.distribution&&e.jsx("div",{className:"nice-ratings__distribution",children:Object.entries(h.distribution).sort(([c],[a])=>+a-+c).map(([c,a])=>e.jsxs("div",{className:"nice-ratings__distribution-row",children:[e.jsx("span",{children:c}),e.jsx("div",{className:"nice-ratings__bar",children:e.jsx("div",{className:"nice-ratings__bar-fill",style:{width:`${h.count?a/h.count*100:0}%`}})}),e.jsx("span",{children:a})]},c))})]})]})}),V=l.forwardRef(function(T,E){const{stats:m,userState:n,onLike:o,onShare:h,onBookmark:p,direction:r="horizontal",size:y="md",showCounts:S=!0,showLabels:C=!1,className:j,style:b}=T,k=l.useCallback(s=>s>=1e6?(s/1e6).toFixed(1)+"M":s>=1e3?(s/1e3).toFixed(1)+"K":s.toString(),[]),x=[{key:"like",icon:"♡",activeIcon:"♥",label:"Like",count:m.likes,isActive:(n==null?void 0:n.liked)??!1,onClick:o},{key:"share",icon:"↗",activeIcon:"↗",label:"Share",count:m.shares,isActive:(n==null?void 0:n.shared)??!1,onClick:h},{key:"bookmark",icon:"☆",activeIcon:"★",label:"Bookmark",count:m.bookmarks,isActive:(n==null?void 0:n.bookmarked)??!1,onClick:p}];return e.jsx("div",{ref:E,className:`nice-social-panel nice-social-panel--${r} nice-social-panel--${y} ${j??""}`,style:b,children:x.map(s=>e.jsxs("button",{className:`nice-social-panel__btn nice-social-panel__btn--${s.key} ${s.isActive?"nice-social-panel__btn--active":""}`,onClick:s.onClick,title:s.label,children:[e.jsx("span",{className:"nice-social-panel__icon",children:s.isActive?s.activeIcon:s.icon}),C&&e.jsx("span",{className:"nice-social-panel__label",children:s.label}),S&&e.jsx("span",{className:"nice-social-panel__count",children:k(s.count)})]},s.key))})}),Y=l.forwardRef(function(T,E){const{tags:m,onTagClick:n,minFontSize:o=12,maxFontSize:h=36,sortBy:p="weight",maxTags:r,selectedIds:y,className:S,style:C}=T,j=l.useMemo(()=>{let s=[...m];if(p==="weight")s.sort((u,f)=>f.weight-u.weight);else if(p==="alphabetical")s.sort((u,f)=>u.label.localeCompare(f.label));else for(let u=s.length-1;u>0;u--){const f=Math.floor(Math.random()*(u+1));[s[u],s[f]]=[s[f],s[u]]}return r&&s.length>r&&(s=s.slice(0,r)),s},[m,p,r]),{minW:b,maxW:k}=l.useMemo(()=>{if(j.length===0)return{minW:0,maxW:1};const s=j.map(u=>u.weight);return{minW:Math.min(...s),maxW:Math.max(...s)}},[j]),x=s=>{if(k===b)return(o+h)/2;const u=(s-b)/(k-b);return o+u*(h-o)};return e.jsx("div",{ref:E,className:`nice-tag-cloud ${S??""}`,style:C,children:j.length===0?e.jsx("p",{className:"nice-tag-cloud__empty",children:"No tags."}):j.map(s=>{const u=y==null?void 0:y.includes(s.id),f=x(s.weight);return e.jsx("span",{className:`nice-tag-cloud__tag ${u?"nice-tag-cloud__tag--selected":""}`,style:{fontSize:f,color:s.color,cursor:n?"pointer":void 0},onClick:()=>n==null?void 0:n(s),role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&n&&n(s)},title:`${s.label} (${s.weight})`,children:s.label},s.id)})})}),G={online:"#22c55e",away:"#eab308",busy:"#ef4444",offline:"#9ca3af"},J=l.forwardRef(function(T,E){const{users:m,onUserClick:n,onAction:o,actions:h=[],searchable:p=!1,statusFilter:r,showStatus:y=!0,layout:S="list",groupByRole:C=!1,className:j,style:b}=T,[k,x]=l.useState(""),s=l.useMemo(()=>{let t=m;if(r&&r.length>0&&(t=t.filter(i=>i.status&&r.includes(i.status))),k.trim()){const i=k.toLowerCase();t=t.filter(c=>{var a,g;return c.name.toLowerCase().includes(i)||((a=c.email)==null?void 0:a.toLowerCase().includes(i))||((g=c.role)==null?void 0:g.toLowerCase().includes(i))})}return t},[m,r,k]),u=l.useMemo(()=>{if(!C)return{"":s};const t={};for(const i of s){const c=i.role??"Other";t[c]||(t[c]=[]),t[c].push(i)}return t},[s,C]),f=t=>e.jsxs("div",{className:`nice-user-list__item nice-user-list__item--${S}`,onClick:()=>n==null?void 0:n(t),role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:i=>{i.key==="Enter"&&n&&n(t)},children:[e.jsxs("div",{className:"nice-user-list__avatar-wrap",children:[t.avatarUrl?e.jsx("img",{src:t.avatarUrl,alt:t.name,className:"nice-user-list__avatar"}):e.jsx("span",{className:"nice-user-list__avatar-placeholder",children:t.name.charAt(0).toUpperCase()}),y&&t.status&&e.jsx("span",{className:"nice-user-list__status-dot",style:{backgroundColor:G[t.status]},title:t.status})]}),e.jsxs("div",{className:"nice-user-list__info",children:[e.jsx("span",{className:"nice-user-list__name",children:t.name}),t.email&&e.jsx("span",{className:"nice-user-list__email",children:t.email}),t.role&&e.jsx("span",{className:"nice-user-list__role",children:t.role})]}),h.length>0&&e.jsx("div",{className:"nice-user-list__actions",children:h.map(i=>e.jsx("button",{className:"nice-user-list__action-btn",onClick:c=>{c.stopPropagation(),o==null||o(t,i)},children:i},i))})]},t.id);return e.jsxs("div",{ref:E,className:`nice-user-list nice-user-list--${S} ${j??""}`,style:b,children:[p&&e.jsx("input",{type:"text",value:k,onChange:t=>x(t.target.value),placeholder:"Search users…",className:"nice-user-list__search"}),s.length===0?e.jsx("p",{className:"nice-user-list__empty",children:"No users found."}):Object.entries(u).map(([t,i])=>e.jsxs("div",{className:"nice-user-list__group",children:[C&&t&&e.jsxs("h4",{className:"nice-user-list__group-title",children:[t," (",i.length,")"]}),i.map(f)]},t))]})}),Q=l.forwardRef(function(T,E){const{pages:m,selectedPageId:n,onSelectPage:o,onSavePage:h,onDeletePage:p,onCreatePage:r,editable:y=!1,searchable:S=!0,renderHtml:C=!1,sidebarWidth:j=260,className:b,style:k}=T,[x,s]=l.useState(""),[u,f]=l.useState(!1),[t,i]=l.useState(""),[c,a]=l.useState(""),[g,M]=l.useState(""),[L,R]=l.useState(!1),P=l.useMemo(()=>{if(m.some(v=>v.children&&v.children.length>0))return m.filter(v=>!v.parentId);const _=new Map;for(const v of m)_.set(v.id,{...v,children:[]});const N=[];for(const v of _.values())v.parentId&&_.has(v.parentId)?_.get(v.parentId).children.push(v):N.push(v);return N},[m]),w=l.useMemo(()=>m.find(_=>_.id===n),[m,n]),$=l.useMemo(()=>{if(!x.trim())return P;const _=x.toLowerCase(),N=new Set(m.filter(v=>v.title.toLowerCase().includes(_)).map(v=>v.id));return m.filter(v=>N.has(v.id))},[P,m,x]),D=l.useCallback(()=>{w&&(i(w.title),a(w.content??""),f(!0))},[w]),d=l.useCallback(()=>{!w||!h||(h(w.id,c,t),f(!1))},[w,c,t,h]),I=l.useCallback(()=>{!g.trim()||!r||(r(n??null,g.trim()),M(""),R(!1))},[g,n,r]),F=(_,N=0)=>{var v;return e.jsxs("div",{children:[e.jsx("div",{className:`nice-wiki__page-item ${_.id===n?"nice-wiki__page-item--active":""}`,style:{paddingLeft:12+N*16},onClick:()=>o==null?void 0:o(_),role:"button",tabIndex:0,onKeyDown:W=>{W.key==="Enter"&&(o==null||o(_))},children:_.title}),(v=_.children)==null?void 0:v.map(W=>F(W,N+1))]},_.id)};return e.jsxs("div",{ref:E,className:`nice-wiki ${b??""}`,style:{display:"flex",...k},children:[e.jsxs("div",{className:"nice-wiki__sidebar",style:{width:j,minWidth:j},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("strong",{children:"Wiki"}),y&&r&&e.jsx("button",{onClick:()=>R(!L),title:"New page",children:"+"})]}),L&&e.jsxs("div",{className:"nice-wiki__new-page",children:[e.jsx("input",{type:"text",value:g,onChange:_=>M(_.target.value),placeholder:"New page title"}),e.jsx("button",{onClick:I,disabled:!g.trim(),children:"Create"})]}),S&&e.jsx("input",{type:"text",className:"nice-wiki__search",value:x,onChange:_=>s(_.target.value),placeholder:"Search pages…"}),e.jsx("div",{className:"nice-wiki__tree",children:$.length===0?e.jsx("p",{className:"nice-wiki__empty",children:"No pages."}):$.map(_=>F(_))})]}),e.jsx("div",{className:"nice-wiki__content",children:w?u?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("input",{type:"text",className:"nice-wiki__edit-title",value:t,onChange:_=>i(_.target.value)}),e.jsx("textarea",{className:"nice-wiki__edit-body",value:c,onChange:_=>a(_.target.value),rows:20}),e.jsxs("div",{className:"nice-wiki__edit-actions",children:[e.jsx("button",{onClick:d,children:"Save"}),e.jsx("button",{onClick:()=>f(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"nice-wiki__viewer",children:[e.jsxs("div",{className:"nice-wiki__viewer-header",children:[e.jsx("h2",{children:w.title}),e.jsxs("div",{className:"nice-wiki__viewer-meta",children:[w.lastEditedBy&&e.jsxs("span",{children:["Edited by ",w.lastEditedBy]}),w.lastEditedAt&&e.jsxs("span",{children:[" on ",w.lastEditedAt]})]}),y&&e.jsxs("div",{className:"nice-wiki__viewer-actions",children:[e.jsx("button",{onClick:D,children:"Edit"}),p&&e.jsx("button",{onClick:()=>p(w.id),children:"Delete"})]})]}),C?e.jsx("div",{className:"nice-wiki__viewer-body",dangerouslySetInnerHTML:{__html:w.content??""}}):e.jsx("div",{className:"nice-wiki__viewer-body",children:w.content??e.jsx("em",{children:"No content."})})]}):e.jsx("div",{className:"nice-wiki__placeholder",children:"Select a page from the sidebar."})})]})}),U={comment:"💬",like:"❤️",share:"↗️",create:"✨",update:"✏️",delete:"🗑️",join:"👋",leave:"🚪",upload:"📎",mention:"@",custom:"📌"},X=l.forwardRef(function(T,E){const{events:m,onEventClick:n,groupByDate:o=!0,typeFilter:h,showFilters:p=!1,maxEvents:r,onLoadMore:y,hasMore:S=!1,className:C,style:j}=T,[b,k]=l.useState(new Set),x=h??(b.size>0?Array.from(b):void 0),s=l.useMemo(()=>{let i=m;if(x&&x.length>0){const c=new Set(x);i=i.filter(a=>c.has(a.type))}return r&&(i=i.slice(0,r)),i},[m,x,r]),u=l.useMemo(()=>{if(!o)return[{label:"",events:s}];const i=new Map;for(const c of s){const a=c.timestamp.slice(0,10);i.has(a)||i.set(a,[]),i.get(a).push(c)}return Array.from(i.entries()).map(([c,a])=>({label:c,events:a}))},[s,o]),f=l.useMemo(()=>{const i=new Set(m.map(c=>c.type));return Array.from(i).sort()},[m]),t=i=>{k(c=>{const a=new Set(c);return a.has(i)?a.delete(i):a.add(i),a})};return e.jsxs("div",{ref:E,className:`nice-activity-feed ${C??""}`,style:j,children:[p&&!h&&e.jsxs("div",{className:"nice-activity-feed__filters",children:[f.map(i=>e.jsxs("button",{className:`nice-activity-feed__filter-chip ${b.has(i)?"nice-activity-feed__filter-chip--active":""}`,onClick:()=>t(i),children:[U[i]," ",i]},i)),b.size>0&&e.jsx("button",{className:"nice-activity-feed__filter-clear",onClick:()=>k(new Set),children:"Clear"})]}),s.length===0?e.jsx("p",{className:"nice-activity-feed__empty",children:"No activity."}):u.map(({label:i,events:c})=>e.jsxs("div",{className:"nice-activity-feed__group",children:[o&&i&&e.jsx("div",{className:"nice-activity-feed__date-label",children:i}),c.map(a=>e.jsxs("div",{className:"nice-activity-feed__event",onClick:()=>n==null?void 0:n(a),role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:g=>{g.key==="Enter"&&n&&n(a)},children:[e.jsx("span",{className:"nice-activity-feed__icon",children:U[a.type]}),e.jsxs("div",{className:"nice-activity-feed__body",children:[a.actorAvatarUrl&&e.jsx("img",{src:a.actorAvatarUrl,alt:"",className:"nice-activity-feed__avatar"}),e.jsxs("span",{className:"nice-activity-feed__message",children:[e.jsx("strong",{children:a.actorName})," ",a.message,a.targetLabel&&e.jsxs(e.Fragment,{children:[" ",e.jsx("em",{children:a.targetLabel})]})]}),e.jsx("time",{className:"nice-activity-feed__time",children:a.timestamp})]})]},a.id))]},i||"__all")),S&&y&&e.jsx("button",{className:"nice-activity-feed__load-more",onClick:y,children:"Load more"})]})});exports.NiceActivityFeed=X;exports.NiceComments=O;exports.NiceRatings=q;exports.NiceSocialPanel=V;exports.NiceTagCloud=Y;exports.NiceUserList=J;exports.NiceWiki=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),O=l.forwardRef(function(x,E){const{comments:m,currentUserId:n,onSubmit:o,onEdit:h,onDelete:N,onReact:r,readOnly:b=!1,maxDepth:T=4,reactions:S=["👍","❤️","😂","😮","😢"],placeholder:g="Write a comment…",className:k,style:w}=x,[p,s]=l.useState(""),[u,v]=l.useState(null),[t,i]=l.useState(""),[c,a]=l.useState(null),[y,M]=l.useState(""),L=new Map;for(const d of m){const I=d.parentId??"__root__";L.has(I)||L.set(I,[]),L.get(I).push(d)}const R=l.useCallback(()=>{!p.trim()||!o||(o(p.trim()),s(""))},[p,o]),P=l.useCallback(()=>{!t.trim()||!o||!u||(o(t.trim(),u),i(""),v(null))},[t,u,o]),C=l.useCallback(()=>{!c||!y.trim()||!h||(h(c,y.trim()),a(null),M(""))},[c,y,h]),A=(d,I)=>{const F=n&&d.authorId===n,_=L.get(d.id)??[];return e.jsxs("div",{className:"nice-comments__item",style:{marginLeft:I*24},children:[e.jsxs("div",{className:"nice-comments__header",children:[d.authorAvatarUrl&&e.jsx("img",{src:d.authorAvatarUrl,alt:"",className:"nice-comments__avatar"}),e.jsx("strong",{className:"nice-comments__author",children:d.authorName}),e.jsx("time",{className:"nice-comments__time",children:d.createdAt}),d.isEdited&&e.jsx("span",{className:"nice-comments__edited",children:"(edited)"})]}),c===d.id?e.jsxs("div",{className:"nice-comments__edit-form",children:[e.jsx("textarea",{value:y,onChange:j=>M(j.target.value)}),e.jsx("button",{onClick:C,children:"Save"}),e.jsx("button",{onClick:()=>a(null),children:"Cancel"})]}):e.jsx("p",{className:"nice-comments__content",children:d.isDeleted?e.jsx("em",{children:"Comment deleted"}):d.content}),!d.isDeleted&&d.reactions&&e.jsx("div",{className:"nice-comments__reactions",children:Object.entries(d.reactions).map(([j,f])=>e.jsxs("button",{className:"nice-comments__reaction",onClick:()=>r==null?void 0:r(d.id,j),children:[j," ",f]},j))}),!d.isDeleted&&!b&&e.jsxs("div",{className:"nice-comments__actions",children:[r&&S.map(j=>e.jsx("button",{onClick:()=>r(d.id,j),title:j,children:j},j)),I<T&&e.jsx("button",{onClick:()=>{v(d.id),i("")},children:"Reply"}),F&&h&&e.jsx("button",{onClick:()=>{a(d.id),M(d.content)},children:"Edit"}),F&&N&&e.jsx("button",{onClick:()=>N(d.id),children:"Delete"})]}),u===d.id&&e.jsxs("div",{className:"nice-comments__reply-form",children:[e.jsx("textarea",{value:t,onChange:j=>i(j.target.value),placeholder:"Write a reply…"}),e.jsx("button",{onClick:P,disabled:!t.trim(),children:"Send"}),e.jsx("button",{onClick:()=>v(null),children:"Cancel"})]}),_.map(j=>A(j,I+1))]},d.id)},D=L.get("__root__")??[];return e.jsxs("div",{ref:E,className:`nice-comments ${k??""}`,style:w,children:[!b&&e.jsxs("div",{className:"nice-comments__new",children:[e.jsx("textarea",{value:p,onChange:d=>s(d.target.value),placeholder:g}),e.jsx("button",{onClick:R,disabled:!p.trim(),children:"Post"})]}),D.length===0?e.jsx("p",{className:"nice-comments__empty",children:"No comments yet."}):D.map(d=>A(d,0))]})}),z="☆",B="★",K="♡",H="♥",q=l.forwardRef(function(x,E){const{value:m,max:n=5,mode:o="stars",aggregation:h,onChange:N,readOnly:r=!1,size:b="md",showValue:T=!1,label:S,emojiSet:g=["😢","😕","😐","🙂","😍"],className:k,style:w}=x,[p,s]=l.useState(null),u=p!==null?p+1:m??0,v=l.useCallback(c=>{r||!N||N(c+1)},[r,N]),t=()=>{const c=[];for(let a=0;a<n;a++){const y=a<u;let M;o==="emoji"?M=g[a]??g[g.length-1]:o==="hearts"?M=y?H:K:o==="thumbs"?M=y?"👍":"👎":M=y?B:z,c.push(e.jsx("span",{className:`nice-ratings__symbol ${y?"nice-ratings__symbol--active":""}`,onClick:()=>v(a),onMouseEnter:()=>!r&&s(a),onMouseLeave:()=>!r&&s(null),role:r?void 0:"button",tabIndex:r?void 0:0,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&v(a)},children:M},a))}return c},i=()=>e.jsxs("div",{className:"nice-ratings__numeric",children:[e.jsx("input",{type:"number",min:0,max:n,step:.5,value:m??0,onChange:c=>N==null?void 0:N(parseFloat(c.target.value)||0),readOnly:r,className:"nice-ratings__numeric-input"}),e.jsxs("span",{className:"nice-ratings__numeric-max",children:["/ ",n]})]});return e.jsxs("div",{ref:E,className:`nice-ratings nice-ratings--${b} nice-ratings--${o} ${r?"nice-ratings--readonly":""} ${k??""}`,style:w,children:[S&&e.jsx("span",{className:"nice-ratings__label",children:S}),e.jsxs("div",{className:"nice-ratings__body",children:[o==="numeric"?i():t(),T&&o!=="numeric"&&e.jsxs("span",{className:"nice-ratings__value",children:[u," / ",n]})]}),h&&e.jsxs("div",{className:"nice-ratings__aggregation",children:[e.jsx("span",{className:"nice-ratings__avg",children:h.average.toFixed(1)}),e.jsxs("span",{className:"nice-ratings__count",children:["(",h.count," ratings)"]}),h.distribution&&e.jsx("div",{className:"nice-ratings__distribution",children:Object.entries(h.distribution).sort(([c],[a])=>+a-+c).map(([c,a])=>e.jsxs("div",{className:"nice-ratings__distribution-row",children:[e.jsx("span",{children:c}),e.jsx("div",{className:"nice-ratings__bar",children:e.jsx("div",{className:"nice-ratings__bar-fill",style:{width:`${h.count?a/h.count*100:0}%`}})}),e.jsx("span",{children:a})]},c))})]})]})}),V=l.forwardRef(function(x,E){const{stats:m,userState:n,onLike:o,onShare:h,onBookmark:N,direction:r="horizontal",size:b="md",showCounts:T=!0,showLabels:S=!1,className:g,style:k}=x,w=l.useCallback(s=>s>=1e6?(s/1e6).toFixed(1)+"M":s>=1e3?(s/1e3).toFixed(1)+"K":s.toString(),[]),p=[{key:"like",icon:"♡",activeIcon:"♥",label:"Like",count:m.likes,isActive:(n==null?void 0:n.liked)??!1,onClick:o},{key:"share",icon:"↗",activeIcon:"↗",label:"Share",count:m.shares,isActive:(n==null?void 0:n.shared)??!1,onClick:h},{key:"bookmark",icon:"☆",activeIcon:"★",label:"Bookmark",count:m.bookmarks,isActive:(n==null?void 0:n.bookmarked)??!1,onClick:N}];return e.jsx("div",{ref:E,className:`nice-social-panel nice-social-panel--${r} nice-social-panel--${b} ${g??""}`,style:k,children:p.map(s=>e.jsxs("button",{className:`nice-social-panel__btn nice-social-panel__btn--${s.key} ${s.isActive?"nice-social-panel__btn--active":""}`,onClick:s.onClick,title:s.label,children:[e.jsx("span",{className:"nice-social-panel__icon",children:s.isActive?s.activeIcon:s.icon}),S&&e.jsx("span",{className:"nice-social-panel__label",children:s.label}),T&&e.jsx("span",{className:"nice-social-panel__count",children:w(s.count)})]},s.key))})}),Y=l.forwardRef(function(x,E){const{tags:m,onTagClick:n,minFontSize:o=12,maxFontSize:h=36,sortBy:N="weight",maxTags:r,selectedIds:b,className:T,style:S}=x,g=l.useMemo(()=>{let s=[...m];if(N==="weight")s.sort((u,v)=>v.weight-u.weight);else if(N==="alphabetical")s.sort((u,v)=>u.label.localeCompare(v.label));else for(let u=s.length-1;u>0;u--){const v=Math.floor(Math.random()*(u+1));[s[u],s[v]]=[s[v],s[u]]}return r&&s.length>r&&(s=s.slice(0,r)),s},[m,N,r]),{minW:k,maxW:w}=l.useMemo(()=>{if(g.length===0)return{minW:0,maxW:1};const s=g.map(u=>u.weight);return{minW:Math.min(...s),maxW:Math.max(...s)}},[g]),p=s=>{if(w===k)return(o+h)/2;const u=(s-k)/(w-k);return o+u*(h-o)};return e.jsx("div",{ref:E,className:`nice-tag-cloud ${T??""}`,style:S,children:g.length===0?e.jsx("p",{className:"nice-tag-cloud__empty",children:"No tags."}):g.map(s=>{const u=b==null?void 0:b.includes(s.id),v=p(s.weight);return e.jsx("span",{className:`nice-tag-cloud__tag ${u?"nice-tag-cloud__tag--selected":""}`,style:{fontSize:v,color:s.color,cursor:n?"pointer":void 0},onClick:()=>n==null?void 0:n(s),role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&n&&n(s)},title:`${s.label} (${s.weight})`,children:s.label},s.id)})})}),G={online:"#22c55e",away:"#eab308",busy:"#ef4444",offline:"#9ca3af"},J=l.forwardRef(function(x,E){const{users:m,onUserClick:n,onAction:o,actions:h=[],searchable:N=!1,statusFilter:r,showStatus:b=!0,layout:T="list",groupByRole:S=!1,className:g,style:k}=x,[w,p]=l.useState(""),s=l.useMemo(()=>{let t=m;if(r&&r.length>0&&(t=t.filter(i=>i.status&&r.includes(i.status))),w.trim()){const i=w.toLowerCase();t=t.filter(c=>{var a,y;return c.name.toLowerCase().includes(i)||((a=c.email)==null?void 0:a.toLowerCase().includes(i))||((y=c.role)==null?void 0:y.toLowerCase().includes(i))})}return t},[m,r,w]),u=l.useMemo(()=>{if(!S)return{"":s};const t={};for(const i of s){const c=i.role??"Other";t[c]||(t[c]=[]),t[c].push(i)}return t},[s,S]),v=t=>e.jsxs("div",{className:`nice-user-list__item nice-user-list__item--${T}`,onClick:()=>n==null?void 0:n(t),role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:i=>{i.key==="Enter"&&n&&n(t)},children:[e.jsxs("div",{className:"nice-user-list__avatar-wrap",children:[t.avatarUrl?e.jsx("img",{src:t.avatarUrl,alt:t.name,className:"nice-user-list__avatar"}):e.jsx("span",{className:"nice-user-list__avatar-placeholder",children:t.name.charAt(0).toUpperCase()}),b&&t.status&&e.jsx("span",{className:"nice-user-list__status-dot",style:{backgroundColor:G[t.status]},title:t.status})]}),e.jsxs("div",{className:"nice-user-list__info",children:[e.jsx("span",{className:"nice-user-list__name",children:t.name}),t.email&&e.jsx("span",{className:"nice-user-list__email",children:t.email}),t.role&&e.jsx("span",{className:"nice-user-list__role",children:t.role})]}),h.length>0&&e.jsx("div",{className:"nice-user-list__actions",children:h.map(i=>e.jsx("button",{className:"nice-user-list__action-btn",onClick:c=>{c.stopPropagation(),o==null||o(t,i)},children:i},i))})]},t.id);return e.jsxs("div",{ref:E,className:`nice-user-list nice-user-list--${T} ${g??""}`,style:k,children:[N&&e.jsx("input",{type:"text",value:w,onChange:t=>p(t.target.value),placeholder:"Search users…",className:"nice-user-list__search"}),s.length===0?e.jsx("p",{className:"nice-user-list__empty",children:"No users found."}):Object.entries(u).map(([t,i])=>e.jsxs("div",{className:"nice-user-list__group",children:[S&&t&&e.jsxs("h4",{className:"nice-user-list__group-title",children:[t," (",i.length,")"]}),i.map(v)]},t))]})});function Q($){if(!$)return"";let x=$;return x=x.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,""),x=x.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),x=x.replace(/(href|src|action)\s*=\s*(?:"javascript:[^"]*"|'javascript:[^']*')/gi,'$1=""'),x=x.replace(/(href|src|action)\s*=\s*(?:"vbscript:[^"]*"|'vbscript:[^']*')/gi,'$1=""'),x=x.replace(/<\/?(iframe|object|embed|form)\b[^>]*>/gi,""),x}const X=l.forwardRef(function(x,E){const{pages:m,selectedPageId:n,onSelectPage:o,onSavePage:h,onDeletePage:N,onCreatePage:r,editable:b=!1,searchable:T=!0,renderHtml:S=!1,sidebarWidth:g=260,className:k,style:w}=x,[p,s]=l.useState(""),[u,v]=l.useState(!1),[t,i]=l.useState(""),[c,a]=l.useState(""),[y,M]=l.useState(""),[L,R]=l.useState(!1),P=l.useMemo(()=>{if(m.some(f=>f.children&&f.children.length>0))return m.filter(f=>!f.parentId);const _=new Map;for(const f of m)_.set(f.id,{...f,children:[]});const j=[];for(const f of _.values())f.parentId&&_.has(f.parentId)?_.get(f.parentId).children.push(f):j.push(f);return j},[m]),C=l.useMemo(()=>m.find(_=>_.id===n),[m,n]),A=l.useMemo(()=>{if(!p.trim())return P;const _=p.toLowerCase(),j=new Set(m.filter(f=>f.title.toLowerCase().includes(_)).map(f=>f.id));return m.filter(f=>j.has(f.id))},[P,m,p]),D=l.useCallback(()=>{C&&(i(C.title),a(C.content??""),v(!0))},[C]),d=l.useCallback(()=>{!C||!h||(h(C.id,c,t),v(!1))},[C,c,t,h]),I=l.useCallback(()=>{!y.trim()||!r||(r(n??null,y.trim()),M(""),R(!1))},[y,n,r]),F=(_,j=0)=>{var f;return e.jsxs("div",{children:[e.jsx("div",{className:`nice-wiki__page-item ${_.id===n?"nice-wiki__page-item--active":""}`,style:{paddingLeft:12+j*16},onClick:()=>o==null?void 0:o(_),role:"button",tabIndex:0,onKeyDown:W=>{W.key==="Enter"&&(o==null||o(_))},children:_.title}),(f=_.children)==null?void 0:f.map(W=>F(W,j+1))]},_.id)};return e.jsxs("div",{ref:E,className:`nice-wiki ${k??""}`,style:{display:"flex",...w},children:[e.jsxs("div",{className:"nice-wiki__sidebar",style:{width:g,minWidth:g},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("strong",{children:"Wiki"}),b&&r&&e.jsx("button",{onClick:()=>R(!L),title:"New page",children:"+"})]}),L&&e.jsxs("div",{className:"nice-wiki__new-page",children:[e.jsx("input",{type:"text",value:y,onChange:_=>M(_.target.value),placeholder:"New page title"}),e.jsx("button",{onClick:I,disabled:!y.trim(),children:"Create"})]}),T&&e.jsx("input",{type:"text",className:"nice-wiki__search",value:p,onChange:_=>s(_.target.value),placeholder:"Search pages…"}),e.jsx("div",{className:"nice-wiki__tree",children:A.length===0?e.jsx("p",{className:"nice-wiki__empty",children:"No pages."}):A.map(_=>F(_))})]}),e.jsx("div",{className:"nice-wiki__content",children:C?u?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("input",{type:"text",className:"nice-wiki__edit-title",value:t,onChange:_=>i(_.target.value)}),e.jsx("textarea",{className:"nice-wiki__edit-body",value:c,onChange:_=>a(_.target.value),rows:20}),e.jsxs("div",{className:"nice-wiki__edit-actions",children:[e.jsx("button",{onClick:d,children:"Save"}),e.jsx("button",{onClick:()=>v(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"nice-wiki__viewer",children:[e.jsxs("div",{className:"nice-wiki__viewer-header",children:[e.jsx("h2",{children:C.title}),e.jsxs("div",{className:"nice-wiki__viewer-meta",children:[C.lastEditedBy&&e.jsxs("span",{children:["Edited by ",C.lastEditedBy]}),C.lastEditedAt&&e.jsxs("span",{children:[" on ",C.lastEditedAt]})]}),b&&e.jsxs("div",{className:"nice-wiki__viewer-actions",children:[e.jsx("button",{onClick:D,children:"Edit"}),N&&e.jsx("button",{onClick:()=>N(C.id),children:"Delete"})]})]}),S?e.jsx("div",{className:"nice-wiki__viewer-body",dangerouslySetInnerHTML:{__html:Q(C.content??"")}}):e.jsx("div",{className:"nice-wiki__viewer-body",children:C.content??e.jsx("em",{children:"No content."})})]}):e.jsx("div",{className:"nice-wiki__placeholder",children:"Select a page from the sidebar."})})]})}),U={comment:"💬",like:"❤️",share:"↗️",create:"✨",update:"✏️",delete:"🗑️",join:"👋",leave:"🚪",upload:"📎",mention:"@",custom:"📌"},Z=l.forwardRef(function(x,E){const{events:m,onEventClick:n,groupByDate:o=!0,typeFilter:h,showFilters:N=!1,maxEvents:r,onLoadMore:b,hasMore:T=!1,className:S,style:g}=x,[k,w]=l.useState(new Set),p=h??(k.size>0?Array.from(k):void 0),s=l.useMemo(()=>{let i=m;if(p&&p.length>0){const c=new Set(p);i=i.filter(a=>c.has(a.type))}return r&&(i=i.slice(0,r)),i},[m,p,r]),u=l.useMemo(()=>{if(!o)return[{label:"",events:s}];const i=new Map;for(const c of s){const a=c.timestamp.slice(0,10);i.has(a)||i.set(a,[]),i.get(a).push(c)}return Array.from(i.entries()).map(([c,a])=>({label:c,events:a}))},[s,o]),v=l.useMemo(()=>{const i=new Set(m.map(c=>c.type));return Array.from(i).sort()},[m]),t=i=>{w(c=>{const a=new Set(c);return a.has(i)?a.delete(i):a.add(i),a})};return e.jsxs("div",{ref:E,className:`nice-activity-feed ${S??""}`,style:g,children:[N&&!h&&e.jsxs("div",{className:"nice-activity-feed__filters",children:[v.map(i=>e.jsxs("button",{className:`nice-activity-feed__filter-chip ${k.has(i)?"nice-activity-feed__filter-chip--active":""}`,onClick:()=>t(i),children:[U[i]," ",i]},i)),k.size>0&&e.jsx("button",{className:"nice-activity-feed__filter-clear",onClick:()=>w(new Set),children:"Clear"})]}),s.length===0?e.jsx("p",{className:"nice-activity-feed__empty",children:"No activity."}):u.map(({label:i,events:c})=>e.jsxs("div",{className:"nice-activity-feed__group",children:[o&&i&&e.jsx("div",{className:"nice-activity-feed__date-label",children:i}),c.map(a=>e.jsxs("div",{className:"nice-activity-feed__event",onClick:()=>n==null?void 0:n(a),role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:y=>{y.key==="Enter"&&n&&n(a)},children:[e.jsx("span",{className:"nice-activity-feed__icon",children:U[a.type]}),e.jsxs("div",{className:"nice-activity-feed__body",children:[a.actorAvatarUrl&&e.jsx("img",{src:a.actorAvatarUrl,alt:"",className:"nice-activity-feed__avatar"}),e.jsxs("span",{className:"nice-activity-feed__message",children:[e.jsx("strong",{children:a.actorName})," ",a.message,a.targetLabel&&e.jsxs(e.Fragment,{children:[" ",e.jsx("em",{children:a.targetLabel})]})]}),e.jsx("time",{className:"nice-activity-feed__time",children:a.timestamp})]})]},a.id))]},i||"__all")),T&&b&&e.jsx("button",{className:"nice-activity-feed__load-more",onClick:b,children:"Load more"})]})});exports.NiceActivityFeed=Z;exports.NiceComments=O;exports.NiceRatings=q;exports.NiceSocialPanel=V;exports.NiceTagCloud=Y;exports.NiceUserList=J;exports.NiceWiki=X;
package/dist/index.mjs CHANGED
@@ -1,33 +1,33 @@
1
1
  import { jsxs as c, jsx as e, Fragment as H } from "react/jsx-runtime";
2
- import { forwardRef as D, useState as T, useCallback as P, useMemo as F } from "react";
3
- const Z = D(function(I, L) {
2
+ import { forwardRef as R, useState as $, useCallback as D, useMemo as F } from "react";
3
+ const ee = R(function(p, I) {
4
4
  const {
5
5
  comments: m,
6
6
  currentUserId: a,
7
7
  onSubmit: o,
8
8
  onEdit: _,
9
- onDelete: N,
9
+ onDelete: g,
10
10
  onReact: r,
11
- readOnly: k = !1,
12
- maxDepth: E = 4,
13
- reactions: x = ["👍", "❤️", "😂", "😮", "😢"],
14
- placeholder: y = "Write a comment…",
15
- className: w,
16
- style: C
17
- } = I, [v, i] = T(""), [h, f] = T(null), [n, t] = T(""), [l, s] = T(null), [b, $] = T(""), A = /* @__PURE__ */ new Map();
11
+ readOnly: w = !1,
12
+ maxDepth: T = 4,
13
+ reactions: E = ["👍", "❤️", "😂", "😮", "😢"],
14
+ placeholder: b = "Write a comment…",
15
+ className: C,
16
+ style: S
17
+ } = p, [v, i] = $(""), [h, N] = $(null), [n, t] = $(""), [l, s] = $(null), [k, L] = $(""), A = /* @__PURE__ */ new Map();
18
18
  for (const d of m) {
19
- const M = d.parentId ?? "__root__";
20
- A.has(M) || A.set(M, []), A.get(M).push(d);
19
+ const P = d.parentId ?? "__root__";
20
+ A.has(P) || A.set(P, []), A.get(P).push(d);
21
21
  }
22
- const O = P(() => {
22
+ const j = D(() => {
23
23
  !v.trim() || !o || (o(v.trim()), i(""));
24
- }, [v, o]), z = P(() => {
25
- !n.trim() || !o || !h || (o(n.trim(), h), t(""), f(null));
26
- }, [n, h, o]), S = P(() => {
27
- !l || !b.trim() || !_ || (_(l, b.trim()), s(null), $(""));
28
- }, [l, b, _]), W = (d, M) => {
24
+ }, [v, o]), z = D(() => {
25
+ !n.trim() || !o || !h || (o(n.trim(), h), t(""), N(null));
26
+ }, [n, h, o]), x = D(() => {
27
+ !l || !k.trim() || !_ || (_(l, k.trim()), s(null), L(""));
28
+ }, [l, k, _]), W = (d, P) => {
29
29
  const U = a && d.authorId === a, u = A.get(d.id) ?? [];
30
- return /* @__PURE__ */ c("div", { className: "nice-comments__item", style: { marginLeft: M * 24 }, children: [
30
+ return /* @__PURE__ */ c("div", { className: "nice-comments__item", style: { marginLeft: P * 24 }, children: [
31
31
  /* @__PURE__ */ c("div", { className: "nice-comments__header", children: [
32
32
  d.authorAvatarUrl && /* @__PURE__ */ e("img", { src: d.authorAvatarUrl, alt: "", className: "nice-comments__avatar" }),
33
33
  /* @__PURE__ */ e("strong", { className: "nice-comments__author", children: d.authorName }),
@@ -35,97 +35,97 @@ const Z = D(function(I, L) {
35
35
  d.isEdited && /* @__PURE__ */ e("span", { className: "nice-comments__edited", children: "(edited)" })
36
36
  ] }),
37
37
  l === d.id ? /* @__PURE__ */ c("div", { className: "nice-comments__edit-form", children: [
38
- /* @__PURE__ */ e("textarea", { value: b, onChange: (g) => $(g.target.value) }),
39
- /* @__PURE__ */ e("button", { onClick: S, children: "Save" }),
38
+ /* @__PURE__ */ e("textarea", { value: k, onChange: (y) => L(y.target.value) }),
39
+ /* @__PURE__ */ e("button", { onClick: x, children: "Save" }),
40
40
  /* @__PURE__ */ e("button", { onClick: () => s(null), children: "Cancel" })
41
41
  ] }) : /* @__PURE__ */ e("p", { className: "nice-comments__content", children: d.isDeleted ? /* @__PURE__ */ e("em", { children: "Comment deleted" }) : d.content }),
42
- !d.isDeleted && d.reactions && /* @__PURE__ */ e("div", { className: "nice-comments__reactions", children: Object.entries(d.reactions).map(([g, p]) => /* @__PURE__ */ c(
42
+ !d.isDeleted && d.reactions && /* @__PURE__ */ e("div", { className: "nice-comments__reactions", children: Object.entries(d.reactions).map(([y, f]) => /* @__PURE__ */ c(
43
43
  "button",
44
44
  {
45
45
  className: "nice-comments__reaction",
46
- onClick: () => r == null ? void 0 : r(d.id, g),
46
+ onClick: () => r == null ? void 0 : r(d.id, y),
47
47
  children: [
48
- g,
48
+ y,
49
49
  " ",
50
- p
50
+ f
51
51
  ]
52
52
  },
53
- g
53
+ y
54
54
  )) }),
55
- !d.isDeleted && !k && /* @__PURE__ */ c("div", { className: "nice-comments__actions", children: [
56
- r && x.map((g) => /* @__PURE__ */ e("button", { onClick: () => r(d.id, g), title: g, children: g }, g)),
57
- M < E && /* @__PURE__ */ e("button", { onClick: () => {
58
- f(d.id), t("");
55
+ !d.isDeleted && !w && /* @__PURE__ */ c("div", { className: "nice-comments__actions", children: [
56
+ r && E.map((y) => /* @__PURE__ */ e("button", { onClick: () => r(d.id, y), title: y, children: y }, y)),
57
+ P < T && /* @__PURE__ */ e("button", { onClick: () => {
58
+ N(d.id), t("");
59
59
  }, children: "Reply" }),
60
60
  U && _ && /* @__PURE__ */ e("button", { onClick: () => {
61
- s(d.id), $(d.content);
61
+ s(d.id), L(d.content);
62
62
  }, children: "Edit" }),
63
- U && N && /* @__PURE__ */ e("button", { onClick: () => N(d.id), children: "Delete" })
63
+ U && g && /* @__PURE__ */ e("button", { onClick: () => g(d.id), children: "Delete" })
64
64
  ] }),
65
65
  h === d.id && /* @__PURE__ */ c("div", { className: "nice-comments__reply-form", children: [
66
66
  /* @__PURE__ */ e(
67
67
  "textarea",
68
68
  {
69
69
  value: n,
70
- onChange: (g) => t(g.target.value),
70
+ onChange: (y) => t(y.target.value),
71
71
  placeholder: "Write a reply…"
72
72
  }
73
73
  ),
74
74
  /* @__PURE__ */ e("button", { onClick: z, disabled: !n.trim(), children: "Send" }),
75
- /* @__PURE__ */ e("button", { onClick: () => f(null), children: "Cancel" })
75
+ /* @__PURE__ */ e("button", { onClick: () => N(null), children: "Cancel" })
76
76
  ] }),
77
- u.map((g) => W(g, M + 1))
77
+ u.map((y) => W(y, P + 1))
78
78
  ] }, d.id);
79
- }, j = A.get("__root__") ?? [];
80
- return /* @__PURE__ */ c("div", { ref: L, className: `nice-comments ${w ?? ""}`, style: C, children: [
81
- !k && /* @__PURE__ */ c("div", { className: "nice-comments__new", children: [
79
+ }, O = A.get("__root__") ?? [];
80
+ return /* @__PURE__ */ c("div", { ref: I, className: `nice-comments ${C ?? ""}`, style: S, children: [
81
+ !w && /* @__PURE__ */ c("div", { className: "nice-comments__new", children: [
82
82
  /* @__PURE__ */ e(
83
83
  "textarea",
84
84
  {
85
85
  value: v,
86
86
  onChange: (d) => i(d.target.value),
87
- placeholder: y
87
+ placeholder: b
88
88
  }
89
89
  ),
90
- /* @__PURE__ */ e("button", { onClick: O, disabled: !v.trim(), children: "Post" })
90
+ /* @__PURE__ */ e("button", { onClick: j, disabled: !v.trim(), children: "Post" })
91
91
  ] }),
92
- j.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-comments__empty", children: "No comments yet." }) : j.map((d) => W(d, 0))
92
+ O.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-comments__empty", children: "No comments yet." }) : O.map((d) => W(d, 0))
93
93
  ] });
94
- }), V = "☆", Y = "★", q = "♡", G = "♥", ee = D(function(I, L) {
94
+ }), V = "☆", Y = "★", q = "♡", G = "♥", ie = R(function(p, I) {
95
95
  const {
96
96
  value: m,
97
97
  max: a = 5,
98
98
  mode: o = "stars",
99
99
  aggregation: _,
100
- onChange: N,
100
+ onChange: g,
101
101
  readOnly: r = !1,
102
- size: k = "md",
103
- showValue: E = !1,
104
- label: x,
105
- emojiSet: y = ["😢", "😕", "😐", "🙂", "😍"],
106
- className: w,
107
- style: C
108
- } = I, [v, i] = T(null), h = v !== null ? v + 1 : m ?? 0, f = P((l) => {
109
- r || !N || N(l + 1);
110
- }, [r, N]), n = () => {
102
+ size: w = "md",
103
+ showValue: T = !1,
104
+ label: E,
105
+ emojiSet: b = ["😢", "😕", "😐", "🙂", "😍"],
106
+ className: C,
107
+ style: S
108
+ } = p, [v, i] = $(null), h = v !== null ? v + 1 : m ?? 0, N = D((l) => {
109
+ r || !g || g(l + 1);
110
+ }, [r, g]), n = () => {
111
111
  const l = [];
112
112
  for (let s = 0; s < a; s++) {
113
- const b = s < h;
114
- let $;
115
- o === "emoji" ? $ = y[s] ?? y[y.length - 1] : o === "hearts" ? $ = b ? G : q : o === "thumbs" ? $ = b ? "👍" : "👎" : $ = b ? Y : V, l.push(
113
+ const k = s < h;
114
+ let L;
115
+ o === "emoji" ? L = b[s] ?? b[b.length - 1] : o === "hearts" ? L = k ? G : q : o === "thumbs" ? L = k ? "👍" : "👎" : L = k ? Y : V, l.push(
116
116
  /* @__PURE__ */ e(
117
117
  "span",
118
118
  {
119
- className: `nice-ratings__symbol ${b ? "nice-ratings__symbol--active" : ""}`,
120
- onClick: () => f(s),
119
+ className: `nice-ratings__symbol ${k ? "nice-ratings__symbol--active" : ""}`,
120
+ onClick: () => N(s),
121
121
  onMouseEnter: () => !r && i(s),
122
122
  onMouseLeave: () => !r && i(null),
123
123
  role: r ? void 0 : "button",
124
124
  tabIndex: r ? void 0 : 0,
125
125
  onKeyDown: (A) => {
126
- (A.key === "Enter" || A.key === " ") && f(s);
126
+ (A.key === "Enter" || A.key === " ") && N(s);
127
127
  },
128
- children: $
128
+ children: L
129
129
  },
130
130
  s
131
131
  )
@@ -141,7 +141,7 @@ const Z = D(function(I, L) {
141
141
  max: a,
142
142
  step: 0.5,
143
143
  value: m ?? 0,
144
- onChange: (l) => N == null ? void 0 : N(parseFloat(l.target.value) || 0),
144
+ onChange: (l) => g == null ? void 0 : g(parseFloat(l.target.value) || 0),
145
145
  readOnly: r,
146
146
  className: "nice-ratings__numeric-input"
147
147
  }
@@ -154,14 +154,14 @@ const Z = D(function(I, L) {
154
154
  return /* @__PURE__ */ c(
155
155
  "div",
156
156
  {
157
- ref: L,
158
- className: `nice-ratings nice-ratings--${k} nice-ratings--${o} ${r ? "nice-ratings--readonly" : ""} ${w ?? ""}`,
159
- style: C,
157
+ ref: I,
158
+ className: `nice-ratings nice-ratings--${w} nice-ratings--${o} ${r ? "nice-ratings--readonly" : ""} ${C ?? ""}`,
159
+ style: S,
160
160
  children: [
161
- x && /* @__PURE__ */ e("span", { className: "nice-ratings__label", children: x }),
161
+ E && /* @__PURE__ */ e("span", { className: "nice-ratings__label", children: E }),
162
162
  /* @__PURE__ */ c("div", { className: "nice-ratings__body", children: [
163
163
  o === "numeric" ? t() : n(),
164
- E && o !== "numeric" && /* @__PURE__ */ c("span", { className: "nice-ratings__value", children: [
164
+ T && o !== "numeric" && /* @__PURE__ */ c("span", { className: "nice-ratings__value", children: [
165
165
  h,
166
166
  " / ",
167
167
  a
@@ -189,20 +189,20 @@ const Z = D(function(I, L) {
189
189
  ]
190
190
  }
191
191
  );
192
- }), ie = D(function(I, L) {
192
+ }), te = R(function(p, I) {
193
193
  const {
194
194
  stats: m,
195
195
  userState: a,
196
196
  onLike: o,
197
197
  onShare: _,
198
- onBookmark: N,
198
+ onBookmark: g,
199
199
  direction: r = "horizontal",
200
- size: k = "md",
201
- showCounts: E = !0,
202
- showLabels: x = !1,
203
- className: y,
204
- style: w
205
- } = I, C = P((i) => i >= 1e6 ? (i / 1e6).toFixed(1) + "M" : i >= 1e3 ? (i / 1e3).toFixed(1) + "K" : i.toString(), []), v = [
200
+ size: w = "md",
201
+ showCounts: T = !0,
202
+ showLabels: E = !1,
203
+ className: b,
204
+ style: C
205
+ } = p, S = D((i) => i >= 1e6 ? (i / 1e6).toFixed(1) + "M" : i >= 1e3 ? (i / 1e3).toFixed(1) + "K" : i.toString(), []), v = [
206
206
  {
207
207
  key: "like",
208
208
  icon: "♡",
@@ -228,15 +228,15 @@ const Z = D(function(I, L) {
228
228
  label: "Bookmark",
229
229
  count: m.bookmarks,
230
230
  isActive: (a == null ? void 0 : a.bookmarked) ?? !1,
231
- onClick: N
231
+ onClick: g
232
232
  }
233
233
  ];
234
234
  return /* @__PURE__ */ e(
235
235
  "div",
236
236
  {
237
- ref: L,
238
- className: `nice-social-panel nice-social-panel--${r} nice-social-panel--${k} ${y ?? ""}`,
239
- style: w,
237
+ ref: I,
238
+ className: `nice-social-panel nice-social-panel--${r} nice-social-panel--${w} ${b ?? ""}`,
239
+ style: C,
240
240
  children: v.map((i) => /* @__PURE__ */ c(
241
241
  "button",
242
242
  {
@@ -245,54 +245,54 @@ const Z = D(function(I, L) {
245
245
  title: i.label,
246
246
  children: [
247
247
  /* @__PURE__ */ e("span", { className: "nice-social-panel__icon", children: i.isActive ? i.activeIcon : i.icon }),
248
- x && /* @__PURE__ */ e("span", { className: "nice-social-panel__label", children: i.label }),
249
- E && /* @__PURE__ */ e("span", { className: "nice-social-panel__count", children: C(i.count) })
248
+ E && /* @__PURE__ */ e("span", { className: "nice-social-panel__label", children: i.label }),
249
+ T && /* @__PURE__ */ e("span", { className: "nice-social-panel__count", children: S(i.count) })
250
250
  ]
251
251
  },
252
252
  i.key
253
253
  ))
254
254
  }
255
255
  );
256
- }), te = D(function(I, L) {
256
+ }), ne = R(function(p, I) {
257
257
  const {
258
258
  tags: m,
259
259
  onTagClick: a,
260
260
  minFontSize: o = 12,
261
261
  maxFontSize: _ = 36,
262
- sortBy: N = "weight",
262
+ sortBy: g = "weight",
263
263
  maxTags: r,
264
- selectedIds: k,
265
- className: E,
266
- style: x
267
- } = I, y = F(() => {
264
+ selectedIds: w,
265
+ className: T,
266
+ style: E
267
+ } = p, b = F(() => {
268
268
  let i = [...m];
269
- if (N === "weight")
270
- i.sort((h, f) => f.weight - h.weight);
271
- else if (N === "alphabetical")
272
- i.sort((h, f) => h.label.localeCompare(f.label));
269
+ if (g === "weight")
270
+ i.sort((h, N) => N.weight - h.weight);
271
+ else if (g === "alphabetical")
272
+ i.sort((h, N) => h.label.localeCompare(N.label));
273
273
  else
274
274
  for (let h = i.length - 1; h > 0; h--) {
275
- const f = Math.floor(Math.random() * (h + 1));
276
- [i[h], i[f]] = [i[f], i[h]];
275
+ const N = Math.floor(Math.random() * (h + 1));
276
+ [i[h], i[N]] = [i[N], i[h]];
277
277
  }
278
278
  return r && i.length > r && (i = i.slice(0, r)), i;
279
- }, [m, N, r]), { minW: w, maxW: C } = F(() => {
280
- if (y.length === 0) return { minW: 0, maxW: 1 };
281
- const i = y.map((h) => h.weight);
279
+ }, [m, g, r]), { minW: C, maxW: S } = F(() => {
280
+ if (b.length === 0) return { minW: 0, maxW: 1 };
281
+ const i = b.map((h) => h.weight);
282
282
  return { minW: Math.min(...i), maxW: Math.max(...i) };
283
- }, [y]), v = (i) => {
284
- if (C === w) return (o + _) / 2;
285
- const h = (i - w) / (C - w);
283
+ }, [b]), v = (i) => {
284
+ if (S === C) return (o + _) / 2;
285
+ const h = (i - C) / (S - C);
286
286
  return o + h * (_ - o);
287
287
  };
288
- return /* @__PURE__ */ e("div", { ref: L, className: `nice-tag-cloud ${E ?? ""}`, style: x, children: y.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-tag-cloud__empty", children: "No tags." }) : y.map((i) => {
289
- const h = k == null ? void 0 : k.includes(i.id), f = v(i.weight);
288
+ return /* @__PURE__ */ e("div", { ref: I, className: `nice-tag-cloud ${T ?? ""}`, style: E, children: b.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-tag-cloud__empty", children: "No tags." }) : b.map((i) => {
289
+ const h = w == null ? void 0 : w.includes(i.id), N = v(i.weight);
290
290
  return /* @__PURE__ */ e(
291
291
  "span",
292
292
  {
293
293
  className: `nice-tag-cloud__tag ${h ? "nice-tag-cloud__tag--selected" : ""}`,
294
294
  style: {
295
- fontSize: f,
295
+ fontSize: N,
296
296
  color: i.color,
297
297
  cursor: a ? "pointer" : void 0
298
298
  },
@@ -313,43 +313,43 @@ const Z = D(function(I, L) {
313
313
  away: "#eab308",
314
314
  busy: "#ef4444",
315
315
  offline: "#9ca3af"
316
- }, ne = D(function(I, L) {
316
+ }, ae = R(function(p, I) {
317
317
  const {
318
318
  users: m,
319
319
  onUserClick: a,
320
320
  onAction: o,
321
321
  actions: _ = [],
322
- searchable: N = !1,
322
+ searchable: g = !1,
323
323
  statusFilter: r,
324
- showStatus: k = !0,
325
- layout: E = "list",
326
- groupByRole: x = !1,
327
- className: y,
328
- style: w
329
- } = I, [C, v] = T(""), i = F(() => {
324
+ showStatus: w = !0,
325
+ layout: T = "list",
326
+ groupByRole: E = !1,
327
+ className: b,
328
+ style: C
329
+ } = p, [S, v] = $(""), i = F(() => {
330
330
  let n = m;
331
- if (r && r.length > 0 && (n = n.filter((t) => t.status && r.includes(t.status))), C.trim()) {
332
- const t = C.toLowerCase();
331
+ if (r && r.length > 0 && (n = n.filter((t) => t.status && r.includes(t.status))), S.trim()) {
332
+ const t = S.toLowerCase();
333
333
  n = n.filter(
334
334
  (l) => {
335
- var s, b;
336
- return l.name.toLowerCase().includes(t) || ((s = l.email) == null ? void 0 : s.toLowerCase().includes(t)) || ((b = l.role) == null ? void 0 : b.toLowerCase().includes(t));
335
+ var s, k;
336
+ return l.name.toLowerCase().includes(t) || ((s = l.email) == null ? void 0 : s.toLowerCase().includes(t)) || ((k = l.role) == null ? void 0 : k.toLowerCase().includes(t));
337
337
  }
338
338
  );
339
339
  }
340
340
  return n;
341
- }, [m, r, C]), h = F(() => {
342
- if (!x) return { "": i };
341
+ }, [m, r, S]), h = F(() => {
342
+ if (!E) return { "": i };
343
343
  const n = {};
344
344
  for (const t of i) {
345
345
  const l = t.role ?? "Other";
346
346
  n[l] || (n[l] = []), n[l].push(t);
347
347
  }
348
348
  return n;
349
- }, [i, x]), f = (n) => /* @__PURE__ */ c(
349
+ }, [i, E]), N = (n) => /* @__PURE__ */ c(
350
350
  "div",
351
351
  {
352
- className: `nice-user-list__item nice-user-list__item--${E}`,
352
+ className: `nice-user-list__item nice-user-list__item--${T}`,
353
353
  onClick: () => a == null ? void 0 : a(n),
354
354
  role: a ? "button" : void 0,
355
355
  tabIndex: a ? 0 : void 0,
@@ -359,7 +359,7 @@ const Z = D(function(I, L) {
359
359
  children: [
360
360
  /* @__PURE__ */ c("div", { className: "nice-user-list__avatar-wrap", children: [
361
361
  n.avatarUrl ? /* @__PURE__ */ e("img", { src: n.avatarUrl, alt: n.name, className: "nice-user-list__avatar" }) : /* @__PURE__ */ e("span", { className: "nice-user-list__avatar-placeholder", children: n.name.charAt(0).toUpperCase() }),
362
- k && n.status && /* @__PURE__ */ e(
362
+ w && n.status && /* @__PURE__ */ e(
363
363
  "span",
364
364
  {
365
365
  className: "nice-user-list__status-dot",
@@ -388,68 +388,74 @@ const Z = D(function(I, L) {
388
388
  },
389
389
  n.id
390
390
  );
391
- return /* @__PURE__ */ c("div", { ref: L, className: `nice-user-list nice-user-list--${E} ${y ?? ""}`, style: w, children: [
392
- N && /* @__PURE__ */ e(
391
+ return /* @__PURE__ */ c("div", { ref: I, className: `nice-user-list nice-user-list--${T} ${b ?? ""}`, style: C, children: [
392
+ g && /* @__PURE__ */ e(
393
393
  "input",
394
394
  {
395
395
  type: "text",
396
- value: C,
396
+ value: S,
397
397
  onChange: (n) => v(n.target.value),
398
398
  placeholder: "Search users…",
399
399
  className: "nice-user-list__search"
400
400
  }
401
401
  ),
402
402
  i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-user-list__empty", children: "No users found." }) : Object.entries(h).map(([n, t]) => /* @__PURE__ */ c("div", { className: "nice-user-list__group", children: [
403
- x && n && /* @__PURE__ */ c("h4", { className: "nice-user-list__group-title", children: [
403
+ E && n && /* @__PURE__ */ c("h4", { className: "nice-user-list__group-title", children: [
404
404
  n,
405
405
  " (",
406
406
  t.length,
407
407
  ")"
408
408
  ] }),
409
- t.map(f)
409
+ t.map(N)
410
410
  ] }, n))
411
411
  ] });
412
- }), ae = D(function(I, L) {
412
+ });
413
+ function Q(M) {
414
+ if (!M) return "";
415
+ let p = M;
416
+ return p = p.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ""), p = p.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, ""), p = p.replace(/(href|src|action)\s*=\s*(?:"javascript:[^"]*"|'javascript:[^']*')/gi, '$1=""'), p = p.replace(/(href|src|action)\s*=\s*(?:"vbscript:[^"]*"|'vbscript:[^']*')/gi, '$1=""'), p = p.replace(/<\/?(iframe|object|embed|form)\b[^>]*>/gi, ""), p;
417
+ }
418
+ const se = R(function(p, I) {
413
419
  const {
414
420
  pages: m,
415
421
  selectedPageId: a,
416
422
  onSelectPage: o,
417
423
  onSavePage: _,
418
- onDeletePage: N,
424
+ onDeletePage: g,
419
425
  onCreatePage: r,
420
- editable: k = !1,
421
- searchable: E = !0,
422
- renderHtml: x = !1,
423
- sidebarWidth: y = 260,
424
- className: w,
425
- style: C
426
- } = I, [v, i] = T(""), [h, f] = T(!1), [n, t] = T(""), [l, s] = T(""), [b, $] = T(""), [A, O] = T(!1), z = F(() => {
427
- if (m.some((p) => p.children && p.children.length > 0)) return m.filter((p) => !p.parentId);
426
+ editable: w = !1,
427
+ searchable: T = !0,
428
+ renderHtml: E = !1,
429
+ sidebarWidth: b = 260,
430
+ className: C,
431
+ style: S
432
+ } = p, [v, i] = $(""), [h, N] = $(!1), [n, t] = $(""), [l, s] = $(""), [k, L] = $(""), [A, j] = $(!1), z = F(() => {
433
+ if (m.some((f) => f.children && f.children.length > 0)) return m.filter((f) => !f.parentId);
428
434
  const u = /* @__PURE__ */ new Map();
429
- for (const p of m)
430
- u.set(p.id, { ...p, children: [] });
431
- const g = [];
432
- for (const p of u.values())
433
- p.parentId && u.has(p.parentId) ? u.get(p.parentId).children.push(p) : g.push(p);
434
- return g;
435
- }, [m]), S = F(() => m.find((u) => u.id === a), [m, a]), W = F(() => {
435
+ for (const f of m)
436
+ u.set(f.id, { ...f, children: [] });
437
+ const y = [];
438
+ for (const f of u.values())
439
+ f.parentId && u.has(f.parentId) ? u.get(f.parentId).children.push(f) : y.push(f);
440
+ return y;
441
+ }, [m]), x = F(() => m.find((u) => u.id === a), [m, a]), W = F(() => {
436
442
  if (!v.trim()) return z;
437
- const u = v.toLowerCase(), g = new Set(m.filter((p) => p.title.toLowerCase().includes(u)).map((p) => p.id));
438
- return m.filter((p) => g.has(p.id));
439
- }, [z, m, v]), j = P(() => {
440
- S && (t(S.title), s(S.content ?? ""), f(!0));
441
- }, [S]), d = P(() => {
442
- !S || !_ || (_(S.id, l, n), f(!1));
443
- }, [S, l, n, _]), M = P(() => {
444
- !b.trim() || !r || (r(a ?? null, b.trim()), $(""), O(!1));
445
- }, [b, a, r]), U = (u, g = 0) => {
446
- var p;
443
+ const u = v.toLowerCase(), y = new Set(m.filter((f) => f.title.toLowerCase().includes(u)).map((f) => f.id));
444
+ return m.filter((f) => y.has(f.id));
445
+ }, [z, m, v]), O = D(() => {
446
+ x && (t(x.title), s(x.content ?? ""), N(!0));
447
+ }, [x]), d = D(() => {
448
+ !x || !_ || (_(x.id, l, n), N(!1));
449
+ }, [x, l, n, _]), P = D(() => {
450
+ !k.trim() || !r || (r(a ?? null, k.trim()), L(""), j(!1));
451
+ }, [k, a, r]), U = (u, y = 0) => {
452
+ var f;
447
453
  return /* @__PURE__ */ c("div", { children: [
448
454
  /* @__PURE__ */ e(
449
455
  "div",
450
456
  {
451
457
  className: `nice-wiki__page-item ${u.id === a ? "nice-wiki__page-item--active" : ""}`,
452
- style: { paddingLeft: 12 + g * 16 },
458
+ style: { paddingLeft: 12 + y * 16 },
453
459
  onClick: () => o == null ? void 0 : o(u),
454
460
  role: "button",
455
461
  tabIndex: 0,
@@ -459,28 +465,28 @@ const Z = D(function(I, L) {
459
465
  children: u.title
460
466
  }
461
467
  ),
462
- (p = u.children) == null ? void 0 : p.map((B) => U(B, g + 1))
468
+ (f = u.children) == null ? void 0 : f.map((B) => U(B, y + 1))
463
469
  ] }, u.id);
464
470
  };
465
- return /* @__PURE__ */ c("div", { ref: L, className: `nice-wiki ${w ?? ""}`, style: { display: "flex", ...C }, children: [
466
- /* @__PURE__ */ c("div", { className: "nice-wiki__sidebar", style: { width: y, minWidth: y }, children: [
471
+ return /* @__PURE__ */ c("div", { ref: I, className: `nice-wiki ${C ?? ""}`, style: { display: "flex", ...S }, children: [
472
+ /* @__PURE__ */ c("div", { className: "nice-wiki__sidebar", style: { width: b, minWidth: b }, children: [
467
473
  /* @__PURE__ */ c("div", { className: "nice-wiki__sidebar-header", children: [
468
474
  /* @__PURE__ */ e("strong", { children: "Wiki" }),
469
- k && r && /* @__PURE__ */ e("button", { onClick: () => O(!A), title: "New page", children: "+" })
475
+ w && r && /* @__PURE__ */ e("button", { onClick: () => j(!A), title: "New page", children: "+" })
470
476
  ] }),
471
477
  A && /* @__PURE__ */ c("div", { className: "nice-wiki__new-page", children: [
472
478
  /* @__PURE__ */ e(
473
479
  "input",
474
480
  {
475
481
  type: "text",
476
- value: b,
477
- onChange: (u) => $(u.target.value),
482
+ value: k,
483
+ onChange: (u) => L(u.target.value),
478
484
  placeholder: "New page title"
479
485
  }
480
486
  ),
481
- /* @__PURE__ */ e("button", { onClick: M, disabled: !b.trim(), children: "Create" })
487
+ /* @__PURE__ */ e("button", { onClick: P, disabled: !k.trim(), children: "Create" })
482
488
  ] }),
483
- E && /* @__PURE__ */ e(
489
+ T && /* @__PURE__ */ e(
484
490
  "input",
485
491
  {
486
492
  type: "text",
@@ -492,7 +498,7 @@ const Z = D(function(I, L) {
492
498
  ),
493
499
  /* @__PURE__ */ e("div", { className: "nice-wiki__tree", children: W.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-wiki__empty", children: "No pages." }) : W.map((u) => U(u)) })
494
500
  ] }),
495
- /* @__PURE__ */ e("div", { className: "nice-wiki__content", children: S ? h ? /* @__PURE__ */ c("div", { className: "nice-wiki__editor", children: [
501
+ /* @__PURE__ */ e("div", { className: "nice-wiki__content", children: x ? h ? /* @__PURE__ */ c("div", { className: "nice-wiki__editor", children: [
496
502
  /* @__PURE__ */ e(
497
503
  "input",
498
504
  {
@@ -513,33 +519,33 @@ const Z = D(function(I, L) {
513
519
  ),
514
520
  /* @__PURE__ */ c("div", { className: "nice-wiki__edit-actions", children: [
515
521
  /* @__PURE__ */ e("button", { onClick: d, children: "Save" }),
516
- /* @__PURE__ */ e("button", { onClick: () => f(!1), children: "Cancel" })
522
+ /* @__PURE__ */ e("button", { onClick: () => N(!1), children: "Cancel" })
517
523
  ] })
518
524
  ] }) : /* @__PURE__ */ c("div", { className: "nice-wiki__viewer", children: [
519
525
  /* @__PURE__ */ c("div", { className: "nice-wiki__viewer-header", children: [
520
- /* @__PURE__ */ e("h2", { children: S.title }),
526
+ /* @__PURE__ */ e("h2", { children: x.title }),
521
527
  /* @__PURE__ */ c("div", { className: "nice-wiki__viewer-meta", children: [
522
- S.lastEditedBy && /* @__PURE__ */ c("span", { children: [
528
+ x.lastEditedBy && /* @__PURE__ */ c("span", { children: [
523
529
  "Edited by ",
524
- S.lastEditedBy
530
+ x.lastEditedBy
525
531
  ] }),
526
- S.lastEditedAt && /* @__PURE__ */ c("span", { children: [
532
+ x.lastEditedAt && /* @__PURE__ */ c("span", { children: [
527
533
  " on ",
528
- S.lastEditedAt
534
+ x.lastEditedAt
529
535
  ] })
530
536
  ] }),
531
- k && /* @__PURE__ */ c("div", { className: "nice-wiki__viewer-actions", children: [
532
- /* @__PURE__ */ e("button", { onClick: j, children: "Edit" }),
533
- N && /* @__PURE__ */ e("button", { onClick: () => N(S.id), children: "Delete" })
537
+ w && /* @__PURE__ */ c("div", { className: "nice-wiki__viewer-actions", children: [
538
+ /* @__PURE__ */ e("button", { onClick: O, children: "Edit" }),
539
+ g && /* @__PURE__ */ e("button", { onClick: () => g(x.id), children: "Delete" })
534
540
  ] })
535
541
  ] }),
536
- x ? /* @__PURE__ */ e(
542
+ E ? /* @__PURE__ */ e(
537
543
  "div",
538
544
  {
539
545
  className: "nice-wiki__viewer-body",
540
- dangerouslySetInnerHTML: { __html: S.content ?? "" }
546
+ dangerouslySetInnerHTML: { __html: Q(x.content ?? "") }
541
547
  }
542
- ) : /* @__PURE__ */ e("div", { className: "nice-wiki__viewer-body", children: S.content ?? /* @__PURE__ */ e("em", { children: "No content." }) })
548
+ ) : /* @__PURE__ */ e("div", { className: "nice-wiki__viewer-body", children: x.content ?? /* @__PURE__ */ e("em", { children: "No content." }) })
543
549
  ] }) : /* @__PURE__ */ e("div", { className: "nice-wiki__placeholder", children: "Select a page from the sidebar." }) })
544
550
  ] });
545
551
  }), K = {
@@ -554,19 +560,19 @@ const Z = D(function(I, L) {
554
560
  upload: "📎",
555
561
  mention: "@",
556
562
  custom: "📌"
557
- }, se = D(function(I, L) {
563
+ }, ce = R(function(p, I) {
558
564
  const {
559
565
  events: m,
560
566
  onEventClick: a,
561
567
  groupByDate: o = !0,
562
568
  typeFilter: _,
563
- showFilters: N = !1,
569
+ showFilters: g = !1,
564
570
  maxEvents: r,
565
- onLoadMore: k,
566
- hasMore: E = !1,
567
- className: x,
568
- style: y
569
- } = I, [w, C] = T(/* @__PURE__ */ new Set()), v = _ ?? (w.size > 0 ? Array.from(w) : void 0), i = F(() => {
571
+ onLoadMore: w,
572
+ hasMore: T = !1,
573
+ className: E,
574
+ style: b
575
+ } = p, [C, S] = $(/* @__PURE__ */ new Set()), v = _ ?? (C.size > 0 ? Array.from(C) : void 0), i = F(() => {
570
576
  let t = m;
571
577
  if (v && v.length > 0) {
572
578
  const l = new Set(v);
@@ -581,21 +587,21 @@ const Z = D(function(I, L) {
581
587
  t.has(s) || t.set(s, []), t.get(s).push(l);
582
588
  }
583
589
  return Array.from(t.entries()).map(([l, s]) => ({ label: l, events: s }));
584
- }, [i, o]), f = F(() => {
590
+ }, [i, o]), N = F(() => {
585
591
  const t = new Set(m.map((l) => l.type));
586
592
  return Array.from(t).sort();
587
593
  }, [m]), n = (t) => {
588
- C((l) => {
594
+ S((l) => {
589
595
  const s = new Set(l);
590
596
  return s.has(t) ? s.delete(t) : s.add(t), s;
591
597
  });
592
598
  };
593
- return /* @__PURE__ */ c("div", { ref: L, className: `nice-activity-feed ${x ?? ""}`, style: y, children: [
594
- N && !_ && /* @__PURE__ */ c("div", { className: "nice-activity-feed__filters", children: [
595
- f.map((t) => /* @__PURE__ */ c(
599
+ return /* @__PURE__ */ c("div", { ref: I, className: `nice-activity-feed ${E ?? ""}`, style: b, children: [
600
+ g && !_ && /* @__PURE__ */ c("div", { className: "nice-activity-feed__filters", children: [
601
+ N.map((t) => /* @__PURE__ */ c(
596
602
  "button",
597
603
  {
598
- className: `nice-activity-feed__filter-chip ${w.has(t) ? "nice-activity-feed__filter-chip--active" : ""}`,
604
+ className: `nice-activity-feed__filter-chip ${C.has(t) ? "nice-activity-feed__filter-chip--active" : ""}`,
599
605
  onClick: () => n(t),
600
606
  children: [
601
607
  K[t],
@@ -605,11 +611,11 @@ const Z = D(function(I, L) {
605
611
  },
606
612
  t
607
613
  )),
608
- w.size > 0 && /* @__PURE__ */ e(
614
+ C.size > 0 && /* @__PURE__ */ e(
609
615
  "button",
610
616
  {
611
617
  className: "nice-activity-feed__filter-clear",
612
- onClick: () => C(/* @__PURE__ */ new Set()),
618
+ onClick: () => S(/* @__PURE__ */ new Set()),
613
619
  children: "Clear"
614
620
  }
615
621
  )
@@ -623,8 +629,8 @@ const Z = D(function(I, L) {
623
629
  onClick: () => a == null ? void 0 : a(s),
624
630
  role: a ? "button" : void 0,
625
631
  tabIndex: a ? 0 : void 0,
626
- onKeyDown: (b) => {
627
- b.key === "Enter" && a && a(s);
632
+ onKeyDown: (k) => {
633
+ k.key === "Enter" && a && a(s);
628
634
  },
629
635
  children: [
630
636
  /* @__PURE__ */ e("span", { className: "nice-activity-feed__icon", children: K[s.type] }),
@@ -646,15 +652,15 @@ const Z = D(function(I, L) {
646
652
  s.id
647
653
  ))
648
654
  ] }, t || "__all")),
649
- E && k && /* @__PURE__ */ e("button", { className: "nice-activity-feed__load-more", onClick: k, children: "Load more" })
655
+ T && w && /* @__PURE__ */ e("button", { className: "nice-activity-feed__load-more", onClick: w, children: "Load more" })
650
656
  ] });
651
657
  });
652
658
  export {
653
- se as NiceActivityFeed,
654
- Z as NiceComments,
655
- ee as NiceRatings,
656
- ie as NiceSocialPanel,
657
- te as NiceTagCloud,
658
- ne as NiceUserList,
659
- ae as NiceWiki
659
+ ce as NiceActivityFeed,
660
+ ee as NiceComments,
661
+ ie as NiceRatings,
662
+ te as NiceSocialPanel,
663
+ ne as NiceTagCloud,
664
+ ae as NiceUserList,
665
+ se as NiceWiki
660
666
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/social",
3
- "version": "0.1.0",
3
+ "version": "1.0.2",
4
4
  "description": "Nice2Dev Social — Comments, ratings, activity feed, tag cloud, social panel, user list, wiki for React",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -46,6 +46,8 @@
46
46
  "react-dom": ">=17.0.0"
47
47
  },
48
48
  "devDependencies": {
49
+ "@testing-library/jest-dom": "^6.9.1",
50
+ "@testing-library/react": "^14.0.0",
49
51
  "@types/react": "^18.2.0",
50
52
  "@types/react-dom": "^18.2.0",
51
53
  "@vitejs/plugin-react": "^4.2.0",
@@ -53,6 +55,7 @@
53
55
  "react-dom": "^18.2.0",
54
56
  "typescript": "^5.3.0",
55
57
  "vite": "^6.2.0",
56
- "vite-plugin-dts": "^4.5.0"
58
+ "vite-plugin-dts": "^4.5.0",
59
+ "vitest": "^4.1.0"
57
60
  }
58
61
  }