diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 36a6502b..c431950a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -21,7 +21,6 @@ module.exports = { ], 'rules': { 'react/react-in-jsx-scope': 'off', - 'no-multiple-empty-lines': ['warn', {'max': 1, 'maxEOF': 1}], 'indent': ['warn', 4], 'key-spacing': ['warn', {'beforeColon': false, 'afterColon': true}], 'no-trailing-spaces': 'warn', @@ -35,6 +34,7 @@ module.exports = { 'prefer-const': 'warn', 'space-before-blocks': 'warn', 'space-before-function-paren': ['warn', 'never'], + 'react/jsx-first-prop-new-line': [1, 'multiline'], 'space-in-parens': 'warn', 'spaced-comment': 'warn', 'arrow-spacing': 'warn', diff --git a/package-lock.json b/package-lock.json index 09eb8c5d..034ed31b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@radui/ui", - "version": "0.0.11", + "version": "0.0.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@radui/ui", - "version": "0.0.11", + "version": "0.0.13", "license": "ISC", "dependencies": { "@floating-ui/react": "^0.26.2", diff --git a/package.json b/package.json index 4e9605b0..29b3b348 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,23 @@ { "name": "@radui/ui", - "version": "0.0.11", + "version": "0.0.13", "description": "", "main": "dist", "type": "module", "exports": { "./themes/default.css": "./dist/themes/default.css", - "./Avatar": "./dist/components/Avatar.js" + "./Avatar": "./dist/components/Avatar.js", + "./Badge": "./dist/components/Badge.js", + "./Button": "./dist/components/Button.js", + "./BlockQuote": "./dist/components/BlockQuote.js", + "./Em": "./dist/components/Em.js", + "./Quote": "./dist/components/Quote.js", + "./Tabs": "./dist/components/Tabs.js", + "./Text": "./dist/components/Text.js", + "./Heading": "./dist/components/Heading.js", + "./Link": "./dist/components/Link.js", + "./Code": "./dist/components/Code.js", + "./Separator": "./dist/components/Separator.js" }, "scripts": { "test": "jest", diff --git a/src/components/tools/Popper/Popper.js b/src/components/tools/Popper/Popper.js index 6b1f851a..5ae61fb9 100644 --- a/src/components/tools/Popper/Popper.js +++ b/src/components/tools/Popper/Popper.js @@ -1,7 +1,7 @@ import {useState, useRef} from 'react'; import {customClassSwitcher} from '~/core'; -import {useFloating, useInteractions, useHover, FloatingArrow, arrow, offset, flip, autoPlacement, useRole, useDismiss} from '@floating-ui/react'; +import {useFloating, useInteractions, useHover, FloatingArrow, arrow, offset, flip, autoUpdate, autoPlacement, useRole, useDismiss} from '@floating-ui/react'; // TODO : Use Floating Portal? // TODO : Collisions dont seem to be working as expected, need to investigate @@ -9,39 +9,55 @@ import {useFloating, useInteractions, useHover, FloatingArrow, arrow, offset, fl const ARROW_HEIGHT = 7; const GAP = 2; -const Popper = ({popperName='', customRootClass='', className='', children, open=false, hoverDelay=10, showArrow=true, pop=<>>, ...props}) => { - const rootClass = customClassSwitcher(customRootClass, popperName); +/** + * + * + * For Placement https://floating-ui.com/docs/computePosition#placement - const arrowRef = useRef(null); + */ + +const Popper = ({ + popperName='', + customRootClass='', + activationStrategy='hover', + className='', + placement='top', + children, + open=false, + hoverDelay=10, + showArrow=true, + pop=<>>, + ...props}) => { + // + const rootClass = customClassSwitcher(customRootClass, popperName); + const arrowRef = useRef(null); const [isOpen, setIsOpen] = useState(open); const {refs, floatingStyles, context} = useFloating({ + placement: placement, + whileElementsMounted: autoUpdate, open: isOpen, + // strategy: 'fixed', middleware: [ arrow({ element: arrowRef, }), offset(ARROW_HEIGHT + GAP), - // autoPlacement({ - // crossAxis: 'center', - // alignment: 'start', - // autoAlignment: true, - // allowedPlacements: ['top', 'bottom', 'left', 'right'], - // padding: 5, - // }), - flip(), - + flip({ + mainAxis: false, + fallbackPlacements: ['right', 'bottom'], + }, + ), ], onOpenChange: setIsOpen, - placement: 'top', }); const role = useRole(context); const dismiss = useDismiss(context); const hover = useHover(context, { - // delay: hoverDelay, + // delay: hoverDelay, }); const {getReferenceProps, getFloatingProps} = useInteractions([ @@ -51,13 +67,14 @@ const Popper = ({popperName='', customRootClass='', className='', children, open ]); return <> - { - console.log('click'); + { + console.log('click'); + }, }, - }, - )}>{children} + )}>{children} {isOpen &&