Skip to content

Commit 5671400

Browse files
authored
release of v10.101.1 (#7097)
2 parents 9f44cb2 + 4f96fda commit 5671400

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2852
-171
lines changed

packages/dnb-design-system-portal/src/docs/uilib/components/stat/Examples.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import React from 'react'
2-
import ComponentBox from '../../../../shared/tags/ComponentBox'
3-
import Stat from '@dnb/eufemia/src/components/Stat'
1+
import { useTranslation } from '@dnb/eufemia/shared'
42
import {
53
Card,
64
Code,
@@ -10,8 +8,9 @@ import {
108
Icon,
119
IconPrimary,
1210
} from '@dnb/eufemia/src'
13-
import { useTranslation } from '@dnb/eufemia/shared'
11+
import Stat from '@dnb/eufemia/src/components/Stat'
1412
import { globe_medium } from '@dnb/eufemia/src/icons'
13+
import ComponentBox from '../../../../shared/tags/ComponentBox'
1514

1615
export const BasicUsage = () => (
1716
<ComponentBox data-visual-test="stat-amount-default">
@@ -199,6 +198,27 @@ export const PercentDefault = () => (
199198
</ComponentBox>
200199
)
201200

201+
export const PercentColorizeBySign = () => (
202+
<ComponentBox data-visual-test="stat-percent-colorize-by-sign">
203+
<Stat.Root>
204+
<Stat.Label>Positive without signDisplay</Stat.Label>
205+
<Stat.Content>
206+
<Stat.Percent value={12.3} fontSize="medium" colorizeBySign />
207+
</Stat.Content>
208+
209+
<Stat.Label top>Negative without signDisplay</Stat.Label>
210+
<Stat.Content>
211+
<Stat.Percent value={-12.3} fontSize="medium" colorizeBySign />
212+
</Stat.Content>
213+
214+
<Stat.Label top>Zero without signDisplay</Stat.Label>
215+
<Stat.Content>
216+
<Stat.Percent value={0} fontSize="medium" colorizeBySign />
217+
</Stat.Content>
218+
</Stat.Root>
219+
</ComponentBox>
220+
)
221+
202222
export const RatingDefault = () => (
203223
<ComponentBox data-visual-test="stat-rating-default">
204224
<Stat.Root>

packages/dnb-design-system-portal/src/docs/uilib/components/stat/demos.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ You can use `mainSize` and `auxiliarySize` to adjust the relative size of the cu
4040

4141
<Examples.PercentDefault />
4242

43+
### Percent colorized by sign
44+
45+
<Examples.PercentColorizeBySign />
46+
4347
### Rating
4448

4549
<Examples.RatingDefault />

packages/dnb-design-system-portal/src/docs/uilib/components/stat/info.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ import { Stat } from '@dnb/eufemia'
3232

3333
- `Stat.Info` renders supporting text with a smaller, muted style.
3434

35+
- `Stat.Inline` is a horizontal layout container for grouping content elements like `Stat.Trend` and `Stat.Info` side by side with consistent spacing and alignment.
36+
37+
### Deprecated
38+
39+
- `Stat.Amount` is deprecated and will be removed in a future version. Use `Stat.Number` instead.
40+
3541
## Accessibility
3642

3743
- `Stat.Root` provides semantic definition-list markup (`dl`), where `Stat.Label` is rendered as `dt` and `Stat.Content` as `dd`.

packages/dnb-eufemia/src/components/list/Container.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1-
import React from 'react'
1+
import React, { useContext } from 'react'
22
import classnames from 'classnames'
33
import { ListVariant, ListContext } from './ListContext'
44
import FlexContainer, { Props as FlexProps } from '../flex/Stack'
5+
import type { SkeletonShow } from '../Skeleton'
6+
import SharedContext from '../../shared/Context'
57

68
export type ListContainerProps = {
79
variant?: ListVariant
810
separated?: boolean
9-
} & React.HTMLAttributes<HTMLDivElement> &
10-
FlexProps
11+
skeleton?: SkeletonShow
12+
disabled?: boolean
13+
} & FlexProps
1114

1215
function ListContainer(props: ListContainerProps) {
1316
const {
1417
className,
1518
children,
1619
variant = 'basic',
17-
separated,
20+
separated = false,
21+
skeleton,
22+
disabled,
1823
wrapChildrenInSpace = false,
1924
...rest
2025
} = props
2126

27+
const parentContext = useContext(ListContext)
28+
const globalContext = useContext(SharedContext)
29+
const appliedSkeleton =
30+
skeleton ?? parentContext?.skeleton ?? globalContext?.skeleton
31+
const appliedDisabled = disabled ?? parentContext?.disabled
32+
2233
return (
23-
<ListContext.Provider value={{ variant, separated }}>
34+
<ListContext.Provider
35+
value={{
36+
variant,
37+
separated,
38+
skeleton: appliedSkeleton,
39+
disabled: appliedDisabled,
40+
}}
41+
>
2442
<FlexContainer
2543
element="ul"
2644
rowGap={separated ? 'small' : false}

packages/dnb-eufemia/src/components/list/ItemAccordion.tsx

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, {
77
} from 'react'
88
import classnames from 'classnames'
99
import useId from '../../shared/helpers/useId'
10-
import { ListVariant } from './ListContext'
10+
import { ListVariant, ListContext } from './ListContext'
1111
import ItemContent, { ItemContentProps } from './ItemContent'
1212
import FlexItem from '../flex/Item'
1313
import type { IconIcon } from '../icon/Icon'
@@ -18,6 +18,8 @@ import Space from '../space/Space'
1818
import { omitSpacingProps, pickSpacingProps } from '../flex/utils'
1919
import ItemIcon from './ItemIcon'
2020
import ItemTitle from './ItemTitle'
21+
import { createSkeletonClass } from '../skeleton/SkeletonHelper'
22+
import Context from '../../shared/Context'
2123

2224
export type ItemAccordionIconPosition = 'left' | 'right'
2325

@@ -28,6 +30,10 @@ export type ItemAccordionProps = {
2830
* When true, keeps the accordion content in the DOM when closed. Defaults to false.
2931
*/
3032
keepInDOM?: boolean
33+
/**
34+
* When true, the accordion is visually dimmed and interaction is prevented.
35+
*/
36+
disabled?: boolean
3137
chevronPosition?: ItemAccordionIconPosition
3238
icon?: IconIcon
3339
title?: React.ReactNode
@@ -38,6 +44,7 @@ const ItemAccordionContext = createContext<{
3844
open?: boolean
3945
openState: boolean
4046
pending?: boolean
47+
disabled?: boolean
4148
keepInDOM?: boolean
4249
chevronPosition?: ItemAccordionIconPosition
4350
accordionId: string
@@ -54,6 +61,8 @@ function ItemAccordion(props: ItemAccordionProps) {
5461
children,
5562
variant,
5663
pending,
64+
disabled,
65+
skeleton,
5766
open = false,
5867
keepInDOM = false,
5968
chevronPosition = 'right',
@@ -65,6 +74,8 @@ function ItemAccordion(props: ItemAccordionProps) {
6574

6675
const [openState, setOpen] = useState(open)
6776
const accordionId = useId(idProp)
77+
const inheritedDisabled = useContext(ListContext)?.disabled
78+
const appliedDisabled = disabled ?? inheritedDisabled
6879
const childArray = React.Children.toArray(children)
6980
const hasExplicitHeader = childArray.some(
7081
(child) =>
@@ -81,6 +92,7 @@ function ItemAccordion(props: ItemAccordionProps) {
8192
open,
8293
openState,
8394
pending,
95+
disabled: appliedDisabled,
8496
keepInDOM,
8597
chevronPosition,
8698
accordionId,
@@ -98,6 +110,8 @@ function ItemAccordion(props: ItemAccordionProps) {
98110
)}
99111
direction="vertical"
100112
pending={pending}
113+
disabled={appliedDisabled}
114+
skeleton={skeleton}
101115
variant={variant}
102116
{...rest}
103117
>
@@ -120,21 +134,26 @@ function AccordionHeader(props: AccordionHeaderProps) {
120134
setOpen,
121135
onClick,
122136
pending,
137+
disabled,
123138
chevronPosition,
124139
accordionId,
125140
openState,
126141
icon,
127142
title,
128143
} = useContext(ItemAccordionContext)
129144

145+
const context = useContext(Context)
146+
const inheritedSkeleton = useContext(ListContext)?.skeleton
147+
const isInactive = pending || disabled
148+
130149
const handleClick = useCallback(
131150
(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
132-
if (!pending) {
151+
if (!isInactive) {
133152
setOpen((prev) => !prev)
134153
onClick && onClick(event)
135154
}
136155
},
137-
[onClick, pending, setOpen]
156+
[onClick, isInactive, setOpen]
138157
)
139158

140159
const handleKeyDown = useCallback(
@@ -149,19 +168,20 @@ function AccordionHeader(props: AccordionHeaderProps) {
149168
[handleClick]
150169
)
151170

152-
return (
171+
const content = (
153172
<FlexItem
154173
className={classnames(
155174
'dnb-list__item__accordion__header',
156175
chevronPosition === 'left' && 'dnb-list__item--chevron-left',
176+
inheritedSkeleton && createSkeletonClass('font', true),
157177
className
158178
)}
159179
id={`${accordionId}-header`}
160180
role="button"
161181
aria-controls={`${accordionId}-content`}
162182
aria-expanded={openState}
163-
aria-disabled={pending ? true : undefined}
164-
tabIndex={pending ? -1 : 0}
183+
aria-disabled={isInactive ? true : undefined}
184+
tabIndex={isInactive ? -1 : 0}
165185
onClick={handleClick}
166186
onKeyDown={handleKeyDown}
167187
{...rest}
@@ -173,22 +193,37 @@ function AccordionHeader(props: AccordionHeaderProps) {
173193
{chevronPosition === 'right' && <ChevronIcon />}
174194
</FlexItem>
175195
)
196+
197+
if (inheritedSkeleton) {
198+
return (
199+
<Context.Provider
200+
value={{ ...context, skeleton: inheritedSkeleton }}
201+
>
202+
{content}
203+
</Context.Provider>
204+
)
205+
}
206+
207+
return content
176208
}
177209
ItemAccordion.Header = AccordionHeader
178210
AccordionHeader._supportsSpacingProps = true
179211

180212
function AccordionContent(props: ItemContentProps) {
181213
const { className, children, ...rest } = props
214+
const context = useContext(Context)
182215
const { openState, accordionId, keepInDOM } = useContext(
183216
ItemAccordionContext
184217
)
218+
const inheritedSkeleton = useContext(ListContext)?.skeleton
185219

186220
const spacingProps = pickSpacingProps(rest)
187221

188-
return (
222+
const content = (
189223
<FlexItem
190224
className={classnames(
191225
'dnb-list__item__accordion__content',
226+
inheritedSkeleton && createSkeletonClass('font', true),
192227
className
193228
)}
194229
id={`${accordionId}-content`}
@@ -203,6 +238,18 @@ function AccordionContent(props: ItemContentProps) {
203238
</HeightAnimation>
204239
</FlexItem>
205240
)
241+
242+
if (inheritedSkeleton) {
243+
return (
244+
<Context.Provider
245+
value={{ ...context, skeleton: inheritedSkeleton }}
246+
>
247+
{content}
248+
</Context.Provider>
249+
)
250+
}
251+
252+
return content
206253
}
207254
ItemAccordion.Content = AccordionContent
208255
AccordionContent._supportsSpacingProps = true

0 commit comments

Comments
 (0)