addon-ui 0.9.2 → 0.11.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/README.md +54 -12
- package/dist-types/components/Popover/Popover.d.ts +6 -0
- package/dist-types/components/Popover/PopoverAnchor.d.ts +6 -0
- package/dist-types/components/Popover/PopoverClose.d.ts +6 -0
- package/dist-types/components/Popover/PopoverContent.d.ts +15 -0
- package/dist-types/components/Popover/PopoverTrigger.d.ts +8 -0
- package/dist-types/components/Popover/index.d.ts +6 -0
- package/dist-types/components/Select/Select.d.ts +1 -1
- package/dist-types/components/Select/SelectIcon.d.ts +1 -1
- package/dist-types/components/Select/SelectItemIndicator.d.ts +6 -0
- package/dist-types/components/Select/SelectItemText.d.ts +6 -0
- package/dist-types/components/Select/SelectValue.d.ts +1 -1
- package/dist-types/components/Select/index.d.ts +2 -0
- package/dist-types/components/Shift/Shift.d.ts +10 -0
- package/dist-types/components/Shift/index.d.ts +2 -0
- package/dist-types/components/TextField/TextField.d.ts +2 -1
- package/dist-types/components/TextField/utils.d.ts +8 -0
- package/dist-types/components/ToggleGroup/ToggleGroup.d.ts +7 -0
- package/dist-types/components/ToggleGroup/ToggleGroupIndicator.d.ts +4 -0
- package/dist-types/components/ToggleGroup/ToggleGroupItem.d.ts +6 -0
- package/dist-types/components/ToggleGroup/index.d.ts +4 -0
- package/dist-types/components/Truncate/Truncate.d.ts +2 -2
- package/dist-types/components/Truncate/utils.d.ts +2 -0
- package/dist-types/components/index.d.ts +3 -0
- package/dist-types/components/types.d.ts +8 -1
- package/dist-types/plugin/index.d.ts +28 -2
- package/dist-types/providers/theme/ThemeProvider.d.ts +88 -0
- package/dist-types/providers/ui/UIProvider.d.ts +22 -1
- package/package.json +10 -21
- package/src/components/Button/button.module.scss +0 -1
- package/src/components/Popover/Popover.tsx +15 -0
- package/src/components/Popover/PopoverAnchor.tsx +23 -0
- package/src/components/Popover/PopoverClose.tsx +23 -0
- package/src/components/Popover/PopoverContent.tsx +73 -0
- package/src/components/Popover/PopoverTrigger.tsx +35 -0
- package/src/components/Popover/index.ts +5 -0
- package/src/components/Popover/popover.module.scss +77 -0
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Select/SelectContent.tsx +4 -2
- package/src/components/Select/SelectIcon.tsx +1 -1
- package/src/components/Select/SelectItem.tsx +8 -9
- package/src/components/Select/SelectItemIndicator.tsx +17 -0
- package/src/components/Select/SelectItemText.tsx +17 -0
- package/src/components/Select/SelectValue.tsx +1 -1
- package/src/components/Select/index.ts +2 -0
- package/src/components/Select/select.module.scss +7 -1
- package/src/components/Shift/Shift.tsx +98 -0
- package/src/components/Shift/index.ts +1 -0
- package/src/components/Shift/shift.module.scss +21 -0
- package/src/components/TextArea/text-area.module.scss +5 -0
- package/src/components/TextField/TextField.tsx +66 -13
- package/src/components/TextField/text-field.module.scss +4 -2
- package/src/components/TextField/utils.ts +56 -0
- package/src/components/ToggleGroup/ToggleGroup.tsx +25 -0
- package/src/components/ToggleGroup/ToggleGroupIndicator.tsx +17 -0
- package/src/components/ToggleGroup/ToggleGroupItem.tsx +28 -0
- package/src/components/ToggleGroup/index.ts +8 -0
- package/src/components/ToggleGroup/toggleGroup.module.scss +32 -0
- package/src/components/Tooltip/tooltip.module.scss +1 -0
- package/src/components/Truncate/Truncate.tsx +38 -56
- package/src/components/Truncate/truncate.module.scss +14 -15
- package/src/components/Truncate/utils.ts +62 -0
- package/src/components/index.ts +3 -0
- package/src/components/types.ts +23 -9
- package/src/plugin/index.ts +223 -9
- package/src/providers/theme/ThemeProvider.tsx +121 -15
- package/src/providers/ui/UIProvider.tsx +42 -15
- package/src/providers/ui/styles/default.scss +5 -1
- package/src/providers/ui/styles/reset.scss +1 -0
- package/src/styles/mixins.scss +19 -6
- /package/src/providers/theme/{ThemeStorage.tsx → ThemeStorage.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {Anchor, PopoverAnchorProps} from "@radix-ui/react-popover";
|
|
6
|
+
|
|
7
|
+
import {useComponentProps} from "../../providers";
|
|
8
|
+
|
|
9
|
+
import styles from "./popover.module.scss";
|
|
10
|
+
|
|
11
|
+
export type {PopoverAnchorProps};
|
|
12
|
+
|
|
13
|
+
const PopoverAnchor: ForwardRefRenderFunction<HTMLDivElement, PopoverAnchorProps> = (props, ref) => {
|
|
14
|
+
const {className, children, ...other} = {...useComponentProps("popoverAnchor"), ...props};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Anchor ref={ref} className={classnames(styles["popover__anchor"], className)} {...other}>
|
|
18
|
+
{children}
|
|
19
|
+
</Anchor>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default memo(forwardRef(PopoverAnchor));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {Close, PopoverCloseProps} from "@radix-ui/react-popover";
|
|
6
|
+
|
|
7
|
+
import {useComponentProps} from "../../providers";
|
|
8
|
+
|
|
9
|
+
import styles from "./popover.module.scss";
|
|
10
|
+
|
|
11
|
+
export type {PopoverCloseProps};
|
|
12
|
+
|
|
13
|
+
const PopoverClose: ForwardRefRenderFunction<HTMLButtonElement, PopoverCloseProps> = (props, ref) => {
|
|
14
|
+
const {className, children, ...other} = {...useComponentProps("popoverClose"), ...props};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Close ref={ref} className={classnames(styles["popover__close"], className)} {...other}>
|
|
18
|
+
{children}
|
|
19
|
+
</Close>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default memo(forwardRef(PopoverClose));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Arrow,
|
|
7
|
+
Content,
|
|
8
|
+
PopoverContentProps as PopoverContentRadixProps,
|
|
9
|
+
PopoverPortalProps,
|
|
10
|
+
Portal,
|
|
11
|
+
} from "@radix-ui/react-popover";
|
|
12
|
+
|
|
13
|
+
import {useComponentProps} from "../../providers";
|
|
14
|
+
|
|
15
|
+
import styles from "./popover.module.scss";
|
|
16
|
+
|
|
17
|
+
export interface PopoverContentProps extends PopoverContentRadixProps, PopoverPortalProps {
|
|
18
|
+
maxWidth?: number;
|
|
19
|
+
minWidth?: number;
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
arrow?: boolean;
|
|
22
|
+
arrowWidth?: number;
|
|
23
|
+
arrowHeight?: number;
|
|
24
|
+
overlay?: boolean;
|
|
25
|
+
overlayClassname?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const PopoverContent: ForwardRefRenderFunction<HTMLDivElement, PopoverContentProps> = (props, ref) => {
|
|
29
|
+
const {
|
|
30
|
+
maxWidth,
|
|
31
|
+
minWidth,
|
|
32
|
+
arrow,
|
|
33
|
+
arrowWidth,
|
|
34
|
+
arrowHeight,
|
|
35
|
+
fullWidth,
|
|
36
|
+
overlay,
|
|
37
|
+
overlayClassname,
|
|
38
|
+
container,
|
|
39
|
+
className,
|
|
40
|
+
style,
|
|
41
|
+
children,
|
|
42
|
+
...other
|
|
43
|
+
} = {...useComponentProps("popoverContent"), ...props};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Portal container={container}>
|
|
47
|
+
<>
|
|
48
|
+
{overlay && <div className={classnames(styles["popover__overlay"], overlayClassname)} />}
|
|
49
|
+
<Content
|
|
50
|
+
ref={ref}
|
|
51
|
+
className={classnames(
|
|
52
|
+
styles["popover__content"],
|
|
53
|
+
{
|
|
54
|
+
[styles["popover__content--full-width"]]: fullWidth,
|
|
55
|
+
},
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
{...other}
|
|
59
|
+
style={{
|
|
60
|
+
minWidth: minWidth ? minWidth : undefined,
|
|
61
|
+
maxWidth: maxWidth ? maxWidth : undefined,
|
|
62
|
+
...style,
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
{arrow && <Arrow className={styles["popover__arrow"]} width={arrowWidth} height={arrowHeight} />}
|
|
67
|
+
</Content>
|
|
68
|
+
</>
|
|
69
|
+
</Portal>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default memo(forwardRef(PopoverContent));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {PopoverTriggerProps as PopoverTriggerRadixProps, Trigger} from "@radix-ui/react-popover";
|
|
6
|
+
|
|
7
|
+
import {useComponentProps} from "../../providers";
|
|
8
|
+
|
|
9
|
+
import styles from "./popover.module.scss";
|
|
10
|
+
|
|
11
|
+
export interface PopoverTriggerProps extends PopoverTriggerRadixProps {
|
|
12
|
+
center?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const PopoverTrigger: ForwardRefRenderFunction<HTMLButtonElement, PopoverTriggerProps> = (props, ref) => {
|
|
16
|
+
const {center, className, children, ...other} = {...useComponentProps("popoverTrigger"), ...props};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Trigger
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={classnames(
|
|
22
|
+
styles["popover__trigger"],
|
|
23
|
+
{
|
|
24
|
+
[styles["popover__trigger--center"]]: center,
|
|
25
|
+
},
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
28
|
+
{...other}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</Trigger>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default memo(forwardRef(PopoverTrigger));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export {default as Popover, type PopoverProps} from "./Popover";
|
|
2
|
+
export {default as PopoverClose, type PopoverCloseProps} from "./PopoverClose";
|
|
3
|
+
export {default as PopoverAnchor, type PopoverAnchorProps} from "./PopoverAnchor";
|
|
4
|
+
export {default as PopoverTrigger, type PopoverTriggerProps} from "./PopoverTrigger";
|
|
5
|
+
export {default as PopoverContent, type PopoverContentProps} from "./PopoverContent";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
$root: popover;
|
|
2
|
+
|
|
3
|
+
.#{$root} {
|
|
4
|
+
&__overlay {
|
|
5
|
+
width: 100vw;
|
|
6
|
+
height: 100vh;
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
background: var(--popover-overlay-bg, var(--overlay-bg, rgba(0, 0, 0, 0.5)));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__anchor {
|
|
14
|
+
height: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&__trigger {
|
|
18
|
+
all: unset;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
color: var(--popover-trigger-color);
|
|
25
|
+
background: var(--popover-trigger-bg-color, var(--bg-secondary-color));
|
|
26
|
+
box-shadow: var(--popover-trigger-shadow-offset) var(--popover-trigger-shadow-color);
|
|
27
|
+
|
|
28
|
+
border-width: var(--popover-trigger-border-width, 1px);
|
|
29
|
+
border-style: var(--popover-trigger-border-style, solid);
|
|
30
|
+
border-color: var(--popover-trigger-border-color, var(--border-color));
|
|
31
|
+
border-radius: var(--popover-trigger-border-radius, 10px);
|
|
32
|
+
|
|
33
|
+
font-size: var(--popover-trigger-font-size, var(--popover-font-size, 14px));
|
|
34
|
+
font-weight: var(--popover-trigger-font-weight, 500);
|
|
35
|
+
padding: var(--popover-trigger-padding, 8px 12px);
|
|
36
|
+
height: var(--popover-trigger-height);
|
|
37
|
+
gap: var(--popover-trigger-gap, 5px);
|
|
38
|
+
transition:
|
|
39
|
+
color var(--popover-speed-color, var(--speed-color)),
|
|
40
|
+
background var(--popover-speed-background, var(--speed-color)),
|
|
41
|
+
box-shadow var(--popover-speed-shadow, var(--speed-color)),
|
|
42
|
+
border-color var(--popover-speed-border-color, var(--speed-color));
|
|
43
|
+
|
|
44
|
+
&--center {
|
|
45
|
+
justify-content: center;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:hover {
|
|
49
|
+
box-shadow: var(--popover-trigger-shadow-offset-hover) var(--popover-trigger-shadow-color);
|
|
50
|
+
border-width: var(--popover-trigger-border-width-hover, var(--popover-trigger-border-width, 1px));
|
|
51
|
+
border-color: var(--popover-trigger-border-color-hover, var(--popover-trigger-border-color, var(--border-color)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&__content {
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
padding: var(--popover-content-padding, 16px);
|
|
58
|
+
background: var(--popover-content-bg-color, var(--bg-primary-color));
|
|
59
|
+
border-radius: var(--popover-content-border-radius, 8px);
|
|
60
|
+
box-shadow: var(--popover-content-shadow-offset, 0 0 5px 0) var(--popover-content-shadow-color, rgba(0, 0, 0, 0.25));
|
|
61
|
+
height: var(--popover-content-height);
|
|
62
|
+
max-height: var(--popover-content-max-height, var(--radix-popover-content-available-height));
|
|
63
|
+
transition:
|
|
64
|
+
background var(--popover-speed-background, var(--speed-color)),
|
|
65
|
+
box-shadow var(--popover-speed-shadow, var(--speed-color));
|
|
66
|
+
|
|
67
|
+
&--full-width {
|
|
68
|
+
width: var(--popover-content-full-width, var(--radix-popover-content-available-width));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&__arrow {
|
|
73
|
+
& > polygon {
|
|
74
|
+
fill: var(--popover-arrow-bg-color, var(--popover-content-bg-color, var(--bg-primary-color)));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -6,7 +6,7 @@ import {Root, SelectProps} from "@radix-ui/react-select";
|
|
|
6
6
|
|
|
7
7
|
import {useComponentProps} from "../../providers";
|
|
8
8
|
|
|
9
|
-
export {SelectProps};
|
|
9
|
+
export {type SelectProps};
|
|
10
10
|
|
|
11
11
|
const Select: FC<SelectProps> = props => {
|
|
12
12
|
const {...other} = {...useComponentProps("select"), ...props};
|
|
@@ -33,7 +33,8 @@ const SelectContent: ForwardRefRenderFunction<HTMLDivElement, SelectContentProps
|
|
|
33
33
|
arrow,
|
|
34
34
|
arrowWidth,
|
|
35
35
|
arrowHeight,
|
|
36
|
-
fullWidth,
|
|
36
|
+
fullWidth = true,
|
|
37
|
+
position = "popper",
|
|
37
38
|
container,
|
|
38
39
|
viewportProps,
|
|
39
40
|
scrollUpButton,
|
|
@@ -54,6 +55,7 @@ const SelectContent: ForwardRefRenderFunction<HTMLDivElement, SelectContentProps
|
|
|
54
55
|
},
|
|
55
56
|
className
|
|
56
57
|
)}
|
|
58
|
+
position={position}
|
|
57
59
|
{...other}
|
|
58
60
|
>
|
|
59
61
|
{scrollUpButton && (
|
|
@@ -75,7 +77,7 @@ const SelectContent: ForwardRefRenderFunction<HTMLDivElement, SelectContentProps
|
|
|
75
77
|
</SelectScrollDownButton>
|
|
76
78
|
)}
|
|
77
79
|
|
|
78
|
-
{arrow && <Arrow width={arrowWidth} height={arrowHeight} />}
|
|
80
|
+
{arrow && <Arrow className={styles["select__arrow"]} width={arrowWidth} height={arrowHeight} />}
|
|
79
81
|
</Content>
|
|
80
82
|
</Portal>
|
|
81
83
|
);
|
|
@@ -8,7 +8,7 @@ import {useComponentProps} from "../../providers";
|
|
|
8
8
|
|
|
9
9
|
import styles from "./select.module.scss";
|
|
10
10
|
|
|
11
|
-
export {SelectIconProps};
|
|
11
|
+
export {type SelectIconProps};
|
|
12
12
|
|
|
13
13
|
const SelectIcon: ForwardRefRenderFunction<HTMLSpanElement, SelectIconProps> = (props, ref) => {
|
|
14
14
|
const {className, ...other} = {...useComponentProps("selectIcon"), ...props};
|
|
@@ -2,10 +2,13 @@ import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
|
2
2
|
|
|
3
3
|
import classnames from "classnames";
|
|
4
4
|
|
|
5
|
-
import {Item,
|
|
5
|
+
import {Item, SelectItemProps as SelectItemRadixProps} from "@radix-ui/react-select";
|
|
6
6
|
|
|
7
7
|
import {useComponentProps} from "../../providers";
|
|
8
8
|
|
|
9
|
+
import SelectItemIndicator from "./SelectItemIndicator";
|
|
10
|
+
import SelectItemText from "./SelectItemText";
|
|
11
|
+
|
|
9
12
|
import styles from "./select.module.scss";
|
|
10
13
|
|
|
11
14
|
export interface SelectItemProps extends SelectItemRadixProps {
|
|
@@ -14,24 +17,20 @@ export interface SelectItemProps extends SelectItemRadixProps {
|
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const SelectItem: ForwardRefRenderFunction<HTMLDivElement, SelectItemProps> = (props, ref) => {
|
|
17
|
-
const {indicator,
|
|
20
|
+
const {textValue, indicator, indicatorClassname, className, children, ...other} = {
|
|
18
21
|
...useComponentProps("selectItem"),
|
|
19
22
|
...props,
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
|
-
<Item ref={ref} className={classnames(styles["select__item"], className)}
|
|
26
|
+
<Item ref={ref} textValue={textValue} className={classnames(styles["select__item"], className)} {...other}>
|
|
24
27
|
{children && children}
|
|
25
28
|
|
|
26
29
|
{!children && (
|
|
27
30
|
<>
|
|
28
|
-
{indicator &&
|
|
29
|
-
<ItemIndicator className={classnames(styles["select__item__indicator"], indicatorClassname)}>
|
|
30
|
-
{indicator}
|
|
31
|
-
</ItemIndicator>
|
|
32
|
-
)}
|
|
31
|
+
{indicator && <SelectItemIndicator className={indicatorClassname}>{indicator}</SelectItemIndicator>}
|
|
33
32
|
|
|
34
|
-
{textValue && <
|
|
33
|
+
{textValue && <SelectItemText>{textValue}</SelectItemText>}
|
|
35
34
|
</>
|
|
36
35
|
)}
|
|
37
36
|
</Item>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {ItemIndicator, SelectItemIndicatorProps} from "@radix-ui/react-select";
|
|
6
|
+
|
|
7
|
+
import styles from "./select.module.scss";
|
|
8
|
+
|
|
9
|
+
export {type SelectItemIndicatorProps};
|
|
10
|
+
|
|
11
|
+
const SelectItemIndicator: ForwardRefRenderFunction<HTMLSpanElement, SelectItemIndicatorProps> = (props, ref) => {
|
|
12
|
+
const {className, ...other} = props;
|
|
13
|
+
|
|
14
|
+
return <ItemIndicator ref={ref} className={classnames(styles["select__item__indicator"], className)} {...other} />;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default memo(forwardRef(SelectItemIndicator));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {ItemText, SelectItemTextProps} from "@radix-ui/react-select";
|
|
6
|
+
|
|
7
|
+
import styles from "./select.module.scss";
|
|
8
|
+
|
|
9
|
+
export {type SelectItemTextProps};
|
|
10
|
+
|
|
11
|
+
const SelectItemText: ForwardRefRenderFunction<HTMLSpanElement, SelectItemTextProps> = (props, ref) => {
|
|
12
|
+
const {className, ...other} = props;
|
|
13
|
+
|
|
14
|
+
return <ItemText ref={ref} className={classnames(styles["select__item__text"], className)} {...other} />;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default memo(forwardRef(SelectItemText));
|
|
@@ -8,7 +8,7 @@ import {useComponentProps} from "../../providers";
|
|
|
8
8
|
|
|
9
9
|
import styles from "./select.module.scss";
|
|
10
10
|
|
|
11
|
-
export {SelectValueProps};
|
|
11
|
+
export {type SelectValueProps};
|
|
12
12
|
|
|
13
13
|
const SelectValue: ForwardRefRenderFunction<HTMLSpanElement, SelectValueProps> = (props, ref) => {
|
|
14
14
|
const {className, ...other} = {...useComponentProps("selectValue"), ...props};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export {default as Select, type SelectProps} from "./Select";
|
|
2
2
|
export {default as SelectItem, type SelectItemProps} from "./SelectItem";
|
|
3
|
+
export {default as SelectItemText, type SelectItemTextProps} from "./SelectItemText";
|
|
4
|
+
export {default as SelectItemIndicator, type SelectItemIndicatorProps} from "./SelectItemIndicator";
|
|
3
5
|
export {default as SelectIcon, type SelectIconProps} from "./SelectIcon";
|
|
4
6
|
export {default as SelectValue, type SelectValueProps} from "./SelectValue";
|
|
5
7
|
export {default as SelectTrigger, type SelectTriggerProps} from "./SelectTrigger";
|
|
@@ -46,7 +46,7 @@ $root: select;
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
&[data-placeholder] {
|
|
49
|
-
color: var(--
|
|
49
|
+
color: var(--select-placeholder-color, var(--placeholder-color));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@include theme.rtl {
|
|
@@ -147,4 +147,10 @@ $root: select;
|
|
|
147
147
|
background-color: var(--select-scroll-btn-hover-bg-color, var(--bg-secondary-color));
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
|
|
151
|
+
&__arrow {
|
|
152
|
+
& > polygon {
|
|
153
|
+
fill: var(--select-arrow-bg-color, var(--select-content-bg-color, var(--bg-primary-color)));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
150
156
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
ComponentProps,
|
|
5
|
+
createElement,
|
|
6
|
+
CSSProperties,
|
|
7
|
+
forwardRef,
|
|
8
|
+
ForwardRefRenderFunction,
|
|
9
|
+
isValidElement,
|
|
10
|
+
memo,
|
|
11
|
+
useImperativeHandle,
|
|
12
|
+
useLayoutEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
useState,
|
|
15
|
+
} from "react";
|
|
16
|
+
|
|
17
|
+
import classnames from "classnames";
|
|
18
|
+
|
|
19
|
+
import styles from "./shift.module.scss";
|
|
20
|
+
|
|
21
|
+
export interface ShiftProps extends ComponentProps<"div"> {
|
|
22
|
+
active?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
adaptiveHeight?: boolean;
|
|
25
|
+
itemClassName?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const Shift: ForwardRefRenderFunction<HTMLDivElement, ShiftProps> = (props, ref) => {
|
|
29
|
+
const {
|
|
30
|
+
active = 1,
|
|
31
|
+
height,
|
|
32
|
+
adaptiveHeight = true,
|
|
33
|
+
itemClassName,
|
|
34
|
+
className,
|
|
35
|
+
style,
|
|
36
|
+
children: childrenProps,
|
|
37
|
+
...other
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
const [currentHeight, setCurrentHeight] = useState<number>();
|
|
41
|
+
|
|
42
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
43
|
+
|
|
44
|
+
const children = Children.map(childrenProps, (child, index) => {
|
|
45
|
+
const item = index + 1;
|
|
46
|
+
|
|
47
|
+
const className = classnames(styles["shift-item"], itemClassName);
|
|
48
|
+
|
|
49
|
+
const style: CSSProperties = {
|
|
50
|
+
opacity: 0,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (item > active) {
|
|
54
|
+
style.transform = `translate3d(0, ${(item - active) * 100}%, 0)`;
|
|
55
|
+
} else if (item < active) {
|
|
56
|
+
style.transform = `translate3d(0, -${(active - item) * 100}%, 0)`;
|
|
57
|
+
} else {
|
|
58
|
+
style.opacity = 1;
|
|
59
|
+
style.transform = "translate3d(0, 0, 0)";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isValidElement<React.HTMLAttributes<HTMLElement>>(child)) {
|
|
63
|
+
return createElement("span", {className, style}, child);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return cloneElement(child, {
|
|
67
|
+
style: {...(child.props?.style ?? {}), ...style},
|
|
68
|
+
className: classnames(className, child.props.className),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
useImperativeHandle(ref, () => containerRef.current as HTMLDivElement);
|
|
73
|
+
|
|
74
|
+
useLayoutEffect(() => {
|
|
75
|
+
const el = containerRef.current?.children[active - 1] as HTMLElement;
|
|
76
|
+
|
|
77
|
+
if (el) {
|
|
78
|
+
setCurrentHeight(el.offsetHeight);
|
|
79
|
+
}
|
|
80
|
+
}, [active]);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
ref={containerRef}
|
|
85
|
+
className={classnames(styles["shift"], className)}
|
|
86
|
+
style={{
|
|
87
|
+
...style,
|
|
88
|
+
...(adaptiveHeight ? {height: currentHeight} : {}),
|
|
89
|
+
...(height ? {height} : {}),
|
|
90
|
+
}}
|
|
91
|
+
{...other}
|
|
92
|
+
>
|
|
93
|
+
{children}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default memo(forwardRef(Shift));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Shift, type ShiftProps} from "./Shift";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.shift {
|
|
2
|
+
position: relative;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
width: 100%;
|
|
9
|
+
transition: height var(--shift-speed-height, var(--speed-sm));
|
|
10
|
+
|
|
11
|
+
&-item {
|
|
12
|
+
position: absolute;
|
|
13
|
+
width: 100%;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
left: 0;
|
|
16
|
+
top: 0;
|
|
17
|
+
transition:
|
|
18
|
+
transform var(--shift-speed-transform, var(--speed-sm)),
|
|
19
|
+
opacity var(--shift-speed-opacity, var(--speed-sm));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -26,6 +26,11 @@ $root: text-area;
|
|
|
26
26
|
cursor: not-allowed;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
&::placeholder {
|
|
30
|
+
color: var(--text-area-placeholder-color, var(--placeholder-color));
|
|
31
|
+
transition: color var(--text-area-speed-color, var(--speed-color));
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
&--full-width {
|
|
30
35
|
width: 100% !important;
|
|
31
36
|
}
|