@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
144 lines (143 loc) • 5.22 kB
TypeScript
import { AdaptableIcon } from '../Common/AdaptableIcon';
import { AdaptablePredicate } from '../Common/AdaptablePredicate';
import { AdaptableBooleanQuery } from '../Common/AdaptableQuery';
import { AdaptableStyle, CellBoxStyle, CellFontStyle } from '../Common/AdaptableStyle';
import { TypeHint } from '../Common/Types';
/**
* Predicates available when creating a Badge Style Rule
*/
export type SystemBadgeStylePredicateId = 'In' | 'NotIn' | 'Blanks' | 'NonBlanks' | 'Equals' | 'NotEquals' | 'GreaterThan' | 'LessThan' | 'Positive' | 'Negative' | 'Zero' | 'Between' | 'NotBetween' | 'Is' | 'IsNot' | 'Contains' | 'NotContains' | 'StartsWith' | 'EndsWith' | 'Regex';
/**
* System Predicate Ids available for Badge Style
*/
export type SystemBadgeStylePredicateIds = SystemBadgeStylePredicateId[];
/**
* System Predicate definition for Badge Style
*/
export interface BadgeStylePredicate extends AdaptablePredicate {
PredicateId: TypeHint<string, SystemBadgeStylePredicateId>;
}
/** Keys copied from legacy `BadgeStyleDefinition.Style` (`AdaptableStyle`) into `PillStyle`. */
export declare const BADGE_PILL_STYLE_KEYS: readonly ["BackColor", "ForeColor", "BorderColor", "FontWeight", "FontStyle", "TextDecoration"];
/**
* Visual styling applied to a single Badge pill — an explicit subset of
* {@link AdaptableStyle}. Not used: `BorderRadius` ({@link BadgeShape}),
* `Alignment` / `FontSize` / `ClassName` (column-level or unsupported).
*/
export type BadgePillStyle = Pick<AdaptableStyle, (typeof BADGE_PILL_STYLE_KEYS)[number]>;
/**
* Visual shape of a Badge; convenience shorthand that resolves to a border radius without having to pick a pixel value
*/
export type BadgeShape = 'Pill' | 'Rounded' | 'Square';
/**
* Density preset that controls inner padding (and therefore overall height)
* for *all* badges in a column. Applied at the {@link BadgeStyle} level so
* a single column reads as one consistent label set.
*
* - `'Compact'` - tight padding for dense grids
* - `'Normal'` - default; balanced padding (matches pre-existing look)
* - `'Comfortable'` - looser padding for low-density / large-font grids
*/
export type BadgeDensity = 'Compact' | 'Normal' | 'Comfortable';
/**
* How adjacent badges in an array-column cell should lay out when the cell
* is too narrow to fit them on one line.
*
* - `'Truncate'` - default; badges sit on a single line and the cell clips
* anything that overflows (legacy behaviour).
* - `'Wrap'` - badges wrap onto subsequent lines; row height grows to fit.
* AG Grid `rowHeight` / `getRowHeight` should be tall enough to host the
* wrapped badges; consider `autoRowHeight` on the column.
* - `'Scroll'` - badges stay on one line and the cell becomes
* horizontally scrollable.
*/
export type BadgeOverflowMode = 'Truncate' | 'Wrap' | 'Scroll';
/**
* Icon settings for a {@link BadgeStyleDefinition} — the icon itself plus its
* placement and behaviour inside the pill. All four properties are tightly
* coupled (the placement / gap / icon-only flags are only meaningful when an
* `Icon` is set) so they live together in a single nested object.
*
* @public
*/
export interface BadgeIconProperties {
/**
* Icon to display in the badge.
*/
Icon: AdaptableIcon;
/**
* Position of the icon in the badge — `'Start'` or `'End'`.
*
* @defaultValue 'Start'
*/
Position?: 'Start' | 'End';
/**
* Pixel gap between the icon and the badge text. Falls back to the badge
* `Density` preset when omitted; ignored when {@link IconOnly} is `true`.
*/
Gap?: number;
/**
* Only show the icon and no badge text.
*/
IconOnly?: boolean;
}
/**
* Defines a Badge Style
*/
export interface BadgeStyleDefinition {
/**
* Optional Rule for deciding whether Badge is displayed
*/
Predicate?: BadgeStylePredicate;
Expression?: AdaptableBooleanQuery;
/**
* Style for the Badge **pill** (cut-down version of Adaptable Style)
*/
PillStyle?: BadgePillStyle;
/**
* Visual shape of the Badge's corner radius
*
* @defaultValue 'Rounded'
*/
Shape?: BadgeShape;
/**
* Settings for Icon to display alongside badge text
*/
IconProperties?: BadgeIconProperties;
}
/**
* Collection of Badge Style Definitions to display in a Badge Styled Column
*/
export interface BadgeStyle {
/**
* Collection of Badge Style Definitions
*/
Badges?: BadgeStyleDefinition[];
/**
* Density preset shared by every badge in the column - controls inner padding.
*
* @defaultValue 'Normal'
*/
Density?: BadgeDensity;
/**
* Pixel gap between adjacent badges in array-column cells
*
* @defaultValue 4
*/
Spacing?: number;
/**
* How badges lay out in array-column cells where space is tight
*
* @defaultValue 'Truncate'
*/
OverflowMode?: BadgeOverflowMode;
/**
* Optional cell-box styling applied to grid cell **behind** the badges
*/
Cell?: CellBoxStyle;
/**
* Optional column-level Font (only Alignment is meaningful for Badge cells)
*
*/
Font?: CellFontStyle;
}