@alexgorbatchev/shadcn 0.0.101 → 0.0.102

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.
@@ -2,7 +2,14 @@ import type { IAnalyticsProps } from "../../analytics/types.js";
2
2
  import type { ReactElement } from "react";
3
3
  import type { ToasterProps } from "sonner";
4
4
  import type { IDensityProps } from "../../density/types.js";
5
- type SonnerProps = ToasterProps & IDensityProps & IAnalyticsProps;
6
- declare function Sonner({ analytics, density, className, toastOptions, icons, theme, dir, expand, ...props }: SonnerProps): ReactElement;
5
+ interface ISonnerLiveProps {
6
+ /**
7
+ * Render the notifications section as a polite live region. Defaults to true. Pass false when the
8
+ * application announces each toast through its own live region, so screen readers hear it once.
9
+ */
10
+ live?: boolean;
11
+ }
12
+ type SonnerProps = Omit<ToasterProps, "containerLive"> & ISonnerLiveProps & IDensityProps & IAnalyticsProps;
13
+ declare function Sonner({ analytics, density, className, toastOptions, icons, theme, dir, expand, live, ...props }: SonnerProps): ReactElement;
7
14
  export { Sonner, Sonner as SonnerToaster, Sonner as Toaster };
8
15
  export { toast } from "sonner";
@@ -944,7 +944,7 @@ var Toaster = /* @__PURE__ */ React.forwardRef(function Toaster(props, ref) {
944
944
  const { id, invert, position = "bottom-right", hotkey = [
945
945
  "altKey",
946
946
  "KeyT"
947
- ], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, customAriaLabel, containerAriaLabel = "Notifications" } = props;
947
+ ], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, customAriaLabel, containerAriaLabel = "Notifications", containerLive = true } = props;
948
948
  const [toasts, setToasts] = React.useState([]);
949
949
  const filteredToasts = React.useMemo(() => {
950
950
  if (id) {
@@ -1097,9 +1097,11 @@ var Toaster = /* @__PURE__ */ React.forwardRef(function Toaster(props, ref) {
1097
1097
  ref,
1098
1098
  "aria-label": customAriaLabel != null ? customAriaLabel : `${containerAriaLabel} ${hotkeyLabel}`,
1099
1099
  tabIndex: -1,
1100
- "aria-live": "polite",
1101
- "aria-relevant": "additions text",
1102
- "aria-atomic": "false",
1100
+ ...containerLive ? {
1101
+ "aria-live": "polite",
1102
+ "aria-relevant": "additions text",
1103
+ "aria-atomic": "false"
1104
+ } : {},
1103
1105
  suppressHydrationWarning: true,
1104
1106
  "data-react-aria-top-layer": true
1105
1107
  }, possiblePositions.map((position, index) => {
@@ -1207,6 +1209,7 @@ function Sonner({
1207
1209
  theme,
1208
1210
  dir,
1209
1211
  expand = true,
1212
+ live = true,
1210
1213
  ...props
1211
1214
  }) {
1212
1215
  const activate = useAnalyticsCallback("Sonner", analytics, { name: "ui.activate" }, undefined);
@@ -1225,6 +1228,7 @@ function Sonner({
1225
1228
  theme: theme ?? resolvedTheme,
1226
1229
  dir: dir ?? inheritedDirection,
1227
1230
  expand,
1231
+ containerLive: live,
1228
1232
  className: cn2("[&[data-sonner-toaster]]:font-mono", "[@media(max-width:600px)]:[&[data-sonner-toaster]]:w-auto!", "[@media(max-width:600px)]:[&[data-sonner-toaster]]:left-[var(--mobile-offset-left)]!", "[@media(max-width:600px)]:[&[data-sonner-toaster]]:right-[var(--mobile-offset-right)]!", "[@media(max-width:600px)]:[&[data-sonner-toaster]_[data-sonner-toast]]:w-full!", className),
1229
1233
  icons: {
1230
1234
  success: /* @__PURE__ */ jsx("span", {
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.101",
2054
+ version: "0.0.102",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -323,3 +323,26 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
323
323
  }
324
324
  }
325
325
  ```
326
+
327
+ ### AnnouncedByApplication
328
+
329
+ ```tsx
330
+ {
331
+ args: { live: false },
332
+ render: function Render(args) {
333
+ const [announcement, setAnnouncement] = useState("");
334
+ return (<>
335
+ <Sonner {...args}/>
336
+ <div aria-live="polite" data-testid="application-announcer">
337
+ {announcement}
338
+ </div>
339
+ <Button onClick={() => {
340
+ toast("Archived Pricing", { toasterId: args.id, action: { label: "Undo", onClick() { } } });
341
+ setAnnouncement("Archived Pricing. Undo is in Notifications.");
342
+ }}>
343
+ Archive page
344
+ </Button>
345
+ </>);
346
+ }
347
+ }
348
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.101",
3
+ "version": "0.0.102",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {