@wso2/oxygen-ui 0.16.0 → 0.17.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/.claude/skills/oxygen-component/SKILL.md +31 -3
- package/.claude/skills/oxygen-form/SKILL.md +21 -8
- package/.claude/skills/oxygen-layout/SKILL.md +128 -35
- package/dist/components/ListingTable/ListingTable/ListingTable.d.ts +2 -1
- package/dist/components/ListingTable/index.d.ts +2 -1
- package/dist/components/ListingTable/shared/ListingTableFilter.d.ts +80 -0
- package/dist/components/ListingTable/shared/ListingTableFilterMenu.d.ts +47 -0
- package/dist/components/ListingTable/shared/index.d.ts +2 -0
- package/dist/components/TimeRangeFilter/TimeRangeFilter.d.ts +185 -0
- package/dist/components/TimeRangeFilter/index.d.ts +2 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/index.js +1219 -639
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
|
@@ -19,6 +19,34 @@ description: Generate Oxygen UI React components following best practices. Use w
|
|
|
19
19
|
- Never hardcode colors or spacing values
|
|
20
20
|
- For data tables, prefer `ListingTable` over MUI's `Table`
|
|
21
21
|
- For layouts, use `AppShell`, `Header`, `Sidebar`
|
|
22
|
+
- Write all UI text in sentence case (see below)
|
|
23
|
+
|
|
24
|
+
## UI Text
|
|
25
|
+
|
|
26
|
+
Write all titles, action text, and content in sentence case. Capitalize only the first word, proper nouns, product names, and acronyms.
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
✓ Create project ✓ API keys ✓ Last modified
|
|
30
|
+
✗ Create Project ✗ API Keys ✗ LAST MODIFIED
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Applies to titles, headings, buttons, links, menu items, tabs, labels, placeholders, table columns, tooltips, and messages
|
|
34
|
+
- Write the text in sentence case in the source; never change case with `textTransform: 'uppercase'` or `'capitalize'`
|
|
35
|
+
|
|
36
|
+
## Choosing a Table
|
|
37
|
+
|
|
38
|
+
Pick the table type by what users do with the data:
|
|
39
|
+
|
|
40
|
+
| Type | Use when | Setup |
|
|
41
|
+
|------|----------|-------|
|
|
42
|
+
| Listing table (default) | Scanning and comparing records across columns; tables inside a page section, panel, or dialog | `<ListingTable variant="table">` |
|
|
43
|
+
| Card table | Top level listing of entities users click to open (projects, components); rich rows with few columns | `<ListingTable variant="card">`, `disablePaper` on `Container`, `variant="card" hover clickable` on each `Row` |
|
|
44
|
+
| Data table | Large or server-paginated data; column filtering, resizing, hiding, reordering; bulk selection | `<ListingTable.DataGrid>` inside `ListingTable.Provider` (`variant="data-grid-card"` on the Provider only for entity listings) |
|
|
45
|
+
|
|
46
|
+
- Default to the listing table when unsure
|
|
47
|
+
- Do not nest a card table inside a card, dialog, or drawer
|
|
48
|
+
- Do not use `striped` or `bordered` with the card variant
|
|
49
|
+
- Use one table type for the same kind of data across the product
|
|
22
50
|
|
|
23
51
|
## Component Template
|
|
24
52
|
|
|
@@ -50,7 +78,7 @@ import { ListingTable, Chip, IconButton } from '@wso2/oxygen-ui';
|
|
|
50
78
|
import { EditIcon, TrashIcon } from '@wso2/oxygen-ui-icons-react';
|
|
51
79
|
|
|
52
80
|
<ListingTable.Container>
|
|
53
|
-
<ListingTable.Toolbar showSearch actions={<Button>Add
|
|
81
|
+
<ListingTable.Toolbar showSearch actions={<Button>Add item</Button>} />
|
|
54
82
|
<ListingTable variant="card">
|
|
55
83
|
<ListingTable.Head>
|
|
56
84
|
<ListingTable.Row>
|
|
@@ -83,7 +111,7 @@ import { EditIcon, TrashIcon } from '@wso2/oxygen-ui-icons-react';
|
|
|
83
111
|
import { Paper, Typography, Box, Button } from '@wso2/oxygen-ui';
|
|
84
112
|
|
|
85
113
|
<Paper sx={{ p: 3 }}>
|
|
86
|
-
<Typography variant="h6" gutterBottom>Card
|
|
114
|
+
<Typography variant="h6" gutterBottom>Card title</Typography>
|
|
87
115
|
<Typography color="text.secondary" sx={{ mb: 2 }}>
|
|
88
116
|
Card description text
|
|
89
117
|
</Typography>
|
|
@@ -107,7 +135,7 @@ import {
|
|
|
107
135
|
} from '@wso2/oxygen-ui';
|
|
108
136
|
|
|
109
137
|
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
|
110
|
-
<DialogTitle>Dialog
|
|
138
|
+
<DialogTitle>Dialog title</DialogTitle>
|
|
111
139
|
<DialogContent>
|
|
112
140
|
<DialogContentText>Dialog content goes here.</DialogContentText>
|
|
113
141
|
</DialogContent>
|
|
@@ -18,6 +18,19 @@ description: Generate forms with Form.* components and validation. Use when crea
|
|
|
18
18
|
- Use controlled components with state
|
|
19
19
|
- Show validation errors with `error` and `helperText` props
|
|
20
20
|
- Use theme tokens for spacing
|
|
21
|
+
- Write all UI text in sentence case (see below)
|
|
22
|
+
|
|
23
|
+
## UI Text
|
|
24
|
+
|
|
25
|
+
Write all titles, action text, and content in sentence case. Capitalize only the first word, proper nouns, product names, and acronyms.
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
✓ First name ✓ Create account ✓ Enter your email address
|
|
29
|
+
✗ First Name ✗ Create Account ✗ ENTER YOUR EMAIL ADDRESS
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Applies to section headers, labels, placeholders, helper text, error messages, and buttons
|
|
33
|
+
- Write the text in sentence case in the source; never change case with `textTransform: 'uppercase'` or `'capitalize'`
|
|
21
34
|
|
|
22
35
|
## Basic Form
|
|
23
36
|
|
|
@@ -95,22 +108,22 @@ function SectionedForm() {
|
|
|
95
108
|
return (
|
|
96
109
|
<Box sx={{ maxWidth: 600 }}>
|
|
97
110
|
<Form.Section>
|
|
98
|
-
<Form.Header>Personal
|
|
111
|
+
<Form.Header>Personal information</Form.Header>
|
|
99
112
|
<Form.Subheader>Enter your basic details</Form.Subheader>
|
|
100
113
|
|
|
101
114
|
<Form.Stack spacing={2}>
|
|
102
|
-
<Form.TextInput label="First
|
|
103
|
-
<Form.TextInput label="Last
|
|
115
|
+
<Form.TextInput label="First name" required />
|
|
116
|
+
<Form.TextInput label="Last name" required />
|
|
104
117
|
<Form.TextInput label="Email" type="email" required />
|
|
105
118
|
</Form.Stack>
|
|
106
119
|
</Form.Section>
|
|
107
120
|
|
|
108
121
|
<Form.Section>
|
|
109
|
-
<Form.Header>Company
|
|
122
|
+
<Form.Header>Company details</Form.Header>
|
|
110
123
|
<Form.Subheader>Optional information about your organization</Form.Subheader>
|
|
111
124
|
|
|
112
125
|
<Form.Stack spacing={2}>
|
|
113
|
-
<Form.TextInput label="Company
|
|
126
|
+
<Form.TextInput label="Company name" />
|
|
114
127
|
<Form.SelectInput label="Role">
|
|
115
128
|
<Form.MenuItem value="developer">Developer</Form.MenuItem>
|
|
116
129
|
<Form.MenuItem value="designer">Designer</Form.MenuItem>
|
|
@@ -213,7 +226,7 @@ function LoginForm() {
|
|
|
213
226
|
disabled={loading}
|
|
214
227
|
sx={{ mt: 3, mb: 2 }}
|
|
215
228
|
>
|
|
216
|
-
{loading ? 'Signing in...' : 'Sign
|
|
229
|
+
{loading ? 'Signing in...' : 'Sign in'}
|
|
217
230
|
</Button>
|
|
218
231
|
|
|
219
232
|
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
@@ -292,7 +305,7 @@ function RegistrationWizard() {
|
|
|
292
305
|
<>
|
|
293
306
|
<TextField
|
|
294
307
|
fullWidth
|
|
295
|
-
label="Full
|
|
308
|
+
label="Full name"
|
|
296
309
|
value={formData.name}
|
|
297
310
|
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
|
298
311
|
margin="normal"
|
|
@@ -399,7 +412,7 @@ function AddressForm() {
|
|
|
399
412
|
|
|
400
413
|
<TextField fullWidth label="City" margin="normal" />
|
|
401
414
|
<TextField fullWidth label="Address" margin="normal" multiline rows={2} />
|
|
402
|
-
<TextField fullWidth label="
|
|
415
|
+
<TextField fullWidth label="ZIP code" margin="normal" />
|
|
403
416
|
|
|
404
417
|
<Button variant="contained" sx={{ mt: 2 }}>
|
|
405
418
|
Save Address
|
|
@@ -19,6 +19,20 @@ description: Generate application layouts with AppShell, Header, and Sidebar. Us
|
|
|
19
19
|
- Import icons from `@wso2/oxygen-ui-icons-react`
|
|
20
20
|
- Use theme tokens for all styling
|
|
21
21
|
- Set a browser tab title on every page using `[Specific page/resource] | [Product]` (see below)
|
|
22
|
+
- Write all UI text in sentence case (see below)
|
|
23
|
+
- Group sidebar items with section titles and collapsible groups (see below)
|
|
24
|
+
|
|
25
|
+
## UI Text
|
|
26
|
+
|
|
27
|
+
Write all titles, action text, and content in sentence case. Capitalize only the first word, proper nouns, product names, and acronyms.
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
✓ User management ✓ API keys ✓ Sign out
|
|
31
|
+
✗ User Management ✗ API Keys ✗ SIGN OUT
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- Applies to page titles, headings, navigation items, sidebar categories, header actions, and menu items
|
|
35
|
+
- Write the text in sentence case in the source; never change case with `textTransform: 'uppercase'` or `'capitalize'`
|
|
22
36
|
|
|
23
37
|
## Browser Tab Title
|
|
24
38
|
|
|
@@ -31,7 +45,7 @@ Every page must set a browser tab title in this format, so users can tell tabs,
|
|
|
31
45
|
Examples:
|
|
32
46
|
|
|
33
47
|
```text
|
|
34
|
-
All
|
|
48
|
+
All projects | Acme Console
|
|
35
49
|
Environments | Acme Console
|
|
36
50
|
```
|
|
37
51
|
|
|
@@ -47,13 +61,122 @@ Environments | Acme Console
|
|
|
47
61
|
function ProjectsPage() {
|
|
48
62
|
return (
|
|
49
63
|
<>
|
|
50
|
-
<title>All
|
|
64
|
+
<title>All projects | Acme Console</title>
|
|
51
65
|
{/* page content */}
|
|
52
66
|
</>
|
|
53
67
|
);
|
|
54
68
|
}
|
|
55
69
|
```
|
|
56
70
|
|
|
71
|
+
## Side Panel Navigation
|
|
72
|
+
|
|
73
|
+
Group sidebar items with section titles and collapsible groups. Titles keep the main areas visible; collapsible groups keep the panel short as items grow.
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
Section title Main areas users need to see at a glance Sidebar.CategoryLabel
|
|
77
|
+
Collapsible group Secondary items, or a parent with sub-pages Sidebar.Item with nested Sidebar.Item children
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If users visit an item often, put it under a title. Otherwise, put it in a collapsible group.
|
|
81
|
+
|
|
82
|
+
Section titles:
|
|
83
|
+
- Keep titles short and clear; they are labels only, never clickable
|
|
84
|
+
- Limit the number of titled sections; don't give every group a title
|
|
85
|
+
|
|
86
|
+
Collapsible groups:
|
|
87
|
+
- The parent only opens and closes the group; never give it a page or a `link`
|
|
88
|
+
- Expand the group that contains the active page by default
|
|
89
|
+
- Remember each user's open and closed groups (`Sidebar` does not store this; see below)
|
|
90
|
+
- One level of nesting only; never put a collapsible group inside another
|
|
91
|
+
- Give child items icons that differ from the parent's icon
|
|
92
|
+
|
|
93
|
+
General:
|
|
94
|
+
- Put Settings, Notifications, and Help in `Sidebar.Footer`, outside the scrolling `Sidebar.Nav`
|
|
95
|
+
- Add a menu search when the panel has many items
|
|
96
|
+
- Don't mix the rules: titles never toggle, collapsible parents never navigate
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
const storageKey = `side-panel-groups:${userId}`;
|
|
100
|
+
|
|
101
|
+
const [expandedMenus, setExpandedMenus] = useState<Record<string, boolean>>({});
|
|
102
|
+
|
|
103
|
+
// Load the user's saved groups on the client, after mount (safe for SSR).
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
try {
|
|
106
|
+
const saved = JSON.parse(localStorage.getItem(storageKey) ?? '{}');
|
|
107
|
+
setExpandedMenus((prev) => ({ ...saved, ...prev }));
|
|
108
|
+
} catch {
|
|
109
|
+
// Storage is unavailable or the saved value is invalid.
|
|
110
|
+
}
|
|
111
|
+
}, [storageKey]);
|
|
112
|
+
|
|
113
|
+
// Open the group that contains the active page whenever it changes.
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (activeGroupId) {
|
|
116
|
+
setExpandedMenus((prev) => ({ ...prev, [activeGroupId]: true }));
|
|
117
|
+
}
|
|
118
|
+
}, [activeGroupId]);
|
|
119
|
+
|
|
120
|
+
const toggleExpand = (id: string) => {
|
|
121
|
+
setExpandedMenus((prev) => {
|
|
122
|
+
const next = { ...prev, [id]: !prev[id] };
|
|
123
|
+
try {
|
|
124
|
+
localStorage.setItem(storageKey, JSON.stringify(next));
|
|
125
|
+
} catch {
|
|
126
|
+
// Storage is unavailable.
|
|
127
|
+
}
|
|
128
|
+
return next;
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
<Sidebar
|
|
133
|
+
collapsed={collapsed}
|
|
134
|
+
activeItem={activeItem}
|
|
135
|
+
expandedMenus={expandedMenus}
|
|
136
|
+
onSelect={setActiveItem}
|
|
137
|
+
onToggleExpand={toggleExpand}
|
|
138
|
+
>
|
|
139
|
+
<Sidebar.Nav>
|
|
140
|
+
<Sidebar.Category>
|
|
141
|
+
<Sidebar.Item id="home">
|
|
142
|
+
<Sidebar.ItemIcon><Home size={20} /></Sidebar.ItemIcon>
|
|
143
|
+
<Sidebar.ItemLabel>Home</Sidebar.ItemLabel>
|
|
144
|
+
</Sidebar.Item>
|
|
145
|
+
</Sidebar.Category>
|
|
146
|
+
|
|
147
|
+
<Sidebar.Category>
|
|
148
|
+
<Sidebar.CategoryLabel>Build</Sidebar.CategoryLabel>
|
|
149
|
+
<Sidebar.Item id="projects">
|
|
150
|
+
<Sidebar.ItemIcon><FolderOpen size={20} /></Sidebar.ItemIcon>
|
|
151
|
+
<Sidebar.ItemLabel>Projects</Sidebar.ItemLabel>
|
|
152
|
+
</Sidebar.Item>
|
|
153
|
+
{/* Collapsible group: nest child items inside the parent */}
|
|
154
|
+
<Sidebar.Item id="developer-tools">
|
|
155
|
+
<Sidebar.ItemIcon><Wrench size={20} /></Sidebar.ItemIcon>
|
|
156
|
+
<Sidebar.ItemLabel>Developer tools</Sidebar.ItemLabel>
|
|
157
|
+
<Sidebar.Item id="api-keys">
|
|
158
|
+
<Sidebar.ItemIcon><KeyRound size={20} /></Sidebar.ItemIcon>
|
|
159
|
+
<Sidebar.ItemLabel>API keys</Sidebar.ItemLabel>
|
|
160
|
+
</Sidebar.Item>
|
|
161
|
+
<Sidebar.Item id="webhooks">
|
|
162
|
+
<Sidebar.ItemIcon><Webhook size={20} /></Sidebar.ItemIcon>
|
|
163
|
+
<Sidebar.ItemLabel>Webhooks</Sidebar.ItemLabel>
|
|
164
|
+
</Sidebar.Item>
|
|
165
|
+
</Sidebar.Item>
|
|
166
|
+
</Sidebar.Category>
|
|
167
|
+
</Sidebar.Nav>
|
|
168
|
+
|
|
169
|
+
<Sidebar.Footer>
|
|
170
|
+
<Sidebar.Category>
|
|
171
|
+
<Sidebar.Item id="settings">
|
|
172
|
+
<Sidebar.ItemIcon><Settings size={20} /></Sidebar.ItemIcon>
|
|
173
|
+
<Sidebar.ItemLabel>Settings</Sidebar.ItemLabel>
|
|
174
|
+
</Sidebar.Item>
|
|
175
|
+
</Sidebar.Category>
|
|
176
|
+
</Sidebar.Footer>
|
|
177
|
+
</Sidebar>
|
|
178
|
+
```
|
|
179
|
+
|
|
57
180
|
## Complete App Shell Layout
|
|
58
181
|
|
|
59
182
|
```tsx
|
|
@@ -80,9 +203,9 @@ import {
|
|
|
80
203
|
function ProjectsPage() {
|
|
81
204
|
return (
|
|
82
205
|
<>
|
|
83
|
-
<title>All
|
|
206
|
+
<title>All projects | My Application</title>
|
|
84
207
|
{/* Page content goes here */}
|
|
85
|
-
<h1>All
|
|
208
|
+
<h1>All projects</h1>
|
|
86
209
|
</>
|
|
87
210
|
);
|
|
88
211
|
}
|
|
@@ -216,36 +339,6 @@ export default App;
|
|
|
216
339
|
</Header>
|
|
217
340
|
```
|
|
218
341
|
|
|
219
|
-
## Sidebar with Nested Items
|
|
220
|
-
|
|
221
|
-
```tsx
|
|
222
|
-
<Sidebar
|
|
223
|
-
collapsed={collapsed}
|
|
224
|
-
activeItem={activeItem}
|
|
225
|
-
expandedMenus={expandedMenus}
|
|
226
|
-
onSelect={setActiveItem}
|
|
227
|
-
onToggleExpand={toggleExpand}
|
|
228
|
-
>
|
|
229
|
-
<Sidebar.Nav>
|
|
230
|
-
<Sidebar.Item id="parent" hasChildren>
|
|
231
|
-
<Sidebar.ItemIcon><FolderIcon size={20} /></Sidebar.ItemIcon>
|
|
232
|
-
<Sidebar.ItemLabel>Parent Item</Sidebar.ItemLabel>
|
|
233
|
-
</Sidebar.Item>
|
|
234
|
-
|
|
235
|
-
{expandedMenus['parent'] && (
|
|
236
|
-
<>
|
|
237
|
-
<Sidebar.Item id="child1" nested>
|
|
238
|
-
<Sidebar.ItemLabel>Child 1</Sidebar.ItemLabel>
|
|
239
|
-
</Sidebar.Item>
|
|
240
|
-
<Sidebar.Item id="child2" nested>
|
|
241
|
-
<Sidebar.ItemLabel>Child 2</Sidebar.ItemLabel>
|
|
242
|
-
</Sidebar.Item>
|
|
243
|
-
</>
|
|
244
|
-
)}
|
|
245
|
-
</Sidebar.Nav>
|
|
246
|
-
</Sidebar>
|
|
247
|
-
```
|
|
248
|
-
|
|
249
342
|
## Dashboard Layout with Stats
|
|
250
343
|
|
|
251
344
|
```tsx
|
|
@@ -259,7 +352,7 @@ function DashboardContent() {
|
|
|
259
352
|
<Grid container spacing={3}>
|
|
260
353
|
<Grid item xs={12} sm={6} md={3}>
|
|
261
354
|
<Paper sx={{ p: 3 }}>
|
|
262
|
-
<Typography color="text.secondary" variant="body2">Total
|
|
355
|
+
<Typography color="text.secondary" variant="body2">Total users</Typography>
|
|
263
356
|
<Typography variant="h4" fontWeight="bold">12,345</Typography>
|
|
264
357
|
</Paper>
|
|
265
358
|
</Grid>
|
|
@@ -8,7 +8,7 @@ import ListingTableFooter from './ListingTableFooter';
|
|
|
8
8
|
import ListingTableRow from './ListingTableRow';
|
|
9
9
|
import ListingTableCell from './ListingTableCell';
|
|
10
10
|
import ListingTableDataGrid from './ListingTableDataGrid';
|
|
11
|
-
import { ListingTableCellIcon, ListingTableRowActions, ListingTableEmptyState, ListingTableToolbar, ListingTableSortLabel, ListingTableDensityControl } from '../shared';
|
|
11
|
+
import { ListingTableCellIcon, ListingTableRowActions, ListingTableEmptyState, ListingTableToolbar, ListingTableSortLabel, ListingTableFilter, ListingTableDensityControl } from '../shared';
|
|
12
12
|
import { ListingTableProvider } from '../ListingTableProvider';
|
|
13
13
|
export interface ListingTableProps extends MuiTableProps {
|
|
14
14
|
/**
|
|
@@ -49,6 +49,7 @@ interface ListingTableComponent {
|
|
|
49
49
|
EmptyState: typeof ListingTableEmptyState;
|
|
50
50
|
Toolbar: typeof ListingTableToolbar;
|
|
51
51
|
SortLabel: typeof ListingTableSortLabel;
|
|
52
|
+
Filter: typeof ListingTableFilter;
|
|
52
53
|
DensityControl: typeof ListingTableDensityControl;
|
|
53
54
|
DataGrid: typeof ListingTableDataGrid;
|
|
54
55
|
}
|
|
@@ -17,7 +17,8 @@ export type { ListingTableToolbarProps } from './shared';
|
|
|
17
17
|
export type { ListingTableEmptyStateProps } from './shared';
|
|
18
18
|
export type { ListingTableDensityControlProps } from './shared';
|
|
19
19
|
export type { ListingTableSortLabelProps, ListingSortDirection } from './shared';
|
|
20
|
+
export type { ListingTableFilterProps, ListingTableFilterOption } from './shared';
|
|
20
21
|
export type { ListingTableRowActionsProps } from './shared';
|
|
21
22
|
export type { ListingTableCellIconProps } from './shared';
|
|
22
|
-
export { ListingTableToolbar, Toolbar, ListingTableEmptyState, EmptyState, ListingTableDensityControl, DensityControl, ListingTableSortLabel, SortLabel, ListingTableRowActions, RowActions, ListingTableCellIcon, CellIcon, } from './shared';
|
|
23
|
+
export { ListingTableToolbar, Toolbar, ListingTableEmptyState, EmptyState, ListingTableDensityControl, DensityControl, ListingTableSortLabel, SortLabel, ListingTableFilter, Filter, ListingTableRowActions, RowActions, ListingTableCellIcon, CellIcon, } from './shared';
|
|
23
24
|
export { ListingTableContainer, Container, ListingTableHead, Head, ListingTableBody, Body, ListingTableFooter, Footer, ListingTableRow, Row, ListingTableCell, Cell, } from './ListingTable';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import type { ListingTableFilterOption } from './ListingTableFilterMenu';
|
|
4
|
+
export type { ListingTableFilterOption };
|
|
5
|
+
/**
|
|
6
|
+
* Props for the ListingTable.Filter component. The rest of the props go to the funnel button.
|
|
7
|
+
*/
|
|
8
|
+
export interface ListingTableFilterProps extends Omit<IconButtonProps, 'onChange' | 'value' | 'children'> {
|
|
9
|
+
/**
|
|
10
|
+
* Field/column identifier for context-based filtering.
|
|
11
|
+
* When provided and used with ListingTable.Provider, the component reads the applied value from
|
|
12
|
+
* `filters[field]` and reports changes through `onFilterChange(field, value)`. The value in `filters`
|
|
13
|
+
* is the `value` of the chosen option, so it is a string; any other type counts as not applied.
|
|
14
|
+
*/
|
|
15
|
+
field?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The choices.
|
|
18
|
+
*/
|
|
19
|
+
options: ListingTableFilterOption[];
|
|
20
|
+
/**
|
|
21
|
+
* The applied value, or `null` or an empty string when the filter is not applied.
|
|
22
|
+
* When using with Provider and the field prop, this is derived from context.
|
|
23
|
+
*/
|
|
24
|
+
value?: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Called with the chosen value, or `null` when the "any" choice is picked.
|
|
27
|
+
* When using with Provider and the field prop, this is handled via context.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (value: string | null) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Adds a search field above the choices, to narrow them by typing. Without it, the choices are
|
|
32
|
+
* only picked.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
searchable?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Accessible name and tooltip of the button, for example "Filter by status".
|
|
38
|
+
* @default 'Filter'
|
|
39
|
+
*/
|
|
40
|
+
label?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Text of the choice that clears the filter.
|
|
43
|
+
* @default 'Any'
|
|
44
|
+
*/
|
|
45
|
+
allLabel?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Placeholder of the search field.
|
|
48
|
+
* @default 'Search'
|
|
49
|
+
*/
|
|
50
|
+
searchPlaceholder?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Text shown when typing matches no choice.
|
|
53
|
+
* @default 'No matches'
|
|
54
|
+
*/
|
|
55
|
+
noMatchLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Keeps the funnel visible, at half strength until the column is pointed at, instead of hiding it
|
|
58
|
+
* until then. Use it where discovering the filter matters more than a quiet heading.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
alwaysShowIcon?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* ListingTable.Filter - The filter counterpart of ListingTable.SortLabel: a funnel button for a
|
|
65
|
+
* column heading that opens the choices for that column.
|
|
66
|
+
*
|
|
67
|
+
* Put it in a header cell, next to a `ListingTable.SortLabel` if the column also sorts. A column
|
|
68
|
+
* without it has no filter, as a column without a SortLabel has no sort. The table never filters
|
|
69
|
+
* rows: the application owns the applied values and filters its own rows.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <ListingTable.Cell>
|
|
74
|
+
* <ListingTable.SortLabel field="status">Status</ListingTable.SortLabel>
|
|
75
|
+
* <ListingTable.Filter field="status" label="Filter by status" options={statusOptions} />
|
|
76
|
+
* </ListingTable.Cell>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare const ListingTableFilter: React.ForwardRefExoticComponent<Omit<ListingTableFilterProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
80
|
+
export default ListingTableFilter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* One choice of a filter list.
|
|
4
|
+
*/
|
|
5
|
+
export interface ListingTableFilterOption {
|
|
6
|
+
/**
|
|
7
|
+
* Value reported when the choice is picked. It must not be empty: an empty value means no filter is
|
|
8
|
+
* applied, so a choice with one is left out of the list. Use the "any" choice to clear the filter.
|
|
9
|
+
* Values must be unique: each one identifies its choice, so two choices with the same value could not
|
|
10
|
+
* be told apart when picked or ticked.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/** Text shown for the choice. */
|
|
14
|
+
label: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ListingTableFilterMenuProps {
|
|
17
|
+
/** Whether the list is open. */
|
|
18
|
+
open: boolean;
|
|
19
|
+
/** The element the list is placed under. */
|
|
20
|
+
anchorEl: HTMLElement | null;
|
|
21
|
+
/** Called when the list asks to close: after a choice, on Escape, and on a click outside. */
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
/** The choices. */
|
|
24
|
+
options: ListingTableFilterOption[];
|
|
25
|
+
/** The applied value, or `null` or an empty string when nothing is applied. */
|
|
26
|
+
value: string | null;
|
|
27
|
+
/** Called with the chosen value, or `null` when the "any" choice is picked. */
|
|
28
|
+
onChange: (value: string | null) => void;
|
|
29
|
+
/** Adds a search field above the choices, to narrow them by typing. */
|
|
30
|
+
searchable?: boolean;
|
|
31
|
+
/** Accessible name of the list and of the search field. */
|
|
32
|
+
label: string;
|
|
33
|
+
/** Id of the list of choices, for the `aria-controls` of the button that opens it. */
|
|
34
|
+
listId?: string;
|
|
35
|
+
/** Text of the choice that clears the filter. */
|
|
36
|
+
allLabel: string;
|
|
37
|
+
/** Placeholder of the search field. */
|
|
38
|
+
searchPlaceholder: string;
|
|
39
|
+
/** Text shown when typing matches no choice. */
|
|
40
|
+
noMatchLabel: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The list of choices of a ListingTable.Filter: an optional search field above a menu of choices,
|
|
44
|
+
* with the applied one marked. It is internal to the table: use `ListingTable.Filter`.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ListingTableFilterMenu: React.FC<ListingTableFilterMenuProps>;
|
|
47
|
+
export default ListingTableFilterMenu;
|
|
@@ -8,6 +8,8 @@ export { default as ListingTableDensityControl, ListingTableDensityControl as De
|
|
|
8
8
|
export type { ListingTableDensityControlProps } from './ListingTableDensityControl';
|
|
9
9
|
export { default as ListingTableSortLabel, ListingTableSortLabel as SortLabel } from './ListingTableSortLabel';
|
|
10
10
|
export type { ListingTableSortLabelProps, ListingSortDirection } from './ListingTableSortLabel';
|
|
11
|
+
export { default as ListingTableFilter, ListingTableFilter as Filter } from './ListingTableFilter';
|
|
12
|
+
export type { ListingTableFilterProps, ListingTableFilterOption } from './ListingTableFilter';
|
|
11
13
|
export { default as ListingTableRowActions, ListingTableRowActions as RowActions } from './ListingTableRowActions';
|
|
12
14
|
export type { ListingTableRowActionsProps } from './ListingTableRowActions';
|
|
13
15
|
export { default as ListingTableCellIcon, ListingTableCellIcon as CellIcon } from './ListingTableCellIcon';
|