@aragon/gov-ui-kit 1.20.0 → 1.22.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 +22 -0
- package/build.css +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/types/src/core/components/cards/cardCollapsible/cardCollapsible.d.ts +7 -1
- package/dist/types/src/core/components/collapsible/collapsible.api.d.ts +7 -0
- package/dist/types/src/core/components/collapsible/collapsible.d.ts +16 -0
- package/dist/types/src/core/components/collapsible/collapsibleUtils.d.ts +95 -0
- package/dist/types/src/core/components/dataList/dataListItem/dataListItem.d.ts +6 -2
- package/dist/types/src/core/components/dialogs/dialog/dialogContent/dialogContent.d.ts +1 -0
- package/dist/types/src/core/components/dialogs/dialog/dialogHeader/dialogHeader.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type ICollapsibleProps } from '../../collapsible';
|
|
2
|
-
export interface ICardCollapsibleProps extends Omit<ICollapsibleProps, 'buttonVariant' | 'className'> {
|
|
2
|
+
export interface ICardCollapsibleProps extends Omit<ICollapsibleProps, 'buttonVariant' | 'className' | 'showOverlay' | 'collapsedLines'> {
|
|
3
3
|
/**
|
|
4
4
|
* Additional class names to apply to the card.
|
|
5
5
|
*/
|
|
6
6
|
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The collapsed height in pixels. CardCollapsible always uses overlay mode (showOverlay=true),
|
|
9
|
+
* which requires pixel-based height measurement instead of line-based counting.
|
|
10
|
+
* @default 180
|
|
11
|
+
*/
|
|
12
|
+
collapsedPixels?: number;
|
|
7
13
|
}
|
|
8
14
|
export declare const CardCollapsible: React.FC<ICardCollapsibleProps>;
|
|
@@ -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,95 @@
|
|
|
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;
|
|
49
|
+
/**
|
|
50
|
+
* Result of element height measurements for collapsible calculations.
|
|
51
|
+
*/
|
|
52
|
+
export interface MeasureHeightsResult {
|
|
53
|
+
/**
|
|
54
|
+
* The current rendered height of the element in the DOM (with clamp/max-height applied).
|
|
55
|
+
*/
|
|
56
|
+
clampedClientHeight: number;
|
|
57
|
+
/**
|
|
58
|
+
* The full content height with no clamping and no max-height applied.
|
|
59
|
+
*/
|
|
60
|
+
fullHeight: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Measures the current (clamped) clientHeight and the full content height by
|
|
64
|
+
* creating a hidden clone without clamping and without max-height.
|
|
65
|
+
*
|
|
66
|
+
* This allows overflow detection and overlay sizing for mixed-content
|
|
67
|
+
* rich text (e.g. combinations of h1, ul/li, p, code) where a single
|
|
68
|
+
* line-height is not representative.
|
|
69
|
+
*/
|
|
70
|
+
export declare const measureElementHeights: (element: HTMLElement | null) => MeasureHeightsResult;
|
|
71
|
+
export interface OverlayRatioParams {
|
|
72
|
+
/** Number of lines visible when collapsed (requested). */
|
|
73
|
+
collapsedLines: number;
|
|
74
|
+
/** Number of lines used for overlay sizing (requested). */
|
|
75
|
+
overlayLines: number;
|
|
76
|
+
/** Actual rendered height of the collapsed block (in pixels). */
|
|
77
|
+
clampedClientHeight: number;
|
|
78
|
+
/** Minimum visible pixels of content above overlay to avoid full cover. */
|
|
79
|
+
minVisiblePx?: number;
|
|
80
|
+
/** Minimum overlay thickness in pixels (after clamping). */
|
|
81
|
+
minOverlayPx?: number;
|
|
82
|
+
/** Maximum overlay thickness in pixels (after clamping). */
|
|
83
|
+
maxOverlayPx?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Computes overlay height as a ratio of the actual visible collapsed height
|
|
87
|
+
* instead of relying on a single line-height. This makes the overlay robust
|
|
88
|
+
* for mixed content where each line may have different heights.
|
|
89
|
+
*
|
|
90
|
+
* Constraints:
|
|
91
|
+
* - overlayLines is clamped to [0, collapsedLines - 1]
|
|
92
|
+
* - overlay cannot cover all visible content; we keep at least `minVisiblePx`
|
|
93
|
+
* - final result is clamped within [minOverlayPx, maxOverlayPx]
|
|
94
|
+
*/
|
|
95
|
+
export declare const computeOverlayHeightByRatio: (params: OverlayRatioParams) => number;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { type AnchorHTMLAttributes, type
|
|
2
|
-
|
|
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
|
*/
|