playbook_ui 14.18.0.pre.rc.4 → 14.19.0.pre.rc.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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
  3. data/app/pb_kits/playbook/pb_circle_chart/circleChart.test.js +2 -2
  4. data/app/pb_kits/playbook/pb_circle_chart/circleChartTheme.ts +53 -0
  5. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.html.erb +2 -2
  6. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +1 -1
  7. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.html.erb +1 -1
  8. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.jsx +1 -1
  11. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.html.erb +1 -1
  12. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb +1 -1
  14. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +1 -1
  15. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +2 -2
  16. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.jsx +38 -0
  17. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.md +1 -0
  18. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.html.erb +1 -1
  19. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +2 -3
  21. data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +2 -1
  22. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +39 -1
  23. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +4 -0
  24. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +9 -1
  25. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.test.js +14 -0
  26. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.html.erb +28 -0
  27. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.jsx +42 -0
  28. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_size.md +1 -0
  29. data/app/pb_kits/playbook/pb_circle_icon_button/docs/example.yml +2 -0
  30. data/app/pb_kits/playbook/pb_circle_icon_button/docs/index.js +1 -0
  31. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook_rails.html.erb +14 -0
  32. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook_rails.md +3 -0
  33. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +1 -0
  34. data/app/pb_kits/playbook/pb_copy_button/index.js +46 -20
  35. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +12 -0
  36. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +12 -0
  37. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +50 -1
  38. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_error.jsx +4 -1
  39. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_rails.md +4 -0
  40. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_range_limit.md +1 -1
  41. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_react.md +5 -1
  42. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +34 -0
  43. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.md +14 -0
  44. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern_rails.html.erb +20 -0
  45. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern_rails.md +14 -0
  46. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
  47. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
  48. data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +10 -0
  49. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +10 -1
  50. data/app/pb_kits/playbook/pb_dialog/dialog.rb +2 -0
  51. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames.html.erb +117 -0
  52. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_turbo_frames_rails.md +9 -0
  53. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
  54. data/app/pb_kits/playbook/pb_dialog/index.js +106 -14
  55. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.jsx +4 -1
  56. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.jsx +30 -0
  57. data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.md +1 -0
  58. data/app/pb_kits/playbook/pb_gauge/docs/example.yml +1 -0
  59. data/app/pb_kits/playbook/pb_gauge/docs/index.js +1 -0
  60. data/app/pb_kits/playbook/pb_gauge/gaugeTheme.ts +85 -0
  61. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +34 -0
  62. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +25 -4
  63. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_background.jsx +49 -0
  64. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_background.md +1 -0
  65. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_opacity.jsx +81 -0
  66. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_fullscreen_opacity.md +1 -0
  67. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +2 -0
  68. data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
  69. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.jsx +8 -1
  70. data/app/pb_kits/playbook/pb_select/docs/_select_error.jsx +7 -2
  71. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.jsx +9 -1
  72. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.jsx +7 -1
  73. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx +6 -2
  74. data/dist/chunks/_typeahead-BX8IifKY.js +22 -0
  75. data/dist/chunks/_weekday_stacked-DfMD7HJz.js +45 -0
  76. data/dist/chunks/{lib-Cj4H6j1c.js → lib-96_ZmvAo.js} +1 -1
  77. data/dist/chunks/{pb_form_validation-Bx1OK6xs.js → pb_form_validation-Vv2TqXVC.js} +1 -1
  78. data/dist/chunks/vendor.js +1 -1
  79. data/dist/menu.yml +2 -2
  80. data/dist/playbook-doc.js +2 -2
  81. data/dist/playbook-rails-react-bindings.js +1 -1
  82. data/dist/playbook-rails.js +1 -1
  83. data/dist/playbook.css +1 -1
  84. data/lib/playbook/version.rb +2 -2
  85. metadata +27 -6
  86. data/dist/chunks/_typeahead-aRwivA3u.js +0 -22
  87. data/dist/chunks/_weekday_stacked-Bm5175-u.js +0 -45
@@ -77,6 +77,14 @@ module Playbook
77
77
  default: ""
78
78
  prop :validation_message, type: Playbook::Props::String,
79
79
  default: ""
