@nice2dev/admin 1.2.0 → 1.2.1
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 +103 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +814 -823
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,108 @@
|
|
|
1
1
|
# @nice2dev/admin — Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8c82c30: 1.2.1 — the decisions that waited since 1.2.0, and the debts the CI gates were holding. One API
|
|
8
|
+
change, agreed: `NiceIconSuggestorAI` suggests Nice icons only. Two stylesheets to import if you use
|
|
9
|
+
the packages: `@nice2dev/social/style.css`, `@nice2dev/ui-science/style.css`. Upgrade notes:
|
|
10
|
+
`documentation/omniverk/OMNIVERK_UPGRADE_1.2.1.md`.
|
|
11
|
+
|
|
12
|
+
**Tree-shaking.** An import from a package no longer brings the whole package. Module-level
|
|
13
|
+
statements that may have a side effect — a `displayName` assigned after each component (now
|
|
14
|
+
`Object.assign` inside `/* @__PURE__ */`, or under a development check for plain functions),
|
|
15
|
+
unannotated `forwardRef` / `memo` / `createContext` / icon-factory calls, spreads, registries filled
|
|
16
|
+
at import, `<style>` tags injected at import, a direct `eval` in ui-math — are gone. One import from
|
|
17
|
+
each of 53 packages: 5066.5 kB → 1171.6 kB (`@nice2dev/ui` 1928.2 kB → 12.9 kB, icon packs 48–275 kB
|
|
18
|
+
→ 1.6–2.6 kB). `defaultViewRegistry` has the Nice\* input controls from the start, each loading its
|
|
19
|
+
module on first render; sixteen controls add their styles to `<head>` on first render.
|
|
20
|
+
|
|
21
|
+
**Dead code.** 405 source files no entry point imported (never on npm) are deleted;
|
|
22
|
+
`NiceClipboardStack` (`@nice2dev/ui`) and `NiceSampleBrowser` (`@nice2dev/ui-audio`), finished and
|
|
23
|
+
documented, are exported.
|
|
24
|
+
|
|
25
|
+
**ui-mobile draws Nice icons.** New peer `@nice2dev/icons ^1.2.0`; `TabIcons`, `DrawerIcons`,
|
|
26
|
+
`HeaderIcons`, the `NiceSwipeActions` presets and the `NiceInfiniteScroll` states are `Ntd*` icons
|
|
27
|
+
instead of pasted `<svg>`, simple glyphs are CSS marks. `@nice2dev/icons` adds `NtdReply` and
|
|
28
|
+
`NtdInbox`; an icon no longer throws without `window.matchMedia`.
|
|
29
|
+
|
|
30
|
+
**`NiceIconSuggestorAI` (breaking, agreed).** `AIIconLibrary` is `'nice'`; `svgPath` and `unicode`
|
|
31
|
+
left `AISuggestedIcon`; the preview is a `<NiceIcon>`, "Copy SVG" is "Copy JSX".
|
|
32
|
+
|
|
33
|
+
**Peer ranges.** Every internal `@nice2dev/*` peer is `^1.2.0` (was as wide as `^1.0.20`), except
|
|
34
|
+
`@nice2dev/icons ^1.2.1` where a package draws an icon new in 1.2.1: ui-mobile (`NtdReply`,
|
|
35
|
+
`NtdInbox`), ui-audio (`NtdMicrophoneOff`) and ui-security (`NtdBackspace`). ui-security, licensing
|
|
36
|
+
(`^1.2.0`) and templates (`^1.2.0`) gain the `@nice2dev/icons` peer: their glyph icons (`⌫`, `←`,
|
|
37
|
+
`→`, `↑`, `↓`) are Nice icons now. `@nice2dev/icons` adds `NtdBackspace`.
|
|
38
|
+
|
|
39
|
+
**Class names inside components.** 834 class names in library stylesheets had no `nice-` prefix
|
|
40
|
+
(`.tab-button`, `.status-badge`, `.selected`, …) and styled every element of that name on the page.
|
|
41
|
+
They follow `nice-{block}__{element}--{modifier}` now — no change on screen. The class theme hooks
|
|
42
|
+
next to `[data-theme]` on seven controls (`dark` on the AI chart / data grid / code and HTML
|
|
43
|
+
editors / form builder, `light-theme` on `NiceMAM` and `NiceVideoAnnotator`) are `nice-dark` /
|
|
44
|
+
`nice-light`; `NiceLowPowerMode` marks `<html>` with `nice-lpm-no-animations` /
|
|
45
|
+
`nice-lpm-reduced-quality`; the `NiceVideoEditor` of `@nice2dev/ui-video` styles its elements under
|
|
46
|
+
`nice-video-studio`, so they no longer collide with the `NiceVideoEditor` of `@nice2dev/ui`.
|
|
47
|
+
Rules for classes nothing rendered are gone, among them the stylesheet of `NiceGanttChart`, which
|
|
48
|
+
left ui-erp in 1.0.10.
|
|
49
|
+
|
|
50
|
+
**Translations.** About 3,400 UI texts in 32 packages were hard-coded; they go through `t()` now,
|
|
51
|
+
with the English text unchanged and pl / de / fr / es / uk in `@nice2dev/i18n` (ui-diagrams,
|
|
52
|
+
ui-presentations and ui-math in their own dictionaries). In `@nice2dev/events` and
|
|
53
|
+
`@nice2dev/admin` that includes column headers, option labels and the statuses and roles they used
|
|
54
|
+
to print raw (`checked-in`, `no-show`) — English labels for those come from the dictionary. ui-3d and ui-graphics read the app's
|
|
55
|
+
global translator, as ui-audio does since 1.2.0 — their own provider overrides it. ui-audio's
|
|
56
|
+
controls used 631 keys the dictionary did not have (English in every language), and the radio
|
|
57
|
+
player showed raw keys (`search_stations`). Texts that were hard-coded **in Polish** — in
|
|
58
|
+
`NiceSidebarNav`, `NiceNetworkDiscoveryPanel`, the backup and smart-home controls,
|
|
59
|
+
`NiceSavedQueryPanel`, `NiceNotificationPreferences`, the ui-buildings panels, the ui-printing
|
|
60
|
+
template editor and the photo editor — default to English now; Polish is in the dictionary. English
|
|
61
|
+
plurals glued on (`result{s}`) are two keys. `presentationsTranslator(lang)` (ui-presentations)
|
|
62
|
+
translates outside its provider.
|
|
63
|
+
|
|
64
|
+
**List props are optional.** 170 list props (`items`, `columns`, `data`, …) in 15 packages that
|
|
65
|
+
were required without a default are optional, with a stable empty default; every one of those
|
|
66
|
+
controls mounts without data (tested). `NiceStockChart` without data no longer computes NaN
|
|
67
|
+
coordinates.
|
|
68
|
+
|
|
69
|
+
**Unstyled components get stylesheets.** 98 components rendered class names no stylesheet had —
|
|
70
|
+
admin panels, auth forms, events rounds and pickers, the ERP invoice / purchase order / VAT table /
|
|
71
|
+
HR dashboard, the radio player, `NiceInbox`, PWA prompts, `NiceViewRenderer`, shells, smart-home,
|
|
72
|
+
… The fixed layout that sat in inline style objects is in classes now, so an app can override it;
|
|
73
|
+
values that depend on data stay inline. **`@nice2dev/social` and `@nice2dev/ui-science` ship a
|
|
74
|
+
stylesheet — import `@nice2dev/social/style.css` / `@nice2dev/ui-science/style.css`.** ui-science's
|
|
75
|
+
`sideEffects` is `["*.css"]`. Colours, spacing and radii in every stylesheet come from theme tokens
|
|
76
|
+
(visible in dark themes: `NiceRecipe` difficulty badges, transcoder states, warehouse heat map).
|
|
77
|
+
|
|
78
|
+
**Icons only from Nice.** About 130 glyphs (`×`, `→`, `↑`) and 100 pasted `<svg>` used as icons
|
|
79
|
+
are Nice icons; 11 `<svg>` stay as the control's own graphic (logos, spinners, checkbox mark). `NiceIcon`
|
|
80
|
+
gains `pin`, `mic-off`, `log-out`, `chevrons-left`, `chevrons-right`, `zoom-in`, `zoom-out`,
|
|
81
|
+
`navigation`, `refresh-ccw`, `minimize` and `smartphone`; `@nice2dev/icons` gains
|
|
82
|
+
`NtdMicrophoneOff`. The `icon` fields of the module, menu, tab, mode, quick-action, scene and admin
|
|
83
|
+
widget DTOs, notification channels and view toolbar items are rendered through `NiceIcon` — they
|
|
84
|
+
used to be printed as text. `NiceRatings` `thumbs` draws shapes instead of emoji.
|
|
85
|
+
|
|
86
|
+
**Dialogs instead of `window.prompt` / `confirm` / `alert`.** New `useNiceDialogs()` — `prompt`,
|
|
87
|
+
`confirm` and `alert` as promises on `NicePromptDialog` / `NiceConfirmDialog` — and
|
|
88
|
+
`NiceConfirmDialog.showReject`. Seventeen controls asked through the browser's blocking dialogs and
|
|
89
|
+
use the library's now (`NiceFileManager`, `NiceHtmlEditor`, `NiceViewRenderer` action `confirm`, the 3D,
|
|
90
|
+
vector and pixel editors, …). Keys pressed in `NicePromptDialog` / `NiceConfirmDialog` no longer
|
|
91
|
+
reach the page's shortcuts (Escape still closes them), and `NicePromptDialog`'s backdrop covers the
|
|
92
|
+
whole viewport.
|
|
93
|
+
|
|
94
|
+
**Smaller fixes.** `NiceFileManager.items` is optional. `NiceMLStudio` status badges: `draft`,
|
|
95
|
+
`registered`, `archived`, `cancelled` get a neutral colour, deploying / stopped deployments theirs.
|
|
96
|
+
Component docs (`doc.json`) list only props the components have. `NiceMobileTabs`: tabs beyond
|
|
97
|
+
`maxTabs` open from "More" (it only logged). `NiceInventoryManager`: new `onCreatePurchaseOrder`;
|
|
98
|
+
without it the "Create PO" button is gone (it only logged). Keyboard: `NiceNavShell` tabs follow the
|
|
99
|
+
WAI-ARIA tabs pattern, clickable `NiceDeviceTile` / `NiceCardGroup` cards and animated icons with
|
|
100
|
+
`trigger="click"` are focusable. ui-math: `CalculatorService.evaluate` parses instead of running
|
|
101
|
+
`new Function` (`asin`, `sinh`, `ceil`, exponents and `angleUnit` were wrong); `ExpressionParser`
|
|
102
|
+
takes `functions`, `constants`, `ignoreCase` and `strict`, multiplies implicitly (`2x`) and reads `^`
|
|
103
|
+
right to left. `InvoiceLine.vatRate` and `VatRate.rate` are documented as fractions (0.23).
|
|
104
|
+
`AmqpServerBinding` is `Record<string, never>`.
|
|
105
|
+
|
|
3
106
|
## 1.2.0
|
|
4
107
|
|
|
5
108
|
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"),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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),C=require("@nice2dev/ui"),n=require("react"),O=n.forwardRef(function(g,b){const{t:s}=C.useNiceTranslation(),{widgets:N,columns:T=4,title:v,headerActions:_,onWidgetClick:d,className:A,style:k}=g,i=v??s("adminDashboard.title","Dashboard");return e.jsxs("div",{ref:b,className:`nice-admin-dashboard ${A??""}`,style:k,children:[e.jsxs("div",{className:"nice-admin-dashboard__header",children:[e.jsx("h2",{children:i}),_&&e.jsx("div",{className:"nice-admin-dashboard__actions",children:_})]}),e.jsx("div",{className:"nice-admin-dashboard__grid",style:{gridTemplateColumns:`repeat(${T}, 1fr)`},children:N.map(h=>e.jsxs("div",{className:`nice-admin-dashboard__widget nice-admin-dashboard__widget--${h.type}`,style:{gridColumn:h.colSpan?`span ${h.colSpan}`:void 0,gridRow:h.rowSpan?`span ${h.rowSpan}`:void 0},onClick:()=>d==null?void 0:d(h),onKeyDown:d?S=>{(S.key==="Enter"||S.key===" ")&&d(h)}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,children:[e.jsxs("div",{className:"nice-admin-dashboard__widget-header",children:[h.icon&&e.jsx("span",{className:"nice-admin-dashboard__widget-icon",children:e.jsx(C.NiceIcon,{name:h.icon,size:16})}),e.jsx("span",{className:"nice-admin-dashboard__widget-title",children:h.title})]}),h.type==="stat"&&e.jsxs("div",{className:"nice-admin-dashboard__stat",children:[e.jsx("span",{className:"nice-admin-dashboard__stat-value",children:h.value}),h.change&&e.jsx("span",{className:`nice-admin-dashboard__stat-change ${h.changePositive?"nice-admin-dashboard__stat-change--positive":"nice-admin-dashboard__stat-change--negative"}`,children:h.change})]}),h.type==="custom"&&h.render&&e.jsx("div",{className:"nice-admin-dashboard__custom",children:h.render()}),(h.type==="chart"||h.type==="table"||h.type==="list")&&h.render&&e.jsx("div",{className:"nice-admin-dashboard__content",children:h.render()})]},h.id))})]})}),q={active:"success",inactive:"secondary",suspended:"danger",pending:"warning"},B=n.forwardRef(function(g,b){const{t:s}=C.useNiceTranslation(),{users:N,availableRoles:T=[],onCreate:v,onEdit:_,onDelete:d,onToggleStatus:A,onChangeRoles:k,searchable:i=!0,title:h,className:S,style:R}=g,[x,D]=n.useState(""),y=n.useMemo(()=>x?N.filter(o=>o.status===x):N,[N,x]),l=n.useMemo(()=>{const o=[{field:"name",header:s("adminUsers.user","User"),sortable:!0,render:(c,p)=>e.jsxs("span",{className:"nice-admin-users__user-cell",children:[e.jsx(C.NiceAvatar,{src:p.avatarUrl,name:p.name,size:"sm"}),e.jsx("span",{children:p.name})]})},{field:"email",header:s("adminUsers.email","Email"),sortable:!0,render:c=>e.jsx("span",{className:"nice-admin-users__email",children:String(c??"")})},{field:"roles",header:s("adminUsers.roles","Roles"),render:(c,p)=>k?e.jsx("select",{multiple:!0,value:p.roles,onChange:f=>{const w=Array.from(f.target.selectedOptions,u=>u.value);k(p.id,w)},className:"nice-admin-users__roles-select","aria-label":s("adminUsers.rolesFor","Roles for {name}").replace("{name}",p.name),children:T.map(f=>e.jsx("option",{value:f,children:f},f))}):e.jsx("span",{className:"nice-admin-users__roles",children:p.roles.map(f=>e.jsx(C.NiceTag,{size:"sm",children:f},f))})},{field:"status",header:s("adminUsers.status","Status"),sortable:!0,render:(c,p)=>{const f=e.jsx(C.NiceBadge,{variant:q[p.status],size:"sm",children:s(`adminUsers.userStatus.${p.status}`,p.status)});if(!A)return e.jsx("span",{className:"nice-admin-users__status-badge",children:f});const w=p.status==="active"?"suspended":"active";return e.jsx("button",{type:"button",className:"nice-admin-users__status-badge nice-admin-users__status-badge--toggle",onClick:()=>A(p.id,w),"aria-label":s("adminUsers.toggleStatusFor","Toggle status for {name}").replace("{name}",p.name),children:f})}},{field:"createdAt",header:s("adminUsers.created","Created"),dataType:"date",sortable:!0},{field:"lastLoginAt",header:s("adminUsers.lastLogin","Last Login"),dataType:"date",sortable:!0,render:c=>c?String(c):"—"}];return(_||d)&&o.push({field:"__actions",header:s("adminUsers.actions","Actions"),align:"right",render:(c,p)=>e.jsxs("span",{className:"nice-admin-users__actions",children:[_&&e.jsx(C.NiceButton,{size:"sm",variant:"ghost",ariaLabel:s("adminUsers.editUser","Edit {name}").replace("{name}",p.name),onClick:()=>_(p),children:e.jsx(C.NiceIcon,{name:"edit"})}),d&&e.jsx(C.NiceButton,{size:"sm",variant:"ghost",ariaLabel:s("adminUsers.deleteUser","Delete {name}").replace("{name}",p.name),onClick:()=>d(p.id),children:e.jsx(C.NiceIcon,{name:"trash"})})]})}),o},[T,k,d,_,A,s]),a=n.useMemo(()=>{if(d)return[{key:"delete",label:s("adminUsers.delete","Delete"),variant:"danger",icon:e.jsx(C.NiceIcon,{name:"trash"}),onClick:o=>o.forEach(c=>d(c))}]},[d,s]),r=e.jsxs("div",{className:"nice-admin-users__toolbar",children:[e.jsx(C.NiceSelect,{value:x,onChange:o=>D(o??""),title:s("adminUsers.filterByStatus","Filter by status"),options:[{value:"",label:s("adminUsers.allStatuses","All statuses")},{value:"active",label:s("adminUsers.userStatus.active","Active")},{value:"inactive",label:s("adminUsers.userStatus.inactive","Inactive")},{value:"suspended",label:s("adminUsers.userStatus.suspended","Suspended")},{value:"pending",label:s("adminUsers.userStatus.pending","Pending")}],size:"sm"}),v&&e.jsxs(C.NiceButton,{size:"sm",variant:"primary",onClick:v,children:[e.jsx(C.NiceIcon,{name:"plus"}),e.jsx("span",{children:s("adminUsers.addUser","Add User")})]})]});return e.jsxs("div",{ref:b,className:`nice-admin-users ${S??""}`,style:R,children:[h!=null&&e.jsxs("div",{className:"nice-admin-users__header",children:[e.jsx("h3",{children:h}),e.jsx("span",{className:"nice-admin-users__count",children:s("adminUsers.count","{count} users").replace("{count}",String(N.length))})]}),e.jsx(C.NiceDataGrid,{columns:l,data:y,keyField:"id",searchable:i,searchPlaceholder:s("adminUsers.searchUsers","Search users…"),selectable:!!d,bulkActions:a,striped:!0,toolbar:r,emptyText:s("adminUsers.noUsers","No users found.")})]})});function H(E){let g=0;for(const b of Object.values(E.permissions))g+=b.length;return g}const V=n.forwardRef(function(g,b){var m;const{t:s}=C.useNiceTranslation(),{roles:N,actions:T,resources:v,onPermissionChange:_,onCreate:d,onDelete:A,onRename:k,title:i,className:h,style:S}=g,[R,x]=n.useState(((m=N[0])==null?void 0:m.id)??null),[D,y]=n.useState(!1),[l,a]=n.useState(""),[r,o]=n.useState(""),[c,p]=n.useState(null),f=N.find(t=>t.id===R),w=n.useCallback(()=>{!l.trim()||!d||(d(l.trim(),r.trim()),a(""),o(""),y(!1))},[l,r,d]),u=(t,j,F)=>{var U;return((U=t.permissions[j])==null?void 0:U.includes(F))??!1},L=n.useMemo(()=>[{field:"name",header:s("adminRoles.role","Role"),sortable:!0,render:(t,j)=>e.jsxs("span",{className:"nice-admin-roles__name-cell",children:[j.color&&e.jsx("span",{className:"nice-admin-roles__color-dot",style:{background:j.color},"aria-hidden":"true"}),e.jsx("span",{children:j.name}),j.isSystem&&e.jsx(C.NiceIcon,{name:"lock",size:"sm",title:s("adminRoles.systemRole","System role"),className:"nice-admin-roles__system-icon"})]})},{field:"description",header:s("adminRoles.description","Description"),sortable:!0,render:(t,j)=>j.description??"—"},{field:"permissionCount",header:s("adminRoles.permissions","Permissions"),align:"right",dataType:"number",sortable:!0,render:(t,j)=>H(j)},{field:"userCount",header:s("adminRoles.users","Users"),align:"right",dataType:"number",sortable:!0,render:(t,j)=>j.userCount??0}],[s]);return e.jsxs("div",{ref:b,className:`nice-admin-roles ${h??""}`,style:S,children:[e.jsx(C.NicePromptDialog,{open:c!==null,title:s("adminRoles.newRoleName","New role name"),defaultValue:c==null?void 0:c.name,onSubmit:t=>{c&&t&&(k==null||k(c.id,t)),p(null)},onCancel:()=>p(null)}),(i||d)&&e.jsxs("div",{className:"nice-admin-roles__header",children:[i&&e.jsx("h3",{children:i}),d&&e.jsx("button",{onClick:()=>y(!D),children:s("adminRoles.newRole","+ New Role")})]}),D&&e.jsxs("div",{className:"nice-admin-roles__create-form",children:[e.jsx("input",{type:"text",value:l,onChange:t=>a(t.target.value),placeholder:s("adminRoles.roleName","Role name")}),e.jsx("input",{type:"text",value:r,onChange:t=>o(t.target.value),placeholder:s("adminRoles.description","Description")}),e.jsx("button",{onClick:w,disabled:!l.trim(),children:s("adminRoles.create","Create")}),e.jsx("button",{onClick:()=>y(!1),children:s("adminRoles.cancel","Cancel")})]}),e.jsx(C.NiceDataGrid,{className:"nice-admin-roles__grid",columns:L,data:N,keyField:"id",searchable:!0,striped:!0,size:"sm",selectable:!1,onRowClick:t=>x(t.id)}),f&&e.jsxs("div",{className:"nice-admin-roles__matrix-wrap",children:[f.description&&e.jsx("p",{className:"nice-admin-roles__description",children:f.description}),e.jsxs("table",{className:"nice-admin-roles__matrix",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("adminRoles.resource","Resource")}),T.map(t=>e.jsx("th",{title:t.description,children:t.label},t.id))]})}),e.jsx("tbody",{children:v.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.label}),T.map(j=>{const F=u(f,t.id,j.id);return e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:F,onChange:()=>_==null?void 0:_(f.id,t.id,j.id,!F),disabled:f.isSystem})},j.id)})]},t.id))})]}),!f.isSystem&&e.jsxs("div",{className:"nice-admin-roles__role-actions",children:[k&&e.jsx("button",{onClick:()=>p(f),children:s("adminRoles.rename","Rename")}),A&&e.jsx("button",{onClick:()=>A(f.id),children:s("adminRoles.deleteRole","Delete Role")})]})]})]})}),Y={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"}},K=n.forwardRef(function(g,b){const{t:s}=C.useNiceTranslation(),{entries:N,onEntryClick:T,onLoadMore:v,hasMore:_=!1,searchable:d=!0,showSeverityFilter:A=!0,title:k,className:i,style:h}=g,[S,R]=n.useState(""),[x,D]=n.useState(""),y=n.useMemo(()=>{let a=N;if(x&&(a=a.filter(r=>r.severity===x)),S.trim()){const r=S.toLowerCase();a=a.filter(o=>{var c;return o.actorName.toLowerCase().includes(r)||o.action.toLowerCase().includes(r)||o.resource.toLowerCase().includes(r)||((c=o.details)==null?void 0:c.toLowerCase().includes(r))})}return a},[N,x,S]),l=n.useMemo(()=>[{field:"timestamp",header:s("adminAuditLog.timestamp","Timestamp"),sortable:!0,width:170},{field:"severity",header:s("adminAuditLog.severity","Severity"),sortable:!0,width:120,render:(a,r)=>{const o=Y[r.severity];return e.jsxs("span",{className:"nice-admin-audit-log__severity",style:{color:o.color},children:[e.jsx(C.NiceIcon,{name:o.icon,size:14}),s(`adminAuditLog.short.${r.severity}`,o.label)]})}},{field:"actorName",header:s("adminAuditLog.actor","Actor"),sortable:!0},{field:"action",header:s("adminAuditLog.action","Action"),sortable:!0},{field:"resource",header:s("adminAuditLog.resource","Resource"),sortable:!0,render:(a,r)=>e.jsxs(e.Fragment,{children:[r.resource,r.resourceId?` #${r.resourceId}`:""]})},{field:"ipAddress",header:"IP",width:130,render:a=>a??"—"},{field:"details",header:s("adminAuditLog.details","Details"),render:a=>e.jsx("span",{className:"nice-admin-audit-log__details",children:a??"—"})}],[s]);return e.jsxs("div",{ref:b,className:`nice-admin-audit-log ${i??""}`,style:h,children:[k&&e.jsx("div",{className:"nice-admin-audit-log__header",children:e.jsx("h3",{children:k})}),e.jsxs("div",{className:"nice-admin-audit-log__toolbar",children:[d&&e.jsx("input",{type:"text",value:S,onChange:a=>R(a.target.value),placeholder:s("adminAuditLog.searchAuditLog","Search audit log…"),className:"nice-admin-audit-log__search"}),A&&e.jsxs("select",{value:x,onChange:a=>D(a.target.value),className:"nice-admin-audit-log__severity-filter",children:[e.jsx("option",{value:"",children:s("adminAuditLog.allSeverities","All severities")}),e.jsx("option",{value:"info",children:s("adminAuditLog.info","Info")}),e.jsx("option",{value:"warning",children:s("adminAuditLog.warning","Warning")}),e.jsx("option",{value:"error",children:s("adminAuditLog.error","Error")}),e.jsx("option",{value:"critical",children:s("adminAuditLog.critical","Critical")})]})]}),e.jsx(C.NiceDataGrid,{columns:l,data:y,keyField:"id",striped:!0,size:"sm",emptyText:s("adminAuditLog.noEntries","No audit log entries found."),onRowClick:T?a=>T(a):void 0}),_&&v&&e.jsx("button",{className:"nice-admin-audit-log__load-more",onClick:v,children:s("adminAuditLog.loadMore","Load more")})]})}),J=n.forwardRef(function(g,b){const{t:s}=C.useNiceTranslation(),{settings:N,onSave:T,onChange:v,onReset:_,saving:d=!1,title:A,className:k,style:i}=g,h=A??s("adminSettings.title","Settings"),[S,R]=n.useState(()=>{const a={};for(const r of N)a[r.key]=r.value;return a}),x=n.useCallback((a,r)=>{R(o=>({...o,[a]:r})),v==null||v(a,r)},[v]),D=n.useCallback(()=>{T==null||T(S)},[T,S]),y=new Map;for(const a of N){const r=a.section??s("adminSettings.general","General");y.has(r)||y.set(r,[]),y.get(r).push(a)}const l=a=>{var o;const r=S[a.key];switch(a.type){case"boolean":return e.jsxs("label",{className:"nice-admin-settings__toggle",children:[e.jsx("input",{type:"checkbox",checked:!!r,onChange:c=>x(a.key,c.target.checked)}),a.label]});case"select":return e.jsx("select",{value:String(r??""),onChange:c=>x(a.key,c.target.value),className:"nice-admin-settings__select",children:(o=a.options)==null?void 0:o.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))});case"textarea":return e.jsx("textarea",{value:String(r??""),onChange:c=>x(a.key,c.target.value),placeholder:a.placeholder,className:"nice-admin-settings__textarea",rows:4});case"number":return e.jsx("input",{type:"number",value:r!=null?Number(r):"",onChange:c=>x(a.key,parseFloat(c.target.value)||0),placeholder:a.placeholder,className:"nice-admin-settings__input"});case"color":return e.jsx("input",{type:"color",value:String(r??"#000000"),onChange:c=>x(a.key,c.target.value),className:"nice-admin-settings__color"});case"password":return e.jsx("input",{type:"password",value:String(r??""),onChange:c=>x(a.key,c.target.value),placeholder:a.placeholder,className:"nice-admin-settings__input",autoComplete:"new-password"});default:return e.jsx("input",{type:"text",value:String(r??""),onChange:c=>x(a.key,c.target.value),placeholder:a.placeholder,className:"nice-admin-settings__input"})}};return e.jsxs("div",{ref:b,className:`nice-admin-settings ${k??""}`,style:i,children:[e.jsx("div",{className:"nice-admin-settings__header",children:e.jsx("h3",{children:h})}),Array.from(y.entries()).map(([a,r])=>e.jsxs("fieldset",{className:"nice-admin-settings__section",children:[e.jsx("legend",{children:a}),r.map(o=>e.jsxs("div",{className:"nice-admin-settings__field",children:[o.type!=="boolean"&&e.jsxs("label",{className:"nice-admin-settings__label",children:[o.label,o.required&&e.jsx("span",{className:"nice-admin-settings__required",children:"*"})]}),o.description&&e.jsx("p",{className:"nice-admin-settings__description",children:o.description}),l(o)]},o.key))]},a)),e.jsxs("div",{className:"nice-admin-settings__actions",children:[e.jsx("button",{className:"nice-admin-settings__save-btn",onClick:D,disabled:d,children:d?s("adminSettings.saving","Saving…"):s("adminSettings.saveSettings","Save Settings")}),_&&e.jsx("button",{className:"nice-admin-settings__reset-btn",onClick:_,children:s("adminSettings.resetToDefaults","Reset to Defaults")})]})]})}),W=n.forwardRef(function(g,b){const{t:s}=C.useNiceTranslation(),{notifications:N,availableChannels:T=["email","push","sms","in-app","webhook"],onToggle:v,onEdit:_,onTest:d,onCreate:A,onDelete:k,title:i,className:h,style:S}=g,R=n.useMemo(()=>{const D=[{field:"enabled",header:s("adminNotifications.enabled","Enabled"),align:"center",width:90,sortable:!0,render:(y,l)=>e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:()=>v==null?void 0:v(l.id,!l.enabled),"aria-label":s("adminNotifications.toggle","Toggle {name}").replace("{name}",l.name)})},{field:"name",header:s("adminNotifications.name","Name"),sortable:!0,render:(y,l)=>e.jsxs("div",{className:"nice-admin-notifications__name",children:[e.jsx("strong",{children:l.name}),l.description&&e.jsx("small",{className:"nice-admin-notifications__description",children:l.description})]})},{field:"event",header:s("adminNotifications.event","Event"),sortable:!0,render:(y,l)=>e.jsx("code",{children:l.event})},{field:"channels",header:s("adminNotifications.channels","Channels"),render:(y,l)=>l.channels.join(", ")},{field:"lastSentAt",header:s("adminNotifications.lastSent","Last Sent"),sortable:!0,render:(y,l)=>l.lastSentAt??"—"},{field:"sentCount",header:s("adminNotifications.sent","Sent"),align:"right",dataType:"number",sortable:!0,render:(y,l)=>l.sentCount??0}];return(_||d||k)&&D.push({field:"__actions",header:s("adminNotifications.actions","Actions"),align:"right",sortable:!1,render:(y,l)=>e.jsxs("div",{className:"nice-admin-notifications__actions",children:[_&&e.jsx("button",{type:"button",onClick:()=>_(l),children:s("adminNotifications.edit","Edit")}),d&&e.jsx("button",{type:"button",onClick:()=>d(l.id),children:s("adminNotifications.test","Test")}),k&&e.jsx("button",{type:"button",onClick:()=>k(l.id),children:s("adminNotifications.delete","Delete")})]})}),D},[v,_,d,k,s]),x=A?e.jsx("button",{type:"button",onClick:A,className:"nice-admin-notifications__create",children:s("adminNotifications.newNotification","New Notification")}):void 0;return e.jsxs("div",{ref:b,className:`nice-admin-notifications ${h??""}`,style:S,children:[i&&e.jsx("div",{className:"nice-admin-notifications__header",children:e.jsx("h3",{children:i})}),e.jsx(C.NiceDataGrid,{data:N,columns:R,keyField:"id",searchable:!0,striped:!0,emptyText:s("adminNotifications.noNotifications","No notifications found."),toolbar:x})]})}),Q=n.forwardRef(function(g,b){const{t:s}=C.useNiceTranslation(),{flags:N,environmentNames:T=["development","staging","production"],onToggle:v,onPercentageChange:_,onCreate:d,onDelete:A,onEdit:k,title:i,className:h,style:S}=g,R=i??s("featureFlags.title","Feature Flags"),[x,D]=n.useState(""),[y,l]=n.useState(!1),[a,r]=n.useState(""),[o,c]=n.useState(""),[p,f]=n.useState(""),w=n.useMemo(()=>{if(!x.trim())return N;const m=x.toLowerCase();return N.filter(t=>{var j,F;return t.key.toLowerCase().includes(m)||t.name.toLowerCase().includes(m)||((j=t.description)==null?void 0:j.toLowerCase().includes(m))||((F=t.tags)==null?void 0:F.some(U=>U.toLowerCase().includes(m)))})},[N,x]),u=n.useCallback(()=>{!a.trim()||!o.trim()||!d||(d(a.trim(),o.trim(),p.trim()),r(""),c(""),f(""),l(!1))},[a,o,p,d]),L=(m,t)=>m.environments.find(j=>j.name===t);return e.jsxs("div",{ref:b,className:`nice-feature-flags ${h??""}`,style:S,children:[e.jsxs("div",{className:"nice-feature-flags__header",children:[e.jsx("h3",{children:R}),e.jsx("span",{className:"nice-feature-flags__count",children:s("featureFlags.count","{count} flags").replace("{count}",String(N.length))}),d&&e.jsx("button",{onClick:()=>l(!y),children:s("featureFlags.newFlag","+ New Flag")})]}),y&&e.jsxs("div",{className:"nice-feature-flags__create-form",children:[e.jsx("input",{type:"text",value:a,onChange:m=>r(m.target.value),placeholder:"flag_key"}),e.jsx("input",{type:"text",value:o,onChange:m=>c(m.target.value),placeholder:s("featureFlags.displayName","Display name")}),e.jsx("input",{type:"text",value:p,onChange:m=>f(m.target.value),placeholder:s("featureFlags.description","Description")}),e.jsx("button",{onClick:u,disabled:!a.trim()||!o.trim(),children:s("featureFlags.create","Create")}),e.jsx("button",{onClick:()=>l(!1),children:s("featureFlags.cancel","Cancel")})]}),e.jsx("input",{type:"text",value:x,onChange:m=>D(m.target.value),placeholder:s("featureFlags.searchFlags","Search flags…"),className:"nice-feature-flags__search"}),w.length===0?e.jsx("p",{className:"nice-feature-flags__empty",children:s("featureFlags.noFeatureFlagsFound","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:s("featureFlags.flag","Flag")}),T.map(m=>e.jsx("th",{children:m},m)),e.jsx("th",{children:s("featureFlags.tags","Tags")}),e.jsx("th",{children:s("featureFlags.updated","Updated")}),e.jsx("th",{children:s("featureFlags.actions","Actions")})]})}),e.jsx("tbody",{children:w.map(m=>{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:m.name}),e.jsx("code",{className:"nice-feature-flags__key",children:m.key}),m.description&&e.jsx("small",{children:m.description})]})}),T.map(j=>{const F=L(m,j);return e.jsxs("td",{className:"nice-feature-flags__env-cell",children:[e.jsx("input",{type:"checkbox",checked:(F==null?void 0:F.enabled)??!1,onChange:()=>v==null?void 0:v(m.id,j,!((F==null?void 0:F.enabled)??!1))}),(F==null?void 0:F.percentage)!=null&&e.jsx("input",{type:"number",min:0,max:100,value:F.percentage,onChange:U=>_==null?void 0:_(m.id,j,parseInt(U.target.value,10)||0),className:"nice-feature-flags__percentage",title:s("featureFlags.rollout","Rollout %")})]},j)}),e.jsx("td",{children:((t=m.tags)==null?void 0:t.join(", "))||"—"}),e.jsx("td",{children:m.updatedAt??m.createdAt}),e.jsxs("td",{className:"nice-feature-flags__actions",children:[k&&e.jsx("button",{onClick:()=>k(m),children:s("featureFlags.edit","Edit")}),A&&e.jsx("button",{onClick:()=>A(m.id),children:s("featureFlags.delete","Delete")})]})]},m.id)})})]})]})}),X=n.forwardRef(function(g,b){var w;const{t:s}=C.useNiceTranslation(),{entities:N,formats:T=["json","csv","xlsx"],jobs:v=[],onImport:_,onExport:d,onDownload:A,title:k,className:i,style:h}=g,S=k??s("importExport.title","Import / Export"),[R,x]=n.useState("export"),[D,y]=n.useState(((w=N[0])==null?void 0:w.id)??""),[l,a]=n.useState(T[0]??"json"),[r,o]=n.useState(null),c=n.useCallback(()=>{!_||!r||!D||(_(D,l,r),o(null))},[_,D,l,r]),p=n.useCallback(()=>{!d||!D||d(D,l)},[d,D,l]),f=u=>{var L;o(((L=u.target.files)==null?void 0:L[0])??null)};return e.jsxs("div",{ref:b,className:`nice-import-export ${i??""}`,style:h,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 ${R==="import"?"nice-import-export__tab--active":""}`,onClick:()=>x("import"),children:s("importExport.import","Import")}),e.jsx("button",{className:`nice-import-export__tab ${R==="export"?"nice-import-export__tab--active":""}`,onClick:()=>x("export"),children:s("importExport.export","Export")})]}),e.jsxs("div",{className:"nice-import-export__form",children:[e.jsxs("label",{children:[s("importExport.entity","Entity"),e.jsx("select",{value:D,onChange:u=>y(u.target.value),children:N.map(u=>e.jsx("option",{value:u.id,children:u.label},u.id))})]}),e.jsxs("label",{children:[s("importExport.format","Format"),e.jsx("select",{value:l,onChange:u=>a(u.target.value),children:T.map(u=>e.jsx("option",{value:u,children:u.toUpperCase()},u))})]}),R==="import"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[s("importExport.file","File"),e.jsx("input",{type:"file",onChange:f,accept:`.${l}`})]}),e.jsx("button",{className:"nice-import-export__action-btn",onClick:c,disabled:!r,children:s("importExport.startImport","Start Import")})]}),R==="export"&&e.jsx("button",{className:"nice-import-export__action-btn",onClick:p,children:s("importExport.startExport","Start Export")})]}),v.length>0&&e.jsxs("div",{className:"nice-import-export__jobs",children:[e.jsx("h4",{children:s("importExport.recentJobs","Recent Jobs")}),e.jsxs("table",{className:"nice-import-export__jobs-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("importExport.type","Type")}),e.jsx("th",{children:s("importExport.format","Format")}),e.jsx("th",{children:s("importExport.status","Status")}),e.jsx("th",{children:s("importExport.progress","Progress")}),e.jsx("th",{children:s("importExport.errors","Errors")}),e.jsx("th",{children:s("importExport.created","Created")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:v.map(u=>e.jsxs("tr",{children:[e.jsx("td",{children:u.type}),e.jsx("td",{children:u.format.toUpperCase()}),e.jsx("td",{children:e.jsx("span",{className:`nice-import-export__status nice-import-export__status--${u.status}`,children:u.status})}),e.jsx("td",{children:u.processedRows!=null&&u.totalRows?`${u.processedRows} / ${u.totalRows}`:"—"}),e.jsx("td",{children:u.errorCount??0}),e.jsx("td",{children:u.createdAt}),e.jsx("td",{children:u.type==="export"&&u.status==="completed"&&A&&e.jsx("button",{onClick:()=>A(u.id),children:s("importExport.download","Download")})})]},u.id))})]})]})]})}),M=n.createContext({flags:{}});function Z({config:E,children:g}){return e.jsx(M.Provider,{value:E,children:g})}function P(E){const g=n.useContext(M);return n.useMemo(()=>{const b=g.flags[E];return b===void 0?{enabled:!1}:typeof b=="boolean"?{enabled:b}:{enabled:b>0,percentage:b}},[g.flags,E])}function G({flag:E,fallback:g=null,children:b}){const{enabled:s}=P(E);return e.jsx(e.Fragment,{children:s?b:g})}const I={low:"#2196f3",medium:"#ff9800",high:"#f44336",critical:"#9c27b0"},$={field:"Hidden Field",endpoint:"Decoy Endpoint",file:"Canary File",credential:"Fake Credential",cookie:"Tracking Cookie"},ee=n.forwardRef(function({tokens:g,events:b,onCreate:s,onToggle:N,onDelete:T,onDismissEvent:v,title:_,className:d,style:A},k){const{t:i}=C.useNiceTranslation(),h=_??i("honeyTokenDashboard.title","Honey Tokens"),[S,R]=n.useState(""),[x,D]=n.useState(!1),[y,l]=n.useState(""),[a,r]=n.useState("field"),[o,c]=n.useState("medium"),[p,f]=n.useState(""),w=n.useMemo(()=>g.filter(t=>t.name.toLowerCase().includes(S.toLowerCase())||t.location.toLowerCase().includes(S.toLowerCase())),[g,S]),u=n.useMemo(()=>[...b].sort((t,j)=>new Date(j.timestamp).getTime()-new Date(t.timestamp).getTime()),[b]),L=n.useMemo(()=>{const t=g.filter(U=>U.active).length,j=g.reduce((U,z)=>U+z.tripCount,0),F=b.filter(U=>U.severity==="critical").length;return{activeCount:t,totalCount:g.length,totalTrips:j,criticalEvents:F}},[g,b]),m=()=>{y.trim()&&p.trim()&&s&&(s(y.trim(),a,o,p.trim()),l(""),f(""),D(!1))};return e.jsxs("div",{ref:k,className:`nice-honey-token-dashboard${d?` ${d}`:""}`,style:A,children:[e.jsxs("div",{className:"nice-honey-token-dashboard__header",children:[e.jsx("h2",{children:h}),e.jsxs("div",{className:"nice-honey-token-dashboard__stats",children:[e.jsxs("span",{className:"nice-honey-token-dashboard__stat",children:["Active: ",L.activeCount,"/",L.totalCount]}),e.jsxs("span",{className:"nice-honey-token-dashboard__stat",children:["Trips: ",L.totalTrips]}),L.criticalEvents>0&&e.jsxs("span",{className:"nice-honey-token-dashboard__stat nice-honey-token-dashboard__stat--critical",children:["Critical: ",L.criticalEvents]})]})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__toolbar",children:[e.jsx("input",{type:"text",className:"nice-honey-token-dashboard__search",placeholder:i("honeyTokenDashboard.searchTokens","Search tokens..."),value:S,onChange:t=>R(t.target.value)}),s&&e.jsx("button",{className:"nice-honey-token-dashboard__btn",onClick:()=>D(!x),children:x?i("honeyTokenDashboard.cancel","Cancel"):i("honeyTokenDashboard.newToken","+ New Token")})]}),x&&e.jsxs("div",{className:"nice-honey-token-dashboard__create",children:[e.jsx("input",{type:"text",placeholder:i("honeyTokenDashboard.tokenName","Token name"),value:y,onChange:t=>l(t.target.value)}),e.jsx("select",{value:a,onChange:t=>r(t.target.value),children:Object.entries($).map(([t,j])=>e.jsx("option",{value:t,children:i(`honeyTokenDashboard.tokenType.${t}`,j)},t))}),e.jsxs("select",{value:o,onChange:t=>c(t.target.value),children:[e.jsx("option",{value:"low",children:i("honeyTokenDashboard.low","Low")}),e.jsx("option",{value:"medium",children:i("honeyTokenDashboard.medium","Medium")}),e.jsx("option",{value:"high",children:i("honeyTokenDashboard.high","High")}),e.jsx("option",{value:"critical",children:i("honeyTokenDashboard.critical","Critical")})]}),e.jsx("input",{type:"text",placeholder:i("honeyTokenDashboard.locationEGApiAdmin","Location (e.g. /api/admin/secret)"),value:p,onChange:t=>f(t.target.value)}),e.jsx("button",{onClick:m,children:i("honeyTokenDashboard.create","Create")})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__tokens",children:[e.jsxs("h3",{children:["Tokens (",w.length,")"]}),e.jsxs("table",{className:"nice-honey-token-dashboard__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:i("honeyTokenDashboard.name","Name")}),e.jsx("th",{children:i("honeyTokenDashboard.type","Type")}),e.jsx("th",{children:i("honeyTokenDashboard.severity","Severity")}),e.jsx("th",{children:i("honeyTokenDashboard.location","Location")}),e.jsx("th",{children:i("honeyTokenDashboard.trips","Trips")}),e.jsx("th",{children:i("honeyTokenDashboard.lastTripped","Last Tripped")}),e.jsx("th",{children:i("honeyTokenDashboard.status","Status")}),e.jsx("th",{children:i("honeyTokenDashboard.actions","Actions")})]})}),e.jsx("tbody",{children:w.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:i(`honeyTokenDashboard.tokenType.${t.type}`,$[t.type])}),e.jsx("td",{children:e.jsx("span",{className:"nice-honey-token-dashboard__severity",style:{color:I[t.severity]},children:i(`honeyTokenDashboard.${t.severity}`,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?i("honeyTokenDashboard.active","Active"):i("honeyTokenDashboard.inactive","Inactive")})}),e.jsxs("td",{children:[N&&e.jsx("button",{onClick:()=>N(t.id,!t.active),children:t.active?i("honeyTokenDashboard.disable","Disable"):i("honeyTokenDashboard.enable","Enable")}),T&&e.jsx("button",{onClick:()=>T(t.id),children:i("honeyTokenDashboard.delete","Delete")})]})]},t.id))})]})]}),u.length>0&&e.jsxs("div",{className:"nice-honey-token-dashboard__events",children:[e.jsx("h3",{children:i("honeyTokenDashboard.recentEvents","Recent Events ({count})").replace("{count}",String(u.length))}),e.jsx("div",{className:"nice-honey-token-dashboard__event-list",children:u.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:I[t.severity]},children:i(`honeyTokenDashboard.${t.severity}`,t.severity)}),e.jsx("time",{children:t.timestamp})]}),e.jsxs("div",{className:"nice-honey-token-dashboard__event-details",children:[e.jsx("span",{children:i("honeyTokenDashboard.ip","IP: {ip}").replace("{ip}",t.sourceIp)}),t.userId&&e.jsx("span",{children:i("honeyTokenDashboard.user","User: {user}").replace("{user}",t.userId)}),t.details&&e.jsx("span",{children:t.details})]}),v&&e.jsx("button",{className:"nice-honey-token-dashboard__dismiss",onClick:()=>v(t.id),children:i("honeyTokenDashboard.dismiss","Dismiss")})]},t.id))})]})]})});exports.FeatureGate=G;exports.NiceAdminAuditLog=K;exports.NiceAdminDashboard=O;exports.NiceAdminNotifications=W;exports.NiceAdminRoles=V;exports.NiceAdminSettings=J;exports.NiceAdminUsers=B;exports.NiceFeatureFlags=Q;exports.NiceFeatureGate=G;exports.NiceFeatureGateProvider=Z;exports.NiceHoneyTokenDashboard=ee;exports.NiceImportExport=X;exports.useFeatureGate=P;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare interface AdminWidget {
|
|
|
52
52
|
change?: string;
|
|
53
53
|
/** Whether change is positive. */
|
|
54
54
|
changePositive?: boolean;
|
|
55
|
-
/**
|
|
55
|
+
/** NiceIcon name, e.g. `users` (until 1.2.1 the dashboard printed it as text). */
|
|
56
56
|
icon?: string;
|
|
57
57
|
/** Custom render function. */
|
|
58
58
|
render?: () => default_2.ReactNode;
|