@deadragdoll/reactnu 0.1.73 → 0.1.75
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/dist/components/DragDrop/NuDragDropProvider.d.ts +24 -17
- package/dist/components/IconGrid/NuIconGrid.d.ts +9 -5
- package/dist/components/ListBox/ListBox.d.ts +6 -4
- package/dist/components/ListBox/internals/ListBoxGroupView.d.ts +3 -2
- package/dist/components/ListBox/internals/ListBoxItemView.d.ts +3 -2
- package/dist/components/ListView/ListView.d.ts +13 -2
- package/dist/components/ListView/internals/ListViewRow.d.ts +6 -1
- package/dist/components/TreeListView/TreeListView.d.ts +8 -4
- package/dist/components/TreeListView/internals/TreeListViewRow.d.ts +3 -2
- package/dist/index.cjs +393 -382
- package/dist/index.js +653 -636
- package/docs/API_REFERENCE.md +4 -1
- package/docs/GETTING_STARTED.md +1 -1
- package/docs/IconGrid.md +4 -4
- package/docs/ListBox.md +3 -0
- package/docs/ListView.md +10 -0
- package/docs/NuDragDropProvider.md +39 -6
- package/docs/TreeListView.md +8 -0
- package/package.json +5 -1
package/docs/API_REFERENCE.md
CHANGED
|
@@ -46,8 +46,11 @@ See: [Slot Customization](./SLOT_CUSTOMIZATION.md)
|
|
|
46
46
|
- `useNuIconManager()`
|
|
47
47
|
manages icons inside a `NuIconProvider`
|
|
48
48
|
- `useNuDragDrop()`
|
|
49
|
-
|
|
49
|
+
returns the underlying react-dnd manager for advanced integration; most
|
|
50
50
|
applications should use component props from [Shared Drag and Drop](./NuDragDropProvider.md)
|
|
51
|
+
- `useNuDropTarget(element, options)`
|
|
52
|
+
registers a custom target and returns reactive `isOver`, `canDrop`, and item
|
|
53
|
+
state; docs: [NuDragDropProvider](./NuDragDropProvider.md)
|
|
51
54
|
- `usePopupMenu()`
|
|
52
55
|
anchor/open helper for `PopupMenu`
|
|
53
56
|
- `useWindowMenu()`
|
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -49,7 +49,7 @@ export function App() {
|
|
|
49
49
|
## Recommended Order
|
|
50
50
|
|
|
51
51
|
1. `NuThemeProvider`
|
|
52
|
-
2. `NuDragDropProvider` when ListBox, TreeListView, or IconGrid need to exchange items
|
|
52
|
+
2. `NuDragDropProvider` when ListBox, ListView, TreeListView, or IconGrid need to exchange items
|
|
53
53
|
3. `NuDesktop`
|
|
54
54
|
3. host-driven `appBar`
|
|
55
55
|
4. workspace content
|
package/docs/IconGrid.md
CHANGED
|
@@ -72,10 +72,10 @@ function Applications() {
|
|
|
72
72
|
`onIconMoveOut(icon, context)` runs on the source after a successful transfer.
|
|
73
73
|
`context` exposes both managers, grids, and the target `position`.
|
|
74
74
|
- Within `NuDragDropProvider`, use `acceptsDrop(item)` and `onDrop(item,
|
|
75
|
-
context)` to accept application-defined items from `ListBox` or
|
|
76
|
-
`TreeListView`. `
|
|
77
|
-
|
|
78
|
-
icon-to-icon transfers.
|
|
75
|
+
context)` to accept application-defined items from `ListBox`, `ListView`, or
|
|
76
|
+
`TreeListView`. Return `{ action: "copy" }` from that target's `onDrop`, or
|
|
77
|
+
return `false` from `onDragOut(item, result)`, to retain the source icon.
|
|
78
|
+
The existing `accepts(icon)` API remains specific to icon-to-icon transfers.
|
|
79
79
|
|
|
80
80
|
`useNuIconManager()`
|
|
81
81
|
|
package/docs/ListBox.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
- `onItemDoubleClick?: (item, group) => void`
|
|
23
23
|
- `onPopupMenu?: (event, item, group) => void`
|
|
24
24
|
- `getDragItem?: (item, group) => NuDragDropItem | false`
|
|
25
|
+
- `renderDragPreview?: (item, group) => ReactNode`
|
|
25
26
|
- `onItemDragOut?: (item, group) => void`
|
|
26
27
|
- `acceptsDrop?: (item) => boolean`
|
|
27
28
|
- `onDrop?: (item, context) => boolean | void`
|
|
@@ -44,3 +45,5 @@
|
|
|
44
45
|
- Inside `NuDragDropProvider`, `getDragItem` makes rows draggable. The
|
|
45
46
|
application decides accepted data in `acceptsDrop` and updates its collection
|
|
46
47
|
in `onDrop` / `onItemDragOut`.
|
|
48
|
+
- `renderDragPreview(item, group)` may render a compact React preview instead
|
|
49
|
+
of the full list row while dragging.
|
package/docs/ListView.md
CHANGED
|
@@ -40,6 +40,11 @@ const columns: ListViewColumn<Row>[] = [
|
|
|
40
40
|
- `selectedId`
|
|
41
41
|
- `onRowSelect`
|
|
42
42
|
- `onRowDoubleClick`
|
|
43
|
+
- `getDragItem`
|
|
44
|
+
- `onRowDragOut`
|
|
45
|
+
- `acceptsDrop`
|
|
46
|
+
- `onDrop`
|
|
47
|
+
- `renderDragPreview`
|
|
43
48
|
- `showCheckBox`
|
|
44
49
|
- `checkedIds`
|
|
45
50
|
- `onRowCheckChange`
|
|
@@ -50,6 +55,11 @@ const columns: ListViewColumn<Row>[] = [
|
|
|
50
55
|
- Keyboard navigation follows the same pattern as other list-like controls.
|
|
51
56
|
- Column titles support `&` mnemonic markup.
|
|
52
57
|
- A column can use `field` for simple value rendering or `renderCell` for custom content.
|
|
58
|
+
- `getDragItem(row)` makes a row a shared drag source. `onRowDragOut(row)` runs
|
|
59
|
+
after another target accepts it; `acceptsDrop` and `onDrop` make the list a
|
|
60
|
+
target. Wrap related controls in `NuDragDropProvider`.
|
|
61
|
+
- `renderDragPreview(row)` can return a compact React node, rather than using
|
|
62
|
+
the complete report row as the native drag preview.
|
|
53
63
|
|
|
54
64
|
## Imperative Handle
|
|
55
65
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# NuDragDropProvider
|
|
2
2
|
|
|
3
|
-
`NuDragDropProvider` coordinates
|
|
4
|
-
`ListBox`, and `TreeListView`. It
|
|
5
|
-
|
|
3
|
+
`NuDragDropProvider` coordinates native HTML5 drag-and-drop between
|
|
4
|
+
`NuIconGrid`, `ListBox`, `ListView`, and `TreeListView`. It is implemented on
|
|
5
|
+
top of `react-dnd`; it carries an application-defined item and does not mutate
|
|
6
|
+
host list or tree data.
|
|
6
7
|
|
|
7
8
|
```tsx
|
|
8
9
|
<NuDragDropProvider>
|
|
@@ -34,10 +35,42 @@ not mutate the host application's list or tree data.
|
|
|
34
35
|
perform its own state update. Returning `false` rejects the transfer.
|
|
35
36
|
- `onItemDragOut` / `onDragOut` run only after a target accepted the item;
|
|
36
37
|
remove or update the source data there.
|
|
38
|
+
- A target may return `{ action: "copy" }` from `onDrop`. `NuIconGrid` then
|
|
39
|
+
leaves its source icon in place; `{ action: "move" }` is the default. List
|
|
40
|
+
and tree sources always leave source-data mutation to their host callback.
|
|
41
|
+
- `renderDragPreview` on `ListBox`, `ListView`, and `TreeListView` renders a
|
|
42
|
+
compact React preview instead of the browser's full-row preview.
|
|
37
43
|
- `NuIconGrid` keeps `accepts(icon)`, `onIconDrop`, and `onIconMoveOut` for
|
|
38
44
|
its existing icon-to-icon transfer. Its `acceptsDrop` and `onDrop` receive
|
|
39
45
|
non-icon shared drag items.
|
|
40
46
|
|
|
41
|
-
Wrap
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
Wrap a workspace once when sources and targets must interact. The controls can
|
|
48
|
+
also mount independently, but one provider gives cross-control dragging and a
|
|
49
|
+
single custom-preview layer an explicit scope.
|
|
50
|
+
|
|
51
|
+
## Hover feedback
|
|
52
|
+
|
|
53
|
+
`useNuDropTarget(element, options)` returns reactive `{ isOver, canDrop, item
|
|
54
|
+
}` state. Use it in a custom target to render classic accept/reject feedback;
|
|
55
|
+
`onDragEnter(item, canDrop)` and `onDragLeave(item)` are available when a
|
|
56
|
+
callback fits better.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const [element, setElement] = useState<HTMLDivElement | null>(null);
|
|
60
|
+
const dropState = useNuDropTarget(element, {
|
|
61
|
+
accepts: (item) => item.type === "receiver",
|
|
62
|
+
onDrop: (item) => {
|
|
63
|
+
assignReceiver(item.data);
|
|
64
|
+
},
|
|
65
|
+
type: "receiver-group"
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
<div
|
|
69
|
+
className={dropState.isOver && dropState.canDrop ? "group group--accept" : "group"}
|
|
70
|
+
ref={setElement}
|
|
71
|
+
/>;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`NuIconGrid dropTarget` additionally registers a bounded desktop fallback, so
|
|
75
|
+
an icon grid behind managed windows can accept an item dropped anywhere inside
|
|
76
|
+
its own bounds without intercepting normal pointer interaction.
|
package/docs/TreeListView.md
CHANGED
|
@@ -44,6 +44,8 @@ const columns: TreeListColumn<Node>[] = [
|
|
|
44
44
|
## Key Props
|
|
45
45
|
|
|
46
46
|
- `columns`
|
|
47
|
+
- `columnStoreKey` — stores user-resized widths under `reactnu.<key>` in
|
|
48
|
+
`localStorage`
|
|
47
49
|
- `data`
|
|
48
50
|
- `getCellContent`
|
|
49
51
|
- `dataVersion`
|
|
@@ -56,6 +58,7 @@ const columns: TreeListColumn<Node>[] = [
|
|
|
56
58
|
- `onItemDoubleClick`
|
|
57
59
|
- `onPopupMenu`
|
|
58
60
|
- `getDragItem`
|
|
61
|
+
- `renderDragPreview`
|
|
59
62
|
- `onItemDragOut`
|
|
60
63
|
- `acceptsDrop`
|
|
61
64
|
- `onDrop`
|
|
@@ -87,6 +90,9 @@ const columns: TreeListColumn<Node>[] = [
|
|
|
87
90
|
- Columns auto-size from visible content by default.
|
|
88
91
|
- `minWidth` sets a lower bound for auto-sized and resized columns.
|
|
89
92
|
- Columns are resizable unless `resizable={false}` is set on a column.
|
|
93
|
+
- Give `columnStoreKey` a stable, application-owned name to restore a user's
|
|
94
|
+
resized widths on the next mount. Missing, malformed, or unavailable browser
|
|
95
|
+
storage falls back to the column definitions without throwing.
|
|
90
96
|
- Right-clicking an enabled row activates it and calls
|
|
91
97
|
`onPopupMenu(event, item, context)`. `context` has the same `depth`, `isLeaf`,
|
|
92
98
|
`item`, and `rowIndex` fields as `getCellContent`; the host owns rendering the
|
|
@@ -94,3 +100,5 @@ const columns: TreeListColumn<Node>[] = [
|
|
|
94
100
|
- Inside `NuDragDropProvider`, rows may produce shared drag items through
|
|
95
101
|
`getDragItem`; the host filters and applies incoming items with
|
|
96
102
|
`acceptsDrop` and `onDrop`.
|
|
103
|
+
- `renderDragPreview(item, context)` may return a compact React preview, such
|
|
104
|
+
as a name chip, instead of the complete multi-column row.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deadragdoll/reactnu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.75",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React components with a precise DOS-era utility interface.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,5 +51,9 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^19.2.0",
|
|
53
53
|
"react-dom": "^19.2.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"react-dnd": "^16.0.1",
|
|
57
|
+
"react-dnd-html5-backend": "^16.0.1"
|
|
54
58
|
}
|
|
55
59
|
}
|