@robzepdev/trama 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +44 -3
- package/dist/AGENTS.md +19 -0
- package/dist/components/button.d.mts +30 -0
- package/dist/components/button.mjs +32 -0
- package/dist/components/card.d.mts +19 -0
- package/dist/components/card.mjs +77 -0
- package/dist/components/checkbox.d.mts +13 -0
- package/dist/components/checkbox.mjs +33 -0
- package/dist/components/dialog.d.mts +25 -0
- package/dist/components/dialog.mjs +97 -0
- package/dist/components/field.d.mts +18 -0
- package/dist/components/field.mjs +41 -0
- package/dist/components/input.d.mts +4 -0
- package/dist/components/input.mjs +14 -0
- package/dist/components/menu.d.mts +22 -0
- package/dist/components/menu.mjs +89 -0
- package/dist/components/select.d.mts +25 -0
- package/dist/components/select.mjs +127 -0
- package/dist/components/stack.d.mts +48 -0
- package/dist/components/stack.mjs +196 -0
- package/dist/components/text.d.mts +25 -0
- package/dist/components/text.mjs +81 -0
- package/dist/components/toast.d.mts +15 -0
- package/dist/components/toast.mjs +49 -0
- package/dist/docs/button.md +84 -0
- package/dist/docs/card-content.md +41 -0
- package/dist/docs/card-description.md +41 -0
- package/dist/docs/card-footer.md +41 -0
- package/dist/docs/card-header.md +41 -0
- package/dist/docs/card-title.md +41 -0
- package/dist/docs/card.md +41 -0
- package/dist/docs/checkbox.md +142 -0
- package/dist/docs/dialog-close.md +53 -0
- package/dist/docs/dialog-content.md +70 -0
- package/dist/docs/dialog-description.md +46 -0
- package/dist/docs/dialog-footer.md +28 -0
- package/dist/docs/dialog-header.md +28 -0
- package/dist/docs/dialog-title.md +46 -0
- package/dist/docs/dialog-trigger.md +70 -0
- package/dist/docs/dialog.md +100 -0
- package/dist/docs/field-description.md +69 -0
- package/dist/docs/field-error.md +77 -0
- package/dist/docs/field-label.md +77 -0
- package/dist/docs/field.md +128 -0
- package/dist/docs/index.md +41 -0
- package/dist/docs/input.md +46 -0
- package/dist/docs/menu-content.md +95 -0
- package/dist/docs/menu-group.md +51 -0
- package/dist/docs/menu-item.md +79 -0
- package/dist/docs/menu-label.md +46 -0
- package/dist/docs/menu-separator.md +51 -0
- package/dist/docs/menu-trigger.md +93 -0
- package/dist/docs/menu.md +135 -0
- package/dist/docs/select-content.md +91 -0
- package/dist/docs/select-group.md +46 -0
- package/dist/docs/select-item.md +75 -0
- package/dist/docs/select-label.md +46 -0
- package/dist/docs/select-separator.md +51 -0
- package/dist/docs/select-trigger.md +63 -0
- package/dist/docs/select-value.md +59 -0
- package/dist/docs/select.md +164 -0
- package/dist/docs/stack.md +58 -0
- package/dist/docs/text.md +60 -0
- package/dist/docs/toast-provider.md +34 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +12 -0
- package/dist/lib/cn.mjs +9 -0
- package/dist/lib/responsive.d.mts +4 -0
- package/dist/lib/responsive.mjs +17 -0
- package/package.json +67 -3
- package/styles.css +67 -0
- package/themes/brutalista.css +36 -0
- package/themes/neon.css +37 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# MenuItem
|
|
2
|
+
|
|
3
|
+
One action. `onClick` runs when it is activated; the menu then closes.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { MenuItem } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `className`
|
|
14
|
+
Type: `string | ((state: MenuItemState) => string | undefined) | undefined`
|
|
15
|
+
|
|
16
|
+
CSS class applied to the element, or a function that
|
|
17
|
+
returns a class based on the component's state.
|
|
18
|
+
|
|
19
|
+
### `closeOnClick`
|
|
20
|
+
Type: `boolean | undefined`, default: true
|
|
21
|
+
|
|
22
|
+
Whether to close the menu when the item is clicked.
|
|
23
|
+
|
|
24
|
+
### `disabled`
|
|
25
|
+
Type: `boolean | undefined`, default: false
|
|
26
|
+
|
|
27
|
+
Whether the component should ignore user interaction.
|
|
28
|
+
|
|
29
|
+
### `id`
|
|
30
|
+
Type: `string | undefined`
|
|
31
|
+
|
|
32
|
+
No description.
|
|
33
|
+
|
|
34
|
+
### `label`
|
|
35
|
+
Type: `string | undefined`
|
|
36
|
+
|
|
37
|
+
Overrides the text used for keyboard text navigation and filtering.
|
|
38
|
+
Falls back to the rendered text when not provided.
|
|
39
|
+
|
|
40
|
+
### `nativeButton`
|
|
41
|
+
Type: `boolean | undefined`, default: false
|
|
42
|
+
|
|
43
|
+
Whether the component renders a native `<button>` element when replacing it
|
|
44
|
+
via the `render` prop.
|
|
45
|
+
Set to `true` if the rendered element is a native button.
|
|
46
|
+
|
|
47
|
+
### `onClick`
|
|
48
|
+
Type: `((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined`
|
|
49
|
+
|
|
50
|
+
The click handler for the menu item.
|
|
51
|
+
|
|
52
|
+
### `render`
|
|
53
|
+
Type: `ComponentRenderFn<HTMLProps, MenuItemState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
54
|
+
|
|
55
|
+
Allows you to replace the component's HTML element
|
|
56
|
+
with a different tag, or compose it with another component.
|
|
57
|
+
|
|
58
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
59
|
+
|
|
60
|
+
### `style`
|
|
61
|
+
Type: `CSSProperties | ((state: MenuItemState) => CSSProperties | undefined) | undefined`
|
|
62
|
+
|
|
63
|
+
Style applied to the element, or a function that
|
|
64
|
+
returns a style object based on the component's state.
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
export const InThemedSubtree: Story = {
|
|
70
|
+
args: { defaultOpen: true },
|
|
71
|
+
render: (args) => (
|
|
72
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
73
|
+
<div className="bg-background p-4 text-foreground">
|
|
74
|
+
<Actions {...args} />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
),
|
|
78
|
+
};
|
|
79
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# MenuLabel
|
|
2
|
+
|
|
3
|
+
Label of a `MenuGroup`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { MenuLabel } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `className`
|
|
14
|
+
Type: `string | ((state: MenuGroupLabelState) => string | undefined) | undefined`
|
|
15
|
+
|
|
16
|
+
CSS class applied to the element, or a function that
|
|
17
|
+
returns a class based on the component's state.
|
|
18
|
+
|
|
19
|
+
### `render`
|
|
20
|
+
Type: `ComponentRenderFn<HTMLProps, MenuGroupLabelState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
21
|
+
|
|
22
|
+
Allows you to replace the component's HTML element
|
|
23
|
+
with a different tag, or compose it with another component.
|
|
24
|
+
|
|
25
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
26
|
+
|
|
27
|
+
### `style`
|
|
28
|
+
Type: `CSSProperties | ((state: MenuGroupLabelState) => CSSProperties | undefined) | undefined`
|
|
29
|
+
|
|
30
|
+
Style applied to the element, or a function that
|
|
31
|
+
returns a style object based on the component's state.
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
export const InThemedSubtree: Story = {
|
|
37
|
+
args: { defaultOpen: true },
|
|
38
|
+
render: (args) => (
|
|
39
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
40
|
+
<div className="bg-background p-4 text-foreground">
|
|
41
|
+
<Actions {...args} />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# MenuSeparator
|
|
2
|
+
|
|
3
|
+
Line between items or groups.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { MenuSeparator } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `className`
|
|
14
|
+
Type: `string | ((state: SeparatorState) => string | undefined) | undefined`
|
|
15
|
+
|
|
16
|
+
CSS class applied to the element, or a function that
|
|
17
|
+
returns a class based on the component's state.
|
|
18
|
+
|
|
19
|
+
### `orientation`
|
|
20
|
+
Type: `Orientation | undefined`, default: 'horizontal'
|
|
21
|
+
|
|
22
|
+
The orientation of the separator.
|
|
23
|
+
|
|
24
|
+
### `render`
|
|
25
|
+
Type: `ComponentRenderFn<HTMLProps, SeparatorState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
26
|
+
|
|
27
|
+
Allows you to replace the component's HTML element
|
|
28
|
+
with a different tag, or compose it with another component.
|
|
29
|
+
|
|
30
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
31
|
+
|
|
32
|
+
### `style`
|
|
33
|
+
Type: `CSSProperties | ((state: SeparatorState) => CSSProperties | undefined) | undefined`
|
|
34
|
+
|
|
35
|
+
Style applied to the element, or a function that
|
|
36
|
+
returns a style object based on the component's state.
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
export const InThemedSubtree: Story = {
|
|
42
|
+
args: { defaultOpen: true },
|
|
43
|
+
render: (args) => (
|
|
44
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
45
|
+
<div className="bg-background p-4 text-foreground">
|
|
46
|
+
<Actions {...args} />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# MenuTrigger
|
|
2
|
+
|
|
3
|
+
Button that opens the menu.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { MenuTrigger } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `children`
|
|
14
|
+
Type: `ReactNode`
|
|
15
|
+
|
|
16
|
+
No description.
|
|
17
|
+
|
|
18
|
+
### `className`
|
|
19
|
+
Type: `string | ((state: MenuTriggerState) => string | undefined) | undefined`
|
|
20
|
+
|
|
21
|
+
CSS class applied to the element, or a function that
|
|
22
|
+
returns a class based on the component's state.
|
|
23
|
+
|
|
24
|
+
### `closeDelay`
|
|
25
|
+
Type: `number | undefined`, default: 0
|
|
26
|
+
|
|
27
|
+
How long to wait before closing the menu that was opened on hover.
|
|
28
|
+
Specified in milliseconds.
|
|
29
|
+
|
|
30
|
+
Requires the `openOnHover` prop.
|
|
31
|
+
|
|
32
|
+
### `delay`
|
|
33
|
+
Type: `number | undefined`, default: 100
|
|
34
|
+
|
|
35
|
+
How long to wait before the menu may be opened on hover. Specified in milliseconds.
|
|
36
|
+
|
|
37
|
+
Requires the `openOnHover` prop.
|
|
38
|
+
|
|
39
|
+
### `disabled`
|
|
40
|
+
Type: `boolean | undefined`, default: false
|
|
41
|
+
|
|
42
|
+
Whether the component should ignore user interaction.
|
|
43
|
+
|
|
44
|
+
### `handle`
|
|
45
|
+
Type: `MenuHandle<unknown> | undefined`
|
|
46
|
+
|
|
47
|
+
A handle to associate the trigger with a menu.
|
|
48
|
+
|
|
49
|
+
### `nativeButton`
|
|
50
|
+
Type: `boolean | undefined`, default: true
|
|
51
|
+
|
|
52
|
+
Whether the component renders a native `<button>` element when replacing it
|
|
53
|
+
via the `render` prop.
|
|
54
|
+
Set to `false` if the rendered element is not a button (for example, `<div>`).
|
|
55
|
+
|
|
56
|
+
### `openOnHover`
|
|
57
|
+
Type: `boolean | undefined`
|
|
58
|
+
|
|
59
|
+
Whether the menu should also open when the trigger is hovered.
|
|
60
|
+
|
|
61
|
+
### `payload`
|
|
62
|
+
Type: `unknown`
|
|
63
|
+
|
|
64
|
+
A payload to pass to the menu when it is opened.
|
|
65
|
+
|
|
66
|
+
### `render`
|
|
67
|
+
Type: `ComponentRenderFn<HTMLProps, MenuTriggerState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
68
|
+
|
|
69
|
+
Allows you to replace the component's HTML element
|
|
70
|
+
with a different tag, or compose it with another component.
|
|
71
|
+
|
|
72
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
73
|
+
|
|
74
|
+
### `style`
|
|
75
|
+
Type: `CSSProperties | ((state: MenuTriggerState) => CSSProperties | undefined) | undefined`
|
|
76
|
+
|
|
77
|
+
Style applied to the element, or a function that
|
|
78
|
+
returns a style object based on the component's state.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
export const InThemedSubtree: Story = {
|
|
84
|
+
args: { defaultOpen: true },
|
|
85
|
+
render: (args) => (
|
|
86
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
87
|
+
<div className="bg-background p-4 text-foreground">
|
|
88
|
+
<Actions {...args} />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
```
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Menu
|
|
2
|
+
|
|
3
|
+
Groups all parts of the menu. Doesn't render an element.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Menu } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `actionsRef`
|
|
14
|
+
Type: `RefObject<MenuRootActions | null> | undefined`
|
|
15
|
+
|
|
16
|
+
A ref to imperative actions.
|
|
17
|
+
- `unmount`: Ends the closing phase of the menu after an externally controlled closing animation finishes.
|
|
18
|
+
Call `preventUnmountOnClose()` in `onOpenChange` first, otherwise the menu completes closing on its own.
|
|
19
|
+
Whether it leaves the DOM is decided by `keepMounted` on the portal.
|
|
20
|
+
- `close`: Closes the menu imperatively when called.
|
|
21
|
+
|
|
22
|
+
### `children`
|
|
23
|
+
Type: `PayloadChildRenderFunction<unknown> | ReactNode`
|
|
24
|
+
|
|
25
|
+
The content of the menu.
|
|
26
|
+
This can be a regular React node or a render function that receives the `payload` of the active trigger.
|
|
27
|
+
|
|
28
|
+
### `closeParentOnEsc`
|
|
29
|
+
Type: `boolean | undefined`, default: false
|
|
30
|
+
|
|
31
|
+
When in a submenu, determines whether pressing the Escape key
|
|
32
|
+
closes the entire menu, or only the current child menu.
|
|
33
|
+
|
|
34
|
+
### `defaultOpen`
|
|
35
|
+
Type: `boolean | undefined`, default: false
|
|
36
|
+
|
|
37
|
+
Whether the menu is initially open.
|
|
38
|
+
|
|
39
|
+
To render a controlled menu, use the `open` prop instead.
|
|
40
|
+
|
|
41
|
+
### `defaultTriggerId`
|
|
42
|
+
Type: `string | null | undefined`
|
|
43
|
+
|
|
44
|
+
ID of the trigger that the menu is associated with.
|
|
45
|
+
This is useful in conjunction with the `defaultOpen` prop to create an initially open menu.
|
|
46
|
+
|
|
47
|
+
### `disabled`
|
|
48
|
+
Type: `boolean | undefined`, default: false
|
|
49
|
+
|
|
50
|
+
Whether the component should ignore user interaction.
|
|
51
|
+
|
|
52
|
+
### `handle`
|
|
53
|
+
Type: `MenuHandle<unknown> | undefined`
|
|
54
|
+
|
|
55
|
+
A handle to associate the menu with a trigger.
|
|
56
|
+
If specified, allows external triggers to control the menu's open state.
|
|
57
|
+
|
|
58
|
+
### `highlightItemOnHover`
|
|
59
|
+
Type: `boolean | undefined`, default: true
|
|
60
|
+
|
|
61
|
+
Whether moving the pointer over items should highlight them.
|
|
62
|
+
Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.
|
|
63
|
+
|
|
64
|
+
### `loopFocus`
|
|
65
|
+
Type: `boolean | undefined`, default: true
|
|
66
|
+
|
|
67
|
+
Whether to loop keyboard focus back to the first item
|
|
68
|
+
when the end of the list is reached while using the arrow keys.
|
|
69
|
+
|
|
70
|
+
### `modal`
|
|
71
|
+
Type: `boolean | undefined`, default: true
|
|
72
|
+
|
|
73
|
+
Determines if the menu enters a modal state when open.
|
|
74
|
+
- `true`: user interaction is limited to the menu: document page scroll is locked and pointer interactions on outside elements are disabled.
|
|
75
|
+
- `false`: user interaction with the rest of the document is allowed.
|
|
76
|
+
|
|
77
|
+
On touch devices, a `true` modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior.
|
|
78
|
+
|
|
79
|
+
Nested menus ignore this prop, and menus opened by hover are never modal.
|
|
80
|
+
|
|
81
|
+
### `onItemHighlighted`
|
|
82
|
+
Type: `((highlightedItem: HTMLElement | undefined, eventDetails: MenuRootHighlightEventDetails) => void) | undefined`
|
|
83
|
+
|
|
84
|
+
Callback fired when an item is highlighted or unhighlighted.
|
|
85
|
+
Receives the highlighted item element (or `undefined` if no item is highlighted) and details
|
|
86
|
+
containing the reason for the change, the event, and the item's text label.
|
|
87
|
+
The `reason` can be:
|
|
88
|
+
- `'keyboard'`: the highlight changed due to keyboard navigation.
|
|
89
|
+
- `'pointer'`: the highlight changed due to pointer hovering. The event may be a `MouseEvent`
|
|
90
|
+
rather than a `PointerEvent`.
|
|
91
|
+
- `'none'`: the highlight changed for another reason, such as automatic highlighting while
|
|
92
|
+
filtering, the item list changing, or the popup opening or closing.
|
|
93
|
+
|
|
94
|
+
### `onOpenChange`
|
|
95
|
+
Type: `((open: boolean, eventDetails: MenuRootChangeEventDetails) => void) | undefined`
|
|
96
|
+
|
|
97
|
+
Event handler called when the menu is opened or closed.
|
|
98
|
+
|
|
99
|
+
### `onOpenChangeComplete`
|
|
100
|
+
Type: `((open: boolean) => void) | undefined`
|
|
101
|
+
|
|
102
|
+
Event handler called after any animations complete when the menu is opened or closed.
|
|
103
|
+
|
|
104
|
+
### `open`
|
|
105
|
+
Type: `boolean | undefined`
|
|
106
|
+
|
|
107
|
+
Whether the menu is currently open.
|
|
108
|
+
|
|
109
|
+
### `orientation`
|
|
110
|
+
Type: `MenuRootOrientation | undefined`, default: 'vertical'
|
|
111
|
+
|
|
112
|
+
The visual orientation of the menu.
|
|
113
|
+
Controls whether roving focus uses up/down or left/right arrow keys.
|
|
114
|
+
|
|
115
|
+
### `triggerId`
|
|
116
|
+
Type: `string | null | undefined`
|
|
117
|
+
|
|
118
|
+
ID of the trigger that the menu is associated with.
|
|
119
|
+
This is useful in conjunction with the `open` prop to create a controlled menu.
|
|
120
|
+
There's no need to specify this prop when the menu is uncontrolled (that is, when the `open` prop is not set).
|
|
121
|
+
|
|
122
|
+
## Examples
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
export const InThemedSubtree: Story = {
|
|
126
|
+
args: { defaultOpen: true },
|
|
127
|
+
render: (args) => (
|
|
128
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
129
|
+
<div className="bg-background p-4 text-foreground">
|
|
130
|
+
<Actions {...args} />
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
),
|
|
134
|
+
};
|
|
135
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# SelectContent
|
|
2
|
+
|
|
3
|
+
Popup with the list of items, in a portal. It takes the theme and scheme of the subtree the trigger is in.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectContent } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `align`
|
|
14
|
+
Type: `Align | undefined`, default: 'center'
|
|
15
|
+
|
|
16
|
+
How to align the popup relative to the specified side.
|
|
17
|
+
|
|
18
|
+
### `alignItemWithTrigger`
|
|
19
|
+
Type: `boolean | undefined`, default: true
|
|
20
|
+
|
|
21
|
+
Whether the positioner overlaps the trigger so the selected item's text is aligned with the trigger's value text. This only applies to mouse input and is automatically disabled if there is not enough space.
|
|
22
|
+
|
|
23
|
+
### `children`
|
|
24
|
+
Type: `ReactNode`
|
|
25
|
+
|
|
26
|
+
No description.
|
|
27
|
+
|
|
28
|
+
### `className`
|
|
29
|
+
Type: `string | ((state: SelectPopupState) => string | undefined) | undefined`
|
|
30
|
+
|
|
31
|
+
CSS class applied to the element, or a function that
|
|
32
|
+
returns a class based on the component's state.
|
|
33
|
+
|
|
34
|
+
### `finalFocus`
|
|
35
|
+
Type: `boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | undefined`
|
|
36
|
+
|
|
37
|
+
Determines the element to focus when the select popup is closed.
|
|
38
|
+
|
|
39
|
+
- `false`: Do not move focus.
|
|
40
|
+
- `true`: Move focus based on the default behavior (trigger or previously focused element).
|
|
41
|
+
- `RefObject`: Move focus to the ref element.
|
|
42
|
+
- `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`).
|
|
43
|
+
Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.
|
|
44
|
+
|
|
45
|
+
### `render`
|
|
46
|
+
Type: `ComponentRenderFn<HTMLProps, SelectPopupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
47
|
+
|
|
48
|
+
Allows you to replace the component's HTML element
|
|
49
|
+
with a different tag, or compose it with another component.
|
|
50
|
+
|
|
51
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
52
|
+
|
|
53
|
+
### `side`
|
|
54
|
+
Type: `Side | undefined`, default: 'bottom'
|
|
55
|
+
|
|
56
|
+
Which side of the anchor element to align the popup against.
|
|
57
|
+
May automatically change to avoid collisions.
|
|
58
|
+
|
|
59
|
+
### `sideOffset`
|
|
60
|
+
Type: `number | OffsetFunction | undefined`, default: 0
|
|
61
|
+
|
|
62
|
+
Distance between the anchor and the popup in pixels.
|
|
63
|
+
Also accepts a function that returns the distance to read the dimensions of the anchor
|
|
64
|
+
and positioner elements, along with its side and alignment.
|
|
65
|
+
|
|
66
|
+
The function takes a `data` object parameter with the following properties:
|
|
67
|
+
- `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.
|
|
68
|
+
- `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.
|
|
69
|
+
- `data.side`: which side of the anchor element the positioner is aligned against.
|
|
70
|
+
- `data.align`: how the positioner is aligned relative to the specified side.
|
|
71
|
+
|
|
72
|
+
### `style`
|
|
73
|
+
Type: `CSSProperties | ((state: SelectPopupState) => CSSProperties | undefined) | undefined`
|
|
74
|
+
|
|
75
|
+
Style applied to the element, or a function that
|
|
76
|
+
returns a style object based on the component's state.
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
export const InThemedSubtree: Story = {
|
|
82
|
+
args: { defaultOpen: true },
|
|
83
|
+
render: (args) => (
|
|
84
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
85
|
+
<div className="bg-background p-4 text-foreground">
|
|
86
|
+
<Fruits {...args} />
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SelectGroup
|
|
2
|
+
|
|
3
|
+
Groups items under a `SelectLabel`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectGroup } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `className`
|
|
14
|
+
Type: `string | ((state: SelectGroupState) => string | undefined) | undefined`
|
|
15
|
+
|
|
16
|
+
CSS class applied to the element, or a function that
|
|
17
|
+
returns a class based on the component's state.
|
|
18
|
+
|
|
19
|
+
### `render`
|
|
20
|
+
Type: `ComponentRenderFn<HTMLProps, SelectGroupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
21
|
+
|
|
22
|
+
Allows you to replace the component's HTML element
|
|
23
|
+
with a different tag, or compose it with another component.
|
|
24
|
+
|
|
25
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
26
|
+
|
|
27
|
+
### `style`
|
|
28
|
+
Type: `CSSProperties | ((state: SelectGroupState) => CSSProperties | undefined) | undefined`
|
|
29
|
+
|
|
30
|
+
Style applied to the element, or a function that
|
|
31
|
+
returns a style object based on the component's state.
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
export const InThemedSubtree: Story = {
|
|
37
|
+
args: { defaultOpen: true },
|
|
38
|
+
render: (args) => (
|
|
39
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
40
|
+
<div className="bg-background p-4 text-foreground">
|
|
41
|
+
<Fruits {...args} />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# SelectItem
|
|
2
|
+
|
|
3
|
+
One choice. `value` is what `onValueChange` receives.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectItem } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `children`
|
|
14
|
+
Type: `ReactNode`
|
|
15
|
+
|
|
16
|
+
No description.
|
|
17
|
+
|
|
18
|
+
### `className`
|
|
19
|
+
Type: `string | ((state: SelectItemState) => string | undefined) | undefined`
|
|
20
|
+
|
|
21
|
+
CSS class applied to the element, or a function that
|
|
22
|
+
returns a class based on the component's state.
|
|
23
|
+
|
|
24
|
+
### `disabled`
|
|
25
|
+
Type: `boolean | undefined`, default: false
|
|
26
|
+
|
|
27
|
+
Whether the component should ignore user interaction.
|
|
28
|
+
|
|
29
|
+
### `label`
|
|
30
|
+
Type: `string | undefined`
|
|
31
|
+
|
|
32
|
+
Specifies the text label to use when the item is matched during keyboard text navigation.
|
|
33
|
+
|
|
34
|
+
Defaults to the item text content if not provided.
|
|
35
|
+
|
|
36
|
+
### `nativeButton`
|
|
37
|
+
Type: `boolean | undefined`, default: false
|
|
38
|
+
|
|
39
|
+
Whether the component renders a native `<button>` element when replacing it
|
|
40
|
+
via the `render` prop.
|
|
41
|
+
Set to `true` if the rendered element is a native button.
|
|
42
|
+
|
|
43
|
+
### `render`
|
|
44
|
+
Type: `ComponentRenderFn<HTMLProps, SelectItemState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
45
|
+
|
|
46
|
+
Allows you to replace the component's HTML element
|
|
47
|
+
with a different tag, or compose it with another component.
|
|
48
|
+
|
|
49
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
50
|
+
|
|
51
|
+
### `style`
|
|
52
|
+
Type: `CSSProperties | ((state: SelectItemState) => CSSProperties | undefined) | undefined`
|
|
53
|
+
|
|
54
|
+
Style applied to the element, or a function that
|
|
55
|
+
returns a style object based on the component's state.
|
|
56
|
+
|
|
57
|
+
### `value`
|
|
58
|
+
Type: `any`, default: null
|
|
59
|
+
|
|
60
|
+
A unique value that identifies this select item.
|
|
61
|
+
|
|
62
|
+
## Examples
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
export const InThemedSubtree: Story = {
|
|
66
|
+
args: { defaultOpen: true },
|
|
67
|
+
render: (args) => (
|
|
68
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
69
|
+
<div className="bg-background p-4 text-foreground">
|
|
70
|
+
<Fruits {...args} />
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SelectLabel
|
|
2
|
+
|
|
3
|
+
Label of a `SelectGroup`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectLabel } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `className`
|
|
14
|
+
Type: `string | ((state: SelectGroupLabelState) => string | undefined) | undefined`
|
|
15
|
+
|
|
16
|
+
CSS class applied to the element, or a function that
|
|
17
|
+
returns a class based on the component's state.
|
|
18
|
+
|
|
19
|
+
### `render`
|
|
20
|
+
Type: `ComponentRenderFn<HTMLProps, SelectGroupLabelState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
21
|
+
|
|
22
|
+
Allows you to replace the component's HTML element
|
|
23
|
+
with a different tag, or compose it with another component.
|
|
24
|
+
|
|
25
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
26
|
+
|
|
27
|
+
### `style`
|
|
28
|
+
Type: `CSSProperties | ((state: SelectGroupLabelState) => CSSProperties | undefined) | undefined`
|
|
29
|
+
|
|
30
|
+
Style applied to the element, or a function that
|
|
31
|
+
returns a style object based on the component's state.
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
export const InThemedSubtree: Story = {
|
|
37
|
+
args: { defaultOpen: true },
|
|
38
|
+
render: (args) => (
|
|
39
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
40
|
+
<div className="bg-background p-4 text-foreground">
|
|
41
|
+
<Fruits {...args} />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
```
|