@aragon/gov-ui-kit 1.19.1 → 1.21.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.
@@ -9,6 +9,13 @@ export interface ICollapsibleProps extends Omit<ComponentProps<'div'>, 'onToggle
9
9
  * Exact pixel height for the collapsible container that will override collapsedLines prop if defined.
10
10
  */
11
11
  collapsedPixels?: number;
12
+ /**
13
+ * Number of text lines used for the gradient overlay height when collapsed.
14
+ * Has effect only when `showOverlay` is true and the content is collapsed.
15
+ * Overlay height will be clamped to at most (collapsedLines - 1).
16
+ * @default 2
17
+ */
18
+ overlayLines?: number;
12
19
  /**
13
20
  * Controlled state of the collapsible container.
14
21
  * @default false
@@ -1,2 +1,18 @@
1
1
  import { type ICollapsibleProps } from './collapsible.api';
2
+ /**
3
+ * Collapsible component that can wrap any content and visually collapse it for space-saving purposes.
4
+ *
5
+ * @param props - The component props
6
+ * @param props.collapsedLines - Number of text lines to show while collapsed (default: 3)
7
+ * @param props.collapsedPixels - Exact pixel height for the collapsible container that will override collapsedLines prop if defined
8
+ * @param props.overlayLines - Number of text lines used for the gradient overlay height when collapsed (default: 2)
9
+ * @param props.isOpen - Controlled state of the collapsible container (default: false)
10
+ * @param props.defaultOpen - Default state of the collapsible container (default: false)
11
+ * @param props.buttonLabelClosed - The label to display on the trigger button when the collapsible container is closed
12
+ * @param props.buttonLabelOpened - The label to display on the trigger button when the collapsible container is open
13
+ * @param props.showOverlay - Show overlay when the collapsible container is open (default: false)
14
+ * @param props.onToggle - Callback function that is called when the collapsible container is toggled
15
+ * @param props.children - The content to be collapsible
16
+ * @returns The rendered Collapsible component
17
+ */
2
18
  export declare const Collapsible: React.FC<ICollapsibleProps>;
@@ -0,0 +1,48 @@
1
+ export declare const collapsibleDefaultLineHeight = 24;
2
+ /**
3
+ * Computes the line height of an element with intelligent fallback strategy.
4
+ *
5
+ * The function uses a multi-level approach to find the most accurate line-height:
6
+ * 1. First, tries to get line-height from the first <p> child element
7
+ * - This is important because content often consists of paragraphs with specific typography styles
8
+ * - For example, `.prose p` classes in Tailwind Typography apply custom line-heights to paragraphs
9
+ * - Taking line-height from the first paragraph ensures accurate height calculations when content
10
+ * has different typography than the container
11
+ *
12
+ * 2. If no paragraph is found, falls back to the container element itself
13
+ * - This handles cases where content doesn't use paragraph tags (images, custom components, etc.)
14
+ *
15
+ * 3. If line-height cannot be computed (SSR, null element, or invalid value), uses the fallback
16
+ * - Ensures the component works gracefully in all environments
17
+ *
18
+ * @param element - The container element to compute the line height from
19
+ * @param fallback - The fallback line height to use if computation fails (default: 24px)
20
+ * @returns The computed line height in pixels
21
+ */
22
+ export declare const computeElementLineHeight: (element: HTMLElement | null, fallback?: number) => number;
23
+ /**
24
+ * Calculates the collapsed height of an element.
25
+ * @param collapsedLines - The number of lines to show while collapsed.
26
+ * @param lineHeight - The line height of the element.
27
+ * @param collapsedPixels - The collapsed pixels of the element.
28
+ * @returns The collapsed height of the element.
29
+ */
30
+ export declare const calculateCollapsedHeight: (collapsedLines: number, lineHeight: number, collapsedPixels?: number) => number;
31
+ /**
32
+ * Computes the whether an element is overflowing.
33
+ * @param fullHeight - The full height of the element.
34
+ * @param collapsedHeight - The collapsed height of the element.
35
+ * @param epsilon - The epsilon to use for the overflow.
36
+ * @returns The whether an element is overflowing.
37
+ */
38
+ export declare const computeContentOverflow: (fullHeight: number, collapsedHeight: number, epsilon?: number) => boolean;
39
+ export interface OverlayHeightParams {
40
+ showOverlay: boolean;
41
+ isOpen: boolean;
42
+ collapsedLines: number;
43
+ overlayLines: number;
44
+ lineHeight: number;
45
+ collapsedHeight: number;
46
+ fallbackLineHeight?: number;
47
+ }
48
+ export declare const computeOverlayHeightPx: (params: OverlayHeightParams) => number;
@@ -1,3 +1,7 @@
1
- import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
2
- export type IDataListItemProps = ButtonHTMLAttributes<HTMLButtonElement> | AnchorHTMLAttributes<HTMLAnchorElement> | HTMLAttributes<HTMLDivElement>;
1
+ import { type AnchorHTMLAttributes, type HTMLAttributes } from 'react';
2
+ type DivPropsWithCustomClick = Omit<HTMLAttributes<HTMLDivElement>, 'onClick'> & {
3
+ onClick?: () => void;
4
+ };
5
+ export type IDataListItemProps = AnchorHTMLAttributes<HTMLAnchorElement> | DivPropsWithCustomClick;
3
6
  export declare const DataListItem: React.FC<IDataListItemProps>;
7
+ export {};
@@ -3,6 +3,7 @@ import { type ComponentPropsWithoutRef } from 'react';
3
3
  export interface IDialogContentProps extends ComponentPropsWithoutRef<'div'> {
4
4
  /**
5
5
  * Optional description of the dialog.
6
+ * Considering using the same prop on `DialogContentHeader` for sticky effect.
6
7
  */
7
8
  description?: string;
8
9
  /**
@@ -4,6 +4,11 @@ export interface IDialogHeaderProps extends ComponentPropsWithoutRef<'div'> {
4
4
  * Title of the dialog displayed on the header and used as the dialog's accessible name.
5
5
  */
6
6
  title: string;
7
+ /**
8
+ * Optional description of the dialog. When set here, the description stays sticky with the header
9
+ * and remains visible while scrolling through long content.
10
+ */
11
+ description?: string;
7
12
  /**
8
13
  * Callback triggered on close button click. The close button is not displayed when the property is not set.
9
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aragon/gov-ui-kit",
3
- "version": "1.19.1",
3
+ "version": "1.21.0",
4
4
  "description": "Implementation of the Aragon's Governance UI Kit",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/types/src/index.d.ts",