@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,127 @@
1
+ "use client";
2
+ import { Select as Select$1 } from "@base-ui/react/select";
3
+ import { createContext, useContext, useState } from "react";
4
+ import { cn } from "../lib/cn.mjs";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/select.tsx
7
+ function merge(base, className) {
8
+ return (state) => cn(base, typeof className === "function" ? className(state) : className);
9
+ }
10
+ const TriggerContext = createContext([null, () => {}]);
11
+ /** Groups all parts of the select. Doesn't render an element. */
12
+ function Select(props) {
13
+ const trigger = useState(null);
14
+ return /* @__PURE__ */ jsx(TriggerContext, {
15
+ value: trigger,
16
+ children: /* @__PURE__ */ jsx(Select$1.Root, { ...props })
17
+ });
18
+ }
19
+ /** Button that opens the popup. Put `SelectValue` inside it. */
20
+ function SelectTrigger({ className, children, ref, ...props }) {
21
+ const [, setTrigger] = useContext(TriggerContext);
22
+ return /* @__PURE__ */ jsxs(Select$1.Trigger, {
23
+ "data-slot": "select-trigger",
24
+ ...props,
25
+ ref: (node) => {
26
+ setTrigger(node);
27
+ if (typeof ref === "function") ref(node);
28
+ else if (ref) ref.current = node;
29
+ },
30
+ className: merge(cn("inline-flex h-9 items-center justify-between gap-2 rounded-md border-ui border-input bg-background px-3 text-sm text-foreground whitespace-nowrap", "outline-hidden focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "data-popup-open:border-ring data-disabled:cursor-not-allowed data-disabled:opacity-50 data-placeholder:text-muted-foreground"), className),
31
+ children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
32
+ "data-slot": "select-icon",
33
+ className: "text-muted-foreground",
34
+ children: /* @__PURE__ */ jsx("svg", {
35
+ viewBox: "0 0 16 16",
36
+ className: "size-4",
37
+ fill: "none",
38
+ stroke: "currentColor",
39
+ strokeWidth: "2",
40
+ "aria-hidden": "true",
41
+ children: /* @__PURE__ */ jsx("path", { d: "M4 6l4 4 4-4" })
42
+ })
43
+ })]
44
+ });
45
+ }
46
+ /** Shows the label of the selected item, or `placeholder` when nothing is selected. */
47
+ function SelectValue({ className, ...props }) {
48
+ return /* @__PURE__ */ jsx(Select$1.Value, {
49
+ "data-slot": "select-value",
50
+ ...props,
51
+ className: merge("truncate", className)
52
+ });
53
+ }
54
+ /** Popup with the list of items, in a portal. It takes the theme and scheme of the subtree the trigger is in. */
55
+ function SelectContent({ className, children, side, align, sideOffset = 4, alignItemWithTrigger, ...props }) {
56
+ const [trigger] = useContext(TriggerContext);
57
+ return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(Select$1.Positioner, {
58
+ ref: (node) => {
59
+ if (!node || !trigger) return;
60
+ for (const key of ["theme", "scheme"]) {
61
+ const owner = trigger.closest(`[data-${key}]`);
62
+ const value = owner?.dataset[key];
63
+ if (value === void 0 || owner === document.documentElement) delete node.dataset[key];
64
+ else node.dataset[key] = value;
65
+ }
66
+ },
67
+ side,
68
+ align,
69
+ sideOffset,
70
+ alignItemWithTrigger,
71
+ className: "z-50",
72
+ children: /* @__PURE__ */ jsx(Select$1.Popup, {
73
+ "data-slot": "select-content",
74
+ ...props,
75
+ className: merge("max-h-(--available-height) min-w-(--anchor-width) overflow-y-auto rounded-lg border-ui border-border bg-popover p-1 font-sans text-popover-foreground shadow-md outline-hidden", className),
76
+ children: /* @__PURE__ */ jsx(Select$1.List, { children })
77
+ })
78
+ }) });
79
+ }
80
+ /** One choice. `value` is what `onValueChange` receives. */
81
+ function SelectItem({ className, children, ...props }) {
82
+ return /* @__PURE__ */ jsxs(Select$1.Item, {
83
+ "data-slot": "select-item",
84
+ ...props,
85
+ className: merge(cn("grid cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none", "data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50"), className),
86
+ children: [/* @__PURE__ */ jsx(Select$1.ItemIndicator, {
87
+ "data-slot": "select-item-indicator",
88
+ className: "col-start-1",
89
+ children: /* @__PURE__ */ jsx("svg", {
90
+ viewBox: "0 0 16 16",
91
+ className: "size-4",
92
+ fill: "none",
93
+ stroke: "currentColor",
94
+ strokeWidth: "2",
95
+ "aria-hidden": "true",
96
+ children: /* @__PURE__ */ jsx("path", { d: "M3.5 8.5l3 3 6-7" })
97
+ })
98
+ }), /* @__PURE__ */ jsx(Select$1.ItemText, {
99
+ className: "col-start-2",
100
+ children
101
+ })]
102
+ });
103
+ }
104
+ /** Groups items under a `SelectLabel`. */
105
+ function SelectGroup(props) {
106
+ return /* @__PURE__ */ jsx(Select$1.Group, {
107
+ "data-slot": "select-group",
108
+ ...props
109
+ });
110
+ }
111
+ /** Label of a `SelectGroup`. */
112
+ function SelectLabel({ className, ...props }) {
113
+ return /* @__PURE__ */ jsx(Select$1.GroupLabel, {
114
+ "data-slot": "select-label",
115
+ ...props,
116
+ className: merge("px-2 py-1.5 text-xs text-muted-foreground", className)
117
+ });
118
+ }
119
+ /** Line between items or groups. */
120
+ function SelectSeparator({ className, ...props }) {
121
+ return /* @__PURE__ */ jsx(Select$1.Separator, {
122
+ "data-slot": "select-separator",
123
+ ...props,
124
+ className: merge("-mx-1 my-1 h-(--ui-border-width) bg-border", className)
125
+ });
126
+ }
127
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue };
@@ -0,0 +1,48 @@
1
+ import { useRender } from "@base-ui/react/use-render";
2
+ import { Responsive } from "../lib/responsive.mjs";
3
+ declare const direction: {
4
+ readonly row: readonly ["flex-row", "sm:flex-row", "md:flex-row", "lg:flex-row", "xl:flex-row", "2xl:flex-row"];
5
+ readonly column: readonly ["flex-col", "sm:flex-col", "md:flex-col", "lg:flex-col", "xl:flex-col", "2xl:flex-col"];
6
+ };
7
+ declare const gap: {
8
+ readonly "0": readonly ["gap-0", "sm:gap-0", "md:gap-0", "lg:gap-0", "xl:gap-0", "2xl:gap-0"];
9
+ readonly "1": readonly ["gap-1", "sm:gap-1", "md:gap-1", "lg:gap-1", "xl:gap-1", "2xl:gap-1"];
10
+ readonly "2": readonly ["gap-2", "sm:gap-2", "md:gap-2", "lg:gap-2", "xl:gap-2", "2xl:gap-2"];
11
+ readonly "3": readonly ["gap-3", "sm:gap-3", "md:gap-3", "lg:gap-3", "xl:gap-3", "2xl:gap-3"];
12
+ readonly "4": readonly ["gap-4", "sm:gap-4", "md:gap-4", "lg:gap-4", "xl:gap-4", "2xl:gap-4"];
13
+ readonly "5": readonly ["gap-5", "sm:gap-5", "md:gap-5", "lg:gap-5", "xl:gap-5", "2xl:gap-5"];
14
+ readonly "6": readonly ["gap-6", "sm:gap-6", "md:gap-6", "lg:gap-6", "xl:gap-6", "2xl:gap-6"];
15
+ readonly "8": readonly ["gap-8", "sm:gap-8", "md:gap-8", "lg:gap-8", "xl:gap-8", "2xl:gap-8"];
16
+ };
17
+ declare const align: {
18
+ readonly start: readonly ["items-start", "sm:items-start", "md:items-start", "lg:items-start", "xl:items-start", "2xl:items-start"];
19
+ readonly center: readonly ["items-center", "sm:items-center", "md:items-center", "lg:items-center", "xl:items-center", "2xl:items-center"];
20
+ readonly end: readonly ["items-end", "sm:items-end", "md:items-end", "lg:items-end", "xl:items-end", "2xl:items-end"];
21
+ readonly stretch: readonly ["items-stretch", "sm:items-stretch", "md:items-stretch", "lg:items-stretch", "xl:items-stretch", "2xl:items-stretch"];
22
+ readonly baseline: readonly ["items-baseline", "sm:items-baseline", "md:items-baseline", "lg:items-baseline", "xl:items-baseline", "2xl:items-baseline"];
23
+ };
24
+ declare const justify: {
25
+ readonly start: readonly ["justify-start", "sm:justify-start", "md:justify-start", "lg:justify-start", "xl:justify-start", "2xl:justify-start"];
26
+ readonly center: readonly ["justify-center", "sm:justify-center", "md:justify-center", "lg:justify-center", "xl:justify-center", "2xl:justify-center"];
27
+ readonly end: readonly ["justify-end", "sm:justify-end", "md:justify-end", "lg:justify-end", "xl:justify-end", "2xl:justify-end"];
28
+ readonly between: readonly ["justify-between", "sm:justify-between", "md:justify-between", "lg:justify-between", "xl:justify-between", "2xl:justify-between"];
29
+ };
30
+ declare const wrap: {
31
+ readonly nowrap: readonly ["flex-nowrap", "sm:flex-nowrap", "md:flex-nowrap", "lg:flex-nowrap", "xl:flex-nowrap", "2xl:flex-nowrap"];
32
+ readonly wrap: readonly ["flex-wrap", "sm:flex-wrap", "md:flex-wrap", "lg:flex-wrap", "xl:flex-wrap", "2xl:flex-wrap"];
33
+ };
34
+ export interface StackProps extends useRender.ComponentProps<"div"> {
35
+ /** Main axis. Accepts a responsive object. @default "column" */
36
+ direction?: Responsive<keyof typeof direction>;
37
+ /** Space between children, on the `--spacing` scale (`"2"` is `gap-2`). Accepts a responsive object. */
38
+ gap?: Responsive<keyof typeof gap>;
39
+ /** Cross-axis alignment of children. Accepts a responsive object. */
40
+ align?: Responsive<keyof typeof align>;
41
+ /** Main-axis distribution of children. Accepts a responsive object. */
42
+ justify?: Responsive<keyof typeof justify>;
43
+ /** Whether children wrap onto several lines. Accepts a responsive object. */
44
+ wrap?: Responsive<keyof typeof wrap>;
45
+ }
46
+ /** 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`. */
47
+ export declare function Stack({ direction: dir, gap: g, align: a, justify: j, wrap: w, className, render, ...props }: StackProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
48
+ export {};
@@ -0,0 +1,196 @@
1
+ "use client";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import { cn } from "../lib/cn.mjs";
4
+ import { classes } from "../lib/responsive.mjs";
5
+ // src/components/stack.tsx
6
+ const direction = {
7
+ row: [
8
+ "flex-row",
9
+ "sm:flex-row",
10
+ "md:flex-row",
11
+ "lg:flex-row",
12
+ "xl:flex-row",
13
+ "2xl:flex-row"
14
+ ],
15
+ column: [
16
+ "flex-col",
17
+ "sm:flex-col",
18
+ "md:flex-col",
19
+ "lg:flex-col",
20
+ "xl:flex-col",
21
+ "2xl:flex-col"
22
+ ]
23
+ };
24
+ const gap = {
25
+ "0": [
26
+ "gap-0",
27
+ "sm:gap-0",
28
+ "md:gap-0",
29
+ "lg:gap-0",
30
+ "xl:gap-0",
31
+ "2xl:gap-0"
32
+ ],
33
+ "1": [
34
+ "gap-1",
35
+ "sm:gap-1",
36
+ "md:gap-1",
37
+ "lg:gap-1",
38
+ "xl:gap-1",
39
+ "2xl:gap-1"
40
+ ],
41
+ "2": [
42
+ "gap-2",
43
+ "sm:gap-2",
44
+ "md:gap-2",
45
+ "lg:gap-2",
46
+ "xl:gap-2",
47
+ "2xl:gap-2"
48
+ ],
49
+ "3": [
50
+ "gap-3",
51
+ "sm:gap-3",
52
+ "md:gap-3",
53
+ "lg:gap-3",
54
+ "xl:gap-3",
55
+ "2xl:gap-3"
56
+ ],
57
+ "4": [
58
+ "gap-4",
59
+ "sm:gap-4",
60
+ "md:gap-4",
61
+ "lg:gap-4",
62
+ "xl:gap-4",
63
+ "2xl:gap-4"
64
+ ],
65
+ "5": [
66
+ "gap-5",
67
+ "sm:gap-5",
68
+ "md:gap-5",
69
+ "lg:gap-5",
70
+ "xl:gap-5",
71
+ "2xl:gap-5"
72
+ ],
73
+ "6": [
74
+ "gap-6",
75
+ "sm:gap-6",
76
+ "md:gap-6",
77
+ "lg:gap-6",
78
+ "xl:gap-6",
79
+ "2xl:gap-6"
80
+ ],
81
+ "8": [
82
+ "gap-8",
83
+ "sm:gap-8",
84
+ "md:gap-8",
85
+ "lg:gap-8",
86
+ "xl:gap-8",
87
+ "2xl:gap-8"
88
+ ]
89
+ };
90
+ const align = {
91
+ start: [
92
+ "items-start",
93
+ "sm:items-start",
94
+ "md:items-start",
95
+ "lg:items-start",
96
+ "xl:items-start",
97
+ "2xl:items-start"
98
+ ],
99
+ center: [
100
+ "items-center",
101
+ "sm:items-center",
102
+ "md:items-center",
103
+ "lg:items-center",
104
+ "xl:items-center",
105
+ "2xl:items-center"
106
+ ],
107
+ end: [
108
+ "items-end",
109
+ "sm:items-end",
110
+ "md:items-end",
111
+ "lg:items-end",
112
+ "xl:items-end",
113
+ "2xl:items-end"
114
+ ],
115
+ stretch: [
116
+ "items-stretch",
117
+ "sm:items-stretch",
118
+ "md:items-stretch",
119
+ "lg:items-stretch",
120
+ "xl:items-stretch",
121
+ "2xl:items-stretch"
122
+ ],
123
+ baseline: [
124
+ "items-baseline",
125
+ "sm:items-baseline",
126
+ "md:items-baseline",
127
+ "lg:items-baseline",
128
+ "xl:items-baseline",
129
+ "2xl:items-baseline"
130
+ ]
131
+ };
132
+ const justify = {
133
+ start: [
134
+ "justify-start",
135
+ "sm:justify-start",
136
+ "md:justify-start",
137
+ "lg:justify-start",
138
+ "xl:justify-start",
139
+ "2xl:justify-start"
140
+ ],
141
+ center: [
142
+ "justify-center",
143
+ "sm:justify-center",
144
+ "md:justify-center",
145
+ "lg:justify-center",
146
+ "xl:justify-center",
147
+ "2xl:justify-center"
148
+ ],
149
+ end: [
150
+ "justify-end",
151
+ "sm:justify-end",
152
+ "md:justify-end",
153
+ "lg:justify-end",
154
+ "xl:justify-end",
155
+ "2xl:justify-end"
156
+ ],
157
+ between: [
158
+ "justify-between",
159
+ "sm:justify-between",
160
+ "md:justify-between",
161
+ "lg:justify-between",
162
+ "xl:justify-between",
163
+ "2xl:justify-between"
164
+ ]
165
+ };
166
+ const wrap = {
167
+ nowrap: [
168
+ "flex-nowrap",
169
+ "sm:flex-nowrap",
170
+ "md:flex-nowrap",
171
+ "lg:flex-nowrap",
172
+ "xl:flex-nowrap",
173
+ "2xl:flex-nowrap"
174
+ ],
175
+ wrap: [
176
+ "flex-wrap",
177
+ "sm:flex-wrap",
178
+ "md:flex-wrap",
179
+ "lg:flex-wrap",
180
+ "xl:flex-wrap",
181
+ "2xl:flex-wrap"
182
+ ]
183
+ };
184
+ /** 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`. */
185
+ function Stack({ direction: dir, gap: g, align: a, justify: j, wrap: w, className, render, ...props }) {
186
+ return useRender({
187
+ render,
188
+ defaultTagName: "div",
189
+ props: {
190
+ "data-slot": "stack",
191
+ ...props,
192
+ className: cn("flex", classes(direction, dir, "column"), classes(gap, g), classes(align, a), classes(justify, j), classes(wrap, w), className)
193
+ }
194
+ });
195
+ }
196
+ export { Stack };
@@ -0,0 +1,25 @@
1
+ import { useRender } from "@base-ui/react/use-render";
2
+ import { Responsive } from "../lib/responsive.mjs";
3
+ declare const size: {
4
+ readonly xs: readonly ["text-xs", "sm:text-xs", "md:text-xs", "lg:text-xs", "xl:text-xs", "2xl:text-xs"];
5
+ readonly sm: readonly ["text-sm", "sm:text-sm", "md:text-sm", "lg:text-sm", "xl:text-sm", "2xl:text-sm"];
6
+ readonly base: readonly ["text-base", "sm:text-base", "md:text-base", "lg:text-base", "xl:text-base", "2xl:text-base"];
7
+ readonly lg: readonly ["text-lg", "sm:text-lg", "md:text-lg", "lg:text-lg", "xl:text-lg", "2xl:text-lg"];
8
+ readonly xl: readonly ["text-xl", "sm:text-xl", "md:text-xl", "lg:text-xl", "xl:text-xl", "2xl:text-xl"];
9
+ readonly "2xl": readonly ["text-2xl", "sm:text-2xl", "md:text-2xl", "lg:text-2xl", "xl:text-2xl", "2xl:text-2xl"];
10
+ readonly "3xl": readonly ["text-3xl", "sm:text-3xl", "md:text-3xl", "lg:text-3xl", "xl:text-3xl", "2xl:text-3xl"];
11
+ };
12
+ declare const tone: {
13
+ readonly normal: "text-foreground";
14
+ readonly muted: "text-muted-foreground";
15
+ readonly destructive: "text-destructive";
16
+ };
17
+ export interface TextProps extends useRender.ComponentProps<"p"> {
18
+ /** Size on the theme's type scale. Accepts a responsive object. @default "base" */
19
+ size?: Responsive<keyof typeof size>;
20
+ /** Semantic text color. @default "normal" */
21
+ tone?: keyof typeof tone;
22
+ }
23
+ /** 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 />}`. */
24
+ export declare function Text({ size: s, tone: t, className, render, ...props }: TextProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
25
+ export {};
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import { cn } from "../lib/cn.mjs";
4
+ import { classes } from "../lib/responsive.mjs";
5
+ // src/components/text.tsx
6
+ const size = {
7
+ xs: [
8
+ "text-xs",
9
+ "sm:text-xs",
10
+ "md:text-xs",
11
+ "lg:text-xs",
12
+ "xl:text-xs",
13
+ "2xl:text-xs"
14
+ ],
15
+ sm: [
16
+ "text-sm",
17
+ "sm:text-sm",
18
+ "md:text-sm",
19
+ "lg:text-sm",
20
+ "xl:text-sm",
21
+ "2xl:text-sm"
22
+ ],
23
+ base: [
24
+ "text-base",
25
+ "sm:text-base",
26
+ "md:text-base",
27
+ "lg:text-base",
28
+ "xl:text-base",
29
+ "2xl:text-base"
30
+ ],
31
+ lg: [
32
+ "text-lg",
33
+ "sm:text-lg",
34
+ "md:text-lg",
35
+ "lg:text-lg",
36
+ "xl:text-lg",
37
+ "2xl:text-lg"
38
+ ],
39
+ xl: [
40
+ "text-xl",
41
+ "sm:text-xl",
42
+ "md:text-xl",
43
+ "lg:text-xl",
44
+ "xl:text-xl",
45
+ "2xl:text-xl"
46
+ ],
47
+ "2xl": [
48
+ "text-2xl",
49
+ "sm:text-2xl",
50
+ "md:text-2xl",
51
+ "lg:text-2xl",
52
+ "xl:text-2xl",
53
+ "2xl:text-2xl"
54
+ ],
55
+ "3xl": [
56
+ "text-3xl",
57
+ "sm:text-3xl",
58
+ "md:text-3xl",
59
+ "lg:text-3xl",
60
+ "xl:text-3xl",
61
+ "2xl:text-3xl"
62
+ ]
63
+ };
64
+ const tone = {
65
+ normal: "text-foreground",
66
+ muted: "text-muted-foreground",
67
+ destructive: "text-destructive"
68
+ };
69
+ /** 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 />}`. */
70
+ function Text({ size: s, tone: t = "normal", className, render, ...props }) {
71
+ return useRender({
72
+ render,
73
+ defaultTagName: "p",
74
+ props: {
75
+ "data-slot": "text",
76
+ ...props,
77
+ className: cn(classes(size, s, "base"), tone[t], className)
78
+ }
79
+ });
80
+ }
81
+ export { Text };
@@ -0,0 +1,15 @@
1
+ import { Toast } from "@base-ui/react/toast";
2
+ declare const manager: import("@base-ui/react").ToastManager<any>;
3
+ /** Shows a toast from anywhere in the app. Needs a `ToastProvider` mounted. Returns the toast id. */
4
+ export declare function toast(options: Parameters<typeof manager.add>[0]): string;
5
+ export declare namespace toast {
6
+ var _a: (id?: string) => void;
7
+ export { _a as close };
8
+ }
9
+ export interface ToastProviderProps extends Omit<Toast.Provider.Props, "toastManager"> {
10
+ /** Classes for the toast region, merged after the defaults: use it to move or resize the region. */
11
+ className?: string | undefined;
12
+ }
13
+ /** Mounts the toast region once, near the root of the app. Toasts are shown with `toast()`. */
14
+ export declare function ToastProvider({ children, className, ...props }: ToastProviderProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ import { Toast } from "@base-ui/react/toast";
3
+ import { cn } from "../lib/cn.mjs";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/components/toast.tsx
6
+ const manager = Toast.createToastManager();
7
+ /** Shows a toast from anywhere in the app. Needs a `ToastProvider` mounted. Returns the toast id. */
8
+ function toast(options) {
9
+ return manager.add(options);
10
+ }
11
+ /** Closes the toast with the given id, or all toasts when called without one. */
12
+ toast.close = manager.close;
13
+ function ToastList() {
14
+ const { toasts } = Toast.useToastManager();
15
+ return toasts.map((t) => /* @__PURE__ */ jsxs(Toast.Root, {
16
+ toast: t,
17
+ "data-slot": "toast",
18
+ className: cn("flex w-full items-start gap-2 rounded-lg border-ui border-border bg-popover p-4 text-popover-foreground shadow-md transition-[opacity,translate] duration-200 motion-reduce:transition-none", "data-starting-style:translate-y-2 data-starting-style:opacity-0 data-ending-style:opacity-0"),
19
+ children: [/* @__PURE__ */ jsxs(Toast.Content, {
20
+ "data-slot": "toast-content",
21
+ className: "grid flex-1 gap-1",
22
+ children: [/* @__PURE__ */ jsx(Toast.Title, {
23
+ "data-slot": "toast-title",
24
+ className: "text-sm leading-none font-semibold"
25
+ }), /* @__PURE__ */ jsx(Toast.Description, {
26
+ "data-slot": "toast-description",
27
+ className: "text-sm text-muted-foreground"
28
+ })]
29
+ }), /* @__PURE__ */ jsx(Toast.Close, {
30
+ "data-slot": "toast-close",
31
+ "aria-label": "Close",
32
+ className: "rounded-sm px-1 text-sm leading-none text-muted-foreground outline-offset-2 hover:text-foreground focus-visible:outline-2",
33
+ children: "×"
34
+ })]
35
+ }, t.id));
36
+ }
37
+ /** Mounts the toast region once, near the root of the app. Toasts are shown with `toast()`. */
38
+ function ToastProvider({ children, className, ...props }) {
39
+ return /* @__PURE__ */ jsxs(Toast.Provider, {
40
+ toastManager: manager,
41
+ ...props,
42
+ children: [children, /* @__PURE__ */ jsx(Toast.Portal, { children: /* @__PURE__ */ jsx(Toast.Viewport, {
43
+ "data-slot": "toast-viewport",
44
+ className: cn("fixed right-4 bottom-4 z-50 flex w-[calc(100%-var(--spacing)*8)] max-w-sm flex-col gap-2 font-sans", className),
45
+ children: /* @__PURE__ */ jsx(ToastList, {})
46
+ }) })]
47
+ });
48
+ }
49
+ export { ToastProvider, toast };
@@ -0,0 +1,84 @@
1
+ # Button
2
+
3
+ Button with the shadcn/ui API on top of Base UI. Polymorphism goes through `render`, not `asChild` or `as`.
4
+
5
+ ```tsx
6
+ import { Button } 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: ButtonState) => 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
+ ### `disabled`
20
+ Type: `boolean | undefined`
21
+
22
+ Whether the button should ignore user interaction.
23
+
24
+ ### `focusableWhenDisabled`
25
+ Type: `boolean | undefined`, default: false
26
+
27
+ Whether the button should be focusable when disabled.
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, ButtonState> | 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
+ ### `size`
45
+ Type: `"default" | "icon" | "icon-lg" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs" | undefined`, default: "default"
46
+
47
+ Height and padding. Same values as shadcn/ui.
48
+
49
+ ### `style`
50
+ Type: `CSSProperties | ((state: ButtonState) => CSSProperties | undefined) | undefined`
51
+
52
+ Style applied to the element, or a function that
53
+ returns a style object based on the component's state.
54
+
55
+ ### `variant`
56
+ Type: `"default" | "destructive" | "ghost" | "link" | "outline" | "secondary" | undefined`, default: "default"
57
+
58
+ Visual emphasis. Same values as shadcn/ui.
59
+
60
+ ## Examples
61
+
62
+ ```tsx
63
+ export const Variants: Story = {
64
+ render: () => (
65
+ <div className="flex flex-col gap-4 p-4">
66
+ {variants.map((variant) => (
67
+ <div key={variant} className="flex flex-wrap items-center gap-2">
68
+ {sizes.map((size) =>
69
+ size.startsWith("icon") ? (
70
+ <Button key={size} variant={variant} size={size} aria-label={`${variant} ${size}`}>
71
+ +
72
+ </Button>
73
+ ) : (
74
+ <Button key={size} variant={variant} size={size}>
75
+ {variant} {size}
76
+ </Button>
77
+ ),
78
+ )}
79
+ </div>
80
+ ))}
81
+ </div>
82
+ ),
83
+ };
84
+ ```
@@ -0,0 +1,41 @@
1
+ # CardContent
2
+
3
+ Main body of the card.
4
+
5
+ ```tsx
6
+ import { CardContent } 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
+ ## Examples
22
+
23
+ ```tsx
24
+ export const Default: Story = {
25
+ render: () => (
26
+ <div className="p-4">
27
+ <Card className="max-w-sm">
28
+ <CardHeader>
29
+ <CardTitle>Team plan</CardTitle>
30
+ <CardDescription>Up to ten members, billed monthly.</CardDescription>
31
+ </CardHeader>
32
+ <CardContent>Includes shared workspaces and priority support.</CardContent>
33
+ <CardFooter>
34
+ <Button>Upgrade</Button>
35
+ <Button variant="outline">Cancel</Button>
36
+ </CardFooter>
37
+ </Card>
38
+ </div>
39
+ ),
40
+ };
41
+ ```