@nice2dev/ui 1.3.15 → 1.3.17

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/{NiceDataGrid-BwiBkE3u.cjs → NiceDataGrid-aNPAHsWy.cjs} +1 -1
  3. package/dist/NiceEventOrchestrator.doc-Dwtq2s_L.cjs +6 -0
  4. package/dist/{NiceForm-Cxvh2O6y.cjs → NiceForm-BtRBLffD.cjs} +1 -1
  5. package/dist/{NiceMention-CYTx04JY.cjs → NiceMention-CMqAGvO0.cjs} +1 -1
  6. package/dist/NiceModuleLifecyclePanel-ugNtHimh.cjs +1 -0
  7. package/dist/{NicePagination-CKsAP38Q.cjs → NicePagination-D7XxeNFz.cjs} +1 -1
  8. package/dist/{NiceSavedQueryPanel-CN1rCPFs.cjs → NiceSavedQueryPanel-JHrSlHAV.cjs} +1 -1
  9. package/dist/{NiceScheduler-K8ZAqFCQ.cjs → NiceScheduler-2TwOZq-y.cjs} +1 -1
  10. package/dist/{core-lazy-DfNWyf__.cjs → core-lazy-Cda-D35m.cjs} +1 -1
  11. package/dist/data.cjs +1 -1
  12. package/dist/docs/NiceEventOrchestrator.doc.json.mjs +19 -19
  13. package/dist/editors/inputs/NiceNumberInput.mjs +27 -27
  14. package/dist/editors.cjs +1 -1
  15. package/dist/index.cjs +220 -220
  16. package/dist/index.d.ts +129 -62
  17. package/dist/index.mjs +912 -910
  18. package/dist/lazy.cjs +1 -1
  19. package/dist/navigation/NiceFirstRunPreferences.mjs +55 -54
  20. package/dist/navigation/NiceNavShell.mjs +429 -429
  21. package/dist/navigation/NiceSetupWizard.mjs +333 -317
  22. package/dist/navigation/NiceSidebarNav.mjs +1111 -1039
  23. package/dist/navigation/menuBuilderModel.mjs +1 -1
  24. package/dist/navigation/sidebarColors.mjs +67 -39
  25. package/dist/navigation/sidebarNavTypes.mjs +16 -14
  26. package/dist/navigation/sidebarPrefs/NiceSidebarPrefsDisplay.mjs +120 -42
  27. package/dist/navigation.cjs +1 -1
  28. package/dist/navigation.d.ts +32 -6
  29. package/dist/{no-code-BQqK8mvU.cjs → no-code-B3BHeyG-.cjs} +1 -1
  30. package/dist/no-code.cjs +1 -1
  31. package/dist/style.css +2 -2
  32. package/dist/tools/NiceThemeDesigner.mjs +1359 -900
  33. package/dist/tools/NiceThemePreview.mjs +18 -18
  34. package/dist/tools/themeCatalog.mjs +50 -0
  35. package/dist/workflow/NiceWorkflowDesigner.mjs +452 -898
  36. package/package.json +5 -5
  37. package/dist/NiceEventOrchestrator.doc-CxjsLxBG.cjs +0 -6
  38. package/dist/NiceModuleLifecyclePanel-DHHAjwQx.cjs +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,95 @@
1
1
  # [1.0.27] — 2026-06-07
2
2
 
3
+ ## 1.3.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 59a1a84: Icons, showcase feedback round 41:
8
+
9
+ - **Removed** (breaking): NtdGym (use NtdDumbbell), NtdPizzaFood (NtdPizza), NtdDelivery (NtdTruck),
10
+ NtdOmniVerkBadge, NtdOmniVerkLogo, NtdOmniVerkSpinner (`<NtdOmniVerk animation="spin" />` or NiceSpinner) and
11
+ NtdOmniVerkWatermark (NiceLogo).
12
+ - **`animationSpeed`** on every icon, the style decorators and SmilAnimationWrapper — and every animation now runs
13
+ at half its earlier pace by default: CSS animations, `smilAnimation`, gradient animations and the icons' own
14
+ (NtdOmniVerk, NtdOmniVerkAnimated). `animationSpeed={2}` is the old pace; an explicit duration keeps its length.
15
+ createIcon's new `animated` option scales an icon's own SVG animation times.
16
+ - **Redrawn**: NtdNuke, NtdRunning, NtdDumbbell, NtdBeer, NtdCrown, NtdTarget, NtdMolecule, NtdPlate, NtdFood,
17
+ NtdCoffeeFood, NtdTruck, NtdRefresh, NtdLayers, NtdTrash, NtdCoins; NtdPlanet's ring is primary with a thin
18
+ accent rim.
19
+
20
+ - 68db136: NiceThemeDesigner, showcase feedback round 41:
21
+
22
+ - **Opens on a themes tree** (`startScreen`, default `'browser'`): Favorites, My themes and the built-in catalog by
23
+ category, searchable, with a star per theme, New / Duplicate / Edit / Import and **Delete only with `allowDelete`**
24
+ (own themes, behind a confirmation). Own themes and favorites: `themes` / `onThemesChange`,
25
+ `favorites` / `onFavoritesChange`, or kept by the designer in `localStorage` under `storageKey`.
26
+ - **Edit opens the theme in the whole window**: Back, a breadcrumb, **Undo / Redo** (buttons, Ctrl+Z, Ctrl+Shift+Z,
27
+ Ctrl+Y; quick edits of one field make one step), Save for own themes, Save as copy, Discard changes. **Theme Name
28
+ moved into the General section.** `startScreen="edit"` with `theme` opens the editor straight away, as before;
29
+ the New / Clone / Open buttons and the preset picker of the old header are replaced by the tree. `onSave` is new.
30
+ - The catalog is in the library: `NICE_THEME_CATALOG` and `NICE_THEME_CATALOG_ENTRIES` (the showcase reads them).
31
+ - NiceThemePreview: buttons, badges and the active page button take the theme's text-on-fill colours (they used the
32
+ page text colour), the switch thumb the theme's background.
33
+ - NiceThemeProvider: the dark flag (`data-theme`, `color-scheme`) follows a theme set through `setTheme`; a light
34
+ theme applied over a dark prop kept the dark-mode CSS.
35
+ - i18n: 37 `theme.*` keys (the tree, the editor, the catalog categories) in all 12 dictionaries.
36
+
37
+ - 8ae6e97: NiceWorkflowDesigner moves to `@nice2dev/ui-diagrams` (showcase feedback round 41):
38
+
39
+ - **Moved** (breaking for imports): `import { NiceWorkflowDesigner } from '@nice2dev/ui-diagrams'`. The data types
40
+ (`NiceWorkflowDefinition`, `NiceWorkflowState`, `NiceWorkflowTransition`…) stay in `@nice2dev/ui`;
41
+ `NiceWorkflowState.type` also takes ids of your own step kinds.
42
+ - Rebuilt on the diagram canvas: **arrows** between the steps, **automatic layered layout** (left to right, or
43
+ `layoutDirection="TB"`), the whole flow **fitted to the canvas at start**, zoom − / % / + and Fit in the toolbar,
44
+ wheel zoom, pan by dragging the empty canvas.
45
+ - **Step kinds**: `stepTypes` (default start, state, approval, end, error) and `loadStepTypes` (loaded at mount,
46
+ merged by id); "Add step" offers them all.
47
+ - A new step gets a **unique name** and comes **connected from the selected step** (the duplicated "New state"
48
+ dead-end / orphan pair is gone); transitions are drawn from a step's port onto another step or edited in the
49
+ properties panel (name, target, add, delete); a selected transition has its own panel; a problem message selects
50
+ its step.
51
+ - The designer keeps the workflow itself; `onChange` reports every change with the laid-out positions.
52
+
53
+ NiceDiagramEditor, more configurable (backward compatible): `document` (controlled), `nodeTypes` (a palette),
54
+ `autoLayout`, `fitOnMount`, `readOnly`; connections drawn from the ports (`onEdgeCreate` was declared but never
55
+ called); `onChange` fires for every change (only undo / redo reached it — the editor hook memoised on a document the
56
+ model edits in place, which also froze the viewport and the undo state) and no longer during render; `lang` follows
57
+ the app's language by default. DiagramCanvas: `autoFit` / `fitKey` / `refitKey`, `resizable`, `panOnDrag`,
58
+ `onResize`, `ariaLabel`, per-instance arrow markers, curves that leave and enter along their ports' sides, labels on
59
+ the curve's middle. The `dagre` layout is a real layered layout now (cycle breaking, longest-path ranks, barycenter
60
+ ordering, top-left positions, `ranks` in the result); `fitViewport` / `diagramBounds` exported; a layout is one undo
61
+ step.
62
+
63
+ ui-forms: the studio's workflow screen uses the designer from `@nice2dev/ui-diagrams` (new peer dependency).
64
+
65
+ - Updated dependencies [68db136]
66
+ - Updated dependencies [8ae6e97]
67
+ - @nice2dev/ui-core@1.3.17
68
+ - @nice2dev/i18n@1.3.17
69
+
70
+ ## 1.3.16
71
+
72
+ ### Patch Changes
73
+
74
+ - ac962ae: NiceNumberInput: stretched across a form column (or by `controlWidth` / an inherited
75
+ `--nice-field-control-width`), the value takes the free width with − at the left edge and + at the right. It
76
+ kept a 4-character value with both buttons packed into the right corner. A content-sized field stays as narrow
77
+ as before.
78
+ - 0a1cf53: NiceSidebarNav: the tree takes the theme's colours by default, shaded by level (the source header in the
79
+ primary, each level lighter, pages a faint tint of their level), and branch colours (e.g. databases) paint
80
+ nothing — the new colour style `'theme'`. `'bar'` keeps the shades and shows a branch's colour as a bar on the
81
+ left edge (it stepped in with the indent); `'fill'` is unchanged. The source header stays above the scroll area
82
+ (the scrollbar starts a level lower) and the headers above the first visible row stick under it, one per level
83
+ (`stickyHeaders: 'path'`, or `'root'` / `'none'`). `indent: 'none'` drops the indentation. All three are user
84
+ preferences on Preferences → Display; NiceFirstRunPreferences offers the theme colours; NiceNavShell's tabs stay
85
+ uncoloured in the `'theme'` style.
86
+ - 97aaf14: NiceSetupWizard: a step with `final: false` never completes the wizard, even while it is the only one or the
87
+ last one in view — for a first choice whose following steps the host adds later. Its main button reads Next;
88
+ pressed before the next step exists (e.g. the host adds the steps in `validate`), the wizard moves on as soon as
89
+ that step arrives.
90
+ - @nice2dev/i18n@1.3.16
91
+ - @nice2dev/ui-core@1.3.16
92
+
3
93
  ## 1.3.15
