playbook_ui 13.30.0.pre.alpha.PBNTR353draggablev53136 → 13.30.0.pre.alpha.PLAY1328fixtimelinekitglobalpropsreact3096

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_card/_card.tsx +3 -4
  3. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +4 -2
  4. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +50 -70
  5. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +1 -2
  6. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +1 -1
  7. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +1 -5
  8. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +4 -11
  9. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +2 -4
  10. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +2 -2
  11. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +1 -7
  12. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +4 -6
  13. data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +15 -142
  14. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +5 -6
  15. data/app/pb_kits/playbook/pb_list/_list.tsx +4 -4
  16. data/app/pb_kits/playbook/pb_list/_list_item.tsx +3 -7
  17. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.md +4 -4
  18. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -4
  19. data/app/pb_kits/playbook/pb_selectable_list/_item.tsx +3 -7
  20. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.tsx +3 -3
  21. data/app/pb_kits/playbook/utilities/globalProps.ts +0 -1
  22. data/dist/menu.yml +2 -2
  23. data/dist/playbook-rails.js +2 -2
  24. data/lib/playbook/version.rb +1 -1
  25. metadata +2 -8
  26. data/app/pb_kits/playbook/pb_draggable/context/types.ts +0 -26
  27. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +0 -7
  28. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.html.erb +0 -24
  29. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.html.erb +0 -11
  30. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +0 -27
  31. data/app/pb_kits/playbook/pb_overlay/overlay.rb +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d681e69c84f185b628e40d1d517d5cee70c28972186ee4b47b21641a4ca4637
4
- data.tar.gz: 0c5933b2d3d51c8d8c891f4604f1f11447f1edcf5227446b68db72a4b169731e
3
+ metadata.gz: 9bec2adcbbd24c7d8dedcfd434368fd206154d30a3f22011db8fd8c17bd2002b
4
+ data.tar.gz: a5afc1f25e3609873b5bb0ba02d8c796ae9060cdd6aff33fcf103ec9fe88b7de
5
5
  SHA512:
6
- metadata.gz: 80a03f749ddd4bf241009567ecc83c161a4cbbefc6779d8db7c2b717242ff4ac536afb263715bae97bca4cfb73bbb2c29d11c8747592ea341bed2b4547572ae2
7
- data.tar.gz: 9cdc6ecc0caeab5ee99f8846513121233f191f28c3b9dd1b9bf3c631133f707dbde9bec819db905663ca437fd2ba66a43e03a871e055e74874a61de87059ff00
6
+ metadata.gz: d754acdd73fd036d57ec1fcf6cd21891a5a872268448021ba01d407cdb7c60f990b1a1cfd3680cbd6801e367eb33d919a6725f2747b8f0ba10cbf6657803720f
7
+ data.tar.gz: 9bc1f39ec7aa9bcdf8fb27aa9ac0bb50919a4e94b1db0cae50233701639a78b9963c60b2e3c8c39363e2b9548b3909e167c7bcbd486163283f7d9fcf82b1fe18
@@ -20,7 +20,6 @@ type CardPropTypes = {
20
20
  children: React.ReactChild[] | React.ReactChild | number,
21
21
  className?: string,
22
22
  data?: {[key: string]: string},
23
- dragId?: string,
24
23
  draggableItem?: boolean,
25
24
  dragHandle?: boolean,
26
25
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
@@ -86,11 +85,11 @@ const Card = (props: CardPropTypes): React.ReactElement => {
86
85
  children,
87
86
  className,
88
87
  data = {},
89
- dragId,
90
88
  dragHandle = true,
91
89
  draggableItem = false,
92
90
  highlight = {},
93
91
  htmlOptions = {},
92
+ id,
94
93
  selected = false,
95
94
  tag = 'div',
96
95
  } = props
@@ -127,8 +126,8 @@ const Card = (props: CardPropTypes): React.ReactElement => {
127
126
  <>
128
127
  {
129
128
  draggableItem ? (
130
- <Draggable.Item dragId={dragId}
131
- key={dragId}
129
+ <Draggable.Item id={id}
130
+ key={id}
132
131
  >
133
132
  <Tag
134
133
  {...ariaProps}
@@ -1,9 +1,11 @@
1
1
  @import "../tokens/colors";
2
- @import "../tokens/opacity";
3
2
 
4
3
  .pb_draggable_container {
5
4
  .is_dragging {
6
- opacity: $opacity_4;
5
+ opacity: 40%;
6
+ }
7
+ .active {
8
+ opacity: 60%;
7
9
  }
8
10
  .pb_draggable_item:hover {
9
11
  cursor: grab;
@@ -1,110 +1,90 @@
1
- import React, { createContext, useReducer, useContext, useEffect, useMemo } from "react";
2
- import { InitialStateType, ActionType, DraggableProviderType } from "./types";
3
-
4
- const initialState: InitialStateType = {
5
- items: [],
6
- dragData: { id: "", initialGroup: "" },
7
- isDragging: "",
8
- activeContainer: ""
9
- };
10
-
11
- const reducer = (state: InitialStateType, action: ActionType) => {
12
- switch (action.type) {
13
- case 'SET_ITEMS':
14
- return { ...state, items: action.payload };
15
- case 'SET_DRAG_DATA':
16
- return { ...state, dragData: action.payload };
17
- case 'SET_IS_DRAGGING':
18
- return { ...state, isDragging: action.payload };
19
- case 'SET_ACTIVE_CONTAINER':
20
- return { ...state, activeContainer: action.payload };
21
- case 'CHANGE_CATEGORY':
22
- return {
23
- ...state,
24
- items: state.items.map(item =>
25
- item.id === action.payload.itemId
26
- ? { ...item, container: action.payload.container }
27
- : item
28
- )
29
- };
30
- case 'REORDER_ITEMS': {
31
- const { dragId, targetId } = action.payload;
32
- const newItems = [...state.items];
33
- const draggedItem = newItems.find(item => item.id === dragId);
34
- const draggedIndex = newItems.indexOf(draggedItem);
35
- const targetIndex = newItems.findIndex(item => item.id === targetId);
36
-
37
- newItems.splice(draggedIndex, 1);
38
- newItems.splice(targetIndex, 0, draggedItem);
1
+ import React, { createContext, useState, useContext, useEffect } from "react";
39
2
 
40
- return { ...state, items: newItems };
41
- }
42
- default:
43
- return state;
44
- }
45
- };
46
-
47
- // Context and Provider
48
3
  const DragContext = createContext<any>({});
49
4
 
50
5
  export const DraggableContext = () => {
51
6
  return useContext(DragContext);
52
7
  };
53
8
 
54
- export const DraggableProvider = ({ children, initialItems, onReorder }: DraggableProviderType) => {
55
- const [state, dispatch] = useReducer(reducer, initialState);
9
+ export const DraggableProvider = ({ children, initialItems, onReorder }: any) => {
10
+ const [items, setItems] = useState([]);
11
+ const [dragData, setDragData] = useState<{ [key: string]: any }>({});
12
+ const [isDragging, setIsDragging] = useState("");
13
+ const [activeContainer, setActiveContainer] = useState("");
56
14
 
57
15
  useEffect(() => {
58
- dispatch({ type: 'SET_ITEMS', payload: initialItems });
16
+ setItems(initialItems);
59
17
  }, [initialItems]);
60
18
 
61
19
  useEffect(() => {
62
- onReorder(state.items);
63
- }, [state.items]);
20
+ onReorder(items);
21
+ }, [items]);
64
22
 
65
23
  const handleDragStart = (id: string, container: string) => {
66
- dispatch({ type: 'SET_DRAG_DATA', payload: { id: id, initialGroup: container } });
67
- dispatch({ type: 'SET_IS_DRAGGING', payload: id });
24
+ setDragData({ id: id, initialGroup: container });
25
+ setIsDragging(id);
68
26
  };
69
27
 
70
28
  const handleDragEnter = (id: string, container: string) => {
71
- if (state.dragData.id !== id) {
72
- dispatch({ type: 'REORDER_ITEMS', payload: { dragId: state.dragData.id, targetId: id } });
73
- dispatch({ type: 'SET_DRAG_DATA', payload: { id: state.dragData.id, initialGroup: container } });
29
+ if (dragData?.id !== id) {
30
+ const newItems = [...items];
31
+ const draggedItem = newItems.find((item) => item.id === dragData.id);
32
+ const draggedIndex = newItems.indexOf(draggedItem);
33
+ const targetIndex = newItems.findIndex((item) => item.id === id);
34
+
35
+ newItems.splice(draggedIndex, 1);
36
+ newItems.splice(targetIndex, 0, draggedItem);
37
+
38
+ setItems(newItems);
39
+ setDragData({ id: dragData.id, initialGroup: container });
74
40
  }
75
41
  };
76
42
 
77
43
  const handleDragEnd = () => {
78
- dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
79
- dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
44
+ setIsDragging("");
45
+ setActiveContainer("");
80
46
  };
81
47
 
82
48
  const changeCategory = (itemId: string, container: string) => {
83
- dispatch({ type: 'CHANGE_CATEGORY', payload: { itemId, container } });
49
+ const updatedItems = items.map((item) => {
50
+ if (item.id === itemId) {
51
+ return { ...item, container: container };
52
+ }
53
+ return item;
54
+ });
55
+
56
+ setItems(updatedItems);
84
57
  };
85
58
 
86
59
  const handleDrop = (container: string) => {
87
- dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
88
- dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
89
- changeCategory(state.dragData.id, container);
60
+ setIsDragging("");
61
+ setActiveContainer("");
62
+ const selected = dragData.id;
63
+ changeCategory(selected, container);
90
64
  };
91
65
 
92
66
  const handleDragOver = (e: Event, container: string) => {
93
67
  e.preventDefault();
94
- dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
68
+ setActiveContainer(container);
95
69
  };
96
70
 
97
- const contextValue = useMemo(() => ({
98
- items: state.items,
99
- dragData: state.dragData,
100
- isDragging: state.isDragging,
101
- activeContainer: state.activeContainer,
71
+
72
+
73
+ const contextValue = {
74
+ items,
75
+ setItems,
76
+ dragData,
77
+ setDragData,
78
+ isDragging,
79
+ setIsDragging,
80
+ activeContainer,
81
+ setActiveContainer,
102
82
  handleDragStart,
103
83
  handleDragEnter,
104
84
  handleDragEnd,
105
85
  handleDrop,
106
- handleDragOver
107
- }), [state]);
86
+ handleDragOver,
87
+ };
108
88
 
109
89
  return (
110
90
  <DragContext.Provider value={contextValue}>{children}</DragContext.Provider>
@@ -32,14 +32,13 @@ const DraggableDefault = (props) => {
32
32
  <Draggable.Container {...props}>
33
33
  <SelectableList variant="checkbox">
34
34
  {initialState.map(({ id, text }) => (
35
- <Draggable.Item dragId={id}
35
+ <Draggable.Item id={id}
36
36
  key={id}
37
37
  >
38
38
  <SelectableList.Item
39
39
  label={text}
40
40
  name={id}
41
41
  value={id}
42
- {...props}
43
42
  />
44
43
  </Draggable.Item>
45
44
  ))}
@@ -1,4 +1,4 @@
1
1
  To use the Draggable kit, you must use the DraggableProvider and pass in `initialItems`. The `onReorder` is a function that returns the data as it changes as items are reordered. Use this to manage state as shown.
2
2
 
3
3
  The `Draggable.Container` specifies the container within which items can be dropped.
4
- The `Draggable.Item` specifies the items that can be dragged and dropped. `dragId` is a REQUIRED prop for Draggable.Item.
4
+ The `Draggable.Item` specifies the items that can be dragged and dropped. `Draggable.Item` requires `id` to be passed in as shown.
@@ -113,13 +113,12 @@ const DraggableMultipleContainer = (props) => {
113
113
  }) => (
114
114
  <Draggable.Item
115
115
  container={container}
116
- dragId={id}
116
+ id={id}
117
117
  key={id}
118
118
  >
119
119
  <Card
120
120
  marginBottom="sm"
121
121
  padding="sm"
122
- {...props}
123
122
  >
124
123
  <Flex justify="between">
125
124
  <FlexItem>
@@ -132,7 +131,6 @@ const DraggableMultipleContainer = (props) => {
132
131
  <Title paddingLeft="xs"
133
132
  size={4}
134
133
  text={title}
135
- {...props}
136
134
  />
137
135
  </Flex>
138
136
  </FlexItem>
@@ -141,12 +139,10 @@ const DraggableMultipleContainer = (props) => {
141
139
  rounded
142
140
  text={badgeProperties(container).text}
143
141
  variant={badgeProperties(container).color}
144
- {...props}
145
142
  />
146
143
  </Flex>
147
144
  <Body paddingTop="xs"
148
145
  text={description}
149
- {...props}
150
146
  />
151
147
  </Card>
152
148
  </Draggable.Item>
@@ -36,32 +36,29 @@ const DraggableWithCards = (props) => {
36
36
  >
37
37
  <Draggable.Container {...props}>
38
38
  {initialState.map(({ id, text }) => (
39
- <Card dragId={id}
39
+ <Card
40
40
  draggableItem
41
41
  highlight={{ color: "primary", position: "side" }}
42
+ id={id}
42
43
  key={id}
43
44
  marginBottom="xs"
44
45
  padding="xs"
45
- {...props}
46
46
  >
47
47
  <Flex alignItems="stretch"
48
48
  flexDirection="column"
49
49
  >
50
50
  <Flex gap="xs">
51
51
  <Title size={4}
52
- text={text}
53
- {...props}
52
+ text={text}
54
53
  />
55
54
  <Badge
56
55
  text="35-12345"
57
56
  variant="primary"
58
- {...props}
59
57
  />
60
58
  </Flex>
61
59
  <Caption
62
60
  size="xs"
63
61
  text="8:00A • Township Name • 90210"
64
- {...props}
65
62
  />
66
63
  <Flex gap="xxs"
67
64
  spacing="between"
@@ -69,7 +66,6 @@ const DraggableWithCards = (props) => {
69
66
  <Flex gap="xxs">
70
67
  <Caption color="error"
71
68
  size="xs"
72
- {...props}
73
69
  >
74
70
  <Icon icon="house-circle-exclamation" />
75
71
  </Caption>
@@ -82,17 +78,14 @@ const DraggableWithCards = (props) => {
82
78
  <Badge rounded
83
79
  text="Schedule QA"
84
80
  variant="warning"
85
- {...props}
86
81
  />
87
82
  <Badge rounded
88
83
  text="Flex"
89
- variant="primary"
90
- {...props}
84
+ variant="primary"
91
85
  />
92
86
  <Badge rounded
93
87
  text="R99"
94
88
  variant="primary"
95
- {...props}
96
89
  />
97
90
  </Flex>
98
91
  </Flex>
@@ -1,5 +1,3 @@
1
- For a simplified version of the Draggable API for the Card kit, You can use the Card kit as the Draggable Item by using the `draggableItem` prop. The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the Card kit.
1
+ For a simplified version of the Draggable API for the Card kit, You can use the the Card kit as the Draggable Item by using the `draggableItem` prop on Card. The dragHandle is added by default but this can be opted out off by setting `dragHandle` to false on the Card kit.
2
2
 
3
- In addition to the above, `dragId` is a REQUIRED prop to be passed to the Card kit when implementing dragging.
4
-
5
- The dev must manage state as shown.
3
+ The dev must manage state as shown and pass in id to the Card for dragging to work.
@@ -30,11 +30,11 @@ const DraggableWithList = (props) => {
30
30
  <DraggableProvider initialItems={data}
31
31
  onReorder={(items) => setInitialState(items)}
32
32
  >
33
- <List enableDrag
33
+ <List draggable
34
34
  {...props}
35
35
  >
36
36
  {initialState.map(({ id, text }) => (
37
- <ListItem dragId={id}
37
+ <ListItem id={id}
38
38
  key={id}
39
39
  >
40
40
  {text}
@@ -1,7 +1 @@
1
- For a simplified version of the Draggable API for the List kit, use the DraggableProvider to wrap the List kit and use the `enableDrag` prop.
2
-
3
- In addition to the above, `dragId` is a REQUIRED prop to be passed to the List kit when implementing dragging.
4
-
5
- The dev must manage state as shown.
6
-
7
- The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the List kit.
1
+ For a simplified version of the Draggable API for the List kit, use the DraggableProvider to wrap the List kit and use the `draggable` prop on List. The dev must manage state as shown and pass in id to the ListItem for dragging to work.
@@ -29,18 +29,16 @@ const DraggableWithSelectableList = (props) => {
29
29
  <DraggableProvider initialItems={data}
30
30
  onReorder={(items) => setInitialState(items)}
31
31
  >
32
- <SelectableList enableDrag
33
- variant="radio"
32
+ <SelectableList draggable
33
+ variant="checkbox"
34
34
  {...props}
35
35
  >
36
36
  {initialState.map(({ id, text }) => (
37
- <SelectableList.Item
38
- dragId={id}
37
+ <SelectableList.Item id={id}
39
38
  key={id}
40
39
  label={text}
41
- name="radio-test"
40
+ name={id}
42
41
  value={id}
43
- {...props}
44
42
  />
45
43
  ))}
46
44
  </SelectableList>
@@ -1,16 +1,9 @@
1
- import React, { useState } from "react";
2
- import { render, screen } from "../utilities/test-utils";
1
+ import React, {useState} from "react"
2
+ import { render, screen } from "../utilities/test-utils"
3
3
 
4
- import {
5
- Draggable,
6
- DraggableProvider,
7
- SelectableList,
8
- List,
9
- ListItem,
10
- Card,
11
- } from "../";
4
+ import { Draggable, DraggableProvider, SelectableList } from '../'
12
5
 
13
- const testId = "draggable";
6
+ const testId = 'draggable'
14
7
 
15
8
  const data = [
16
9
  {
@@ -31,6 +24,7 @@ const data = [
31
24
  },
32
25
  ];
33
26
 
27
+
34
28
  const DefaultDraggableKit = () => {
35
29
  const [initialState, setInitialState] = useState(data);
36
30
 
@@ -39,11 +33,13 @@ const DefaultDraggableKit = () => {
39
33
  initialItems={data}
40
34
  onReorder={(items) => setInitialState(items)}
41
35
  >
42
- <Draggable data={{ testid: testId }}>
36
+ <Draggable
37
+ data={{ testid: testId }}
38
+ >
43
39
  <Draggable.Container>
44
40
  <SelectableList variant="checkbox">
45
41
  {initialState.map(({ id, text }) => (
46
- <Draggable.Item dragId={id}
42
+ <Draggable.Item id={id}
47
43
  key={id}
48
44
  >
49
45
  <SelectableList.Item label={text}
@@ -59,132 +55,9 @@ const DefaultDraggableKit = () => {
59
55
  );
60
56
  };
61
57
 
62
- const DraggableKitWithList = () => {
63
- const [initialState, setInitialState] = useState(data);
64
- return (
65
- <div data-testid="draggable">
66
- <DraggableProvider
67
- initialItems={data}
68
- onReorder={(items) => setInitialState(items)}
69
- >
70
- <List enableDrag>
71
- {initialState.map(({ id, text }) => (
72
- <ListItem dragId={id}
73
- key={id}
74
- >
75
- {text}
76
- </ListItem>
77
- ))}
78
- </List>
79
- </DraggableProvider>
80
- </div>
81
- );
82
- };
83
-
84
- const DraggableKitWithSelectableList = () => {
85
- const [initialState, setInitialState] = useState(data);
86
- return (
87
- <div data-testid="draggable">
88
- <DraggableProvider
89
- initialItems={data}
90
- onReorder={(items) => setInitialState(items)}
91
- >
92
- <SelectableList enableDrag>
93
- {initialState.map(({ id, text }) => (
94
- <SelectableList.Item
95
- dragId={id}
96
- key={id}
97
- label={text}
98
- name={id}
99
- value={id}
100
- />
101
- ))}
102
- </SelectableList>
103
- </DraggableProvider>
104
- </div>
105
- );
106
- };
107
-
108
- const DraggableKitWithCard = () => {
109
- const [initialState, setInitialState] = useState(data);
110
- return (
111
- <div data-testid="draggable">
112
- <DraggableProvider
113
- initialItems={data}
114
- onReorder={(items) => setInitialState(items)}
115
- >
116
- <Draggable.Container>
117
- {initialState.map(({ id, text }) => (
118
- <Card dragId={id}
119
- draggableItem
120
- key={id}
121
- >
122
- {text}
123
- </Card>
124
- ))}
125
- </Draggable.Container>
126
- </DraggableProvider>
127
- </div>
128
- );
129
- };
130
-
131
- test("generated default kit and classname", () => {
132
- render(<DefaultDraggableKit />);
133
- const kit = screen.getByTestId(testId);
134
- expect(kit).toBeInTheDocument();
135
- expect(kit).toHaveClass("pb_draggable");
136
- });
137
-
138
- test("generated Draggable Container", () => {
139
- render(<DefaultDraggableKit />);
140
- const kit = screen.getByTestId(testId);
141
-
142
- const container = kit.querySelector(".pb_draggable_container");
143
- expect(container).toBeInTheDocument();
144
- });
145
-
146
- test("generated Draggable Item", () => {
147
- render(<DefaultDraggableKit />);
148
- const kit = screen.getByTestId(testId);
149
-
150
- const item = kit.querySelector(".pb_draggable_item");
151
- expect(item).toBeInTheDocument();
152
- });
153
-
154
- test("Attached draggable HTML attributes", () => {
155
- render(<DefaultDraggableKit />);
156
- const kit = screen.getByTestId(testId);
157
-
158
- const item = kit.querySelector(".pb_draggable_item");
159
- expect(item).toHaveAttribute("draggable");
160
- });
161
-
162
- test("generated dragHandle with List", () => {
163
- render(<DraggableKitWithList />);
164
- const kit = screen.getByTestId(testId);
165
-
166
- const list = kit.querySelector(".pb_list_kit");
167
- expect(list).toBeInTheDocument();
168
- const dragHandle = list.querySelector(".fa-grip-dots-vertical");
169
- expect(dragHandle).toBeInTheDocument();
170
- });
171
-
172
- test("generated dragHandle with SelectableList", () => {
173
- render(<DraggableKitWithSelectableList />);
174
- const kit = screen.getByTestId(testId);
175
-
176
- const selectabellist = kit.querySelector(".pb_selectable_list_kit");
177
- expect(selectabellist).toBeInTheDocument();
178
- const dragHandle = selectabellist.querySelector(".fa-grip-dots-vertical");
179
- expect(dragHandle).toBeInTheDocument();
180
- });
181
-
182
- test("generated dragHandle with Card", () => {
183
- render(<DraggableKitWithCard />);
184
- const kit = screen.getByTestId(testId);
185
-
186
- const card = kit.querySelector(".pb_card_kit_deselected_border_radius_md");
187
- expect(card).toBeInTheDocument();
188
- const dragHandle = card.querySelector(".fa-grip-dots-vertical");
189
- expect(dragHandle).toBeInTheDocument();
190
- });
58
+ test('generated default kit and classname', () => {
59
+ render(<DefaultDraggableKit/>)
60
+ const kit = screen.getByTestId(testId)
61
+ expect(kit).toBeInTheDocument()
62
+ expect(kit).toHaveClass('pb_draggable')
63
+ })
@@ -17,11 +17,10 @@ type DraggableItemProps = {
17
17
  data?: { [key: string]: string };
18
18
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
19
19
  id?: string;
20
- dragId?: string;
21
20
  };
22
21
 
23
22
  const DraggableItem = (props: DraggableItemProps) => {
24
- const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id, dragId } = props;
23
+ const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id } = props;
25
24
 
26
25
  const { isDragging, handleDragStart, handleDragEnter, handleDragEnd } =
27
26
  DraggableContext();
@@ -32,7 +31,7 @@ const DraggableItem = (props: DraggableItemProps) => {
32
31
 
33
32
  const classes = classnames(
34
33
  buildCss("pb_draggable_item"),
35
- `${isDragging === dragId ? "is_dragging" : ""}`,
34
+ `${isDragging === id ? "is_dragging" : ""}`,
36
35
  globalProps(props),
37
36
  className
38
37
  );
@@ -45,10 +44,10 @@ const DraggableItem = (props: DraggableItemProps) => {
45
44
  className={classes}
46
45
  draggable
47
46
  id={id}
48
- key={dragId}
47
+ key={id}
49
48
  onDragEnd={() => handleDragEnd()}
50
- onDragEnter={() => handleDragEnter(dragId, container)}
51
- onDragStart={() => handleDragStart(dragId, container)}
49
+ onDragEnter={() => handleDragEnter(id, container)}
50
+ onDragStart={() => handleDragStart(id, container)}
52
51
  >
53
52
  {children}
54
53
  </div>
@@ -10,7 +10,7 @@ type ListProps = {
10
10
  className?: string;
11
11
  children: React.ReactNode[] | React.ReactNode;
12
12
  dark?: boolean;
13
- enableDrag?: boolean;
13
+ draggable?: boolean;
14
14
  data?: Record<string, unknown>;
15
15
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
16
16
  id?: string;
@@ -32,7 +32,7 @@ const List = (props: ListProps) => {
32
32
  className,
33
33
  dark = false,
34
34
  data = {},
35
- enableDrag = false,
35
+ draggable = false,
36
36
  htmlOptions = {},
37
37
  id,
38
38
  layout = "",
@@ -54,7 +54,7 @@ const List = (props: ListProps) => {
54
54
  const childrenWithProps = React.Children.map(
55
55
  children,
56
56
  (child: React.ReactElement) => {
57
- return React.cloneElement(child, { text, variant, enableDrag });
57
+ return React.cloneElement(child, { text, variant, draggable });
58
58
  }
59
59
  );
60
60
  const ariaProps = buildAriaProps(aria);
@@ -74,7 +74,7 @@ const List = (props: ListProps) => {
74
74
  return (
75
75
  <>
76
76
  {
77
- enableDrag ? (
77
+ draggable ? (
78
78
  <Draggable.Container>
79
79
  <div className={classes}>
80
80
  {ordered ? (