diff --git a/packages/core/src/components/KeyValue/KeyValue.stories.tsx b/packages/core/src/components/KeyValue/KeyValue.stories.tsx index eff8f598..9a1f20f1 100644 --- a/packages/core/src/components/KeyValue/KeyValue.stories.tsx +++ b/packages/core/src/components/KeyValue/KeyValue.stories.tsx @@ -13,6 +13,7 @@ import { KeyValue } from './KeyValue'; import { HFlex } from '../HFlex'; import { Avatar } from '../Avatar'; import { KeyValueText, KeyValueTextContainer } from './components'; +import { VFlex } from '../VFlex'; const meta: Meta = { title: 'Components/Feedback/KeyValue', @@ -164,3 +165,44 @@ export const Custom: Story = { ))(args), }; + +export const DescriptionList: Story = { + name: 'Description list mode', + render: () => + (() => ( + + + + + + + ))(), +}; diff --git a/packages/core/src/components/KeyValue/KeyValue.tsx b/packages/core/src/components/KeyValue/KeyValue.tsx index d5708405..7a797a77 100644 --- a/packages/core/src/components/KeyValue/KeyValue.tsx +++ b/packages/core/src/components/KeyValue/KeyValue.tsx @@ -20,12 +20,16 @@ export const InternalKeyValue: React.FC = ({ id, invertOrder, keyContent, + keyTruncateLine = 1, + keyWidth, role, size = 'md', supportingVisual, tooltip, unit, valueContent, + valueTruncateLine = 1, + valueWidth, }) => ( = ({ ? 2 : 1 } + truncateLine={ + invertOrder && boldScheme === 'value' + ? keyTruncateLine + : boldScheme === 'value' + ? valueTruncateLine + : invertOrder + ? valueTruncateLine + : keyTruncateLine + } + width={ + invertOrder && boldScheme === 'value' + ? keyWidth + : boldScheme === 'value' + ? valueWidth + : invertOrder + ? valueWidth + : keyWidth + } size={size} > {boldScheme === 'key' ? keyContent : valueContent} @@ -65,6 +87,24 @@ export const InternalKeyValue: React.FC = ({ ? 1 : 2 } + truncateLine={ + invertOrder && boldScheme === 'value' + ? keyTruncateLine + : boldScheme === 'value' + ? keyTruncateLine + : invertOrder + ? keyTruncateLine + : valueTruncateLine + } + width={ + invertOrder && boldScheme === 'value' + ? keyWidth + : boldScheme === 'value' + ? keyWidth + : invertOrder + ? keyWidth + : valueWidth + } size={size} unit={unit} > diff --git a/packages/core/src/components/KeyValue/components/KeyValueText/KeyValueText.tsx b/packages/core/src/components/KeyValue/components/KeyValueText/KeyValueText.tsx index 7eb76bad..6f266500 100644 --- a/packages/core/src/components/KeyValue/components/KeyValueText/KeyValueText.tsx +++ b/packages/core/src/components/KeyValue/components/KeyValueText/KeyValueText.tsx @@ -11,6 +11,7 @@ export interface KeyValueTextProps Omit, Pick { bold?: boolean; + width?: React.CSSProperties['width']; } export const KeyValueText: React.FC = ({ @@ -21,17 +22,20 @@ export const KeyValueText: React.FC = ({ unit, order, size, + truncateLine = 1, + width, ...restTypographyProps }) => { const context = React.useContext(KeyValueContext); const evalSize = size || context.size; + return ( - + <> diff --git a/packages/core/src/components/KeyValue/components/KeyValueTextContainer/KeyValueTextContainer.tsx b/packages/core/src/components/KeyValue/components/KeyValueTextContainer/KeyValueTextContainer.tsx index d3a83273..5012270c 100644 --- a/packages/core/src/components/KeyValue/components/KeyValueTextContainer/KeyValueTextContainer.tsx +++ b/packages/core/src/components/KeyValue/components/KeyValueTextContainer/KeyValueTextContainer.tsx @@ -19,7 +19,13 @@ export const KeyValueTextContainer: React.FC = ({ return ( = ({ : undefined } minWidth="0" + width="100%" > {children} diff --git a/packages/core/src/components/KeyValue/declarations.ts b/packages/core/src/components/KeyValue/declarations.ts index 152b57b9..fd3f8e93 100644 --- a/packages/core/src/components/KeyValue/declarations.ts +++ b/packages/core/src/components/KeyValue/declarations.ts @@ -3,6 +3,7 @@ import * as React from 'react'; import type { TTypoBodySize } from '../../declarations'; import { PickUnion } from '../../typeFunctions'; +import type { ITypography } from '../Typography/declarations'; export type TKeyValueBoldScheme = 'key' | 'value'; export type TKeyValueFormat = 'base' | 'row' | 'column'; @@ -19,6 +20,11 @@ export interface IKeyValue { invertOrder?: boolean; /** The content for the key block. */ keyContent?: React.ReactNode; + /** The number of lines before get truncated text with overflow to ellipsis + * (Css line-clamp property). */ + keyTruncateLine?: ITypography['truncateLine']; + /** The width for the key block. */ + keyWidth?: React.CSSProperties['width']; /** The size of the component which defines font-size, spacing, line-height... * etc. */ size?: PickUnion; @@ -29,6 +35,11 @@ export interface IKeyValue { unit?: React.ReactNode; /** The content for the value block. */ valueContent?: React.ReactNode; + /** The width for the value block. */ + valueWidth?: React.CSSProperties['width']; + /** The number of lines before get truncated text with overflow to ellipsis + * (Css line-clamp property). */ + valueTruncateLine?: ITypography['truncateLine']; /** The supporting visual: icon, image, SVG... etc. at the beginning of the * component (if it's React Icon component from genesys-icons library it will * inherit the perfect size from context). */ diff --git a/packages/core/src/components/SelectControl/SelectControl.cases.stories.tsx b/packages/core/src/components/SelectControl/SelectControl.cases.stories.tsx index 85c3ddd5..c2b70749 100644 --- a/packages/core/src/components/SelectControl/SelectControl.cases.stories.tsx +++ b/packages/core/src/components/SelectControl/SelectControl.cases.stories.tsx @@ -81,7 +81,7 @@ export const SingleOptionWithReset: Story = { {...props} //menuIsOpen onChange={(opt: TSelectOption) => { - setValue(opt.value) + setValue(opt.value); }} options={[ { value: 1, label: 'Option one' }, @@ -224,6 +224,7 @@ export const MultipleBasic: Story = { onChange={(val) => setValue(val)} options={getOptions(50)} value={value} + maxMenuWidth="120px" /> ); })(args), diff --git a/packages/core/src/components/SelectControl/components/Menu/Menu.tsx b/packages/core/src/components/SelectControl/components/Menu/Menu.tsx index 65c62a00..727ac289 100644 --- a/packages/core/src/components/SelectControl/components/Menu/Menu.tsx +++ b/packages/core/src/components/SelectControl/components/Menu/Menu.tsx @@ -42,6 +42,7 @@ export const Menu =