@nice2dev/admin 1.0.28 → 1.0.29

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,5 +1,23 @@
1
1
  # @nice2dev/admin — Changelog
2
2
 
3
+ ## 1.0.29
4
+
5
+ ### Patch Changes
6
+
7
+ - 9d6bca9: feat(admin): rebuild the Admin views on NiceDataGrid + drop redundant headers
8
+
9
+ NiceAdminUsers, NiceAdminRoles, NiceAdminAuditLog and NiceAdminNotifications now
10
+ render their tables with `<NiceDataGrid>` (search, sort, striping, row actions,
11
+ bulk actions, currency/date/boolean formatting) for a consistent, better-looking
12
+ UI, and the redundant page headers ("Role Management" / "Audit Log" + entry count
13
+ / "Notification Management") are gone by default (the `title` prop still renders a
14
+ header when explicitly set). All public props/callbacks are unchanged and the unit
15
+ tests pass.
16
+
17
+ This adds **`@nice2dev/ui` as a peer dependency** of `@nice2dev/admin` (externalized
18
+ in the build, so the package stays ~10 KB gzip). Consumers now need `@nice2dev/ui`
19
+ installed alongside `@nice2dev/admin`.
20
+
3
21
  ## [0.2.0] — 2026-03-25
4
22
 
5
23
  ### Added (FAZA 7.6)
@@ -39,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
39
57
  ## [0.1.0] — 2025-06-01
40
58
 
41
59
  ### Added
60
+
42
61
  - `NiceAdminDashboard` — admin dashboard with configurable widget grid
43
62
  - `NiceAdminUsers` — user management table with CRUD and role assignment
