@scality/core-ui 0.193.0 → 0.195.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/dist/components/UnsuccessfulResult.component.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.component.d.ts.map +1 -1
- package/dist/components/banner/Banner.component.d.ts +6 -1
- package/dist/components/banner/Banner.component.d.ts.map +1 -1
- package/dist/components/banner/Banner.component.js +30 -9
- package/dist/components/breadcrumb/Breadcrumb.component.d.ts.map +1 -1
- package/dist/components/buttonv2/CopyButton.component.d.ts.map +1 -1
- package/dist/components/charts/MetricsTimeSpanProvider.d.ts.map +1 -1
- package/dist/components/charts/barchart/Barchart.d.ts.map +1 -1
- package/dist/components/charts/barchart/Barchart.js +29 -19
- package/dist/components/charts/barchart/Barchart.utils.d.ts.map +1 -1
- package/dist/components/charts/barchart/BarchartTooltip.d.ts.map +1 -1
- package/dist/components/charts/common/ChartTooltip.d.ts.map +1 -1
- package/dist/components/charts/common/SharedComponents.d.ts +6 -6
- package/dist/components/charts/common/SharedComponents.d.ts.map +1 -1
- package/dist/components/charts/common/SharedComponents.js +7 -3
- package/dist/components/charts/common/chartUtils.d.ts +7 -2
- package/dist/components/charts/common/chartUtils.d.ts.map +1 -1
- package/dist/components/charts/common/chartUtils.js +55 -20
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.hooks.d.ts.map +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts +3 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts.map +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBarTooltip.d.ts.map +1 -1
- package/dist/components/charts/globalhealthbar/HealthBarXAxis.d.ts.map +1 -1
- package/dist/components/charts/index.d.ts +1 -1
- package/dist/components/charts/index.d.ts.map +1 -1
- package/dist/components/charts/legend/ChartLegend.d.ts.map +1 -1
- package/dist/components/charts/legend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts +12 -47
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -1
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.js +46 -220
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.d.ts +77 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.js +6 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts.map +1 -1
- package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.d.ts +18 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.js +65 -0
- package/dist/components/charts/linetimeseries/useChartData.d.ts +44 -0
- package/dist/components/charts/linetimeseries/useChartData.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/useChartData.js +207 -0
- package/dist/components/charts/linetimeseries/useChartHover.d.ts +15 -0
- package/dist/components/charts/linetimeseries/useChartHover.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/useChartHover.js +29 -0
- package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.component.js +15 -7
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +3 -2
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.component.js +3 -0
- package/dist/components/error-pages/ErrorPage401.component.js +1 -1
- package/dist/components/error-pages/ErrorPage404.component.js +1 -1
- package/dist/components/error-pages/ErrorPage500.component.js +1 -1
- package/dist/components/form/Form.component.d.ts.map +1 -1
- package/dist/components/form/Form.component.js +3 -3
- package/dist/components/icon/CustomsIcons.d.ts +10 -0
- package/dist/components/icon/CustomsIcons.d.ts.map +1 -1
- package/dist/components/icon/CustomsIcons.js +8 -0
- package/dist/components/icon/Icon.component.d.ts +2 -131
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +10 -133
- package/dist/components/icon/iconTable.d.ts +138 -0
- package/dist/components/icon/iconTable.d.ts.map +1 -0
- package/dist/components/icon/iconTable.js +137 -0
- package/dist/components/iconhelper/IconHelper.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessage.component.js +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -1
- package/dist/components/inlineinput/InlineInput.d.ts.map +1 -1
- package/dist/components/inputlist/InputButtons.d.ts.map +1 -1
- package/dist/components/inputlist/InputList.component.d.ts +2 -0
- package/dist/components/inputlist/InputList.component.d.ts.map +1 -1
- package/dist/components/inputlist/InputList.component.js +2 -2
- package/dist/components/inputv2/inputv2.d.ts +2 -0
- package/dist/components/inputv2/inputv2.d.ts.map +1 -1
- package/dist/components/inputv2/inputv2.js +6 -2
- package/dist/components/layout/v2/panels.d.ts.map +1 -1
- package/dist/components/modal/Modal.component.d.ts.map +1 -1
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
- package/dist/components/searchinput/SearchInput.component.js +1 -1
- package/dist/components/statusicon/StatusIcon.component.d.ts.map +1 -1
- package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/Search.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableUtils.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.js +2 -3
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tabsv2/useScrollingTabs.d.ts.map +1 -1
- package/dist/components/text/Text.component.d.ts +9 -6
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/components/text/Text.component.js +5 -0
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.component.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/next.d.ts +3 -3
- package/dist/next.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -1
- package/dist/spacing.d.ts.map +1 -1
- package/dist/utils.d.ts +16 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +27 -0
- package/jest.config.js +6 -1
- package/package.json +7 -7
- package/src/lib/components/banner/Banner.component.test.tsx +58 -0
- package/src/lib/components/banner/Banner.component.tsx +57 -10
- package/src/lib/components/charts/barchart/Barchart.test.tsx +3 -1
- package/src/lib/components/charts/barchart/Barchart.tsx +123 -106
- package/src/lib/components/charts/common/SharedComponents.tsx +15 -11
- package/src/lib/components/charts/common/chartUtils.test.ts +27 -12
- package/src/lib/components/charts/common/chartUtils.ts +67 -23
- package/src/lib/components/charts/index.ts +1 -1
- package/src/lib/components/charts/linetimeseries/LineTimeSerieChart.tsx +136 -516
- package/src/lib/components/charts/linetimeseries/LineTimeSerieChart.types.ts +93 -0
- package/src/lib/components/charts/linetimeseries/LineTimeSerieChartTooltip.tsx +137 -0
- package/src/lib/components/charts/linetimeseries/useChartData.ts +322 -0
- package/src/lib/components/charts/linetimeseries/useChartHover.ts +35 -0
- package/src/lib/components/checkbox/Checkbox.component.tsx +19 -20
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +3 -2
- package/src/lib/components/dropdown/Dropdown.component.tsx +3 -0
- package/src/lib/components/error-pages/ErrorPage401.component.tsx +1 -1
- package/src/lib/components/error-pages/ErrorPage404.component.tsx +1 -1
- package/src/lib/components/error-pages/ErrorPage500.component.tsx +1 -1
- package/src/lib/components/form/Form.component.tsx +5 -19
- package/src/lib/components/icon/CustomsIcons.tsx +36 -0
- package/src/lib/components/icon/Icon.component.tsx +17 -137
- package/src/lib/components/icon/iconTable.ts +137 -0
- package/src/lib/components/iconhelper/IconHelper.test.tsx +2 -2
- package/src/lib/components/infomessage/InfoMessage.component.tsx +1 -1
- package/src/lib/components/inputlist/InputList.component.tsx +4 -2
- package/src/lib/components/inputv2/inputv2.tsx +11 -5
- package/src/lib/components/searchinput/SearchInput.component.tsx +1 -0
- package/src/lib/components/searchinput/SearchInput.test.tsx +6 -6
- package/src/lib/components/tablev2/Tablestyle.tsx +2 -4
- package/src/lib/components/text/Text.component.tsx +18 -10
- package/src/lib/components/tooltip/Tooltip.component.tsx +1 -1
- package/src/lib/index.ts +3 -2
- package/src/lib/next.ts +3 -3
- package/src/lib/utils.ts +42 -0
- package/stories/GlobalHealthBar/globalhealthbar.stories.tsx +1 -1
- package/stories/banner.stories.tsx +37 -5
- package/stories/inputlist.stories.tsx +18 -6
- package/stories/linetimeseriechart.stories.tsx +325 -6
- package/tsconfig.json +1 -1
- package/dist/components/date/FormattedDateTime.spec.d.ts +0 -2
- package/dist/components/date/FormattedDateTime.spec.d.ts.map +0 -1
- package/dist/components/date/FormattedDateTime.spec.js +0 -161
- package/dist/components/date/dateDiffer.spec.d.ts +0 -2
- package/dist/components/date/dateDiffer.spec.d.ts.map +0 -1
- package/dist/components/date/dateDiffer.spec.js +0 -6
|
@@ -16,6 +16,13 @@ type Props = {
|
|
|
16
16
|
children: React.ReactNode | string;
|
|
17
17
|
status?: Status;
|
|
18
18
|
id?: string;
|
|
19
|
+
} & TextProps;
|
|
20
|
+
type TextProps = {
|
|
21
|
+
color?: keyof CoreUITheme;
|
|
22
|
+
variant?: TextVariant;
|
|
23
|
+
isEmphazed?: boolean;
|
|
24
|
+
isGentleEmphazed?: boolean;
|
|
25
|
+
compact?: boolean;
|
|
19
26
|
};
|
|
20
27
|
const BasicTextStyle = styled.span`
|
|
21
28
|
color: ${(props) => props.theme.textPrimary};
|
|
@@ -33,7 +40,7 @@ const LargerTextStyle = styled(BasicTextStyle)`
|
|
|
33
40
|
const EmphaseTextStyle = styled(BasicTextStyle)`
|
|
34
41
|
font-weight: 700;
|
|
35
42
|
`;
|
|
36
|
-
const StatusTextStyle = styled(BasicTextStyle)<{ statusColor: string }>`
|
|
43
|
+
const StatusTextStyle = styled(BasicTextStyle) <{ statusColor: string }>`
|
|
37
44
|
color: ${(props) => props.theme[`${props.statusColor}`]};
|
|
38
45
|
`;
|
|
39
46
|
const LargetStyle = styled(BasicTextStyle)`
|
|
@@ -70,7 +77,7 @@ const getStatusColor = (status?: Status) => {
|
|
|
70
77
|
return statusColor;
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
export const SmallerEmphaseTextStyle = styled(SmallerTextStyle)<{
|
|
80
|
+
export const SmallerEmphaseTextStyle = styled(SmallerTextStyle) <{
|
|
74
81
|
statusColor: string;
|
|
75
82
|
}>`
|
|
76
83
|
font-weight: 700;
|
|
@@ -122,7 +129,7 @@ export function SmallerEmphaseText({ children, status, ...rest }: Props) {
|
|
|
122
129
|
export function ChartTitleText({ children, ...rest }: Props) {
|
|
123
130
|
return <ChartTitleTextStyle {...rest}>{children}</ChartTitleTextStyle>;
|
|
124
131
|
}
|
|
125
|
-
export const GentleEmphaseSecondaryText = styled(SecondaryText)<{
|
|
132
|
+
export const GentleEmphaseSecondaryText = styled(SecondaryText) <{
|
|
126
133
|
alignRight?: boolean;
|
|
127
134
|
}>`
|
|
128
135
|
font-style: italic;
|
|
@@ -135,12 +142,7 @@ export const GentleEmphaseSecondaryText = styled(SecondaryText)<{
|
|
|
135
142
|
: ''}
|
|
136
143
|
`;
|
|
137
144
|
|
|
138
|
-
export const Text = styled.span<
|
|
139
|
-
variant?: TextVariant;
|
|
140
|
-
color?: keyof CoreUITheme;
|
|
141
|
-
isEmphazed?: boolean;
|
|
142
|
-
isGentleEmphazed?: boolean;
|
|
143
|
-
}>`
|
|
145
|
+
export const Text = styled.span<TextProps>`
|
|
144
146
|
${(props) => props.color && `color: ${props.theme[props.color]};`}
|
|
145
147
|
${(props) =>
|
|
146
148
|
props.variant === 'Larger'
|
|
@@ -187,8 +189,14 @@ export const Text = styled.span<{
|
|
|
187
189
|
|
|
188
190
|
${(props) =>
|
|
189
191
|
props.variant === 'ChartTitle' && `letter-spacing: ${spacing.r2};`}
|
|
190
|
-
`;
|
|
191
192
|
|
|
193
|
+
${(props) => props.compact && `line-height: 1.2;`}
|
|
194
|
+
`;
|
|
195
|
+
export const HelperText = ({ children, color, ...rest }: Props) => {
|
|
196
|
+
return (
|
|
197
|
+
<Text variant="Smaller" isEmphazed compact color={color} {...rest}>{children}</Text>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
192
200
|
export const Link = styled.a`
|
|
193
201
|
font-size: 1rem;
|
|
194
202
|
line-height: ${spacing.r24};
|
|
@@ -58,7 +58,7 @@ const TooltipOverLayContainer = styled.div<{
|
|
|
58
58
|
(props && props.style && props.style.fontSize) || fontSize.small};
|
|
59
59
|
vertical-align: middle;
|
|
60
60
|
padding: ${spacing.r4} ${spacing.r8};
|
|
61
|
-
max-width:
|
|
61
|
+
max-width: 20rem;
|
|
62
62
|
`;
|
|
63
63
|
|
|
64
64
|
const TooltipText = styled.div`
|
package/src/lib/index.ts
CHANGED
|
@@ -11,8 +11,8 @@ export {
|
|
|
11
11
|
STATUS_INFO,
|
|
12
12
|
STATUS_UNKNOWN,
|
|
13
13
|
STATUS_NONE,
|
|
14
|
-
Status,
|
|
15
14
|
} from './components/constants';
|
|
15
|
+
export type { Status } from './components/constants';
|
|
16
16
|
export { Layout } from './components/layout/Layout.component';
|
|
17
17
|
export { Loader } from './components/loader/Loader.component';
|
|
18
18
|
export { Modal } from './components/modal/Modal.component';
|
|
@@ -78,4 +78,5 @@ export { InfoMessage } from './components/infomessage/InfoMessage.component';
|
|
|
78
78
|
export { InputList } from './components/inputlist/InputList.component';
|
|
79
79
|
export { InlineInput } from './components/inlineinput/InlineInput';
|
|
80
80
|
export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
|
|
81
|
-
export { CoreUITheme } from './style/theme';
|
|
81
|
+
export type { CoreUITheme } from './style/theme';
|
|
82
|
+
export { formatISONumber } from './utils';
|
package/src/lib/next.ts
CHANGED
|
@@ -21,8 +21,6 @@ export { Accordion } from './components/accordion/Accordion.component';
|
|
|
21
21
|
// Export all chart components from the consolidated charts folder
|
|
22
22
|
export {
|
|
23
23
|
Barchart,
|
|
24
|
-
BarchartSortFn,
|
|
25
|
-
BarchartTooltipFn,
|
|
26
24
|
BarchartTooltip,
|
|
27
25
|
LineTimeSerieChart,
|
|
28
26
|
GlobalHealthBar,
|
|
@@ -40,6 +38,8 @@ export {
|
|
|
40
38
|
export type {
|
|
41
39
|
BarchartProps,
|
|
42
40
|
BarchartBars,
|
|
41
|
+
BarchartSortFn,
|
|
42
|
+
BarchartTooltipFn,
|
|
43
43
|
LineChartProps,
|
|
44
44
|
Serie,
|
|
45
45
|
GlobalHealthProps,
|
|
@@ -49,4 +49,4 @@ export type {
|
|
|
49
49
|
CategoryType,
|
|
50
50
|
} from './components/charts';
|
|
51
51
|
|
|
52
|
-
export { CoreUITheme } from './style/theme';
|
|
52
|
+
export type { CoreUITheme } from './style/theme';
|
package/src/lib/utils.ts
CHANGED
|
@@ -25,6 +25,10 @@ export const getThemeVariantSelector = () => (props) => {
|
|
|
25
25
|
return theme[key];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
/** Returns the theme color key for a given variant (e.g. for use with Icon color prop). */
|
|
29
|
+
export const getVariantThemeKey = (variant: string): string =>
|
|
30
|
+
variantMapping[variant] ?? variant;
|
|
31
|
+
|
|
28
32
|
export const hex2RGB = (str: string): [number, number, number] => {
|
|
29
33
|
const [, short, long] = String(str).match(RGB_HEX) || [];
|
|
30
34
|
|
|
@@ -55,3 +59,41 @@ export const convertRemToPixels = (rem: number): number => {
|
|
|
55
59
|
|
|
56
60
|
return 0;
|
|
57
61
|
};
|
|
62
|
+
|
|
63
|
+
type FormatISONumberOptions = {
|
|
64
|
+
decimals?: number;
|
|
65
|
+
compact?: boolean;
|
|
66
|
+
fixedDecimals?: boolean;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Formats a number to ISO 80000-1 format:
|
|
71
|
+
* - Space as thousands separator
|
|
72
|
+
* - Dot as decimal separator
|
|
73
|
+
* - Optional compact notation (10K, 1M, etc.)
|
|
74
|
+
* - Very small values (< 0.001): scientific notation
|
|
75
|
+
*/
|
|
76
|
+
export const formatISONumber = (
|
|
77
|
+
value: number,
|
|
78
|
+
options: FormatISONumberOptions = {},
|
|
79
|
+
): string => {
|
|
80
|
+
const { decimals = 2, compact = false, fixedDecimals = false } = options;
|
|
81
|
+
|
|
82
|
+
if (value === 0) return '0';
|
|
83
|
+
|
|
84
|
+
const absValue = Math.abs(value);
|
|
85
|
+
|
|
86
|
+
if (absValue < 0.001) {
|
|
87
|
+
return value.toExponential();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ISO format: space as thousands separator, dot as decimal separator
|
|
91
|
+
// With optional compact notation (10K, 1M, etc.)
|
|
92
|
+
return new Intl.NumberFormat('fr-FR', {
|
|
93
|
+
minimumFractionDigits: fixedDecimals ? decimals : undefined,
|
|
94
|
+
maximumFractionDigits: decimals,
|
|
95
|
+
notation: compact ? 'compact' : 'standard',
|
|
96
|
+
})
|
|
97
|
+
.format(value)
|
|
98
|
+
.replace(',', '.');
|
|
99
|
+
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type Story = StoryObj<GlobalHealthProps>;
|
|
10
10
|
|
|
11
11
|
const meta: Meta<GlobalHealthProps> = {
|
|
12
|
-
title: 'Components/
|
|
12
|
+
title: 'Components/Data Display/Charts/GlobalHealthBar',
|
|
13
13
|
component: GlobalHealthBar,
|
|
14
14
|
};
|
|
15
15
|
export default meta;
|
|
@@ -9,22 +9,24 @@ export default {
|
|
|
9
9
|
component: Banner,
|
|
10
10
|
decorators: [(story) => <Wrapper>{story()}</Wrapper>],
|
|
11
11
|
args: {
|
|
12
|
-
|
|
12
|
+
withDefaultIcon: true,
|
|
13
13
|
},
|
|
14
14
|
argTypes: {
|
|
15
|
+
withDefaultIcon: { control: 'boolean' },
|
|
15
16
|
icon: iconArgType,
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export const Playground = {
|
|
20
|
-
render: ({ icon, variant, children, ...args }) => {
|
|
21
|
+
render: ({ withDefaultIcon, icon, variant, children, ...args }) => {
|
|
21
22
|
return (
|
|
22
23
|
<Banner
|
|
23
|
-
|
|
24
|
+
withDefaultIcon={withDefaultIcon}
|
|
25
|
+
icon={icon ? <Icon name={icon} /> : undefined}
|
|
24
26
|
variant={variant}
|
|
25
27
|
children={children}
|
|
26
28
|
{...args}
|
|
27
|
-
|
|
29
|
+
/>
|
|
28
30
|
);
|
|
29
31
|
},
|
|
30
32
|
args: {
|
|
@@ -35,23 +37,38 @@ export const Playground = {
|
|
|
35
37
|
variant: { control: { disable: false } },
|
|
36
38
|
title: { control: { disable: false } },
|
|
37
39
|
children: { control: { disable: false } },
|
|
40
|
+
withDefaultIcon: { control: { disable: false } },
|
|
38
41
|
icon: { control: { disable: false } },
|
|
39
42
|
},
|
|
40
43
|
};
|
|
41
44
|
|
|
45
|
+
/** No icon. */
|
|
42
46
|
export const Default = {
|
|
43
47
|
...Playground,
|
|
44
48
|
args: {
|
|
45
49
|
children: 'There is an alert',
|
|
46
50
|
variant: 'base',
|
|
51
|
+
withDefaultIcon: false,
|
|
47
52
|
icon: undefined,
|
|
48
53
|
},
|
|
49
54
|
};
|
|
50
55
|
|
|
56
|
+
/** Simple default: withDefaultIcon + variant. Info-circle for base, Exclamation-circle otherwise. */
|
|
57
|
+
export const WithIcon = {
|
|
58
|
+
args: {
|
|
59
|
+
withDefaultIcon: true,
|
|
60
|
+
variant: 'base',
|
|
61
|
+
title: 'Info',
|
|
62
|
+
children: 'Use withDefaultIcon for the default icon (Info-circle on base, Exclamation-circle on warning/danger/etc.).',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
51
66
|
export const SuccessBanner = {
|
|
52
67
|
...Playground,
|
|
53
68
|
args: {
|
|
54
|
-
variant: '
|
|
69
|
+
variant: 'healthy',
|
|
70
|
+
withDefaultIcon: false,
|
|
71
|
+
icon: 'Check-circle',
|
|
55
72
|
title: 'Success',
|
|
56
73
|
children: 'There is a success',
|
|
57
74
|
},
|
|
@@ -60,16 +77,31 @@ export const SuccessBanner = {
|
|
|
60
77
|
export const WarningBanner = {
|
|
61
78
|
...Playground,
|
|
62
79
|
args: {
|
|
80
|
+
withDefaultIcon: true,
|
|
63
81
|
variant: 'warning',
|
|
64
82
|
title: 'Warning',
|
|
65
83
|
children: 'There is a warning',
|
|
66
84
|
},
|
|
67
85
|
};
|
|
86
|
+
|
|
68
87
|
export const ErrorBanner = {
|
|
69
88
|
...Playground,
|
|
70
89
|
args: {
|
|
90
|
+
withDefaultIcon: true,
|
|
71
91
|
variant: 'danger',
|
|
72
92
|
title: 'Error',
|
|
73
93
|
children: 'There is an error',
|
|
74
94
|
},
|
|
75
95
|
};
|
|
96
|
+
|
|
97
|
+
/** Custom icon when default (Exclamation-circle / Info-circle) is not desired. */
|
|
98
|
+
export const WithCustomIcon = {
|
|
99
|
+
...Playground,
|
|
100
|
+
args: {
|
|
101
|
+
variant: 'base',
|
|
102
|
+
withDefaultIcon: false,
|
|
103
|
+
icon: 'Exclamation-circle',
|
|
104
|
+
title: 'Custom',
|
|
105
|
+
children: 'Use the icon prop when you need a specific icon other than the withDefaultIcon default.',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { InputList } from '../src/lib/components/inputlist/InputList.component';
|
|
3
|
+
import { InputList, InputListProps } from '../src/lib/components/inputlist/InputList.component';
|
|
4
4
|
import { Wrapper as StoryWrapper } from './common';
|
|
5
5
|
import { FormSection } from '../src/lib/components/form/Form.component';
|
|
6
6
|
import { Controller, useForm } from 'react-hook-form';
|
|
@@ -9,15 +9,27 @@ const meta: Meta<typeof InputList> = {
|
|
|
9
9
|
tags: ['autodocs'],
|
|
10
10
|
title: 'Components/Inputs/InputList',
|
|
11
11
|
component: InputList,
|
|
12
|
+
args: {
|
|
13
|
+
value: [''],
|
|
14
|
+
size: '1/2',
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
size: {
|
|
18
|
+
options: ['1/3', '1/2', '2/3', '1'],
|
|
19
|
+
control: 'select',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
12
22
|
};
|
|
13
23
|
export default meta;
|
|
14
24
|
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
15
26
|
interface InputListForm {
|
|
16
27
|
firstNames: string[];
|
|
17
28
|
lastNames: string[];
|
|
18
29
|
}
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
|
|
32
|
+
const ExampleList = ({ size }: { size?: InputListProps<string>['size'] }) => {
|
|
21
33
|
const { control } = useForm<InputListForm>({
|
|
22
34
|
mode: 'all',
|
|
23
35
|
defaultValues: {
|
|
@@ -35,10 +47,11 @@ const ExampleList = () => {
|
|
|
35
47
|
}}
|
|
36
48
|
render={({ field: { onChange, onBlur, value } }) => (
|
|
37
49
|
<InputList
|
|
38
|
-
placeholder="
|
|
50
|
+
placeholder="San Francisco"
|
|
39
51
|
onBlur={onBlur}
|
|
40
52
|
onChange={onChange}
|
|
41
53
|
value={value}
|
|
54
|
+
size={size}
|
|
42
55
|
/>
|
|
43
56
|
)}
|
|
44
57
|
name="firstNames"
|
|
@@ -46,12 +59,11 @@ const ExampleList = () => {
|
|
|
46
59
|
</FormSection>
|
|
47
60
|
);
|
|
48
61
|
};
|
|
49
|
-
type Story = StoryObj<typeof InputList>;
|
|
50
62
|
export const SimpleListOfInputs: Story = {
|
|
51
63
|
name: 'List of inputs',
|
|
52
|
-
render: () => (
|
|
64
|
+
render: (args) => (
|
|
53
65
|
<StoryWrapper>
|
|
54
|
-
<ExampleList />
|
|
66
|
+
<ExampleList {...args} />
|
|
55
67
|
</StoryWrapper>
|
|
56
68
|
),
|
|
57
69
|
};
|