@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,175 @@
|
|
|
1
|
+
import { splitProps } from "@shadow-js/core";
|
|
2
|
+
import { Polymorphic, type PolymorphicProps, type PolymorphicTarget } from "@shadow-js/primitives";
|
|
3
|
+
import type { ComponentProps, JSX } from "@shadow-js/web";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { type ClassValue, cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The class list of a marker for each `variant`. Use it to give another element the look of a marker.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { markerVariants } from "@/components/ui/marker";
|
|
13
|
+
*
|
|
14
|
+
* export function Divider() {
|
|
15
|
+
* return <p class={markerVariants({ variant: "separator" })}>Today</p>;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @see {@link Marker}
|
|
20
|
+
*/
|
|
21
|
+
const markerVariants = cva(
|
|
22
|
+
"group/marker flex w-full min-w-0 items-center gap-2 text-sm text-muted-foreground outline-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [a&]:transition-colors [a&]:hover:text-foreground [button&]:transition-colors [button&]:hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 motion-reduce:transition-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-transparent",
|
|
23
|
+
{
|
|
24
|
+
variants: {
|
|
25
|
+
variant: {
|
|
26
|
+
default: "",
|
|
27
|
+
border: "border-b pb-2",
|
|
28
|
+
separator:
|
|
29
|
+
"justify-center gap-3 text-xs before:h-px before:flex-1 before:bg-border after:h-px after:flex-1 after:bg-border",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: { variant: "default" },
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/** The props as the implementation sees them. */
|
|
37
|
+
type Loose = VariantProps<typeof markerVariants> & {
|
|
38
|
+
readonly as?: PolymorphicTarget;
|
|
39
|
+
readonly class?: ClassValue;
|
|
40
|
+
readonly [prop: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Props of {@link Marker}: every attribute of the chosen element plus `variant`, which is
|
|
45
|
+
* `"default"` (an inline note), `"border"` (a rule under the row) or `"separator"` (a centered label
|
|
46
|
+
* between two lines). The `as` prop picks the element (a `div` by default).
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
* @see {@link Marker}
|
|
49
|
+
*/
|
|
50
|
+
export type MarkerProps<T extends PolymorphicTarget = "div"> = PolymorphicProps<
|
|
51
|
+
"div",
|
|
52
|
+
VariantProps<typeof markerVariants>,
|
|
53
|
+
T
|
|
54
|
+
>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* An inline note between the messages of a conversation: "Checking the logs...", "Ada joined", a
|
|
58
|
+
* date, or a place the thread can be restored to. It is a row with an optional {@link MarkerIcon} and
|
|
59
|
+
* a {@link MarkerContent}. Render a link or a button with `as` to make the whole row interactive.
|
|
60
|
+
*
|
|
61
|
+
* Keyboard and ARIA: a marker is presentational and has no role of its own, so choose one for its
|
|
62
|
+
* purpose: `role="status"` for work in progress (with a `Spinner` in the icon, so the change is
|
|
63
|
+
* announced). Do not give a labeled separator `role="separator"`: a separator has no name, so its text
|
|
64
|
+
* would not be announced. As a `button` or a link it takes the native keys and shows a focus ring.
|
|
65
|
+
*
|
|
66
|
+
* Compared with shadcn/ui: `as` replaces `render`, `class` replaces `className`, and every part has a `data-slot`.
|
|
67
|
+
*
|
|
68
|
+
* @param props - The marker props: `variant`, `as`, `children` and the attributes of the element.
|
|
69
|
+
* @returns The marker element.
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* import { Marker, MarkerContent } from "@/components/ui/marker";
|
|
73
|
+
*
|
|
74
|
+
* export function Today() {
|
|
75
|
+
* return (
|
|
76
|
+
* <Marker variant="separator">
|
|
77
|
+
* <MarkerContent>Today</MarkerContent>
|
|
78
|
+
* </Marker>
|
|
79
|
+
* );
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
* @see {@link MarkerIcon}
|
|
84
|
+
* @see {@link MarkerContent}
|
|
85
|
+
*/
|
|
86
|
+
function Marker<T extends PolymorphicTarget = "div">(props: MarkerProps<T>): JSX.Element {
|
|
87
|
+
const [local, rest] = splitProps(props as unknown as Loose, ["as", "class", "variant"]);
|
|
88
|
+
return (
|
|
89
|
+
<Polymorphic
|
|
90
|
+
as={local.as ?? "div"}
|
|
91
|
+
data-slot="marker"
|
|
92
|
+
data-variant={local.variant ?? "default"}
|
|
93
|
+
class={cn(markerVariants({ variant: local.variant }), local.class)}
|
|
94
|
+
{...rest}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The icon of a marker, before its content. It is decorative: it is hidden from assistive
|
|
101
|
+
* technology, so a marker that shows only an icon needs an `aria-label` or visible text.
|
|
102
|
+
*
|
|
103
|
+
* Keyboard and ARIA: no keys, and `aria-hidden="true"`.
|
|
104
|
+
*
|
|
105
|
+
* @param props - The `span` attributes and `class`.
|
|
106
|
+
* @returns The icon slot.
|
|
107
|
+
* @example
|
|
108
|
+
* ```tsx
|
|
109
|
+
* import { CheckIcon } from "@/components/ui/icons";
|
|
110
|
+
* import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";
|
|
111
|
+
*
|
|
112
|
+
* export function Done() {
|
|
113
|
+
* return (
|
|
114
|
+
* <Marker>
|
|
115
|
+
* <MarkerIcon>
|
|
116
|
+
* <CheckIcon />
|
|
117
|
+
* </MarkerIcon>
|
|
118
|
+
* <MarkerContent>Changes saved</MarkerContent>
|
|
119
|
+
* </Marker>
|
|
120
|
+
* );
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
* @since 1.0.0
|
|
124
|
+
* @see {@link Marker}
|
|
125
|
+
*/
|
|
126
|
+
function MarkerIcon(props: ComponentProps<"span">): JSX.Element {
|
|
127
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
128
|
+
return (
|
|
129
|
+
<span
|
|
130
|
+
data-slot="marker-icon"
|
|
131
|
+
aria-hidden="true"
|
|
132
|
+
class={cn("inline-flex shrink-0 items-center", local.class)}
|
|
133
|
+
{...rest}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The text of a marker. It truncates in a row; in a separator it is the label between the lines. Add the
|
|
140
|
+
* `shimmer` class from `animations.css` to a streaming line.
|
|
141
|
+
*
|
|
142
|
+
* Keyboard and ARIA: no keys and no role. The text is what a screen reader reads.
|
|
143
|
+
*
|
|
144
|
+
* @param props - The `span` attributes and `class`.
|
|
145
|
+
* @returns The content slot.
|
|
146
|
+
* @example
|
|
147
|
+
* ```tsx
|
|
148
|
+
* import { Marker, MarkerContent } from "@/components/ui/marker";
|
|
149
|
+
*
|
|
150
|
+
* export function Thinking() {
|
|
151
|
+
* return (
|
|
152
|
+
* <Marker role="status">
|
|
153
|
+
* <MarkerContent class="shimmer">Checking the logs...</MarkerContent>
|
|
154
|
+
* </Marker>
|
|
155
|
+
* );
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
* @since 1.0.0
|
|
159
|
+
* @see {@link Marker}
|
|
160
|
+
*/
|
|
161
|
+
function MarkerContent(props: ComponentProps<"span">): JSX.Element {
|
|
162
|
+
const [local, rest] = splitProps(props, ["class"]);
|
|
163
|
+
return (
|
|
164
|
+
<span
|
|
165
|
+
data-slot="marker-content"
|
|
166
|
+
class={cn(
|
|
167
|
+
"min-w-0 truncate group-data-[variant=separator]/marker:overflow-visible",
|
|
168
|
+
local.class,
|
|
169
|
+
)}
|
|
170
|
+
{...rest}
|
|
171
|
+
/>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export { Marker, MarkerContent, MarkerIcon, markerVariants };
|