playbook_ui 14.18.0.pre.rc.3 → 14.18.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +56 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +1 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +29 -19
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +6 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expand_by_depth.jsx +66 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expand_by_depth.md +10 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +39 -1
  14. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +4 -0
  15. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +9 -1
  16. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +14 -0
  17. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.html.erb +28 -0
  18. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.jsx +42 -0
  19. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.md +1 -0
  20. data/app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml +2 -0
  21. data/app/pb_kits/playbook/pb_circle_icon_button/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook_rails.html.erb +14 -0
  23. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook_rails.md +3 -0
  24. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +1 -0
  25. data/app/pb_kits/playbook/pb_copy_button/index.js +46 -20
  26. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +10 -1
  27. data/app/pb_kits/playbook/pb_dialog/dialog.rb +2 -0
  28. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames.html.erb +117 -0
  29. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames_rails.md +9 -0
  30. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
  31. data/app/pb_kits/playbook/pb_dialog/index.js +106 -14
  32. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.html.erb +42 -0
  33. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.md +1 -0
  34. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +1 -0
  35. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -1
  36. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +1 -1
  37. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.jsx +31 -0
  38. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.md +1 -0
  39. data/app/pb_kits/playbook/pb_gauge/docs/example.yml +1 -0
  40. data/app/pb_kits/playbook/pb_gauge/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_gauge/gaugeTheme.ts +83 -0
  42. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +34 -0
  43. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +25 -4
  44. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_background.jsx +49 -0
  45. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_background.md +1 -0
  46. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_opacity.jsx +81 -0
  47. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_opacity.md +1 -0
  48. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +2 -0
  49. data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
  50. data/dist/chunks/_typeahead-C_FX7o_S.js +22 -0
  51. data/dist/chunks/_weekday_stacked-B4RLTeDo.js +45 -0
  52. data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
  53. data/dist/chunks/lib-ySl8uEpT.js +29 -0
  54. data/dist/chunks/{pb_form_validation-nsvkJU2J.js → pb_form_validation-BRjyJrKh.js} +1 -1
  55. data/dist/chunks/vendor.js +1 -1
  56. data/dist/menu.yml +2 -2
  57. data/dist/playbook-doc.js +1 -1
  58. data/dist/playbook-rails-react-bindings.js +1 -1
  59. data/dist/playbook-rails.js +1 -1
  60. data/dist/playbook.css +1 -1
  61. data/lib/playbook/version.rb +1 -1
  62. metadata +25 -7
  63. data/dist/chunks/_typeahead-DUI-4yjJ.js +0 -22
  64. data/dist/chunks/_weekday_stacked-q9YP0zaF.js +0 -45
  65. data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
  66. data/dist/chunks/lib-BV_AF_eh.js +0 -29
@@ -1,6 +1,33 @@
1
1
  import PbEnhancedElement from "../pb_enhanced_element"
2
2
 
