playbook_ui 14.19.0.pre.rc.0 → 14.19.0.pre.rc.1
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/_advanced_table.scss +304 -21
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +6 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.html.erb +58 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.html.erb +43 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors.html.erb +55 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_colors_rails.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable.rb +9 -1
- data/app/pb_kits/playbook/pb_draggable/index.js +139 -142
- data/app/pb_kits/playbook/pb_filter/docs/_filter_within_turbo_frames.html.erb +41 -0
- data/app/pb_kits/playbook/pb_filter/docs/_filter_within_turbo_frames.md +1 -0
- data/app/pb_kits/playbook/pb_filter/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.jsx +52 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.md +1 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_line_graph/lineGraphTheme.ts +110 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.html.erb +46 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.md +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_popover/index.ts +13 -1
- data/app/pb_kits/playbook/pb_popover/popover.rb +2 -0
- data/dist/chunks/{_typeahead-BX8IifKY.js → _typeahead-CITBvzU7.js} +1 -1
- data/dist/chunks/_weekday_stacked-C8-PW1nI.js +45 -0
- data/dist/chunks/{lib-96_ZmvAo.js → lib-BmTAc7Nc.js} +1 -1
- data/dist/chunks/{pb_form_validation-Vv2TqXVC.js → pb_form_validation-BWjy4bFn.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/version.rb +1 -1
- metadata +22 -8
- data/dist/chunks/_weekday_stacked-DfMD7HJz.js +0 -45
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_drop_zones_colors.md → _draggable_drop_zones_colors_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_drop_zones.md → _draggable_drop_zones_react.md} +0 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
<% initial_items = [
|
2
|
+
{
|
3
|
+
id: "141",
|
4
|
+
url: "https://unsplash.it/500/400/?image=633",
|
5
|
+
},
|
6
|
+
{
|
7
|
+
id: "142",
|
8
|
+
url: "https://unsplash.it/500/400/?image=634",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
id: "143",
|
12
|
+
url: "https://unsplash.it/500/400/?image=637",
|
13
|
+
},
|
14
|
+
] %>
|
15
|
+
|
16
|
+
<% next_init_items = [
|
17
|
+
{
|
18
|
+
id: "151",
|
19
|
+
url: "https://unsplash.it/500/400/?image=633",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
id: "152",
|
23
|
+
url: "https://unsplash.it/500/400/?image=634",
|
24
|
+
},
|
25
|
+
{
|
26
|
+
id: "153",
|
27
|
+
url: "https://unsplash.it/500/400/?image=637",
|
28
|
+
},
|
29
|
+
] %>
|
30
|
+
|
31
|
+
<%= pb_rails("draggable", props: {initial_items: initial_items, drop_zone_type: "shadow", drop_zone_color: "primary"}) do %>
|
32
|
+
<%= pb_rails("draggable/draggable_container") do %>
|
33
|
+
<%= pb_rails("flex", props: { gap: "sm" }) do %>
|
34
|
+
<% initial_items.each do |item| %>
|
35
|
+
<%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id]}) do %>
|
36
|
+
<%= pb_rails("image", props: { alt: item[:id], size: "md", url: item[:url] }) %>
|
37
|
+
<% end %>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
42
|
+
|
43
|
+
<br/>
|
44
|
+
|
45
|
+
<%= pb_rails("draggable", props: {initial_items: next_init_items, drop_zone_type: "outline", drop_zone_color: "purple"}) do %>
|
46
|
+
<%= pb_rails("draggable/draggable_container") do %>
|
47
|
+
<%= pb_rails("flex", props: { gap: "sm" }) do %>
|
48
|
+
<% initial_items.each do |item| %>
|
49
|
+
<%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id]}) do %>
|
50
|
+
<%= pb_rails("image", props: { alt: item[:id], size: "md", url: item[:url] }) %>
|
51
|
+
<% end %>
|
52
|
+
<% end %>
|
53
|
+
<% end %>
|
54
|
+
<% end %>
|
55
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
The default `color` for Draggable kit drop zones is "neutral", with "primary" or "purple" as additional options.
|
@@ -17,5 +17,6 @@ examples:
|
|
17
17
|
- draggable_with_cards: Draggable with Cards
|
18
18
|
- draggable_with_table: Draggable with Table
|
19
19
|
- draggable_multiple_containers: Dragging Across Multiple Containers
|
20
|
+
- draggable_drop_zones: Draggable Drop Zones
|
21
|
+
- draggable_drop_zones_colors: Draggable Drop Zones Colors
|
20
22
|
- draggable_event_listeners: Draggable Event Listeners
|
21
|
-
|
@@ -5,9 +5,17 @@ module Playbook
|
|
5
5
|
class Draggable < ::Playbook::KitBase
|
6
6
|
prop :initial_items, type: Playbook::Props::Array,
|
7
7
|
default: []
|
8
|
+
prop :drop_zone_type, type: Playbook::Props::Enum,
|
9
|
+
values: %w[ghost shadow outline line],
|
10
|
+
default: "ghost"
|
11
|
+
prop :drop_zone_color, type: Playbook::Props::Enum,
|
12
|
+
values: %w[neutral primary purple],
|
13
|
+
default: "neutral"
|
8
14
|
|
9
15
|
def data
|
10
|
-
Hash(prop(:data)).merge(pb_draggable: true
|
16
|
+
Hash(prop(:data)).merge(pb_draggable: true,
|
17
|
+
drop_zone_type: drop_zone_type,
|
18
|
+
drop_zone_color: drop_zone_color)
|
11
19
|
end
|
12
20
|
|
13
21
|
def classname
|
@@ -1,24 +1,26 @@
|
|
1
1
|
import PbEnhancedElement from "../pb_enhanced_element";
|
2
2
|
|
3
|
-
const DRAGGABLE_SELECTOR
|
3
|
+
const DRAGGABLE_SELECTOR = "[data-pb-draggable]";
|
4
4
|
const DRAGGABLE_CONTAINER = ".pb_draggable_container";
|
5
|
+
const NEEDS_CLONE = ["shadow", "outline"]; // clone only for these types
|
5
6
|
|
6
7
|
export default class PbDraggable extends PbEnhancedElement {
|
7
|
-
static get selector() {
|
8
|
-
return DRAGGABLE_SELECTOR;
|
9
|
-
}
|
8
|
+
static get selector() { return DRAGGABLE_SELECTOR; }
|
10
9
|
|
11
10
|
connect() {
|
12
11
|
this.state = {
|
13
|
-
items:
|
14
|
-
dragData:
|
15
|
-
isDragging:
|
16
|
-
activeContainer: ""
|
12
|
+
items: [],
|
13
|
+
dragData: { id: "", initialGroup: "" },
|
14
|
+
isDragging: "",
|
15
|
+
activeContainer: "",
|
17
16
|
};
|
18
17
|
|
19
|
-
this.draggedItem
|
18
|
+
this.draggedItem = null;
|
20
19
|
this.draggedItemId = null;
|
20
|
+
this.dragGhost = null;
|
21
21
|
this.hasMultipleContainers = false;
|
22
|
+
this.dragZoneType = "";
|
23
|
+
this.dragZoneColor = "";
|
22
24
|
|
23
25
|
document.addEventListener("DOMContentLoaded", () => this.bindEventListeners());
|
24
26
|
}
|
@@ -26,13 +28,12 @@ export default class PbDraggable extends PbEnhancedElement {
|
|
26
28
|
setState(newState) {
|
27
29
|
this.state = { ...this.state, ...newState };
|
28
30
|
if (newState.items) {
|
29
|
-
|
31
|
+
this.element.dispatchEvent(new CustomEvent("pb-draggable-reorder", {
|
30
32
|
detail: {
|
31
33
|
reorderedItems: this.state.items,
|
32
|
-
containerId:
|
33
|
-
}
|
34
|
-
});
|
35
|
-
this.element.dispatchEvent(customEvent);
|
34
|
+
containerId: this.element.querySelector(DRAGGABLE_CONTAINER).id,
|
35
|
+
},
|
36
|
+
}));
|
36
37
|
}
|
37
38
|
}
|
38
39
|
|
@@ -43,71 +44,100 @@ export default class PbDraggable extends PbEnhancedElement {
|
|
43
44
|
|
44
45
|
// Needed to prevent images within draggable items from being independently draggable
|
45
46
|
// Needed if using Image kit in draggable items
|
46
|
-
this.element.querySelectorAll(".pb_draggable_item img")
|
47
|
-
img.setAttribute("draggable", "false");
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
this.element.querySelectorAll(".pb_draggable_item img")
|
48
|
+
.forEach(img => img.setAttribute("draggable", "false"));
|
49
|
+
|
50
|
+
this.element.querySelectorAll(".pb_draggable_item")
|
51
|
+
.forEach(item => {
|
52
|
+
item.addEventListener("dragstart", this.handleDragStart.bind(this));
|
53
|
+
item.addEventListener("dragend", this.handleDragEnd.bind(this));
|
54
|
+
item.addEventListener("dragenter", this.handleDragEnter.bind(this));
|
55
|
+
});
|
55
56
|
|
56
|
-
containers.forEach(
|
57
|
-
|
58
|
-
|
57
|
+
containers.forEach(c => {
|
58
|
+
c.addEventListener("dragover", this.handleDragOver.bind(this));
|
59
|
+
c.addEventListener("drop", this.handleDrop.bind(this));
|
59
60
|
});
|
60
61
|
}
|
61
62
|
|
63
|
+
/* ---------------- DRAG START ---------------- */
|
62
64
|
handleDragStart(event) {
|
63
65
|
// Needed to prevent images within draggable items from being independently draggable
|
64
66
|
// Needed if using Image kit in draggable items
|
65
|
-
if (event.target.tagName.toLowerCase() ===
|
67
|
+
if (event.target.tagName.toLowerCase() === "img") {
|
66
68
|
event.preventDefault();
|
67
69
|
return;
|
68
70
|
}
|
69
71
|
|
70
|
-
const container
|
71
|
-
this.draggedItem
|
72
|
+
const container = event.target.closest(DRAGGABLE_CONTAINER);
|
73
|
+
this.draggedItem = event.target;
|
72
74
|
this.draggedItemId = event.target.id;
|
75
|
+
this.dragZoneType = this.element.dataset.dropZoneType || "";
|
76
|
+
this.dragZoneColor = this.element.dataset.dropZoneColor || "";
|
73
77
|
|
74
78
|
this.setState({
|
75
|
-
dragData:
|
76
|
-
isDragging: this.draggedItemId
|
79
|
+
dragData: { id: this.draggedItemId, initialGroup: container.id },
|
80
|
+
isDragging: this.draggedItemId,
|
77
81
|
});
|
78
82
|
|
79
|
-
|
83
|
+
this.draggedItem.classList.add(
|
84
|
+
"is_dragging",
|
85
|
+
`drop_zone_${this.dragZoneType}`,
|
86
|
+
`drop_zone_color_${this.dragZoneColor}`,
|
87
|
+
);
|
88
|
+
|
80
89
|
if (event.dataTransfer) {
|
81
|
-
event.dataTransfer.effectAllowed =
|
82
|
-
event.dataTransfer.setData(
|
90
|
+
event.dataTransfer.effectAllowed = "move";
|
91
|
+
event.dataTransfer.setData("text/plain", this.draggedItemId);
|
92
|
+
|
93
|
+
/* ---------- custom ghost clone (shadow + outline only) ---------- */
|
94
|
+
if (NEEDS_CLONE.includes(this.dragZoneType)) {
|
95
|
+
const ghost = this.draggedItem.cloneNode(true);
|
96
|
+
ghost.classList.remove(
|
97
|
+
"is_dragging",
|
98
|
+
`drop_zone_${this.dragZoneType}`,
|
99
|
+
`drop_zone_color_${this.dragZoneColor}`,
|
100
|
+
);
|
101
|
+
const { width, height } = this.draggedItem.getBoundingClientRect();
|
102
|
+
Object.assign(ghost.style, {
|
103
|
+
border: "none",
|
104
|
+
width: `${width}px`,
|
105
|
+
height: `${height}px`,
|
106
|
+
position: "absolute",
|
107
|
+
top: "-9999px",
|
108
|
+
left: "-9999px",
|
109
|
+
boxSizing: "border-box",
|
110
|
+
zIndex: "9999",
|
111
|
+
});
|
112
|
+
document.body.appendChild(ghost);
|
113
|
+
this.dragGhost = ghost;
|
114
|
+
event.dataTransfer.setDragImage(ghost, width / 2, height / 2);
|
115
|
+
}
|
116
|
+
/* ---------------------------------------------------------------- */
|
83
117
|
}
|
84
118
|
|
85
|
-
|
86
|
-
event.target.style.opacity = '0.5';
|
87
|
-
}, 0);
|
119
|
+
requestAnimationFrame(() => (event.target.style.opacity = "0.5"));
|
88
120
|
}
|
89
121
|
|
122
|
+
/* ---------------- DRAG ENTER ---------------- */
|
90
123
|
handleDragEnter(event) {
|
91
124
|
if (!this.draggedItem || event.target === this.draggedItem) return;
|
92
|
-
|
93
|
-
|
94
|
-
this.
|
95
|
-
} else {
|
96
|
-
this.handleSingleContainerDragEnter(event);
|
97
|
-
}
|
125
|
+
this.hasMultipleContainers
|
126
|
+
? this.handleMultiContainerDragEnter(event)
|
127
|
+
: this.handleSingleContainerDragEnter(event);
|
98
128
|
}
|
99
129
|
|
100
130
|
handleSingleContainerDragEnter(event) {
|
101
|
-
const targetItem = event.target.closest(
|
131
|
+
const targetItem = event.target.closest(".pb_draggable_item");
|
132
|
+
// If we're entering a container directly or there's no target item
|
102
133
|
if (!targetItem) return;
|
103
134
|
|
104
135
|
const container = targetItem.parentNode;
|
105
|
-
const items
|
136
|
+
const items = Array.from(container.children);
|
137
|
+
const fromIdx = items.indexOf(this.draggedItem);
|
138
|
+
const toIdx = items.indexOf(targetItem);
|
106
139
|
|
107
|
-
|
108
|
-
const targetIndex = items.indexOf(targetItem);
|
109
|
-
|
110
|
-
if (draggedIndex > targetIndex) {
|
140
|
+
if (fromIdx > toIdx) {
|
111
141
|
container.insertBefore(this.draggedItem, targetItem);
|
112
142
|
} else {
|
113
143
|
container.insertBefore(this.draggedItem, targetItem.nextSibling);
|
@@ -116,146 +146,113 @@ export default class PbDraggable extends PbEnhancedElement {
|
|
116
146
|
|
117
147
|
handleMultiContainerDragEnter(event) {
|
118
148
|
const targetContainer = event.target.closest(DRAGGABLE_CONTAINER);
|
119
|
-
const targetItem
|
120
|
-
|
149
|
+
const targetItem = event.target.closest(".pb_draggable_item");
|
121
150
|
if (!targetContainer) return;
|
122
151
|
|
123
|
-
// If we're entering a container directly or there's no target item
|
124
152
|
if (!targetItem) {
|
125
|
-
const
|
126
|
-
|
127
|
-
targetContainer.insertBefore(this.draggedItem,
|
128
|
-
|
129
|
-
targetContainer.appendChild(this.draggedItem);
|
130
|
-
}
|
153
|
+
const last = targetContainer.querySelector(".pb_draggable_item:last-child");
|
154
|
+
last
|
155
|
+
? targetContainer.insertBefore(this.draggedItem, last.nextSibling)
|
156
|
+
: targetContainer.appendChild(this.draggedItem);
|
131
157
|
return;
|
132
158
|
}
|
133
159
|
|
134
|
-
const
|
135
|
-
|
136
|
-
|
137
|
-
const newItems = [...items].map(item => ({
|
138
|
-
id: item.id,
|
139
|
-
container: container.id
|
140
|
-
}));
|
141
|
-
|
142
|
-
this.setState({ items: newItems });
|
160
|
+
const items = Array.from(targetContainer.children);
|
161
|
+
this.setState({ items: items.map(i => ({ id: i.id, container: targetContainer.id })) });
|
143
162
|
|
144
|
-
const
|
145
|
-
|
163
|
+
const midY = targetItem.getBoundingClientRect().top +
|
164
|
+
targetItem.getBoundingClientRect().height / 2;
|
146
165
|
|
147
|
-
if (event.clientY <
|
148
|
-
|
166
|
+
if (event.clientY < midY) {
|
167
|
+
targetContainer.insertBefore(this.draggedItem, targetItem);
|
149
168
|
} else {
|
150
|
-
|
169
|
+
targetContainer.insertBefore(this.draggedItem, targetItem.nextSibling);
|
151
170
|
}
|
152
171
|
}
|
153
172
|
|
173
|
+
/* ---------------- DRAG OVER ---------------- */
|
154
174
|
handleDragOver(event) {
|
155
175
|
event.preventDefault();
|
156
176
|
event.stopPropagation();
|
157
|
-
|
158
|
-
|
159
|
-
this.
|
160
|
-
} else {
|
161
|
-
this.handleSingleContainerDragOver(event);
|
162
|
-
}
|
177
|
+
this.hasMultipleContainers
|
178
|
+
? this.handleMultiContainerDragOver(event)
|
179
|
+
: this.handleSingleContainerDragOver(event);
|
163
180
|
}
|
164
181
|
|
165
182
|
handleSingleContainerDragOver(event) {
|
166
183
|
const container = event.target.closest(DRAGGABLE_CONTAINER);
|
167
|
-
if (container)
|
168
|
-
container.classList.add("active_container");
|
169
|
-
}
|
184
|
+
if (container) container.classList.add("active_container");
|
170
185
|
}
|
171
186
|
|
172
187
|
handleMultiContainerDragOver(event) {
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
const lastItem = container.querySelector('.pb_draggable_item:last-child');
|
186
|
-
if (!lastItem || (lastItem && event.clientY > lastItem.getBoundingClientRect().bottom)) {
|
187
|
-
if (this.draggedItem && this.draggedItem.parentNode !== container) {
|
188
|
-
container.appendChild(this.draggedItem);
|
189
|
-
}
|
188
|
+
const container = event.target.matches(DRAGGABLE_CONTAINER)
|
189
|
+
? event.target
|
190
|
+
: event.target.closest(DRAGGABLE_CONTAINER);
|
191
|
+
if (!container) return;
|
192
|
+
|
193
|
+
this.setState({ activeContainer: container.id });
|
194
|
+
container.classList.add("active_container");
|
195
|
+
|
196
|
+
const last = container.querySelector(".pb_draggable_item:last-child");
|
197
|
+
if (!last || event.clientY > last.getBoundingClientRect().bottom) {
|
198
|
+
if (this.draggedItem && this.draggedItem.parentNode !== container) {
|
199
|
+
container.appendChild(this.draggedItem);
|
190
200
|
}
|
191
201
|
}
|
192
202
|
}
|
193
203
|
|
204
|
+
/* ---------------- DROP ---------------- */
|
194
205
|
handleDrop(event) {
|
195
206
|
event.preventDefault();
|
196
207
|
event.stopPropagation();
|
197
208
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
} else {
|
202
|
-
container = event.target.closest(DRAGGABLE_CONTAINER);
|
203
|
-
}
|
204
|
-
|
209
|
+
const container = event.target.matches(DRAGGABLE_CONTAINER)
|
210
|
+
? event.target
|
211
|
+
: event.target.closest(DRAGGABLE_CONTAINER);
|
205
212
|
if (!container || !this.draggedItem) return;
|
206
213
|
|
207
214
|
container.classList.remove("active_container");
|
208
|
-
this.draggedItem.style.opacity =
|
215
|
+
this.draggedItem.style.opacity = "1";
|
209
216
|
|
210
217
|
// Handle empty containers
|
211
|
-
if (this.hasMultipleContainers && !container.querySelector(
|
218
|
+
if (this.hasMultipleContainers && !container.querySelector(".pb_draggable_item")) {
|
212
219
|
container.appendChild(this.draggedItem);
|
213
220
|
}
|
214
221
|
|
215
222
|
// Updated order of items as an array of item IDs
|
216
|
-
const reorderedItems = Array.from(
|
217
|
-
|
218
|
-
).map(item => ({
|
219
|
-
id: item.id,
|
220
|
-
container: item.closest(DRAGGABLE_CONTAINER).id
|
221
|
-
}));
|
222
|
-
|
223
|
-
// Store reordered items in a data attribute on the container
|
224
|
-
container.setAttribute("data-reordered-items", JSON.stringify(reorderedItems));
|
225
|
-
|
226
|
-
const customEvent = new CustomEvent('pb-draggable-reorder', {
|
227
|
-
detail: {
|
228
|
-
reorderedItems,
|
229
|
-
containerId: container.id,
|
230
|
-
}
|
231
|
-
});
|
232
|
-
|
233
|
-
this.element.dispatchEvent(customEvent);
|
223
|
+
const reorderedItems = Array.from(this.element.querySelectorAll(".pb_draggable_item"))
|
224
|
+
.map(i => ({ id: i.id, container: i.closest(DRAGGABLE_CONTAINER).id }));
|
234
225
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
});
|
226
|
+
container.dataset.reorderedItems = JSON.stringify(reorderedItems);
|
227
|
+
this.element.dispatchEvent(new CustomEvent("pb-draggable-reorder", {
|
228
|
+
detail: { reorderedItems, containerId: container.id },
|
229
|
+
}));
|
240
230
|
|
241
|
-
this.
|
231
|
+
this.setState({ items: reorderedItems, isDragging: "", activeContainer: "" });
|
232
|
+
this.draggedItem = null;
|
242
233
|
this.draggedItemId = null;
|
243
234
|
}
|
244
235
|
|
236
|
+
/* ---------------- DRAG END ---------------- */
|
245
237
|
handleDragEnd(event) {
|
246
|
-
event.target.classList.remove(
|
247
|
-
|
238
|
+
event.target.classList.remove(
|
239
|
+
"is_dragging",
|
240
|
+
`drop_zone_${this.dragZoneType}`,
|
241
|
+
`drop_zone_color_${this.dragZoneColor}`,
|
242
|
+
);
|
243
|
+
event.target.style.opacity = "1";
|
244
|
+
|
245
|
+
if (this.dragGhost) {
|
246
|
+
document.body.removeChild(this.dragGhost);
|
247
|
+
this.dragGhost = null;
|
248
|
+
}
|
248
249
|
|
249
|
-
this.setState({
|
250
|
-
isDragging: "",
|
251
|
-
activeContainer: ""
|
252
|
-
});
|
250
|
+
this.setState({ isDragging: "", activeContainer: "" });
|
253
251
|
|
254
|
-
this.
|
255
|
-
|
252
|
+
this.element.querySelectorAll(DRAGGABLE_CONTAINER)
|
253
|
+
.forEach(c => c.classList.remove("active_container"));
|
256
254
|
|
257
|
-
this.
|
258
|
-
|
259
|
-
});
|
255
|
+
this.draggedItem = null;
|
256
|
+
this.draggedItemId = null;
|
260
257
|
}
|
261
258
|
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%=
|
2
|
+
pb_rails("filter", props: {
|
3
|
+
id: "filter_within_trubo_frames",
|
4
|
+
position: "top",
|
5
|
+
filters: [
|
6
|
+
{ name: "name", value: "John Wick" },
|
7
|
+
{ name: "city", value: "San Francisco"}
|
8
|
+
],
|
9
|
+
sort_menu: [
|
10
|
+
{ item: "Popularity", link: "?q[sorts]=managers_popularity+asc", active: true, direction: "desc" },
|
11
|
+
{ item: "Mananger's Title", link: "?q[sorts]=managers_title+asc", active: false },
|
12
|
+
{ item: "Manager's Name", link: "?q[sorts]=managers_name+asc", active: false },
|
13
|
+
],
|
14
|
+
template: "default",
|
15
|
+
results: 1,
|
16
|
+
popover_props: { append_to: "parent" },
|
17
|
+
}) do
|
18
|
+
%>
|
19
|
+
<%
|
20
|
+
example_collection = [
|
21
|
+
OpenStruct.new(name: "USA", value: 1),
|
22
|
+
OpenStruct.new(name: "Canada", value: 2),
|
23
|
+
OpenStruct.new(name: "Brazil", value: 3),
|
24
|
+
OpenStruct.new(name: "Philippines", value: 4),
|
25
|
+
OpenStruct.new(name: "A galaxy far far away, like really far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far away...", value: 5)
|
26
|
+
]
|
27
|
+
%>
|
28
|
+
<%= pb_rails("form", props: { form_system_options: { scope: :example, method: :get } }) do |form| %>
|
29
|
+
<%= form.text_field :example_text_field, props: { label: true } %>
|
30
|
+
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: {max_width: "sm", label: true } %>
|
31
|
+
|
32
|
+
<%= form.actions do |action| %>
|
33
|
+
<%= action.submit props: {
|
34
|
+
text: "Apply",
|
35
|
+
data: {
|
36
|
+
disable_with: "pb_rails('icon', props: { icon: 'spinner', spin: true, fixed_width: true })Searching...".html_safe
|
37
|
+
},}%>
|
38
|
+
<%= action.button props: { type: "reset", text: "Clear", variant: "secondary" } %>
|
39
|
+
<% end %>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
By default, the filter popover attaches to the `<body>`. To attach it elsewhere, like inside a Turbo Frame, pass the `append_to` prop through `popover_props`. Set it to `"parent"` to place the tooltip inside its parent element, or pass any CSS selector (`#id` or `.class`) to specify a custom container.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import lineGraphTheme from '../lineGraphTheme'
|
3
|
+
import Highcharts from "highcharts"
|
4
|
+
import HighchartsReact from "highcharts-react-official"
|
5
|
+
|
6
|
+
const data = [{
|
7
|
+
name: 'Installation',
|
8
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
9
|
+
}, {
|
10
|
+
name: 'Manufacturing',
|
11
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
|
12
|
+
}, {
|
13
|
+
name: 'Sales & Distribution',
|
14
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
|
15
|
+
}, {
|
16
|
+
name: 'Project Development',
|
17
|
+
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227],
|
18
|
+
}, {
|
19
|
+
name: 'Other',
|
20
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
|
21
|
+
}]
|
22
|
+
|
23
|
+
const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
24
|
+
|
25
|
+
const baseOptions = {
|
26
|
+
series: data,
|
27
|
+
title: { text: "Solar Employment Growth by Sector, 2010-2016" },
|
28
|
+
subtitle: { text: "Source: thesolarfoundation.com" },
|
29
|
+
xAxis: {
|
30
|
+
categories: categories,
|
31
|
+
},
|
32
|
+
yAxis: {
|
33
|
+
title: {
|
34
|
+
text: "Number of Employees",
|
35
|
+
},
|
36
|
+
},
|
37
|
+
}
|
38
|
+
|
39
|
+
const LineGraphPbStyles = () => {
|
40
|
+
const options = Highcharts.merge({}, lineGraphTheme, baseOptions)
|
41
|
+
|
42
|
+
return(
|
43
|
+
<div>
|
44
|
+
<HighchartsReact
|
45
|
+
highcharts={Highcharts}
|
46
|
+
options={options}
|
47
|
+
/>
|
48
|
+
</div>
|
49
|
+
)
|
50
|
+
}
|
51
|
+
|
52
|
+
export default LineGraphPbStyles
|
@@ -0,0 +1 @@
|
|
1
|
+
You don't need to use the Line Graph Kit to apply Playbook styles to your Highcharts line graph. Just import lineGraphTheme.ts and merge it with your graph options—Playbook’s styling will apply automatically.
|
@@ -4,3 +4,4 @@ export { default as LineGraphLegendPosition } from './_line_graph_legend_positio
|
|
4
4
|
export { default as LineGraphLegendNonclickable } from './_line_graph_legend_nonclickable.jsx'
|
5
5
|
export { default as LineGraphHeight } from './_line_graph_height.jsx'
|
6
6
|
export { default as LineGraphColors } from './_line_graph_colors.jsx'
|
7
|
+
export { default as LineGraphPbStyles } from './_line_graph_pb_styles.jsx'
|