80
+ prop :controls_start_id, type: Playbook::Props::String,
81
+ default: ""
82
+ prop :controls_end_id, type: Playbook::Props::String,
83
+ default: ""
84
+ prop :sync_start_with, type: Playbook::Props::String,
85
+ default: ""
86
+ prop :sync_end_with, type: Playbook::Props::String,
87
+ default: ""
80
88
 
81
89
  def classname
82
90
  default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
@@ -108,6 +116,10 @@ module Playbook
108
116
  staticPosition: static_position,
109
117
  thisRangesEndToday: this_ranges_end_today,
110
118
  yearRange: year_range,
119
+ controlsStartId: controls_start_id,
120
+ controlsEndId: controls_end_id,
121
+ syncStartWith: sync_start_with,
122
+ syncEndWith: sync_end_with,
111
123
  }.to_json.html_safe
112
124
  end
113
125
 
@@ -32,7 +32,11 @@ type DatePickerConfig = {
32
32
  thisRangesEndToday?: boolean,
33
33
  timeCaption?: string,
34
34
  timeFormat?: string,
35
- yearRange: number[]
35
+ yearRange: number[],
36
+ controlsStartId?: string,
37
+ controlsEndId?: string,
38
+ syncStartWith?: string,
39
+ syncEndWith?: string,
36
40
  } & Pick<BaseOptions, "allowInput" | "defaultDate" | "enableTime" | "maxDate" | "minDate" | "mode" | "plugins" | "position" | "positionElement" >
37
41
 
38
42
  const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HTMLElement) => {
@@ -67,6 +71,10 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
67
71
  timeCaption = 'Select Time',
68
72
  timeFormat = 'at h:i K',
69
73
  yearRange,
74
+ controlsStartId,
75
+ controlsEndId,
76
+ syncStartWith,
77
+ syncEndWith,
70
78
  } = config
71
79
 
72
80
  // ===========================================================
@@ -275,6 +283,47 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
275
283
  })
276
284
  }
277
285
 