3
- export default class PbCopyButton extends PbEnhancedElement {
3
+ function getTextFromElement(element) {
4
+ if (!element) return ''
5
+ return element.tagName.toLowerCase() === 'input'
6
+ ? element.value
7
+ : element.innerText
8
+ }
9
+
10
+ function copyTextToClipboard(text) {
11
+ if (!text) return
12
+ navigator.clipboard.writeText(text)
13
+ .catch(err => console.error('Failed to copy text:', err))
14
+ }
15
+
16
+ function handleExternalControlCopyClick(element) {
17
+ const value = element.getAttribute('data-external-copy-value')
18
+ const fromId = element.getAttribute('data-external-copy-from')
19
+
20
+ if (value) {
21
+ copyTextToClipboard(value)
22
+ } else if (fromId) {
23
+ const fromElement = document.querySelector(`#${fromId}`)
24
+ copyTextToClipboard(getTextFromElement(fromElement))
25
+ } else {
26
+ console.warn('Failed to copy:', element)
27
+ }
28
+ }
29
+
30
+ export class PbCopyButton extends PbEnhancedElement {
4
31
  static get selector() {
5
32
  return '.pb_copy_button_kit'
6
33
  }
@@ -20,28 +47,27 @@ export default class PbCopyButton extends PbEnhancedElement {
20
47
  }
21
48
 
22
49
  handleClick() {
50
+ const value = this.element.getAttribute('data-copy-value')
23
51
  const fromId = this.element.getAttribute('data-from')
24
- if (fromId) {
25
- const fromElement = document.querySelector(`#${fromId}`)
26
- if (fromElement) {
27
- let contentToCopy = ''
28
- if (fromElement.tagName.toLowerCase() === 'input') {
29
- contentToCopy = fromElement.value
30
- } else {
31
- contentToCopy = fromElement.innerText
32
- }
33
- navigator.clipboard.writeText(contentToCopy)
34
- .catch(err => console.error('Failed to copy text', err))
35
- return
36
- }
37
- }
38
52
 
39
- const textToCopy = this.element.getAttribute('data-copy-value')
40
- if (textToCopy) {
41
- navigator.clipboard.writeText(textToCopy)
42
- .catch(err => console.error('Failed to copy text', err))
53
+ if (value) {
54
+ copyTextToClipboard(value)
55
+ } else if (fromId) {
56
+ const fromElement = document.querySelector(`#${fromId}`)
57
+ copyTextToClipboard(getTextFromElement(fromElement))
43
58
  } else {
44
- console.warn('No data-copy-value attribute found or data-from element')
59
+ console.warn('No data-copy-value or data-from attribute found')
45
60
  }
46
61
  }
47
62
  }
63
+
64
+ export function addCopyEventListeners() {
65
+ const externalCopyElements = [
66
+ ...document.querySelectorAll('div[data-external-copy-value]'),
67
+ ...document.querySelectorAll('div[data-external-copy-from]')
68
+ ]
69
+
70
+ externalCopyElements.forEach(element => {
71
+ element.addEventListener('click', () => handleExternalControlCopyClick(element))
72
+ })
73
+ }
@@ -1,7 +1,16 @@
1
1
  <div
2
2
  class="pb_dialog_wrapper_rails <%= object.full_height_style %>"
3
3
  data-pb-dialog-wrapper="true"
4
- data-overlay-click= <%= object.overlay_close %>
4
+ data-overlay-click="<%= object.overlay_close %>"
5
+ <% if object.custom_event_type.present? %>
6
+ data-custom-event-type="<%= object.custom_event_type %>"
7
+ <% end %>
8
+ <% if object.confirm_button_id.present? %>
9
+ data-confirm-button-id="<%= object.confirm_button_id %>"
10
+ <% end %>
11
+ <% if object.cancel_button_id.present? %>
12
+ data-cancel-button-id="<%= object.cancel_button_id %>"
13
+ <% end %>
5
14
  >
6
15
  <%= pb_content_tag(:dialog) do %>
7
16
  <% if object.status === "" && object.title %>
@@ -21,6 +21,8 @@ module Playbook
21
21
  prop :status, type: Playbook::Props::Enum,
22
22
  values: ["info", "caution", "delete", "error", "success", "default", ""],
23
23
  default: ""
24
+ prop :custom_event_type, type: Playbook::Props::String,
25
+ default: ""
24
26
 
25
27
  def classname
26
28
  generate_classname("pb_dialog pb_dialog_rails pb_dialog_#{size}_#{placement}")
@@ -0,0 +1,117 @@
1
+ <%= pb_rails("flex", props:{ gap: "xs", wrap:true}) do %>
2
+ <%= pb_rails("button", props: { id: "button-open-example-turbo-frames", margin_right: "md", text: "Open Dialog via Custom Event" }) %>
3
+ <%= pb_rails("button", props: { id: "open-dialog-button", data: { open_dialog: "dialog-confirm-turbo-frames" }, margin_right: "md", text: "Custom Event Linked to Confirm Button" }) %>
4
+ <%= pb_rails("button", props: { id: "button-open-multi-dialog", text: "Mutliple Events Example" }) %>
5
+ <% end %>
6
+
7
+ <!-- Example 1: Basic dialog with custom event opening -->
8
+ <%= pb_rails("dialog", props: {
9
+ id: "dialog-open-turbo-frames",
10
+ title: "Click Event Simulation",
11
+ text: "Demonstrating Opening the Dialog with a Custom Event.",
12
+ custom_event_type: "dialogOpen",
13
+ cancel_button: "Cancel Button",
14
+ confirm_button: "Okay",
15
+ confirm_button_id: "confirm-button-turbo-frames"
16
+ }) %>
17
+
18
+ <script>
19
+ document.getElementById("button-open-example-turbo-frames").addEventListener("click", () => {
20
+ console.log("📣 Dispatching 'dialogOpen' custom event")
21
+
22
+ window.dispatchEvent(new CustomEvent("dialogOpen", {
23
+ bubbles: true,
24
+ detail: {
25
+ dialogId: "dialog-open-turbo-frames",
26
+ action: "open"
27
+ }
28
+ }))
29
+
30
+ console.log("✅ Custom event dispatched - dialog should open")
31
+ })
32
+ </script>
33
+
34
+ <!-- Example 2: Dialog with custom event linking confirm button to closing the dialog-->
35
+ <%= pb_rails("dialog", props: {
36
+ id: "dialog-confirm-turbo-frames",
37
+ title: "Custom Event Button Action",
38
+ text: "Clicking this dialog's confirm button triggers closing the dialog as well.",
39
+ custom_event_type: "turboResponse",
40
+ cancel_button: "Cancel",
41
+ cancel_button_id: "cancel-button-id-turbo-frames",
42
+ confirm_button: "Confirm Button",
43
+ confirm_button_id: "confirm-button-id-turbo-frames"
44
+ }) %>
45
+
46
+ <script>
47
+ window.addEventListener("turboResponse", (event) => {
48
+ const { dialogId, action, cancelButtonId } = event.detail || {}
49
+ console.log("📦 turboResponse event triggered:", { dialogId, action, cancelButtonId })
50
+
51
+ if (action === "close" && cancelButtonId) {
52
+ const dialog = document.getElementById(dialogId)
53
+ if (dialog?.close) {
54
+ console.log("🚪 Closing dialog programmatically")
55
+ dialog.close()
56
+ }
57
+ }
58
+ })
59
+
60
+ document.getElementById("confirm-button-id-turbo-frames").addEventListener("click", function () {
61
+ console.log("✅ Confirm button clicked! Triggering cancel via turboResponse")
62
+
63
+ window.dispatchEvent(new CustomEvent("turboResponse", {
64
+ detail: {
65
+ dialogId: "dialog-confirm-turbo-frames",
66
+ action: "close",
67
+ cancelButtonId: "cancel-button-id-turbo-frames"
68
+ }
69
+ }))
70
+ })
71
+ </script>
72
+
73
+ <!-- Example 3: Dialog with multiple custom event types -->
74
+ <%= pb_rails("dialog", props: {
75
+ id: "multi-event-dialog",
76
+ title: "Multiple Event Types",
77
+ text: "This dialog responds to multiple custom event types - see console logs.",
78
+ custom_event_type: "dialogOpenMutli,turboResponseMulti",
79
+ cancel_button: "Cancel",
80
+ cancel_button_id: "multi-event-cancel",
81
+ confirm_button: "Confirm",
82
+ confirm_button_id: "multi-event-confirm"
83
+ }) %>
84
+
85
+ <script>
86
+ document.getElementById("button-open-multi-dialog").addEventListener("click", () => {
87
+ console.log("📣 Dispatching 'dialogOpenMutli' custom event")
88
+ window.dispatchEvent(new CustomEvent("dialogOpenMutli", {
89
+ detail: {
90
+ dialogId: "multi-event-dialog",
91
+ action: "open"
92
+ }
93
+ }))
94
+ })
95
+
96
+ document.getElementById("multi-event-confirm")?.addEventListener("click", function() {
97
+ console.log("✅ Confirm clicked — dispatching 'turboResponseMulti' to simulate dialog close")
98
+
99
+ window.dispatchEvent(new CustomEvent("turboResponseMulti", {
100
+ detail: {
101
+ dialogId: "multi-event-dialog",
102
+ action: "close",
103
+ cancelButtonId: "multi-event-cancel"
104
+ }
105
+ }))
106
+ })
107
+
108
+ window.addEventListener("turboResponseMulti", (event) => {
109
+ const { dialogId, action, cancelButtonId } = event.detail || {}
110
+
111
+ if (action === "close" && dialogId) {
112
+ const dialog = document.getElementById(dialogId)
113
+ dialog.close?.()
114
+ console.log("🚪 Closing dialog programmatically")
115
+ }
116
+ })
117
+ </script>
@@ -0,0 +1,9 @@
1
+ The `custom_event_type` prop allows you to specify custom events that will trigger the dialog's initialization or control its behavior. This is especially useful when working with Turbo Frame updates where standard DOM events might not suffice.
2
+
3
+ The examples demonstrate two use cases:
4
+ 1) Opening a dialog via custom event dispatch: The first example shows how to configure a dialog to listen for a specific custom event (dialogOpen). When this event is dispatched, the dialog will automatically open, making it easy to trigger the dialog from JavaScript or after Turbo Frame operations.
5
+ 2) Controlling dialog button actions with custom events: The second example demonstrates how to set up a dialog that can have its confirm button triggered through external events (turboResponse). This pattern is useful when you need to programmatically confirm a dialog after some background operation completes.
6
+ 3) Multiple custom events: The third example combines the first two to show how `custom_event_type` prop can support multiple event types separated by a comma.
7
+
8
+ For Turbo integration, you can use standard Turbo events like turbo:frame-load or turbo:submit-end as your `custom_event_type` to ensure the dialog responds properly after Turbo navigation or form submissions. The dialog component will listen for these events automatically.
9
+ The implementation handles various actions including 'open', 'close', 'clickConfirm', and 'clickCancel', making it flexible for different interaction patterns in your Turbo-enhanced application.
@@ -11,6 +11,7 @@ examples:
11
11
  - dialog_full_height: Full Height
