@udixio/ui-react 2.6.0 → 2.8.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 +34 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +2300 -1971
- package/dist/lib/components/Button.d.ts.map +1 -1
- package/dist/lib/components/Card.d.ts.map +1 -1
- package/dist/lib/components/Fab.d.ts +1 -1
- package/dist/lib/components/Fab.d.ts.map +1 -1
- package/dist/lib/components/FabMenu.d.ts +9 -0
- package/dist/lib/components/FabMenu.d.ts.map +1 -0
- package/dist/lib/components/IconButton.d.ts.map +1 -1
- package/dist/lib/components/NavigationRail.d.ts.map +1 -1
- package/dist/lib/components/NavigationRailItem.d.ts.map +1 -1
- package/dist/lib/components/Tab.d.ts.map +1 -1
- package/dist/lib/components/ToolTip.d.ts.map +1 -1
- package/dist/lib/components/index.d.ts +1 -0
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/effects/State.d.ts +26 -0
- package/dist/lib/effects/State.d.ts.map +1 -0
- package/dist/lib/effects/index.d.ts +1 -0
- package/dist/lib/effects/index.d.ts.map +1 -1
- package/dist/lib/effects/ripple/RippleEffect.d.ts.map +1 -1
- package/dist/lib/interfaces/button.interface.d.ts +4 -1
- package/dist/lib/interfaces/button.interface.d.ts.map +1 -1
- package/dist/lib/interfaces/fab-menu.interface.d.ts +12 -0
- package/dist/lib/interfaces/fab-menu.interface.d.ts.map +1 -0
- package/dist/lib/interfaces/fab.interface.d.ts +2 -2
- package/dist/lib/interfaces/fab.interface.d.ts.map +1 -1
- package/dist/lib/interfaces/index.d.ts +1 -0
- package/dist/lib/interfaces/index.d.ts.map +1 -1
- package/dist/lib/interfaces/side-sheet.interface.d.ts +1 -1
- package/dist/lib/interfaces/side-sheet.interface.d.ts.map +1 -1
- package/dist/lib/styles/button.style.d.ts +43 -3
- package/dist/lib/styles/button.style.d.ts.map +1 -1
- package/dist/lib/styles/card.style.d.ts +9 -1
- package/dist/lib/styles/card.style.d.ts.map +1 -1
- package/dist/lib/styles/carousel-item.style.d.ts +11 -1
- package/dist/lib/styles/carousel-item.style.d.ts.map +1 -1
- package/dist/lib/styles/carousel.style.d.ts +16 -1
- package/dist/lib/styles/carousel.style.d.ts.map +1 -1
- package/dist/lib/styles/divider.style.d.ts +8 -2
- package/dist/lib/styles/divider.style.d.ts.map +1 -1
- package/dist/lib/styles/fab-menu.style.d.ts +83 -0
- package/dist/lib/styles/fab-menu.style.d.ts.map +1 -0
- package/dist/lib/styles/fab.style.d.ts +29 -5
- package/dist/lib/styles/fab.style.d.ts.map +1 -1
- package/dist/lib/styles/icon-button.style.d.ts +37 -1
- package/dist/lib/styles/icon-button.style.d.ts.map +1 -1
- package/dist/lib/styles/index.d.ts +2 -0
- package/dist/lib/styles/index.d.ts.map +1 -1
- package/dist/lib/styles/navigation-rail-item.style.d.ts +11 -1
- package/dist/lib/styles/navigation-rail-item.style.d.ts.map +1 -1
- package/dist/lib/styles/navigation-rail.style.d.ts +31 -1
- package/dist/lib/styles/navigation-rail.style.d.ts.map +1 -1
- package/dist/lib/styles/progress-indicator.style.d.ts +12 -1
- package/dist/lib/styles/progress-indicator.style.d.ts.map +1 -1
- package/dist/lib/styles/side-sheet.style.d.ts +20 -3
- package/dist/lib/styles/side-sheet.style.d.ts.map +1 -1
- package/dist/lib/styles/slider.style.d.ts +21 -2
- package/dist/lib/styles/slider.style.d.ts.map +1 -1
- package/dist/lib/styles/snackbar.style.d.ts +14 -3
- package/dist/lib/styles/snackbar.style.d.ts.map +1 -1
- package/dist/lib/styles/switch.style.d.ts +14 -2
- package/dist/lib/styles/switch.style.d.ts.map +1 -1
- package/dist/lib/styles/tab.style.d.ts +12 -2
- package/dist/lib/styles/tab.style.d.ts.map +1 -1
- package/dist/lib/styles/tabs.style.d.ts +17 -2
- package/dist/lib/styles/tabs.style.d.ts.map +1 -1
- package/dist/lib/styles/text-field.style.d.ts +23 -2
- package/dist/lib/styles/text-field.style.d.ts.map +1 -1
- package/dist/lib/styles/tooltip.style.d.ts +20 -3
- package/dist/lib/styles/tooltip.style.d.ts.map +1 -1
- package/dist/lib/utils/styles/get-classname.d.ts +3 -0
- package/dist/lib/utils/styles/get-classname.d.ts.map +1 -1
- package/dist/lib/utils/styles/index.d.ts +1 -0
- package/dist/lib/utils/styles/index.d.ts.map +1 -1
- package/dist/lib/utils/styles/use-classnames.d.ts +6 -0
- package/dist/lib/utils/styles/use-classnames.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/lib/components/Button.tsx +54 -20
- package/src/lib/components/Card.tsx +11 -9
- package/src/lib/components/Carousel.tsx +2 -2
- package/src/lib/components/CarouselItem.tsx +2 -2
- package/src/lib/components/Divider.tsx +2 -2
- package/src/lib/components/Fab.tsx +22 -21
- package/src/lib/components/FabMenu.tsx +229 -0
- package/src/lib/components/IconButton.tsx +24 -30
- package/src/lib/components/NavigationRail.tsx +7 -4
- package/src/lib/components/NavigationRailItem.tsx +13 -4
- package/src/lib/components/ProgressIndicator.tsx +2 -2
- package/src/lib/components/SideSheet.tsx +2 -2
- package/src/lib/components/Slider.tsx +2 -2
- package/src/lib/components/Snackbar.tsx +2 -2
- package/src/lib/components/Switch.tsx +2 -2
- package/src/lib/components/Tab.tsx +11 -11
- package/src/lib/components/Tabs.tsx +2 -2
- package/src/lib/components/TextField.tsx +2 -2
- package/src/lib/components/ToolTip.tsx +9 -3
- package/src/lib/components/index.ts +1 -0
- package/src/lib/effects/State.tsx +83 -0
- package/src/lib/effects/index.ts +1 -0
- package/src/lib/effects/ripple/RippleEffect.tsx +40 -27
- package/src/lib/interfaces/button.interface.ts +5 -1
- package/src/lib/interfaces/fab-menu.interface.ts +12 -0
- package/src/lib/interfaces/fab.interface.ts +8 -2
- package/src/lib/interfaces/index.ts +1 -0
- package/src/lib/interfaces/side-sheet.interface.tsx +1 -1
- package/src/lib/styles/button.style.ts +127 -136
- package/src/lib/styles/card.style.ts +22 -17
- package/src/lib/styles/carousel-item.style.ts +23 -9
- package/src/lib/styles/carousel.style.ts +17 -5
- package/src/lib/styles/divider.style.ts +27 -13
- package/src/lib/styles/fab-menu.style.ts +28 -0
- package/src/lib/styles/fab.style.ts +45 -43
- package/src/lib/styles/icon-button.style.ts +160 -149
- package/src/lib/styles/index.ts +2 -0
- package/src/lib/styles/navigation-rail-item.style.ts +49 -40
- package/src/lib/styles/navigation-rail.style.ts +31 -15
- package/src/lib/styles/progress-indicator.style.ts +49 -36
- package/src/lib/styles/side-sheet.style.ts +41 -27
- package/src/lib/styles/slider.style.ts +37 -23
- package/src/lib/styles/snackbar.style.ts +22 -10
- package/src/lib/styles/switch.style.ts +61 -45
- package/src/lib/styles/tab.style.ts +76 -66
- package/src/lib/styles/tabs.style.ts +19 -10
- package/src/lib/styles/text-field.style.ts +108 -97
- package/src/lib/styles/tooltip.style.ts +42 -33
- package/src/lib/utils/styles/get-classname.ts +23 -0
- package/src/lib/utils/styles/index.ts +1 -0
- package/src/lib/utils/styles/use-classnames.ts +25 -0
- package/src/tests/useClassNames.spec.tsx +82 -0
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
import { classNames, ReactProps } from '../utils';
|
|
2
2
|
import { ButtonInterface } from '../interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { useButtonStyle } from '../styles';
|
|
4
4
|
import { Icon } from '../icon';
|
|
5
5
|
import { ProgressIndicator } from './ProgressIndicator';
|
|
6
|
-
import {
|
|
6
|
+
import { State } from '../effects';
|
|
7
7
|
import React, { useEffect, useRef } from 'react';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Resolves variant aliases to their actual variant values
|
|
11
|
+
*/
|
|
12
|
+
function resolveVariantAlias(
|
|
13
|
+
variant?:
|
|
14
|
+
| 'filled'
|
|
15
|
+
| 'elevated'
|
|
16
|
+
| 'tonal'
|
|
17
|
+
| 'outlined'
|
|
18
|
+
| 'text'
|
|
19
|
+
| 'primary'
|
|
20
|
+
| 'secondary',
|
|
21
|
+
): 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text' {
|
|
22
|
+
const aliasMap = {
|
|
23
|
+
primary: 'filled',
|
|
24
|
+
secondary: 'tonal',
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
if (variant && variant in aliasMap) {
|
|
28
|
+
return aliasMap[variant as keyof typeof aliasMap];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
(variant as 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text') ||
|
|
33
|
+
'filled'
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
9
37
|
/**
|
|
10
38
|
* Buttons prompt most actions in a UI
|
|
11
39
|
* @status beta
|
|
@@ -38,6 +66,7 @@ export const Button = ({
|
|
|
38
66
|
'Button component requires either a label prop or children content',
|
|
39
67
|
);
|
|
40
68
|
}
|
|
69
|
+
variant = resolveVariantAlias(variant);
|
|
41
70
|
|
|
42
71
|
const ElementType = href ? 'a' : 'button';
|
|
43
72
|
|
|
@@ -72,7 +101,7 @@ export const Button = ({
|
|
|
72
101
|
onToggle(next);
|
|
73
102
|
};
|
|
74
103
|
}
|
|
75
|
-
const styles =
|
|
104
|
+
const styles = useButtonStyle({
|
|
76
105
|
allowShapeTransformation,
|
|
77
106
|
size,
|
|
78
107
|
disableTextMargins,
|
|
@@ -109,25 +138,30 @@ export const Button = ({
|
|
|
109
138
|
style={{ transition: transition.duration + 's' }}
|
|
110
139
|
>
|
|
111
140
|
<div className={styles.touchTarget}></div>
|
|
112
|
-
<
|
|
113
|
-
className={styles.stateLayer}
|
|
141
|
+
<State
|
|
114
142
|
style={{ transition: transition.duration + 's' }}
|
|
115
|
-
|
|
116
|
-
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
className={styles.stateLayer}
|
|
144
|
+
colorName={classNames(
|
|
145
|
+
variant === 'filled' && {
|
|
146
|
+
'on-surface-variant': !isActive && Boolean(onToggle),
|
|
147
|
+
'on-primary': isActive || !onToggle,
|
|
148
|
+
},
|
|
149
|
+
variant === 'elevated' && {
|
|
150
|
+
'on-primary': isActive && Boolean(onToggle),
|
|
151
|
+
primary: !isActive || !onToggle,
|
|
152
|
+
},
|
|
153
|
+
variant === 'tonal' && {
|
|
154
|
+
'on-secondary': isActive && Boolean(onToggle),
|
|
155
|
+
'on-secondary-container': !isActive || !onToggle,
|
|
156
|
+
},
|
|
157
|
+
variant === 'outlined' && {
|
|
158
|
+
'inverse-on-surface': isActive && Boolean(onToggle),
|
|
159
|
+
'on-surface-variant': !isActive || !onToggle,
|
|
160
|
+
},
|
|
161
|
+
variant === 'text' && 'primary',
|
|
129
162
|
)}
|
|
130
|
-
|
|
163
|
+
stateClassName={'state-ripple-group-[button]'}
|
|
164
|
+
/>
|
|
131
165
|
|
|
132
166
|
{iconPosition === 'left' && iconElement}
|
|
133
167
|
{loading && (
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { RippleEffect } from '../effects/ripple';
|
|
4
2
|
import { CardInterface } from '../interfaces';
|
|
5
|
-
import {
|
|
3
|
+
import { useCardStyle } from '../styles';
|
|
6
4
|
import { ReactProps } from '../utils';
|
|
5
|
+
import { State } from '../effects';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Cards display content and actions about a single subject
|
|
@@ -18,18 +17,21 @@ export const Card = ({
|
|
|
18
17
|
ref,
|
|
19
18
|
...rest
|
|
20
19
|
}: ReactProps<CardInterface>) => {
|
|
21
|
-
const styles =
|
|
20
|
+
const styles = useCardStyle({ className, isInteractive, variant, children });
|
|
22
21
|
|
|
23
22
|
const defaultRef = useRef<HTMLDivElement>(null);
|
|
24
23
|
const resolvedRef = ref || defaultRef;
|
|
25
24
|
|
|
26
25
|
return (
|
|
27
26
|
<div {...rest} ref={resolvedRef} className={styles.card}>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
{isInteractive && (
|
|
28
|
+
<State
|
|
29
|
+
className={styles.stateLayer}
|
|
30
|
+
colorName={'on-surface'}
|
|
31
|
+
stateClassName={'state-ripple-group-[card]'}
|
|
32
|
+
/>
|
|
33
|
+
)}
|
|
34
|
+
|
|
33
35
|
{children}
|
|
34
36
|
</div>
|
|
35
37
|
);
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { animate } from 'motion/react';
|
|
3
3
|
import { CarouselInterface, CarouselItemInterface } from '../interfaces';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useCarouselStyle } from '../styles';
|
|
6
6
|
import { CustomScroll } from '../effects';
|
|
7
7
|
import { ReactProps } from '../utils';
|
|
8
8
|
import { CarouselItem, normalize } from './CarouselItem';
|
|
@@ -40,7 +40,7 @@ export const Carousel = ({
|
|
|
40
40
|
|
|
41
41
|
const [translateX, setTranslateX] = useState(0);
|
|
42
42
|
|
|
43
|
-
const styles =
|
|
43
|
+
const styles = useCarouselStyle({
|
|
44
44
|
index,
|
|
45
45
|
className,
|
|
46
46
|
children,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
2
|
import { CarouselItemInterface } from '../interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { useCarouselItemStyle } from '../styles';
|
|
4
4
|
import { MotionProps } from '../utils';
|
|
5
5
|
|
|
6
6
|
export const normalize = (
|
|
@@ -34,7 +34,7 @@ export const CarouselItem = ({
|
|
|
34
34
|
const defaultRef = useRef(null);
|
|
35
35
|
const ref: React.RefObject<null | HTMLDivElement> = optionalRef || defaultRef;
|
|
36
36
|
|
|
37
|
-
const styles =
|
|
37
|
+
const styles = useCarouselItemStyle({
|
|
38
38
|
className,
|
|
39
39
|
index,
|
|
40
40
|
width,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDividerStyle } from '../styles';
|
|
2
2
|
import { DividerInterface } from '../interfaces';
|
|
3
3
|
import { ReactProps } from '../utils';
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ export const Divider = ({
|
|
|
12
12
|
className,
|
|
13
13
|
...restProps
|
|
14
14
|
}: ReactProps<DividerInterface>) => {
|
|
15
|
-
const styles =
|
|
15
|
+
const styles = useDividerStyle({ orientation, className });
|
|
16
16
|
|
|
17
17
|
return <hr className={styles.divider} {...restProps} />;
|
|
18
18
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
2
|
import { Icon } from '../icon';
|
|
3
|
-
|
|
4
|
-
import { RippleEffect } from '../effects/ripple';
|
|
5
3
|
import { AnimatePresence, motion } from 'motion/react';
|
|
6
4
|
import { FabInterface } from '../interfaces/fab.interface';
|
|
7
|
-
import {
|
|
5
|
+
import { useFabStyle } from '../styles/fab.style';
|
|
8
6
|
import { classNames } from '../utils';
|
|
9
7
|
import { ReactProps } from '../utils/component';
|
|
10
8
|
import { ToolTip } from './ToolTip';
|
|
9
|
+
import { State } from '../effects';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Floating action buttons (FABs) help people take primary actions
|
|
@@ -22,7 +21,7 @@ export const Fab = ({
|
|
|
22
21
|
href,
|
|
23
22
|
type,
|
|
24
23
|
icon,
|
|
25
|
-
|
|
24
|
+
extended = false,
|
|
26
25
|
ref,
|
|
27
26
|
transition,
|
|
28
27
|
children,
|
|
@@ -36,10 +35,10 @@ export const Fab = ({
|
|
|
36
35
|
}
|
|
37
36
|
const ElementType = href ? 'a' : 'button';
|
|
38
37
|
|
|
39
|
-
const styles =
|
|
38
|
+
const styles = useFabStyle({
|
|
40
39
|
href,
|
|
41
40
|
icon,
|
|
42
|
-
|
|
41
|
+
extended,
|
|
43
42
|
label,
|
|
44
43
|
size,
|
|
45
44
|
variant,
|
|
@@ -84,28 +83,30 @@ export const Fab = ({
|
|
|
84
83
|
{...(restProps as any)}
|
|
85
84
|
ref={resolvedRef}
|
|
86
85
|
href={href}
|
|
87
|
-
aria-label={
|
|
86
|
+
aria-label={extended ? undefined : label}
|
|
88
87
|
className={styles.fab}
|
|
89
88
|
>
|
|
90
89
|
<ToolTip
|
|
91
|
-
trigger={
|
|
90
|
+
trigger={extended ? null : undefined}
|
|
92
91
|
text={label}
|
|
93
92
|
targetRef={resolvedRef}
|
|
94
93
|
/>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
<State
|
|
95
|
+
style={{ transition: transition.duration + 's' }}
|
|
96
|
+
className={styles.stateLayer}
|
|
97
|
+
colorName={classNames({
|
|
98
|
+
'on-primary': variant == 'primary',
|
|
99
|
+
'on-secondary': variant == 'secondary',
|
|
100
|
+
'on-tertiary': variant == 'tertiary',
|
|
101
|
+
'on-primary-container': variant == 'primaryContainer',
|
|
102
|
+
'on-secondary-container': variant == 'secondaryContainer',
|
|
103
|
+
'on-tertiary-container': variant == 'tertiaryContainer',
|
|
104
|
+
})}
|
|
105
|
+
stateClassName={'state-ripple-group-[fab]'}
|
|
106
|
+
/>
|
|
106
107
|
<Icon icon={icon} className={styles.icon} />
|
|
107
108
|
<AnimatePresence>
|
|
108
|
-
{
|
|
109
|
+
{extended && (
|
|
109
110
|
<motion.span
|
|
110
111
|
variants={labelVariants}
|
|
111
112
|
initial="hidden"
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { FabMenuInterface } from '../interfaces/fab-menu.interface';
|
|
3
|
+
import { useFabMenuStyle } from '../styles/fab-menu.style';
|
|
4
|
+
import { ReactProps } from '../utils/component';
|
|
5
|
+
import { Fab } from './Fab';
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
import { ButtonInterface } from '../interfaces';
|
|
8
|
+
import { classNames } from '../utils';
|
|
9
|
+
import { IconButton } from './IconButton';
|
|
10
|
+
import { faClose } from '@fortawesome/free-solid-svg-icons';
|
|
11
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Floating action buttons (FABs) help people take primary actions
|
|
15
|
+
* @status beta
|
|
16
|
+
* @category Action
|
|
17
|
+
*/
|
|
18
|
+
export const FabMenu = ({
|
|
19
|
+
className,
|
|
20
|
+
label,
|
|
21
|
+
variant = 'primary',
|
|
22
|
+
size = 'medium',
|
|
23
|
+
href,
|
|
24
|
+
icon,
|
|
25
|
+
extended = false,
|
|
26
|
+
ref,
|
|
27
|
+
transition,
|
|
28
|
+
children,
|
|
29
|
+
open: openProp,
|
|
30
|
+
defaultOpen = false,
|
|
31
|
+
onOpenChange,
|
|
32
|
+
...restProps
|
|
33
|
+
}: ReactProps<FabMenuInterface>) => {
|
|
34
|
+
transition = { duration: 0.3, ease: 'easeInOut', ...transition };
|
|
35
|
+
|
|
36
|
+
const defaultRef = useRef(null);
|
|
37
|
+
const resolvedRef = ref || defaultRef;
|
|
38
|
+
|
|
39
|
+
// Controlled/uncontrolled open state
|
|
40
|
+
const isControlled = typeof openProp === 'boolean';
|
|
41
|
+
const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);
|
|
42
|
+
const open = isControlled ? (openProp as boolean) : internalOpen;
|
|
43
|
+
const setOpen = (next: boolean) => {
|
|
44
|
+
if (!isControlled) setInternalOpen(next);
|
|
45
|
+
onOpenChange?.(next);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const buttonChildren = React.Children.toArray(children).filter(
|
|
49
|
+
(child) => React.isValidElement(child) && child.type === Button,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const styles = useFabMenuStyle({
|
|
53
|
+
href,
|
|
54
|
+
icon,
|
|
55
|
+
extended,
|
|
56
|
+
label,
|
|
57
|
+
size,
|
|
58
|
+
variant,
|
|
59
|
+
className,
|
|
60
|
+
transition,
|
|
61
|
+
children: label,
|
|
62
|
+
open,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const MotionFab = motion.create(Fab);
|
|
66
|
+
const MotionIconButton = motion.create(IconButton);
|
|
67
|
+
const MotionButton = motion.create(Button);
|
|
68
|
+
|
|
69
|
+
const renderFab = (props) => (
|
|
70
|
+
<MotionFab
|
|
71
|
+
icon={icon}
|
|
72
|
+
extended={extended}
|
|
73
|
+
label={label}
|
|
74
|
+
variant={(variant + 'Container') as any}
|
|
75
|
+
size={size}
|
|
76
|
+
className={styles.fab + ' ' + (className ?? '')}
|
|
77
|
+
aria-expanded={open}
|
|
78
|
+
onClick={() => setOpen(true)}
|
|
79
|
+
style={{ transition: 'border-radius 0.3s ease-in-out' }}
|
|
80
|
+
transition={{
|
|
81
|
+
duration: transition.duration,
|
|
82
|
+
ease: 'easeInOut',
|
|
83
|
+
borderRadius: { duration: transition.duration, ease: 'easeInOut' },
|
|
84
|
+
background: { duration: transition.duration, ease: 'easeInOut' },
|
|
85
|
+
...transition,
|
|
86
|
+
}}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div className={styles.fabMenu} ref={resolvedRef} {...restProps}>
|
|
93
|
+
<AnimatePresence>
|
|
94
|
+
{open && (
|
|
95
|
+
<div className={styles.actions} role="menu" aria-hidden={!open}>
|
|
96
|
+
{(() => {
|
|
97
|
+
const total = buttonChildren.length;
|
|
98
|
+
return buttonChildren.map((child, index) => {
|
|
99
|
+
const childProps = (
|
|
100
|
+
child as React.ReactElement<ReactProps<ButtonInterface>>
|
|
101
|
+
).props;
|
|
102
|
+
const reverseIndex = total - 1 - index; // inverser l'ordre d'animation
|
|
103
|
+
const delay = (transition?.delay ?? 0) + reverseIndex * 0.06; // délai échelonné inversé, un peu plus marqué
|
|
104
|
+
|
|
105
|
+
const variants = {
|
|
106
|
+
open: {
|
|
107
|
+
overflow: 'visible',
|
|
108
|
+
opacity: 1,
|
|
109
|
+
width: 'auto',
|
|
110
|
+
transition: {
|
|
111
|
+
...transition,
|
|
112
|
+
delay,
|
|
113
|
+
opacity: {
|
|
114
|
+
delay: transition?.duration / 2 + delay,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
close: {
|
|
119
|
+
overflow: 'hidden',
|
|
120
|
+
opacity: 0,
|
|
121
|
+
width: 0,
|
|
122
|
+
transition: {
|
|
123
|
+
...transition,
|
|
124
|
+
delay,
|
|
125
|
+
opacity: {
|
|
126
|
+
duration: transition?.duration / 1.5,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<motion.div
|
|
134
|
+
initial={'close'}
|
|
135
|
+
animate={'open'}
|
|
136
|
+
variants={variants}
|
|
137
|
+
transition={transition}
|
|
138
|
+
exit={'close'}
|
|
139
|
+
>
|
|
140
|
+
{React.cloneElement(
|
|
141
|
+
child as React.ReactElement<ReactProps<ButtonInterface>>,
|
|
142
|
+
{
|
|
143
|
+
key: index,
|
|
144
|
+
shape: 'rounded',
|
|
145
|
+
variant: 'filled',
|
|
146
|
+
className: () => ({
|
|
147
|
+
button: classNames('max-w-full overflow-hidden', {
|
|
148
|
+
'px-0': !open,
|
|
149
|
+
'bg-primary-container text-on-primary-container ':
|
|
150
|
+
variant === 'primary',
|
|
151
|
+
'bg-secondary-container text-on-secondary-container':
|
|
152
|
+
variant === 'secondary',
|
|
153
|
+
'bg-tertiary-container text-on-tertiary-container':
|
|
154
|
+
variant === 'tertiary',
|
|
155
|
+
}),
|
|
156
|
+
stateLayer: classNames({
|
|
157
|
+
'state-on-primary-container': variant === 'primary',
|
|
158
|
+
'state-on-secondary-container':
|
|
159
|
+
variant === 'secondary',
|
|
160
|
+
'state-on-tertiary-container':
|
|
161
|
+
variant === 'tertiary',
|
|
162
|
+
}),
|
|
163
|
+
}),
|
|
164
|
+
},
|
|
165
|
+
)}
|
|
166
|
+
</motion.div>
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
})()}
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</AnimatePresence>
|
|
173
|
+
|
|
174
|
+
{renderFab({
|
|
175
|
+
className: 'invisible pointer-events-none',
|
|
176
|
+
})}
|
|
177
|
+
<div className={'absolute right-0 top-0'}>
|
|
178
|
+
{!open &&
|
|
179
|
+
renderFab({
|
|
180
|
+
className: '',
|
|
181
|
+
layout: true,
|
|
182
|
+
layoutId: 'fab-menu',
|
|
183
|
+
})}
|
|
184
|
+
{open && (
|
|
185
|
+
<>
|
|
186
|
+
<MotionIconButton
|
|
187
|
+
layout
|
|
188
|
+
layoutId="fab-menu"
|
|
189
|
+
variant={'filled'}
|
|
190
|
+
className={() => ({
|
|
191
|
+
iconButton: classNames('', {
|
|
192
|
+
'bg-primary text-on-primary': variant === 'primary',
|
|
193
|
+
'bg-secondary text-on-secondary': variant === 'secondary',
|
|
194
|
+
'bg-tertiary text-on-tertiary': variant === 'tertiary',
|
|
195
|
+
}),
|
|
196
|
+
stateLayer: classNames({
|
|
197
|
+
'[--default-color:var(--color-on-primary)]':
|
|
198
|
+
variant === 'primary',
|
|
199
|
+
'[--default-color:var(--color-on-secondary)]':
|
|
200
|
+
variant === 'secondary',
|
|
201
|
+
'[--default-color:var(--color-on-tertiary)]':
|
|
202
|
+
variant === 'tertiary',
|
|
203
|
+
}),
|
|
204
|
+
})}
|
|
205
|
+
style={{ transition: 'border-radius 0.3s ease-in-out' }}
|
|
206
|
+
transition={{
|
|
207
|
+
duration: transition.duration,
|
|
208
|
+
ease: 'easeInOut',
|
|
209
|
+
borderRadius: {
|
|
210
|
+
duration: transition.duration,
|
|
211
|
+
ease: 'easeInOut',
|
|
212
|
+
},
|
|
213
|
+
background: {
|
|
214
|
+
duration: transition.duration,
|
|
215
|
+
ease: 'easeInOut',
|
|
216
|
+
},
|
|
217
|
+
...transition,
|
|
218
|
+
}}
|
|
219
|
+
icon={faClose}
|
|
220
|
+
onClick={() => setOpen(false)}
|
|
221
|
+
>
|
|
222
|
+
Close
|
|
223
|
+
</MotionIconButton>
|
|
224
|
+
</>
|
|
225
|
+
)}
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
);
|
|
229
|
+
};
|
|
@@ -2,9 +2,9 @@ import React, { useEffect, useRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Icon } from '../icon/icon';
|
|
4
4
|
import { IconButtonInterface } from '../interfaces/icon-button.interface';
|
|
5
|
-
import {
|
|
5
|
+
import { useIconButtonStyle } from '../styles/icon-button.style';
|
|
6
6
|
import { ReactProps } from '../utils/component';
|
|
7
|
-
import {
|
|
7
|
+
import { State } from '../effects';
|
|
8
8
|
import { classNames } from '../utils';
|
|
9
9
|
import { ToolTip } from './ToolTip';
|
|
10
10
|
|
|
@@ -76,7 +76,7 @@ export const IconButton = ({
|
|
|
76
76
|
// Détermine le type de l'élément à rendre : un bouton ou un lien
|
|
77
77
|
const ElementType = href ? 'a' : 'button';
|
|
78
78
|
|
|
79
|
-
const styles =
|
|
79
|
+
const styles = useIconButtonStyle({
|
|
80
80
|
transition,
|
|
81
81
|
shape,
|
|
82
82
|
allowShapeTransformation,
|
|
@@ -120,35 +120,29 @@ export const IconButton = ({
|
|
|
120
120
|
></ToolTip>
|
|
121
121
|
|
|
122
122
|
<div className={styles.touchTarget} />
|
|
123
|
-
<
|
|
124
|
-
className={styles.stateLayer}
|
|
123
|
+
<State
|
|
125
124
|
style={{ transition: transition.duration + 's' }}
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
'on-primary': isActive,
|
|
145
|
-
},
|
|
146
|
-
)}
|
|
147
|
-
triggerRef={resolvedRef}
|
|
148
|
-
/>
|
|
125
|
+
className={styles.stateLayer}
|
|
126
|
+
colorName={classNames(
|
|
127
|
+
variant === 'standard' && {
|
|
128
|
+
'on-surface-variant': !isActive,
|
|
129
|
+
'on-primary': isActive,
|
|
130
|
+
},
|
|
131
|
+
variant === 'filled' && {
|
|
132
|
+
'on-surface-variant': !isActive && Boolean(onToggle),
|
|
133
|
+
'on-primary': isActive || !onToggle,
|
|
134
|
+
},
|
|
135
|
+
variant === 'tonal' && {
|
|
136
|
+
'on-secondary': isActive && Boolean(onToggle),
|
|
137
|
+
'on-secondary-container': !isActive || !onToggle,
|
|
138
|
+
},
|
|
139
|
+
variant === 'outlined' && {
|
|
140
|
+
'inverse-on-surface': isActive && Boolean(onToggle),
|
|
141
|
+
'on-surface-variant': !isActive || !onToggle,
|
|
142
|
+
},
|
|
149
143
|
)}
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
stateClassName={'state-ripple-group-[icon-button]'}
|
|
145
|
+
/>
|
|
152
146
|
{icon && <Icon icon={icon} className={styles.icon} />}
|
|
153
147
|
</ElementType>
|
|
154
148
|
);
|
|
@@ -8,12 +8,15 @@ import {
|
|
|
8
8
|
RefObject,
|
|
9
9
|
useEffect,
|
|
10
10
|
useRef,
|
|
11
|
-
useState
|
|
11
|
+
useState,
|
|
12
12
|
} from 'react';
|
|
13
13
|
import { ReactProps } from '../utils';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
NavigationRailItem,
|
|
16
|
+
NavigationRailSection,
|
|
17
|
+
} from './NavigationRailItem';
|
|
15
18
|
import { Fab } from './Fab';
|
|
16
|
-
import {
|
|
19
|
+
import { useNavigationRailStyle } from '../styles/navigation-rail.style';
|
|
17
20
|
import { NavigationRailInterface } from '../interfaces/navigation-rail.interface';
|
|
18
21
|
import { FabInterface, NavigationRailItemInterface } from '../interfaces';
|
|
19
22
|
import { faBars, faXmark } from '@fortawesome/free-solid-svg-icons';
|
|
@@ -96,7 +99,7 @@ export const NavigationRail = ({
|
|
|
96
99
|
(child) => isValidElement(child) && child.type === Fab,
|
|
97
100
|
);
|
|
98
101
|
|
|
99
|
-
const styles =
|
|
102
|
+
const styles = useNavigationRailStyle({
|
|
100
103
|
children,
|
|
101
104
|
onItemSelected,
|
|
102
105
|
selectedItem,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Icon } from '../icon';
|
|
4
|
-
import { ReactProps } from '../utils';
|
|
4
|
+
import { classNames, ReactProps } from '../utils';
|
|
5
5
|
import { NavigationRailItemInterface } from '../interfaces';
|
|
6
|
-
import {
|
|
6
|
+
import { useNavigationRailItemStyle } from '../styles/navigation-rail-item.style';
|
|
7
7
|
import { AnimatePresence, motion } from 'motion/react';
|
|
8
|
+
import { State } from '../effects';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @status beta
|
|
@@ -80,7 +81,7 @@ export const NavigationRailItem = ({
|
|
|
80
81
|
}
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
const styles =
|
|
84
|
+
const styles = useNavigationRailItemStyle({
|
|
84
85
|
isExtended,
|
|
85
86
|
extendedOnly,
|
|
86
87
|
className,
|
|
@@ -128,7 +129,15 @@ export const NavigationRailItem = ({
|
|
|
128
129
|
transition={transition}
|
|
129
130
|
className={styles.container}
|
|
130
131
|
>
|
|
131
|
-
<
|
|
132
|
+
<State
|
|
133
|
+
style={{ transition: transition.duration + 's' }}
|
|
134
|
+
className={styles.stateLayer}
|
|
135
|
+
colorName={classNames({
|
|
136
|
+
'on-surface': !isSelected,
|
|
137
|
+
'on-secondary-container': isSelected,
|
|
138
|
+
})}
|
|
139
|
+
stateClassName={'state-ripple-group-[navigation-rail-item]'}
|
|
140
|
+
/>
|
|
132
141
|
{icon && (
|
|
133
142
|
<Icon
|
|
134
143
|
icon={isSelected ? iconSelected : icon}
|
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import { ProgressIndicatorInterface } from '../interfaces/progress-indicator.interface';
|
|
3
3
|
|
|
4
4
|
import { motion } from 'motion/react';
|
|
5
|
-
import {
|
|
5
|
+
import { useProgressIndicatorStyle } from '../styles/progress-indicator.style';
|
|
6
6
|
import { ReactProps } from '../utils/component';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -67,7 +67,7 @@ export const ProgressIndicator = ({
|
|
|
67
67
|
return;
|
|
68
68
|
}, [completedPercentage, transitionDuration]);
|
|
69
69
|
|
|
70
|
-
const styles =
|
|
70
|
+
const styles = useProgressIndicatorStyle({
|
|
71
71
|
className,
|
|
72
72
|
variant,
|
|
73
73
|
value,
|