44
63
  - `NiceAdminRoles` — role management with permission matrix
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),G=a.forwardRef(function(p,_){const{widgets:m,columns:b=4,title:v="Dashboard",headerActions:g,onWidgetClick:x,className:f,style:S}=p;return e.jsxs("div",{ref:_,className:`nice-admin-dashboard ${f??""}`,style:S,children:[e.jsxs("div",{className:"nice-admin-dashboard__header",children:[e.jsx("h2",{children:v}),g&&e.jsx("div",{className:"nice-admin-dashboard__actions",children:g})]}),e.jsx("div",{className:"nice-admin-dashboard__grid",style:{display:"grid",gridTemplateColumns:`repeat(${b}, 1fr)`,gap:16},children:m.map(l=>e.jsxs("div",{className:`nice-admin-dashboard__widget nice-admin-dashboard__widget--${l.type}`,style:{gridColumn:l.colSpan?`span ${l.colSpan}`:void 0,gridRow:l.rowSpan?`span ${l.rowSpan}`:void 0},onClick:()=>x==null?void 0:x(l),onKeyDown:x?y=>{(y.key==="Enter"||y.key===" ")&&x(l)}:void 0,role:x?"button":void 0,tabIndex:x?0:void 0,children:[e.jsxs("div",{className:"nice-admin-dashboard__widget-header",children:[l.icon&&e.jsx("span",{className:"nice-admin-dashboard__widget-icon",children:l.icon}),e.jsx("span",{className:"nice-admin-dashboard__widget-title",children:l.title})]}),l.type==="stat"&&e.jsxs("div",{className:"nice-admin-dashboard__stat",children:[e.jsx("span",{className:"nice-admin-dashboard__stat-value",children:l.value}),l.change&&e.jsx("span",{className:`nice-admin-dashboard__stat-change ${l.changePositive?"nice-admin-dashboard__stat-change--positive":"nice-admin-dashboard__stat-change--negative"}`,children:l.change})]}),l.type==="custom"&&l.render&&e.jsx("div",{className:"nice-admin-dashboard__custom",children:l.render()}),(l.type==="chart"||l.type==="table"||l.type==="list")&&l.render&&e.jsx("div",{className:"nice-admin-dashboard__content",children:l.render()})]},l.id))})]})}),O={active:"#22c55e",inactive:"#9ca3af",suspended:"#ef4444",pending:"#eab308"},q=a.forwardRef(function(p,_){const{users:m,availableRoles:b=[],onCreate:v,onEdit:g,onDelete:x,onToggleStatus:f,onChangeRoles:S,searchable:l=!0,title:y="User Management",className:k,style:j}=p,[N,C]=a.useState(""),[i,s]=a.useState(""),c=a.useMemo(()=>{let n=m;if(i&&(n=n.filter(o=>o.status===i)),N.trim()){const o=N.toLowerCase();n=n.filter(R=>R.name.toLowerCase().includes(o)||R.email.toLowerCase().includes(o)||R.roles.some(E=>E.toLowerCase().includes(o)))}return n},[m,i,N]),u=a.useCallback(n=>{if(!f)return;const o=n.status==="active"?"suspended":"active";f(n.id,o)},[f]);return e.jsxs("div",{ref:_,className:`nice-admin-users ${k??""}`,style:j,children:[e.jsxs("div",{className:"nice-admin-users__header",children:[e.jsx("h3",{children:y}),e.jsxs("span",{className:"nice-admin-users__count",children:[m.length," users"]}),v&&e.jsx("button",{className:"nice-admin-users__create-btn",onClick:v,children:"+ Add User"})]}),e.jsxs("div",{className:"nice-admin-users__toolbar",children:[l&&e.jsx("input",{type:"text",value:N,onChange:n=>C(n.target.value),placeholder:"Search users…",className:"nice-admin-users__search"}),e.jsxs("select",{value:i,onChange:n=>s(n.target.value),className:"nice-admin-users__status-filter",children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"inactive",children:"Inactive"}),e.jsx("option",{value:"suspended",children:"Suspended"}),e.jsx("option",{value:"pending",children:"Pending"})]})]}),c.length===0?e.jsx("p",{className:"nice-admin-users__empty",children:"No users found."}):e.jsxs("table",{className:"nice-admin-users__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"User"}),e.jsx("th",{children:"Email"}),e.jsx("th",{children:"Roles"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Last Login"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:c.map(n=>e.jsxs("tr",{children:[e.jsxs("td",{className:"nice-admin-users__user-cell",children:[n.avatarUrl&&e.jsx("img",{src:n.avatarUrl,alt:"",className:"nice-admin-users__avatar"}),e.jsx("span",{children:n.name})]}),e.jsx("td",{children:n.email}),e.jsx("td",{children:S?e.jsx("select",{multiple:!0,value:n.roles,onChange:o=>{const R=Array.from(o.target.selectedOptions,E=>E.value);S(n.id,R)},className:"nice-admin-users__roles-select",children:b.map(o=>e.jsx("option",{value:o,children:o},o))}):n.roles.join(", ")}),e.jsx("td",{children:e.jsx("span",{className:"nice-admin-users__status-badge",style:{backgroundColor:O[n.status]},onClick:()=>u(n),onKeyDown:f?o=>{(o.key==="Enter"||o.key===" ")&&u(n)}:void 0,role:f?"button":void 0,tabIndex:f?0:void 0,children:n.status})}),e.jsx("td",{children:n.createdAt}),e.jsx("td",{children:n.lastLoginAt??"—"}),e.jsxs("td",{className:"nice-admin-users__actions",children:[g&&e.jsx("button",{onClick:()=>g(n),children:"Edit"}),x&&e.jsx("button",{onClick:()=>x(n.id),children:"Delete"})]})]},n.id))})]})]})}),P=a.forwardRef(function(p,_){var h;const{roles:m,actions:b,resources:v,onPermissionChange:g,onCreate:x,onDelete:f,onRename:S,title:l="Role Management",className:y,style:k}=p,[j,N]=a.useState(((h=m[0])==null?void 0:h.id)??null),[C,i]=a.useState(!1),[s,c]=a.useState(""),[u,n]=a.useState(""),o=m.find(r=>r.id===j),R=a.useCallback(()=>{!s.trim()||!x||(x(s.trim(),u.trim()),c(""),n(""),i(!1))},[s,u,x]),E=(r,d,t)=>{var w;return((w=r.permissions[d])==null?void 0:w.includes(t))??!1};return e.jsxs("div",{ref:_,className:`nice-admin-roles ${y??""}`,style:k,children:[e.jsxs("div",{className:"nice-admin-roles__header",children:[e.jsx("h3",{children:l}),x&&e.jsx("button",{onClick:()=>i(!C),children:"+ New Role"})]}),C&&e.jsxs("div",{className:"nice-admin-roles__create-form",children:[e.jsx("input",{type:"text",value:s,onChange:r=>c(r.target.value),placeholder:"Role name"}),e.jsx("input",{type:"text",value:u,onChange:r=>n(r.target.value),placeholder:"Description"}),e.jsx("button",{onClick:R,disabled:!s.trim(),children:"Create"}),e.jsx("button",{onClick:()=>i(!1),children:"Cancel"})]}),e.jsx("div",{className:"nice-admin-roles__tabs",children:m.map(r=>e.jsxs("button",{className:`nice-admin-roles__tab ${r.id===j?"nice-admin-roles__tab--active":""}`,onClick:()=>N(r.id),style:r.color?{borderColor:r.color}:void 0,children:[r.name,r.userCount!=null&&e.jsxs("span",{className:"nice-admin-roles__tab-count",children:["(",r.userCount,")"]}),r.isSystem&&e.jsx("span",{className:"nice-admin-roles__tab-system",children:"🔒"})]},r.id))}),o&&e.jsxs("div",{className:"nice-admin-roles__matrix-wrap",children:[o.description&&e.jsx("p",{className:"nice-admin-roles__description",children:o.description}),e.jsxs("table",{className:"nice-admin-roles__matrix",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Resource"}),b.map(r=>e.jsx("th",{title:r.description,children:r.label},r.id))]})}),e.jsx("tbody",{children:v.map(r=>e.jsxs("tr",{children:[e.jsx("td",{children:r.label}),b.map(d=>{const t=E(o,r.id,d.id);return e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:t,onChange:()=>g==null?void 0:g(o.id,r.id,d.id,!t),disabled:o.isSystem})},d.id)})]},r.id))})]}),!o.isSystem&&e.jsxs("div",{className:"nice-admin-roles__role-actions",children:[S&&e.jsx("button",{onClick:()=>{const r=prompt("New role name:",o.name);r&&S(o.id,r)},children:"Rename"}),f&&e.jsx("button",{onClick:()=>f(o.id),children:"Delete Role"})]})]})]})}),H={info:{color:"#3b82f6",label:"INFO"},warning:{color:"#eab308",label:"WARN"},error:{color:"#ef4444",label:"ERROR"},critical:{color:"#dc2626",label:"CRIT"}},K=a.forwardRef(function(p,_){const{entries:m,onEntryClick:b,onLoadMore:v,hasMore:g=!1,searchable:x=!0,showSeverityFilter:f=!0,title:S="Audit Log",className:l,style:y}=p,[k,j]=a.useState(""),[N,C]=a.useState(""),i=a.useMemo(()=>{let s=m;if(N&&(s=s.filter(c=>c.severity===N)),k.trim()){const c=k.toLowerCase();s=s.filter(u=>{var n;return u.actorName.toLowerCase().includes(c)||u.action.toLowerCase().includes(c)||u.resource.toLowerCase().includes(c)||((n=u.details)==null?void 0:n.toLowerCase().includes(c))})}return s},[m,N,k]);return e.jsxs("div",{ref:_,className:`nice-admin-audit-log ${l??""}`,style:y,children:[e.jsxs("div",{className:"nice-admin-audit-log__header",children:[e.jsx("h3",{children:S}),e.jsxs("span",{className:"nice-admin-audit-log__count",children:[m.length," entries"]})]}),e.jsxs("div",{className:"nice-admin-audit-log__toolbar",children:[x&&e.jsx("input",{type:"text",value:k,onChange:s=>j(s.target.value),placeholder:"Search audit log…",className:"nice-admin-audit-log__search"}),f&&e.jsxs("select",{value:N,onChange:s=>C(s.target.value),className:"nice-admin-audit-log__severity-filter",children:[e.jsx("option",{value:"",children:"All severities"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"error",children:"Error"}),e.jsx("option",{value:"critical",children:"Critical"})]})]}),i.length===0?e.jsx("p",{className:"nice-admin-audit-log__empty",children:"No audit log entries found."}):e.jsxs("table",{className:"nice-admin-audit-log__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Severity"}),e.jsx("th",{children:"Actor"}),e.jsx("th",{children:"Action"}),e.jsx("th",{children:"Resource"}),e.jsx("th",{children:"IP"}),e.jsx("th",{children:"Details"})]})}),e.jsx("tbody",{children:i.map(s=>{const c=H[s.severity];return e.jsxs("tr",{className:"nice-admin-audit-log__row",onClick:()=>b==null?void 0:b(s),role:b?"button":void 0,tabIndex:b?0:void 0,children:[e.jsx("td",{children:s.timestamp}),e.jsx("td",{children:e.jsx("span",{className:"nice-admin-audit-log__severity",style:{color:c.color},children:c.label})}),e.jsx("td",{children:s.actorName}),e.jsx("td",{children:s.action}),e.jsxs("td",{children:[s.resource,s.resourceId?` #${s.resourceId}`:""]}),e.jsx("td",{children:s.ipAddress??"—"}),e.jsx("td",{className:"nice-admin-audit-log__details",children:s.details??"—"})]},s.id)})})]}),g&&v&&e.jsx("button",{className:"nice-admin-audit-log__load-more",onClick:v,children:"Load more"})]})}),Y=a.forwardRef(function(p,_){const{settings:m,onSave:b,onChange:v,onReset:g,saving:x=!1,title:f="Settings",className:S,style:l}=p,[y,k]=a.useState(()=>{const s={};for(const c of m)s[c.key]=c.value;return s}),j=a.useCallback((s,c)=>{k(u=>({...u,[s]:c})),v==null||v(s,c)},[v]),N=a.useCallback(()=>{b==null||b(y)},[b,y]),C=new Map;for(const s of m){const c=s.section??"General";C.has(c)||C.set(c,[]),C.get(c).push(s)}const i=s=>{var u;const c=y[s.key];switch(s.type){case"boolean":return e.jsxs("label",{className:"nice-admin-settings__toggle",children:[e.jsx("input",{type:"checkbox",checked:!!c,onChange:n=>j(s.key,n.target.checked)}),s.label]});case"select":return e.jsx("select",{value:String(c??""),onChange:n=>j(s.key,n.target.value),className:"nice-admin-settings__select",children:(u=s.options)==null?void 0:u.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))});case"textarea":return e.jsx("textarea",{value:String(c??""),onChange:n=>j(s.key,n.target.value),placeholder:s.placeholder,className:"nice-admin-settings__textarea",rows:4});case"number":return e.jsx("input",{type:"number",value:c!=null?Number(c):"",onChange:n=>j(s.key,parseFloat(n.target.value)||0),placeholder:s.placeholder,className:"nice-admin-settings__input"});case"color":return e.jsx("input",{type:"color",value:String(c??"#000000"),onChange:n=>j(s.key,n.target.value),className:"nice-admin-settings__color"});case"password":return e.jsx("input",{type:"password",value:String(c??""),onChange:n=>j(s.key,n.target.value),placeholder:s.placeholder,className:"nice-admin-settings__input",autoComplete:"new-password"});default:return e.jsx("input",{type:"text",value:String(c??""),onChange:n=>j(s.key,n.target.value),placeholder:s.placeholder,className:"nice-admin-settings__input"})}};return e.jsxs("div",{ref:_,className:`nice-admin-settings ${S??""}`,style:l,children:[e.jsx("div",{className:"nice-admin-settings__header",children:e.jsx("h3",{children:f})}),Array.from(C.entries()).map(([s,c])=>e.jsxs("fieldset",{className:"nice-admin-settings__section",children:[e.jsx("legend",{children:s}),c.map(u=>e.jsxs("div",{className:"nice-admin-settings__field",children:[u.type!=="boolean"&&e.jsxs("label",{className:"nice-admin-settings__label",children:[u.label,u.required&&e.jsx("span",{className:"nice-admin-settings__required",children:"*"})]}),u.description&&e.jsx("p",{className:"nice-admin-settings__description",children:u.description}),i(u)]},u.key))]},s)),e.jsxs("div",{className:"nice-admin-settings__actions",children:[e.jsx("button",{className:"nice-admin-settings__save-btn",onClick:N,disabled:x,children:x?"Saving…":"Save Settings"}),g&&e.jsx("button",{className:"nice-admin-settings__reset-btn",onClick:g,children:"Reset to Defaults"})]})]})}),V=a.forwardRef(function(p,_){const{notifications:m,availableChannels:b=["email","push","sms","in-app","webhook"],onToggle:v,onEdit:g,onTest:x,onCreate:f,onDelete:S,title:l="Notification Management",className:y,style:k}=p,[j,N]=a.useState(""),C=a.useMemo(()=>{if(!j.trim())return m;const i=j.toLowerCase();return m.filter(s=>{var c;return s.name.toLowerCase().includes(i)||s.event.toLowerCase().includes(i)||((c=s.description)==null?void 0:c.toLowerCase().includes(i))})},[m,j]);return e.jsxs("div",{ref:_,className:`nice-admin-notifications ${y??""}`,style:k,children:[e.jsxs("div",{className:"nice-admin-notifications__header",children:[e.jsx("h3",{children:l}),f&&e.jsx("button",{onClick:f,children:"+ New Notification"})]}),e.jsx("input",{type:"text",value:j,onChange:i=>N(i.target.value),placeholder:"Search notifications…",className:"nice-admin-notifications__search"}),C.length===0?e.jsx("p",{className:"nice-admin-notifications__empty",children:"No notifications found."}):e.jsxs("table",{className:"nice-admin-notifications__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Enabled"}),e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Event"}),e.jsx("th",{children:"Channels"}),e.jsx("th",{children:"Last Sent"}),e.jsx("th",{children:"Sent"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:C.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:()=>v==null?void 0:v(i.id,!i.enabled)})}),e.jsxs("td",{children:[e.jsx("strong",{children:i.name}),i.description&&e.jsx("br",{}),i.description&&e.jsx("small",{children:i.description})]}),e.jsx("td",{children:e.jsx("code",{children:i.event})}),e.jsx("td",{children:i.channels.join(", ")}),e.jsx("td",{children:i.lastSentAt??"—"}),e.jsx("td",{children:i.sentCount??0}),e.jsxs("td",{className:"nice-admin-notifications__actions",children:[g&&e.jsx("button",{onClick:()=>g(i),children:"Edit"}),x&&e.jsx("button",{onClick:()=>x(i.id),children:"Test"}),S&&e.jsx("button",{onClick:()=>S(i.id),children:"Delete"})]})]},i.id))})]})]})}),B=a.forwardRef(function(p,_){const{flags:m,environmentNames:b=["development","staging","production"],onToggle:v,onPercentageChange:g,onCreate:x,onDelete:f,onEdit:S,title:l="Feature Flags",className:y,style:k}=p,[j,N]=a.useState(""),[C,i]=a.useState(!1),[s,c]=a.useState(""),[u,n]=a.useState(""),[o,R]=a.useState(""),E=a.useMemo(()=>{if(!j.trim())return m;const d=j.toLowerCase();return m.filter(t=>{var w,L;return t.key.toLowerCase().includes(d)||t.name.toLowerCase().includes(d)||((w=t.description)==null?void 0:w.toLowerCase().includes(d))||((L=t.tags)==null?void 0:L.some(F=>F.toLowerCase().includes(d)))})},[m,j]),h=a.useCallback(()=>{!s.trim()||!u.trim()||!x||(x(s.trim(),u.trim(),o.trim()),c(""),n(""),R(""),i(!1))},[s,u,o,x]),r=(d,t)=>d.environments.find(w=>w.name===t);return e.jsxs("div",{ref:_,className:`nice-feature-flags ${y??""}`,style:k,children:[e.jsxs("div",{className:"nice-feature-flags__header",children:[e.jsx("h3",{children:l}),e.jsxs("span",{className:"nice-feature-flags__count",children:[m.length," flags"]}),x&&e.jsx("button",{onClick:()=>i(!C),children:"+ New Flag"})]}),C&&e.jsxs("div",{className:"nice-feature-flags__create-form",children:[e.jsx("input",{type:"text",value:s,onChange:d=>c(d.target.value),placeholder:"flag_key"}),e.jsx("input",{type:"text",value:u,onChange:d=>n(d.target.value),placeholder:"Display name"}),e.jsx("input",{type:"text",value:o,onChange:d=>R(d.target.value),placeholder:"Description"}),e.jsx("button",{onClick:h,disabled:!s.trim()||!u.trim(),children:"Create"}),e.jsx("button",{onClick:()=>i(!1),children:"Cancel"})]}),e.jsx("input",{type:"text",value:j,onChange:d=>N(d.target.value),placeholder:"Search flags…",className:"nice-feature-flags__search"}),E.length===0?e.jsx("p",{className:"nice-feature-flags__empty",children:"No feature flags found."}):e.jsxs("table",{className:"nice-feature-flags__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Flag"}),b.map(d=>e.jsx("th",{children:d},d)),e.jsx("th",{children:"Tags"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:E.map(d=>{var t;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"nice-feature-flags__flag-info",children:[e.jsx("strong",{children:d.name}),e.jsx("code",{className:"nice-feature-flags__key",children:d.key}),d.description&&e.jsx("small",{children:d.description})]})}),b.map(w=>{const L=r(d,w);return e.jsxs("td",{className:"nice-feature-flags__env-cell",children:[e.jsx("input",{type:"checkbox",checked:(L==null?void 0:L.enabled)??!1,onChange:()=>v==null?void 0:v(d.id,w,!((L==null?void 0:L.enabled)??!1))}),(L==null?void 0:L.percentage)!=null&&e.jsx("input",{type:"number",min:0,max:100,value:L.percentage,onChange:F=>g==null?void 0:g(d.id,w,parseInt(F.target.value,10)||0),className:"nice-feature-flags__percentage",title:"Rollout %"})]},w)}),e.jsx("td",{children:((t=d.tags)==null?void 0:t.join(", "))||"—"}),e.jsx("td",{children:d.updatedAt??d.createdAt}),e.jsxs("td",{className:"nice-feature-flags__actions",children:[S&&e.jsx("button",{onClick:()=>S(d),children:"Edit"}),f&&e.jsx("button",{onClick:()=>f(d.id),children:"Delete"})]})]},d.id)})})]})]})}),J=a.forwardRef(function(p,_){var E;const{entities:m,formats:b=["json","csv","xlsx"],jobs:v=[],onImport:g,onExport:x,onDownload:f,title:S="Import / Export",className:l,style:y}=p,[k,j]=a.useState("export"),[N,C]=a.useState(((E=m[0])==null?void 0:E.id)??""),[i,s]=a.useState(b[0]??"json"),[c,u]=a.useState(null),n=a.useCallback(()=>{!g||!c||!N||(g(N,i,c),u(null))},[g,N,i,c]),o=a.useCallback(()=>{!x||!N||x(N,i)},[x,N,i]),R=h=>{var r;u(((r=h.target.files)==null?void 0:r[0])??null)};return e.jsxs("div",{ref:_,className:`nice-import-export ${l??""}`,style:y,children:[e.jsx("div",{className:"nice-import-export__header",children:e.jsx("h3",{children:S})}),e.jsxs("div",{className:"nice-import-export__tabs",children:[e.jsx("button",{className:`nice-import-export__tab ${k==="import"?"nice-import-export__tab--active":""}`,onClick:()=>j("import"),children:"Import"}),e.jsx("button",{className:`nice-import-export__tab ${k==="export"?"nice-import-export__tab--active":""}`,onClick:()=>j("export"),children:"Export"})]}),e.jsxs("div",{className:"nice-import-export__form",children:[e.jsxs("label",{children:["Entity",e.jsx("select",{value:N,onChange:h=>C(h.target.value),children:m.map(h=>e.jsx("option",{value:h.id,children:h.label},h.id))})]}),e.jsxs("label",{children:["Format",e.jsx("select",{value:i,onChange:h=>s(h.target.value),children:b.map(h=>e.jsx("option",{value:h,children:h.toUpperCase()},h))})]}),k==="import"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["File",e.jsx("input",{type:"file",onChange:R,accept:`.${i}`})]}),e.jsx("button",{className:"nice-import-export__action-btn",onClick:n,disabled:!c,children:"Start Import"})]}),k==="export"&&e.jsx("button",{className:"nice-import-export__action-btn",onClick:o,children:"Start Export"})]}),v.length>0&&e.jsxs("div",{className:"nice-import-export__jobs",children:[e.jsx("h4",{children:"Recent Jobs"}),e.jsxs("table",{className:"nice-import-export__jobs-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Format"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Progress"}),e.jsx("th",{children:"Errors"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:v.map(h=>e.jsxs("tr",{children:[e.jsx("td",{children:h.type}),e.jsx("td",{children:h.format.toUpperCase()}),e.jsx("td",{children:e.jsx("span",{className:`nice-import-export__status nice-import-export__status--${h.status}`,children:h.status})}),e.jsx("td",{children:h.processedRows!=null&&h.totalRows?`${h.processedRows} / ${h.totalRows}`:"—"}),e.jsx("td",{children:h.errorCount??0}),e.jsx("td",{children:h.createdAt}),e.jsx("td",{children:h.type==="export"&&h.status==="completed"&&f&&e.jsx("button",{onClick:()=>f(h.id),children:"Download"})})]},h.id))})]})]})]})}),I=a.createContext({flags:{}});function W({config:A,children:p}){return e.jsx(I.Provider,{value:A,children:p})}function $(A){const p=a.useContext(I);return a.useMemo(()=>{const _=p.flags[A];return _===void 0?{enabled:!1}:typeof _=="boolean"?{enabled:_}:{enabled:_>0,percentage:_}},[p.flags,A])}function M({flag:A,fallback:p=null,children:_}){const{enabled:m}=$(A);return e.jsx(e.Fragment,{children:m?_:p})}const T={low:"#2196f3",medium:"#ff9800",high:"#f44336",critical:"#9c27b0"},D={field:"Hidden Field",endpoint:"Decoy Endpoint",file:"Canary File",credential:"Fake Credential",cookie:"Tracking Cookie"},z=a.forwardRef(function({tokens:p,events:_,onCreate:m,onToggle:b,onDelete:v,onDismissEvent:g,title:x="Honey Tokens",className:f,style:S},l){const[y,k]=a.useState(""),[j,N]=a.useState(!1),[C,i]=a.useState(""),[s,c]=a.useState("field"),[u,n]=a.useState("medium"),[o,R]=a.useState(""),E=a.useMemo(()=>p.filter(t=>t.name.toLowerCase().includes(y.toLowerCase())||t.location.toLowerCase().includes(y.toLowerCase())),[p,y]),h=a.useMemo(()=>[..._].sort((t,w)=>new Date(w.timestamp).getTime()-new Date(t.timestamp).getTime()),[_]),r=a.useMemo(()=>{const t=p.filter(F=>F.active).length,w=p.reduce((F,U)=>F+U.tripCount,0),L=_.filter(F=>F.severity==="critical").length;return{activeCount:t,totalCount:p.length,totalTrips:w,criticalEvents:L}},[p,_]),d=()=>{C.trim()&&o.trim()&&m&&(m(C.trim(),s,u,o.trim()),i(""),R(""),N(!1))};return e.jsxs("div",{ref:l,className:`nice-honey-token-dashboard${f?` ${f}`:""}`,style:S,children:[e.jsxs("div",{className:"nice-honey-token-dashboard__header",children:[e.jsx("h2",{children:x}),e.jsxs("div",{className:"nice-honey-token-dashboard__stats",children:[e.jsxs("span",{className:"nice-honey-token-dashboard__stat",children:["Active: ",r.activeCount,"/",r.totalCount]}),e.jsxs("span",{className:"nice-honey-token-dashboard__stat",children:["Trips: ",r.totalTrips]}),r.criticalEvents>0&&e.jsxs("span",{className:"nice-honey-token-dashboard__stat nice-honey-token-dashboard__stat--critical",children:["Critical: ",r.criticalEvents]})]})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__toolbar",children:[e.jsx("input",{type:"text",className:"nice-honey-token-dashboard__search",placeholder:"Search tokens...",value:y,onChange:t=>k(t.target.value)}),m&&e.jsx("button",{className:"nice-honey-token-dashboard__btn",onClick:()=>N(!j),children:j?"Cancel":"+ New Token"})]}),j&&e.jsxs("div",{className:"nice-honey-token-dashboard__create",children:[e.jsx("input",{type:"text",placeholder:"Token name",value:C,onChange:t=>i(t.target.value)}),e.jsx("select",{value:s,onChange:t=>c(t.target.value),children:Object.entries(D).map(([t,w])=>e.jsx("option",{value:t,children:w},t))}),e.jsxs("select",{value:u,onChange:t=>n(t.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]}),e.jsx("input",{type:"text",placeholder:"Location (e.g. /api/admin/secret)",value:o,onChange:t=>R(t.target.value)}),e.jsx("button",{onClick:d,children:"Create"})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__tokens",children:[e.jsxs("h3",{children:["Tokens (",E.length,")"]}),e.jsxs("table",{className:"nice-honey-token-dashboard__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Severity"}),e.jsx("th",{children:"Location"}),e.jsx("th",{children:"Trips"}),e.jsx("th",{children:"Last Tripped"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:E.map(t=>e.jsxs("tr",{className:t.tripCount>0?"nice-honey-token-dashboard__row--tripped":"",children:[e.jsx("td",{children:t.name}),e.jsx("td",{children:D[t.type]}),e.jsx("td",{children:e.jsx("span",{className:"nice-honey-token-dashboard__severity",style:{color:T[t.severity]},children:t.severity})}),e.jsx("td",{children:e.jsx("code",{children:t.location})}),e.jsx("td",{children:t.tripCount}),e.jsx("td",{children:t.lastTripped??"—"}),e.jsx("td",{children:e.jsx("span",{className:`nice-honey-token-dashboard__status--${t.active?"active":"inactive"}`,children:t.active?"Active":"Inactive"})}),e.jsxs("td",{children:[b&&e.jsx("button",{onClick:()=>b(t.id,!t.active),children:t.active?"Disable":"Enable"}),v&&e.jsx("button",{onClick:()=>v(t.id),children:"Delete"})]})]},t.id))})]})]}),h.length>0&&e.jsxs("div",{className:"nice-honey-token-dashboard__events",children:[e.jsxs("h3",{children:["Recent Events (",h.length,")"]}),e.jsx("div",{className:"nice-honey-token-dashboard__event-list",children:h.map(t=>e.jsxs("div",{className:`nice-honey-token-dashboard__event nice-honey-token-dashboard__event--${t.severity}`,children:[e.jsxs("div",{className:"nice-honey-token-dashboard__event-header",children:[e.jsx("strong",{children:t.tokenName}),e.jsx("span",{className:"nice-honey-token-dashboard__severity",style:{color:T[t.severity]},children:t.severity}),e.jsx("time",{children:t.timestamp})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__event-details",children:[e.jsxs("span",{children:["IP: ",t.sourceIp]}),t.userId&&e.jsxs("span",{children:["User: ",t.userId]}),t.details&&e.jsx("span",{children:t.details})]}),g&&e.jsx("button",{className:"nice-honey-token-dashboard__dismiss",onClick:()=>g(t.id),children:"Dismiss"})]},t.id))})]})]})});exports.FeatureGate=M;exports.NiceAdminAuditLog=K;exports.NiceAdminDashboard=G;exports.NiceAdminNotifications=V;exports.NiceAdminRoles=P;exports.NiceAdminSettings=Y;exports.NiceAdminUsers=q;exports.NiceFeatureFlags=B;exports.NiceFeatureGate=M;exports.NiceFeatureGateProvider=W;exports.NiceHoneyTokenDashboard=z;exports.NiceImportExport=J;exports.useFeatureGate=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),T=require("@nice2dev/ui"),z=i.forwardRef(function(u,p){const{widgets:m,columns:N=4,title:_="Dashboard",headerActions:x,onWidgetClick:l,className:y,style:f}=u;return e.jsxs("div",{ref:p,className:`nice-admin-dashboard ${y??""}`,style:f,children:[e.jsxs("div",{className:"nice-admin-dashboard__header",children:[e.jsx("h2",{children:_}),x&&e.jsx("div",{className:"nice-admin-dashboard__actions",children:x})]}),e.jsx("div",{className:"nice-admin-dashboard__grid",style:{display:"grid",gridTemplateColumns:`repeat(${N}, 1fr)`,gap:16},children:m.map(c=>e.jsxs("div",{className:`nice-admin-dashboard__widget nice-admin-dashboard__widget--${c.type}`,style:{gridColumn:c.colSpan?`span ${c.colSpan}`:void 0,gridRow:c.rowSpan?`span ${c.rowSpan}`:void 0},onClick:()=>l==null?void 0:l(c),onKeyDown:l?C=>{(C.key==="Enter"||C.key===" ")&&l(c)}:void 0,role:l?"button":void 0,tabIndex:l?0:void 0,children:[e.jsxs("div",{className:"nice-admin-dashboard__widget-header",children:[c.icon&&e.jsx("span",{className:"nice-admin-dashboard__widget-icon",children:c.icon}),e.jsx("span",{className:"nice-admin-dashboard__widget-title",children:c.title})]}),c.type==="stat"&&e.jsxs("div",{className:"nice-admin-dashboard__stat",children:[e.jsx("span",{className:"nice-admin-dashboard__stat-value",children:c.value}),c.change&&e.jsx("span",{className:`nice-admin-dashboard__stat-change ${c.changePositive?"nice-admin-dashboard__stat-change--positive":"nice-admin-dashboard__stat-change--negative"}`,children:c.change})]}),c.type==="custom"&&c.render&&e.jsx("div",{className:"nice-admin-dashboard__custom",children:c.render()}),(c.type==="chart"||c.type==="table"||c.type==="list")&&c.render&&e.jsx("div",{className:"nice-admin-dashboard__content",children:c.render()})]},c.id))})]})}),P={active:"success",inactive:"secondary",suspended:"danger",pending:"warning"},O=i.forwardRef(function(u,p){const{users:m,availableRoles:N=[],onCreate:_,onEdit:x,onDelete:l,onToggleStatus:y,onChangeRoles:f,searchable:c=!0,title:C,className:w,style:b}=u,[v,k]=i.useState(""),j=i.useMemo(()=>v?m.filter(r=>r.status===v):m,[m,v]),t=i.useMemo(()=>{const r=[{field:"name",header:"User",sortable:!0,render:(h,g)=>e.jsxs("span",{className:"nice-admin-users__user-cell",children:[e.jsx(T.NiceAvatar,{src:g.avatarUrl,name:g.name,size:"sm"}),e.jsx("span",{children:g.name})]})},{field:"email",header:"Email",sortable:!0,render:h=>e.jsx("span",{className:"nice-admin-users__email",children:String(h??"")})},{field:"roles",header:"Roles",render:(h,g)=>f?e.jsx("select",{multiple:!0,value:g.roles,onChange:S=>{const o=Array.from(S.target.selectedOptions,E=>E.value);f(g.id,o)},className:"nice-admin-users__roles-select","aria-label":`Roles for ${g.name}`,children:N.map(S=>e.jsx("option",{value:S,children:S},S))}):e.jsx("span",{className:"nice-admin-users__roles",children:g.roles.map(S=>e.jsx(T.NiceTag,{size:"sm",children:S},S))})},{field:"status",header:"Status",sortable:!0,render:(h,g)=>{const S=e.jsx(T.NiceBadge,{variant:P[g.status],size:"sm",children:g.status});if(!y)return e.jsx("span",{className:"nice-admin-users__status-badge",children:S});const o=g.status==="active"?"suspended":"active";return e.jsx("button",{type:"button",className:"nice-admin-users__status-badge nice-admin-users__status-badge--toggle",onClick:()=>y(g.id,o),"aria-label":`Toggle status for ${g.name}`,children:S})}},{field:"createdAt",header:"Created",dataType:"date",sortable:!0},{field:"lastLoginAt",header:"Last Login",dataType:"date",sortable:!0,render:h=>h?String(h):"—"}];return(x||l)&&r.push({field:"__actions",header:"Actions",align:"right",render:(h,g)=>e.jsxs("span",{className:"nice-admin-users__actions",children:[x&&e.jsx(T.NiceButton,{size:"sm",variant:"ghost",ariaLabel:`Edit ${g.name}`,onClick:()=>x(g),children:e.jsx(T.NiceIcon,{name:"edit"})}),l&&e.jsx(T.NiceButton,{size:"sm",variant:"ghost",ariaLabel:`Delete ${g.name}`,onClick:()=>l(g.id),children:e.jsx(T.NiceIcon,{name:"trash"})})]})}),r},[N,f,l,x,y]),n=i.useMemo(()=>{if(l)return[{key:"delete",label:"Delete",variant:"danger",icon:e.jsx(T.NiceIcon,{name:"trash"}),onClick:r=>r.forEach(h=>l(h))}]},[l]),d=e.jsxs("div",{className:"nice-admin-users__toolbar",children:[e.jsx(T.NiceSelect,{value:v,onChange:r=>k(r??""),title:"Filter by status",options:[{value:"",label:"All statuses"},{value:"active",label:"Active"},{value:"inactive",label:"Inactive"},{value:"suspended",label:"Suspended"},{value:"pending",label:"Pending"}],size:"sm"}),_&&e.jsxs(T.NiceButton,{size:"sm",variant:"primary",onClick:_,children:[e.jsx(T.NiceIcon,{name:"plus"}),e.jsx("span",{children:"Add User"})]})]});return e.jsxs("div",{ref:p,className:`nice-admin-users ${w??""}`,style:b,children:[C!=null&&e.jsxs("div",{className:"nice-admin-users__header",children:[e.jsx("h3",{children:C}),e.jsxs("span",{className:"nice-admin-users__count",children:[m.length," users"]})]}),e.jsx(T.NiceDataGrid,{columns:t,data:j,keyField:"id",searchable:c,searchPlaceholder:"Search users…",selectable:!!l,bulkActions:n,striped:!0,toolbar:d,emptyText:"No users found."})]})});function q(F){let u=0;for(const p of Object.values(F.permissions))u+=p.length;return u}const B=i.forwardRef(function(u,p){var E;const{roles:m,actions:N,resources:_,onPermissionChange:x,onCreate:l,onDelete:y,onRename:f,title:c,className:C,style:w}=u,[b,v]=i.useState(((E=m[0])==null?void 0:E.id)??null),[k,j]=i.useState(!1),[t,n]=i.useState(""),[d,r]=i.useState(""),h=m.find(a=>a.id===b),g=i.useCallback(()=>{!t.trim()||!l||(l(t.trim(),d.trim()),n(""),r(""),j(!1))},[t,d,l]),S=(a,s,A)=>{var R;return((R=a.permissions[s])==null?void 0:R.includes(A))??!1},o=i.useMemo(()=>[{field:"name",header:"Role",sortable:!0,render:(a,s)=>e.jsxs("span",{className:"nice-admin-roles__name-cell",children:[s.color&&e.jsx("span",{className:"nice-admin-roles__color-dot",style:{background:s.color},"aria-hidden":"true"}),e.jsx("span",{children:s.name}),s.isSystem&&e.jsx(T.NiceIcon,{name:"lock",size:"sm",title:"System role",className:"nice-admin-roles__system-icon"})]})},{field:"description",header:"Description",sortable:!0,render:(a,s)=>s.description??"—"},{field:"permissionCount",header:"Permissions",align:"right",dataType:"number",sortable:!0,render:(a,s)=>q(s)},{field:"userCount",header:"Users",align:"right",dataType:"number",sortable:!0,render:(a,s)=>s.userCount??0}],[]);return e.jsxs("div",{ref:p,className:`nice-admin-roles ${C??""}`,style:w,children:[(c||l)&&e.jsxs("div",{className:"nice-admin-roles__header",children:[c&&e.jsx("h3",{children:c}),l&&e.jsx("button",{onClick:()=>j(!k),children:"+ New Role"})]}),k&&e.jsxs("div",{className:"nice-admin-roles__create-form",children:[e.jsx("input",{type:"text",value:t,onChange:a=>n(a.target.value),placeholder:"Role name"}),e.jsx("input",{type:"text",value:d,onChange:a=>r(a.target.value),placeholder:"Description"}),e.jsx("button",{onClick:g,disabled:!t.trim(),children:"Create"}),e.jsx("button",{onClick:()=>j(!1),children:"Cancel"})]}),e.jsx(T.NiceDataGrid,{className:"nice-admin-roles__grid",columns:o,data:m,keyField:"id",searchable:!0,striped:!0,size:"sm",selectable:!1,onRowClick:a=>v(a.id)}),h&&e.jsxs("div",{className:"nice-admin-roles__matrix-wrap",children:[h.description&&e.jsx("p",{className:"nice-admin-roles__description",children:h.description}),e.jsxs("table",{className:"nice-admin-roles__matrix",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Resource"}),N.map(a=>e.jsx("th",{title:a.description,children:a.label},a.id))]})}),e.jsx("tbody",{children:_.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.label}),N.map(s=>{const A=S(h,a.id,s.id);return e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:A,onChange:()=>x==null?void 0:x(h.id,a.id,s.id,!A),disabled:h.isSystem})},s.id)})]},a.id))})]}),!h.isSystem&&e.jsxs("div",{className:"nice-admin-roles__role-actions",children:[f&&e.jsx("button",{onClick:()=>{const a=prompt("New role name:",h.name);a&&f(h.id,a)},children:"Rename"}),y&&e.jsx("button",{onClick:()=>y(h.id),children:"Delete Role"})]})]})]})}),H={info:{color:"var(--nice-color-info, #3b82f6)",label:"INFO",icon:"info"},warning:{color:"var(--nice-color-warning, #eab308)",label:"WARN",icon:"warning"},error:{color:"var(--nice-color-danger, #ef4444)",label:"ERROR",icon:"error"},critical:{color:"var(--nice-color-danger, #dc2626)",label:"CRIT",icon:"error"}},V=i.forwardRef(function(u,p){const{entries:m,onEntryClick:N,onLoadMore:_,hasMore:x=!1,searchable:l=!0,showSeverityFilter:y=!0,title:f,className:c,style:C}=u,[w,b]=i.useState(""),[v,k]=i.useState(""),j=i.useMemo(()=>{let n=m;if(v&&(n=n.filter(d=>d.severity===v)),w.trim()){const d=w.toLowerCase();n=n.filter(r=>{var h;return r.actorName.toLowerCase().includes(d)||r.action.toLowerCase().includes(d)||r.resource.toLowerCase().includes(d)||((h=r.details)==null?void 0:h.toLowerCase().includes(d))})}return n},[m,v,w]),t=i.useMemo(()=>[{field:"timestamp",header:"Timestamp",sortable:!0,width:170},{field:"severity",header:"Severity",sortable:!0,width:120,render:(n,d)=>{const r=H[d.severity];return e.jsxs("span",{className:"nice-admin-audit-log__severity",style:{color:r.color,display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(T.NiceIcon,{name:r.icon,size:14}),r.label]})}},{field:"actorName",header:"Actor",sortable:!0},{field:"action",header:"Action",sortable:!0},{field:"resource",header:"Resource",sortable:!0,render:(n,d)=>e.jsxs(e.Fragment,{children:[d.resource,d.resourceId?` #${d.resourceId}`:""]})},{field:"ipAddress",header:"IP",width:130,render:n=>n??"—"},{field:"details",header:"Details",render:n=>e.jsx("span",{className:"nice-admin-audit-log__details",children:n??"—"})}],[]);return e.jsxs("div",{ref:p,className:`nice-admin-audit-log ${c??""}`,style:C,children:[f&&e.jsx("div",{className:"nice-admin-audit-log__header",children:e.jsx("h3",{children:f})}),e.jsxs("div",{className:"nice-admin-audit-log__toolbar",children:[l&&e.jsx("input",{type:"text",value:w,onChange:n=>b(n.target.value),placeholder:"Search audit log…",className:"nice-admin-audit-log__search"}),y&&e.jsxs("select",{value:v,onChange:n=>k(n.target.value),className:"nice-admin-audit-log__severity-filter",children:[e.jsx("option",{value:"",children:"All severities"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"error",children:"Error"}),e.jsx("option",{value:"critical",children:"Critical"})]})]}),e.jsx(T.NiceDataGrid,{columns:t,data:j,keyField:"id",striped:!0,size:"sm",emptyText:"No audit log entries found.",onRowClick:N?n=>N(n):void 0}),x&&_&&e.jsx("button",{className:"nice-admin-audit-log__load-more",onClick:_,children:"Load more"})]})}),Y=i.forwardRef(function(u,p){const{settings:m,onSave:N,onChange:_,onReset:x,saving:l=!1,title:y="Settings",className:f,style:c}=u,[C,w]=i.useState(()=>{const t={};for(const n of m)t[n.key]=n.value;return t}),b=i.useCallback((t,n)=>{w(d=>({...d,[t]:n})),_==null||_(t,n)},[_]),v=i.useCallback(()=>{N==null||N(C)},[N,C]),k=new Map;for(const t of m){const n=t.section??"General";k.has(n)||k.set(n,[]),k.get(n).push(t)}const j=t=>{var d;const n=C[t.key];switch(t.type){case"boolean":return e.jsxs("label",{className:"nice-admin-settings__toggle",children:[e.jsx("input",{type:"checkbox",checked:!!n,onChange:r=>b(t.key,r.target.checked)}),t.label]});case"select":return e.jsx("select",{value:String(n??""),onChange:r=>b(t.key,r.target.value),className:"nice-admin-settings__select",children:(d=t.options)==null?void 0:d.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))});case"textarea":return e.jsx("textarea",{value:String(n??""),onChange:r=>b(t.key,r.target.value),placeholder:t.placeholder,className:"nice-admin-settings__textarea",rows:4});case"number":return e.jsx("input",{type:"number",value:n!=null?Number(n):"",onChange:r=>b(t.key,parseFloat(r.target.value)||0),placeholder:t.placeholder,className:"nice-admin-settings__input"});case"color":return e.jsx("input",{type:"color",value:String(n??"#000000"),onChange:r=>b(t.key,r.target.value),className:"nice-admin-settings__color"});case"password":return e.jsx("input",{type:"password",value:String(n??""),onChange:r=>b(t.key,r.target.value),placeholder:t.placeholder,className:"nice-admin-settings__input",autoComplete:"new-password"});default:return e.jsx("input",{type:"text",value:String(n??""),onChange:r=>b(t.key,r.target.value),placeholder:t.placeholder,className:"nice-admin-settings__input"})}};return e.jsxs("div",{ref:p,className:`nice-admin-settings ${f??""}`,style:c,children:[e.jsx("div",{className:"nice-admin-settings__header",children:e.jsx("h3",{children:y})}),Array.from(k.entries()).map(([t,n])=>e.jsxs("fieldset",{className:"nice-admin-settings__section",children:[e.jsx("legend",{children:t}),n.map(d=>e.jsxs("div",{className:"nice-admin-settings__field",children:[d.type!=="boolean"&&e.jsxs("label",{className:"nice-admin-settings__label",children:[d.label,d.required&&e.jsx("span",{className:"nice-admin-settings__required",children:"*"})]}),d.description&&e.jsx("p",{className:"nice-admin-settings__description",children:d.description}),j(d)]},d.key))]},t)),e.jsxs("div",{className:"nice-admin-settings__actions",children:[e.jsx("button",{className:"nice-admin-settings__save-btn",onClick:v,disabled:l,children:l?"Saving…":"Save Settings"}),x&&e.jsx("button",{className:"nice-admin-settings__reset-btn",onClick:x,children:"Reset to Defaults"})]})]})}),K=i.forwardRef(function(u,p){const{notifications:m,availableChannels:N=["email","push","sms","in-app","webhook"],onToggle:_,onEdit:x,onTest:l,onCreate:y,onDelete:f,title:c,className:C,style:w}=u,b=i.useMemo(()=>{const k=[{field:"enabled",header:"Enabled",align:"center",width:90,sortable:!0,render:(j,t)=>e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:()=>_==null?void 0:_(t.id,!t.enabled),"aria-label":`Toggle ${t.name}`})},{field:"name",header:"Name",sortable:!0,render:(j,t)=>e.jsxs("div",{className:"nice-admin-notifications__name",children:[e.jsx("strong",{children:t.name}),t.description&&e.jsx("small",{className:"nice-admin-notifications__description",children:t.description})]})},{field:"event",header:"Event",sortable:!0,render:(j,t)=>e.jsx("code",{children:t.event})},{field:"channels",header:"Channels",render:(j,t)=>t.channels.join(", ")},{field:"lastSentAt",header:"Last Sent",sortable:!0,render:(j,t)=>t.lastSentAt??"—"},{field:"sentCount",header:"Sent",align:"right",dataType:"number",sortable:!0,render:(j,t)=>t.sentCount??0}];return(x||l||f)&&k.push({field:"__actions",header:"Actions",align:"right",sortable:!1,render:(j,t)=>e.jsxs("div",{className:"nice-admin-notifications__actions",children:[x&&e.jsx("button",{type:"button",onClick:()=>x(t),children:"Edit"}),l&&e.jsx("button",{type:"button",onClick:()=>l(t.id),children:"Test"}),f&&e.jsx("button",{type:"button",onClick:()=>f(t.id),children:"Delete"})]})}),k},[_,x,l,f]),v=y?e.jsx("button",{type:"button",onClick:y,className:"nice-admin-notifications__create",children:"New Notification"}):void 0;return e.jsxs("div",{ref:p,className:`nice-admin-notifications ${C??""}`,style:w,children:[c&&e.jsx("div",{className:"nice-admin-notifications__header",children:e.jsx("h3",{children:c})}),e.jsx(T.NiceDataGrid,{data:m,columns:b,keyField:"id",searchable:!0,striped:!0,emptyText:"No notifications found.",toolbar:v})]})}),J=i.forwardRef(function(u,p){const{flags:m,environmentNames:N=["development","staging","production"],onToggle:_,onPercentageChange:x,onCreate:l,onDelete:y,onEdit:f,title:c="Feature Flags",className:C,style:w}=u,[b,v]=i.useState(""),[k,j]=i.useState(!1),[t,n]=i.useState(""),[d,r]=i.useState(""),[h,g]=i.useState(""),S=i.useMemo(()=>{if(!b.trim())return m;const a=b.toLowerCase();return m.filter(s=>{var A,R;return s.key.toLowerCase().includes(a)||s.name.toLowerCase().includes(a)||((A=s.description)==null?void 0:A.toLowerCase().includes(a))||((R=s.tags)==null?void 0:R.some(D=>D.toLowerCase().includes(a)))})},[m,b]),o=i.useCallback(()=>{!t.trim()||!d.trim()||!l||(l(t.trim(),d.trim(),h.trim()),n(""),r(""),g(""),j(!1))},[t,d,h,l]),E=(a,s)=>a.environments.find(A=>A.name===s);return e.jsxs("div",{ref:p,className:`nice-feature-flags ${C??""}`,style:w,children:[e.jsxs("div",{className:"nice-feature-flags__header",children:[e.jsx("h3",{children:c}),e.jsxs("span",{className:"nice-feature-flags__count",children:[m.length," flags"]}),l&&e.jsx("button",{onClick:()=>j(!k),children:"+ New Flag"})]}),k&&e.jsxs("div",{className:"nice-feature-flags__create-form",children:[e.jsx("input",{type:"text",value:t,onChange:a=>n(a.target.value),placeholder:"flag_key"}),e.jsx("input",{type:"text",value:d,onChange:a=>r(a.target.value),placeholder:"Display name"}),e.jsx("input",{type:"text",value:h,onChange:a=>g(a.target.value),placeholder:"Description"}),e.jsx("button",{onClick:o,disabled:!t.trim()||!d.trim(),children:"Create"}),e.jsx("button",{onClick:()=>j(!1),children:"Cancel"})]}),e.jsx("input",{type:"text",value:b,onChange:a=>v(a.target.value),placeholder:"Search flags…",className:"nice-feature-flags__search"}),S.length===0?e.jsx("p",{className:"nice-feature-flags__empty",children:"No feature flags found."}):e.jsxs("table",{className:"nice-feature-flags__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Flag"}),N.map(a=>e.jsx("th",{children:a},a)),e.jsx("th",{children:"Tags"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:S.map(a=>{var s;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"nice-feature-flags__flag-info",children:[e.jsx("strong",{children:a.name}),e.jsx("code",{className:"nice-feature-flags__key",children:a.key}),a.description&&e.jsx("small",{children:a.description})]})}),N.map(A=>{const R=E(a,A);return e.jsxs("td",{className:"nice-feature-flags__env-cell",children:[e.jsx("input",{type:"checkbox",checked:(R==null?void 0:R.enabled)??!1,onChange:()=>_==null?void 0:_(a.id,A,!((R==null?void 0:R.enabled)??!1))}),(R==null?void 0:R.percentage)!=null&&e.jsx("input",{type:"number",min:0,max:100,value:R.percentage,onChange:D=>x==null?void 0:x(a.id,A,parseInt(D.target.value,10)||0),className:"nice-feature-flags__percentage",title:"Rollout %"})]},A)}),e.jsx("td",{children:((s=a.tags)==null?void 0:s.join(", "))||"—"}),e.jsx("td",{children:a.updatedAt??a.createdAt}),e.jsxs("td",{className:"nice-feature-flags__actions",children:[f&&e.jsx("button",{onClick:()=>f(a),children:"Edit"}),y&&e.jsx("button",{onClick:()=>y(a.id),children:"Delete"})]})]},a.id)})})]})]})}),W=i.forwardRef(function(u,p){var S;const{entities:m,formats:N=["json","csv","xlsx"],jobs:_=[],onImport:x,onExport:l,onDownload:y,title:f="Import / Export",className:c,style:C}=u,[w,b]=i.useState("export"),[v,k]=i.useState(((S=m[0])==null?void 0:S.id)??""),[j,t]=i.useState(N[0]??"json"),[n,d]=i.useState(null),r=i.useCallback(()=>{!x||!n||!v||(x(v,j,n),d(null))},[x,v,j,n]),h=i.useCallback(()=>{!l||!v||l(v,j)},[l,v,j]),g=o=>{var E;d(((E=o.target.files)==null?void 0:E[0])??null)};return e.jsxs("div",{ref:p,className:`nice-import-export ${c??""}`,style:C,children:[e.jsx("div",{className:"nice-import-export__header",children:e.jsx("h3",{children:f})}),e.jsxs("div",{className:"nice-import-export__tabs",children:[e.jsx("button",{className:`nice-import-export__tab ${w==="import"?"nice-import-export__tab--active":""}`,onClick:()=>b("import"),children:"Import"}),e.jsx("button",{className:`nice-import-export__tab ${w==="export"?"nice-import-export__tab--active":""}`,onClick:()=>b("export"),children:"Export"})]}),e.jsxs("div",{className:"nice-import-export__form",children:[e.jsxs("label",{children:["Entity",e.jsx("select",{value:v,onChange:o=>k(o.target.value),children:m.map(o=>e.jsx("option",{value:o.id,children:o.label},o.id))})]}),e.jsxs("label",{children:["Format",e.jsx("select",{value:j,onChange:o=>t(o.target.value),children:N.map(o=>e.jsx("option",{value:o,children:o.toUpperCase()},o))})]}),w==="import"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["File",e.jsx("input",{type:"file",onChange:g,accept:`.${j}`})]}),e.jsx("button",{className:"nice-import-export__action-btn",onClick:r,disabled:!n,children:"Start Import"})]}),w==="export"&&e.jsx("button",{className:"nice-import-export__action-btn",onClick:h,children:"Start Export"})]}),_.length>0&&e.jsxs("div",{className:"nice-import-export__jobs",children:[e.jsx("h4",{children:"Recent Jobs"}),e.jsxs("table",{className:"nice-import-export__jobs-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Format"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Progress"}),e.jsx("th",{children:"Errors"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:_.map(o=>e.jsxs("tr",{children:[e.jsx("td",{children:o.type}),e.jsx("td",{children:o.format.toUpperCase()}),e.jsx("td",{children:e.jsx("span",{className:`nice-import-export__status nice-import-export__status--${o.status}`,children:o.status})}),e.jsx("td",{children:o.processedRows!=null&&o.totalRows?`${o.processedRows} / ${o.totalRows}`:"—"}),e.jsx("td",{children:o.errorCount??0}),e.jsx("td",{children:o.createdAt}),e.jsx("td",{children:o.type==="export"&&o.status==="completed"&&y&&e.jsx("button",{onClick:()=>y(o.id),children:"Download"})})]},o.id))})]})]})]})}),$=i.createContext({flags:{}});function Q({config:F,children:u}){return e.jsx($.Provider,{value:F,children:u})}function M(F){const u=i.useContext($);return i.useMemo(()=>{const p=u.flags[F];return p===void 0?{enabled:!1}:typeof p=="boolean"?{enabled:p}:{enabled:p>0,percentage:p}},[u.flags,F])}function G({flag:F,fallback:u=null,children:p}){const{enabled:m}=M(F);return e.jsx(e.Fragment,{children:m?p:u})}const I={low:"#2196f3",medium:"#ff9800",high:"#f44336",critical:"#9c27b0"},L={field:"Hidden Field",endpoint:"Decoy Endpoint",file:"Canary File",credential:"Fake Credential",cookie:"Tracking Cookie"},X=i.forwardRef(function({tokens:u,events:p,onCreate:m,onToggle:N,onDelete:_,onDismissEvent:x,title:l="Honey Tokens",className:y,style:f},c){const[C,w]=i.useState(""),[b,v]=i.useState(!1),[k,j]=i.useState(""),[t,n]=i.useState("field"),[d,r]=i.useState("medium"),[h,g]=i.useState(""),S=i.useMemo(()=>u.filter(s=>s.name.toLowerCase().includes(C.toLowerCase())||s.location.toLowerCase().includes(C.toLowerCase())),[u,C]),o=i.useMemo(()=>[...p].sort((s,A)=>new Date(A.timestamp).getTime()-new Date(s.timestamp).getTime()),[p]),E=i.useMemo(()=>{const s=u.filter(D=>D.active).length,A=u.reduce((D,U)=>D+U.tripCount,0),R=p.filter(D=>D.severity==="critical").length;return{activeCount:s,totalCount:u.length,totalTrips:A,criticalEvents:R}},[u,p]),a=()=>{k.trim()&&h.trim()&&m&&(m(k.trim(),t,d,h.trim()),j(""),g(""),v(!1))};return e.jsxs("div",{ref:c,className:`nice-honey-token-dashboard${y?` ${y}`:""}`,style:f,children:[e.jsxs("div",{className:"nice-honey-token-dashboard__header",children:[e.jsx("h2",{children:l}),e.jsxs("div",{className:"nice-honey-token-dashboard__stats",children:[e.jsxs("span",{className:"nice-honey-token-dashboard__stat",children:["Active: ",E.activeCount,"/",E.totalCount]}),e.jsxs("span",{className:"nice-honey-token-dashboard__stat",children:["Trips: ",E.totalTrips]}),E.criticalEvents>0&&e.jsxs("span",{className:"nice-honey-token-dashboard__stat nice-honey-token-dashboard__stat--critical",children:["Critical: ",E.criticalEvents]})]})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__toolbar",children:[e.jsx("input",{type:"text",className:"nice-honey-token-dashboard__search",placeholder:"Search tokens...",value:C,onChange:s=>w(s.target.value)}),m&&e.jsx("button",{className:"nice-honey-token-dashboard__btn",onClick:()=>v(!b),children:b?"Cancel":"+ New Token"})]}),b&&e.jsxs("div",{className:"nice-honey-token-dashboard__create",children:[e.jsx("input",{type:"text",placeholder:"Token name",value:k,onChange:s=>j(s.target.value)}),e.jsx("select",{value:t,onChange:s=>n(s.target.value),children:Object.entries(L).map(([s,A])=>e.jsx("option",{value:s,children:A},s))}),e.jsxs("select",{value:d,onChange:s=>r(s.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]}),e.jsx("input",{type:"text",placeholder:"Location (e.g. /api/admin/secret)",value:h,onChange:s=>g(s.target.value)}),e.jsx("button",{onClick:a,children:"Create"})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__tokens",children:[e.jsxs("h3",{children:["Tokens (",S.length,")"]}),e.jsxs("table",{className:"nice-honey-token-dashboard__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Severity"}),e.jsx("th",{children:"Location"}),e.jsx("th",{children:"Trips"}),e.jsx("th",{children:"Last Tripped"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:S.map(s=>e.jsxs("tr",{className:s.tripCount>0?"nice-honey-token-dashboard__row--tripped":"",children:[e.jsx("td",{children:s.name}),e.jsx("td",{children:L[s.type]}),e.jsx("td",{children:e.jsx("span",{className:"nice-honey-token-dashboard__severity",style:{color:I[s.severity]},children:s.severity})}),e.jsx("td",{children:e.jsx("code",{children:s.location})}),e.jsx("td",{children:s.tripCount}),e.jsx("td",{children:s.lastTripped??"—"}),e.jsx("td",{children:e.jsx("span",{className:`nice-honey-token-dashboard__status--${s.active?"active":"inactive"}`,children:s.active?"Active":"Inactive"})}),e.jsxs("td",{children:[N&&e.jsx("button",{onClick:()=>N(s.id,!s.active),children:s.active?"Disable":"Enable"}),_&&e.jsx("button",{onClick:()=>_(s.id),children:"Delete"})]})]},s.id))})]})]}),o.length>0&&e.jsxs("div",{className:"nice-honey-token-dashboard__events",children:[e.jsxs("h3",{children:["Recent Events (",o.length,")"]}),e.jsx("div",{className:"nice-honey-token-dashboard__event-list",children:o.map(s=>e.jsxs("div",{className:`nice-honey-token-dashboard__event nice-honey-token-dashboard__event--${s.severity}`,children:[e.jsxs("div",{className:"nice-honey-token-dashboard__event-header",children:[e.jsx("strong",{children:s.tokenName}),e.jsx("span",{className:"nice-honey-token-dashboard__severity",style:{color:I[s.severity]},children:s.severity}),e.jsx("time",{children:s.timestamp})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__event-details",children:[e.jsxs("span",{children:["IP: ",s.sourceIp]}),s.userId&&e.jsxs("span",{children:["User: ",s.userId]}),s.details&&e.jsx("span",{children:s.details})]}),x&&e.jsx("button",{className:"nice-honey-token-dashboard__dismiss",onClick:()=>x(s.id),children:"Dismiss"})]},s.id))})]})]})});exports.FeatureGate=G;exports.NiceAdminAuditLog=V;exports.NiceAdminDashboard=z;exports.NiceAdminNotifications=K;exports.NiceAdminRoles=B;exports.NiceAdminSettings=Y;exports.NiceAdminUsers=O;exports.NiceFeatureFlags=J;exports.NiceFeatureGate=G;exports.NiceFeatureGateProvider=Q;exports.NiceHoneyTokenDashboard=X;exports.NiceImportExport=W;exports.useFeatureGate=M;
package/dist/index.d.ts CHANGED
@@ -193,7 +193,8 @@ export declare interface ImportExportJob {
193
193
  }
194
194
 
195
195
  /**
196
- * {@link NiceAdminAuditLog} — Audit log viewer with search and severity filtering.
196
+ * {@link NiceAdminAuditLog} — Audit log viewer built on {@link NiceDataGrid},
197
+ * with search and severity filtering.
197
198
  */
198
199
  export declare const NiceAdminAuditLog: default_2.ForwardRefExoticComponent<NiceAdminAuditLogProps & default_2.RefAttributes<HTMLDivElement>>;
199
200
 
@@ -211,7 +212,7 @@ export declare interface NiceAdminAuditLogProps {
211
212
  searchable?: boolean;
212
213
  /** Whether to show severity filter. */
213
214
  showSeverityFilter?: boolean;
214
- /** Title. */
215
+ /** Optional heading. When omitted, no header block is rendered. */
215
216
  title?: string;
216
217
  className?: string;
217
218
  style?: default_2.CSSProperties;
@@ -239,7 +240,10 @@ export declare interface NiceAdminDashboardProps {
239
240
  }
240
241
 
241
242
  /**
242
- * {@link NiceAdminNotifications} — Notification management panel.
243
+ * {@link NiceAdminNotifications} — Notification management panel built on
244
+ * {@link NiceDataGrid}. The grid provides search, sorting and an empty state;
245
+ * the redundant "Notification Management" heading is gone (pass `title` to
246
+ * opt back into a header).
243
247
  */
244
248
  export declare const NiceAdminNotifications: default_2.ForwardRefExoticComponent<NiceAdminNotificationsProps & default_2.RefAttributes<HTMLDivElement>>;
245
249
 
@@ -259,14 +263,21 @@ export declare interface NiceAdminNotificationsProps {
259
263
  onCreate?: () => void;
260
264
  /** Called when deleting a notification. */
261
265
  onDelete?: (id: string) => void;
262
- /** Title. */
266
+ /**
267
+ * Optional panel title. When omitted (default) no header block is rendered —
268
+ * the grid stands on its own without a redundant "X Management" heading.
269
+ */
263
270
  title?: string;
264
271
  className?: string;
265
272
  style?: default_2.CSSProperties;
266
273
  }
267
274
 
268
275
  /**
269
- * {@link NiceAdminRoles} — Role management with permission matrix grid.
276
+ * {@link NiceAdminRoles} — Role management built on {@link NiceDataGrid}.
277
+ *
278
+ * The roles are presented as a sortable/searchable data grid (name, description,
279
+ * permission count, user count). Selecting a row opens the permission matrix
280
+ * editor for that role below the grid. No default header is rendered.
270
281
  */
271
282
  export declare const NiceAdminRoles: default_2.ForwardRefExoticComponent<NiceAdminRolesProps & default_2.RefAttributes<HTMLDivElement>>;
272
283
 
@@ -286,7 +297,10 @@ export declare interface NiceAdminRolesProps {
286
297
  onDelete?: (roleId: string) => void;
287
298
  /** Called when renaming a role. */
288
299
  onRename?: (roleId: string, name: string) => void;
289
- /** Title. */
300
+ /**
301
+ * Optional heading. When omitted (default) no header block is rendered —
302
+ * the roles grid speaks for itself.
303
+ */
290
304
  title?: string;
291
305
  className?: string;
292
306
  style?: default_2.CSSProperties;
@@ -316,7 +330,8 @@ export declare interface NiceAdminSettingsProps {
316
330
  }
317
331
 
318
332
  /**
319
- * {@link NiceAdminUsers} — User management table with CRUD and role assignment.
333
+ * {@link NiceAdminUsers} — User management table built on {@link NiceDataGrid}
334
+ * with CRUD, role assignment and status filtering.
320
335
  */
321
336
  export declare const NiceAdminUsers: default_2.ForwardRefExoticComponent<NiceAdminUsersProps & default_2.RefAttributes<HTMLDivElement>>;
322
337
 
@@ -338,7 +353,10 @@ export declare interface NiceAdminUsersProps {
338
353
  onChangeRoles?: (userId: string, roles: string[]) => void;
339
354
  /** Whether to show search. */
340
355
  searchable?: boolean;
341
- /** Title. */
356
+ /**
357
+ * Optional page title. When omitted (default) no header block is rendered —
358
+ * the grid stands on its own. Provide a string to opt back into a heading.
359
+ */
342
360
  title?: string;
343
361
  className?: string;
344
362
  style?: default_2.CSSProperties;