react-restyle-components 0.4.23 → 0.4.25
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/lib/src/core-components/src/components/AlertBanner/AlertBanner.d.ts +4 -0
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +45 -0
- package/lib/src/core-components/src/components/AlertBanner/elements.d.ts +27 -0
- package/lib/src/core-components/src/components/AlertBanner/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/elements.js +233 -0
- package/lib/src/core-components/src/components/AlertBanner/index.d.ts +3 -0
- package/lib/src/core-components/src/components/AlertBanner/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/index.js +2 -0
- package/lib/src/core-components/src/components/AlertBanner/types.d.ts +46 -0
- package/lib/src/core-components/src/components/AlertBanner/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/types.js +10 -0
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.d.ts.map +1 -1
- package/lib/src/core-components/src/components/Badge/Badge.d.ts +33 -33
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.d.ts +28 -0
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +83 -0
- package/lib/src/core-components/src/components/Breadcrumb/elements.d.ts +44 -0
- package/lib/src/core-components/src/components/Breadcrumb/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +370 -0
- package/lib/src/core-components/src/components/Breadcrumb/index.d.ts +4 -0
- package/lib/src/core-components/src/components/Breadcrumb/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/index.js +3 -0
- package/lib/src/core-components/src/components/Breadcrumb/types.d.ts +14 -0
- package/lib/src/core-components/src/components/Breadcrumb/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/types.js +3 -0
- package/lib/src/core-components/src/components/Button/Button.spec.js +1 -1
- package/lib/src/core-components/src/components/Button/button.component.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.d.ts +5 -0
- package/lib/src/core-components/src/components/Chip/Chip.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/Chip.js +64 -0
- package/lib/src/core-components/src/components/Chip/elements.d.ts +27 -0
- package/lib/src/core-components/src/components/Chip/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/elements.js +253 -0
- package/lib/src/core-components/src/components/Chip/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Chip/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/index.js +2 -0
- package/lib/src/core-components/src/components/Chip/types.d.ts +54 -0
- package/lib/src/core-components/src/components/Chip/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/types.js +4 -0
- package/lib/src/core-components/src/components/Divider/Divider.d.ts +4 -0
- package/lib/src/core-components/src/components/Divider/Divider.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/Divider.js +25 -0
- package/lib/src/core-components/src/components/Divider/elements.d.ts +22 -0
- package/lib/src/core-components/src/components/Divider/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/elements.js +103 -0
- package/lib/src/core-components/src/components/Divider/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Divider/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/index.js +2 -0
- package/lib/src/core-components/src/components/Divider/types.d.ts +30 -0
- package/lib/src/core-components/src/components/Divider/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/types.js +4 -0
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.d.ts +6 -0
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +147 -0
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.d.ts +12 -0
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +89 -0
- package/lib/src/core-components/src/components/DynamicGrid/elements.d.ts +49 -0
- package/lib/src/core-components/src/components/DynamicGrid/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +409 -0
- package/lib/src/core-components/src/components/DynamicGrid/index.d.ts +4 -0
- package/lib/src/core-components/src/components/DynamicGrid/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/index.js +3 -0
- package/lib/src/core-components/src/components/DynamicGrid/types.d.ts +173 -0
- package/lib/src/core-components/src/components/DynamicGrid/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/types.js +28 -0
- package/lib/src/core-components/src/components/DynamicGrid/utils.d.ts +65 -0
- package/lib/src/core-components/src/components/DynamicGrid/utils.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +193 -0
- package/lib/src/core-components/src/components/Icon/Icon.js +1 -1
- package/lib/src/core-components/src/components/Masonry/Masonry.d.ts +7 -0
- package/lib/src/core-components/src/components/Masonry/Masonry.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/Masonry.js +73 -0
- package/lib/src/core-components/src/components/Masonry/elements.d.ts +31 -0
- package/lib/src/core-components/src/components/Masonry/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/elements.js +122 -0
- package/lib/src/core-components/src/components/Masonry/hooks.d.ts +21 -0
- package/lib/src/core-components/src/components/Masonry/hooks.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/hooks.js +100 -0
- package/lib/src/core-components/src/components/Masonry/index.d.ts +4 -0
- package/lib/src/core-components/src/components/Masonry/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/index.js +3 -0
- package/lib/src/core-components/src/components/Masonry/types.d.ts +117 -0
- package/lib/src/core-components/src/components/Masonry/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/types.js +1 -0
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +1 -1
- package/lib/src/core-components/src/components/Skeleton/Skeleton.d.ts +8 -0
- package/lib/src/core-components/src/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +51 -0
- package/lib/src/core-components/src/components/Skeleton/elements.d.ts +33 -0
- package/lib/src/core-components/src/components/Skeleton/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/elements.js +238 -0
- package/lib/src/core-components/src/components/Skeleton/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Skeleton/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/index.js +2 -0
- package/lib/src/core-components/src/components/Skeleton/types.d.ts +80 -0
- package/lib/src/core-components/src/components/Skeleton/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/types.js +4 -0
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.d.ts +4 -0
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +128 -0
- package/lib/src/core-components/src/components/SpeedDial/elements.d.ts +57 -0
- package/lib/src/core-components/src/components/SpeedDial/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/elements.js +299 -0
- package/lib/src/core-components/src/components/SpeedDial/index.d.ts +3 -0
- package/lib/src/core-components/src/components/SpeedDial/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/index.js +2 -0
- package/lib/src/core-components/src/components/SpeedDial/types.d.ts +149 -0
- package/lib/src/core-components/src/components/SpeedDial/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/types.js +3 -0
- package/lib/src/core-components/src/components/Switch/Switch.d.ts +4 -0
- package/lib/src/core-components/src/components/Switch/Switch.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/Switch.js +26 -0
- package/lib/src/core-components/src/components/Switch/elements.d.ts +33 -0
- package/lib/src/core-components/src/components/Switch/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/elements.js +167 -0
- package/lib/src/core-components/src/components/Switch/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Switch/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/index.js +2 -0
- package/lib/src/core-components/src/components/Switch/types.d.ts +32 -0
- package/lib/src/core-components/src/components/Switch/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/types.js +3 -0
- package/lib/src/core-components/src/components/Table/Table.d.ts +7 -0
- package/lib/src/core-components/src/components/Table/Table.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/Table.js +695 -0
- package/lib/src/core-components/src/components/Table/elements.d.ts +89 -0
- package/lib/src/core-components/src/components/Table/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/elements.js +611 -0
- package/lib/src/core-components/src/components/Table/filters.d.ts +23 -0
- package/lib/src/core-components/src/components/Table/filters.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/filters.js +181 -0
- package/lib/src/core-components/src/components/Table/hooks.d.ts +107 -0
- package/lib/src/core-components/src/components/Table/hooks.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/hooks.js +451 -0
- package/lib/src/core-components/src/components/Table/index.d.ts +5 -0
- package/lib/src/core-components/src/components/Table/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/index.js +4 -0
- package/lib/src/core-components/src/components/Table/types.d.ts +635 -0
- package/lib/src/core-components/src/components/Table/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/types.js +1 -0
- package/lib/src/core-components/src/components/Toast/Toast.d.ts +5 -0
- package/lib/src/core-components/src/components/Toast/Toast.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/Toast.js +50 -0
- package/lib/src/core-components/src/components/Toast/elements.d.ts +28 -0
- package/lib/src/core-components/src/components/Toast/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/elements.js +272 -0
- package/lib/src/core-components/src/components/Toast/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Toast/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/index.js +2 -0
- package/lib/src/core-components/src/components/Toast/types.d.ts +52 -0
- package/lib/src/core-components/src/components/Toast/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/types.js +9 -0
- package/lib/src/core-components/src/components/Tooltip/Tooltip.d.ts +7 -0
- package/lib/src/core-components/src/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +200 -0
- package/lib/src/core-components/src/components/Tooltip/elements.d.ts +19 -0
- package/lib/src/core-components/src/components/Tooltip/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/elements.js +195 -0
- package/lib/src/core-components/src/components/Tooltip/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Tooltip/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/index.js +2 -0
- package/lib/src/core-components/src/components/Tooltip/types.d.ts +81 -17
- package/lib/src/core-components/src/components/Tooltip/types.d.ts.map +1 -1
- package/lib/src/core-components/src/components/Tooltip/types.js +17 -1
- package/lib/src/core-components/src/components/Tooltip/utils.d.ts +26 -0
- package/lib/src/core-components/src/components/Tooltip/utils.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/utils.js +140 -0
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.d.ts +5 -0
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +303 -0
- package/lib/src/core-components/src/components/TreeSelect/elements.d.ts +74 -0
- package/lib/src/core-components/src/components/TreeSelect/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/elements.js +494 -0
- package/lib/src/core-components/src/components/TreeSelect/hooks.d.ts +57 -0
- package/lib/src/core-components/src/components/TreeSelect/hooks.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +252 -0
- package/lib/src/core-components/src/components/TreeSelect/index.d.ts +4 -0
- package/lib/src/core-components/src/components/TreeSelect/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/index.js +3 -0
- package/lib/src/core-components/src/components/TreeSelect/types.d.ts +205 -0
- package/lib/src/core-components/src/components/TreeSelect/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -0
- package/lib/src/core-components/src/components/index.d.ts +13 -1
- package/lib/src/core-components/src/components/index.d.ts.map +1 -1
- package/lib/src/core-components/src/components/index.js +14 -1
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.d.ts +2 -2
- package/lib/src/core-components/src/tc.global.css +14 -3
- package/lib/src/core-components/src/tc.module.css +2 -2
- package/package.json +1 -1
- package/lib/src/core-components/src/components/Tooltip/tooltip.component.d.ts +0 -29
- package/lib/src/core-components/src/components/Tooltip/tooltip.component.d.ts.map +0 -1
- package/lib/src/core-components/src/components/Tooltip/tooltip.component.js +0 -10
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TooltipVariant, TooltipSize, TooltipPosition } from './types';
|
|
3
|
+
export declare const TooltipTrigger: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
4
|
+
export declare const TooltipPortal: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
5
|
+
$zIndex: number;
|
|
6
|
+
}>> & string;
|
|
7
|
+
export declare const TooltipContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
8
|
+
$variant: TooltipVariant;
|
|
9
|
+
$size: TooltipSize;
|
|
10
|
+
$maxWidth?: number | undefined;
|
|
11
|
+
$animated: boolean;
|
|
12
|
+
$isVisible: boolean;
|
|
13
|
+
$position: TooltipPosition;
|
|
14
|
+
}>> & string;
|
|
15
|
+
export declare const TooltipArrow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
16
|
+
$variant: TooltipVariant;
|
|
17
|
+
$position: TooltipPosition;
|
|
18
|
+
}>> & string;
|
|
19
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Tooltip/elements.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,cAAc,EAAE,WAAW,EAAE,eAAe,EAAC,MAAM,SAAS,CAAC;AAkDrE,eAAO,MAAM,cAAc,+NAG1B,CAAC;AAEF,eAAO,MAAM,aAAa;aACf,MAAM;YAQhB,CAAC;AAEF,eAAO,MAAM,cAAc;cACf,cAAc;WACjB,WAAW;;eAEP,OAAO;gBACN,OAAO;eACR,eAAe;YA0C3B,CAAC;AAEF,eAAO,MAAM,YAAY;cACb,cAAc;eACb,eAAe;YAsG3B,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { styled, css, keyframes } from 'styled-components';
|
|
2
|
+
// Animations
|
|
3
|
+
const fadeIn = keyframes `
|
|
4
|
+
from {
|
|
5
|
+
opacity: 0;
|
|
6
|
+
transform: scale(0.96);
|
|
7
|
+
}
|
|
8
|
+
to {
|
|
9
|
+
opacity: 1;
|
|
10
|
+
transform: scale(1);
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
// Variant colors
|
|
14
|
+
const variantStyles = {
|
|
15
|
+
dark: {
|
|
16
|
+
bg: '#1f2937',
|
|
17
|
+
text: '#f9fafb',
|
|
18
|
+
border: '#374151',
|
|
19
|
+
},
|
|
20
|
+
light: {
|
|
21
|
+
bg: '#ffffff',
|
|
22
|
+
text: '#1f2937',
|
|
23
|
+
border: '#e5e7eb',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
// Size styles
|
|
27
|
+
const sizeStyles = {
|
|
28
|
+
small: {
|
|
29
|
+
padding: '4px 8px',
|
|
30
|
+
fontSize: '12px',
|
|
31
|
+
borderRadius: '4px',
|
|
32
|
+
},
|
|
33
|
+
medium: {
|
|
34
|
+
padding: '8px 12px',
|
|
35
|
+
fontSize: '13px',
|
|
36
|
+
borderRadius: '6px',
|
|
37
|
+
},
|
|
38
|
+
large: {
|
|
39
|
+
padding: '12px 16px',
|
|
40
|
+
fontSize: '14px',
|
|
41
|
+
borderRadius: '8px',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
// Arrow size
|
|
45
|
+
const ARROW_SIZE = 6;
|
|
46
|
+
export const TooltipTrigger = styled.span `
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
cursor: default;
|
|
49
|
+
`;
|
|
50
|
+
export const TooltipPortal = styled.div `
|
|
51
|
+
position: fixed;
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
width: 0;
|
|
55
|
+
height: 0;
|
|
56
|
+
z-index: ${({ $zIndex }) => $zIndex};
|
|
57
|
+
`;
|
|
58
|
+
export const TooltipContent = styled.div `
|
|
59
|
+
position: fixed;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
|
|
63
|
+
/* Variant */
|
|
64
|
+
background: ${({ $variant }) => variantStyles[$variant].bg};
|
|
65
|
+
color: ${({ $variant }) => variantStyles[$variant].text};
|
|
66
|
+
border: 1px solid ${({ $variant }) => variantStyles[$variant].border};
|
|
67
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
68
|
+
|
|
69
|
+
/* Size */
|
|
70
|
+
padding: ${({ $size }) => sizeStyles[$size].padding};
|
|
71
|
+
font-size: ${({ $size }) => sizeStyles[$size].fontSize};
|
|
72
|
+
border-radius: ${({ $size }) => sizeStyles[$size].borderRadius};
|
|
73
|
+
|
|
74
|
+
/* Layout */
|
|
75
|
+
max-width: ${({ $maxWidth }) => ($maxWidth ? `${$maxWidth}px` : '280px')};
|
|
76
|
+
width: max-content;
|
|
77
|
+
text-align: left;
|
|
78
|
+
line-height: 1.5;
|
|
79
|
+
word-wrap: break-word;
|
|
80
|
+
white-space: normal;
|
|
81
|
+
|
|
82
|
+
/* Animation */
|
|
83
|
+
opacity: 0;
|
|
84
|
+
${({ $animated, $isVisible }) => $isVisible &&
|
|
85
|
+
($animated
|
|
86
|
+
? css `
|
|
87
|
+
animation: ${fadeIn} 0.15s ease-out forwards;
|
|
88
|
+
`
|
|
89
|
+
: css `
|
|
90
|
+
opacity: 1;
|
|
91
|
+
`)}
|
|
92
|
+
|
|
93
|
+
/* Accessibility */
|
|
94
|
+
@media (prefers-reduced-motion: reduce) {
|
|
95
|
+
animation: none;
|
|
96
|
+
opacity: ${({ $isVisible }) => ($isVisible ? 1 : 0)};
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
export const TooltipArrow = styled.div `
|
|
100
|
+
position: absolute;
|
|
101
|
+
width: 0;
|
|
102
|
+
height: 0;
|
|
103
|
+
border: ${ARROW_SIZE}px solid transparent;
|
|
104
|
+
|
|
105
|
+
/* Position and color based on tooltip position */
|
|
106
|
+
${({ $position, $variant }) => {
|
|
107
|
+
const color = variantStyles[$variant].bg;
|
|
108
|
+
const borderColor = variantStyles[$variant].border;
|
|
109
|
+
// Top positions - arrow at bottom
|
|
110
|
+
if ($position.startsWith('top')) {
|
|
111
|
+
return css `
|
|
112
|
+
top: 100%;
|
|
113
|
+
border-top-color: ${color};
|
|
114
|
+
|
|
115
|
+
&::before {
|
|
116
|
+
content: '';
|
|
117
|
+
position: absolute;
|
|
118
|
+
top: -${ARROW_SIZE + 1}px;
|
|
119
|
+
left: -${ARROW_SIZE}px;
|
|
120
|
+
border: ${ARROW_SIZE}px solid transparent;
|
|
121
|
+
border-top-color: ${borderColor};
|
|
122
|
+
z-index: -1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
${$position === 'top' && css `left: 50%; margin-left: -${ARROW_SIZE}px;`}
|
|
126
|
+
${$position === 'top-start' && css `left: 12px;`}
|
|
127
|
+
${$position === 'top-end' && css `right: 12px;`}
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
// Bottom positions - arrow at top
|
|
131
|
+
if ($position.startsWith('bottom')) {
|
|
132
|
+
return css `
|
|
133
|
+
bottom: 100%;
|
|
134
|
+
border-bottom-color: ${color};
|
|
135
|
+
|
|
136
|
+
&::before {
|
|
137
|
+
content: '';
|
|
138
|
+
position: absolute;
|
|
139
|
+
bottom: -${ARROW_SIZE + 1}px;
|
|
140
|
+
left: -${ARROW_SIZE}px;
|
|
141
|
+
border: ${ARROW_SIZE}px solid transparent;
|
|
142
|
+
border-bottom-color: ${borderColor};
|
|
143
|
+
z-index: -1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
${$position === 'bottom' && css `left: 50%; margin-left: -${ARROW_SIZE}px;`}
|
|
147
|
+
${$position === 'bottom-start' && css `left: 12px;`}
|
|
148
|
+
${$position === 'bottom-end' && css `right: 12px;`}
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
// Left positions - arrow at right
|
|
152
|
+
if ($position.startsWith('left')) {
|
|
153
|
+
return css `
|
|
154
|
+
left: 100%;
|
|
155
|
+
border-left-color: ${color};
|
|
156
|
+
|
|
157
|
+
&::before {
|
|
158
|
+
content: '';
|
|
159
|
+
position: absolute;
|
|
160
|
+
left: -${ARROW_SIZE - 1}px;
|
|
161
|
+
top: -${ARROW_SIZE}px;
|
|
162
|
+
border: ${ARROW_SIZE}px solid transparent;
|
|
163
|
+
border-left-color: ${borderColor};
|
|
164
|
+
z-index: -1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
${$position === 'left' && css `top: 50%; margin-top: -${ARROW_SIZE}px;`}
|
|
168
|
+
${$position === 'left-start' && css `top: 12px;`}
|
|
169
|
+
${$position === 'left-end' && css `bottom: 12px;`}
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
// Right positions - arrow at left
|
|
173
|
+
if ($position.startsWith('right')) {
|
|
174
|
+
return css `
|
|
175
|
+
right: 100%;
|
|
176
|
+
border-right-color: ${color};
|
|
177
|
+
|
|
178
|
+
&::before {
|
|
179
|
+
content: '';
|
|
180
|
+
position: absolute;
|
|
181
|
+
right: -${ARROW_SIZE - 1}px;
|
|
182
|
+
top: -${ARROW_SIZE}px;
|
|
183
|
+
border: ${ARROW_SIZE}px solid transparent;
|
|
184
|
+
border-right-color: ${borderColor};
|
|
185
|
+
z-index: -1;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
${$position === 'right' && css `top: 50%; margin-top: -${ARROW_SIZE}px;`}
|
|
189
|
+
${$position === 'right-start' && css `top: 12px;`}
|
|
190
|
+
${$position === 'right-end' && css `bottom: 12px;`}
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
return '';
|
|
194
|
+
}}
|
|
195
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,WAAW,CAAC;AACnD,cAAc,SAAS,CAAC"}
|
|
@@ -1,22 +1,86 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
export declare const TOOLTIP_POSITIONS: readonly ["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "right", "right-start", "right-end"];
|
|
3
|
+
export type TooltipPosition = (typeof TOOLTIP_POSITIONS)[number];
|
|
4
|
+
export declare const TOOLTIP_VARIANTS: readonly ["dark", "light"];
|
|
5
|
+
export type TooltipVariant = (typeof TOOLTIP_VARIANTS)[number];
|
|
6
|
+
export declare const TOOLTIP_SIZES: readonly ["small", "medium", "large"];
|
|
7
|
+
export type TooltipSize = (typeof TOOLTIP_SIZES)[number];
|
|
8
|
+
export declare const TOOLTIP_TRIGGERS: readonly ["hover", "click", "focus", "manual"];
|
|
9
|
+
export type TooltipTrigger = (typeof TOOLTIP_TRIGGERS)[number];
|
|
10
|
+
export interface TargetRect {
|
|
11
|
+
top: number;
|
|
12
|
+
left: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TooltipClassNames {
|
|
17
|
+
/** Custom className for the trigger wrapper */
|
|
18
|
+
trigger?: string;
|
|
19
|
+
/** Custom className for the content container */
|
|
20
|
+
content?: string;
|
|
21
|
+
/** Custom className for the arrow */
|
|
22
|
+
arrow?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TooltipStyles {
|
|
25
|
+
/** Custom style for the trigger wrapper */
|
|
26
|
+
trigger?: CSSProperties;
|
|
27
|
+
/** Custom style for the content container */
|
|
28
|
+
content?: CSSProperties;
|
|
29
|
+
/** Custom style for the arrow */
|
|
30
|
+
arrow?: CSSProperties;
|
|
31
|
+
}
|
|
32
|
+
export interface TooltipProps {
|
|
33
|
+
/** Children element (trigger) */
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
/** Tooltip content */
|
|
12
36
|
content?: React.ReactNode;
|
|
13
|
-
/**
|
|
37
|
+
/** Preferred position */
|
|
38
|
+
position?: TooltipPosition;
|
|
39
|
+
/** @deprecated use 'position' instead */
|
|
40
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
41
|
+
/** Alignment (only for basic positions) */
|
|
14
42
|
align?: 'start' | 'center' | 'end';
|
|
15
|
-
/**
|
|
43
|
+
/** Visual variant */
|
|
44
|
+
variant?: TooltipVariant;
|
|
45
|
+
/** Size preset */
|
|
46
|
+
size?: TooltipSize;
|
|
47
|
+
/** Delay before showing (ms) */
|
|
48
|
+
delay?: number;
|
|
49
|
+
/** Delay before hiding (ms) */
|
|
50
|
+
hideDelay?: number;
|
|
51
|
+
/** Distance from trigger element */
|
|
52
|
+
offset?: number;
|
|
53
|
+
/** @deprecated use 'offset' instead */
|
|
54
|
+
sideOffset?: number;
|
|
55
|
+
/** @deprecated use 'offset' instead */
|
|
16
56
|
alignOffset?: number;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
/**
|
|
57
|
+
/** Maximum width of tooltip */
|
|
58
|
+
maxWidth?: number;
|
|
59
|
+
/** Show arrow */
|
|
60
|
+
showArrow?: boolean;
|
|
61
|
+
/** Disable tooltip */
|
|
20
62
|
disabled?: boolean;
|
|
21
|
-
|
|
63
|
+
/** Trigger mode */
|
|
64
|
+
trigger?: TooltipTrigger | TooltipTrigger[];
|
|
65
|
+
/** Controlled open state */
|
|
66
|
+
open?: boolean;
|
|
67
|
+
/** Open state change handler */
|
|
68
|
+
onOpenChange?: (open: boolean) => void;
|
|
69
|
+
/** Avoid viewport collisions */
|
|
70
|
+
avoidCollisions?: boolean;
|
|
71
|
+
/** Use portal for rendering */
|
|
72
|
+
portal?: boolean;
|
|
73
|
+
/** Enable animations */
|
|
74
|
+
animated?: boolean;
|
|
75
|
+
/** Custom class names */
|
|
76
|
+
classNames?: TooltipClassNames;
|
|
77
|
+
/** Custom styles */
|
|
78
|
+
styles?: TooltipStyles;
|
|
79
|
+
/** Deprecated: use classNames.trigger */
|
|
80
|
+
className?: string;
|
|
81
|
+
/** z-index for tooltip */
|
|
82
|
+
zIndex?: number;
|
|
83
|
+
/** Accessibility: aria-label override */
|
|
84
|
+
ariaLabel?: string;
|
|
85
|
+
}
|
|
22
86
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Tooltip/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const TOOLTIP_POSITIONS = [
|
|
2
|
+
'top',
|
|
3
|
+
'top-start',
|
|
4
|
+
'top-end',
|
|
5
|
+
'bottom',
|
|
6
|
+
'bottom-start',
|
|
7
|
+
'bottom-end',
|
|
8
|
+
'left',
|
|
9
|
+
'left-start',
|
|
10
|
+
'left-end',
|
|
11
|
+
'right',
|
|
12
|
+
'right-start',
|
|
13
|
+
'right-end',
|
|
14
|
+
];
|
|
15
|
+
export const TOOLTIP_VARIANTS = ['dark', 'light'];
|
|
16
|
+
export const TOOLTIP_SIZES = ['small', 'medium', 'large'];
|
|
17
|
+
export const TOOLTIP_TRIGGERS = ['hover', 'click', 'focus', 'manual'];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TooltipPosition, TargetRect } from './types';
|
|
2
|
+
export interface TooltipCoords {
|
|
3
|
+
top: number;
|
|
4
|
+
left: number;
|
|
5
|
+
}
|
|
6
|
+
export interface TooltipDimensions {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Calculate tooltip position relative to viewport (for fixed positioning)
|
|
12
|
+
*/
|
|
13
|
+
export declare const calculateTooltipPosition: (position: TooltipPosition, targetRect: TargetRect, tooltipDimensions: TooltipDimensions, offset?: number) => TooltipCoords;
|
|
14
|
+
/**
|
|
15
|
+
* Get alternate position when collision detected
|
|
16
|
+
*/
|
|
17
|
+
export declare const getAlternatePosition: (position: TooltipPosition, coords: TooltipCoords, tooltipDimensions: TooltipDimensions, viewportWidth: number, viewportHeight: number) => TooltipPosition | null;
|
|
18
|
+
/**
|
|
19
|
+
* Clamp coords within viewport
|
|
20
|
+
*/
|
|
21
|
+
export declare const clampToViewport: (coords: TooltipCoords, tooltipDimensions: TooltipDimensions, viewportWidth: number, viewportHeight: number) => TooltipCoords;
|
|
22
|
+
/**
|
|
23
|
+
* Convert side + align to position
|
|
24
|
+
*/
|
|
25
|
+
export declare const sideAlignToPosition: (side: 'top' | 'right' | 'bottom' | 'left', align: 'start' | 'center' | 'end') => TooltipPosition;
|
|
26
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Tooltip/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAIpD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,aACzB,eAAe,cACb,UAAU,qBACH,iBAAiB,WAC5B,MAAM,KACb,aA6FF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,aACrB,eAAe,UACjB,aAAa,qBACF,iBAAiB,iBACrB,MAAM,kBACL,MAAM,KACrB,eAAe,GAAG,IA+BpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,WAClB,aAAa,qBACF,iBAAiB,iBACrB,MAAM,kBACL,MAAM,KACrB,aAQF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,SACxB,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,SAClC,OAAO,GAAG,QAAQ,GAAG,KAAK,KAChC,eAGF,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const ARROW_SIZE = 6;
|
|
2
|
+
/**
|
|
3
|
+
* Calculate tooltip position relative to viewport (for fixed positioning)
|
|
4
|
+
*/
|
|
5
|
+
export const calculateTooltipPosition = (position, targetRect, tooltipDimensions, offset = 8) => {
|
|
6
|
+
const { top, left, width, height } = targetRect;
|
|
7
|
+
const { width: tooltipWidth, height: tooltipHeight } = tooltipDimensions;
|
|
8
|
+
let coords = { top: 0, left: 0 };
|
|
9
|
+
const totalOffset = offset + ARROW_SIZE;
|
|
10
|
+
switch (position) {
|
|
11
|
+
// Top positions
|
|
12
|
+
case 'top':
|
|
13
|
+
coords = {
|
|
14
|
+
top: top - tooltipHeight - totalOffset,
|
|
15
|
+
left: left + width / 2 - tooltipWidth / 2,
|
|
16
|
+
};
|
|
17
|
+
break;
|
|
18
|
+
case 'top-start':
|
|
19
|
+
coords = {
|
|
20
|
+
top: top - tooltipHeight - totalOffset,
|
|
21
|
+
left: left,
|
|
22
|
+
};
|
|
23
|
+
break;
|
|
24
|
+
case 'top-end':
|
|
25
|
+
coords = {
|
|
26
|
+
top: top - tooltipHeight - totalOffset,
|
|
27
|
+
left: left + width - tooltipWidth,
|
|
28
|
+
};
|
|
29
|
+
break;
|
|
30
|
+
// Bottom positions
|
|
31
|
+
case 'bottom':
|
|
32
|
+
coords = {
|
|
33
|
+
top: top + height + totalOffset,
|
|
34
|
+
left: left + width / 2 - tooltipWidth / 2,
|
|
35
|
+
};
|
|
36
|
+
break;
|
|
37
|
+
case 'bottom-start':
|
|
38
|
+
coords = {
|
|
39
|
+
top: top + height + totalOffset,
|
|
40
|
+
left: left,
|
|
41
|
+
};
|
|
42
|
+
break;
|
|
43
|
+
case 'bottom-end':
|
|
44
|
+
coords = {
|
|
45
|
+
top: top + height + totalOffset,
|
|
46
|
+
left: left + width - tooltipWidth,
|
|
47
|
+
};
|
|
48
|
+
break;
|
|
49
|
+
// Left positions
|
|
50
|
+
case 'left':
|
|
51
|
+
coords = {
|
|
52
|
+
top: top + height / 2 - tooltipHeight / 2,
|
|
53
|
+
left: left - tooltipWidth - totalOffset,
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
case 'left-start':
|
|
57
|
+
coords = {
|
|
58
|
+
top: top,
|
|
59
|
+
left: left - tooltipWidth - totalOffset,
|
|
60
|
+
};
|
|
61
|
+
break;
|
|
62
|
+
case 'left-end':
|
|
63
|
+
coords = {
|
|
64
|
+
top: top + height - tooltipHeight,
|
|
65
|
+
left: left - tooltipWidth - totalOffset,
|
|
66
|
+
};
|
|
67
|
+
break;
|
|
68
|
+
// Right positions
|
|
69
|
+
case 'right':
|
|
70
|
+
coords = {
|
|
71
|
+
top: top + height / 2 - tooltipHeight / 2,
|
|
72
|
+
left: left + width + totalOffset,
|
|
73
|
+
};
|
|
74
|
+
break;
|
|
75
|
+
case 'right-start':
|
|
76
|
+
coords = {
|
|
77
|
+
top: top,
|
|
78
|
+
left: left + width + totalOffset,
|
|
79
|
+
};
|
|
80
|
+
break;
|
|
81
|
+
case 'right-end':
|
|
82
|
+
coords = {
|
|
83
|
+
top: top + height - tooltipHeight,
|
|
84
|
+
left: left + width + totalOffset,
|
|
85
|
+
};
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
coords = calculateTooltipPosition('top', targetRect, tooltipDimensions, offset);
|
|
89
|
+
}
|
|
90
|
+
return coords;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Get alternate position when collision detected
|
|
94
|
+
*/
|
|
95
|
+
export const getAlternatePosition = (position, coords, tooltipDimensions, viewportWidth, viewportHeight) => {
|
|
96
|
+
const { top, left } = coords;
|
|
97
|
+
const { width, height } = tooltipDimensions;
|
|
98
|
+
const padding = 8;
|
|
99
|
+
// Check if current position has collision
|
|
100
|
+
const leftOverflow = left < padding;
|
|
101
|
+
const rightOverflow = left + width > viewportWidth - padding;
|
|
102
|
+
const topOverflow = top < padding;
|
|
103
|
+
const bottomOverflow = top + height > viewportHeight - padding;
|
|
104
|
+
if (!leftOverflow && !rightOverflow && !topOverflow && !bottomOverflow) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
// Determine alternate position
|
|
108
|
+
if (position.startsWith('top') && topOverflow) {
|
|
109
|
+
return position.replace('top', 'bottom');
|
|
110
|
+
}
|
|
111
|
+
if (position.startsWith('bottom') && bottomOverflow) {
|
|
112
|
+
return position.replace('bottom', 'top');
|
|
113
|
+
}
|
|
114
|
+
if (position.startsWith('left') && leftOverflow) {
|
|
115
|
+
return position.replace('left', 'right');
|
|
116
|
+
}
|
|
117
|
+
if (position.startsWith('right') && rightOverflow) {
|
|
118
|
+
return position.replace('right', 'left');
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Clamp coords within viewport
|
|
124
|
+
*/
|
|
125
|
+
export const clampToViewport = (coords, tooltipDimensions, viewportWidth, viewportHeight) => {
|
|
126
|
+
const { width, height } = tooltipDimensions;
|
|
127
|
+
const padding = 8;
|
|
128
|
+
return {
|
|
129
|
+
top: Math.max(padding, Math.min(coords.top, viewportHeight - height - padding)),
|
|
130
|
+
left: Math.max(padding, Math.min(coords.left, viewportWidth - width - padding)),
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Convert side + align to position
|
|
135
|
+
*/
|
|
136
|
+
export const sideAlignToPosition = (side, align) => {
|
|
137
|
+
if (align === 'center')
|
|
138
|
+
return side;
|
|
139
|
+
return `${side}-${align}`;
|
|
140
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeSelect.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/TreeSelect/TreeSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AA0Bf,OAAO,EAAC,eAAe,EAAiB,MAAM,SAAS,CAAC;AA8DxD,eAAO,MAAM,UAAU,wFA8nBtB,CAAC;AAIF,eAAe,UAAU,CAAC"}
|