npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hiui-popper

v0.0.3

Published

基础弹层组件

Downloads

2

Readme

Popper

基础弹层组件

快速使用

依附元素

import Popper from "@hi-ui/hiui/es/popper"
import React, { useState, useRef } from "react"
const demo = () => {
  const PopperAttachEle = useRef()
  const [showPopper, setShowPopper] = useState(false)
  return (
    <div>
      <div ref={PopperAttachEle}>popper-attachEle</div>
      <Popper
        // 弹出层的显示隐藏
        show={showPopper}
        // 依附的元素
        attachEle={PopperAttachEle.current}
        // 点击弹出层以及依附元素以外的区域时会触发该回调
        onClickOutside={() => {
          setShowPopper(false)
        }}
      >
        <div className='popper-content'>Popper Content</div>
      </Popper>
    </div>
  )
}

无依附元素

import Popper from "@hi-ui/hiui/es/popper"
import React, { useState, useRef } from react
const demo = () => {
  const [showPopper, setShowPopper] = useState(false)
  return (
    <div>
      <Popper
        // 弹出层的显示隐藏
        show={showPopper}
        left={20}
        top={20}
        // 点击弹出层以及依附元素以外的区域时会触发该回调
        onClickOutside={() => {
          setShowPopper(false)
        }}
      >
        <div className="popper-content">Popper Content</div>
      </Popper>
    </div>
  )
}

Props

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | --------- | -------------------------------------------------------------------------------------------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | | show | 弹出层显示隐藏 | boolean | - | false | | attachEle | 依附元素,会自动显示到该元素下方,并跟随自动 | HTMLElement | - | - | | container | 弹出层依赖定位的元素,也就是弹出层参考定位的元素 | HTMLElement | - | - | | width | 弹层宽度,如果存在attachEle参数且宽度未传入的情况下,会根据attachEle的宽度进行计算,其他情况请传入宽度 | number | string | bool | - | - | | topGap | 距离依附元素的上偏移量,存在 attachEle 属性时有效, | number | 0 | 0 | | leftGap | 距离依附元素的左偏移量,存在 attachEle 属性时有效, | number | 0 | 0 | | zIndex | 堆叠顺序 | number | - | 1060 | | placement | 位于依附元素的方位 | string | bottom | bottom-start | bottom-end | top | top-start | top-end | left | left-start | left-end | right | right-start | right-end | top-bottom-start(使用该属性会自动根据依附元素距离可视区域自动翻转) | top-bottom | left-right | left-right-start | bottom-start |

Events

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ------------------- | --------------------------------------------------------------------- | --------------------- | ------ | ------------------- | | onClickOutside | 点击该元素外的回调方法 | function | - | - | | setOverlayContainer | 如遇到菜单滚动定位问题,试试修改为滚动的区域,并相对其定位 (3.0 新增) | function(triggerNode) | - | () => document.body |