@wso2/oxygen-ui 0.23.0 → 0.23.1
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/.ai/AGENTS.md +1 -0
- package/.ai/components.md +23 -16
- package/.claude/components.md +23 -16
- package/.claude/skills/oxygen-layout/SKILL.md +17 -2
- package/.claude/skills/oxygen-select/SKILL.md +32 -1
- package/dist/components/ComplexSelect/ComplexSelect.d.ts +19 -4
- package/dist/index.js +352 -248
- package/dist/index.js.map +4 -4
- package/dist/utils/omitDerivedThemeValues.d.ts +29 -0
- package/package.json +2 -2
package/.ai/AGENTS.md
CHANGED
|
@@ -24,6 +24,7 @@ function App() {
|
|
|
24
24
|
4. **MUI X uses namespaces** - `DataGrid.DataGrid`, `DatePickers.DatePicker`, `TreeView.TreeView`
|
|
25
25
|
5. **Use theme tokens** - Use `sx` prop with theme values, not hardcoded colors/spacing
|
|
26
26
|
6. **Fixed labels on inputs** - Give every labelled `TextField` and `Select` `labelPlacement="top"`; never use MUI's floating label (`InputLabel` inside `FormControl`) in new code
|
|
27
|
+
- **`ComplexSelect` is the exception** - Pass `label` and keep the default `labelAnchor` (`inside`), which puts the label inside the field above the selected value. Do not set `labelAnchor="outside"` or `"border"` in new code
|
|
27
28
|
7. **Select placeholders come from the developer** - Give every `Select` and `TextField select` a `placeholder`; ask the developer for the text instead of inventing it. Native selects (`native` or `SelectProps={{ native: true }}`) ignore `placeholder`, so put that same text in the empty option instead: `<option value="">Select a role</option>`
|
|
28
29
|
|
|
29
30
|
## Import Patterns
|
package/.ai/components.md
CHANGED
|
@@ -987,7 +987,7 @@ import { PageContent } from '@wso2/oxygen-ui';
|
|
|
987
987
|
|
|
988
988
|
## ComplexSelect
|
|
989
989
|
|
|
990
|
-
|
|
990
|
+
Select with rich options: icons, avatars, two-line text, list headers and dividers. Built on the MUI `Select`, so it accepts the `Select` props. Use it for the organization and project switchers in `Header.Switchers`.
|
|
991
991
|
|
|
992
992
|
```tsx
|
|
993
993
|
import { ComplexSelect } from '@wso2/oxygen-ui';
|
|
@@ -997,27 +997,34 @@ import { ComplexSelect } from '@wso2/oxygen-ui';
|
|
|
997
997
|
|
|
998
998
|
| Prop | Type | Default | Description |
|
|
999
999
|
|------|------|---------|-------------|
|
|
1000
|
-
| `
|
|
1001
|
-
| `
|
|
1002
|
-
| `
|
|
1003
|
-
| `
|
|
1004
|
-
| `
|
|
1000
|
+
| `label` | `ReactNode` | - | Field label. Names the combobox |
|
|
1001
|
+
| `labelAnchor` | `'inside' \| 'outside' \| 'border'` | `'inside'` | Where the label sits. Keep the default in new code; `outside` and `border` are for existing screens only |
|
|
1002
|
+
| `size` | `'small' \| 'medium'` | `'small'` | Field size. A theme can change it with `components.MuiComplexSelect.defaultProps.size` |
|
|
1003
|
+
| `value` | `unknown` | - | Selected value |
|
|
1004
|
+
| `onChange` | `(event) => void` | - | Change handler |
|
|
1005
|
+
| `children` | `ReactNode` | required | `ComplexSelect.MenuItem`, `ComplexSelect.ListHeader` and `ComplexSelect.Divider` |
|
|
1006
|
+
|
|
1007
|
+
Sub-components: `ComplexSelect.MenuItem`, `ComplexSelect.MenuItem.Icon`, `ComplexSelect.MenuItem.Avatar`, `ComplexSelect.MenuItem.Text` (`primary`, `secondary`), `ComplexSelect.ListHeader`, `ComplexSelect.Divider`.
|
|
1005
1008
|
|
|
1006
1009
|
### Usage
|
|
1007
1010
|
|
|
1008
1011
|
```tsx
|
|
1009
|
-
<ComplexSelect
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
onChange={setCountry}
|
|
1017
|
-
searchable
|
|
1018
|
-
/>
|
|
1012
|
+
<ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
|
|
1013
|
+
<ComplexSelect.ListHeader>Organizations</ComplexSelect.ListHeader>
|
|
1014
|
+
<ComplexSelect.MenuItem value="acme">
|
|
1015
|
+
<ComplexSelect.MenuItem.Avatar>A</ComplexSelect.MenuItem.Avatar>
|
|
1016
|
+
<ComplexSelect.MenuItem.Text primary="Acme Corp" secondary="Owner" />
|
|
1017
|
+
</ComplexSelect.MenuItem>
|
|
1018
|
+
</ComplexSelect>
|
|
1019
1019
|
```
|
|
1020
1020
|
|
|
1021
|
+
### Label
|
|
1022
|
+
|
|
1023
|
+
- With the default `labelAnchor`, `inside`, the label sits inside the field above the selected value. The field keeps the option's icon or avatar and hides its secondary text. It is 48px tall, so it fits the 64px `Header`.
|
|
1024
|
+
- Pass `label` and do not set `labelAnchor`. Do not wrap it in `FormControl` or add an `InputLabel`, `FormLabel` or `labelPlacement`.
|
|
1025
|
+
- Without a visible label, name it with `slotProps={{ input: { 'aria-label': 'Organization' } }}`.
|
|
1026
|
+
- For a chain of levels in the Header, use `ContextSwitcher`, which draws each level as a `ComplexSelect` with the label inside.
|
|
1027
|
+
|
|
1021
1028
|
---
|
|
1022
1029
|
|
|
1023
1030
|
## NotificationBanner
|
package/.claude/components.md
CHANGED
|
@@ -987,7 +987,7 @@ import { PageContent } from '@wso2/oxygen-ui';
|
|
|
987
987
|
|
|
988
988
|
## ComplexSelect
|
|
989
989
|
|
|
990
|
-
|
|
990
|
+
Select with rich options: icons, avatars, two-line text, list headers and dividers. Built on the MUI `Select`, so it accepts the `Select` props. Use it for the organization and project switchers in `Header.Switchers`.
|
|
991
991
|
|
|
992
992
|
```tsx
|
|
993
993
|
import { ComplexSelect } from '@wso2/oxygen-ui';
|
|
@@ -997,27 +997,34 @@ import { ComplexSelect } from '@wso2/oxygen-ui';
|
|
|
997
997
|
|
|
998
998
|
| Prop | Type | Default | Description |
|
|
999
999
|
|------|------|---------|-------------|
|
|
1000
|
-
| `
|
|
1001
|
-
| `
|
|
1002
|
-
| `
|
|
1003
|
-
| `
|
|
1004
|
-
| `
|
|
1000
|
+
| `label` | `ReactNode` | - | Field label. Names the combobox |
|
|
1001
|
+
| `labelAnchor` | `'inside' \| 'outside' \| 'border'` | `'inside'` | Where the label sits. Keep the default in new code; `outside` and `border` are for existing screens only |
|
|
1002
|
+
| `size` | `'small' \| 'medium'` | `'small'` | Field size. A theme can change it with `components.MuiComplexSelect.defaultProps.size` |
|
|
1003
|
+
| `value` | `unknown` | - | Selected value |
|
|
1004
|
+
| `onChange` | `(event) => void` | - | Change handler |
|
|
1005
|
+
| `children` | `ReactNode` | required | `ComplexSelect.MenuItem`, `ComplexSelect.ListHeader` and `ComplexSelect.Divider` |
|
|
1006
|
+
|
|
1007
|
+
Sub-components: `ComplexSelect.MenuItem`, `ComplexSelect.MenuItem.Icon`, `ComplexSelect.MenuItem.Avatar`, `ComplexSelect.MenuItem.Text` (`primary`, `secondary`), `ComplexSelect.ListHeader`, `ComplexSelect.Divider`.
|
|
1005
1008
|
|
|
1006
1009
|
### Usage
|
|
1007
1010
|
|
|
1008
1011
|
```tsx
|
|
1009
|
-
<ComplexSelect
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
onChange={setCountry}
|
|
1017
|
-
searchable
|
|
1018
|
-
/>
|
|
1012
|
+
<ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
|
|
1013
|
+
<ComplexSelect.ListHeader>Organizations</ComplexSelect.ListHeader>
|
|
1014
|
+
<ComplexSelect.MenuItem value="acme">
|
|
1015
|
+
<ComplexSelect.MenuItem.Avatar>A</ComplexSelect.MenuItem.Avatar>
|
|
1016
|
+
<ComplexSelect.MenuItem.Text primary="Acme Corp" secondary="Owner" />
|
|
1017
|
+
</ComplexSelect.MenuItem>
|
|
1018
|
+
</ComplexSelect>
|
|
1019
1019
|
```
|
|
1020
1020
|
|
|
1021
|
+
### Label
|
|
1022
|
+
|
|
1023
|
+
- With the default `labelAnchor`, `inside`, the label sits inside the field above the selected value. The field keeps the option's icon or avatar and hides its secondary text. It is 48px tall, so it fits the 64px `Header`.
|
|
1024
|
+
- Pass `label` and do not set `labelAnchor`. Do not wrap it in `FormControl` or add an `InputLabel`, `FormLabel` or `labelPlacement`.
|
|
1025
|
+
- Without a visible label, name it with `slotProps={{ input: { 'aria-label': 'Organization' } }}`.
|
|
1026
|
+
- For a chain of levels in the Header, use `ContextSwitcher`, which draws each level as a `ComplexSelect` with the label inside.
|
|
1027
|
+
|
|
1021
1028
|
---
|
|
1022
1029
|
|
|
1023
1030
|
## NotificationBanner
|
|
@@ -311,8 +311,21 @@ export default App;
|
|
|
311
311
|
</Header.Brand>
|
|
312
312
|
|
|
313
313
|
<Header.Switchers>
|
|
314
|
-
<
|
|
315
|
-
|
|
314
|
+
<ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
|
|
315
|
+
{organizations.map((o) => (
|
|
316
|
+
<ComplexSelect.MenuItem key={o.id} value={o.id}>
|
|
317
|
+
<ComplexSelect.MenuItem.Avatar>{o.initial}</ComplexSelect.MenuItem.Avatar>
|
|
318
|
+
<ComplexSelect.MenuItem.Text primary={o.name} secondary={o.role} />
|
|
319
|
+
</ComplexSelect.MenuItem>
|
|
320
|
+
))}
|
|
321
|
+
</ComplexSelect>
|
|
322
|
+
<ComplexSelect label="Project" value={project} onChange={(e) => setProject(e.target.value as string)}>
|
|
323
|
+
{projects.map((p) => (
|
|
324
|
+
<ComplexSelect.MenuItem key={p.id} value={p.id}>
|
|
325
|
+
<ComplexSelect.MenuItem.Text primary={p.name} />
|
|
326
|
+
</ComplexSelect.MenuItem>
|
|
327
|
+
))}
|
|
328
|
+
</ComplexSelect>
|
|
316
329
|
</Header.Switchers>
|
|
317
330
|
|
|
318
331
|
<Header.Spacer />
|
|
@@ -326,6 +339,8 @@ export default App;
|
|
|
326
339
|
</Header>
|
|
327
340
|
```
|
|
328
341
|
|
|
342
|
+
Switchers use `ComplexSelect` with a `label` and the default `labelAnchor`, `inside`: the label sits inside the field above the selected value. Do not set `labelAnchor`; `outside` and `border` are for existing screens only, and they make the field too tall for the 64px Header. Keep the default `size` (`small`); the field is 48px tall. For a chain of levels (organization, project, component), use `ContextSwitcher` instead, which draws each level the same way. See the `oxygen-select` skill.
|
|
343
|
+
|
|
329
344
|
## Minimal Header (No Switchers)
|
|
330
345
|
|
|
331
346
|
```tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: oxygen-select
|
|
3
|
-
description: Use the Oxygen UI Select with a fixed label above the field instead of MUI's floating label, and a placeholder the developer provides. Use when adding or editing any Select, dropdown, or picker built on Select, or when converting FormControl + InputLabel + Select code to fixed labels.
|
|
3
|
+
description: Use the Oxygen UI Select with a fixed label above the field instead of MUI's floating label, and a placeholder the developer provides. Use ComplexSelect with its default inside label. Use when adding or editing any Select, ComplexSelect, dropdown, or picker built on Select, or when converting FormControl + InputLabel + Select code to fixed labels.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Fixed-Label Select
|
|
@@ -92,6 +92,37 @@ Suggestions follow these rules:
|
|
|
92
92
|
- `placeholder` shows text in the field while nothing is selected (an empty value: `''`, `null`, `undefined` or `[]`), in the secondary text colour so it meets contrast requirements. It works with a custom `renderValue`. Native selects ignore it, so give them an empty option with the developer's placeholder text instead: `<option value="">Select a role</option>`.
|
|
93
93
|
- Without a `label`, the prop has no effect and the select renders as a plain MUI `Select`.
|
|
94
94
|
|
|
95
|
+
## ComplexSelect: keep the label inside
|
|
96
|
+
|
|
97
|
+
`ComplexSelect` (rich options with icons, avatars and list headers, such as the organization and project switchers in `Header.Switchers`) follows a different rule from `Select`. Its label sits inside the field, above the selected value. This is the default `labelAnchor`, `inside`.
|
|
98
|
+
|
|
99
|
+
1. Pass `label` and do not set `labelAnchor`. The default is `inside`.
|
|
100
|
+
2. Do not use `labelAnchor="outside"` or `labelAnchor="border"` in new code. They are kept for existing screens only. When you edit a `ComplexSelect` that sets either, ask the developer before changing it, as the field's height changes.
|
|
101
|
+
3. Do not add `labelPlacement`, `FormControl`, `InputLabel` or a `FormLabel` around it. `ComplexSelect` draws and links its own label.
|
|
102
|
+
4. Do not add your own `aria-label` when a label is set. The label names the combobox.
|
|
103
|
+
5. Leave `size` at its default, `small`. With the label inside, the field is 48px tall and fits the 64px `Header` with 8px above and below.
|
|
104
|
+
6. For a chain of levels in the Header (organization, then project, then component), use `ContextSwitcher`, which draws each level as a `ComplexSelect` with the label inside.
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import { ComplexSelect } from '@wso2/oxygen-ui';
|
|
108
|
+
|
|
109
|
+
<ComplexSelect label="Organization" value={org} onChange={(e) => setOrg(e.target.value as string)}>
|
|
110
|
+
<ComplexSelect.MenuItem value="acme">
|
|
111
|
+
<ComplexSelect.MenuItem.Avatar>A</ComplexSelect.MenuItem.Avatar>
|
|
112
|
+
<ComplexSelect.MenuItem.Text primary="Acme Corp" secondary="Owner" />
|
|
113
|
+
</ComplexSelect.MenuItem>
|
|
114
|
+
</ComplexSelect>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The field shows the label, then the selected option with its icon or avatar. Secondary text appears only in the open list.
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
✓ <ComplexSelect label="Organization" …> label inside, the default
|
|
121
|
+
✗ <ComplexSelect label="Organization" labelAnchor="outside" …> existing screens only
|
|
122
|
+
✗ <ComplexSelect label="Organization" labelAnchor="border" …> existing screens only
|
|
123
|
+
✗ <ComplexSelect slotProps={{ input: { 'aria-label': 'Organization' } }} …> hidden name where a visible label fits
|
|
124
|
+
```
|
|
125
|
+
|
|
95
126
|
## Selects with no visible label
|
|
96
127
|
|
|
97
128
|
Some selects have no visible label, such as a sort or page-size picker in a toolbar. Omit `label`, give the select an accessible name, and still ask the developer for a placeholder if the select can be empty:
|
|
@@ -7,14 +7,29 @@ export interface ComplexSelectProps extends Omit<SelectProps, 'children'> {
|
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
/**
|
|
9
9
|
* The anchor position of the label when provided.
|
|
10
|
-
* - '
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* - 'inside' (default): Label appears inside the select field above the selected value.
|
|
11
|
+
* Icons are preserved but secondary text is automatically hidden for a cleaner, more compact display.
|
|
12
|
+
* - 'outside': Label appears above the select
|
|
13
13
|
* - 'border': Label appears on the border (MUI standard behavior)
|
|
14
|
+
* @default 'inside'
|
|
14
15
|
*/
|
|
15
16
|
labelAnchor?: 'outside' | 'inside' | 'border';
|
|
17
|
+
/**
|
|
18
|
+
* The size of the field. Defaults to `small`, whatever the theme sets for `Select`, so
|
|
19
|
+
* switchers fit the Header. A theme can change it with
|
|
20
|
+
* `components.MuiComplexSelect.defaultProps.size`.
|
|
21
|
+
* @default 'small'
|
|
22
|
+
*/
|
|
23
|
+
size?: SelectProps['size'];
|
|
16
24
|
}
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Select with rich options: icons, avatars, two-line text, list headers and dividers.
|
|
27
|
+
*
|
|
28
|
+
* With a `label` and the default `labelAnchor` (`inside`), the label is drawn inside the field
|
|
29
|
+
* above the selected value and names the combobox through a visually hidden element. Without a
|
|
30
|
+
* label, pass a name through `slotProps.input['aria-label']`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ComplexSelect(inProps: ComplexSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
18
33
|
interface ComplexSelectComponent {
|
|
19
34
|
(props: ComplexSelectProps): ReactElement;
|
|
20
35
|
ListHeader: typeof ComplexSelectListHeader;
|