12
12
  - dialog_full_height_placement: Full Height Placement
13
13
  - dialog_loading: Loading
14
+ - dialog_turbo_frames: Within Turbo Frames
14
15
 
15
16
 
16
17
  react:
@@ -10,6 +10,81 @@ export default class PbDialog extends PbEnhancedElement {
10
10
  connect() {
11
11
  window.addEventListener("DOMContentLoaded", () => this.setupDialog())
12
12
  window.addEventListener("turbo:frame-load", () => this.setupDialog())
13
+
14
+ // Code for custom_event_type setup (can take multiple events in a string separated by commas)
15
+ const customEventTypeString = this.element.dataset.customEventType
16
+ if (customEventTypeString && !this.element.hasAttribute("data-custom-event-handled")) {
17
+ this.customEventTypes = customEventTypeString.split(",").map(e => e.trim()).filter(Boolean)
18
+ this.customEventTypes.forEach(eventType => {
19
+ window.addEventListener(eventType, this.handleCustomEvent)
20
+ })
21
+
22
+ this.element.setAttribute("data-custom-event-handled", "true")
23
+ }
24
+ }
25
+
26
+ disconnect() {
27
+ if (this.customEventTypes && Array.isArray(this.customEventTypes)) {
28
+ this.customEventTypes.forEach(eventType => {
29
+ window.removeEventListener(eventType, this.handleCustomEvent)
30
+ })
31
+ }
32
+ }
33
+
34
+ handleCustomEvent = (event) => {
35
+ const dialogId = event.detail?.dialogId || this.element.querySelector("dialog")?.id
36
+ const dialog = dialogId && document.getElementById(dialogId)
37
+
38
+ if (!dialog) {
39
+ console.warn(`[PbDialog] Could not find dialog with ID '${dialogId}'`)
40
+ return
41
+ }
42
+
43
+ this.setupDialog()
44
+
45
+ const action = event.detail?.action || 'open'
46
+
47
+ // Known Actions - four "standard" dialog actions that felt like things devs might want to do
48
+ const knownActions = ['open', 'close', 'clickConfirm', 'clickCancel'];
49
+
50
+ if (knownActions.includes(action)) {
51
+ switch (action) {
52
+ case 'open':
53
+ if (!dialog.open) dialog.showModal()
54
+ break
55
+ case 'close':
56
+ if (dialog.open) dialog.close(event.detail?.returnValue)
57
+ break
58
+ case 'clickConfirm':
59
+ this.triggerButtonClick(dialog, event, 'confirm')
60
+ break
61
+ case 'clickCancel':
62
+ this.triggerButtonClick(dialog, event, 'cancel')
63
+ break
64
+ }
65
+ }
66
+ // Custom Actions - flexible for Turbo or other integration
67
+ else if (typeof event.detail?.customAction === 'function') {
68
+ event.detail.customAction({ dialog, event })
69
+ } else if (window.pbDialogActions?.[action]) {
70
+ // Can register custom actions globally
71
+ window.pbDialogActions[action]({ dialog, event })
72
+ } else {
73
+ console.warn(`[PbDialog] Unknown action: ${action}`)
74
+ }
75
+ }
76
+
77
+ triggerButtonClick(dialog, event, type) {
78
+ const buttonId = event.detail?.[`${type}ButtonId`] ||
79
+ dialog.closest('[data-pb-dialog-wrapper]')?.dataset[`${type}ButtonId`]
80
+ const button = buttonId ? document.getElementById(buttonId) :
81
+ dialog.querySelector(`[data-${type}-button]`)
82
+
83
+ if (button) {
84
+ button.click()
85
+ } else {
86
+ console.warn(`[PbDialog] Could not find ${type} button for dialog`)
87
+ }
13
88
  }
14
89
 
15
90
  setupDialog() {
@@ -18,7 +93,7 @@ export default class PbDialog extends PbEnhancedElement {
18
93
  const dialogs = document.querySelectorAll(".pb_dialog_rails")
19
94
 
20
95
  const loadingButton = document.querySelector('[data-disable-with="Loading"]');
21
- if (loadingButton) {
96
+ if (loadingButton && !loadingButton.dataset.listenerAttached) {
22
97
  loadingButton.addEventListener("click", function () {
23
98
  const okayLoadingButton = document.querySelector('[data-disable-with="Loading"]');
24
99
  const cancelButton = document.querySelector('[data-disable-cancel-with="Loading"]');
@@ -35,27 +110,42 @@ export default class PbDialog extends PbEnhancedElement {
35
110
  okayLoadingButton.className = newClass;
36
111
  if (cancelButton) cancelButton.className = newCancelClass;
37
112
  });
113
+
114
+ // Prevent multiple registrations
115
+ loadingButton.dataset.listenerAttached = "true";
38
116
  }
39
-
117
+
40
118
  openTrigger.forEach((open) => {
41
- open.addEventListener("click", () => {
42
- var openTriggerData = open.dataset.openDialog;
43
- var targetDialog = document.getElementById(openTriggerData)
44
- if (targetDialog.open) return;
45
- targetDialog.showModal();
46
- });
119
+ const originalClickHandler = open._openDialogClickHandler
120
+ if (originalClickHandler) open.removeEventListener("click", originalClickHandler)
121
+
122
+ open._openDialogClickHandler = () => {
123
+ const openTriggerData = open.dataset.openDialog;
124
+ const targetDialogOpen = document.getElementById(openTriggerData)
125
+ if (targetDialogOpen && !targetDialogOpen.open) targetDialogOpen.showModal()
126
+ };
127
+
128
+ open.addEventListener("click", open._openDialogClickHandler)
47
129
  });
48
130
 
49
131
  closeTrigger.forEach((close) => {
50
- close.addEventListener("click", () => {
51
- var closeTriggerData = close.dataset.closeDialog;
52
- document.getElementById(closeTriggerData).close();
53
- });
132
+ const originalClickHandler = close._closeDialogClickHandler
133
+ if (originalClickHandler) close.removeEventListener("click", originalClickHandler)
134
+
135
+ close._closeDialogClickHandler = () => {
136
+ const closeTriggerData = close.dataset.closeDialog;
137
+ const targetDialogClose = document.getElementById(closeTriggerData)
138
+ if (targetDialogClose) targetDialogClose.close();
139
+ };
140
+
141
+ close.addEventListener("click", close._closeDialogClickHandler)
54
142
  });
55
143
 
56
144
  // Close dialog box on outside click
57
145
  dialogs.forEach((dialogElement) => {
58
- dialogElement.addEventListener("mousedown", (event) => {
146
+ const originalMousedownHandler = dialogElement._outsideClickHandler
147
+ if (originalMousedownHandler) dialogElement.removeEventListener("mousedown", originalMousedownHandler)
148
+ dialogElement._outsideClickHandler = (event) => {
59
149
  const dialogParentDataset = dialogElement.parentElement.dataset
60
150
  if (dialogParentDataset.overlayClick === "overlay_close") return
61
151
 
@@ -69,7 +159,9 @@ export default class PbDialog extends PbEnhancedElement {
69
159
  dialogElement.close()
70
160
  event.stopPropagation()
71
161
  }
72
- })
162
+ }
163
+
164
+ dialogElement.addEventListener("mousedown", dialogElement._outsideClickHandler);
73
165
  })
74
166
  }
75
167
  }
@@ -0,0 +1,42 @@
1
+ <% initial_items = [
2
+ {
3
+ id: "100",
4
+ url: "https://unsplash.it/500/400/?image=638",
5
+ },
6
+ {
7
+ id: "200",
8
+ url: "https://unsplash.it/500/400/?image=639",
9
+ },
10
+ {
11
+ id: "300",
12
+ url: "https://unsplash.it/500/400/?image=640",
13
+ },
14
+ ] %>
15
+
16
+ <%= pb_rails("draggable", props: {initial_items: initial_items}) do %>
17
+ <%= pb_rails("draggable/draggable_container") do %>
18
+ <%= pb_rails("flex") do %>
19
+ <% initial_items.each do |item| %>
20
+ <%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id]}) do %>
21
+ <%= pb_rails("image", props: { alt: item[:id], size: "md", url: item[:url], margin: "xs" }) %>
22
+ <% end %>
23
+ <% end %>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
27
+
28
+ <script>
29
+ const itemIds = ["item_100", "item_200", "item_300"];
30
+
31
+ itemIds.forEach((id) => {
32
+ const element = document.getElementById(id);
33
+ if (element) {
34
+ element.addEventListener("dragstart", (event) => {
35
+ console.log(`${id} drag start!`);
36
+ });
37
+ element.addEventListener("dragend", (event) => {
38
+ console.log(`${id} drag end!`);
39
+ });
40
+ }
41
+ });
42
+ </script>
@@ -0,0 +1 @@
1
+ You can add drag event listeners for `drag`, `dragend`, `dragenter`, `dragleave`, `dragover`, `dragstart`, and `drop`.
@@ -17,4 +17,5 @@ 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_event_listeners: Draggable Event Listeners
20
21
 
