@aiquants/drag-drop-panels 0.8.0 → 0.8.1
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/README.md +81 -81
- package/dist/DragDropLayout.d.ts.map +1 -1
- package/dist/index.es.js +174 -165
- package/dist/index.umd.js +1 -1
- package/dist/styles/drag-drop-panels.standalone.css +1 -1
- package/package.json +1 -1
- package/src/DragDropLayout.spec.tsx +64 -0
- package/src/DragDropLayout.tsx +10 -1
package/README.md
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
# Drag & Drop Panel Package
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reusable Drag & Drop panel layout component package.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Package Info
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- **Name**: `@aiquants/drag-drop-panels`
|
|
8
|
+
- **Location**: `/workspace/packages/drag-drop-panels`
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Features
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- FLIP
|
|
19
|
-
-
|
|
20
|
-
-
|
|
12
|
+
- Multi-column Drag & Drop layouts
|
|
13
|
+
- Panel reordering
|
|
14
|
+
- Panel movement across columns
|
|
15
|
+
- Column width resizing
|
|
16
|
+
- Panel visibility toggle
|
|
17
|
+
- Custom drag handler support
|
|
18
|
+
- FLIP animations
|
|
19
|
+
- Edge scrolling support
|
|
20
|
+
- Debug overlay
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Installation
|
|
23
23
|
|
|
24
|
-
```
|
|
24
|
+
```jsonc
|
|
25
|
+
// consumer package.json
|
|
25
26
|
{
|
|
26
27
|
"dependencies": {
|
|
27
|
-
|
|
28
|
+
"@aiquants/drag-drop-panels": "workspace:*"
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
```
|
|
@@ -33,39 +34,42 @@
|
|
|
33
34
|
pnpm install
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
##
|
|
37
|
+
## Usage
|
|
37
38
|
|
|
38
|
-
### CSS
|
|
39
|
+
### CSS Integration
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
Structural styles (layouts, resize handles) are required for all hosts. Ships plain CSS without `:root` theme variables, Tailwind utilities, or preflight:
|
|
41
42
|
|
|
42
|
-
- `@aiquants/drag-drop-panels/css` (`./css` export
|
|
43
|
+
- `@aiquants/drag-drop-panels/css` (`./css` export, `dist/drag-drop-panels.css`) - Structural layout styles (import in JS or load per route via `?url`).
|
|
43
44
|
|
|
44
|
-
JSX
|
|
45
|
+
Tailwind utilities in JSX depend on the host environment:
|
|
45
46
|
|
|
46
|
-
- **Tailwind v4
|
|
47
|
+
- **Tailwind v4 Host**: Add the package `src` directory to your scan targets to generate utilities in your host build:
|
|
47
48
|
|
|
48
49
|
```css
|
|
49
50
|
/* app tailwind.css */
|
|
50
51
|
@source "../node_modules/@aiquants/drag-drop-panels/src/**/*.{ts,tsx}";
|
|
51
|
-
/*
|
|
52
|
+
/* monorepo: @source "../../../../packages/drag-drop-panels/src/**/*.{ts,tsx}"; */
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
-
|
|
55
|
+
- **Non-Tailwind Host**: Import the self-contained standalone CSS bundle (`pnpm run build:css` → `dist/styles/drag-drop-panels.standalone.css`):
|
|
55
56
|
|
|
56
57
|
```css
|
|
57
58
|
@import "@aiquants/drag-drop-panels/styles/drag-drop-panels.standalone.css";
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
Dark mode activates based on the `.dark` class on `<html>`.
|
|
62
|
+
|
|
63
|
+
### Basic Usage Example
|
|
61
64
|
|
|
62
65
|
```tsx
|
|
63
66
|
import { DragDropLayout } from "@aiquants/drag-drop-panels"
|
|
64
|
-
import type { ColumnConfig
|
|
67
|
+
import type { ColumnConfig } from "@aiquants/drag-drop-panels"
|
|
65
68
|
import "@aiquants/drag-drop-panels/css"
|
|
69
|
+
import { useState } from "react"
|
|
66
70
|
|
|
67
71
|
function MyApp() {
|
|
68
|
-
//
|
|
72
|
+
// Column configuration
|
|
69
73
|
const columns: ColumnConfig[] = [
|
|
70
74
|
{
|
|
71
75
|
id: "column-1",
|
|
@@ -77,18 +81,18 @@ function MyApp() {
|
|
|
77
81
|
},
|
|
78
82
|
]
|
|
79
83
|
|
|
80
|
-
//
|
|
84
|
+
// Panel ID layout per column
|
|
81
85
|
const [columnPanels, setColumnPanels] = useState({
|
|
82
86
|
column1: ["panel1", "panel2"],
|
|
83
87
|
})
|
|
84
88
|
|
|
85
|
-
//
|
|
89
|
+
// Panel visibility
|
|
86
90
|
const [panelVisibility, setPanelVisibility] = useState({
|
|
87
91
|
panel1: true,
|
|
88
92
|
panel2: true,
|
|
89
93
|
})
|
|
90
94
|
|
|
91
|
-
//
|
|
95
|
+
// Panel component mapping
|
|
92
96
|
const panelComponentMap = {
|
|
93
97
|
panel1: { component: MyPanel1, title: "Panel 1" },
|
|
94
98
|
panel2: { component: MyPanel2, title: "Panel 2" },
|
|
@@ -108,61 +112,61 @@ function MyApp() {
|
|
|
108
112
|
}
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
##
|
|
115
|
+
## Demo App
|
|
112
116
|
|
|
113
|
-
|
|
117
|
+
You can view the interactive demo in the web application.
|
|
114
118
|
|
|
115
|
-
###
|
|
119
|
+
### Running the Demo
|
|
116
120
|
|
|
117
|
-
1.
|
|
121
|
+
1. Start the web application:
|
|
118
122
|
|
|
119
123
|
```bash
|
|
120
124
|
cd /workspace/apps/quants-react-router
|
|
121
125
|
pnpm dev
|
|
122
126
|
```
|
|
123
127
|
|
|
124
|
-
2.
|
|
128
|
+
2. Open the following URL in your browser:
|
|
125
129
|
|
|
126
130
|
```text
|
|
127
131
|
http://localhost:5173/drag-drop-demo
|
|
128
132
|
```
|
|
129
133
|
|
|
130
|
-
###
|
|
134
|
+
### Demo Features
|
|
131
135
|
|
|
132
|
-
- 3
|
|
133
|
-
- 4
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
136
|
+
- 3-column layout
|
|
137
|
+
- 4 sample panels
|
|
138
|
+
- Drag & Drop panel movement
|
|
139
|
+
- Column width resizing
|
|
140
|
+
- Panel visibility toggles
|
|
137
141
|
|
|
138
|
-
## API
|
|
142
|
+
## API Reference
|
|
139
143
|
|
|
140
144
|
### DragDropLayout Props
|
|
141
145
|
|
|
142
|
-
|
|
|
146
|
+
| Property | Type | Required | Description |
|
|
143
147
|
| --- | --- | --- | --- |
|
|
144
|
-
| `columns` | `ColumnConfig[]` | ✓ |
|
|
145
|
-
| `columnPanels` | `Record<string, string[]>` | ✓ |
|
|
146
|
-
| `onColumnPanelsChange` | `(panels: Record<string, string[]>) => void` | ✓ |
|
|
147
|
-
| `panelVisibility` | `Record<string, boolean>` | ✓ |
|
|
148
|
-
| `onPanelVisibilityChange` | `(visibility: Record<string, boolean>) => void` | ✓ |
|
|
149
|
-
| `panelComponentMap` | `Record<string, PanelConfig>` | ✓ |
|
|
150
|
-
| `columnWidths` | `Record<string, number>` | - |
|
|
151
|
-
| `onColumnWidthsChange` | `(widths: Record<string, number>) => void` | - |
|
|
152
|
-
| `enableResize` | `boolean` | - |
|
|
153
|
-
| `debugConfig` | `DebugConfig` | - |
|
|
148
|
+
| `columns` | `ColumnConfig[]` | ✓ | Column configurations array |
|
|
149
|
+
| `columnPanels` | `Record<string, string[]>` | ✓ | Panel IDs map per column key |
|
|
150
|
+
| `onColumnPanelsChange` | `(panels: Record<string, string[]>) => void` | ✓ | Panel placement change callback |
|
|
151
|
+
| `panelVisibility` | `Record<string, boolean>` | ✓ | Panel visibility map |
|
|
152
|
+
| `onPanelVisibilityChange` | `(visibility: Record<string, boolean>) => void` | ✓ | Visibility change callback |
|
|
153
|
+
| `panelComponentMap` | `Record<string, PanelConfig>` | ✓ | Component registry map for panel keys |
|
|
154
|
+
| `columnWidths` | `Record<string, number>` | - | Column width overrides |
|
|
155
|
+
| `onColumnWidthsChange` | `(widths: Record<string, number>) => void` | - | Column width change callback |
|
|
156
|
+
| `enableResize` | `boolean` | - | Enables column resizing (default: false) |
|
|
157
|
+
| `debugConfig` | `DebugConfig` | - | Debug overlay settings |
|
|
154
158
|
|
|
155
159
|
### ColumnConfig
|
|
156
160
|
|
|
157
161
|
```typescript
|
|
158
162
|
interface ColumnConfig {
|
|
159
|
-
id: string //
|
|
160
|
-
key: string //
|
|
161
|
-
initialWidth?: number //
|
|
162
|
-
minWidth?: number //
|
|
163
|
-
maxWidth?: number //
|
|
164
|
-
resizable?: boolean //
|
|
165
|
-
className?: string //
|
|
163
|
+
id: string // Unique column ID
|
|
164
|
+
key: string // Column key (referenced in columnPanels)
|
|
165
|
+
initialWidth?: number // Initial width in px
|
|
166
|
+
minWidth?: number // Minimum width in px
|
|
167
|
+
maxWidth?: number // Maximum width in px
|
|
168
|
+
resizable?: boolean // Whether column is resizable
|
|
169
|
+
className?: string // Custom CSS class
|
|
166
170
|
}
|
|
167
171
|
```
|
|
168
172
|
|
|
@@ -170,39 +174,35 @@ interface ColumnConfig {
|
|
|
170
174
|
|
|
171
175
|
```typescript
|
|
172
176
|
interface PanelConfig {
|
|
173
|
-
component: ComponentType //
|
|
174
|
-
title: string //
|
|
175
|
-
props?: Record<string, unknown> //
|
|
177
|
+
component: ComponentType // Panel component reference
|
|
178
|
+
title: string // Panel title
|
|
179
|
+
props?: Record<string, unknown> // Props passed to component
|
|
176
180
|
}
|
|
177
181
|
```
|
|
178
182
|
|
|
179
|
-
##
|
|
183
|
+
## Build
|
|
180
184
|
|
|
181
185
|
```bash
|
|
182
186
|
cd /workspace/packages/drag-drop-panels
|
|
183
187
|
pnpm build
|
|
184
188
|
```
|
|
185
189
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
- `dist/index.es.js` - ES モジュール
|
|
189
|
-
- `dist/index.umd.js` - UMD モジュール
|
|
190
|
-
- `dist/index.d.ts` - TypeScript 型定義
|
|
191
|
-
- `dist/drag-drop-panels.css` - 構造系スタイルシート (`./css` export、実質 Artifact A)
|
|
192
|
-
- `dist/styles/drag-drop-panels.standalone.css` - 非 Tailwind ホスト向けの自己完結 CSS (構造系 + 全ユーティリティ、`./styles/drag-drop-panels.standalone.css` export、`pnpm run build:css` で生成)
|
|
193
|
-
|
|
194
|
-
## 開発
|
|
190
|
+
Build outputs:
|
|
195
191
|
|
|
196
|
-
|
|
192
|
+
- `dist/index.es.js` - ES module
|
|
193
|
+
- `dist/index.umd.js` - UMD module
|
|
194
|
+
- `dist/index.d.ts` - TypeScript type definitions
|
|
195
|
+
- `dist/drag-drop-panels.css` - Structural stylesheet (`./css` export)
|
|
196
|
+
- `dist/styles/drag-drop-panels.standalone.css` - Standalone CSS for non-Tailwind hosts
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
2. ビルド: `pnpm build`
|
|
200
|
-
3. `quants-react-router` でテスト
|
|
198
|
+
## Development
|
|
201
199
|
|
|
202
|
-
###
|
|
200
|
+
### Modifying Package
|
|
203
201
|
|
|
204
|
-
|
|
202
|
+
1. Edit source files in `/workspace/packages/drag-drop-panels/src`
|
|
203
|
+
2. Build: `pnpm build`
|
|
204
|
+
3. Test in application
|
|
205
205
|
|
|
206
|
-
##
|
|
206
|
+
## License
|
|
207
207
|
|
|
208
208
|
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropLayout.d.ts","sourceRoot":"","sources":["../src/DragDropLayout.tsx"],"names":[],"mappings":"AAWA,OAAO,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,SAAS,EAAE,qBAAqB,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhP;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