Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
5cb6433a
Commit
5cb6433a
authored
2 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome/dnd] more doc & lint
parent
6987c2cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/dome/renderer/newdnd.tsx
+21
-6
21 additions, 6 deletions
ivette/src/dome/renderer/newdnd.tsx
ivette/src/sandbox/usednd.tsx
+1
-1
1 addition, 1 deletion
ivette/src/sandbox/usednd.tsx
with
22 additions
and
7 deletions
ivette/src/dome/renderer/newdnd.tsx
+
21
−
6
View file @
5cb6433a
...
...
@@ -102,14 +102,14 @@ interface DropZone extends DropHandler {
node
:
HTMLElement
;
}
/**
D&D Controller.
/** D&D Controller.
This class allows to connect Drag Sources and Drop Target with each others.
You shall never use the methods of the `DnD` class directly.
The preferred way for creating `DnD` classes is to use the `useDnD()` React Hook.
*/
The preferred way for creating `DnD` classes is to use the `useDnD()`
React Hook.
*/
export
class
DnD
{
constructor
()
{
...
...
@@ -164,7 +164,7 @@ export class DnD {
const
rect
=
hover
.
node
.
getBoundingClientRect
();
const
dropX
=
Math
.
round
(
e
.
clientX
-
rect
.
left
);
const
dropY
=
Math
.
round
(
e
.
clientY
-
rect
.
top
);
const
d
=
this
.
dropping
=
{
meta
,
rect
,
dropX
,
dropY
}
const
d
=
this
.
dropping
=
{
meta
,
rect
,
dropX
,
dropY
}
;
hover
.
onDropIn
(
d
);
}
}
...
...
@@ -243,7 +243,6 @@ export interface DropTargetProps extends DropHandler {
Remark: a `<DragSource/>` also behaves as a `<DropTarget/>`
when it has Drop handler callbacks.
*/
export
function
DropTarget
(
props
:
DropTargetProps
):
JSX
.
Element
{
const
{
dnd
,
disabled
=
false
,
className
,
style
,
children
}
=
props
;
const
nodeRef
=
useDropTarget
(
dnd
,
disabled
?
undefined
:
props
);
...
...
@@ -473,6 +472,7 @@ export interface ItemProps {
children
?:
React
.
ReactNode
;
}
/** List item component. Shall only be used inside a `<List/>` component. */
export
function
Item
(
props
:
ItemProps
):
JSX
.
Element
{
//--- Ordering
const
{
dnd
,
items
,
setSource
,
setTarget
,
onStop
}
=
...
...
@@ -513,6 +513,21 @@ export interface ListProps {
children
?:
React
.
ReactNode
;
}
/** Sortable list wrapper.
This component has no DOM element on its own and shall be placed inside a
`<div/>` component with a `flex` display, typically an horizontal or vertical
Dome box.
The component wraps its <Item/> children within a local DnD context and
enable reordering them by Drag & Drop.
The behavior of the component can be _controlled_ or _uncontrolled_ whether
`items` and `setItems` properties are set or not. In controlled mode, the
`items` property is not mandatory to contains all the list elements, in which
case the missing elements would be added to the end. Notice that `setItems`
callback is only notified after drag & drop.
*/
export
function
List
(
props
:
ListProps
):
JSX
.
Element
{
const
dnd
=
useDnD
();
const
[
locals
,
setLocals
]
=
React
.
useState
<
string
[]
>
([]);
...
...
This diff is collapsed.
Click to expand it.
ivette/src/sandbox/usednd.tsx
+
1
−
1
View file @
5cb6433a
...
...
@@ -93,7 +93,7 @@ function UseDnD(): JSX.Element {
const
[
items
,
setItems
]
=
React
.
useState
<
string
[]
>
([]);
const
[
source
,
setSource
]
=
React
.
useState
(
'
--
'
);
const
[
target
,
setTarget
]
=
React
.
useState
(
'
--
'
);
const
onReset
=
()
=>
{
const
onReset
=
()
:
void
=>
{
setItems
([]);
setSource
(
'
--
'
);
setTarget
(
'
--
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment