@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +44 -3
  3. package/dist/AGENTS.md +19 -0
  4. package/dist/components/button.d.mts +30 -0
  5. package/dist/components/button.mjs +32 -0
  6. package/dist/components/card.d.mts +19 -0
  7. package/dist/components/card.mjs +77 -0
  8. package/dist/components/checkbox.d.mts +13 -0
  9. package/dist/components/checkbox.mjs +33 -0
  10. package/dist/components/dialog.d.mts +25 -0
  11. package/dist/components/dialog.mjs +97 -0
  12. package/dist/components/field.d.mts +18 -0
  13. package/dist/components/field.mjs +41 -0
  14. package/dist/components/input.d.mts +4 -0
  15. package/dist/components/input.mjs +14 -0
  16. package/dist/components/menu.d.mts +22 -0
  17. package/dist/components/menu.mjs +89 -0
  18. package/dist/components/select.d.mts +25 -0
  19. package/dist/components/select.mjs +127 -0
  20. package/dist/components/stack.d.mts +48 -0
  21. package/dist/components/stack.mjs +196 -0
  22. package/dist/components/text.d.mts +25 -0
  23. package/dist/components/text.mjs +81 -0
  24. package/dist/components/toast.d.mts +15 -0
  25. package/dist/components/toast.mjs +49 -0
  26. package/dist/docs/button.md +84 -0
  27. package/dist/docs/card-content.md +41 -0
  28. package/dist/docs/card-description.md +41 -0
  29. package/dist/docs/card-footer.md +41 -0
  30. package/dist/docs/card-header.md +41 -0
  31. package/dist/docs/card-title.md +41 -0
  32. package/dist/docs/card.md +41 -0
  33. package/dist/docs/checkbox.md +142 -0
  34. package/dist/docs/dialog-close.md +53 -0
  35. package/dist/docs/dialog-content.md +70 -0
  36. package/dist/docs/dialog-description.md +46 -0
  37. package/dist/docs/dialog-footer.md +28 -0
  38. package/dist/docs/dialog-header.md +28 -0
  39. package/dist/docs/dialog-title.md +46 -0
  40. package/dist/docs/dialog-trigger.md +70 -0
  41. package/dist/docs/dialog.md +100 -0
  42. package/dist/docs/field-description.md +69 -0
  43. package/dist/docs/field-error.md +77 -0
  44. package/dist/docs/field-label.md +77 -0
  45. package/dist/docs/field.md +128 -0
  46. package/dist/docs/index.md +41 -0
  47. package/dist/docs/input.md +46 -0
  48. package/dist/docs/menu-content.md +95 -0
  49. package/dist/docs/menu-group.md +51 -0
  50. package/dist/docs/menu-item.md +79 -0
  51. package/dist/docs/menu-label.md +46 -0
  52. package/dist/docs/menu-separator.md +51 -0
  53. package/dist/docs/menu-trigger.md +93 -0
  54. package/dist/docs/menu.md +135 -0
  55. package/dist/docs/select-content.md +91 -0
  56. package/dist/docs/select-group.md +46 -0
  57. package/dist/docs/select-item.md +75 -0
  58. package/dist/docs/select-label.md +46 -0
  59. package/dist/docs/select-separator.md +51 -0
  60. package/dist/docs/select-trigger.md +63 -0
  61. package/dist/docs/select-value.md +59 -0
  62. package/dist/docs/select.md +164 -0
  63. package/dist/docs/stack.md +58 -0
  64. package/dist/docs/text.md +60 -0
  65. package/dist/docs/toast-provider.md +34 -0
  66. package/dist/index.d.mts +12 -0
  67. package/dist/index.mjs +12 -0
  68. package/dist/lib/cn.mjs +9 -0
  69. package/dist/lib/responsive.d.mts +4 -0
  70. package/dist/lib/responsive.mjs +17 -0
  71. package/package.json +67 -3
  72. package/styles.css +67 -0
  73. package/themes/brutalista.css +36 -0
  74. package/themes/neon.css +37 -0
