@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,51 @@
|
|
|
1
|
+
# SelectSeparator
|
|
2
|
+
|
|
3
|
+
Line between items or groups.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectSeparator } 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: SelectSeparatorState) => 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, SelectSeparatorState> | 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: SelectSeparatorState) => 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
|
+
<Fruits {...args} />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# SelectTrigger
|
|
2
|
+
|
|
3
|
+
Button that opens the popup. Put `SelectValue` inside it.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectTrigger } 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: SelectTriggerState) => 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`
|
|
26
|
+
|
|
27
|
+
Whether the component should ignore user interaction.
|
|
28
|
+
|
|
29
|
+
### `nativeButton`
|
|
30
|
+
Type: `boolean | undefined`, default: true
|
|
31
|
+
|
|
32
|
+
Whether the component renders a native `<button>` element when replacing it
|
|
33
|
+
via the `render` prop.
|
|
34
|
+
Set to `false` if the rendered element is not a button (for example, `<div>`).
|
|
35
|
+
|
|
36
|
+
### `render`
|
|
37
|
+
Type: `ComponentRenderFn<HTMLProps, SelectTriggerState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
38
|
+
|
|
39
|
+
Allows you to replace the component's HTML element
|
|
40
|
+
with a different tag, or compose it with another component.
|
|
41
|
+
|
|
42
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
43
|
+
|
|
44
|
+
### `style`
|
|
45
|
+
Type: `CSSProperties | ((state: SelectTriggerState) => CSSProperties | undefined) | undefined`
|
|
46
|
+
|
|
47
|
+
Style applied to the element, or a function that
|
|
48
|
+
returns a style object based on the component's state.
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
export const InThemedSubtree: Story = {
|
|
54
|
+
args: { defaultOpen: true },
|
|
55
|
+
render: (args) => (
|
|
56
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
57
|
+
<div className="bg-background p-4 text-foreground">
|
|
58
|
+
<Fruits {...args} />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# SelectValue
|
|
2
|
+
|
|
3
|
+
Shows the label of the selected item, or `placeholder` when nothing is selected.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { SelectValue } 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: `((value: any) => ReactNode) | ReactNode`
|
|
15
|
+
|
|
16
|
+
Accepts a function that returns a `ReactNode` to format the selected value.
|
|
17
|
+
Treat the value as read-only: in `multiple` mode it may be a shared frozen array
|
|
18
|
+
when nothing is selected.
|
|
19
|
+
|
|
20
|
+
### `className`
|
|
21
|
+
Type: `string | ((state: SelectValueState) => string | undefined) | undefined`
|
|
22
|
+
|
|
23
|
+
CSS class applied to the element, or a function that
|
|
24
|
+
returns a class based on the component's state.
|
|
25
|
+
|
|
26
|
+
### `placeholder`
|
|
27
|
+
Type: `ReactNode`
|
|
28
|
+
|
|
29
|
+
The placeholder value to display when no value is selected.
|
|
30
|
+
This is overridden by `children` if specified, or by a null item's label in `items`.
|
|
31
|
+
|
|
32
|
+
### `render`
|
|
33
|
+
Type: `ComponentRenderFn<HTMLProps, SelectValueState> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
34
|
+
|
|
35
|
+
Allows you to replace the component's HTML element
|
|
36
|
+
with a different tag, or compose it with another component.
|
|
37
|
+
|
|
38
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
39
|
+
|
|
40
|
+
### `style`
|
|
41
|
+
Type: `CSSProperties | ((state: SelectValueState) => CSSProperties | undefined) | undefined`
|
|
42
|
+
|
|
43
|
+
Style applied to the element, or a function that
|
|
44
|
+
returns a style object based on the component's state.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
export const InThemedSubtree: Story = {
|
|
50
|
+
args: { defaultOpen: true },
|
|
51
|
+
render: (args) => (
|
|
52
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
53
|
+
<div className="bg-background p-4 text-foreground">
|
|
54
|
+
<Fruits {...args} />
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
```
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
Groups all parts of the select. Doesn't render an element.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Select } 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<SelectRootActions | null> | undefined`
|
|
15
|
+
|
|
16
|
+
A ref to imperative actions.
|
|
17
|
+
- `unmount`: Ends the closing phase of the select after an externally controlled closing animation finishes.
|
|
18
|
+
Call `preventUnmountOnClose()` in `onOpenChange` first, otherwise the select completes closing on its own.
|
|
19
|
+
Whether it leaves the DOM is decided by `keepMounted` on the portal.
|
|
20
|
+
- `close`: Closes the select imperatively when called.
|
|
21
|
+
|
|
22
|
+
### `autoComplete`
|
|
23
|
+
Type: `string | undefined`
|
|
24
|
+
|
|
25
|
+
Provides a hint to the browser for autofill.
|
|
26
|
+
|
|
27
|
+
### `children`
|
|
28
|
+
Type: `ReactNode`
|
|
29
|
+
|
|
30
|
+
No description.
|
|
31
|
+
|
|
32
|
+
### `defaultOpen`
|
|
33
|
+
Type: `boolean | undefined`, default: false
|
|
34
|
+
|
|
35
|
+
Whether the select popup is initially open.
|
|
36
|
+
|
|
37
|
+
To render a controlled select popup, use the `open` prop instead.
|
|
38
|
+
|
|
39
|
+
### `defaultValue`
|
|
40
|
+
Type: `SelectInputValue<Value, Multiple> | null | undefined`
|
|
41
|
+
|
|
42
|
+
The uncontrolled value of the select when it's initially rendered.
|
|
43
|
+
|
|
44
|
+
To render a controlled select, use the `value` prop instead.
|
|
45
|
+
|
|
46
|
+
### `disabled`
|
|
47
|
+
Type: `boolean | undefined`, default: false
|
|
48
|
+
|
|
49
|
+
Whether the component should ignore user interaction.
|
|
50
|
+
|
|
51
|
+
### `form`
|
|
52
|
+
Type: `string | undefined`
|
|
53
|
+
|
|
54
|
+
Identifies the form that owns the hidden input.
|
|
55
|
+
Useful when the select is rendered outside the form.
|
|
56
|
+
|
|
57
|
+
### `highlightItemOnHover`
|
|
58
|
+
Type: `boolean | undefined`, default: true
|
|
59
|
+
|
|
60
|
+
Whether moving the pointer over items should highlight them.
|
|
61
|
+
Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.
|
|
62
|
+
|
|
63
|
+
### `id`
|
|
64
|
+
Type: `string | undefined`
|
|
65
|
+
|
|
66
|
+
The id of the Select.
|
|
67
|
+
|
|
68
|
+
### `inputRef`
|
|
69
|
+
Type: `Ref<HTMLInputElement> | undefined`
|
|
70
|
+
|
|
71
|
+
A ref to access the hidden input element.
|
|
72
|
+
|
|
73
|
+
### `isItemEqualToValue`
|
|
74
|
+
Type: `((itemValue: Value, value: Value) => boolean) | undefined`
|
|
75
|
+
|
|
76
|
+
Custom comparison logic used to determine if a select item value matches the current selected value. Useful when item values are objects without matching referentially.
|
|
77
|
+
Defaults to `Object.is` comparison.
|
|
78
|
+
|
|
79
|
+
### `items`
|
|
80
|
+
Type: `readonly Group<any>[] | readonly { label: ReactNode; value: any; }[] | Record<string, ReactNode> | undefined`
|
|
81
|
+
|
|
82
|
+
Data structure of the items rendered in the select popup.
|
|
83
|
+
When specified, `<Select.Value>` renders the label of the selected item instead of the raw value.
|
|
84
|
+
|
|
85
|
+
### `itemToStringLabel`
|
|
86
|
+
Type: `((itemValue: Value) => string) | undefined`
|
|
87
|
+
|
|
88
|
+
When the item values are objects (`<Select.Item value={object}>`), this function converts the object value to a string representation for display in the trigger.
|
|
89
|
+
If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop.
|
|
90
|
+
|
|
91
|
+
### `itemToStringValue`
|
|
92
|
+
Type: `((itemValue: Value) => string) | undefined`
|
|
93
|
+
|
|
94
|
+
When the item values are objects (`<Select.Item value={object}>`), this function converts the object value to a string representation for form submission.
|
|
95
|
+
If the shape of the object is `{ value, label }`, the value will be used automatically without needing to specify this prop.
|
|
96
|
+
|
|
97
|
+
### `modal`
|
|
98
|
+
Type: `boolean | undefined`, default: true
|
|
99
|
+
|
|
100
|
+
Determines if the select enters a modal state when open.
|
|
101
|
+
- `true`: user interaction is limited to the select: document page scroll is locked and pointer interactions on outside elements are disabled.
|
|
102
|
+
- `false`: user interaction with the rest of the document is allowed.
|
|
103
|
+
|
|
104
|
+
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.
|
|
105
|
+
|
|
106
|
+
### `multiple`
|
|
107
|
+
Type: `Multiple | undefined`, default: false
|
|
108
|
+
|
|
109
|
+
Whether multiple items can be selected.
|
|
110
|
+
|
|
111
|
+
### `name`
|
|
112
|
+
Type: `string | undefined`
|
|
113
|
+
|
|
114
|
+
Identifies the field when a form is submitted.
|
|
115
|
+
|
|
116
|
+
### `onOpenChange`
|
|
117
|
+
Type: `((open: boolean, eventDetails: SelectRootOpenChangeEventDetails) => void) | undefined`
|
|
118
|
+
|
|
119
|
+
Event handler called when the select popup is opened or closed.
|
|
120
|
+
|
|
121
|
+
### `onOpenChangeComplete`
|
|
122
|
+
Type: `((open: boolean) => void) | undefined`
|
|
123
|
+
|
|
124
|
+
Event handler called after any animations complete when the select popup is opened or closed.
|
|
125
|
+
|
|
126
|
+
### `onValueChange`
|
|
127
|
+
Type: `((value: SelectOutputValue<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: SelectRootChangeEventDetails) => void) | undefined`
|
|
128
|
+
|
|
129
|
+
Event handler called when the value of the select changes.
|
|
130
|
+
|
|
131
|
+
### `open`
|
|
132
|
+
Type: `boolean | undefined`
|
|
133
|
+
|
|
134
|
+
Whether the select popup is currently open.
|
|
135
|
+
|
|
136
|
+
### `readOnly`
|
|
137
|
+
Type: `boolean | undefined`, default: false
|
|
138
|
+
|
|
139
|
+
Whether the user should be unable to choose a different option from the select popup.
|
|
140
|
+
|
|
141
|
+
### `required`
|
|
142
|
+
Type: `boolean | undefined`, default: false
|
|
143
|
+
|
|
144
|
+
Whether the user must choose a value before submitting a form.
|
|
145
|
+
|
|
146
|
+
### `value`
|
|
147
|
+
Type: `SelectInputValue<Value, Multiple> | null | undefined`
|
|
148
|
+
|
|
149
|
+
The value of the select. Use when controlled.
|
|
150
|
+
|
|
151
|
+
## Examples
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
export const InThemedSubtree: Story = {
|
|
155
|
+
args: { defaultOpen: true },
|
|
156
|
+
render: (args) => (
|
|
157
|
+
<div className="p-4" data-theme="neon" data-scheme="dark">
|
|
158
|
+
<div className="bg-background p-4 text-foreground">
|
|
159
|
+
<Fruits {...args} />
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
),
|
|
163
|
+
};
|
|
164
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Stack
|
|
2
|
+
|
|
3
|
+
Flex layout component. Layout props take a single value or a mobile-first object with `initial` and Tailwind breakpoints, like `{ initial: "2", md: "4" }`. Polymorphism goes through `render`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Stack } 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: `Responsive<"baseline" | "center" | "end" | "start" | "stretch"> | undefined`
|
|
15
|
+
|
|
16
|
+
Cross-axis alignment of children. Accepts a responsive object.
|
|
17
|
+
|
|
18
|
+
### `direction`
|
|
19
|
+
Type: `Responsive<"column" | "row"> | undefined`, default: "column"
|
|
20
|
+
|
|
21
|
+
Main axis. Accepts a responsive object.
|
|
22
|
+
|
|
23
|
+
### `gap`
|
|
24
|
+
Type: `Responsive<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "8"> | undefined`
|
|
25
|
+
|
|
26
|
+
Space between children, on the `--spacing` scale (`"2"` is `gap-2`). Accepts a responsive object.
|
|
27
|
+
|
|
28
|
+
### `justify`
|
|
29
|
+
Type: `Responsive<"between" | "center" | "end" | "start"> | undefined`
|
|
30
|
+
|
|
31
|
+
Main-axis distribution of children. Accepts a responsive object.
|
|
32
|
+
|
|
33
|
+
### `render`
|
|
34
|
+
Type: `ComponentRenderFn<HTMLProps, {}> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
35
|
+
|
|
36
|
+
Allows you to replace the component's HTML element
|
|
37
|
+
with a different tag, or compose it with another component.
|
|
38
|
+
|
|
39
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
40
|
+
|
|
41
|
+
### `wrap`
|
|
42
|
+
Type: `Responsive<"nowrap" | "wrap"> | undefined`
|
|
43
|
+
|
|
44
|
+
Whether children wrap onto several lines. Accepts a responsive object.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
export const Responsive: Story = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<Stack direction={{ initial: "column", md: "row" }} gap={{ initial: "2", md: "4" }} className="p-4">
|
|
52
|
+
<div className={box}>One</div>
|
|
53
|
+
<div className={box}>Two</div>
|
|
54
|
+
<div className={box}>Three</div>
|
|
55
|
+
</Stack>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Text
|
|
2
|
+
|
|
3
|
+
Text layout component. `size` takes a single value or a mobile-first object like `{ initial: "base", md: "xl" }`. Change the element through `render`, e.g. `render={<h1 />}`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Text } from "@robzepdev/trama";
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Every other prop of the underlying DOM element is accepted as well.
|
|
12
|
+
|
|
13
|
+
### `render`
|
|
14
|
+
Type: `ComponentRenderFn<HTMLProps, {}> | ReactElement<unknown, string | JSXElementConstructor<any>> | undefined`
|
|
15
|
+
|
|
16
|
+
Allows you to replace the component's HTML element
|
|
17
|
+
with a different tag, or compose it with another component.
|
|
18
|
+
|
|
19
|
+
Accepts a `ReactElement` or a function that returns the element to render.
|
|
20
|
+
|
|
21
|
+
### `size`
|
|
22
|
+
Type: `Responsive<"2xl" | "3xl" | "base" | "lg" | "sm" | "xl" | "xs"> | undefined`, default: "base"
|
|
23
|
+
|
|
24
|
+
Size on the theme's type scale. Accepts a responsive object.
|
|
25
|
+
|
|
26
|
+
### `tone`
|
|
27
|
+
Type: `"destructive" | "muted" | "normal" | undefined`, default: "normal"
|
|
28
|
+
|
|
29
|
+
Semantic text color.
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
export const All: Story = {
|
|
35
|
+
render: () => (
|
|
36
|
+
<div className="flex flex-col gap-4 p-4">
|
|
37
|
+
{tones.map((tone) => (
|
|
38
|
+
<div key={tone} className="flex flex-col gap-1">
|
|
39
|
+
{sizes.map((size) => (
|
|
40
|
+
<Text key={size} size={size} tone={tone}>
|
|
41
|
+
{tone} {size}
|
|
42
|
+
</Text>
|
|
43
|
+
))}
|
|
44
|
+
</div>
|
|
45
|
+
))}
|
|
46
|
+
<Text size={{ initial: "base", md: "2xl" }}>Responsive: base, 2xl from md</Text>
|
|
47
|
+
</div>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
export const AsHeading: Story = {
|
|
54
|
+
render: () => (
|
|
55
|
+
<Text render={<h2 />} size="xl" tone="muted">
|
|
56
|
+
Heading
|
|
57
|
+
</Text>
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# ToastProvider
|
|
2
|
+
|
|
3
|
+
Mounts the toast region once, near the root of the app. Toasts are shown with `toast()`.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { ToastProvider } 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 | undefined`
|
|
20
|
+
|
|
21
|
+
Classes for the toast region, merged after the defaults: use it to move or resize the region.
|
|
22
|
+
|
|
23
|
+
### `limit`
|
|
24
|
+
Type: `number | undefined`, default: 3
|
|
25
|
+
|
|
26
|
+
The maximum number of toasts that can be displayed at once.
|
|
27
|
+
When the limit is exceeded, the oldest toasts are marked as `limited` (via the `data-limited`
|
|
28
|
+
attribute) rather than removed, so they can be hidden or animated out.
|
|
29
|
+
|
|
30
|
+
### `timeout`
|
|
31
|
+
Type: `number | undefined`, default: 5000
|
|
32
|
+
|
|
33
|
+
The default amount of time (in ms) before a toast is auto dismissed.
|
|
34
|
+
A value of `0` will prevent the toast from being dismissed automatically.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Button, ButtonProps } from "./components/button.mjs";
|
|
2
|
+
import { Card, CardContent, CardContentProps, CardDescription, CardDescriptionProps, CardFooter, CardFooterProps, CardHeader, CardHeaderProps, CardProps, CardTitle, CardTitleProps } from "./components/card.mjs";
|
|
3
|
+
import { Checkbox, CheckboxProps } from "./components/checkbox.mjs";
|
|
4
|
+
import { Dialog, DialogClose, DialogCloseProps, DialogContent, DialogContentProps, DialogDescription, DialogDescriptionProps, DialogFooter, DialogFooterProps, DialogHeader, DialogHeaderProps, DialogProps, DialogTitle, DialogTitleProps, DialogTrigger, DialogTriggerProps } from "./components/dialog.mjs";
|
|
5
|
+
import { Field, FieldDescription, FieldDescriptionProps, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps } from "./components/field.mjs";
|
|
6
|
+
import { Input, InputProps } from "./components/input.mjs";
|
|
7
|
+
import { Menu, MenuContent, MenuContentProps, MenuGroup, MenuGroupProps, MenuItem, MenuItemProps, MenuLabel, MenuLabelProps, MenuProps, MenuSeparator, MenuSeparatorProps, MenuTrigger, MenuTriggerProps } from "./components/menu.mjs";
|
|
8
|
+
import { Select, SelectContent, SelectContentProps, SelectGroup, SelectGroupProps, SelectItem, SelectItemProps, SelectLabel, SelectLabelProps, SelectProps, SelectSeparator, SelectSeparatorProps, SelectTrigger, SelectTriggerProps, SelectValue, SelectValueProps } from "./components/select.mjs";
|
|
9
|
+
import { Stack, StackProps } from "./components/stack.mjs";
|
|
10
|
+
import { ToastProvider, ToastProviderProps, toast } from "./components/toast.mjs";
|
|
11
|
+
import { Text, TextProps } from "./components/text.mjs";
|
|
12
|
+
export { Button, type ButtonProps, Card, CardContent, type CardContentProps, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps, Checkbox, type CheckboxProps, Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderProps, type DialogProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, Field, FieldDescription, type FieldDescriptionProps, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, Input, type InputProps, Menu, MenuContent, type MenuContentProps, MenuGroup, type MenuGroupProps, MenuItem, type MenuItemProps, MenuLabel, type MenuLabelProps, type MenuProps, MenuSeparator, type MenuSeparatorProps, MenuTrigger, type MenuTriggerProps, Select, SelectContent, type SelectContentProps, SelectGroup, type SelectGroupProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, type SelectProps, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, Stack, type StackProps, Text, type TextProps, ToastProvider, type ToastProviderProps, toast };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Button } from "./components/button.mjs";
|
|
2
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/card.mjs";
|
|
3
|
+
import { Checkbox } from "./components/checkbox.mjs";
|
|
4
|
+
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./components/dialog.mjs";
|
|
5
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "./components/field.mjs";
|
|
6
|
+
import { Input } from "./components/input.mjs";
|
|
7
|
+
import { Menu, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger } from "./components/menu.mjs";
|
|
8
|
+
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from "./components/select.mjs";
|
|
9
|
+
import { Stack } from "./components/stack.mjs";
|
|
10
|
+
import { ToastProvider, toast } from "./components/toast.mjs";
|
|
11
|
+
import { Text } from "./components/text.mjs";
|
|
12
|
+
export { Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Field, FieldDescription, FieldError, FieldLabel, Input, Menu, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Stack, Text, ToastProvider, toast };
|
package/dist/lib/cn.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
|
+
// src/lib/cn.ts
|
|
4
|
+
const twMerge = extendTailwindMerge({ extend: { classGroups: { "border-w": ["border-ui"] } } });
|
|
5
|
+
/** Joins class names; on conflicts the last one wins, so a consumer's `className` beats the internal classes. */
|
|
6
|
+
function cn(...inputs) {
|
|
7
|
+
return twMerge(clsx(inputs));
|
|
8
|
+
}
|
|
9
|
+
export { cn };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const breakpoints: readonly ["initial", "sm", "md", "lg", "xl", "2xl"];
|
|
2
|
+
export type Breakpoint = (typeof breakpoints)[number];
|
|
3
|
+
/** A value for every breakpoint that needs one, mobile-first: `initial` has no media query. */
|
|
4
|
+
export type Responsive<V extends string> = V | { [B in Breakpoint]?: V; };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/lib/responsive.ts
|
|
2
|
+
const breakpoints = [
|
|
3
|
+
"initial",
|
|
4
|
+
"sm",
|
|
5
|
+
"md",
|
|
6
|
+
"lg",
|
|
7
|
+
"xl",
|
|
8
|
+
"2xl"
|
|
9
|
+
];
|
|
10
|
+
function classes(table, value, fallback) {
|
|
11
|
+
const byBreakpoint = typeof value === "object" ? value : value === void 0 ? {} : { initial: value };
|
|
12
|
+
return breakpoints.map((bp) => {
|
|
13
|
+
const v = byBreakpoint[bp] ?? (bp === "initial" ? fallback : void 0);
|
|
14
|
+
return v === void 0 ? void 0 : table[v][breakpoints.indexOf(bp)];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { breakpoints, classes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robzepdev/trama",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=24"
|
|
7
|
+
},
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"**/*.css"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"./styles.css": "./styles.css",
|
|
17
|
+
"./themes/*.css": "./themes/*.css"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/RobertoZeppilli/ui-library.git"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"dist",
|
|
26
|
+
"styles.css",
|
|
27
|
+
"themes"
|
|
28
|
+
],
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^19",
|
|
31
|
+
"react-dom": "^19",
|
|
32
|
+
"tailwindcss": "^4"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@base-ui/react": "^1.9.0",
|
|
36
|
+
"clsx": "^2.1.1",
|
|
37
|
+
"tailwind-merge": "^3.7.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@changesets/cli": "^3.0.3",
|
|
41
|
+
"@kjanat/actionlint": "^1.17.1",
|
|
42
|
+
"@storybook/addon-a11y": "^10.6.8",
|
|
43
|
+
"@storybook/addon-docs": "10.6.8",
|
|
44
|
+
"@storybook/addon-themes": "^10.6.8",
|
|
45
|
+
"@storybook/addon-vitest": "^10.6.8",
|
|
46
|
+
"@storybook/react-vite": "^10.6.8",
|
|
47
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
48
|
+
"@types/react": "^19.3.0",
|
|
49
|
+
"@vitest/browser-playwright": "^5.1.1",
|
|
50
|
+
"playwright": "^1.65.1",
|
|
51
|
+
"react": "^19.3.1",
|
|
52
|
+
"react-dom": "^19.3.1",
|
|
53
|
+
"storybook": "^10.6.8",
|
|
54
|
+
"tailwindcss": "^4.3.5",
|
|
55
|
+
"tsdown": "^0.23.7",
|
|
56
|
+
"typescript": "^7.0.2",
|
|
57
|
+
"vitest": "^5.1.1"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"test": "vitest run --passWithNoTests",
|
|
61
|
+
"typecheck": "tsc",
|
|
62
|
+
"build": "tsdown && node scripts/agent-docs.ts",
|
|
63
|
+
"build:docs": "node scripts/agent-docs.ts",
|
|
64
|
+
"build:storybook": "storybook build",
|
|
65
|
+
"changeset": "changeset",
|
|
66
|
+
"lint:workflows": "actionlint .github/workflows/release.yml",
|
|
67
|
+
"pack:check": "pnpm pack --dry-run",
|
|
68
|
+
"build:example": "pnpm build && pnpm --filter trama-example-next build"
|
|
69
|
+
}
|
|
6
70
|
}
|