@aiquants/drag-drop-panels
v0.3.0
Published
Reusable drag-and-drop panel layout components and utilities
Readme
Drag & Drop Panel Package
再利用可能な Drag & Drop パネルレイアウトコンポーネントパッケージです。
パッケージ情報
- 名前:
@aiquants/drag-drop-panels - バージョン: 0.1.0
- 場所:
/workspace/packages/drag-drop-panels
機能
- 複数カラムのドラッグ&ドロップレイアウト
- パネルの並び替え
- カラム間でのパネル移動
- カラム幅のリサイズ
- パネルの表示/非表示切り替え
- カスタムドラッグハンドラーのサポート
- FLIP アニメーション
- エッジスクロール機能
- デバッグオーバーレイ
インストール
{
"dependencies": {
"@aiquants/drag-drop-panels": "workspace:*"
}
}pnpm install使用方法
基本的な使用例
import { DragDropLayout } from "@aiquants/drag-drop-panels"
import type { ColumnConfig, DragOverPosition } from "@aiquants/drag-drop-panels"
import "@aiquants/drag-drop-panels/dist/drag-drop-panels.css"
function MyApp() {
// カラム設定
const columns: ColumnConfig[] = [
{
id: "column-1",
key: "column1",
initialWidth: 400,
minWidth: 300,
maxWidth: 600,
resizable: true,
},
]
// カラムごとのパネルID配置
const [columnPanels, setColumnPanels] = useState({
column1: ["panel1", "panel2"],
})
// パネルの可視性
const [panelVisibility, setPanelVisibility] = useState({
panel1: true,
panel2: true,
})
// パネルコンポーネントのマッピング
const panelComponentMap = {
panel1: { component: MyPanel1, title: "Panel 1" },
panel2: { component: MyPanel2, title: "Panel 2" },
}
return (
<DragDropLayout
columns={columns}
columnPanels={columnPanels}
onColumnPanelsChange={setColumnPanels}
panelVisibility={panelVisibility}
onPanelVisibilityChange={setPanelVisibility}
panelComponentMap={panelComponentMap}
enableResize={true}
/>
)
}デモページ
quants-react-router アプリケーションでデモページを確認できます。
デモページへのアクセス
quants-react-routerを起動:
cd /workspace/apps/quants-react-router
pnpm dev- ブラウザで以下の URL にアクセス:
http://localhost:5173/drag-drop-demoデモページの機能
- 3 カラムのレイアウト
- 4 つのサンプルパネル
- ドラッグ&ドロップによるパネル移動
- カラム幅のリサイズ
- パネルの表示/非表示切り替え
API リファレンス
DragDropLayout Props
| プロパティ | 型 | 必須 | 説明 |
|-----------|-----|------|------|
| columns | ColumnConfig[] | ✓ | カラムの設定配列 |
| columnPanels | Record<string, string[]> | ✓ | カラムごとのパネル ID 配列 |
| onColumnPanelsChange | (panels: Record<string, string[]>) => void | ✓ | パネル配置変更時のコールバック |
| panelVisibility | Record<string, boolean> | ✓ | パネルの可視性 |
| onPanelVisibilityChange | (visibility: Record<string, boolean>) => void | ✓ | 可視性変更時のコールバック |
| panelComponentMap | Record<string, PanelConfig> | ✓ | パネルコンポーネントのマッピング |
| columnWidths | Record<string, number> | - | カラム幅 |
| onColumnWidthsChange | (widths: Record<string, number>) => void | - | カラム幅変更時のコールバック |
| enableResize | boolean | - | リサイズ機能の有効化 (デフォルト: false) |
| debugConfig | DebugConfig | - | デバッグ設定 |
ColumnConfig
interface ColumnConfig {
id: string // カラムの一意な ID
key: string // カラムのキー (columnPanels で使用)
initialWidth?: number // 初期幅 (px)
minWidth?: number // 最小幅 (px)
maxWidth?: number // 最大幅 (px)
resizable?: boolean // リサイズ可能かどうか
className?: string // カスタム CSS クラス
}PanelConfig
interface PanelConfig {
component: ComponentType // パネルのコンポーネント
title: string // パネルのタイトル
props?: Record<string, unknown> // コンポーネントに渡す props
}ビルド
cd /workspace/packages/drag-drop-panels
pnpm buildビルド出力:
dist/index.es.js- ES モジュールdist/index.umd.js- UMD モジュールdist/index.d.ts- TypeScript 型定義dist/drag-drop-panels.css- スタイルシート
開発
パッケージの修正
/workspace/packages/drag-drop-panels/srcでソースを編集- ビルド:
pnpm build quants-react-routerでテスト
既知の問題
現時点では特にありません。
ライセンス
MIT
