playbook_ui_docs 16.2.0 → 16.3.0.pre.alpha.PLAY2779dropdowncustomeventtype14814

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.jsx +50 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.md +1 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  6. data/app/pb_kits/playbook/pb_caption/docs/_caption_colors.html.erb +6 -4
  7. data/app/pb_kits/playbook/pb_caption/docs/_caption_colors.jsx +14 -4
  8. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions.md +1 -0
  9. data/app/pb_kits/playbook/pb_detail/docs/_detail_colors.html.erb +6 -24
  10. data/app/pb_kits/playbook/pb_detail/docs/_detail_colors.jsx +35 -33
  11. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +3 -1
  12. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb +18 -9
  13. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +24 -5
  14. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options.jsx +63 -0
  15. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options.md +1 -0
  16. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options_rails.html.erb +16 -0
  17. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options_rails.md +1 -0
  18. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_event_type.html.erb +224 -0
  19. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_event_type.md +7 -0
  20. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +3 -0
  21. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -1
  23. data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +2 -0
  24. data/app/pb_kits/playbook/pb_link/docs/_link_underline.jsx +31 -1
  25. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_reset_key.jsx +100 -0
  26. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_reset_key.md +1 -0
  27. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
  28. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  29. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.jsx +1 -1
  30. data/app/pb_kits/playbook/pb_select/docs/_select_required_indicator.html.erb +24 -0
  31. data/app/pb_kits/playbook/pb_select/docs/_select_required_indicator.jsx +33 -0
  32. data/app/pb_kits/playbook/pb_select/docs/_select_required_indicator.md +3 -0
  33. data/app/pb_kits/playbook/pb_select/docs/example.yml +3 -2
  34. data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.jsx +152 -0
  36. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.md +17 -0
  37. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.html.erb +121 -0
  38. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.md +17 -0
  39. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  40. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_disabled.jsx +11 -13
  42. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_disabled.html.erb +10 -0
  43. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_disabled.jsx +27 -0
  44. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_input_options.jsx +68 -0
  45. data/app/pb_kits/playbook/pb_textarea/docs/example.yml +3 -0
  46. data/app/pb_kits/playbook/pb_textarea/docs/index.js +10 -8
  47. data/app/pb_kits/playbook/pb_title/docs/_title_colors.html.erb +2 -0
  48. data/app/pb_kits/playbook/pb_title/docs/_title_colors.jsx +14 -0
  49. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7bb2214a52b11123d3b0e739b02b0b6f6e556e7dc4b2db0212080e1773cfbfa
4
- data.tar.gz: ebe6a162f19e4efa53fbc8f30b705147c56269f5b05f1ff7d987476e0b3d4f17
3
+ metadata.gz: a202b4c2d3abe944d7248f78ad90917976c11e6176a02cf34028626534ee356d
4
+ data.tar.gz: 693c9c1f71ae0d1526478936dd9555a57bc84f8600e2c94ee3245a1cee75ce13
5
5
  SHA512:
6
- metadata.gz: 1f280040d880d2542c3931ca6dc156b9fbd61d6fd5ca5eb198ecefda34c216b44ab1dbfd8738d22b09385fec0142025f340173b9ccacd944d176ebfc5e1d5985
7
- data.tar.gz: 92aad1b9bfdb2307addd84602b38fb657ae9ac393b2b532bb80fe935ec67176570c144233f865383f1c8f586e171867d766a96518d29e2009f021ef68d4f3a27
6
+ metadata.gz: bed570031f4aed95e8ac18ed1e70c97c0d8f6bc00f55274f7c3f3bdc5360a74b402cf9273e8263a037f06222eb614f7bf644eef163efe23eb42cf5f6afd9f4ee
7
+ data.tar.gz: f805a1699bd6d1d8aeeed6a5d215df5a7d00c81ab10c23276d18d158175b74d438169707f5530470625665b1ffe7f6e2ecd1e8e9cc6b174ae1a03f23d4fb39b8
@@ -0,0 +1,50 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableCascadeCollapse = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ return (
39
+ <div>
40
+ <AdvancedTable
41
+ cascadeCollapse
42
+ columnDefinitions={columnDefinitions}
43
+ tableData={MOCK_DATA}
44
+ {...props}
45
+ />
46
+ </div>
47
+ )
48
+ }
49
+
50
+ export default AdvancedTableCascadeCollapse
@@ -0,0 +1 @@
1
+ `cascadeCollapse` is an optional prop that is set to 'false' by default. If set to 'true', collapsing any parent row itself or by using the toggle exapansion buttons in any header or subheader row also collapses all descendants and clears their expansion state. Re-expanding then shows only direct children until the user expands deeper levels again.
@@ -42,6 +42,7 @@ examples:
42
42
  - advanced_table_expanded_control: Expanded Control
