playbook_ui 14.16.0.pre.rc.6 → 14.16.0
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_bar_graph/_bar_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +115 -5
- data/app/pb_kits/playbook/pb_draggable/_draggable.tsx +6 -4
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +35 -9
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +35 -28
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.jsx +184 -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 +97 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +11 -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_filter/Filter/SortMenu.tsx +2 -1
- 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_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_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_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_line_graph/_line_graph.tsx +1 -1
- 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 +26 -0
- 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_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/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- 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 +27 -6
- 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/tokens/_colors.scss +1 -4
- data/app/pb_kits/playbook/utilities/object.test.js +139 -1
- data/app/pb_kits/playbook/utilities/object.ts +86 -0
- data/app/pb_kits/playbook/utilities/text.ts +1 -1
- data/dist/chunks/_typeahead-BuTZG1Jn.js +22 -0
- data/dist/chunks/_weekday_stacked-oT22q75-.js +45 -0
- data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
- data/dist/chunks/{lib-BeKPJYlk.js → lib-Co5y3V4K.js} +2 -2
- data/dist/chunks/{pb_form_validation-BvDxpfs-.js → pb_form_validation-DMajaRt3.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/version.rb +1 -1
- metadata +23 -7
- data/dist/chunks/_typeahead-CRAPc8k-.js +0 -22
- data/dist/chunks/_weekday_stacked-T0kFfioG.js +0 -45
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbada6b3906a7bdd5cd17ccdc6db4251385789e29416980b5f3ffa501a9c9f94
|
4
|
+
data.tar.gz: 27b40157f9658e595e8f0ee77c1fc837c2bb80f0c794df82715de2d59dce8a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45a55efaef13d3ccc5e8907b755ce1e2aa1fb428b87b9c6ca8fad3f5d268e71e0b72ba2d71fe8d372443d501ab76a37f864e6c2744c71012360f0036defcbb8
|
7
|
+
data.tar.gz: a070cb303d181a6a48842fed3ebba697ca17428cd4b6e475f9b0cb97565351dac99b78d81a1ee76582d12cdde9841f2434be5b755035fe83c3d7bf78b41adcf3
|
@@ -7,7 +7,7 @@ import Highcharts from "highcharts";
|
|
7
7
|
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
8
8
|
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
9
9
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
10
|
-
import { merge } from '
|
10
|
+
import { merge } from '../utilities/object'
|
11
11
|
|
12
12
|
import classnames from "classnames";
|
13
13
|
|
@@ -10,7 +10,7 @@ import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
|
10
10
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
11
|
import { globalProps } from "../utilities/globalProps";
|
12
12
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
13
|
-
import { merge } from '
|
13
|
+
import { merge } from '../utilities/object'
|
14
14
|
|
15
15
|
type CircleChartProps = {
|
16
16
|
align?: "left" | "right" | "center";
|
@@ -2,10 +2,120 @@
|
|
2
2
|
@import "../tokens/opacity";
|
3
3
|
|
4
4
|
.pb_draggable_container {
|
5
|
-
.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
.pb_draggable_item {
|
6
|
+
&:hover {
|
7
|
+
cursor: grab;
|
8
|
+
}
|
9
|
+
|
10
|
+
&.is_dragging {
|
11
|
+
position: relative;
|
12
|
+
|
13
|
+
// Ghost variant - show the item at 50% opacity. Default behavior.
|
14
|
+
&.drop_zone_ghost {
|
15
|
+
opacity: $opacity_4;
|
16
|
+
}
|
17
|
+
|
18
|
+
// Outline variant
|
19
|
+
&.drop_zone_outline {
|
20
|
+
// Create a container for the outline
|
21
|
+
position: relative;
|
22
|
+
|
23
|
+
// Make content invisible
|
24
|
+
& > * {
|
25
|
+
opacity: 0;
|
26
|
+
}
|
27
|
+
|
28
|
+
// Add outline
|
29
|
+
&::before {
|
30
|
+
content: '';
|
31
|
+
position: absolute;
|
32
|
+
top: 0;
|
33
|
+
left: 0;
|
34
|
+
width: 100%;
|
35
|
+
height: 100%;
|
36
|
+
border: 2px dashed $neutral;
|
37
|
+
border-radius: $border-radius-sm;
|
38
|
+
box-sizing: border-box;
|
39
|
+
z-index: 10;
|
40
|
+
pointer-events: none;
|
41
|
+
}
|
42
|
+
|
43
|
+
// Apply color variants to the ::before element
|
44
|
+
&.drop_zone_color_primary::before { border-color: $primary; }
|
45
|
+
&.drop_zone_color_purple::before { border-color: $purple; }
|
46
|
+
}
|
47
|
+
|
48
|
+
// Shadow variant
|
49
|
+
&.drop_zone_shadow {
|
50
|
+
// Create a container for the shadow
|
51
|
+
position: relative;
|
52
|
+
|
53
|
+
// Make content invisible
|
54
|
+
& > * {
|
55
|
+
opacity: 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
// Add shadow background
|
59
|
+
&::before {
|
60
|
+
content: '';
|
61
|
+
position: absolute;
|
62
|
+
top: 0;
|
63
|
+
left: 0;
|
64
|
+
width: 100%;
|
65
|
+
height: 100%;
|
66
|
+
background-color: rgba($neutral, $opacity_5);
|
67
|
+
border-radius: $border-radius-sm;
|
68
|
+
z-index: 10;
|
69
|
+
pointer-events: none;
|
70
|
+
}
|
71
|
+
|
72
|
+
// Apply rgba color variants to the ::before element
|
73
|
+
&.drop_zone_color_primary::before { background-color: rgba($primary, $opacity_5); }
|
74
|
+
&.drop_zone_color_purple::before { background-color: rgba($purple, $opacity_5); }
|
75
|
+
}
|
76
|
+
|
77
|
+
// Line variant
|
78
|
+
&.drop_zone_line {
|
79
|
+
// Hide the original content to show the line
|
80
|
+
& > * {
|
81
|
+
opacity: 0;
|
82
|
+
}
|
83
|
+
|
84
|
+
// Style for horizontal line (default)
|
85
|
+
&::before {
|
86
|
+
content: '';
|
87
|
+
position: absolute;
|
88
|
+
left: 0;
|
89
|
+
top: 0;
|
90
|
+
width: 4px;
|
91
|
+
height: 100%;
|
92
|
+
background-color: $neutral;
|
93
|
+
border-radius: 1000px;
|
94
|
+
z-index: 10;
|
95
|
+
pointer-events: none;
|
96
|
+
}
|
97
|
+
|
98
|
+
// Apply color variants
|
99
|
+
&.drop_zone_color_primary::before { background-color: $primary; }
|
100
|
+
&.drop_zone_color_purple::before { background-color: $purple; }
|
101
|
+
}
|
102
|
+
}
|
10
103
|
}
|
11
104
|
}
|
105
|
+
|
106
|
+
// Support for vertical layouts (horizontal line)
|
107
|
+
.pb_draggable_container.vertical {
|
108
|
+
.pb_draggable_item {
|
109
|
+
&.is_dragging {
|
110
|
+
// Line variant for vertical layouts (horizontal line)
|
111
|
+
&.drop_zone_line {
|
112
|
+
&::before {
|
113
|
+
width: 100%;
|
114
|
+
height: 4px;
|
115
|
+
left: 0;
|
116
|
+
top: 0;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
@@ -10,6 +10,8 @@ type DraggableProps = {
|
|
10
10
|
className?: string;
|
11
11
|
children?: React.ReactNode;
|
12
12
|
data?: { [key: string]: string };
|
13
|
+
dropZone?: 'ghost' | 'outline' | 'shadow' | 'line';
|
14
|
+
dropZoneColor?: 'primary' | 'neutral' | 'purple';
|
13
15
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
14
16
|
id?: string;
|
15
17
|
};
|
@@ -24,7 +26,6 @@ const Draggable = (props: DraggableProps) => {
|
|
24
26
|
id,
|
25
27
|
} = props;
|
26
28
|
|
27
|
-
|
28
29
|
const ariaProps = buildAriaProps(aria);
|
29
30
|
const dataProps = buildDataProps(data);
|
30
31
|
const htmlProps = buildHtmlProps(htmlOptions);
|
@@ -36,10 +37,11 @@ const Draggable = (props: DraggableProps) => {
|
|
36
37
|
);
|
37
38
|
|
38
39
|
return (
|
39
|
-
<div
|
40
|
-
{...
|
40
|
+
<div
|
41
|
+
{...ariaProps}
|
42
|
+
{...dataProps}
|
41
43
|
{...htmlProps}
|
42
|
-
className={classes}
|
44
|
+
className={classes}
|
43
45
|
id={id}
|
44
46
|
>
|
45
47
|
{children}
|
@@ -51,18 +51,39 @@ export const DraggableContext = () => {
|
|
51
51
|
return useContext(DragContext);
|
52
52
|
};
|
53
53
|
|
54
|
-
export const DraggableProvider = ({
|
55
|
-
children,
|
56
|
-
initialItems,
|
54
|
+
export const DraggableProvider = ({
|
55
|
+
children,
|
56
|
+
initialItems,
|
57
57
|
onReorder,
|
58
|
-
onDragStart,
|
59
|
-
onDragEnter,
|
60
|
-
onDragEnd,
|
61
|
-
onDrop,
|
62
|
-
onDragOver
|
58
|
+
onDragStart,
|
59
|
+
onDragEnter,
|
60
|
+
onDragEnd,
|
61
|
+
onDrop,
|
62
|
+
onDragOver,
|
63
|
+
dropZone = { type: 'ghost', color: 'neutral', direction: 'vertical' }
|
63
64
|
}: DraggableProviderType) => {
|
64
65
|
const [state, dispatch] = useReducer(reducer, initialState);
|
65
66
|
|
67
|
+
// Parse dropZone prop - handle both string format (backward compatibility) and object format
|
68
|
+
let dropZoneType = 'ghost';
|
69
|
+
let dropZoneColor = 'neutral';
|
70
|
+
let dropZoneDirection = 'vertical';
|
71
|
+
|
72
|
+
if (typeof dropZone === 'string') {
|
73
|
+
// Legacy format - just the type is provided as a string
|
74
|
+
dropZoneType = dropZone;
|
75
|
+
} else {
|
76
|
+
// New object format
|
77
|
+
dropZoneType = dropZone.type || 'ghost';
|
78
|
+
// Line default is set to primary. Other types default to neutral.
|
79
|
+
dropZoneColor = dropZone.type === 'line' ? (dropZone.color || 'primary') : (dropZone.color || 'neutral');
|
80
|
+
|
81
|
+
// Only use direction if the type is 'line'
|
82
|
+
if (dropZoneType === 'line') {
|
83
|
+
dropZoneDirection = dropZone.direction || 'vertical';
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
66
87
|
useEffect(() => {
|
67
88
|
dispatch({ type: 'SET_ITEMS', payload: initialItems });
|
68
89
|
}, [initialItems]);
|
@@ -108,17 +129,22 @@ export const DraggableProvider = ({
|
|
108
129
|
if (onDragOver) onDragOver(e, container);
|
109
130
|
};
|
110
131
|
|
132
|
+
// Include direction in contextValue only if type is 'line'
|
111
133
|
const contextValue = useMemo(() => ({
|
112
134
|
items: state.items,
|
113
135
|
dragData: state.dragData,
|
114
136
|
isDragging: state.isDragging,
|
115
137
|
activeContainer: state.activeContainer,
|
138
|
+
dropZone: dropZoneType,
|
139
|
+
dropZoneColor,
|
140
|
+
// Only include direction when type is 'line'
|
141
|
+
...(dropZoneType === 'line' ? { direction: dropZoneDirection } : {}),
|
116
142
|
handleDragStart,
|
117
143
|
handleDragEnter,
|
118
144
|
handleDragEnd,
|
119
145
|
handleDrop,
|
120
146
|
handleDragOver
|
121
|
-
}), [state]);
|
147
|
+
}), [state, dropZoneType, dropZoneColor, dropZoneDirection]);
|
122
148
|
|
123
149
|
return (
|
124
150
|
<DragContext.Provider value={contextValue}>{children}</DragContext.Provider>
|
@@ -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,184 @@
|
|
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
|
+
textAlign="center"
|
75
|
+
>
|
76
|
+
{"Shadow"}
|
77
|
+
</Caption>
|
78
|
+
<Draggable.Container
|
79
|
+
htmlOptions={{style:{ width: "200px"}}}
|
80
|
+
{...props}
|
81
|
+
>
|
82
|
+
{initialShadowState.map(({ id, text }) => (
|
83
|
+
<Card dragId={id}
|
84
|
+
draggableItem
|
85
|
+
key={id}
|
86
|
+
marginBottom="xs"
|
87
|
+
padding="xs"
|
88
|
+
{...props}
|
89
|
+
>
|
90
|
+
<Flex alignItems="stretch"
|
91
|
+
flexDirection="column"
|
92
|
+
>
|
93
|
+
<Body
|
94
|
+
text={text}
|
95
|
+
{...props}
|
96
|
+
/>
|
97
|
+
</Flex>
|
98
|
+
</Card>
|
99
|
+
))}
|
100
|
+
</Draggable.Container>
|
101
|
+
</DraggableProvider>
|
102
|
+
</FlexItem>
|
103
|
+
<FlexItem marginRight="xl">
|
104
|
+
<DraggableProvider
|
105
|
+
dropZone={{type: "outline"}}
|
106
|
+
initialItems={dataOutline}
|
107
|
+
onReorder={(items) => setInitialOutlineState(items)}
|
108
|
+
>
|
109
|
+
<Caption
|
110
|
+
marginBottom="xs"
|
111
|
+
textAlign="center"
|
112
|
+
>
|
113
|
+
{"Outline"}
|
114
|
+
</Caption>
|
115
|
+
<Draggable.Container
|
116
|
+
htmlOptions={{style:{ width: "200px"}}}
|
117
|
+
{...props}
|
118
|
+
>
|
119
|
+
{initialOutlineState.map(({ id, text }) => (
|
120
|
+
<Card
|
121
|
+
dragId={id}
|
122
|
+
draggableItem
|
123
|
+
key={id}
|
124
|
+
marginBottom="xs"
|
125
|
+
padding="xs"
|
126
|
+
{...props}
|
127
|
+
>
|
128
|
+
<Flex
|
129
|
+
alignItems="stretch"
|
130
|
+
flexDirection="column"
|
131
|
+
>
|
132
|
+
<Body
|
133
|
+
text={text}
|
134
|
+
{...props}
|
135
|
+
/>
|
136
|
+
</Flex>
|
137
|
+
</Card>
|
138
|
+
))}
|
139
|
+
</Draggable.Container>
|
140
|
+
</DraggableProvider>
|
141
|
+
</FlexItem>
|
142
|
+
<FlexItem>
|
143
|
+
<DraggableProvider
|
144
|
+
dropZone={{type: "line"}}
|
145
|
+
initialItems={dataLine}
|
146
|
+
onReorder={(items) => setInitialLineState(items)}
|
147
|
+
>
|
148
|
+
<Caption
|
149
|
+
marginBottom="xs"
|
150
|
+
textAlign="center"
|
151
|
+
>
|
152
|
+
{"Line"}
|
153
|
+
</Caption>
|
154
|
+
<Draggable.Container
|
155
|
+
htmlOptions={{style:{ width: "200px"}}}
|
156
|
+
{...props}
|
157
|
+
>
|
158
|
+
{initialLineState.map(({ id, text }) => (
|
159
|
+
<Card dragId={id}
|
160
|
+
draggableItem
|
161
|
+
key={id}
|
162
|
+
marginBottom="xs"
|
163
|
+
padding="xs"
|
164
|
+
{...props}
|
165
|
+
>
|
166
|
+
<Flex alignItems="stretch"
|
167
|
+
flexDirection="column"
|
168
|
+
>
|
169
|
+
<Body
|
170
|
+
text={text}
|
171
|
+
{...props}
|
172
|
+
/>
|
173
|
+
</Flex>
|
174
|
+
</Card>
|
175
|
+
))}
|
176
|
+
</Draggable.Container>
|
177
|
+
</DraggableProvider>
|
178
|
+
</FlexItem>
|
179
|
+
</Flex>
|
180
|
+
</>
|
181
|
+
);
|
182
|
+
};
|
183
|
+
|
184
|
+
export default DraggableDropZones;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The Draggable kit allows you to choose the style of drop zones that appear when dragging an item.
|
2
|
+
|
3
|
+
By default, the Draggable kit utilizes the "ghost" style for drop zones, but you can also choose between "shadow", "outline", and "line".
|
4
|
+
|
5
|
+
Additionally, when using the "line" style, be sure to set the proper `direction` attribute within the `dropZone` prop depending on the orentation of your draggable view. By default, this attribute is set to "vertical", but can also be used with a "horizontal" direction. The `direction` attribute only applies to the "line" style and will not affect other drop zone styles.
|
@@ -0,0 +1,97 @@
|
|
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
|
+
// Initial items to be dragged
|
10
|
+
const dataPrimary = [
|
11
|
+
{
|
12
|
+
id: "81",
|
13
|
+
url: "https://unsplash.it/500/400/?image=633",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
id: "82",
|
17
|
+
url: "https://unsplash.it/500/400/?image=634",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
id: "83",
|
21
|
+
url: "https://unsplash.it/500/400/?image=637",
|
22
|
+
},
|
23
|
+
];
|
24
|
+
const dataPurple = [
|
25
|
+
{
|
26
|
+
id: "91",
|
27
|
+
url: "https://unsplash.it/500/400/?image=633",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
id: "92",
|
31
|
+
url: "https://unsplash.it/500/400/?image=634",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
id: "93",
|
35
|
+
url: "https://unsplash.it/500/400/?image=637",
|
36
|
+
},
|
37
|
+
];
|
38
|
+
|
39
|
+
const DraggableDropZonesColors = (props) => {
|
40
|
+
const [initialPrimaryState, setInitialPrimaryState] = useState(dataPrimary);
|
41
|
+
const [initialPurpleState, setInitialPurpleState] = useState(dataPurple);
|
42
|
+
|
43
|
+
return (
|
44
|
+
<>
|
45
|
+
<Caption marginBottom="xs">
|
46
|
+
Primary
|
47
|
+
</Caption>
|
48
|
+
<DraggableProvider
|
49
|
+
dropZone={{type: "shadow", color: "primary"}}
|
50
|
+
initialItems={dataPrimary}
|
51
|
+
onReorder={(items) => setInitialPrimaryState(items)}
|
52
|
+
>
|
53
|
+
<Draggable.Container {...props}>
|
54
|
+
<Flex>
|
55
|
+
{initialPrimaryState.map(({ id, url }) => (
|
56
|
+
<Draggable.Item dragId={id}
|
57
|
+
key={id}
|
58
|
+
marginRight="sm"
|
59
|
+
>
|
60
|
+
<Image alt={id}
|
61
|
+
size="md"
|
62
|
+
url={url}
|
63
|
+
/>
|
64
|
+
</Draggable.Item>
|
65
|
+
))}
|
66
|
+
</Flex>
|
67
|
+
</Draggable.Container>
|
68
|
+
</DraggableProvider>
|
69
|
+
<Caption marginBottom="xs">
|
70
|
+
Purple
|
71
|
+
</Caption>
|
72
|
+
<DraggableProvider
|
73
|
+
dropZone={{type: "outline", color: "purple"}}
|
74
|
+
initialItems={dataPurple}
|
75
|
+
onReorder={(items) => setInitialPurpleState(items)}
|
76
|
+
>
|
77
|
+
<Draggable.Container {...props}>
|
78
|
+
<Flex>
|
79
|
+
{initialPurpleState.map(({ id, url }) => (
|
80
|
+
<Draggable.Item dragId={id}
|
81
|
+
key={id}
|
82
|
+
marginRight="sm"
|
83
|
+
>
|
84
|
+
<Image alt={id}
|
85
|
+
size="md"
|
86
|
+
url={url}
|
87
|
+
/>
|
88
|
+
</Draggable.Item>
|
89
|
+
))}
|
90
|
+
</Flex>
|
91
|
+
</Draggable.Container>
|
92
|
+
</DraggableProvider>
|
93
|
+
</>
|
94
|
+
);
|
95
|
+
};
|
96
|
+
|
97
|
+
export default DraggableDropZonesColors;
|
@@ -0,0 +1 @@
|
|
1
|
+
By default, the Draggable kit sets the default color of drop zones to "neutral" (or "primary" if using the "line" style.)
|
@@ -22,18 +22,27 @@ 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') : 'vertical';
|
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
|
+
// Only add vertical class if dropZone is 'line' and direction is 'vertical'
|
45
|
+
(dropZone === 'line' && direction === 'vertical') ? 'vertical' : '',
|
37
46
|
globalProps(props),
|
38
47
|
className
|
39
48
|
);
|