@deadragdoll/reactnu 0.1.49 → 0.1.52
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 +2 -0
- package/dist/components/DragDrop/NuDragDropProvider.d.ts +46 -0
- package/dist/components/DragDrop/index.d.ts +1 -0
- package/dist/components/IconGrid/NuIconGrid.d.ts +10 -3
- package/dist/components/ListBox/ListBox.d.ts +11 -2
- package/dist/components/ListBox/internals/ListBoxGroupView.d.ts +4 -1
- package/dist/components/ListBox/internals/ListBoxItemView.d.ts +4 -1
- package/dist/components/TreeListView/TreeListView.d.ts +11 -2
- package/dist/components/TreeListView/internals/TreeListViewRow.d.ts +4 -1
- package/dist/index.cjs +1049 -795
- package/dist/index.d.ts +1 -0
- package/dist/index.js +831 -576
- package/docs/API_REFERENCE.md +9 -0
- package/docs/COMPONENT_INDEX.md +2 -0
- package/docs/GETTING_STARTED.md +2 -1
- package/docs/IconGrid.md +5 -0
- package/docs/ListBox.md +7 -0
- package/docs/NuDragDropProvider.md +43 -0
- package/docs/NuThemeProvider.md +1 -1
- package/docs/TreeListView.md +7 -0
- package/package.json +1 -1
package/docs/API_REFERENCE.md
CHANGED
|
@@ -21,6 +21,10 @@ See: [Slot Customization](./SLOT_CUSTOMIZATION.md)
|
|
|
21
21
|
|
|
22
22
|
- `NuThemeProvider`
|
|
23
23
|
docs: [NuThemeProvider](./NuThemeProvider.md)
|
|
24
|
+
- `NuDragDropProvider`
|
|
25
|
+
coordinates application-owned transfers among `NuIconGrid`, `ListBox`, and
|
|
26
|
+
`TreeListView`
|
|
27
|
+
docs: [NuDragDropProvider](./NuDragDropProvider.md)
|
|
24
28
|
- `NuDesktop`
|
|
25
29
|
docs: [Desktop](./Desktop.md)
|
|
26
30
|
- `Dashboard`
|
|
@@ -41,6 +45,9 @@ See: [Slot Customization](./SLOT_CUSTOMIZATION.md)
|
|
|
41
45
|
also exposes `showMessageBox(...)` and `showInputBox(...)`
|
|
42
46
|
- `useNuIconManager()`
|
|
43
47
|
manages icons inside a `NuIconProvider`
|
|
48
|
+
- `useNuDragDrop()`
|
|
49
|
+
internal integration hook for custom shared drag sources and targets; most
|
|
50
|
+
applications should use component props from [Shared Drag and Drop](./NuDragDropProvider.md)
|
|
44
51
|
- `usePopupMenu()`
|
|
45
52
|
anchor/open helper for `PopupMenu`
|
|
46
53
|
- `useWindowMenu()`
|
|
@@ -91,6 +98,8 @@ See: [Slot Customization](./SLOT_CUSTOMIZATION.md)
|
|
|
91
98
|
docs: [TreeView](./TreeView.md)
|
|
92
99
|
- `TreeListView`
|
|
93
100
|
docs: [TreeListView](./TreeListView.md)
|
|
101
|
+
- Shared drag-and-drop contract
|
|
102
|
+
docs: [NuDragDropProvider](./NuDragDropProvider.md)
|
|
94
103
|
|
|
95
104
|
## Layout And Surfaces
|
|
96
105
|
|
package/docs/COMPONENT_INDEX.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
- [Contributor Guide](./CONTRIBUTOR_GUIDE.md)
|
|
9
9
|
- [Slot Customization](./SLOT_CUSTOMIZATION.md)
|
|
10
10
|
- [Storybook](./STORYBOOK.md)
|
|
11
|
+
- [Shared Drag and Drop](./NuDragDropProvider.md)
|
|
11
12
|
|
|
12
13
|
## Core Components
|
|
13
14
|
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
## Providers
|
|
59
60
|
|
|
61
|
+
- [NuDragDropProvider](./NuDragDropProvider.md)
|
|
60
62
|
- [NuThemeProvider](./NuThemeProvider.md)
|
|
61
63
|
- [NuAppHostProvider](./NuAppHostProvider.md)
|
|
62
64
|
|
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -49,7 +49,8 @@ export function App() {
|
|
|
49
49
|
## Recommended Order
|
|
50
50
|
|
|
51
51
|
1. `NuThemeProvider`
|
|
52
|
-
2. `
|
|
52
|
+
2. `NuDragDropProvider` when ListBox, TreeListView, or IconGrid need to exchange items
|
|
53
|
+
3. `NuDesktop`
|
|
53
54
|
3. host-driven `appBar`
|
|
54
55
|
4. workspace content
|
|
55
56
|
5. open windows through `useNuWindowManager()`
|
package/docs/IconGrid.md
CHANGED
|
@@ -71,6 +71,11 @@ function Applications() {
|
|
|
71
71
|
the target first and may return `false` to reject the transfer;
|
|
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
|
+
- Within `NuDragDropProvider`, use `acceptsDrop(item)` and `onDrop(item,
|
|
75
|
+
context)` to accept application-defined items from `ListBox` or
|
|
76
|
+
`TreeListView`. `onDragOut(item)` runs when an icon is accepted by one of
|
|
77
|
+
those non-icon targets. The existing `accepts(icon)` API remains specific to
|
|
78
|
+
icon-to-icon transfers.
|
|
74
79
|
|
|
75
80
|
`useNuIconManager()`
|
|
76
81
|
|
package/docs/ListBox.md
CHANGED
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
- `onItemCheckChange?: (item, group, checked) => void`
|
|
22
22
|
- `onItemDoubleClick?: (item, group) => void`
|
|
23
23
|
- `onPopupMenu?: (event, item, group) => void`
|
|
24
|
+
- `getDragItem?: (item, group) => NuDragDropItem | false`
|
|
25
|
+
- `onItemDragOut?: (item, group) => void`
|
|
26
|
+
- `acceptsDrop?: (item) => boolean`
|
|
27
|
+
- `onDrop?: (item, context) => boolean | void`
|
|
24
28
|
- `rightCheckBox?: boolean`
|
|
25
29
|
- `emptyText?: string`
|
|
26
30
|
|
|
@@ -37,3 +41,6 @@
|
|
|
37
41
|
- Right-clicking an enabled item activates it, prevents the browser context menu,
|
|
38
42
|
and calls `onPopupMenu`. Use the event coordinates to open an application-owned
|
|
39
43
|
`PopupMenu` or another contextual action surface.
|
|
44
|
+
- Inside `NuDragDropProvider`, `getDragItem` makes rows draggable. The
|
|
45
|
+
application decides accepted data in `acceptsDrop` and updates its collection
|
|
46
|
+
in `onDrop` / `onItemDragOut`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# NuDragDropProvider
|
|
2
|
+
|
|
3
|
+
`NuDragDropProvider` coordinates pointer drag-and-drop between `NuIconGrid`,
|
|
4
|
+
`ListBox`, and `TreeListView`. It carries an application-defined item; it does
|
|
5
|
+
not mutate the host application's list or tree data.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
<NuDragDropProvider>
|
|
9
|
+
<ListBox
|
|
10
|
+
data={receivers}
|
|
11
|
+
getDragItem={(item, group) => ({
|
|
12
|
+
type: "receiver",
|
|
13
|
+
id: String(item.id),
|
|
14
|
+
data: { group: group.category?.text ?? "ungrouped", receiver: item }
|
|
15
|
+
})}
|
|
16
|
+
onItemDragOut={(item) => removeReceiver(String(item.id))}
|
|
17
|
+
/>
|
|
18
|
+
<TreeListView
|
|
19
|
+
acceptsDrop={(drag) => drag.type === "receiver"}
|
|
20
|
+
columns={columns}
|
|
21
|
+
data={groups}
|
|
22
|
+
onDrop={(drag) => {
|
|
23
|
+
assignReceiverToSelectedGroup(drag.data);
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
</NuDragDropProvider>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Contract
|
|
30
|
+
|
|
31
|
+
- A source uses `getDragItem` to opt a displayed item into dragging. Return a
|
|
32
|
+
stable `type`, an ID, and any host payload in `data`.
|
|
33
|
+
- A target uses `acceptsDrop(item)` to filter drag item types and `onDrop` to
|
|
34
|
+
perform its own state update. Returning `false` rejects the transfer.
|
|
35
|
+
- `onItemDragOut` / `onDragOut` run only after a target accepted the item;
|
|
36
|
+
remove or update the source data there.
|
|
37
|
+
- `NuIconGrid` keeps `accepts(icon)`, `onIconDrop`, and `onIconMoveOut` for
|
|
38
|
+
its existing icon-to-icon transfer. Its `acceptsDrop` and `onDrop` receive
|
|
39
|
+
non-icon shared drag items.
|
|
40
|
+
|
|
41
|
+
Wrap every source and target that should interact in the same provider. A
|
|
42
|
+
fallback coordinator preserves existing unwrapped IconGrid transfers, but a
|
|
43
|
+
provider gives the application an explicit DnD scope.
|
package/docs/NuThemeProvider.md
CHANGED
|
@@ -63,7 +63,7 @@ Supported props:
|
|
|
63
63
|
|
|
64
64
|
- Built-in themes are `classic` (default), `amber`, `phosphor`, `midnight`, and
|
|
65
65
|
`grayscale`.
|
|
66
|
-
- `midnight` is a
|
|
66
|
+
- `midnight` is a dark slate-blue palette with blue chrome and a burnt-orange focus accent.
|
|
67
67
|
- `grayscale` is a high-contrast monochrome monitor palette. Semantic button variants use brightness rather than hue.
|
|
68
68
|
- Theme tokens drive desktop, windowing, controls, selection, and inactive overlays.
|
|
69
69
|
- Provider typography affects preview content, managed windows, dialogs, menus, and popup portals rendered inside the theme scope.
|
package/docs/TreeListView.md
CHANGED
|
@@ -55,6 +55,10 @@ const columns: TreeListColumn<Node>[] = [
|
|
|
55
55
|
- `onItemSelect`
|
|
56
56
|
- `onItemDoubleClick`
|
|
57
57
|
- `onPopupMenu`
|
|
58
|
+
- `getDragItem`
|
|
59
|
+
- `onItemDragOut`
|
|
60
|
+
- `acceptsDrop`
|
|
61
|
+
- `onDrop`
|
|
58
62
|
- `onItemCheckChange`
|
|
59
63
|
- `onExpandedIdsChange`
|
|
60
64
|
- `onActiveItemChange`
|
|
@@ -87,3 +91,6 @@ const columns: TreeListColumn<Node>[] = [
|
|
|
87
91
|
`onPopupMenu(event, item, context)`. `context` has the same `depth`, `isLeaf`,
|
|
88
92
|
`item`, and `rowIndex` fields as `getCellContent`; the host owns rendering the
|
|
89
93
|
resulting menu.
|
|
94
|
+
- Inside `NuDragDropProvider`, rows may produce shared drag items through
|
|
95
|
+
`getDragItem`; the host filters and applies incoming items with
|
|
96
|
+
`acceptsDrop` and `onDrop`.
|