playbook_ui 14.17.0.pre.alpha.play1735highchartscirclechartdefaultrebuild7368 → 14.17.0.pre.alpha.play1735highchartscirclechartdefaultrebuild7372

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_circle_chart/circleChart.test.js +2 -2
  3. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.html.erb +2 -2
  4. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +1 -1
  5. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.html.erb +1 -1
  6. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +1 -1
  7. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.html.erb +1 -1
  8. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb +1 -1
  12. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +2 -2
  14. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.jsx +1 -1
  15. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.html.erb +1 -1
  16. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +1 -1
  17. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +10 -1
  18. data/app/pb_kits/playbook/pb_dialog/dialog.rb +2 -0
  19. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames.html.erb +117 -0
  20. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames_rails.md +9 -0
  21. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
  22. data/app/pb_kits/playbook/pb_dialog/index.js +106 -14
  23. data/dist/menu.yml +1 -1
  24. data/dist/playbook-doc.js +1 -1
  25. data/dist/playbook-rails.js +1 -1
  26. data/lib/playbook/version.rb +1 -1
  27. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fd90f06df9761ed83939be0a332b4b8b960987fbcdefdcdb8cd47c2c23f9f03
4
- data.tar.gz: 629565cbc4924a93ed75e116ccf95e802a39a526b2954f3d08ea9a6fc19ff74b
3
+ metadata.gz: b79260385722d6d3fe338b005d35bfbe8cb939865f99efb2a05d3421fc5749be
4
+ data.tar.gz: a83f1196c4f3ebcbeec42dd0996415eed3a439373115e89c055a2620e83bbfc2
5
5
  SHA512:
6
- metadata.gz: bef76431ab0c389ac44a41c5a1a597a1b337276ba47bd5a8840903bcdcbf8b535550c5d24247eff8f4dec51a2d934dba5e8ac75e287e15a1303917685f99a044
7
- data.tar.gz: c8526c5943342b8642ebdc19b86fd1ff940de528a401246674debb98e2cf53c0fd3bfd14132f39a8d12da9b9bdfc9c56b117ad286bde41b8addec778f32dc8ab
6
+ metadata.gz: b2348dc2df6b786e5714e7bc3c392c9b2286b426c97b427465e3511afa3abf8300cfc2440d22cfeebfee1b5f9a6cfdd469596e8af2af5f5d07c59e82f9ed7b8b
7
+ data.tar.gz: 1f5c2676b913b969fd033f95df4f9074bba38fc55e26d161a689d5b6762564fd14da47bbf98432543a6be1376d5cfab78c08557b8557cb1d760a11aa664b957b
@@ -28,7 +28,7 @@ test('uses exact classname', () => {
28
28
  value: 49,
29
29
  },
30
30
  {
31
- name: 'After call',
31
+ name: 'After Call',
32
32
  value: 10,
33
33
  },
34
34
  ]
@@ -39,7 +39,7 @@ test('uses exact classname', () => {
39
39
  id='circlechartid'
40
40
  />
41
41
  );
42
-
42
+
43
43
  const kit = screen.getByTestId(testId);
44
44
  expect(kit).toHaveClass('pb_circle_chart');
45
45
  });
@@ -7,7 +7,7 @@
7
7
  value: 49,
8
8
  },
9
9
  {
10
- name: 'After call',
10
+ name: 'After Call',
11
11
  value: 10,
12
12
  }
13
13
  ] %>
@@ -18,7 +18,7 @@
18
18
  chart_data: data_51,
19
19
  id: "with-a-block-2",
20
20
  rounded: true,
21
- }) do %>
21
+ }) do %>
22
22
  <%= pb_rails('title', props: {text: "83", size: 1, tag: 'div'}) %>
23
23
  <% end %>
24
24
 
@@ -13,7 +13,7 @@ const dataWithABlock = [
13
13
  value: 49,
14
14
  },
15
15
  {
16
- name: 'After call',
16
+ name: 'After Call',
17
17
  value: 10,
18
18
  },
19
19
  ]
@@ -7,7 +7,7 @@
7
7
  value: 49,
8
8
  },
9
9
  {
10
- name: 'After call',
10
+ name: 'After Call',
11
11
  value: 10,
12
12
  }
13
13
  ] %>
@@ -12,7 +12,7 @@ const dataWithColors = [
12
12
  value: 49,
13
13
  },
14
14
  {
15
- name: 'After call',
15
+ name: 'After Call',
16
16
  value: 10,
17
17
  },
18
18
  ]
@@ -7,7 +7,7 @@
7
7
  value: 49,
8
8
  },
9
9
  {
10
- name: 'After call',
10
+ name: 'After Call',
11
11
  value: 10,
12
12
  }
13
13
  ] %>
@@ -12,7 +12,7 @@ const data = [
12
12
  value: 49,
13
13
  },
14
14
  {
15
- name: 'After call',
15
+ name: 'After Call',
16
16
  value: 10,
17
17
  },
18
18
  ]
@@ -7,7 +7,7 @@
7
7
  value: 49,
8
8
  },
9
9
  {
10
- name: 'After call',
10
+ name: 'After Call',
11
11
  value: 10,
12
12
  }
13
13
  ] %>
@@ -12,7 +12,7 @@ const data = [
12
12
  value: 49,
13
13
  },
14
14
  {
15
- name: 'After call',
15
+ name: 'After Call',
16
16
  value: 10,
17
17
  },
18
18
  ]
@@ -7,7 +7,7 @@
7
7
  value: 49,
8
8
  },
9
9
  {
10
- name: 'After call',
10
+ name: 'After Call',
11
11
  value: 10,
12
12
  }
13
13
  ] %>
@@ -14,7 +14,7 @@ const data = [
14
14
  value: 49,
15
15
  },
16
16
  {
17
- name: 'After call',
17
+ name: 'After Call',
18
18
  value: 10,
19
19
  },
20
20
  ]
@@ -14,7 +14,7 @@ const CircleChartLiveData = (props) => {
14
14
  value: 49,
15
15
  },
16
16
  {
17
- name: 'After call',
17
+ name: 'After Call',
18
18
  value: 10,
19
19
  },
20
20
  ])
@@ -29,7 +29,7 @@ const CircleChartLiveData = (props) => {
29
29
  value: 12,
30
30
  },
31
31
  {
32
- name: 'After call',
32
+ name: 'After Call',
33
33
  value: 140,
34
34
  },
35
35
  ]
@@ -13,7 +13,7 @@ const data = [
13
13
  y: 49,
14
14
  },
15
15
  {
16
- name: 'After call',
16
+ name: 'After Call',
17
17
  y: 10,
18
18
  },
19
19
  ]
@@ -7,7 +7,7 @@
7
7
  value: 49,
8
8
  },
9
9
  {
10
- name: 'After call',
10
+ name: 'After Call',
11
11
  value: 10,
12
12
  }
13
13
  ] %>
@@ -12,7 +12,7 @@ const dataRounded = [
12
12
  value: 49,
13
13
  },
14
14
  {
15
- name: 'After call',
15
+ name: 'After Call',
16
16
  value: 10,
17
17
  },
18
18
  ]
@@ -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
  }
data/dist/menu.yml CHANGED
@@ -28,7 +28,7 @@ kits:
28
28
  status: stable
29
29
  icons_used: true
30
30
  react_rendered: false
31
- enhanced_element_used: false
31
+ enhanced_element_used: true
32
32
  - name: fixed_confirmation_toast
33
33
  platforms: *1
34
34
  description: Fixed Confirmation Toast is used as an alert. Success is used when