@shadow-js/ui 0.0.0-stage → 1.0.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 +24 -0
- package/LICENSE +21 -0
- package/README.md +598 -2
- package/dist/cli.mjs +2293 -0
- package/dist/dev/cli/schema.d.ts +73 -0
- package/dist/dev/index.d.ts +6 -0
- package/dist/dev/index.js +5 -0
- package/dist/dev/locales/ar.d.ts +141 -0
- package/dist/dev/locales/ar.js +128 -0
- package/dist/dev/locales/ar.js.map +1 -0
- package/dist/dev/locales/en.d.ts +141 -0
- package/dist/dev/locales/en.js +128 -0
- package/dist/dev/locales/en.js.map +1 -0
- package/dist/dev/registry/utils/utils.d.ts +29 -0
- package/dist/dev/registry/utils/utils.js +27 -0
- package/dist/dev/registry/utils/utils.js.map +1 -0
- package/dist/dev/theme/theme-logic.d.ts +187 -0
- package/dist/dev/theme/theme-logic.js +184 -0
- package/dist/dev/theme/theme-logic.js.map +1 -0
- package/dist/dev/theme/theme-provider.d.ts +90 -0
- package/dist/dev/theme/theme-provider.js +150 -0
- package/dist/dev/theme/theme-provider.js.map +1 -0
- package/dist/prod/index.js +1 -0
- package/dist/prod/locales/ar.js +2 -0
- package/dist/prod/locales/ar.js.map +1 -0
- package/dist/prod/locales/en.js +2 -0
- package/dist/prod/locales/en.js.map +1 -0
- package/dist/prod/registry/utils/utils.js +2 -0
- package/dist/prod/registry/utils/utils.js.map +1 -0
- package/dist/prod/theme/theme-logic.js +2 -0
- package/dist/prod/theme/theme-logic.js.map +1 -0
- package/dist/prod/theme/theme-provider.js +2 -0
- package/dist/prod/theme/theme-provider.js.map +1 -0
- package/package.json +102 -4
- package/registry/accordion/accordion.tsx +210 -0
- package/registry/accordion/item.json +4 -0
- package/registry/alert/alert.tsx +200 -0
- package/registry/alert/item.json +4 -0
- package/registry/alert-dialog/alert-dialog.tsx +530 -0
- package/registry/alert-dialog/item.json +4 -0
- package/registry/aspect-ratio/aspect-ratio.tsx +71 -0
- package/registry/aspect-ratio/item.json +4 -0
- package/registry/attachment/attachment.tsx +459 -0
- package/registry/attachment/item.json +4 -0
- package/registry/avatar/avatar.tsx +385 -0
- package/registry/avatar/item.json +4 -0
- package/registry/badge/badge.tsx +108 -0
- package/registry/badge/item.json +4 -0
- package/registry/breadcrumb/breadcrumb.tsx +354 -0
- package/registry/breadcrumb/item.json +4 -0
- package/registry/bubble/bubble.tsx +260 -0
- package/registry/bubble/item.json +4 -0
- package/registry/button/button.tsx +125 -0
- package/registry/button/item.json +4 -0
- package/registry/button-group/button-group.tsx +189 -0
- package/registry/button-group/item.json +4 -0
- package/registry/calendar/calendar.tsx +348 -0
- package/registry/calendar/item.json +4 -0
- package/registry/card/card.tsx +311 -0
- package/registry/card/item.json +4 -0
- package/registry/carousel/carousel.tsx +851 -0
- package/registry/carousel/item.json +4 -0
- package/registry/chart/chart.tsx +1956 -0
- package/registry/chart/item.json +4 -0
- package/registry/chart-scale/chart-scale.ts +670 -0
- package/registry/chart-scale/item.json +5 -0
- package/registry/checkbox/checkbox.tsx +79 -0
- package/registry/checkbox/item.json +4 -0
- package/registry/code-block/code-block.tsx +470 -0
- package/registry/code-block/item.json +4 -0
- package/registry/collapsible/collapsible.tsx +117 -0
- package/registry/collapsible/item.json +4 -0
- package/registry/combobox/combobox.tsx +977 -0
- package/registry/combobox/item.json +4 -0
- package/registry/command/command.tsx +757 -0
- package/registry/command/item.json +4 -0
- package/registry/context-menu/context-menu.tsx +697 -0
- package/registry/context-menu/item.json +4 -0
- package/registry/data-table/data-table.tsx +437 -0
- package/registry/data-table/item.json +4 -0
- package/registry/date-picker/date-picker.tsx +349 -0
- package/registry/date-picker/item.json +4 -0
- package/registry/dialog/dialog.tsx +412 -0
- package/registry/dialog/item.json +4 -0
- package/registry/direction/direction.tsx +88 -0
- package/registry/direction/item.json +4 -0
- package/registry/drawer/drawer.tsx +787 -0
- package/registry/drawer/item.json +4 -0
- package/registry/dropdown-menu/dropdown-menu.tsx +692 -0
- package/registry/dropdown-menu/item.json +4 -0
- package/registry/empty/empty.tsx +240 -0
- package/registry/empty/item.json +4 -0
- package/registry/field/field.tsx +624 -0
- package/registry/field/item.json +4 -0
- package/registry/form/form.tsx +1112 -0
- package/registry/form/item.json +4 -0
- package/registry/hover-card/hover-card.tsx +144 -0
- package/registry/hover-card/item.json +4 -0
- package/registry/icons/icons.tsx +1691 -0
- package/registry/icons/item.json +4 -0
- package/registry/input/input.tsx +43 -0
- package/registry/input/item.json +4 -0
- package/registry/input-group/input-group.tsx +315 -0
- package/registry/input-group/item.json +4 -0
- package/registry/input-otp/input-otp.tsx +329 -0
- package/registry/input-otp/item.json +4 -0
- package/registry/item/item.json +4 -0
- package/registry/item/item.tsx +439 -0
- package/registry/kbd/item.json +4 -0
- package/registry/kbd/kbd.tsx +65 -0
- package/registry/label/item.json +4 -0
- package/registry/label/label.tsx +60 -0
- package/registry/marker/item.json +4 -0
- package/registry/marker/marker.tsx +175 -0
- package/registry/menubar/item.json +4 -0
- package/registry/menubar/menubar.tsx +694 -0
- package/registry/message/item.json +4 -0
- package/registry/message/message.tsx +280 -0
- package/registry/message-scroller/item.json +4 -0
- package/registry/message-scroller/message-scroller.tsx +262 -0
- package/registry/native-select/item.json +4 -0
- package/registry/native-select/native-select.tsx +113 -0
- package/registry/navigation-menu/item.json +4 -0
- package/registry/navigation-menu/navigation-menu.tsx +362 -0
- package/registry/pagination/item.json +4 -0
- package/registry/pagination/pagination.tsx +460 -0
- package/registry/password-input/item.json +5 -0
- package/registry/password-input/password-input.tsx +494 -0
- package/registry/popover/item.json +4 -0
- package/registry/popover/popover.tsx +284 -0
- package/registry/progress/item.json +4 -0
- package/registry/progress/progress.tsx +190 -0
- package/registry/questionnaire/item.json +4 -0
- package/registry/questionnaire/questionnaire.tsx +569 -0
- package/registry/radio-group/item.json +4 -0
- package/registry/radio-group/radio-group.tsx +101 -0
- package/registry/resizable/item.json +4 -0
- package/registry/resizable/resizable.tsx +455 -0
- package/registry/scroll-area/item.json +4 -0
- package/registry/scroll-area/scroll-area.tsx +149 -0
- package/registry/select/item.json +4 -0
- package/registry/select/select.tsx +571 -0
- package/registry/separator/item.json +4 -0
- package/registry/separator/separator.tsx +52 -0
- package/registry/sheet/item.json +4 -0
- package/registry/sheet/sheet.tsx +476 -0
- package/registry/sidebar/item.json +4 -0
- package/registry/sidebar/sidebar.tsx +1870 -0
- package/registry/skeleton/item.json +4 -0
- package/registry/skeleton/skeleton.tsx +47 -0
- package/registry/slider/item.json +4 -0
- package/registry/slider/slider.tsx +149 -0
- package/registry/spinner/item.json +4 -0
- package/registry/spinner/spinner.tsx +51 -0
- package/registry/switch/item.json +4 -0
- package/registry/switch/switch.tsx +93 -0
- package/registry/table/item.json +4 -0
- package/registry/table/table.tsx +373 -0
- package/registry/tabs/item.json +4 -0
- package/registry/tabs/tabs.tsx +209 -0
- package/registry/textarea/item.json +4 -0
- package/registry/textarea/textarea.tsx +51 -0
- package/registry/toast/item.json +4 -0
- package/registry/toast/toast.tsx +949 -0
- package/registry/toggle/item.json +4 -0
- package/registry/toggle/toggle.tsx +110 -0
- package/registry/toggle-group/item.json +4 -0
- package/registry/toggle-group/toggle-group.tsx +189 -0
- package/registry/tooltip/item.json +4 -0
- package/registry/tooltip/tooltip.tsx +169 -0
- package/registry/trace/item.json +4 -0
- package/registry/trace/trace.tsx +356 -0
- package/registry/ui-strings/item.json +5 -0
- package/registry/ui-strings/ui-strings.tsx +454 -0
- package/registry/use-highlighted-code/item.json +5 -0
- package/registry/use-highlighted-code/use-highlighted-code.tsx +145 -0
- package/registry/use-mobile/item.json +5 -0
- package/registry/use-mobile/use-mobile.ts +46 -0
- package/registry/utils/item.json +5 -0
- package/registry/utils/utils.ts +38 -0
- package/registry.json +3274 -0
- package/styles/animations.css +321 -0
- package/styles/theme-core.css +55 -0
- package/styles/theme.css +12 -0
- package/styles/themes/gray.css +69 -0
- package/styles/themes/neutral.css +69 -0
- package/styles/themes/slate.css +69 -0
- package/styles/themes/stone.css +69 -0
- package/styles/themes/zinc.css +69 -0
- package/styles/typeset.css +251 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { splitProps } from "@shadow-js/core";
|
|
2
|
+
import type { ComponentProps, JSX } from "@shadow-js/web";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The class list of an alert for each `variant`. Use it to style another element like an alert.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { alertVariants } from "@/components/ui/alert";
|
|
12
|
+
*
|
|
13
|
+
* export function AlertBox() {
|
|
14
|
+
* return <section class={alertVariants({ variant: "destructive" })}>Payment failed.</section>;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
* @see {@link Alert}
|
|
19
|
+
*/
|
|
20
|
+
const alertVariants = cva(
|
|
21
|
+
"relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border bg-card px-4 py-3 text-sm text-card-foreground has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
default: "",
|
|
26
|
+
destructive:
|
|
27
|
+
"text-destructive *:data-[slot=alert-description]:text-destructive [&>svg]:text-current",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
variant: "default",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Props of {@link Alert}: the attributes of a `div` plus `variant`. The `variant` is `"default"`
|
|
38
|
+
* (the default) or `"destructive"`, which colors the text red. The rest are the element's
|
|
39
|
+
* attributes; `class` is merged with the variant classes.
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
* @see {@link Alert}
|
|
42
|
+
*/
|
|
43
|
+
export type AlertProps = ComponentProps<"div"> & VariantProps<typeof alertVariants>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A callout that draws attention to a message. It has `role="alert"`, which screen readers
|
|
47
|
+
* announce when it appears, so render it only for messages that deserve an interruption. Put an
|
|
48
|
+
* optional icon first, then {@link AlertTitle} and {@link AlertDescription}.
|
|
49
|
+
*
|
|
50
|
+
* Keyboard and ARIA: the alert is not interactive, so it has no keys. It has `role="alert"` and no
|
|
51
|
+
* accessible name, because its text is the message. Place the message text in the alert itself
|
|
52
|
+
* (the title and description), not in an attribute.
|
|
53
|
+
*
|
|
54
|
+
* Compared with shadcn/ui: `class` replaces `className`, and every part carries `data-slot`.
|
|
55
|
+
*
|
|
56
|
+
* @param props - The alert props: `variant` (`"default"` or `"destructive"`), `children`, and the
|
|
57
|
+
* `div` attributes.
|
|
58
|
+
* @returns The alert element.
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
62
|
+
* import { TriangleAlertIcon } from "@/components/ui/icons";
|
|
63
|
+
*
|
|
64
|
+
* export function SessionWarning() {
|
|
65
|
+
* return (
|
|
66
|
+
* <Alert variant="destructive">
|
|
67
|
+
* <TriangleAlertIcon />
|
|
68
|
+
* <AlertTitle>Error</AlertTitle>
|
|
69
|
+
* <AlertDescription>Your session has expired.</AlertDescription>
|
|
70
|
+
* </Alert>
|
|
71
|
+
* );
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
* @see {@link AlertTitle}
|
|
76
|
+
* @see {@link AlertDescription}
|
|
77
|
+
* @see {@link AlertProps}
|
|
78
|
+
*/
|
|
79
|
+
function Alert(props: AlertProps): JSX.Element {
|
|
80
|
+
const [local, rest] = splitProps(props, ["class", "variant", "children"]);
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
data-slot="alert"
|
|
84
|
+
role="alert"
|
|
85
|
+
class={cn(alertVariants({ variant: local.variant }), local.class)}
|
|
86
|
+
{...rest}
|
|
87
|
+
>
|
|
88
|
+
{local.children}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The title of an alert: a short, medium-weight line in the second column, next to the icon.
|
|
95
|
+
*
|
|
96
|
+
* @param props - The title props: `children` and the `div` attributes.
|
|
97
|
+
* @returns The title element.
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* import { Alert, AlertTitle } from "@/components/ui/alert";
|
|
101
|
+
*
|
|
102
|
+
* export function Heads() {
|
|
103
|
+
* return (
|
|
104
|
+
* <Alert>
|
|
105
|
+
* <AlertTitle>Heads up!</AlertTitle>
|
|
106
|
+
* </Alert>
|
|
107
|
+
* );
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
* @since 1.0.0
|
|
111
|
+
* @see {@link Alert}
|
|
112
|
+
*/
|
|
113
|
+
function AlertTitle(props: ComponentProps<"div">): JSX.Element {
|
|
114
|
+
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
data-slot="alert-title"
|
|
118
|
+
class={cn("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight", local.class)}
|
|
119
|
+
{...rest}
|
|
120
|
+
>
|
|
121
|
+
{local.children}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The body text of an alert, placed under the title in the second column. Paragraphs inside it
|
|
128
|
+
* get relaxed line height.
|
|
129
|
+
*
|
|
130
|
+
* @param props - The description props: `children` and the `div` attributes.
|
|
131
|
+
* @returns The description element.
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
135
|
+
*
|
|
136
|
+
* export function Tip() {
|
|
137
|
+
* return (
|
|
138
|
+
* <Alert>
|
|
139
|
+
* <AlertTitle>Tip</AlertTitle>
|
|
140
|
+
* <AlertDescription>You can add components to your app.</AlertDescription>
|
|
141
|
+
* </Alert>
|
|
142
|
+
* );
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
* @since 1.0.0
|
|
146
|
+
* @see {@link Alert}
|
|
147
|
+
*/
|
|
148
|
+
function AlertDescription(props: ComponentProps<"div">): JSX.Element {
|
|
149
|
+
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
data-slot="alert-description"
|
|
153
|
+
class={cn(
|
|
154
|
+
"col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed",
|
|
155
|
+
local.class,
|
|
156
|
+
)}
|
|
157
|
+
{...rest}
|
|
158
|
+
>
|
|
159
|
+
{local.children}
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A slot in the top-end corner of an alert, for a short action such as a button or a link. It is
|
|
166
|
+
* positioned over the alert, so keep its title short enough to leave room for it.
|
|
167
|
+
*
|
|
168
|
+
* Keyboard and ARIA: it adds no role and no keys; the action inside it is the focusable control.
|
|
169
|
+
*
|
|
170
|
+
* @param props - The action props: `children` and the `div` attributes.
|
|
171
|
+
* @returns The action element.
|
|
172
|
+
* @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* import { Alert, AlertAction, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
175
|
+
*
|
|
176
|
+
* export function Update() {
|
|
177
|
+
* return (
|
|
178
|
+
* <Alert>
|
|
179
|
+
* <AlertTitle>Update available</AlertTitle>
|
|
180
|
+
* <AlertDescription>Restart to apply it.</AlertDescription>
|
|
181
|
+
* <AlertAction>
|
|
182
|
+
* <button type="button">Restart</button>
|
|
183
|
+
* </AlertAction>
|
|
184
|
+
* </Alert>
|
|
185
|
+
* );
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
* @since 1.0.0
|
|
189
|
+
* @see {@link Alert}
|
|
190
|
+
*/
|
|
191
|
+
function AlertAction(props: ComponentProps<"div">): JSX.Element {
|
|
192
|
+
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
193
|
+
return (
|
|
194
|
+
<div data-slot="alert-action" class={cn("absolute end-2 top-2", local.class)} {...rest}>
|
|
195
|
+
{local.children}
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { Alert, AlertAction, AlertDescription, AlertTitle, alertVariants };
|