@axinom/mosaic-ui 0.32.0-rc.5 → 0.32.0-rc.7
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/dist/components/Actions/Action/Action.d.ts.map +1 -1
- package/dist/components/Buttons/Button/Button.d.ts +9 -10
- package/dist/components/Buttons/Button/Button.d.ts.map +1 -1
- package/dist/components/Buttons/Button/Button.model.d.ts +21 -0
- package/dist/components/Buttons/Button/Button.model.d.ts.map +1 -0
- package/dist/components/Buttons/Button/index.d.ts +3 -0
- package/dist/components/Buttons/Button/index.d.ts.map +1 -0
- package/dist/components/Buttons/Button.model.d.ts +69 -7
- package/dist/components/Buttons/Button.model.d.ts.map +1 -1
- package/dist/components/Buttons/CompositeButton/CompositeButton.d.ts +5 -14
- package/dist/components/Buttons/CompositeButton/CompositeButton.d.ts.map +1 -1
- package/dist/components/Buttons/CompositeButton/CompositeButton.model.d.ts +20 -0
- package/dist/components/Buttons/CompositeButton/CompositeButton.model.d.ts.map +1 -0
- package/dist/components/Buttons/CompositeButton/index.d.ts +3 -0
- package/dist/components/Buttons/CompositeButton/index.d.ts.map +1 -0
- package/dist/components/Buttons/TextButton/TextButton.d.ts +5 -9
- package/dist/components/Buttons/TextButton/TextButton.d.ts.map +1 -1
- package/dist/components/Buttons/TextButton/TextButton.model.d.ts +18 -0
- package/dist/components/Buttons/TextButton/TextButton.model.d.ts.map +1 -0
- package/dist/components/Buttons/TextButton/index.d.ts +3 -0
- package/dist/components/Buttons/TextButton/index.d.ts.map +1 -0
- package/dist/components/Buttons/index.d.ts +3 -3
- package/dist/components/Buttons/index.d.ts.map +1 -1
- package/dist/components/Explorer/Explorer.d.ts.map +1 -1
- package/dist/components/Explorer/NavigationExplorer/NavigationExplorer.d.ts +3 -2
- package/dist/components/Explorer/NavigationExplorer/NavigationExplorer.d.ts.map +1 -1
- package/dist/components/FormElements/ToggleButton/ToggleButton.d.ts +2 -2
- package/dist/components/FormElements/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/components/List/ListRow/ListRow.d.ts.map +1 -1
- package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.d.ts.map +1 -1
- package/dist/components/models.d.ts +5 -2
- package/dist/components/models.d.ts.map +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Actions/Action/Action.spec.tsx +14 -0
- package/src/components/Actions/Action/Action.tsx +5 -2
- package/src/components/Buttons/Button/Button.model.ts +30 -0
- package/src/components/Buttons/Button/Button.scss +3 -1
- package/src/components/Buttons/Button/Button.spec.tsx +254 -83
- package/src/components/Buttons/Button/Button.stories.tsx +20 -0
- package/src/components/Buttons/Button/Button.tsx +103 -32
- package/src/components/Buttons/Button/index.ts +2 -0
- package/src/components/Buttons/Button.model.ts +84 -9
- package/src/components/Buttons/CompositeButton/CompositeButton.model.ts +32 -0
- package/src/components/Buttons/CompositeButton/CompositeButton.scss +6 -1
- package/src/components/Buttons/CompositeButton/CompositeButton.spec.tsx +277 -89
- package/src/components/Buttons/CompositeButton/CompositeButton.stories.tsx +20 -0
- package/src/components/Buttons/CompositeButton/CompositeButton.tsx +94 -30
- package/src/components/Buttons/CompositeButton/index.ts +2 -0
- package/src/components/Buttons/TextButton/TextButton.model.ts +27 -0
- package/src/components/Buttons/TextButton/TextButton.scss +3 -1
- package/src/components/Buttons/TextButton/TextButton.spec.tsx +198 -87
- package/src/components/Buttons/TextButton/TextButton.stories.tsx +20 -0
- package/src/components/Buttons/TextButton/TextButton.tsx +74 -20
- package/src/components/Buttons/TextButton/index.ts +2 -0
- package/src/components/Buttons/index.ts +3 -6
- package/src/components/Explorer/Explorer.tsx +2 -2
- package/src/components/Explorer/NavigationExplorer/NavigationExplorer.tsx +4 -3
- package/src/components/FormElements/CustomTags/CustomTags.spec.tsx +26 -16
- package/src/components/FormElements/ToggleButton/ToggleButton.tsx +2 -2
- package/src/components/List/ListRow/ListRow.tsx +18 -13
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.spec.tsx +513 -388
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.tsx +11 -7
- package/src/components/models.ts +5 -2
|
@@ -1,62 +1,91 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { ForwardedRef } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
3
4
|
import { noop } from '../../../helpers/utils';
|
|
4
5
|
import { IconName, Icons } from '../../Icons';
|
|
5
|
-
import {
|
|
6
|
+
import { ButtonContext } from '../Button.model';
|
|
7
|
+
import {
|
|
8
|
+
ButtonProps,
|
|
9
|
+
ContextButtonProps,
|
|
10
|
+
NavigationButtonProps,
|
|
11
|
+
} from './Button.model';
|
|
6
12
|
import classes from './Button.scss';
|
|
7
13
|
|
|
8
|
-
export interface ButtonProps extends BaseButtonOptions {
|
|
9
|
-
/** Button's height (default: '50px') */
|
|
10
|
-
height?: string | number;
|
|
11
|
-
/** Button's width (default: '50px') */
|
|
12
|
-
width?: string | number;
|
|
13
|
-
/** Optional icon */
|
|
14
|
-
icon?: IconName;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
14
|
const ButtonElement: React.ForwardRefRenderFunction<
|
|
18
|
-
HTMLButtonElement,
|
|
15
|
+
HTMLButtonElement | HTMLAnchorElement,
|
|
19
16
|
ButtonProps
|
|
20
17
|
> = (
|
|
18
|
+
{
|
|
19
|
+
className,
|
|
20
|
+
dataTestId,
|
|
21
|
+
disabled = false,
|
|
22
|
+
height,
|
|
23
|
+
icon,
|
|
24
|
+
path,
|
|
25
|
+
width,
|
|
26
|
+
openInNewTab,
|
|
27
|
+
...rest
|
|
28
|
+
},
|
|
29
|
+
ref: ForwardedRef<HTMLButtonElement | HTMLAnchorElement>,
|
|
30
|
+
) => {
|
|
31
|
+
const commonProps = {
|
|
32
|
+
className,
|
|
33
|
+
dataTestId,
|
|
34
|
+
disabled,
|
|
35
|
+
height,
|
|
36
|
+
icon,
|
|
37
|
+
width,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return path ? (
|
|
41
|
+
<NavigationButtonElement
|
|
42
|
+
{...commonProps}
|
|
43
|
+
ref={ref as ForwardedRef<HTMLAnchorElement>}
|
|
44
|
+
path={path}
|
|
45
|
+
openInNewTab={openInNewTab}
|
|
46
|
+
/>
|
|
47
|
+
) : (
|
|
48
|
+
<ContextButtonElement
|
|
49
|
+
{...commonProps}
|
|
50
|
+
{...rest}
|
|
51
|
+
ref={ref as ForwardedRef<HTMLButtonElement>}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const ContextButtonElement = React.forwardRef<
|
|
57
|
+
HTMLButtonElement,
|
|
58
|
+
ContextButtonProps
|
|
59
|
+
>(function ContextButtonElement(
|
|
21
60
|
{
|
|
22
61
|
type = 'button',
|
|
23
62
|
height,
|
|
24
63
|
width,
|
|
25
|
-
buttonContext = ButtonContext.
|
|
64
|
+
buttonContext = ButtonContext.Active,
|
|
26
65
|
disabled = false,
|
|
27
66
|
icon,
|
|
28
67
|
className = '',
|
|
29
|
-
dataTestId
|
|
68
|
+
dataTestId,
|
|
30
69
|
onButtonClicked = noop,
|
|
31
70
|
onBlur,
|
|
32
|
-
},
|
|
33
|
-
ref
|
|
34
|
-
)
|
|
35
|
-
const customStyles = {
|
|
36
|
-
height: height,
|
|
37
|
-
width: width,
|
|
38
|
-
} as React.CSSProperties;
|
|
39
|
-
|
|
71
|
+
}: ContextButtonProps,
|
|
72
|
+
ref: ForwardedRef<HTMLButtonElement>,
|
|
73
|
+
) {
|
|
40
74
|
return (
|
|
41
75
|
<button
|
|
42
76
|
ref={ref}
|
|
43
77
|
className={clsx(
|
|
44
78
|
classes.container,
|
|
45
|
-
{ [classes.navigation]: buttonContext === ButtonContext.Navigation },
|
|
46
79
|
{
|
|
47
80
|
[classes.context]: buttonContext === ButtonContext.Context,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
81
|
[classes.icon]: buttonContext === ButtonContext.Icon,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
82
|
[classes.active]: buttonContext === ButtonContext.Active,
|
|
54
83
|
},
|
|
55
84
|
'button-container',
|
|
56
85
|
className,
|
|
57
86
|
)}
|
|
58
87
|
type={type}
|
|
59
|
-
style={
|
|
88
|
+
style={{ height, width }}
|
|
60
89
|
onClick={onButtonClicked}
|
|
61
90
|
disabled={disabled}
|
|
62
91
|
onBlur={onBlur}
|
|
@@ -65,13 +94,55 @@ const ButtonElement: React.ForwardRefRenderFunction<
|
|
|
65
94
|
<Icons icon={icon} />
|
|
66
95
|
</button>
|
|
67
96
|
);
|
|
68
|
-
};
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const NavigationButtonElement = React.forwardRef<
|
|
100
|
+
HTMLAnchorElement,
|
|
101
|
+
NavigationButtonProps
|
|
102
|
+
>(function NavigationButtonElement(
|
|
103
|
+
{
|
|
104
|
+
path,
|
|
105
|
+
height,
|
|
106
|
+
width,
|
|
107
|
+
icon,
|
|
108
|
+
className = '',
|
|
109
|
+
dataTestId = undefined,
|
|
110
|
+
disabled = false,
|
|
111
|
+
openInNewTab = false,
|
|
112
|
+
}: NavigationButtonProps,
|
|
113
|
+
ref: ForwardedRef<HTMLAnchorElement>,
|
|
114
|
+
) {
|
|
115
|
+
const defaultIcon = openInNewTab ? IconName.External : IconName.ChevronRight;
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<Link
|
|
119
|
+
ref={ref}
|
|
120
|
+
className={clsx(
|
|
121
|
+
classes.container,
|
|
122
|
+
classes.navigation,
|
|
123
|
+
{ [classes.disabled]: disabled },
|
|
124
|
+
'button-container',
|
|
125
|
+
className,
|
|
126
|
+
)}
|
|
127
|
+
to={path}
|
|
128
|
+
style={{ height, width }}
|
|
129
|
+
data-test-id={dataTestId ?? 'button'}
|
|
130
|
+
target={openInNewTab ? '_blank' : undefined}
|
|
131
|
+
>
|
|
132
|
+
<Icons icon={icon ? icon : defaultIcon} />
|
|
133
|
+
</Link>
|
|
134
|
+
);
|
|
135
|
+
});
|
|
69
136
|
|
|
70
137
|
/**
|
|
71
138
|
* Button which can render an icon.
|
|
72
139
|
* @example
|
|
140
|
+
* // to render a button element
|
|
73
141
|
* <Button type="button" icon={IconName.X} />
|
|
142
|
+
* // to render an anchor element
|
|
143
|
+
* <Button path="/home" icon={IconName.X} />
|
|
74
144
|
*/
|
|
75
|
-
export const Button = React.forwardRef<
|
|
76
|
-
|
|
77
|
-
|
|
145
|
+
export const Button = React.forwardRef<
|
|
146
|
+
HTMLButtonElement | HTMLAnchorElement,
|
|
147
|
+
ButtonProps
|
|
148
|
+
>(ButtonElement);
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { Not } from '../../types';
|
|
2
|
+
import { IconName } from '../Icons';
|
|
3
|
+
import { LinkAction } from '../models';
|
|
4
|
+
|
|
1
5
|
/** Button's context type. This type defines the button's colors and border. */
|
|
2
6
|
export enum ButtonContext {
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated not used anymore and will be removed in future versions.
|
|
9
|
+
* Define `path` property instead of `onButtonClicked`,
|
|
10
|
+
* `onBlur` properties for navigation type buttons.
|
|
11
|
+
* This will render link instead of button.
|
|
12
|
+
*/
|
|
3
13
|
Navigation,
|
|
4
14
|
Context,
|
|
5
15
|
Active,
|
|
@@ -7,21 +17,86 @@ export enum ButtonContext {
|
|
|
7
17
|
None,
|
|
8
18
|
}
|
|
9
19
|
|
|
10
|
-
/**
|
|
11
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Button options for buttons with JS handlers
|
|
22
|
+
* (renders as a button)
|
|
23
|
+
*/
|
|
24
|
+
export interface CommonJsButtonOptions
|
|
25
|
+
extends CommonButtonOptions,
|
|
26
|
+
ButtonSizeOptions,
|
|
27
|
+
JsButtonOptions,
|
|
28
|
+
Not<LinkAction> {
|
|
29
|
+
/**
|
|
30
|
+
* Buttons type (default: 'Active').
|
|
31
|
+
* Affects buttons color and border.
|
|
32
|
+
* Button context type `Navigation` is deprecated and will
|
|
33
|
+
* be removed in future versions.
|
|
34
|
+
* For navigation type of buttons define `path` instead
|
|
35
|
+
* of `onButtonClicked`, `onBlur` and `type` properties
|
|
36
|
+
* to render link instead of button.
|
|
37
|
+
*/
|
|
38
|
+
buttonContext?: ButtonContext;
|
|
12
39
|
/** HTML button type attribute (default: 'button') */
|
|
13
40
|
type?: 'button' | 'submit' | 'reset';
|
|
14
|
-
|
|
15
|
-
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Button options for buttons with navigation
|
|
45
|
+
* (renders as a link)
|
|
46
|
+
*/
|
|
47
|
+
export interface CommonNavigationButtonOptions
|
|
48
|
+
extends CommonButtonOptions,
|
|
49
|
+
ButtonSizeOptions,
|
|
50
|
+
LinkAction,
|
|
51
|
+
Not<JsButtonOptions> {}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Button text options
|
|
55
|
+
*/
|
|
56
|
+
export interface TextButtonOptions {
|
|
57
|
+
/** Button text */
|
|
58
|
+
text?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Button icon options
|
|
63
|
+
*/
|
|
64
|
+
export interface ButtonIconOptions {
|
|
65
|
+
/** Optional icon */
|
|
66
|
+
icon?: IconName;
|
|
67
|
+
/** Optional Icon Position */
|
|
68
|
+
iconPosition?: 'left' | 'right';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Button event handler options for JS buttons
|
|
73
|
+
*/
|
|
74
|
+
interface JsButtonOptions {
|
|
75
|
+
/** Event to raise when the button is clicked */
|
|
76
|
+
onButtonClicked?: (
|
|
77
|
+
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
78
|
+
) => void;
|
|
79
|
+
onBlur?: React.FocusEventHandler<HTMLButtonElement>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Button size options
|
|
84
|
+
*/
|
|
85
|
+
interface ButtonSizeOptions {
|
|
86
|
+
/** Button's height */
|
|
87
|
+
height?: string | number;
|
|
88
|
+
/** Button's width */
|
|
89
|
+
width?: string | number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Common properties for all buttons
|
|
94
|
+
*/
|
|
95
|
+
interface CommonButtonOptions {
|
|
16
96
|
/** Whether the button is disabled. If set to true, disallows interactions. (default: undefined) */
|
|
17
97
|
disabled?: boolean;
|
|
18
98
|
/** Optional class */
|
|
19
99
|
className?: string;
|
|
20
100
|
/** Optional data-test-id */
|
|
21
101
|
dataTestId?: string;
|
|
22
|
-
/** Event to raise when the button is clicked */
|
|
23
|
-
onButtonClicked?: (
|
|
24
|
-
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
25
|
-
) => void;
|
|
26
|
-
onBlur?: React.FocusEventHandler<HTMLButtonElement>;
|
|
27
102
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonIconOptions,
|
|
3
|
+
CommonJsButtonOptions,
|
|
4
|
+
CommonNavigationButtonOptions,
|
|
5
|
+
TextButtonOptions,
|
|
6
|
+
} from '../Button.model';
|
|
7
|
+
|
|
8
|
+
export type CompositeButtonProps =
|
|
9
|
+
| (CompositeNavigationButtonProps | CompositeJsButtonProps) & {
|
|
10
|
+
/** Optional button's height (default: 50px) */
|
|
11
|
+
width?: string | number;
|
|
12
|
+
/** Optional button's height (default: undefined) */
|
|
13
|
+
height?: string | number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Button options for composite buttons (text + icon)
|
|
18
|
+
* with navigation
|
|
19
|
+
*/
|
|
20
|
+
export interface CompositeNavigationButtonProps
|
|
21
|
+
extends CommonNavigationButtonOptions,
|
|
22
|
+
ButtonIconOptions,
|
|
23
|
+
TextButtonOptions {}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Button options for composite buttons (text + icon)
|
|
27
|
+
* with JS handlers
|
|
28
|
+
*/
|
|
29
|
+
export interface CompositeJsButtonProps
|
|
30
|
+
extends CommonJsButtonOptions,
|
|
31
|
+
ButtonIconOptions,
|
|
32
|
+
TextButtonOptions {}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
display: grid;
|
|
9
9
|
grid-auto-flow: column;
|
|
10
|
+
grid-gap: 10px;
|
|
10
11
|
place-items: center;
|
|
11
12
|
width: max-content;
|
|
12
13
|
|
|
@@ -32,6 +33,9 @@
|
|
|
32
33
|
&.navigation {
|
|
33
34
|
color: white;
|
|
34
35
|
background-color: $light-blue;
|
|
36
|
+
width: fit-content;
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
box-sizing: border-box;
|
|
35
39
|
|
|
36
40
|
svg * {
|
|
37
41
|
stroke: white;
|
|
@@ -50,8 +54,9 @@
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
&.disabled {
|
|
54
58
|
background-color: $gray;
|
|
59
|
+
pointer-events: none;
|
|
55
60
|
color: rgba(white, 0.5);
|
|
56
61
|
|
|
57
62
|
svg * {
|