@wso2/oxygen-ui 0.15.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 +170 -33
- package/dist/components/Header/HeaderToggle.d.ts +2 -2
- package/dist/components/ListingTable/ListingTable/ListingTable.d.ts +2 -1
- package/dist/components/ListingTable/ListingTable/ListingTableBody.d.ts +14 -2
- 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/RelativeTime/RelativeTime.d.ts +61 -0
- package/dist/components/RelativeTime/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 +5 -1
- package/dist/index.js +1412 -718
- 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
|
|
@@ -18,6 +18,164 @@ description: Generate application layouts with AppShell, Header, and Sidebar. Us
|
|
|
18
18
|
- Use compound component pattern for `AppShell`, `Header`, `Sidebar`
|
|
19
19
|
- Import icons from `@wso2/oxygen-ui-icons-react`
|
|
20
20
|
- Use theme tokens for all styling
|
|
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'`
|
|
36
|
+
|
|
37
|
+
## Browser Tab Title
|
|
38
|
+
|
|
39
|
+
Every page must set a browser tab title in this format, so users can tell tabs, bookmarks, and history entries apart. Render a React 19 `<title>` element in the page component rather than assigning `document.title`:
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
[Specific page/resource] | [Product]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
All projects | Acme Console
|
|
49
|
+
Environments | Acme Console
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- Put the specific page or resource first and the product name last
|
|
53
|
+
- Separate them with ` | ` (space, pipe, space)
|
|
54
|
+
- Use the same product name on every page
|
|
55
|
+
- On the product home or landing page, use the product name only: `Acme Console`
|
|
56
|
+
- For nested resources, go from most to least specific: `Environments | Payments API | Acme Console`
|
|
57
|
+
- For dynamic names, use the resource name once it loads; until then show the page type (`Project | Acme Console`), never `Loading...`
|
|
58
|
+
- On error pages, name the error: `Page Not Found | Acme Console`
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
function ProjectsPage() {
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
<title>All projects | Acme Console</title>
|
|
65
|
+
{/* page content */}
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
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
|
+
```
|
|
21
179
|
|
|
22
180
|
## Complete App Shell Layout
|
|
23
181
|
|
|
@@ -42,6 +200,16 @@ import {
|
|
|
42
200
|
FileIcon,
|
|
43
201
|
} from '@wso2/oxygen-ui-icons-react';
|
|
44
202
|
|
|
203
|
+
function ProjectsPage() {
|
|
204
|
+
return (
|
|
205
|
+
<>
|
|
206
|
+
<title>All projects | My Application</title>
|
|
207
|
+
{/* Page content goes here */}
|
|
208
|
+
<h1>All projects</h1>
|
|
209
|
+
</>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
45
213
|
function App() {
|
|
46
214
|
const [collapsed, setCollapsed] = useState(false);
|
|
47
215
|
const [activeItem, setActiveItem] = useState('home');
|
|
@@ -116,8 +284,7 @@ function App() {
|
|
|
116
284
|
|
|
117
285
|
<AppShell.Main>
|
|
118
286
|
<Box sx={{ p: 3 }}>
|
|
119
|
-
|
|
120
|
-
<h1>Welcome</h1>
|
|
287
|
+
<ProjectsPage />
|
|
121
288
|
</Box>
|
|
122
289
|
</AppShell.Main>
|
|
123
290
|
|
|
@@ -172,36 +339,6 @@ export default App;
|
|
|
172
339
|
</Header>
|
|
173
340
|
```
|
|
174
341
|
|
|
175
|
-
## Sidebar with Nested Items
|
|
176
|
-
|
|
177
|
-
```tsx
|
|
178
|
-
<Sidebar
|
|
179
|
-
collapsed={collapsed}
|
|
180
|
-
activeItem={activeItem}
|
|
181
|
-
expandedMenus={expandedMenus}
|
|
182
|
-
onSelect={setActiveItem}
|
|
183
|
-
onToggleExpand={toggleExpand}
|
|
184
|
-
>
|
|
185
|
-
<Sidebar.Nav>
|
|
186
|
-
<Sidebar.Item id="parent" hasChildren>
|
|
187
|
-
<Sidebar.ItemIcon><FolderIcon size={20} /></Sidebar.ItemIcon>
|
|
188
|
-
<Sidebar.ItemLabel>Parent Item</Sidebar.ItemLabel>
|
|
189
|
-
</Sidebar.Item>
|
|
190
|
-
|
|
191
|
-
{expandedMenus['parent'] && (
|
|
192
|
-
<>
|
|
193
|
-
<Sidebar.Item id="child1" nested>
|
|
194
|
-
<Sidebar.ItemLabel>Child 1</Sidebar.ItemLabel>
|
|
195
|
-
</Sidebar.Item>
|
|
196
|
-
<Sidebar.Item id="child2" nested>
|
|
197
|
-
<Sidebar.ItemLabel>Child 2</Sidebar.ItemLabel>
|
|
198
|
-
</Sidebar.Item>
|
|
199
|
-
</>
|
|
200
|
-
)}
|
|
201
|
-
</Sidebar.Nav>
|
|
202
|
-
</Sidebar>
|
|
203
|
-
```
|
|
204
|
-
|
|
205
342
|
## Dashboard Layout with Stats
|
|
206
343
|
|
|
207
344
|
```tsx
|
|
@@ -215,7 +352,7 @@ function DashboardContent() {
|
|
|
215
352
|
<Grid container spacing={3}>
|
|
216
353
|
<Grid item xs={12} sm={6} md={3}>
|
|
217
354
|
<Paper sx={{ p: 3 }}>
|
|
218
|
-
<Typography color="text.secondary" variant="body2">Total
|
|
355
|
+
<Typography color="text.secondary" variant="body2">Total users</Typography>
|
|
219
356
|
<Typography variant="h4" fontWeight="bold">12,345</Typography>
|
|
220
357
|
</Paper>
|
|
221
358
|
</Grid>
|
|
@@ -39,11 +39,11 @@ export interface HeaderToggleProps {
|
|
|
39
39
|
/**
|
|
40
40
|
* HeaderToggle - Sidebar toggle button for the header.
|
|
41
41
|
*
|
|
42
|
-
* Displays
|
|
42
|
+
* Displays a hamburger icon; state is conveyed via tooltip and `aria-expanded`
|
|
43
43
|
* and toggles between expanded/collapsed states.
|
|
44
44
|
*
|
|
45
45
|
* Custom icons can be provided via `expandIcon` and `collapseIcon` props.
|
|
46
|
-
* Defaults
|
|
46
|
+
* Defaults to `Menu` in both states.
|
|
47
47
|
*
|
|
48
48
|
* Theme tokens used:
|
|
49
49
|
* - `text.secondary` - Icon color
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { TableBodyProps as MuiTableBodyProps } from '@mui/material/TableBody';
|
|
3
3
|
export interface ListingTableBodyProps extends MuiTableBodyProps {
|
|
4
|
+
/** Active search query; falls back to the ListingTable.Provider value */
|
|
5
|
+
searchValue?: string;
|
|
6
|
+
/** Skips the no-results state while data is loading; falls back to the ListingTable.Provider value */
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
/** @default 'No results found' */
|
|
9
|
+
noSearchResultsText?: string;
|
|
10
|
+
/** @default 'Try a different keyword' */
|
|
11
|
+
noSearchResultsDescription?: string;
|
|
12
|
+
/** @default <Search /> */
|
|
13
|
+
noSearchResultsIcon?: ReactNode;
|
|
14
|
+
/** @default 1000 */
|
|
15
|
+
emptyStateColSpan?: number;
|
|
4
16
|
}
|
|
5
|
-
export declare function ListingTableBody({ children, ...props }: ListingTableBodyProps): ReactElement;
|
|
17
|
+
export declare function ListingTableBody({ children, searchValue, loading, noSearchResultsText, noSearchResultsDescription, noSearchResultsIcon, emptyStateColSpan, ...props }: ListingTableBodyProps): ReactElement;
|
|
6
18
|
export default ListingTableBody;
|
|
@@ -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';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the RelativeTime component
|
|
5
|
+
*/
|
|
6
|
+
export interface RelativeTimeProps {
|
|
7
|
+
/**
|
|
8
|
+
* The relative time text to display, provided by the consumer (e.g. "3 weeks ago").
|
|
9
|
+
*/
|
|
10
|
+
time: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Optional operation shown before the time (e.g. "Created", "Updated", "Deleted").
|
|
13
|
+
*/
|
|
14
|
+
action?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Machine-readable date/time for the `<time>` element (e.g. an ISO 8601 string).
|
|
17
|
+
*/
|
|
18
|
+
dateTime?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional tooltip content, typically the full absolute date.
|
|
21
|
+
*/
|
|
22
|
+
tooltip?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Custom icon. Defaults to a clock icon.
|
|
25
|
+
*/
|
|
26
|
+
icon?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Hides the icon.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
hideIcon?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Size of the text and icon.
|
|
34
|
+
* @default 'medium'
|
|
35
|
+
*/
|
|
36
|
+
size?: 'small' | 'medium';
|
|
37
|
+
/**
|
|
38
|
+
* Custom styles for the root element.
|
|
39
|
+
*/
|
|
40
|
+
sx?: SxProps<Theme>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* RelativeTime component - Displays a clock icon with an optional action and a relative time
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <RelativeTime time="3 weeks ago" />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <RelativeTime
|
|
53
|
+
* action="Updated"
|
|
54
|
+
* time="5 minutes ago"
|
|
55
|
+
* dateTime="2026-10-08T09:15:00Z"
|
|
56
|
+
* tooltip="October 8, 2026, 9:15 AM"
|
|
57
|
+
* />
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare const RelativeTime: React.FC<RelativeTimeProps>;
|
|
61
|
+
export default RelativeTime;
|