@@ -35,7 +35,7 @@ type DropdownProps = {
35
35
  label?: string;
36
36
  onSelect?: (arg: GenericObject) => null;
37
37
  options: GenericObject;
38
- separators: boolean;
38
+ separators?: boolean;
39
39
  triggerRef?: any;
40
40
  variant?: "default" | "subtle";
41
41
  };
@@ -22,7 +22,7 @@ type DropdownOptionProps = {
22
22
  data?: { [key: string]: string };
23
23
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
24
24
  id?: string;
25
- key?: string;
25
+ key?: string | number;
26
26
  option?: GenericObject;
27
27
  padding?: string;
28
28
  } & GlobalProps;
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+ import gaugeTheme from '../gaugeTheme'
3
+ import Highcharts from "highcharts"
4
+ import HighchartsReact from "highcharts-react-official"
5
+ import HighchartsMore from "highcharts/highcharts-more"
6
+ import SolidGauge from "highcharts/modules/solid-gauge"
7
+
8
+ HighchartsMore(Highcharts);
9
+ SolidGauge(Highcharts);
10
+
11
+ const data = [{ name: "Name", y: 45 }]
12
+
13
+ const baseOptions = {
14
+ title: { text: "" },
15
+ series: [{ data: data }],
16
+ };
17
+
18
+ const GaugePbStyles = () => {
19
+ const options = Highcharts.merge({}, gaugeTheme, baseOptions);
20
+
21
+ return (
22
+ <div>
23
+ <HighchartsReact
24
+ highcharts={Highcharts}
25
+ options={options}
26
+ />
27
+ </div>
28
+ );
29
+ };
30
+
31
+ export default GaugePbStyles;
@@ -0,0 +1 @@
1
+ You don't need to use the Gauge Kit to apply Playbook styles to your Highcharts gauge chart. Just import gaugeTheme.ts and merge it with your chart options—Playbook’s styling will apply automatically.
@@ -15,6 +15,7 @@ examples:
15
15
 
