@drivenets/design-system 0.5.0 → 0.6.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 +7 -0
- package/dist/components/ds-alert-banner/ds-alert-banner.d.ts +5 -5
- package/dist/components/ds-autocomplete/ds-autocomplete.d.ts +2 -2
- package/dist/components/ds-autocomplete/ds-autocomplete.d.ts.map +1 -1
- package/dist/components/ds-button/ds-button.d.ts +2 -2
- package/dist/components/ds-button/versions/ds-button-legacy/ds-button-legacy.d.ts +2 -0
- package/dist/components/ds-button/versions/ds-button-legacy/ds-button-legacy.types.d.ts +1 -1
- package/dist/components/ds-button/versions/ds-button-legacy/index.d.ts +2 -0
- package/dist/components/ds-card/ds-card.d.cts +5 -5
- package/dist/components/ds-card/ds-card.d.cts.map +1 -1
- package/dist/components/ds-card/ds-card.d.ts +5 -5
- package/dist/components/ds-card/ds-card.module.cjs +4 -4
- package/dist/components/ds-card/ds-card.module.js +4 -4
- package/dist/components/ds-card/ds-card.module.js.map +1 -1
- package/dist/components/ds-confirmation/ds-confirmation.d.cts +8 -8
- package/dist/components/ds-confirmation/ds-confirmation.d.cts.map +1 -1
- package/dist/components/ds-confirmation/ds-confirmation.d.ts +8 -8
- package/dist/components/ds-date-input/ds-date-input.d.cts +2 -2
- package/dist/components/ds-drawer/ds-drawer.d.cts +9 -9
- package/dist/components/ds-drawer/ds-drawer.d.ts +9 -9
- package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.cts +2 -2
- package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.cts.map +1 -1
- package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.ts +2 -2
- package/dist/components/ds-form-control/ds-form-control.d.cts +8 -8
- package/dist/components/ds-icon/ds-icon.d.cts +2 -2
- package/dist/components/ds-icon/ds-icon.d.ts +2 -2
- package/dist/components/ds-icon/ds-icon.d.ts.map +1 -1
- package/dist/components/ds-loader/ds-loader.d.cts +2 -2
- package/dist/components/ds-loader/ds-loader.d.ts +2 -2
- package/dist/components/ds-modal/ds-modal.d.cts +8 -8
- package/dist/components/ds-modal/ds-modal.d.ts +8 -8
- package/dist/components/ds-panel/ds-panel.cjs +112 -33
- package/dist/components/ds-panel/ds-panel.d.cts +3 -2
- package/dist/components/ds-panel/ds-panel.d.cts.map +1 -1
- package/dist/components/ds-panel/ds-panel.d.ts +3 -2
- package/dist/components/ds-panel/ds-panel.d.ts.map +1 -1
- package/dist/components/ds-panel/ds-panel.js +112 -33
- package/dist/components/ds-panel/ds-panel.js.map +1 -1
- package/dist/components/ds-panel/ds-panel.module.cjs +7 -6
- package/dist/components/ds-panel/ds-panel.module.js +7 -6
- package/dist/components/ds-panel/ds-panel.module.js.map +1 -1
- package/dist/components/ds-panel/ds-panel.types.d.cts +1 -0
- package/dist/components/ds-panel/ds-panel.types.d.cts.map +1 -1
- package/dist/components/ds-panel/ds-panel.types.d.ts +1 -0
- package/dist/components/ds-panel/ds-panel.types.d.ts.map +1 -1
- package/dist/components/ds-select/ds-select.d.cts +2 -2
- package/dist/components/ds-select/ds-select.d.ts +2 -2
- package/dist/components/ds-skeleton/ds-skeleton-circle.d.cts +2 -2
- package/dist/components/ds-skeleton/ds-skeleton-rect.d.cts +2 -2
- package/dist/components/ds-skeleton/ds-skeleton-text.d.cts +2 -2
- package/dist/components/ds-skeleton/ds-skeleton.d.cts +4 -4
- package/dist/components/ds-smart-tabs/ds-smart-tabs.d.cts +2 -2
- package/dist/components/ds-smart-tabs/ds-smart-tabs.d.ts +2 -2
- package/dist/components/ds-stepper/components/ds-step-content.cjs +31 -35
- package/dist/components/ds-stepper/components/ds-step-content.d.cts +5 -5
- package/dist/components/ds-stepper/components/ds-step-content.d.cts.map +1 -1
- package/dist/components/ds-stepper/components/ds-step-content.d.ts +5 -5
- package/dist/components/ds-stepper/components/ds-step-content.d.ts.map +1 -1
- package/dist/components/ds-stepper/components/ds-step-content.js +32 -36
- package/dist/components/ds-stepper/components/ds-step-content.js.map +1 -1
- package/dist/components/ds-stepper/components/ds-step-next-button.cjs +34 -17
- package/dist/components/ds-stepper/components/ds-step-next-button.d.cts +8 -5
- package/dist/components/ds-stepper/components/ds-step-next-button.d.cts.map +1 -1
- package/dist/components/ds-stepper/components/ds-step-next-button.d.ts +9 -5
- package/dist/components/ds-stepper/components/ds-step-next-button.d.ts.map +1 -1
- package/dist/components/ds-stepper/components/ds-step-next-button.js +34 -17
- package/dist/components/ds-stepper/components/ds-step-next-button.js.map +1 -1
- package/dist/components/ds-stepper/components/ds-step-separator.cjs +36 -0
- package/dist/components/ds-stepper/components/ds-step-separator.js +36 -0
- package/dist/components/ds-stepper/components/ds-step-separator.js.map +1 -0
- package/dist/components/ds-stepper/components/ds-step.cjs +145 -90
- package/dist/components/ds-stepper/components/ds-step.d.cts +24 -5
- package/dist/components/ds-stepper/components/ds-step.d.cts.map +1 -1
- package/dist/components/ds-stepper/components/ds-step.d.ts +24 -5
- package/dist/components/ds-stepper/components/ds-step.d.ts.map +1 -1
- package/dist/components/ds-stepper/components/ds-step.js +145 -90
- package/dist/components/ds-stepper/components/ds-step.js.map +1 -1
- package/dist/components/ds-stepper/ds-stepper.cjs +75 -48
- package/dist/components/ds-stepper/ds-stepper.d.cts +7 -3
- package/dist/components/ds-stepper/ds-stepper.d.cts.map +1 -1
- package/dist/components/ds-stepper/ds-stepper.d.ts +7 -3
- package/dist/components/ds-stepper/ds-stepper.d.ts.map +1 -1
- package/dist/components/ds-stepper/ds-stepper.js +76 -49
- package/dist/components/ds-stepper/ds-stepper.js.map +1 -1
- package/dist/components/ds-stepper/ds-stepper.module.cjs +17 -11
- package/dist/components/ds-stepper/ds-stepper.module.js +17 -11
- package/dist/components/ds-stepper/ds-stepper.module.js.map +1 -1
- package/dist/components/ds-stepper/ds-stepper.types.d.cts +11 -2
- package/dist/components/ds-stepper/ds-stepper.types.d.cts.map +1 -1
- package/dist/components/ds-stepper/ds-stepper.types.d.ts +11 -2
- package/dist/components/ds-stepper/ds-stepper.types.d.ts.map +1 -1
- package/dist/components/ds-stepper/hooks/use-stepper.js.map +1 -1
- package/dist/components/ds-stepper/hooks/use-steps.cjs +13 -11
- package/dist/components/ds-stepper/hooks/use-steps.js +13 -11
- package/dist/components/ds-stepper/hooks/use-steps.js.map +1 -1
- package/dist/components/ds-stepper/index.d.ts +4 -4
- package/dist/components/ds-table/ds-table.d.cts +2 -2
- package/dist/components/ds-tabs/ds-tabs.d.cts +5 -5
- package/dist/components/ds-tag/ds-tag.d.cts +2 -2
- package/dist/components/ds-tag/ds-tag.d.ts +2 -2
- package/dist/components/ds-tag-filter/ds-tag-filter.d.cts +2 -2
- package/dist/components/ds-tag-filter/ds-tag-filter.d.ts +2 -2
- package/dist/components/ds-toggle/ds-toggle.d.cts +2 -2
- package/dist/components/ds-toggle/ds-toggle.d.ts +2 -2
- package/dist/components/ds-vertical-tabs/ds-vertical-tabs.d.cts +5 -5
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.min.css +1 -1
- package/package.json +1 -1
- package/src/components/ds-card/ds-card.module.scss +3 -11
- package/src/components/ds-panel/ds-panel.module.scss +6 -0
- package/src/components/ds-panel/ds-panel.tsx +85 -0
- package/src/components/ds-panel/ds-panel.types.ts +1 -0
- package/src/components/ds-stepper/components/ds-step-content.tsx +25 -7
- package/src/components/ds-stepper/components/ds-step-next-button.tsx +8 -3
- package/src/components/ds-stepper/components/ds-step-separator.tsx +22 -0
- package/src/components/ds-stepper/components/ds-step.tsx +69 -10
- package/src/components/ds-stepper/ds-stepper.module.scss +193 -31
- package/src/components/ds-stepper/ds-stepper.tsx +29 -5
- package/src/components/ds-stepper/ds-stepper.types.ts +11 -1
- package/src/components/ds-stepper/hooks/use-stepper.ts +3 -1
- package/src/components/ds-stepper/hooks/use-steps.ts +3 -2
- package/src/components/ds-stepper/index.tsx +4 -4
- package/src/styles/_mixin.scss +1 -0
- package/src/styles/mixins/_disabled.scss +18 -0
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use '../../styles/mixin' as mixins;
|
|
2
|
+
|
|
1
3
|
$border-radius: 8px;
|
|
2
4
|
$min-width-small: 224px;
|
|
3
5
|
$min-width-medium: 264px;
|
|
@@ -13,18 +15,8 @@ $transition-duration: 0.2s;
|
|
|
13
15
|
overflow: hidden;
|
|
14
16
|
box-sizing: border-box;
|
|
15
17
|
border-radius: $border-radius;
|
|
16
|
-
}
|
|
17
18
|
|
|
18
|
-
.
|
|
19
|
-
&::after {
|
|
20
|
-
content: '';
|
|
21
|
-
position: absolute;
|
|
22
|
-
inset: 0;
|
|
23
|
-
// TODO: remove once we import all the tokens from figma
|
|
24
|
-
background: rgba(255, 255, 255, 0.6);
|
|
25
|
-
pointer-events: none;
|
|
26
|
-
border-radius: inherit;
|
|
27
|
-
}
|
|
19
|
+
@include mixins.disabled-overlay;
|
|
28
20
|
}
|
|
29
21
|
|
|
30
22
|
.root[data-size='small'] {
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.22));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
&.dragging {
|
|
27
|
+
cursor: grabbing;
|
|
28
|
+
user-select: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
&.disablePadding {
|
|
27
32
|
padding: 0;
|
|
28
33
|
}
|
|
@@ -89,6 +94,7 @@
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
.root.variantFloating & {
|
|
97
|
+
z-index: 1;
|
|
92
98
|
top: 50%;
|
|
93
99
|
transform: translateY(-50%);
|
|
94
100
|
}
|
|
@@ -1,9 +1,89 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
1
2
|
import * as Collapsible from '@radix-ui/react-collapsible';
|
|
2
3
|
import classnames from 'classnames';
|
|
3
4
|
import styles from './ds-panel.module.scss';
|
|
4
5
|
import { DsIcon } from '../ds-icon';
|
|
5
6
|
import type { DsPanelCollapseButtonProps, DsPanelProps } from './ds-panel.types';
|
|
6
7
|
|
|
8
|
+
function useDraggable(enabled: boolean) {
|
|
9
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
10
|
+
const positionRef = useRef({ x: 0, y: 0 });
|
|
11
|
+
const dragRef = useRef<{
|
|
12
|
+
startX: number;
|
|
13
|
+
startY: number;
|
|
14
|
+
originX: number;
|
|
15
|
+
originY: number;
|
|
16
|
+
} | null>(null);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const root = rootRef.current;
|
|
20
|
+
|
|
21
|
+
if (!root) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!enabled) {
|
|
26
|
+
positionRef.current = { x: 0, y: 0 };
|
|
27
|
+
root.style.transform = '';
|
|
28
|
+
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const handleMouseDown = (e: MouseEvent) => {
|
|
33
|
+
const target = e.target as HTMLElement;
|
|
34
|
+
|
|
35
|
+
if (!target.closest('[data-drag-handle]')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
|
|
41
|
+
dragRef.current = {
|
|
42
|
+
startX: e.clientX,
|
|
43
|
+
startY: e.clientY,
|
|
44
|
+
originX: positionRef.current.x,
|
|
45
|
+
originY: positionRef.current.y,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
root.classList.add(styles.dragging);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
52
|
+
if (!dragRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
positionRef.current = {
|
|
57
|
+
x: dragRef.current.originX + (e.clientX - dragRef.current.startX),
|
|
58
|
+
y: dragRef.current.originY + (e.clientY - dragRef.current.startY),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
root.style.transform = `translate(${String(positionRef.current.x)}px, ${String(positionRef.current.y)}px)`;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleMouseUp = () => {
|
|
65
|
+
if (!dragRef.current) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
dragRef.current = null;
|
|
70
|
+
root.classList.remove(styles.dragging);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
root.addEventListener('mousedown', handleMouseDown);
|
|
74
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
75
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
76
|
+
|
|
77
|
+
return () => {
|
|
78
|
+
root.removeEventListener('mousedown', handleMouseDown);
|
|
79
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
80
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
81
|
+
};
|
|
82
|
+
}, [enabled]);
|
|
83
|
+
|
|
84
|
+
return rootRef;
|
|
85
|
+
}
|
|
86
|
+
|
|
7
87
|
export function DsPanel({
|
|
8
88
|
open,
|
|
9
89
|
onOpenChange,
|
|
@@ -11,11 +91,16 @@ export function DsPanel({
|
|
|
11
91
|
className,
|
|
12
92
|
slotProps,
|
|
13
93
|
variant = 'docked',
|
|
94
|
+
draggable = false,
|
|
14
95
|
disablePadding = false,
|
|
15
96
|
...props
|
|
16
97
|
}: DsPanelProps) {
|
|
98
|
+
const isDraggable = variant === 'floating' && draggable;
|
|
99
|
+
const rootRef = useDraggable(isDraggable);
|
|
100
|
+
|
|
17
101
|
return (
|
|
18
102
|
<Collapsible.Root
|
|
103
|
+
ref={rootRef}
|
|
19
104
|
open={open}
|
|
20
105
|
onOpenChange={onOpenChange}
|
|
21
106
|
className={classnames(styles.root, className, {
|
|
@@ -4,6 +4,7 @@ export type DsPanelVariant = 'docked' | 'floating';
|
|
|
4
4
|
|
|
5
5
|
export type DsPanelProps = Omit<Collapsible.CollapsibleProps, 'onOpenChange'> & {
|
|
6
6
|
variant?: DsPanelVariant;
|
|
7
|
+
draggable?: boolean;
|
|
7
8
|
disablePadding?: boolean;
|
|
8
9
|
slotProps?: {
|
|
9
10
|
collapseButton?: DsPanelCollapseButtonProps;
|
|
@@ -2,31 +2,49 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
import { useStepper } from '../hooks/use-stepper';
|
|
3
3
|
import { DsStepLabel } from './ds-step-label';
|
|
4
4
|
import { DsStepDescription } from './ds-step-description';
|
|
5
|
+
import { DsStepSeparator } from './ds-step-separator';
|
|
5
6
|
import classnames from 'classnames';
|
|
6
7
|
import styles from '../ds-stepper.module.scss';
|
|
7
8
|
|
|
8
|
-
type DsStepContentProps = {
|
|
9
|
+
export type DsStepContentProps = {
|
|
9
10
|
index: number;
|
|
10
|
-
label:
|
|
11
|
-
description?:
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
12
13
|
actions?: ReactNode;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export function DsStepContent({ index, label, description, actions }: DsStepContentProps) {
|
|
16
|
-
const { variant, stepsApi } = useStepper();
|
|
17
|
+
const { variant, orientation, stepsApi } = useStepper();
|
|
17
18
|
const { current } = stepsApi.getItemState({ index });
|
|
18
19
|
|
|
20
|
+
const isHorizontal = orientation === 'horizontal';
|
|
21
|
+
const showDescription = variant !== 'single' && description;
|
|
22
|
+
|
|
19
23
|
return (
|
|
20
24
|
<div
|
|
21
25
|
className={classnames(styles.stepContent, {
|
|
22
26
|
[styles.stepContentSingle]: variant === 'single',
|
|
23
27
|
})}
|
|
24
28
|
>
|
|
25
|
-
|
|
29
|
+
{isHorizontal ? (
|
|
30
|
+
<>
|
|
31
|
+
<div className={styles.stepLabelRow}>
|
|
32
|
+
<DsStepLabel>{label}</DsStepLabel>
|
|
33
|
+
|
|
34
|
+
<DsStepSeparator index={index} />
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
{showDescription && <DsStepDescription>{description}</DsStepDescription>}
|
|
38
|
+
</>
|
|
39
|
+
) : (
|
|
40
|
+
<>
|
|
41
|
+
<DsStepLabel>{label}</DsStepLabel>
|
|
26
42
|
|
|
27
|
-
|
|
43
|
+
{showDescription && <DsStepDescription>{description}</DsStepDescription>}
|
|
28
44
|
|
|
29
|
-
|
|
45
|
+
{actions && current && <div className={styles.stepActions}>{actions}</div>}
|
|
46
|
+
</>
|
|
47
|
+
)}
|
|
30
48
|
</div>
|
|
31
49
|
);
|
|
32
50
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react';
|
|
2
1
|
import { useStepper } from '../hooks/use-stepper';
|
|
3
2
|
import DsButton from '../../ds-button/ds-button';
|
|
3
|
+
import type { DsButtonProps } from '../../ds-button/versions/ds-button-legacy';
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type DsNextStepButtonProps = Pick<
|
|
6
|
+
DsButtonProps,
|
|
7
|
+
'variant' | 'size' | 'className' | 'style' | 'children'
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function DsNextStepButton({ children, size = 'small', ...rest }: DsNextStepButtonProps) {
|
|
6
11
|
const context = useStepper();
|
|
7
12
|
|
|
8
13
|
return (
|
|
9
|
-
<DsButton {...context.stepsApi.getNextTriggerProps()} size=
|
|
14
|
+
<DsButton {...context.stepsApi.getNextTriggerProps()} size={size} {...rest}>
|
|
10
15
|
{children}
|
|
11
16
|
</DsButton>
|
|
12
17
|
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useStepper } from '../hooks/use-stepper';
|
|
2
|
+
import styles from '../ds-stepper.module.scss';
|
|
3
|
+
|
|
4
|
+
type DsStepSeparatorProps = {
|
|
5
|
+
index: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function DsStepSeparator({ index }: DsStepSeparatorProps) {
|
|
9
|
+
const { stepsApi, orientation } = useStepper();
|
|
10
|
+
const { last } = stepsApi.getItemState({ index });
|
|
11
|
+
|
|
12
|
+
if (last) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
{...stepsApi.getSeparatorProps({ index })}
|
|
19
|
+
className={orientation === 'horizontal' ? styles.horizontalSeparator : styles.separator}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react';
|
|
1
|
+
import type { MouseEvent, PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
import { useStepper } from '../hooks/use-stepper';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import styles from '../ds-stepper.module.scss';
|
|
5
5
|
import DsIcon from '../../ds-icon/ds-icon';
|
|
6
|
+
import { DsStepSeparator } from './ds-step-separator';
|
|
6
7
|
|
|
7
|
-
type DsStepProps = PropsWithChildren<{
|
|
8
|
+
export type DsStepProps = PropsWithChildren<{
|
|
8
9
|
index: number;
|
|
9
10
|
className?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Represents the variant type that determines the state or style of a component.
|
|
14
|
+
* @default 'default'
|
|
15
|
+
*/
|
|
16
|
+
variant?: 'error' | 'default';
|
|
17
|
+
slots?: {
|
|
18
|
+
indicator?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
slotProps?: {
|
|
21
|
+
indicator?: {
|
|
22
|
+
className?: string;
|
|
23
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
10
26
|
}>;
|
|
11
27
|
|
|
12
|
-
export function DsStep({
|
|
28
|
+
export function DsStep({
|
|
29
|
+
index,
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
disabled,
|
|
33
|
+
variant = 'default',
|
|
34
|
+
slots,
|
|
35
|
+
slotProps,
|
|
36
|
+
}: DsStepProps) {
|
|
13
37
|
const context = useStepper();
|
|
14
38
|
|
|
15
39
|
const { completed, current, last } = context.stepsApi.getItemState({ index });
|
|
16
40
|
|
|
17
41
|
const isSingleVariant = context.variant === 'single';
|
|
42
|
+
const isHorizontal = context.orientation === 'horizontal';
|
|
18
43
|
const isLast = last && context.stepsApi.value === index + 1;
|
|
19
44
|
|
|
20
45
|
const shouldHide = isSingleVariant && !current && !isLast;
|
|
@@ -23,7 +48,7 @@ export function DsStep({ index, children, className }: DsStepProps) {
|
|
|
23
48
|
return null;
|
|
24
49
|
}
|
|
25
50
|
|
|
26
|
-
const isClickable = completed && !isSingleVariant;
|
|
51
|
+
const isClickable = completed && !isSingleVariant && !disabled;
|
|
27
52
|
|
|
28
53
|
const Wrapper = isClickable ? 'button' : 'div';
|
|
29
54
|
|
|
@@ -35,22 +60,56 @@ export function DsStep({ index, children, className }: DsStepProps) {
|
|
|
35
60
|
}
|
|
36
61
|
: {};
|
|
37
62
|
|
|
63
|
+
const indicatorClassName = classnames(styles.indicator, slotProps?.indicator?.className);
|
|
64
|
+
|
|
65
|
+
const renderIndicator = () => {
|
|
66
|
+
if (slots?.indicator) {
|
|
67
|
+
return (
|
|
68
|
+
<span {...slotProps?.indicator} className={indicatorClassName}>
|
|
69
|
+
{slots.indicator}
|
|
70
|
+
</span>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (variant === 'error') {
|
|
75
|
+
return (
|
|
76
|
+
<span {...slotProps?.indicator} className={slotProps?.indicator?.className}>
|
|
77
|
+
<DsIcon icon="close" className={indicatorClassName} />
|
|
78
|
+
</span>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (completed) {
|
|
83
|
+
return (
|
|
84
|
+
<span {...slotProps?.indicator} className={slotProps?.indicator?.className}>
|
|
85
|
+
<DsIcon icon="check" className={indicatorClassName} />
|
|
86
|
+
</span>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<span {...slotProps?.indicator} className={indicatorClassName}>
|
|
92
|
+
{index + 1}
|
|
93
|
+
</span>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
38
97
|
return (
|
|
39
98
|
<Wrapper
|
|
40
99
|
{...context.stepsApi.getItemProps({ index })}
|
|
41
100
|
data-current={current ? '' : undefined}
|
|
42
101
|
data-complete={completed ? '' : undefined}
|
|
102
|
+
data-disabled={disabled ? '' : undefined}
|
|
103
|
+
data-error={variant === 'error' ? '' : undefined}
|
|
43
104
|
className={classnames(styles.step, className)}
|
|
44
105
|
{...props}
|
|
45
106
|
>
|
|
107
|
+
{context.floating && <DsIcon icon="drag_indicator" className={styles.dragHandle} data-drag-handle="" />}
|
|
108
|
+
|
|
46
109
|
<div {...context.stepsApi.getIndicatorProps({ index })} className={styles.indicatorContainer}>
|
|
47
|
-
{
|
|
48
|
-
<DsIcon icon="check" className={styles.indicator} />
|
|
49
|
-
) : (
|
|
50
|
-
<span className={styles.indicator}>{index + 1}</span>
|
|
51
|
-
)}
|
|
110
|
+
{renderIndicator()}
|
|
52
111
|
|
|
53
|
-
|
|
112
|
+
{!isHorizontal && <DsStepSeparator index={index} />}
|
|
54
113
|
</div>
|
|
55
114
|
|
|
56
115
|
{children}
|
|
@@ -1,17 +1,76 @@
|
|
|
1
|
+
@use '../../styles/mixin' as mixins;
|
|
2
|
+
|
|
3
|
+
$step-padding: var(--spacing-sm);
|
|
4
|
+
$step-gap: var(--spacing-standard);
|
|
5
|
+
$step-border-radius: var(--spacing-3xs);
|
|
6
|
+
|
|
7
|
+
$step-single-padding-block: var(--spacing-standard);
|
|
8
|
+
$step-single-padding-inline-start: var(--spacing-sm);
|
|
9
|
+
$step-single-padding-inline-end: var(--spacing-md);
|
|
10
|
+
$step-single-border-radius: var(--spacing-xs);
|
|
11
|
+
|
|
12
|
+
$indicator-size: 36px;
|
|
13
|
+
$indicator-size-single: var(--icon-width-extra-large);
|
|
14
|
+
$indicator-border-width: var(--spacing-4xs);
|
|
15
|
+
$indicator-border-width-current: 3px;
|
|
16
|
+
$indicator-container-padding: 0 var(--spacing-4xs);
|
|
17
|
+
|
|
18
|
+
$separator-width: var(--spacing-4xs);
|
|
19
|
+
$separator-offset: var(--spacing-sm);
|
|
20
|
+
|
|
21
|
+
$label-padding: var(--spacing-4xs) 0;
|
|
22
|
+
$label-font-size: var(--font-size-md);
|
|
23
|
+
$label-font-size-single: var(--font-size-sm);
|
|
24
|
+
$label-line-height: 1.5;
|
|
25
|
+
$label-font-weight: var(--font-weight-medium);
|
|
26
|
+
$description-font-size: var(--font-size-sm);
|
|
27
|
+
$description-line-height: 1.4;
|
|
28
|
+
|
|
29
|
+
$actions-margin-top: var(--spacing-sm);
|
|
30
|
+
$actions-gap: var(--spacing-3xs);
|
|
31
|
+
|
|
32
|
+
$drag-handle-size: 20px;
|
|
33
|
+
|
|
34
|
+
$horizontal-current-min-width: 256px;
|
|
35
|
+
$horizontal-description-line-clamp: 2;
|
|
36
|
+
|
|
37
|
+
.dragHandle {
|
|
38
|
+
display: grid;
|
|
39
|
+
place-items: center;
|
|
40
|
+
flex-shrink: 0;
|
|
41
|
+
width: $drag-handle-size;
|
|
42
|
+
height: $drag-handle-size;
|
|
43
|
+
color: var(--color-font-secondary);
|
|
44
|
+
cursor: grab;
|
|
45
|
+
}
|
|
46
|
+
.root {
|
|
47
|
+
background: var(--color-background);
|
|
48
|
+
overflow-y: auto;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.verticalActions {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: $actions-gap;
|
|
54
|
+
padding: $step-padding;
|
|
55
|
+
}
|
|
56
|
+
|
|
1
57
|
.step {
|
|
2
|
-
|
|
58
|
+
position: relative;
|
|
59
|
+
padding: $step-padding;
|
|
3
60
|
display: flex;
|
|
4
|
-
gap:
|
|
61
|
+
gap: $step-gap;
|
|
5
62
|
background: none;
|
|
6
63
|
border: none;
|
|
7
64
|
text-align: start;
|
|
8
65
|
font-family: inherit;
|
|
9
66
|
|
|
67
|
+
@include mixins.disabled-overlay;
|
|
68
|
+
|
|
10
69
|
.root.variantSingle & {
|
|
11
|
-
padding-block:
|
|
12
|
-
padding-inline-start:
|
|
13
|
-
padding-inline-end:
|
|
14
|
-
border-radius:
|
|
70
|
+
padding-block: $step-single-padding-block;
|
|
71
|
+
padding-inline-start: $step-single-padding-inline-start;
|
|
72
|
+
padding-inline-end: $step-single-padding-inline-end;
|
|
73
|
+
border-radius: $step-single-border-radius;
|
|
15
74
|
}
|
|
16
75
|
|
|
17
76
|
.root:not(.variantSingle) &[data-complete] {
|
|
@@ -19,26 +78,26 @@
|
|
|
19
78
|
}
|
|
20
79
|
|
|
21
80
|
&[data-current] {
|
|
22
|
-
border-radius:
|
|
81
|
+
border-radius: $step-border-radius;
|
|
23
82
|
background: var(--color-background-action-secondary-hover);
|
|
24
83
|
}
|
|
25
84
|
|
|
26
85
|
.indicatorContainer {
|
|
27
|
-
padding:
|
|
86
|
+
padding: $indicator-container-padding;
|
|
28
87
|
position: relative;
|
|
29
88
|
display: flex;
|
|
30
89
|
|
|
31
90
|
.indicator {
|
|
32
|
-
height:
|
|
33
|
-
width:
|
|
34
|
-
border:
|
|
91
|
+
height: $indicator-size;
|
|
92
|
+
width: $indicator-size;
|
|
93
|
+
border: $indicator-border-width solid var(--color-border);
|
|
35
94
|
display: grid;
|
|
36
95
|
place-items: center;
|
|
37
96
|
border-radius: 100%;
|
|
38
97
|
|
|
39
98
|
.variantSingle & {
|
|
40
|
-
height:
|
|
41
|
-
width:
|
|
99
|
+
height: $indicator-size-single;
|
|
100
|
+
width: $indicator-size-single;
|
|
42
101
|
}
|
|
43
102
|
}
|
|
44
103
|
|
|
@@ -50,26 +109,27 @@
|
|
|
50
109
|
&[data-current] .indicator {
|
|
51
110
|
background: var(--color-background-selected);
|
|
52
111
|
color: var(--white);
|
|
53
|
-
border:
|
|
112
|
+
border: $indicator-border-width-current solid var(--white);
|
|
54
113
|
}
|
|
55
114
|
|
|
56
115
|
.separator {
|
|
57
116
|
position: absolute;
|
|
58
|
-
width:
|
|
59
|
-
height: calc(100% -
|
|
60
|
-
top:
|
|
117
|
+
width: $separator-width;
|
|
118
|
+
height: calc(100% - $separator-offset);
|
|
119
|
+
top: $indicator-size;
|
|
61
120
|
left: 50%;
|
|
62
|
-
margin-left: -
|
|
121
|
+
margin-left: calc($separator-width / -2);
|
|
63
122
|
background: var(--color-border);
|
|
123
|
+
z-index: 10;
|
|
64
124
|
|
|
65
125
|
&[data-complete] {
|
|
66
126
|
background: var(--color-background-selected);
|
|
67
127
|
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
128
|
|
|
71
|
-
|
|
72
|
-
|
|
129
|
+
&[data-current] {
|
|
130
|
+
background: var(--color-background-selected);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
73
133
|
}
|
|
74
134
|
|
|
75
135
|
.stepContent {
|
|
@@ -84,21 +144,21 @@
|
|
|
84
144
|
}
|
|
85
145
|
|
|
86
146
|
.stepLabel {
|
|
87
|
-
padding:
|
|
88
|
-
font-size:
|
|
89
|
-
line-height:
|
|
90
|
-
font-weight:
|
|
147
|
+
padding: $label-padding;
|
|
148
|
+
font-size: $label-font-size;
|
|
149
|
+
line-height: $label-line-height;
|
|
150
|
+
font-weight: $label-font-weight;
|
|
91
151
|
color: var(--color-font-secondary);
|
|
92
152
|
|
|
93
153
|
.root.variantSingle & {
|
|
94
|
-
font-size:
|
|
154
|
+
font-size: $label-font-size-single;
|
|
95
155
|
}
|
|
96
156
|
}
|
|
97
157
|
|
|
98
158
|
.stepDescription {
|
|
99
159
|
margin: 0;
|
|
100
|
-
font-size:
|
|
101
|
-
line-height:
|
|
160
|
+
font-size: $description-font-size;
|
|
161
|
+
line-height: $description-line-height;
|
|
102
162
|
color: var(--color-background-deselected);
|
|
103
163
|
}
|
|
104
164
|
|
|
@@ -123,12 +183,114 @@
|
|
|
123
183
|
}
|
|
124
184
|
|
|
125
185
|
.stepContent:not(.stepContentSingle) .stepActions {
|
|
126
|
-
margin-top:
|
|
186
|
+
margin-top: $actions-margin-top;
|
|
127
187
|
}
|
|
128
188
|
|
|
129
189
|
.stepActions {
|
|
130
190
|
margin-inline-start: auto;
|
|
131
191
|
display: flex;
|
|
132
|
-
gap:
|
|
192
|
+
gap: $actions-gap;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.step[data-error] {
|
|
197
|
+
.indicatorContainer .indicator {
|
|
198
|
+
background: var(--color-background-danger-weak);
|
|
199
|
+
color: var(--color-background-danger-strong);
|
|
200
|
+
border-color: var(--color-background-danger-strong);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.stepLabel {
|
|
204
|
+
color: var(--color-font-danger);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.root[data-orientation='horizontal'] {
|
|
209
|
+
display: flex;
|
|
210
|
+
align-items: center;
|
|
211
|
+
padding: var(--spacing-xs) var(--spacing-standard);
|
|
212
|
+
|
|
213
|
+
.stepsContainer {
|
|
214
|
+
display: flex;
|
|
215
|
+
flex: 1 1 0;
|
|
216
|
+
align-items: flex-start;
|
|
217
|
+
min-width: 0;
|
|
218
|
+
overflow-x: auto;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.horizontalActions {
|
|
222
|
+
display: flex;
|
|
223
|
+
align-items: center;
|
|
224
|
+
flex-shrink: 0;
|
|
225
|
+
padding-inline-start: var(--spacing-xs);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.step {
|
|
229
|
+
flex: 1 1 0;
|
|
230
|
+
padding: var(--spacing-3xs) var(--spacing-xs);
|
|
231
|
+
gap: var(--spacing-sm);
|
|
232
|
+
border-radius: var(--spacing-2xs);
|
|
233
|
+
overflow: clip;
|
|
234
|
+
|
|
235
|
+
&[data-current] {
|
|
236
|
+
min-width: $horizontal-current-min-width;
|
|
237
|
+
border-radius: var(--spacing-2xs);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.indicatorContainer {
|
|
242
|
+
padding: 0;
|
|
243
|
+
|
|
244
|
+
.indicator {
|
|
245
|
+
height: $indicator-size;
|
|
246
|
+
width: $indicator-size;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.stepContent {
|
|
251
|
+
min-width: 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.stepLabelRow {
|
|
255
|
+
display: flex;
|
|
256
|
+
align-items: center;
|
|
257
|
+
gap: var(--spacing-sm);
|
|
258
|
+
height: $indicator-size;
|
|
259
|
+
min-width: 0;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.stepLabel {
|
|
263
|
+
padding: 0;
|
|
264
|
+
font-size: var(--font-size-sm);
|
|
265
|
+
line-height: var(--line-height-sm);
|
|
266
|
+
white-space: nowrap;
|
|
267
|
+
overflow: hidden;
|
|
268
|
+
text-overflow: ellipsis;
|
|
269
|
+
flex-shrink: 0;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.horizontalSeparator {
|
|
273
|
+
flex: 1 1 0;
|
|
274
|
+
height: var(--spacing-4xs);
|
|
275
|
+
min-width: 0;
|
|
276
|
+
background: var(--color-border-contrast);
|
|
277
|
+
|
|
278
|
+
&[data-complete] {
|
|
279
|
+
background: var(--color-background-selected);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
&[data-current] {
|
|
283
|
+
background: var(--color-outline-moderate);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.stepDescription {
|
|
288
|
+
font-size: var(--font-size-xs);
|
|
289
|
+
line-height: var(--line-height-xs);
|
|
290
|
+
max-height: var(--spacing-8);
|
|
291
|
+
overflow: hidden;
|
|
292
|
+
display: -webkit-box;
|
|
293
|
+
-webkit-line-clamp: $horizontal-description-line-clamp;
|
|
294
|
+
-webkit-box-orient: vertical;
|
|
133
295
|
}
|
|
134
296
|
}
|