playbook_ui 13.30.0.pre.alpha.20240515remotebuildkitconversion3150 → 13.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -3
  3. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +4 -4
  4. data/app/pb_kits/playbook/pb_card/_card.tsx +3 -4
  5. data/app/pb_kits/playbook/pb_collapsible/index.js +1 -6
  6. data/app/pb_kits/playbook/pb_date_time_stacked/docs/example.yml +1 -6
  7. data/app/pb_kits/playbook/pb_draggable/_draggable.scss +4 -2
  8. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +50 -70
  9. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +1 -2
  10. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +1 -1
  11. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +1 -5
  12. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +4 -11
  13. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +2 -4
  14. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +2 -2
  15. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +1 -7
  16. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +4 -6
  17. data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +15 -142
  18. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +5 -6
  19. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -18
  20. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +218 -228
  21. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -2
  22. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -2
  23. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +12 -14
  24. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -7
  25. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +2 -17
  26. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +3 -9
  27. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +0 -2
  28. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +0 -1
  29. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +11 -16
  30. data/app/pb_kits/playbook/pb_icon/_icon.tsx +6 -37
  31. data/app/pb_kits/playbook/pb_icon/docs/_icon_default.html.erb +1 -6
  32. data/app/pb_kits/playbook/pb_icon/docs/_icon_default.jsx +5 -21
  33. data/app/pb_kits/playbook/pb_icon/icon.rb +1 -21
  34. data/app/pb_kits/playbook/pb_list/_list.tsx +4 -4
  35. data/app/pb_kits/playbook/pb_list/_list_item.tsx +3 -7
  36. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.html.erb +1 -1
  37. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx +0 -1
  38. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.md +1 -3
  39. data/app/pb_kits/playbook/pb_nav/item.html.erb +1 -1
  40. data/app/pb_kits/playbook/pb_nav/item.rb +0 -1
  41. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.md +4 -4
  42. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -4
  43. data/app/pb_kits/playbook/pb_selectable_list/_item.tsx +3 -7
  44. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.tsx +3 -3
  45. data/app/pb_kits/playbook/pb_table/table_header.html.erb +2 -16
  46. data/app/pb_kits/playbook/pb_timeline/_item.tsx +10 -11
  47. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +6 -8
  48. data/app/pb_kits/playbook/utilities/globalProps.ts +0 -1
  49. data/dist/menu.yml +2 -2
  50. data/dist/playbook-rails.js +7 -7
  51. data/lib/playbook/version.rb +2 -2
  52. metadata +5 -22
  53. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +0 -59
  54. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.md +0 -6
  55. data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_default_swift.md +0 -33
  56. data/app/pb_kits/playbook/pb_date_time_stacked/docs/_date_time_stacked_props_swift.md +0 -18
  57. data/app/pb_kits/playbook/pb_draggable/context/types.ts +0 -26
  58. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +0 -7
  59. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.html.erb +0 -9
  60. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.jsx +0 -34
  61. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_custom_icon.html.erb +0 -32
  62. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_custom_icon.jsx +0 -48
  63. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +0 -72
  64. data/app/pb_kits/playbook/pb_icon/icon_aliases.json +0 -39
  65. data/app/pb_kits/playbook/pb_icon/types.d.ts +0 -1
  66. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.html.erb +0 -24
  67. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.html.erb +0 -11
  68. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +0 -27
  69. 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: 566e8e55a2019e4b07f21aaf87d7c9cdec4882133ffff612eb28eea86a6e4ffa
4
- data.tar.gz: '0197bd9877b5b0ed9002660f011dbea1fe06b6cf258481cea72cb3be712b2c10'
3
+ metadata.gz: 11ed59c33255cb5af32fdc3180c3fa48f6ba570eb896e4409699a19e8d461cdc
4
+ data.tar.gz: 61ed0816ffcf97e5383e7ab42497523610ec8b19907a175964adfc7c732702ea
5
5
  SHA512:
