-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:IQSS/dataverse-frontend into 456…
…-localstack-s3-env
- Loading branch information
Showing
97 changed files
with
7,898 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
**What this PR does / why we need it**: | ||
## What this PR does / why we need it: | ||
|
||
**Which issue(s) this PR closes**: | ||
## Which issue(s) this PR closes: | ||
|
||
Closes # | ||
- Closes # | ||
|
||
**Special notes for your reviewer**: | ||
## Special notes for your reviewer: | ||
|
||
**Suggestions on how to test this**: | ||
## Suggestions on how to test this: | ||
|
||
**Does this PR introduce a user interface change? If mockups are available, please link/include them here**: | ||
## Does this PR introduce a user interface change? If mockups are available, please link/include them here: | ||
|
||
**Is there a release notes update needed for this change?**: | ||
## Is there a release notes update needed for this change?: | ||
|
||
**Additional documentation**: | ||
## Additional documentation: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |
- **FormTextArea:** extend Props Interface to accept `autoFocus` prop. | ||
- **FormSelect:** extend Props Interface to accept `autoFocus` prop. | ||
- **Stack:** NEW Stack element to manage layouts. | ||
- **TransferList:** NEW TransferList component to transfer items between two list, also sortable. | ||
- **Table:** extend Props Interface to accept `bordered` prop to add or remove borders on all sides of the table and cells. Defaults to true. | ||
|
||
# [1.1.0](https://github.com/IQSS/dataverse-frontend/compare/@iqss/[email protected]...@iqss/[email protected]) (2024-03-12) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/design-system/src/lib/components/transfer-list/ItemsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { ListGroup } from 'react-bootstrap' | ||
import { DndContext, DragEndEvent } from '@dnd-kit/core' | ||
import { arrayMove, SortableContext } from '@dnd-kit/sortable' | ||
import { restrictToVerticalAxis } from '@dnd-kit/modifiers' | ||
import { type TransferListItem } from './TransferList' | ||
import { ListItem } from './ListItem' | ||
import styles from './TransferList.module.scss' | ||
|
||
type ListProps = | ||
| { | ||
items: TransferListItem[] | ||
side: 'left' | ||
checked: TransferListItem[] | ||
onToggle: (item: TransferListItem) => () => void | ||
rightItems?: never | ||
setRight?: never | ||
onChange?: never | ||
} | ||
| { | ||
items: TransferListItem[] | ||
side: 'right' | ||
checked: TransferListItem[] | ||
onToggle: (item: TransferListItem) => () => void | ||
rightItems: TransferListItem[] | ||
setRight: React.Dispatch<React.SetStateAction<TransferListItem[]>> | ||
onChange?: (selected: TransferListItem[]) => void | ||
} | ||
|
||
export const ItemsList = ({ | ||
items, | ||
side, | ||
checked, | ||
onToggle, | ||
rightItems, | ||
setRight, | ||
onChange | ||
}: ListProps) => { | ||
if (side === 'left') { | ||
return ( | ||
<ListGroup className={styles['items-list']} data-testid={`${side}-list-group`}> | ||
{items.map((item: TransferListItem) => ( | ||
<ListItem | ||
item={item} | ||
side={side} | ||
checked={checked} | ||
onToggle={onToggle} | ||
key={item.value} | ||
/> | ||
))} | ||
</ListGroup> | ||
) | ||
} | ||
|
||
const handleDragEnd = (event: DragEndEvent) => { | ||
const { active, over } = event | ||
|
||
if (over && active.id !== over.id) { | ||
const oldIndex = rightItems.findIndex((item) => item.id === active.id) | ||
const newIndex = rightItems.findIndex((item) => item.id === over.id) | ||
|
||
const newItems = arrayMove(rightItems, oldIndex, newIndex) | ||
|
||
setRight(newItems) | ||
|
||
onChange && onChange(newItems) | ||
} | ||
} | ||
|
||
return ( | ||
<DndContext onDragEnd={handleDragEnd} modifiers={[restrictToVerticalAxis]}> | ||
<SortableContext items={items}> | ||
<ListGroup className={styles['items-list']} data-testid={`${side}-list-group`}> | ||
{items.map((item: TransferListItem) => ( | ||
<ListItem | ||
item={item} | ||
side={side} | ||
checked={checked} | ||
onToggle={onToggle} | ||
key={item.value} | ||
/> | ||
))} | ||
</ListGroup> | ||
</SortableContext> | ||
</DndContext> | ||
) | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/design-system/src/lib/components/transfer-list/ListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useId } from 'react' | ||
import { useSortable } from '@dnd-kit/sortable' | ||
import { CSS } from '@dnd-kit/utilities' | ||
import { ListGroup } from 'react-bootstrap' | ||
import { Form } from '../form/Form' | ||
import { TransferListItem } from './TransferList' | ||
import { Stack } from '../stack/Stack' | ||
import styles from './TransferList.module.scss' | ||
|
||
interface ListItemProps { | ||
item: TransferListItem | ||
side: 'left' | 'right' | ||
checked: readonly TransferListItem[] | ||
onToggle: (item: TransferListItem) => () => void | ||
} | ||
|
||
export const ListItem = ({ item, side, checked, onToggle }: ListItemProps) => { | ||
const { attributes, listeners, transform, transition, setNodeRef, setActivatorNodeRef } = | ||
useSortable({ id: item.id }) | ||
|
||
const uniqueID = useId() | ||
const labelId = `transfer-list-item-${item.value}-label-${uniqueID}` | ||
|
||
if (side === 'left') { | ||
return ( | ||
<ListGroup.Item className={styles['list-item']}> | ||
<Form.Group.Checkbox | ||
label={item.label} | ||
onChange={onToggle(item)} | ||
id={labelId} | ||
checked={checked.indexOf(item) !== -1} | ||
/> | ||
</ListGroup.Item> | ||
) | ||
} | ||
|
||
const style = { | ||
transform: CSS.Transform.toString(transform), | ||
transition | ||
} | ||
|
||
return ( | ||
<ListGroup.Item | ||
ref={setNodeRef} | ||
{...attributes} | ||
role="" | ||
style={style} | ||
className={styles['list-item']}> | ||
<Stack direction="horizontal" gap={1}> | ||
<button | ||
type="button" | ||
ref={setActivatorNodeRef} | ||
{...listeners} | ||
className={styles['drag-handle']} | ||
aria-label="press space to select and keys to drag"> | ||
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"> | ||
<circle cx="9" cy="6" r="1.5" fill="#777" /> | ||
<circle cx="15" cy="6" r="1.5" fill="#777" /> | ||
<circle cx="9" cy="12" r="1.5" fill="#777" /> | ||
<circle cx="15" cy="12" r="1.5" fill="#777" /> | ||
<circle cx="9" cy="18" r="1.5" fill="#777" /> | ||
<circle cx="15" cy="18" r="1.5" fill="#777" /> | ||
</svg> | ||
</button> | ||
<Form.Group.Checkbox | ||
label={item.label} | ||
onChange={onToggle(item)} | ||
id={labelId} | ||
checked={checked.indexOf(item) !== -1} | ||
/> | ||
</Stack> | ||
</ListGroup.Item> | ||
) | ||
} |
Oops, something went wrong.