design-react-kit 5.5.1 → 5.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 +18 -0
- package/dist/Alert/Alert.cjs.map +1 -1
- package/dist/Alert/Alert.js.map +1 -1
- package/dist/Autocomplete/Autocomplete.cjs +3 -1
- package/dist/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/Autocomplete/Autocomplete.js +2 -2
- package/dist/Autocomplete/Autocomplete.js.map +1 -1
- package/dist/BackToTop/BackToTop.cjs +1 -1
- package/dist/BackToTop/BackToTop.cjs.map +1 -1
- package/dist/BackToTop/BackToTop.js +1 -1
- package/dist/BackToTop/BackToTop.js.map +1 -1
- package/dist/BottomNav/BottomNavItem.cjs +1 -1
- package/dist/BottomNav/BottomNavItem.cjs.map +1 -1
- package/dist/Callout/CalloutMoreFooter.cjs +1 -1
- package/dist/Callout/CalloutMoreFooter.cjs.map +1 -1
- package/dist/Card/CardCategory.cjs +1 -1
- package/dist/Card/CardCategory.cjs.map +1 -1
- package/dist/Card/CardCategory.js +3 -3
- package/dist/Card/CardCategory.js.map +1 -1
- package/dist/Card/CardReadMore.cjs +1 -1
- package/dist/Card/CardReadMore.cjs.map +1 -1
- package/dist/Collapse/Collapse.cjs +1 -1
- package/dist/Collapse/Collapse.cjs.map +1 -1
- package/dist/Collapse/Collapse.js +3 -3
- package/dist/Collapse/Collapse.js.map +1 -1
- package/dist/Dimmer/Dimmer.cjs +1 -1
- package/dist/Dimmer/Dimmer.cjs.map +1 -1
- package/dist/Dropdown/Dropdown.cjs.map +1 -1
- package/dist/Dropdown/Dropdown.js +1 -1
- package/dist/Dropdown/Dropdown.js.map +1 -1
- package/dist/Dropdown/DropdownToggle.cjs +1 -1
- package/dist/Dropdown/DropdownToggle.cjs.map +1 -1
- package/dist/Forward/Forward.cjs.map +1 -1
- package/dist/Forward/Forward.js.map +1 -1
- package/dist/GoBack/GoBack.cjs +1 -1
- package/dist/GoBack/GoBack.cjs.map +1 -1
- package/dist/Grid/GridItemTextWrapper.cjs.map +1 -1
- package/dist/Grid/GridItemTextWrapper.js.map +1 -1
- package/dist/Grid/index.cjs.map +1 -1
- package/dist/Header/HeaderBrand.cjs +1 -1
- package/dist/Header/HeaderBrand.cjs.map +1 -1
- package/dist/Header/HeaderSearch.cjs +1 -1
- package/dist/Header/HeaderSearch.cjs.map +1 -1
- package/dist/Header/HeaderToggler.cjs.map +1 -1
- package/dist/Header/HeaderToggler.js +1 -1
- package/dist/Header/HeaderToggler.js.map +1 -1
- package/dist/Icon/Icon.cjs +1 -1
- package/dist/Icon/Icon.cjs.map +1 -1
- package/dist/Icon/Icon.js +3 -3
- package/dist/Icon/Icon.js.map +1 -1
- package/dist/Icon/assets/index.cjs.map +1 -1
- package/dist/Input/Input.cjs +1 -1
- package/dist/Input/Input.cjs.map +1 -1
- package/dist/Input/Input.js +13 -6
- package/dist/Input/Input.js.map +1 -1
- package/dist/Input/InputContainer.cjs.map +1 -1
- package/dist/Input/InputContainer.js.map +1 -1
- package/dist/Input/TextArea.cjs +1 -1
- package/dist/Input/TextArea.cjs.map +1 -1
- package/dist/Input/TextArea.js.map +1 -1
- package/dist/Input/utils.cjs +1 -1
- package/dist/Input/utils.cjs.map +1 -1
- package/dist/Input/utils.js +1 -2
- package/dist/Input/utils.js.map +1 -1
- package/dist/List/List.cjs.map +1 -1
- package/dist/List/List.js.map +1 -1
- package/dist/List/ListItem.cjs.map +1 -1
- package/dist/List/ListItem.js +2 -2
- package/dist/List/ListItem.js.map +1 -1
- package/dist/Megamenu/MegamenuItem.cjs +1 -1
- package/dist/Megamenu/MegamenuItem.cjs.map +1 -1
- package/dist/Modal/ModalHeader.cjs +1 -1
- package/dist/Modal/ModalHeader.cjs.map +1 -1
- package/dist/NavScroll/types.cjs.map +1 -1
- package/dist/Notification/NotificationContent.cjs +1 -1
- package/dist/Notification/NotificationContent.cjs.map +1 -1
- package/dist/Notification/core.cjs +1 -1
- package/dist/Notification/core.cjs.map +1 -1
- package/dist/Notification/index.cjs +1 -1
- package/dist/Notification/index.cjs.map +1 -1
- package/dist/Rating/Rating.cjs +1 -1
- package/dist/Rating/Rating.cjs.map +1 -1
- package/dist/ResponsiveImage/ResponsiveImage.cjs.map +1 -1
- package/dist/ResponsiveImage/ResponsiveImage.js.map +1 -1
- package/dist/Skiplink/Skiplink.cjs.map +1 -1
- package/dist/Skiplink/Skiplink.js.map +1 -1
- package/dist/Skiplink/SkiplinkItem.cjs.map +1 -1
- package/dist/Stepper/StepperHeaderElement.cjs +1 -1
- package/dist/Stepper/StepperHeaderElement.cjs.map +1 -1
- package/dist/Stepper/StepperHeaderElement.js +3 -5
- package/dist/Stepper/StepperHeaderElement.js.map +1 -1
- package/dist/Tab/TabNav.cjs +2 -0
- package/dist/Tab/TabNav.cjs.map +1 -0
- package/dist/Tab/TabNav.js +63 -0
- package/dist/Tab/TabNav.js.map +1 -0
- package/dist/Tab/TabNavItem.cjs +2 -0
- package/dist/Tab/TabNavItem.cjs.map +1 -0
- package/dist/Tab/TabNavItem.js +7 -0
- package/dist/Tab/TabNavItem.js.map +1 -0
- package/dist/Tab/TabNavLink.cjs +2 -0
- package/dist/Tab/TabNavLink.cjs.map +1 -0
- package/dist/Tab/TabNavLink.js +7 -0
- package/dist/Tab/TabNavLink.js.map +1 -0
- package/dist/Tab/TabPanel.cjs +2 -0
- package/dist/Tab/TabPanel.cjs.map +1 -0
- package/dist/Tab/TabPanel.js +7 -0
- package/dist/Tab/TabPanel.js.map +1 -0
- package/dist/Timeline/TimelinePin.cjs +1 -1
- package/dist/Timeline/TimelinePin.cjs.map +1 -1
- package/dist/Timeline/TimelinePin.js +1 -1
- package/dist/Timeline/TimelinePin.js.map +1 -1
- package/dist/Toggle/Toggle.cjs.map +1 -1
- package/dist/Toggle/Toggle.js.map +1 -1
- package/dist/Toolbar/ToolbarItem.cjs +1 -1
- package/dist/Toolbar/ToolbarItem.cjs.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/track-focus.cjs.map +1 -1
- package/dist/track-focus.js.map +1 -1
- package/dist/types/Icon/Icon.d.ts +1 -1
- package/dist/types/NavScroll/types.d.ts +2 -2
- package/dist/types/Stepper/StepperHeaderElement.d.ts +4 -4
- package/dist/types/Tab/TabNav.d.ts +24 -0
- package/dist/types/Tab/TabNavItem.d.ts +8 -0
- package/dist/types/Tab/TabNavLink.d.ts +8 -0
- package/dist/types/Tab/TabPanel.d.ts +8 -0
- package/dist/types/index.d.ts +11 -3
- package/package.json +5 -3
- package/src/Alert/Alert.tsx +1 -2
- package/src/Autocomplete/Autocomplete.tsx +70 -69
- package/src/BackToTop/BackToTop.tsx +2 -1
- package/src/Card/CardCategory.tsx +17 -4
- package/src/Collapse/Collapse.tsx +8 -12
- package/src/Dropdown/Dropdown.tsx +4 -6
- package/src/Forward/Forward.tsx +3 -3
- package/src/Grid/GridItemTextWrapper.tsx +7 -1
- package/src/Header/HeaderToggler.tsx +2 -2
- package/src/Icon/Icon.tsx +22 -4
- package/src/Icon/assets/index.ts +1 -1
- package/src/Input/Input.tsx +13 -7
- package/src/Input/InputContainer.tsx +0 -1
- package/src/Input/TextArea.tsx +1 -4
- package/src/Input/utils.tsx +1 -2
- package/src/List/List.tsx +1 -8
- package/src/List/ListItem.tsx +24 -33
- package/src/NavScroll/types.ts +2 -2
- package/src/ResponsiveImage/ResponsiveImage.tsx +13 -7
- package/src/Skiplink/Skiplink.tsx +12 -7
- package/src/Skiplink/SkiplinkItem.tsx +1 -1
- package/src/Stepper/StepperHeaderElement.tsx +8 -10
- package/src/Tab/TabNav.tsx +111 -0
- package/src/Tab/TabNavItem.tsx +14 -0
- package/src/Tab/TabNavLink.tsx +14 -0
- package/src/Tab/TabPanel.tsx +14 -0
- package/src/Timeline/TimelinePin.tsx +2 -2
- package/src/Toggle/Toggle.tsx +1 -1
- package/src/index.ts +9 -5
- package/src/track-focus.js +14 -15
package/src/Icon/Icon.tsx
CHANGED
|
@@ -47,7 +47,7 @@ export interface IconProps extends SVGProps<SVGSVGElement> {
|
|
|
47
47
|
size?: 'xl' | 'lg' | '' | 'sm' | 'xs';
|
|
48
48
|
/**
|
|
49
49
|
* Il nome dell'icona da mostrare. Per una lista completa vedi:
|
|
50
|
-
* <a href="https://italia.github.io/design-react-kit/?path=/story/
|
|
50
|
+
* <a href="https://italia.github.io/design-react-kit/?path=/story/documentazione-utilities-icon--lista-icone" target="_blank">Lista icone</a>.
|
|
51
51
|
* In caso di un'immagine esterna l'URL da utilizzare.
|
|
52
52
|
**/
|
|
53
53
|
icon: string;
|
|
@@ -65,7 +65,7 @@ export const Icon: FC<IconProps> = ({
|
|
|
65
65
|
color = '',
|
|
66
66
|
size = '',
|
|
67
67
|
icon = '',
|
|
68
|
-
title,
|
|
68
|
+
title = '',
|
|
69
69
|
className,
|
|
70
70
|
padding = false,
|
|
71
71
|
onIconLoad,
|
|
@@ -108,8 +108,26 @@ export const Icon: FC<IconProps> = ({
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
if (!IconComponent) {
|
|
111
|
-
return
|
|
111
|
+
return (
|
|
112
|
+
<EmptyIcon
|
|
113
|
+
className={classes}
|
|
114
|
+
role={title === '' ? undefined : 'img'}
|
|
115
|
+
aria-hidden={title === '' ? true : false}
|
|
116
|
+
title={title}
|
|
117
|
+
{...attributes}
|
|
118
|
+
data-testid={testId}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
112
121
|
}
|
|
113
122
|
|
|
114
|
-
return
|
|
123
|
+
return (
|
|
124
|
+
<IconComponent
|
|
125
|
+
className={classes}
|
|
126
|
+
role={title === '' ? undefined : 'img'}
|
|
127
|
+
aria-hidden={title === '' ? true : false}
|
|
128
|
+
title={title}
|
|
129
|
+
data-testid={testId}
|
|
130
|
+
{...attributes}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
115
133
|
};
|
package/src/Icon/assets/index.ts
CHANGED
package/src/Input/Input.tsx
CHANGED
|
@@ -203,8 +203,8 @@ export const Input = ({
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// associate the input field with the help text
|
|
206
|
-
const infoId = id ? `${id}Description` : undefined;
|
|
207
|
-
if (
|
|
206
|
+
const infoId = id && infoText ? `${id}Description` : undefined;
|
|
207
|
+
if (infoId) {
|
|
208
208
|
extraAttributes['aria-describedby'] = infoId;
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -296,11 +296,19 @@ export const Input = ({
|
|
|
296
296
|
}
|
|
297
297
|
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
|
|
298
298
|
nativeInputValueSetter?.call(inputRef.current, `${newValue}`);
|
|
299
|
+
const ev1 = new Event('change', { bubbles: true });
|
|
299
300
|
const ev2 = new Event('input', { bubbles: true });
|
|
301
|
+
inputRef.current?.dispatchEvent(ev1);
|
|
300
302
|
inputRef.current?.dispatchEvent(ev2);
|
|
303
|
+
inputRef.current?.focus();
|
|
301
304
|
};
|
|
302
305
|
|
|
303
306
|
if (['currency', 'percentage', 'adaptive', 'number'].includes(type)) {
|
|
307
|
+
if (containerProps.extraLabelClass) {
|
|
308
|
+
containerProps.extraLabelClass = containerProps.extraLabelClass + ' input-symbol-label';
|
|
309
|
+
} else {
|
|
310
|
+
containerProps.extraLabelClass = 'input-symbol-label';
|
|
311
|
+
}
|
|
304
312
|
return (
|
|
305
313
|
<InputContainer {...containerProps}>
|
|
306
314
|
<div
|
|
@@ -308,8 +316,6 @@ export const Input = ({
|
|
|
308
316
|
'input-group': true,
|
|
309
317
|
'input-number': true,
|
|
310
318
|
disabled: rest.disabled,
|
|
311
|
-
'input-number-percentage': type === 'percentage',
|
|
312
|
-
'input-number-currency': type === 'currency',
|
|
313
319
|
'input-number-adaptive': type === 'adaptive'
|
|
314
320
|
})}
|
|
315
321
|
style={{ width }}
|
|
@@ -328,10 +334,10 @@ export const Input = ({
|
|
|
328
334
|
ref={inputRef}
|
|
329
335
|
/>
|
|
330
336
|
<span className='input-group-text align-buttons flex-column'>
|
|
331
|
-
<button className='input-number-add' onClick={() => clickIncrDecr(1)}
|
|
337
|
+
<button className='input-number-add' onClick={() => clickIncrDecr(1)}>
|
|
332
338
|
<span className='visually-hidden'>{incrementLabel || ''}</span>
|
|
333
339
|
</button>
|
|
334
|
-
<button className='input-number-sub' onClick={() => clickIncrDecr(-1)}
|
|
340
|
+
<button className='input-number-sub' onClick={() => clickIncrDecr(-1)}>
|
|
335
341
|
<span className='visually-hidden'>{decrementLabel || ''}</span>
|
|
336
342
|
</button>
|
|
337
343
|
</span>
|
|
@@ -416,4 +422,4 @@ export const Input = ({
|
|
|
416
422
|
}
|
|
417
423
|
|
|
418
424
|
return <Tag {...rest} {...extraAttributes} className={inputClasses} {...sharedAttributes} data-testid={testId} />;
|
|
419
|
-
};
|
|
425
|
+
};
|
package/src/Input/TextArea.tsx
CHANGED
|
@@ -57,10 +57,7 @@ export const TextArea = ({
|
|
|
57
57
|
const extraAttributes: { ['aria-describedby']?: string } = {};
|
|
58
58
|
|
|
59
59
|
//Chiamo questa funzione per impostare classNames a 'form-control'
|
|
60
|
-
const formControlClass = getFormControlClass(
|
|
61
|
-
{},
|
|
62
|
-
cssModule
|
|
63
|
-
);
|
|
60
|
+
const formControlClass = getFormControlClass({}, cssModule);
|
|
64
61
|
// associate the input field with the help text
|
|
65
62
|
const infoId = id ? `${id}Description` : undefined;
|
|
66
63
|
if (id) {
|
package/src/Input/utils.tsx
CHANGED
|
@@ -117,8 +117,7 @@ export function getClasses(
|
|
|
117
117
|
// we can model here only if stylings
|
|
118
118
|
'form-control-plaintext': normalizedOnlyCondition,
|
|
119
119
|
'form-control': passwordOnlyCondition,
|
|
120
|
-
'input-password': passwordOnlyCondition
|
|
121
|
-
'focus--mouse': passwordOnlyCondition || normalizedOnlyCondition
|
|
120
|
+
'input-password': passwordOnlyCondition
|
|
122
121
|
}
|
|
123
122
|
),
|
|
124
123
|
cssModule
|
package/src/List/List.tsx
CHANGED
|
@@ -16,14 +16,7 @@ export interface ListProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
16
16
|
testId?: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const List: FC<ListProps> = ({
|
|
20
|
-
className,
|
|
21
|
-
wrapperClassName,
|
|
22
|
-
tag = 'div',
|
|
23
|
-
noWrapper,
|
|
24
|
-
testId,
|
|
25
|
-
...attributes
|
|
26
|
-
}) => {
|
|
19
|
+
export const List: FC<ListProps> = ({ className, wrapperClassName, tag = 'div', noWrapper, testId, ...attributes }) => {
|
|
27
20
|
const Tag = tag;
|
|
28
21
|
const wrapperClasses = classNames('it-list-wrapper', wrapperClassName);
|
|
29
22
|
const classes = classNames(className, 'it-list');
|
package/src/List/ListItem.tsx
CHANGED
|
@@ -39,46 +39,37 @@ export const ListItem: FC<ListItemProps> & {
|
|
|
39
39
|
children,
|
|
40
40
|
...attributes
|
|
41
41
|
}) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
'avatar size-lg': avatar,
|
|
51
|
-
'it-thumb': img
|
|
52
|
-
}),
|
|
53
|
-
leftItem = icon || avatar || img;
|
|
54
|
-
|
|
55
|
-
if (href) {
|
|
56
|
-
return (
|
|
57
|
-
<li className={wrapperClassName} data-testid={testId}>
|
|
58
|
-
<a href={href || '#'} {...attributes} className={classes}>
|
|
59
|
-
<div className="it-right-zone">{children}</div>
|
|
60
|
-
</a>
|
|
61
|
-
</li>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
42
|
+
const Tag = tag;
|
|
43
|
+
const classes = classNames(className, { active }, 'list-item'),
|
|
44
|
+
classesItem = classNames(className, {
|
|
45
|
+
'it-rounded-icon': icon,
|
|
46
|
+
'avatar size-lg': avatar,
|
|
47
|
+
'it-thumb': img
|
|
48
|
+
}),
|
|
49
|
+
leftItem = icon || avatar || img;
|
|
64
50
|
|
|
51
|
+
if (href) {
|
|
65
52
|
return (
|
|
66
53
|
<li className={wrapperClassName} data-testid={testId}>
|
|
67
|
-
<
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
href={href}
|
|
71
|
-
to={to}
|
|
72
|
-
>
|
|
73
|
-
{leftItem && <div className={classesItem}>{leftItem}</div>}
|
|
74
|
-
<div className="it-right-zone">{children}</div>
|
|
75
|
-
</Tag>
|
|
54
|
+
<a href={href || '#'} {...attributes} className={classes}>
|
|
55
|
+
<div className='it-right-zone'>{children}</div>
|
|
56
|
+
</a>
|
|
76
57
|
</li>
|
|
77
58
|
);
|
|
78
|
-
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<li className={wrapperClassName} data-testid={testId}>
|
|
63
|
+
<Tag {...attributes} className={classes} href={href} to={to}>
|
|
64
|
+
{leftItem && <div className={classesItem}>{leftItem}</div>}
|
|
65
|
+
<div className='it-right-zone'>{children}</div>
|
|
66
|
+
</Tag>
|
|
67
|
+
</li>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
79
70
|
|
|
80
71
|
const MultipleAction: FC<ListItemProps> = ({ children }) => {
|
|
81
|
-
return <span className='it-multiple'>{children}</span
|
|
72
|
+
return <span className='it-multiple'>{children}</span>;
|
|
82
73
|
};
|
|
83
74
|
|
|
84
75
|
ListItem.MultipleAction = MultipleAction;
|
package/src/NavScroll/types.ts
CHANGED
|
@@ -12,26 +12,32 @@ export interface ResponsiveImageProps extends HTMLAttributes<HTMLImageElement> {
|
|
|
12
12
|
proportioned?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const ResponsiveImage: FC<ResponsiveImageProps> = ({
|
|
15
|
+
export const ResponsiveImage: FC<ResponsiveImageProps> = ({
|
|
16
|
+
alt,
|
|
17
|
+
testId,
|
|
18
|
+
proportioned = false,
|
|
19
|
+
children,
|
|
20
|
+
...attributes
|
|
21
|
+
}) => {
|
|
16
22
|
if (children) {
|
|
17
23
|
if (proportioned) {
|
|
18
|
-
return(
|
|
24
|
+
return (
|
|
19
25
|
<div className='img-responsive-wrapper'>
|
|
20
26
|
<div className='img-responsive'>
|
|
21
27
|
<figure className='img-wrapper'>
|
|
22
|
-
<img {...attributes} alt={alt}
|
|
28
|
+
<img {...attributes} alt={alt} className='figure-img img-fluid rounded' />
|
|
23
29
|
{children}
|
|
24
30
|
</figure>
|
|
25
31
|
</div>
|
|
26
32
|
</div>
|
|
27
|
-
)
|
|
33
|
+
);
|
|
28
34
|
} else {
|
|
29
|
-
return(
|
|
35
|
+
return (
|
|
30
36
|
<figure className='figure img-full w-100 img-responsive-wrapper'>
|
|
31
|
-
<img {...attributes} alt={alt}
|
|
37
|
+
<img {...attributes} alt={alt} className='figure-img img-fluid rounded' />
|
|
32
38
|
{children}
|
|
33
39
|
</figure>
|
|
34
|
-
)
|
|
40
|
+
);
|
|
35
41
|
}
|
|
36
42
|
} else {
|
|
37
43
|
return (
|
|
@@ -12,18 +12,23 @@ export interface SkiplinkProps extends HTMLAttributes<HTMLElement> {
|
|
|
12
12
|
testId?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const Skiplink: FC<SkiplinkProps> = ({
|
|
15
|
+
export const Skiplink: FC<SkiplinkProps> = ({
|
|
16
|
+
ariaLabel = null,
|
|
17
|
+
className,
|
|
18
|
+
tag = 'div',
|
|
19
|
+
nav = false,
|
|
20
|
+
testId,
|
|
21
|
+
children,
|
|
22
|
+
...attributes
|
|
23
|
+
}) => {
|
|
16
24
|
const Tag = nav ? 'nav' : tag;
|
|
17
25
|
const classes = classNames(className, 'skiplinks');
|
|
18
26
|
if (nav) {
|
|
19
27
|
return (
|
|
20
|
-
<Tag aria-label={ariaLabel} className={classes} {...attributes} data-testid={testId}
|
|
21
|
-
<ul>
|
|
22
|
-
{children}
|
|
23
|
-
</ul>
|
|
28
|
+
<Tag aria-label={ariaLabel} className={classes} {...attributes} data-testid={testId}>
|
|
29
|
+
<ul>{children}</ul>
|
|
24
30
|
</Tag>
|
|
25
|
-
)
|
|
26
|
-
|
|
31
|
+
);
|
|
27
32
|
} else {
|
|
28
33
|
return <Tag aria-label={ariaLabel} className={classes} {...attributes} data-testid={testId} />;
|
|
29
34
|
}
|
|
@@ -29,14 +29,14 @@ export interface StepperHeaderElementProps extends HTMLAttributes<HTMLLIElement>
|
|
|
29
29
|
appendIcon?: string;
|
|
30
30
|
/** Icona da mostrare alla sinistra dell'etichetta dello step */
|
|
31
31
|
prependIcon?: string;
|
|
32
|
+
/** Titolo dell'icona da mostrare alla destra dell'etichetta dello step */
|
|
33
|
+
appendIconTitle?: string;
|
|
34
|
+
/** Titolo dell'icona da mostrare alla sinistra dell'etichetta dello step */
|
|
35
|
+
prependIconTitle?: string;
|
|
32
36
|
/** Utilizzare questo attributo per elementi aggiuntivi da mostrare su dispositivi mobile per lo step attivo */
|
|
33
37
|
stepperNumber?: ReactNode;
|
|
34
38
|
/** Nasconde il bordo inferiore azzurro per lo step */
|
|
35
39
|
noLine?: boolean;
|
|
36
|
-
/** @deprecated Usare `appendIcon` */
|
|
37
|
-
icon?: string;
|
|
38
|
-
/** @deprecated Usare `prependIcon` */
|
|
39
|
-
iconName?: string;
|
|
40
40
|
testId?: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -45,8 +45,8 @@ export const StepperHeaderElement: FC<StepperHeaderElementProps> = ({
|
|
|
45
45
|
variant,
|
|
46
46
|
appendIcon,
|
|
47
47
|
prependIcon,
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
appendIconTitle,
|
|
49
|
+
prependIconTitle,
|
|
50
50
|
noLine,
|
|
51
51
|
stepperNumber,
|
|
52
52
|
testId,
|
|
@@ -61,14 +61,12 @@ export const StepperHeaderElement: FC<StepperHeaderElementProps> = ({
|
|
|
61
61
|
const iconClass = classNames('icon', 'steppers-success');
|
|
62
62
|
const spanClass = classNames('steppers-number');
|
|
63
63
|
|
|
64
|
-
const iconToAppend = appendIcon || icon;
|
|
65
|
-
const iconToPrepend = prependIcon || iconName;
|
|
66
64
|
return (
|
|
67
65
|
<Tag {...attributes} className={wrapperClasses} data-testid={testId}>
|
|
68
|
-
{
|
|
66
|
+
{prependIcon && <Icon icon={prependIcon} title={prependIconTitle} />}
|
|
69
67
|
{stepperNumber && <span className={spanClass}>{stepperNumber}</span>}
|
|
70
68
|
{children}
|
|
71
|
-
{
|
|
69
|
+
{appendIcon && <Icon icon={appendIcon} title={appendIconTitle} className={iconClass} />}
|
|
72
70
|
</Tag>
|
|
73
71
|
);
|
|
74
72
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React, { ElementType, FC, useRef } from 'react';
|
|
3
|
+
import { Nav, NavProps } from 'react-bootstrap';
|
|
4
|
+
|
|
5
|
+
export interface TabNavProps extends NavProps {
|
|
6
|
+
/** Utilizzarlo in caso di utilizzo di componenti personalizzati
|
|
7
|
+
* @default ul
|
|
8
|
+
*/
|
|
9
|
+
tag?: ElementType;
|
|
10
|
+
/** Classi aggiuntive da usare per il componente Tab */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Imposta l'orientameno delle tab in verticale
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
vertical?: boolean;
|
|
16
|
+
/** Imposta la tab con sfondo scuro
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
dark?: boolean;
|
|
20
|
+
/** Imposta la tab con design tipo card
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
card?: boolean;
|
|
24
|
+
testId?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const TabNav: FC<TabNavProps> = ({
|
|
28
|
+
className,
|
|
29
|
+
vertical = false,
|
|
30
|
+
dark = false,
|
|
31
|
+
card = false,
|
|
32
|
+
tag = 'ul',
|
|
33
|
+
testId,
|
|
34
|
+
...attributes
|
|
35
|
+
}) => {
|
|
36
|
+
const Tag = tag;
|
|
37
|
+
const rootRef = useRef<HTMLInputElement>();
|
|
38
|
+
|
|
39
|
+
const classes = classNames(
|
|
40
|
+
className,
|
|
41
|
+
'nav-tabs',
|
|
42
|
+
{ 'nav-tabs-vertical': vertical },
|
|
43
|
+
{ 'nav-dark': dark },
|
|
44
|
+
{ 'nav-tabs-cards': card }
|
|
45
|
+
);
|
|
46
|
+
let currentTabIndex = 0;
|
|
47
|
+
let activeTabIndex = -1;
|
|
48
|
+
|
|
49
|
+
// Ugly workaround to keep Bootstrap Italia behaviour
|
|
50
|
+
|
|
51
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>, disabled: boolean = false) => {
|
|
52
|
+
const queriedElements = rootRef.current?.querySelectorAll('.nav-link');
|
|
53
|
+
if (queriedElements) {
|
|
54
|
+
for (let i = 0; i < queriedElements.length; i++) {
|
|
55
|
+
if (queriedElements[i].ariaSelected === 'true') {
|
|
56
|
+
activeTabIndex = i;
|
|
57
|
+
}
|
|
58
|
+
// Disabled elements ignore current focused tab
|
|
59
|
+
if (!disabled && document.activeElement === queriedElements[i]) {
|
|
60
|
+
currentTabIndex = i;
|
|
61
|
+
}
|
|
62
|
+
queriedElements[i].ariaSelected = 'false';
|
|
63
|
+
}
|
|
64
|
+
switch (event.key) {
|
|
65
|
+
case 'ArrowLeft':
|
|
66
|
+
case 'ArrowUp':
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
if (currentTabIndex - 1 < 0) {
|
|
70
|
+
currentTabIndex = queriedElements.length;
|
|
71
|
+
}
|
|
72
|
+
currentTabIndex = (currentTabIndex - 1) % queriedElements.length;
|
|
73
|
+
break;
|
|
74
|
+
case 'ArrowRight':
|
|
75
|
+
case 'ArrowDown':
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
currentTabIndex = (currentTabIndex + 1) % queriedElements.length;
|
|
79
|
+
break;
|
|
80
|
+
case 'Enter':
|
|
81
|
+
event.stopPropagation();
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
(queriedElements[currentTabIndex] as HTMLElement).click();
|
|
84
|
+
break;
|
|
85
|
+
case 'Tab':
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (queriedElements[currentTabIndex].ariaDisabled === 'true') {
|
|
91
|
+
handleKeyDown(event, true);
|
|
92
|
+
} else {
|
|
93
|
+
(queriedElements[currentTabIndex] as HTMLElement).focus({ preventScroll: true });
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
queriedElements[activeTabIndex].ariaSelected = 'true';
|
|
96
|
+
}, 300);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Nav
|
|
103
|
+
ref={rootRef}
|
|
104
|
+
as={Tag}
|
|
105
|
+
className={classes}
|
|
106
|
+
data-testid={testId}
|
|
107
|
+
{...attributes}
|
|
108
|
+
onKeyDown={handleKeyDown}
|
|
109
|
+
></Nav>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ElementType, FC } from 'react';
|
|
2
|
+
import { Nav, NavItemProps } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
export interface TabNavItemProps extends NavItemProps {
|
|
5
|
+
/** Utilizzarlo in caso di utilizzo di componenti personalizzati */
|
|
6
|
+
tag?: ElementType;
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const TabNavItem: FC<TabNavItemProps> = ({ tag = 'li', testId, ...attributes }) => {
|
|
11
|
+
const Tag = tag;
|
|
12
|
+
|
|
13
|
+
return <Nav.Item as={Tag} role='presentation' data-testid={testId} {...attributes}></Nav.Item>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ElementType, FC } from 'react';
|
|
2
|
+
import { Nav, NavLinkProps } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
export interface TabNavLinkProps extends NavLinkProps {
|
|
5
|
+
/** Utilizzarlo in caso di utilizzo di componenti personalizzati */
|
|
6
|
+
tag?: ElementType;
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const TabNavLink: FC<TabNavLinkProps> = ({ tag, testId, ...attributes }) => {
|
|
11
|
+
const Tag = tag;
|
|
12
|
+
|
|
13
|
+
return <Nav.Link as={Tag} data-testid={testId} {...attributes}></Nav.Link>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ElementType, FC } from 'react';
|
|
2
|
+
import { NavProps, Tab } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
export interface TabsProps extends NavProps {
|
|
5
|
+
/** Utilizzarlo in caso di utilizzo di componenti personalizzati */
|
|
6
|
+
tag?: ElementType;
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const TabContainer: FC<TabsProps> = ({ tag, testId, ...attributes }) => {
|
|
11
|
+
const Tag = tag;
|
|
12
|
+
|
|
13
|
+
return <Tab.Container as={Tag} data-testid={testId} {...attributes}></Tab.Container>;
|
|
14
|
+
};
|
|
@@ -40,7 +40,7 @@ export const TimelinePin: FC<TimelinePinProps> = ({
|
|
|
40
40
|
nowText,
|
|
41
41
|
testId,
|
|
42
42
|
className,
|
|
43
|
-
tag='h3',
|
|
43
|
+
tag = 'h3',
|
|
44
44
|
...attributes
|
|
45
45
|
}) => {
|
|
46
46
|
const { children, ...rest } = attributes;
|
|
@@ -51,7 +51,7 @@ export const TimelinePin: FC<TimelinePinProps> = ({
|
|
|
51
51
|
});
|
|
52
52
|
const pinIcon = (
|
|
53
53
|
<div className='pin-icon'>
|
|
54
|
-
<Icon icon={iconName || icon} role=
|
|
54
|
+
<Icon icon={iconName || icon} role='img' title={iconTitle} />
|
|
55
55
|
</div>
|
|
56
56
|
);
|
|
57
57
|
const pinLabel = (
|
package/src/Toggle/Toggle.tsx
CHANGED
|
@@ -23,7 +23,7 @@ export const Toggle: FC<ToggleProps> = ({ label, testId, ...rest }) => {
|
|
|
23
23
|
<div className='toggles' data-testid={testId}>
|
|
24
24
|
<Label check for={rest.id}>
|
|
25
25
|
{label}
|
|
26
|
-
<Input {...rest} type='checkbox' aria-describedby={rest.id ? rest.id + 'Description' : ''
|
|
26
|
+
<Input {...rest} type='checkbox' aria-describedby={rest.id ? rest.id + 'Description' : ''} />
|
|
27
27
|
<span className='lever' />
|
|
28
28
|
</Label>
|
|
29
29
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -37,8 +37,6 @@ export {
|
|
|
37
37
|
PopoverBody,
|
|
38
38
|
PopoverHeader,
|
|
39
39
|
Row,
|
|
40
|
-
TabContent,
|
|
41
|
-
TabPane,
|
|
42
40
|
Table,
|
|
43
41
|
Tooltip,
|
|
44
42
|
UncontrolledAlert,
|
|
@@ -47,6 +45,7 @@ export {
|
|
|
47
45
|
Util
|
|
48
46
|
} from 'reactstrap';
|
|
49
47
|
|
|
48
|
+
export { TabContainer, TabContent, TabPane } from 'react-bootstrap';
|
|
50
49
|
export { Autocomplete } from './Autocomplete/Autocomplete';
|
|
51
50
|
export { Accordion } from './Accordion/Accordion';
|
|
52
51
|
export { AccordionBody } from './Accordion/AccordionBody';
|
|
@@ -136,6 +135,9 @@ export { StepperDots } from './Stepper/StepperDots';
|
|
|
136
135
|
export { StepperHeader } from './Stepper/StepperHeader';
|
|
137
136
|
export { StepperHeaderElement } from './Stepper/StepperHeaderElement';
|
|
138
137
|
export { StepperNav } from './Stepper/StepperNav';
|
|
138
|
+
export { TabNav } from './Tab/TabNav';
|
|
139
|
+
export { TabNavItem } from './Tab/TabNavItem';
|
|
140
|
+
export { TabNavLink } from './Tab/TabNavLink';
|
|
139
141
|
export { ThumbNav } from './ThumbNav/ThumbNav';
|
|
140
142
|
export { ThumbNavItem } from './ThumbNav/ThumbNavItem';
|
|
141
143
|
export { TimelinePin } from './Timeline/TimelinePin';
|
|
@@ -242,6 +244,9 @@ export type { StepperDotsProps } from './Stepper/StepperDots';
|
|
|
242
244
|
export type { StepperHeaderProps } from './Stepper/StepperHeader';
|
|
243
245
|
export type { StepperHeaderElementProps } from './Stepper/StepperHeaderElement';
|
|
244
246
|
export type { StepperNavProps } from './Stepper/StepperNav';
|
|
247
|
+
export type { TabNavProps } from './Tab/TabNav';
|
|
248
|
+
export type { TabNavItemProps } from './Tab/TabNavItem';
|
|
249
|
+
export type { TabNavLinkProps } from './Tab/TabNavLink';
|
|
245
250
|
export type { ThumbNavProps } from './ThumbNav/ThumbNav';
|
|
246
251
|
export type { ThumbNavItemProps } from './ThumbNav/ThumbNavItem';
|
|
247
252
|
export type { TimelinePinProps } from './Timeline/TimelinePin';
|
|
@@ -290,8 +295,6 @@ export type {
|
|
|
290
295
|
PopoverHeaderProps,
|
|
291
296
|
PopoverProps,
|
|
292
297
|
RowProps,
|
|
293
|
-
TabContentProps,
|
|
294
|
-
TabPaneProps,
|
|
295
298
|
TableProps,
|
|
296
299
|
TooltipProps,
|
|
297
300
|
UncontrolledAlertProps,
|
|
@@ -299,4 +302,5 @@ export type {
|
|
|
299
302
|
UncontrolledTooltipProps
|
|
300
303
|
} from 'reactstrap';
|
|
301
304
|
|
|
302
|
-
|
|
305
|
+
export type { TabContainerProps, TabContentProps, TabPaneProps } from 'react-bootstrap';
|
|
306
|
+
import './track-focus.js';
|