Skip to content

Commit d027d9b

Browse files
authored
Merge pull request #73 from solved-ac/realease/v0.6.3
Release
2 parents 9c1aba2 + d35a594 commit d027d9b

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

example/src/stories/Tooltip.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ export default {
5757
'Whether to activate the tooltip on mouse click - repeated clicks will toggle the tooltip',
5858
defaultValue: false,
5959
},
60+
zIndex: {
61+
control: 'number',
62+
description: 'The z-index of the tooltip',
63+
defaultValue: 0,
64+
},
6065
noDefaultStyles: {
6166
control: 'boolean',
6267
description:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solved-ac/ui-react",
3-
"version": "0.6.1",
3+
"version": "0.6.3",
44
"description": "React component library used by solved.ac",
55
"author": "shiftpsh",
66
"license": "MIT",

src/components/Select.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import React, {
2727
useImperativeHandle,
2828
useLayoutEffect,
2929
useRef,
30-
useState,
30+
useState
3131
} from 'react'
3232
import { PP, PR } from '../types/PolymorphicElementProps'
3333
import { Timeout } from '../types/Timeout'
@@ -93,7 +93,7 @@ export interface SelectProps<T extends SelectItemNode> {
9393
value?: string | null
9494
zIndex?: number
9595
onChange?: (value: T) => void
96-
render?: (value: T) => ReactNode
96+
render?: (value: T, index?: number) => ReactNode
9797
ListItemProps?: Partial<PP<'div', ListItemProps>>
9898
}
9999

@@ -327,23 +327,25 @@ export const Select = forwardRefWithGenerics(
327327
? theme.color.background.card.main
328328
: undefined
329329
}
330-
style={{
331-
...(disableEllipsis
332-
? {}
333-
: {
334-
textOverflow: 'ellipsis',
335-
overflow: 'hidden',
336-
whiteSpace: 'nowrap',
337-
}),
338-
...(ListItemProps?.style || {}),
339-
fontWeight: i === selectedIndex ? 'bold' : 'normal',
340-
}}
341330
ref={(node) => {
342331
listRef.current[i] = node
343332
listContentRef.current[i] =
344333
typeof item === 'string' ? item : item.value
345334
}}
346335
{...getItemProps({
336+
...ListItemProps,
337+
style: {
338+
...(disableEllipsis
339+
? {}
340+
: {
341+
textOverflow: 'ellipsis',
342+
overflow: 'hidden',
343+
whiteSpace: 'nowrap',
344+
}),
345+
...(ListItemProps?.style || {}),
346+
fontWeight:
347+
i === selectedIndex ? 'bold' : 'normal',
348+
},
347349
onTouchStart() {
348350
allowSelectRef.current = true
349351
allowMouseUpRef.current = false
@@ -374,9 +376,8 @@ export const Select = forwardRefWithGenerics(
374376
})
375377
},
376378
})}
377-
{...ListItemProps}
378379
>
379-
{render(item)}
380+
{render(item, i)}
380381
</ListItem>
381382
)
382383
})}

src/components/Tooltip.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ export type TooltipProps = {
6767
theme?: SolvedTheme
6868
children?: ReactNode
6969
arrow?: boolean
70-
keepOpen?: boolean
70+
open?: boolean
7171
place?: TooltipPlacement
7272
interactive?: boolean
7373
activateOnHover?: boolean
7474
activateOnClick?: boolean
7575
noThemeChange?: boolean
76+
zIndex?: number
7677
} & (
7778
| {
7879
noDefaultStyles: false
@@ -125,16 +126,17 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
125126
noDefaultStyles: noBackground,
126127
children,
127128
arrow: drawArrow = true,
128-
keepOpen = false,
129+
open,
129130
place,
130131
interactive = false,
131132
activateOnHover = true,
132133
activateOnClick = false,
133134
noThemeChange = false,
135+
zIndex,
134136
...cardProps
135137
} = props
136138
const [isOpen, setIsOpen] = useState(false)
137-
const renderTooltip = keepOpen || isOpen
139+
const renderTooltip = typeof open === 'boolean' ? open : isOpen
138140

139141
const arrowRef = useRef(null)
140142

@@ -176,7 +178,7 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
176178
enabled: activateOnClick,
177179
}),
178180
useDismiss(context, {
179-
enabled: activateOnClick && !keepOpen,
181+
enabled: activateOnClick,
180182
}),
181183
])
182184

@@ -200,14 +202,16 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
200202
<RenderComponent
201203
ref={refs.setFloating}
202204
{...getFloatingProps({
205+
...(cardProps || {}),
203206
style: {
207+
...('style' in cardProps ? cardProps.style || {} : {}),
204208
position: strategy,
205209
top: y || 0,
206210
left: x || 0,
207211
pointerEvents: interactive ? 'auto' : 'none',
212+
zIndex,
208213
},
209214
})}
210-
{...cardProps}
211215
transition={{ duration: 0.2, ease: 'easeInOut' }}
212216
initial={{ opacity: 0, scale: 0.9 }}
213217
animate={{ opacity: 1, scale: 1 }}

0 commit comments

Comments
 (0)