4
94
 
5
95
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- "use strict";const t=require("react/jsx-runtime"),y=require("@nice2dev/ui-core"),r=require("react"),pn=require("react-dom"),Wi=require("./NiceForm-Cxvh2O6y.cjs"),qi=require("./devops-cgRBnZVX.cjs"),Vi=require("./NiceModal-BRVzjuUN.cjs"),Ui=require("./NicePagination-CKsAP38Q.cjs"),ys=require("./NiceSelect-BNPXs6FQ.cjs"),Hi=[],Ji=[{target:".nice-filterbuilder",titleKey:"tutorial.filterBuilder.intro.title",title:"Filter builder",contentKey:"tutorial.filterBuilder.intro.content",content:"Build complex AND/OR filter trees: add conditions and nested groups, choose fields and operators, and save reusable presets.",placement:"auto"}],Xi=[{value:"=",label:"Equals"},{value:"<>",label:"Not Equals"},{value:"<",label:"Less Than"},{value:"<=",label:"Less or Equal"},{value:">",label:"Greater Than"},{value:">=",label:"Greater or Equal"},{value:"contains",label:"Contains"},{value:"notcontains",label:"Not Contains"},{value:"startswith",label:"Starts With"},{value:"endswith",label:"Ends With"},{value:"isblank",label:"Is Blank"},{value:"isnotblank",label:"Is Not Blank"}],Yi=({condition:l,fields:x,onChange:m,onRemove:_})=>{const{t:b}=y.useNiceTranslation(),h=x.find(g=>g.field===l.field),N=l.operator==="isblank"||l.operator==="isnotblank",S=h?.operators||Xi;return t.jsxs("div",{className:"nice-filterbuilder__condition",children:[t.jsx("select",{className:"nice-filterbuilder__select",value:l.field,onChange:g=>m({...l,field:g.target.value,value:""}),children:x.map(g=>t.jsx("option",{value:g.field,children:g.label},g.field))}),t.jsx("select",{className:"nice-filterbuilder__select",value:l.operator,onChange:g=>m({...l,operator:g.target.value}),children:S.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))}),!N&&(h?.options?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value}),children:[t.jsx("option",{value:"",children:"--"}),h.options.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]}):h?.type==="boolean"?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value==="true"}),children:[t.jsx("option",{value:"true",children:b("filterBuilder.true","True")}),t.jsx("option",{value:"false",children:b("filterBuilder.false","False")})]}):t.jsx("input",{className:"nice-filterbuilder__input",type:h?.type==="number"?"number":h?.type==="date"?"date":"text",value:String(l.value??""),onChange:g=>m({...l,value:h?.type==="number"?Number(g.target.value):g.target.value})})),t.jsx("button",{"aria-label":b("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]})},vs=({group:l,fields:x,onChange:m,onRemove:_,depth:b,maxDepth:h})=>{const{t:N}=y.useNiceTranslation(),[S,g]=r.useState(!1),Z=()=>m({...l,logic:l.logic==="and"?"or":"and"}),K=l.items.filter(C=>C.type==="condition").length,ee=l.items.length-K,de=[K?`${K} condition${K>1?"s":""}`:"",ee?`${ee} group${ee>1?"s":""}`:""].filter(Boolean).join(" · ")||"empty",ue=()=>{const C={type:"condition",field:x[0]?.field||"",operator:"=",value:""};m({...l,items:[...l.items,C]})},fe=()=>{if(b>=h)return;const C={type:"group",logic:"and",items:[]};m({...l,items:[...l.items,C]})},M=(C,R)=>{const k=[...l.items];k[C]=R,m({...l,items:k})},te=C=>{m({...l,items:l.items.filter((R,k)=>k!==C)})};return t.jsxs("div",{className:`nice-filterbuilder__group nice-filterbuilder__group--depth-${Math.min(b,3)}`,children:[t.jsxs("div",{className:"nice-filterbuilder__group-header",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__collapse",onClick:()=>g(C=>!C),"aria-expanded":!S,title:S?N("filterBuilder.expandGroup","Expand group"):N("filterBuilder.collapseGroup","Collapse group"),children:t.jsx(y.NiceIcon,{name:S?"chevron-right":"chevron-down",size:"sm"})}),t.jsx("button",{className:"nice-filterbuilder__logic",onClick:Z,title:N("filterBuilder.matchClickToSwitch","Match {mode} — click to switch to {other}").replace("{mode}",l.logic==="and"?N("filterBuilder.matchAll","ALL"):N("filterBuilder.matchAny","ANY")).replace("{other}",l.logic==="and"?"OR":"AND"),children:l.logic.toUpperCase()}),S?t.jsx("span",{className:"nice-filterbuilder__summary",children:de}):t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:ue,children:N("filterBuilder.condition","+ Condition")}),b<h&&t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:fe,children:N("filterBuilder.group","+ Group")})]}),_&&t.jsx("button",{"aria-label":N("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]}),!S&&t.jsx("div",{className:"nice-filterbuilder__group-body",children:l.items.map((C,R)=>t.jsx(r.Fragment,{children:C.type==="condition"?t.jsx(Yi,{condition:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R)}):t.jsx(vs,{group:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R),depth:b+1,maxDepth:h})},R))})]})},xn=({fields:l=Hi,value:x,defaultValue:m,onChange:_,maxDepth:b=3,presets:h,onSavePreset:N,onDeletePreset:S,tutorial:g,className:Z,style:K,"data-testid":ee})=>{const{t:de}=y.useNiceTranslation(),[ue,fe]=y.useControllableState({value:x,defaultValue:m,fallbackValue:{type:"group",logic:"and",items:[]},onChange:_,componentName:"NiceFilterBuilder"}),[M,te]=r.useState(""),C=r.useCallback(k=>{const Qe=h?.find(ze=>ze.name===k);Qe&&fe(structuredClone(Qe.filter))},[h,fe]),R=r.useCallback(()=>{!M.trim()||!N||(N({name:M.trim(),filter:structuredClone(ue)}),te(""))},[M,ue,N]);return t.jsxs("div",{className:`nice-filterbuilder ${Z||""}`,style:{position:"relative",...K},"data-testid":ee,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(g,Ji)})}),(h?.length||N)&&t.jsxs("div",{className:"nice-filterbuilder__presets",children:[h&&h.length>0&&t.jsx("div",{className:"nice-filterbuilder__preset-list",children:h.map(k=>t.jsxs("span",{className:"nice-filterbuilder__preset-tag",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__preset-btn",onClick:()=>C(k.name),children:k.name}),S&&t.jsx("button",{"aria-label":de("filterBuilder.close","Close"),type:"button",className:"nice-filterbuilder__preset-del",onClick:()=>S(k.name),children:t.jsx(y.NiceIcon,{name:"close",size:14})})]},k.name))}),N&&t.jsxs("div",{className:"nice-filterbuilder__preset-save",children:[t.jsx("input",{className:"nice-filterbuilder__input",value:M,onChange:k=>te(k.target.value),placeholder:de("filterBuilder.presetName","Preset name...")}),t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:R,disabled:!M.trim(),children:de("filterBuilder.save","Save")})]})]}),t.jsx(vs,{group:ue,fields:l,onChange:fe,depth:0,maxDepth:b})]})};process.env.NODE_ENV!=="production"&&(xn.displayName="NiceFilterBuilder");const js="nice-datagrid-";function mn(l){if(typeof window>"u")return null;try{const x=window.localStorage.getItem(js+l);return x?JSON.parse(x):null}catch{return null}}function _s(l,x){if(!(typeof window>"u"))try{window.localStorage.setItem(js+l,x)}catch{}}function Ns(l){const x={};return Object.keys(l.columnWidths).length>0&&(x.columnWidths=l.columnWidths),l.columnOrder&&l.columnOrder.length>0&&(x.columnOrder=l.columnOrder),l.hiddenColumns&&l.hiddenColumns.length>0&&(x.hiddenColumns=l.hiddenColumns),l.sortField&&l.sortDirection&&(x.sortField=l.sortField,x.sortDirection=l.sortDirection),l.pageSize!==void 0&&(x.pageSize=l.pageSize),l.expandedGroups.size>0&&(x.expandedGroups=Array.from(l.expandedGroups)),x}function Cs(l,x,m){const _=l.map(b=>b[x]).filter(b=>typeof b=="number");if(_.length===0)return m==="count"?"0":"";switch(m){case"sum":return _.reduce((b,h)=>b+h,0).toLocaleString();case"avg":return(_.reduce((b,h)=>b+h,0)/_.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(l.length);case"min":return Math.min(..._).toLocaleString();case"max":return Math.max(..._).toLocaleString()}}function Ss(l,x){const m=/^([^#0,.]*)([#0,]+(?:\.[#0]+)?)(.*)$/.exec(x);if(!m)return String(l);const[,_,b,h]=m,[N,S=""]=b.split("."),g=new Intl.NumberFormat(void 0,{useGrouping:N.includes(","),minimumIntegerDigits:Math.min(21,Math.max(1,(N.match(/0/g)??[]).length)),minimumFractionDigits:(S.match(/0/g)??[]).length,maximumFractionDigits:S.length}).format(l);return`${_}${g}${h}`}function gn(l,x,m=40){let _=m;return l.querySelectorAll(`[data-field="${x.replace(/["\\]/g,"\\$&")}"]`).forEach(h=>{let N=h.scrollWidth;const S=typeof document.createRange=="function"?document.createRange():null;if(S&&typeof S.getBoundingClientRect=="function"){S.selectNodeContents(h);const g=S.getBoundingClientRect().width;if(g>0){const Z=window.getComputedStyle(h),K=(parseFloat(Z.paddingLeft)||0)+(parseFloat(Z.paddingRight)||0);N=Math.ceil(g+K)}}_=Math.max(_,N)}),_}function hn(l,x){const m=new Map(l.map(b=>[b.field,b])),_=[];for(const b of x){const h=m.get(b);h&&(_.push(h),m.delete(b))}return[..._,...l.filter(b=>m.has(b.field))]}function ks(l,x){const m=[];for(const _ of l){const b=x.find(N=>N.columns.includes(_))??null,h=m[m.length-1];h&&h.group===b?h.span+=1:m.push({group:b,span:1})}return m}function Ye(l){return l.includes(",")||l.includes('"')||l.includes(`
1
+ "use strict";const t=require("react/jsx-runtime"),y=require("@nice2dev/ui-core"),r=require("react"),pn=require("react-dom"),Wi=require("./NiceForm-BtRBLffD.cjs"),qi=require("./devops-cgRBnZVX.cjs"),Vi=require("./NiceModal-BRVzjuUN.cjs"),Ui=require("./NicePagination-D7XxeNFz.cjs"),ys=require("./NiceSelect-BNPXs6FQ.cjs"),Hi=[],Ji=[{target:".nice-filterbuilder",titleKey:"tutorial.filterBuilder.intro.title",title:"Filter builder",contentKey:"tutorial.filterBuilder.intro.content",content:"Build complex AND/OR filter trees: add conditions and nested groups, choose fields and operators, and save reusable presets.",placement:"auto"}],Xi=[{value:"=",label:"Equals"},{value:"<>",label:"Not Equals"},{value:"<",label:"Less Than"},{value:"<=",label:"Less or Equal"},{value:">",label:"Greater Than"},{value:">=",label:"Greater or Equal"},{value:"contains",label:"Contains"},{value:"notcontains",label:"Not Contains"},{value:"startswith",label:"Starts With"},{value:"endswith",label:"Ends With"},{value:"isblank",label:"Is Blank"},{value:"isnotblank",label:"Is Not Blank"}],Yi=({condition:l,fields:x,onChange:m,onRemove:_})=>{const{t:b}=y.useNiceTranslation(),h=x.find(g=>g.field===l.field),N=l.operator==="isblank"||l.operator==="isnotblank",S=h?.operators||Xi;return t.jsxs("div",{className:"nice-filterbuilder__condition",children:[t.jsx("select",{className:"nice-filterbuilder__select",value:l.field,onChange:g=>m({...l,field:g.target.value,value:""}),children:x.map(g=>t.jsx("option",{value:g.field,children:g.label},g.field))}),t.jsx("select",{className:"nice-filterbuilder__select",value:l.operator,onChange:g=>m({...l,operator:g.target.value}),children:S.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))}),!N&&(h?.options?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value}),children:[t.jsx("option",{value:"",children:"--"}),h.options.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]}):h?.type==="boolean"?t.jsxs("select",{className:"nice-filterbuilder__select",value:String(l.value??""),onChange:g=>m({...l,value:g.target.value==="true"}),children:[t.jsx("option",{value:"true",children:b("filterBuilder.true","True")}),t.jsx("option",{value:"false",children:b("filterBuilder.false","False")})]}):t.jsx("input",{className:"nice-filterbuilder__input",type:h?.type==="number"?"number":h?.type==="date"?"date":"text",value:String(l.value??""),onChange:g=>m({...l,value:h?.type==="number"?Number(g.target.value):g.target.value})})),t.jsx("button",{"aria-label":b("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]})},vs=({group:l,fields:x,onChange:m,onRemove:_,depth:b,maxDepth:h})=>{const{t:N}=y.useNiceTranslation(),[S,g]=r.useState(!1),Z=()=>m({...l,logic:l.logic==="and"?"or":"and"}),K=l.items.filter(C=>C.type==="condition").length,ee=l.items.length-K,de=[K?`${K} condition${K>1?"s":""}`:"",ee?`${ee} group${ee>1?"s":""}`:""].filter(Boolean).join(" · ")||"empty",ue=()=>{const C={type:"condition",field:x[0]?.field||"",operator:"=",value:""};m({...l,items:[...l.items,C]})},fe=()=>{if(b>=h)return;const C={type:"group",logic:"and",items:[]};m({...l,items:[...l.items,C]})},M=(C,R)=>{const k=[...l.items];k[C]=R,m({...l,items:k})},te=C=>{m({...l,items:l.items.filter((R,k)=>k!==C)})};return t.jsxs("div",{className:`nice-filterbuilder__group nice-filterbuilder__group--depth-${Math.min(b,3)}`,children:[t.jsxs("div",{className:"nice-filterbuilder__group-header",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__collapse",onClick:()=>g(C=>!C),"aria-expanded":!S,title:S?N("filterBuilder.expandGroup","Expand group"):N("filterBuilder.collapseGroup","Collapse group"),children:t.jsx(y.NiceIcon,{name:S?"chevron-right":"chevron-down",size:"sm"})}),t.jsx("button",{className:"nice-filterbuilder__logic",onClick:Z,title:N("filterBuilder.matchClickToSwitch","Match {mode} — click to switch to {other}").replace("{mode}",l.logic==="and"?N("filterBuilder.matchAll","ALL"):N("filterBuilder.matchAny","ANY")).replace("{other}",l.logic==="and"?"OR":"AND"),children:l.logic.toUpperCase()}),S?t.jsx("span",{className:"nice-filterbuilder__summary",children:de}):t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:ue,children:N("filterBuilder.condition","+ Condition")}),b<h&&t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:fe,children:N("filterBuilder.group","+ Group")})]}),_&&t.jsx("button",{"aria-label":N("filterBuilder.close","Close"),className:"nice-filterbuilder__remove",onClick:_,children:t.jsx(y.NiceIcon,{name:"close",size:14})})]}),!S&&t.jsx("div",{className:"nice-filterbuilder__group-body",children:l.items.map((C,R)=>t.jsx(r.Fragment,{children:C.type==="condition"?t.jsx(Yi,{condition:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R)}):t.jsx(vs,{group:C,fields:x,onChange:k=>M(R,k),onRemove:()=>te(R),depth:b+1,maxDepth:h})},R))})]})},xn=({fields:l=Hi,value:x,defaultValue:m,onChange:_,maxDepth:b=3,presets:h,onSavePreset:N,onDeletePreset:S,tutorial:g,className:Z,style:K,"data-testid":ee})=>{const{t:de}=y.useNiceTranslation(),[ue,fe]=y.useControllableState({value:x,defaultValue:m,fallbackValue:{type:"group",logic:"and",items:[]},onChange:_,componentName:"NiceFilterBuilder"}),[M,te]=r.useState(""),C=r.useCallback(k=>{const Qe=h?.find(ze=>ze.name===k);Qe&&fe(structuredClone(Qe.filter))},[h,fe]),R=r.useCallback(()=>{!M.trim()||!N||(N({name:M.trim(),filter:structuredClone(ue)}),te(""))},[M,ue,N]);return t.jsxs("div",{className:`nice-filterbuilder ${Z||""}`,style:{position:"relative",...K},"data-testid":ee,children:[t.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:t.jsx(y.NiceTutorialButton,{steps:y.resolveTutorial(g,Ji)})}),(h?.length||N)&&t.jsxs("div",{className:"nice-filterbuilder__presets",children:[h&&h.length>0&&t.jsx("div",{className:"nice-filterbuilder__preset-list",children:h.map(k=>t.jsxs("span",{className:"nice-filterbuilder__preset-tag",children:[t.jsx("button",{type:"button",className:"nice-filterbuilder__preset-btn",onClick:()=>C(k.name),children:k.name}),S&&t.jsx("button",{"aria-label":de("filterBuilder.close","Close"),type:"button",className:"nice-filterbuilder__preset-del",onClick:()=>S(k.name),children:t.jsx(y.NiceIcon,{name:"close",size:14})})]},k.name))}),N&&t.jsxs("div",{className:"nice-filterbuilder__preset-save",children:[t.jsx("input",{className:"nice-filterbuilder__input",value:M,onChange:k=>te(k.target.value),placeholder:de("filterBuilder.presetName","Preset name...")}),t.jsx("button",{className:"nice-btn nice-btn--sm",onClick:R,disabled:!M.trim(),children:de("filterBuilder.save","Save")})]})]}),t.jsx(vs,{group:ue,fields:l,onChange:fe,depth:0,maxDepth:b})]})};process.env.NODE_ENV!=="production"&&(xn.displayName="NiceFilterBuilder");const js="nice-datagrid-";function mn(l){if(typeof window>"u")return null;try{const x=window.localStorage.getItem(js+l);return x?JSON.parse(x):null}catch{return null}}function _s(l,x){if(!(typeof window>"u"))try{window.localStorage.setItem(js+l,x)}catch{}}function Ns(l){const x={};return Object.keys(l.columnWidths).length>0&&(x.columnWidths=l.columnWidths),l.columnOrder&&l.columnOrder.length>0&&(x.columnOrder=l.columnOrder),l.hiddenColumns&&l.hiddenColumns.length>0&&(x.hiddenColumns=l.hiddenColumns),l.sortField&&l.sortDirection&&(x.sortField=l.sortField,x.sortDirection=l.sortDirection),l.pageSize!==void 0&&(x.pageSize=l.pageSize),l.expandedGroups.size>0&&(x.expandedGroups=Array.from(l.expandedGroups)),x}function Cs(l,x,m){const _=l.map(b=>b[x]).filter(b=>typeof b=="number");if(_.length===0)return m==="count"?"0":"";switch(m){case"sum":return _.reduce((b,h)=>b+h,0).toLocaleString();case"avg":return(_.reduce((b,h)=>b+h,0)/_.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(l.length);case"min":return Math.min(..._).toLocaleString();case"max":return Math.max(..._).toLocaleString()}}function Ss(l,x){const m=/^([^#0,.]*)([#0,]+(?:\.[#0]+)?)(.*)$/.exec(x);if(!m)return String(l);const[,_,b,h]=m,[N,S=""]=b.split("."),g=new Intl.NumberFormat(void 0,{useGrouping:N.includes(","),minimumIntegerDigits:Math.min(21,Math.max(1,(N.match(/0/g)??[]).length)),minimumFractionDigits:(S.match(/0/g)??[]).length,maximumFractionDigits:S.length}).format(l);return`${_}${g}${h}`}function gn(l,x,m=40){let _=m;return l.querySelectorAll(`[data-field="${x.replace(/["\\]/g,"\\$&")}"]`).forEach(h=>{let N=h.scrollWidth;const S=typeof document.createRange=="function"?document.createRange():null;if(S&&typeof S.getBoundingClientRect=="function"){S.selectNodeContents(h);const g=S.getBoundingClientRect().width;if(g>0){const Z=window.getComputedStyle(h),K=(parseFloat(Z.paddingLeft)||0)+(parseFloat(Z.paddingRight)||0);N=Math.ceil(g+K)}}_=Math.max(_,N)}),_}function hn(l,x){const m=new Map(l.map(b=>[b.field,b])),_=[];for(const b of x){const h=m.get(b);h&&(_.push(h),m.delete(b))}return[..._,...l.filter(b=>m.has(b.field))]}function ks(l,x){const m=[];for(const _ of l){const b=x.find(N=>N.columns.includes(_))??null,h=m[m.length-1];h&&h.group===b?h.span+=1:m.push({group:b,span:1})}return m}function Ye(l){return l.includes(",")||l.includes('"')||l.includes(`
2
2
  `)?`"${l.replace(/"/g,'""')}"`:l}const ye={width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},Qi=()=>t.jsx("svg",{...ye,children:t.jsx("polyline",{points:"6 15 12 9 18 15"})}),Je=()=>t.jsx("svg",{...ye,children:t.jsx("polyline",{points:"6 9 12 15 18 9"})}),Zi=()=>t.jsxs("svg",{...ye,style:{opacity:.55},children:[t.jsx("polyline",{points:"6 10 12 5 18 10"}),t.jsx("polyline",{points:"6 14 12 19 18 14"})]}),jt=()=>t.jsx("svg",{...ye,children:t.jsx("polyline",{points:"9 6 15 12 9 18"})}),ea=()=>t.jsxs("svg",{...ye,children:[t.jsx("polyline",{points:"3 17 9 11 13 15 21 7"}),t.jsx("polyline",{points:"14 7 21 7 21 14"})]}),ta=()=>t.jsxs("svg",{...ye,children:[t.jsx("polyline",{points:"3 7 9 13 13 9 21 17"}),t.jsx("polyline",{points:"14 17 21 17 21 10"})]}),na=()=>t.jsx("svg",{...ye,children:t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})}),sa=40,Xe=l=>l.stopPropagation(),ia=[];function aa(l){return typeof l=="boolean"?l?t.jsx(y.NiceIcon,{name:"check",size:16,className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--true",title:"true"}):t.jsx(y.NiceIcon,{name:"close",size:16,className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--false",title:"false"}):String(l??"")}function bn({columns:l=ia,data:x,keyField:m="id",dataSource:_,sortable:b=!0,sortField:h,sortDirection:N,onSort:S,showAdvancedFilter:g,advancedFilter:Z,onAdvancedFilterChange:K,filterFields:ee,filterPresets:de,onSaveFilterPreset:ue,onDeleteFilterPreset:fe,selectable:M,selectedKeys:te,onSelectionChange:C,pagination:R,pageSize:k=10,page:Qe,onPageChange:ze,totalRows:yn,autoPagination:ne=!1,stickyHeader:_t=!0,stickyFooter:ws=!0,searchable:vn,searchPlaceholder:Ms,virtualScroll:X,rowHeight:W=40,groupBy:Nt,groupRender:Ze,onCellEdit:$,editMode:Re="inline",formItems:Ds,formColumns:Is=2,editFormTitle:zs,formProps:Rs,onRowEdit:et,onRowAdd:tt,onRowDelete:ve,confirmDelete:nt,bulkActions:Ct,onBulkDelete:St,exportCsv:jn,exportFilename:_n="export",detailRow:q,expandedRowKeys:As,onExpandedRowChange:kt,columnReorder:Es,onColumnReorder:Nn,columnResize:wt,rowDraggable:z,onRowReorder:st,striped:Os,compact:Ts,size:Mt,loading:$s,emptyText:Fs,toolbar:Cn,onRowClick:pe,pinnedTopKeys:Dt,pinnedBottomKeys:It,colSpan:Sn,showStatusBar:Ls,contextMenuItems:it,onContextMenuAction:Ps,printFriendly:Bs,keyboardNavigation:Ae,focusedCell:Gs,onFocusedCellChange:zt,cellRangeSelection:kn,selectedCellRange:Ks,onCellRangeChange:Rt,clipboard:me,clipboardFormat:At="text",onBeforeCopy:wn,onCopy:Mn,onPaste:Et,quickFilters:se,activeQuickFilters:Ws,onQuickFilterChange:Ot,columnGroups:Tt,stateStorageKey:U,initialState:qs,onStateChange:Dn,flashRowKeys:$t,flashDuration:In=500,autoFitColumns:Ft,showColumnStats:Ee,rowIndicator:Oe,frozenRows:Vs,className:Us,style:Hs,accessMode:Js,id:Xs,displayStyle:zn,disabled:Ys,readOnly:Rn,error:Lt}){const Pt=y.useNiceAccessMode(Js,Xs),Qs=Pt==="hidden",je=Ys||Pt==="disabled",Te=Rn||je||Pt==="readOnly",ie=!!ve&&!Te,ge=Math.max(0,Math.floor(Vs??0)),{t:u}=y.useNiceTranslation();y.useComponentDisplayStyle("table",zn),y.useComponentDisplayClass("table",zn);const D=y.useNiceDataSource(_??null,{autoLoad:!!_,defaultPageSize:k}),w=!!_,Bt=r.useMemo(()=>w?D.data:x??[],[w,D.data,x]),at=w?D.loading:$s,[O]=r.useState(()=>qs??(U?mn(U):null)),[An,En]=r.useState(()=>({field:O?.sortField??"",dir:O?.sortDirection??null})),[Zs,ei]=r.useState(1),[ti,Gt]=r.useState(new Set),[rt,ni]=r.useState(""),[si,ii]=r.useState({type:"group",logic:"and",items:[]}),[On,Tn]=r.useState(!1),ae=Z??si,$n=e=>{K?K(e):ii(e)},ai=r.useMemo(()=>ee??l.filter(e=>e.filterable!==!1&&e.field).map(e=>({field:String(e.field),label:String(e.header??e.field)})),[ee,l]),he=ae.items.length,[lt,Fn]=r.useState(O?.pageSize??k),[re,Kt]=r.useState(null),[ot,$e]=r.useState(null),[_e,xe]=r.useState(null),[Wt,Ln]=r.useState(()=>new Set(O?.expandedGroups??[])),[qt,ri]=r.useState(0),ct=r.useRef(null),[li,oi]=r.useState(new Set),dt=As??li,[Fe,Vt]=r.useState(()=>O?.columnWidths??{}),[Ne,Ce]=r.useState(null),[Se,Ut]=r.useState(null),[Ht,Jt]=r.useState(null),[ci,di]=r.useState(null),[ui,fi]=r.useState(null),[pi,mi]=r.useState([]),[ke,Xt]=r.useState(null),Yt=r.useRef(null),[ut,Qt]=r.useState(()=>O?.hiddenColumns??[]),[Le,Pn]=r.useState(()=>O?.columnOrder??null),[Zt,en]=r.useState(null),[Bn,ft]=r.useState(null),tn=r.useRef(null),[gi,Gn]=r.useState(new Set),[Pe,nn]=r.useState(null),Kn=r.useRef(null),[hi,xi]=r.useState({}),le=r.useRef(null),[bi,yi]=r.useState(k);r.useEffect(()=>{if(!ne)return;const e=ct.current;if(!e||typeof ResizeObserver>"u")return;const n=()=>{const i=e.clientHeight;if(i<=0)return;const a=Math.max(1,Math.floor(i/W)-1);yi(o=>o===a?o:a),w&&D.setPageSize(a)};n();const s=new ResizeObserver(n);return s.observe(e),()=>s.disconnect()},[ne,W,w]);const B=Gs??ci,F=Ks??ui,H=Ws??pi,Wn=r.useRef(U);r.useEffect(()=>{if(Wn.current===U)return;Wn.current=U;const e=U?mn(U):null;e&&(Vt(e.columnWidths??{}),Ln(new Set(e.expandedGroups??[])),Qt(e.hiddenColumns??[]),Pn(e.columnOrder??null),En({field:e.sortField??"",dir:e.sortDirection??null}),e.pageSize!==void 0&&Fn(e.pageSize))},[U]),r.useEffect(()=>{!w||!O||(O.sortField&&O.sortDirection&&D.setSortField(O.sortField,O.sortDirection),O.pageSize!==void 0&&!ne&&D.setPageSize(O.pageSize))},[]),r.useEffect(()=>{if(!$t?.size)return;Gn(new Set($t));const e=setTimeout(()=>Gn(new Set),In);return()=>clearTimeout(e)},[$t,In]),r.useEffect(()=>{if(!Se)return;const e=()=>Ut(null);return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Se]);const vi=r.useCallback((e,n)=>{it?.length&&(e.preventDefault(),Ut({x:e.clientX,y:e.clientY,row:n}))},[it]),qn=r.useCallback(e=>{const n=new Set(dt);n.has(e)?n.delete(e):n.add(e),kt?kt(n):oi(n)},[dt,kt]),ji=r.useCallback((e,n)=>{if(!wt)return;n.preventDefault();const s=n.clientX,a=n.target.closest("th")?.offsetWidth??100,o=f=>{const d=Math.max(40,a+f.clientX-s);Vt(j=>({...j,[e]:d}))},c=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",c)},[wt]),J=w?D.sort[0]?.field??"":h??An.field,G=w?D.sort[0]?.direction??null:N??An.dir,we=w?D.page:Qe??Zs,I=te??ti,Y=r.useMemo(()=>Le?hn(l,Le):l,[l,Le]),T=r.useMemo(()=>Y.filter(e=>!e.hidden&&!ut.includes(e.field)),[Y,ut]),sn=r.useMemo(()=>T.filter(e=>e.pinned==="left"),[T]),pt=r.useMemo(()=>T.filter(e=>e.pinned==="right"),[T]),Vn=r.useMemo(()=>T.filter(e=>!e.pinned),[T]),v=r.useMemo(()=>[...sn,...Vn,...pt],[sn,Vn,pt]),_i=r.useMemo(()=>T.some(e=>e.aggregate),[T]),Be=sn.length>0||pt.length>0,an=r.useMemo(()=>{if(!Tt?.length)return null;const e=ks(v.map(n=>n.field),Tt);return e.some(n=>n.group)?e:null},[Tt,v]),Ge=r.useCallback((e,n)=>{w?n?D.setSortField(e,n):D.setSort([]):S?S(e,n):En({field:e,dir:n})},[w,D,S]),Un=r.useCallback(e=>{Ge(e,J===e?G==="asc"?"desc":G==="desc"?null:"asc":"asc")},[J,G,Ge]),L=r.useMemo(()=>{if(w)return Bt;let e=[...Bt];if(rt){const n=rt.toLowerCase();e=e.filter(s=>T.some(i=>String(s[i.field]??"").toLowerCase().includes(n)))}return ae.items.length>0&&(e=e.filter(n=>y.matchesFilterGroup(n,ae))),!S&&J&&G&&e.sort((n,s)=>{const i=n[J]??"",a=s[J]??"",o=typeof i=="number"?i-a:String(i).localeCompare(String(a));return G==="desc"?-o:o}),e},[Bt,rt,ae,T,J,G,S,w]),mt=w?D.totalCount:yn??L.length,oe=ne?bi:w?D.pageSize:lt,rn=Math.max(1,Math.ceil(mt/oe)),V=w?L:R&&!yn?L.slice((we-1)*oe,we*oe):L,Ke=r.useCallback(e=>{w?D.setPage(e):ze?ze(e):ei(e)},[w,D,ze]);y.useIntent(["pagePrev","pageNext"],e=>{const n=we+(e.intent==="pageNext"?1:-1);if(e.source==="keyboard"||n<1||n>rn)return!1;Ke(n)},{ref:le,enabled:!!R}),y.useInputHints(le,[{intent:"pagePrev",label:u("input.intent.pagePrev","Previous page")},{intent:"pageNext",label:u("input.intent.pageNext","Next page")}],{enabled:!!R&&rn>1});const We=JSON.stringify(Ns({columnWidths:Fe,sortField:J,sortDirection:G,pageSize:ne?void 0:oe,expandedGroups:Wt,hiddenColumns:ut,columnOrder:Le??void 0})),Hn=r.useRef(Dn);Hn.current=Dn;const ln=r.useRef(U);ln.current=U;const gt=r.useRef(null),qe=r.useRef(null),ht=r.useCallback(e=>{gt.current=e,qe.current=null,ln.current&&_s(ln.current,e),Hn.current?.(JSON.parse(e))},[]);r.useEffect(()=>{if(gt.current===null){gt.current=We;return}if(We===gt.current){qe.current=null;return}qe.current=We;const e=setTimeout(()=>ht(We),300);return()=>clearTimeout(e)},[We,ht]),r.useEffect(()=>()=>{qe.current!==null&&ht(qe.current)},[ht]);const on=r.useCallback(()=>{Xt(null),Yt.current?.focus()},[]),Q=ys.useAnchoredPopup(ke!==null,Yt,on),Jn=Q.popupRef,Xn=Q.ready;r.useEffect(()=>{ke===null||!Xn||Jn.current?.querySelector('[role="menuitem"]:not(:disabled)')?.focus()},[ke,Xn,Jn]);const Ni=r.useCallback(e=>{const n=le.current;if(!n)return;const s=l.find(a=>a.field===e),i=gn(n,e,s?.minWidth??40);Vt(a=>({...a,[e]:i}))},[l]),Yn=r.useId(),Ci=r.useCallback(()=>nn(null),[]),be=ys.useAnchoredPopup(Pe!==null,Kn,Ci,{anchorKey:Pe}),Qn=(e,n)=>{Kn.current=e.currentTarget,nn(n)},Zn=e=>nn(n=>n===e?null:n),es=r.useCallback((e,n)=>{const s=Y.findIndex(c=>c.field===e),i=Y.findIndex(c=>c.field===n);if(s<0||i<0||s===i||(Y[s].pinned??null)!==(Y[i].pinned??null))return;const a=Y.map(c=>c.field).filter(c=>c!==e),o=a.indexOf(n)+(s<i?1:0);a.splice(o,0,e),Pn(a),Nn?.(hn(l,a))},[Y,l,Nn]);r.useEffect(()=>{const e=tn.current;e&&(tn.current=null,le.current?.querySelector(`thead th[data-field="${e.replace(/["\\]/g,"\\$&")}"]`)?.focus())},[Le]);const Si=e=>{ae.items.some(s=>s.type==="condition"&&s.field===e)||$n({...ae,items:[...ae.items,{type:"condition",field:e,operator:"contains",value:""}]}),Tn(!0)},ki=e=>{e(),on()},wi=e=>{const n=Array.from(e.currentTarget.querySelectorAll('[role="menuitem"]:not(:disabled)'));if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const s=e.key==="ArrowDown"?1:-1,i=n.indexOf(document.activeElement),a=i<0?s>0?0:n.length-1:(i+s+n.length)%n.length;n[a]?.focus()}else e.key==="Tab"&&Xt(null)},Me=r.useMemo(()=>V.map(e=>String(e[m])),[V,m]),De=Me.length>0&&Me.every(e=>I.has(e)),ts=Me.some(e=>I.has(e)),ns=r.useCallback(()=>{const e=new Set(I);De?Me.forEach(n=>e.delete(n)):Me.forEach(n=>e.add(n)),C?C(e):Gt(e)},[De,Me,I,C]),ss=r.useCallback(e=>{const n=new Set(I);n.has(e)?n.delete(e):n.add(e),C?C(n):Gt(n)},[I,C]),Mi=({field:e})=>J!==e||!G?t.jsx("span",{className:"nice-table__sort-icon",children:t.jsx(Zi,{})}):t.jsx("span",{className:"nice-table__sort-icon",children:G==="asc"?t.jsx(Qi,{}):t.jsx(Je,{})}),A=r.useMemo(()=>{if(!Nt)return V.map((s,i)=>({type:"data",row:s,key:String(s[m]??i)}));const e=new Map;V.forEach(s=>{const i=s[Nt];e.has(i)||e.set(i,[]),e.get(i).push(s)});const n=[];return e.forEach((s,i)=>{const a=`__group_${String(i)}`,o=Wt.has(a);n.push({type:"group",value:i,rows:s,expanded:o,key:a}),o&&s.forEach((c,f)=>n.push({type:"data",row:c,key:String(c[m]??`${a}_${f}`)}))}),n},[V,Nt,m,Wt]),{pinnedTopRows:cn,pinnedBottomRows:Di,normalRows:dn}=r.useMemo(()=>{if(!Dt?.size&&!It?.size)return{pinnedTopRows:[],pinnedBottomRows:[],normalRows:A};const e=[],n=[],s=[];for(const i of A){if(i.type==="data"){const a=i.key;if(Dt?.has(a)){e.push(i);continue}if(It?.has(a)){n.push(i);continue}}s.push(i)}return{pinnedTopRows:e,pinnedBottomRows:n,normalRows:s}},[A,Dt,It]),is=r.useCallback(e=>{Ln(n=>{const s=new Set(n);return s.has(e)?s.delete(e):s.add(e),s})},[]),as=r.useMemo(()=>{if(!X)return A;const e=ct.current?.clientHeight??400,n=Math.ceil(e/W),s=Math.max(0,Math.floor(qt/W)-3),i=Math.min(A.length-1,s+n+6),a=A.slice(s,i+1).map((c,f)=>({...c,_vIdx:s+f}));return[...A.slice(0,Math.min(ge,s)).map((c,f)=>({...c,_vIdx:f})),...a]},[X,A,qt,W,ge]),Ve=r.useMemo(()=>ge>0?[...cn,...dn].slice(0,ge).map(e=>e.key):[],[ge,cn,dn]),[Ii,zi]=r.useState([]);r.useLayoutEffect(()=>{if(X||Ve.length===0)return;const e=ct.current?.querySelector("table");if(!e)return;const n=Array.from(e.tBodies[0]?.rows??[]);let s=_t?e.tHead?.offsetHeight??0:0;const i=Ve.map(a=>{const o=s;return s+=n.find(c=>c.dataset.rowKey===a)?.offsetHeight??0,o});zi(a=>a.length===i.length&&a.every((o,c)=>o===i[c])?a:i)},[X,Ve,_t,Fe,v,an]);const rs=e=>{const n=Ve.indexOf(e);return n<0?{className:""}:{className:n===Ve.length-1?"nice-datagrid__row--frozen nice-datagrid__row--frozen-last":"nice-datagrid__row--frozen",style:{position:"sticky",top:Ii[n]??0,zIndex:2}}};r.useLayoutEffect(()=>{const e=le.current;if(!Ft||!e)return;const n={};for(const s of v)s.width===void 0&&Fe[s.field]===void 0&&(n[s.field]=gn(e,s.field,s.minWidth??40));xi(s=>{const i=Object.keys(n);return i.length===Object.keys(s).length&&i.every(o=>Math.abs((s[o]??-1/0)-n[o])<=1)?s:n})},[Ft,v,Fe,as]);const Ie=e=>Fe[e.field]||e.width||(Ft?hi[e.field]:void 0),xt=r.useCallback((e,n,s)=>{!$||Te||(Kt({rowKey:e,field:n}),$e(s))},[$,Te]),ls=r.useCallback(()=>{re&&$&&$(re.rowKey,re.field,ot),Kt(null),$e(null)},[re,ot,$]),Ri=r.useCallback(()=>{Kt(null),$e(null)},[]),Ai=r.useCallback((e,n)=>{!ve||Te||(nt?Jt({key:e,row:n}):ve(e,n))},[ve,Te,nt]),Ei=r.useCallback(()=>{const e=Ht;Jt(null),e&&ve?.(e.key,e.row)},[Ht,ve]),Oi=r.useCallback(()=>Jt(null),[]),Ue=`nice-datagrid__actions-col${pt.length>0?" nice-datagrid__actions-col--sticky":""}`,os=(e,n)=>t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs nice-btn--ghost nice-datagrid__row-delete","aria-label":u("controls.delete","Delete"),title:u("controls.delete","Delete"),onClick:s=>{s.stopPropagation(),Ai(e,n)},onDoubleClick:Xe,onKeyDown:Xe,children:t.jsx(y.NiceIcon,{name:"trash",size:14})}),Ti=r.useCallback(()=>{const e=T,n=e.map(f=>Ye(f.header)).join(","),s=L.map(f=>e.map(d=>Ye(String(f[d.field]??""))).join(",")),i=[n,...s].join(`
