@alaarab/ogrid-react-fluent 2.0.0-beta
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/README.md +85 -0
- package/dist/esm/ColumnChooser/ColumnChooser.js +152 -0
- package/dist/esm/ColumnChooser/ColumnChooser.module.css +15 -0
- package/dist/esm/ColumnHeaderFilter/ColumnHeaderFilter.js +49 -0
- package/dist/esm/ColumnHeaderFilter/ColumnHeaderFilter.module.css +374 -0
- package/dist/esm/ColumnHeaderFilter/MultiSelectFilterPopover.js +9 -0
- package/dist/esm/ColumnHeaderFilter/PeopleFilterPopover.js +9 -0
- package/dist/esm/ColumnHeaderFilter/TextFilterPopover.js +12 -0
- package/dist/esm/ColumnHeaderFilter/index.js +1 -0
- package/dist/esm/DataGridTable/DataGridTable.js +265 -0
- package/dist/esm/DataGridTable/DataGridTable.module.css +592 -0
- package/dist/esm/DataGridTable/GridContextMenu.js +35 -0
- package/dist/esm/DataGridTable/InlineCellEditor.js +6 -0
- package/dist/esm/DataGridTable/StatusBar.js +7 -0
- package/dist/esm/FluentDataTable/FluentDataTable.js +18 -0
- package/dist/esm/FluentDataTable/index.js +1 -0
- package/dist/esm/PaginationControls/PaginationControls.js +20 -0
- package/dist/esm/PaginationControls/PaginationControls.module.css +74 -0
- package/dist/esm/index.js +8 -0
- package/dist/types/ColumnChooser/ColumnChooser.d.ts +10 -0
- package/dist/types/ColumnHeaderFilter/ColumnHeaderFilter.d.ts +22 -0
- package/dist/types/ColumnHeaderFilter/MultiSelectFilterPopover.d.ts +19 -0
- package/dist/types/ColumnHeaderFilter/PeopleFilterPopover.d.ts +14 -0
- package/dist/types/ColumnHeaderFilter/TextFilterPopover.d.ts +13 -0
- package/dist/types/ColumnHeaderFilter/index.d.ts +1 -0
- package/dist/types/DataGridTable/DataGridTable.d.ts +5 -0
- package/dist/types/DataGridTable/GridContextMenu.d.ts +10 -0
- package/dist/types/DataGridTable/InlineCellEditor.d.ts +12 -0
- package/dist/types/DataGridTable/StatusBar.d.ts +16 -0
- package/dist/types/FluentDataTable/FluentDataTable.d.ts +7 -0
- package/dist/types/FluentDataTable/index.d.ts +1 -0
- package/dist/types/PaginationControls/PaginationControls.d.ts +12 -0
- package/dist/types/index.d.ts +6 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>OGrid for Fluent UI</strong> — The lightweight React data grid with enterprise features and zero enterprise cost.
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@alaarab/ogrid-react-fluent"><img src="https://img.shields.io/npm/v/@alaarab/ogrid-react-fluent?color=%23217346&label=npm" alt="npm version" /></a>
|
|
7
|
+
<a href="https://github.com/alaarab/ogrid/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="MIT License" /></a>
|
|
8
|
+
<img src="https://img.shields.io/badge/React-17%20%7C%2018%20%7C%2019-blue" alt="React 17, 18, 19" />
|
|
9
|
+
<img src="https://img.shields.io/badge/TypeScript-strict-blue" alt="TypeScript strict" />
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://alaarab.github.io/ogrid/">Documentation</a> · <a href="https://alaarab.github.io/ogrid/docs/getting-started/overview">Getting Started</a> · <a href="https://alaarab.github.io/ogrid/docs/api/ogrid-props">API Reference</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
OGrid data grid for **[Fluent UI v9](https://react.fluentui.dev/)**. Also available for [Radix UI](https://www.npmjs.com/package/@alaarab/ogrid-react-radix) (default, lightweight) and [Material UI](https://www.npmjs.com/package/@alaarab/ogrid-react-material). Same API, just swap the import.
|
|
19
|
+
|
|
20
|
+
## Why OGrid?
|
|
21
|
+
|
|
22
|
+
| | OGrid | AG Grid Community | AG Grid Enterprise |
|
|
23
|
+
|---|---|---|---|
|
|
24
|
+
| Spreadsheet selection | Built-in | - | $999/dev/year |
|
|
25
|
+
| Clipboard (copy/paste) | Built-in | - | $999/dev/year |
|
|
26
|
+
| Fill handle | Built-in | - | $999/dev/year |
|
|
27
|
+
| Undo/redo | Built-in | - | $999/dev/year |
|
|
28
|
+
| Context menu | Built-in | - | $999/dev/year |
|
|
29
|
+
| Status bar | Built-in | - | $999/dev/year |
|
|
30
|
+
| Side bar | Built-in | - | $999/dev/year |
|
|
31
|
+
| Cell editing | Built-in | Built-in | Built-in |
|
|
32
|
+
| Sorting & filtering | Built-in | Built-in | Built-in |
|
|
33
|
+
| **License** | **MIT (free)** | MIT | Commercial |
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
Sorting · Filtering (text, multi-select, date range, people picker) · Pagination · Cell editing (inline, select, checkbox, rich select, date, custom popover) · Spreadsheet selection · Clipboard · Fill handle · Undo/redo · Row selection · Column groups · Column pinning · Column resize · Column chooser · Side bar · Context menu · Status bar with aggregations · CSV export · Grid API · Server-side data · Column state persistence · Keyboard navigation (Excel-style Ctrl+Arrow) · Built-in column types (text, numeric, date, boolean) · React 17/18/19 · TypeScript strict
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @alaarab/ogrid-react-fluent
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Peer Dependencies
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
@fluentui/react-components ^9.0.0
|
|
49
|
+
@fluentui/react-icons ^2.0.0
|
|
50
|
+
react ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
51
|
+
react-dom ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { OGrid, type IColumnDef } from '@alaarab/ogrid-react-fluent';
|
|
58
|
+
|
|
59
|
+
const columns: IColumnDef<Employee>[] = [
|
|
60
|
+
{ columnId: 'name', name: 'Name', sortable: true, editable: true },
|
|
61
|
+
{ columnId: 'department', name: 'Department',
|
|
62
|
+
filterable: { type: 'multiSelect' },
|
|
63
|
+
cellEditor: 'richSelect', cellEditorParams: { values: ['Engineering', 'Sales', 'Marketing'] } },
|
|
64
|
+
{ columnId: 'salary', name: 'Salary', type: 'numeric', editable: true,
|
|
65
|
+
valueFormatter: (v) => `$${Number(v).toLocaleString()}` },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
<OGrid
|
|
69
|
+
columns={columns}
|
|
70
|
+
data={employees}
|
|
71
|
+
getRowId={(e) => e.id}
|
|
72
|
+
editable
|
|
73
|
+
cellSelection
|
|
74
|
+
statusBar
|
|
75
|
+
sideBar
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Documentation
|
|
80
|
+
|
|
81
|
+
Full docs, API reference, and interactive examples at **[alaarab.github.io/ogrid](https://alaarab.github.io/ogrid/)**.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT — Free forever. No enterprise tiers. No feature paywalls.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { Checkbox, makeStyles, tokens, mergeClasses, } from '@fluentui/react-components';
|
|
4
|
+
import { TableSettingsRegular, ChevronDownRegular, ChevronUpRegular } from '@fluentui/react-icons';
|
|
5
|
+
import { useColumnChooserState } from '@alaarab/ogrid-react';
|
|
6
|
+
const useStyles = makeStyles({
|
|
7
|
+
container: {
|
|
8
|
+
position: 'relative',
|
|
9
|
+
display: 'inline-flex',
|
|
10
|
+
},
|
|
11
|
+
triggerButton: {
|
|
12
|
+
display: 'inline-flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
gap: '6px',
|
|
15
|
+
padding: '6px 12px',
|
|
16
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
17
|
+
borderRadius: tokens.borderRadiusMedium,
|
|
18
|
+
backgroundColor: tokens.colorNeutralBackground1,
|
|
19
|
+
cursor: 'pointer',
|
|
20
|
+
fontSize: tokens.fontSizeBase300,
|
|
21
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
22
|
+
color: tokens.colorNeutralForeground1,
|
|
23
|
+
transitionDuration: '0.15s',
|
|
24
|
+
transitionProperty: 'all',
|
|
25
|
+
transitionTimingFunction: 'ease',
|
|
26
|
+
':hover': {
|
|
27
|
+
backgroundColor: tokens.colorNeutralBackground1Hover,
|
|
28
|
+
border: `1px solid ${tokens.colorNeutralStroke1Hover}`,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
triggerButtonOpen: {
|
|
32
|
+
border: `1px solid ${tokens.colorBrandStroke1}`,
|
|
33
|
+
},
|
|
34
|
+
buttonIcon: {
|
|
35
|
+
fontSize: '16px',
|
|
36
|
+
},
|
|
37
|
+
chevron: {
|
|
38
|
+
fontSize: '12px',
|
|
39
|
+
color: tokens.colorNeutralForeground3,
|
|
40
|
+
},
|
|
41
|
+
dropdown: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
top: 'calc(100% + 4px)',
|
|
44
|
+
right: '0',
|
|
45
|
+
zIndex: 10000,
|
|
46
|
+
minWidth: '220px',
|
|
47
|
+
backgroundColor: tokens.colorNeutralBackground1,
|
|
48
|
+
borderRadius: tokens.borderRadiusMedium,
|
|
49
|
+
boxShadow: tokens.shadow16,
|
|
50
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
51
|
+
display: 'flex',
|
|
52
|
+
flexDirection: 'column',
|
|
53
|
+
},
|
|
54
|
+
header: {
|
|
55
|
+
padding: '8px 12px',
|
|
56
|
+
borderBottom: `1px solid ${tokens.colorNeutralStroke2}`,
|
|
57
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
58
|
+
fontSize: tokens.fontSizeBase300,
|
|
59
|
+
color: tokens.colorNeutralForeground1,
|
|
60
|
+
backgroundColor: tokens.colorNeutralBackground2,
|
|
61
|
+
},
|
|
62
|
+
optionsList: {
|
|
63
|
+
maxHeight: '320px',
|
|
64
|
+
overflowY: 'auto',
|
|
65
|
+
padding: 0,
|
|
66
|
+
},
|
|
67
|
+
optionItem: {
|
|
68
|
+
padding: '4px 12px',
|
|
69
|
+
display: 'flex',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
minHeight: '32px',
|
|
72
|
+
':hover': {
|
|
73
|
+
backgroundColor: tokens.colorNeutralBackground1Hover,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
actions: {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
justifyContent: 'flex-end',
|
|
79
|
+
gap: '8px',
|
|
80
|
+
padding: '8px 12px',
|
|
81
|
+
borderTop: `1px solid ${tokens.colorNeutralStroke2}`,
|
|
82
|
+
backgroundColor: tokens.colorNeutralBackground2,
|
|
83
|
+
},
|
|
84
|
+
clearButton: {
|
|
85
|
+
padding: '6px 12px',
|
|
86
|
+
border: `1px solid ${tokens.colorNeutralStroke1}`,
|
|
87
|
+
borderRadius: tokens.borderRadiusSmall,
|
|
88
|
+
backgroundColor: tokens.colorNeutralBackground1,
|
|
89
|
+
color: tokens.colorNeutralForeground2,
|
|
90
|
+
fontSize: tokens.fontSizeBase200,
|
|
91
|
+
fontWeight: tokens.fontWeightRegular,
|
|
92
|
+
cursor: 'pointer',
|
|
93
|
+
transitionDuration: '0.15s',
|
|
94
|
+
transitionProperty: 'all',
|
|
95
|
+
':hover': {
|
|
96
|
+
backgroundColor: tokens.colorNeutralBackground1Hover,
|
|
97
|
+
color: tokens.colorNeutralForeground1,
|
|
98
|
+
border: `1px solid ${tokens.colorNeutralStroke1Hover}`,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
selectAllButton: {
|
|
102
|
+
padding: '6px 16px',
|
|
103
|
+
border: 'none',
|
|
104
|
+
borderRadius: tokens.borderRadiusSmall,
|
|
105
|
+
backgroundColor: tokens.colorBrandBackground,
|
|
106
|
+
color: tokens.colorNeutralForegroundOnBrand,
|
|
107
|
+
fontSize: tokens.fontSizeBase200,
|
|
108
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
109
|
+
cursor: 'pointer',
|
|
110
|
+
transitionDuration: '0.15s',
|
|
111
|
+
transitionProperty: 'all',
|
|
112
|
+
':hover': {
|
|
113
|
+
backgroundColor: tokens.colorBrandBackgroundHover,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
export const ColumnChooser = (props) => {
|
|
118
|
+
const { columns, visibleColumns, onVisibilityChange, className } = props;
|
|
119
|
+
const classes = useStyles();
|
|
120
|
+
const buttonRef = useRef(null);
|
|
121
|
+
const dropdownRef = useRef(null);
|
|
122
|
+
const { open: isOpen, handleToggle, handleClose, handleCheckboxChange: setColumnVisible, handleSelectAll, handleClearAll, visibleCount, totalCount, } = useColumnChooserState({ columns, visibleColumns, onVisibilityChange });
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!isOpen)
|
|
125
|
+
return;
|
|
126
|
+
const handleClickOutside = (event) => {
|
|
127
|
+
const target = event.target;
|
|
128
|
+
const isOutsideDropdown = dropdownRef.current && !dropdownRef.current.contains(target);
|
|
129
|
+
const isOutsideButton = buttonRef.current && !buttonRef.current.contains(target);
|
|
130
|
+
if (isOutsideDropdown && isOutsideButton) {
|
|
131
|
+
handleClose();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const timeoutId = setTimeout(() => {
|
|
135
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
136
|
+
}, 0);
|
|
137
|
+
return () => {
|
|
138
|
+
clearTimeout(timeoutId);
|
|
139
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
140
|
+
};
|
|
141
|
+
}, [isOpen, handleClose]);
|
|
142
|
+
const handleCheckboxChange = (columnKey) => {
|
|
143
|
+
return (ev, data) => {
|
|
144
|
+
ev.stopPropagation();
|
|
145
|
+
setColumnVisible(columnKey)(data.checked === true);
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const handleDropdownClick = (e) => {
|
|
149
|
+
e.stopPropagation();
|
|
150
|
+
};
|
|
151
|
+
return (_jsxs("div", { className: `${classes.container} ${className || ''}`, children: [_jsxs("button", { type: "button", ref: buttonRef, className: mergeClasses(classes.triggerButton, isOpen && classes.triggerButtonOpen), onClick: handleToggle, "aria-expanded": isOpen, "aria-haspopup": "listbox", children: [_jsx(TableSettingsRegular, { className: classes.buttonIcon }), _jsxs("span", { children: ["Column Visibility (", visibleCount, " of ", totalCount, ")"] }), isOpen ? _jsx(ChevronUpRegular, { className: classes.chevron }) : _jsx(ChevronDownRegular, { className: classes.chevron })] }), isOpen && (_jsxs("div", { className: classes.dropdown, ref: dropdownRef, onClick: handleDropdownClick, children: [_jsxs("div", { className: classes.header, children: ["Select Columns (", visibleCount, " of ", totalCount, ")"] }), _jsx("div", { className: classes.optionsList, children: columns.map(column => (_jsx("div", { className: classes.optionItem, children: _jsx(Checkbox, { label: column.name, checked: visibleColumns.has(column.columnId), onChange: handleCheckboxChange(column.columnId) }) }, column.columnId))) }), _jsxs("div", { className: classes.actions, children: [_jsx("button", { type: "button", className: classes.clearButton, onClick: handleClearAll, children: "Clear All" }), _jsx("button", { type: "button", className: classes.selectAllButton, onClick: handleSelectAll, children: "Select All" })] })] }))] }));
|
|
152
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.columnChooser {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.columnChooserHeader {
|
|
6
|
+
padding: 10px 15px;
|
|
7
|
+
border-bottom: 1px solid var(--colorNeutralStroke2, #edebe9);
|
|
8
|
+
margin-bottom: 5px;
|
|
9
|
+
}
|
|
10
|
+
.columnChooserHeader h3 {
|
|
11
|
+
margin: 0;
|
|
12
|
+
font-size: 14px;
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
color: var(--colorNeutralForeground1, #323130);
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Popover, PopoverSurface } from '@fluentui/react-components';
|
|
4
|
+
import { ArrowUpRegular, ArrowDownRegular, ArrowSortRegular, FilterRegular } from '@fluentui/react-icons';
|
|
5
|
+
import { useColumnHeaderFilterState } from '@alaarab/ogrid-react';
|
|
6
|
+
import { TextFilterPopover } from './TextFilterPopover';
|
|
7
|
+
import { MultiSelectFilterPopover } from './MultiSelectFilterPopover';
|
|
8
|
+
import { PeopleFilterPopover } from './PeopleFilterPopover';
|
|
9
|
+
import styles from './ColumnHeaderFilter.module.css';
|
|
10
|
+
export const ColumnHeaderFilter = React.memo((props) => {
|
|
11
|
+
const { columnName, filterType, isSorted = false, isSortedDescending = false, onSort, selectedValues, onFilterChange, options, isLoadingOptions = false, textValue = '', onTextChange, selectedUser, onUserChange, peopleSearch, dateValue, onDateChange, } = props;
|
|
12
|
+
const state = useColumnHeaderFilterState({
|
|
13
|
+
filterType,
|
|
14
|
+
isSorted,
|
|
15
|
+
isSortedDescending,
|
|
16
|
+
onSort,
|
|
17
|
+
selectedValues,
|
|
18
|
+
onFilterChange,
|
|
19
|
+
options,
|
|
20
|
+
isLoadingOptions,
|
|
21
|
+
textValue,
|
|
22
|
+
onTextChange,
|
|
23
|
+
selectedUser,
|
|
24
|
+
onUserChange,
|
|
25
|
+
peopleSearch,
|
|
26
|
+
dateValue,
|
|
27
|
+
onDateChange,
|
|
28
|
+
});
|
|
29
|
+
const { headerRef, popoverRef, peopleInputRef, isFilterOpen, setFilterOpen, tempSelected, setTempTextValue, searchText, setSearchText, filteredOptions, peopleSuggestions, isPeopleLoading, peopleSearchText, setPeopleSearchText, hasActiveFilter, handlers, } = state;
|
|
30
|
+
const filterBtnRef = React.useRef(null);
|
|
31
|
+
const renderPopoverContent = () => {
|
|
32
|
+
if (filterType === 'multiSelect') {
|
|
33
|
+
return (_jsx(MultiSelectFilterPopover, { searchText: searchText, onSearchChange: setSearchText, options: options ?? [], filteredOptions: filteredOptions, selected: tempSelected, onOptionToggle: handlers.handleCheckboxChange, onSelectAll: handlers.handleSelectAll, onClearSelection: handlers.handleClearSelection, onApply: handlers.handleApplyMultiSelect, isLoading: isLoadingOptions, onPopoverClick: handlers.handlePopoverClick, onInputFocus: handlers.handleInputFocus, onInputMouseDown: handlers.handleInputMouseDown, onInputClick: handlers.handleInputClick, onInputKeyDown: handlers.handleInputKeyDown }));
|
|
34
|
+
}
|
|
35
|
+
if (filterType === 'text') {
|
|
36
|
+
return (_jsx(TextFilterPopover, { value: state.tempTextValue, onValueChange: setTempTextValue, onApply: handlers.handleTextApply, onClear: handlers.handleTextClear, onPopoverClick: handlers.handlePopoverClick, onInputFocus: handlers.handleInputFocus, onInputMouseDown: handlers.handleInputMouseDown, onInputClick: handlers.handleInputClick, onInputKeyDown: handlers.handleInputKeyDown }));
|
|
37
|
+
}
|
|
38
|
+
if (filterType === 'people') {
|
|
39
|
+
return (_jsx(PeopleFilterPopover, { selectedUser: selectedUser, searchText: peopleSearchText, onSearchChange: setPeopleSearchText, suggestions: peopleSuggestions, isLoading: isPeopleLoading, onUserSelect: handlers.handleUserSelect, onClearUser: handlers.handleClearUser, onPopoverClick: handlers.handlePopoverClick, inputRef: peopleInputRef }));
|
|
40
|
+
}
|
|
41
|
+
if (filterType === 'date') {
|
|
42
|
+
return (_jsxs("div", { onClick: handlers.handlePopoverClick, children: [_jsxs("div", { style: { padding: '8px 12px', display: 'flex', flexDirection: 'column', gap: 6 }, children: [_jsxs("label", { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 12 }, children: ["From:", _jsx("input", { type: "date", value: state.tempDateFrom, onChange: (e) => state.setTempDateFrom(e.target.value), style: { flex: 1 } })] }), _jsxs("label", { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 12 }, children: ["To:", _jsx("input", { type: "date", value: state.tempDateTo, onChange: (e) => state.setTempDateTo(e.target.value), style: { flex: 1 } })] })] }), _jsxs("div", { className: styles.popoverActions, children: [_jsx("button", { className: styles.clearButton, onClick: handlers.handleDateClear, disabled: !state.tempDateFrom && !state.tempDateTo, children: "Clear" }), _jsx("button", { className: styles.applyButton, onClick: handlers.handleDateApply, children: "Apply" })] })] }));
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
return (_jsxs("div", { className: styles.columnHeader, ref: headerRef, children: [_jsx("div", { className: styles.headerContent, children: _jsx("span", { className: styles.columnName, title: columnName, "data-header-label": true, children: columnName }) }), _jsxs("div", { className: styles.headerActions, children: [onSort && (_jsx("button", { type: "button", className: `${styles.sortIcon} ${isSorted ? styles.sortActive : ''}`, onClick: handlers.handleSortClick, "aria-label": `Sort by ${columnName}`, title: isSorted ? (isSortedDescending ? 'Sorted descending' : 'Sorted ascending') : 'Sort', children: isSorted ? (isSortedDescending ? _jsx(ArrowDownRegular, {}) : _jsx(ArrowUpRegular, {})) : (_jsx(ArrowSortRegular, {})) })), filterType !== 'none' && (_jsxs(_Fragment, { children: [_jsxs("button", { ref: filterBtnRef, type: "button", className: `${styles.filterIcon} ${hasActiveFilter ? styles.filterActive : ''} ${isFilterOpen ? styles.filterOpen : ''}`, onClick: handlers.handleFilterIconClick, "aria-label": `Filter ${columnName}`, title: `Filter ${columnName}`, children: [_jsx(FilterRegular, {}), hasActiveFilter && _jsx("span", { className: styles.filterBadge })] }), _jsx(Popover, { open: isFilterOpen, onOpenChange: (_, data) => { if (!data.open)
|
|
47
|
+
setFilterOpen(false); }, positioning: { target: filterBtnRef.current ?? undefined, position: 'below', align: 'start', offset: 4 }, trapFocus: false, children: _jsxs(PopoverSurface, { ref: popoverRef, className: styles.filterPopover, onClick: handlers.handlePopoverClick, children: [_jsxs("div", { className: styles.popoverHeader, children: ["Filter: ", columnName] }), renderPopoverContent()] }) })] }))] })] }));
|
|
48
|
+
});
|
|
49
|
+
ColumnHeaderFilter.displayName = 'ColumnHeaderFilter';
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
.columnHeader {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 4px;
|
|
5
|
+
width: 100%;
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
min-width: 0;
|
|
8
|
+
position: relative;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Keep header actions always visible, but do not let them participate in layout.
|
|
14
|
+
Otherwise, wide header cells make the sort/filter icons look "stranded" far to the right.
|
|
15
|
+
|
|
16
|
+
NOTE: Fluent's column resize hit-target lives at the far right edge of the header cell.
|
|
17
|
+
We leave a 16px safety zone for it.
|
|
18
|
+
*/
|
|
19
|
+
:root {
|
|
20
|
+
--dt-header-resize-zone: 16px;
|
|
21
|
+
--dt-header-action-button: 24px;
|
|
22
|
+
--dt-header-action-gap: 2px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.headerContent {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 4px;
|
|
29
|
+
flex: 1;
|
|
30
|
+
min-width: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
padding: 2px 0;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
/* Reserve room for 2 buttons + gap + resize zone so text never overlaps actions. */
|
|
37
|
+
/* padding-right removed: use normal flex layout so actions never overflow */
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.columnName {
|
|
41
|
+
display: block;
|
|
42
|
+
min-width: 0;
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
color: var(--colorNeutralForeground1, #242424);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.headerActions {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
gap: var(--dt-header-action-gap);
|
|
56
|
+
/* Keep actions in normal flow so they never overflow the header cell. */
|
|
57
|
+
margin-left: auto;
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sortIcon {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
width: 24px;
|
|
66
|
+
height: 24px;
|
|
67
|
+
padding: 4px;
|
|
68
|
+
border: none;
|
|
69
|
+
border-radius: var(--borderRadiusSmall, 4px);
|
|
70
|
+
background-color: transparent;
|
|
71
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
transition: all 0.15s ease;
|
|
75
|
+
}
|
|
76
|
+
.sortIcon svg {
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
}
|
|
79
|
+
.sortIcon:hover {
|
|
80
|
+
background-color: var(--colorSubtleBackgroundHover, #f5f5f5);
|
|
81
|
+
color: var(--colorNeutralForeground2Hover, #424242);
|
|
82
|
+
}
|
|
83
|
+
.sortIcon.sortActive {
|
|
84
|
+
background-color: var(--colorSubtleBackgroundSelected, #e0e0e0);
|
|
85
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
86
|
+
}
|
|
87
|
+
.sortIcon.sortActive:hover {
|
|
88
|
+
background-color: var(--colorSubtleBackgroundHover, #f5f5f5);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.filterIcon {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
width: 24px;
|
|
96
|
+
height: 24px;
|
|
97
|
+
padding: 4px;
|
|
98
|
+
margin-left: 2px;
|
|
99
|
+
border: none;
|
|
100
|
+
border-radius: var(--borderRadiusSmall, 4px);
|
|
101
|
+
background-color: transparent;
|
|
102
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
flex-shrink: 0;
|
|
105
|
+
position: relative;
|
|
106
|
+
transition: all 0.15s ease;
|
|
107
|
+
}
|
|
108
|
+
.filterIcon svg {
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
}
|
|
111
|
+
.filterIcon:hover {
|
|
112
|
+
background-color: var(--colorSubtleBackgroundHover, #f5f5f5);
|
|
113
|
+
color: var(--colorNeutralForeground2Hover, #424242);
|
|
114
|
+
}
|
|
115
|
+
.filterIcon.filterActive {
|
|
116
|
+
background-color: var(--colorSubtleBackgroundSelected, #e0e0e0);
|
|
117
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
118
|
+
}
|
|
119
|
+
.filterIcon.filterActive:hover {
|
|
120
|
+
background-color: var(--colorSubtleBackgroundHover, #f5f5f5);
|
|
121
|
+
}
|
|
122
|
+
.filterIcon.filterOpen {
|
|
123
|
+
background-color: var(--colorSubtleBackgroundPressed, #ebebeb);
|
|
124
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.filterBadge {
|
|
128
|
+
position: absolute;
|
|
129
|
+
top: 2px;
|
|
130
|
+
right: 2px;
|
|
131
|
+
width: 6px;
|
|
132
|
+
height: 6px;
|
|
133
|
+
background-color: var(--colorBrandBackground, #0f6cbd);
|
|
134
|
+
border-radius: 50%;
|
|
135
|
+
border: 1px solid var(--colorNeutralBackground1, #ffffff);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.filterPopover {
|
|
139
|
+
min-width: 280px;
|
|
140
|
+
max-width: 320px;
|
|
141
|
+
overflow: hidden;
|
|
142
|
+
padding: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.popoverHeader {
|
|
146
|
+
padding: 10px 14px;
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
font-weight: 600;
|
|
149
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
150
|
+
border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
|
|
151
|
+
background-color: var(--colorNeutralBackground2, #fafafa);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.popoverSearch {
|
|
155
|
+
padding: 10px 12px;
|
|
156
|
+
border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
|
|
157
|
+
}
|
|
158
|
+
.popoverSearch .searchInput {
|
|
159
|
+
width: 100%;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.nativeInputWrapper {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 8px;
|
|
166
|
+
width: 100%;
|
|
167
|
+
border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
|
|
168
|
+
border-radius: var(--borderRadiusMedium, 4px);
|
|
169
|
+
background-color: var(--colorNeutralBackground1, #ffffff);
|
|
170
|
+
padding: 6px 12px;
|
|
171
|
+
min-height: 36px;
|
|
172
|
+
box-sizing: border-box;
|
|
173
|
+
}
|
|
174
|
+
.nativeInputWrapper:focus-within {
|
|
175
|
+
border-color: var(--colorBrandStroke1, #0f6cbd);
|
|
176
|
+
outline: none;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.nativeInputIcon {
|
|
180
|
+
color: var(--colorNeutralForeground3, #616161);
|
|
181
|
+
font-size: 16px;
|
|
182
|
+
flex-shrink: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.nativeInput {
|
|
186
|
+
flex: 1;
|
|
187
|
+
min-width: 0;
|
|
188
|
+
border: none;
|
|
189
|
+
outline: none;
|
|
190
|
+
padding: 0;
|
|
191
|
+
font-size: 14px;
|
|
192
|
+
font-family: inherit;
|
|
193
|
+
background: transparent;
|
|
194
|
+
color: var(--colorNeutralForeground1, #242424);
|
|
195
|
+
}
|
|
196
|
+
.nativeInput::placeholder {
|
|
197
|
+
color: var(--colorNeutralForeground4, #707070);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.resultCount {
|
|
201
|
+
margin-top: 6px;
|
|
202
|
+
font-size: 11px;
|
|
203
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.selectAllRow {
|
|
207
|
+
display: flex;
|
|
208
|
+
gap: 8px;
|
|
209
|
+
padding: 6px 12px;
|
|
210
|
+
border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
|
|
211
|
+
background-color: var(--colorNeutralBackground2, #fafafa);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.selectAllButton {
|
|
215
|
+
background: none;
|
|
216
|
+
border: none;
|
|
217
|
+
color: var(--colorBrandForeground1, #0f6cbd);
|
|
218
|
+
font-size: 12px;
|
|
219
|
+
font-weight: 500;
|
|
220
|
+
cursor: pointer;
|
|
221
|
+
padding: 4px 8px;
|
|
222
|
+
border-radius: var(--borderRadiusSmall, 4px);
|
|
223
|
+
transition: background-color 0.15s ease;
|
|
224
|
+
}
|
|
225
|
+
.selectAllButton:hover {
|
|
226
|
+
background-color: var(--colorBrandBackground2, #ebf3fc);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.popoverOptions {
|
|
230
|
+
overflow-y: auto;
|
|
231
|
+
max-height: 250px;
|
|
232
|
+
padding: 6px 0;
|
|
233
|
+
}
|
|
234
|
+
.popoverOptions::-webkit-scrollbar {
|
|
235
|
+
width: 6px;
|
|
236
|
+
}
|
|
237
|
+
.popoverOptions::-webkit-scrollbar-track {
|
|
238
|
+
background: var(--colorNeutralBackground3, #f5f5f5);
|
|
239
|
+
}
|
|
240
|
+
.popoverOptions::-webkit-scrollbar-thumb {
|
|
241
|
+
background: var(--colorNeutralStroke1, #d1d1d1);
|
|
242
|
+
border-radius: 3px;
|
|
243
|
+
}
|
|
244
|
+
.popoverOptions::-webkit-scrollbar-thumb:hover {
|
|
245
|
+
background: var(--colorNeutralForeground2, #616161);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.popoverOption {
|
|
249
|
+
padding: 4px 12px;
|
|
250
|
+
transition: background-color 0.1s ease;
|
|
251
|
+
}
|
|
252
|
+
.popoverOption:hover {
|
|
253
|
+
background-color: var(--colorNeutralBackground1Hover, #f5f5f5);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.personOption {
|
|
257
|
+
padding: 8px 12px;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
transition: background-color 0.1s ease;
|
|
260
|
+
}
|
|
261
|
+
.personOption:hover {
|
|
262
|
+
background-color: var(--colorNeutralBackground1Hover, #f5f5f5);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.loadingContainer {
|
|
266
|
+
padding: 20px;
|
|
267
|
+
text-align: center;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.noResults {
|
|
271
|
+
padding: 16px;
|
|
272
|
+
text-align: center;
|
|
273
|
+
font-size: 12px;
|
|
274
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.selectedUserSection {
|
|
278
|
+
padding: 10px 12px;
|
|
279
|
+
border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
|
|
280
|
+
background-color: var(--colorSubtleBackgroundSelected, #e0e0e0);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.selectedUserLabel {
|
|
284
|
+
font-size: 11px;
|
|
285
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
286
|
+
margin-bottom: 6px;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.selectedUser {
|
|
290
|
+
display: flex;
|
|
291
|
+
align-items: center;
|
|
292
|
+
justify-content: space-between;
|
|
293
|
+
gap: 8px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.userInfo {
|
|
297
|
+
display: flex;
|
|
298
|
+
align-items: center;
|
|
299
|
+
gap: 8px;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.userText {
|
|
303
|
+
display: flex;
|
|
304
|
+
flex-direction: column;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.userSecondary {
|
|
308
|
+
font-size: 12px;
|
|
309
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.removeUserButton {
|
|
313
|
+
display: flex;
|
|
314
|
+
align-items: center;
|
|
315
|
+
justify-content: center;
|
|
316
|
+
width: 24px;
|
|
317
|
+
height: 24px;
|
|
318
|
+
padding: 0;
|
|
319
|
+
border: none;
|
|
320
|
+
border-radius: 50%;
|
|
321
|
+
background-color: transparent;
|
|
322
|
+
color: var(--colorNeutralForeground2, #616161);
|
|
323
|
+
cursor: pointer;
|
|
324
|
+
transition: all 0.15s ease;
|
|
325
|
+
}
|
|
326
|
+
.removeUserButton:hover {
|
|
327
|
+
background-color: var(--colorNeutralBackground1Hover, #f5f5f5);
|
|
328
|
+
color: var(--colorPaletteRedForeground1, #c4314b);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.popoverActions {
|
|
332
|
+
display: flex;
|
|
333
|
+
justify-content: flex-end;
|
|
334
|
+
gap: 8px;
|
|
335
|
+
padding: 10px 12px;
|
|
336
|
+
border-top: 1px solid var(--colorNeutralStroke2, #e0e0e0);
|
|
337
|
+
background-color: var(--colorNeutralBackground2, #fafafa);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.clearButton {
|
|
341
|
+
padding: 6px 12px;
|
|
342
|
+
border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
|
|
343
|
+
border-radius: var(--borderRadiusMedium, 4px);
|
|
344
|
+
background-color: var(--colorNeutralBackground1, #ffffff);
|
|
345
|
+
color: var(--colorNeutralForeground1, #242424);
|
|
346
|
+
font-size: 12px;
|
|
347
|
+
font-weight: 500;
|
|
348
|
+
cursor: pointer;
|
|
349
|
+
transition: all 0.15s ease;
|
|
350
|
+
}
|
|
351
|
+
.clearButton:hover:not(:disabled) {
|
|
352
|
+
background-color: var(--colorNeutralBackground1Hover, #f5f5f5);
|
|
353
|
+
border-color: var(--colorNeutralStroke1Hover, #c7c7c7);
|
|
354
|
+
}
|
|
355
|
+
.clearButton:disabled {
|
|
356
|
+
opacity: 0.5;
|
|
357
|
+
cursor: not-allowed;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.applyButton {
|
|
361
|
+
padding: 6px 12px;
|
|
362
|
+
border: 1px solid var(--colorBrandBackground, #0f6cbd);
|
|
363
|
+
border-radius: var(--borderRadiusMedium, 4px);
|
|
364
|
+
background-color: var(--colorBrandBackground, #0f6cbd);
|
|
365
|
+
color: var(--colorNeutralForegroundOnBrand, #ffffff);
|
|
366
|
+
font-size: 12px;
|
|
367
|
+
font-weight: 600;
|
|
368
|
+
cursor: pointer;
|
|
369
|
+
transition: all 0.15s ease;
|
|
370
|
+
}
|
|
371
|
+
.applyButton:hover {
|
|
372
|
+
background-color: var(--colorBrandBackgroundHover, #115ea3);
|
|
373
|
+
border-color: var(--colorBrandBackgroundHover, #115ea3);
|
|
374
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Input, Checkbox, Spinner } from '@fluentui/react-components';
|
|
3
|
+
import { SearchRegular } from '@fluentui/react-icons';
|
|
4
|
+
import styles from './ColumnHeaderFilter.module.css';
|
|
5
|
+
export const MultiSelectFilterPopover = ({ searchText, onSearchChange, options, filteredOptions, selected, onOptionToggle, onSelectAll, onClearSelection, onApply, isLoading, onPopoverClick, onInputFocus, onInputMouseDown, onInputClick, onInputKeyDown, }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.popoverSearch, onClick: onPopoverClick, children: [_jsx(Input, { placeholder: "Search...", value: searchText, onChange: (e, data) => onSearchChange(data.value ?? ''), onFocus: onInputFocus, onMouseDown: onInputMouseDown, onClick: onInputClick, onKeyDown: onInputKeyDown, autoComplete: "off", className: styles.searchInput, contentBefore: _jsx(SearchRegular, {}) }), _jsxs("div", { className: styles.resultCount, children: [filteredOptions.length, " of ", options.length, " options"] })] }), _jsxs("div", { className: styles.selectAllRow, onClick: onPopoverClick, children: [_jsxs("button", { type: "button", className: styles.selectAllButton, onClick: onSelectAll, children: ["Select All (", filteredOptions.length, ")"] }), _jsx("button", { type: "button", className: styles.selectAllButton, onClick: onClearSelection, children: "Clear" })] }), _jsx("div", { className: styles.popoverOptions, onClick: onPopoverClick, children: isLoading ? (_jsx("div", { className: styles.loadingContainer, children: _jsx(Spinner, { size: "small", label: "Loading..." }) })) : filteredOptions.length === 0 ? (_jsx("div", { className: styles.noResults, children: "No options found" })) : (filteredOptions.map((option) => (_jsx("div", { className: styles.popoverOption, children: _jsx(Checkbox, { label: option, checked: selected.has(option), onChange: (ev, data) => {
|
|
6
|
+
ev.stopPropagation();
|
|
7
|
+
onOptionToggle(option, data.checked === true);
|
|
8
|
+
} }) }, option)))) }), _jsxs("div", { className: styles.popoverActions, onClick: onPopoverClick, children: [_jsx("button", { type: "button", className: styles.clearButton, onClick: onClearSelection, children: "Clear" }), _jsx("button", { type: "button", className: styles.applyButton, onClick: onApply, children: "Apply" })] })] }));
|
|
9
|
+
MultiSelectFilterPopover.displayName = 'MultiSelectFilterPopover';
|