@nice2dev/ui 1.3.17 → 1.4.0
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 +146 -0
- package/README.md +29 -2
- package/dist/{NiceDataGrid-aNPAHsWy.cjs → NiceDataGrid-BT6iCUgP.cjs} +1 -1
- package/dist/NiceForm-Bysp66Ef.cjs +1 -0
- package/dist/{NiceMention-CMqAGvO0.cjs → NiceMention-sc8W-DwH.cjs} +1 -1
- package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-JHrSlHAV.cjs → NiceSavedQueryPanel-BbznsXFd.cjs} +1 -1
- package/dist/{NiceScheduler-2TwOZq-y.cjs → NiceScheduler-3Ez0zSQJ.cjs} +1 -1
- package/dist/{core-lazy-Cda-D35m.cjs → core-lazy-CL4ZIxF-.cjs} +1 -1
- package/dist/data/treeDragSession.mjs +52 -46
- package/dist/data.cjs +1 -1
- package/dist/editors/inputs/NiceAutocomplete.mjs +44 -46
- package/dist/editors/pickers/NiceDateTimePicker.mjs +1 -1
- package/dist/editors/pickers/pickerCommons.mjs +284 -87
- package/dist/editors/pickers/themePickerHelpers.mjs +10 -8
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +162 -162
- package/dist/index.d.ts +253 -31
- package/dist/index.mjs +1517 -1483
- package/dist/navigation/NiceIconRail.mjs +74 -53
- package/dist/navigation/NiceNavShell.mjs +855 -807
- package/dist/navigation/NiceSetupWizard.mjs +287 -278
- package/dist/navigation/NiceSidebarNav.mjs +1487 -1144
- package/dist/navigation/navItemDrag.mjs +42 -0
- package/dist/navigation/navShellPane.mjs +16 -11
- package/dist/navigation/sidebarColors.mjs +61 -50
- package/dist/navigation/sidebarNavTypes.mjs +1 -0
- package/dist/navigation/sidebarSearch.mjs +28 -0
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +70 -21
- package/dist/pickerCommons-CwcCc8Qi.cjs +1 -0
- package/dist/planning/NiceResourceAllocation.mjs +31 -31
- package/dist/style.css +4 -4
- package/dist/tools/NiceThemeDesigner.mjs +781 -708
- package/dist/tools/NiceThemePreview.mjs +344 -282
- package/dist/tools/themeCatalog.mjs +28 -44
- package/dist/tools/themeCatalogArchive.mjs +38 -0
- package/dist/tools/themeDesigner/ThemeSetEditors.mjs +400 -0
- package/dist/tools/themeDesigner/ThemeValueField.mjs +146 -0
- package/dist/tools/themeDesigner/themeDesignerPaths.mjs +105 -0
- package/package.json +4 -4
- package/dist/NiceForm-BtRBLffD.cjs +0 -1
- package/dist/NiceModuleLifecyclePanel-ugNtHimh.cjs +0 -1
- package/dist/pickerCommons-BWglYl6J.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,151 @@
|
|
|
1
1
|
# [1.0.27] — 2026-06-07
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 41a88b4: 1.4.0 — **NiceThemeDesigner edits the new theme fields**:
|
|
8
|
+
|
|
9
|
+
- Every colour field is a **colour, a gradient (surfaces) or a link** — to a palette swatch, a gradient or another
|
|
10
|
+
field ("the same colour, like a variable"). A linked field shows a chip with the target, **Go to the source**
|
|
11
|
+
and **Unlink** (it keeps the colour it showed; one undo step); a value other fields link to shows how many.
|
|
12
|
+
Links that would close a loop are not offered.
|
|
13
|
+
- New sections: **Palette** (named colours and gradients — renaming a swatch rewrites every link to it, removing a
|
|
14
|
+
used one leaves the linked fields their colour), **Layout** (body, panel, top bar, sidebar, sidebar items, with
|
|
15
|
+
their texts and borders; the sidebar's **header levels** — shaded from one colour, a palette or a list, with
|
|
16
|
+
**Sync** and **Sync once** to fix single levels — and the **active item's branch**), **Scrollbar** (colours,
|
|
17
|
+
track and thumb widths, rounding, a live sample).
|
|
18
|
+
- NiceThemePreview draws the theme with its links resolved; its Navigation tab opens with the layout in
|
|
19
|
+
miniature (top bar, sidebar with the shaded active branch, body with a panel, a scroller), and its tints no
|
|
20
|
+
longer break on colours that are not `#rrggbb`.
|
|
21
|
+
- `resolveThemeValue(theme, path)` (ui-core): what a field stands for now, links and defaults followed.
|
|
22
|
+
|
|
23
|
+
- 8bb55b6: 1.4.0 — **theme previews show the layout**:
|
|
24
|
+
|
|
25
|
+
- `themePreviewRoles(theme)` (ui-core): the colours a thumbnail needs — top bar, sidebar with its first three
|
|
26
|
+
header levels, highlight, body, panel (gradients kept) — every default followed, so themes from before 1.4.0
|
|
27
|
+
get them too.
|
|
28
|
+
- `toThemeDescriptor` resolves links and adds them as `preview.roles`; with roles **`ThemePreviewSwatch`** draws
|
|
29
|
+
`'swatch'` / `'columns'` as one column per role (the sidebar with its header levels at its top) and `'page'` /
|
|
30
|
+
`'layout'` as the app in miniature (top bar, sidebar with levels and the active row, body with a panel). Without
|
|
31
|
+
roles the shapes draw as before. NiceThemePicker, the first-run and setup-wizard pickers and the top bar's
|
|
32
|
+
cluster use it through their descriptors.
|
|
33
|
+
- **NiceThemeDesigner**'s themes tree shows the columns preview in place of its two bars.
|
|
34
|
+
|
|
35
|
+
- 2290551: 1.4.0 — **eight curated themes, the rest archived** (breaking):
|
|
36
|
+
|
|
37
|
+
- `NICE_THEME_PRESETS` — what the pickers, the theme catalog and NiceThemeDesigner offer — is now eight themes in the
|
|
38
|
+
1.4.0 standard (palette, gradients, layout colours, shaded sidebar headers, active path, scrollbars): **Black Tie
|
|
39
|
+
Gala** — black and gold, the **default** (`NICE_THEME_DEFAULT`; sans-serif now) — then Fluent, Slate, Minimalism,
|
|
40
|
+
Banking (light) and Obsidian, Onyx, Shadow (dark). As packs: `NICE_THEME_CURATED_PACKS`. Each passes WCAG AA on
|
|
41
|
+
every layout surface, header level and the active row.
|
|
42
|
+
- The themes from before 1.4.0 — the 100-theme gallery, the 36 packs, Blue / High Contrast / Material / Bootstrap /
|
|
43
|
+
the old Fluent — are in **`NICE_THEME_ARCHIVE`** (`core`, `gallery`, `packs`, `packsExtended`, `all`), names a
|
|
44
|
+
curated theme took suffixed " Classic"; their named exports stay. `NICE_THEME_ARCHIVE_CATALOG` (ui) lists them in
|
|
45
|
+
their old categories.
|
|
46
|
+
- `NICE_THEME_CATALOG` has three categories: Premium, Light, Dark.
|
|
47
|
+
- NiceThemeProvider: `theme="light"` / `"dark"` keep the base themes (`niceThemeLight` / `niceThemeDark`); a curated
|
|
48
|
+
name selects that theme; any other name — an archived theme's among them — falls back to Black Tie Gala with a
|
|
49
|
+
warning (import the archived theme and pass the object).
|
|
50
|
+
|
|
51
|
+
- 577c952: 1.4.0 — the layout colours of a theme reach the components; branch highlight shading; themed scrollbars:
|
|
52
|
+
|
|
53
|
+
- **NiceNavShell** paints its main area and panes in the theme's **body** colour (and its gradient), the row under
|
|
54
|
+
the top bar in the top bar's family; **NiceTopNav** (default variant) takes the **top bar** colour / gradient /
|
|
55
|
+
text; **NiceSidebarNav** the **sidebar** colour / gradient / text, its tree's **header levels** shaded from the
|
|
56
|
+
theme's header colour (`layout.sideNav.headers`, the primary by default), its leaves the **item** colour when the
|
|
57
|
+
theme sets one (else a tint of their level); **NiceCard** the **panel** colour. Inside the top bar and the sidebar the
|
|
58
|
+
ordinary tokens are remapped to their colours (menus opened there take the page's back). Every default equals the
|
|
59
|
+
look before: a theme without `layout` renders as it did.
|
|
60
|
+
- **The active item's branch** in the theme's shades is no longer one flat highlight colour: every level above the
|
|
61
|
+
active row takes the highlight over its own colour — weakest at the root, stronger each level down — and the active
|
|
62
|
+
row takes the highlight itself (`layout.sideNav.highlight`).
|
|
63
|
+
- **Scrollbars** follow the theme (`scrollbar`: track, thumb or gradient, hover, the track's width, the thumb's width
|
|
64
|
+
inside it, rounding — `--nice-scrollbar-*`) in every NiceThemeProvider scope. They were grey everywhere because
|
|
65
|
+
components set `scrollbar-width` / `scrollbar-color`, which makes Chrome ignore all `::-webkit-scrollbar` rules;
|
|
66
|
+
those are gone (Firefox gets them only where it lacks the pseudo-elements), and the components that drew their own
|
|
67
|
+
scrollbar take the theme's colours.
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [41a88b4]
|
|
72
|
+
- Updated dependencies [a430ce8]
|
|
73
|
+
- Updated dependencies [8bb55b6]
|
|
74
|
+
- Updated dependencies [2290551]
|
|
75
|
+
- @nice2dev/ui-core@1.4.0
|
|
76
|
+
- @nice2dev/i18n@1.4.0
|
|
77
|
+
|
|
78
|
+
## 1.3.18
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- 00b696e: Icons and motion (OmniVerk wishlist §1, §8):
|
|
83
|
+
|
|
84
|
+
- **Reduced motion:** for users who ask for it (`prefers-reduced-motion: reduce`) every `Ntd*` icon holds still on
|
|
85
|
+
its own — no CSS animation class, and its SVG (SMIL) animations jump to their last frame (an entrance shows its
|
|
86
|
+
result, a loop rests on the shape as drawn): the icons' own animations (NtdOmniVerk…), `smilAnimation`, gradient
|
|
87
|
+
animations, the style decorators and `SmilAnimationWrapper`. `reducedMotion="ignore"` plays anyway. The
|
|
88
|
+
stylesheet has a reduced-motion rule for anything animated by hand. `withReducedMotionProps` also clears
|
|
89
|
+
`smilAnimation`; `useReducedMotion` follows the same store.
|
|
90
|
+
- NiceSetupWizard pauses SVG animations in its `loadingIndicator` for reduced motion (CSS animations stopped
|
|
91
|
+
already; SMIL kept going).
|
|
92
|
+
- **`animationMode="single"`** plays a looping `animation` once (the parts an icon animates inside itself
|
|
93
|
+
included): the stylesheet repeats `var(--ntd-anim-iterations, infinite)`. **`playKey`** starts the animations over
|
|
94
|
+
when it changes; **`replayOnClick`** on every click.
|
|
95
|
+
- InteractiveIcon with a `click` trigger plays again on every click; `AnimationController.play()` starts over while
|
|
96
|
+
already playing.
|
|
97
|
+
|
|
98
|
+
- 92418c0: OmniVerk wishlist §3, packaging:
|
|
99
|
+
|
|
100
|
+
- No test declarations in `dist` any more: erp-adapter (16 files), auth (12), ui-communication (8), ui-presentations
|
|
101
|
+
(14), and the test `setup.d.ts` of ui-3d, ui-graphics and game-engine.
|
|
102
|
+
- **One stylesheet per package**: icons, ui-3d and ui-graphics ship theirs in `dist/esm` only — where `exports`
|
|
103
|
+
points; the `dist/cjs` copy was reached from nothing.
|
|
104
|
+
- design-tokens builds its CLI as ES modules only: `bin` and `./cli` point at `dist/cli/index.js`; the CommonJS
|
|
105
|
+
`dist/cli/index.cjs` nothing referred to is gone.
|
|
106
|
+
- ui README: the Tools section and its link say 12 components (the link pointed at `#tools-14-components`).
|
|
107
|
+
|
|
108
|
+
- ef02ccf: OmniVerk wishlist §7: **pages carried to the shortcuts and the favourites**. A row of NiceSidebarNav's tree can be
|
|
109
|
+
dragged (mouse or pen; a press that does not move is still a click, a finger still scrolls): while it is carried a
|
|
110
|
+
bar above the footer offers **Favourites** (the list in view) and, with `shortcutsRail`, **Shortcuts**. The
|
|
111
|
+
Favourites view takes a drop too, and on the shortcuts rail a page lands where it is dropped among the user's
|
|
112
|
+
shortcuts — which can be dragged along it to reorder; the host's stay put. In NiceNavShell a tab of one page dragged
|
|
113
|
+
out of its strip — across it, or off it while reordering — is carried the same way; the sidebar finds its item by
|
|
114
|
+
the route. Escape cancels. The keyboard keeps the item's menu and star.
|
|
115
|
+
- 924eb04: OmniVerk wishlist §2, §4:
|
|
116
|
+
|
|
117
|
+
- **`NiceNavShellPaneHeader`** and `headerSlot` in `NiceNavShellPaneInfo`: in a merged tab a page's own header row
|
|
118
|
+
goes under its pane's header and stays put while the pane scrolls — the mirror of `NiceNavShellPaneFooter`;
|
|
119
|
+
anywhere else the children render where they stand.
|
|
120
|
+
- An inherited **`--nice-field-control-width`** (e.g. `100%` on a filter row) now stretches **NiceSelect**,
|
|
121
|
+
**NiceAutocomplete** and **NiceDateTimePicker** like the text inputs since 1.3.15: the field took the width, the
|
|
122
|
+
select stayed 160px, the autocomplete 220px (an inline style no width could change, not even `controlWidth`)
|
|
123
|
+
and the date input content-sized. Without the variable they look as before.
|
|
124
|
+
|
|
125
|
+
- b3c4b2e: OmniVerk wishlist §6: **NiceSidebarNav `shortcutsRail`** — a last collapse level. Past icons only, the sidebar folds
|
|
126
|
+
to a column of shortcuts (`NiceIconRail`, `railWidth` wide): the host's `predefinedShortcuts` first (fixed), then the
|
|
127
|
+
user's, kept in the new **`shortcuts`** preference. An item's menu and its star's lists gain **Add to shortcuts** /
|
|
128
|
+
**Remove from shortcuts**; a shortcut's own menu (right-click, the menu key) opens it in a new tab, moves it up or
|
|
129
|
+
down, removes it. The footer has a level-down and a level-up button; **`collapseLevel`** /
|
|
130
|
+
`defaultCollapseLevel` / `onCollapseLevelChange` (`'expanded' | 'icons' | 'rail'`) control it, while `collapsed` /
|
|
131
|
+
`onCollapsedChange` keep working (icons and the rail are both collapsed). New helpers `addShortcut`,
|
|
132
|
+
`removeShortcut`, `moveShortcut`. **`allowUserShortcuts={false}`** (an administrator's choice) leaves the rail to the
|
|
133
|
+
predefined ones. `railItems` — the column beside the expanded sidebar — is unchanged.
|
|
134
|
+
|
|
135
|
+
**NiceIconRail**: an item's `menu` (`NiceMenuItem[]`) opens on right-click, the menu key or Shift+F10.
|
|
136
|
+
|
|
137
|
+
- fca336f: OmniVerk wishlist §5: **NiceSidebarNav `inlineSearch`** — a box above the tree that narrows whatever the current
|
|
138
|
+
mode shows (All, groups, Favorites) as you type. A match on a label or tooltip keeps everything under it, the
|
|
139
|
+
branches above a match open for as long as the query lasts and close back to their stored state when it is
|
|
140
|
+
cleared; a source with nothing left hides. Case and diacritics are ignored ("lodz" finds "Łódź"). Filtering is
|
|
141
|
+
view-only — favourites edits still act on the full lists. Controlled through `searchText` / `onSearchChange`
|
|
142
|
+
(or `defaultSearchText`), placeholder via `searchPlaceholder`; Escape clears. With `inlineSearch` the separate
|
|
143
|
+
Search mode icon is left out of the mode strip. The matching helpers are exported as `normalizeSidebarSearch`,
|
|
144
|
+
`sidebarItemMatches` and `filterSidebarItems`.
|
|
145
|
+
- Updated dependencies [bf710b2]
|
|
146
|
+
- @nice2dev/i18n@1.3.18
|
|
147
|
+
- @nice2dev/ui-core@1.3.18
|
|
148
|
+
|
|
3
149
|
## 1.3.17
|
|
4
150
|
|
|
5
151
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Quick reference — most common areas:
|
|
|
65
65
|
- [Charts (16)](#charts-16-components)
|
|
66
66
|
- [Overlays & Layout (9)](#overlays--layout-9-components)
|
|
67
67
|
- [Planning (4)](#planning-4-components)
|
|
68
|
-
- [Tools (
|
|
68
|
+
- [Tools (12)](#tools-12-components)
|
|
69
69
|
- [Validation (3 + 1 hook)](#validation-3-components--1-hook)
|
|
70
70
|
- [Core Infrastructure](#core-infrastructure)
|
|
71
71
|
- [Shared Types](#shared-types)
|
|
@@ -332,7 +332,7 @@ Form input components with consistent `NiceFormFieldProps` interface: `label`, `
|
|
|
332
332
|
| `NiceDiagram` | `nodes[]`, `edges[]`, `onNodeClick`, `onEdgeClick` | Node/edge diagram |
|
|
333
333
|
| `NiceStepper` | `steps[]`, `currentStep`, `onStepChange`, `vertical` | Step wizard |
|
|
334
334
|
|
|
335
|
-
### Tools (
|
|
335
|
+
### Tools (12 components)
|
|
336
336
|
|
|
337
337
|
| Component | Key Props | Description |
|
|
338
338
|
| ------------------- | -------------------------------------------------------- | ---------------------------------------- |
|
|
@@ -678,6 +678,33 @@ Create a custom theme by overriding CSS variables:
|
|
|
678
678
|
}
|
|
679
679
|
```
|
|
680
680
|
|
|
681
|
+
### Themes (1.4.0): layout colours, links, palettes, scrollbars
|
|
682
|
+
|
|
683
|
+
A theme (`NiceTheme`, passed to `NiceThemeProvider`) also colours the **layout** — `layout.body`, `layout.panel`,
|
|
684
|
+
`layout.topNav`, `layout.sideNav` (each `background` / `text` / `border`; the sidebar adds its tree's `headers`
|
|
685
|
+
levels, its `items` and the `highlight` of the active item and its branch) — and the **scrollbars** (`scrollbar`:
|
|
686
|
+
`track`, `thumb`, `thumbHover`, `width`, `thumbWidth`, `radius`). A value is a colour, a gradient (surfaces) or a
|
|
687
|
+
**link** to another value, like a variable — `{palette.gold}`, `{gradients.sheen}`, `{colors.primary}`,
|
|
688
|
+
`{layout.topNav.background}` — against the theme's own named `palette` and `gradients`:
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
const myTheme: NiceTheme = {
|
|
692
|
+
...niceThemeSlateV2,
|
|
693
|
+
name: 'My Slate',
|
|
694
|
+
palette: { ink: '#0f172a', sky: '#0369a1' },
|
|
695
|
+
layout: {
|
|
696
|
+
topNav: { background: 'linear-gradient(90deg, {palette.ink}, #1e293b)', text: '#f1f5f9' },
|
|
697
|
+
sideNav: { headers: { base: '{palette.ink}' }, highlight: { base: '{palette.sky}', text: '#ffffff' } },
|
|
698
|
+
},
|
|
699
|
+
};
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
The built-in themes (`NICE_THEME_PRESETS`) are eight: **Black Tie Gala** (the default, `NICE_THEME_DEFAULT`),
|
|
703
|
+
Fluent, Slate, Minimalism, Banking, Obsidian, Onyx, Shadow. The themes from before 1.4.0 are in
|
|
704
|
+
`NICE_THEME_ARCHIVE` (`core`, `gallery`, `packs`, `packsExtended`, `all`). `resolveTheme(theme)` resolves the
|
|
705
|
+
links; `useNiceTheme().theme` is the resolved theme, `sourceTheme` the one as written. NiceThemeDesigner edits all
|
|
706
|
+
of it — links, the palette, the header levels with Sync / Sync once, the scrollbar.
|
|
707
|
+
|
|
681
708
|
### Following your app's own variables
|
|
682
709
|
|
|
683
710
|
`style.css` declares the conventional shorthand names (`--color-primary`, `--bg-primary`,
|
|
@@ -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-
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),y=require("@nice2dev/ui-core"),r=require("react"),pn=require("react-dom"),Wi=require("./NiceForm-Bysp66Ef.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+`
|