3
3
  `),a=new Blob(["\uFEFF"+i],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(a),c=document.createElement("a");c.href=o,c.download=`${_n}.csv`,c.click(),URL.revokeObjectURL(o)},[T,L,_n]),bt=r.useCallback(e=>{zt?zt(e):di(e)},[zt]),yt=r.useCallback(e=>{Rt?Rt(e):fi(e)},[Rt]),P=r.useMemo(()=>A.filter(e=>e.type==="data").map(e=>e.key),[A]),$i=r.useCallback(e=>{if(e.target!==e.currentTarget||!Ae||re||!B)return;const n=P.indexOf(B.rowKey),s=v.findIndex(c=>c.field===B.field);if(n<0||s<0)return;let i=n,a=s;switch(e.key){case"ArrowUp":i=Math.max(0,n-1);break;case"ArrowDown":i=Math.min(P.length-1,n+1);break;case"ArrowLeft":a=Math.max(0,s-1);break;case"ArrowRight":a=Math.min(v.length-1,s+1);break;case"Tab":{const c=s+(e.shiftKey?-1:1);if(c<0||c>=v.length)return;a=c;break}case"Enter":{const c=v[s];if(c.editable&&$){const f=V.find(d=>String(d[m])===B.rowKey);f&&xt(B.rowKey,c.field,f[c.field])}return}case"Escape":bt(null),yt(null);return;case"Home":e.ctrlKey&&(i=0),a=0;break;case"End":e.ctrlKey&&(i=P.length-1),a=v.length-1;break;case"PageUp":i=Math.max(0,n-lt);break;case"PageDown":i=Math.min(P.length-1,n+lt);break;default:return}e.preventDefault();const o={rowKey:P[i],field:v[a].field};if(bt(o),e.shiftKey&&kn){const c=F?.start??B;yt({start:c,end:o})}else yt(null)},[Ae,re,B,P,v,kn,F,bt,yt,$,V,m,xt,lt]),cs=r.useCallback(()=>{let e=[],n=[];if(F){const s=P.indexOf(F.start.rowKey),i=P.indexOf(F.end.rowKey),a=Math.min(s,i),o=Math.max(s,i),c=v.findIndex(p=>p.field===F.start.field),f=v.findIndex(p=>p.field===F.end.field),d=Math.min(c,f),j=Math.max(c,f);n=v.slice(d,j+1).map(p=>p.field),e=V.filter(p=>{const E=P.indexOf(String(p[m]));return E>=a&&E<=o})}else I.size>0&&(e=V.filter(s=>I.has(String(s[m]))),n=v.map(s=>s.field));return{rows:e,fields:n}},[F,P,v,V,m,I]),ds=r.useCallback((e,n,s)=>{const i=v.filter(a=>n.includes(a.field));switch(s){case"json":return JSON.stringify(e.map(a=>Object.fromEntries(n.map(o=>[o,a[o]]))),null,2);case"csv":{const a=i.map(c=>Ye(c.header)).join(","),o=e.map(c=>i.map(f=>Ye(String(c[f.field]??""))).join(",")).join(`
4
4
  `);return a+`
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="https://nice2dev.com/schemas/component-doc-v1.json",t="NiceEventOrchestrator",o="Event-driven workflow orchestrator with triggers, conditions, and actions.",n="no-code",s="1.0.7",i="stable",r=[{name:"flows",type:"EventFlow[]",description:"Initial event flows"},{name:"eventSources",type:"EventSourceDefinition[]",description:"Available event sources"},{name:"eventHandlers",type:"EventHandlerDefinition[]",description:"Available event handlers"},{name:"onFlowsChange",type:"(flows: EventFlow[]) => void",description:"Called with the flows after every change"},{name:"onExport",type:"(code: string) => void",description:"Called with the generated code on export"},{name:"onTest",type:"(flowId: string) => void",description:"Called when a flow is tested"}],c=[{title:"Event Orchestrator",description:"Build event-driven workflows",code:`<NiceEventOrchestrator
2
+ flows={flows}
3
+ eventSources={sources}
4
+ eventHandlers={handlers}
5
+ onFlowsChange={setFlows}
6
+ />`}],a={role:"application",ariaLabel:"Event workflow orchestrator"},l=["NiceWorkflowDesigner","NiceAPIFlow"],d={$schema:e,name:t,description:o,category:n,since:s,status:i,props:r,examples:c,accessibility:a,seeAlso:l};exports.$schema=e;exports.accessibility=a;exports.category=n;exports.default=d;exports.description=o;exports.examples=c;exports.name=t;exports.props=r;exports.seeAlso=l;exports.since=s;exports.status=i;