286
+ // === Automatic Sync Logic for 3 input range pattern===
287
+
288
+ // If this is a quickpick that controls start and end
289
+ if (selectionType === "quickpick" && (controlsStartId || controlsEndId)) {
290
+ picker.config.onClose.push((selectedDates:string) => {
291
+ const [start, end] = selectedDates;
292
+
293
+ if (controlsStartId) {
294
+ const startPicker = (document.querySelector(`#${controlsStartId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
295
+ startPicker?.setDate(start, true);
296
+ }
297
+
298
+ if (controlsEndId) {
299
+ const endPicker = (document.querySelector(`#${controlsEndId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
300
+ endPicker?.setDate(end, true);
301
+ }
302
+ });
303
+ }
304
+
305
+ // If this is a start picker that syncs with a quickpick
306
+ if (syncStartWith) {
307
+ picker.config.onClose.push((selectedDates: string) => {
308
+ if (selectedDates?.length) {
309
+ const quickpick = (document.querySelector(`#${syncStartWith}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
310
+ quickpick?.clear();
311
+ }
312
+ });
313
+ }
314
+
315
+ // If this is an end picker that syncs with a quickpick
316
+ if (syncEndWith) {
317
+ picker.config.onClose.push((selectedDates: string) => {
318
+ if (selectedDates?.length) {
319
+ const quickpick = (document.querySelector(`#${syncEndWith}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
320
+ quickpick?.clear();
321
+ }
322
+ });
323
+ }
324
+ // === End of Automatic Sync Logic ===
325
+
326
+
278
327
  // Adding dropdown icons to year and month select
279
328
  dropdown.insertAdjacentHTML('afterend', `<i class="year-dropdown-icon">${angleDown}</i>`)
280
329
  if (picker.monthElements[0].parentElement) {
@@ -1,11 +1,14 @@
1
1
  import React from 'react'
2
2
 
3
3
  import DatePicker from '../_date_picker'
4
+ import Icon from '../../pb_icon/_icon'
4
5
 
5
6
  const DatePickerError = (props) => (
6
7
  <div>
7
8
  <DatePicker
8
- error="Invalid date. Please pick a valid date."
9
+ error={<>
10
+ <Icon icon="warning" /> Invalid date. Please pick a valid date.
11
+ </>}
9
12
  pickerId="date-picker-error"
10
13
  {...props}
11
14
  />
@@ -1,3 +1,7 @@
1
+ To use the `quickpick`:
2
+ - prop `mode` must be set to `range`
3
+ - prop `selection_type` must be set to `quickpick`
4
+
1
5
  This date range variant uses hidden inputs to handle start and end dates. While they are not required props, it is advisable to specify a unique `start_date_id`, `start_date_name`, `end_date_id`, and `end_date_name` for each quick pick instance you place in a form and/or on a page.
2
6
 
3
7
  Like all other date pickers, the quick pick does require a `picker_id`.
@@ -1 +1 @@
1
- Because the Quick Pick variant has `allowInput` set to `true` by default, use the `onClose` handler function to access the startDate and endDate values. See the `onClose` example for details.
1
+ Use `this_ranges_end_today`/`thisRangesEndToday` to set end date on all ranges that start with 'this' to today's date. For instance, by default 'This Year' will set end day to 12/31/(current year), but if the `this_ranges_end_today`/`thisRangesEndToday` prop is used, end date on that range will be today's date.
@@ -1 +1,5 @@
1
- Use the `onChange` handler function to access the startDate and endDate values. Check the [`onChange` example](https://playbook.powerapp.cloud/kits/date_picker/react#onchange) for more information.
1
+ To use the `quickpick`:
2
+ - prop `mode` must be set to `range`
3
+ - prop `selectionType` must be set to `quickpick`
4
+
5
+ Use the `onClose` handler function to access the startDate and endDate values. Check the [`onClose` example](https://playbook.powerapp.cloud/kits/date_picker/react#onclose) for more information.
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import DatePicker from "../_date_picker";
3
+
4
+ const DatePickerRangePattern = (props) => {
5
+ return (
6
+ <>
7
+ <DatePicker
8
+ controlsEndId="end-date-picker"
9
+ controlsStartId="start-date-picker"
10
+ mode="range"
11
+ pickerId="quickpick-for-range"
12
+ placeholder="Select a Range"
13
+ selectionType="quickpick"
14
+ {...props}
15
+ />
16
+
17
+ <DatePicker
18
+ pickerId="start-date-picker"
19
+ placeholder="Select a Start Date"
20
+ syncStartWith="quickpick-for-range"
21
+ {...props}
22
+ />
23
+
24
+ <DatePicker
25
+ pickerId="end-date-picker"
26
+ placeholder="Select a End Date"
27
+ syncEndWith="quickpick-for-range"
28
+ {...props}
29
+ />
30
+ </>
31
+ );
32
+ };
33
+
34
+ export default DatePickerRangePattern;
@@ -0,0 +1,14 @@
1
+ You can link a Quickpick DatePicker to standard DatePickers using the following props:
2
+
3
+ **For the Quickpick DatePicker**:
4
+ `controlsStartId`: ID of the DatePicker that should receive the start date.
5
+
6
+ `controlsEndId`: ID of the DatePicker that should receive the end date.
7
+
8
+ When a quickpick option like “This Year” is selected, it automatically populates the linked start and end inputs.
9
+
10
+ **For the Start/End DatePickers**:
11
+ `syncStartWith`: ID of the quickpick this start date is synced to.
12
+ `syncEndWith`: ID of the quickpick this end date is synced to.
13
+
14
+ When a user manually edits the start or end date, it clears the selected quickpick to prevent conflicting values.
@@ -0,0 +1,20 @@
1
+ <%= pb_rails("date_picker", props: {
2
+ mode: "range",
3
+ picker_id: "quick-pick-date-range",
4
+ placeholder: "Select a Date Range",
5
+ selection_type: "quickpick",
6
+ controls_end_id: "quick-pick-date-range-end",
7
+ controls_start_id: "quick-pick-date-range-start",
8
+ }) %>
9
+
10
+ <%= pb_rails("date_picker", props: {
11
+ picker_id: "quick-pick-date-range-start",
12
+ placeholder: "Select a Start Date",
13
+ sync_start_with:"quick-pick-date-range",
14
+ }) %>
15
+
16
+ <%= pb_rails("date_picker", props: {
17
+ picker_id: "quick-pick-date-range-end",
18
+ placeholder: "Select an End Date",
19
+ sync_end_with:"quick-pick-date-range",
20
+ }) %>
@@ -0,0 +1,14 @@
1
+ You can link a Quickpick DatePicker to standard DatePickers using the following props:
2
+
3
+ **For the Quickpick DatePicker**:
4
+ `controls_start_id`: ID of the DatePicker that should receive the start date.
5
+
6
+ `controls_end_id`: ID of the DatePicker that should receive the end date.
7
+
8
+ When a quickpick option like “This Year” is selected, it automatically populates the linked start and end inputs.
9
+
10
+ **For the Start/End DatePickers**:
11
+ `sync_start_with`: ID of the quickpick this start date is synced to.
12
+ `sync_end_with`: ID of the quickpick this end date is synced to.
13
+
14
+ When a user manually edits the start or end date, it clears the selected quickpick to prevent conflicting values.
@@ -15,6 +15,7 @@ examples:
15
15
  - date_picker_quick_pick_custom: Custom Quick Pick Dates
16
16
  - date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
17
17
  - date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
18
+ - date_picker_range_pattern_rails: Range with 2 Date Pickers and a Quick Pick
18
19
  - date_picker_format: Format
19
20
  - date_picker_disabled: Disabled Dates
20
21
  - date_picker_min_max: Min Max
@@ -47,6 +48,7 @@ examples:
47
48
  - date_picker_quick_pick_custom: Custom Quick Pick Dates
48
49
  - date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
49
50
  - date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
51
+ - date_picker_range_pattern: Range with 2 Date Pickers and a Quick Pick
50
52
  - date_picker_format: Format
51
53
  - date_picker_disabled: Disabled Dates
52
54
  - date_picker_min_max: Min Max
@@ -26,3 +26,4 @@ export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
26
26
  export { default as DatePickerQuickPickCustom } from './_date_picker_quick_pick_custom'
27
27
  export { default as DatePickerQuickPickCustomOverride } from './_date_picker_quick_pick_custom_override'
28
28
  export { default as DatePickerQuickPickDefaultDate } from './_date_picker_quick_pick_default_date'
29
+ export { default as DatePickerRangePattern } from './_date_picker_range_pattern'
@@ -238,6 +238,16 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
238
238
  },
239
239
 
240
240
  onClose(selectedDates: Array<Date>) {
241
+ // Patch .clear() to also remove active state if cleared
242
+ const originalClear = fp.clear;
243
+ fp.clear = function (...args: any) {
244
+ const current = pluginData.rangesNav.querySelector('.active');
245
+ if (current) {
246
+ current.classList.remove('active');
247
+ }
248
+ activeLabel = "";
249
+ return originalClear.apply(this, args);
250
+ };
241
251
  // remove the active class from the button if the selected dates don't match the label
242
252
  if (!isLabelMatchingSelectedDates(selectedDates)) {
243
253
  pluginData.rangesButtons[activeLabel]?.classList.remove('active');
@@ -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
  }
@@ -1,9 +1,12 @@
1
1
  import React, { useState } from 'react'
2
2
  import Dropdown from '../../pb_dropdown/_dropdown'
3
+ import Icon from '../../pb_icon/_icon'
3
4
 
4
5
  const DropdownError = (props) => {
5
6
  const [selectedOption, setSelectedOption] = useState()
6
- const error = selectedOption?.value ? null : "Please make a valid selection"
7
+ const error = selectedOption?.value ? null : (<>
8
+ <Icon icon="warning" /> Please make a valid selection
9
+ </>)
7
10
  const options = [
8
11
  {
9
12
  label: "United States",
@@ -0,0 +1,30 @@
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
+ series: [{ data: data }],
15
+ };
16
+
17
+ const GaugePbStyles = () => {
18
+ const options = Highcharts.merge({}, gaugeTheme, baseOptions);
19
+
20
+ return (
21
+ <div>
22
+ <HighchartsReact
23
+ highcharts={Highcharts}
24
+ options={options}
25
+ />
26
+ </div>
27
+ );
28
+ };
29
+
30
+ 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'