@startlibs/components 1.1.1 → 1.1.3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startlibs/components",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Startlibs Components",
5
5
  "main": "lib/index.cjs",
6
6
  "exports": {
@@ -86,7 +86,6 @@ export const ListItem = styled.li`
86
86
  }
87
87
  ${ifProp('hover', css`
88
88
  & > a, & > label {
89
- // background: ${props => lighten(0.53, getColor("main")(props))};
90
89
  background: ${props => transparentize(0.88, getColor("main")(props))};
91
90
  color: ${props => darken(0.03, getColor("main")(props))};
92
91
  }`)}
@@ -242,7 +241,7 @@ export class SimpleLi extends React.Component {
242
241
  }
243
242
 
244
243
  componentDidUpdate() {
245
- if (this.props.hover) {
244
+ if (this.props.hover && this.props.scrollOnHover !== false) {
246
245
  this.scrollToVisibility()
247
246
  }
248
247
  }
@@ -289,7 +288,7 @@ export class SimpleLi extends React.Component {
289
288
  }
290
289
 
291
290
  render() {
292
- const {label, layerIndex, href, linkTo, prefixWith, subMenu, icon, children, ...rest} = this.props
291
+ const {label, layerIndex, href, linkTo, prefixWith, subMenu, icon, children, scrollOnHover, ...rest} = this.props
293
292
  const Tag = (linkTo) ? Link : 'a'
294
293
  return <ListItem
295
294
  {...rest}
@@ -307,7 +306,7 @@ export class SimpleLi extends React.Component {
307
306
  }
308
307
  }
309
308
 
310
- export const Li = React.forwardRef(({emitter = mitt(), index, menuSlot, keepOpen, hover, layerIndex, hoverCursor, passTouchThrough, children, setCursorOnHover, onClick, prefixWith, linkTo, icon, label,descText,helpText, target, href, ...rest},ref) => {
309
+ export const Li = React.forwardRef(({emitter = mitt(), index, menuSlot, keepOpen, hover, layerIndex, hoverCursor, scrollOnHover, passTouchThrough, children, setCursorOnHover, onClick, prefixWith, linkTo, icon, label,descText,helpText, target, href, ...rest},ref) => {
311
310
  const nodeRef = useEnsureRef(ref)
312
311
  const tagRef = useRef()
313
312
  const subMenu = useToggle()
@@ -333,7 +332,7 @@ export const Li = React.forwardRef(({emitter = mitt(), index, menuSlot, keepOpen
333
332
  }
334
333
 
335
334
  useEffect(() => {
336
- if (hover) {
335
+ if (hover && scrollOnHover !== false) {
337
336
  try {
338
337
  const el = nodeRef.current
339
338
  const parent = el.parentElement
@@ -469,6 +468,9 @@ export const ContextMenuComponent = forwardRef((
469
468
  ) => {
470
469
  const ref = useEnsureRef(unesuredRef)
471
470
  const [hoverCursor, setHoverCursor] = useState(autoHover || sub ? 0 : -1)
471
+ // Hover vindo do mouse não deve rolar a lista: o Chrome dispara mousemove sintético
472
+ // ao fim do scroll, e o item cortado sob o cursor puxaria a lista de volta.
473
+ const hoverFromMouse = useRef(false)
472
474
  const [layerCursor, setLayerCursor] = useContextMenuSharedState(0)
473
475
 
474
476
  const [layerIndex, {getSize}] = useContextMenuLayers()
@@ -484,6 +486,7 @@ export const ContextMenuComponent = forwardRef((
484
486
 
485
487
  useEffect(() => {
486
488
  if (hoverIndex !== undefined) {
489
+ if (hoverIndex !== hoverCursor) hoverFromMouse.current = false
487
490
  setHoverCursor(Math.min(Math.max(hoverIndex, -1), getTotalKeyboardItems(children) + 1))
488
491
  }
489
492
  }, [hoverIndex !== hoverCursor])
@@ -510,6 +513,7 @@ export const ContextMenuComponent = forwardRef((
510
513
  const direction = e.keyCode - 39
511
514
  const max = getTotalKeyboardItems(children)
512
515
  const newIndex = (hoverCursor + direction + max) % max
516
+ hoverFromMouse.current = false
513
517
  setHoverCursor(newIndex)
514
518
  onHover(newIndex)
515
519
  }
@@ -532,6 +536,7 @@ export const ContextMenuComponent = forwardRef((
532
536
  }
533
537
 
534
538
  const setCursorOnHover = (index) => {
539
+ hoverFromMouse.current = true
535
540
  setLayerCursor(layerIndex)
536
541
  setHoverCursor(index)
537
542
  onHover(index)
@@ -548,6 +553,7 @@ export const ContextMenuComponent = forwardRef((
548
553
  fixedPosition:props.fixed,
549
554
  hover: hoverCursor === indexRef.current && layerIndex === layerCursor,
550
555
  hoverCursor: hoverCursor,
556
+ scrollOnHover: !hoverFromMouse.current,
551
557
  index: indexRef.current++,
552
558
  setCursorOnHover,
553
559
  emitter: itemsEmitter,
@@ -10,7 +10,7 @@ export const TextButton = styled(({className,isLoading,alert, fontSize, children
10
10
  </Wrapper>)`
11
11
  display: inline-block;
12
12
  font-weight: 600;
13
- font-size: ${props => props.fontSize ? fontSize : "14"}px;
13
+ font-size: ${props => props.fontSize ? props.fontSize : "14"}px;
14
14
  color: ${props => props.alert ? getColor('alert') : getColor('main')};
15
15
  cursor: pointer;
16
16
  text-decoration: none;
@@ -196,7 +196,7 @@ export const useToastNotificationToggle = (notification,timeout) => {
196
196
  open: () => toggle.get() ? toggle.get().openWith(formatNotification(notification,extraProps),timeout) : toggle.openWith(make(notification,timeout))
197
197
  }),[toggle.isOpen])
198
198
  }
199
- export const willShowToastNotification = (str) => () => showToastNotification(str)
199
+ export const willShowToastNotification = (str,timeout) => () => createToastNotification(str,timeout)
200
200
 
201
201
  const EXIT_ANIMATION_MS = 300
202
202
  const TOAST_EASING = 'cubic-bezier(0.22, 0.61, 0.36, 1)'