@scaleflex/ui-tw 0.0.159 → 0.0.160

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.
@@ -1,6 +1,6 @@
1
1
  import * as DialogPrimitive from '@radix-ui/react-dialog';
2
2
  import React, { type ComponentProps } from 'react';
3
- import type { DialogContentProps, DialogHeaderProps, DialogTitleProps } from './dialog.types';
3
+ import type { DialogContentProps, DialogDescriptionProps, DialogHeaderProps, DialogTitleProps } from './dialog.types';
4
4
  declare function Dialog({ ...props }: ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element;
5
5
  declare function DialogTrigger({ ...props }: ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element;
6
6
  declare function DialogPortal({ ...props }: ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
@@ -9,7 +9,7 @@ declare function DialogOverlay({ className, ...props }: ComponentProps<typeof Di
9
9
  declare function DialogContent({ className, children, overlayClassName, variant, headerSize, maxWidth, hideCloseButton, ...props }: DialogContentProps): React.JSX.Element;
10
10
  declare function DialogHeader({ className, size, ...props }: DialogHeaderProps): React.JSX.Element;
11
11
  declare function DialogTitle({ className, size, align, ...props }: DialogTitleProps): React.JSX.Element;
12
- declare function DialogDescription({ className, ...props }: ComponentProps<typeof DialogPrimitive.Description>): React.JSX.Element;
12
+ declare function DialogDescription({ className, visuallyHidden, ...props }: DialogDescriptionProps): React.JSX.Element;
13
13
  declare function DialogBody({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
14
14
  declare function DialogFooter({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
15
15
  declare function DialogIcon({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
@@ -5,13 +5,14 @@ var _excluded = ["className"],
5
5
  _excluded2 = ["className", "children", "overlayClassName", "variant", "headerSize", "maxWidth", "hideCloseButton"],
6
6
  _excluded3 = ["className", "size"],
7
7
  _excluded4 = ["className", "size", "align"],
8
- _excluded5 = ["className"],
8
+ _excluded5 = ["className", "visuallyHidden"],
9
9
  _excluded6 = ["className"],
10
10
  _excluded7 = ["className"],
11
11
  _excluded8 = ["className"],
12
12
  _excluded9 = ["className"],
13
13
  _excluded10 = ["className"];
14
14
  import * as DialogPrimitive from '@radix-ui/react-dialog';
15
+ import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
15
16
  import { Button } from '@scaleflex/ui-tw/button';
16
17
  import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
17
18
  import { cn } from '@scaleflex/ui-tw/utils/cn';
@@ -160,9 +161,22 @@ function DialogTitle(_ref8) {
160
161
  }), className)
161
162
  }, props));
162
163
  }
164
+
165
+ // Radix warns ("Missing `Description`...") when a Dialog has no description in the a11y tree.
166
+ // `visuallyHidden` keeps the description for screen readers (silencing the warning) but hides it visually.
163
167
  function DialogDescription(_ref9) {
164
168
  var className = _ref9.className,
169
+ visuallyHidden = _ref9.visuallyHidden,
165
170
  props = _objectWithoutProperties(_ref9, _excluded5);
171
+ if (visuallyHidden) {
172
+ // `asChild` applies the hidden styles to the Description itself, so it stays the `aria-describedby` target without an extra wrapper.
173
+ return /*#__PURE__*/React.createElement(VisuallyHidden, {
174
+ asChild: true
175
+ }, /*#__PURE__*/React.createElement(DialogPrimitive.Description, _extends({
176
+ "data-slot": "dialog-description",
177
+ className: className
178
+ }, props)));
179
+ }
166
180
  return /*#__PURE__*/React.createElement(DialogPrimitive.Description, _extends({
167
181
  "data-slot": "dialog-description",
168
182
  className: cn('text-muted-foreground text-sm', className)
@@ -20,6 +20,10 @@ export interface DialogTitleProps extends ComponentProps<typeof DialogPrimitive.
20
20
  size?: DialogHeaderSize;
21
21
  align?: DialogTitleAlign;
22
22
  }
23
+ export interface DialogDescriptionProps extends ComponentProps<typeof DialogPrimitive.Description> {
24
+ /** Render the description in the a11y tree but hide it visually. Satisfies Radix's `aria-describedby` requirement without showing description text. */
25
+ visuallyHidden?: boolean;
26
+ }
23
27
  /** @deprecated Use `DialogHeaderSize` instead */
24
28
  export type DialogSize = DialogHeaderSize;
25
29
  /** @deprecated Use `DialogTitleAlign` instead */
package/dialog/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogErrorIcon, DialogFooter, DialogHeader, DialogIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DialogWarningIcon, DialogFormBody, DialogFormContent, DialogFormDescription, DialogFormErrorIcon, DialogFormFooter, DialogFormHeader, DialogFormIcon, DialogFormTitle, DialogFormWarningIcon, DialogWideBody, DialogWideContent, DialogWideFooter, DialogWideHeader, DialogWideTitle, } from './dialog.component';
2
2
  export { dialogCloseButtonPositionVariants, dialogContentWidthVariants, dialogHeaderDefaultVariants, dialogTitleDefaultVariants, dialogWideHeaderVariants, dialogWideTitleVariants, } from './dialog.constants';
3
- export type { DialogAlign, DialogContentProps, DialogContentWidth, DialogFormContentProps, DialogHeaderProps, DialogHeaderSize, DialogSize, DialogTitleAlign, DialogTitleProps, DialogVariant, DialogWideContentProps, DialogWideHeaderProps, DialogWideTitleProps, } from './dialog.types';
3
+ export type { DialogAlign, DialogContentProps, DialogContentWidth, DialogDescriptionProps, DialogFormContentProps, DialogHeaderProps, DialogHeaderSize, DialogSize, DialogTitleAlign, DialogTitleProps, DialogVariant, DialogWideContentProps, DialogWideHeaderProps, DialogWideTitleProps, } from './dialog.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.159",
3
+ "version": "0.0.160",
4
4
  "author": "scaleflex",
5
5
  "repository": "github:scaleflex/ui",
6
6
  "homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
@@ -29,7 +29,8 @@
29
29
  "@radix-ui/react-switch": "^1.0.1",
30
30
  "@radix-ui/react-tabs": "^1.1.13",
31
31
  "@radix-ui/react-tooltip": "^1.2.6",
32
- "@scaleflex/icons-tw": "^0.0.159",
32
+ "@radix-ui/react-visually-hidden": "^1.2.4",
33
+ "@scaleflex/icons-tw": "^0.0.160",
33
34
  "@tanstack/react-table": "^8.21.3",
34
35
  "@types/lodash.merge": "^4.6.9",
35
36
  "class-variance-authority": "^0.7.1",