6
- metadata.gz: 85abde5d0af055ed6e080eeb6d767c38a93b495b9c4d6404b1a2f2e202131344089776a2d0f1b22de9ba2d48bb6940bab23237277b9e5f2031601c418e5ce24f
7
- data.tar.gz: bd1b40be0a0d261605f2835806562f91ec2c8248dbb39cbe4cb4591cb9d4a20fb25fb90d93f1e346cd7b71c23a66c71ad7dc09aa200dcc637ebeb27184551df9
6
+ metadata.gz: ab9a4635ef513699914e2817e96faa8d7b2b756234453fc1aafedfb062f88926c163d1b373999d65cb718272da327e7fd798beba2a6cfd95f84ca2b458e55cf9
7
+ data.tar.gz: 56798ee732587d6ae51b38671125c00364e2595084bf42ab632460c6b38d968e9961dc731187b656d5238e8616e37fafca86f1ec577c8662e545a9dc19552a08
@@ -2,15 +2,14 @@ examples:
2
2
  rails:
3
3
  - advanced_table_beta: Default (Required Props)
4
4
  - advanced_table_beta_subrow_headers: SubRow Headers
5
- - advanced_table_beta_sort: Enable Sorting
6
5
  react:
7
6
  - advanced_table_default: Default (Required Props)
8
7
  - advanced_table_loading: Loading State
9
- - advanced_table_sort: Enable Sorting
8
+ - advanced_table_sort: enable Sorting
10
9
  - advanced_table_sort_control: Sort Control
11
10
  - advanced_table_expanded_control: Expanded Control
12
11
  - advanced_table_subrow_headers: SubRow Headers
13
12
  - advanced_table_collapsible_trail: Collapsible Trail
14
13
  - advanced_table_table_options: Table Options
15
14
  - advanced_table_table_props: Table Props
16
- - advanced_table_inline_row_loading: Inline Row Loading
15
+ - advanced_table_inline_row_loading: inline Row Loading
@@ -1,11 +1,11 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("table/table_row", props: { tag: "div" }) do %>
2
+ <%= pb_rails("table/table_row", props: {tag:"div"}) do %>
3
3
  <% object.column_definitions.each_with_index do |item, index| %>
4
- <%= pb_rails("table/table_header", props: { tag: "div", id: item[:accessor], classname: object.th_classname, sort_menu: item[:sort_menu] }) do %>
5
- <%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end", text_align: "end" }) do %>
4
+ <%= pb_rails("table/table_header", props: { tag:"div", id:item[:accessor], classname:object.th_classname}) do %>
5
+ <%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end", text_align:"end" }) do %>
6
6
  <% if index.zero? && (object.enable_toggle_expansion == "header" || object.enable_toggle_expansion == "all") %>
7
7
  <button class="gray-icon toggle-all-icon" onclick="expandAllRows(this)">
8
- <%= pb_rails("icon", props: { icon: "arrows-from-line", cursor: "pointer", fixed_width: true, padding_right: "xs" }) %>
8
+ <%= pb_rails("icon", props: { icon: "arrows-from-line", cursor: "pointer", fixed_width: true, padding_right:"xs" }) %>
9
9
  </button>
10
10
  <% end %>
11
11
  <%= item[:label] %>
@@ -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}
@@ -14,12 +14,7 @@ export default class PbCollapsible extends PbEnhancedElement {
14
14
  this.element.addEventListener('click', () => {
15
15
  this.toggleElement(this.target)
16
16
  })
17
- // Check the initial state of the collapsible content and set the arrow accordingly
18
- if (this.target.classList.contains('is-visible')) {
19
- this.displayUpArrow()
20
- } else {
21
- this.displayDownArrow()
22
- }
17
+ this.displayDownArrow()
23
18
  // Listen for a custom event to toggle the collapsible
24
19
  document.addEventListener(`${this.target.id}`, () => {
25
20
  this.toggleElement(this.target)
@@ -2,11 +2,6 @@ examples:
2
2
 
3
3
  rails:
4
4
  - date_time_stacked_default: Default
5
-
5
+
6
6
  react:
7
7
  - date_time_stacked_default: Default
8
-
9
- swift:
10
- - date_time_stacked_default_swift: Default
11
- - date_time_stacked_props_swift: ""
12
-
@@ -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 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 passedd 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
+ })