@platformatic/ui-components 0.7.25 → 0.7.27
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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import styles from './Tooltip.module.css'
|
|
4
4
|
import { useEffect, useRef, useState } from 'react'
|
|
5
|
-
import { DIRECTIONS, DIRECTION_BOTTOM, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_TOP } from './constants'
|
|
5
|
+
import { DIRECTIONS, DIRECTION_BOTTOM, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_TOP, POSITIONS, POSITION_CENTER, POSITION_END, POSITION_START } from './constants'
|
|
6
6
|
|
|
7
7
|
function Tooltip ({
|
|
8
8
|
immediateActive = true,
|
|
@@ -13,13 +13,17 @@ function Tooltip ({
|
|
|
13
13
|
delay = 0,
|
|
14
14
|
children = null,
|
|
15
15
|
tooltipClassName = '',
|
|
16
|
-
offset = 0
|
|
16
|
+
offset = 0,
|
|
17
|
+
position = POSITION_CENTER
|
|
17
18
|
}) {
|
|
18
19
|
let timeout
|
|
19
20
|
// const [active, setActive] = useState(activeDependsOnVisible ? visible : false)
|
|
20
21
|
const [active, setActive] = useState(immediateActive)
|
|
21
22
|
let componentClassName = tooltipClassName || styles.tooltipTipBaseClass
|
|
22
23
|
componentClassName += ` ${styles.tooltipTip} ` + styles[`${direction}`]
|
|
24
|
+
if (direction === DIRECTION_BOTTOM || direction === DIRECTION_TOP) {
|
|
25
|
+
componentClassName += ' ' + styles[`${position}`]
|
|
26
|
+
}
|
|
23
27
|
const fixedStyle = { top: '0px', left: '0px' }
|
|
24
28
|
const wrapperRef = useRef()
|
|
25
29
|
|
|
@@ -39,6 +43,19 @@ function Tooltip ({
|
|
|
39
43
|
fixedStyle.top = `${referenceBoundingClientRect.y + referenceBoundingClientRect.height + offset}px`
|
|
40
44
|
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2)}px`
|
|
41
45
|
fixedStyle.transform = 'translateX(-50%)'
|
|
46
|
+
switch (position) {
|
|
47
|
+
case POSITION_END:
|
|
48
|
+
fixedStyle.transform = 'translateX(0%)'
|
|
49
|
+
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2) - 10}px`
|
|
50
|
+
break
|
|
51
|
+
case POSITION_START:
|
|
52
|
+
fixedStyle.transform = 'translateX(-100%)'
|
|
53
|
+
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2) + 10}px`
|
|
54
|
+
break
|
|
55
|
+
default:
|
|
56
|
+
fixedStyle.transform = 'translateX(-50%)'
|
|
57
|
+
break
|
|
58
|
+
}
|
|
42
59
|
break
|
|
43
60
|
case DIRECTION_LEFT:
|
|
44
61
|
fixedStyle.top = `${referenceBoundingClientRect.y + referenceBoundingClientRect.height / 2}px`
|
|
@@ -53,7 +70,19 @@ function Tooltip ({
|
|
|
53
70
|
default:
|
|
54
71
|
fixedStyle.top = `${referenceBoundingClientRect.y - referenceBoundingClientRect.height - offset}px`
|
|
55
72
|
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2)}px`
|
|
56
|
-
|
|
73
|
+
switch (position) {
|
|
74
|
+
case POSITION_END:
|
|
75
|
+
fixedStyle.transform = 'translateX(0%)'
|
|
76
|
+
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2) - 10}px`
|
|
77
|
+
break
|
|
78
|
+
case POSITION_START:
|
|
79
|
+
fixedStyle.transform = 'translateX(-100%)'
|
|
80
|
+
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2) + 10}px`
|
|
81
|
+
break
|
|
82
|
+
default:
|
|
83
|
+
fixedStyle.transform = 'translateX(-50%)'
|
|
84
|
+
break
|
|
85
|
+
}
|
|
57
86
|
break
|
|
58
87
|
}
|
|
59
88
|
}
|
|
@@ -123,7 +152,11 @@ Tooltip.propTypes = {
|
|
|
123
152
|
/**
|
|
124
153
|
* offset
|
|
125
154
|
*/
|
|
126
|
-
offset: PropTypes.number
|
|
155
|
+
offset: PropTypes.number,
|
|
156
|
+
/**
|
|
157
|
+
* position
|
|
158
|
+
*/
|
|
159
|
+
position: PropTypes.oneOf(POSITIONS)
|
|
127
160
|
}
|
|
128
161
|
|
|
129
162
|
export default Tooltip
|
|
@@ -27,7 +27,8 @@ function Select ({
|
|
|
27
27
|
dataAttrValue = '',
|
|
28
28
|
backgroundColor = WHITE,
|
|
29
29
|
inputTextClassName = '',
|
|
30
|
-
beforeIcon = {}
|
|
30
|
+
beforeIcon = {},
|
|
31
|
+
paddingClass = ''
|
|
31
32
|
}) {
|
|
32
33
|
const inputRef = useRef()
|
|
33
34
|
const [showOptions, setShowOptions] = useState(false)
|
|
@@ -37,7 +38,7 @@ function Select ({
|
|
|
37
38
|
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
38
39
|
const showError = errorMessage.length > 0
|
|
39
40
|
const containerClassName = `${styles.container} ${defaultContainerClassName} `
|
|
40
|
-
let baseWrapperClassName = `${styles.selectContainer} `
|
|
41
|
+
let baseWrapperClassName = `${styles.selectContainer} ${paddingClass || styles.defaultPaddingClass}`
|
|
41
42
|
let inputClassName = `${styles.select} ${inputTextClassName}`
|
|
42
43
|
baseWrapperClassName += ' ' + styles[`select-${mainColor}`]
|
|
43
44
|
baseWrapperClassName += ' ' + commonStyles[`text--${borderColor}`]
|
|
@@ -280,7 +281,11 @@ Select.propTypes = {
|
|
|
280
281
|
iconName: PropTypes.string,
|
|
281
282
|
color: PropTypes.string,
|
|
282
283
|
size: PropTypes.oneOf(SIZES)
|
|
283
|
-
})
|
|
284
|
+
}),
|
|
285
|
+
/**
|
|
286
|
+
* paddingClass
|
|
287
|
+
*/
|
|
288
|
+
paddingClass: PropTypes.string
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
export default Select
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
@apply flex flex-col w-full relative
|
|
3
3
|
}
|
|
4
4
|
.selectContainer {
|
|
5
|
-
@apply w-full flex items-center relative z-10 gap-x-2 border border-solid box-border rounded
|
|
6
|
-
}
|
|
5
|
+
@apply w-full flex items-center relative z-10 gap-x-2 border border-solid box-border rounded;
|
|
6
|
+
}
|
|
7
|
+
.defaultPaddingClass {
|
|
8
|
+
@apply py-1.5 px-2 md:px-3 md:py-[10.5px];
|
|
9
|
+
}
|
|
7
10
|
.select {
|
|
8
11
|
@apply h-full border-none rounded truncate w-[calc(100%-1rem)];
|
|
9
12
|
}
|
|
@@ -4,10 +4,9 @@ import Tooltip from '../components/Tooltip'
|
|
|
4
4
|
import {
|
|
5
5
|
ANTI_FLASH_WHITE,
|
|
6
6
|
CHANGE_BACKGROUND_COLOR,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
DIRECTIONS,
|
|
8
|
+
POSITIONS,
|
|
9
9
|
RICH_BLACK,
|
|
10
|
-
SIZES,
|
|
11
10
|
WHITE
|
|
12
11
|
} from '../components/constants'
|
|
13
12
|
import Button from '../components/Button'
|
|
@@ -29,43 +28,38 @@ export default {
|
|
|
29
28
|
)
|
|
30
29
|
],
|
|
31
30
|
argTypes: {
|
|
32
|
-
|
|
33
|
-
type: 'string',
|
|
34
|
-
control: 'text'
|
|
35
|
-
},
|
|
36
|
-
bold: {
|
|
31
|
+
immediateActive: {
|
|
37
32
|
type: 'boolean'
|
|
38
33
|
},
|
|
39
|
-
|
|
34
|
+
direction: {
|
|
40
35
|
type: 'radio',
|
|
41
|
-
options:
|
|
36
|
+
options: DIRECTIONS
|
|
42
37
|
},
|
|
43
|
-
|
|
44
|
-
type: '
|
|
45
|
-
options: COLORS_BUTTON
|
|
38
|
+
visible: {
|
|
39
|
+
type: 'boolean'
|
|
46
40
|
},
|
|
47
|
-
|
|
41
|
+
activeDependsOnVisible: {
|
|
48
42
|
type: 'boolean'
|
|
49
43
|
},
|
|
50
|
-
|
|
51
|
-
type: '
|
|
52
|
-
control: {
|
|
53
|
-
type: 'radio',
|
|
54
|
-
options: SIZES
|
|
55
|
-
}
|
|
44
|
+
content: {
|
|
45
|
+
type: 'node'
|
|
56
46
|
},
|
|
57
|
-
|
|
58
|
-
type: '
|
|
59
|
-
options: HOVER_EFFECTS_BUTTONS
|
|
47
|
+
delay: {
|
|
48
|
+
type: 'number'
|
|
60
49
|
},
|
|
61
|
-
|
|
62
|
-
type: '
|
|
50
|
+
children: {
|
|
51
|
+
type: 'node'
|
|
63
52
|
},
|
|
64
|
-
|
|
65
|
-
type: '
|
|
53
|
+
tooltipClassName: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
control: 'text'
|
|
66
56
|
},
|
|
67
|
-
|
|
68
|
-
type: '
|
|
57
|
+
offset: {
|
|
58
|
+
type: 'number'
|
|
59
|
+
},
|
|
60
|
+
position: {
|
|
61
|
+
type: 'radio',
|
|
62
|
+
options: POSITIONS
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
65
|
}
|