16
16
  react:
17
17
  - gauge_default: Default
18
+ - gauge_pb_styles: Playbook Styles
18
19
  - gauge_disable_animation: Disable Animation
19
20
  - gauge_title: Title
20
21
  - gauge_units: Units
@@ -1,4 +1,5 @@
1
1
  export { default as GaugeDefault } from './_gauge_default.jsx'
2
+ export { default as GaugePbStyles } from './_gauge_pb_styles.jsx'
2
3
  export { default as GaugeDisableAnimation } from './_gauge_disable_animation.jsx'
3
4
  export { default as GaugeFullCircle } from './_gauge_full_circle.jsx'
4
5
  export { default as GaugeHeight } from './_gauge_height.jsx'
@@ -0,0 +1,83 @@
1
+ import colors from '../tokens/exports/_colors.module.scss'
2
+ import typography from '../tokens/exports/_typography.module.scss'
3
+
4
+ const gaugeTheme = {
5
+ chart: {
6
+ type: "solidgauge",
7
+ events: {
8
+ render() {
9
+ this.container
10
+ const arc = this.container.querySelector('path.gauge-pane');
11
+ if (arc) arc.setAttribute('stroke-linejoin', 'round');
12
+ }
13
+ }
14
+ },
15
+ pane: {
16
+ size: "90%",
17
+ startAngle: -100,
18
+ endAngle: 100,
19
+ background: [
20
+ {
21
+ borderWidth: 20,
22
+ innerRadius: "90%",
23
+ outerRadius: "90%",
24
+ shape: "arc",
25
+ className: "gauge-pane",
26
+ borderColor: colors.border_light,
27
+ borderRadius: '50%',
28
+ },
29
+ ],
30
+ },
31
+ tooltip: {
32
+ backgroundColor: {
33
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
34
+ stops: [
35
+ [0, colors.bg_dark],
36
+ [1, colors.bg_dark],
37
+ ],
38
+ },
39
+ pointFormat:
40
+ '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' +
41
+ "<b>{point.y}</b>",
42
+ followPointer: true,
43
+ shadow: false,
44
+ borderWidth: 0,
45
+ borderRadius: 10,
46
+ style: {
47
+ fontFamily: typography.font_family_base,
48
+ color: colors.text_dk_default,
49
+ fontWeight: typography.regular,
50
+ fontSize: typography.text_smaller,
51
+ },
52
+ },
53
+ yAxis: {
54
+ min: 0,
55
+ max: 100,
56
+ lineWidth: 0,
57
+ tickPositions: [] as number[],
58
+ },
59
+ plotOptions: {
60
+ solidgauge: {
61
+ borderColor: colors.data_1,
62
+ borderWidth: 20,
63
+ color: colors.data_1,
64
+ radius: 90,
65
+ innerRadius: "90%",
66
+ y: -26,
67
+ dataLabels: {
68
+ borderWidth: 0,
69
+ color: colors.text_lt_default,
70
+ enabled: true,
71
+ format: '<span class="fix">{y:,f}</span>',
72
+ style: {
73
+ fontFamily: typography.font_family_base,
74
+ fontWeight: typography.regular,
75
+ fontSize: typography.heading_2,
76
+ },
77
+ y: -26,
78
+ },
79
+ },
80
+ }
81
+ }
82
+
83
+ export default gaugeTheme;
@@ -88,6 +88,40 @@ $overlay_colors: (
88
88
  }
89
89
  }
90
90
 
91
+ &.overlay-full-screen {
92
+ position: fixed;
93
+ top: 0;
94
+ left: 0;
95
+ right: 0;
96
+ bottom: 0;
97
+ width: 100vw;
98
+ height: 100vh;
99
+ z-index: 9999;
100
+
101
+ &.no_gradient {
102
+ @each $color_name, $color in $overlay_colors {
103
+ &[data-overlay-color="#{$color_name}"] {
104
+ &::before {
105
+ content: "";
106
+ position: absolute;
107
+ top: 0;
108
+ left: 0;
109
+ right: 0;
110
+ bottom: 0;
111
+ background: $color;
112
+ pointer-events: none;
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ @each $key, $value in $opacity {
119
+ &.#{$key}::before {
120
+ opacity: $value;
121
+ }
122
+ }
123
+ }
124
+
91
125
  &.no_gradient {
92
126
  @each $color_name, $color in $overlay_colors {
93
127
  .overlay_#{$color_name} {