@udixio/ui-react 2.10.13 → 2.10.14
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/package.json +4 -1
- package/.eslintrc.mjs +0 -22
- package/.storybook/main.ts +0 -20
- package/.storybook/preview.ts +0 -1
- package/CHANGELOG.md +0 -1144
- package/postcss.config.mjs +0 -5
- package/src/index.css +0 -4
- package/src/index.ts +0 -1
- package/src/lib/components/AnchorPositioner.tsx +0 -185
- package/src/lib/components/Button.tsx +0 -208
- package/src/lib/components/Card.tsx +0 -47
- package/src/lib/components/Carousel.tsx +0 -437
- package/src/lib/components/CarouselItem.tsx +0 -61
- package/src/lib/components/Checkbox.tsx +0 -120
- package/src/lib/components/Chip.tsx +0 -341
- package/src/lib/components/Chips.tsx +0 -331
- package/src/lib/components/ContextMenu.tsx +0 -109
- package/src/lib/components/DatePicker.tsx +0 -432
- package/src/lib/components/Divider.tsx +0 -20
- package/src/lib/components/Fab.tsx +0 -127
- package/src/lib/components/FabMenu.tsx +0 -239
- package/src/lib/components/IconButton.tsx +0 -146
- package/src/lib/components/Menu.tsx +0 -88
- package/src/lib/components/MenuGroup.tsx +0 -34
- package/src/lib/components/MenuHeadline.tsx +0 -9
- package/src/lib/components/MenuItem.tsx +0 -215
- package/src/lib/components/NavigationRail.tsx +0 -186
- package/src/lib/components/NavigationRailItem.tsx +0 -227
- package/src/lib/components/ProgressIndicator.tsx +0 -214
- package/src/lib/components/SideSheet.tsx +0 -135
- package/src/lib/components/Slider.tsx +0 -374
- package/src/lib/components/Snackbar.tsx +0 -77
- package/src/lib/components/Switch.tsx +0 -107
- package/src/lib/components/Tab.tsx +0 -123
- package/src/lib/components/TabGroup.tsx +0 -66
- package/src/lib/components/TabGroupContext.tsx +0 -16
- package/src/lib/components/TabPanel.tsx +0 -27
- package/src/lib/components/TabPanels.tsx +0 -76
- package/src/lib/components/Tabs.tsx +0 -105
- package/src/lib/components/TextField.tsx +0 -586
- package/src/lib/components/Tooltip.tsx +0 -217
- package/src/lib/components/index.ts +0 -34
- package/src/lib/config/config.interface.ts +0 -9
- package/src/lib/config/define-config.ts +0 -16
- package/src/lib/config/index.ts +0 -2
- package/src/lib/effects/AnimateOnScroll.ts +0 -391
- package/src/lib/effects/State.tsx +0 -90
- package/src/lib/effects/SyncedFixedWrapper.tsx +0 -62
- package/src/lib/effects/ThemeProvider.tsx +0 -174
- package/src/lib/effects/block-scroll.effect.tsx +0 -313
- package/src/lib/effects/custom-scroll/custom-scroll.effect.tsx +0 -407
- package/src/lib/effects/custom-scroll/custom-scroll.interface.ts +0 -29
- package/src/lib/effects/custom-scroll/custom-scroll.style.ts +0 -32
- package/src/lib/effects/custom-scroll/index.ts +0 -3
- package/src/lib/effects/index.ts +0 -7
- package/src/lib/effects/ripple/RippleEffect.tsx +0 -116
- package/src/lib/effects/ripple/index.tsx +0 -1
- package/src/lib/effects/scrollDriven.ts +0 -239
- package/src/lib/effects/smooth-scroll.effect.tsx +0 -112
- package/src/lib/effects/theme.worker.ts +0 -97
- package/src/lib/hooks/index.ts +0 -10
- package/src/lib/hooks/useTooltipTrigger.ts +0 -270
- package/src/lib/icon/icon.tsx +0 -125
- package/src/lib/icon/index.ts +0 -1
- package/src/lib/index.ts +0 -8
- package/src/lib/interfaces/button.interface.ts +0 -65
- package/src/lib/interfaces/card.interface.ts +0 -11
- package/src/lib/interfaces/carousel-item.interface.ts +0 -12
- package/src/lib/interfaces/carousel.interface.ts +0 -41
- package/src/lib/interfaces/checkbox.interface.ts +0 -39
- package/src/lib/interfaces/chip.interface.ts +0 -97
- package/src/lib/interfaces/chips.interface.ts +0 -37
- package/src/lib/interfaces/date-picker.interface.ts +0 -79
- package/src/lib/interfaces/divider.interface.ts +0 -7
- package/src/lib/interfaces/fab-menu.interface.ts +0 -12
- package/src/lib/interfaces/fab.interface.ts +0 -27
- package/src/lib/interfaces/icon-button.interface.ts +0 -38
- package/src/lib/interfaces/index.ts +0 -26
- package/src/lib/interfaces/menu-group.interface.ts +0 -13
- package/src/lib/interfaces/menu-item.interface.ts +0 -29
- package/src/lib/interfaces/menu.interface.ts +0 -19
- package/src/lib/interfaces/navigation-rail-item.interface.ts +0 -39
- package/src/lib/interfaces/navigation-rail.interface.ts +0 -39
- package/src/lib/interfaces/progress-indicator.interface.ts +0 -41
- package/src/lib/interfaces/side-sheet.interface.tsx +0 -28
- package/src/lib/interfaces/slider.interface.ts +0 -27
- package/src/lib/interfaces/snackbar.interface.ts +0 -13
- package/src/lib/interfaces/switch.interface.ts +0 -14
- package/src/lib/interfaces/tab-group.interface.ts +0 -13
- package/src/lib/interfaces/tab-panels.interface.ts +0 -21
- package/src/lib/interfaces/tab.interface.ts +0 -31
- package/src/lib/interfaces/tabs.interface.ts +0 -22
- package/src/lib/interfaces/text-field.interface.ts +0 -61
- package/src/lib/interfaces/tooltip.interface.ts +0 -61
- package/src/lib/styles/button.style.ts +0 -136
- package/src/lib/styles/card.style.ts +0 -29
- package/src/lib/styles/carousel-item.style.ts +0 -24
- package/src/lib/styles/carousel.style.ts +0 -22
- package/src/lib/styles/checkbox.style.ts +0 -64
- package/src/lib/styles/chip.style.ts +0 -62
- package/src/lib/styles/chips.style.ts +0 -20
- package/src/lib/styles/date-picker.style.ts +0 -43
- package/src/lib/styles/divider.style.ts +0 -31
- package/src/lib/styles/fab-menu.style.ts +0 -29
- package/src/lib/styles/fab.style.ts +0 -49
- package/src/lib/styles/icon-button.style.ts +0 -168
- package/src/lib/styles/index.ts +0 -25
- package/src/lib/styles/menu-group.style.ts +0 -34
- package/src/lib/styles/menu-headline.style.ts +0 -20
- package/src/lib/styles/menu-item.style.ts +0 -45
- package/src/lib/styles/menu.style.ts +0 -32
- package/src/lib/styles/navigation-rail-item.style.ts +0 -56
- package/src/lib/styles/navigation-rail.style.ts +0 -36
- package/src/lib/styles/progress-indicator.style.ts +0 -72
- package/src/lib/styles/side-sheet.style.ts +0 -45
- package/src/lib/styles/slider.style.ts +0 -41
- package/src/lib/styles/snackbar.style.ts +0 -26
- package/src/lib/styles/switch.style.ts +0 -67
- package/src/lib/styles/tab-panels.style.ts +0 -35
- package/src/lib/styles/tab.style.ts +0 -78
- package/src/lib/styles/tabs.style.ts +0 -22
- package/src/lib/styles/text-field.style.ts +0 -115
- package/src/lib/styles/tooltip.style.ts +0 -48
- package/src/lib/utils/component-helper.ts +0 -134
- package/src/lib/utils/component.ts +0 -34
- package/src/lib/utils/index.ts +0 -7
- package/src/lib/utils/string.ts +0 -9
- package/src/lib/utils/styles/classnames.ts +0 -49
- package/src/lib/utils/styles/get-classname.ts +0 -96
- package/src/lib/utils/styles/index.ts +0 -4
- package/src/lib/utils/styles/use-classnames.ts +0 -25
- package/src/stories/action/button.stories.tsx +0 -86
- package/src/stories/action/fab.stories.tsx +0 -54
- package/src/stories/action/icon-button.stories.tsx +0 -134
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -5
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +0 -15
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -3
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +0 -12
- package/src/stories/assets/youtube.svg +0 -4
- package/src/stories/communication/ProgressIndicator.stories.tsx +0 -57
- package/src/stories/communication/SnackBar.stories.tsx +0 -32
- package/src/stories/communication/tool-tip.stories.tsx +0 -133
- package/src/stories/containment/card.stories.tsx +0 -42
- package/src/stories/containment/carousel.stories.tsx +0 -65
- package/src/stories/containment/divider.stories.tsx +0 -35
- package/src/stories/containment/slide-sheet.stories.tsx +0 -45
- package/src/stories/effect/smooth-scroll.stories.tsx +0 -54
- package/src/stories/navigation/navigation-rail/navigation-rail-item.stories.tsx +0 -65
- package/src/stories/navigation/navigation-rail/navigation-rail.stories.tsx +0 -122
- package/src/stories/navigation/tabs/tab.stories.tsx +0 -57
- package/src/stories/navigation/tabs/tabs.stories.tsx +0 -102
- package/src/stories/selection/slider.stories.tsx +0 -85
- package/src/stories/selection/switch.stories.tsx +0 -46
- package/src/stories/text-inputs/text-field.stories.tsx +0 -135
- package/src/tests/Button.spec.tsx +0 -67
- package/src/tests/useClassNames.spec.tsx +0 -82
- package/src/udixio.css +0 -120
- package/theme.config.ts +0 -7
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -51
- package/tsconfig.spec.json +0 -37
- package/tsconfig.storybook.json +0 -38
- package/vite.config.ts +0 -96
package/postcss.config.mjs
DELETED
package/src/index.css
DELETED
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/index';
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
CSSProperties,
|
|
3
|
-
RefObject,
|
|
4
|
-
useId,
|
|
5
|
-
useLayoutEffect,
|
|
6
|
-
useState,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import { createPortal } from 'react-dom';
|
|
9
|
-
import { SyncedFixedWrapper } from '../effects';
|
|
10
|
-
import IntrinsicElements = React.JSX.IntrinsicElements;
|
|
11
|
-
|
|
12
|
-
export type PositionKeyword =
|
|
13
|
-
| 'left'
|
|
14
|
-
| 'center'
|
|
15
|
-
| 'right'
|
|
16
|
-
| 'span-left'
|
|
17
|
-
| 'span-right'
|
|
18
|
-
| 'x-start'
|
|
19
|
-
| 'x-end'
|
|
20
|
-
| 'span-x-start'
|
|
21
|
-
| 'span-x-end'
|
|
22
|
-
| 'self-x-start'
|
|
23
|
-
| 'self-x-end'
|
|
24
|
-
| 'span-self-x-start'
|
|
25
|
-
| 'span-self-x-end'
|
|
26
|
-
| 'top'
|
|
27
|
-
| 'bottom'
|
|
28
|
-
| 'span-top'
|
|
29
|
-
| 'span-bottom'
|
|
30
|
-
| 'y-start'
|
|
31
|
-
| 'y-end'
|
|
32
|
-
| 'span-y-start'
|
|
33
|
-
| 'span-y-end'
|
|
34
|
-
| 'self-y-start'
|
|
35
|
-
| 'self-y-end'
|
|
36
|
-
| 'span-self-y-start'
|
|
37
|
-
| 'span-self-y-end'
|
|
38
|
-
| 'block-start'
|
|
39
|
-
| 'block-end'
|
|
40
|
-
| 'span-block-start'
|
|
41
|
-
| 'span-block-end'
|
|
42
|
-
| 'inline-start'
|
|
43
|
-
| 'inline-end'
|
|
44
|
-
| 'span-inline-start'
|
|
45
|
-
| 'span-inline-end'
|
|
46
|
-
| 'self-block-start'
|
|
47
|
-
| 'self-block-end'
|
|
48
|
-
| 'span-self-block-start'
|
|
49
|
-
| 'span-self-block-end'
|
|
50
|
-
| 'self-inline-start'
|
|
51
|
-
| 'self-inline-end'
|
|
52
|
-
| 'span-self-inline-start'
|
|
53
|
-
| 'span-self-inline-end'
|
|
54
|
-
| 'start'
|
|
55
|
-
| 'end'
|
|
56
|
-
| 'span-start'
|
|
57
|
-
| 'span-end'
|
|
58
|
-
| 'self-start'
|
|
59
|
-
| 'self-end'
|
|
60
|
-
| 'span-self-start'
|
|
61
|
-
| 'span-self-end'
|
|
62
|
-
| 'span-all';
|
|
63
|
-
|
|
64
|
-
export type Position =
|
|
65
|
-
| PositionKeyword
|
|
66
|
-
| `${PositionKeyword} ${PositionKeyword}`
|
|
67
|
-
| 'top-left'
|
|
68
|
-
| 'top-right'
|
|
69
|
-
| 'bottom-left'
|
|
70
|
-
| 'bottom-right'
|
|
71
|
-
| 'right-start'
|
|
72
|
-
| 'right-end'
|
|
73
|
-
| 'left-start'
|
|
74
|
-
| 'left-end';
|
|
75
|
-
|
|
76
|
-
export interface AnchorPositionerProps {
|
|
77
|
-
anchorRef: RefObject<HTMLElement | null>;
|
|
78
|
-
position?: Position;
|
|
79
|
-
children: React.ReactNode;
|
|
80
|
-
style?: CSSProperties;
|
|
81
|
-
className?: string; // Optional if we want to wrap in a class
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const AnchorPositioner = ({
|
|
85
|
-
anchorRef,
|
|
86
|
-
position = 'bottom',
|
|
87
|
-
children,
|
|
88
|
-
style,
|
|
89
|
-
...restProps
|
|
90
|
-
}: AnchorPositionerProps & IntrinsicElements['div']) => {
|
|
91
|
-
const uniqueId = useId();
|
|
92
|
-
const anchorName = `--anchor-${uniqueId.replace(/:/g, '')}`;
|
|
93
|
-
const [supportsAnchor, setSupportsAnchor] = useState(false);
|
|
94
|
-
|
|
95
|
-
useLayoutEffect(() => {
|
|
96
|
-
if (typeof CSS !== 'undefined' && CSS.supports('anchor-name', '--a')) {
|
|
97
|
-
setSupportsAnchor(true);
|
|
98
|
-
}
|
|
99
|
-
}, []);
|
|
100
|
-
|
|
101
|
-
useLayoutEffect(() => {
|
|
102
|
-
if (supportsAnchor && anchorRef.current) {
|
|
103
|
-
const el = anchorRef.current;
|
|
104
|
-
// Apply anchor name to the reference element
|
|
105
|
-
(el.style as any).anchorName = anchorName;
|
|
106
|
-
return () => {
|
|
107
|
-
if (anchorRef.current) {
|
|
108
|
-
(anchorRef.current.style as any).anchorName = '';
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}, [supportsAnchor, anchorRef, anchorName]);
|
|
113
|
-
|
|
114
|
-
if (supportsAnchor) {
|
|
115
|
-
const floatingStyles: CSSProperties = {
|
|
116
|
-
position: 'fixed',
|
|
117
|
-
margin: 0,
|
|
118
|
-
zIndex: 9999,
|
|
119
|
-
positionAnchor: anchorName,
|
|
120
|
-
positionArea: position,
|
|
121
|
-
positionTryFallbacks: 'flip-block, flip-inline', // Correct CSS prop
|
|
122
|
-
...style,
|
|
123
|
-
} as any;
|
|
124
|
-
|
|
125
|
-
return createPortal(
|
|
126
|
-
<div style={floatingStyles} {...restProps}>
|
|
127
|
-
{children}
|
|
128
|
-
</div>,
|
|
129
|
-
document.body,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const fallbackStyles: CSSProperties = {
|
|
134
|
-
position: 'absolute',
|
|
135
|
-
pointerEvents: 'auto',
|
|
136
|
-
...style,
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
switch (position) {
|
|
140
|
-
case 'top':
|
|
141
|
-
fallbackStyles.bottom = '100%';
|
|
142
|
-
fallbackStyles.left = '50%';
|
|
143
|
-
fallbackStyles.transform = 'translateX(-50%)';
|
|
144
|
-
break;
|
|
145
|
-
case 'top-left':
|
|
146
|
-
fallbackStyles.bottom = '100%';
|
|
147
|
-
fallbackStyles.left = 0;
|
|
148
|
-
break;
|
|
149
|
-
case 'top-right':
|
|
150
|
-
fallbackStyles.bottom = '100%';
|
|
151
|
-
fallbackStyles.right = 0;
|
|
152
|
-
break;
|
|
153
|
-
case 'bottom':
|
|
154
|
-
fallbackStyles.top = '100%';
|
|
155
|
-
fallbackStyles.left = '50%';
|
|
156
|
-
fallbackStyles.transform = 'translateX(-50%)';
|
|
157
|
-
break;
|
|
158
|
-
case 'bottom-left':
|
|
159
|
-
fallbackStyles.top = '100%';
|
|
160
|
-
fallbackStyles.left = 0;
|
|
161
|
-
break;
|
|
162
|
-
case 'bottom-right':
|
|
163
|
-
fallbackStyles.top = '100%';
|
|
164
|
-
fallbackStyles.right = 0;
|
|
165
|
-
break;
|
|
166
|
-
case 'left':
|
|
167
|
-
fallbackStyles.right = '100%';
|
|
168
|
-
fallbackStyles.top = '50%';
|
|
169
|
-
fallbackStyles.transform = 'translateY(-50%)';
|
|
170
|
-
break;
|
|
171
|
-
case 'right':
|
|
172
|
-
fallbackStyles.left = '100%';
|
|
173
|
-
fallbackStyles.top = '50%';
|
|
174
|
-
fallbackStyles.transform = 'translateY(-50%)';
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return (
|
|
179
|
-
<SyncedFixedWrapper targetRef={anchorRef}>
|
|
180
|
-
<div style={fallbackStyles} {...restProps}>
|
|
181
|
-
{children}
|
|
182
|
-
</div>
|
|
183
|
-
</SyncedFixedWrapper>
|
|
184
|
-
);
|
|
185
|
-
};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { classNames, ReactProps } from '../utils';
|
|
3
|
-
import { ButtonInterface } from '../interfaces';
|
|
4
|
-
import { useButtonStyle } from '../styles';
|
|
5
|
-
import { Icon } from '../icon';
|
|
6
|
-
import { ProgressIndicator } from './ProgressIndicator';
|
|
7
|
-
import { State } from '../effects';
|
|
8
|
-
import React, { useEffect, useRef } from 'react';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Resolves variant aliases to their actual variant values
|
|
12
|
-
*/
|
|
13
|
-
function resolveVariantAlias(
|
|
14
|
-
variant?:
|
|
15
|
-
| 'filled'
|
|
16
|
-
| 'elevated'
|
|
17
|
-
| 'tonal'
|
|
18
|
-
| 'outlined'
|
|
19
|
-
| 'text'
|
|
20
|
-
| 'primary'
|
|
21
|
-
| 'secondary',
|
|
22
|
-
): 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text' {
|
|
23
|
-
const aliasMap = {
|
|
24
|
-
primary: 'filled',
|
|
25
|
-
secondary: 'tonal',
|
|
26
|
-
} as const;
|
|
27
|
-
|
|
28
|
-
if (variant && variant in aliasMap) {
|
|
29
|
-
return aliasMap[variant as keyof typeof aliasMap];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
(variant as 'filled' | 'elevated' | 'tonal' | 'outlined' | 'text') ||
|
|
34
|
-
'filled'
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Buttons prompt most actions in a UI
|
|
40
|
-
* @status beta
|
|
41
|
-
* @category Action
|
|
42
|
-
* @devx
|
|
43
|
-
* - Requires `label` or children; used for visible text and a11y.
|
|
44
|
-
* - `onToggle` uses internal state; pair with `activated` for controlled usage.
|
|
45
|
-
* @limitations
|
|
46
|
-
* - No explicit `type` prop; HTML button defaults may submit in forms.
|
|
47
|
-
* - When `href` is set, `disabled` is visual only (no `aria-disabled`).
|
|
48
|
-
*/
|
|
49
|
-
export const Button = ({
|
|
50
|
-
variant = 'filled',
|
|
51
|
-
disabled = false,
|
|
52
|
-
icon,
|
|
53
|
-
href,
|
|
54
|
-
label,
|
|
55
|
-
disableTextMargins,
|
|
56
|
-
className,
|
|
57
|
-
iconPosition = 'left',
|
|
58
|
-
loading = false,
|
|
59
|
-
shape = 'rounded',
|
|
60
|
-
onClick,
|
|
61
|
-
onToggle,
|
|
62
|
-
activated,
|
|
63
|
-
ref,
|
|
64
|
-
size = 'medium',
|
|
65
|
-
allowShapeTransformation = true,
|
|
66
|
-
transition,
|
|
67
|
-
children,
|
|
68
|
-
...restProps
|
|
69
|
-
}: ReactProps<ButtonInterface>) => {
|
|
70
|
-
if (children) label = children;
|
|
71
|
-
if (!label) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
'Button component requires either a label prop or children content',
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
variant = resolveVariantAlias(variant);
|
|
77
|
-
|
|
78
|
-
const ElementType = href ? 'a' : 'button';
|
|
79
|
-
|
|
80
|
-
const defaultRef = useRef<HTMLDivElement>(null);
|
|
81
|
-
const resolvedRef = ref || defaultRef;
|
|
82
|
-
|
|
83
|
-
const [isActive, setIsActive] = React.useState(activated);
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
setIsActive(activated);
|
|
86
|
-
}, [activated]);
|
|
87
|
-
|
|
88
|
-
transition = { duration: 0.3, ...transition };
|
|
89
|
-
|
|
90
|
-
const handleClick = (e: React.MouseEvent<any, MouseEvent>) => {
|
|
91
|
-
if (disabled) {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
}
|
|
94
|
-
if (onToggle) {
|
|
95
|
-
setIsActive(!isActive);
|
|
96
|
-
onToggle(!isActive);
|
|
97
|
-
} else if (onClick) {
|
|
98
|
-
onClick(e);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const styles = useButtonStyle({
|
|
103
|
-
allowShapeTransformation,
|
|
104
|
-
size,
|
|
105
|
-
disableTextMargins,
|
|
106
|
-
shape,
|
|
107
|
-
href,
|
|
108
|
-
disabled,
|
|
109
|
-
icon,
|
|
110
|
-
iconPosition,
|
|
111
|
-
loading,
|
|
112
|
-
variant,
|
|
113
|
-
transition,
|
|
114
|
-
className,
|
|
115
|
-
isActive: isActive ?? false,
|
|
116
|
-
onToggle,
|
|
117
|
-
activated: isActive,
|
|
118
|
-
label,
|
|
119
|
-
children: label,
|
|
120
|
-
});
|
|
121
|
-
const iconElement = icon ? (
|
|
122
|
-
<Icon icon={icon} className={styles.icon} />
|
|
123
|
-
) : (
|
|
124
|
-
<></>
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<ElementType
|
|
129
|
-
ref={resolvedRef}
|
|
130
|
-
href={href}
|
|
131
|
-
className={styles.button}
|
|
132
|
-
{...(restProps as any)}
|
|
133
|
-
onClick={handleClick}
|
|
134
|
-
disabled={disabled}
|
|
135
|
-
aria-pressed={onToggle ? isActive : undefined}
|
|
136
|
-
style={{ transition: transition.duration + 's' }}
|
|
137
|
-
>
|
|
138
|
-
<div className={styles.touchTarget}></div>
|
|
139
|
-
<State
|
|
140
|
-
style={{ transition: transition.duration + 's' }}
|
|
141
|
-
className={styles.stateLayer}
|
|
142
|
-
colorName={classNames(
|
|
143
|
-
variant === 'filled' && {
|
|
144
|
-
'on-surface-variant': !isActive && Boolean(onToggle),
|
|
145
|
-
'on-primary': isActive || !onToggle,
|
|
146
|
-
},
|
|
147
|
-
variant === 'elevated' && {
|
|
148
|
-
'on-primary': isActive && Boolean(onToggle),
|
|
149
|
-
primary: !isActive || !onToggle,
|
|
150
|
-
},
|
|
151
|
-
variant === 'tonal' && {
|
|
152
|
-
'on-secondary': isActive && Boolean(onToggle),
|
|
153
|
-
'on-secondary-container': !isActive || !onToggle,
|
|
154
|
-
},
|
|
155
|
-
variant === 'outlined' && {
|
|
156
|
-
'inverse-on-surface': isActive && Boolean(onToggle),
|
|
157
|
-
'on-surface-variant': !isActive || !onToggle,
|
|
158
|
-
},
|
|
159
|
-
variant === 'text' && 'primary',
|
|
160
|
-
)}
|
|
161
|
-
stateClassName={'state-ripple-group-[button]'}
|
|
162
|
-
/>
|
|
163
|
-
|
|
164
|
-
{iconPosition === 'left' && iconElement}
|
|
165
|
-
{loading && (
|
|
166
|
-
<div
|
|
167
|
-
className={
|
|
168
|
-
'!absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2'
|
|
169
|
-
}
|
|
170
|
-
>
|
|
171
|
-
<ProgressIndicator
|
|
172
|
-
className={() => ({
|
|
173
|
-
progressIndicator: 'h-6 w-6',
|
|
174
|
-
activeIndicator: classNames(
|
|
175
|
-
{
|
|
176
|
-
'!stroke-primary': variant === 'elevated' && !disabled,
|
|
177
|
-
'!stroke-on-surface/[38%]':
|
|
178
|
-
variant === 'elevated' && disabled,
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
'!stroke-on-primary': variant === 'filled' && !disabled,
|
|
182
|
-
'!stroke-on-surface/[38%]': variant === 'filled' && disabled,
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
'!stroke-on-secondary-container':
|
|
186
|
-
variant === 'tonal' && !disabled,
|
|
187
|
-
'!stroke-on-surface/[38%]': variant === 'tonal' && disabled,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
'!stroke-primary': variant === 'outlined' && !disabled,
|
|
191
|
-
'!stroke-on-surface/[38%]':
|
|
192
|
-
variant === 'outlined' && disabled,
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
'!stroke-primary': variant === 'text' && !disabled,
|
|
196
|
-
'!stroke-on-surface/[38%]': variant === 'text' && disabled,
|
|
197
|
-
},
|
|
198
|
-
),
|
|
199
|
-
})}
|
|
200
|
-
variant={'circular-indeterminate'}
|
|
201
|
-
/>
|
|
202
|
-
</div>
|
|
203
|
-
)}
|
|
204
|
-
<span className={styles.label}>{label}</span>
|
|
205
|
-
{iconPosition === 'right' && iconElement}
|
|
206
|
-
</ElementType>
|
|
207
|
-
);
|
|
208
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
import { CardInterface } from '../interfaces';
|
|
3
|
-
import { useCardStyle } from '../styles';
|
|
4
|
-
import { ReactProps } from '../utils';
|
|
5
|
-
import { State } from '../effects';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Cards display content and actions about a single subject
|
|
9
|
-
* @status beta
|
|
10
|
-
* @category Layout
|
|
11
|
-
* @devx
|
|
12
|
-
* - `interactive` only adds a state layer; add your own click/role semantics.
|
|
13
|
-
* @limitations
|
|
14
|
-
* - No built-in header/actions slots; layout is fully custom via children.
|
|
15
|
-
*/
|
|
16
|
-
export const Card = ({
|
|
17
|
-
variant = 'outlined',
|
|
18
|
-
className,
|
|
19
|
-
children,
|
|
20
|
-
interactive = false,
|
|
21
|
-
ref,
|
|
22
|
-
...rest
|
|
23
|
-
}: ReactProps<CardInterface>) => {
|
|
24
|
-
const styles = useCardStyle({
|
|
25
|
-
className,
|
|
26
|
-
interactive,
|
|
27
|
-
variant,
|
|
28
|
-
children,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const defaultRef = useRef<HTMLDivElement>(null);
|
|
32
|
-
const resolvedRef = ref || defaultRef;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div {...rest} ref={resolvedRef} className={styles.card}>
|
|
36
|
-
{interactive && (
|
|
37
|
-
<State
|
|
38
|
-
className={styles.stateLayer}
|
|
39
|
-
colorName={'on-surface'}
|
|
40
|
-
stateClassName={'state-ripple-group-[card]'}
|
|
41
|
-
/>
|
|
42
|
-
)}
|
|
43
|
-
|
|
44
|
-
{children}
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
};
|