@alexgorbatchev/shadcn 0.0.199 → 0.0.200
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/README.md +3 -1
- package/dist/{chunk-n3br443n.js → chunk-q8gmx221.js} +14 -2
- package/dist/{chunk-jza4avjy.js → chunk-qcacpahw.js} +8 -2
- package/dist/{chunk-231fr3v5.js → chunk-yvq8emse.js} +1 -1
- package/dist/components/Alert.d.ts +8 -1
- package/dist/components/FormDialog.d.ts +7 -1
- package/dist/components/assistant-ui/elements/GuardrailNotice.js +2 -2
- package/dist/components/assistant-ui/index.js +2 -2
- package/dist/components/input-otp/index.js +1 -1
- package/dist/components/json-render/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/prototype.js +1 -1
- package/llms/components/feedback/Alert.md +137 -1
- package/llms/components/overlays/FormDialog.md +78 -2
- package/llms/setup.md +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -302,6 +302,8 @@ Every action shows a visible affordance at rest. Interactive control edges use t
|
|
|
302
302
|
|
|
303
303
|
`ButtonLink` renders a native anchor with Button's `variant`, `size`, `align`, `truncate`, `fullWidth`, and `density` options, so navigation keeps the link role, Enter activation, and browser link behavior without `role="button"`. Pass `href` for a plain link, or a router link element through `render`, such as `<ButtonLink variant="outline" render={<Link to="/settings" />}>Settings</ButtonLink>`; class names, children, handlers, and refs merge with the rendered element. Its render callback receives typed slot and density state. Mark icons with `data-icon="inline-start"` or `data-icon="inline-end"` as in Button. Use `Button` for actions that do not navigate.
|
|
304
304
|
|
|
305
|
+
`Alert` centres a leading icon on its `AlertTitle` and `AlertDescription`. `AlertAction` puts one compact action at the end of the title's line. `AlertActions` puts actions in a row of their own below the text, aligned with it, and leaves the icon beside the text; use it instead of placing buttons that follow the message in the description. Make all of them direct children of `Alert`, with `AlertActions` last, after the text it belongs to. An alert is one `role="alert"` region that contains its text and its actions, in that order.
|
|
306
|
+
|
|
305
307
|
`Badge` renders a span by default. Use `render={<a href="https://base-ui.com/" />}` for navigation or a native button for actions; handlers and refs merge with the rendered element. Its render callback receives typed variant, density, and slot state. Mark icons with `data-icon="inline-start"` or `data-icon="inline-end"`; their spacing follows inline direction. Use the success and warning variants for those statuses. The `outline` variant is a status tag: a pill with a quiet edge and regular-weight muted text, so a tag such as "Required" never looks like the outline Button beside it.
|
|
306
308
|
|
|
307
309
|
Compose `CardHeader`, `CardTitle`, `CardDescription`, `CardAction`, `CardContent`, and `CardFooter` inside `Card`. Use a native heading inside `CardTitle` when the title belongs in the document outline. The `size="sm"` option reduces spacing; density controls the base inset. A leading image meets the frame without top padding, and cards without footers retain bottom padding. The `--card-spacing` CSS variable adjusts both section gaps and insets.
|
|
@@ -480,7 +482,7 @@ Embedded actions, links, menus, editable fields, and media controls retain their
|
|
|
480
482
|
|
|
481
483
|
`DialogContent size="wide"` uses a desktop maximum width of 576px; `size="narrow"` uses 192px, and the default uses 384px. Dialogs remain bounded by the viewport. `FieldGroup columns={2}` arranges fields in two columns on desktop and one on mobile.
|
|
482
484
|
|
|
483
|
-
`FormDialog` supplies a controlled dialog with a fixed heading and footer around a scrolling body. Supply `open`, `onOpenChange`, `title`, and children; `description`, `size`, and `density` are optional. With `onSubmit`, the body and actions use a native form: the caller handles `preventDefault`, validation, submission, and pending state. `submitLabel` adds the stock submit button, with optional `submitVariant` and `submitDisabled`; `primaryAction` supplies a custom action instead. Without `onSubmit`, custom actions can request consent without introducing a form. Without a primary action, `cancelLabel="Done"` gives a close-only footer. `isBusy` blocks native dismissal and disables the stock actions; callers disable their own inputs and custom actions. Pass already-rendered safe guidance through `error`.
|
|
485
|
+
`FormDialog` supplies a controlled dialog with a fixed heading and footer around a scrolling body. Supply `open`, `onOpenChange`, `title`, and children; `description`, `size`, and `density` are optional. With `onSubmit`, the body and actions use a native form: the caller handles `preventDefault`, validation, submission, and pending state. `submitLabel` adds the stock submit button, with optional `submitVariant` and `submitDisabled`; `primaryAction` supplies a custom action instead. Without `onSubmit`, custom actions can request consent without introducing a form. Without a primary action, `cancelLabel="Done"` gives a close-only footer. `isBusy` blocks native dismissal and disables the stock actions; callers disable their own inputs and custom actions. Pass already-rendered safe guidance through `error`, and a button that acts on it through `errorAction`, which renders below the message and only with an `error`. With `onSubmit`, that button is inside the form: use `Button`, or a native button with `type="button"`, because a native button without a type submits the form. The error is one `role="alert"` region that contains the message and then the action.
|
|
484
486
|
|
|
485
487
|
`ImagePicker` displays a 256px square preview with upload and unset buttons. Supply the existing `src`, a staged `file` (`undefined` for the existing image, `null` for removal), and `onFileChange`/`onClear` callbacks. It accepts PNG, JPEG, and GIF files and releases local preview URLs when they change or unmount. The consumer owns saving and removal confirmation.
|
|
486
488
|
|
|
@@ -8,7 +8,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
8
|
var alertVariants = cva([
|
|
9
9
|
"group/alert relative grid w-full grid-cols-[1fr] gap-x-2 gap-y-0.5 rounded-sm border p-panel text-start text-sm",
|
|
10
10
|
"has-[>svg]:grid-cols-[auto_1fr] has-data-[slot=alert-action]:grid-cols-[1fr_auto] has-[>svg]:has-data-[slot=alert-action]:grid-cols-[auto_1fr_auto]",
|
|
11
|
-
"*:[svg]:col-start-1 *:[svg]:row-start-1 *:[svg]:self-center has-data-[slot=alert-title]:has-data-[slot=alert-description]:*:[svg]:row-span-2",
|
|
11
|
+
"*:[svg]:col-start-1 *:[svg]:row-start-1 *:[svg]:self-center not-has-[>[data-slot=alert-actions]]:has-data-[slot=alert-title]:has-data-[slot=alert-description]:*:[svg]:row-span-2",
|
|
12
|
+
"has-[>[data-slot=alert-actions]]:has-[>[data-slot=alert-title]]:has-[>[data-slot=alert-description]]:*:[svg]:row-[1/3]",
|
|
13
|
+
"has-[>[data-slot=alert-actions]]:has-[>[data-slot=alert-action]]:not-has-[>[data-slot=alert-title]]:*:[svg]:row-start-2",
|
|
14
|
+
"has-[>[data-slot=alert-actions]]:not-has-[>svg]:*:data-[slot=alert-title]:col-start-1 has-[>[data-slot=alert-actions]]:not-has-[>svg]:*:data-[slot=alert-description]:col-start-1",
|
|
15
|
+
"*:data-[slot=alert-actions]:col-span-full has-[>svg]:*:data-[slot=alert-actions]:col-start-2",
|
|
12
16
|
"*:[svg]:text-current *:[svg:not([class*='size-'])]:size-4"
|
|
13
17
|
].join(" "), {
|
|
14
18
|
variants: {
|
|
@@ -67,5 +71,13 @@ function AlertAction2({ density, className, ...props }) {
|
|
|
67
71
|
...props
|
|
68
72
|
});
|
|
69
73
|
}
|
|
74
|
+
function AlertActions2({ density, className, ...props }) {
|
|
75
|
+
return /* @__PURE__ */ jsx("div", {
|
|
76
|
+
"data-density": density,
|
|
77
|
+
"data-slot": "alert-actions",
|
|
78
|
+
className: cn2("mt-control-gap flex min-w-0 flex-wrap items-center gap-control-gap empty:hidden", className),
|
|
79
|
+
...props
|
|
80
|
+
});
|
|
81
|
+
}
|
|
70
82
|
|
|
71
|
-
export { Alert2, AlertTitle2, AlertDescription2, AlertAction2 };
|
|
83
|
+
export { Alert2, AlertTitle2, AlertDescription2, AlertAction2, AlertActions2 };
|
|
@@ -43,8 +43,9 @@ import {
|
|
|
43
43
|
import {
|
|
44
44
|
Alert2,
|
|
45
45
|
AlertTitle2,
|
|
46
|
-
AlertDescription2
|
|
47
|
-
|
|
46
|
+
AlertDescription2,
|
|
47
|
+
AlertActions2
|
|
48
|
+
} from "./chunk-q8gmx221.js";
|
|
48
49
|
import {
|
|
49
50
|
Dialog2,
|
|
50
51
|
DialogClose2,
|
|
@@ -347,9 +348,11 @@ function FormDialog2({
|
|
|
347
348
|
primaryAction,
|
|
348
349
|
cancelLabel = "Cancel",
|
|
349
350
|
error,
|
|
351
|
+
errorAction,
|
|
350
352
|
children
|
|
351
353
|
}) {
|
|
352
354
|
const isFullscreen = size === "fullscreen";
|
|
355
|
+
const hasErrorAction = errorAction != null && typeof errorAction !== "boolean";
|
|
353
356
|
const body = /* @__PURE__ */ jsxs2(Fragment, {
|
|
354
357
|
children: [
|
|
355
358
|
/* @__PURE__ */ jsx4(ScrollArea2, {
|
|
@@ -368,6 +371,9 @@ function FormDialog2({
|
|
|
368
371
|
}),
|
|
369
372
|
/* @__PURE__ */ jsx4(AlertDescription2, {
|
|
370
373
|
children: error
|
|
374
|
+
}),
|
|
375
|
+
hasErrorAction && /* @__PURE__ */ jsx4(AlertActions2, {
|
|
376
|
+
children: errorAction
|
|
371
377
|
})
|
|
372
378
|
]
|
|
373
379
|
})
|
|
@@ -13,4 +13,11 @@ type AlertDescriptionProps = ComponentProps<"div"> & IDensityProps;
|
|
|
13
13
|
declare function AlertDescription({ density, className, ...props }: AlertDescriptionProps): ReactElement;
|
|
14
14
|
type AlertActionProps = ComponentProps<"div"> & IDensityProps;
|
|
15
15
|
declare function AlertAction({ density, className, ...props }: AlertActionProps): ReactElement;
|
|
16
|
-
|
|
16
|
+
type AlertActionsProps = ComponentProps<"div"> & IDensityProps;
|
|
17
|
+
/**
|
|
18
|
+
* Actions in a row of their own below the alert's title and description. Place it after them. Use it, rather than the
|
|
19
|
+
* description, for buttons that follow the message: the icon stays centred on the title and the description. Without
|
|
20
|
+
* content it takes up no space.
|
|
21
|
+
*/
|
|
22
|
+
declare function AlertActions({ density, className, ...props }: AlertActionsProps): ReactElement;
|
|
23
|
+
export { Alert, AlertTitle, AlertDescription, AlertAction, AlertActions };
|
|
@@ -15,9 +15,15 @@ interface IFormDialogProps extends IDensityProps {
|
|
|
15
15
|
submitDisabled?: boolean;
|
|
16
16
|
primaryAction?: ReactNode;
|
|
17
17
|
cancelLabel?: string;
|
|
18
|
+
/** The message of an error alert below the body. The alert is a live region, so its message is announced. */
|
|
18
19
|
error?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* A button that acts on the error, below its message and in the same alert. Use `Button`, or a native button with
|
|
22
|
+
* `type="button"`, so it never submits the form. Renders nothing without `error`.
|
|
23
|
+
*/
|
|
24
|
+
errorAction?: ReactNode;
|
|
19
25
|
children: ReactNode;
|
|
20
26
|
}
|
|
21
27
|
/** Controlled dialog layout; the caller owns submission, validation, and pending state. */
|
|
22
|
-
export declare function FormDialog({ open, onOpenChange, title, description, size, density, isBusy, onSubmit, submitLabel, submitVariant, submitDisabled, primaryAction, cancelLabel, error, children, }: IFormDialogProps): ReactElement;
|
|
28
|
+
export declare function FormDialog({ open, onOpenChange, title, description, size, density, isBusy, onSubmit, submitLabel, submitVariant, submitDisabled, primaryAction, cancelLabel, error, errorAction, children, }: IFormDialogProps): ReactElement;
|
|
23
29
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GuardrailNotice2
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import"../../../chunk-
|
|
3
|
+
} from "../../../chunk-yvq8emse.js";
|
|
4
|
+
import"../../../chunk-q8gmx221.js";
|
|
5
5
|
import"../../../chunk-n63meq6q.js";
|
|
6
6
|
import"../../../chunk-x90xmrba.js";
|
|
7
7
|
import"../../../chunk-jpvw9xqy.js";
|
|
@@ -297,10 +297,10 @@ import {
|
|
|
297
297
|
import {
|
|
298
298
|
GitHubIcon2
|
|
299
299
|
} from "../../chunk-4bjqbky7.js";
|
|
300
|
-
import"../../chunk-
|
|
300
|
+
import"../../chunk-q8gmx221.js";
|
|
301
301
|
import {
|
|
302
302
|
GuardrailNotice2
|
|
303
|
-
} from "../../chunk-
|
|
303
|
+
} from "../../chunk-yvq8emse.js";
|
|
304
304
|
import {
|
|
305
305
|
ImageRoot2,
|
|
306
306
|
ImagePreview2,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
PaginationPrevious2,
|
|
27
27
|
PaginationNext2,
|
|
28
28
|
PaginationEllipsis2
|
|
29
|
-
} from "../../chunk-
|
|
29
|
+
} from "../../chunk-qcacpahw.js";
|
|
30
30
|
import {
|
|
31
31
|
MenuPopup,
|
|
32
32
|
MenuItem2,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
Alert2,
|
|
40
40
|
AlertTitle2,
|
|
41
41
|
AlertDescription2
|
|
42
|
-
} from "../../chunk-
|
|
42
|
+
} from "../../chunk-q8gmx221.js";
|
|
43
43
|
import {
|
|
44
44
|
Dialog2,
|
|
45
45
|
DialogContent2,
|
package/dist/index.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export type { ToggleGroupProps } from "./components/ToggleGroup.js";
|
|
|
65
65
|
export { AspectRatio } from "./components/AspectRatio.js";
|
|
66
66
|
export type { IAspectRatioProps } from "./components/AspectRatio.js";
|
|
67
67
|
export { DirectionProvider, useDirection } from "./components/DirectionProvider.js";
|
|
68
|
-
export { Alert, AlertTitle, AlertDescription, AlertAction } from "./components/Alert.js";
|
|
68
|
+
export { Alert, AlertTitle, AlertDescription, AlertAction, AlertActions } from "./components/Alert.js";
|
|
69
69
|
export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge, } from "./components/Avatar.js";
|
|
70
70
|
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, } from "./components/Breadcrumb.js";
|
|
71
71
|
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants } from "./components/ButtonGroup.js";
|
package/dist/index.js
CHANGED
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
DashboardLayout2,
|
|
189
189
|
BillingUsage2,
|
|
190
190
|
SelectionAction2
|
|
191
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-qcacpahw.js";
|
|
192
192
|
import {
|
|
193
193
|
statusDotVariants2,
|
|
194
194
|
StatusDot2
|
|
@@ -323,8 +323,9 @@ import {
|
|
|
323
323
|
Alert2,
|
|
324
324
|
AlertTitle2,
|
|
325
325
|
AlertDescription2,
|
|
326
|
-
AlertAction2
|
|
327
|
-
|
|
326
|
+
AlertAction2,
|
|
327
|
+
AlertActions2
|
|
328
|
+
} from "./chunk-q8gmx221.js";
|
|
328
329
|
import {
|
|
329
330
|
FieldSet2,
|
|
330
331
|
FieldLegend2,
|
|
@@ -518,6 +519,7 @@ export {
|
|
|
518
519
|
ActionsMenuTrigger2 as ActionsMenuTrigger,
|
|
519
520
|
Alert2 as Alert,
|
|
520
521
|
AlertAction2 as AlertAction,
|
|
522
|
+
AlertActions2 as AlertActions,
|
|
521
523
|
AlertDescription2 as AlertDescription,
|
|
522
524
|
AlertDialog2 as AlertDialog,
|
|
523
525
|
AlertDialogAction2 as AlertDialogAction,
|
package/dist/prototype.js
CHANGED
|
@@ -2051,7 +2051,7 @@ var program = new Command;
|
|
|
2051
2051
|
// package.json
|
|
2052
2052
|
var package_default = {
|
|
2053
2053
|
name: "@alexgorbatchev/shadcn",
|
|
2054
|
-
version: "0.0.
|
|
2054
|
+
version: "0.0.200",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -8,12 +8,13 @@ Source: src/components/stories/feedback/Alert.stories.tsx
|
|
|
8
8
|
## Public imports
|
|
9
9
|
|
|
10
10
|
```tsx
|
|
11
|
-
import { Alert, AlertAction, AlertDescription, AlertTitle, Button } from "@alexgorbatchev/shadcn";
|
|
11
|
+
import { Alert, AlertAction, AlertActions, AlertDescription, AlertTitle, Button } from "@alexgorbatchev/shadcn";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## Supporting imports
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
+
import type { ReactElement } from "react";
|
|
17
18
|
import { CircleAlertIcon, TriangleAlertIcon } from "lucide-react";
|
|
18
19
|
```
|
|
19
20
|
|
|
@@ -212,3 +213,138 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
212
213
|
</div>)
|
|
213
214
|
}
|
|
214
215
|
```
|
|
216
|
+
|
|
217
|
+
### WithActions
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
{
|
|
221
|
+
args: { variant: "destructive" },
|
|
222
|
+
render: (args) => (<Alert {...args}>
|
|
223
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
224
|
+
<AlertTitle>Changes not saved</AlertTitle>
|
|
225
|
+
<AlertDescription>The server did not answer. Check the connection, then save again.</AlertDescription>
|
|
226
|
+
<AlertActions>
|
|
227
|
+
<Button size="sm" variant="outline" onClick={onRetry}>
|
|
228
|
+
Save again
|
|
229
|
+
</Button>
|
|
230
|
+
<Button size="sm" variant="ghost">
|
|
231
|
+
Discard changes
|
|
232
|
+
</Button>
|
|
233
|
+
</AlertActions>
|
|
234
|
+
</Alert>)
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### ActionsBelowText
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
{
|
|
242
|
+
render: () => (<div className="flex w-80 flex-col gap-2">
|
|
243
|
+
{directions.flatMap((dir) => densities.flatMap((density) => lineCounts.flatMap((lines) => [true, false].flatMap((hasTitle) => [true, false].map((hasAction) => {
|
|
244
|
+
const name = `${dir}, ${density}, ${lines} lines, title ${hasTitle}, action ${hasAction}`;
|
|
245
|
+
return (<Alert key={name} dir={dir} density={density} variant="destructive" data-case={name}>
|
|
246
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
247
|
+
{hasTitle && <AlertTitle>Update failed</AlertTitle>}
|
|
248
|
+
<AlertDescription data-lines={lines}>{renderLines(lines)}</AlertDescription>
|
|
249
|
+
{hasAction && (<AlertAction>
|
|
250
|
+
<Button size="xs">Dismiss</Button>
|
|
251
|
+
</AlertAction>)}
|
|
252
|
+
<AlertActions>
|
|
253
|
+
<Button>Retry</Button>
|
|
254
|
+
</AlertActions>
|
|
255
|
+
</Alert>);
|
|
256
|
+
})))))}
|
|
257
|
+
</div>)
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### ActionsInEveryVariant
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
{
|
|
265
|
+
render: () => (<div className="flex w-80 flex-col gap-2">
|
|
266
|
+
{appearances.flatMap((appearance) => variants.flatMap((variant) => [true, false].flatMap((hasTitle) => [true, false].map((hasActions) => (<Alert key={`${appearance}-${variant}-${hasTitle}-${hasActions}`} appearance={appearance} variant={variant} data-case={`${appearance}, ${variant}, title ${hasTitle}`} data-actions={hasActions}>
|
|
267
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
268
|
+
{hasTitle && <AlertTitle>Changes saved</AlertTitle>}
|
|
269
|
+
<AlertDescription>{wrappingDescription}</AlertDescription>
|
|
270
|
+
{hasActions && (<AlertActions>
|
|
271
|
+
<Button variant="outline">Show changes</Button>
|
|
272
|
+
</AlertActions>)}
|
|
273
|
+
</Alert>)))))}
|
|
274
|
+
</div>)
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### ActionsInNarrowAlert
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
{
|
|
282
|
+
render: () => (<div className="flex w-60 flex-col gap-2">
|
|
283
|
+
{directions.flatMap((dir) => [true, false].map((hasTitle) => (<Alert key={`${dir}-${hasTitle}`} dir={dir} variant="destructive" data-case={`${dir}, title ${String(hasTitle)}`}>
|
|
284
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
285
|
+
{hasTitle && <AlertTitle>Update failed</AlertTitle>}
|
|
286
|
+
<AlertDescription>{wrappingDescription}</AlertDescription>
|
|
287
|
+
<AlertActions>
|
|
288
|
+
<Button>Check again</Button>
|
|
289
|
+
<Button variant="outline">Show all changes</Button>
|
|
290
|
+
</AlertActions>
|
|
291
|
+
</Alert>)))}
|
|
292
|
+
</div>)
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### ActionsInNestedAlerts
|
|
297
|
+
|
|
298
|
+
```tsx
|
|
299
|
+
{
|
|
300
|
+
render: () => (<div className="flex w-96 flex-col gap-2">
|
|
301
|
+
<Alert variant="destructive" data-case="outer actions">
|
|
302
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
303
|
+
<AlertDescription>
|
|
304
|
+
<p>The import stopped.</p>
|
|
305
|
+
<Alert variant="warning" appearance="outline" data-case="inner text">
|
|
306
|
+
<TriangleAlertIcon aria-hidden="true"/>
|
|
307
|
+
<AlertTitle>Two files are missing</AlertTitle>
|
|
308
|
+
<AlertDescription>They moved after the import started.</AlertDescription>
|
|
309
|
+
<AlertAction>
|
|
310
|
+
<Button size="xs">Show</Button>
|
|
311
|
+
</AlertAction>
|
|
312
|
+
</Alert>
|
|
313
|
+
</AlertDescription>
|
|
314
|
+
<AlertActions>
|
|
315
|
+
<Button>Import again</Button>
|
|
316
|
+
</AlertActions>
|
|
317
|
+
</Alert>
|
|
318
|
+
<Alert variant="warning" data-case="outer text">
|
|
319
|
+
<TriangleAlertIcon aria-hidden="true"/>
|
|
320
|
+
<AlertDescription>
|
|
321
|
+
<p>The import stopped.</p>
|
|
322
|
+
<Alert variant="destructive" appearance="outline" data-case="inner actions">
|
|
323
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
324
|
+
<AlertTitle>Two files are missing</AlertTitle>
|
|
325
|
+
<AlertDescription>They moved after the import started.</AlertDescription>
|
|
326
|
+
<AlertActions>
|
|
327
|
+
<Button>Find files</Button>
|
|
328
|
+
</AlertActions>
|
|
329
|
+
</Alert>
|
|
330
|
+
</AlertDescription>
|
|
331
|
+
</Alert>
|
|
332
|
+
<Alert variant="destructive" data-case="both actions">
|
|
333
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
334
|
+
<AlertTitle>The import stopped</AlertTitle>
|
|
335
|
+
<AlertDescription>
|
|
336
|
+
<Alert variant="warning" appearance="outline" data-case="inner actions without an icon">
|
|
337
|
+
<AlertTitle>Two files are missing</AlertTitle>
|
|
338
|
+
<AlertDescription>They moved after the import started.</AlertDescription>
|
|
339
|
+
<AlertActions>
|
|
340
|
+
<Button>Find files</Button>
|
|
341
|
+
</AlertActions>
|
|
342
|
+
</Alert>
|
|
343
|
+
</AlertDescription>
|
|
344
|
+
<AlertActions>
|
|
345
|
+
<Button>Import again</Button>
|
|
346
|
+
</AlertActions>
|
|
347
|
+
</Alert>
|
|
348
|
+
</div>)
|
|
349
|
+
}
|
|
350
|
+
```
|
|
@@ -8,13 +8,14 @@ Source: src/components/stories/overlays/FormDialog.stories.tsx
|
|
|
8
8
|
## Public imports
|
|
9
9
|
|
|
10
10
|
```tsx
|
|
11
|
-
import { FormDialog, Input, Button } from "@alexgorbatchev/shadcn";
|
|
11
|
+
import { Alert, AlertDescription, FormDialog, Input, Button } from "@alexgorbatchev/shadcn";
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## Supporting imports
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
-
import { useState, type ReactElement } from "react";
|
|
17
|
+
import { useState, type ComponentProps, type ReactElement } from "react";
|
|
18
|
+
import { CircleAlertIcon } from "lucide-react";
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
## Default component
|
|
@@ -108,3 +109,78 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
108
109
|
args: { size: "fullscreen" }
|
|
109
110
|
}
|
|
110
111
|
```
|
|
112
|
+
|
|
113
|
+
### ErrorActionLight
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
{
|
|
117
|
+
globals: { theme: "light" },
|
|
118
|
+
render: ErrorDialog
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### ErrorActionDark
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
{
|
|
126
|
+
globals: { theme: "dark" },
|
|
127
|
+
render: ErrorDialog
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### ErrorActionKeyboard
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
{
|
|
135
|
+
args: {
|
|
136
|
+
error: renderErrorLines(1),
|
|
137
|
+
errorAction: (<>
|
|
138
|
+
<Button onClick={onReload}>Reload project</Button>
|
|
139
|
+
<button type="button" onClick={onReload}>
|
|
140
|
+
Reload settings
|
|
141
|
+
</button>
|
|
142
|
+
</>),
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### ErrorActionNumber
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
{
|
|
151
|
+
args: { error: renderErrorLines(1), errorAction: 0 }
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### ErrorActionWithoutError
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
{
|
|
159
|
+
args: { errorAction: <Button>Reload project</Button> }
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### ErrorActionInScrollingBody
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
{
|
|
167
|
+
args: {
|
|
168
|
+
children: Array.from({ length: 60 }, (_, index) => <p key={index}>Project detail {index + 1}</p>),
|
|
169
|
+
error: renderErrorLines(2),
|
|
170
|
+
errorAction: <Button>Reload project</Button>,
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### ErrorActionRenderingNothing
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
{
|
|
179
|
+
render: (args) => (<FormDialog {...args} open error="The change was not saved." errorAction={<NoAction />}>
|
|
180
|
+
<Alert variant="destructive">
|
|
181
|
+
<CircleAlertIcon aria-hidden="true"/>
|
|
182
|
+
<AlertDescription>The change was not saved.</AlertDescription>
|
|
183
|
+
</Alert>
|
|
184
|
+
</FormDialog>)
|
|
185
|
+
}
|
|
186
|
+
```
|
package/llms/setup.md
CHANGED
|
@@ -302,6 +302,8 @@ Every action shows a visible affordance at rest. Interactive control edges use t
|
|
|
302
302
|
|
|
303
303
|
`ButtonLink` renders a native anchor with Button's `variant`, `size`, `align`, `truncate`, `fullWidth`, and `density` options, so navigation keeps the link role, Enter activation, and browser link behavior without `role="button"`. Pass `href` for a plain link, or a router link element through `render`, such as `<ButtonLink variant="outline" render={<Link to="/settings" />}>Settings</ButtonLink>`; class names, children, handlers, and refs merge with the rendered element. Its render callback receives typed slot and density state. Mark icons with `data-icon="inline-start"` or `data-icon="inline-end"` as in Button. Use `Button` for actions that do not navigate.
|
|
304
304
|
|
|
305
|
+
`Alert` centres a leading icon on its `AlertTitle` and `AlertDescription`. `AlertAction` puts one compact action at the end of the title's line. `AlertActions` puts actions in a row of their own below the text, aligned with it, and leaves the icon beside the text; use it instead of placing buttons that follow the message in the description. Make all of them direct children of `Alert`, with `AlertActions` last, after the text it belongs to. An alert is one `role="alert"` region that contains its text and its actions, in that order.
|
|
306
|
+
|
|
305
307
|
`Badge` renders a span by default. Use `render={<a href="https://base-ui.com/" />}` for navigation or a native button for actions; handlers and refs merge with the rendered element. Its render callback receives typed variant, density, and slot state. Mark icons with `data-icon="inline-start"` or `data-icon="inline-end"`; their spacing follows inline direction. Use the success and warning variants for those statuses. The `outline` variant is a status tag: a pill with a quiet edge and regular-weight muted text, so a tag such as "Required" never looks like the outline Button beside it.
|
|
306
308
|
|
|
307
309
|
Compose `CardHeader`, `CardTitle`, `CardDescription`, `CardAction`, `CardContent`, and `CardFooter` inside `Card`. Use a native heading inside `CardTitle` when the title belongs in the document outline. The `size="sm"` option reduces spacing; density controls the base inset. A leading image meets the frame without top padding, and cards without footers retain bottom padding. The `--card-spacing` CSS variable adjusts both section gaps and insets.
|
|
@@ -480,7 +482,7 @@ Embedded actions, links, menus, editable fields, and media controls retain their
|
|
|
480
482
|
|
|
481
483
|
`DialogContent size="wide"` uses a desktop maximum width of 576px; `size="narrow"` uses 192px, and the default uses 384px. Dialogs remain bounded by the viewport. `FieldGroup columns={2}` arranges fields in two columns on desktop and one on mobile.
|
|
482
484
|
|
|
483
|
-
`FormDialog` supplies a controlled dialog with a fixed heading and footer around a scrolling body. Supply `open`, `onOpenChange`, `title`, and children; `description`, `size`, and `density` are optional. With `onSubmit`, the body and actions use a native form: the caller handles `preventDefault`, validation, submission, and pending state. `submitLabel` adds the stock submit button, with optional `submitVariant` and `submitDisabled`; `primaryAction` supplies a custom action instead. Without `onSubmit`, custom actions can request consent without introducing a form. Without a primary action, `cancelLabel="Done"` gives a close-only footer. `isBusy` blocks native dismissal and disables the stock actions; callers disable their own inputs and custom actions. Pass already-rendered safe guidance through `error`.
|
|
485
|
+
`FormDialog` supplies a controlled dialog with a fixed heading and footer around a scrolling body. Supply `open`, `onOpenChange`, `title`, and children; `description`, `size`, and `density` are optional. With `onSubmit`, the body and actions use a native form: the caller handles `preventDefault`, validation, submission, and pending state. `submitLabel` adds the stock submit button, with optional `submitVariant` and `submitDisabled`; `primaryAction` supplies a custom action instead. Without `onSubmit`, custom actions can request consent without introducing a form. Without a primary action, `cancelLabel="Done"` gives a close-only footer. `isBusy` blocks native dismissal and disables the stock actions; callers disable their own inputs and custom actions. Pass already-rendered safe guidance through `error`, and a button that acts on it through `errorAction`, which renders below the message and only with an `error`. With `onSubmit`, that button is inside the form: use `Button`, or a native button with `type="button"`, because a native button without a type submits the form. The error is one `role="alert"` region that contains the message and then the action.
|
|
484
486
|
|
|
485
487
|
`ImagePicker` displays a 256px square preview with upload and unset buttons. Supply the existing `src`, a staged `file` (`undefined` for the existing image, `null` for removal), and `onFileChange`/`onClear` callbacks. It accepts PNG, JPEG, and GIF files and releases local preview URLs when they change or unmount. The consumer owns saving and removal confirmation.
|
|
486
488
|
|