Socket
Book a DemoInstallSign in
Socket

@cubetiq/antd-modal

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cubetiq/antd-modal

Modal from Ant Design, draggable, resizable.

latest
Source
npmnpm
Version
0.0.1-alpha.3
Version published
Maintainers
2
Created
Source

Ant Design Draggable Modal

Modal from Ant Design, draggable, resizable.

Version Downloads BundlePhobia MIT License Watch on GitHub Star on GitHub

Example of @cubetiq/antd-modal.

🌎 Example

Required

  • Ant Design 5.x
  • React 18.x

✨ Features

  • Drag with title bar.
  • Resize with handle.
  • Keep in bounds.
    • During drag.
    • During resize.
    • During resize window.
  • Multiple modals with managed zIndex.
  • Open from center.
  • Better API for using as a controlled component.
  • Open from quadrants.
  • Better escape key management.
  • Resize with option key.

✨ Enhancements

  • Ant Design 5.x
  • Modal visible to open

📦 Install

yarn add @cubetiq/antd-modal

NOTE: You must use react@18 and react-dom@18 or higher and antd@5 or higher.

🔨 Usage

import { useState, useCallback } from 'react'
import { Button } from 'antd'
import { DraggableModal, DraggableModalProvider } from '@cubetiq/antd-modal'
import '@cubetiq/antd-modal/dist/index.css'

const ModalWithButton = () => {
    const [visible, setVisible] = useState(false)
    const onOk = useCallback(() => setVisible(true), [])
    const onCancel = useCallback(() => setVisible(false), [])
    return (
        <>
            <Button onClick={onOk}>Open</Button>
            <DraggableModal open={visible} onOk={onOk} onCancel={onCancel}>
                Body text.
            </DraggableModal>
        </>
    )
}

// DraggableModalProvider manages the zIndex
// of DraggableModals rendered beneath it.
const App = () => (
    <DraggableModalProvider>
        <ModalWithButton />
        <ModalWithButton />
        <ModalWithButton />
    </DraggableModalProvider>
)

⚠️ User Experience Warning

You should probably try to design your app not to need to use this, apps should usually not be window managers.

License

MIT © DylanVann

Enhanced for Ant Design 5.x by Sambo Chea

FAQs

Package last updated on 23 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts