@nice2dev/social 1.1.6 → 1.1.9
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 +56 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +348 -315
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @nice2dev/social — Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.9
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 1.1.8
|
|
8
|
+
|
|
9
|
+
No changes in this release.
|
|
10
|
+
|
|
11
|
+
## 1.1.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Close the three items left open in the 1.1.6 response to OmniVerk.
|
|
16
|
+
|
|
17
|
+
**Every value control works without state in the parent.** The `audit-controllable-state` gate
|
|
18
|
+
counted 87 value props that were required with no `default*`, so the control could not render from a
|
|
19
|
+
manifest without data. It now reports 0 and gates CI at `--max=0`. 48 controls gained `default*` props
|
|
20
|
+
through `useControllableState` (existing `value` + handler call sites behave as before); 33 read-only
|
|
21
|
+
data lists are optional with a stable empty default; 4 props paired with a handler only by name are
|
|
22
|
+
optional; `NiceWhiteboard` and `NiceMetricsDashboard` render an empty state until a session or
|
|
23
|
+
dashboard arrives. Additive API only — nothing renamed or removed.
|
|
24
|
+
|
|
25
|
+
- `NicePivotGrid.fields`, `NiceScheduler.events` and `NiceGitHooks.hooks` are controlled only together
|
|
26
|
+
with their change handler, as `NiceScheduler` already documented for `currentDate`/`view`. A bare
|
|
27
|
+
prop stays an initial value; prop plus handler now always wins (later prop updates used to be
|
|
28
|
+
ignored). `NiceGitHooks.onHookChange` is now called; `onHooksChange` and
|
|
29
|
+
`NiceLocaleManager.onTranslationsChange` are new.
|
|
30
|
+
- `NiceCodeEditor` / `NiceCodeDiffEditor` no longer report a value written from the prop back through
|
|
31
|
+
`onChange`, and call the latest handler rather than the one captured at mount.
|
|
32
|
+
- `NiceHtmlEditor` no longer rewrites its content on every render (React 19 compares the
|
|
33
|
+
`dangerouslySetInnerHTML` object, not its string), which moved the caret; the HTML source and
|
|
34
|
+
Markdown views can be closed again.
|
|
35
|
+
- Selections seeded once from the first item (access manager, automation/scene editors, git diff
|
|
36
|
+
viewer, ribbon, setup wizard) follow data that arrives after mount.
|
|
37
|
+
- `useControllableState`: new `fallbackValue` seed that never triggers the value/default clash warning;
|
|
38
|
+
two functional updates in one tick no longer lose the first; `onChange` is called with one argument
|
|
39
|
+
when there is no meta. `UseControllableStateOptions` is now a union type alias.
|
|
40
|
+
|
|
41
|
+
**`--nice-*` is the source of truth for design tokens.** Controls read only `--nice-*` (9,225 reads in
|
|
42
|
+
339 files). The unprefixed names (`--color-primary`, `--bg-primary`, `--text-muted`, …) stay declared
|
|
43
|
+
as aliases pointing at the Nice tokens, so reading them works, but setting them no longer repaints Nice
|
|
44
|
+
controls. Apps that relied on that can import `@nice2dev/ui/css/legacy-bg-text-aliases.css` after
|
|
45
|
+
`style.css` (removed in 1.2), or set `--nice-color-primary` and friends directly. 13 tokens that were
|
|
46
|
+
read and never declared (`--color-danger`, `--text-on-primary`, `--color-white`, …) are defined; the
|
|
47
|
+
dark blocks define the canonical names, so `.nice-dark` on `<body>` no longer leaves them on light
|
|
48
|
+
values; `--nice-primary-bg` and `--nice-selected-bg` are a primary tint instead of falling through to
|
|
49
|
+
grey. New gate `audit-token-names`.
|
|
50
|
+
|
|
51
|
+
**Node ESM and `require()`.** `@nice2dev/spatial-core` imports from plain Node ESM (51 relative
|
|
52
|
+
specifiers gained extensions, enforced by `nodenext`), and so does `@nice2dev/ui-buildings`, which
|
|
53
|
+
failed through it. `require()` works for `ui-3d`, `ui-graphics` and `game-engine`. The package-exports
|
|
54
|
+
gate now loads every entry in both module systems.
|
|
55
|
+
|
|
56
|
+
**Hygiene.** Sources are prettier-formatted and CI gates on it; 640 stale `.d.ts` files were removed
|
|
57
|
+
from source trees (never published).
|
|
58
|
+
|
|
3
59
|
## 1.1.6
|
|
4
60
|
|
|
5
61
|
No changes in this release.
|
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(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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),U=l.forwardRef(function(u,M){const{comments:m,currentUserId:n,onSubmit:o,onEdit:_,onDelete:g,onReact:r,readOnly:b=!1,maxDepth:$=4,reactions:S=["👍","❤️","😂","😮","😢"],placeholder:N="Write a comment…",className:k,style:w}=u,[x,s]=l.useState(""),[h,v]=l.useState(null),[t,i]=l.useState(""),[c,a]=l.useState(null),[y,E]=l.useState(""),L=new Map;for(const d of m){const A=d.parentId??"__root__";L.has(A)||L.set(A,[]),L.get(A).push(d)}const R=l.useCallback(()=>{!x.trim()||!o||(o(x.trim()),s(""))},[x,o]),P=l.useCallback(()=>{!t.trim()||!o||!h||(o(t.trim(),h),i(""),v(null))},[t,h,o]),C=l.useCallback(()=>{!c||!y.trim()||!_||(_(c,y.trim()),a(null),E(""))},[c,y,_]),I=(d,A)=>{const F=n&&d.authorId===n,p=L.get(d.id)??[];return e.jsxs("div",{className:"nice-comments__item",style:{marginLeft:A*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=>E(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)),A<$&&e.jsx("button",{onClick:()=>{v(d.id),i("")},children:"Reply"}),F&&_&&e.jsx("button",{onClick:()=>{a(d.id),E(d.content)},children:"Edit"}),F&&g&&e.jsx("button",{onClick:()=>g(d.id),children:"Delete"})]}),h===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"})]}),p.map(j=>I(j,A+1))]},d.id)},D=L.get("__root__")??[];return e.jsxs("div",{ref:M,className:`nice-comments ${k??""}`,style:w,children:[!b&&e.jsxs("div",{className:"nice-comments__new",children:[e.jsx("textarea",{value:x,onChange:d=>s(d.target.value),placeholder:N}),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=>I(d,0))]})}),z={star:"polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 79% 94%, 50% 73%, 21% 94%, 31% 59%, 2% 37%, 38% 36%)",heart:"polygon(50% 92%, 12% 54%, 4% 40%, 4% 25%, 10% 13%, 22% 6%, 34% 6%, 44% 12%, 50% 21%, 56% 12%, 66% 6%, 78% 6%, 90% 13%, 96% 25%, 96% 40%, 88% 54%)",share:"polygon(42% 8%, 92% 8%, 92% 58%, 75% 41%, 27% 89%, 11% 73%, 59% 25%)"},O=({shape:T,filled:u=!0})=>e.jsx("span",{"aria-hidden":"true",className:`nice-social-shape nice-social-shape--${T}`,style:{display:"inline-block",width:"1em",height:"1em",verticalAlign:"-0.125em",background:"currentColor",clipPath:z[T],opacity:u?1:.35}}),B=l.forwardRef(function(u,M){const{value:m,max:n=5,mode:o="stars",aggregation:_,onChange:g,readOnly:r=!1,size:b="md",showValue:$=!1,label:S,emojiSet:N=["😢","😕","😐","🙂","😍"],className:k,style:w}=u,[x,s]=l.useState(null),h=x!==null?x+1:m??0,v=l.useCallback(c=>{r||!g||g(c+1)},[r,g]),t=()=>{const c=[];for(let a=0;a<n;a++){const y=a<h;let E;o==="emoji"?E=N[a]??N[N.length-1]:o==="hearts"?E=e.jsx(O,{shape:"heart",filled:y}):o==="thumbs"?E=y?"👍":"👎":E=e.jsx(O,{shape:"star",filled:y}),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:E},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=>g==null?void 0:g(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:M,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(),$&&o!=="numeric"&&e.jsxs("span",{className:"nice-ratings__value",children:[h," / ",n]})]}),_&&e.jsxs("div",{className:"nice-ratings__aggregation",children:[e.jsx("span",{className:"nice-ratings__avg",children:_.average.toFixed(1)}),e.jsxs("span",{className:"nice-ratings__count",children:["(",_.count," ratings)"]}),_.distribution&&e.jsx("div",{className:"nice-ratings__distribution",children:Object.entries(_.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:`${_.count?a/_.count*100:0}%`}})}),e.jsx("span",{children:a})]},c))})]})]})}),K=l.forwardRef(function(u,M){const{stats:m,userState:n,onLike:o,onShare:_,onBookmark:g,direction:r="horizontal",size:b="md",showCounts:$=!0,showLabels:S=!1,className:N,style:k}=u,w=l.useCallback(s=>s>=1e6?(s/1e6).toFixed(1)+"M":s>=1e3?(s/1e3).toFixed(1)+"K":s.toString(),[]),x=[{key:"like",shape:"heart",label:"Like",count:m.likes,isActive:(n==null?void 0:n.liked)??!1,onClick:o},{key:"share",shape:"share",label:"Share",count:m.shares,isActive:(n==null?void 0:n.shared)??!1,onClick:_},{key:"bookmark",shape:"star",label:"Bookmark",count:m.bookmarks,isActive:(n==null?void 0:n.bookmarked)??!1,onClick:g}];return e.jsx("div",{ref:M,className:`nice-social-panel nice-social-panel--${r} nice-social-panel--${b} ${N??""}`,style:k,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,"aria-label":s.label,"aria-pressed":s.isActive,children:[e.jsx("span",{className:"nice-social-panel__icon",children:e.jsx(O,{shape:s.shape,filled:s.isActive||s.shape==="share"})}),S&&e.jsx("span",{className:"nice-social-panel__label",children:s.label}),$&&e.jsx("span",{className:"nice-social-panel__count",children:w(s.count)})]},s.key))})}),H=l.forwardRef(function(u,M){const{tags:m,onTagClick:n,minFontSize:o=12,maxFontSize:_=36,sortBy:g="weight",maxTags:r,selectedIds:b,className:$,style:S}=u,N=l.useMemo(()=>{let s=[...m];if(g==="weight")s.sort((h,v)=>v.weight-h.weight);else if(g==="alphabetical")s.sort((h,v)=>h.label.localeCompare(v.label));else for(let h=s.length-1;h>0;h--){const v=Math.floor(Math.random()*(h+1));[s[h],s[v]]=[s[v],s[h]]}return r&&s.length>r&&(s=s.slice(0,r)),s},[m,g,r]),{minW:k,maxW:w}=l.useMemo(()=>{if(N.length===0)return{minW:0,maxW:1};const s=N.map(h=>h.weight);return{minW:Math.min(...s),maxW:Math.max(...s)}},[N]),x=s=>{if(w===k)return(o+_)/2;const h=(s-k)/(w-k);return o+h*(_-o)};return e.jsx("div",{ref:M,className:`nice-tag-cloud ${$??""}`,style:S,children:N.length===0?e.jsx("p",{className:"nice-tag-cloud__empty",children:"No tags."}):N.map(s=>{const h=b==null?void 0:b.includes(s.id),v=x(s.weight);return e.jsx("span",{className:`nice-tag-cloud__tag ${h?"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)})})}),q={online:"#22c55e",away:"#eab308",busy:"#ef4444",offline:"#9ca3af"},V=l.forwardRef(function(u,M){const{users:m,onUserClick:n,onAction:o,actions:_=[],searchable:g=!1,statusFilter:r,showStatus:b=!0,layout:$="list",groupByRole:S=!1,className:N,style:k}=u,[w,x]=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]),h=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--${$}`,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:q[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})]}),_.length>0&&e.jsx("div",{className:"nice-user-list__actions",children:_.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:M,className:`nice-user-list nice-user-list--${$} ${N??""}`,style:k,children:[g&&e.jsx("input",{type:"text",value:w,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(h).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 Y(T){if(!T)return"";let u=T;return u=u.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,""),u=u.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,""),u=u.replace(/(href|src|action)\s*=\s*(?:"javascript:[^"]*"|'javascript:[^']*')/gi,'$1=""'),u=u.replace(/(href|src|action)\s*=\s*(?:"vbscript:[^"]*"|'vbscript:[^']*')/gi,'$1=""'),u=u.replace(/<\/?(iframe|object|embed|form)\b[^>]*>/gi,""),u}const G=l.forwardRef(function(u,M){const{pages:m,selectedPageId:n,onSelectPage:o,onSavePage:_,onDeletePage:g,onCreatePage:r,editable:b=!1,searchable:$=!0,renderHtml:S=!1,sidebarWidth:N=260,className:k,style:w}=u,[x,s]=l.useState(""),[h,v]=l.useState(!1),[t,i]=l.useState(""),[c,a]=l.useState(""),[y,E]=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 p=new Map;for(const f of m)p.set(f.id,{...f,children:[]});const j=[];for(const f of p.values())f.parentId&&p.has(f.parentId)?p.get(f.parentId).children.push(f):j.push(f);return j},[m]),C=l.useMemo(()=>m.find(p=>p.id===n),[m,n]),I=l.useMemo(()=>{if(!x.trim())return P;const p=x.toLowerCase(),j=new Set(m.filter(f=>f.title.toLowerCase().includes(p)).map(f=>f.id));return m.filter(f=>j.has(f.id))},[P,m,x]),D=l.useCallback(()=>{C&&(i(C.title),a(C.content??""),v(!0))},[C]),d=l.useCallback(()=>{!C||!_||(_(C.id,c,t),v(!1))},[C,c,t,_]),A=l.useCallback(()=>{!y.trim()||!r||(r(n??null,y.trim()),E(""),R(!1))},[y,n,r]),F=(p,j=0)=>{var f;return e.jsxs("div",{children:[e.jsx("div",{className:`nice-wiki__page-item ${p.id===n?"nice-wiki__page-item--active":""}`,style:{paddingLeft:12+j*16},onClick:()=>o==null?void 0:o(p),role:"button",tabIndex:0,onKeyDown:W=>{W.key==="Enter"&&(o==null||o(p))},children:p.title}),(f=p.children)==null?void 0:f.map(W=>F(W,j+1))]},p.id)};return e.jsxs("div",{ref:M,className:`nice-wiki ${k??""}`,style:{display:"flex",...w},children:[e.jsxs("div",{className:"nice-wiki__sidebar",style:{width:N,minWidth:N},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:p=>E(p.target.value),placeholder:"New page title"}),e.jsx("button",{onClick:A,disabled:!y.trim(),children:"Create"})]}),$&&e.jsx("input",{type:"text",className:"nice-wiki__search",value:x,onChange:p=>s(p.target.value),placeholder:"Search pages…"}),e.jsx("div",{className:"nice-wiki__tree",children:I.length===0?e.jsx("p",{className:"nice-wiki__empty",children:"No pages."}):I.map(p=>F(p))})]}),e.jsx("div",{className:"nice-wiki__content",children:C?h?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("input",{type:"text",className:"nice-wiki__edit-title",value:t,onChange:p=>i(p.target.value)}),e.jsx("textarea",{className:"nice-wiki__edit-body",value:c,onChange:p=>a(p.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"}),g&&e.jsx("button",{onClick:()=>g(C.id),children:"Delete"})]})]}),S?e.jsx("div",{className:"nice-wiki__viewer-body",dangerouslySetInnerHTML:{__html:Y(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."})})]})}),J={comment:"var(--nice-color-primary, #3b82f6)",like:"var(--nice-color-error, #ef4444)",share:"var(--nice-color-info, #0ea5e9)",create:"var(--nice-color-success, #22c55e)",update:"var(--nice-color-warning, #f59e0b)",delete:"var(--nice-color-error, #ef4444)",join:"var(--nice-color-success, #22c55e)",leave:"var(--nice-text-muted, #6b7280)",upload:"var(--nice-color-accent, #8b5cf6)",mention:"var(--nice-color-primary, #3b82f6)",custom:"var(--nice-text-muted, #6b7280)"},Q=l.forwardRef(function(u,M){const{events:m,onEventClick:n,groupByDate:o=!0,typeFilter:_,showFilters:g=!1,maxEvents:r,onLoadMore:b,hasMore:$=!1,className:S,style:N}=u,[k,w]=l.useState(new Set),x=_??(k.size>0?Array.from(k):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]),h=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:M,className:`nice-activity-feed ${S??""}`,style:N,children:[g&&!_&&e.jsxs("div",{className:"nice-activity-feed__filters",children:[v.map(i=>e.jsx("button",{className:`nice-activity-feed__filter-chip ${k.has(i)?"nice-activity-feed__filter-chip--active":""}`,onClick:()=>t(i),children: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."}):h.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 nice-activity-feed__icon--${a.type}`,title:a.type,"aria-hidden":"true",style:{display:"inline-block",width:10,height:10,marginTop:4,flexShrink:0,borderRadius:"50%",background:J[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")),$&&b&&e.jsx("button",{className:"nice-activity-feed__load-more",onClick:b,children:"Load more"})]})});exports.NiceActivityFeed=Q;exports.NiceComments=U;exports.NiceRatings=B;exports.NiceSocialPanel=K;exports.NiceTagCloud=H;exports.NiceUserList=V;exports.NiceWiki=G;
|
package/dist/index.mjs
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
const
|
|
4
|
-
function(
|
|
1
|
+
import { jsxs as l, jsx as e, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as W, useState as L, useCallback as D, useMemo as P } from "react";
|
|
3
|
+
const X = W(
|
|
4
|
+
function(u, T) {
|
|
5
5
|
const {
|
|
6
6
|
comments: m,
|
|
7
|
-
currentUserId:
|
|
7
|
+
currentUserId: s,
|
|
8
8
|
onSubmit: o,
|
|
9
9
|
onEdit: _,
|
|
10
|
-
onDelete:
|
|
10
|
+
onDelete: N,
|
|
11
11
|
onReact: r,
|
|
12
12
|
readOnly: w = !1,
|
|
13
|
-
maxDepth:
|
|
14
|
-
reactions:
|
|
13
|
+
maxDepth: E = 4,
|
|
14
|
+
reactions: $ = ["👍", "❤️", "😂", "😮", "😢"],
|
|
15
15
|
placeholder: b = "Write a comment…",
|
|
16
16
|
className: C,
|
|
17
|
-
style:
|
|
18
|
-
} =
|
|
17
|
+
style: x
|
|
18
|
+
} = u, [v, i] = L(""), [h, g] = L(null), [a, t] = L(""), [c, n] = L(null), [k, I] = L(""), F = /* @__PURE__ */ new Map();
|
|
19
19
|
for (const d of m) {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const M = d.parentId ?? "__root__";
|
|
21
|
+
F.has(M) || F.set(M, []), F.get(M).push(d);
|
|
22
22
|
}
|
|
23
23
|
const j = D(() => {
|
|
24
24
|
!v.trim() || !o || (o(v.trim()), i(""));
|
|
25
25
|
}, [v, o]), z = D(() => {
|
|
26
|
-
!
|
|
27
|
-
}, [
|
|
28
|
-
!
|
|
29
|
-
}, [
|
|
30
|
-
const
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */
|
|
26
|
+
!a.trim() || !o || !h || (o(a.trim(), h), t(""), g(null));
|
|
27
|
+
}, [a, h, o]), S = D(() => {
|
|
28
|
+
!c || !k.trim() || !_ || (_(c, k.trim()), n(null), I(""));
|
|
29
|
+
}, [c, k, _]), O = (d, M) => {
|
|
30
|
+
const R = s && d.authorId === s, p = F.get(d.id) ?? [];
|
|
31
|
+
return /* @__PURE__ */ l("div", { className: "nice-comments__item", style: { marginLeft: M * 24 }, children: [
|
|
32
|
+
/* @__PURE__ */ l("div", { className: "nice-comments__header", children: [
|
|
33
33
|
d.authorAvatarUrl && /* @__PURE__ */ e("img", { src: d.authorAvatarUrl, alt: "", className: "nice-comments__avatar" }),
|
|
34
34
|
/* @__PURE__ */ e("strong", { className: "nice-comments__author", children: d.authorName }),
|
|
35
35
|
/* @__PURE__ */ e("time", { className: "nice-comments__time", children: d.createdAt }),
|
|
36
36
|
d.isEdited && /* @__PURE__ */ e("span", { className: "nice-comments__edited", children: "(edited)" })
|
|
37
37
|
] }),
|
|
38
|
-
|
|
39
|
-
/* @__PURE__ */ e("textarea", { value: k, onChange: (y) =>
|
|
40
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
41
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
38
|
+
c === d.id ? /* @__PURE__ */ l("div", { className: "nice-comments__edit-form", children: [
|
|
39
|
+
/* @__PURE__ */ e("textarea", { value: k, onChange: (y) => I(y.target.value) }),
|
|
40
|
+
/* @__PURE__ */ e("button", { onClick: S, children: "Save" }),
|
|
41
|
+
/* @__PURE__ */ e("button", { onClick: () => n(null), children: "Cancel" })
|
|
42
42
|
] }) : /* @__PURE__ */ e("p", { className: "nice-comments__content", children: d.isDeleted ? /* @__PURE__ */ e("em", { children: "Comment deleted" }) : d.content }),
|
|
43
|
-
!d.isDeleted && d.reactions && /* @__PURE__ */ e("div", { className: "nice-comments__reactions", children: Object.entries(d.reactions).map(([y, f]) => /* @__PURE__ */
|
|
43
|
+
!d.isDeleted && d.reactions && /* @__PURE__ */ e("div", { className: "nice-comments__reactions", children: Object.entries(d.reactions).map(([y, f]) => /* @__PURE__ */ l(
|
|
44
44
|
"button",
|
|
45
45
|
{
|
|
46
46
|
className: "nice-comments__reaction",
|
|
@@ -53,45 +53,45 @@ const ee = R(
|
|
|
53
53
|
},
|
|
54
54
|
y
|
|
55
55
|
)) }),
|
|
56
|
-
!d.isDeleted && !w && /* @__PURE__ */
|
|
57
|
-
r &&
|
|
58
|
-
|
|
56
|
+
!d.isDeleted && !w && /* @__PURE__ */ l("div", { className: "nice-comments__actions", children: [
|
|
57
|
+
r && $.map((y) => /* @__PURE__ */ e("button", { onClick: () => r(d.id, y), title: y, children: y }, y)),
|
|
58
|
+
M < E && /* @__PURE__ */ e(
|
|
59
59
|
"button",
|
|
60
60
|
{
|
|
61
61
|
onClick: () => {
|
|
62
|
-
|
|
62
|
+
g(d.id), t("");
|
|
63
63
|
},
|
|
64
64
|
children: "Reply"
|
|
65
65
|
}
|
|
66
66
|
),
|
|
67
|
-
|
|
67
|
+
R && _ && /* @__PURE__ */ e(
|
|
68
68
|
"button",
|
|
69
69
|
{
|
|
70
70
|
onClick: () => {
|
|
71
|
-
|
|
71
|
+
n(d.id), I(d.content);
|
|
72
72
|
},
|
|
73
73
|
children: "Edit"
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
|
-
|
|
76
|
+
R && N && /* @__PURE__ */ e("button", { onClick: () => N(d.id), children: "Delete" })
|
|
77
77
|
] }),
|
|
78
|
-
h === d.id && /* @__PURE__ */
|
|
78
|
+
h === d.id && /* @__PURE__ */ l("div", { className: "nice-comments__reply-form", children: [
|
|
79
79
|
/* @__PURE__ */ e(
|
|
80
80
|
"textarea",
|
|
81
81
|
{
|
|
82
|
-
value:
|
|
82
|
+
value: a,
|
|
83
83
|
onChange: (y) => t(y.target.value),
|
|
84
84
|
placeholder: "Write a reply…"
|
|
85
85
|
}
|
|
86
86
|
),
|
|
87
|
-
/* @__PURE__ */ e("button", { onClick: z, disabled: !
|
|
88
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
87
|
+
/* @__PURE__ */ e("button", { onClick: z, disabled: !a.trim(), children: "Send" }),
|
|
88
|
+
/* @__PURE__ */ e("button", { onClick: () => g(null), children: "Cancel" })
|
|
89
89
|
] }),
|
|
90
|
-
|
|
90
|
+
p.map((y) => O(y, M + 1))
|
|
91
91
|
] }, d.id);
|
|
92
|
-
},
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
!w && /* @__PURE__ */
|
|
92
|
+
}, U = F.get("__root__") ?? [];
|
|
93
|
+
return /* @__PURE__ */ l("div", { ref: T, className: `nice-comments ${C ?? ""}`, style: x, children: [
|
|
94
|
+
!w && /* @__PURE__ */ l("div", { className: "nice-comments__new", children: [
|
|
95
95
|
/* @__PURE__ */ e(
|
|
96
96
|
"textarea",
|
|
97
97
|
{
|
|
@@ -102,173 +102,194 @@ const ee = R(
|
|
|
102
102
|
),
|
|
103
103
|
/* @__PURE__ */ e("button", { onClick: j, disabled: !v.trim(), children: "Post" })
|
|
104
104
|
] }),
|
|
105
|
-
|
|
105
|
+
U.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-comments__empty", children: "No comments yet." }) : U.map((d) => O(d, 0))
|
|
106
106
|
] });
|
|
107
107
|
}
|
|
108
|
-
), V =
|
|
109
|
-
|
|
108
|
+
), V = {
|
|
109
|
+
star: "polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 79% 94%, 50% 73%, 21% 94%, 31% 59%, 2% 37%, 38% 36%)",
|
|
110
|
+
heart: "polygon(50% 92%, 12% 54%, 4% 40%, 4% 25%, 10% 13%, 22% 6%, 34% 6%, 44% 12%, 50% 21%, 56% 12%, 66% 6%, 78% 6%, 90% 13%, 96% 25%, 96% 40%, 88% 54%)",
|
|
111
|
+
share: "polygon(42% 8%, 92% 8%, 92% 58%, 75% 41%, 27% 89%, 11% 73%, 59% 25%)"
|
|
112
|
+
}, K = ({
|
|
113
|
+
shape: A,
|
|
114
|
+
filled: u = !0
|
|
115
|
+
}) => /* @__PURE__ */ e(
|
|
116
|
+
"span",
|
|
117
|
+
{
|
|
118
|
+
"aria-hidden": "true",
|
|
119
|
+
className: `nice-social-shape nice-social-shape--${A}`,
|
|
120
|
+
style: {
|
|
121
|
+
display: "inline-block",
|
|
122
|
+
width: "1em",
|
|
123
|
+
height: "1em",
|
|
124
|
+
verticalAlign: "-0.125em",
|
|
125
|
+
background: "currentColor",
|
|
126
|
+
clipPath: V[A],
|
|
127
|
+
opacity: u ? 1 : 0.35
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
), Z = W(
|
|
131
|
+
function(u, T) {
|
|
110
132
|
const {
|
|
111
133
|
value: m,
|
|
112
|
-
max:
|
|
134
|
+
max: s = 5,
|
|
113
135
|
mode: o = "stars",
|
|
114
136
|
aggregation: _,
|
|
115
|
-
onChange:
|
|
137
|
+
onChange: N,
|
|
116
138
|
readOnly: r = !1,
|
|
117
139
|
size: w = "md",
|
|
118
|
-
showValue:
|
|
119
|
-
label:
|
|
140
|
+
showValue: E = !1,
|
|
141
|
+
label: $,
|
|
120
142
|
emojiSet: b = ["😢", "😕", "😐", "🙂", "😍"],
|
|
121
143
|
className: C,
|
|
122
|
-
style:
|
|
123
|
-
} =
|
|
124
|
-
(
|
|
125
|
-
r || !
|
|
144
|
+
style: x
|
|
145
|
+
} = u, [v, i] = L(null), h = v !== null ? v + 1 : m ?? 0, g = D(
|
|
146
|
+
(c) => {
|
|
147
|
+
r || !N || N(c + 1);
|
|
126
148
|
},
|
|
127
|
-
[r,
|
|
128
|
-
),
|
|
129
|
-
const
|
|
130
|
-
for (let
|
|
131
|
-
const k =
|
|
132
|
-
let
|
|
133
|
-
o === "emoji" ?
|
|
149
|
+
[r, N]
|
|
150
|
+
), a = () => {
|
|
151
|
+
const c = [];
|
|
152
|
+
for (let n = 0; n < s; n++) {
|
|
153
|
+
const k = n < h;
|
|
154
|
+
let I;
|
|
155
|
+
o === "emoji" ? I = b[n] ?? b[b.length - 1] : o === "hearts" ? I = /* @__PURE__ */ e(K, { shape: "heart", filled: k }) : o === "thumbs" ? I = k ? "👍" : "👎" : I = /* @__PURE__ */ e(K, { shape: "star", filled: k }), c.push(
|
|
134
156
|
/* @__PURE__ */ e(
|
|
135
157
|
"span",
|
|
136
158
|
{
|
|
137
159
|
className: `nice-ratings__symbol ${k ? "nice-ratings__symbol--active" : ""}`,
|
|
138
|
-
onClick: () =>
|
|
139
|
-
onMouseEnter: () => !r && i(
|
|
160
|
+
onClick: () => g(n),
|
|
161
|
+
onMouseEnter: () => !r && i(n),
|
|
140
162
|
onMouseLeave: () => !r && i(null),
|
|
141
163
|
role: r ? void 0 : "button",
|
|
142
164
|
tabIndex: r ? void 0 : 0,
|
|
143
|
-
onKeyDown: (
|
|
144
|
-
(
|
|
165
|
+
onKeyDown: (F) => {
|
|
166
|
+
(F.key === "Enter" || F.key === " ") && g(n);
|
|
145
167
|
},
|
|
146
|
-
children:
|
|
168
|
+
children: I
|
|
147
169
|
},
|
|
148
|
-
|
|
170
|
+
n
|
|
149
171
|
)
|
|
150
172
|
);
|
|
151
173
|
}
|
|
152
|
-
return
|
|
153
|
-
}, t = () => /* @__PURE__ */
|
|
174
|
+
return c;
|
|
175
|
+
}, t = () => /* @__PURE__ */ l("div", { className: "nice-ratings__numeric", children: [
|
|
154
176
|
/* @__PURE__ */ e(
|
|
155
177
|
"input",
|
|
156
178
|
{
|
|
157
179
|
type: "number",
|
|
158
180
|
min: 0,
|
|
159
|
-
max:
|
|
181
|
+
max: s,
|
|
160
182
|
step: 0.5,
|
|
161
183
|
value: m ?? 0,
|
|
162
|
-
onChange: (
|
|
184
|
+
onChange: (c) => N == null ? void 0 : N(parseFloat(c.target.value) || 0),
|
|
163
185
|
readOnly: r,
|
|
164
186
|
className: "nice-ratings__numeric-input"
|
|
165
187
|
}
|
|
166
188
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ l("span", { className: "nice-ratings__numeric-max", children: [
|
|
168
190
|
"/ ",
|
|
169
|
-
|
|
191
|
+
s
|
|
170
192
|
] })
|
|
171
193
|
] });
|
|
172
|
-
return /* @__PURE__ */
|
|
194
|
+
return /* @__PURE__ */ l(
|
|
173
195
|
"div",
|
|
174
196
|
{
|
|
175
|
-
ref:
|
|
197
|
+
ref: T,
|
|
176
198
|
className: `nice-ratings nice-ratings--${w} nice-ratings--${o} ${r ? "nice-ratings--readonly" : ""} ${C ?? ""}`,
|
|
177
|
-
style:
|
|
199
|
+
style: x,
|
|
178
200
|
children: [
|
|
179
|
-
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
o === "numeric" ? t() :
|
|
182
|
-
|
|
201
|
+
$ && /* @__PURE__ */ e("span", { className: "nice-ratings__label", children: $ }),
|
|
202
|
+
/* @__PURE__ */ l("div", { className: "nice-ratings__body", children: [
|
|
203
|
+
o === "numeric" ? t() : a(),
|
|
204
|
+
E && o !== "numeric" && /* @__PURE__ */ l("span", { className: "nice-ratings__value", children: [
|
|
183
205
|
h,
|
|
184
206
|
" / ",
|
|
185
|
-
|
|
207
|
+
s
|
|
186
208
|
] })
|
|
187
209
|
] }),
|
|
188
|
-
_ && /* @__PURE__ */
|
|
210
|
+
_ && /* @__PURE__ */ l("div", { className: "nice-ratings__aggregation", children: [
|
|
189
211
|
/* @__PURE__ */ e("span", { className: "nice-ratings__avg", children: _.average.toFixed(1) }),
|
|
190
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ l("span", { className: "nice-ratings__count", children: [
|
|
191
213
|
"(",
|
|
192
214
|
_.count,
|
|
193
215
|
" ratings)"
|
|
194
216
|
] }),
|
|
195
|
-
_.distribution && /* @__PURE__ */ e("div", { className: "nice-ratings__distribution", children: Object.entries(_.distribution).sort(([
|
|
196
|
-
/* @__PURE__ */ e("span", { children:
|
|
217
|
+
_.distribution && /* @__PURE__ */ e("div", { className: "nice-ratings__distribution", children: Object.entries(_.distribution).sort(([c], [n]) => +n - +c).map(([c, n]) => /* @__PURE__ */ l("div", { className: "nice-ratings__distribution-row", children: [
|
|
218
|
+
/* @__PURE__ */ e("span", { children: c }),
|
|
197
219
|
/* @__PURE__ */ e("div", { className: "nice-ratings__bar", children: /* @__PURE__ */ e(
|
|
198
220
|
"div",
|
|
199
221
|
{
|
|
200
222
|
className: "nice-ratings__bar-fill",
|
|
201
223
|
style: {
|
|
202
|
-
width: `${_.count ?
|
|
224
|
+
width: `${_.count ? n / _.count * 100 : 0}%`
|
|
203
225
|
}
|
|
204
226
|
}
|
|
205
227
|
) }),
|
|
206
|
-
/* @__PURE__ */ e("span", { children:
|
|
207
|
-
] },
|
|
228
|
+
/* @__PURE__ */ e("span", { children: n })
|
|
229
|
+
] }, c)) })
|
|
208
230
|
] })
|
|
209
231
|
]
|
|
210
232
|
}
|
|
211
233
|
);
|
|
212
234
|
}
|
|
213
|
-
),
|
|
214
|
-
function(
|
|
235
|
+
), ee = W(
|
|
236
|
+
function(u, T) {
|
|
215
237
|
const {
|
|
216
238
|
stats: m,
|
|
217
|
-
userState:
|
|
239
|
+
userState: s,
|
|
218
240
|
onLike: o,
|
|
219
241
|
onShare: _,
|
|
220
|
-
onBookmark:
|
|
242
|
+
onBookmark: N,
|
|
221
243
|
direction: r = "horizontal",
|
|
222
244
|
size: w = "md",
|
|
223
|
-
showCounts:
|
|
224
|
-
showLabels:
|
|
245
|
+
showCounts: E = !0,
|
|
246
|
+
showLabels: $ = !1,
|
|
225
247
|
className: b,
|
|
226
248
|
style: C
|
|
227
|
-
} =
|
|
249
|
+
} = u, x = D((i) => i >= 1e6 ? (i / 1e6).toFixed(1) + "M" : i >= 1e3 ? (i / 1e3).toFixed(1) + "K" : i.toString(), []), v = [
|
|
228
250
|
{
|
|
229
251
|
key: "like",
|
|
230
|
-
|
|
231
|
-
activeIcon: "♥",
|
|
252
|
+
shape: "heart",
|
|
232
253
|
label: "Like",
|
|
233
254
|
count: m.likes,
|
|
234
|
-
isActive: (
|
|
255
|
+
isActive: (s == null ? void 0 : s.liked) ?? !1,
|
|
235
256
|
onClick: o
|
|
236
257
|
},
|
|
237
258
|
{
|
|
238
259
|
key: "share",
|
|
239
|
-
|
|
240
|
-
activeIcon: "↗",
|
|
260
|
+
shape: "share",
|
|
241
261
|
label: "Share",
|
|
242
262
|
count: m.shares,
|
|
243
|
-
isActive: (
|
|
263
|
+
isActive: (s == null ? void 0 : s.shared) ?? !1,
|
|
244
264
|
onClick: _
|
|
245
265
|
},
|
|
246
266
|
{
|
|
247
267
|
key: "bookmark",
|
|
248
|
-
|
|
249
|
-
activeIcon: "★",
|
|
268
|
+
shape: "star",
|
|
250
269
|
label: "Bookmark",
|
|
251
270
|
count: m.bookmarks,
|
|
252
|
-
isActive: (
|
|
253
|
-
onClick:
|
|
271
|
+
isActive: (s == null ? void 0 : s.bookmarked) ?? !1,
|
|
272
|
+
onClick: N
|
|
254
273
|
}
|
|
255
274
|
];
|
|
256
275
|
return /* @__PURE__ */ e(
|
|
257
276
|
"div",
|
|
258
277
|
{
|
|
259
|
-
ref:
|
|
278
|
+
ref: T,
|
|
260
279
|
className: `nice-social-panel nice-social-panel--${r} nice-social-panel--${w} ${b ?? ""}`,
|
|
261
280
|
style: C,
|
|
262
|
-
children: v.map((i) => /* @__PURE__ */
|
|
281
|
+
children: v.map((i) => /* @__PURE__ */ l(
|
|
263
282
|
"button",
|
|
264
283
|
{
|
|
265
284
|
className: `nice-social-panel__btn nice-social-panel__btn--${i.key} ${i.isActive ? "nice-social-panel__btn--active" : ""}`,
|
|
266
285
|
onClick: i.onClick,
|
|
267
286
|
title: i.label,
|
|
287
|
+
"aria-label": i.label,
|
|
288
|
+
"aria-pressed": i.isActive,
|
|
268
289
|
children: [
|
|
269
|
-
/* @__PURE__ */ e("span", { className: "nice-social-panel__icon", children: i.
|
|
270
|
-
|
|
271
|
-
|
|
290
|
+
/* @__PURE__ */ e("span", { className: "nice-social-panel__icon", children: /* @__PURE__ */ e(K, { shape: i.shape, filled: i.isActive || i.shape === "share" }) }),
|
|
291
|
+
$ && /* @__PURE__ */ e("span", { className: "nice-social-panel__label", children: i.label }),
|
|
292
|
+
E && /* @__PURE__ */ e("span", { className: "nice-social-panel__count", children: x(i.count) })
|
|
272
293
|
]
|
|
273
294
|
},
|
|
274
295
|
i.key
|
|
@@ -276,57 +297,57 @@ const ee = R(
|
|
|
276
297
|
}
|
|
277
298
|
);
|
|
278
299
|
}
|
|
279
|
-
),
|
|
280
|
-
function(
|
|
300
|
+
), ie = W(
|
|
301
|
+
function(u, T) {
|
|
281
302
|
const {
|
|
282
303
|
tags: m,
|
|
283
|
-
onTagClick:
|
|
304
|
+
onTagClick: s,
|
|
284
305
|
minFontSize: o = 12,
|
|
285
306
|
maxFontSize: _ = 36,
|
|
286
|
-
sortBy:
|
|
307
|
+
sortBy: N = "weight",
|
|
287
308
|
maxTags: r,
|
|
288
309
|
selectedIds: w,
|
|
289
|
-
className:
|
|
290
|
-
style:
|
|
291
|
-
} =
|
|
310
|
+
className: E,
|
|
311
|
+
style: $
|
|
312
|
+
} = u, b = P(() => {
|
|
292
313
|
let i = [...m];
|
|
293
|
-
if (
|
|
294
|
-
i.sort((h,
|
|
295
|
-
else if (
|
|
296
|
-
i.sort((h,
|
|
314
|
+
if (N === "weight")
|
|
315
|
+
i.sort((h, g) => g.weight - h.weight);
|
|
316
|
+
else if (N === "alphabetical")
|
|
317
|
+
i.sort((h, g) => h.label.localeCompare(g.label));
|
|
297
318
|
else
|
|
298
319
|
for (let h = i.length - 1; h > 0; h--) {
|
|
299
|
-
const
|
|
300
|
-
[i[h], i[
|
|
320
|
+
const g = Math.floor(Math.random() * (h + 1));
|
|
321
|
+
[i[h], i[g]] = [i[g], i[h]];
|
|
301
322
|
}
|
|
302
323
|
return r && i.length > r && (i = i.slice(0, r)), i;
|
|
303
|
-
}, [m,
|
|
324
|
+
}, [m, N, r]), { minW: C, maxW: x } = P(() => {
|
|
304
325
|
if (b.length === 0)
|
|
305
326
|
return { minW: 0, maxW: 1 };
|
|
306
327
|
const i = b.map((h) => h.weight);
|
|
307
328
|
return { minW: Math.min(...i), maxW: Math.max(...i) };
|
|
308
329
|
}, [b]), v = (i) => {
|
|
309
|
-
if (
|
|
330
|
+
if (x === C)
|
|
310
331
|
return (o + _) / 2;
|
|
311
|
-
const h = (i - C) / (
|
|
332
|
+
const h = (i - C) / (x - C);
|
|
312
333
|
return o + h * (_ - o);
|
|
313
334
|
};
|
|
314
|
-
return /* @__PURE__ */ e("div", { ref:
|
|
315
|
-
const h = w == null ? void 0 : w.includes(i.id),
|
|
335
|
+
return /* @__PURE__ */ e("div", { ref: T, className: `nice-tag-cloud ${E ?? ""}`, style: $, children: b.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-tag-cloud__empty", children: "No tags." }) : b.map((i) => {
|
|
336
|
+
const h = w == null ? void 0 : w.includes(i.id), g = v(i.weight);
|
|
316
337
|
return /* @__PURE__ */ e(
|
|
317
338
|
"span",
|
|
318
339
|
{
|
|
319
340
|
className: `nice-tag-cloud__tag ${h ? "nice-tag-cloud__tag--selected" : ""}`,
|
|
320
341
|
style: {
|
|
321
|
-
fontSize:
|
|
342
|
+
fontSize: g,
|
|
322
343
|
color: i.color,
|
|
323
|
-
cursor:
|
|
344
|
+
cursor: s ? "pointer" : void 0
|
|
324
345
|
},
|
|
325
|
-
onClick: () =>
|
|
326
|
-
role:
|
|
327
|
-
tabIndex:
|
|
328
|
-
onKeyDown: (
|
|
329
|
-
(
|
|
346
|
+
onClick: () => s == null ? void 0 : s(i),
|
|
347
|
+
role: s ? "button" : void 0,
|
|
348
|
+
tabIndex: s ? 0 : void 0,
|
|
349
|
+
onKeyDown: (a) => {
|
|
350
|
+
(a.key === "Enter" || a.key === " ") && s && s(i);
|
|
330
351
|
},
|
|
331
352
|
title: `${i.label} (${i.weight})`,
|
|
332
353
|
children: i.label
|
|
@@ -335,79 +356,79 @@ const ee = R(
|
|
|
335
356
|
);
|
|
336
357
|
}) });
|
|
337
358
|
}
|
|
338
|
-
),
|
|
359
|
+
), q = {
|
|
339
360
|
online: "#22c55e",
|
|
340
361
|
away: "#eab308",
|
|
341
362
|
busy: "#ef4444",
|
|
342
363
|
offline: "#9ca3af"
|
|
343
|
-
},
|
|
344
|
-
function(
|
|
364
|
+
}, te = W(
|
|
365
|
+
function(u, T) {
|
|
345
366
|
const {
|
|
346
367
|
users: m,
|
|
347
|
-
onUserClick:
|
|
368
|
+
onUserClick: s,
|
|
348
369
|
onAction: o,
|
|
349
370
|
actions: _ = [],
|
|
350
|
-
searchable:
|
|
371
|
+
searchable: N = !1,
|
|
351
372
|
statusFilter: r,
|
|
352
373
|
showStatus: w = !0,
|
|
353
|
-
layout:
|
|
354
|
-
groupByRole:
|
|
374
|
+
layout: E = "list",
|
|
375
|
+
groupByRole: $ = !1,
|
|
355
376
|
className: b,
|
|
356
377
|
style: C
|
|
357
|
-
} =
|
|
358
|
-
let
|
|
359
|
-
if (r && r.length > 0 && (
|
|
360
|
-
const t =
|
|
361
|
-
|
|
362
|
-
(
|
|
363
|
-
var
|
|
364
|
-
return
|
|
378
|
+
} = u, [x, v] = L(""), i = P(() => {
|
|
379
|
+
let a = m;
|
|
380
|
+
if (r && r.length > 0 && (a = a.filter((t) => t.status && r.includes(t.status))), x.trim()) {
|
|
381
|
+
const t = x.toLowerCase();
|
|
382
|
+
a = a.filter(
|
|
383
|
+
(c) => {
|
|
384
|
+
var n, k;
|
|
385
|
+
return c.name.toLowerCase().includes(t) || ((n = c.email) == null ? void 0 : n.toLowerCase().includes(t)) || ((k = c.role) == null ? void 0 : k.toLowerCase().includes(t));
|
|
365
386
|
}
|
|
366
387
|
);
|
|
367
388
|
}
|
|
368
|
-
return
|
|
369
|
-
}, [m, r,
|
|
370
|
-
if (
|
|
389
|
+
return a;
|
|
390
|
+
}, [m, r, x]), h = P(() => {
|
|
391
|
+
if (!$)
|
|
371
392
|
return { "": i };
|
|
372
|
-
const
|
|
393
|
+
const a = {};
|
|
373
394
|
for (const t of i) {
|
|
374
|
-
const
|
|
375
|
-
|
|
395
|
+
const c = t.role ?? "Other";
|
|
396
|
+
a[c] || (a[c] = []), a[c].push(t);
|
|
376
397
|
}
|
|
377
|
-
return
|
|
378
|
-
}, [i,
|
|
398
|
+
return a;
|
|
399
|
+
}, [i, $]), g = (a) => /* @__PURE__ */ l(
|
|
379
400
|
"div",
|
|
380
401
|
{
|
|
381
|
-
className: `nice-user-list__item nice-user-list__item--${
|
|
382
|
-
onClick: () =>
|
|
383
|
-
role:
|
|
384
|
-
tabIndex:
|
|
402
|
+
className: `nice-user-list__item nice-user-list__item--${E}`,
|
|
403
|
+
onClick: () => s == null ? void 0 : s(a),
|
|
404
|
+
role: s ? "button" : void 0,
|
|
405
|
+
tabIndex: s ? 0 : void 0,
|
|
385
406
|
onKeyDown: (t) => {
|
|
386
|
-
t.key === "Enter" &&
|
|
407
|
+
t.key === "Enter" && s && s(a);
|
|
387
408
|
},
|
|
388
409
|
children: [
|
|
389
|
-
/* @__PURE__ */
|
|
390
|
-
|
|
391
|
-
w &&
|
|
410
|
+
/* @__PURE__ */ l("div", { className: "nice-user-list__avatar-wrap", children: [
|
|
411
|
+
a.avatarUrl ? /* @__PURE__ */ e("img", { src: a.avatarUrl, alt: a.name, className: "nice-user-list__avatar" }) : /* @__PURE__ */ e("span", { className: "nice-user-list__avatar-placeholder", children: a.name.charAt(0).toUpperCase() }),
|
|
412
|
+
w && a.status && /* @__PURE__ */ e(
|
|
392
413
|
"span",
|
|
393
414
|
{
|
|
394
415
|
className: "nice-user-list__status-dot",
|
|
395
|
-
style: { backgroundColor:
|
|
396
|
-
title:
|
|
416
|
+
style: { backgroundColor: q[a.status] },
|
|
417
|
+
title: a.status
|
|
397
418
|
}
|
|
398
419
|
)
|
|
399
420
|
] }),
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
/* @__PURE__ */ e("span", { className: "nice-user-list__name", children:
|
|
402
|
-
|
|
403
|
-
|
|
421
|
+
/* @__PURE__ */ l("div", { className: "nice-user-list__info", children: [
|
|
422
|
+
/* @__PURE__ */ e("span", { className: "nice-user-list__name", children: a.name }),
|
|
423
|
+
a.email && /* @__PURE__ */ e("span", { className: "nice-user-list__email", children: a.email }),
|
|
424
|
+
a.role && /* @__PURE__ */ e("span", { className: "nice-user-list__role", children: a.role })
|
|
404
425
|
] }),
|
|
405
426
|
_.length > 0 && /* @__PURE__ */ e("div", { className: "nice-user-list__actions", children: _.map((t) => /* @__PURE__ */ e(
|
|
406
427
|
"button",
|
|
407
428
|
{
|
|
408
429
|
className: "nice-user-list__action-btn",
|
|
409
|
-
onClick: (
|
|
410
|
-
|
|
430
|
+
onClick: (c) => {
|
|
431
|
+
c.stopPropagation(), o == null || o(a, t);
|
|
411
432
|
},
|
|
412
433
|
children: t
|
|
413
434
|
},
|
|
@@ -415,247 +436,243 @@ const ee = R(
|
|
|
415
436
|
)) })
|
|
416
437
|
]
|
|
417
438
|
},
|
|
418
|
-
|
|
439
|
+
a.id
|
|
419
440
|
);
|
|
420
|
-
return /* @__PURE__ */
|
|
441
|
+
return /* @__PURE__ */ l(
|
|
421
442
|
"div",
|
|
422
443
|
{
|
|
423
|
-
ref:
|
|
424
|
-
className: `nice-user-list nice-user-list--${
|
|
444
|
+
ref: T,
|
|
445
|
+
className: `nice-user-list nice-user-list--${E} ${b ?? ""}`,
|
|
425
446
|
style: C,
|
|
426
447
|
children: [
|
|
427
|
-
|
|
448
|
+
N && /* @__PURE__ */ e(
|
|
428
449
|
"input",
|
|
429
450
|
{
|
|
430
451
|
type: "text",
|
|
431
|
-
value:
|
|
432
|
-
onChange: (
|
|
452
|
+
value: x,
|
|
453
|
+
onChange: (a) => v(a.target.value),
|
|
433
454
|
placeholder: "Search users…",
|
|
434
455
|
className: "nice-user-list__search"
|
|
435
456
|
}
|
|
436
457
|
),
|
|
437
|
-
i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-user-list__empty", children: "No users found." }) : Object.entries(h).map(([
|
|
438
|
-
|
|
439
|
-
|
|
458
|
+
i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-user-list__empty", children: "No users found." }) : Object.entries(h).map(([a, t]) => /* @__PURE__ */ l("div", { className: "nice-user-list__group", children: [
|
|
459
|
+
$ && a && /* @__PURE__ */ l("h4", { className: "nice-user-list__group-title", children: [
|
|
460
|
+
a,
|
|
440
461
|
" (",
|
|
441
462
|
t.length,
|
|
442
463
|
")"
|
|
443
464
|
] }),
|
|
444
|
-
t.map(
|
|
445
|
-
] },
|
|
465
|
+
t.map(g)
|
|
466
|
+
] }, a))
|
|
446
467
|
]
|
|
447
468
|
}
|
|
448
469
|
);
|
|
449
470
|
}
|
|
450
471
|
);
|
|
451
|
-
function
|
|
452
|
-
if (!
|
|
472
|
+
function Y(A) {
|
|
473
|
+
if (!A)
|
|
453
474
|
return "";
|
|
454
|
-
let
|
|
455
|
-
return
|
|
475
|
+
let u = A;
|
|
476
|
+
return u = u.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ""), u = u.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, ""), u = u.replace(/(href|src|action)\s*=\s*(?:"javascript:[^"]*"|'javascript:[^']*')/gi, '$1=""'), u = u.replace(/(href|src|action)\s*=\s*(?:"vbscript:[^"]*"|'vbscript:[^']*')/gi, '$1=""'), u = u.replace(/<\/?(iframe|object|embed|form)\b[^>]*>/gi, ""), u;
|
|
456
477
|
}
|
|
457
|
-
const
|
|
478
|
+
const ae = W(function(u, T) {
|
|
458
479
|
const {
|
|
459
480
|
pages: m,
|
|
460
|
-
selectedPageId:
|
|
481
|
+
selectedPageId: s,
|
|
461
482
|
onSelectPage: o,
|
|
462
483
|
onSavePage: _,
|
|
463
|
-
onDeletePage:
|
|
484
|
+
onDeletePage: N,
|
|
464
485
|
onCreatePage: r,
|
|
465
486
|
editable: w = !1,
|
|
466
|
-
searchable:
|
|
467
|
-
renderHtml:
|
|
487
|
+
searchable: E = !0,
|
|
488
|
+
renderHtml: $ = !1,
|
|
468
489
|
sidebarWidth: b = 260,
|
|
469
490
|
className: C,
|
|
470
|
-
style:
|
|
471
|
-
} =
|
|
491
|
+
style: x
|
|
492
|
+
} = u, [v, i] = L(""), [h, g] = L(!1), [a, t] = L(""), [c, n] = L(""), [k, I] = L(""), [F, j] = L(!1), z = P(() => {
|
|
472
493
|
if (m.some((f) => f.children && f.children.length > 0))
|
|
473
494
|
return m.filter((f) => !f.parentId);
|
|
474
|
-
const
|
|
495
|
+
const p = /* @__PURE__ */ new Map();
|
|
475
496
|
for (const f of m)
|
|
476
|
-
|
|
497
|
+
p.set(f.id, { ...f, children: [] });
|
|
477
498
|
const y = [];
|
|
478
|
-
for (const f of
|
|
479
|
-
f.parentId &&
|
|
499
|
+
for (const f of p.values())
|
|
500
|
+
f.parentId && p.has(f.parentId) ? p.get(f.parentId).children.push(f) : y.push(f);
|
|
480
501
|
return y;
|
|
481
|
-
}, [m]),
|
|
482
|
-
() => m.find((
|
|
483
|
-
[m,
|
|
484
|
-
),
|
|
502
|
+
}, [m]), S = P(
|
|
503
|
+
() => m.find((p) => p.id === s),
|
|
504
|
+
[m, s]
|
|
505
|
+
), O = P(() => {
|
|
485
506
|
if (!v.trim())
|
|
486
507
|
return z;
|
|
487
|
-
const
|
|
488
|
-
m.filter((f) => f.title.toLowerCase().includes(
|
|
508
|
+
const p = v.toLowerCase(), y = new Set(
|
|
509
|
+
m.filter((f) => f.title.toLowerCase().includes(p)).map((f) => f.id)
|
|
489
510
|
);
|
|
490
511
|
return m.filter((f) => y.has(f.id));
|
|
491
|
-
}, [z, m, v]),
|
|
492
|
-
|
|
493
|
-
}, [
|
|
494
|
-
!
|
|
495
|
-
}, [
|
|
496
|
-
!k.trim() || !r || (r(
|
|
497
|
-
}, [k,
|
|
512
|
+
}, [z, m, v]), U = D(() => {
|
|
513
|
+
S && (t(S.title), n(S.content ?? ""), g(!0));
|
|
514
|
+
}, [S]), d = D(() => {
|
|
515
|
+
!S || !_ || (_(S.id, c, a), g(!1));
|
|
516
|
+
}, [S, c, a, _]), M = D(() => {
|
|
517
|
+
!k.trim() || !r || (r(s ?? null, k.trim()), I(""), j(!1));
|
|
518
|
+
}, [k, s, r]), R = (p, y = 0) => {
|
|
498
519
|
var f;
|
|
499
|
-
return /* @__PURE__ */
|
|
520
|
+
return /* @__PURE__ */ l("div", { children: [
|
|
500
521
|
/* @__PURE__ */ e(
|
|
501
522
|
"div",
|
|
502
523
|
{
|
|
503
|
-
className: `nice-wiki__page-item ${
|
|
524
|
+
className: `nice-wiki__page-item ${p.id === s ? "nice-wiki__page-item--active" : ""}`,
|
|
504
525
|
style: { paddingLeft: 12 + y * 16 },
|
|
505
|
-
onClick: () => o == null ? void 0 : o(
|
|
526
|
+
onClick: () => o == null ? void 0 : o(p),
|
|
506
527
|
role: "button",
|
|
507
528
|
tabIndex: 0,
|
|
508
529
|
onKeyDown: (B) => {
|
|
509
|
-
B.key === "Enter" && (o == null || o(
|
|
530
|
+
B.key === "Enter" && (o == null || o(p));
|
|
510
531
|
},
|
|
511
|
-
children:
|
|
532
|
+
children: p.title
|
|
512
533
|
}
|
|
513
534
|
),
|
|
514
|
-
(f =
|
|
515
|
-
] },
|
|
535
|
+
(f = p.children) == null ? void 0 : f.map((B) => R(B, y + 1))
|
|
536
|
+
] }, p.id);
|
|
516
537
|
};
|
|
517
|
-
return /* @__PURE__ */
|
|
518
|
-
/* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ l("div", { ref: T, className: `nice-wiki ${C ?? ""}`, style: { display: "flex", ...x }, children: [
|
|
539
|
+
/* @__PURE__ */ l("div", { className: "nice-wiki__sidebar", style: { width: b, minWidth: b }, children: [
|
|
540
|
+
/* @__PURE__ */ l("div", { className: "nice-wiki__sidebar-header", children: [
|
|
520
541
|
/* @__PURE__ */ e("strong", { children: "Wiki" }),
|
|
521
|
-
w && r && /* @__PURE__ */ e("button", { onClick: () => j(!
|
|
542
|
+
w && r && /* @__PURE__ */ e("button", { onClick: () => j(!F), title: "New page", children: "+" })
|
|
522
543
|
] }),
|
|
523
|
-
|
|
544
|
+
F && /* @__PURE__ */ l("div", { className: "nice-wiki__new-page", children: [
|
|
524
545
|
/* @__PURE__ */ e(
|
|
525
546
|
"input",
|
|
526
547
|
{
|
|
527
548
|
type: "text",
|
|
528
549
|
value: k,
|
|
529
|
-
onChange: (
|
|
550
|
+
onChange: (p) => I(p.target.value),
|
|
530
551
|
placeholder: "New page title"
|
|
531
552
|
}
|
|
532
553
|
),
|
|
533
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
554
|
+
/* @__PURE__ */ e("button", { onClick: M, disabled: !k.trim(), children: "Create" })
|
|
534
555
|
] }),
|
|
535
|
-
|
|
556
|
+
E && /* @__PURE__ */ e(
|
|
536
557
|
"input",
|
|
537
558
|
{
|
|
538
559
|
type: "text",
|
|
539
560
|
className: "nice-wiki__search",
|
|
540
561
|
value: v,
|
|
541
|
-
onChange: (
|
|
562
|
+
onChange: (p) => i(p.target.value),
|
|
542
563
|
placeholder: "Search pages…"
|
|
543
564
|
}
|
|
544
565
|
),
|
|
545
|
-
/* @__PURE__ */ e("div", { className: "nice-wiki__tree", children:
|
|
566
|
+
/* @__PURE__ */ e("div", { className: "nice-wiki__tree", children: O.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-wiki__empty", children: "No pages." }) : O.map((p) => R(p)) })
|
|
546
567
|
] }),
|
|
547
|
-
/* @__PURE__ */ e("div", { className: "nice-wiki__content", children:
|
|
568
|
+
/* @__PURE__ */ e("div", { className: "nice-wiki__content", children: S ? h ? /* @__PURE__ */ l("div", { className: "nice-wiki__editor", children: [
|
|
548
569
|
/* @__PURE__ */ e(
|
|
549
570
|
"input",
|
|
550
571
|
{
|
|
551
572
|
type: "text",
|
|
552
573
|
className: "nice-wiki__edit-title",
|
|
553
|
-
value:
|
|
554
|
-
onChange: (
|
|
574
|
+
value: a,
|
|
575
|
+
onChange: (p) => t(p.target.value)
|
|
555
576
|
}
|
|
556
577
|
),
|
|
557
578
|
/* @__PURE__ */ e(
|
|
558
579
|
"textarea",
|
|
559
580
|
{
|
|
560
581
|
className: "nice-wiki__edit-body",
|
|
561
|
-
value:
|
|
562
|
-
onChange: (
|
|
582
|
+
value: c,
|
|
583
|
+
onChange: (p) => n(p.target.value),
|
|
563
584
|
rows: 20
|
|
564
585
|
}
|
|
565
586
|
),
|
|
566
|
-
/* @__PURE__ */
|
|
587
|
+
/* @__PURE__ */ l("div", { className: "nice-wiki__edit-actions", children: [
|
|
567
588
|
/* @__PURE__ */ e("button", { onClick: d, children: "Save" }),
|
|
568
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
589
|
+
/* @__PURE__ */ e("button", { onClick: () => g(!1), children: "Cancel" })
|
|
569
590
|
] })
|
|
570
|
-
] }) : /* @__PURE__ */
|
|
571
|
-
/* @__PURE__ */
|
|
572
|
-
/* @__PURE__ */ e("h2", { children:
|
|
573
|
-
/* @__PURE__ */
|
|
574
|
-
|
|
591
|
+
] }) : /* @__PURE__ */ l("div", { className: "nice-wiki__viewer", children: [
|
|
592
|
+
/* @__PURE__ */ l("div", { className: "nice-wiki__viewer-header", children: [
|
|
593
|
+
/* @__PURE__ */ e("h2", { children: S.title }),
|
|
594
|
+
/* @__PURE__ */ l("div", { className: "nice-wiki__viewer-meta", children: [
|
|
595
|
+
S.lastEditedBy && /* @__PURE__ */ l("span", { children: [
|
|
575
596
|
"Edited by ",
|
|
576
|
-
|
|
597
|
+
S.lastEditedBy
|
|
577
598
|
] }),
|
|
578
|
-
|
|
599
|
+
S.lastEditedAt && /* @__PURE__ */ l("span", { children: [
|
|
579
600
|
" on ",
|
|
580
|
-
|
|
601
|
+
S.lastEditedAt
|
|
581
602
|
] })
|
|
582
603
|
] }),
|
|
583
|
-
w && /* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
585
|
-
|
|
604
|
+
w && /* @__PURE__ */ l("div", { className: "nice-wiki__viewer-actions", children: [
|
|
605
|
+
/* @__PURE__ */ e("button", { onClick: U, children: "Edit" }),
|
|
606
|
+
N && /* @__PURE__ */ e("button", { onClick: () => N(S.id), children: "Delete" })
|
|
586
607
|
] })
|
|
587
608
|
] }),
|
|
588
|
-
|
|
609
|
+
$ ? /* @__PURE__ */ e(
|
|
589
610
|
"div",
|
|
590
611
|
{
|
|
591
612
|
className: "nice-wiki__viewer-body",
|
|
592
|
-
dangerouslySetInnerHTML: { __html:
|
|
613
|
+
dangerouslySetInnerHTML: { __html: Y(S.content ?? "") }
|
|
593
614
|
}
|
|
594
|
-
) : /* @__PURE__ */ e("div", { className: "nice-wiki__viewer-body", children:
|
|
615
|
+
) : /* @__PURE__ */ e("div", { className: "nice-wiki__viewer-body", children: S.content ?? /* @__PURE__ */ e("em", { children: "No content." }) })
|
|
595
616
|
] }) : /* @__PURE__ */ e("div", { className: "nice-wiki__placeholder", children: "Select a page from the sidebar." }) })
|
|
596
617
|
] });
|
|
597
|
-
}),
|
|
598
|
-
comment: "
|
|
599
|
-
like: "
|
|
600
|
-
share: "
|
|
601
|
-
create: "
|
|
602
|
-
update: "
|
|
603
|
-
delete: "
|
|
604
|
-
join: "
|
|
605
|
-
leave: "
|
|
606
|
-
upload: "
|
|
607
|
-
mention: "
|
|
608
|
-
custom: "
|
|
609
|
-
},
|
|
610
|
-
function(
|
|
618
|
+
}), G = {
|
|
619
|
+
comment: "var(--nice-color-primary, #3b82f6)",
|
|
620
|
+
like: "var(--nice-color-error, #ef4444)",
|
|
621
|
+
share: "var(--nice-color-info, #0ea5e9)",
|
|
622
|
+
create: "var(--nice-color-success, #22c55e)",
|
|
623
|
+
update: "var(--nice-color-warning, #f59e0b)",
|
|
624
|
+
delete: "var(--nice-color-error, #ef4444)",
|
|
625
|
+
join: "var(--nice-color-success, #22c55e)",
|
|
626
|
+
leave: "var(--nice-text-muted, #6b7280)",
|
|
627
|
+
upload: "var(--nice-color-accent, #8b5cf6)",
|
|
628
|
+
mention: "var(--nice-color-primary, #3b82f6)",
|
|
629
|
+
custom: "var(--nice-text-muted, #6b7280)"
|
|
630
|
+
}, ne = W(
|
|
631
|
+
function(u, T) {
|
|
611
632
|
const {
|
|
612
633
|
events: m,
|
|
613
|
-
onEventClick:
|
|
634
|
+
onEventClick: s,
|
|
614
635
|
groupByDate: o = !0,
|
|
615
636
|
typeFilter: _,
|
|
616
|
-
showFilters:
|
|
637
|
+
showFilters: N = !1,
|
|
617
638
|
maxEvents: r,
|
|
618
639
|
onLoadMore: w,
|
|
619
|
-
hasMore:
|
|
620
|
-
className:
|
|
640
|
+
hasMore: E = !1,
|
|
641
|
+
className: $,
|
|
621
642
|
style: b
|
|
622
|
-
} =
|
|
643
|
+
} = u, [C, x] = L(/* @__PURE__ */ new Set()), v = _ ?? (C.size > 0 ? Array.from(C) : void 0), i = P(() => {
|
|
623
644
|
let t = m;
|
|
624
645
|
if (v && v.length > 0) {
|
|
625
|
-
const
|
|
626
|
-
t = t.filter((
|
|
646
|
+
const c = new Set(v);
|
|
647
|
+
t = t.filter((n) => c.has(n.type));
|
|
627
648
|
}
|
|
628
649
|
return r && (t = t.slice(0, r)), t;
|
|
629
|
-
}, [m, v, r]), h =
|
|
650
|
+
}, [m, v, r]), h = P(() => {
|
|
630
651
|
if (!o)
|
|
631
652
|
return [{ label: "", events: i }];
|
|
632
653
|
const t = /* @__PURE__ */ new Map();
|
|
633
|
-
for (const
|
|
634
|
-
const
|
|
635
|
-
t.has(
|
|
654
|
+
for (const c of i) {
|
|
655
|
+
const n = c.timestamp.slice(0, 10);
|
|
656
|
+
t.has(n) || t.set(n, []), t.get(n).push(c);
|
|
636
657
|
}
|
|
637
|
-
return Array.from(t.entries()).map(([
|
|
638
|
-
}, [i, o]),
|
|
639
|
-
const t = new Set(m.map((
|
|
658
|
+
return Array.from(t.entries()).map(([c, n]) => ({ label: c, events: n }));
|
|
659
|
+
}, [i, o]), g = P(() => {
|
|
660
|
+
const t = new Set(m.map((c) => c.type));
|
|
640
661
|
return Array.from(t).sort();
|
|
641
|
-
}, [m]),
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
return
|
|
662
|
+
}, [m]), a = (t) => {
|
|
663
|
+
x((c) => {
|
|
664
|
+
const n = new Set(c);
|
|
665
|
+
return n.has(t) ? n.delete(t) : n.add(t), n;
|
|
645
666
|
});
|
|
646
667
|
};
|
|
647
|
-
return /* @__PURE__ */
|
|
648
|
-
|
|
649
|
-
|
|
668
|
+
return /* @__PURE__ */ l("div", { ref: T, className: `nice-activity-feed ${$ ?? ""}`, style: b, children: [
|
|
669
|
+
N && !_ && /* @__PURE__ */ l("div", { className: "nice-activity-feed__filters", children: [
|
|
670
|
+
g.map((t) => /* @__PURE__ */ e(
|
|
650
671
|
"button",
|
|
651
672
|
{
|
|
652
673
|
className: `nice-activity-feed__filter-chip ${C.has(t) ? "nice-activity-feed__filter-chip--active" : ""}`,
|
|
653
|
-
onClick: () =>
|
|
654
|
-
children:
|
|
655
|
-
K[t],
|
|
656
|
-
" ",
|
|
657
|
-
t
|
|
658
|
-
]
|
|
674
|
+
onClick: () => a(t),
|
|
675
|
+
children: t
|
|
659
676
|
},
|
|
660
677
|
t
|
|
661
678
|
)),
|
|
@@ -663,60 +680,76 @@ const se = R(function(p, I) {
|
|
|
663
680
|
"button",
|
|
664
681
|
{
|
|
665
682
|
className: "nice-activity-feed__filter-clear",
|
|
666
|
-
onClick: () =>
|
|
683
|
+
onClick: () => x(/* @__PURE__ */ new Set()),
|
|
667
684
|
children: "Clear"
|
|
668
685
|
}
|
|
669
686
|
)
|
|
670
687
|
] }),
|
|
671
|
-
i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-activity-feed__empty", children: "No activity." }) : h.map(({ label: t, events:
|
|
688
|
+
i.length === 0 ? /* @__PURE__ */ e("p", { className: "nice-activity-feed__empty", children: "No activity." }) : h.map(({ label: t, events: c }) => /* @__PURE__ */ l("div", { className: "nice-activity-feed__group", children: [
|
|
672
689
|
o && t && /* @__PURE__ */ e("div", { className: "nice-activity-feed__date-label", children: t }),
|
|
673
|
-
|
|
690
|
+
c.map((n) => /* @__PURE__ */ l(
|
|
674
691
|
"div",
|
|
675
692
|
{
|
|
676
693
|
className: "nice-activity-feed__event",
|
|
677
|
-
onClick: () =>
|
|
678
|
-
role:
|
|
679
|
-
tabIndex:
|
|
694
|
+
onClick: () => s == null ? void 0 : s(n),
|
|
695
|
+
role: s ? "button" : void 0,
|
|
696
|
+
tabIndex: s ? 0 : void 0,
|
|
680
697
|
onKeyDown: (k) => {
|
|
681
|
-
k.key === "Enter" &&
|
|
698
|
+
k.key === "Enter" && s && s(n);
|
|
682
699
|
},
|
|
683
700
|
children: [
|
|
684
|
-
/* @__PURE__ */ e(
|
|
685
|
-
|
|
686
|
-
|
|
701
|
+
/* @__PURE__ */ e(
|
|
702
|
+
"span",
|
|
703
|
+
{
|
|
704
|
+
className: `nice-activity-feed__icon nice-activity-feed__icon--${n.type}`,
|
|
705
|
+
title: n.type,
|
|
706
|
+
"aria-hidden": "true",
|
|
707
|
+
style: {
|
|
708
|
+
display: "inline-block",
|
|
709
|
+
width: 10,
|
|
710
|
+
height: 10,
|
|
711
|
+
marginTop: 4,
|
|
712
|
+
flexShrink: 0,
|
|
713
|
+
borderRadius: "50%",
|
|
714
|
+
background: G[n.type]
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
),
|
|
718
|
+
/* @__PURE__ */ l("div", { className: "nice-activity-feed__body", children: [
|
|
719
|
+
n.actorAvatarUrl && /* @__PURE__ */ e(
|
|
687
720
|
"img",
|
|
688
721
|
{
|
|
689
|
-
src:
|
|
722
|
+
src: n.actorAvatarUrl,
|
|
690
723
|
alt: "",
|
|
691
724
|
className: "nice-activity-feed__avatar"
|
|
692
725
|
}
|
|
693
726
|
),
|
|
694
|
-
/* @__PURE__ */
|
|
695
|
-
/* @__PURE__ */ e("strong", { children:
|
|
727
|
+
/* @__PURE__ */ l("span", { className: "nice-activity-feed__message", children: [
|
|
728
|
+
/* @__PURE__ */ e("strong", { children: n.actorName }),
|
|
696
729
|
" ",
|
|
697
|
-
|
|
698
|
-
|
|
730
|
+
n.message,
|
|
731
|
+
n.targetLabel && /* @__PURE__ */ l(H, { children: [
|
|
699
732
|
" ",
|
|
700
|
-
/* @__PURE__ */ e("em", { children:
|
|
733
|
+
/* @__PURE__ */ e("em", { children: n.targetLabel })
|
|
701
734
|
] })
|
|
702
735
|
] }),
|
|
703
|
-
/* @__PURE__ */ e("time", { className: "nice-activity-feed__time", children:
|
|
736
|
+
/* @__PURE__ */ e("time", { className: "nice-activity-feed__time", children: n.timestamp })
|
|
704
737
|
] })
|
|
705
738
|
]
|
|
706
739
|
},
|
|
707
|
-
|
|
740
|
+
n.id
|
|
708
741
|
))
|
|
709
742
|
] }, t || "__all")),
|
|
710
|
-
|
|
743
|
+
E && w && /* @__PURE__ */ e("button", { className: "nice-activity-feed__load-more", onClick: w, children: "Load more" })
|
|
711
744
|
] });
|
|
712
745
|
}
|
|
713
746
|
);
|
|
714
747
|
export {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
748
|
+
ne as NiceActivityFeed,
|
|
749
|
+
X as NiceComments,
|
|
750
|
+
Z as NiceRatings,
|
|
751
|
+
ee as NiceSocialPanel,
|
|
752
|
+
ie as NiceTagCloud,
|
|
753
|
+
te as NiceUserList,
|
|
754
|
+
ae as NiceWiki
|
|
722
755
|
};
|
package/package.json
CHANGED