playbook_ui 14.16.0.pre.rc.6 → 14.17.0.pre.alpha.PBNTR766tablenestedcollapsiblerowsborderdoubling7192
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +104 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +168 -85
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +10 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +20 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.jsx +90 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_fullscreen.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows.html.erb +39 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +19 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +38 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +49 -37
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +39 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_button/_button.scss +5 -5
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +14 -7
- data/app/pb_kits/playbook/pb_contact/contact.test.js +7 -7
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +34 -34
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +16 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +0 -11
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.jsx +0 -7
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_inline_styles.scss +28 -24
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.test.js +2 -2
- data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.test.js +1 -1
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +138 -5
- data/app/pb_kits/playbook/pb_draggable/_draggable.tsx +6 -4
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +91 -24
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +35 -28
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.jsx +181 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.jsx +99 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.jsx +110 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_table_react.jsx → _draggable_with_table.jsx} +1 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.md +3 -1
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +9 -6
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +4 -1
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +71 -3
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +12 -2
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +65 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +3 -0
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +6 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +8 -8
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +3 -3
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +3 -4
- data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +2 -2
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +67 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +67 -0
- data/app/pb_kits/playbook/pb_form/pb_form_validation.js +1 -1
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +22 -0
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon/_icon.scss +8 -1
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb +10 -4
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx +49 -24
- data/app/pb_kits/playbook/pb_icon/icon.test.js +9 -9
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +4 -1
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_click.jsx +13 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_icon_value/icon_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_label_value/label_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_layout/_layout.scss +58 -0
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +20 -7
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.jsx +190 -0
- data/app/pb_kits/playbook/pb_layout/docs/_layout_bracket.md +5 -0
- data/app/pb_kits/playbook/pb_layout/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_layout/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_layout/layout.test.js +4 -0
- data/app/pb_kits/playbook/pb_layout/subcomponents/_game.tsx +90 -0
- data/app/pb_kits/playbook/pb_layout/subcomponents/_round.tsx +57 -0
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/hooks/useVisibility.js +1 -1
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_link/link.test.jsx +2 -2
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +23 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +28 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.html.erb +72 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.jsx +97 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.html.erb +71 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/index.js +105 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +10 -0
- data/app/pb_kits/playbook/pb_nav/_nav.scss +5 -0
- data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +5 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +29 -11
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +4 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +2 -0
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical.md +1 -0
- data/app/pb_kits/playbook/pb_stat_change/stat_change.test.js +8 -4
- data/app/pb_kits/playbook/pb_table/_table.tsx +4 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless.jsx +50 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_borderless_react.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating.jsx +59 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_header_style_floating_react.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +24 -0
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +76 -0
- data/app/pb_kits/playbook/pb_table/styles/_striped.scss +3 -3
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +11 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +11 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -0
- data/app/pb_kits/playbook/pb_table/table.test.js +17 -0
- data/app/pb_kits/playbook/pb_tooltip/index.js +183 -56
- data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +2 -5
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +4 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.html.erb +19 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.jsx +23 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +4 -4
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_typeahead/index.ts +2 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -5
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +3 -0
- data/app/pb_kits/playbook/pb_user/_user.tsx +78 -13
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options.html.erb +22 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options.jsx +40 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options_rails.md +5 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_font_options_react.md +5 -0
- data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_user/user.html.erb +28 -12
- data/app/pb_kits/playbook/pb_user/user.rb +17 -1
- data/app/pb_kits/playbook/pb_user/user.test.js +182 -1
- data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +1 -6
- data/app/pb_kits/playbook/tokens/_colors.scss +1 -4
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -1
- data/app/pb_kits/playbook/utilities/object.test.js +287 -1
- data/app/pb_kits/playbook/utilities/object.ts +171 -3
- data/app/pb_kits/playbook/utilities/text.ts +1 -1
- data/dist/chunks/_typeahead-HqfDnjRe.js +22 -0
- data/dist/chunks/_weekday_stacked-DVQITtQ9.js +45 -0
- data/dist/chunks/lib-BGzBzFZX.js +29 -0
- data/dist/chunks/{pb_form_validation-BvDxpfs-.js → pb_form_validation-BvNy9Bd6.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/forms/builder/multi_level_select_field.rb +2 -0
- data/lib/playbook/kit_base.rb +4 -4
- data/lib/playbook/version.rb +2 -2
- metadata +53 -21
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
- data/dist/chunks/_typeahead-CRAPc8k-.js +0 -22
- data/dist/chunks/_weekday_stacked-T0kFfioG.js +0 -45
- data/dist/chunks/lib-BeKPJYlk.js +0 -29
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.md → _advanced_table_selectable_rows_no_subrows_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.md → _advanced_table_selectable_rows_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_default_rails.html.erb → _draggable_default.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_default.md → _draggable_default_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_multiple_containers_rails.html.erb → _draggable_multiple_containers.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_multiple_containers.md → _draggable_multiple_containers_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_cards_rails.html.erb → _draggable_with_cards.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_cards.md → _draggable_with_cards_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_list_rails.html.erb → _draggable_with_list.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_list.md → _draggable_with_list_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_selectable_list_rails.html.erb → _draggable_with_selectable_list.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_selectable_list.md → _draggable_with_selectable_list_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_with_table.md → _draggable_with_table_rails.md} +0 -0
@@ -1,31 +1,38 @@
|
|
1
1
|
export interface ItemType {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
id: string;
|
3
|
+
container: string;
|
4
|
+
[key: string]: any;
|
5
|
+
}
|
6
|
+
|
7
|
+
export interface InitialStateType {
|
8
|
+
items: ItemType[];
|
9
|
+
dragData: { id: string; initialGroup: string };
|
10
|
+
isDragging: string;
|
11
|
+
activeContainer: string;
|
12
|
+
}
|
13
|
+
|
14
|
+
export type ActionType =
|
15
|
+
| { type: 'SET_ITEMS'; payload: ItemType[] }
|
16
|
+
| { type: 'SET_DRAG_DATA'; payload: { id: string; initialGroup: string } }
|
17
|
+
| { type: 'SET_IS_DRAGGING'; payload: string }
|
18
|
+
| { type: 'SET_ACTIVE_CONTAINER'; payload: string }
|
19
|
+
| { type: 'CHANGE_CATEGORY'; payload: { itemId: string; container: string } }
|
20
|
+
| { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } };
|
21
|
+
|
22
|
+
export interface DropZoneConfig {
|
23
|
+
type?: 'ghost' | 'outline' | 'shadow' | 'line';
|
24
|
+
color?: 'primary' | 'neutral' | 'purple';
|
25
|
+
direction?: 'horizontal' | 'vertical';
|
12
26
|
}
|
13
|
-
|
14
|
-
export type ActionType =
|
15
|
-
| { type: 'SET_ITEMS'; payload: ItemType[] }
|
16
|
-
| { type: 'SET_DRAG_DATA'; payload: { id: string; initialGroup: string } }
|
17
|
-
| { type: 'SET_IS_DRAGGING'; payload: string }
|
18
|
-
| { type: 'SET_ACTIVE_CONTAINER'; payload: string }
|
19
|
-
| { type: 'CHANGE_CATEGORY'; payload: { itemId: string; container: string } }
|
20
|
-
| { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } };
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
export interface DraggableProviderType {
|
29
|
+
children: React.ReactNode;
|
30
|
+
initialItems: ItemType[];
|
31
|
+
onReorder: (items: ItemType[]) => void;
|
32
|
+
onDragStart?: (id: string, container: string) => void;
|
33
|
+
onDragEnter?: (id: string, container: string) => void;
|
34
|
+
onDragEnd?: () => void;
|
35
|
+
onDrop?: (container: string) => void;
|
36
|
+
onDragOver?: (e: Event, container: string) => void;
|
37
|
+
dropZone?: DropZoneConfig | string; // Can accept string for backward compatibility
|
38
|
+
}
|
@@ -0,0 +1,181 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import Body from '../../pb_body/_body'
|
3
|
+
import Flex from '../../pb_flex/_flex'
|
4
|
+
import FlexItem from '../../pb_flex/_flex_item'
|
5
|
+
import Card from '../../pb_card/_card'
|
6
|
+
import Caption from '../../pb_caption/_caption'
|
7
|
+
import Draggable from '../../pb_draggable/_draggable'
|
8
|
+
import { DraggableProvider } from '../../pb_draggable/context'
|
9
|
+
|
10
|
+
// Initial items to be dragged
|
11
|
+
const dataShadow = [
|
12
|
+
{
|
13
|
+
id: "51",
|
14
|
+
text: "Task 1",
|
15
|
+
},
|
16
|
+
{
|
17
|
+
id: "52",
|
18
|
+
text: "Task 2",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
id: "53",
|
22
|
+
text: "Task 3",
|
23
|
+
},
|
24
|
+
];
|
25
|
+
|
26
|
+
const dataOutline = [
|
27
|
+
{
|
28
|
+
id: "61",
|
29
|
+
text: "Task 1",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
id: "62",
|
33
|
+
text: "Task 2",
|
34
|
+
},
|
35
|
+
{
|
36
|
+
id: "63",
|
37
|
+
text: "Task 3",
|
38
|
+
},
|
39
|
+
];
|
40
|
+
|
41
|
+
const dataLine = [
|
42
|
+
{
|
43
|
+
id: "71",
|
44
|
+
text: "Task 1",
|
45
|
+
},
|
46
|
+
{
|
47
|
+
id: "72",
|
48
|
+
text: "Task 2",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
id: "73",
|
52
|
+
text: "Task 3",
|
53
|
+
},
|
54
|
+
];
|
55
|
+
|
56
|
+
const DraggableDropZones = (props) => {
|
57
|
+
const [initialShadowState, setInitialShadowState] = useState(dataShadow);
|
58
|
+
const [initialOutlineState, setInitialOutlineState] = useState(dataOutline);
|
59
|
+
const [initialLineState, setInitialLineState] = useState(dataLine);
|
60
|
+
|
61
|
+
return (
|
62
|
+
<>
|
63
|
+
<Flex justify="between"
|
64
|
+
{...props}
|
65
|
+
>
|
66
|
+
<FlexItem marginRight="xl">
|
67
|
+
<DraggableProvider
|
68
|
+
dropZone={{type: "shadow"}}
|
69
|
+
initialItems={dataShadow}
|
70
|
+
onReorder={(items) => setInitialShadowState(items)}
|
71
|
+
>
|
72
|
+
<Caption
|
73
|
+
marginBottom="xs"
|
74
|
+
text="Shadow"
|
75
|
+
textAlign="center"
|
76
|
+
/>
|
77
|
+
<Draggable.Container
|
78
|
+
htmlOptions={{style:{ width: "200px"}}}
|
79
|
+
{...props}
|
80
|
+
>
|
81
|
+
{initialShadowState.map(({ id, text }) => (
|
82
|
+
<Card dragId={id}
|
83
|
+
draggableItem
|
84
|
+
key={id}
|
85
|
+
marginBottom="xs"
|
86
|
+
padding="xs"
|
87
|
+
{...props}
|
88
|
+
>
|
89
|
+
<Flex alignItems="stretch"
|
90
|
+
flexDirection="column"
|
91
|
+
>
|
92
|
+
<Body
|
93
|
+
text={text}
|
94
|
+
{...props}
|
95
|
+
/>
|
96
|
+
</Flex>
|
97
|
+
</Card>
|
98
|
+
))}
|
99
|
+
</Draggable.Container>
|
100
|
+
</DraggableProvider>
|
101
|
+
</FlexItem>
|
102
|
+
<FlexItem marginRight="xl">
|
103
|
+
<DraggableProvider
|
104
|
+
dropZone={{type: "outline"}}
|
105
|
+
initialItems={dataOutline}
|
106
|
+
onReorder={(items) => setInitialOutlineState(items)}
|
107
|
+
>
|
108
|
+
<Caption
|
109
|
+
marginBottom="xs"
|
110
|
+
text="Outline"
|
111
|
+
textAlign="center"
|
112
|
+
/>
|
113
|
+
<Draggable.Container
|
114
|
+
htmlOptions={{style:{ width: "200px"}}}
|
115
|
+
{...props}
|
116
|
+
>
|
117
|
+
{initialOutlineState.map(({ id, text }) => (
|
118
|
+
<Card
|
119
|
+
dragId={id}
|
120
|
+
draggableItem
|
121
|
+
key={id}
|
122
|
+
marginBottom="xs"
|
123
|
+
padding="xs"
|
124
|
+
{...props}
|
125
|
+
>
|
126
|
+
<Flex
|
127
|
+
alignItems="stretch"
|
128
|
+
flexDirection="column"
|
129
|
+
>
|
130
|
+
<Body
|
131
|
+
text={text}
|
132
|
+
{...props}
|
133
|
+
/>
|
134
|
+
</Flex>
|
135
|
+
</Card>
|
136
|
+
))}
|
137
|
+
</Draggable.Container>
|
138
|
+
</DraggableProvider>
|
139
|
+
</FlexItem>
|
140
|
+
<FlexItem>
|
141
|
+
<DraggableProvider
|
142
|
+
dropZone={{type: "line"}}
|
143
|
+
initialItems={dataLine}
|
144
|
+
onReorder={(items) => setInitialLineState(items)}
|
145
|
+
>
|
146
|
+
<Caption
|
147
|
+
marginBottom="xs"
|
148
|
+
text="Line"
|
149
|
+
textAlign="center"
|
150
|
+
/>
|
151
|
+
<Draggable.Container
|
152
|
+
htmlOptions={{style:{ width: "200px"}}}
|
153
|
+
{...props}
|
154
|
+
>
|
155
|
+
{initialLineState.map(({ id, text }) => (
|
156
|
+
<Card dragId={id}
|
157
|
+
draggableItem
|
158
|
+
key={id}
|
159
|
+
marginBottom="xs"
|
160
|
+
padding="xs"
|
161
|
+
{...props}
|
162
|
+
>
|
163
|
+
<Flex alignItems="stretch"
|
164
|
+
flexDirection="column"
|
165
|
+
>
|
166
|
+
<Body
|
167
|
+
text={text}
|
168
|
+
{...props}
|
169
|
+
/>
|
170
|
+
</Flex>
|
171
|
+
</Card>
|
172
|
+
))}
|
173
|
+
</Draggable.Container>
|
174
|
+
</DraggableProvider>
|
175
|
+
</FlexItem>
|
176
|
+
</Flex>
|
177
|
+
</>
|
178
|
+
);
|
179
|
+
};
|
180
|
+
|
181
|
+
export default DraggableDropZones;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The Draggable kit lets you customize the style of drop zones that appear when dragging an item.
|
2
|
+
|
3
|
+
By default, drop zones are in the "ghost" style, but you can also choose from "shadow," "outline," and "line."
|
4
|
+
|
5
|
+
When using the "line" type, make sure to set the appropriate `direction` attribute within the `dropZone` prop based on the orientation of your draggable view. By default, this is set to "vertical," but it can also be adjusted to "horizontal." Note that the direction attribute only applies to the "line" type and does not affect other drop zone styles. For more on the "line" style in particular, check out the [Draggable Drop Zones Line doc example](https://playbook.powerapp.cloud/kits/draggable/react#draggable-drop-zones-line).
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
|
3
|
+
import Flex from '../../pb_flex/_flex'
|
4
|
+
import Image from '../../pb_image/_image'
|
5
|
+
import Caption from '../../pb_caption/_caption'
|
6
|
+
import Draggable from '../../pb_draggable/_draggable'
|
7
|
+
import { DraggableProvider } from '../../pb_draggable/context'
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
// Initial items to be dragged
|
12
|
+
const dataPrimary = [
|
13
|
+
{
|
14
|
+
id: "81",
|
15
|
+
url: "https://unsplash.it/500/400/?image=633",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
id: "82",
|
19
|
+
url: "https://unsplash.it/500/400/?image=634",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
id: "83",
|
23
|
+
url: "https://unsplash.it/500/400/?image=637",
|
24
|
+
},
|
25
|
+
];
|
26
|
+
const dataPurple = [
|
27
|
+
{
|
28
|
+
id: "91",
|
29
|
+
url: "https://unsplash.it/500/400/?image=633",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
id: "92",
|
33
|
+
url: "https://unsplash.it/500/400/?image=634",
|
34
|
+
},
|
35
|
+
{
|
36
|
+
id: "93",
|
37
|
+
url: "https://unsplash.it/500/400/?image=637",
|
38
|
+
},
|
39
|
+
];
|
40
|
+
|
41
|
+
const DraggableDropZonesColors = (props) => {
|
42
|
+
const [initialPrimaryState, setInitialPrimaryState] = useState(dataPrimary);
|
43
|
+
const [initialPurpleState, setInitialPurpleState] = useState(dataPurple);
|
44
|
+
|
45
|
+
return (
|
46
|
+
<>
|
47
|
+
<Caption marginBottom="xs"
|
48
|
+
text="Primary"
|
49
|
+
/>
|
50
|
+
<DraggableProvider
|
51
|
+
dropZone={{type: "shadow", color: "primary"}}
|
52
|
+
initialItems={dataPrimary}
|
53
|
+
onReorder={(items) => setInitialPrimaryState(items)}
|
54
|
+
>
|
55
|
+
<Draggable.Container {...props}>
|
56
|
+
<Flex>
|
57
|
+
{initialPrimaryState.map(({ id, url }) => (
|
58
|
+
<Draggable.Item dragId={id}
|
59
|
+
key={id}
|
60
|
+
marginRight="sm"
|
61
|
+
>
|
62
|
+
<Image alt={id}
|
63
|
+
size="md"
|
64
|
+
url={url}
|
65
|
+
/>
|
66
|
+
</Draggable.Item>
|
67
|
+
))}
|
68
|
+
</Flex>
|
69
|
+
</Draggable.Container>
|
70
|
+
</DraggableProvider>
|
71
|
+
<Caption marginBottom="xs"
|
72
|
+
text="Purple"
|
73
|
+
/>
|
74
|
+
<DraggableProvider
|
75
|
+
dropZone={{type: "outline", color: "purple"}}
|
76
|
+
initialItems={dataPurple}
|
77
|
+
onReorder={(items) => setInitialPurpleState(items)}
|
78
|
+
>
|
79
|
+
<Draggable.Container {...props}>
|
80
|
+
<Flex>
|
81
|
+
{initialPurpleState.map(({ id, url }) => (
|
82
|
+
<Draggable.Item dragId={id}
|
83
|
+
key={id}
|
84
|
+
marginRight="sm"
|
85
|
+
>
|
86
|
+
<Image alt={id}
|
87
|
+
size="md"
|
88
|
+
url={url}
|
89
|
+
/>
|
90
|
+
</Draggable.Item>
|
91
|
+
))}
|
92
|
+
</Flex>
|
93
|
+
</Draggable.Container>
|
94
|
+
</DraggableProvider>
|
95
|
+
</>
|
96
|
+
);
|
97
|
+
};
|
98
|
+
|
99
|
+
export default DraggableDropZonesColors;
|
@@ -0,0 +1 @@
|
|
1
|
+
The default `color` for Draggable kit drop zones is "neutral", with "primary" or "purple" as additional options. When `type` is set to "line", the default color is "primary" and "purple" is the only other option.
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import Flex from '../../pb_flex/_flex'
|
3
|
+
import Caption from '../../pb_caption/_caption'
|
4
|
+
import Draggable from '../_draggable'
|
5
|
+
import { DraggableProvider } from '../context'
|
6
|
+
import Image from '../../pb_image/_image'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
const dataLineVertical = [
|
11
|
+
{
|
12
|
+
id: "211",
|
13
|
+
url: "https://unsplash.it/500/400/?image=633",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
id: "212",
|
17
|
+
url: "https://unsplash.it/500/400/?image=634",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
id: "213",
|
21
|
+
url: "https://unsplash.it/500/400/?image=637",
|
22
|
+
},
|
23
|
+
];
|
24
|
+
|
25
|
+
const dataLineHorizontal = [
|
26
|
+
{
|
27
|
+
id: "2111",
|
28
|
+
url: "https://unsplash.it/500/400/?image=633",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
id: "2122",
|
32
|
+
url: "https://unsplash.it/500/400/?image=634",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
id: "2133",
|
36
|
+
url: "https://unsplash.it/500/400/?image=637",
|
37
|
+
},
|
38
|
+
];
|
39
|
+
|
40
|
+
const DraggableDropZones = (props) => {
|
41
|
+
const [initialLineVerticalState, setInitialLineVerticalState] = useState(dataLineVertical);
|
42
|
+
const [initialLineHorizontalState, setInitialLineHorizontalState] = useState(dataLineHorizontal);
|
43
|
+
|
44
|
+
return (
|
45
|
+
<>
|
46
|
+
<Caption marginBottom="xs"
|
47
|
+
marginTop="xl"
|
48
|
+
text="Vertical"
|
49
|
+
/>
|
50
|
+
<DraggableProvider
|
51
|
+
dropZone={{ type: "line", color: "purple" }}
|
52
|
+
initialItems={dataLineVertical}
|
53
|
+
onReorder={(items) => setInitialLineVerticalState(items)}
|
54
|
+
>
|
55
|
+
<Draggable.Container {...props}>
|
56
|
+
<Flex flexDirection="column"
|
57
|
+
height="367px"
|
58
|
+
>
|
59
|
+
{initialLineVerticalState.map(({ id, url }) => (
|
60
|
+
<Draggable.Item dragId={id}
|
61
|
+
key={id}
|
62
|
+
marginBottom="sm"
|
63
|
+
>
|
64
|
+
<Image alt={id}
|
65
|
+
size="md"
|
66
|
+
url={url}
|
67
|
+
/>
|
68
|
+
</Draggable.Item>
|
69
|
+
))}
|
70
|
+
</Flex>
|
71
|
+
</Draggable.Container>
|
72
|
+
</DraggableProvider>
|
73
|
+
<Caption marginBottom="xs"
|
74
|
+
marginTop="xl"
|
75
|
+
text="Horizontal"
|
76
|
+
/>
|
77
|
+
<Flex>
|
78
|
+
<DraggableProvider
|
79
|
+
dropZone={{ type: "line", direction: "horizontal" }}
|
80
|
+
initialItems={dataLineHorizontal}
|
81
|
+
onReorder={(items) => setInitialLineHorizontalState(items)}
|
82
|
+
>
|
83
|
+
<Draggable.Container
|
84
|
+
htmlOptions={{style:{ width: "285px"}}}
|
85
|
+
{...props}
|
86
|
+
>
|
87
|
+
<Flex alignItems="stretch"
|
88
|
+
flexDirection="row"
|
89
|
+
height="110px"
|
90
|
+
>
|
91
|
+
{initialLineHorizontalState.map(({ id, url }) => (
|
92
|
+
<Draggable.Item dragId={id}
|
93
|
+
key={id}
|
94
|
+
marginRight="sm"
|
95
|
+
>
|
96
|
+
<Image alt={id}
|
97
|
+
size="md"
|
98
|
+
url={url}
|
99
|
+
/>
|
100
|
+
</Draggable.Item>
|
101
|
+
))}
|
102
|
+
</Flex>
|
103
|
+
</Draggable.Container>
|
104
|
+
</DraggableProvider>
|
105
|
+
</Flex>
|
106
|
+
</>
|
107
|
+
);
|
108
|
+
};
|
109
|
+
|
110
|
+
export default DraggableDropZones;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
When using the "line" style, make sure to set the appropriate `direction` attribute within the `dropZone` prop based on the orientation of your draggable view. By default, this is set to "vertical," but it can also be adjusted to "horizontal." Note that the direction attribute only applies to the "line" style and does not affect other drop zone styles. The default `color` for "line" is "primary" and "purple" is the only alternative color option.
|
2
|
+
|
3
|
+
The length of the line is calculated based off of the width (for "vertical") or height (for "horizontal") of the parent container holding the draggable items.
|
4
|
+
|
5
|
+
Additionally, if the parent container of the `DraggableProvider`/`DraggableContainer` (or a subcontainer within) does not have a set height (for "vertical") or width (for "horizontal"), like the [Draggable Drop Zones doc example](https://playbook.powerapp.cloud/kits/draggable/react#draggable-drop-zones) does, elements on the page may jump up (for "vertical") or to the left (for "horizontal") when an item is actively being dragged. To prevent this, give a parent element a fixed height (for "vertical") or width (for "horizontal") as demonstrated in this doc example.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
2
|
|
3
3
|
import Flex from '../../pb_flex/_flex'
|
4
|
-
import { DraggableProvider } from '
|
4
|
+
import { DraggableProvider } from '../context'
|
5
5
|
import Avatar from '../../pb_avatar/_avatar'
|
6
6
|
import Body from '../../pb_body/_body'
|
7
7
|
import Table from '../../pb_table/_table'
|
@@ -2,4 +2,6 @@ The draggable kit can also be used in conjunction with the table kit to create d
|
|
2
2
|
|
3
3
|
- Wrap the Table with the `DraggableProvider` and manage state as shown.
|
4
4
|
- use the `draggableContainer` prop on the Table.Body to designate it as the Draggable Container
|
5
|
-
- use the `draggableItem` prop on the Table.Row to designate it as the Draggable Item. Make sure to also pass id to the `dragId` prop here.
|
5
|
+
- use the `draggableItem` prop on the Table.Row to designate it as the Draggable Item. Make sure to also pass id to the `dragId` prop here.
|
6
|
+
|
7
|
+
We recommending using the default `dropZone type` with the Table kit.
|
@@ -4,14 +4,17 @@ examples:
|
|
4
4
|
- draggable_with_list: Draggable with List Kit
|
5
5
|
- draggable_with_selectable_list: Draggable with SelectableList Kit
|
6
6
|
- draggable_with_cards: Draggable with Cards
|
7
|
-
-
|
7
|
+
- draggable_with_table: Draggable with Table
|
8
8
|
- draggable_multiple_containers: Dragging Across Multiple Containers
|
9
|
+
- draggable_drop_zones: Draggable Drop Zones
|
10
|
+
- draggable_drop_zones_colors: Draggable Drop Zones Colors
|
11
|
+
- draggable_drop_zones_line: Draggable Drop Zones Line
|
9
12
|
|
10
13
|
rails:
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
14
|
+
- draggable_default: Default
|
15
|
+
- draggable_with_list: Draggable with List Kit
|
16
|
+
- draggable_with_selectable_list: Draggable with SelectableList Kit
|
17
|
+
- draggable_with_cards: Draggable with Cards
|
15
18
|
- draggable_with_table: Draggable with Table
|
16
|
-
-
|
19
|
+
- draggable_multiple_containers: Dragging Across Multiple Containers
|
17
20
|
|
@@ -3,4 +3,7 @@ export { default as DraggableWithCards } from './_draggable_with_cards.jsx'
|
|
3
3
|
export { default as DraggableWithList } from './_draggable_with_list.jsx'
|
4
4
|
export { default as DraggableWithSelectableList } from './_draggable_with_selectable_list.jsx'
|
5
5
|
export { default as DraggableMultipleContainers } from './_draggable_multiple_containers.jsx'
|
6
|
-
export { default as
|
6
|
+
export { default as DraggableWithTable } from './_draggable_with_table.jsx'
|
7
|
+
export { default as DraggableDropZones } from './_draggable_drop_zones.jsx'
|
8
|
+
export { default as DraggableDropZonesColors } from './_draggable_drop_zones_colors.jsx'
|
9
|
+
export { default as DraggableDropZonesLine } from './_draggable_drop_zones_line.jsx'
|
@@ -128,6 +128,58 @@ const DraggableKitWithCard = () => {
|
|
128
128
|
);
|
129
129
|
};
|
130
130
|
|
131
|
+
const DraggableWithLineVertical = () => {
|
132
|
+
const [initialState, setInitialState] = useState(data);
|
133
|
+
return (
|
134
|
+
<div data-testid={testId}>
|
135
|
+
<DraggableProvider
|
136
|
+
dropZone={{ type: "line" }}
|
137
|
+
initialItems={data}
|
138
|
+
onReorder={(items) => setInitialState(items)}
|
139
|
+
>
|
140
|
+
<Draggable>
|
141
|
+
<Draggable.Container>
|
142
|
+
{initialState.map(({ id, text }) => (
|
143
|
+
<Draggable.Item
|
144
|
+
dragId={id}
|
145
|
+
key={id}
|
146
|
+
>
|
147
|
+
{text}
|
148
|
+
</Draggable.Item>
|
149
|
+
))}
|
150
|
+
</Draggable.Container>
|
151
|
+
</Draggable>
|
152
|
+
</DraggableProvider>
|
153
|
+
</div>
|
154
|
+
);
|
155
|
+
};
|
156
|
+
|
157
|
+
const DraggableWithLineHorizontal = () => {
|
158
|
+
const [initialState, setInitialState] = useState(data);
|
159
|
+
return (
|
160
|
+
<div data-testid={testId}>
|
161
|
+
<DraggableProvider
|
162
|
+
dropZone={{ type: "line", direction: "horizontal" }}
|
163
|
+
initialItems={data}
|
164
|
+
onReorder={(items) => setInitialState(items)}
|
165
|
+
>
|
166
|
+
<Draggable>
|
167
|
+
<Draggable.Container>
|
168
|
+
{initialState.map(({ id, text }) => (
|
169
|
+
<Draggable.Item
|
170
|
+
dragId={id}
|
171
|
+
key={id}
|
172
|
+
>
|
173
|
+
{text}
|
174
|
+
</Draggable.Item>
|
175
|
+
))}
|
176
|
+
</Draggable.Container>
|
177
|
+
</Draggable>
|
178
|
+
</DraggableProvider>
|
179
|
+
</div>
|
180
|
+
);
|
181
|
+
};
|
182
|
+
|
131
183
|
test("generated default kit and classname", () => {
|
132
184
|
render(<DefaultDraggableKit />);
|
133
185
|
const kit = screen.getByTestId(testId);
|
@@ -165,7 +217,7 @@ test("generated dragHandle with List", () => {
|
|
165
217
|
|
166
218
|
const list = kit.querySelector(".pb_list_kit");
|
167
219
|
expect(list).toBeInTheDocument();
|
168
|
-
const dragHandle = list.querySelector(".
|
220
|
+
const dragHandle = list.querySelector(".pb_custom_icon");
|
169
221
|
expect(dragHandle).toBeInTheDocument();
|
170
222
|
});
|
171
223
|
|
@@ -175,7 +227,7 @@ test("generated dragHandle with SelectableList", () => {
|
|
175
227
|
|
176
228
|
const selectabellist = kit.querySelector(".pb_selectable_list_kit");
|
177
229
|
expect(selectabellist).toBeInTheDocument();
|
178
|
-
const dragHandle = selectabellist.querySelector(".
|
230
|
+
const dragHandle = selectabellist.querySelector(".pb_custom_icon");
|
179
231
|
expect(dragHandle).toBeInTheDocument();
|
180
232
|
});
|
181
233
|
|
@@ -185,6 +237,22 @@ test("generated dragHandle with Card", () => {
|
|
185
237
|
|
186
238
|
const card = kit.querySelector(".pb_card_kit_deselected_border_radius_md");
|
187
239
|
expect(card).toBeInTheDocument();
|
188
|
-
const dragHandle = card.querySelector(".
|
240
|
+
const dragHandle = card.querySelector(".pb_custom_icon");
|
189
241
|
expect(dragHandle).toBeInTheDocument();
|
190
242
|
});
|
243
|
+
|
244
|
+
test("line dropZone with default direction applies 'line_vertical' class to container", () => {
|
245
|
+
render(<DraggableWithLineVertical />);
|
246
|
+
const kit = screen.getByTestId(testId);
|
247
|
+
const container = kit.querySelector(".pb_draggable_container");
|
248
|
+
|
249
|
+
expect(container).toHaveClass("line_vertical");
|
250
|
+
});
|
251
|
+
|
252
|
+
test("line dropZone with horizontal direction applies 'line_horizontal' class to container", () => {
|
253
|
+
render(<DraggableWithLineHorizontal />);
|
254
|
+
const kit = screen.getByTestId(testId);
|
255
|
+
const container = kit.querySelector(".pb_draggable_container");
|
256
|
+
|
257
|
+
expect(container).toHaveClass("line_horizontal");
|
258
|
+
});
|
@@ -22,18 +22,28 @@ type DraggableContainerProps = {
|
|
22
22
|
|
23
23
|
const DraggableContainer = (props: DraggableContainerProps) => {
|
24
24
|
const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id, tag="div" } = props;
|
25
|
+
const contextValues = DraggableContext();
|
26
|
+
const {
|
27
|
+
handleDragOver,
|
28
|
+
handleDrop,
|
29
|
+
activeContainer,
|
30
|
+
dropZone
|
31
|
+
} = contextValues;
|
25
32
|
|
26
|
-
|
33
|
+
// Only get direction if dropZone is 'line'
|
34
|
+
const direction = dropZone === 'line' ? (contextValues.direction || 'vertical') : null;
|
27
35
|
|
28
36
|
const ariaProps = buildAriaProps(aria);
|
29
37
|
const dataProps = buildDataProps(data);
|
30
38
|
const htmlProps = buildHtmlProps(htmlOptions);
|
31
|
-
|
32
39
|
const Tag: React.ReactElement | any = `${tag}`;
|
33
40
|
|
34
41
|
const classes = classnames(
|
35
42
|
buildCss("pb_draggable_container"),
|
36
43
|
`${activeContainer === container ? "active" : ""}`,
|
44
|
+
// Line variant gets line_{direction} classname on container no matter what
|
45
|
+
dropZone === 'line' && direction === 'vertical' ? 'line_vertical' : '',
|
46
|
+
dropZone === 'line' && direction === 'horizontal' ? 'line_horizontal' : '',
|
37
47
|
globalProps(props),
|
38
48
|
className
|
39
49
|
);
|