@@ -0,0 +1,100 @@
1
+ # Dialog
2
+
3
+ Groups all parts of the dialog. Doesn't render an element.
4
+
5
+ ```tsx
6
+ import { Dialog } 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<DialogRootActions | null> | undefined`
15
+
16
+ A ref to imperative actions.
17
+ - `unmount`: Ends the closing phase of the dialog after an externally controlled closing animation finishes.
18
+ Call `preventUnmountOnClose()` in `onOpenChange` first, otherwise the dialog completes closing on its own.
19
+ Whether it leaves the DOM is decided by `keepMounted` on the portal.
20
+ - `close`: Closes the dialog imperatively when called.
21
+
22
+ ### `children`
23
+ Type: `PayloadChildRenderFunction<unknown> | ReactNode`
24
+
25
+ The content of the dialog.
26
+ This can be a regular React node or a render function that receives the `payload` of the active trigger.
27
+
28
+ ### `defaultOpen`
29
+ Type: `boolean | undefined`, default: false
30
+
31
+ Whether the dialog is initially open.
32
+
33
+ To render a controlled dialog, use the `open` prop instead.
34
+
35
+ ### `defaultTriggerId`
36
+ Type: `string | null | undefined`
37
+
38
+ ID of the trigger that the dialog is associated with.
39
+ This is useful in conjunction with the `defaultOpen` prop to create an initially open dialog.
40
+
41
+ ### `disablePointerDismissal`
42
+ Type: `boolean | undefined`, default: false
43
+
44
+ Whether to prevent the dialog from closing on outside presses.
45
+ For non-modal dialogs, this also prevents the dialog from closing when focus moves outside of it.
46
+
47
+ ### `handle`
48
+ Type: `DialogHandle<unknown> | undefined`
49
+
50
+ A handle to associate the dialog with a trigger.
51
+ If specified, allows external triggers to control the dialog's open state.
52
+ Can be created with the Dialog.createHandle() method.
53
+
54
+ ### `modal`
55
+ Type: `"trap-focus" | boolean | undefined`, default: true
56
+
57
+ Determines if the dialog enters a modal state when open.
58
+ - `true`: user interaction is limited to just the dialog: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled.
59
+ - `false`: user interaction with the rest of the document is allowed.
60
+ - `'trap-focus'`: focus is trapped inside the dialog, but document page scroll is not locked and pointer interactions outside of it remain enabled.
61
+
62
+ When `modal` is `true` or `'trap-focus'`, render `<Dialog.Close>` inside `<Dialog.Popup>` so
63
+ touch screen readers can escape the popup.
64
+
65
+ ### `onOpenChange`
66
+ Type: `((open: boolean, eventDetails: DialogRootChangeEventDetails) => void) | undefined`
67
+
68
+ Event handler called when the dialog is opened or closed.
69
+
70
+ ### `onOpenChangeComplete`
71
+ Type: `((open: boolean) => void) | undefined`
72
+
73
+ Event handler called after any animations complete when the dialog is opened or closed.
74
+
75
+ ### `open`
76
+ Type: `boolean | undefined`
77
+
78
+ Whether the dialog is currently open.
79
+
80
+ ### `triggerId`
81
+ Type: `string | null | undefined`
82
+
83
+ ID of the trigger that the dialog is associated with.
84
+ This is useful in conjunction with the `open` prop to create a controlled dialog.
85
+ There's no need to specify this prop when the dialog is uncontrolled (that is, when the `open` prop is not set).
86
+
87
+ ## Examples
88
+
89
+ ```tsx
90
+ export const InThemedSubtree: Story = {
91
+ args: { defaultOpen: true },
92
+ render: (args) => (
93
+ <div className="p-4" data-theme="neon" data-scheme="dark">
94
+ <div className="bg-background p-4 text-foreground">
95
+ <Example {...args} />
96
+ </div>
97
+ </div>
98
+ ),
99
+ };
100
+ ```
@@ -0,0 +1,69 @@
1
+ # FieldDescription
2
+
3
+ Helper text, announced through `aria-describedby` on the input.
4
+
5
+ ```tsx
6
+ import { FieldDescription } 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: FieldDescriptionState) => 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, FieldDescriptionState> | 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: FieldDescriptionState) => 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 Default: Story = {
37
+ render: () => (
38
+ <Field className="w-72 p-4">
39
+ <FieldLabel>Email</FieldLabel>
40
+ <Input type="email" placeholder="you@example.com" />
41
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
42
+ </Field>
43
+ ),
44
+ };
45
+ ```
46
+
47
+ ```tsx
48
+ export const WithError: Story = {
49
+ render: () => (
50
+ <Field invalid className="w-72 p-4">
51
+ <FieldLabel>Email</FieldLabel>
52
+ <Input type="email" defaultValue="not-an-email" />
53
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
54
+ <FieldError match>Enter a valid email address.</FieldError>
55
+ </Field>
56
+ ),
57
+ };
58
+ ```
59
+
60
+ ```tsx
61
+ export const Disabled: Story = {
62
+ render: () => (
63
+ <Field disabled className="w-72 p-4">
64
+ <FieldLabel>Email</FieldLabel>
65
+ <Input type="email" />
66
+ </Field>
67
+ ),
68
+ };
69
+ ```
@@ -0,0 +1,77 @@
1
+ # FieldError
2
+
3
+ Error message, announced through `aria-describedby` on the input. Set `match` to show it regardless of the validity state.
4
+
5
+ ```tsx
6
+ import { FieldError } 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: FieldErrorState) => 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
+ ### `match`
20
+ Type: `boolean | keyof ValidityState | undefined`
21
+
22
+ Determines whether to show the error message according to the field's
23
+ [ValidityState](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState).
24
+ Specifying `true` will always show the error message, and lets external libraries
25
+ control the visibility.
26
+
27
+ ### `render`
28
+ Type: `ComponentRenderFn<HTMLProps, FieldErrorState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
29
+
30
+ Allows you to replace the component's HTML element
31
+ with a different tag, or compose it with another component.
32
+
33
+ Accepts a `ReactElement` or a function that returns the element to render.
34
+
35
+ ### `style`
36
+ Type: `CSSProperties | ((state: FieldErrorState) => CSSProperties | undefined) | undefined`
37
+
38
+ Style applied to the element, or a function that
39
+ returns a style object based on the component's state.
40
+
41
+ ## Examples
42
+
43
+ ```tsx
44
+ export const Default: Story = {
45
+ render: () => (
46
+ <Field className="w-72 p-4">
47
+ <FieldLabel>Email</FieldLabel>
48
+ <Input type="email" placeholder="you@example.com" />
49
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
50
+ </Field>
51
+ ),
52
+ };
53
+ ```
54
+
55
+ ```tsx
56
+ export const WithError: Story = {
57
+ render: () => (
58
+ <Field invalid className="w-72 p-4">
59
+ <FieldLabel>Email</FieldLabel>
60
+ <Input type="email" defaultValue="not-an-email" />
61
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
62
+ <FieldError match>Enter a valid email address.</FieldError>
63
+ </Field>
64
+ ),
65
+ };
66
+ ```
67
+
68
+ ```tsx
69
+ export const Disabled: Story = {
70
+ render: () => (
71
+ <Field disabled className="w-72 p-4">
72
+ <FieldLabel>Email</FieldLabel>
73
+ <Input type="email" />
74
+ </Field>
75
+ ),
76
+ };
77
+ ```
@@ -0,0 +1,77 @@
1
+ # FieldLabel
2
+
3
+ Accessible name of the input in the same `Field`.
4
+
5
+ ```tsx
6
+ import { FieldLabel } 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: FieldLabelState) => 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
+ ### `nativeLabel`
20
+ Type: `boolean | undefined`, default: true
21
+
22
+ Whether the component renders a native `<label>` element when replacing it via the `render` prop.
23
+ Set to `false` if the rendered element is not a label (for example, `<div>`).
24
+
25
+ This is useful to avoid inheriting label behaviors on `<button>` controls (such as `<Select.Trigger>` and `<Combobox.Trigger>`), including avoiding `:hover` on the button when hovering the label, and preventing clicks on the label from firing on the button.
26
+
27
+ ### `render`
28
+ Type: `ComponentRenderFn<HTMLProps, FieldLabelState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
29
+
30
+ Allows you to replace the component's HTML element
31
+ with a different tag, or compose it with another component.
32
+
33
+ Accepts a `ReactElement` or a function that returns the element to render.
34
+
35
+ ### `style`
36
+ Type: `CSSProperties | ((state: FieldLabelState) => CSSProperties | undefined) | undefined`
37
+
38
+ Style applied to the element, or a function that
39
+ returns a style object based on the component's state.
40
+
41
+ ## Examples
42
+
43
+ ```tsx
44
+ export const Default: Story = {
45
+ render: () => (
46
+ <Field className="w-72 p-4">
47
+ <FieldLabel>Email</FieldLabel>
48
+ <Input type="email" placeholder="you@example.com" />
49
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
50
+ </Field>
51
+ ),
52
+ };
53
+ ```
54
+
55
+ ```tsx
56
+ export const WithError: Story = {
57
+ render: () => (
58
+ <Field invalid className="w-72 p-4">
59
+ <FieldLabel>Email</FieldLabel>
60
+ <Input type="email" defaultValue="not-an-email" />
61
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
62
+ <FieldError match>Enter a valid email address.</FieldError>
63
+ </Field>
64
+ ),
65
+ };
66
+ ```
67
+
68
+ ```tsx
69
+ export const Disabled: Story = {
70
+ render: () => (
71
+ <Field disabled className="w-72 p-4">
72
+ <FieldLabel>Email</FieldLabel>
73
+ <Input type="email" />
74
+ </Field>
75
+ ),
76
+ };
77
+ ```
@@ -0,0 +1,128 @@
1
+ # Field
2
+
3
+ Groups a label, an input, a description and an error, and links them for assistive technology.
4
+
5
+ ```tsx
6
+ import { Field } 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<FieldRootActions | null> | undefined`
15
+
16
+ A ref to imperative actions.
17
+ - `validate`: Validates the field when called.
18
+
19
+ ### `className`
20
+ Type: `string | ((state: FieldRootState) => string | undefined) | undefined`
21
+
22
+ CSS class applied to the element, or a function that
23
+ returns a class based on the component's state.
24
+
25
+ ### `dirty`
26
+ Type: `boolean | undefined`
27
+
28
+ Whether the field's value has been changed from its initial value.
29
+ Useful when the field state is controlled by an external library.
30
+
31
+ ### `disabled`
32
+ Type: `boolean | undefined`
33
+
34
+ Whether the field and its input should ignore user interaction.
35
+
36
+ ### `invalid`
37
+ Type: `boolean | undefined`
38
+
39
+ Whether the field is invalid. Marks the input `aria-invalid` and lets `FieldError` render.
40
+
41
+ ### `name`
42
+ Type: `string | undefined`
43
+
44
+ Identifies the field when a form is submitted.
45
+ Takes precedence over the `name` prop on the `<Field.Control>` component.
46
+
47
+ ### `render`
48
+ Type: `ComponentRenderFn<HTMLProps, FieldRootState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
49
+
50
+ Allows you to replace the component's HTML element
51
+ with a different tag, or compose it with another component.
52
+
53
+ Accepts a `ReactElement` or a function that returns the element to render.
54
+
55
+ ### `style`
56
+ Type: `CSSProperties | ((state: FieldRootState) => CSSProperties | undefined) | undefined`
57
+
58
+ Style applied to the element, or a function that
59
+ returns a style object based on the component's state.
60
+
61
+ ### `touched`
62
+ Type: `boolean | undefined`
63
+
64
+ Whether the field has been touched.
65
+ Useful when the field state is controlled by an external library.
66
+
67
+ ### `validate`
68
+ Type: `((value: unknown, formValues: Record<string, any>) => void | string | string[] | Promise<void | string | string[] | null> | null) | undefined`
69
+
70
+ A function for custom validation. Return a string or an array of strings with
71
+ the error message(s) if the value is invalid. Returning nothing, `null`, an empty
72
+ string, or an empty array means the value is valid.
73
+ Asynchronous functions are supported, but they do not prevent form submission
74
+ when using `validationMode="onSubmit"`.
75
+
76
+ ### `validationDebounceTime`
77
+ Type: `number | undefined`, default: 0
78
+
79
+ How long to wait between `validate` callbacks if
80
+ `validationMode="onChange"` is used. Specified in milliseconds.
81
+
82
+ ### `validationMode`
83
+ Type: `FormValidationMode | undefined`, default: 'onSubmit'
84
+
85
+ Determines when the field should be validated.
86
+ This takes precedence over the `validationMode` prop on `<Form>`.
87
+
88
+ - `onSubmit`: triggers validation when the form is submitted, and re-validates on change after submission.
89
+ - `onBlur`: triggers validation when the control loses focus.
90
+ - `onChange`: triggers validation on every change to the control value.
91
+
92
+ ## Examples
93
+
94
+ ```tsx
95
+ export const Default: Story = {
96
+ render: () => (
97
+ <Field className="w-72 p-4">
98
+ <FieldLabel>Email</FieldLabel>
99
+ <Input type="email" placeholder="you@example.com" />
100
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
101
+ </Field>
102
+ ),
103
+ };
104
+ ```
105
+
106
+ ```tsx
107
+ export const WithError: Story = {
108
+ render: () => (
109
+ <Field invalid className="w-72 p-4">
110
+ <FieldLabel>Email</FieldLabel>
111
+ <Input type="email" defaultValue="not-an-email" />
112
+ <FieldDescription>We only use it to send the receipt.</FieldDescription>
113
+ <FieldError match>Enter a valid email address.</FieldError>
114
+ </Field>
115
+ ),
116
+ };
117
+ ```
118
+
119
+ ```tsx
120
+ export const Disabled: Story = {
121
+ render: () => (
122
+ <Field disabled className="w-72 p-4">
123
+ <FieldLabel>Email</FieldLabel>
124
+ <Input type="email" />
125
+ </Field>
126
+ ),
127
+ };
128
+ ```
@@ -0,0 +1,41 @@
1
+ # trama components
2
+
3
+ - [Button](./button.md): Button with the shadcn/ui API on top of Base UI.
4
+ - [Card](./card.md): Surface that groups related content.
5
+ - [CardContent](./card-content.md): Main body of the card.
6
+ - [CardDescription](./card-description.md): Supporting text under the title.
7
+ - [CardFooter](./card-footer.md): Bottom of the card, usually actions.
8
+ - [CardHeader](./card-header.md): Top of the card: holds `CardTitle` and `CardDescription`.
9
+ - [CardTitle](./card-title.md): Title of the card.
10
+ - [Checkbox](./checkbox.md): Checkbox with the shadcn/ui API on top of Base UI.
11
+ - [Dialog](./dialog.md): Groups all parts of the dialog.
12
+ - [DialogClose](./dialog-close.md): Button that closes the dialog.
13
+ - [DialogContent](./dialog-content.md): Popup with its backdrop, in a portal.
14
+ - [DialogDescription](./dialog-description.md): Accessible description of the dialog.
15
+ - [DialogFooter](./dialog-footer.md): Holds the actions, usually `DialogClose` buttons.
16
+ - [DialogHeader](./dialog-header.md): Groups the title and description.
17
+ - [DialogTitle](./dialog-title.md): Accessible name of the dialog.
18
+ - [DialogTrigger](./dialog-trigger.md): Button that opens the dialog.
19
+ - [Field](./field.md): Groups a label, an input, a description and an error, and links them for assistive technology.
20
+ - [FieldDescription](./field-description.md): Helper text, announced through `aria-describedby` on the input.
21
+ - [FieldError](./field-error.md): Error message, announced through `aria-describedby` on the input.
22
+ - [FieldLabel](./field-label.md): Accessible name of the input in the same `Field`.
23
+ - [Input](./input.md): Text input with the shadcn/ui API on top of Base UI.
24
+ - [Menu](./menu.md): Groups all parts of the menu.
25
+ - [MenuContent](./menu-content.md): Popup with the list of items, in a portal.
26
+ - [MenuGroup](./menu-group.md): Groups items under a `MenuLabel`.
27
+ - [MenuItem](./menu-item.md): One action.
28
+ - [MenuLabel](./menu-label.md): Label of a `MenuGroup`.
29
+ - [MenuSeparator](./menu-separator.md): Line between items or groups.
30
+ - [MenuTrigger](./menu-trigger.md): Button that opens the menu.
31
+ - [Select](./select.md): Groups all parts of the select.
32
+ - [SelectContent](./select-content.md): Popup with the list of items, in a portal.
33
+ - [SelectGroup](./select-group.md): Groups items under a `SelectLabel`.
34
+ - [SelectItem](./select-item.md): One choice.
35
+ - [SelectLabel](./select-label.md): Label of a `SelectGroup`.
36
+ - [SelectSeparator](./select-separator.md): Line between items or groups.
37
+ - [SelectTrigger](./select-trigger.md): Button that opens the popup.
38
+ - [SelectValue](./select-value.md): Shows the label of the selected item, or `placeholder` when nothing is selected.
39
+ - [Stack](./stack.md): Flex layout component.
40
+ - [ToastProvider](./toast-provider.md): Mounts the toast region once, near the root of the app.
41
+ - [Text](./text.md): Text layout component.
@@ -0,0 +1,46 @@
1
+ # Input
2
+
3
+ Text input with the shadcn/ui API on top of Base UI. Inside `Field` it is linked to the label, description and error.
4
+
5
+ ```tsx
6
+ import { Input } 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: InputState) => 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
+ ### `defaultValue`
20
+ Type: `string | number | readonly string[] | undefined`
21
+
22
+ The default value of the input. Use when uncontrolled.
23
+
24
+ ### `onValueChange`
25
+ Type: `((value: string, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void) | undefined`
26
+
27
+ Callback fired when the `value` changes. Use when controlled.
28
+
29
+ ### `render`
30
+ Type: `ComponentRenderFn<HTMLProps, InputState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
31
+
32
+ Allows you to replace the component's HTML element
33
+ with a different tag, or compose it with another component.
34
+
35
+ Accepts a `ReactElement` or a function that returns the element to render.
36
+
37
+ ### `style`
38
+ Type: `CSSProperties | ((state: InputState) => CSSProperties | undefined) | undefined`
39
+
40
+ Style applied to the element, or a function that
41
+ returns a style object based on the component's state.
42
+
43
+ ### `value`
44
+ Type: `string | number | readonly string[] | undefined`
45
+
46
+ The value of the input. Use when controlled.
@@ -0,0 +1,95 @@
1
+ # MenuContent
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 { MenuContent } 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
+ Submenus and menubars default to `'start'`.
19
+
20
+ ### `children`
21
+ Type: `ReactNode`
22
+
23
+ No description.
24
+
25
+ ### `className`
26
+ Type: `string | ((state: MenuPopupState) => string | undefined) | undefined`
27
+
28
+ CSS class applied to the element, or a function that
29
+ returns a class based on the component's state.
30
+
31
+ ### `finalFocus`
32
+ Type: `boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | undefined`
33
+
34
+ Determines the element to focus when the menu is closed.
35
+
36
+ - `false`: Do not move focus.
37
+ - `true`: Move focus based on the default behavior (trigger or previously focused element).
38
+ - `RefObject`: Move focus to the ref element.
39
+ - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`).
40
+ Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.
41
+
42
+ ### `id`
43
+ Type: `string | undefined`
44
+
45
+ No description.
46
+
47
+ ### `render`
48
+ Type: `ComponentRenderFn<HTMLProps, MenuPopupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
49
+
50
+ Allows you to replace the component's HTML element
51
+ with a different tag, or compose it with another component.
52
+
53
+ Accepts a `ReactElement` or a function that returns the element to render.
54
+
55
+ ### `side`
56
+ Type: `Side | undefined`, default: 'bottom'
57
+
58
+ Which side of the anchor element to align the popup against.
59
+ May automatically change to avoid collisions.
60
+
61
+ Submenus and vertical menubars default to `'inline-end'`.
62
+
63
+ ### `sideOffset`
64
+ Type: `number | OffsetFunction | undefined`, default: 0
65
+
66
+ Distance between the anchor and the popup in pixels.
67
+ Also accepts a function that returns the distance to read the dimensions of the anchor
68
+ and positioner elements, along with its side and alignment.
69
+
70
+ The function takes a `data` object parameter with the following properties:
71
+ - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.
72
+ - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.
73
+ - `data.side`: which side of the anchor element the positioner is aligned against.
74
+ - `data.align`: how the positioner is aligned relative to the specified side.
75
+
76
+ ### `style`
77
+ Type: `CSSProperties | ((state: MenuPopupState) => CSSProperties | undefined) | undefined`
78
+
79
+ Style applied to the element, or a function that
80
+ returns a style object based on the component's state.
81
+
82
+ ## Examples
83
+
84
+ ```tsx
85
+ export const InThemedSubtree: Story = {
86
+ args: { defaultOpen: true },
87
+ render: (args) => (
88
+ <div className="p-4" data-theme="neon" data-scheme="dark">
89
+ <div className="bg-background p-4 text-foreground">
90
+ <Actions {...args} />
91
+ </div>
92
+ </div>
93
+ ),
94
+ };
95
+ ```
@@ -0,0 +1,51 @@
1
+ # MenuGroup
2
+
3
+ Groups items under a `MenuLabel`.
4
+
5
+ ```tsx
6
+ import { MenuGroup } 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
+ The content of the component.
17
+
18
+ ### `className`
19
+ Type: `string | ((state: MenuGroupState) => 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
+ ### `render`
25
+ Type: `ComponentRenderFn<HTMLProps, MenuGroupState> | 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: MenuGroupState) => 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
+ ```