43
43
  - advanced_table_expand_by_depth: Expand by Depth
44
44
  - advanced_table_subrow_headers: SubRow Headers
45
+ - advanced_table_cascade_collapse: Cascade Collapse
45
46
  - advanced_table_collapsible_trail: Collapsible Trail
46
47
  - advanced_table_table_options: Table Options
47
48
  - advanced_table_table_props: Table Props
@@ -48,4 +48,5 @@ export { default as AdvancedTablePaddingControl } from './_advanced_table_paddin
48
48
  export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
49
49
  export { default as AdvancedTableColumnStylingBackground } from './_advanced_table_column_styling_background.jsx'
50
50
  export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
51
- export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
51
+ export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
52
+ export { default as AdvancedTableCascadeCollapse } from './_advanced_table_cascade_collapse.jsx'
@@ -1,4 +1,6 @@
1
- <%= pb_rails("caption", props: { text: "Test colors" }) %>
2
- <%= pb_rails("caption", props: { text: "Test colors", color: "success" }) %>
3
- <%= pb_rails("caption", props: { text: "Test colors", color: "error" }) %>
4
- <%= pb_rails("caption", props: { text: "Test colors", color: "link" }) %>
1
+ <%= pb_rails("caption", props: { text: "Caption light" }) %>
2
+ <%= pb_rails("caption", props: { text: "Caption default", color: "default" }) %>
3
+ <%= pb_rails("caption", props: { text: "Caption lighter", color: "lighter" }) %>
4
+ <%= pb_rails("caption", props: { text: "Caption success", color: "success" }) %>
5
+ <%= pb_rails("caption", props: { text: "Caption error", color: "error" }) %>
6
+ <%= pb_rails("caption", props: { text: "Caption link", color: "link" }) %>
@@ -4,23 +4,33 @@ import Caption from "../../pb_caption/_caption"
4
4
  const CaptionColors = (props) => {
5
5
  return (
6
6
  <div>
7
+ <Caption
8
+ text="Caption light"
9
+ {...props}
10
+ />
11
+ <Caption
12
+ color="default"
13
+ text="Caption default"
14
+ {...props}
15
+ />
7
16
  <Caption
8
- text="Test colors"
17
+ color="lighter"
18
+ text="Caption lighter"
9
19
  {...props}
10
20
  />
11
21
  <Caption
12
22
  color="success"
13
- text="Test colors"
23
+ text="Caption success"
14
24
  {...props}
15
25
  />
16
26
  <Caption
17
27
  color="error"
18
- text="Test colors"
28
+ text="Caption error"
19
29
  {...props}
20
30
  />
21
31
  <Caption
22
32
  color="link"
23
- text="Test colors"
33
+ text="Caption link"
24
34
  {...props}
25
35
  />
26
36
  </div>
@@ -1,6 +1,7 @@
1
1
  Datepicker supports `position` options from [Flatpickr Options Documentation](https://flatpickr.js.org/options/). There are multiple positioning options to choose from.
2
2
 
3
3
  **Note:** In order for the above prop to work properly, you must also send `staticPosition={false}` to your Datepicker kit instance.
4
+ If you are using the Datepicker within a Dialog, you cannot use the `staticPosition`/`static_position` prop.
4
5
 
5
6
  #### Affix Datepicker Upon Scrolling
6
7
 
@@ -1,24 +1,6 @@
1
- <%= pb_rails("detail", props: {
2
- text: "I am a detail kit",
3
- color: "default"
4
- }) %>
5
-
6
- <%= pb_rails("detail", props: {
7
- text: "I am a detail kit",
8
- color: "lighter"
9
- }) %>
10
-
11
- <%= pb_rails("detail", props: {
12
- text: "I am a detail kit",
13
- color: "link"
14
- }) %>
15
-
16
- <%= pb_rails("detail", props: {
17
- text: "I am a detail kit",
18
- color: "error"
19
- }) %>
20
-
21
- <%= pb_rails("detail", props: {
22
- text: "I am a detail kit",
23
- color: "success"
24
- }) %>
1
+ <%= pb_rails("detail", props: { text: "I am a detail kit" }) %>
2
+ <%= pb_rails("detail", props: { text: "I am a detail kit", color: "default" }) %>
3
+ <%= pb_rails("detail", props: { text: "I am a detail kit", color: "lighter" }) %>
4
+ <%= pb_rails("detail", props: { text: "I am a detail kit", color: "link" }) %>
5
+ <%= pb_rails("detail", props: { text: "I am a detail kit", color: "error" }) %>
6
+ <%= pb_rails("detail", props: { text: "I am a detail kit", color: "success" }) %>
@@ -1,38 +1,40 @@
1
1
  import React from 'react'
2
2
  import Detail from '../../pb_detail/_detail'
3
3
 
4
- const DetailColors = (props) => (
5
- <div>
6
- <Detail
7
- color="default"
8
- text="I am a detail kit"
9
- {...props}
10
- />
11
-
12
- <Detail
13
- color="lighter"
14
- text="I am a detail kit"
15
- {...props}
16
- />
17
-
18
- <Detail
19
- color="link"
20
- text="I am a detail kit"
21
- {...props}
22
- />
23
-
24
- <Detail
25
- color="error"
26
- text="I am a detail kit"
27
- {...props}
28
- />
29
-
30
- <Detail
31
- color="success"
32
- text="I am a detail kit"
33
- {...props}
34
- />
35
- </div>
36
- )
4
+ const DetailColors = (props) => {
5
+ return (
6
+ <div>
7
+ <Detail
8
+ text="I am a detail kit"
9
+ {...props}
10
+ />
11
+ <Detail
12
+ color="default"
13
+ text="I am a detail kit"
14
+ {...props}
15
+ />
16
+ <Detail
17
+ color="lighter"
18
+ text="I am a detail kit"
19
+ {...props}
20
+ />
21
+ <Detail
22
+ color="link"
23
+ text="I am a detail kit"
24
+ {...props}
25
+ />
26
+ <Detail
27
+ color="error"
28
+ text="I am a detail kit"
29
+ {...props}
30
+ />
31
+ <Detail
32
+ color="success"
33
+ text="I am a detail kit"
34
+ {...props}
35
+ />
36
+ </div>
37
+ )
38
+ }
37
39
 
38
40
  export default DetailColors
@@ -1,4 +1,6 @@
1
1
  The dialog kit also supports customizing your dialog with a [compound component](https://kentcdodds.com/blog/compound-components-with-react-hooks) structure.
2
2
  This allows for greater flexibility and more complex dialogs.
3
3
 
4
- For the Rails version, when using the kit as a compound component it is necessary to pass the same value as the id for the dialog, the dialog header and the dialog footer in order for the opening and closing of the dialog to function as expected.
4
+ For the Rails version, when using the kit as a compound component it is necessary to pass the same value as the id for the dialog, the dialog header and the dialog footer in order for the opening and closing of the dialog to function as expected.
5
+
6
+ If you are using the datepicker within the Rails dialog, do not use the `static_position` prop on the datepicker.
@@ -1,11 +1,20 @@
1
1
  <%= pb_rails("button", props: { text: "Open Dialog", data: {"open-dialog": "dialog-1"} }) %>
2
2
 
3
- <%= pb_rails("dialog", props: {
4
- id:"dialog-1",
5
- size: "sm",
6
- title: "Header Title is the Title Prop",
7
- text: "Hello Body Text, Nice to meet ya.",
8
- cancel_button: "Cancel Button",
9
- confirm_button: "Okay",
10
- confirm_button_id: "confirm-button-1"
11
- }) %>
3
+ <%= pb_rails("dialog", props: {
4
+ id:"dialog-1",
5
+ size: "md",
6
+ title: "Header Title is the Title Prop"
7
+ }) do %>
8
+ <%= pb_rails("dialog/dialog_body") do %>
9
+ <%= pb_rails("button", props: { aria: { label: "Loading" }, loading: true, margin_right: "lg", text: "Button Primary" }) %>
10
+ <div style="height: 800px; background-color: lightgray;"></div>
11
+ <%= pb_rails("button", props: { loading: true, text: "Loading..." }) %>
12
+ <% end %>
13
+
14
+ <%= pb_rails("dialog/dialog_footer") do %>
15
+ <%= pb_rails("flex", props: { spacing: "between", padding_x: "md", padding_bottom: "md", padding: "sm" }) do %>
16
+ <%= pb_rails("button", props: { loading: true, text: "Send My Issue" }) %>
17
+ <%= pb_rails("button", props: { text: "Back", variant: "link", data: {"close-dialog": "dialog-1"} }) %>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
@@ -12,16 +12,35 @@ const DialogDefault = () => {
12
12
  <>
13
13
  <Button onClick={open}>{'Open Dialog'}</Button>
14
14
  <Dialog
15
- cancelButton="Cancel Button"
16
- confirmButton="Okay"
17
15
  onCancel={close}
18
16
  onClose={close}
19
17
  onConfirm={close}
20
18
  opened={isOpen}
21
- size="sm"
22
- text="Hello Body Text, Nice to meet ya."
19
+ size="md"
23
20
  title="Header Title is the Title Prop"
24
- />
21
+ >
22
+ <Dialog.Body>
23
+ <Button
24
+ aria={{ label: 'Loading' }}
25
+ loading
26
+ text="Button Primary"
27
+ />
28
+ <div style={{height: '800px', backgroundColor: 'lightgray'}} />
29
+ <Button
30
+ loading
31
+ text="Loading..."
32
+ />
33
+ </Dialog.Body>
34
+ <Dialog.Footer>
35
+ <Button
36
+ loading
37
+ text="Send My Issue"
38
+ />
39
+ <Button variant="link">
40
+ {"Back"}
41
+ </Button>
42
+ </Dialog.Footer>
43
+ </Dialog>
25
44
  </>
26
45
  )
27
46
  }
@@ -0,0 +1,63 @@
1
+ import React from 'react'
2
+ import Dropdown from '../../pb_dropdown/_dropdown'
3
+ import Caption from '../../pb_caption/_caption'
4
+
5
+ const DropdownClosingOptions = (props) => {
6
+ const options = [
7
+ {
8
+ label: "United States",
9
+ value: "unitedStates",
10
+ id: "us"
11
+ },
12
+ {
13
+ label: "Canada",
14
+ value: "canada",
15
+ id: "ca"
16
+ },
17
+ {
18
+ label: "Pakistan",
19
+ value: "pakistan",
20
+ id: "pk"
21
+ }
22
+ ];
23
+
24
+ return (
25
+ <>
26
+ <Caption
27
+ marginBottom="xs"
28
+ text="Any"
29
+ />
30
+ <Dropdown
31
+ closeOnClick='any'
32
+ options={options}
33
+ {...props}
34
+ />
35
+
36
+ <br />
37
+
38
+ <Caption
39
+ marginBottom="xs"
40
+ text="Outside"
41
+ />
42
+ <Dropdown
43
+ closeOnClick='outside'
44
+ options={options}
45
+ {...props}
46
+ />
47
+
48
+ <br />
49
+
50
+ <Caption
51
+ marginBottom="xs"
52
+ text="Inside"
53
+ />
54
+ <Dropdown
55
+ closeOnClick='inside'
56
+ options={options}
57
+ {...props}
58
+ />
59
+ </>
60
+ )
61
+ }
62
+
63
+ export default DropdownClosingOptions
@@ -0,0 +1 @@
1
+ The `closeOnClick` prop allows you to control when the Dropdown closes in response to click interactions. The value `any` reflects the default behavior, where the dropdown will close after any click. Set it to `outside` to ensure interactive elements as dropdown options are able to be interacted with or modified. Set it to `inside` for a dropdown that only closes when the input or dropdown menu is clicked.
@@ -0,0 +1,16 @@
1
+ <%
2
+ options = [
3
+ { label: "United States", value: "unitedStates", id: "us" },
4
+ { label: "Canada", value: "canada", id: "ca" },
5
+ { label: "Pakistan", value: "pakistan", id: "pk" },
6
+ ]
7
+ %>
8
+
9
+ <%= pb_rails("caption", props: { margin_bottom: "xs", text: "Any" }) %>
10
+ <%= pb_rails("dropdown", props: { options: options, close_on_click: "any", margin_bottom: "md" }) %>
11
+
12
+ <%= pb_rails("caption", props: { margin_bottom: "xs", text: "Outside" }) %>
13
+ <%= pb_rails("dropdown", props: { options: options, close_on_click: "outside", margin_bottom: "md" }) %>
14
+
15
+ <%= pb_rails("caption", props: { margin_bottom: "xs", text: "Inside" }) %>
16
+ <%= pb_rails("dropdown", props: { options: options, close_on_click: "inside" }) %>
@@ -0,0 +1 @@
1
+ The `close_on_click` prop allows you to control when the Dropdown closes in response to click interactions. The value `any` reflects the default behavior, where the dropdown will close after any click. Set it to `outside` to ensure interactive elements as dropdown options are able to be interacted with or modified. Set it to `inside` for a dropdown that only closes when the input or dropdown menu is clicked.
@@ -0,0 +1,224 @@
1
+ <%
2
+ default_options = [
3
+ { label: 'United States', value: 'unitedStates', id: 'us' },
4
+ { label: 'Canada', value: 'canada', id: 'ca' },
5
+ { label: 'Pakistan', value: 'pakistan', id: 'pk' },
6
+ { label: 'India', value: 'India', id: 'in' },
7
+ { label: 'Mexico', value: 'Mexico', id: 'mx' },
8
+ ]
9
+
10
+ multi_options = [
11
+ { label: 'United States', value: 'unitedStates', id: 'us' },
12
+ { label: 'Canada', value: 'canada', id: 'ca' },
13
+ { label: 'Pakistan', value: 'pakistan', id: 'pk' },
14
+ { label: 'India', value: 'india', id: 'in' },
15
+ { label: 'United Kingdom', value: 'unitedKingdom', id: 'uk' },
16
+ ]
17
+
18
+ autocomplete_options = [
19
+ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "us" },
20
+ { label: "United Kingdom", value: "unitedKingdom", areaCode: "+44", icon: "🇬🇧", id: "gb" },
21
+ { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pk" },
22
+ ]
23
+
24
+ custom_display_options = [
25
+ { label: "Strong Bad", value: "strongBad", id: "strong-bad", status: "Offline" },
26
+ { label: "Strong Mad", value: "strongMad", id: "strong-mad", status: "Online" },
27
+ { label: "Strong Sad", value: "strongSad", id: "strong-sad", status: "Away" },
28
+ ]
29
+
30
+ custom_display_content = capture do
31
+ pb_rails("flex", props: { align: "center" }) do
32
+ concat(pb_rails("avatar", props: { name: "", size: "xs", id: "cet-dropdown-avatar" }))
33
+ concat(pb_rails("body", props: { text: "", size: "xs", margin_x: "xs", id: "cet-dropdown-avatar-name" }))
34
+ concat(pb_rails("badge", props: { text: "", id: "cet-dropdown-avatar-status" }))
35
+ end
36
+ end
37
+ %>
38
+
39
+ <!-- Example 1: Default dropdown -->
40
+ <%= pb_rails("dropdown", props: {
41
+ custom_event_type: "form:submitted,pb:dropdown:clearRequest",
42
+ id: "dropdown-default-cet",
43
+ label: "Default dropdown",
44
+ margin_bottom: "sm",
45
+ options: default_options,
46
+ }) %>
47
+ <%= pb_rails("flex", props: { wrap: true, gap: "sm", align: "center", margin_bottom: "md" }) do %>
48
+ <%= pb_rails("button", props: { id: "clear-default-cet", text: "Clear", variant: "primary" }) %>
49
+ <%= pb_rails("button", props: { id: "select-default-cet", text: "Select Canada", variant: "secondary" }) %>
50
+ <%= pb_rails("button", props: { id: "simulate-default-cet", text: "Simulate form submit", variant: "secondary" }) %>
51
+ <% end %>
52
+
53
+ <script>
54
+ (function() {
55
+ var id = "dropdown-default-cet";
56
+ document.getElementById("clear-default-cet").addEventListener("click", function() {
57
+ document.dispatchEvent(new CustomEvent("pb:dropdown:clearRequest", { detail: { dropdownId: id } }));
58
+ });
59
+ document.getElementById("select-default-cet").addEventListener("click", function() {
60
+ document.dispatchEvent(new CustomEvent("pb:dropdown:select", { detail: { dropdownId: id, optionId: "ca" } }));
61
+ });
62
+ document.getElementById("simulate-default-cet").addEventListener("click", function() {
63
+ document.dispatchEvent(new CustomEvent("form:submitted", { detail: { dropdownId: id } }));
64
+ });
65
+ })();
66
+ </script>
67
+
68
+ <!-- Example 2: Multi select -->
69
+ <%= pb_rails("dropdown", props: {
70
+ custom_event_type: "form:submitted,pb:dropdown:clearRequest",
71
+ id: "dropdown-multi-cet",
72
+ label: "Multi select dropdown",
73
+ margin_bottom: "sm",
74
+ multi_select: true,
75
+ options: multi_options,
76
+ }) %>
77
+ <%= pb_rails("flex", props: { wrap: true, gap: "sm", align: "center", margin_bottom: "md" }) do %>
78
+ <%= pb_rails("button", props: { id: "clear-multi-cet", text: "Clear", variant: "primary" }) %>
79
+ <%= pb_rails("button", props: { id: "select-multi-cet", text: "Select US + UK", variant: "secondary" }) %>
80
+ <%= pb_rails("button", props: { id: "simulate-multi-cet", text: "Simulate form submit", variant: "secondary" }) %>
81
+ <% end %>
82
+
83
+ <script>
84
+ (function() {
85
+ var id = "dropdown-multi-cet";
86
+ document.getElementById("clear-multi-cet").addEventListener("click", function() {
87
+ document.dispatchEvent(new CustomEvent("pb:dropdown:clearRequest", { detail: { dropdownId: id } }));
88
+ });
89
+ document.getElementById("select-multi-cet").addEventListener("click", function() {
90
+ document.dispatchEvent(new CustomEvent("pb:dropdown:select", { detail: { dropdownId: id, optionIds: ["us", "uk"] } }));
91
+ });
92
+ document.getElementById("simulate-multi-cet").addEventListener("click", function() {
93
+ document.dispatchEvent(new CustomEvent("form:submitted", { detail: { dropdownId: id } }));
94
+ });
95
+ })();
96
+ </script>
97
+
98
+ <!-- Example 3: Autocomplete -->
99
+ <%= pb_rails("dropdown", props: {
100
+ autocomplete: true,
101
+ custom_event_type: "form:submitted,pb:dropdown:clearRequest",
102
+ id: "dropdown-autocomplete-cet",
103
+ label: "Autocomplete dropdown",
104
+ margin_bottom: "sm",
105
+ options: autocomplete_options,
106
+ }) %>
107
+ <%= pb_rails("flex", props: { wrap: true, gap: "sm", align: "center", margin_bottom: "md" }) do %>
108
+ <%= pb_rails("button", props: { id: "clear-autocomplete-cet", text: "Clear", variant: "primary" }) %>
109
+ <%= pb_rails("button", props: { id: "select-autocomplete-cet", text: "Select Pakistan", variant: "secondary" }) %>
110
+ <%= pb_rails("button", props: { id: "simulate-autocomplete-cet", text: "Simulate form submit", variant: "secondary" }) %>
111
+ <% end %>
112
+
113
+ <script>
114
+ (function() {
115
+ var id = "dropdown-autocomplete-cet";
116
+ document.getElementById("clear-autocomplete-cet").addEventListener("click", function() {
117
+ document.dispatchEvent(new CustomEvent("pb:dropdown:clearRequest", { detail: { dropdownId: id } }));
118
+ });
119
+ document.getElementById("select-autocomplete-cet").addEventListener("click", function() {
120
+ document.dispatchEvent(new CustomEvent("pb:dropdown:select", { detail: { dropdownId: id, optionId: "pk" } }));
121
+ });
122
+ document.getElementById("simulate-autocomplete-cet").addEventListener("click", function() {
123
+ document.dispatchEvent(new CustomEvent("form:submitted", { detail: { dropdownId: id } }));
124
+ });
125
+ })();
126
+ </script>
127
+
128
+ <!-- Example 4: Quick pick (Date Range) -->
129
+ <%= pb_rails("dropdown", props: {
130
+ custom_event_type: "form:submitted,pb:dropdown:clearRequest",
131
+ id: "dropdown-quickpick-cet",
132
+ label: "Quickpick dropdown",
133
+ margin_bottom: "sm",
134
+ variant: "quickpick",
135
+ }) %>
136
+ <%= pb_rails("flex", props: { wrap: true, gap: "sm", align: "center", margin_bottom: "md" }) do %>
137
+ <%= pb_rails("button", props: { id: "clear-quickpick-cet", text: "Clear", variant: "primary" }) %>
138
+ <%= pb_rails("button", props: { id: "select-quickpick-cet", text: "Select This Week", variant: "secondary" }) %>
139
+ <%= pb_rails("button", props: { id: "simulate-quickpick-cet", text: "Simulate form submit", variant: "secondary" }) %>
140
+ <% end %>
141
+
142
+ <script>
143
+ (function() {
144
+ var id = "dropdown-quickpick-cet";
145
+ document.getElementById("clear-quickpick-cet").addEventListener("click", function() {
146
+ document.dispatchEvent(new CustomEvent("pb:dropdown:clearRequest", { detail: { dropdownId: id } }));
147
+ });
148
+ document.getElementById("select-quickpick-cet").addEventListener("click", function() {
149
+ document.dispatchEvent(new CustomEvent("pb:dropdown:select", { detail: { dropdownId: id, optionId: "quickpick-this-week" } }));
150
+ });
151
+ document.getElementById("simulate-quickpick-cet").addEventListener("click", function() {
152
+ document.dispatchEvent(new CustomEvent("form:submitted", { detail: { dropdownId: id } }));
153
+ });
154
+ })();
155
+ </script>
156
+
157
+ <!-- Example 5: Custom display -->
158
+ <%= pb_rails("dropdown", props: {
159
+ custom_event_type: "form:submitted,pb:dropdown:clearRequest",
160
+ id: "dropdown-custom-display-cet",
161
+ label: "Custom display (Subcomponent) dropdown",
162
+ margin_bottom: "sm",
163
+ options: custom_display_options,
164
+ }) do %>
165
+ <%= pb_rails("dropdown/dropdown_trigger", props: { placeholder: "Select a User", custom_display: custom_display_content }) %>
166
+ <%= pb_rails("dropdown/dropdown_container") do %>
167
+ <% custom_display_options.each do |option| %>
168
+ <%= pb_rails("dropdown/dropdown_option", props: { option: option }) do %>
169
+ <%= pb_rails("flex", props: { align: "center", justify: "between" }) do %>
170
+ <%= pb_rails("flex/flex_item") do %>
171
+ <%= pb_rails("user", props: { name: option[:label], align: "left", avatar: true, orientation: "horizontal" }) %>
172
+ <% end %>
173
+ <%= pb_rails("flex/flex_item") do %>
174
+ <%= pb_rails("badge", props: { rounded: true, dark: true, text: option[:status], variant: option[:status] == "Offline" ? "neutral" : option[:status] == "Online" ? "success" : "warning" }) %>
175
+ <% end %>
176
+ <% end %>
177
+ <% end %>
178
+ <% end %>
179
+ <% end %>
180
+ <% end %>
181
+ <%= pb_rails("flex", props: { wrap: true, gap: "sm", align: "center", margin_bottom: "md" }) do %>
182
+ <%= pb_rails("button", props: { id: "clear-custom-display-cet", text: "Clear", variant: "primary" }) %>
183
+ <%= pb_rails("button", props: { id: "select-custom-display-cet", text: "Select Strong Sad", variant: "secondary" }) %>
184
+ <%= pb_rails("button", props: { id: "simulate-custom-display-cet", text: "Simulate form submit", variant: "secondary" }) %>
185
+ <% end %>
186
+
187
+ <script>
188
+ (function() {
189
+ var id = "dropdown-custom-display-cet";
190
+ document.getElementById("clear-custom-display-cet").addEventListener("click", function() {
191
+ document.dispatchEvent(new CustomEvent("pb:dropdown:clearRequest", { detail: { dropdownId: id } }));
192
+ });
193
+ document.getElementById("select-custom-display-cet").addEventListener("click", function() {
194
+ document.dispatchEvent(new CustomEvent("pb:dropdown:select", { detail: { dropdownId: id, optionId: "strong-sad" } }));
195
+ });
196
+ document.getElementById("simulate-custom-display-cet").addEventListener("click", function() {
197
+ document.dispatchEvent(new CustomEvent("form:submitted", { detail: { dropdownId: id } }));
198
+ });
199
+
200
+ document.addEventListener("pb:dropdown:selected", function(e) {
201
+ if (e.target && e.target.id === id && e.detail) {
202
+ var display = e.target.querySelector("[data-dropdown-trigger-custom-display]");
203
+ if (!display) return;
204
+ var nameEl = display.querySelector("#cet-dropdown-avatar-name");
205
+ if (nameEl) nameEl.textContent = e.detail.label;
206
+ var avatarEl = display.querySelector("#cet-dropdown-avatar");
207
+ if (avatarEl) {
208
+ var wrapper = avatarEl.querySelector(".avatar_wrapper");
209
+ if (wrapper) {
210
+ var initials = (e.detail.label[0] + (e.detail.label.split(" ").pop() || "")[0]).toUpperCase();
211
+ wrapper.dataset.name = e.detail.label;
212
+ wrapper.setAttribute("data-initials", initials);
213
+ }
214
+ }
215
+ var badgeEl = display.querySelector("#cet-dropdown-avatar-status");
216
+ if (badgeEl && e.detail.status) {
217
+ var variant = e.detail.status === "Online" ? "success" : e.detail.status === "Offline" ? "neutral" : "warning";
218
+ badgeEl.querySelector("span").textContent = e.detail.status;
219
+ badgeEl.className = "pb_badge_kit_" + variant;
220
+ }
221
+ }
222
+ });
223
+ })();
224
+ </script>